From ba1b860de9a0ccc239e29715e01111946b00f3dd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 15:56:38 +0000 Subject: [PATCH] Update docs from maps rnmapbox/maps@523479c --- ...Entry-414249083df8a729d1dc5ff38e448274.js} | 28 +++++++++---------- static/example-app/index.html | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) rename static/example-app/_expo/static/js/web/{AppEntry-8ee7a91d23c2a319eaa19a6f225c8b71.js => AppEntry-414249083df8a729d1dc5ff38e448274.js} (75%) diff --git a/static/example-app/_expo/static/js/web/AppEntry-8ee7a91d23c2a319eaa19a6f225c8b71.js b/static/example-app/_expo/static/js/web/AppEntry-414249083df8a729d1dc5ff38e448274.js similarity index 75% rename from static/example-app/_expo/static/js/web/AppEntry-8ee7a91d23c2a319eaa19a6f225c8b71.js rename to static/example-app/_expo/static/js/web/AppEntry-414249083df8a729d1dc5ff38e448274.js index f36f1b1..232f195 100644 --- a/static/example-app/_expo/static/js/web/AppEntry-8ee7a91d23c2a319eaa19a6f225c8b71.js +++ b/static/example-app/_expo/static/js/web/AppEntry-414249083df8a729d1dc5ff38e448274.js @@ -61,7 +61,7 @@ __d((function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule", __d((function(g,r,_i,_a,m,_e,d){Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=function(n){var s,o={},c={};null!=n&&t.call(n.cssRules).forEach(((t,e)=>{var n=t.cssText;if(n.indexOf('stylesheet-group')>-1)s=u(t),o[s]={start:e,rules:[n]};else{var l=a(n);null!=l&&(c[l]=!0,o[s].rules.push(n))}}));function f(t,e,n){var u=l(o),s=u.indexOf(e)+1,a=u[s],c=null!=a&&null!=o[a].start?o[a].start:t.cssRules.length,f=i(t,n,c);if(f){null==o[e].start&&(o[e].start=c);for(var v=s;vl(o).map((t=>{var e=o[t].rules,n=e.shift();return e.sort(),e.unshift(n),e.join('\n')})).join('\n'),insert(t,u){var l=Number(u);if(null==o[l]){var s=e(l);o[l]={start:null,rules:[s]},null!=n&&f(n,l,s)}var i=a(t);null!=i&&null==c[i]&&(c[i]=!0,o[l].rules.push(t),null!=n&&(f(n,l,t)||o[l].rules.pop()))}}};var t=Array.prototype.slice;function e(t){return"[stylesheet-group=\""+t+"\"]{}"}var n=/["']/g;function u(t){return Number(t.selectorText.split(n)[1])}function l(t){return Object.keys(t).map(Number).sort(((t,e)=>t>e?1:-1))}var s=/\s*([,])\s*/g;function a(t){var e=t.split('{')[0].trim();return''!==e?e.replace(s,'$1'):null}function i(t,e,n){try{return t.insertRule(e,n),!0}catch(t){return!1}}}),25,[]); __d((function(g,r,i,a,m,e,d){'use strict';e.createRoot=r(d[0]).createRoot,e.hydrateRoot=r(d[0]).hydrateRoot}),26,[12]); __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 n=t(r(d[1])),i=t(r(d[2])),o=t(r(d[3])),l=["writingDirection"],u=new WeakMap,c=(0,r(d[4]).createSheet)(),f={shadow:!0,textShadow:!0};function s(t,o){void 0===o&&(o={});var c=o,s=c.writingDirection,v=(0,i.default)(c,l),_='rtl'===s;return r(d[5]).styleq.factory({transform(t){var i=u.get(t);return null!=i?(0,r(d[6]).localizeStyle)(i,_):(0,r(d[7]).preprocess)(t,(0,n.default)((0,n.default)({},f),v))}})(t)}function v(t){t.forEach((t=>{var n=t[0],i=t[1];null!=c&&n.forEach((t=>{c.insert(t,i)}))}))}function _(t,n){var i=(0,r(d[8]).classic)(t,n),o=i[0];return v(i[1]),o}var O={position:'absolute',left:0,right:0,top:0,bottom:0},w=h({x:(0,n.default)({},O)}).x;function h(t){return Object.keys(t).forEach((n=>{var i,o,l,c,s=t[n];null!=s&&!0!==s.$$css&&(n.indexOf('$raw')>-1?i=_(s,n.split('$raw')[0]):(o=s,l=(0,r(d[8]).atomic)((0,r(d[7]).preprocess)(o,f)),c=l[0],v(l[1]),i=c),u.set(s,i))})),t}function p(t,n){void 0===n&&(n={});var i='rtl'===n.writingDirection,o=s(t,n);return Array.isArray(o)&&null!=o[1]&&(o[1]=(0,r(d[8]).inline)(o[1],i)),o}p.absoluteFill=w,p.absoluteFillObject=O,p.create=h,p.compose=function(t,n){return[t,n]},p.flatten=function(){for(var t=arguments.length,n=new Array(t),i=0;i=0)continue;n[t]=r[t]}return n},m.exports.__esModule=!0,m.exports.default=m.exports}),28,[]); +__d((function(g,_r,i,a,m,_e,d){m.exports=function(r,e){if(null==r)return{};var n={};for(var t in r)if({}.hasOwnProperty.call(r,t)){if(e.includes(t))continue;n[t]=r[t]}return n},m.exports.__esModule=!0,m.exports.default=m.exports}),28,[]); __d((function(g,r,_i2,a,m,e,d){'use strict';Object.defineProperty(e,"__esModule",{value:!0}),e.styleq=void 0;var l=new WeakMap;function n(n){var s,u,t;return null!=n&&(s=!0===n.disableCache,u=!0===n.disableMix,t=n.transform),function(){for(var n=[],i='',o=null,f=s?null:l,v=new Array(arguments.length),c=0;c0;){var p=v.pop();if(null!=p&&!1!==p)if(Array.isArray(p))for(var y=0;y{s.default.accessToken=t}};e.default=l}),83,[1,84]); -__d((function(e,t,i,r,n,o,s){var a=t(s[0]),l=t(s[1]);const c=["data"];function h(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function u(e){for(var t=1;t0?(i[0]=2*(a*s+h*r+l*o-c*n)/u,i[1]=2*(l*s+h*n+c*r-a*o)/u,i[2]=2*(c*s+h*o+a*n-l*r)/u):(i[0]=2*(a*s+h*r+l*o-c*n),i[1]=2*(l*s+h*n+c*r-a*o),i[2]=2*(c*s+h*o+a*n-l*r)),j(e,t,i),e},O.getTranslation=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},O.getScaling=G,O.getRotation=function(e,t){var i=new F.ARRAY_TYPE(3);G(i,t);var r=1/i[0],n=1/i[1],o=1/i[2],s=t[0]*r,a=t[1]*n,l=t[2]*o,c=t[4]*r,h=t[5]*n,u=t[6]*o,d=t[8]*r,p=t[9]*n,f=t[10]*o,m=s+h+f,_=0;return m>0?(_=2*Math.sqrt(m+1),e[3]=.25*_,e[0]=(u-p)/_,e[1]=(d-l)/_,e[2]=(a-c)/_):s>h&&s>f?(_=2*Math.sqrt(1+s-h-f),e[3]=(u-p)/_,e[0]=.25*_,e[1]=(a+c)/_,e[2]=(d+l)/_):h>f?(_=2*Math.sqrt(1+h-s-f),e[3]=(d-l)/_,e[0]=(a+c)/_,e[1]=.25*_,e[2]=(u+p)/_):(_=2*Math.sqrt(1+f-s-h),e[3]=(a-c)/_,e[0]=(d+l)/_,e[1]=(u+p)/_,e[2]=.25*_),e},O.fromRotationTranslationScale=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3],l=n+n,c=o+o,h=s+s,u=n*l,d=n*c,p=n*h,f=o*c,m=o*h,_=s*h,g=a*l,y=a*c,x=a*h,v=r[0],b=r[1],w=r[2];return e[0]=(1-(f+_))*v,e[1]=(d+x)*v,e[2]=(p-y)*v,e[3]=0,e[4]=(d-x)*b,e[5]=(1-(u+_))*b,e[6]=(m+g)*b,e[7]=0,e[8]=(p+y)*w,e[9]=(m-g)*w,e[10]=(1-(u+f))*w,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e},O.fromRotationTranslationScaleOrigin=function(e,t,i,r,n){var o=t[0],s=t[1],a=t[2],l=t[3],c=o+o,h=s+s,u=a+a,d=o*c,p=o*h,f=o*u,m=s*h,_=s*u,g=a*u,y=l*c,x=l*h,v=l*u,b=r[0],w=r[1],T=r[2],E=n[0],S=n[1],M=n[2],A=(1-(m+g))*b,I=(p+v)*b,C=(f-x)*b,P=(p-v)*w,z=(1-(d+g))*w,D=(_+y)*w,R=(f+x)*T,L=(_-y)*T,k=(1-(d+m))*T;return e[0]=A,e[1]=I,e[2]=C,e[3]=0,e[4]=P,e[5]=z,e[6]=D,e[7]=0,e[8]=R,e[9]=L,e[10]=k,e[11]=0,e[12]=i[0]+E-(A*E+P*S+R*M),e[13]=i[1]+S-(I*E+z*S+L*M),e[14]=i[2]+M-(C*E+D*S+k*M),e[15]=1,e},O.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-u-f,e[1]=h+g,e[2]=d-_,e[3]=0,e[4]=h-g,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+_,e[9]=p-m,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},O.frustum=function(e,t,i,r,n,o,s){var a=1/(i-t),l=1/(n-r),c=1/(o-s);return e[0]=2*o*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(i+t)*a,e[9]=(n+r)*l,e[10]=(s+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*c,e[15]=0,e},O.perspectiveNO=q,O.perspectiveZO=function(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=n*(o=1/(r-n)),e[14]=n*r*o):(e[10]=-1,e[14]=-r),e},O.perspectiveFromFieldOfView=function(e,t,i,r){var n=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),s=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),l=2/(s+a),c=2/(n+o);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=-(s-a)*l*.5,e[9]=(n-o)*c*.5,e[10]=r/(i-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*i/(i-r),e[15]=0,e},O.orthoNO=Z,O.orthoZO=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=o*c,e[15]=1,e},O.lookAt=function(e,t,i,r){var n,o,s,a,l,c,h,u,d,p,f=t[0],m=t[1],_=t[2],g=r[0],y=r[1],x=r[2],v=i[0],b=i[1],w=i[2];return Math.abs(f-v)0&&(h*=p=1/Math.sqrt(p),u*=p,d*=p);var f=l*d-c*u,m=c*h-a*d,_=a*u-l*h;return(p=f*f+m*m+_*_)>0&&(f*=p=1/Math.sqrt(p),m*=p,_*=p),e[0]=f,e[1]=m,e[2]=_,e[3]=0,e[4]=u*_-d*m,e[5]=d*f-h*_,e[6]=h*m-u*f,e[7]=0,e[8]=h,e[9]=u,e[10]=d,e[11]=0,e[12]=n,e[13]=o,e[14]=s,e[15]=1,e},O.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]+")"},O.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])},O.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e[9]=t[9]+i[9],e[10]=t[10]+i[10],e[11]=t[11]+i[11],e[12]=t[12]+i[12],e[13]=t[13]+i[13],e[14]=t[14]+i[14],e[15]=t[15]+i[15],e},O.subtract=$,O.multiplyScalar=function(e,t,i){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]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12]*i,e[13]=t[13]*i,e[14]=t[14]*i,e[15]=t[15]*i,e},O.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e[9]=t[9]+i[9]*r,e[10]=t[10]+i[10]*r,e[11]=t[11]+i[11]*r,e[12]=t[12]+i[12]*r,e[13]=t[13]+i[13]*r,e[14]=t[14]+i[14]*r,e[15]=t[15]+i[15]*r,e},O.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]},O.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=t[0],x=t[1],v=t[2],b=t[3],w=t[4],T=t[5],E=t[6],S=t[7],M=t[8],A=t[9],I=t[10],C=t[11],P=t[12],z=t[13],D=t[14],R=t[15];return Math.abs(i-y)<=F.EPSILON*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-x)<=F.EPSILON*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=F.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(o-b)<=F.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=F.EPSILON*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=F.EPSILON*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=F.EPSILON*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-S)<=F.EPSILON*Math.max(1,Math.abs(c),Math.abs(S))&&Math.abs(h-M)<=F.EPSILON*Math.max(1,Math.abs(h),Math.abs(M))&&Math.abs(u-A)<=F.EPSILON*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(d-I)<=F.EPSILON*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(p-C)<=F.EPSILON*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(f-P)<=F.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(m-z)<=F.EPSILON*Math.max(1,Math.abs(m),Math.abs(z))&&Math.abs(_-D)<=F.EPSILON*Math.max(1,Math.abs(_),Math.abs(D))&&Math.abs(g-R)<=F.EPSILON*Math.max(1,Math.abs(g),Math.abs(R))},O.sub=O.mul=O.ortho=O.perspective=void 0;var F=(function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==B(e)&&"function"!=typeof e)return{default:e};var i=N(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r})(p);function N(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(N=function(e){return e?i:t})(e)}function V(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 U(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*a+b*u+w*m,e[1]=x*n+v*l+b*d+w*_,e[2]=x*o+v*c+b*p+w*g,e[3]=x*s+v*h+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,e[5]=x*n+v*l+b*d+w*_,e[6]=x*o+v*c+b*p+w*g,e[7]=x*s+v*h+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,e[9]=x*n+v*l+b*d+w*_,e[10]=x*o+v*c+b*p+w*g,e[11]=x*s+v*h+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,e[13]=x*n+v*l+b*d+w*_,e[14]=x*o+v*c+b*p+w*g,e[15]=x*s+v*h+b*f+w*y,e}function j(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=r+r,l=n+n,c=o+o,h=r*a,u=r*l,d=r*c,p=n*l,f=n*c,m=o*c,_=s*a,g=s*l,y=s*c;return e[0]=1-(p+m),e[1]=u+y,e[2]=d-g,e[3]=0,e[4]=u-y,e[5]=1-(h+m),e[6]=f+_,e[7]=0,e[8]=d+g,e[9]=f-_,e[10]=1-(h+p),e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}function G(e,t){var i=t[4],r=t[5],n=t[6],o=t[8],s=t[9],a=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(i,r,n),e[2]=Math.hypot(o,s,a),e}function q(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+r)*(o=1/(r-n)),e[14]=2*n*r*o):(e[10]=-1,e[14]=-2*r),e}function Z(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e}function $(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e[9]=t[9]-i[9],e[10]=t[10]-i[10],e[11]=t[11]-i[11],e[12]=t[12]-i[12],e[13]=t[13]-i[13],e[14]=t[14]-i[14],e[15]=t[15]-i[15],e}O.perspective=q,O.ortho=Z,O.mul=U,O.sub=$;var W={},Q={};function H(e){return H="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},H(e)}Object.defineProperty(Q,"__esModule",{value:!0}),Q.create=J,Q.clone=function(e){var t=new X.ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},Q.length=K,Q.fromValues=function(e,t,i){var r=new X.ARRAY_TYPE(3);return r[0]=e,r[1]=t,r[2]=i,r},Q.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},Q.set=function(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e},Q.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e},Q.subtract=ee,Q.multiply=te,Q.divide=ie,Q.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},Q.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},Q.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e},Q.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e},Q.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},Q.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e},Q.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e},Q.distance=re,Q.squaredDistance=ne,Q.squaredLength=oe,Q.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},Q.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},Q.normalize=function(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},Q.dot=se,Q.cross=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e},Q.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e},Q.hermite=function(e,t,i,r,n,o){var s=o*o,a=s*(2*o-3)+1,l=s*(o-2)+o,c=s*(o-1),h=s*(3-2*o);return e[0]=t[0]*a+i[0]*l+r[0]*c+n[0]*h,e[1]=t[1]*a+i[1]*l+r[1]*c+n[1]*h,e[2]=t[2]*a+i[2]*l+r[2]*c+n[2]*h,e},Q.bezier=function(e,t,i,r,n,o){var s=1-o,a=s*s,l=o*o,c=a*s,h=3*o*a,u=3*l*s,d=l*o;return e[0]=t[0]*c+i[0]*h+r[0]*u+n[0]*d,e[1]=t[1]*c+i[1]*h+r[1]*u+n[1]*d,e[2]=t[2]*c+i[2]*h+r[2]*u+n[2]*d,e},Q.random=function(e,t){t=t||1;var i=2*X.RANDOM()*Math.PI,r=2*X.RANDOM()-1,n=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(i)*n,e[1]=Math.sin(i)*n,e[2]=r*t,e},Q.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e},Q.transformMat3=function(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e},Q.transformQuat=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=n*l-o*a,h=o*s-r*l,u=r*a-n*s,d=n*u-o*h,p=o*c-r*u,f=r*h-n*c,m=2*i[3];return h*=m,u*=m,p*=2,f*=2,e[0]=s+(c*=m)+(d*=2),e[1]=a+h+p,e[2]=l+u+f,e},Q.rotateX=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0],o[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),o[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},Q.rotateY=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),o[1]=n[1],o[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},Q.rotateZ=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),o[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),o[2]=n[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},Q.angle=function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2],l=Math.sqrt(i*i+r*r+n*n)*Math.sqrt(o*o+s*s+a*a),c=l&&se(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))},Q.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e},Q.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},Q.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},Q.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(i-o)<=X.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-s)<=X.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-a)<=X.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))},Q.forEach=Q.sqrLen=Q.len=Q.sqrDist=Q.dist=Q.div=Q.mul=Q.sub=void 0;var X=(function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==H(e)&&"function"!=typeof e)return{default:e};var i=Y(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r})(p);function Y(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(Y=function(e){return e?i:t})(e)}function J(){var e=new X.ARRAY_TYPE(3);return X.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function K(e){return Math.hypot(e[0],e[1],e[2])}function ee(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function te(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function ie(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e}function re(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function ne(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}function oe(e){var t=e[0],i=e[1],r=e[2];return t*t+i*i+r*r}function se(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}Q.sub=ee,Q.mul=te,Q.div=ie,Q.dist=re,Q.sqrDist=ne,Q.len=K,Q.sqrLen=oe;var ae,le=(ae=J(),function(e,t,i,r,n,o){var s,a;for(t||(t=3),i||(i=0),a=r?Math.min(r*t+i,e.length):e.length,s=i;s0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e},ce.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},ce.cross=function(e,t,i,r){var n=i[0]*r[1]-i[1]*r[0],o=i[0]*r[2]-i[2]*r[0],s=i[0]*r[3]-i[3]*r[0],a=i[1]*r[2]-i[2]*r[1],l=i[1]*r[3]-i[3]*r[1],c=i[2]*r[3]-i[3]*r[2],h=t[0],u=t[1],d=t[2],p=t[3];return e[0]=u*c-d*l+p*a,e[1]=-h*c+d*s-p*o,e[2]=h*l-u*s+p*n,e[3]=-h*a+u*o-d*n,e},ce.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e[3]=a+r*(i[3]-a),e},ce.random=function(e,t){var i,r,n,o,s,a;t=t||1;do{s=(i=2*ue.RANDOM()-1)*i+(r=2*ue.RANDOM()-1)*r}while(s>=1);do{a=(n=2*ue.RANDOM()-1)*n+(o=2*ue.RANDOM()-1)*o}while(a>=1);var l=Math.sqrt((1-s)/a);return e[0]=t*i,e[1]=t*r,e[2]=t*n*l,e[3]=t*o*l,e},ce.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e},ce.transformQuat=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2],c=i[3],h=c*r+a*o-l*n,u=c*n+l*r-s*o,d=c*o+s*n-a*r,p=-s*r-a*n-l*o;return e[0]=h*c+p*-s+u*-l-d*-a,e[1]=u*c+p*-a+d*-s-h*-l,e[2]=d*c+p*-l+h*-a-u*-s,e[3]=t[3],e},ce.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},ce.str=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},ce.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},ce.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(i-s)<=ue.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-a)<=ue.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-l)<=ue.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-c)<=ue.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},ce.forEach=ce.sqrLen=ce.len=ce.sqrDist=ce.dist=ce.div=ce.mul=ce.sub=void 0;var ue=(function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==he(e)&&"function"!=typeof e)return{default:e};var i=de(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r})(p);function de(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(de=function(e){return e?i:t})(e)}function pe(){var e=new ue.ARRAY_TYPE(4);return ue.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function fe(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}function me(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}function _e(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e[3]=t[3]/i[3],e}function ge(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3])}function ye(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2],o=t[3]-e[3];return i*i+r*r+n*n+o*o}function xe(e){return Math.hypot(e[0],e[1],e[2],e[3])}function ve(e){var t=e[0],i=e[1],r=e[2],n=e[3];return t*t+i*i+r*r+n*n}ce.sub=fe,ce.mul=me,ce.div=_e,ce.dist=ge,ce.sqrDist=ye,ce.len=xe,ce.sqrLen=ve;var be=(function(){var e=pe();return function(t,i,r,n,o,s){var a,l;for(i||(i=4),r||(r=0),l=n?Math.min(n*i+r,t.length):t.length,a=r;aTe.EPSILON?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),i},W.getAngle=function(e,t){var i=Be(e,t);return Math.acos(2*i*i-1)},W.multiply=ze,W.rotateX=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a,e},W.rotateY=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a,e},W.rotateZ=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*a,e[1]=n*l-r*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e},W.calculateW=function(e,t){var i=t[0],r=t[1],n=t[2];return e[0]=i,e[1]=r,e[2]=n,e[3]=Math.sqrt(Math.abs(1-i*i-r*r-n*n)),e},W.exp=De,W.ln=Re,W.pow=function(e,t,i){return Re(e,t),Oe(e,e,i),De(e,e),e},W.slerp=Le,W.random=function(e){var t=Te.RANDOM(),i=Te.RANDOM(),r=Te.RANDOM(),n=Math.sqrt(1-t),o=Math.sqrt(t);return e[0]=n*Math.sin(2*Math.PI*i),e[1]=n*Math.cos(2*Math.PI*i),e[2]=o*Math.sin(2*Math.PI*r),e[3]=o*Math.cos(2*Math.PI*r),e},W.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o,a=s?1/s:0;return e[0]=-i*a,e[1]=-r*a,e[2]=-n*a,e[3]=o*a,e},W.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},W.fromMat3=ke,W.fromEuler=function(e,t,i,r){var n=.5*Math.PI/180;t*=n,i*=n,r*=n;var o=Math.sin(t),s=Math.cos(t),a=Math.sin(i),l=Math.cos(i),c=Math.sin(r),h=Math.cos(r);return e[0]=o*l*h-s*a*c,e[1]=s*a*h+o*l*c,e[2]=s*l*c-o*a*h,e[3]=s*l*h+o*a*c,e},W.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},W.setAxes=W.sqlerp=W.rotationTo=W.equals=W.exactEquals=W.normalize=W.sqrLen=W.squaredLength=W.len=W.length=W.lerp=W.dot=W.scale=W.mul=W.add=W.set=W.copy=W.fromValues=W.clone=void 0;var Te=Ie(p),Ee=Ie(P),Se=Ie(Q),Me=Ie(ce);function Ae(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(Ae=function(e){return e?i:t})(e)}function Ie(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==we(e)&&"function"!=typeof e)return{default:e};var i=Ae(t);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r}function Ce(){var e=new Te.ARRAY_TYPE(4);return Te.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Pe(e,t,i){i*=.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function ze(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*h+s*a+n*c-o*l,e[1]=n*h+s*l+o*a-r*c,e[2]=o*h+s*c+r*l-n*a,e[3]=s*h-r*a-n*l-o*c,e}function De(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=Math.exp(o),l=s>0?a*Math.sin(s)/s:0;return e[0]=i*l,e[1]=r*l,e[2]=n*l,e[3]=a*Math.cos(s),e}function Re(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=s>0?Math.atan2(s,o)/s:0;return e[0]=i*a,e[1]=r*a,e[2]=n*a,e[3]=.5*Math.log(i*i+r*r+n*n+o*o),e}function Le(e,t,i,r){var n,o,s,a,l,c=t[0],h=t[1],u=t[2],d=t[3],p=i[0],f=i[1],m=i[2],_=i[3];return(o=c*p+h*f+u*m+d*_)<0&&(o=-o,p=-p,f=-f,m=-m,_=-_),1-o>Te.EPSILON?(n=Math.acos(o),s=Math.sin(n),a=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(a=1-r,l=r),e[0]=a*c+l*p,e[1]=a*h+l*f,e[2]=a*u+l*m,e[3]=a*d+l*_,e}function ke(e,t){var i,r=t[0]+t[4]+t[8];if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,e[0]=(t[5]-t[7])*(i=.5/i),e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);var o=(n+1)%3,s=(n+2)%3;i=Math.sqrt(t[3*n+n]-t[3*o+o]-t[3*s+s]+1),e[n]=.5*i,e[3]=(t[3*o+s]-t[3*s+o])*(i=.5/i),e[o]=(t[3*o+n]+t[3*n+o])*i,e[s]=(t[3*s+n]+t[3*n+s])*i}return e}W.clone=Me.clone,W.fromValues=Me.fromValues,W.copy=Me.copy,W.set=Me.set,W.add=Me.add,W.mul=ze;var Oe=Me.scale;W.scale=Oe;var Be=Me.dot;W.dot=Be,W.lerp=Me.lerp;var Fe=Me.length;W.length=Fe,W.len=Fe;var Ne=Me.squaredLength;W.squaredLength=Ne,W.sqrLen=Ne;var Ve=Me.normalize;W.normalize=Ve,W.exactEquals=Me.exactEquals,W.equals=Me.equals;var Ue,je,Ge,qe=(Ue=Se.create(),je=Se.fromValues(1,0,0),Ge=Se.fromValues(0,1,0),function(e,t,i){var r=Se.dot(t,i);return r<-.999999?(Se.cross(Ue,je,t),Se.len(Ue)<1e-6&&Se.cross(Ue,Ge,t),Se.normalize(Ue,Ue),Pe(e,Ue,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Se.cross(Ue,t,i),e[0]=Ue[0],e[1]=Ue[1],e[2]=Ue[2],e[3]=1+r,Ve(e,e))});W.rotationTo=qe;var Ze,$e,We=(Ze=Ce(),$e=Ce(),function(e,t,i,r,n,o){return Le(Ze,t,n,o),Le($e,i,r,o),Le(e,Ze,$e,2*o*(1-o)),e});W.sqlerp=We;var Qe,He=(Qe=Ee.create(),function(e,t,i,r){return Qe[0]=i[0],Qe[3]=i[1],Qe[6]=i[2],Qe[1]=r[0],Qe[4]=r[1],Qe[7]=r[2],Qe[2]=-t[0],Qe[5]=-t[1],Qe[8]=-t[2],Ve(e,ke(e,Qe))});W.setAxes=He;var Xe={};function Ye(e){return Ye="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},Ye(e)}Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.create=function(){var e=new Je.ARRAY_TYPE(8);return Je.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},Xe.clone=function(e){var t=new Je.ARRAY_TYPE(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t},Xe.fromValues=function(e,t,i,r,n,o,s,a){var l=new Je.ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=i,l[3]=r,l[4]=n,l[5]=o,l[6]=s,l[7]=a,l},Xe.fromRotationTranslationValues=function(e,t,i,r,n,o,s){var a=new Je.ARRAY_TYPE(8);a[0]=e,a[1]=t,a[2]=i,a[3]=r;var l=.5*n,c=.5*o,h=.5*s;return a[4]=l*r+c*i-h*t,a[5]=c*r+h*e-l*i,a[6]=h*r+l*t-c*e,a[7]=-l*e-c*t-h*i,a},Xe.fromRotationTranslation=rt,Xe.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},Xe.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},Xe.fromMat4=function(e,t){var i=Ke.create();et.getRotation(i,t);var r=new Je.ARRAY_TYPE(3);return et.getTranslation(r,t),rt(e,i,r),e},Xe.copy=nt,Xe.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},Xe.set=function(e,t,i,r,n,o,s,a,l){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e},Xe.getDual=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},Xe.setDual=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},Xe.getTranslation=function(e,t){var i=t[4],r=t[5],n=t[6],o=t[7],s=-t[0],a=-t[1],l=-t[2],c=t[3];return e[0]=2*(i*c+o*s+r*l-n*a),e[1]=2*(r*c+o*a+n*s-i*l),e[2]=2*(n*c+o*l+i*a-r*s),e},Xe.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=.5*i[0],l=.5*i[1],c=.5*i[2],h=t[4],u=t[5],d=t[6],p=t[7];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=s*a+n*c-o*l+h,e[5]=s*l+o*a-r*c+u,e[6]=s*c+r*l-n*a+d,e[7]=-r*a-n*l-o*c+p,e},Xe.rotateX=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=a*s+h*r+l*o-c*n,d=l*s+h*n+c*r-a*o,p=c*s+h*o+a*n-l*r,f=h*s-a*r-l*n-c*o;return Ke.rotateX(e,t,i),e[4]=u*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-u*o,e[6]=p*s+f*o+u*n-d*r,e[7]=f*s-u*r-d*n-p*o,e},Xe.rotateY=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=a*s+h*r+l*o-c*n,d=l*s+h*n+c*r-a*o,p=c*s+h*o+a*n-l*r,f=h*s-a*r-l*n-c*o;return Ke.rotateY(e,t,i),e[4]=u*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-u*o,e[6]=p*s+f*o+u*n-d*r,e[7]=f*s-u*r-d*n-p*o,e},Xe.rotateZ=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=a*s+h*r+l*o-c*n,d=l*s+h*n+c*r-a*o,p=c*s+h*o+a*n-l*r,f=h*s-a*r-l*n-c*o;return Ke.rotateZ(e,t,i),e[4]=u*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-u*o,e[6]=p*s+f*o+u*n-d*r,e[7]=f*s-u*r-d*n-p*o,e},Xe.rotateByQuatAppend=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],h=t[3];return e[0]=a*s+h*r+l*o-c*n,e[1]=l*s+h*n+c*r-a*o,e[2]=c*s+h*o+a*n-l*r,e[3]=h*s-a*r-l*n-c*o,e[4]=(a=t[4])*s+(h=t[7])*r+(l=t[5])*o-(c=t[6])*n,e[5]=l*s+h*n+c*r-a*o,e[6]=c*s+h*o+a*n-l*r,e[7]=h*s-a*r-l*n-c*o,e},Xe.rotateByQuatPrepend=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*h+s*a+n*c-o*l,e[1]=n*h+s*l+o*a-r*c,e[2]=o*h+s*c+r*l-n*a,e[3]=s*h-r*a-n*l-o*c,e[4]=r*(h=i[7])+s*(a=i[4])+n*(c=i[6])-o*(l=i[5]),e[5]=n*h+s*l+o*a-r*c,e[6]=o*h+s*c+r*l-n*a,e[7]=s*h-r*a-n*l-o*c,e},Xe.rotateAroundAxis=function(e,t,i,r){if(Math.abs(r)0){i=Math.sqrt(i);var r=t[0]/i,n=t[1]/i,o=t[2]/i,s=t[3]/i,a=t[4],l=t[5],c=t[6],h=t[7],u=r*a+n*l+o*c+s*h;e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=(a-r*u)/i,e[5]=(l-n*u)/i,e[6]=(c-o*u)/i,e[7]=(h-s*u)/i}return e},Xe.str=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},Xe.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]},Xe.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=t[0],u=t[1],d=t[2],p=t[3],f=t[4],m=t[5],_=t[6],g=t[7];return Math.abs(i-h)<=Je.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(r-u)<=Je.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(n-d)<=Je.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(o-p)<=Je.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(s-f)<=Je.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-m)<=Je.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(l-_)<=Je.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(c-g)<=Je.EPSILON*Math.max(1,Math.abs(c),Math.abs(g))},Xe.sqrLen=Xe.squaredLength=Xe.len=Xe.length=Xe.dot=Xe.mul=Xe.setReal=Xe.getReal=void 0;var Je=it(p),Ke=it(W),et=it(O);function tt(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(tt=function(e){return e?i:t})(e)}function it(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Ye(e)&&"function"!=typeof e)return{default:e};var i=tt(t);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r}function rt(e,t,i){var r=.5*i[0],n=.5*i[1],o=.5*i[2],s=t[0],a=t[1],l=t[2],c=t[3];return e[0]=s,e[1]=a,e[2]=l,e[3]=c,e[4]=r*c+n*l-o*a,e[5]=n*c+o*s-r*l,e[6]=o*c+r*a-n*s,e[7]=-r*s-n*a-o*l,e}function nt(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 ot(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[4],l=i[5],c=i[6],h=i[7],u=t[4],d=t[5],p=t[6],f=t[7],m=i[0],_=i[1],g=i[2],y=i[3];return e[0]=r*y+s*m+n*g-o*_,e[1]=n*y+s*_+o*m-r*g,e[2]=o*y+s*g+r*_-n*m,e[3]=s*y-r*m-n*_-o*g,e[4]=r*h+s*a+n*c-o*l+u*y+f*m+d*g-p*_,e[5]=n*h+s*l+o*a-r*c+d*y+f*_+p*m-u*g,e[6]=o*h+s*c+r*l-n*a+p*y+f*g+u*_-d*m,e[7]=s*h-r*a-n*l-o*c+f*y-u*m-d*_-p*g,e}Xe.getReal=Ke.copy,Xe.setReal=Ke.copy,Xe.mul=ot;var st=Ke.dot;Xe.dot=st;var at=Ke.length;Xe.length=at,Xe.len=at;var lt=Ke.squaredLength;Xe.squaredLength=lt,Xe.sqrLen=lt;var ct={};function ht(e){return ht="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},ht(e)}Object.defineProperty(ct,"__esModule",{value:!0}),ct.create=pt,ct.clone=function(e){var t=new ut.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},ct.fromValues=function(e,t){var i=new ut.ARRAY_TYPE(2);return i[0]=e,i[1]=t,i},ct.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},ct.set=function(e,t,i){return e[0]=t,e[1]=i,e},ct.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e},ct.subtract=ft,ct.multiply=mt,ct.divide=_t,ct.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},ct.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},ct.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e},ct.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e},ct.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},ct.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},ct.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e},ct.distance=gt,ct.squaredDistance=yt,ct.length=xt,ct.squaredLength=vt,ct.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},ct.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},ct.normalize=function(e,t){var i=t[0],r=t[1],n=i*i+r*r;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e},ct.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},ct.cross=function(e,t,i){var r=t[0]*i[1]-t[1]*i[0];return e[0]=e[1]=0,e[2]=r,e},ct.lerp=function(e,t,i,r){var n=t[0],o=t[1];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e},ct.random=function(e,t){t=t||1;var i=2*ut.RANDOM()*Math.PI;return e[0]=Math.cos(i)*t,e[1]=Math.sin(i)*t,e},ct.transformMat2=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n,e[1]=i[1]*r+i[3]*n,e},ct.transformMat2d=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n+i[4],e[1]=i[1]*r+i[3]*n+i[5],e},ct.transformMat3=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[3]*n+i[6],e[1]=i[1]*r+i[4]*n+i[7],e},ct.transformMat4=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e},ct.rotate=function(e,t,i,r){var n=t[0]-i[0],o=t[1]-i[1],s=Math.sin(r),a=Math.cos(r);return e[0]=n*a-o*s+i[0],e[1]=n*s+o*a+i[1],e},ct.angle=function(e,t){var i=e[0],r=e[1],n=t[0],o=t[1],s=Math.sqrt(i*i+r*r)*Math.sqrt(n*n+o*o);return Math.acos(Math.min(Math.max(s&&(i*n+r*o)/s,-1),1))},ct.zero=function(e){return e[0]=0,e[1]=0,e},ct.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},ct.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ct.equals=function(e,t){var i=e[0],r=e[1],n=t[0],o=t[1];return Math.abs(i-n)<=ut.EPSILON*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(r-o)<=ut.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))},ct.forEach=ct.sqrLen=ct.sqrDist=ct.dist=ct.div=ct.mul=ct.sub=ct.len=void 0;var ut=(function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==ht(e)&&"function"!=typeof e)return{default:e};var i=dt(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r})(p);function dt(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(dt=function(e){return e?i:t})(e)}function pt(){var e=new ut.ARRAY_TYPE(2);return ut.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function ft(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function mt(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e}function _t(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e}function gt(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function yt(e,t){var i=t[0]-e[0],r=t[1]-e[1];return i*i+r*r}function xt(e){return Math.hypot(e[0],e[1])}function vt(e){var t=e[0],i=e[1];return t*t+i*i}ct.len=xt,ct.sub=ft,ct.mul=mt,ct.div=_t,ct.dist=gt,ct.sqrDist=yt,ct.sqrLen=vt;var bt=(function(){var e=pt();return function(t,i,r,n,o,s){var a,l;for(i||(i=2),r||(r=0),l=n?Math.min(n*i+r,t.length):t.length,a=r;a1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var Bt=u(kt),Ft=Nt;function Nt(e,t){this.x=e,this.y=t}Nt.prototype={clone:function(){return new Nt(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,i=e.y-this.y;return t*t+i*i},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),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround:function(e,t){var i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Nt.convert=function(e){return e instanceof Nt?e:Array.isArray(e)?new Nt(e[0],e[1]):e};var Vt=u(Ft);const Ut=Math.PI/180,jt=180/Math.PI;function Gt(e){return e*Ut}function qt(e){return e*jt}const Zt=[[0,0],[1,0],[1,1],[0,1]];function $t(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function Wt(e,t,i,r){const n=new Bt(e,t,i,r);return function(e){return n.solve(e)}}const Qt=Wt(.25,.1,.25,1);function Ht(e,t,i){return Math.min(i,Math.max(t,e))}function Xt(e,t,i){return(i=Ht((i-e)/(t-e),0,1))*i*(3-2*i)}function Yt(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function Jt(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach(((e,s)=>{t(e,((e,t)=>{e&&(o=e),n[s]=t,0==--r&&i(o,n)}))}))}function Kt(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let ei=1;function ti(){return ei++}function ii(){return(function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e)})()}function ri(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function ni(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)}function oi(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function si(e,t){return-1!==e.indexOf(t,e.length-t.length)}function ai(e,t,i){const r={};for(const i in e)r[i]=t.call(this,e[i],i,e);return r}function li(e,t,i){const r={};for(const i in e)t.call(this,e[i],i,e)&&(r[i]=e[i]);return r}function ci(e){return Array.isArray(e)?e.map(ci):"object"==typeof e&&e?ai(e,ci):e}const hi={};function ui(e){hi[e]||("undefined"!=typeof console&&console.warn(e),hi[e]=!0)}function di(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function pi(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let gi,yi,xi,vi,bi,wi,Ti=null;function Ei(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function Si(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function Mi(e,t,i,r){for(;t>1;e[n]>1;e[n]<=r?t=n+1:i=n}return t}function Ii(e){return e>0?1/(1.001-e):1+e}function Ci(e){return e>0?1-1/(1.001-e):-e}function Pi(){return null==gi&&(gi=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),gi}const zi={now:()=>void 0!==vi?vi:performance.now(),setNow(e){vi=e},restoreNow(){vi=void 0},frame(e){const t=requestAnimationFrame(e);return{cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:r}=e;bi||(bi=document.createElement("canvas"));const n=bi.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return(i>bi.width||r>bi.height)&&(bi.width=i,bi.height=r),n.clearRect(-t,-t,i+2*t,r+2*t),n.drawImage(e,0,0,i,r),n.getImageData(-t,-t,i+2*t,r+2*t)},resolveURL:e=>(yi||(yi=document.createElement("a")),yi.href=e,yi.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==xi&&(xi=window.matchMedia("(prefers-reduced-motion: reduce)")),xi.matches)},hasCanvasFingerprintNoise(){if(void 0!==wi)return wi;if(!Pi())return wi=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let i=0;for(let r=0;r0?`?${o}`:""}`}const Li="mapbox-tiles";let ki,Oi,Bi=500,Fi=50;function Ni(){try{return caches}catch(e){}}function Vi(){const e=Ni();e&&!ki&&(ki=e.open(Li))}let Ui=1/0;const ji={supported:!1,testSupport:function(e){!Zi&&qi&&($i?Qi(e):Gi=e)}};let Gi,qi,Zi=!1,$i=!1;const Wi="undefined"!=typeof self?self:{};function Qi(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,qi),e.isContextLost())return;ji.supported=!0}catch(e){}e.deleteTexture(t),Zi=!0}Wi.document&&(qi=Wi.document.createElement("img"),qi.onload=function(){Gi&&Qi(Gi),Gi=null,$i=!0},qi.onerror=function(){Zi=!0,Gi=null},qi.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Hi={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Hi);class Xi extends Error{constructor(e,t,i){401===t&&n(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Yi=mi()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,Ji=function(e,t){if(!(/^file:/.test(i=e.url)||/^file:/.test(Yi())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return(function(e,t){const i=new AbortController,r=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Yi(),referrerPolicy:e.referrerPolicy,signal:i.signal});let o=!1,s=!1;const a=(l=r.url).indexOf("sku=")>0&&n(l);var l;"json"===e.type&&r.headers.set("Accept","application/json");const c=(i,n,o)=>{if(s)return;if(i&&"SecurityError"!==i.message&&ui(i.toString()),n&&o)return h(n);const l=Date.now();fetch(r).then((i=>{if(i.ok){const e=a?i.clone():null;return h(i,e,l)}return t(new Xi(i.statusText,i.status,e.url))})).catch((i=>{"AbortError"!==i.name&&t(new Error(`${i.message} ${e.url}`))}))},h=(i,n,a)=>{("arrayBuffer"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text()).then((e=>{s||(n&&a&&(function(e,t,i){if(Vi(),!ki)return;const r=_i(t.headers.get("Cache-Control")||"");if(r["no-store"])return;const n={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach(((e,t)=>n.headers.set(t,e))),r["max-age"]&&n.headers.set("Expires",new Date(i+1e3*r["max-age"]).toUTCString());const o=n.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-i<42e4)return;let s=Ri(e.url,{persistentParams:["language","worldview"]});if(206===t.status){const t=e.headers.get("Range");if(!t)return;n.status=200,s=Di(s,{range:t})}!(function(e,t){if(void 0===Oi)try{new Response(new ReadableStream),Oi=!0}catch(e){Oi=!1}Oi?t(e.body):e.blob().then(t)})(t,(e=>{const t=new Response(e,n);Vi(),ki&&ki.then((e=>e.put(s,t))).catch((e=>ui(e.message)))}))})(r,n,a),o=!0,t(null,e,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((e=>{s||t(new Error(e.message))}))};return a?(function(e,t){if(Vi(),!ki)return t(null);ki.then((i=>{let r=Ri(e.url,{persistentParams:["language","worldview"]});const n=e.headers.get("Range");n&&(r=Di(r,{range:n})),i.match(r).then((e=>{const n=(function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=_i(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]})(e);i.delete(r),n&&i.put(r,e.clone()),t(null,e,n)})).catch(t)})).catch(t)})(r,c):c(null,null),{cancel:()=>{s=!0,o||i.abort()}}})(e,t);if(mi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var i;return(function(e,t){const i=new XMLHttpRequest;i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=()=>{t(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===e.type)try{r=JSON.parse(i.response)}catch(e){return t(e)}t(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else t(new Xi(i.statusText,i.status,e.url))},i.send(e.body),{cancel:()=>i.abort()}})(e,t)},Ki=function(e,t){return Ji(Kt(e,{type:"arrayBuffer"}),t)};function er(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}const tr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let ir,rr;ir=[],rr=0;const nr=function(e,t){if(ji.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),rr>=r.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return ir.push(i),i}rr++;let i=!1;const n=()=>{if(!i)for(i=!0,rr--;ir.length&&rr{n(),e?t(e):i&&(self.createImageBitmap?(function(e,t){const i=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(i).then((e=>{t(null,e)})).catch((e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))})(i,((e,i)=>t(e,i,r,o))):(function(e,t){const i=new Image;i.onload=()=>{t(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame((()=>{i.src=tr}))},i.onerror=()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const r=new Blob([new Uint8Array(e)],{type:"image/png"});i.src=e.byteLength?URL.createObjectURL(r):tr})(i,((e,i)=>t(e,i,r,o))))}));return{cancel:()=>{o.cancel(),n()}}},or="01",sr="NO_ACCESS_TOKEN",ar=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function lr(e){const t=e.match(ar);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 cr(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const hr="mapbox.eventData";function ur(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(atob(t[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class dr{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=ur(r.ACCESS_TOKEN);let i="";return i=t&&t.u?btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):r.ACCESS_TOKEN||"",e?`${hr}.${e}:${i}`:`${hr}:${i}`}fetchEventData(){const e=Ei("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{const e=localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const r=localStorage.getItem(i);r&&(this.anonId=r)}catch(e){ui("Unable to read from LocalStorage")}}saveEventData(){const e=Ei("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid"),r=this.anonId;if(e&&r)try{localStorage.setItem(i,r),Object.keys(this.eventData).length>=1&&localStorage.setItem(t,JSON.stringify(this.eventData))}catch(e){ui("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,i,n){if(!r.EVENTS_URL)return;const o=lr(r.EVENTS_URL);o.params.push(`access_token=${n||r.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(e).toISOString()},a=t?Kt(s,t):s,l={url:cr(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=(function(e,t){return Ji(Kt(e,{method:"POST"}),t)})(l,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(n)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const pr=new class extends dr{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){r.EVENTS_URL&&r.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>o(e)||n(e)))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const i=ur(r.ACCESS_TOKEN),n=i?i.u:r.ACCESS_TOKEN;let o=n!==this.eventData.tokenU;ni(this.anonId)||(this.anonId=ii(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||e.getDate()!==t.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:or,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=n)}),e):this.processRequests()}},fr=pr.postTurnstileEvent.bind(pr),mr=new class extends dr{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,n){this.skuToken=t,this.errorCb=n,r.EVENTS_URL&&(i||r.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(sr)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:i,timestamp:r}=this.queue.shift();i&&this.success[i]||(this.anonId||this.fetchEventData(),ni(this.anonId)||(this.anonId=ii()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:or,skuToken:this.skuToken,userId:this.anonId},(e=>{e?this.errorCb(e):i&&(this.success[i]=!0)}),e))}remove(){this.errorCb=null}},_r=mr.postMapLoadEvent.bind(mr),gr=new class extends dr{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(e){let t=this.mapInstanceIdMap.get(e);return t||(t=ii(),this.mapInstanceIdMap.set(e,t)),t}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:i,style:n,importedStyles:o}=t;if(!r.EVENTS_URL||!e&&!r.ACCESS_TOKEN)return;const s=this.getMapInstanceId(i),a={mapInstanceId:s,eventId:this.getEventId(s),style:n};o.length&&(a.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:a},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,(()=>{}),e)}},yr=gr.postStyleLoadEvent.bind(gr),xr=new class extends dr{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){r.EVENTS_URL&&(e||r.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:i,performanceData:r}=this.queue.shift(),n=(function(e){const i=performance.getEntriesByType("resource"),r=performance.getEntriesByType("mark"),n=(function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const r of e[i]){const e=`${i}ResolveRangeMin`,n=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,r.startTime),t[n]=Math.max(t[n]||-1/0,r.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==r.transferSize&&0===r.transferSize&&a(s),a(o)}return t})((function(e,t){const i={};if(e)for(const r of e){const e=t(r);void 0===i[e]&&(i[e]=[]),i[e].push(r)}return i})(i,h)),o=window.devicePixelRatio,s=navigator.connection||navigator.mozConnection||navigator.webkitConnection,a=s?s.effectiveType:void 0,u={counters:[],metadata:[],attributes:[]},d=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()})};for(const e in n)d(u.counters,e,n[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(d(u.counters,"interactionRangeMin",e.interactionRange[0]),d(u.counters,"interactionRangeMax",e.interactionRange[1])),r)for(const e of Object.keys(c)){const t=c[e],i=r.find((e=>e.name===t));i&&d(u.counters,t,i.startTime)}return d(u.counters,"visibilityHidden",e.visibilityHidden),d(u.attributes,"style",(function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(l(e)){const t=e.split("/").slice(-2);if(2===t.length)return`mapbox://styles/${t[0]}/${t[1]}`}}})(i)),d(u.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),d(u.attributes,"fogEnabled",e.fogEnabled?"true":"false"),d(u.attributes,"projection",e.projection),d(u.attributes,"zoom",e.zoom),d(u.metadata,"devicePixelRatio",o),d(u.metadata,"connectionEffectiveType",a),d(u.metadata,"navigatorUserAgent",navigator.userAgent),d(u.metadata,"screenWidth",window.screen.width),d(u.metadata,"screenHeight",window.screen.height),d(u.metadata,"windowWidth",window.innerWidth),d(u.metadata,"windowHeight",window.innerHeight),d(u.metadata,"mapWidth",e.width/o),d(u.metadata,"mapHeight",e.height/o),d(u.metadata,"webglRenderer",e.renderer),d(u.metadata,"webglVendor",e.vendor),d(u.metadata,"sdkVersion",t),d(u.metadata,"sdkIdentifier","mapbox-gl-js"),u})(r);for(const e of n.metadata);for(const e of n.counters);for(const e of n.attributes);this.postEvent(i,n,(()=>{}),e)}},vr=xr.postPerformanceEvent.bind(xr),br=new class extends dr{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,n){if(!r.API_URL||!r.SESSION_PATH)return;const o=lr(r.API_URL+r.SESSION_PATH);o.params.push(`sku=${t||""}`),o.params.push(`access_token=${n||r.ACCESS_TOKEN||""}`);const s={url:cr(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=(function(e,t){return Ji(Kt(e,{method:"GET"}),t)})(s,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(n)}))}getSessionAPI(e,t,i,n){this.skuToken=t,this.errorCb=n,r.SESSION_PATH&&r.API_URL&&(i||r.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(sr)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e)}remove(){this.errorCb=null}},wr=br.getSessionAPI.bind(br),Tr=new Set;var Er={exports:{}},Sr={exports:{}};Sr.exports=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&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};var Mr=Sr.exports,Ar={exports:{}};Ar.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0};var Ir=Mr,Cr=Ar.exports;Er.exports=Ir,Er.exports.murmur3=Ir,Er.exports.murmur2=Cr;var Pr=u(Er.exports);function zr(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function Dr(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class Rr{constructor(e,t={}){Kt(this,t),this.type=e}}class Lr extends Rr{constructor(e,t={}){super("error",Kt({error:e},t))}}class kr{on(e,t){return this._listeners=this._listeners||{},zr(e,t,this._listeners),this}off(e,t){return Dr(e,t,this._listeners),Dr(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},zr(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new Rr(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of r)Dr(i,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(Kt(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof Lr&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}e.z=void 0;var Or={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 Br(e){return(e=Math.round(e))<0?0:e>255?255:e}function Fr(e){return Br("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function Nr(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function Vr(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(.6666666666666666-i)*6:e}try{e.z={}.parseCSSColor=function(e){var t,i=e.replace(/ /g,"").toLowerCase();if(i in Or)return Or[i].slice();if("#"===i[0])return 4===i.length?(t=parseInt(i.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===i.length&&(t=parseInt(i.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=i.indexOf("("),n=i.indexOf(")");if(-1!==r&&n+1===i.length){var o=i.substr(0,r),s=i.substr(r+1,n-(r+1)).split(","),a=1;switch(o){case"rgba":if(4!==s.length)return null;a=Nr(s.pop());case"rgb":return 3!==s.length?null:[Fr(s[0]),Fr(s[1]),Fr(s[2]),a];case"hsla":if(4!==s.length)return null;a=Nr(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,c=Nr(s[1]),h=Nr(s[2]),u=h<=.5?h*(c+1):h+c-h*c,d=2*h-u;return[Br(255*Vr(d,u,l+.3333333333333333)),Br(255*Vr(d,u,l)),Br(255*Vr(d,u,l-.3333333333333333)),a];default:return null}}return null}}catch(e){}class Ur{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof Ur)return t;if("string"!=typeof t)return;const i=e.z(t);return i?new Ur(i[0]/255*i[3],i[1]/255*i[3],i[2]/255*i[3],i[3]):void 0}toString(){const[e,t,i,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${r})`}toArray(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*i/r,r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,i/r,r]}toArray01Scaled(e){const{r:t,g:i,b:r,a:n}=this;return 0===n?[0,0,0]:[t/n*e,i/n*e,r/n*e]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:r}=this;return[e,t,i,r]}toArray01Linear(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[Math.pow(e/r,2.2),Math.pow(t/r,2.2),Math.pow(i/r,2.2),r]}}function jr(e,t,i){return e*(1-i)+t*i}function Gr(e,t,i){return e.map(((e,r)=>jr(e,t[r],i)))}Ur.black=new Ur(0,0,0,1),Ur.white=new Ur(1,1,1,1),Ur.transparent=new Ur(0,0,0,0),Ur.red=new Ur(1,0,0,1),Ur.blue=new Ur(0,0,1,1);var qr=Object.freeze({__proto__:null,array:Gr,color:function(e,t,i){return new Ur(jr(e.r,t.r,i),jr(e.g,t.g,i),jr(e.b,t.b,i),jr(e.a,t.a,i))},number:jr});function Zr(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}class $r extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Wr{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Wr(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Qr={kind:"null"},Hr={kind:"number"},Xr={kind:"string"},Yr={kind:"boolean"},Jr={kind:"color"},Kr={kind:"object"},en={kind:"value"},tn={kind:"collator"},rn={kind:"formatted"},nn={kind:"resolvedImage"};function on(e,t){return{kind:"array",itemType:e,N:t}}function sn(e){if("array"===e.kind){const t=sn(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const an=[Qr,Hr,Xr,Yr,Jr,rn,Kr,on(en),nn];function ln(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!ln(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of an)if(!ln(e,t))return null}return`Expected ${sn(e)} but found ${sn(t)} instead.`}function cn(e,t){return t.some((t=>t.kind===e.kind))}function hn(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}class un{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class dn{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n}}class pn{constructor(e){this.sections=e}static fromString(e){return new pn([new dn(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.namePrimary.length))}static factory(e){return e instanceof pn?e:pn.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.namePrimary]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(i)}return e}}class fn{constructor(e){this.namePrimary=e.namePrimary,e.nameSecondary&&(this.nameSecondary=e.nameSecondary),this.available=e.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(e,t){return e?new fn({namePrimary:e,nameSecondary:t,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function mn(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function _n(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 Ur)return!0;if(e instanceof un)return!0;if(e instanceof pn)return!0;if(e instanceof fn)return!0;if(Array.isArray(e)){for(const t of e)if(!_n(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!_n(e[t]))return!1;return!0}return!1}function gn(e){if(null===e)return Qr;if("string"==typeof e)return Xr;if("boolean"==typeof e)return Yr;if("number"==typeof e)return Hr;if(e instanceof Ur)return Jr;if(e instanceof un)return tn;if(e instanceof pn)return rn;if(e instanceof fn)return nn;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=gn(t);if(i){if(i===e)continue;i=en;break}i=e}return on(i||en,t)}return Kr}function yn(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ur||e instanceof pn||e instanceof fn?e.toString():JSON.stringify(e)}class xn{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!_n(e[1]))return t.error("invalid value");const i=e[1];let r=gn(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new xn(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Ur?["rgba"].concat(this.value.toArray()):this.value instanceof pn?this.value.serialize():this.value}}class vn{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const bn={string:Xr,number:Hr,boolean:Yr,object:Kr};class wn{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in bn)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=bn[i],r++}else n=en;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}i=on(n,o)}else i=bn[n];const o=[];for(;re.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map((e=>e.serialize())))}}class Tn{constructor(e){this.type=rn,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,Hr),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,on(Xr)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,Jr),!s))return null;const a=r[r.length-1];a.scale=e,a.font=i,a.textColor=s}else{const o=t.parse(e[i],1,en);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new Tn(r)}evaluate(e){return new pn(this.sections.map((t=>{const i=t.content.evaluate(e);return gn(i)===nn?new dn("",i,null,null,null):new dn(yn(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class En{constructor(e,t){this.type=nn,this.inputPrimary=e,this.inputSecondary=t}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");const i=t.parse(e[1],1,Xr);if(!i)return t.error("No image name provided.");if(2===e.length)return new En(i);const r=t.parse(e[2],1,Xr);return r?new En(i,r):t.error("Secondary image variant is not a string.")}evaluate(e){const t=fn.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return t&&e.availableImages&&(t.available=e.availableImages.indexOf(t.namePrimary)>-1,t.nameSecondary&&t.available&&e.availableImages&&(t.available=e.availableImages.indexOf(t.nameSecondary)>-1)),t}eachChild(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function Sn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}const Mn={"to-boolean":Yr,"to-color":Jr,"to-number":Hr,"to-string":Xr};class An{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0],r=[];let n=Qr;if("to-array"===i){if(!Array.isArray(e[1]))return null;const i=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);n=on(t.expectedType.itemType,i)}else{if(!(i>0&&_n(e[1][0])))return null;n=on(gn(e[1][0]),i)}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:mn(t[0],t[1],t[2],t[3]),!i))return new Ur(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new vn(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new vn(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?pn.fromString(yn(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?fn.fromString(yn(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map((t=>t.evaluate(e))):yn(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Tn([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new En(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize())})),e}}const In=["Unknown","Point","LineString","Polygon"];class Cn{constructor(e,t){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?In[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Ur.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class Pn{constructor(e,t,i,r,n){this.name=e,this.type=t,this._evaluate=i,this.args=r,this._overloadIndex=n}evaluate(e){if(!this._evaluate){const e=Pn.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1]}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const i=e[0],r=Pn.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=[];let a=null,l=-1;for(const[r,c]of o){if(Array.isArray(r)&&r.length!==e.length-1)continue;s.push(r),l++,a=new qo(t.registry,t.path,null,t.scope,void 0,t._scope,t.options);const o=[];let h=!1;for(let t=1;te))).map(zn).join(" | "),r=[];for(let i=1;in;){if(o-n>600){var a=o-n+1,l=r-n+1,c=Math.log(a),h=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*h*(a-h)/a)*(l-a/2<0?-1:1);e(i,r,Math.max(n,Math.floor(r-l*h/a+u)),Math.min(o,Math.floor(r+(a-l)*h/a+u)),s)}var d=i[r],p=n,f=o;for(t(i,n,r),s(i[o],d)>0&&t(i,n,o);p0;)f--}0===s(i[n],d)?t(i,n,f):t(i,++f,o),f<=r&&(n=f+1),r<=f&&(o=f-1)}}function t(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function i(e,t){return et?1:0}return function(t,r,n,o,s){e(t,r,n||0,o||t.length-1,s||i)}})();var Ln=u(Rn.exports);function kn(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Fn(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Nn(e,t,i=!1){let r=!1;for(let a=0,l=t.length;a(n=e)[1]!=(s=h)[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}}var n,o,s;return r}function Vn(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(e[0]-i[0])*o-n*(e[1]-i[1]),a=(t[0]-i[0])*o-n*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Un(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*o[0]&&!(!Vn(e,t,i,r)||!Vn(i,r,e,t));var n,o}const jn=8192;function Gn(e,t){const i=(180+e[0])/360,r=(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(i*n*jn),Math.round(r*n*jn)]}function qn(e,t){for(let i=0;ii[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}On(t,e)}function Yn(e,t,i,r){const n=Math.pow(2,r.z)*jn,o=[r.x*jn,r.y*jn],s=[];if(!e)return s;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];Xn(r,t,i,n),s.push(r)}return s}function Jn(e,t,i,r){const n=Math.pow(2,r.z)*jn,o=[r.x*jn,r.y*jn],s=[];if(!e)return s;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];On(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)Xn(r,t,i,n)}var a;return s}class Kn{constructor(e,t){this.type=Yr,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(_n(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e180;)e-=360;return e}return i.fromTile=function(e,r,n){var o=Math.PI*(1-2*(e+.5)/Math.pow(2,r)),s=Math.atan(.5*(Math.exp(o)-Math.exp(-o)))/t;return new i(s,n)},r.units.get=function(){return e},i.prototype.distance=function(e,t){var i=s(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)},i.prototype.bearing=function(e,i){var r=s(i[0]-e[0])*this.kx;return Math.atan2(r,(i[1]-e[1])*this.ky)/t},i.prototype.destination=function(e,i,r){var n=r*t;return this.offset(e,Math.sin(n)*i,Math.cos(n)*i)},i.prototype.offset=function(e,t,i){return[e[0]+t/this.kx,e[1]+i/this.ky]},i.prototype.lineDistance=function(e){for(var t=0,i=0;it)return o(n,s,(t-(i-a))/a)}return e[e.length-1]},i.prototype.pointToSegmentDistance=function(e,t,i){var r=t[0],n=t[1],o=s(i[0]-r)*this.kx,a=(i[1]-n)*this.ky,l=0;return 0===o&&0===a||((l=(s(e[0]-r)*this.kx*o+(e[1]-n)*this.ky*a)/(o*o+a*a))>1?(r=i[0],n=i[1]):l>0&&(r+=o/this.kx*l,n+=a/this.ky*l)),o=s(e[0]-r)*this.kx,a=(e[1]-n)*this.ky,Math.sqrt(o*o+a*a)},i.prototype.pointOnLine=function(e,t){for(var i,r,n,o,a=1/0,l=0;l1?(c=e[l+1][0],h=e[l+1][1]):p>0&&(c+=u/this.kx*p,h+=d/this.ky*p));var f=(u=s(t[0]-c)*this.kx)*u+(d=(t[1]-h)*this.ky)*d;fo.index||r.index===o.index&&r.t>o.t){var s=r;r=o,o=s}var a=[r.point],l=r.index+1,c=o.index;!n(i[l],a[0])&&l<=c&&a.push(i[l]);for(var h=l+1;h<=c;h++)a.push(i[h]);return n(i[c],o.point)||a.push(o.point),a},i.prototype.lineSliceAlong=function(e,t,i){for(var r=0,n=[],s=0;se&&0===n.length&&n.push(o(a,l,(e-(r-c))/c)),r>=t)return n.push(o(a,l,(t-(r-c))/c)),n;r>e&&n.push(l)}return n},i.prototype.bufferPoint=function(e,t){var i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[0]+r,e[1]+i]},i.prototype.bufferBBox=function(e,t){var i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[2]+r,e[3]+i]},i.prototype.insideBBox=function(e,t){return s(e[0]-t[0])>=0&&s(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]},Object.defineProperties(i,r),i})()})(eo);var to=u(eo.exports),io={exports:{}};!(function(e,t){e.exports=(function(){var e=function(e,i){if(void 0===e&&(e=[]),void 0===i&&(i=t),this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)};function t(e,t){return et?1:0}return e.prototype.push=function(e){this.data.push(e),this.length++,this._up(this.length-1)},e.prototype.pop=function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}},e.prototype.peek=function(){return this.data[0]},e.prototype._up=function(e){for(var t=this.data,i=this.compare,r=t[e];e>0;){var n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r},e.prototype._down=function(e){for(var t=this.data,i=this.compare,r=this.length>>1,n=t[e];e=0)break;t[e]=s,e=o}t[e]=n},e})()})(io);var ro=u(io.exports),no=8192;function oo(e,t){return t.dist-e.dist}const so=100,ao=50;function lo(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(let i=0;i=e[0]&&e[1]e[1])return[null,null];const i=co(e);if(t){if(2===i)return[e,null];const t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===i)return[e,null];const t=Math.floor(i/2)-1;return[[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function po(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!ho(t,e.length))return i;for(let r=t[0];r<=t[1];++r)On(i,e[r]);return i}function fo(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;it[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]=r)return r;if(Bn(n,o)){if(Ao(e,t))return 0}else if(Ao(t,e))return 0;let s=r;for(const r of e)for(let e=0,n=r.length,o=n-1;e=o)continue;const c=n.range1;if(co(c)<=a){if(!ho(c,e.length))return NaN;if(t){const t=Mo(e,c,i,r);if(0===(o=Math.min(o,t)))return o}else for(let t=c[0];t<=c[1];++t){const n=So(e[t],i,r);if(0===(o=Math.min(o,n)))return o}}else{const i=uo(c,t);if(null!==i[0]){const t=mo(po(e,i[0]),l,r);t=s)continue;const h=o.range1,u=o.range2;if(co(h)<=l&&co(u)<=c){if(!ho(h,e.length)||!ho(u,i.length))return NaN;if(t&&r?s=Math.min(s,To(e,h,i,u,n)):t||r?t&&!r?s=Math.min(s,bo(i,u,e,h,n)):!t&&r&&(s=Math.min(s,bo(e,h,i,u,n))):s=Math.min(s,Eo(e,h,i,u,n)),0===s)return s}else{const o=uo(h,t),l=uo(u,r);Co(a,s,n,e,i,o[0],l[0]),Co(a,s,n,e,i,o[0],l[1]),Co(a,s,n,e,i,o[1],l[0]),Co(a,s,n,e,i,o[1],l[1])}}return s}function Do(e,t,i,r,n=1/0){let o=n;const s=po(e,[0,e.length-1]);for(const n of i)if(!(o!==1/0&&mo(s,po(n,[0,n.length-1]),r)>=o)&&(o=Math.min(o,zo(e,t,n,!0,r,o)),0===o))return o;return o}function Ro(e,t,i,r,n=1/0){let o=n;const s=po(e,[0,e.length-1]);for(const n of i){if(o!==1/0&&mo(s,fo(n),r)>=o)continue;const i=Po(e,t,n,r,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function Lo(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class ko{constructor(e,t){this.type=Hr,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(_n(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;ei&&(e=i),e}class Fo{constructor(e,t,i){this.type=e,this.key=t,this.scope=i}static parse(e,t){let i=t.expectedType;if(null==i&&(i=en),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const r=t.parse(e[1],1);if(!(r instanceof xn))return t.error("Key name of 'config' expression must be a string literal.");if(e.length>=3){const n=t.parse(e[2],2);return n instanceof xn?new Fo(i,yn(r.value),yn(n.value)):t.error("Scope of 'config' expression must be a string literal.")}return new Fo(i,yn(r.value))}evaluate(e){const t=[this.key,this.scope,e.scope].filter(Boolean).join("\x1f"),i=e.getConfig(t);if(!i)return null;const{type:r,value:n,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(e);let h=c;if(n){const t=e.scope;e.scope=(t||"").split("\x1f").slice(1).join("\x1f"),h=n.evaluate(e),e.scope=t}return r&&(h=Oo(r,h)),void 0===h||void 0===s&&void 0===a&&void 0===l||("number"==typeof h?h=Bo(h,s,a,l):Array.isArray(h)&&(h=h.map((e=>"number"==typeof e?Bo(e,s,a,l):e)))),void 0!==n&&void 0!==h&&o&&!o.includes(h)&&(h=c,r&&(h=Oo(r,h))),(r&&r!==this.type||void 0!==h&&gn(h)!==this.type)&&(h=Oo(this.type.kind,h)),h}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.key),e}}function No(e){if(e instanceof Pn){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 Kn)return!1;if(e instanceof ko)return!1;let t=!0;return e.eachChild((e=>{t&&!No(e)&&(t=!1)})),t}function Vo(e){if(e instanceof Pn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!Vo(e)&&(t=!1)})),t}function Uo(e){if(e instanceof Fo)return!1;let t=!0;return e.eachChild((e=>{t&&!Uo(e)&&(t=!1)})),t}function jo(e,t){if(e instanceof Pn&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild((e=>{i&&!jo(e,t)&&(i=!1)})),i}class Go{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new Go(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class qo{constructor(e,t=[],i,r=new Wr,n=[],o,s){this.registry=e,this.path=t,this.key=t.map((e=>`[${e}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i,this._scope=o,this.options=s}parse(e,t,i,r,n={}){return t||i?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return"assert"===i?new wn(t,[e]):"coerce"===i?new An(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r="string"==typeof e[0]?this.registry[e[0]]:void 0;if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"coerce");else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof xn)&&"resolvedImage"!==n.type.kind&&Zo(n)){const t=new Cn(this._scope,this.options);try{n=new xn(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return An.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new qo(this.registry,r,t||null,n,this.errors,this._scope,this.options)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new $r(i,e))}checkSubtype(e,t){const i=ln(e,t);return i&&this.error(i),i}}function Zo(e){if(e instanceof Go)return Zo(e.boundExpression);if(e instanceof Pn&&"error"===e.name)return!1;if(e instanceof Dn)return!1;if(e instanceof Kn)return!1;if(e instanceof ko)return!1;if(e instanceof Fo)return!1;const t=e instanceof An||e instanceof wn;let i=!0;return e.eachChild((e=>{i=t?i&&Zo(e):i&&e instanceof xn})),!!i&&No(e)&&jo(e,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function $o(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||tt))throw new vn("Input is not a number.");s=a-1}return 0}class Wo{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,Hr);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Wo(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[$o(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const Qo=.95047,Ho=1.08883,Xo=.13793103448275862,Yo=.20689655172413793,Jo=.12841854934601665,Ko=.008856451679035631,es=Math.PI/180,ts=180/Math.PI;function is(e){return e>Ko?Math.pow(e,.3333333333333333):e/Jo+Xo}function rs(e){return e>Yo?e*e*e:Jo*(e-Xo)}function ns(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,.4166666666666667)-.055)}function os(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function ss(e){const t=os(e.r),i=os(e.g),r=os(e.b),n=is((.4124564*t+.3575761*i+.1804375*r)/Qo),o=is((.2126729*t+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-is((.0193339*t+.119192*i+.9503041*r)/Ho)),alpha:e.a}}function as(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*rs(t),i=Qo*rs(i),r=Ho*rs(r),new Ur(ns(3.2404542*i-1.5371385*t-.4985314*r),ns(-.969266*i+1.8760108*t+.041556*r),ns(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function ls(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const cs={forward:ss,reverse:as,interpolate:function(e,t,i){return{l:jr(e.l,t.l,i),a:jr(e.a,t.a,i),b:jr(e.b,t.b,i),alpha:jr(e.alpha,t.alpha,i)}}},hs={forward:function(e){const{l:t,a:i,b:r}=ss(e),n=Math.atan2(r,i)*ts;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*es,i=e.c;return as({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:ls(e.h,t.h,i),c:jr(e.c,t.c,i),l:jr(e.l,t.l,i),alpha:jr(e.alpha,t.alpha,i)}}};var us=Object.freeze({__proto__:null,hcl:hs,lab:cs});class ds{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=ps(t,e.base,i,r);else if("linear"===e.name)n=ps(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new Bt(o[0],o[1],o[2],o[3]).solve(ps(t,1,i,r))}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,Hr),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=Jr:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new ds(a,i,r,n,s):t.error(`Type ${sn(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=$o(t,r),s=ds.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?qr[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?hs.reverse(hs.interpolate(hs.forward(a),hs.forward(l),s)):cs.reverse(cs.interpolate(cs.forward(a),cs.forward(l),s))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let e=0;eln(r,e.type)));return new fs(o?en:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof fn&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize())})),e}}class ms{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r=i.length)throw new vn(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new vn(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class gs{constructor(e,t){this.type=Yr,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,en),r=t.parse(e[2],2,en);return i&&r?cn(i.type,[Yr,Xr,Hr,Qr,en])?new gs(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${sn(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!hn(t,["boolean","string","number","null"]))throw new vn(`Expected first argument to be of type boolean, string, number or null, but found ${sn(gn(t))} instead.`);if(!hn(i,["string","array"]))throw new vn(`Expected second argument to be of type array or string, but found ${sn(gn(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ys{constructor(e,t,i){this.type=Hr,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,en),r=t.parse(e[2],2,en);if(!i||!r)return null;if(!cn(i.type,[Yr,Xr,Hr,Qr,en]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${sn(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Hr);return n?new ys(i,r,n):null}return new ys(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!hn(t,["boolean","string","number","null"]))throw new vn(`Expected first argument to be of type boolean, string, number or null, but found ${sn(gn(t))} instead.`);if(!hn(i,["string","array"]))throw new vn(`Expected second argument to be of type array or string, but found ${sn(gn(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class xs{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,gn(e)))return null}else i=gn(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const h=t.parse(l,s,r);if(!h)return null;r=r||h.type,o.push(h)}const s=t.parse(e[1],1,en);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new xs(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(gn(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class vs{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;nt.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}class bs{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,en),r=t.parse(e[2],2,Hr);if(!i||!r)return null;if(!cn(i.type,[on(en),Xr,en]))return t.error(`Expected first argument to be of type array or string, but found ${sn(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Hr);return n?new bs(i.type,i,r,n):null}return new bs(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!hn(t,["string","array"]))throw new vn(`Expected first argument to be of type array or string, but found ${sn(gn(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function ws(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 Ts(e,t,i,r){return 0===r.compare(t,i)}function Es(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=Yr,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let o=t.parse(e[1],1,en);if(!o)return null;if(!ws(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${sn(o.type)}'.`);let s=t.parse(e[2],2,en);if(!s)return null;if(!ws(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${sn(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${sn(o.type)}' and '${sn(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new wn(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new wn(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,tn),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=gn(o),i=gn(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new vn(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=gn(o),i=gn(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize())})),t}}}const Ss=Es("==",(function(e,t,i){return t===i}),Ts),Ms=Es("!=",(function(e,t,i){return t!==i}),(function(e,t,i,r){return!Ts(0,t,i,r)})),As=Es("<",(function(e,t,i){return t",(function(e,t,i){return t>i}),(function(e,t,i,r){return r.compare(t,i)>0})),Cs=Es("<=",(function(e,t,i){return t<=i}),(function(e,t,i,r){return r.compare(t,i)<=0})),Ps=Es(">=",(function(e,t,i){return t>=i}),(function(e,t,i,r){return r.compare(t,i)>=0}));class zs{constructor(e,t,i,r,n,o){this.type=Xr,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Hr);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,Xr),!n))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,Xr),!o))return null;let s=null;if(r.unit&&(s=t.parse(r.unit,1,Xr),!s))return null;let a=null;if(r["min-fraction-digits"]&&(a=t.parse(r["min-fraction-digits"],1,Hr),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,Hr),!l)?null:new zs(i,n,o,s,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Ds{constructor(e){this.type=Hr,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${sn(i.type)} instead.`):new Ds(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new vn(`Expected value to be of type string or array, but found ${sn(gn(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}function Rs(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const Ls={"==":Ss,"!=":Ms,">":Is,"<":As,">=":Ps,"<=":Cs,array:wn,at:_s,boolean:wn,case:vs,coalesce:fs,collator:Dn,format:Tn,image:En,in:gs,"index-of":ys,interpolate:ds,"interpolate-hcl":ds,"interpolate-lab":ds,length:Ds,let:ms,literal:xn,match:xs,number:wn,"number-format":zs,object:wn,slice:bs,step:Wo,string:wn,"to-boolean":An,"to-color":An,"to-number":An,"to-string":An,var:Go,within:Kn,distance:ko,config:Fo};function ks(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=mn(t,i,r,o);if(s)throw new vn(s);return new Ur(t/255*o,i/255*o,r/255*o,o)}function Os(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=(function(e,t,i,r){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof i&&i>=0&&i<=100?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid hsla value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'h' must be between 0 and 360.`})(t,i,r,o);if(s)throw new vn(s);const a=`hsla(${t}, ${i}%, ${r}%, ${o})`,l=Ur.parse(a);if(!l)throw new vn(`Failed to parse HSLA color: ${a}`);return l}function Bs(e,t){return e in t}function Fs(e,t){const i=t[e];return void 0===i?null:i}function Ns(e){return{type:e}}function Vs(e){return{result:"success",value:e}}function Us(e){return{result:"error",value:e}}function js(e,t){return!!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function Gs(e){return"data-driven"===e["property-type"]}function qs(e){return js(e.expression,"measure-light")}function Zs(e){return js(e.expression,"zoom")}function $s(e){return!!e.expression&&e.expression.interpolated}function Ws(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Qs(e){return e}function Hs(e,t){const i="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),o=e.type||($s(t)?"exponential":"interval");if(i&&((e=Zr({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],Ur.parse(e[1])]))),e.default=Ur.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!us[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=Ks;else if("interval"===o)s=Js;else if("categorical"===o){s=Ys,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=ea}if(r){const i={},r=[];for(let t=0;te[0])),evaluate:({zoom:i},r)=>Ks({stops:n,base:e.base},t,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:ds.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?Xs(e.default,t.default):s(e,t,n,a,l)}}}function Xs(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Ys(e,t,i,r,n){return Xs(typeof i===n?r[i]:void 0,e.default,t.default)}function Js(e,t,i){if("number"!==Sn(i))return Xs(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=$o(e.stops.map((e=>e[0])),i);return e.stops[n][1]}function Ks(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==Sn(i))return Xs(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=$o(e.stops.map((e=>e[0])),i),s=(function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)})(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=qr[t.type]||Qs;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=us[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function ea(e,t,i){return"color"===t.type?i=Ur.parse(i):"formatted"===t.type?i=pn.fromString(i.toString()):"resolvedImage"===t.type?i=fn.fromString(i.toString()):Sn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Xs(i,e.default,t.default)}Pn.register(Ls,{error:[{kind:"error"},[Xr],(e,[t])=>{throw new vn(t.evaluate(e))}],typeof:[Xr,[en],(e,[t])=>sn(gn(t.evaluate(e)))],"to-rgba":[on(Hr,4),[Jr],(e,[t])=>t.evaluate(e).toArray()],rgb:[Jr,[Hr,Hr,Hr],ks],rgba:[Jr,[Hr,Hr,Hr,Hr],ks],hsl:[Jr,[Hr,Hr,Hr],Os],hsla:[Jr,[Hr,Hr,Hr,Hr],Os],has:{type:Yr,overloads:[[[Xr],(e,[t])=>Bs(t.evaluate(e),e.properties())],[[Xr,Kr],(e,[t,i])=>Bs(t.evaluate(e),i.evaluate(e))]]},get:{type:en,overloads:[[[Xr],(e,[t])=>Fs(t.evaluate(e),e.properties())],[[Xr,Kr],(e,[t,i])=>Fs(t.evaluate(e),i.evaluate(e))]]},"feature-state":[en,[Xr],(e,[t])=>Fs(t.evaluate(e),e.featureState||{})],properties:[Kr,[],e=>e.properties()],"geometry-type":[Xr,[],e=>e.geometryType()],id:[en,[],e=>e.id()],zoom:[Hr,[],e=>e.globals.zoom],pitch:[Hr,[],e=>e.globals.pitch||0],"distance-from-center":[Hr,[],e=>e.distanceFromCenter()],"measure-light":[Hr,[Xr],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Hr,[],e=>e.globals.heatmapDensity||0],"line-progress":[Hr,[],e=>e.globals.lineProgress||0],"raster-value":[Hr,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[Hr,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[Hr,[],e=>e.globals.skyRadialProgress||0],accumulated:[en,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Hr,Ns(Hr),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Hr,Ns(Hr),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Hr,overloads:[[[Hr,Hr],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Hr],(e,[t])=>-t.evaluate(e)]]},"/":[Hr,[Hr,Hr],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Hr,[Hr,Hr],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Hr,[],()=>Math.LN2],pi:[Hr,[],()=>Math.PI],e:[Hr,[],()=>Math.E],"^":[Hr,[Hr,Hr],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Hr,[Hr],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Hr,[Hr],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Hr,[Hr],(e,[t])=>Math.log(t.evaluate(e))],log2:[Hr,[Hr],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Hr,[Hr],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Hr,[Hr],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Hr,[Hr],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Hr,[Hr],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Hr,[Hr],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Hr,[Hr],(e,[t])=>Math.atan(t.evaluate(e))],min:[Hr,Ns(Hr),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Hr,Ns(Hr),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Hr,[Hr],(e,[t])=>Math.abs(t.evaluate(e))],round:[Hr,[Hr],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Hr,[Hr],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Hr,[Hr],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Yr,[Xr,en],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Yr,[en],(e,[t])=>e.id()===t.value],"filter-type-==":[Yr,[Xr],(e,[t])=>e.geometryType()===t.value],"filter-<":[Yr,[Xr,en],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r{const i=e.id(),r=t.value;return typeof i==typeof r&&i":[Yr,[Xr,en],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Yr,[en],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[Yr,[Xr,en],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Yr,[en],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[Yr,[Xr,en],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Yr,[en],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[Yr,[en],(e,[t])=>t.value in e.properties()],"filter-has-id":[Yr,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Yr,[on(Xr)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Yr,[on(en)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Yr,[Xr,on(en)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Yr,[Xr,on(en)],(e,[t,i])=>(function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1})(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Yr,overloads:[[[Yr,Yr],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Ns(Yr),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Yr,overloads:[[[Yr,Yr],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Ns(Yr),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Yr,[Yr],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Yr,[Xr],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Xr,[Xr],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Xr,[Xr],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Xr,Ns(en),(e,t)=>t.map((t=>yn(t.evaluate(e)))).join("")],"resolved-locale":[Xr,[tn],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Hr,[Hr,Hr,en],(e,t)=>{const[i,r,n]=t.map((t=>t.evaluate(e)));if(i>r)return i;if(i===r)return i;let o;if("string"==typeof n)o=(function(e){let t=0;if(0===e.length)return t;for(let i=0;iJSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function ia(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Ls}function ra(e,t,i,r){const n=new qo(Ls,[],t?(function(e){const t={color:Jr,string:Xr,number:Hr,enum:Xr,boolean:Yr,formatted:rn,resolvedImage:nn};return"array"===e.type?on(t[e.value]||en,e.length):t[e.type]})(t):void 0,void 0,void 0,i,r),o=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return o?Vs(new ta(o,t,i,r)):Us(n.errors)}class na{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isStateDependent="constant"!==e&&!Vo(t.expression),this.isConfigDependent=!Uo(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}}class oa{constructor(e,t,i,r,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Vo(t.expression),this.isLightConstant=n,this.isConfigDependent=!Uo(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?ds.interpolationFactor(this.interpolationType,e,t,i):0}}function sa(e,t,i,r){if("error"===(e=ra(e,t,i,r)).result)return e;const n=e.value.expression,o=No(n);if(!o&&!Gs(t))return Us([new $r("","data expressions not supported")]);const s=jo(n,["zoom","pitch","distance-from-center"]);if(!s&&!Zs(t))return Us([new $r("","zoom expressions not supported")]);const a=jo(n,["measure-light"]);if(!a&&!qs(t))return Us([new $r("","measure-light expression not supported")]);const l=t.expression&&t.expression.relaxZoomRestriction,c=la(n);return c||s||l?c instanceof $r?Us([c]):c instanceof ds&&!$s(t)?Us([new $r("",'"interpolate" expressions cannot be used with this property')]):Vs(c?new oa(o?"camera":"composite",e.value,c.labels,c instanceof ds?c.interpolation:void 0,a):new na(o?"constant":"source",e.value,a)):Us([new $r("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class aa{constructor(e,t){this._parameters=e,this._specification=t,Zr(this,Hs(this._parameters,this._specification))}static deserialize(e){return new aa(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function la(e){let t=null;if(e instanceof ms)t=la(e.result);else if(e instanceof fs){for(const i of e.args)if(t=la(i),t)break}else(e instanceof Wo||e instanceof ds)&&e.input instanceof Pn&&"zoom"===e.input.name&&(t=e);return t instanceof $r||e.eachChild((e=>{const i=la(e);i instanceof $r?t=i:t&&i&&t!==i&&(t=new $r("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}var ca=ua,ha=3;function ua(e,t,i){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(var o=0;o=h[p+0]&&r>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},ua.prototype._forEachCell=function(e,t,i,r,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=l;d<=h;d++)for(var p=c;p<=u;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&n.call(this,e,t,i,r,f,o,s,a))return}},ua.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},ua.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},ua.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=ha+this.cells.length+1+1,i=0,r=0;r=0||(n[i]=ga(e[i],t)));e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof e)}function ya(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||ma(e)||_a(e)||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(ya);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=new Map;for(const i of Object.keys(e))"$name"!==i&&t.set(i,ya(e[i]));return t}const{klass:i}=pa[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=ya(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const xa={"Latin-1 Supplement":e=>e>=128&&e<=255,Arabic:e=>e>=1536&&e<=1791,"Arabic Supplement":e=>e>=1872&&e<=1919,"Arabic Extended-A":e=>e>=2208&&e<=2303,"Hangul Jamo":e=>e>=4352&&e<=4607,"Unified Canadian Aboriginal Syllabics":e=>e>=5120&&e<=5759,Khmer:e=>e>=6016&&e<=6143,"Unified Canadian Aboriginal Syllabics Extended":e=>e>=6320&&e<=6399,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"CJK Radicals Supplement":e=>e>=11904&&e<=12031,"Kangxi Radicals":e=>e>=12032&&e<=12255,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Bopomofo:e=>e>=12544&&e<=12591,"Hangul Compatibility Jamo":e=>e>=12592&&e<=12687,Kanbun:e=>e>=12688&&e<=12703,"Bopomofo Extended":e=>e>=12704&&e<=12735,"CJK Strokes":e=>e>=12736&&e<=12783,"Katakana Phonetic Extensions":e=>e>=12784&&e<=12799,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"CJK Unified Ideographs Extension A":e=>e>=13312&&e<=19903,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Yi Syllables":e=>e>=40960&&e<=42127,"Yi Radicals":e=>e>=42128&&e<=42191,"Hangul Jamo Extended-A":e=>e>=43360&&e<=43391,"Hangul Syllables":e=>e>=44032&&e<=55215,"Hangul Jamo Extended-B":e=>e>=55216&&e<=55295,"Private Use Area":e=>e>=57344&&e<=63743,"CJK Compatibility Ideographs":e=>e>=63744&&e<=64255,"Arabic Presentation Forms-A":e=>e>=64336&&e<=65023,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Arabic Presentation Forms-B":e=>e>=65136&&e<=65279,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519,"CJK Unified Ideographs Extension B":e=>e>=131072&&e<=173791};function va(e){for(const t of e)if(Ta(t.charCodeAt(0)))return!0;return!1}function ba(e){for(const t of e)if(!wa(t.charCodeAt(0)))return!1;return!0}function wa(e){return!(xa.Arabic(e)||xa["Arabic Supplement"](e)||xa["Arabic Extended-A"](e)||xa["Arabic Presentation Forms-A"](e)||xa["Arabic Presentation Forms-B"](e))}function Ta(e){return!(746!==e&&747!==e&&(e<4352||!(xa["Bopomofo Extended"](e)||xa.Bopomofo(e)||xa["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||xa["CJK Compatibility Ideographs"](e)||xa["CJK Compatibility"](e)||xa["CJK Radicals Supplement"](e)||xa["CJK Strokes"](e)||!(!xa["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||xa["CJK Unified Ideographs Extension A"](e)||xa["CJK Unified Ideographs"](e)||xa["Enclosed CJK Letters and Months"](e)||xa["Hangul Compatibility Jamo"](e)||xa["Hangul Jamo Extended-A"](e)||xa["Hangul Jamo Extended-B"](e)||xa["Hangul Jamo"](e)||xa["Hangul Syllables"](e)||xa.Hiragana(e)||xa["Ideographic Description Characters"](e)||xa.Kanbun(e)||xa["Kangxi Radicals"](e)||xa["Katakana Phonetic Extensions"](e)||xa.Katakana(e)&&12540!==e||!(!xa["Halfwidth and Fullwidth Forms"](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)||!(!xa["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||xa["Unified Canadian Aboriginal Syllabics"](e)||xa["Unified Canadian Aboriginal Syllabics Extended"](e)||xa["Vertical Forms"](e)||xa["Yijing Hexagram Symbols"](e)||xa["Yi Syllables"](e)||xa["Yi Radicals"](e))))}function Ea(e){return!(Ta(e)||(function(e){return!!(xa["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||xa["General Punctuation"](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)||xa["Letterlike Symbols"](e)||xa["Number Forms"](e)||xa["Miscellaneous Technical"](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)||xa["Control Pictures"](e)&&9251!==e||xa["Optical Character Recognition"](e)||xa["Enclosed Alphanumerics"](e)||xa["Geometric Shapes"](e)||xa["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||xa["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||xa["CJK Symbols and Punctuation"](e)||xa.Katakana(e)||xa["Private Use Area"](e)||xa["CJK Compatibility Forms"](e)||xa["Small Form Variants"](e)||xa["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)})(e))}function Sa(e){return e>=1424&&e<=2303||xa["Arabic Presentation Forms-A"](e)||xa["Arabic Presentation Forms-B"](e)}function Ma(e,t){return!(!t&&Sa(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||xa.Khmer(e))}function Aa(e){for(const t of e)if(Sa(t.charCodeAt(0)))return!0;return!1}const Ia="deferred",Ca="loading",Pa="loaded";let za=null,Da="unavailable",Ra=null;const La=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Da="error"),za&&za(e)};function ka(){Oa.fire(new Rr("pluginStateChange",{pluginStatus:Da,pluginURL:Ra}))}const Oa=new kr,Ba=function(){return Da},Fa=function(){if(Da!==Ia||!Ra)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Da=Ca,ka(),Ra&&Ki({url:Ra},(e=>{e?La(e):(Da=Pa,ka())}))},Na={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Da===Pa||null!=Na.applyArabicShaping,isLoading:()=>Da===Ca,setState(e){Da=e.pluginStatus,Ra=e.pluginURL},isParsed:()=>null!=Na.applyArabicShaping&&null!=Na.processBidirectionalText&&null!=Na.processStyledBidirectionalText,getPluginURL:()=>Ra};class Va{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return(function(e,t){for(const i of e)if(!Ma(i.charCodeAt(0),t))return!1;return!0})(e,Na.isLoaded())}}class Ua{constructor(e,t,i,r){this.property=e,this.value=t,this.expression=(function(e,t,i,r){if(Ws(e))return new aa(e,t);if(ia(e)||Array.isArray(e)&&e.length>0){const n=sa(e,t,i,r);if("error"===n.result)throw new Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return n.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=Ur.parse(e)),{kind:"constant",isConfigDependent:!1,evaluate:()=>i}}})(void 0===t?e.specification.default:t,e.specification,i,r)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class ja{constructor(e,t,i){this.property=e,this.value=new Ua(e,void 0,t,i)}transitioned(e,t){return new qa(this.property,this.value,t,Kt({},e.transition,this.transition),e.now)}untransitioned(){return new qa(this.property,this.value,null,{},0)}}class Ga{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=i,this.isConfigDependent=!1}getValue(e){return ci(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new ja(this._values[e].property,this._scope,this._options)),this._values[e].value=new Ua(this._values[e].property,null===t?void 0:ci(t),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].value.expression.isConfigDependent}setTransitionOrValue(e,t){t&&(this._options=t);const i=this._properties.properties;if(e)for(const t in e){const r=e[t];if(si(t,"-transition")){const e=t.slice(0,-11);i[e]&&this.setTransition(e,r)}else i[t]&&this.setValue(t,r)}}getTransition(e){return ci(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new ja(this._values[e].property)),this._values[e].transition=ci(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){const i=new Za(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Za(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class qa{constructor(e,t,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r":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"}},"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_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"}},"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","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","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","default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":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"]},"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-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"}},"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-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"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-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"}},"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,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":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"}},"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-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,"expression":{},"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"expression":{},"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 il(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!il(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function rl(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};il(e)||(e=hl(e));const i=e;let r=!0;try{r=(function(e){if(!sl(e))return e;let t=el(e);return ol(t),t=nl(t),t})(i)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const n=tl[`filter_${t}`],o=ra(r,n);let s=null;if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(e,t,i)=>o.value.evaluate(e,t,{},i);let a=null,l=null;if(r!==i){const e=ra(i,n);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a=(t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o),l=!No(e.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:cl(r),needFeature:!!l}}function nl(e){if(!Array.isArray(e))return e;const t=(function(e){if(al.has(e[0]))for(let t=1;tnl(e)))}function ol(e){let t=!1;const i=[];if("case"===e[0]){for(let r=1;r",">=","<","<=","to-boolean"]);function ll(e,t){return et?1:0}function cl(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?ul(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(hl))):"all"===t?["all"].concat(e.slice(1).map(hl)):"none"===t?["all"].concat(e.slice(1).map(hl).map(fl)):"in"===t?dl(e[1],e.slice(2)):"!in"===t?fl(dl(e[1],e.slice(2))):"has"===t?pl(e[1]):"!has"!==t||fl(pl(e[1]));var i}function ul(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function dl(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(ll)]]:["filter-in-small",e,["literal",t]]}}function pl(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function fl(e){return["!",e]}const ml="\x1f";function _l(e,t){return t?`${e}${ml}${t}`:e}const gl="-transition",yl=new Set(["fill","line","background","hillshade","raster"]);class xl extends kr{constructor(e,t,i,r){if(super(),this.id=e.id,this.fqid=_l(this.id,i),this.type=e.type,this.scope=i,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),e.slot&&(this.slot=e.slot),t.layout&&(this._unevaluatedLayout=new $a(t.layout,this.scope,r),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),t.paint)){this._transitionablePaint=new Ga(t.paint,this.scope,r);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Qa(t.paint)}}onAdd(e){}onRemove(e){}isDraped(e){return yl.has(this.type)}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const i=this._unevaluatedLayout;i._properties.properties[e]&&(i.setValue(e,t),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,"visibility"===e&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(e){return si(e,gl)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t){const i=this._transitionablePaint,r=i._properties.properties;if(si(e,gl)){const n=e.slice(0,-11);return r[n]&&i.setTransition(n,t||void 0),!1}if(!r[e])return!1;const n=i._values[e],o=n.value.isDataDriven(),s=n.value;i.setValue(e,t),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,this._handleSpecialPaintPropertyUpdate(e);const a=i._values[e].value,l=a.isDataDriven(),c=si(e,"pattern")||"line-dasharray"===e;return l||o||c||this._handleOverridablePaintPropertyUpdate(e,s,a)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){return li({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Wa&&Gs(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rl(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(e){}queryIntersectsFeature(e,t,i,r,n,o,s,a,l){}queryIntersectsMatchingFeature(e,t,i,r){}}const vl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class bl{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class wl{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Tl(e,t=1){let i=0,r=0;return{members:e.map((e=>{const n=vl[e.type].BYTES_PER_ELEMENT,o=i=El(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}})),size:El(i,Math.max(r,t)),alignment:t}}function El(e,t){return Math.ceil(e/t)*t}class Sl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}Sl.prototype.bytesPerElement=4,fa(Sl,"StructArrayLayout2i4");class Ml extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}Ml.prototype.bytesPerElement=6,fa(Ml,"StructArrayLayout3i6");class Al extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}Al.prototype.bytesPerElement=8,fa(Al,"StructArrayLayout4i8");class Il extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,e}}Il.prototype.bytesPerElement=10,fa(Il,"StructArrayLayout5i10");class Cl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=6*e,c=12*e,h=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,e}}Cl.prototype.bytesPerElement=12,fa(Cl,"StructArrayLayout2i4ub1f12");class Pl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}Pl.prototype.bytesPerElement=16,fa(Pl,"StructArrayLayout4f16");class zl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}zl.prototype.bytesPerElement=8,fa(zl,"StructArrayLayout2f8");class Dl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=6*e,a=3*e;return this.uint16[s+0]=t,this.uint16[s+1]=i,this.uint16[s+2]=r,this.uint16[s+3]=n,this.float32[a+2]=o,e}}Dl.prototype.bytesPerElement=12,fa(Dl,"StructArrayLayout4ui1f12");class Rl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=i,this.uint16[o+2]=r,this.uint16[o+3]=n,e}}Rl.prototype.bytesPerElement=8,fa(Rl,"StructArrayLayout4ui8");class Ll extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}Ll.prototype.bytesPerElement=12,fa(Ll,"StructArrayLayout6i12");class kl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,h,u)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,e}}kl.prototype.bytesPerElement=24,fa(kl,"StructArrayLayout4i4ui4i24");class Ol extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}Ol.prototype.bytesPerElement=20,fa(Ol,"StructArrayLayout3i3f20");class Bl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}Bl.prototype.bytesPerElement=4,fa(Bl,"StructArrayLayout1ul4");class Fl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}Fl.prototype.bytesPerElement=4,fa(Fl,"StructArrayLayout2ui4");class Nl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,s,a,l,c,h,u,d)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}Nl.prototype.bytesPerElement=40,fa(Nl,"StructArrayLayout5i4f1i1ul2ui40");class Vl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}Vl.prototype.bytesPerElement=16,fa(Vl,"StructArrayLayout3i2i2i16");class Ul extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}Ul.prototype.bytesPerElement=16,fa(Ul,"StructArrayLayout2f1f2i16");class jl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=12*e,s=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[s+1]=r,this.float32[s+2]=n,e}}jl.prototype.bytesPerElement=12,fa(jl,"StructArrayLayout2ub2f12");class Gl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}Gl.prototype.bytesPerElement=6,fa(Gl,"StructArrayLayout3ui6");class ql extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,e}}ql.prototype.bytesPerElement=60,fa(ql,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Zl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,M,A,I,C,P,z){const D=this.length;return this.resize(D+1),this.emplace(D,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,M,A,I,C,P,z)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,M,A,I,C,P,z,D){const R=20*e,L=40*e,k=80*e;return this.float32[R+0]=t,this.float32[R+1]=i,this.int16[L+4]=r,this.int16[L+5]=n,this.int16[L+6]=o,this.int16[L+7]=s,this.int16[L+8]=a,this.int16[L+9]=l,this.int16[L+10]=c,this.int16[L+11]=h,this.int16[L+12]=u,this.uint16[L+13]=d,this.uint16[L+14]=p,this.uint16[L+15]=f,this.uint16[L+16]=m,this.uint16[L+17]=_,this.uint16[L+18]=g,this.uint16[L+19]=y,this.uint16[L+20]=x,this.uint16[L+21]=v,this.uint16[L+22]=b,this.uint16[L+23]=w,this.uint16[L+24]=T,this.uint16[L+25]=E,this.uint16[L+26]=S,this.uint16[L+27]=M,this.uint32[R+14]=A,this.float32[R+15]=I,this.float32[R+16]=C,this.float32[R+17]=P,this.float32[R+18]=z,this.uint8[k+76]=D,e}}Zl.prototype.bytesPerElement=80,fa(Zl,"StructArrayLayout2f9i15ui1ul4f1ub80");class $l extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}$l.prototype.bytesPerElement=4,fa($l,"StructArrayLayout1f4");class Wl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,this.float32[s+4]=o,e}}Wl.prototype.bytesPerElement=20,fa(Wl,"StructArrayLayout5f20");class Ql extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}Ql.prototype.bytesPerElement=28,fa(Ql,"StructArrayLayout7f28");class Hl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}Hl.prototype.bytesPerElement=12,fa(Hl,"StructArrayLayout1ul3ui12");class Xl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Xl.prototype.bytesPerElement=2,fa(Xl,"StructArrayLayout1ui2");class Yl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}Yl.prototype.bytesPerElement=12,fa(Yl,"StructArrayLayout3f12");class Jl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=i,this.float32[g+2]=r,this.float32[g+3]=n,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=h,this.float32[g+10]=u,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,e}}Jl.prototype.bytesPerElement=64,fa(Jl,"StructArrayLayout16f64");class Kl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=10*e,c=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=i,this.uint16[l+2]=r,this.uint16[l+3]=n,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,e}}Kl.prototype.bytesPerElement=20,fa(Kl,"StructArrayLayout4ui3f20");class ec extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}ec.prototype.bytesPerElement=2,fa(ec,"StructArrayLayout1i2");class tc extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}tc.prototype.bytesPerElement=1,fa(tc,"StructArrayLayout1ub1");class ic extends bl{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}ic.prototype.size=40;class rc extends Nl{get(e){return new ic(this,e)}}fa(rc,"CollisionBoxArray");class nc extends bl{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}nc.prototype.size=60;class oc extends ql{get(e){return new nc(this,e)}}fa(oc,"PlacedSymbolArray");class sc extends bl{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}sc.prototype.size=80;class ac extends Zl{get(e){return new sc(this,e)}}fa(ac,"SymbolInstanceArray");class lc extends $l{getoffsetX(e){return this.float32[1*e+0]}}fa(lc,"GlyphOffsetArray");class cc extends Sl{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}fa(cc,"SymbolLineVertexArray");class hc extends bl{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}hc.prototype.size=12;class uc extends Hl{get(e){return new hc(this,e)}}fa(uc,"FeatureIndexArray");class dc extends Fl{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}fa(dc,"FillExtrusionCentroidArray");const pc=Tl([{name:"a_pos",components:2,type:"Int16"}],4),fc=Tl([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class mc{constructor(e=[]){this.segments=e}_prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>mc.MAX_VERTEX_ARRAY_LENGTH&&ui(`Max vertices per segment is ${mc.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>mc.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}prepareSegment(e,t,i,r){return this._prepareSegment(e,t.length,i.length,r)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,r){return new mc([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function _c(e,t){return 256*(e=Ht(Math.floor(e),0,255))+Ht(Math.floor(t),0,255)}mc.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,fa(mc,"SegmentVector");const gc=Tl([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),yc=Tl([{name:"a_dash",components:4,type:"Uint16"}]);class xc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(vc(e)),this.positions.push(t,i,r)}eachPosition(e,t){const i=vc(e);let r=0,n=this.ids.length-1;for(;r>1;this.ids[e]>=i?n=e:r=e+1}for(;this.ids[r]===i;)t(this.positions[3*r],this.positions[3*r+1],this.positions[3*r+2]),r++}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return bc(i,r,0,i.length-1),t&&(t.add(i.buffer),t.add(r.buffer)),{ids:i,positions:r}}static deserialize(e){const t=new xc;let i;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==i&&t.uniqueIds.push(e),i=e;return t.indexed=!0,t}}function vc(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Pr(String(e))}function bc(e,t,i,r){for(;i>1];let o=i-1,s=r+1;for(;;){do{o++}while(e[o]n);if(o>=s)break;wc(e,o,s),wc(t,3*o,3*s),wc(t,3*o+1,3*s+1),wc(t,3*o+2,3*s+2)}s-i`u_${e}`)),this.type=i}setUniform(e,t,i,r,n){t.set(e,n,r.constantOr(this.value))}getBinding(e,t){return"color"===this.type?new Cc(e):new Sc(e)}}class Bc{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,t,i,r,n){const o="u_pattern"===n||"u_dash"===n?this.pattern:"u_pixel_ratio"===n?this.pixelRatio:null;o&&t.set(e,n,o)}getBinding(e,t){return"u_pattern"===t||"u_dash"===t?new Ic(e):new Sc(e)}}class Fc{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,i,r,n,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new Va(0,{brightness:o}),t,{},n,r,s);this.paintVertexArray.resize(e),this._setPaintValue(a,e,l)}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a)}_setPaintValue(e,t,i){if("color"===this.type){const r=kc(i);for(let i=e;i`u_${e}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate(new Va(this.zoom,{brightness:o}),t,{},n,r,s),l=this.expression.evaluate(new Va(this.zoom+1,{brightness:o}),t,{},n,r,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(c,e,a,l)}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom,brightness:s},i,r,void 0,n),l=this.expression.evaluate({zoom:this.zoom+1,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a,l)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=kc(i),o=kc(r);for(let i=e;i!0)){this.binders={},this._buffers=[];const r=[];for(const n in e.paint._values){const o=e.paint.get(n);if(!i(n))continue;if(!(o instanceof Wa&&Gs(o.property.specification)))continue;const s=qc(n,e.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,h="line-dasharray"===n||n.endsWith("pattern"),u="line-dasharray"===n&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||h){const t=Wc(n,l,"source");this.binders[n]=h?new Vc(a,s,l,t,e.id):new Fc(a,s,l,t),r.push(`/a_${n}`)}else{const e=Wc(n,l,"composite");this.binders[n]=new Nc(a,s,l,c,t,e),r.push(`/z_${n}`)}else this.binders[n]=h?new Bc(a.value,s):new Oc(a.value,s,l),r.push(`/u_${n}`)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Fc||t instanceof Nc?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o,s){for(const a in this.binders){const l=this.binders[a];(l instanceof Fc||l instanceof Nc||l instanceof Vc)&&l.populatePaintArray(e,t,i,r,n,o,s)}}setConstantPatternPositions(e){for(const t in this.binders){const i=this.binders[t];i instanceof Bc&&i.setConstantPatternPositions(e)}}updatePaintArrays(e,t,i,r,n,o,s,a){let l=!1;const c=Object.keys(e),h=0!==c.length,u=h?c:t.uniqueIds;for(const c in this.binders){const d=this.binders[c];if((d instanceof Fc||d instanceof Nc||d instanceof Vc)&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){const p=n.paint.get(c);d.expression=p.value;for(const i of u){const n=e[i.toString()];t.eachPosition(i,((e,t,i)=>{const l=r.feature(e);d.updatePaintArray(t,i,l,n,o,s,a)}))}if(!h)for(const t of i.uniqueIds){const n=e[t.toString()];i.eachPosition(t,((e,t,i)=>{const l=r.feature(e);d.updatePaintArray(t,i,l,n,o,s,a)}))}l=!0}}return l}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Oc||i instanceof Bc)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Fc||i instanceof Nc||i instanceof Vc)for(let t=0;t!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Uc(r,t,i);this.needsUpload=!1,this._featureMap=new xc,this._featureMapWithoutIds=new xc,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,i,r,n,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,s,a);void 0!==t.id?this._featureMap.add(t.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r,n,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,s,r,n,o||0)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const Gc={"text-opacity":["opacity"],"icon-opacity":["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"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function qc(e,t){return Gc[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Zc={"line-pattern":{source:Dl,composite:Dl},"fill-pattern":{source:Dl,composite:Dl},"fill-extrusion-pattern":{source:Dl,composite:Dl},"line-dasharray":{source:Rl,composite:Rl}},$c={color:{source:zl,composite:Pl},number:{source:$l,composite:zl}};function Wc(e,t,i){const r=Zc[e];return r&&r[i]||$c[t][i]}fa(Oc,"ConstantBinder"),fa(Bc,"PatternConstantBinder"),fa(Fc,"SourceExpressionBinder"),fa(Vc,"PatternCompositeBinder"),fa(Nc,"CompositeExpressionBinder"),fa(Uc,"ProgramConfiguration",{omit:["_buffers"]}),fa(jc,"ProgramConfigurationSet");const Qc=no/Math.PI/2,Hc=5,Xc=6,Yc=16383,Jc=64,Kc=[Jc,32,16],eh=-Qc,th=Qc;function ih(e,t,i,r=Qc){return i=Gt(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function rh(e,t,i){return ih(Math.cos(Gt(e)),Math.sin(Gt(e)),t,i)}const nh=6371008.8,oh=2*Math.PI*nh;class sh{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new sh(Yt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return nh*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new ah({lng:this.lng-i,lat:this.lat-t},{lng:this.lng+i,lat:this.lat+t})}toEcef(e){return rh(this.lat,this.lng,Qc+e*Qc/nh)}static convert(e){if(e instanceof sh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new sh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new sh(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class ah{constructor(e,t){if(e)if(t)this.setSouthWest(e).setNorthEast(t);else if(4===e.length){const t=e;this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]])}else{const t=e;this.setSouthWest(t[0]).setNorthEast(t[1])}}setNorthEast(e){return this._ne=e instanceof sh?new sh(e.lng,e.lat):sh.convert(e),this}setSouthWest(e){return this._sw=e instanceof sh?new sh(e.lng,e.lat):sh.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof sh)r=e,n=e;else{if(!(e instanceof ah))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(ah.convert(e)):this.extend(sh.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(sh.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new sh(r.lng,r.lat),this._ne=new sh(n.lng,n.lat)),this}getCenter(){return new sh((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new sh(this.getWest(),this.getNorth())}getSouthEast(){return new sh(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:i}=sh.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){return!e||e instanceof ah?e:new ah(e)}}var lh={};!(function(e,t){!(function(e){function t(e,t,r){var n=i(256*e,256*(t=Math.pow(2,r)-t-1),r),o=i(256*(e+1),256*(t+1),r);return n[0]+","+n[1]+","+o[0]+","+o[1]}function i(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}e.getURL=function(e,i,r,n,o,s){return s=s||{},e+"?"+["bbox="+t(r,n,o),"format="+(s.format||"image/png"),"service="+(s.service||"WMS"),"version="+(s.version||"1.1.1"),"request="+(s.request||"GetMap"),"srs="+(s.srs||"EPSG:3857"),"width="+(s.width||256),"height="+(s.height||256),"layers="+i].join("&")},e.getTileBBox=t,e.getMercCoords=i,Object.defineProperty(e,"__esModule",{value:!0})})(t)})(0,lh);var ch=lh;class hh{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=ph(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const i=ch.getTileBBox(this.x,this.y,this.z),r=(function(e,t,i){let r,n="";for(let o=e;o>0;o--)r=1<this.canonical.z?new dh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new dh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return ph(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return ph(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new dh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new dh(t,this.wrap,t,i,r),new dh(t,this.wrap,t,i+1,r),new dh(t,this.wrap,t,i,r+1),new dh(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,i=e.wrap;return t===1<new dh(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new dh(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<=l?(Ph(e,t,i,c,h,o,u,a,l),Ph(e,c,h,r,n,u,s,a,l)):e.push(s)}function zh(e,t,i){let r=e[0],n=r.x,o=r.y;t(r);const s=[r];for(let a=1;ae.x+1||re.y+1)&&ui("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Bh(e,t,i){const r=e.loadGeometry(),n=e.extent,o=no/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<{const i=bh((t.x+e.x/n)/o),r=wh((t.y+e.y/n)/o),h=c.project(i,r);e.x=(h.x*s-a)*n,e.y=(h.y*s-l)*n};for(let t=0;t=n||i.y<0||i.y>=n||(h(i),e.push(i));r[t]=e}}for(const e of r)for(const t of e)Oh(t,o);return r}function Fh(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Bh(e):[]}}function Nh(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2)}function Vh(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class Uh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Sl,this.indexArray=new Gl,this.segments=new mc,this.programConfigurations=new jc(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Fh(t,e);if(!this.layers[0]._featureFilter.filter(new Va(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Bh(t,i,r),patterns:{},sortKey:h};o.push(u)}s&&o.sort(((e,t)=>e.sortKey-t.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Ll,a=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,l=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,a,t.brightness),t.featureIndex.insert(l,n,o,s,this.index)}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,pc.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,fc.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,i,r,n,o,s){for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=no||r<0||r>=no)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r),s=this.globeExtVertexArray;Vh(s,e,t),Vh(s,e,t),Vh(s,e,t),Vh(s,e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;Nh(this.layoutVertexArray,i,r,-1,-1),Nh(this.layoutVertexArray,i,r,1,-1),Nh(this.layoutVertexArray,i,r,1,1),Nh(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n,s)}}function jh(e,t){for(let i=0;i1){if($h(e,t))return!0;for(let r=0;r1?i:i.sub(t)._mult(n)._add(t))}function Xh(e,t){let i,r,n,o=!1;for(let s=0;st.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function Yh(e,t){let i=!1;for(let r=0,n=e.length-1;rt.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function Jh(e,t,i,r,n){for(const o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const o=[new Vt(t,i),new Vt(t,n),new Vt(r,n),new Vt(r,i)];if(e.length>2)for(const t of o)if(Yh(e,t))return!0;for(let t=0;tn.x&&t.x>n.x||e.yn.y&&t.y>n.y)return!1;const o=di(e,t,i[0]);return o!==di(e,t,i[1])||o!==di(e,t,i[2])||o!==di(e,t,i[3])}function eu(e,t,i,r,n,o){let s=t.y-e.y,a=e.x-t.x;if(o=o||0){const e=s*s+a*a;if(0===e)return!0;const t=Math.sqrt(e);s/=t,a/=t}return!((i.x-e.x)*s+(i.y-e.y)*a-o<0||(r.x-e.x)*s+(r.y-e.y)*a-o<0||(n.x-e.x)*s+(n.y-e.y)*a-o<0)}function tu(e,t,i,r,n,o,s){return!(eu(e,t,r,n,o,s)||eu(t,i,r,n,o,s)||eu(i,e,r,n,o,s)||eu(r,n,e,t,i,s)||eu(n,o,e,t,i,s)||eu(o,r,e,t,i,s))}function iu(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function ru(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function nu(e,t,i,r,n){if(!t[0]&&!t[1])return e;const o=Vt.convert(t)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let t=0;t=0;if(0===s)return 0;s!==i.length&&(r=!1)}return r?2:1}function du(e,t){for(const i of e.projections){const r=hu(t,e.points[0],i.axis);if(i.projection[1]r[1])return 0}return 1}function pu(t,i){let r=0;const n=[0,0,0,0];for(let o=0;o=0&&r++;return r}class fu{constructor(t,i){this.points=t||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([0,0,0,0]),this.bounds=mu.fromPoints(this.points),this.projections=[],this.frustumEdges=[e.Q.sub([],this.points[2],this.points[3]),e.Q.sub([],this.points[0],this.points[3]),e.Q.sub([],this.points[4],this.points[0]),e.Q.sub([],this.points[5],this.points[1]),e.Q.sub([],this.points[6],this.points[2]),e.Q.sub([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],i=[e[2],0,-e[0]];this.projections.push({axis:t,projection:hu(this.points,this.points[0],t)}),this.projections.push({axis:i,projection:hu(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(t,i,r,n){const o=Math.pow(2,r),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const s=e.aa.transformMat4([],r,t),a=1/s[3]/i*o;return e.aa.mul(s,s,[a,a,n?1/s[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const i=e.Q.sub([],s[t[0]],s[t[1]]),r=e.Q.sub([],s[t[2]],s[t[1]]),n=e.Q.normalize([],e.Q.cross([],i,r)),o=-e.Q.dot(n,s[t[1]]);return n.concat(o)})),l=[];for(let e=0;ea[1]||a[0]>s[1])return 0}return 1}}class mu{static fromPoints(t){const i=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const n of t)e.Q.min(i,i,n),e.Q.max(r,r,n);return new mu(i,r)}static fromTileIdAndHeight(e,t,i){const r=1<e.max[t]||e.min[t]>this.max[t])return!1;return!0}intersectsAabbXY(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t])}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t])}closestPoint(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}fa(mu,"Aabb");const _u=Tl([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:gu}=_u,yu=Tl([{name:"a_pos_3",components:3,type:"Int16"}]);var xu=Tl([{name:"a_pos",type:"Int16",components:2}]);function vu(e){return e*Qc/nh}const bu=[new mu([eh,eh,eh],[th,th,th]),new mu([eh,eh,eh],[0,0,th]),new mu([0,eh,eh],[th,0,th]),new mu([eh,0,eh],[0,th,th]),new mu([0,0,eh],[th,th,th])];function wu(t,i,r,n=!0){const o=e.Q.scale([],t._camera.position,t.worldSize),s=[i,r,1,1];e.aa.transformMat4(s,s,t.pixelMatrixInverse),e.aa.scale(s,s,1/s[3]);const a=e.Q.sub([],s,o),l=e.Q.normalize([],a),c=t.globeMatrix,h=[c[12],c[13],c[14]],u=e.Q.sub([],h,o),d=e.Q.length(u),p=e.Q.normalize([],u),f=t.worldSize/(2*Math.PI),m=e.Q.dot(p,l),_=Math.asin(f/d);if(_1?null:(function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)})(e.a[t],e.b[t],e.angle,Ht(i,0,1))+e.center[t]}function Su(e){if(e.z<=1)return bu[e.z+2*e.y+e.x];const t=Pu(Cu(e));return mu.fromPoints(t)}function Mu(t,i,r){return e.Q.scale(t,t,1-r),e.Q.scaleAndAdd(t,t,i,r)}function Au(t,i,r){for(const n of t)e.Q.transformMat4(n,n,i),e.Q.scale(n,n,r)}function Iu(t,i,r,n){const o=i/t.worldSize,s=t.globeMatrix;if(r.z<=1){const e=Su(r).getCorners();return Au(e,s,o),mu.fromPoints(e)}const a=Cu(r,n),l=Pu(a,Qc+vu(t._tileCoverLift));Au(l,s,o);const c=Number.MAX_VALUE,h=[-c,-c,-c],u=[c,c,c];if(a.contains(t.center)){for(const t of l)e.Q.min(u,u,t),e.Q.max(h,h,t);h[2]=0;const i=t.point,r=[i.x*o,i.y*o,0];return e.Q.min(u,u,r),e.Q.max(h,h,r),new mu(u,h)}if(t._tileCoverLift>0){for(const t of l)e.Q.min(u,u,t),e.Q.max(h,h,t);return new mu(u,h)}const d=[s[12]*o,s[13]*o,s[14]*o],p=a.getCenter(),f=Ht(t.center.lat,-85.051129,Eh),m=Ht(p.lat,-85.051129,Eh),_=yh(t.center.lng),g=xh(f);let y=_-yh(p.lng);const x=g-xh(m);y>.5?y-=1:y<-.5&&(y+=1);let v=0;if(Math.abs(y)>Math.abs(x))v=y>=0?1:3;else{v=x>=0?0:2;const t=[s[4]*o,s[5]*o,s[6]*o],i=-Math.sin(Gt(x>=0?a.getSouth():a.getNorth()))*Qc;e.Q.scaleAndAdd(d,d,t,i)}const b=l[v],w=l[(v+1)%4],T=new Tu(b,w,d),E=[Eu(T,0)||b[0],Eu(T,1)||b[1],Eu(T,2)||b[2]],S=Nu(t.zoom);if(S>0){const n=(function({x:e,y:t,z:i},r,n,o,s){const a=1/(1<.5?d=-1:p<-.5&&(d=1),l=((l+d)*r-(o*=r))*n+o,c=((c+d)*r-o)*n+o,h=(h*r-(s*=r))*n+s,u=(u*r-s)*n+s,[[l,u,0],[c,u,0],[c,h,0],[l,h,0]]})(r,i,t._pixelsPerMercatorPixel,_,g);for(let e=0;eMath.PI/2*1.01}const ju=Gt(85),Gu=Math.cos(ju),qu=Math.sin(ju),Zu=e.a9.create(),$u=e=>{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function Wu(t,i,r,n,o,s,a,l,c){if(s&&t.queryGeometry.isAboveHorizon)return!1;s&&(c*=t.pixelToTileUnitsFactor);const h=t.tileID.canonical,u=r.projection.upVectorScale(h,r.center.lat,r.worldSize).metersToTile;for(const d of i)for(const i of d){const d=i.add(l),p=o&&r.elevation?r.elevation.exaggeration()*o.getElevationAt(d.x,d.y,!0):0,f=r.projection.projectTilePoint(d.x,d.y,h);if(p>0){const e=r.projection.upVector(h,d.x,d.y);f.x+=e[0]*u*p,f.y+=e[1]*u*p,f.z+=e[2]*u*p}const m=s?d:Qu(f.x,f.y,f.z,n),_=s?t.tilespaceRays.map((e=>Yu(e,p))):t.queryGeometry.screenGeometry,g=e.aa.transformMat4([],[f.x,f.y,f.z,1],n);if(!a&&s?c*=g[3]/r.cameraToCenterDistance:a&&!s&&(c*=r.cameraToCenterDistance/g[3]),s){const e=wh((i.y/no+h.y)/(1<e.width||n.height>e.height||i.x>e.width-n.width||i.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||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const a=e.data,l=t.data,c=4===o&&s;for(let s=0;s{t[e.evaluationKey]=o;const s=e.expression.evaluate(t);s&&(n.data[i+r+0]=Math.floor(255*s.r/s.a),n.data[i+r+1]=Math.floor(255*s.g/s.a),n.data[i+r+2]=Math.floor(255*s.b/s.a),n.data[i+r+3]=Math.floor(255*s.a))};if(e.clips)for(let t=0,n=0;t80*i){r=o=e[0],n=s=e[1];for(var f=i;fo&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-r,s-n))?32767/c:0}return _d(d,p,i,r,n,c,0),p}function fd(e,t,i,r,n){var o,s;if(n===Fd(e,t,i,r)>0)for(o=t;o=t;o-=r)s=kd(o,e[o],e[o+1],s);return s&&Cd(s,s.next)&&(Od(s),s=s.next),s}function md(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!Cd(r,r.next)&&0!==Id(r.prev,r,r.next))r=r.next;else{if(Od(r),(r=t=r.prev)===r.next)break;i=!0}}while(i||r!==t);return t}function _d(e,t,i,r,n,o,s){if(e){!s&&o&&(function(e,t,i,r){var n=e;do{0===n.z&&(n.z=Ed(n.x,n.y,t,i,r)),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,i,r,n,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,c*=2}while(s>1)})(n)})(e,r,n,o);for(var a,l,c=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?yd(e,r,n,o):gd(e))t.push(a.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),Od(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?_d(e=xd(md(e),t,i),t,i,r,n,o,2):2===s&&vd(e,t,i,r,n,o):_d(md(e),t,i,r,n,o,1);break}}}function gd(e){var t=e.prev,i=e,r=e.next;if(Id(t,i,r)>=0)return!1;for(var n=t.x,o=i.x,s=r.x,a=t.y,l=i.y,c=r.y,h=no?n>s?n:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c,f=r.next;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&Md(n,a,o,l,s,c,f.x,f.y)&&Id(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function yd(e,t,i,r){var n=e.prev,o=e,s=e.next;if(Id(n,o,s)>=0)return!1;for(var a=n.x,l=o.x,c=s.x,h=n.y,u=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=Ed(p,f,t,i,r),y=Ed(m,_,t,i,r),x=e.prevZ,v=e.nextZ;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&Md(a,h,l,u,c,d,x.x,x.y)&&Id(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&Md(a,h,l,u,c,d,v.x,v.y)&&Id(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&Md(a,h,l,u,c,d,x.x,x.y)&&Id(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&Md(a,h,l,u,c,d,v.x,v.y)&&Id(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function xd(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!Cd(n,o)&&Pd(n,r,r.next,o)&&Rd(n,o)&&Rd(o,n)&&(t.push(n.i/i|0),t.push(r.i/i|0),t.push(o.i/i|0),Od(r),Od(r.next),r=e=o),r=r.next}while(r!==e);return md(r)}function vd(e,t,i,r,n,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Ad(s,a)){var l=Ld(s,a);return s=md(s,s.next),l=md(l,l.next),_d(s,t,i,r,n,o,0),void _d(l,t,i,r,n,o,0)}a=a.next}s=s.next}while(s!==e)}function bd(e,t){return e.x-t.x}function wd(e,t){var i=(function(e,t){var i,r=t,n=e.x,o=e.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s&&(s=a,i=r.x=r.x&&r.x>=h&&n!==r.x&&Md(oi.x||r.x===i.x&&Td(i,r)))&&(i=r,d=l)),r=r.next}while(r!==c);return i})(e,t);if(!i)return t;var r=Ld(i,e);return md(r,r.next),md(i,i.next)}function Td(e,t){return Id(e.prev,e,t.prev)<0&&Id(t.next,e,e.next)<0}function Ed(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Sd(e){var t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(r-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function Ad(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!(function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Pd(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1})(e,t)&&(Rd(e,t)&&Rd(t,e)&&(function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r})(e,t)&&(Id(e.prev,e,t.prev)||Id(e,t.prev,t))||Cd(e,t)&&Id(e.prev,e,e.next)>0&&Id(t.prev,t,t.next)>0)}function Id(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Cd(e,t){return e.x===t.x&&e.y===t.y}function Pd(e,t,i,r){var n=Dd(Id(e,t,i)),o=Dd(Id(e,t,r)),s=Dd(Id(i,r,e)),a=Dd(Id(i,r,t));return n!==o&&s!==a||!(0!==n||!zd(e,i,t))||!(0!==o||!zd(e,r,t))||!(0!==s||!zd(i,e,r))||!(0!==a||!zd(i,t,r))}function zd(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Dd(e){return e>0?1:e<0?-1:0}function Rd(e,t){return Id(e.prev,e,e.next)<0?Id(e,t,e.next)>=0&&Id(e,e.prev,t)>=0:Id(e,t,e.prev)<0||Id(e,e.next,t)<0}function Ld(e,t){var i=new Bd(e.i,e.x,e.y),r=new Bd(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function kd(e,t,i,r){var n=new Bd(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Od(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 Bd(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Fd(e,t,i,r){for(var n=0,o=t,s=i-r;o0&&i.holes.push(r+=e[n-1].length)}return i};var Nd=u(dd.exports);function Vd(e,t){const i=e.length;if(i<=1)return[e];const r=[];let n,o;for(let t=0;t1)for(let e=0;ee.fqid)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Sl,this.indexArray=new Gl,this.indexArray2=new Fl,this.programConfigurations=new jc(e.layers,e.zoom),this.segments=new mc,this.segments2=new mc,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}populate(e,t,i,r){this.hasPattern=jd("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,h=Fh(s,e);if(!this.layers[0]._featureFilter.filter(new Va(this.zoom),h,i))continue;const u=n?n.evaluate(h,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?h.geometry:Bh(s,i,r),patterns:{},sortKey:u};o.push(d)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const e=Gd("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.availableImages,t.brightness);t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n)}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ud),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,r,n,o=[],s){for(const e of Vd(t,500)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),n.push(t[0].x),n.push(t[0].y);for(let e=1;e>3}if(n--,1===r||2===r)o+=e.readSVarint(),s+=e.readSVarint(),1===r&&(t&&a.push(t),t=[]),t.push(new ep(o,s));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&a.push(t),a},ip.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos>3}if(r--,1===i||2===i)(n+=e.readSVarint())a&&(a=n),(o+=e.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},ip.prototype.toGeoJSON=function(e,t,i){var r,n,o=this.extent*Math.pow(2,i),s=this.extent*e,a=this.extent*t,l=this.loadGeometry(),c=ip.types[this.type];function h(e){for(var t=0;t>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t})(i))}ap.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new op(this._pbf,t,this.extent,this._keys,this._values)};var cp=sp;function hp(e,t,i){if(3===e){var r=new cp(i,i.readVarint()+i.pos);r.length&&(t[r.name]=r)}}var up=Kd.VectorTile=function(e,t){this.layers=e.readFields(hp,{},t)},dp=Kd.VectorTileFeature=tp;function pp(e,t,i,r){const n=[],o=0===r?(e,t,i,r,n,o)=>{e.push(new Vt(o,i+(o-t)/(r-t)*(n-i)))}:(e,t,i,r,n,o)=>{e.push(new Vt(t+(o-i)/(n-i)*(r-t),o))};for(const s of e){const e=[];for(const n of s){if(n.length<=2)continue;const s=[];for(let e=0;et&&o(s,a,l,c,h,t):u>i?d=t&&o(s,a,l,c,h,t),d>i&&u<=i&&o(s,a,l,c,h,i)}let a=n[n.length-1];const l=0===r?a.x:a.y;l>=t&&l<=i&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),e.push(s))}e.length&&n.push(e)}return n}function fp(e,t){return e.x-t.x||e.y-t.y}function mp(e,t){return 0===fp(e.min,t.min)&&0===fp(e.max,t.max)}function _p(e,t){return!(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew Vt((e.x+o.x*no)*a-s.x*no,(e.y+o.y*no)*a-s.y*no)))}return xp(i,n,e.indices,0,e.indices.length,0,0)}Kd.VectorTileLayer=sp;class bp{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const i=this.toIdx(e,t);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function wp(e,t,i,r){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(r[s])<1e-15){if(i[s]t[s])return null}else{const a=1/r[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e}if(l>n&&(n=l),co)return null}return n}function Tp(e,t,i,r,n,o,s,a,l,c,h){const u=r-e,d=n-t,p=o-i,f=s-e,m=a-t,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,x=h[0]*m-h[1]*f,v=u*g+d*y+p*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,E=c[2]-i,S=(w*g+T*y+E*x)*b;if(S<0||S>1)return null;const M=T*p-E*d,A=E*u-w*p,I=w*d-T*u,C=(h[0]*M+h[1]*A+h[2]*I)*b;return C<0||S+C>1?null:(f*M+m*A+_*I)*b}function Ep(e,t,i){return(e-t)/(i-t)}function Sp(e,t,i,r,n,o,s,a,l){const c=1<{const o=r?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=a,n[2]=s,n[3]=l};let s=new bp(r);const a=[];for(let t=0;t=1;r/=2){const e=i[i.length-1];s=new bp(r);for(let t=0;t0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){Sp(m,_,g,t,i,r,n,u,d);const l=1<=t[2])return f}continue}let y=0;for(let e=0;e=c[h[r]]&&(h.splice(r,0,e),i=!0);i||(h[y]=e),y++}}for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}static pack(e,t){const i=[0,0,0,0],r=Dp.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new nd({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;te.max.x&&(e.max.x=t.x,r=!0),t.ye.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===no)&&t.x===i.x)!=((0===t.y||t.y===no)&&t.y===i.y)&&this.processBorderOverlap(t,i),r&&this.checkBorderIntersection(t,i)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,jr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>no!=e.x>no&&this.addBorderIntersection(1,jr(t.y,e.y,(no-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,jr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>no!=e.y>no&&this.addBorderIntersection(3,jr(t.x,e.x,(no-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];ti[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){return 0===this.accCount?new Vt(0,0):new Vt(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0):0}}function Wp(e,t){const i=e.add(t)._unit(),r=Ht(e.x*i.x+e.y*i.y,-1,1);var n,o,s;return n=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(n)))/4*Fp*((o=e).x*(s=t).y-o.y*s.x<0?-1:1)}const Qp=[e=>e.x<0,e=>e.x>no,e=>e.y<0,e=>e.y>no];function Hp(e,t,i,r){const n=[4];if(0===r)return n;i._mult(r);const o=e.sub(i),s=t.sub(i),a=[e,t,o,s];for(let e=0;e<4;e++)for(const t of a)if(Qp[e](t)){n.push(e);break}return n}class Xp{constructor(e){this.vertexArray=new Il,this.indexArray=new Gl,this.programConfigurations=new jc(e.layers,e.zoom,(e=>Op.includes(e))),this._segments=new mc,this.hiddenByLandmarkVertexArray=new tc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new mc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,r=!1){const n=e.length;if(n>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],i=e[1];a=Wp(t.sub(e[n-1])._perp()._unit(),i.sub(t)._perp()._unit())}for(let l=0;le.region-t.region));for(let i=0;ie+t),0);let o=0;for(let e=0;e<=4;e++){const t=n[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new mc);const n={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};i.get().push(n)}o+=t}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Xd.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy()}}}}class Yp{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Gl,this.footprintVertices=new Sl,this.footprintSegments=[],this.layoutVertexArray=new Al,this.centroidVertexArray=new dc,this.indexArray=new Gl,this.programConfigurations=new jc(e.layers,e.zoom,(e=>kp.includes(e))),this.segments=new mc,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.groundEffect=new Xp(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}populate(e,t,i,r){this.features=[],this.hasPattern=jd("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=Ih(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Fh(n,e);if(!this.layers[0]._featureFilter.filter(new Va(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Bh(n,i,r),properties:n.properties,type:n.type,patterns:{}},h=this.layoutVertexArray.length;this.hasPattern?this.features.push(Gd("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,s,i,{},t.availableImages,r,t.brightness),t.featureIndex.insert(n,c.geometry,s,a,this.index,h)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,i,r,n,o){for(const e of this.features){const{geometry:s}=e;this.addFeature(e,s,e.index,t,i,r,n,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,i,r,n){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,t,s,i,r,n),this.groundEffect.update(e,t,s,i,r,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Jd),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Yd.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Hd.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,r,n,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,c=[new Vt(0,0),new Vt(no,no)],h=s.projection,u="globe"===h.name,d="Polygon"===Lp[e.type],p=new $p;p.centroidDataIndex=this.centroidData.length;const f=new Zp,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},r);f.height=_,f.vertexArrayOffset=this.layoutVertexArray.length,f.groundVertexArrayOffset=this.groundEffect.vertexArray.length,u&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Ll);const g=Vd(t,500);for(let e=g.length-1;e>=0;e--){const t=g[e];(0===t.length||(y=t[0]).every((e=>e.x<=0))||y.every((e=>e.x>=no))||y.every((e=>e.y<=0))||y.every((e=>e.y>=no)))&&g.splice(e,1)}var y;let x;if(u)x=af(g,c,r);else{x=[];for(const e of g)x.push({polygon:e,bounds:c})}const v=d?this.edgeRadius:0,b=v>0&&this.zoom<17,w=(e,t)=>{if(0===e.length)return!1;const i=e[e.length-1];return t.x===i.x&&t.y===i.y};for(const{polygon:e,bounds:t}of x){let i=0,n=0;for(const t of e)d&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=d?t.length-1:t.length;const o=this.segments.prepareSegment((d?5:4)*n,this.layoutVertexArray,this.indexArray);f.footprintSegIdx<0&&(f.footprintSegIdx=this.footprintSegments.length),f.polygonSegIdx<0&&(f.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new qp;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],d){const n=[],s=[];i=o.vertexLength;for(let i=0;i4&&nf(s[s.length-2],s[0],s[1]),c=v?Kp(s[s.length-2],s[0],s[1],v):0;const _=[];let g,y,x;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let e=1,n=0;e0?1:0,A=l.dist(d);if(n+A>32768&&(n=0),v){x=T.sub(d)._perp()._unit();let e=ef(l,d,T,Jp(y,x),v);isNaN(e)&&(e=0);const t=d.sub(l)._unit();l=l.add(t.mult(c))._round(),d=d.add(t.mult(-e))._round(),c=e,y=x,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,d)||_.push(d))}const I=o.vertexLength,C=s.length>4&&nf(l,d,T);let P=of(n,a,b);if(Up(this.layoutVertexArray,l.x,l.y,S,M,0,0,P),Up(this.layoutVertexArray,l.x,l.y,S,M,0,1,P),n+=A,P=of(n,C,!b),a=C,Up(this.layoutVertexArray,d.x,d.y,S,M,0,0,P),Up(this.layoutVertexArray,d.x,d.y,S,M,0,1,P),o.vertexLength+=4,this.indexArray.emplaceBack(I+0,I+1,I+2),this.indexArray.emplaceBack(I+1,I+3,I+2),o.primitiveLength+=2,v){const r=i+(1===e?s.length-2:e-2),n=1===e?i:r+1;if(this.indexArray.emplaceBack(I+1,r,I+3),this.indexArray.emplaceBack(r,n,I+3),o.primitiveLength+=2,void 0===g&&(g=I),!tf(T,s[e],t)){const t=e===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(I+2,I+3,t),this.indexArray.emplaceBack(I+3,t+1,t),this.indexArray.emplaceBack(I+3,n,t+1),o.primitiveLength+=3}b=!b}if(u){const e=this.layoutVertexExtArray,t=h.projectTilePoint(l.x,l.y,r),i=h.projectTilePoint(d.x,d.y,r),n=h.upVector(r,l.x,l.y),o=h.upVector(r,d.x,d.y);Gp(e,t,n),Gp(e,t,n),Gp(e,i,o),Gp(e,i,o)}}d&&(i+=s.length-1),m&&v&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,t,l,v>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?Np:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]))}splitToSubtiles(){const e=[];for(let t=0;tno),n=2*r+(+(i.min.x+i.max.x>no)^r);for(let r=0;re.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx));let i=0,r=0,n=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;n++}const o=e.length;for(;r!==e.length;){i=e[r].triangleSegmentIdx;let s=0,a=r,l=r;for(let t=a;t0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let t=a;t[e[0]*(1-i[0])+t[0]*i[0],e[1]*(1-i[1])+t[1]*i[1]],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/no,d[1]=e.min.y/no,p[0]=e.max.x/no,p[1]=e.max.y/no;const t=u(l,c,d),o=u(l,c,p);if(0===new mu([t[0],t[1],r],[o[0],o[1],n]).intersectsPrecise(i)){a&&(h.segments.push(a),a=void 0);continue}const s=e.segment;a&&a.vertexOffset!==s.vertexOffset&&(h.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&h.segments.push(a),h}encodeCentroid(e,t){const i=e.centroid(),r=t.span(),n=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new Vt(Ht(i.x,1,8191)<<3|n,Ht(i.y,1,8191)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new Vt(0,0);const t=e.borders,i=Number.MAX_VALUE;if(t[0][0]!==i||t[1][0]!==i){const e=t[0][0]!==i?0:1;return new Vt(6|(t[0][0]!==i?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==i?2:3;return new Vt((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=Vp,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,r=e.flags&Vp?Np:e.centroidXY,n=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||n!==r.x){for(let e=t;en.max.x||n.min.x>t.max.x||t.min.y>n.max.y||n.min.y>t.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(r=!r)}s=i}}return r}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,r=!0;const n=4*(e+no)*no+(t+no);if(this.partLookup.hasOwnProperty(n)){const e=this.partLookup[n];return e?{height:e.height,hidden:!!(e.flags&Vp)}:void 0}for(const 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>i&&(i=o.height,this.partLookup[n]=o,r=!!(o.flags&Vp));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:r};this.partLookup[n]=void 0}}function Jp(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function Kp(e,t,i,r){const n=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return ef(e,t,i,Jp(n,o),r)}function ef(e,t,i,r,n){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(i)/3,n*o/r)}function tf(e,t,i){return e.xi[1].x&&t.x>i[1].x||e.yi[1].y&&t.y>i[1].y}function rf(e,t){return e.xt[1].x||e.yt[1].y}function nf(e,t,i){if(e.x<0||e.x>=no||t.x<0||t.x>=no||i.x<0||i.x>=no)return!1;const r=i.sub(t),n=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function of(e,t,i){const r=t?2|e:-3&e;return i?1|r:-2&r}function sf(){const e=Math.PI/32,t=Math.tan(e),i=nh;return i*Math.sqrt(1+2*t*t)-i}function af(e,t,i){const r=1<{for(const i of e)s.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(r)),h=l-c,u=[];for(let e=0;e0?0:1);for(let e=0;et+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e)}if(f.length){const e=[new Vt(0===i?h:r.x,1===i?h:r.y),s];u.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return s})(e,t,Math.ceil((o-n)/11.25),Math.ceil((s-a)/11.25),1,((e,t,n)=>{if(0===e)return.5*(t+n);{const e=wh((i.y+t/no)/r);return(xh(.5*(wh((i.y+n/no)/r)+e))*r-i.y)*no}}))}function lf(e,t,i,r,n,o){const s=Math.pow(2,r.z-n.z);for(let a=0;a1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e)}else u=r-Math.sqrt(h*h+d*d);this.image.data[n+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i1&&(s=e[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return ui("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;te.fqid)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new Cl,this.layoutVertexArray2=new Pl,this.patternVertexArray=new zl,this.indexArray=new Gl,this.programConfigurations=new jc(e.layers,e.zoom),this.segments=new mc,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,i,r){this.hasPattern=jd("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Fh(t,e);if(!this.layers[0]._featureFilter.filter(new Va(this.zoom),c,i))continue;const h=n?n.evaluate(c,{},i):void 0,u={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Bh(t,i,r),patterns:{},sortKey:h};o.push(u)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:s,featureIndex:a}=t,l=this.addConstantDashes(s);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,s),this.hasPattern){const e=Gd("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,s.positions,t.availableImages,t.brightness);a.insert(e[o].feature,n,o,c,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else{const t=n.value,i=r.value;if(!i)continue;e.addDash(i,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a;if("constant"===n.kind){if(s=n.value,!s)continue}else s=n.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[r.id]=t.getKey(s,a)}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n)}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,yf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,vf)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,_f),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,r,n,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap").evaluate(e,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,s)}addLine(e,t,i,r,n,o){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0;const s="none"===i;if(this.patternJoinNone=this.hasPattern&&s,this.segmentStart=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[l-1].equals(e[l-2]);)l--;let c=0;for(;c0;if(E&&t>c){const e=d.dist(p);if(e>2*h){const t=d.sub(d.sub(p)._mult(h/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,m,0,0,u),p=t}}if(g&&"round"===y&&(wn&&(y="bevel"),"bevel"===y&&(w>2&&(y="flipbevel"),w100)v=_.mult(-1);else{const e=w*m.add(_).mag()/m.sub(_).mag();v._perp()._mult(e*(S?-1:1))}this.addCurrentVertex(d,v,0,0,u),this.addCurrentVertex(d,v.mult(-1),0,0,u)}else if("bevel"===y||"fakeround"===y){const e=-Math.sqrt(w*w-1),t=S?e:0,i=S?0:e;if(p&&this.addCurrentVertex(d,m,t,i,u),"fakeround"===y){const e=Math.round(180*T/Math.PI/20);for(let t=1;t2*h){const t=d.add(f.sub(d)._mult(h/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,_,0,0,u),d=t}}}}addCurrentVertex(e,t,i,r,n,o=!1){const s=t.y*r-t.x,a=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,n),this.addHalfVertex(e,s,a,o,!0,-r,n),this.patternJoinNone&&this.segmentPoints.push(this.lineSoFar-this.segmentStart,i)}addHalfVertex({x:e,y:t},i,r,n,o,s,a){this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}fa(Sf,"LineBucket",{omit:["layers","patternFeatures"]});const Mf=new Ja({"line-cap":new Xa(tl.layout_line["line-cap"]),"line-join":new Xa(tl.layout_line["line-join"]),"line-miter-limit":new Ha(tl.layout_line["line-miter-limit"]),"line-round-limit":new Ha(tl.layout_line["line-round-limit"]),"line-sort-key":new Xa(tl.layout_line["line-sort-key"]),visibility:new Ha(tl.layout_line.visibility)});var Af={paint:new Ja({"line-opacity":new Xa(tl.paint_line["line-opacity"]),"line-color":new Xa(tl.paint_line["line-color"]),"line-translate":new Ha(tl.paint_line["line-translate"]),"line-translate-anchor":new Ha(tl.paint_line["line-translate-anchor"]),"line-width":new Xa(tl.paint_line["line-width"]),"line-gap-width":new Xa(tl.paint_line["line-gap-width"]),"line-offset":new Xa(tl.paint_line["line-offset"]),"line-blur":new Xa(tl.paint_line["line-blur"]),"line-dasharray":new Xa(tl.paint_line["line-dasharray"]),"line-pattern":new Xa(tl.paint_line["line-pattern"]),"line-gradient":new Ya(tl.paint_line["line-gradient"]),"line-trim-offset":new Ha(tl.paint_line["line-trim-offset"]),"line-emissive-strength":new Ha(tl.paint_line["line-emissive-strength"]),"line-border-width":new Xa(tl.paint_line["line-border-width"]),"line-border-color":new Xa(tl.paint_line["line-border-color"])}),layout:Mf};function If(e,t,i){return t*(no/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function Cf(e,t){return 1/If(e,1,t.tileZoom)}function Pf(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const zf=e=>{const t=[];Df(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const r="none"===e.layout.get("line-join").constantOr("miter"),n=!!e.paint.get("line-pattern").constantOr(1);return r&&n&&t.push("LINE_JOIN_NONE"),t};function Df(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const Rf=new class extends Xa{possiblyEvaluate(e,t){return t=new Va(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=Kt({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}(Af.paint.properties["line-width"].specification);function Lf(e,t){return t>0?t+2*e:e}Rf.useIntegerZoom=!0;const kf=Tl([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Of=Tl([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Bf=Tl([{name:"a_projected_pos",components:4,type:"Float32"}],4);Tl([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ff=Tl([{name:"a_z_offset",components:1,type:"Float32"}],4),Nf=Tl([{name:"a_texb",components:2,type:"Uint16"}]),Vf=Tl([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Uf=Tl([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_z_offset",components:1,type:"Float32"}]);Tl([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const jf=Tl([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Gf=Tl([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Tl([{name:"triangle",components:3,type:"Uint16"}]),Tl([{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"}]),Tl([{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"}]),Tl([{type:"Float32",name:"offsetX"}]),Tl([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var qf=24;const Zf=128;function $f(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Va(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n{e.text=(function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Na.applyArabicShaping&&(e=Na.applyArabicShaping(e)),e})(e.text,t,i)})),e}const Yf={"!":"\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 Jf(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 Kf(e){return"\ufe35"===e||"\ufe47"===e||"\ufe37"===e||"\ufe43"===e||"\ufe41"===e||"\ufe3d"===e||"\ufe3b"===e||"\ufe39"===e||"\ufe17"===e||"\ufe3f"===e}var em={ +__d((function(e,t,i,r,n,o,s){var a=t(s[0]),l=t(s[1]);const c=["data"];function u(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function h(e){for(var t=1;t0?(i[0]=2*(a*s+u*r+l*o-c*n)/h,i[1]=2*(l*s+u*n+c*r-a*o)/h,i[2]=2*(c*s+u*o+a*n-l*r)/h):(i[0]=2*(a*s+u*r+l*o-c*n),i[1]=2*(l*s+u*n+c*r-a*o),i[2]=2*(c*s+u*o+a*n-l*r)),G(e,t,i),e},B.getTranslation=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},B.getScaling=q,B.getRotation=function(e,t){var i=new N.ARRAY_TYPE(3);q(i,t);var r=1/i[0],n=1/i[1],o=1/i[2],s=t[0]*r,a=t[1]*n,l=t[2]*o,c=t[4]*r,u=t[5]*n,h=t[6]*o,d=t[8]*r,p=t[9]*n,f=t[10]*o,m=s+u+f,_=0;return m>0?(_=2*Math.sqrt(m+1),e[3]=.25*_,e[0]=(h-p)/_,e[1]=(d-l)/_,e[2]=(a-c)/_):s>u&&s>f?(_=2*Math.sqrt(1+s-u-f),e[3]=(h-p)/_,e[0]=.25*_,e[1]=(a+c)/_,e[2]=(d+l)/_):u>f?(_=2*Math.sqrt(1+u-s-f),e[3]=(d-l)/_,e[0]=(a+c)/_,e[1]=.25*_,e[2]=(h+p)/_):(_=2*Math.sqrt(1+f-s-u),e[3]=(a-c)/_,e[0]=(d+l)/_,e[1]=(h+p)/_,e[2]=.25*_),e},B.fromRotationTranslationScale=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3],l=n+n,c=o+o,u=s+s,h=n*l,d=n*c,p=n*u,f=o*c,m=o*u,_=s*u,g=a*l,y=a*c,x=a*u,v=r[0],b=r[1],w=r[2];return e[0]=(1-(f+_))*v,e[1]=(d+x)*v,e[2]=(p-y)*v,e[3]=0,e[4]=(d-x)*b,e[5]=(1-(h+_))*b,e[6]=(m+g)*b,e[7]=0,e[8]=(p+y)*w,e[9]=(m-g)*w,e[10]=(1-(h+f))*w,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e},B.fromRotationTranslationScaleOrigin=function(e,t,i,r,n){var o=t[0],s=t[1],a=t[2],l=t[3],c=o+o,u=s+s,h=a+a,d=o*c,p=o*u,f=o*h,m=s*u,_=s*h,g=a*h,y=l*c,x=l*u,v=l*h,b=r[0],w=r[1],T=r[2],E=n[0],S=n[1],M=n[2],I=(1-(m+g))*b,A=(p+v)*b,C=(f-x)*b,P=(p-v)*w,z=(1-(d+g))*w,D=(_+y)*w,L=(f+x)*T,R=(_-y)*T,k=(1-(d+m))*T;return e[0]=I,e[1]=A,e[2]=C,e[3]=0,e[4]=P,e[5]=z,e[6]=D,e[7]=0,e[8]=L,e[9]=R,e[10]=k,e[11]=0,e[12]=i[0]+E-(I*E+P*S+L*M),e[13]=i[1]+S-(A*E+z*S+R*M),e[14]=i[2]+M-(C*E+D*S+k*M),e[15]=1,e},B.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,u=r*s,h=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-h-f,e[1]=u+g,e[2]=d-_,e[3]=0,e[4]=u-g,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+_,e[9]=p-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},B.frustum=function(e,t,i,r,n,o,s){var a=1/(i-t),l=1/(n-r),c=1/(o-s);return e[0]=2*o*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(i+t)*a,e[9]=(n+r)*l,e[10]=(s+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*c,e[15]=0,e},B.perspectiveNO=Z,B.perspectiveZO=function(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=n*(o=1/(r-n)),e[14]=n*r*o):(e[10]=-1,e[14]=-r),e},B.perspectiveFromFieldOfView=function(e,t,i,r){var n=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),s=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),l=2/(s+a),c=2/(n+o);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=-(s-a)*l*.5,e[9]=(n-o)*c*.5,e[10]=r/(i-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*i/(i-r),e[15]=0,e},B.orthoNO=$,B.orthoZO=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=o*c,e[15]=1,e},B.lookAt=function(e,t,i,r){var n,o,s,a,l,c,u,h,d,p,f=t[0],m=t[1],_=t[2],g=r[0],y=r[1],x=r[2],v=i[0],b=i[1],w=i[2];return Math.abs(f-v)0&&(u*=p=1/Math.sqrt(p),h*=p,d*=p);var f=l*d-c*h,m=c*u-a*d,_=a*h-l*u;return(p=f*f+m*m+_*_)>0&&(f*=p=1/Math.sqrt(p),m*=p,_*=p),e[0]=f,e[1]=m,e[2]=_,e[3]=0,e[4]=h*_-d*m,e[5]=d*f-u*_,e[6]=u*m-h*f,e[7]=0,e[8]=u,e[9]=h,e[10]=d,e[11]=0,e[12]=n,e[13]=o,e[14]=s,e[15]=1,e},B.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]+")"},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],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},B.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e[9]=t[9]+i[9],e[10]=t[10]+i[10],e[11]=t[11]+i[11],e[12]=t[12]+i[12],e[13]=t[13]+i[13],e[14]=t[14]+i[14],e[15]=t[15]+i[15],e},B.subtract=W,B.multiplyScalar=function(e,t,i){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]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12]*i,e[13]=t[13]*i,e[14]=t[14]*i,e[15]=t[15]*i,e},B.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e[9]=t[9]+i[9]*r,e[10]=t[10]+i[10]*r,e[11]=t[11]+i[11]*r,e[12]=t[12]+i[12]*r,e[13]=t[13]+i[13]*r,e[14]=t[14]+i[14]*r,e[15]=t[15]+i[15]*r,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]&&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]},B.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=t[0],x=t[1],v=t[2],b=t[3],w=t[4],T=t[5],E=t[6],S=t[7],M=t[8],I=t[9],A=t[10],C=t[11],P=t[12],z=t[13],D=t[14],L=t[15];return Math.abs(i-y)<=N.EPSILON*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-x)<=N.EPSILON*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=N.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(o-b)<=N.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=N.EPSILON*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=N.EPSILON*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=N.EPSILON*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-S)<=N.EPSILON*Math.max(1,Math.abs(c),Math.abs(S))&&Math.abs(u-M)<=N.EPSILON*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(h-I)<=N.EPSILON*Math.max(1,Math.abs(h),Math.abs(I))&&Math.abs(d-A)<=N.EPSILON*Math.max(1,Math.abs(d),Math.abs(A))&&Math.abs(p-C)<=N.EPSILON*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(f-P)<=N.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(m-z)<=N.EPSILON*Math.max(1,Math.abs(m),Math.abs(z))&&Math.abs(_-D)<=N.EPSILON*Math.max(1,Math.abs(_),Math.abs(D))&&Math.abs(g-L)<=N.EPSILON*Math.max(1,Math.abs(g),Math.abs(L))},B.sub=B.mul=B.ortho=B.perspective=void 0;var N=(function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==F(e)&&"function"!=typeof e)return{default:e};var i=V(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r})(f);function V(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(V=function(e){return e?i:t})(e)}function U(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function j(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*a+b*h+w*m,e[1]=x*n+v*l+b*d+w*_,e[2]=x*o+v*c+b*p+w*g,e[3]=x*s+v*u+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*h+(w=i[7])*m,e[5]=x*n+v*l+b*d+w*_,e[6]=x*o+v*c+b*p+w*g,e[7]=x*s+v*u+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*h+(w=i[11])*m,e[9]=x*n+v*l+b*d+w*_,e[10]=x*o+v*c+b*p+w*g,e[11]=x*s+v*u+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*h+(w=i[15])*m,e[13]=x*n+v*l+b*d+w*_,e[14]=x*o+v*c+b*p+w*g,e[15]=x*s+v*u+b*f+w*y,e}function G(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=r+r,l=n+n,c=o+o,u=r*a,h=r*l,d=r*c,p=n*l,f=n*c,m=o*c,_=s*a,g=s*l,y=s*c;return e[0]=1-(p+m),e[1]=h+y,e[2]=d-g,e[3]=0,e[4]=h-y,e[5]=1-(u+m),e[6]=f+_,e[7]=0,e[8]=d+g,e[9]=f-_,e[10]=1-(u+p),e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}function q(e,t){var i=t[4],r=t[5],n=t[6],o=t[8],s=t[9],a=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(i,r,n),e[2]=Math.hypot(o,s,a),e}function Z(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+r)*(o=1/(r-n)),e[14]=2*n*r*o):(e[10]=-1,e[14]=-2*r),e}function $(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e}function W(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e[9]=t[9]-i[9],e[10]=t[10]-i[10],e[11]=t[11]-i[11],e[12]=t[12]-i[12],e[13]=t[13]-i[13],e[14]=t[14]-i[14],e[15]=t[15]-i[15],e}B.perspective=Z,B.ortho=$,B.mul=j,B.sub=W;var H={},X={};function Y(e){return Y="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},Y(e)}Object.defineProperty(X,"__esModule",{value:!0}),X.create=Q,X.clone=function(e){var t=new K.ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},X.length=ee,X.fromValues=function(e,t,i){var r=new K.ARRAY_TYPE(3);return r[0]=e,r[1]=t,r[2]=i,r},X.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},X.set=function(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e},X.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e},X.subtract=te,X.multiply=ie,X.divide=re,X.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},X.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},X.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e},X.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e},X.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},X.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e},X.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e},X.distance=ne,X.squaredDistance=oe,X.squaredLength=se,X.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},X.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},X.normalize=function(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},X.dot=ae,X.cross=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e},X.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e},X.hermite=function(e,t,i,r,n,o){var s=o*o,a=s*(2*o-3)+1,l=s*(o-2)+o,c=s*(o-1),u=s*(3-2*o);return e[0]=t[0]*a+i[0]*l+r[0]*c+n[0]*u,e[1]=t[1]*a+i[1]*l+r[1]*c+n[1]*u,e[2]=t[2]*a+i[2]*l+r[2]*c+n[2]*u,e},X.bezier=function(e,t,i,r,n,o){var s=1-o,a=s*s,l=o*o,c=a*s,u=3*o*a,h=3*l*s,d=l*o;return e[0]=t[0]*c+i[0]*u+r[0]*h+n[0]*d,e[1]=t[1]*c+i[1]*u+r[1]*h+n[1]*d,e[2]=t[2]*c+i[2]*u+r[2]*h+n[2]*d,e},X.random=function(e,t){t=t||1;var i=2*K.RANDOM()*Math.PI,r=2*K.RANDOM()-1,n=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(i)*n,e[1]=Math.sin(i)*n,e[2]=r*t,e},X.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e},X.transformMat3=function(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e},X.transformQuat=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=n*l-o*a,u=o*s-r*l,h=r*a-n*s,d=n*h-o*u,p=o*c-r*h,f=r*u-n*c,m=2*i[3];return u*=m,h*=m,p*=2,f*=2,e[0]=s+(c*=m)+(d*=2),e[1]=a+u+p,e[2]=l+h+f,e},X.rotateX=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0],o[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),o[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},X.rotateY=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),o[1]=n[1],o[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},X.rotateZ=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),o[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),o[2]=n[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},X.angle=function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2],l=Math.sqrt(i*i+r*r+n*n)*Math.sqrt(o*o+s*s+a*a),c=l&&ae(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))},X.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e},X.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},X.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},X.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(i-o)<=K.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-s)<=K.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-a)<=K.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))},X.forEach=X.sqrLen=X.len=X.sqrDist=X.dist=X.div=X.mul=X.sub=void 0;var K=(function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Y(e)&&"function"!=typeof e)return{default:e};var i=J(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r})(f);function J(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(J=function(e){return e?i:t})(e)}function Q(){var e=new K.ARRAY_TYPE(3);return K.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ee(e){return Math.hypot(e[0],e[1],e[2])}function te(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function ie(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function re(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e}function ne(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function oe(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}function se(e){var t=e[0],i=e[1],r=e[2];return t*t+i*i+r*r}function ae(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}X.sub=te,X.mul=ie,X.div=re,X.dist=ne,X.sqrDist=oe,X.len=ee,X.sqrLen=se;var le,ce=(le=Q(),function(e,t,i,r,n,o){var s,a;for(t||(t=3),i||(i=0),a=r?Math.min(r*t+i,e.length):e.length,s=i;s0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e},ue.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},ue.cross=function(e,t,i,r){var n=i[0]*r[1]-i[1]*r[0],o=i[0]*r[2]-i[2]*r[0],s=i[0]*r[3]-i[3]*r[0],a=i[1]*r[2]-i[2]*r[1],l=i[1]*r[3]-i[3]*r[1],c=i[2]*r[3]-i[3]*r[2],u=t[0],h=t[1],d=t[2],p=t[3];return e[0]=h*c-d*l+p*a,e[1]=-u*c+d*s-p*o,e[2]=u*l-h*s+p*n,e[3]=-u*a+h*o-d*n,e},ue.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e[3]=a+r*(i[3]-a),e},ue.random=function(e,t){var i,r,n,o,s,a;t=t||1;do{s=(i=2*de.RANDOM()-1)*i+(r=2*de.RANDOM()-1)*r}while(s>=1);do{a=(n=2*de.RANDOM()-1)*n+(o=2*de.RANDOM()-1)*o}while(a>=1);var l=Math.sqrt((1-s)/a);return e[0]=t*i,e[1]=t*r,e[2]=t*n*l,e[3]=t*o*l,e},ue.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e},ue.transformQuat=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2],c=i[3],u=c*r+a*o-l*n,h=c*n+l*r-s*o,d=c*o+s*n-a*r,p=-s*r-a*n-l*o;return e[0]=u*c+p*-s+h*-l-d*-a,e[1]=h*c+p*-a+d*-s-u*-l,e[2]=d*c+p*-l+u*-a-h*-s,e[3]=t[3],e},ue.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},ue.str=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},ue.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},ue.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(i-s)<=de.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-a)<=de.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-l)<=de.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-c)<=de.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},ue.forEach=ue.sqrLen=ue.len=ue.sqrDist=ue.dist=ue.div=ue.mul=ue.sub=void 0;var de=(function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==he(e)&&"function"!=typeof e)return{default:e};var i=pe(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r})(f);function pe(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(pe=function(e){return e?i:t})(e)}function fe(){var e=new de.ARRAY_TYPE(4);return de.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function me(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}function _e(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}function ge(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e[3]=t[3]/i[3],e}function ye(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3])}function xe(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2],o=t[3]-e[3];return i*i+r*r+n*n+o*o}function ve(e){return Math.hypot(e[0],e[1],e[2],e[3])}function be(e){var t=e[0],i=e[1],r=e[2],n=e[3];return t*t+i*i+r*r+n*n}ue.sub=me,ue.mul=_e,ue.div=ge,ue.dist=ye,ue.sqrDist=xe,ue.len=ve,ue.sqrLen=be;var we=(function(){var e=fe();return function(t,i,r,n,o,s){var a,l;for(i||(i=4),r||(r=0),l=n?Math.min(n*i+r,t.length):t.length,a=r;aEe.EPSILON?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),i},H.getAngle=function(e,t){var i=Fe(e,t);return Math.acos(2*i*i-1)},H.multiply=De,H.rotateX=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a,e},H.rotateY=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a,e},H.rotateZ=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*a,e[1]=n*l-r*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e},H.calculateW=function(e,t){var i=t[0],r=t[1],n=t[2];return e[0]=i,e[1]=r,e[2]=n,e[3]=Math.sqrt(Math.abs(1-i*i-r*r-n*n)),e},H.exp=Le,H.ln=Re,H.pow=function(e,t,i){return Re(e,t),Be(e,e,i),Le(e,e),e},H.slerp=ke,H.random=function(e){var t=Ee.RANDOM(),i=Ee.RANDOM(),r=Ee.RANDOM(),n=Math.sqrt(1-t),o=Math.sqrt(t);return e[0]=n*Math.sin(2*Math.PI*i),e[1]=n*Math.cos(2*Math.PI*i),e[2]=o*Math.sin(2*Math.PI*r),e[3]=o*Math.cos(2*Math.PI*r),e},H.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o,a=s?1/s:0;return e[0]=-i*a,e[1]=-r*a,e[2]=-n*a,e[3]=o*a,e},H.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},H.fromMat3=Oe,H.fromEuler=function(e,t,i,r){var n=.5*Math.PI/180;t*=n,i*=n,r*=n;var o=Math.sin(t),s=Math.cos(t),a=Math.sin(i),l=Math.cos(i),c=Math.sin(r),u=Math.cos(r);return e[0]=o*l*u-s*a*c,e[1]=s*a*u+o*l*c,e[2]=s*l*c-o*a*u,e[3]=s*l*u+o*a*c,e},H.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},H.setAxes=H.sqlerp=H.rotationTo=H.equals=H.exactEquals=H.normalize=H.sqrLen=H.squaredLength=H.len=H.length=H.lerp=H.dot=H.scale=H.mul=H.add=H.set=H.copy=H.fromValues=H.clone=void 0;var Ee=Ce(f),Se=Ce(z),Me=Ce(X),Ie=Ce(ue);function Ae(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(Ae=function(e){return e?i:t})(e)}function Ce(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Te(e)&&"function"!=typeof e)return{default:e};var i=Ae(t);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r}function Pe(){var e=new Ee.ARRAY_TYPE(4);return Ee.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ze(e,t,i){i*=.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function De(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],u=i[3];return e[0]=r*u+s*a+n*c-o*l,e[1]=n*u+s*l+o*a-r*c,e[2]=o*u+s*c+r*l-n*a,e[3]=s*u-r*a-n*l-o*c,e}function Le(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=Math.exp(o),l=s>0?a*Math.sin(s)/s:0;return e[0]=i*l,e[1]=r*l,e[2]=n*l,e[3]=a*Math.cos(s),e}function Re(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=s>0?Math.atan2(s,o)/s:0;return e[0]=i*a,e[1]=r*a,e[2]=n*a,e[3]=.5*Math.log(i*i+r*r+n*n+o*o),e}function ke(e,t,i,r){var n,o,s,a,l,c=t[0],u=t[1],h=t[2],d=t[3],p=i[0],f=i[1],m=i[2],_=i[3];return(o=c*p+u*f+h*m+d*_)<0&&(o=-o,p=-p,f=-f,m=-m,_=-_),1-o>Ee.EPSILON?(n=Math.acos(o),s=Math.sin(n),a=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(a=1-r,l=r),e[0]=a*c+l*p,e[1]=a*u+l*f,e[2]=a*h+l*m,e[3]=a*d+l*_,e}function Oe(e,t){var i,r=t[0]+t[4]+t[8];if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,e[0]=(t[5]-t[7])*(i=.5/i),e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);var o=(n+1)%3,s=(n+2)%3;i=Math.sqrt(t[3*n+n]-t[3*o+o]-t[3*s+s]+1),e[n]=.5*i,e[3]=(t[3*o+s]-t[3*s+o])*(i=.5/i),e[o]=(t[3*o+n]+t[3*n+o])*i,e[s]=(t[3*s+n]+t[3*n+s])*i}return e}H.clone=Ie.clone,H.fromValues=Ie.fromValues,H.copy=Ie.copy,H.set=Ie.set,H.add=Ie.add,H.mul=De;var Be=Ie.scale;H.scale=Be;var Fe=Ie.dot;H.dot=Fe,H.lerp=Ie.lerp;var Ne=Ie.length;H.length=Ne,H.len=Ne;var Ve=Ie.squaredLength;H.squaredLength=Ve,H.sqrLen=Ve;var Ue=Ie.normalize;H.normalize=Ue,H.exactEquals=Ie.exactEquals,H.equals=Ie.equals;var je,Ge,qe,Ze=(je=Me.create(),Ge=Me.fromValues(1,0,0),qe=Me.fromValues(0,1,0),function(e,t,i){var r=Me.dot(t,i);return r<-.999999?(Me.cross(je,Ge,t),Me.len(je)<1e-6&&Me.cross(je,qe,t),Me.normalize(je,je),ze(e,je,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Me.cross(je,t,i),e[0]=je[0],e[1]=je[1],e[2]=je[2],e[3]=1+r,Ue(e,e))});H.rotationTo=Ze;var $e,We,He=($e=Pe(),We=Pe(),function(e,t,i,r,n,o){return ke($e,t,n,o),ke(We,i,r,o),ke(e,$e,We,2*o*(1-o)),e});H.sqlerp=He;var Xe,Ye=(Xe=Se.create(),function(e,t,i,r){return Xe[0]=i[0],Xe[3]=i[1],Xe[6]=i[2],Xe[1]=r[0],Xe[4]=r[1],Xe[7]=r[2],Xe[2]=-t[0],Xe[5]=-t[1],Xe[8]=-t[2],Ue(e,Oe(e,Xe))});H.setAxes=Ye;var Ke={};function Je(e){return Je="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},Je(e)}Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.create=function(){var e=new Qe.ARRAY_TYPE(8);return Qe.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},Ke.clone=function(e){var t=new Qe.ARRAY_TYPE(8);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t},Ke.fromValues=function(e,t,i,r,n,o,s,a){var l=new Qe.ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=i,l[3]=r,l[4]=n,l[5]=o,l[6]=s,l[7]=a,l},Ke.fromRotationTranslationValues=function(e,t,i,r,n,o,s){var a=new Qe.ARRAY_TYPE(8);a[0]=e,a[1]=t,a[2]=i,a[3]=r;var l=.5*n,c=.5*o,u=.5*s;return a[4]=l*r+c*i-u*t,a[5]=c*r+u*e-l*i,a[6]=u*r+l*t-c*e,a[7]=-l*e-c*t-u*i,a},Ke.fromRotationTranslation=nt,Ke.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},Ke.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},Ke.fromMat4=function(e,t){var i=et.create();tt.getRotation(i,t);var r=new Qe.ARRAY_TYPE(3);return tt.getTranslation(r,t),nt(e,i,r),e},Ke.copy=ot,Ke.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},Ke.set=function(e,t,i,r,n,o,s,a,l){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e},Ke.getDual=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},Ke.setDual=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},Ke.getTranslation=function(e,t){var i=t[4],r=t[5],n=t[6],o=t[7],s=-t[0],a=-t[1],l=-t[2],c=t[3];return e[0]=2*(i*c+o*s+r*l-n*a),e[1]=2*(r*c+o*a+n*s-i*l),e[2]=2*(n*c+o*l+i*a-r*s),e},Ke.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=.5*i[0],l=.5*i[1],c=.5*i[2],u=t[4],h=t[5],d=t[6],p=t[7];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=s*a+n*c-o*l+u,e[5]=s*l+o*a-r*c+h,e[6]=s*c+r*l-n*a+d,e[7]=-r*a-n*l-o*c+p,e},Ke.rotateX=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=a*s+u*r+l*o-c*n,d=l*s+u*n+c*r-a*o,p=c*s+u*o+a*n-l*r,f=u*s-a*r-l*n-c*o;return et.rotateX(e,t,i),e[4]=h*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-h*o,e[6]=p*s+f*o+h*n-d*r,e[7]=f*s-h*r-d*n-p*o,e},Ke.rotateY=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=a*s+u*r+l*o-c*n,d=l*s+u*n+c*r-a*o,p=c*s+u*o+a*n-l*r,f=u*s-a*r-l*n-c*o;return et.rotateY(e,t,i),e[4]=h*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-h*o,e[6]=p*s+f*o+h*n-d*r,e[7]=f*s-h*r-d*n-p*o,e},Ke.rotateZ=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=a*s+u*r+l*o-c*n,d=l*s+u*n+c*r-a*o,p=c*s+u*o+a*n-l*r,f=u*s-a*r-l*n-c*o;return et.rotateZ(e,t,i),e[4]=h*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-h*o,e[6]=p*s+f*o+h*n-d*r,e[7]=f*s-h*r-d*n-p*o,e},Ke.rotateByQuatAppend=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],u=t[3];return e[0]=a*s+u*r+l*o-c*n,e[1]=l*s+u*n+c*r-a*o,e[2]=c*s+u*o+a*n-l*r,e[3]=u*s-a*r-l*n-c*o,e[4]=(a=t[4])*s+(u=t[7])*r+(l=t[5])*o-(c=t[6])*n,e[5]=l*s+u*n+c*r-a*o,e[6]=c*s+u*o+a*n-l*r,e[7]=u*s-a*r-l*n-c*o,e},Ke.rotateByQuatPrepend=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],u=i[3];return e[0]=r*u+s*a+n*c-o*l,e[1]=n*u+s*l+o*a-r*c,e[2]=o*u+s*c+r*l-n*a,e[3]=s*u-r*a-n*l-o*c,e[4]=r*(u=i[7])+s*(a=i[4])+n*(c=i[6])-o*(l=i[5]),e[5]=n*u+s*l+o*a-r*c,e[6]=o*u+s*c+r*l-n*a,e[7]=s*u-r*a-n*l-o*c,e},Ke.rotateAroundAxis=function(e,t,i,r){if(Math.abs(r)0){i=Math.sqrt(i);var r=t[0]/i,n=t[1]/i,o=t[2]/i,s=t[3]/i,a=t[4],l=t[5],c=t[6],u=t[7],h=r*a+n*l+o*c+s*u;e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=(a-r*h)/i,e[5]=(l-n*h)/i,e[6]=(c-o*h)/i,e[7]=(u-s*h)/i}return e},Ke.str=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},Ke.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]},Ke.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=t[0],h=t[1],d=t[2],p=t[3],f=t[4],m=t[5],_=t[6],g=t[7];return Math.abs(i-u)<=Qe.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(r-h)<=Qe.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(n-d)<=Qe.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(o-p)<=Qe.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(s-f)<=Qe.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-m)<=Qe.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(l-_)<=Qe.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(c-g)<=Qe.EPSILON*Math.max(1,Math.abs(c),Math.abs(g))},Ke.sqrLen=Ke.squaredLength=Ke.len=Ke.length=Ke.dot=Ke.mul=Ke.setReal=Ke.getReal=void 0;var Qe=rt(f),et=rt(H),tt=rt(B);function it(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(it=function(e){return e?i:t})(e)}function rt(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Je(e)&&"function"!=typeof e)return{default:e};var i=it(t);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r}function nt(e,t,i){var r=.5*i[0],n=.5*i[1],o=.5*i[2],s=t[0],a=t[1],l=t[2],c=t[3];return e[0]=s,e[1]=a,e[2]=l,e[3]=c,e[4]=r*c+n*l-o*a,e[5]=n*c+o*s-r*l,e[6]=o*c+r*a-n*s,e[7]=-r*s-n*a-o*l,e}function ot(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 st(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[4],l=i[5],c=i[6],u=i[7],h=t[4],d=t[5],p=t[6],f=t[7],m=i[0],_=i[1],g=i[2],y=i[3];return e[0]=r*y+s*m+n*g-o*_,e[1]=n*y+s*_+o*m-r*g,e[2]=o*y+s*g+r*_-n*m,e[3]=s*y-r*m-n*_-o*g,e[4]=r*u+s*a+n*c-o*l+h*y+f*m+d*g-p*_,e[5]=n*u+s*l+o*a-r*c+d*y+f*_+p*m-h*g,e[6]=o*u+s*c+r*l-n*a+p*y+f*g+h*_-d*m,e[7]=s*u-r*a-n*l-o*c+f*y-h*m-d*_-p*g,e}Ke.getReal=et.copy,Ke.setReal=et.copy,Ke.mul=st;var at=et.dot;Ke.dot=at;var lt=et.length;Ke.length=lt,Ke.len=lt;var ct=et.squaredLength;Ke.squaredLength=ct,Ke.sqrLen=ct;var ut={};function ht(e){return ht="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},ht(e)}Object.defineProperty(ut,"__esModule",{value:!0}),ut.create=ft,ut.clone=function(e){var t=new dt.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},ut.fromValues=function(e,t){var i=new dt.ARRAY_TYPE(2);return i[0]=e,i[1]=t,i},ut.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},ut.set=function(e,t,i){return e[0]=t,e[1]=i,e},ut.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e},ut.subtract=mt,ut.multiply=_t,ut.divide=gt,ut.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},ut.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},ut.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e},ut.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e},ut.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},ut.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},ut.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e},ut.distance=yt,ut.squaredDistance=xt,ut.length=vt,ut.squaredLength=bt,ut.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},ut.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},ut.normalize=function(e,t){var i=t[0],r=t[1],n=i*i+r*r;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e},ut.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},ut.cross=function(e,t,i){var r=t[0]*i[1]-t[1]*i[0];return e[0]=e[1]=0,e[2]=r,e},ut.lerp=function(e,t,i,r){var n=t[0],o=t[1];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e},ut.random=function(e,t){t=t||1;var i=2*dt.RANDOM()*Math.PI;return e[0]=Math.cos(i)*t,e[1]=Math.sin(i)*t,e},ut.transformMat2=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n,e[1]=i[1]*r+i[3]*n,e},ut.transformMat2d=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n+i[4],e[1]=i[1]*r+i[3]*n+i[5],e},ut.transformMat3=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[3]*n+i[6],e[1]=i[1]*r+i[4]*n+i[7],e},ut.transformMat4=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e},ut.rotate=function(e,t,i,r){var n=t[0]-i[0],o=t[1]-i[1],s=Math.sin(r),a=Math.cos(r);return e[0]=n*a-o*s+i[0],e[1]=n*s+o*a+i[1],e},ut.angle=function(e,t){var i=e[0],r=e[1],n=t[0],o=t[1],s=Math.sqrt(i*i+r*r)*Math.sqrt(n*n+o*o);return Math.acos(Math.min(Math.max(s&&(i*n+r*o)/s,-1),1))},ut.zero=function(e){return e[0]=0,e[1]=0,e},ut.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},ut.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ut.equals=function(e,t){var i=e[0],r=e[1],n=t[0],o=t[1];return Math.abs(i-n)<=dt.EPSILON*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(r-o)<=dt.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))},ut.forEach=ut.sqrLen=ut.sqrDist=ut.dist=ut.div=ut.mul=ut.sub=ut.len=void 0;var dt=(function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==ht(e)&&"function"!=typeof e)return{default:e};var i=pt(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o]}return r.default=e,i&&i.set(e,r),r})(f);function pt(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(pt=function(e){return e?i:t})(e)}function ft(){var e=new dt.ARRAY_TYPE(2);return dt.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function mt(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function _t(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e}function gt(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e}function yt(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function xt(e,t){var i=t[0]-e[0],r=t[1]-e[1];return i*i+r*r}function vt(e){return Math.hypot(e[0],e[1])}function bt(e){var t=e[0],i=e[1];return t*t+i*i}ut.len=vt,ut.sub=mt,ut.mul=_t,ut.div=gt,ut.dist=yt,ut.sqrDist=xt,ut.sqrLen=bt;var wt=(function(){var e=ft();return function(t,i,r,n,o,s){var a,l;for(i||(i=2),r||(r=0),l=n?Math.min(n*i+r,t.length):t.length,a=r;a1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var Ft=d(Ot),Nt=Vt;function Vt(e,t){this.x=e,this.y=t}Vt.prototype={clone:function(){return new Vt(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,i=e.y-this.y;return t*t+i*i},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),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround:function(e,t){var i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Vt.convert=function(e){return e instanceof Vt?e:Array.isArray(e)?new Vt(e[0],e[1]):e};var Ut=d(Nt);const jt=Math.PI/180,Gt=180/Math.PI;function qt(e){return e*jt}function Zt(e){return e*Gt}const $t=[[0,0],[1,0],[1,1],[0,1]];function Wt(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function Ht(e,t,i,r){const n=new Ft(e,t,i,r);return function(e){return n.solve(e)}}const Xt=Ht(.25,.1,.25,1);function Yt(e,t,i){return Math.min(i,Math.max(t,e))}function Kt(e,t,i){return(i=Yt((i-e)/(t-e),0,1))*i*(3-2*i)}function Jt(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function Qt(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach(((e,s)=>{t(e,((e,t)=>{e&&(o=e),n[s]=t,0==--r&&i(o,n)}))}))}function ei(e){const t=[];for(const i in e)t.push(e[i]);return t}function ti(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let ii=1;function ri(){return ii++}function ni(){return(function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e)})()}function oi(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function si(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)}function ai(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function li(e,t){return-1!==e.indexOf(t,e.length-t.length)}function ci(e,t,i){const r={};for(const i in e)r[i]=t.call(this,e[i],i,e);return r}function ui(e,t,i){const r={};for(const i in e)t.call(this,e[i],i,e)&&(r[i]=e[i]);return r}function hi(e){return Array.isArray(e)?e.map(hi):"object"==typeof e&&e?ci(e,hi):e}const di={};function pi(e){di[e]||("undefined"!=typeof console&&console.warn(e),di[e]=!0)}function fi(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function mi(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let xi,vi,bi,wi,Ti,Ei,Si=null;function Mi(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function Ii(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function Ai(e,t,i,r){for(;t>1;e[n]>1;e[n]<=r?t=n+1:i=n}return t}function Pi(e){return e>0?1/(1.001-e):1+e}function zi(e){return e>0?1-1/(1.001-e):-e}function Di(){return null==xi&&(xi=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),xi}const Li={now:()=>void 0!==wi?wi:performance.now(),setNow(e){wi=e},restoreNow(){wi=void 0},frame(e){const t=requestAnimationFrame(e);return{cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:r}=e;Ti||(Ti=document.createElement("canvas"));const n=Ti.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return(i>Ti.width||r>Ti.height)&&(Ti.width=i,Ti.height=r),n.clearRect(-t,-t,i+2*t,r+2*t),n.drawImage(e,0,0,i,r),n.getImageData(-t,-t,i+2*t,r+2*t)},resolveURL:e=>(vi||(vi=document.createElement("a")),vi.href=e,vi.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==bi&&(bi=window.matchMedia("(prefers-reduced-motion: reduce)")),bi.matches)},hasCanvasFingerprintNoise(){if(void 0!==Ei)return Ei;if(!Di())return Ei=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let i=0;for(let r=0;r0?`?${o}`:""}`}const Oi="mapbox-tiles";let Bi,Fi,Ni=500,Vi=50;function Ui(){try{return caches}catch(e){}}function ji(){const e=Ui();e&&!Bi&&(Bi=e.open(Oi))}let Gi=1/0;const qi={supported:!1,testSupport:function(e){!Wi&&$i&&(Hi?Yi(e):Zi=e)}};let Zi,$i,Wi=!1,Hi=!1;const Xi="undefined"!=typeof self?self:{};function Yi(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,$i),e.isContextLost())return;qi.supported=!0}catch(e){}e.deleteTexture(t),Wi=!0}Xi.document&&($i=Xi.document.createElement("img"),$i.onload=function(){Zi&&Yi(Zi),Zi=null,Hi=!0},$i.onerror=function(){Wi=!0,Zi=null},$i.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ki={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Ki);class Ji extends Error{constructor(e,t,i){401===t&&n(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Qi=gi()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,er=function(e,t){if(!(/^file:/.test(i=e.url)||/^file:/.test(Qi())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return(function(e,t){const i=new AbortController,r=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Qi(),referrerPolicy:e.referrerPolicy,signal:i.signal});let o=!1,s=!1;const a=(l=r.url).indexOf("sku=")>0&&n(l);var l;"json"===e.type&&r.headers.set("Accept","application/json");const c=(i,n,o)=>{if(s)return;if(i&&"SecurityError"!==i.message&&pi(i.toString()),n&&o)return u(n);const l=Date.now();fetch(r).then((i=>{if(i.ok){const e=a?i.clone():null;return u(i,e,l)}return t(new Ji(i.statusText,i.status,e.url))})).catch((i=>{"AbortError"!==i.name&&t(new Error(`${i.message} ${e.url}`))}))},u=(i,n,a)=>{("arrayBuffer"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text()).then((e=>{s||(n&&a&&(function(e,t,i){if(ji(),!Bi)return;const r=yi(t.headers.get("Cache-Control")||"");if(r["no-store"])return;const n={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach(((e,t)=>n.headers.set(t,e))),r["max-age"]&&n.headers.set("Expires",new Date(i+1e3*r["max-age"]).toUTCString());const o=n.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-i<42e4)return;let s=ki(e.url,{persistentParams:["language","worldview"]});if(206===t.status){const t=e.headers.get("Range");if(!t)return;n.status=200,s=Ri(s,{range:t})}!(function(e,t){if(void 0===Fi)try{new Response(new ReadableStream),Fi=!0}catch(e){Fi=!1}Fi?t(e.body):e.blob().then(t)})(t,(e=>{const i=new Response(200!==(r=t.status)&&404!==r&&[101,103,204,205,304].includes(r)?null:e,n);var r;ji(),Bi&&Bi.then((e=>e.put(s,i))).catch((e=>pi(e.message)))}))})(r,n,a),o=!0,t(null,e,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((e=>{s||t(new Error(e.message))}))};return a?(function(e,t){if(ji(),!Bi)return t(null);Bi.then((i=>{let r=ki(e.url,{persistentParams:["language","worldview"]});const n=e.headers.get("Range");n&&(r=Ri(r,{range:n})),i.match(r).then((e=>{const n=(function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=yi(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]})(e);i.delete(r),n&&i.put(r,e.clone()),t(null,e,n)})).catch(t)})).catch(t)})(r,c):c(null,null),{cancel:()=>{s=!0,o||i.abort()}}})(e,t);if(gi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var i;return(function(e,t){const i=new XMLHttpRequest;i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=()=>{t(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===e.type)try{r=JSON.parse(i.response)}catch(e){return t(e)}t(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else t(new Ji(i.statusText,i.status,e.url))},i.send(e.body),{cancel:()=>i.abort()}})(e,t)},tr=function(e,t){return er(ti(e,{type:"arrayBuffer"}),t)};function ir(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}const rr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let nr,or;nr=[],or=0;const sr=function(e,t){if(qi.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),or>=r.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return nr.push(i),i}or++;let i=!1;const n=()=>{if(!i)for(i=!0,or--;nr.length&&or{n(),e?t(e):i&&(self.createImageBitmap?(function(e,t){const i=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(i).then((e=>{t(null,e)})).catch((e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))})(i,((e,i)=>t(e,i,r,o))):(function(e,t){const i=new Image;i.onload=()=>{t(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame((()=>{i.src=rr}))},i.onerror=()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const r=new Blob([new Uint8Array(e)],{type:"image/png"});i.src=e.byteLength?URL.createObjectURL(r):rr})(i,((e,i)=>t(e,i,r,o))))}));return{cancel:()=>{o.cancel(),n()}}},ar="01",lr="NO_ACCESS_TOKEN",cr=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ur(e){const t=e.match(cr);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 hr(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const dr="mapbox.eventData";function pr(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(atob(t[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class fr{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=pr(r.ACCESS_TOKEN);let i="";return i=t&&t.u?btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):r.ACCESS_TOKEN||"",e?`${dr}.${e}:${i}`:`${dr}:${i}`}fetchEventData(){const e=Mi("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{const e=localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const r=localStorage.getItem(i);r&&(this.anonId=r)}catch(e){pi("Unable to read from LocalStorage")}}saveEventData(){const e=Mi("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid"),r=this.anonId;if(e&&r)try{localStorage.setItem(i,r),Object.keys(this.eventData).length>=1&&localStorage.setItem(t,JSON.stringify(this.eventData))}catch(e){pi("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,i,n){if(!r.EVENTS_URL)return;const o=ur(r.EVENTS_URL);o.params.push(`access_token=${n||r.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(e).toISOString()},a=t?ti(s,t):s,l={url:hr(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=(function(e,t){return er(ti(e,{method:"POST"}),t)})(l,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(n)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const mr=new class extends fr{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){r.EVENTS_URL&&r.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>o(e)||n(e)))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const i=pr(r.ACCESS_TOKEN),n=i?i.u:r.ACCESS_TOKEN;let o=n!==this.eventData.tokenU;si(this.anonId)||(this.anonId=ni(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||e.getDate()!==t.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:ar,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=n)}),e):this.processRequests()}},_r=mr.postTurnstileEvent.bind(mr),gr=new class extends fr{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,n){this.skuToken=t,this.errorCb=n,r.EVENTS_URL&&(i||r.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(lr)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:i,timestamp:r}=this.queue.shift();i&&this.success[i]||(this.anonId||this.fetchEventData(),si(this.anonId)||(this.anonId=ni()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:ar,skuToken:this.skuToken,userId:this.anonId},(e=>{e?this.errorCb(e):i&&(this.success[i]=!0)}),e))}remove(){this.errorCb=null}},yr=gr.postMapLoadEvent.bind(gr),xr=new class extends fr{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(e){let t=this.mapInstanceIdMap.get(e);return t||(t=ni(),this.mapInstanceIdMap.set(e,t)),t}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:i,style:n,importedStyles:o}=t;if(!r.EVENTS_URL||!e&&!r.ACCESS_TOKEN)return;const s=this.getMapInstanceId(i),a={mapInstanceId:s,eventId:this.getEventId(s),style:n};o.length&&(a.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:a},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,(()=>{}),e)}},vr=xr.postStyleLoadEvent.bind(xr),br=new class extends fr{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){r.EVENTS_URL&&(e||r.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:i,performanceData:r}=this.queue.shift(),n=(function(e){const i=performance.getEntriesByType("resource"),r=performance.getEntriesByType("mark"),n=(function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const r of e[i]){const e=`${i}ResolveRangeMin`,n=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,r.startTime),t[n]=Math.max(t[n]||-1/0,r.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==r.transferSize&&0===r.transferSize&&a(s),a(o)}return t})((function(e,t){const i={};if(e)for(const r of e){const e=t(r);void 0===i[e]&&(i[e]=[]),i[e].push(r)}return i})(i,h)),o=window.devicePixelRatio,s=navigator.connection||navigator.mozConnection||navigator.webkitConnection,a=s?s.effectiveType:void 0,u={counters:[],metadata:[],attributes:[]},d=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()})};for(const e in n)d(u.counters,e,n[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(d(u.counters,"interactionRangeMin",e.interactionRange[0]),d(u.counters,"interactionRangeMax",e.interactionRange[1])),r)for(const e of Object.keys(c)){const t=c[e],i=r.find((e=>e.name===t));i&&d(u.counters,t,i.startTime)}return d(u.counters,"visibilityHidden",e.visibilityHidden),d(u.attributes,"style",(function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(l(e)){const t=e.split("/").slice(-2);if(2===t.length)return`mapbox://styles/${t[0]}/${t[1]}`}}})(i)),d(u.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),d(u.attributes,"fogEnabled",e.fogEnabled?"true":"false"),d(u.attributes,"projection",e.projection),d(u.attributes,"zoom",e.zoom),d(u.metadata,"devicePixelRatio",o),d(u.metadata,"connectionEffectiveType",a),d(u.metadata,"navigatorUserAgent",navigator.userAgent),d(u.metadata,"screenWidth",window.screen.width),d(u.metadata,"screenHeight",window.screen.height),d(u.metadata,"windowWidth",window.innerWidth),d(u.metadata,"windowHeight",window.innerHeight),d(u.metadata,"mapWidth",e.width/o),d(u.metadata,"mapHeight",e.height/o),d(u.metadata,"webglRenderer",e.renderer),d(u.metadata,"webglVendor",e.vendor),d(u.metadata,"sdkVersion",t),d(u.metadata,"sdkIdentifier","mapbox-gl-js"),u})(r);for(const e of n.metadata);for(const e of n.counters);for(const e of n.attributes);this.postEvent(i,n,(()=>{}),e)}},wr=br.postPerformanceEvent.bind(br),Tr=new class extends fr{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,n){if(!r.API_URL||!r.SESSION_PATH)return;const o=ur(r.API_URL+r.SESSION_PATH);o.params.push(`sku=${t||""}`),o.params.push(`access_token=${n||r.ACCESS_TOKEN||""}`);const s={url:hr(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=(function(e,t){return er(ti(e,{method:"GET"}),t)})(s,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(n)}))}getSessionAPI(e,t,i,n){this.skuToken=t,this.errorCb=n,r.SESSION_PATH&&r.API_URL&&(i||r.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(lr)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e)}remove(){this.errorCb=null}},Er=Tr.getSessionAPI.bind(Tr),Sr=new Set;var Mr={exports:{}},Ir={exports:function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}},Ar=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&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},Cr=Ir.exports;Mr.exports=Ar,Mr.exports.murmur3=Ar,Mr.exports.murmur2=Cr;var Pr=d(Mr.exports);function zr(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function Dr(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class Lr{constructor(e,t={}){ti(this,t),this.type=e}}class Rr extends Lr{constructor(e,t={}){super("error",ti({error:e},t))}}class kr{on(e,t){return this._listeners=this._listeners||{},zr(e,t,this._listeners),this}off(e,t){return Dr(e,t,this._listeners),Dr(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},zr(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new Lr(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of r)Dr(i,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(ti(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof Rr&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}e.F=void 0;var Or={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 Br(e){return(e=Math.round(e))<0?0:e>255?255:e}function Fr(e){return Br("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function Nr(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function Vr(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(.6666666666666666-i)*6:e}try{e.F={}.parseCSSColor=function(e){var t,i=e.replace(/ /g,"").toLowerCase();if(i in Or)return Or[i].slice();if("#"===i[0])return 4===i.length?(t=parseInt(i.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===i.length&&(t=parseInt(i.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=i.indexOf("("),n=i.indexOf(")");if(-1!==r&&n+1===i.length){var o=i.substr(0,r),s=i.substr(r+1,n-(r+1)).split(","),a=1;switch(o){case"rgba":if(4!==s.length)return null;a=Nr(s.pop());case"rgb":return 3!==s.length?null:[Fr(s[0]),Fr(s[1]),Fr(s[2]),a];case"hsla":if(4!==s.length)return null;a=Nr(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,c=Nr(s[1]),u=Nr(s[2]),h=u<=.5?u*(c+1):u+c-u*c,d=2*u-h;return[Br(255*Vr(d,h,l+.3333333333333333)),Br(255*Vr(d,h,l)),Br(255*Vr(d,h,l-.3333333333333333)),a];default:return null}}return null}}catch(e){}class Ur{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(t){if(!t)return;if(t instanceof Ur)return t;if("string"!=typeof t)return;const i=e.F(t);return i?new Ur(i[0]/255*i[3],i[1]/255*i[3],i[2]/255*i[3],i[3]):void 0}toString(){const[e,t,i,r]=0===this.a?[0,0,0,0]:[255*this.r/this.a,255*this.g/this.a,255*this.b/this.a,this.a];return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${r})`}toRenderColor(e){const{r:t,g:i,b:r,a:n}=this;return new jr(e,t,i,r,n)}}class jr{constructor(e,t,i,r,n){if(e){const o=e.image.height,s=o*o;t=0===n?0:t/n*(o-1),i=0===n?0:i/n*(o-1),r=0===n?0:r/n*(o-1);const a=Math.floor(t),l=Math.floor(i),c=Math.floor(r),u=Math.ceil(t),h=Math.ceil(i),d=Math.ceil(r),p=t-a,f=i-l,m=r-c,_=e.image.data,g=4*(a+l*s+c*o),y=4*(a+l*s+d*o),x=4*(a+h*s+c*o),v=4*(a+h*s+d*o),b=4*(u+l*s+c*o),w=4*(u+l*s+d*o),T=4*(u+h*s+c*o),E=4*(u+h*s+d*o);if(g<0||E>=_.length)throw new Error("out of range");this.r=Gr(Gr(Gr(_[g],_[y],m),Gr(_[x],_[v],m),f),Gr(Gr(_[b],_[w],m),Gr(_[T],_[E],m),f),p)/255*n,this.g=Gr(Gr(Gr(_[g+1],_[y+1],m),Gr(_[x+1],_[v+1],m),f),Gr(Gr(_[b+1],_[w+1],m),Gr(_[T+1],_[E+1],m),f),p)/255*n,this.b=Gr(Gr(Gr(_[g+2],_[y+2],m),Gr(_[x+2],_[v+2],m),f),Gr(Gr(_[b+2],_[w+2],m),Gr(_[T+2],_[E+2],m),f),p)/255*n,this.a=n}else this.r=t,this.g=i,this.b=r,this.a=n}toArray(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*i/r,r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,i/r,r]}toArray01Scaled(e){const{r:t,g:i,b:r,a:n}=this;return 0===n?[0,0,0]:[t/n*e,i/n*e,r/n*e]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:r}=this;return[e,t,i,r]}toArray01Linear(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[Math.pow(e/r,2.2),Math.pow(t/r,2.2),Math.pow(i/r,2.2),r]}}function Gr(e,t,i){return e*(1-i)+t*i}function qr(e,t,i){return e.map(((e,r)=>Gr(e,t[r],i)))}Ur.black=new Ur(0,0,0,1),Ur.white=new Ur(1,1,1,1),Ur.transparent=new Ur(0,0,0,0),Ur.red=new Ur(1,0,0,1),Ur.blue=new Ur(0,0,1,1);var Zr=Object.freeze({__proto__:null,array:qr,color:function(e,t,i){return new Ur(Gr(e.r,t.r,i),Gr(e.g,t.g,i),Gr(e.b,t.b,i),Gr(e.a,t.a,i))},number:Gr});function $r(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}class Wr extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Hr{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Hr(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Xr={kind:"null"},Yr={kind:"number"},Kr={kind:"string"},Jr={kind:"boolean"},Qr={kind:"color"},en={kind:"object"},tn={kind:"value"},rn={kind:"collator"},nn={kind:"formatted"},on={kind:"resolvedImage"};function sn(e,t){return{kind:"array",itemType:e,N:t}}function an(e){if("array"===e.kind){const t=an(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const ln=[Xr,Yr,Kr,Jr,Qr,nn,en,sn(tn),on];function cn(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!cn(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of ln)if(!cn(e,t))return null}return`Expected ${an(e)} but found ${an(t)} instead.`}function un(e,t){return t.some((t=>t.kind===e.kind))}function hn(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}class dn{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class pn{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n}}class fn{constructor(e){this.sections=e}static fromString(e){return new fn([new pn(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.namePrimary.length))}static factory(e){return e instanceof fn?e:fn.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.namePrimary]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toRenderColor(null).toArray())),e.push(i)}return e}}class mn{constructor(e){this.namePrimary=e.namePrimary,e.nameSecondary&&(this.nameSecondary=e.nameSecondary),this.available=e.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(e,t){return e?new mn({namePrimary:e,nameSecondary:t,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function _n(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function gn(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 Ur)return!0;if(e instanceof dn)return!0;if(e instanceof fn)return!0;if(e instanceof mn)return!0;if(Array.isArray(e)){for(const t of e)if(!gn(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!gn(e[t]))return!1;return!0}return!1}function yn(e){if(null===e)return Xr;if("string"==typeof e)return Kr;if("boolean"==typeof e)return Jr;if("number"==typeof e)return Yr;if(e instanceof Ur)return Qr;if(e instanceof dn)return rn;if(e instanceof fn)return nn;if(e instanceof mn)return on;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=yn(t);if(i){if(i===e)continue;i=tn;break}i=e}return sn(i||tn,t)}return en}function xn(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ur||e instanceof fn||e instanceof mn?e.toString():JSON.stringify(e)}class vn{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!gn(e[1]))return t.error("invalid value");const i=e[1];let r=yn(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new vn(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Ur?["rgba"].concat(this.value.toRenderColor(null).toArray()):this.value instanceof fn?this.value.serialize():this.value}}class bn{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const wn={string:Kr,number:Yr,boolean:Jr,object:en};class Tn{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in wn)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=wn[i],r++}else n=tn;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}i=sn(n,o)}else i=wn[n];const o=[];for(;re.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map((e=>e.serialize())))}}class En{constructor(e){this.type=nn,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,Yr),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,sn(Kr)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,Qr),!s))return null;const a=r[r.length-1];a.scale=e,a.font=i,a.textColor=s}else{const o=t.parse(e[i],1,tn);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new En(r)}evaluate(e){return new fn(this.sections.map((t=>{const i=t.content.evaluate(e);return yn(i)===on?new pn("",i,null,null,null):new pn(xn(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class Sn{constructor(e,t){this.type=on,this.inputPrimary=e,this.inputSecondary=t}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");const i=t.parse(e[1],1,Kr);if(!i)return t.error("No image name provided.");if(2===e.length)return new Sn(i);const r=t.parse(e[2],1,Kr);return r?new Sn(i,r):t.error("Secondary image variant is not a string.")}evaluate(e){const t=mn.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return t&&e.availableImages&&(t.available=e.availableImages.indexOf(t.namePrimary)>-1,t.nameSecondary&&t.available&&e.availableImages&&(t.available=e.availableImages.indexOf(t.nameSecondary)>-1)),t}eachChild(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function Mn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}const In={"to-boolean":Jr,"to-color":Qr,"to-number":Yr,"to-string":Kr};class An{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0],r=[];let n=Xr;if("to-array"===i){if(!Array.isArray(e[1]))return null;const i=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);n=sn(t.expectedType.itemType,i)}else{if(!(i>0&&gn(e[1][0])))return null;n=sn(yn(e[1][0]),i)}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:_n(t[0],t[1],t[2],t[3]),!i))return new Ur(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new bn(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new bn(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?fn.fromString(xn(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?mn.fromString(xn(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map((t=>t.evaluate(e))):xn(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new En([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Sn(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize())})),e}}const Cn=["Unknown","Point","LineString","Polygon"];class Pn{constructor(e,t){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Cn[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Ur.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class zn{constructor(e,t,i,r,n){this.name=e,this.type=t,this._evaluate=i,this.args=r,this._overloadIndex=n}evaluate(e){if(!this._evaluate){const e=zn.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1]}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const i=e[0],r=zn.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=[];let a=null,l=-1;for(const[r,c]of o){if(Array.isArray(r)&&r.length!==e.length-1)continue;s.push(r),l++,a=new Yo(t.registry,t.path,null,t.scope,void 0,t._scope,t.options);const o=[];let u=!1;for(let t=1;te))).map(Dn).join(" | "),r=[];for(let i=1;in;){if(o-n>600){var a=o-n+1,l=r-n+1,c=Math.log(a),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(a-u)/a)*(l-a/2<0?-1:1);e(i,r,Math.max(n,Math.floor(r-l*u/a+h)),Math.min(o,Math.floor(r+(a-l)*u/a+h)),s)}var d=i[r],p=n,f=o;for(t(i,n,r),s(i[o],d)>0&&t(i,n,o);p0;)f--}0===s(i[n],d)?t(i,n,f):t(i,++f,o),f<=r&&(n=f+1),r<=f&&(o=f-1)}}function t(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function i(e,t){return et?1:0}return function(t,r,n,o,s){e(t,r,n||0,o||t.length-1,s||i)}})();var kn=d(Rn.exports);function On(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Nn(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Vn(e,t,i=!1){let r=!1;for(let a=0,l=t.length;a(n=e)[1]!=(s=u)[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}}var n,o,s;return r}function Un(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(e[0]-i[0])*o-n*(e[1]-i[1]),a=(t[0]-i[0])*o-n*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function jn(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*o[0]&&!(!Un(e,t,i,r)||!Un(i,r,e,t));var n,o}const Gn=8192;function qn(e,t){const i=(180+e[0])/360,r=(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(i*n*Gn),Math.round(r*n*Gn)]}function Zn(e,t){for(let i=0;ii[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}Bn(t,e)}function Jn(e,t,i,r){const n=Math.pow(2,r.z)*Gn,o=[r.x*Gn,r.y*Gn],s=[];if(!e)return s;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];Kn(r,t,i,n),s.push(r)}return s}function Qn(e,t,i,r){const n=Math.pow(2,r.z)*Gn,o=[r.x*Gn,r.y*Gn],s=[];if(!e)return s;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Bn(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)Kn(r,t,i,n)}var a;return s}class eo{constructor(e,t){this.type=Jr,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(gn(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;et)return oo(n,o,(t-(i-s))/s)}return e[e.length-1]}pointToSegmentDistance(e,t,i){let[r,n]=t,o=so(i[0]-r)*this.kx,s=(i[1]-n)*this.ky;if(0!==o||0!==s){const t=(so(e[0]-r)*this.kx*o+(e[1]-n)*this.ky*s)/(o*o+s*s);t>1?(r=i[0],n=i[1]):t>0&&(r+=o/this.kx*t,n+=s/this.ky*t)}return o=so(e[0]-r)*this.kx,s=(e[1]-n)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(e,t){let i=1/0,r=e[0][0],n=e[0][1],o=0,s=0;for(let a=0;a1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=so(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;pn.index||r.index===n.index&&r.t>n.t){const e=r;r=n,n=e}const o=[r.point],s=r.index+1,a=n.index;!no(i[s],o[0])&&s<=a&&o.push(i[s]);for(let e=s+1;e<=a;e++)o.push(i[e]);return no(i[a],n.point)||o.push(n.point),o}lineSliceAlong(e,t,i){let r=0;const n=[];for(let o=0;oe&&0===n.length&&n.push(oo(s,a,(e-(r-l))/l)),r>=t)return n.push(oo(s,a,(t-(r-l))/l)),n;r>e&&n.push(a)}return n}bufferPoint(e,t){const i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[0]+r,e[1]+i]}bufferBBox(e,t){const i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[2]+r,e[3]+i]}insideBBox(e,t){return so(e[0]-t[0])>=0&&so(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function no(e,t){return e[0]===t[0]&&e[1]===t[1]}function oo(e,t,i){const r=so(t[0]-e[0]);return[e[0]+r*i,e[1]+(t[1]-e[1])*i]}function so(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}var ao={exports:{}};!(function(e,t){e.exports=(function(){var e=function(e,i){if(void 0===e&&(e=[]),void 0===i&&(i=t),this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)};function t(e,t){return et?1:0}return e.prototype.push=function(e){this.data.push(e),this.length++,this._up(this.length-1)},e.prototype.pop=function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}},e.prototype.peek=function(){return this.data[0]},e.prototype._up=function(e){for(var t=this.data,i=this.compare,r=t[e];e>0;){var n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r},e.prototype._down=function(e){for(var t=this.data,i=this.compare,r=this.length>>1,n=t[e];e=0)break;t[e]=s,e=o}t[e]=n},e})()})(ao);var lo=d(ao.exports),co=8192;function uo(e,t){return t.dist-e.dist}const ho=100,po=50;function fo(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(let i=0;i=e[0]&&e[1]e[1])return[null,null];const i=mo(e);if(t){if(2===i)return[e,null];const t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===i)return[e,null];const t=Math.floor(i/2)-1;return[[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function yo(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!_o(t,e.length))return i;for(let r=t[0];r<=t[1];++r)Bn(i,e[r]);return i}function xo(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;it[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]=r)return r;if(Fn(n,o)){if(Do(e,t))return 0}else if(Do(t,e))return 0;let s=r;for(const r of e)for(let e=0,n=r.length,o=n-1;e=o)continue;const c=n.range1;if(mo(c)<=a){if(!_o(c,e.length))return NaN;if(t){const t=zo(e,c,i,r);if(0===(o=Math.min(o,t)))return o}else for(let t=c[0];t<=c[1];++t){const n=Po(e[t],i,r);if(0===(o=Math.min(o,n)))return o}}else{const i=go(c,t);if(null!==i[0]){const t=vo(yo(e,i[0]),l,r);t=s)continue;const u=o.range1,h=o.range2;if(mo(u)<=l&&mo(h)<=c){if(!_o(u,e.length)||!_o(h,i.length))return NaN;if(t&&r?s=Math.min(s,Ao(e,u,i,h,n)):t||r?t&&!r?s=Math.min(s,Mo(i,h,e,u,n)):!t&&r&&(s=Math.min(s,Mo(e,u,i,h,n))):s=Math.min(s,Co(e,u,i,h,n)),0===s)return s}else{const o=go(u,t),l=go(h,r);Ro(a,s,n,e,i,o[0],l[0]),Ro(a,s,n,e,i,o[0],l[1]),Ro(a,s,n,e,i,o[1],l[0]),Ro(a,s,n,e,i,o[1],l[1])}}return s}function Bo(e,t,i,r,n=1/0){let o=n;const s=yo(e,[0,e.length-1]);for(const n of i)if(!(o!==1/0&&vo(s,yo(n,[0,n.length-1]),r)>=o)&&(o=Math.min(o,Oo(e,t,n,!0,r,o)),0===o))return o;return o}function Fo(e,t,i,r,n=1/0){let o=n;const s=yo(e,[0,e.length-1]);for(const n of i){if(o!==1/0&&vo(s,xo(n),r)>=o)continue;const i=ko(e,t,n,r,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function No(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class Vo{constructor(e,t){this.type=Yr,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(gn(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;ei&&(e=i),e}class Go{constructor(e,t,i){this.type=e,this.key=t,this.scope=i}static parse(e,t){let i=t.expectedType;if(null==i&&(i=tn),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const r=t.parse(e[1],1);if(!(r instanceof vn))return t.error("Key name of 'config' expression must be a string literal.");if(e.length>=3){const n=t.parse(e[2],2);return n instanceof vn?new Go(i,xn(r.value),xn(n.value)):t.error("Scope of 'config' expression must be a string literal.")}return new Go(i,xn(r.value))}evaluate(e){const t=[this.key,this.scope,e.scope].filter(Boolean).join("\x1f"),i=e.getConfig(t);if(!i)return null;const{type:r,value:n,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(e);let u=c;if(n){const t=e.scope;e.scope=(t||"").split("\x1f").slice(1).join("\x1f"),u=n.evaluate(e),e.scope=t}return r&&(u=Uo(r,u)),void 0===u||void 0===s&&void 0===a&&void 0===l||("number"==typeof u?u=jo(u,s,a,l):Array.isArray(u)&&(u=u.map((e=>"number"==typeof e?jo(e,s,a,l):e)))),void 0!==n&&void 0!==u&&o&&!o.includes(u)&&(u=c,r&&(u=Uo(r,u))),(r&&r!==this.type||void 0!==u&&yn(u)!==this.type)&&(u=Uo(this.type.kind,u)),u}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.key),e}}function qo(e){if(e instanceof zn){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 eo)return!1;if(e instanceof Vo)return!1;let t=!0;return e.eachChild((e=>{t&&!qo(e)&&(t=!1)})),t}function Zo(e){if(e instanceof zn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!Zo(e)&&(t=!1)})),t}function $o(e){if(e instanceof Go)return!1;let t=!0;return e.eachChild((e=>{t&&!$o(e)&&(t=!1)})),t}function Wo(e,t){if(e instanceof zn&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild((e=>{i&&!Wo(e,t)&&(i=!1)})),i}class Ho{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new Ho(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Xo{constructor(e,t=[],i,r=new Hr,n=[],o,s){this.registry=e,this.path=t,this.key=t.map((e=>`[${e}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i,this._scope=o,this.options=s}parse(e,t,i,r,n={}){return t||i?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return"assert"===i?new Tn(t,[e]):"coerce"===i?new An(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r="string"==typeof e[0]?this.registry[e[0]]:void 0;if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"coerce");else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof vn)&&"resolvedImage"!==n.type.kind&&Ko(n)){const t=new Pn(this._scope,this.options);try{n=new vn(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return An.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new Xo(this.registry,r,t||null,n,this.errors,this._scope,this.options)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Wr(i,e))}checkSubtype(e,t){const i=cn(e,t);return i&&this.error(i),i}}var Yo=Xo;function Ko(e){if(e instanceof Ho)return Ko(e.boundExpression);if(e instanceof zn&&"error"===e.name)return!1;if(e instanceof Ln)return!1;if(e instanceof eo)return!1;if(e instanceof Vo)return!1;if(e instanceof Go)return!1;const t=e instanceof An||e instanceof Tn;let i=!0;return e.eachChild((e=>{i=t?i&&Ko(e):i&&e instanceof vn})),!!i&&qo(e)&&Wo(e,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Jo(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||tt))throw new bn("Input is not a number.");s=a-1}return 0}class Qo{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,Yr);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Qo(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[Jo(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const es=.95047,ts=1.08883,is=.13793103448275862,rs=.20689655172413793,ns=.12841854934601665,os=.008856451679035631,ss=Math.PI/180,as=180/Math.PI;function ls(e){return e>os?Math.pow(e,.3333333333333333):e/ns+is}function cs(e){return e>rs?e*e*e:ns*(e-is)}function us(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,.4166666666666667)-.055)}function hs(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function ds(e){const t=hs(e.r),i=hs(e.g),r=hs(e.b),n=ls((.4124564*t+.3575761*i+.1804375*r)/es),o=ls((.2126729*t+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-ls((.0193339*t+.119192*i+.9503041*r)/ts)),alpha:e.a}}function ps(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*cs(t),i=es*cs(i),r=ts*cs(r),new Ur(us(3.2404542*i-1.5371385*t-.4985314*r),us(-.969266*i+1.8760108*t+.041556*r),us(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function fs(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const ms={forward:ds,reverse:ps,interpolate:function(e,t,i){return{l:Gr(e.l,t.l,i),a:Gr(e.a,t.a,i),b:Gr(e.b,t.b,i),alpha:Gr(e.alpha,t.alpha,i)}}},_s={forward:function(e){const{l:t,a:i,b:r}=ds(e),n=Math.atan2(r,i)*as;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*ss,i=e.c;return ps({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:fs(e.h,t.h,i),c:Gr(e.c,t.c,i),l:Gr(e.l,t.l,i),alpha:Gr(e.alpha,t.alpha,i)}}};var gs=Object.freeze({__proto__:null,hcl:_s,lab:ms});class ys{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=xs(t,e.base,i,r);else if("linear"===e.name)n=xs(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new Ft(o[0],o[1],o[2],o[3]).solve(xs(t,1,i,r))}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,Yr),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=Qr:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new ys(a,i,r,n,s):t.error(`Type ${an(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=Jo(t,r),s=ys.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?Zr[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?_s.reverse(_s.interpolate(_s.forward(a),_s.forward(l),s)):ms.reverse(ms.interpolate(ms.forward(a),ms.forward(l),s))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let e=0;ecn(r,e.type)));return new vs(o?tn:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof mn&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize())})),e}}class bs{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r=i.length)throw new bn(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new bn(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Ts{constructor(e,t){this.type=Jr,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,tn),r=t.parse(e[2],2,tn);return i&&r?un(i.type,[Jr,Kr,Yr,Xr,tn])?new Ts(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${an(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!hn(t,["boolean","string","number","null"]))throw new bn(`Expected first argument to be of type boolean, string, number or null, but found ${an(yn(t))} instead.`);if(!hn(i,["string","array"]))throw new bn(`Expected second argument to be of type array or string, but found ${an(yn(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Es{constructor(e,t,i){this.type=Yr,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,tn),r=t.parse(e[2],2,tn);if(!i||!r)return null;if(!un(i.type,[Jr,Kr,Yr,Xr,tn]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${an(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Yr);return n?new Es(i,r,n):null}return new Es(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!hn(t,["boolean","string","number","null"]))throw new bn(`Expected first argument to be of type boolean, string, number or null, but found ${an(yn(t))} instead.`);if(!hn(i,["string","array"]))throw new bn(`Expected second argument to be of type array or string, but found ${an(yn(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Ss{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,yn(e)))return null}else i=yn(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const u=t.parse(l,s,r);if(!u)return null;r=r||u.type,o.push(u)}const s=t.parse(e[1],1,tn);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new Ss(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(yn(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class Ms{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;nt.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}class Is{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,tn),r=t.parse(e[2],2,Yr);if(!i||!r)return null;if(!un(i.type,[sn(tn),Kr,tn]))return t.error(`Expected first argument to be of type array or string, but found ${an(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Yr);return n?new Is(i.type,i,r,n):null}return new Is(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!hn(t,["string","array"]))throw new bn(`Expected first argument to be of type array or string, but found ${an(yn(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function As(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 Cs(e,t,i,r){return 0===r.compare(t,i)}function Ps(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=Jr,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let o=t.parse(e[1],1,tn);if(!o)return null;if(!As(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${an(o.type)}'.`);let s=t.parse(e[2],2,tn);if(!s)return null;if(!As(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${an(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${an(o.type)}' and '${an(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Tn(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Tn(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,rn),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=yn(o),i=yn(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new bn(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=yn(o),i=yn(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize())})),t}}}const zs=Ps("==",(function(e,t,i){return t===i}),Cs),Ds=Ps("!=",(function(e,t,i){return t!==i}),(function(e,t,i,r){return!Cs(0,t,i,r)})),Ls=Ps("<",(function(e,t,i){return t",(function(e,t,i){return t>i}),(function(e,t,i,r){return r.compare(t,i)>0})),ks=Ps("<=",(function(e,t,i){return t<=i}),(function(e,t,i,r){return r.compare(t,i)<=0})),Os=Ps(">=",(function(e,t,i){return t>=i}),(function(e,t,i,r){return r.compare(t,i)>=0}));class Bs{constructor(e,t,i,r,n,o){this.type=Kr,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Yr);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,Kr),!n))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,Kr),!o))return null;let s=null;if(r.unit&&(s=t.parse(r.unit,1,Kr),!s))return null;let a=null;if(r["min-fraction-digits"]&&(a=t.parse(r["min-fraction-digits"],1,Yr),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,Yr),!l)?null:new Bs(i,n,o,s,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Fs{constructor(e){this.type=Yr,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${an(i.type)} instead.`):new Fs(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new bn(`Expected value to be of type string or array, but found ${an(yn(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}function Ns(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const Vs={"==":zs,"!=":Ds,">":Rs,"<":Ls,">=":Os,"<=":ks,array:Tn,at:ws,boolean:Tn,case:Ms,coalesce:vs,collator:Ln,format:En,image:Sn,in:Ts,"index-of":Es,interpolate:ys,"interpolate-hcl":ys,"interpolate-lab":ys,length:Fs,let:bs,literal:vn,match:Ss,number:Tn,"number-format":Bs,object:Tn,slice:Is,step:Qo,string:Tn,"to-boolean":An,"to-color":An,"to-number":An,"to-string":An,var:Ho,within:eo,distance:Vo,config:Go};function Us(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=_n(t,i,r,o);if(s)throw new bn(s);return new Ur(t/255*o,i/255*o,r/255*o,o)}function js(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=(function(e,t,i,r){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof i&&i>=0&&i<=100?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid hsla value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'h' must be between 0 and 360.`})(t,i,r,o);if(s)throw new bn(s);const a=`hsla(${t}, ${i}%, ${r}%, ${o})`,l=Ur.parse(a);if(!l)throw new bn(`Failed to parse HSLA color: ${a}`);return l}function Gs(e,t){return e in t}function qs(e,t){const i=t[e];return void 0===i?null:i}function Zs(e){return{type:e}}function $s(e){return{result:"success",value:e}}function Ws(e){return{result:"error",value:e}}function Hs(e,t){return!!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function Xs(e){return"data-driven"===e["property-type"]}function Ys(e){return Hs(e.expression,"measure-light")}function Ks(e){return Hs(e.expression,"zoom")}function Js(e){return!!e.expression&&e.expression.interpolated}function Qs(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ea(e){return e}function ta(e,t){const i="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),o=e.type||(Js(t)?"exponential":"interval");if(i&&((e=$r({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],Ur.parse(e[1])]))),e.default=Ur.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!gs[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=oa;else if("interval"===o)s=na;else if("categorical"===o){s=ra,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=sa}if(r){const i={},r=[];for(let t=0;te[0])),evaluate:({zoom:i},r)=>oa({stops:n,base:e.base},t,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:ys.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?ia(e.default,t.default):s(e,t,n,a,l)}}}function ia(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function ra(e,t,i,r,n){return ia(typeof i===n?r[i]:void 0,e.default,t.default)}function na(e,t,i){if("number"!==Mn(i))return ia(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=Jo(e.stops.map((e=>e[0])),i);return e.stops[n][1]}function oa(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==Mn(i))return ia(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=Jo(e.stops.map((e=>e[0])),i),s=(function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)})(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=Zr[t.type]||ea;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=gs[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function sa(e,t,i){return"color"===t.type?i=Ur.parse(i):"formatted"===t.type?i=fn.fromString(i.toString()):"resolvedImage"===t.type?i=mn.fromString(i.toString()):Mn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),ia(i,e.default,t.default)}zn.register(Vs,{error:[{kind:"error"},[Kr],(e,[t])=>{throw new bn(t.evaluate(e))}],typeof:[Kr,[tn],(e,[t])=>an(yn(t.evaluate(e)))],"to-rgba":[sn(Yr,4),[Qr],(e,[t])=>t.evaluate(e).toRenderColor(null).toArray()],rgb:[Qr,[Yr,Yr,Yr],Us],rgba:[Qr,[Yr,Yr,Yr,Yr],Us],hsl:[Qr,[Yr,Yr,Yr],js],hsla:[Qr,[Yr,Yr,Yr,Yr],js],has:{type:Jr,overloads:[[[Kr],(e,[t])=>Gs(t.evaluate(e),e.properties())],[[Kr,en],(e,[t,i])=>Gs(t.evaluate(e),i.evaluate(e))]]},get:{type:tn,overloads:[[[Kr],(e,[t])=>qs(t.evaluate(e),e.properties())],[[Kr,en],(e,[t,i])=>qs(t.evaluate(e),i.evaluate(e))]]},"feature-state":[tn,[Kr],(e,[t])=>qs(t.evaluate(e),e.featureState||{})],properties:[en,[],e=>e.properties()],"geometry-type":[Kr,[],e=>e.geometryType()],id:[tn,[],e=>e.id()],zoom:[Yr,[],e=>e.globals.zoom],pitch:[Yr,[],e=>e.globals.pitch||0],"distance-from-center":[Yr,[],e=>e.distanceFromCenter()],"measure-light":[Yr,[Kr],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Yr,[],e=>e.globals.heatmapDensity||0],"line-progress":[Yr,[],e=>e.globals.lineProgress||0],"raster-value":[Yr,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[Yr,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[Yr,[],e=>e.globals.skyRadialProgress||0],accumulated:[tn,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Yr,Zs(Yr),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Yr,Zs(Yr),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Yr,overloads:[[[Yr,Yr],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Yr],(e,[t])=>-t.evaluate(e)]]},"/":[Yr,[Yr,Yr],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Yr,[Yr,Yr],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Yr,[],()=>Math.LN2],pi:[Yr,[],()=>Math.PI],e:[Yr,[],()=>Math.E],"^":[Yr,[Yr,Yr],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Yr,[Yr],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Yr,[Yr],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Yr,[Yr],(e,[t])=>Math.log(t.evaluate(e))],log2:[Yr,[Yr],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Yr,[Yr],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Yr,[Yr],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Yr,[Yr],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Yr,[Yr],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Yr,[Yr],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Yr,[Yr],(e,[t])=>Math.atan(t.evaluate(e))],min:[Yr,Zs(Yr),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Yr,Zs(Yr),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Yr,[Yr],(e,[t])=>Math.abs(t.evaluate(e))],round:[Yr,[Yr],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Yr,[Yr],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Yr,[Yr],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Jr,[Kr,tn],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Jr,[tn],(e,[t])=>e.id()===t.value],"filter-type-==":[Jr,[Kr],(e,[t])=>e.geometryType()===t.value],"filter-<":[Jr,[Kr,tn],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r{const i=e.id(),r=t.value;return typeof i==typeof r&&i":[Jr,[Kr,tn],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Jr,[tn],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[Jr,[Kr,tn],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Jr,[tn],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[Jr,[Kr,tn],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Jr,[tn],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[Jr,[tn],(e,[t])=>t.value in e.properties()],"filter-has-id":[Jr,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Jr,[sn(Kr)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Jr,[sn(tn)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Jr,[Kr,sn(tn)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Jr,[Kr,sn(tn)],(e,[t,i])=>(function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1})(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Jr,overloads:[[[Jr,Jr],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Zs(Jr),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Jr,overloads:[[[Jr,Jr],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Zs(Jr),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Jr,[Jr],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Jr,[Kr],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Kr,[Kr],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Kr,[Kr],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Kr,Zs(tn),(e,t)=>t.map((t=>xn(t.evaluate(e)))).join("")],"resolved-locale":[Kr,[rn],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Yr,[Yr,Yr,tn],(e,t)=>{const[i,r,n]=t.map((t=>t.evaluate(e)));if(i>r)return i;if(i===r)return i;let o;if("string"==typeof n)o=(function(e){let t=0;if(0===e.length)return t;for(let i=0;iJSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function la(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Vs}function ca(e,t,i,r){const n=new Yo(Vs,[],t?(function(e){const t={color:Qr,string:Kr,number:Yr,enum:Kr,boolean:Jr,formatted:nn,resolvedImage:on};return"array"===e.type?sn(t[e.value]||tn,e.length):t[e.type]})(t):void 0,void 0,void 0,i,r),o=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return o?$s(new aa(o,t,i,r)):Ws(n.errors)}class ua{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isStateDependent="constant"!==e&&!Zo(t.expression),this.isConfigDependent=!$o(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}}class ha{constructor(e,t,i,r,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Zo(t.expression),this.isLightConstant=n,this.isConfigDependent=!$o(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?ys.interpolationFactor(this.interpolationType,e,t,i):0}}function da(e,t,i,r){if("error"===(e=ca(e,t,i,r)).result)return e;const n=e.value.expression,o=qo(n);if(!o&&!Xs(t))return Ws([new Wr("","data expressions not supported")]);const s=Wo(n,["zoom","pitch","distance-from-center"]);if(!s&&!Ks(t))return Ws([new Wr("","zoom expressions not supported")]);const a=Wo(n,["measure-light"]);if(!a&&!Ys(t))return Ws([new Wr("","measure-light expression not supported")]);const l=t.expression&&t.expression.relaxZoomRestriction,c=fa(n);return c||s||l?c instanceof Wr?Ws([c]):c instanceof ys&&!Js(t)?Ws([new Wr("",'"interpolate" expressions cannot be used with this property')]):$s(c?new ha(o?"camera":"composite",e.value,c.labels,c instanceof ys?c.interpolation:void 0,a):new ua(o?"constant":"source",e.value,a)):Ws([new Wr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class pa{constructor(e,t){this._parameters=e,this._specification=t,$r(this,ta(this._parameters,this._specification))}static deserialize(e){return new pa(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function fa(e){let t=null;if(e instanceof bs)t=fa(e.result);else if(e instanceof vs){for(const i of e.args)if(t=fa(i),t)break}else(e instanceof Qo||e instanceof ys)&&e.input instanceof zn&&"zoom"===e.input.name&&(t=e);return t instanceof Wr||e.eachChild((e=>{const i=fa(e);i instanceof Wr?t=i:t&&i&&t!==i&&(t=new Wr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}var ma=ga,_a=3;function ga(e,t,i){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(var o=0;o=u[p+0]&&r>=u[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},ga.prototype._forEachCell=function(e,t,i,r,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),d=l;d<=u;d++)for(var p=c;p<=h;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&n.call(this,e,t,i,r,f,o,s,a))return}},ga.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},ga.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},ga.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=_a+this.cells.length+1+1,i=0,r=0;r=0||(n[i]=Ta(e[i],t)));e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof e)}function Ea(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||ba(e)||wa(e)||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(Ea);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=new Map;for(const i of Object.keys(e))"$name"!==i&&t.set(i,Ea(e[i]));return t}const{klass:i}=xa[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=Ea(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const Sa={"Latin-1 Supplement":e=>e>=128&&e<=255,Arabic:e=>e>=1536&&e<=1791,"Arabic Supplement":e=>e>=1872&&e<=1919,"Arabic Extended-A":e=>e>=2208&&e<=2303,"Hangul Jamo":e=>e>=4352&&e<=4607,"Unified Canadian Aboriginal Syllabics":e=>e>=5120&&e<=5759,Khmer:e=>e>=6016&&e<=6143,"Unified Canadian Aboriginal Syllabics Extended":e=>e>=6320&&e<=6399,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"CJK Radicals Supplement":e=>e>=11904&&e<=12031,"Kangxi Radicals":e=>e>=12032&&e<=12255,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Bopomofo:e=>e>=12544&&e<=12591,"Hangul Compatibility Jamo":e=>e>=12592&&e<=12687,Kanbun:e=>e>=12688&&e<=12703,"Bopomofo Extended":e=>e>=12704&&e<=12735,"CJK Strokes":e=>e>=12736&&e<=12783,"Katakana Phonetic Extensions":e=>e>=12784&&e<=12799,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"CJK Unified Ideographs Extension A":e=>e>=13312&&e<=19903,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Yi Syllables":e=>e>=40960&&e<=42127,"Yi Radicals":e=>e>=42128&&e<=42191,"Hangul Jamo Extended-A":e=>e>=43360&&e<=43391,"Hangul Syllables":e=>e>=44032&&e<=55215,"Hangul Jamo Extended-B":e=>e>=55216&&e<=55295,"Private Use Area":e=>e>=57344&&e<=63743,"CJK Compatibility Ideographs":e=>e>=63744&&e<=64255,"Arabic Presentation Forms-A":e=>e>=64336&&e<=65023,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Arabic Presentation Forms-B":e=>e>=65136&&e<=65279,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519,"CJK Unified Ideographs Extension B":e=>e>=131072&&e<=173791};function Ma(e){for(const t of e)if(Ca(t.charCodeAt(0)))return!0;return!1}function Ia(e){for(const t of e)if(!Aa(t.charCodeAt(0)))return!1;return!0}function Aa(e){return!(Sa.Arabic(e)||Sa["Arabic Supplement"](e)||Sa["Arabic Extended-A"](e)||Sa["Arabic Presentation Forms-A"](e)||Sa["Arabic Presentation Forms-B"](e))}function Ca(e){return!(746!==e&&747!==e&&(e<4352||!(Sa["Bopomofo Extended"](e)||Sa.Bopomofo(e)||Sa["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||Sa["CJK Compatibility Ideographs"](e)||Sa["CJK Compatibility"](e)||Sa["CJK Radicals Supplement"](e)||Sa["CJK Strokes"](e)||!(!Sa["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Sa["CJK Unified Ideographs Extension A"](e)||Sa["CJK Unified Ideographs"](e)||Sa["Enclosed CJK Letters and Months"](e)||Sa["Hangul Compatibility Jamo"](e)||Sa["Hangul Jamo Extended-A"](e)||Sa["Hangul Jamo Extended-B"](e)||Sa["Hangul Jamo"](e)||Sa["Hangul Syllables"](e)||Sa.Hiragana(e)||Sa["Ideographic Description Characters"](e)||Sa.Kanbun(e)||Sa["Kangxi Radicals"](e)||Sa["Katakana Phonetic Extensions"](e)||Sa.Katakana(e)&&12540!==e||!(!Sa["Halfwidth and Fullwidth Forms"](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)||!(!Sa["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||Sa["Unified Canadian Aboriginal Syllabics"](e)||Sa["Unified Canadian Aboriginal Syllabics Extended"](e)||Sa["Vertical Forms"](e)||Sa["Yijing Hexagram Symbols"](e)||Sa["Yi Syllables"](e)||Sa["Yi Radicals"](e))))}function Pa(e){return!(Ca(e)||(function(e){return!!(Sa["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||Sa["General Punctuation"](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)||Sa["Letterlike Symbols"](e)||Sa["Number Forms"](e)||Sa["Miscellaneous Technical"](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)||Sa["Control Pictures"](e)&&9251!==e||Sa["Optical Character Recognition"](e)||Sa["Enclosed Alphanumerics"](e)||Sa["Geometric Shapes"](e)||Sa["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Sa["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Sa["CJK Symbols and Punctuation"](e)||Sa.Katakana(e)||Sa["Private Use Area"](e)||Sa["CJK Compatibility Forms"](e)||Sa["Small Form Variants"](e)||Sa["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)})(e))}function za(e){return e>=1424&&e<=2303||Sa["Arabic Presentation Forms-A"](e)||Sa["Arabic Presentation Forms-B"](e)}function Da(e,t){return!(!t&&za(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||Sa.Khmer(e))}function La(e){for(const t of e)if(za(t.charCodeAt(0)))return!0;return!1}const Ra="deferred",ka="loading",Oa="loaded";let Ba=null,Fa="unavailable",Na=null;const Va=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Fa="error"),Ba&&Ba(e)};function Ua(){ja.fire(new Lr("pluginStateChange",{pluginStatus:Fa,pluginURL:Na}))}const ja=new kr,Ga=function(){return Fa},qa=function(){if(Fa!==Ra||!Na)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Fa=ka,Ua(),Na&&tr({url:Na},(e=>{e?Va(e):(Fa=Oa,Ua())}))},Za={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Fa===Oa||null!=Za.applyArabicShaping,isLoading:()=>Fa===ka,setState(e){Fa=e.pluginStatus,Na=e.pluginURL},isParsed:()=>null!=Za.applyArabicShaping&&null!=Za.processBidirectionalText&&null!=Za.processStyledBidirectionalText,getPluginURL:()=>Na};class $a{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return(function(e,t){for(const i of e)if(!Da(i.charCodeAt(0),t))return!1;return!0})(e,Za.isLoaded())}}class Wa{constructor(e,t,i,r){this.property=e,this.value=t,this.expression=(function(e,t,i,r){if(Qs(e))return new pa(e,t);if(la(e)||Array.isArray(e)&&e.length>0){const n=da(e,t,i,r);if("error"===n.result)throw new Error(n.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return n.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=Ur.parse(e)),{kind:"constant",isConfigDependent:!1,evaluate:()=>i}}})(void 0===t?e.specification.default:t,e.specification,i,r)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Ha{constructor(e,t,i){this.property=e,this.value=new Wa(e,void 0,t,i)}transitioned(e,t){return new Ya(this.property,this.value,t,ti({},e.transition,this.transition),e.now)}untransitioned(){return new Ya(this.property,this.value,null,{},0)}}class Xa{constructor(e,t,i){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=i,this.isConfigDependent=!1}getValue(e){return hi(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ha(this._values[e].property,this._scope,this._options)),this._values[e].value=new Wa(this._values[e].property,null===t?void 0:hi(t),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].value.expression.isConfigDependent}setTransitionOrValue(e,t){t&&(this._options=t);const i=this._properties.properties;if(e)for(const t in e){const r=e[t];if(li(t,"-transition")){const e=t.slice(0,-11);i[e]&&this.setTransition(e,r)}else i.hasOwnProperty(t)&&this.setValue(t,r)}}getTransition(e){return hi(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ha(this._values[e].property)),this._values[e].transition=hi(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){const i=new Ka(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Ka(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Ya{constructor(e,t,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r":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"}},"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","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"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"]},"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,"experimental":true,"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":1,"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"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"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":1,"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"}},"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"}},"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-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,"expression":{},"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"expression":{},"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 sl(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function al(e){if(Array.isArray(e))return e.map(al);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=al(e[i]);return t}return sl(e)}function ll(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!ll(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function cl(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};ll(e)||(e=_l(e));const i=e;let r=!0;try{r=(function(e){if(!dl(e))return e;let t=al(e);return hl(t),t=ul(t),t})(i)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const n=ol[`filter_${t}`],o=ca(r,n);let s=null;if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(e,t,i)=>o.value.evaluate(e,t,{},i);let a=null,l=null;if(r!==i){const e=ca(i,n);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a=(t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o),l=!qo(e.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:ml(r),needFeature:!!l}}function ul(e){if(!Array.isArray(e))return e;const t=(function(e){if(pl.has(e[0]))for(let t=1;tul(e)))}function hl(e){let t=!1;const i=[];if("case"===e[0]){for(let r=1;r",">=","<","<=","to-boolean"]);function fl(e,t){return et?1:0}function ml(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?gl(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(_l))):"all"===t?["all"].concat(e.slice(1).map(_l)):"none"===t?["all"].concat(e.slice(1).map(_l).map(vl)):"in"===t?yl(e[1],e.slice(2)):"!in"===t?vl(yl(e[1],e.slice(2))):"has"===t?xl(e[1]):"!has"!==t||vl(xl(e[1]));var i}function gl(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function yl(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(fl)]]:["filter-in-small",e,["literal",t]]}}function xl(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function vl(e){return["!",e]}const bl="\x1f";function wl(e,t){return t?`${e}${bl}${t}`:e}const Tl="-transition",El=new Set(["fill","line","background","hillshade","raster"]);class Sl extends kr{constructor(e,t,i,r,n){if(super(),this.id=e.id,this.fqid=wl(this.id,i),this.type=e.type,this.scope=i,this.lut=r,this.options=n,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),e.slot&&(this.slot=e.slot),t.layout&&(this._unevaluatedLayout=new Ja(t.layout,this.scope,n),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),t.paint)){this._transitionablePaint=new Xa(t.paint,this.scope,n);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new el(t.paint)}}onAdd(e){}onRemove(e){}isDraped(e){return El.has(this.type)}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const i=this._unevaluatedLayout;i._properties.properties[e]&&(i.setValue(e,t),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,"visibility"===e&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(e){return li(e,Tl)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t){const i=this._transitionablePaint,r=i._properties.properties;if(li(e,Tl)){const n=e.slice(0,-11);return r[n]&&i.setTransition(n,t||void 0),!1}if(!r[e])return!1;const n=i._values[e],o=n.value.isDataDriven(),s=n.value;i.setValue(e,t),this.isConfigDependent=this.isConfigDependent||i.isConfigDependent,this._handleSpecialPaintPropertyUpdate(e);const a=i._values[e].value,l=a.isDataDriven(),c=li(e,"pattern")||"line-dasharray"===e;return l||o||c||this._handleOverridablePaintPropertyUpdate(e,s,a)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,i){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){return ui({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Qa&&Xs(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=cl(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(e){}queryIntersectsFeature(e,t,i,r,n,o,s,a,l){}queryIntersectsMatchingFeature(e,t,i,r){}}const Ml={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Il{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Al{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Cl(e,t=1){let i=0,r=0;return{members:e.map((e=>{const n=Ml[e.type].BYTES_PER_ELEMENT,o=i=Pl(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}})),size:Pl(i,Math.max(r,t)),alignment:t}}function Pl(e,t){return Math.ceil(e/t)*t}class zl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}zl.prototype.bytesPerElement=4,va(zl,"StructArrayLayout2i4");class Dl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}Dl.prototype.bytesPerElement=6,va(Dl,"StructArrayLayout3i6");class Ll extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}Ll.prototype.bytesPerElement=8,va(Ll,"StructArrayLayout4i8");class Rl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,e}}Rl.prototype.bytesPerElement=10,va(Rl,"StructArrayLayout5i10");class kl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,e}}kl.prototype.bytesPerElement=12,va(kl,"StructArrayLayout2i4ub1f12");class Ol extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}Ol.prototype.bytesPerElement=16,va(Ol,"StructArrayLayout4f16");class Bl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}Bl.prototype.bytesPerElement=12,va(Bl,"StructArrayLayout3f12");class Fl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=6*e,a=3*e;return this.uint16[s+0]=t,this.uint16[s+1]=i,this.uint16[s+2]=r,this.uint16[s+3]=n,this.float32[a+2]=o,e}}Fl.prototype.bytesPerElement=12,va(Fl,"StructArrayLayout4ui1f12");class Nl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=i,this.uint16[o+2]=r,this.uint16[o+3]=n,e}}Nl.prototype.bytesPerElement=8,va(Nl,"StructArrayLayout4ui8");class Vl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}Vl.prototype.bytesPerElement=12,va(Vl,"StructArrayLayout6i12");class Ul extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,u,h)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}Ul.prototype.bytesPerElement=24,va(Ul,"StructArrayLayout4i4ui4i24");class jl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}jl.prototype.bytesPerElement=20,va(jl,"StructArrayLayout3i3f20");class Gl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}Gl.prototype.bytesPerElement=4,va(Gl,"StructArrayLayout1ul4");class ql extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}ql.prototype.bytesPerElement=4,va(ql,"StructArrayLayout1f4");class Zl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}Zl.prototype.bytesPerElement=4,va(Zl,"StructArrayLayout2ui4");class $l extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,s,a,l,c,u,h,d)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}$l.prototype.bytesPerElement=40,va($l,"StructArrayLayout5i4f1i1ul2ui40");class Wl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}Wl.prototype.bytesPerElement=16,va(Wl,"StructArrayLayout3i2i2i16");class Hl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}Hl.prototype.bytesPerElement=16,va(Hl,"StructArrayLayout2f1f2i16");class Xl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=12*e,s=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[s+1]=r,this.float32[s+2]=n,e}}Xl.prototype.bytesPerElement=12,va(Xl,"StructArrayLayout2ub2f12");class Yl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}Yl.prototype.bytesPerElement=6,va(Yl,"StructArrayLayout3ui6");class Kl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,e}}Kl.prototype.bytesPerElement=60,va(Kl,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Jl extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v,b,w,T,E,S,M,I,A,C,P,z,D,L){const R=this.length;return this.resize(R+1),this.emplace(R,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v,b,w,T,E,S,M,I,A,C,P,z,D,L)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v,b,w,T,E,S,M,I,A,C,P,z,D,L,R){const k=22*e,O=44*e,B=88*e;return this.float32[k+0]=t,this.float32[k+1]=i,this.int16[O+4]=r,this.int16[O+5]=n,this.int16[O+6]=o,this.int16[O+7]=s,this.int16[O+8]=a,this.int16[O+9]=l,this.int16[O+10]=c,this.int16[O+11]=u,this.int16[O+12]=h,this.uint16[O+13]=d,this.uint16[O+14]=p,this.uint16[O+15]=f,this.uint16[O+16]=m,this.uint16[O+17]=_,this.uint16[O+18]=g,this.uint16[O+19]=y,this.uint16[O+20]=x,this.uint16[O+21]=v,this.uint16[O+22]=b,this.uint16[O+23]=w,this.uint16[O+24]=T,this.uint16[O+25]=E,this.uint16[O+26]=S,this.uint16[O+27]=M,this.uint32[k+14]=I,this.float32[k+15]=A,this.float32[k+16]=C,this.float32[k+17]=P,this.float32[k+18]=z,this.float32[k+19]=D,this.float32[k+20]=L,this.uint8[B+84]=R,e}}Jl.prototype.bytesPerElement=88,va(Jl,"StructArrayLayout2f9i15ui1ul6f1ub88");class Ql extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,this.float32[s+4]=o,e}}Ql.prototype.bytesPerElement=20,va(Ql,"StructArrayLayout5f20");class ec extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}ec.prototype.bytesPerElement=28,va(ec,"StructArrayLayout7f28");class tc extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}tc.prototype.bytesPerElement=8,va(tc,"StructArrayLayout2f8");class ic extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}ic.prototype.bytesPerElement=12,va(ic,"StructArrayLayout1ul3ui12");class rc extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}rc.prototype.bytesPerElement=2,va(rc,"StructArrayLayout1ui2");class nc extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=i,this.float32[g+2]=r,this.float32[g+3]=n,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=u,this.float32[g+10]=h,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,e}}nc.prototype.bytesPerElement=64,va(nc,"StructArrayLayout16f64");class oc extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=10*e,c=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=i,this.uint16[l+2]=r,this.uint16[l+3]=n,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,e}}oc.prototype.bytesPerElement=20,va(oc,"StructArrayLayout4ui3f20");class sc extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}sc.prototype.bytesPerElement=2,va(sc,"StructArrayLayout1i2");class ac extends Al{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}ac.prototype.bytesPerElement=1,va(ac,"StructArrayLayout1ub1");class lc extends Il{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}lc.prototype.size=40;class cc extends $l{get(e){return new lc(this,e)}}va(cc,"CollisionBoxArray");class uc extends Il{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}uc.prototype.size=60;class hc extends Kl{get(e){return new uc(this,e)}}va(hc,"PlacedSymbolArray");class dc extends Il{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e}get occlusionState(){return this._structArray.float32[this._pos4+19]}set occlusionState(e){this._structArray.float32[this._pos4+19]=e}get occlusionOpacity(){return this._structArray.float32[this._pos4+20]}set occlusionOpacity(e){this._structArray.float32[this._pos4+20]=e}get hasIconTextFit(){return this._structArray.uint8[this._pos1+84]}}dc.prototype.size=88;class pc extends Jl{get(e){return new dc(this,e)}}va(pc,"SymbolInstanceArray");class fc extends ql{getoffsetX(e){return this.float32[1*e+0]}}va(fc,"GlyphOffsetArray");class mc extends zl{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}va(mc,"SymbolLineVertexArray");class _c extends Il{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}_c.prototype.size=12;class gc extends ic{get(e){return new _c(this,e)}}va(gc,"FeatureIndexArray");class yc extends Zl{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}va(yc,"FillExtrusionCentroidArray");const xc=Cl([{name:"a_pos",components:2,type:"Int16"}],4),vc=Cl([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class bc{constructor(e=[]){this.segments=e}_prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>bc.MAX_VERTEX_ARRAY_LENGTH&&pi(`Max vertices per segment is ${bc.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>bc.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}prepareSegment(e,t,i,r){return this._prepareSegment(e,t.length,i.length,r)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,r){return new bc([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function wc(e,t){return 256*(e=Yt(Math.floor(e),0,255))+Yt(Math.floor(t),0,255)}bc.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,va(bc,"SegmentVector");const Tc=Cl([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ec=Cl([{name:"a_dash",components:4,type:"Uint16"}]);class Sc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(Mc(e)),this.positions.push(t,i,r)}eachPosition(e,t){const i=Mc(e);let r=0,n=this.ids.length-1;for(;r>1;this.ids[e]>=i?n=e:r=e+1}for(;this.ids[r]===i;)t(this.positions[3*r],this.positions[3*r+1],this.positions[3*r+2]),r++}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Ic(i,r,0,i.length-1),t&&(t.add(i.buffer),t.add(r.buffer)),{ids:i,positions:r}}static deserialize(e){const t=new Sc;let i;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==i&&t.uniqueIds.push(e),i=e;return t.indexed=!0,t}}function Mc(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Pr(String(e))}function Ic(e,t,i,r){for(;i>1];let o=i-1,s=r+1;for(;;){do{o++}while(e[o]n);if(o>=s)break;Ac(e,o,s),Ac(t,3*o,3*s),Ac(t,3*o+1,3*s+1),Ac(t,3*o+2,3*s+2)}s-i`u_${e}`)),this.type=i,this.context=r}setUniform(e,t,i,r,n){const o=r.constantOr(this.value);t.set(e,n,o instanceof Ur?o.toRenderColor(this.context.lut):o)}getBinding(e,t){return"color"===this.type?new kc(e):new zc(e)}}class Gc{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,t,i,r,n){const o="u_pattern"===n||"u_dash"===n?this.pattern:"u_pixel_ratio"===n?this.pixelRatio:null;o&&t.set(e,n,o)}getBinding(e,t){return"u_pattern"===t||"u_dash"===t?new Rc(e):new zc(e)}}class qc{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,i,r,n,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new $a(0,{brightness:o}),t,{},n,r,s);this.paintVertexArray.resize(e),this._setPaintValue(a,e,l,this.context)}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a,this.context)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=Uc(i.toRenderColor(r.lut));for(let i=e;i`u_${e}_t`)),this.type=i,this.useIntegerZoom=r,this.context=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate(new $a(this.context.zoom,{brightness:o}),t,{},n,r,s),l=this.expression.evaluate(new $a(this.context.zoom+1,{brightness:o}),t,{},n,r,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(c,e,a,l,this.context)}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:this.context.zoom,brightness:s},i,r,void 0,n),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a,l,this.context)}_setPaintValue(e,t,i,r,n){if("color"===this.type){const r=Uc(i.toRenderColor(n.lut)),o=Uc(i.toRenderColor(n.lut));for(let i=e;i!0){this.binders={},this._buffers=[],this.context=t;const r=[];for(const n in e.paint._values){const o=e.paint.get(n);if(!i(n))continue;if(!(o instanceof Qa&&Xs(o.property.specification)))continue;const s=Yc(n,e.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,u="line-dasharray"===n||n.endsWith("pattern"),h="line-dasharray"===n&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==a.kind||h)if("source"===a.kind||h||u){const t=Qc(n,l,"source");this.binders[n]=u?new $c(a,s,l,t,e.id):new qc(a,s,l,t),r.push(`/a_${n}`)}else{const e=Qc(n,l,"composite");this.binders[n]=new Zc(a,s,l,c,t,e),r.push(`/z_${n}`)}else this.binders[n]=u?new Gc(a.value,s):new jc(a.value,s,l,t),r.push(`/u_${n}`)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof qc||t instanceof Zc?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o,s){for(const a in this.binders){const l=this.binders[a];l.context=this.context,(l instanceof qc||l instanceof Zc||l instanceof $c)&&l.populatePaintArray(e,t,i,r,n,o,s)}}setConstantPatternPositions(e){for(const t in this.binders){const i=this.binders[t];i instanceof Gc&&i.setConstantPatternPositions(e)}}updatePaintArrays(e,t,i,r,n,o,s,a){let l=!1;const c=Object.keys(e),u=0!==c.length,h=u?c:t.uniqueIds;this.context.lut=n.lut;for(const c in this.binders){const d=this.binders[c];if(d.context=this.context,(d instanceof qc||d instanceof Zc||d instanceof $c)&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){const p=n.paint.get(c);d.expression=p.value;for(const i of h){const n=e[i.toString()];t.eachPosition(i,((e,t,i)=>{const l=r.feature(e);d.updatePaintArray(t,i,l,n,o,s,a)}))}if(!u)for(const t of i.uniqueIds){const n=e[t.toString()];i.eachPosition(t,((e,t,i)=>{const l=r.feature(e);d.updatePaintArray(t,i,l,n,o,s,a)}))}l=!0}}return l}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof jc||i instanceof Gc)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof qc||i instanceof Zc||i instanceof $c)for(let t=0;t!0){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Wc(r,t,i);this.needsUpload=!1,this._featureMap=new Sc,this._featureMapWithoutIds=new Sc,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,i,r,n,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,s,a);void 0!==t.id?this._featureMap.add(t.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r,n,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,s,r,n,o||0)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const Xc={"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"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Yc(e,t){return Xc[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Kc={"line-pattern":{source:Fl,composite:Fl},"fill-pattern":{source:Fl,composite:Fl},"fill-extrusion-pattern":{source:Fl,composite:Fl},"line-dasharray":{source:Nl,composite:Nl}},Jc={color:{source:tc,composite:Ol},number:{source:ql,composite:tc}};function Qc(e,t,i){const r=Kc[e];return r&&r[i]||Jc[t][i]}va(jc,"ConstantBinder"),va(Gc,"PatternConstantBinder"),va(qc,"SourceExpressionBinder"),va($c,"PatternCompositeBinder"),va(Zc,"CompositeExpressionBinder"),va(Wc,"ProgramConfiguration",{omit:["_buffers"]}),va(Hc,"ProgramConfigurationSet");const eu=co/Math.PI/2,tu=5,iu=6,ru=16383,nu=64,ou=[nu,32,16],su=-eu,au=eu;function lu(e,t,i,r=eu){return i=qt(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function cu(e,t,i){return lu(Math.cos(qt(e)),Math.sin(qt(e)),t,i)}const uu=6371008.8,hu=2*Math.PI*uu;class du{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new du(Jt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return uu*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new pu({lng:this.lng-i,lat:this.lat-t},{lng:this.lng+i,lat:this.lat+t})}toEcef(e){return cu(this.lat,this.lng,eu+e*eu/uu)}static convert(e){if(e instanceof du)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new du(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new du(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class pu{constructor(e,t){if(e)if(t)this.setSouthWest(e).setNorthEast(t);else if(4===e.length){const t=e;this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]])}else{const t=e;this.setSouthWest(t[0]).setNorthEast(t[1])}}setNorthEast(e){return this._ne=e instanceof du?new du(e.lng,e.lat):du.convert(e),this}setSouthWest(e){return this._sw=e instanceof du?new du(e.lng,e.lat):du.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof du)r=e,n=e;else{if(!(e instanceof pu))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(pu.convert(e)):this.extend(du.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(du.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new du(r.lng,r.lat),this._ne=new du(n.lng,n.lat)),this}getCenter(){return new du((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new du(this.getWest(),this.getNorth())}getSouthEast(){return new du(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:i}=du.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){return!e||e instanceof pu?e:new pu(e)}}var fu={};!(function(e,t){!(function(e){function t(e,t,r){var n=i(256*e,256*(t=Math.pow(2,r)-t-1),r),o=i(256*(e+1),256*(t+1),r);return n[0]+","+n[1]+","+o[0]+","+o[1]}function i(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}e.getURL=function(e,i,r,n,o,s){return s=s||{},e+"?"+["bbox="+t(r,n,o),"format="+(s.format||"image/png"),"service="+(s.service||"WMS"),"version="+(s.version||"1.1.1"),"request="+(s.request||"GetMap"),"srs="+(s.srs||"EPSG:3857"),"width="+(s.width||256),"height="+(s.height||256),"layers="+i].join("&")},e.getTileBBox=t,e.getMercCoords=i,Object.defineProperty(e,"__esModule",{value:!0})})(t)})(0,fu);var mu=fu;class _u{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=xu(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const i=mu.getTileBBox(this.x,this.y,this.z),r=(function(e,t,i){let r,n="";for(let o=e;o>0;o--)r=1<this.canonical.z?new yu(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new yu(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return xu(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return xu(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new yu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new yu(t,this.wrap,t,i,r),new yu(t,this.wrap,t,i+1,r),new yu(t,this.wrap,t,i,r+1),new yu(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,i=e.wrap;return t===1<new yu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new yu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<=l?(Ou(e,t,i,c,u,o,h,a,l),Ou(e,c,u,r,n,h,s,a,l)):e.push(s)}function Bu(e,t,i){let r=e[0],n=r.x,o=r.y;t(r);const s=[r];for(let a=1;ae.x+1||re.y+1)&&pi("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Gu(e,t,i){const r=e.loadGeometry(),n=e.extent,o=co/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<{const i=Iu((t.x+e.x/n)/o),r=Au((t.y+e.y/n)/o),u=c.project(i,r);e.x=(u.x*s-a)*n,e.y=(u.y*s-l)*n};for(let t=0;t=n||i.y<0||i.y>=n||(u(i),e.push(i));r[t]=e}}for(const e of r)for(const t of e)ju(t,o);return r}function qu(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Gu(e):[]}}function Zu(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2)}function $u(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class Wu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new zl,this.indexArray=new Yl,this.segments=new bc,this.programConfigurations=new Hc(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}updateFootprints(e,t){}populate(e,t,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=qu(t,e);if(!this.layers[0]._featureFilter.filter(new $a(this.zoom),c,i))continue;const u=s?s.evaluate(c,{},i):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Gu(t,i,r),patterns:{},sortKey:u};o.push(h)}s&&o.sort(((e,t)=>e.sortKey-t.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Vl,a=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,l=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,a,t.brightness),t.featureIndex.insert(l,n,o,s,this.index)}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xc.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,vc.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,i,r,n,o,s){for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=co||r<0||r>=co)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r),s=this.globeExtVertexArray;$u(s,e,t),$u(s,e,t),$u(s,e,t),$u(s,e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;Zu(this.layoutVertexArray,i,r,-1,-1),Zu(this.layoutVertexArray,i,r,1,-1),Zu(this.layoutVertexArray,i,r,1,1),Zu(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n,s)}}function Hu(e,t){for(let i=0;i1){if(Ju(e,t))return!0;for(let r=0;r1?i:i.sub(t)._mult(n)._add(t))}function ih(e,t){let i,r,n,o=!1;for(let s=0;st.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function rh(e,t){let i=!1;for(let r=0,n=e.length-1;rt.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function nh(e,t,i,r,n){for(const o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const o=[new Ut(t,i),new Ut(t,n),new Ut(r,n),new Ut(r,i)];if(e.length>2)for(const t of o)if(rh(e,t))return!0;for(let t=0;tn.x&&t.x>n.x||e.yn.y&&t.y>n.y)return!1;const o=fi(e,t,i[0]);return o!==fi(e,t,i[1])||o!==fi(e,t,i[2])||o!==fi(e,t,i[3])}function sh(e,t,i,r,n,o){let s=t.y-e.y,a=e.x-t.x;if(o=o||0){const e=s*s+a*a;if(0===e)return!0;const t=Math.sqrt(e);s/=t,a/=t}return!((i.x-e.x)*s+(i.y-e.y)*a-o<0||(r.x-e.x)*s+(r.y-e.y)*a-o<0||(n.x-e.x)*s+(n.y-e.y)*a-o<0)}function ah(e,t,i,r,n,o,s){return!(sh(e,t,r,n,o,s)||sh(t,i,r,n,o,s)||sh(i,e,r,n,o,s)||sh(r,n,e,t,i,s)||sh(n,o,e,t,i,s)||sh(o,r,e,t,i,s))}function lh(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function ch(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function uh(e,t,i,r,n){if(!t[0]&&!t[1])return e;const o=Ut.convert(t)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let t=0;t=0;if(0===s)return 0;s!==i.length&&(r=!1)}return r?2:1}function yh(e,t){for(const i of e.projections){const r=_h(t,e.points[0],i.axis);if(i.projection[1]r[1])return 0}return 1}function xh(t,i){let r=0;const n=[0,0,0,0];for(let o=0;o=0&&r++;return r}class vh{constructor(t,i){this.points=t||new Array(8).fill([0,0,0]),this.planes=i||new Array(6).fill([0,0,0,0]),this.bounds=bh.fromPoints(this.points),this.projections=[],this.frustumEdges=[e._.sub([],this.points[2],this.points[3]),e._.sub([],this.points[0],this.points[3]),e._.sub([],this.points[4],this.points[0]),e._.sub([],this.points[5],this.points[1]),e._.sub([],this.points[6],this.points[2]),e._.sub([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],i=[e[2],0,-e[0]];this.projections.push({axis:t,projection:_h(this.points,this.points[0],t)}),this.projections.push({axis:i,projection:_h(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(t,i,r,n){const o=Math.pow(2,r),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const s=e.aA.transformMat4([],r,t),a=1/s[3]/i*o;return e.aA.mul(s,s,[a,a,n?1/s[3]:a,a])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const i=e._.sub([],s[t[0]],s[t[1]]),r=e._.sub([],s[t[2]],s[t[1]]),n=e._.normalize([],e._.cross([],i,r)),o=-e._.dot(n,s[t[1]]);return n.concat(o)})),l=[];for(let e=0;ea[1]||a[0]>s[1])return 0}return 1}}class bh{static fromPoints(t){const i=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const n of t)e._.min(i,i,n),e._.max(r,r,n);return new bh(i,r)}static fromTileIdAndHeight(e,t,i){const r=1<e.max[t]||e.min[t]>this.max[t])return!1;return!0}intersectsAabbXY(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t])}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t])}closestPoint(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}va(bh,"Aabb");const wh=Cl([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Th}=wh,Eh=Cl([{name:"a_pos_3",components:3,type:"Int16"}]);var Sh=Cl([{name:"a_pos",type:"Int16",components:2}]);function Mh(e){return e*eu/uu}const Ih=[new bh([su,su,su],[au,au,au]),new bh([su,su,su],[0,0,au]),new bh([0,su,su],[au,0,au]),new bh([su,0,su],[0,au,au]),new bh([0,0,su],[au,au,au])];function Ah(t,i,r,n=!0){const o=e._.scale([],t._camera.position,t.worldSize),s=[i,r,1,1];e.aA.transformMat4(s,s,t.pixelMatrixInverse),e.aA.scale(s,s,1/s[3]);const a=e._.sub([],s,o),l=e._.normalize([],a),c=t.globeMatrix,u=[c[12],c[13],c[14]],h=e._.sub([],u,o),d=e._.length(h),p=e._.normalize([],h),f=t.worldSize/(2*Math.PI),m=e._.dot(p,l),_=Math.asin(f/d);if(_1?null:(function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)})(e.a[t],e.b[t],e.angle,Yt(i,0,1))+e.center[t]}function zh(e){if(e.z<=1)return Ih[e.z+2*e.y+e.x];const t=Bh(Oh(e));return bh.fromPoints(t)}function Dh(t,i,r){return e._.scale(t,t,1-r),e._.scaleAndAdd(t,t,i,r)}function Lh(t,i){const r=$h(i.zoom);if(0===r)return zh(t);const n=Oh(t),o=Bh(n),s=Eu(n.getWest())*i.worldSize,a=Eu(n.getEast())*i.worldSize,l=Su(n.getNorth())*i.worldSize,c=Su(n.getSouth())*i.worldSize,u=[s,l,0],h=[a,l,0],d=[s,c,0],p=[a,c,0],f=e.ad.invert([],i.globeMatrix);return e._.transformMat4(u,u,f),e._.transformMat4(h,h,f),e._.transformMat4(d,d,f),e._.transformMat4(p,p,f),o[0]=Dh(o[0],d,r),o[1]=Dh(o[1],p,r),o[2]=Dh(o[2],h,r),o[3]=Dh(o[3],u,r),bh.fromPoints(o)}function Rh(t,i,r){for(const n of t)e._.transformMat4(n,n,i),e._.scale(n,n,r)}function kh(t,i,r,n){const o=i/t.worldSize,s=t.globeMatrix;if(r.z<=1){const e=zh(r).getCorners();return Rh(e,s,o),bh.fromPoints(e)}const a=Oh(r,n),l=Bh(a,eu+Mh(t._tileCoverLift));Rh(l,s,o);const c=Number.MAX_VALUE,u=[-c,-c,-c],h=[c,c,c];if(a.contains(t.center)){for(const t of l)e._.min(h,h,t),e._.max(u,u,t);u[2]=0;const i=t.point,r=[i.x*o,i.y*o,0];return e._.min(h,h,r),e._.max(u,u,r),new bh(h,u)}if(t._tileCoverLift>0){for(const t of l)e._.min(h,h,t),e._.max(u,u,t);return new bh(h,u)}const d=[s[12]*o,s[13]*o,s[14]*o],p=a.getCenter(),f=Yt(t.center.lat,-85.051129,Pu),m=Yt(p.lat,-85.051129,Pu),_=Eu(t.center.lng),g=Su(f);let y=_-Eu(p.lng);const x=g-Su(m);y>.5?y-=1:y<-.5&&(y+=1);let v=0;if(Math.abs(y)>Math.abs(x))v=y>=0?1:3;else{v=x>=0?0:2;const t=[s[4]*o,s[5]*o,s[6]*o],i=-Math.sin(qt(x>=0?a.getSouth():a.getNorth()))*eu;e._.scaleAndAdd(d,d,t,i)}const b=l[v],w=l[(v+1)%4],T=new Ch(b,w,d),E=[Ph(T,0)||b[0],Ph(T,1)||b[1],Ph(T,2)||b[2]],S=$h(t.zoom);if(S>0){const n=(function({x:e,y:t,z:i},r,n,o,s){const a=1/(1<.5?d=-1:p<-.5&&(d=1),l=((l+d)*r-(o*=r))*n+o,c=((c+d)*r-o)*n+o,u=(u*r-(s*=r))*n+s,h=(h*r-s)*n+s,[[l,h,0],[c,h,0],[c,u,0],[l,u,0]]})(r,i,t._pixelsPerMercatorPixel,_,g);for(let e=0;eMath.PI/2*1.01}const Xh=qt(85),Yh=Math.cos(Xh),Kh=Math.sin(Xh),Jh=e.ad.create(),Qh=e=>{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function ed(t,i,r,n,o,s,a,l,c){if(s&&t.queryGeometry.isAboveHorizon)return!1;s&&(c*=t.pixelToTileUnitsFactor);const u=t.tileID.canonical,h=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(const d of i)for(const i of d){const d=i.add(l),p=o&&r.elevation?r.elevation.exaggeration()*o.getElevationAt(d.x,d.y,!0):0,f=r.projection.projectTilePoint(d.x,d.y,u);if(p>0){const e=r.projection.upVector(u,d.x,d.y);f.x+=e[0]*h*p,f.y+=e[1]*h*p,f.z+=e[2]*h*p}const m=s?d:td(f.x,f.y,f.z,n),_=s?t.tilespaceRays.map((e=>nd(e,p))):t.queryGeometry.screenGeometry,g=e.aA.transformMat4([],[f.x,f.y,f.z,1],n);if(!a&&s?c*=g[3]/r.cameraToCenterDistance:a&&!s&&(c*=r.cameraToCenterDistance/g[3]),s){const e=Au((i.y/co+u.y)/(1<e.width||n.height>e.height||i.x>e.width-n.width||i.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||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,c=t.data,u=4===o&&a;for(let a=0;a{t[e.evaluationKey]=o;const s=e.expression.evaluate(t);s&&(n.data[i+r+0]=Math.floor(255*s.r/s.a),n.data[i+r+1]=Math.floor(255*s.g/s.a),n.data[i+r+2]=Math.floor(255*s.b/s.a),n.data[i+r+3]=Math.floor(255*s.a))};if(e.clips)for(let t=0,n=0;t80*i){a=1/0,l=1/0;let t=-1/0,r=-1/0;for(let o=i;ot&&(t=i),n>r&&(r=n)}c=Math.max(t-a,r-l),c=0!==c?32767/c:0}return wd(o,s,i,a,l,c,0),s}function vd(e,t,i,r,n){let o;if(n===(function(e,t,i,r){let n=0;for(let o=t,s=i-r;o0)for(let n=t;n=t;n-=r)o=Ud(n/r|0,e[n],e[n+1],o);return o&&kd(o,o.next)&&(jd(o),o=o.next),o}function bd(e,t){if(!e)return e;t||(t=e);let i,r=e;do{if(i=!1,r.steiner||!kd(r,r.next)&&0!==Rd(r.prev,r,r.next))r=r.next;else{if(jd(r),r=t=r.prev,r===r.next)break;i=!0}}while(i||r!==t);return t}function wd(e,t,i,r,n,o,s){if(!e)return;!s&&o&&(function(e,t,i,r){let n=e;do{0===n.z&&(n.z=Pd(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,(function(e){let t,i=1;do{let r,n=e;e=null;let o=null;for(t=0;n;){t++;let s=n,a=0;for(let e=0;e0||l>0&&s;)0!==a&&(0===l||!s||n.z<=s.z)?(r=n,n=n.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=s}o.nextZ=null,i*=2}while(t>1)})(n)})(e,r,n,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?Ed(e,r,n,o):Td(e))t.push(l.i,e.i,c.i),jd(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?wd(e=Sd(bd(e),t),t,i,r,n,o,2):2===s&&Md(e,t,i,r,n,o):wd(bd(e),t,i,r,n,o,1);break}}}function Td(e){const t=e.prev,i=e,r=e.next;if(Rd(t,i,r)>=0)return!1;const n=t.x,o=i.x,s=r.x,a=t.y,l=i.y,c=r.y,u=no?n>s?n:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c;let f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Dd(n,a,o,l,s,c,f.x,f.y)&&Rd(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ed(e,t,i,r){const n=e.prev,o=e,s=e.next;if(Rd(n,o,s)>=0)return!1;const a=n.x,l=o.x,c=s.x,u=n.y,h=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,_=u>h?u>d?u:d:h>d?h:d,g=Pd(p,f,t,i,r),y=Pd(m,_,t,i,r);let x=e.prevZ,v=e.nextZ;for(;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&Dd(a,u,l,h,c,d,x.x,x.y)&&Rd(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&Dd(a,u,l,h,c,d,v.x,v.y)&&Rd(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&Dd(a,u,l,h,c,d,x.x,x.y)&&Rd(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&Dd(a,u,l,h,c,d,v.x,v.y)&&Rd(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Sd(e,t){let i=e;do{const r=i.prev,n=i.next.next;!kd(r,n)&&Od(r,i,i.next,n)&&Nd(r,n)&&Nd(n,r)&&(t.push(r.i,i.i,n.i),jd(i),jd(i.next),i=e=n),i=i.next}while(i!==e);return bd(i)}function Md(e,t,i,r,n,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Ld(s,e)){let a=Vd(s,e);return s=bd(s,s.next),a=bd(a,a.next),wd(s,t,i,r,n,o,0),void wd(a,t,i,r,n,o,0)}e=e.next}s=s.next}while(s!==e)}function Id(e,t){return e.x-t.x}function Ad(e,t){const i=(function(e,t){let i=t;const r=e.x,n=e.y;let o,s=-1/0;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const e=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>s&&(s=e,o=i.x=i.x&&i.x>=l&&r!==i.x&&Dd(no.x||i.x===o.x&&Cd(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o})(e,t);if(!i)return t;const r=Vd(i,e);return bd(r,r.next),bd(i,i.next)}function Cd(e,t){return Rd(e.prev,e,t.prev)<0&&Rd(t.next,e,e.next)<0}function Pd(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function zd(e){let t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(r-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function Ld(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!(function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Od(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1})(e,t)&&(Nd(e,t)&&Nd(t,e)&&(function(e,t){let i=e,r=!1;const n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r})(e,t)&&(Rd(e.prev,e,t.prev)||Rd(e,t.prev,t))||kd(e,t)&&Rd(e.prev,e,e.next)>0&&Rd(t.prev,t,t.next)>0)}function Rd(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function kd(e,t){return e.x===t.x&&e.y===t.y}function Od(e,t,i,r){const n=Fd(Rd(e,t,i)),o=Fd(Rd(e,t,r)),s=Fd(Rd(i,r,e)),a=Fd(Rd(i,r,t));return n!==o&&s!==a||!(0!==n||!Bd(e,i,t))||!(0!==o||!Bd(e,r,t))||!(0!==s||!Bd(i,e,r))||!(0!==a||!Bd(i,t,r))}function Bd(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Fd(e){return e>0?1:e<0?-1:0}function Nd(e,t){return Rd(e.prev,e,e.next)<0?Rd(e,t,e.next)>=0&&Rd(e,e.prev,t)>=0:Rd(e,t,e.prev)<0||Rd(e,e.next,t)<0}function Vd(e,t){const i=Gd(e.i,e.x,e.y),r=Gd(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Ud(e,t,i,r){const n=Gd(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function jd(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 Gd(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function qd(e,t){const i=e.length;if(i<=1)return[e];const r=[];let n,o;for(let t=0;t1)for(let e=0;ee.fqid)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new zl,this.indexArray=new Yl,this.indexArray2=new Zl,this.programConfigurations=new Hc(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new bc,this.segments2=new bc,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}updateFootprints(e,t){}populate(e,t,i,r){this.hasPattern=$d("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=qu(s,e);if(!this.layers[0]._featureFilter.filter(new $a(this.zoom),u,i))continue;const h=n?n.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Gu(s,i,r),patterns:{},sortKey:h};o.push(d)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const e=Wd("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.availableImages,t.brightness);t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n)}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,yd),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,r,n,o=[],s){for(const e of qd(t,500)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),n.push(t[0].x),n.push(t[0].y);for(let e=1;ee.cellIdx-t.cellIdx||e.triIdx-t.triIdx));let c=0;for(;cthis.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const i=Jd(e.x-this.min.x,this.xScale,this.cellsX),r=Jd(e.y-this.min.y,this.yScale,this.cellsY),n=this.cells[r*this.cellsX+i];if(n){this._lazyInitLookup();for(let e=0;ethis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const r=Jd(e.x-this.min.x,this.xScale,this.cellsX),n=Jd(t.x-this.min.x,this.xScale,this.cellsX),o=Jd(e.y-this.min.y,this.yScale,this.cellsY),s=Jd(t.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=s;e++)for(let t=r;t<=n;t++){const r=this.cells[e*this.cellsX+t];if(r)for(let e=0;ee.fqid)),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.footprints=[]}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e})}populate(e,t,i,r){const n=[];for(const{feature:t,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=qu(t,e);if(!this.layers[0]._featureFilter.filter(new $a(this.zoom),l,i))continue;const c={id:o,properties:t.properties,type:t.type,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Gu(t,i,r),patterns:{}};n.push(c)}for(const r of n){const{geometry:n,index:o,sourceLayerIndex:s}=r;this.addFeature(r,n,o,i,{},t.availableImages,t.brightness),t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,t,i,r,n){}destroy(){}addFeature(e,t,i,r,n,o=[],s){for(const e of qd(t,2)){const t=[],i=[],r=[],n=new Ut(1/0,1/0),o=new Ut(-1/0,-1/0);for(const s of e)if(0!==s.length){s!==e[0]&&r.push(i.length/2);for(let e=0;e>3}if(n--,1===r||2===r)o+=e.readSVarint(),s+=e.readSVarint(),1===r&&(t&&a.push(t),t=[]),t.push(new cp(o,s));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&a.push(t),a},hp.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos>3}if(r--,1===i||2===i)(n+=e.readSVarint())a&&(a=n),(o+=e.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},hp.prototype.toGeoJSON=function(e,t,i){var r,n,o=this.extent*Math.pow(2,i),s=this.extent*e,a=this.extent*t,l=this.loadGeometry(),c=hp.types[this.type];function u(e){for(var t=0;t>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t})(i))}_p.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new fp(this._pbf,t,this.extent,this._keys,this._values)};var yp=mp;function xp(e,t,i){if(3===e){var r=new yp(i,i.readVarint()+i.pos);r.length&&(t[r.name]=r)}}var vp=lp.VectorTile=function(e,t){this.layers=e.readFields(xp,{},t)},bp=lp.VectorTileFeature=up;lp.VectorTileLayer=mp;class wp extends Ut{constructor(e,t,i){super(e,t),this.z=i}}class Tp extends wp{constructor(e,t,i,r){super(e,t,i),this.w=r}}function Ep(e,t,i,r){const n=[],o=0===r?(e,t,i,r,n,o)=>{e.push(new Ut(o,i+(o-t)/(r-t)*(n-i)))}:(e,t,i,r,n,o)=>{e.push(new Ut(t+(o-i)/(n-i)*(r-t),o))};for(const s of e){const e=[];for(const n of s){if(n.length<=2)continue;const s=[];for(let e=0;et&&o(s,a,l,c,u,t):h>i?d=t&&o(s,a,l,c,u,t),d>i&&h<=i&&o(s,a,l,c,u,i)}let a=n[n.length-1];const l=0===r?a.x:a.y;l>=t&&l<=i&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),e.push(s))}e.length&&n.push(e)}return n}function Sp(e,t,i,r){const n="x"===i?"y":"x",o=(r-e[i])/(t[i]-e[i]);e[n]=e[n]+(t[n]-e[n])*o,e[i]=r,e.hasOwnProperty("z")&&(e.z=Gr(e.z,t.z,o)),e.hasOwnProperty("w")&&(e.w=Gr(e.w,t.w,o))}function Mp(e,t,i,r){const n=i,o=r;for(const i of["x","y"]){let r=e,s=t;r[i]>=s[i]&&(r=t,s=e),r[i]n&&Sp(r,s,i,n),r[i]o&&Sp(s,r,i,o)}}function Ip(e,t){return e.x-t.x||e.y-t.y}function Ap(e,t){return 0===Ip(e.min,t.min)&&0===Ip(e.max,t.max)}function Cp(e,t){return!(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew Ut((e.x+o.x*co)*a-s.x*co,(e.y+o.y*co)*a-s.y*co)))}return Lp(i,n,e.indices,0,e.indices.length,0,0)}function kp(e,t,i,r){const n=Math.pow(2,r.z-i.z);return new Ut((e+i.x*co)*n-r.x*co,(t+i.y*co)*n-r.y*co)}function Op(e,t){const i=[];t.footprint.grid.queryPoint(e,i);const r=t.footprint.indices,n=t.footprint.vertices;for(let t=0;tt[s])return null}else{const a=1/r[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e}if(l>n&&(n=l),co)return null}return n}function Np(e,t,i,r,n,o,s,a,l,c,u){const h=r-e,d=n-t,p=o-i,f=s-e,m=a-t,_=l-i,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,x=u[0]*m-u[1]*f,v=h*g+d*y+p*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,E=c[2]-i,S=(w*g+T*y+E*x)*b;if(S<0||S>1)return null;const M=T*p-E*d,I=E*h-w*p,A=w*d-T*h,C=(u[0]*M+u[1]*I+u[2]*A)*b;return C<0||S+C>1?null:(f*M+m*I+_*A)*b}function Vp(e,t,i){return(e-t)/(i-t)}function Up(e,t,i,r,n,o,s,a,l){const c=1<{const o=r?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=a,n[2]=s,n[3]=l};let s=new Bp(r);const a=[];for(let t=0;t=1;r/=2){const e=i[i.length-1];s=new Bp(r);for(let t=0;t0;){const{idx:l,t:f,nodex:m,nodey:_,depth:g}=p.pop();if(this.leaves[l]){Up(m,_,g,t,i,r,n,h,d);const l=1<=t[2])return f}continue}let y=0;for(let e=0;e=c[u[r]]&&(u.splice(r,0,e),i=!0);i||(u[y]=e),y++}}for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}static pack(e,t){const i=[0,0,0,0],r=Hp.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new hd({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;te.max.x&&(e.max.x=t.x,r=!0),t.ye.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===co)&&t.x===i.x)!=((0===t.y||t.y===co)&&t.y===i.y)&&this.processBorderOverlap(t,i),r&&this.checkBorderIntersection(t,i)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Gr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>co!=e.x>co&&this.addBorderIntersection(1,Gr(t.y,e.y,(co-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Gr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>co!=e.y>co&&this.addBorderIntersection(3,Gr(t.x,e.x,(co-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];ti[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){return 0===this.accCount?new Ut(0,0):new Ut(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0):0}}function hf(e,t){const i=e.add(t)._unit(),r=Yt(e.x*i.x+e.y*i.y,-1,1);var n,o,s;return n=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(n)))/4*tf*((o=e).x*(s=t).y-o.y*s.x<0?-1:1)}const df=[e=>e.x<0,e=>e.x>co,e=>e.y<0,e=>e.y>co];function pf(e,t,i,r){const n=[4];if(0===r)return n;i._mult(r);const o=e.sub(i),s=t.sub(i),a=[e,t,o,s];for(let e=0;e<4;e++)for(const t of a)if(df[e](t)){n.push(e);break}return n}class ff{constructor(e){this.vertexArray=new Rl,this.indexArray=new Yl,this.programConfigurations=new Hc(e.layers,{zoom:e.zoom,lut:e.lut},(e=>Qp.includes(e))),this._segments=new bc,this.hiddenByLandmarkVertexArray=new ac,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new bc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,r=!1){const n=e.length;if(n>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],i=e[1];a=hf(t.sub(e[n-1])._perp()._unit(),i.sub(t)._perp()._unit())}for(let l=0;le.region-t.region));for(let i=0;ie+t),0);let o=0;for(let e=0;e<=4;e++){const t=n[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new bc);const n={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};i.get().push(n)}o+=t}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,op.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy()}}}}class mf{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Yl,this.footprintVertices=new zl,this.footprintSegments=[],this.layoutVertexArray=new Ll,this.centroidVertexArray=new yc,this.indexArray=new Yl,this.programConfigurations=new Hc(e.layers,{zoom:e.zoom,lut:e.lut},(e=>Jp.includes(e))),this.segments=new bc,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.groundEffect=new ff(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(e,t){}populate(e,t,i,r){this.features=[],this.hasPattern=$d("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=Ru(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=qu(n,e);if(!this.layers[0]._featureFilter.filter(new $a(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Gu(n,i,r),properties:n.properties,type:n.type,patterns:{}},u=this.layoutVertexArray.length;this.hasPattern?this.features.push(Wd("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,s,i,{},t.availableImages,r,t.brightness),t.featureIndex.insert(n,c.geometry,s,a,this.index,u)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,i,r,n,o){for(const e of this.features){const{geometry:s}=e;this.addFeature(e,s,e.index,t,i,r,n,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,i,r,n){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,t,s,i,r,n),this.groundEffect.update(e,t,s,i,r,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ap),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,sp.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,np.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,r,n,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,c=[new Ut(0,0),new Ut(co,co)],u=s.projection,h="globe"===u.name,d="Polygon"===Kp[e.type],p=new uf;p.centroidDataIndex=this.centroidData.length;const f=new cf,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},r);f.height=_,f.vertexArrayOffset=this.layoutVertexArray.length,f.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Vl);const g=qd(t,500);for(let e=g.length-1;e>=0;e--){const t=g[e];(0===t.length||(y=t[0]).every((e=>e.x<=0))||y.every((e=>e.x>=co))||y.every((e=>e.y<=0))||y.every((e=>e.y>=co)))&&g.splice(e,1)}var y;let x;if(h)x=Ef(g,c,r);else{x=[];for(const e of g)x.push({polygon:e,bounds:c})}const v=d?this.edgeRadius:0,b=v>0&&this.zoom<17,w=(e,t)=>{if(0===e.length)return!1;const i=e[e.length-1];return t.x===i.x&&t.y===i.y};for(const{polygon:e,bounds:t}of x){let i=0,n=0;for(const t of e)d&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=d?t.length-1:t.length;const o=this.segments.prepareSegment((d?5:4)*n,this.layoutVertexArray,this.indexArray);f.footprintSegIdx<0&&(f.footprintSegIdx=this.footprintSegments.length),f.polygonSegIdx<0&&(f.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new lf;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],d){const n=[],s=[];i=o.vertexLength;for(let i=0;i4&&bf(s[s.length-2],s[0],s[1]),c=v?gf(s[s.length-2],s[0],s[1],v):0;const _=[];let g,y,x;y=s[1].sub(s[0])._perp()._unit();let b=!0;for(let e=1,n=0;e0?1:0,I=l.dist(d);if(n+I>32768&&(n=0),v){x=T.sub(d)._perp()._unit();let e=yf(l,d,T,_f(y,x),v);isNaN(e)&&(e=0);const t=d.sub(l)._unit();l=l.add(t.mult(c))._round(),d=d.add(t.mult(-e))._round(),c=e,y=x,m&&this.zoom>=17&&(w(_,l)||_.push(l),w(_,d)||_.push(d))}const A=o.vertexLength,C=s.length>4&&bf(l,d,T);let P=wf(n,a,b);if(of(this.layoutVertexArray,l.x,l.y,S,M,0,0,P),of(this.layoutVertexArray,l.x,l.y,S,M,0,1,P),n+=I,P=wf(n,C,!b),a=C,of(this.layoutVertexArray,d.x,d.y,S,M,0,0,P),of(this.layoutVertexArray,d.x,d.y,S,M,0,1,P),o.vertexLength+=4,this.indexArray.emplaceBack(A+0,A+1,A+2),this.indexArray.emplaceBack(A+1,A+3,A+2),o.primitiveLength+=2,v){const r=i+(1===e?s.length-2:e-2),n=1===e?i:r+1;if(this.indexArray.emplaceBack(A+1,r,A+3),this.indexArray.emplaceBack(r,n,A+3),o.primitiveLength+=2,void 0===g&&(g=A),!xf(T,s[e],t)){const t=e===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(A+2,A+3,t),this.indexArray.emplaceBack(A+3,t+1,t),this.indexArray.emplaceBack(A+3,n,t+1),o.primitiveLength+=3}b=!b}if(h){const e=this.layoutVertexExtArray,t=u.projectTilePoint(l.x,l.y,r),i=u.projectTilePoint(d.x,d.y,r),n=u.upVector(r,l.x,l.y),o=u.upVector(r,d.x,d.y);af(e,t,n),af(e,t,n),af(e,i,o),af(e,i,o)}}d&&(i+=s.length-1),m&&v&&this.zoom>=17&&(0!==_.length&&w(_,_[0])&&_.pop(),this.groundEffect.addData(_,t,l,v>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?rf:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]))}splitToSubtiles(){const e=[];for(let t=0;tco),n=2*r+(+(i.min.x+i.max.x>co)^r);for(let r=0;re.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx));let i=0,r=0,n=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;n++}const o=e.length;for(;r!==e.length;){i=e[r].triangleSegmentIdx;let s=0,a=r,l=r;for(let t=a;t0&&this.triangleSubSegments.push({segment:u,min:o,max:c}),a=l;for(let t=a;t[e[0]*(1-i[0])+t[0]*i[0],e[1]*(1-i[1])+t[1]*i[1]],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/co,d[1]=e.min.y/co,p[0]=e.max.x/co,p[1]=e.max.y/co;const t=h(l,c,d),o=h(l,c,p);if(0===new bh([t[0],t[1],r],[o[0],o[1],n]).intersectsPrecise(i)){a&&(u.segments.push(a),a=void 0);continue}const s=e.segment;a&&a.vertexOffset!==s.vertexOffset&&(u.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}}}return a&&u.segments.push(a),u}encodeCentroid(e,t){const i=e.centroid(),r=t.span(),n=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new Ut(Yt(i.x,1,8191)<<3|n,Yt(i.y,1,8191)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new Ut(0,0);const t=e.borders,i=Number.MAX_VALUE;if(t[0][0]!==i||t[1][0]!==i){const e=t[0][0]!==i?0:1;return new Ut(6|(t[0][0]!==i?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==i?2:3;return new Ut((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=nf,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,r=e.flags&nf?rf:e.centroidXY,n=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||n!==r.x){for(let e=t;ei.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(r=!r)}s=i}}return r}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,r=!0;const n=4*(e+co)*co+(t+co);if(this.partLookup.hasOwnProperty(n)){const e=this.partLookup[n];return e?{height:e.height,hidden:!!(e.flags&nf)}:void 0}for(const 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>i&&(i=o.height,this.partLookup[n]=o,r=!!(o.flags&nf));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:r};this.partLookup[n]=void 0}}function _f(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function gf(e,t,i,r){const n=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return yf(e,t,i,_f(n,o),r)}function yf(e,t,i,r,n){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(i)/3,n*o/r)}function xf(e,t,i){return e.xi[1].x&&t.x>i[1].x||e.yi[1].y&&t.y>i[1].y}function vf(e,t){return e.xt[1].x||e.yt[1].y}function bf(e,t,i){if(e.x<0||e.x>=co||t.x<0||t.x>=co||i.x<0||i.x>=co)return!1;const r=i.sub(t),n=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function wf(e,t,i){const r=t?2|e:-3&e;return i?1|r:-2&r}function Tf(){const e=Math.PI/32,t=Math.tan(e),i=uu;return i*Math.sqrt(1+2*t*t)-i}function Ef(e,t,i){const r=1<{for(const i of e)s.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(r)),u=l-c,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e)}if(f.length){const e=[new Ut(0===i?u:r.x,1===i?u:r.y),s];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return s})(e,t,Math.ceil((o-n)/11.25),Math.ceil((s-a)/11.25),1,((e,t,n)=>{if(0===e)return.5*(t+n);{const e=Au((i.y+t/co)/r);return(Su(.5*(Au((i.y+n/co)/r)+e))*r-i.y)*co}}))}function Sf(e,t,i,r,n,o){const s=Math.pow(2,r.z-n.z);for(let a=0;a1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=r-Math.sqrt(u*u+d*d);this.image.data[n+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i1&&(s=e[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return pi("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;te.fqid)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new kl,this.layoutVertexArray2=new Ol,this.patternVertexArray=new Bl,this.indexArray=new Yl,this.programConfigurations=new Hc(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new bc,this.maxLineLength=0,this.zOffsetVertexArray=new ql,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.tessellationStep=e.tessellationStep?e.tessellationStep:128}updateFootprints(e,t){}populate(e,t,i,r){this.hasPattern=$d("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),o=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!o.isConstant()||!!o.constantOr(0);const s=[];for(const{feature:t,id:o,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=qu(t,e);if(!this.layers[0]._featureFilter.filter(new $a(this.zoom),c,i))continue;const u=n?n.evaluate(c,{},i):void 0,h={id:o,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Gu(t,i,r),patterns:{},sortKey:u};s.push(h)}n&&s.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:a,featureIndex:l}=t,c=this.addConstantDashes(a);for(const r of s){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(c&&this.addFeatureDashes(r,a),this.hasPattern){const e=Wd("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,a.positions,t.availableImages,t.brightness);l.insert(e[o].feature,n,o,s,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else{const t=n.value,i=r.value;if(!i)continue;e.addDash(i,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a;if("constant"===n.kind){if(s=n.value,!s)continue}else s=n.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[r.id]=t.getKey(s,a)}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n)}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Rf)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Of)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Uf.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Df),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,r,n,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap").evaluate(e,{}),u=a.get("line-miter-limit"),h=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,r,l,c,u,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,s)}addLine(e,t,i,r,n,o,s){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const a={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,c="none"===r;if(this.patternJoinNone=this.hasPattern&&c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[h-1].equals(e[h-2]);)h--;let d=0;for(;d0;if(A&&i>d){const e=m.dist(_);if(e>2*p){const t=m.sub(m.sub(_)._mult(p/e)._round());this.updateDistance(_,t),this.addCurrentVertex(t,y,0,0,f,v),_=t}}if(b&&"round"===w&&(Mo&&(w="bevel"),"bevel"===w&&(M>2&&(w="flipbevel"),M100)E=x.mult(-1);else{const e=M*y.add(x).mag()/y.sub(x).mag();E._perp()._mult(e*(C?-1:1))}this.addCurrentVertex(m,E,0,0,f,v),this.addCurrentVertex(m,E.mult(-1),0,0,f,v)}else if("bevel"===w||"fakeround"===w){const e=-Math.sqrt(M*M-1),t=C?e:0,i=C?0:e;if(_&&this.addCurrentVertex(m,y,t,i,f,v),"fakeround"===w){const e=Math.round(180*I/Math.PI/20);for(let t=1;t2*p){const t=m.add(g.sub(m)._mult(p/e)._round());this.updateDistance(m,t),this.addCurrentVertex(t,x,0,0,f,v),m=t}}}}addVerticesTo(e,t,i,r,n,o,s,a,l,c){const u=(t.w-e.w)/this.tessellationStep|0;if(u>1){this.lineSoFar=e.w;const h=(t.x-e.x)/u,d=(t.y-e.y)/u,p=(t.z-e.z)/u,f=(t.w-e.w)/u;for(let t=1;t=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l)}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}function Jf(e,t,i){return e.xi||e.yi}va(Kf,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const Qf=new nl({"line-cap":new il(ol.layout_line["line-cap"]),"line-join":new il(ol.layout_line["line-join"]),"line-miter-limit":new tl(ol.layout_line["line-miter-limit"]),"line-round-limit":new tl(ol.layout_line["line-round-limit"]),"line-sort-key":new il(ol.layout_line["line-sort-key"]),"line-z-offset":new il(ol.layout_line["line-z-offset"]),visibility:new tl(ol.layout_line.visibility)});var em={paint:new nl({"line-opacity":new il(ol.paint_line["line-opacity"]),"line-color":new il(ol.paint_line["line-color"]),"line-translate":new tl(ol.paint_line["line-translate"]),"line-translate-anchor":new tl(ol.paint_line["line-translate-anchor"]),"line-width":new il(ol.paint_line["line-width"]),"line-gap-width":new il(ol.paint_line["line-gap-width"]),"line-offset":new il(ol.paint_line["line-offset"]),"line-blur":new il(ol.paint_line["line-blur"]),"line-dasharray":new il(ol.paint_line["line-dasharray"]),"line-pattern":new il(ol.paint_line["line-pattern"]),"line-gradient":new rl(ol.paint_line["line-gradient"]),"line-trim-offset":new tl(ol.paint_line["line-trim-offset"]),"line-trim-fade-range":new tl(ol.paint_line["line-trim-fade-range"]),"line-trim-color":new tl(ol.paint_line["line-trim-color"]),"line-emissive-strength":new tl(ol.paint_line["line-emissive-strength"]),"line-border-width":new il(ol.paint_line["line-border-width"]),"line-border-color":new il(ol.paint_line["line-border-color"]),"line-occlusion-opacity":new tl(ol.paint_line["line-occlusion-opacity"])}),layout:Qf};function tm(e,t,i){return t*(co/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function im(e,t){return 1/tm(e,1,t.tileZoom)}function rm(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const nm=e=>{const t=[];om(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const r="none"===e.layout.get("line-join").constantOr("miter"),n=!!e.paint.get("line-pattern").constantOr(1);return r&&n&&t.push("LINE_JOIN_NONE"),t};function om(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}class sm{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t */ -read:function(e,t,i,r,n){var o,s,a=8*n-r-1,l=(1<>1,h=-7,u=i?n-1:0,d=i?-1:1,p=e[t+u];for(u+=d,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+e[t+u],u+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+e[t+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},write:function(e,t,i,r,n,o){var s,a,l,c=8*o-n-1,h=(1<>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(t*l-1)*Math.pow(2,n),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;e[i+p]=255&a,p+=f,a/=256,n-=8);for(s=s<0;e[i+p]=255&s,p+=f,s/=256,c-=8);e[i+p-f]|=128*m}},tm=rm,im=em;function rm(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}rm.Varint=0,rm.Fixed64=1,rm.Bytes=2,rm.Fixed32=5;var nm=4294967296,om=2.3283064365386963e-10,sm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function am(e){return e.type===rm.Bytes?e.readVarint()+e.pos:e.pos+1}function lm(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function cm(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function hm(e,t){for(var i=0;i>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function bm(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}rm.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=xm(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=bm(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=xm(this.buf,this.pos)+xm(this.buf,this.pos+4)*nm;return this.pos+=8,e},readSFixed64:function(){var e=xm(this.buf,this.pos)+bm(this.buf,this.pos+4)*nm;return this.pos+=8,e},readFloat:function(){var e=im.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=im.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:(function(e,t,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return lm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return lm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return lm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return lm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return lm(e,r,t);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return lm(e,r,t);throw new Error("Expected varint not more than 10 bytes")})(t|=(15&(i=r[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&&sm?(function(e,t,i){return sm.decode(e.subarray(t,i))})(this.buf,t,e):(function(e,t,i){for(var r="",n=t;n239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===h?(s=e[n+2],128==(192&(o=e[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(s=e[n+2],a=e[n+3],128==(192&(o=e[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r})(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,t){if(this.type!==rm.Bytes)return e.push(this.readVarint(t));var i=am(this);for(e=e||[];this.pos127;);else if(t===rm.Bytes)this.pos=this.readVarint()+this.pos;else if(t===rm.Fixed32)this.pos+=4;else{if(t!==rm.Fixed64)throw new Error("Unimplemented type: "+t);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 i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),(function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)})(i,0,t),(function(e,t){var i=(7&e)<<4;t.buf[t.pos++]|=i|((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)))))})(r,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,i){for(var r,n,o=0;o55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i})(this.buf,e,this.pos);var i=this.pos-t;i>=128&&cm(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),im.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),im.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i=128&&cm(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,i){this.writeTag(e,rm.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,hm,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,um,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,fm,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,dm,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,pm,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,mm,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,_m,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,gm,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,ym,t)},writeBytesField:function(e,t){this.writeTag(e,rm.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,rm.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,rm.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,rm.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,rm.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,rm.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,rm.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,rm.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,rm.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,rm.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var wm=u(tm);function Tm(e,t,i){t.glyphs=[],1===e&&i.readMessage(Em,t)}function Em(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Sm,{});t.glyphs.push({id:e,bitmap:new id({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function Sm(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}const Mm={horizontal:1,vertical:2,horizontalOnly:3};class Am{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const i=new Am;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new Am;return t.imageName=e,t}}class Im{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const i=new Im;for(let r=0;r=0&&i>=e&&Pm[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const i=new Im;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Am.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Cm(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=Im.fromFeature(e,n);u===Mm.vertical&&m.verticalizePunctuation(d);let _=[];const g=(function(e,t,i,r,n,o){if(!e)return[];const s=[],a=(function(e,t,i,r,n,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(E=e[m]);const r=t[a.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(x=o.metrics,M=8203!==m?qf:0,_){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,i=(e+t)*g;w-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;ar;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=t.dist(i)}return!0}function Gm(e){let t=0;for(let i=0;ic){const h=(c-l)/o,u=jr(r.x,n.x,h),d=jr(r.y,n.y,h),p=new Um(u,d,0,n.angleTo(r),i);return!s||jm(e,p,a,s,t)?p:void 0}l+=o}}function Wm(e,t,i,r,n,o,s,a,l){const c=qm(r,o,s),h=Zm(r,n),u=h*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-u=0&&g=0&&y=0&&d+c<=h){const i=new Um(g,y,0,m,t);r&&!jm(e,i,o,r,n)||p.push(i)}}u+=f}return a||p.length||s||(p=Qm(e,u/2,i,r,n,o,s,!0,l)),p}function Hm(e,t,i,r,n){const o=[];for(let s=0;s=r&&c.x>=r||(s.x>=r?s=new Vt(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=r&&(c=new Vt(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=n&&c.y>=n||(s.y>=n?s=new Vt(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round():c.y>=n&&(c=new Vt(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function Xm(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();ee.hasImage(t,i))),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const r in e.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[r],e.getImage(r,i),t),this.patchUpdatedImage(this.patternPositions[r],e.getImage(r,i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl,o=!!Object.keys(this.patternPositions).length;i.update(t.data,{useMipmap:o},{x:r,y:n})}}fa(Jm,"ImagePosition"),fa(Km,"ImageAtlas");const e_=1e20;function t_(e,t,i,r,n,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=e_}for(let a=0,l=0;a{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[t];if(void 0!==n)return void i(null,{stack:e,id:t,glyph:n});if(n=this._tinySDF(r,e,t),n)return r.glyphs[t]=n,void i(null,{stack:e,id:t,glyph:n});const s=Math.floor(t/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[s])return void i(null,{stack:e,id:t,glyph:n});let a=r.requests[s];a||(a=r.requests[s]=[],o_.loadGlyphRange(e,s,o,this.requestManager,((e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[s]=!0}for(const i of a)i(e,t);delete r.requests[s]}))),a.push(((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null})}))}),((e,t)=>{if(e)i(e);else if(t){const e={};for(const{stack:i,id:r,glyph:n}of t)void 0===e[i]&&(e[i]={}),void 0===e[i].glyphs&&(e[i].glyphs={}),e[i].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[i].ascender=this.entries[i].ascender,e[i].descender=this.entries[i].descender;i(null,e)}}))}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==n_.none&&(this.localGlyphMode===n_.all?!!this.localFontFamily:!!this.localFontFamily&&(xa["CJK Unified Ideographs"](e)||xa["Hangul Syllables"](e)||xa.Hiragana(e)||xa.Katakana(e)||xa["CJK Symbols and Punctuation"](e)||xa["CJK Unified Ideographs Extension A"](e)||xa["CJK Unified Ideographs Extension B"](e)))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),n=e.tinySDF=new o_.TinySDF({fontFamily:r,fontWeight:i,fontSize:48,buffer:6,radius:16}),n.fontWeight=i}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new id({width:a,height:l},s),metrics:{width:c/r_,height:h/r_,left:u/r_,top:d/r_-27,advance:p/r_,localGlyph:!0}}}}o_.loadGlyphRange=function(e,t,i,r,n){const o=256*t,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),Hi.Glyphs);Ki(a,((e,t)=>{if(e)n(e);else if(t){const e={},i=(function(e){return new wm(e).readFields(Tm,{})})(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}}))},o_.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const a=this.size=e+4*t,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(e_,0,u),_.fill(0,0,u);for(let e=0;e0?e*e:0,_[r]=e<0?e*e:0}}t_(g,0,0,c,h,c,this.f,this.v,this.z),t_(_,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;ee+t[1]-t[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,x=f,v=0,b=m,w=0,T=_,E=0,S=g;if(o.content&&r){const e=o.content;y=l_(u,0,e[0]),v=l_(d,0,e[1]),x=l_(u,e[0],e[2]),b=l_(d,e[1],e[3]),w=e[0]-y,E=e[1]-v,T=e[2]-e[0]-x,S=e[3]-e[1]-b}const M=(r,n,a,l)=>{const u=h_(r.stretch-y,x,c,e.left),d=u_(r.fixed-w,T,r.stretch,f),p=h_(n.stretch-v,b,h,e.top),_=u_(n.fixed-E,S,n.stretch,m),g=h_(a.stretch-y,x,c,e.left),M=u_(a.fixed-w,T,a.stretch,f),A=h_(l.stretch-v,b,h,e.top),I=u_(l.fixed-E,S,l.stretch,m),C=new Vt(u,p),P=new Vt(g,p),z=new Vt(g,A),D=new Vt(u,A),R=new Vt(d/s,_/s),L=new Vt(M/s,I/s),k=t*Math.PI/180;if(k){const e=Math.sin(k),t=Math.cos(k),i=[t,-e,e,t];C._matMult(i),P._matMult(i),D._matMult(i),z._matMult(i)}const O=r.stretch+r.fixed,B=a.stretch+a.fixed,F=n.stretch+n.fixed,N=l.stretch+l.fixed,V=e.imageSecondary;return{tl:C,tr:P,bl:D,br:z,texPrimary:{x:o.paddedRect.x+s_+O,y:o.paddedRect.y+s_+F,w:B-O,h:N-F},texSecondary:V?{x:V.paddedRect.x+s_+O,y:V.paddedRect.y+s_+F,w:B-O,h:N-F}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:L,minFontScaleX:T/s/c,minFontScaleY:S/s/h,isSDF:i}};if(r&&(o.stretchX||o.stretchY)){const e=c_(u,_,f),t=c_(d,g,m);for(let i=0;io)&&(o=t.x),(!e||t.y>s)&&(s=t.y)}const l=Math.min(o-r,s-n);let c=l/2;const h=new ro([],f_);if(0===l)return new Vt(r,n);for(let t=r;tu.d||!u.d)&&(u=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-u.d<=t||(c=r.h/2,h.push(new m_(r.p.x-c,r.p.y-c,c,e)),h.push(new m_(r.p.x+c,r.p.y-c,c,e)),h.push(new m_(r.p.x-c,r.p.y+c,c,e)),h.push(new m_(r.p.x+c,r.p.y+c,c,e)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${u.d}`)),u.p}function f_(e,t){return t.max-e.max}class m_{constructor(e,t,i,r){this.p=new Vt(e,t),this.h=i,this.d=(function(e,t){let i=!1,r=1/0;for(let n=0;ne.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,Hh(e,n,a))}}return(i?1:-1)*Math.sqrt(r)})(this.p,r),this.max=this.d+this.h*Math.SQRT2}}const __=Number.POSITIVE_INFINITY,g_=Math.sqrt(2);function y_(e,[t,i]){let r=0,n=0;if(i===__){t<0&&(t=0);const i=t/g_;switch(e){case"top-right":case"top-left":n=i-7;break;case"bottom-right":case"bottom-left":n=7-i;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=t;break;case"right":r=-t}}else{switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}}return[r,n]}function x_(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 v_(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){let m=o.textMaxSize.evaluate(t,{},u);void 0===m&&(m=s);const _=e.layers[0].layout,g=_.get("icon-offset").evaluate(t,{},u),y=E_(i.horizontal)||i.vertical,x="globe"===d.name,v=qf,b=s/v,w=e.tilePixelRatio*m/v,T=(z=e.overscaling,e.zoom>18&&z>2&&(z>>=1),Math.max(no/(512*z),1)*_.get("symbol-spacing")),E=_.get("text-padding")*e.tilePixelRatio,S=_.get("icon-padding")*e.tilePixelRatio,M=Gt(_.get("text-max-angle")),A="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),I="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),C=_.get("symbol-placement"),P=T/2;var z;const D=_.get("icon-text-fit").evaluate(t,{},u),R=_.get("icon-text-fit-padding").evaluate(t,{},u),L="none"!==D;let k;!1===e.hasAnyIconTextFit&&L&&(e.hasAnyIconTextFit=!0),r&&L&&(e.allowVerticalPlacement&&i.vertical&&(k=Vm(r,i.vertical,D,R,g,b)),y&&(r=Vm(r,y,D,R,g,b)));const O=(s,a,m)=>{if(a.x<0||a.x>=no||a.y<0||a.y>=no)return;let _=null;if(x){const{x:e,y:t,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new Um(e,t,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!(function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,M){const A=e.addToLineVertexArray(t,r);let I,C,P,z,D,R,L,k=0,O=0,B=0,F=0,N=-1,V=-1;const U={};let j=Pr("");const G=i?i.anchor:t,q="none"!==l.layout.get("icon-text-fit").evaluate(v,{},E);let Z=0,$=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,$]=l.layout.get("text-offset").evaluate(v,{},E).map((e=>e*qf)):(Z=l.layout.get("text-radial-offset").evaluate(v,{},E)*qf,$=__),e.allowVerticalPlacement&&n.vertical){const e=n.vertical;if(f)R=M_(e),a&&(L=M_(a));else{const i=l.layout.get("text-rotate").evaluate(v,{},E)+90;P=S_(c,G,t,h,u,d,e,p,i,m),a&&(z=S_(c,G,t,h,u,d,a,g,i))}}if(o){const r=l.layout.get("icon-rotate").evaluate(v,{},E),n=a_(o,r,w,q),s=a?a_(a,r,w,q):void 0;C=S_(c,G,t,h,u,d,o,g,r),k=4*n.length;const p=e.iconSizeData;let f=null;"source"===p.kind?(f=[Zf*l.layout.get("icon-size").evaluate(v,{},E)],f[0]>w_&&ui(`${e.layerIds[0]}: Value for "icon-size" is >= ${b_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Zf*b.compositeIconSizes[0].evaluate(v,{},E),Zf*b.compositeIconSizes[1].evaluate(v,{},E)],(f[0]>w_||f[1]>w_)&&ui(`${e.layerIds[0]}: Value for "icon-size" is >= ${b_}. Reduce your "icon-size".`)),e.addSymbols(e.icon,n,f,x,y,v,!1,i,t,A.lineStartIndex,A.lineLength,-1,T,E,S,M),N=e.icon.placedSymbolArray.length-1,s&&(O=4*s.length,e.addSymbols(e.icon,s,f,x,y,v,Mm.vertical,i,t,A.lineStartIndex,A.lineLength,-1,T,E,S,M),V=e.icon.placedSymbolArray.length-1)}for(const r in n.horizontal){const o=n.horizontal[r];I||(j=Pr(o.text),f?D=M_(o):I=S_(c,G,t,h,u,d,o,p,l.layout.get("text-rotate").evaluate(v,{},E),m));const a=1===o.positionedLines.length;if(B+=T_(e,i,t,o,s,l,f,v,m,A,n.vertical?Mm.horizontal:Mm.horizontalOnly,a?Object.keys(n.horizontal):[r],U,N,b,T,E,S),a)break}n.vertical&&(F+=T_(e,i,t,n.vertical,s,l,f,v,m,A,Mm.vertical,["vertical"],U,V,b,T,E,S));let W=-1;const Q=(e,t)=>e?Math.max(e,t):t;W=Q(D,W),W=Q(R,W),W=Q(L,W);const H=W>-1?1:0;e.glyphOffsetArray.length>=65535&&ui("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,G.x,G.y,G.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,N,V,j,void 0!==I?I:e.collisionBoxArray.length,void 0!==I?I+1:e.collisionBoxArray.length,void 0!==P?P:e.collisionBoxArray.length,void 0!==P?P+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,z||e.collisionBoxArray.length,z?z+1:e.collisionBoxArray.length,h,B,F,k,O,H,0,Z,$,W,0,q?1:0)})(e,a,_,s,i,r,n,k,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,E,A,l,0,S,I,g,t,o,c,h,u,p,f)};if("line"===C)for(const n of Hm(t.geometry,0,0,no,no)){const t=Wm(n,T,M,i.vertical||y,r,v,w,e.overscaling,no);for(const i of t)y&&A_(e,y.text,P,i)||O(n,i,u)}else if("line-center"===C){for(const e of t.geometry)if(e.length>1){const t=$m(e,M,i.vertical||y,r,v,w);t&&O(e,t,u)}}else if("Polygon"===t.type)for(const e of Vd(t.geometry,0)){const t=p_(e,16);O(e[0],new Um(t.x,t.y,0,0,void 0),u)}else if("LineString"===t.type)for(const e of t.geometry)O(e,new Um(e[0].x,e[0].y,0,0,void 0),u);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)O([t],new Um(t.x,t.y,0,0,void 0),u)}const b_=255,w_=32640;function T_(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=(function(e,t,i,r,n,o,s,a){const l=[];if(0===t.positionedLines.length)return l;const c=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=(function(e){const t=e[0],i=e[1],r=t*i;return r>0?[t,-i]:r<0?[-t,i]:0===t?[i,t]:[i,-t]})(i);let u=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)u-=e.lineOffset;const d=t.positionedLines.length,p=u/d;let f=t.top-i[1];for(let e=0;ew_&&ui(`${e.layerIds[0]}: Value for "text-size" is >= ${b_}. Reduce your "text-size".`)):"composite"===x.kind&&(v=[Zf*f.compositeTextSizes[0].evaluate(a,{},_),Zf*f.compositeTextSizes[1].evaluate(a,{},_)],(v[0]>w_||v[1]>w_)&&ui(`${e.layerIds[0]}: Value for "text-size" is >= ${b_}. Reduce your "text-size".`)),e.addSymbols(e.text,y,v,l,s,a,h,t,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const t of u)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function E_(e){for(const t in e)return e[t];return null}function S_(e,t,i,r,n,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const e=new Vt(d,h),t=new Vt(p,h),i=new Vt(d,u),r=new Vt(p,u),n=Gt(l);let o=new Vt(0,0);c&&(o=new Vt(c[0],c[1])),e._rotateAround(n,o),t._rotateAround(n,o),i._rotateAround(n,o),r._rotateAround(n,o),d=Math.min(e.x,t.x,i.x,r.x),p=Math.max(e.x,t.x,i.x,r.x),h=Math.min(e.y,t.y,i.y,r.y),u=Math.max(e.y,t.y,i.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,d,h,p,u,a,r,n,o),e.length-1}function M_(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function A_(e,t,i,r){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])x&&(v(e,c,r,n,a,l),v(c,i,a,l,o,s))}v(u,d,r,o,n,o),v(d,p,n,o,n,s),v(p,f,n,s,r,s),v(f,u,r,s,r,o),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}function P_(e,{x:t,y:i},r=0){return new Vt(((t-r)*e.scale-e.x)*no,(i*e.scale-e.y)*no)}const z_=e.a9.identity(new Float32Array(16));class D_{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new sh(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i=!0){return e._coordinatePoint(e.locationCoordinate(t),i)}pixelsPerMeter(e,t){return vh(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return I_(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,r){const n=e.horizonLineFromTop(!1),o=new Vt(t,Math.max(n,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,i){const r=new Vt(t,i);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y0?t<-U_+i&&(t=-U_+i):t>U_-i&&(t=U_-i);const o=n/Math.pow(j_(t),r);let s=o*Math.sin(r*e),a=n-o*Math.cos(r*e);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:i,f:r}=this,n=r-t,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=Ht(qt(a/i)+this.center[0],-180,180),c=Ht(qt(2*Math.atan(Math.pow(r/s,1/i))-U_),-85.051129,Eh);return new sh(l,this.southernCenter?-c:c)}}class q_ extends D_{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:yh(e),y:xh(t),z:0}}unproject(e,t){const i=bh(e),r=wh(t);return new sh(i,r)}}const Z_=Gt(Eh);class $_ extends D_{project(e,t){const i=(t=Gt(t))*t,r=i*i;return{x:.5*((e=Gt(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.06507600000000001*e))),i=Ht(i-n,-Z_,Z_)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=Ht(qt(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=qt(i);return new sh(s,a)}}const W_=Gt(Eh);class Q_ extends D_{project(e,t){t=Gt(t),e=Gt(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*r+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,h=n*n,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(n*u)*Math.sqrt(1/m):0,y=.5*(2*g*n*d+2*i/Math.PI)-e,x=.5*(g*o+r)-t,v=.5*_*(h*f+g*n*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*n)+.5,E=b*w-T*v;s=(x*b-y*T)/E,a=(y*w-x*v)/E,i=Ht(i-s,-Math.PI,Math.PI),r=Ht(r-a,-W_,W_)}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new sh(qt(i),qt(r))}}class H_ extends D_{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Gt(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:i,cosPhi:r}=this;return{x:Gt(e)*r*i+.5,y:-Math.sin(Gt(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=Ht(qt((e-.5)/i)/r,-180,180),s=Math.asin(Ht(n*r,-1,1)),a=Ht(qt(s),-85.051129,Eh);return new sh(o,a)}}class X_ extends q_{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,i,r){const n=zu(t,i,r),o=Lu(Su(r));return e.Q.transformMat4(n,n,o),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,i){const r=rh(i.lat,i.lng),n=e.Q.normalize([],r),o=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(i),t._centerAltitude):t._centerAltitude,s=vh(1,0)*no*o;e.Q.scaleAndAdd(r,r,n,s);const a=e.a9.identity(new Float64Array(16));return e.a9.multiply(a,t.pixelMatrix,t.globeMatrix),e.Q.transformMat4(r,r,a),new Vt(r[0],r[1])}pixelsPerMeter(e,t){return vh(1,0)*t}pixelSpaceConversion(e,t,i){const r=vh(1,e)*t,n=jr(vh(1,45)*t,r,i);return this.pixelsPerMeter(e,t)/n}createTileMatrix(t,i,r){const n=ku(Su(r.canonical));return e.a9.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,i){const{center:r}=t,n=Lu(Su(i));return e.a9.rotateY(n,n,Gt(r.lng)),e.a9.rotateX(n,n,Gt(r.lat)),e.a9.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,i,r){return wu(e,t,i,!0)||new Ch(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!wu(e,t.x,t.y,!1)}farthestPixelDistance(t){const i=(function(t,i){const r=t.cameraToCenterDistance,n=t._centerAltitude*i,o=t._camera,s=t._camera.forward(),a=e.Q.add([],e.Q.scale([],s,-r),[0,0,n]),l=t.worldSize/(2*Math.PI),c=[0,0,-l],h=t.width/t.height,u=Math.tan(t.fovAboveCenter),d=e.Q.scale([],o.up(),u),p=e.Q.scale([],o.right(),u*h),f=e.Q.normalize([],e.Q.add([],e.Q.add([],s,d),p)),m=[];let _;if(new lu(a,f).closestPointOnSphere(c,l,m)){const i=e.Q.add([],m,c),r=e.Q.sub([],i,a);_=Math.cos(t.fovAboveCenter)*e.Q.length(r)}else{const t=e.Q.sub([],a,c),i=e.Q.sub([],c,a);e.Q.normalize(i,i);const r=e.Q.length(t)-l;_=Math.sqrt(r*(r+2*l));const n=Math.acos(_/(l+r))-Math.acos(e.Q.dot(s,i));_*=Math.cos(n)}return 1.01*_})(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),r=Nu(t.zoom);if(r>0){const e=I_(t,vh(1,t.center.lat)*t.worldSize),n=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return jr(i,e+n*(1-Math.cos(o)),Math.pow(r,10))}return i}upVector(e,t,i){return zu(t,i,e,1)}upVectorScale(e){return{metersToTile:vu(Du(Su(e)))}}}function Y_(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new q_(e);case"equirectangular":return new V_(e);case"naturalEarth":return new $_(e);case"equalEarth":return new N_(e);case"winkelTripel":return new Q_(e);case"albers":return i?new H_(e):new R_(e);case"lambertConformalConic":return i?new H_(e):new G_(e);case"globe":return new X_(e)}throw new Error(`Invalid projection name: ${e.name}`)}const J_=dp.types,K_=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function eg(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=a?Math.min(w_,Math.round(a[0])):0,f=a?Math.min(w_,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),f,16*c,16*h,256*u,256*d)}function tg(e,t,i){e.emplaceBack(t,i)}function ig(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,s)}function rg(e,t,i,r,n){e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n)}function ng(e){for(const t of e.sections)if(Aa(t.text))return!0;return!1}class og{constructor(e){this.layoutVertexArray=new kl,this.indexArray=new Gl,this.programConfigurations=e,this.segments=new mc,this.dynamicLayoutVertexArray=new Pl,this.opacityVertexArray=new Bl,this.placedSymbolArray=new oc,this.iconTransitioningVertexArray=new Fl,this.globeExtVertexArray=new Ol,this.zOffsetVertexArray=new $l}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,t,i,r,n){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,kf.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Bf.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,K_,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,Nf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Of.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Ff.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}fa(og,"SymbolBuffers");class sg{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new mc,this.collisionVertexArray=new jl,this.collisionVertexArrayExt=new Pl}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Vf.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Uf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}fa(sg,"CollisionBuffers");class ag{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((e=>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=e.a9.identity([]),this.placementViewportMatrix=e.a9.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=$f(this.zoom,i["text-size"]),this.iconSizeData=$f(this.zoom,i["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),o=r.get("symbol-z-order");this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map((e=>Mm[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=r.get("symbol-z-elevate")}createArrays(){this.text=new og(new jc(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new og(new jc(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new lc,this.lineVertexArray=new cc,this.symbolInstances=new ac}calculateGlyphDependencies(e,t,i,r,n){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==h.value.kind||!!h.value.value||Object.keys(h.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!u&&!d)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new Va(this.zoom);for(const{feature:i,id:c,index:h,sourceLayerIndex:y}of t){const t=o._featureFilter.needGeometry,x=Fh(i,t);if(!o._featureFilter.filter(g,x,r))continue;if(t||(x.geometry=Bh(i,r,n)),a&&1!==i.type&&r.z<=5){const t=x.geometry,i=.98078528056,n=(t,n)=>{const o=zu(t.x,t.y,r,1),s=zu(n.x,n.y,r,1);return e.Q.dot(o,s)=0;for(const i of v.sections)if(i.image)f[i.image.namePrimary]=!0;else{const r=va(v.toString()),n=i.fontStack||e,o=m[n]=m[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r)}}}"line"===s.get("symbol-placement")&&(this.features=(function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;ce.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,i,r,n){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,t,s,i,r,n),this.icon.programConfigurations.updatePaintArrays(e,t,s,i,r,n)}updateZOffset(){const e=(e,t,r)=>{i+=t,i>e.length&&e.resize(i);for(let n=-t;n<0;n++)e.emplace(n+i,r)},t=(e,t,i)=>{r+=t,r>e.length&&e.resize(r);for(let n=-t;n<0;n++)e.emplace(n+r,i)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,r=0;for(let i=0;i0;if((n>0||o>0)&&(e(this.text.zOffsetVertexArray,n,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=r;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,r.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Y_(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:i}of t)this.lineVertexArray.emplaceBack(e,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=e.indexArray,g=e.layoutVertexArray,y=e.globeExtVertexArray,x=e.segments.prepareSegment(4*t.length,g,_,this.canOverlap?o.sortKey:void 0),v=this.glyphOffsetArray.length,b=x.vertexLength,w=this.allowVerticalPlacement&&s===Mm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let r=0;r=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=Wf(this.textSizeData,e,n)/qf;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=Wf(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i,r){e.emplaceBack(t,-i,-i,r),e.emplaceBack(t,i,-i,r),e.emplaceBack(t,i,i,r),e.emplaceBack(t,-i,i,r)}_updateTextDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tr[e]-r[t]||n[t]-n[e])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset))}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),r>=0&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}fa(ag,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),ag.addDynamicAttributes=rg;const lg=new Ja({"symbol-placement":new Ha(tl.layout_symbol["symbol-placement"]),"symbol-spacing":new Ha(tl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ha(tl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Xa(tl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ha(tl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ha(tl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Ha(tl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ha(tl.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ha(tl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ha(tl.layout_symbol["icon-rotation-alignment"]),"icon-size":new Xa(tl.layout_symbol["icon-size"]),"icon-text-fit":new Xa(tl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Xa(tl.layout_symbol["icon-text-fit-padding"]),"icon-image":new Xa(tl.layout_symbol["icon-image"]),"icon-rotate":new Xa(tl.layout_symbol["icon-rotate"]),"icon-padding":new Ha(tl.layout_symbol["icon-padding"]),"icon-keep-upright":new Ha(tl.layout_symbol["icon-keep-upright"]),"icon-offset":new Xa(tl.layout_symbol["icon-offset"]),"icon-anchor":new Xa(tl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ha(tl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ha(tl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ha(tl.layout_symbol["text-rotation-alignment"]),"text-field":new Xa(tl.layout_symbol["text-field"]),"text-font":new Xa(tl.layout_symbol["text-font"]),"text-size":new Xa(tl.layout_symbol["text-size"]),"text-max-width":new Xa(tl.layout_symbol["text-max-width"]),"text-line-height":new Xa(tl.layout_symbol["text-line-height"]),"text-letter-spacing":new Xa(tl.layout_symbol["text-letter-spacing"]),"text-justify":new Xa(tl.layout_symbol["text-justify"]),"text-radial-offset":new Xa(tl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ha(tl.layout_symbol["text-variable-anchor"]),"text-anchor":new Xa(tl.layout_symbol["text-anchor"]),"text-max-angle":new Ha(tl.layout_symbol["text-max-angle"]),"text-writing-mode":new Ha(tl.layout_symbol["text-writing-mode"]),"text-rotate":new Xa(tl.layout_symbol["text-rotate"]),"text-padding":new Ha(tl.layout_symbol["text-padding"]),"text-keep-upright":new Ha(tl.layout_symbol["text-keep-upright"]),"text-transform":new Xa(tl.layout_symbol["text-transform"]),"text-offset":new Xa(tl.layout_symbol["text-offset"]),"text-allow-overlap":new Ha(tl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ha(tl.layout_symbol["text-ignore-placement"]),"text-optional":new Ha(tl.layout_symbol["text-optional"]),visibility:new Ha(tl.layout_symbol.visibility)});var cg={paint:new Ja({"icon-opacity":new Xa(tl.paint_symbol["icon-opacity"]),"icon-emissive-strength":new Xa(tl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Xa(tl.paint_symbol["text-emissive-strength"]),"icon-color":new Xa(tl.paint_symbol["icon-color"]),"icon-halo-color":new Xa(tl.paint_symbol["icon-halo-color"]),"icon-halo-width":new Xa(tl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Xa(tl.paint_symbol["icon-halo-blur"]),"icon-translate":new Ha(tl.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ha(tl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Xa(tl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Xa(tl.paint_symbol["text-opacity"]),"text-color":new Xa(tl.paint_symbol["text-color"],{runtimeType:Jr,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Xa(tl.paint_symbol["text-halo-color"]),"text-halo-width":new Xa(tl.paint_symbol["text-halo-width"]),"text-halo-blur":new Xa(tl.paint_symbol["text-halo-blur"]),"text-translate":new Ha(tl.paint_symbol["text-translate"]),"text-translate-anchor":new Ha(tl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ha(tl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ha(tl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ha(tl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ha(tl.paint_symbol["icon-color-brightness-max"])}),layout:lg};class hg{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Qr,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}fa(hg,"FormatSectionOverride",{omit:["defaultValue"]});class ug extends xl{constructor(t,i,r){super(t,cg,i,r),this._colorAdjustmentMatrix=e.a9.identity([])}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(t,i,r,n){return this._saturation===t&&this._contrast===i&&this._brightnessMin===r&&this._brightnessMax===n||(this._colorAdjustmentMatrix=(function(t,i,r,n){t=Ci(t),i=Ii(i);const o=e.a9.create(),s=t/3,a=1-2*s,l=[a,s,s,0,s,a,s,0,s,s,a,0,0,0,0,1],c=.5-.5*i,h=n-r;return e.a9.multiply(o,[h,0,0,0,0,h,0,0,0,0,h,0,r,r,r,1],[i,0,0,0,0,i,0,0,0,0,i,0,c,c,c,1]),e.a9.multiply(o,o,l),o})(t,i,r,n),this._saturation=t,this._contrast=i,this._brightnessMin=r,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||ia(o.value)||!n?n:(function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))})(t.properties,n)}createBucket(e){return new ag(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of cg.paint.overridableProperties){if(!ug.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new hg(t),r=new ta(i,t.property.specification,this.scope,this.options);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new na("source",r):new oa("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Wa(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&ug.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=cg.paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof pn)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{n||(t instanceof xn&&gn(t.value)===rn?o(t.value.sections):t instanceof Tn?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}getProgramIds(){const e=0!==this.paint.get("icon-opacity").constantOr(1),t=0!==this.paint.get("text-opacity").constantOr(1),i=[];return e&&i.push("symbolIcon"),t&&i.push("symbolSDF"),i}getDefaultProgramParams(e,t){return{config:new Uc(this,t),overrideFog:!1}}}const dg=new Ja({visibility:new Ha(tl.layout_background.visibility)});var pg={paint:new Ja({"background-color":new Ha(tl.paint_background["background-color"]),"background-pattern":new Ha(tl.paint_background["background-pattern"]),"background-opacity":new Ha(tl.paint_background["background-opacity"]),"background-emissive-strength":new Ha(tl.paint_background["background-emissive-strength"])}),layout:dg};const fg=new Ja({visibility:new Ha(tl.layout_raster.visibility)});var mg={paint:new Ja({"raster-opacity":new Ha(tl.paint_raster["raster-opacity"]),"raster-color":new Ya(tl.paint_raster["raster-color"]),"raster-color-mix":new Ha(tl.paint_raster["raster-color-mix"]),"raster-color-range":new Ha(tl.paint_raster["raster-color-range"]),"raster-hue-rotate":new Ha(tl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Ha(tl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Ha(tl.paint_raster["raster-brightness-max"]),"raster-saturation":new Ha(tl.paint_raster["raster-saturation"]),"raster-contrast":new Ha(tl.paint_raster["raster-contrast"]),"raster-resampling":new Ha(tl.paint_raster["raster-resampling"]),"raster-fade-duration":new Ha(tl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new Ha(tl.paint_raster["raster-emissive-strength"]),"raster-array-band":new Ha(tl.paint_raster["raster-array-band"]),"raster-elevation":new Ha(tl.paint_raster["raster-elevation"])}),layout:fg},_g=Tl([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class gg{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r)}update(e,t,i){const{width:r,height:n}=e,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!t||!1!==t.premultiply)),i||this.size&&this.size[0]===r&&this.size[1]===n){const{x:t,y:o}=i||{x:0,y:0};if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,t,o,s.RGBA,s.UNSIGNED_BYTE,e);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,t,o,r,n,i,a,e.data)}}else if(this.size=[r,n],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap){let t=this.format;this.format===s.R8&&(t=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,t,s.UNSIGNED_BYTE,e)}else{let t=this.format,i=this.format,o=s.UNSIGNED_BYTE;this.format===s.DEPTH_COMPONENT&&(t=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),s.texImage2D(s.TEXTURE_2D,0,t,r,n,0,i,o,e.data)}this.useMipmap=Boolean(t&&t.useMipmap),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(e,t,i=!1){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.useMipmap&&!i?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t)}bindExtraParam(e,t,i,r){const{context:n}=this,{gl:o}=n;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),r!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapT=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class yg{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:i}=this,{gl:r}=i;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 xg(t,i,r,n,o,s,a,l){const c=[t,i,1,r,n,1,o,s,1],h=[a,l,1],u=e.ct.adjoint([],c),[d,p,f]=e.Q.transformMat3(h,h,u);return e.ct.multiply(c,c,[d,0,0,0,p,0,0,0,f])}function vg(t,i,r,n,o,s,a,l){const c=(function(t,i,r,n,o,s,a,l){const c=xg(0,0,1,0,1,1,0,1),h=xg(t,i,r,n,o,s,a,l),u=e.ct.adjoint([],c);return e.ct.multiply(h,h,u)})(t,i,r,n,o,s,a,l);return[c[2]/c[8]/no,c[5]/c[8]/no]}function bg(e){return[e[0],Math.min(Math.max(e[1],-85.051129),Eh)]}class wg extends kr{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new Rr("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=nr(this.map._requestManager.transformRequest(this.url,Hi.Image),((t,i)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new Lr(t)):i&&(this.image=i instanceof HTMLImageElement?zi.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new yg(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Rr("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof yg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const r of e)r[1]>i&&(i=r[1]),r[1]Eh?this.onNorthPole=!0:r<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(Ch.fromLngLat);this.tileID=(function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);const o=Math.max(r-t,n-i),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);let l=Math.floor((t+r)/2*a);return l>1&&(l-=1),new hh(s,l,Math.floor((i+n)/2*a))})(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Rr("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=C_(new hh(0,0,0),this.map.transform.projection),r=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!(function(e){const t=e[1].x-e[0].x,i=e[1].y-e[0].y,r=e[2].x-e[1].x,n=e[2].y-e[1].y,o=e[3].x-e[2].x,s=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*n-r*i,h=r*s-o*n,u=o*l-a*s,d=a*i-t*l;return c>0&&h>0&&u>0&&d>0||c<0&&h<0&&u<0&&d<0})(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const n=C_(this.tileID,this.map.transform.projection),[o,s,a,l]=this.coordinates.map((e=>{const t=n.projection.project(e[0],e[1]);return P_(n,t)._round()}));this.perspectiveTransform=vg(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Al;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,no,0),c.emplaceBack(l.x,l.y,0,no),c.emplaceBack(a.x,a.y,no,no),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(c,_g.members),this.boundsSegments=mc.simpleSegment(0,0,4,2);const h=[],u=[bg((d=this.coordinates)[0]),bg(d[1]),bg(d[2]),bg(d[3])];var d;const[p,f,m,_]=(function(e){let t=e[0][0],i=t,r=e[0][1],n=r;for(let o=1;oi&&(i=e[o][0]),e[o][1]n&&(n=e[o][1]);return[t,r,i-t,n-r]})(u);{const n=new Al,[o,s,a,l]=(function(e){let t=e[0].x,i=t,r=e[0].y,n=r;for(let o=1;oi&&(i=e[o].x),e[o].yn&&(n=e[o].y);return[t,r,i-t,n-r]})(r),c=e=>[(e.x-o)/a,(e.y-s)/l],[u,d,g,y]=r.map(c),x=(function(t,i,r,n,o,s,a,l){const c=xg(0,0,1,0,1,1,0,1),h=xg(t,i,r,n,o,s,a,l),u=e.ct.adjoint([],h);return e.ct.multiply(c,c,u)})(u[0],u[1],d[0],d[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=vg(u[0],u[1],d[0],d[1],g[0],g[1],y[0],y[1]);const v=(t,i)=>{h.push(t.lng);const r=Math.round((t.lng-p)/m*no),o=Math.round((t.lat-f)/_*no),s=c(i),a=e.Q.transformMat3([],[s[0],s[1],1],x),l=Math.round(a[0]/a[2]*no),u=Math.round(a[1]/a[2]*no);n.emplaceBack(r,o,l,u)},b=r[3].x-r[0].x,w=r[3].y-r[0].y,T=r[2].x-r[1].x,E=r[2].y-r[1].y;for(let e=0;e<65;e++){const t=e/64,n=[r[0].x+t*b,r[0].y+t*w],o=[r[1].x+t*T,r[1].y+t*E],s=o[0]-n[0],a=o[1]-n[1];for(let e=0;e<65;e++){const t=e/64,r={x:n[0]+s*t,y:n[1]+a*t,z:0};v(i.projection.unproject(r.x,r.y),r)}}this.elevatedGlobeVertexBuffer=t.createVertexBuffer(n,_g.members)}{this.maxLongitudeTriangleSize=0;let e=[],i=new Gl;const r=(t,r,n)=>{i.emplaceBack(t,r,n);const o=h[t],s=h[r],a=h[n],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),e.push(l+c/2)};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const i=65*e+t,n=i+1,o=i+65,s=o+1;r(i,o,n),r(n,o,s)}[e,i]=(function(e,t){const i=Array.from({length:e.length},((e,t)=>t));i.sort(((t,i)=>e[t]-e[i]));const r=[],n=new Gl;for(let o=0;oe+360*Math.round((t-e)/360))(e+180,i[0]);const n=new mc,o=(e,i)=>{n.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},s=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-r)<=s){const e=Ai(i,0,i.length,r+s);return e===i.length||o(e,Mi(i,e+1,i.length,r+360-s)-e),n}r0){const r=(function(t,i){const r=i.worldSize,n=vh(1,0)*r*Mh(i.center.lat,i.zoom)/Ou(r),o=vh(1,i.center.lat)*r,s=e.a9.identity([]);return e.a9.rotateY(s,s,Gt(i.center.lng)),e.a9.rotateX(s,s,Gt(i.center.lat)),e.a9.translate(s,s,[0,0,Qc]),e.a9.scale(s,s,[n,n,n*o]),e.a9.translate(s,s,[i.point.x-.5*r,i.point.y-.5*r,0]),e.a9.multiply(s,s,t),e.a9.multiply(s,i.globeMatrix,s)})(t,i);return(function(t,i,r){const n=(t,i,r)=>{const n=e.Q.length(t),o=e.Q.length(i),s=Mu(t,i,r);return e.Q.scale(s,s,1/e.Q.length(s)*jr(n,o,r))},o=n([t[0],t[1],t[2]],[i[0],i[1],i[2]],r),s=n([t[4],t[5],t[6]],[i[4],i[5],i[6]],r),a=n([t[8],t[9],t[10]],[i[8],i[9],i[10]],r),l=Mu([t[12],t[13],t[14]],[i[12],i[13],i[14]],r);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]})(o,r,n)}return o}function jg(e,t,i,r){const n=mu.projectAabbCorners(r,i);let o=Number.MAX_VALUE,s=-1;for(let e=0;enew Vt(n[e][0],n[e][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(jh(e,l))return o}const Gg=Tl([{name:"a_pos_3f",components:3,type:"Float32"}]),qg=Tl([{name:"a_color_3f",components:3,type:"Float32"}]),Zg=Tl([{name:"a_color_4f",components:4,type:"Float32"}]),$g=Tl([{name:"a_uv_2f",components:2,type:"Float32"}]),Wg=Tl([{name:"a_normal_3f",components:3,type:"Float32"}]),Qg=Tl([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Hg=Tl([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Xg{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function Yg(e,t){const i=-1===e.indexOf("://");try{return new URL(e,i&&t?"http://example.com":void 0),!0}catch(e){return!1}}class Jg{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class Kg{constructor(){this.instancedDataArray=new Jl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class ey{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?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}populate(e,t,i,r){this.tileToMeter=Ih(i);const n=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Fh(o,n);if(!this.layers[0]._featureFilter.filter(new Va(this.zoom),c,i))continue;const h={id:e,sourceLayerIndex:l,index:a,geometry:n?c.geometry:Bh(o,i,r),properties:o.properties,type:o.type,patterns:{}},u=this.addFeature(h,h.geometry,c);u&&t.featureIndex.insert(o,h.geometry,a,l,this.index,this.instancesPerModel[u].instancedDataArray.length,256)}this.lookup=null}update(e,t,i,r){for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t in e)i.idToFeaturesIndex.hasOwnProperty(t)&&(this.evaluate(i.features[i.idToFeaturesIndex[t]],e[t],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const i in this.instancesPerModel){const r=this.instancesPerModel[i];for(const i of r.features){const n=this.layers[0],o=i.feature,s=this.canonical,a=n.paint.get("model-rotation").evaluate(o,{},s),l=n.paint.get("model-scale").evaluate(o,{},s),c=n.paint.get("model-translation").evaluate(o,{},s);e.Q.exactEquals(i.rotation,a)&&e.Q.exactEquals(i.scale,l)&&e.Q.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,r,!0),t=!0)}}return t}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];i.instancedDataArray.length<0||0===i.instancedDataArray.length||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,Qg.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}const e=this.layers[0].modelManager;if(e&&this.modelUris)for(const t of this.modelUris)e.removeModel(t,"")}addFeature(e,t,i){const r=this.layers[0],n=r.layout.get("model-id").evaluate(i,{},this.canonical);if(!n)return ui(`modelId is not evaluated for layer ${r.id} and it is not going to get rendered.`),n;Yg(n,!1)&&(this.modelUris.includes(n)||this.modelUris.push(n)),this.instancesPerModel[n]||(this.instancesPerModel[n]=new Kg);const o=this.instancesPerModel[n],s=o.instancedDataArray,a=new Jg(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=no||t.y<0||t.y>=no)continue;const e=(this.lookupDim-1)/no,i=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const r=s.length;s.resize(r+1),o.instancesEvaluatedElevation.push(0),s.float32[16*r]=t.x,s.float32[16*r+1]=t.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),n}getModelUris(){return this.modelUris}evaluate(e,t,i,r){const n=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=n.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=n.paint.get("model-scale").evaluate(o,t,s),c=e.translation=n.paint.get("model-translation").evaluate(o,t,s),h=n.paint.get("model-color").evaluate(o,t,s);h.a=n.paint.get("model-color-mix-intensity").evaluate(o,t,s);const u=[];this.maxVerticalOffset10?this.tileToMeter:Ih(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[n]=c[2]}}}fa(ey,"ModelBucket",{omit:["layers"]}),fa(Kg,"PerModelAttributes"),fa(Jg,"ModelFeature");const ty=new Ja({visibility:new Ha(tl.layout_model.visibility),"model-id":new Xa(tl.layout_model["model-id"])});var iy={paint:new Ja({"model-opacity":new Ha(tl.paint_model["model-opacity"]),"model-rotation":new Xa(tl.paint_model["model-rotation"]),"model-scale":new Xa(tl.paint_model["model-scale"]),"model-translation":new Xa(tl.paint_model["model-translation"]),"model-color":new Xa(tl.paint_model["model-color"]),"model-color-mix-intensity":new Xa(tl.paint_model["model-color-mix-intensity"]),"model-type":new Ha(tl.paint_model["model-type"]),"model-cast-shadows":new Ha(tl.paint_model["model-cast-shadows"]),"model-receive-shadows":new Ha(tl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new Ha(tl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Xa(tl.paint_model["model-emissive-strength"]),"model-roughness":new Xa(tl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Xa(tl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new Ha(tl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new Ha(tl.paint_model["model-front-cutoff"])}),layout:ty};const ry=64,ny={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function oy(t,i,r,n,o,s,a,l,c,h=!1){const u=r.zoom,d=r.project(n),p=Mh(n.lat,u),f=1/p;e.a9.identity(t),e.a9.translate(t,t,[d.x+a[0]*f,d.y+a[1]*f,a[2]]);let m=1,_=1;const g=r.worldSize;if(h){if("mercator"===r.projection.name){let t=0;r.elevation&&(t=r.elevation.getAtPointOrZero(new Ch(d.x/g,d.y/g),0));const i=e.aa.transformMat4([],[d.x,d.y,t,1],r.projMatrix)[3]/r.cameraToCenterDistance;m=i,_=i*Mh(r.center.lat,u)}else if("globe"===r.projection.name){const i=Ug(t,r),o=e.a9.multiply([],r.projMatrix,i),s=[0,0,0,1];e.aa.transformMat4(s,s,o);const a=s[3]/r.cameraToCenterDistance,l=Nu(u),c=r.projection.pixelsPerMeter(n.lat,g)*Mh(n.lat,u),h=r.projection.pixelsPerMeter(r.center.lat,g)*Mh(r.center.lat,u);m=a/jr(c,Sh(r.center.lat),l),_=a*p/c,m*=h,_*=h}}else m=f;e.a9.scale(t,t,[m,m,_]);const y=[...t],x=i.orientation,v=[];if(Ng(v,[x[0]+o[0],x[1]+o[1],x[2]+o[2]],s),e.a9.multiply(t,y,v),l&&r.elevation){let o=0;const s=[];if(c&&r.elevation){o=(function(t,i,r,n,o){const s=i.elevation;if(!s)return 0;const a=mu.projectAabbCorners(r,n),l=vh(1,o.lat)*i.worldSize,c=(function(t,i){const r=[0,0,1],n=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of n){const n=t[o.corners[0]],s=t[o.corners[1]],a=t[o.corners[2]],l=[s[0]-n[0],s[1]-n[1],i*(s[2]-n[2])],c=e.Q.cross(l,l,[a[0]-n[0],a[1]-n[1],i*(a[2]-n[2])]);e.Q.normalize(c,c),o.dotProductWithUp=e.Q.dot(c,r)}return n.sort(((e,t)=>e.dotProductWithUp-t.dotProductWithUp)),n[0].corners})(a,l),h=a[c[0]],u=a[c[1]],d=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new Ch(h[0]/i.worldSize,h[1]/i.worldSize),0),m=s.getAtPointOrZero(new Ch(u[0]/i.worldSize,u[1]/i.worldSize),0),_=s.getAtPointOrZero(new Ch(d[0]/i.worldSize,d[1]/i.worldSize),0),g=s.getAtPointOrZero(new Ch(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,x=(m+_)/2;return y>x?m<_?Vg(t,u,p,h,m,g,f,l):Vg(t,d,h,p,_,f,g,l):f=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function ay(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Gg.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Wg.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,$g.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?qg:Zg).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Hg.members,!0)),e.segments=mc.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&sy(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&sy(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&sy(r.normalTexture,t),r.occlusionTexture&&sy(r.occlusionTexture,t,i),r.emissionTexture&&sy(r.emissionTexture,t)}function ly(e,t,i){if(e.meshes)for(const r of e.meshes)ay(r,t,i);if(e.children)for(const r of e.children)ly(r,t,i)}function cy(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)cy(t)}function hy(e){if(e.meshes)for(const i of e.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((t=i.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));var t;if(e.children)for(const t of e.children)hy(t)}class uy{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class dy{constructor(){this.tasks={},this.taskQueue=[],oi(["process"],this),this.invoker=new uy(this.process),this.nextId=0}add(e,t){const i=this.nextId++,r=(function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i})(t);if(0===r){mi();try{e()}finally{}return null}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){mi();try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||mi()){const e=this.callbacks[i],r=this.scheduler.add((()=>this.processTask(i,t)),e&&e.metadata||{type:"message"});r&&(this.cancelCallbacks[i]=r)}else this.processTask(i,t)}processTask(e,t){if(delete this.cancelCallbacks[e],""===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(ya(t.error)):i(null,ya(t.data)))}else{const i=new Set,r=t.hasCallback?(t,r)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?ga(t):null,data:ga(r,i)},i)}:e=>{},n=ya(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],n.source,n.scope)[e[1]](n,r)}else r(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class fy{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=ti();const i=this.workerPool.acquire(this.id);for(let e=0;e{this.ready=!0}))}broadcast(e,t,i){Jt(this.actors,((i,r)=>{i.send(e,t,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove()})),this.actors=[],this.workerPool.release(this.id)}}fy.Actor=py;var my={workerUrl:"",workerClass:null,workerParams:void 0};function _y(){return null!=my.workerClass?new my.workerClass:new self.Worker(my.workerUrl,my.workerParams)}const gy="mapboxgl_preloaded_worker_pool";class yy{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[gy]}numActive(){return Object.keys(this.active).length}}let xy;function vy(){return xy||(xy=new yy),xy}yy.workerCount=2;let by,wy,Ty,Ey,Sy,My=null;function Ay(){return mi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:wy||r.DRACO_URL}function Iy(){if(mi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(Ey)return Ey;const e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return Ey=WebAssembly.validate(e)?r.MESHOPT_SIMD_URL:r.MESHOPT_URL,Ey}const Cy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Py={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},zy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Dy(e,t,i){const r=i.json.bufferViews.length,n=i.buffers.length;t.bufferView=r,i.json.bufferViews[r]={buffer:n,byteLength:e.byteLength},i.buffers[n]=e}const Ry="KHR_draco_mesh_compression";function Ly(e,t){const i=e.extensions&&e.extensions[Ry];if(!i)return;const r=new Ty.Decoder,n=Uy(t,i.bufferView),o=new Ty.Mesh;if(!r.DecodeArrayToMesh(n,n.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=t.json.accessors[e.indices],a=Cy[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=Ty._malloc(l);a===Uint16Array?r.GetTrianglesUInt16Array(o,l,c):r.GetTrianglesUInt32Array(o,l,c),Dy(Ty.memory.buffer.slice(c,c+l),s,t),Ty._free(c);for(const n of Object.keys(i.attributes)){const s=r.GetAttributeByUniqueId(o,i.attributes[n]),a=t.json.accessors[e.attributes[n]],l=Py[a.componentType],c=a.count*zy[a.type]*Cy[a.componentType].BYTES_PER_ELEMENT,h=Ty._malloc(c);r.GetAttributeDataArrayForAllPoints(o,s,Ty[l],c,h),Dy(Ty.memory.buffer.slice(h,h+c),a,t),Ty._free(h)}r.destroy(),o.destroy(),delete e.extensions[Ry]}const ky="EXT_meshopt_compression";function Oy(e,t){if(!e.extensions||!e.extensions[ky])return;const i=e.extensions[ky],r=new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),n=new Uint8Array(i.count*i.byteStride);Sy.decodeGltfBuffer(n,i.count,i.byteStride,r,i.mode,i.filter),e.buffer=t.buffers.length,e.byteOffset=0,t.buffers[e.buffer]=n.buffer,delete e.extensions[ky]}const By=1179937895,Fy=new TextDecoder("utf8");function Ny(e,t){return new URL(e,t).href}function Vy(e,t,i,r){return fetch(Ny(e.uri,r)).then((e=>e.arrayBuffer())).then((e=>{t.buffers[i]=e}))}function Uy(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function jy(e,t,i,r){if(e.uri){const n=Ny(e.uri,r);return fetch(n).then((e=>e.blob())).then((e=>createImageBitmap(e))).then((e=>{t.images[i]=e}))}if(void 0!==e.bufferView){const r=Uy(t,e.bufferView),n=new Blob([r],{type:e.mimeType});return createImageBitmap(n).then((e=>{t.images[i]=e}))}}function Gy(e,t=0,i){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===By){const i=new Uint32Array(e,t);let n=2;const o=(i[n++]>>2)-3,s=i[n++]>>2;if(n++,r.json=JSON.parse(Fy.decode(i.subarray(n,n+s))),n+=s,n{const e=[],t=a&&a.includes(Ry),n=a&&a.includes(ky);if(t&&e.push((function(){if(!Ty)return by||(by=(function(e){let t,i=null;function r(){t=new Uint8Array(i.buffer)}function n(){throw new Error("Unexpected Draco error.")}const o={a:{a:n,d:function(e,i,r){return t.copyWithin(e,i,i+r)},c:function(e){const n=t.length,o=Math.max(e>>>0,Math.ceil(1.2*n)),s=Math.ceil((o-n)/65536);try{return i.grow(s),r(),!0}catch(e){return!1}},b:n}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,o)))).then((e=>{const{Rb:n,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:x,Ab:v,Bb:b,Db:w,Gb:T}=e.instance.exports;i=g;const E=(()=>{let e=0,i=0,r=0,s=0;return a=>{r&&(n(s),n(e),i+=r,r=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(r=l,c=s=o(l));for(let e=0;e{Ty=e,by=void 0})))})()),n&&e.push((function(){if(Sy)return;const e=(function(e){let t;const i=WebAssembly.instantiateStreaming(e,{}).then((e=>{t=e.instance,t.exports.__wasm_call_ctors()})),r={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},n={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(e,i,o,s,a,l){!(function(e,t,i,r,n,o,s){const a=e.exports.sbrk,l=r+3&-4,c=a(l*n),h=a(o.length),u=new Uint8Array(e.exports.memory.buffer);u.set(o,h);const d=t(c,r,n,h,o.length);if(0===d&&s&&s(c,l,n),i.set(u.subarray(c,c+r*n)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)})(t,t.exports[n[a]],e,i,o,s,t.exports[r[l]])}}})(fetch(Iy()));return e.ready.then((()=>{Sy=e}))})()),o)for(let t=0;t{if(t&&s)for(const{primitives:e}of s)for(const t of e)Ly(t,r);if(n&&s&&l)for(const e of l)Oy(e,r);return r}))}))}class qy{constructor(e,t,i,r){if(this.triangleCount=t.length/3,this.min=new Vt(0,0),this.max=new Vt(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[n,o]=[e[0].clone(),e[0].clone()];for(let t=1;te.cellIdx-t.cellIdx||e.triIdx-t.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let e=0;e0){for(let n=0;n0){o.texcoordArray=new zl;const e=t.json.accessors[n.TEXCOORD_0];o.texcoordArray.resize(e.count);const i=$y(t,e);Wy(t,e,o.texcoordArray,i)}if(void 0!==n._FEATURE_ID_RGBA4444){const e=t.json.accessors[n._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$y(t,e))}void 0!==n._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($y(t,t.json.accessors[n._FEATURE_RGBA4444]).buffer));const u=e.material;return o.material=(function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:r="OPAQUE",alphaCutoff:n=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=e.pbrMetallicRoughness||{},f=s?t[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const e=s.extensions.KHR_texture_transform;f.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Ur(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?t[d.index]:void 0,metallicRoughnessTexture:p?t[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:r,alphaCutoff:n,normalTexture:o?t[o.index]:void 0,occlusionTexture:f,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}})(void 0!==u?t.json.materials[u]:{defined:!1},i),o}function Hy(t,i,r){const{matrix:n,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:h}=t,u={};if(u.matrix=n||e.a9.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){u.meshes=r[l];const e=u.anchor=[0,0];for(const t of u.meshes){const{min:i,max:r}=t.aabb;e[0]+=i[0]+r[0],e[1]+=i[1]+r[1]}e[0]=Math.floor(e[0]/u.meshes.length/2),e[1]=Math.floor(e[1]/u.meshes.length/2)}if(c&&(c.id&&(u.id=c.id),c.lights&&(u.lights=(function(e){if(!e.length)return[];const t=(function(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e1&&r[r.length-1].equals(r[0])&&r.pop();let n=0;for(let e=0;e0&&r.reverse();const o=Nd(r.flatMap((e=>[e.x,e.y])),[]);return 0===o.length?null:{vertices:r,indices:o}}function Jy(t,i){const r=[],n=[];let o=0;const s=[];for(const a of t){o=r.length;const t=a.vertexArray.float32,l=a.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]])}return{vertices:r,indices:n}}function Ky(e){const t=(function(e,t){const i=[],r=WebGL2RenderingContext;if(e.json.textures)for(const n of e.json.textures){const o={magFilter:r.LINEAR,minFilter:r.NEAREST,wrapS:r.REPEAT,wrapT:r.REPEAT};void 0!==n.sampler&&Object.assign(o,e.json.samplers[n.sampler]),i.push({image:t[n.source],sampler:o,uploaded:!1})}return i})(e,e.images),i=(function(e,t){const i=[];for(const r of e.json.meshes){const n=[];for(const i of r.primitives)n.push(Qy(i,e,t));i.push(n)}return i})(e,t),{scenes:r,scene:n,nodes:o}=e.json,s=r?r[n||0].nodes:o,a=[];for(const t of s)a.push(Hy(o[t],e,i));return(function(e,t,i){const r={},n=new Set;for(let o=0;o0){const t=Array.from(n.values()).sort(((e,t)=>e-t));for(let i=t.length-1;i>=0;i--)e.splice(t[i],1)}})(a,s,e.json.nodes),a}function ex(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,r=e.aabb.min[1]-1,n=ry/(e.aabb.max[0]-i+2),o=ry/(e.aabb.max[1]-r+2);for(let s=0;se.heightmap[c*ry+l]&&(e.heightmap[c*ry+l]=a)}}function tx(t,i){const r={};r.indexArray=new Gl,r.indexArray.reserve(4*t.length),r.vertexArray=new Yl,r.vertexArray.reserve(10*t.length),r.colorArray=new Pl,r.vertexArray.reserve(10*t.length);let n=0;for(const o of t){const t=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=e.Q.scaleAndAdd([],o.pos,s,l/2),h=e.Q.scaleAndAdd([],o.pos,s,-l/2),u=[c[0],c[1],c[2]+o.height],d=[h[0],h[1],h[2]+o.height],p=e.Q.scaleAndAdd([],o.normal,s,a);e.Q.scale(p,p,t);const f=e.Q.scaleAndAdd([],o.normal,s,-a);e.Q.scale(f,f,t),e.Q.add(p,c,p),e.Q.add(f,h,f),c[2]+=.1,h[2]+=.1,r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/t/2;r.colorArray.emplaceBack(-m-a,-1,m,.8),r.colorArray.emplaceBack(m+a,-1,m,.8),r.colorArray.emplaceBack(-m,0,m,1.3),r.colorArray.emplaceBack(m,0,m,1.3),r.colorArray.emplaceBack(m+a,-.8,m,.7),r.colorArray.emplaceBack(m+a,-.8,m,.7),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(m+a,-1.2,m,.8),r.colorArray.emplaceBack(m+a,-1.2,m,.8),r.indexArray.emplaceBack(6+n,4+n,8+n),r.indexArray.emplaceBack(7+n,9+n,5+n),r.indexArray.emplaceBack(0+n,1+n,2+n),r.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Ur.white,o.pbrMetallicRoughness=s,r.material=o,r.aabb=new mu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}fa(qy,"TriangleGridIndex");class ix{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=0&&r[3]>=0&&l.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new up(new wm(this.rawTileData)).layers,this.sourceLayerCoder=new ix(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,i,r){this.loadVTLayers();const n=e.params||{},o=rl(n.filter),s=e.tileResult,a=e.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((e,t,i,r)=>Jh(s.bufferedTilespaceGeometry,e,t,i,r)));c.sort(ax);let h=null;a.elevation&&c.length>0&&(h=Rp.create(a.elevation,this.tileID));const u={};let d;for(let l=0;l(m||(m=Bh(t,this.tileID.canonical,e.tileTransform)),i.queryIntersectsFeature(s,t,r,m,this.z,e.transform,e.pixelPosMatrix,h,n))))}return u}loadMatchingFeature(e,t,i,r,n,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=t,p=this.bucketLayerIDs[h];if(r&&!(function(e,t){for(let i=0;i=0)return!0;return!1})(r,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const e=Fh(m,!0);if(!i.filter(new Va(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new Va(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let t=0;t{const s=t instanceof Qa?t.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s}))}function ax(e,t){return t-e}fa(ox,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const lx=new Float32Array(262144),cx=new Uint8Array(262144);function hx(e){let t=0;if(e.meshes)for(const i of e.meshes)t=Math.max(t,i.aabb.max[2]);if(e.children)for(const i of e.children)t=Math.max(t,hx(i));return t}function ux(e,t,i){if(e.meshes)for(const r of e.meshes)r.aabb.min[0]!==1/0&&i.insert(t,r.aabb.min[0],r.aabb.min[1],r.aabb.max[0],r.aabb.max[1]);if(e.children)for(const r of e.children)ux(r,t,i)}const dx=["","wall","door","roof","window","lamp","logo"];class px{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:e.id,geometry:[],properties:{height:hx(e)}}}getLocalBounds(){if(!this.node.meshes)return new mu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new mu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==e&&t.encapsulate(i.aabb),e++;this.aabb=mu.applyTransform(t,this.node.matrix)}return this.aabb}}class fx{constructor(e,t,i,r,n,o){this.id=t,this.modelTraits|=ny.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=ny.HasMapboxMeshFeatures),r&&(this.modelTraits|=ny.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=n,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const t of e)this.nodesInfo.push(new px(t)),ux(t,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const i of t){const t=i.node;this.uploaded?this.updatePbrBuffer(t):ly(t,e,!0)}for(const e of t)cy(e.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);return t}needsReEvaluation(e,t,i){const r=e.transform.projectionOptions,n=e.style.getBrightness(),o=this.brightness!==n;return!!(!this.uploaded||this.dirty||r.name!==this.projection.name||mx(i.paint.get("model-color").value,o)||mx(i.paint.get("model-color-mix-intensity").value,o)||mx(i.paint.get("model-roughness").value,o)||mx(i.paint.get("model-emissive-strength").value,o)||mx(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=r,this.brightness=n,!0)}evaluateScale(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),r=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},r)}}evaluate(e){const t=this.getNodesInfo();for(const i of t){if(!i.node.meshes)continue;const t=i.feature,r=i.node.meshes&&i.node.meshes[0].featureData,n=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,r){for(let r=0;r=e)continue;const u=lx[c],d=Math.abs(u);d>a&&(s=u,a=d,l=n,h=t)}if(a>.1){const o=1-(e+.5*Math.abs(l*h))/c;let a=t._dem.get(r,i)+s*o;const u=t._dem.get(r+l,i+h),d=t._dem.get(r-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),lx[n]=t._dem.set(r,i,a),cx[n]=e}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=zi.now())}getNodesInfo(){return this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)cy(t.node),hy(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped()),r=this.getNodesInfo();for(let e=0;ee.footprint===t.footprint))}}getHeightAtTileCoord(t,i){const r=this.getNodesInfo(),n=[],o=[0,0,0];for(let s=0;sc.max[0]||i>c.max[1])continue;const h=(t-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*ry|0,u=Math.min(63,(i-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*ry|0)*ry+Math.min(63,h);if(o[2]=l.heightmap[u],e.Q.transformMat4(o,o,a.node.matrix),!(l.heightmap[u]<0&&a.node.footprint)){if(a.hiddenByReplacement)return;return{height:o[2],maxHeight:a.feature.properties.height,hidden:!1,verticalScale:a.evaluatedScale[2]}}if(a.node.footprint.grid.query(new Vt(t,i),new Vt(t,i),n),n.length>0)return{height:void 0,maxHeight:a.feature.properties.height,hidden:a.hiddenByReplacement,verticalScale:a.evaluatedScale[2]}}}}function mx(e,t){return!e.isLightConstant&&t}function _x(e,t,i,r,n,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,h=240&t|(240&t)>>4;i[3]>0&&(l=jr(l,255*i[0],i[3]),c=jr(c,255*i[1],i[3]),h=jr(h,255*i[2],i[3]));const u=l<<8|c,d=h<<8|Math.floor(255*r[3]),p=(function(e){const t=Ht(e,0,2);return Math.min(Math.round(.5*t*255),255)})(r[2])<<8|15*r[0]<<4|15*r[1],f=Ht(n[0],0,1),m=Ht(n[1],0,1),_=Ht(n[2],0,1),g=Ht(n[3],0,1);let y,x,v,b;if(f!==m&&s!==o&&m!==f){const e=s-o;x=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=Ht(n[4],-1,1);b=Math.pow(10,t),y=255*_<<8|255*g}else y=65535,x=0,v=1,b=1;if(e.emplaceBack(u,d,p,y,x,v,b),a){const e=a.length;a.clear();for(let t=0;t>16&65535,a=o?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,c=e.evaluatedRMEA[l],h=e.evaluatedColor[l],u=e.emissionHeightBasedParams[l];let d;if(s&&2===l&&r.lights&&(d=new Kl,d.resize(10*r.lights.length)),_x(i.featureArray,n,h,c,u,i.aabb.min[2],i.aabb.max[2],d),d&&s){s=!1;const e=r.meshes[r.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}i.featureArray._trim(),n++}}function yx(e,t,i,r){const n=1<e.polygon)).flat());const g=f?l:null,[y,x]=(function(t,i,r,n,o,s,a,l,c,h,u){return"globe"===t.projection.name?(function(t,i,r,n,o,s,a,l,c,h,u){const d=[],p=[],f=t.projection.upVectorScale(u,t.center.lat,t.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(e,t,i,r)=>{e[0]=t,e[1]=i,e[2]=r,e[3]=1},y=sf();r>0&&(r+=y),n+=y;for(const y of i){const i=[],x=[];for(const d of y){const p=d.x+o.x,y=d.y+o.y,v=t.projection.projectTilePoint(p,y,u),b=t.projection.upVector(u,d.x,d.y);let w=r,T=n;if(a){const e=ff(p,y,r,n,a,l,c,h);w+=e.base,T+=e.top}0!==r?g(m,v.x+b[0]*f*w,v.y+b[1]*f*w,v.z+b[2]*f*w):g(m,v.x,v.y,v.z),g(_,v.x+b[0]*f*T,v.y+b[1]*f*T,v.z+b[2]*f*T),e.Q.transformMat4(m,m,s),e.Q.transformMat4(_,_,s),i.push(new uf(m[0],m[1],m[2])),x.push(new uf(_[0],_[1],_[2]))}d.push(i),p.push(x)}return[d,p]})(t,i,r,n,o,s,a,l,c,h,u):a?(function(t,i,r,n,o,s,a,l,c){const h=[],u=[],d=[0,0,0,1];for(const p of t){const t=[],f=[];for(const h of p){const u=h.x+n.x,p=h.y+n.y,m=ff(u,p,i,r,s,a,l,c);d[0]=u,d[1]=p,d[2]=m.base,d[3]=1,e.aa.transformMat4(d,d,o),d[3]=Math.max(d[3],1e-5);const _=new uf(d[0]/d[3],d[1]/d[3],d[2]/d[3]);d[0]=u,d[1]=p,d[2]=m.top,d[3]=1,e.aa.transformMat4(d,d,o),d[3]=Math.max(d[3],1e-5);const g=new uf(d[0]/d[3],d[1]/d[3],d[2]/d[3]);t.push(_),f.push(g)}h.push(t),u.push(f)}return[h,u]})(i,r,n,o,s,a,l,c,h):(function(e,t,i,r,n){const o=[],s=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,h=n[11]*t,u=n[8]*i,d=n[9]*i,p=n[10]*i,f=n[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+r.x,s=o.y+r.y,m=n[0]*t+n[4]*s+n[12],_=n[1]*t+n[5]*s+n[13],g=n[2]*t+n[6]*s+n[14],y=n[3]*t+n[7]*s+n[15],x=m+a,v=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,E=_+d,S=g+p,M=Math.max(y+f,1e-5);e.push(new uf(x/w,v/w,b/w)),i.push(new uf(T/M,E/M,S/M))}o.push(e),s.push(i)}return[o,s]})(i,r,n,o,s)})(s,n,d,u,h,a,g,p,m,s.center.lat,t.tileID.canonical),v=t.queryGeometry;return(function(e,t,i){let r=1/0;qh(i,t)&&(r=pf(i,t[0]));for(let n=0;n=3)for(let t=0;t>1,u=-7,h=i?n-1:0,d=i?-1:1,p=e[t+h];for(h+=d,o=p&(1<<-u)-1,p>>=-u,u+=a;u>0;o=256*o+e[t+h],h+=d,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=r;u>0;s=256*s+e[t+h],h+=d,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},write:function(e,t,i,r,n,o){var s,a,l,c=8*o-n-1,u=(1<>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*l-1)*Math.pow(2,n),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;e[i+p]=255&a,p+=f,a/=256,n-=8);for(s=s<0;e[i+p]=255&s,p+=f,s/=256,c-=8);e[i+p-f]|=128*m}},lm=um,cm=am;function um(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}um.Varint=0,um.Fixed64=1,um.Bytes=2,um.Fixed32=5;var hm=4294967296,dm=2.3283064365386963e-10,pm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function fm(e){return e.type===um.Bytes?e.readVarint()+e.pos:e.pos+1}function mm(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function _m(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function gm(e,t){for(var i=0;i>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function Am(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}um.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Mm(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Am(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Mm(this.buf,this.pos)+Mm(this.buf,this.pos+4)*hm;return this.pos+=8,e},readSFixed64:function(){var e=Mm(this.buf,this.pos)+Am(this.buf,this.pos+4)*hm;return this.pos+=8,e},readFloat:function(){var e=cm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=cm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:(function(e,t,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return mm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return mm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return mm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return mm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return mm(e,r,t);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return mm(e,r,t);throw new Error("Expected varint not more than 10 bytes")})(t|=(15&(i=r[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&&pm?(function(e,t,i){return pm.decode(e.subarray(t,i))})(this.buf,t,e):(function(e,t,i){for(var r="",n=t;n239?4:l>223?3:l>191?2:1;if(n+u>i)break;1===u?l<128&&(c=l):2===u?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(s=e[n+2],128==(192&(o=e[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(s=e[n+2],a=e[n+3],128==(192&(o=e[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=u}return r})(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,t){if(this.type!==um.Bytes)return e.push(this.readVarint(t));var i=fm(this);for(e=e||[];this.pos127;);else if(t===um.Bytes)this.pos=this.readVarint()+this.pos;else if(t===um.Fixed32)this.pos+=4;else{if(t!==um.Fixed64)throw new Error("Unimplemented type: "+t);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 i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),(function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)})(i,0,t),(function(e,t){var i=(7&e)<<4;t.buf[t.pos++]|=i|((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)))))})(r,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,i){for(var r,n,o=0;o55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i})(this.buf,e,this.pos);var i=this.pos-t;i>=128&&_m(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),cm.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),cm.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i=128&&_m(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,i){this.writeTag(e,um.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,gm,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,ym,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,bm,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,xm,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,vm,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,wm,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Tm,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Em,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Sm,t)},writeBytesField:function(e,t){this.writeTag(e,um.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,um.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,um.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,um.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,um.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,um.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,um.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,um.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,um.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,um.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var Cm=d(lm);const Pm=["id","tile","layer","source","sourceLayer","state"];class zm{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=r,this.properties=e.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const t of Pm)void 0!==this[t]&&(e[t]=this[t]);return e}}class Dm{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},ti(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])i[t]||(this.deletedStates[e][r][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){const i=String(t),r=ti({},(this.state[e]||{})[i],(this.stateChanges[e]||{})[i]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const i=this.deletedStates[e][t];if(null===i)return{};for(const e in i)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),ti(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else if(this.state[e][i])for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i]}i[e]=i[e]||{},ti(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in e)e[r].setFeatureState(i,t)}}class Lm{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ya(co,16,0),this.featureIndexArray=new gc,this.promoteId=t,this.is3DTile=!1}insert(e,t,i,r,n,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const l=this.grid;for(let e=0;e=0&&r[3]>=0&&l.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new vp(new Cm(this.rawTileData)).layers,this.sourceLayerCoder=new sm(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,i,r){this.loadVTLayers();const n=e.params||{},o=cl(n.filter),s=e.tileResult,a=e.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((e,t,i,r)=>nh(s.bufferedTilespaceGeometry,e,t,i,r)));c.sort(km);let u=null;a.elevation&&c.length>0&&(u=Xp.create(a.elevation,this.tileID));const h={};let d;for(let l=0;l(m||(m=Gu(t,this.tileID.canonical,e.tileTransform)),i.queryIntersectsFeature(s,t,r,m,this.z,e.transform,e.pixelPosMatrix,u,n))))}return h}loadMatchingFeature(e,t,i,r,n,o,s,a,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:d}=t,p=this.bucketLayerIDs[u];if(r&&!(function(e,t){for(let i=0;i=0)return!0;return!1})(r,p))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(i.needGeometry){const e=qu(m,!0);if(!i.filter(new $a(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new $a(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let t=0;t{const s=t instanceof el?t.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s}))}function km(e,t){return t-e}va(Lm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});var Om=24;const Bm=128;function Fm(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new $a(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n{e.text=(function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Za.applyArabicShaping&&(e=Za.applyArabicShaping(e)),e})(e.text,t,i)})),e}const Gm={"!":"\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 qm(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 Zm(e){return"\ufe35"===e||"\ufe47"===e||"\ufe37"===e||"\ufe43"===e||"\ufe41"===e||"\ufe3d"===e||"\ufe3b"===e||"\ufe39"===e||"\ufe17"===e||"\ufe3f"===e}function $m(e,t,i){t.glyphs=[],1===e&&i.readMessage(Wm,t)}function Wm(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Hm,{});t.glyphs.push({id:e,bitmap:new cd({width:n+6,height:o+6},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function Hm(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}const Xm={horizontal:1,vertical:2,horizontalOnly:3};class Ym{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const i=new Ym;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new Ym;return t.imageName=e,t}}class Km{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const i=new Km;for(let r=0;r=0&&i>=e&&Qm[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const i=new Km;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Ym.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Jm(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f){const m=Km.fromFeature(e,n);h===Xm.vertical&&m.verticalizePunctuation(d);let _=[];const g=(function(e,t,i,r,n,o){if(!e)return[];const s=[],a=(function(e,t,i,r,n,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(E=e[m]);const r=t[a.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(x=o.metrics,M=8203!==m?Om:0,_){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,i=(e+t)*g;w-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;ar;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=t.dist(i)}return!0}function d_(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=Gr(r.x,n.x,u),d=Gr(r.y,n.y,u),p=new u_(h,d,0,n.angleTo(r),i);return!s||h_(e,p,a,s,t)?p:void 0}l+=o}}function __(e,t,i,r,n,o,s,a,l){const c=p_(r,o,s),u=f_(r,n),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&g=0&&y=0&&d+c<=u){const i=new u_(g,y,0,m,t);r&&!h_(e,i,o,r,n)||p.push(i)}}h+=f}return a||p.length||s||(p=g_(e,h/2,i,r,n,o,s,!0,l)),p}function y_(e,t,i,r,n){const o=[];for(let s=0;s=r&&c.x>=r||(s.x>=r?s=new Ut(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=r&&(c=new Ut(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=n&&c.y>=n||(s.y>=n?s=new Ut(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round():c.y>=n&&(c=new Ut(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}function x_(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();ee.hasImage(t,i))),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const r in e.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[r],e.getImage(r,i),t),this.patchUpdatedImage(this.patternPositions[r],e.getImage(r,i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl,o=!!Object.keys(this.patternPositions).length;i.update(t.data,{useMipmap:o},{x:r,y:n})}}va(b_,"ImagePosition"),va(w_,"ImageAtlas");const T_=1e20;function E_(e,t,i,r,n,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=T_}for(let a=0,l=0;a{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[t];if(void 0!==n)return void i(null,{stack:e,id:t,glyph:n});if(n=this._tinySDF(r,e,t),n)return r.glyphs[t]=n,void i(null,{stack:e,id:t,glyph:n});const s=Math.floor(t/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[s])return void i(null,{stack:e,id:t,glyph:n});let a=r.requests[s];a||(a=r.requests[s]=[],A_.loadGlyphRange(e,s,o,this.requestManager,((e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[s]=!0}for(const i of a)i(e,t);delete r.requests[s]}))),a.push(((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null})}))}),((e,t)=>{if(e)i(e);else if(t){const e={};for(const{stack:i,id:r,glyph:n}of t)void 0===e[i]&&(e[i]={}),void 0===e[i].glyphs&&(e[i].glyphs={}),e[i].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[i].ascender=this.entries[i].ascender,e[i].descender=this.entries[i].descender;i(null,e)}}))}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==I_.none&&(this.localGlyphMode===I_.all?!!this.localFontFamily:!!this.localFontFamily&&(Sa["CJK Unified Ideographs"](e)||Sa["Hangul Syllables"](e)||Sa.Hiragana(e)||Sa.Katakana(e)||Sa["CJK Symbols and Punctuation"](e)||Sa["CJK Unified Ideographs Extension A"](e)||Sa["CJK Unified Ideographs Extension B"](e)))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),n=e.tinySDF=new A_.TinySDF({fontFamily:r,fontWeight:i,fontSize:48,buffer:6,radius:16}),n.fontWeight=i}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:d,glyphAdvance:p}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new cd({width:a,height:l},s),metrics:{width:c/M_,height:u/M_,left:h/M_,top:d/M_-27,advance:p/M_,localGlyph:!0}}}}A_.loadGlyphRange=function(e,t,i,r,n){const o=256*t,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),Ki.Glyphs);tr(a,((e,t)=>{if(e)n(e);else if(t){const e={},i=(function(e){return new Cm(e).readFields($m,{})})(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}}))},A_.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const a=this.size=e+4*t,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(T_,0,h),_.fill(0,0,h);for(let e=0;e0?e*e:0,_[r]=e<0?e*e:0}}E_(g,0,0,c,u,c,this.f,this.v,this.z),E_(_,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;ee+t[1]-t[0],f=h.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let y=0,x=f,v=0,b=m,w=0,T=_,E=0,S=g;if(o.content&&r){const e=o.content;y=z_(h,0,e[0]),v=z_(d,0,e[1]),x=z_(h,e[0],e[2]),b=z_(d,e[1],e[3]),w=e[0]-y,E=e[1]-v,T=e[2]-e[0]-x,S=e[3]-e[1]-b}const M=(r,n,a,l)=>{const h=L_(r.stretch-y,x,c,e.left),d=R_(r.fixed-w,T,r.stretch,f),p=L_(n.stretch-v,b,u,e.top),_=R_(n.fixed-E,S,n.stretch,m),g=L_(a.stretch-y,x,c,e.left),M=R_(a.fixed-w,T,a.stretch,f),I=L_(l.stretch-v,b,u,e.top),A=R_(l.fixed-E,S,l.stretch,m),C=new Ut(h,p),P=new Ut(g,p),z=new Ut(g,I),D=new Ut(h,I),L=new Ut(d/s,_/s),R=new Ut(M/s,A/s),k=t*Math.PI/180;if(k){const e=Math.sin(k),t=Math.cos(k),i=[t,-e,e,t];C._matMult(i),P._matMult(i),D._matMult(i),z._matMult(i)}const O=r.stretch+r.fixed,B=a.stretch+a.fixed,F=n.stretch+n.fixed,N=l.stretch+l.fixed,V=e.imageSecondary;return{tl:C,tr:P,bl:D,br:z,texPrimary:{x:o.paddedRect.x+C_+O,y:o.paddedRect.y+C_+F,w:B-O,h:N-F},texSecondary:V?{x:V.paddedRect.x+C_+O,y:V.paddedRect.y+C_+F,w:B-O,h:N-F}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:R,minFontScaleX:T/s/c,minFontScaleY:S/s/u,isSDF:i}};if(r&&(o.stretchX||o.stretchY)){const e=D_(h,_,f),t=D_(d,g,m);for(let i=0;io)&&(o=t.x),(!e||t.y>s)&&(s=t.y)}const l=Math.min(o-r,s-n);let c=l/2;const u=new lo([],B_);if(0===l)return new Ut(r,n);for(let t=r;th.d||!h.d)&&(h=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-h.d<=t||(c=r.h/2,u.push(new F_(r.p.x-c,r.p.y-c,c,e)),u.push(new F_(r.p.x+c,r.p.y-c,c,e)),u.push(new F_(r.p.x-c,r.p.y+c,c,e)),u.push(new F_(r.p.x+c,r.p.y+c,c,e)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function B_(e,t){return t.max-e.max}class F_{constructor(e,t,i,r){this.p=new Ut(e,t),this.h=i,this.d=(function(e,t){let i=!1,r=1/0;for(let n=0;ne.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,th(e,n,a))}}return(i?1:-1)*Math.sqrt(r)})(this.p,r),this.max=this.d+this.h*Math.SQRT2}}const N_=Number.POSITIVE_INFINITY,V_=Math.sqrt(2);function U_(e,[t,i]){let r=0,n=0;if(i===N_){t<0&&(t=0);const i=t/V_;switch(e){case"top-right":case"top-left":n=i-7;break;case"bottom-right":case"bottom-left":n=7-i;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=t;break;case"right":r=-t}}else{switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}}return[r,n]}function j_(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 G_(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f){let m=o.textMaxSize.evaluate(t,{},h);void 0===m&&(m=s);const _=e.layers[0].layout,g=_.get("icon-offset").evaluate(t,{},h),y=W_(i.horizontal)||i.vertical,x="globe"===d.name,v=Om,b=s/v,w=e.tilePixelRatio*m/v,T=(z=e.overscaling,e.zoom>18&&z>2&&(z>>=1),Math.max(co/(512*z),1)*_.get("symbol-spacing")),E=_.get("text-padding")*e.tilePixelRatio,S=_.get("icon-padding")*e.tilePixelRatio,M=qt(_.get("text-max-angle")),I="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),A="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),C=_.get("symbol-placement"),P=T/2;var z;const D=_.get("icon-text-fit").evaluate(t,{},h),L=_.get("icon-text-fit-padding").evaluate(t,{},h),R="none"!==D;let k;!1===e.hasAnyIconTextFit&&R&&(e.hasAnyIconTextFit=!0),r&&R&&(e.allowVerticalPlacement&&i.vertical&&(k=c_(r,i.vertical,D,L,g,b)),y&&(r=c_(r,y,D,L,g,b)));const O=(s,a,m)=>{if(a.x<0||a.x>=co||a.y<0||a.y>=co)return;let _=null;if(x){const{x:e,y:t,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new u_(e,t,i,0,void 0),up:d.upVector(m,a.x,a.y)}}!(function(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x,v,b,w,T,E,S,M){const I=e.addToLineVertexArray(t,r);let A,C,P,z,D,L,R,k=0,O=0,B=0,F=0,N=-1,V=-1;const U={};let j=Pr("");const G=i?i.anchor:t,q="none"!==l.layout.get("icon-text-fit").evaluate(v,{},E);let Z=0,$=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,$]=l.layout.get("text-offset").evaluate(v,{},E).map((e=>e*Om)):(Z=l.layout.get("text-radial-offset").evaluate(v,{},E)*Om,$=N_),e.allowVerticalPlacement&&n.vertical){const e=n.vertical;if(f)L=X_(e),a&&(R=X_(a));else{const i=l.layout.get("text-rotate").evaluate(v,{},E)+90;P=H_(c,G,t,u,h,d,e,p,i,m),a&&(z=H_(c,G,t,u,h,d,a,g,i))}}if(o){const r=l.layout.get("icon-rotate").evaluate(v,{},E),n=P_(o,r,w,q),s=a?P_(a,r,w,q):void 0;C=H_(c,G,t,u,h,d,o,g,r),k=4*n.length;const p=e.iconSizeData;let f=null;"source"===p.kind?(f=[Bm*l.layout.get("icon-size").evaluate(v,{},E)],f[0]>Z_&&pi(`${e.layerIds[0]}: Value for "icon-size" is >= ${q_}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[Bm*b.compositeIconSizes[0].evaluate(v,{},E),Bm*b.compositeIconSizes[1].evaluate(v,{},E)],(f[0]>Z_||f[1]>Z_)&&pi(`${e.layerIds[0]}: Value for "icon-size" is >= ${q_}. Reduce your "icon-size".`)),e.addSymbols(e.icon,n,f,x,y,v,!1,i,t,I.lineStartIndex,I.lineLength,-1,T,E,S,M),N=e.icon.placedSymbolArray.length-1,s&&(O=4*s.length,e.addSymbols(e.icon,s,f,x,y,v,Xm.vertical,i,t,I.lineStartIndex,I.lineLength,-1,T,E,S,M),V=e.icon.placedSymbolArray.length-1)}for(const r in n.horizontal){const o=n.horizontal[r];A||(j=Pr(o.text),f?D=X_(o):A=H_(c,G,t,u,h,d,o,p,l.layout.get("text-rotate").evaluate(v,{},E),m));const a=1===o.positionedLines.length;if(B+=$_(e,i,t,o,s,l,f,v,m,I,n.vertical?Xm.horizontal:Xm.horizontalOnly,a?Object.keys(n.horizontal):[r],U,N,b,T,E,S),a)break}n.vertical&&(F+=$_(e,i,t,n.vertical,s,l,f,v,m,I,Xm.vertical,["vertical"],U,V,b,T,E,S));let W=-1;const H=(e,t)=>e?Math.max(e,t):t;W=H(D,W),W=H(L,W),W=H(R,W);const X=W>-1?1:0;e.glyphOffsetArray.length>=65535&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,G.x,G.y,G.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,N,V,j,void 0!==A?A:e.collisionBoxArray.length,void 0!==A?A+1:e.collisionBoxArray.length,void 0!==P?P:e.collisionBoxArray.length,void 0!==P?P+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,z||e.collisionBoxArray.length,z?z+1:e.collisionBoxArray.length,u,B,F,k,O,X,0,Z,$,W,0,1,1,q?1:0)})(e,a,_,s,i,r,n,k,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,E,I,l,0,S,A,g,t,o,c,u,h,p,f)};if("line"===C)for(const n of y_(t.geometry,0,0,co,co)){const t=__(n,T,M,i.vertical||y,r,v,w,e.overscaling,co);for(const i of t)y&&Y_(e,y.text,P,i)||O(n,i,h)}else if("line-center"===C){for(const e of t.geometry)if(e.length>1){const t=m_(e,M,i.vertical||y,r,v,w);t&&O(e,t,h)}}else if("Polygon"===t.type)for(const e of qd(t.geometry,0)){const t=O_(e,16);O(e[0],new u_(t.x,t.y,0,0,void 0),h)}else if("LineString"===t.type)for(const e of t.geometry)O(e,new u_(e[0].x,e[0].y,0,0,void 0),h);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)O([t],new u_(t.x,t.y,0,0,void 0),h)}const q_=255,Z_=32640;function $_(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g){const y=(function(e,t,i,r,n,o,s,a){const l=[];if(0===t.positionedLines.length)return l;const c=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,u=(function(e){const t=e[0],i=e[1],r=t*i;return r>0?[t,-i]:r<0?[-t,i]:0===t?[i,t]:[i,-t]})(i);let h=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)h-=e.lineOffset;const d=t.positionedLines.length,p=h/d;let f=t.top-i[1];for(let e=0;eZ_&&pi(`${e.layerIds[0]}: Value for "text-size" is >= ${q_}. Reduce your "text-size".`)):"composite"===x.kind&&(v=[Bm*f.compositeTextSizes[0].evaluate(a,{},_),Bm*f.compositeTextSizes[1].evaluate(a,{},_)],(v[0]>Z_||v[1]>Z_)&&pi(`${e.layerIds[0]}: Value for "text-size" is >= ${q_}. Reduce your "text-size".`)),e.addSymbols(e.text,y,v,l,s,a,u,t,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function W_(e){for(const t in e)return e[t];return null}function H_(e,t,i,r,n,o,s,a,l,c){let u=s.top,h=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],u-=f[1],p+=f[2],h+=f[3]),l){const e=new Ut(d,u),t=new Ut(p,u),i=new Ut(d,h),r=new Ut(p,h),n=qt(l);let o=new Ut(0,0);c&&(o=new Ut(c[0],c[1])),e._rotateAround(n,o),t._rotateAround(n,o),i._rotateAround(n,o),r._rotateAround(n,o),d=Math.min(e.x,t.x,i.x,r.x),p=Math.max(e.x,t.x,i.x,r.x),u=Math.min(e.y,t.y,i.y,r.y),h=Math.max(e.y,t.y,i.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,d,u,p,h,a,r,n,o),e.length-1}function X_(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Y_(e,t,i,r){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])x&&(v(e,c,r,n,a,l),v(c,i,a,l,o,s))}v(h,d,r,o,n,o),v(d,p,n,o,n,s),v(p,f,n,s,r,s),v(f,h,r,s,r,o),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}function Q_(e,{x:t,y:i},r=0){return new Ut(((t-r)*e.scale-e.x)*co,(i*e.scale-e.y)*co)}const eg=e.ad.identity(new Float32Array(16));class tg{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new du(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i=!0){return e._coordinatePoint(e.locationCoordinate(t),i)}pixelsPerMeter(e,t){return Mu(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return K_(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,r){const n=e.horizonLineFromTop(!1),o=new Ut(t,Math.max(n,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,i){const r=new Ut(t,i);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y0?t<-ug+i&&(t=-ug+i):t>ug-i&&(t=ug-i);const o=n/Math.pow(hg(t),r);let s=o*Math.sin(r*e),a=n-o*Math.cos(r*e);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:i,f:r}=this,n=r-t,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=Yt(Zt(a/i)+this.center[0],-180,180),c=Yt(Zt(2*Math.atan(Math.pow(r/s,1/i))-ug),-85.051129,Pu);return new du(l,this.southernCenter?-c:c)}}class pg extends tg{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:Eu(e),y:Su(t),z:0}}unproject(e,t){const i=Iu(e),r=Au(t);return new du(i,r)}}const fg=qt(Pu);class mg extends tg{project(e,t){const i=(t=qt(t))*t,r=i*i;return{x:.5*((e=qt(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.06507600000000001*e))),i=Yt(i-n,-fg,fg)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=Yt(Zt(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Zt(i);return new du(s,a)}}const _g=qt(Pu);class gg extends tg{project(e,t){t=qt(t),e=qt(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*r+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,u=n*n,h=Math.cos(i/2),d=Math.sin(i/2),p=2*h*d,f=d*d,m=1-u*h*h,_=m?1/m:0,g=m?Math.acos(n*h)*Math.sqrt(1/m):0,y=.5*(2*g*n*d+2*i/Math.PI)-e,x=.5*(g*o+r)-t,v=.5*_*(u*f+g*n*h*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*u*p),T=.5*_*(c*h+g*f*n)+.5,E=b*w-T*v;s=(x*b-y*T)/E,a=(y*w-x*v)/E,i=Yt(i-s,-Math.PI,Math.PI),r=Yt(r-a,-_g,_g)}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new du(Zt(i),Zt(r))}}class yg extends tg{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(qt(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:i,cosPhi:r}=this;return{x:qt(e)*r*i+.5,y:-Math.sin(qt(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=Yt(Zt((e-.5)/i)/r,-180,180),s=Math.asin(Yt(n*r,-1,1)),a=Yt(Zt(s),-85.051129,Pu);return new du(o,a)}}class xg extends pg{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,i,r){const n=Fh(t,i,r),o=Uh(zh(r));return e._.transformMat4(n,n,o),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,i){const r=cu(i.lat,i.lng),n=e._.normalize([],r),o=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(i),t._centerAltitude):t._centerAltitude,s=Mu(1,0)*co*o;e._.scaleAndAdd(r,r,n,s);const a=e.ad.identity(new Float64Array(16));return e.ad.multiply(a,t.pixelMatrix,t.globeMatrix),e._.transformMat4(r,r,a),new Ut(r[0],r[1])}pixelsPerMeter(e,t){return Mu(1,0)*t}pixelSpaceConversion(e,t,i){const r=Mu(1,e)*t,n=Gr(Mu(1,45)*t,r,i);return this.pixelsPerMeter(e,t)/n}createTileMatrix(t,i,r){const n=jh(zh(r.canonical));return e.ad.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,i){const{center:r}=t,n=Uh(zh(i));return e.ad.rotateY(n,n,qt(r.lng)),e.ad.rotateX(n,n,qt(r.lat)),e.ad.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,i,r){return Ah(e,t,i,!0)||new ku(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!Ah(e,t.x,t.y,!1)}farthestPixelDistance(t){const i=(function(t,i){const r=t.cameraToCenterDistance,n=t._centerAltitude*i,o=t._camera,s=t._camera.forward(),a=e._.add([],e._.scale([],s,-r),[0,0,n]),l=t.worldSize/(2*Math.PI),c=[0,0,-l],u=t.width/t.height,h=Math.tan(t.fovAboveCenter),d=e._.scale([],o.up(),h),p=e._.scale([],o.right(),h*u),f=e._.normalize([],e._.add([],e._.add([],s,d),p)),m=[];let _;if(new fh(a,f).closestPointOnSphere(c,l,m)){const i=e._.add([],m,c),r=e._.sub([],i,a);_=Math.cos(t.fovAboveCenter)*e._.length(r)}else{const t=e._.sub([],a,c),i=e._.sub([],c,a);e._.normalize(i,i);const r=e._.length(t)-l;_=Math.sqrt(r*(r+2*l));const n=Math.acos(_/(l+r))-Math.acos(e._.dot(s,i));_*=Math.cos(n)}return 1.01*_})(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),r=$h(t.zoom);if(r>0){const e=K_(t,Mu(1,t.center.lat)*t.worldSize),n=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Gr(i,e+n*(1-Math.cos(o)),Math.pow(r,10))}return i}upVector(e,t,i){return Fh(t,i,e,1)}upVectorScale(e){return{metersToTile:Mh(Nh(zh(e)))}}}function vg(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new pg(e);case"equirectangular":return new cg(e);case"naturalEarth":return new mg(e);case"equalEarth":return new lg(e);case"winkelTripel":return new gg(e);case"albers":return i?new yg(e):new ig(e);case"lambertConformalConic":return i?new yg(e):new dg(e);case"globe":return new xg(e)}throw new Error(`Invalid projection name: ${e.name}`)}class bg{constructor(e,t,i,r){this.id=bg.uniqueIdxCounter,bg.uniqueIdxCounter++,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||r||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=bg.uniqueIdxCounter,bg.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}bg.uniqueIdxCounter=0;class wg{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}wg.ReadOnly=!1,wg.ReadWrite=!0,wg.disabled=new wg(519,wg.ReadOnly,[0,1]);const Tg=7680;class Eg{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}Eg.disabled=new Eg({func:519,mask:0},0,0,Tg,Tg,Tg);const Sg=771;class Mg{constructor(e,t,i,r){this.blendFunction=e,this.blendColor=t,this.mask=i,this.blendEquation=r}}Mg.Replace=[1,0,1,0],Mg.disabled=new Mg(Mg.Replace,Ur.transparent,[!1,!1,!1,!1]),Mg.unblended=new Mg(Mg.Replace,Ur.transparent,[!0,!0,!0,!0]),Mg.alphaBlended=new Mg([1,Sg,1,Sg],Ur.transparent,[!0,!0,!0,!0]),Mg.alphaBlendedNonPremultiplied=new Mg([770,Sg,770,Sg],Ur.transparent,[!0,!0,!0,!0]),Mg.multiply=new Mg([774,0,774,0],Ur.transparent,[!0,!0,!0,!0]);const Ig=1029,Ag=2305;class Cg{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Cg.disabled=new Cg(!1,Ig,Ag),Cg.backCCW=new Cg(!0,Ig,Ag),Cg.backCW=new Cg(!0,Ig,2304),Cg.frontCW=new Cg(!0,1028,2304),Cg.frontCCW=new Cg(!0,1028,Ag);const Pg=bp.types,zg=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Dg(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=a?Math.min(Z_,Math.round(a[0])):0,f=a?Math.min(Z_,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),f,16*c,16*u,256*h,256*d)}function Lg(e,t,i){e.emplaceBack(t,i)}function Rg(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,s)}function kg(e,t,i,r,n){e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n)}function Og(e){for(const t of e.sections)if(La(t.text))return!0;return!1}class Bg{constructor(e){this.layoutVertexArray=new Ul,this.indexArray=new Yl,this.programConfigurations=e,this.segments=new bc,this.dynamicLayoutVertexArray=new Ol,this.opacityVertexArray=new Gl,this.occlusionQueryOpacityVertexArray=new ql,this.placedSymbolArray=new hc,this.iconTransitioningVertexArray=new Zl,this.globeExtVertexArray=new jl,this.zOffsetVertexArray=new ql}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,t,i,r,n){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Bf.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Nf.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,zg,!0),this.occlusionQueryOpacityVertexBuffer=e.createVertexBuffer(this.occlusionQueryOpacityVertexArray,Vf.members,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,jf.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Ff.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Uf.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}va(Bg,"SymbolBuffers");class Fg{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new bc,this.collisionVertexArray=new Xl,this.collisionVertexArrayExt=new Ol}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Gf.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,qf.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}va(Fg,"CollisionBuffers");class Ng{constructor(t){this.queries=new Map,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((e=>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=e.ad.identity([]),this.placementViewportMatrix=e.ad.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Fm(this.zoom,i["text-size"]),this.iconSizeData=Fm(this.zoom,i["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),o=r.get("symbol-z-order");this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map((e=>Xm[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=r.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Bg(new Hc(this.layers,{zoom:this.zoom,lut:this.lut},(e=>/^text/.test(e)))),this.icon=new Bg(new Hc(this.layers,{zoom:this.zoom,lut:this.lut},(e=>/^icon/.test(e)))),this.glyphOffsetArray=new fc,this.lineVertexArray=new mc,this.symbolInstances=new pc}calculateGlyphDependencies(e,t,i,r,n){for(let i=0;i0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,p=s.get("symbol-sort-key");if(this.features=[],!h&&!d)return;const f=i.iconDependencies,m=i.glyphDependencies,_=i.availableImages,g=new $a(this.zoom);for(const{feature:i,id:c,index:u,sourceLayerIndex:y}of t){const t=o._featureFilter.needGeometry,x=qu(i,t);if(!o._featureFilter.filter(g,x,r))continue;if(t||(x.geometry=Gu(i,r,n)),a&&1!==i.type&&r.z<=5){const t=x.geometry,i=.98078528056,n=(t,n)=>{const o=Fh(t.x,t.y,r,1),s=Fh(n.x,n.y,r,1);return e._.dot(o,s)=0;for(const i of v.sections)if(i.image)f[i.image.namePrimary]=!0;else{const r=Ma(v.toString()),n=i.fontStack||e,o=m[n]=m[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r)}}}"line"===s.get("symbol-placement")&&(this.features=(function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;ce.geometry))})(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,i,r,n){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,t,s,i,r,n),this.icon.programConfigurations.updatePaintArrays(e,t,s,i,r,n)}updateOcclusionOpacities(e,t,i){if(!t.useOcclusionQueries)return!1;const r=this;if("globe"===r.projection.name)return!1;let n=!1;r.hasTextData()&&(n=n||0!==r.text.occlusionQueryOpacityVertexArray.length),r.hasIconData()&&(n=n||0!==r.icon.occlusionQueryOpacityVertexArray.length);const o=r.layers[0].paint,s=o.get("icon-occlusion-opacity").constantOr(0),a=o.get("text-occlusion-opacity").constantOr(0);if(!r.layers[0].hasInitialOcclusionOpacityProperties||1===s&&1===a)return!1;let l=!n;for(let e=0;e.5?1:-1)*t.fadeSpeed*i*.001,n.occlusionOpacity=Yt(n.occlusionOpacity,0,1),l=l||n.occlusionOpacity!==o}if(!l)return!1;let c=0,u=0;const h=(e,t,i,r)=>{let n=0,o=0;i?(n=u,u+=r,o=u):(n=c,c+=r,o=c),o>t.occlusionQueryOpacityVertexArray.length&&t.occlusionQueryOpacityVertexArray.resize(o);const s=e.occlusionOpacity;for(let e=0;e0;if((i>0||n>0)&&(h(t,r.text,!1,i),h(t,r.text,!1,n)),s){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=t;e>=0&&h(t,r.icon,!0,o),i>=0&&h(t,r.icon,!0,t.numVerticalIconVertices)}}return r.hasTextData()&&r.text.occlusionQueryOpacityVertexBuffer&&(r.text.occlusionQueryOpacityVertexBuffer.length{i+=t,i>e.length&&e.resize(i);for(let n=-t;n<0;n++)e.emplace(n+i,r)},t=(e,t,i)=>{r+=t,r>e.length&&e.resize(r);for(let n=-t;n<0;n++)e.emplace(n+r,i)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,r=0;for(let i=0;i0;if((n>0||o>0)&&(e(this.text.zOffsetVertexArray,n,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=r;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,r.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=vg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const e of this.queries.values())e.destroy()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:i}of t)this.lineVertexArray.emplaceBack(e,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){const _=e.indexArray,g=e.layoutVertexArray,y=e.globeExtVertexArray,x=e.segments.prepareSegment(4*t.length,g,_,this.canOverlap?o.sortKey:void 0),v=this.glyphOffsetArray.length,b=x.vertexLength,w=this.allowVerticalPlacement&&s===Xm.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let r=0;r=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=Nm(this.textSizeData,e,n)/Om;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=Nm(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i,r){e.emplaceBack(t,-i,-i,r),e.emplaceBack(t,i,-i,r),e.emplaceBack(t,i,i,r),e.emplaceBack(t,-i,i,r)}_updateTextDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tr[e]-r[t]||n[t]-n[e])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset))}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),r>=0&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}va(Ng,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Ng.addDynamicAttributes=kg;class Vg{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r)}update(e,t,i){const{width:r,height:n}=e,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!t||!1!==t.premultiply)),i||this.size&&this.size[0]===r&&this.size[1]===n){const{x:t,y:o}=i||{x:0,y:0};if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap)s.texSubImage2D(s.TEXTURE_2D,0,t,o,s.RGBA,s.UNSIGNED_BYTE,e);else{let i=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(i=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,t,o,r,n,i,a,e.data)}}else if(this.size=[r,n],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap){let t=this.format;this.format===s.R8&&(t=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,t,s.UNSIGNED_BYTE,e)}else{let t=this.format,i=this.format,o=s.UNSIGNED_BYTE;this.format===s.DEPTH_COMPONENT&&(t=s.DEPTH_COMPONENT16,o=s.UNSIGNED_SHORT),this.format===s.R8&&(i=s.RED),this.format===s.R32F&&(o=s.FLOAT,i=s.RED),s.texImage2D(s.TEXTURE_2D,0,t,r,n,0,i,o,e.data)}this.useMipmap=Boolean(t&&t.useMipmap),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(e,t,i=!1){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.useMipmap&&!i?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t)}bindExtraParam(e,t,i,r){const{context:n}=this,{gl:o}=n;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),r!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapT=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Ug{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:i}=this,{gl:r}=i;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)}}const jg=32,Gg=33,qg=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,r=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=jg:i=r=a=jg;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=s,r=a):(i=n,r=o,n=s,o=a),s=e,a=l}const l=4*e;qg[l+0]=i,qg[l+1]=r,qg[l+2]=n,qg[l+3]=o}const Zg=new Uint16Array(2178),$g=new Uint8Array(1089),Wg=new Uint16Array(1089);function Hg(e){return 0===e?-.03125:32===e?.03125:0}var Xg=Cl([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]),Yg=Cl([{name:"a_index",type:"Int16",components:1}]);const Kg={type:2,extent:co,loadGeometry:()=>[[new Ut(0,0),new Ut(8193,0),new Ut(8193,8193),new Ut(0,8193),new Ut(0,0)]]};class Jg{constructor(e,t,i,r,n){this.tileID=e,this.uid=ri(),this.uses=0,this.tileSize=t,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.fqid]=r}}return i})(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Ng){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Ng&&t.hasRTLText){this.hasRTLText=!0,Za.isLoading()||Za.isLoaded()||"deferred"!==Ga()||qa();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e],r=t.style.getOwnLayer(e);if(!r)continue;const n=r.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,n)}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness}else this.collisionBoxArray=new cc}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.fqid]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const t=e.gl,i=this.imageAtlas;if(i&&!i.uploaded){const r=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new Vg(e,i.image,t.RGBA,{useMipmap:r}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Vg(e,this.glyphAtlasImage,t.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Vg(e,this.lineAtlas.image,t.R8),this.lineAtlas.uploaded=!0)}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const r=t.style.getBrightness();(this._lastUpdatedBrightness||r)&&(this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this._lastUpdatedBrightness=r,this.updateBuckets(void 0,t)))}queryRenderedFeatures(e,t,i,r,n,o,s,a){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const s=cl(t&&t.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let t=0;te)i=!1;else if(t)if(this.expirationTime=0;e--){const t=4*e,i=qg[t+0],r=qg[t+1],n=qg[t+2],o=qg[t+3],s=i+n>>1,a=r+o>>1,l=s+a-r,c=a+i-s,u=r*Gg+i,h=o*Gg+n,d=a*Gg+s,p=Math.hypot((Zg[2*u+0]+Zg[2*h+0])/2-Zg[2*d+0],(Zg[2*u+1]+Zg[2*h+1])/2-Zg[2*d+1])>=16;$g[d]=$g[d]||(p?1:0),e<1022&&($g[d]=$g[d]||$g[(r+c>>1)*Gg+(i+l>>1)]||$g[(o+c>>1)*Gg+(n+l>>1)])}const n=new Ll,o=new Yl;let s=0;function a(e,t){const i=t*Gg+e;return 0===Wg[i]&&(n.emplaceBack(Zg[2*i+0],Zg[2*i+1],e*co/jg,t*co/jg),Wg[i]=++s),Wg[i]-1}function l(e,t,i,r,n,s){const c=e+i>>1,u=t+r>>1;if(Math.abs(e-n)+Math.abs(t-s)>1&&$g[u*Gg+c])l(n,s,e,t,c,u),l(i,r,n,s,c,u);else{const l=a(e,t),c=a(i,r),u=a(n,s);o.emplaceBack(l,c,u)}}return l(0,0,jg,jg,jg,0),l(jg,jg,0,0,0,jg),{vertices:n,indices:o}})(this.tileID.canonical,t);r=e.vertices,n=e.indices}else{r=new Ll,n=new Yl;for(const{x:e,y:t}of i)r.emplaceBack(e,t,0,0);const e=xd(r.int16,void 0,4);for(let t=0;t0&&(a=e.ad.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,n,i,o,a,s),this._makeGlobeTileDebugTextBuffer(t,n,i,o,a,s)}_globePoint(t,i,r,n,o,s,a){let l=Fh(t,i,r);if(s){const o=1<.5?d=-1:h<-.5&&(d=1);let p=(t/co+r.x)/o+d,f=(i/co+r.y)/o;p=(p-c)*n._pixelsPerMercatorPixel+c,f=(f-u)*n._pixelsPerMercatorPixel+u;const m=[p*n.worldSize,f*n.worldSize,0];e._.transformMat4(m,m,s),l=Dh(l,m,a)}return e._.transformMat4(l,l,o)}_makeGlobeTileDebugBorderBuffer(e,t,i,r,n,o){const s=new zl,a=new rc,l=new Dl,c=(e,c,u,h,d)=>{const p=(u-e)/(d-1),f=(h-c)/(d-1),m=s.length;for(let u=0;uc*e+t;for(let e=0;e>1,h=-7,u=i?n-1:0,d=i? * @license BSD-3-Clause * @version 11.2.6 */ -class wx{constructor(e=0,t=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=i,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){return e.map((e=>[e,this.get(e)]))}evict(e=!1){if(e||this.size>0){const e=this.first;delete this.items[e.key],0==--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const i=this.items[e];this.ttl>0&&i.expiry<=Date.now()?this.delete(e):(t=i.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t,i=!1,r=this.resetTtl){let n;if(i||this.has(e)){if(n=this.items[e],n.value=t,!1===i&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){const e=this.last,t=n.next,i=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,e.next=n,null!==i&&(i.next=t),null!==t&&(t.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1==++this.size?this.first=n:this.last.next=n;return this.last=n,this}values(e=this.keys()){return e.map((e=>this.get(e)))}}function Tx(e,t){if(4!==t.length)throw new Error(`Expected data of dimension 4 but got ${t.length}.`);let i=t[3];for(let r=2;r>=1;r--){const n=1===r?1:0,o=2===r?1:0;for(let r=0;r>>1^-(1&e[t]);return e}function Sx(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t>4|(61440&i)>>8|(240&r)<<4|61440&r,e[t+1]=15&i|(3840&i)>>4|(15&r)<<8|(3840&r)<<4}return e;case"uint8":for(let t=0;t>6|(192&r)>>4|(192&n)>>2|192&o,e[t+1]=(48&i)>>4|(48&r)>>2|48&n|(48&o)<<2,e[t+2]=(12&i)>>2|12&r|(12&n)<<2|(12&o)<<4,e[t+3]=3&i|(3&r)<<2|(3&n)<<4|(3&o)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}class Mx extends Error{constructor(e){super(e),this.name="MRTError"}}var Ax=Uint8Array,Ix=Uint16Array,Cx=Int32Array,Px=new Ax([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]),zx=new Ax([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]),Dx=new Ax([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Rx=function(e,t){for(var i=new Ix(31),r=0;r<31;++r)i[r]=t+=1<>1|(21845&Nx)<<1;Fx[Nx]=((65280&(Vx=(61680&(Vx=(52428&Vx)>>2|(13107&Vx)<<2))>>4|(3855&Vx)<<4))>>8|(255&Vx)<<8)>>1}var Ux=function(e,t,i){for(var r=e.length,n=0,o=new Ix(t);n>l]=c}else for(s=new Ix(r),n=0;n>15-e[n]);return s},jx=new Ax(288);for(Nx=0;Nx<144;++Nx)jx[Nx]=8;for(Nx=144;Nx<256;++Nx)jx[Nx]=9;for(Nx=256;Nx<280;++Nx)jx[Nx]=7;for(Nx=280;Nx<288;++Nx)jx[Nx]=8;var Gx=new Ax(32);for(Nx=0;Nx<32;++Nx)Gx[Nx]=5;var qx=Ux(jx,9,1),Zx=Ux(Gx,5,1),$x=function(e){for(var t=e[0],i=1;it&&(t=e[i]);return t},Wx=function(e,t,i){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&i},Qx=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Hx=["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"],Xx=function(e,t,i){var r=new Error(t||Hx[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Xx),!i)throw r;return r},Yx=new Ax(0),Jx="undefined"!=typeof TextDecoder&&new TextDecoder;try{Jx.decode(Yx,{stream:!0})}catch(e){}const Kx={gzip_data:"gzip"},ev={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},tv={uint32:1,uint16:2,uint8:4},iv={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class rv{constructor(e=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){return this.layers[e]}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new Mx("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),i=this.getHeaderLength(e);if(t.length= ${i} but got buffer of length ${t.length}`);const r=new wm(t.subarray(0,i)),n=vx.read(r);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Mx(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new nv(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],i=this.getLayer(e.layerName);for(let r=0;re.lastBlock)continue;if(i._blocksInProgress.has(r))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:r,blockShape:[n.bands.length].concat(i.bandShape),buffer:i.buffer,codec:n.codec.codec,filters:n.filters.map((e=>e.filter))};i._blocksInProgress.add(r),t.push(a)}return new ov(t,(()=>{t.forEach((e=>i._blocksInProgress.delete(e.blockIndex)))}),((e,r)=>{if(t.forEach((e=>i._blocksInProgress.delete(e.blockIndex))),e)throw e;r.forEach((e=>{this.getLayer(e.layerName).processDecodedData(e)}))}))}}class nv{constructor({version:e,name:t,units:i,tilesize:r,pixel_format:n,buffer:o,data_index:s},a){if(this.version=e,1!==this.version)throw new Mx(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=r,this.buffer=o,this.pixelFormat=ev[n],this.dataIndex=s,this.bandShape=[r+2*o,r+2*o,tv[this.pixelFormat]],this._decodedBlocks=(function(e=1e3,t=0,i=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof i)throw new TypeError("Invalid resetTtl value");return new wx(e,t,i)})(a?a.cacheSize:5),this._blocksInProgress=new Set}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.set(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[i,r]of this.dataIndex.entries()){for(const[n,o]of r.bands.entries())if(o===e)return{bandIndex:t+n,blockIndex:i,blockBandIndex:n};t+=r.bands.length}break;case"number":for(const[i,r]of this.dataIndex.entries()){if(e>=t&&e=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:i}=this.getBlockForBand(e),r=this._decodedBlocks.get(t.toString());if(!r)throw new Mx(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const n=this.dataIndex[t],o=this.bandShape.reduce(((e,t)=>e*t),1),s=i*o,a=r.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:n.offset,scale:n.scale}}}class ov{constructor(e,t,i){this.tasks=e,this._onCancel=t,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}rv.performDecoding=function(e,t){return Promise.all(t.tasks.map((t=>{const{layerName:i,firstByte:r,lastByte:n,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,h=new Uint8Array(e).subarray(r,n+1),u=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return d=(function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=(function(e){31==e[0]&&139==e[1]&&8==e[2]||Xx(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[i++]);return i+(2&t)})(n=e))+8>n.length&&Xx(6,"invalid gzip data"),(function(e,t,i,r){var n=e.length;if(!n||t.f&&!t.l)return i||new Ax(0);var o=!i,s=o||2!=t.i,a=t.i;o&&(i=new Ax(3*n));var l,c,h=function(e){var t=i.length;if(e>t){var r=new Ax(Math.max(2*t,e));r.set(i),i=r}},u=t.f||0,d=t.p||0,p=t.b||0,f=t.l,m=t.d,_=t.m,g=t.n,y=8*n;do{if(!f){u=Wx(e,d,1);var x=Wx(e,d+1,3);if(d+=3,!x){var v=e[(z=4+((d+7)/8|0))-4]|e[z-3]<<8,b=z+v;if(b>n){a&&Xx(0);break}s&&h(p+v),i.set(e.subarray(z,b),p),t.b=p+=v,t.p=d=8*b,t.f=u;continue}if(1==x)f=qx,m=Zx,_=9,g=5;else if(2==x){var w=Wx(e,d,31)+257,T=Wx(e,d+10,15)+4,E=w+Wx(e,d+5,31)+1;d+=14;for(var S=new Ax(E),M=new Ax(19),A=0;A>4)<16)S[A++]=z;else{var R=0,L=0;for(16==z?(L=3+Wx(e,d,3),d+=2,R=S[A-1]):17==z?(L=3+Wx(e,d,7),d+=3):18==z&&(L=11+Wx(e,d,127),d+=7);L--;)S[A++]=R}}var k=S.subarray(0,w),O=S.subarray(w);_=$x(k),g=$x(O),f=Ux(k,_,1),m=Ux(O,g,1)}else Xx(1);if(d>y){a&&Xx(0);break}}s&&h(p+131072);for(var B=(1<<_)-1,F=(1<>4;if((d+=15&R)>y){a&&Xx(0);break}if(R||Xx(2),V<256)i[p++]=V;else{if(256==V){N=d,f=null;break}var U=V-254;V>264&&(U=Wx(e,d,(1<<(q=Px[A=V-257]))-1)+kx[A],d+=q);var j=m[Qx(e,d)&F],G=j>>4;if(j||Xx(3),d+=15&j,O=Bx[G],G>3){var q=zx[G];O+=Qx(e,d)&(1<y){a&&Xx(0);break}s&&h(p+131072);var Z=p+U;if(pl.length)&&(c=l.length),new Ax(l.subarray(0,c))):i.subarray(0,p)})(n.subarray(o,-8),{i:2},new Ax(((i=n)[(r=i.length)-4]|i[r-3]<<8|i[r-2]<<16|i[r-1]<<24)>>>0))));var i,r,n,o;const s=Kx[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then((e=>new Uint8Array(e)))})(h,c).then((e=>{const t=bx.read(new wm(e));if("uint32_values"===t.values)return t.uint32_values.readValuesInto(u),new(0,iv[o])(u.buffer);throw new Error(`Unhandled numeric data "${t.values}"`)})),d.then((e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":Tx(e,s);break;case"zigzag_filter":Ex(e);break;case"bitshuffle_filter":Sx(e,o);break;default:throw new Error(`Unhandled filter "${l[t]}"`)}return{layerName:i,blockIndex:a,data:e}})).catch((e=>{throw e}))})))},fa(ov,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});const sv=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class av{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=sv[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new av(s,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=sv.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return lv(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=s){for(let s=u;s<=h;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[s])}continue}const d=u+h>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(u),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u<=o){for(let i=u;i<=h;i++)dv(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=u+h>>1,p=n[2*d],f=n[2*d+1];dv(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(u),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c))}return a}}function lv(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;cv(e,t,s,r,n,o),lv(e,t,i,r,s-1,1-o),lv(e,t,i,s+1,n,1-o)}function cv(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);cv(e,t,i,Math.max(r,Math.floor(i-a*c/s+h)),Math.min(n,Math.floor(i+(s-a)*c/s+h)),o)}const s=t[2*i+o];let a=r,l=n;for(hv(e,t,r,i),t[2*n+o]>s&&hv(e,t,r,n);as;)l--}t[2*r+o]===s?hv(e,t,r,l):(l++,hv(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function hv(e,t,i,r){uv(e,i,r),uv(t,2*i,2*r),uv(t,2*i+1,2*r+1)}function uv(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function dv(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}e.$=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return(function([e,t]){const i=fi([1,e,t]);return{x:i.x,y:i.y,z:i.z}})(e.expression.evaluate(t))}interpolate(e,t,i){return{x:jr(e.x,t.x,i),y:jr(e.y,t.y,i),z:jr(e.z,t.z,i)}}},e.A=il,e.B=Ws,e.C=Pn,e.D=qs,e.E=kr,e.F=function(e){const t=e.value;let i=[];if(!t)return i;const r=Sn(t);return"string"!==r?(i=i.concat([new Xg(e.key,t,`string expected, "${r}" found`)]),i):(Yg(t,!0)||(i=i.concat([new Xg(e.key,t,`invalid url "${t}"`)])),i)},e.G=tl,e.H=Ja,e.I=Jm,e.J=Ha,e.K=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return fi(e.expression.evaluate(t))}interpolate(e,t,i){return{x:jr(e.x,t.x,i),y:jr(e.y,t.y,i),z:jr(e.z,t.z,i),azimuthal:jr(e.azimuthal,t.azimuthal,i),polar:jr(e.polar,t.polar,i)}}},e.L=Ga,e.M=class{constructor(e,t,i,r){this.id=e,this.position=null!=t?new sh(t[0],t[1]):new sh(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new mu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,i){if(e.a9.multiply(t.matrix,i,t.matrix),t.meshes)for(const e of t.meshes){const i=mu.applyTransform(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=e.a9.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(e,t,i,r,n,o,s=!1){oy(this.matrix,this,e.transform,this.position,t,i,r,n,o,s)}upload(e){if(!this.uploaded){for(const t of this.nodes)ly(t,e);for(const e of this.nodes)cy(e);this.uploaded=!0}}destroy(){for(const e of this.nodes)hy(e)}},e.N=Va,e.O=Ch,e.P=Vt,e.R=Hi,e.S=Xt,e.T=gg,e.U=Qa,e.V=Xg,e.W=Nu,e.X=jr,e.Y=no,e.Z=oa,e._=Gr,e.a=Lr,e.a$=oi,e.a0=function(e,t,i=0,r=!0){const n=new Vt(i,i),o=e.sub(n),s=t.add(n),a=[o,new Vt(s.x,o.y),s,new Vt(o.x,s.y)];return r&&a.push(o.clone()),a},e.a1=function(e,t){const i=[];for(let r=0;r{r(e,i)}),t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,r)}),t):e(i,r);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==r)),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}},e.aj=_l,e.ak=function(e,t,i){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const r=Ki(e.request,((e,r,n,o)=>{e?t(e):r&&t(null,{vectorTile:i?void 0:new up(new wm(r)),rawData:r,cacheControl:n,expires:o})}));return()=>{r.cancel(),t()}}),t)},e.al=function(e){Ui++,Ui>Fi&&(e.getActor().send("enforceCacheSizeLimit",Bi),Ui=0)},e.am=fr,e.an=Pi,e.ao=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.ap=dh,e.aq=Eg,e.ar=Ag,e.as=wg,e.at=function(e,t){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){t(null,i)};for(let t=0;t{}}},e.au=yg,e.av=C_,e.aw=bh,e.ax=wh,e.ay=Al,e.az=Gl,e.b=Rr,e.b$=o_,e.b0=rv,e.b1=Ki,e.b2=function(e){const t=[];for(const i in e)t.push(e[i]);return t},e.b3=function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i},e.b4=Jt,e.b5=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.b6=function(t,i){const{x:r,y:n}=t.point,o=Fu(r,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return e.a9.multiply(o,o,ku(Su(i)))},e.b8=Qf,e.b9=Mm,e.bA=Xc,e.bB=function(t){const i=e.a9.identity(new Float64Array(16));e.a9.multiply(i,t.pixelMatrix,t.globeMatrix);const r=[0,eh,0],n=[0,th,0];return e.Q.transformMat4(r,r,i),e.Q.transformMat4(n,n,i),[r[0]>0&&r[0]<=t.width&&r[1]>0&&r[1]<=t.height&&!Uu(t,new sh(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!Uu(t,new sh(t.center.lat,-90))]},e.bC=function(t,i){const{scale:r}=t.tileTransform,n=r*no/(t.tileSize*Math.pow(2,i.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return e.b7.scale(new Float32Array(4),i.inverseAdjustmentMatrix,[n,n])},e.bD=kg,e.bE=Rg,e.bF=function(t){const i=Rg(t,!0);return e.b7.invert([],[i[0],i[1],i[4],i[5]])},e.bG=cu,e.bH=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return Fu(t,i,e.worldSize,r,n)},e.bI=qt,e.bJ=Hc,e.bK=function(e){const t=Math.round((e+45+360)%360/90)%4;return Zt[t]},e.bL=45,e.bM=gh,e.bN=zc,e.bO=Mc,e.bP=Ac,e.bQ=Sc,e.bR=Ec,e.bS=Ic,e.bT=function(e,t,i){const r=Math.sqrt(e*e+t*t+i*i),n=r>0?Math.acos(i/r)*jt:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*jt+90:0;return o<0&&(o+=360),[r,o,n]},e.bU=Ih,e.bV=mu,e.bW=fi,e.bX=function(e){return[Math.pow(e[0],.45454545454545453),Math.pow(e[1],.45454545454545453),Math.pow(e[2],.45454545454545453)]},e.bY=function(e){return e({pluginStatus:Da,pluginURL:Ra}),Oa.on("pluginStateChange",e),e},e.bZ=fy,e.b_=vy,e.ba=Wf,e.bb=function(e,t,i,r,n){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=r,e.float32[o+2]=n},e.bc=rg,e.bd=Hm,e.be=jh,e.bf=qf,e.bg=x_,e.bh=y_,e.bi=Bm,e.bj=av,e.bk=Yt,e.bm=Gt,e.bn=Si,e.bo=vh,e.bp=function(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3]},e.bq=sh,e.br=Y_,e.bs=uh,e.bt=fu,e.bu=Lg,e.bv=hh,e.bw=Iu,e.bx=function(e,t,i,r,n,o,s,a,l){if("globe"===l.name)return Iu(e,t,new hh(i,r,n),!1);const c=C_({z:i,x:r,y:n},l);return new mu([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])},e.by=function(e,t,i){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]=0?e.slice(0,t):e},e.c9=function(e){return e.indexOf(ml)>=0},e.cA=e=>({u_matrix:new zc(e),u_pixels_to_tile_units:new Lc(e),u_device_pixel_ratio:new Sc(e),u_units_to_pixels:new Mc(e),u_dash_image:new Ec(e),u_gradient_image:new Ec(e),u_image_height:new Sc(e),u_texsize:new Mc(e),u_tile_units_to_pixels:new Sc(e),u_alpha_discard_threshold:new Sc(e),u_trim_offset:new Mc(e),u_emissive_strength:new Sc(e)}),e.cB=e=>({u_matrix:new zc(e),u_texsize:new Mc(e),u_pixels_to_tile_units:new Lc(e),u_device_pixel_ratio:new Sc(e),u_image:new Ec(e),u_units_to_pixels:new Mc(e),u_tile_units_to_pixels:new Sc(e),u_alpha_discard_threshold:new Sc(e),u_trim_offset:new Mc(e)}),e.cC=Ul,e.cD=Gf,e.cE=Hf,e.cF=$u,e.cG=(e,t,i,r,n,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=Bu(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:zi.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Zu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{const s=e.transform;return{u_matrix:Pf(e,t,i,r),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:n,u_image:0,u_tile_units_to_pixels:Cf(t,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},e.cJ=(e,t,i,r,n,o,s)=>{const a=e.transform,l=a.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Pf(e,t,i,r),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:Df(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Cf(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_emissive_strength:i.paint.get("line-emissive-strength")}},e.cK=ri,e.cL=ad,e.cM=sf,e.cN=fh,e.cO=Yp,e.cP=Vp,e.cQ=450,e.cR=7,e.cS=Tg,e.cT=256,e.cU=ku,e.cV=Yl,e.cW=Wl,e.cX=Ql,e.cY=function(e,t,i,r,n){return Ht((e-t)/(i-t)*(n-r)+r,r,n)},e.cZ=Mh,e.c_=Ug,e.ca=function(e){const t=e.indexOf(ml);return t>=0?e.slice(t+1):""},e.cb=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},e.cc=li,e.cd=Oa,e.ce=Ji,e.cf=Cc,e.cg=class extends Tc{constructor(e){super(e),this.current=Dc}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},e.ch=$t,e.ci=function(e,t,i){const r=Nu(i.zoom),n=e.style.map._antialias,o=t.options.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!n&&!o},e.cj=function(t){const i=t.pixelsPerMeter,r=i/vh(1,t.center.lat),n=e.a9.identity(new Float64Array(16));return e.a9.translate(n,n,[t.point.x,t.point.y,0]),e.a9.scale(n,n,[r,r,i]),Float32Array.from(n)},e.ck=Cu,e.cl=function(e){const t=80.051129;e=Ht(e,-80.051129,t)/t*90;const i=Math.pow(Math.abs(Math.sin(Gt(e))),3);return Math.round(i*(Kc.length-1))},e.cm=function(t,i,r,n){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=1<0){const t=180/n;e.ct.multiply(f,f,[t/h+1,0,0,0,t/u+1,0,-.5*t/d,.5*t/p,1])}return f[2]=c,f[5]=t.x,f[8]=t.y,f},e.cn=Su,e.co=function(t,i,r){const n=e.a9.identity(new Float64Array(16)),o=(i/(1<1)return!1;const i=t.getSource().maxzoom,r=1<1)return t;const n=r.getSource().maxzoom,o=1<{const s=this.getAtTileOffset(t,o.x,o.y),a=n.upVector(t.canonical,o.x,o.y),l=n.upVectorScale(t.canonical,i,r).metersToTile;return e.Q.scale(a,a,s*l),a}}getForTilePoints(e,t,i,r){if(this.isUsingMockSource())return!1;const n=Rp.create(this,e,r);return!!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i)})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<({u_camera_to_center_distance:new Sc(e),u_extrude_scale:new Lc(e),u_device_pixel_ratio:new Sc(e),u_matrix:new zc(e),u_inv_rot_matrix:new zc(e),u_merc_center:new Mc(e),u_tile_id:new Ac(e),u_zoom_transition:new Sc(e),u_up_dir:new Ac(e),u_emissive_strength:new Sc(e)}),e.d=nr,e.d$=py,e.d0=Rp,e.d1=ny,e.d2=Fl,e.d3=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[]}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e){const t=gp(new Vt(0,0),new Vt(no,no),e),i=[];for(const r of this._activeRegions){if(r.hiddenByOverlap)continue;if(!_p(t,r))continue;const n=yp(r.min,r.max,e);i.push({min:n.min,max:n.max,sourceId:this._sourceIds[r.priority],footprint:r.footprint,footprintTileId:r.tileId})}return i}setSources(e){this._setSources(e.map((e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(i).buckets[e.layer];if(r)for(const e of r.getNodesInfo()){const r=e.node;r.footprint&&t.push({footprint:r.footprint,id:i.toUnwrapped()})}}return t}}))))}_addSource(e){const t=e.getFootprints();if(0!==t.length){for(const e of t){if(!e.footprint)continue;const t=gp(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint})}this._sourceIds.push(e.getSourceId())}}_computeReplacement(){this._activeRegions.sort(((e,t)=>e.priority-t.priority||fp(e.min,t.min)||fp(e.max,t.max)));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0,i=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],n=this._prevRegions[i];e=r.priority!==n.priority||!mp(r,n),++t,++i}}if(e){++this._updateTime;const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const i=t[e].priority;for(;e1){let t=0,i=e(t);for(;t!==i;){let r=t;const n=t;for(;r!==i;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.d4=class{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,t){const i=new Sl,r=new Gl,n=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let r=e===o-1?e-2:0===e?e:e-1;return r+=i?24575:0,[r,t]};for(let e=0;ee()))},e.dC=my,e.dD=Ay,e.dE=function(e){wy=zi.resolveURL(e),My||(My=new fy(vy(),new kr)),My.broadcast("setDracoUrl",wy)},e.dF=Iy,e.dG=function(e){Ey=zi.resolveURL(e),My||(My=new fy(vy(),new kr)),My.broadcast("setMeshoptUrl",Ey)},e.dH=fa,e.dI=id,e.dJ=r_,e.dK=ix,e.dL=ox,e.dM=bf,e.dN=ai,e.dO=Km,e.dP=function(e,t,i,r,n,o,s,a,l,c,h){e.createArrays(),e.tilePixelRatio=no/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const u=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Va(t),a),d["text-size"].possiblyEvaluate(new Va(i),a)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Va(t),a),d["icon-size"].possiblyEvaluate(new Va(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Va(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Va(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Va(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const t of e.features)if(t.icon&&t.icon.nameSecondary){_=!0;break}for(const o of e.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),x=o.text;let v,b=[0,0];if(x){const r=x.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*qf,c=u.get("text-line-height").evaluate(o,{},a)*qf,h=ba(r)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const e=u.get("text-radial-offset").evaluate(o,{},a);b=e?y_(p,[e*qf,__]):u.get("text-offset").evaluate(o,{},a).map((e=>e*qf))}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const v="point"===u.get("symbol-placement"),w=v?u.get("text-max-width").evaluate(o,{},a)*qf:1/0,T=o=>{e.allowVerticalPlacement&&va(r)&&(y.vertical=Cm(x,t,i,n,l,w,c,p,o,h,b,Mm.vertical,!0,g,d))};if(!f&&m){const e="auto"===_?m.map((e=>x_(e))):[_];let r=!1;for(let o=0;o=0||!va(r)){const e=Cm(x,t,i,n,l,w,c,p,_,h,b,Mm.horizontal,!1,g,d);e&&(y.horizontal[_]=e)}T(v?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const t=r[o.icon.namePrimary];t&&(v=Nm(n[o.icon.namePrimary],o.icon.nameSecondary?n[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&ui("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const T=E_(y.horizontal)||y.vertical;e.iconsInText||(e.iconsInText=!!T&&T.iconsInText),(T||v)&&v_(e,o,y,v,r,p,g,0,b,w,s,a,c,h,_)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)},e.dQ=up,e.dR=wm,e.dS=Dp,e.dT=dp,e.dU=Kd,e.dV=Ft,e.dW=tm,e.dX=u,e.dY=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==By){const i=new Uint32Array(e,0,7),[,,r,n,o,s]=i;t=i.byteLength+n+o+s+o,(r!==e.byteLength||t>=e.byteLength)&&ui("Invalid b3dm header information.")}return Gy(e,t)},e.dZ=function(e,t){const i=Ky(e);for(const e of i){for(const t of e.meshes)ex(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(tx(e.lights,t)))}return i},e.d_=fx,e.da=rh,e.db=function([e,t,i]){const r=Math.hypot(e,t,i),n=Math.atan2(e,i),o=.5*Math.PI-Math.acos(-t/r);return new sh(qt(n),qt(o))},e.dc=nh,e.dd=r,e.de=Uu,e.df=Vu,e.dg=function(t){const i=[0,0,0],r=e.a9.identity(new Float64Array(16));return e.a9.multiply(r,t.pixelMatrix,t.globeMatrix),e.Q.transformMat4(i,i,r),new Vt(i[0],i[1])},e.dh=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!(function(e){if(null==Ti){const t=e.navigator?e.navigator.userAgent:null;Ti=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Ti})(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.di=class{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=(function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",or,e].join(""),tokenExpiresAt:Date.now()+432e5}})();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,i){if(!o(e))return e;const r=lr(e);return r.params.push(`sdk=js-${t}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||i)}normalizeGlyphsURL(e,t){if(!o(e))return e;const i=lr(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeModelURL(e,t){if(!o(e))return e;const i=lr(e);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,r){if(!o(e))return e;const n=lr(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),i&&n.params.push(`language=${i}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,r){const n=lr(e);return o(e)?(n.path=`/styles/v1${n.path}/sprite${t}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${t}${i}`,cr(n))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!o(e))return e;const n=lr(e);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==n.authority&&512===i?"@2x":""}${ji.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${r.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${r.RASTERARRAYS_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${r.TILE_URL_VERSION}${n.path}`);const s=this._customAccessToken||(function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null})(n.params)||r.ACCESS_TOKEN;return r.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(e,t){const i=lr(e);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${r.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${i.path.replace(`/${r.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${r.TILE_URL_VERSION}/`,"")}`;let o=i.params;return t&&(o=o.filter((e=>!e.match(/^access_token=/)))),o.length&&(n+=`?${o.join("&")}`),n}canonicalizeTileset(e,t){const i=!!t&&o(t),r=[];for(const t of e.tiles||[])n(t)?r.push(this.canonicalizeTileURL(t,i)):r.push(t);return r}_makeAPIURL(e,t){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=lr(r.API_URL);if(e.protocol=n.protocol,e.authority=n.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==n.path&&(e.path=`${n.path}${e.path}`),!r.REQUIRE_ACCESS_TOKEN)return cr(e);if(t=t||r.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),cr(e)}},e.dj=function(e,t){t?Tr.add(e):Tr.delete(e)},e.dk=ji,e.dl=vr,e.dm=wr,e.dn=sr,e.dp=_r,e.dq=yr,e.dr=function(e){Tr.delete(e)},e.ds=br,e.dt=mr,e.du=t,e.dv=function(e,t){Bi=e,Fi=t},e.dw=function(e,t,i=!1){if(Da===Ia||Da===Ca||Da===Pa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Ra=zi.resolveURL(e),Da=Ia,za=t,ka(),i||Fa()},e.dx=Ba,e.dy=function(){vy().acquire(gy)},e.dz=function(){const e=xy;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(gy),xy=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.e=Kt,e.e0=Na,e.e1=function(e){Vi(),ki&&ki.then((t=>{t.keys().then((i=>{for(let r=0;re.arrayBuffer())).then((t=>Gy(t,0,e)))},e.m=Gs,e.n=Zs,e.o=ia,e.p=Xm,e.q=el,e.r=sa,e.s=$s,e.t=ra,e.u=Ka,e.v=Vo,e.w=ui,e.x=jo,e.y=No})),r(0,(function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const r of e)t+=`${i(r)},`;return`${t}]`}let t="{";for(const r of Object.keys(e).sort())t+=`${r}:${i(e[r])},`;return`${t}}`}function r(t){let r="";for(const n of e.b5)r+=`/${i(t[n])}`;return r}class n{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,i,n){this._options=n;for(const i of t)this._layerConfigs[i.id]=i,(this._layers[i.id]=e.c7(i,this.scope,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const o=(function(e,t){const i={};for(let n=0;nthis._layers[e.id])),i=t[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(t)}}}const o=1*e.dJ;class s{constructor(t){const i={},r=[];for(const e in t){const n=t[e],s=i[e]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i=t.metrics.localGlyph?o:1,a={x:0,y:0,w:t.bitmap.width+2*i,h:t.bitmap.height+2*i};r.push(a),s[e]=a}}const{w:n,h:s}=e.p(r),a=new e.dI({width:n||1,height:s||1});for(const r in t){const n=t[r];for(const t in n.glyphs){const s=n.glyphs[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[r][t],c=s.metrics.localGlyph?o:1;e.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}e.dH(s,"GlyphAtlas");class a{constructor(t){this.tileID=new e.ap(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.av(t.tileID.canonical,t.projection),this.projection=t.projection,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster}parse(t,i,r,n,o){this.status="parsing",this.data=t,this.collisionBoxArray=new e.aG;const a=new e.dK(Object.keys(t.layers).sort()),c=new e.dL(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new e.dM(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:r,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const n=t.layers[i];if(!n)continue;let o=!1,s=!1,u=!1;for(const e of p[i])"symbol"===e[0].type?o=!0:s=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let e=0;e=t.maxzoom||"none"!==t.visibility&&(l(e,this.zoom,d.brightness,r),(h[t.id]=t.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(e.map((e=>e.id)))))}}let f,m,_,g;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},x=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:e.b2(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const t=new s(m),i=new e.dO(_,g);for(const n in h){const o=h[n];o instanceof e.aH?(l(o.layers,this.zoom,d.brightness,r),e.dP(o,m,t.positions,_,i.iconPositions,this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof e.aN||o instanceof e.aO||o instanceof e.cO)&&(l(o.layers,this.zoom,d.brightness,r),o.addFeatures(d,this.tileID.canonical,i.patternPositions,r,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:e.b2(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:u,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const t=e.dN(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?n.send("getGlyphs",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{f||(f=e,m=t,x())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?n.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{f||(f=e,_=t,x())}),void 0,!1,y):_={};const r=Object.keys(d.patternDependencies);r.length?n.send("getImages",{icons:r,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{f||(f=e,g=t,x())}),void 0,!1,y):g={}}x()}}function l(t,i,r,n){const o=new e.N(i,{brightness:r});for(const e of t)e.recalculate(o,n)}class c extends e.E{constructor(t,i,r,n,o,s){super(),this.actor=t,this.layerIndex=i,this.availableImages=r,this.loadVectorData=o||e.ak,this.loading={},this.loaded={},this.deduped=new e.ai(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler,this.brightness=s}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[n]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const h=!this.loading[n];if(delete this.loading[n],h||a||!c)return l.status="done",h||(this.loaded[n]=l),r(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new e.dQ(new e.dR(u));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,n)=>{if(i||!n)return r(i);const a={};if(s){const e=t(o);e.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(e)))}r(null,e.e({rawTileData:u.slice(0)},n,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[n]=l}))}reloadTile(t,i){const r=this.loaded,n=t.uid,o=this;if(r&&r[n]){const s=r[n];s.showCollisionBoxes=t.showCollisionBoxes,s.projection=t.projection,s.brightness=t.brightness,s.tileTransform=e.av(t.tileID.canonical,t.projection),s.extraShadowCaster=t.extraShadowCaster;const a=(e,t)=>{const r=s.reloadCallback;r&&(delete s.reloadCallback,s.parse(s.vectorTile,o.layerIndex,this.availableImages,o.actor,r)),i(e,t)};"parsing"===s.status?s.reloadCallback=a:"done"===s.status&&(s.vectorTile?s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}else i(null,void 0)}abortTile(e,t){const i=e.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}}class h{loadTile(t,i){const{uid:r,encoding:n,rawImageData:o,padding:s}=t,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new e.dS(r,a,n,s<1))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const i=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),i}}class u{decodeRasterArray({task:t,buffer:i},r){e.b0.performDecoding(i,t).then((e=>{r(null,e)}),(e=>{r(e)}))}}const d=e.dT.prototype.toGeoJSON;let p=class{constructor(t){this._feature=t,this.extent=e.Y,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const i of this._feature.geometry)t.push([new e.P(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const r=[];for(const t of i)r.push(new e.P(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,i){return d.call(this,e,t,i)}},f=class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.Y,this.length=t.length,this._features=t}feature(e){return new p(this._features[e])}};var m={exports:{}},_=e.dV,g=e.dU.VectorTileFeature,y=x;function x(e,t){this.options=t||{},this.features=e,this.length=e.length}function v(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}x.prototype.feature=function(e){return new v(this.features[e],this.options.extent)},v.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t>31}function C(e,t){for(var i=e.loadGeometry(),r=e.type,n=0,o=0,s=i.length,a=0;ae},R=Math.fround||(L=new Float32Array(1),e=>(L[0]=+e,L[0]));var L;const k=3,O=5,B=6;class F{constructor(e){this.options=Object.assign(Object.create(D),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),s=this.getClusters([-180,r,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(U(i),j(o),U(n),j(r)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+O]>1?N(l,t,this.clusterProps):this.points[l[t+k]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(t*this.stride>=o.length)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+O]>1?N(o,i,this.clusterProps):this.points[o[i+k]])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,i){const r=[];return this._appendLeaves(r,e,t=t||10,i=i||0,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,h={features:[]};return this._addTileFeatures(r.range((t-a)/n,l,(t+1+a)/n,c),r.data,t,i,n,h),0===t&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.data,n,i,n,h),t===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.data,-1,i,n,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n1;let l,c,h;if(a)l=V(t,e,this.clusterProps),c=t[e],h=t[e+1];else{const i=this.points[t[e+k]];l=i.properties;const[r,n]=i.geometry.coordinates;c=U(r),h=j(n)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(h*n-r))]],tags:l};let d;d=a||this.options.generateId?t[e+k]:this.points[t[e+k]].id,void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:r,reduce:n,minPoints:o}=this.options,s=i/(r*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+O])}if(p>d&&p>=o){let e,o=r*d,s=h*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const r of u){const l=r*c;if(a[l+2]<=t)continue;a[l+2]=t;const h=a[l+O];o+=a[l]*h,s+=a[l+1]*h,a[l+4]=m,n&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),n&&l.push(f)}else{for(let e=0;e1)for(const e of u){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+O]>1){const r=this.clusterProps[e[t+B]];return i?Object.assign({},r):r}const r=this.points[e[t+k]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function N(e,t,i){return{type:"Feature",id:e[t+k],properties:V(e,t,i),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),G(e[t+1])]}};var r}function V(e,t,i){const r=e[t+O],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+B],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+k],point_count:r,point_count_abbreviated:n})}function U(e){return e/360+.5}function j(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function G(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var q={exports:{}};q.exports=(function(){function e(i,r,n,o){for(var s,a=o,l=n-r>>1,c=n-r,h=i[r],u=i[r+1],d=i[n],p=i[n+1],f=r+3;fa)s=f,a=m;else if(m===a){var _=Math.abs(f-l);_o&&(s-r>3&&e(i,r,s,o),i[s+2]=a,n-s>3&&e(i,s,n,o))}function t(e,t,i,r,n,o){var s=n-i,a=o-r;if(0!==s||0!==a){var l=((e-i)*s+(t-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return(s=e-i)*s+(a=t-r)*a}function i(e,t,i,n){var o={id:void 0===e?null:e,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return(function(e){var t=e.geometry,i=e.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)r(e,t);else if("Polygon"===i||"MultiLineString"===i)for(var n=0;n0&&(a+=n?(o*d-u*s)/2:Math.sqrt(Math.pow(u-o,2)+Math.pow(d-s,2))),o=u,s=d}var p=i.length-3;i[2]=1,e(i,0,p,r),i[p+2]=1,i.size=Math.abs(a),i.start=0,i.end=i.size}function a(e,t,i,r){for(var n=0;n1?1:i}function h(e,t,r,n,o,s,a,l){if(n/=t,s>=(r/=t)&&a=n)return null;for(var c=[],h=0;h=r&&y=n)){var x=[];if("Point"===_||"MultiPoint"===_)u(m,x,r,n,o);else if("LineString"===_)d(m,x,r,n,o,!1,l.lineMetrics);else if("MultiLineString"===_)f(m,x,r,n,o,!1);else if("Polygon"===_)f(m,x,r,n,o,!0);else if("MultiPolygon"===_)for(var v=0;v=i&&s<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function d(e,t,i,r,n,o,s){for(var a,l,c=p(e),h=0===n?_:g,u=e.start,d=0;di&&(l=h(c,f,y,v,b,i),s&&(c.start=u+a*l)):w>r?T=i&&(l=h(c,f,y,v,b,i),E=!0),T>r&&w<=r&&(l=h(c,f,y,v,b,r),E=!0),!o&&E&&(s&&(c.end=u+a*l),t.push(c),c=p(e)),s&&(u+=a)}var S=e.length-3;f=e[S],y=e[S+1],x=e[S+2],(w=0===n?f:y)>=i&&w<=r&&m(c,f,y,x),S=c.length-3,o&&S>=3&&(c[S]!==c[0]||c[S+1]!==c[1])&&m(c,c[0],c[1],c[2]),c.length&&t.push(c)}function p(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function f(e,t,i,r,n,o){for(var s=0;ss.maxX&&(s.maxX=h),u>s.maxY&&(s.maxY=u)}return s}function T(e,t,i,r){var n=t.geometry,o=t.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a0&&t.size<(n?s:r))i.numPoints+=t.length/3;else{for(var a=[],l=0;ls)&&(i.numSimplified++,a.push(t[l]),a.push(t[l+1])),i.numPoints++;n&&(function(e,t){for(var i=0,r=0,n=e.length,o=n-2;r0===t)for(r=0,n=e.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=(function(e,t){var i=[];if("FeatureCollection"===e.type)for(var r=0;r1&&console.time("creation"),p=this.tiles[d]=w(e,t,i,r,l),this.tileCoords.push({z:t,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(p.source=e,n){if(t===l.maxZoom||t===n)continue;var m=1<1&&console.time("clipping");var _,g,y,x,v,b,T=.5*l.buffer/l.extent,E=.5-T,S=.5+T,A=1+T;_=g=y=x=null,v=h(e,u,i-T,i+S,0,p.minX,p.maxX,l),b=h(e,u,i+E,i+A,0,p.minX,p.maxX,l),e=null,v&&(_=h(v,u,r-T,r+S,1,p.minY,p.maxY,l),g=h(v,u,r+E,r+A,1,p.minY,p.maxY,l),v=null),b&&(y=h(b,u,r-T,r+S,1,p.minY,p.maxY,l),x=h(b,u,r+E,r+A,1,p.minY,p.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*r),a.push(g||[],t+1,2*i,2*r+1),a.push(y||[],t+1,2*i+1,2*r),a.push(x||[],t+1,2*i+1,2*r+1)}}},S.prototype.getTile=function(e,t,i){var r=this.options,n=r.extent,o=r.debug;if(e<0||e>24)return null;var s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);for(var l,c=e,h=t,u=i;!l&&c>0;)c--,h=Math.floor(h/2),u=Math.floor(u/2),l=this.tiles[M(c,h,u)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,h,u),o>1&&console.time("drilling down"),this.splitTile(l.source,c,h,u,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?v(this.tiles[a],n):null):null},function(e,t){return new S(e,t)}})();var Z=e.dX(q.exports);function $(e,t){const i=e.tileID.canonical;if(!this._geoJSONIndex)return t(null,null);const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!r)return t(null,null);const n=new f(r.features);let o=z(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),t(null,{vectorTile:n,rawData:o.buffer})}class W extends c{constructor(e,t,i,r,n,o){super(e,t,i,r,$,o),n&&(this.loadGeoJSON=n),this._featureMap=new Map}loadData(i,r){const n=i&&i.request,o=n&&n.collectResourceTiming;this.loadGeoJSON(i,((s,a)=>{if(s||!a)return r(s);if("object"!=typeof a)return r(new Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`));{try{if(i.filter){const t=e.t(i.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a.features=a.features.filter((e=>t.value.evaluate({zoom:0},e)))}if(i.dynamic){"Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),i.append||this._featureMap.clear();for(const e of a.features||[]){const t=e.id;void 0!==t&&(e.geometry?this._featureMap.set(t,e):this._featureMap.delete(t))}a.features=[...this._featureMap.values()]}this._geoJSONIndex=i.cluster?new F((function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const r={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.t(s),l=e.t("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=a.value,n[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=r[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=n[t].evaluate(o,s)},t})(i)).load(a.features):Z(a,i.geojsonVtOptions)}catch(s){return r(s)}this.loaded={};const l={};if(o){const e=t(n);e&&(l.resourceTiming={},l.resourceTiming[i.source]=JSON.parse(JSON.stringify(e)))}r(null,l)}}))}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)e.g(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class Q{constructor(t,i){this.tileID=new e.ap(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=i}parse(t,i,r,n){this.status="parsing";const o=new e.ap(r.tileID.overscaledZ,r.tileID.wrap,r.tileID.canonical.z,r.tileID.canonical.x,r.tileID.canonical.y),s={},a=i.familiesBySource[r.source],l=new e.dL(o,r.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.dY(t).then((t=>{if(!t)return n(new Error("Could not parse tile"));const i=e.dZ(t,1/e.bU(r.tileID.canonical)),c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,h=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new e.N(this.zoom,{brightness:this.brightness});for(const t in a)for(const r of a[t]){const t=r[0];l.bucketLayerIDs.push(r.map((e=>e.id))),t.recalculate(u,[]);const n=new e.d_(i,o,c,h,this.brightness,l);c||(n.needsUpload=!0),s[t.fqid]=n,n.evaluate(t)}this.status="done",n(null,{buckets:s,featureIndex:l})})).catch((e=>n(new Error(e.message))))}}class H{constructor(e,t,i,r,n,o){this.actor=e,this.layerIndex=t,this.brightness=o,this.loading={},this.loaded={}}loadTile(t,i){const r=t.uid,n=this.loading[r]=new Q(t,this.brightness);e.b1(t.request,((e,o)=>{const s=!this.loading[r];return delete this.loading[r],s||e?(n.status="done",s||(this.loaded[r]=n),i(e)):o&&0!==o.byteLength?void n.parse(o,this.layerIndex,t,((e,t)=>{n.status="done",this.loaded=this.loaded||{},this.loaded[r]=n,e||!t?i(e):i(null,t)})):(n.status="done",this.loaded[r]=n,i())}))}reloadTile(e,t){const i=this.loaded,r=e.uid;if(i&&i[r]){const n=i[r];n.projection=e.projection,n.brightness=e.brightness;const o=(i,r)=>{n.reloadCallback&&(delete n.reloadCallback,this.loadTile(e,t)),t(i,r)};"parsing"===n.status?n.reloadCallback=o:"done"===n.status&&this.loadTile(e,t)}}abortTile(e,t){const i=e.uid;this.loading[i]&&delete this.loading[i],t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}}class X{constructor(t){this.self=t,this.actor=new e.d$(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.br({name:"mercator"}),this.workerSourceTypes={vector:c,geojson:W,"batched-model":H},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.e0.isParsed())throw new Error("RTL text plugin already registered.");e.e0.applyArabicShaping=t.applyArabicShaping,e.e0.processBidirectionalText=t.processBidirectionalText,e.e0.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,{scope:i,isLoaded:r}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][i]=r,this.workerSources[t]&&this.workerSources[t][i])for(const n in this.workerSources[t][i]){const o=this.workerSources[t][i][n];for(const t in o)o[t]instanceof c&&(o[t].isSpriteLoaded=r,o[t].fire(new e.b("isSpriteLoaded")))}}setImages(e,{scope:t,images:i},r){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=i,this.workerSources[e]&&this.workerSources[e][t]){for(const r in this.workerSources[e][t]){const n=this.workerSources[e][t][r];for(const e in n)n[e].availableImages=i}r()}else r()}setProjection(t,i){this.projections[t]=e.br(i)}setBrightness(e,t,i){this.brightness=t,i()}setLayers(e,t,i){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),i()}updateLayers(e,t,i){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),i()}loadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,i)}loadDEMTile(e,t,i){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,i)}decodeRasterArray(e,t,i){this.getRasterArrayWorkerSource().decodeRasterArray(t,i)}reloadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,i)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,i)}removeSource(e,t,i){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const r=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,r){try{e.e0.setState(i);const t=e.e0.getPluginURL();if(e.e0.isLoaded()&&!e.e0.isParsed()&&null!=t){this.self.importScripts(t);const i=e.e0.isParsed();r(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),i)}}catch(e){r(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let i=this.availableImages[e][t];return i||(i=[]),i}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let i=this.layerIndexes[e][t];return i||(i=this.layerIndexes[e][t]=new n,i.scope=t),i}getWorkerSource(e,t,i,r){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][r]||(this.workerSources[e][r]={}),this.workerSources[e][r][t]||(this.workerSources[e][r][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!this.workerSources[e][r][t][i]){const n={send:(t,i,r,n,o,s)=>{this.actor.send(t,i,r,e,o,s)},scheduler:this.actor.scheduler};this.workerSources[e][r][t][i]=new this.workerSourceTypes[t](n,this.getLayerIndex(e,r),this.getAvailableImages(e,r),this.isSpriteLoaded[e][r],void 0,this.brightness)}return this.workerSources[e][r][t][i]}getDEMWorkerSource(e,t,i){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][i]||(this.demWorkerSources[e][i]={}),this.demWorkerSources[e][i][t]||(this.demWorkerSources[e][i][t]=new h),this.demWorkerSources[e][i][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new u),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,i){e.e1(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new X(self)),X})),r(0,(function(e){function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let r=0;r{window.removeEventListener("click",m,!0)}),0)}function g(e,t){const i=e.getBoundingClientRect();return v(e,i,t)}function y(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;n=0?0:e.button}function v(t,i,r){const n=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((r.clientX-i.left)*n,(r.clientY-i.top)*n)}class b{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}class w extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={}}loadModel(t,i){return e.l(this.requestManager.transformRequest(i,e.R.Model).url).then((i=>{if(!i)return;const r=e.c(i),n=new e.M(t,void 0,void 0,r);return n.computeBoundsAndApplyParent(),n})).catch((r=>{if(r&&404===r.status)return null;this.fire(new e.a(new Error(`Could not load model ${t} from ${i}: ${r.message}`)))}))}load(t,i){this.models[i]||(this.models[i]={});const r=Object.keys(t);this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+r.length;const n=[];for(const e of r)n.push(this.loadModel(e,t[e]));Promise.allSettled(n).then((t=>{for(let e=0;e{this.fire(new e.a(new Error(`Could not load models: ${t.message}`)))}))}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t){return!!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.hasModel(e,i)&&this.models[i][e].numReferences++,this.load({[e]:this.requestManager.normalizeModelURL(t)},i)}addModels(e,t){this.models[t]||(this.models[t]={});const i={};for(const r in e)this.models[t][r]={},i[r]=this.requestManager.normalizeModelURL(e[r]);this.load(i,t)}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={});const i={};for(const r of e)this.hasModel(r,t)?this.models[t][r].numReferences++:i[r]=this.requestManager.normalizeModelURL(r);this.load(i,t)}removeModel(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){const i=this.models[t][e].model;delete this.models[t][e],i.destroy()}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context)}}class T{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,i,r){const n=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},e.e(this.stateChanges[t][n],r),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])r[e]||(this.deletedStates[t][n][e]=null)}else for(const e in r)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(t,i){const r=String(i),n=e.e({},(this.state[t]||{})[r],(this.stateChanges[t]||{})[r]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][i];if(null===e)return{};for(const t in e)delete n[t]}return n}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(t,i){const r={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const r in this.stateChanges[t])this.state[t][r]||(this.state[t][r]={}),e.e(this.state[t][r],this.stateChanges[t][r]),i[r]=this.state[t][r];r[t]=i}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else if(this.state[t][e])for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e]}r[t]=r[t]||{},e.e(r[t],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const e in t)t[e].setFeatureState(r,i)}}function E(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class S extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0}createScope(t){this.images[t]={},this.loaded[t]=!1,this.updatedImages[t]={},this.patterns[t]={},this.callbackDispatchedThisFrame[t]={},this.atlasImage[t]=new e.h({width:1,height:1})}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return!1;return!0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[]}}hasImage(e,t){return!!this.getImage(e,t)}getImage(e,t){return this.images[t][e]}addImage(e,t,i){this._validate(e,i)&&(this.images[t][e]=i)}_validate(t,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]o)return[new e.V(i,r,`${r} is greater than the maximum value ${o}`)]}return[]}function C(t){const i=t.valueSpec,r=e.u(t.value.type);let n,o,s,a={};const l="categorical"!==r&&void 0===t.value.property,c=!l,h="array"===e.j(t.value.stops)&&"array"===e.j(t.value.stops[0])&&"object"===e.j(t.value.stops[0][0]),u=M({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const n=t.value;return i=i.concat(A({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:d})),"array"===e.j(n)&&0===n.length&&i.push(new e.V(t.key,n,"array must have at least one stop")),i},default:function(e){return Q({key:e.key,value:e.value,valueSpec:i,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===r&&l&&u.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||u.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!e.s(t.valueSpec)&&u.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(c&&!e.m(t.valueSpec)?u.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.n(t.valueSpec)&&u.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!h||void 0!==t.value.property||u.push(new e.V(t.key,t.value,'"property" property is required')),u;function d(t){let r=[];const n=t.value,l=t.key;if("array"!==e.j(n))return[new e.V(l,n,`array expected, ${e.j(n)} found`)];if(2!==n.length)return[new e.V(l,n,`array length 2 expected, length ${n.length} found`)];if(h){if("object"!==e.j(n[0]))return[new e.V(l,n,`object expected, ${e.j(n[0])} found`)];if(void 0===n[0].zoom)return[new e.V(l,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new e.V(l,n,"object stop key must have value")];const i=e.u(n[0].zoom);if("number"!=typeof i)return[new e.V(l,n[0].zoom,"stop zoom values must be numbers")];if(s&&s>i)return[new e.V(l,n[0].zoom,"stop zoom values must appear in ascending order")];i!==s&&(s=i,o=void 0,a={}),r=r.concat(M({key:`${l}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:I,value:p}}))}else r=r.concat(p({key:`${l}[0]`,value:n[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},n));return e.o(e.q(n[1]))?r.concat([new e.V(`${l}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(Q({key:`${l}[1]`,value:n[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const l=e.j(t.value),c=e.u(t.value),h=null!==t.value?t.value:s;if(n){if(l!==n)return[new e.V(t.key,h,`${l} stop domain type must match previous stop domain type ${n}`)]}else n=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof c&&"string"!=typeof c&&"boolean"!=typeof c)return[new e.V(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==r){let n=`number expected, ${l} found`;return e.m(i)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,h,n)]}return"categorical"!==r||"number"!==l||"number"==typeof c&&isFinite(c)&&Math.floor(c)===c?"categorical"!==r&&"number"===l&&"number"==typeof c&&"number"==typeof o&&void 0!==o&&cnew e.V(`${t.key}${i.key}`,t.value,i.message)));const r=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return[new e.V(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.v(r))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return z(r,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.x(r,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.y(r))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function z(t,i){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const n=[];return t instanceof e.C&&r.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild((e=>{n.push(...z(e,i))})),n)}function D(t){const i=t.key,r=t.value,n=t.valueSpec,o=[];return Array.isArray(n.values)?-1===n.values.indexOf(e.u(r))&&o.push(new e.V(i,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(e.u(r))&&o.push(new e.V(i,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),o}function R(t){return e.A(e.q(t.value))?P(e.k({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):L(t)}function L(t){const i=t.value,r=t.key;if("array"!==e.j(i))return[new e.V(r,i,`array expected, ${e.j(i)} found`)];const n=t.styleSpec;let o,s=[];if(i.length<1)return[new e.V(r,i,"filter array must have at least 1 element")];switch(s=s.concat(D({key:`${r}[0]`,value:i[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.u(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.u(i[1])&&s.push(new e.V(r,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&s.push(new e.V(r,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(o=e.j(i[1]),"string"!==o&&s.push(new e.V(`${r}[1]`,i[1],`string expected, ${o} found`)));for(let a=2;a{t in r&&i.push(new e.V(n,r[t],`"${t}" is prohibited for ref layers`))})),o.layers.forEach((i=>{e.u(i.id)===l&&(t=i)})),t?t.ref?i.push(new e.V(n,r.ref,"ref cannot reference another ref layer")):a=e.u(t.type):"string"==typeof l&&i.push(new e.V(n,r.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(r.source){const t=o.sources&&o.sources[r.source],s=t&&e.u(t.type);t?"vector"===s&&"raster"===a?i.push(new e.V(n,r.source,`layer "${r.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new e.V(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new e.V(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"!==a||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||"geojson"===s&&t.lineMetrics?"raster-particle"===a&&"raster-array"!==s&&i.push(new e.V(n,r.source,`layer "${r.id}" requires a 'raster-array' source.`)):i.push(new e.V(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):i.push(new e.V(n,r.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(n,r,`layer "${r.id}" must specify a "source-layer"`)):i.push(new e.V(n,r.source,`source "${r.source}" not found`))}else i.push(new e.V(n,r,'missing required property "source"'));return i=i.concat(M({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Q({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:t=>R(e.k({layerType:a},t)),layout:t=>M({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>B(e.k({layerType:a},t))}}),paint:t=>M({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>O(e.k({layerType:a,layer:r},t))}})}})),i}function N(t){const i=t.value,r=t.key,n=e.j(i);return"string"!==n?[new e.V(r,i,`string expected, ${n} found`)]:[]}const V={promoteId:function({key:t,value:i}){if("string"===e.j(i))return N({key:t,value:i});{const e=[];for(const r in i)e.push(...N({key:`${t}.${r}`,value:i[r]}));return e}}};function U(t){const i=t.value,r=t.key,n=t.styleSpec,o=t.style;if(!i.type)return[new e.V(r,i,'"type" is required')];const s=e.u(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&(i.url||i.tiles||a.push(new e.i(r,i,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(M({key:r,value:i,valueSpec:n[`source_${s.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:V})),a;case"geojson":if(a=M({key:r,value:i,valueSpec:n.source_geojson,style:o,styleSpec:n,objectElementValidators:V}),i.cluster)for(const e in i.clusterProperties){const[t,n]=i.clusterProperties[e],o="string"==typeof t?[t,["accumulated"],["get",e]]:t;a.push(...P({key:`${r}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...P({key:`${r}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return M({key:r,value:i,valueSpec:n.source_video,style:o,styleSpec:n});case"image":return M({key:r,value:i,valueSpec:n.source_image,style:o,styleSpec:n});case"canvas":return[new e.V(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return D({key:`${r}.type`,value:i.type,valueSpec:{values:j(n)},style:o,styleSpec:n})}}function j(e){return e.source.reduce(((t,i)=>{const r=e[i];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values))),t}),[])}function G(t){const i=t.value,r=t.styleSpec,n=r.light,o=t.style;let s=[];const a=e.j(i);if(void 0===i)return s;if("object"!==a)return s=s.concat([new e.V("light",i,`object expected, ${a} found`)]),s;for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?Q({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?Q({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new e.V(t,i[t],`unknown property "${t}"`)])}return s}function q(t){const i=t.value;let r=[];if(!i)return r;const n=e.j(i);if("object"!==n)return r=r.concat([new e.V("light-3d",i,`object expected, ${n} found`)]),r;const o=t.styleSpec,s=o["light-3d"],a=t.key,l=t.style,c=t.style.lights;for(const t of["type","id"])if(!(t in i))return r=r.concat([new e.V("light-3d",i,`missing property ${t} on light`)]),r;if(i.type&&c)for(let n=0;n[],array:A,boolean:function(t){const i=t.value,r=t.key,n=e.j(i);return"boolean"!==n?[new e.V(r,i,`boolean expected, ${n} found`)]:[]},number:I,color:function(t){const i=t.key,r=t.value,n=e.j(r);return"string"!==n?[new e.V(i,r,`color expected, ${n} found`)]:null===e.z(r)?[new e.V(i,r,`color expected, "${r}" found`)]:[]},enum:D,filter:R,function:C,layer:F,object:M,source:U,model:e.F,light:G,"light-3d":q,terrain:Z,fog:$,string:N,formatted:function(e){return 0===N(e).length?[]:P(e)},resolvedImage:function(e){return 0===N(e).length?[]:P(e)},projection:function(t){const i=t.value,r=t.styleSpec,n=r.projection,o=t.style;let s=[];const a=e.j(i);if("object"===a)for(const e in i)s=s.concat(Q({key:e,value:i[e],valueSpec:n[e],style:o,styleSpec:r}));else"string"!==a&&(s=s.concat([new e.V("projection",i,`object or string expected, ${a} found`)]));return s},import:function(t){const{value:i,styleSpec:r}=t,{data:n}=i,o=l(i,c);Object.defineProperty(o,"__line__",{value:i.__line__,enumerable:!1});let s=M(e.k({},t,{value:o,valueSpec:r.import}));return""===e.u(o.id)&&s.push(new e.V(`${t.key}.id`,o,"import id can't be an empty string")),n&&(s=s.concat(X(n,r,{key:`${t.key}.data`}))),s}};function Q(t,i=!1){const r=t.value,n=t.valueSpec,o=t.styleSpec;if(n.expression&&e.B(e.u(r)))return C(t);if(n.expression&&e.o(e.q(r)))return P(t);if(n.type&&W[n.type]){const r=W[n.type](t);return!0===i&&r.length>0&&"array"===e.j(t.value)?P(t):r}return M(e.k({},t,{valueSpec:n.type?o[n.type]:n}))}function H(t){const i=t.value,r=t.key,n=N(t);return n.length||(-1===i.indexOf("{fontstack}")&&n.push(new e.V(r,i,'"glyphs" url must include a "{fontstack}" token')),-1===i.indexOf("{range}")&&n.push(new e.V(r,i,'"glyphs" url must include a "{range}" token'))),n}function X(t,i=e.G,r={}){return Q({key:r.key||"",value:t,valueSpec:i.$root,styleSpec:i,style:t,objectElementValidators:{glyphs:H,"*":()=>[]}})}function Y(t,i=e.G){return le(X(t,i))}const J=e=>le(U(e)),K=e=>le(G(e)),ee=e=>le(q(e)),te=e=>le(Z(e)),ie=e=>le($(e)),re=e=>le(F(e)),ne=e=>le(R(e)),oe=e=>le(O(e)),se=e=>le(B(e)),ae=t=>le(e.F(t));function le(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function ce(t,i){let r=!1;if(i&&i.length)for(const n of i)n instanceof e.i?e.w(n.message):(t.fire(new e.a(new Error(n.message))),r=!0);return r}const he=new e.H({anchor:new e.J(e.G.light.anchor),position:new e.K(e.G.light.position),color:new e.J(e.G.light.color),intensity:new e.J(e.G.light.intensity)});class ue extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.L(he),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(K,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,r){return(!r||!1!==r.validate)&&ce(this,t.call(Y,e.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.G})))}}const de=new e.H({source:new e.J(e.G.terrain.source),exaggeration:new e.J(e.G.terrain.exaggeration)});let pe=class extends e.E{constructor(t,i,r,n){super(),this.scope=r,this._transitionable=new e.L(de,r,n),this._transitionable.setTransitionOrValue(t,n),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.N(t)).get("exaggeration")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.Z}};const fe=45,me=65,_e=.05;function ge(t,i,r,n){const o=e.S(fe,me,r),[s,a]=ye(t,n);let l=1-Math.min(1,Math.exp((i-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function ye(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}function xe(t,i,r,n,o){const s=e.Q.transformMat4([],[i,r,n],o.mercatorFogMatrix);return ge(t,e.Q.length(s),o.pitch,o._fov)}function ve(t,i,r,n,o,s,a){const l=[[r,n,0],[o,n,0],[o,s,0],[r,s,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const r=e.Q.transformMat4([],t,i),n=e.Q.length(r);c=Math.min(c,n),h=Math.max(h,n)}return[ge(t,c,a.pitch,a._fov),ge(t,h,a.pitch,a._fov)]}const be=new e.H({range:new e.J(e.G.fog.range),color:new e.J(e.G.fog.color),"high-color":new e.J(e.G.fog["high-color"]),"space-color":new e.J(e.G.fog["space-color"]),"horizon-blend":new e.J(e.G.fog["horizon-blend"]),"star-intensity":new e.J(e.G.fog["star-intensity"]),"vertical-range":new e.J(e.G.fog["vertical-range"])});class we extends e.E{constructor(t,i,r,n){super(),this._transitionable=new e.L(be,r,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.U(be)}get state(){const t=this._transform,i="globe"===t.projection.name,r=e.W(t.zoom),n=this.properties.get("range"),o=[.5,3];return{range:i?[e.X(o[0],n[0],r),e.X(o[1],n[1],r)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(ie,t,r))return;const n=e.e({},t);for(const t of Object.keys(e.G.fog))void 0===n[t]&&(n[t]=e.G.fog[t].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,i)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.S(fe,me,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?(function(t,i,r){const n=e.O.fromLngLat(i),o=r.elevation?r.elevation.getAtPointOrZero(n):0;return xe(t,n.x,n.y,o,r)})(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return ve(this.state,i,0,0,e.Y,e.Y,this._transform)}getOpacityForBounds(e,t,i,r,n){return this._transform.projection.supportsFog?ve(this.state,e,t,i,r,n,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?ye(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const i=[4,5,6,7];for(const r of i){const i=t.points[r];let n;if(i[2]>=0)n=i;else{const o=t.points[r-4];n=e._(o,i,o[2]/(o[2]-i[2]))}if(xe(this.state,n[0],n[1],0,this._transform)>=_e)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,r){return(!r||!1!==r.validate)&&ce(this,t.call(Y,e.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.G})))}}class Te extends e.E{constructor(t,i,r,n){super(),this.scope=r,this._options=t,this.properties=new e.U(i),this._transitionable=new e.L(i,r,new Map(n)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}const Ee=new e.H({color:new e.J(e.G.properties_light_ambient.color),intensity:new e.J(e.G.properties_light_ambient.intensity)}),Se=new e.H({direction:new e.$(e.G.properties_light_directional.direction),color:new e.J(e.G.properties_light_directional.color),intensity:new e.J(e.G.properties_light_directional.intensity),"cast-shadows":new e.J(e.G.properties_light_directional["cast-shadows"]),"shadow-intensity":new e.J(e.G.properties_light_directional["shadow-intensity"])});class Me{constructor(e,t,i,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(t,i){let r,n;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);r=[o],n=i.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),s=e.P.convert(t[1]);r=[o,s],n=e.a0(o,s).every((e=>i.isPointAboveHorizon(e)))}return new Me(r,i.getCameraPoint(),n,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.a0(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.a0(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=r.x?n[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(n[3]=this.cameraPoint)),e.a1(n,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.a0(i,r,t),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>r.y))+((o.x>i.x)+(o.x>r.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(t,i,r,n=0){const o=t.queryPadding/i._pixelsPerMercatorPixel+1,s=r?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=t.tileID.wrap+(s.unwrapped?n:0);const l=s.polygon.map((i=>e.a2(t.tileTransform,i,a)));if(!e.a3(l,0,0,e.Y,e.Y))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map((i=>e.a4(t.tileTransform,i,a))),h=c.map((t=>new e.P(t[0],t[1]))),u=i.getFreeCameraOptions().position||new e.O(0,0,0),d=e.a4(t.tileTransform,u,a),p=c.map((t=>{const i=e.Q.sub(t,t,d);return e.Q.normalize(i,i),new e.a5(d,i)})),f=e.a6(t,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:h,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.a7(l),m.min.x=e.ad(m.min.x,0,e.Y),m.min.y=e.ad(m.min.y,0,e.Y),m.max.x=e.ad(m.max.x,0,e.Y),m.max.y=e.ad(m.max.y,0,e.Y),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=Ce(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=Ce(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(t,i){const r=(function(t,i){const r=e.a9.multiply([],i.pixelMatrix,i.globeMatrix),n=[0,-e.ae,0,1],o=[0,e.ae,0,1],s=[0,0,0,1];e.aa.transformMat4(n,n,r),e.aa.transformMat4(o,o,r),e.aa.transformMat4(s,s,r);const a=new e.P(n[0]/n[3],n[1]/n[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.ab(t,a)&&n[3]1?Ae(t.slice(0,d),i):[],m=dnew e.P(Ie(t.x),t.y))),m=m.map((t=>new e.P(Ie(t.x),t.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=e.X(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,p);let y;return y=c?[new e.P(0,g),new e.P(0,0),new e.P(1,0),new e.P(1,g)]:[new e.P(1,g),new e.P(1,1),new e.P(0,1),new e.P(0,g)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((t=>new e.O(t.x,t.y))),unwrapped:!1}})(t,i);if(r)return r;const n=(function(t,i){let r=!1,n=-1/0,o=0;for(let e=0;en&&(n=t[e].x,o=e);for(let e=0;e.5&&(n.x{e.x-=1})),{polygon:t,unwrapped:r}})(Ae(t,i).map((t=>new e.P(Ie(t.x),t.y))),i);return{polygon:n.polygon.map((t=>new e.O(t.x,t.y))),unwrapped:n.unwrapped}}}function Ae(t,i){return e.ac(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),.00390625)}function Ie(e){return e<0?1+e%1:e%1}function Ce(e){return 100*e|0}function Pe(t,i,r,n,o){const s=function(r,n){if(r)return o(r);if(n){t.url&&n.tiles&&t.tiles&&delete t.tiles;const r=e.af(e.e(n,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(r.vectorLayers=n.vector_layers,r.vectorLayerIds=r.vectorLayers.map((e=>e.id))),n.raster_layers&&(r.rasterLayers=n.raster_layers,r.rasterLayerIds=r.rasterLayers.map((e=>e.id))),r.tiles=i.canonicalizeTileset(r,t.url),o(null,r)}};return t.url?e.g(i.transformRequest(i.normalizeSourceURL(t.url,null,r,n),e.R.Source),s):e.f.frame((()=>s(null,t)))}class ze{constructor(t,i,r){this.bounds=e.ag.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=r||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),r=Math.floor(e.a8(this.bounds.getWest())*i),n=Math.floor(e.ah(this.bounds.getNorth())*i),o=Math.ceil(e.a8(this.bounds.getEast())*i),s=Math.ceil(e.ah(this.bounds.getSouth())*i);return t.x>=r&&t.x=n&&t.y{this._tileJSONRequest=null,this._loaded=!0,n?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new e.a(n))):o&&(e.e(this,o),o.bounds&&(this.tileBounds=new ze(o.bounds,this.minzoom,this.maxzoom)),e.am(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aj(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.e({},this._options)}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(r,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster};if(n.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",n,o.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);else{const i=e.ak.call({deduped:this._deduped},n,((e,i)=>{e||!i?o.call(this,e):(n.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",n,o.bind(this),void 0,!0))}),!0);t.request={cancel:i}}function o(r,n){return delete t.request,t.aborted?i(null):r&&404!==r.status?i(r):(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),e.al(this.dispatcher),i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Re extends e.E{constructor(t,i,r,n){super(),this.id=t,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},i),e.e(this,e.af(i,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"})),this._tileJSONRequest=Pe(this._options,this.map._requestManager,null,null,((i,r)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.a(i)):r&&(e.e(this,r),r.bounds&&(this.tileBounds=new ze(r.bounds,this.minzoom,this.maxzoom)),e.am(r.tiles),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aj(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const r=e.f.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.d(this.map._requestManager.transformRequest(n,e.R.Tile),((r,n,o,s)=>(delete t.request,t.aborted?(t.state="unloaded",i(null)):r?(t.state="errored",i(r)):n?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(n,this.map.painter),t.state="loaded",e.al(this.dispatcher),void i(null)):i(null))))}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Le extends Re{constructor(t,i,r,n){super(t,i,r,n),this.type="raster-array",this.maxzoom=22,this._options=e.e({type:"raster-array"},i)}triggerRepaint(e){const t=this.map.painter._terrain,i=this.map.style.getSourceCache(this.id);t&&t.enabled&&i&&t._clearRenderCacheForTile(i.id,e.tileID),this.map.triggerRepaint()}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),n=this.map._requestManager.transformRequest(r,e.R.Tile);t.requestParams=n,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,r,n,o)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(e){if(20===e.code)return;return t.state="errored",i(e)}this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:o}),t.state="empty",i(null)}))}unloadTile(t){const 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"}prepareTile(t,i,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(i,r,((i,r)=>{if(i)return t.state="errored",this.fire(new e.a(i)),void this.triggerRepaint(t);r&&(t.setTexture(r,this.map.painter),t.state="loaded",this.triggerRepaint(t))})))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find((({id:t})=>t===e)),i=t&&t.fields,r=i&&i.bands&&i.bands;return r?r[0]:0}getTextureDescriptor(t,i,r){if(!t)return;const n=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!n)return;let o=null;i instanceof e.aq?o=i.paint.get("raster-array-band"):i instanceof e.ar&&(o=i.paint.get("raster-particle-array-band"));const s=o||this.getInitialBand(n);if(null!=s)if(t.textureDescriptor){if(!t.updateNeeded(n,s)||r)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,n,s)}}const ke=32,Oe=33,Be=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,r=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=ke:i=r=a=ke;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=s,r=a):(i=n,r=o,n=s,o=a),s=e,a=l}const l=4*e;Be[l+0]=i,Be[l+1]=r,Be[l+2]=n,Be[l+3]=o}const Fe=new Uint16Array(2178),Ne=new Uint8Array(1089),Ve=new Uint16Array(1089);function Ue(e){return 0===e?-.03125:32===e?.03125:0}class je{constructor(e,t,i,r){this.id=je.uniqueIdxCounter,je.uniqueIdxCounter++,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||r||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=je.uniqueIdxCounter,je.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}je.uniqueIdxCounter=0;const Ge={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class qe{constructor(e,t,i,r,n,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i0&&e.vertexAttribDivisor(n,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ze{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class $e extends Ze{getDefault(){return e.aA.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class We extends Ze{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Qe extends Ze{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class He extends Ze{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Xe extends Ze{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Ye extends Ze{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Je extends Ze{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Ke extends Ze{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class et extends Ze{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class tt extends Ze{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class it extends Ze{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class rt extends Ze{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class nt extends Ze{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class ot extends Ze{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class st extends Ze{getDefault(){return e.aA.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class at extends Ze{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class lt extends Ze{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class ct extends Ze{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class ht extends Ze{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let ut=class extends Ze{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class dt extends Ze{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class pt extends Ze{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class ft extends Ze{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class mt extends Ze{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class _t extends Ze{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class gt extends Ze{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class yt extends Ze{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class xt extends Ze{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class vt extends Ze{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class bt extends Ze{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class wt extends Ze{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Tt extends Ze{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Et extends Tt{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class St extends Tt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Mt extends Tt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class At extends St{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class It{constructor(e,t,i,r,n){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();r&&(this.colorAttachment=new Et(e,o)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new St(e,o):new Mt(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}else{const t=this.depthAttachment.get();t&&e.deleteTexture(t)}e.deleteFramebuffer(this.framebuffer)}}class Ct{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}Ct.ReadOnly=!1,Ct.ReadWrite=!0,Ct.disabled=new Ct(519,Ct.ReadOnly,[0,1]);const Pt=7680;class zt{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}zt.disabled=new zt({func:519,mask:0},0,0,Pt,Pt,Pt);const Dt=771;class Rt{constructor(e,t,i,r){this.blendFunction=e,this.blendColor=t,this.mask=i,this.blendEquation=r}}Rt.Replace=[1,0,1,0],Rt.disabled=new Rt(Rt.Replace,e.aA.transparent,[!1,!1,!1,!1]),Rt.unblended=new Rt(Rt.Replace,e.aA.transparent,[!0,!0,!0,!0]),Rt.alphaBlended=new Rt([1,Dt,1,Dt],e.aA.transparent,[!0,!0,!0,!0]),Rt.multiply=new Rt([774,0,774,0],e.aA.transparent,[!0,!0,!0,!0]);const Lt=1029,kt=2305;class Ot{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Ot.disabled=new Ot(!1,Lt,kt),Ot.backCCW=new Ot(!0,Lt,kt),Ot.backCW=new Ot(!0,Lt,2304),Ot.frontCW=new Ot(!0,1028,2304),Ot.frontCCW=new Ot(!0,1028,kt);class Bt{constructor(e,t){this.gl=e,this.clearColor=new $e(this),this.clearDepth=new We(this),this.clearStencil=new Qe(this),this.colorMask=new He(this),this.depthMask=new Xe(this),this.stencilMask=new Ye(this),this.stencilFunc=new Je(this),this.stencilOp=new Ke(this),this.stencilTest=new et(this),this.depthRange=new tt(this),this.depthTest=new it(this),this.depthFunc=new rt(this),this.blend=new nt(this),this.blendFunc=new ot(this),this.blendColor=new st(this),this.blendEquation=new at(this),this.cullFace=new lt(this),this.cullFaceSide=new ct(this),this.frontFace=new ht(this),this.program=new ut(this),this.activeTexture=new dt(this),this.viewport=new pt(this),this.bindFramebuffer=new ft(this),this.bindRenderbuffer=new mt(this),this.bindTexture=new _t(this),this.bindVertexBuffer=new gt(this),this.bindElementBuffer=new yt(this),this.bindVertexArrayOES=new xt(this),this.pixelStoreUnpack=new vt(this),this.pixelStoreUnpackPremultiplyAlpha=new bt(this),this.pixelStoreUnpackFlipY=new wt(this),this.options=t?u({},t):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1]}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t,i){return new je(this,e,t,i)}createVertexBuffer(e,t,i,r,n){return new qe(this,e,t,i,r,n)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i,r){return new It(this,e,t,i,r)}clear({color:e,depth:t,stencil:i,colorMask:r}){const n=this.gl;let o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(r||[!0,!0,!0,!0])),void 0!==t&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(o)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){t(e.blendFunction,Rt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}var Ft=e.aB([{name:"a_index",type:"Int16",components:1}]);const Nt=.15000000000000002;class Vt{constructor(t,i,r,n){const o={width:r[0],height:r[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,o,s.RGBA,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,s.RGBA,{useMipmap:!1}),this.context=t,this.setParticleTextureDimension(i,n),this.lastInvalidatedAt=0}setParticleTextureDimension(t,i){if(this.particleTextureDimension===i)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const r=this.context.gl,n=i*i,o=new Uint8Array(4*n),s=.7692307692307692,a=e.aC(t.key);for(let e=0;e[[new e.P(0,0),new e.P(e.Y+1,0),new e.P(e.Y+1,e.Y+1),new e.P(0,e.Y+1),new e.P(0,0)]]};class jt{constructor(t,i,r,n,o){this.tileID=t,this.uid=e.aF(),this.uses=0,this.tileSize=i,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const i=t+this.timeAdded;it.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.fqid]=r}}return i})(t.buckets,i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.aH){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.aH&&i.hasRTLText){this.hasRTLText=!0,e.aI();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],r=i.style.getOwnLayer(e);if(!r)continue;const n=r.queryRadius(t);this.queryPadding=Math.max(this.queryPadding,n)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new e.aG}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const i=t.gl,r=this.imageAtlas;if(r&&!r.uploaded){const n=!!Object.keys(r.patternPositions).length;this.imageAtlasTexture=new e.T(t,r.image,i.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,i.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(t,this.lineAtlas.image,i.R8),this.lineAtlas.uploaded=!0)}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const r=t.style.getBrightness();(this._lastUpdatedBrightness||r)&&(this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this._lastUpdatedBrightness=r,this.updateBuckets(void 0,t)))}queryRenderedFeatures(e,t,i,r,n,o,s,a){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(t,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),o=i?i.sourceLayer:"",s=n._geojsonTileLayer||n[o];if(!s)return;const a=e.aJ(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime=0;e--){const t=4*e,i=Be[t+0],r=Be[t+1],n=Be[t+2],o=Be[t+3],s=i+n>>1,a=r+o>>1,l=s+a-r,c=a+i-s,h=r*Oe+i,u=o*Oe+n,d=a*Oe+s,p=Math.hypot((Fe[2*h+0]+Fe[2*u+0])/2-Fe[2*d+0],(Fe[2*h+1]+Fe[2*u+1])/2-Fe[2*d+1])>=16;Ne[d]=Ne[d]||(p?1:0),e<1022&&(Ne[d]=Ne[d]||Ne[(r+c>>1)*Oe+(i+l>>1)]||Ne[(o+c>>1)*Oe+(n+l>>1)])}const o=new e.ay,s=new e.az;let a=0;function l(t,i){const r=i*Oe+t;return 0===Ve[r]&&(o.emplaceBack(Fe[2*r+0],Fe[2*r+1],t*e.Y/ke,i*e.Y/ke),Ve[r]=++a),Ve[r]-1}function c(e,t,i,r,n,o){const a=e+i>>1,h=t+r>>1;if(Math.abs(e-n)+Math.abs(t-o)>1&&Ne[h*Oe+a])c(n,o,e,t,a,h),c(i,r,n,o,a,h);else{const a=l(e,t),c=l(i,r),h=l(n,o);s.emplaceBack(a,c,h)}}return c(0,0,ke,ke,ke,0),c(ke,ke,0,0,0,ke),{vertices:o,indices:s}})(this.tileID.canonical,i);n=t.vertices,o=t.indices}else{n=new e.ay,o=new e.az;for(const{x:e,y:t}of r)n.emplaceBack(e,t,0,0);const t=e.aT(n.int16,void 0,4);for(let e=0;e0&&(l=e.a9.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,n,i,s,l,a),this._makeGlobeTileDebugTextBuffer(t,n,i,s,l,a)}_globePoint(t,i,r,n,o,s,a){let l=e.aX(t,i,r);if(s){const o=1<.5?d=-1:u<-.5&&(d=1);let p=(t/e.Y+r.x)/o+d,f=(i/e.Y+r.y)/o;p=(p-c)*n._pixelsPerMercatorPixel+c,f=(f-h)*n._pixelsPerMercatorPixel+h;const m=[p*n.worldSize,f*n.worldSize,0];e.Q.transformMat4(m,m,s),l=e.aY(l,m,a)}return e.Q.transformMat4(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,i,r,n,o,s){const a=new e.aQ,l=new e.aR,c=new e.aZ,h=(e,t,h,u,d)=>{const p=(h-e)/(d-1),f=(u-t)/(d-1),m=a.length;for(let h=0;hu*e+t;for(let e=0;e0&&(l[new e.ap(t.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.a(i));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&r&&r.resourceTiming&&r.resourceTiming[this.id]&&(t.resourceTiming=r.resourceTiming[this.id]),this.fire(new e.b("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,i){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const n={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};t.request=this.actor.send(r,n,((e,n)=>(delete t.request,t.destroy(),t.aborted?i(null):e?i(e):(t.loadVectorData(n,this.map.painter,"reloadTile"===r),i(null)))),void 0,"loadTile"===r)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.as{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.at(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.a(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.a(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.as,model:class extends e.E{constructor(e,t,i,r){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t}load(){const t=[];for(const i in this._options.models){const r=this._options.models[i],n=e.l(this.map._requestManager.transformRequest(r.uri,e.R.Model).url).then((t=>{if(!t)return;const n=e.c(t),o=new e.M(i,r.position,r.orientation,n);o.computeBoundsAndApplyParent(),this.models.push(o)})).catch((t=>{this.fire(new e.a(new Error(`Could not load model ${i} from ${r.uri}: ${t.message}`)))}));t.push(n)}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((t=>{this.fire(new e.a(new Error(`Could not load models: ${t.message}`)))}))}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return{type:"model"}}},"batched-model":class extends e.E{constructor(e,t,i,r){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(r)}onAdd(e){this.map=e,this.load()}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map._worldview;this._tileJSONRequest=Pe(this._options,this.map._requestManager,i,r,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new e.a(n))):o&&(e.e(this,o),o.bounds&&(this.tileBounds=new ze(o.bounds,this.minzoom,this.maxzoom)),e.am(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(r,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=i;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",n,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);function o(e,r){return t.aborted?i(null):e&&404!==e.status?i(e):(r&&(r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(r),t.buckets=u(u({},t.buckets),r.buckets),r.featureIndex&&(t.latestFeatureIndex=r.featureIndex)),t.state="loaded",void i(null))}}serialize(){return e.e({},this._options)}},canvas:class extends e.as{constructor(t,i,r,n){super(t,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.a(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.a(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.a(new e.V(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.a(new e.V(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.a(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.a(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.au||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.E{constructor(t,i,r,n){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=i,this.setEventedParent(n),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.a(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.a(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ze(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),e.e(this,e.af(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.af(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:r,z:n}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:r,z:n},{signal:o.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):(function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement})(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((i=>{20!==i.code&&(e.state="errored",t(i))})),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this._map.painter)}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this._map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:r}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:r})}i()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){const t=e.aj(this.id,this.scope);this._map.style.clearSource(t)}_update(){this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))}}},qt=function(t,i,r,n){const o=new Gt[i.type](t,i,r,n);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.a$(["load","abort","unload","serialize","prepare"],o),o};function Zt(t,i){const r=e.a9.identity([]);return e.a9.scale(r,r,[.5*t.width,.5*-t.height,1]),e.a9.translate(r,r,[1,-1,0]),e.a9.multiply(r,r,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(r)}function $t(e,t,i,r,n,o,s,a=!1){const l=e.tilesIn(r,s,a);l.sort(Qt);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r,n,o,Zt(e.transform,r.tile.tileID),a)});const h=(function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t})(c);for(const t in h)h[t].forEach((t=>{const i=t.feature,r=i.layer;r&&"background"!==r.type&&"sky"!==r.type&&"slot"!==r.type&&(i.source=r.source,r["source-layer"]&&(i.sourceLayer=r["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(r["source-layer"],i.id):{})}));return h}function Wt(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],n={};for(let e=0;e{if(e)i(e);else try{const e=r.getHeaderLength(n);if(e>t)return void(this.request=this.fetchHeader(e,i));r.parseHeader(n),this._isHeaderLoaded=!0;let a=0;for(const e of Object.values(r.layers))a=Math.max(a,e.dataIndex[e.dataIndex.length-1].last_byte);n.byteLength>=a&&(this.entireBuffer=n),i(null,this.entireBuffer||n,o,s)}catch(e){i(e)}})),this.request}fetchBand(t,i,r){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void r(new Error("Tile header is not ready"));const o=this.actor;if(!o)return void r(new Error("Can't fetch tile band without an actor"));let s;const a=(e,n)=>{s.complete(e,n),e?r(e):(this.updateTextureDescriptor(t,i),r(null,this.textureDescriptor&&this.textureDescriptor.img))},l=(e,t)=>{if(e)return r(e);const i=o.send("decodeRasterArray",{buffer:t,task:s},a,void 0,!0);this._workQueue.push((()=>{i&&i.cancel(),s.cancel()}))},c=n.getLayer(t);if(!c)return void r(new Error(`Unknown sourceLayer "${t}"`));if(c.hasDataForBand(i))return this.updateTextureDescriptor(t,i),void r(null,this.textureDescriptor?this.textureDescriptor.img:null);const h=c.getDataRange([i]);if(s=n.createDecodingTask(h),!s||s.tasks.length)if(this.flushQueues(),this.entireBuffer)l(null,this.entireBuffer.slice(h.firstByte,h.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${h.firstByte}-${h.lastByte}`}}),i=e.b1(t,l);this._fetchQueue.push((()=>{i.cancel(),s.cancel()}))}else r(null)}updateNeeded(e,t){return(!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}updateTextureDescriptor(t,i){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(i)||!r.hasDataForBand(i))return;const{bytes:n,tileSize:o,buffer:s,offset:a,scale:l}=r.getBandView(i),c=o+2*s,h={data:n,width:c,height:c},u=this.texture;u&&u instanceof e.T&&u.update(h,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:i,img:h,buffer:s,offset:a,tileSize:o,format:r.pixelFormat,mix:[l,256*l,65536*l,16777216*l]}}}class Xt{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class Yt extends e.E{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),t.on("error",(()=>{this._sourceErrored=!0})),this._source=t,this._tiles={},this._cache=new Xt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new T,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return e.b2(this._tiles).map((e=>e.tileID)).sort(Jt).map((e=>e.key))}getRenderableIds(t,i){const r=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&r.push(this._tiles[e]);return t?r.sort(((t,i)=>{const r=t.tileID,n=i.tileID,o=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),s=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x})).map((e=>e.tileID.key)):r.map((e=>e.tileID)).sort(Jt).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)))}_tileLoaded(t,i,r,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new e.a(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new e.b("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=e.f.now(),"expired"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new e.b("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(t,i,r,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!r)return;let o;if(this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain)if(this._source.tileID)o=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.ap(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,o=n.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoom<=1&&"globe"===t.projection.name&&(o.push(new e.ap(1,0,1,0,0)),o.push(new e.ap(1,0,1,1,0)),o.push(new e.ap(1,0,1,0,1)),o.push(new e.ap(1,0,1,1,1)))}else o=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter((e=>this._source.hasTile(e))));else o=[];if(o.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Kt(this._source.type)){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!r}),s=Math.min(e,this._source.maxzoom),a=t.extendTileCoverForShadows(o,n,s);for(const e of a)this._shadowCasterTiles[e.key]=!0,o.push(e)}const s=this._updateRetainedTiles(o);if(Kt(this._source.type)&&0!==o.length){const t={},i={},r=Object.keys(s);for(const n of r){const r=s[n],o=this._tiles[n];if(!o||o.fadeEndTime&&o.fadeEndTime<=e.f.now())continue;const a=this.findLoadedParent(r,Math.max(r.overscaledZ-Yt.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),i[n]=r}const n=o[o.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(s[e]||!t.hasData())continue;let r=t.tileID;for(;r.overscaledZ>n;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&i[r.key]){s[e]=t.tileID;break}}}for(const e in t)s[e]||(this._coveredTiles[e]=!0,s[e]=t[e])}for(const e in s)this._tiles[e].clearFadeHold();const a=e.b3(this._tiles,s);for(const e of a){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},r=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-Yt.maxOverzooming,this._source.minzoom),s=Math.max(n+Yt.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(t){let i=this._tiles[t.key];if(i)return!0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const r=Boolean(i);if(!r){const e=this.map?this.map.painter:null,r=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new Ht(t,r,this.transform.tileZoom,e,this._isRaster):new jt(t,r,this.transform.tileZoom,e,this._isRaster),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state))}return i?(i.uses++,this._tiles[t.key]=i,r||this._source.fire(new e.b("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),i))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,i,r){const n=[],o=this.transform;if(!o)return n;const s="globe"===o.projection.name,a=e.a8(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(r&&c.clearQueryDebugViz(),c.holdingForFade())continue;let h;if(s){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.ad(a,...ei(t,-1))-a),Math.abs(e.ad(a,...ei(t,1))-a)];h=[0,2*i.indexOf(Math.min(...i))-1]}else{const i=[Math.abs(e.ad(a,...ei(t,-1))-a),Math.abs(e.ad(a,...ei(t,0))-a),Math.abs(e.ad(a,...ei(t,1))-a)];h=[i.indexOf(Math.min(...i))-1]}}else h=[0];for(const e of h){const r=t.containsTile(c,o,i,e);r&&n.push(r)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map((e=>this._tiles[e].tileID)),r="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=r?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,r=this.transform._camera.forward(),n={};for(const e of t){const t=1/(1<n[e.key]-n[t.key])),t}hasTransition(){if(this._source.hasTransition())return!0;if(Kt(this._source.type))for(const t in this._tiles){const i=this._tiles[t];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=e.f.now())return!0}return!1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i)}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)))}_preloadTiles(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i))};return void this._source.on("data",e)}const r=new Map,n=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of n){const t=e.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)r.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const a=Array.from(r.values());e.b4(a,((e,t)=>{const i=new jt(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)}))}),i)}}function Jt(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Kt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function ei(e,t){const i=1<0:"model"===i.type&&(r=!i.isHidden(e)&&i.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!r&&t.visible,t.visible=r}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,r=this.style.getLayerSourceCache(i);let n=1;"fill-extrusion"===i.type&&(n=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0);let o=r?r.getTile(t):null;if(!o&&r&&t.canonical.z>r.getSource().minzoom){let e=t.scaledTo(Math.min(r.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=r.getSource().minzoom&&(o=r.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:n})}e.hasAnyZOffset=!1;let i=!1;for(let r=0;r{e in i&&(r[e]=i[e])})),r}function ri(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class pi{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let e=0;e0:s}_queryCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[h]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[h],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const h=this.circleCells[n];if(null!==h){const n=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],e,t,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[h],t=n[h+1],i=n[h+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,h=this.boxCells[n];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const u=this.circleCells[n];if(null!==u){const e=this.circles;for(const t of u)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(s-n)/2,h=Math.abs(t-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}const fi={unknown:0,flipRequired:1,flipNotRequired:2},mi=Math.tan(85*Math.PI/180);function _i(t,i,r,n,o,s,a){const l=e.a9.create();if(r)if("globe"===s.name){const t=e.b6(o,i);e.a9.multiply(l,l,t)}else{const t=e.b7.invert([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],n||e.a9.rotateZ(l,l,o.angle)}else e.a9.multiply(l,o.labelPlaneMatrix,t);return l}function gi(e,t,i,r,n,o,s){const a=_i(e,t,i,r,n,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function yi(t,i,r,n,o,s,a){if(r){if("globe"===s.name){const l=_i(t,i,r,n,o,s,a);return e.a9.invert(l,l),e.a9.multiply(l,t,l),l}{const i=e.a9.clone(t),r=e.a9.identity([]);return r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3],e.a9.multiply(i,i,r),n||e.a9.rotateZ(i,i,-o.angle),i}}return o.glCoordMatrix}function xi(t,i,r,n){const o=[t,i,r,1];r?e.aa.transformMat4(o,o,n):Pi(o,o,n);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function vi(e,t){return Math.min(.5+e/t*.5,1.5)}function bi(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function wi(t,i,r,n,o,s,a,l,c,h){const u=r.transform,d=n?t.textSizeData:t.iconSizeData,p=e.b8(d,r.transform.zoom),f="globe"===u.projection.name,m=[256/r.width*2+1,256/r.height*2+1],_=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=n?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,x=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,v=r.transform.width/r.transform.height;let b,w=!1;for(let n=0;nMath.abs(r)?{useVertical:!0}:t===e.b9.vertical?n>0?{needsFlipping:!0}:null:i!==fi.unknown&&(function(e,t){return 0===e||Math.abs(t/e)>mi})(r,n)?i===fi.flipRequired?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function Si(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=i/24,b=t.lineOffsetX*v,w=t.lineOffsetY*v,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:S,segment:M,writingMode:A,flipState:I}=t,C=T+t.lineLength,P=t=>{if(u){const[i,r,n]=t.up,o=h.length;e.bb(u,o+0,i,r,n),e.bb(u,o+1,i,r,n),e.bb(u,o+2,i,r,n),e.bb(u,o+3,i,r,n)}const[i,r,n]=t.point;e.bc(h,i,r,n,t.angle)};if(S>1){const e=Ti(v,l,b,w,r,d,p,t,c,s,f,_,!1,g,y,x);if(!e)return{notEnoughRoom:!0};if(n&&!r){let[i,r,n]=e.first.point,[o,s,l]=e.last.point;[i,r]=xi(i,r,n,a),[o,s]=xi(o,s,l,a);const c=Ei(A,I,(o-i)*m,s-r);if(t.flipState=c&&c.needsFlipping?fi.flipRequired:fi.flipNotRequired,c)return c}P(e.first);for(let e=E+1;e0?s:Ai(p,n,i,1,o,void 0,g,y.canonical),l=Ei(A,I,(a[0]-i[0])*m,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?fi.flipRequired:fi.flipNotRequired,l)return l}const i=Ii(v*l.getoffsetX(E),b,w,r,d,p,M,T,C,c,s,f,_,!1,!1,g,y,x);if(!i)return{notEnoughRoom:!0};P(i)}return{}}function Mi(e,t,i,r,n){const{x:o,y:s,z:a}=r.projectTilePoint(e.x,e.y,t);if(!n)return xi(o,s,a,i);const[l,c,h]=n(e);return xi(o+l,s+c,a+h,i)}function Ai(t,i,r,n,o,s,a,l){const c=Mi(t.sub(i)._unit()._add(t),l,o,a,s);return e.Q.sub(c,r,c),e.Q.normalize(c,c),e.Q.scaleAndAdd(c,r,c,n)}function Ii(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=n?t-i:t+i;let v=x>0?1:-1,b=0;n&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=l+a+(v>0?0:1)|0,T=o,E=o,S=0,M=0;const A=Math.abs(x),I=[],C=[];let P=s,z=P;const D=()=>Ai(z,P,E,A-S+1,u,p,_,g.canonical);for(;S+M<=A;){if(w+=v,w=c)return null;if(E=T,z=P,I.push(E),f&&C.push(z),P=new e.P(h.getx(w),h.gety(w)),T=d[w],!T){const e=Mi(P,g.canonical,u,_,p);T=e[3]>0?d[w]=e:D()}S+=M,M=e.Q.distance(E,T)}m&&p&&(d[w]&&(T=D(),M=e.Q.distance(E,T)),d[w]=T);const R=(A-S)/M,L=P.sub(z)._mult(R)._add(z),k=e.Q.sub([],T,E),O=e.Q.scaleAndAdd([],E,k,R);let B=[0,0,1],F=k[0],N=k[1];if(y&&(B=_.upVector(g.canonical,L.x,L.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],i=e.Q.cross([],B,t);e.Q.normalize(t,t),e.Q.normalize(i,i),F=e.Q.dot(k,t),N=e.Q.dot(k,i)}if(r){const t=e.Q.cross([],B,k);e.Q.normalize(t,t),e.Q.scaleAndAdd(O,O,t,r*v)}const V=b+Math.atan2(N,F);return I.push(O),f&&C.push(L),{point:O,angle:V,path:I,tilePath:C,up:B}}function Ci(e,t){const i=t.length,r=i+4*e;t.resize(r),t.float32.fill(-1/0,4*i,4*r)}function Pi(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const zi=100;class Di{constructor(e,t,i=new pi(e.width+200,e.height+200,25),r=new pi(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+zi,this.screenBottomBoundary=e.height+zi,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,i,r,n,o,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const u=i.elevation,d=i.tileID,p=e.getProjection();if(u&&d){const[e,t,r]=p.upVector(d.canonical,i.tileAnchorX,i.tileAnchorY),n=p.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*u*n,c+=t*u*n,h+=r*u*n}const f=this.projectAndGetPerspectiveRatio(s,l,c,h,i.tileID,"globe"===p.name||!!u||this.transform.pitch>0,p),m=o*f.perspectiveRatio,_=(i.x1*t+r.x-i.padding)*m+f.point.x,g=(i.y1*t+r.y-i.padding)*m+f.point.y,y=(i.x2*t+r.x+i.padding)*m+f.point.x,x=(i.y2*t+r.y+i.padding)*m+f.point.y,v=f.perspectiveRatio<=.55||f.occluded;return!this.isInsideGrid(_,g,y,x)||!n&&this.grid.hitTest(_,g,y,x,a)||v?{box:[],offscreen:!1,occluded:f.occluded}:{box:[_,g,y,x],offscreen:this.isOffscreen(_,g,y,x),occluded:!1}}placeCollisionCircles(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=[],g=this.transform.elevation,y=t.getProjection(),x=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,v=new e.P(r.tileAnchorX,r.tileAnchorY);let{x:b,y:w,z:T}=y.projectTilePoint(v.x,v.y,m.canonical);if(x){const[e,t,i]=x(v);b+=e,w+=t,T+=i}const E="globe"===y.name,S=this.projectAndGetPerspectiveRatio(a,b,w,T,m,E||!!g||this.transform.pitch>0,y),{perspectiveRatio:M}=S,A=(u?s/M:s*M)/e.bf,I=xi(b,w,T,l),C=S.signedDistanceFromCamera>0?Ti(A,o,r.lineOffsetX*A,r.lineOffsetY*A,!1,I,v,r,n,l,{},g&&!u?x:null,u&&!!g,y,m,u):null;let P=!1,z=!1,D=!0;if(C&&!S.occluded){const t=.5*p*M+f,r=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new di,{first:s,last:a}=C,l=s.path.length;let u=[];for(let e=l-1;e>=1;e--)u.push(s.path[e]);for(let e=1;e(x&&!E&&(i=x(re[3]<=0))&&(u=[]));let g=[];if(u.length>0){let t=1/0,i=-1/0,o=1/0,s=-1/0;for(const e of u)t=Math.min(t,e[0]),o=Math.min(o,e[1]),i=Math.max(i,e[0]),s=Math.max(s,e[1]);i>=r.x&&t<=n.x&&s>=r.y&&o<=n.y&&(g=[u.map((t=>new e.P(t[0],t[1])))],(tn.x||on.y)&&(g=e.bd(g,r.x,r.y,n.x,n.y)))}for(const e of g){o.reset(e,.25*t);let r=0;r=o.length<=.5*t?1:Math.ceil(o.paddedLength/m)+1;for(let e=0;e0){if(e.aa.transformMat4(l,l,t),this.fogState&&o&&"globe"!==a.name){const t=(function(t,i,r,n,o,s){const a=s.calculateFogTileMatrix(o),l=[i,r,n];return e.Q.transformMat4(l,l,a),ge(t,e.Q.length(l),s.pitch,s._fov)})(this.fogState,i,r,n,o.toUnwrapped(),this.transform);c=t>.9}}else Pi(l,l,t);const h=l[3];return{point:new e.P((l[0]/h+1)/2*this.transform.width+zi,(-l[1]/h+1)/2*this.transform.height+zi),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/h*.5,1.5),signedDistanceFromCamera:h,occluded:s&&l[2]>h||c}}isOffscreen(e,t,i,r){return i=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function ji(t,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=e.bi(t),l=-(s-.5)*i,c=-(a-.5)*r,h=e.bh(t,n);return new e.P(l+h[0]*o,c+h[1]*o)}function Gi(t,i,r,n,o){const s=new e.P(t,i);return r&&s._rotate(n?o:-o),s}class qi{constructor(e,t,i,r,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new Di(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Ui(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,r,n){const o=r.getBucket(i),s=r.latestFeatureIndex;if(!o||!s||i.fqid!==o.layerIds[0])return;const a=o.layers[0].layout,l=r.collisionBoxArray,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),h=r.tileSize/e.Y,u=r.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(p=r.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(p.toUnwrapped()):Ri(m,f,p));var p,f,m;const _="map"===a.get("text-pitch-alignment"),g="map"===a.get("text-rotation-alignment");i.compileFilter();const y=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),v=this.transform.calculatePixelsToTileUnitsMatrix(r),b=gi(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),v);let w=null;if(_){const t=yi(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),v);w=e.a9.multiply([],this.transform.labelPlaneMatrix,t)}let T=null;y&&r.latestFeatureIndex&&(T={unwrappedTileID:u,dynamicFilter:y,dynamicFilterNeedsFeature:x,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new Vi(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,r.tileID);const E={bucket:o,layout:a,posMatrix:d,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:h,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.b8(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.b8(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const e of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:E})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:E})}attemptAnchorPlacement(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const{textOffset0:y,textOffset1:x,crossTileID:v}=u,b=[y,x],w=ji(e,i,r,b,n),T=this.collisionIndex.placeCollisionBox(p,n,t,Gi(w.x,w.y,o,s,this.transform.angle),h,a,l,c.predicate);if(m){const e=p.getSymbolInstanceIconSize(g,this.transform.zoom,u.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(p,e,m,Gi(w.x,w.y,o,s,this.transform.angle),h,a,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[v]&&this.prevPlacement.placements[v]&&this.prevPlacement.placements[v].text&&(t=this.prevPlacement.variableOffsets[v].anchor),this.variableOffsets[v]={textOffset:b,width:i,height:r,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(p,e,u,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,u),this.placedOrientations[v]=f),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,r,n){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:h,textPixelRatio:u,holdingForFade:d,collisionBoxArray:p,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=t.parameters,g=s.get("text-optional"),y=s.get("icon-optional"),x=s.get("text-allow-overlap"),v=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="viewport-y"===s.get("symbol-z-order"),E=s.get("symbol-z-elevate");this.transform.setProjection(o.projection);let S=x&&(v||!o.hasIconData()||y),M=v&&(x||!o.hasTextData()||g);!o.collisionArrays&&p&&o.deserializeCollisionBoxes(p),r&&n&&o.updateCollisionDebugBuffers(this.transform.zoom,p);const A=(t,n,p)=>{const{crossTileID:T,numVerticalGlyphVertices:E}=t;if(h){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let n=null;if(h.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];n=h.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,h.dynamicFilter)(r,n,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(h.unwrappedTileID)))return this.placements[T]=new Fi(!1,!1,!1,!0),void i.add(T)}if(i.has(T))return;if(d)return void(this.placements[T]=new Fi(!1,!1,!1));let A=!1,I=!1,C=!0,P=!1,z=!1,D=null,R={box:null,offscreen:null,occluded:null},L={box:null,offscreen:null,occluded:null},k=null,O=null,B=null,F=0,N=0,V=0;p.textFeatureIndex?F=p.textFeatureIndex:t.useRuntimeCollisionCircles&&(F=t.featureIndex),p.verticalTextFeatureIndex&&(N=p.verticalTextFeatureIndex);const U=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const i=this.transform.elevation;e.elevation=t.zOffset+(i?i.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0)},j=p.textBox;if(j){U(j);const i=i=>{let r=e.b9.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[T];e&&(this.placedOrientations[T]=e,r=e,this.markUsedOrientation(o,r,t))}return r},r=(t,i)=>{if(o.allowVerticalPlacement&&E>0&&p.verticalTextBox){for(const r of o.writingModes)if(r===e.b9.vertical?(R=i(),L=R):R=t(),R&&R.box&&R.box.length)break}else R=t()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor))}const c=(e,i,r)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),c=(e.x2-e.x1)*s+2*e.padding,h=(e.y2-e.y1)*s+2*e.padding,d=t.hasIconTextFit&&!v?i:null;d&&U(d);let p={box:[],offscreen:!1,occluded:!1};const g=x?2*l.length:l.length;for(let i=0;i=l.length,t,n,o,r,d,f,m);if(g&&(p=g.placedGlyphBoxes,p&&p.box&&p.box.length)){A=!0,D=g.shift;break}}return p};r((()=>c(j,p.iconBox,e.b9.horizontal)),(()=>{const t=p.verticalTextBox;return t&&U(t),o.allowVerticalPlacement&&!(R&&R.box&&R.box.length)&&E>0&&t?c(t,p.verticalIconBox,e.b9.vertical):{box:null,offscreen:null,occluded:null}})),R&&(A=R.box,C=R.offscreen,P=R.occluded);const h=i(!(!R||!R.box));if(!A&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[T];e&&(this.variableOffsets[T]=e,this.markUsedJustification(o,e.anchor,t,h))}}else{const s=(i,r)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(o,s,i,new e.P(0,0),x,u,a,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,r,t),this.placedOrientations[T]=r),l};r((()=>s(j,e.b9.horizontal)),(()=>{const t=p.verticalTextBox;return o.allowVerticalPlacement&&E>0&&t?(U(t),s(t,e.b9.vertical)):{box:null,offscreen:null,occluded:null}})),i(!!(R&&R.box&&R.box.length))}}if(k=R,A=k&&k.box&&k.box.length>0,C=k&&k.offscreen,P=k&&k.occluded,t.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),n=e.ba(o.textSizeData,f,i),h=s.get("text-padding");O=this.collisionIndex.placeCollisionCircles(o,x,i,o.lineVertexArray,o.glyphOffsetArray,n,a,l,c,r,w,_.predicate,t.collisionCircleDiameter*n/e.bf,h,this.retainedQueryData[o.bucketInstanceId].tileID),A=x||O.circles.length>0&&!O.collisionDetected,C=C&&O.offscreen,P=O.occluded}if(p.iconFeatureIndex&&(V=p.iconFeatureIndex),p.iconBox){const i=i=>{U(i);const r=t.hasIconTextFit&&D?Gi(D.x,D.y,b,w,this.transform.angle):new e.P(0,0),n=o.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,n,i,r,v,u,a,_.predicate)};L&&L.box&&L.box.length&&p.verticalIconBox?(B=i(p.verticalIconBox),I=B.box.length>0):(B=i(p.iconBox),I=B.box.length>0),C=C&&B.offscreen,z=B.occluded}const G=g||0===t.numHorizontalGlyphVertices&&0===E,q=y||0===t.numIconVertices;if(G||q?q?G||(I=I&&A):A=I&&A:I=A=I&&A,A&&k&&k.box&&this.collisionIndex.insertCollisionBox(k.box,s.get("text-ignore-placement"),o.bucketInstanceId,L&&L.box&&N?N:F,_.ID),I&&B&&this.collisionIndex.insertCollisionBox(B.box,s.get("icon-ignore-placement"),o.bucketInstanceId,V,_.ID),O&&(A&&this.collisionIndex.insertCollisionCircles(O.circles,s.get("text-ignore-placement"),o.bucketInstanceId,F,_.ID),r)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new Ni);for(let e=0;e=0;--e){const i=t[e];A(o.symbolInstances.get(i),i,o.collisionArrays[i])}o.hasAnyZOffset&&e.w(`${o.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(o.hasAnyZOffset){const e=o.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(o).crossTileID=u>=0&&o!==u?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=u>=0&&s!==u?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=u>=0&&a!==u?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=u>=0&&l!==u?0:c)}markUsedOrientation(t,i,r){const n=i===e.b9.horizontal||i===e.b9.horizontalOnly?i:0,o=i===e.b9.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=r,h=t.text.placedSymbolArray;s>=0&&(h.get(s).placedOrientation=n),a>=0&&(h.get(a).placedOrientation=n),l>=0&&(h.get(l).placedOrientation=n),c>=0&&(h.get(c).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new Bi(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Bi(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new Bi(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i=new Set;for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,i,r.collisionBoxArray),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,r.tileID),t.updateZOffset()))}}updateBucketOpacities(t,i,r){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const n=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),s=new Bi(null,0,!1,!1,!0),a=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),c=n.get("text-variable-anchor"),h="map"===n.get("text-rotation-alignment"),u="map"===n.get("text-pitch-alignment"),d=new Bi(null,0,a&&(l||!t.hasIconData()||n.get("icon-optional")),l&&(a||!t.hasTextData()||n.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const p=(e,t,i)=>{for(let r=0;r0||l>0,v=_>0,b=this.placedOrientations[m],w=b===e.b9.vertical,T=b===e.b9.horizontal||b===e.b9.horizontalOnly;if(!x&&!v||y.isHidden()||f++,x){const e=Ki(y.text);p(t.text,a,w?er:e),p(t.text,l,T?er:e);const i=y.text.isHidden(),{leftJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:c}=n,h=t.text.placedSymbolArray,u=i||w?1:0;r>=0&&(h.get(r).hidden=u),o>=0&&(h.get(o).hidden=u),s>=0&&(h.get(s).hidden=u),c>=0&&(h.get(c).hidden=i||T?1:0);const d=this.variableOffsets[m];d&&this.markUsedJustification(t,d.anchor,n,b);const f=this.placedOrientations[m];f&&(this.markUsedJustification(t,"left",n,f),this.markUsedOrientation(t,f,n))}if(v){const e=Ki(y.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:r}=n,o=t.icon.placedSymbolArray,s=y.icon.isHidden()?1:0;i>=0&&(p(t.icon,_,w?er:e),o.get(i).hidden=s),r>=0&&(p(t.icon,n.numVerticalIconVertices,T?er:e),o.get(r).hidden=s)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let r=new e.P(0,0),s=!0;if(i.textBox||i.verticalTextBox){if(c){const e=this.variableOffsets[m];e?(r=ji(e.anchor,e.width,e.height,e.textOffset,e.textScale),h&&r._rotate(u?this.transform.angle:-this.transform.angle)):s=!1}o&&(s=!y.clipped),i.textBox&&Zi(t.textCollisionBox.collisionVertexArray,y.text.placed,!s||w,r.x,r.y),i.verticalTextBox&&Zi(t.textCollisionBox.collisionVertexArray,y.text.placed,!s||T,r.x,r.y)}const a=s&&Boolean(!T&&i.verticalIconBox);i.iconBox&&Zi(t.iconCollisionBox.collisionVertexArray,y.icon.placed,a,n.hasIconTextFit?r.x:0,n.hasIconTextFit?r.y:0),i.verticalIconBox&&Zi(t.iconCollisionBox.collisionVertexArray,y.icon.placed,!a,n.hasIconTextFit?r.x:0,n.hasIconTextFit?r.y:0)}}}if(t.fullyClipped=0===f,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Zi(e,t,i,r,n){e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0)}const $i=Math.pow(2,25),Wi=Math.pow(2,24),Qi=Math.pow(2,17),Hi=Math.pow(2,16),Xi=Math.pow(2,9),Yi=Math.pow(2,8),Ji=Math.pow(2,1);function Ki(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*$i+t*Wi+i*Qi+t*Hi+i*Xi+t*Yi+i*Ji+t}const er=0;class tr{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,t,i,r,n){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex{const t=e.f.now()-o;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const o=i[t[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===o.type&&(!o.minzoom||o.minzoom<=a)&&(!o.maxzoom||o.maxzoom>a)){const t=o,i=t.layout.get("symbol-z-elevate"),a=this._inProgressLayer=this._inProgressLayer||new tr(t),l=e.aj(o.source,o.scope);if(a.continuePlacement(i?n[l]:r[l],this.placement,this._showCollisionBoxes,o,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const rr=512/e.Y/2;class nr{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this.index=new e.bj(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const n=t.canonical.x*e.Y,o=t.canonical.y*e.Y;for(let e=0;ee.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}class lr{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=e.X(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.X(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=e.X(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=e.X(t.right,i.right,r)),this}getCenter(t,i){const r=e.ad((this.left+t-this.right)/2,0,t),n=e.ad((this.top+i-this.bottom)/2,0,i);return new e.P(r,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new lr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function cr(t,i){const r=e.bn(t,3);e.a9.fromQuat(t,i),e.bp(t,3,r)}function hr(t,i){const r=e.bl.identity([]);return e.bl.rotateZ(r,r,-i),e.bl.rotateX(r,r,-t),r}function ur(t,i){const r=[t[0],t[1],0],n=[i[0],i[1],0];if(e.Q.length(r)>=1e-15){const t=e.Q.normalize([],r);e.Q.scale(n,t,e.Q.dot(n,t)),i[0]=n[0],i[1]=n[1]}const o=e.Q.cross([],i,t);if(e.Q.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return hr(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class dr{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.O?t:new e.O(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bk(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const r=this.position,n=this._elevation?this._elevation.getAtPointOrZero(e.O.fromLngLat(t)):0,o=e.O.fromLngLat(t,n),s=[o.x-r.x,o.y-r.y,o.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=ur(s,i)}setPitchBearing(t,i){this.orientation=hr(e.bm(t),e.bm(-i))}}class pr{constructor(t,i){this._transform=e.a9.identity([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.O(t[0],t[1],t[2])}get position(){const t=e.bn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.bp(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.bl.identity([]),t&&cr(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=hr(e,t),cr(this._transform,this._orientation)}forward(){const t=e.bn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.bn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.bn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const r=new Float64Array(16);return e.a9.invert(r,this.getWorldToCamera(t,i)),r}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,r){const n=this.position;e.Q.scale(n,n,-t);const o=new Float64Array(16);return e.a9.fromScaling(o,[r,r,r]),e.a9.translate(o,o,n),o[10]*=i,o}getWorldToCamera(t,i){const r=new Float64Array(16),n=new Float64Array(4),o=this.position;return e.bl.conjugate(n,this._orientation),e.Q.scale(o,o,-t),e.a9.fromQuat(r,n),e.a9.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=i,r[9]*=i,r[10]*=i,r[11]*=i,r}getCameraToClipPerspective(t,i,r,n){const o=new Float64Array(16);return e.a9.perspective(o,t,i,r,n),o}getCameraToClipOrthographic(t,i,r,n,o,s){const a=new Float64Array(16);return e.a9.ortho(a,t,i,r,n,o,s),a}getDistanceToElevation(t,i=!1){const r=0===t?0:e.bo(t,i?e.ax(this.position[1]):this.position[1]),n=this.forward();return(r-this.position[2])/n[2]}clone(){return new pr([...this.position],[...this.orientation])}}const fr=(e,t,i)=>(1-i)*e+i*t,mr=e=>e*e*e*e*e;class _r{constructor(t,i,r,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=null==r?0:r,this._maxPitch=null==n?60:n,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.bq(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new lr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new pr,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1}clone(){const e=new _r(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.af(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=e.br(this.projectionOptions);const n=!t(r,this.getProjection());return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.br({name:"mercator"});const i=t!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.bo(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bk(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const i=-t*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=e.b7.create(),e.b7.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.ad(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.bm(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e)}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s0,h=t.y+10,d=r.wrap-(c?0:1),p=r.wrap+(l?0:1),f=c?t.x-1:a-1,m=l?t.x+1:0;i[0]<0?(n.push(new e.ap(o,p,t.z,m,t.y)),i[1]<0&&h&&(n.push(new e.ap(o,s,t.z,t.x,t.y+1)),n.push(new e.ap(o,p,t.z,m,t.y+1))),i[1]>0&&u&&(n.push(new e.ap(o,s,t.z,t.x,t.y-1)),n.push(new e.ap(o,p,t.z,m,t.y-1)))):i[0]>0?(n.push(new e.ap(o,d,t.z,f,t.y)),i[1]<0&&h&&(n.push(new e.ap(o,s,t.z,t.x,t.y+1)),n.push(new e.ap(o,d,t.z,f,t.y+1))),i[1]>0&&u&&(n.push(new e.ap(o,s,t.z,t.x,t.y-1)),n.push(new e.ap(o,d,t.z,f,t.y-1)))):i[1]<0&&h?n.push(new e.ap(o,s,t.z,t.x,t.y+1)):u&&n.push(new e.ap(o,s,t.z,t.x,t.y-1))}if(n.length>1){n.sort(((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y));let e=0,t=0;for(;te.isChildOf(t)))||o.push(e);return n=o.filter((e=>!t.some((t=>!!(e.overscaledZt.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=25e-6,r=new e.O(t.x+i,t.y,t.z),n=new e.O(t.x,t.y+i,t.z),o=t.toLngLat(),s=r.toLngLat(),a=n.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),h=this.locationCoordinate(a),u=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(h.x-l.x,h.y-l.y);return Math.sqrt(u*d)*T/i},S=t=>{const i=b,r=w;return{aabb:e.bx(this,c,0,0,0,t,r,i,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:i,wrap:t,fullyVisible:!1}},M=[];let A=[];const I=i,C=t.reparseOverscaled?r:i,P=e=>e*e,z=P((_-this._centerAltitude)*m),D=e=>{if(!this._elevation||!e.tileID||!s)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=R(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},R=t=>{if(t.zoom=.9)return!0}else if(o&&(s=P(t.aabb.distanceZ(g)*m)),this.projection.isReprojectedInTileSpace&&r<=5){const i=Math.pow(2,t.zoom),r=E(new e.O((t.x+.5)/i,(t.y+.5)/i));a=r>.85?1:r}const c=i*i+n*n+s,h=P((1<{if(t*P(.707)0;){const r=M.pop(),n=r.x,a=r.y;let l=r.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===r.y||r.y===(1<>1),d={aabb:s?r.aabb.quadrant(t):e.bx(this,c,r.zoom+1,i,h,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:i,y:h,wrap:r.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};o&&!u&&(d.tileID=new e.ap(r.zoom+1===I?C:r.zoom+1,r.wrap,r.zoom+1,i,h),D(d)),M.push(d)}else{const o=r.zoom===I?C:r.zoom;if(t.minzoom&&t.minzoom>o)continue;if(!l){let t=y?r.aabb.intersectsPrecise(p):r.aabb.intersectsPreciseFlat(p);if(0===t&&d()){const i=new e.bv(r.zoom,n,a);t=e.bw(this,c,i,!0).intersectsPrecise(p)}if(0===t)continue}const s=h[0]-(.5+n+(r.wrap<{const o=[0,0,0,1],s=[e.Y,e.Y,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());e.aa.transformMat4(o,o,a),e.aa.transformMat4(s,s,a);const l=e.aa.min([],o,s),c=e.aa.max([],o,s),h=e.by(l,c);if(0===h)return!0;let u=!1;const d=this._elevation;if(d&&h>i&&0!==r){const i=this.calculateProjMatrix(n.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(n.tileID)),o||(o={min:w,max:b});const s=e.bK(this.rotation),a=[s[0]*e.Y,s[1]*e.Y,o.max];e.Q.transformMat4(a,a,i),u=(1-a[1])*this.height*.5e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const i=e.ad(t.lat,-e.bz,e.bz),r=this.projection.project(t.lng,i);return new e.P(r.x*this.worldSize,r.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.bo(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let r,n;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;r=(i.x-o.x)/e,n=(i.y-o.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(o);r=e.x-t.x,n=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.O(s.x-r,s.y-n))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,i){const r=i?e.bo(i,t.lat):void 0,n=this.projection.project(t.lng,t.lat);return new e.O(n.x,n.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const r=null!=i?i:this._centerAltitude,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.aa.transformMat4(n,n,this.pixelMatrixInverse),e.aa.transformMat4(o,o,this.pixelMatrixInverse);const s=o[3];e.aa.scale(n,n,1/n[3]),e.aa.scale(o,o,1/s);const a=n[2],l=o[2];return{p0:n,p1:o,t:a===l?0:(r-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.aa.transformMat4(i,i,this.pixelMatrixInverse),e.aa.transformMat4(r,r,this.pixelMatrixInverse),e.aa.scale(i,i,1/i[3]),e.aa.scale(r,r,1/r[3]),i[2]=e.bo(i[2],this._center.lat)*this.worldSize,r[2]=e.bo(r[2],this._center.lat)*this.worldSize,e.aa.scale(i,i,1/this.worldSize),e.aa.scale(r,r,1/this.worldSize),new e.a5([i[0],i[1],i[2]],e.Q.normalize([],e.Q.sub([],r,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:r,t:n}=t,o=e.bo(i[2],this._center.lat),s=e.bo(r[2],this._center.lat);return new e.O(e.X(i[0],r[0],n)/this.worldSize,e.X(i[1],r[1],n)/this.worldSize,e.X(o,s,n))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let i=this.projection.pointCoordinate3D(this,t.x,t.y);if(i)return new e.O(i[0],i[1],i[2]);let r=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);const o=.02*n,s=t.clone();for(let t=0;t<10&&n-r>o;t++){s.y=e.X(r,n,.66);const t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(n=s.y,i=t):r=s.y}return i?new e.O(i[0],i[1],i[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.bA)return!this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const r=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.aa.transformMat4(n,n,this.pixelMatrix),n[3]>0?new e.P(n[0]/n[3],n[1]/n[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(n,t)),a=this.pointLocation3D(new e.P(n,r)),l=this.pointLocation3D(new e.P(i,r));let c=Math.min(o.lng,s.lng,a.lng,l.lng),h=Math.max(o.lng,s.lng,a.lng,l.lng),u=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,i,r,n,o)=>{const s=(t+r)/2,a=(i+n)/2,l=new e.P(s,a),{lng:_,lat:g}=this.pointLocation3D(l),y=Math.max(0,c-_,u-g,_-h,g-d);c=Math.min(c,_),h=Math.max(h,_),u=Math.min(u,g),d=Math.max(d,g),(op)&&(m(t,i,s,a,o+1),m(s,a,r,n,o+1))};if(m(i,t,n,t,1),m(n,t,n,r,1),m(n,r,i,r,1),m(i,r,i,t,1),"globe"===this.projection.name){const[t,i]=e.bB(this);t?(d=90,h=180,c=-180):i&&(u=-90,h=180,c=-180)}return new e.ag(new e.bq(c,u),new e.bq(h,d))}_getBoundsRectangular(t,i){const{top:r,left:n}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(n,r),l=new e.P(s,r),c=new e.P(s,o),h=new e.P(n,o);let u=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,i),f=this.pointCoordinate(h,i),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return u.y>1&&d.y>=0?u=new e.O((1-f.y)/m(f,u)+f.x,1):u.y<0&&d.y<=1&&(u=new e.O(-f.y/m(f,u)+f.x,0)),d.y>1&&u.y>=0?d=new e.O((1-p.y)/m(p,d)+p.x,1):d.y<0&&u.y<=1&&(d=new e.O(-p.y/m(p,d)+p.x,0)),(new e.ag).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.bz,this.maxLat=e.bz,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngu&&(a=u-c),u-ht&&(s=t-l),t-e{for(let n=0;n<16;n++)e[n]=fr(t[n],i[n],r)})(a,a,l,mr(this.pitch>=15?1:this.pitch/15))}else a=l;const c=e.a9.mul([],l,s);let h=e.a9.mul([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.a9.identity([]);e.a9.translate(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.a9.multiply(i,i,e.bE(this)),e.a9.translate(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.a9.multiply(h,h,i),e.a9.multiply(c,c,i),this.inverseAdjustmentMatrix=e.bF(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.a9.scale([],h,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=h,this.invProjMatrix=e.a9.invert(new Float64Array(16),this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.a9.mul([],i,s)}else this.expandedFarZProjMatrix=this.projMatrix;const u=e.a9.invert([],a);this.frustumCorners=e.bG.fromInvProjectionMatrix(u,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.a9.identity(d),e.a9.scale(d,d,[1,-1,1]),e.a9.rotateX(d,d,this._pitch),e.a9.rotateZ(d,d,this.angle);const p=e.a9.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.a9.clone(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-t.x/this.width,p[9]=2*(t.y+f)/this.height,this.skyboxMatrix=e.a9.multiply(d,p,d);const m=this.point,_=m.x,g=m.y,y=this.width%2/2,x=this.height%2/2,v=Math.cos(this.angle),b=Math.sin(this.angle),w=_-Math.round(_)+v*y+b*x,T=g-Math.round(g)+v*x+b*y,E=new Float64Array(h);if(e.a9.translate(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,h=e.a9.create(),e.a9.scale(h,h,[this.width/2,-this.height/2,1]),e.a9.translate(h,h,[1,-1,0]),this.labelPlaneMatrix=h,h=e.a9.create(),e.a9.scale(h,h,[1,-1,1]),e.a9.translate(h,h,[-1,-1,0]),e.a9.scale(h,h,[2/this.width,2/this.height,1]),this.glCoordMatrix=h,this.pixelMatrix=e.a9.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},h=e.a9.invert(new Float64Array(16),this.pixelMatrix),!h)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=h,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.bH(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.Q.transformMat4(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=h;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,r=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,i];e.Q.scale(o,o,n),e.Q.scale(r,r,-1),e.Q.multiply(r,r,o);const s=e.a9.create();e.a9.translate(s,s,r),e.a9.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,n)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],n=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(o=Math.min((i-r)/n,1)),this._camera.position=e.Q.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:n}=this._camera.getPitchBearing(),o=e.bo(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.bm(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(r),s),l=this._zoomFromMercatorZ(a);e.Q.scaleAndAdd(t,t,i,a),this._pitch=e.ad(r,e.bm(this.minPitch),e.bm(this.maxPitch)),this.angle=e.bk(n,-Math.PI,Math.PI),this._setZoom(e.ad(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.O(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,r=e.bA,n=0,o=1/0;for(;r-i>1e-6&&r>i;){const e=i+.5*(r-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(t*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.bI(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const r=e.Q.length(e.Q.sub([],this._camera.position,t)),n=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){const t=(function([t,i,r],n){const o=[t,i,r,1];e.aa.transformMat4(o,o,n);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o})([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,r=this.worldSize){const n=e.bD(t,i,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,r,n);let s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=fr(1,s,mr(this.pitch>=15?1:this.pitch/15))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.a9.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const gr={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,ShadowMap0:10},yr=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const r=t.transform,n=Math.max(Math.abs(r._zoom-(t.minCutoffZoom-1)),1),o=r.isLODDisabled(!1)?e.S(60,45,r.pitch):e.S(30,15,r.pitch),s=r._farZ-r._nearZ,a=i*r.height,l=((1-(c=o))*r.cameraToCenterDistance+c*(r._farZ+a))*n;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[r._nearZ,r._farZ,(l-r._nearZ)/s,(l-a-r._nearZ)/s]}}},xr={cascadeCount:2,shadowMapResolution:2048};class vr{constructor(e,t){this.aabb=e,this.lastCascade=t}}class br{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new vr(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,r){const n=e.bV.fromPoints(t.points);let o=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!n.intersectsAabb(s.aabb))continue;s.aabb.min=n.closestPoint(s.aabb.min),s.aabb.max=n.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t1||s[1]<-1||s[1]>1){n=!1;break}}if(s.lastCascade=t,o=Math.max(o,t),n)break}}return o+1}}class wr{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new br,this._depthMode=new Ct(e.context.gl.LEQUAL,Ct.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},(()=>{this.painter.style.map.triggerRepaint()})),e.tp.registerParameter(xr,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(xr,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,i){const r=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!i||!i.properties)return;const n=i.properties.get("shadow-intensity");if(!i.shadowsEnabled()||n<=0)return;if(this._shadowLayerCount=r.style.order.reduce(((e,i)=>{const n=r.style._mergedLayers[i];return e+(n.hasShadowPass()&&!n.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=r.context,s=xr.shadowMapResolution,a=xr.shadowMapResolution;if(0===this._cascades.length||xr.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;te.dem)).forEach((e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0])})),1e4!==i[0]&&(l=(i[1]-i[0])*e.exaggeration())}const c=1.5*t.cameraToCenterDistance,h=3*c,u=new Float64Array(16);for(let i=0;i=0)return{};const o=(function(t,i,r){const n=r/(1<0&&(e.Q.add(o[1],o[1],[n[0]*s,0,0]),e.Q.add(o[2],o[2],[n[0]*s,0,0])),n[1]<0?(e.Q.add(o[0],o[0],[0,n[1]*s,0]),e.Q.add(o[1],o[1],[0,n[1]*s,0])):n[1]>0&&(e.Q.add(o[2],o[2],[0,n[1]*s,0]),e.Q.add(o[3],o[3],[0,n[1]*s,0]));const a={};return a.vertices=o,a.planes=[Tr(o[1],o[0],o[4]),Tr(o[2],o[1],o[5]),Tr(o[3],o[2],o[6]),Tr(o[0],o[3],o[7])],a}addShadowReceiver(t,i,r){this._receivers.add(t,e.bV.fromTileIdAndHeight(t,i,r))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function Tr(t,i,r){const n=e.Q.sub([],r,i),o=e.Q.sub([],t,i),s=e.Q.cross([],n,o),a=e.Q.length(s);return 0===a?[0,0,1,0]:(e.Q.scale(s,s,1/a),[s[0],s[1],s[2],-e.Q.dot(s,i)])}function Er(t){const i=t.properties.get("direction"),r=e.bT(i.x,i.y,i.z);r[2]=e.ad(r[2],0,75);const n=e.bW([r[0],r[1],r[2]]);return e.Q.fromValues(n.x,n.y,n.z)}function Sr(t,i){const r=t.properties.get("color"),n=t.properties.get("intensity"),o=t.properties.get("direction"),s=[o.x,o.y,o.z],a=i.properties.get("color"),l=i.properties.get("intensity"),c=Math.max(e.Q.dot([0,0,1],s),0),h=[0,0,0];e.Q.scale(h,a.toArray01Linear().slice(0,3),l);const u=[0,0,0];return e.Q.scale(u,r.toArray01Linear().slice(0,3),c*n),e.bX([h[0]>0?h[0]/(h[0]+u[0]):0,h[1]>0?h[1]/(h[1]+u[1]):0,h[2]>0?h[2]/(h[2]+u[2]):0])}function Mr(t,i,r,n,o,s){const a=t.zoom,l=t.scale,c=t.worldSize,h=1/c,u=t.aspect,d=Math.sqrt(1+u*u)*Math.tan(.5*t.fovX),p=d*d,f=n-r,m=n+r;let _,g;p>f/m?(_=n,g=n*d):(_=.5*m*(1+p),g=.5*Math.sqrt(f*f+2*(n*n+r*r)*p+m*m*p*p));const y=t.projection.pixelsPerMeter(t.center.lat,c),x=t._camera.getCameraToWorldMercator(),v=[0,0,-_*h];e.Q.transformMat4(v,v,x);let b=g*h;const w=t._edgeInsets;if(!(0===w.left&&0===w.top&&0===w.right&&0===w.bottom||w.left===w.right&&w.top===w.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?y:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,r,n);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.a9.mul(s,o,i);const h=new Float64Array(16);e.a9.invert(h,s);const u=e.bt.fromInvProjectionMatrix(h,c,a,!0);for(const i of u.points){const r=((T=i)[0]/=l,T[1]/=l,T[2]=e.bo(T[2],t._center.lat),T);b=Math.max(b,e.Q.len(e.Q.subtract([],v,r)))}}var T;b*=o/(o-1);const E=Math.acos(i[2]),S=Math.atan2(-i[0],-i[1]),M=new pr;M.position=v,M.setPitchBearing(E,S);const A=M.getWorldToCamera(c,y),I=b*c,C=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*I),P=M.getCameraToClipOrthographic(-I,I,-I,I,C,(I+s*y)/i[2]),z=new Float64Array(16);e.a9.multiply(z,P,A);const D=e.Q.fromValues(Math.floor(1e6*v[0])/1e6*c,Math.floor(1e6*v[1])/1e6*c,0),R=.5*o,L=[0,0,0];e.Q.transformMat4(L,D,z),e.Q.scale(L,L,R);const k=[Math.floor(L[0]),Math.floor(L[1]),Math.floor(L[2])],O=[0,0,0];e.Q.sub(O,L,k),e.Q.scale(O,O,-1/R);const B=new Float64Array(16);return e.a9.identity(B),e.a9.translate(B,B,O),e.a9.multiply(z,B,z),[z,I]}const Ar=(e,t)=>ce(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),Ir=e.af(ni,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),Cr=e.af(ni,["setCenter","setZoom","setBearing","setPitch"]),Pr={version:8,layers:[],sources:{}},zr={duration:300,delay:0};class Dr extends e.E{constructor(t,i={}){super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition=e.e({},zr),this._buildingIndex=new ti(this),this.crossTileSymbolIndex=new ar,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=i.styleChanges||new b,this.dispatcher=i.dispatcher?i.dispatcher:new e.bZ(e.b_(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new S,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.b$(t._requestManager,i.localFontFamily?e.c0.all:i.localIdeographFontFamily?e.c0.ideographs:e.c0.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new w(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._config=i.config,this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.c1());const r=this;this._rtlTextPluginCallback=Dr.registerForPluginStateChange((t=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,i)=>{if(e.c2(t),i&&i.every((e=>e)))for(const e in r._sourceCaches){const t=r._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i)}}))}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.c3(t))return t;const i=e.c4(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return`json://${e.c5(JSON.stringify(t))}`}_diffStyle(t,i,r){this.globalId=this._getGlobalId(t);const n=(e,t)=>{try{t(null,this.setState(e,r))}catch(e){t(e,!1)}};if("string"==typeof t){const r=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(r,e.R.Style);e.g(o,((t,r)=>{t?this.fire(new e.a(t)):r&&n(r,i)}))}else"object"==typeof t&&n(t,i)}loadURL(t,i={}){this.fire(new e.b("dataloading",{dataType:"style"}));const r="boolean"==typeof i.validate?i.validate:!e.c3(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const n=this.importsCache.get(t);if(n)return this._load(n,r);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.g(o,((i,n)=>{if(this._request=null,i)this.fire(new e.a(i));else if(n)return this.importsCache.set(t,n),this._load(n,r)}))}loadJSON(t,i={}){this.fire(new e.b("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.f.frame((()=>{this._request=null,this._load(t,!1!==i.validate)}))}loadEmpty(){this.fire(new e.b("dataloading",{dataType:"style"})),this._load(Pr,!1)}_loadImports(t,i,r){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const n=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise((e=>{t.once("style.import.load",e),t.once("error",e)})).then((()=>this.mergeAll()));if(n.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const s=e.data||this.importsCache.get(e.url);s?(t.loadJSON(s,{validate:i}),this._isInternalStyle(s)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(r){const e=this.fragments.findIndex((({id:e})=>e===r));this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}return Promise.allSettled(n)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return[...t.values()]}_createFragmentStyle(t){const i=this.scope?e.aj(t.id,this.scope):t.id;let r;const n=this._initialConfig&&this._initialConfig[i];(t.config||n)&&(r=e.e({},t.config,n));const o=new Dr(this.map,{scope:i,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:r,configOptions:this.options,configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.isRootStyle()}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){const r=t.schema;if(this._isInternalStyle(t)){const r=e.e({},Pr,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(r,i)}if(this.updateConfig(this._config,r),i&&Ar(this,Y(t)))return;this._loaded=!0,this.stylesheet=e.c6(t);for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(t.glyphs,this.scope);const n=ri(this.stylesheet.layers);if(this._order=n.map((e=>e.id)),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new ue(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new ue(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const t of n){const i=e.c7(t,this.scope,this.options);i.isConfigDependent&&this._configDependentLayers.add(i.fqid),i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._serializedLayers[i.id]=i.serialize();const r=this.getOwnLayerSourceCache(i),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();r&&i.canCastShadows()&&n&&(r.castsShadows=!0)}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const o=this.stylesheet.terrain;o&&(void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.f.hasCanvasFingerprintNoise()),this.disableElevatedTerrain?e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."):this.terrainSetForDrapingOnly()||this._createTerrain(o,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.b("data",{dataType:"style"}));const s=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then((()=>{this._reloadImports(),this.fire(new e.b(s?"style.load":"style.import.load"))})):(this._reloadImports(),this.fire(new e.b(s?"style.load":"style.import.load")))}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,i,r,n,o,s,a,l;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((e=>{if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(const t of e.stylesheet.lights)"ambient"===t.type&&null!=e.ambientLight&&(i=e.ambientLight),"directional"===t.type&&null!=e.directionalLight&&(r=e.directionalLight);n=this._prioritizeTerrain(n,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(o=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(s=e.stylesheet.projection),null!=e.stylesheet.transition&&(a=e.stylesheet.transition)}})),this.light=t,this.ambientLight=i,this.directionalLight=r,this.fog=o,null===n?delete this.terrain:this.terrain=n,this.camera=l||{"camera-projection":"perspective"},this.projection=s||{name:"mercator"},this.transition=e.e({},zr,a),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i)};t(this)}_prioritizeTerrain(e,t,i){const r=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:r?e:null:null!=t&&(!e||r||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain)})),null===e?delete this.terrain:this.terrain=e}mergeProjection(){let e;this.forEachFragmentStyle((t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)})),this.projection=e||{name:"mercator"}}mergeSources(){const t={},i={},r={};this.forEachFragmentStyle((n=>{for(const i in n._sourceCaches){const r=e.aj(i,n.scope);t[r]=n._sourceCaches[i]}for(const t in n._otherSourceCaches){const r=e.aj(t,n.scope);i[r]=n._otherSourceCaches[t]}for(const t in n._symbolSourceCaches){const i=e.aj(t,n.scope);r[i]=n._symbolSourceCaches[t]}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=r}mergeLayers(){const t={},i=[],r={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((r=>{for(const n of r._order){const o=r._layers[n];if("slot"===o.type){const i=e.c8(n);if(t[i])continue;t[i]=[]}o.slot&&t[o.slot]?t[o.slot].push(o):i.push(o)}})),this._mergedOrder=[];const n=(i=[])=>{for(const o of i)if("slot"===o.type){const i=e.c8(o.id);t[i]&&n(t[i])}else{const t=e.aj(o.id,o.scope);this._mergedOrder.push(t),r[t]=o,o.is3D()&&(this._has3DLayers=!0),"circle"===o.type&&(this._hasCircleLayers=!0),"symbol"===o.type&&(this._hasSymbolLayers=!0)}};n(i),this._mergedLayers=r,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=e.e({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=(function(t,i,r){let n,o,s;const a=e.f.devicePixelRatio>1?"@2x":"";let l=e.g(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),((e,t)=>{l=null,s||(s=e,n=t,h())})),c=e.d(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),((e,t)=>{c=null,s||(s=e,o=t,h())}));function h(){if(s)r(s);else if(n&&o){const t=e.f.getImageData(o),i={};for(const r in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:p}=n[r],f=new e.h({width:o,height:s});e.h.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),i[r]={data:f,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:p}}r(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}})(t,this.map._requestManager,((t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.a(t));else if(i)for(const e in i)this.imageManager.addImage(e,this.scope,i[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.b("data",{dataType:"style"}))}))}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const r=t.sourceLayer;r&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new e.a(new Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded())return!1;if(!this.modelManager.isLoaded())return!1;for(const{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map(((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e}))}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize())}return t}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.a(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.a(new Error(`The source '${t}' does not exist in the map's style.`)))}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i));const r=this._changes.isDirty();if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:r}=e[t];(i||r)&&this._updateWorkerLayers(t,i,r)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._changes.reset()}const n={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];n[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const i=this._mergedLayers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()))}if(!this._precompileDone&&this._shouldPrecompile)for(let e=i.minzoom||0;e<(i.maxzoom||25.5);e++){const e=this.map.painter;if(e){const r=i.getProgramIds();if(!r)continue;for(const n of r){const r=i.getDefaultProgramParams(n,t.zoom);r&&(e.style=this,this.fog&&(e._fogVisible=!0,r.overrideFog=!0,e.getOrCreateProgram(n,r)),e._fogVisible=!1,r.overrideFog=!1,e.getOrCreateProgram(n,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,e.getOrCreateProgram(n,r)))}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const t in n){const i=this._mergedSourceCaches[t];n[t]!==i.used&&i.getSource().fire(new e.b("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),r&&this.fire(new e.b("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages()}}_updateWorkerLayers(e,t,i){const r=this.getFragmentStyle(e);r&&this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:i||[],options:r.options})}setState(i,r){if(this._checkLoaded(),Ar(this,Y(i)))return!1;(i=e.c6(i)).layers=ri(i.layers);const n=(function(e,i){if(!e)return[{command:ni.setStyle,args:[i]}];let r=[];try{if(!t(e.version,i.version))return[{command:ni.setStyle,args:[i]}];t(e.center,i.center)||r.push({command:ni.setCenter,args:[i.center]}),t(e.zoom,i.zoom)||r.push({command:ni.setZoom,args:[i.zoom]}),t(e.bearing,i.bearing)||r.push({command:ni.setBearing,args:[i.bearing]}),t(e.pitch,i.pitch)||r.push({command:ni.setPitch,args:[i.pitch]}),t(e.sprite,i.sprite)||r.push({command:ni.setSprite,args:[i.sprite]}),t(e.glyphs,i.glyphs)||r.push({command:ni.setGlyphs,args:[i.glyphs]}),t(e.imports,i.imports)||(function(e=[],i=[],r){i=i||[];const n=(e=e||[]).map(hi),o=i.map(hi),s=e.reduce(ui,{}),a=i.reduce(ui,{}),l=n.slice();let c,h,u,d;for(c=0,h=0;c{e.source&&n[e.source]?r.push({command:ni.removeLayer,args:[e.id]}):s.push(e)}));let a=e.terrain;a&&n[a.source]&&(r.push({command:ni.setTerrain,args:[void 0]}),a=void 0),r=r.concat(o),t(a,i.terrain)||r.push({command:ni.setTerrain,args:[i.terrain]}),(function(e,i,r){i=i||[];const n=(e=e||[]).map(hi),o=i.map(hi),s=e.reduce(ui,{}),a=i.reduce(ui,{}),l=n.slice(),c=Object.create(null);let h,u,d,p,f,m,_;for(h=0,u=0;h!(e.command in Cr)));if(0===n.length)return!1;const o=n.filter((e=>!(e.command in Ir)));if(o.length>0)throw new Error(`Unimplemented: ${o.map((e=>e.command)).join(", ")}.`);const s=[];return n.forEach((e=>{s.push(this[e.command].apply(this,e.args))})),r&&Promise.all(s).then(r),this.stylesheet=i,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(t,i){return this.getImage(t)?this.fire(new e.a(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,i),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t)}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new e.a(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(t),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new e.b("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,i={}){return this._checkLoaded(),this._validate(ae,`models.${e}`,t,null,i)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new e.a(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,r={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(J,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=qt(t,i,this.dispatcher,this);n.scope=this.scope,n.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(n.id),source:n.serialize(),sourceId:n.id})));const o=t=>{const i=(t?"symbol:":"other:")+n.id,r=e.aj(i,this.scope),o=this._sourceCaches[i]=new Yt(r,n,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[n.id]=o,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),n.onAdd&&n.onAdd(this.map),r.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.a(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.a(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const r=this.getOwnSourceCaches(t);for(const t of r){const i=e.c8(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.b("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource())}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}setLights(t){if(this._checkLoaded(),!t)return void delete this.ambientLight;const i=this._getTransitionParameters();for(const e of t){if(this._validate(ee,"lights",e))return;switch(e.type){case"ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i)}else this.ambientLight=new Te(e,Ee,this.scope,this.options);break;case"directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i)}else this.directionalLight=new Te(e,Se,this.scope,this.options)}}const r=new e.N(this.z||0,i);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const r=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),n=t.properties.get("color").toArray01(),o=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.bT(s.x,s.y,s.z)[2]/90,l=r(n)*o*a,c=i.properties.get("color").toArray01(),h=i.properties.get("intensity");return(l+r(c)*h)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(!t)return this;if(e.c9(t)){const i=e.ca(t),r=this.fragments.find((({id:e})=>e===i));if(!r)throw new Error(`Style import not found: ${t}`);const n=e.c8(t);return r.style.getFragmentStyle(n)}{const e=this.fragments.find((({id:e})=>e===t));if(!e)throw new Error(`Style import not found: ${t}`);return e.style}}getConfigProperty(t,i){const r=this.getFragmentStyle(t);if(!r)return null;const n=e.aj(i,r.scope),o=r.options.get(n),s=o?o.value||o.default:null;return s?s.serialize():null}setConfigProperty(t,i,r){const n=this.getFragmentStyle(t);if(!n)return;const o=n.stylesheet.schema;if(!o||!o[i])return;const s=e.t(r);if("success"!==s.result)return void Ar(this,s.value);const a=s.value.expression,l=e.aj(i,n.scope),c=n.options.get(l);if(!c)return;let h;const{minValue:d,maxValue:p,stepValue:f,type:m,values:_}=o[i],g=e.t(o[i].default);"success"===g.result&&(h=g.value.expression),h?(this.options.set(l,u(u({},c),{},{value:a,default:h,minValue:d,maxValue:p,stepValue:f,type:m,values:_})),this.updateConfigDependencies()):this.fire(new e.a(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)))}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const r=i.stylesheet.schema;if(!r)return null;const n={};for(const t in r){const r=e.aj(t,i.scope),o=i.options.get(r),s=o?o.value||o.default:null;n[t]=s?s.serialize():null}return n}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies())}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const r in i){let n,o;const s=e.t(i[r].default);if("success"===s.result&&(n=s.value.expression),t&&void 0!==t[r]){const i=e.t(t[r]);"success"===i.result&&(o=i.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:h,values:u}=i[r];if(n){const t=e.aj(r,this.scope);this.options.set(t,{default:n,value:o,minValue:a,maxValue:l,stepValue:c,type:h,values:u})}else this.fire(new e.a(new Error(`No schema defined for config option "${r}".`)))}else this.fire(new e.a(new Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t))}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this._changes.setDirty()}addLayer(t,i,r={}){this._checkLoaded();const n=t.id;if(this._layers[n])return void this.fire(new e.a(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===t.type){if(Ar(this,e.cb(t)))return;o=e.c7(t,this.scope,this.options)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.c6(t),t=e.e(t,{source:n})),this._validate(re,`layers.${n}`,t,{arrayIndex:-1},r))return;o=e.c7(t,this.scope,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[o.id]=o.serialize()}o.isConfigDependent&&this._configDependentLayers.add(o.fqid);let s=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.a(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?s=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o;const a=this.getOwnLayerSourceCache(o),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&o.canCastShadows()&&l&&(a.castsShadows=!0);const c=this._changes.getRemovedLayer(o);if(c&&o.source&&a&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.aj(o.source,o.scope);c.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,i){this._checkLoaded();const r=this._checkLayer(t);if(!r)return;if(t===i)return;const n=this._order.indexOf(t);this._order.splice(n,1);let o=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.a(new Error(`Layer with id "${i}" does not exist on this map.`)));r.slot===this._layers[i].slot?o=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}r.castsShadows=e}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,i){this._checkLoaded();const r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)))}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i))}setFilter(i,r,n={}){this._checkLoaded();const o=this._checkLayer(i);if(o&&!t(o.filter,r))return null==r?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(ne,`layers.${o.id}.filter`,r,{layerType:o.type},n)||(o.filter=e.c6(r),this._updateLayer(o)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.c6(i.filter)}setLayoutProperty(i,r,n,o={}){this._checkLoaded();const s=this._checkLayer(i);if(s&&!t(s.getLayoutProperty(r),n)){if(null!=n&&(!o||!1!==o.validate)&&Ar(s,se.call(Y,{key:`layers.${i}.layout.${r}`,layerType:s.type,objectKey:r,value:n,styleSpec:e.G,style:{glyphs:!0,sprite:!0}})))return;s.setLayoutProperty(r,n),s.isConfigDependent&&this._configDependentLayers.add(s.fqid),this._updateLayer(s)}}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(i,r,n,o={}){this._checkLoaded();const s=this._checkLayer(i);if(!s)return;if(t(s.getPaintProperty(r),n))return;if(null!=n&&(!o||!1!==o.validate)&&Ar(s,oe.call(Y,{key:`layers.${i}.paint.${r}`,layerType:s.type,objectKey:r,value:n,styleSpec:e.G})))return;const a=s.setPaintProperty(r,n);s.isConfigDependent&&this._configDependentLayers.add(s.fqid),a&&this._updateLayer(s),this._changes.updatePaintProperties(s)}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){this._checkLoaded();const r=t.source,n=t.sourceLayer,o=this._checkSource(r);if(!o)return;const s=o.type;if("geojson"===s&&n)return void this.fire(new e.a(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(r);for(const e of a)e.setFeatureState(n,t.id,i)}removeFeatureState(t,i){this._checkLoaded();const r=t.source,n=this._checkSource(r);if(!n)return;const o=n.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.a(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(r);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){this._checkLoaded();const i=t.source,r=t.sourceLayer,n=this._checkSource(i);if(n){if("vector"!==n.type||r)return void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(r,t.id);this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition=e.e({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return e.e({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.cc({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),r=e.aj(t.source,t.scope),n=this._changes.getUpdatedSourceCaches();t.source&&!n[r]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(r,"reload"),i.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type||"model"===this._mergedLayers[e].type,i=this.order,r={},n=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){r[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t)}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(r[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),l=Me.createFromScreenPoints(t,r);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e].getSource();if(!t||t.scope!==i.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;i.layers&&!n[c]||o.push($t(this._mergedSourceCaches[e],this._mergedLayers,s,l,i,r,a,!!this.map._showQueryGeometry))}return this.placement&&o.push((function(e,t,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(Qt);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in r){const t=a[e]=a[e]||[],n=r[e];n.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of n)t.push(e)}}for(const t in a)a[t].forEach((r=>{const n=r.feature,o=i(e[t]);if(!o)return;const s=o.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=s}));return a})(this._mergedLayers,s,this.getLayerSourceCache.bind(this),l.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,t){t&&t.filter&&this._validate(ne,"querySourceFeatures.filter",t.filter,null,t);const i=this.getOwnSourceCaches(e);let r=[];for(const e of i)r=r.concat(Wt(e,t));return r}addSourceType(e,t,i){return Dr.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Dr.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,i,r={}){this._checkLoaded();const n=this.light.getLight();let o=!1;for(const i in e)if(!t(e[i],n[i])){o=!0;break}if(!o)return;const s=this._getTransitionParameters();this.light.setLight(e,i,r),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(i,r=1){if(this._checkLoaded(),!i)return this.terrainSetForDrapingOnly()&&0!==r||delete this.terrain,null===i?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let n=i;const o=null==i.source;if(1===r){if("object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.c6(n),n=e.e(n,{source:t})}const t=e.e({},n),i={};if(this.terrain&&o){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize())}if(this._validate(te,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!o||this.terrain&&r!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,r),this.fire(new e.b("data",{dataType:"style"}))}else{const r=this.terrain,o=r.get();for(const t of Object.keys(e.G.terrain))!n.hasOwnProperty(t)&&e.G.terrain[t].default&&(n[t]=e.G.terrain[t].default);for(const n in i)if(!t(i[n],o[n])){r.set(i,this.options),this.stylesheet.terrain=i;const t=this._getTransitionParameters({duration:0});r.updateTransitions(t),this.fire(new e.b("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new we(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!t(i.get(),e)){i.set(e,this.options),this.stylesheet.fog=i.get();const t=this._getTransitionParameters({duration:0});i.updateTransitions(t)}}else this._createFog(e);this._markersNeedUpdate=!0}_getTransitionParameters(t){return{now:e.f.now(),transition:e.e(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i in this._mergedLayers)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const i=this.terrain=new pe(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,i,r,n,o={}){if(o&&!1===o.validate)return!1;const s=e.e({},this.serialize());return Ar(this,t.call(Y,e.e({key:i,style:s,value:r,styleSpec:e.G},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.cd.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove())}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles()}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles()}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload()}reloadSources(){for(const e of this.getSources())e.reload&&e.reload()}updateSources(e){let t;this.directionalLight&&(t=Er(this.directionalLight));for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].update(e,void 0,void 0,t)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,i,r,n,o=!1){let s=!1,a=!1;const l={},c={};for(const i of this._mergedOrder){const r=this._mergedLayers[i];if("symbol"!==r.type)continue;const n=e.aj(r.source,r.scope);let o=l[n];if(!o){const e=this.getLayerSourceCache(r);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));c[n]=t.slice(),o=l[n]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const a=this.crossTileSymbolIndex.addLayer(r,o,t.center.lng,t.projection);s=s||a}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),o=o||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.b("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.f.now(),t.zoom))&&(this.pauseablePlacement=new ir(t,this._mergedOrder,o,i,r,n,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,l,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.f.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s){this._buildingIndex.onNewFrame(t.zoom);for(const t of this._mergedOrder){const i=this._mergedLayers[t];"symbol"===i.type&&this.placement.updateLayerOpacities(i,l[e.aj(i.source,i.scope)])}}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.f.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(t,i){this._checkLoaded();const r=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==r.findIndex((({id:e})=>e===t.id)))return void this.fire(new e.a(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return r.push(t),this._loadImports([t],!0);const n=r.findIndex((({id:e})=>e===i));return-1===n&&this.fire(new e.a(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=r.slice(0,n).concat(t).concat(r.slice(n)),this._loadImports([t],!0,i)}updateImport(e,i){this._checkLoaded();const r=this.stylesheet.imports||[],n=this.getImportIndex(e);return-1===n?this:"string"==typeof i?(this.setImportUrl(e,i),this):(i.url&&i.url!==r[n].url&&this.setImportUrl(e,i.url),t(i.config,r[n].config)||this.setImportConfig(e,i.config),t(i.data,r[n].data)||this.setImportData(e,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const r=this.getImportIndex(e);if(-1===r)return this;const n=this.getImportIndex(t);if(-1===n)return this;const o=i[r],s=this.fragments[r];return i=i.filter((({id:t})=>t!==e)),this.fragments=this.fragments.filter((({id:t})=>t!==e)),this.stylesheet.imports=i.slice(0,n).concat(o).concat(i.slice(n)),this.fragments=this.fragments.slice(0,n).concat(s).concat(this.fragments.slice(n)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;i[r].url=t;const n=this.fragments[r];return n.style=this._createFragmentStyle(i[r]),n.style.on("style.import.load",(()=>this.mergeAll())),n.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];return-1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete r[i].data,this.setImportUrl(e,r[i].url))}setImportConfig(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===i)return this;t?r[i].config=t:delete r[i].config;const n=this.fragments[i],o=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.updateConfig(t,o),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports())}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex((e=>e.id===t));return-1===i&&this.fire(new e.a(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource())}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const r=e.aj(t,i);return this._mergedOtherSourceCaches[r]}getLayerSourceCache(t){const i=e.aj(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t)}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e)}}getImages(e,t,i){this.imageManager.getImages(t.icons,t.scope,i),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,t.scope,i)}getResource(t,i,r){return e.ce(i,r)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.a(new Error(`There is no source with ID '${t}'`))),!1):i.every((e=>e.loaded()))}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach((e=>{e.style._remove()})),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Dr.getSourceType=function(e){return Gt[e]},Dr.setSourceType=function(e,t){Gt[e]=t},Dr.registerForPluginStateChange=e.bY;var Rr="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",Lr="\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,vec2 pos,vec2 lod_coord) {vec2 size=vec2(textureSize(image,0));vec2 dx=dFdx(lod_coord.xy*size);vec2 dy=dFdy(lod_coord.xy*size);float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}",kr="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}",Or="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",Br="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",Fr="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",Nr="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",Vr="#ifdef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",Ur="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec4 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=vec2(u_data_offset+dot(t.rg,u_data_scale.yx),-(u_data_offset+dot(t.ba,u_data_scale.yx)));velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}",jr="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",Gr="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const qr=[];Xr(Rr,qr),Xr(kr,qr),Xr(Lr,qr);const Zr={"_prelude_fog.vertex.glsl":Fr,"_prelude_terrain.vertex.glsl":Br,"_prelude_shadow.vertex.glsl":jr,"_prelude_fog.fragment.glsl":Nr,"_prelude_shadow.fragment.glsl":Gr,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":Vr,"_prelude_raster_particle.glsl":Ur},$r={};Yr("",Br),Yr(Nr,Fr),Yr(Gr,jr),Yr(Vr,""),Yr(Ur,"");const Wr=Yr(Lr,kr),Qr=Rr;var Hr={background:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:Yr("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Yr('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:Yr("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Yr("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in float a_size_scale;in vec2 a_padding;in float a_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+elevation(a_anchor_pos)),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:Yr("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Yr("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:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nuniform float u_emissive_strength;in float v_height;void main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,u_emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);cutoff=max(0.01,cutoff_opacity(u_cutoff_params,ground.z));if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff < 0.01 && centroid_pos.x !=0.0));gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillExtrusionDepth:Yr("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nout vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:Yr('#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:Yr("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(1.0,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:Yr("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:Yr('#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:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) { \nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trimmed,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),linePattern:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform mediump float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 v_uv;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float pattern_x=v_linesofar/pattern_size.x*aspect;float x=mod(pattern_x,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {color=vec4(0,0,0,0);}}\n#endif\n#ifdef LINE_JOIN_NONE\nfloat pattern_len=pattern_size.x/aspect;float segment_phase=pattern_len-mod((v_linesofar-v_pattern_data.x),pattern_len);float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 a_packed;\n#endif\nin float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin vec2 a_pattern_data;out vec2 v_pattern_data;\n#endif\nuniform mat4 u_matrix;uniform mediump float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec4 v_uv;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nfloat a_uv_x=a_packed[0];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef LINE_JOIN_NONE\nv_width+=ANTIALIASING;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5/u_tile_units_to_pixels;v_linesofar+=line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),raster:Yr('#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:Yr('#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:Yr("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin float a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(a_index,u_particle_texture_side_len),a_index/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-vec2(1.0),0.0,1.0);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:Yr("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:Yr('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp float speed=velocity==INVALID_VELOCITY ? 0.0 : length(velocity);highp float reset_rate_bump=speed*u_reset_rate;highp vec2 particle_pos_min=-u_particle_pos_offset;highp vec2 particle_pos_max=vec2(1.0)+u_particle_pos_offset;highp vec2 pos_drop_rate=vec2(1.0)-step(particle_pos_min,pos)+step(particle_pos_max,pos);highp float drop_rate=max(u_reset_rate+reset_rate_bump,length(pos_drop_rate));highp float drop=step(1.0-drop_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbolIcon:Yr('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\nout_color*=alpha;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:Yr('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:Yr('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;in float v_draw_halo;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:Yr('#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:Yr("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:Yr('#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}',Or),skyboxGradient:Yr('#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}',Or),skyboxCapture:Yr("\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:Yr('#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:Yr('#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:Yr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);color=mix(color,v_color_mix.rgb,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=u_matrix*pos;pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normalize(normal_3f));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:Yr("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:Yr("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}")};function Xr(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e)}}function Yr(e,t){const i=/#include\s+"([^"]+)"/g,r=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let n=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);n&&(n=n.map((e=>{const t=e.split(" ");return t[t.length-1]})),n=[...new Set(n)]);const o={},s=[],a=[];if(e=e.replace(i,((e,t)=>(a.push(t),""))),(t=t.replace(i,((e,t)=>(s.push(t),"")))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let l=[...qr];Xr(e,l),Xr(t,l);for(const e of[...s,...a])Zr[e]||console.error(`Undefined include: ${e}`),$r[e]||($r[e]=[],Xr(Zr[e],$r[e])),l=[...l,...$r[e]];return{fragmentSource:e=e.replace(r,((e,t,i,r,n)=>(o[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${i} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(r,((e,t,i,r,n)=>{const s="float"===r?"vec2":r,a=n.match(/color/)?"color":s;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${i} ${r} a_${n};\n#endif\n`:o[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${i} ${r} a_${n};\n out ${i} ${r} ${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 ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===a?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${i} ${r} ${n} = a_${n};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:n,usedDefines:l,vertexIncludes:s,fragmentIncludes:a}}class Jr{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,r,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e{const o=r.paint.get("hillshade-shadow-color"),s=r.paint.get("hillshade-highlight-color"),a=r.paint.get("hillshade-accent-color"),l=r.paint.get("hillshade-emissive-strength");let c=e.bm(r.paint.get("hillshade-illumination-direction"));if("viewport"===r.paint.get("hillshade-illumination-anchor"))c-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),r=e.bT(i.x,i.y,i.z);c=e.bm(r[1])}const h=!t.options.moving;return{u_matrix:n||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),h),u_image:0,u_latrange:Kr(0,i.tileID),u_light:[r.paint.get("hillshade-exaggeration"),c],u_shadow:o,u_highlight:s,u_emissive_strength:l,u_accent:a}})(t,r,n,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:_}=t.getTileBoundsBuffers(r);d.draw(t,c.TRIANGLES,o,s,a,Ot.disabled,p,n.id,f,m,_)}function tn(t,i,r){if(!i.needsDEMTextureUpload)return;const n=t.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(r.stride);const s=r.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.T(n,s,o.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}function rn(t,i,r){const n=t.context,o=n.gl;if(!i.dem)return;const s=i.dem;if(n.activeTexture.set(o.TEXTURE1),tn(t,i,s),!i.demTexture)return;i.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=s.dim;n.activeTexture.set(o.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(n,{width:a,height:a,data:null},o.RGBA);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=i.hillshadeFBO=n.createFramebuffer(a,a,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}n.bindFramebuffer.set(l.framebuffer),n.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:u}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,Ct.disabled,zt.disabled,Rt.unblended,Ot.disabled,((t,i)=>{const r=i.stride,n=e.a9.create();return e.a9.ortho(n,0,e.Y,-e.Y,0,0,1),e.a9.translate(n,n,[0,-e.Y,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ}})(i.tileID,s),r.id,c,h,u),i.needsHillshadePrepare=!1}const nn=t=>({u_matrix:new e.bN(t),u_image0:new e.bR(t),u_skirt_height:new e.bQ(t),u_ground_shadow_factor:new e.bP(t)}),on=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),sn=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:u,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f});function an(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const ln=new class{constructor(){this.operations={}}newMorphing(e,t,i,r,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i)}else this.operations[e]={startTime:r,phase:0,duration:n,from:t,to:i,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},cn={0:null,1:"TERRAIN_VERTEX_MORPHING"};function hn(e,t,i){if(0===t)return 0;const r=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function un(e,t){const i=1<({u_matrix:e});function pn(t,i,r,n,o){if(o>0){const s=e.f.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=r.getSource(),h=n.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),d=u&&t.refreshedUponExpiration?1:e.ad(u?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class fn extends Yt{constructor(t){const i={type:"raster-dem",maxzoom:t.transform.maxZoom},r=new e.bZ(e.b_(),null),n=qt("mock-dem",i,r,t.style);super("mock-dem",n,!1),n.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class mn extends Yt{constructor(t){const i=qt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.bZ(e.b_(),null),t.style);super("proxy",i,!1),i.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new jt(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[i.key]=t}return t}),{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class _n extends e.ap{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i}}class gn extends e.cp{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},(()=>{this._style.map.triggerRepaint()})),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},(()=>{this._style.map.triggerRepaint()})),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",(()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()})),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,n,o]=(function(t){const i=new e.aQ,r=new e.az,n=131;i.reserve(17161),r.reserve(33800);const o=e.Y/128,s=e.Y+o/2,a=s+o;for(let t=-o;ts||t<0||t>s?24575:0,o=e.ad(Math.round(r),0,e.Y),a=e.ad(Math.round(t),0,e.Y);i.emplaceBack(o+n,a)}const l=(e,t)=>{const i=t*n+e;r.emplaceBack(i+1,i,i+n),r.emplaceBack(i+n,i+n+1,i+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)})),[i,r,32768]})(),s=t.context;this.gridBuffer=s.createVertexBuffer(r,e.aS.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=e.aE.simpleSegment(0,0,r.length,n.length),this.gridNoSkirtSegments=e.aE.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new mn(i.map),this.orthoMatrix=e.a9.create(),e.a9.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.Y,0,e.Y,0,1);const a=s.gl;this._overlapStencilMode=new zt({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new fn(i.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache()}))}update(t,i,r){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const n=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.f.now();const a=t.terrain&&t.terrain.scope,l=n.get("source"),c=o?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._exaggeration=s?this.calculateExaggeration(i):n.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const h=()=>{this.sourceCache.used&&e.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),i.updateElevation(!0,r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom}else this._disable()}calculateExaggeration(t){const i=this._previousCameraAltitude,r=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=r;const n=null!=i?r-i:Number.MAX_VALUE;if(Math.abs(n)<2)return this._exaggeration;const o=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(o);let a=o-this._previousZoom;const l=this._previousUpdateTimestamp;let c=o;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(o-c)>.5&&(a=.5*(o-c+a)),a*n<0&&(c+=a)),this._evaluationZoom=c;const h=s.getExaggeration(c),u=h===s.getExaggeration(Math.max(0,c-.1));if(u&&Math.abs(h-this._exaggeration)<.01)return h;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(u||h<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.X(this._exaggeration,h,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.O.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=i.getIds().map((e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t}));!(function(t,i){const r=i.transform.pointCoordinate(i.transform.getCameraPoint()),n=new e.P(r.x,r.y);t.sort(((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const r=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const r=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=n.map((e=>new _n(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),tn(this.painter,r,n))}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=r||"";return i[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,i=t.gl;if(!this._emptyDepthBufferTexture){const r=new e.h({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.T(t,r,i.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const r=i.dem.tree.minimums[0];return r>0&&e++,t+r}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const r=this._getLoadedAreaMinimum(),[n,o]=(()=>{const t=new e.cr({width:1,height:1},new Float32Array([r]));return[i.R32F,t]})();this._emptyDEMTextureDirty=!1;let s=this._emptyDEMTexture;return s?s.update(o,{premultiply:!1}):s=this._emptyDEMTexture=new e.T(t,o,n,{premultiply:!1}),s}setupElevationDraw(t,i,r){const n=this.painter.context,o=n.gl,s={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,i=r.morphing.dstDemTile;c=r.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i))}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST,u=e=>{s.u_dem_size=1===e.size[0]?1:e.size[0]-2};if(l&&a)n.activeTexture.set(o.TEXTURE2),a.demTexture.bind(h(a),o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE4),l.demTexture.bind(h(l),o.CLAMP_TO_EDGE),a.demTexture&&u(a.demTexture),s.u_dem_lerp=c;else{a=this.terrainTileForTile[t.tileID.key],n.activeTexture.set(o.TEXTURE2);const e=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture;e.bind(h(a),o.CLAMP_TO_EDGE),u(e)}if(n.activeTexture.set(o.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&a){const t=(1<{if(c===i)return;const r=[cn[i],"PROJECTION_GLOBE_VIEW"];u&&r.push("CUSTOM_ANTIALIASING");const n=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:r,overrideFog:n}),c=i},p=t.colorModeForRenderPass(),f=new Ct(a.LEQUAL,Ct.ReadWrite,t.depthRangeFor3D);ln.update(o);const m=e.cj(h),_=[e.a8(h.center.lng),e.ah(h.center.lat)],g=t.globeSharedBuffers,y=[h.width*e.f.devicePixelRatio,h.height*e.f.devicePixelRatio],x=Float32Array.from(h.globeMatrix),v={useDenormalizedUpVectorScale:!0};{const h=t.transform,u=hn(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=a.TRIANGLES;for(const c of n){const n=r.getTile(c),w=zt.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];an(T,E)&&ln.newMorphing(c.key,T,E,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=ln.getMorphValuesForProxy(c.key),M=S?1:0;S&&e.k(v,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.ch(S.phase)}});const A=e.ck(c.canonical),I=e.cl(A.getCenter().lat),C=e.cm(c.canonical,A,I,h.worldSize/h._pixelsPerMercatorPixel),P=e.aW(e.cn(c.canonical)),z=sn(h.expandedFarZProjMatrix,x,m,P,e.W(h.zoom),_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,y,u,h._farZ,C);if(d(c,M),l&&(i.setupElevationDraw(n,l,v),t.uploadCommonUniforms(s,l,c.toUnwrapped()),g)){const[e,i,r]=g.getGridBuffers(I,0!==u);l.draw(t,b,f,w,p,Ot.backCCW,z,"globe_raster",e,i,r)}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];u&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of n){const{x:n,y:c,z:u}=o.canonical,d=0===c,m=c===(1<e.draw(t,a.TRIANGLES,f,zt.disabled,p,Ot.disabled,sn(h.expandedFarZProjMatrix,g,g,E,0,_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,y,0,h._farZ),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,v),t.uploadCommonUniforms(s,l,o.toUnwrapped()),d&&t.renderDefaultNorthPole&&S(l,x),m&&t.renderDefaultSouthPole&&(g=e.a9.scale(e.a9.create(),g,[1,-1,1]),S(l,b))}}}})(t,i,r,n,o);else{const s=t.context,a=s.gl;let l,c;const h=t.shadowRenderer,u=yr(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(cn[e]),u.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e},p=t.colorModeForRenderPass(),f=new Ct(a.LEQUAL,Ct.ReadWrite,t.depthRangeFor3D);ln.update(o);const m=t.transform,_=hn(m.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(h){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(g=Sr(e,i))}{c=-1;const y=a.TRIANGLES,[x,v]=[i.gridIndexBuffer,i.gridSegments];for(const c of n){const n=r.getTile(c),b=zt.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];an(w,T)&&ln.newMorphing(c.key,w,T,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=ln.getMorphValuesForProxy(c.key),S=E?1:0;let M;E&&(M={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.ch(E.phase)}});const A=on(c.projMatrix,un(c.canonical,m.renderWorldCopies)?_/10:_,g);if(d(S),!l)continue;i.setupElevationDraw(n,l,M);const I=c.toUnwrapped();h&&h.setupShadows(I,l),t.uploadCommonUniforms(s,l,I,null,u),l.draw(t,y,f,b,p,Ot.backCCW,A,"terrain_raster",i.gridBuffer,x,v)}}}})(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,r=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];let c=0;for(const h of o){const o=n.getTileByID(h.proxyTileKey),u=n.proxyCachedFBO[h.key]?n.proxyCachedFBO[h.key][t]:void 0,d=void 0!==u?n.renderCache[u]:this.pool[c++],p=void 0!==u;if(o.texture=d.tex,p&&!d.dirty){l.push(o.tileID);continue}let f;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.aA.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const n=i.style.getLayerSourceCache(t),o=n?this.proxyToSource[h.key][n.id]:[h];if(!o)continue;const s=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),i.renderLayer(i,n,t,s)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const n=i.style.getLayerSourceCache(t),o=n?this.proxyToSource[h.key][n.id]:[h];if(!o)continue;const s=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),i.renderLayer(i,n,t,s)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,r=t;for(let n=0;ni}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((e=>e.dem)).map((r=>{const n=r.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,i=t.gl,r=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const n=new e.T(t,{width:r[0],height:r[1],data:null},i.RGBA);n.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!0,null);return o.colorAttachment.set(n.texture),o.depthAttachment=new At(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof De){t=!0;break}if(!t)return;const i={};for(let t=0;te>t.end))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=r}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key)))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):zt.disabled}_renderTileClippingMasks(e,t){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs={},r.setColorMode(Rt.disabled),r.setDepthMode(Ct.disabled);const o=i.getOrCreateProgram("clippingMask");for(const r of e){const e=i._tileClippingMaskIDs[r.key]=--t;o.draw(i,n.TRIANGLES,Ct.disabled,new zt({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Rt.disabled,Ot.disabled,dn(r.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const r=[t.x,t.y,1,1];e.aa.transformMat4(r,r,i.pixelMatrixInverse),e.aa.scale(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;const n=i._camera.position,o=e.bo(1,i.center.lat),s=[n[0],n[1],n[2]/o,0],a=e.Q.subtract([],r.slice(0,3),s);e.Q.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.Q.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const t=this.painter,i=t.context,r=this.proxySourceCache,n=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===n&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=i.gl,r=i.createFramebuffer(n,o,!0,"renderbuffer");i.activeTexture.set(t.TEXTURE0);const s=new e.T(i,{width:n,height:o,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),r.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,n,o);r.depthAttachment.set(a),this._depthFBO=r,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,n,o]),(function(e,t,i,r){if("globe"===e.transform.projection.name)return;const n=e.context,o=n.gl;n.clear({depth:1});const s=e.getOrCreateProgram("terrainDepth"),a=new Ct(o.LESS,Ct.ReadWrite,e.depthRangeFor3D);for(const n of r){const r=i.getTile(n),l=on(n.projMatrix,0,[0,0,0]);t.setupElevationDraw(r,s),s.draw(e,o.TRIANGLES,a,zt.disabled,Rt.unblended,Ot.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments)}})(t,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,i,r){if(t.getSource()instanceof e.as)return this._setupProxiedCoordsForImageSource(t,i,r);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ))}_setupProxiedCoordsForImageSource(t,i,r){if(!t.getSource().loaded())return;const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e)),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(t,i)=>{const r=t.wrap+t.canonical.x/(1<s+c.max.x||n+oa+c.max.y};for(let e=0;ee.key===i.tileID.key));if(e)return e}if(i.tileID.key!==t.key){const r=t.canonical.z-i.tileID.canonical.z;let o,s,a;n=e.a9.create();const l=i.tileID.wrap-t.wrap<0?(o=e.Y>>r,s=o*((i.tileID.canonical.x<=n){const r=t.canonical.z-n;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.ap(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(a=n,s=new e.ap(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r))}s.key!==t.key&&(c.push(s.key),r=i.getTile(s))}const h=e=>{c.forEach((t=>{n[t]=e})),c.length=0};for(a-=1;a>=l&&(!r||!r.hasData());a--){r&&h(r.tileID.key);const e=s.calculateScaledKey(a);if(r=i.getTileByID(e),r&&r.hasData())break;const t=n[e];if(null===t)break;void 0===t?c.push(e):r=i.getTileByID(t)}return h(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0}}function yn(t,i,r){const n=(function(t,i,r){const n=e.Q.dot(i,t),o=e.Q.dot(r,[.2126,.7152,.0722]),s=(e,t,i)=>(1-i)*e+i*t,a=s(1-.3*Math.min(o,1),1,Math.min(n+1,1));return s(.92,1,Math.asin(e.ad(i[2],-1,1))/Math.PI+.5)*a})(t,[0,0,1],i),o=[0,0,0];e.Q.scale(o,r.slice(0,3),n);const s=[0,0,0];e.Q.scale(s,i.slice(0,3),t[2]);const a=[0,0,0];return e.Q.add(a,o,s),e.bX(a)}const xn=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],vn=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class bn{static cacheKey(e,t,i,r){let n=`${t}${r?r.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(t,i,r,n,o,s){const a=t.gl;this.program=a.createProgram(),this.configuration=n,this.name=i,this.fixedDefines=[...s];const l=n?n.getBinderAttributes():[],c=(r.staticAttributes||[]).concat(l);let h=n?n.defines():[];h=h.concat(s.map((e=>`#define ${e}`)));const u="#version 300 es\n";let d=u+h.concat("precision mediump float;",Qr,Wr.fragmentSource).join("\n");for(const e of r.fragmentIncludes)d+=`\n${Zr[e]}`;d+=`\n${r.fragmentSource}`;let p=u+h.concat("precision highp float;",Qr,Wr.vertexSource).join("\n");for(const e of r.vertexIncludes)p+=`\n${Zr[e]}`;p+=`\n${r.vertexSource}`;const f=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(f,d),a.compileShader(f),a.attachShader(this.program,f);const m=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(m,p),a.compileShader(m),a.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.bR(t),u_dem_prev:new e.bR(t),u_dem_tl:new e.bO(t),u_dem_scale:new e.bQ(t),u_dem_tl_prev:new e.bO(t),u_dem_scale_prev:new e.bQ(t),u_dem_size:new e.bQ(t),u_dem_lerp:new e.bQ(t),u_exaggeration:new e.bQ(t),u_depth:new e.bR(t),u_depth_size_inv:new e.bO(t),u_meter_to_dem:new e.bQ(t),u_label_plane_matrix_inv:new e.bN(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.bP(t),u_tile_tr_up:new e.bP(t),u_tile_br_up:new e.bP(t),u_tile_bl_up:new e.bP(t),u_tile_up_scale:new e.bQ(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.bN(t),u_fog_range:new e.bO(t),u_fog_color:new e.bS(t),u_fog_horizon_blend:new e.bQ(t),u_fog_vertical_limit:new e.bO(t),u_fog_temporal_offset:new e.bQ(t),u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_globe_pos:new e.bP(t),u_globe_radius:new e.bQ(t),u_globe_transition:new e.bQ(t),u_is_globe:new e.bR(t),u_viewport:new e.bO(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.bS(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.bP(t),u_lighting_directional_dir:new e.bP(t),u_lighting_directional_color:new e.bP(t),u_ground_radiance:new e.bP(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.bN(t),u_light_matrix_1:new e.bN(t),u_fade_range:new e.bO(t),u_shadow_normal_offset:new e.bP(t),u_shadow_intensity:new e.bQ(t),u_shadow_texel_size:new e.bQ(t),u_shadow_map_resolution:new e.bQ(t),u_shadow_direction:new e.bP(t),u_shadow_bias:new e.bP(t),u_shadowmap_0:new e.bR(t),u_shadowmap_1:new e.bR(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}_drawDebugWireframe(t,i,r,n,o,s,a,l,c,h){const u=t.options.wireframe;if(!1===u.terrain&&!1===u.layers2D&&!1===u.layers3D)return;const d=t.context;if(!(()=>!(!u.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!u.layers2D||t._terrain&&t._terrain.renderingToTexture||!xn.includes(this.name))||!(!u.layers3D||!vn.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!f)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const _=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(_.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const r in t[e])i[e][r]&&i[e][r].set(i.program,r,t[e][r].current)};c&&c.setUniforms(_.program,d,_.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,_),g("terrainUniforms",this,_),g("globeUniforms",this,_),g("fogUniforms",this,_),g("lightsUniforms",this,_),g("shadowUniforms",this,_),f.bind(),d.setColorMode(new Rt([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.aA.transparent,[!0,!0,!0,!1])),d.setDepthMode(new Ct(i.func===p.LESS?p.LEQUAL:i.func,Ct.ReadOnly,i.range)),d.setStencilMode(zt.disabled);const y=3*s.primitiveLength*2,x=3*s.primitiveOffset*2*2;h&&h>1?p.drawElementsInstanced(p.LINES,y,p.UNSIGNED_SHORT,x,h):p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,x),o.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(r),d.setColorMode(n)}draw(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=e.context,g=_.gl;if(this.failedToCreate)return;_.program.set(this.program),_.setDepthMode(i),_.setStencilMode(r),_.setColorMode(n),_.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,_,this.binderUniforms,u,{zoom:d});const y={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],x=m&&m>0?1:void 0;for(const o of h.get()){const s=o.vaos||(o.vaos={});(s[a]||(s[a]=new Jr)).bind(_,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],x),m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2,m):c?g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2):g.drawArrays(t,o.vertexOffset,o.vertexLength),t===g.TRIANGLES&&c&&this._drawDebugWireframe(e,i,r,n,c,o,u,d,p,m)}}}function wn(t,i){const r=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,o=n*(i.tileID.canonical.x+i.tileID.wrap*r),s=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.a6(i,1,t.transform.tileZoom),u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}const Tn=e.a9.create(),En=(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_)=>{const g=i.style.light,y=g.properties.get("position"),x=[y.x,y.y,y.z],v=e.ct.create();"viewport"===g.properties.get("anchor")&&(e.ct.fromRotation(v,-i.transform.angle),e.Q.transformMat3(x,x,v));const b=g.properties.get("color"),w=i.transform,T={u_matrix:t,u_lightpos:x,u_lightintensity:g.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+r,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Tn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:s,u_flood_light_color:d,u_vertical_scale:p,u_flood_light_intensity:f,u_ground_shadow_factor:m,u_emissive_strength:_};return"globe"===w.projection.name&&(T.u_tile_id=[a.canonical.x,a.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_vertical_scale:i}),Mn=(t,i,r,n,o,s,a,l,c,h,u,d,p,f)=>{const m=En(t,i,r,n,o,s,a,c,h,u,d,p,f,1,[0,0,0],0),_={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return e.e(m,wn(i,l),_)},An=(e,t)=>({u_matrix:e,u_emissive_strength:t}),In=(t,i,r,n)=>e.e(An(t,i),wn(r,n)),Cn=(e,t,i)=>({u_matrix:e,u_world:i,u_emissive_strength:t}),Pn=(t,i,r,n,o)=>e.e(In(t,i,r,n),{u_world:o}),zn=(t,i,r,n)=>{const o=e.Y/r.tileSize;return{u_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(n),u_extrude_scale:[i.pixelsToGLUnits[0]/o,i.pixelsToGLUnits[1]/o]}},Dn=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Rn=e.a9.create(),Ln=(t,i,r,n,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.cu(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.a6(r,1,s),u={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:a,u_inv_rot_matrix:Rn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){u.u_inv_rot_matrix=n,u.u_merc_center=o,u.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:r,u_merc_matrix:n,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:h,u_fade_t:u.mix,u_opacity:u.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:e.cv(d.paint.get("raster-saturation")),u_contrast_factor:e.cw(d.paint.get("raster-contrast")),u_spin_weights:Fn(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:kn(e.cx,_,y),u_colorization_offset:On(e.cx,g,y),u_color_ramp:m,u_texture_offset:[v/(x+2*v),x/(x+2*v)],u_texture_res:[x+2*v,x+2*v],u_emissive_strength:b});function Fn(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Nn=(e,t,i,r,n,o,s,a,l,c,h,u)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:r,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:u,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Vn=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:r,u_color_ramp:o,u_velocity_res:n,u_max_speed:s,u_uv_offset:a,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[Nt,Nt]}),Un=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:r,u_max_speed:n,u_speed_factor:o,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[Nt,Nt]}),jn=e.a9.create(),Gn=(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y)=>{const x=o.transform,v={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:x.getCameraToCenterDistance(_),u_rotate_symbol:+r,u_aspect_ratio:x.width/x.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+n,u_texsize:h,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:jn,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:jn,u_up_vector:[0,-1,0],u_color_adj_mat:g,u_icon_transition:y||0};return"globe"===_.name&&(v.u_tile_id=[u.canonical.x,u.canonical.y,1<e.e(Gn(t,i,r,n,o,s,a,l,c,h,d,p,f,m,_,g),{u_gamma_scale:n?o.transform.getCameraToCenterDistance(g)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.f.devicePixelRatio,u_is_halo:+u,undefined:void 0}),Zn=(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_)=>e.e(qn(t,i,r,n,o,s,a,l,!0,c,!0,u,d,p,f,m,_),{u_texsize_icon:h,u_texture_icon:1}),$n=(e,t,i,r)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:r}),Wn=(t,i,r,n,o,s,a)=>e.e((function(t,i,r,n){const o=r.imageManager.getPattern(t.toString(),i),{width:s,height:a}=r.imageManager.getPixelSize(i),l=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,r.transform.tileZoom)/l,h=c*(n.tileID.canonical.x+n.tileID.wrap*l),u=c*n.tileID.canonical.y;return{u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[s,a],u_pattern_size:o.displaySize,u_tile_units_to_pixels:1/e.a6(n,1,r.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}})(o,s,n,a),{u_matrix:t,u_emissive_strength:i,u_opacity:r}),Qn=new Float32Array(e.a9.identity([])),Hn=(t,i,r,n,o,s,a,l,c,h,u,d,p,f=[0,0,0],m)=>{const _=o.style.light,g=_.properties.get("position"),y=[-g.x,-g.y,g.z],x=e.ct.create();"viewport"===_.properties.get("anchor")&&(e.ct.fromRotation(x,-o.transform.angle),e.Q.transformMat3(y,y,x));const v="MASK"===u.alphaMode,b=_.properties.get("color"),w=p.paint.get("model-ambient-occlusion-intensity"),T=p.paint.get("model-color").constantOr(e.aA.white),E=p.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:r,u_node_matrix:n||Qn,u_lightpos:y,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+v,u_alphaCutoff:u.alphaCutoff,u_baseColorFactor:[a.r,a.g,a.b,a.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:gr.BaseColor,u_metallicRoughnessTexture:gr.MetallicRoughness,u_normalTexture:gr.Normal,u_occlusionTexture:gr.Occlusion,u_emissionTexture:gr.Emission,u_color_mix:[T.r,T.g,T.b,E],u_aoIntensity:w,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},Xn=(e,t=Qn,i=Qn)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Yn={fillExtrusion:t=>({u_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_vertical_gradient:new e.bQ(t),u_opacity:new e.bQ(t),u_edge_radius:new e.bQ(t),u_ao:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_up_dir:new e.bP(t),u_height_lift:new e.bQ(t),u_flood_light_color:new e.bP(t),u_vertical_scale:new e.bQ(t),u_flood_light_intensity:new e.bQ(t),u_ground_shadow_factor:new e.bP(t),u_emissive_strength:new e.bQ(t)}),fillExtrusionDepth:t=>({u_matrix:new e.bN(t),u_edge_radius:new e.bQ(t),u_vertical_scale:new e.bQ(t)}),fillExtrusionPattern:t=>({u_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_vertical_gradient:new e.bQ(t),u_height_factor:new e.bQ(t),u_edge_radius:new e.bQ(t),u_ao:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_up_dir:new e.bP(t),u_height_lift:new e.bQ(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t),u_opacity:new e.bQ(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.bN(t),u_opacity:new e.bQ(t),u_ao_pass:new e.bQ(t),u_meter_to_tile:new e.bQ(t),u_ao:new e.bO(t),u_flood_light_intensity:new e.bQ(t),u_flood_light_color:new e.bP(t),u_attenuation:new e.bQ(t),u_edge_radius:new e.bQ(t),u_fb:new e.bR(t),u_fb_size:new e.bQ(t)}),fill:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t)}),fillPattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),fillOutline:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_world:new e.bO(t)}),fillOutlinePattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_world:new e.bO(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),circle:e.cz,collisionBox:t=>({u_matrix:new e.bN(t),u_camera_to_center_distance:new e.bQ(t),u_extrude_scale:new e.bO(t)}),collisionCircle:t=>({u_matrix:new e.bN(t),u_inv_matrix:new e.bN(t),u_camera_to_center_distance:new e.bQ(t),u_viewport_size:new e.bO(t)}),debug:t=>({u_color:new e.cf(t),u_matrix:new e.bN(t),u_overlay:new e.bR(t),u_overlay_scale:new e.bQ(t)}),clippingMask:t=>({u_matrix:new e.bN(t)}),heatmap:t=>({u_extrude_scale:new e.bQ(t),u_intensity:new e.bQ(t),u_matrix:new e.bN(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_up_dir:new e.bP(t)}),heatmapTexture:t=>({u_image:new e.bR(t),u_color_ramp:new e.bR(t),u_opacity:new e.bQ(t)}),hillshade:t=>({u_matrix:new e.bN(t),u_image:new e.bR(t),u_latrange:new e.bO(t),u_light:new e.bO(t),u_shadow:new e.cf(t),u_highlight:new e.cf(t),u_emissive_strength:new e.bQ(t),u_accent:new e.cf(t)}),hillshadePrepare:t=>({u_matrix:new e.bN(t),u_image:new e.bR(t),u_dimension:new e.bO(t),u_zoom:new e.bQ(t)}),line:e.cA,linePattern:e.cB,raster:t=>({u_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_grid_matrix:new e.cg(t),u_tl_parent:new e.bO(t),u_scale_parent:new e.bQ(t),u_fade_t:new e.bQ(t),u_opacity:new e.bQ(t),u_image0:new e.bR(t),u_image1:new e.bR(t),u_brightness_low:new e.bQ(t),u_brightness_high:new e.bQ(t),u_saturation_factor:new e.bQ(t),u_contrast_factor:new e.bQ(t),u_spin_weights:new e.bP(t),u_perspective_transform:new e.bO(t),u_raster_elevation:new e.bQ(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_cutoff_params:new e.bS(t),u_colorization_mix:new e.bS(t),u_colorization_offset:new e.bQ(t),u_color_ramp:new e.bR(t),u_texture_offset:new e.bO(t),u_texture_res:new e.bO(t),u_emissive_strength:new e.bQ(t)}),rasterParticle:t=>({u_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_grid_matrix:new e.cg(t),u_tl_parent:new e.bO(t),u_scale_parent:new e.bQ(t),u_fade_t:new e.bQ(t),u_opacity:new e.bQ(t),u_image0:new e.bR(t),u_image1:new e.bR(t),u_raster_elevation:new e.bQ(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_cutoff_params:new e.bS(t)}),rasterParticleTexture:t=>({u_texture:new e.bR(t),u_opacity:new e.bQ(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.bR(t),u_particle_texture_side_len:new e.bQ(t),u_tile_offset:new e.bO(t),u_velocity:new e.bR(t),u_color_ramp:new e.bR(t),u_velocity_res:new e.bO(t),u_max_speed:new e.bQ(t),u_uv_offset:new e.bO(t),u_data_scale:new e.bS(t),u_data_offset:new e.bQ(t),u_particle_pos_scale:new e.bQ(t),u_particle_pos_offset:new e.bO(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.bR(t),u_particle_texture_side_len:new e.bQ(t),u_velocity:new e.bR(t),u_velocity_res:new e.bO(t),u_max_speed:new e.bQ(t),u_speed_factor:new e.bQ(t),u_reset_rate:new e.bQ(t),u_rand_seed:new e.bQ(t),u_uv_offset:new e.bO(t),u_data_scale:new e.bS(t),u_data_offset:new e.bQ(t),u_particle_pos_scale:new e.bQ(t),u_particle_pos_offset:new e.bO(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_camera_forward:new e.bP(t),u_tile_matrix:new e.bN(t),u_up_vector:new e.bP(t),u_ecef_origin:new e.bP(t),u_texture:new e.bR(t),u_icon_transition:new e.bQ(t),u_color_adj_mat:new e.bN(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_texture:new e.bR(t),u_gamma_scale:new e.bQ(t),u_device_pixel_ratio:new e.bQ(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_camera_forward:new e.bP(t),u_tile_matrix:new e.bN(t),u_up_vector:new e.bP(t),u_ecef_origin:new e.bP(t),u_is_halo:new e.bR(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_texsize_icon:new e.bO(t),u_texture:new e.bR(t),u_texture_icon:new e.bR(t),u_gamma_scale:new e.bQ(t),u_device_pixel_ratio:new e.bQ(t),u_is_halo:new e.bR(t)}),background:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_opacity:new e.bQ(t),u_color:new e.cf(t)}),backgroundPattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_opacity:new e.bQ(t),u_image:new e.bR(t),u_pattern_tl:new e.bO(t),u_pattern_br:new e.bO(t),u_texsize:new e.bO(t),u_pattern_size:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),terrainRaster:nn,terrainDepth:nn,skybox:t=>({u_matrix:new e.bN(t),u_sun_direction:new e.bP(t),u_cubemap:new e.bR(t),u_opacity:new e.bQ(t),u_temporal_offset:new e.bQ(t)}),skyboxGradient:t=>({u_matrix:new e.bN(t),u_color_ramp:new e.bR(t),u_center_direction:new e.bP(t),u_radius:new e.bQ(t),u_opacity:new e.bQ(t),u_temporal_offset:new e.bQ(t)}),skyboxCapture:t=>({u_matrix_3f:new e.cg(t),u_sun_direction:new e.bP(t),u_sun_intensity:new e.bQ(t),u_color_tint_r:new e.bS(t),u_color_tint_m:new e.bS(t),u_luminance:new e.bQ(t)}),globeRaster:t=>({u_proj_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_image0:new e.bR(t),u_grid_matrix:new e.cg(t),u_skirt_height:new e.bQ(t),u_far_z_cutoff:new e.bQ(t),u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_globe_pos:new e.bP(t),u_globe_radius:new e.bQ(t),u_viewport:new e.bO(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_horizon:new e.bQ(t),u_transition:new e.bQ(t),u_fadeout_range:new e.bQ(t),u_color:new e.bS(t),u_high_color:new e.bS(t),u_space_color:new e.bS(t),u_temporal_offset:new e.bQ(t),u_horizon_angle:new e.bQ(t)}),model:t=>({u_matrix:new e.bN(t),u_lighting_matrix:new e.bN(t),u_normal_matrix:new e.bN(t),u_node_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_camera_pos:new e.bP(t),u_opacity:new e.bQ(t),u_baseColorFactor:new e.bS(t),u_emissiveFactor:new e.bS(t),u_metallicFactor:new e.bQ(t),u_roughnessFactor:new e.bQ(t),u_baseTextureIsAlpha:new e.bR(t),u_alphaMask:new e.bR(t),u_alphaCutoff:new e.bQ(t),u_baseColorTexture:new e.bR(t),u_metallicRoughnessTexture:new e.bR(t),u_normalTexture:new e.bR(t),u_occlusionTexture:new e.bR(t),u_emissionTexture:new e.bR(t),u_color_mix:new e.bS(t),u_aoIntensity:new e.bQ(t),u_emissive_strength:new e.bQ(t),u_occlusionTextureTransform:new e.bS(t)}),modelDepth:t=>({u_matrix:new e.bN(t),u_instance:new e.bN(t),u_node_matrix:new e.bN(t)}),groundShadow:t=>({u_matrix:new e.bN(t),u_ground_shadow_factor:new e.bP(t)}),stars:t=>({u_matrix:new e.bN(t),u_up:new e.bP(t),u_right:new e.bP(t),u_intensity_multiplier:new e.bQ(t)})};let Jn;function Kn(t,i,r,n,o,s,a){const l=t.context,c=l.gl,h=t.transform,u=t.getOrCreateProgram("collisionBox"),d=[];let p=0,f=0;for(let l=0;l0){const t=e.a9.create(),i=x;e.a9.mul(t,g.placementInvProjMatrix,h.glCoordMatrix),e.a9.mul(t,t,g.placementViewportMatrix),d.push({circleArray:b,circleOffset:f,transform:i,invTransform:t,projection:g.getProjection()}),p+=b.length/4,f=p}v&&(t.terrain&&t.terrain.setupElevationDraw(_,u),u.draw(t,c.LINES,Ct.disabled,zt.disabled,t.colorModeForRenderPass(),Ot.disabled,zn(x,h,_,g.getProjection()),r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,h.zoom,null,[v.collisionVertexBuffer,v.collisionVertexBufferExt]))}if(!a||!d.length)return;const m=t.getOrCreateProgram("collisionCircle"),_=new e.cC;_.resize(4*p),_._trim();let g=0;for(const e of d)for(let t=0;t=0&&(m[v.associatedIconIndex]={x:S,y:M,z:A,angle:D})}else Ci(T,p)}if(u){f.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{const i=S&&"point"!==r.layout.get("symbol-placement"),a=[],c=i||z,u=r.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&A&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),u>0&&a.push("ICON_TRANSITION"),s.icon.zOffsetVertexBuffer&&a.push("Z_OFFSET"),0===y&&0===x&&0===v&&1===b||a.push("COLOR_ADJUSTMENT");const g=s.icon.programConfigurations.get(r.id),w=t.getOrCreateProgram(s.sdfIcons?"symbolSDF":"symbolIcon",{config:g,defines:a});let M;const I=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],C=s.iconSizeData,P=e.b8(C,E.zoom),R=A||0!==E.pitch,k=_i(f,n.tileID.canonical,A,S,E,s.getProjection(),m),F=yi(f,n.tileID.canonical,A,S,E,s.getProjection(),m),N=t.translatePosMatrix(F,n,l,h,!0),V=t.translatePosMatrix(f,n,l,h),U=c?eo:k,j=S&&!A&&!i;let G=O;!L&&!E.mercatorFromTransition||S||(G=to(E));const q=d?G:O;if(s.sdfIcons&&!s.iconsInText)M=qn(C.kind,P,j,A,t,V,U,N,!1,I,!0,o,p,D,B,q,s.getProjection());else{const e=r.getColorAdjustmentMatrix(y,x,v,b);M=Gn(C.kind,P,j,A,t,V,U,N,!1,I,o,p,D,B,q,s.getProjection(),e,u)}const Z=n.imageAtlasTexture?n.imageAtlasTexture:null,$=1!==r.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,W=s.sdfIcons||t.options.rotating||t.options.zooming||$||R?T.LINEAR:T.NEAREST,Q=s.sdfIcons&&0!==r.paint.get("icon-halo-width").constantOr(1),H=t.terrain&&A&&i?e.a9.invert(e.a9.create(),k):eo;if(i&&s.icon){const e=E.elevation,i=e?e.getAtTileOffsetFunc(o,E.center.lat,E.worldSize,s.getProjection()):null,r=gi(f,n.tileID.canonical,A,S,E,s.getProjection(),m);wi(s,f,t,!1,r,F,A,_,i,o)}return{program:w,buffers:s.icon,uniformValues:M,atlasTexture:Z,atlasTextureIcon:null,atlasInterpolation:W,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:Q,tile:n,labelPlaneMatrixInv:H}},N=()=>{const i=M&&"point"!==r.layout.get("symbol-placement"),a=[],l=i||R||z;t.terrainRenderModeElevated()&&I&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),s.text.zOffsetVertexBuffer&&a.push("Z_OFFSET");const h=s.text.programConfigurations.get(r.id),_=t.getOrCreateProgram(s.iconsInText?"symbolTextAndIcon":"symbolSDF",{config:h,defines:a});let y,x=[0,0],v=null;const b=s.textSizeData;s.iconsInText&&(x=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],v=n.imageAtlasTexture?n.imageAtlasTexture:null,y=I||0!==E.pitch||t.options.rotating||t.options.zooming||"composite"===b.kind||"camera"===b.kind?T.LINEAR:T.NEAREST);const w=n.glyphAtlasTexture?n.glyphAtlasTexture.size:[0,0],S=e.b8(b,E.zoom),A=_i(f,n.tileID.canonical,I,M,E,s.getProjection(),m),C=yi(f,n.tileID.canonical,I,M,E,s.getProjection(),m),P=t.translatePosMatrix(C,n,c,u,!0),k=t.translatePosMatrix(f,n,c,u),F=l?eo:A,N=M&&!I&&!i;let V=O;!L&&!E.mercatorFromTransition||M||(V=to(E));const U=d?V:O;let j;j=s.iconsInText?Zn(b.kind,S,N,I,t,k,F,P,w,x,o,p,D,B,U,s.getProjection()):qn(b.kind,S,N,I,t,k,F,P,!0,w,!0,o,p,D,B,U,s.getProjection());const G=n.glyphAtlasTexture?n.glyphAtlasTexture:null,q=T.LINEAR,Z=0!==r.paint.get("text-halo-width").constantOr(1),$=t.terrain&&I&&i?e.a9.invert(e.a9.create(),A):eo;if(i&&s.text){const e=E.elevation,i=e?e.getAtTileOffsetFunc(o,E.center.lat,E.worldSize,s.getProjection()):null,r=gi(f,n.tileID.canonical,I,M,E,s.getProjection(),m);wi(s,f,t,!0,r,C,I,g,i,o)}return{program:_,buffers:s.text,uniformValues:j,atlasTexture:G,atlasTextureIcon:v,atlasInterpolation:q,atlasInterpolationIcon:y,isSDF:!0,hasHalo:Z,tile:n,labelPlaneMatrixInv:$}},V=s.icon.segments.get().length,U=s.text.segments.get().length,j=V&&!a.onlyText?F():null,G=U&&!a.onlyIcons?N():null,q=r.paint.get("icon-opacity").constantOr(1),Z=r.paint.get("text-opacity").constantOr(1);if(C&&s.canOverlap){P=!0;const t=q&&!a.onlyText?s.icon.segments.get():[],i=Z&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)k.push({segments:new e.aE([i]),sortKey:i.sortKey,state:j});for(const t of i)k.push({segments:new e.aE([t]),sortKey:t.sortKey,state:G})}else a.onlyText||k.push({segments:q?s.icon.segments:new e.aE([]),sortKey:0,state:j}),a.onlyIcons||k.push({segments:Z?s.text.segments:new e.aE([]),sortKey:0,state:G})}P&&k.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of k){const i=e.state;if(i)if(t.terrain&&t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:E.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),w.activeTexture.set(T.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,T.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(w.activeTexture.set(T.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,T.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const n=i.uniformValues;n.u_is_halo=1,oo(i.buffers,e.segments,r,t,i.program,z,o,s,n,2),n.u_is_halo=0}else{if(i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,oo(i.buffers,e.segments,r,t,i.program,z,o,s,n,1)),n.u_is_halo=0}oo(i.buffers,e.segments,r,t,i.program,z,o,s,i.uniformValues,1)}}}function oo(e,t,i,r,n,o,s,a,l,c){const h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];n.draw(r,r.context.gl.TRIANGLES,o,s,a,Ot.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),h,c)}function so(e,t,i,r,n,o,s){const a=e.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1);let h,u,d,p,f;s?(u=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=a.LINES):(u=c?"fillPattern":"fill",h=a.TRIANGLES);for(const m of r){const r=t.getTile(m);if(c&&!r.patternsLoaded())continue;const _=r.getBucket(i);if(!_)continue;e.prepareDrawTile();const g=_.programConfigurations.get(i.id),y=e.isTileAffectedByFog(m),x=e.getOrCreateProgram(u,{config:g,overrideFog:y});c&&(e.context.activeTexture.set(a.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),g.updatePaintBuffers());const v=l.constantOr(null);if(v&&r.imageAtlas){const e=r.imageAtlas.patternPositions[v.toString()];e&&g.setConstantPatternPositions(e)}const b=e.translatePosMatrix(m.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),w=i.paint.get("fill-emissive-strength");if(s){p=_.indexBuffer2,f=_.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[a.drawingBufferWidth,a.drawingBufferHeight];d="fillOutlinePattern"===u&&c?Pn(b,w,e,r,t):Cn(b,w,t)}else p=_.indexBuffer,f=_.segments,d=c?In(b,w,e,r):An(b,w);e.uploadCommonUniforms(e.context,x,m.toUnwrapped()),x.draw(e,h,n,e.stencilModeForClipping(m),o,Ot.disabled,d,i.id,_.layoutVertexBuffer,p,f,i.paint,e.transform.zoom,g,void 0)}}function ao(t,i,r,n,o,s,a,l){r.resetLayerRenderingStats(t);const c=t.context,h=c.gl,u=t.transform,d=r.paint.get("fill-extrusion-pattern"),p=d.constantOr(1),f=r.paint.get("fill-extrusion-opacity"),m=t.style.enable3dLights(),_=r.paint.get(m&&!p?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),g=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),_],y=r.layout.get("fill-extrusion-edge-radius"),x=y>0&&!r.paint.get("fill-extrusion-rounded-roof"),v=x?0:y,b="globe"===u.projection.name?e.cM():0,w="globe"===u.projection.name,T=w?e.W(u.zoom):0,E=[e.a8(u.center.lng),e.ah(u.center.lat)],S=r.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),M=r.paint.get("fill-extrusion-flood-light-intensity"),A=r.paint.get("fill-extrusion-vertical-scale"),I=yr(t,r.paint.get("fill-extrusion-cutoff-fade-range")),C=r.paint.get("fill-extrusion-emissive-strength"),P=[];let z;w&&P.push("PROJECTION_GLOBE_VIEW"),g[0]>0&&P.push("FAUX_AO"),x&&P.push("ZERO_ROOF_RADIUS"),l&&P.push("HAS_CENTROID"),M>0&&P.push("FLOOD_LIGHT"),I.shouldRenderCutoff&&P.push("RENDER_CUTOFF");const D="shadow"===t.renderPass,R=t.shadowRenderer,L=D&&!!R;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let k=[0,0,0];if(R){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(k=Sr(e,i)),z=P.concat(["SHADOWS_SINGLE_CASCADE"])}const O=L?"fillExtrusionDepth":p?"fillExtrusionPattern":"fillExtrusion",B=r.getLayerRenderingStats();for(const e of n){const n=i.getTile(e),m=n.getBucket(r);if(!m||m.projection.name!==u.projection.name)continue;let _=!1;R&&(_=0===R.getMaxCascadeForTile(e.toUnwrapped()));const y=t.isTileAffectedByFog(e),x=m.programConfigurations.get(r.id),L=t.getOrCreateProgram(O,{config:x,defines:_?z:P,overrideFog:y});if(t.terrain&&t.terrain.setupElevationDraw(n,L,{useMeterToDem:!0}),!m.centroidVertexBuffer){const e=L.attributes.a_centroid_pos;void 0!==e&&h.vertexAttrib2f(e,0,0)}!D&&R&&R.setupShadows(n.tileID.toUnwrapped(),L,"vector-tile",n.tileID.overscaledZ),p&&(t.context.activeTexture.set(h.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),x.updatePaintBuffers());const F=d.constantOr(null);if(F&&n.imageAtlas){const e=n.imageAtlas.patternPositions[F.toString()];e&&x.setConstantPatternPositions(e)}const N=r.paint.get("fill-extrusion-vertical-gradient");let V;if(D&&R){if(fo(n.tileID,m,t))continue;const e=R.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());V=Sn(e,v,A)}else{const i=t.translatePosMatrix(e.expandedProjMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),o=u.projection.createInversionMatrix(u,e.canonical);V=p?Mn(i,t,N,f,g,v,e,n,b,T,E,o,S,A):En(i,t,N,f,g,v,e,b,T,E,o,S,A,M,k,C)}t.uploadCommonUniforms(c,L,e.toUnwrapped(),null,I);let U=m.segments;if("mercator"===u.projection.name&&!D&&(U=m.getVisibleSegments(n.tileID,t.terrain,t.transform.getFrustum(0)),!U.get().length))continue;if(B)if(D)for(const e of U.get())B.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of U.get())B.numRenderedVerticesInTransparentPass+=e.primitiveLength;const j=[];(t.terrain||l)&&j.push(m.centroidVertexBuffer),w&&j.push(m.layoutVertexExtBuffer),L.draw(t,c.gl.TRIANGLES,o,s,a,Ot.backCCW,V,r.id,m.layoutVertexBuffer,m.indexBuffer,U,r.paint,t.transform.zoom,x,j)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}function lo(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x){const v=t.context,b=v.gl,w=t.transform,T=t.transform.zoom,E=[],S=yr(t,r.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===h?(E.push("CLEAR_SUBPASS"),x&&(E.push("CLEAR_FROM_TEXTURE"),v.activeTexture.set(b.TEXTURE0),x.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===h&&E.push("SDF_SUBPASS"),g&&E.push("HAS_CENTROID"),S.shouldRenderCutoff&&E.push("RENDER_CUTOFF");const M=r.layout.get("fill-extrusion-edge-radius"),A=(e,i,n,h,y)=>{const b=i.programConfigurations.get(r.id),w=t.isTileAffectedByFog(e),A=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:E,overrideFog:w}),I=((e,t,i,r,n,o,s,a,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:r?1:0,u_meter_to_tile:n,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h}))(0,h,u,c,y,[d,p*y],f,m,_,T>=17?0:M*y,x?x.size[0]:0),C=[];g&&C.push(i.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(v,A,e.toUnwrapped(),null,S),A.draw(t,v.gl.TRIANGLES,o,s,a,l,I,r.id,i.vertexBuffer,i.indexBuffer,n,r.paint,T,b,C)};for(const o of n){const n=i.getTile(o),s=n.getBucket(r);if(!s||s.projection.name!==w.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=t.translatePosMatrix(o.projMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),i=a.getDefaultSegment();A(o,a,i,e,l)}if(y)for(let s=0;s<4;s++){const a=e.cN[s](o),c=i.getTile(a);if(!c)continue;const h=c.getBucket(r);if(!h||h.projection.name!==w.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const u=h.groundEffect;let d,p;0===s?(d=[-e.Y,0,0],p=1):1===s?(d=[e.Y,0,0],p=0):2===s?(d=[0,-e.Y,0],p=3):(d=[0,e.Y,0],p=2);const f=u.regionSegments[p];if(!f)continue;const m=new Float32Array(16);e.a9.translate(m,o.projMatrix,d),A(o,u,f,t.translatePosMatrix(m,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),l)}}}function co(t,i,r,n,o,s,a){0===n.centroidVertexArray.length&&n.createCentroidsBuffer();const l=s?s.findDEMTileFor(r):null;if(!(l&&l.dem||a))return;const c=t=>new e.P(Math.ceil((t+e.cQ)*e.cR),0),h=e=>{const t=i.getSource().minzoom,r=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},n=[0,-1,1];for(const i of n){if(e.overscaledZ+i(u[0]=Math.min(t.min.y,i.min.y),u[1]=Math.max(t.max.y,i.max.y),u[2]=e.Y-i.min.x>t.max.x?i.min.x-e.Y:t.max.x,u),p=(t,i)=>(u[0]=Math.min(t.min.x,i.min.x),u[1]=Math.max(t.max.x,i.max.x),u[2]=e.Y-i.min.y>t.max.y?i.min.y-e.Y:t.max.y,u),f=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,i,n,o,a,c,h)=>{if(!s)return 0;const u=[[c?n:t,c?t:n,0],[c?n:i,c?i:n,0]],d=h<0?e.Y+h:h,p=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===n&&h<0||0!==n&&h>0?s.getForTilePoints(a,[p],!0,o):u.push(p),s.getForTilePoints(r,u,!0,l),Math.max(u[0][2],u[1][2],p[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=n.borderFeatureIndices[t];if(0===i.length)continue;const o=e.cN[t](r),l=h(o);if(!(l&&l instanceof e.cO))continue;if(n.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const u=s?s.findDEMTileFor(o):null;if(!(u&&u.dem||a))continue;const d=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[d]!==n.canonical.z,y=l.borderFeatureIndices[d];let x=0;if(n.canonical.z!==l.canonical.z){for(const e of i)n.showCentroid(n.featuresOnBorder[e]);if(p)for(const e of y)l.showCentroid(l.featuresOnBorder[e]);n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}for(const r of i){const i=n.featuresOnBorder[r],s=n.centroidData[i.centroidDataIndex],h=i.borders[t];let p;for(;xh[0]+3||e[0]>h[0]-3)break;l.showCentroid(p),x++}if(p&&xh[1]-3)&&(v++,++x!==y.length);)p=l.featuresOnBorder[y[x]];if(p=l.featuresOnBorder[y[r]],v>1){const e=p.borders[d];Math.abs(h[0]-e[0])<3&&Math.abs(h[1]-e[1])<3&&(v=1,x=r+1)}else if(0===v){n.showCentroid(i);continue}const b=l.centroidData[p.centroidDataIndex];a&&1===v&&(((_=s).flags|(g=b).flags)&e.cP?(_.flags|=e.cP,g.flags|=e.cP):(_.flags&=~e.cP,g.flags&=~e.cP));const w=i.intersectsCount()>1||p.intersectsCount()>1;if(v>1)x=r,s.centroidXY=b.centroidXY=new e.P(0,0);else if(u&&u.dem&&!w){const i=f[t](s,b),r=t%2?e.Y-1:0,n=m(i[0],Math.min(e.Y-1,i[1]),r,u,o,t<2,i[2]);s.centroidXY=b.centroidXY=c(n)}else w?s.centroidXY=b.centroidXY=new e.P(0,0):(s.centroidXY=n.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(p));n.writeCentroidToBuffer(s),l.writeCentroidToBuffer(b)}else n.showCentroid(i)}n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}var _,g;(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}const ho=[1,0,0],uo=[0,1,0],po=[0,0,1];function fo(t,i,r){const n=r.transform,o=r.shadowRenderer;if(!o)return!0;const s=t.toUnwrapped(),a=n.tileSize*o._cascades[r.currentShadowCascade].scale;let l=i.maxHeight;if(n.elevation){const e=n.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const h=o.computeSimplifiedTileShadowVolume(s,l,a,c);if(!h)return!1;const u=[ho,uo,po,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===n.projection.name,p=n.scaleZoom(a),f=e.bt.fromInvProjectionMatrix(n.invProjMatrix,n.worldSize,p,!d),m=o.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(h.vertices,h.planes,u)||0===m.intersectsPrecise(h.vertices,h.planes,u)}function mo(t){return[t[0]*e.cS,t[1]*e.cS,t[2]*e.cS,0]}function _o(t,i,r,n,o,s,a,l,c){const h=n.getSource(),u=r.globeSharedBuffers;if(!u)return;let d,p,f;if(i&&(d=n.getTile(i)),h instanceof e.as?(p=h.texture,f=e.co(0,0,r.transform)):d&&i&&(p=d.texture,f=e.co(i.canonical.z,i.canonical.x,r.transform)),!p||!f)return;t||(f=e.a9.scale(e.a9.create(),f,[1,-1,1]));const m=r.context,_=m.gl,g="nearest"===o.paint.get("raster-resampling")?_.NEAREST:_.LINEAR,y=r.colorModeForDrapableLayerRenderPass(s),x=a.defines;x.push("GLOBE_POLES");const v=new Ct(_.LEQUAL,Ct.ReadWrite,r.depthRangeFor3D),b=Float32Array.from(r.transform.expandedFarZProjMatrix),w=Float32Array.from(e.aW(e.cn(new e.bv(0,0,0))));r.terrain&&r.terrain.prepareDrawTile(),m.activeTexture.set(_.TEXTURE0),p.bind(g,_.CLAMP_TO_EDGE),m.activeTexture.set(_.TEXTURE1),p.bind(g,_.CLAMP_TO_EDGE),p.useMipmap&&m.extTextureFilterAnisotropic&&r.transform.pitch>20&&_.texParameterf(_.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[T,E,S,M]=i?u.getPoleBuffers(i.canonical.z,!1):u.getPoleBuffers(0,!0),A=o.paint.get("raster-elevation");let I;t?(I=T,r.renderDefaultNorthPole=0!==A):(I=E,r.renderDefaultSouthPole=0!==A);const C=mo(a.mix),P=((e,t,i,r,n,o,s,a,l,c,h,u,d)=>Bn(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0],a,2,c,h,u,1,0,d))(b,w,f,e.W(r.transform.zoom),0,o,0,A,0,C,a.offset,a.range,s),z=r.getOrCreateProgram("raster",{defines:x});r.uploadCommonUniforms(m,z,null),z.draw(r,_.TRIANGLES,v,c,y,l,P,o.id,I,S,M)}function go(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return[t,i,(o-n-t)/r,(o-t)/r]}function yo(e,t,i,r){if(e)return t instanceof Le&&e instanceof Ht?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:mo(r.mix),offset:r.offset,buffer:0,tileSize:1}}function xo(t,i,r){if(!t)return null;const n=i.getTextureDescriptor(t,r,!0);if(!n)return null;let{texture:o,mix:s,offset:a,tileSize:l,buffer:c,format:h}=n;if(!o||!h)return null;let u=!1;return"uint32"===h&&(u=!0,s[3]=0,s=kn(e.cT,s,[0,r.paint.get("raster-particle-max-speed")]),a=On(e.cT,a,[0,r.paint.get("raster-particle-max-speed")])),{texture:o,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:u,scale:s,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[h]]}}function vo(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return[t,i,(o-n-t)/r,(o-t)/r]}const bo=new e.aA(1,0,0,1),wo=new e.aA(0,1,0,1),To=new e.aA(0,0,1,1),Eo=new e.aA(1,0,1,1),So=new e.aA(0,1,1,1);function Mo(t,i,r,n,o,s,a){const l=t.context,c=t.transform,h=l.gl,u="globe"===c.projection.name,d=u?["PROJECTION_GLOBE_VIEW"]:[];let p=e.a9.clone(r.projMatrix);if(u&&e.W(c.zoom)>0){const t=e.aV(r.canonical,c),i=e.cU(t);p=e.a9.multiply(new Float32Array(16),c.globeMatrix,i),e.a9.multiply(p,c.projMatrix,p)}const f=e.a9.create();f[12]+=2*o/(e.f.devicePixelRatio*c.width),f[13]+=2*s/(e.f.devicePixelRatio*c.height),e.a9.multiply(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),_=i.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(_,m);const g=Ct.disabled,y=zt.disabled,x=t.colorModeForRenderPass(),v="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),u?_._makeGlobeTileDebugBuffers(t.context,c):_._makeDebugTileBoundsBuffers(t.context,c.projection);const b=_._tileDebugBuffer||t.debugBuffer,w=_._tileDebugIndexBuffer||t.debugIndexBuffer,T=_._tileDebugSegments||t.debugSegments;if(m.draw(t,h.LINE_STRIP,g,y,x,Ot.disabled,Dn(p,n),v,b,w,T,null,null,null,[_._globeTileDebugBorderBuffer]),a){const e=_.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let n=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(n+=` => ${r.overscaledZ}`),n+=` ${_.state}`,n+=` ${i}kb`,(function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.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(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)})(t,n)}const E=i.getTile(r).tileSize,S=512/Math.min(E,512)*(r.overscaledZ/c.zoom)*.5,M=_._tileDebugTextBuffer||t.debugBuffer,A=_._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,I=_._tileDebugTextSegments||t.debugSegments;m.draw(t,h.TRIANGLES,g,y,Rt.alphaBlended,Ot.disabled,Dn(p,e.aA.transparent,S),v,M,A,I,null,null,null,[_._globeTileDebugTextBuffer])}function Ao(e,t,i,r){Co(e,0,t+i/2,e.transform.width,i,r)}function Io(e,t,i,r){Co(e,t-i/2,0,i,e.transform.height,r)}function Co(t,i,r,n,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.f.devicePixelRatio,r*e.f.devicePixelRatio,n*e.f.devicePixelRatio,o*e.f.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const Po=e.aB([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:zo}=Po;function Do(e,t,i,r){e.emplaceBack(t,i,r)}class Ro{constructor(t){this.vertexArray=new e.cV,this.indices=new e.az,Do(this.vertexArray,-1,-1,1),Do(this.vertexArray,1,-1,1),Do(this.vertexArray,-1,1,1),Do(this.vertexArray,1,1,1),Do(this.vertexArray,-1,-1,-1),Do(this.vertexArray,1,-1,-1),Do(this.vertexArray,-1,1,-1),Do(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,zo),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.aE.simpleSegment(0,0,36,12)}}function Lo(t,i,r,n,o,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),u=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(e.ct.fromMat4(e.ct.create(),n),o,h,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),r.draw(t,a.TRIANGLES,Ct.disabled,zt.disabled,Rt.unblended,Ot.frontCW,u,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const ko=e.aB([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Oo{constructor(t){const i=new e.cW;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const r=new e.az;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,ko.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=e.aE.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Bo=e.aB([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class Fo{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class No{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Rt([1,Dt,1,Dt],e.aA.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Rt([1,0,1,0],e.aA.transparent,[!1,!1,!1,!0]),this.params=new Fo,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},(()=>{this.updateNeeded=!0})),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0})),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0}))}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Oo(i);const t=this.params.sizeRange,r=this.params.intensityRange,n=(function(t){const i=e.aC(30),r=[];for(let n=0;n{const i="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const u=t.getOrCreateProgram("globeAtmosphere",{defines:i}),p=((e,t,i,r,n,o,s,a,l,c,h,u)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:s,u_color:a,u_high_color:l,u_space_color:c,u_temporal_offset:h,u_horizon_angle:u}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,d,l,c,h,f,g);t.uploadCommonUniforms(r,u);const m=this.atmosphereBuffer;m&&u.draw(t,n.TRIANGLES,s,zt.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Ot.backCW,p,e?"atmosphere_glow_alpha":"atmosphere_glow",m.vertexBuffer,m.indexBuffer,m.segments)};y(!1),y(!0)}drawStars(t,i){const r=e.ad(i.properties.get("star-intensity"),0,1);if(0===r)return;const n=t.context,o=n.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.bl.identity([]);e.bl.rotateX(l,l,-s._pitch),e.bl.rotateZ(l,l,-s.angle),e.bl.rotateX(l,l,e.bm(s._center.lat)),e.bl.rotateY(l,l,-e.bm(s._center.lng));const c=e.a9.fromQuat(new Float32Array(16),l),h=e.a9.multiply([],s.starsProjMatrix,c),u=e.ct.fromMat4([],c),d=e.ct.invert([],u),p=[0,1,0];e.Q.transformMat3(p,p,d),e.Q.scale(p,p,this.params.sizeMultiplier);const f=[1,0,0];e.Q.transformMat3(f,f,d),e.Q.scale(f,f,this.params.sizeMultiplier);const m=(_=p,g=f,y=r,{u_matrix:Float32Array.from(h),u_up:_,u_right:g,u_intensity_multiplier:y});var _,g,y;t.uploadCommonUniforms(n,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,Ct.disabled,zt.disabled,this.colorModeAlphaBlendedWriteRGB,Ot.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function Vo(t,i){const r=[...t],n=i.cameraWorldSizeForFog/i.worldSize,o=e.a9.identity([]);return e.a9.scale(o,o,[n,n,1]),e.a9.multiply(r,o,r),e.a9.multiply(r,i.worldToFogMatrix,r),r}function Uo(e,t,i,r){const n=i.material,o=r.context,{baseColorTexture:s,metallicRoughnessTexture:a}=n.pbrMetallicRoughness,{normalTexture:l,occlusionTexture:c,emissionTexture:h}=n;function u(t,i,r){if(t&&(e.push(i),o.activeTexture.set(o.gl.TEXTURE0+r),t.gfxTexture)){const{minFilter:e,magFilter:i,wrapS:r,wrapT:n}=t.sampler;t.gfxTexture.bindExtraParam(e,i,r,n)}}u(s,"HAS_TEXTURE_u_baseColorTexture",gr.BaseColor),u(a,"HAS_TEXTURE_u_metallicRoughnessTexture",gr.MetallicRoughness),u(l,"HAS_TEXTURE_u_normalTexture",gr.Normal),u(c,"HAS_TEXTURE_u_occlusionTexture",gr.Occlusion),u(h,"HAS_TEXTURE_u_emissionTexture",gr.Emission),i.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(i.texcoordBuffer)),i.colorBuffer&&(e.push(12===i.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(i.colorBuffer)),i.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(i.normalBuffer)),i.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(i.pbrBuffer)),"OPAQUE"!==n.alphaMode&&"MASK"!==n.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),n.defined||e.push("DIFFUSE_SHADED"),e.push("USE_STANDARD_DERIVATIVES")}function jo(t,i,r,n,o,s){const a=r.paint.get("model-opacity"),l=i.context,c=new Ct(i.context.gl.LEQUAL,Ct.ReadWrite,i.depthRangeFor3D),h=i.transform,u=t.mesh,d=u.material,p=d.pbrMetallicRoughness,f=i.style.fog;let m;m="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.a9.multiply([],n.zScaleMatrix,t.nodeModelMatrix),e.a9.multiply(m,n.negCameraPosMatrix,m);const _=e.a9.invert([],m);e.a9.transpose(_,_);const g=r.paint.get("model-emissive-strength").constantOr(0),y=Hn(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(_),null,i,a,p.baseColorFactor,d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,g,r),x={defines:[]},v=[];Uo(x.defines,v,u,i);const b=i.shadowRenderer;b&&(b.useNormalOffset=!1);let w=null;if(f){const e=Vo(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),"globe"!==h.projection.name){const t=u.aabb.min,i=u.aabb.max,[r,n]=f.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);x.overrideFog=r>=_e||n>=_e}}const T=yr(i,r.paint.get("model-cutoff-fade-range"));T.shouldRenderCutoff&&x.defines.push("RENDER_CUTOFF");const E=i.getOrCreateProgram("model",x);i.uploadCommonUniforms(l,E,null,w,T),"shadow"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,o,s,u.material.doubleSided?Ot.disabled:Ot.backCCW,y,r.id,u.vertexBuffer,u.indexBuffer,u.segments,r.paint,i.transform.zoom,void 0,v)}function Go(t,i,r,n,o,s,a){let l;l="globe"===t.projection.name?e.c_(r,t):[...r],e.a9.multiply(l,l,i.matrix);const c=e.a9.multiply([],n,l);if(i.meshes)for(const t of i.meshes){if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:o,worldViewProjection:c,nodeModelMatrix:l});continue}const i=e.Q.transformMat4([],t.centroid,c);i[2]>0&&s.push({mesh:t,depth:i[2],modelIndex:o,worldViewProjection:c,nodeModelMatrix:l})}if(i.children)for(const e of i.children)Go(t,e,r,n,o,s,a)}function qo(e,t,i,r){const n=i.shadowRenderer;if(!n)return;const o=n.getShadowPassDepthMode(),s=n.getShadowPassColorMode(),a=n.calculateShadowPassMatrixFromMatrix(t),l=Xn(a);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,o,zt.disabled,s,Ot.backCCW,l,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,i.transform.zoom,void 0,void 0)}function Zo(t,i,r){const n=i.updateZoomBasedPaintProperties(),o=(function(t,i,r){let n,o,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,o=i.findDEMTileFor(r);o&&o.dem?n=e.d0.create(i,r,o):a=0}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||n&&n._demTile&&n._demTile.tileID===i.validForDEMTile.id&&n._dem._timestamp===i.validForDEMTile.timestamp))return!1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eh&&(h=e.max)}const u=e.ad(n.x,s,a)-n.x,d=e.ad(n.y,l,c)-n.y,p=e.bo(h,i.center.lat)-n.z;return i._zoomFromMercatorZ(Math.sqrt(u*u+d*d+p*p))}function Qo(e,t,i,r,n,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new Ct(a.gl.LEQUAL,Ct.ReadWrite,e.depthRangeFor3D),u=e.isTileAffectedByFog(o);if(i.meshes)for(const d of i.meshes){const p=["MODEL_POSITION_ON_GPU"],f=[];let m,_,g;r.instancedDataArray.length>20&&p.push("INSTANCED_ARRAYS");const y=yr(e,t.paint.get("model-cutoff-fade-range"));if(y.shouldRenderCutoff&&p.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:p}),_=Xn(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.matrix)),g=c.getShadowPassColorMode();else{Uo(p,f,d,e),m=e.getOrCreateProgram("model",{defines:p,overrideFog:u});const r=d.material,l=r.pbrMetallicRoughness,h=t.paint.get("model-opacity"),x=t.paint.get("model-emissive-strength").constantOr(0);_=Hn(o.expandedProjMatrix,Float32Array.from(i.matrix),new Float32Array(16),null,e,h,l.baseColorFactor,r.emissiveFactor,l.metallicFactor,l.roughnessFactor,r,x,t,n),c&&(s.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),m,"model-tile",o.overscaledZ),s.shadowUniformsInitialized=!0)),g=y.shouldRenderCutoff||h<1||"OPAQUE"!==r.alphaMode?Rt.alphaBlended:Rt.unblended}e.uploadCommonUniforms(a,m,o.toUnwrapped(),null,y);const x=d.material.doubleSided?Ot.disabled:Ot.backCCW;if(r.instancedDataArray.length>20)f.push(r.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,h,zt.disabled,g,x,_,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f,r.instancedDataArray.length);else{const i=l?"u_instance":"u_normal_matrix";for(let n=0;n30&&(i.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}const Ko={symbol:function(t,i,r,n,o){if("translucent"!==t.renderPass)return;const s=zt.disabled,a=t.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&(function(t,i,r,n,o,s,a){const l=i.transform,c="map"===o,h="map"===s;for(const i of t){const t=n.getTile(i),o=t.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.b8(o.textSizeData,l.zoom),u=ki(i,o.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),p=_i(u,t.tileID.canonical,h,c,l,o.getProjection(),d),f=o.hasIconTextFit()&&o.hasIconData();if(s){const r=Math.pow(2,l.zoom-t.tileID.overscaledZ);ro(o,c,h,a,e.cE,l,p,i,r,s,f)}}})(n,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o);const l=0!==r.paint.get("icon-opacity").constantOr(1),c=0!==r.paint.get("text-opacity").constantOr(1);void 0!==r.layout.get("symbol-sort-key").constantOr(1)&&(l||c)?no(t,i,r,n,s,a):(l&&no(t,i,r,n,s,a,{onlyIcons:!0}),c&&no(t,i,r,n,s,a,{onlyText:!0})),i.map.showCollisionBoxes&&(Kn(t,i,r,n,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),Kn(t,i,r,n,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,r,n){if("translucent"!==t.renderPass)return;const o=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),a=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1),c=r.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const h=t.context,u=h.gl,d=t.transform,p=t.depthModeForSublayer(0,Ct.ReadOnly),f=zt.disabled,m=t.colorModeForDrapableLayerRenderPass(c),_="globe"===d.projection.name,g=[e.a8(d.center.lng),e.ah(d.center.lat)],y=[];for(let o=0;oe.sortKey-t.sortKey));const x={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of y){const{programConfiguration:i,program:n,layoutVertexBuffer:o,globeExtVertexBuffer:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,_=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,n,x),t.uploadCommonUniforms(h,n,c.tileID.toUnwrapped()),n.draw(t,u.TRIANGLES,p,f,m,Ot.disabled,l,r.id,o,a,_,r.paint,d.zoom,i,[s])}},heatmap:function(t,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=zt.disabled,l=new Rt([s.ONE,s.ONE,s.ONE,s.ONE],e.aA.transparent,[!0,!0,!0,!0]);!(function(e,t,i,r){const n=e.gl,o=t.width*r,s=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!0,null),(function(e,t,i,r,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)})(e,0,t,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)})(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.aA.transparent});const c=t.transform,h="globe"===c.projection.name,u=h?["PROJECTION_GLOBE_VIEW"]:[],d=h?Ot.frontCCW:Ot.disabled,p=[e.a8(c.center.lng),e.ah(c.center.lat)];for(let e=0;e({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)})(t,r))},line:function(t,i,r,n){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),s=r.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=r.paint.get("line-emissive-strength"),l=t.depthModeForSublayer(0,Ct.ReadOnly),c=t.colorModeForDrapableLayerRenderPass(a),h=t.terrain&&t.terrain.renderingToTexture?1:e.f.devicePixelRatio,u=r.paint.get("line-dasharray"),d=u.constantOr(1),p=r.layout.get("line-cap"),f=r.paint.get("line-pattern"),m=f.constantOr(1),_=1!==r.paint.get("line-opacity").constantOr(1);let g=!m&&_;const y=r.paint.get("line-gradient"),x=m?"linePattern":"line",v=t.context,b=v.gl,w=e.cH(r);t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(g=!1);for(const o of n){const n=i.getTile(o);if(m&&!n.patternsLoaded())continue;const s=n.getBucket(r);if(!s)continue;t.prepareDrawTile();const a=s.programConfigurations.get(r.id),_=t.isTileAffectedByFog(o),T=t.getOrCreateProgram(x,{config:a,defines:w,overrideFog:_}),E=f.constantOr(null);if(E&&n.imageAtlas){const e=n.imageAtlas.patternPositions[E.toString()];e&&a.setConstantPatternPositions(e)}const S=u.constantOr(null),M=p.constantOr(null);if(!m&&S&&M&&n.lineAtlas){const e=n.lineAtlas.getDash(S,M);e&&a.setConstantPatternPositions(e)}let[A,I]=r.paint.get("line-trim-offset");if("round"===M||"square"===M){const e=1;A!==I&&(0===A&&(A-=e),1===I&&(I+=e))}const C=t.terrain?o.projMatrix:null,P=m?e.cI(t,n,r,C,h,[A,I]):e.cJ(t,n,r,C,s.lineClipsArray.length,h,[A,I]);if(y){const n=s.gradients[r.id];let a=n.texture;if(r.gradientVersion!==n.version){let l=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<{T.draw(t,b.TRIANGLES,l,e,c,Ot.disabled,P,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,t.transform.zoom,a,[s.layoutVertexBuffer2,s.patternVertexBuffer])};if(g){const e=t.stencilModeForClipping(o).ref;0===e&&t.terrain&&v.clear({stencil:0});const i={func:b.EQUAL,mask:255};P.u_alpha_discard_threshold=.8,z(new zt(i,e,255,b.KEEP,b.KEEP,b.INVERT)),P.u_alpha_discard_threshold=0,z(new zt(i,e,255,b.KEEP,b.KEEP,b.KEEP))}else z(t.stencilModeForClipping(o))}g&&(t.resetStencilClippingMasks(),t.terrain&&v.clear({stencil:0}))},fill:function(t,i,r,n){const o=r.paint.get("fill-color"),s=r.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=r.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=r.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.aA.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===h){const e=t.depthModeForSublayer(1,"opaque"===t.renderPass?Ct.ReadWrite:Ct.ReadOnly);so(t,i,r,n,e,l,!1)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const e=t.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,Ct.ReadOnly);so(t,i,r,n,e,l,!0)}},"fill-extrusion":function(t,i,r,n){const o=r.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const h=t.conflationActive&&t.layerUsedInConflation(r,i.getSource());if(h&&(function(e,t,i,r){for(const n of r){const r=t.getTile(n).getBucket(i);r&&(r.updateReplacement(n,e.replacementSource),r.uploadCentroid(e.context))}})(t,i,r,n),l||h)for(const e of n){const n=i.getTile(e).getBucket(r);n&&co(t.context,i,e,n,r,l,h)}if("shadow"===t.renderPass&&t.shadowRenderer){const s=t.shadowRenderer;if(l&&o<.65&&r._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.Z)return;const a=s.getShadowPassDepthMode(),c=s.getShadowPassColorMode();ao(t,i,r,n,a,zt.disabled,c,h)}else if("translucent"===t.renderPass){const u=!r.paint.get("fill-extrusion-pattern").constantOr(1),d=r.paint.get("fill-extrusion-color").constantOr(e.aA.white);if(!c&&0!==d.a){const e=new Ct(t.context.gl.LEQUAL,Ct.ReadWrite,t.depthRangeFor3D);1===o&&u?ao(t,i,r,n,e,zt.disabled,Rt.unblended,h):(ao(t,i,r,n,e,zt.disabled,Rt.disabled,h),ao(t,i,r,n,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),h),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&u&&(!l&&"globe"!==t.transform.projection.name||c)){const o=r.paint.get("fill-extrusion-opacity"),u=r.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=r.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=r.paint.get("fill-extrusion-flood-light-intensity"),f=r.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),m=u>0&&d>0,_=p>0,g=(e,t,i)=>(1-i)*e+i*t,y=s=>{const l=t.depthModeForSublayer(1,Ct.ReadOnly,a.LEQUAL,!0),c=r.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),m=g(.1,3,c),_=t._showOverdrawInspector;if(!_){const c=new zt({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),_=new Rt([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!1,!1,!1,!0],a.MIN);lo(t,i,r,n,l,c,_,Ot.disabled,s,"sdf",o,u,d,p,f,m,h,!1)}{const c=_?zt.disabled:new zt({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=_?t.colorModeForRenderPass():new Rt([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.aA.transparent,[!0,!0,!0,!0]);lo(t,i,r,n,l,c,g,Ot.disabled,s,"color",o,u,d,p,f,m,h,!1)}};if(c){const c=(s,l,c)=>{const m=t.depthModeForSublayer(1,Ct.ReadOnly,a.LEQUAL,!1),_=r.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),y=g(.1,3,_);{const c=new Rt([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!1,!1,!1,!0]);lo(t,i,r,n,m,zt.disabled,c,Ot.disabled,s,"clear",o,u,d,p,f,y,h,l)}{const c=new zt({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),_=new Rt([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!1,!1,!1,!0],a.MIN);lo(t,i,r,n,m,c,_,Ot.disabled,s,"sdf",o,u,d,p,f,y,h,l)}{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,_=new zt({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=new Rt([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.aA.transparent,[!0,!0,!0,!0]);lo(t,i,r,n,m,_,g,Ot.disabled,s,"color",o,u,d,p,f,y,h,l)}{const _=new Rt([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.aA.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);lo(t,i,r,n,m,zt.disabled,_,Ot.disabled,s,"clear",o,u,d,p,f,y,h,l,c)}};if(m||_){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],r=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===r)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(s,new e.h({width:t,height:r}),a.RGBA)),i.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,t,r,0)}m&&c(!0,!1,i),_&&c(!1,!0,i)}}else m&&y(!0),_&&y(!1)}}},hillshade:function(e,t,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const n=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},r]:e.stencilConfigForOverlap(r);for(const r of a){const n=t.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)rn(e,n,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Ct.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):s[r.overscaledZ];en(e,r,n,i,t,c,l)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,i,r,n,o,s){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==r.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const h=t.context,u=h.gl,d=i.getSource(),p=(function(t,i,r,n){const o=i.paint.get("raster-color"),s="raster-array"===t.type,a=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let h=i.paint.get("raster-color-range");const u=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?n.NEAREST:n.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=n.NEAREST,!h&&t.rasterLayers)){const e=t.rasterLayers.find((({id:e})=>e===i.sourceLayer));e&&e.fields&&e.fields.range&&(h=e.fields.range)}if(h=h||[0,1],o){a.push("RASTER_COLOR"),r.activeTexture.set(n.TEXTURE2),i.updateColorRamp(h);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(r,i.colorRamp,n.RGBA)),t.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:u,range:h,offset:d,defines:a,resampling:p}})(d,r,h,u);if(d instanceof e.as&&!n.length&&!a)return;const f=r.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(f),_=t.terrain&&t.terrain.renderingToTexture,g=!t.options.moving,y="nearest"===r.paint.get("raster-resampling")?u.NEAREST:u.LINEAR;if(d instanceof e.as&&!n.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():zt.disabled;return void _o(!!d.onNorthPole,null,t,i,r,f,p,Ot.disabled,e)}if(!n.length)return;const[x,v]=d instanceof e.as||_?[{},n]:t.stencilConfigForOverlap(n),b=v[v.length-1].overscaledZ;c&&p.defines.push("PROJECTION_GLOBE_VIEW"),l&&p.defines.push("RENDER_CUTOFF");const w=(n,o,v)=>{for(const w of n){const n=w.toUnwrapped(),T=i.getTile(w);if(_&&(!T||!T.hasData()))continue;h.activeTexture.set(u.TEXTURE0);const E=yo(T,d,r,p);if(!E||!E.texture)continue;const{texture:S,mix:M,offset:A,tileSize:I,buffer:C}=E;let P,z;_?(P=Ct.disabled,z=w.projMatrix):l?(P=new Ct(u.LEQUAL,Ct.ReadWrite,t.depthRangeFor3D),z=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(n,g)):(P=t.depthModeForSublayer(w.overscaledZ-b,1===r.paint.get("raster-opacity")?Ct.ReadWrite:Ct.ReadOnly,u.LESS),z=t.transform.calculateProjMatrix(n,g));const D=t.terrain&&_?t.terrain.stencilModeForRTTOverlap(w):x[w.overscaledZ],R=s?0:r.paint.get("raster-fade-duration");T.registerFadeDuration(R);const L=i.findLoadedParent(w,0),k=pn(T,L,i,t.transform,R);let O,B;t.terrain&&t.terrain.prepareDrawTile(),h.activeTexture.set(u.TEXTURE0),S.bind(y,u.CLAMP_TO_EDGE),h.activeTexture.set(u.TEXTURE1),L?(L.texture&&L.texture.bind(y,u.CLAMP_TO_EDGE),O=Math.pow(2,L.tileID.overscaledZ-T.tileID.overscaledZ),B=[T.tileID.canonical.x*O%1,T.tileID.canonical.y*O%1]):S.bind(y,u.CLAMP_TO_EDGE),S.useMipmap&&h.extTextureFilterAnisotropic&&t.transform.pitch>20&&u.texParameterf(u.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const F=t.transform;let N;const V=l?go(F):[0,0,0,0];let U,j,G,q,Z,$=0;if(c&&d instanceof e.as&&d.coordinates.length>3)U=Float32Array.from(e.aW(e.cn(new e.bv(0,0,0)))),j=Float32Array.from(F.globeMatrix),G=Float32Array.from(e.cj(F)),q=[e.a8(F.center.lng),e.ah(F.center.lat)],N=d.elevatedGlobePerspectiveTransform,Z=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.ck(w.canonical);$=e.cl(t.getCenter().lat),U=Float32Array.from(e.aW(e.cn(w.canonical))),j=Float32Array.from(F.globeMatrix),G=Float32Array.from(e.cj(F)),q=[e.a8(F.center.lng),e.ah(F.center.lat)],N=[0,0],Z=Float32Array.from(e.cm(w.canonical,t,$,F.worldSize/F._pixelsPerMercatorPixel))}else N=d instanceof e.as?d.perspectiveTransform:[0,0],U=new Float32Array(16),j=new Float32Array(9),G=new Float32Array(16),q=[0,0],Z=new Float32Array(9);const W=Bn(z,U,j,G,Z,B||[0,0],e.W(t.transform.zoom),q,V,O||1,k,r,N,l?r.paint.get("raster-elevation"):0,2,M,A,p.range,I,C,f),Q=t.isTileAffectedByFog(w),H=t.getOrCreateProgram("raster",{defines:p.defines,overrideFog:Q});if(t.uploadCommonUniforms(h,H,n),d instanceof e.as){const i=d.elevatedGlobeVertexBuffer,n=d.elevatedGlobeIndexBuffer;if(_||!a)d.boundsBuffer&&d.boundsSegments&&H.draw(t,u.TRIANGLES,P,zt.disabled,m,Ot.disabled,W,r.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&n){const s=F.zoom<=e.bJ?d.elevatedGlobeSegments:d.getSegmentsForLongitude(F.center.lng);s&&H.draw(t,u.TRIANGLES,P,zt.disabled,m,o,W,r.id,i,n,s)}}else if(c){P=new Ct(u.LEQUAL,Ct.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[i,n,s]=e.getGridBuffers($,!1);H.draw(t,u.TRIANGLES,P,v||D,t.colorModeForRenderPass(),o,W,r.id,i,n,s)}}else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:n}=t.getTileBoundsBuffers(T);H.draw(t,u.TRIANGLES,P,D,m,Ot.disabled,W,r.id,e,i,n)}}if(!(d instanceof e.as)&&c)for(const e of n){const n=e.canonical.y===(1<e.cN[t](n)));f.push(n);const m=n.canonical.x,_=n.canonical.y;for(const e of f){const o=i.getTile(l?e.wrapped():e);if(!o)continue;const a=o.rasterParticleState;if(!a)continue;const h=e.canonical.x+(1<e.tileID))),u&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context,i.scope));for(const d of y){const y=e.isTileAffectedByFog(d),x=e.getOrCreateProgram(_,{overrideFog:y}),v=d.toUnwrapped(),b=r?d.projMatrix:e.transform.calculateProjMatrix(v);e.prepareDrawTile();const w=t?t.getTile(d):g?g[d.key]:new jt(d,h,c.zoom,e),T=u?Wn(b,s,o,e,u,i.scope,{tileID:d,tileSize:h}):$n(b,s,o,n);e.uploadCommonUniforms(a,x,v);const{tileBoundsBuffer:E,tileBoundsIndexBuffer:S,tileBoundsSegments:M}=e.getTileBoundsBuffers(w);x.draw(e,l.TRIANGLES,f,p,m,Ot.disabled,T,i.id,E,S,M)}},sky:function(t,i,r){const n=t._atmosphere?e.W(t.transform.zoom):1,o=r.paint.get("sky-opacity")*n;if(0===o)return;const s=t.context,a=r.paint.get("sky-type"),l=new Ct(s.gl.LEQUAL,Ct.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&((function(t,i,r,n){const o=t.context,s=o.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=o.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new Ro(o),i.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let e=0;e<6;++e)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=i.getCenter(t,!0),c=t.getOrCreateProgram("skyboxCapture"),h=new Float64Array(16);e.a9.identity(h),e.a9.rotateY(h,h,.5*-Math.PI),Lo(t,i,c,h,l,0),e.a9.identity(h),e.a9.rotateY(h,h,.5*Math.PI),Lo(t,i,c,h,l,1),e.a9.identity(h),e.a9.rotateX(h,h,.5*-Math.PI),Lo(t,i,c,h,l,2),e.a9.identity(h),e.a9.rotateX(h,h,.5*Math.PI),Lo(t,i,c,h,l,3),e.a9.identity(h),Lo(t,i,c,h,l,4),e.a9.identity(h),e.a9.rotateY(h,h,Math.PI),Lo(t,i,c,h,l,5),o.viewport.set([0,0,t.width,t.height])})(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&(function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),0,r,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,zt.disabled,e.colorModeForRenderPass(),Ot.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)})(t,r,l,o,c):"gradient"===a&&"sky"===t.renderPass&&(function(t,i,r,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ro(s)),s.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(s,i.colorRamp,a.RGBA)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const u=((t,i,r,n,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.bm(r),u_opacity:n,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),n,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,r,zt.disabled,t.colorModeForRenderPass(),Ot.backCW,u,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)})(t,r,l,o,c)},debug:function(t,i,r,n,o,s){for(let a=0;a{a&&(a.useNormalOffset=!0,l||(a.enabled=!0))},h=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==h.type)return;if("vector"===h.type||"geojson"===h.type)return(function(t,i,r,n,o){const s=t.transform;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D models for ${s.projection.name} projection is not yet implemented`);const a=s.getFreeCameraOptions().position;if(!t.modelManager)return;const l=t.modelManager;r.modelManager=l;const c=t.shadowRenderer;if(!r._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const h=r._unevaluatedLayout._values["model-id"],d=u({},r.layout.get("model-id").parameters);for(const u of n){const n=i.getTile(u).getBucket(r);if(!n||n.projection.name!==s.projection.name)continue;const p=n.getModelUris();p&&!n.modelsRequested&&(l.addModelsFromBucket(p,o),n.modelsRequested=!0);const f=Wo(u,s);d.zoom=f;const m=h.possiblyEvaluate(d);if(Zo(t,n,u),$o.shadowUniformsInitialized=!1,$o.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(u.toUnwrapped()),"shadow"===t.renderPass&&c){if(1===t.currentShadowCascade&&n.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(u.toUnwrapped(),s.worldSize);if($o.tileMatrix.set(i),$o.shadowTileMatrix=Float32Array.from(c.calculateShadowPassMatrixFromMatrix(i)),$o.aabb.min.fill(0),$o.aabb.max[0]=$o.aabb.max[1]=e.Y,$o.aabb.max[2]=0,Xo(n,$o,t,r.scope))continue}const _=1<0&&(e=m.evaluate(i.features[0].feature,{}));const s=l.getModel(e,o);if(s&&s.uploaded)for(const e of s.nodes)Qo(t,r,e,i,g,u,$o)}}})(t,i,r,n,"vector"===h.type?r.scope:""),void c();if(!h.loaded())return;if("batched-model"===h.type)return(function(t,i,r,n){r.resetLayerRenderingStats(t);const o=t.context,s=t.transform,a=t.style.fog,l=t.shadowRenderer;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D landmark models for ${s.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,h=e.Q.scale([],[c.x,c.y,c.z],t.transform.worldSize);e.Q.negate(h,h);const u=e.a9.identity([]),d=e.cZ(s.center.lat,s.zoom),p=e.a9.fromScaling([],[1,1,1/d]);e.a9.translate(u,u,h);const f=r.paint.get("model-opacity"),m=new Ct(o.gl.LEQUAL,Ct.ReadWrite,t.depthRangeFor3D),_=new Ct(o.gl.LEQUAL,Ct.ReadOnly,t.depthRangeFor3D),g=new e.bV([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),y="shadow"===t.renderPass,x=y&&l?l.getCurrentCascadeFrustum():s.getFrustum(s.scaleZoom(s.worldSize)),v=r.getLayerRenderingStats(),b=function(c,h){for(const d of n){const n=i.getTile(d).getBucket(r);if(!n||!n.uploaded)continue;let b=!1;l&&(b=0===l.getMaxCascadeForTile(d.toUnwrapped()));const w=s.calculatePosMatrix(d.toUnwrapped(),s.worldSize),T=n.modelTraits;for(const i of n.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const n=i.evaluatedScale,d=i.node;let E=0;if(t.terrain&&d.elevation&&(E=d.elevation*t.terrain.exaggeration()),n[0]<=1&&n[1]<=1&&n[2]<=1&&0===(()=>{const t=i.getLocalBounds();return g.min=[...t.min],g.max=[...t.max],g.min[2]+=E,g.max[2]+=E,e.Q.transformMat4(g.min,g.min,w),e.Q.transformMat4(g.max,g.max,w),g})().intersects(x))continue;const S=[...w];e.a9.translate(S,S,[(d.anchor?d.anchor[0]:0)*(n[0]-1),(d.anchor?d.anchor[1]:0)*(n[1]-1),E]),e.Q.exactEquals(n,e.c$)||e.a9.scale(S,S,n);const M=e.a9.multiply([],S,d.matrix);let A=e.a9.multiply([],p,S);e.a9.multiply(A,u,A);const I=e.a9.invert([],A);e.a9.transpose(I,I),e.a9.scale(I,I,Ho),A=e.a9.multiply(A,A,d.matrix);const C="light-beam"===t.renderPass,P=e.a9.multiply([],s.expandedFarZProjMatrix,M),z=e.a9.multiply([],s.expandedFarZProjMatrix,S),D=T&e.d1.HasMapboxMeshFeatures,R=D?0:i.evaluatedRMEA[0][2];for(let e=0;e=_e||o>=_e}}const T=n.material;let E;T.occlusionTexture&&T.occlusionTexture.offsetScale&&(E=T.occlusionTexture.offsetScale,g.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!y&&l&&(l.useNormalOffset=!!n.normalBuffer);const L=t.getOrCreateProgram("model",g);!y&&l&&l.setupShadowsFromMatrix(S,L,l.useNormalOffset),t.uploadCommonUniforms(o,L,null,w);const k=T.pbrMetallicRoughness;k.metallicFactor=.9,k.roughnessFactor=.5;const O=Hn(new Float32Array(p),new Float32Array(A),new Float32Array(I),new Float32Array(d.matrix),t,f,k.baseColorFactor,T.emissiveFactor,k.metallicFactor,k.roughnessFactor,T,R,r,[0,0,0],E);L.draw(t,o.gl.TRIANGLES,h&&!u?m:_,zt.disabled,c?u||f<1||i.hasTranslucentParts?Rt.alphaBlended:Rt.unblended:Rt.disabled,Ot.backCCW,O,r.id,n.vertexBuffer,n.indexBuffer,n.segments,r.paint,t.transform.zoom,void 0,x)}}}};(function(e,t,i,r){const n=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const s of r){const r=t.getTile(s).getBucket(i);r&&(e.conflationActive&&r.updateReplacement(s,e.replacementSource),r.evaluateScale(e,i),e.terrain&&n>0&&r.elevationUpdate(e.terrain,n,s,i.source),r.needsReEvaluation(e,o,i)&&r.evaluate(i))}})(t,i,r,n),1===f?b(!0,!0):(b(!1,!0),b(!0,!1))})(t,i,r,n),void c();const d=h.getModels(),p=[],f=t.transform.getFreeCameraOptions().position,m=e.Q.scale([],[f.x,f.y,f.z],t.transform.worldSize);e.Q.negate(m,m);const _=[],g=[];let y=0;for(const i of d){const n=r.paint.get("model-rotation").constantOr(null),o=r.paint.get("model-scale").constantOr(null),s=r.paint.get("model-translation").constantOr(null);i.computeModelMatrix(t,n,o,s,!0,!0,!1);const a=e.a9.identity([]),l=e.cZ(i.position.lat,t.transform.zoom),c=e.a9.fromScaling([],[1,1,1/l]);e.a9.translate(a,a,m),p.push({zScaleMatrix:c,negCameraPosMatrix:a});for(const e of i.nodes)Go(t.transform,e,i.matrix,t.transform.expandedFarZProjMatrix,y,_,g);y++}if(_.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass){if(1===o)for(const e of g)jo(e,t,r,p[e.modelIndex],zt.disabled,t.colorModeForRenderPass());else{for(const e of g)jo(e,t,r,p[e.modelIndex],zt.disabled,Rt.disabled);for(const e of g)jo(e,t,r,p[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks()}for(const e of _)jo(e,t,r,p[e.modelIndex],zt.disabled,t.colorModeForRenderPass());c()}else{for(const e of g)qo(e.mesh,e.nodeModelMatrix,t,r);for(const e of _)qo(e.mesh,e.nodeModelMatrix,t,r);c()}}},es={model:function(e,t,i){const r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(i.modelManager&&i.modelManager.upload(i,"vector"===r.type?e.scope:""));if("batched-model"===r.type)return;const n=r.getModels();for(const e of n)e.upload(i.context)},raster:function(e,t,i){const r=t.getSource();if(!(r instanceof Le&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&r.prepareTile(e,n,o)},"raster-particle":function(e,t,i){const r=t.getSource();if(!(r instanceof Le&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-particle-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&r.prepareTile(e,n,o)}};class ts{constructor(t,i,r,n){this.context=new Bt(t,i),this.transform=r,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=n,this._timeStamp=(new Date).getTime(),this._averageFPS=0,this._fpsHistory=[],this._debugParams={showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const o=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(const e of o)this._debugParams.enabledLayers[e]=!0;n.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(()=>{this.style.map.triggerRepaint()})),n.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),n.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),n.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),n.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of o)n.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.setup(),this.numSublayers=Yt.maxUnderzooming+Yt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.d3,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new wr(this),this._wireframeDebugCache=new Jo,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new gn(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.enabled&&(this.transform.elevation=null)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.f.devicePixelRatio,this.height=i*e.f.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize()}setup(){const t=this.context,i=new e.aQ;i.emplaceBack(0,0),i.emplaceBack(e.Y,0),i.emplaceBack(0,e.Y),i.emplaceBack(e.Y,e.Y),this.tileExtentBuffer=t.createVertexBuffer(i,e.aS.members),this.tileExtentSegments=e.aE.simpleSegment(0,0,4,2);const r=new e.aQ;r.emplaceBack(0,0),r.emplaceBack(e.Y,0),r.emplaceBack(0,e.Y),r.emplaceBack(e.Y,e.Y),this.debugBuffer=t.createVertexBuffer(r,e.aS.members),this.debugSegments=e.aE.simpleSegment(0,0,4,5);const n=new e.aQ;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.aS.members),this.viewportSegments=e.aE.simpleSegment(0,0,4,2);const o=new e.ay;o.emplaceBack(0,0,0,0),o.emplaceBack(e.Y,0,e.Y,0),o.emplaceBack(0,e.Y,0,e.Y),o.emplaceBack(e.Y,e.Y,e.Y,e.Y),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.aU.members),this.mercatorBoundsSegments=e.aE.simpleSegment(0,0,4,2);const s=new e.az;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.aR;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.h({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.a9.create();const l=this.context.gl;this.stencilClearMode=new zt({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,Ct.disabled,this.stencilClearMode,Rt.disabled,Ot.disabled,dn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,n=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(Rt.disabled),r.setDepthMode(Ct.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),r=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);o.draw(this,n.TRIANGLES,Ct.disabled,new zt({func:n.ALWAYS,mask:0},r,255,n.KEEP,n.KEEP,n.REPLACE),Rt.disabled,Ot.disabled,dn(e.projMatrix),"$clipping",s,a,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new zt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new zt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Rt([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.aA(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,r=!1){if(!this.opaquePassEnabledForLayer()&&!r)return Ct.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Ct(i||this.context.gl.LEQUAL,t,[n,n])}opaquePassEnabledForLayer(){return this.currentLayerthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce(((e,t)=>e+t/this._fpsHistory.length),0))}render(t,i){this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const r=this.style._mergedLayers,n=this.style.order.filter((e=>{const t=r[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]})),o=n.map((e=>r[e])),s=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.f.now()),this.imageManager.beginFrame();let a=0,l=!1;for(const e in s){const t=s[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++a)}for(const e of o)e.isHidden(this.transform.zoom)||this.prepareLayer(e);const c={},h={},u={},d={},p={};for(const e in s){const t=s[e];c[e]=t.getVisibleCoordinates(),h[e]=c[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse(),d[e]=t.getShadowCasterCoordinates(),p[e]=t.sortCoordinatesByDistance(c[e])}const f=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(a){const e=[];for(const t of o)this.layerUsedInConflation(t,f(t))&&e.push(t);if(e.length>1){const t=[];for(const i of e){const e=this.style.getLayerSourceCache(i);e&&e.used&&e.getSource().usedInConflation&&t.push({layer:i.fqid,cache:e})}this.replacementSource.setSources(t),l=!0}}l||this.replacementSource.clear(),this.conflationActive=l,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const e of o){const t=e.cutoffRange();if(this.longestCutoffRange=Math.max(t,this.longestCutoffRange),t>0){const t=f(e);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),e.minzoom&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom))}}this.opaquePassCutoff=1/0;for(let e=0;e{if(i.showOverdrawInspector)return e.aA.black;if(this.style.fog&&this.transform.projection.supportsFog&&!y){const t=this.style.fog.properties.get("color").toArray01();return new e.aA(...t)}if(this.style.fog&&this.transform.projection.supportsFog&&y){const t=this.style.fog.properties.get("space-color").toArray01();return new e.aA(...t)}return e.aA.transparent})();if(this.context.clear({color:x,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const e=o[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const r=i?(e.is3D()?p:h)[i.id]:void 0;this._renderTileClippingMasks(e,i,r),this.renderLayer(this,i,e,r)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.W(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--b&&(_.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=o[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?h[i.id]:void 0)}this.currentLayer=e,this.renderPass="translucent"}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;o.forEach((e=>{const r=t.getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}isPatternMissing(e,t){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString(),t)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const r=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,n=this.terrain&&0===this.terrain.exaggeration(),o=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(o.push("LIGHTING_3D_MODE"),o.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||o.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||o.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?o.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):o.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(o.push("TERRAIN"),this.linearFloatFilteringSupported()&&o.push("TERRAIN_DEM_FLOAT_FORMAT"),n&&o.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&o.push("GLOBE"),!this._fogVisible||r||void 0!==t&&!t||o.push("FOG","FOG_DITHERING"),r&&o.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&o.push("OVERDRAW_INSPECTOR"),o}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],r=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=bn.cacheKey(Hr[e],e,n,r);return this.cache[o]||(this.cache[o]=new bn(this.context,e,Hr[e],r,Yn[e],n)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const r=this.style.directionalLight,n=this.style.ambientLight;if(r&&n){const o=((t,i)=>{const r=t.properties.get("direction"),n=t.properties.get("color").toArray01(),o=t.properties.get("intensity"),s=i.properties.get("color").toArray01(),a=i.properties.get("intensity"),l=[r.x,r.y,r.z],c=e.cs(s,a),h=e.cs(n,o);return{u_lighting_ambient_color:c,u_lighting_directional_dir:l,u_lighting_directional_color:h,u_ground_radiance:yn(l,h,c)}})(r,n);i.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,i,r,n,o){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const o=s.getOpacity(this.transform.pitch),a=((t,i,r,n,o,s,a,l,c,h,u,d)=>{const p=t.transform,f=i.properties.get("color").toArray01();f[3]=n;const m=t.frameCounter/1e3%1,[_,g]=i.properties.get("vertical-range");return{u_fog_matrix:r?p.calculateFogTileMatrix(r):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:f,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_,g),g],u_fog_temporal_offset:m,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:u,u_globe_transition:e.W(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,r,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.f.devicePixelRatio,this.transform.height*e.f.devicePixelRatio],n);i.setFogUniformValues(t,a)}o&&i.setCutoffUniformValues(t,o.uniformValues)}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)t[r.key]=e[r.key]||new jt(r,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={}}layerUsedInConflation(e,t){return!(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||"building"!==e.sourceLayer&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=_e||t[1]>=_e}}function is(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1)};return()=>(i=!0,r||n(),r)}class rs{constructor(t){this._hashName=t&&encodeURIComponent(t),e.a$(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=is(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const t=ns(e);if(this._hashName){const e=this._hashName;let i=!1;const r=location.hash.slice(1).split("&").map((r=>{const n=r.split("=")[0];return n===e?(i=!0,`${n}=${t}`):r})).filter((e=>e));return i||r.push(`${e}=${t}`),`#${r.join("&")}`}return`#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function ns(e,t){const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(2.8444444444444446))/Math.LN10),o=Math.pow(10,n),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let h=t?`/${s}/${a}/${r}`:`${r}/${a}/${s}`;return(l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const os={linearity:.3,easing:e.d6(0,0,.3,1)},ss=e.e({deceleration:2500,maxSpeed:1400},os),as=e.e({deceleration:20,maxSpeed:1400},os),ls=e.e({deceleration:1e3,maxSpeed:360},os),cs=e.e({deceleration:1e3,maxSpeed:90},os);class hs{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.f.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.f.now();for(;t.length>0&&i-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const o=ds(i.pan.mag(),r,e.e({},ss,t||{}));n.offset=i.pan.mult(o.amount/i.pan.mag()),n.center=this._map.transform.center,us(n,o)}if(i.zoom){const e=ds(i.zoom,r,as);n.zoom=this._map.transform.zoom+e.amount,us(n,e)}if(i.bearing){const t=ds(i.bearing,r,ls);n.bearing=this._map.transform.bearing+e.ad(t.amount,-179,179),us(n,t)}if(i.pitch){const e=ds(i.pitch,r,cs);n.pitch=this._map.transform.pitch+e.amount,us(n,e)}if(n.zoom||n.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function us(e,t){(!e.duration||e.durationi.unproject(e))),a=o.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new e.P(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class ms extends e.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class _s{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new ms(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ps(e.type,this._map,e))}mouseup(e){this._map.fire(new ps(e.type,this._map,e))}preclick(t){const i=e.e({},t);i.type="preclick",this._map.fire(new ps(i.type,this._map,i))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new ps(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new ps(e.type,this._map,e))}mouseover(e){this._map.fire(new ps(e.type,this._map,e))}mouseout(e){this._map.fire(new ps(e.type,this._map,e))}touchstart(e){return this._firePreventable(new fs(e.type,this._map,e))}touchmove(e){this._map.fire(new fs(e.type,this._map,e))}touchend(e){this._map.fire(new fs(e.type,this._map,e))}touchcancel(e){this._map.fire(new fs(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class gs{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new ps(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ps("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new ps(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ys{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(p(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t,r=this._startPos,n=this._lastPos;if(!r||!n||n.equals(i)||!this._box&&i.dist(r){this._box&&(this._box.style.transform=`translate(${s}px,${l}px)`,this._box.style.width=a-s+"px",this._box.style.height=c-l+"px")}))}mouseupWindow(t,i){if(!this._active)return;const r=this._startPos,n=i;if(r&&0===t.button){if(this.reset(),_(),r.x!==n.x||r.y!==n.y)return this._map.fire(new e.b("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,n,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),f(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.b(t,{originalEvent:i}))}}function xs(e,t){const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=(function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)})(i),this.touches=xs(r,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=xs(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class bs{constructor(e){this.singleTap=new vs(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class ws{constructor(){this._zoomIn=new bs({numTouches:1,numTaps:2}),this._zoomOut=new bs({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Ts={0:1,2:2};class Es{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const i=x(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i)}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&(function(e,t){const i=Ts[t];return void 0===e.buttons||(e.buttons&i)!==i})(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const n=xs(r,i),o=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in n){const t=n[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,n[e]=t)}if(this._touches=n,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")}),500)}}class Cs{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,i){return{}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,s=Ps(i,t,n),a=Ps(i,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=Ps(i,t,r),s=Ps(i,t,n);o&&s||(this._active&&_(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ps(e,t,i){for(let r=0;rMath.abs(e.x)}class Os extends Cs{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,ks(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,i,r){const n=this._lastPoints;if(!n)return;const o=t[0].sub(n[0]),s=t[1].sub(n[1]);return this._map._cooperativeGestures&&!e.d7()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return ks(e)&&ks(t)&&o}}const Bs={panStep:100,bearingStep:15,pitchStep:10};class Fs{constructor(){const e=Bs;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Ns,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Ns(e){return e*(2-e)}const Vs=4.000244140625;class Us{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.a$(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.d7()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=e.f.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%Vs==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=g(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Vs?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const n=i(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:i(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const t=Math.min((e.f.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.X(n,r,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=r,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200));let l=s-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.d8;if(this._prevEase){const t=this._prevEase,r=(e.f.now()-t.start)/t.duration,n=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.d6(o,s,.25,1)}return this._prevEase={start:e.f.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")}),200)}}class js{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Gs{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qs{constructor(){this._tap=new bs({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i))}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zs{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class $s{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Ws{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Qs=e=>e.zoom||e.drag||e.pitch||e.rotate;class Hs extends e.b{}class Xs{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const r=e.Q.sub([],i,t);this.radius=e.Q.length(r[2]<0?e.Q.div([],r,this.constants):[r[0],r[1],0])}projectRay(t){e.Q.div(t,t,this.constants),e.Q.normalize(t,t),e.Q.mul(t,t,this.constants);const i=e.Q.scale([],t,this.radius);if(i[2]>0){const t=e.Q.scale([],[0,0,1],e.Q.dot(i,[0,0,1])),r=e.Q.scale([],e.Q.normalize([],[i[0],i[1],0]),this.radius),n=e.Q.add([],i,e.Q.scale([],e.Q.sub([],e.Q.add([],r,t),i),2));i[0]=n[0],i[1]=n[1]}return i}}function Ys(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Js{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new hs(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Xs,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.a$(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,r,i)}}destroy(){for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,r,i)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new _s(t,e));const r=t.boxZoom=new ys(t,e);this._add("boxZoom",r);const n=new ws,o=new Gs;t.doubleClickZoom=new js(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new qs;this._add("tapDragZoom",s);const a=t.touchPitch=new Os(t);this._add("touchPitch",a);const l=new Ms(e),c=new As(e);t.dragRotate=new $s(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Ss(e),u=new Is(t,e);t.dragPan=new Zs(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const d=new Ls,p=new Ds;t.touchZoomRotate=new Ws(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new gs(t));const f=t.scrollZoom=new Us(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new Fs;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i])}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Qs(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,r=i?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?y(this._el,a):i?void 0:g(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(s,h,i)?c.reset():c[t||e.type]&&(u=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,u,i,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=r);this._previousActiveHandlers=s,(Object.keys(c).length||Ys(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Ys(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=n;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))}mergeHandlerResult(t,i,r,n,o){if(!r)return;e.e(t,r);const s={handlerName:n,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const t={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.aroundCoord&&(t.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.e(i,o),e.e(r,s);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,i,r){const n=this._map,o=n.transform,s=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Ys(t)){const e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&n._stop(!0),!Ys(t))return void this._fireEvents(i,r,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:u,aroundCoord:d,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(u=p),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&u&&(this._dragOrigin=s(o.pointCoordinate3D(u)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),u=u||n.transform.centerPoint,c&&(o.bearing+=c),h&&(o.pitch+=h),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(u).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(u.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=o.pointCoordinate(u);if("globe"===o.projection.name){a=a.rotate(-o.angle);const i=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.d9(e.ax(t.y))*i,f[1]=-a.y*e.d9(o.center.lat)*i}else{const e=o.pointCoordinate(u.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,_=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(u)),i={dir:e.Q.normalize([],e.Q.sub([],t,o._camera.position))};if(i.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e.Q.scale(_,i.dir,r)}}const g=e.Q.add(f,f,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,r,!0)}_fireEvents(t,i,r){const n=Qs(this._eventsInProgress),o=Qs(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||r,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=Qs(this._eventsInProgress);if(r&&(n||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Hs("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Ks="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ea extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.a$(["_renderFrameCallback"],this)}getCenter(){return new e.bq(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,r){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),r)}panTo(t,i,r){return this.easeTo(e.e({center:t},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,r){return this.easeTo(e.e({zoom:t},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,i,r){return this.easeTo(e.e({bearing:t},i),r)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,r,n,o,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.bq.convert(i),h=e.bq.convert(r),u=.5*(c.lat+h.lat),d=.5*(c.lng+h.lng),p=e.da(u,d),f=e.Q.normalize([],p),m=e.Q.normalize([],e.Q.cross([],f,[0,1,0])),_=e.Q.cross([],m,f),g=[m[0],m[1],m[2],0,_[0],_[1],_[2],0,f[0],f[1],f[2],0,0,0,0,1],y=[p,e.da(c.lat,c.lng),e.da(h.lat,c.lng),e.da(h.lat,h.lng),e.da(c.lat,h.lng),e.da(u,c.lng),e.da(u,h.lng),e.da(c.lat,d),e.da(h.lat,d)];let x=e.bV.fromPoints(y.map((t=>[e.Q.dot(m,t),e.Q.dot(_,t),e.Q.dot(f,t)])));const v=e.Q.transformMat4([],x.center,g);0===e.Q.squaredLength(v)&&e.Q.set(v,0,0,1),e.Q.normalize(v,v),e.Q.scale(v,v,e.ae),a.center=e.db(v);const b=a.getWorldToCameraMatrix(),w=e.a9.invert(new Float64Array(16),b);x=e.bV.applyTransform(x,e.a9.multiply([],b,g));const T=this._extendAABB(x,a,l,n);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T,e.Q.transformMat4(v,v,b);const E=.5*(x.max[2]-x.min[2]),S=this._minimumAABBFrustumDistance(a,x),M=e.Q.scale([],[0,0,1],E),A=e.Q.add(M,v,M),I=S+(0===a.pitch?0:e.Q.distance(v,A)),C=a.globeCenterInViewSpace,P=e.Q.sub([],v,[C[0],C[1],C[2]]);e.Q.normalize(P,P),e.Q.scale(P,P,I);const z=e.Q.add([],v,P);e.Q.transformMat4(z,z,w);const D=e.dc/e.ae,R=e.Q.length(z),L=e.bo(Math.max(R*D-e.dc,Number.EPSILON),0),k=Math.min(a.zoomFromMercatorZAdjusted(L),l.maxZoom);return k>.5*(e.bJ+e.bA)?(a.setProjection({name:"mercator"}),a.zoom=k,this._cameraForBounds(a,i,r,n,o,s)):{center:a.center,zoom:k,bearing:n,pitch:o}}_extendAABB(t,i,r,n){const o=.5*((r.padding.left||0)+(r.padding.right||0)),s=.5*((r.padding.top||0)+(r.padding.bottom||0)),a=s,l=o,c=o,h=s,u=i.width-(l+c),d=i.height-(a+h),p=e.Q.sub([],t.max,t.min),f=Math.min(u/p[0],d/p[1]),m=Math.min(i.scaleZoom(i.scale*f),r.maxZoom);if(isNaN(m))return null;const _=i.scale/i.zoomScale(m),g=new e.bV([t.min[0]-l*_,t.min[1]-h*_,t.min[2]],[t.max[0]+c*_,t.max[1]+a*_,t.max[2]]),y=("number"==typeof r.offset.x&&"number"==typeof r.offset.y?new e.P(r.offset.x,r.offset.y):e.P.convert(r.offset)).rotate(-e.bm(n));return g.center[0]-=y.x*_,g.center[1]+=y.y*_,g}queryTerrainElevation(t,i){const r=this.transform.elevation;return r?(i=e.e({},{exaggerated:!0},i),r.getAtPoint(e.O.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,r,n,o,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,r,n,o,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.bq.convert(i),h=e.bq.convert(r),u=new e.bq(c.lng,h.lat),d=new e.bq(h.lng,c.lat),p=a.project(c),f=a.project(h),m=this.queryTerrainElevation(c),_=this.queryTerrainElevation(h),g=this.queryTerrainElevation(u),y=this.queryTerrainElevation(d),x=[[p.x,p.y,Math.min(m||0,_||0,g||0,y||0)],[f.x,f.y,Math.max(m||0,_||0,g||0,y||0)]];let v=e.bV.fromPoints(x);const b=a.getWorldToCameraMatrix(),w=e.a9.invert(new Float64Array(16),b);v=e.bV.applyTransform(v,b);const T=this._extendAABB(v,a,l,n);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=T;const E=.5*e.Q.sub([],v.max,v.min)[2],S=this._minimumAABBFrustumDistance(a,v),M=[0,0,1,0];e.aa.transformMat4(M,M,b),e.aa.normalize(M,M);const A=e.Q.scale([],M,S+E),I=e.Q.add([],v.center,A);e.Q.transformMat4(v.center,v.center,w),e.Q.transformMat4(I,I,w);const C=[v.center[0],v.center[1],I[2]*a.pixelsPerMeter];e.Q.scale(C,C,1/a.worldSize);const P=e.aw(C[0]),z=e.ax(C[1]),D=Math.min(a._zoomFromMercatorZ(C[2]),l.maxZoom),R=new e.bq(P,z);return a.mercatorFromTransition&&D<.5*(e.bJ+e.bA)?(a.setProjection({name:"globe"}),a.zoom=D,this._cameraForBounds(a,i,r,n,o,s)):{center:R,zoom:D,bearing:n,pitch:o}}fitBounds(e,t,i){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,i)}fitScreenCoordinates(t,i,r,n,o){const s=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const h=this.transform.pointLocation3D(l),u=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(h.lng,u.lng,d.lng,p.lng),Math.min(h.lat,u.lat,d.lat,p.lat)],m=[Math.max(h.lng,u.lng,d.lng,p.lng),Math.max(h.lat,u.lat,d.lat,p.lat)],_=n&&n.pitch?n.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,f,m,r,_,n);return this._fitInternal(g,n,o)}_fitInternal(t,i,r){return t?(i=e.e(t,i)).linear?this.easeTo(i,r):this.flyTo(i,r):this}jumpTo(t,i){this.stop();const r=t.preloadOnly?this.transform.clone():this.transform;let n=!1,o=!1,s=!1;return"zoom"in t&&r.zoom!==+t.zoom&&(n=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.bq.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(s=!0,r.pitch=+t.pitch),null==t.padding||r.isPaddingEqual(t.padding)||(r.padding=t.padding),t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.b("movestart",i)).fire(new e.b("move",i)),n&&this.fire(new e.b("zoomstart",i)).fire(new e.b("zoom",i)).fire(new e.b("zoomend",i)),o&&this.fire(new e.b("rotatestart",i)).fire(new e.b("rotate",i)).fire(new e.b("rotateend",i)),s&&this.fire(new e.b("pitchstart",i)).fire(new e.b("pitch",i)).fire(new e.b("pitchend",i)),this.fire(new e.b("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(Ks),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const r=this.transform;if(!r.projection.supportsFreeCamera)return e.w(Ks),this;this.stop();const n=r.zoom,o=r.pitch,s=r.bearing;r.setFreeCameraOptions(t);const a=n!==r.zoom,l=o!==r.pitch,c=s!==r.bearing;return this.fire(new e.b("movestart",i)).fire(new e.b("move",i)),a&&this.fire(new e.b("zoomstart",i)).fire(new e.b("zoom",i)).fire(new e.b("zoomend",i)),c&&this.fire(new e.b("rotatestart",i)).fire(new e.b("rotate",i)).fire(new e.b("rotateend",i)),l&&this.fire(new e.b("pitchstart",i)).fire(new e.b("pitch",i)).fire(new e.b("pitchend",i)),this.fire(new e.b("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.d8},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,h="pitch"in t?+t.pitch:s,u=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===r.projection.name){const i=e.O.fromLngLat(r.center),n=d.rotate(-r.angle);i.x+=n.x/r.worldSize,i.y+=n.y/r.worldSize;const o=i.toLngLat(),s=e.bq.convert(t.center||o);this._normalizeCenter(s),p=r.centerPoint.add(n),f=new e.P(i.x,i.y).mult(r.worldSize),m=new e.P(e.a8(s.lng),e.ah(s.lat)).mult(r.worldSize).sub(f)}else{p=r.centerPoint.add(d);const i=r.pointLocation(p),n=e.bq.convert(t.center||i);this._normalizeCenter(n),f=r.project(i),m=r.project(n).sub(f)}const _=r.zoomScale(l-n);let g,y;t.around&&(g=e.bq.convert(t.around),y=r.locationPoint(g));const x=this._zooming||l!==n,v=this._rotating||o!==c,b=this._pitching||h!==s,w=!r.isPaddingEqual(u),T=r=>T=>{if(x&&(r.zoom=e.X(n,l,T)),v&&(r.bearing=e.X(o,c,T)),b&&(r.pitch=e.X(s,h,T)),w&&(r.interpolatePadding(a,u,T),p=r.centerPoint.add(d)),g)r.setLocationAtPoint(g,y);else{const e=r.zoomScale(r.zoom-n),t=l>n?Math.min(2,_):Math.max(.5,_),i=Math.pow(t,1-T),o=r.unproject(f.add(m.mult(T*i)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(T,t.duration,r);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=v,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,E),this._ease(T(r),(e=>{"sea"===r.cameraElevationReference&&r.recenterOnTerrain(),this._afterEase(i,e)}),t),this}_prepareEase(t,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||r.moving||this.fire(new e.b("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.b("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.b("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.b("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.b("move",t)),this._zooming&&this.fire(new e.b("zoom",t)),this._rotating&&this.fire(new e.b("rotate",t)),this._pitching&&this.fire(new e.b("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.b("zoomend",t)),n&&this.fire(new e.b("rotateend",t)),o&&this.fire(new e.b("pitchend",t)),this.fire(new e.b("moveend",t))}flyTo(t,i){if(this._prefersReducedMotion(t)){const r=e.af(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,i)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.d8},t);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.ad(+t.zoom,r.minZoom,r.maxZoom):n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,h="pitch"in t?+t.pitch:s,u=this._extendPadding(t.padding),d=r.zoomScale(l-n),p=e.P.convert(t.offset);let f=r.centerPoint.add(p);const m=r.pointLocation(f),_=e.bq.convert(t.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let x=t.curve;const v=Math.max(r.width,r.height),b=v/d,w=y.mag();if("minZoom"in t){const i=e.ad(Math.min(t.minZoom,n,l),r.minZoom,r.maxZoom),o=v/r.zoomScale(i-n);x=Math.sqrt(o/w*2)}const T=x*x;function E(e){const t=(b*b-v*v+(e?-1:1)*T*T*w*w)/(2*(e?b:v)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function M(e){return(Math.exp(e)+Math.exp(-e))/2}const A=E(0);let I=function(e){return M(A)/M(A+x*e)},C=function(e){return v*((M(A)*(S(t=A+x*e)/M(t))-S(A))/T)/w;var t},P=(E(1)-A)/x;if(Math.abs(w)<1e-6||!isFinite(P)){if(Math.abs(v-b)<1e-6)return this.easeTo(t,i);const e=bt.maxDuration&&(t.duration=0);const z=o!==c,D=h!==s,R=!r.isPaddingEqual(u),L=r=>d=>{const m=d*P,x=1/I(m);r.zoom=1===d?l:n+r.scaleZoom(x),z&&(r.bearing=e.X(o,c,d)),D&&(r.pitch=e.X(s,h,d)),R&&(r.interpolatePadding(a,u,d),f=r.centerPoint.add(p));const v=1===d?_:r.unproject(g.add(y.mult(C(m))).mult(x));return r.setLocationAtPoint(r.renderWorldCopies?v.wrap():v,f),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(L,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=z,this._pitching=D,this._padding=R,this._prepareEase(i,!1),this._ease(L(r),(()=>this._afterEase(i)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,i,r){!1===r.animate||0===r.duration?(t(1),i()):(this._easeStart=e.f.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.f.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,i){t=e.bk(t,-180,180);const r=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.f.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone())}return n}_preloadTiles(e,t){}}class ta{constructor(t={}){this.options=t,e.a$(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o("div","mapboxgl-ctrl-attrib-inner",this._container),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.dd.ACCESS_TOKEN}];if(t){const r=i.reduce(((e,t,r)=>(t.value&&(e+=`${t.key}=${t.value}${re.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class ia{constructor(){e.a$(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class ra{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function na(t,i,r){if(t=new e.bq(t.lng,t.lat),i){const n=new e.bq(t.lng-360,t.lat),o=new e.bq(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),a=r.locationPoint(t).distSqr(i),l=i.x<0||i.y<0||i.x>r.width||i.y>r.height;r.locationPoint(n).distSqr(i)180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const oa={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class sa extends e.E{constructor(t,i){if(super(),(t instanceof HTMLElement||i)&&(t=e.e({element:t},i)),e.a$(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const i=41,r=27,n=s("svg",{display:"block",height:i*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${i}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},n));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),s("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},n),s("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},n),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),this._offset=e.P.convert(t&&t.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const r=this._element.classList;for(const e in oa)r.remove(`mapboxgl-marker-anchor-${e}`);r.add(`mapboxgl-marker-anchor-${this._anchor}`);const n=t&&t.className?t.className.trim().split(/\s+/):[];r.add(...n),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.bq.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=13.5,i=Math.sqrt(Math.pow(t,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[i,-34.14594154601839],"bottom-right":[-9.545941546018392,-34.14594154601839],left:[t,-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}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const i=e.unproject(t),r=e.getFreeCameraOptions();if(!r.position)return!1;const n=r.position.toLngLat();return n.distanceTo(i)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const r=t.unproject(i);let n;t._showingGlobe()&&e.de(t.transform,this._lngLat)?n=0:(n=1-t._queryFogOpacity(r),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(n*=this._occludedOpacity)),this._element.style.opacity=`${n}`,this._element.style.pointerEvents=n>0?"auto":"none",this._popup&&this._popup._setOpacity(n),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${oa[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,i=this._map,r=this.getPitchAlignment();if(!i||!t||"map"!==r)return"";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const n=e.bI(e.df(i.transform,this._lngLat)),o=t.sub(e.dg(i.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=n/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return"";let r=0;const n=this.getRotationAlignment();if("map"===n)if(i._showingGlobe()){const t=i.project(new e.bq(this._lngLat.lng,this._lngLat.lat+.001)),n=i.project(new e.bq(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);r=e.bI(Math.atan2(n.y,n.x))-90}else r=-i.getBearing();else if("horizon"===n){const n=e.S(4,6,i.getZoom()),o=e.dg(i.transform);o.y+=n*i.transform.height;const s=t.sub(o),a=e.bI(Math.atan2(s.y,s.x));r=(a>90?a-270:a+90)*(1-n)}return r+=this._rotation,r?`rotateZ(${r}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=na(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),t._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const i=this._map;if(!i)return;const r=this._pointerdownPos,n=this._positionDelta;if(r&&n){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(r)=this._endTime)return this._end;const i=e.ch((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i}}class ua{registerParameter(e,t,i,r,n){}registerButton(e,t,i){}registerBinding(e,t,i,r){}refreshUI(){}}const da={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},pa={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},fa={showCompass:!0,showZoom:!0,visualizePitch:!1};class ma{constructor(t,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Ms({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new As({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.a$(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),p()}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){f(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),g(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,g(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=y(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=y(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.dh(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new _r(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new ra,this._domRenderTaskQueue=new ra,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.aF(),this._locale=e.e({},da,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ha(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.di(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?u({},t.contextCreateOptions):{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.a$(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp=t.devtools?new ua(this):new ua,this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},(()=>{this._update()})),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Js(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.dd.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new rs("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==i.center&&null==i.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const r=t.bounds;r&&(this.resize(),this.fitBounds(r,e.e({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new ta({customAttribution:t.customAttribution})),this._logoControl=new ia,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent()})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.b(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.b(`${t.dataType}dataloading`,t))}))}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.a(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.a(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new e.b("movestart",t)).fire(new e.b("move",t)),this.fire(new e.b("resize",t)),i&&this.fire(new e.b("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.ag.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.b("zoomstart")).fire(new e.b("zoom")).fire(new e.b("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.b("pitchstart")).fire(new e.b("pitch")).fire(new e.b("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return"auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?navigator.language:e)):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,i=t.projection.name;let r;"globe"===i&&t.zoom>=e.bA?(t.setMercatorFromTransition(),r=!0):"mercator"===i&&t.zoom=e.bA?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),i&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t){return this.transform.locationPoint3D(e.bq.convert(t))}unproject(t){return this.transform.pointLocation3D(e.P.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),s=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new ps(e,this,n.originalEvent,{features:s}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new ps(e,this,n.originalEvent)))},o=t=>{r&&(r=!1,i.call(this,new ps(e,this,t.originalEvent)))};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),n=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features)};return{layers:new Set(t),listener:i,delegates:{[e]:r}}}}on(e,t,i){if(void 0===i)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);for(const e of t)if(!this._isValidId(e))return this;const r=(e,t)=>{if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0},n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n{r?(e.w(`Unable to perform style diff: ${String(r.message||r.error||r)}. Rebuilding the style from scratch.`),this._updateStyle(t,i)):n&&this._update(!0)}),(()=>{this._postStyleLoadEvent()})),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(t,i){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){const r=e.e({},i);i&&i.config&&(r.initialConfig=i.config,delete r.config),this.style=new Dr(this,r).setEventedParent(this,{style:this.style}).load(t)}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Dr(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.a(new Error("IDs can't be empty."))),!1):!e.c9(t)||(this.fire(new e.a(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:l,height:c,data:h}=e.f.getImageData(i);this.style.addImage(t,{data:new e.h({width:l,height:c},h),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0})}else if(void 0===i.width||void 0===i.height)this.fire(new e.a(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:c}=i,h=i;this.style.addImage(t,{data:new e.h({width:l,height:c},new Uint8Array(h.data)),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t)}}updateImage(t,i){this._lazyInitEmptyStyle();const r=this.style.getImage(t);if(!r)return void this.fire(new e.a(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.f.getImageData(i):i,{width:o,height:s}=n,a=n.data;if(void 0===o||void 0===s)return void this.fire(new e.a(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==r.data.width||s!==r.data.height)return void this.fire(new e.a(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const l=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);r.data.replace(a,l),this.style.updateImage(t,r)}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.a(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,i){e.d(this._requestManager.transformRequest(t,e.R.Image),((t,r)=>{i(t,r instanceof HTMLImageElement?e.f.getImageData(r):r)}))}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.a(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(e,t){return this.style.addImport(e,t),this}updateImport(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.bq.convert(t),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,r,n,o=this._container;for(;o&&(!r||!n);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(r=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(n=i[3])),o=o.parentElement}this._containerWidth=r?Math.abs(e/r):e,this._containerHeight=n?Math.abs(t/n):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._canvas=o("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=o("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{r[e]=o("div",`mapboxgl-ctrl-${e}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const r=e.f.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.e({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl2",t);r?(e.dj(r,!0),this.painter=new ts(r,this._contextCreateOptions,this.transform,this._tp),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.dk.testSupport(r)):this.fire(new e.a(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.b("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.b("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let i;this.fire(new e.b("renderstart"));const r=this.painter.context.extTimerQuery,n=e.f.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(i=o.createQuery(),o.beginQuery(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,r=e.f.now(),n=new e.N(t,{now:r,fadeDuration:s,pitch:i,transition:this.style.transition});this.style.update(n)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(n),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(n),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.b("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.b("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=e.f.now()-n;o.endQuery(r.TIME_ELAPSED_EXT),setTimeout((()=>{const r=o.getQueryParameter(i,o.QUERY_RESULT)/1e6;o.deleteQuery(i),this.fire(new e.b("gpu-timing-frame",{cpuTime:t,gpuTime:r}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.b("gpu-timing-layer",{layerTimes:i}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.b("gpu-timing-deferred-render",{gpuTime:i}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(n,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.b("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.b("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._performanceMetricsCollection&&e.dl(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation();this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){e.dm(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.dn||401===t.status)){const t=this.painter.context.gl;e.dj(t,!1),this._logoControl instanceof ia&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.a(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),e.dp(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_postStyleLoadEvent(){this.style.globalId&&e.dq(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.b4(i,((e,i)=>e._preloadTiles(t,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(t,i){e.dv(t,i)}get version(){return e.du}},NavigationControl:class{constructor(t){this.options=e.e({},fa,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.a$(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.a$(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ma(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const i=o("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends e.E{constructor(t){super();const i=navigator.geolocation;this.options=e.e({geolocation:i},_a,t),e.a$(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=is(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then((e=>t("denied"!==e.state))).catch((()=>t())):t()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return!!t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.b("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("geolocate",t)),this._finish()}}_updateCamera(t){const i=new e.bq(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,n=this._map.getBearing(),o=e.e({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.bq(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,i=e.bo(1,t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new sa({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new sa({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.b("trackuserlocationend")))}))}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.b("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.b("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.b("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:ta,ScaleControl:class{constructor(t){this.options=e.e({},ga,t),this._isNumberFormatSupported=(function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}})(),e.a$(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,r=t._containerWidth/2-e/2,n=t.unproject([r,i]),o=t.unproject([r+e,i]),s=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter")}_setScale(e,t,i){this._map._requestDomTask((()=>{const r=(function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:(function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t})(i),t*i})(t),n=r/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(r):`${r} ${ya[i]}`,this._container.style.width=e*n+"px"}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.a$(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.E{constructor(t){super(),this.options=e.e(Object.create(aa),t),e.a$(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.b("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.b("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.bq.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,r=this._pos;if(!t||!i||!r)return"bottom";const n=i.offsetWidth,o=i.offsetHeight,s=r.xt.transform.width-n/2;if(r.y+et.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const i=this._map,r=this._content;if(!i||!this._lngLat&&!this._trackPointer||!r)return;let n=this._container;if(n||(n=this._container=o("div","mapboxgl-popup",i.getContainer()),this._tip=o("div","mapboxgl-popup-tip",n),n.appendChild(r)),this.options.maxWidth&&n.style.maxWidth!==this.options.maxWidth&&(n.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=na(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:i.project(this._lngLat),r=ca(this.options.offset),n=this._anchor=this._getAnchor(r.y),o=ca(this.options.offset,n),s=e.add(o).round();i._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${oa[n]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&i._showingGlobe()){const t=e.de(i.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(la);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:sa,Style:Dr,LngLat:e.bq,LngLatBounds:e.ag,Point:e.P,MercatorCoordinate:e.O,FreeCameraOptions:dr,Evented:e.E,config:e.dd,prewarm:e.dy,clearPrewarmedResources:e.dz,get accessToken(){return e.dd.ACCESS_TOKEN},set accessToken(t){e.dd.ACCESS_TOKEN=t},get baseApiUrl(){return e.dd.API_URL},set baseApiUrl(t){e.dd.API_URL=t},get workerCount(){return e.dA.workerCount},set workerCount(t){e.dA.workerCount=t},get maxParallelImageRequests(){return e.dd.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.dd.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.dB(t)},get workerUrl(){return e.dC.workerUrl},set workerUrl(t){e.dC.workerUrl=t},get workerClass(){return e.dC.workerClass},set workerClass(t){e.dC.workerClass=t},get workerParams(){return e.dC.workerParams},set workerParams(t){e.dC.workerParams=t},get dracoUrl(){return e.dD()},set dracoUrl(t){e.dE(t)},get meshoptUrl(){return e.dF()},set meshoptUrl(t){e.dG(t)},setNow:e.f.setNow,restoreNow:e.f.restoreNow};return xa})),i}))}),84,[6,85]); -__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;o=0||{}.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n},m.exports.__esModule=!0,m.exports.default=m.exports}),85,[28]); +class ty{constructor(e=0,t=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=i,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){return e.map((e=>[e,this.get(e)]))}evict(e=!1){if(e||this.size>0){const e=this.first;delete this.items[e.key],0==--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const i=this.items[e];this.ttl>0&&i.expiry<=Date.now()?this.delete(e):(t=i.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t,i=!1,r=this.resetTtl){let n;if(i||this.has(e)){if(n=this.items[e],n.value=t,!1===i&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){const e=this.last,t=n.next,i=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,e.next=n,null!==i&&(i.next=t),null!==t&&(t.prev=i)}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1==++this.size?this.first=n:this.last.next=n;return this.last=n,this}values(e=this.keys()){return e.map((e=>this.get(e)))}}function iy(e,t){if(4!==t.length)throw new Error(`Expected data of dimension 4 but got ${t.length}.`);let i=t[3];for(let r=2;r>=1;r--){const n=1===r?1:0,o=2===r?1:0;for(let r=0;r>>1^-(1&e[t]);return e}function ny(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t>4|(61440&i)>>8|(240&r)<<4|61440&r,e[t+1]=15&i|(3840&i)>>4|(15&r)<<8|(3840&r)<<4}return e;case"uint8":for(let t=0;t>6|(192&r)>>4|(192&n)>>2|192&o,e[t+1]=(48&i)>>4|(48&r)>>2|48&n|(48&o)<<2,e[t+2]=(12&i)>>2|12&r|(12&n)<<2|(12&o)<<4,e[t+3]=3&i|(3&r)<<2|(3&n)<<4|(3&o)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}class oy extends Error{constructor(e){super(e),this.name="MRTError"}}var sy=Uint8Array,ay=Uint16Array,ly=Int32Array,cy=new sy([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]),uy=new sy([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]),hy=new sy([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dy=function(e,t){for(var i=new ay(31),r=0;r<31;++r)i[r]=t+=1<>1|(21845&yy)<<1;gy[yy]=((65280&(xy=(61680&(xy=(52428&xy)>>2|(13107&xy)<<2))>>4|(3855&xy)<<4))>>8|(255&xy)<<8)>>1}var vy=function(e,t,i){for(var r=e.length,n=0,o=new ay(t);n>l]=c}else for(s=new ay(r),n=0;n>15-e[n]);return s},by=new sy(288);for(yy=0;yy<144;++yy)by[yy]=8;for(yy=144;yy<256;++yy)by[yy]=9;for(yy=256;yy<280;++yy)by[yy]=7;for(yy=280;yy<288;++yy)by[yy]=8;var wy=new sy(32);for(yy=0;yy<32;++yy)wy[yy]=5;var Ty=vy(by,9,1),Ey=vy(wy,5,1),Sy=function(e){for(var t=e[0],i=1;it&&(t=e[i]);return t},My=function(e,t,i){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&i},Iy=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Ay=["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"],Cy=function(e,t,i){var r=new Error(t||Ay[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Cy),!i)throw r;return r},Py=new sy(0),zy="undefined"!=typeof TextDecoder&&new TextDecoder;try{zy.decode(Py,{stream:!0})}catch(e){}const Dy={gzip_data:"gzip"},Ly={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Ry={uint32:1,uint16:2,uint8:4},ky={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Oy{constructor(e=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){return this.layers[e]}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new oy("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),i=this.getHeaderLength(e);if(t.length= ${i} but got buffer of length ${t.length}`);const r=new Cm(t.subarray(0,i)),n=Qg.read(r);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new oy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new By(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],i=this.getLayer(e.layerName);for(let r=0;re.lastBlock)continue;if(i._blocksInProgress.has(r))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:r,blockShape:[n.bands.length].concat(i.bandShape),buffer:i.buffer,codec:n.codec.codec,filters:n.filters.map((e=>e.filter))};i._blocksInProgress.add(r),t.push(a)}return new Fy(t,(()=>{t.forEach((e=>i._blocksInProgress.delete(e.blockIndex)))}),((e,r)=>{if(t.forEach((e=>i._blocksInProgress.delete(e.blockIndex))),e)throw e;r.forEach((e=>{this.getLayer(e.layerName).processDecodedData(e)}))}))}}class By{constructor({version:e,name:t,units:i,tilesize:r,pixel_format:n,buffer:o,data_index:s},a){if(this.version=e,1!==this.version)throw new oy(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=r,this.buffer=o,this.pixelFormat=Ly[n],this.dataIndex=s,this.bandShape=[r+2*o,r+2*o,Ry[this.pixelFormat]],this._decodedBlocks=(function(e=1e3,t=0,i=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof i)throw new TypeError("Invalid resetTtl value");return new ty(e,t,i)})(a?a.cacheSize:5),this._blocksInProgress=new Set}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.set(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[i,r]of this.dataIndex.entries()){for(const[n,o]of r.bands.entries())if(o===e)return{bandIndex:t+n,blockIndex:i,blockBandIndex:n};t+=r.bands.length}break;case"number":for(const[i,r]of this.dataIndex.entries()){if(e>=t&&e=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:i}=this.getBlockForBand(e),r=this._decodedBlocks.get(t.toString());if(!r)throw new oy(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const n=this.dataIndex[t],o=this.bandShape.reduce(((e,t)=>e*t),1),s=i*o,a=r.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:n.offset,scale:n.scale}}}class Fy{constructor(e,t,i){this.tasks=e,this._onCancel=t,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}Oy.performDecoding=function(e,t){return Promise.all(t.tasks.map((t=>{const{layerName:i,firstByte:r,lastByte:n,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,u=new Uint8Array(e).subarray(r,n+1),h=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return d=(function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=(function(e){31==e[0]&&139==e[1]&&8==e[2]||Cy(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[i++]);return i+(2&t)})(n=e))+8>n.length&&Cy(6,"invalid gzip data"),(function(e,t,i,r){var n=e.length;if(!n||t.f&&!t.l)return i||new sy(0);var o=!i,s=o||2!=t.i,a=t.i;o&&(i=new sy(3*n));var l,c,u=function(e){var t=i.length;if(e>t){var r=new sy(Math.max(2*t,e));r.set(i),i=r}},h=t.f||0,d=t.p||0,p=t.b||0,f=t.l,m=t.d,_=t.m,g=t.n,y=8*n;do{if(!f){h=My(e,d,1);var x=My(e,d+1,3);if(d+=3,!x){var v=e[(z=4+((d+7)/8|0))-4]|e[z-3]<<8,b=z+v;if(b>n){a&&Cy(0);break}s&&u(p+v),i.set(e.subarray(z,b),p),t.b=p+=v,t.p=d=8*b,t.f=h;continue}if(1==x)f=Ty,m=Ey,_=9,g=5;else if(2==x){var w=My(e,d,31)+257,T=My(e,d+10,15)+4,E=w+My(e,d+5,31)+1;d+=14;for(var S=new sy(E),M=new sy(19),I=0;I>4)<16)S[I++]=z;else{var L=0,R=0;for(16==z?(R=3+My(e,d,3),d+=2,L=S[I-1]):17==z?(R=3+My(e,d,7),d+=3):18==z&&(R=11+My(e,d,127),d+=7);R--;)S[I++]=L}}var k=S.subarray(0,w),O=S.subarray(w);_=Sy(k),g=Sy(O),f=vy(k,_,1),m=vy(O,g,1)}else Cy(1);if(d>y){a&&Cy(0);break}}s&&u(p+131072);for(var B=(1<<_)-1,F=(1<>4;if((d+=15&L)>y){a&&Cy(0);break}if(L||Cy(2),V<256)i[p++]=V;else{if(256==V){N=d,f=null;break}var U=V-254;V>264&&(U=My(e,d,(1<<(q=cy[I=V-257]))-1)+fy[I],d+=q);var j=m[Iy(e,d)&F],G=j>>4;if(j||Cy(3),d+=15&j,O=_y[G],G>3){var q=uy[G];O+=Iy(e,d)&(1<y){a&&Cy(0);break}s&&u(p+131072);var Z=p+U;if(pl.length)&&(c=l.length),new sy(l.subarray(0,c))):i.subarray(0,p)})(n.subarray(o,-8),{i:2},new sy(((i=n)[(r=i.length)-4]|i[r-3]<<8|i[r-2]<<16|i[r-1]<<24)>>>0))));var i,r,n,o;const s=Dy[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then((e=>new Uint8Array(e)))})(u,c).then((e=>{const t=ey.read(new Cm(e));if("uint32_values"===t.values)return t.uint32_values.readValuesInto(h),new(0,ky[o])(h.buffer);throw new Error(`Unhandled numeric data "${t.values}"`)})),d.then((e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":iy(e,s);break;case"zigzag_filter":ry(e);break;case"bitshuffle_filter":ny(e,o);break;default:throw new Error(`Unhandled filter "${l[t]}"`)}return{layerName:i,blockIndex:a,data:e}})).catch((e=>{throw e}))})))};class Ny extends Jg{constructor(e,t,i,r,n){super(e,t,i,r,n),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(e,t){const i=t.context,r=i.gl;this.texture=this.texture||t.getTileTexture(e.width),this.texture&&this.texture instanceof Vg?this.texture.update(e,{useMipmap:!1,premultiply:!1}):this.texture=new Vg(i,e,r.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(e=16384,t){const i=this._mrt=new Oy(30),r=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(e-1)}});return this.entireBuffer=null,this.request=tr(r,((r,n,o,s)=>{if(r)t(r);else try{const r=i.getHeaderLength(n);if(r>e)return void(this.request=this.fetchHeader(r,t));i.parseHeader(n),this._isHeaderLoaded=!0;let a=0;for(const e of Object.values(i.layers))a=Math.max(a,e.dataIndex[e.dataIndex.length-1].last_byte);n.byteLength>=a&&(this.entireBuffer=n),t(null,this.entireBuffer||n,o,s)}catch(e){t(e)}})),this.request}fetchBand(e,t,i){const r=this._mrt;if(!this._isHeaderLoaded||!r)return void i(new Error("Tile header is not ready"));const n=this.actor;if(!n)return void i(new Error("Can't fetch tile band without an actor"));let o;const s=(r,n)=>{o.complete(r,n),r?i(r):(this.updateTextureDescriptor(e,t),i(null,this.textureDescriptor&&this.textureDescriptor.img))},a=(e,t)=>{if(e)return i(e);const r=n.send("decodeRasterArray",{buffer:t,task:o},s,void 0,!0);this._workQueue.push((()=>{r&&r.cancel(),o.cancel()}))},l=r.getLayer(e);if(!l)return void i(new Error(`Unknown sourceLayer "${e}"`));if(l.hasDataForBand(t))return this.updateTextureDescriptor(e,t),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const c=l.getDataRange([t]);if(o=r.createDecodingTask(c),!o||o.tasks.length)if(this.flushQueues(),this.entireBuffer)a(null,this.entireBuffer.slice(c.firstByte,c.lastByte+1));else{const e=Object.assign({},this.requestParams,{headers:{Range:`bytes=${c.firstByte}-${c.lastByte}`}}),t=tr(e,a);this._fetchQueue.push((()=>{t.cancel(),o.cancel()}))}else i(null)}updateNeeded(e,t){return(!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}updateTextureDescriptor(e,t){if(!this._mrt)return;const i=this._mrt.getLayer(e);if(!i||!i.hasBand(t)||!i.hasDataForBand(t))return;const{bytes:r,tileSize:n,buffer:o,offset:s,scale:a}=i.getBandView(t),l=n+2*o,c={data:r,width:l,height:l},u=this.texture;u&&u instanceof Vg&&u.update(c,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:e,band:t,img:c,buffer:o,offset:s,tileSize:n,format:i.pixelFormat,mix:[a,256*a,65536*a,16777216*a]}}}class Vy{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class Uy extends kr{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),t.on("error",(()=>{this._sourceErrored=!0})),this._source=t,this._tiles={},this._cache=new Vy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Dm,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e)}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e)}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return ei(this._tiles).map((e=>e.tileID)).sort(jy).map((e=>e.key))}getRenderableIds(e,t){const i=[];for(const r in this._tiles)this._isIdRenderable(+r,e,t)&&i.push(this._tiles[r]);return e?i.sort(((e,t)=>{const i=e.tileID,r=t.tileID,n=new Ut(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new Ut(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||o.y-n.y||o.x-n.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(jy).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)))}_tileLoaded(e,t,i,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new Rr(r,{tile:e}));else{if(!(e.tileID.key in this._loadedParentTiles))return void this._source.fire(new Lr("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform)}else e.timeAdded=Li.now(),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Lr("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(e,t,i,r){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let n;if(this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new yu(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)));else if(0!==this.tileCoverLift){const r=e.clone();r.tileCoverLift=this.tileCoverLift,n=r.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoom<=1&&"globe"===e.projection.name&&(n.push(new yu(1,0,1,0,0)),n.push(new yu(1,0,1,1,0)),n.push(new yu(1,0,1,0,1)),n.push(new yu(1,0,1,1,1)))}else if(n=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);n=n.filter((t=>e(t)))}}else n=[];if(n.length>0&&this.castsShadows&&r&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Gy(this._source.type)){const o=e.coveringZoomLevel({tileSize:t||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=e.extendTileCoverForShadows(n,r,s);for(const e of a)this._shadowCasterTiles[e.key]=!0,n.push(e)}const o=this._updateRetainedTiles(n);if(Gy(this._source.type)&&0!==n.length){const e={},t={},i=Object.keys(o);for(const r of i){const i=o[r],n=this._tiles[r];if(!n||n.fadeEndTime&&n.fadeEndTime<=Li.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-Uy.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),e[s.tileID.key]=s.tileID),t[r]=i}const r=n[n.length-1].overscaledZ;for(const e in this._tiles){const i=this._tiles[e];if(o[e]||!i.hasData())continue;let n=i.tileID;for(;n.overscaledZ>r;){n=n.scaledTo(n.overscaledZ-1);const r=this._tiles[n.key];if(r&&r.hasData()&&t[n.key]){o[e]=i.tileID;break}}}for(const t in e)o[t]||(this._coveredTiles[t]=!0,o[t]=e[t])}for(const e in o)this._tiles[e].clearFadeHold();const s=(function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i})(this._tiles,o);for(const e of s){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},r=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-Uy.maxOverzooming,this._source.minzoom),s=Math.max(n+Uy.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(e){let t=this._tiles[e.key];if(t)return!0!==t.isExtraShadowCaster||!!this._shadowCasterTiles[e.key]||this._reloadTile(e.key,"reloading"),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const i=Boolean(t);if(!i){const i=this.map?this.map.painter:null,r=this._source.tileSize*e.overscaleFactor();t="raster-array"===this._source.type?new Ny(e,r,this.transform.tileZoom,i,this._isRaster):new Jg(e,r,this.transform.tileZoom,i,this._isRaster),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,i||this._source.fire(new Lr("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),i))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,t,i){const r=[],n=this.transform;if(!n)return r;const o="globe"===n.projection.name,s=Eu(n.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(Yt(s,...qy(e,-1))-s),Math.abs(Yt(s,...qy(e,1))-s)];c=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(Yt(s,...qy(e,-1))-s),Math.abs(Yt(s,...qy(e,0))-s),Math.abs(Yt(s,...qy(e,1))-s)];c=[t.indexOf(Math.min(...t))-1]}}else c=[0];for(const i of c){const o=e.containsTile(l,n,t,i);o&&r.push(o)}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map((e=>this._tiles[e].tileID)),r="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=r?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,r=this.transform._camera.forward(),n={};for(const e of t){const t=1/(1<n[e.key]-n[t.key])),t}hasTransition(){if(this._source.hasTransition())return!0;if(Gy(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=Li.now())return!0}return!1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i)}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)))}_preloadTiles(e,t){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(e,t))};return void this._source.on("data",i)}const i=new Map,r=Array.isArray(e)?e:[e],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}Qt(Array.from(i.values()),((e,t)=>{const i=new Jg(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)}))}),t)}}function jy(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Gy(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function qy(e,t){const i=1<0?t+2*e:e}Zy.useIntegerZoom=!0;const Wy=new nl({"symbol-placement":new tl(ol.layout_symbol["symbol-placement"]),"symbol-spacing":new tl(ol.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new tl(ol.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new il(ol.layout_symbol["symbol-sort-key"]),"symbol-z-order":new tl(ol.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new tl(ol.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new tl(ol.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new tl(ol.layout_symbol["icon-ignore-placement"]),"icon-optional":new tl(ol.layout_symbol["icon-optional"]),"icon-rotation-alignment":new tl(ol.layout_symbol["icon-rotation-alignment"]),"icon-size":new il(ol.layout_symbol["icon-size"]),"icon-text-fit":new il(ol.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new il(ol.layout_symbol["icon-text-fit-padding"]),"icon-image":new il(ol.layout_symbol["icon-image"]),"icon-rotate":new il(ol.layout_symbol["icon-rotate"]),"icon-padding":new tl(ol.layout_symbol["icon-padding"]),"icon-keep-upright":new tl(ol.layout_symbol["icon-keep-upright"]),"icon-offset":new il(ol.layout_symbol["icon-offset"]),"icon-anchor":new il(ol.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new tl(ol.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new tl(ol.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new tl(ol.layout_symbol["text-rotation-alignment"]),"text-field":new il(ol.layout_symbol["text-field"]),"text-font":new il(ol.layout_symbol["text-font"]),"text-size":new il(ol.layout_symbol["text-size"]),"text-max-width":new il(ol.layout_symbol["text-max-width"]),"text-line-height":new il(ol.layout_symbol["text-line-height"]),"text-letter-spacing":new il(ol.layout_symbol["text-letter-spacing"]),"text-justify":new il(ol.layout_symbol["text-justify"]),"text-radial-offset":new il(ol.layout_symbol["text-radial-offset"]),"text-variable-anchor":new tl(ol.layout_symbol["text-variable-anchor"]),"text-anchor":new il(ol.layout_symbol["text-anchor"]),"text-max-angle":new tl(ol.layout_symbol["text-max-angle"]),"text-writing-mode":new tl(ol.layout_symbol["text-writing-mode"]),"text-rotate":new il(ol.layout_symbol["text-rotate"]),"text-padding":new tl(ol.layout_symbol["text-padding"]),"text-keep-upright":new tl(ol.layout_symbol["text-keep-upright"]),"text-transform":new il(ol.layout_symbol["text-transform"]),"text-offset":new il(ol.layout_symbol["text-offset"]),"text-allow-overlap":new tl(ol.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new tl(ol.layout_symbol["text-ignore-placement"]),"text-optional":new tl(ol.layout_symbol["text-optional"]),visibility:new tl(ol.layout_symbol.visibility)});var Hy={paint:new nl({"icon-opacity":new il(ol.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new il(ol.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new il(ol.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new il(ol.paint_symbol["text-emissive-strength"]),"icon-color":new il(ol.paint_symbol["icon-color"]),"icon-halo-color":new il(ol.paint_symbol["icon-halo-color"]),"icon-halo-width":new il(ol.paint_symbol["icon-halo-width"]),"icon-halo-blur":new il(ol.paint_symbol["icon-halo-blur"]),"icon-translate":new tl(ol.paint_symbol["icon-translate"]),"icon-translate-anchor":new tl(ol.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new il(ol.paint_symbol["icon-image-cross-fade"]),"text-opacity":new il(ol.paint_symbol["text-opacity"]),"text-occlusion-opacity":new il(ol.paint_symbol["text-occlusion-opacity"]),"text-color":new il(ol.paint_symbol["text-color"],{runtimeType:Qr,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new il(ol.paint_symbol["text-halo-color"]),"text-halo-width":new il(ol.paint_symbol["text-halo-width"]),"text-halo-blur":new il(ol.paint_symbol["text-halo-blur"]),"text-translate":new tl(ol.paint_symbol["text-translate"]),"text-translate-anchor":new tl(ol.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new tl(ol.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new tl(ol.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new tl(ol.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new tl(ol.paint_symbol["icon-color-brightness-max"])}),layout:Wy};class Xy{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Xr,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}va(Xy,"FormatSectionOverride",{omit:["defaultValue"]});class Yy extends Sl{constructor(t,i,r,n){super(t,Hy,i,r,n),this._colorAdjustmentMatrix=e.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(t,i,r,n){return this._saturation===t&&this._contrast===i&&this._brightnessMin===r&&this._brightnessMax===n||(this._colorAdjustmentMatrix=(function(t,i,r,n){t=zi(t),i=Pi(i);const o=e.ad.create(),s=t/3,a=1-2*s,l=[a,s,s,0,s,a,s,0,s,s,a,0,0,0,0,1],c=.5-.5*i,u=n-r;return e.ad.multiply(o,[u,0,0,0,0,u,0,0,0,0,u,0,r,r,r,1],[i,0,0,0,0,i,0,0,0,0,i,0,c,c,c,1]),e.ad.multiply(o,o,l),o})(t,i,r,n),this._saturation=t,this._contrast=i,this._brightnessMin=r,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||la(o.value)||!n?n:(function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))})(t.properties,n)}createBucket(e){return new Ng(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Hy.paint.overridableProperties){if(!Yy.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new Xy(t),r=new aa(i,t.property.specification,this.scope,this.options);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new ua("source",r):new ha("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Qa(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&Yy.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=Hy.paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof fn)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{n||(t instanceof vn&&yn(t.value)===nn?o(t.value.sections):t instanceof En?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}getProgramIds(){const e=0!==this.paint.get("icon-opacity").constantOr(1),t=0!==this.paint.get("text-opacity").constantOr(1),i=[];return e&&i.push("symbolIcon"),t&&i.push("symbolSDF"),i}getDefaultProgramParams(e,t,i){return{config:new Wc(this,{zoom:t,lut:i}),overrideFog:!1}}}const Ky=new nl({visibility:new tl(ol.layout_background.visibility)});var Jy={paint:new nl({"background-color":new tl(ol.paint_background["background-color"]),"background-pattern":new tl(ol.paint_background["background-pattern"]),"background-opacity":new tl(ol.paint_background["background-opacity"]),"background-emissive-strength":new tl(ol.paint_background["background-emissive-strength"])}),layout:Ky};const Qy=new nl({visibility:new tl(ol.layout_raster.visibility)});var ex={paint:new nl({"raster-opacity":new tl(ol.paint_raster["raster-opacity"]),"raster-color":new rl(ol.paint_raster["raster-color"]),"raster-color-mix":new tl(ol.paint_raster["raster-color-mix"]),"raster-color-range":new tl(ol.paint_raster["raster-color-range"]),"raster-hue-rotate":new tl(ol.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new tl(ol.paint_raster["raster-brightness-min"]),"raster-brightness-max":new tl(ol.paint_raster["raster-brightness-max"]),"raster-saturation":new tl(ol.paint_raster["raster-saturation"]),"raster-contrast":new tl(ol.paint_raster["raster-contrast"]),"raster-resampling":new tl(ol.paint_raster["raster-resampling"]),"raster-fade-duration":new tl(ol.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new tl(ol.paint_raster["raster-emissive-strength"]),"raster-array-band":new tl(ol.paint_raster["raster-array-band"]),"raster-elevation":new tl(ol.paint_raster["raster-elevation"])}),layout:Qy};function tx(t,i,r,n,o,s,a,l){const c=[t,i,1,r,n,1,o,s,1],u=[a,l,1],h=e.bC.adjoint([],c),[d,p,f]=e._.transformMat3(u,u,h);return e.bC.multiply(c,c,[d,0,0,0,p,0,0,0,f])}function ix(t,i,r,n,o,s,a,l){const c=(function(t,i,r,n,o,s,a,l){const c=tx(0,0,1,0,1,1,0,1),u=tx(t,i,r,n,o,s,a,l),h=e.bC.adjoint([],c);return e.bC.multiply(u,u,h)})(t,i,r,n,o,s,a,l);return[c[2]/c[8]/co,c[5]/c[8]/co]}function rx(e){return[e[0],Math.min(Math.max(e[1],-85.051129),Pu)]}class nx extends kr{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new Lr("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=sr(this.map._requestManager.transformRequest(this.url,Ki.Image),((t,i)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new Rr(t)):i&&(this.image=i instanceof HTMLImageElement?Li.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Ug(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Lr("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Ug||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const r of e)r[1]>i&&(i=r[1]),r[1]Pu?this.onNorthPole=!0:r<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(ku.fromLngLat);this.tileID=(function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);const o=Math.max(r-t,n-i),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);let l=Math.floor((t+r)/2*a);return l>1&&(l-=1),new _u(s,l,Math.floor((i+n)/2*a))})(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Lr("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=J_(new _u(0,0,0),this.map.transform.projection),r=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!(function(e){const t=e[1].x-e[0].x,i=e[1].y-e[0].y,r=e[2].x-e[1].x,n=e[2].y-e[1].y,o=e[3].x-e[2].x,s=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*n-r*i,u=r*s-o*n,h=o*l-a*s,d=a*i-t*l;return c>0&&u>0&&h>0&&d>0||c<0&&u<0&&h<0&&d<0})(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const n=J_(this.tileID,this.map.transform.projection),[o,s,a,l]=this.coordinates.map((e=>{const t=n.projection.project(e[0],e[1]);return Q_(n,t)._round()}));this.perspectiveTransform=ix(o.x,o.y,s.x,s.y,a.x,a.y,l.x,l.y);const c=this._boundsArray=new Ll;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(s.x,s.y,co,0),c.emplaceBack(l.x,l.y,0,co),c.emplaceBack(a.x,a.y,co,co),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(c,Xg.members),this.boundsSegments=bc.simpleSegment(0,0,4,2);const u=[],h=(function(e){return[rx(e[0]),rx(e[1]),rx(e[2]),rx(e[3])]})(this.coordinates),[d,p,f,m]=(function(e){let t=e[0][0],i=t,r=e[0][1],n=r;for(let o=1;oi&&(i=e[o][0]),e[o][1]n&&(n=e[o][1]);return[t,r,i-t,n-r]})(h);{const n=new Ll,[o,s,a,l]=(function(e){let t=e[0].x,i=t,r=e[0].y,n=r;for(let o=1;oi&&(i=e[o].x),e[o].yn&&(n=e[o].y);return[t,r,i-t,n-r]})(r),c=e=>[(e.x-o)/a,(e.y-s)/l],[h,_,g,y]=r.map(c),x=(function(t,i,r,n,o,s,a,l){const c=tx(0,0,1,0,1,1,0,1),u=tx(t,i,r,n,o,s,a,l),h=e.bC.adjoint([],u);return e.bC.multiply(c,c,h)})(h[0],h[1],_[0],_[1],g[0],g[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=ix(h[0],h[1],_[0],_[1],g[0],g[1],y[0],y[1]);const v=(t,i)=>{u.push(t.lng);const r=Math.round((t.lng-d)/f*co),o=Math.round((t.lat-p)/m*co),s=c(i),a=e._.transformMat3([],[s[0],s[1],1],x),l=Math.round(a[0]/a[2]*co),h=Math.round(a[1]/a[2]*co);n.emplaceBack(r,o,l,h)},b=r[3].x-r[0].x,w=r[3].y-r[0].y,T=r[2].x-r[1].x,E=r[2].y-r[1].y;for(let e=0;e<65;e++){const t=e/64,n=[r[0].x+t*b,r[0].y+t*w],o=[r[1].x+t*T,r[1].y+t*E],s=o[0]-n[0],a=o[1]-n[1];for(let e=0;e<65;e++){const t=e/64,r={x:n[0]+s*t,y:n[1]+a*t,z:0};v(i.projection.unproject(r.x,r.y),r)}}this.elevatedGlobeVertexBuffer=t.createVertexBuffer(n,Xg.members)}{this.maxLongitudeTriangleSize=0;let e=[],i=new Yl;const r=(t,r,n)=>{i.emplaceBack(t,r,n);const o=u[t],s=u[r],a=u[n],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),e.push(l+c/2)};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const i=65*e+t,n=i+1,o=i+65,s=o+1;r(i,o,n),r(n,o,s)}[e,i]=(function(e,t){const i=Array.from({length:e.length},((e,t)=>t));i.sort(((t,i)=>e[t]-e[i]));const r=[],n=new Yl;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-r)<=a){const e=Ci(i,0,i.length,r+a);return e===i.length||s(e,Ai(i,e+1,i.length,r+360-a)-e),o}r0){const r=(function(t,i){const r=i.worldSize,n=Mu(1,0)*r*Du(i.center.lat,i.zoom)/Gh(r),o=Mu(1,i.center.lat)*r,s=e.ad.identity([]);return e.ad.rotateY(s,s,qt(i.center.lng)),e.ad.rotateX(s,s,qt(i.center.lat)),e.ad.translate(s,s,[0,0,eu]),e.ad.scale(s,s,[n,n,n*o]),e.ad.translate(s,s,[i.point.x-.5*r,i.point.y-.5*r,0]),e.ad.multiply(s,s,t),e.ad.multiply(s,i.globeMatrix,s)})(t,i);return(function(t,i,r){const n=(t,i,r)=>{const n=e._.length(t),o=e._.length(i),s=Dh(t,i,r);return e._.scale(s,s,1/e._.length(s)*Gr(n,o,r))},o=n([t[0],t[1],t[2]],[i[0],i[1],i[2]],r),s=n([t[4],t[5],t[6]],[i[4],i[5],i[6]],r),a=n([t[8],t[9],t[10]],[i[8],i[9],i[10]],r),l=Dh([t[12],t[13],t[14]],[i[12],i[13],i[14]],r);return[o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],0,l[0],l[1],l[2],1]})(o,r,n)}return o}function Ex(e,t,i,r){const n=bh.projectAabbCorners(r,i);let o=Number.MAX_VALUE,s=-1;for(let e=0;enew Ut(n[e][0],n[e][1]);let l;switch(s){case 0:case 6:l=[a(1),a(5),a(4),a(7),a(3),a(2),a(1)];break;case 1:case 7:l=[a(0),a(4),a(5),a(6),a(2),a(3),a(0)];break;case 3:case 5:l=[a(1),a(0),a(4),a(7),a(6),a(2),a(1)];break;default:l=[a(1),a(5),a(6),a(7),a(3),a(0),a(1)]}if(Hu(e,l))return o}const Sx=Cl([{name:"a_pos_3f",components:3,type:"Float32"}]),Mx=Cl([{name:"a_color_3f",components:3,type:"Float32"}]),Ix=Cl([{name:"a_color_4f",components:4,type:"Float32"}]),Ax=Cl([{name:"a_uv_2f",components:2,type:"Float32"}]),Cx=Cl([{name:"a_normal_3f",components:3,type:"Float32"}]),Px=Cl([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),zx=Cl([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Dx{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function Lx(e,t){const i=-1===e.indexOf("://");try{return new URL(e,i&&t?"http://example.com":void 0),!0}catch(e){return!1}}class Rx{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class kx{constructor(){this.instancedDataArray=new nc,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Ox{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0}updateFootprints(e,t){}populate(e,t,i,r){this.tileToMeter=Ru(i);const n=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=qu(o,n);if(!this.layers[0]._featureFilter.filter(new $a(this.zoom),c,i))continue;const u={id:e,sourceLayerIndex:l,index:a,geometry:n?c.geometry:Gu(o,i,r),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(u,u.geometry,c);h&&t.featureIndex.insert(o,u.geometry,a,l,this.index,this.instancesPerModel[h].instancedDataArray.length,256)}this.lookup=null}update(e,t,i,r){for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t in e)i.idToFeaturesIndex.hasOwnProperty(t)&&(this.evaluate(i.features[i.idToFeaturesIndex[t]],e[t],i,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const i in this.instancesPerModel){const r=this.instancesPerModel[i];for(const i of r.features){const n=this.layers[0],o=i.feature,s=this.canonical,a=n.paint.get("model-rotation").evaluate(o,{},s),l=n.paint.get("model-scale").evaluate(o,{},s),c=n.paint.get("model-translation").evaluate(o,{},s);e._.exactEquals(i.rotation,a)&&e._.exactEquals(i.scale,l)&&e._.exactEquals(i.translation,c)||(this.evaluate(i,i.featureStates,r,!0),t=!0)}}return t}updateReplacement(e,t,i){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(Pp(this.activeReplacements,r))return!1;this.activeReplacements=r;let n=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t],o=r.instancedDataArray;for(const t of r.features){const r=t.instancedDataOffset,s=t.instancedDataCount;for(let t=0;tco?a-co:a;const l=Math.floor(a),c=o.float32[s+1];let u=!1;for(const t of this.activeReplacements)if(!(t.orderl||l>t.max.x||t.min.y>c||c>t.max.y)&&(u=Op(kp(l,c,e.canonical,t.footprintTileId.canonical),t),u))break;o.float32[s]=u?a+co:a,n=n||u}}}return n}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];i.instancedDataArray.length<0||0===i.instancedDataArray.length||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,Px.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}const e=this.layers[0].modelManager;if(e&&this.modelUris)for(const t of this.modelUris)e.removeModel(t,"")}addFeature(e,t,i){const r=this.layers[0],n=r.layout.get("model-id").evaluate(i,{},this.canonical);if(!n)return pi(`modelId is not evaluated for layer ${r.id} and it is not going to get rendered.`),n;Lx(n,!1)&&(this.modelUris.includes(n)||this.modelUris.push(n)),this.instancesPerModel[n]||(this.instancesPerModel[n]=new kx);const o=this.instancesPerModel[n],s=o.instancedDataArray,a=new Rx(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=co||t.y<0||t.y>=co)continue;const e=(this.lookupDim-1)/co,i=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1}this.instanceCount++;const r=s.length;s.resize(r+1),o.instancesEvaluatedElevation.push(0),s.float32[16*r]=t.x,s.float32[16*r+1]=t.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),n}getModelUris(){return this.modelUris}evaluate(e,t,i,r){const n=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=n.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=n.paint.get("model-scale").evaluate(o,t,s),c=e.translation=n.paint.get("model-translation").evaluate(o,t,s),u=n.paint.get("model-color").evaluate(o,t,s);u.a=n.paint.get("model-color-mix-intensity").evaluate(o,t,s);const h=[];this.maxVerticalOffset10?this.tileToMeter:Ru(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=h[0],a[o+8]=h[1],a[o+9]=h[2],a[o+10]=h[4],a[o+11]=h[5],a[o+12]=h[6],a[o+13]=h[8],a[o+14]=h[9],a[o+15]=h[10],i.instancesEvaluatedElevation[n]=c[2]}}}va(Ox,"ModelBucket",{omit:["layers"]}),va(kx,"PerModelAttributes"),va(Rx,"ModelFeature");const Bx=new nl({visibility:new tl(ol.layout_model.visibility),"model-id":new il(ol.layout_model["model-id"])});var Fx={paint:new nl({"model-opacity":new tl(ol.paint_model["model-opacity"]),"model-rotation":new il(ol.paint_model["model-rotation"]),"model-scale":new il(ol.paint_model["model-scale"]),"model-translation":new il(ol.paint_model["model-translation"]),"model-color":new il(ol.paint_model["model-color"]),"model-color-mix-intensity":new il(ol.paint_model["model-color-mix-intensity"]),"model-type":new tl(ol.paint_model["model-type"]),"model-cast-shadows":new tl(ol.paint_model["model-cast-shadows"]),"model-receive-shadows":new tl(ol.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new tl(ol.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new il(ol.paint_model["model-emissive-strength"]),"model-roughness":new il(ol.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new il(ol.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new tl(ol.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new tl(ol.paint_model["model-front-cutoff"])}),layout:Bx};const Nx=64,Vx={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Ux(t,i,r,n,o,s,a,l,c,u=!1){const h=r.zoom,d=r.project(n),p=Du(n.lat,h),f=1/p;e.ad.identity(t),e.ad.translate(t,t,[d.x+a[0]*f,d.y+a[1]*f,a[2]]);let m=1,_=1;const g=r.worldSize;if(u){if("mercator"===r.projection.name){let t=0;r.elevation&&(t=r.elevation.getAtPointOrZero(new ku(d.x/g,d.y/g),0));const i=e.aA.transformMat4([],[d.x,d.y,t,1],r.projMatrix)[3]/r.cameraToCenterDistance;m=i,_=i*Du(r.center.lat,h)}else if("globe"===r.projection.name){const i=Tx(t,r),o=e.ad.multiply([],r.projMatrix,i),s=[0,0,0,1];e.aA.transformMat4(s,s,o);const a=s[3]/r.cameraToCenterDistance,l=$h(h),c=r.projection.pixelsPerMeter(n.lat,g)*Du(n.lat,h),u=r.projection.pixelsPerMeter(r.center.lat,g)*Du(r.center.lat,h);m=a/Gr(c,zu(r.center.lat),l),_=a*p/c,m*=u,_*=u}}else m=f;e.ad.scale(t,t,[m,m,_]);const y=[...t],x=i.orientation,v=[];if(bx(v,[x[0]+o[0],x[1]+o[1],x[2]+o[2]],s),e.ad.multiply(t,y,v),l&&r.elevation){let o=0;const s=[];if(c&&r.elevation){o=(function(t,i,r,n,o){const s=i.elevation;if(!s)return 0;const a=bh.projectAabbCorners(r,n),l=Mu(1,o.lat)*i.worldSize,c=(function(t,i){const r=[0,0,1],n=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of n){const n=t[o.corners[0]],s=t[o.corners[1]],a=t[o.corners[2]],l=[s[0]-n[0],s[1]-n[1],i*(s[2]-n[2])],c=e._.cross(l,l,[a[0]-n[0],a[1]-n[1],i*(a[2]-n[2])]);e._.normalize(c,c),o.dotProductWithUp=e._.dot(c,r)}return n.sort(((e,t)=>e.dotProductWithUp-t.dotProductWithUp)),n[0].corners})(a,l),u=a[c[0]],h=a[c[1]],d=a[c[2]],p=a[c[3]],f=s.getAtPointOrZero(new ku(u[0]/i.worldSize,u[1]/i.worldSize),0),m=s.getAtPointOrZero(new ku(h[0]/i.worldSize,h[1]/i.worldSize),0),_=s.getAtPointOrZero(new ku(d[0]/i.worldSize,d[1]/i.worldSize),0),g=s.getAtPointOrZero(new ku(p[0]/i.worldSize,p[1]/i.worldSize),0),y=(f+g)/2,x=(m+_)/2;return y>x?m<_?wx(t,h,p,u,m,g,f,l):wx(t,d,u,p,_,f,g,l):f=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function Gx(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Sx.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Cx.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Ax.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Mx:Ix).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,zx.members,!0)),e.segments=bc.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&jx(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&jx(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&jx(r.normalTexture,t),r.occlusionTexture&&jx(r.occlusionTexture,t,i),r.emissionTexture&&jx(r.emissionTexture,t)}function qx(e,t,i){if(e.meshes)for(const r of e.meshes)Gx(r,t,i);if(e.children)for(const r of e.children)qx(r,t,i)}function Zx(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)Zx(t)}function $x(e){if(e.meshes)for(const i of e.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((t=i.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));var t;if(e.children)for(const t of e.children)$x(t)}class Wx{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Hx{constructor(){this.tasks={},this.taskQueue=[],ai(["process"],this),this.invoker=new Wx(this.process),this.nextId=0}add(e,t){const i=this.nextId++,r=(function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i})(t);if(0===r){try{e()}finally{}return null}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||gi()){const e=this.callbacks[i],r=this.scheduler.add((()=>this.processTask(i,t)),e&&e.metadata||{type:"message"});r&&(this.cancelCallbacks[i]=r)}else this.processTask(i,t)}processTask(e,t){if(delete this.cancelCallbacks[e],""===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(Ea(t.error)):i(null,Ea(t.data)))}else{const i=new Set,r=t.hasCallback?(t,r)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Ta(t):null,data:Ta(r,i)},i)}:e=>{},n=Ea(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],n.source,n.scope)[e[1]](n,r)}else r(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class Yx{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=ri();const i=this.workerPool.acquire(this.id);for(let e=0;e{this.ready=!0}))}broadcast(e,t,i){Qt(this.actors,((i,r)=>{i.send(e,t,r)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove()})),this.actors=[],this.workerPool.release(this.id)}}Yx.Actor=Xx;var Kx={workerUrl:"",workerClass:null,workerParams:void 0};function Jx(){return null!=Kx.workerClass?new Kx.workerClass:new self.Worker(Kx.workerUrl,Kx.workerParams)}const Qx="mapboxgl_preloaded_worker_pool";class ev{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Qx]}numActive(){return Object.keys(this.active).length}}let tv;function iv(){return tv||(tv=new ev),tv}ev.workerCount=2;let rv,nv,ov,sv,av,lv=null;function cv(){return gi()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:nv||r.DRACO_URL}function uv(){if(gi()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(sv)return sv;const e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return sv=WebAssembly.validate(e)?r.MESHOPT_SIMD_URL:r.MESHOPT_URL,sv}const hv={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},dv={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},pv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function fv(e,t,i){const r=i.json.bufferViews.length,n=i.buffers.length;t.bufferView=r,i.json.bufferViews[r]={buffer:n,byteLength:e.byteLength},i.buffers[n]=e}const mv="KHR_draco_mesh_compression";function _v(e,t){const i=e.extensions&&e.extensions[mv];if(!i)return;const r=new ov.Decoder,n=Tv(t,i.bufferView),o=new ov.Mesh;if(!r.DecodeArrayToMesh(n,n.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=t.json.accessors[e.indices],a=hv[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=ov._malloc(l);a===Uint16Array?r.GetTrianglesUInt16Array(o,l,c):r.GetTrianglesUInt32Array(o,l,c),fv(ov.memory.buffer.slice(c,c+l),s,t),ov._free(c);for(const n of Object.keys(i.attributes)){const s=r.GetAttributeByUniqueId(o,i.attributes[n]),a=t.json.accessors[e.attributes[n]],l=dv[a.componentType],c=a.count*pv[a.type]*hv[a.componentType].BYTES_PER_ELEMENT,u=ov._malloc(c);r.GetAttributeDataArrayForAllPoints(o,s,ov[l],c,u),fv(ov.memory.buffer.slice(u,u+c),a,t),ov._free(u)}r.destroy(),o.destroy(),delete e.extensions[mv]}const gv="EXT_meshopt_compression";function yv(e,t){if(!e.extensions||!e.extensions[gv])return;const i=e.extensions[gv],r=new Uint8Array(t.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),n=new Uint8Array(i.count*i.byteStride);av.decodeGltfBuffer(n,i.count,i.byteStride,r,i.mode,i.filter),e.buffer=t.buffers.length,e.byteOffset=0,t.buffers[e.buffer]=n.buffer,delete e.extensions[gv]}const xv=1179937895,vv=new TextDecoder("utf8");function bv(e,t){return new URL(e,t).href}function wv(e,t,i,r){return fetch(bv(e.uri,r)).then((e=>e.arrayBuffer())).then((e=>{t.buffers[i]=e}))}function Tv(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ev(e,t,i,r){if(e.uri){const n=bv(e.uri,r);return fetch(n).then((e=>e.blob())).then((e=>createImageBitmap(e))).then((e=>{t.images[i]=e}))}if(void 0!==e.bufferView){const r=Tv(t,e.bufferView),n=new Blob([r],{type:e.mimeType});return createImageBitmap(n).then((e=>{t.images[i]=e}))}}function Sv(e,t=0,i){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===xv){const i=new Uint32Array(e,t);let n=2;const o=(i[n++]>>2)-3,s=i[n++]>>2;if(n++,r.json=JSON.parse(vv.decode(i.subarray(n,n+s))),n+=s,n{const e=[],t=a&&a.includes(mv),n=a&&a.includes(gv);if(t&&e.push((function(){if(!ov)return rv||(rv=(function(e){let t,i=null;function r(){t=new Uint8Array(i.buffer)}function n(){throw new Error("Unexpected Draco error.")}const o={a:{a:n,d:function(e,i,r){return t.copyWithin(e,i,i+r)},c:function(e){const n=t.length,o=Math.max(e>>>0,Math.ceil(1.2*n)),s=Math.ceil((o-n)/65536);try{return i.grow(s),r(),!0}catch(e){return!1}},b:n}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,o)))).then((e=>{const{Rb:n,Qb:o,P:s,T:a,X:l,Ja:c,La:u,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:x,Ab:v,Bb:b,Db:w,Gb:T}=e.instance.exports;i=g;const E=(()=>{let e=0,i=0,r=0,s=0;return a=>{r&&(n(s),n(e),i+=r,r=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(r=l,c=s=o(l));for(let e=0;e{ov=e,rv=void 0})))})()),n&&e.push((function(){if(av)return;const e=(function(e){let t;const i=WebAssembly.instantiateStreaming(e,{}).then((e=>{t=e.instance,t.exports.__wasm_call_ctors()})),r={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},n={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(e,i,o,s,a,l){!(function(e,t,i,r,n,o,s){const a=e.exports.sbrk,l=r+3&-4,c=a(l*n),u=a(o.length),h=new Uint8Array(e.exports.memory.buffer);h.set(o,u);const d=t(c,r,n,u,o.length);if(0===d&&s&&s(c,l,n),i.set(h.subarray(c,c+r*n)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)})(t,t.exports[n[a]],e,i,o,s,t.exports[r[l]])}}})(fetch(uv()));return e.ready.then((()=>{av=e}))})()),o)for(let t=0;t{if(t&&s)for(const{primitives:e}of s)for(const t of e)_v(t,r);if(n&&s&&l)for(const e of l)yv(e,r);return r}))}))}function Mv(e,t){const i=e.json.bufferViews[t.bufferView],r=hv[t.componentType];return new r(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*(i.byteStride&&i.byteStride!==pv[t.type]*r.BYTES_PER_ELEMENT?i.byteStride/r.BYTES_PER_ELEMENT:pv[t.type]))}function Iv(e,t,i,r){const n=hv[t.componentType],o=(function(e){switch(e){case Int8Array:return.007874015748031496;case Uint8Array:return.00392156862745098;case Int16Array:return 3051850947599719e-20;case Uint16Array:return 15259021896696422e-21;default:return 1}})(n),s=e.json.bufferViews[t.bufferView],a=s.byteStride?s.byteStride/n.BYTES_PER_ELEMENT:pv[t.type],l=i.float32,c=l.length/i.capacity;for(let e=0,i=0;e0){for(let n=0;n0){o.texcoordArray=new tc;const e=t.json.accessors[n.TEXCOORD_0];o.texcoordArray.resize(e.count);const i=Mv(t,e);Iv(t,e,o.texcoordArray,i)}if(void 0!==n._FEATURE_ID_RGBA4444){const e=t.json.accessors[n._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=Mv(t,e))}void 0!==n._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(Mv(t,t.json.accessors[n._FEATURE_RGBA4444]).buffer));const h=e.material;return o.material=(function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:r="OPAQUE",alphaCutoff:n=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:u=1,roughnessFactor:h=1,baseColorTexture:d,metallicRoughnessTexture:p}=e.pbrMetallicRoughness||{},f=s?t[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&f){const e=s.extensions.KHR_texture_transform;f.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Ur(...c),metallicFactor:u,roughnessFactor:h,baseColorTexture:d?t[d.index]:void 0,metallicRoughnessTexture:p?t[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:r,alphaCutoff:n,normalTexture:o?t[o.index]:void 0,occlusionTexture:f,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}})(void 0!==h?t.json.materials[h]:{defined:!1},i),o}function Cv(t,i,r){const{matrix:n,rotation:o,translation:s,scale:a,mesh:l,extras:c,children:u}=t,h={};if(h.matrix=n||e.ad.fromRotationTranslationScale([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),void 0!==l){h.meshes=r[l];const e=h.anchor=[0,0];for(const t of h.meshes){const{min:i,max:r}=t.aabb;e[0]+=i[0]+r[0],e[1]+=i[1]+r[1]}e[0]=Math.floor(e[0]/h.meshes.length/2),e[1]=Math.floor(e[1]/h.meshes.length/2)}if(c&&(c.id&&(h.id=c.id),c.lights&&(h.lights=(function(e){if(!e.length)return[];const t=(function(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e1&&r[r.length-1].equals(r[0])&&r.pop();let n=0;for(let e=0;e0&&r.reverse();const o=xd(r.flatMap((e=>[e.x,e.y])),[]);return 0===o.length?null:{vertices:r,indices:o}}function Dv(t,i){const r=[],n=[];let o=0;const s=[];for(const a of t){o=r.length;const t=a.vertexArray.float32,l=a.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]])}return{vertices:r,indices:n}}function Lv(e){const t=(function(e,t){const i=[],r=WebGL2RenderingContext;if(e.json.textures)for(const n of e.json.textures){const o={magFilter:r.LINEAR,minFilter:r.NEAREST,wrapS:r.REPEAT,wrapT:r.REPEAT};void 0!==n.sampler&&Object.assign(o,e.json.samplers[n.sampler]),i.push({image:t[n.source],sampler:o,uploaded:!1})}return i})(e,e.images),i=(function(e,t){const i=[];for(const r of e.json.meshes){const n=[];for(const i of r.primitives)n.push(Av(i,e,t));i.push(n)}return i})(e,t),{scenes:r,scene:n,nodes:o}=e.json,s=r?r[n||0].nodes:o,a=[];for(const t of s)a.push(Cv(o[t],e,i));return(function(e,t,i){const r={},n=new Set;for(let o=0;o0){const t=Array.from(n.values()).sort(((e,t)=>e-t));for(let i=t.length-1;i>=0;i--)e.splice(t[i],1)}})(a,s,e.json.nodes),a}function Rv(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,r=e.aabb.min[1]-1,n=Nx/(e.aabb.max[0]-i+2),o=Nx/(e.aabb.max[1]-r+2);for(let s=0;se.heightmap[c*Nx+l]&&(e.heightmap[c*Nx+l]=a)}}function kv(t,i){const r={};r.indexArray=new Yl,r.indexArray.reserve(4*t.length),r.vertexArray=new Bl,r.vertexArray.reserve(10*t.length),r.colorArray=new Ol,r.vertexArray.reserve(10*t.length);let n=0;for(const o of t){const t=Math.min(10,Math.max(4,1.3*o.height))*i,s=[-o.normal[1],o.normal[0],0],a=Math.min(.29,.1*o.width/o.depth),l=o.width-2*o.depth*i*(a+.01),c=e._.scaleAndAdd([],o.pos,s,l/2),u=e._.scaleAndAdd([],o.pos,s,-l/2),h=[c[0],c[1],c[2]+o.height],d=[u[0],u[1],u[2]+o.height],p=e._.scaleAndAdd([],o.normal,s,a);e._.scale(p,p,t);const f=e._.scaleAndAdd([],o.normal,s,-a);e._.scale(f,f,t),e._.add(p,c,p),e._.add(f,u,f),c[2]+=.1,u[2]+=.1,r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]);const m=l/t/2;r.colorArray.emplaceBack(-m-a,-1,m,.8),r.colorArray.emplaceBack(m+a,-1,m,.8),r.colorArray.emplaceBack(-m,0,m,1.3),r.colorArray.emplaceBack(m,0,m,1.3),r.colorArray.emplaceBack(m+a,-.8,m,.7),r.colorArray.emplaceBack(m+a,-.8,m,.7),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(m+a,-1.2,m,.8),r.colorArray.emplaceBack(m+a,-1.2,m,.8),r.indexArray.emplaceBack(6+n,4+n,8+n),r.indexArray.emplaceBack(7+n,9+n,5+n),r.indexArray.emplaceBack(0+n,1+n,2+n),r.indexArray.emplaceBack(1+n,3+n,2+n),n+=10}const o={defined:!0,emissiveFactor:[0,0,0]},s={};return s.baseColorFactor=Ur.white,o.pbrMetallicRoughness=s,r.material=o,r.aabb=new bh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}const Ov=new Float32Array(262144),Bv=new Uint8Array(262144);function Fv(e){let t=0;if(e.meshes)for(const i of e.meshes)t=Math.max(t,i.aabb.max[2]);if(e.children)for(const i of e.children)t=Math.max(t,Fv(i));return t}function Nv(e,t,i){if(e.meshes)for(const r of e.meshes)r.aabb.min[0]!==1/0&&i.insert(t,r.aabb.min[0],r.aabb.min[1],r.aabb.max[0],r.aabb.max[1]);if(e.children)for(const r of e.children)Nv(r,t,i)}const Vv=["","wall","door","roof","window","lamp","logo"];class Uv{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:e.id,geometry:[],properties:{height:Fv(e)}},this.aabb=this._getLocalBounds()}_getLocalBounds(){if(!this.node.meshes)return new bh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new bh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const i of this.node.meshes)this.node.lightMeshIndex!==e&&(i.transformedAabb=bh.applyTransform(i.aabb,this.node.matrix),t.encapsulate(i.transformedAabb)),e++;this.aabb=t}return this.aabb}}class jv{constructor(e,t,i,r,n,o){this.id=t,this.modelTraits|=Vx.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=Vx.HasMapboxMeshFeatures),r&&(this.modelTraits|=Vx.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=n,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const t of e)this.nodesInfo.push(new Uv(t)),Nv(t,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}updateFootprints(e,t){for(const i of this.getNodesInfo()){const r=i.node;r.footprint&&t.push({footprint:r.footprint,id:e})}}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const i of t){const t=i.node;this.uploaded?this.updatePbrBuffer(t):qx(t,e,!0)}for(const e of t)Zx(e.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);return t}needsReEvaluation(e,t,i){const r=e.transform.projectionOptions,n=e.style.getBrightness(),o=this.brightness!==n;return!!(!this.uploaded||this.dirty||r.name!==this.projection.name||Gv(i.paint.get("model-color").value,o)||Gv(i.paint.get("model-color-mix-intensity").value,o)||Gv(i.paint.get("model-roughness").value,o)||Gv(i.paint.get("model-emissive-strength").value,o)||Gv(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=r,this.brightness=n,!0)}evaluateScale(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),r=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},r)}}evaluate(e){const t=this.getNodesInfo();for(const i of t){if(!i.node.meshes)continue;const t=i.feature,r=i.node.meshes&&i.node.meshes[0].featureData,n=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,r){for(let r=0;r=e)continue;const h=Ov[c],d=Math.abs(h);d>a&&(s=h,a=d,l=n,u=t)}if(a>.1){const o=1-(e+.5*Math.abs(l*u))/c;let a=t._dem.get(r,i)+s*o;const h=t._dem.get(r+l,i+u),d=t._dem.get(r-l,i-u,!0);(a-h)*(a-d)>0&&(a=(h+d)/2),Ov[n]=t._dem.set(r,i,a),Bv[n]=e}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=Li.now())}getNodesInfo(){return this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)Zx(t.node),$x(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped()),r=this.getNodesInfo();for(let e=0;ee.footprint===t.footprint))}}getHeightAtTileCoord(t,i){const r=this.getNodesInfo(),n=[],o=[0,0,0],s=e.ad.identity([]);for(let a=0;au.max[0]||i>u.max[1])continue;if(!0===l.node.hidden)return{height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};e.ad.invert(s,l.node.matrix),o[0]=t,o[1]=i,e._.transformMat4(o,o,s);const h=(o[0]-c.aabb.min[0])/(c.aabb.max[0]-c.aabb.min[0])*Nx|0,d=Math.min(63,(o[1]-c.aabb.min[1])/(c.aabb.max[1]-c.aabb.min[1])*Nx|0)*Nx+Math.min(63,h),p=c.heightmap[d];if(!(p<0&&l.node.footprint)){if(l.hiddenByReplacement)return;return{height:p,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]}}if(l.node.footprint.grid.query(new Ut(t,i),new Ut(t,i),n),n.length>0)return{height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function Gv(e,t){return!e.isLightConstant&&t}function qv(e,t,i,r,n,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,u=240&t|(240&t)>>4;i[3]>0&&(l=Gr(l,255*i[0],i[3]),c=Gr(c,255*i[1],i[3]),u=Gr(u,255*i[2],i[3]));const h=l<<8|c,d=u<<8|Math.floor(255*r[3]),p=(function(e){const t=Yt(e,0,2);return Math.min(Math.round(.5*t*255),255)})(r[2])<<8|15*r[0]<<4|15*r[1],f=Yt(n[0],0,1),m=Yt(n[1],0,1),_=Yt(n[2],0,1),g=Yt(n[3],0,1);let y,x,v,b;if(f!==m&&s!==o&&m!==f){const e=s-o;x=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=Yt(n[4],-1,1);b=Math.pow(10,t),y=255*_<<8|255*g}else y=65535,x=0,v=1,b=1;if(e.emplaceBack(h,d,p,y,x,v,b),a){const e=a.length;a.clear();for(let t=0;t>16&65535,a=o?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,c=e.evaluatedRMEA[l],u=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let d;if(s&&2===l&&r.lights&&(d=new oc,d.resize(10*r.lights.length)),qv(i.featureArray,n,u,c,h,i.aabb.min[2],i.aabb.max[2],d),d&&s){s=!1;const e=r.meshes[r.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}i.featureArray._trim(),n++}}function $v(e,t,i,r){const n=1<e.polygon)).flat());const g=f?l:null,[y,x]=(function(t,i,r,n,o,s,a,l,c,u,h){return"globe"===t.projection.name?(function(t,i,r,n,o,s,a,l,c,u,h){const d=[],p=[],f=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,m=[0,0,0,1],_=[0,0,0,1],g=(e,t,i,r)=>{e[0]=t,e[1]=i,e[2]=r,e[3]=1},y=Tf();r>0&&(r+=y),n+=y;for(const y of i){const i=[],x=[];for(const d of y){const p=d.x+o.x,y=d.y+o.y,v=t.projection.projectTilePoint(p,y,h),b=t.projection.upVector(h,d.x,d.y);let w=r,T=n;if(a){const e=Pf(p,y,r,n,a,l,c,u);w+=e.base,T+=e.top}0!==r?g(m,v.x+b[0]*f*w,v.y+b[1]*f*w,v.z+b[2]*f*w):g(m,v.x,v.y,v.z),g(_,v.x+b[0]*f*T,v.y+b[1]*f*T,v.z+b[2]*f*T),e._.transformMat4(m,m,s),e._.transformMat4(_,_,s),i.push(new wp(m[0],m[1],m[2])),x.push(new wp(_[0],_[1],_[2]))}d.push(i),p.push(x)}return[d,p]})(t,i,r,n,o,s,a,l,c,u,h):a?(function(t,i,r,n,o,s,a,l,c){const u=[],h=[],d=[0,0,0,1];for(const p of t){const t=[],f=[];for(const u of p){const h=u.x+n.x,p=u.y+n.y,m=Pf(h,p,i,r,s,a,l,c);d[0]=h,d[1]=p,d[2]=m.base,d[3]=1,e.aA.transformMat4(d,d,o),d[3]=Math.max(d[3],1e-5);const _=new wp(d[0]/d[3],d[1]/d[3],d[2]/d[3]);d[0]=h,d[1]=p,d[2]=m.top,d[3]=1,e.aA.transformMat4(d,d,o),d[3]=Math.max(d[3],1e-5);const g=new wp(d[0]/d[3],d[1]/d[3],d[2]/d[3]);t.push(_),f.push(g)}u.push(t),h.push(f)}return[u,h]})(i,r,n,o,s,a,l,c,u):(function(e,t,i,r,n){const o=[],s=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,u=n[11]*t,h=n[8]*i,d=n[9]*i,p=n[10]*i,f=n[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+r.x,s=o.y+r.y,m=n[0]*t+n[4]*s+n[12],_=n[1]*t+n[5]*s+n[13],g=n[2]*t+n[6]*s+n[14],y=n[3]*t+n[7]*s+n[15],x=m+a,v=_+l,b=g+c,w=Math.max(y+u,1e-5),T=m+h,E=_+d,S=g+p,M=Math.max(y+f,1e-5);e.push(new wp(x/w,v/w,b/w)),i.push(new wp(T/M,E/M,S/M))}o.push(e),s.push(i)}return[o,s]})(i,r,n,o,s)})(s,n,d,h,u,a,g,p,m,s.center.lat,t.tileID.canonical),v=t.queryGeometry;return(function(e,t,i){let r=1/0;Yu(i,t)&&(r=Cf(i,t[0]));for(let n=0;n=3)for(let t=0;t>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=Hv[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new Xv(s,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=Hv.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Yv(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)eb(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=h+u>>1,p=n[2*d],f=n[2*d+1];eb(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function Yv(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;Kv(e,t,s,r,n,o),Yv(e,t,i,r,s-1,1-o),Yv(e,t,i,s+1,n,1-o)}function Kv(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);Kv(e,t,i,Math.max(r,Math.floor(i-a*c/s+u)),Math.min(n,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=r,l=n;for(Jv(e,t,r,i),t[2*n+o]>s&&Jv(e,t,r,n);as;)l--}t[2*r+o]===s?Jv(e,t,r,l):(l++,Jv(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function Jv(e,t,i,r){Qv(e,i,r),Qv(t,2*i,2*r),Qv(t,2*i+1,2*r+1)}function Qv(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function eb(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}e.$=Kt,e.A=Wo,e.B=qo,e.C=Ur,e.D=zn,e.E=kr,e.G=ll,e.H=Qs,e.I=bg,e.J=Ys,e.K=function(e){const t=e.value;let i=[];if(!t)return i;const r=Mn(t);return"string"!==r?(i=i.concat([new Dx(e.key,t,`string expected, "${r}" found`)]),i):(Lx(t,!0)||(i=i.concat([new Dx(e.key,t,`invalid url "${t}"`)])),i)},e.L=ol,e.M=class{constructor(e,t,i,r){this.id=e,this.position=null!=t?new du(t[0],t[1]):new du(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new bh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,i){if(e.ad.multiply(t.matrix,i,t.matrix),t.meshes)for(const e of t.meshes){const i=bh.applyTransform(e.aabb,t.matrix);this.aabb.encapsulate(i)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=e.ad.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(e,t,i,r,n,o,s=!1){Ux(this.matrix,this,e.transform,this.position,t,i,r,n,o,s)}upload(e){if(!this.uploaded){for(const t of this.nodes)qx(t,e);for(const e of this.nodes)Zx(e);this.uploaded=!0}}destroy(){for(const e of this.nodes)$x(e)}},e.N=nl,e.O=tl,e.P=Ut,e.Q=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return _i(e.expression.evaluate(t))}interpolate(e,t,i){return{x:Gr(e.x,t.x,i),y:Gr(e.y,t.y,i),z:Gr(e.z,t.z,i),azimuthal:Gr(e.azimuthal,t.azimuthal,i),polar:Gr(e.polar,t.polar,i)}}},e.R=Ki,e.S=sc,e.T=Vg,e.U=Xa,e.V=Dx,e.W=ti,e.X=$a,e.Y=ku,e.Z=ha,e.a=Mg,e.a$=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return Zh(t,i,e.worldSize,r,n)},e.a0=el,e.a1=$h,e.a2=Gr,e.a3=co,e.a4=qr,e.a5=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return(function([e,t]){const i=_i([1,e,t]);return{x:i.x,y:i.y,z:i.z}})(e.expression.evaluate(t))}interpolate(e,t,i){return{x:Gr(e.x,t.x,i),y:Gr(e.y,t.y,i),z:Gr(e.z,t.z,i)}}},e.a6=Bc,e.a7=Pc,e.a8=Dc,e.a9=kc,e.aB=function(t,i){const{x:r,y:n}=t.point,o=Zh(r,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return e.ad.multiply(o,o,jh(zh(i)))},e.aD=Vm,e.aE=Xm,e.aF=Nm,e.aG=function(e,t,i,r,n){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=r,e.float32[o+2]=n},e.aH=kg,e.aI=du,e.aJ=vg,e.aK=gu,e.aL=yu,e.aM=vh,e.aN=_x,e.aO=_u,e.aP=kh,e.aQ=function(e,t,i,r,n,o,s,a,l){if("globe"===l.name)return kh(e,t,new _u(i,r,n),!1);const c=J_({z:i,x:r,y:n},l);return new bh([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])},e.aR=function(e,t,i){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]0&&r[0]<=t.width&&r[1]>0&&r[1]<=t.height&&!Hh(t,new du(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!Hh(t,new du(t.center.lat,-90))]},e.aW=function(t,i){const{scale:r}=t.tileTransform,n=r*co/(t.tileSize*Math.pow(2,i.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return e.aC.scale(new Float32Array(4),i.inverseAdjustmentMatrix,[n,n])},e.aX=gx,e.aY=mx,e.aZ=function(t){const i=mx(t,!0);return e.aC.invert([],[i[0],i[1],i[4],i[5]])},e.a_=mh,e.aa=zc,e.ab=qt,e.ac=function(e,t,i){const r=Math.sqrt(e*e+t*t+i*i),n=r>0?Math.acos(i/r)*Gt:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*Gt+90:0;return o<0&&(o+=360),[r,o,n]},e.ae=wg,e.af=Cg,e.ag=Eg,e.ah=function(e,t){const i={};for(let r=0;rVi&&(e.getActor().send("enforceCacheSizeLimit",Ni),Gi=0)},e.an=_r,e.ao=class{constructor(e){this.entries={},this.scheduler=e}request(e,t,i,r){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(e,i)}),t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,r)}),t):e(i,r);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==r)),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}},e.ap=function(e,t,i){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const r=tr(e.request,((e,r,n,o)=>{e?t(e):r&&t(null,{vectorTile:i?void 0:new vp(new Cm(r)),rawData:r,cacheControl:n,expires:o})}));return()=>{r.cancel(),t()}}),t)},e.aq=Lc,e.ar=class extends Cc{constructor(e){super(e),this.current=Fc}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},e.as=Rc,e.at=Yt,e.au=Jt,e.aw=Ii,e.ax=Mu,e.ay=Au,e.az=function(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3]},e.b=bc,e.b$=nf,e.b0=Zt,e.b1=tu,e.b2=function(e){const t=Math.round((e+45+360)%360/90)%4;return $t[t]},e.b3=45,e.b4=Tu,e.b5=Ru,e.b6=bh,e.b7=_i,e.b8=function(e){return[Math.pow(e[0],.45454545454545453),Math.pow(e[1],.45454545454545453),Math.pow(e[2],.45454545454545453)]},e.b9=Wt,e.bA=function(e,t){return[Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]},e.bB=tm,e.bD=qh,e.bE=zi,e.bF=Pi,e.bG=256,e.bH=function(t,i){const r=[0,0,0],n=Uh(zh(i.canonical));return e._.transformMat4(r,r,n),e._.transformMat4(r,r,t),r},e.bI=e=>({u_camera_to_center_distance:new zc(e),u_extrude_scale:new Vc(e),u_device_pixel_ratio:new zc(e),u_matrix:new Bc(e),u_inv_rot_matrix:new Bc(e),u_merc_center:new Dc(e),u_tile_id:new Lc(e),u_zoom_transition:new zc(e),u_up_dir:new Lc(e),u_emissive_strength:new zc(e)}),e.bJ=e=>({u_matrix:new Bc(e),u_pixels_to_tile_units:new Vc(e),u_device_pixel_ratio:new zc(e),u_units_to_pixels:new Dc(e),u_dash_image:new Pc(e),u_gradient_image:new Pc(e),u_image_height:new zc(e),u_texsize:new Dc(e),u_tile_units_to_pixels:new zc(e),u_alpha_discard_threshold:new zc(e),u_trim_offset:new Dc(e),u_trim_fade_range:new Dc(e),u_trim_color:new Rc(e),u_emissive_strength:new zc(e)}),e.bK=e=>({u_matrix:new Bc(e),u_texsize:new Dc(e),u_pixels_to_tile_units:new Vc(e),u_device_pixel_ratio:new zc(e),u_image:new Pc(e),u_units_to_pixels:new Dc(e),u_tile_units_to_pixels:new zc(e),u_alpha_discard_threshold:new zc(e),u_trim_offset:new Dc(e)}),e.bL=Hl,e.bM=$f,e.bN=Om,e.bO=Um,e.bP=U_,e.bQ=s_,e.bR=Qh,e.bS=(e,t,i,r,n,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=qh(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Li.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Jh,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{const s=e.transform;return{u_matrix:rm(e,t,i,r),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:n,u_image:0,u_tile_units_to_pixels:im(t,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},e.bV=(e,t,i,r,n,o,s)=>{const a=e.transform,l=a.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:rm(e,t,i,r),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:om(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:im(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},e.bW=oi,e.bX=fd,e.bY=Tf,e.bZ=vu,e.b_=mf,e.ba=function(e,t,i){const r=$h(i.zoom),n=e.style.map._antialias,o=t.options.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!n&&!o},e.bb=function(t){const i=t.pixelsPerMeter,r=i/Mu(1,t.center.lat),n=e.ad.identity(new Float64Array(16));return e.ad.translate(n,n,[t.point.x,t.point.y,0]),e.ad.scale(n,n,[r,r,i]),Float32Array.from(n)},e.bc=Oh,e.bd=function(e){const t=80.051129;e=Yt(e,-80.051129,t)/t*90;const i=Math.pow(Math.abs(Math.sin(qt(e))),3);return Math.round(i*(ou.length-1))},e.be=function(t,i,r,n){const o=i.getNorth(),s=i.getSouth(),a=i.getWest(),l=i.getEast(),c=1<0){const t=180/n;e.bC.multiply(f,f,[t/u+1,0,0,0,t/h+1,0,-.5*t/d,.5*t/p,1])}return f[2]=c,f[5]=t.x,f[8]=t.y,f},e.bf=Uh,e.bg=zh,e.bh=function(t,i,r){const n=e.ad.identity(new Float64Array(16)),o=(i/(1<{}}},e.bo=Ug,e.bp=ai,e.bq=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const i=t.getSource().maxzoom,r=1<1)return t;const n=r.getSource().maxzoom,o=1<{const s=this.getAtTileOffset(t,o.x,o.y),a=n.upVector(t.canonical,o.x,o.y),l=n.upVectorScale(t.canonical,i,r).metersToTile;return e._.scale(a,a,s*l),a}}getForTilePoints(e,t,i,r){if(this.isUsingMockSource())return!1;const n=Xp.create(this,e,r);return!!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i)})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<=0?e.slice(0,t):e},e.cV=function(e){return e.indexOf(bl)>=0},e.cW=function(e){const t=e.indexOf(bl);return t>=0?e.slice(t+1):""},e.cX=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},e.cY=function(e,t,i,r){return"custom"===e.type?new ux(e,t):new Wv[e.type](e,t,i,r)},e.cZ=ui,e.c_=ja,e.ca=1,e.cb=Sg,e.cc=0,e.cd=ec,e.ce=function(e,t,i,r,n){return Yt((e-t)/(i-t)*(n-r)+r,r,n)},e.cf=Ns,e.cg=Du,e.ch=class{constructor(e,t,i,r){this.context=e,this.format=r,this.size=i,this.texture=e.gl.createTexture();const[n,o,s]=this.size,{gl:a}=e;a.bindTexture(a.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,c=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(l=a.DEPTH_COMPONENT16,c=a.UNSIGNED_SHORT),this.format===a.R8&&(r=a.RED),this.format===a.R32F&&(c=a.FLOAT,r=a.RED),a.texImage3D(a.TEXTURE_3D,0,l,n,o,s,0,r,c,t.data)}bind(e,t){const{context:i}=this,{gl:r}=i;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)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}},e.ci=Tx,e.cj=[1,1,1],e.ck=Xp,e.cl=Vx,e.cm=Zl,e.cn=tc,e.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ut(1/0,1/0),max:new Ut(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const i=zp(new Ut(0,0),new Ut(co,co),e),r=[];if(t&&!Cp(i,this._globalClipBounds))return r;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Cp(i,t))continue;const n=Dp(t.min,t.max,e);r.push({min:n.min,max:n.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask})}return r}setSources(e){this._setSources(e.map((e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(i).buckets[e.layer];r&&r.updateFootprints(i.toUnwrapped(),t)}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask}))))}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const i=e.getOrder(),r=e.getClipMask();for(const e of t){if(!e.footprint)continue;const t=zp(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint,order:i,clipMask:r})}this._sourceIds.push(e.getSourceId())}_computeReplacement(){this._activeRegions.sort(((e,t)=>e.priority-t.priority||Ip(e.min,t.min)||Ip(e.max,t.max)));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const i=this._activeRegions[t],r=this._prevRegions[t];e=i.priority!==r.priority||!Ap(i,r)||i.order!==r.order||i.clipMask!==r.clipMask,++t}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const i=t[e].priority;for(;e1){let t=0,i=e(t);for(;t!==i;){let r=t;const n=t;for(;r!==i;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.cp=Ll,e.cq=Xg,e.cr=rc,e.cs=class{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,t){const i=new zl,r=new Yl,n=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let r=e===o-1?e-2:0===e?e:e-1;return r+=i?24575:0,[r,t]};for(let e=0;ee()))},e.dB=Kx,e.dC=cv,e.dD=function(e){nv=Li.resolveURL(e),lv||(lv=new Yx(iv(),new kr)),lv.broadcast("setDracoUrl",nv)},e.dE=uv,e.dF=function(e){sv=Li.resolveURL(e),lv||(lv=new Yx(iv(),new kr)),lv.broadcast("setMeshoptUrl",sv)},e.dG=ei,e.dH=va,e.dI=cd,e.dJ=M_,e.dK=J_,e.dL=cc,e.dM=sm,e.dN=Lm,e.dO=Wf,e.dP=ci,e.dQ=w_,e.dR=Ng,e.dS=function(e,t,i,r,n,o,s,a,l,c,u){e.createArrays(),e.tilePixelRatio=co/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new $a(t),a),d["text-size"].possiblyEvaluate(new $a(i),a)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new $a(t),a),d["icon-size"].possiblyEvaluate(new $a(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new $a(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new $a(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new $a(18),a);const f="map"===h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement"),m=h.get("text-size");let _=!1;for(const t of e.features)if(t.icon&&t.icon.nameSecondary){_=!0;break}for(const o of e.features){const l=h.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),x=o.text;let v,b=[0,0];if(x){const r=x.toString(),s=h.get("text-letter-spacing").evaluate(o,{},a)*Om,c=h.get("text-line-height").evaluate(o,{},a)*Om,u=Ia(r)?s:0,p=h.get("text-anchor").evaluate(o,{},a),m=h.get("text-variable-anchor");if(!m){const e=h.get("text-radial-offset").evaluate(o,{},a);b=e?U_(p,[e*Om,N_]):h.get("text-offset").evaluate(o,{},a).map((e=>e*Om))}let _=f?"center":h.get("text-justify").evaluate(o,{},a);const v="point"===h.get("symbol-placement"),w=v?h.get("text-max-width").evaluate(o,{},a)*Om:1/0,T=o=>{e.allowVerticalPlacement&&Ma(r)&&(y.vertical=Jm(x,t,i,n,l,w,c,p,o,u,b,Xm.vertical,!0,g,d))};if(!f&&m){const e="auto"===_?m.map((e=>j_(e))):[_];let r=!1;for(let o=0;o=0||!Ma(r)){const e=Jm(x,t,i,n,l,w,c,p,_,u,b,Xm.horizontal,!1,g,d);e&&(y.horizontal[_]=e)}T(v?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const t=r[o.icon.namePrimary];t&&(v=l_(n[o.icon.namePrimary],o.icon.nameSecondary?n[o.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(o,{},a),h.get("icon-anchor").evaluate(o,{},a)),w=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&pi("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const T=W_(y.horizontal)||y.vertical;e.iconsInText||(e.iconsInText=!!T&&T.iconsInText),(T||v)&&G_(e,o,y,v,r,p,g,0,b,w,s,a,c,u,_)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)},e.dT=Kf,e.dU=Hd,e.dV=vp,e.dW=Cm,e.dX=Hp,e.dY=Oy,e.dZ=bp,e.d_=lp,e.da=Wh,e.db=function(t){const i=[0,0,0],r=e.ad.identity(new Float64Array(16));return e.ad.multiply(r,t.pixelMatrix,t.globeMatrix),e._.transformMat4(i,i,r),new Ut(i[0],i[1])},e.dc=u,e.dd=c,e.de=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!(function(e){if(null==Si){const t=e.navigator?e.navigator.userAgent:null;Si=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Si})(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.df=ri,e.dg=class{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=(function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",ar,e].join(""),tokenExpiresAt:Date.now()+432e5}})();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,i){if(!o(e))return e;const r=ur(e);return r.params.push(`sdk=js-${t}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||i)}normalizeGlyphsURL(e,t){if(!o(e))return e;const i=ur(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeModelURL(e,t){if(!o(e))return e;const i=ur(e);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,r){if(!o(e))return e;const n=ur(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),i&&n.params.push(`language=${i}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,r){const n=ur(e);return o(e)?(n.path=`/styles/v1${n.path}/sprite${t}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${t}${i}`,hr(n))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!o(e))return e;const n=ur(e);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==n.authority&&512===i?"@2x":""}${qi.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${r.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${r.RASTERARRAYS_URL_PREFIX}${n.path}`:"3dtiles"===n.authority?n.path=`/${r.TILES3D_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${r.TILE_URL_VERSION}${n.path}`);const s=this._customAccessToken||(function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null})(n.params)||r.ACCESS_TOKEN;return r.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(e,t){const i=ur(e);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${r.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${i.path.replace(`/${r.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${r.TILE_URL_VERSION}/`,"")}`;let o=i.params;return t&&(o=o.filter((e=>!e.match(/^access_token=/)))),o.length&&(n+=`?${o.join("&")}`),n}canonicalizeTileset(e,t){const i=!!t&&o(t),r=[];for(const t of e.tiles||[])n(t)?r.push(this.canonicalizeTileURL(t,i)):r.push(t);return r}_makeAPIURL(e,t){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=ur(r.API_URL);if(e.protocol=n.protocol,e.authority=n.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==n.path&&(e.path=`${n.path}${e.path}`),!r.REQUIRE_ACCESS_TOKEN)return hr(e);if(t=t||r.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),hr(e)}},e.dh=function(e,t){t?Sr.add(e):Sr.delete(e)},e.di=qi,e.dj=wr,e.dk=Er,e.dl=lr,e.dm=yr,e.dn=vr,e.dp=function(e){Sr.delete(e)},e.dq=Tr,e.dr=gr,e.ds=Qt,e.dt=t,e.du=function(e,t){Ni=e,Vi=t},e.dv=function(e,t,i=!1){if(Fa===Ra||Fa===ka||Fa===Oa)throw new Error("setRTLTextPlugin cannot be called multiple times.");Na=Li.resolveURL(e),Fa=Ra,Ba=t,Ua(),i||qa()},e.dw=Ga,e.dx=function(){iv().acquire(Qx)},e.dy=function(){const e=tv;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Qx),tv=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.dz=ev,e.e=Li,e.e0=lm,e.e1=d,e.e2=tr,e.e3=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==xv){const i=new Uint32Array(e,0,7),[,,r,n,o,s]=i;t=i.byteLength+n+o+s+o,(r!==e.byteLength||t>=e.byteLength)&&pi("Invalid b3dm header information.")}return Sv(e,t)},e.e4=function(e,t){const i=Lv(e);for(const e of i){for(const t of e.meshes)Rv(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(kv(e.lights,t)))}return i},e.e5=jv,e.e6=Xx,e.e7=Za,e.e8=function(e){ji(),Bi&&Bi.then((t=>{t.keys().then((i=>{for(let r=0;re.arrayBuffer())).then((t=>Sv(t,0,e)))},e.m=class extends Dx{},e.n=Mn,e.o=$r,e.p=Yg,e.q=Xs,e.r=Ks,e.s=Js,e.t=la,e.u=sl,e.v=al,e.w=pi,e.x=da,e.y=ca,e.z=Zo})),r(0,(function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const r of e)t+=`${i(r)},`;return`${t}]`}let t="{";for(const r of Object.keys(e).sort())t+=`${r}:${i(e[r])},`;return`${t}}`}function r(t){let r="";for(const n of e.cE)r+=`/${i(t[n])}`;return r}class n{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,i,n){this._options=n;for(const i of t)this._layerConfigs[i.id]=i,(this._layers[i.id]=e.cY(i,this.scope,null,this._options)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const o=(function(e,t){const i={};for(let n=0;nthis._layers[e.id])),i=t[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(t)}}}const o=1*e.dJ;class s{constructor(t){const i={},r=[];for(const e in t){const n=t[e],s=i[e]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i=t.metrics.localGlyph?o:1,a={x:0,y:0,w:t.bitmap.width+2*i,h:t.bitmap.height+2*i};r.push(a),s[e]=a}}const{w:n,h:s}=e.j(r),a=new e.dI({width:n||1,height:s||1});for(const r in t){const n=t[r];for(const t in n.glyphs){const s=n.glyphs[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[r][t],c=s.metrics.localGlyph?o:1;e.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}e.dH(s,"GlyphAtlas");class a{constructor(t){this.tileID=new e.aL(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.lut=t.lut,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.dK(t.tileID.canonical,t.projection),this.projection=t.projection,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep}parse(t,i,r,n,o){this.status="parsing",this.data=t,this.collisionBoxArray=new e.dL;const a=new e.dM(Object.keys(t.layers).sort()),c=new e.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h=new e.dO(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:h,availableImages:r,brightness:this.brightness},p=i.familiesBySource[this.source];for(const i in p){const n=t.layers[i];if(!n)continue;let o=!1,s=!1,h=!1;for(const e of p[i])"symbol"===e[0].type?o=!0:s=!0,e[0].is3D()&&"model"!==e[0].type&&(h=!0);if(this.extraShadowCaster&&!h)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(i),m=[];for(let e=0;e=t.maxzoom||"none"!==t.visibility&&(l(e,this.zoom,d.brightness,r),(u[t.id]=t.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(e.map((e=>e.id)))))}}let f,m,_,g;h.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},x=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:e.dG(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&_&&g){const t=new s(m),i=new e.dQ(_,g,this.lut);for(const n in u){const o=u[n];o instanceof e.dR?(l(o.layers,this.zoom,d.brightness,r),e.dS(o,m,t.positions,_,i.iconPositions,this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof e.dT||o instanceof e.dU||o instanceof e.b_)&&(l(o.layers,this.zoom,d.brightness,r),o.addFeatures(d,this.tileID.canonical,i.patternPositions,r,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:e.dG(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:h,imageAtlas:i,brightness:d.brightness})}};if(!this.extraShadowCaster){const t=e.dP(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?n.send("getGlyphs",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{f||(f=e,m=t,x())}),void 0,!1,y):m={};const i=Object.keys(d.iconDependencies);i.length?n.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{f||(f=e,_=t,x())}),void 0,!1,y):_={};const r=Object.keys(d.patternDependencies);r.length?n.send("getImages",{icons:r,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{f||(f=e,g=t,x())}),void 0,!1,y):g={}}x()}}function l(t,i,r,n){const o=new e.X(i,{brightness:r});for(const e of t)e.recalculate(o,n)}class c extends e.E{constructor(t,i,r,n,o,s){super(),this.actor=t,this.layerIndex=i,this.availableImages=r,this.loadVectorData=o||e.ap,this.loading={},this.loaded={},this.deduped=new e.ao(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler,this.brightness=s}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,l=this.loading[n]=new a(i);l.abort=this.loadVectorData(i,((a,c)=>{const u=!this.loading[n];if(delete this.loading[n],u||a||!c)return l.status="done",u||(this.loaded[n]=l),r(a);const h=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new e.dV(new e.dW(h));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((i,n)=>{if(i||!n)return r(i);const a={};if(s){const e=t(o);e.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(e)))}r(null,e.W({rawTileData:h.slice(0)},n,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[n]=l}))}reloadTile(t,i){const r=this.loaded,n=t.uid;if(r&&r[n]){const o=r[n];o.showCollisionBoxes=t.showCollisionBoxes,o.projection=t.projection,o.brightness=t.brightness,o.tileTransform=e.dK(t.tileID.canonical,t.projection),o.extraShadowCaster=t.extraShadowCaster,o.lut=t.lut;const s=(e,t)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,r)),i(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 i(null,void 0)}abortTile(e,t){const i=e.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}}class u{loadTile(t,i){const{uid:r,encoding:n,rawImageData:o,padding:s}=t,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new e.dX(r,a,n,s<1))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const i=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),i}}class h{decodeRasterArray({task:t,buffer:i},r){e.dY.performDecoding(i,t).then((e=>{r(null,e)}),(e=>{r(e)}))}}const d=e.dZ.prototype.toGeoJSON;let p=class{constructor(t){this._feature=t,this.extent=e.a3,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const i of this._feature.geometry)t.push([new e.P(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const r=[];for(const t of i)r.push(new e.P(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,i){return d.call(this,e,t,i)}},f=class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.a3,this.length=t.length,this._features=t}feature(e){return new p(this._features[e])}};const m=.015625;class _{constructor(){this.features=new Map}clear(){this.features.clear()}load(e=[],t){for(const i of e){const e=i.id;if(null==e)continue;let r=this.features.get(e);r&&this.updateCache(r,t),i.geometry?(r=y(i),this.updateCache(r,t),this.features.set(e,r)):this.features.delete(e),this.updateCache(r,t)}}updateCache(e,t){for(const{canonical:i,uid:r}of Object.values(t)){const{z:n,x:o,y:s}=i;g(e,Math.pow(2,n),o,s)&&delete t[r]}}getTile(e,t,i){const r=Math.pow(2,e),n=[];for(const e of this.features.values())g(e,r,t,i)&&n.push(w(e,r,t,i));return{features:n}}getFeatures(){return[...this.features.values()]}}function g({minX:e,minY:t,maxX:i,maxY:r},n,o,s){return e<(o+1+m)/n&&t<(s+1+m)/n&&i>(o-m)/n&&r>(s-m)/n}function y(e){const{id:t,geometry:i,properties:r}=e;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:n,coordinates:o}=i,s={id:t,type:1,geometry:[],tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===n)x(o,a,s);else if("MultiPoint"===n)for(const e of o)x(e,a,s);else if("LineString"===n)s.type=2,v(o,a,s);else if("MultiLineString"===n)s.type=2,b(o,a,s);else if("Polygon"===n)s.type=3,b(o,a,s,!0);else{if("MultiPolygon"!==n)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const e of o)b(e,a,s,!0)}return s}function x([t,i],r,n){const o=e.aj(t);let s=e.ak(i);s=s<0?0:s>1?1:s,r.push(o,s),n.minX=Math.min(n.minX,o),n.minY=Math.min(n.minY,s),n.maxX=Math.max(n.maxX,o),n.maxY=Math.max(n.maxY,s)}function v(e,t,i,r=!1,n=!1){const o=[];for(const t of e)x(t,o,i);t.push(o),r&&(function(e,t){let i=0;for(let t=0,r=e.length,n=r-2;t0===t)for(let t=0,i=e.length;t>31}function N(e,t){for(var i=e.loadGeometry(),r=e.type,n=0,o=0,s=i.length,a=0;ae},G=Math.fround||(q=new Float32Array(1),e=>(q[0]=+e,q[0]));var q;const Z=3,$=5,W=6;class H{constructor(e){this.options=Object.assign(Object.create(j),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),s=this.getClusters([-180,r,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(K(i),J(o),K(n),J(r)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+$]>1?X(l,t,this.clusterProps):this.points[l[t+Z]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(t*this.stride>=o.length)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+$]>1?X(o,i,this.clusterProps):this.points[o[i+Z]])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,i){const r=[];return this._appendLeaves(r,e,t=t||10,i=i||0,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,u={features:[]};return this._addTileFeatures(r.range((t-a)/n,l,(t+1+a)/n,c),r.data,t,i,n,u),0===t&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.data,n,i,n,u),t===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.data,-1,i,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n1;let l,c,u;if(a)l=Y(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+Z]];l=i.properties;const[r,n]=i.geometry.coordinates;c=K(r),u=J(n)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(u*n-r))]],tags:l};let d;d=a||this.options.generateId?t[e+Z]:this.points[t[e+Z]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:r,reduce:n,minPoints:o}=this.options,s=i/(r*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+$])}if(p>d&&p>=o){let e,o=r*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const r of h){const l=r*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+$];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,n&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),n&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+$]>1){const r=this.clusterProps[e[t+W]];return i?Object.assign({},r):r}const r=this.points[e[t+Z]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function X(e,t,i){return{type:"Feature",id:e[t+Z],properties:Y(e,t,i),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),Q(e[t+1])]}};var r}function Y(e,t,i){const r=e[t+$],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+W],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+Z],point_count:r,point_count_abbreviated:n})}function K(e){return e/360+.5}function J(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function Q(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function ee(e,t,i,r){let n=r;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let r=t+3;rn)s=r,n=t;else if(t===n){const e=Math.abs(r-o);er&&(s-t>3&&ee(e,t,s,r),e[s+2]=n,i-s>3&&ee(e,s,i,r))}function te(e,t,i,r,n,o){let s=n-i,a=o-r;if(0!==s||0!==a){const l=((e-i)*s+(t-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return s=e-i,a=t-r,s*s+a*a}function ie(e,t,i,r){const n={id:e??null,type:t,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)re(n,i);else if("Polygon"===t)re(n,i[0]);else if("MultiLineString"===t)for(const e of i)re(n,e);else if("MultiPolygon"===t)for(const e of i)re(n,e[0]);return n}function re(e,t){for(let i=0;i0&&(s+=r?(n*l-a*o)/2:Math.sqrt(Math.pow(a-n,2)+Math.pow(l-o,2))),n=a,o=l}const a=t.length-3;t[2]=1,ee(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function ae(e,t,i,r){for(let n=0;n1?1:i}function ue(e,t,i,r,n,o,s,a){if(r/=t,o>=(i/=t)&&s=r)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===n?t.minX:t.minY,c=0===n?t.maxX:t.maxY;if(s>=i&&c=r)continue;let u=[];if("Point"===o||"MultiPoint"===o)he(e,u,i,r,n);else if("LineString"===o)de(e,u,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===o)fe(e,u,i,r,n,!1);else if("Polygon"===o)fe(e,u,i,r,n,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];fe(t,e,i,r,n,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(ie(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(ie(t.id,o,u,t.tags))}}return l.length?l:null}function he(e,t,i,r,n){for(let o=0;o=i&&s<=r&&me(t,e[o],e[o+1],e[o+2])}}function de(e,t,i,r,n,o,s){let a=pe(e);const l=0===n?_e:ge;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,_,g,i),s&&(a.start=h+c*u)):y>r?x=i&&(u=l(a,p,f,_,g,i),v=!0),x>r&&y<=r&&(u=l(a,p,f,_,g,r),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=pe(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===n?p:f;m>=i&&m<=r&&me(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&me(a,a[0],a[1],a[2]),a.length&&t.push(a)}function pe(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function fe(e,t,i,r,n,o){for(const s of e)de(s,t,i,r,n,o,!1)}function me(e,t,i,r){e.push(t,i,r)}function _e(e,t,i,r,n,o){const s=(o-t)/(r-t);return me(e,o,i+(n-i)*s,1),s}function ge(e,t,i,r,n,o){const s=(o-i)/(n-i);return me(e,t+(r-t)*s,o,1),s}function ye(e,t){const i=[];for(let r=0;r0&&t.size<(n?s:r))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;n&&(function(e,t){let i=0;for(let t=0,r=e.length,n=r-2;t0===t)for(let t=0,i=e.length;t24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let r=(function(e,t){const i=[];if("FeatureCollection"===e.type)for(let r=0;r1&&console.time("creation"),d=this.tiles[h]=we(e,t,i,r,l),this.tileCoords.push({z:t,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==n){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===n)continue;if(null!=n){const e=n-t;if(i!==o>>e||r!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,_=1+p;let g=null,y=null,x=null,v=null,b=ue(e,u,i-p,i+m,0,d.minX,d.maxX,l),w=ue(e,u,i+f,i+_,0,d.minX,d.maxX,l);e=null,b&&(g=ue(b,u,r-p,r+m,1,d.minY,d.maxY,l),y=ue(b,u,r+f,r+_,1,d.minY,d.maxY,l),b=null),w&&(x=ue(w,u,r-p,r+m,1,d.minY,d.maxY,l),v=ue(w,u,r+f,r+_,1,d.minY,d.maxY,l),w=null),c>1&&console.timeEnd("clipping"),a.push(g||[],t+1,2*i,2*r),a.push(y||[],t+1,2*i,2*r+1),a.push(x||[],t+1,2*i+1,2*r),a.push(v||[],t+1,2*i+1,2*r+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const r=this.options,{extent:n,debug:o}=r;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[Ie(c,u,h)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ve(this.tiles[a],n):null):null}}function Ie(e,t,i){return 32*((1<{if(s||!a)return r(s);if("object"!=typeof a)return r(new Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`));{try{if(i.filter){const t=e.y(i.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a.features=a.features.filter((e=>t.value.evaluate({zoom:0},e)))}i.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),i.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),i.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=i.cluster?new H((function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const r={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.y(s),l=e.y("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=a.value,n[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=r[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=n[t].evaluate(o,s)},t})(i)).load(a.features):i.dynamic?this._dynamicIndex:(function(e,t){return new Me(e,t)})(a,i.geojsonVtOptions)}catch(e){return r(e)}const s={};if(o){const e=t(n);e&&(s.resourceTiming={},s.resourceTiming[i.source]=JSON.parse(JSON.stringify(e)))}r(null,s)}}))}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)e.g(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class Pe{constructor(t,i){this.tileID=new e.aL(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=i}parse(t,i,r,n){this.status="parsing";const o=new e.aL(r.tileID.overscaledZ,r.tileID.wrap,r.tileID.canonical.z,r.tileID.canonical.x,r.tileID.canonical.y),s={},a=i.familiesBySource[r.source],l=new e.dN(o,r.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.e3(t).then((t=>{if(!t)return n(new Error("Could not parse tile"));const i=e.e4(t,1/e.b5(r.tileID.canonical)),c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,u=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),h=new e.X(this.zoom,{brightness:this.brightness});for(const t in a)for(const r of a[t]){const t=r[0];l.bucketLayerIDs.push(r.map((e=>e.id))),t.recalculate(h,[]);const n=new e.e5(i,o,c,u,this.brightness,l);c||(n.needsUpload=!0),s[t.fqid]=n,n.evaluate(t)}this.status="done",n(null,{buckets:s,featureIndex:l})})).catch((e=>n(new Error(e.message))))}}class ze{constructor(e,t,i,r,n,o){this.actor=e,this.layerIndex=t,this.brightness=o,this.loading={},this.loaded={}}loadTile(t,i){const r=t.uid,n=this.loading[r]=new Pe(t,this.brightness);e.e2(t.request,((e,o)=>{const s=!this.loading[r];return delete this.loading[r],s||e?(n.status="done",s||(this.loaded[r]=n),i(e)):o&&0!==o.byteLength?void n.parse(o,this.layerIndex,t,((e,t)=>{n.status="done",this.loaded=this.loaded||{},this.loaded[r]=n,e||!t?i(e):i(null,t)})):(n.status="done",this.loaded[r]=n,i())}))}reloadTile(e,t){const i=this.loaded,r=e.uid;if(i&&i[r]){const n=i[r];n.projection=e.projection,n.brightness=e.brightness;const o=(i,r)=>{n.reloadCallback&&(delete n.reloadCallback,this.loadTile(e,t)),t(i,r)};"parsing"===n.status?n.reloadCallback=o:"done"===n.status&&this.loadTile(e,t)}}abortTile(e,t){const i=e.uid;this.loading[i]&&delete this.loading[i],t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}}class De{constructor(t){this.self=t,this.actor=new e.e6(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.aJ({name:"mercator"}),this.workerSourceTypes={vector:c,geojson:Ce,"batched-model":ze},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.e7.isParsed())throw new Error("RTL text plugin already registered.");e.e7.applyArabicShaping=t.applyArabicShaping,e.e7.processBidirectionalText=t.processBidirectionalText,e.e7.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,{scope:i,isLoaded:r}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][i]=r,this.workerSources[t]&&this.workerSources[t][i])for(const n in this.workerSources[t][i]){const o=this.workerSources[t][i][n];for(const t in o){const i=o[t];i instanceof c&&(i.isSpriteLoaded=r,i.fire(new e.f("isSpriteLoaded")))}}}setImages(e,{scope:t,images:i},r){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=i,this.workerSources[e]&&this.workerSources[e][t]){for(const r in this.workerSources[e][t]){const n=this.workerSources[e][t][r];for(const e in n)n[e].availableImages=i}r()}else r()}setProjection(t,i){this.projections[t]=e.aJ(i)}setBrightness(e,t,i){this.brightness=t,i()}setLayers(e,t,i){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),i()}updateLayers(e,t,i){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),i()}loadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,i)}loadDEMTile(e,t,i){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,i)}decodeRasterArray(e,t,i){this.getRasterArrayWorkerSource().decodeRasterArray(t,i)}reloadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,i)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,i)}removeSource(e,t,i){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const r=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,r){try{e.e7.setState(i);const t=e.e7.getPluginURL();if(e.e7.isLoaded()&&!e.e7.isParsed()&&null!=t){this.self.importScripts(t);const i=e.e7.isParsed();r(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),i)}}catch(e){r(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let i=this.availableImages[e][t];return i||(i=[]),i}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let i=this.layerIndexes[e][t];return i||(i=this.layerIndexes[e][t]=new n,i.scope=t),i}getWorkerSource(e,t,i,r){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][r]||(this.workerSources[e][r]={}),this.workerSources[e][r][t]||(this.workerSources[e][r][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),this.workerSources[e][r][t][i]||(this.workerSources[e][r][t][i]=new this.workerSourceTypes[t]({send:(t,i,r,n,o,s)=>{this.actor.send(t,i,r,e,o,s)},scheduler:this.actor.scheduler},this.getLayerIndex(e,r),this.getAvailableImages(e,r),this.isSpriteLoaded[e][r],void 0,this.brightness)),this.workerSources[e][r][t][i]}getDEMWorkerSource(e,t,i){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][i]||(this.demWorkerSources[e][i]={}),this.demWorkerSources[e][i][t]||(this.demWorkerSources[e][i][t]=new u),this.demWorkerSources[e][i][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new h),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,i){e.e8(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new De(self)),De})),r(0,(function(e){function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let r=0;r{window.removeEventListener("click",m,!0)}),0)}function g(e,t){const i=e.getBoundingClientRect();return v(e,i,t)}function y(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;n=0?0:e.button}function v(t,i,r){const n=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((r.clientX-i.left)*n,(r.clientY-i.top)*n)}class b{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}const w={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class T{constructor(e,t,i,r,n,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i0&&e.vertexAttribDivisor(n,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class E{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class S extends E{getDefault(){return e.C.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class M extends E{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class I extends E{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class A extends E{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class C extends E{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class P extends E{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class z extends E{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class D extends E{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class L extends E{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class R extends E{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class k extends E{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class O extends E{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class B extends E{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class F extends E{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class N extends E{getDefault(){return e.C.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class V extends E{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class U extends E{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class j extends E{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class G extends E{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let q=class extends E{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class Z extends E{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class $ extends E{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class W extends E{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class H extends E{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class X extends E{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class Y extends E{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class K extends E{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class J extends E{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class Q extends E{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class ee extends E{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class te extends E{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class ie extends E{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class re extends ie{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class ne extends ie{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class oe extends ie{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class se extends ne{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class ae{constructor(e,t,i,r,n){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();r&&(this.colorAttachment=new re(e,o)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new ne(e,o):new oe(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}else{const t=this.depthAttachment.get();t&&e.deleteTexture(t)}e.deleteFramebuffer(this.framebuffer)}}class le{constructor(e,t){this.gl=e,this.clearColor=new S(this),this.clearDepth=new M(this),this.clearStencil=new I(this),this.colorMask=new A(this),this.depthMask=new C(this),this.stencilMask=new P(this),this.stencilFunc=new z(this),this.stencilOp=new D(this),this.stencilTest=new L(this),this.depthRange=new R(this),this.depthTest=new k(this),this.depthFunc=new O(this),this.blend=new B(this),this.blendFunc=new F(this),this.blendColor=new N(this),this.blendEquation=new V(this),this.cullFace=new U(this),this.cullFaceSide=new j(this),this.frontFace=new G(this),this.program=new q(this),this.activeTexture=new Z(this),this.viewport=new $(this),this.bindFramebuffer=new W(this),this.bindRenderbuffer=new H(this),this.bindTexture=new X(this),this.bindVertexBuffer=new Y(this),this.bindElementBuffer=new K(this),this.bindVertexArrayOES=new J(this),this.pixelStoreUnpack=new Q(this),this.pixelStoreUnpackPremultiplyAlpha=new ee(this),this.pixelStoreUnpackFlipY=new te(this),this.options=t?h({},t):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1]}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,i,r){return new e.I(this,t,i,r)}createVertexBuffer(e,t,i,r,n){return new T(this,e,t,i,r,n)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i,r){return new ae(this,e,t,i,r)}clear({color:e,depth:t,stencil:i,colorMask:r}){const n=this.gl;let o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(r||[!0,!0,!0,!0])),void 0!==t&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(o)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(i){t(i.blendFunction,e.a.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(i.blendFunction),this.blendColor.set(i.blendColor),i.blendEquation?this.blendEquation.set(i.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(i.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}class ce{constructor(e){this._gl=e.gl,this._query=this._gl.createQuery(),this._isFree=!0}begin(){this._gl.beginQuery(this._gl.ANY_SAMPLES_PASSED,this._query),this._isFree=!1}end(){this._gl.endQuery(this._gl.ANY_SAMPLES_PASSED)}isResultAvailable(){return this._gl.getQueryParameter(this._query,this._gl.QUERY_RESULT_AVAILABLE)}consumeResult(){const e=this._gl.getQueryParameter(this._query,this._gl.QUERY_RESULT);return this._isFree=!0,e}isFree(){return this._isFree}destroy(){this._gl.deleteQuery(this._query)}}class ue{constructor(e){this.useOcclusionQueries=!0,this.visualizeOcclusions="none",this.occlusionQueryFrameWindow=5,this.occluderSize=32,this.fadeSpeed=7,this.depthOffset=-1e-4,e.registerParameter(this,["Symbols"],"useOcclusionQueries"),e.registerParameter(this,["Symbols"],"visualizeOcclusions",{options:{none:"none",zPass:"zPass",zTest:"zTest"}}),e.registerParameter(this,["Symbols"],"occlusionQueryFrameWindow",{min:1,max:30,step:1}),e.registerParameter(this,["Symbols"],"occluderSize",{min:1,max:100,step:1}),e.registerParameter(this,["Symbols"],"fadeSpeed",{min:.1,max:50,step:.1}),e.registerParameter(this,["Symbols"],"depthOffset",{min:-.001,max:0,step:1e-4})}}class he{constructor(t,i,r,n){const o={width:r[0],height:r[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,o,s.RGBA,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,s.RGBA,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,n),this.lastInvalidatedAt=0}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const r=this.context.gl,n=i.width*i.height;this.particleTexture0=new e.T(this.context,i,r.RGBA,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,r.RGBA,{premultiply:!1,useMipmap:!1});const o=new e.S;o.reserve(n);for(let e=0;e{if(!i)return;const r=e.c(i),n=new e.M(t,void 0,void 0,r);return n.computeBoundsAndApplyParent(),n})).catch((r=>{if(r&&404===r.status)return null;this.fire(new e.d(new Error(`Could not load model ${t} from ${i}: ${r.message}`)))}))}load(t,i){this.models[i]||(this.models[i]={});const r=Object.keys(t);this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+r.length;const n=[];for(const e of r)n.push(this.loadModel(e,t[e]));Promise.allSettled(n).then((t=>{for(let e=0;e{this.fire(new e.d(new Error(`Could not load models: ${t.message}`)))}))}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t){return!!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.hasModel(e,i)&&this.models[i][e].numReferences++,this.load({[e]:this.requestManager.normalizeModelURL(t)},i)}addModels(e,t){this.models[t]||(this.models[t]={});const i={};for(const r in e)this.models[t][r]={},i[r]=this.requestManager.normalizeModelURL(e[r]);this.load(i,t)}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={});const i={};for(const r of e)this.hasModel(r,t)?this.models[t][r].numReferences++:i[r]=this.requestManager.normalizeModelURL(r);this.load(i,t)}removeModel(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){const i=this.models[t][e].model;delete this.models[t][e],i.destroy()}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context)}}function pe(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class fe extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0}createScope(t){this.images[t]={},this.loaded[t]=!1,this.updatedImages[t]={},this.patterns[t]={},this.callbackDispatchedThisFrame[t]={},this.atlasImage[t]=new e.i({width:1,height:1})}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return!1;return!0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[]}}hasImage(e,t){return!!this.getImage(e,t)}getImage(e,t){return this.images[t][e]}addImage(e,t,i){this._validate(e,i)&&(this.images[t][e]=i)}_validate(t,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.d(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.d(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new e.d(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]o)return[new e.V(i,r,`${r} is greater than the maximum value ${o}`)]}return[]}function ye(t){const i=t.valueSpec,r=e.u(t.value.type);let n,o,s,a={};const l="categorical"!==r&&void 0===t.value.property,c=!l,u="array"===e.n(t.value.stops)&&"array"===e.n(t.value.stops[0])&&"object"===e.n(t.value.stops[0][0]),h=me({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const n=t.value;return i=i.concat(_e({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:d})),"array"===e.n(n)&&0===n.length&&i.push(new e.V(t.key,n,"array must have at least one stop")),i},default:function(e){return Be({key:e.key,value:e.value,valueSpec:i,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===r&&l&&h.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||h.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!e.s(t.valueSpec)&&h.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(c&&!e.q(t.valueSpec)?h.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.r(t.valueSpec)&&h.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||h.push(new e.V(t.key,t.value,'"property" property is required')),h;function d(t){let r=[];const n=t.value,l=t.key;if("array"!==e.n(n))return[new e.V(l,n,`array expected, ${e.n(n)} found`)];if(2!==n.length)return[new e.V(l,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==e.n(n[0]))return[new e.V(l,n,`object expected, ${e.n(n[0])} found`)];if(void 0===n[0].zoom)return[new e.V(l,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new e.V(l,n,"object stop key must have value")];const i=e.u(n[0].zoom);if("number"!=typeof i)return[new e.V(l,n[0].zoom,"stop zoom values must be numbers")];if(s&&s>i)return[new e.V(l,n[0].zoom,"stop zoom values must appear in ascending order")];i!==s&&(s=i,o=void 0,a={}),r=r.concat(me({key:`${l}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:ge,value:p}}))}else r=r.concat(p({key:`${l}[0]`,value:n[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},n));return e.t(e.v(n[1]))?r.concat([new e.V(`${l}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(Be({key:`${l}[1]`,value:n[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const l=e.n(t.value),c=e.u(t.value),u=null!==t.value?t.value:s;if(n){if(l!==n)return[new e.V(t.key,u,`${l} stop domain type must match previous stop domain type ${n}`)]}else n=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof c&&"string"!=typeof c&&"boolean"!=typeof c)return[new e.V(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==r){let n=`number expected, ${l} found`;return e.q(i)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,u,n)]}return"categorical"!==r||"number"!==l||"number"==typeof c&&isFinite(c)&&Math.floor(c)===c?"categorical"!==r&&"number"===l&&"number"==typeof c&&"number"==typeof o&&void 0!==o&&cnew e.V(`${t.key}${i.key}`,t.value,i.message)));const r=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return[new e.V(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.z(r))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return ve(r,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.A(r,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.B(r))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ve(t,i){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const n=[];return t instanceof e.D&&r.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild((e=>{n.push(...ve(e,i))})),n)}function be(t){const i=t.key,r=t.value,n=t.valueSpec,o=[];return Array.isArray(n.values)?-1===n.values.indexOf(e.u(r))&&o.push(new e.V(i,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(e.u(r))&&o.push(new e.V(i,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),o}function we(t){return e.G(e.v(t.value))?xe(e.o({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):Te(t)}function Te(t){const i=t.value,r=t.key;if("array"!==e.n(i))return[new e.V(r,i,`array expected, ${e.n(i)} found`)];const n=t.styleSpec;let o,s=[];if(i.length<1)return[new e.V(r,i,"filter array must have at least 1 element")];switch(s=s.concat(be({key:`${r}[0]`,value:i[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.u(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.u(i[1])&&s.push(new e.V(r,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&s.push(new e.V(r,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(o=e.n(i[1]),"string"!==o&&s.push(new e.V(`${r}[1]`,i[1],`string expected, ${o} found`)));for(let a=2;a{t in r&&i.push(new e.V(n,r[t],`"${t}" is prohibited for ref layers`))})),o.layers.forEach((i=>{e.u(i.id)===l&&(t=i)})),t?t.ref?i.push(new e.V(n,r.ref,"ref cannot reference another ref layer")):a=e.u(t.type):"string"==typeof l&&i.push(new e.V(n,r.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(r.source){const t=o.sources&&o.sources[r.source],s=t&&e.u(t.type);t?"vector"===s&&"raster"===a?i.push(new e.V(n,r.source,`layer "${r.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new e.V(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new e.V(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"!==a||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||"geojson"===s&&t.lineMetrics?"raster-particle"===a&&"raster-array"!==s&&i.push(new e.V(n,r.source,`layer "${r.id}" requires a 'raster-array' source.`)):i.push(new e.V(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):i.push(new e.V(n,r.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(n,r,`layer "${r.id}" must specify a "source-layer"`)):i.push(new e.V(n,r.source,`source "${r.source}" not found`))}else i.push(new e.V(n,r,'missing required property "source"'));return i=i.concat(me({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Be({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:t=>we(e.o({layerType:a},t)),layout:t=>me({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>Me(e.o({layerType:a},t))}}),paint:t=>me({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>Se(e.o({layerType:a,layer:r},t))}})}})),i}function Ae(t){const i=t.value,r=t.key,n=e.n(i);return"string"!==n?[new e.V(r,i,`string expected, ${n} found`)]:[]}const Ce={promoteId:function({key:t,value:i}){if("string"===e.n(i))return Ae({key:t,value:i});{const e=[];for(const r in i)e.push(...Ae({key:`${t}.${r}`,value:i[r]}));return e}}};function Pe(t){const i=t.value,r=t.key,n=t.styleSpec,o=t.style;if(!i.type)return[new e.V(r,i,'"type" is required')];const s=e.u(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&(i.url||i.tiles||a.push(new e.m(r,i,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(me({key:r,value:i,valueSpec:n[`source_${s.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:Ce})),a;case"geojson":if(a=me({key:r,value:i,valueSpec:n.source_geojson,style:o,styleSpec:n,objectElementValidators:Ce}),i.cluster)for(const e in i.clusterProperties){const[t,n]=i.clusterProperties[e],o="string"==typeof t?[t,["accumulated"],["get",e]]:t;a.push(...xe({key:`${r}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...xe({key:`${r}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return me({key:r,value:i,valueSpec:n.source_video,style:o,styleSpec:n});case"image":return me({key:r,value:i,valueSpec:n.source_image,style:o,styleSpec:n});case"canvas":return[new e.V(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return be({key:`${r}.type`,value:i.type,valueSpec:{values:ze(n)},style:o,styleSpec:n})}}function ze(e){return e.source.reduce(((t,i)=>{const r=e[i];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values))),t}),[])}function De(t){const i=t.value,r=t.styleSpec,n=r.light,o=t.style;let s=[];const a=e.n(i);if(void 0===i)return s;if("object"!==a)return s=s.concat([new e.V("light",i,`object expected, ${a} found`)]),s;for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?Be({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?Be({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new e.V(t,i[t],`unknown property "${t}"`)])}return s}function Le(t){const i=t.value;let r=[];if(!i)return r;const n=e.n(i);if("object"!==n)return r=r.concat([new e.V("light-3d",i,`object expected, ${n} found`)]),r;const o=t.styleSpec,s=o["light-3d"],a=t.key,l=t.style,c=t.style.lights;for(const t of["type","id"])if(!(t in i))return r=r.concat([new e.V("light-3d",i,`missing property ${t} on light`)]),r;if(i.type&&c)for(let n=0;n[],array:_e,boolean:function(t){const i=t.value,r=t.key,n=e.n(i);return"boolean"!==n?[new e.V(r,i,`boolean expected, ${n} found`)]:[]},number:ge,color:function(t){const i=t.key,r=t.value,n=e.n(r);return"string"!==n?[new e.V(i,r,`color expected, ${n} found`)]:null===e.F(r)?[new e.V(i,r,`color expected, "${r}" found`)]:[]},enum:be,filter:we,function:ye,layer:Ie,object:me,source:Pe,model:e.K,light:De,"light-3d":Le,terrain:Re,fog:ke,string:Ae,formatted:function(e){return 0===Ae(e).length?[]:xe(e)},resolvedImage:function(e){return 0===Ae(e).length?[]:xe(e)},projection:function(t){const i=t.value,r=t.styleSpec,n=r.projection,o=t.style;let s=[];const a=e.n(i);if("object"===a)for(const e in i)s=s.concat(Be({key:e,value:i[e],valueSpec:n[e],style:o,styleSpec:r}));else"string"!==a&&(s=s.concat([new e.V("projection",i,`object or string expected, ${a} found`)]));return s},import:function(t){const{value:i,styleSpec:r}=t,{data:n}=i,o=a(i,c);Object.defineProperty(o,"__line__",{value:i.__line__,enumerable:!1});let s=me(e.o({},t,{value:o,valueSpec:r.import}));return""===e.u(o.id)&&s.push(new e.V(`${t.key}.id`,o,"import id can't be an empty string")),n&&(s=s.concat(Ne(n,r,{key:`${t.key}.data`}))),s}};function Be(t,i=!1){const r=t.value,n=t.valueSpec,o=t.styleSpec;if(n.expression&&e.H(e.u(r)))return ye(t);if(n.expression&&e.t(e.v(r)))return xe(t);if(n.type&&Oe[n.type]){const r=Oe[n.type](t);return!0===i&&r.length>0&&"array"===e.n(t.value)?xe(t):r}return me(e.o({},t,{valueSpec:n.type?o[n.type]:n}))}function Fe(t){const i=t.value,r=t.key,n=Ae(t);return n.length||(-1===i.indexOf("{fontstack}")&&n.push(new e.V(r,i,'"glyphs" url must include a "{fontstack}" token')),-1===i.indexOf("{range}")&&n.push(new e.V(r,i,'"glyphs" url must include a "{range}" token'))),n}function Ne(t,i=e.L,r={}){return Be({key:r.key||"",value:t,valueSpec:i.$root,styleSpec:i,style:t,objectElementValidators:{glyphs:Fe,"*":()=>[]}})}function Ve(t,i=e.L){return Ke(Ne(t,i))}const Ue=e=>Ke(Pe(e)),je=e=>Ke(De(e)),Ge=e=>Ke(Le(e)),qe=e=>Ke(Re(e)),Ze=e=>Ke(ke(e)),$e=e=>Ke(Ie(e)),We=e=>Ke(we(e)),He=e=>Ke(Se(e)),Xe=e=>Ke(Me(e)),Ye=t=>Ke(e.K(t));function Ke(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function Je(t,i){let r=!1;if(i&&i.length)for(const n of i)n instanceof e.m?e.w(n.message):(t.fire(new e.d(new Error(n.message))),r=!0);return r}const Qe=new e.N({anchor:new e.O(e.L.light.anchor),position:new e.Q(e.L.light.position),color:new e.O(e.L.light.color),intensity:new e.O(e.L.light.intensity)});class et extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.U(Qe),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(je,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,r){return(!r||!1!==r.validate)&&Je(this,t.call(Ve,e.W({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.L})))}}const tt=new e.N({source:new e.O(e.L.terrain.source),exaggeration:new e.O(e.L.terrain.exaggeration)});let it=class extends e.E{constructor(t,i,r,n){super(),this.scope=r,this._transitionable=new e.U(tt,r,n),this._transitionable.setTransitionOrValue(t,n),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.X(t)).get("exaggeration")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.Z}};const rt=45,nt=65,ot=.05;function st(t,i,r,n){const o=e.$(rt,nt,r),[s,a]=at(t,n);let l=1-Math.min(1,Math.exp((i-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function at(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}function lt(t,i,r,n,o){const s=e._.transformMat4([],[i,r,n],o.mercatorFogMatrix);return st(t,e._.length(s),o.pitch,o._fov)}function ct(t,i,r,n,o,s,a){const l=[[r,n,0],[o,n,0],[o,s,0],[r,s,0]];let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const t of l){const r=e._.transformMat4([],t,i),n=e._.length(r);c=Math.min(c,n),u=Math.max(u,n)}return[st(t,c,a.pitch,a._fov),st(t,u,a.pitch,a._fov)]}const ut=new e.N({range:new e.O(e.L.fog.range),color:new e.O(e.L.fog.color),"high-color":new e.O(e.L.fog["high-color"]),"space-color":new e.O(e.L.fog["space-color"]),"horizon-blend":new e.O(e.L.fog["horizon-blend"]),"star-intensity":new e.O(e.L.fog["star-intensity"]),"vertical-range":new e.O(e.L.fog["vertical-range"])});class ht extends e.E{constructor(t,i,r,n){super(),this._transitionable=new e.U(ut,r,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.a0(ut),this.scope=r}get state(){const t=this._transform,i="globe"===t.projection.name,r=e.a1(t.zoom),n=this.properties.get("range"),o=[.5,3];return{range:i?[e.a2(o[0],n[0],r),e.a2(o[1],n[1],r)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(Ze,t,r))return;const n=e.W({},t);for(const t of Object.keys(e.L.fog))void 0===n[t]&&(n[t]=e.L.fog[t].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,i)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.$(rt,nt,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?(function(t,i,r){const n=e.Y.fromLngLat(i),o=r.elevation?r.elevation.getAtPointOrZero(n):0;return lt(t,n.x,n.y,o,r)})(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return ct(this.state,i,0,0,e.a3,e.a3,this._transform)}getOpacityForBounds(e,t,i,r,n){return this._transform.projection.supportsFog?ct(this.state,e,t,i,r,n,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?at(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const i=[4,5,6,7];for(const r of i){const i=t.points[r];let n;if(i[2]>=0)n=i;else{const o=t.points[r-4];n=e.a4(o,i,o[2]/(o[2]-i[2]))}if(lt(this.state,n[0],n[1],0,this._transform)>=ot)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,r){return(!r||!1!==r.validate)&&Je(this,t.call(Ve,e.W({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.L})))}}class dt extends e.E{constructor(t,i,r,n){super(),this.scope=r,this._options=t,this.properties=new e.a0(i),this._transitionable=new e.U(i,r,new Map(n)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}const pt=new e.N({color:new e.O(e.L.properties_light_ambient.color),intensity:new e.O(e.L.properties_light_ambient.intensity)}),ft=new e.N({direction:new e.a5(e.L.properties_light_directional.direction),color:new e.O(e.L.properties_light_directional.color),intensity:new e.O(e.L.properties_light_directional.intensity),"cast-shadows":new e.O(e.L.properties_light_directional["cast-shadows"]),"shadow-intensity":new e.O(e.L.properties_light_directional["shadow-intensity"])});var mt="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",_t="\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,vec2 pos,vec2 lod_coord) {vec2 size=vec2(textureSize(image,0));vec2 dx=dFdx(lod_coord.xy*size);vec2 dy=dFdy(lod_coord.xy*size);float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",gt="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}",yt="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",xt="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",vt="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",bt="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",wt="#ifdef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",Tt="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec4 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=vec2(u_data_offset+dot(t.rg,u_data_scale.yx),-(u_data_offset+dot(t.ba,u_data_scale.yx)));velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}",Et="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",St="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const Mt=[];Dt(mt,Mt),Dt(gt,Mt),Dt(_t,Mt);const It={"_prelude_fog.vertex.glsl":vt,"_prelude_terrain.vertex.glsl":xt,"_prelude_shadow.vertex.glsl":Et,"_prelude_fog.fragment.glsl":bt,"_prelude_shadow.fragment.glsl":St,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":wt,"_prelude_raster_particle.glsl":Tt},At={};Lt("",xt),Lt(bt,vt),Lt(St,Et),Lt(wt,""),Lt(Tt,"");const Ct=Lt(_t,gt),Pt=mt;var zt={background:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:Lt("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Lt('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:Lt("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Lt("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in float a_size_scale;in vec2 a_padding;in float a_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+elevation(a_anchor_pos)),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:Lt("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Lt("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:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nuniform float u_emissive_strength;in float v_height;void main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,u_emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);cutoff=max(0.01,cutoff_opacity(u_cutoff_params,ground.z));if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff < 0.01 && centroid_pos.x !=0.0));gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillExtrusionDepth:Lt("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nout vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:Lt('#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:Lt("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(1.0,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:Lt("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:Lt('#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:Lt('#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 lowp 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) {float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/clamp(u_trim_fade_range[0],1e-4,1.0)));float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/clamp(u_trim_fade_range[1],1e-4,1.0)));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) { \nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*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)\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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\n#if defined(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);\n#else\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\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:Lt('#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;float x=mod(pattern_x,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {color=vec4(0,0,0,0);}}\n#endif\n#ifdef LINE_JOIN_NONE\nfloat pattern_len=pattern_size/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)\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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\n#if defined(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);\n#else\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\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:Lt('#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:Lt('#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:Lt("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin float a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(a_index,u_particle_texture_side_len),a_index/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-vec2(1.0),0.0,1.0);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:Lt("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:Lt('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp float speed=velocity==INVALID_VELOCITY ? 0.0 : length(velocity);highp float reset_rate_bump=speed*u_reset_rate;highp vec2 particle_pos_min=-u_particle_pos_offset;highp vec2 particle_pos_max=vec2(1.0)+u_particle_pos_offset;highp vec2 pos_drop_rate=vec2(1.0)-step(particle_pos_min,pos)+step(particle_pos_max,pos);highp float drop_rate=max(u_reset_rate+reset_rate_bump,length(pos_drop_rate));highp float drop=step(1.0-drop_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbolIcon:Lt('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\nout_color*=alpha;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;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\nfloat occlusion_fade=globe_occlusion_fade;\n#ifdef SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH\nocclusion_fade*=occlusionFade(projected_point);\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);v_fade_opacity*=occludedFadeMultiplier;\n#endif\n}'),symbolSDF:Lt('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\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_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;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 fontScale=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*fontScale+a_pxoffset);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=globe_occlusion_fade;\n#ifdef SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH\nocclusion_fade*=occlusionFade(projected_point);\n#endif\nfloat 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 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_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:Lt('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;in float v_draw_halo;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=globe_occlusion_fade;\n#ifdef SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH\nocclusion_fade*=occlusionFade(projected_point);\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 projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;\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_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:Lt('#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:Lt("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:Lt('#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}',yt),skyboxGradient:Lt('#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}',yt),skyboxCapture:Lt("\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:Lt('#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:Lt('#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:Lt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\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\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#else\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float 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(normalize(normal_3f));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:Lt("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:Lt("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:Lt("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 Dt(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e)}}function Lt(e,t){const i=/#include\s+"([^"]+)"/g,r=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let n=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);n&&(n=n.map((e=>{const t=e.split(" ");return t[t.length-1]})),n=[...new Set(n)]);const o={},s=[],a=[];if(e=e.replace(i,((e,t)=>(a.push(t),""))),(t=t.replace(i,((e,t)=>(s.push(t),"")))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let l=[...Mt];Dt(e,l),Dt(t,l);for(const e of[...s,...a])It[e]||console.error(`Undefined include: ${e}`),At[e]||(At[e]=[],Dt(It[e],At[e])),l=[...l,...At[e]];return{fragmentSource:e=e.replace(r,((e,t,i,r,n)=>(o[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${i} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(r,((e,t,i,r,n)=>{const s="float"===r?"vec2":r,a=n.match(/color/)?"color":s;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${i} ${r} a_${n};\n#endif\n`:o[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${i} ${r} a_${n};\n out ${i} ${r} ${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 ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===a?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${i} ${r} ${n} = a_${n};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:n,usedDefines:l,vertexIncludes:s,fragmentIncludes:a}}class Rt{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,r,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e{const o=r.paint.get("hillshade-shadow-color"),s=r.paint.get("hillshade-highlight-color"),a=r.paint.get("hillshade-accent-color"),l=r.paint.get("hillshade-emissive-strength");let c=e.ab(r.paint.get("hillshade-illumination-direction"));if("viewport"===r.paint.get("hillshade-illumination-anchor"))c-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),r=e.ac(i.x,i.y,i.z);c=e.ab(r[1])}const u=!t.options.moving;return{u_matrix:n||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),u),u_image:0,u_latrange:kt(0,i.tileID),u_light:[r.paint.get("hillshade-exaggeration"),c],u_shadow:o.toRenderColor(r.lut),u_highlight:s.toRenderColor(r.lut),u_emissive_strength:l,u_accent:a.toRenderColor(r.lut)}})(t,r,n,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:_}=t.getTileBoundsBuffers(r);d.draw(t,c.TRIANGLES,o,s,a,e.af.disabled,p,n.id,f,m,_)}function Bt(t,i,r){if(!i.needsDEMTextureUpload)return;const n=t.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(r.stride);const s=r.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.T(n,s,o.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}function Ft(t,i,r){const n=t.context,o=n.gl;if(!i.dem)return;const s=i.dem;if(n.activeTexture.set(o.TEXTURE1),Bt(t,i,s),!i.demTexture)return;i.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=s.dim;n.activeTexture.set(o.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(n,{width:a,height:a,data:null},o.RGBA);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=i.hillshadeFBO=n.createFramebuffer(a,a,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}n.bindFramebuffer.set(l.framebuffer),n.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,e.ae.disabled,e.ag.disabled,e.a.unblended,e.af.disabled,((t,i)=>{const r=i.stride,n=e.ad.create();return e.ad.ortho(n,0,e.a3,-e.a3,0,0,1),e.ad.translate(n,n,[0,-e.a3,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ}})(i.tileID,s),r.id,c,u,h),i.needsHillshadePrepare=!1}function Nt(t,i,r,n,o){const s=function(r,n){if(r)return o(r);if(n){if(t.url&&n.tiles&&t.tiles&&delete t.tiles,n.variants){if(!Array.isArray(n.variants))return o(new Error("variants must be an array"));for(const t of n.variants){if(null==t||"object"!=typeof t||t.constructor!==Object)return o(new Error("variant must be an object"));if(!Array.isArray(t.capabilities))return o(new Error("capabilities must be an array"));if(1===t.capabilities.length&&"meshopt"===t.capabilities[0]){n=e.W(n,t);break}}}const r=e.ah(e.W(n,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(r.vectorLayers=n.vector_layers,r.vectorLayerIds=r.vectorLayers.map((e=>e.id))),n.raster_layers&&(r.rasterLayers=n.raster_layers,r.rasterLayerIds=r.rasterLayers.map((e=>e.id))),r.tiles=i.canonicalizeTileset(r,t.url),o(null,r)}};return t.url?e.g(i.transformRequest(i.normalizeSourceURL(t.url,null,r,n),e.R.Source),s):e.e.frame((()=>s(null,t)))}class Vt{constructor(t,i,r){this.bounds=e.ai.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=r||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),r=Math.floor(e.aj(this.bounds.getWest())*i),n=Math.floor(e.ak(this.bounds.getNorth())*i),o=Math.ceil(e.aj(this.bounds.getEast())*i),s=Math.ceil(e.ak(this.bounds.getSouth())*i);return t.x>=r&&t.x=n&&t.y{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.d(i)):r&&(e.W(this,r),r.bounds&&(this.tileBounds=new Vt(r.bounds,this.minzoom,this.maxzoom)),e.an(r.tiles),this.fire(new e.f("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.f("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.al(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest()}serialize(){return e.W({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const r=e.e.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.h(this.map._requestManager.transformRequest(n,e.R.Tile),((r,n,o,s)=>(delete t.request,t.aborted?(t.state="unloaded",i(null)):r?(t.state="errored",i(r)):n?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(n,this.map.painter),t.state="loaded",e.am(this.dispatcher),void i(null)):i(null))))}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t()}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class jt extends e.E{constructor(t,i,r,n){if(super(),this.id=t,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.W(this,e.ah(i,["url","scheme","tileSize","promoteId"])),this._options=e.W({type:"vector"},i),this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n),this._tileWorkers={},this._deduped=new e.ao}load(t){this._loaded=!1,this.fire(new e.f("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map._worldview;this._tileJSONRequest=Nt(this._options,this.map._requestManager,i,r,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new e.d(n))):o&&(e.W(this,o),o.bounds&&(this.tileBounds=new Vt(o.bounds,this.minzoom,this.maxzoom)),e.an(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.f("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.f("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.al(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest()}serialize(){return e.W({},this._options)}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n=this.map._requestManager.transformRequest(r,e.R.Tile),o=this.map.style?this.map.style.getLut(this.scope):null,s={request:n,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,lut:o?{image:o.image.clone()}:null,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.e.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep};if(s.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",s,a.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",s,a.bind(this),void 0,!0);else{const i=e.ap.call({deduped:this._deduped},s,((e,i)=>{e||!i?a.call(this,e):(s.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",s,a.bind(this),void 0,!0))}),!0);t.request={cancel:i}}function a(r,n){return delete t.request,t.aborted?i(null):r&&404!==r.status?i(r):(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),e.am(this.dispatcher),i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e,t){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}const Gt=t=>({u_matrix:new e.a6(t),u_image0:new e.a7(t),u_skirt_height:new e.aa(t),u_ground_shadow_factor:new e.aq(t)}),qt=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),Zt=(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f});class $t{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=e.a2(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.a2(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=e.a2(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=e.a2(t.right,i.right,r)),this}getCenter(t,i){const r=e.at((this.left+t-this.right)/2,0,t),n=e.at((this.top+i-this.bottom)/2,0,i);return new e.P(r,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new $t(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Wt(t,i){const r=e.aw(t,3);e.ad.fromQuat(t,i),e.az(t,3,r)}function Ht(t,i){const r=e.av.identity([]);return e.av.rotateZ(r,r,-i),e.av.rotateX(r,r,-t),r}function Xt(t,i){const r=[t[0],t[1],0],n=[i[0],i[1],0];if(e._.length(r)>=1e-15){const t=e._.normalize([],r);e._.scale(n,t,e._.dot(n,t)),i[0]=n[0],i[1]=n[1]}const o=e._.cross([],i,t);if(e._.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Ht(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class Yt{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.Y?t:new e.Y(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.au(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const r=this.position,n=this._elevation?this._elevation.getAtPointOrZero(e.Y.fromLngLat(t)):0,o=e.Y.fromLngLat(t,n),s=[o.x-r.x,o.y-r.y,o.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Xt(s,i)}setPitchBearing(t,i){this.orientation=Ht(e.ab(t),e.ab(-i))}}class Kt{constructor(t,i){this._transform=e.ad.identity([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.Y(t[0],t[1],t[2])}get position(){const t=e.aw(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.az(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.av.identity([]),t&&Wt(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Ht(e,t),Wt(this._transform,this._orientation)}forward(){const t=e.aw(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.aw(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.aw(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const r=new Float64Array(16);return e.ad.invert(r,this.getWorldToCamera(t,i)),r}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,r){const n=this.position;e._.scale(n,n,-t);const o=new Float64Array(16);return e.ad.fromScaling(o,[r,r,r]),e.ad.translate(o,o,n),o[10]*=i,o}getWorldToCamera(t,i){const r=new Float64Array(16),n=new Float64Array(4),o=this.position;return e.av.conjugate(n,this._orientation),e._.scale(o,o,-t),e.ad.fromQuat(r,n),e.ad.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=i,r[9]*=i,r[10]*=i,r[11]*=i,r}getCameraToClipPerspective(t,i,r,n){const o=new Float64Array(16);return e.ad.perspective(o,t,i,r,n),o}getCameraToClipOrthographic(t,i,r,n,o,s){const a=new Float64Array(16);return e.ad.ortho(a,t,i,r,n,o,s),a}getDistanceToElevation(t,i=!1){const r=0===t?0:e.ax(t,i?e.ay(this.position[1]):this.position[1]),n=this.forward();return(r-this.position[2])/n[2]}clone(){return new Kt([...this.position],[...this.orientation])}}const Jt={unknown:0,flipRequired:1,flipNotRequired:2},Qt=Math.tan(85*Math.PI/180);function ei(t,i,r,n,o,s,a){const l=e.ad.create();if(r)if("globe"===s.name){const t=e.aB(o,i);e.ad.multiply(l,l,t)}else{const t=e.aC.invert([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],n||e.ad.rotateZ(l,l,o.angle)}else e.ad.multiply(l,o.labelPlaneMatrix,t);return l}function ti(e,t,i,r,n,o,s){const a=ei(e,t,i,r,n,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ii(t,i,r,n,o,s,a){if(r){if("globe"===s.name){const l=ei(t,i,r,n,o,s,a);return e.ad.invert(l,l),e.ad.multiply(l,t,l),l}{const i=e.ad.clone(t),r=e.ad.identity([]);return r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3],e.ad.multiply(i,i,r),n||e.ad.rotateZ(i,i,-o.angle),i}}return o.glCoordMatrix}function ri(t,i,r,n){const o=[t,i,r,1];r?e.aA.transformMat4(o,o,n):fi(o,o,n);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function ni(e,t){return Math.min(.5+e/t*.5,1.5)}function oi(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function si(t,i,r,n,o,s,a,l,c,u){const h=r.transform,d=n?t.textSizeData:t.iconSizeData,p=e.aD(d,r.transform.zoom),f="globe"===h.projection.name,m=[256/r.width*2+1,256/r.height*2+1],_=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=n?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,x=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,v=r.transform.width/r.transform.height;let b,w=!1;for(let n=0;nMath.abs(r)?{useVertical:!0}:t===e.aE.vertical?n>0?{needsFlipping:!0}:null:i!==Jt.unknown&&(function(e,t){return 0===e||Math.abs(t/e)>Qt})(r,n)?i===Jt.flipRequired?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function ci(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x){const v=i/24,b=t.lineOffsetX*v,w=t.lineOffsetY*v,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:S,segment:M,writingMode:I,flipState:A}=t,C=T+t.lineLength,P=t=>{if(h){const[i,r,n]=t.up,o=u.length;e.aG(h,o+0,i,r,n),e.aG(h,o+1,i,r,n),e.aG(h,o+2,i,r,n),e.aG(h,o+3,i,r,n)}const[i,r,n]=t.point;e.aH(u,i,r,n,t.angle)};if(S>1){const e=ai(v,l,b,w,r,d,p,t,c,s,f,_,!1,g,y,x);if(!e)return{notEnoughRoom:!0};if(n&&!r){let[i,r,n]=e.first.point,[o,s,l]=e.last.point;[i,r]=ri(i,r,n,a),[o,s]=ri(o,s,l,a);const c=li(I,A,(o-i)*m,s-r);if(t.flipState=c&&c.needsFlipping?Jt.flipRequired:Jt.flipNotRequired,c)return c}P(e.first);for(let e=E+1;e0?s:hi(p,n,i,1,o,void 0,g,y.canonical),l=li(I,A,(a[0]-i[0])*m,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?Jt.flipRequired:Jt.flipNotRequired,l)return l}const i=di(v*l.getoffsetX(E),b,w,r,d,p,M,T,C,c,s,f,_,!1,!1,g,y,x);if(!i)return{notEnoughRoom:!0};P(i)}return{}}function ui(e,t,i,r,n){const{x:o,y:s,z:a}=r.projectTilePoint(e.x,e.y,t);if(!n)return ri(o,s,a,i);const[l,c,u]=n(e);return ri(o+l,s+c,a+u,i)}function hi(t,i,r,n,o,s,a,l){const c=ui(t.sub(i)._unit()._add(t),l,o,a,s);return e._.sub(c,r,c),e._.normalize(c,c),e._.scaleAndAdd(c,r,c,n)}function di(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y){const x=n?t-i:t+i;let v=x>0?1:-1,b=0;n&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=l+a+(v>0?0:1)|0,T=o,E=o,S=0,M=0;const I=Math.abs(x),A=[],C=[];let P=s,z=P;const D=()=>hi(z,P,E,I-S+1,h,p,_,g.canonical);for(;S+M<=I;){if(w+=v,w=c)return null;if(E=T,z=P,A.push(E),f&&C.push(z),P=new e.P(u.getx(w),u.gety(w)),T=d[w],!T){const e=ui(P,g.canonical,h,_,p);T=e[3]>0?d[w]=e:D()}S+=M,M=e._.distance(E,T)}m&&p&&(d[w]&&(T=D(),M=e._.distance(E,T)),d[w]=T);const L=(I-S)/M,R=P.sub(z)._mult(L)._add(z),k=e._.sub([],T,E),O=e._.scaleAndAdd([],E,k,L);let B=[0,0,1],F=k[0],N=k[1];if(y&&(B=_.upVector(g.canonical,R.x,R.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],i=e._.cross([],B,t);e._.normalize(t,t),e._.normalize(i,i),F=e._.dot(k,t),N=e._.dot(k,i)}if(r){const t=e._.cross([],B,k);e._.normalize(t,t),e._.scaleAndAdd(O,O,t,r*v)}const V=b+Math.atan2(N,F);return A.push(O),f&&C.push(R),{point:O,angle:V,path:A,tilePath:C,up:B}}function pi(e,t){const i=t.length,r=i+4*e;t.resize(r),t.float32.fill(-1/0,4*i,4*r)}function fi(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const mi=(e,t,i)=>(1-i)*e+i*t,_i=e=>e*e*e*e*e;class gi{constructor(t,i,r,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=r??0,this._maxPitch=n??60,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.aI(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 $t,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Kt,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1}clone(){const e=new gi(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.ah(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=e.aJ(this.projectionOptions);const n=!t(r,this.getProjection());return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.aJ({name:"mercator"});const i=t!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.ax(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.au(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const i=-t*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=e.aC.create(),e.aC.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.at(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.ab(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e)}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s0,u=t.y+10,d=r.wrap-(c?0:1),p=r.wrap+(l?0:1),f=c?t.x-1:a-1,m=l?t.x+1:0;i[0]<0?(n.push(new e.aL(o,p,t.z,m,t.y)),i[1]<0&&u&&(n.push(new e.aL(o,s,t.z,t.x,t.y+1)),n.push(new e.aL(o,p,t.z,m,t.y+1))),i[1]>0&&h&&(n.push(new e.aL(o,s,t.z,t.x,t.y-1)),n.push(new e.aL(o,p,t.z,m,t.y-1)))):i[0]>0?(n.push(new e.aL(o,d,t.z,f,t.y)),i[1]<0&&u&&(n.push(new e.aL(o,s,t.z,t.x,t.y+1)),n.push(new e.aL(o,d,t.z,f,t.y+1))),i[1]>0&&h&&(n.push(new e.aL(o,s,t.z,t.x,t.y-1)),n.push(new e.aL(o,d,t.z,f,t.y-1)))):i[1]<0&&u?n.push(new e.aL(o,s,t.z,t.x,t.y+1)):h&&n.push(new e.aL(o,s,t.z,t.x,t.y-1))}if(n.length>1){n.sort(((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y));let e=0,t=0;for(;te.isChildOf(t)))||o.push(e);return n=o.filter((e=>!t.some((t=>!!(e.overscaledZt.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=25e-6,r=new e.Y(t.x+i,t.y,t.z),n=new e.Y(t.x,t.y+i,t.z),o=t.toLngLat(),s=r.toLngLat(),a=n.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*d)*T/i},S=t=>{const i=b,r=w;return{aabb:e.aQ(this,c,0,0,0,t,r,i,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:i,wrap:t,fullyVisible:!1}},M=[];let I=[];const A=i,C=t.reparseOverscaled?r:i,P=e=>e*e,z=P((_-this._centerAltitude)*m),D=e=>{if(!this._elevation||!e.tileID||!s)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=L(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},L=t=>{if(t.zoom=.9)return!0}else if(o&&(s=P(t.aabb.distanceZ(g)*m)),this.projection.isReprojectedInTileSpace&&r<=5){const i=Math.pow(2,t.zoom),r=E(new e.Y((t.x+.5)/i,(t.y+.5)/i));a=r>.85?1:r}const c=i*i+n*n+s,u=P((1<{if(t*P(.707)0;){const r=M.pop(),n=r.x,a=r.y;let l=r.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===r.y||r.y===(1<>1),d={aabb:s?r.aabb.quadrant(t):e.aQ(this,c,r.zoom+1,i,u,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:i,y:u,wrap:r.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};o&&!h&&(d.tileID=new e.aL(r.zoom+1===A?C:r.zoom+1,r.wrap,r.zoom+1,i,u),D(d)),M.push(d)}else{const o=r.zoom===A?C:r.zoom;if(t.minzoom&&t.minzoom>o)continue;if(!l){let t=y?r.aabb.intersectsPrecise(p):r.aabb.intersectsPreciseFlat(p);if(0===t&&d()){const i=new e.aO(r.zoom,n,a);t=e.aP(this,c,i,!0).intersectsPrecise(p)}if(0===t)continue}const s=u[0]-(.5+n+(r.wrap<{const o=[0,0,0,1],s=[e.a3,e.a3,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());e.aA.transformMat4(o,o,a),e.aA.transformMat4(s,s,a);const l=e.aA.min([],o,s),c=e.aA.max([],o,s),u=e.aR(l,c);if(0===u)return!0;let h=!1;const d=this._elevation;if(d&&u>i&&0!==r){const i=this.calculateProjMatrix(n.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(n.tileID)),o||(o={min:w,max:b});const s=e.b2(this.rotation),a=[s[0]*e.a3,s[1]*e.a3,o.max];e._.transformMat4(a,a,i),h=(1-a[1])*this.height*.5e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const i=e.at(t.lat,-e.aS,e.aS),r=this.projection.project(t.lng,i);return new e.P(r.x*this.worldSize,r.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.ax(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let r,n;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;r=(i.x-o.x)/e,n=(i.y-o.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(o);r=e.x-t.x,n=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.Y(s.x-r,s.y-n))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,i){const r=i?e.ax(i,t.lat):void 0,n=this.projection.project(t.lng,t.lat);return new e.Y(n.x,n.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const r=null!=i?i:this._centerAltitude,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.aA.transformMat4(n,n,this.pixelMatrixInverse),e.aA.transformMat4(o,o,this.pixelMatrixInverse);const s=o[3];e.aA.scale(n,n,1/n[3]),e.aA.scale(o,o,1/s);const a=n[2],l=o[2];return{p0:n,p1:o,t:a===l?0:(r-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.aA.transformMat4(i,i,this.pixelMatrixInverse),e.aA.transformMat4(r,r,this.pixelMatrixInverse),e.aA.scale(i,i,1/i[3]),e.aA.scale(r,r,1/r[3]),i[2]=e.ax(i[2],this._center.lat)*this.worldSize,r[2]=e.ax(r[2],this._center.lat)*this.worldSize,e.aA.scale(i,i,1/this.worldSize),e.aA.scale(r,r,1/this.worldSize),new e.aT([i[0],i[1],i[2]],e._.normalize([],e._.sub([],r,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:r,t:n}=t,o=e.ax(i[2],this._center.lat),s=e.ax(r[2],this._center.lat);return new e.Y(e.a2(i[0],r[0],n)/this.worldSize,e.a2(i[1],r[1],n)/this.worldSize,e.a2(o,s,n))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let i=this.projection.pointCoordinate3D(this,t.x,t.y);if(i)return new e.Y(i[0],i[1],i[2]);let r=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);const o=.02*n,s=t.clone();for(let t=0;t<10&&n-r>o;t++){s.y=e.a2(r,n,.66);const t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(n=s.y,i=t):r=s.y}return i?new e.Y(i[0],i[1],i[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.aU)return!this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const r=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.aA.transformMat4(n,n,this.pixelMatrix),n[3]>0?new e.P(n[0]/n[3],n[1]/n[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(n,t)),a=this.pointLocation3D(new e.P(n,r)),l=this.pointLocation3D(new e.P(i,r));let c=Math.min(o.lng,s.lng,a.lng,l.lng),u=Math.max(o.lng,s.lng,a.lng,l.lng),h=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,i,r,n,o)=>{const s=(t+r)/2,a=(i+n)/2,l=new e.P(s,a),{lng:_,lat:g}=this.pointLocation3D(l),y=Math.max(0,c-_,h-g,_-u,g-d);c=Math.min(c,_),u=Math.max(u,_),h=Math.min(h,g),d=Math.max(d,g),(op)&&(m(t,i,s,a,o+1),m(s,a,r,n,o+1))};if(m(i,t,n,t,1),m(n,t,n,r,1),m(n,r,i,r,1),m(i,r,i,t,1),"globe"===this.projection.name){const[t,i]=e.aV(this);t?(d=90,u=180,c=-180):i&&(h=-90,u=180,c=-180)}return new e.ai(new e.aI(c,h),new e.aI(u,d))}_getBoundsRectangular(t,i){const{top:r,left:n}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(n,r),l=new e.P(s,r),c=new e.P(s,o),u=new e.P(n,o);let h=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,i),f=this.pointCoordinate(u,i),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.Y((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new e.Y(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new e.Y((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new e.Y(-p.y/m(p,d)+p.x,0)),(new e.ai).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.aS,this.maxLat=e.aS,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngh&&(a=h-c),h-ut&&(s=t-l),t-e{for(let n=0;n<16;n++)e[n]=mi(t[n],i[n],r)})(a,a,l,_i(this.pitch>=15?1:this.pitch/15))}else a=l;const c=e.ad.mul([],l,s);let u=e.ad.mul([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.ad.identity([]);e.ad.translate(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.ad.multiply(i,i,e.aY(this)),e.ad.translate(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.ad.multiply(u,u,i),e.ad.multiply(c,c,i),this.inverseAdjustmentMatrix=e.aZ(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.ad.scale([],u,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=u,this.invProjMatrix=e.ad.invert(new Float64Array(16),this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.ad.mul([],i,s)}else this.expandedFarZProjMatrix=this.projMatrix;const h=e.ad.invert([],a);this.frustumCorners=e.a_.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.aM.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.ad.identity(d),e.ad.scale(d,d,[1,-1,1]),e.ad.rotateX(d,d,this._pitch),e.ad.rotateZ(d,d,this.angle);const p=e.ad.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.ad.clone(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-t.x/this.width,p[9]=2*(t.y+f)/this.height,this.skyboxMatrix=e.ad.multiply(d,p,d);const m=this.point,_=m.x,g=m.y,y=this.width%2/2,x=this.height%2/2,v=Math.cos(this.angle),b=Math.sin(this.angle),w=_-Math.round(_)+v*y+b*x,T=g-Math.round(g)+v*x+b*y,E=new Float64Array(u);if(e.ad.translate(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,u=e.ad.create(),e.ad.scale(u,u,[this.width/2,-this.height/2,1]),e.ad.translate(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=e.ad.create(),e.ad.scale(u,u,[1,-1,1]),e.ad.translate(u,u,[-1,-1,0]),e.ad.scale(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=e.ad.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=e.ad.invert(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.a$(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e._.transformMat4(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,r=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,i];e._.scale(o,o,n),e._.scale(r,r,-1),e._.multiply(r,r,o);const s=e.ad.create();e.ad.translate(s,s,r),e.ad.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,n)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],n=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(o=Math.min((i-r)/n,1)),this._camera.position=e._.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:n}=this._camera.getPitchBearing(),o=e.ax(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.ab(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(r),s),l=this._zoomFromMercatorZ(a);e._.scaleAndAdd(t,t,i,a),this._pitch=e.at(r,e.ab(this.minPitch),e.ab(this.maxPitch)),this.angle=e.au(n,-Math.PI,Math.PI),this._setZoom(e.at(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.Y(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,r=e.aU,n=0,o=1/0;for(;r-i>1e-6&&r>i;){const e=i+.5*(r-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(t*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.b0(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const r=e._.length(e._.sub([],this._camera.position,t)),n=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){const t=(function([t,i,r],n){const o=[t,i,r,1];e.aA.transformMat4(o,o,n);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o})([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,r=this.worldSize){const n=e.aX(t,i,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,r,n);let s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=mi(1,s,_i(this.pitch>=15?1:this.pitch/15))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.ad.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.aM.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const yi={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11},xi=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const r=t.transform,n=Math.max(Math.abs(r._zoom-(t.minCutoffZoom-1)),1),o=r.isLODDisabled(!1)?e.$(60,45,r.pitch):e.$(30,15,r.pitch),s=r._farZ-r._nearZ,a=i*r.height,l=((1-(c=o))*r.cameraToCenterDistance+c*(r._farZ+a))*n;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[r._nearZ,r._farZ,(l-r._nearZ)/s,(l-a-r._nearZ)/s]}}},vi={cascadeCount:2,shadowMapResolution:2048};class bi{constructor(e,t){this.aabb=e,this.lastCascade=t}}class wi{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new bi(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,r){const n=e.b6.fromPoints(t.points);let o=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!n.intersectsAabb(s.aabb))continue;s.aabb.min=n.closestPoint(s.aabb.min),s.aabb.max=n.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t1||s[1]<-1||s[1]>1){n=!1;break}}if(s.lastCascade=t,o=Math.max(o,t),n)break}}return o+1}}class Ti{constructor(t){this.painter=t,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new wi,this._depthMode=new e.ae(t.context.gl.LEQUAL,e.ae.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1,t.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},(()=>{this.painter.style.map.triggerRepaint()})),t.tp.registerParameter(vi,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),t.tp.registerParameter(vi,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),t.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,i){const r=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!i||!i.properties)return;const n=i.properties.get("shadow-intensity");if(!i.shadowsEnabled()||n<=0)return;if(this._shadowLayerCount=r.style.order.reduce(((e,i)=>{const n=r.style._mergedLayers[i];return e+(n.hasShadowPass()&&!n.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=r.context,s=vi.shadowMapResolution,a=vi.shadowMapResolution;if(0===this._cascades.length||vi.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;te.dem)).forEach((e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0])})),1e4!==i[0]&&(l=(i[1]-i[0])*e.exaggeration())}const c=1.5*t.cameraToCenterDistance,u=3*c,h=new Float64Array(16);for(let i=0;i=0)return{};const o=(function(t,i,r){const n=r/(1<0&&(e._.add(o[1],o[1],[n[0]*s,0,0]),e._.add(o[2],o[2],[n[0]*s,0,0])),n[1]<0?(e._.add(o[0],o[0],[0,n[1]*s,0]),e._.add(o[1],o[1],[0,n[1]*s,0])):n[1]>0&&(e._.add(o[2],o[2],[0,n[1]*s,0]),e._.add(o[3],o[3],[0,n[1]*s,0]));const a={};return a.vertices=o,a.planes=[Ei(o[1],o[0],o[4]),Ei(o[2],o[1],o[5]),Ei(o[3],o[2],o[6]),Ei(o[0],o[3],o[7])],a}addShadowReceiver(t,i,r){this._receivers.add(t,e.b6.fromTileIdAndHeight(t,i,r))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function Ei(t,i,r){const n=e._.sub([],r,i),o=e._.sub([],t,i),s=e._.cross([],n,o),a=e._.length(s);return 0===a?[0,0,1,0]:(e._.scale(s,s,1/a),[s[0],s[1],s[2],-e._.dot(s,i)])}function Si(t){const i=t.properties.get("direction"),r=e.ac(i.x,i.y,i.z);r[2]=e.at(r[2],0,75);const n=e.b7([r[0],r[1],r[2]]);return e._.fromValues(n.x,n.y,n.z)}function Mi(t,i,r){const n=i.properties.get("color"),o=i.properties.get("intensity"),s=i.properties.get("direction"),a=[s.x,s.y,s.z],l=r.properties.get("color"),c=r.properties.get("intensity"),u=Math.max(e._.dot([0,0,1],a),0),h=[0,0,0];e._.scale(h,l.toRenderColor(t.getLut(i.scope)).toArray01Linear().slice(0,3),c);const d=[0,0,0];return e._.scale(d,n.toRenderColor(t.getLut(r.scope)).toArray01Linear().slice(0,3),u*o),e.b8([h[0]>0?h[0]/(h[0]+d[0]):0,h[1]>0?h[1]/(h[1]+d[1]):0,h[2]>0?h[2]/(h[2]+d[2]):0])}function Ii(t,i,r,n,o,s){const a=t.zoom,l=t.scale,c=t.worldSize,u=1/c,h=t.aspect,d=Math.sqrt(1+h*h)*Math.tan(.5*t.fovX),p=d*d,f=n-r,m=n+r;let _,g;p>f/m?(_=n,g=n*d):(_=.5*m*(1+p),g=.5*Math.sqrt(f*f+2*(n*n+r*r)*p+m*m*p*p));const y=t.projection.pixelsPerMeter(t.center.lat,c),x=t._camera.getCameraToWorldMercator(),v=[0,0,-_*u];e._.transformMat4(v,v,x);let b=g*u;const w=t._edgeInsets;if(!(0===w.left&&0===w.top&&0===w.right&&0===w.bottom||w.left===w.right&&w.top===w.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?y:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,r,n);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.ad.mul(s,o,i);const u=new Float64Array(16);e.ad.invert(u,s);const h=e.aM.fromInvProjectionMatrix(u,c,a,!0);for(const i of h.points){const r=((T=i)[0]/=l,T[1]/=l,T[2]=e.ax(T[2],t._center.lat),T);b=Math.max(b,e._.len(e._.subtract([],v,r)))}}var T;b*=o/(o-1);const E=Math.acos(i[2]),S=Math.atan2(-i[0],-i[1]),M=new Kt;M.position=v,M.setPitchBearing(E,S);const I=M.getWorldToCamera(c,y),A=b*c,C=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*A),P=M.getCameraToClipOrthographic(-A,A,-A,A,C,(A+s*y)/i[2]),z=new Float64Array(16);e.ad.multiply(z,P,I);const D=e._.fromValues(Math.floor(1e6*v[0])/1e6*c,Math.floor(1e6*v[1])/1e6*c,0),L=.5*o,R=[0,0,0];e._.transformMat4(R,D,z),e._.scale(R,R,L);const k=[Math.floor(R[0]),Math.floor(R[1]),Math.floor(R[2])],O=[0,0,0];e._.sub(O,R,k),e._.scale(O,O,-1/L);const B=new Float64Array(16);return e.ad.identity(B),e.ad.translate(B,B,O),e.ad.multiply(z,B,z),[z,A]}function Ai(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Ci=new class{constructor(){this.operations={}}newMorphing(e,t,i,r,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i)}else this.operations[e]={startTime:r,phase:0,duration:n,from:t,to:i,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},Pi={0:null,1:"TERRAIN_VERTEX_MORPHING"};function zi(e,t,i){if(0===t)return 0;const r=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function Di(e,t){const i=1<({u_matrix:e});function Ri(t,i,r,n,o){if(o>0){const s=e.e.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=r.getSource(),u=n.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=h&&t.refreshedUponExpiration?1:e.at(h?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class ki extends Ut{constructor(t,i,r,n){super(t,i,r,n),this.type="raster-array",this.maxzoom=22,this._options=e.W({type:"raster-array"},i)}triggerRepaint(e){const t=this.map.painter._terrain,i=this.map.style.getSourceCache(this.id);t&&t.enabled&&i&&t._clearRenderCacheForTile(i.id,e.tileID),this.map.triggerRepaint()}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),n=this.map._requestManager.transformRequest(r,e.R.Tile);t.requestParams=n,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,r,n,o)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(e){if(20===e.code)return;return t.state="errored",i(e)}this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:o}),t.state="empty",i(null)}))}unloadTile(t,i){const r=t.texture;r&&r instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(r)):(t.destroy(),t.flushQueues(),t._isHeaderLoaded=!1,delete t._mrt,delete t.textureDescriptor),t.fbo&&(t.fbo.destroy(),delete t.fbo),delete t.request,delete t.requestParams,delete t.neighboringTiles,t.state="unloaded"}prepareTile(t,i,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(i,r,((i,r)=>{if(i)return t.state="errored",this.fire(new e.d(i)),void this.triggerRepaint(t);r&&(t.setTexture(r,this.map.painter),t.state="loaded",this.triggerRepaint(t))})))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find((({id:t})=>t===e)),i=t&&t.fields,r=i&&i.bands&&i.bands;return r?r[0]:0}getTextureDescriptor(t,i,r){if(!t)return;const n=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!n)return;let o=null;i instanceof e.bk?o=i.paint.get("raster-array-band"):i instanceof e.bl&&(o=i.paint.get("raster-particle-array-band"));const s=o||this.getInitialBand(n);if(null!=s)if(t.textureDescriptor){if(!t.updateNeeded(n,s)||r)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,n,s)}}const Oi={vector:jt,raster:Ut,"raster-dem":class extends Ut{constructor(t,i,r,n){super(t,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=e.W({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,r){e&&(t.state="errored",i(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null))}t.request=e.h(this.map._requestManager.transformRequest(r,e.R.Tile),function(r,o,s,a){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(r)t.state="errored",i(r);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:a});const i=ImageBitmap&&o instanceof ImageBitmap&&e.bi(),r=1-(o.width-e.bj(o.width))/2;r<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=i?o:e.e.getImageData(o,r),c={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:l,encoding:this.encoding,padding:r};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,n.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const i=t.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,o=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+r)%r,a=i.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.aL(t.overscaledZ,o,i.z,n,i.y).key]={backfilled:!1},l[new e.aL(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.aL(t.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new e.aL(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aL(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.d(i));else{const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&r&&r.resourceTiming&&r.resourceTiming[this.id]&&(i.resourceTiming=r.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.f("data",i)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,i){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const n=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:n?{image:n.image.clone()}:null,scope:this.scope,pixelRatio:e.e.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,partial:o};t.request=this.actor.send(r,s,((e,n)=>o&&!n?(t.state="loaded",i(null)):(delete t.request,t.destroy(),t.aborted?i(null):e?i(e):(t.loadVectorData(n,this.map.painter,"reloadTile"===r),i(null)))),void 0,"loadTile"===r)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.W({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.bm{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.bn(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.d(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.d(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.bm,model:class extends e.E{constructor(e,t,i,r){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t}load(){const t=[];for(const i in this._options.models){const r=this._options.models[i],n=e.l(this.map._requestManager.transformRequest(r.uri,e.R.Model).url).then((t=>{if(!t)return;const n=e.c(t),o=new e.M(i,r.position,r.orientation,n);o.computeBoundsAndApplyParent(),this.models.push(o)})).catch((t=>{this.fire(new e.d(new Error(`Could not load model ${i} from ${r.uri}: ${t.message}`)))}));t.push(n)}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.f("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((t=>{this.fire(new e.d(new Error(`Could not load models: ${t.message}`)))}))}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return{type:"model"}}},"batched-model":class extends e.E{constructor(e,t,i,r){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(r)}onAdd(e){this.map=e,this.load()}load(t){this._loaded=!1,this.fire(new e.f("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map._worldview;this._tileJSONRequest=Nt(this._options,this.map._requestManager,i,r,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new e.d(n))):o&&(e.W(this,o),o.bounds&&(this.tileBounds=new Vt(o.bounds,this.minzoom,this.maxzoom)),e.an(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.f("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.f("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(r,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=i;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",n,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);function o(e,r){return t.aborted?i(null):e&&404!==e.status?i(e):(r&&(r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(r),t.buckets=h(h({},t.buckets),r.buckets),r.featureIndex&&(t.latestFeatureIndex=r.featureIndex)),t.state="loaded",void i(null))}}serialize(){return e.W({},this._options)}},canvas:class extends e.bm{constructor(t,i,r,n){super(t,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.d(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.d(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.d(new e.V(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.d(new e.V(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.d(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.d(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(e){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.bo||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.E{constructor(t,i,r,n){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=i,this.setEventedParent(n),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.d(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.d(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Vt(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),e.W(this,e.ah(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.ah(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.f("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.f("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.f("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:r,z:n}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:r,z:n},{signal:o.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):(function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement})(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((i=>{20!==i.code&&(e.state="errored",t(i))})),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this._map.painter)}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this._map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:r}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:r})}i&&i()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){const t=e.al(this.id,this.scope);this._map.style.clearSource(t)}_update(){this.fire(new e.f("data",{dataType:"source",sourceDataType:"content"}))}}},Bi=function(t,i,r,n){const o=new Oi[i.type](t,i,r,n);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.bp(["load","abort","unload","serialize","prepare"],o),o};class Fi extends e.bv{constructor(t){const i={type:"raster-dem",maxzoom:t.transform.maxZoom},r=new e.bw(e.bx(),null),n=Bi("mock-dem",i,r,t.style);super("mock-dem",n,!1),n.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Ni extends e.bv{constructor(t){const i=Bi("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.bw(e.bx(),null),t.style);super("proxy",i,!1),i.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,i,r){if(t.freezeTileCoverage)return;this.transform=t;const n=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((i,r)=>{if(i[r.key]="",!this._tiles[r.key]){const i=new e.by(r,this._source.tileSize*r.overscaleFactor(),t.tileZoom);i.state="loaded",this._tiles[r.key]=i}return i}),{});for(const e in this._tiles)e in n||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Vi extends e.aL{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i}}class Ui extends e.bq{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},(()=>{this._style.map.triggerRepaint()})),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},(()=>{this._style.map.triggerRepaint()})),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",(()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()})),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,n,o]=(function(t){const i=new e.bt,r=new e.bu,n=131;i.reserve(17161),r.reserve(33800);const o=e.a3/128,s=e.a3+o/2,a=s+o;for(let t=-o;ts||t<0||t>s?24575:0,o=e.at(Math.round(r),0,e.a3),a=e.at(Math.round(t),0,e.a3);i.emplaceBack(o+n,a)}const l=(e,t)=>{const i=t*n+e;r.emplaceBack(i+1,i,i+n),r.emplaceBack(i+n,i+n+1,i+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)})),[i,r,32768]})(),s=t.context;this.gridBuffer=s.createVertexBuffer(r,e.br.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=e.b.simpleSegment(0,0,r.length,n.length),this.gridNoSkirtSegments=e.b.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ni(i.map),this.orthoMatrix=e.ad.create(),e.ad.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.a3,0,e.a3,0,1);const a=s.gl;this._overlapStencilMode=new e.ag({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Fi(i.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache()}))}update(t,i,r){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const n=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.e.now();const a=t.terrain&&t.terrain.scope,l=n.get("source"),c=o?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._exaggeration=s?this.calculateExaggeration(i):n.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{this.sourceCache.used&&e.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),i.updateElevation(!0,r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom}else this._disable()}calculateExaggeration(t){const i=this._previousCameraAltitude,r=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=r;const n=null!=i?r-i:Number.MAX_VALUE;if(Math.abs(n)<2)return this._exaggeration;const o=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(o);let a=o-this._previousZoom;const l=this._previousUpdateTimestamp;let c=o;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(o-c)>.5&&(a=.5*(o-c+a)),a*n<0&&(c+=a)),this._evaluationZoom=c;const u=s.getExaggeration(c),h=u===s.getExaggeration(Math.max(0,c-.1));if(h&&Math.abs(u-this._exaggeration)<.01)return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||u<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.a2(this._exaggeration,u,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.Y.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=i.getIds().map((e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t}));!(function(t,i){const r=i.transform.pointCoordinate(i.transform.getCameraPoint()),n=new e.P(r.x,r.y);t.sort(((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const r=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const r=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=n.map((e=>new Vi(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Bt(this.painter,r,n))}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=r||"";return i[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,i=t.gl;if(!this._emptyDepthBufferTexture){const r=new e.i({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.T(t,r,i.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const r=i.dem.tree.minimums[0];return r>0&&e++,t+r}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const r=this._getLoadedAreaMinimum(),[n,o]=(()=>{const t=new e.bz({width:1,height:1},new Float32Array([r]));return[i.R32F,t]})();this._emptyDEMTextureDirty=!1;let s=this._emptyDEMTexture;return s?s.update(o,{premultiply:!1}):s=this._emptyDEMTexture=new e.T(t,o,n,{premultiply:!1}),s}setupElevationDraw(t,i,r){const n=this.painter.context,o=n.gl,s={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,i=r.morphing.dstDemTile;c=r.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST;let h=null;var d;if(this.enabled?l&&a?(h=a.demTexture,n.activeTexture.set(o.TEXTURE4),l.demTexture.bind(u(l),o.CLAMP_TO_EDGE),s.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],h=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture):h=this.emptyDEMTexture,n.activeTexture.set(o.TEXTURE2),h&&(s.u_dem_size=1===(d=h).size[0]?1:d.size[0]-2,h.bind(u(a),o.CLAMP_TO_EDGE)),n.activeTexture.set(o.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&a){const t=(1<{if(c===i)return;const r=[Pi[i],"PROJECTION_GLOBE_VIEW"];h&&r.push("CUSTOM_ANTIALIASING");const n=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:r,overrideFog:n}),c=i},p=t.colorModeForRenderPass(),f=new e.ae(a.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D);Ci.update(o);const m=e.bb(u),_=[e.aj(u.center.lng),e.ak(u.center.lat)],g=t.globeSharedBuffers,y=[u.width*e.e.devicePixelRatio,u.height*e.e.devicePixelRatio],x=Float32Array.from(u.globeMatrix),v={useDenormalizedUpVectorScale:!0};{const u=t.transform,h=zi(u.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=a.TRIANGLES;for(const c of n){const n=r.getTile(c),w=e.ag.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];Ai(T,E)&&Ci.newMorphing(c.key,T,E,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=Ci.getMorphValuesForProxy(c.key),M=S?1:0;S&&e.o(v,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.b9(S.phase)}});const I=e.bc(c.canonical),A=e.bd(I.getCenter().lat),C=e.be(c.canonical,I,A,u.worldSize/u._pixelsPerMercatorPixel),P=e.bf(e.bg(c.canonical)),z=Zt(u.expandedFarZProjMatrix,x,m,P,e.a1(u.zoom),_,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,y,h,u._farZ,C);if(d(c,M),l&&(i.setupElevationDraw(n,l,v),t.uploadCommonUniforms(s,l,c.toUnwrapped()),g)){const[i,r,n]=g.getGridBuffers(A,0!==h);l.draw(t,b,f,w,p,e.af.backCCW,z,"globe_raster",i,r,n)}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of n){const{x:n,y:c,z:h}=o.canonical,d=0===c,m=c===(1<i.draw(t,a.TRIANGLES,f,e.ag.disabled,p,e.af.disabled,Zt(u.expandedFarZProjMatrix,g,g,E,0,_,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,y,0,u._farZ),"globe_pole_raster",r,w,T);i.setupElevationDraw(c,l,v),t.uploadCommonUniforms(s,l,o.toUnwrapped()),d&&t.renderDefaultNorthPole&&S(l,x),m&&t.renderDefaultSouthPole&&(g=e.ad.scale(e.ad.create(),g,[1,-1,1]),S(l,b))}}}})(t,i,r,n,o);else{const s=t.context,a=s.gl;let l,c;const u=t.shadowRenderer,h=xi(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(Pi[e]),h.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e},p=t.colorModeForRenderPass(),f=new e.ae(a.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D);Ci.update(o);const m=t.transform,_=zi(m.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(u){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(g=Mi(t.style,e,i))}{c=-1;const y=a.TRIANGLES,[x,v]=[i.gridIndexBuffer,i.gridSegments];for(const c of n){const n=r.getTile(c),b=e.ag.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];Ai(w,T)&&Ci.newMorphing(c.key,w,T,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=Ci.getMorphValuesForProxy(c.key),S=E?1:0;let M;E&&(M={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.b9(E.phase)}});const I=qt(c.projMatrix,Di(c.canonical,m.renderWorldCopies)?_/10:_,g);if(d(S),!l)continue;i.setupElevationDraw(n,l,M);const A=c.toUnwrapped();u&&u.setupShadows(A,l),t.uploadCommonUniforms(s,l,A,null,h),l.draw(t,y,f,b,p,e.af.backCCW,I,"terrain_raster",i.gridBuffer,x,v)}}}})(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,r=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];let c=0;for(const u of o){const o=n.getTileByID(u.proxyTileKey),h=n.proxyCachedFBO[u.key]?n.proxyCachedFBO[u.key][t]:void 0,d=void 0!==h?n.renderCache[h]:this.pool[c++],p=void 0!==h;if(o.texture=d.tex,p&&!d.dirty){l.push(o.tileID);continue}let f;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.C.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const n=i.style.getLayerSourceCache(t),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),i.renderLayer(i,n,t,s)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const n=i.style.getLayerSourceCache(t),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),i.renderLayer(i,n,t,s)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,r=t;for(let n=0;ni}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((e=>e.dem)).map((r=>{const n=r.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,i=t.gl,r=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const n=new e.T(t,{width:r[0],height:r[1],data:null},i.RGBA);n.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!0,null);return o.colorAttachment.set(n.texture),o.depthAttachment=new se(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof jt){t=!0;break}if(!t)return;const i={};for(let t=0;te>t.end))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=r}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key)))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.ag.disabled}_renderTileClippingMasks(t,i){const r=this.painter,n=this.painter.context,o=n.gl;r._tileClippingMaskIDs={},n.setColorMode(e.a.disabled),n.setDepthMode(e.ae.disabled);const s=r.getOrCreateProgram("clippingMask");for(const n of t){const t=r._tileClippingMaskIDs[n.key]=--i;s.draw(r,o.TRIANGLES,e.ae.disabled,new e.ag({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.a.disabled,e.af.disabled,Li(n.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const r=[t.x,t.y,1,1];e.aA.transformMat4(r,r,i.pixelMatrixInverse),e.aA.scale(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;const n=i._camera.position,o=e.ax(1,i.center.lat),s=[n[0],n[1],n[2]/o,0],a=e._.subtract([],r.slice(0,3),s);e._.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e._.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const t=this.painter,i=t.context,r=this.proxySourceCache,n=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===n&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=i.gl,r=i.createFramebuffer(n,o,!0,"renderbuffer");i.activeTexture.set(t.TEXTURE0);const s=new e.T(i,{width:n,height:o,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),r.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,n,o);r.depthAttachment.set(a),this._depthFBO=r,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,n,o]),(function(t,i,r,n){if("globe"===t.transform.projection.name)return;const o=t.context,s=o.gl;o.clear({depth:1});const a=t.getOrCreateProgram("terrainDepth"),l=new e.ae(s.LESS,e.ae.ReadWrite,t.depthRangeFor3D);for(const o of n){const n=r.getTile(o),c=qt(o.projMatrix,0,[0,0,0]);i.setupElevationDraw(n,a),a.draw(t,s.TRIANGLES,l,e.ag.disabled,e.a.unblended,e.af.backCCW,c,"terrain_depth",i.gridBuffer,i.gridIndexBuffer,i.gridNoSkirtSegments)}})(t,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,i,r){if(t.getSource()instanceof e.bm)return this._setupProxiedCoordsForImageSource(t,i,r);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ))}_setupProxiedCoordsForImageSource(t,i,r){if(!t.getSource().loaded())return;const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e)),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,i)=>{const r=t.wrap+t.canonical.x/(1<s+c.max.x||n+oa+c.max.y};for(let e=0;ee.key===i.tileID.key));if(e)return e}if(i.tileID.key!==t.key){const r=t.canonical.z-i.tileID.canonical.z;let o,s,a;n=e.ad.create();const l=i.tileID.wrap-t.wrap<0?(o=e.a3>>r,s=o*((i.tileID.canonical.x<=n){const r=t.canonical.z-n;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.aL(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(a=n,s=new e.aL(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r))}s.key!==t.key&&(c.push(s.key),r=i.getTile(s))}const u=e=>{c.forEach((t=>{n[t]=e})),c.length=0};for(a-=1;a>=l&&(!r||!r.hasData());a--){r&&u(r.tileID.key);const e=s.calculateScaledKey(a);if(r=i.getTileByID(e),r&&r.hasData())break;const t=n[e];if(null===t)break;void 0===t?c.push(e):r=i.getTileByID(t)}return u(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0}}function ji(t,i,r){const n=(function(t,i,r){const n=e._.dot(i,t),o=e._.dot(r,[.2126,.7152,.0722]),s=(e,t,i)=>(1-i)*e+i*t,a=s(1-.3*Math.min(o,1),1,Math.min(n+1,1));return s(.92,1,Math.asin(e.at(i[2],-1,1))/Math.PI+.5)*a})(t,[0,0,1],i),o=[0,0,0];e._.scale(o,r.slice(0,3),n);const s=[0,0,0];e._.scale(s,i.slice(0,3),t[2]);const a=[0,0,0];return e._.add(a,o,s),e.b8(a)}const Gi=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],qi=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class Zi{static cacheKey(e,t,i,r){let n=`${t}${r?r.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(t,i,r,n,o,s){const a=t.gl;this.program=a.createProgram(),this.configuration=n,this.name=i,this.fixedDefines=[...s];const l=n?n.getBinderAttributes():[],c=(r.staticAttributes||[]).concat(l);let u=n?n.defines():[];u=u.concat(s.map((e=>`#define ${e}`)));const h="#version 300 es\n";let d=h+u.concat("precision mediump float;",Pt,Ct.fragmentSource).join("\n");for(const e of r.fragmentIncludes)d+=`\n${It[e]}`;d+=`\n${r.fragmentSource}`;let p=h+u.concat("precision highp float;",Pt,Ct.vertexSource).join("\n");for(const e of r.vertexIncludes)p+=`\n${It[e]}`;p+=`\n${r.vertexSource}`;const f=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(f,d),a.compileShader(f),a.attachShader(this.program,f);const m=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(m,p),a.compileShader(m),a.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.a7(t),u_dem_prev:new e.a7(t),u_dem_tl:new e.a8(t),u_dem_scale:new e.aa(t),u_dem_tl_prev:new e.a8(t),u_dem_scale_prev:new e.aa(t),u_dem_size:new e.aa(t),u_dem_lerp:new e.aa(t),u_exaggeration:new e.aa(t),u_depth:new e.a7(t),u_depth_size_inv:new e.a8(t),u_meter_to_dem:new e.aa(t),u_label_plane_matrix_inv:new e.a6(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.aq(t),u_tile_tr_up:new e.aq(t),u_tile_br_up:new e.aq(t),u_tile_bl_up:new e.aq(t),u_tile_up_scale:new e.aa(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.a6(t),u_fog_range:new e.a8(t),u_fog_color:new e.as(t),u_fog_horizon_blend:new e.aa(t),u_fog_vertical_limit:new e.a8(t),u_fog_temporal_offset:new e.aa(t),u_frustum_tl:new e.aq(t),u_frustum_tr:new e.aq(t),u_frustum_br:new e.aq(t),u_frustum_bl:new e.aq(t),u_globe_pos:new e.aq(t),u_globe_radius:new e.aa(t),u_globe_transition:new e.aa(t),u_is_globe:new e.a7(t),u_viewport:new e.a8(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.as(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.aq(t),u_lighting_directional_dir:new e.aq(t),u_lighting_directional_color:new e.aq(t),u_ground_radiance:new e.aq(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.a6(t),u_light_matrix_1:new e.a6(t),u_fade_range:new e.a8(t),u_shadow_normal_offset:new e.aq(t),u_shadow_intensity:new e.aa(t),u_shadow_texel_size:new e.aa(t),u_shadow_map_resolution:new e.aa(t),u_shadow_direction:new e.aq(t),u_shadow_bias:new e.aq(t),u_shadowmap_0:new e.a7(t),u_shadowmap_1:new e.a7(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}_drawDebugWireframe(t,i,r,n,o,s,a,l,c,u){const h=t.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const d=t.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||t._terrain&&t._terrain.renderingToTexture||!Gi.includes(this.name))||!(!h.layers3D||!qi.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!f)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const _=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(_.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const r in t[e])i[e][r]&&i[e][r].set(i.program,r,t[e][r].current)};c&&c.setUniforms(_.program,d,_.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,_),g("terrainUniforms",this,_),g("globeUniforms",this,_),g("fogUniforms",this,_),g("lightsUniforms",this,_),g("shadowUniforms",this,_),f.bind(),d.setColorMode(new e.a([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.C.transparent,[!0,!0,!0,!1])),d.setDepthMode(new e.ae(i.func===p.LESS?p.LEQUAL:i.func,e.ae.ReadOnly,i.range)),d.setStencilMode(e.ag.disabled);const y=3*s.primitiveLength*2,x=3*s.primitiveOffset*2*2;u&&u>1?p.drawElementsInstanced(p.LINES,y,p.UNSIGNED_SHORT,x,u):p.drawElements(p.LINES,y,p.UNSIGNED_SHORT,x),o.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(r),d.setColorMode(n)}draw(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){const _=e.context,g=_.gl;if(this.failedToCreate)return;_.program.set(this.program),_.setDepthMode(i),_.setStencilMode(r),_.setColorMode(n),_.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,_,this.binderUniforms,h,{zoom:d});const y={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],x=m&&m>0?1:void 0;for(const o of u.get()){const s=o.vaos||(o.vaos={});(s[a]||(s[a]=new Rt)).bind(_,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],x),m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2,m):c?g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2):g.drawArrays(t,o.vertexOffset,o.vertexLength),t===g.TRIANGLES&&c&&this._drawDebugWireframe(e,i,r,n,c,o,h,d,p,m)}}}function $i(t,i){const r=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,o=n*(i.tileID.canonical.x+i.tileID.wrap*r),s=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.bB(i,1,t.transform.tileZoom),u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}const Wi=e.ad.create(),Hi=(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_)=>{const g=i.style.light,y=g.properties.get("position"),x=[y.x,y.y,y.z],v=e.bC.create();"viewport"===g.properties.get("anchor")&&(e.bC.fromRotation(v,-i.transform.angle),e._.transformMat3(x,x,v));const b=g.properties.get("color"),w=i.transform,T={u_matrix:t,u_lightpos:x,u_lightintensity:g.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+r,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Wi,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:s,u_flood_light_color:d,u_vertical_scale:p,u_flood_light_intensity:f,u_ground_shadow_factor:m,u_emissive_strength:_};return"globe"===w.projection.name&&(T.u_tile_id=[a.canonical.x,a.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_vertical_scale:i}),Yi=(t,i,r,n,o,s,a,l,c,u,h,d,p,f)=>{const m=Hi(t,i,r,n,o,s,a,c,u,h,d,p,f,1,[0,0,0],0),_={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return e.W(m,$i(i,l),_)},Ki=(e,t)=>({u_matrix:e,u_emissive_strength:t}),Ji=(t,i,r,n)=>e.W(Ki(t,i),$i(r,n)),Qi=(e,t,i)=>({u_matrix:e,u_world:i,u_emissive_strength:t}),er=(t,i,r,n,o)=>e.W(Ji(t,i,r,n),{u_world:o}),tr=(t,i,r,n)=>{const o=e.a3/r.tileSize;return{u_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(n),u_extrude_scale:[i.pixelsToGLUnits[0]/o,i.pixelsToGLUnits[1]/o]}},ir=(e,t,i=1)=>({u_matrix:e,u_color:t.toRenderColor(null),u_overlay:0,u_overlay_scale:i}),rr=e.ad.create(),nr=(t,i,r,n,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.bD(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.bB(r,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:rr,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=n,h.u_merc_center=o,h.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:r,u_merc_matrix:n,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:u,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:e.bE(d.paint.get("raster-saturation")),u_contrast_factor:e.bF(d.paint.get("raster-contrast")),u_spin_weights:lr(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:or(e.bG,_,y),u_colorization_offset:sr(e.bG,g,y),u_color_ramp:m,u_texture_offset:[v/(x+2*v),x/(x+2*v)],u_texture_res:[x+2*v,x+2*v],u_emissive_strength:b});function lr(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const cr=.15,ur=(e,t,i,r,n,o,s,a,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:r,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),hr=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:r,u_color_ramp:o,u_velocity_res:n,u_max_speed:s,u_uv_offset:a,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[cr,cr]}),dr=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:r,u_max_speed:n,u_speed_factor:o,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[cr,cr]}),pr=e.ad.create(),fr=(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y)=>{const x=o.transform,v={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:x.getCameraToCenterDistance(_),u_rotate_symbol:+r,u_aspect_ratio:x.width/x.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+n,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:pr,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:pr,u_up_vector:[0,-1,0],u_color_adj_mat:g,u_icon_transition:y||0};return"globe"===_.name&&(v.u_tile_id=[h.canonical.x,h.canonical.y,1<e.W(fr(t,i,r,n,o,s,a,l,c,u,d,p,f,m,_,g),{u_gamma_scale:n?o.transform.getCameraToCenterDistance(g)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.e.devicePixelRatio,u_is_halo:+h,undefined:void 0}),_r=(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_)=>e.W(mr(t,i,r,n,o,s,a,l,!0,c,!0,h,d,p,f,m,_),{u_texsize_icon:u,u_texture_icon:1}),gr=(e,t,i,r)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:r}),yr=(t,i,r,n,o,s,a,l)=>e.W((function(t,i,r,n,o){const{width:s,height:a}=n.imageManager.getPixelSize(i),l=Math.pow(2,o.tileID.overscaledZ),c=o.tileSize*Math.pow(2,n.transform.tileZoom)/l,u=c*(o.tileID.canonical.x+o.tileID.wrap*l),h=c*o.tileID.canonical.y;return{u_image:0,u_pattern_tl:r.tl,u_pattern_br:r.br,u_texsize:[s,a],u_pattern_size:r.displaySize,u_tile_units_to_pixels:1/e.bB(o,1,n.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}})(0,s,a,n,l),{u_matrix:t,u_emissive_strength:i,u_opacity:r}),xr=new Float32Array(e.ad.identity([])),vr=(t,i,r,n,o,s,a,l,c,u,h,d,p,f=[0,0,0],m)=>{const _=o.style.light,g=_.properties.get("position"),y=[-g.x,-g.y,g.z],x=e.bC.create();"viewport"===_.properties.get("anchor")&&(e.bC.fromRotation(x,-o.transform.angle),e._.transformMat3(y,y,x));const v="MASK"===h.alphaMode,b=_.properties.get("color").toRenderColor(null),w=p.paint.get("model-ambient-occlusion-intensity"),T=p.paint.get("model-color").constantOr(e.C.white).toRenderColor(null),E=p.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:r,u_node_matrix:n||xr,u_lightpos:y,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+v,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:[a.r,a.g,a.b,a.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:c,u_roughnessFactor:u,u_baseColorTexture:yi.BaseColor,u_metallicRoughnessTexture:yi.MetallicRoughness,u_normalTexture:yi.Normal,u_occlusionTexture:yi.Occlusion,u_emissionTexture:yi.Emission,u_lutTexture:yi.LUT,u_color_mix:[T.r,T.g,T.b,E],u_aoIntensity:w,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},br=(e,t=xr,i=xr)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),wr=(e,t,i,r,n)=>({u_matrix:Float32Array.from(e),u_anchorPos:t,u_screenSizePx:i,u_occluderSizePx:r,u_color:n}),Tr={fillExtrusion:t=>({u_matrix:new e.a6(t),u_lightpos:new e.aq(t),u_lightintensity:new e.aa(t),u_lightcolor:new e.aq(t),u_vertical_gradient:new e.aa(t),u_opacity:new e.aa(t),u_edge_radius:new e.aa(t),u_ao:new e.a8(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_up_dir:new e.aq(t),u_height_lift:new e.aa(t),u_flood_light_color:new e.aq(t),u_vertical_scale:new e.aa(t),u_flood_light_intensity:new e.aa(t),u_ground_shadow_factor:new e.aq(t),u_emissive_strength:new e.aa(t)}),fillExtrusionDepth:t=>({u_matrix:new e.a6(t),u_edge_radius:new e.aa(t),u_vertical_scale:new e.aa(t)}),fillExtrusionPattern:t=>({u_matrix:new e.a6(t),u_lightpos:new e.aq(t),u_lightintensity:new e.aa(t),u_lightcolor:new e.aq(t),u_vertical_gradient:new e.aa(t),u_height_factor:new e.aa(t),u_edge_radius:new e.aa(t),u_ao:new e.a8(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_up_dir:new e.aq(t),u_height_lift:new e.aa(t),u_image:new e.a7(t),u_texsize:new e.a8(t),u_pixel_coord_upper:new e.a8(t),u_pixel_coord_lower:new e.a8(t),u_tile_units_to_pixels:new e.aa(t),u_opacity:new e.aa(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.a6(t),u_opacity:new e.aa(t),u_ao_pass:new e.aa(t),u_meter_to_tile:new e.aa(t),u_ao:new e.a8(t),u_flood_light_intensity:new e.aa(t),u_flood_light_color:new e.aq(t),u_attenuation:new e.aa(t),u_edge_radius:new e.aa(t),u_fb:new e.a7(t),u_fb_size:new e.aa(t)}),fill:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t)}),fillPattern:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_image:new e.a7(t),u_texsize:new e.a8(t),u_pixel_coord_upper:new e.a8(t),u_pixel_coord_lower:new e.a8(t),u_tile_units_to_pixels:new e.aa(t)}),fillOutline:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_world:new e.a8(t)}),fillOutlinePattern:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_world:new e.a8(t),u_image:new e.a7(t),u_texsize:new e.a8(t),u_pixel_coord_upper:new e.a8(t),u_pixel_coord_lower:new e.a8(t),u_tile_units_to_pixels:new e.aa(t)}),circle:e.bI,collisionBox:t=>({u_matrix:new e.a6(t),u_camera_to_center_distance:new e.aa(t),u_extrude_scale:new e.a8(t)}),collisionCircle:t=>({u_matrix:new e.a6(t),u_inv_matrix:new e.a6(t),u_camera_to_center_distance:new e.aa(t),u_viewport_size:new e.a8(t)}),debug:t=>({u_color:new e.a9(t),u_matrix:new e.a6(t),u_overlay:new e.a7(t),u_overlay_scale:new e.aa(t)}),clippingMask:t=>({u_matrix:new e.a6(t)}),heatmap:t=>({u_extrude_scale:new e.aa(t),u_intensity:new e.aa(t),u_matrix:new e.a6(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_up_dir:new e.aq(t)}),heatmapTexture:t=>({u_image:new e.a7(t),u_color_ramp:new e.a7(t),u_opacity:new e.aa(t)}),hillshade:t=>({u_matrix:new e.a6(t),u_image:new e.a7(t),u_latrange:new e.a8(t),u_light:new e.a8(t),u_shadow:new e.a9(t),u_highlight:new e.a9(t),u_emissive_strength:new e.aa(t),u_accent:new e.a9(t)}),hillshadePrepare:t=>({u_matrix:new e.a6(t),u_image:new e.a7(t),u_dimension:new e.a8(t),u_zoom:new e.aa(t)}),line:e.bJ,linePattern:e.bK,raster:t=>({u_matrix:new e.a6(t),u_normalize_matrix:new e.a6(t),u_globe_matrix:new e.a6(t),u_merc_matrix:new e.a6(t),u_grid_matrix:new e.ar(t),u_tl_parent:new e.a8(t),u_scale_parent:new e.aa(t),u_fade_t:new e.aa(t),u_opacity:new e.aa(t),u_image0:new e.a7(t),u_image1:new e.a7(t),u_brightness_low:new e.aa(t),u_brightness_high:new e.aa(t),u_saturation_factor:new e.aa(t),u_contrast_factor:new e.aa(t),u_spin_weights:new e.aq(t),u_perspective_transform:new e.a8(t),u_raster_elevation:new e.aa(t),u_zoom_transition:new e.aa(t),u_merc_center:new e.a8(t),u_cutoff_params:new e.as(t),u_colorization_mix:new e.as(t),u_colorization_offset:new e.aa(t),u_color_ramp:new e.a7(t),u_texture_offset:new e.a8(t),u_texture_res:new e.a8(t),u_emissive_strength:new e.aa(t)}),rasterParticle:t=>({u_matrix:new e.a6(t),u_normalize_matrix:new e.a6(t),u_globe_matrix:new e.a6(t),u_merc_matrix:new e.a6(t),u_grid_matrix:new e.ar(t),u_tl_parent:new e.a8(t),u_scale_parent:new e.aa(t),u_fade_t:new e.aa(t),u_opacity:new e.aa(t),u_image0:new e.a7(t),u_image1:new e.a7(t),u_raster_elevation:new e.aa(t),u_zoom_transition:new e.aa(t),u_merc_center:new e.a8(t),u_cutoff_params:new e.as(t)}),rasterParticleTexture:t=>({u_texture:new e.a7(t),u_opacity:new e.aa(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.a7(t),u_particle_texture_side_len:new e.aa(t),u_tile_offset:new e.a8(t),u_velocity:new e.a7(t),u_color_ramp:new e.a7(t),u_velocity_res:new e.a8(t),u_max_speed:new e.aa(t),u_uv_offset:new e.a8(t),u_data_scale:new e.as(t),u_data_offset:new e.aa(t),u_particle_pos_scale:new e.aa(t),u_particle_pos_offset:new e.a8(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.a7(t),u_particle_texture_side_len:new e.aa(t),u_velocity:new e.a7(t),u_velocity_res:new e.a8(t),u_max_speed:new e.aa(t),u_speed_factor:new e.aa(t),u_reset_rate:new e.aa(t),u_rand_seed:new e.aa(t),u_uv_offset:new e.a8(t),u_data_scale:new e.as(t),u_data_offset:new e.aa(t),u_particle_pos_scale:new e.aa(t),u_particle_pos_offset:new e.a8(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.a7(t),u_is_size_feature_constant:new e.a7(t),u_size_t:new e.aa(t),u_size:new e.aa(t),u_camera_to_center_distance:new e.aa(t),u_rotate_symbol:new e.a7(t),u_aspect_ratio:new e.aa(t),u_fade_change:new e.aa(t),u_matrix:new e.a6(t),u_label_plane_matrix:new e.a6(t),u_coord_matrix:new e.a6(t),u_is_text:new e.a7(t),u_pitch_with_map:new e.a7(t),u_texsize:new e.a8(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_camera_forward:new e.aq(t),u_tile_matrix:new e.a6(t),u_up_vector:new e.aq(t),u_ecef_origin:new e.aq(t),u_texture:new e.a7(t),u_icon_transition:new e.aa(t),u_color_adj_mat:new e.a6(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.a7(t),u_is_size_feature_constant:new e.a7(t),u_size_t:new e.aa(t),u_size:new e.aa(t),u_camera_to_center_distance:new e.aa(t),u_rotate_symbol:new e.a7(t),u_aspect_ratio:new e.aa(t),u_fade_change:new e.aa(t),u_matrix:new e.a6(t),u_label_plane_matrix:new e.a6(t),u_coord_matrix:new e.a6(t),u_is_text:new e.a7(t),u_pitch_with_map:new e.a7(t),u_texsize:new e.a8(t),u_texture:new e.a7(t),u_gamma_scale:new e.aa(t),u_device_pixel_ratio:new e.aa(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_camera_forward:new e.aq(t),u_tile_matrix:new e.a6(t),u_up_vector:new e.aq(t),u_ecef_origin:new e.aq(t),u_is_halo:new e.a7(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.a7(t),u_is_size_feature_constant:new e.a7(t),u_size_t:new e.aa(t),u_size:new e.aa(t),u_camera_to_center_distance:new e.aa(t),u_rotate_symbol:new e.a7(t),u_aspect_ratio:new e.aa(t),u_fade_change:new e.aa(t),u_matrix:new e.a6(t),u_label_plane_matrix:new e.a6(t),u_coord_matrix:new e.a6(t),u_is_text:new e.a7(t),u_pitch_with_map:new e.a7(t),u_texsize:new e.a8(t),u_texsize_icon:new e.a8(t),u_texture:new e.a7(t),u_texture_icon:new e.a7(t),u_gamma_scale:new e.aa(t),u_device_pixel_ratio:new e.aa(t),u_is_halo:new e.a7(t)}),background:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_opacity:new e.aa(t),u_color:new e.a9(t)}),backgroundPattern:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_opacity:new e.aa(t),u_image:new e.a7(t),u_pattern_tl:new e.a8(t),u_pattern_br:new e.a8(t),u_texsize:new e.a8(t),u_pattern_size:new e.a8(t),u_pixel_coord_upper:new e.a8(t),u_pixel_coord_lower:new e.a8(t),u_tile_units_to_pixels:new e.aa(t)}),terrainRaster:Gt,terrainDepth:Gt,skybox:t=>({u_matrix:new e.a6(t),u_sun_direction:new e.aq(t),u_cubemap:new e.a7(t),u_opacity:new e.aa(t),u_temporal_offset:new e.aa(t)}),skyboxGradient:t=>({u_matrix:new e.a6(t),u_color_ramp:new e.a7(t),u_center_direction:new e.aq(t),u_radius:new e.aa(t),u_opacity:new e.aa(t),u_temporal_offset:new e.aa(t)}),skyboxCapture:t=>({u_matrix_3f:new e.ar(t),u_sun_direction:new e.aq(t),u_sun_intensity:new e.aa(t),u_color_tint_r:new e.as(t),u_color_tint_m:new e.as(t),u_luminance:new e.aa(t)}),globeRaster:t=>({u_proj_matrix:new e.a6(t),u_globe_matrix:new e.a6(t),u_normalize_matrix:new e.a6(t),u_merc_matrix:new e.a6(t),u_zoom_transition:new e.aa(t),u_merc_center:new e.a8(t),u_image0:new e.a7(t),u_grid_matrix:new e.ar(t),u_skirt_height:new e.aa(t),u_far_z_cutoff:new e.aa(t),u_frustum_tl:new e.aq(t),u_frustum_tr:new e.aq(t),u_frustum_br:new e.aq(t),u_frustum_bl:new e.aq(t),u_globe_pos:new e.aq(t),u_globe_radius:new e.aa(t),u_viewport:new e.a8(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.aq(t),u_frustum_tr:new e.aq(t),u_frustum_br:new e.aq(t),u_frustum_bl:new e.aq(t),u_horizon:new e.aa(t),u_transition:new e.aa(t),u_fadeout_range:new e.aa(t),u_color:new e.as(t),u_high_color:new e.as(t),u_space_color:new e.as(t),u_temporal_offset:new e.aa(t),u_horizon_angle:new e.aa(t)}),model:t=>({u_matrix:new e.a6(t),u_lighting_matrix:new e.a6(t),u_normal_matrix:new e.a6(t),u_node_matrix:new e.a6(t),u_lightpos:new e.aq(t),u_lightintensity:new e.aa(t),u_lightcolor:new e.aq(t),u_camera_pos:new e.aq(t),u_opacity:new e.aa(t),u_baseColorFactor:new e.as(t),u_emissiveFactor:new e.as(t),u_metallicFactor:new e.aa(t),u_roughnessFactor:new e.aa(t),u_baseTextureIsAlpha:new e.a7(t),u_alphaMask:new e.a7(t),u_alphaCutoff:new e.aa(t),u_baseColorTexture:new e.a7(t),u_metallicRoughnessTexture:new e.a7(t),u_normalTexture:new e.a7(t),u_occlusionTexture:new e.a7(t),u_emissionTexture:new e.a7(t),u_lutTexture:new e.a7(t),u_color_mix:new e.as(t),u_aoIntensity:new e.aa(t),u_emissive_strength:new e.aa(t),u_occlusionTextureTransform:new e.as(t)}),modelDepth:t=>({u_matrix:new e.a6(t),u_instance:new e.a6(t),u_node_matrix:new e.a6(t)}),groundShadow:t=>({u_matrix:new e.a6(t),u_ground_shadow_factor:new e.aq(t)}),stars:t=>({u_matrix:new e.a6(t),u_up:new e.aq(t),u_right:new e.aq(t),u_intensity_multiplier:new e.aa(t)}),occlusion:t=>({u_matrix:new e.a6(t),u_anchorPos:new e.aq(t),u_screenSizePx:new e.a8(t),u_occluderSizePx:new e.a8(t),u_color:new e.as(t)})};function Er(t,i,r){const n=i.createTileMatrix(t,t.worldSize,r.toUnwrapped());return e.ad.multiply(new Float32Array(16),t.projMatrix,n)}function Sr(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const r=i.clone();return r.setProjection(t.projection),Er(r,t.getProjection(),e)}function Mr(e,t,i){return t.name===i.projection.name?e.projMatrix:Er(i,t,e)}let Ir;function Ar(t,i,r,n,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=t.getOrCreateProgram("collisionBox"),d=[];let p=0,f=0;for(let l=0;l0){const t=e.ad.create(),i=x;e.ad.mul(t,g.placementInvProjMatrix,u.glCoordMatrix),e.ad.mul(t,t,g.placementViewportMatrix),d.push({circleArray:b,circleOffset:f,transform:i,invTransform:t,projection:g.getProjection()}),p+=b.length/4,f=p}v&&(t.terrain&&t.terrain.setupElevationDraw(_,h),h.draw(t,c.LINES,e.ae.disabled,e.ag.disabled,t.colorModeForRenderPass(),e.af.disabled,tr(x,u,_,g.getProjection()),r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,u.zoom,null,[v.collisionVertexBuffer,v.collisionVertexBufferExt]))}if(!a||!d.length)return;const m=t.getOrCreateProgram("collisionCircle"),_=new e.bL;_.resize(4*p),_._trim();let g=0;for(const e of d)for(let t=0;t=0&&(m[v.associatedIconIndex]={x:S,y:M,z:I,angle:D})}else pi(T,p)}if(h){f.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{const i=I&&"point"!==r.layout.get("symbol-placement"),a=[];r.hasInitialOcclusionOpacityProperties&&z&&t.symbolParams.useOcclusionQueries&&!d&&!F&&a.push("OCCLUSION_QUERIES"),r.hasInitialOcclusionOpacityProperties||a.push("SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH");const c=i||T,h=r.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&C&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),h>0&&a.push("ICON_TRANSITION"),s.icon.zOffsetVertexBuffer&&a.push("Z_OFFSET"),0===y&&0===x&&0===v&&1===b||a.push("COLOR_ADJUSTMENT");const g=s.icon.programConfigurations.get(r.id),w=t.getOrCreateProgram(s.sdfIcons?"symbolSDF":"symbolIcon",{config:g,defines:a});let A;const P=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],D=s.iconSizeData,L=e.aD(D,M.zoom),R=C||0!==M.pitch,k=ei(f,n.tileID.canonical,C,I,M,s.getProjection(),m),B=ii(f,n.tileID.canonical,C,I,M,s.getProjection(),m),N=t.translatePosMatrix(B,n,l,u,!0),U=t.translatePosMatrix(f,n,l,u),j=c?Cr:k,G=I&&!C&&!i;let q=V;!F&&!M.mercatorFromTransition||I||(q=Pr(M));const Z=d?q:V;if(s.sdfIcons&&!s.iconsInText)A=mr(D.kind,L,G,C,t,U,j,N,!1,P,!0,o,p,O,E,Z,s.getProjection());else{const e=r.getColorAdjustmentMatrix(y,x,v,b);A=fr(D.kind,L,G,C,t,U,j,N,!1,P,o,p,O,E,Z,s.getProjection(),e,h)}const $=n.imageAtlasTexture?n.imageAtlasTexture:null,W=1!==r.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,H=s.sdfIcons||t.options.rotating||t.options.zooming||W||R?S.LINEAR:S.NEAREST,X=s.sdfIcons&&0!==r.paint.get("icon-halo-width").constantOr(1),Y=t.terrain&&C&&i?e.ad.invert(e.ad.create(),k):Cr;if(i&&s.icon){const e=M.elevation,i=e?e.getAtTileOffsetFunc(o,M.center.lat,M.worldSize,s.getProjection()):null,r=ti(f,n.tileID.canonical,C,I,M,s.getProjection(),m);si(s,f,t,!1,r,B,C,_,i,o)}return{program:w,buffers:s.icon,uniformValues:A,atlasTexture:$,atlasTextureIcon:null,atlasInterpolation:H,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:X,tile:n,labelPlaneMatrixInv:Y}},U=()=>{const i=A&&"point"!==r.layout.get("symbol-placement"),a=[],l=i||B||T;r.hasInitialOcclusionOpacityProperties&&D&&t.symbolParams.useOcclusionQueries&&!d&&!F&&a.push("OCCLUSION_QUERIES"),r.hasInitialOcclusionOpacityProperties||a.push("SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH"),t.terrainRenderModeElevated()&&P&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),s.text.zOffsetVertexBuffer&&a.push("Z_OFFSET");const u=s.text.programConfigurations.get(r.id),_=t.getOrCreateProgram(s.iconsInText?"symbolTextAndIcon":"symbolSDF",{config:u,defines:a});let y,x=[0,0],v=null;const b=s.textSizeData;s.iconsInText&&(x=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],v=n.imageAtlasTexture?n.imageAtlasTexture:null,y=P||0!==M.pitch||t.options.rotating||t.options.zooming||"composite"===b.kind||"camera"===b.kind?S.LINEAR:S.NEAREST);const w=n.glyphAtlasTexture?n.glyphAtlasTexture.size:[0,0],I=e.aD(b,M.zoom),C=ei(f,n.tileID.canonical,P,A,M,s.getProjection(),m),z=ii(f,n.tileID.canonical,P,A,M,s.getProjection(),m),L=t.translatePosMatrix(z,n,c,h,!0),R=t.translatePosMatrix(f,n,c,h),k=l?Cr:C,N=A&&!P&&!i;let U=V;!F&&!M.mercatorFromTransition||A||(U=Pr(M));const j=d?U:V;let G;G=s.iconsInText?_r(b.kind,I,N,P,t,R,k,L,w,x,o,p,O,E,j,s.getProjection()):mr(b.kind,I,N,P,t,R,k,L,!0,w,!0,o,p,O,E,j,s.getProjection());const q=n.glyphAtlasTexture?n.glyphAtlasTexture:null,Z=S.LINEAR,$=0!==r.paint.get("text-halo-width").constantOr(1),W=t.terrain&&P&&i?e.ad.invert(e.ad.create(),C):Cr;if(i&&s.text){const e=M.elevation,i=e?e.getAtTileOffsetFunc(o,M.center.lat,M.worldSize,s.getProjection()):null,r=ti(f,n.tileID.canonical,P,A,M,s.getProjection(),m);si(s,f,t,!0,r,z,P,g,i,o)}return{program:_,buffers:s.text,uniformValues:G,atlasTexture:q,atlasTextureIcon:v,atlasInterpolation:Z,atlasInterpolationIcon:y,isSDF:!0,hasHalo:$,tile:n,labelPlaneMatrixInv:W}},j=s.icon.segments.get().length,G=s.text.segments.get().length,q=j&&!a.onlyText?k():null,Z=G&&!a.onlyIcons?U():null,$=r.paint.get("icon-opacity").constantOr(1),W=r.paint.get("text-opacity").constantOr(1);if(L&&s.canOverlap){R=!0;const t=$&&!a.onlyText?s.icon.segments.get():[],i=W&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)N.push({segments:new e.b([i]),sortKey:i.sortKey,state:q});for(const t of i)N.push({segments:new e.b([t]),sortKey:t.sortKey,state:Z})}else a.onlyText||N.push({segments:$?s.icon.segments:new e.b([]),sortKey:0,state:q}),a.onlyIcons||N.push({segments:W?s.text.segments:new e.b([]),sortKey:0,state:Z})}R&&N.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of N){const i=e.state;if(i)if(t.terrain&&t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:!r.hasInitialOcclusionOpacityProperties&&M.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),E.activeTexture.set(S.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,S.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(E.activeTexture.set(S.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,S.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const n=i.uniformValues;n.u_is_halo=1,Rr(i.buffers,e.segments,r,t,i.program,k,o,s,n,2),n.u_is_halo=0}else{if(i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,Rr(i.buffers,e.segments,r,t,i.program,k,o,s,n,1)),n.u_is_halo=0}Rr(i.buffers,e.segments,r,t,i.program,k,o,s,i.uniformValues,1)}}}function Rr(t,i,r,n,o,s,a,l,c,u){const h=n.context.gl,d=[t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.iconTransitioningVertexBuffer,t.globeExtVertexBuffer,t.zOffsetVertexBuffer];t.occlusionQueryOpacityVertexBuffer.length>0&&d.push(t.occlusionQueryOpacityVertexBuffer),o.draw(n,h.TRIANGLES,s,a,l,e.af.disabled,c,r.id,t.layoutVertexBuffer,t.indexBuffer,i,r.paint,n.transform.zoom,t.programConfigurations.get(r.id),d,u)}function kr(t,i,r,n,o,s,a){const l=t.context.gl,c=r.paint.get("fill-pattern"),u=c&&c.constantOr(1);let h,d,p,f,m;a?(d=u&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=l.LINES):(d=u?"fillPattern":"fill",h=l.TRIANGLES);for(const _ of n){const n=i.getTile(_);if(u&&!n.patternsLoaded())continue;const g=n.getBucket(r);if(!g)continue;t.prepareDrawTile();const y=g.programConfigurations.get(r.id),x=t.isTileAffectedByFog(_),v=t.getOrCreateProgram(d,{config:y,overrideFog:x});u&&(t.context.activeTexture.set(l.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),y.updatePaintBuffers());const b=c.constantOr(null);if(b&&n.imageAtlas){const e=n.imageAtlas.patternPositions[b.toString()];e&&y.setConstantPatternPositions(e)}const w=t.translatePosMatrix(_.projMatrix,n,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor")),T=r.paint.get("fill-emissive-strength");if(a){f=g.indexBuffer2,m=g.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];p="fillOutlinePattern"===d&&u?er(w,T,t,n,e):Qi(w,T,e)}else f=g.indexBuffer,m=g.segments,p=u?Ji(w,T,t,n):Ki(w,T);t.uploadCommonUniforms(t.context,v,_.toUnwrapped()),v.draw(t,h,o,t.stencilModeForClipping(_),s,e.af.disabled,p,r.id,g.layoutVertexBuffer,f,m,r.paint,t.transform.zoom,y,void 0)}}function Or(t,i,r,n,o,s,a,l){r.resetLayerRenderingStats(t);const c=t.context,u=c.gl,h=t.transform,d=r.paint.get("fill-extrusion-pattern"),p=d.constantOr(1),f=r.paint.get("fill-extrusion-opacity"),m=t.style.enable3dLights(),_=r.paint.get(m&&!p?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),g=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),_],y=r.layout.get("fill-extrusion-edge-radius"),x=y>0&&!r.paint.get("fill-extrusion-rounded-roof"),v=x?0:y,b="globe"===h.projection.name?e.bY():0,w="globe"===h.projection.name,T=w?e.a1(h.zoom):0,E=[e.aj(h.center.lng),e.ak(h.center.lat)],S=r.paint.get("fill-extrusion-flood-light-color").toRenderColor(r.lut).toArray01().slice(0,3),M=r.paint.get("fill-extrusion-flood-light-intensity"),I=r.paint.get("fill-extrusion-vertical-scale"),A=xi(t,r.paint.get("fill-extrusion-cutoff-fade-range")),C=r.paint.get("fill-extrusion-emissive-strength"),P=[];let z;w&&P.push("PROJECTION_GLOBE_VIEW"),g[0]>0&&P.push("FAUX_AO"),x&&P.push("ZERO_ROOF_RADIUS"),l&&P.push("HAS_CENTROID"),M>0&&P.push("FLOOD_LIGHT"),A.shouldRenderCutoff&&P.push("RENDER_CUTOFF");const D="shadow"===t.renderPass,L=t.shadowRenderer,R=D&&!!L;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let k=[0,0,0];if(L){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(k=Mi(t.style,e,i)),z=P.concat(["SHADOWS_SINGLE_CASCADE"])}const O=R?"fillExtrusionDepth":p?"fillExtrusionPattern":"fillExtrusion",B=r.getLayerRenderingStats();for(const m of n){const n=i.getTile(m),_=n.getBucket(r);if(!_||_.projection.name!==h.projection.name)continue;let y=!1;L&&(y=0===L.getMaxCascadeForTile(m.toUnwrapped()));const x=t.isTileAffectedByFog(m),R=_.programConfigurations.get(r.id),F=t.getOrCreateProgram(O,{config:R,defines:y?z:P,overrideFog:x});if(t.terrain&&t.terrain.setupElevationDraw(n,F,{useMeterToDem:!0}),!_.centroidVertexBuffer){const e=F.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}!D&&L&&L.setupShadows(n.tileID.toUnwrapped(),F,"vector-tile",n.tileID.overscaledZ),p&&(t.context.activeTexture.set(u.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),R.updatePaintBuffers());const N=d.constantOr(null);if(N&&n.imageAtlas){const e=n.imageAtlas.patternPositions[N.toString()];e&&R.setConstantPatternPositions(e)}const V=r.paint.get("fill-extrusion-vertical-gradient");let U;if(D&&L){if(jr(n.tileID,_,t))continue;const e=L.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());U=Xi(e,v,I)}else{const e=t.translatePosMatrix(m.expandedProjMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),i=h.projection.createInversionMatrix(h,m.canonical);U=p?Yi(e,t,V,f,g,v,m,n,b,T,E,i,S,I):Hi(e,t,V,f,g,v,m,b,T,E,i,S,I,M,k,C)}t.uploadCommonUniforms(c,F,m.toUnwrapped(),null,A);let j=_.segments;if("mercator"===h.projection.name&&!D&&(j=_.getVisibleSegments(n.tileID,t.terrain,t.transform.getFrustum(0)),!j.get().length))continue;if(B)if(D)for(const e of j.get())B.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of j.get())B.numRenderedVerticesInTransparentPass+=e.primitiveLength;const G=[];(t.terrain||l)&&G.push(_.centroidVertexBuffer),w&&G.push(_.layoutVertexExtBuffer),F.draw(t,c.gl.TRIANGLES,o,s,a,e.af.backCCW,U,r.id,_.layoutVertexBuffer,_.indexBuffer,j,r.paint,t.transform.zoom,R,G)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}function Br(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g,y,x){const v=t.context,b=v.gl,w=t.transform,T=t.transform.zoom,E=[],S=xi(t,r.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===u?(E.push("CLEAR_SUBPASS"),x&&(E.push("CLEAR_FROM_TEXTURE"),v.activeTexture.set(b.TEXTURE0),x.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===u&&E.push("SDF_SUBPASS"),g&&E.push("HAS_CENTROID"),S.shouldRenderCutoff&&E.push("RENDER_CUTOFF");const M=r.layout.get("fill-extrusion-edge-radius"),I=(e,i,n,u,y)=>{const b=i.programConfigurations.get(r.id),w=t.isTileAffectedByFog(e),I=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:E,overrideFog:w}),A=((e,t,i,r,n,o,s,a,l,c,u)=>({u_matrix:t,u_opacity:i,u_ao_pass:r?1:0,u_meter_to_tile:n,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:u}))(0,u,h,c,y,[d,p*y],f,m,_,T>=17?0:M*y,x?x.size[0]:0),C=[];g&&C.push(i.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(v,I,e.toUnwrapped(),null,S),I.draw(t,v.gl.TRIANGLES,o,s,a,l,A,r.id,i.vertexBuffer,i.indexBuffer,n,r.paint,T,b,C)};for(const o of n){const n=i.getTile(o),s=n.getBucket(r);if(!s||s.projection.name!==w.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=t.translatePosMatrix(o.projMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),i=a.getDefaultSegment();I(o,a,i,e,l)}if(y)for(let s=0;s<4;s++){const a=e.bZ[s](o),c=i.getTile(a);if(!c)continue;const u=c.getBucket(r);if(!u||u.projection.name!==w.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const h=u.groundEffect;let d,p;0===s?(d=[-e.a3,0,0],p=1):1===s?(d=[e.a3,0,0],p=0):2===s?(d=[0,-e.a3,0],p=3):(d=[0,e.a3,0],p=2);const f=h.regionSegments[p];if(!f)continue;const m=new Float32Array(16);e.ad.translate(m,o.projMatrix,d),I(o,h,f,t.translatePosMatrix(m,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),l)}}}function Fr(t,i,r,n,o,s,a){0===n.centroidVertexArray.length&&n.createCentroidsBuffer();const l=s?s.findDEMTileFor(r):null;if(!(l&&l.dem||a))return;const c=t=>new e.P(Math.ceil((t+e.c0)*e.c1),0),u=e=>{const t=i.getSource().minzoom,r=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},n=[0,-1,1];for(const i of n){if(e.overscaledZ+i(h[0]=Math.min(t.min.y,i.min.y),h[1]=Math.max(t.max.y,i.max.y),h[2]=e.a3-i.min.x>t.max.x?i.min.x-e.a3:t.max.x,h),p=(t,i)=>(h[0]=Math.min(t.min.x,i.min.x),h[1]=Math.max(t.max.x,i.max.x),h[2]=e.a3-i.min.y>t.max.y?i.min.y-e.a3:t.max.y,h),f=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,i,n,o,a,c,u)=>{if(!s)return 0;const h=[[c?n:t,c?t:n,0],[c?n:i,c?i:n,0]],d=u<0?e.a3+u:u,p=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===n&&u<0||0!==n&&u>0?s.getForTilePoints(a,[p],!0,o):h.push(p),s.getForTilePoints(r,h,!0,l),Math.max(h[0][2],h[1][2],p[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=n.borderFeatureIndices[t];if(0===i.length)continue;const o=e.bZ[t](r),l=u(o);if(!(l&&l instanceof e.b_))continue;if(n.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const h=s?s.findDEMTileFor(o):null;if(!(h&&h.dem||a))continue;const d=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[d]!==n.canonical.z,y=l.borderFeatureIndices[d];let x=0;if(n.canonical.z!==l.canonical.z){for(const e of i)n.showCentroid(n.featuresOnBorder[e]);if(p)for(const e of y)l.showCentroid(l.featuresOnBorder[e]);n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}for(const r of i){const i=n.featuresOnBorder[r],s=n.centroidData[i.centroidDataIndex],u=i.borders[t];let p;for(;xu[0]+3||e[0]>u[0]-3)break;l.showCentroid(p),x++}if(p&&xu[1]-3)&&(v++,++x!==y.length);)p=l.featuresOnBorder[y[x]];if(p=l.featuresOnBorder[y[r]],v>1){const e=p.borders[d];Math.abs(u[0]-e[0])<3&&Math.abs(u[1]-e[1])<3&&(v=1,x=r+1)}else if(0===v){n.showCentroid(i);continue}const b=l.centroidData[p.centroidDataIndex];a&&1===v&&(((_=s).flags|(g=b).flags)&e.b$?(_.flags|=e.b$,g.flags|=e.b$):(_.flags&=~e.b$,g.flags&=~e.b$));const w=i.intersectsCount()>1||p.intersectsCount()>1;if(v>1)x=r,s.centroidXY=b.centroidXY=new e.P(0,0);else if(h&&h.dem&&!w){const i=f[t](s,b),r=t%2?e.a3-1:0,n=m(i[0],Math.min(e.a3-1,i[1]),r,h,o,t<2,i[2]);s.centroidXY=b.centroidXY=c(n)}else w?s.centroidXY=b.centroidXY=new e.P(0,0):(s.centroidXY=n.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(p));n.writeCentroidToBuffer(s),l.writeCentroidToBuffer(b)}else n.showCentroid(i)}n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}var _,g;(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}const Nr=[1,0,0],Vr=[0,1,0],Ur=[0,0,1];function jr(t,i,r){const n=r.transform,o=r.shadowRenderer;if(!o)return!0;const s=t.toUnwrapped(),a=n.tileSize*o._cascades[r.currentShadowCascade].scale;let l=i.maxHeight;if(n.elevation){const e=n.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const u=o.computeSimplifiedTileShadowVolume(s,l,a,c);if(!u)return!1;const h=[Nr,Vr,Ur,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===n.projection.name,p=n.scaleZoom(a),f=e.aM.fromInvProjectionMatrix(n.invProjMatrix,n.worldSize,p,!d),m=o.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(u.vertices,u.planes,h)||0===m.intersectsPrecise(u.vertices,u.planes,h)}function Gr(t){return[t[0]*e.c2,t[1]*e.c2,t[2]*e.c2,0]}function qr(t,i,r,n,o,s,a,l,c){const u=n.getSource(),h=r.globeSharedBuffers;if(!h)return;let d,p,f;if(i&&(d=n.getTile(i)),u instanceof e.bm?(p=u.texture,f=e.bh(0,0,r.transform)):d&&i&&(p=d.texture,f=e.bh(i.canonical.z,i.canonical.x,r.transform)),!p||!f)return;t||(f=e.ad.scale(e.ad.create(),f,[1,-1,1]));const m=r.context,_=m.gl,g="nearest"===o.paint.get("raster-resampling")?_.NEAREST:_.LINEAR,y=r.colorModeForDrapableLayerRenderPass(s),x=a.defines;x.push("GLOBE_POLES");const v=new e.ae(_.LEQUAL,e.ae.ReadWrite,r.depthRangeFor3D),b=Float32Array.from(r.transform.expandedFarZProjMatrix),w=Float32Array.from(e.bf(e.bg(new e.aO(0,0,0))));r.terrain&&r.terrain.prepareDrawTile(),m.activeTexture.set(_.TEXTURE0),p.bind(g,_.CLAMP_TO_EDGE),m.activeTexture.set(_.TEXTURE1),p.bind(g,_.CLAMP_TO_EDGE),p.useMipmap&&m.extTextureFilterAnisotropic&&r.transform.pitch>20&&_.texParameterf(_.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[T,E,S,M]=i?h.getPoleBuffers(i.canonical.z,!1):h.getPoleBuffers(0,!0),I=o.paint.get("raster-elevation");let A;t?(A=T,r.renderDefaultNorthPole=0!==I):(A=E,r.renderDefaultSouthPole=0!==I);const C=Gr(a.mix),P=((e,t,i,r,n,o,s,a,l,c,u,h,d)=>ar(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0],a,2,c,u,h,1,0,d))(b,w,f,e.a1(r.transform.zoom),0,o,0,I,0,C,a.offset,a.range,s),z=r.getOrCreateProgram("raster",{defines:x});r.uploadCommonUniforms(m,z,null),z.draw(r,_.TRIANGLES,v,c,y,l,P,o.id,A,S,M)}function Zr(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return[t,i,(o-n-t)/r,(o-t)/r]}function $r(t,i,r,n){if(t)return i instanceof ki&&t instanceof e.c3?i.getTextureDescriptor(t,r,!0):{texture:t.texture,mix:Gr(n.mix),offset:n.offset,buffer:0,tileSize:1}}function Wr(t,i,r){if(!t)return null;const n=i.getTextureDescriptor(t,r,!0);if(!n)return null;let{texture:o,mix:s,offset:a,tileSize:l,buffer:c,format:u}=n;if(!o||!u)return null;let h=!1;return"uint32"===u&&(h=!0,s[3]=0,s=or(e.c4,s,[0,r.paint.get("raster-particle-max-speed")]),a=sr(e.c4,a,[0,r.paint.get("raster-particle-max-speed")])),{texture:o,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:h,scale:s,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[u]]}}function Hr(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return[t,i,(o-n-t)/r,(o-t)/r]}const Xr=new e.C(1,0,0,1),Yr=new e.C(0,1,0,1),Kr=new e.C(0,0,1,1),Jr=new e.C(1,0,1,1),Qr=new e.C(0,1,1,1);function en(t,i,r,n,o,s,a){const l=t.context,c=t.transform,u=l.gl,h="globe"===c.projection.name,d=h?["PROJECTION_GLOBE_VIEW"]:[];let p=e.ad.clone(r.projMatrix);if(h&&e.a1(c.zoom)>0){const t=e.c5(r.canonical,c),i=e.c6(t);p=e.ad.multiply(new Float32Array(16),c.globeMatrix,i),e.ad.multiply(p,c.projMatrix,p)}const f=e.ad.create();f[12]+=2*o/(e.e.devicePixelRatio*c.width),f[13]+=2*s/(e.e.devicePixelRatio*c.height),e.ad.multiply(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),_=i.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(_,m);const g=e.ae.disabled,y=e.ag.disabled,x=t.colorModeForRenderPass(),v="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),h?_._makeGlobeTileDebugBuffers(t.context,c):_._makeDebugTileBoundsBuffers(t.context,c.projection);const b=_._tileDebugBuffer||t.debugBuffer,w=_._tileDebugIndexBuffer||t.debugIndexBuffer,T=_._tileDebugSegments||t.debugSegments;if(m.draw(t,u.LINE_STRIP,g,y,x,e.af.disabled,ir(p,n),v,b,w,T,null,null,null,[_._globeTileDebugBorderBuffer]),a){const e=_.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let n=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(n+=` => ${r.overscaledZ}`),n+=` ${_.state}`,n+=` ${i}kb`,(function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.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(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)})(t,n)}const E=i.getTile(r).tileSize,S=512/Math.min(E,512)*(r.overscaledZ/c.zoom)*.5,M=_._tileDebugTextBuffer||t.debugBuffer,I=_._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,A=_._tileDebugTextSegments||t.debugSegments;m.draw(t,u.TRIANGLES,g,y,e.a.alphaBlended,e.af.disabled,ir(p,e.C.transparent,S),v,M,I,A,null,null,null,[_._globeTileDebugTextBuffer])}function tn(e,t,i,r){nn(e,0,t+i/2,e.transform.width,i,r)}function rn(e,t,i,r){nn(e,t-i/2,0,i,e.transform.height,r)}function nn(t,i,r,n,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.e.devicePixelRatio,r*e.e.devicePixelRatio,n*e.e.devicePixelRatio,o*e.e.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const on=e.c7([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:sn}=on;function an(e,t,i,r){e.emplaceBack(t,i,r)}class ln{constructor(t){this.vertexArray=new e.c8,this.indices=new e.bu,an(this.vertexArray,-1,-1,1),an(this.vertexArray,1,-1,1),an(this.vertexArray,-1,1,1),an(this.vertexArray,1,1,1),an(this.vertexArray,-1,-1,-1),an(this.vertexArray,1,-1,-1),an(this.vertexArray,-1,1,-1),an(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,sn),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.b.simpleSegment(0,0,36,12)}}function cn(t,i,r,n,o,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(e.bC.fromMat4(e.bC.create(),n),o,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),r.draw(t,a.TRIANGLES,e.ae.disabled,e.ag.disabled,e.a.unblended,e.af.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const un=e.c7([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class hn{constructor(t){const i=new e.c9;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const r=new e.bu;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,un.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=e.b.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const dn=e.c7([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class pn{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class fn{constructor(t){this.colorModeAlphaBlendedWriteRGB=new e.a([e.ca,e.cb,e.ca,e.cb],e.C.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new e.a([e.ca,e.cc,e.ca,e.cc],e.C.transparent,[!1,!1,!1,!0]),this.params=new pn,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},(()=>{this.updateNeeded=!0})),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0})),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0}))}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new hn(i);const t=this.params.sizeRange,r=this.params.intensityRange,n=(function(t){const i=e.cf(30),r=[];for(let n=0;n{const l="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];i&&l.push("ALPHA_PASS");const d=t.getOrCreateProgram("globeAtmosphere",{defines:l}),f=((e,t,i,r,n,o,s,a,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:s,u_color:a,u_high_color:l,u_space_color:c,u_temporal_offset:u,u_horizon_angle:h}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,p,c,u,h,m,y);t.uploadCommonUniforms(r,d);const _=this.atmosphereBuffer;_&&d.draw(t,n.TRIANGLES,s,e.ag.disabled,i?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,e.af.backCW,f,i?"atmosphere_glow_alpha":"atmosphere_glow",_.vertexBuffer,_.indexBuffer,_.segments)};x(!1),x(!0)}drawStars(t,i){const r=e.at(i.properties.get("star-intensity"),0,1);if(0===r)return;const n=t.context,o=n.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.av.identity([]);e.av.rotateX(l,l,-s._pitch),e.av.rotateZ(l,l,-s.angle),e.av.rotateX(l,l,e.ab(s._center.lat)),e.av.rotateY(l,l,-e.ab(s._center.lng));const c=e.ad.fromQuat(new Float32Array(16),l),u=e.ad.multiply([],s.starsProjMatrix,c),h=e.bC.fromMat4([],c),d=e.bC.invert([],h),p=[0,1,0];e._.transformMat3(p,p,d),e._.scale(p,p,this.params.sizeMultiplier);const f=[1,0,0];e._.transformMat3(f,f,d),e._.scale(f,f,this.params.sizeMultiplier);const m=(_=p,g=f,y=r,{u_matrix:Float32Array.from(u),u_up:_,u_right:g,u_intensity_multiplier:y});var _,g,y;t.uploadCommonUniforms(n,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,e.ae.disabled,e.ag.disabled,this.colorModeAlphaBlendedWriteRGB,e.af.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function mn(t,i){const r=[...t],n=i.cameraWorldSizeForFog/i.worldSize,o=e.ad.identity([]);return e.ad.scale(o,o,[n,n,1]),e.ad.multiply(r,o,r),e.ad.multiply(r,i.worldToFogMatrix,r),r}function _n(t,i,r,n,o){const s=r.material,a=n.context,{baseColorTexture:l,metallicRoughnessTexture:c}=s.pbrMetallicRoughness,{normalTexture:u,occlusionTexture:h,emissionTexture:d}=s;function p(e,i,r){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+r),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:r,wrapT:n}=e.sampler;e.gfxTexture.bindExtraParam(t,i,r,n)}}p(l,"HAS_TEXTURE_u_baseColorTexture",yi.BaseColor),p(c,"HAS_TEXTURE_u_metallicRoughnessTexture",yi.MetallicRoughness),p(u,"HAS_TEXTURE_u_normalTexture",yi.Normal),p(h,"HAS_TEXTURE_u_occlusionTexture",yi.Occlusion),p(d,"HAS_TEXTURE_u_emissionTexture",yi.Emission),o&&(o.texture||(o.texture=new e.ch(n.context,o.image,[o.image.height,o.image.height,o.image.height],a.gl.RGBA)),a.activeTexture.set(a.gl.TEXTURE0+yi.LUT),o.texture&&o.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),r.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(r.texcoordBuffer)),r.colorBuffer&&(t.push(12===r.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(r.colorBuffer)),r.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(r.normalBuffer)),r.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(r.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||t.push("DIFFUSE_SHADED"),t.push("USE_STANDARD_DERIVATIVES")}function gn(t,i,r,n,o,s){const a=r.paint.get("model-opacity"),l=i.context,c=new e.ae(i.context.gl.LEQUAL,e.ae.ReadWrite,i.depthRangeFor3D),u=i.transform,h=t.mesh,d=h.material,p=d.pbrMetallicRoughness,f=i.style.fog;let m;m="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.ad.multiply([],n.zScaleMatrix,t.nodeModelMatrix),e.ad.multiply(m,n.negCameraPosMatrix,m);const _=e.ad.invert([],m);e.ad.transpose(_,_);const g=r.paint.get("model-emissive-strength").constantOr(0),y=vr(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(_),null,i,a,p.baseColorFactor.toRenderColor(null),d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,g,r),x={defines:[]},v=[];_n(x.defines,v,h,i,r.lut);const b=i.shadowRenderer;b&&(b.useNormalOffset=!1);let w=null;if(f){const e=mn(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),"globe"!==u.projection.name){const t=h.aabb.min,i=h.aabb.max,[r,n]=f.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);x.overrideFog=r>=ot||n>=ot}}const T=xi(i,r.paint.get("model-cutoff-fade-range"));T.shouldRenderCutoff&&x.defines.push("RENDER_CUTOFF");const E=i.getOrCreateProgram("model",x);i.uploadCommonUniforms(l,E,null,w,T),"shadow"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,o,s,h.material.doubleSided?e.af.disabled:e.af.backCCW,y,r.id,h.vertexBuffer,h.indexBuffer,h.segments,r.paint,i.transform.zoom,void 0,v)}function yn(t,i,r,n,o,s,a){let l;l="globe"===t.projection.name?e.ci(r,t):[...r],e.ad.multiply(l,l,i.matrix);const c=e.ad.multiply([],n,l);if(i.meshes)for(const t of i.meshes){if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:o,worldViewProjection:c,nodeModelMatrix:l});continue}const i=e._.transformMat4([],t.centroid,c);i[2]>0&&s.push({mesh:t,depth:i[2],modelIndex:o,worldViewProjection:c,nodeModelMatrix:l})}if(i.children)for(const e of i.children)yn(t,e,r,n,o,s,a)}function xn(t,i,r,n){const o=r.shadowRenderer;if(!o)return;const s=o.getShadowPassDepthMode(),a=o.getShadowPassColorMode(),l=o.calculateShadowPassMatrixFromMatrix(i),c=br(l);r.getOrCreateProgram("modelDepth",{defines:r._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(r,r.context.gl.TRIANGLES,s,e.ag.disabled,a,e.af.backCCW,c,n.id,t.vertexBuffer,t.indexBuffer,t.segments,n.paint,r.transform.zoom,void 0,void 0)}function vn(t,i,r){const n=i.updateZoomBasedPaintProperties(),o=(function(t,i,r){let n,o,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,o=i.findDEMTileFor(r);o&&o.dem?n=e.ck.create(i,r,o):a=0}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||n&&n._demTile&&n._demTile.tileID===i.validForDEMTile.id&&n._dem._timestamp===i.validForDEMTile.timestamp))return!1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eu&&(u=e.max)}const h=e.at(n.x,s,a)-n.x,d=e.at(n.y,l,c)-n.y,p=e.ax(u,i.center.lat)-n.z;return i._zoomFromMercatorZ(Math.sqrt(h*h+d*d+p*p))}function Tn(t,i,r,n,o,s,a){const l=t.context,c="shadow"===t.renderPass,u=t.shadowRenderer,h=c&&u?u.getShadowPassDepthMode():new e.ae(l.gl.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D),d=t.isTileAffectedByFog(s);if(r.meshes)for(const p of r.meshes){const f=["MODEL_POSITION_ON_GPU"],m=[];let _,g,y;n.instancedDataArray.length>20&&f.push("INSTANCED_ARRAYS");const x=xi(t,i.paint.get("model-cutoff-fade-range"));if(x.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),c&&u)_=t.getOrCreateProgram("modelDepth",{defines:f}),g=br(a.shadowTileMatrix,a.shadowTileMatrix,Float32Array.from(r.matrix)),y=u.getShadowPassColorMode();else{_n(f,m,p,t,i.lut),_=t.getOrCreateProgram("model",{defines:f,overrideFog:d});const n=p.material,c=n.pbrMetallicRoughness,h=i.paint.get("model-opacity"),v=i.paint.get("model-emissive-strength").constantOr(0);g=vr(s.expandedProjMatrix,Float32Array.from(r.matrix),new Float32Array(16),null,t,h,c.baseColorFactor.toRenderColor(null),n.emissiveFactor,c.metallicFactor,c.roughnessFactor,n,v,i,o),u&&(a.shadowUniformsInitialized?_.setShadowUniformValues(l,u.getShadowUniformValues()):(u.setupShadows(s.toUnwrapped(),_,"model-tile",s.overscaledZ),a.shadowUniformsInitialized=!0)),y=x.shouldRenderCutoff||h<1||"OPAQUE"!==n.alphaMode?e.a.alphaBlended:e.a.unblended}t.uploadCommonUniforms(l,_,s.toUnwrapped(),null,x);const v=p.material.doubleSided?e.af.disabled:e.af.backCCW;if(n.instancedDataArray.length>20)m.push(n.instancedDataBuffer),_.draw(t,l.gl.TRIANGLES,h,e.ag.disabled,y,v,g,i.id,p.vertexBuffer,p.indexBuffer,p.segments,i.paint,t.transform.zoom,void 0,m,n.instancedDataArray.length);else{const r=c?"u_instance":"u_normal_matrix";for(let o=0;ou[1]?l:u,a[0]=r.max[0],l=e.aA.transformMat4([],a,s),c=l[1]u[1]?l:u,a[1]=r.min[1],l=e.aA.transformMat4([],a,s),c=l[1]u[1]?l:u;const h=e.at(n[0],0,1),d=100*i.pixelsPerMeter*e.at(n[1],0,1),p=e.at(n[2],0,1),f=e._.lerp([],c,u,h),m=Math.tan(.5*i.fovX),_=-f[2]*m;if(0===d)return f[1]<-Math.abs(_)?p:1;const g=(-Math.abs(_)-f[1])/d,y=(e,t,i)=>(1-i)*e+i*t,x=e.at(y(1,p,g),p,1);return y(1,x,e.at((i.pitch-20)/20,0,1))}class An{}class Cn{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,i,r){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const n=r.gl,o=n.getBufferParameter(n.ELEMENT_ARRAY_BUFFER,n.BUFFER_SIZE),s=new ArrayBuffer(o),a=new Int16Array(s);n.getBufferSubData(n.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.cm;for(let e=0;e30&&(i.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}const Pn=e.c7([{type:"Float32",name:"a_offset_xy",components:2}]);class zn{constructor(t){const i=new e.cn,r=new e.bu;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),this.segments=e.b.simpleSegment(0,0,i.length,r.length),this.vx=t.createVertexBuffer(i,Pn.members),this.idx=t.createIndexBuffer(r)}destroy(){this.vx.destroy(),this.idx.destroy()}}const Dn={symbol:function(t,i,r,n,o){if("translucent"!==t.renderPass)return;const s=e.ag.disabled,a=t.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&(function(t,i,r,n,o,s,a){const l=i.transform,c="map"===o,u="map"===s;for(const i of t){const t=n.getTile(i),o=t.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.aD(o.textSizeData,l.zoom),h=Mr(i,o.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),p=ei(h,t.tileID.canonical,u,c,l,o.getProjection(),d),f=o.hasIconTextFit()&&o.hasIconData();if(s){const r=Math.pow(2,l.zoom-t.tileID.overscaledZ);Dr(o,c,u,a,e.bO,l,p,i,r,s,f)}}})(n,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o);const l=0!==r.paint.get("icon-opacity").constantOr(1),c=0!==r.paint.get("text-opacity").constantOr(1);void 0!==r.layout.get("symbol-sort-key").constantOr(1)&&(l||c)?Lr(t,i,r,n,s,a):(l&&Lr(t,i,r,n,s,a,{onlyIcons:!0}),c&&Lr(t,i,r,n,s,a,{onlyText:!0}),(function(t,i,r,n){if(!t.symbolParams.useOcclusionQueries)return;const o=t.context.gl,s=t.transform,a=r.paint,l=a.get("icon-occlusion-opacity").constantOr(0),c=a.get("text-occlusion-opacity").constantOr(0);if(!r.hasInitialOcclusionOpacityProperties||1===l&&1===c)return;const u="globe"===s.projection.name;for(const a of n){const n=i.getTile(a),l=n.getBucket(r);if(!l)continue;if("mercator"===l.projection.name&&u)continue;if(l.fullyClipped)continue;if("globe"===l.projection.name){e.w(`Occlusion not supported for globe mode. Layer: ${r.type}`);continue}const c=Mr(a,l.getProjection(),s),h=e.ad.fromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,t.symbolParams.depthOffset,1),d=e.ad.multiply([],h,c),p="none"!==t.symbolParams.visualizeOcclusions?1:t.symbolParams.occlusionQueryFrameWindow;for(let i=0;ie.sortKey-t.sortKey));const x={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const i of y){const{programConfiguration:n,program:o,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:l,uniformValues:c,tile:_}=i.state,g=i.segments;t.terrain&&t.terrain.setupElevationDraw(_,o,x),t.uploadCommonUniforms(u,o,_.tileID.toUnwrapped()),o.draw(t,h.TRIANGLES,p,f,m,e.af.disabled,c,r.id,s,l,g,r.paint,d.zoom,n,[a])}},heatmap:function(t,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=e.ag.disabled,l=new e.a([s.ONE,s.ONE,s.ONE,s.ONE],e.C.transparent,[!0,!0,!0,!0]);!(function(e,t,i,r){const n=e.gl,o=t.width*r,s=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!0,null),(function(e,t,i,r,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)})(e,0,t,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)})(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.C.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:[],d=u?e.af.frontCCW:e.af.disabled,p=[e.aj(c.center.lng),e.ak(c.center.lat)];for(let f=0;f({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)})(t,r))},line:function(t,i,r,n){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),s=r.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=r.paint.get("line-emissive-strength"),l=r.paint.get("line-occlusion-opacity"),c=t.context,u=c.gl,h=r.layout.get("line-z-offset"),d=!h.isConstant()||!!h.constantOr(0),p=d?new e.ae(t.depthOcclusion?u.GREATER:u.LEQUAL,e.ae.ReadOnly,t.depthRangeFor3D):t.depthModeForSublayer(0,e.ae.ReadOnly),f=t.colorModeForDrapableLayerRenderPass(a),m=t.terrain&&t.terrain.renderingToTexture,_=m?1:e.e.devicePixelRatio,g=r.paint.get("line-dasharray"),y=g.constantOr(1),x=r.layout.get("line-cap"),v=g.constantOr(null),b=x.constantOr(null),w=r.paint.get("line-pattern"),T=w.constantOr(1),E=w.constantOr(null),S=r.paint.get("line-opacity").constantOr(1);let M=!T&&1!==S||t.depthOcclusion&&l>0&&l<1;const I=r.paint.get("line-gradient"),A=T?"linePattern":"line",C=e.bT(r);let P;if(m&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(M=!1),0!==l&&t.depthOcclusion){const t=r.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?P=t.value:e.w(`Occlusion opacity for layer ${r.id} is supported only when line-opacity isn't data-driven.`)}if(d&&(t.forceTerrainMode=!0),!d&&0!==l&&t.terrain&&!m)return void e.w(`Occlusion opacity for layer ${r.id} is supported on terrain only if the layer has non-zero line-z-offset.`);const z=M&&d?t.stencilModeFor3D():e.ag.disabled;for(const o of n){const n=i.getTile(o);if(T&&!n.patternsLoaded())continue;const s=n.getBucket(r);if(!s)continue;t.prepareDrawTile();const a=s.programConfigurations.get(r.id),h=t.isTileAffectedByFog(o),g=t.getOrCreateProgram(A,{config:a,defines:d?[...C,"ELEVATED"]:C,overrideFog:h});if(E&&n.imageAtlas){const e=n.imageAtlas.patternPositions[E.toString()];e&&a.setConstantPatternPositions(e)}if(!T&&v&&b&&n.lineAtlas){const e=n.lineAtlas.getDash(v,b);e&&a.setConstantPatternPositions(e)}let[x,w]=r.paint.get("line-trim-offset");if("round"===b||"square"===b){const e=1;x!==w&&(0===x&&(x-=e),1===w&&(w+=e))}const D=m?o.projMatrix:null,L=T?e.bU(t,n,r,D,_,[x,w]):e.bV(t,n,r,D,s.lineClipsArray.length,_,[x,w]);if(I){const n=s.gradients[r.id];let a=n.texture;if(r.gradientVersion!==n.version){let l=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<{null!=P&&(P.value=S*l),g.draw(t,u.TRIANGLES,p,i,f,e.af.disabled,L,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,t.transform.zoom,a,[s.layoutVertexBuffer2,s.patternVertexBuffer,s.zOffsetVertexBuffer]),null!=P&&(P.value=S)};if(M&&!d){const i=t.stencilModeForClipping(o).ref;0===i&&m&&c.clear({stencil:0});const r={func:u.EQUAL,mask:255};L.u_alpha_discard_threshold=.8,R(new e.ag(r,i,255,u.KEEP,u.KEEP,u.INVERT)),L.u_alpha_discard_threshold=0,R(new e.ag(r,i,255,u.KEEP,u.KEEP,u.KEEP))}else M&&d&&(L.u_alpha_discard_threshold=.001),R(d?z:t.stencilModeForClipping(o))}M&&(t.resetStencilClippingMasks(),m&&c.clear({stencil:0})),0===l||t.depthOcclusion||m||t.layersWithOcclusionOpacity.push(t.currentLayer),d&&(t.forceTerrainMode=!1)},fill:function(t,i,r,n){const o=r.paint.get("fill-color"),s=r.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=r.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.C.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const o=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.ae.ReadWrite:e.ae.ReadOnly);kr(t,i,r,n,o,l,!1)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const o=t.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,e.ae.ReadOnly);kr(t,i,r,n,o,l,!0)}},"fill-extrusion":function(t,i,r,n){const o=r.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const u=t.conflationActive&&t.style.isLayerClipped(r,i.getSource()),h=t.style.order.indexOf(r.fqid);if(u&&(function(e,t,i,r,n){for(const o of r){const r=t.getTile(o).getBucket(i);r&&(r.updateReplacement(o,e.replacementSource,n),r.uploadCentroid(e.context))}})(t,i,r,n,h),l||u)for(const e of n){const n=i.getTile(e).getBucket(r);n&&Fr(t.context,i,e,n,r,l,u)}if("shadow"===t.renderPass&&t.shadowRenderer){const s=t.shadowRenderer;if(l&&o<.65&&r._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.Z)return;const a=s.getShadowPassDepthMode(),c=s.getShadowPassColorMode();Or(t,i,r,n,a,e.ag.disabled,c,u)}else if("translucent"===t.renderPass){const h=!r.paint.get("fill-extrusion-pattern").constantOr(1),d=r.paint.get("fill-extrusion-color").constantOr(e.C.white);if(!c&&0!==d.a){const s=new e.ae(t.context.gl.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D);1===o&&h?Or(t,i,r,n,s,e.ag.disabled,e.a.unblended,u):(Or(t,i,r,n,s,e.ag.disabled,e.a.disabled,u),Or(t,i,r,n,s,t.stencilModeFor3D(),t.colorModeForRenderPass(),u),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&h&&(!l&&"globe"!==t.transform.projection.name||c)){const o=r.paint.get("fill-extrusion-opacity"),h=r.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=r.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=r.paint.get("fill-extrusion-flood-light-intensity"),f=r.paint.get("fill-extrusion-flood-light-color").toRenderColor(r.lut).toArray01().slice(0,3),m=h>0&&d>0,_=p>0,g=(e,t,i)=>(1-i)*e+i*t,y=s=>{const l=t.depthModeForSublayer(1,e.ae.ReadOnly,a.LEQUAL,!0),c=r.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),m=g(.1,3,c),_=t._showOverdrawInspector;if(!_){const c=new e.ag({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),_=new e.a([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0],a.MIN);Br(t,i,r,n,l,c,_,e.af.disabled,s,"sdf",o,h,d,p,f,m,u,!1)}{const c=_?e.ag.disabled:new e.ag({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=_?t.colorModeForRenderPass():new e.a([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.C.transparent,[!0,!0,!0,!0]);Br(t,i,r,n,l,c,g,e.af.disabled,s,"color",o,h,d,p,f,m,u,!1)}};if(c){const c=(s,l,c)=>{const m=t.depthModeForSublayer(1,e.ae.ReadOnly,a.LEQUAL,!1),_=r.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),y=g(.1,3,_);{const c=new e.a([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0]);Br(t,i,r,n,m,e.ag.disabled,c,e.af.disabled,s,"clear",o,h,d,p,f,y,u,l)}{const c=new e.ag({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),_=new e.a([a.ONE,a.ONE,a.ONE,a.ONE],e.C.transparent,[!1,!1,!1,!0],a.MIN);Br(t,i,r,n,m,c,_,e.af.disabled,s,"sdf",o,h,d,p,f,y,u,l)}{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,_=new e.ag({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=new e.a([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.C.transparent,[!0,!0,!0,!0]);Br(t,i,r,n,m,_,g,e.af.disabled,s,"color",o,h,d,p,f,y,u,l)}{const _=new e.a([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.C.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);Br(t,i,r,n,m,e.ag.disabled,_,e.af.disabled,s,"clear",o,h,d,p,f,y,u,l,c)}};if(m||_){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],r=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===r)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(s,new e.i({width:t,height:r}),a.RGBA)),i.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,t,r,0)}m&&c(!0,!1,i),_&&c(!1,!0,i)}}else m&&y(!0),_&&y(!1)}}},hillshade:function(t,i,r,n){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;if(t.style.disableElevatedTerrain)return;const o=t.context,s=t.terrain&&t.terrain.renderingToTexture,[a,l]="translucent"!==t.renderPass||s?[{},n]:t.stencilConfigForOverlap(n);for(const n of l){const o=i.getTile(n);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)Ft(t,o,r);else if("translucent"===t.renderPass){const i=t.depthModeForSublayer(0,e.ae.ReadOnly),l=r.paint.get("hillshade-emissive-strength"),c=t.colorModeForDrapableLayerRenderPass(l),u=s&&t.terrain?t.terrain.stencilModeForRTTOverlap(n):a[n.overscaledZ];Ot(t,n,o,r,i,u,c)}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,i,r,n,o,s){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==r.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const u=t.context,h=u.gl,d=i.getSource(),p=(function(t,i,r,n){const o=i.paint.get("raster-color"),s="raster-array"===t.type,a=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let u=i.paint.get("raster-color-range");const h=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?n.NEAREST:n.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=n.NEAREST,!u&&t.rasterLayers)){const e=t.rasterLayers.find((({id:e})=>e===i.sourceLayer));e&&e.fields&&e.fields.range&&(u=e.fields.range)}if(u=u||[0,1],o){a.push("RASTER_COLOR"),r.activeTexture.set(n.TEXTURE2),i.updateColorRamp(u);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(r,i.colorRamp,n.RGBA)),t.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:h,range:u,offset:d,defines:a,resampling:p}})(d,r,u,h);if(d instanceof e.bm&&!n.length&&!a)return;const f=r.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(f),_=t.terrain&&t.terrain.renderingToTexture,g=!t.options.moving,y="nearest"===r.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(d instanceof e.bm&&!n.length&&(d.onNorthPole||d.onSouthPole)){const n=l?t.stencilModeFor3D():e.ag.disabled;return void qr(!!d.onNorthPole,null,t,i,r,f,p,e.af.disabled,n)}if(!n.length)return;const[x,v]=d instanceof e.bm||_?[{},n]:t.stencilConfigForOverlap(n),b=v[v.length-1].overscaledZ;c&&p.defines.push("PROJECTION_GLOBE_VIEW"),l&&p.defines.push("RENDER_CUTOFF");const w=(n,o,v)=>{for(const w of n){const n=w.toUnwrapped(),T=i.getTile(w);if(_&&(!T||!T.hasData()))continue;u.activeTexture.set(h.TEXTURE0);const E=$r(T,d,r,p);if(!E||!E.texture)continue;const{texture:S,mix:M,offset:I,tileSize:A,buffer:C}=E;let P,z;_?(P=e.ae.disabled,z=w.projMatrix):l?(P=new e.ae(h.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D),z=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(n,g)):(P=t.depthModeForSublayer(w.overscaledZ-b,1===r.paint.get("raster-opacity")?e.ae.ReadWrite:e.ae.ReadOnly,h.LESS),z=t.transform.calculateProjMatrix(n,g));const D=t.terrain&&_?t.terrain.stencilModeForRTTOverlap(w):x[w.overscaledZ],L=s?0:r.paint.get("raster-fade-duration");T.registerFadeDuration(L);const R=i.findLoadedParent(w,0),k=Ri(T,R,i,t.transform,L);let O,B;t.terrain&&t.terrain.prepareDrawTile(),u.activeTexture.set(h.TEXTURE0),S.bind(y,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE1),R?(R.texture&&R.texture.bind(y,h.CLAMP_TO_EDGE),O=Math.pow(2,R.tileID.overscaledZ-T.tileID.overscaledZ),B=[T.tileID.canonical.x*O%1,T.tileID.canonical.y*O%1]):S.bind(y,h.CLAMP_TO_EDGE),S.useMipmap&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const F=t.transform;let N;const V=l?Zr(F):[0,0,0,0];let U,j,G,q,Z,$=0;if(c&&d instanceof e.bm&&d.coordinates.length>3)U=Float32Array.from(e.bf(e.bg(new e.aO(0,0,0)))),j=Float32Array.from(F.globeMatrix),G=Float32Array.from(e.bb(F)),q=[e.aj(F.center.lng),e.ak(F.center.lat)],N=d.elevatedGlobePerspectiveTransform,Z=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.bc(w.canonical);$=e.bd(t.getCenter().lat),U=Float32Array.from(e.bf(e.bg(w.canonical))),j=Float32Array.from(F.globeMatrix),G=Float32Array.from(e.bb(F)),q=[e.aj(F.center.lng),e.ak(F.center.lat)],N=[0,0],Z=Float32Array.from(e.be(w.canonical,t,$,F.worldSize/F._pixelsPerMercatorPixel))}else N=d instanceof e.bm?d.perspectiveTransform:[0,0],U=new Float32Array(16),j=new Float32Array(9),G=new Float32Array(16),q=[0,0],Z=new Float32Array(9);const W=ar(z,U,j,G,Z,B||[0,0],e.a1(t.transform.zoom),q,V,O||1,k,r,N,l?r.paint.get("raster-elevation"):0,2,M,I,p.range,A,C,f),H=t.isTileAffectedByFog(w),X=t.getOrCreateProgram("raster",{defines:p.defines,overrideFog:H});if(t.uploadCommonUniforms(u,X,n),d instanceof e.bm){const i=d.elevatedGlobeVertexBuffer,n=d.elevatedGlobeIndexBuffer;if(_||!a)d.boundsBuffer&&d.boundsSegments&&X.draw(t,h.TRIANGLES,P,e.ag.disabled,m,e.af.disabled,W,r.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&n){const s=F.zoom<=e.b1?d.elevatedGlobeSegments:d.getSegmentsForLongitude(F.center.lng);s&&X.draw(t,h.TRIANGLES,P,e.ag.disabled,m,o,W,r.id,i,n,s)}}else if(c){P=new e.ae(h.LEQUAL,e.ae.ReadOnly,t.depthRangeFor3D);const i=t.globeSharedBuffers;if(i){const[e,n,s]=i.getGridBuffers($,!1);X.draw(t,h.TRIANGLES,P,v||D,t.colorModeForRenderPass(),o,W,r.id,e,n,s)}}else{const{tileBoundsBuffer:i,tileBoundsIndexBuffer:n,tileBoundsSegments:o}=t.getTileBoundsBuffers(T);X.draw(t,h.TRIANGLES,P,D,m,e.af.disabled,W,r.id,i,n,o)}}if(!(d instanceof e.bm)&&c)for(const s of n){const n=s.canonical.y===(1<>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},n=.7692307692307692;for(let e=0;ee.bZ[t](n)));f.push(n);const m=n.canonical.x,_=n.canonical.y;for(const o of f){const a=i.getTile(l?o.wrapped():o);if(!a)continue;const u=a.rasterParticleState;if(!u)continue;const d=o.canonical.x+(1<e.tileID))),d&&(l.activeTexture.set(c.TEXTURE0),t.imageManager.bind(t.context,r.scope));for(const f of v){const v=t.isTileAffectedByFog(f),b=t.getOrCreateProgram(y,{overrideFog:v}),w=f.toUnwrapped(),T=n?f.projMatrix:t.transform.calculateProjMatrix(w);t.prepareDrawTile();const E=i?i.getTile(f):x?x[f.key]:new e.by(f,h,u.zoom,t),S=d?yr(T,a,s,t,0,r.scope,p,{tileID:f,tileSize:h}):gr(T,a,s,o.toRenderColor(r.lut));t.uploadCommonUniforms(l,b,w);const{tileBoundsBuffer:M,tileBoundsIndexBuffer:I,tileBoundsSegments:A}=t.getTileBoundsBuffers(E);b.draw(t,c.TRIANGLES,_,m,g,e.af.disabled,S,r.id,M,I,A)}},sky:function(t,i,r){const n=t._atmosphere?e.a1(t.transform.zoom):1,o=r.paint.get("sky-opacity")*n;if(0===o)return;const s=t.context,a=r.paint.get("sky-type"),l=new e.ae(s.gl.LEQUAL,e.ae.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&((function(t,i,r,n){const o=t.context,s=o.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=o.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new ln(o),i.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let e=0;e<6;++e)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=i.getCenter(t,!0),c=t.getOrCreateProgram("skyboxCapture"),u=new Float64Array(16);e.ad.identity(u),e.ad.rotateY(u,u,.5*-Math.PI),cn(t,i,c,u,l,0),e.ad.identity(u),e.ad.rotateY(u,u,.5*Math.PI),cn(t,i,c,u,l,1),e.ad.identity(u),e.ad.rotateX(u,u,.5*-Math.PI),cn(t,i,c,u,l,2),e.ad.identity(u),e.ad.rotateX(u,u,.5*Math.PI),cn(t,i,c,u,l,3),e.ad.identity(u),cn(t,i,c,u,l,4),e.ad.identity(u),e.ad.rotateY(u,u,Math.PI),cn(t,i,c,u,l,5),o.viewport.set([0,0,t.width,t.height])})(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&(function(t,i,r,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const u=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(l.skyboxMatrix,i.getCenter(t,!1),0,n,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,r,e.ag.disabled,t.colorModeForRenderPass(),e.af.backCW,u,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)})(t,r,l,o,c):"gradient"===a&&"sky"===t.renderPass&&(function(t,i,r,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new ln(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new e.T(s,i.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,i,r,n,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.ab(r),u_opacity:n,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),n,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,r,e.ag.disabled,t.colorModeForRenderPass(),e.af.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)})(t,r,l,o,c)},debug:function(t,i,r,n,o,s){for(let a=0;a{a&&(a.useNormalOffset=!0,l||(a.enabled=!0))},u=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==u.type)return;if("vector"===u.type||"geojson"===u.type)return(function(t,i,r,n,o){const s=t.transform;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D models for ${s.projection.name} projection is not yet implemented`);const a=s.getFreeCameraOptions().position;if(!t.modelManager)return;const l=t.modelManager;r.modelManager=l;const c=t.shadowRenderer;if(!r._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const u=r._unevaluatedLayout._values["model-id"],d=h({},r.layout.get("model-id").parameters),p=t.style.order.indexOf(r.fqid);for(const h of n){const n=i.getTile(h).getBucket(r);if(!n||n.projection.name!==s.projection.name)continue;const f=n.getModelUris();f&&!n.modelsRequested&&(l.addModelsFromBucket(f,o),n.modelsRequested=!0);const m=wn(h,s);d.zoom=m;const _=u.possiblyEvaluate(d);if(vn(t,n,h),bn.shadowUniformsInitialized=!1,bn.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(h.toUnwrapped()),"shadow"===t.renderPass&&c){if(1===t.currentShadowCascade&&n.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(h.toUnwrapped(),s.worldSize);if(bn.tileMatrix.set(i),bn.shadowTileMatrix=Float32Array.from(c.calculateShadowPassMatrixFromMatrix(i)),bn.aabb.min.fill(0),bn.aabb.max[0]=bn.aabb.max[1]=e.a3,bn.aabb.max[2]=0,Sn(n,bn,t,r.scope))continue}const g=1<0&&t.style.isLayerClipped(r,i.getSource())&&n.updateReplacement(h,t.replacementSource,p)&&(n.uploaded=!1,n.upload(t.context));for(let e in n.instancesPerModel){const i=n.instancesPerModel[e];i.features.length>0&&(e=_.evaluate(i.features[0].feature,{}));const s=l.getModel(e,o);if(s&&s.uploaded)for(const e of s.nodes)Tn(t,r,e,i,y,h,bn)}}})(t,i,r,n,"vector"===u.type?r.scope:""),void c();if(!u.loaded())return;if("batched-model"===u.type)return(function(t,i,r,n){r.resetLayerRenderingStats(t);const o=t.context,s=t.transform,a=t.style.fog,l=t.shadowRenderer;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D landmark models for ${s.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,u=e._.scale([],[c.x,c.y,c.z],t.transform.worldSize);e._.negate(u,u);const h=e.ad.identity([]),d=e.cg(s.center.lat,s.zoom),p=e.ad.fromScaling([],[1,1,1/d]);e.ad.translate(h,h,u);const f=r.paint.get("model-opacity"),m=new e.ae(o.gl.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D),_=new e.ae(o.gl.LEQUAL,e.ae.ReadOnly,t.depthRangeFor3D),g=new e.b6([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),y="shadow"===t.renderPass,x=y&&l?l.getCurrentCascadeFrustum():s.getFrustum(s.scaleZoom(s.worldSize)),v=r.paint.get("model-front-cutoff"),b=v[2]<1,w=xi(t,r.paint.get("model-cutoff-fade-range")),T=r.getLayerRenderingStats();(function(e,t,i,r){const n=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const s of r){const r=t.getTile(s).getBucket(i);r&&(e.conflationActive&&r.updateReplacement(s,e.replacementSource),r.evaluateScale(e,i),e.terrain&&n>0&&r.elevationUpdate(e.terrain,n,s,i.source),r.needsReEvaluation(e,o,i)&&r.evaluate(i))}})(t,i,r,n),(function(){let c,u,d;b?(c=n.length-1,u=-1,d=-1):(c=0,u=n.length,d=1);for(let E=c;E!==u;E+=d){const c=n[E],u=i.getTile(c).getBucket(r);if(!u||!u.uploaded)continue;let d=!1;l&&(d=0===l.getMaxCascadeForTile(c.toUnwrapped()));const S=s.calculatePosMatrix(c.toUnwrapped(),s.worldSize),M=u.modelTraits,I=[];for(const i of u.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const r=i.node;let n=0;t.terrain&&r.elevation&&(n=r.elevation*t.terrain.exaggeration());const o=i.evaluatedScale;if(o[0]<=1&&o[1]<=1&&o[2]<=1&&0===(()=>{const t=i.aabb;return g.min=[...t.min],g.max=[...t.max],g.min[2]+=n,g.max[2]+=n,e._.transformMat4(g.min,g.min,S),e._.transformMat4(g.max,g.max,S),g})().intersects(x))continue;const a=[...S],l=r.anchor?r.anchor[0]:0,c=r.anchor?r.anchor[1]:0;e.ad.translate(a,a,[l*(o[0]-1),c*(o[1]-1),n]),e._.exactEquals(o,e.cj)||e.ad.scale(a,a,o);const u=e.ad.multiply([],a,r.matrix),h=e.ad.multiply([],s.expandedFarZProjMatrix,u),d=e.ad.multiply([],s.expandedFarZProjMatrix,a),p=e.aA.transformMat4([],[l,c,n,1],h)[2];r.hidden=!1;let m=f;y||(b&&(m*=In(a,s,i.aabb,v)),m*=Mn(w,p)),0!==m?I.push({nodeInfo:i,depth:p,opacity:m,wvpForNode:h,wvpForTile:d,nodeModelMatrix:u,tileModelMatrix:a}):r.hidden=!0}y||I.sort(((e,t)=>!b||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1));for(const i of I){const n=i.nodeInfo,c=n.node;let u=e.ad.multiply([],p,i.tileModelMatrix);e.ad.multiply(u,h,u);const f=e.ad.invert([],u);e.ad.transpose(f,f),e.ad.scale(f,f,En),u=e.ad.multiply(u,u,c.matrix);const g="light-beam"===t.renderPass,x=M&e.cl.HasMapboxMeshFeatures,v=x?0:n.evaluatedRMEA[0][2];for(let h=0;h=ot||n>=ot}}const I=p.material;let A;I.occlusionTexture&&I.occlusionTexture.offsetScale&&(A=I.occlusionTexture.offsetScale,E.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!y&&l&&(l.useNormalOffset=!!p.normalBuffer);const C=t.getOrCreateProgram("model",E);!y&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,C,l.useNormalOffset),t.uploadCommonUniforms(o,C,null,M);const P=I.pbrMetallicRoughness;P.metallicFactor=.9,P.roughnessFactor=.5;const z=vr(new Float32Array(w),new Float32Array(u),new Float32Array(f),new Float32Array(c.matrix),t,i.opacity,P.baseColorFactor.toRenderColor(null),I.emissiveFactor,P.metallicFactor,P.roughnessFactor,I,v,r,[0,0,0],A);!b&&(n.hasTranslucentParts||i.opacity<1)&&C.draw(t,o.gl.TRIANGLES,m,e.ag.disabled,e.a.disabled,e.af.backCCW,z,r.id,p.vertexBuffer,p.indexBuffer,p.segments,r.paint,t.transform.zoom,void 0,S),C.draw(t,o.gl.TRIANGLES,b?_:m,e.ag.disabled,b||i.opacity<1||n.hasTranslucentParts?e.a.alphaBlended:e.a.unblended,e.af.backCCW,z,r.id,p.vertexBuffer,p.indexBuffer,p.segments,r.paint,t.transform.zoom,void 0,S)}}}})()})(t,i,r,n),void c();const d=u.getModels(),p=[],f=t.transform.getFreeCameraOptions().position,m=e._.scale([],[f.x,f.y,f.z],t.transform.worldSize);e._.negate(m,m);const _=[],g=[];let y=0;for(const i of d){const n=r.paint.get("model-rotation").constantOr(null),o=r.paint.get("model-scale").constantOr(null),s=r.paint.get("model-translation").constantOr(null);i.computeModelMatrix(t,n,o,s,!0,!0,!1);const a=e.ad.identity([]),l=e.cg(i.position.lat,t.transform.zoom),c=e.ad.fromScaling([],[1,1,1/l]);e.ad.translate(a,a,m),p.push({zScaleMatrix:c,negCameraPosMatrix:a});for(const e of i.nodes)yn(t.transform,e,i.matrix,t.transform.expandedFarZProjMatrix,y,_,g);y++}if(_.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass){if(1===o)for(const i of g)gn(i,t,r,p[i.modelIndex],e.ag.disabled,t.colorModeForRenderPass());else{for(const i of g)gn(i,t,r,p[i.modelIndex],e.ag.disabled,e.a.disabled);for(const e of g)gn(e,t,r,p[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks()}for(const i of _)gn(i,t,r,p[i.modelIndex],e.ag.disabled,t.colorModeForRenderPass());c()}else{for(const e of g)xn(e.mesh,e.nodeModelMatrix,t,r);for(const e of _)xn(e.mesh,e.nodeModelMatrix,t,r);c()}}},Ln={model:function(e,t,i){const r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(i.modelManager&&i.modelManager.upload(i,"vector"===r.type?e.scope:""));if("batched-model"===r.type)return;const n=r.getModels();for(const e of n)e.upload(i.context)},raster:function(e,t,i){const r=t.getSource();if(!(r instanceof ki&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&r.prepareTile(e,n,o)},"raster-particle":function(e,t,i){const r=t.getSource();if(!(r instanceof ki&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-particle-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&r.prepareTile(e,n,o)}};class Rn{constructor(t,i,r,n){this.context=new le(t,i),this.occlusionBuffers=new zn(this.context),this.transform=r,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=n,this._timeStamp=e.e.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const o=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(const e of o)this._debugParams.enabledLayers[e]=!0;n.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(()=>{this.style.map.triggerRepaint()})),n.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),n.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),n.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),n.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of o)n.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.symbolParams=new ue(n),this.setup(),this.numSublayers=e.bv.maxUnderzooming+e.bv.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.co,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new Ti(this),this._wireframeDebugCache=new Cn,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[]}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Ui(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.enabled&&(this.transform.elevation=null)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new Ui(this,this.style)),this._forceTerrainMode=e}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.e.devicePixelRatio,this.height=i*e.e.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize()}setup(){const t=this.context,i=new e.bt;i.emplaceBack(0,0),i.emplaceBack(e.a3,0),i.emplaceBack(0,e.a3),i.emplaceBack(e.a3,e.a3),this.tileExtentBuffer=t.createVertexBuffer(i,e.br.members),this.tileExtentSegments=e.b.simpleSegment(0,0,4,2);const r=new e.bt;r.emplaceBack(0,0),r.emplaceBack(e.a3,0),r.emplaceBack(0,e.a3),r.emplaceBack(e.a3,e.a3),this.debugBuffer=t.createVertexBuffer(r,e.br.members),this.debugSegments=e.b.simpleSegment(0,0,4,5);const n=new e.bt;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.br.members),this.viewportSegments=e.b.simpleSegment(0,0,4,2);const o=new e.cp;o.emplaceBack(0,0,0,0),o.emplaceBack(e.a3,0,e.a3,0),o.emplaceBack(0,e.a3,0,e.a3),o.emplaceBack(e.a3,e.a3,e.a3,e.a3),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.cq.members),this.mercatorBoundsSegments=e.b.simpleSegment(0,0,4,2);const s=new e.bu;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.cr;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.i({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.ad.create();const l=this.context.gl;this.stencilClearMode=new e.ag({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,t.TRIANGLES,e.ae.disabled,this.stencilClearMode,e.a.disabled,e.af.disabled,Li(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,i,r){if(!i||this.currentStencilSource===i.id||!t.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of r)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=i.id;const n=this.context,o=n.gl;this.nextStencilID+r.length>256&&this.clearStencil(),n.setColorMode(e.a.disabled),n.setDepthMode(e.ae.disabled);const s=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of r){const r=i.getTile(t),n=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:a,tileBoundsIndexBuffer:l,tileBoundsSegments:c}=this.getTileBoundsBuffers(r);s.draw(this,o.TRIANGLES,e.ae.disabled,new e.ag({func:o.ALWAYS,mask:0},n,255,o.KEEP,o.KEEP,o.REPLACE),e.a.disabled,e.af.disabled,Li(t.projMatrix),"$clipping",a,l,c)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,i=this.context.gl;return new e.ag({func:i.NOTEQUAL,mask:255},t,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const i=this.context.gl;return new e.ag({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(t){const i=this.context.gl,r=t.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),n=r[r.length-1].overscaledZ,o=r[0].overscaledZ-n+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let r=0;rthis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new e.a([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.C(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(t,i,r,n=!1){if(this.depthOcclusion)return new e.ae(this.context.gl.GREATER,e.ae.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!n)return e.ae.disabled;const o=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new e.ae(r||this.context.gl.LEQUAL,i,[o,o])}opaquePassEnabledForLayer(){return this.currentLayerthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce(((e,t)=>e+t/this._fpsHistory.length),0))}render(t,i){const r=e.e.now();this._dt=r-this._timeStamp,this._timeStamp=r,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const n=this.style._mergedLayers,o=this.style.order.filter((e=>{const t=n[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]})),s=o.map((e=>n[e])),a=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.e.now()),this.imageManager.beginFrame();let l=0,c=!1;for(const e in a){const t=a[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++l)}let u=!1;for(const e of s)e.isHidden(this.transform.zoom)||("clip"===e.type&&(u=!0),this.prepareLayer(e));const h={},d={},p={},f={},m={};for(const e in a){const t=a[e];h[e]=t.getVisibleCoordinates(),d[e]=h[e].slice().reverse(),p[e]=t.getVisibleCoordinates(!0).reverse(),f[e]=t.getShadowCasterCoordinates(),m[e]=t.sortCoordinatesByDistance(h[e])}const _=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(l||u){const t=[],i=[];let r=0;for(const e of s)this.isSourceForClippingOrConflation(e,_(e))&&(t.push(e),i.push(r)),r++;if(u||t.length>1){const r=[];for(let n=0;n0){const e=_(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom))}t.is3D()&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e)}const g=this.style&&this.style.fog;g?(this._fogVisible=0!==g.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=g.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(p),this.opaquePassCutoff=0);const y=this._shadowRenderer;if(y){y.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in a)for(const t of h[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),y.addShadowReceiver(t.toUnwrapped(),e.min,e.max)}}if("globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.cs(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new fn(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),!e.ct(this.context.gl))return;this.renderPass="offscreen";for(const e of s){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const r=i?d[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||r&&r.length)&&this.renderLayer(this,i,e,r)}this.depthRangeFor3D=[0,1-(s.length+2)*this.numSublayers*this.depthEpsilon];const x=this.terrain;x&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&!this.transform.isOrthographic&&x.drawDepth(),this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,f)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const v="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),b=(()=>{if(i.showOverdrawInspector)return e.C.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!v){const r=t.properties.get("color").toRenderColor(i).toArray01();return new e.C(...r)}if(v){const r=t.properties.get("space-color").toRenderColor(i).toArray01();return new e.C(...r)}}return e.C.transparent})();if(this.context.clear({color:b,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&v&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=s[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const r=i?(e.is3D()?m:d)[i.id]:void 0;this._renderTileClippingMasks(e,i,r),this.renderLayer(this,i,e,r)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&v&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.a1(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--T&&(y.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=s[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?d[i.id]:void 0)}this.currentLayer=e,this.renderPass="translucent"}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=s[this.currentLayer],r=t.getLayerSourceCache(i),n=r?d[r.id]:void 0;i.is3D()||this.terrain||this._renderTileClippingMasks(i,r,r?h[r.id]:void 0),this.renderLayer(this,r,i,n)}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;s.forEach((e=>{const r=t.getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const r=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,n=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(n.push("LIGHTING_3D_MODE"),n.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||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||r||void 0!==t&&!t||n.push("FOG","FOG_DITHERING"),r&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],r=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=Zi.cacheKey(zt[e],e,n,r);return this.cache[o]||(this.cache[o]=new Zi(this.context,e,zt[e],r,Tr[e],n)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const r=this.style.directionalLight,n=this.style.ambientLight;if(r&&n){const o=((t,i,r)=>{const n=t.properties.get("direction"),o=t.properties.get("color").toRenderColor(r.getLut(t.scope)).toArray01(),s=t.properties.get("intensity"),a=i.properties.get("color").toRenderColor(r.getLut(i.scope)).toArray01(),l=i.properties.get("intensity"),c=[n.x,n.y,n.z],u=e.bA(a,l),h=e.bA(o,s);return{u_lighting_ambient_color:u,u_lighting_directional_dir:c,u_lighting_directional_color:h,u_ground_radiance:ji(c,h,u)}})(r,n,this.style);i.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,i,r,n,o){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const o=s.getOpacity(this.transform.pitch),a=((t,i,r,n,o,s,a,l,c,u,h,d)=>{const p=t.transform,f=i.properties.get("color").toRenderColor(t.style.getLut(i.scope)).toArray01();f[3]=n;const m=t.frameCounter/1e3%1,[_,g]=i.properties.get("vertical-range");return{u_fog_matrix:r?p.calculateFogTileMatrix(r):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:f,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_,g),g],u_fog_temporal_offset:m,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.a1(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,r,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.e.devicePixelRatio,this.transform.height*e.e.devicePixelRatio],n);i.setFogUniformValues(t,a)}o&&i.setCutoffUniformValues(t,o.uniformValues)}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,i=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const n of r)i[n.key]=t[n.key]||new e.by(n,512,this.transform.tileZoom,this);return i}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(e,t){return!(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerIndices.length||"building"!==e.sourceLayer)&&"clip"!==e.type&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=ot||t[1]>=ot}}class kn{constructor(e,t,i,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(t,i){let r,n;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);r=[o],n=i.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),s=e.P.convert(t[1]);r=[o,s],n=e.cv(o,s).every((e=>i.isPointAboveHorizon(e)))}return new kn(r,i.getCameraPoint(),n,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.cv(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.cv(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=r.x?n[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(n[3]=this.cameraPoint)),e.cw(n,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.cv(i,r,t),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>r.y))+((o.x>i.x)+(o.x>r.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(t,i,r,n=0){const o=t.queryPadding/i._pixelsPerMercatorPixel+1,s=r?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=t.tileID.wrap+(s.unwrapped?n:0);const l=s.polygon.map((i=>e.cx(t.tileTransform,i,a)));if(!e.cy(l,0,0,e.a3,e.a3))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map((i=>e.cz(t.tileTransform,i,a))),u=c.map((t=>new e.P(t[0],t[1]))),h=i.getFreeCameraOptions().position||new e.Y(0,0,0),d=e.cz(t.tileTransform,h,a),p=c.map((t=>{const i=e._.sub(t,t,d);return e._.normalize(i,i),new e.aT(d,i)})),f=e.bB(t,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.cA(l),m.min.x=e.at(m.min.x,0,e.a3),m.min.y=e.at(m.min.y,0,e.a3),m.max.x=e.at(m.max.x,0,e.a3),m.max.y=e.at(m.max.y,0,e.a3),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=Fn(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=Fn(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(t,i){const r=(function(t,i){const r=e.ad.multiply([],i.pixelMatrix,i.globeMatrix),n=[0,-e.cD,0,1],o=[0,e.cD,0,1],s=[0,0,0,1];e.aA.transformMat4(n,n,r),e.aA.transformMat4(o,o,r),e.aA.transformMat4(s,s,r);const a=new e.P(n[0]/n[3],n[1]/n[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.cB(t,a)&&n[3]1?On(t.slice(0,d),i):[],m=dnew e.P(Bn(t.x),t.y))),m=m.map((t=>new e.P(Bn(t.x),t.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=e.a2(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,p);let y;return y=c?[new e.P(0,g),new e.P(0,0),new e.P(1,0),new e.P(1,g)]:[new e.P(1,g),new e.P(1,1),new e.P(0,1),new e.P(0,g)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((t=>new e.Y(t.x,t.y))),unwrapped:!1}})(t,i);if(r)return r;const n=(function(t,i){let r=!1,n=-1/0,o=0;for(let e=0;en&&(n=t[e].x,o=e);for(let e=0;e.5&&(n.x{e.x-=1})),{polygon:t,unwrapped:r}})(On(t,i).map((t=>new e.P(Bn(t.x),t.y))),i);return{polygon:n.polygon.map((t=>new e.Y(t.x,t.y))),unwrapped:n.unwrapped}}}function On(t,i){return e.cC(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),.00390625)}function Bn(e){return e<0?1+e%1:e%1}function Fn(e){return 100*e|0}function Nn(t,i){const r=e.ad.identity([]);return e.ad.scale(r,r,[.5*t.width,.5*-t.height,1]),e.ad.translate(r,r,[1,-1,0]),e.ad.multiply(r,r,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(r)}function Vn(e,t,i,r,n,o,s,a=!1){const l=e.tilesIn(r,s,a);l.sort(jn);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r,n,o,Nn(e.transform,r.tile.tileID),a)});const u=(function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t})(c);for(const t in u)u[t].forEach((t=>{const i=t.feature,r=i.layer;r&&"background"!==r.type&&"sky"!==r.type&&"slot"!==r.type&&(i.source=r.source,r["source-layer"]&&(i.sourceLayer=r["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(r["source-layer"],i.id):{})}));return u}function Un(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],n={};for(let e=0;e0:"model"===i.type&&(r=!i.isHidden(e)&&i.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!r&&t.visible,t.visible=r}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,r=this.style.getLayerSourceCache(i);let n=1;"fill-extrusion"===i.type&&(n=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0);let o=r?r.getTile(t):null;if(!o&&r&&t.canonical.z>r.getSource().minzoom){let e=t.scaledTo(Math.min(r.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=r.getSource().minzoom&&(o=r.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:n})}e.hasAnyZOffset=!1;let i=!1;for(let r=0;r{e in i&&(r[e]=i[e])})),r}function Zn(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class to{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let e=0;e0:s}_queryCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const u=this.circleCells[n];if(null!==u){const n=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[u],t=n[u+1],i=n[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[n];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(s-n)/2,u=Math.abs(t-(n+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}const io=100;class ro{constructor(e,t,i=new to(e.width+200,e.height+200,25),r=new to(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+io,this.screenBottomBoundary=e.height+io,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,i,r,n,o,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,u=i.projectedAnchorZ;const h=i.elevation,d=i.tileID,p=e.getProjection();if(h&&d){const[e,t,r]=p.upVector(d.canonical,i.tileAnchorX,i.tileAnchorY),n=p.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*h*n,c+=t*h*n,u+=r*h*n}const f=this.projectAndGetPerspectiveRatio(s,l,c,u,i.tileID,"globe"===p.name||!!h||this.transform.pitch>0,p),m=o*f.perspectiveRatio,_=(i.x1*t+r.x-i.padding)*m+f.point.x,g=(i.y1*t+r.y-i.padding)*m+f.point.y,y=(i.x2*t+r.x+i.padding)*m+f.point.x,x=(i.y2*t+r.y+i.padding)*m+f.point.y,v=f.perspectiveRatio<=.55||f.occluded;return!this.isInsideGrid(_,g,y,x)||!n&&this.grid.hitTest(_,g,y,x,a)||v?{box:[],offscreen:!1,occluded:f.occluded}:{box:[_,g,y,x],offscreen:this.isOffscreen(_,g,y,x),occluded:!1}}placeCollisionCircles(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){const _=[],g=this.transform.elevation,y=t.getProjection(),x=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,v=new e.P(r.tileAnchorX,r.tileAnchorY);let{x:b,y:w,z:T}=y.projectTilePoint(v.x,v.y,m.canonical);if(x){const[e,t,i]=x(v);b+=e,w+=t,T+=i}const E="globe"===y.name,S=this.projectAndGetPerspectiveRatio(a,b,w,T,m,E||!!g||this.transform.pitch>0,y),{perspectiveRatio:M}=S,I=(h?s/M:s*M)/e.bN,A=ri(b,w,T,l),C=S.signedDistanceFromCamera>0?ai(I,o,r.lineOffsetX*I,r.lineOffsetY*I,!1,A,v,r,n,l,{},g&&!h?x:null,h&&!!g,y,m,h):null;let P=!1,z=!1,D=!0;if(C&&!S.occluded){const t=.5*p*M+f,r=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new eo,{first:s,last:a}=C,l=s.path.length;let h=[];for(let e=l-1;e>=1;e--)h.push(s.path[e]);for(let e=1;e(x&&!E&&(i=x(re[3]<=0))&&(h=[]));let g=[];if(h.length>0){let t=1/0,i=-1/0,o=1/0,s=-1/0;for(const e of h)t=Math.min(t,e[0]),o=Math.min(o,e[1]),i=Math.max(i,e[0]),s=Math.max(s,e[1]);i>=r.x&&t<=n.x&&s>=r.y&&o<=n.y&&(g=[h.map((t=>new e.P(t[0],t[1])))],(tn.x||on.y)&&(g=e.cF(g,r.x,r.y,n.x,n.y)))}for(const e of g){o.reset(e,.25*t);let r=0;r=o.length<=.5*t?1:Math.ceil(o.paddedLength/m)+1;for(let e=0;e0){if(e.aA.transformMat4(l,l,t),this.fogState&&o&&"globe"!==a.name){const t=(function(t,i,r,n,o,s){const a=s.calculateFogTileMatrix(o),l=[i,r,n];return e._.transformMat4(l,l,a),st(t,e._.length(l),s.pitch,s._fov)})(this.fogState,i,r,n,o.toUnwrapped(),this.transform);c=t>.9}}else fi(l,l,t);const u=l[3];return{point:new e.P((l[0]/u+1)/2*this.transform.width+io,(-l[1]/u+1)/2*this.transform.height+io),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:s&&l[2]>u||c}}isOffscreen(e,t,i,r){return i=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function uo(t,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=e.bQ(t),l=-(s-.5)*i,c=-(a-.5)*r,u=e.bP(t,n);return new e.P(l+u[0]*o,c+u[1]*o)}function ho(t,i,r,n,o){const s=new e.P(t,i);return r&&s._rotate(n?o:-o),s}class po{constructor(e,t,i,r,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new ro(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new co(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,r,n){const o=r.getBucket(i),s=r.latestFeatureIndex;if(!o||!s||i.fqid!==o.layerIds[0])return;const a=o.layers[0].layout,l=r.collisionBoxArray,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/e.a3,h=r.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(p=r.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(p.toUnwrapped()):Er(m,f,p));var p,f,m;const _="map"===a.get("text-pitch-alignment"),g="map"===a.get("text-rotation-alignment");i.compileFilter();const y=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),v=this.transform.calculatePixelsToTileUnitsMatrix(r),b=ti(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),v);let w=null;if(_){const t=ii(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),v);w=e.ad.multiply([],this.transform.labelPlaneMatrix,t)}let T=null;y&&r.latestFeatureIndex&&(T={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:x,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new lo(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,r.tileID);const E={bucket:o,layout:a,posMatrix:d,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.aD(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.aD(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const e of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:E})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:E})}attemptAnchorPlacement(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,_,g){const{textOffset0:y,textOffset1:x,crossTileID:v}=h,b=[y,x],w=uo(e,i,r,b,n),T=this.collisionIndex.placeCollisionBox(p,n,t,ho(w.x,w.y,o,s,this.transform.angle),u,a,l,c.predicate);if(m){const e=p.getSymbolInstanceIconSize(g,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(p,e,m,ho(w.x,w.y,o,s,this.transform.angle),u,a,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[v]&&this.prevPlacement.placements[v]&&this.prevPlacement.placements[v].text&&(t=this.prevPlacement.variableOffsets[v].anchor),this.variableOffsets[v]={textOffset:b,width:i,height:r,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(p,e,h,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,h),this.placedOrientations[v]=f),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,r,n){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:d,collisionBoxArray:p,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=t.parameters,g=s.get("text-optional"),y=s.get("icon-optional"),x=s.get("text-allow-overlap"),v=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="viewport-y"===s.get("symbol-z-order"),E=s.get("symbol-z-elevate");this.transform.setProjection(o.projection);let S=x&&(v||!o.hasIconData()||y),M=v&&(x||!o.hasTextData()||g);!o.collisionArrays&&p&&o.deserializeCollisionBoxes(p),r&&n&&o.updateCollisionDebugBuffers(this.transform.zoom,p);const I=(t,n,p)=>{const{crossTileID:T,numVerticalGlyphVertices:E}=t;if(u){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let n=null;if(u.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];n=u.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(r,n,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[T]=new so(!1,!1,!1,!0),void i.add(T)}if(i.has(T))return;if(d)return void(this.placements[T]=new so(!1,!1,!1));let I=!1,A=!1,C=!0,P=!1,z=!1,D=null,L={box:null,offscreen:null,occluded:null},R={box:null,offscreen:null,occluded:null},k=null,O=null,B=null,F=0,N=0,V=0;p.textFeatureIndex?F=p.textFeatureIndex:t.useRuntimeCollisionCircles&&(F=t.featureIndex),p.verticalTextFeatureIndex&&(N=p.verticalTextFeatureIndex);const U=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const i=this.transform.elevation;e.elevation=t.zOffset+(i?i.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0)},j=p.textBox;if(j){U(j);const i=i=>{let r=e.aE.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[T];e&&(this.placedOrientations[T]=e,r=e,this.markUsedOrientation(o,r,t))}return r},r=(t,i)=>{if(o.allowVerticalPlacement&&E>0&&p.verticalTextBox){for(const r of o.writingModes)if(r===e.aE.vertical?(L=i(),R=L):L=t(),L&&L.box&&L.box.length)break}else L=t()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor))}const c=(e,i,r)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),c=(e.x2-e.x1)*s+2*e.padding,u=(e.y2-e.y1)*s+2*e.padding,d=t.hasIconTextFit&&!v?i:null;d&&U(d);let p={box:[],offscreen:!1,occluded:!1};const g=x?2*l.length:l.length;for(let i=0;i=l.length,t,n,o,r,d,f,m);if(g&&(p=g.placedGlyphBoxes,p&&p.box&&p.box.length)){I=!0,D=g.shift;break}}return p};r((()=>c(j,p.iconBox,e.aE.horizontal)),(()=>{const t=p.verticalTextBox;return t&&U(t),o.allowVerticalPlacement&&!(L&&L.box&&L.box.length)&&E>0&&t?c(t,p.verticalIconBox,e.aE.vertical):{box:null,offscreen:null,occluded:null}})),L&&(I=L.box,C=L.offscreen,P=L.occluded);const u=i(!(!L||!L.box));if(!I&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[T];e&&(this.variableOffsets[T]=e,this.markUsedJustification(o,e.anchor,t,u))}}else{const s=(i,r)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(o,s,i,new e.P(0,0),x,h,a,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,r,t),this.placedOrientations[T]=r),l};r((()=>s(j,e.aE.horizontal)),(()=>{const t=p.verticalTextBox;return o.allowVerticalPlacement&&E>0&&t?(U(t),s(t,e.aE.vertical)):{box:null,offscreen:null,occluded:null}})),i(!!(L&&L.box&&L.box.length))}}if(k=L,I=k&&k.box&&k.box.length>0,C=k&&k.offscreen,P=k&&k.occluded,t.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),n=e.aF(o.textSizeData,f,i),u=s.get("text-padding");O=this.collisionIndex.placeCollisionCircles(o,x,i,o.lineVertexArray,o.glyphOffsetArray,n,a,l,c,r,w,_.predicate,t.collisionCircleDiameter*n/e.bN,u,this.retainedQueryData[o.bucketInstanceId].tileID),I=x||O.circles.length>0&&!O.collisionDetected,C=C&&O.offscreen,P=O.occluded}if(p.iconFeatureIndex&&(V=p.iconFeatureIndex),p.iconBox){const i=i=>{U(i);const r=t.hasIconTextFit&&D?ho(D.x,D.y,b,w,this.transform.angle):new e.P(0,0),n=o.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,n,i,r,v,h,a,_.predicate)};R&&R.box&&R.box.length&&p.verticalIconBox?(B=i(p.verticalIconBox),A=B.box.length>0):(B=i(p.iconBox),A=B.box.length>0),C=C&&B.offscreen,z=B.occluded}const G=g||0===t.numHorizontalGlyphVertices&&0===E,q=y||0===t.numIconVertices;if(G||q?q?G||(A=A&&I):I=A&&I:A=I=A&&I,I&&k&&k.box&&this.collisionIndex.insertCollisionBox(k.box,s.get("text-ignore-placement"),o.bucketInstanceId,R&&R.box&&N?N:F,_.ID),A&&B&&this.collisionIndex.insertCollisionBox(B.box,s.get("icon-ignore-placement"),o.bucketInstanceId,V,_.ID),O&&(I&&this.collisionIndex.insertCollisionCircles(O.circles,s.get("text-ignore-placement"),o.bucketInstanceId,F,_.ID),r)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new ao);for(let e=0;e=0;--e){const i=t[e];I(o.symbolInstances.get(i),i,o.collisionArrays[i])}o.hasAnyZOffset&&e.w(`${o.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(o.hasAnyZOffset){const e=o.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(t,i,r){const n=i===e.aE.horizontal||i===e.aE.horizontalOnly?i:0,o=i===e.aE.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=r,u=t.text.placedSymbolArray;s>=0&&(u.get(s).placedOrientation=n),a>=0&&(u.get(a).placedOrientation=n),l>=0&&(u.get(l).placedOrientation=n),c>=0&&(u.get(c).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new oo(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new oo(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new oo(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t,i,r){const n=new Set;for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,n,o.collisionBoxArray,i,r,o.tileID),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,o.tileID),t.updateZOffset()))}}updateBucketOpacities(t,i,r,n,o,s){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const a=t.layers[0].layout,l=!!t.layers[0].dynamicFilter(),c=new oo(null,0,!1,!1,!0),u=a.get("text-allow-overlap"),h=a.get("icon-allow-overlap"),d=a.get("text-variable-anchor"),p="map"===a.get("text-rotation-alignment"),f="map"===a.get("text-pitch-alignment"),m=new oo(null,0,u&&(h||!t.hasIconData()||a.get("icon-optional")),h&&(u||!t.hasTextData()||a.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const _=(e,t,i)=>{for(let r=0;r0||h>0,S=x>0,M=this.placedOrientations[y],I=M===e.aE.vertical,A=M===e.aE.horizontal||M===e.aE.horizontalOnly;!E&&!S||T.isHidden()||g++;let C=!1;if((E||S)&&o)for(const i of t.activeReplacements){if(i.orderv||v>i.max.x||i.min.y>b||b>i.max.y)continue;const t=e.cH(v,b,s.canonical,i.footprintTileId.canonical);if(C=e.cI(t,i),C)break}if(E){const e=C?To:wo(T.text);_(t.text,u,I?To:e),_(t.text,h,A?To:e);const i=T.text.isHidden(),{leftJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:s}=a,l=t.text.placedSymbolArray,c=i||I?1:0;r>=0&&(l.get(r).hidden=c),n>=0&&(l.get(n).hidden=c),o>=0&&(l.get(o).hidden=c),s>=0&&(l.get(s).hidden=i||A?1:0);const d=this.variableOffsets[y];d&&this.markUsedJustification(t,d.anchor,a,M);const p=this.placedOrientations[y];p&&(this.markUsedJustification(t,"left",a,p),this.markUsedOrientation(t,p,a))}if(S){const e=C?To:wo(T.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:r}=a,n=t.icon.placedSymbolArray,o=T.icon.isHidden()?1:0;i>=0&&(_(t.icon,x,I?To:e),n.get(i).hidden=o),r>=0&&(_(t.icon,a.numVerticalIconVertices,A?To:e),n.get(r).hidden=o)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let r=new e.P(0,0),n=!0;if(i.textBox||i.verticalTextBox){if(d){const e=this.variableOffsets[y];e?(r=uo(e.anchor,e.width,e.height,e.textOffset,e.textScale),p&&r._rotate(f?this.transform.angle:-this.transform.angle)):n=!1}l&&(n=!T.clipped),i.textBox&&fo(t.textCollisionBox.collisionVertexArray,T.text.placed,!n||I,r.x,r.y),i.verticalTextBox&&fo(t.textCollisionBox.collisionVertexArray,T.text.placed,!n||A,r.x,r.y)}const o=n&&Boolean(!A&&i.verticalIconBox);i.iconBox&&fo(t.iconCollisionBox.collisionVertexArray,T.icon.placed,o,a.hasIconTextFit?r.x:0,a.hasIconTextFit?r.y:0),i.verticalIconBox&&fo(t.iconCollisionBox.collisionVertexArray,T.icon.placed,!o,a.hasIconTextFit?r.x:0,a.hasIconTextFit?r.y:0)}}}if(t.fullyClipped=0===g,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function fo(e,t,i,r,n){e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0)}const mo=Math.pow(2,25),_o=Math.pow(2,24),go=Math.pow(2,17),yo=Math.pow(2,16),xo=Math.pow(2,9),vo=Math.pow(2,8),bo=Math.pow(2,1);function wo(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*mo+t*_o+i*go+t*yo+i*xo+t*vo+i*bo+t}const To=0;class Eo{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,t,i,r,n){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex{const t=e.e.now()-o;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const o=i[t[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===o.type&&(!o.minzoom||o.minzoom<=a)&&(!o.maxzoom||o.maxzoom>a)){const t=o,i=t.layout.get("symbol-z-elevate"),a=this._inProgressLayer=this._inProgressLayer||new Eo(t),l=e.al(o.source,o.scope);if(a.continuePlacement(i?n[l]:r[l],this.placement,this._showCollisionBoxes,o,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Mo=512/e.a3/2;class Io{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this.index=new e.cK(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const n=t.canonical.x*e.a3,o=t.canonical.y*e.a3;for(let e=0;ee.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const zo=new e.N({data:new e.O(e.L.colorTheme.data)}),Do=(e,t)=>Je(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),Lo=e.ah($n,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),Ro=e.ah($n,["setCenter","setZoom","setBearing","setPitch"]),ko={version:8,layers:[],sources:{}},Oo={duration:300,delay:0};class Bo extends e.E{constructor(t,i={}){super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition=e.W({},Oo),this._buildingIndex=new Gn(this),this.crossTileSymbolIndex=new Po,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerIndices=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=i.styleChanges||new b,this.dispatcher=i.dispatcher?i.dispatcher:new e.bw(e.bx(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new fe,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.cM(t._requestManager,i.localFontFamily?e.cN.all:i.localIdeographFontFamily?e.cN.ideographs:e.cN.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new de(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this._styleColorTheme={lut:null,lutLoading:!1,colorTheme:null},this._styleColorThemeForScope={},this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._config=i.config,this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.cO());const r=this;this._rtlTextPluginCallback=Bo.registerForPluginStateChange((t=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,i)=>{if(e.cP(t),i&&i.every((e=>e)))for(const e in r._sourceCaches){const t=r._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i)}}))}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.cQ(t))return t;const i=e.cR(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return`json://${e.cS(JSON.stringify(t))}`}_diffStyle(t,i,r){this.globalId=this._getGlobalId(t);const n=(e,t)=>{try{t(null,this.setState(e,r))}catch(e){t(e,!1)}};if("string"==typeof t){const r=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(r,e.R.Style);e.g(o,((t,r)=>{t?this.fire(new e.d(t)):r&&n(r,i)}))}else"object"==typeof t&&n(t,i)}loadURL(t,i={}){this.fire(new e.f("dataloading",{dataType:"style"}));const r="boolean"==typeof i.validate?i.validate:!e.cQ(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const n=this.importsCache.get(t);if(n)return this._load(n,r);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.g(o,((i,n)=>{if(this._request=null,i)this.fire(new e.d(i));else if(n)return this.importsCache.set(t,n),this._load(n,r)}))}loadJSON(t,i={}){this.fire(new e.f("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.e.frame((()=>{this._request=null,this._load(t,!1!==i.validate)}))}loadEmpty(){this.fire(new e.f("dataloading",{dataType:"style"})),this._load(ko,!1)}_loadImports(t,i,r){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const n=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise((e=>{t.once("style.import.load",e),t.once("error",e)})).then((()=>this.mergeAll()));if(n.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const s=e.data||this.importsCache.get(e.url);s?(t.loadJSON(s,{validate:i}),this._isInternalStyle(s)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(r){const e=this.fragments.findIndex((({id:e})=>e===r));this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}return Promise.allSettled(n)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return[...t.values()]}_createFragmentStyle(t){const i=this.scope?e.al(t.id,this.scope):t.id;let r;const n=this._initialConfig&&this._initialConfig[i];(t.config||n)&&(r=e.W({},t.config,n));const o=new Bo(this.map,{scope:i,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:r,configOptions:this.options,configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.isRootStyle()}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){const r=t.schema;if(this._isInternalStyle(t)){const r=e.W({},ko,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(r,i)}if(this.updateConfig(this._config,r),i&&Do(this,Ve(t)))return;this._loaded=!0,this.stylesheet=e.cT(t);const n=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(t.glyphs,this.scope);const r=Zn(this.stylesheet.layers);if(this._order=r.map((e=>e.id)),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new et(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new et(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const t of r){const i=e.cY(t,this.scope,this._styleColorTheme.lut,this.options);i.isConfigDependent&&this._configDependentLayers.add(i.fqid),i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._serializedLayers[i.id]=i.serialize();const r=this.getOwnLayerSourceCache(i),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();r&&i.canCastShadows()&&n&&(r.castsShadows=!0)}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const n=this.stylesheet.terrain;n&&(this.checkCanvasFingerprintNoise(),this.terrainSetForDrapingOnly()||this._createTerrain(n,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.f("data",{dataType:"style"}));const o=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then((()=>{this._reloadImports(),this.fire(new e.f(o?"style.load":"style.import.load"))})):(this._reloadImports(),this.fire(new e.f(o?"style.load":"style.import.load")))},o=this.stylesheet["color-theme"];if(this._styleColorTheme.colorTheme=o,o){const t=this._evaluateColorThemeData(o);this._loadColorTheme(t).then((()=>{n()})).catch((t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),n()}))}else this._styleColorTheme.lut=null,n()}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,i,r,n,o,s,a,l;const c={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((e=>{if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(const t of e.stylesheet.lights)"ambient"===t.type&&null!=e.ambientLight&&(i=e.ambientLight),"directional"===t.type&&null!=e.directionalLight&&(r=e.directionalLight);n=this._prioritizeTerrain(n,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(o=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(s=e.stylesheet.projection),null!=e.stylesheet.transition&&(a=e.stylesheet.transition),c[e.scope]=e._styleColorTheme}})),this.light=t,this.ambientLight=i,this.directionalLight=r,this.fog=o,this._styleColorThemeForScope=c,null===n?delete this.terrain:this.terrain=n,this.camera=l||{"camera-projection":"perspective"},this.projection=s||{name:"mercator"},this.transition=e.W({},Oo,a),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i)};t(this)}_prioritizeTerrain(e,t,i){const r=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:r?e:null:null!=t&&(!e||r||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain)})),null===e?delete this.terrain:this.terrain=e}mergeProjection(){let e;this.forEachFragmentStyle((t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)})),this.projection=e||{name:"mercator"}}mergeSources(){const t={},i={},r={};this.forEachFragmentStyle((n=>{for(const i in n._sourceCaches){const r=e.al(i,n.scope);t[r]=n._sourceCaches[i]}for(const t in n._otherSourceCaches){const r=e.al(t,n.scope);i[r]=n._otherSourceCaches[t]}for(const t in n._symbolSourceCaches){const i=e.al(t,n.scope);r[i]=n._symbolSourceCaches[t]}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=r}mergeLayers(){const t={},i=[],r={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((r=>{for(const n of r._order){const o=r._layers[n];if("slot"===o.type){const i=e.cU(n);if(t[i])continue;t[i]=[]}o.slot&&t[o.slot]?t[o.slot].push(o):i.push(o)}})),this._mergedOrder=[],this._clipLayerIndices=[];let n=0;const o=(i=[])=>{for(const s of i)if("slot"===s.type){const i=e.cU(s.id);t[i]&&o(t[i]),this._mergedSlots.push(i)}else{const t=e.al(s.id,s.scope);this._mergedOrder.push(t),r[t]=s,s.is3D()&&(this._has3DLayers=!0),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&this._clipLayerIndices.push(n),n++}};o(i),this._mergedLayers=r,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=e.W({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?(function(t,i,r){const n=e.W({},i);for(const t of Object.keys(e.L.colorTheme))void 0===n[t]&&(n[t]=e.L.colorTheme[t].default);const o=new e.U(zo,t,new Map(r));return o.setTransitionOrValue(n,r),o.untransitioned().possiblyEvaluate(new e.X(0))})(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){return this._styleColorTheme.lutLoading=!0,new Promise(((i,r)=>{const n="data:image/png;base64,";if(0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void i();t.startsWith(n)||(t=n+t);const o="mapbox-reserved-lut",s=new Image;s.src=t,s.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"))},s.onload=()=>{this._styleColorTheme.lutLoading=!1;const{width:n,height:a,data:l}=e.e.getImageData(s);if(a>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(n!==a*a)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(o)&&this.removeImage(o),this.addImage(o,{data:new e.i({width:n,height:a},l),pixelRatio:1,sdf:!1,version:0});const c=this.imageManager.getImage(o,this.scope);c?(this._styleColorTheme.lut={image:c.data,data:t},i()):r(new Error("Missing LUT image."))}}))}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=(function(t,i,r){let n,o,s;const a=e.e.devicePixelRatio>1?"@2x":"";let l=e.g(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),((e,t)=>{l=null,s||(s=e,n=t,u())})),c=e.h(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),((e,t)=>{c=null,s||(s=e,o=t,u())}));function u(){if(s)r(s);else if(n&&o){const t=e.e.getImageData(o),i={};for(const r in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p}=n[r],f=new e.i({width:o,height:s});e.i.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s},null),i[r]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p}}r(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}})(t,this.map._requestManager,((t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.d(t));else if(i)for(const e in i)this.imageManager.addImage(e,this.scope,i[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.f("data",{dataType:"style"}))}))}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const r=t.sourceLayer;r&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new e.d(new Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded())return!1;if(!this.modelManager.isLoaded())return!1;if(this._styleColorTheme.lutLoading)return!1;for(const{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map(((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e}))}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize())}return t}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.d(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.d(new Error(`The source '${t}' does not exist in the map's style.`)))}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i));const r=this._changes.isDirty();let n=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:r}=e[t];(i||r)&&(this._updateWorkerLayers(t,i,r),n=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._changes.reset()}const o={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];o[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const i=this._mergedLayers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()))}if(!this._precompileDone&&this._shouldPrecompile)for(let e=i.minzoom||0;e<(i.maxzoom||25.5);e++){const e=this.map.painter;if(e){const r=i.getProgramIds();if(!r)continue;for(const n of r){const r=i.getDefaultProgramParams(n,t.zoom,this._styleColorTheme.lut);r&&(e.style=this,this.fog&&(e._fogVisible=!0,r.overrideFog=!0,e.getOrCreateProgram(n,r)),e._fogVisible=!1,r.overrideFog=!1,e.getOrCreateProgram(n,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,e.getOrCreateProgram(n,r)))}}}}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&n&&this.mergeLayers();for(const t in o){const i=this._mergedSourceCaches[t];o[t]!==i.used&&i.getSource().fire(new e.f("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),r&&this.fire(new e.f("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages()}}_updateWorkerLayers(e,t,i){const r=this.getFragmentStyle(e);r&&this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:i||[],options:r.options})}setState(i,r){if(this._checkLoaded(),Do(this,Ve(i)))return!1;(i=e.cT(i)).layers=Zn(i.layers);const n=(function(e,i){if(!e)return[{command:$n.setStyle,args:[i]}];let r=[];try{if(!t(e.version,i.version))return[{command:$n.setStyle,args:[i]}];if(t(e.center,i.center)||r.push({command:$n.setCenter,args:[i.center]}),t(e.zoom,i.zoom)||r.push({command:$n.setZoom,args:[i.zoom]}),t(e.bearing,i.bearing)||r.push({command:$n.setBearing,args:[i.bearing]}),t(e.pitch,i.pitch)||r.push({command:$n.setPitch,args:[i.pitch]}),t(e.sprite,i.sprite)||r.push({command:$n.setSprite,args:[i.sprite]}),t(e.glyphs,i.glyphs)||r.push({command:$n.setGlyphs,args:[i.glyphs]}),t(e.imports,i.imports)||(function(e=[],i=[],r){i=i||[];const n=(e=e||[]).map(Jn),o=i.map(Jn),s=e.reduce(Qn,{}),a=i.reduce(Qn,{}),l=n.slice();let c,u,h,d;for(c=0,u=0;c{e.source&&n[e.source]?r.push({command:$n.removeLayer,args:[e.id]}):s.push(e)}));let a=e.terrain;a&&n[a.source]&&(r.push({command:$n.setTerrain,args:[void 0]}),a=void 0),r=r.concat(o),t(a,i.terrain)||r.push({command:$n.setTerrain,args:[i.terrain]}),(function(e,i,r){i=i||[];const n=(e=e||[]).map(Jn),o=i.map(Jn),s=e.reduce(Qn,{}),a=i.reduce(Qn,{}),l=n.slice(),c=Object.create(null);let u,h,d,p,f,m,_;for(u=0,h=0;u!(e.command in Ro)));if(0===n.length)return!1;const o=n.filter((e=>!(e.command in Lo)));if(o.length>0)throw new Error(`Unimplemented: ${o.map((e=>e.command)).join(", ")}.`);const s=[];return n.forEach((e=>{s.push(this[e.command].apply(this,e.args))})),r&&Promise.all(s).then(r),this.stylesheet=i,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(t,i){return this.getImage(t)?this.fire(new e.d(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,i),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t)}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new e.d(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(t),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new e.f("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,i={}){return this._checkLoaded(),this._validate(Ye,`models.${e}`,t,null,i)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new e.d(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,r={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(Ue,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=Bi(t,i,this.dispatcher,this);n.scope=this.scope,n.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(n.id),source:n.serialize(),sourceId:n.id})));const o=t=>{const i=(t?"symbol:":"other:")+n.id,r=e.al(i,this.scope),o=this._sourceCaches[i]=new e.bv(r,n,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[n.id]=o,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),n.onAdd&&n.onAdd(this.map),r.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.d(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.d(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const r=this.getOwnSourceCaches(t);for(const t of r){const i=e.cU(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.f("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource())}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}setLights(t){if(this._checkLoaded(),!t)return void delete this.ambientLight;const i=this._getTransitionParameters();for(const e of t){if(this._validate(Ge,"lights",e))return;switch(e.type){case"ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i)}else this.ambientLight=new dt(e,pt,this.scope,this.options);break;case"directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i)}else this.directionalLight=new dt(e,ft,this.scope,this.options)}}const r=new e.X(this.z||0,i);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const r=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),n=t.properties.get("color").toRenderColor(null).toArray01(),o=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.ac(s.x,s.y,s.z)[2]/90,l=r(n)*o*a,c=i.properties.get("color").toRenderColor(null).toArray01(),u=i.properties.get("intensity");return(l+r(c)*u)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(!t)return this;if(e.cV(t)){const i=e.cW(t),r=this.fragments.find((({id:e})=>e===i));if(!r)throw new Error(`Style import not found: ${t}`);const n=e.cU(t);return r.style.getFragmentStyle(n)}{const e=this.fragments.find((({id:e})=>e===t));if(!e)throw new Error(`Style import not found: ${t}`);return e.style}}getConfigProperty(t,i){const r=this.getFragmentStyle(t);if(!r)return null;const n=e.al(i,r.scope),o=r.options.get(n),s=o?o.value||o.default:null;return s?s.serialize():null}setConfigProperty(t,i,r){const n=this.getFragmentStyle(t);if(!n)return;const o=n.stylesheet.schema;if(!o||!o[i])return;const s=e.y(r);if("success"!==s.result)return void Do(this,s.value);const a=s.value.expression,l=e.al(i,n.scope),c=n.options.get(l);if(!c)return;let u;const{minValue:d,maxValue:p,stepValue:f,type:m,values:_}=o[i],g=e.y(o[i].default);"success"===g.result&&(u=g.value.expression),u?(this.options.set(l,h(h({},c),{},{value:a,default:u,minValue:d,maxValue:p,stepValue:f,type:m,values:_})),this.updateConfigDependencies()):this.fire(new e.d(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)))}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const r=i.stylesheet.schema;if(!r)return null;const n={};for(const t in r){const r=e.al(t,i.scope),o=i.options.get(r),s=o?o.value||o.default:null;n[t]=s?s.serialize():null}return n}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies())}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const r in i){let n,o;const s=e.y(i[r].default);if("success"===s.result&&(n=s.value.expression),t&&void 0!==t[r]){const i=e.y(t[r]);"success"===i.result&&(o=i.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:u,values:h}=i[r];if(n){const t=e.al(r,this.scope);this.options.set(t,{default:n,value:o,minValue:a,maxValue:l,stepValue:c,type:u,values:h})}else this.fire(new e.d(new Error(`No schema defined for config option "${r}".`)))}else this.fire(new e.d(new Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t))}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.forEachFragmentStyle((e=>{if(e._styleColorTheme.colorTheme){const t=e._evaluateColorThemeData(e._styleColorTheme.colorTheme);(!e._styleColorTheme.lut||e._styleColorTheme.lut&&t!==e._styleColorTheme.lut.data)&&e.setColorTheme(e._styleColorTheme.colorTheme)}})),this._changes.setDirty()}addLayer(t,i,r={}){this._checkLoaded();const n=t.id;if(this._layers[n])return void this.fire(new e.d(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===t.type){if(Do(this,e.cX(t)))return;o=e.cY(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.cT(t),t=e.W(t,{source:n})),this._validate($e,`layers.${n}`,t,{arrayIndex:-1},r))return;o=e.cY(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[o.id]=o.serialize()}o.isConfigDependent&&this._configDependentLayers.add(o.fqid);let s=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.d(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?s=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o;const a=this.getOwnLayerSourceCache(o),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&o.canCastShadows()&&l&&(a.castsShadows=!0);const c=this._changes.getRemovedLayer(o);if(c&&o.source&&a&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.al(o.source,o.scope);c.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,i){this._checkLoaded();const r=this._checkLayer(t);if(!r)return;if(t===i)return;const n=this._order.indexOf(t);this._order.splice(n,1);let o=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.d(new Error(`Layer with id "${i}" does not exist on this map.`)));r.slot===this._layers[i].slot?o=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}r.castsShadows=e}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,i){this._checkLoaded();const r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i))}setFilter(i,r,n={}){this._checkLoaded();const o=this._checkLayer(i);if(o&&!t(o.filter,r))return null==r?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(We,`layers.${o.id}.filter`,r,{layerType:o.type},n)||(o.filter=e.cT(r),this._updateLayer(o)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.cT(i.filter)}setLayoutProperty(i,r,n,o={}){this._checkLoaded();const s=this._checkLayer(i);if(s&&!t(s.getLayoutProperty(r),n)){if(null!=n&&(!o||!1!==o.validate)&&Do(s,Xe.call(Ve,{key:`layers.${i}.layout.${r}`,layerType:s.type,objectKey:r,value:n,styleSpec:e.L,style:{glyphs:!0,sprite:!0}})))return;s.setLayoutProperty(r,n),s.isConfigDependent&&this._configDependentLayers.add(s.fqid),this._updateLayer(s)}}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(i,r,n,o={}){this._checkLoaded();const s=this._checkLayer(i);if(!s)return;if(t(s.getPaintProperty(r),n))return;if(null!=n&&(!o||!1!==o.validate)&&Do(s,He.call(Ve,{key:`layers.${i}.paint.${r}`,layerType:s.type,objectKey:r,value:n,styleSpec:e.L})))return;const a=s.setPaintProperty(r,n);s.isConfigDependent&&this._configDependentLayers.add(s.fqid),a&&this._updateLayer(s),this._changes.updatePaintProperties(s)}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){this._checkLoaded();const r=t.source,n=t.sourceLayer,o=this._checkSource(r);if(!o)return;const s=o.type;if("geojson"===s&&n)return void this.fire(new e.d(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new e.d(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.d(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(r);for(const e of a)e.setFeatureState(n,t.id,i)}removeFeatureState(t,i){this._checkLoaded();const r=t.source,n=this._checkSource(r);if(!n)return;const o=n.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.d(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.d(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(r);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){this._checkLoaded();const i=t.source,r=t.sourceLayer,n=this._checkSource(i);if(n){if("vector"!==n.type||r)return void 0===t.id&&this.fire(new e.d(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(r,t.id);this.fire(new e.d(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition=e.W({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return e.W({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.cZ({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),r=e.al(t.source,t.scope),n=this._changes.getUpdatedSourceCaches();t.source&&!n[r]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(r,"reload"),i.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type||"model"===this._mergedLayers[e].type,i=this.order,r={},n=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){r[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t)}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(t.layer&&r[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),l=kn.createFromScreenPoints(t,r);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e].getSource();if(!t||t.scope!==i.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;i.layers&&!n[c]||o.push(Vn(this._mergedSourceCaches[e],this._mergedLayers,s,l,i,r,a,!!this.map._showQueryGeometry))}return this.placement&&o.push((function(e,t,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(jn);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in r){const t=a[e]=a[e]||[],n=r[e];n.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of n)t.push(e)}}for(const t in a)a[t].forEach((r=>{const n=r.feature,o=i(e[t]);if(!o)return;const s=o.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=s}));return a})(this._mergedLayers,s,this.getLayerSourceCache.bind(this),l.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,t){t&&t.filter&&this._validate(We,"querySourceFeatures.filter",t.filter,null,t);const i=this.getOwnSourceCaches(e);let r=[];for(const e of i)r=r.concat(Un(e,t));return r}addSourceType(e,t,i){return Bo.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Bo.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,i,r={}){this._checkLoaded();const n=this.light.getLight();let o=!1;for(const i in e)if(!t(e[i],n[i])){o=!0;break}if(!o)return;const s=this._getTransitionParameters();this.light.setLight(e,i,r),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.e.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(i,r=1){if(this._checkLoaded(),!i)return this.terrainSetForDrapingOnly()&&0!==r||delete this.terrain,null===i?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let n=i;const o=null==i.source;if(1===r){if(this.disableElevatedTerrain)return;if("object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.cT(n),n=e.W(n,{source:t})}const t=e.W({},n),i={};if(this.terrain&&o){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize())}if(this._validate(qe,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!o||this.terrain&&r!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,r),this.fire(new e.f("data",{dataType:"style"}))}else{const r=this.terrain,o=r.get();for(const t of Object.keys(e.L.terrain))!n.hasOwnProperty(t)&&e.L.terrain[t].default&&(n[t]=e.L.terrain[t].default);for(const n in i)if(!t(i[n],o[n])){r.set(i,this.options),this.stylesheet.terrain=i;const t=this._getTransitionParameters({duration:0});r.updateTransitions(t),this.fire(new e.f("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new ht(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!t(i.get(),e)){i.set(e,this.options),this.stylesheet.fog=i.get();const t=this._getTransitionParameters({duration:0});i.updateTransitions(t)}}else this._createFog(e);this._markersNeedUpdate=!0}setColorTheme(t){this._checkLoaded();const i=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles()};if(this._styleColorTheme.colorTheme=t,!t)return this._styleColorTheme.lut=null,void i();const r=this._evaluateColorThemeData(t);this._loadColorTheme(r).then((()=>{i()})).catch((t=>{e.w(`Couldn't set color theme: ${t}`)}))}_getTransitionParameters(t){return{now:e.e.now(),transition:e.W(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i in this._mergedLayers)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const i=this.terrain=new it(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,i,r,n,o={}){if(o&&!1===o.validate)return!1;const s=e.W({},this.serialize());return Do(this,t.call(Ve,e.W({key:i,style:s,value:r,styleSpec:e.L},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.c_.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove())}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles()}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles()}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload()}reloadSources(){for(const e of this.getSources())e.reload&&e.reload()}updateSources(e){let t;this.directionalLight&&(t=Si(this.directionalLight));for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].update(e,void 0,void 0,t)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,i,r,n,o,s,a=!1){let l=!1,c=!1;const u={},h={};for(const t of this._mergedOrder){const r=this._mergedLayers[t];if("symbol"!==r.type)continue;const n=e.al(r.source,r.scope);let o=u[n];if(!o){const e=this.getLayerSourceCache(r);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));h[n]=t.slice(),o=u[n]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const s=this.crossTileSymbolIndex.addLayer(r,o,i.center.lng,i.projection);l=l||s}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),a=a||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new e.f("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.e.now(),i.zoom))&&(this.pauseablePlacement=new So(i,this._mergedOrder,a,r,n,o,this.placement,this.fog&&i.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,u,h),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.e.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l){this._buildingIndex.onNewFrame(i.zoom);for(let t=0;tte===t.id)))return void this.fire(new e.d(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return r.push(t),this._loadImports([t],!0);const n=r.findIndex((({id:e})=>e===i));return-1===n&&this.fire(new e.d(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=r.slice(0,n).concat(t).concat(r.slice(n)),this._loadImports([t],!0,i)}updateImport(e,i){this._checkLoaded();const r=this.stylesheet.imports||[],n=this.getImportIndex(e);return-1===n?this:"string"==typeof i?(this.setImportUrl(e,i),this):(i.url&&i.url!==r[n].url&&this.setImportUrl(e,i.url),t(i.config,r[n].config)||this.setImportConfig(e,i.config),t(i.data,r[n].data)||this.setImportData(e,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const r=this.getImportIndex(e);if(-1===r)return this;const n=this.getImportIndex(t);if(-1===n)return this;const o=i[r],s=this.fragments[r];return i=i.filter((({id:t})=>t!==e)),this.fragments=this.fragments.filter((({id:t})=>t!==e)),this.stylesheet.imports=i.slice(0,n).concat(o).concat(i.slice(n)),this.fragments=this.fragments.slice(0,n).concat(s).concat(this.fragments.slice(n)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;i[r].url=t;const n=this.fragments[r];return n.style=this._createFragmentStyle(i[r]),n.style.on("style.import.load",(()=>this.mergeAll())),n.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];return-1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete r[i].data,this.setImportUrl(e,r[i].url))}setImportConfig(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===i)return this;t?r[i].config=t:delete r[i].config;const n=this.fragments[i],o=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.updateConfig(t,o),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports())}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex((e=>e.id===t));return-1===i&&this.fire(new e.d(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource())}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const r=e.al(t,i);return this._mergedOtherSourceCaches[r]}getLayerSourceCache(t){const i=e.al(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t)}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e)}}getImages(e,t,i){this.imageManager.getImages(t.icons,t.scope,i),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,t.scope,i)}getResource(t,i,r){return e.c$(i,r)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.d(new Error(`There is no source with ID '${t}'`))),!1):i.every((e=>e.loaded()))}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(t,i){if(0===this._clipLayerIndices.length&&"fill-extrusion"!==t.type)return!1;const r="fill-extrusion"===t.type&&"building"===t.sourceLayer;let n=0;if(t.is3D()){if(r||i&&"batched-model"===i.type)return!0;"model"===t.type&&(n=e.cu.Model)}else"symbol"===t.type&&(n=e.cu.Symbol);for(const t of this._clipLayerIndices){const i=this._mergedLayers[this._mergedOrder[t]];if(!i)continue;const r=[];for(const t of i.layout.get("clip-layer-types"))r.push("model"===t?e.cu.Model:"symbol"===t?e.cu.Symbol:e.cu.FillExtrusion);for(const e of r)if(n&e)return!0}return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach((e=>{e.style._remove()})),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}function Fo(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1)};return()=>(i=!0,r||n(),r)}Bo.getSourceType=function(e){return Oi[e]},Bo.setSourceType=function(e,t){Oi[e]=t},Bo.registerForPluginStateChange=e.cL;class No{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bp(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Fo(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const t=Vo(e);if(this._hashName){const e=this._hashName;let i=!1;const r=location.hash.slice(1).split("&").map((r=>{const n=r.split("=")[0];return n===e?(i=!0,`${n}=${t}`):r})).filter((e=>e));return i||r.push(`${e}=${t}`),`#${r.join("&")}`}return`#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Vo(e,t){const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(2.8444444444444446))/Math.LN10),o=Math.pow(10,n),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${s}/${a}/${r}`:`${r}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const Uo={linearity:.3,easing:e.d0(0,0,.3,1)},jo=e.W({deceleration:2500,maxSpeed:1400},Uo),Go=e.W({deceleration:20,maxSpeed:1400},Uo),qo=e.W({deceleration:1e3,maxSpeed:360},Uo),Zo=e.W({deceleration:1e3,maxSpeed:90},Uo);class $o{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.e.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.e.now();for(;t.length>0&&i-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const o=Ho(i.pan.mag(),r,e.W({},jo,t||{}));n.offset=i.pan.mult(o.amount/i.pan.mag()),n.center=this._map.transform.center,Wo(n,o)}if(i.zoom){const e=Ho(i.zoom,r,Go);n.zoom=this._map.transform.zoom+e.amount,Wo(n,e)}if(i.bearing){const t=Ho(i.bearing,r,qo);n.bearing=this._map.transform.bearing+e.at(t.amount,-179,179),Wo(n,t)}if(i.pitch){const e=Ho(i.pitch,r,Zo);n.pitch=this._map.transform.pitch+e.amount,Wo(n,e)}if(n.zoom||n.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function Wo(e,t){(!e.duration||e.durationi.unproject(e))),a=o.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new e.P(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class Ko extends e.f{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class Jo{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new Ko(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Xo(e.type,this._map,e))}mouseup(e){this._map.fire(new Xo(e.type,this._map,e))}preclick(t){const i=e.W({},t);i.type="preclick",this._map.fire(new Xo(i.type,this._map,i))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Xo(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new Xo(e.type,this._map,e))}mouseover(e){this._map.fire(new Xo(e.type,this._map,e))}mouseout(e){this._map.fire(new Xo(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Yo(e.type,this._map,e))}touchmove(e){this._map.fire(new Yo(e.type,this._map,e))}touchend(e){this._map.fire(new Yo(e.type,this._map,e))}touchcancel(e){this._map.fire(new Yo(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Qo{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new Xo(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Xo("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Xo(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class es{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(p(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t,r=this._startPos,n=this._lastPos;if(!r||!n||n.equals(i)||!this._box&&i.dist(r){this._box&&(this._box.style.transform=`translate(${s}px,${l}px)`,this._box.style.width=a-s+"px",this._box.style.height=c-l+"px")}))}mouseupWindow(t,i){if(!this._active)return;const r=this._startPos,n=i;if(r&&0===t.button){if(this.reset(),_(),r.x!==n.x||r.y!==n.y)return this._map.fire(new e.f("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,n,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),f(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.f(t,{originalEvent:i}))}}function ts(e,t){const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=(function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)})(i),this.touches=ts(r,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=ts(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class rs{constructor(e){this.singleTap=new is(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class ns{constructor(){this._zoomIn=new rs({numTouches:1,numTaps:2}),this._zoomOut=new rs({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const os={0:1,2:2};class ss{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const i=x(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i)}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&(function(e,t){const i=os[t];return void 0===e.buttons||(e.buttons&i)!==i})(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const n=ts(r,i),o=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in n){const t=n[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,n[e]=t)}if(this._touches=n,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")}),500)}}class hs{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,i){return{}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,s=ds(i,t,n),a=ds(i,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=ds(i,t,r),s=ds(i,t,n);o&&s||(this._active&&_(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function ds(e,t,i){for(let r=0;rMath.abs(e.x)}class ys extends hs{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,gs(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,i,r){const n=this._lastPoints;if(!n)return;const o=t[0].sub(n[0]),s=t[1].sub(n[1]);return this._map._cooperativeGestures&&!e.d1()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return gs(e)&&gs(t)&&o}}const xs={panStep:100,bearingStep:15,pitchStep:10};class vs{constructor(){const e=xs;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:bs,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function bs(e){return e*(2-e)}const ws=4.000244140625;class Ts{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.bp(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.d1()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=e.e.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%ws==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=g(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>ws?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const n=i(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:i(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const t=Math.min((e.e.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.a2(n,r,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=r,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200));let l=s-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.d2;if(this._prevEase){const t=this._prevEase,r=(e.e.now()-t.start)/t.duration,n=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.d0(o,s,.25,1)}return this._prevEase={start:e.e.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")}),200)}}class Es{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ss{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ms{constructor(){this._tap=new rs({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i))}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Is{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class As{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Cs{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Ps=e=>e.zoom||e.drag||e.pitch||e.rotate;class zs extends e.f{}class Ds{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const r=e._.sub([],i,t);this.radius=e._.length(r[2]<0?e._.div([],r,this.constants):[r[0],r[1],0])}projectRay(t){e._.div(t,t,this.constants),e._.normalize(t,t),e._.mul(t,t,this.constants);const i=e._.scale([],t,this.radius);if(i[2]>0){const t=e._.scale([],[0,0,1],e._.dot(i,[0,0,1])),r=e._.scale([],e._.normalize([],[i[0],i[1],0]),this.radius),n=e._.add([],i,e._.scale([],e._.sub([],e._.add([],r,t),i),2));i[0]=n[0],i[1]=n[1]}return i}}function Ls(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Rs{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new $o(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Ds,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.bp(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,r,i)}}destroy(){for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,r,i)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Jo(t,e));const r=t.boxZoom=new es(t,e);this._add("boxZoom",r);const n=new ns,o=new Ss;t.doubleClickZoom=new Es(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new Ms;this._add("tapDragZoom",s);const a=t.touchPitch=new ys(t);this._add("touchPitch",a);const l=new ls(e),c=new cs(e);t.dragRotate=new As(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new as(e),h=new us(t,e);t.dragPan=new Is(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new _s,p=new fs;t.touchZoomRotate=new Cs(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Qo(t));const f=t.scrollZoom=new Ts(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new vs;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i])}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ps(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,r=i?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?y(this._el,a):i?void 0:g(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,h,i,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=r);this._previousActiveHandlers=s,(Object.keys(c).length||Ls(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Ls(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(t,i,r,n,o){if(!r)return;e.W(t,r);const s={handlerName:n,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const t={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.aroundCoord&&(t.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.W(i,o),e.W(r,s);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,i,r){const n=this._map,o=n.transform,s=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Ls(t)){const e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&n._stop(!0),!Ls(t))return void this._fireEvents(i,r,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(h=p),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),h=h||n.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){a=a.rotate(-o.angle);const i=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.d3(e.ay(t.y))*i,f[1]=-a.y*e.d3(o.center.lat)*i}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,_=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(h)),i={dir:e._.normalize([],e._.sub([],t,o._camera.position))};if(i.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e._.scale(_,i.dir,r)}}const g=e._.add(f,f,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,r,!0)}_fireEvents(t,i,r){const n=Ps(this._eventsInProgress),o=Ps(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||r,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=Ps(this._eventsInProgress);if(r&&(n||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new zs("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const ks="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Os extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.bp(["_renderFrameCallback"],this)}getCenter(){return new e.aI(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,r){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.W({offset:t},i),r)}panTo(t,i,r){return this.easeTo(e.W({center:t},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,r){return this.easeTo(e.W({zoom:t},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,i,r){return this.easeTo(e.W({bearing:t},i),r)}resetNorth(t,i){return this.rotateTo(0,e.W({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.W({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,r,n,o,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.aI.convert(i),u=e.aI.convert(r),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),p=e.d4(h,d),f=e._.normalize([],p),m=e._.normalize([],e._.cross([],f,[0,1,0])),_=e._.cross([],m,f),g=[m[0],m[1],m[2],0,_[0],_[1],_[2],0,f[0],f[1],f[2],0,0,0,0,1],y=[p,e.d4(c.lat,c.lng),e.d4(u.lat,c.lng),e.d4(u.lat,u.lng),e.d4(c.lat,u.lng),e.d4(h,c.lng),e.d4(h,u.lng),e.d4(c.lat,d),e.d4(u.lat,d)];let x=e.b6.fromPoints(y.map((t=>[e._.dot(m,t),e._.dot(_,t),e._.dot(f,t)])));const v=e._.transformMat4([],x.center,g);0===e._.squaredLength(v)&&e._.set(v,0,0,1),e._.normalize(v,v),e._.scale(v,v,e.cD),a.center=e.d5(v);const b=a.getWorldToCameraMatrix(),w=e.ad.invert(new Float64Array(16),b);x=e.b6.applyTransform(x,e.ad.multiply([],b,g));const T=this._extendAABB(x,a,l,n);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T,e._.transformMat4(v,v,b);const E=.5*(x.max[2]-x.min[2]),S=this._minimumAABBFrustumDistance(a,x),M=e._.scale([],[0,0,1],E),I=e._.add(M,v,M),A=S+(0===a.pitch?0:e._.distance(v,I)),C=a.globeCenterInViewSpace,P=e._.sub([],v,[C[0],C[1],C[2]]);e._.normalize(P,P),e._.scale(P,P,A);const z=e._.add([],v,P);e._.transformMat4(z,z,w);const D=e.d7/e.cD,L=e._.length(z),R=e.ax(Math.max(L*D-e.d7,Number.EPSILON),0),k=Math.min(a.zoomFromMercatorZAdjusted(R),l.maxZoom);return k>.5*(e.b1+e.aU)?(a.setProjection({name:"mercator"}),a.zoom=k,this._cameraForBounds(a,i,r,n,o,s)):{center:a.center,zoom:k,bearing:n,pitch:o}}_extendAABB(t,i,r,n){const o=.5*((r.padding.left||0)+(r.padding.right||0)),s=.5*((r.padding.top||0)+(r.padding.bottom||0)),a=s,l=o,c=o,u=s,h=i.width-(l+c),d=i.height-(a+u),p=e._.sub([],t.max,t.min),f=Math.min(h/p[0],d/p[1]),m=Math.min(i.scaleZoom(i.scale*f),r.maxZoom);if(isNaN(m))return null;const _=i.scale/i.zoomScale(m),g=new e.b6([t.min[0]-l*_,t.min[1]-u*_,t.min[2]],[t.max[0]+c*_,t.max[1]+a*_,t.max[2]]),y=("number"==typeof r.offset.x&&"number"==typeof r.offset.y?new e.P(r.offset.x,r.offset.y):e.P.convert(r.offset)).rotate(-e.ab(n));return g.center[0]-=y.x*_,g.center[1]+=y.y*_,g}queryTerrainElevation(t,i){const r=this.transform.elevation;return r?(i=e.W({},{exaggerated:!0},i),r.getAtPoint(e.Y.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,r,n,o,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,r,n,o,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.aI.convert(i),u=e.aI.convert(r),h=new e.aI(c.lng,u.lat),d=new e.aI(u.lng,c.lat),p=a.project(c),f=a.project(u),m=this.queryTerrainElevation(c),_=this.queryTerrainElevation(u),g=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),x=[[p.x,p.y,Math.min(m||0,_||0,g||0,y||0)],[f.x,f.y,Math.max(m||0,_||0,g||0,y||0)]];let v=e.b6.fromPoints(x);const b=a.getWorldToCameraMatrix(),w=e.ad.invert(new Float64Array(16),b);v=e.b6.applyTransform(v,b);const T=this._extendAABB(v,a,l,n);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=T;const E=.5*e._.sub([],v.max,v.min)[2],S=this._minimumAABBFrustumDistance(a,v),M=[0,0,1,0];e.aA.transformMat4(M,M,b),e.aA.normalize(M,M);const I=e._.scale([],M,S+E),A=e._.add([],v.center,I);e._.transformMat4(v.center,v.center,w),e._.transformMat4(A,A,w);const C=[v.center[0],v.center[1],A[2]*a.pixelsPerMeter];e._.scale(C,C,1/a.worldSize);const P=e.d6(C[0]),z=e.ay(C[1]),D=Math.min(a._zoomFromMercatorZ(C[2]),l.maxZoom),L=new e.aI(P,z);return a.mercatorFromTransition&&D<.5*(e.b1+e.aU)?(a.setProjection({name:"globe"}),a.zoom=D,this._cameraForBounds(a,i,r,n,o,s)):{center:L,zoom:D,bearing:n,pitch:o}}fitBounds(e,t,i){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,i)}fitScreenCoordinates(t,i,r,n,o){const s=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(u.lng,h.lng,d.lng,p.lng),Math.min(u.lat,h.lat,d.lat,p.lat)],m=[Math.max(u.lng,h.lng,d.lng,p.lng),Math.max(u.lat,h.lat,d.lat,p.lat)],_=n&&n.pitch?n.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,f,m,r,_,n);return this._fitInternal(g,n,o)}_fitInternal(t,i,r){return t?(i=e.W(t,i)).linear?this.easeTo(i,r):this.flyTo(i,r):this}jumpTo(t,i){this.stop();const r=t.preloadOnly?this.transform.clone():this.transform;let n=!1,o=!1,s=!1;return"zoom"in t&&r.zoom!==+t.zoom&&(n=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.aI.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(s=!0,r.pitch=+t.pitch),null==t.padding||r.isPaddingEqual(t.padding)||(r.padding=t.padding),t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.f("movestart",i)).fire(new e.f("move",i)),n&&this.fire(new e.f("zoomstart",i)).fire(new e.f("zoom",i)).fire(new e.f("zoomend",i)),o&&this.fire(new e.f("rotatestart",i)).fire(new e.f("rotate",i)).fire(new e.f("rotateend",i)),s&&this.fire(new e.f("pitchstart",i)).fire(new e.f("pitch",i)).fire(new e.f("pitchend",i)),this.fire(new e.f("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(ks),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const r=this.transform;if(!r.projection.supportsFreeCamera)return e.w(ks),this;this.stop();const n=r.zoom,o=r.pitch,s=r.bearing;r.setFreeCameraOptions(t);const a=n!==r.zoom,l=o!==r.pitch,c=s!==r.bearing;return this.fire(new e.f("movestart",i)).fire(new e.f("move",i)),a&&this.fire(new e.f("zoomstart",i)).fire(new e.f("zoom",i)).fire(new e.f("zoomend",i)),c&&this.fire(new e.f("rotatestart",i)).fire(new e.f("rotate",i)).fire(new e.f("rotateend",i)),l&&this.fire(new e.f("pitchstart",i)).fire(new e.f("pitch",i)).fire(new e.f("pitchend",i)),this.fire(new e.f("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.W({offset:[0,0],duration:500,easing:e.d2},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===r.projection.name){const i=e.Y.fromLngLat(r.center),n=d.rotate(-r.angle);i.x+=n.x/r.worldSize,i.y+=n.y/r.worldSize;const o=i.toLngLat(),s=e.aI.convert(t.center||o);this._normalizeCenter(s),p=r.centerPoint.add(n),f=new e.P(i.x,i.y).mult(r.worldSize),m=new e.P(e.aj(s.lng),e.ak(s.lat)).mult(r.worldSize).sub(f)}else{p=r.centerPoint.add(d);const i=r.pointLocation(p),n=e.aI.convert(t.center||i);this._normalizeCenter(n),f=r.project(i),m=r.project(n).sub(f)}const _=r.zoomScale(l-n);let g,y;t.around&&(g=e.aI.convert(t.around),y=r.locationPoint(g));const x=this._zooming||l!==n,v=this._rotating||o!==c,b=this._pitching||u!==s,w=!r.isPaddingEqual(h),T=r=>T=>{if(x&&(r.zoom=e.a2(n,l,T)),v&&(r.bearing=e.a2(o,c,T)),b&&(r.pitch=e.a2(s,u,T)),w&&(r.interpolatePadding(a,h,T),p=r.centerPoint.add(d)),g)r.setLocationAtPoint(g,y);else{const e=r.zoomScale(r.zoom-n),t=l>n?Math.min(2,_):Math.max(.5,_),i=Math.pow(t,1-T),o=r.unproject(f.add(m.mult(T*i)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(T,t.duration,r);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=v,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,E),this._ease(T(r),(e=>{"sea"===r.cameraElevationReference&&r.recenterOnTerrain(),this._afterEase(i,e)}),t),this}_prepareEase(t,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||r.moving||this.fire(new e.f("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.f("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.f("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.f("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.f("move",t)),this._zooming&&this.fire(new e.f("zoom",t)),this._rotating&&this.fire(new e.f("rotate",t)),this._pitching&&this.fire(new e.f("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.f("zoomend",t)),n&&this.fire(new e.f("rotateend",t)),o&&this.fire(new e.f("pitchend",t)),this.fire(new e.f("moveend",t))}flyTo(t,i){if(this._prefersReducedMotion(t)){const r=e.ah(t,["center","zoom","bearing","pitch","around","padding"]);return this.jumpTo(r,i)}this.stop(),t=e.W({offset:[0,0],speed:1.2,curve:1.42,easing:e.d2},t);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.at(+t.zoom,r.minZoom,r.maxZoom):n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=r.zoomScale(l-n),p=e.P.convert(t.offset);let f=r.centerPoint.add(p);const m=r.pointLocation(f),_=e.aI.convert(t.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let x=t.curve;const v=Math.max(r.width,r.height),b=v/d,w=y.mag();if("minZoom"in t){const i=e.at(Math.min(t.minZoom,n,l),r.minZoom,r.maxZoom),o=v/r.zoomScale(i-n);x=Math.sqrt(o/w*2)}const T=x*x;function E(e){const t=(b*b-v*v+(e?-1:1)*T*T*w*w)/(2*(e?b:v)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function M(e){return(Math.exp(e)+Math.exp(-e))/2}const I=E(0);let A=function(e){return M(I)/M(I+x*e)},C=function(e){return v*((M(I)*(S(t=I+x*e)/M(t))-S(I))/T)/w;var t},P=(E(1)-I)/x;if(Math.abs(w)<1e-6||!isFinite(P)){if(Math.abs(v-b)<1e-6)return this.easeTo(t,i);const e=bt.maxDuration&&(t.duration=0);const z=o!==c,D=u!==s,L=!r.isPaddingEqual(h),R=r=>d=>{const m=d*P,x=1/A(m);r.zoom=1===d?l:n+r.scaleZoom(x),z&&(r.bearing=e.a2(o,c,d)),D&&(r.pitch=e.a2(s,u,d)),L&&(r.interpolatePadding(a,h,d),f=r.centerPoint.add(p));const v=1===d?_:r.unproject(g.add(y.mult(C(m))).mult(x));return r.setLocationAtPoint(r.renderWorldCopies?v.wrap():v,f),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(R,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=z,this._pitching=D,this._padding=L,this._prepareEase(i,!1),this._ease(R(r),(()=>this._afterEase(i)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,i,r){!1===r.animate||0===r.duration?(t(1),i()):(this._easeStart=e.e.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.e.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,i){t=e.au(t,-180,180);const r=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.e.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone())}return n}_preloadTiles(e,t){}}class Bs{constructor(t={}){this.options=t,e.bp(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o("div","mapboxgl-ctrl-attrib-inner",this._container),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.d8.ACCESS_TOKEN}];if(t){const r=i.reduce(((e,t,r)=>(t.value&&(e+=`${t.key}=${t.value}${re.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Fs{constructor(){e.bp(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class Ns{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Vs(t,i,r){if(t=new e.aI(t.lng,t.lat),i){const n=new e.aI(t.lng-360,t.lat),o=new e.aI(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),a=r.locationPoint(t).distSqr(i),l=i.x<0||i.y<0||i.x>r.width||i.y>r.height;r.locationPoint(n).distSqr(i)180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const Us={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class js extends e.E{constructor(t,i){if(super(),(t instanceof HTMLElement||i)&&(t=e.W({element:t},i)),e.bp(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const i=41,r=27,n=s("svg",{display:"block",height:i*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${i}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},n));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),s("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},n),s("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},n),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),this._offset=e.P.convert(t&&t.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const r=this._element.classList;for(const e in Us)r.remove(`mapboxgl-marker-anchor-${e}`);r.add(`mapboxgl-marker-anchor-${this._anchor}`);const n=t&&t.className?t.className.trim().split(/\s+/):[];r.add(...n),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.aI.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=13.5,i=Math.sqrt(Math.pow(t,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[i,-34.14594154601839],"bottom-right":[-9.545941546018392,-34.14594154601839],left:[t,-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}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const i=e.unproject(t),r=e.getFreeCameraOptions();if(!r.position)return!1;const n=r.position.toLngLat();return n.distanceTo(i)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const r=t.unproject(i);let n;t._showingGlobe()&&e.d9(t.transform,this._lngLat)?n=0:(n=1-t._queryFogOpacity(r),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(n*=this._occludedOpacity)),this._element.style.opacity=`${n}`,this._element.style.pointerEvents=n>0?"auto":"none",this._popup&&this._popup._setOpacity(n),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${Us[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,i=this._map,r=this.getPitchAlignment();if(!i||!t||"map"!==r)return"";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const n=e.b0(e.da(i.transform,this._lngLat)),o=t.sub(e.db(i.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=n/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return"";let r=0;const n=this.getRotationAlignment();if("map"===n)if(i._showingGlobe()){const t=i.project(new e.aI(this._lngLat.lng,this._lngLat.lat+.001)),n=i.project(new e.aI(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);r=e.b0(Math.atan2(n.y,n.x))-90}else r=-i.getBearing();else if("horizon"===n){const n=e.$(4,6,i.getZoom()),o=e.db(i.transform);o.y+=n*i.transform.height;const s=t.sub(o),a=e.b0(Math.atan2(s.y,s.x));r=(a>90?a-270:a+90)*(1-n)}return r+=this._rotation,r?`rotateZ(${r}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Vs(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),t._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const i=this._map;if(!i)return;const r=this._pointerdownPos,n=this._positionDelta;if(r&&n){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(r)=this._endTime)return this._end;const i=e.b9((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i}}const Ws={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class Hs{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}const Xs={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},Ys={showCompass:!0,showZoom:!0,visualizePitch:!1};class Ks{constructor(t,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new ls({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new cs({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bp(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),p()}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){f(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.W({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),g(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,g(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=y(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=y(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)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.de(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new gi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Ns,this._domRenderTaskQueue=new Ns,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.df(),this._locale=e.W({},Ws,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new $s(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._lastDirtyFrameId=0,this._requestManager=new e.dg(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?h({},t.contextCreateOptions):{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.bp(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new Hs),this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},(()=>{this._update()})),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Rs(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.d8.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new No("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==i.center&&null==i.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const r=t.bounds;r&&(this.resize(),this.fitBounds(r,e.W({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new Bs({customAttribution:t.customAttribution})),this._logoControl=new Fs,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent()})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.f(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.f(`${t.dataType}dataloading`,t))}))}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.d(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.d(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new e.f("movestart",t)).fire(new e.f("move",t)),this.fire(new e.f("resize",t)),i&&this.fire(new e.f("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.ai.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.f("zoomstart")).fire(new e.f("zoom")).fire(new e.f("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.f("pitchstart")).fire(new e.f("pitch")).fire(new e.f("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return"auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?navigator.language:e)):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,i=t.projection.name;let r;"globe"===i&&t.zoom>=e.aU?(t.setMercatorFromTransition(),r=!0):"mercator"===i&&t.zoom=e.aU?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),i&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t){return this.transform.locationPoint3D(e.aI.convert(t))}unproject(t){return this.transform.pointLocation3D(e.P.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),s=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new Xo(e,this,n.originalEvent,{features:s}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new Xo(e,this,n.originalEvent)))},o=t=>{r&&(r=!1,i.call(this,new Xo(e,this,t.originalEvent)))};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),n=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features)};return{layers:new Set(t),listener:i,delegates:{[e]:r}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);const r=new Set(Array.isArray(t)?t:[t]);for(const e of r)if(!this._isValidId(e))return this;const n=(e,t)=>{if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0},o=this._delegatedListeners?this._delegatedListeners[e]:void 0;return o&&(e=>{for(let t=0;t{r?(e.w(`Unable to perform style diff: ${String(r.message||r.error||r)}. Rebuilding the style from scratch.`),this._updateStyle(t,i)):n&&this._update(!0)}),(()=>{this._postStyleLoadEvent()})),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(t,i){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){const r=e.W({},i);i&&i.config&&(r.initialConfig=i.config,delete r.config),this.style=new Bo(this,r).load(t),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Bo(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.d(new Error("IDs can't be empty."))),!1):!e.cV(t)||(this.fire(new e.d(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:l,height:c,data:u}=e.e.getImageData(i);this.style.addImage(t,{data:new e.i({width:l,height:c},u),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0})}else if(void 0===i.width||void 0===i.height)this.fire(new e.d(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:c}=i,u=i;this.style.addImage(t,{data:new e.i({width:l,height:c},new Uint8Array(u.data)),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:u}),u.onAdd&&u.onAdd(this,t)}}updateImage(t,i){this._lazyInitEmptyStyle();const r=this.style.getImage(t);if(!r)return void this.fire(new e.d(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.e.getImageData(i):i,{width:o,height:s,data:a}=n;if(void 0===o||void 0===s)return void this.fire(new e.d(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==r.data.width||s!==r.data.height)return void this.fire(new e.d(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const l=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);r.data.replace(a,l),this.style.updateImage(t,r)}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.d(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,i){e.h(this._requestManager.transformRequest(t,e.R.Image),((t,r)=>{i(t,r instanceof HTMLImageElement?e.e.getImageData(r):r)}))}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.d(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(e,t){return this.style.addImport(e,t),this}updateImport(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}getSlots(){return this.style.getSlots()}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.aI.convert(t),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,r,n,o=this._container;for(;o&&(!r||!n);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(r=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(n=i[3])),o=o.parentElement}this._containerWidth=r?Math.abs(e/r):e,this._containerHeight=n?Math.abs(t/n):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._canvas=o("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=o("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{r[e]=o("div",`mapboxgl-ctrl-${e}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const r=e.e.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.W({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl2",t);r?(e.dh(r,!0),this.painter=new Rn(r,this._contextCreateOptions,this.transform,this._tp),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.di.testSupport(r)):this.fire(new e.d(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.f("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.f("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty&&!this._occlusionOpacityChanged&&this._occlusionCriteriaSatisfied()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let i;this.fire(new e.f("renderstart")),++this._frameId;const r=this.painter.context.extTimerQuery,n=e.e.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(i=o.createQuery(),o.beginQuery(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,r=e.e.now(),n=new e.X(t,{now:r,fadeDuration:s,pitch:i,transition:this.style.transition});this.style.update(n)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(n),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(n);const l=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions,this.painter.replacementSource);if(l&&(this._placementDirty=l.needsRerender,this._occlusionOpacityChanged=l.occlusionQueryBasedOpacityChanged),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.f("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.dc.mark(e.dd.load),this.fire(new e.f("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=e.e.now()-n;o.endQuery(r.TIME_ELAPSED_EXT),setTimeout((()=>{const r=o.getQueryParameter(i,o.QUERY_RESULT)/1e6;o.deleteQuery(i),this.fire(new e.f("gpu-timing-frame",{cpuTime:t,gpuTime:r}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.f("gpu-timing-layer",{layerTimes:i}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.f("gpu-timing-deferred-render",{gpuTime:i}))}),50)}const c=this._sourcesDirty||this._styleDirty||this._placementDirty||this._occlusionOpacityChanged||a;if((this._sourcesDirty||this._styleDirty||a||this._occlusionOpacityChanged)&&(this._lastDirtyFrameId=this._frameId),c||this._repaint||!this._occlusionCriteriaSatisfied())this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(n,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.f("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.f("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}this._loaded&&!this._fullyLoaded&&!c&&this._occlusionCriteriaSatisfied()&&(this._fullyLoaded=!0,e.dc.mark(e.dd.fullLoad),this._performanceMetricsCollection&&e.dj(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){e.dk(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.dl||401===t.status)){const t=this.painter.context.gl;e.dh(t,!1),this._logoControl instanceof Fs&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.d(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),e.dm(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_postStyleLoadEvent(){this.style.globalId&&e.dn(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.ds(i,((e,i)=>e._preloadTiles(t,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(t,i){e.du(t,i)}_occlusionCriteriaSatisfied(){const e=this.style&&(this.style.has3DLayers()||this.style.terrain&&!this.style.disableElevatedTerrain);return!(this.style&&this.style.hasSymbolLayers()&&e&&this.painter)||this._frameId-this._lastDirtyFrameId>5+2*this.painter.symbolParams.occlusionQueryFrameWindow}get version(){return e.dt}},NavigationControl:class{constructor(t){this.options=e.W({},Ys,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.bp(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.bp(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ks(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const i=o("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends e.E{constructor(t){super();const i=navigator.geolocation;this.options=e.W({geolocation:i},Js,t),e.bp(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Fo(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then((e=>t("denied"!==e.state))).catch((()=>t())):t()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return!!t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.f("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.f("geolocate",t)),this._finish()}}_updateCamera(t){const i=new e.aI(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,n=this._map.getBearing(),o=e.W({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.aI(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,i=e.ax(1,t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.f("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new js({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new js({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.f("trackuserlocationend")))}))}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.f("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.f("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.f("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Bs,ScaleControl:class{constructor(t){this.options=e.W({},Qs,t),this._isNumberFormatSupported=(function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}})(),e.bp(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,r=t._containerWidth/2-e/2,n=t.unproject([r,i]),o=t.unproject([r+e,i]),s=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter")}_setScale(e,t,i){this._map._requestDomTask((()=>{const r=(function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:(function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t})(i),t*i})(t),n=r/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(r):`${r} ${ea[i]}`,this._container.style.width=e*n+"px"}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.bp(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.E{constructor(t){super(),this.options=e.W(Object.create(Gs),t),e.bp(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.f("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.f("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.aI.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,r=this._pos;if(!t||!i||!r)return"bottom";const n=i.offsetWidth,o=i.offsetHeight,s=r.xt.transform.width-n/2;if(r.y+et.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const i=this._map,r=this._content;if(!i||!this._lngLat&&!this._trackPointer||!r)return;let n=this._container;if(n||(n=this._container=o("div","mapboxgl-popup",i.getContainer()),this._tip=o("div","mapboxgl-popup-tip",n),n.appendChild(r)),this.options.maxWidth&&n.style.maxWidth!==this.options.maxWidth&&(n.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Vs(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:i.project(this._lngLat),r=Zs(this.options.offset),n=this._anchor=this._getAnchor(r.y),o=Zs(this.options.offset,n),s=e.add(o).round();i._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${Us[n]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&i._showingGlobe()){const t=e.d9(i.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(qs);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:js,Style:Bo,LngLat:e.aI,LngLatBounds:e.ai,Point:e.P,MercatorCoordinate:e.Y,FreeCameraOptions:Yt,Evented:e.E,config:e.d8,prewarm:e.dx,clearPrewarmedResources:e.dy,get accessToken(){return e.d8.ACCESS_TOKEN},set accessToken(t){e.d8.ACCESS_TOKEN=t},get baseApiUrl(){return e.d8.API_URL},set baseApiUrl(t){e.d8.API_URL=t},get workerCount(){return e.dz.workerCount},set workerCount(t){e.dz.workerCount=t},get maxParallelImageRequests(){return e.d8.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.d8.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.dA(t)},get workerUrl(){return e.dB.workerUrl},set workerUrl(t){e.dB.workerUrl=t},get workerClass(){return e.dB.workerClass},set workerClass(t){e.dB.workerClass=t},get workerParams(){return e.dB.workerParams},set workerParams(t){e.dB.workerParams=t},get dracoUrl(){return e.dC()},set dracoUrl(t){e.dD(t)},get meshoptUrl(){return e.dE()},set meshoptUrl(t){e.dF(t)},setNow:e.e.setNow,restoreNow:e.e.restoreNow};return ta})),i}))}),84,[85,6]); +__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;o(null==e?void 0:e.title)??(null==t?void 0:t.name))}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.useEffect((()=>{if(!n)return;const e=t.current;if(e){const t=r(e.getCurrentOptions(),e.getCurrentRoute());document.title=t}return null==e?void 0:e.addListener('options',(t=>{const n=r(t.data.options,null==e?void 0:e.getCurrentRoute());document.title=n}))}))};var e=(function(e,n){if(!n&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=t(n);if(r&&r.has(e))return r.get(e);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var l=u?Object.getOwnPropertyDescriptor(e,i):null;l&&(l.get||l.set)?Object.defineProperty(o,i,l):o[i]=e[i]}return o.default=e,r&&r.set(e,o),o})(_r(d[0]));function t(e){if("function"!=typeof WeakMap)return null;var n=new WeakMap,r=new WeakMap;return(t=function(e){return e?r:n})(e)}}),225,[14]); +__d((function(g,_r,_i,_a,m,_e,d){Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=function(t){let{enabled:n=!0,formatter:r=(e,t)=>(null==e?void 0:e.title)??(null==t?void 0:t.name)}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.useEffect((()=>{if(!n)return;const e=t.current;if(e){const t=r(e.getCurrentOptions(),e.getCurrentRoute());document.title=t}return null==e?void 0:e.addListener('options',(t=>{const n=r(t.data.options,null==e?void 0:e.getCurrentRoute());document.title=n}))}))};var e=(function(e,n){if(!n&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=t(n);if(r&&r.has(e))return r.get(e);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var l=u?Object.getOwnPropertyDescriptor(e,i):null;l&&(l.get||l.set)?Object.defineProperty(o,i,l):o[i]=e[i]}return o.default=e,r&&r.set(e,o),o})(_r(d[0]));function t(e){if("function"!=typeof WeakMap)return null;var n=new WeakMap,r=new WeakMap;return(t=function(e){return e?r:n})(e)}}),225,[14]); __d((function(g,_r,_i,_a,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=function(e,s){let{independent:u,enabled:c=!0,config:l,getStateFromPath:f=_r(d[5]).getStateFromPath,getPathFromState:h=_r(d[5]).getPathFromState,getActionFromState:p=_r(d[5]).getActionFromState}=s;r.useEffect((()=>{}),[c,u]);const[v]=r.useState(n.default),y=r.useRef(c),R=r.useRef(l),k=r.useRef(f),w=r.useRef(h),P=r.useRef(p);r.useEffect((()=>{y.current=c,R.current=l,k.current=f,w.current=h,P.current=p}));const S=r.useContext(o.default),b=r.useCallback((()=>{let e;if(y.current){const t=(null==S?void 0:S.location)??window.location,r=t?t.pathname+t.search:void 0;r&&(e=k.current(r,R.current))}const t={then:t=>Promise.resolve(t?t(e):e),catch:()=>t};return t}),[]),_=r.useRef(void 0),F=r.useRef(void 0),O=r.useRef(void 0);return r.useEffect((()=>(_.current=v.index,v.listen((()=>{const t=e.current;if(!t||!c)return;const{location:r}=window,n=r.pathname+r.search,o=v.index,s=_.current??0;_.current=o,O.current=n;const a=v.get(o);if((null==a?void 0:a.path)===n&&null!=a&&a.state)return void t.resetRoot(a.state);const i=k.current(n,R.current);if(i){const e=t.getRootState();if(i.routes.some((t=>!(null!=e&&e.routeNames.includes(t.name)))))return void console.warn("The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.");if(o>s){const e=P.current(i,R.current);if(void 0!==e)try{t.dispatch(e)}catch(e){console.warn(`An error occurred when trying to handle the link '${n}': ${'object'==typeof e&&null!=e&&'message'in e?e.message:e}`)}else t.resetRoot(i)}else t.resetRoot(i)}else t.resetRoot(i)})))),[c,v,e]),r.useEffect((()=>{var r;if(!c)return;const n=(e,r)=>{if(null!=e&&e.path){const r=k.current(e.path,R.current);if(r){const n=(0,_r(d[5]).findFocusedRoute)(r);if(n&&n.name===e.name&&(0,t.default)(n.params,e.params))return e.path}}return w.current(r,R.current)};if(e.current){const t=e.current.getRootState();if(t){const e=(0,_r(d[5]).findFocusedRoute)(t),r=n(e,t);void 0===F.current&&(F.current=t),v.replace({path:r,state:t})}}return null===(r=e.current)||void 0===r?void 0:r.addListener('state',i((async()=>{const t=e.current;if(!t||!c)return;const r=F.current,o=t.getRootState();if(!o)return;const s=O.current,i=(0,_r(d[5]).findFocusedRoute)(o),u=n(i,o);F.current=o,O.current=void 0;const[l,f]=a(r,o);if(l&&f&&u!==s){const e=(f.history?f.history.length:f.routes.length)-(l.history?l.history.length:l.routes.length);if(e>0)v.push({path:u,state:o});else if(e<0){const t=v.backIndex({path:u}),r=v.index;try{-1!==t&&t{if(void 0===e||void 0===t||e.key!==t.key)return[void 0,void 0];const r=e.history?e.history.length:e.routes.length,n=t.history?t.history.length:t.routes.length,o=e.routes[e.index],s=t.routes[t.index],i=o.state,u=s.state;return r!==n||o.key!==s.key||void 0===i||void 0===u||i.key!==u.key?[e,t]:a(i,u)},i=e=>{let t=Promise.resolve();return()=>{t=t.then(e)}};_e.series=i}),226,[1,227,14,228,229,145]); __d((function(g,r,_i,_a,m,e,d){'use strict';m.exports=function t(n,o){if(n===o)return!0;if(n&&o&&'object'==typeof n&&'object'==typeof o){if(n.constructor!==o.constructor)return!1;var f,u,i;if(Array.isArray(n)){if((f=n.length)!=o.length)return!1;for(u=f;0!=u--;)if(!t(n[u],o[u]))return!1;return!0}if(n.constructor===RegExp)return n.source===o.source&&n.flags===o.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===o.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===o.toString();if((f=(i=Object.keys(n)).length)!==Object.keys(o).length)return!1;for(u=f;0!=u--;)if(!Object.prototype.hasOwnProperty.call(o,i[u]))return!1;for(u=f;0!=u--;){var c=i[u];if(!t(n[c],o[c]))return!1}return!0}return n!=n&&o!=o}}),227,[]); __d((function(g,r,_i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){let t=0,n=[];const i=[],o=()=>{i.forEach((t=>{const n=t.cb;t.cb=()=>n(!0)}))};return{get index(){var t;const i=null===(t=window.history.state)||void 0===t?void 0:t.id;if(i){const t=n.findIndex((t=>t.id===i));return t>-1?t:0}return 0},get:t=>n[t],backIndex(i){let{path:o}=i;for(let i=t-1;i>=0;i--){if(n[i].path===o)return i}return-1},push(i){let{path:s,state:c}=i;o();const l=(0,r(d[0]).nanoid)();n=n.slice(0,t+1),n.push({path:s,state:c,id:l}),t=n.length-1,window.history.pushState({id:l},'',s)},replace(i){var s;let{path:c,state:l}=i;o();const h=(null===(s=window.history.state)||void 0===s?void 0:s.id)??(0,r(d[0]).nanoid)();let w=c;!n.length||n.findIndex((t=>t.id===h))<0?(w+=location.hash,n=[{path:w,state:l,id:h}],t=0):(n[t].path===c&&(w+=location.hash),n[t]={path:c,state:l,id:h}),window.history.replaceState({id:h},'',w)},go(s){o();const c=t+s,l=n.length-1;if(s<0&&!n[c]?(s=-t,t=0):s>0&&c>l?(s=l-t,t=l):t=c,0!==s)return new Promise(((o,c)=>{const l=t=>{if(clearTimeout(h),t)return void c(new Error('History was changed during navigation.'));const{title:n}=window.document;window.document.title='',window.document.title=n,o()};i.push({ref:l,cb:l});const h=setTimeout((()=>{const t=i.findIndex((t=>t.ref===l));t>-1&&(i[t].cb(),i.splice(t,1))}),100),w=()=>{var o;const s=null===(o=window.history.state)||void 0===o?void 0:o.id,c=n.findIndex((t=>t.id===s));t=Math.max(c,0);const l=i.pop();window.removeEventListener('popstate',w),null==l||l.cb()};window.addEventListener('popstate',w),window.history.go(s)}))},listen(t){const n=()=>{i.length||t()};return window.addEventListener('popstate',n),()=>window.removeEventListener('popstate',n)}}}}),228,[166]); @@ -614,19 +614,19 @@ __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Ob __d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.Badge=void 0;var t=e(r(d[1])),n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),i=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(o=Object.getOwnPropertySymbols(e);s{var u,{containerStyle:p,textStyle:y,textProps:b,badgeStyle:P,onPress:h,onLongPress:O,onPressOut:v,onPressIn:_,Component:j=(h||O||_||v?l.default:s.default),value:S,theme:x=r(d[6]).defaultTheme,status:B="primary",pressableProps:I}=e,C=i(e,["containerStyle","textStyle","textProps","badgeStyle","onPress","onLongPress","onPressOut","onPressIn","Component","value","theme","status","pressableProps"]);const E=(0,r(d[6]).renderNode)(o.default,S,Object.assign({style:n.default.flatten([c.text,y&&y])},b));return t.default.createElement(s.default,{testID:"RNE__Badge__Container",style:n.default.flatten([p&&p])},t.default.createElement(j,Object.assign({},Object.assign(Object.assign({onPress:h,onLongPress:O,onPressOut:v,onPressIn:_},I),C),{testID:"RNE__Badge",style:n.default.flatten([{alignSelf:'center',minWidth:f,height:f,borderRadius:f/2,alignItems:'center',justifyContent:'center',backgroundColor:null===(u=null==x?void 0:x.colors)||void 0===u?void 0:u[B],borderWidth:n.default.hairlineWidth,borderColor:'#fff'},!E&&c.miniBadge,P&&P])}),E))};_e.Badge=u;const f=18,c=n.default.create({miniBadge:{paddingHorizontal:0,paddingVertical:0,minWidth:8,height:8,borderRadius:4},text:{fontSize:12,color:'white',paddingHorizontal:4}});u.displayName='Badge'}),552,[1,14,27,93,123,336,402]); __d((function(g,r,_i,a,m,_e,d){var t=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.withBadge=void 0;var e=t(r(d[1])),n=t(r(d[2])),o=t(r(d[3])),l=this&&this.__rest||function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(o=Object.getOwnPropertySymbols(t);ls=>{const f=f=>{const{bottom:u,hidden:p=!1,left:y,containerStyle:b}=c,O=l(c,["bottom","hidden","left","containerStyle"]);let{right:h=-16,top:v=-1}=c;t||(h=-3,v=3);const j='function'==typeof t?t(f):t;return e.default.createElement(o.default,{style:n.default.flatten([i.container,b])},e.default.createElement(s,Object.assign({},f)),!p&&e.default.createElement(r(d[4]).Badge,Object.assign({value:j,status:"error",containerStyle:n.default.flatten([i.badgeContainer,{bottom:u,left:y,right:h,top:v}])},O)))};return f.displayName=`WithBadge(${s.displayName||s.name||'Component'})`,f};const i=n.default.create({badgeContainer:{position:'absolute'},container:{alignItems:'center',justifyContent:'center',position:'relative'}})}),553,[1,14,27,123,552]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BottomSheet",{enumerable:!0,get:function(){return r(d[0]).BottomSheet}})}),554,[555]); -__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.BottomSheet=void 0;var t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),n=e(r(d[4])),s=e(r(d[5])),i=e(r(d[6])),c=this&&this.__rest||function(e,t){var l={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(l[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n{var{containerStyle:f,backdropStyle:p,onBackdropPress:b=(()=>null),isVisible:y=!1,modalProps:O={},children:v,scrollViewProps:P={}}=e,S=c(e,["containerStyle","backdropStyle","onBackdropPress","isVisible","modalProps","children","scrollViewProps"]);return t.default.createElement(l.default,Object.assign({animationType:"slide",onRequestClose:b,transparent:!0,visible:y},O),t.default.createElement(s.default,{onPress:b,style:[n.default.absoluteFill,p],testID:"RNE__Overlay__backdrop"}),t.default.createElement(r(d[7]).SafeAreaView,Object.assign({style:n.default.flatten([u.safeAreaView,f&&f]),pointerEvents:"box-none"},S),t.default.createElement(o.default,null,t.default.createElement(i.default,Object.assign({},P),v))))};_e.BottomSheet=f;const u=n.default.create({safeAreaView:{flex:1,backgroundColor:'rgba(0,0,0,0.2)',flexDirection:'column-reverse'}});f.displayName='BottomSheet'}),555,[1,14,556,123,27,336,251,326]); +__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.BottomSheet=void 0;var t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),n=e(r(d[4])),s=e(r(d[5])),i=e(r(d[6])),c=this&&this.__rest||function(e,t){var l={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(l[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n{var{containerStyle:f,backdropStyle:p,onBackdropPress:b=()=>null,isVisible:y=!1,modalProps:O={},children:v,scrollViewProps:P={}}=e,S=c(e,["containerStyle","backdropStyle","onBackdropPress","isVisible","modalProps","children","scrollViewProps"]);return t.default.createElement(l.default,Object.assign({animationType:"slide",onRequestClose:b,transparent:!0,visible:y},O),t.default.createElement(s.default,{onPress:b,style:[n.default.absoluteFill,p],testID:"RNE__Overlay__backdrop"}),t.default.createElement(r(d[7]).SafeAreaView,Object.assign({style:n.default.flatten([u.safeAreaView,f&&f]),pointerEvents:"box-none"},S),t.default.createElement(o.default,null,t.default.createElement(i.default,Object.assign({},P),v))))};_e.BottomSheet=f;const u=n.default.create({safeAreaView:{flex:1,backgroundColor:'rgba(0,0,0,0.2)',flexDirection:'column-reverse'}});f.displayName='BottomSheet'}),555,[1,14,556,123,27,336,251,326]); __d((function(g,_r,_i,_a,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var t=e(_r(d[1])),n=e(_r(d[2])),r=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=u(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var o=a?Object.getOwnPropertyDescriptor(e,i):null;o&&(o.get||o.set)?Object.defineProperty(r,i,o):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r})(_r(d[3])),a=e(_r(d[4])),i=e(_r(d[5])),o=e(_r(d[6])),l=e(_r(d[7]));function u(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(u=function(e){return e?n:t})(e)}var f=["animationType","children","onDismiss","onRequestClose","onShow","transparent","visible"],s=0,c=[],p={};function v(){if(0!==c.length){var e=c[c.length-1];c.forEach((t=>{t in p&&p[t](t===e)}))}}function y(e){e in p&&(p[e](!1),delete p[e]);var t=c.indexOf(e);-1!==t&&(c.splice(t,1),v())}function b(e,t){y(e),c.push(e),p[e]=t,v()}var h=r.forwardRef(((e,u)=>{var c=e.animationType,p=e.children,v=e.onDismiss,h=e.onRequestClose,_=e.onShow,w=e.transparent,O=e.visible,j=void 0===O||O,E=(0,n.default)(e,f),M=r.useMemo((()=>s++),[]),P=r.useState(!1),k=P[0],C=P[1],D=r.useCallback((()=>{y(M),v&&v()}),[M,v]),R=r.useCallback((()=>{b(M,C),_&&_()}),[M,_]);return r.useEffect((()=>()=>y(M)),[M]),r.createElement(a.default,null,r.createElement(i.default,{animationType:c,onDismiss:D,onShow:R,visible:j},r.createElement(l.default,{active:k},r.createElement(o.default,(0,t.default)({},E,{active:k,onRequestClose:h,ref:u,transparent:w}),p))))}));_e.default=h}),556,[1,19,28,14,557,558,559,560]); __d((function(g,_r,_i,_a,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var t=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=u(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in e)if("default"!==f&&{}.hasOwnProperty.call(e,f)){var l=o?Object.getOwnPropertyDescriptor(e,f):null;l&&(l.get||l.set)?Object.defineProperty(n,f,l):n[f]=e[f]}return n.default=e,r&&r.set(e,n),n})(_r(d[1])),r=e(_r(d[2])),n=e(_r(d[3]));function u(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(u=function(e){return e?r:t})(e)}_e.default=function(e){var u=e.children,o=t.useRef(null);if(n.default&&!o.current){var f=document.createElement('div');f&&document.body&&(document.body.appendChild(f),o.current=f)}return t.useEffect((()=>{if(n.default)return()=>{document.body&&o.current&&(document.body.removeChild(o.current),o.current=null)}}),[]),o.current&&n.default?r.default.createPortal(u,o.current):null}}),557,[1,14,12,23]); __d((function(g,_r,_i,_a,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var t=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=r(t);if(n&&n.has(e))return n.get(e);var a={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&{}.hasOwnProperty.call(e,o)){var u=i?Object.getOwnPropertyDescriptor(e,o):null;u&&(u.get||u.set)?Object.defineProperty(a,o,u):a[o]=e[o]}return a.default=e,n&&n.set(e,a),a})(_r(d[1])),n=e(_r(d[2])),a=e(_r(d[3]));function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(r=function(e){return e?n:t})(e)}function i(e,t){return'slide'===e?t?u:f:'fade'===e?t?s:c:t?o.container:o.hidden}var o=n.default.create({container:{position:'fixed',top:0,right:0,bottom:0,left:0,zIndex:9999},animatedIn:{animationDuration:"300ms",animationTimingFunction:'ease-in'},animatedOut:{pointerEvents:'none',animationDuration:"300ms",animationTimingFunction:'ease-out'},fadeIn:{opacity:1,animationKeyframes:{'0%':{opacity:0},'100%':{opacity:1}}},fadeOut:{opacity:0,animationKeyframes:{'0%':{opacity:1},'100%':{opacity:0}}},slideIn:{transform:'translateY(0%)',animationKeyframes:{'0%':{transform:'translateY(100%)'},'100%':{transform:'translateY(0%)'}}},slideOut:{transform:'translateY(100%)',animationKeyframes:{'0%':{transform:'translateY(0%)'},'100%':{transform:'translateY(100%)'}}},hidden:{opacity:0}}),u=[o.container,o.animatedIn,o.slideIn],f=[o.container,o.animatedOut,o.slideOut],s=[o.container,o.animatedIn,o.fadeIn],c=[o.container,o.animatedOut,o.fadeOut];_e.default=function(e){var n=e.animationType,r=e.children,u=e.onDismiss,f=e.onShow,s=e.visible,c=t.useState(!1),l=c[0],p=c[1],y=t.useRef(!1),O=t.useRef(!1),v=n&&'none'!==n,_=t.useCallback((e=>{e&&e.currentTarget!==e.target||(s?f&&f():p(!1))}),[f,s]);return t.useEffect((()=>{O.current&&!l&&u&&u(),O.current=l}),[l,u]),t.useEffect((()=>{s&&p(!0),s===y.current||v||_(),y.current=s}),[v,s,_]),l||s?(0,a.default)('div',{style:l?i(n,s):o.hidden,onAnimationEnd:_,children:r}):null}}),558,[1,14,27,94]); __d((function(g,_r,_i,_a,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var t=e(_r(d[1])),r=e(_r(d[2])),a=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=u(t);if(r&&r.has(e))return r.get(e);var a={__proto__:null},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&{}.hasOwnProperty.call(e,o)){var l=n?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(a,o,l):a[o]=e[o]}return a.default=e,r&&r.set(e,a),a})(_r(d[3])),n=e(_r(d[4])),o=e(_r(d[5])),l=e(_r(d[6]));function u(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(u=function(e){return e?r:t})(e)}var f=["active","children","onRequestClose","transparent"],i=a.forwardRef(((e,o)=>{var u=e.active,i=e.children,p=e.onRequestClose,s=e.transparent,v=(0,r.default)(e,f);a.useEffect((()=>{if(l.default){var e=e=>{u&&'Escape'===e.key&&(e.stopPropagation(),p&&p())};return document.addEventListener('keyup',e,!1),()=>document.removeEventListener('keyup',e,!1)}}),[u,p]);var y=a.useMemo((()=>[c.modal,s?c.modalTransparent:c.modalOpaque]),[s]);return a.createElement(n.default,(0,t.default)({},v,{"aria-modal":!0,ref:o,role:u?'dialog':null,style:y}),a.createElement(n.default,{style:c.container},i))})),c=o.default.create({modal:{position:'fixed',top:0,right:0,bottom:0,left:0},modalTransparent:{backgroundColor:'transparent'},modalOpaque:{backgroundColor:'white'},container:{top:0,flex:1}});_e.default=i}),559,[1,19,28,14,123,27,23]); __d((function(g,_r,_i,_a,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var t=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=a(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var c in e)if("default"!==c&&{}.hasOwnProperty.call(e,c)){var o=u?Object.getOwnPropertyDescriptor(e,c):null;o&&(o.get||o.set)?Object.defineProperty(n,c,o):n[c]=e[c]}return n.default=e,r&&r.set(e,n),n})(_r(d[1])),r=e(_r(d[2])),n=e(_r(d[3])),u=e(_r(d[4])),c=e(_r(d[5])),o=e(_r(d[6]));function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(a=function(e){return e?r:t})(e)}var l=()=>(0,n.default)('div',{role:'none',tabIndex:0,style:v.focusBracket});function f(e){if(!o.default)return!1;try{e.focus()}catch(e){}return document.activeElement===e}function i(e){for(var t=0;t=0;t--){var r=e.childNodes[t];if(f(r)||s(r))return!0}return!1}_e.default=e=>{var n=e.active,u=e.children,a=t.useRef(),f=t.useRef({trapFocusInProgress:!1,lastFocusedElement:null});return t.useEffect((()=>{if(o.default){var e=()=>{if(null!=a.current&&!f.current.trapFocusInProgress&&n){try{if(f.current.trapFocusInProgress=!0,document.activeElement instanceof Node&&!a.current.contains(document.activeElement)){var e=i(a.current);f.current.lastFocusedElement===document.activeElement&&(e=s(a.current)),!e&&null!=a.current&&document.activeElement&&c.default.focus(a.current)}}finally{f.current.trapFocusInProgress=!1}f.current.lastFocusedElement=document.activeElement}};return e(),document.addEventListener('focus',e,!0),()=>document.removeEventListener('focus',e,!0)}}),[n]),t.useEffect((function(){if(o.default){var e=document.activeElement;return function(){e&&document.contains(e)&&c.default.focus(e)}}}),[]),t.createElement(t.Fragment,null,t.createElement(l,null),t.createElement(r.default,{ref:a},u),t.createElement(l,null))};var v=u.default.create({focusBracket:{outlineStyle:'none'}})}),560,[1,14,123,94,27,106,23]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Button",{enumerable:!0,get:function(){return r(d[0]).Button}})}),561,[562]); -__d((function(g,_r,_i,_a2,m,_e2,d){var e=_r(d[0]);Object.defineProperty(_e2,"__esModule",{value:!0}),_e2.Button=void 0;e(_r(d[1]));var t=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var o=a(t);if(o&&o.has(e))return o.get(e);var n={__proto__:null},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var l=r?Object.getOwnPropertyDescriptor(e,i):null;l&&(l.get||l.set)?Object.defineProperty(n,i,l):n[i]=e[i]}return n.default=e,o&&o.set(e,n),n})(_r(d[2])),o=e(_r(d[3])),n=(e(_r(d[4])),e(_r(d[5]))),r=e(_r(d[6])),i=(e(_r(d[7])),e(_r(d[8]))),l=e(_r(d[9]));function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,o=new WeakMap;return(a=function(e){return e?o:t})(e)}var s=this&&this.__rest||function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r{var o;return{color:'solid'===e?'white':null===(o=null==t?void 0:t.colors)||void 0===o?void 0:o.primary,size:'small'}},u={top:'column',bottom:'column-reverse',left:'row',right:'row-reverse'},f=e=>{var a,f,b,y,v,h,{TouchableComponent:O,containerStyle:w,onPress:P=(()=>{}),buttonStyle:j,type:S="solid",loading:C=!1,loadingStyle:_,loadingProps:k,size:z="md",radius:E="xs",uppercase:T=!1,color:M="primary",title:R="",titleProps:x,titleStyle:N,icon:V,iconContainerStyle:W,iconRight:D=!1,disabled:I=!1,disabledStyle:B,disabledTitleStyle:A,raised:G=!1,linearGradientProps:H,ViewComponent:q=l.default,theme:F=_r(d[10]).defaultTheme,iconPosition:U="left",children:Y=R}=e,J=s(e,["TouchableComponent","containerStyle","onPress","buttonStyle","type","loading","loadingStyle","loadingProps","size","radius","uppercase","color","title","titleProps","titleStyle","icon","iconContainerStyle","iconRight","disabled","disabledStyle","disabledTitleStyle","raised","linearGradientProps","ViewComponent","theme","iconPosition","children"]);(0,t.useEffect)((()=>{H&&!q&&console.warn("You need to pass a ViewComponent to use linearGradientProps !\nExample: ViewComponent={require('react-native-linear-gradient')}")}));const K=(0,t.useCallback)((e=>{C||I||P(e)}),[C,P,I]),L=O||i.default,Q=(0,t.useMemo)((()=>{var e,t;return n.default.flatten([{color:'solid'===S?'white':null===(e=null==F?void 0:F.colors)||void 0===e?void 0:e.primary},T&&{textTransform:'uppercase'},p.title,N,I&&{color:(0,_r(d[10]).color)(null===(t=null==F?void 0:F.colors)||void 0===t?void 0:t.disabled).darken(.3).string()},I&&A])}),[I,A,N,null===(a=null==F?void 0:F.colors)||void 0===a?void 0:a.disabled,null===(f=null==F?void 0:F.colors)||void 0===f?void 0:f.primary,S,T]),X=(0,t.useMemo)((()=>Object.assign(Object.assign({},c(S,F)),k)),[k,F,S]),Z=(0,t.useMemo)((()=>({disabled:!!I,busy:!!C})),[I,C]),$=(0,t.useMemo)((()=>{var e;return Number(null!==(e=F.spacing[E])&&void 0!==e?e:E||'0')||0}),[E,F]);return t.default.createElement(l.default,{style:[p.container,{borderRadius:$},w,G&&!I&&'clear'!==S&&p.raised],testID:"RNE_BUTTON_WRAPPER"},t.default.createElement(L,Object.assign({onPress:K,delayPressIn:0,activeOpacity:.3,accessibilityRole:"button",accessibilityState:Z,disabled:I,background:undefined},J),t.default.createElement(q,Object.assign({},H,{style:n.default.flatten([p.button,{padding:F.spacing[z],paddingHorizontal:F.spacing[z]+2,borderRadius:$,flexDirection:u[D?'right':U]||'row',backgroundColor:'solid'===S?F.colors[M]||M||(null===(b=null==F?void 0:F.colors)||void 0===b?void 0:b.primary):'transparent',borderColor:null===(y=null==F?void 0:F.colors)||void 0===y?void 0:y.primary,borderWidth:'outline'===S?n.default.hairlineWidth:0},j,I&&'solid'===S&&{backgroundColor:null===(v=null==F?void 0:F.colors)||void 0===v?void 0:v.disabled},I&&'outline'===S&&{borderColor:(0,_r(d[10]).color)(null===(h=null==F?void 0:F.colors)||void 0===h?void 0:h.disabled).darken(.3).string()},I&&B])}),C&&t.default.createElement(o.default,Object.assign({style:n.default.flatten([p.loading,_]),color:X.color,size:X.size},X)),!C&&V&&(0,_r(d[10]).renderNode)(_r(d[11]).Icon,V,{containerStyle:n.default.flatten([p.iconContainer,W])}),!C&&t.default.Children.toArray(Y).map(((e,o)=>t.default.createElement(t.default.Fragment,{key:o},'string'==typeof e?(0,_r(d[10]).renderNode)(r.default,e,Object.assign({style:Object.assign({},Q)},x)):e))))))};_e2.Button=f;const p=n.default.create({button:{flexDirection:'row',justifyContent:'center',alignItems:'center',padding:_r(d[10]).defaultTheme.spacing.md,paddingHorizontal:_r(d[10]).defaultTheme.spacing.lg},container:{overflow:'hidden'},title:Object.assign({fontSize:16,textAlign:'center',paddingVertical:1},{fontSize:18}),iconContainer:{marginHorizontal:5},raised:Object.assign({backgroundColor:'#fff',overflow:'visible'},{shadowColor:'rgba(0,0,0, .4)',shadowOffset:{height:1,width:1},shadowOpacity:1,shadowRadius:1}),loading:{marginVertical:2}});f.displayName='Button'}),562,[1,405,14,563,77,27,93,564,355,123,402,545]); +__d((function(g,_r,_i,_a2,m,_e2,d){var e=_r(d[0]);Object.defineProperty(_e2,"__esModule",{value:!0}),_e2.Button=void 0;e(_r(d[1]));var t=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var o=a(t);if(o&&o.has(e))return o.get(e);var n={__proto__:null},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var l=r?Object.getOwnPropertyDescriptor(e,i):null;l&&(l.get||l.set)?Object.defineProperty(n,i,l):n[i]=e[i]}return n.default=e,o&&o.set(e,n),n})(_r(d[2])),o=e(_r(d[3])),n=(e(_r(d[4])),e(_r(d[5]))),r=e(_r(d[6])),i=(e(_r(d[7])),e(_r(d[8]))),l=e(_r(d[9]));function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,o=new WeakMap;return(a=function(e){return e?o:t})(e)}var s=this&&this.__rest||function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r{var o;return{color:'solid'===e?'white':null===(o=null==t?void 0:t.colors)||void 0===o?void 0:o.primary,size:'small'}},u={top:'column',bottom:'column-reverse',left:'row',right:'row-reverse'},f=e=>{var a,f,b,y,v,h,{TouchableComponent:O,containerStyle:w,onPress:P=()=>{},buttonStyle:j,type:S="solid",loading:C=!1,loadingStyle:_,loadingProps:k,size:z="md",radius:E="xs",uppercase:T=!1,color:M="primary",title:R="",titleProps:x,titleStyle:N,icon:V,iconContainerStyle:W,iconRight:D=!1,disabled:I=!1,disabledStyle:B,disabledTitleStyle:A,raised:G=!1,linearGradientProps:H,ViewComponent:q=l.default,theme:F=_r(d[10]).defaultTheme,iconPosition:U="left",children:Y=R}=e,J=s(e,["TouchableComponent","containerStyle","onPress","buttonStyle","type","loading","loadingStyle","loadingProps","size","radius","uppercase","color","title","titleProps","titleStyle","icon","iconContainerStyle","iconRight","disabled","disabledStyle","disabledTitleStyle","raised","linearGradientProps","ViewComponent","theme","iconPosition","children"]);(0,t.useEffect)((()=>{H&&!q&&console.warn("You need to pass a ViewComponent to use linearGradientProps !\nExample: ViewComponent={require('react-native-linear-gradient')}")}));const K=(0,t.useCallback)((e=>{C||I||P(e)}),[C,P,I]),L=O||i.default,Q=(0,t.useMemo)((()=>{var e,t;return n.default.flatten([{color:'solid'===S?'white':null===(e=null==F?void 0:F.colors)||void 0===e?void 0:e.primary},T&&{textTransform:'uppercase'},p.title,N,I&&{color:(0,_r(d[10]).color)(null===(t=null==F?void 0:F.colors)||void 0===t?void 0:t.disabled).darken(.3).string()},I&&A])}),[I,A,N,null===(a=null==F?void 0:F.colors)||void 0===a?void 0:a.disabled,null===(f=null==F?void 0:F.colors)||void 0===f?void 0:f.primary,S,T]),X=(0,t.useMemo)((()=>Object.assign(Object.assign({},c(S,F)),k)),[k,F,S]),Z=(0,t.useMemo)((()=>({disabled:!!I,busy:!!C})),[I,C]),$=(0,t.useMemo)((()=>{var e;return Number(null!==(e=F.spacing[E])&&void 0!==e?e:E||'0')||0}),[E,F]);return t.default.createElement(l.default,{style:[p.container,{borderRadius:$},w,G&&!I&&'clear'!==S&&p.raised],testID:"RNE_BUTTON_WRAPPER"},t.default.createElement(L,Object.assign({onPress:K,delayPressIn:0,activeOpacity:.3,accessibilityRole:"button",accessibilityState:Z,disabled:I,background:undefined},J),t.default.createElement(q,Object.assign({},H,{style:n.default.flatten([p.button,{padding:F.spacing[z],paddingHorizontal:F.spacing[z]+2,borderRadius:$,flexDirection:u[D?'right':U]||'row',backgroundColor:'solid'===S?F.colors[M]||M||(null===(b=null==F?void 0:F.colors)||void 0===b?void 0:b.primary):'transparent',borderColor:null===(y=null==F?void 0:F.colors)||void 0===y?void 0:y.primary,borderWidth:'outline'===S?n.default.hairlineWidth:0},j,I&&'solid'===S&&{backgroundColor:null===(v=null==F?void 0:F.colors)||void 0===v?void 0:v.disabled},I&&'outline'===S&&{borderColor:(0,_r(d[10]).color)(null===(h=null==F?void 0:F.colors)||void 0===h?void 0:h.disabled).darken(.3).string()},I&&B])}),C&&t.default.createElement(o.default,Object.assign({style:n.default.flatten([p.loading,_]),color:X.color,size:X.size},X)),!C&&V&&(0,_r(d[10]).renderNode)(_r(d[11]).Icon,V,{containerStyle:n.default.flatten([p.iconContainer,W])}),!C&&t.default.Children.toArray(Y).map(((e,o)=>t.default.createElement(t.default.Fragment,{key:o},'string'==typeof e?(0,_r(d[10]).renderNode)(r.default,e,Object.assign({style:Object.assign({},Q)},x)):e))))))};_e2.Button=f;const p=n.default.create({button:{flexDirection:'row',justifyContent:'center',alignItems:'center',padding:_r(d[10]).defaultTheme.spacing.md,paddingHorizontal:_r(d[10]).defaultTheme.spacing.lg},container:{overflow:'hidden'},title:Object.assign({fontSize:16,textAlign:'center',paddingVertical:1},{fontSize:18}),iconContainer:{marginHorizontal:5},raised:Object.assign({backgroundColor:'#fff',overflow:'visible'},{shadowColor:'rgba(0,0,0, .4)',shadowOffset:{height:1,width:1},shadowOpacity:1,shadowRadius:1}),loading:{marginVertical:2}});f.displayName='Button'}),562,[1,405,14,563,77,27,93,564,355,123,402,545]); __d((function(g,_r,_i,_a,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var t=e(_r(d[1])),a=e(_r(d[2])),n=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var a=o(t);if(a&&a.has(e))return a.get(e);var n={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if("default"!==r&&{}.hasOwnProperty.call(e,r)){var l=i?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(n,r,l):n[r]=e[r]}return n.default=e,a&&a.set(e,n),n})(_r(d[3])),i=e(_r(d[4])),r=e(_r(d[5]));function o(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,a=new WeakMap;return(o=function(e){return e?a:t})(e)}var l=["animating","color","hidesWhenStopped","size","style"],s=e=>n.createElement("circle",{cx:"16",cy:"16",fill:"none",r:"14",strokeWidth:"4",style:e}),u=n.forwardRef(((e,i)=>{var o=e.animating,u=void 0===o||o,p=e.color,h=void 0===p?'#1976D2':p,y=e.hidesWhenStopped,v=void 0===y||y,w=e.size,_=void 0===w?'small':w,b=e.style,P=(0,a.default)(e,l),k=n.createElement("svg",{height:"100%",viewBox:"0 0 32 32",width:"100%"},s({stroke:h,opacity:.2}),s({stroke:h,strokeDasharray:80,strokeDashoffset:60}));return n.createElement(r.default,(0,t.default)({},P,{"aria-valuemax":1,"aria-valuemin":0,ref:i,role:"progressbar",style:[f.container,b]}),n.createElement(r.default,{children:k,style:['number'==typeof _?{height:_,width:_}:c[_],f.animation,!u&&f.animationPause,!u&&v&&f.hidesWhenStopped]}))}));u.displayName='ActivityIndicator';var f=i.default.create({container:{alignItems:'center',justifyContent:'center'},hidesWhenStopped:{visibility:'hidden'},animation:{animationDuration:'0.75s',animationKeyframes:[{'0%':{transform:'rotate(0deg)'},'100%':{transform:'rotate(360deg)'}}],animationTimingFunction:'linear',animationIterationCount:'infinite'},animationPause:{animationPlayState:'paused'}}),c=i.default.create({small:{width:20,height:20},large:{width:36,height:36}});_e.default=u}),563,[1,19,28,14,27,123]); __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 u=t(r(d[1]));e.default=u.default}),564,[1,565]); __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 l=t(r(d[1])),n=t(r(d[2]));class s extends n.default.Component{render(){return n.default.createElement(l.default,{style:[u,this.props.style]},this.props.children)}}var u={};e.default=s}),565,[1,123,14]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"ButtonGroup",{enumerable:!0,get:function(){return r(d[0]).ButtonGroup}})}),566,[567]); -__d((function(g,r,_i,a,m,_e2,d){var e=r(d[0]);Object.defineProperty(_e2,"__esModule",{value:!0}),_e2.ButtonGroup=void 0;var t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),n=(e(r(d[4])),e(r(d[5]))),i=e(r(d[6])),s=this&&this.__rest||function(e,t){var l={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(l[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n{var c,b,{Component:f=i.default,pressableProps:p,buttons:v,onPress:S=(()=>null),onLongPress:h,onPressIn:x,onPressOut:O,selectedIndex:C=null,selectedIndexes:P=[],selectMultiple:I=!1,containerStyle:T,innerBorderStyle:B,buttonStyle:j,buttonContainerStyle:_,textStyle:w,selectedTextStyle:E,selectedButtonStyle:k,activeOpacity:G,onHideUnderlay:R,onShowUnderlay:U,setOpacityTo:D,disabled:H=!1,disabledStyle:W,disabledTextStyle:z,disabledSelectedStyle:L,disabledSelectedTextStyle:M,vertical:N=!1,theme:A=r(d[7]).defaultTheme,underlayColor:V=(null===(c=null==A?void 0:A.colors)||void 0===c?void 0:c.primary)}=e,q=s(e,["Component","pressableProps","buttons","onPress","onLongPress","onPressIn","onPressOut","selectedIndex","selectedIndexes","selectMultiple","containerStyle","innerBorderStyle","buttonStyle","buttonContainerStyle","textStyle","selectedTextStyle","selectedButtonStyle","activeOpacity","onHideUnderlay","onShowUnderlay","setOpacityTo","disabled","disabledStyle","disabledTextStyle","disabledSelectedStyle","disabledSelectedTextStyle","vertical","theme","underlayColor"]);let F=null!==(b=null==B?void 0:B.width)&&void 0!==b?b:1;return l.default.createElement(o.default,Object.assign({testID:"RNE__ButtonGroupContainer"},q,{style:n.default.flatten([u.container,N&&u.verticalContainer,T&&T])}),null==v?void 0:v.map(((e,i)=>{var s,c,b,T,q,J;const K=C===i||P.includes(i),Q=!0===H||Array.isArray(H)&&H.includes(i);return l.default.createElement(o.default,{key:i,style:n.default.flatten([!N&&u.button,N&&u.verticalComponent,i!==v.length-1&&(N?{borderBottomWidth:F,borderBottomColor:B&&B.color||(null===(s=null==A?void 0:A.colors)||void 0===s?void 0:s.grey4)}:{borderRightWidth:F,borderRightColor:B&&B.color||(null===(c=null==A?void 0:A.colors)||void 0===c?void 0:c.grey4)}),_])},l.default.createElement(f,Object.assign({testID:"RNE__ButtonGroupItem",accessibilityState:{disabled:Q},activeOpacity:G,setOpacityTo:D,onHideUnderlay:R,onShowUnderlay:U,disabled:Q,onPress:()=>{I?P.includes(i)?S(P.filter((e=>e!==i))):S([...P,i]):S(i)},style:u.button},Object.assign({android_ripple:(0,r(d[7]).androidRipple)((0,t.default)(V).alpha(G).rgb().toString()),onPressIn:x,onPressOut:O,onLongPress:h},p)),l.default.createElement(o.default,{style:n.default.flatten([u.textContainer,j&&j,K&&{backgroundColor:null===(b=null==A?void 0:A.colors)||void 0===b?void 0:b.primary},K&&k&&k,Q&&u.disabled,Q&&W,Q&&K&&{backgroundColor:null===(T=null==A?void 0:A.colors)||void 0===T?void 0:T.disabled},Q&&K&&L])},y(e)?l.default.createElement(e.element,{isSelected:K}):l.default.createElement(r(d[8]).Text,{testID:"buttonGroupItemText",style:n.default.flatten([Object.assign({fontSize:(0,r(d[7]).normalizeText)(13),color:null===(q=null==A?void 0:A.colors)||void 0===q?void 0:q.grey2},{fontWeight:'500'}),w&&w,K&&{color:'#fff'},K&&E,Q&&{color:(0,r(d[7]).color)(null===(J=null==A?void 0:A.colors)||void 0===J?void 0:J.disabled).darken(.3).toString()},Q&&z,Q&&K&&M])},e))))})))};_e2.ButtonGroup=c;const u=n.default.create({button:{flex:1},textContainer:{flex:1,justifyContent:'center',alignItems:'center'},container:{marginHorizontal:10,marginVertical:5,borderColor:'#e3e3e3',borderWidth:1,flexDirection:'row',borderRadius:3,overflow:'hidden',backgroundColor:'#fff',height:40},verticalContainer:{flexDirection:'column',height:null},verticalComponent:{height:40},disabled:{backgroundColor:'transparent'}});c.displayName='ButtonGroup';const y=e=>'object'==typeof e&&Boolean(e.element)}),567,[1,405,14,123,77,27,336,402,568]); +__d((function(g,r,_i,a,m,_e2,d){var e=r(d[0]);Object.defineProperty(_e2,"__esModule",{value:!0}),_e2.ButtonGroup=void 0;var t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),n=(e(r(d[4])),e(r(d[5]))),i=e(r(d[6])),s=this&&this.__rest||function(e,t){var l={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(l[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n{var c,b,{Component:f=i.default,pressableProps:p,buttons:v,onPress:S=()=>null,onLongPress:h,onPressIn:x,onPressOut:O,selectedIndex:C=null,selectedIndexes:P=[],selectMultiple:I=!1,containerStyle:T,innerBorderStyle:B,buttonStyle:j,buttonContainerStyle:_,textStyle:w,selectedTextStyle:E,selectedButtonStyle:k,activeOpacity:G,onHideUnderlay:R,onShowUnderlay:U,setOpacityTo:D,disabled:H=!1,disabledStyle:W,disabledTextStyle:z,disabledSelectedStyle:L,disabledSelectedTextStyle:M,vertical:N=!1,theme:A=r(d[7]).defaultTheme,underlayColor:V=(null===(c=null==A?void 0:A.colors)||void 0===c?void 0:c.primary)}=e,q=s(e,["Component","pressableProps","buttons","onPress","onLongPress","onPressIn","onPressOut","selectedIndex","selectedIndexes","selectMultiple","containerStyle","innerBorderStyle","buttonStyle","buttonContainerStyle","textStyle","selectedTextStyle","selectedButtonStyle","activeOpacity","onHideUnderlay","onShowUnderlay","setOpacityTo","disabled","disabledStyle","disabledTextStyle","disabledSelectedStyle","disabledSelectedTextStyle","vertical","theme","underlayColor"]);let F=null!==(b=null==B?void 0:B.width)&&void 0!==b?b:1;return l.default.createElement(o.default,Object.assign({testID:"RNE__ButtonGroupContainer"},q,{style:n.default.flatten([u.container,N&&u.verticalContainer,T&&T])}),null==v?void 0:v.map(((e,i)=>{var s,c,b,T,q,J;const K=C===i||P.includes(i),Q=!0===H||Array.isArray(H)&&H.includes(i);return l.default.createElement(o.default,{key:i,style:n.default.flatten([!N&&u.button,N&&u.verticalComponent,i!==v.length-1&&(N?{borderBottomWidth:F,borderBottomColor:B&&B.color||(null===(s=null==A?void 0:A.colors)||void 0===s?void 0:s.grey4)}:{borderRightWidth:F,borderRightColor:B&&B.color||(null===(c=null==A?void 0:A.colors)||void 0===c?void 0:c.grey4)}),_])},l.default.createElement(f,Object.assign({testID:"RNE__ButtonGroupItem",accessibilityState:{disabled:Q},activeOpacity:G,setOpacityTo:D,onHideUnderlay:R,onShowUnderlay:U,disabled:Q,onPress:()=>{I?P.includes(i)?S(P.filter((e=>e!==i))):S([...P,i]):S(i)},style:u.button},Object.assign({android_ripple:(0,r(d[7]).androidRipple)((0,t.default)(V).alpha(G).rgb().toString()),onPressIn:x,onPressOut:O,onLongPress:h},p)),l.default.createElement(o.default,{style:n.default.flatten([u.textContainer,j&&j,K&&{backgroundColor:null===(b=null==A?void 0:A.colors)||void 0===b?void 0:b.primary},K&&k&&k,Q&&u.disabled,Q&&W,Q&&K&&{backgroundColor:null===(T=null==A?void 0:A.colors)||void 0===T?void 0:T.disabled},Q&&K&&L])},y(e)?l.default.createElement(e.element,{isSelected:K}):l.default.createElement(r(d[8]).Text,{testID:"buttonGroupItemText",style:n.default.flatten([Object.assign({fontSize:(0,r(d[7]).normalizeText)(13),color:null===(q=null==A?void 0:A.colors)||void 0===q?void 0:q.grey2},{fontWeight:'500'}),w&&w,K&&{color:'#fff'},K&&E,Q&&{color:(0,r(d[7]).color)(null===(J=null==A?void 0:A.colors)||void 0===J?void 0:J.disabled).darken(.3).toString()},Q&&z,Q&&K&&M])},e))))})))};_e2.ButtonGroup=c;const u=n.default.create({button:{flex:1},textContainer:{flex:1,justifyContent:'center',alignItems:'center'},container:{marginHorizontal:10,marginVertical:5,borderColor:'#e3e3e3',borderWidth:1,flexDirection:'row',borderRadius:3,overflow:'hidden',backgroundColor:'#fff',height:40},verticalContainer:{flexDirection:'column',height:null},verticalComponent:{height:40},disabled:{backgroundColor:'transparent'}});c.displayName='ButtonGroup';const y=e=>'object'==typeof e&&Boolean(e.element)}),567,[1,405,14,123,77,27,336,402,568]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Text",{enumerable:!0,get:function(){return r(d[0]).Text}})}),568,[569]); __d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.Text=void 0;var t=e(r(d[1])),l=e(r(d[2])),n=e(r(d[3])),o=(e(r(d[4])),e(r(d[5]))),f=this&&this.__rest||function(e,t){var l={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(l[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o{var i,{style:h={},h1:s=!1,h2:u=!1,h3:y=!1,h4:b=!1,h1Style:p={},h2Style:O={},h3Style:S={},h4Style:v={},children:j="",theme:x=r(d[6]).defaultTheme}=e,_=f(e,["style","h1","h2","h3","h4","h1Style","h2Style","h3Style","h4Style","children","theme"]);return t.default.createElement(l.default,Object.assign({accessibilityRole:"text",style:n.default.flatten([Object.assign(Object.assign({},void 0),{color:null===(i=null==x?void 0:x.colors)||void 0===i?void 0:i.black}),h,(s||u||y||b)&&c.bold,s&&n.default.flatten([{fontSize:(0,o.default)(40)},p]),u&&n.default.flatten([{fontSize:(0,o.default)(34)},O]),y&&n.default.flatten([{fontSize:(0,o.default)(28)},S]),b&&n.default.flatten([{fontSize:(0,o.default)(22)},v])])},(0,r(d[6]).patchWebProps)(_)),j)};_e.Text=i;const c=n.default.create({bold:Object.assign({},void 0)});i.displayName='Text'}),569,[1,14,93,27,77,537,402]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.Card=void 0;e.Card=Object.assign(r(d[0]).CardBase,{Divider:r(d[1]).CardDivider,Image:r(d[2]).CardImage,Title:r(d[3]).CardTitle,FeaturedTitle:r(d[4]).CardFeaturedTitle,FeaturedSubtitle:r(d[5]).CardFeaturedSubtitle})}),570,[571,572,575,576,577,578]); @@ -647,7 +647,7 @@ __d((function(g,_r,_i,_a,m,_e,d){'use strict';var e=_r(d[0]);Object.defineProper __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.Dialog=void 0;e.Dialog=Object.assign(r(d[0]).DialogBase,{Loading:r(d[1]).DialogLoading,Title:r(d[2]).DialogTitle,Actions:r(d[3]).DialogActions,Button:r(d[4]).DialogButton})}),585,[586,590,591,592,593]); __d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.DialogBase=void 0;var t=e(r(d[1])),o=e(r(d[2])),l=this&&this.__rest||function(e,t){var o={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&t.indexOf(l)<0&&(o[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(l=Object.getOwnPropertySymbols(e);i{var{children:i,overlayStyle:s,onBackdropPress:c,isVisible:y}=e,f=l(e,["children","overlayStyle","onBackdropPress","isVisible"]);return t.default.createElement(r(d[3]).Overlay,Object.assign({isVisible:y,onBackdropPress:c,overlayStyle:o.default.flatten([n.dialog,s]),testID:"Internal__Overlay"},f),i)};_e.DialogBase=i;const n=o.default.create({dialog:{width:'75%',padding:20},buttonView:{marginTop:10,marginRight:-35,flexDirection:'row-reverse',justifyContent:'flex-start'}});i.displayName='Dialog'}),586,[1,14,27,587]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Overlay",{enumerable:!0,get:function(){return r(d[0]).Overlay}})}),587,[588]); -__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.Overlay=void 0;var t=e(r(d[1])),o=e(r(d[2])),n=e(r(d[3])),l=(e(r(d[4])),e(r(d[5]))),s=e(r(d[6])),i=e(r(d[7])),c=e(r(d[8])),u=this&&this.__rest||function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(n=Object.getOwnPropertySymbols(e);l{var f,{children:p,backdropStyle:y,overlayStyle:h,onBackdropPress:v=(()=>null),fullScreen:O=!1,ModalComponent:P=s.default,isVisible:_,pressableProps:w,onPressOut:j,onPressIn:k,onLongPress:C,theme:E}=e,I=u(e,["children","backdropStyle","overlayStyle","onBackdropPress","fullScreen","ModalComponent","isVisible","pressableProps","onPressOut","onPressIn","onLongPress","theme"]);return t.default.createElement(P,Object.assign({visible:_,onRequestClose:v,transparent:!0},I),t.default.createElement(l.default,Object.assign({style:n.default.flatten([b.backdrop,y]),onPress:v,testID:"RNE__Overlay__backdrop"},w,{onPressOut:j,onPressIn:k,onLongPress:C})),t.default.createElement(i.default,{testID:"RNE__Overlay__Container",style:b.container,pointerEvents:"box-none",behavior:r(d[9]).getBehaviorType},t.default.createElement(o.default,{testID:"RNE__Overlay",style:n.default.flatten([b.overlay,O&&b.fullscreen,{backgroundColor:(0,c.default)(null===(f=null==E?void 0:E.colors)||void 0===f?void 0:f.white).lighten(10).rgb().toString()},h])},p)))};_e.Overlay=f;const b=n.default.create({backdrop:{position:'absolute',top:0,left:0,width:'100%',height:'100%',justifyContent:'center',alignItems:'center',backgroundColor:'rgba(0, 0, 0, .4)'},container:{flex:1,alignItems:'center',justifyContent:'center'},fullscreen:{width:'100%',height:'100%'},overlay:Object.assign({backgroundColor:'white',borderRadius:3,padding:10},{shadowColor:'rgba(0, 0, 0, .3)',shadowOffset:{width:0,height:1},shadowRadius:4})});f.displayName='Overlay'}),588,[1,14,123,27,77,336,556,589,405,402]); +__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.Overlay=void 0;var t=e(r(d[1])),o=e(r(d[2])),n=e(r(d[3])),l=(e(r(d[4])),e(r(d[5]))),s=e(r(d[6])),i=e(r(d[7])),c=e(r(d[8])),u=this&&this.__rest||function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(n=Object.getOwnPropertySymbols(e);l{var f,{children:p,backdropStyle:y,overlayStyle:h,onBackdropPress:v=()=>null,fullScreen:O=!1,ModalComponent:P=s.default,isVisible:_,pressableProps:w,onPressOut:j,onPressIn:k,onLongPress:C,theme:E}=e,I=u(e,["children","backdropStyle","overlayStyle","onBackdropPress","fullScreen","ModalComponent","isVisible","pressableProps","onPressOut","onPressIn","onLongPress","theme"]);return t.default.createElement(P,Object.assign({visible:_,onRequestClose:v,transparent:!0},I),t.default.createElement(l.default,Object.assign({style:n.default.flatten([b.backdrop,y]),onPress:v,testID:"RNE__Overlay__backdrop"},w,{onPressOut:j,onPressIn:k,onLongPress:C})),t.default.createElement(i.default,{testID:"RNE__Overlay__Container",style:b.container,pointerEvents:"box-none",behavior:r(d[9]).getBehaviorType},t.default.createElement(o.default,{testID:"RNE__Overlay",style:n.default.flatten([b.overlay,O&&b.fullscreen,{backgroundColor:(0,c.default)(null===(f=null==E?void 0:E.colors)||void 0===f?void 0:f.white).lighten(10).rgb().toString()},h])},p)))};_e.Overlay=f;const b=n.default.create({backdrop:{position:'absolute',top:0,left:0,width:'100%',height:'100%',justifyContent:'center',alignItems:'center',backgroundColor:'rgba(0, 0, 0, .4)'},container:{flex:1,alignItems:'center',justifyContent:'center'},fullscreen:{width:'100%',height:'100%'},overlay:Object.assign({backgroundColor:'white',borderRadius:3,padding:10},{shadowColor:'rgba(0, 0, 0, .3)',shadowOffset:{width:0,height:1},shadowRadius:4})});f.displayName='Overlay'}),588,[1,14,123,27,77,336,556,589,405,402]); __d((function(g,_r,_i,_a,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var t=e(_r(d[1])),r=e(_r(d[2])),n=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=o(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&{}.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u]}return n.default=e,r&&r.set(e,n),n})(_r(d[3])),a=e(_r(d[4]));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)}var u=["behavior","contentContainerStyle","keyboardVerticalOffset"];class i extends n.Component{constructor(){super(...arguments),this.frame=null,this.onLayout=e=>{this.frame=e.nativeEvent.layout}}relativeKeyboardHeight(e){var t=this.frame;if(!t||!e)return 0;var r=e.screenY-(this.props.keyboardVerticalOffset||0);return Math.max(t.y+t.height-r,0)}onKeyboardChange(e){}render(){var e=this.props,o=(e.behavior,e.contentContainerStyle,e.keyboardVerticalOffset,(0,r.default)(e,u));return n.createElement(a.default,(0,t.default)({onLayout:this.onLayout},o))}}_e.default=i}),589,[1,19,28,14,123]); __d((function(g,r,i,a,m,e,d){var l=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.DialogLoading=void 0;var o=l(r(d[1])),t=l(r(d[2])),n=l(r(d[3])),u=l(r(d[4]));const s=({loadingStyle:l,loadingProps:s,theme:f=r(d[5]).defaultTheme})=>{var v,y,p;return o.default.createElement(u.default,{style:c.loadingView},o.default.createElement(n.default,Object.assign({style:t.default.flatten([c.loading,l]),color:null!==(v=null==s?void 0:s.color)&&void 0!==v?v:null===(y=null==f?void 0:f.colors)||void 0===y?void 0:y.primary,size:null!==(p=null==s?void 0:s.size)&&void 0!==p?p:'large',testID:"Dialog__Loading"},s)))};e.DialogLoading=s,s.defaultProps={loadingProps:{size:'large'}};const c=t.default.create({loading:{marginVertical:20},loadingView:{flexDirection:'row',justifyContent:'center',alignItems:'center'}});s.displayName='Dialog.Loading'}),590,[1,14,27,563,123,402]); __d((function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.DialogTitle=void 0;var l=t(r(d[1])),o=t(r(d[2])),n=t(r(d[3]));t(r(d[4]));const f=({title:t,titleStyle:f,titleProps:c})=>l.default.createElement(o.default,Object.assign({style:n.default.flatten([s.title,f]),testID:"Dialog__Title"},c),t);e.DialogTitle=f;const s=n.default.create({title:{fontSize:18,fontWeight:'700',marginBottom:10}});f.displayName='Dialog.Title'}),591,[1,14,93,27,77]); @@ -698,23 +698,23 @@ __d((function(g,r,_i,a,m,_e,d){var t=r(d[0]);Object.defineProperty(_e,"__esModul __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"SocialIcon",{enumerable:!0,get:function(){return r(d[0]).SocialIcon}})}),636,[637]); __d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.SocialIcon=void 0;var t=e(r(d[1])),o=e(r(d[2])),n=e(r(d[3])),i=(e(r(d[4])),e(r(d[5]))),l=e(r(d[6])),s=(e(r(d[7])),this&&this.__rest||function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i{var{activityIndicatorStyle:f,button:b=!1,disabled:y,fontFamily:p,fontStyle:h,fontWeight:w,iconType:I="font-awesome",iconColor:O="white",iconSize:P=24,iconStyle:v,light:S,loading:j,onLongPress:C,onPress:E,onPressOut:_,onPressIn:k,Component:R=(E||C||k||_?i.default:o.default),raised:x=!0,small:z,style:D,title:F,type:L,underlayColor:N,pressableProps:T}=e,W=s(e,["activityIndicatorStyle","button","disabled","fontFamily","fontStyle","fontWeight","iconType","iconColor","iconSize","iconStyle","light","loading","onLongPress","onPress","onPressOut","onPressIn","Component","raised","small","style","title","type","underlayColor","pressableProps"]);const A=b&&F;return t.default.createElement(R,Object.assign({},Object.assign(Object.assign({onLongPress:C,onPress:E,onPressOut:_,onPressIn:k,android_ripple:(0,r(d[8]).androidRipple)(S?'white':N||L&&c[L])},T),W),{testID:"RNE_SocialIcon",underlayColor:S?'white':N||L&&c[L],disabled:y,style:n.default.flatten([x&&u.raised,u.container,b&&u.button,!b&&x&&u.icon,!b&&!S&&!x&&{width:2*P+4,height:2*P+4,borderRadius:2*P},{backgroundColor:L&&c[L]},{width:2*P+4,height:2*P+4,borderRadius:2*P},S&&{backgroundColor:'white'},D&&D])}),t.default.createElement(o.default,{style:u.wrapper},(A||!j)&&t.default.createElement(r(d[9]).Icon,{testID:"RNE_Icon",iconStyle:n.default.flatten([v&&v]),color:S?L&&c[L]:O,name:L,size:P,type:I}),A&&t.default.createElement(r(d[10]).Text,{style:n.default.flatten([u.title,S&&{color:L&&c[L]},p&&{fontFamily:p},w&&{fontWeight:w},h&&h])},F),j&&t.default.createElement(l.default,{testID:"RNE_ActivityIndicator",animating:!0,style:n.default.flatten([u.activityIndicatorStyle,f]),color:S?L&&c[L]:O||'white',size:z?'small':'large'})))};_e.SocialIcon=f;const u=n.default.create({container:{margin:7,borderRadius:30,flexDirection:'row',justifyContent:'center',alignItems:'center'},button:{paddingTop:14,paddingBottom:14},raised:Object.assign({},{shadowColor:'rgba(0,0,0, .4)',shadowOffset:{height:1,width:1},shadowOpacity:1,shadowRadius:1}),wrapper:{flexDirection:'row',justifyContent:'center',alignItems:'center'},title:Object.assign({color:'white',marginLeft:15},{fontWeight:'bold'}),icon:{height:52,width:52},activityIndicatorStyle:{marginHorizontal:10,height:0}});f.displayName='SocialIcon'}),637,[1,14,123,27,77,336,563,544,402,545,568]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.SpeedDial=void 0;e.SpeedDial=Object.assign(r(d[0]).SpeedDial,{Action:r(d[1]).SpeedDialAction})}),638,[639,640]); -__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.SpeedDial=void 0;var t=e(r(d[1])),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),s=e(r(d[5])),i=e(r(d[6])),u=e(r(d[7])),c=this&&this.__rest||function(e,t){var l={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(l[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o{var f,{isOpen:b=!1,onOpen:y=(()=>{}),onClose:O=(()=>{}),icon:v,openIcon:h,children:j,transitionDuration:E=150,style:P,overlayColor:x,theme:C=r(d[8]).defaultTheme,placement:w,labelPressable:D,backdropPressableProps:S}=e,_=c(e,["isOpen","onOpen","onClose","icon","openIcon","children","transitionDuration","style","overlayColor","theme","placement","labelPressable","backdropPressableProps"]);const k=t.default.useRef([...new Array(t.default.Children.count(j))].map((()=>new n.default.Value(Number(b)))));return t.default.useEffect((()=>{n.default.stagger(50,k.current.map((e=>n.default.timing(e,{toValue:Number(b),duration:E,useNativeDriver:!0})))[b?'reverse':'sort']()).start()}),[b,k,j,E]),t.default.createElement(l.default,{style:[p.container,P],pointerEvents:"box-none"},t.default.createElement(i.default,Object.assign({},S,{onPress:O,style:[o.default.absoluteFillObject],pointerEvents:b?'auto':'none'}),t.default.createElement(n.default.View,{style:[o.default.absoluteFillObject,{opacity:k.current[0],backgroundColor:x||(0,u.default)(null===(f=null==C?void 0:C.colors)||void 0===f?void 0:f.black).alpha(.6).rgb().toString()}]})),t.default.createElement(s.default,{pointerEvents:"box-none",style:[{alignItems:'left'===w?'flex-start':'flex-end'},w&&{[w]:0,bottom:0,position:'absolute'}]},t.default.Children.toArray(j).map(((e,l)=>t.default.createElement(n.default.View,{pointerEvents:b?'auto':'none',key:l,style:{transform:[{scale:k.current[l]}],opacity:k.current[l]}},t.default.cloneElement(e,{placement:w,labelPressable:D})))),t.default.createElement(r(d[9]).FAB,Object.assign({style:[p.fab],icon:b?h:v,theme:C},_,{onPress:b?O:y}))))};_e.SpeedDial=f;const p=o.default.create({safeArea:{alignItems:'flex-end'},container:Object.assign(Object.assign({},o.default.absoluteFillObject),{justifyContent:'flex-end'}),fab:{margin:16,marginTop:0}});f.displayName='SpeedDial'}),639,[1,14,123,240,27,125,336,405,402,594]); +__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.SpeedDial=void 0;var t=e(r(d[1])),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),s=e(r(d[5])),i=e(r(d[6])),u=e(r(d[7])),c=this&&this.__rest||function(e,t){var l={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(l[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o{var f,{isOpen:b=!1,onOpen:y=()=>{},onClose:O=()=>{},icon:v,openIcon:h,children:j,transitionDuration:E=150,style:P,overlayColor:x,theme:C=r(d[8]).defaultTheme,placement:w,labelPressable:D,backdropPressableProps:S}=e,_=c(e,["isOpen","onOpen","onClose","icon","openIcon","children","transitionDuration","style","overlayColor","theme","placement","labelPressable","backdropPressableProps"]);const k=t.default.useRef([...new Array(t.default.Children.count(j))].map((()=>new n.default.Value(Number(b)))));return t.default.useEffect((()=>{n.default.stagger(50,k.current.map((e=>n.default.timing(e,{toValue:Number(b),duration:E,useNativeDriver:!0})))[b?'reverse':'sort']()).start()}),[b,k,j,E]),t.default.createElement(l.default,{style:[p.container,P],pointerEvents:"box-none"},t.default.createElement(i.default,Object.assign({},S,{onPress:O,style:[o.default.absoluteFillObject],pointerEvents:b?'auto':'none'}),t.default.createElement(n.default.View,{style:[o.default.absoluteFillObject,{opacity:k.current[0],backgroundColor:x||(0,u.default)(null===(f=null==C?void 0:C.colors)||void 0===f?void 0:f.black).alpha(.6).rgb().toString()}]})),t.default.createElement(s.default,{pointerEvents:"box-none",style:[{alignItems:'left'===w?'flex-start':'flex-end'},w&&{[w]:0,bottom:0,position:'absolute'}]},t.default.Children.toArray(j).map(((e,l)=>t.default.createElement(n.default.View,{pointerEvents:b?'auto':'none',key:l,style:{transform:[{scale:k.current[l]}],opacity:k.current[l]}},t.default.cloneElement(e,{placement:w,labelPressable:D})))),t.default.createElement(r(d[9]).FAB,Object.assign({style:[p.fab],icon:b?h:v,theme:C},_,{onPress:b?O:y}))))};_e.SpeedDial=f;const p=o.default.create({safeArea:{alignItems:'flex-end'},container:Object.assign(Object.assign({},o.default.absoluteFillObject),{justifyContent:'flex-end'}),fab:{margin:16,marginTop:0}});f.displayName='SpeedDial'}),639,[1,14,123,240,27,125,336,405,402,594]); __d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.SpeedDialAction=void 0;var t=e(r(d[1])),l=e(r(d[2])),n=e(r(d[3])),i=e(r(d[4])),o=this&&this.__rest||function(e,t){var l={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(l[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i{var{title:i,titleStyle:s,placement:f,labelPressable:p,onPress:u}=e,y=o(e,["title","titleStyle","placement","labelPressable","onPress"]);return t.default.createElement(l.default,{onPress:p?u:void 0,style:[c.action,'left'===f&&{flexDirection:'row-reverse'}]},i&&t.default.createElement(n.default,{style:[c.title,s]},i),t.default.createElement(r(d[5]).FAB,Object.assign({},y,{onPress:u,size:"small",style:[y.style]})))};_e.SpeedDialAction=s;const c=i.default.create({title:{backgroundColor:'white',color:'black',borderRadius:5,paddingHorizontal:12,paddingVertical:6,marginVertical:8,marginHorizontal:16,elevation:2},action:{marginBottom:16,marginRight:24,flexDirection:'row',justifyContent:'flex-end',alignItems:'center'}});s.displayName='SpeedDial.Action'}),640,[1,14,336,93,27,594]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Switch",{enumerable:!0,get:function(){return r(d[0]).Switch}})}),641,[642]); __d((function(g,_r,_i,_a2,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.Switch=void 0;var t=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var o=r(t);if(o&&o.has(e))return o.get(e);var l={__proto__:null},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&{}.hasOwnProperty.call(e,a)){var i=n?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(l,a,i):l[a]=e[a]}return l.default=e,o&&o.set(e,l),l})(_r(d[1])),o=e(_r(d[2]));e(_r(d[3]));function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,o=new WeakMap;return(r=function(e){return e?o:t})(e)}var l=this&&this.__rest||function(e,t){var o={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(r=Object.getOwnPropertySymbols(e);l{var r,{value:n=!1,disabled:a=!1,onValueChange:i,color:u="primary",style:c,theme:s=_r(d[4]).defaultTheme}=e,f=l(e,["value","disabled","onValueChange","color","style","theme"]);const v=(0,t.useMemo)((()=>(null==s?void 0:s.colors[u])||u||(null==s?void 0:s.colors.primary)),[u,null==s?void 0:s.colors]),p=(0,t.useMemo)((()=>a?null==s?void 0:s.colors.disabled:v),[a,v,null==s?void 0:s.colors.disabled]),b=(0,t.useMemo)((()=>{var e;return a?(null===(e=null==s?void 0:s.colors)||void 0===e?void 0:e.disabled)||'#fff':v}),[a,v,null===(r=null==s?void 0:s.colors)||void 0===r?void 0:r.disabled]),y=(0,t.useMemo)((()=>({activeTrackColor:p,activeThumbColor:v})),[p,v,a,s.colors.disabled]);return t.default.createElement(o.default,Object.assign({testID:"RNE__SWITCH",value:n,accessibilityState:{checked:n,disabled:a},disabled:a,thumbColor:b,onValueChange:a?void 0:i,style:c},y,f))};_e.Switch=n,n.displayName='Switch'}),642,[1,14,643,77,402]); __d((function(g,_r,_i,_a,m,_e,d){var e=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var t=e(_r(d[1])),r=e(_r(d[2])),l=e(_r(d[3])),a=(function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=c(t);if(r&&r.has(e))return r.get(e);var l={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&{}.hasOwnProperty.call(e,o)){var n=a?Object.getOwnPropertyDescriptor(e,o):null;n&&(n.get||n.set)?Object.defineProperty(l,o,n):l[o]=e[o]}return l.default=e,r&&r.set(e,l),l})(_r(d[4])),o=e(_r(d[5])),n=e(_r(d[6])),u=e(_r(d[7])),i=e(_r(d[8]));function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(c=function(e){return e?r:t})(e)}var f=["aria-label","accessibilityLabel","activeThumbColor","activeTrackColor","disabled","onValueChange","style","thumbColor","trackColor","value"],s={},b='0px 1px 3px rgba(0,0,0,0.5)',h='#D5D5D5',p='#BDBDBD',v=a.forwardRef(((e,t)=>{var c=e['aria-label'],v=e.accessibilityLabel,C=e.activeThumbColor,w=e.activeTrackColor,j=e.disabled,k=void 0!==j&&j,D=e.onValueChange,x=e.style,O=void 0===x?s:x,_=e.thumbColor,A=e.trackColor,F=e.value,S=void 0!==F&&F,P=(0,l.default)(e,f),E=a.useRef(null);function M(e){var t='focus'===e.nativeEvent.type?"0px 1px 3px rgba(0,0,0,0.5), 0 0 0 10px rgba(0,0,0,0.1)":b;null!=E.current&&(E.current.style.boxShadow=t)}var B=u.default.flatten(O),R=B.height,T=B.width,I=R||'20px',W=(0,n.default)(I,2),L=T>W?T:W,V=(0,n.default)(I,.5),N=!0===S?null!=A&&'object'==typeof A?A.true:null!=w?w:"#A3D3CF":null!=A&&'object'==typeof A?A.false:null!=A?A:"#939393",Z=S?null!=C?C:"#009688":null!=_?_:"#FAFAFA",q=I,z=q,G=[y.root,O,k&&y.cursorDefault,{height:I,width:L}],H=!0===S?'string'==typeof w&&null!=w||'object'==typeof A&&null!=A&&A.true?N:h:'string'==typeof A&&null!=A||'object'==typeof A&&null!=A&&A.false?N:h,J=!0===S?null==C?p:Z:null==_?p:Z,K=[y.track,{backgroundColor:k?H:N,borderRadius:V}],Q=[y.thumb,S&&y.thumbActive,{backgroundColor:k?J:Z,height:q,marginStart:S?(0,n.default)(z,-1):0,width:z}],U=(0,o.default)('input',{'aria-label':c||v,checked:S,disabled:k,onBlur:M,onChange:function(e){null!=D&&D(e.nativeEvent.target.checked)},onFocus:M,ref:t,style:[y.nativeControl,y.cursorInherit],type:'checkbox',role:'switch'});return a.createElement(i.default,(0,r.default)({},P,{style:G}),a.createElement(i.default,{style:K}),a.createElement(i.default,{ref:E,style:Q}),U)}));v.displayName='Switch';var y=u.default.create({root:{cursor:'pointer',userSelect:'none'},cursorDefault:{cursor:'default'},cursorInherit:{cursor:'inherit'},track:(0,t.default)((0,t.default)({forcedColorAdjust:'none'},u.default.absoluteFillObject),{},{height:'70%',margin:'auto',transitionDuration:'0.1s',width:'100%'}),thumb:{forcedColorAdjust:'none',alignSelf:'flex-start',borderRadius:'100%',boxShadow:b,start:'0%',transform:'translateZ(0)',transitionDuration:'0.1s'},thumbActive:{insetInlineStart:'100%'},nativeControl:(0,t.default)((0,t.default)({},u.default.absoluteFillObject),{},{height:'100%',margin:0,appearance:'none',padding:0,width:'100%'})});_e.default=v}),643,[1,5,19,28,14,94,644,27,123]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=/^[+-]?\d*(?:\.\d+)?(?:[Ee][+-]?\d+)?(%|\w*)/;e.default=(o,l)=>{var n;return'string'==typeof o?""+parseFloat(o)*l+o.match(t)[1]:(n=o,!isNaN(parseFloat(n))&&isFinite(n)?o*l:void 0)}}),644,[]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.Tab=void 0;e.Tab=Object.assign(r(d[0]).TabBase,{Item:r(d[1]).TabItem})}),645,[646,647]); -__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.TabBase=void 0;var t=e(r(d[1])),n=e(r(d[2])),l=e(r(d[3])),o=e(r(d[4])),i=e(r(d[5])),u=this&&this.__rest||function(e,t){var n={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(l=Object.getOwnPropertySymbols(e);o{var o,s,{theme:f=r(d[6]).defaultTheme,children:y,value:v=0,scrollable:b=!1,onChange:h=(()=>{}),indicatorStyle:p,disableIndicator:S,variant:w="default",style:O,dense:E,iconPosition:P,buttonStyle:j,titleStyle:C,containerStyle:R}=e,_=u(e,["theme","children","value","scrollable","onChange","indicatorStyle","disableIndicator","variant","style","dense","iconPosition","buttonStyle","titleStyle","containerStyle"]);const x=t.default.useRef(new l.default.Value(0)),k=t.default.useRef(null),T=t.default.useRef(0),A=t.default.useMemo((()=>t.default.Children.toArray(y)),[y]),I=t.default.useRef([]),[M,F]=t.default.useState(0),V=t.default.useCallback((e=>{if(I.current.length>e){let t=0===e?0:I.current[e-1].position,n=I.current[e].position;const l=T.current;let o=l;t{l.default.timing(x.current,{toValue:v,useNativeDriver:!0,duration:170}).start(),b&&requestAnimationFrame((()=>V(v)))}),[x,V,v,b]);const z=t.default.useCallback((e=>{T.current=e.nativeEvent.contentOffset.x}),[]),B=t.default.useMemo((()=>{const e=A.length;if(e<2||!I.current.length)return 0;const t=Array.from(Array(e+1).keys()),n=I.current.map((({position:e})=>e));return t.length-1!==n.length?0:x.current.interpolate({inputRange:t,outputRange:[0,...n]})}),[x,A,I.current.length]),D=t.default.useMemo((()=>{var e;return null===(e=I.current[v])||void 0===e?void 0:e.width}),[v,I.current.length]);return t.default.createElement(n.default,Object.assign({},_,{accessibilityRole:"tablist",style:['primary'===w&&{backgroundColor:null===(o=null==f?void 0:f.colors)||void 0===o?void 0:o.primary},c.viewStyle,O],onLayout:({nativeEvent:{layout:e}})=>{F(e.width)}}),t.default.createElement(b?i.default:t.default.Fragment,Object.assign(Object.assign({},b&&{horizontal:!0,ref:k,onScroll:z,showsHorizontalScrollIndicator:!1}),{children:t.default.createElement(t.default.Fragment,null,A.map(((e,n)=>t.default.cloneElement(e,{onPress:()=>h(n),onLayout:e=>{var t;const{width:l}=e.nativeEvent.layout,o=(null===(t=I.current[n-1])||void 0===t?void 0:t.position)||0;I.current[n]={position:o+l,width:l}},active:n===v,variant:w,_parentProps:{dense:E,iconPosition:P,buttonStyle:j,containerStyle:R,titleStyle:C}}))),!S&&t.default.createElement(l.default.View,{style:[c.indicator,{backgroundColor:null===(s=null==f?void 0:f.colors)||void 0===s?void 0:s.secondary,transform:[{translateX:B}],width:D},p]}))})))};_e.TabBase=s;const c=o.default.create({viewStyle:{flexDirection:'row',position:'relative'},indicator:{display:'flex',position:'absolute',height:2,bottom:0}});s.displayName='Tab'}),646,[1,14,123,240,27,251,402]); +__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.TabBase=void 0;var t=e(r(d[1])),n=e(r(d[2])),l=e(r(d[3])),o=e(r(d[4])),i=e(r(d[5])),u=this&&this.__rest||function(e,t){var n={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(l=Object.getOwnPropertySymbols(e);o{var o,s,{theme:f=r(d[6]).defaultTheme,children:y,value:v=0,scrollable:b=!1,onChange:h=()=>{},indicatorStyle:p,disableIndicator:S,variant:w="default",style:O,dense:E,iconPosition:P,buttonStyle:j,titleStyle:C,containerStyle:R}=e,_=u(e,["theme","children","value","scrollable","onChange","indicatorStyle","disableIndicator","variant","style","dense","iconPosition","buttonStyle","titleStyle","containerStyle"]);const x=t.default.useRef(new l.default.Value(0)),k=t.default.useRef(null),T=t.default.useRef(0),A=t.default.useMemo((()=>t.default.Children.toArray(y)),[y]),I=t.default.useRef([]),[M,F]=t.default.useState(0),V=t.default.useCallback((e=>{if(I.current.length>e){let t=0===e?0:I.current[e-1].position,n=I.current[e].position;const l=T.current;let o=l;t{l.default.timing(x.current,{toValue:v,useNativeDriver:!0,duration:170}).start(),b&&requestAnimationFrame((()=>V(v)))}),[x,V,v,b]);const z=t.default.useCallback((e=>{T.current=e.nativeEvent.contentOffset.x}),[]),B=t.default.useMemo((()=>{const e=A.length;if(e<2||!I.current.length)return 0;const t=Array.from(Array(e+1).keys()),n=I.current.map((({position:e})=>e));return t.length-1!==n.length?0:x.current.interpolate({inputRange:t,outputRange:[0,...n]})}),[x,A,I.current.length]),D=t.default.useMemo((()=>{var e;return null===(e=I.current[v])||void 0===e?void 0:e.width}),[v,I.current.length]);return t.default.createElement(n.default,Object.assign({},_,{accessibilityRole:"tablist",style:['primary'===w&&{backgroundColor:null===(o=null==f?void 0:f.colors)||void 0===o?void 0:o.primary},c.viewStyle,O],onLayout:({nativeEvent:{layout:e}})=>{F(e.width)}}),t.default.createElement(b?i.default:t.default.Fragment,Object.assign(Object.assign({},b&&{horizontal:!0,ref:k,onScroll:z,showsHorizontalScrollIndicator:!1}),{children:t.default.createElement(t.default.Fragment,null,A.map(((e,n)=>t.default.cloneElement(e,{onPress:()=>h(n),onLayout:e=>{var t;const{width:l}=e.nativeEvent.layout,o=(null===(t=I.current[n-1])||void 0===t?void 0:t.position)||0;I.current[n]={position:o+l,width:l}},active:n===v,variant:w,_parentProps:{dense:E,iconPosition:P,buttonStyle:j,containerStyle:R,titleStyle:C}}))),!S&&t.default.createElement(l.default.View,{style:[c.indicator,{backgroundColor:null===(s=null==f?void 0:f.colors)||void 0===s?void 0:s.secondary,transform:[{translateX:B}],width:D},p]}))})))};_e.TabBase=s;const c=o.default.create({viewStyle:{flexDirection:'row',position:'relative'},indicator:{display:'flex',position:'absolute',height:2,bottom:0}});s.displayName='Tab'}),646,[1,14,123,240,27,251,402]); __d((function(g,r,_i,a,m,_e,d){var t=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.TabItem=void 0;var e=t(r(d[1])),n=t(r(d[2])),o=t(r(d[3])),i=this&&this.__rest||function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i{var o,l,{active:y,theme:s=r(d[4]).defaultTheme,_parentProps:u={},titleStyle:b=u.titleStyle,containerStyle:p=u.containerStyle,buttonStyle:S=u.buttonStyle,iconPosition:f=u.iconPosition||'top',dense:v=u.dense,iconContainerStyle:O,variant:P,title:h,icon:_}=t,j=i(t,["active","theme","_parentProps","titleStyle","containerStyle","buttonStyle","iconPosition","dense","iconContainerStyle","variant","title","icon"]);const C=n.default.useCallback((t=>'function'==typeof t?t(y):t),[y]);return n.default.createElement(r(d[5]).Button,Object.assign({accessibilityRole:"tab",accessibilityState:{selected:y},accessibilityValue:'string'==typeof h?{text:h}:void 0,buttonStyle:[c.buttonStyle,C(S)],titleStyle:[!v&&c.titleStyle,{color:'primary'===P?'white':null===(o=null==s?void 0:s.colors)||void 0===o?void 0:o.secondary,paddingVertical:v||_?2:8},C(b)],containerStyle:[c.containerStyle,'primary'===P&&{backgroundColor:y?(0,e.default)(null===(l=null==s?void 0:s.colors)||void 0===l?void 0:l.primary).darken(.05).rgb().toString():'transparent'},C(p)],iconContainerStyle:C(O),icon:C(_),iconPosition:f,title:h},j))};_e.TabItem=l;const c=o.default.create({buttonStyle:{borderRadius:0,backgroundColor:'transparent'},titleStyle:{paddingHorizontal:16,paddingVertical:8},containerStyle:{flex:1,borderRadius:0}});l.displayName='Tab.Item'}),647,[1,405,14,27,402,561]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.TabView=void 0;e.TabView=Object.assign(r(d[0]).TabViewBase,{Item:r(d[1]).TabViewItem})}),648,[649,650]); -__d((function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.TabViewBase=void 0;var n=t(r(d[1])),l=t(r(d[2])),u=t(r(d[3])),s=t(r(d[4])),o=t(r(d[5])),f=t(r(d[6]));const c=({value:t=0,children:c,onChange:h=(()=>{}),onSwipeStart:p=(()=>{}),animationType:v="spring",animationConfig:y={},containerStyle:w,tabItemContainerStyle:M,disableSwipe:R=!1,disableTransition:S=!1,minSwipeRatio:x=.4,minSwipeSpeed:V=1})=>{const C=n.default.useRef(new l.default.Value(0)),T=n.default.useRef(0),[E,P]=n.default.useState(1),_=n.default.useMemo((()=>n.default.Children.toArray(c).length),[c]),j=n.default.useCallback((t=>{l.default[v](C.current,Object.assign({toValue:t,useNativeDriver:!0,easing:u.default.ease},y)).start()}),[y,v]),I=n.default.useCallback(((t,{dx:n,vx:l})=>{const u=n/-E,s=Math.abs(u)>x||Math.abs(l)>V;T.current+=s?Math.sign(u):0,j(T.current),h(T.current)}),[j,E,x,V,h]),N=n.default.useMemo((()=>s.default.create({onPanResponderGrant:(t,{vx:n})=>{p(n>0?'left':'right')},onMoveShouldSetPanResponder:(t,{dx:n,dy:l,vx:u,vy:s})=>{const o=Math.floor(T.current);return!(n>0&&o<=0||n<0&&o>=_-1)&&Math.abs(n)>2*Math.abs(l)&&Math.abs(u)>2.5*Math.abs(s)},onPanResponderMove:(t,{dx:n})=>{const l=n/-E;C.current.setValue(Math.floor(T.current)+l)},onPanResponderRelease:I,onPanResponderTerminate:I})),[_,E,p,I]);return n.default.useEffect((()=>{Number.isInteger(t)&&t!==T.current&&(j(t),T.current=t)}),[j,t]),n.default.createElement(o.default,{style:[b.container,w],onLayout:({nativeEvent:{layout:t}})=>{P(t.width)}},n.default.createElement(l.default.View,Object.assign({testID:"RNE__TabView",style:f.default.flatten([f.default.absoluteFillObject,b.container,{width:E*_,transform:[{translateX:S?-t*E:C.current.interpolate({inputRange:[0,1],outputRange:[0,-E]})}]}])},!R&&N.panHandlers),n.default.Children.toArray(c).map(((t,l)=>n.default.createElement(o.default,{key:l,style:f.default.flatten([b.container,M,{width:E}])},t)))))};e.TabViewBase=c;const b=f.default.create({container:{flex:1,flexDirection:'row',alignItems:'stretch'}});c.displayName='TabView'}),649,[1,14,240,319,388,123,27]); +__d((function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.TabViewBase=void 0;var n=t(r(d[1])),l=t(r(d[2])),u=t(r(d[3])),s=t(r(d[4])),o=t(r(d[5])),f=t(r(d[6]));const c=({value:t=0,children:c,onChange:h=()=>{},onSwipeStart:p=()=>{},animationType:v="spring",animationConfig:y={},containerStyle:w,tabItemContainerStyle:M,disableSwipe:R=!1,disableTransition:S=!1,minSwipeRatio:x=.4,minSwipeSpeed:V=1})=>{const C=n.default.useRef(new l.default.Value(0)),T=n.default.useRef(0),[E,P]=n.default.useState(1),_=n.default.useMemo((()=>n.default.Children.toArray(c).length),[c]),j=n.default.useCallback((t=>{l.default[v](C.current,Object.assign({toValue:t,useNativeDriver:!0,easing:u.default.ease},y)).start()}),[y,v]),I=n.default.useCallback(((t,{dx:n,vx:l})=>{const u=n/-E,s=Math.abs(u)>x||Math.abs(l)>V;T.current+=s?Math.sign(u):0,j(T.current),h(T.current)}),[j,E,x,V,h]),N=n.default.useMemo((()=>s.default.create({onPanResponderGrant:(t,{vx:n})=>{p(n>0?'left':'right')},onMoveShouldSetPanResponder:(t,{dx:n,dy:l,vx:u,vy:s})=>{const o=Math.floor(T.current);return!(n>0&&o<=0||n<0&&o>=_-1)&&Math.abs(n)>2*Math.abs(l)&&Math.abs(u)>2.5*Math.abs(s)},onPanResponderMove:(t,{dx:n})=>{const l=n/-E;C.current.setValue(Math.floor(T.current)+l)},onPanResponderRelease:I,onPanResponderTerminate:I})),[_,E,p,I]);return n.default.useEffect((()=>{Number.isInteger(t)&&t!==T.current&&(j(t),T.current=t)}),[j,t]),n.default.createElement(o.default,{style:[b.container,w],onLayout:({nativeEvent:{layout:t}})=>{P(t.width)}},n.default.createElement(l.default.View,Object.assign({testID:"RNE__TabView",style:f.default.flatten([f.default.absoluteFillObject,b.container,{width:E*_,transform:[{translateX:S?-t*E:C.current.interpolate({inputRange:[0,1],outputRange:[0,-E]})}]}])},!R&&N.panHandlers),n.default.Children.toArray(c).map(((t,l)=>n.default.createElement(o.default,{key:l,style:f.default.flatten([b.container,M,{width:E}])},t)))))};e.TabViewBase=c;const b=f.default.create({container:{flex:1,flexDirection:'row',alignItems:'stretch'}});c.displayName='TabView'}),649,[1,14,240,319,388,123,27]); __d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.TabViewItem=void 0;var t=e(r(d[1])),n=e(r(d[2])),l=this&&this.__rest||function(e,t){var n={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(l=Object.getOwnPropertySymbols(e);i{var{children:i}=e,o=l(e,["children"]);return t.default.createElement(n.default,Object.assign({},o),t.default.isValidElement(i)&&i)};_e.TabViewItem=i,i.displayName='TabView.Item'}),650,[1,14,123]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Tile",{enumerable:!0,get:function(){return r(d[0]).Tile}})}),651,[652]); __d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.Tile=void 0;var t=e(r(d[1])),n=e(r(d[2])),i=e(r(d[3])),l=e(r(d[4])),o=e(r(d[5])),c=e(r(d[6])),s=this&&this.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(i=Object.getOwnPropertySymbols(e);l{var f,{featured:u,imageSrc:p,icon:S,title:h,children:O,caption:b,titleStyle:C,onPress:v,activeOpacity:j,overlayContainerStyle:P,captionStyle:w,iconContainerStyle:I,imageContainerStyle:E,containerStyle:T,contentContainerStyle:_,titleNumberOfLines:x,ImageComponent:L=r(d[7]).Image,imageProps:N={},width:z=l.default.get('window').width,height:B=.8*z,theme:F=r(d[8]).defaultTheme}=e,M=s(e,["featured","imageSrc","icon","title","children","caption","titleStyle","onPress","activeOpacity","overlayContainerStyle","captionStyle","iconContainerStyle","imageContainerStyle","containerStyle","contentContainerStyle","titleNumberOfLines","ImageComponent","imageProps","width","height","theme"]);if(u){const e={title:h,icon:S,caption:b,imageSrc:p,onPress:v,activeOpacity:j,containerStyle:T,imageContainerStyle:E,overlayContainerStyle:P,titleStyle:C,captionStyle:w,width:z,height:B,imageProps:N,ImageComponent:L};return t.default.createElement(r(d[9]).FeaturedTile,Object.assign({},e))}return t.default.createElement(o.default,Object.assign({},Object.assign({onPress:v,android_ripple:(0,r(d[8]).androidRipple)((0,c.default)(null===(f=null==F?void 0:F.colors)||void 0===f?void 0:f.primary).alpha(j).rgb().toString())},M),{style:i.default.flatten([{width:z,height:B},T&&T])}),t.default.createElement(L,Object.assign({resizeMode:"cover",source:p,containerStyle:i.default.flatten([y.imageContainer,E&&E]),style:Object.assign(Object.assign({},i.default.absoluteFillObject),{alignItems:'center',justifyContent:'center'})},N),t.default.createElement(n.default,{style:i.default.flatten([y.iconContainer,I&&I])},S&&t.default.createElement(r(d[10]).Icon,Object.assign({},S)))),t.default.createElement(n.default,{style:i.default.flatten([y.contentContainer,_&&_])},t.default.createElement(r(d[11]).Text,{testID:"tileTitle",h4:!C||!('fontSize'in C),style:i.default.flatten([y.text,C&&C]),numberOfLines:x},h),O))};_e.Tile=f;const y=i.default.create({imageContainer:{flex:2},text:{backgroundColor:'rgba(0,0,0,0)',marginBottom:5},contentContainer:{paddingTop:15,paddingBottom:5,paddingLeft:15,paddingRight:15},iconContainer:{justifyContent:'center',alignItems:'center',alignSelf:'center'}});f.displayName='Tile'}),652,[1,14,123,27,136,336,405,548,402,653,545,568]); __d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.FeaturedTile=void 0;var t=e(r(d[1])),n=e(r(d[2])),i=e(r(d[3])),l=e(r(d[4])),o=e(r(d[5])),c=this&&this.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(i=Object.getOwnPropertySymbols(e);l{var s,y,u,{title:p,icon:h,caption:S,imageSrc:C,containerStyle:b,imageContainerStyle:O,overlayContainerStyle:j,iconContainerStyle:v,titleStyle:w,captionStyle:x,ImageComponent:I=r(d[6]).BackgroundImage,imageProps:E={},width:T=o.default.get('window').width,height:P=.8*T}=e,_=c(e,["title","icon","caption","imageSrc","containerStyle","imageContainerStyle","overlayContainerStyle","iconContainerStyle","titleStyle","captionStyle","ImageComponent","imageProps","width","height"]);return t.default.createElement(n.default,Object.assign({},_,{style:l.default.flatten([{width:T,height:P},b&&b])}),t.default.createElement(I,Object.assign({resizeMode:"cover"},E,{source:C,style:l.default.flatten([{width:T,height:P},f.imageContainer,O&&O])}),t.default.createElement(i.default,{style:l.default.flatten([f.overlayContainer,j&&j])},t.default.createElement(i.default,{style:l.default.flatten([f.iconContainer,v&&v])},h&&t.default.createElement(r(d[8]).Icon,Object.assign({},h))),t.default.createElement(r(d[7]).Text,{testID:"featuredTileTitle",h4:!w||!('fontSize'in w),style:l.default.flatten([f.text,w&&w])},p),(s=S,y={style:x},u=f.text,(0,r(d[6]).renderNode)(r(d[7]).Text,s,Object.assign(Object.assign({},y),{style:l.default.flatten([u,y&&y.style])}))))))};const f=l.default.create({imageContainer:{alignItems:'center',justifyContent:'center'},overlayContainer:{flex:1,alignItems:'center',alignSelf:'stretch',justifyContent:'center',paddingLeft:25,paddingRight:25,paddingTop:45,paddingBottom:40,position:'absolute',top:0,left:0,right:0,bottom:0},text:{color:'#ffffff',backgroundColor:'rgba(0,0,0,0)',marginBottom:15,textAlign:'center'},iconContainer:{justifyContent:'center',alignItems:'center',alignSelf:'center'}})}),653,[1,14,336,123,27,136,402,568,545]); __d((function(g,r,i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Tooltip",{enumerable:!0,get:function(){return r(d[0]).Tooltip}})}),654,[655]); -__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.Tooltip=void 0;var t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),n=e(r(d[4])),i=(e(r(d[5])),e(r(d[6]))),s=(e(r(d[7])),e(r(d[8]))),u=e(r(d[9])),f=e(r(d[10])),c=this&&this.__rest||function(e,t){var l={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(l[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n{var{withOverlay:h=!0,overlayColor:p="#fafafa14",highlightColor:y="transparent",withPointer:O=!0,toggleOnPress:b=!0,toggleAction:v="onPress",height:C=40,width:E=150,containerStyle:P={},backgroundColor:w="#617080",pointerColor:S=w,pointerStyle:k,onClose:T=(()=>{}),onOpen:j=(()=>{}),visible:x=!1,skipAndroidStatusBar:B=!1,ModalComponent:H=o.default,closeOnlyOnBackdropPress:W=!1,animationType:_="fade"}=e,A=c(e,["withOverlay","overlayColor","highlightColor","withPointer","toggleOnPress","toggleAction","height","width","containerStyle","backgroundColor","pointerColor","pointerStyle","onClose","onOpen","visible","skipAndroidStatusBar","ModalComponent","closeOnlyOnBackdropPress","animationType"]);const I=t.default.useRef(!1),L=t.default.useRef(null),[M,D]=t.default.useState({yOffset:0,xOffset:0,elementWidth:0,elementHeight:0}),R=t.default.useCallback((()=>{var e;null===(e=L.current)||void 0===e||e.measure(((e,t,l=0,o=0,n=0,i=0)=>{I.current&&D({xOffset:n,yOffset:r(d[11]).isIOS||B?i:i-0,elementWidth:l,elementHeight:o})}))}),[B]),Y=t.default.useCallback((()=>{R(),I.current&&b&&(x?null==T||T():null==j||j())}),[R,T,j,b,x]),q=({tooltipY:e})=>{const{yOffset:l,xOffset:o,elementHeight:s,elementWidth:u}=M,c=l>(e||0);return O?t.default.createElement(n.default,{style:{position:'absolute',top:c?l-13:l+s-2,[i.default.isRTL?'right':'left']:o+(0,r(d[12]).getElementVisibleWidth)(u,o,r(d[11]).ScreenWidth)/2-7.5}},t.default.createElement(f.default,{style:k,pointerColor:S,isDown:c})):null},F=t.default.useMemo((()=>{const{yOffset:e,xOffset:t,elementWidth:l,elementHeight:o}=M;return{position:'absolute',top:e,[i.default.isRTL?'right':'left']:t,backgroundColor:y,overflow:'visible',width:l,height:o}}),[M,y]),N=()=>W?t.default.createElement(n.default,{testID:"tooltipTouchableHighlightedButton",style:F},A.children):t.default.createElement(u.default,{testID:"tooltipTouchableHighlightedButton",onPress:Y,style:F},A.children);t.default.useEffect((()=>{I.current=!0,requestAnimationFrame(R);const e=s.default.addEventListener('change',R);return()=>{I.current=!1,(null==e?void 0:e.remove)?e.remove():s.default.removeEventListener('change',R)}}),[R]);const V=t.default.useMemo((()=>(0,r(d[13]).getTooltipStyle)(Object.assign(Object.assign({},M),{backgroundColor:w,containerStyle:P,height:C,width:E,withPointer:O}))),[w,P,M,C,E,O]);return t.default.createElement(n.default,{collapsable:!1,ref:L},t.default.createElement(u.default,Object.assign({},{[v]:Y},{delayLongPress:250}),A.children),t.default.createElement(H,{transparent:!0,visible:x,onShow:j,animationType:_},t.default.createElement(l.default,{style:{backgroundColor:h?p:'transparent',flex:1},onPress:Y,activeOpacity:1},t.default.createElement(n.default,null,t.default.createElement(N,null),t.default.createElement(q,{tooltipY:V.top}),t.default.createElement(n.default,{style:V,testID:"tooltipPopoverContainer"},A.popover)))))};_e.Tooltip=h,h.displayName='Tooltip'}),655,[1,14,355,556,123,598,333,77,136,336,656,402,657,658]); +__d((function(g,r,_i,a,m,_e,d){var e=r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.Tooltip=void 0;var t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),n=e(r(d[4])),i=(e(r(d[5])),e(r(d[6]))),s=(e(r(d[7])),e(r(d[8]))),u=e(r(d[9])),f=e(r(d[10])),c=this&&this.__rest||function(e,t){var l={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(l[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n{var{withOverlay:h=!0,overlayColor:p="#fafafa14",highlightColor:y="transparent",withPointer:O=!0,toggleOnPress:b=!0,toggleAction:v="onPress",height:C=40,width:E=150,containerStyle:P={},backgroundColor:w="#617080",pointerColor:S=w,pointerStyle:k,onClose:T=()=>{},onOpen:j=()=>{},visible:x=!1,skipAndroidStatusBar:B=!1,ModalComponent:H=o.default,closeOnlyOnBackdropPress:W=!1,animationType:_="fade"}=e,A=c(e,["withOverlay","overlayColor","highlightColor","withPointer","toggleOnPress","toggleAction","height","width","containerStyle","backgroundColor","pointerColor","pointerStyle","onClose","onOpen","visible","skipAndroidStatusBar","ModalComponent","closeOnlyOnBackdropPress","animationType"]);const I=t.default.useRef(!1),L=t.default.useRef(null),[M,D]=t.default.useState({yOffset:0,xOffset:0,elementWidth:0,elementHeight:0}),R=t.default.useCallback((()=>{var e;null===(e=L.current)||void 0===e||e.measure(((e,t,l=0,o=0,n=0,i=0)=>{I.current&&D({xOffset:n,yOffset:r(d[11]).isIOS||B?i:i-0,elementWidth:l,elementHeight:o})}))}),[B]),Y=t.default.useCallback((()=>{R(),I.current&&b&&(x?null==T||T():null==j||j())}),[R,T,j,b,x]),q=({tooltipY:e})=>{const{yOffset:l,xOffset:o,elementHeight:s,elementWidth:u}=M,c=l>(e||0);return O?t.default.createElement(n.default,{style:{position:'absolute',top:c?l-13:l+s-2,[i.default.isRTL?'right':'left']:o+(0,r(d[12]).getElementVisibleWidth)(u,o,r(d[11]).ScreenWidth)/2-7.5}},t.default.createElement(f.default,{style:k,pointerColor:S,isDown:c})):null},F=t.default.useMemo((()=>{const{yOffset:e,xOffset:t,elementWidth:l,elementHeight:o}=M;return{position:'absolute',top:e,[i.default.isRTL?'right':'left']:t,backgroundColor:y,overflow:'visible',width:l,height:o}}),[M,y]),N=()=>W?t.default.createElement(n.default,{testID:"tooltipTouchableHighlightedButton",style:F},A.children):t.default.createElement(u.default,{testID:"tooltipTouchableHighlightedButton",onPress:Y,style:F},A.children);t.default.useEffect((()=>{I.current=!0,requestAnimationFrame(R);const e=s.default.addEventListener('change',R);return()=>{I.current=!1,(null==e?void 0:e.remove)?e.remove():s.default.removeEventListener('change',R)}}),[R]);const V=t.default.useMemo((()=>(0,r(d[13]).getTooltipStyle)(Object.assign(Object.assign({},M),{backgroundColor:w,containerStyle:P,height:C,width:E,withPointer:O}))),[w,P,M,C,E,O]);return t.default.createElement(n.default,{collapsable:!1,ref:L},t.default.createElement(u.default,Object.assign({},{[v]:Y},{delayLongPress:250}),A.children),t.default.createElement(H,{transparent:!0,visible:x,onShow:j,animationType:_},t.default.createElement(l.default,{style:{backgroundColor:h?p:'transparent',flex:1},onPress:Y,activeOpacity:1},t.default.createElement(n.default,null,t.default.createElement(N,null),t.default.createElement(q,{tooltipY:V.top}),t.default.createElement(n.default,{style:V,testID:"tooltipPopoverContainer"},A.popover)))))};_e.Tooltip=h,h.displayName='Tooltip'}),655,[1,14,355,556,123,598,333,77,136,336,656,402,657,658]); __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 o=t(r(d[1])),l=t(r(d[2])),n=t(r(d[3]));const f=({style:t,pointerColor:f,isDown:u})=>o.default.createElement(l.default,{testID:"RNE__Tooltip_Triangle",style:n.default.flatten([s.triangle,{borderBottomColor:f},t,u?s.down:{}])}),s=n.default.create({down:{transform:[{rotate:'180deg'}]},triangle:{width:0,height:0,backgroundColor:'transparent',borderStyle:'solid',borderLeftWidth:8,borderRightWidth:8,borderBottomWidth:15,borderLeftColor:'transparent',borderRightColor:'transparent',borderBottomColor:'white'}});e.default=o.default.memo(f)}),656,[1,14,123,27]); __d((function(g,r,i,_a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.getElementVisibleWidth=e.default=void 0;const t=(t,a)=>t*a,a=(t,a)=>Math.sqrt(Math.pow(t[0]-a[0],2)+Math.pow(t[1]-a[1],2)),s=(t,a,s)=>a>=0?a+t<=s?t:s-a:t-a;e.getElementVisibleWidth=s;const n=(t,a,s,n,c)=>{switch(a){case 0:case 3:return t<1?10:t>n?n-10:t;case 1:case 2:{const a=n-t;return a>=c?t:t-(c-a+10)}default:return 0}};e.default=(c,o,u,l,h,f,p,M,_)=>{const b=[c+s(u,c,h)/2,o+l/2],w=[h,b[1]],v=[b[0],f],y=[0,b[1]],E=a(b,[b[0],0]),V=a(b,w),W=a(b,v),j=a(b,y),q=[t(E,j),t(E,V),t(V,W),t(W,j)].map(((t,a)=>({area:t,id:a}))).sort(((t,a)=>a.area-t.area)),x=l/2,O=[[-1,-1],[1,-1],[1,1],[-1,1]],P=[[-p,-M],[0,-M],[0,0],[-p,0]],k=q[0].id,z=(_?b[0]-18*O[k][0]:b[0])+(.001*O[k][0]+P[k][0]);return{x:n(z,k,b[0],h,p),y:b[1]+(x*O[k][1]+P[k][1])+(_?10*O[k][1]:0)}}}),657,[]); __d((function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.getTooltipStyle=void 0;var o=t(r(d[1])),n=t(r(d[2])),l=t(r(d[3]));e.getTooltipStyle=({yOffset:t,xOffset:f,elementHeight:h,elementWidth:u,width:s,height:c,withPointer:y,backgroundColor:p,containerStyle:b})=>{const{x:S,y:v}=(0,l.default)(f,t,u,h,r(d[4]).ScreenWidth,r(d[4]).ScreenHeight,s,c,y);return n.default.flatten([{position:'absolute',[o.default.isRTL?'right':'left']:S,top:v,width:s,height:c,backgroundColor:p,display:'flex',alignItems:'center',justifyContent:'center',flex:1,borderRadius:10,padding:10},b])}}),658,[1,333,27,657,402]); diff --git a/static/example-app/index.html b/static/example-app/index.html index c1a4e33..784e95b 100644 --- a/static/example-app/index.html +++ b/static/example-app/index.html @@ -32,6 +32,6 @@
- +