mapbox-gl
Version:
A WebGL interactive maps library
1 lines • 771 kB
JavaScript
!function(){var e=1e-6,t="undefined"!=typeof Float32Array?Float32Array:Array;function r(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-o*u,e[1]=i*u-n*c,e[2]=n*o-i*a,e[3]=o*l-s*c,e[4]=r*c-i*l,e[5]=i*s-r*o,e[6]=s*u-a*l,e[7]=n*l-r*u,e[8]=r*a-n*s,e}function n(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=r[0],d=r[1],f=r[2],y=r[3],m=r[4],g=r[5],x=r[6],v=r[7],b=r[8];return e[0]=p*n+d*a+f*u,e[1]=p*i+d*o+f*c,e[2]=p*s+d*l+f*h,e[3]=y*n+m*a+g*u,e[4]=y*i+m*o+g*c,e[5]=y*s+m*l+g*h,e[6]=x*n+v*a+b*u,e[7]=x*i+v*o+b*c,e[8]=x*s+v*l+b*h,e}function i(){var e=new t(16);return t!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function s(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 a(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],p=t[10],d=t[11],f=t[12],y=t[13],m=t[14],g=t[15],x=r*o-n*a,v=r*l-i*a,b=r*u-s*a,w=n*l-i*o,_=n*u-s*o,A=i*u-s*l,I=c*y-h*f,P=c*m-p*f,M=c*g-d*f,D=h*m-p*y,B=h*g-d*y,C=p*g-d*m,T=x*C-v*B+b*D+w*M-_*P+A*I;return T?(e[0]=(o*C-l*B+u*D)*(T=1/T),e[1]=(i*B-n*C-s*D)*T,e[2]=(y*A-m*_+g*w)*T,e[3]=(p*_-h*A-d*w)*T,e[4]=(l*M-a*C-u*P)*T,e[5]=(r*C-i*M+s*P)*T,e[6]=(m*b-f*A-g*v)*T,e[7]=(c*A-p*b+d*v)*T,e[8]=(a*B-o*M+u*I)*T,e[9]=(n*M-r*B-s*I)*T,e[10]=(f*_-y*b+g*x)*T,e[11]=(h*b-c*_-d*x)*T,e[12]=(o*P-a*D-l*I)*T,e[13]=(r*D-n*P+i*I)*T,e[14]=(y*v-f*w-m*x)*T,e[15]=(c*w-h*v+p*x)*T,e):null}function o(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=t[9],d=t[10],f=t[11],y=t[12],m=t[13],g=t[14],x=t[15],v=r[0],b=r[1],w=r[2],_=r[3];return e[0]=v*n+b*o+w*h+_*y,e[1]=v*i+b*l+w*p+_*m,e[2]=v*s+b*u+w*d+_*g,e[3]=v*a+b*c+w*f+_*x,e[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*y,e[5]=v*i+b*l+w*p+_*m,e[6]=v*s+b*u+w*d+_*g,e[7]=v*a+b*c+w*f+_*x,e[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*y,e[9]=v*i+b*l+w*p+_*m,e[10]=v*s+b*u+w*d+_*g,e[11]=v*a+b*c+w*f+_*x,e[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*y,e[13]=v*i+b*l+w*p+_*m,e[14]=v*s+b*u+w*d+_*g,e[15]=v*a+b*c+w*f+_*x,e}function l(e,t,r){var n,i,s,a,o,l,u,c,h,p,d,f,y=r[0],m=r[1],g=r[2];return t===e?(e[12]=t[0]*y+t[4]*m+t[8]*g+t[12],e[13]=t[1]*y+t[5]*m+t[9]*g+t[13],e[14]=t[2]*y+t[6]*m+t[10]*g+t[14],e[15]=t[3]*y+t[7]*m+t[11]*g+t[15]):(i=t[1],s=t[2],a=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=t[9],d=t[10],f=t[11],e[0]=n=t[0],e[1]=i,e[2]=s,e[3]=a,e[4]=o,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=p,e[10]=d,e[11]=f,e[12]=n*y+o*m+h*g+t[12],e[13]=i*y+l*m+p*g+t[13],e[14]=s*y+u*m+d*g+t[14],e[15]=a*y+c*m+f*g+t[15]),e}function u(e,t,r){var n=r[0],i=r[1],s=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function c(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[4],a=t[5],o=t[6],l=t[7],u=t[8],c=t[9],h=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+u*n,e[5]=a*i+c*n,e[6]=o*i+h*n,e[7]=l*i+p*n,e[8]=u*i-s*n,e[9]=c*i-a*n,e[10]=h*i-o*n,e[11]=p*i-l*n,e}function h(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],a=t[1],o=t[2],l=t[3],u=t[8],c=t[9],h=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-u*n,e[1]=a*i-c*n,e[2]=o*i-h*n,e[3]=l*i-p*n,e[8]=s*n+u*i,e[9]=a*n+c*i,e[10]=o*n+h*i,e[11]=l*n+p*i,e}function p(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],a=t[1],o=t[2],l=t[3],u=t[4],c=t[5],h=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i+u*n,e[1]=a*i+c*n,e[2]=o*i+h*n,e[3]=l*i+p*n,e[4]=u*i-s*n,e[5]=c*i-a*n,e[6]=h*i-o*n,e[7]=p*i-l*n,e}function d(){var e=new t(3);return t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function f(e){var r=new t(3);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r}function y(e){var t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function m(e,r,n){var i=new t(3);return i[0]=e,i[1]=r,i[2]=n,i}function g(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function x(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function v(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function b(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function w(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function _(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function A(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function I(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function P(e,t){var r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function M(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function D(e,t){var r=t[0],n=t[1],i=t[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function B(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function C(e,t,r){var n=t[0],i=t[1],s=t[2],a=r[0],o=r[1],l=r[2];return e[0]=i*l-s*o,e[1]=s*a-n*l,e[2]=n*o-i*a,e}function T(e,t,r,n){var i=t[0],s=t[1],a=t[2];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=a+n*(r[2]-a),e}function E(e,t,r){var n=t[0],i=t[1],s=t[2],a=r[3]*n+r[7]*i+r[11]*s+r[15];return e[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(a=a||1),e[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/a,e[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/a,e}function k(e,t,r){var n=t[0],i=t[1],s=t[2];return e[0]=n*r[0]+i*r[3]+s*r[6],e[1]=n*r[1]+i*r[4]+s*r[7],e[2]=n*r[2]+i*r[5]+s*r[8],e}function z(e,t,r){var n=r[0],i=r[1],s=r[2],a=r[3],o=t[0],l=t[1],u=t[2],c=i*u-s*l,h=s*o-n*u,p=n*l-i*o;return e[0]=o+a*(c+=c)+i*(p+=p)-s*(h+=h),e[1]=l+a*h+s*c-n*p,e[2]=u+a*p+n*h-i*c,e}function L(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var F=v,V=y;function R(e,t,r){var n=t[0],i=t[1],s=t[2],a=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*a,e[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*a,e[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*a,e[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*a,e}function O(){var e=new t(4);return t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function U(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}d(),function(){var e;e=new t(4),t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0)}();var N,j,G,$,X,q,Z=(N=d(),j=m(1,0,0),G=m(0,1,0),function(e,t,r){var n=B(t,r);return n<-.999999?(C(N,j,t),V(N)<1e-6&&C(N,G,t),D(N,N),function(e,t,r){r*=.5;var n=Math.sin(r);e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r)}(e,N,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(C(N,t,r),e[0]=N[0],e[1]=N[1],e[2]=N[2],e[3]=1+n,function(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],a=r*r+n*n+i*i+s*s;return a>0&&(a=1/Math.sqrt(a)),e[0]=r*a,e[1]=n*a,e[2]=i*a,e[3]=s*a,e}(e,e))});function W(){var e=new t(2);return t!=Float32Array&&(e[0]=0,e[1]=0),e}function Y(e,r){var n=new t(2);return n[0]=e,n[1]=r,n}function J(e,t,r){return e[0]=t,e[1]=r,e}function K(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function Q(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function ee(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function te(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function re(e,t){var r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e}function ne(e,t){return e[0]*t[0]+e[1]*t[1]}function ie(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}O(),O(),$=new t(9),t!=Float32Array&&($[1]=0,$[2]=0,$[3]=0,$[5]=0,$[6]=0,$[7]=0),$[0]=1,$[4]=1,$[8]=1,W();var se=function(){if(q)return X;function e(e,t,r,n){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=r,this.p2y=n}return q=1,X=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,n=0;n<8;n++){var i=this.sampleCurveX(r)-e;if(Math.abs(i)<t)return r;var s=this.sampleCurveDerivativeX(r);if(Math.abs(s)<1e-6)break;r-=i/s}var a=0,o=1;for(r=e,n=0;n<20&&(i=this.sampleCurveX(r),!(Math.abs(i-e)<t));n++)e>i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},X}(),ae=ie(se);function oe(e,t){this.x=e,this.y=t}function le(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!le(e[r],t[r]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(!le(e[r],t[r]))return!1;return!0}return e===t}oe.prototype={clone(){return new oe(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const 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(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),r=Math.sin(e),n=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=n,this},_rotateAround(e,t){const r=Math.cos(e),n=Math.sin(e),i=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-n*(this.y-t.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:oe},oe.convert=function(e){if(e instanceof oe)return e;if(Array.isArray(e))return new oe(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new oe(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const ue=Math.PI/180,ce=180/Math.PI;function he(e){return e*ue}function pe(e){return e*ce}function de(e,t,r){return Math.min(r,Math.max(t,e))}function fe(e,t,r){return(r=de((r-e)/(t-e),0,1))*r*(3-2*r)}function ye(e,t,r){const n=r-t,i=((e-t)%n+n)%n+t;return i===t?r:i}function me(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function ge(e,t,r){const n={};for(const r in e)n[r]=t.call(this,e[r],r,e);return n}function xe(e){return Array.isArray(e)?e.map(xe):"object"==typeof e&&e?ge(e,xe):e}function ve(e,t){for(let r=0;r<e.length;r++)if(t.indexOf(e[r])>=0)return!0;return!1}new ae(.25,.1,.25,1);const be={};function we(e){be[e]||("undefined"!=typeof console&&console.warn(e),be[e]=!0)}function _e(e,t,r){return(r.y-e.y)*(t.x-e.x)>(t.y-e.y)*(r.x-e.x)}function Ae(e){let t=0;for(let r,n,i=0,s=e.length,a=s-1;i<s;a=i++)r=e[i],n=e[a],t+=(n.x-r.x)*(r.y+n.y);return t}function Se(e){return("undefined"!=typeof self||void 0!==e)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==e?e:self)instanceof WorkerGlobalScope}function Ie(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,r,n,i)=>{const s=n||i;return t[r]=!s||s.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}function Pe(e){return e?{cacheControl:e.get("cache-control"),expires:e.get("expires")}:{cacheControl:void 0,expires:void 0}}function Me(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function De(e,t,r,n){for(;t<r;){const i=t+r>>1;e[i]<n?t=i+1:r=i}return t}function Be(e,t,r,n){for(;t<r;){const i=t+r>>1;e[i]<=n?t=i+1:r=i}return t}function Ce(e,t,r){return(e-t.min)*(r.max-r.min)/(t.max-t.min)+r.min}var Te,Ee,ke,ze=function(){if(Ee)return Te;Ee=1,Te=t;var e=3;function t(t,r,n){var i=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var a=0;a<this.d*this.d;a++){var o=s[e+a],l=s[e+a+1];i.push(o===l?null:s.subarray(o,l))}var u=s[e+i.length+1];this.keys=s.subarray(s[e+i.length],u),this.bboxes=s.subarray(u),this.insert=this._insertReadonly}else{this.d=r+2*n;for(var c=0;c<this.d*this.d;c++)i.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=t,this.padding=n,this.scale=r/t,this.uid=0;var h=n/r*t;this.min=-h,this.max=t+h}return t.prototype.insert=function(e,t,r,n,i){this._forEachCell(t,r,n,i,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(r),this.bboxes.push(n),this.bboxes.push(i)},t.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},t.prototype._insertCell=function(e,t,r,n,i,s){this.cells[i].push(s)},t.prototype.query=function(e,t,r,n,i){var s=this.min,a=this.max;if(e<=s&&t<=s&&a<=r&&a<=n&&!i)return Array.prototype.slice.call(this.keys);var o=[];return this._forEachCell(e,t,r,n,this._queryCell,o,{},i),o},t.prototype._queryCell=function(e,t,r,n,i,s,a,o){var l=this.cells[i];if(null!==l)for(var u=this.keys,c=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===a[p]){var d=4*p;(o?o(c[d+0],c[d+1],c[d+2],c[d+3]):e<=c[d+2]&&t<=c[d+3]&&r>=c[d+0]&&n>=c[d+1])?(a[p]=!0,s.push(u[p])):a[p]=!1}}},t.prototype._forEachCell=function(e,t,r,n,i,s,a,o){for(var l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n),p=l;p<=c;p++)for(var d=u;d<=h;d++){var f=this.d*d+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&i.call(this,e,t,r,n,f,s,a,o))return}},t.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},t.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},t.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,r=e+this.cells.length+1+1,n=0,i=0;i<this.cells.length;i++)n+=this.cells[i].length;var s=new Int32Array(r+n+this.keys.length+this.bboxes.length);s[0]=this.extent,s[1]=this.n,s[2]=this.padding;for(var a=r,o=0;o<t.length;o++){var l=t[o];s[e+o]=a,s.set(l,a),a+=l.length}return s[e+t.length]=a,s.set(this.keys,a),s[e+t.length+1]=a+=this.keys.length,s.set(this.bboxes,a),a+=this.bboxes.length,s.buffer},Te}(),Le=ie(ze),Fe={},Ve=function(){if(ke)return Fe;ke=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return(e=Math.round(e))<0?0:e>255?255:e}function r(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function n(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function i(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}try{Fe.parseCSSColor=function(s){var a,o=s.replace(/ /g,"").toLowerCase();if(o in e)return e[o].slice();if("#"===o[0])return 4===o.length?(a=parseInt(o.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1]:null:7===o.length&&(a=parseInt(o.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1]:null;var l=o.indexOf("("),u=o.indexOf(")");if(-1!==l&&u+1===o.length){var c=o.substr(0,l),h=o.substr(l+1,u-(l+1)).split(","),p=1;switch(c){case"rgba":if(4!==h.length)return null;p=n(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),p];case"hsla":if(4!==h.length)return null;p=n(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),y=n(h[2]),m=y<=.5?y*(f+1):y+f-y*f,g=2*y-m;return[t(255*i(g,m,d+1/3)),t(255*i(g,m,d)),t(255*i(g,m,d-1/3)),p];default:return null}}return null}}catch(e){}return Fe}();function Re(e,t,r){return e*(1-r)+t*r}var Oe=Object.freeze({__proto__:null,array:function(e,t,r){return e.map((e,n)=>Re(e,t[n],r))},color:function(e,t,r){return new Color(Re(e.r,t.r,r),Re(e.g,t.g,r),Re(e.b,t.b,r),Re(e.a,t.a,r))},number:Re});class Color{constructor(e,t,r,n=1){this.r=e,this.g=t,this.b=r,this.a=n}static parse(e){if(!e)return;if(e instanceof Color)return e;if("string"!=typeof e)return;const t=Ve.parseCSSColor(e);return t?new Color(t[0]/255,t[1]/255,t[2]/255,t[3]):void 0}toString(){const[e,t,r,n]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*r)},${n})`}toNonPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new NonPremultipliedRenderColor(e,t,r,n,i)}toPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new PremultipliedRenderColor(e,t*i,r*i,n*i,i)}clone(){return new Color(this.r,this.g,this.b,this.a)}}class RenderColor{constructor(e,t,r,n,i,s=!1){if(this.premultiplied=!1,this.premultiplied=s,e){const s=e.image.height,a=s*s;this.premultiplied?(t=0===i?0:t/i*(s-1),r=0===i?0:r/i*(s-1),n=0===i?0:n/i*(s-1)):(t*=s-1,r*=s-1,n*=s-1),t=Math.max(0,Math.min(s-1,t)),r=Math.max(0,Math.min(s-1,r)),n=Math.max(0,Math.min(s-1,n));const o=Math.floor(t),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(t),h=Math.ceil(r),p=Math.ceil(n),d=t-o,f=r-l,y=n-u,m=e.image.data,g=4*(o+l*a+u*s),x=4*(o+l*a+p*s),v=4*(o+h*a+u*s),b=4*(o+h*a+p*s),w=4*(c+l*a+u*s),_=4*(c+l*a+p*s),A=4*(c+h*a+u*s),I=4*(c+h*a+p*s);this.r=Re(Re(Re(m[g],m[x],y),Re(m[v],m[b],y),f),Re(Re(m[w],m[_],y),Re(m[A],m[I],y),f),d)/255*(this.premultiplied?i:1),this.g=Re(Re(Re(m[g+1],m[x+1],y),Re(m[v+1],m[b+1],y),f),Re(Re(m[w+1],m[_+1],y),Re(m[A+1],m[I+1],y),f),d)/255*(this.premultiplied?i:1),this.b=Re(Re(Re(m[g+2],m[x+2],y),Re(m[v+2],m[b+2],y),f),Re(Re(m[w+2],m[_+2],y),Re(m[A+2],m[I+2],y),f),d)/255*(this.premultiplied?i:1),this.a=i}else this.r=t,this.g=r,this.b=n,this.a=i}toArray(){const{r:e,g:t,b:r,a:n}=this;return[255*e,255*t,255*r,n]}toHslaArray(){let{r:e,g:t,b:r,a:n}=this;if(this.premultiplied){if(0===n)return[0,0,0,0];const i=1/n;e*=i,t*=i,r*=i}const i=Math.min(Math.max(e,0),1),s=Math.min(Math.max(t,0),1),a=Math.min(Math.max(r,0),1),o=Math.min(i,s,a),l=Math.max(i,s,a),u=l-o,c=.5*(o+l);if(0===u)return[0,0,100*c,n];const h=c>.5?u/(2-l-o):u/(l+o);let p;switch(l){case i:p=60*((s-a)/u+(s<a?6:0));break;case s:p=60*((a-i)/u+2);break;default:p=60*((i-s)/u+4)}return[p,100*h,100*c,n]}toArray01(){const{r:e,g:t,b:r,a:n}=this;return[e,t,r,n]}toArray01Scaled(e){const{r:t,g:r,b:n}=this;return[t*e,r*e,n*e]}toArray01Linear(){const{r:e,g:t,b:r,a:n}=this;return[Math.pow(e,2.2),Math.pow(t,2.2),Math.pow(r,2.2),n]}}class NonPremultipliedRenderColor extends RenderColor{constructor(e,t,r,n,i){super(e,t,r,n,i,!1)}}class PremultipliedRenderColor extends RenderColor{constructor(e,t,r,n,i){super(e,t,r,n,i,!0)}}Color.black=new Color(0,0,0,1),Color.white=new Color(1,1,1,1),Color.transparent=new Color(0,0,0,0),Color.red=new Color(1,0,0,1),Color.blue=new Color(0,0,1,1);class ParsingError extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Scope{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,r]of t)this.bindings[e]=r}concat(e){return new Scope(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 Ue={kind:"null"},Ne={kind:"number"},je={kind:"string"},Ge={kind:"boolean"},$e={kind:"color"},Xe={kind:"object"},qe={kind:"value"},He={kind:"collator"},Ze={kind:"formatted"},We={kind:"resolvedImage"};function Ye(e,t){return{kind:"array",itemType:e,N:t}}function Je(e){if("array"===e.kind){const t=Je(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Ke=[Ue,Ne,je,Ge,$e,Ze,Xe,Ye(qe),We];function Qe(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Qe(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 Ke)if(!Qe(e,t))return null}return`Expected ${Je(e)} but found ${Je(t)} instead.`}function et(e,t){return t.some(t=>t.kind===e.kind)}function tt(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function rt(e,t){return"array"===e.kind&&"array"===t.kind?e.N===t.N&&rt(e.itemType,t.itemType):e.kind===t.kind}class Collator{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class FormattedSection{constructor(e,t,r,n,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=r,this.fontStack=n,this.textColor=i}}class Formatted{constructor(e){this.sections=e}static fromString(e){return new Formatted([new FormattedSection(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof Formatted?e:Formatted.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){const r=t.image.getPrimary().id.toString();e.push(["image",r]);continue}e.push(t.text);const r={};t.fontStack&&(r["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(r["font-scale"]=t.scale),t.textColor&&(r["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(r)}return e}}class ImageId{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new ImageId(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,r]=e.split("");return new ImageId({name:t,iconsetId:r})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return ImageId.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}class ImageVariant{constructor(e,t={}){this.id=ImageId.from(e),this.params=t.params,this.sx=t.sx||1,this.sy=t.sy||1}toString(){return JSON.stringify(this)}static parse(e){let t,r,n,i;try{({id:t,params:r,sx:n,sy:i}=JSON.parse(e)||{})}catch(e){return null}return t?new ImageVariant(t,{params:r,sx:n,sy:i}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class ResolvedImage{constructor(e,t,r,n,i=!1){this.primaryId=ImageId.from(e),this.primaryOptions=t,r&&(this.secondaryId=ImageId.from(r)),this.secondaryOptions=n,this.available=i}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new ImageVariant(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new ImageVariant(this.secondaryId,this.secondaryOptions):null}static from(e){return"string"==typeof e?ResolvedImage.build({name:e}):e}static build(e,t,r,n){return!e||"object"==typeof e&&!("name"in e)?null:new ResolvedImage(e,r,t,n)}}function nt(e,t,r,n){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function it(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 Color)return!0;if(e instanceof Collator)return!0;if(e instanceof Formatted)return!0;if(e instanceof ResolvedImage)return!0;if(Array.isArray(e)){for(const t of e)if(!it(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!it(e[t]))return!1;return!0}return!1}function st(e){if(null===e)return Ue;if("string"==typeof e)return je;if("boolean"==typeof e)return Ge;if("number"==typeof e)return Ne;if(e instanceof Color)return $e;if(e instanceof Collator)return He;if(e instanceof Formatted)return Ze;if(e instanceof ResolvedImage)return We;if(Array.isArray(e)){const t=e.length;let r;for(const t of e){const e=st(t);if(r){if(r===e)continue;r=qe;break}r=e}return Ye(r||qe,t)}return Xe}function at(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Formatted||e instanceof ResolvedImage||e instanceof Color?e.toString():JSON.stringify(e)}class Literal{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(!it(e[1]))return t.error("invalid value");const r=e[1];let n=st(r);const i=t.expectedType;return"array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Literal(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Color?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Formatted?this.value.serialize():this.value}}class RuntimeError{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const ot={string:je,number:Ne,boolean:Ge,object:Xe};class Assertion{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r,n=1;const i=e[0];if("array"===i){let i,s;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in ot)||"object"===r)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=ot[r],n++}else i=qe;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);s=e[2],n++}r=Ye(i,s)}else r=ot[i];const s=[];for(;n<e.length;n++){const r=t.parse(e[n],n,qe);if(!r)return null;s.push(r)}return new Assertion(r,s)}evaluate(e){for(let t=0;t<this.args.length;t++){const r=this.args[t].evaluate(e);if(!Qe(this.type,st(r)))return r;if(t===this.args.length-1)throw new RuntimeError(`The expression ${JSON.stringify(this.args[t].serialize())} evaluated to ${Je(st(r))} but was expected to be of type ${Je(this.type)}.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const r=e.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){t.push(r.kind);const n=e.N;("number"==typeof n||this.args.length>1)&&t.push(n)}}return t.concat(this.args.map(e=>e.serialize()))}}class FormatExpression{constructor(e){this.type=Ze,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return t.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=e.length-1;++r){const s=e[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let e=null;if(s["font-scale"]&&(e=t.parseObjectValue(s["font-scale"],r,"font-scale",Ne),!e))return null;let a=null;if(s["text-font"]&&(a=t.parseObjectValue(s["text-font"],r,"text-font",Ye(je)),!a))return null;let o=null;if(s["text-color"]&&(o=t.parseObjectValue(s["text-color"],r,"text-color",$e),!o))return null;const l=n[n.length-1];l.scale=e,l.font=a,l.textColor=o}else{const s=t.parse(e[r],r,qe);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null})}}return new FormatExpression(n)}evaluate(e){return new Formatted(this.sections.map(t=>{const r=t.content.evaluate(e);return rt(st(r),We)?new FormattedSection("",r,null,null,null):new FormattedSection(at(r),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const r={};t.scale&&(r["font-scale"]=t.scale.serialize()),t.font&&(r["text-font"]=t.font.serialize()),t.textColor&&(r["text-color"]=t.textColor.serialize()),e.push(r)}return e}}class ImageExpression{constructor(e,t,r,n){this._imageWarnHistory={},this.type=We,this.namePrimary=e,this.nameSecondary=t,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),n&&(this.paramsSecondary=n.params,this.iconsetIdSecondary=n.iconset?n.iconset.id:void 0)}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let r=1;const n=[];function i(){if(r<e.length){const i=t.parse(e[r],r++,je);return i?(n.push({image:i,options:{}}),!0):(t.error(n.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function s(){if(r<e.length){const s=e[r];if(null===(i=s)||"object"!=typeof i||Array.isArray(i))return!0;const a=s.params,o=s.iconset,l=t.concat(r);if(!a&&!o)return r++,!0;if(a){if("object"!=typeof a||a.constructor!==Object)return l.error('Image options "params" should be an object'),!1;const e={},t=l.concat(void 0,"params");for(const r in a){if(!r)return t.error("Image parameter name should be non-empty"),!1;const n=t.concat(void 0,r).parse(a[r],void 0,$e,void 0,{typeAnnotation:"coerce"});if(!n)return!1;e[r]=n}n[n.length-1].options.params=e}if(o){if("object"!=typeof o||o.constructor!==Object)return l.error('Image options "iconset" should be an object'),!1;if(!o.id)return l.error('Image options "iconset" should have an "id" property'),!1;n[n.length-1].options.iconset=o}return r++,!0}var i;return!0}for(let e=0;e<2;e++)if(!i()||!s())return;return new ImageExpression(n[0].image,n[1]?n[1].image:void 0,n[0].options,n[1]?n[1].options:void 0)}evaluateParams(e,t){const r={};if(t){for(const n in t)if(t[n])try{r[n]=t[n].evaluate(e)}catch(e){continue}if(0!==Object.keys(r).length)return{params:r}}}evaluate(e){const t={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},r=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,n=ResolvedImage.build(t,r,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(n&&e.availableImages){const t=n.getPrimary().id;if(n.available=e.availableImages.some(e=>ImageId.isEqual(e,t)),n.available){const t=n.getSecondary()?n.getSecondary().id:null;t&&(n.available=e.availableImages.some(e=>ImageId.isEqual(e,t)))}}return n}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const t in this.paramsPrimary)this.paramsPrimary[t]&&e(this.paramsPrimary[t]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const t in this.paramsSecondary)this.paramsSecondary[t]&&e(this.paramsSecondary[t])}outputDefined(){return!1}serializeOptions(e,t){const r={};if(t&&(r.iconset={id:t}),e){r.params={};for(const t in e)e[t]&&(r.params[t]=e[t].serialize())}return Object.keys(r).length>0?r:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const t=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);t&&e.push(t)}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const t=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);t&&e.push(t)}return e}}function lt(e){return"string"==typeof(t=e)||t instanceof String?"string":ut(e)?"number":function(e){return"boolean"==typeof e||e instanceof Boolean}(e)?"boolean":Array.isArray(e)?"array":null===e?"null":function(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}(e)?"object":typeof e;var t}function ut(e){return"number"==typeof e||e instanceof Number}const ct={"to-boolean":Ge,"to-color":$e,"to-number":Ne,"to-string":je};class Coercion{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[0],n=[];let i=Ue;if("to-array"===r){if(!Array.isArray(e[1]))return null;const r=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);i=Ye(t.expectedType.itemType,r)}else{if(!(r>0&&it(e[1][0])))return null;i=Ye(st(e[1][0]),r)}for(let s=0;s<r;s++){const r=e[1][s];let a;if(Array.isArray(r))a=t.parse(r,void 0,i.itemType);else{const e=lt(r);if(e!==i.itemType.kind)return t.error(`Expected ${i.itemType.kind} but found ${e}.`);a=t.registry.literal.parse(["literal",void 0===r?null:r],t)}if(!a)return null;n.push(a)}}else{if(("to-boolean"===r||"to-string"===r)&&2!==e.length)return t.error("Expected one argument.");i=ct[r];for(let r=1;r<e.length;r++){const i=t.parse(e[r],r,qe);if(!i)return null;n.push(i)}}return new Coercion(i,n)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,r;for(const n of this.args){if(t=n.evaluate(e),r=null,t instanceof Color)return t;if("string"==typeof t){const r=e.parseColor(t);if(r)return r}else if(Array.isArray(t)&&(r=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:nt(t[0],t[1],t[2],t[3]),!r))return new Color(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new RuntimeError(r||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const r of this.args){if(t=r.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new RuntimeError(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Formatted.fromString(at(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?ResolvedImage.build(at(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):at(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 FormatExpression([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new ImageExpression(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize())}),e}}const ht=["Unknown","Point","LineString","Polygon"];class EvaluationContext{constructor(e,t,r){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t,this.iconImageUseTheme=r}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?ht[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*t-e[0])+this.featureDistanceData.bearing[1]*(n*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Color.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class CompoundExpression{constructor(e,t,r,n,i){this.name=e,this.type=t,this._evaluate=r,this.args=n,this._overloadIndex=i}evaluate(e){if(!this._evaluate){const e=CompoundExpression.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1]}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const r=e[0],n=CompoundExpression.definitions[r];if(!n)return t.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=[];let o=null,l=-1;for(const[n,u]of s){if(Array.isArray(n)&&n.length!==e.length-1)continue;a.push(n),l++,o=new ParsingContext(t.registry,t.path,null,t.scope,void 0,t._scope,t.options,t.iconImageUseTheme);const s=[];let c=!1;for(let t=1;t<e.length;t++){const r=e[t],i=Array.isArray(n)?n[t-1]:n.type,a=o.parse(r,1+s.length,i);if(!a){c=!0;break}s.push(a)}if(!c)if(Array.isArray(n)&&n.length!==s.length)o.error(`Expected ${n.length} arguments, but found ${s.length} instead.`);else{for(let e=0;e<s.length;e++){const t=Array.isArray(n)?n[e]:n.type,r=s[e];o.concat(e+1).checkSubtype(t,r.type)}if(0===o.errors.length)return new CompoundExpression(r,i,u,s,l)}}if(1===a.length)t.errors.push(...o.errors);else{const r=(a.length?a:s.map(([e])=>e)).map(pt).join(" | "),n=[];for(let r=1;r<e.length;r++){const i=t.parse(e[r],1+n.length);if(!i)return null;n.push(Je(i.type))}t.error(`Expected arguments of type ${r}, but found (${n.join(", ")}) instead.`)}return null}static register(e,t){CompoundExpression.definitions=t;for(const r in t)e[r]=CompoundExpression}}function pt(e){return Array.isArray(e)?`(${e.map(Je).join(", ")})`:`(${Je(e.type)}...)`}class CollatorExpression{constructor(e,t,r){this.type=He,this.locale=r,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument."),null;const r=e[1];if("object"!=typeof r||Array.isArray(r))return t.error("Collator options argument must be an object."),null;const n=void 0===r["case-sensitive"]?t.parse(!1,1,Ge):t.parseObjectValue(r["case-sensitive"],1,"case-sensitive",Ge);if(!n)return null;const i=void 0===r["diacritic-sensitive"]?t.parse(!1,1,Ge):t.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",Ge);if(!i)return null;let s=null;return r.locale&&(s=t.parseObjectValue(r.locale,1,"locale",je),!s)?null:new CollatorExpression(n,i,s)}evaluate(e){return new Collator(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function dt(e,t,r=0,n=e.length-1,i=yt){for(;n>r;){if(n-r>600){const s=n-r+1,a=t-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);dt(e,t,Math.max(r,Math.floor(t-a*l/s+u)),Math.min(n,Math.floor(t+(s-a)*l/s+u)),i)}const s=e[t];let a=r,o=n;for(ft(e,r,t),i(e[n],s)>0&&ft(e,r,n);a<o;){for(ft(e,a,o),a++,o--;i(e[a],s)<0;)a++;for(;i(e[o],s)>0;)o--}0===i(e[r],s)?ft(e,r,o):(o++,ft(e,o,n)),o<=t&&(r=o+1),t<=o&&(n=o-1)}}function ft(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function yt(e,t){return e<t?-1:e>t?1:0}function mt(e){let t=0;for(let r,n,i=0,s=e.length,a=s-1;i<s;a=i++)r=e[i],n=e[a],t+=(n.x-r.x)*(r.y+n.y);return t}function gt(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function xt(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function vt(e,t,r){const n=e[0]-t[0],i=e[1]-t[1],s=e[0]-r[0],a=e[1]-r[1];return n*a-s*i===0&&n*s<=0&&i*a<=0}function bt(e,t,r){return t[1]>e[1]!=r[1]>e[1]&&e[0]<(r[0]-t[0])*(e[1]-t[1])/(r[1]-t[1])+t[0]}function wt(e,t,r=!1){let n=!1;for(let i=0,s=t.length;i<s;i++){const s=t[i];for(let t=0,i=s.length,a=i-1;t<i;a=t++){const i=s[a],o=s[t];if(vt(e,i,o))return r;bt(e,i,o)&&(n=!n)}}return n}function _t(e,t,r,n){const i=n[0]-r[0],s=n[1]-r[1],a=(e[0]-r[0])*s-i*(e[1]-r[1]),o=(t[0]-r[0])*s-i*(t[1]-r[1]);return a>0&&o<0||a<0&&o>0}function St(e,t,r,n){return 0!==(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*s[0]&&!(!_t(e,t,r,n)||!_t(r,n,e,t));var i,s}function It(e){const t=new oe(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new oe(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of e[0])t.x>n.x&&(t.x=n.x),t.y>n.y&&(t.y=n.y),r.x<n.x&&(r.x=n.x),r.y<n.y&&(r.y=n.y);return{min:t,max:r}}const Pt=8192;function Mt(e,t){const r=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=Math.pow(2,t.z);return[Math.round(r*i*Pt),Math.round(n*i*Pt)]}function Dt(e,t){for(let r=0;r<t.length;r++)if(wt(e,t[r]))return!0;return!1}function Bt(e,t,r){for(const n of r)for(let r=0,i=n.length,s=i-1;r<i;s=r++)if(St(e,t,n[s],n[r]))return!0;return!1}function Ct(e,t){for(let r=0;r<e.length;++r)if(!wt(e[r],t))return!1;for(let r=0;r<e.length-1;++r)if(Bt(e[r],e[r+1],t))return!1;return!0}function Tt(e,t){for(let r=0;r<t.length;r++)if(Ct(e,t[r]))return!0;return!1}function Et(e,t,r){const n=[];for(let i=0;i<e.length;i++){const s=[];for(let n=0;n<e[i].length;n++){const a=Mt(e[i][n],r);gt(t,a),s.push(a)}n.push(s)}return n}function kt(e,t,r){const n=[];for(let i=0;i<e.length;i++){const s=Et(e[i],t,r);n.push(s)}return n}function zt(e,t,r,n){if(e[0]<r[0]||e[0]>r[2]){const t=.5*n;let i=e[0]-r[0]>t?-n:r[0]-e[0]>t?n:0;0===i&&(i=e[0]-r[2]>t?-n:r[2]-e[0]>t?n:0),e[0]+=i}gt(t,e)}function Lt(e,t,r,n){const i=Math.pow(2,n.z)*Pt,s=[n.x*Pt,n.y*Pt],a=[];if(!e)return a;for(const n of e)for(const e of n){const n=[e.x+s[0],e.y+s[1]];zt(n,t,r,i),a.push(n)}return a}function Ft(e,t,r,n){const i=Math.pow(2,n.z)*Pt,s=[n.x*Pt,n.y*Pt],a=[];if(!e)return a;for(const r of e){const e=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];gt(t,r),e.push(r)}a.push(e)}if(t[2]-t[0]<=i/2){(o=t)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const e of a)for(const n of e)zt(n,t,r,i)}var o;return a}class Within{constructor(e,t){this.type=Ge,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(it(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const r=t.features[e].geometry.type;if("Polygon"===r||"MultiPolygon"===r)return new Within(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Within(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Within(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(!i)return!1;if("Polygon"===t.type){const s=Et(t.coordinates,n,i),a=Lt(e.geometry(),r,n,i);if(!xt(r,n))return!1;for(const e of a)if(!wt(e,s))return!1}if("MultiPolygon"===t.type){const s=kt(t.coordinates,n,i),a=Lt(e.geometry(),r,n,i);if(!xt(r,n))return!1;for(const e of a)if(!Dt(e,s))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=e.canonicalID();if(!i)return!1;if("Polygon"===t.type){const s=Et(t.coordinates,n,i),a=Ft(e.geometry(),r,n,i);if(!xt(r,n))return!1;for(const e of a)if(!Ct(e,s))return!1}if("MultiPolygon"===t.type){const s=kt(t.coordinates,n,i),a=Ft(e.geometry(),r,n,i);if(!xt(r,n))return!1;for(const e of a)if(!Tt(e,s))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}const Vt={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},Rt=1/298.257223563,Ot=Rt*(2-Rt),Ut=Math.PI/180;class CheapRuler{static fromTile(e,t,r){const n=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),i=Math.atan(.5*(Math.exp(n)-Math.exp(-n)))/Ut;return new CheapRuler(i,r)}static get units(){return Vt}constructor(e,t){if(void 0===e)throw new Error("No latitude given.");if(t&&!Vt[t])throw new Error(`Unknown unit ${t}. Use one of: ${Object.keys(Vt).join(", ")}`);const r=6378.137*Ut*(t?Vt[t]:1),n=Math.cos(e*Ut),i=1/(1-Ot*(1-n*n)),s=Math.sqrt(i);this.kx=r*s*n,this.ky=r*s*i*(1-Ot)}distance(e,t){const r=Gt(e[0]-t[0])*this.kx,n=(e[1]-t[1])*this.ky;return Math.sqrt(r*r+n*n)}bearing(e,t){const r=Gt(t[0]-e[0])*this.kx;return Math.atan2(r,(t[1]-e[1])*this.ky)/Ut}destination(e,t,r){const n=r*Ut;return this.offset(e,Math.sin(n)*t,Math.cos(n)*t)}offset(e,t,r){return[e[0]+t/this.kx,e[1]+r/this.ky]}lineDistance(e){let t=0;for(let r=0;r<e.length-1;r++)t+=this.distance(e[r],e[r+1]);return t}area(e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];for(let e=0,i=n.length,s=i-1;e<i;s=e++)t+=Gt(n[e][0]-n[s][0])*(n[e][1]+n[s][1])*(r?-1:1)}return Math.abs(t)/2*this.kx*this.ky}along(e,t){let r=0;if(t<=0)return e[0];for(let n=0;n<e.length-1;n++){const i=e[n],s=e[n+1],a=this.distance(i,s);if(r+=a,r>t)return jt(i,s,(t-(r-a))/a)}return e[e.length-1]}pointToSegmentDistance(e,t,r){let[n,i]=t,s=Gt(r[0]-n)*this.kx,a=(r[1]-i)*this.ky;if(0!==s||0!==a)