summit/frontend/node_modules/mapbox-gl/dist/mapbox-gl-csp-worker.js

11 lines
712 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

!function(){var t=1e-6,e="undefined"!=typeof Float32Array?Float32Array:Array;function r(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],l=e[6],u=e[7],c=e[8];return t[0]=s*c-a*u,t[1]=i*u-n*c,t[2]=n*a-i*s,t[3]=a*l-o*c,t[4]=r*c-i*l,t[5]=i*o-r*a,t[6]=o*u-s*l,t[7]=n*l-r*u,t[8]=r*s-n*o,t}function n(t,e,r){var n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],l=e[5],u=e[6],c=e[7],h=e[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 t[0]=p*n+d*s+f*u,t[1]=p*i+d*a+f*c,t[2]=p*o+d*l+f*h,t[3]=y*n+m*s+g*u,t[4]=y*i+m*a+g*c,t[5]=y*o+m*l+g*h,t[6]=x*n+v*s+b*u,t[7]=x*i+v*a+b*c,t[8]=x*o+v*l+b*h,t}function i(){var t=new e(16);return e!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function o(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function s(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],d=e[11],f=e[12],y=e[13],m=e[14],g=e[15],x=r*a-n*s,v=r*l-i*s,b=r*u-o*s,w=n*l-i*a,_=n*u-o*a,A=i*u-o*l,S=c*y-h*f,I=c*m-p*f,P=c*g-d*f,M=h*m-p*y,D=h*g-d*y,E=p*g-d*m,C=x*E-v*D+b*M+w*P-_*I+A*S;return C?(t[0]=(a*E-l*D+u*M)*(C=1/C),t[1]=(i*D-n*E-o*M)*C,t[2]=(y*A-m*_+g*w)*C,t[3]=(p*_-h*A-d*w)*C,t[4]=(l*P-s*E-u*I)*C,t[5]=(r*E-i*P+o*I)*C,t[6]=(m*b-f*A-g*v)*C,t[7]=(c*A-p*b+d*v)*C,t[8]=(s*D-a*P+u*S)*C,t[9]=(n*P-r*D-o*S)*C,t[10]=(f*_-y*b+g*x)*C,t[11]=(h*b-c*_-d*x)*C,t[12]=(a*I-s*M-l*S)*C,t[13]=(r*M-n*I+i*S)*C,t[14]=(y*v-f*w-m*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null}function a(t,e,r){var n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],d=e[10],f=e[11],y=e[12],m=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*a+w*h+_*y,t[1]=v*i+b*l+w*p+_*m,t[2]=v*o+b*u+w*d+_*g,t[3]=v*s+b*c+w*f+_*x,t[4]=(v=r[4])*n+(b=r[5])*a+(w=r[6])*h+(_=r[7])*y,t[5]=v*i+b*l+w*p+_*m,t[6]=v*o+b*u+w*d+_*g,t[7]=v*s+b*c+w*f+_*x,t[8]=(v=r[8])*n+(b=r[9])*a+(w=r[10])*h+(_=r[11])*y,t[9]=v*i+b*l+w*p+_*m,t[10]=v*o+b*u+w*d+_*g,t[11]=v*s+b*c+w*f+_*x,t[12]=(v=r[12])*n+(b=r[13])*a+(w=r[14])*h+(_=r[15])*y,t[13]=v*i+b*l+w*p+_*m,t[14]=v*o+b*u+w*d+_*g,t[15]=v*s+b*c+w*f+_*x,t}function l(t,e,r){var n,i,o,s,a,l,u,c,h,p,d,f,y=r[0],m=r[1],g=r[2];return e===t?(t[12]=e[0]*y+e[4]*m+e[8]*g+e[12],t[13]=e[1]*y+e[5]*m+e[9]*g+e[13],t[14]=e[2]*y+e[6]*m+e[10]*g+e[14],t[15]=e[3]*y+e[7]*m+e[11]*g+e[15]):(i=e[1],o=e[2],s=e[3],a=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],d=e[10],f=e[11],t[0]=n=e[0],t[1]=i,t[2]=o,t[3]=s,t[4]=a,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=d,t[11]=f,t[12]=n*y+a*m+h*g+e[12],t[13]=i*y+l*m+p*g+e[13],t[14]=o*y+u*m+d*g+e[14],t[15]=s*y+c*m+f*g+e[15]),t}function u(t,e,r){var n=r[0],i=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function c(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[4],s=e[5],a=e[6],l=e[7],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+u*n,t[5]=s*i+c*n,t[6]=a*i+h*n,t[7]=l*i+p*n,t[8]=u*i-o*n,t[9]=c*i-s*n,t[10]=h*i-a*n,t[11]=p*i-l*n,t}function h(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],s=e[1],a=e[2],l=e[3],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-u*n,t[1]=s*i-c*n,t[2]=a*i-h*n,t[3]=l*i-p*n,t[8]=o*n+u*i,t[9]=s*n+c*i,t[10]=a*n+h*i,t[11]=l*n+p*i,t}function p(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],s=e[1],a=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+u*n,t[1]=s*i+c*n,t[2]=a*i+h*n,t[3]=l*i+p*n,t[4]=u*i-o*n,t[5]=c*i-s*n,t[6]=h*i-a*n,t[7]=p*i-l*n,t}function d(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function f(t){var r=new e(3);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r}function y(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function m(t,r,n){var i=new e(3);return i[0]=t,i[1]=r,i[2]=n,i}function g(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function x(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function v(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function b(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function w(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function _(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function A(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function S(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}function I(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function P(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function M(t,e){var r=e[0],n=e[1],i=e[2],o=r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function D(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function E(t,e,r){var n=e[0],i=e[1],o=e[2],s=r[0],a=r[1],l=r[2];return t[0]=i*l-o*a,t[1]=o*s-n*l,t[2]=n*a-i*s,t}function C(t,e,r,n){var i=e[0],o=e[1],s=e[2];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t[2]=s+n*(r[2]-s),t}function B(t,e,r){var n=e[0],i=e[1],o=e[2],s=r[3]*n+r[7]*i+r[11]*o+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/(s=s||1),t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/s,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/s,t}function T(t,e,r){var n=e[0],i=e[1],o=e[2];return t[0]=n*r[0]+i*r[3]+o*r[6],t[1]=n*r[1]+i*r[4]+o*r[7],t[2]=n*r[2]+i*r[5]+o*r[8],t}function k(t,e,r){var n=r[0],i=r[1],o=r[2],s=r[3],a=e[0],l=e[1],u=e[2],c=i*u-o*l,h=o*a-n*u,p=n*l-i*a;return t[0]=a+s*(c+=c)+i*(p+=p)-o*(h+=h),t[1]=l+s*h+o*c-n*p,t[2]=u+s*p+n*h-i*c,t}function z(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}var L=v,V=y;function F(t,e,r){var n=e[0],i=e[1],o=e[2],s=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*o+r[12]*s,t[1]=r[1]*n+r[5]*i+r[9]*o+r[13]*s,t[2]=r[2]*n+r[6]*i+r[10]*o+r[14]*s,t[3]=r[3]*n+r[7]*i+r[11]*o+r[15]*s,t}function R(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function O(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}d(),function(){var t;t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var U,N,j,G,$,q,H=(U=d(),N=m(1,0,0),j=m(0,1,0),function(t,e,r){var n=D(e,r);return n<-.999999?(E(U,N,e),V(U)<1e-6&&E(U,j,e),M(U,U),function(t,e,r){r*=.5;var n=Math.sin(r);t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r)}(t,U,Math.PI),t):n>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(E(U,e,r),t[0]=U[0],t[1]=U[1],t[2]=U[2],t[3]=1+n,function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],s=r*r+n*n+i*i+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=n*s,t[2]=i*s,t[3]=o*s,t}(t,t))});function X(){var t=new e(2);return e!=Float32Array&&(t[0]=0,t[1]=0),t}function Z(t,r){var n=new e(2);return n[0]=t,n[1]=r,n}function W(t,e,r){return t[0]=e,t[1]=r,t}function Y(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function J(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function K(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function Q(t){var e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function tt(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t}function et(t,e){return t[0]*e[0]+t[1]*e[1]}function rt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}R(),R(),G=new e(9),e!=Float32Array&&(G[1]=0,G[2]=0,G[3]=0,G[5]=0,G[6]=0,G[7]=0),G[0]=1,G[4]=1,G[8]=1,X();var nt=function(){if(q)return $;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n}return q=1,$=t,t.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)<e)return r;var o=this.sampleCurveDerivativeX(r);if(Math.abs(o)<1e-6)break;r-=i/o}var s=0,a=1;for(r=t,n=0;n<20&&(i=this.sampleCurveX(r),!(Math.abs(i-t)<e));n++)t>i?s=r:a=r,r=.5*(a-s)+s;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},$}(),it=rt(nt);function ot(t,e){this.x=t,this.y=e}function st(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!st(t[r],e[r]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(!st(t[r],e[r]))return!1;return!0}return t===e}ot.prototype={clone(){return new ot(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,e){return this.clone()._rotateAround(t,e)},matMult(t){return this.clone()._matMult(t)},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(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){const e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult(t){const e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){const t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){const e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround(t,e){const r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:ot},ot.convert=function(t){if(t instanceof ot)return t;if(Array.isArray(t))return new ot(+t[0],+t[1]);if(void 0!==t.x&&void 0!==t.y)return new ot(+t.x,+t.y);throw new Error("Expected [x, y] or {x, y} point format")};const at=Math.PI/180,lt=180/Math.PI;function ut(t){return t*at}function ct(t){return t*lt}function ht(t,e,r){return Math.min(r,Math.max(e,t))}function pt(t,e,r){return(r=ht((r-t)/(e-t),0,1))*r*(3-2*r)}function dt(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function ft(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function yt(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function mt(t){return Array.isArray(t)?t.map(mt):"object"==typeof t&&t?yt(t,mt):t}function gt(t,e){for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>=0)return!0;return!1}new it(.25,.1,.25,1);const xt={};function vt(t){xt[t]||("undefined"!=typeof console&&console.warn(t),xt[t]=!0)}function bt(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function wt(t){let e=0;for(let r,n,i=0,o=t.length,s=o-1;i<o;s=i++)r=t[i],n=t[s],e+=(n.x-r.x)*(r.y+n.y);return e}function _t(t){return("undefined"!=typeof self||void 0!==t)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==t?t:self)instanceof WorkerGlobalScope}function St(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const o=n||i;return e[r]=!o||o.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}function It(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function Pt(t,e,r,n){for(;e<r;){const i=e+r>>1;t[i]<n?e=i+1:r=i}return e}function Mt(t,e,r,n){for(;e<r;){const i=e+r>>1;t[i]<=n?e=i+1:r=i}return e}function Dt(t,e,r){return(t-e.min)*(r.max-r.min)/(e.max-e.min)+r.min}var Et,Ct,Bt,Tt=function(){if(Ct)return Et;Ct=1,Et=e;var t=3;function e(e,r,n){var i=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var o=new Int32Array(this.arrayBuffer);e=o[0],this.d=(r=o[1])+2*(n=o[2]);for(var s=0;s<this.d*this.d;s++){var a=o[t+s],l=o[t+s+1];i.push(a===l?null:o.subarray(a,l))}var u=o[t+i.length+1];this.keys=o.subarray(o[t+i.length],u),this.bboxes=o.subarray(u),this.insert=this._insertReadonly}else{this.d=r+2*n;for(var c=0;c<this.d*this.d;c++)i.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=n,this.scale=r/e,this.uid=0;var h=n/r*e;this.min=-h,this.max=e+h}return e.prototype.insert=function(t,e,r,n,i){this._forEachCell(e,r,n,i,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(r),this.bboxes.push(n),this.bboxes.push(i)},e.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},e.prototype._insertCell=function(t,e,r,n,i,o){this.cells[i].push(o)},e.prototype.query=function(t,e,r,n,i){var o=this.min,s=this.max;if(t<=o&&e<=o&&s<=r&&s<=n&&!i)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(t,e,r,n,this._queryCell,a,{},i),a},e.prototype._queryCell=function(t,e,r,n,i,o,s,a){var l=this.cells[i];if(null!==l)for(var u=this.keys,c=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===s[p]){var d=4*p;(a?a(c[d+0],c[d+1],c[d+2],c[d+3]):t<=c[d+2]&&e<=c[d+3]&&r>=c[d+0]&&n>=c[d+1])?(s[p]=!0,o.push(u[p])):s[p]=!1}}},e.prototype._forEachCell=function(t,e,r,n,i,o,s,a){for(var l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n),p=l;p<=c;p++)for(var d=u;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&i.call(this,t,e,r,n,f,o,s,a))return}},e.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},e.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},e.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,r=t+this.cells.length+1+1,n=0,i=0;i<this.cells.length;i++)n+=this.cells[i].length;var o=new Int32Array(r+n+this.keys.length+this.bboxes.length);o[0]=this.extent,o[1]=this.n,o[2]=this.padding;for(var s=r,a=0;a<e.length;a++){var l=e[a];o[t+a]=s,o.set(l,s),s+=l.length}return o[t+e.length]=s,o.set(this.keys,s),o[t+e.length+1]=s+=this.keys.length,o.set(this.bboxes,s),s+=this.bboxes.length,o.buffer},Et}(),kt=rt(Tt),zt={},Lt=function(){if(Bt)return zt;Bt=1;var t={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function e(t){return(t=Math.round(t))<0?0:t>255?255:t}function r(t){return e("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function n(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function i(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{zt.parseCSSColor=function(o){var s,a=o.replace(/ /g,"").toLowerCase();if(a in t)return t[a].slice();if("#"===a[0])return 4===a.length?(s=parseInt(a.substr(1),16))>=0&&s<=4095?[(3840&s)>>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)<<4,1]:null:7===a.length&&(s=parseInt(a.substr(1),16))>=0&&s<=16777215?[(16711680&s)>>16,(65280&s)>>8,255&s,1]:null;var l=a.indexOf("("),u=a.indexOf(")");if(-1!==l&&u+1===a.length){var c=a.substr(0,l),h=a.substr(l+1,u-(l+1)).split(","),p=1;switch(c){case"rgba":if(4!==h.length)return null;p=n(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),p];case"hsla":if(4!==h.length)return null;p=n(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),y=n(h[2]),m=y<=.5?y*(f+1):y+f-y*f,g=2*y-m;return[e(255*i(g,m,d+1/3)),e(255*i(g,m,d)),e(255*i(g,m,d-1/3)),p];default:return null}}return null}}catch(t){}return zt}();function Vt(t,e,r){return t*(1-r)+e*r}var Ft=Object.freeze({__proto__:null,array:function(t,e,r){return t.map(((t,n)=>Vt(t,e[n],r)))},color:function(t,e,r){return new Color(Vt(t.r,e.r,r),Vt(t.g,e.g,r),Vt(t.b,e.b,r),Vt(t.a,e.a,r))},number:Vt});class Color{constructor(t,e,r,n=1){this.r=t,this.g=e,this.b=r,this.a=n}static parse(t){if(!t)return;if(t instanceof Color)return t;if("string"!=typeof t)return;const e=Lt.parseCSSColor(t);return e?new Color(e[0]/255,e[1]/255,e[2]/255,e[3]):void 0}toString(){const[t,e,r,n]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*t)},${Math.round(255*e)},${Math.round(255*r)},${n})`}toNonPremultipliedRenderColor(t){const{r:e,g:r,b:n,a:i}=this;return new NonPremultipliedRenderColor(t,e,r,n,i)}toPremultipliedRenderColor(t){const{r:e,g:r,b:n,a:i}=this;return new PremultipliedRenderColor(t,e*i,r*i,n*i,i)}clone(){return new Color(this.r,this.g,this.b,this.a)}}class RenderColor{constructor(t,e,r,n,i,o=!1){if(this.premultiplied=!1,this.premultiplied=o,t){const o=t.image.height,s=o*o;this.premultiplied?(e=0===i?0:e/i*(o-1),r=0===i?0:r/i*(o-1),n=0===i?0:n/i*(o-1)):(e*=o-1,r*=o-1,n*=o-1);const a=Math.floor(e),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(e),h=Math.ceil(r),p=Math.ceil(n),d=e-a,f=r-l,y=n-u,m=t.image.data,g=4*(a+l*s+u*o),x=4*(a+l*s+p*o),v=4*(a+h*s+u*o),b=4*(a+h*s+p*o),w=4*(c+l*s+u*o),_=4*(c+l*s+p*o),A=4*(c+h*s+u*o),S=4*(c+h*s+p*o);if(g<0||S>=m.length)throw new Error("out of range");this.r=Vt(Vt(Vt(m[g],m[x],y),Vt(m[v],m[b],y),f),Vt(Vt(m[w],m[_],y),Vt(m[A],m[S],y),f),d)/255*(this.premultiplied?i:1),this.g=Vt(Vt(Vt(m[g+1],m[x+1],y),Vt(m[v+1],m[b+1],y),f),Vt(Vt(m[w+1],m[_+1],y),Vt(m[A+1],m[S+1],y),f),d)/255*(this.premultiplied?i:1),this.b=Vt(Vt(Vt(m[g+2],m[x+2],y),Vt(m[v+2],m[b+2],y),f),Vt(Vt(m[w+2],m[_+2],y),Vt(m[A+2],m[S+2],y),f),d)/255*(this.premultiplied?i:1),this.a=i}else this.r=e,this.g=r,this.b=n,this.a=i}toArray(){const{r:t,g:e,b:r,a:n}=this;return[255*t,255*e,255*r,n]}toHslaArray(){let{r:t,g:e,b:r,a:n}=this;if(this.premultiplied){if(0===n)return[0,0,0,0];const i=1/n;t*=i,e*=i,r*=i}const i=Math.min(Math.max(t,0),1),o=Math.min(Math.max(e,0),1),s=Math.min(Math.max(r,0),1),a=Math.min(i,o,s),l=Math.max(i,o,s),u=l-a,c=.5*(a+l);if(0===u)return[0,0,100*c,n];const h=c>.5?u/(2-l-a):u/(l+a);let p;switch(l){case i:p=60*((o-s)/u+(o<s?6:0));break;case o:p=60*((s-i)/u+2);break;default:p=60*((i-o)/u+4)}return[p,100*h,100*c,n]}toArray01(){const{r:t,g:e,b:r,a:n}=this;return[t,e,r,n]}toArray01Scaled(t){const{r:e,g:r,b:n}=this;return[e*t,r*t,n*t]}toArray01Linear(){const{r:t,g:e,b:r,a:n}=this;return[Math.pow(t,2.2),Math.pow(e,2.2),Math.pow(r,2.2),n]}}class NonPremultipliedRenderColor extends RenderColor{constructor(t,e,r,n,i){super(t,e,r,n,i,!1)}}class PremultipliedRenderColor extends RenderColor{constructor(t,e,r,n,i){super(t,e,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(t,e){super(e),this.message=e,this.key=t}}class Scope{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r}concat(t){return new Scope(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Rt={kind:"null"},Ot={kind:"number"},Ut={kind:"string"},Nt={kind:"boolean"},jt={kind:"color"},Gt={kind:"object"},$t={kind:"value"},qt={kind:"collator"},Ht={kind:"formatted"},Xt={kind:"resolvedImage"};function Zt(t,e){return{kind:"array",itemType:t,N:e}}function Wt(t){if("array"===t.kind){const e=Wt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Yt=[Rt,Ot,Ut,Nt,jt,Ht,Gt,Zt($t),Xt];function Jt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Jt(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Yt)if(!Jt(t,e))return null}return`Expected ${Wt(t)} but found ${Wt(e)} instead.`}function Kt(t,e){return e.some((e=>e.kind===t.kind))}function Qt(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function te(t,e){return"array"===t.kind&&"array"===e.kind?t.N===e.N&&te(t.itemType,e.itemType):t.kind===e.kind}class Collator{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class FormattedSection{constructor(t,e,r,n,i){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i}}class Formatted{constructor(t){this.sections=t}static fromString(t){return new Formatted([new FormattedSection(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||!!t.image&&t.image.hasPrimary()))}static factory(t){return t instanceof Formatted?t:Formatted.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){const r=e.image.getPrimary().id.toString();t.push(["image",r]);continue}t.push(e.text);const r={};e.fontStack&&(r["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(r["font-scale"]=e.scale),e.textColor&&(r["text-color"]=["rgba"].concat(e.textColor.toNonPremultipliedRenderColor(null).toArray())),t.push(r)}return t}}class ImageId{constructor(t){"string"==typeof t?this.name=t:(this.name=t.name,this.iconsetId=t.iconsetId)}static from(t){return new ImageId(t)}static toString(t){return t.iconsetId?`${t.name}${t.iconsetId}`:t.name}static parse(t){const[e,r]=t.split("");return new ImageId({name:e,iconsetId:r})}static isEqual(t,e){return t.name===e.name&&t.iconsetId===e.iconsetId}toString(){return ImageId.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}class ImageVariant{constructor(t,e={}){this.id=ImageId.from(t),this.params=e.params,this.sx=e.sx||1,this.sy=e.sy||1}toString(){return JSON.stringify(this)}static parse(t){let e,r,n,i;try{({id:e,params:r,sx:n,sy:i}=JSON.parse(t)||{})}catch(t){return null}return e?new ImageVariant(e,{params:r,sx:n,sy:i}):null}scaleSelf(t,e=t){return this.sx*=t,this.sy*=e,this}}class ResolvedImage{constructor(t,e,r,n,i=!1){this.primaryId=ImageId.from(t),this.primaryOptions=e,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(t){return"string"==typeof t?ResolvedImage.build({name:t}):t}static build(t,e,r,n){return!t||"object"==typeof t&&!("name"in t)?null:new ResolvedImage(t,r,e,n)}}function ee(t,e,r,n){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function re(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof Color)return!0;if(t instanceof Collator)return!0;if(t instanceof Formatted)return!0;if(t instanceof ResolvedImage)return!0;if(Array.isArray(t)){for(const e of t)if(!re(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!re(t[e]))return!1;return!0}return!1}function ne(t){if(null===t)return Rt;if("string"==typeof t)return Ut;if("boolean"==typeof t)return Nt;if("number"==typeof t)return Ot;if(t instanceof Color)return jt;if(t instanceof Collator)return qt;if(t instanceof Formatted)return Ht;if(t instanceof ResolvedImage)return Xt;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=ne(e);if(r){if(r===t)continue;r=$t;break}r=t}return Zt(r||$t,e)}return Gt}function ie(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Formatted||t instanceof ResolvedImage||t instanceof Color?t.toString():JSON.stringify(t)}class Literal{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!re(t[1]))return e.error("invalid value");const r=t[1];let n=ne(r);const i=e.expectedType;return"array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new 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(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const oe={string:Ut,number:Ot,boolean:Nt,object:Gt};class Assertion{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,o;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in oe)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=oe[r],n++}else i=$t;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);o=t[2],n++}r=Zt(i,o)}else r=oe[i];const o=[];for(;n<t.length;n++){const r=e.parse(t[n],n,$t);if(!r)return null;o.push(r)}return new Assertion(r,o)}evaluate(t){for(let e=0;e<this.args.length;e++){const r=this.args[e].evaluate(t);if(!Jt(this.type,ne(r)))return r;if(e===this.args.length-1)throw new RuntimeError(`The expression ${JSON.stringify(this.args[e].serialize())} evaluated to ${Wt(ne(r))} but was expected to be of type ${Wt(this.type)}.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const r=t.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){e.push(r.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n)}}return e.concat(this.args.map((t=>t.serialize())))}}class FormatExpression{constructor(t){this.type=Ht,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const o=t[r];if(i&&"object"==typeof o&&!Array.isArray(o)){i=!1;let t=null;if(o["font-scale"]&&(t=e.parseObjectValue(o["font-scale"],r,"font-scale",Ot),!t))return null;let s=null;if(o["text-font"]&&(s=e.parseObjectValue(o["text-font"],r,"text-font",Zt(Ut)),!s))return null;let a=null;if(o["text-color"]&&(a=e.parseObjectValue(o["text-color"],r,"text-color",jt),!a))return null;const l=n[n.length-1];l.scale=t,l.font=s,l.textColor=a}else{const o=e.parse(t[r],r,$t);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:o,scale:null,font:null,textColor:null})}}return new FormatExpression(n)}evaluate(t){return new Formatted(this.sections.map((e=>{const r=e.content.evaluate(t);return te(ne(r),Xt)?new FormattedSection("",r,null,null,null):new FormattedSection(ie(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const r={};e.scale&&(r["font-scale"]=e.scale.serialize()),e.font&&(r["text-font"]=e.font.serialize()),e.textColor&&(r["text-color"]=e.textColor.serialize()),t.push(r)}return t}}class ImageExpression{constructor(t,e,r,n){this._imageWarnHistory={},this.type=Xt,this.namePrimary=t,this.nameSecondary=e,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(t,e){if(t.length<2)return e.error("Expected two or more arguments.");let r=1;const n=[];function i(){if(r<t.length){const i=e.parse(t[r],r++,Ut);return i?(n.push({image:i,options:{}}),!0):(e.error(n.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function o(){if(r<t.length){const o=t[r];if(null===(i=o)||"object"!=typeof i||Array.isArray(i))return!0;const s=o.params,a=o.iconset,l=e.concat(r);if(!s&&!a)return r++,!0;if(s){if("object"!=typeof s||s.constructor!==Object)return l.error('Image options "params" should be an object'),!1;const t={},e=l.concat(void 0,"params");for(const r in s){if(!r)return e.error("Image parameter name should be non-empty"),!1;const n=e.concat(void 0,r).parse(s[r],void 0,jt,void 0,{typeAnnotation:"coerce"});if(!n)return!1;t[r]=n}n[n.length-1].options.params=t}if(a){if("object"!=typeof a||a.constructor!==Object)return l.error('Image options "iconset" should be an object'),!1;if(!a.id)return l.error('Image options "iconset" should have an "id" property'),!1;n[n.length-1].options.iconset=a}return r++,!0}var i;return!0}for(let t=0;t<2;t++)if(!i()||!o())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(t,e){const r={};if(e){for(const n in e)if(e[n])try{r[n]=e[n].evaluate(t)}catch(t){continue}if(0!==Object.keys(r).length)return{params:r}}}evaluate(t){const e={name:this.namePrimary.evaluate(t),iconsetId:this.iconsetIdPrimary},r=this.nameSecondary?{name:this.nameSecondary.evaluate(t),iconsetId:this.iconsetIdSecondary}:void 0,n=ResolvedImage.build(e,r,this.paramsPrimary?this.evaluateParams(t,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(t,this.paramsSecondary):void 0);if(n&&t.availableImages){const e=n.getPrimary().id;if(n.available=t.availableImages.some((t=>ImageId.isEqual(t,e))),n.available){const e=n.getSecondary()?n.getSecondary().id:null;e&&(n.available=t.availableImages.some((t=>ImageId.isEqual(t,e))))}}return n}eachChild(t){if(t(this.namePrimary),this.paramsPrimary)for(const e in this.paramsPrimary)this.paramsPrimary[e]&&t(this.paramsPrimary[e]);if(this.nameSecondary&&(t(this.nameSecondary),this.paramsSecondary))for(const e in this.paramsSecondary)this.paramsSecondary[e]&&t(this.paramsSecondary[e])}outputDefined(){return!1}serializeOptions(t,e){const r={};if(e&&(r.iconset={id:e}),t){r.params={};for(const e in t)t[e]&&(r.params[e]=t[e].serialize())}return Object.keys(r).length>0?r:void 0}serialize(){const t=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const e=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);e&&t.push(e)}if(this.nameSecondary&&(t.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const e=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);e&&t.push(e)}return t}}function se(t){return"string"==typeof(e=t)||e instanceof String?"string":ae(t)?"number":function(t){return"boolean"==typeof t||t instanceof Boolean}(t)?"boolean":Array.isArray(t)?"array":null===t?"null":function(t){return null!=t&&!Array.isArray(t)&&"function"!=typeof t&&!(t instanceof String||t instanceof Number||t instanceof Boolean)&&"object"==typeof t}(t)?"object":typeof t;var e}function ae(t){return"number"==typeof t||t instanceof Number}const le={"to-boolean":Nt,"to-color":jt,"to-number":Ot,"to-string":Ut};class Coercion{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0],n=[];let i=Rt;if("to-array"===r){if(!Array.isArray(t[1]))return null;const r=t[1].length;if(e.expectedType){if("array"!==e.expectedType.kind)return e.error(`Expected ${e.expectedType.kind} but found array.`);i=Zt(e.expectedType.itemType,r)}else{if(!(r>0&&re(t[1][0])))return null;i=Zt(ne(t[1][0]),r)}for(let o=0;o<r;o++){const r=t[1][o];let s;if(Array.isArray(r))s=e.parse(r,void 0,i.itemType);else{const t=se(r);if(t!==i.itemType.kind)return e.error(`Expected ${i.itemType.kind} but found ${t}.`);s=e.registry.literal.parse(["literal",void 0===r?null:r],e)}if(!s)return null;n.push(s)}}else{if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");i=le[r];for(let r=1;r<t.length;r++){const i=e.parse(t[r],r,$t);if(!i)return null;n.push(i)}}return new Coercion(i,n)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,r;for(const n of this.args){if(e=n.evaluate(t),r=null,e instanceof Color)return e;if("string"==typeof e){const r=t.parseColor(e);if(r)return r}else if(Array.isArray(e)&&(r=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:ee(e[0],e[1],e[2],e[3]),!r))return new Color(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new RuntimeError(r||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new RuntimeError(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Formatted.fromString(ie(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?ResolvedImage.build(ie(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):ie(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new 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 t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}const ue=["Unknown","Point","LineString","Polygon"];class EvaluationContext{constructor(t,e,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=t,this.options=e,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?ue[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Color.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class CompoundExpression{constructor(t,e,r,n,i){this.name=t,this.type=e,this._evaluate=r,this.args=n,this._overloadIndex=i}evaluate(t){if(!this._evaluate){const t=CompoundExpression.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1]}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const r=t[0],n=CompoundExpression.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=[];let a=null,l=-1;for(const[n,u]of o){if(Array.isArray(n)&&n.length!==t.length-1)continue;s.push(n),l++,a=new ParsingContext(e.registry,e.path,null,e.scope,void 0,e._scope,e.options,e.iconImageUseTheme);const o=[];let c=!1;for(let e=1;e<t.length;e++){const r=t[e],i=Array.isArray(n)?n[e-1]:n.type,s=a.parse(r,1+o.length,i);if(!s){c=!0;break}o.push(s)}if(!c)if(Array.isArray(n)&&n.length!==o.length)a.error(`Expected ${n.length} arguments, but found ${o.length} instead.`);else{for(let t=0;t<o.length;t++){const e=Array.isArray(n)?n[t]:n.type,r=o[t];a.concat(t+1).checkSubtype(e,r.type)}if(0===a.errors.length)return new CompoundExpression(r,i,u,o,l)}}if(1===s.length)e.errors.push(...a.errors);else{const r=(s.length?s:o.map((([t])=>t))).map(ce).join(" | "),n=[];for(let r=1;r<t.length;r++){const i=e.parse(t[r],1+n.length);if(!i)return null;n.push(Wt(i.type))}e.error(`Expected arguments of type ${r}, but found (${n.join(", ")}) instead.`)}return null}static register(t,e){CompoundExpression.definitions=e;for(const r in e)t[r]=CompoundExpression}}function ce(t){return Array.isArray(t)?`(${t.map(Wt).join(", ")})`:`(${Wt(t.type)}...)`}class CollatorExpression{constructor(t,e,r){this.type=qt,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=void 0===r["case-sensitive"]?e.parse(!1,1,Nt):e.parseObjectValue(r["case-sensitive"],1,"case-sensitive",Nt);if(!n)return null;const i=void 0===r["diacritic-sensitive"]?e.parse(!1,1,Nt):e.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",Nt);if(!i)return null;let o=null;return r.locale&&(o=e.parseObjectValue(r.locale,1,"locale",Ut),!o)?null:new CollatorExpression(n,i,o)}evaluate(t){return new Collator(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}function he(t,e,r=0,n=t.length-1,i=de){for(;n>r;){if(n-r>600){const o=n-r+1,s=e-r+1,a=Math.log(o),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);he(t,e,Math.max(r,Math.floor(e-s*l/o+u)),Math.min(n,Math.floor(e+(o-s)*l/o+u)),i)}const o=t[e];let s=r,a=n;for(pe(t,r,e),i(t[n],o)>0&&pe(t,r,n);s<a;){for(pe(t,s,a),s++,a--;i(t[s],o)<0;)s++;for(;i(t[a],o)>0;)a--}0===i(t[r],o)?pe(t,r,a):(a++,pe(t,a,n)),a<=e&&(r=a+1),e<=a&&(n=a-1)}}function pe(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function de(t,e){return t<e?-1:t>e?1:0}function fe(t){let e=0;for(let r,n,i=0,o=t.length,s=o-1;i<o;s=i++)r=t[i],n=t[s],e+=(n.x-r.x)*(r.y+n.y);return e}function ye(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function me(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function ge(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],o=t[0]-r[0],s=t[1]-r[1];return n*s-o*i==0&&n*o<=0&&i*s<=0}function xe(t,e,r=!1){let n=!1;for(let a=0,l=e.length;a<l;a++){const l=e[a];for(let e=0,a=l.length,u=a-1;e<a;u=e++){const a=l[u],c=l[e];if(ge(t,a,c))return r;(o=a)[1]>(i=t)[1]!=(s=c)[1]>i[1]&&i[0]<(s[0]-o[0])*(i[1]-o[1])/(s[1]-o[1])+o[0]&&(n=!n)}}var i,o,s;return n}function ve(t,e,r,n){const i=n[0]-r[0],o=n[1]-r[1],s=(t[0]-r[0])*o-i*(t[1]-r[1]),a=(e[0]-r[0])*o-i*(e[1]-r[1]);return s>0&&a<0||s<0&&a>0}function be(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(o=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*o[0]&&!(!ve(t,e,r,n)||!ve(r,n,t,e));var i,o}function we(t){const e=new ot(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new ot(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of t[0])e.x>n.x&&(e.x=n.x),e.y>n.y&&(e.y=n.y),r.x<n.x&&(r.x=n.x),r.y<n.y&&(r.y=n.y);return{min:e,max:r}}const _e=8192;function Ae(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return[Math.round(r*i*_e),Math.round(n*i*_e)]}function Se(t,e){for(let r=0;r<e.length;r++)if(xe(t,e[r]))return!0;return!1}function Ie(t,e,r){for(const n of r)for(let r=0,i=n.length,o=i-1;r<i;o=r++)if(be(t,e,n[o],n[r]))return!0;return!1}function Pe(t,e){for(let r=0;r<t.length;++r)if(!xe(t[r],e))return!1;for(let r=0;r<t.length-1;++r)if(Ie(t[r],t[r+1],e))return!1;return!0}function Me(t,e){for(let r=0;r<e.length;r++)if(Pe(t,e[r]))return!0;return!1}function De(t,e,r){const n=[];for(let i=0;i<t.length;i++){const o=[];for(let n=0;n<t[i].length;n++){const s=Ae(t[i][n],r);ye(e,s),o.push(s)}n.push(o)}return n}function Ee(t,e,r){const n=[];for(let i=0;i<t.length;i++){const o=De(t[i],e,r);n.push(o)}return n}function Ce(t,e,r,n){if(t[0]<r[0]||t[0]>r[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i}ye(e,t)}function Be(t,e,r,n){const i=Math.pow(2,n.z)*_e,o=[n.x*_e,n.y*_e],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+o[0],t.y+o[1]];Ce(n,e,r,i),s.push(n)}return s}function Te(t,e,r,n){const i=Math.pow(2,n.z)*_e,o=[n.x*_e,n.y*_e],s=[];if(!t)return s;for(const r of t){const t=[];for(const n of r){const r=[n.x+o[0],n.y+o[1]];ye(e,r),t.push(r)}s.push(t)}if(e[2]-e[0]<=i/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of s)for(const n of t)Ce(n,e,r,i)}var a;return s}class Within{constructor(t,e){this.type=Nt,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(re(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const r=e.features[t].geometry.type;if("Polygon"===r||"MultiPolygon"===r)return new Within(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Within(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Within(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return!1;if("Polygon"===e.type){const o=De(e.coordinates,n,i),s=Be(t.geometry(),r,n,i);if(!me(r,n))return!1;for(const t of s)if(!xe(t,o))return!1}if("MultiPolygon"===e.type){const o=Ee(e.coordinates,n,i),s=Be(t.geometry(),r,n,i);if(!me(r,n))return!1;for(const t of s)if(!Se(t,o))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return!1;if("Polygon"===e.type){const o=De(e.coordinates,n,i),s=Te(t.geometry(),r,n,i);if(!me(r,n))return!1;for(const t of s)if(!Pe(t,o))return!1}if("MultiPolygon"===e.type){const o=Ee(e.coordinates,n,i),s=Te(t.geometry(),r,n,i);if(!me(r,n))return!1;for(const t of s)if(!Me(t,o))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}const ke={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},ze=1/298.257223563,Le=ze*(2-ze),Ve=Math.PI/180;class CheapRuler{static fromTile(t,e,r){const n=Math.PI*(1-2*(t+.5)/Math.pow(2,e)),i=Math.atan(.5*(Math.exp(n)-Math.exp(-n)))/Ve;return new CheapRuler(i,r)}static get units(){return ke}constructor(t,e){if(void 0===t)throw new Error("No latitude given.");if(e&&!ke[e])throw new Error(`Unknown unit ${e}. Use one of: ${Object.keys(ke).join(", ")}`);const r=6378.137*Ve*(e?ke[e]:1),n=Math.cos(t*Ve),i=1/(1-Le*(1-n*n)),o=Math.sqrt(i);this.kx=r*o*n,this.ky=r*o*i*(1-Le)}distance(t,e){const r=Oe(t[0]-e[0])*this.kx,n=(t[1]-e[1])*this.ky;return Math.sqrt(r*r+n*n)}bearing(t,e){const r=Oe(e[0]-t[0])*this.kx;return Math.atan2(r,(e[1]-t[1])*this.ky)/Ve}destination(t,e,r){const n=r*Ve;return this.offset(t,Math.sin(n)*e,Math.cos(n)*e)}offset(t,e,r){return[t[0]+e/this.kx,t[1]+r/this.ky]}lineDistance(t){let e=0;for(let r=0;r<t.length-1;r++)e+=this.distance(t[r],t[r+1]);return e}area(t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];for(let t=0,i=n.length,o=i-1;t<i;o=t++)e+=Oe(n[t][0]-n[o][0])*(n[t][1]+n[o][1])*(r?-1:1)}return Math.abs(e)/2*this.kx*this.ky}along(t,e){let r=0;if(e<=0)return t[0];for(let n=0;n<t.length-1;n++){const i=t[n],o=t[n+1],s=this.distance(i,o);if(r+=s,r>e)return Re(i,o,(e-(r-s))/s)}return t[t.length-1]}pointToSegmentDistance(t,e,r){let[n,i]=e,o=Oe(r[0]-n)*this.kx,s=(r[1]-i)*this.ky;if(0!==o||0!==s){const e=(Oe(t[0]-n)*this.kx*o+(t[1]-i)*this.ky*s)/(o*o+s*s);e>1?(n=r[0],i=r[1]):e>0&&(n+=o/this.kx*e,i+=s/this.ky*e)}return o=Oe(t[0]-n)*this.kx,s=(t[1]-i)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(t,e){let r=1/0,n=t[0][0],i=t[0][1],o=0,s=0;for(let a=0;a<t.length-1;a++){let l=t[a][0],u=t[a][1],c=Oe(t[a+1][0]-l)*this.kx,h=(t[a+1][1]-u)*this.ky,p=0;0===c&&0===h||(p=(Oe(e[0]-l)*this.kx*c+(e[1]-u)*this.ky*h)/(c*c+h*h),p>1?(l=t[a+1][0],u=t[a+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=Oe(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const d=c*c+h*h;d<r&&(r=d,n=l,i=u,o=a,s=p)}return{point:[n,i],index:o,t:Math.max(0,Math.min(1,s))}}lineSlice(t,e,r){let n=this.pointOnLine(r,t),i=this.pointOnLine(r,e);if(n.index>i.index||n.index===i.index&&n.t>i.t){const t=n;n=i,i=t}const o=[n.point],s=n.index+1,a=i.index;!Fe(r[s],o[0])&&s<=a&&o.push(r[s]);for(let t=s+1;t<=a;t++)o.push(r[t]);return Fe(r[a],i.point)||o.push(i.point),o}lineSliceAlong(t,e,r){let n=0;const i=[];for(let o=0;o<r.length-1;o++){const s=r[o],a=r[o+1],l=this.distance(s,a);if(n+=l,n>t&&0===i.length&&i.push(Re(s,a,(t-(n-l))/l)),n>=e)return i.push(Re(s,a,(e-(n-l))/l)),i;n>t&&i.push(a)}return i}bufferPoint(t,e){const r=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-r,t[0]+n,t[1]+r]}bufferBBox(t,e){const r=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-r,t[2]+n,t[3]+r]}insideBBox(t,e){return Oe(t[0]-e[0])>=0&&Oe(t[0]-e[2])<=0&&t[1]>=e[1]&&t[1]<=e[3]}}function Fe(t,e){return t[0]===e[0]&&t[1]===e[1]}function Re(t,e,r){const n=Oe(e[0]-t[0]);return[t[0]+n*r,t[1]+(e[1]-t[1])*r]}function Oe(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}class TinyQueue{constructor(t=[],e=((t,e)=>t<e?-1:t>e?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(r(n,o)>=0)break;e[t]=o,t=i}e[t]=n}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t<n;){let n=1+(t<<1);const o=n+1;if(o<this.length&&r(e[o],e[n])<0&&(n=o),r(e[n],i)>=0)break;e[t]=e[n],t=n}e[t]=i}}var Ue=8192;function Ne(t,e){return e.dist-t.dist}const je=100,Ge=50;function $e(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function qe(t){return t[1]-t[0]+1}function He(t,e){const r=t[1]>=t[0]&&t[1]<e;return r||console.warn("Distance Expression: Index is out of range"),r}function Xe(t,e){if(t[0]>t[1])return[null,null];const r=qe(t);if(e){if(2===r)return[t,null];const e=Math.floor(r/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===r)return[t,null];const e=Math.floor(r/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function Ze(t,e){const r=[1/0,1/0,-1/0,-1/0];if(!He(e,t.length))return r;for(let n=e[0];n<=e[1];++n)ye(r,t[n]);return r}function We(t){const e=[1/0,1/0,-1/0,-1/0];for(let r=0;r<t.length;++r)for(let n=0;n<t[r].length;++n)ye(e,t[r][n]);return e}function Ye(t,e,r){if($e(t)||$e(e))return NaN;let n=0,i=0;return t[2]<e[0]&&(n=e[0]-t[2]),t[0]>e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]<e[1]&&(i=e[1]-t[3]),r.distance([0,0],[n,i])}function Je(t){return 360*t-180}function Ke(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Qe(t,e){const r=Math.pow(2,e.z),n=(t.y/Ue+e.y)/r;return[Je((t.x/Ue+e.x)/r),Ke(n)]}function tr(t,e){const r=[];for(let n=0;n<t.length;++n)r.push(Qe(t[n],e));return r}function er(t,e,r){const n=r.pointOnLine(e,t).point;return r.distance(t,n)}function rr(t,e,r,n,i){const o=r.slice(n[0],n[1]+1);let s=1/0;for(let r=e[0];r<=e[1];++r)if(0===(s=Math.min(s,er(t[r],o,i))))return 0;return s}function nr(t,e,r,n,i){const o=Math.min(i.pointToSegmentDistance(t,r,n),i.pointToSegmentDistance(e,r,n)),s=Math.min(i.pointToSegmentDistance(r,t,e),i.pointToSegmentDistance(n,t,e));return Math.min(o,s)}function ir(t,e,r,n,i){if(!He(e,t.length)||!He(n,r.length))return NaN;let o=1/0;for(let s=e[0];s<e[1];++s)for(let e=n[0];e<n[1];++e){if(be(t[s],t[s+1],r[e],r[e+1]))return 0;o=Math.min(o,nr(t[s],t[s+1],r[e],r[e+1],i))}return o}function or(t,e,r,n,i){if(!He(e,t.length)||!He(n,r.length))return NaN;let o=1/0;for(let s=e[0];s<=e[1];++s)for(let e=n[0];e<=n[1];++e)if(0===(o=Math.min(o,i.distance(t[s],r[e]))))return o;return o}function sr(t,e,r){if(xe(t,e,!0))return 0;let n=1/0;for(const i of e){const e=i.length;if(e<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(i[0]!==i[e-1]&&0===(n=Math.min(n,r.pointToSegmentDistance(t,i[e-1],i[0]))))return n;if(0===(n=Math.min(n,er(t,i,r))))return n}return n}function ar(t,e,r,n){if(!He(e,t.length))return NaN;for(let n=e[0];n<=e[1];++n)if(xe(t[n],r,!0))return 0;let i=1/0;for(let o=e[0];o<e[1];++o)for(const e of r)for(let r=0,s=e.length,a=s-1;r<s;a=r++){if(be(t[o],t[o+1],e[a],e[r]))return 0;i=Math.min(i,nr(t[o],t[o+1],e[a],e[r],n))}return i}function lr(t,e){for(const r of t)for(let t=0;t<=r.length-1;++t)if(xe(r[t],e,!0))return!0;return!1}function ur(t,e,r,n=1/0){const i=We(t),o=We(e);if(n!==1/0&&Ye(i,o,r)>=n)return n;if(me(i,o)){if(lr(t,e))return 0}else if(lr(e,t))return 0;let s=n;for(const n of t)for(let t=0,i=n.length,o=i-1;t<i;o=t++)for(const i of e)for(let e=0,a=i.length,l=a-1;e<a;l=e++){if(be(n[o],n[t],i[l],i[e]))return 0;s=Math.min(s,nr(n[o],n[t],i[l],i[e],r))}return s}function cr(t,e,r,n,i,o,s){if(null===o||null===s)return;const a=Ye(Ze(n,o),Ze(i,s),r);a<e&&t.push({dist:a,range1:o,range2:s})}function hr(t,e,r,n,i=1/0){let o=Math.min(n.distance(t[0],r[0][0]),i);if(0===o)return o;const s=new TinyQueue([{dist:0,range1:[0,t.length-1],range2:[0,0]}],Ne),a=e?Ge:je,l=We(r);for(;s.length;){const i=s.pop();if(i.dist>=o)continue;const u=i.range1;if(qe(u)<=a){if(!He(u,t.length))return NaN;if(e){const e=ar(t,u,r,n);if(0===(o=Math.min(o,e)))return o}else for(let e=u[0];e<=u[1];++e){const i=sr(t[e],r,n);if(0===(o=Math.min(o,i)))return o}}else{const r=Xe(u,e);if(null!==r[0]){const e=Ye(Ze(t,r[0]),l,n);e<o&&s.push({dist:e,range1:r[0],range2:[0,0]})}if(null!==r[1]){const e=Ye(Ze(t,r[1]),l,n);e<o&&s.push({dist:e,range1:r[1],range2:[0,0]})}}}return o}function pr(t,e,r,n,i,o=1/0){let s=Math.min(o,i.distance(t[0],r[0]));if(0===s)return s;const a=new TinyQueue([{dist:0,range1:[0,t.length-1],range2:[0,r.length-1]}],Ne),l=e?Ge:je,u=n?Ge:je;for(;a.length;){const o=a.pop();if(o.dist>=s)continue;const c=o.range1,h=o.range2;if(qe(c)<=l&&qe(h)<=u){if(!He(c,t.length)||!He(h,r.length))return NaN;if(e&&n?s=Math.min(s,ir(t,c,r,h,i)):e||n?e&&!n?s=Math.min(s,rr(r,h,t,c,i)):!e&&n&&(s=Math.min(s,rr(t,c,r,h,i))):s=Math.min(s,or(t,c,r,h,i)),0===s)return s}else{const o=Xe(c,e),l=Xe(h,n);cr(a,s,i,t,r,o[0],l[0]),cr(a,s,i,t,r,o[0],l[1]),cr(a,s,i,t,r,o[1],l[0]),cr(a,s,i,t,r,o[1],l[1])}}return s}function dr(t,e,r,n,i=1/0){let o=i;const s=Ze(t,[0,t.length-1]);for(const i of r)if(!(o!==1/0&&Ye(s,Ze(i,[0,i.length-1]),n)>=o)&&(o=Math.min(o,pr(t,e,i,!0,n,o)),0===o))return o;return o}function fr(t,e,r,n,i=1/0){let o=i;const s=Ze(t,[0,t.length-1]);for(const i of r){if(o!==1/0&&Ye(s,We(i),n)>=o)continue;const r=hr(t,e,i,n,o);if(isNaN(r))return r;if(0===(o=Math.min(o,r)))return o}return o}function yr(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Distance{constructor(t,e){this.type=Ot,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(re(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;t<e.features.length;++t)if(yr(e.features[t].geometry.type))return new Distance(e,e.features[t].geometry)}else if("Feature"===e.type){if(yr(e.geometry.type))return new Distance(e,e.geometry)}else if(yr(e.type))return new Distance(e,e)}return e.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(t){const e=t.geometry(),r=t.canonicalID();if(null!=e&&null!=r){if("Point"===t.geometryType())return function(t,e,r){const n=[];for(const r of t)for(const t of r)n.push(Qe(t,e));const i=new CheapRuler(n[0][1],"meters");return"Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type?pr(n,!1,"Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,i):"MultiLineString"===r.type?dr(n,!1,r.coordinates,i):"Polygon"===r.type||"MultiPolygon"===r.type?fr(n,!1,"Polygon"===r.type?[r.coordinates]:r.coordinates,i):null}(e,r,this.geometries);if("LineString"===t.geometryType())return function(t,e,r){const n=[];for(const r of t){const t=[];for(const n of r)t.push(Qe(n,e));n.push(t)}const i=new CheapRuler(n[0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return dr("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,n,i);if("MultiLineString"===r.type){let t=1/0;for(let e=0;e<r.coordinates.length;e++){const o=dr(r.coordinates[e],!0,n,i,t);if(isNaN(o))return o;if(0===(t=Math.min(t,o)))return t}return t}if("Polygon"===r.type||"MultiPolygon"===r.type){let t=1/0;for(let e=0;e<n.length;e++){const o=fr(n[e],!0,"Polygon"===r.type?[r.coordinates]:r.coordinates,i,t);if(isNaN(o))return o;if(0===(t=Math.min(t,o)))return t}return t}return null}(e,r,this.geometries);if("Polygon"===t.geometryType())return function(t,e,r){const n=[];for(const r of function(t,e){const r=t.length;if(r<=1)return[t];const n=[];let i,o;for(let e=0;e<r;e++){const r=fe(t[e]);0!==r&&(t[e].area=Math.abs(r),void 0===o&&(o=r<0),o===r<0?(i&&n.push(i),i=[t[e]]):i.push(t[e]))}return i&&n.push(i),n}(t)){const t=[];for(let n=0;n<r.length;++n)t.push(tr(r[n],e));n.push(t)}const i=new CheapRuler(n[0][0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return fr("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,n,i);if("MultiLineString"===r.type){let t=1/0;for(let e=0;e<r.coordinates.length;e++){const o=fr(r.coordinates[e],!0,n,i,t);if(isNaN(o))return o;if(0===(t=Math.min(t,o)))return t}return t}return"Polygon"===r.type||"MultiPolygon"===r.type?function(t,e,r){let n=1/0;for(const i of t)for(const t of e){const e=ur(i,t,r,n);if(isNaN(e))return e;if(0===(n=Math.min(n,e)))return n}return n}("Polygon"===r.type?[r.coordinates]:r.coordinates,n,i):null}(e,r,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requirs valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}function mr(t){if(t instanceof CompoundExpression){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Within)return!1;if(t instanceof Distance)return!1;if(t instanceof Config)return t.featureConstant;let e=!0;return t.eachChild((t=>{e&&!mr(t)&&(e=!1)})),e}function gr(t){if(t instanceof CompoundExpression&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!gr(t)&&(e=!1)})),e}function xr(t,e){if(t instanceof CompoundExpression&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild((t=>{r&&!xr(t,e)&&(r=!1)})),r}function vr(t,e,r){return[t,e,r].filter(Boolean).join("")}function br(t,e){switch(t){case"string":return ie(e);case"number":return+e;case"boolean":return!!e;case"color":return Color.parse(e);case"formatted":return Formatted.fromString(ie(e));case"resolvedImage":return ResolvedImage.build(ie(e))}return e}function wr(t,e,r,n){return void 0!==n&&(t=n*Math.round(t/n)),void 0!==e&&t<e&&(t=e),void 0!==r&&t>r&&(t=r),t}class Config{constructor(t,e,r,n=!1){this.type=t,this.key=e,this.scope=r,this.featureConstant=n}static parse(t,e){let r=e.expectedType;if(null==r&&(r=$t),t.length<2||t.length>3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof Literal))return e.error("Key name of 'config' expression must be a string literal.");let i,o=!0;const s=ie(n.value);if(t.length>=3){const r=e.parse(t[2],2);if(!(r instanceof Literal))return e.error("Scope of 'config' expression must be a string literal.");i=ie(r.value)}if(e.options){const t=vr(s,i,e._scope),r=e.options.get(t);r&&(o=mr(r.value||r.default))}return new Config(r,s,i,o)}evaluate(t){const e=vr(this.key,this.scope,t.scope),r=t.getConfig(e);if(!r)return null;const{type:n,value:i,values:o,minValue:s,maxValue:a,stepValue:l}=r,u=r.default.evaluate(t);let c=u;if(i){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),c=i.evaluate(t),t.scope=e}return n&&(c=br(n,c)),void 0===c||void 0===s&&void 0===a&&void 0===l||("number"==typeof c?c=wr(c,s,a,l):Array.isArray(c)&&(c=c.map((t=>"number"==typeof t?wr(t,s,a,l):t)))),void 0!==i&&void 0!==c&&o&&!o.includes(c)&&(c=u,n&&(c=br(n,c))),(n&&n!==this.type||void 0!==c&&!te(ne(c),this.type))&&(c=br(this.type.kind,c)),c}eachChild(){}outputDefined(){return!1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.scope),t}}class Var{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const r=t[1];return e.scope.has(r)?new Var(r,e.scope.get(r)):e.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class ParsingContext{constructor(t,e=[],r,n=new Scope,i=[],o,s,a){this.registry=t,this.path=e,this.key=e.map((t=>"string"==typeof t?`['${t}']`:`[${t}]`)).join(""),this.scope=n,this.errors=i,this.expectedType=r,this._scope=o,this.options=s,this.iconImageUseTheme=a}parse(t,e,r,n,i={}){return e||r?this.concat(e,null,r,n)._parse(t,i):this._parse(t,i)}parseObjectValue(t,e,r,n,i,o={}){return this.concat(e,r,n,i)._parse(t,o)}_parse(t,e){function r(t,e,r){return"assert"===r?new Assertion(e,[t]):"coerce"===r?new Coercion(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let i=n.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,n=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else i=r(i,t,e.typeAnnotation||"coerce");else i=r(i,t,e.typeAnnotation||"assert")}if(!(i instanceof Literal)&&"resolvedImage"!==i.type.kind&&_r(i)){const t=new EvaluationContext(this._scope,this.options,this.iconImageUseTheme);try{i=new Literal(i.type,i.evaluate(t))}catch(t){return this.error(t.message),null}}return i}return Coercion.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r,n){let i="number"==typeof t?this.path.concat(t):this.path;i="string"==typeof e?i.concat(e):i;const o=n?this.scope.concat(n):this.scope;return new ParsingContext(this.registry,i,r||null,o,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new ParsingError(r,t))}checkSubtype(t,e){const r=Jt(t,e);return r&&this.error(r),r}}function _r(t){if(t instanceof Var)return _r(t.boundExpression);if(t instanceof CompoundExpression&&"error"===t.name)return!1;if(t instanceof CollatorExpression)return!1;if(t instanceof Within)return!1;if(t instanceof Distance)return!1;if(t instanceof Config)return!1;const e=t instanceof Coercion||t instanceof Assertion;let r=!0;return t.eachChild((t=>{r=e?r&&_r(t):r&&t instanceof Literal})),!!r&&mr(t)&&xr(t,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Ar(t,e){const r=t.length-1;let n,i,o=0,s=r,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=t[a],i=t[a+1],n<=e){if(a===r||e<i)return a;o=a+1}else{if(!(n>e))throw new RuntimeError("Input is not a number.");s=a-1}return 0}class Step{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,Ot);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r<t.length;r+=2){const o=1===r?-1/0:t[r],s=t[r+1],a=r,l=r+1;if("number"!=typeof o)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(n.length&&n[n.length-1][0]>=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const u=e.parse(s,l,i);if(!u)return null;i=i||u.type,n.push([o,u])}return new Step(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[Ar(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const Sr=.95047,Ir=1.08883,Pr=4/29,Mr=6/29,Dr=3*Mr*Mr,Er=Mr*Mr*Mr,Cr=Math.PI/180,Br=180/Math.PI;function Tr(t){return t>Er?Math.pow(t,1/3):t/Dr+Pr}function kr(t){return t>Mr?t*t*t:Dr*(t-Pr)}function zr(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Lr(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Vr(t){const e=Lr(t.r),r=Lr(t.g),n=Lr(t.b),i=Tr((.4124564*e+.3575761*r+.1804375*n)/Sr),o=Tr((.2126729*e+.7151522*r+.072175*n)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-Tr((.0193339*e+.119192*r+.9503041*n)/Ir)),alpha:t.a}}function Fr(t){let e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*kr(e),r=Sr*kr(r),n=Ir*kr(n),new Color(zr(3.2404542*r-1.5371385*e-.4985314*n),zr(-.969266*r+1.8760108*e+.041556*n),zr(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}function Rr(t,e,r){const n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}const Or={forward:Vr,reverse:Fr,interpolate:function(t,e,r){return{l:Vt(t.l,e.l,r),a:Vt(t.a,e.a,r),b:Vt(t.b,e.b,r),alpha:Vt(t.alpha,e.alpha,r)}}},Ur={forward:function(t){const{l:e,a:r,b:n}=Vr(t),i=Math.atan2(n,r)*Br;return{h:i<0?i+360:i,c:Math.sqrt(r*r+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Cr,r=t.c;return Fr({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return{h:Rr(t.h,e.h,r),c:Vt(t.c,e.c,r),l:Vt(t.l,e.l,r),alpha:Vt(t.alpha,e.alpha,r)}}};var Nr=Object.freeze({__proto__:null,hcl:Ur,lab:Or});class Interpolate{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=jr(e,t.base,r,n);else if("linear"===t.name)i=jr(e,1,r,n);else if("cubic-bezier"===t.name){const o=t.controlPoints;i=new it(o[0],o[1],o[2],o[3]).solve(jr(e,1,r,n))}return i}static parse(t,e){let[r,n,i,...o]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t}}else{if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length-1>3&&(t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,Ot),!i)return null;const s=[];let a=null;"interpolate-hcl"===r||"interpolate-lab"===r?a=jt:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t<o.length;t+=2){const r=o[t],n=o[t+1],i=t+3,l=t+4;if("number"!=typeof r)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',i);if(s.length&&s[s.length-1][0]>=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,a);if(!u)return null;a=a||u.type,s.push([r,u])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Interpolate(a,r,n,i,s):e.error(`Type ${Wt(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const o=Ar(e,n),s=Interpolate.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=r[o].evaluate(t),l=r[o+1].evaluate(t);return"interpolate"===this.operator?Ft[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Ur.reverse(Ur.interpolate(Ur.forward(a),Ur.forward(l),s)):Or.reverse(Or.interpolate(Or.forward(a),Or.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const e=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)e.push(this.labels[t],this.outputs[t].serialize());return e}}function jr(t,e,r,n){const i=n-r,o=t-r;return 0===i?0:1===e?o/i:(Math.pow(e,o)-1)/(Math.pow(e,i)-1)}class Coalesce{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t)}const o=n&&i.some((t=>Jt(n,t.type)));return new Coalesce(o?$t:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args){if(n++,r=i.evaluate(t),r&&r instanceof ResolvedImage&&!r.available&&(e||(e=r),r=null,n===this.args.length))return e;if(null!==r)break}return r}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class Let{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n<t.length-1;n+=2){const i=t[n];if("string"!=typeof i)return e.error(`Expected string, but found ${typeof i} instead.`,n);if(/[^a-zA-Z0-9_]/.test(i))return e.error("Variable names must contain only alphanumeric characters or '_'.",n);const o=e.parse(t[n+1],n+1);if(!o)return null;r.push([i,o])}const n=e.parse(t[t.length-1],t.length-1,e.expectedType,r);return n?new Let(r,n):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[e,r]of this.bindings)t.push(e,r.serialize());return t.push(this.result.serialize()),t}}class At{constructor(t,e,r){this.type=t,this.index=e,this.input=r}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Ot),n=e.parse(t[2],2,Zt(e.expectedType||$t));return r&&n?new At(n.type.itemType,r,n):null}evaluate(t){const e=this.index.evaluate(t),r=this.input.evaluate(t);if(e<0)throw new RuntimeError("Array index out of bounds: negative index");if(e>=r.length)throw new RuntimeError("Array index out of bounds: index exceeds array size");if(e!==Math.floor(e))throw new RuntimeError("Array index must be an integer. Use at-interpolated for fractional indices");return r[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class AtInterpolated{constructor(t,e,r){this.type=t,this.index=e,this.input=r}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Ot),n=e.parse(t[2],2,Zt(e.expectedType||$t));return r&&n?new AtInterpolated(n.type.itemType,r,n):null}evaluate(t){const e=this.index.evaluate(t),r=this.input.evaluate(t);if(e<0)throw new RuntimeError(`Array index out of bounds: ${e} < 0.`);if(e>r.length-1)throw new RuntimeError(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e===Math.floor(e))return r[e];const n=Math.floor(e),i=Math.ceil(e),o=r[n],s=r[i];if("number"!=typeof o||"number"!=typeof s)throw new RuntimeError(`Cannot interpolate between non-number values at index ${e}.`);const a=e-n;return o*(1-a)+s*a}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class In{constructor(t,e){this.type=Nt,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,$t),n=e.parse(t[2],2,$t);return r&&n?Kt(r.type,[Nt,Ut,Ot,Rt,$t])?new In(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Wt(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(null==r)return!1;if(!Qt(e,["boolean","string","number","null"]))throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${Wt(ne(e))} instead.`);if(!Qt(r,["string","array"]))throw new RuntimeError(`Expected second argument to be of type array or string, but found ${Wt(ne(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class IndexOf{constructor(t,e,r){this.type=Ot,this.needle=t,this.haystack=e,this.fromIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,$t),n=e.parse(t[2],2,$t);if(!r||!n)return null;if(!Kt(r.type,[Nt,Ut,Ot,Rt,$t]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Wt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Ot);return i?new IndexOf(r,n,i):null}return new IndexOf(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Qt(e,["boolean","string","number","null"]))throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${Wt(ne(e))} instead.`);if(!Qt(r,["string","array"]))throw new RuntimeError(`Expected second argument to be of type array or string, but found ${Wt(ne(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return r.indexOf(e,n)}return r.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Match{constructor(t,e,r,n,i,o){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=o}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},o=[];for(let s=2;s<t.length-1;s+=2){let a=t[s];const l=t[s+1];Array.isArray(a)||(a=[a]);const u=e.concat(s);if(0===a.length)return u.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return u.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,ne(t)))return null}else r=ne(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=o.length}const c=e.parse(l,s,n);if(!c)return null;n=n||c.type,o.push(c)}const s=e.parse(t[1],1,$t);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(r,s.type)?null:new Match(r,n,s,i,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(te(ne(e),this.inputType)&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),r=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=r.length,r.push([this.cases[t],[t]])):r[e][1].push(t)}const i=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of r)t.push(1===n.length?i(n[0]):n.map(i)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class Case{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;i<t.length-1;i+=2){const o=e.parse(t[i],i,Nt);if(!o)return null;const s=e.parse(t[i+1],i+1,r);if(!s)return null;n.push([o,s]),r=r||s.type}const i=e.parse(t[t.length-1],t.length-1,r);return i?new Case(r,n,i):null}evaluate(t){for(const[e,r]of this.branches)if(e.evaluate(t))return r.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,r]of this.branches)t(e),t(r);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}class Slice{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,$t),n=e.parse(t[2],2,Ot);if(!r||!n)return null;if(!Kt(r.type,[Zt($t),Ut,$t]))return e.error(`Expected first argument to be of type array or string, but found ${Wt(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Ot);return i?new Slice(r.type,r,n,i):null}return new Slice(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!Qt(e,["string","array"]))throw new RuntimeError(`Expected first argument to be of type array or string, but found ${Wt(ne(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(r,n)}return e.slice(r)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class Split{constructor(t,e){this.type=Zt(Ut),this.str=t,this.delimiter=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Ut),n=e.parse(t[2],2,Ut);return r&&n?new Split(r,n):void 0}evaluate(t){const e=this.str.evaluate(t),r=this.delimiter.evaluate(t);return e.split(r)}eachChild(t){t(this.str),t(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function Gr(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function $r(t,e,r,n){return 0===n.compare(e,r)}function qr(t,e,r){const n="=="!==t&&"!="!==t;return class Comparison{constructor(t,e,r){this.type=Nt,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let i=e.parse(t[1],1,$t);if(!i)return null;if(!Gr(r,i.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${Wt(i.type)}'.`);let o=e.parse(t[2],2,$t);if(!o)return null;if(!Gr(r,o.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${Wt(o.type)}'.`);if(i.type.kind!==o.type.kind&&"value"!==i.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${Wt(i.type)}' and '${Wt(o.type)}'.`);n&&("value"===i.type.kind&&"value"!==o.type.kind?i=new Assertion(o.type,[i]):"value"!==i.type.kind&&"value"===o.type.kind&&(o=new Assertion(i.type,[o])));let s=null;if(4===t.length){if("string"!==i.type.kind&&"string"!==o.type.kind&&"value"!==i.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(s=e.parse(t[3],3,qt),!s)return null}return new Comparison(i,o,s)}evaluate(i){const o=this.lhs.evaluate(i),s=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=ne(o),r=ne(s);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new RuntimeError(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=ne(o),r=ne(s);if("string"!==t.kind||"string"!==r.kind)return e(i,o,s)}return this.collator?r(i,o,s,this.collator.evaluate(i)):e(i,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const Hr=qr("==",(function(t,e,r){return e===r}),$r),Xr=qr("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return!$r(0,e,r,n)})),Zr=qr("<",(function(t,e,r){return e<r}),(function(t,e,r,n){return n.compare(e,r)<0})),Wr=qr(">",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),Yr=qr("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),Jr=qr(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class NumberFormat{constructor(t,e,r,n,i,o){this.type=Ut,this.number=t,this.locale=e,this.currency=r,this.unit=n,this.minFractionDigits=i,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Ot);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parseObjectValue(n.locale,2,"locale",Ut),!i))return null;let o=null;if(n.currency&&(o=e.parseObjectValue(n.currency,2,"currency",Ut),!o))return null;let s=null;if(n.unit&&(s=e.parseObjectValue(n.unit,2,"unit",Ut),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",Ot),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",Ot),!l)?null:new NumberFormat(r,i,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Length{constructor(t){this.type=Ot,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${Wt(r.type)} instead.`):new Length(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new RuntimeError(`Expected value to be of type string or array, but found ${Wt(ne(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Kr={"==":Hr,"!=":Xr,">":Wr,"<":Zr,">=":Jr,"<=":Yr,array:Assertion,at:At,"at-interpolated":AtInterpolated,boolean:Assertion,case:Case,coalesce:Coalesce,collator:CollatorExpression,format:FormatExpression,image:ImageExpression,in:In,"index-of":IndexOf,interpolate:Interpolate,"interpolate-hcl":Interpolate,"interpolate-lab":Interpolate,length:Length,let:Let,literal:Literal,match:Match,number:Assertion,"number-format":NumberFormat,object:Assertion,slice:Slice,step:Step,string:Assertion,"to-boolean":Coercion,"to-color":Coercion,"to-number":Coercion,"to-string":Coercion,var:Var,within:Within,distance:Distance,config:Config,split:Split};function Qr(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const o=i?i.evaluate(t):1,s=ee(e,r,n,o);if(s)throw new RuntimeError(s);return new Color(e/255,r/255,n/255,o)}function tn(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const o=i?i.evaluate(t):1,s=function(t,e,r,n){return"number"==typeof t&&t>=0&&t<=360?"number"==typeof e&&e>=0&&e<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'h' must be between 0 and 360.`}(e,r,n,o);if(s)throw new RuntimeError(s);const a=`hsla(${e}, ${r}%, ${n}%, ${o})`,l=Color.parse(a);if(!l)throw new RuntimeError(`Failed to parse HSLA color: ${a}`);return l}function en(t,e){return t in e}function rn(t,e){const r=e[t];return void 0===r?null:r}function nn(t){return{type:t}}function on(t){if(t instanceof Config)return new Set([t.key]);let e=new Set;return t.eachChild((t=>{e=new Set([...e,...on(t)])})),e}function sn(t){if(t instanceof CompoundExpression&&"is-active-floor"===t.name)return!0;let e=!1;return t.eachChild((t=>{!e&&sn(t)&&(e=!0)})),e}function an(t){return{result:"success",value:t}}function ln(t){return{result:"error",value:t}}function un(t,e){return!!t&&!!t.parameters&&t.parameters.indexOf(e)>-1}function cn(t){return"data-driven"===t["property-type"]}function hn(t){return!!t.expression&&t.expression.interpolated}function pn(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function dn(t){return t}function fn(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),o=t.type||(hn(e)?"exponential":"interval");if(r&&((t=Object.assign({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Color.parse(t[1])]))),t.default=Color.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Nr[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=xn;else if("interval"===o)s=gn;else if("categorical"===o){s=mn,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=vn}if(n){const r={},n=[];for(let e=0;e<t.stops.length;e++){const i=t.stops[e],o=i[0].zoom;void 0===r[o]&&(r[o]={zoom:o,type:t.type,property:t.property,default:t.default,stops:[]},n.push(o)),r[o].stops.push([i[0].value,i[1]])}const i=[];for(const t of n)i.push([r[t].zoom,fn(r[t],e)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:Interpolate.interpolationFactor.bind(void 0,o),zoomStops:i.map((t=>t[0])),evaluate:({zoom:r},n)=>xn({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:r,interpolationFactor:Interpolate.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>s(t,e,r,a,l)}}return{kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?yn(t.default,e.default):s(t,e,i,a,l)}}}function yn(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function mn(t,e,r,n,i){return yn(typeof r===i?n[r]:void 0,t.default,e.default)}function gn(t,e,r){if(!ae(r))return yn(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=Ar(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function xn(t,e,r){const n=void 0!==t.base?t.base:1;if(!ae(r))return yn(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const o=Ar(t.stops.map((t=>t[0])),r),s=function(t,e,r,n){const i=n-r,o=t-r;return 0===i?0:1===e?o/i:(Math.pow(e,o)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let u=Ft[e.type]||dn;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=Nr[t.colorSpace];u=(t,r)=>e.reverse(e.interpolate(e.forward(t),e.forward(r),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==r)return u(e,r,s)}}:u(a,l,s)}function vn(t,e,r){return"color"===e.type?r=Color.parse(r):"formatted"===e.type?r=Formatted.fromString(r.toString()):"resolvedImage"===e.type?r=ResolvedImage.build(r.toString()):se(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0),yn(r,t.default,e.default)}CompoundExpression.register(Kr,{error:[{kind:"error"},[Ut],(t,[e])=>{throw new RuntimeError(e.evaluate(t))}],typeof:[Ut,[$t],(t,[e])=>Wt(ne(e.evaluate(t)))],"to-rgba":[Zt(Ot,4),[jt],(t,[e])=>e.evaluate(t).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Zt(Ot,4),[jt],(t,[e])=>e.evaluate(t).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[jt,[Ot,Ot,Ot],Qr],rgba:[jt,[Ot,Ot,Ot,Ot],Qr],hsl:[jt,[Ot,Ot,Ot],tn],hsla:[jt,[Ot,Ot,Ot,Ot],tn],has:{type:Nt,overloads:[[[Ut],(t,[e])=>en(e.evaluate(t),t.properties())],[[Ut,Gt],(t,[e,r])=>en(e.evaluate(t),r.evaluate(t))]]},get:{type:$t,overloads:[[[Ut],(t,[e])=>rn(e.evaluate(t),t.properties())],[[Ut,Gt],(t,[e,r])=>rn(e.evaluate(t),r.evaluate(t))]]},"feature-state":[$t,[Ut],(t,[e])=>rn(e.evaluate(t),t.featureState||{})],properties:[Gt,[],t=>t.properties()],"geometry-type":[Ut,[],t=>t.geometryType()],worldview:[Ut,[],t=>t.globals.worldview||""],"is-active-floor":[Nt,nn(Ut),(t,e)=>{if(!(t.globals.activeFloors&&t.globals.activeFloors.size>0))return!1;const r=t.globals.activeFloors;return e.some((e=>{const n=e.evaluate(t);return r.has(n)}))}],id:[$t,[],t=>t.id()],zoom:[Ot,[],t=>t.globals.zoom],pitch:[Ot,[],t=>t.globals.pitch||0],"distance-from-center":[Ot,[],t=>t.distanceFromCenter()],"measure-light":[Ot,[Ut],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[Ot,[],t=>t.globals.heatmapDensity||0],"line-progress":[Ot,[],t=>t.globals.lineProgress||0],"raster-value":[Ot,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[Ot,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[Ot,[],t=>t.globals.skyRadialProgress||0],accumulated:[$t,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Ot,nn(Ot),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[Ot,nn(Ot),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:Ot,overloads:[[[Ot,Ot],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Ot],(t,[e])=>-e.evaluate(t)]]},"/":[Ot,[Ot,Ot],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[Ot,[Ot,Ot],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Ot,[],()=>Math.LN2],pi:[Ot,[],()=>Math.PI],e:[Ot,[],()=>Math.E],"^":[Ot,[Ot,Ot],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Ot,[Ot],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Ot,[Ot],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Ot,[Ot],(t,[e])=>Math.log(e.evaluate(t))],log2:[Ot,[Ot],(t,[e])=>Math.log2(e.evaluate(t))],sin:[Ot,[Ot],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Ot,[Ot],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Ot,[Ot],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Ot,[Ot],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Ot,[Ot],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Ot,[Ot],(t,[e])=>Math.atan(e.evaluate(t))],min:[Ot,nn(Ot),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Ot,nn(Ot),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Ot,[Ot],(t,[e])=>Math.abs(e.evaluate(t))],round:[Ot,[Ot],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Ot,[Ot],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Ot,[Ot],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Nt,[Ut,$t],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[Nt,[$t],(t,[e])=>t.id()===e.value],"filter-type-==":[Nt,[Ut],(t,[e])=>t.geometryType()===e.value],"filter-<":[Nt,[Ut,$t],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<i}],"filter-id-<":[Nt,[$t],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<n}],"filter->":[Nt,[Ut,$t],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Nt,[$t],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[Nt,[Ut,$t],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Nt,[$t],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[Nt,[Ut,$t],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Nt,[$t],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[Nt,[$t],(t,[e])=>e.value in t.properties()],"filter-has-id":[Nt,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Nt,[Zt(Ut)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Nt,[Zt($t)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Nt,[Ut,Zt($t)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Nt,[Ut,Zt($t)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return!0;e[i]>t?n=i-1:r=i+1}return!1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Nt,overloads:[[[Nt,Nt],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[nn(Nt),(t,e)=>{for(const r of e)if(!r.evaluate(t))return!1;return!0}]]},any:{type:Nt,overloads:[[[Nt,Nt],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[nn(Nt),(t,e)=>{for(const r of e)if(r.evaluate(t))return!0;return!1}]]},"!":[Nt,[Nt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Nt,[Ut],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return!r||r(e.evaluate(t))}],upcase:[Ut,[Ut],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Ut,[Ut],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Ut,nn($t),(t,e)=>e.map((e=>ie(e.evaluate(t)))).join("")],"resolved-locale":[Ut,[qt],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[Ot,[Ot,Ot,$t],(t,e)=>{const[r,n,i]=e.map((e=>e.evaluate(t)));if(r>n)return r;if(r===n)return r;let o;if("string"==typeof i)o=function(t){let e=0;if(0===t.length)return e;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}(i);else{if("number"!=typeof i)throw new RuntimeError(`Invalid seed input: ${i}`);o=i}var s;return r+(s=o,function(){s=1831565813+(s|=0)|0;let t=Math.imul(s^s>>>15,1|s);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296})()*(n-r)}]});class StyleExpression{constructor(t,e,r,n,i){this.expression=t,this._warningHistory={},this._scope=r,this._options=n,this._iconImageUseTheme=i,this._evaluator=new EvaluationContext(r,n,i),this._defaultValue=e?function(t){return"color"===t.type&&(pn(t.default)||Array.isArray(t.default))?new Color(0,0,0,0):"color"===t.type?Color.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null,this.configDependencies=on(t),this.isIndoorDependent=sn(t)}evaluateWithoutErrorHandling(t,e,r,n,i,o,s,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,o,s,a,l){this._evaluator||(this._evaluator=new EvaluationContext(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this._evaluator.iconImageUseTheme=l||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){const e=t;return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${e.message}`)),this._defaultValue}}}function bn(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Kr}function wn(t,e,r,n,i){const o=new ParsingContext(Kr,[],e?function(t){const e={color:jt,string:Ut,number:Ot,enum:Ut,boolean:Nt,formatted:Ht,resolvedImage:Xt};return"array"===t.type?Zt(e[t.value]||$t,t.length):e[t.type]}(e):void 0,void 0,void 0,r,n,i),s=o.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return s?an(new StyleExpression(s,e,r,n,i)):ln(o.errors)}class ZoomConstantExpression{constructor(t,e,r,n){this.kind=t,this._styleExpression=e,this.isLightConstant=r,this.isLineProgressConstant=n,this.isStateDependent="constant"!==t&&!gr(e.expression),this.configDependencies=on(e.expression),this.isIndoorDependent=sn(e.expression)}evaluateWithoutErrorHandling(t,e,r,n,i,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,o)}evaluate(t,e,r,n,i,o,s){return this._styleExpression.evaluate(t,e,r,n,i,o,void 0,void 0,s)}}class ZoomDependentExpression{constructor(t,e,r,n,i,o){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!gr(e.expression),this.isIndoorDependent=sn(e.expression),this.isLightConstant=i,this.isLineProgressConstant=o,this.configDependencies=on(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,r,n,i,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,o)}evaluate(t,e,r,n,i,o){return this._styleExpression.evaluate(t,e,r,n,i,o)}interpolationFactor(t,e,r){return this.interpolationType?Interpolate.interpolationFactor(this.interpolationType,t,e,r):0}}function _n(t,e,r,n,i){if("error"===(t=wn(t,e,r,n,i)).result)return t;const o=t.value.expression,s=mr(o);if(!s&&!cn(e))return ln([new ParsingError("","data expressions not supported")]);const a=xr(o,["zoom","pitch","distance-from-center"]);if(!a&&!function(t){return un(t.expression,"zoom")}(e))return ln([new ParsingError("","zoom expressions not supported")]);const l=xr(o,["measure-light"]);if(!l&&!function(t){return un(t.expression,"measure-light")}(e))return ln([new ParsingError("","measure-light expression not supported")]);const u=xr(o,["line-progress"]);if(!u&&!function(t){return un(t.expression,"line-progress")}(e))return ln([new ParsingError("","line-progress expression not supported")]);const c=e.expression&&e.expression.relaxZoomRestriction,h=An(o);return h||a||c?h instanceof ParsingError?ln([h]):h instanceof Interpolate&&!hn(e)?ln([new ParsingError("",'"interpolate" expressions cannot be used with this property')]):an(h?new ZoomDependentExpression(s&&u?"camera":"composite",t.value,h.labels,h instanceof Interpolate?h.interpolation:void 0,l,u):new ZoomConstantExpression(s&&u?"constant":"source",t.value,l,u)):ln([new ParsingError("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class StylePropertyFunction{constructor(t,e){this._parameters=t,this._specification=e,Object.assign(this,fn(this._parameters,this._specification))}static deserialize(t){return new StylePropertyFunction(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function An(t){let e=null;if(t instanceof Let)e=An(t.result);else if(t instanceof Coalesce){for(const r of t.args)if(e=An(r),e)break}else(t instanceof Step||t instanceof Interpolate)&&t.input instanceof CompoundExpression&&"zoom"===t.input.name&&(e=t);return e instanceof ParsingError||t.eachChild((t=>{const r=An(t);r instanceof ParsingError?e=r:e&&r&&e!==r&&(e=new ParsingError("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}const Sn={get API_URL_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm"};function Pn(t){return Sn.API_URL_REGEX.test(t)}function Mn(t,e){const r=t.indexOf("?");if(r<0)return`${t}?${new URLSearchParams(e).toString()}`;const n=new URLSearchParams(t.slice(r));for(const t in e)n.set(t,e[t]);return`${t.slice(0,r)}?${n.toString()}`}function Dn(t,e={persistentParams:[]}){const r=t.indexOf("?");if(r<0)return t;const n=new URLSearchParams,i=new URLSearchParams(t.slice(r));for(const t of e.persistentParams){const e=i.get(t);e&&n.set(t,e)}const o=n.toString();return`${t.slice(0,r)}${o.length>0?`?${o}`:""}`}const En="mapbox-tiles",Cn=["language","worldview","jobid"];let Bn,Tn;function kn(){const t=function(){try{return caches}catch(t){}}();t&&null==Bn&&(Bn=t.open(En))}const zn={supported:!1,testSupport:function(t){!Fn&&Vn&&(Rn?Un(t):Ln=t)}};let Ln,Vn,Fn=!1,Rn=!1;const On="undefined"!=typeof self?self:{};function Un(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Vn),t.isContextLost())return;zn.supported=!0}catch(t){}t.deleteTexture(e),Fn=!0}On.document&&(Vn=On.document.createElement("img"),Vn.onload=function(){Ln&&Un(Ln),Ln=null,Rn=!0},Vn.onerror=function(){Fn=!0,Ln=null},Vn.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Nn={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Nn);class AJAXError extends Error{constructor(t,e,r){401===e&&Pn(r)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=r}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const jn=_t()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href;const Gn=function(t,e){if(!(/^file:/.test(r=t.url)||/^file:/.test(jn())&&!/^\w+:/.test(r))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(t,e){const r=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:jn(),referrerPolicy:t.referrerPolicy,signal:r.signal});let i=!1,o=!1;const s=(a=n.url).indexOf("sku=")>0&&Pn(a);var a;"json"===t.type&&n.headers.set("Accept","application/json");const l=(r,i,a)=>{if(o)return;if(r&&"SecurityError"!==r.message&&vt(r.toString()),i&&a)return u(i);const l=Date.now();fetch(n).then((r=>{if(r.ok){const t=s?r.clone():null;return u(r,t,l)}return e(new AJAXError(r.statusText,r.status,t.url))})).catch((r=>{"AbortError"!==r.name&&e(new Error(`${r.message} ${t.url}`))}))},u=(r,s,a)=>{("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{o||(s&&a&&function(t,e,r){if(kn(),null==Bn)return;const n=St(e.headers.get("Cache-Control")||"");if(n["no-store"])return;const i={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>i.headers.set(e,t))),n["max-age"]&&i.headers.set("Expires",new Date(r+1e3*n["max-age"]).toUTCString());const o=i.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-r<42e4)return;let s=Dn(t.url,{persistentParams:Cn});if(206===e.status){const e=t.headers.get("Range");if(!e)return;i.status=200,s=Mn(s,{range:e})}!function(t,e){if(void 0===Tn)try{new Response(new ReadableStream),Tn=!0}catch(t){Tn=!1}Tn?e(t.body):t.blob().then(e).catch((t=>vt(t.message)))}(e,(t=>{const r=new Response(200!==(n=e.status)&&404!==n&&[101,103,204,205,304].includes(n)?null:t,i);var n;kn(),null!=Bn&&Bn.then((t=>t.put(s,r))).catch((t=>vt(t.message)))}))}(n,s,a),i=!0,e(null,t,r.headers))})).catch((t=>{o||e(new Error(t.message))}))};return s?function(t,e){if(kn(),null==Bn)return e(null);Bn.then((r=>{let n=Dn(t.url,{persistentParams:Cn});const i=t.headers.get("Range");i&&(n=Mn(n,{range:i})),r.match(n).then((t=>{const i=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),r=St(t.headers.get("Cache-Control")||"");return Number(e)>Date.now()&&!r["no-cache"]}(t);r.delete(n).catch(e),i&&r.put(n,t.clone()).catch(e),e(null,t,i)})).catch(e)})).catch(e)}(n,l):l(null,null),{cancel:()=>{o=!0,i||r.abort()}}}(t,e);if(_t(self)&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(t,e){const r=new XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{e(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===t.type)try{n=JSON.parse(r.response)}catch(t){return e(t)}const i=new Headers;r.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach((t=>{const e=t.split(": "),r=e.shift(),n=e.join(": ");i.append(r,n)})),e(null,n,i)}else e(new AJAXError(r.statusText,r.status,t.url))},r.send(t.body),{cancel:()=>r.abort()}}(t,e)},$n=function(t,e){return Gn(Object.assign(t,{type:"arrayBuffer"}),e)},qn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Hn,Xn;Hn=[],Xn=0;const Zn=function(t,e){if(zn.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),Xn>=Sn.MAX_PARALLEL_IMAGE_REQUESTS){const r={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return Hn.push(r),r}Xn++;let r=!1;const n=()=>{if(!r)for(r=!0,Xn--;Hn.length&&Xn<Sn.MAX_PARALLEL_IMAGE_REQUESTS;){const t=Hn.shift(),{requestParameters:e,callback:r,cancelled:n}=t;n||(t.cancel=Zn(e,r).cancel)}},i=$n(t,((t,r,i)=>{n(),t?e(t):r&&(self.createImageBitmap?function(t,e){const r=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(r).then((t=>{e(null,t)})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))}))}(r,((t,r)=>e(t,r,i))):function(t,e){const r=new Image;r.onload=()=>{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,requestAnimationFrame((()=>{r.src=qn}))},r.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(n):qn}(r,((t,r)=>e(t,r,i))))}));return{cancel:()=>{i.cancel(),n()}}},Wn={};function Yn(t,e,r={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writable:!1}),Wn[e]={klass:t,omit:r.omit||[]}}Yn(Object,"Object"),kt.serialize=function(t,e){const r=t.toArrayBuffer();return e&&e.add(r),{buffer:r}},kt.deserialize=function(t){return new kt(t.buffer)},Object.defineProperty(kt,"name",{value:"Grid"}),Yn(kt,"Grid"),delete ot.prototype.constructor,Yn(Color,"Color"),Yn(Error,"Error"),Yn(Formatted,"Formatted"),Yn(FormattedSection,"FormattedSection"),Yn(AJAXError,"AJAXError"),Yn(ResolvedImage,"ResolvedImage"),Yn(StylePropertyFunction,"StylePropertyFunction"),Yn(StyleExpression,"StyleExpression",{omit:["_evaluator"]}),Yn(ImageId,"ImageId"),Yn(ImageVariant,"ImageVariant"),Yn(ZoomDependentExpression,"ZoomDependentExpression"),Yn(ZoomConstantExpression,"ZoomConstantExpression"),Yn(CompoundExpression,"CompoundExpression",{omit:["_evaluate"]});for(const t in Kr)Wn[Kr[t]._classRegistryKey]||Yn(Kr[t],`Expression${t}`);function Jn(t){return t&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Kn(t,e){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(Jn(t)||t instanceof ImageBitmap)return e&&e.add(t),t;if(ArrayBuffer.isView(t))return e&&e.add(t.buffer),t;if(t instanceof ImageData)return e&&e.add(t.data.buffer),t;if(Array.isArray(t)){const r=[];for(const n of t)r.push(Kn(n,e));return r}if(t instanceof Map){const r={$name:"Map",entries:[]};for(const[n,i]of t.entries())r.entries.push(Kn(n),Kn(i,e));return r}if(t instanceof Set){const e={$name:"Set"};let r=0;for(const n of t.values())e[++r]=Kn(n);return e}if("bigint"==typeof t)return{$name:"BigInt",value:t.toString()};if("object"==typeof t){const r=t.constructor,n=r._classRegistryKey;if(!n)throw new Error(`Can't serialize object of unregistered class "${r.name}".`);const i=r.serialize?r.serialize(t,e):{};if(!r.serialize){for(const r in t)t.hasOwnProperty(r)&&(Wn[n].omit.indexOf(r)>=0||(i[r]=Kn(t[r],e)));t instanceof Error&&(i.message=t.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(i.$name=n),i}throw new Error("can't serialize object of type "+typeof t)}function Qn(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Jn(t)||t instanceof ImageBitmap||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Qn);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=t.entries||[],r=new Map;for(let t=0;t<e.length;t+=2)r.set(Qn(e[t]),Qn(e[t+1]));return r}if("Set"===e){const e=new Set;for(const r of Object.keys(t))"$name"!==r&&e.add(Qn(t[r]));return e}if("BigInt"===e)return BigInt(t.value);const{klass:r}=Wn[e];if(!r)throw new Error(`Can't deserialize unregistered class "${e}".`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=Qn(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}class ThrottledInvoker{constructor(t){this._callback=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}function ti(t){const e=t?t.url.toString():void 0;return e?performance.getEntriesByName(e):[]}class Scheduler{constructor(){this.tasks={},this.taskQueue=[],ft(["process"],this),this.invoker=new ThrottledInvoker(this.process),this.nextId=0}add(t,e){const r=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:r}){return r=r||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-r:"maybePrepare"===t&&e?400-r:500:200-r:100-r}(e);if(0===n){try{t()}finally{}return null}return this.tasks[r]={fn:t,metadata:e,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r]}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let r=0;r<this.taskQueue.length;r++){const n=this.tasks[this.taskQueue[r]];n.priority<e&&(e=n.priority,t=r)}if(null===t)return null;const r=this.taskQueue[t];return this.taskQueue.splice(t,1),r}remove(){this.invoker.remove()}}class Actor{constructor(t,e,r){this.target=t,this.parent=e,this.mapId=r,this.callbacks={},this.cancelCallbacks={},ft(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new Scheduler}send(t,e,r,n,i=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=o,this.callbacks[s]=r);const a=new Set;return this.target.postMessage({id:s,type:t,hasCallback:!!r,targetMapId:n,mustQueue:i,sourceMapId:this.mapId,data:Kn(e,a)},a),{cancel:()=>{r&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data;if(!e)return;const r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t.cancel()}else if(e.mustQueue||_t(self)){const t=this.callbacks[r],n=this.scheduler.add((()=>this.processTask(r,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[r]=n)}else this.processTask(r,e)}processTask(t,e){if(delete this.cancelCallbacks[t],"<response>"===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(Qn(e.error)):r(null,Qn(e.data)))}else{const r=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?Kn(e):null,data:Kn(n,r)},r)}:()=>{},i=Qn(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,i,n);else if(this.parent.getWorkerSource){const t=e.type.split("."),{source:r,scope:o}=i;this.parent.getWorkerSource(e.sourceMapId,t[0],r,o)[t[1]](i,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class Event{constructor(t,...e){Object.assign(this,e[0]||{}),this.type=t}}class ErrorEvent extends Event{constructor(t,e={}){super("error",Object.assign({error:t},e))}}function ei(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e))}function ri(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}class Evented{on(t,e){return this._listeners=this._listeners||{},ei(t,e,this._listeners),this}off(t,e){return ri(t,e,this._listeners),ri(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},ei(t,e,this._oneTimeListeners),this):new Promise((e=>{this.once(t,e)}))}fire(t,e){const r="string"==typeof t?new Event(t,e):t,n=r.type;if(this.listens(n)){r.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const e of t)e.call(this,r);const e=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of e)ri(n,t,this._oneTimeListeners),t.call(this,r);const i=this._eventedParent;if(i){const t="function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData;Object.assign(r,t),i.fire(r)}}else r instanceof ErrorEvent&&console.error(r.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}const ni={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519,Osage:t=>t>=66736&&t<=66815,"CJK Unified Ideographs Extension B":t=>t>=131072&&t<=173791};function ii(t){for(const e of t)if(ai(e.charCodeAt(0)))return!0;return!1}function oi(t){for(const e of t)if(!si(e.charCodeAt(0)))return!1;return!0}function si(t){return!(ni.Arabic(t)||ni["Arabic Supplement"](t)||ni["Arabic Extended-A"](t)||ni["Arabic Presentation Forms-A"](t)||ni["Arabic Presentation Forms-B"](t))}function ai(t){return!(746!==t&&747!==t&&(t<4352||!(ni["Bopomofo Extended"](t)||ni.Bopomofo(t)||ni["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||ni["CJK Compatibility Ideographs"](t)||ni["CJK Compatibility"](t)||ni["CJK Radicals Supplement"](t)||ni["CJK Strokes"](t)||!(!ni["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||ni["CJK Unified Ideographs Extension A"](t)||ni["CJK Unified Ideographs"](t)||ni["Enclosed CJK Letters and Months"](t)||ni["Hangul Compatibility Jamo"](t)||ni["Hangul Jamo Extended-A"](t)||ni["Hangul Jamo Extended-B"](t)||ni["Hangul Jamo"](t)||ni["Hangul Syllables"](t)||ni.Hiragana(t)||ni["Ideographic Description Characters"](t)||ni.Kanbun(t)||ni["Kangxi Radicals"](t)||ni["Katakana Phonetic Extensions"](t)||ni.Katakana(t)&&12540!==t||!(!ni["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!ni["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||ni["Unified Canadian Aboriginal Syllabics"](t)||ni["Unified Canadian Aboriginal Syllabics Extended"](t)||ni["Vertical Forms"](t)||ni["Yijing Hexagram Symbols"](t)||ni["Yi Syllables"](t)||ni["Yi Radicals"](t))))}function li(t){return!(ai(t)||function(t){return!!(ni["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||ni["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||ni["Letterlike Symbols"](t)||ni["Number Forms"](t)||ni["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||ni["Control Pictures"](t)&&9251!==t||ni["Optical Character Recognition"](t)||ni["Enclosed Alphanumerics"](t)||ni["Geometric Shapes"](t)||ni["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||ni["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||ni["CJK Symbols and Punctuation"](t)||ni.Katakana(t)||ni["Private Use Area"](t)||ni["CJK Compatibility Forms"](t)||ni["Small Form Variants"](t)||ni["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function ui(t){return ni.Arabic(t)||ni["Arabic Supplement"](t)||ni["Arabic Extended-A"](t)||ni["Arabic Presentation Forms-A"](t)||ni["Arabic Presentation Forms-B"](t)}function ci(t){return t>=1424&&t<=2303||ni["Arabic Presentation Forms-A"](t)||ni["Arabic Presentation Forms-B"](t)}function hi(t,e){return!(!e&&ci(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||ni.Khmer(t))}function pi(t){for(const e of t)if(ci(e.charCodeAt(0)))return!0;return!1}let di,fi,yi,mi,gi,xi;function vi(){return null==di&&(di=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),di}const bi={now:()=>void 0!==mi?mi:performance.now(),setNow(t){mi=t},restoreNow(){mi=void 0},frame(t){const e=requestAnimationFrame(t);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:r,height:n}=t;gi||(gi=document.createElement("canvas"));const i=gi.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return(r>gi.width||n>gi.height)&&(gi.width=r,gi.height=n),i.clearRect(-e,-e,r+2*e,n+2*e),i.drawImage(t,0,0,r,n),i.getImageData(-e,-e,r+2*e,n+2*e)},resolveURL:t=>(fi||(fi=document.createElement("a")),fi.href=t,fi.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==yi&&(yi=window.matchMedia("(prefers-reduced-motion: reduce)")),yi.matches)},hasCanvasFingerprintNoise(){if(void 0!==xi)return xi;if(!vi())return xi=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let r=0;for(let n=0;n<t.width;++n)e.fillStyle=`rgba(${r++},${r++},${r++}, 255)`,e.fillRect(n,0,1,1);const n=e.getImageData(0,0,t.width,t.height);r=0;for(let t=0;t<n.data.length;++t)if(t%4!=3&&r++!==n.data[t])return xi=!0,!0;return xi=!1,!1}},wi="parsing",_i="parsed";let Ai="unavailable",Si=null;const Ii={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>"loaded"===Ai||null!=Ii.applyArabicShaping,isLoading:()=>"loading"===Ai,setState(t){Ai=t.pluginStatus,Si=t.pluginURL},isParsing:()=>Ai===wi,isParsed:()=>Ai===_i,getPluginURL:()=>Si};class EvaluationParameters{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness,this.worldview=e.worldview,this.activeFloors=e.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(t){return function(t,e){for(const r of t)if(!hi(r.charCodeAt(0),e))return!1;return!0}(t,Ii.isLoaded())}}class PropertyValue{constructor(t,e,r,n,i){this.property=t,this.value=e,this.expression=function(t,e,r,n,i){if(pn(t))return new StylePropertyFunction(t,e);if(bn(t)||Array.isArray(t)&&t.length>0){const o=_n(t,e,r,n,i);if("error"===o.result)throw new Error(o.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return o.value}{let r=t;return"string"==typeof t&&"color"===e.type&&(r=Color.parse(t)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification,r,n,i)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r,n){return this.property.possiblyEvaluate(this,t,e,r,n)}}class TransitionablePropertyValue{constructor(t,e,r,n){this.property=t,this.value=new PropertyValue(t,void 0,e,r,n)}transitioned(t,e){return new TransitioningPropertyValue(this.property,this.value,e,Object.assign({},t.transition,this.transition),t.now)}untransitioned(){return new TransitioningPropertyValue(this.property,this.value,null,{},0)}}class Transitionable{constructor(t,e,r,n){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=r,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(t){return mt(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new TransitionablePropertyValue(this._values[t].property,this._scope,this._options,this._iconImageUseTheme)),this._values[t].value=new PropertyValue(this._values[t].property,null===e?void 0:mt(e),this._scope,this._options,this._iconImageUseTheme),this._values[t].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[t].value.isIndoorDependent())}setTransitionOrValue(t,e){e&&(this._options=e);const r=this._properties.properties;if(t)for(const e in t){const n=t[e];if(e.endsWith("-transition")){const t=e.slice(0,-11);r[t]&&this.setTransition(t,n)}else r.hasOwnProperty(e)&&this.setValue(e,n)}}getTransition(t){return mt(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new TransitionablePropertyValue(this._values[t].property)),this._values[t].transition=mt(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const r=new Transitioning(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new Transitioning(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}isIndoorDependent(){return this._isIndoorDependent}}class TransitioningPropertyValue{constructor(t,e,r,n,i){const o=n.delay||0,s=n.duration||0;i=i||0,this.property=t,this.value=e,this.begin=i+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r)}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),o=this.prior;if(o){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n<this.begin)return o.possiblyEvaluate(t,e,r);{const s=(n-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(t,e,r),i,function(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}(s))}}return i}}class Transitioning{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,r){const n=new PossiblyEvaluated(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class Layout{constructor(t,e,r,n){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._scope=e,this._options=r,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(t){return mt(this._values[t].value)}setValue(t,e){this._values[t]=new PropertyValue(this._values[t].property,null===e?void 0:mt(e),this._scope,this._options,this._iconImageUseTheme),this._values[t].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[t].isIndoorDependent())}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r)}return t}possiblyEvaluate(t,e,r,n){const i=new PossiblyEvaluated(this._properties);for(const o of Object.keys(this._values))i._values[o]=this._values[o].possiblyEvaluate(t,e,r,n);return i}isIndoorDependent(){return this._isIndoorDependent}}class PossiblyEvaluatedPropertyValue{constructor(t,e,r,n){this.property=t,this.value=e,this.parameters=r,this.iconImageUseTheme=n}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,r,n){return this.property.evaluate(this.value,this.parameters,t,e,r,n,this.iconImageUseTheme)}}class PossiblyEvaluated{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class DataConstantProperty{constructor(t){this.specification=t}possiblyEvaluate(t,e){return t.expression.evaluate(e)}interpolate(t,e,r){const n=Ft[this.specification.type];return n?n(t,e,r):t}}class DataDrivenProperty{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,r,n,i){return"constant"===t.expression.kind||"camera"===t.expression.kind?new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:t.expression.evaluate(e,null,{},r,n,void 0,i)},e):new PossiblyEvaluatedPropertyValue(this,t.expression,e,i)}interpolate(t,e,r){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:void 0},t.parameters);const n=Ft[this.specification.type];return n?new PossiblyEvaluatedPropertyValue(this,{kind:"constant",value:n(t.value.value,e.value.value,r)},t.parameters):t}evaluate(t,e,r,n,i,o,s){return"constant"===t.kind?t.value:t.evaluate(e,r,n,i,o,void 0,s)}}class ColorRampProperty{constructor(t){this.specification=t}possiblyEvaluate(t,e,r,n){return!!t.expression.evaluate(e,null,{},r,n)}interpolate(){return!1}}class Properties{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const e=new EvaluationParameters(0,{});for(const r in t){const n=t[r];n.specification.overridable&&this.overridableProperties.push(r);const i=this.defaultPropertyValues[r]=new PropertyValue(n,void 0),o=this.defaultTransitionablePropertyValues[r]=new TransitionablePropertyValue(n);this.defaultTransitioningPropertyValues[r]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=i.possiblyEvaluate(e)}}}Yn(DataDrivenProperty,"DataDrivenProperty"),Yn(DataConstantProperty,"DataConstantProperty"),Yn(ColorRampProperty,"ColorRampProperty");var Pi=JSON.parse('{"$version":8,"$root":{"version":{"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"snow":{"type":"snow"},"rain":{"type":"rain"},"camera":{"type":"camera"},"color-theme":{"type":"colorTheme"},"indoor":{"type":"indoor"},"imports":{"type":"array","value":"import"},"iconsets":{"type":"iconsets"},"schema":{"type":"schema"},"sources":{"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"type":"featuresets"}},"featuresets":{"*":{"type":"featureset"}},"featureset":{"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"layer":{"type":"string"},"properties":{"type":"selectorProperty"},"featureNamespace":{"type":"string"},"_uniqueFeatureID":{"type":"boolean"}},"selectorProperty":{"*":{"type":"*"}},"model":{"type":"string"},"import":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","expression":{}},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string"},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false},"shadow-quality":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"parameters":["zoom"]}},"shadow-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_ambient":{"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"iconsets":{"*":{"type":"iconset"}},"iconset":["iconset_sprite","iconset_source"],"iconset_sprite":{"type":{"type":"enum","values":{"sprite":1}},"url":{"type":"string"}},"iconset_source":{"type":{"type":"enum","values":{"source":1}},"source":{"type":"string"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"type":"enum","values":{"video":1}},"urls":{"type":"array","value":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"type":"enum","values":{"image":1}},"url":{"type":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"modelNodeOverride":{"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360}},"modelNodeOverrides":{"*":{"type":"modelNodeOverride"}},"modelMaterialOverride":{"model-color":{"type":"color"},"model-color-mix-intensity":{"type":"number"},"model-opacity":{"type":"number"},"model-emissive-strength":{"type":"number"}},"modelMaterialOverrides":{"*":{"type":"modelMaterialOverride"}},"modelSourceModel":{"uri":{"type":"string"},"position":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[-180,-90],"maximum":[180,90]},"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360},"nodeOverrides":{"type":"modelNodeOverrides"},"materialOverrides":{"type":"modelMaterialOverrides"},"nodeOverrideNames":{"type":"array","value":"string"},"materialOverrideNames":{"type":"array","value":"string"},"featureProperties":{"type":"*"}},"modelSourceModels":{"*":{"type":"modelSourceModel"}},"source_model":{"type":{"type":"enum","values":{"model":1,"batched-model":1}},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"},"models":{"type":"modelSourceModels"}},"layer":{"id":{"type":"string"},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"building":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{},"clip":{}}},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"},"appearances":{"type":"array","value":"appearance","supported-layer-types":["symbol"]}},"appearance":{"condition":{"type":"boolean","expression":{"interpolated":true,"parameters":["zoom","pitch","feature","feature-state","measure-light","distance-from-center"]},"property-type":"data-driven"},"name":{"type":"string"},"properties":{"type":"*"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_building","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}}},"layout_clip":{"clip-layer-types":{"type":"array","value":"enum","values":{"model":1,"symbol":1},"default":[],"expression":{}},"clip-layer-scope":{"type":"array","value":"string","default":[],"expression":{}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"default":"none","expression":{}},"fill-construct-bridge-guard-rail":{"type":"boolean","default":"true","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"circle-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-markup":1},"default":"none","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-extrusion-edge-radius":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}}},"layout_building":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"building-facade":{"type":"boolean","default":false,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-floors":{"type":"number","minimum":1,"maximum":200,"default":3,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-unit-width":{"type":"number","minimum":1,"maximum":20,"default":3.1,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-window":{"type":"array","length":2,"value":"number","minimum":0.1,"maximum":1,"default":[0.9,0.9],"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-roof-shape":{"type":"enum","values":{"flat":1,"hipped":1,"gabled":1,"parapet":1,"mansard":1,"skillion":1,"pyramidal":1},"default":"flat","expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flip-roof-orientation":{"property-type":"data-driven","type":"boolean","default":false,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1,"none":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","default":0,"expression":{"parameters":["zoom","feature","line-progress"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"default":"none","expression":{}},"line-cross-slope":{"type":"number","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"line-width-unit":{"type":"enum","values":{"pixels":1,"meters":1},"default":"pixels","expression":{"parameters":["zoom"]}}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]}},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]}},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]}},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{"parameters":["zoom"]}},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"icon-size":{"type":"number","default":1,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"appearance":true,"use-theme":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]}},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]}},"text-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster-particle":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_hillshade":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster-particle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_clip":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_model":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_building":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function Mi(t){if(Array.isArray(t))return t.map(Mi);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const r in t)e[r]=Mi(t[r]);return e}return function(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}(t)}function Di(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Di(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function Ei(t,e="",r=null,n="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Di(t)||(t=Vi(t));const i=t;let o=!0;try{o=function(t){if(!Ti(t))return t;let e=Mi(t);return Bi(e),e=Ci(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}let s=null,a=null;if("background"!==n&&"sky"!==n&&"slot"!==n){a=Pi[`filter_${n}`];const t=wn(o,a,e,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(e,r,n)=>t.value.evaluate(e,r,{},n)}let l=null,u=null;if(o!==i){const t=wn(i,a,e,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));l=(e,r,n,i,o)=>t.value.evaluate(e,r,{},n,void 0,void 0,i,o),u=!mr(t.value.expression)}return{filter:s,dynamicFilter:l||void 0,needGeometry:Li(o),needFeature:!!u}}function Ci(t){if(!Array.isArray(t))return t;const e=function(t){if(ki.has(t[0]))for(let e=1;e<t.length;e++)if(Ti(t[e]))return!0;return t}(t);return!0===e?e:e.map((t=>Ci(t)))}function Bi(t){let e=!1;const r=[];if("case"===t[0]){for(let n=1;n<t.length-1;n+=2)e=e||Ti(t[n]),r.push(t[n+1]);r.push(t[t.length-1])}else if("match"===t[0]){e=e||Ti(t[1]);for(let e=2;e<t.length-1;e+=2)r.push(t[e+1]);r.push(t[t.length-1])}else if("step"===t[0]){e=e||Ti(t[1]);for(let e=1;e<t.length-1;e+=2)r.push(t[e+1])}e&&(t.length=0,t.push("any",...r));for(let e=1;e<t.length;e++)Bi(t[e])}function Ti(t){if(!Array.isArray(t))return!1;if("pitch"===(e=t[0])||"distance-from-center"===e)return!0;var e;for(let e=1;e<t.length;e++)if(Ti(t[e]))return!0;return!1}const ki=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function zi(t,e){return t<e?-1:t>e?1:0}function Li(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e<t.length;e++)if(Li(t[e]))return!0;return!1}function Vi(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?Fi(t[1],t[2],"=="):"!="===e?Ui(Fi(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?Fi(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(Vi))):"all"===e?["all"].concat(t.slice(1).map(Vi)):"none"===e?["all"].concat(t.slice(1).map(Vi).map(Ui)):"in"===e?Ri(t[1],t.slice(2)):"!in"===e?Ui(Ri(t[1],t.slice(2))):"has"===e?Oi(t[1]):"!has"!==e||Ui(Oi(t[1]));var r}function Fi(t,e,r){switch(t){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,t,e]}}function Ri(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(zi)]]:["filter-in-small",t,["literal",e]]}}function Oi(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Ui(t){return["!",t]}function Ni(t,e){return e?`${t}${e}`:t}let ji;const Gi=()=>ji||(ji=new Properties({"icon-size":new DataDrivenProperty(Pi.layout_symbol["icon-size"]),"icon-image":new DataDrivenProperty(Pi.layout_symbol["icon-image"]),"icon-rotate":new DataDrivenProperty(Pi.layout_symbol["icon-rotate"]),"icon-offset":new DataDrivenProperty(Pi.layout_symbol["icon-offset"]),"text-size":new DataDrivenProperty(Pi.layout_symbol["text-size"]),"text-rotate":new DataDrivenProperty(Pi.layout_symbol["text-rotate"]),"text-offset":new DataDrivenProperty(Pi.layout_symbol["text-offset"])}));class SymbolAppearance{constructor(t,e,r,n,i,o){const s=wn(t,Pi.appearance.condition);if("success"===s.result&&(this.condition=s.value),this.name=e,r){this.properties=new PossiblyEvaluated(Gi()),this.unevaluatedLayout=new Layout(Gi(),n,i,o);for(const t in r)this.unevaluatedLayout.setValue(t,r[t])}}isActive(t){return!(this.condition||!t.isHidden||"hidden"!==this.name)||this.condition.evaluate(t.globals,t.feature,t.featureState,t.canonical)}getCondition(){return this.condition}getName(){return this.name}getProperty(t){return this.properties.get(t)}getUnevaluatedProperties(){return this.unevaluatedLayout}getUnevaluatedProperty(t){return this.unevaluatedLayout._values[t]}recalculate(t,e,r){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(t,void 0,e,r))}serialize(){const t={};return t.condition=this.condition.expression.serialize(),this.name&&(t.name=this.name),this.unevaluatedLayout&&(t.properties=this.unevaluatedLayout.serialize()),t}hasIconProperties(){const t=this.hasProperty("icon-image"),e=this.hasProperty("icon-size"),r=this.hasProperty("icon-offset"),n=this.hasProperty("icon-rotate");return t||e||r||n}hasTextProperties(){const t=this.hasProperty("text-size"),e=this.hasProperty("text-offset"),r=this.hasProperty("text-rotate");return t||e||r}hasProperty(t){return void 0!==this.getUnevaluatedProperty(t).value}}const $i="-transition",qi=new Set(["fill","line","background","hillshade","raster"]);class StyleLayer extends Evented{constructor(t,e,r,n,i,o){if(super(),this.id=t.id,this.fqid=Ni(this.id,r),this.type=t.type,this.scope=r,this.lut=n,this.options=i,this.iconImageUseTheme=o,this.appearances=new Array,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},"custom"!==t.type){if(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type&&"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type){this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter;const e=wn(this.filter,Pi[`filter_${t.type}`]);"error"!==e.result&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...e.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||e.value.isIndoorDependent)}if(t.slot&&(this.slot=t.slot),t.appearances&&this.setAppearances(t.appearances),e.layout&&(this._unevaluatedLayout=new Layout(e.layout,this.scope,i,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),e.paint){this._transitionablePaint=new Transitionable(e.paint,this.scope,i);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new PossiblyEvaluated(e.paint)}}}onAdd(t){}onRemove(t){}isDraped(t){return!this.is3D(!0)&&qi.has(this.type)}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const r=this._unevaluatedLayout;r._properties.properties[t]&&(r.setValue(t,e),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),"visibility"===t&&this.possiblyEvaluateVisibility())}setAppearances(t){this.appearances=[],t.forEach((t=>{this.appearances.push(new SymbolAppearance(t.condition,t.name,t.properties,this.scope,this.options,this.iconImageUseTheme))}))}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(t){return t.endsWith($i)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}isPaintProperty(t){return!!this._transitionablePaint._properties.properties[t]}setPaintProperty(t,e){const r=this._transitionablePaint,n=r._properties.properties;if(t.endsWith($i)){const i=t.slice(0,-11);return n[i]&&r.setTransition(i,e||void 0),!1}if(!n[t])return!1;const i=r._values[t],o=i.value.isDataDriven(),s=i.value;r.setValue(t,e),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(t);const a=r._values[t].value,l=a.isDataDriven(),u=t.endsWith("pattern")||"line-dasharray"===t;return l||o||u||this._handleOverridablePaintPropertyUpdate(t,s,a)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,r){return null}_handleOverridablePaintPropertyUpdate(t,e,r){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return 0!==this.appearances.length&&(t.appearances=this.appearances.map((t=>t.serialize()))),function(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(t){return!1}hasElevation(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof PossiblyEvaluatedPropertyValue&&cn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}for(const t of this.appearances)if(!gr(t.condition.expression))return!0;return!1}compileFilter(t){this._filterCompiled||(this._featureFilter=Ei(this.filter,this.scope,t),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(t,e,r){return{}}queryRadius(t){}queryIntersectsFeature(t,e,r,n,i,o,s,a,l){}}const Hi={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Struct{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const Xi=new ArrayBuffer(0);class StructArray{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(t,e){return t._trim(),e&&t.arrayBuffer&&e.add(t.arrayBuffer),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,t.arrayBuffer?e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement:(e.capacity=0,e.arrayBuffer=Xi),e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this._reallocCount++,this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}reserveForAdditional(t){this.reserve(this.length+t)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Zi(t,e=1){let r=0,n=0;return{members:t.map((t=>{const i=Hi[t.type].BYTES_PER_ELEMENT,o=r=Wi(r,Math.max(e,i)),s=t.components||1;return n=Math.max(n,i),r+=i*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Wi(r,Math.max(n,e)),alignment:e}}function Wi(t,e){return Math.ceil(t/e)*e}class StructArrayLayout2i4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}StructArrayLayout2i4.prototype.bytesPerElement=4,Yn(StructArrayLayout2i4,"StructArrayLayout2i4");class StructArrayLayout3i6 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}StructArrayLayout3i6.prototype.bytesPerElement=6,Yn(StructArrayLayout3i6,"StructArrayLayout3i6");class StructArrayLayout4i8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,t}}StructArrayLayout4i8.prototype.bytesPerElement=8,Yn(StructArrayLayout4i8,"StructArrayLayout4i8");class StructArrayLayout1f4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}StructArrayLayout1f4.prototype.bytesPerElement=4,Yn(StructArrayLayout1f4,"StructArrayLayout1f4");class StructArrayLayout2i1f8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t,o=2*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.float32[o+1]=n,t}}StructArrayLayout2i1f8.prototype.bytesPerElement=8,Yn(StructArrayLayout2i1f8,"StructArrayLayout2i1f8");class StructArrayLayout3i8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=4*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}StructArrayLayout3i8.prototype.bytesPerElement=8,Yn(StructArrayLayout3i8,"StructArrayLayout3i8");class StructArrayLayout5i10 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i)}emplace(t,e,r,n,i,o){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,this.int16[s+4]=o,t}}StructArrayLayout5i10.prototype.bytesPerElement=10,Yn(StructArrayLayout5i10,"StructArrayLayout5i10");class StructArrayLayout2i4ub1f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,o,s)}emplace(t,e,r,n,i,o,s,a){const l=6*t,u=12*t,c=3*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=i,this.uint8[u+6]=o,this.uint8[u+7]=s,this.float32[c+2]=a,t}}StructArrayLayout2i4ub1f12.prototype.bytesPerElement=12,Yn(StructArrayLayout2i4ub1f12,"StructArrayLayout2i4ub1f12");class StructArrayLayout3f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}StructArrayLayout3f12.prototype.bytesPerElement=12,Yn(StructArrayLayout3f12,"StructArrayLayout3f12");class StructArrayLayout4ui1f12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i)}emplace(t,e,r,n,i,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,this.float32[a+2]=o,t}}StructArrayLayout4ui1f12.prototype.bytesPerElement=12,Yn(StructArrayLayout4ui1f12,"StructArrayLayout4ui1f12");class StructArrayLayout4ui8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=r,this.uint16[o+2]=n,this.uint16[o+3]=i,t}}StructArrayLayout4ui8.prototype.bytesPerElement=8,Yn(StructArrayLayout4ui8,"StructArrayLayout4ui8");class StructArrayLayout6i12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,o)}emplace(t,e,r,n,i,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,this.int16[a+4]=o,this.int16[a+5]=s,t}}StructArrayLayout6i12.prototype.bytesPerElement=12,Yn(StructArrayLayout6i12,"StructArrayLayout6i12");class StructArrayLayout4i4ui4i24 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s,a,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,o,s,a,l,u,c,h)}emplace(t,e,r,n,i,o,s,a,l,u,c,h,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=r,this.int16[d+2]=n,this.int16[d+3]=i,this.uint16[d+4]=o,this.uint16[d+5]=s,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=u,this.int16[d+9]=c,this.int16[d+10]=h,this.int16[d+11]=p,t}}StructArrayLayout4i4ui4i24.prototype.bytesPerElement=24,Yn(StructArrayLayout4i4ui4i24,"StructArrayLayout4i4ui4i24");class StructArrayLayout3i3f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,o)}emplace(t,e,r,n,i,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.float32[l+2]=i,this.float32[l+3]=o,this.float32[l+4]=s,t}}StructArrayLayout3i3f20.prototype.bytesPerElement=20,Yn(StructArrayLayout3i3f20,"StructArrayLayout3i3f20");class StructArrayLayout4f16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=r,this.float32[o+2]=n,this.float32[o+3]=i,t}}StructArrayLayout4f16.prototype.bytesPerElement=16,Yn(StructArrayLayout4f16,"StructArrayLayout4f16");class StructArrayLayout1ul4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}StructArrayLayout1ul4.prototype.bytesPerElement=4,Yn(StructArrayLayout1ul4,"StructArrayLayout1ul4");class StructArrayLayout2ui4 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}StructArrayLayout2ui4.prototype.bytesPerElement=4,Yn(StructArrayLayout2ui4,"StructArrayLayout2ui4");class StructArrayLayout5i4f1i1ul2ui40 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s,a,l,u,c,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,r,n,i,o,s,a,l,u,c,h,p)}emplace(t,e,r,n,i,o,s,a,l,u,c,h,p,d){const f=20*t,y=10*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.int16[f+4]=o,this.float32[y+3]=s,this.float32[y+4]=a,this.float32[y+5]=l,this.float32[y+6]=u,this.int16[f+14]=c,this.uint32[y+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,t}}StructArrayLayout5i4f1i1ul2ui40.prototype.bytesPerElement=40,Yn(StructArrayLayout5i4f1i1ul2ui40,"StructArrayLayout5i4f1i1ul2ui40");class StructArrayLayout3i2i2i16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,o,s)}emplace(t,e,r,n,i,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+4]=i,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}StructArrayLayout3i2i2i16.prototype.bytesPerElement=16,Yn(StructArrayLayout3i2i2i16,"StructArrayLayout3i2i2i16");class StructArrayLayout2f1f2i16 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i)}emplace(t,e,r,n,i,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.int16[a+6]=i,this.int16[a+7]=o,t}}StructArrayLayout2f1f2i16.prototype.bytesPerElement=16,Yn(StructArrayLayout2f1f2i16,"StructArrayLayout2f1f2i16");class StructArrayLayout2ub4f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,o)}emplace(t,e,r,n,i,o,s){const a=20*t,l=5*t;return this.uint8[a+0]=e,this.uint8[a+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.float32[l+3]=o,this.float32[l+4]=s,t}}StructArrayLayout2ub4f20.prototype.bytesPerElement=20,Yn(StructArrayLayout2ub4f20,"StructArrayLayout2ub4f20");class StructArrayLayout3ui6 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}StructArrayLayout3ui6.prototype.bytesPerElement=6,Yn(StructArrayLayout3ui6,"StructArrayLayout3ui6");class StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g,x,v,b){const w=this.length;return this.resize(w+1),this.emplace(w,t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g,x,v,b)}emplace(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g,x,v,b,w){const _=30*t,A=15*t,S=60*t;return this.int16[_+0]=e,this.int16[_+1]=r,this.int16[_+2]=n,this.float32[A+2]=i,this.float32[A+3]=o,this.uint16[_+8]=s,this.uint16[_+9]=a,this.uint32[A+5]=l,this.uint32[A+6]=u,this.uint32[A+7]=c,this.uint16[_+16]=h,this.uint16[_+17]=p,this.uint16[_+18]=d,this.float32[A+10]=f,this.float32[A+11]=y,this.uint8[S+48]=m,this.uint8[S+49]=g,this.uint8[S+50]=x,this.uint32[A+13]=v,this.int16[_+28]=b,this.uint8[S+58]=w,t}}StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60.prototype.bytesPerElement=60,Yn(StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class StructArrayLayout2f9i15ui1ul4f1ub1ui80 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g,x,v,b,w,_,A,S,I,P,M,D,E,C,B,T){const k=this.length;return this.resize(k+1),this.emplace(k,t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g,x,v,b,w,_,A,S,I,P,M,D,E,C,B,T)}emplace(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g,x,v,b,w,_,A,S,I,P,M,D,E,C,B,T,k){const z=20*t,L=40*t,V=80*t;return this.float32[z+0]=e,this.float32[z+1]=r,this.int16[L+4]=n,this.int16[L+5]=i,this.int16[L+6]=o,this.int16[L+7]=s,this.int16[L+8]=a,this.int16[L+9]=l,this.int16[L+10]=u,this.int16[L+11]=c,this.int16[L+12]=h,this.uint16[L+13]=p,this.uint16[L+14]=d,this.uint16[L+15]=f,this.uint16[L+16]=y,this.uint16[L+17]=m,this.uint16[L+18]=g,this.uint16[L+19]=x,this.uint16[L+20]=v,this.uint16[L+21]=b,this.uint16[L+22]=w,this.uint16[L+23]=_,this.uint16[L+24]=A,this.uint16[L+25]=S,this.uint16[L+26]=I,this.uint16[L+27]=P,this.uint32[z+14]=M,this.float32[z+15]=D,this.float32[z+16]=E,this.float32[z+17]=C,this.float32[z+18]=B,this.uint8[V+76]=T,this.uint16[L+39]=k,t}}StructArrayLayout2f9i15ui1ul4f1ub1ui80.prototype.bytesPerElement=80,Yn(StructArrayLayout2f9i15ui1ul4f1ub1ui80,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class StructArrayLayout6f24 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,o)}emplace(t,e,r,n,i,o,s){const a=6*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,this.float32[a+4]=o,this.float32[a+5]=s,t}}StructArrayLayout6f24.prototype.bytesPerElement=24,Yn(StructArrayLayout6f24,"StructArrayLayout6f24");class StructArrayLayout5f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i)}emplace(t,e,r,n,i,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,this.float32[s+4]=o,t}}StructArrayLayout5f20.prototype.bytesPerElement=20,Yn(StructArrayLayout5f20,"StructArrayLayout5f20");class StructArrayLayout7f28 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,o,s)}emplace(t,e,r,n,i,o,s,a){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=i,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,t}}StructArrayLayout7f28.prototype.bytesPerElement=28,Yn(StructArrayLayout7f28,"StructArrayLayout7f28");class StructArrayLayout11f44 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s,a,l,u,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,r,n,i,o,s,a,l,u,c)}emplace(t,e,r,n,i,o,s,a,l,u,c,h){const p=11*t;return this.float32[p+0]=e,this.float32[p+1]=r,this.float32[p+2]=n,this.float32[p+3]=i,this.float32[p+4]=o,this.float32[p+5]=s,this.float32[p+6]=a,this.float32[p+7]=l,this.float32[p+8]=u,this.float32[p+9]=c,this.float32[p+10]=h,t}}StructArrayLayout11f44.prototype.bytesPerElement=44,Yn(StructArrayLayout11f44,"StructArrayLayout11f44");class StructArrayLayout9f36 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s,a,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,o,s,a,l)}emplace(t,e,r,n,i,o,s,a,l,u){const c=9*t;return this.float32[c+0]=e,this.float32[c+1]=r,this.float32[c+2]=n,this.float32[c+3]=i,this.float32[c+4]=o,this.float32[c+5]=s,this.float32[c+6]=a,this.float32[c+7]=l,this.float32[c+8]=u,t}}StructArrayLayout9f36.prototype.bytesPerElement=36,Yn(StructArrayLayout9f36,"StructArrayLayout9f36");class StructArrayLayout2f8 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}StructArrayLayout2f8.prototype.bytesPerElement=8,Yn(StructArrayLayout2f8,"StructArrayLayout2f8");class StructArrayLayout1ul3ui12 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=r,this.uint16[o+3]=n,this.uint16[o+4]=i,t}}StructArrayLayout1ul3ui12.prototype.bytesPerElement=12,Yn(StructArrayLayout1ul3ui12,"StructArrayLayout1ul3ui12");class StructArrayLayout1ui2 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}StructArrayLayout1ui2.prototype.bytesPerElement=2,Yn(StructArrayLayout1ui2,"StructArrayLayout1ui2");class StructArrayLayout16f64 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y){const m=this.length;return this.resize(m+1),this.emplace(m,t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y)}emplace(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=r,this.float32[g+2]=n,this.float32[g+3]=i,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=p,this.float32[g+12]=d,this.float32[g+13]=f,this.float32[g+14]=y,this.float32[g+15]=m,t}}StructArrayLayout16f64.prototype.bytesPerElement=64,Yn(StructArrayLayout16f64,"StructArrayLayout16f64");class StructArrayLayout4ui3f20 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,i,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,o,s)}emplace(t,e,r,n,i,o,s,a){const l=10*t,u=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=r,this.uint16[l+2]=n,this.uint16[l+3]=i,this.float32[u+2]=o,this.float32[u+3]=s,this.float32[u+4]=a,t}}StructArrayLayout4ui3f20.prototype.bytesPerElement=20,Yn(StructArrayLayout4ui3f20,"StructArrayLayout4ui3f20");class StructArrayLayout1i2 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}StructArrayLayout1i2.prototype.bytesPerElement=2,Yn(StructArrayLayout1i2,"StructArrayLayout1i2");class StructArrayLayout1ub1 extends StructArray{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}StructArrayLayout1ub1.prototype.bytesPerElement=1,Yn(StructArrayLayout1ub1,"StructArrayLayout1ub1");class CollisionBoxStruct extends Struct{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]}}CollisionBoxStruct.prototype.size=40;class CollisionBoxArray extends StructArrayLayout5i4f1i1ul2ui40{get(t){return new CollisionBoxStruct(this,t)}}Yn(CollisionBoxArray,"CollisionBoxArray");class PlacedSymbolStruct extends Struct{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}PlacedSymbolStruct.prototype.size=60;class PlacedSymbolArray extends StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60{get(t){return new PlacedSymbolStruct(this,t)}}Yn(PlacedSymbolArray,"PlacedSymbolArray");class SymbolInstanceStruct extends Struct{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}SymbolInstanceStruct.prototype.size=80;class SymbolInstanceArray extends StructArrayLayout2f9i15ui1ul4f1ub1ui80{get(t){return new SymbolInstanceStruct(this,t)}}Yn(SymbolInstanceArray,"SymbolInstanceArray");class GlyphOffsetArray extends StructArrayLayout1f4{getoffsetX(t){return this.float32[1*t+0]}}Yn(GlyphOffsetArray,"GlyphOffsetArray");class SymbolLineVertexArray extends StructArrayLayout2i4{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}Yn(SymbolLineVertexArray,"SymbolLineVertexArray");class FeatureIndexStruct extends Struct{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]}}FeatureIndexStruct.prototype.size=12;class FeatureIndexArray extends StructArrayLayout1ul3ui12{get(t){return new FeatureIndexStruct(this,t)}}Yn(FeatureIndexArray,"FeatureIndexArray");class FillExtrusionCentroidArray extends StructArrayLayout2ui4{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}Yn(FillExtrusionCentroidArray,"FillExtrusionCentroidArray");class FillExtrusionWallStruct extends Struct{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}FillExtrusionWallStruct.prototype.size=6;class FillExtrusionWallArray extends StructArrayLayout3i6{get(t){return new FillExtrusionWallStruct(this,t)}}Yn(FillExtrusionWallArray,"FillExtrusionWallArray");const Yi=Zi([{name:"a_pos",components:2,type:"Int16"}],4),Ji=Zi([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Ki=Zi([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class SegmentVector{constructor(t=[]){this.segments=t}_prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>SegmentVector.MAX_VERTEX_ARRAY_LENGTH&&vt(`Max vertices per segment is ${SegmentVector.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>SegmentVector.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}prepareSegment(t,e,r,n){return this._prepareSegment(t,e.length,r.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,r,n){return new SegmentVector([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Qi(t,e){return 256*(t=ht(Math.floor(t),0,255))+ht(Math.floor(e),0,255)}SegmentVector.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Yn(SegmentVector,"SegmentVector");const to=Zi([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),eo=Zi([{name:"a_pattern_b",components:4,type:"Uint16"}]),ro=Zi([{name:"a_dash",components:4,type:"Uint16"}]);var no,io,oo,so={exports:{}},ao={exports:{}},lo={exports:{}},uo=function(){if(oo)return so.exports;oo=1;var t=(no||(no=1,ao.exports=function(t,e){var r,n,i,o,s,a,l,u;for(n=t.length-(r=3&t.length),i=e,s=3432918353,a=461845907,u=0;u<n;)l=255&t.charCodeAt(u)|(255&t.charCodeAt(++u))<<8|(255&t.charCodeAt(++u))<<16|(255&t.charCodeAt(++u))<<24,++u,i=27492+(65535&(o=5*(65535&(i=(i^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),ao.exports),e=(io||(io=1,lo.exports=function(t,e){for(var r,n=t.length,i=e^n,o=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:i^=(255&t.charCodeAt(o+2))<<16;case 2:i^=(255&t.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),lo.exports);return so.exports=t,so.exports.murmur3=t,so.exports.murmur2=e,so.exports}(),co=rt(uo);class FeaturePositionMap{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(t,e,r,n){this.ids.push(ho(t)),this.positions.push(e,r,n)}eachPosition(t,e){const r=ho(t);let n=0,i=this.ids.length-1;for(;n<i;){const t=n+i>>1;this.ids[t]>=r?i=t:n=t+1}for(;this.ids[n]===r;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return po(r,n,0,r.length-1),e&&(e.add(r.buffer),e.add(n.buffer)),{ids:r,positions:n}}static deserialize(t){const e=new FeaturePositionMap;let r;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==r&&e.uniqueIds.push(t),r=t;return e.indexed=!0,e}}function ho(t){const e=+t;return Number.isSafeInteger(e)?e:co(String(t))}function po(t,e,r,n){for(;r<n;){const i=t[r+n>>1];let o=r-1,s=n+1;for(;;){do{o++}while(t[o]<i);do{s--}while(t[s]>i);if(o>=s)break;fo(t,o,s),fo(e,3*o,3*s),fo(e,3*o+1,3*s+1),fo(e,3*o+2,3*s+2)}s-r<n-s?(po(t,e,r,s),r=s+1):(po(t,e,s+1,n),n=s)}}function fo(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}Yn(FeaturePositionMap,"FeaturePositionMap");class Uniform{constructor(t){this.gl=t.gl,this.initialized=!1}fetchUniformLocation(t,e){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(t,e),this.initialized=!0),!!this.location}set(t,e,r){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class Uniform1f extends Uniform{constructor(t){super(t),this.current=0}set(t,e,r){this.fetchUniformLocation(t,e)&&this.current!==r&&(this.current=r,this.gl.uniform1f(this.location,r))}}class Uniform4f extends Uniform{constructor(t){super(t),this.current=[0,0,0,0]}set(t,e,r){this.fetchUniformLocation(t,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4f(this.location,r[0],r[1],r[2],r[3])))}}class UniformColor extends Uniform{constructor(t){super(t),this.current=Color.transparent.toPremultipliedRenderColor(null)}set(t,e,r){this.fetchUniformLocation(t,e)&&(r.r===this.current.r&&r.g===this.current.g&&r.b===this.current.b&&r.a===this.current.a||(this.current=r,this.gl.uniform4f(this.location,r.r,r.g,r.b,r.a)))}}function yo(t){return[Qi(255*t.r,255*t.g),Qi(255*t.b,255*t.a)]}function mo(t,e,r,n,i,o,s,a){return!!t&&("composite"===t.kind||"source"===t.kind?"none"===t.evaluate(new EvaluationParameters(0,{brightness:o,worldview:a}),e,r,i,n,s):"none"===t.value)}class ConstantBinder{constructor(t,e,r,n){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=r,this.context=n}setUniform(t,e,r,n,i){const o=n.constantOr(this.value);e.set(t,i,o instanceof Color?o.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):o)}getBinding(t,e){return"color"===this.type?new UniformColor(t):new Uniform1f(t)}}class PatternConstantBinder{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(t,e){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br),this.patternTransition=e?e.tl.concat(e.br):this.pattern}setUniform(t,e,r,n,i){let o=null;"u_pattern"!==i&&"u_dash"!==i||(o=this.pattern),"u_pattern_b"===i&&(o=this.patternTransition),"u_pixel_ratio"===i&&(o=this.pixelRatio),o&&e.set(t,i,o)}getBinding(t,e){return"u_pattern"===e||"u_pattern_b"===e||"u_dash"===e?new Uniform4f(t):new Uniform1f(t)}}class SourceExpressionBinder{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,r,n,i,o,s,a){const l=this.paintVertexArray.length,u="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new EvaluationParameters(0,{brightness:o,worldview:a}),e,{},i,n,s):"constant"===this.expression.kind&&this.expression.value,c=mo(this.lutExpression,e,{},n,i,o,s,a);this.paintVertexArray.resize(t),this._setPaintValue(l,t,u,c?null:this.context.lut)}updatePaintArray(t,e,r,n,i,o,s,a){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:s,worldview:a},r,n,void 0,i):"constant"===this.expression.kind&&this.expression.value,u=mo(this.lutExpression,r,n,i,void 0,s,void 0,a);this._setPaintValue(t,e,l,u?null:this.context.lut)}_setPaintValue(t,e,r,n){if("color"===this.type){const i=yo(r.toPremultipliedRenderColor(n));for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i[0],i[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,r);this.maxValue=Math.max(this.maxValue,Math.abs(r))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.lutExpression&&"constant"!==this.lutExpression.kind&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||"constant"!==this.expression.kind&&(this.expression.isStateDependent||!this.expression.isLightConstant)))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class CompositeExpressionBinder{constructor(t,e,r,n,i,o){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.context=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,r,n,i,o,s,a){const l=this.expression.evaluate(new EvaluationParameters(this.context.zoom,{brightness:o,worldview:a}),e,{},i,n,s),u=this.expression.evaluate(new EvaluationParameters(this.context.zoom+1,{brightness:o,worldview:a}),e,{},i,n,s),c=mo(this.lutExpression,e,{},n,i,o,s,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(h,t,l,u,c?null:this.context.lut)}updatePaintArray(t,e,r,n,i,o,s,a){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:s,worldview:a},r,n,void 0,i),u=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s,worldview:a},r,n,void 0,i),c=mo(this.lutExpression,r,n,i,void 0,s,void 0,a);this._setPaintValue(t,e,l,u,c?null:this.context.lut)}_setPaintValue(t,e,r,n,i){if("color"===this.type){const n=yo(r.toPremultipliedRenderColor(i)),o=yo(r.toPremultipliedRenderColor(i));for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,n[0],n[1],o[0],o[1])}else{for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r,n);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(n))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e,r,n,i){const o=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,s=ht(this.expression.interpolationFactor(o,this.context.zoom,this.context.zoom+1),0,1);e.set(t,i,s)}getBinding(t,e){return new Uniform1f(t)}}class PatternCompositeBinder{constructor(t,e,r,n,i){this.expression=t,this.layerId=i,this.paintVertexAttributes=("array"===r?ro:to).members;for(let t=0;t<e.length;++t);this.paintVertexArray=new n,this.paintTransitionVertexArray=new StructArrayLayout4ui8}populatePaintArray(t,e,r,n){const i=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValues(i,t,e.patterns&&e.patterns[this.layerId],r)}updatePaintArray(t,e,r,n,i,o,s){this._setPaintValues(t,e,r.patterns&&r.patterns[this.layerId],o)}_setPaintValues(t,e,r,n){if(!n||!r)return;const i=n[r[0]],o=n[r[1]];if(i){if(i){const{tl:r,br:n,pixelRatio:o}=i;for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1],n[0],n[1],o)}if(o){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);const{tl:r,br:n}=o;for(let i=t;i<e;i++)this.paintTransitionVertexArray.emplace(i,r[0],r[1],n[0],n[1])}}}upload(t){const e=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,e)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=t.createVertexBuffer(this.paintTransitionVertexArray,eo.members,e))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class ProgramConfiguration{constructor(t,e,r=(()=>!0)){this.binders={},this._buffers=[],this.context=e;const n=[];for(const i in t.paint._values){const o=t.paint.get(i);if(i.endsWith("-use-theme"))continue;if(!r(i))continue;if(!(o instanceof PossiblyEvaluatedPropertyValue&&cn(o.property.specification)))continue;const s=xo(i,t.type),a=o.value,l=o.property.specification.type,u=!!o.property.useIntegerZoom,c="line-dasharray"===i||i.endsWith("pattern"),h=t.paint.get(`${i}-use-theme`),p="line-dasharray"===i&&"constant"!==t.layout.get("line-cap").value.kind||h&&"constant"!==h.value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||c){const e=wo(i,l,"source");this.binders[i]=c?new PatternCompositeBinder(a,s,l,e,t.id):new SourceExpressionBinder(a,s,l,e),n.push(`/a_${i}`)}else{const t=wo(i,l,"composite");this.binders[i]=new CompositeExpressionBinder(a,s,l,u,e,t),n.push(`/z_${i}`)}else this.binders[i]=c?new PatternConstantBinder(a.value,s):new ConstantBinder(a.value,s,l,e),n.push(`/u_${i}`);h&&(this.binders[i].lutExpression=h.value)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof SourceExpressionBinder||e instanceof CompositeExpressionBinder?e.maxValue:0}populatePaintArrays(t,e,r,n,i,o,s,a){for(const l in this.binders){const u=this.binders[l];u.context=this.context,(u instanceof SourceExpressionBinder||u instanceof CompositeExpressionBinder||u instanceof PatternCompositeBinder)&&u.populatePaintArray(t,e,r,n,i,o,s,a)}}setConstantPatternPositions(t,e){for(const r in this.binders){const n=this.binders[r];n instanceof PatternConstantBinder&&n.setConstantPatternPositions(t,e)}}getPatternTransitionVertexBuffer(t){const e=this.binders[t];return e instanceof PatternCompositeBinder?e.paintTransitionVertexBuffer:null}updatePaintArrays(t,e,r,n,i,o,s,a,l,u){let c=!1;const h=Object.keys(t),p=0!==h.length&&!a,d=p?h:e.uniqueIds;this.context.lut=i.lut;for(const a in this.binders){const h=this.binders[a];if(h.context=this.context,(h instanceof SourceExpressionBinder||h instanceof CompositeExpressionBinder||h instanceof PatternCompositeBinder)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const f=i.paint.get(a);h.expression=f.value;for(const r of d){const i=t[r.toString()];e.eachPosition(r,((t,e,r)=>{const a=n.feature(t);h.updatePaintArray(e,r,a,i,o,s,l,u)}))}if(!p)for(const e of r.uniqueIds){const i=t[e.toString()];r.eachPosition(e,((t,e,r)=>{const a=n.feature(t);h.updatePaintArray(e,r,a,i,o,s,l,u)}))}c=!0}}return c}defines(){const t=[];for(const e in this.binders){const r=this.binders[e];(r instanceof ConstantBinder||r instanceof PatternConstantBinder)&&t.push(...r.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t){const e=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof ConstantBinder||n instanceof PatternConstantBinder||n instanceof CompositeExpressionBinder)for(const i of n.uniformNames)e.push({name:i,property:r,binding:n.getBinding(t,i)})}return e}setUniforms(t,e,r,n,i){for(const{name:e,property:o,binding:s}of r)this.binders[o].setUniform(t,s,i,n.get(o),e)}updatePaintBuffers(){this._buffers=[];for(const t in this.binders){const e=this.binders[t];(e instanceof SourceExpressionBinder||e instanceof CompositeExpressionBinder||e instanceof PatternCompositeBinder)&&e.paintVertexBuffer&&this._buffers.push(e.paintVertexBuffer),e instanceof PatternCompositeBinder&&e.paintTransitionVertexBuffer&&this._buffers.push(e.paintTransitionVertexBuffer)}}upload(t){for(const e in this.binders){const r=this.binders[e];(r instanceof SourceExpressionBinder||r instanceof CompositeExpressionBinder||r instanceof PatternCompositeBinder)&&r.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof SourceExpressionBinder||e instanceof CompositeExpressionBinder||e instanceof PatternCompositeBinder)&&e.destroy()}}}class ProgramConfigurationSet{constructor(t,e,r=(()=>!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new ProgramConfiguration(n,e,r);this.needsUpload=!1,this._featureMap=new FeaturePositionMap,this._featureMapWithoutIds=new FeaturePositionMap,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(t,e,r,n,i,o,s,a,l){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,o,s,a,l);void 0!==e.id?this._featureMap.add(e.id,r,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,r,n,i,o,s,a){for(const l of r)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,l,n,i,o,s||0,a)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const go={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function xo(t,e){return go[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const vo={"line-pattern":{source:StructArrayLayout4ui1f12,composite:StructArrayLayout4ui1f12},"fill-pattern":{source:StructArrayLayout4ui1f12,composite:StructArrayLayout4ui1f12},"fill-extrusion-pattern":{source:StructArrayLayout4ui1f12,composite:StructArrayLayout4ui1f12},"line-dasharray":{source:StructArrayLayout4ui8,composite:StructArrayLayout4ui8}},bo={color:{source:StructArrayLayout2f8,composite:StructArrayLayout4f16},number:{source:StructArrayLayout1f4,composite:StructArrayLayout2f8}};function wo(t,e,r){const n=vo[t];return n&&n[r]||bo[e][r]}Yn(ConstantBinder,"ConstantBinder"),Yn(PatternConstantBinder,"PatternConstantBinder"),Yn(SourceExpressionBinder,"SourceExpressionBinder"),Yn(PatternCompositeBinder,"PatternCompositeBinder"),Yn(CompositeExpressionBinder,"CompositeExpressionBinder"),Yn(ProgramConfiguration,"ProgramConfiguration",{omit:["_buffers"]}),Yn(ProgramConfigurationSet,"ProgramConfigurationSet");const _o=Ue/Math.PI/2,Ao=5,So=6,Io=16383,Po=-_o,Mo=_o;function Do(t,e,r,n=_o){return r=ut(r),[t*Math.sin(r)*n,-e*n,t*Math.cos(r)*n]}function Eo(t,e,r){return Do(Math.cos(ut(t)),Math.sin(ut(t)),e,r)}const Co=6371008.8,Bo=2*Math.PI*Co;class LngLat{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new LngLat(dt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Co*Math.acos(Math.min(i,1))}toBounds(t=0){const e=360*t/40075017,r=e/Math.cos(Math.PI/180*this.lat);return new LngLatBounds({lng:this.lng-r,lat:this.lat-e},{lng:this.lng+r,lat:this.lat+e})}toEcef(t){return Eo(this.lat,this.lng,_o+t*_o/Co)}static convert(t){if(t instanceof LngLat)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new LngLat(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new LngLat(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class LngLatBounds{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof LngLat?new LngLat(t.lng,t.lat):LngLat.convert(t),this}setSouthWest(t){return this._sw=t instanceof LngLat?new LngLat(t.lng,t.lat):LngLat.convert(t),this}extend(t){const e=this._sw,r=this._ne;let n,i;if(t instanceof LngLat)n=t,i=t;else{if(!(t instanceof LngLatBounds))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(LngLatBounds.convert(t)):this.extend(LngLat.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(LngLat.convert(t)):this;if(n=t._sw,i=t._ne,!n||!i)return this}return e||r?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),r.lng=Math.max(i.lng,r.lng),r.lat=Math.max(i.lat,r.lat)):(this._sw=new LngLat(n.lng,n.lat),this._ne=new LngLat(i.lng,i.lat)),this}getCenter(){return new LngLat((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 LngLat(this.getWest(),this.getNorth())}getSouthEast(){return new LngLat(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:r}=LngLat.convert(t);let n=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(t){if(t)return t instanceof LngLatBounds?t:new LngLatBounds(t)}}const To=0,ko=25.5;function zo(t){return Bo*Math.cos(t*Math.PI/180)}function Lo(t){return(180+t)/360}function Vo(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Fo(t,e){return t/zo(e)}function Ro(t){return 360*t-180}function Oo(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}const Uo=85.051129;function No(t){return Math.cos(ut(ht(t,-Uo,Uo)))}function jo(t,e){const r=ht(e,To,ko),n=Math.pow(2,r);return No(t)*Bo/(512*n)}function Go(t,e=0){const r=Math.exp(Math.PI*(1-(t.y+e/Ue)/(1<<t.z)*2));return 80150034*r/(r*r+1)/Ue/(1<<t.z)}class MercatorCoordinate{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r}static fromLngLat(t,e=0){const r=LngLat.convert(t);return new MercatorCoordinate(Lo(r.lng),Vo(r.lat),Fo(e,r.lat))}toLngLat(){return new LngLat(Ro(this.x),Oo(this.y))}toAltitude(){return this.z*zo(Oo(this.y))}meterInMercatorCoordinateUnits(){return 1/Bo*(t=Oo(this.y),1/Math.cos(t*Math.PI/180));var t}}function $o(t,e,r,n,i,o,s,a,l){const u=(e+n)/2,c=(r+i)/2,h=new ot(u,c);a(h),function(t,e,r,n,i,o){const s=r-i,a=n-o;return Math.abs((n-e)*s-(r-t)*a)/Math.hypot(s,a)}(h.x,h.y,o.x,o.y,s.x,s.y)>=l?($o(t,e,r,u,c,o,h,a,l),$o(t,u,c,n,i,h,s,a,l)):t.push(s)}function qo(t,e,r){let n=t[0],i=n.x,o=n.y;e(n);const s=[n];for(let a=1;a<t.length;a++){const l=t[a],{x:u,y:c}=l;e(l),$o(s,i,o,u,c,n,l,e,r),i=u,o=c,n=l}return s}function Ho(t,e,r,n){if(n(e,r)){const i=e.add(r)._mult(.5);Ho(t,e,i,n),Ho(t,i,r,n)}else t.push(r)}function Xo(t,e){let r=t[0];const n=[r];for(let i=1;i<t.length;i++){const o=t[i];Ho(n,r,o,e),r=o}return n}const Zo=Math.pow(2,14)-1,Wo=-Zo-1;function Yo(t,e){const r=Math.round(t.x*e),n=Math.round(t.y*e);return t.x=ht(r,Wo,Zo),t.y=ht(n,Wo,Zo),(r<t.x||r>t.x+1||n<t.y||n>t.y+1)&&vt("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Jo(t,e,r){const n=t.loadGeometry(),i=t.extent,o=Ue/i;if(e&&r&&r.projection.isReprojectedInTileSpace){const o=1<<e.z,{scale:s,x:a,y:l,projection:u}=r,c=t=>{const r=Ro((e.x+t.x/i)/o),n=Oo((e.y+t.y/i)/o),c=u.project(r,n);t.x=(c.x*s-a)*i,t.y=(c.y*s-l)*i};for(let e=0;e<n.length;e++)if(1!==t.type)n[e]=qo(n[e],c,1);else{const t=[];for(const r of n[e])r.x<0||r.x>=i||r.y<0||r.y>=i||(c(r),t.push(r));n[e]=t}}for(const t of n)for(const e of t)Yo(e,o);return n}function Ko(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Jo(t):[]}}class VectorTileFeature{constructor(t,e,r,n,i){this.properties={},this.extent=r,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=i,t.readFields(Qo,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos,r=[];let n,i=1,o=0,s=0,a=0;for(;t.pos<e;){if(o<=0){const e=t.readVarint();i=7&e,o=e>>3}if(o--,1===i||2===i)s+=t.readSVarint(),a+=t.readSVarint(),1===i&&(n&&r.push(n),n=[]),n&&n.push(new ot(s,a));else{if(7!==i)throw new Error(`unknown command ${i}`);n&&n.push(n[0].clone())}}return n&&r.push(n),r}bbox(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let r=1,n=0,i=0,o=0,s=1/0,a=-1/0,l=1/0,u=-1/0;for(;t.pos<e;){if(n<=0){const e=t.readVarint();r=7&e,n=e>>3}if(n--,1===r||2===r)i+=t.readSVarint(),o+=t.readSVarint(),i<s&&(s=i),i>a&&(a=i),o<l&&(l=o),o>u&&(u=o);else if(7!==r)throw new Error(`unknown command ${r}`)}return[s,l,a,u]}toGeoJSON(t,e,r){const n=this.extent*Math.pow(2,r),i=this.extent*t,o=this.extent*e,s=this.loadGeometry();function a(t){return[360*(t.x+i)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+o)/n)*Math.PI))-90]}function l(t){return t.map(a)}let u;if(1===this.type){const t=[];for(const e of s)t.push(e[0]);const e=l(t);u=1===t.length?{type:"Point",coordinates:e[0]}:{type:"MultiPoint",coordinates:e}}else if(2===this.type){const t=s.map(l);u=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}}else{if(3!==this.type)throw new Error("unknown feature type");{const t=function(t){const e=t.length;if(e<=1)return[t];const r=[];let n,i;for(let o=0;o<e;o++){const e=ts(t[o]);0!==e&&(void 0===i&&(i=e<0),i===e<0?(n&&r.push(n),n=[t[o]]):n&&n.push(t[o]))}return n&&r.push(n),r}(s),e=[];for(const r of t)e.push(r.map(l));u=1===e.length?{type:"Polygon",coordinates:e[0]}:{type:"MultiPolygon",coordinates:e}}}const c={type:"Feature",geometry:u,properties:this.properties};return null!=this.id&&(c.id=this.id),c}}function Qo(t,e,r){1===t?e.id=r.readVarint():2===t?function(t,e){const r=t.readVarint()+t.pos;for(;t.pos<r;){const r=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[r]=n}}(r,e):3===t?e.type=r.readVarint():4===t&&(e._geometry=r.pos)}function ts(t){let e=0;for(let r,n,i=0,o=t.length,s=o-1;i<o;s=i++)r=t[i],n=t[s],e+=(n.x-r.x)*(r.y+n.y);return e}VectorTileFeature.types=["Unknown","Point","LineString","Polygon"];class VectorTileLayer{constructor(t,e){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(es,this,e),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const e=this._pbf.readVarint()+this._pbf.pos;return new VectorTileFeature(this._pbf,e,this.extent,this._keys,this._values)}}function es(t,e,r){15===t?e.version=r.readVarint():1===t?e.name=r.readString():5===t?e.extent=r.readVarint():2===t?e._features.push(r.pos):3===t?e._keys.push(r.readString()):4===t&&e._values.push(function(t){let e=null;const r=t.readVarint()+t.pos;for(;t.pos<r;){const r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}if(null==e)throw new Error("unknown feature value");return e}(r))}class VectorTile{constructor(t,e){this.layers=t.readFields(rs,{},e)}}function rs(t,e,r){if(3===t){const t=new VectorTileLayer(r,r.readVarint()+r.pos);t.length&&(e[t.name]=t)}}const ns="3d_elevation_id",is="level",os="hd_road_elevation";class PropertyParser{constructor(){this._valid=!1}reset(t){return this.feature=t,this._valid=!0,this._geometry=t.loadGeometry(),0!==this._geometry.length&&0!==this._geometry[0].length||(this._valid=!1),this}geometry(t,e){return this._valid&&t(e(this._geometry)),this}require(t,e,r){return this.get(t,!0,e,r)}optional(t,e,r){return this.get(t,!1,e,r)}success(){return this._valid}get(t,e,r,n){const i=this.feature.properties.hasOwnProperty(t)?+this.feature.properties[t]:void 0;return this._valid&&void 0!==i&&!Number.isNaN(i)?r(n?n(i):i):e&&(this._valid=!1),this}}class VersionSchema{constructor(t,e){this.featureFunc=t,this.vertexFunc=e}parseFeature(t,e,r){return this.featureFunc(t,e,r)}parseVertex(t,e,r){return this.vertexFunc(t,e,r)}}const ss=new VersionSchema(((t,e,r)=>t.reset(e).require(ns,(t=>{r.id=t})).optional("fixed_height_relative",(t=>{r.constantHeight=t}),ElevationFeatureParser.decodeRelativeHeight).geometry((t=>{r.bounds=t}),we).success()),((t,e,r)=>t.reset(e).require(ns,(t=>{r.id=t})).require("elevation_idx",(t=>{r.idx=t})).require("extent",(t=>{r.extent=t})).require("height_relative",(t=>{r.height=t}),ElevationFeatureParser.decodeRelativeHeight).geometry((t=>{r.position=t}),ElevationFeatureParser.getPoint).success())),as=new VersionSchema(((t,e,r)=>t.reset(e).require(ns,(t=>{r.id=t})).optional("fixed_height",(t=>{r.constantHeight=t}),ElevationFeatureParser.decodeMetricHeight).geometry((t=>{r.bounds=t}),we).success()),((t,e,r)=>t.reset(e).require(ns,(t=>{r.id=t})).require("elevation_idx",(t=>{r.idx=t})).require("extent",(t=>{r.extent=t})).require("height",(t=>{r.height=t}),ElevationFeatureParser.decodeMetricHeight).geometry((t=>{r.position=t}),ElevationFeatureParser.getPoint).success()));class ElevationFeatureParser{static getPoint(t){return Z(t[0][0].x,t[0][0].y)}static decodeRelativeHeight(t){return 1e-4*t*5}static decodeMetricHeight(t){return 1e-4*t}static getVersionSchema(t){return t?"1.0.1"===t?as:void 0:ss}static parse(t){const e=[],r=[],n=t.length,i=new PropertyParser;for(let o=0;o<n;o++){const n=t.feature(o),s=n.properties.version,a=ElevationFeatureParser.getVersionSchema(s);if(void 0===a){vt(`Unknown elevation feature version number ${s||"(unknown)"}`);continue}const l=n.properties.type;if(!l)continue;const u=VectorTileFeature.types[n.type];if("Point"===u&&"curve_point"===l){const t={};a.parseVertex(i,n,t)&&e.push(t)}else if("Polygon"===u&&"curve_meta"===l){const t={};a.parseFeature(i,n,t)&&r.push(t)}}return{vertices:e,features:r}}}class Ray2D{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,r){const n=et(e,this.dir);if(Math.abs(n)<1e-6)return!1;const i=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1])/n;return r[0]=this.pos[0]+this.dir[0]*i,r[1]=this.pos[1]+this.dir[1]*i,!0}}class Ray{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,r){const n=D(e,this.dir);if(Math.abs(n)<1e-6)return!1;const i=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[2])/n;return r[0]=this.pos[0]+this.dir[0]*i,r[1]=this.pos[1]+this.dir[1]*i,r[2]=this.pos[2]+this.dir[2]*i,!0}closestPointOnSphere(e,r,n){if(function(e,r){var n=e[0],i=e[1],o=e[2],s=r[0],a=r[1],l=r[2];return Math.abs(n-s)<=t*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-a)<=t*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-l)<=t*Math.max(1,Math.abs(o),Math.abs(l))}(this.pos,e)||0===r)return n[0]=n[1]=n[2]=0,!1;const[i,o,s]=this.dir,a=this.pos[0]-e[0],l=this.pos[1]-e[1],u=this.pos[2]-e[2],c=i*i+o*o+s*s,h=2*(a*i+l*o+u*s),p=h*h-4*c*(a*a+l*l+u*u-r*r);if(p<0){const t=Math.max(-h/2,0),e=a+i*t,c=l+o*t,p=u+s*t,d=Math.hypot(e,c,p);return n[0]=e*r/d,n[1]=c*r/d,n[2]=p*r/d,!1}{const t=(-h-Math.sqrt(p))/(2*c);if(t<0){const t=Math.hypot(a,l,u);return n[0]=a*r/t,n[1]=l*r/t,n[2]=u*r/t,!1}return n[0]=a+i*t,n[1]=l+o*t,n[2]=u+s*t,!0}}}function ls(t,e,r){let n=1/0,i=-1/0;const o=[];for(const s of t){L(o,s,e);const t=D(o,r);n=Math.min(n,t),i=Math.max(i,t)}return[n,i]}function us(t,e){let r=!0;for(let n=0;n<t.planes.length;n++){const i=t.planes[n];let o=0;for(let t=0;t<e.length;t++)o+=+(D(i,e[t])+i[3]>=0);if(0===o)return 0;o!==e.length&&(r=!1)}return r?2:1}function cs(t,e){for(const r of t.projections){const n=ls(e,t.points[0],r.axis);if(r.projection[1]<n[0]||r.projection[0]>n[1])return 0}return 1}class Aabb{static fromPoints(t){const e=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const n of t)b(e,e,n),w(r,r,n);return new Aabb(e,r)}static fromTileIdAndHeight(t,e,r){const n=1<<t.canonical.z,i=t.canonical.x,o=t.canonical.y;return new Aabb([i/n,o/n,e],[(i+1)/n,(o+1)/n,r])}static applyTransform(t,e){const r=t.getCorners();for(let t=0;t<r.length;++t)B(r[t],r[t],e);return Aabb.fromPoints(r)}static applyTransformFast(t,e){const r=[e[12],e[13],e[14]],n=[...r];for(let i=0;i<3;i++)for(let o=0;o<3;o++){const s=e[4*o+i],a=s*t.min[o],l=s*t.max[o];r[i]+=Math.min(a,l),n[i]+=Math.max(a,l)}return new Aabb(r,n)}static projectAabbCorners(t,e){const r=t.getCorners();for(let t=0;t<r.length;++t)B(r[t],r[t],e);return r}constructor(t,e){this.min=t,this.max=e,this.center=_([],x([],this.min,this.max),.5)}quadrant(t){const e=[t%2==0,t<2],r=f(this.min),n=f(this.max);for(let t=0;t<e.length;t++)r[t]=e[t]?this.min[t]:this.center[t],n[t]=e[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new Aabb(r,n)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}getCorners(){const t=this.min,e=this.max;return[[t[0],t[1],t[2]],[e[0],t[1],t[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],e[2]],[t[0],e[1],e[2]]]}intersects(t){return this.intersectsAabb(t.bounds)?us(t,this.getCorners()):0}intersectsFlat(t){return this.intersectsAabb(t.bounds)?us(t,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(t,e){return e||this.intersects(t)?cs(t,this.getCorners()):0}intersectsPreciseFlat(t,e){return e||this.intersectsFlat(t)?cs(t,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(t){for(let e=0;e<3;++e)if(this.min[e]>t.max[e]||t.min[e]>this.max[e])return!1;return!0}intersectsAabbXY(t){return!(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t.min[e]),this.max[e]=Math.max(this.max[e],t.max[e])}encapsulatePoint(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t[e]),this.max[e]=Math.max(this.max[e],t[e])}closestPoint(t){return[Math.max(Math.min(this.max[0],t[0]),this.min[0]),Math.max(Math.min(this.max[1],t[1]),this.min[1]),Math.max(Math.min(this.max[2],t[2]),this.min[2])]}}Yn(Aabb,"Aabb");class EdgeIterator{constructor(t,e){this.feature=t,this.metersToTile=e,this.index=0}get(){const t=this.feature.vertices[this.index],e=this.feature.vertexProps[this.index].dir,r=e[1],n=-e[0],i=(t.extent+1)*this.metersToTile;return[new ot(Math.trunc(t.position[0]+r*i),Math.trunc(t.position[1]+n*i)),new ot(Math.trunc(t.position[0]-r*i),Math.trunc(t.position[1]-n*i))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class ElevationFeature{constructor(t,e,r,n,i,o){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this._tmpVec2=[X(),X(),X(),X(),X(),X(),X()],this.id=t,this.heightRange={min:r,max:r},this.safeArea=e,this.constantHeight=r,null==this.constantHeight&&(null!=this.constantHeight||0!==n.length)){this.vertices=n,this.edges=i,this.edges=this.edges.filter((t=>{return t.a<this.vertices.length&&t.b<this.vertices.length&&!((e=this.vertices[t.a].position)[0]===(r=this.vertices[t.b].position)[0]&&e[1]===r[1]);var e,r})),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(const t of this.vertices)this.vertexProps.push({dir:Z(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,t.height),this.heightRange.max=Math.max(this.heightRange.max,t.height);for(const t of this.edges){const e=this.vertices[t.a].position,r=this.vertices[t.b].position,n=J(X(),r,e),i=Q(n),o=K(X(),n,1/i);this.edgeProps.push({vec:n,dir:o,len:i});const s=this.vertexProps[t.a].dir,a=this.vertexProps[t.b].dir;Y(s,s,o),Y(a,a,o)}for(const t of this.vertexProps)0===t.dir[0]&&0===t.dir[1]||tt(t.dir,t.dir);this.tessellate(o)}}pointElevation(t){if(null!=this.constantHeight)return this.constantHeight;const e=this.getClosestEdge(t);if(null==e)return 0;const[r,n]=e;return Vt(this.vertices[this.edges[r].a].height,this.vertices[this.edges[r].b].height,n)}computeSlopeNormal(t,e){const r=this.getClosestEdge(t);if(!r)return m(0,0,1);const n=r[0],i=this.edges[n],o=this.edgeProps[n].vec,s=m(o[0],o[1],(this.vertices[i.b].height-this.vertices[i.a].height)*e),a=m(s[1],-s[0],0);E(a,a,s);const l=y(a);return l>0?_(a,a,1/l):g(a,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(t){if(0===this.edges.length)return;let e=0,r=Number.POSITIVE_INFINITY,n=0;const[i,o,s,a,l,u,c]=this._tmpVec2;W(c,t.x,t.y);const h=new Ray2D(c,null);for(let t=0;t<this.edges.length;t++){const p=this.edges[t],d=this.edgeProps[t].dir;h.dir=d;const f=this.vertices[p.a].position,y=this.vertices[p.b].position,m=h.intersectsPlane(f,this.vertexProps[p.a].dir,i),g=h.intersectsPlane(y,this.vertexProps[p.b].dir,o);if(!m||!g)continue;J(s,o,i),J(a,c,i);const x=et(s,s),v=x>0?et(a,s)/x:0,b=ht(v,0,1),w=Math.abs((v-b)*this.edgeProps[t].len);J(l,c,f),W(u,d[1],-d[0]);const _=w+Math.abs(et(l,u));_<r&&(e=t,r=_,n=b)}return[e,n]}tessellate(t){const e=d(),r=d(),n=d(),i=d();for(let o=this.edges.length-1;o>=0;--o){const s=this.edges[o].a,a=this.edges[o].b,{position:l,height:u,extent:c}=this.vertices[s],{position:h,height:p,extent:d}=this.vertices[a],f=this.vertexProps[s].dir,y=this.vertexProps[a].dir;if(g(e,l[0]/t,l[1]/t,u),g(r,h[0]/t,h[1]/t,p),g(n,f[1],-f[0],0),_(n,n,c),g(i,y[1],-y[0],0),_(i,i,d),this.distSqLines(m(e[0]+.5*n[0],e[1]+.5*n[1],e[2]+.5*n[2]),m(r[0]-.5*i[0],r[1]-.5*i[1],r[2]-.5*i[2]),m(e[0]-.5*n[0],e[1]-.5*n[1],e[2]-.5*n[2]),m(r[0]+.5*i[0],r[1]+.5*i[1],r[2]+.5*i[2]))<=.0025000000000000005)continue;const x=this.vertices.length,v=Y(X(),l,h);this.vertices.push({position:K(v,v,.5),height:.5*(u+p),extent:.5*(c+d)});const b=Y(X(),f,y);this.vertexProps.push({dir:tt(b,b)}),this.edges.splice(o,1),this.edgeProps.splice(o,1),this.edges.push({a:s,b:x}),this.edges.push({a:x,b:a});const w=J(X(),this.vertices[x].position,l),A=Q(w),S={vec:w,dir:K(X(),w,1/A),len:A};this.edgeProps.push(S),this.edgeProps.push(S)}}distSqLines(t,e,r,n){const i=v(d(),e,t),o=v(d(),n,r),s=v(d(),t,r),a=D(i,i),l=D(i,o),u=D(i,s),c=D(o,o),h=D(o,s),p=a*c-l*l;if(0===p)return I(C(i,r,n,D(s,o)/D(o,o)),t);const f=(a*h-l*u)/p;return I(C(i,t,e,(l*h-u*c)/p),C(o,r,n,f))}}class ElevationFeatures{static parseFrom(t,e){const r=ElevationFeatureParser.parse(t);if(!r)return[];let{vertices:n,features:i}=r;const o=1/Go(e);i.sort(((t,e)=>t.id-e.id)),n.sort(((t,e)=>t.id-e.id||t.idx-e.idx)),n=n.filter(((t,e,r)=>e===r.findIndex((e=>e.id===t.id&&e.idx===t.idx))));const s=new Array;let a=0;const l=n.length;for(const t of i){if(t.constantHeight){s.push(new ElevationFeature(t.id,t.bounds,t.constantHeight));continue}for(;a!==l&&n[a].id<t.id;)a++;if(a===l||n[a].id!==t.id)continue;const e=new Array,r=new Array,i=a;for(;a!==l&&n[a].id===t.id;){const t=n[a];if(e.push({position:t.position,height:t.height,extent:t.extent}),a!==i&&n[a-1].idx===t.idx-1){const t=a-i;r.push({a:t-1,b:t})}a++}s.push(new ElevationFeature(t.id,t.bounds,void 0,e,r,o))}return s}static getElevationFeature(t,e){if(!e)return;const r=+t.properties[ns];return Number.isNaN(r)?void 0:e.find((t=>t.id===r))}}class ElevationFeatureSampler{constructor(t,e){this.zScale=1,this.xOffset=0,this.yOffset=0,t.equals(e)||(this.zScale=Math.pow(2,e.z-t.z),this.xOffset=(t.x*this.zScale-e.x)*Ue,this.yOffset=(t.y*this.zScale-e.y)*Ue)}constantElevation(t,e){if(null!=t.constantHeight)return this.computeBiasedHeight(t.constantHeight,e)}pointElevation(t,e,r){const n=this.constantElevation(e,r);return null!=n?n:(t.x=t.x*this.zScale+this.xOffset,t.y=t.y*this.zScale+this.yOffset,this.computeBiasedHeight(e.pointElevation(t),r))}computeBiasedHeight(t,e){return e<=0?t:t+e*pt(0,e,t>=0?t:Math.abs(.5*t))}}Yn(ElevationFeature,"ElevationFeature");class CircleBucket{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new StructArrayLayout2i4,this.indexArray=new StructArrayLayout3ui6,this.segments=new SegmentVector,this.programConfigurations=new ProgramConfigurationSet(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,"none"!==this.elevationMode&&(this.elevatedLayoutVertexArray=new StructArrayLayout1f4),this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,e){}updateAppearances(t,e,r,n){}populate(t,e,r,n){const i=this.layers[0],o=[];let s=null;"circle"===i.type&&(s=i.layout.get("circle-sort-key"));for(const{feature:i,id:a,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Ko(i,t);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:e.activeFloors}),c,r))continue;const h=s?s.evaluate(c,{},r):void 0,p={id:a,properties:i.properties,type:i.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Jo(i,r,n),patterns:{},sortKey:h};o.push(p)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new StructArrayLayout6i12,a=n.projection);for(const n of o){const{geometry:i,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,i,o,e.availableImages,r,a,e.brightness,e.elevationFeatures),e.featureIndex.insert(l,i,o,s,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(t,e,r,n,i,o,s){this.programConfigurations.updatePaintArrays(t,e,i,r,n,o,s,this.worldview)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Yi.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Ki.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=t.createVertexBuffer(this.elevatedLayoutVertexArray,Ji.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(t,e,r,n,i,o,s,a){let l;"none"!==this.elevationMode&&(l=ElevationFeatures.getElevationFeature(t,a));for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=Ue||n<0||n>=Ue)continue;if(o){const t=o.projectTilePoint(r,n,i),e=o.upVector(i,r,n);this.addGlobeExtVertex(t,e),this.addGlobeExtVertex(t,e),this.addGlobeExtVertex(t,e),this.addGlobeExtVertex(t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;if(this.addCircleVertex(r,n,-1,-1),this.addCircleVertex(r,n,1,-1),this.addCircleVertex(r,n,1,1),this.addCircleVertex(r,n,-1,1),"none"!==this.elevationMode){const t=l?l.pointElevation(new ot(r,n)):0;this.hasElevation=this.hasElevation||0!==t;for(let e=0;e<4;e++)this.elevatedLayoutVertexArray.emplaceBack(t)}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,t,r,{},n,i,s,void 0,this.worldview)}addCircleVertex(t,e,r,n){this.layoutVertexArray.emplaceBack(2*t+(r+1)/2,2*e+(n+1)/2)}addGlobeExtVertex(t,e){const r=16384;this.globeExtVertexArray.emplaceBack(t.x,t.y,t.z,e[0]*r,e[1]*r,e[2]*r)}}function hs(t,e){for(let r=0;r<t.length;r++)if(_s(e,t[r]))return!0;for(let r=0;r<e.length;r++)if(_s(t,e[r]))return!0;return!!ys(t,e)}function ps(t,e,r){return!!_s(t,e)||!!vs(e,t,r)}function ds(t,e){if(1===t.length)return ws(e,t[0]);for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++)if(_s(t,n[e]))return!0}for(let r=0;r<t.length;r++)if(ws(e,t[r]))return!0;for(let r=0;r<e.length;r++)if(ys(t,e[r]))return!0;return!1}function fs(t,e,r){if(t.length>1){if(ys(t,e))return!0;for(let n=0;n<e.length;n++)if(vs(e[n],t,r))return!0}for(let n=0;n<t.length;n++)if(vs(t[n],e,r))return!0;return!1}function ys(t,e){if(0===t.length||0===e.length)return!1;for(let r=0;r<t.length-1;r++){const n=t[r],i=t[r+1];for(let t=0;t<e.length-1;t++)if(ms(n,i,e[t],e[t+1]))return!0}return!1}function ms(t,e,r,n){return bt(t,r,n)!==bt(e,r,n)&&bt(t,e,r)!==bt(t,e,n)}function gs(t,e,r){return(t.x-r.x)*(e.y-r.y)-(t.y-r.y)*(e.x-r.x)}function xs(t,e,r,n){const i=gs(t,e,n),o=gs(t,e,r);if(Math.sign(i)===Math.sign(o))return;const s=gs(r,n,t),a=s+o-i;return Math.sign(s)!==Math.sign(a)?[s/(s-a),o/(o-i)]:void 0}function vs(t,e,r){const n=r*r;if(1===e.length)return t.distSqr(e[0])<n;for(let r=1;r<e.length;r++)if(bs(t,e[r-1],e[r])<n)return!0;return!1}function bs(t,e,r){const n=e.distSqr(r);if(0===n)return t.distSqr(e);const i=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/n;return t.distSqr(i<0?e:i>1?r:r.sub(e)._mult(i)._add(e))}function ws(t,e){let r,n,i,o=!1;for(let s=0;s<t.length;s++){r=t[s];for(let t=0,s=r.length-1;t<r.length;s=t++)n=r[t],i=r[s],n.y>e.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(o=!o)}return o}function _s(t,e){let r=!1;for(let n=0,i=t.length-1;n<t.length;i=n++){const o=t[n],s=t[i];o.y>e.y!=s.y>e.y&&e.x<(s.x-o.x)*(e.y-o.y)/(s.y-o.y)+o.x&&(r=!r)}return r}function As(t,e,r){const n=r[0],i=r[2];if(t.x<n.x&&e.x<n.x||t.x>i.x&&e.x>i.x||t.y<n.y&&e.y<n.y||t.y>i.y&&e.y>i.y)return!1;const o=bt(t,e,r[0]);return o!==bt(t,e,r[1])||o!==bt(t,e,r[2])||o!==bt(t,e,r[3])}function Ss(t,e,r,n,i,o){let s=e.y-t.y,a=t.x-e.x;if(o=o||0){const t=s*s+a*a;if(0===t)return!0;const e=Math.sqrt(t);s/=e,a/=e}return!((r.x-t.x)*s+(r.y-t.y)*a-o<0||(n.x-t.x)*s+(n.y-t.y)*a-o<0||(i.x-t.x)*s+(i.y-t.y)*a-o<0)}function Is(t,e,r,n,i,o,s){return!(Ss(t,e,n,i,o,s)||Ss(e,r,n,i,o,s)||Ss(r,t,n,i,o,s)||Ss(n,i,t,e,r,s)||Ss(i,o,t,e,r,s)||Ss(o,n,t,e,r,s))}function Ps(t,e,r){const n=e.paint.get(t).value;return"constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function Ms(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ds(t,e,r,n,i){if(!e[0]&&!e[1])return t;const o=ot.convert(e)._mult(i);"viewport"===r&&o._rotate(-n);const s=[];for(let e=0;e<t.length;e++)s.push(t[e].sub(o));return s}function Es(t,e,r,n){const i=ot.convert(t)._mult(n);return"viewport"===e&&i._rotate(-r),i}let Cs,Bs;function Ts(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}Yn(CircleBucket,"CircleBucket",{omit:["layers"]});class CanonicalTileID{constructor(t,e,r){this.z=t,this.x=e,this.y=r,this.key=ks(0,t,t,e,r)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}isChildOf(t){const e=this.z-t.z;return 0===t.z||t.z<this.z&&t.x===this.x>>e&&t.y===this.y>>e}url(t,e){const r=function(t,e,r){var n=Ts(256*t,256*(e=Math.pow(2,r)-e-1),r),i=Ts(256*(t+1),256*(e+1),r);return n[0]+","+n[1]+","+i[0]+","+i[1]}(this.x,this.y,this.z),n=function(t,e,r){let n,i="";for(let o=t;o>0;o--)n=1<<o-1,i+=(e&n?1:0)+(r&n?2:0);return i}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===e?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",n).replace("{bbox-epsg-3857}",r)}toString(){return`${this.z}/${this.x}/${this.y}`}}class UnwrappedTileID{constructor(t,e){this.wrap=t,this.canonical=e,this.key=ks(t,e.z,e.z,e.x,e.y)}}class OverscaledTileID{constructor(t,e,r,n,i){this.overscaledZ=t,this.wrap=e,this.canonical=new CanonicalTileID(r,+n,+i),this.key=0===e&&t===r?this.canonical.key:ks(e,t,r,n,i)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){const e=this.canonical.z-t;return t>this.canonical.z?new OverscaledTileID(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new OverscaledTileID(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return ks(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-t;return ks(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.z<this.canonical.z&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new OverscaledTileID(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return[new OverscaledTileID(e,this.wrap,e,r,n),new OverscaledTileID(e,this.wrap,e,r+1,n),new OverscaledTileID(e,this.wrap,e,r,n+1),new OverscaledTileID(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new OverscaledTileID(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new OverscaledTileID(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new UnwrappedTileID(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function ks(t,e,r,n,i){const o=1<<Math.min(r,22);let s=o*(i%o)+n%o;return t&&r<22&&(s+=o*o*((t<0?-2*t-1:2*t)%(1<<2*(22-r)))),16*(32*s+r)+(e-r)}Yn(CanonicalTileID,"CanonicalTileID"),Yn(OverscaledTileID,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]}),Zi([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),Zi([{name:"a_pos_3",components:3,type:"Int16"}]),Zi([{name:"a_pos",type:"Int16",components:2}]);const zs=[new Aabb([Po,Po,Po],[Mo,Mo,Mo]),new Aabb([Po,Po,Po],[0,0,Mo]),new Aabb([0,Po,Po],[Mo,0,Mo]),new Aabb([Po,0,Po],[0,Mo,Mo]),new Aabb([0,0,Po],[Mo,Mo,Mo])];function Ls(t,e,r,n=!0){const i=_([],t._camera.position,t.worldSize),o=[e,r,1,1];F(o,o,t.pixelMatrixInverse),function(t,e,r){t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r}(o,o,1/o[3]);const s=M([],L([],o,i)),a=t.globeMatrix,l=[a[12],a[13],a[14]],u=L([],l,i),c=y(u),h=M([],u),p=t.worldSize/(2*Math.PI),d=D(h,s),f=Math.asin(p/c);if(f<Math.acos(d)){if(!n)return null;const t=[],e=[];_(t,s,c/d),M(e,L(e,t,u)),M(s,x(s,u,_(s,e,Math.tan(f)*c)))}const m=[];new Ray(i,s).closestPointOnSphere(l,p,m);const g=M([],It(a,0)),v=M([],It(a,1)),b=M([],It(a,2)),w=D(g,m),A=D(v,m),S=D(b,m),I=ct(Math.asin(-A/p));let P=ct(Math.atan2(w,S));P=t.center.lng+function(t,e){const r=(e-t+180)%360-180;return r<-180?r+360:r}(t.center.lng,P);const E=Lo(P),C=ht(Vo(I),0,1);return new MercatorCoordinate(E,C)}function Vs(t){if(t.z<=1)return zs[t.z+2*t.y+t.x];const e=function({x:t,y:e,z:r},n=!1){const i=1/(1<<r),o=new LngLat(Ro(t*i),e===(1<<r)-1&&n?-90:Oo((e+1)*i)),s=new LngLat(Ro((t+1)*i),0===e&&n?90:Oo(e*i));return new LngLatBounds(o,s)}(t),r=function(t,e=_o){const r=ut(t.getNorth()),n=ut(t.getSouth()),i=Math.cos(r),o=Math.cos(n),s=Math.sin(r),a=Math.sin(n),l=t.getWest(),u=t.getEast();return[Do(o,a,l,e),Do(o,a,u,e),Do(i,s,u,e),Do(i,s,l,e)]}(e);return Aabb.fromPoints(r)}function Fs(t,e,r){return _(t,t,1-r),A(t,t,e,r)}function Rs(t,e,r,n){const i=1<<r.z,o=(t/Ue+r.x)/i;return Eo(Oo((e/Ue+r.y)/i),Ro(o),n)}function Os({min:t,max:e}){return Io/Math.max(e[0]-t[0],e[1]-t[1],e[2]-t[2])}const Us=new Float64Array(16);function Ns(t){const e=Os(t),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(Us,[e,e,e]);return l(r,r,P([],t.min))}function js(t){const e=Ue/(2*Math.PI);return t/(2*Math.PI)/e}function Gs(t){return pt(Ao,So,t)}function $s(t,e,r,n,i,o,s,a,l){if(o&&t.queryGeometry.isAboveHorizon)return!1;o&&(l*=t.pixelToTileUnitsFactor);const u=t.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(const h of e)for(const e of h){const h=e.add(a),p=i&&r.elevation?r.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,d=r.projection.projectTilePoint(h.x,h.y,u);if(p>0){const t=r.projection.upVector(u,h.x,h.y);d.x+=t[0]*c*p,d.y+=t[1]*c*p,d.z+=t[2]*c*p}const f=o?h:qs(d.x,d.y,d.z,n),y=o?t.tilespaceRays.map((t=>Zs(t,p))):t.queryGeometry.screenGeometry,m=F([],[d.x,d.y,d.z,1],n);if(!s&&o?l*=m[3]/r.cameraToCenterDistance:s&&!o&&(l*=r.cameraToCenterDistance/m[3]),o){const t=Oo((e.y/Ue+u.y)/(1<<u.z));l/=r.projection.pixelsPerMeter(t,1)/Fo(1,t)}if(ps(y,f,l))return!0}return!1}function qs(t,e,r,n){const i=F([],[t,e,r,1],n);return new ot(i[0]/i[3],i[1]/i[3])}i();const Hs=m(0,0,0),Xs=m(0,0,1);function Zs(t,e){const r=d();return Hs[2]=e,t.intersectsPlane(Hs,Xs,r),new ot(r[0],r[1])}class HeatmapBucket extends CircleBucket{}let Ws,Ys,Js,Ks;function Qs(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError("mismatched image size")}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function ta(t,e,r){const{width:n,height:i}=e;n===t.width&&i===t.height||(ea(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,n),height:Math.min(t.height,i)},r,null),t.width=n,t.height=i,t.data=e.data)}function ea(t,e,r,n,i,o,s,a){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,u=e.data,c=4===o&&a;for(let a=0;a<i.height;a++){const h=((r.y+a)*t.width+r.x)*o,p=((n.y+a)*e.width+n.x)*o;if(c)for(let t=0;t<i.width;t++){const e=h+t*o+3,r=p+t*o;u[r+0]=255,u[r+1]=255,u[r+2]=255,u[r+3]=l[e]}else if(s)for(let t=0;t<i.width;t++){const e=h+t*o,r=p+t*o,n=new Color(l[e+0]/255,l[e+1]/255,l[e+2]/255,l[e+3]).toNonPremultipliedRenderColor(s).toArray();u[r+0]=n[0],u[r+1]=n[1],u[r+2]=n[2],u[r+3]=n[3]}else for(let t=0;t<i.width*o;t++)u[p+t]=l[h+t]}return e}Yn(HeatmapBucket,"HeatmapBucket",{omit:["layers"]});class AlphaImage{constructor(t,e){Qs(this,t,1,e)}resize(t){ta(this,new AlphaImage(t),1)}clone(){return new AlphaImage({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,r,n,i){ea(t,e,r,n,i,1,null)}}class RGBAImage{constructor(t,e){Qs(this,t,4,e)}resize(t){ta(this,new RGBAImage(t),4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new RGBAImage({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,r,n,i,o,s){ea(t,e,r,n,i,4,o,s)}}class Float32Image{constructor(t,e){this.width=t.width,this.height=t.height,this.data=e instanceof Uint8Array?new Float32Array(e.buffer):e}}function ra(t){const e={},r=t.resolution||256,n=t.clips?t.clips.length:1,i=t.image||new RGBAImage({width:r,height:n}),o=(r,n,o)=>{e[t.evaluationKey]=o;const s=t.expression.evaluate(e),a=s?s.toNonPremultipliedRenderColor(null):null;a&&(i.data[r+n+0]=Math.floor(255*a.r),i.data[r+n+1]=Math.floor(255*a.g),i.data[r+n+2]=Math.floor(255*a.b),i.data[r+n+3]=Math.floor(255*a.a))};if(t.clips)for(let e=0,i=0;e<n;++e,i+=4*r)for(let n=0,s=0;n<r;n++,s+=4){const a=n/(r-1),{start:l,end:u}=t.clips[e];o(i,s,l*(1-a)+u*a)}else for(let t=0,e=0;t<r;t++,e+=4)o(0,e,t/(r-1));return i}Yn(AlphaImage,"AlphaImage"),Yn(RGBAImage,"RGBAImage");const na=Zi([{name:"a_pos",components:2,type:"Int16"}],4),ia=Zi([{name:"a_road_z_offset",components:1,type:"Float32"}],4),oa=Zi([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),sa=Zi([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);function aa(t,e,r=2){const n=e&&e.length,i=n?e[0]*r:t.length;let o=la(t,0,i,r,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,u;if(n&&(o=function(t,e,r,n){const i=[];for(let r=0,o=e.length;r<o;r++){const s=la(t,e[r]*n,r<o-1?e[r+1]*n:t.length,n,!1);s===s.next&&(s.steiner=!0),i.push(va(s))}i.sort(ya);for(let t=0;t<i.length;t++)r=ma(i[t],r);return r}(t,e,o,r)),t.length>80*r){a=t[0],l=t[1];let e=a,n=l;for(let o=r;o<i;o+=r){const r=t[o],i=t[o+1];r<a&&(a=r),i<l&&(l=i),r>e&&(e=r),i>n&&(n=i)}u=Math.max(e-a,n-l),u=0!==u?32767/u:0}return ca(o,s,r,a,l,u,0),s}function la(t,e,r,n,i){let o;if(i===function(t,e,r,n){let i=0;for(let o=e,s=r-n;o<r;o+=n)i+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return i}(t,e,r,n)>0)for(let i=e;i<r;i+=n)o=Ca(i/n|0,t[i],t[i+1],o);else for(let i=r-n;i>=e;i-=n)o=Ca(i/n|0,t[i],t[i+1],o);return o&&Sa(o,o.next)&&(Ba(o),o=o.next),o}function ua(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Sa(n,n.next)&&0!==Aa(n.prev,n,n.next))n=n.next;else{if(Ba(n),n=e=n.prev,n===n.next)break;r=!0}}while(r||n!==e);return e}function ca(t,e,r,n,i,o,s){if(!t)return;!s&&o&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=xa(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let o=null;for(e=0;i;){e++;let s=i,a=0;for(let t=0;t<r&&(a++,s=s.nextZ,s);t++);let l=r;for(;a>0||l>0&&s;)0!==a&&(0===l||!s||i.z<=s.z)?(n=i,i=i.nextZ,a--):(n=s,s=s.nextZ,l--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;i=s}o.nextZ=null,r*=2}while(e>1)}(i)}(t,n,i,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(o?pa(t,n,i,o):ha(t))e.push(l.i,t.i,u.i),Ba(t),t=u.next,a=u.next;else if((t=u)===a){s?1===s?ca(t=da(ua(t),e),e,r,n,i,o,2):2===s&&fa(t,e,r,n,i,o):ca(ua(t),e,r,n,i,o,1);break}}}function ha(t){const e=t.prev,r=t,n=t.next;if(Aa(e,r,n)>=0)return!1;const i=e.x,o=r.x,s=n.x,a=e.y,l=r.y,u=n.y,c=Math.min(i,o,s),h=Math.min(a,l,u),p=Math.max(i,o,s),d=Math.max(a,l,u);let f=n.next;for(;f!==e;){if(f.x>=c&&f.x<=p&&f.y>=h&&f.y<=d&&wa(i,a,o,l,s,u,f.x,f.y)&&Aa(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function pa(t,e,r,n){const i=t.prev,o=t,s=t.next;if(Aa(i,o,s)>=0)return!1;const a=i.x,l=o.x,u=s.x,c=i.y,h=o.y,p=s.y,d=Math.min(a,l,u),f=Math.min(c,h,p),y=Math.max(a,l,u),m=Math.max(c,h,p),g=xa(d,f,e,r,n),x=xa(y,m,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=d&&v.x<=y&&v.y>=f&&v.y<=m&&v!==i&&v!==s&&wa(a,c,l,h,u,p,v.x,v.y)&&Aa(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,b.x>=d&&b.x<=y&&b.y>=f&&b.y<=m&&b!==i&&b!==s&&wa(a,c,l,h,u,p,b.x,b.y)&&Aa(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;v&&v.z>=g;){if(v.x>=d&&v.x<=y&&v.y>=f&&v.y<=m&&v!==i&&v!==s&&wa(a,c,l,h,u,p,v.x,v.y)&&Aa(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;b&&b.z<=x;){if(b.x>=d&&b.x<=y&&b.y>=f&&b.y<=m&&b!==i&&b!==s&&wa(a,c,l,h,u,p,b.x,b.y)&&Aa(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function da(t,e){let r=t;do{const n=r.prev,i=r.next.next;!Sa(n,i)&&Ia(n,r,r.next,i)&&Da(n,i)&&Da(i,n)&&(e.push(n.i,r.i,i.i),Ba(r),Ba(r.next),r=t=i),r=r.next}while(r!==t);return ua(r)}function fa(t,e,r,n,i,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&_a(s,t)){let a=Ea(s,t);return s=ua(s,s.next),a=ua(a,a.next),ca(s,e,r,n,i,o,0),void ca(a,e,r,n,i,o,0)}t=t.next}s=s.next}while(s!==t)}function ya(t,e){let r=t.x-e.x;return 0===r&&(r=t.y-e.y,0===r)&&(r=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),r}function ma(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let o,s=-1/0;if(Sa(t,r))return r;do{if(Sa(t,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>s&&(s=t,o=r.x<r.next.x?r:r.next,t===n))return o}r=r.next}while(r!==e);if(!o)return null;const a=o,l=o.x,u=o.y;let c=1/0;r=o;do{if(n>=r.x&&r.x>=l&&n!==r.x&&ba(i<u?n:s,i,l,u,i<u?s:n,i,r.x,r.y)){const e=Math.abs(i-r.y)/(n-r.x);Da(r,t)&&(e<c||e===c&&(r.x>o.x||r.x===o.x&&ga(o,r)))&&(o=r,c=e)}r=r.next}while(r!==a);return o}(t,e);if(!r)return e;const n=Ea(r,t);return ua(n,n.next),ua(r,r.next)}function ga(t,e){return Aa(t.prev,t,e.prev)<0&&Aa(e.next,t,t.next)<0}function xa(t,e,r,n,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function va(t){let e=t,r=t;do{(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next}while(e!==t);return r}function ba(t,e,r,n,i,o,s,a){return(i-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(n-a)>=(r-s)*(e-a)&&(r-s)*(o-a)>=(i-s)*(n-a)}function wa(t,e,r,n,i,o,s,a){return!(t===s&&e===a)&&ba(t,e,r,n,i,o,s,a)}function _a(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Ia(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(Da(t,e)&&Da(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(Aa(t.prev,t,e.prev)||Aa(t,e.prev,e))||Sa(t,e)&&Aa(t.prev,t,t.next)>0&&Aa(e.prev,e,e.next)>0)}function Aa(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Sa(t,e){return t.x===e.x&&t.y===e.y}function Ia(t,e,r,n){const i=Ma(Aa(t,e,r)),o=Ma(Aa(t,e,n)),s=Ma(Aa(r,n,t)),a=Ma(Aa(r,n,e));return i!==o&&s!==a||!(0!==i||!Pa(t,r,e))||!(0!==o||!Pa(t,n,e))||!(0!==s||!Pa(r,t,n))||!(0!==a||!Pa(r,e,n))}function Pa(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Ma(t){return t>0?1:t<0?-1:0}function Da(t,e){return Aa(t.prev,t,t.next)<0?Aa(t,e,t.next)>=0&&Aa(t,t.prev,e)>=0:Aa(t,e,t.prev)<0||Aa(t,t.next,e)<0}function Ea(t,e){const r=Ta(t.i,t.x,t.y),n=Ta(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function Ca(t,e,r,n){const i=Ta(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ba(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Ta(t,e,r){return{i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ka(t,e){const r=t.length;if(r<=1)return[t];const n=[];let i,o;for(let e=0;e<r;e++){const r=wt(t[e]);0!==r&&(t[e].area=Math.abs(r),void 0===o&&(o=r<0),o===r<0?(i&&n.push(i),i=[t[e]]):i.push(t[e]))}if(i&&n.push(i),e>1)for(let t=0;t<n.length;t++)n[t].length<=e||(he(n[t],e,1,n[t].length-1,za),n[t]=n[t].slice(0,e));return n}function za(t,e){return e.area-t.area}function La(t,e,r=1){if(!t)return null;const n="string"==typeof t?ResolvedImage.from(t).getPrimary():t.getPrimary(),i="string"==typeof t?null:t.getSecondary();for(const t of[n,i]){if(!t)continue;const n=t.id.toString();e.has(n)||e.set(n,[]),t.scaleSelf(r),e.get(n).push(t)}return{primary:n.toString(),secondary:i?i.toString():null}}function Va(t,e,r,n){const i=n.patternDependencies;let o=!1;for(const n of e){const e=n.paint.get(`${t}-pattern`);e.isConstant()||(o=!0),La(e.constantOr(null),i,r)&&(o=!0)}return o}function Fa(t,e,r,n,i,o){const s=o.patternDependencies;for(const a of e){const e=a.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:n},r,{},o.availableImages);t=t&&t.name?t.name:t;const l=La(t,s,i);if(!l)continue;const{primary:u,secondary:c}=l;u&&(r.patterns[a.id]=[u,c].filter(Boolean))}}return r}class ElevationPolygons{constructor(){this.polygons=new Map}add(t,...e){const r=this.polygons.get(t);r?r.push(...e):this.polygons.set(t,e)}merge(t){for(const[e,r]of t.polygons)this.add(e,...r)}}class ElevationPortalGraph{constructor(){this.portals=[]}static isOnBorder(t,e){return t<=0&&e<=0||t>=Ue&&e>=Ue}static evaluate(t){if(0===t.length)return new ElevationPortalGraph;let e=[];for(const r of t)e.push(...r.portals);if(0===e.length)return new ElevationPortalGraph;for(const t of e){const e=t.va,r=t.vb;(ElevationPortalGraph.isOnBorder(e.x,r.x)||ElevationPortalGraph.isOnBorder(e.y,r.y))&&(t.type="border")}const r=e.filter((t=>"unevaluated"!==t.type)),n=e.filter((t=>"unevaluated"===t.type));if(0===n.length)return new ElevationPortalGraph;n.sort(((t,e)=>t.hash===e.hash?t.isTunnel===e.isTunnel?0:t.isTunnel?-1:1:t.hash<e.hash?1:-1)),e=r.concat(n);let i=r.length,o=i,s=i;do{if(o++,o===e.length||e[i].hash!==e[o].hash){if(o-i==2){s<i&&(e[s]=e[i],e[i]=null);const t=e[s],r=e[o-1];t.type=t.isTunnel!==r.isTunnel?"tunnel":"polygon",t.connection={a:t.connection.a,b:r.connection.a},s++}i=o}}while(i!==e.length);return e.splice(s),e.sort(((t,e)=>t.hash<e.hash?1:-1)),{portals:e}}}Yn(ElevationPortalGraph,"ElevationPortalGraph"),Yn(ElevationPolygons,"ElevationPolygons");class MeshBuilder{constructor(t,e,r){this.outPositions=t,this.outNormals=e,this.outIndices=r,this.vertexLookup=new Map}addVertex(t,e,r){let n=t[2];null!=r&&(n*=r);const i=`${t[0]},${t[1]},${t[2]},${e[0]},${e[1]},${e[2]}`,o=this.vertexLookup.get(i);if(null!=o)return o;const s=this.outPositions.length;this.vertexLookup.set(i,s);const a=Math.trunc(16384*e[0]),l=Math.trunc(16384*e[1]),u=Math.trunc(16384*e[2]);return this.outPositions.emplaceBack(t[0],t[1],n),this.outNormals.emplaceBack(a,l,u),s}addTriangle(t,e,r){this.outIndices.emplaceBack(t,e,r)}addTriangles(t,e,r){if(0===t.length)return;const n=1===r.length,i=d(),o=d();for(let s=0;s<t.length;s+=3){const a=e[t[s+0]],l=e[t[s+1]],u=e[t[s+2]],c=n?r[0]:r[t[s+1]],h=n?r[0]:r[t[s+2]];g(i,a.x,a.y,n?r[0]:r[t[s+0]]);const p=this.addVertex(i,o);g(i,l.x,l.y,c);const d=this.addVertex(i,o);g(i,u.x,u.y,h);const f=this.addVertex(i,o);this.outIndices.emplaceBack(p,d,f)}}addQuad(t,e,r,n,i,o){const s=this.addVertex(t,i,o),a=this.addVertex(e,i,o),l=this.addVertex(r,i,o),u=this.addVertex(n,i,o);this.addTriangle(s,a,l),this.addTriangle(l,u,s)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class ElevatedStructures{constructor(t,e,r,n){this.unevaluatedPortals=new ElevationPortalGraph,this.portalPolygons=new ElevationPolygons,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new StructArrayLayout2i1f8,this.vertexNormals=new StructArrayLayout3i8,this.indexArray=new StructArrayLayout3ui6,this.tileToMeters=Go(t),this.bridgeProgramConfigurations=new ProgramConfigurationSet(e,{zoom:r,lut:n},(t=>"fill-tunnel-structure-color"!==t)),this.tunnelProgramConfigurations=new ProgramConfigurationSet(e,{zoom:r,lut:n},(t=>"fill-bridge-guard-rail-color"!==t))}addVertices(t,e){const r=this.unevalVertices.length;for(let r=0;r<t.length;r++)this.unevalVertices.push(t[r]),this.unevalHeights.push(e[r]);return r}addTriangles(t,e,r){const n=r?this.unevalTunnelTriangles:this.unevalTriangles;for(const r of t)n.push(r+e)}addRenderableRing(t,e,r,n,i,o){const s=[new ot(i.min.x,i.min.y),new ot(i.max.x,i.min.y),new ot(i.max.x,i.max.y),new ot(i.min.x,i.max.y)];for(let a=0;a<r-1;a++){const r=e+a,l=r+1,u=this.unevalVertices[r],c=this.unevalVertices[l];if(!(u.x>=i.min.x&&u.x<=i.max.x&&u.y>=i.min.y&&u.y<=i.max.y||c.x>=i.min.x&&c.x<=i.max.x&&c.y>=i.min.y&&c.y<=i.max.y||As(u,c,s)))continue;if(this.isOnBorder(u.x,c.x)||this.isOnBorder(u.y,c.y))continue;const h=ElevatedStructures.computeEdgeHash(this.unevalVertices[r],this.unevalVertices[l]);let p,d=this.vertexHashLookup.get(ElevatedStructures.computePosHash(u));null!=d?p=d.next:(d=this.vertexHashLookup.get(ElevatedStructures.computePosHash(c)),p=null!=d?d.prev:h),this.unevalEdges.push({polygonIdx:t,a:r,b:l,hash:h,portalHash:p,isTunnel:n,type:"unevaluated",featureInfo:o})}}addPortalCandidates(t,e,r,n,i){if(0===e.length)return;this.portalPolygons.add(t,{geometry:e,zLevel:i});const o=e[0];this.vertexHashLookup.clear();let s=ElevatedStructures.computeEdgeHash(o[o.length-2],o[o.length-1]);for(let e=0;e<o.length-1;e++){const i=o[e+0],a=o[e+1],l=Z(a.x-i.x,a.y-i.y),u=Q(l);if(0===u)continue;let c="unevaluated";const h=n.pointElevation(i),p=n.pointElevation(a);Math.abs(h)<.01&&Math.abs(p)<.01?c="entrance":(this.isOnBorder(i.x,a.x)||this.isOnBorder(i.y,a.y))&&(c="border");const d=ElevatedStructures.computeEdgeHash(i,a);this.unevaluatedPortals.portals.push({connection:{a:t,b:void 0},va:i,vb:a,vab:l,length:u,hash:d,isTunnel:r,type:c});const f=ElevatedStructures.computePosHash(i);this.vertexHashLookup.set(f,{prev:s,next:d}),s=d}}construct(t){if(0===this.unevalVertices.length)return;const e=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=t=>{t.primitiveLength=this.indexArray.length-t.primitiveOffset},n=new MeshBuilder(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(t.portals,this.unevalEdges);const i=e(),o=e(),s=e(),a=(t,e)=>{t.sort(((t,r)=>t.type===e&&r.type!==e?-1:t.type!==e&&r.type===e?1:0));const r=t.findIndex((t=>t.type!==e));return r>=0?r:t.length};let l=0;this.unevalEdges.length>0&&(l=a(this.unevalEdges,"none"),this.constructBridgeStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),r(s);const u=e(),c=e();if(this.unevalEdges.length>0){const t=this.unevalEdges.splice(l),e=a(t,"tunnel")+l;this.unevalEdges.push(...t),this.constructTunnelStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},{min:l,max:e})}r(u),n.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(c),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(o),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),r(i),this.maskSegments=SegmentVector.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.depthSegments=SegmentVector.simpleSegment(0,o.primitiveOffset,0,o.primitiveLength),this.renderableBridgeSegments=SegmentVector.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableTunnelSegments=SegmentVector.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.shadowCasterSegments=SegmentVector.simpleSegment(0,i.primitiveOffset,0,i.primitiveLength)}update(t,e,r,n,i,o,s,a){this.bridgeProgramConfigurations.updatePaintArrays(t,e,i,r,n,o,s,a),this.tunnelProgramConfigurations.updatePaintArrays(t,e,i,r,n,o,s,a)}upload(t){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=t.createVertexBuffer(this.vertexPositions,oa.members),this.vertexBufferNormal=t.createVertexBuffer(this.vertexNormals,sa.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(t),this.tunnelProgramConfigurations.upload(t))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(t,e,r,n,i){const o=(o,s)=>{for(let a=0;a<s.length-1;a++){const l=s[a].featureIndex,u=s[a+1].vertexStart,c=t.feature(l);o.populatePaintArrays(u,c,l,{},r,e,n,void 0,i)}};o(this.bridgeProgramConfigurations,this.bridgeFeatureSections),o(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(t,e,r,n,i){const o=new Map;for(let s=n;s<i;s++){const n=r[s],i=n.a,a=n.b,l=ElevatedStructures.computePosHash(t[i]),u=ElevatedStructures.computePosHash(t[a]);let c=o.get(l);c||(c={},o.set(l,c));let h=o.get(u);h||(h={},o.set(u,h)),e[i]<=0&&e[a]<=0||(c.to=a,h.from=i)}return o}isTerminalVertex(t,e){const r=ElevatedStructures.computePosHash(this.unevalVertices[t]),n=e.get(r);return!n||!n.from||!n.to}constructBridgeStructures(t,e,r,n,i,o){t.clearVertexLookup();const s=this.computeVertexConnections(e,r,n,i.min,i.max),a=1/o,l=.5*a,u=(t,n)=>g(t,e[n].x,e[n].y,r[n]*a),c=d(),h=d(),p=d(),f=d(),y=d(),m=(t,r)=>{const n=s.get(ElevatedStructures.computePosHash(e[r])),i=n.from,o=n.to;if(!i||!o)return;u(c,i),u(h,r),u(p,o),function(t){t[0]=0,t[1]=0,t[2]=0}(f),z(c,h)||(L(y,h,c),M(f,y)),z(p,h)||(L(y,p,h),x(f,f,M(y,y)));const a=V(f);return a>0?_(t,f,1/a):void 0};let v=Number.POSITIVE_INFINITY;this.sortSubarray(n,i.min,i.max,((t,e)=>t.featureInfo.featureIndex-e.featureInfo.featureIndex));const b=d(),w=d(),A=d(),S=d(),I=d(),D=d(),C=d(),B=d(),T=d(),k=[d(),d(),d(),d()],F=[d(),d(),d(),d()],R=[{coord:new ot(0,0),height:0},{coord:new ot(0,0),height:0}],O=(t,e)=>t>e;for(let u=i.min;u<i.max;u++){const i=n[u];if(!i.featureInfo.guardRailEnabled)continue;if(!this.prepareEdgePoints(R,e,r,i,O))continue;const[c,h]=R;if(g(b,c.coord.x,c.coord.y,a*c.height),g(w,h.coord.x,h.coord.y,a*h.height),z(b,w))continue;L(A,w,b),M(A,A);const p=m(B,i.a)||A,d=m(T,i.b)||A;g(S,p[1],-p[0],0),M(S,S),g(I,d[1],-d[0],0),M(I,I),E(B,S,p),M(D,B),E(B,I,d),M(C,B),x(k[0],b,_(B,L(B,S,D),l)),x(k[1],b,_(B,x(B,S,D),l)),x(k[2],b,_(B,D,l)),k[3]=b,x(F[0],w,_(B,L(B,I,C),l)),x(F[1],w,_(B,x(B,I,C),l)),x(F[2],w,_(B,C,l)),F[3]=w,v=this.addFeatureSection(i.featureInfo.featureIndex,v,this.bridgeFeatureSections,t);const f=t.addVertex(k[0],S,o),y=t.addVertex(k[1],S,o),V=t.addVertex(F[0],I,o),U=t.addVertex(F[1],I,o);t.addTriangle(f,y,V),t.addTriangle(y,U,V);const N=t.addVertex(k[1],D,o),j=t.addVertex(k[2],D,o),G=t.addVertex(F[1],C,o),$=t.addVertex(F[2],C,o);t.addTriangle(N,j,G),t.addTriangle(j,$,G),P(S,S),P(I,I);const q=t.addVertex(k[2],S,o),H=t.addVertex(k[3],S,o),X=t.addVertex(F[2],I,o),Z=t.addVertex(F[3],I,o);t.addTriangle(q,H,X),t.addTriangle(H,Z,X);const W=this.isTerminalVertex(i.a,s),Y=this.isTerminalVertex(i.b,s);c.height<.01&&W&&t.addQuad(k[3],k[2],k[1],k[0],P(p,p),o),h.height<.01&&Y&&t.addQuad(F[0],F[1],F[2],F[3],d,o)}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:t.getVertexCount()})}constructTunnelStructures(t,e,r,n,i,o){t.clearVertexLookup();let s=Number.POSITIVE_INFINITY;const a=(t,e)=>t.featureInfo.featureIndex-e.featureInfo.featureIndex;this.sortSubarray(n,i.min,i.max,a),this.sortSubarray(n,o.min,o.max,a);const l=t=>M(t,t),u=[{coord:new ot(0,0),height:0},{coord:new ot(0,0),height:0}],c=(t,e)=>t<e,h=d(),p=d(),f=d(),y=d(),m=d();for(let o=i.min;o<i.max;o++){if(!this.prepareEdgePoints(u,e,r,n[o],c))continue;const[i,a]=u,d=l(g(m,-(a.coord.y-i.coord.y),a.coord.x-i.coord.x,0));s=this.addFeatureSection(n[o].featureInfo.featureIndex,s,this.tunnelFeatureSections,t),t.addQuad(g(h,i.coord.x,i.coord.y,i.height),g(p,a.coord.x,a.coord.y,a.height),g(f,a.coord.x,a.coord.y,n[o].isTunnel?-.1:0),g(y,i.coord.x,i.coord.y,n[o].isTunnel?-.1:0),d)}for(let i=o.min;i<o.max;i++){const o=n[i];o.isTunnel&&([o.a,o.b]=[o.b,o.a]);const a=e[o.a],u=e[o.b],c=l(g(m,-(u.y-a.y),u.x-a.x,0));s=this.addFeatureSection(o.featureInfo.featureIndex,s,this.tunnelFeatureSections,t),t.addQuad(g(h,u.x,u.y,0),g(p,a.x,a.y,0),g(f,a.x,a.y,r[o.a]+4),g(y,u.x,u.y,r[o.b]+4),c),t.addQuad(g(h,a.x,a.y,0),g(p,u.x,u.y,0),g(f,u.x,u.y,r[o.b]+4),g(y,a.x,a.y,r[o.a]+4),c)}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:t.getVertexCount()})}setElevatedPoint(t,e,r,n){t.coord.x=e,t.coord.y=r,t.height=n}prepareEdgePoints(t,e,r,n,i){let o=e[n.a].x,s=e[n.a].y,a=e[n.b].x,l=e[n.b].y,u=r[n.a],c=r[n.b];const h=i(u,0),p=i(c,0);if(h&&p)return this.setElevatedPoint(t[0],o,s,u),this.setElevatedPoint(t[1],a,l,c),!0;if(!h&&!p)return!1;if(h){if(!p){const t=c/(c-u);a=Vt(a,o,t),l=Vt(l,s,t),c=Vt(c,u,t)}}else{const t=u/(u-c);o=Vt(o,a,t),s=Vt(s,l,t),u=Vt(u,c,t)}return this.setElevatedPoint(t[0],o,s,u),this.setElevatedPoint(t[1],a,l,c),!0}prepareEdges(t,e){if(0===e.length)return;e.sort(((t,e)=>t.hash===e.hash?e.polygonIdx-t.polygonIdx:e.hash>t.hash?1:-1));let r=0,n=0,i=0,o=e[r].polygonIdx;do{n++,(n===e.length||e[r].hash!==e[n].hash)&&((1==n-r||e[n-1].polygonIdx!==o)&&(i<r&&(e[i]=e[r],e[r]=null),e[i].type="none",i++),r=n,r!==e.length&&(o=e[r].polygonIdx))}while(r!==e.length);if(e.splice(i),0!==e.length&&0!==t.length){e.sort(((t,e)=>t.portalHash<e.portalHash?1:-1));let r=0,n=0;for(;r!==e.length&&n!==t.length;){const i=e[r],o=t[n];i.portalHash>o.hash?r++:o.hash>i.portalHash?n++:(i.type=o.type,r++)}}}isOnBorder(t,e){return t<=0&&e<=0||t>=Ue&&e>=Ue}addFeatureSection(t,e,r,n){return t!==e&&(e=t,r.push({featureIndex:t,vertexStart:n.getVertexCount()}),n.clearVertexLookup()),e}sortSubarray(t,e,r,n){const i=t.slice(e,r);i.sort(n),t.splice(e,i.length,...i)}static computeEdgeHash(t,e){return(t.y===e.y&&t.x>e.x||t.y>e.y)&&([t,e]=[e,t]),BigInt(ElevatedStructures.computePosHash(t))<<32n|BigInt(ElevatedStructures.computePosHash(e))}static computePosHash(t){return((65535&t.x)<<16|65535&t.y)>>>0}}var Ra,Oa={exports:{}},Ua=(Ra||(Ra=1,function(t){function e(t,e){return t>e?1:t<e?-1:0}var r=function(t,r){void 0===t&&(t=e),void 0===r&&(r=!1),this._compare=t,this._root=null,this._size=0,this._noDuplicates=!!r},n={size:{configurable:!0}};function i(t,e,r,n,o){var s=o-n;if(s>0){var a=n+Math.floor(s/2),l={key:e[a],data:r[a],parent:t};return l.left=i(l,e,r,n,a),l.right=i(l,e,r,a+1,o),l}return null}function o(t,e,r,n,i){if(!(r>=n)){for(var s=t[r+n>>1],a=r-1,l=n+1;;){do{a++}while(i(t[a],s)<0);do{l--}while(i(t[l],s)>0);if(a>=l)break;var u=t[a];t[a]=t[l],t[l]=u,u=e[a],e[a]=e[l],e[l]=u}o(t,e,r,l,i),o(t,e,l+1,n,i)}}r.prototype.rotateLeft=function(t){var e=t.right;e&&(t.right=e.left,e.left&&(e.left.parent=t),e.parent=t.parent),t.parent?t===t.parent.left?t.parent.left=e:t.parent.right=e:this._root=e,e&&(e.left=t),t.parent=e},r.prototype.rotateRight=function(t){var e=t.left;e&&(t.left=e.right,e.right&&(e.right.parent=t),e.parent=t.parent),t.parent?t===t.parent.left?t.parent.left=e:t.parent.right=e:this._root=e,e&&(e.right=t),t.parent=e},r.prototype._splay=function(t){for(;t.parent;){var e=t.parent;e.parent?e.left===t&&e.parent.left===e?(this.rotateRight(e.parent),this.rotateRight(e)):e.right===t&&e.parent.right===e?(this.rotateLeft(e.parent),this.rotateLeft(e)):e.left===t&&e.parent.right===e?(this.rotateRight(e),this.rotateLeft(e)):(this.rotateLeft(e),this.rotateRight(e)):e.left===t?this.rotateRight(e):this.rotateLeft(e)}},r.prototype.splay=function(t){for(var e,r,n,i,o;t.parent;)(r=(e=t.parent).parent)&&r.parent?((n=r.parent).left===r?n.left=t:n.right=t,t.parent=n):(t.parent=null,this._root=t),i=t.left,o=t.right,t===e.left?(r&&(r.left===e?(e.right?(r.left=e.right,r.left.parent=r):r.left=null,e.right=r,r.parent=e):(i?(r.right=i,i.parent=r):r.right=null,t.left=r,r.parent=t)),o?(e.left=o,o.parent=e):e.left=null,t.right=e,e.parent=t):(r&&(r.right===e?(e.left?(r.right=e.left,r.right.parent=r):r.right=null,e.left=r,r.parent=e):(o?(r.left=o,o.parent=r):r.left=null,t.right=r,r.parent=t)),i?(e.right=i,i.parent=e):e.right=null,t.left=e,e.parent=t)},r.prototype.replace=function(t,e){t.parent?t===t.parent.left?t.parent.left=e:t.parent.right=e:this._root=e,e&&(e.parent=t.parent)},r.prototype.minNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.left;)t=t.left;return t},r.prototype.maxNode=function(t){if(void 0===t&&(t=this._root),t)for(;t.right;)t=t.right;return t},r.prototype.insert=function(t,e){var r=this._root,n=null,i=this._compare;if(this._noDuplicates)for(;r;){if(n=r,0===i(r.key,t))return;r=i(r.key,t)<0?r.right:r.left}else for(;r;)n=r,r=i(r.key,t)<0?r.right:r.left;return r={key:t,data:e,left:null,right:null,parent:n},n?i(n.key,r.key)<0?n.right=r:n.left=r:this._root=r,this.splay(r),this._size++,r},r.prototype.find=function(t){for(var e=this._root,r=this._compare;e;){var n=r(e.key,t);if(n<0)e=e.right;else{if(!(n>0))return e;e=e.left}}return null},r.prototype.contains=function(t){for(var e=this._root,r=this._compare;e;){var n=r(t,e.key);if(0===n)return!0;e=n<0?e.left:e.right}return!1},r.prototype.remove=function(t){var e=this.find(t);if(!e)return!1;if(this.splay(e),e.left)if(e.right){var r=this.minNode(e.right);r.parent!==e&&(this.replace(r,r.right),r.right=e.right,r.right.parent=r),this.replace(e,r),r.left=e.left,r.left.parent=r}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0},r.prototype.removeNode=function(t){if(!t)return!1;if(this.splay(t),t.left)if(t.right){var e=this.minNode(t.right);e.parent!==t&&(this.replace(e,e.right),e.right=t.right,e.right.parent=e),this.replace(t,e),e.left=t.left,e.left.parent=e}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0},r.prototype.erase=function(t){var e=this.find(t);if(e){this.splay(e);var r=e.left,n=e.right,i=null;r&&(r.parent=null,i=this.maxNode(r),this.splay(i),this._root=i),n&&(r?i.right=n:this._root=n,n.parent=i),this._size--}},r.prototype.pop=function(){var t=this._root,e=null;if(t){for(;t.left;)t=t.left;e={key:t.key,data:t.data},this.remove(t.key)}return e},r.prototype.next=function(t){var e=t;if(e)if(e.right)for(e=e.right;e&&e.left;)e=e.left;else for(e=t.parent;e&&e.right===t;)t=e,e=e.parent;return e},r.prototype.prev=function(t){var e=t;if(e)if(e.left)for(e=e.left;e&&e.right;)e=e.right;else for(e=t.parent;e&&e.left===t;)t=e,e=e.parent;return e},r.prototype.forEach=function(t){for(var e=this._root,r=[],n=!1,i=0;!n;)e?(r.push(e),e=e.left):r.length>0?(t(e=r.pop(),i++),e=e.right):n=!0;return this},r.prototype.range=function(t,e,r,n){for(var i=[],o=this._compare,s=this._root;0!==i.length||s;)if(s)i.push(s),s=s.left;else{if(o((s=i.pop()).key,e)>0)break;if(o(s.key,t)>=0&&r.call(n,s))return this;s=s.right}return this},r.prototype.keys=function(){for(var t=this._root,e=[],r=[],n=!1;!n;)t?(e.push(t),t=t.left):e.length>0?(t=e.pop(),r.push(t.key),t=t.right):n=!0;return r},r.prototype.values=function(){for(var t=this._root,e=[],r=[],n=!1;!n;)t?(e.push(t),t=t.left):e.length>0?(t=e.pop(),r.push(t.data),t=t.right):n=!0;return r},r.prototype.at=function(t){for(var e=this._root,r=[],n=!1,i=0;!n;)if(e)r.push(e),e=e.left;else if(r.length>0){if(e=r.pop(),i===t)return e;i++,e=e.right}else n=!0;return null},r.prototype.load=function(t,e,r){if(void 0===t&&(t=[]),void 0===e&&(e=[]),void 0===r&&(r=!1),0!==this._size)throw new Error("bulk-load: tree is not empty");var n=t.length;return r&&o(t,e,0,n-1,this._compare),this._root=i(null,t,e,0,n),this._size=n,this},r.prototype.min=function(){var t=this.minNode(this._root);return t?t.key:null},r.prototype.max=function(){var t=this.maxNode(this._root);return t?t.key:null},r.prototype.isEmpty=function(){return null===this._root},n.size.get=function(){return this._size},r.createTree=function(t,e,n,i,o){return new r(n,o).load(t,e,i)},Object.defineProperties(r.prototype,n);var s=0,a=1,l=2,u=3,c=0,h=1,p=2,d=3;function f(t,e,r){null===e?(t.inOut=!1,t.otherInOut=!0):(t.isSubject===e.isSubject?(t.inOut=!e.inOut,t.otherInOut=e.otherInOut):(t.inOut=!e.otherInOut,t.otherInOut=e.isVertical()?!e.inOut:e.inOut),e&&(t.prevInResult=!y(e,r)||e.isVertical()?e.prevInResult:e));var n=y(t,r);t.resultTransition=n?function(t,e){var r,n=!t.inOut,i=!t.otherInOut;switch(e){case c:r=n&&i;break;case h:r=n||i;break;case d:r=n^i;break;case p:r=t.isSubject?n&&!i:i&&!n}return r?1:-1}(t,r):0}function y(t,e){switch(t.type){case s:switch(e){case c:return!t.otherInOut;case h:return t.otherInOut;case p:return t.isSubject&&t.otherInOut||!t.isSubject&&!t.otherInOut;case d:return!0}break;case l:return e===c||e===h;case u:return e===p;case a:return!1}return!1}var m=function(t,e,r,n,i){this.left=e,this.point=t,this.otherEvent=r,this.isSubject=n,this.type=i||s,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},g={inResult:{configurable:!0}};function x(t,e){return t[0]===e[0]&&t[1]===e[1]}m.prototype.isBelow=function(t){var e=this.point,r=this.otherEvent.point;return this.left?(e[0]-t[0])*(r[1]-t[1])-(r[0]-t[0])*(e[1]-t[1])>0:(r[0]-t[0])*(e[1]-t[1])-(e[0]-t[0])*(r[1]-t[1])>0},m.prototype.isAbove=function(t){return!this.isBelow(t)},m.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},g.inResult.get=function(){return 0!==this.resultTransition},m.prototype.clone=function(){var t=new m(this.point,this.left,this.otherEvent,this.isSubject,this.type);return t.contourId=this.contourId,t.resultTransition=this.resultTransition,t.prevInResult=this.prevInResult,t.isExteriorRing=this.isExteriorRing,t.inOut=this.inOut,t.otherInOut=this.otherInOut,t},Object.defineProperties(m.prototype,g);var v=11102230246251565e-32,b=134217729,w=(3+8*v)*v;function _(t,e,r,n,i){var o,s,a,l,u=e[0],c=n[0],h=0,p=0;c>u==c>-u?(o=u,u=e[++h]):(o=c,c=n[++p]);var d=0;if(h<t&&p<r)for(c>u==c>-u?(a=o-((s=u+o)-u),u=e[++h]):(a=o-((s=c+o)-c),c=n[++p]),o=s,0!==a&&(i[d++]=a);h<t&&p<r;)c>u==c>-u?(a=o-((s=o+u)-(l=s-o))+(u-l),u=e[++h]):(a=o-((s=o+c)-(l=s-o))+(c-l),c=n[++p]),o=s,0!==a&&(i[d++]=a);for(;h<t;)a=o-((s=o+u)-(l=s-o))+(u-l),u=e[++h],o=s,0!==a&&(i[d++]=a);for(;p<r;)a=o-((s=o+c)-(l=s-o))+(c-l),c=n[++p],o=s,0!==a&&(i[d++]=a);return 0===o&&0!==d||(i[d++]=o),d}function A(t){return new Float64Array(t)}var S=33306690738754716e-32,I=22204460492503146e-32,P=11093356479670487e-47,M=A(4),D=A(8),E=A(12),C=A(16),B=A(4);function T(t,e,r){var n=function(t,e,r,n,i,o){var s=(e-o)*(r-i),a=(t-i)*(n-o),l=s-a;if(0===s||0===a||s>0!=a>0)return l;var u=Math.abs(s+a);return Math.abs(l)>=S*u?l:-function(t,e,r,n,i,o,s){var a,l,u,c,h,p,d,f,y,m,g,x,v,A,S,T,k,z,L=t-i,V=r-i,F=e-o,R=n-o;M[0]=(S=(f=L-(d=(p=b*L)-(p-L)))*(m=R-(y=(p=b*R)-(p-R)))-((A=L*R)-d*y-f*y-d*m))-((g=S-(k=(f=F-(d=(p=b*F)-(p-F)))*(m=V-(y=(p=b*V)-(p-V)))-((T=F*V)-d*y-f*y-d*m)))+(h=S-g))+(h-k),M[1]=(v=A-((x=A+g)-(h=x-A))+(g-h))-((g=v-T)+(h=v-g))+(h-T),M[2]=x-((z=x+g)-(h=z-x))+(g-h),M[3]=z;var O=function(t,e){for(var r=e[0],n=1;n<4;n++)r+=e[n];return r}(0,M),U=I*s;if(O>=U||-O>=U)return O;if(a=t-(L+(h=t-L))+(h-i),u=r-(V+(h=r-V))+(h-i),l=e-(F+(h=e-F))+(h-o),c=n-(R+(h=n-R))+(h-o),0===a&&0===l&&0===u&&0===c)return O;if(U=P*s+w*Math.abs(O),(O+=L*c+R*a-(F*u+V*l))>=U||-O>=U)return O;B[0]=(S=(f=a-(d=(p=b*a)-(p-a)))*(m=R-(y=(p=b*R)-(p-R)))-((A=a*R)-d*y-f*y-d*m))-((g=S-(k=(f=l-(d=(p=b*l)-(p-l)))*(m=V-(y=(p=b*V)-(p-V)))-((T=l*V)-d*y-f*y-d*m)))+(h=S-g))+(h-k),B[1]=(v=A-((x=A+g)-(h=x-A))+(g-h))-((g=v-T)+(h=v-g))+(h-T),B[2]=x-((z=x+g)-(h=z-x))+(g-h),B[3]=z;var N=_(4,M,4,B,D);B[0]=(S=(f=L-(d=(p=b*L)-(p-L)))*(m=c-(y=(p=b*c)-(p-c)))-((A=L*c)-d*y-f*y-d*m))-((g=S-(k=(f=F-(d=(p=b*F)-(p-F)))*(m=u-(y=(p=b*u)-(p-u)))-((T=F*u)-d*y-f*y-d*m)))+(h=S-g))+(h-k),B[1]=(v=A-((x=A+g)-(h=x-A))+(g-h))-((g=v-T)+(h=v-g))+(h-T),B[2]=x-((z=x+g)-(h=z-x))+(g-h),B[3]=z;var j=_(N,D,4,B,E);B[0]=(S=(f=a-(d=(p=b*a)-(p-a)))*(m=c-(y=(p=b*c)-(p-c)))-((A=a*c)-d*y-f*y-d*m))-((g=S-(k=(f=l-(d=(p=b*l)-(p-l)))*(m=u-(y=(p=b*u)-(p-u)))-((T=l*u)-d*y-f*y-d*m)))+(h=S-g))+(h-k),B[1]=(v=A-((x=A+g)-(h=x-A))+(g-h))-((g=v-T)+(h=v-g))+(h-T),B[2]=x-((z=x+g)-(h=z-x))+(g-h),B[3]=z;var G=_(j,E,4,B,C);return C[G-1]}(t,e,r,n,i,o,u)}(t[0],t[1],e[0],e[1],r[0],r[1]);return n>0?-1:n<0?1:0}function k(t,e){var r=t.point,n=e.point;return r[0]>n[0]?1:r[0]<n[0]?-1:r[1]!==n[1]?r[1]>n[1]?1:-1:function(t,e,r,n){return t.left!==e.left?t.left?1:-1:0!==T(r,t.otherEvent.point,e.otherEvent.point)?t.isBelow(e.otherEvent.point)?-1:1:!t.isSubject&&e.isSubject?1:-1}(t,e,r)}function z(t,e,r){var n=new m(e,!1,t,t.isSubject),i=new m(e,!0,t.otherEvent,t.isSubject);return x(t.point,t.otherEvent.point)&&console.warn("what is that, a collapsed segment?",t),n.contourId=i.contourId=t.contourId,k(i,t.otherEvent)>0&&(t.otherEvent.left=!0,i.left=!1),t.otherEvent.otherEvent=i,t.otherEvent=n,r.push(i),r.push(n),r}function L(t,e){return t[0]*e[1]-t[1]*e[0]}function V(t,e){return t[0]*e[0]+t[1]*e[1]}function F(t,e,r){var n=function(t,e,r,n,i){var o=[e[0]-t[0],e[1]-t[1]],s=[n[0]-r[0],n[1]-r[1]];function a(t,e,r){return[t[0]+e*r[0],t[1]+e*r[1]]}var l=[r[0]-t[0],r[1]-t[1]],u=L(o,s),c=u*u,h=V(o,o);if(c>0){var p=L(l,s)/u;if(p<0||p>1)return null;var d=L(l,o)/u;return d<0||d>1?null:0===p||1===p?[a(t,p,o)]:0===d||1===d?[a(r,d,s)]:[a(t,p,o)]}if((c=(u=L(l,o))*u)>0)return null;var f=V(o,l)/h,y=f+V(o,s)/h,m=Math.min(f,y),g=Math.max(f,y);return m<=1&&g>=0?1===m?[a(t,m>0?m:0,o)]:0===g?[a(t,g<1?g:1,o)]:[a(t,m>0?m:0,o),a(t,g<1?g:1,o)]:null}(t.point,t.otherEvent.point,e.point,e.otherEvent.point),i=n?n.length:0;if(0===i)return 0;if(1===i&&(x(t.point,e.point)||x(t.otherEvent.point,e.otherEvent.point)))return 0;if(2===i&&t.isSubject===e.isSubject)return 0;if(1===i)return x(t.point,n[0])||x(t.otherEvent.point,n[0])||z(t,n[0],r),x(e.point,n[0])||x(e.otherEvent.point,n[0])||z(e,n[0],r),1;var o=[],s=!1,c=!1;return x(t.point,e.point)?s=!0:1===k(t,e)?o.push(e,t):o.push(t,e),x(t.otherEvent.point,e.otherEvent.point)?c=!0:1===k(t.otherEvent,e.otherEvent)?o.push(e.otherEvent,t.otherEvent):o.push(t.otherEvent,e.otherEvent),s&&c||s?(e.type=a,t.type=e.inOut===t.inOut?l:u,s&&!c&&z(o[1].otherEvent,o[0].point,r),2):c?(z(o[0],o[1].point,r),3):o[0]!==o[3].otherEvent?(z(o[0],o[1].point,r),z(o[1],o[2].point,r),3):(z(o[0],o[1].point,r),z(o[3].otherEvent,o[2].point,r),3)}function R(t,e){if(t===e)return 0;if(0!==T(t.point,t.otherEvent.point,e.point)||0!==T(t.point,t.otherEvent.point,e.otherEvent.point))return x(t.point,e.point)?t.isBelow(e.otherEvent.point)?-1:1:t.point[0]===e.point[0]?t.point[1]<e.point[1]?-1:1:1===k(t,e)?e.isAbove(t.point)?-1:1:t.isBelow(e.point)?-1:1;if(t.isSubject!==e.isSubject)return t.isSubject?-1:1;var r=t.point,n=e.point;return r[0]===n[0]&&r[1]===n[1]?(r=t.otherEvent.point)[0]===(n=e.otherEvent.point)[0]&&r[1]===n[1]?0:t.contourId>e.contourId?1:-1:1===k(t,e)?1:-1}var O=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function U(t,e,r,n){var i,o=t+1,s=e[t].point,a=e.length;for(o<a&&(i=e[o].point);o<a&&i[0]===s[0]&&i[1]===s[1];){if(!r[o])return o;++o<a&&(i=e[o].point)}for(o=t-1;r[o]&&o>n;)o--;return o}O.prototype.isExterior=function(){return null==this.holeOf};var N=G,j=G;function G(t,e){if(!(this instanceof G))return new G(t,e);if(this.data=t||[],this.length=this.data.length,this.compare=e||$,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)}function $(t,e){return t<e?-1:t>e?1:0}G.prototype={push:function(t){this.data.push(t),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){var t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,r=this.compare,n=e[t];t>0;){var i=t-1>>1,o=e[i];if(r(n,o)>=0)break;e[t]=o,t=i}e[t]=n},_down:function(t){for(var e=this.data,r=this.compare,n=this.length>>1,i=e[t];t<n;){var o=1+(t<<1),s=o+1,a=e[o];if(s<this.length&&r(e[s],a)<0&&(o=s,a=e[s]),r(a,i)>=0)break;e[t]=a,t=o}e[t]=i}},N.default=j;var q=Math.max,H=Math.min,X=0;function Z(t,e,r,n,i,o){var s,a,l,u,c,h;for(s=0,a=t.length-1;s<a;s++)if(u=t[s+1],c=new m(l=t[s],!1,void 0,e),h=new m(u,!1,c,e),c.otherEvent=h,l[0]!==u[0]||l[1]!==u[1]){c.contourId=h.contourId=r,o||(c.isExteriorRing=!1,h.isExteriorRing=!1),k(c,h)>0?h.left=!0:c.left=!0;var p=l[0],d=l[1];i[0]=H(i[0],p),i[1]=H(i[1],d),i[2]=q(i[2],p),i[3]=q(i[3],d),n.push(c),n.push(h)}}var W=[];function Y(t,e,n){"number"==typeof t[0][0][0]&&(t=[t]),"number"==typeof e[0][0][0]&&(e=[e]);var i=function(t,e,r){var n=null;return t.length*e.length==0&&(r===c?n=W:r===p?n=t:r!==h&&r!==d||(n=0===t.length?e:t)),n}(t,e,n);if(i)return i===W?null:i;var o=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],a=function(t,e,r,n,i){var o,s,a,l,u,c,h=new N(null,k);for(a=0,l=t.length;a<l;a++)for(u=0,c=(o=t[a]).length;u<c;u++)(s=0===u)&&X++,Z(o[u],!0,X,h,r,s);for(a=0,l=e.length;a<l;a++)for(u=0,c=(o=e[a]).length;u<c;u++)s=0===u,i===p&&(s=!1),s&&X++,Z(o[u],!1,X,h,n,s);return h}(t,e,o,s,n);if(i=function(t,e,r,n,i){var o=null;return(r[0]>n[2]||n[0]>r[2]||r[1]>n[3]||n[1]>r[3])&&(i===c?o=W:i===p?o=t:i!==h&&i!==d||(o=t.concat(e))),o}(t,e,o,s,n))return i===W?null:i;for(var l=function(t){var e,r,n=function(t){var e,r,n,i,o=[];for(r=0,n=t.length;r<n;r++)((e=t[r]).left&&e.inResult||!e.left&&e.otherEvent.inResult)&&o.push(e);for(var s=!1;!s;)for(s=!0,r=0,n=o.length;r<n;r++)r+1<n&&1===k(o[r],o[r+1])&&(i=o[r],o[r]=o[r+1],o[r+1]=i,s=!1);for(r=0,n=o.length;r<n;r++)(e=o[r]).otherPos=r;for(r=0,n=o.length;r<n;r++)(e=o[r]).left||(i=e.otherPos,e.otherPos=e.otherEvent.otherPos,e.otherEvent.otherPos=i);return o}(t),i={},o=[],s=function(){if(!i[e]){var t=o.length,r=function(t,e,r){var n=new O;if(null!=t.prevInResult){var i=t.prevInResult,o=i.outputContourId;if(i.resultTransition>0){var s=e[o];if(null!=s.holeOf){var a=s.holeOf;e[a].holeIds.push(r),n.holeOf=a,n.depth=e[o].depth}else e[o].holeIds.push(r),n.holeOf=o,n.depth=e[o].depth+1}else n.holeOf=null,n.depth=e[o].depth}else n.holeOf=null,n.depth=0;return n}(n[e],o,t),s=function(e){i[e]=!0,e<n.length&&n[e]&&(n[e].outputContourId=t)},a=e,l=e;for(r.points.push(n[e].point);s(a),s(a=n[a].otherPos),r.points.push(n[a].point),!((a=U(a,n,i,l))==l||a>=n.length)&&n[a];);o.push(r)}};for(e=0,r=n.length;e<r;e++)s();return o}(function(t,e,n,i,o,s){for(var a,l,u,h=new r(R),d=[],y=Math.min(i[2],o[2]);0!==t.length;){var m=t.pop();if(d.push(m),s===c&&m.point[0]>y||s===p&&m.point[0]>i[2])break;if(m.left){l=a=h.insert(m),a=a!==(u=h.minNode())?h.prev(a):null,l=h.next(l);var g=a?a.key:null;if(f(m,g,s),l&&2===F(m,l.key,t)&&(f(m,g,s),f(l.key,m,s)),a&&2===F(a.key,m,t)){var x=a;f(g,(x=x!==u?h.prev(x):null)?x.key:null,s),f(m,g,s)}}else l=a=h.find(m=m.otherEvent),a&&l&&(a=a!==u?h.prev(a):null,l=h.next(l),h.remove(m),l&&a&&F(a.key,l.key,t))}return d}(a,0,0,o,s,n)),u=[],y=0;y<l.length;y++){var m=l[y];if(m.isExterior()){for(var g=[m.points],x=0;x<m.holeIds.length;x++)g.push(l[m.holeIds[x]].points);u.push(g)}}return u}var J={UNION:h,DIFFERENCE:p,INTERSECTION:c,XOR:d};t.diff=function(t,e){return Y(t,e,p)},t.intersection=function(t,e){return Y(t,e,c)},t.operations=J,t.union=function(t,e){return Y(t,e,h)},t.xor=function(t,e){return Y(t,e,d)},Object.defineProperty(t,"__esModule",{value:!0})}(Oa.exports)),Oa.exports);
/**
* martinez v0.7.4
* Martinez polygon clipping algorithm, does boolean operation on polygons (multipolygons, polygons with holes etc): intersection, union, difference, xor
*
* @author Alex Milevski <info@w8r.name>
* @license MIT
* @preserve
*/function Na(t,e,r,n){const i=[],o=0===n?(t,e,r,n,i,o)=>{t.push(new ot(o,r+(o-e)/(n-e)*(i-r)))}:(t,e,r,n,i,o)=>{t.push(new ot(e+(o-r)/(i-r)*(n-e),o))};for(const s of t){const t=[];for(const i of s){if(i.length<=2)continue;const s=[];for(let t=0;t<i.length-1;t++){const a=i[t].x,l=i[t].y,u=i[t+1].x,c=i[t+1].y,h=0===n?a:l,p=0===n?u:c;h<e?p>e&&o(s,a,l,u,c,e):h>r?p<r&&o(s,a,l,u,c,r):s.push(i[t]),p<e&&h>=e&&o(s,a,l,u,c,e),p>r&&h<=r&&o(s,a,l,u,c,r)}let a=i[i.length-1];const l=0===n?a.x:a.y;l>=e&&l<=r&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),t.push(s))}t.length&&i.push(t)}return i}function ja(t,e){const r=$a(t),n=$a([e]),i=Ua.intersection(r,n);return null==i?[]:qa(i)}function Ga(t,e){const r=65536;let n=$a(t,r);const i=[];for(;e.valid();e.next()){const[t,n]=e.get(),o=t.x*r,s=t.y*r,a=n.x*r,l=n.y*r,u=a-o,c=l-s,h=Math.hypot(u,c);if(0===h)continue;const p=Math.trunc(c/h*3),d=-Math.trunc(u/h*3);i.push([[[o,s],[a,l],[a+p,l+d],[o+p,s+d],[o,s]]])}return i.length>0&&(n=Ua.diff(n,i)),qa(n,1/r)}function $a(t,e=1){return[t.map((t=>t.map((t=>[t.x*e,t.y*e]))))]}function qa(t,e=1){return t.map((t=>t.map(((t,r)=>{const n=t.map((t=>new ot(t[0]*e,t[1]*e).round()));return r>0&&n.reverse(),n}))))}class FillBufferData{constructor(t,e){this.layoutVertexArray=new StructArrayLayout2i4,this.indexArray=new StructArrayLayout3ui6,this.lineIndexArray=new StructArrayLayout2ui4,this.triangleSegments=new SegmentVector,this.lineSegments=new SegmentVector,this.programConfigurations=new ProgramConfigurationSet(t.layers,{zoom:t.zoom,lut:t.lut}),this.uploaded=!1,e&&(this.elevatedLayoutVertexArray=new StructArrayLayout1f4)}update(t,e,r,n,i,o,s,a){this.programConfigurations.updatePaintArrays(t,e,i,r,n,o,s,a)}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,na.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.lineIndexBuffer=t.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=t.createVertexBuffer(this.elevatedLayoutVertexArray,ia.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(t,e,r,n,i,o,s){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,e,r,n,i,o,void 0,s)}}class FillBucket{constructor(t){this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=t.lut,this.bufferData=new FillBufferData(t,!1),this.elevationBufferData=new FillBufferData(t,!0),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=t.sourceLayerIndex,this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,e){}updateAppearances(t,e,r,n){}populate(t,e,r,n){this.hasPattern=Va("fill",this.layers,this.pixelRatio,e);const i=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Ko(s,t);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:e.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r,e.availableImages):void 0,p={id:a,properties:s.properties,type:s.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Jo(s,r,n),patterns:{},sortKey:h};o.push(p)}i&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:i,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Fa("fill",this.layers,n,this.zoom,this.pixelRatio,e);this.patternFeatures.push(t)}else this.addFeature(n,i,o,r,{},e.availableImages,e.brightness,e.elevationFeatures);e.featureIndex.insert(t[o].feature,i,o,s,this.index)}}update(t,e,r,n,i,o,s){this.bufferData.update(t,e,r,n,i,o,s,this.worldview),this.elevationBufferData.update(t,e,r,n,i,o,s,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(t,e,r,n,i,o,s,this.worldview)}addFeatures(t,e,r,n,i,o){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,e,r,n,o,t.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(t){this.bufferData.upload(t),this.elevationBufferData.upload(t),this.elevatedStructures&&this.elevatedStructures.upload(t)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(t,e,r,n,i,o=[],s,a){const l=ka(e,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(t,l,n,r,a):this.addGeometry(l,this.bufferData),this.bufferData.populatePaintArrays(t,r,i,o,n,s,this.worldview),this.elevationBufferData.populatePaintArrays(t,r,i,o,n,s,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(t,e,r,n,i){this.elevatedStructures&&(this.elevatedStructures.construct(t),this.elevatedStructures.populatePaintArrays(e,r,n,i,this.worldview))}addElevatedRoadFeature(t,e,r,n,i){const o=new Array,s=ElevationFeatures.getElevationFeature(t,i);if(!s)return void this.addGeometry(e,this.bufferData);{const t=this.clipPolygonsToTile(e,1);t.length>0&&o.push({polygons:t,elevationFeature:s,elevationTileID:r})}const a={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(t,{},r),featureIndex:n};for(const e of o)if(e.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new ElevatedStructures(e.elevationTileID,this.layers,this.zoom,this.lut));const r=e.elevationFeature.isTunnel();let n=0;t.properties.hasOwnProperty(is)&&(n=+t.properties[is]);for(const t of e.polygons)this.elevatedStructures.addPortalCandidates(e.elevationFeature.id,t,r,e.elevationFeature,n)}null==e.elevationFeature.constantHeight&&(e.polygons=this.prepareElevatedPolygons(e.polygons,e.elevationFeature,e.elevationTileID));const i=new ElevationFeatureSampler(r,e.elevationTileID);this.addElevatedGeometry(e.polygons,i,e.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,n,a)}}addElevatedGeometry(t,e,r,n,i,o){const s={elevation:r,elevationSampler:e,bias:n,index:i,featureInfo:o},[a,l]=this.addGeometry(t,this.elevationBufferData,s);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:a,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,a),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l))}addGeometry(t,e,r){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=null;r&&(o=r.elevationSampler.constantElevation(r.elevation,r.bias),null!=o&&(n=o,i=o));const s=(t,s,a)=>{if(null!=r)if(s.push(t),null!=o)e.elevatedLayoutVertexArray.emplaceBack(o),a.push(o);else{const o=r.elevationSampler.pointElevation(t,r.elevation,r.bias);e.elevatedLayoutVertexArray.emplaceBack(o),a.push(o),n=Math.min(n,o),i=Math.max(i,o)}};for(const n of t){let t=0;for(const e of n)t+=e.length;const i=e.triangleSegments.prepareSegment(t,e.layoutVertexArray,e.indexArray),o=i.vertexLength,a=[],l=[],u=[],c=[],h=[],p=e.layoutVertexArray.length;for(const t of n){if(0===t.length)continue;t!==n[0]&&l.push(a.length/2);const i=e.lineSegments.prepareSegment(t.length,e.layoutVertexArray,e.lineIndexArray),o=i.vertexLength;r&&h.push(e.layoutVertexArray.length-p),s(t[0],u,c),e.layoutVertexArray.emplaceBack(t[0].x,t[0].y),e.lineIndexArray.emplaceBack(o+t.length-1,o),a.push(t[0].x),a.push(t[0].y);for(let r=1;r<t.length;r++)s(t[r],u,c),e.layoutVertexArray.emplaceBack(t[r].x,t[r].y),e.lineIndexArray.emplaceBack(o+r-1,o+r),a.push(t[r].x),a.push(t[r].y);i.vertexLength+=t.length,i.primitiveLength+=t.length}const d=aa(a,l);for(let t=0;t<d.length;t+=3)e.indexArray.emplaceBack(o+d[t],o+d[t+1],o+d[t+2]);if(d.length>0&&r&&"hd-road-base"===this.elevationMode){const t=r.elevation.isTunnel(),e=r.elevation.safeArea,n=this.elevatedStructures.addVertices(u,c);this.elevatedStructures.addTriangles(d,n,t);const i=h.length;if(i>0){for(let o=0;o<i-1;o++)this.elevatedStructures.addRenderableRing(r.index,h[o]+n,h[o+1]-h[o],t,e,r.featureInfo);this.elevatedStructures.addRenderableRing(r.index,h[i-1]+n,u.length-h[i-1],t,e,r.featureInfo)}}i.vertexLength+=t,i.primitiveLength+=d.length/3}return[n,i]}prepareElevatedPolygons(t,e,r){const n=1/Go(r),i=[];for(const r of t){const t=Ga(r,new EdgeIterator(e,n));i.push(...t)}return i}clipPolygonsToTile(t,e){const r=-e,n=-e,i=Ue+e,o=Ue+e;let s=0;const a=[],l=[];for(;s<t.length;s++){const e=t[s],u=we(e);(u.min.x>=r&&u.max.x<=i&&u.min.y>=n&&u.max.y<=o?a:l).push(e)}if(a.length===t.length)return t;const u=[new ot(r,n),new ot(i,n),new ot(i,o),new ot(r,o),new ot(r,n)],c=a;for(const t of l)c.push(...ja(t,u));return c}}let Ha,Xa,Za,Wa;Yn(FillBucket,"FillBucket",{omit:["layers","patternFeatures"]}),Yn(FillBufferData,"FillBufferData"),Yn(ElevatedStructures,"ElevatedStructures");class TriangleGridIndex{constructor(t,e,r,n){if(this.triangleCount=e.length/3,this.min=new ot(0,0),this.max=new ot(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===t.length)return;const[i,o]=[t[0].clone(),t[0].clone()];for(let e=1;e<t.length;++e){const r=t[e];i.x=Math.min(i.x,r.x),i.y=Math.min(i.y,r.y),o.x=Math.max(o.x,r.x),o.y=Math.max(o.y,r.y)}if(n){const t=Math.ceil(Math.max(o.x-i.x,o.y-i.y)/n);r=Math.max(r,t)}if(0===r)return;this.min=i,this.max=o;const s=this.max.sub(this.min);s.x=Math.max(s.x,1),s.y=Math.max(s.y,1);const a=Math.max(s.x,s.y)/r;this.cellsX=Math.max(1,Math.ceil(s.x/a)),this.cellsY=Math.max(1,Math.ceil(s.y/a)),this.xScale=1/a,this.yScale=1/a;const l=[];for(let r=0;r<this.triangleCount;r++){const n=t[e[3*r+0]].sub(this.min),i=t[e[3*r+1]].sub(this.min),o=t[e[3*r+2]].sub(this.min),s=Ya(Math.floor(Math.min(n.x,i.x,o.x)),this.xScale,this.cellsX),u=Ya(Math.floor(Math.max(n.x,i.x,o.x)),this.xScale,this.cellsX),c=Ya(Math.floor(Math.min(n.y,i.y,o.y)),this.yScale,this.cellsY),h=Ya(Math.floor(Math.max(n.y,i.y,o.y)),this.yScale,this.cellsY),p=new ot(0,0),d=new ot(0,0),f=new ot(0,0),y=new ot(0,0);for(let t=c;t<=h;++t){p.y=d.y=t*a,f.y=y.y=(t+1)*a;for(let e=s;e<=u;++e)p.x=f.x=e*a,d.x=y.x=(e+1)*a,(Is(n,i,o,p,d,y)||Is(n,i,o,p,y,f))&&l.push({cellIdx:t*this.cellsX+e,triIdx:r})}}if(0===l.length)return;l.sort(((t,e)=>t.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let u=0;for(;u<l.length;){const t=l[u].cellIdx,e={start:this.payload.length,len:0};for(;u<l.length&&l[u].cellIdx===t;)++e.len,this.payload.push(l[u++].triIdx);this.cells[t]=e}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(t,e){if(0===this.triangleCount||0===this.cells.length)return;if(t.x>this.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const r=Ya(t.x-this.min.x,this.xScale,this.cellsX),n=Ya(t.y-this.min.y,this.yScale,this.cellsY),i=this.cells[n*this.cellsX+r];if(i){this._lazyInitLookup();for(let t=0;t<i.len;t++){const r=this.payload[i.start+t],n=Math.floor(r/8),o=1<<r%8;if(!(this.lookup[n]&o)&&(this.lookup[n]|=o,e.push(r),e.length===this.triangleCount))return}}}query(t,e,r){if(0===this.triangleCount||0===this.cells.length)return;if(t.x>this.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Ya(t.x-this.min.x,this.xScale,this.cellsX),i=Ya(e.x-this.min.x,this.xScale,this.cellsX),o=Ya(t.y-this.min.y,this.yScale,this.cellsY),s=Ya(e.y-this.min.y,this.yScale,this.cellsY);for(let t=o;t<=s;t++)for(let e=n;e<=i;e++){const n=this.cells[t*this.cellsX+e];if(n)for(let t=0;t<n.len;t++){const e=this.payload[n.start+t],i=Math.floor(e/8),o=1<<e%8;if(!(this.lookup[i]&o)&&(this.lookup[i]|=o,r.push(e),r.length===this.triangleCount))return}}}}function Ya(t,e,r){return Math.max(0,Math.min(r-1,Math.floor(t*e)))}Yn(TriangleGridIndex,"TriangleGridIndex");class ClipBucket{constructor(t){this.zoom=t.zoom,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[],this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,e){for(const r of this.footprints)e.push({footprint:r,id:t})}updateAppearances(t,e,r,n){}populate(t,e,r,n){const i=[];for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Ko(o,t);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:e.activeFloors}),u,r))continue;const c={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:a,geometry:t?u.geometry:Jo(o,r,n),patterns:{}};i.push(c)}for(const n of i){const{geometry:i,index:o,sourceLayerIndex:s}=n;this.addFeature(n,i,o,r,{},e.availableImages,e.brightness),e.featureIndex.insert(t[o].feature,i,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(t){}update(t,e,r,n,i,o,s){}destroy(){}addFeature(t,e,r,n,i,o=[],s){for(const t of ka(e,2)){const e=[],r=[],n=[],i=new ot(1/0,1/0),o=new ot(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(r.length/2);for(let t=0;t<s.length;t++)r.push(s[t].x),r.push(s[t].y),e.push(s[t]),i.x=Math.min(i.x,s[t].x),i.y=Math.min(i.y,s[t].y),o.x=Math.max(o.x,s[t].x),o.y=Math.max(o.y,s[t].y)}const s=aa(r,n),a=new TriangleGridIndex(e,s,8,256);this.footprints.push({vertices:e,indices:s,grid:a,min:i,max:o})}}}Yn(ClipBucket,"ClipBucket",{omit:["layers"]});const Ja=Zi([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Ka=Zi([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Qa=Zi([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),tl=Zi([{name:"a_centroid_pos",components:2,type:"Uint16"}]),el=Zi([{name:"a_join_normal_inside",components:3,type:"Int16"}]),rl=Zi([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),nl=Zi([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:il}=Ja,ol=Number.MAX_SAFE_INTEGER,sl=ol-1;function al(t,e,r,n){return t.order<e||t.order===ol||!(t.clipMask&r)||function(t,e){return 0!==e.length&&void 0===e.find((e=>e===t))}(n,t.clipScope)}function ll(t,e){return t.x-e.x||t.y-e.y}function ul(t,e){return 0===ll(t.min,e.min)&&0===ll(t.max,e.max)}function cl(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r].sourceId!==e[r].sourceId||!ul(t[r],e[r])||t[r].order!==e[r].order||t[r].clipMask!==e[r].clipMask||!st(t[r].clipScope,e[r].clipScope))return!1;return!0}function hl(t,e,r,n,i,o,s){const a=t.indices,l=t.vertices,u=[];for(let c=n;c<n+i;c+=3){const n=e[r[c+0]+o],i=e[r[c+1]+o],h=e[r[c+2]+o],p=Math.min(n.x,i.x,h.x),d=Math.max(n.x,i.x,h.x),f=Math.min(n.y,i.y,h.y),y=Math.max(n.y,i.y,h.y);u.length=0,t.grid.query(new ot(p,f),new ot(d,y),u);for(let t=0;t<u.length;t++){const e=u[t];if(Is(l[a[3*e+0]],l[a[3*e+1]],l[a[3*e+2]],n,i,h,s))return!0}}return!1}function pl(t,e,r,n){const i=Math.pow(2,n.z-r.z);return new ot((t+r.x*Ue)*i-n.x*Ue,(e+r.y*Ue)*i-n.y*Ue)}function dl(t,e){const r=[];e.grid.queryPoint(t,r);const n=e.indices,i=e.vertices;for(let e=0;e<r.length;e++){const o=r[e];if(_s([i[n[3*o+0]],i[n[3*o+1]],i[n[3*o+2]]],t))return!0}return!1}const fl=[new ot(0,0),new ot(Ue,0),new ot(Ue,Ue),new ot(0,Ue)];function yl(t,e){const r=[];let n=[];if(!e||t.length<2)return[t];if(2===t.length)return As(t[0],t[1],fl)?[t]:[];for(let e=0;e<t.length+2;e++){const i=t[e%t.length],o=t[(e+1)%t.length],s=As(0===e?t[t.length-1]:t[(e-1)%t.length],i,fl),a=As(i,o,fl),l=s||a;l&&n.push(i),l&&a||n.length>0&&(n.length>1&&r.push(n),n=[])}return n.length>1&&r.push(n),r}const ml=VectorTileFeature.types,gl=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],xl=["fill-extrusion-flood-light-ground-radius"],vl=Math.pow(2,13),bl=Math.pow(2,15)-1,wl=new ot(0,1),_l=2147483648,Al=7,Sl=450;function Il(t,e,r,n,i,o,s,a){t.emplaceBack((e<<1)+s,(r<<1)+o,(Math.floor(n*vl)<<1)+i,Math.round(a))}function Pl(t,e,r){t.emplaceBack(e.x*Ue,e.y*Ue,r?1:0)}function Ml(t,e,r,n,i,o){t.emplaceBack(e.x,e.y,(r.x<<1)+n,(r.y<<1)+i,o)}function Dl(t,e,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,r[0]*n,r[1]*n,r[2]*n)}class FootprintSegment{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class PartData{constructor(){this.centroidXY=new ot(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new ot(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new ot(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new ot(this.max.x-this.min.x,this.max.y-this.min.y)}}class BorderCentroidData{constructor(){this.acc=new ot(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(t,e){t.min.x===Number.MAX_VALUE&&(t.min.x=t.max.x=e.x,t.min.y=t.max.y=e.y)}appendEdge(t,e,r){this.accCount++,this.acc._add(e);let n=!!this.borders;e.x<t.min.x?(t.min.x=e.x,n=!0):e.x>t.max.x&&(t.max.x=e.x,n=!0),e.y<t.min.y?(t.min.y=e.y,n=!0):e.y>t.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Ue)&&e.x===r.x)!=((0===e.y||e.y===Ue)&&e.y===r.y)&&this.processBorderOverlap(e,r),n&&this.checkBorderIntersection(e,r)}checkBorderIntersection(t,e){e.x<0!=t.x<0&&this.addBorderIntersection(0,Vt(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>Ue!=t.x>Ue&&this.addBorderIntersection(1,Vt(e.y,t.y,(Ue-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,Vt(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>Ue!=t.y>Ue&&this.addBorderIntersection(3,Vt(e.x,t.x,(Ue-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const r=this.borders[t];e<r[0]&&(r[0]=e),e>r[1]&&(r[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const r=0===t.x?0:1;this.addBorderIntersection(r,e.y),this.addBorderIntersection(r,t.y)}else{const r=0===t.y?2:3;this.addBorderIntersection(r,e.x),this.addBorderIntersection(r,t.x)}}centroid(){return 0===this.accCount?new ot(0,0):new ot(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function El(t,e){const r=t.add(e)._unit(),n=ht(t.x*r.x+t.y*r.y,-1,1);var i,o,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*bl*((i=t).x*(o=e).y-i.y*o.x<0?-1:1)}const Cl=[t=>t.x<0,t=>t.x>Ue,t=>t.y<0,t=>t.y>Ue];function Bl(t,e,r,n){const i=[4];if(0===n)return i;r._mult(n);const o=t.sub(r),s=e.sub(r),a=[t,e,o,s];for(let t=0;t<4;t++)for(const e of a)if(Cl[t](e)){i.push(t);break}return i}class GroundEffect{constructor(t){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new StructArrayLayout5i10,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(t.layers,{zoom:t.zoom,lut:t.lut},(t=>xl.includes(t))),this._segments=new SegmentVector,this.hiddenByLandmarkVertexArray=new StructArrayLayout1ub1,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new SegmentVector}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,r,n=!1){const i=t.length;if(i>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*i,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 e=t[0],r=t[1];a=El(e.sub(t[i-1])._perp()._unit(),r.sub(e)._perp()._unit())}for(let l=0;l<i;l++){const u=l===i-1?0:l+1,c=t[l],h=t[u],p=t[u===i-1?0:u+1],d=h.sub(c)._perp()._unit(),f=El(d,p.sub(h)._perp()._unit()),y=a,m=f;if(Ll(c,h,e)||n&&Vl(c,e)&&Vl(h,e)){a=f;continue}const g=s.vertexLength;Ml(this.vertexArray,c,h,1,1,y),Ml(this.vertexArray,c,h,1,0,y),Ml(this.vertexArray,c,h,0,1,m),Ml(this.vertexArray,c,h,0,0,m),s.vertexLength+=4;const x=Bl(c,h,d,r);for(const t of x)this._segmentToGroundQuads[o].push({id:g,region:t}),this._segmentToRegionTriCounts[o][t]+=2,s.primitiveLength+=2;a=f}}}prepareBorderSegments(){if(!this.hasData())return;const t=this._segments.get(),e=t.length;for(let t=0;t<e;t++)this._segmentToGroundQuads[t].sort(((t,e)=>t.region-e.region));for(let r=0;r<e;r++){const e=this._segmentToGroundQuads[r],n=t[r],i=this._segmentToRegionTriCounts[r];i.reduce(((t,e)=>t+e),0);let o=0;for(let t=0;t<=4;t++){const e=i[t];if(0!==e){let r=this.regionSegments[t];r||(r=this.regionSegments[t]=new SegmentVector);const i={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+o,vertexLength:n.vertexLength,primitiveLength:e};r.get().push(i)}o+=e}for(let t=0;t<e.length;t++){const r=e[t].id;this.indexArray.emplaceBack(r,r+1,r+3),this.indexArray.emplaceBack(r,r+3,r+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(t,e,r,n,i,o,s){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,t,e,r,n,i,o,void 0,s)}upload(t){this.hasData()&&(this.vertexBuffer=t.createVertexBuffer(this.vertexArray,Ka.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),null!=this.groundRadiusArray&&(this.groundRadiusBuffer=t.createVertexBuffer(this.groundRadiusArray,Qa.members)))}uploadPaintProperties(t){this.hasData()&&this.programConfigurations.upload(t)}update(t,e,r,n,i,o,s,a){this.hasData()&&this.programConfigurations.updatePaintArrays(t,e,r,n,i,o,s,a)}updateHiddenByLandmark(t){this.updateHiddenByLandmarkRange(t.groundVertexArrayOffset,t.groundVertexCount,!!(t.flags&_l))}updateHiddenByLandmarkRange(t,e,r){if(!this.hasData())return;const n=e+t;if(0!==e){for(let e=t;e<n;++e)this.hiddenByLandmarkVertexArray.emplace(e,r?1:0);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(t){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,rl.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;t<=4;t++){const e=this.regionSegments[t];e&&e.destroy()}}}}class FillExtrusionBucket{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.pixelRatio=t.pixelRatio,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new StructArrayLayout3ui6,this.footprintVertices=new StructArrayLayout2i4,this.footprintSegments=[],this.layoutVertexArray=new StructArrayLayout4i8,this.centroidVertexArray=new FillExtrusionCentroidArray,this.wallVertexArray=new FillExtrusionWallArray,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(t.layers,{zoom:t.zoom,lut:t.lut},(t=>gl.includes(t))),this.segments=new SegmentVector,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new GroundEffect(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,e){}updateAppearances(t,e,r,n){}populate(t,e,r,n){this.features=[],this.hasPattern=Va("fill-extrusion",this.layers,this.pixelRatio,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Go(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:i,id:o,index:s,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Ko(i,t);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:e.activeFloors}),l,r))continue;const u={id:o,sourceLayerIndex:a,index:s,geometry:t?l.geometry:Jo(i,r,n),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length,h="Polygon"===ml[u.type];if(this.hasPattern)this.features.push({featureId:i.id,feature:Fa("fill-extrusion",this.layers,u,this.zoom,this.pixelRatio,e)});else if(this.wallMode)for(const t of u.geometry)for(const o of yl(t,h))this.addFeature(i.id,u,[o],s,r,{},e.availableImages,n,e.brightness);else this.addFeature(i.id,u,u.geometry,s,r,{},e.availableImages,n,e.brightness);e.featureIndex.insert(i,u.geometry,s,a,this.index,c)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(t,e,r,n,i,o){for(const{featureId:t,feature:s}of this.features){const a="Polygon"===ml[s.type],{geometry:l}=s;if(this.wallMode)for(const u of l)for(const l of yl(u,a))this.addFeature(t,s,[l],s.index,e,r,n,i,o);else this.addFeature(t,s,l,s.index,e,r,n,i,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(t,e,r,n,i,o,s){this.programConfigurations.updatePaintArrays(t,e,i,r,n,o,s,this.worldview),this.groundEffect.update(t,e,i,r,n,o,s,this.worldview)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,il),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,el.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,nl.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,tl.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,r,n,i,o,s,a,l){const u=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,c=[new ot(0,0),new ot(Ue,Ue)],h=a.projection,p="globe"===h.name,d=this.wallMode||"Polygon"===ml[e.type],f=new BorderCentroidData;f.centroidDataIndex=this.centroidData.length;const y=new PartData;y.buildingId=t,e.properties&&e.properties.hasOwnProperty("building_id")&&(y.buildingId=e.properties.building_id);const m=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},i)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},i);let x;if(y.height=g,y.vertexArrayOffset=this.layoutVertexArray.length,y.groundVertexArrayOffset=this.groundEffect.vertexArray.length,p&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new StructArrayLayout6i12),this.wallMode){if(p)return void vt("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==r.length)return;x=function(t){const e=t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y,r=function(t){let e=0;const r=t.length;for(let n=0;n<r;n++)e+=(t[(n+1)%r].x-t[n].x)*(t[(n+1)%r].y+t[n].y);return e>=0}(t);r||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},i=[],o=[],s=[];let a=t.length;for(;a>=2&&t[a-1].equals(t[a-2]);)a--;if(a<(e?3:2))return n;let l,u,c,h,p,d=0;for(;d<a-1&&t[d].equals(t[d+1]);)d++;e&&(l=t[a-2],p=t[d].sub(l)._unit()._perp());for(let r=d;r<a;r++){if(c=r===a-1?e?t[d+1]:void 0:t[r+1],c&&t[r].equals(c))continue;p&&(h=p),l&&(u=l),l=t[r],p=c?c.sub(l)._unit()._perp():h,h=h||p;let n=h.add(p);0===n.x&&0===n.y||n._unit();const f=n.x*p.x+n.y*p.y,y=0!==f?1/f:1/0,m=h.x*p.y-h.y*p.x>0;let g="miter";const x=2;"miter"===g&&y>x&&(g="bevel"),"bevel"===g&&(y>100&&(g="flipbevel"),y<x&&(g="miter"));const v=(t,e,r,n)=>{const a=new ot(t.x,t.y),l=new ot(t.x,t.y);a.x+=e.x*n,a.y+=e.y*n,l.x-=e.x*Math.max(r,1),l.y-=e.y*Math.max(r,1),s.push(e),i.push(a),o.push(l)};if("miter"===g)n._mult(y),v(l,n,0,0);else if("flipbevel"===g)n=p.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else{const t=-Math.sqrt(y*y-1),e=m?t:0,r=m?0:t;u&&v(l,h,e,r),c&&v(l,p,e,r)}}n.geometry=[...i,...o.reverse(),i[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let t=0;t<f/2;t++)if(t+1<f/2){let e=t,r=t+1,i=f-1-t,o=f-2-t;e=0===e?f-1:e-1,r=0===r?f-1:r-1,i=0===i?f-1:i-1,o=0===o?f-1:o-1,n.indices.push(i),n.indices.push(r),n.indices.push(e),n.indices.push(i),n.indices.push(o),n.indices.push(r)}return n}(r[0]),r=[x.geometry]}const v=(t,e)=>t<(e.length-1)/2||t===e.length-1,b=this.wallMode?[r]:ka(r,500);for(let t=b.length-1;t>=0;t--){const e=b[t];(0===e.length||(w=e[0]).every((t=>t.x<=0))||w.every((t=>t.x>=Ue))||w.every((t=>t.y<=0))||w.every((t=>t.y>=Ue)))&&b.splice(t,1)}var w;let _;if(p)_=Ol(b,c,i);else{_=[];for(const t of b)_.push({polygon:t,bounds:c})}const A=d?this.edgeRadius:0,S=A>0&&this.zoom<17,I=(t,e)=>{if(0===t.length)return!1;const r=t[t.length-1];return e.x===r.x&&e.y===r.y};for(const{polygon:t,bounds:e}of _){let r=0,n=0;for(const e of t)d&&!e[0].equals(e[e.length-1])&&e.push(e[0]),n+=d?e.length-1:e.length;const o=this.segments.prepareSegment((d?5:4)*n,this.layoutVertexArray,this.indexArray);y.footprintSegIdx<0&&(y.footprintSegIdx=this.footprintSegments.length),y.polygonSegIdx<0&&(y.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new FootprintSegment;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],d){const n=[],s=[];r=o.vertexLength;for(let r=0;r<t.length;r++){const l=t[r];l.length&&0!==r&&s.push(n.length/2);const c=[];let d,f;d=l[1].sub(l[0])._perp()._unit(),a.ringIndices.push(l.length-1);for(let t=1;t<l.length;t++){const e=l[t],r=l[t===l.length-1?1:t+1],s=e.clone();if(A){f=r.sub(e)._perp()._unit();const t=d.add(f)._unit(),n=A*Math.min(4,1/(d.x*t.x+d.y*t.y));s.x+=n*t.x,s.y+=n*t.y,s.x=Math.round(s.x),s.y=Math.round(s.y),d=f}if(!m||0!==A&&!S||I(c,s)||c.push(s),Il(this.layoutVertexArray,s.x,s.y,0,0,1,1,0),this.wallMode){const e=v(t,l);Pl(this.wallVertexArray,x.joinNormals[t],!e)}o.vertexLength++,this.footprintVertices.emplaceBack(e.x,e.y),n.push(e.x,e.y),p&&Dl(this.layoutVertexExtArray,h.projectTilePoint(s.x,s.y,i),h.upVector(i,s.x,s.y))}m&&(0===A||S)&&(0!==c.length&&I(c,c[0])&&c.pop(),this.groundEffect.addData(c,e,u))}const l=this.wallMode?x.indices:aa(n,s);for(let t=0;t<l.length;t+=3)this.footprintIndices.emplaceBack(a.vertexOffset+l[t+0],a.vertexOffset+l[t+1],a.vertexOffset+l[t+2]),this.indexArray.emplaceBack(r+l[t],r+l[t+2],r+l[t+1]),o.primitiveLength++;a.indexCount+=l.length,a.vertexCount+=this.footprintVertices.length-a.vertexOffset}for(let n=0;n<t.length;n++){const s=t[n];f.startRing(y,s[0]);let a=s.length>4&&Fl(s[s.length-2],s[0],s[1]),l=A?kl(s[s.length-2],s[0],s[1],A):0;const c=[];let g,b,w;b=s[1].sub(s[0])._perp()._unit();let _=!0;for(let t=1,n=0;t<s.length;t++){let u=s[t-1],d=s[t];const S=s[t===s.length-1?1:t+1];if(f.appendEdge(y,d,u),Ll(d,u,e)){A&&(b=S.sub(d)._perp()._unit(),_=!_);continue}const P=d.sub(u)._perp(),M=P.x/(Math.abs(P.x)+Math.abs(P.y)),D=P.y>0?1:0,E=u.dist(d);if(n+E>32768&&(n=0),A){w=S.sub(d)._perp()._unit();let t=zl(u,d,S,Tl(b,w),A);isNaN(t)&&(t=0);const e=d.sub(u)._unit();u=u.add(e.mult(l))._round(),d=d.add(e.mult(-t))._round(),l=t,b=w,m&&this.zoom>=17&&(I(c,u)||c.push(u),I(c,d)||c.push(d))}const C=o.vertexLength,B=s.length>4&&Fl(u,d,S);let T=Rl(n,a,_);if(Il(this.layoutVertexArray,u.x,u.y,M,D,0,0,T),Il(this.layoutVertexArray,u.x,u.y,M,D,0,1,T),this.wallMode){const e=v(t-1,s),r=x.joinNormals[t-1];Pl(this.wallVertexArray,r,e),Pl(this.wallVertexArray,r,e)}if(n+=E,T=Rl(n,B,!_),a=B,Il(this.layoutVertexArray,d.x,d.y,M,D,0,0,T),Il(this.layoutVertexArray,d.x,d.y,M,D,0,1,T),this.wallMode){const e=v(t,s),r=x.joinNormals[t];Pl(this.wallVertexArray,r,e),Pl(this.wallVertexArray,r,e)}if(o.vertexLength+=4,this.indexArray.emplaceBack(C+0,C+1,C+2),this.indexArray.emplaceBack(C+1,C+3,C+2),o.primitiveLength+=2,A){const n=r+(1===t?s.length-2:t-2),i=1===t?r:n+1;if(this.indexArray.emplaceBack(C+1,n,C+3),this.indexArray.emplaceBack(n,i,C+3),o.primitiveLength+=2,void 0===g&&(g=C),!Ll(S,s[t],e)){const e=t===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(C+2,C+3,e),this.indexArray.emplaceBack(C+3,e+1,e),this.indexArray.emplaceBack(C+3,i,e+1),o.primitiveLength+=3}_=!_}if(p){const t=this.layoutVertexExtArray,e=h.projectTilePoint(u.x,u.y,i),r=h.projectTilePoint(d.x,d.y,i),n=h.upVector(i,u.x,u.y),o=h.upVector(i,d.x,d.y);Dl(t,e,n),Dl(t,e,n),Dl(t,r,o),Dl(t,r,o)}}d&&(r+=s.length-1),m&&A&&this.zoom>=17&&(0!==c.length&&I(c,c[0])&&c.pop(),this.groundEffect.addData(c,e,u,A>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++y.footprintSegLen,++y.polygonSegLen}if(y.vertexCount=this.layoutVertexArray.length-y.vertexArrayOffset,y.groundVertexCount=this.groundEffect.vertexArray.length-y.groundVertexArrayOffset,0!==y.vertexCount){if(y.centroidXY=f.borders?wl:this.encodeCentroid(f,y),this.centroidData.push(y),f.borders){this.featuresOnBorder.push(f);const t=this.featuresOnBorder.length-1;for(let e=0;e<f.borders.length;e++)f.borders[e][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[e].push(t)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,o,s,i,l,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(e,n,o,s,i,l,this.worldview),this.maxHeight=Math.max(this.maxHeight,g)}}sortBorders(){for(let t=0;t<this.borderFeatureIndices.length;t++)this.borderFeatureIndices[t].sort(((e,r)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[r].borders[t][0]))}splitToSubtiles(){const t=[];for(let e=0;e<this.centroidData.length;e++){const r=this.centroidData[e],n=+(r.min.y+r.max.y>Ue),i=2*n+(+(r.min.x+r.max.x>Ue)^n);for(let n=0;n<r.polygonSegLen;n++){const o=r.polygonSegIdx+n;t.push({centroidIdx:e,subtile:i,polygonSegmentIdx:o,triangleSegmentIdx:this.polygonSegments[o].triangleSegIdx})}}const e=new StructArrayLayout3ui6;t.sort(((t,e)=>t.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let r=0,n=0,i=0;for(const e of t){if(e.triangleSegmentIdx!==r)break;i++}const o=t.length;for(;n!==t.length;){r=t[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let e=a;e<i&&t[e].subtile===s;e++)l++;for(;a!==i;){const n=t[a];s=n.subtile;const o=this.centroidData[n.centroidIdx].min.clone(),u=this.centroidData[n.centroidIdx].max.clone(),c={vertexOffset:this.segments.segments[r].vertexOffset,primitiveOffset:e.length,vertexLength:this.segments.segments[r].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let r=a;r<l;r++){const n=t[r],i=this.polygonSegments[n.polygonSegmentIdx],s=this.centroidData[n.centroidIdx].min,a=this.centroidData[n.centroidIdx].max,l=this.indexArray.uint16;for(let t=i.triangleArrayOffset;t<i.triangleArrayOffset+i.triangleCount;t++)e.emplaceBack(l[3*t],l[3*t+1],l[3*t+2]);c.primitiveLength+=i.triangleCount,o.x=Math.min(o.x,s.x),o.y=Math.min(o.y,s.y),u.x=Math.max(u.x,a.x),u.y=Math.max(u.y,a.y)}c.primitiveLength>0&&this.triangleSubSegments.push({segment:c,min:o,max:u}),a=l;for(let e=a;e<i&&t[e].subtile===t[a].subtile;e++)l++}n=i;for(let e=n;e<o&&t[e].triangleSegmentIdx===t[n].triangleSegmentIdx;e++)i++}e._trim(),this.indexArray=e}getVisibleSegments(t,e,r){const n=new SegmentVector;if(this.wallMode){for(const t of this.triangleSubSegments)n.segments.push(t.segment);return n}let i=0,o=0;const s=1<<t.canonical.z;if(e){const r=e.getMinMaxForTile(t);r&&(i=r.min,o=r.max)}o+=this.maxHeight;const a=t.toUnwrapped();let l;const u=[a.canonical.x/s+a.wrap,a.canonical.y/s],c=[(a.canonical.x+1)/s+a.wrap,(a.canonical.y+1)/s],h=(t,e,r)=>[t[0]*(1-r[0])+e[0]*r[0],t[1]*(1-r[1])+e[1]*r[1]],p=[],d=[];for(const t of this.triangleSubSegments){p[0]=t.min.x/Ue,p[1]=t.min.y/Ue,d[0]=t.max.x/Ue,d[1]=t.max.y/Ue;const e=h(u,c,p),s=h(u,c,d);if(0===new Aabb([e[0],e[1],i],[s[0],s[1],o]).intersectsPrecise(r)){l&&(n.segments.push(l),l=void 0);continue}const a=t.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(t,e){const r=t.centroid(),n=e.span(),i=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new ot(ht(r.x,1,Ue-1)<<3|i,ht(r.y,1,Ue-1)<<3|o)}encodeBorderCentroid(t){if(!t.borders)return new ot(0,0);const e=t.borders,r=Number.MAX_VALUE;if(e[0][0]!==r||e[1][0]!==r){const t=e[0][0]!==r?0:1;return new ot(6|(e[0][0]!==r?0:65528),(e[t][0]+e[t][1])/2<<3|6)}{const t=e[2][0]!==r?2:3;return new ot((e[t][0]+e[t][1])/2<<3|6,6|(e[2][0]!==r?0:65528))}}showCentroid(t){const e=this.centroidData[t.centroidDataIndex];e.flags&=2147483647,e.centroidXY.x=0,e.centroidXY.y=0,this.writeCentroidToBuffer(e)}writeCentroidToBuffer(t){this.groundEffect.updateHiddenByLandmark(t);const e=t.vertexArrayOffset,r=t.vertexCount+t.vertexArrayOffset,n=t.flags&_l?wl:t.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(e);if(this.centroidVertexArray.geta_centroid_pos1(e)!==n.y||i!==n.x){for(let t=e;t<r;++t)this.centroidVertexArray.emplace(t,n.x,n.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of this.centroidData)this.writeCentroidToBuffer(t)}updateReplacement(t,e,r){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped());if(cl(this.activeReplacements,n))return;if(this.activeReplacements=n,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(const t of this.centroidData)t.flags&=2147483647;const i=[];for(const e of this.activeReplacements){if(e.order<r)continue;const n=Math.max(1,Math.pow(2,e.footprintTileId.canonical.z-t.canonical.z));if(e.footprint.buildingIds)for(const t of this.centroidData)t.flags&_l||e.min.x>t.max.x||t.min.x>e.max.x||e.min.y>t.max.y||t.min.y>e.max.y||e.footprint.buildingIds.has(t.buildingId)&&(t.flags|=_l);else for(const r of this.centroidData)if(!(r.flags&_l||e.min.x>r.max.x||r.min.x>e.max.x||e.min.y>r.max.y||r.min.y>e.max.y))for(let o=0;o<r.footprintSegLen;o++){const s=this.footprintSegments[r.footprintSegIdx+o];if(i.length=0,Ul(this.footprintVertices,s.vertexOffset,s.vertexCount,e.footprintTileId.canonical,t.canonical,i),hl(e.footprint,i,this.footprintIndices.uint16,s.indexOffset,s.indexCount,-s.vertexOffset,-n)){r.flags|=_l;break}}}for(const t of this.centroidData)this.writeCentroidToBuffer(t);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(t,e,r){let n=!1;for(let i=0;i<r.footprintSegLen;i++){const o=this.footprintSegments[r.footprintSegIdx+i];let s=0;for(const r of o.ringIndices){for(let i=s,a=r+s-1;i<r+s;a=i++){const r=this.footprintVertices.int16[2*(i+o.vertexOffset)+0],s=this.footprintVertices.int16[2*(i+o.vertexOffset)+1],l=this.footprintVertices.int16[2*(a+o.vertexOffset)+1];s>e!=l>e&&t<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-r)*(e-s)/(l-s)+r&&(n=!n)}s=r}}return n}getHeightAtTileCoord(t,e){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(t+Ue)*Ue+(e+Ue);if(this.partLookup.hasOwnProperty(i)){const t=this.partLookup[i];return t?{height:t.height,hidden:!!(t.flags&_l)}:void 0}for(const o of this.centroidData)t>o.max.x||o.min.x>t||e>o.max.y||o.min.y>e||o.height<=r||this.footprintContainsPoint(t,e,o)&&(r=o.height,this.partLookup[i]=o,n=!!(o.flags&_l));if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:n};this.partLookup[i]=void 0}}function Tl(t,e){const r=t.add(e)._unit();return t.x*r.x+t.y*r.y}function kl(t,e,r,n){const i=e.sub(t)._perp()._unit(),o=r.sub(e)._perp()._unit();return zl(t,e,r,Tl(i,o),n)}function zl(t,e,r,n,i){const o=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(r)/3,i*o/n)}function Ll(t,e,r){return t.x<r[0].x&&e.x<r[0].x||t.x>r[1].x&&e.x>r[1].x||t.y<r[0].y&&e.y<r[0].y||t.y>r[1].y&&e.y>r[1].y}function Vl(t,e){return t.x<e[0].x||t.x>e[1].x||t.y<e[0].y||t.y>e[1].y}function Fl(t,e,r){if(t.x<0||t.x>=Ue||e.x<0||e.x>=Ue||r.x<0||r.x>=Ue)return!1;const n=r.sub(e),i=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&i.x*o.x+i.y*o.y<0}function Rl(t,e,r){const n=e?2|t:-3&t;return r?1|n:-2&n}function Ol(t,e,r){const n=1<<r.z,i=Ro(r.x/n),o=Ro((r.x+1)/n),s=Oo(r.y/n),a=Oo((r.y+1)/n);return function(t,e,r,n,i=0,o){const s=[];if(!t.length||!r||!n)return s;const a=(t,e)=>{for(const r of t)s.push({polygon:r,bounds:e})},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let t=0;t<Math.abs(c);t++)h.push(c>0?0:1);for(let t=0;t<Math.min(l,u);t++)h.push(0),h.push(1);let p=t;if(p=Na(p,e[0].y-i,e[1].y+i,1),p=Na(p,e[0].x-i,e[1].x+i,0),!p.length)return s;const d=[];for(h.length?d.push({polygons:p,bounds:e,depth:0}):a(p,e);d.length;){const t=d.pop(),e=t.depth,r=h[e],n=t.bounds[0],s=t.bounds[1],l=0===r?n.x:n.y,u=0===r?s.x:s.y,c=o?o(r,l,u):.5*(l+u),p=Na(t.polygons,l-i,c+i,r),f=Na(t.polygons,c-i,u+i,r);if(p.length){const t=[n,new ot(0===r?c:s.x,1===r?c:s.y)];h.length>e+1?d.push({polygons:p,bounds:t,depth:e+1}):a(p,t)}if(f.length){const t=[new ot(0===r?c:n.x,1===r?c:n.y),s];h.length>e+1?d.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-i)/11.25),Math.ceil((s-a)/11.25),1,((t,e,i)=>{if(0===t)return.5*(e+i);{const t=Oo((r.y+e/Ue)/n);return(Vo(.5*(Oo((r.y+i/Ue)/n)+t))*n-r.y)*Ue}}))}function Ul(t,e,r,n,i,o){const s=Math.pow(2,n.z-i.z);for(let a=0;a<r;a++){let r=t.int16[2*(a+e)+0],l=t.int16[2*(a+e)+1];r=(r+i.x*Ue)*s-n.x*Ue,l=(l+i.y*Ue)*s-n.y*Ue,o.push(new ot(r,l))}}let Nl,jl;Yn(FillExtrusionBucket,"FillExtrusionBucket",{omit:["layers","features"]}),Yn(PartData,"PartData"),Yn(FootprintSegment,"FootprintSegment"),Yn(BorderCentroidData,"BorderCentroidData"),Yn(GroundEffect,"GroundEffect");class Point3D extends ot{constructor(t,e,r){super(t,e),this.z=r}}class Point4D extends Point3D{constructor(t,e,r,n){super(t,e,r),this.w=n}}function Gl(t,e,r,n){const i="x"===r?"y":"x",o=(n-t[r])/(e[r]-t[r]);t[i]=Math.round(t[i]+(e[i]-t[i])*o),t[r]=n,t.hasOwnProperty("z")&&(t.z=Vt(t.z,e.z,o)),t.hasOwnProperty("w")&&(t.w=Vt(t.w,e.w,o))}function $l(t,e,r,n){const i=r,o=n;for(const r of["x","y"]){let n=t,s=e;n[r]>=s[r]&&(n=e,s=t),n[r]<i&&s[r]>i&&Gl(n,s,r,i),n[r]<o&&s[r]>o&&Gl(s,n,r,o)}}function ql(t,e,r,n,i,o){const s=[];for(let a=0;a<t.length;a++){const l=t[a];let u;const c=s.length;let h=0;for(let t=0;t<l.length-1;t++){let c=l[t],p=l[t+1],d=0;const f=h;let y,m;o&&(d=Math.hypot(p.x-c.x,p.y-c.y),h+=d,y=c,m=p),c.x<e&&p.x<e||(c.x<e?c=new ot(e,c.y+(e-c.x)/(p.x-c.x)*(p.y-c.y))._round():p.x<e&&(p=new ot(e,c.y+(e-c.x)/(p.x-c.x)*(p.y-c.y))._round()),c.y<r&&p.y<r||(c.y<r?c=new ot(c.x+(r-c.y)/(p.y-c.y)*(p.x-c.x),r)._round():p.y<r&&(p=new ot(c.x+(r-c.y)/(p.y-c.y)*(p.x-c.x),r)._round()),c.x>=n&&p.x>=n||(c.x>=n?c=new ot(n,c.y+(n-c.x)/(p.x-c.x)*(p.y-c.y))._round():p.x>=n&&(p=new ot(n,c.y+(n-c.x)/(p.x-c.x)*(p.y-c.y))._round()),c.y>=i&&p.y>=i||(c.y>=i?c=new ot(c.x+(i-c.y)/(p.y-c.y)*(p.x-c.x),i)._round():p.y>=i&&(p=new ot(c.x+(i-c.y)/(p.y-c.y)*(p.x-c.x),i)._round()),u&&c.equals(u[u.length-1])||(u=[c],s.push(u),o&&o.push({progress:{min:f+Xl(y,m,c)*d,max:1},parentIndex:a,prevPoint:y,nextPoint:m})),u.push(p),o&&(o[o.length-1].progress.max=f+Xl(y,m,p)*d,o[o.length-1].nextPoint=m)))))}if(o&&h>0)for(let t=c;t<s.length;t++)o[t].progress.min/=h,o[t].progress.max/=h}return s}function Hl(t,e,r,n,i){if(t.length<2)return void n.push(t);const o=[];for(;e.valid();){const[r,n]=e.get();for(let e=0;e<t.length-1;e++){const i=t[e],s=t[e+1],a=xs(i,s,r,n);if(a){const[t]=a,r=new ot(Vt(i.x,s.x,t),Vt(i.y,s.y,t));o.push({t:e+t,distance:0,point:r})}}e.next()}if(0===o.length)return void n.push(t);o.sort(((t,e)=>t.t-e.t));let s=0,a=0,l=[];for(n.push(l);s!==t.length;){if(a===o.length){for(;s!==t.length;)0!==l.length&&l[l.length-1].equals(t[s])||l.push(t[s]),s++;break}o[a].t<=s?(0!==l.length&&l[l.length-1].equals(o[a].point)||l.push(o[a].point),Math.trunc(o[a].t),a++):(0!==l.length&&l[l.length-1].equals(t[s])||l.push(t[s]),s++)}}function Xl(t,e,r){return t.x!==e.x?(r.x-t.x)/(e.x-t.x):t.y!==e.y?(r.y-t.y)/(e.y-t.y):0}function Zl(t,e){return t.x*e.x+t.y*e.y}function Wl(t,e){if(1===t.length){let r=0;const n=e[r++];let i;for(;!i||n.equals(i);)if(i=e[r++],!i)return 1/0;for(;r<e.length;r++){const o=e[r],s=t[0],a=i.sub(n),l=o.sub(n),u=s.sub(n),c=Zl(a,a),h=Zl(a,l),p=Zl(l,l),d=Zl(u,a),f=Zl(u,l),y=c*p-h*h,m=(p*d-h*f)/y,g=(c*f-h*d)/y,x=n.z*(1-m-g)+i.z*m+o.z*g;if(isFinite(x))return x}return 1/0}{let t=1/0;for(const r of e)t=Math.min(t,r.z);return t}}function Yl(t,e,r){let n=1/0;ds(r,e)&&(n=Wl(r,e[0]));for(let i=0;i<e.length;i++){const o=e[i],s=t[i];for(let t=0;t<o.length-1;t++){const e=o[t],i=[e,o[t+1],s[t+1],s[t],e];hs(r,i)&&(n=Math.min(n,Wl(r,i)))}}return n!==1/0&&n}function Jl(t,e,r,n,i,o,s,a,l,u,c){return"globe"===t.projection.name?function(t,e,r,n,i,o,s,a,l,u,c){const h=[],p=[],d=t.projection.upVectorScale(c,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],y=[0,0,0,1],m=(t,e,r,n)=>{t[0]=e,t[1]=r,t[2]=n,t[3]=1},g=function(){const t=Math.PI/32,e=Math.tan(t),r=Co;return r*Math.sqrt(1+2*e*e)-r}();r>0&&(r+=g),n+=g;for(const g of e){const e=[],x=[];for(const h of g){const p=h.x+i.x,g=h.y+i.y,v=t.projection.projectTilePoint(p,g,c),b=t.projection.upVector(c,h.x,h.y);let w=r,_=n;if(s){const t=Kl(p,g,r,n,s,a,l,u);w+=t.base,_+=t.top}0!==r?m(f,v.x+b[0]*d*w,v.y+b[1]*d*w,v.z+b[2]*d*w):m(f,v.x,v.y,v.z),m(y,v.x+b[0]*d*_,v.y+b[1]*d*_,v.z+b[2]*d*_),B(f,f,o),B(y,y,o),e.push(new Point3D(f[0],f[1],f[2])),x.push(new Point3D(y[0],y[1],y[2]))}h.push(e),p.push(x)}return[h,p]}(t,e,r,n,i,o,s,a,l,u,c):s?function(t,e,r,n,i,o,s,a,l){const u=[],c=[],h=[0,0,0,1];for(const p of t){const t=[],d=[];for(const u of p){const c=u.x+n.x,p=u.y+n.y,f=Kl(c,p,e,r,o,s,a,l);h[0]=c,h[1]=p,h[2]=f.base,h[3]=1,F(h,h,i),h[3]=Math.max(h[3],1e-5);const y=new Point3D(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=p,h[2]=f.top,h[3]=1,F(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new Point3D(h[0]/h[3],h[1]/h[3],h[2]/h[3]);t.push(y),d.push(m)}u.push(t),c.push(d)}return[u,c]}(e,r,n,i,o,s,a,l,u):function(t,e,r,n,i){const o=[],s=[],a=i[8]*e,l=i[9]*e,u=i[10]*e,c=i[11]*e,h=i[8]*r,p=i[9]*r,d=i[10]*r,f=i[11]*r;for(const e of t){const t=[],r=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,y=i[0]*e+i[4]*s+i[12],m=i[1]*e+i[5]*s+i[13],g=i[2]*e+i[6]*s+i[14],x=i[3]*e+i[7]*s+i[15],v=y+a,b=m+l,w=g+u,_=Math.max(x+c,1e-5),A=y+h,S=m+p,I=g+d,P=Math.max(x+f,1e-5);t.push(new Point3D(v/_,b/_,w/_)),r.push(new Point3D(A/P,S/P,I/P))}o.push(t),s.push(r)}return[o,s]}(e,r,n,i,o)}function Kl(t,e,r,n,i,o,s,a){const l=s*i.getElevationAt(t,e,!0,!0),u=0!==o[0],c=u?0===o[1]?s*(o[0]/Al-Sl):s*function(t,e,r){const n=Math.floor(e[0]/8),i=Math.floor(e[1]/8),o=10*(e[0]-8*n),s=10*(e[1]-8*i),a=t.getElevationAt(n,i,!0,!0),l=t.getMeterToDEM(r),u=Math.floor(.5*(o*l-1)),c=Math.floor(.5*(s*l-1)),h=t.tileCoordToPixel(n,i),p=2*u+1,d=2*c+1,f=function(t,e,r,n,i){return[t.getElevationAtPixel(e,r,!0),t.getElevationAtPixel(e+i,r,!0),t.getElevationAtPixel(e,r+i,!0),t.getElevationAtPixel(e+n,r+i,!0)]}(t,h.x-u,h.y-c,p,d),y=Math.abs(f[0]-f[1]),m=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),x=Math.min(.25,.5*l*(y+m)/p),v=Math.min(.25,.5*l*g/d);return a+Math.max(x*o,v*s)}(i,o,a):l;return{base:l+(0===r?-1:r),top:u?Math.max(c+n,l+r+2):l+n}}const Ql=4096;class BuildingGen{constructor(t){this.module=t,this.memoryStack=this.module.malloc(Ql),this.memoryStackNextFree=this.memoryStack}createIntArray(t){const e=this.memoryStackNextFree;return this.memoryStackNextFree+=t.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Ql?-1:(new Int32Array(this.module.heap32.buffer,e,t.length).set(t),e)}createFloatArray(t){const e=this.memoryStackNextFree;return this.memoryStackNextFree+=t.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Ql?-1:(new Float32Array(this.module.heapF32.buffer,e,t.length).set(t),e)}readStringBuffer(t){let e="";for(;0!==this.module.heapU8[t];)e+=String.fromCharCode(this.module.heapU8[t]),++t;return e}setStyle(t){const e=t.normalScale;this.module.setStyle(e[0],e[1],e[2],t.tileToMeters)}setAOOptions(t,e){this.module.setAOOptions(t?1:0,e)}setMetricOptions(t,e){this.module.setMetricOptions(t?1:0,e)}setStructuralOptions(t){this.module.setStructuralOptions(t?1:0)}setFacadeOptions(t,e){this.module.setFacadeOptions(t,e?1:0)}setFauxFacadeOptions(t,e,r){this.module.setFauxFacadeOptions(t?1:0,e?1:0,r)}setFacadeClassifierOptions(t){this.module.setFacadeClassifierOptions(t)}generateMesh(t,e){this.memoryStackNextFree=this.memoryStack;for(const e of t){const t=this.createIntArray(e.ringIndices),r=this.createFloatArray(e.coordinates);if(-1===t||-1===r)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(e.id,e.sourceId,e.minHeight,e.height,e.roofType,r,t,e.ringIndices.length-1)}for(const t of e){let e;e=t.entrances?JSON.parse(t.entrances):[];const r=this.createFloatArray(e),n=this.createFloatArray(t.coordinates);if(-1===r||-1===n)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(t.sourceId,t.crossPerc,t.distanceToRoad,r,e.length,n,t.coordinates.length)}if(!this.module.generateMesh()){const t=this.module.getLastError();return this.readStringBuffer(t)}const r=this.module.getMeshCount(),n=new Array(r);for(let t=0;t<r;t++){const e=this.module.getPositionsPtr(t),r=this.module.getPositionsLength(t),i=new Float32Array(this.module.heapF32.buffer,e,r),o=this.module.getNormalsPtr(t),s=this.module.getNormalsLength(t),a=new Float32Array(this.module.heapF32.buffer,o,s),l=this.module.getAOPtr(t),u=this.module.getAOLength(t),c=new Float32Array(this.module.heapF32.buffer,l,u),h=this.module.getUVPtr(t),p=this.module.getUVLength(t),d=new Float32Array(this.module.heapF32.buffer,h,p),f=this.module.getFauxFacadePtr(t),y=this.module.getFauxFacadeLength(t),m=new Uint8Array(this.module.heapU8.buffer,f,y),g=this.module.getIndicesPtr(t),x=this.module.getIndicesLength(t),v=new Int16Array(this.module.heap16.buffer,g,x),b=this.module.getBuildingPart(t);n[t]={positions:i,normals:a,ao:c,uv:d,isFauxFacade:m,indices:v,buildingPart:b}}const i=this.module.getRingCount(),o=[];for(let t=0;t<i;t++){const e=this.module.getRingPtr(t),r=this.module.getRingLength(t),n=new Float32Array(this.module.heapF32.buffer,e,r);o.push(n)}return{meshes:n,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:o}}}let tu,eu,ru,nu,iu=null,ou=null,su=null;function au(){return su}const lu={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},uu={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},cu={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function hu(t,e,r){const n=r.json.bufferViews.length,i=r.buffers.length;e.bufferView=n,r.json.bufferViews[n]={buffer:i,byteLength:t.byteLength},r.buffers[i]=t}const pu="KHR_draco_mesh_compression";function du(t,e){const r=t.extensions&&t.extensions[pu];if(!r)return;const n=new eu.Decoder,i=bu(e,r.bufferView),o=new eu.Mesh;if(!n.DecodeArrayToMesh(i,i.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],a=lu[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,u=eu._malloc(l);a===Uint16Array?n.GetTrianglesUInt16Array(o,l,u):n.GetTrianglesUInt32Array(o,l,u),hu(eu.memory.buffer.slice(u,u+l),s,e),eu._free(u);for(const i of Object.keys(r.attributes)){const s=n.GetAttributeByUniqueId(o,r.attributes[i]),a=e.json.accessors[t.attributes[i]],l=uu[a.componentType],u=a.count*cu[a.type]*lu[a.componentType].BYTES_PER_ELEMENT,c=eu._malloc(u);n.GetAttributeDataArrayForAllPoints(o,s,eu[l],u,c),hu(eu.memory.buffer.slice(c,c+u),a,e),eu._free(c)}n.destroy(),o.destroy(),delete t.extensions[pu]}const fu="EXT_meshopt_compression";function yu(t,e){if(!t.extensions||!t.extensions[fu])return;const r=t.extensions[fu],n=new Uint8Array(e.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),i=new Uint8Array(r.count*r.byteStride);nu.decodeGltfBuffer(i,r.count,r.byteStride,n,r.mode,r.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=i.buffer,delete t.extensions[fu]}const mu=1179937895,gu=new TextDecoder("utf8");function xu(t,e){return new URL(t,e).href}function vu(t,e,r,n){return fetch(xu(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[r]=t}))}function bu(t,e){const r=t.json.bufferViews[e];return new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength)}function wu(t,e,r,n){if(t.uri){const i=xu(t.uri,n);return fetch(i).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[r]=t}))}if(void 0!==t.bufferView){const n=bu(e,t.bufferView),i=new Blob([n],{type:t.mimeType});return createImageBitmap(i).then((t=>{e.images[r]=t}))}}function _u(t,e=0,r){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===mu){const r=new Uint32Array(t,e);let i=2;const o=(r[i++]>>2)-3,s=r[i++]>>2;if(i++,n.json=JSON.parse(gu.decode(r.subarray(i,i+s))),i+=s,i<o){const o=r[i++];i++;const s=e+(i<<2);n.buffers[0]=t.slice(s,s+o)}}else n.json=JSON.parse(gu.decode(new Uint8Array(t,e)));const{buffers:i,images:o,meshes:s,extensionsUsed:a,bufferViews:l}=n.json;let u=Promise.resolve();if(i){const t=[];for(let e=0;e<i.length;e++){const o=i[e];o.uri?t.push(vu(o,n,e,r)):n.buffers[e]||(n.buffers[e]=null)}u=Promise.all(t)}return u.then((()=>{const t=[],e=a&&a.includes(pu),i=a&&a.includes(fu);if(e&&t.push(function(){if(!eu)return null!=tu?tu:(tu=function(t){let e,r=null;function n(){e=new Uint8Array(r.buffer)}function i(){throw new Error("Unexpected Draco error.")}const o={a:{a:i,d:function(t,r,n){return e.copyWithin(t,r,r+n)},c:function(t){const i=e.length,o=Math.max(t>>>0,Math.ceil(1.2*i)),s=Math.ceil((o-i)/65536);try{return r.grow(s),n(),!0}catch(t){return!1}},b:i}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,o):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,o)))).then((t=>{const{Rb:i,Qb:o,P:s,T:a,X:l,Ja:u,La:c,Qa:h,Va:p,Wa:d,eb:f,jb:y,f:m,e:g,yb:x,zb:v,Ab:b,Bb:w,Db:_,Gb:A}=t.instance.exports;r=g;const S=(()=>{let t=0,r=0,n=0,s=0;return a=>{n&&(i(s),i(t),r+=n,n=t=0),t||(r+=128,t=o(r));const l=a.length+7&-8;let u=t;l>=r&&(n=l,u=s=o(l));for(let t=0;t<a.length;t++)e[u+t]=a[t];return u}})();return n(),m(),{memory:g,_free:i,_malloc:o,Mesh:class Mesh{constructor(){this.ptr=s()}destroy(){a(this.ptr)}},Decoder:class Decoder{constructor(){this.ptr=u()}destroy(){y(this.ptr)}DecodeArrayToMesh(t,e,r){const n=S(t),i=c(this.ptr,n,e,r.ptr);return!!l(i)}GetAttributeByUniqueId(t,e){return{ptr:h(this.ptr,t.ptr,e)}}GetTrianglesUInt16Array(t,e,r){p(this.ptr,t.ptr,e,r)}GetTrianglesUInt32Array(t,e,r){d(this.ptr,t.ptr,e,r)}GetAttributeDataArrayForAllPoints(t,e,r,n,i){f(this.ptr,t.ptr,e.ptr,r,n,i)}},DT_INT8:x(),DT_UINT8:v(),DT_INT16:b(),DT_UINT16:w(),DT_UINT32:_(),DT_FLOAT32:A()}}))}(fetch(_t(self)&&self.worker.dracoUrl?self.worker.dracoUrl:Sn.DRACO_URL)),tu.then((t=>{eu=t,tu=void 0})))}()),i&&t.push(function(){if(nu)return;const t=function(t){let e;const r=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors()})),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},i={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:r,supported:!0,decodeGltfBuffer(t,r,o,s,a,l){!function(t,e,r,n,i,o,s){const a=t.exports.sbrk,l=n+3&-4,u=a(l*i),c=a(o.length),h=new Uint8Array(t.exports.memory.buffer);h.set(o,c);const p=e(u,n,i,c,o.length);if(0===p&&s&&s(u,l,i),r.set(h.subarray(u,u+n*i)),a(u-a(0)),0!==p)throw new Error(`Malformed buffer data: ${p}`)}(e,e.exports[i[a]],t,r,o,s,e.exports[n[l]])}}}(fetch(function(){if(_t(self)&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(ru)return ru;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return ru=WebAssembly.validate(t)?Sn.MESHOPT_SIMD_URL:Sn.MESHOPT_URL,ru}()));return t.ready.then((()=>{nu=t}))}()),o)for(let e=0;e<o.length;e++)t.push(wu(o[e],n,e,r));return(t.length?Promise.all(t):Promise.resolve()).then((()=>{if(e&&s)for(const{primitives:t}of s)for(const e of t)du(e,n);if(i&&s&&l)for(const t of l)yu(t,n);return n}))}))}function Au(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>_u(e,0,t)))}function Su(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Iu(t){switch(t){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Texture{constructor(t,e,r,n){this.context=t,this.format=r,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply})}update(t,e){const r=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:i}=this,{gl:o}=i,{x:s,y:a}=e&&e.position?e.position:{x:0,y:0},l=s+r,u=a+n;!this.size||this.size[0]===l&&this.size[1]===u||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),i.pixelStoreUnpackFlipY.set(!1),i.pixelStoreUnpack.set(1),i.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!e||!1!==e.premultiply));const c=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&u>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,u)))+1:1;o.texStorage2D(o.TEXTURE_2D,t,this.format,l,u),this.size=[l,u]}this.size&&(c?o.texSubImage2D(o.TEXTURE_2D,0,s,a,Su(this.format),Iu(this.format),t):"data"in t&&t.data&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,r,n,Su(this.format),Iu(this.format),t.data)),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(t,e,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),t!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?t===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrapS=e)}bindExtraParam(t,e,r,n,i){const{context:o}=this,{gl:s}=o;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?t===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),r!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,n),this.wrapT=n),i!==this.compareMode&&(i?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,i)):s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.NONE),this.compareMode=i)}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class UserManagedTexture{constructor(t,e){this.context=t,this.texture=e}bind(t,e){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e)}}const Pu=Zi([{name:"a_pos_3f",components:3,type:"Float32"}]),Mu=Zi([{name:"a_color_3f",components:3,type:"Float32"}]),Du=Zi([{name:"a_color_4f",components:4,type:"Float32"}]),Eu=Zi([{name:"a_uv_2f",components:2,type:"Float32"}]),Cu=Zi([{name:"a_normal_3f",components:3,type:"Float32"}]),Bu=Zi([{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"}]),Tu=Zi([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function ku(t,e,r){o(t),p(t,t,ut(e[2])),c(t,t,ut(e[0])),h(t,t,ut(e[1])),u(t,t,r),a(t,t,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function zu(t,e,r,n,i,o,s,a){const l=[r[0]-e[0],r[1]-e[1],0],u=[n[0]-e[0],n[1]-e[1],0];if(y(l)<1e-12||y(u)<1e-12)return O(t);const c=E([],l,u);M(c,c),v(u,n,e),l[2]=(o-i)*a,u[2]=(s-i)*a;const h=l;return E(h,l,u),M(h,h),H(t,c,h)}function Lu(t,e,r=!1){const n=Gs(e.zoom),i=function(t,e,r){const n=e.worldSize,i=[t[12],t[13],t[14]],s=Oo(i[1]/n),c=Ro(i[0]/n),h=o([]),p=Fo(1,s)*n,d=Fo(1,0)*n*jo(s,e.zoom),f=1/js(n);let y=d*f;if(r){const t=function(t,e,r,n,i=1/0){const o=t.range;if(!o)return 0;const s=Math.min(i,Math.max(r,n)),a=Math.log2(s/1024);return pt(o[0]+a,o[1]+a,e)}(e.projection,e.zoom,e.width,e.height,1024);y=f*e.projection.pixelSpaceConversion(e.center.lat,n,t)}const m=Eo(s,c);x(m,m,_([],M([],m),p*y*i[2]));const g=function(t){const e=[t[0],t[1],t[2]];let r=[0,1,0];const n=E([],r,e);return E(r,e,n),0===function(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}(r)&&(r=[0,1,0],E(n,e,r)),M(n,n),M(r,r),M(e,e),[n[0],n[1],n[2],0,r[0],r[1],r[2],0,e[0],e[1],e[2],0,t[0],t[1],t[2],1]}(m);u(h,h,[y,y,y*p]),l(h,h,[-i[0],-i[1],-i[2]]);const v=a([],e.globeMatrix,g);return a(v,v,h),a(v,v,t),v}(t,e,r);if(n>0){const r=function(t,e){const r=e.worldSize,n=Fo(1,0)*r*jo(e.center.lat,e.zoom)/js(r),i=Fo(1,e.center.lat)*r,s=o([]);h(s,s,ut(e.center.lng)),c(s,s,ut(e.center.lat)),l(s,s,[0,0,_o]),u(s,s,[n,n,n*i]);const p=e.point;return l(s,s,[-p.x,-p.y,0]),a(s,s,t),a(s,e.globeMatrix,s)}(t,e);return function(t,e,r){const n=(t,e,r)=>{const n=y(t),i=y(e),o=Fs(t,e,r);return _(o,o,1/y(o)*Vt(n,i,r))},i=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],r),o=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],r),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],r),a=Fs([t[12],t[13],t[14]],[e[12],e[13],e[14]],r);return[i[0],i[1],i[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(i,r,n)}return i}function Vu(t,e,r,n){const i=Aabb.projectAabbCorners(n,r);let o=Number.MAX_VALUE;for(let t=0;t<i.length;++t){const r=i[t];r[0]=(.5*r[0]+.5)*e.width,r[1]=(.5-.5*r[1])*e.height,r[2]<o&&(o=r[2])}const s=function(t){const e=[];let r=0;for(let e=1;e<t.length;e++)(t[e][0]<t[r][0]||t[e][0]===t[r][0]&&t[e][1]<t[r][1])&&(r=e);let n,i=r;const o=new Uint8Array(t.length);do{if(o[i])break;e.push(new ot(t[i][0],t[i][1])),o[i]=1,n=(i+1)%t.length;for(let e=0;e<t.length;e++){if(t[e][0]===t[n][0]&&t[e][1]===t[n][1]||t[e][0]===t[i][0]&&t[e][1]===t[i][1])continue;const r=[t[e][0]-t[i][0],t[e][1]-t[i][1]],o=[t[n][0]-t[i][0],t[n][1]-t[i][1]],s=r[0]*o[1]-r[1]*o[0];(s>0||0===s&&r[0]*o[0]+r[1]*o[1]>=0&&r[0]*r[0]+r[1]*r[1]>o[0]*o[0]+o[1]*o[1])&&(n=e)}i=n}while(i!==r);return e.length>0&&e.push(e[0]),e}(i);if(hs(t,s))return o}const Fu=64;function Ru(t,e,r,n,i,s,c,h,p,d=!1){const f=r.zoom,y=r.project(n),m=jo(n.lat,f),g=1/m;o(t),l(t,t,[y.x+c[0]*g,y.y+c[1]*g,c[2]]);let x=1,v=1;const b=r.worldSize;if(d){if("mercator"===r.projection.name){let t=0;r.elevation&&(t=r.elevation.getAtPointOrZero(new MercatorCoordinate(y.x/b,y.y/b),0));const e=F([],[y.x,y.y,t,1],r.projMatrix)[3]/r.cameraToCenterDistance;x=e,v=e*jo(r.center.lat,f)}else if("globe"===r.projection.name){const e=Lu(t,r),i=[0,0,0,1];F(i,i,a([],r.projMatrix,e));const o=i[3]/r.cameraToCenterDistance,s=Gs(f),l=r.projection.pixelsPerMeter(n.lat,b)*jo(n.lat,f),u=r.projection.pixelsPerMeter(r.center.lat,b)*jo(r.center.lat,f);x=o/Vt(l,No(r.center.lat),s),v=o*m/l,x*=u,v*=u}}else x=g;u(t,t,[x,x,v]);const w=[...t],_=e.orientation,A=[];if(ku(A,[_[0]+(i?i[0]:0),_[1]+(i?i[1]:0),_[2]+(i?i[2]:0)],s),a(t,w,A),h&&r.elevation){let i=0;const o=[];if(p&&r.elevation){i=function(t,e,r,n,i){const o=e.elevation;if(!o)return 0;const s=Aabb.projectAabbCorners(r,n),a=Fo(1,i.lat)*e.worldSize,l=function(t,e){const r=[0,0,1],n=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const i of n){const n=t[i.corners[0]],o=t[i.corners[1]],s=t[i.corners[2]],a=[o[0]-n[0],o[1]-n[1],e*(o[2]-n[2])],l=E(a,a,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);M(l,l),i.dotProductWithUp=D(l,r)}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,a),u=s[l[0]],c=s[l[1]],h=s[l[2]],p=s[l[3]],d=o.getAtPointOrZero(new MercatorCoordinate(u[0]/e.worldSize,u[1]/e.worldSize),0),f=o.getAtPointOrZero(new MercatorCoordinate(c[0]/e.worldSize,c[1]/e.worldSize),0),y=o.getAtPointOrZero(new MercatorCoordinate(h[0]/e.worldSize,h[1]/e.worldSize),0),m=o.getAtPointOrZero(new MercatorCoordinate(p[0]/e.worldSize,p[1]/e.worldSize),0),g=(d+m)/2,x=(f+y)/2;return g>x?f<y?zu(t,c,p,u,f,m,d,a):zu(t,h,u,p,y,d,m,a):d<m?zu(t,u,c,h,d,f,y,a):zu(t,p,h,c,m,y,f,a),Math.max(g,x)}(o,r,e.aabb,t,n);const s=function(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],s=r+r,a=n+n,l=i+i,u=r*s,c=n*s,h=n*a,p=i*s,d=i*a,f=i*l,y=o*s,m=o*a,g=o*l;return t[0]=1-h-f,t[1]=c+g,t[2]=p-m,t[3]=0,t[4]=c-g,t[5]=1-u-f,t[6]=d+y,t[7]=0,t[8]=p+m,t[9]=d-y,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}([],o),l=a([],s,A);a(t,w,l)}else i=r.elevation.getAtPointOrZero(new MercatorCoordinate(y.x/b,y.y/b),0);0!==i&&(t[14]+=i)}}class Model{constructor(t,e,r,n,i){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=t,this.uri=e,this.position=null!=r?new LngLat(r[0],r[1]):new LngLat(0,0),this.orientation=null!=n?n:[0,0,0],this.nodes=i,this.uploaded=!1,this.aabb=new Aabb([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,e){a(t.globalMatrix,e,t.localMatrix);const r=this.nodeOverrides.get(t.name);if(void 0!==r){const e=[];!function(t,e){o(t),h(t,t,ut(e[1])),p(t,t,ut(e[2])),c(t,t,ut(e[0]))}(e,r.orientation),a(t.globalMatrix,t.globalMatrix,e)}if(t.meshes)for(const e of t.meshes){const r=Aabb.applyTransformFast(e.aabb,t.globalMatrix);this.aabb.encapsulate(r)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.globalMatrix)}computeBoundsAndApplyParent(){const t=o([]);this.aabb=new Aabb([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(t,e,r,n,i,o,s=!1){Ru(this.matrix,this,t.transform,this.position,e,r,n,i,o,s)}upload(t){if(!this.uploaded){for(const e of this.nodes)Nu(e,t);for(const t of this.nodes)ju(t);this.uploaded=!0}}destroy(){for(const t of this.nodes)Gu(t)}}function Ou(t,e,r=!1){t.uploaded||(t.gfxTexture=new Texture(e,t.image,r?e.gl.R8:e.gl.RGBA8,{useMipmap:t.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null)}function Uu(t,e,r){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Pu.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Cu.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Eu.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?Mu:Du).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Tu.members,!0)),t.segments=SegmentVector.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Ou(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Ou(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Ou(n.normalTexture,e),n.occlusionTexture&&Ou(n.occlusionTexture,e,r),n.emissionTexture&&Ou(n.emissionTexture,e)}function Nu(t,e,r){if(t.meshes)for(const n of t.meshes)Uu(n,e,r);if(t.children)for(const n of t.children)Nu(n,e,r)}function ju(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)ju(e)}function Gu(t){if(t.meshes)for(const r of t.meshes)r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.normalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((e=r.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)Gu(e)}function $u(t,e){const r=t.json.bufferViews[e.bufferView],n=lu[e.componentType];return new n(t.buffers[r.buffer],(e.byteOffset||0)+(r.byteOffset||0),e.count*(r.byteStride&&r.byteStride!==cu[e.type]*n.BYTES_PER_ELEMENT?r.byteStride/n.BYTES_PER_ELEMENT:cu[e.type]))}function qu(t,e,r,n){const i=lu[e.componentType],o=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(i),s=t.json.bufferViews[e.bufferView],a=s.byteStride?s.byteStride/i.BYTES_PER_ELEMENT:cu[e.type],l=r.float32,u=l.length/r.capacity;for(let t=0,r=0;t<e.count*a;t+=a,r+=u)for(let e=0;e<u;e++)l[r+e]=n[t+e]*o;r._trim()}function Hu(t,e,r){const n=t.indices,i=t.attributes,o={};o.indexArray=new StructArrayLayout3ui6;const s=e.json.accessors[n],a=s.count/3;o.indexArray.reserve(a);const l=$u(e,s);for(let t=0;t<a;t++)o.indexArray.emplaceBack(l[3*t],l[3*t+1],l[3*t+2]);o.indexArray._trim(),o.vertexArray=new StructArrayLayout3f12;const u=e.json.accessors[i.POSITION];o.vertexArray.reserve(u.count);const c=$u(e,u);for(let t=0;t<u.count;t++)o.vertexArray.emplaceBack(c[3*t],c[3*t+1],c[3*t+2]);if(o.vertexArray._trim(),o.aabb=new Aabb(u.min,u.max),o.centroid=function(t,e){const r=[0,0,0],n=t.length;if(n>0){for(let i=0;i<n;i++){const n=3*t[i];r[0]+=e[n],r[1]+=e[n+1],r[2]+=e[n+2]}r[0]/=n,r[1]/=n,r[2]/=n}return r}(l,c),void 0!==i.COLOR_0){const t=e.json.accessors[i.COLOR_0],r=cu[t.type],n=$u(e,t);o.colorArray=3===r?new StructArrayLayout3f12:new StructArrayLayout4f16,o.colorArray.resize(t.count),qu(e,t,o.colorArray,n)}if(void 0!==i.NORMAL){o.normalArray=new StructArrayLayout3f12;const t=e.json.accessors[i.NORMAL];o.normalArray.resize(t.count);const r=$u(e,t);qu(e,t,o.normalArray,r)}if(void 0!==i.TEXCOORD_0&&r.length>0){o.texcoordArray=new StructArrayLayout2f8;const t=e.json.accessors[i.TEXCOORD_0];o.texcoordArray.resize(t.count);const r=$u(e,t);qu(e,t,o.texcoordArray,r)}if(void 0!==i._FEATURE_ID_RGBA4444){const t=e.json.accessors[i._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=$u(e,t))}void 0!==i._FEATURE_RGBA4444&&(o.featureData=new Uint32Array($u(e,e.json.accessors[i._FEATURE_RGBA4444]).buffer));const h=t.material;return o.material=function(t,e){const{emissiveFactor:r=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:i=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l,name:u}=t,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:p=1,baseColorTexture:d,metallicRoughnessTexture:f}=t.pbrMetallicRoughness||{},y=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&y){const t=s.extensions.KHR_texture_transform;y.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]]}return{name:u,pbrMetallicRoughness:{baseColorFactor:new Color(...c),metallicFactor:h,roughnessFactor:p,baseColorTexture:d?e[d.index]:void 0,metallicRoughnessTexture:f?e[f.index]:void 0},doubleSided:l,emissiveFactor:new Color(...r),alphaMode:n,alphaCutoff:i,normalTexture:o?e[o.index]:void 0,occlusionTexture:y,emissionTexture:a?e[a.index]:void 0,defined:void 0===t.defined}}(void 0!==h?e.json.materials[h]:{defined:!1},r),o}function Xu(t,r,n){const{matrix:i,rotation:o,translation:s,scale:a,mesh:l,extras:u,children:c,name:h}=t,p={};if(p.name=h,p.localMatrix=i||function(t,e,r,n){var i=e[0],o=e[1],s=e[2],a=e[3],l=i+i,u=o+o,c=s+s,h=i*l,p=i*u,d=i*c,f=o*u,y=o*c,m=s*c,g=a*l,x=a*u,v=a*c,b=n[0],w=n[1],_=n[2];return t[0]=(1-(f+m))*b,t[1]=(p+v)*b,t[2]=(d-x)*b,t[3]=0,t[4]=(p-v)*w,t[5]=(1-(h+m))*w,t[6]=(y+g)*w,t[7]=0,t[8]=(d+x)*_,t[9]=(y-g)*_,t[10]=(1-(h+f))*_,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}([],o||[0,0,0,1],s||[0,0,0],a||[1,1,1]),p.globalMatrix=function(t){var r=new e(16);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r}(p.localMatrix),void 0!==l){p.meshes=n[l];const t=p.anchor=[0,0];for(const e of p.meshes){const{min:r,max:n}=e.aabb;t[0]+=r[0]+n[0],t[1]+=r[1]+n[1]}t[0]=Math.floor(t[0]/p.meshes.length/2),t[1]=Math.floor(t[1]/p.meshes.length/2)}if(u&&(u.id&&(p.id=u.id),u.lights&&(p.lights=function(t){if(!t.length)return[];const e=function(t){const e=atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.codePointAt(t);return r}(t),r=[],n=e.length/24,i=new Uint16Array(e.buffer),o=new Float32Array(e.buffer);for(let t=0;t<n;t++){const e=i[2*t*6]/30,n=i[2*t*6+1]/30,s=i[2*t*6+10]/100,a=o[6*t+1],l=o[6*t+2],u=o[6*t+3],c=o[6*t+4],h=u-a,p=c-l,d=Math.hypot(h,p);r.push({pos:[a+.5*h,l+.5*p,n],normal:[p/d,-h/d,0],width:d,height:e,depth:s,points:[a,l,u,c]})}return r}(u.lights)),u.MAPBOX_geometry_bloom&&(p.isGeometryBloom=u.MAPBOX_geometry_bloom)),c){const t=[];for(const e of c)t.push(Xu(r.json.nodes[e],r,n));p.children=t}return p}function Zu(t){if(0===t.vertices.length||0===t.indices.length)return null;const e=new TriangleGridIndex(t.vertices,t.indices,8,256),[r,n]=[e.min.clone(),e.max.clone()];return{vertices:t.vertices,indices:t.indices,grid:e,min:r,max:n}}function Wu(t){if(!t.extras||!t.extras.ground)return null;const e=t.extras.ground;if(!e||!Array.isArray(e)||0===e.length)return null;const r=e[0];if(!r||!Array.isArray(r)||0===r.length)return null;const n=[];for(const t of r){if(!Array.isArray(t)||2!==t.length)continue;const e=t[0],r=t[1];"number"==typeof e&&"number"==typeof r&&n.push(new ot(e,r))}if(n.length<3)return null;n.length>1&&n[n.length-1].equals(n[0])&&n.pop();let i=0;for(let t=0;t<n.length;t++){const e=n[t],r=n[(t+1)%n.length],o=n[(t+2)%n.length];i+=(e.x-r.x)*(o.y-r.y)-(o.x-r.x)*(e.y-r.y)}i>0&&n.reverse();const o=aa(n.flatMap((t=>[t.x,t.y])),[]);return 0===o.length?null:{vertices:n,indices:o}}function Yu(t,e){const r=[],n=[];let i=0;const o=[];for(const s of t){i=r.length;const t=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n<s.vertexArray.length;n++)o[0]=t[3*n+0],o[1]=t[3*n+1],o[2]=t[3*n+2],B(o,o,e),r.push(new ot(o[0],o[1]));for(let t=0;t<3*s.indexArray.length;t++)n.push(a[t]+i)}if(n.length%3!=0)return null;for(let t=0;t<n.length;t+=3){const e=r[n[t+0]],i=r[n[t+1]],o=r[n[t+2]];(e.x-i.x)*(o.y-i.y)-(o.x-i.x)*(e.y-i.y)>0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]])}return{vertices:r,indices:n}}function Ju(t){const e=function(t,e){const r=[],n=WebGL2RenderingContext;if(t.json.textures)for(const i of t.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==i.sampler&&Object.assign(o,t.json.samplers[i.sampler]),r.push({image:e[i.source],sampler:o,uploaded:!1})}return r}(t,t.images),r=function(t,e){const r=[];for(const n of t.json.meshes){const i=[];for(const r of n.primitives)i.push(Hu(r,t,e));r.push(i)}return r}(t,e),{scenes:n,scene:i,nodes:o}=t.json,s=n?n[i||0].nodes:[...o.keys()],a=[];for(const e of s)a.push(Xu(o[e],t,r));return function(t,e,r){const n={},i=new Set;for(let o=0;o<t.length;o++){const t=r[e[o]];if(!t.extras)continue;const s=t.extras["mapbox:footprint:version"],a=t.extras["mapbox:footprint:id"];(s||a)&&i.add(o),"1.0.0"===s&&a&&(n[a]=o)}for(let o=0;o<t.length;o++){if(i.has(o))continue;const s=t[o],a=r[e[o]];if(!a.extras)continue;let l=null;s.id in n&&(l=Yu(t[n[s.id]].meshes,s.localMatrix)),l||(l=Wu(a)),l&&(s.footprint=Zu(l))}if(i.size>0){const e=Array.from(i.values()).sort(((t,e)=>t-e));for(let r=e.length-1;r>=0;r--)t.splice(e[r],1)}}(a,s,t.json.nodes),a}function Ku(t,e){const r=Ju(t);for(const t of r){for(const e of t.meshes)Qu(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(ec(t.lights,e)))}return r}function Qu(t){t.heightmap=new Float32Array(Fu*Fu),t.heightmap.fill(-1);const e=t.vertexArray.float32,r=t.aabb.min[0]-1,n=t.aabb.min[1]-1,i=Fu/(t.aabb.max[0]-r+2),o=Fu/(t.aabb.max[1]-n+2);for(let s=0;s<e.length;s+=3){const a=e[s+2],l=(e[s+0]-r)*i|0,u=(e[s+1]-n)*o|0;a>t.heightmap[u*Fu+l]&&(t.heightmap[u*Fu+l]=a)}}function tc(t,e,r,n,i){r.reserve(r.length+4*t.length),n.reserve(n.length+10*t.length),i.reserve(i.length+10*t.length);let o=n.length;for(const s of t){const t=Math.min(10,Math.max(4,1.3*s.height))*e,a=[-s.normal[1],s.normal[0],0],l=Math.min(.29,.1*s.width/s.depth),u=s.width-2*s.depth*e*(l+.01),c=A([],s.pos,a,u/2),h=A([],s.pos,a,-u/2),p=[c[0],c[1],c[2]+s.height],d=[h[0],h[1],h[2]+s.height],f=A([],s.normal,a,l);_(f,f,t);const y=A([],s.normal,a,-l);_(y,y,t),x(f,c,f),x(y,h,y),c[2]+=.1,h[2]+=.1,n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(y[0],y[1],y[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(y[0],y[1],y[2]);const m=u/t/2;i.emplaceBack(-m-l,-1,m,.8),i.emplaceBack(m+l,-1,m,.8),i.emplaceBack(-m,0,m,1.3),i.emplaceBack(m,0,m,1.3),i.emplaceBack(m+l,-.8,m,.7),i.emplaceBack(m+l,-.8,m,.7),i.emplaceBack(0,0,m,1.3),i.emplaceBack(0,0,m,1.3),i.emplaceBack(m+l,-1.2,m,.8),i.emplaceBack(m+l,-1.2,m,.8),r.emplaceBack(6+o,4+o,8+o),r.emplaceBack(7+o,9+o,5+o),r.emplaceBack(0+o,1+o,2+o),r.emplaceBack(1+o,3+o,2+o),o+=10}}function ec(t,e){const r={};r.indexArray=new StructArrayLayout3ui6,r.vertexArray=new StructArrayLayout3f12,r.colorArray=new StructArrayLayout4f16,tc(t,e,r.indexArray,r.vertexArray,r.colorArray);const n={defined:!0};n.emissiveFactor=Color.black;const i={};return i.baseColorFactor=Color.white,n.pbrMetallicRoughness=i,r.material=n,r.aabb=new Aabb([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}const rc=Zi([{name:"a_pos_3f",components:3,type:"Float32"}]),nc=Zi([{name:"a_normal_3",components:3,type:"Int16"}]),ic=Zi([{name:"a_centroid_3",components:3,type:"Int16"}]),oc=Zi([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),sc=Zi([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),ac=Zi([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),lc=Zi([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),uc=Zi([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),cc=Zi([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),hc=VectorTileFeature.types,pc=32767;function dc(t,e){const r=Ue+e;for(const n of t)for(const t of n)if(t.x<-e||t.x>r||t.y<-e||t.y>r)return!1;return!0}function fc(t){switch(t){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${t}`)}}class BuildingBloomGeometry{constructor(){this.layoutVertexArray=new StructArrayLayout3f12,this.layoutAttenuationArray=new StructArrayLayout4f16,this.layoutColorArray=new StructArrayLayout2ui4,this.indexArray=new StructArrayLayout3ui6,this.indexArrayForConflation=new StructArrayLayout3ui6,this.segmentsBucket=new SegmentVector}}class BuildingGeometry{constructor(t){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new SegmentVector,this.entranceBloom=new BuildingBloomGeometry;const e=66560;this.layoutVertexArray=new StructArrayLayout3f12,this.layoutVertexArray.reserve(e),this.layoutNormalArray=new StructArrayLayout3i6,this.layoutNormalArray.reserve(e),this.layoutCentroidArray=new StructArrayLayout3i6,this.layoutCentroidArray.reserve(e),this.layoutColorArray=new StructArrayLayout2ui4,this.layoutColorArray.reserve(e),this.layoutFloodLightDataArray=new StructArrayLayout1ui2,this.layoutFloodLightDataArray.reserve(e),this.layoutAOArray=new StructArrayLayout1ub1,this.layoutAOArray.reserve(e),this.indexArray=new StructArrayLayout3ui6,this.indexArray.reserve(66560),this.indexArrayForConflation=new StructArrayLayout3ui6,this.segmentsBucket=new SegmentVector,this.entranceBloom=new BuildingBloomGeometry,t&&(this.layoutFacadePaintArray=new StructArrayLayout2ui4,this.layoutFacadeDataArray=new StructArrayLayout4ui8,this.layoutFacadeVerticalRangeArray=new StructArrayLayout2ui4)}reserve(t,e,r){this.layoutVertexArray.reserveForAdditional(t),this.layoutCentroidArray.reserveForAdditional(t),this.layoutFloodLightDataArray.reserveForAdditional(t),this.layoutNormalArray.reserveForAdditional(t),this.layoutAOArray.reserveForAdditional(t),this.layoutColorArray.reserveForAdditional(t),this.indexArray.reserveForAdditional(e),r&&(this.layoutFacadePaintArray.reserveForAdditional(t),this.layoutFacadeDataArray.reserveForAdditional(t),this.layoutFacadeVerticalRangeArray.reserveForAdditional(t))}}class BuildingBucket{constructor(t){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new StructArrayLayout2f8,this.footprintsIndices=new StructArrayLayout1ui2,this.footprintsMin=new ot(1/0,1/0),this.footprintsMax=new ot(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new BuildingGeometry(!1),this.buildingWithFacade=new BuildingGeometry(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.worldview=t.worldview,this.lut=t.lut,this.programConfigurations=new ProgramConfigurationSet(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection,this.groundEffect=new GroundEffect(t),this.groundEffect.groundRadiusArray=new StructArrayLayout1f4,this.hasAppearances=null}updateFootprints(t,e){const r=new TriangleGridIndex([],[],1),n={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};e.push({footprint:n,id:t})}updateAppearances(t,e,r,n){}prepare(){return function(){if(null!=su||null!=ou)return null;if(null!=iu)return iu;const t=fetch(Sn.BUILDING_GEN_URL);return iu=function(t){let e,r,n,i,o;function s(){e=new Uint8Array(o.buffer),r=new Int16Array(o.buffer),n=new Int32Array(o.buffer),i=new Float32Array(o.buffer)}function a(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},u={a:{a,f:function(t){const r=e.length,n=Math.max(t>>>0,Math.ceil(1.2*r)),i=Math.ceil((n-r)/65536);try{return o.grow(i),s(),!0}catch(t){return!1}},g:a,b:l,c:l,d:l,e:l}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,u):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,u)))).then((t=>{const a=t.instance.exports;return(0,a.g)(),o=a.f,s(),new BuildingGen({setStyle:a.h,setAOOptions:a.i,setMetricOptions:a.j,setStructuralOptions:a.k,setFacadeOptions:a.l,setFauxFacadeOptions:a.m,setFacadeClassifierOptions:a.n,addFeature:a.o,addFacade:a.p,generateMesh:a.q,getLastError:a.r,getOuterRingLength:a.s,getMeshCount:a.t,getPositionsPtr:a.u,getPositionsLength:a.v,getNormalsPtr:a.w,getNormalsLength:a.x,getAOPtr:a.y,getAOLength:a.z,getUVPtr:a.A,getUVLength:a.B,getFauxFacadePtr:a.C,getFauxFacadeLength:a.D,getIndicesPtr:a.E,getIndicesLength:a.F,getBuildingPart:a.G,getRingCount:a.H,getRingPtr:a.I,getRingLength:a.J,malloc:a.K,free:a.L,heapU8:e,heap16:r,heap32:n,heapF32:i})}))}(t).then((t=>(iu=null,su=t,su))).catch((t=>{vt("Could not load building-gen"),iu=null,ou=t})),iu}()}populate(t,e,r,n){const i=au();if(!i)return;const o=Go(r);this.tileToMeter=o,this.brightness=e.brightness,i.setStyle({normalScale:[1,-1,o],tileToMeters:o}),i.setAOOptions(!1,.3),i.setMetricOptions(!1,16),i.setStructuralOptions(!0),i.setFacadeClassifierOptions(3);const s=new Map,a=new Map;let l=0;for(const{feature:e}of t){if("LineString"!==hc[e.type]){s.set(e.id,e.properties.source_id);continue}const t=this.layers[0]._featureFilter.needGeometry;if(t&&!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),e,r))continue;const i=Ko(e,t);if(!t&&!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),i,r))continue;const o=t?i.geometry:Jo(e,r,n),u=[];for(const t of o)for(const e of t)u.push(e.x),u.push(e.y);const c={coordinates:u,crossPerc:e.properties.cross_perc,distanceToRoad:e.properties.distance_to_road,entrances:e.properties.entrances,sourceId:0},h=e.properties.source_id;let p=a.get(h);p||(p=[],a.set(h,p)),p.push(c),++l}this.maxHeight=0;const u=new Array,c=new Set,h=t=>{null!=t&&c.add(t)},p=(t,e)=>{null!=t&&u.push({buildingId:t,footprintIndex:e})},d=64*(t.length-l),f=d/2;this.buildingWithFacade.reserve(d,f,!0),this.buildingWithoutFacade.reserve(2*d,2*f,!1),this.footprintsIndices.reserve(16*(t.length-l)),this.footprintsVertices.reserve(8*(t.length-l));for(const{feature:l,id:u,index:d,sourceLayerIndex:f}of t){if("LineString"===hc[l.type])continue;const t=this.layers[0]._featureFilter.needGeometry;if(t&&!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),l,r))continue;let y=null;if(l.properties&&l.properties.hasOwnProperty("building_id")&&(y=l.properties.building_id,c.has(y)))continue;const m=Ko(l,t);if(!t&&!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom),m,r))continue;const g=t?m.geometry:Jo(l,r,n),x=ka(g,500);let v=!1;for(const t of x)if(1!==t.length){v=!0;break}if(v){h(y);continue}if(!dc(g,163)){h(y);continue}const b=this.layers[0],w=fc(b.layout.get("building-roof-shape").evaluate(l,{},r)),_=b.layout.get("building-base").evaluate(l,{},r),A=b.layout.get("building-height").evaluate(l,{},r),S=b.layout.get("building-flood-light-ground-radius").evaluate(l,{},r),I=b.paint.get("building-ambient-occlusion-intensity"),P=S/this.tileToMeter;l.properties["building-part"]="roof";const M=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),D=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="wall";const E=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),C=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="window";const B=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),T=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="door";const k=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),z=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);let L=b.layout.get("building-flood-light-wall-radius").evaluate(l,{},r);L=ht(L,0,2048);const V=L/2048*pc,F=s.get(u),R=a.get(F)||[],O=0!==R.length&&b.layout.get("building-facade").evaluate(l,{},r);i.setFacadeOptions(4,!0),i.setFauxFacadeOptions(O,!1,1);let U=0,N=0,j=0,G=0,$=0,q=0,H=0,X=0,Z=0,W=0,Y=0;if(O){let t=Math.round(b.layout.get("building-facade-floors").evaluate(l,{},r));if(0===_){t=Math.max(1,t-(R.length>0?1:0));let e=4;if(A>100){const t=[10,13,15];e=t[l.id?l.id%t.length:0]}else A<=10&&(e=3);i.setFacadeOptions(e,!0),$=(A<15?1.3:1.61803)*e/o}else $=_/o;q=A/o,$=Math.min($,q),j=b.layout.get("building-facade-unit-width").evaluate(l,{},r)/o,G=(q-$)/t,i.setFauxFacadeOptions(!0,!0,j);const e=b.layout.get("building-facade-window").evaluate(l,{},r);U=e[0],N=e[1],H=Math.floor(65535*Math.min(1,$/Ue)),X=Math.floor(65535*Math.min(1,q/Ue)),Z=Math.floor(255*U)<<8|Math.floor(255*N),W=Math.floor(65535*Math.min(1,j/Ue)),Y=Math.floor(65535*Math.min(1,G/Ue))}const J=Array(x.length),K={x:1/0,y:1/0},Q={x:-1/0,y:-1/0},tt={x:0,y:0};let et=0;for(let t=0;t<x.length;t++){const e=x[t];if(e.length>0){const r=[],n=Array(e.length+1);n[0]=0;for(let t=0;t<e.length;t++){const i=e[t];for(let t=0;t<i.length;t++){const e=i[i.length-t-1];K.x=Math.min(K.x,e.x),K.y=Math.min(K.y,e.y),Q.x=Math.max(Q.x,e.x),Q.y=Math.max(Q.y,e.y),tt.x+=e.x,tt.y+=e.y,et++,r.push(e.x),r.push(e.y)}n[t+1]=r.length}J[t]={id:l.id?l.id:0,height:A,minHeight:_,sourceId:0,roofType:w,coordinates:r,ringIndices:n}}}tt.x/=et||1,tt.y/=et||1;const rt=i.generateMesh(J,R);if("string"==typeof rt){vt(`Unable to generate building ${l.id}: ${rt}`),h(y);continue}if(0===rt.meshes.length||0===rt.modifiedPolygonRings.length){h(y);continue}const nt=O?this.buildingWithFacade:this.buildingWithoutFacade;let it=0;for(const t of rt.meshes)it+=t.positions.length/3;const st=nt.segmentsBucket.prepareSegment(it,nt.layoutVertexArray,nt.indexArray),at=[];let lt=null,ut=0,ct=-1;const pt=nt.layoutVertexArray.length,dt=pt+it;nt.layoutVertexArray.resize(dt),nt.layoutCentroidArray.resize(dt),nt.layoutNormalArray.resize(dt),nt.layoutAOArray.resize(dt),nt.layoutColorArray.resize(dt),nt.layoutFloodLightDataArray.resize(dt),O&&(nt.layoutFacadePaintArray.resize(dt),nt.layoutFacadeDataArray.resize(dt),nt.layoutFacadeVerticalRangeArray.resize(dt));const ft=nt.indexArray.length;let yt=0,mt=pt;for(const t of rt.meshes){let e,r;if(1===t.buildingPart)e=M,r=D;else if(0===t.buildingPart)e=E,r=C;else if(2===t.buildingPart)e=B,r=T;else{if(3!==t.buildingPart)continue;e=k,r=z}if(r=ht(r,0,1),3===t.buildingPart){const e=new Array;for(let r=0;r<t.positions.length;r+=12){const n=t.positions[r+0],i=t.positions[r+1],o=t.positions[r+3],s=t.positions[r+4],a=t.positions[r+2],l=t.positions[r+8]-a,u=1,c=o-n,h=s-i,p=Math.hypot(c,h);e.push({pos:[n+.5*c,i+.5*h,a],normal:[h/p,-c/p,0],width:p,height:l,depth:u,points:[n,i,o,s]})}const r=nt.entranceBloom.segmentsBucket.prepareSegment(10*e.length,nt.entranceBloom.layoutVertexArray,nt.entranceBloom.indexArray),n=nt.entranceBloom.layoutVertexArray.length;ut=nt.entranceBloom.indexArray.length,tc(e,.5/this.tileToMeter,nt.entranceBloom.indexArray,nt.entranceBloom.layoutVertexArray,nt.entranceBloom.layoutAttenuationArray);const i=nt.entranceBloom.layoutVertexArray.length-n;ct=nt.entranceBloom.indexArray.length-ut;for(let t=0;t<i;t++)nt.entranceBloom.layoutColorArray.emplaceBack(255*k.r<<8|255*k.g,255*k.b<<8|51*z);r.vertexLength+=i,r.primitiveLength+=ct,lt={part:t.buildingPart,vertexOffset:n,vertexLength:i}}nt.layoutVertexArray.float32.set(t.positions,3*mt);const n=t.positions.length/3;for(let i=0;i<n;++i){const n=3*i;yt=Math.max(yt,t.positions[n+2]);const o=t.normals[n+1]*pc,s=t.normals[n+2]*pc,a=3*(mt+i);nt.layoutNormalArray.int16[a]=t.normals[n]*pc,nt.layoutNormalArray.int16[a+1]=o,nt.layoutNormalArray.int16[a+2]=s;const l=t.ao[i];nt.layoutAOArray.uint8[mt+i]=255*l;const u=1+(l-1)*I,c=255*e.b*u<<8|255*r;nt.layoutColorArray.uint16[2*(mt+i)]=255*e.r*u<<8|255*e.g*u,nt.layoutColorArray.uint16[2*(mt+i)+1]=c}const i=Math.floor(tt.x),o=Math.floor(tt.y),s=Math.floor(A);for(let t=0;t<n;++t){const e=3*(mt+t);nt.layoutCentroidArray.int16[e]=i,nt.layoutCentroidArray.int16[e+1]=o,nt.layoutCentroidArray.int16[e+2]=s}if(nt.layoutFloodLightDataArray.uint16.fill(0===t.buildingPart?V:0,mt,mt+n),O){const e=255*B.r<<8|255*B.g,r=255*B.b<<8|255*T;for(let t=0;t<n;++t){const n=2*(mt+t);nt.layoutFacadePaintArray.uint16[n]=e,nt.layoutFacadePaintArray.uint16[n+1]=r}for(let e=0;e<n;++e)if(t.isFauxFacade[e]){const r=Math.min(65535,Math.floor(t.uv[2*e]*rt.outerRingLength));nt.layoutFacadeDataArray.emplace(mt+e,1|r,Z,W,Y),nt.layoutFacadeVerticalRangeArray.emplace(mt+e,H,X)}else nt.layoutFacadeDataArray.emplace(mt+e,0,0,0,0),nt.layoutFacadeVerticalRangeArray.emplace(mt+e,0,0)}const a=st.vertexLength,l=t.indices.length/3,u=nt.indexArray.length;nt.indexArray.resize(u+l);for(let e=0;e<l;++e){const r=3*e,n=3*u+r;nt.indexArray.uint16[n]=a+t.indices[r],nt.indexArray.uint16[n+1]=a+t.indices[r+1],nt.indexArray.uint16[n+2]=a+t.indices[r+2]}1!==t.buildingPart&&0!==t.buildingPart&&2!==t.buildingPart&&3!==t.buildingPart||at.push({part:t.buildingPart,vertexOffset:mt,vertexLength:t.positions.length/3}),mt+=n,st.vertexLength+=n,st.primitiveLength+=t.indices.length/3}this.maxHeight=Math.max(this.maxHeight,yt);const gt=nt.indexArray.length-ft,xt=this.footprintsIndices.length,bt=this.footprintsVertices.length,wt=[],_t=new ot(1/0,1/0),St=new ot(-1/0,-1/0),It=this.groundEffect.vertexArray.length;for(const t of rt.modifiedPolygonRings){const e=[],r=new ot(1/0,1/0),n=new ot(-1/0,-1/0);for(let i=0;i<t.length;i+=2){const o=t.length-i-2;r.x=Math.min(r.x,t[o]),r.y=Math.min(r.y,t[o+1]),n.x=Math.max(n.x,t[o]),n.y=Math.max(n.y,t[o+1]);const s=new ot(t[o],t[o+1]);e.push(s),wt.push(s.x,s.y),this.footprintsVertices.emplaceBack(s.x,s.y)}_t.x=Math.min(_t.x,r.x),_t.y=Math.min(_t.y,r.y),St.x=Math.max(St.x,n.x),St.y=Math.max(St.y,n.y),this.groundEffect.addData(e,[r,n],P)}const Pt=this.groundEffect.vertexArray.length-It;this.groundEffect.groundRadiusArray.reserveForAdditional(Pt);for(let t=0;t<Pt;t++)this.groundEffect.groundRadiusArray.emplaceBack(S);(K.x<0||Q.x>Ue||K.y<0||Q.y>Ue)&&this.featuresOnBorder.push({featureId:l.id,footprintIndex:this.footprints.length});{const t=aa(wt,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+t.length),this.footprintsIndices.uint16.set(t,xt),this.buildingIds.add(null!=y?y:l.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,_t.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,_t.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,St.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,St.y);const e={footprintVertexOffset:bt,footprintVertexLength:this.footprintsVertices.length-bt,footprintIndexOffset:xt,footprintIndexLength:this.footprintsIndices.length-xt,min:_t,max:St,hiddenFlags:0,indicesOffset:ft,indicesLength:gt,bloomIndicesOffset:ut,bloomIndicesLength:ct,groundEffectVertexOffset:It,groundEffectVertexLength:Pt,hasFauxFacade:O,height:yt,promoteId:u,feature:m,parts:at,buildingBloom:lt},r=this.footprints.length;void 0!==l.id&&this.featureFootprintLookup.set(l.id,r),p(y,r),this.footprints.push(e)}this.programConfigurations.populatePaintArrays(nt.layoutVertexArray.length,l,d,{},e.availableImages,r,e.brightness),this.groundEffect.addPaintPropertiesData(l,d,{},e.availableImages,r,e.brightness),e.featureIndex.insert(l,g,d,f,this.index,pt)}u.forEach((({buildingId:t,footprintIndex:e})=>{c.has(t)&&(this.footprints[e].hiddenFlags|=4)}));const y=new Set;this.buildingIds.forEach(((t,e,r)=>{c.has(t)||y.add(t)})),this.buildingIds=y,this.groundEffect.prepareBorderSegments()}update(t,e,r,n,i,o,s){this.programConfigurations.updatePaintArrays(t,e,i,r,n,o,s),this.groundEffect.update(t,e,i,r,n,o,s),this.evaluate(this.layers[0],t),this.colorBufferUploaded=!1}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){const e=e=>{e.layoutVertexBuffer=t.createVertexBuffer(e.layoutVertexArray,rc.members),e.layoutNormalBuffer=t.createVertexBuffer(e.layoutNormalArray,nc.members),e.layoutCentroidBuffer=t.createVertexBuffer(e.layoutCentroidArray,ic.members),e.layoutFloodLightDataBuffer=t.createVertexBuffer(e.layoutFloodLightDataArray,cc.members),e.layoutFacadeDataArray&&e.layoutFacadeDataArray.length&&(e.layoutFacadeDataBuffer=t.createVertexBuffer(e.layoutFacadeDataArray,ac.members)),e.layoutFacadeVerticalRangeArray&&e.layoutFacadeVerticalRangeArray.length&&(e.layoutFacadeVerticalRangeBuffer=t.createVertexBuffer(e.layoutFacadeVerticalRangeArray,lc.members)),e.entranceBloom.layoutVertexArray.length&&(e.entranceBloom.layoutVertexBuffer=t.createVertexBuffer(e.entranceBloom.layoutVertexArray,rc.members),e.entranceBloom.layoutAttenuationBuffer=t.createVertexBuffer(e.entranceBloom.layoutAttenuationArray,uc.members)),this.uploadUpdatedColorBuffer(t),this.uploadUpdatedIndexBuffer(t)};this.uploaded||(e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){const t=t=>{t.layoutVertexBuffer&&(t.layoutVertexBuffer.destroy(),t.layoutNormalBuffer.destroy(),t.layoutColorBuffer.destroy(),t.segmentsBucket.destroy(),t.indexBuffer&&t.indexBuffer.destroy(),t.entranceBloom.layoutVertexBuffer&&(t.entranceBloom.layoutVertexBuffer.destroy(),t.entranceBloom.layoutColorBuffer.destroy(),t.entranceBloom.layoutAttenuationBuffer.destroy(),t.entranceBloom.indexBuffer.destroy(),t.entranceBloom.segmentsBucket.destroy()))};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(t,e,r=!0){let n=!1;const i=r?e:0,o=0|(r?-1:~e);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of t){const t=this.footprints[e],r=t.hiddenFlags&o|i;t.hiddenFlags!==r&&(t.hiddenFlags=r,n=!0,this.groundEffect.updateHiddenByLandmarkRange(t.groundEffectVertexOffset,t.groundEffectVertexLength,0!==t.hiddenFlags))}return n&&(this.indexArrayForConflationUploaded=!1),n}uploadUpdatedIndexBuffer(t){if(this.groundEffect.uploadHiddenByLandmark(t),this.indexArrayForConflationUploaded)return;const e=t=>{0!==t.indexArray.length&&(t.indexArrayForConflation.resize(t.indexArray.length),t.indexArrayForConflation.uint16.set(t.indexArray.uint16),t.entranceBloom.indexArrayForConflation.resize(t.entranceBloom.indexArray.length),t.entranceBloom.indexArrayForConflation.uint16.set(t.entranceBloom.indexArray.uint16))};e(this.buildingWithoutFacade),e(this.buildingWithFacade);for(const t of this.footprints){const e=t.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,r=t.indicesOffset+t.indicesLength;if(0!==t.hiddenFlags){for(let n=t.indicesOffset;n<r;n++)e.indexArrayForConflation.uint16[3*n+0]=0,e.indexArrayForConflation.uint16[3*n+1]=0,e.indexArrayForConflation.uint16[3*n+2]=0;const n=t.bloomIndicesOffset+t.bloomIndicesLength;for(let r=t.bloomIndicesOffset;r<n;r++)e.entranceBloom.indexArrayForConflation.uint16[3*r+0]=0,e.entranceBloom.indexArrayForConflation.uint16[3*r+1]=0,e.entranceBloom.indexArrayForConflation.uint16[3*r+2]=0}}const r=e=>{0!==e.indexArray.length&&(e.indexBuffer?e.indexBuffer.updateData(e.indexArrayForConflation):e.indexBuffer=t.createIndexBuffer(e.indexArrayForConflation,!0),e.entranceBloom.indexBuffer?e.entranceBloom.indexBuffer.updateData(e.entranceBloom.indexArrayForConflation):e.entranceBloom.indexBuffer=t.createIndexBuffer(e.entranceBloom.indexArrayForConflation,!0))};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(t){const e=e=>{e.layoutColorBuffer?e.layoutColorBuffer.updateData(e.layoutColorArray):e.layoutColorBuffer=t.createVertexBuffer(e.layoutColorArray,oc.members,!0),e.layoutFacadePaintArray&&(e.layoutFacadePaintBuffer?e.layoutFacadePaintBuffer.updateData(e.layoutFacadePaintArray):e.layoutFacadePaintBuffer=t.createVertexBuffer(e.layoutFacadePaintArray,sc.members,!0)),e.entranceBloom.layoutColorBuffer?e.entranceBloom.layoutColorBuffer.updateData(e.entranceBloom.layoutColorArray):e.entranceBloom.layoutColorBuffer=t.createVertexBuffer(e.entranceBloom.layoutColorArray,oc.members,!0)};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(t,e){const r=t.paint.get("building-ambient-occlusion-intensity");for(const n of this.footprints){if(4&n.hiddenFlags)continue;const i=e[n.promoteId],o=n.feature;o.properties["building-part"]="roof";const s=t.paint.get("building-color").evaluate(o,i,this.canonical).toPremultipliedRenderColor(this.lut),a=t.paint.get("building-emissive-strength").evaluate(o,i,this.canonical);o.properties["building-part"]="wall";const l=t.paint.get("building-color").evaluate(o,i,this.canonical).toPremultipliedRenderColor(this.lut),u=t.paint.get("building-emissive-strength").evaluate(o,i,this.canonical);o.properties["building-part"]="window";const c=t.paint.get("building-color").evaluate(o,i,this.canonical).toPremultipliedRenderColor(this.lut),h=t.paint.get("building-emissive-strength").evaluate(o,i,this.canonical);o.properties["building-part"]="door";const p=t.paint.get("building-color").evaluate(o,i,this.canonical).toPremultipliedRenderColor(this.lut),d=t.paint.get("building-emissive-strength").evaluate(o,i,this.canonical),f=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const t of n.parts){let e,i=s;1===t.part?(i=s,e=a):0===t.part?(i=l,e=u):2===t.part?(i=c,e=h):3===t.part&&(i=p,e=d),e=ht(e,0,1);for(let o=0;o<t.vertexLength;o++){const s=t.vertexOffset+o,a=1+(f.layoutAOArray.uint8[s]/255-1)*r;f.layoutColorArray.emplace(s,i.r*a*255<<8|i.g*a*255,i.b*a*255<<8|255*e),n.hasFauxFacade&&f.layoutFacadePaintArray.emplace(s,255*c.r<<8|255*c.g,255*c.b<<8|255*h)}}const y=n.buildingBloom;if(y)for(let t=0;t<y.vertexLength;t++)f.entranceBloom.layoutColorArray.emplace(y.vertexOffset+t,255*p.r<<8|255*p.g,255*p.b<<8|51*d)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(t,e,r){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped());if(cl(this.activeReplacements,n))return;this.activeReplacements=n;for(const t of this.footprints)t.hiddenFlags&=-2;const i=[];for(const e of this.activeReplacements){if(e.order<=sl)continue;const r=Math.max(1,Math.pow(2,e.footprintTileId.canonical.z-t.canonical.z));for(const n of this.footprints)n.min.x>e.max.x||n.max.x<e.min.x||n.min.y>e.max.y||n.max.y<e.min.y||(i.length=0,mc(this.footprintsVertices,n.footprintVertexOffset,n.footprintVertexLength,e.footprintTileId.canonical,t.canonical,i),hl(e.footprint,i,this.footprintsIndices.uint16,n.footprintIndexOffset,n.footprintIndexLength,0,-r)&&(n.hiddenFlags|=1))}0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(t.groundEffectVertexOffset,t.groundEffectVertexLength,0!==t.hiddenFlags);this.indexArrayForConflationUploaded=!1}getFootprint(t){if(void 0!==t.id){const e=this.featureFootprintLookup.get(t.id);return this.footprints[e]}return null}getHeightAtTileCoord(t,e){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(t+Ue)*Ue+(e+Ue);if(this.footprintLookup.hasOwnProperty(i)){const t=this.footprintLookup[i];return t?{height:t.height,hidden:0!==t.hiddenFlags}:void 0}const o=new ot(t,e);for(const s of this.footprints)t>s.max.x||s.min.x>t||e>s.max.y||s.min.y>e||s.height<=r||yc(o,this.footprintsVertices.float32.subarray(2*s.footprintVertexOffset,2*(s.footprintVertexOffset+s.footprintVertexLength)),this.footprintsIndices.uint16.subarray(s.footprintIndexOffset,s.footprintIndexOffset+s.footprintIndexLength))&&(r=s.height,this.footprintLookup[i]=s,n=0!==s.hiddenFlags);if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:n};this.footprintLookup[i]=void 0}}function yc(t,e,r){for(let n=0;n<r.length;n+=3){const i=r[n],o=r[n+1],s=r[n+2],a=e[2*i+0],l=e[2*i+1],u=e[2*o+0],c=e[2*o+1],h=e[2*s+0],p=e[2*s+1],d=(a-h)*(t.y-p)-(l-p)*(t.x-h),f=(u-a)*(t.y-l)-(c-l)*(t.x-a);if(d<0!=f<0&&0!==d&&0!==f)continue;const y=(h-u)*(t.y-c)-(p-c)*(t.x-u);if(0===y||y<0==d+f<=0)return!0}return!1}function mc(t,e,r,n,i,o){const s=Math.pow(2,n.z-i.z);for(let a=0;a<r;a++){let r=t.float32[2*(a+e)+0],l=t.float32[2*(a+e)+1];r=(r+i.x*Ue)*s-n.x*Ue,l=(l+i.y*Ue)*s-n.y*Ue,o.push(new ot(r,l))}}let gc,xc;Yn(BuildingBucket,"BuildingBucket",{omit:["layers"]}),Yn(BuildingGeometry,"BuildingGeometry"),Yn(BuildingBloomGeometry,"BuildingBloomGeometry");const vc=Zi([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),bc=Zi([{name:"a_z_offset_width",components:3,type:"Float32"}],4),{members:wc}=vc,_c=Zi([{name:"a_packed",components:3,type:"Float32"}]),{members:Ac}=_c,Sc=Zi([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:Ic}=Sc;class LineAtlas{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.image=new AlphaImage({width:t,height:e}),this.positions={},this.uploaded=!1}getDash(t,e){const r=this.getKey(t,e);return this.positions[r]}trim(){const t=this.width,e=this.height=(r=this.nextRow)<=1?1:Math.pow(2,Math.ceil(Math.log2(r)));var r;this.image.resize({width:t,height:e})}getKey(t,e){return t.join(",")+e}getDashRanges(t,e,r){const n=[];let i=t.length%2==1?-t[t.length-1]*r:0,o=t[0]*r,s=!0;n.push({left:i,right:o,isDash:s,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){s=!s;const l=t[e];i=a*r,a+=l,o=a*r,n.push({left:i,right:o,isDash:s,zeroLength:0===l})}return n}addRoundDash(t,e,r){const n=e/2;for(let e=-r;e<=r;e++){const i=this.width*(this.nextRow+r+e);let o=0,s=t[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=t[++o]);const l=Math.abs(a-s.left),u=Math.abs(a-s.right),c=Math.min(l,u);let h;const p=e/r*(n+1);if(s.isDash){const t=n-Math.abs(p);h=Math.sqrt(c*c+t*t)}else h=n-Math.sqrt(c*c+p*p);this.image.data[i+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1))}const r=t[0],n=t[t.length-1];r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let o=0,s=t[o];for(let r=0;r<this.width;r++){r/s.right>1&&(s=t[++o]);const n=Math.abs(r-s.left),a=Math.abs(r-s.right),l=Math.min(n,a);this.image.data[i+r]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const r=this.getKey(t,e);if(this.positions[r])return this.positions[r];const n="round"===e,i=n?7:0,o=2*i+1;if(this.nextRow+o>this.height)return vt("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;e<t.length;e++)t[e]<0&&(vt("Negative value is found in line dasharray, replacing values with 0"),t[e]=0),s+=t[e];if(0!==s){const r=this.width/s,o=this.getDashRanges(t,this.width,r);n?this.addRoundDash(o,r,i):this.addRegularDash(o,"square"===e?.5*r:0)}const a=this.nextRow+i;this.nextRow+=o;const l={tl:[a,i],br:[s,0]};return this.positions[r]=l,l}}Yn(LineAtlas,"LineAtlas");const Pc=VectorTileFeature.types,Mc=Math.cos(Math.PI/180*37.5),Dc=Math.cos(Math.PI/180*5);class LineBucket{constructor(t){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.zoom=t.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=t.overscaling,this.pixelRatio=t.pixelRatio,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new StructArrayLayout2i4ub1f12,this.layoutVertexArray2=new StructArrayLayout3f12,this.patternVertexArray=new StructArrayLayout3f12,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=new ProgramConfigurationSet(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new SegmentVector,this.maxLineLength=0,this.zOffsetVertexArray=new StructArrayLayout3f12,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:Ue/64,this.worldview=t.worldview,this.hasAppearances=null}updateFootprints(t,e){}updateAppearances(t,e,r,n){}populate(t,e,r,n){this.hasPattern=Va("line",this.layers,this.pixelRatio,e);const i=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Go(r);const o=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===o)this.elevationType="road";else{const t=this.layers[0].layout.get("line-z-offset"),e=t.isConstant()&&!t.constantOr(0);this.elevationType="sea"!==o&&"ground"!==o&&e?"none":"offset","offset"===this.elevationType&&"none"===o&&vt(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==s;const a=[];for(const{feature:o,id:s,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Ko(o,t);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:e.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r):void 0,p={id:s,properties:o.properties,type:o.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Jo(o,r,n),patterns:{},sortKey:h};a.push(p)}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:l,featureIndex:u}=e,c=this.addConstantDashes(l);for(const n of a){const{geometry:i,index:o,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,l),this.hasPattern){const t=Fa("line",this.layers,n,this.zoom,this.pixelRatio,e);this.patternFeatures.push(t)}else this.addFeature(n,i,o,r,l.positions,e.availableImages,e.brightness,e.elevationFeatures);u.insert(t[o].feature,i,o,s,this.index)}}addConstantDashes(t){let e=!1;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,i=r.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==i.kind)e=!0;else{const e=i.value,r=n.value;if(!r)continue;t.addDash(r,e)}}return e}addFeatureDashes(t,e){const r=this.zoom;for(const n of this.layers){const i=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===o.kind)continue;let s,a;if("constant"===i.kind){if(s=i.value,!s)continue}else s=i.evaluate({zoom:r},t);a="constant"===o.kind?o.value:o.evaluate({zoom:r},t),e.addDash(s,a),t.patterns[n.id]=[e.getKey(s,a)]}}update(t,e,r,n,i,o,s,a){this.programConfigurations.updatePaintArrays(t,e,i,r,n,o,s,a)}addFeatures(t,e,r,n,i,o){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,e,r,n,o,t.elevationFeatures)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ac)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Ic)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,bc.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,wc),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t,e){let r,n;if(e&&e>0?(r=`mapbox_clip_start_${e}`,n=`mapbox_clip_end_${e}`):(r="mapbox_clip_start",n="mapbox_clip_end"),t.properties&&t.properties.hasOwnProperty(r)&&t.properties.hasOwnProperty(n))return{start:+t.properties[r],end:+t.properties[n]}}addFeature(t,e,r,n,i,o,s,a){const l=this.layers[0].layout,u=l.get("line-join").evaluate(t,{}),c=l.get("line-cap").evaluate(t,{}),h=l.get("line-miter-limit"),p=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(t),this.lineFeature=t;const d=!(!t.properties||!t.properties.hasOwnProperty("mapbox_line_metrics"))&&t.properties.mapbox_line_metrics;this.zOffsetValue=l.get("line-z-offset").value;const f=this.layers[0].paint.get("line-width").value;if("constant"!==f.kind&&!1===f.isLineProgressConstant&&(this.variableWidthValue=f),"road"===this.elevationType){const r=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(t,e,n,a,u,c,h,p)){const[i,o]=this.clipRuntimeLinesToTile(e,1);for(let e=0;e<i.length;e++){const r=i[e],s=o[e],a={progress:{min:s.progress.min,max:s.progress.max},nextDir:this.computeSegNextDir(s,r),prevDir:this.computeSegPrevDir(s,r)};this.addLine(r,t,n,u,c,h,p,a,d&&s.parentIndex>0?s.parentIndex:null)}this.fillNonElevatedRoadSegment(r)}}else for(let r=0;r<e.length;r++)this.addLine(e[r],t,n,u,c,h,p,void 0,d&&r>0?r:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,o,n,s,void 0,this.worldview)}computeSegNextDir(t,e){return t.nextPoint.sub(e.at(-2)).unit()}computeSegPrevDir(t,e){return e[1].sub(t.prevPoint).unit()}clipLinesToTile(t,e){return ql(t,-e,-e,Ue+e,Ue+e)}clipRuntimeLinesToTile(t,e){const r=[];return[ql(t,-e,-e,Ue+e,Ue+e,r),r]}addElevatedRoadFeature(t,e,r,n,i,o,s,a){const l=[],u=ElevationFeatures.getElevationFeature(t,n);if(u){const t=this.clipLinesToTile(e,1),n=this.prepareElevatedLines(t,u,r);for(const t of n)l.push({geometry:t,elevation:u,elevationTileID:r,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(0===l.length)return!1;for(const e of l){const n=this.layoutVertexArray.length;this.addLine(e.geometry,t,r,i,o,s,a);const l=new ElevationFeatureSampler(r,e.elevationTileID);if(e.elevation)for(let t=n;t<this.layoutVertexArray.length;t++){const r=new ot(this.layoutVertexArray.int16[6*t]>>1,this.layoutVertexArray.int16[6*t+1]>>1),n=l.pointElevation(r,e.elevation,.05);this.updateHeightRange(n),this.zOffsetVertexArray.emplaceBack(n,0,0)}else this.fillNonElevatedRoadSegment(n)}return!0}prepareElevatedLines(t,e,r){if(null!=e.constantHeight)return t;const n=[],i=1/Go(r);for(const r of t)Hl(r,new EdgeIterator(e,i),0,n);return n}fillNonElevatedRoadSegment(t){for(let e=t;e<this.layoutVertexArray.length;e++)this.zOffsetVertexArray.emplaceBack(0,0,0)}updateHeightRange(t){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,t),this.heightRange.max=Math.max(this.heightRange.max,t)):this.heightRange={min:t,max:t}}addLine(t,e,r,n,i,o,s,a,l){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0,this.lineClips=l?this.lineFeatureClips(e,l):this.lineClips;const u="none"===n;this.patternJoinNone=this.hasPattern&&u,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];const c=a&&a.progress.min>0,h=a&&a.progress.max<1;if(this.lineClips){let r={min:this.lineClips.start,max:this.lineClips.end},n=1;if(a){const t=this.lineClips.end-this.lineClips.start;r=function(t,e,r){return{min:Dt(t.min,e,r),max:Dt(t.max,e,r)}}(a.progress,{min:0,max:1},r),t>0&&(n=(r.max-r.min)/t)}const i=+e.properties.mapbox_clip_feature_len,o=+e.properties.mapbox_clip_seg_len;if(Number.isNaN(i)||Number.isNaN(o)){for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);const e=this.totalDistance/(r.max-r.min);this.totalFeatureLength=Number.isFinite(e)?e:0,this.lineClips.start=r.min,this.lineClips.end=r.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=i,this.distance=o*n,this.lineClips.start=r.min,this.lineClips.end=r.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}const p="Polygon"===Pc[e.type];let d=t.length;for(;d>=2&&t[d-1].equals(t[d-2]);)d--;let f=0;for(;f<d-1&&t[f].equals(t[f+1]);)f++;if(d<(p?3:2))return;"bevel"===n&&(o=1.05);const y=this.segments.prepareSegment(10*d,this.layoutVertexArray,this.indexArray);let m,g,x,v,b,w,_,A;a&&a.prevDir&&(w=a.prevDir.perp()),a&&a.nextDir&&(_=a.nextDir.perp()),this.e1=this.e2=-1,p&&(m=t[d-2],b=t[f].sub(m)._unit()._perp());for(let e=f;e<d;e++){if(x=e===d-1?p?t[f+1]:void 0:t[e+1],x&&t[e].equals(x))continue;b&&(v=b),m&&(g=m),m=t[e],A=this.evaluateLineProgressFeatures(g?g.dist(m):0),b=x?x.sub(m)._unit()._perp():v,v=v||b;const r=g&&x;let a=r?n:p||u?"butt":i;const l=v.x*b.x+v.y*b.y;if(u){const t=function(t){if(t.patternJoinNone){const e=t.segmentPoints.length/2,r=t.lineSoFar-t.segmentStart;for(let n=0;n<e;++n){const e=t.segmentPoints[2*n+1],i=Math.round(t.segmentPoints[2*n])+.5+.25*e;t.patternVertexArray.emplaceBack(i,r,t.segmentStart),t.patternVertexArray.emplaceBack(i,r,t.segmentStart)}t.segmentPoints.length=0}t.e1=t.e2=-1};if(r&&l<Dc){this.updateDistance(g,m),this.addCurrentVertex(m,v,1,1,y,A),t(this),this.addCurrentVertex(m,b,-1,-1,y,A);continue}if(g){if(!x){this.updateDistance(g,m),this.addCurrentVertex(m,v,1,1,y,A),t(this);continue}a="miter"}}let S=v.add(b);0===S.x&&0===S.y||S._unit();const I=S.x*b.x+S.y*b.y,P=0!==I?1/I:1/0,M=2*Math.sqrt(2-2*I),D=I<Mc&&g&&x,E=v.x*b.y-v.y*b.x>0,C=this.overscaling<=16?15*Ue/(512*this.overscaling):0;if(r&&"round"===a)if(P<s)a="miter";else if(P<=2){const t=Ec(m,-10,Ue+10);a="offset"===this.elevationType&&(t||this.hasCrossSlope)?"miter":"fakeround"}if("miter"===a&&P>o&&(a="bevel"),"bevel"===a&&(P>2&&(a="flipbevel"),P<o&&(a="miter")),g&&!("miter"===a&&D)&&this.updateDistance(g,m),"miter"===a)if(D){const t=m.dist(g);if(t>2*C){const e=m.sub(m.sub(g)._mult(C/t)._round());this.updateDistance(g,e),this.addCurrentVertex(e,v,0,0,y,A),g=e}this.updateDistance(g,m),S._mult(P),this.addCurrentVertex(m,S,0,0,y,A);const e=m.dist(x);if(e>2*C){const t=m.add(x.sub(m)._mult(C/e)._round());this.updateDistance(m,t),this.addCurrentVertex(t,b,0,0,y,A),m=t}}else S._mult(P),this.addCurrentVertex(m,S,0,0,y,A);else if("flipbevel"===a){if(P>100)S=b.mult(-1);else{const t=P*v.add(b).mag()/v.sub(b).mag();S._perp()._mult(t*(E?-1:1))}this.addCurrentVertex(m,S,0,0,y,A),this.addCurrentVertex(m,S.mult(-1),0,0,y,A)}else if("bevel"===a||"fakeround"===a){null!=A&&g&&this.addCurrentVertex(m,_||v,-1,-1,y,A);const t=m.dist(g)<=2*C&&"bevel"!==a,e=S.mult(E?1:-1);e._mult(P);const r=b.mult(E?-1:1),n=v.mult(E?-1:1),i=this.evaluateLineProgressFeatures(this.distance);if(null==A&&(this.addHalfVertex(m,e.x,e.y,!1,!E,0,y,i),t||this.addHalfVertex(m,e.x+2*n.x,e.y+2*n.y,!1,E,0,y,i)),"fakeround"===a){const t=Math.round(180*M/Math.PI/20);this.addHalfVertex(m,n.x,n.y,!1,E,0,y,i);for(let e=0;e<t;e++){let o=e/t;if(.5!==o){const t=o-.5;o+=o*t*(o-1)*((1.0904+l*(l*(3.55645-1.43519*l)-3.2452))*t*t+(.848013+l*(.215638*l-1.06021)))}const s=r.sub(n)._mult(o)._add(n)._unit();this.addHalfVertex(m,s.x,s.y,!1,E,0,y,i)}this.addHalfVertex(m,r.x,r.y,!1,E,0,y,i)}t||null!=A||this.addHalfVertex(m,e.x+2*r.x,e.y+2*r.y,!1,E,0,y,i),null!=A&&x&&this.addCurrentVertex(m,w||b,1,1,y,A)}else if("butt"===a)this.addCurrentVertex(m,S,0,0,y,A);else if("square"===a){if(!g){const t=c?0:-1;this.addCurrentVertex(m,S,t,t,y,A)}if(this.addCurrentVertex(m,S,0,0,y,A),g){const t=h?0:1;this.addCurrentVertex(m,S,t,t,y,A)}}else if("round"===a){if(g){const t=!r&&_?_:v;this.addCurrentVertex(m,t,0,0,y,A),!r&&h||this.addCurrentVertex(m,t,1,1,y,A,!0)}if(x){const t=!r&&w?w:b;!r&&c||this.addCurrentVertex(m,t,-1,-1,y,A,!0),this.addCurrentVertex(m,t,0,0,y,A)}}}}addVerticesTo(t,e,r,n,i,o,s,a,l,u){const c=(e.w-t.w)/this.tessellationStep|0;let h=0;const p=this.scaledDistance;if(c>1){this.lineSoFar=t.w;const p=(e.x-t.x)/c,d=(e.y-t.y)/c,f=(e.z-t.z)/c,y=(e.w-t.w)/c;for(let e=1;e<c;++e){t.x+=p,t.y+=d,t.z+=f,this.lineSoFar+=y,h+=y;const e=this.evaluateLineProgressFeatures(this.prevDistance+h);this.scaledDistance=(this.prevDistance+h)/this.totalDistance,this.addHalfVertex(t,r,n,u,!1,s,l,e),this.addHalfVertex(t,i,o,u,!0,-a,l,e)}}this.lineSoFar=e.w,this.scaledDistance=p;const d=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(e,r,n,u,!1,s,l,d),this.addHalfVertex(e,i,o,u,!0,-a,l,d)}evaluateLineProgressFeatures(t){if(!this.variableWidthValue&&"offset"!==this.elevationType)return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+t)/this.totalFeatureLength):vt(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let e=0;return this.variableWidthValue&&"constant"!==this.variableWidthValue.kind&&(e=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0),"offset"!==this.elevationType?{zOffset:0,variableWidth:e}:"constant"===this.zOffsetValue.kind?{zOffset:this.zOffsetValue.value,variableWidth:e}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:e}}addCurrentVertex(t,e,r,n,i,o,s=!1){const a=e.x+e.y*r,l=e.y-e.x*r,u=e.y*n-e.x,c=-e.y-e.x*n;if(null!=o){const e="offset"===this.elevationType,h=-10,p=Ue+10,d=o.zOffset,f=new Point4D(t.x,t.y,d,this.lineSoFar),y=!!e&&Ec(t,h,p),m=this.lineSoFar,g=this.distance;if(this.currentVertex)if(y){const e=this.currentVertexIsOutside,o=this.currentVertex,y=new Point4D(t.x,t.y,d,this.lineSoFar);if($l(o,y,h,p),!Ec(y,h,p)){if(e){this.e1=this.e2=-1,this.distance-=o.dist(f),this.lineSoFar=o.w;const t=this.evaluateLineProgressFeatures(o.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(o,a,l,s,!1,r,i,t),this.addHalfVertex(o,u,c,s,!0,-n,i,t),this.prevDistance=this.distance}this.distance=this.prevDistance+o.dist(y),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(o,y,a,l,u,c,r,n,i,s),this.distance=g,this.scaledDistance=this.distance/this.totalDistance}}else{const t=this.currentVertex;if(this.currentVertexIsOutside){$l(t,f,h,p),this.e1=this.e2=-1,this.distance-=t.dist(f),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t.w;const e=this.evaluateLineProgressFeatures(t.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(t,a,l,s,!1,r,i,e),this.addHalfVertex(t,u,c,s,!0,-n,i,e),this.prevDistance=this.distance,this.distance=g,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(t,f,a,l,u,c,r,n,i,s)}else y||(this.addHalfVertex(t,a,l,s,!1,r,i,o),this.addHalfVertex(t,u,c,s,!0,-n,i,o));this.currentVertex=f,this.currentVertexIsOutside=y,this.lineSoFar=m}else this.addHalfVertex(t,a,l,s,!1,r,i,o),this.addHalfVertex(t,u,c,s,!0,-n,i,o)}addHalfVertex({x:t,y:e},r,n,i,o,s,a,l){if(this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),o||this.segmentPoints.push(this.lineSoFar-this.segmentStart,s)),this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(o?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){const t=Vt(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,t)}const u=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),a.primitiveLength++),o?this.e2=u:this.e1=u,null!=l&&this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(t,e){this.prevDistance=this.distance,this.distance+=t.dist(e),this.updateScaledDistance()}}function Ec(t,e,r){return t.x<e||t.x>r||t.y<e||t.y>r}let Cc,Bc,Tc;Yn(LineBucket,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const kc=()=>Tc||(Tc={layout:Cc||(Cc=new Properties({"line-cap":new DataDrivenProperty(Pi.layout_line["line-cap"]),"line-join":new DataDrivenProperty(Pi.layout_line["line-join"]),"line-miter-limit":new DataConstantProperty(Pi.layout_line["line-miter-limit"]),"line-round-limit":new DataConstantProperty(Pi.layout_line["line-round-limit"]),"line-sort-key":new DataDrivenProperty(Pi.layout_line["line-sort-key"]),"line-z-offset":new DataDrivenProperty(Pi.layout_line["line-z-offset"]),"line-elevation-reference":new DataConstantProperty(Pi.layout_line["line-elevation-reference"]),"line-cross-slope":new DataConstantProperty(Pi.layout_line["line-cross-slope"]),visibility:new DataConstantProperty(Pi.layout_line.visibility),"line-width-unit":new DataConstantProperty(Pi.layout_line["line-width-unit"])})),paint:Bc||(Bc=new Properties({"line-opacity":new DataDrivenProperty(Pi.paint_line["line-opacity"]),"line-color":new DataDrivenProperty(Pi.paint_line["line-color"]),"line-translate":new DataConstantProperty(Pi.paint_line["line-translate"]),"line-translate-anchor":new DataConstantProperty(Pi.paint_line["line-translate-anchor"]),"line-width":new DataDrivenProperty(Pi.paint_line["line-width"]),"line-gap-width":new DataDrivenProperty(Pi.paint_line["line-gap-width"]),"line-offset":new DataDrivenProperty(Pi.paint_line["line-offset"]),"line-blur":new DataDrivenProperty(Pi.paint_line["line-blur"]),"line-dasharray":new DataDrivenProperty(Pi.paint_line["line-dasharray"]),"line-pattern":new DataDrivenProperty(Pi.paint_line["line-pattern"]),"line-pattern-cross-fade":new DataConstantProperty(Pi.paint_line["line-pattern-cross-fade"]),"line-gradient":new ColorRampProperty(Pi.paint_line["line-gradient"]),"line-trim-offset":new DataConstantProperty(Pi.paint_line["line-trim-offset"]),"line-trim-fade-range":new DataConstantProperty(Pi.paint_line["line-trim-fade-range"]),"line-trim-color":new DataConstantProperty(Pi.paint_line["line-trim-color"]),"line-emissive-strength":new DataDrivenProperty(Pi.paint_line["line-emissive-strength"]),"line-border-width":new DataDrivenProperty(Pi.paint_line["line-border-width"]),"line-border-color":new DataDrivenProperty(Pi.paint_line["line-border-color"]),"line-occlusion-opacity":new DataConstantProperty(Pi.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},Tc);class LineFloorwidthProperty extends DataDrivenProperty{possiblyEvaluate(t,e){return e=new EvaluationParameters(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition,worldview:e.worldview}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=Object.assign({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let zc;function Lc(t,e){return e>0?e+2*t:t}const Vc=Zi([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Fc=Zi([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Rc=Zi([{name:"a_projected_pos",components:4,type:"Float32"}],4);Zi([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Oc=Zi([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Uc=Zi([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),Nc=Zi([{name:"a_texb",components:2,type:"Uint16"}]),jc=Zi([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Gc=Zi([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Zi([{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 $c=Zi([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);Zi([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4),Zi([{name:"triangle",components:3,type:"Uint16"}]),Zi([{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"}]),Zi([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),Zi([{type:"Float32",name:"offsetX"}]),Zi([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var qc=24;function Hc(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ii.applyArabicShaping&&(t=Ii.applyArabicShaping(t)),t}(t.text,e,r)})),t}const Xc={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Zc(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||""===t||" ̄"===t||"︑"===t||"︒"===t}function Wc(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}const Yc=4294967296,Jc=1/Yc,Kc="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");let Qc=class Pbf{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,r=this.length){for(;this.pos<r;){const r=this.readVarint(),n=r>>3,i=this.pos;this.type=7&r,t(n,e,this),this.pos===i&&this.skip(r)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Yc;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Yc;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let r,n;return n=e[this.pos++],r=127&n,n<128?r:(n=e[this.pos++],r|=(127&n)<<7,n<128?r:(n=e[this.pos++],r|=(127&n)<<14,n<128?r:(n=e[this.pos++],r|=(127&n)<<21,n<128?r:(n=e[this.pos],r|=(15&n)<<28,function(t,e,r){const n=r.buf;let i,o;if(o=n[r.pos++],i=(112&o)>>4,o<128)return th(t,i,e);if(o=n[r.pos++],i|=(127&o)<<3,o<128)return th(t,i,e);if(o=n[r.pos++],i|=(127&o)<<10,o<128)return th(t,i,e);if(o=n[r.pos++],i|=(127&o)<<17,o<128)return th(t,i,e);if(o=n[r.pos++],i|=(127&o)<<24,o<128)return th(t,i,e);if(o=n[r.pos++],i|=(1&o)<<31,o<128)return th(t,i,e);throw new Error("Expected varint not more than 10 bytes")}(r,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Kc?Kc.decode(this.buf.subarray(e,t)):function(t,e,r){let n="",i=e;for(;i<r;){const e=t[i];let o,s,a,l=null,u=e>239?4:e>223?3:e>191?2:1;if(i+u>r)break;1===u?e<128&&(l=e):2===u?(o=t[i+1],128==(192&o)&&(l=(31&e)<<6|63&o,l<=127&&(l=null))):3===u?(o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(l=(15&e)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&e)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),i+=u}return n}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const r=this.readPackedEnd();for(;this.pos<r;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(t){const e=7&t;if(0===e)for(;this.buf[this.pos++]>127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){const t=new Uint8Array(e);t.set(this.buf),this.buf=t,this.dataView=new DataView(t.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Jc),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Jc),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?function(t,e){let r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(r=~(-t%4294967296),n=~(-t/4294967296),4294967295^r?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7)}(r,0,e),function(t,e){const r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const e=this.pos;this.pos=function(t,e,r){for(let n,i,o=0;o<e.length;o++){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){n>56319||o+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);const r=this.pos-e;r>=128&&eh(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e);for(let r=0;r<e;r++)this.buf[this.pos++]=t[r]}writeRawMessage(t,e){this.pos++;const r=this.pos;t(e,this);const n=this.pos-r;n>=128&&eh(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n}writeMessage(t,e,r){this.writeTag(t,2),this.writeRawMessage(e,r)}writePackedVarint(t,e){e.length&&this.writeMessage(t,rh,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,nh,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,sh,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,ih,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,oh,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,ah,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,lh,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,uh,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,ch,e)}writeBytesField(t,e){this.writeTag(t,2),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,5),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,5),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,1),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,1),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,0),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,0),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,2),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,5),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,1),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}};function th(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function eh(t,e,r){const n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(let e=r.pos-1;e>=t;e--)r.buf[e+n]=r.buf[e]}function rh(t,e){for(let r=0;r<t.length;r++)e.writeVarint(t[r])}function nh(t,e){for(let r=0;r<t.length;r++)e.writeSVarint(t[r])}function ih(t,e){for(let r=0;r<t.length;r++)e.writeFloat(t[r])}function oh(t,e){for(let r=0;r<t.length;r++)e.writeDouble(t[r])}function sh(t,e){for(let r=0;r<t.length;r++)e.writeBoolean(t[r])}function ah(t,e){for(let r=0;r<t.length;r++)e.writeFixed32(t[r])}function lh(t,e){for(let r=0;r<t.length;r++)e.writeSFixed32(t[r])}function uh(t,e){for(let r=0;r<t.length;r++)e.writeFixed64(t[r])}function ch(t,e){for(let r=0;r<t.length;r++)e.writeSFixed64(t[r])}const hh=3,ph={horizontal:1,vertical:2,horizontalOnly:3},dh=-17;class SectionOptions{constructor(){this.scale=1,this.fontStack="",this.image=null}static forText(t,e){const r=new SectionOptions;return r.scale=t||1,r.fontStack=e,r}static forImage(t){const e=new SectionOptions;return e.image=t,e}}class TaggedString{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e,r){const n=new TaggedString;for(let i=0;i<t.sections.length;i++){const o=t.sections[i];o.image?n.addImageSection(o,r):n.addTextSection(o,e)}return n}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSections(){return this.sections}getSectionIndex(t){return this.sectionIndex[t]}getCodePoint(t){return this.text.codePointAt(t)}verticalizePunctuation(t){this.text=function(t,e){let r="";for(let n=0;n<t.length;n++){const i=t.charCodeAt(n+1)||null,o=t.charCodeAt(n-1)||null;r+=!e&&(i&&li(i)&&!Xc[t[n+1]]||o&&li(o)&&!Xc[t[n-1]])||!Xc[t[n]]?t[n]:Xc[t[n]]}return r}(this.text,t)}trim(){let t=0;for(let e=0;e<this.text.length&&yh[this.text.charCodeAt(e)];e++)t++;let e=this.text.length;for(let r=this.text.length-1;r>=0&&r>=t&&yh[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const r=new TaggedString;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(SectionOptions.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e<t.text.length;++e)this.sectionIndex.push(r)}addImageSection(t,e){const r=t.image?t.image.getPrimary():null;if(!r)return void vt("Can't add FormattedSection with an empty image.");r.scaleSelf(e);const n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCodePoint(n),this.sections.push(SectionOptions.forImage(r)),this.sectionIndex.push(this.sections.length-1)):vt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function fh(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y=1){const m=TaggedString.fromFeature(t,i,y);h===ph.vertical&&m.verticalizePunctuation(p);let g=[];const x=function(t,e,r,n,i,o){if(!t)return[];const s=[],a=function(t,e,r,n,i,o){let s=0;for(let r=0;r<t.length();r++){const a=t.getSection(r);s+=gh(t.getCodePoint(r),a,n,i,e,o)}return s/Math.max(1,Math.ceil(s/r))}(t,e,r,n,i,o),l=t.text.indexOf("")>=0;let u=0;for(let r=0;r<t.length();r++){const h=t.getSection(r),p=t.getCodePoint(r);if(yh[p]||(u+=gh(p,h,n,i,e,o)),r<t.length()-1){const e=!((c=p)<11904||!(ni["Bopomofo Extended"](c)||ni.Bopomofo(c)||ni["CJK Compatibility Forms"](c)||ni["CJK Compatibility Ideographs"](c)||ni["CJK Compatibility"](c)||ni["CJK Radicals Supplement"](c)||ni["CJK Strokes"](c)||ni["CJK Symbols and Punctuation"](c)||ni["CJK Unified Ideographs Extension A"](c)||ni["CJK Unified Ideographs"](c)||ni["Enclosed CJK Letters and Months"](c)||ni["Halfwidth and Fullwidth Forms"](c)||ni.Hiragana(c)||ni["Ideographic Description Characters"](c)||ni["Kangxi Radicals"](c)||ni["Katakana Phonetic Extensions"](c)||ni.Katakana(c)||ni["Vertical Forms"](c)||ni["Yi Radicals"](c)||ni["Yi Syllables"](c)));(mh[p]||e||h.image)&&s.push(bh(r+1,u,a,s,vh(p,t.getCodePoint(r+1),e&&l),!1))}}var c;return wh(bh(t.length(),u,a,s,0,!0))}(m,u,o,e,n,d),{processBidirectionalText:v,processStyledBidirectionalText:b}=Ii;if(v&&1===m.sections.length){const t=v(m.toString(),x);for(const e of t){const t=new TaggedString;t.text=e,t.sections=m.sections;for(let r=0;r<e.length;r++)t.sectionIndex.push(0);g.push(t)}}else if(b){const t=b(m.text,m.sectionIndex,x);for(const e of t){const t=new TaggedString;t.text=e[0],t.sectionIndex=e[1],t.sections=m.sections,g.push(t)}}else g=function(t,e){const r=[],n=t.text;let i=0;for(const n of e)r.push(t.substring(i,n)),i=n;return i<n.length&&r.push(t.substring(i,n.length)),r}(m,x);const w=[],_={positionedLines:w,text:m.toString(),top:c[1],bottom:c[1],left:c[0],right:c[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if(function(t,e,r,n,i,o,s,a,l,u,c,h){let p=0,d=0,f=0;const y="right"===a?1:"left"===a?0:.5;let m=!1;for(const t of i){const r=t.getSections();for(const t of r){if(t.image)continue;const r=e[t.fontStack];if(r&&(m=void 0!==r.ascender&&void 0!==r.descender,!m))break}if(!m)break}let g=0;for(const s of i){s.trim();const i=s.getMaxScale(),a=(i-1)*qc,v={positionedGlyphs:[],lineOffset:0};t.positionedLines[g]=v;const b=v.positionedGlyphs;let w=0;if(!s.length()){d+=o,++g;continue}let _=0,A=0;for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),y=s.getCodePoint(o);let g=a.scale,v=null,S=null,I=null,P=qc,M=0,D=l;D===ph.vertical&&(12312===(x=y)||12313===x||12316===x||12540===x||12448===x)&&(D=ph.horizontal);const E=!(D===ph.horizontal||!c&&!ai(y)||c&&(yh[y]||ui(y)));if(a.image){const e=n.get(a.image.toString());if(!e)continue;I=a.image,t.iconsInText=t.iconsInText||!0,S=e.paddedRect;const r=e.displaySize;g=g*qc/h,v={width:r[0],height:r[1],left:0,top:-hh,advance:E?r[1]:r[0],localGlyph:!1},M=m?-v.height*g:dh+i*qc-r[1]*g,P=v.advance;const o=(E?r[0]:r[1])*g-qc*i;o>0&&o>w&&(w=o)}else{const t=r[a.fontStack];if(!t)continue;t[y]&&(S=t[y]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[y];if(!o)continue;if(v=o.metrics,P=8203!==y?qc:0,m){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,r=(t+e)*g;_<r&&(_=r,A=(t-e)/2*g),M=-t*g}else M=dh+(i-g)*qc}E?(t.verticalizable=!0,b.push({glyph:y,image:I,x:p,y:d+M,vertical:E,scale:g,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:S}),p+=P*g+u):(b.push({glyph:y,image:I,x:p,y:d+M,vertical:E,scale:g,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:S}),p+=v.advance*g+u)}0!==b.length&&(f=Math.max(p-u,f),m?Ah(b,y,w,A,o*i/2):Ah(b,y,w,0,o/2)),p=0;const S=o*i+w;v.lineOffset=Math.max(w,a),d+=S,++g}var x;const v=d,{horizontalAlign:b,verticalAlign:w}=_h(s);(function(t,e,r,n,i,o){const s=(e-r)*i,a=-o*n;for(const e of t)for(const t of e.positionedGlyphs)t.x+=s,t.y+=a})(t.positionedLines,y,b,w,f,v),t.top+=-w*v,t.bottom=t.top+v,t.left+=-b*f,t.right=t.left+f,t.hasBaseline=m}(_,e,r,n,g,s,a,l,h,u,p,f),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(w))return _}const yh={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},mh={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function gh(t,e,r,n,i,o){if(e.image){const t=n.get(e.image.toString());return t?t.displaySize[0]*e.scale*qc/o+i:0}{const n=r[e.fontStack],o=n&&n.glyphs[t];return o?o.metrics.advance*e.scale+i:0}}function xh(t,e,r,n){const i=Math.pow(t-e,2);return n?t<e?i/2:2*i:i+Math.abs(r)*r}function vh(t,e,r){let n=0;return 10===t&&(n-=1e4),r&&(n+=150),40!==t&&65288!==t||(n+=50),41!==e&&65289!==e||(n+=50),n}function bh(t,e,r,n,i,o){let s=null,a=xh(e,r,i,o);for(const t of n){const n=xh(e-t.x,r,i,o)+t.badness;n<=a&&(s=t,a=n)}return{index:t,x:e,priorBreak:s,badness:a}}function wh(t){return t?wh(t.priorBreak).concat(t.index):[]}function _h(t){let e=.5,r=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function Ah(t,e,r,n,i){if(!(e||r||n||i))return;const o=t.length-1,s=t[o],a=(s.x+s.metrics.advance*s.scale)*e;for(let e=0;e<=o;e++)t[e].x-=a,t[e].y+=r+n+i}function Sh(t){return void 0!==t.imagePrimary&&void 0!==t.top&&void 0!==t.bottom&&void 0!==t.left&&void 0!==t.right}function Ih(t,e,r,n){const{horizontalAlign:i,verticalAlign:o}=_h(n),s=r[0]-t.displaySize[0]*i,a=r[1]-t.displaySize[1]*o;return{imagePrimary:t,imageSecondary:e,top:a,bottom:a+t.displaySize[1],left:s,right:s+t.displaySize[0]}}function Ph(t,e,r,n,i,o){const s=t.imagePrimary;let a;if(s.content){const t=s.content,e=s.pixelRatio||1;a=[t[0]/e,t[1]/e,s.displaySize[0]-t[2]/e,s.displaySize[1]-t[3]/e]}const l=e.left*o,u=e.right*o;let c,h,p,d;"width"===r||"both"===r?(d=i[0]+l-n[3],h=i[0]+u+n[1]):(d=i[0]+(l+u-s.displaySize[0])/2,h=d+s.displaySize[0]);const f=e.top*o,y=e.bottom*o;return"height"===r||"both"===r?(c=i[1]+f-n[0],p=i[1]+y+n[2]):(c=i[1]+(f+y-s.displaySize[1])/2,p=c+s.displaySize[1]),{imagePrimary:s,imageSecondary:void 0,top:c,right:h,bottom:p,left:d,collisionPadding:a}}function Mh(t){return!t.imagePrimary.stretchX}function Dh(t){return!t.imagePrimary.stretchY}function Eh(t){return{width:t.right-t.left,height:t.bottom-t.top}}const Ch=128;function Bh(t,e,r){const{expression:n}=e;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new EvaluationParameters(t+1,{worldview:r}))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:i}=n;let o=0;for(;o<e.length&&e[o]<=t;)o++;o=Math.max(0,o-1);let s=o;for(;s<e.length&&e[s]<t+1;)s++;s=Math.min(e.length-1,s);const a=e[o],l=e[s];return"composite"===n.kind?{kind:"composite",minZoom:a,maxZoom:l,interpolationType:i}:{kind:"camera",minZoom:a,maxZoom:l,minSize:n.evaluate(new EvaluationParameters(a,{worldview:r})),maxSize:n.evaluate(new EvaluationParameters(l,{worldview:r})),interpolationType:i}}}function Th(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return"source"===t.kind?n/Ch:"composite"===t.kind?Vt(n/Ch,i/Ch,r):e}function kh(t,e,r=1){let n=0,i=0;if("constant"===t.kind)i=t.layoutSize*r;else if("source"!==t.kind){const{interpolationType:o,minZoom:s,maxZoom:a}=t,l=o?ht(Interpolate.interpolationFactor(o,e,s,a),0,1):0;"camera"===t.kind?i=Vt(t.minSize,t.maxSize,l)*r:n=l*r}return{uSizeT:n,uSize:i}}class Anchor extends ot{constructor(t,e,r,n,i){super(t,e),this.angle=n,this.z=r,void 0!==i&&(this.segment=i)}clone(){return new Anchor(this.x,this.y,this.z,this.angle,this.segment)}}function zh(t,e,r,n,i){if(void 0===e.segment)return!0;let o=e,s=e.segment+1,a=0;for(;a>-r/2;){if(s--,s<0)return!1;a-=t[s].dist(o),o=t[s]}a+=t[s].dist(t[s+1]),s++;const l=[];let u=0;for(;a<r/2;){const e=t[s],r=t[s+1];if(!r)return!1;let o=t[s-1].angleTo(e)-e.angleTo(r);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:o}),u+=o;a-l[0].distance>n;)u-=l.shift().angleDelta;if(u>i)return!1;s++,a+=e.dist(r)}return!0}function Lh(t){let e=0;for(let r=0;r<t.length-1;r++)e+=t[r].dist(t[r+1]);return e}function Vh(t,e,r){return t?.6*e*r:0}function Fh(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function Rh(t,e,r,n,i,o){const s=Vh(r,i,o),a=Fh(r,n)*o;let l=0;const u=Lh(t)/2;for(let r=0;r<t.length-1;r++){const n=t[r],i=t[r+1],o=n.dist(i);if(l+o>u){const c=(u-l)/o,h=Vt(n.x,i.x,c),p=Vt(n.y,i.y,c),d=new Anchor(h,p,0,i.angleTo(n),r);return!s||zh(t,d,a,s,e)?d:void 0}l+=o}}function Oh(t,e,r,n,i,o,s,a,l){const u=Vh(n,o,s),c=Fh(n,i),h=c*s,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h<e/4&&(e=h+e/4),Uh(t,p?e/2*a%e:(c/2+2*o)*s*a%e,e,u,r,h,p,!1,l)}function Uh(t,e,r,n,i,o,s,a,l){const u=o/2,c=Lh(t);let h=0,p=e-r,d=[];for(let e=0;e<t.length-1;e++){const s=t[e],a=t[e+1],f=s.dist(a),y=a.angleTo(s);for(;p+r<h+f;){p+=r;const m=(p-h)/f,g=Vt(s.x,a.x,m),x=Vt(s.y,a.y,m);if(g>=0&&g<l&&x>=0&&x<l&&p-u>=0&&p+u<=c){const r=new Anchor(g,x,0,y,e);n&&!zh(t,r,o,n,i)||d.push(r)}}h+=f}return a||d.length||s||(d=Uh(t,h/2,r,n,i,o,s,!0,l)),d}function Nh(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,o=Math.max(o,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();e&&t<n.length&&(n[t]=e)}else e.h===r.h?(r.x+=e.w,r.w-=e.w):e.w===r.w?(r.y+=e.h,r.h-=e.h):(n.push({x:r.x+e.w,y:r.y,w:r.w-e.w,h:e.h}),r.y+=e.h,r.h-=e.h);break}}return{w:i,h:o,fill:e/(i*o)||0}}Yn(Anchor,"Anchor");const jh=1;class ImagePosition{static getImagePositionScale(t,e,r){if(e&&t){const{sx:e,sy:r}=t;return{x:e,y:r}}return{x:r,y:r}}constructor(t,e,r,n){this.paddedRect=t;const{pixelRatio:i,version:o,stretchX:s,stretchY:a,content:l,sdf:u,usvg:c}=e;this.pixelRatio=i,this.stretchX=s,this.stretchY=a,this.content=l,this.version=o,this.padding=r,this.sdf=u,this.usvg=c,this.scale=ImagePosition.getImagePositionScale(n,c,i)}get tl(){return[this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return[this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return[(this.paddedRect.w-2*this.padding)/this.scale.x,(this.paddedRect.h-2*this.padding)/this.scale.y]}}function Gh(t,e,r){const n=ImageVariant.parse(t),i=function(t,e,r=[1,1]){return{x:0,y:0,w:(t.data?t.data.width:t.width*r[0])+2*e,h:(t.data?t.data.height:t.height*r[1])+2*e}}(e,r,[n.sx,n.sy]);return{bin:i,imagePosition:new ImagePosition(i,e,r,n),imageVariant:n}}class ImageAtlas{constructor(t,e,r){const n=new Map,i=new Map;this.haveRenderCallbacks=[];const o=[];this.addImages(t,n,jh,o),this.addImages(e,i,2,o);const{w:s,h:a}=Nh(o),l=new RGBAImage({width:s||1,height:a||1});for(const[e,r]of t.entries()){const t=n.get(e).paddedRect;RGBAImage.copy(r.data,l,{x:0,y:0},{x:t.x+jh,y:t.y+jh},r.data,null,r.sdf)}for(const[t,n]of e.entries()){const e=i.get(t),o=e.paddedRect;let s=e.padding;const a=o.x+s,u=o.y+s,c=n.data.width,h=n.data.height;s=s>1?s-1:s,RGBAImage.copy(n.data,l,{x:0,y:0},{x:a,y:u},n.data,r),RGBAImage.copy(n.data,l,{x:0,y:h-s},{x:a,y:u-s},{width:c,height:s},r),RGBAImage.copy(n.data,l,{x:0,y:0},{x:a,y:u+h},{width:c,height:s},r),RGBAImage.copy(n.data,l,{x:c-s,y:0},{x:a-s,y:u},{width:s,height:h},r),RGBAImage.copy(n.data,l,{x:0,y:0},{x:a+c,y:u},{width:s,height:h},r),RGBAImage.copy(n.data,l,{x:c-s,y:h-s},{x:a-s,y:u-s},{width:s,height:s},r),RGBAImage.copy(n.data,l,{x:0,y:h-s},{x:a+c,y:u-s},{width:s,height:s},r),RGBAImage.copy(n.data,l,{x:0,y:0},{x:a+c,y:u+h},{width:s,height:s},r),RGBAImage.copy(n.data,l,{x:c-s,y:0},{x:a-s,y:u+h},{width:s,height:s},r)}this.lut=r,this.image=l,this.iconPositions=n,this.patternPositions=i}addImages(t,e,r,n){for(const[i,o]of t.entries()){const{bin:t,imagePosition:s,imageVariant:a}=Gh(i,o,r);e.set(i,s),n.push(t),o.hasRenderCallback&&this.haveRenderCallbacks.push(a.id)}}patchUpdatedImages(t,e,r){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,r))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const n of t.getUpdatedImages(r)){for(const i of this.iconPositions.keys()){const o=ImageVariant.parse(i);if(ImageId.isEqual(o.id,n)){const o=t.getImage(n,r);this.patchUpdatedImage(this.iconPositions.get(i),o,e,null)}}for(const i of this.patternPositions.keys()){const o=ImageVariant.parse(i);if(ImageId.isEqual(o.id,n)){const o=t.getImage(n,r);this.patchUpdatedImage(this.patternPositions.get(i),o,e,this.lut)}}}}patchUpdatedImage(t,e,r,n=null){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[i,o]=t.tl,s=t.sdf;if(this.lut||s){const t={width:e.data.width,height:e.data.height},a=new RGBAImage(t);RGBAImage.copy(e.data,a,{x:0,y:0},{x:0,y:0},t,n,s),r.update(a,{position:{x:i,y:o}})}else r.update(e.data,{position:{x:i,y:o}})}}Yn(ImagePosition,"ImagePosition"),Yn(ImageAtlas,"ImageAtlas");const $h=2,qh=jh;function Hh(t,e){return t+e[1]-e[0]}function Xh(t,e,r,n,i=1){const o=[],s=t.imagePrimary,a=s.pixelRatio,l=s.paddedRect.w-2*qh,u=s.paddedRect.h-2*qh,c=(t.right-t.left)*i,h=(t.bottom-t.top)*i,p=s.stretchX||[[0,l]],d=s.stretchY||[[0,u]],f=p.reduce(Hh,0),y=d.reduce(Hh,0),m=l-f,g=u-y;let x=0,v=f,b=0,w=y,_=0,A=m,S=0,I=g;if(s.content&&n){const t=s.content;x=Wh(p,0,t[0]),b=Wh(d,0,t[1]),v=Wh(p,t[0],t[2]),w=Wh(d,t[1],t[3]),_=t[0]-x,S=t[1]-b,A=t[2]-t[0]-v,I=t[3]-t[1]-w}const P=(n,o,l,u)=>{const p=Kh(n.stretch-x,v,c,t.left*i),d=Qh(n.fixed-_,A,n.stretch,f),m=Kh(o.stretch-b,w,h,t.top*i),g=Qh(o.fixed-S,I,o.stretch,y),P=Kh(l.stretch-x,v,c,t.left*i),M=Qh(l.fixed-_,A,l.stretch,f),D=Kh(u.stretch-b,w,h,t.top*i),E=Qh(u.fixed-S,I,u.stretch,y),C=new ot(p,m),B=new ot(P,m),T=new ot(P,D),k=new ot(p,D),z=new ot(d/a,g/a),L=new ot(M/a,E/a),V=e*Math.PI/180;if(V){const t=Math.sin(V),e=Math.cos(V),r=[e,-t,t,e];C._matMult(r),B._matMult(r),k._matMult(r),T._matMult(r)}const F=n.stretch+n.fixed,R=l.stretch+l.fixed,O=o.stretch+o.fixed,U=u.stretch+u.fixed,N=t.imageSecondary;return{tl:C,tr:B,bl:k,br:T,texPrimary:{x:s.paddedRect.x+qh+F,y:s.paddedRect.y+qh+O,w:R-F,h:U-O},texSecondary:N?{x:N.paddedRect.x+qh+F,y:N.paddedRect.y+qh+O,w:R-F,h:U-O}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:z,pixelOffsetBR:L,minFontScaleX:A/a/c,minFontScaleY:I/a/h,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=Yh(p,m,f),e=Yh(d,g,y);for(let r=0;r<t.length-1;r++){const n=t[r],i=t[r+1];for(let t=0;t<e.length-1;t++)o.push(P(n,e[t],i,e[t+1]))}}else o.push(P({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:u+1}));return o}function Zh(t,e){const r=t.stretchY||[[0,t.paddedRect.h-2*qh]];return e&&(t.stretchX||t.stretchY)?Jh(t.stretchX||[[0,t.paddedRect.w-2*qh]])*Jh(r):1}function Wh(t,e,r){let n=0;for(const i of t)n+=Math.max(e,Math.min(r,i[1]))-Math.max(e,Math.min(r,i[0]));return n}function Yh(t,e,r){const n=[{fixed:-qh,stretch:0}];for(const[e,r]of t){const t=n[n.length-1];n.push({fixed:e-t.stretch,stretch:t.stretch}),n.push({fixed:e-t.stretch,stretch:t.stretch+(r-e)})}return n.push({fixed:e+qh,stretch:r}),n}function Jh(t){return 2*t.length+1}function Kh(t,e,r,n){return t/e*r+n}function Qh(t,e,r,n){return t-e*r/n}function tp(t,e,r,n){const i=e+t.positionedLines[n].lineOffset;return 0===n?r+i/2:r+(i+(e+t.positionedLines[n-1].lineOffset))/2}function ep(t,e=1,r=!1){let n=1/0,i=1/0,o=-1/0,s=-1/0;const a=t[0];for(let t=0;t<a.length;t++){const e=a[t];(!t||e.x<n)&&(n=e.x),(!t||e.y<i)&&(i=e.y),(!t||e.x>o)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-i);let u=l/2;const c=new TinyQueue([],rp);if(0===l)return new ot(n,i);for(let e=n;e<o;e+=l)for(let r=i;r<s;r+=l)c.push(new Cell(e+u,r+u,u,t));let h=function(t){let e=0,r=0,n=0;const i=t[0];for(let t=0,o=i.length,s=o-1;t<o;s=t++){const o=i[t],a=i[s],l=o.x*a.y-a.x*o.y;r+=(o.x+a.x)*l,n+=(o.y+a.y)*l,e+=3*l}return new Cell(r/e,n/e,0,t)}(t),p=c.length;for(;c.length;){const n=c.pop();(n.d>h.d||!h.d)&&(h=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,p)),n.max-h.d<=e||(u=n.h/2,c.push(new Cell(n.p.x-u,n.p.y-u,u,t)),c.push(new Cell(n.p.x+u,n.p.y-u,u,t)),c.push(new Cell(n.p.x-u,n.p.y+u,u,t)),c.push(new Cell(n.p.x+u,n.p.y+u,u,t)),p+=4)}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${h.d}`)),h.p}function rp(t,e){return e.max-t.max}class Cell{constructor(t,e,r,n){this.p=new ot(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;i<e.length;i++){const o=e[i];for(let e=0,i=o.length,s=i-1;e<i;s=e++){const i=o[e],a=o[s];i.y>t.y!=a.y>t.y&&t.x<(a.x-i.x)*(t.y-i.y)/(a.y-i.y)+i.x&&(r=!r),n=Math.min(n,bs(t,i,a))}}return(r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}}const np=Object.keys,ip=7,op=Number.POSITIVE_INFINITY,sp=Math.sqrt(2),ap={MAX_GLYPHS:65535};function lp(t,e,r,n,i){const o=Sh(t)&&t.collisionPadding?t.collisionPadding:[0,0,0,0],s={top:t.top-o[1],bottom:t.bottom+o[3],left:t.left-o[0],right:t.right+o[2],scaled:!1};return void 0!==n&&function(t,e){t.top*=e,t.bottom*=e,t.left*=e,t.right*=e,t.scaled=!0}(s,n),r&&function(t,e){if(!e)return;const r=ut(e),n=new ot(t.left,t.top),i=new ot(t.right,t.top),o=new ot(t.left,t.bottom),s=new ot(t.right,t.bottom),a=new ot(0,0);n._rotateAround(r,a),i._rotateAround(r,a),o._rotateAround(r,a),s._rotateAround(r,a),t.left=Math.min(n.x,i.x,o.x,s.x),t.right=Math.max(n.x,i.x,o.x,s.x),t.top=Math.min(n.y,i.y,o.y,s.y),t.bottom=Math.max(n.y,i.y,o.y,s.y)}(s,r),i&&(s.left+=i[0],s.right+=i[0],s.top+=i[1],s.bottom+=i[1]),e?{top:Math.min(e.top,s.top),bottom:Math.max(e.bottom,s.bottom),left:Math.min(e.left,s.left),right:Math.max(e.right,s.right),scaled:e.scaled||s.scaled}:s}function up(t,[e,r]){let n=0,i=0;if(r===op){e<0&&(e=0);const r=e/sp;switch(t){case"top-right":case"top-left":i=r-ip;break;case"bottom-right":case"bottom-left":i=-r+ip;break;case"bottom":i=-e+ip;break;case"top":i=e-ip}switch(t){case"top-right":case"bottom-right":n=-r;break;case"top-left":case"bottom-left":n=r;break;case"left":n=e;break;case"right":n=-e}}else{switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-ip;break;case"bottom-right":case"bottom-left":case"bottom":i=-r+ip}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}}return[n,i]}function cp(t,e,r,n,i,o,s,a=1,l,u,c){t.createArrays(),t.tilePixelRatio=Ue/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const h=t.layers[0].layout,p=t.layers[0]._unevaluatedLayout._values,d={};d.scaleFactor=a,d.textSizeScaleRange=h.get("text-size-scale-range"),d.iconSizeScaleRange=h.get("icon-size-scale-range");const[f,y]=d.textSizeScaleRange,[m,g]=d.iconSizeScaleRange;d.textScaleFactor=ht(d.scaleFactor,f,y),d.iconScaleFactor=ht(d.scaleFactor,m,g);const x=p["text-size"],v=p["icon-size"];if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:r}=t.textSizeData;d.compositeTextSizes=[x.possiblyEvaluate(new EvaluationParameters(e,{worldview:c}),o),x.possiblyEvaluate(new EvaluationParameters(r,{worldview:c}),o)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:r}=t.iconSizeData;d.compositeIconSizes=[v.possiblyEvaluate(new EvaluationParameters(e,{worldview:c}),o),v.possiblyEvaluate(new EvaluationParameters(r,{worldview:c}),o)]}d.layoutTextSize=x.possiblyEvaluate(new EvaluationParameters(s+1,{worldview:c}),o),d.layoutIconSize=v.possiblyEvaluate(new EvaluationParameters(s+1,{worldview:c}),o),d.textMaxSize=x.possiblyEvaluate(new EvaluationParameters(18,{worldview:c}),o);const b=h.get("symbol-placement"),w="map"===h.get("text-rotation-alignment")&&"point"!==b,_=h.get("text-size");let A=!1;const S=[];for(const s of t.features){const a=h.get("text-font").evaluate(s,{},o).join(","),f=_.evaluate(s,{},o)*d.textScaleFactor,y=d.layoutTextSize.evaluate(s,{},o)*d.textScaleFactor,m=d.layoutIconSize.evaluate(s,{},o)*d.iconScaleFactor,g={horizontal:{},vertical:void 0},x=s.text;let v,I=[0,0];if(x){const n=x.toString(),u=h.get("text-letter-spacing").evaluate(s,{},o)*qc,c=h.get("text-line-height").evaluate(s,{},o)*qc,p=oi(n)?u:0,d=h.get("text-anchor").evaluate(s,{},o),m=h.get("text-variable-anchor");if(!m){const t=h.get("text-radial-offset").evaluate(s,{},o);if(t)I=up(d,[t*qc,op]);else{const t=h.get("text-offset").evaluate(s,{},o);I=[t[0]*qc,t[1]*qc]}}let v=w?"center":h.get("text-justify").evaluate(s,{},o);const _="point"===b,A=_?h.get("text-max-width").evaluate(s,{},o)*qc:1/0,S=o=>{t.allowVerticalPlacement&&ii(n)&&(g.vertical=fh(x,e,r,i,a,A,c,d,o,p,I,ph.vertical,!0,y,f,l))};if(!w&&m){const t="auto"===v?m.map((t=>_p(t))):[v];let n=!1;for(let o=0;o<t.length;o++){const s=t[o];if(!g.horizontal[s])if(n)g.horizontal[s]=g.horizontal[0];else{const t=fh(x,e,r,i,a,A,c,"center",s,p,I,ph.horizontal,!1,y,f,l);t&&(g.horizontal[s]=t,n=1===t.positionedLines.length)}}S("left")}else{if("auto"===v&&(v=_p(d)),_||h.get("text-writing-mode").indexOf("horizontal")>=0||!ii(n)){const t=fh(x,e,r,i,a,A,c,d,v,p,I,ph.horizontal,!1,y,f,l);t&&(g.horizontal[v]=t)}S(_?"left":v)}}let P,M,D,E,C,B,T=!1;const k=h.get("icon-text-fit").evaluate(s,{},o);if(s.icon&&s.icon.hasPrimary()){const e=mp(s.icon,t.iconSizeData,p["icon-size"],o,t.zoom,s,l,d.iconScaleFactor,c);P=e.iconPrimary,D=e.iconSecondary;const r=P.toString();if(M=n.get(r),M&&(C=h.get("icon-offset").evaluate(s,{},o),B=h.get("icon-anchor").evaluate(s,{},o),v=Ih(i.get(r),D?i.get(D.toString()):void 0,C,B),T=M.sdf,void 0===t.sdfIcons?t.sdfIcons=M.sdf:t.sdfIcons!==M.sdf&&vt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(M.pixelRatio!==t.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0)),D){const t=D.toString();E=n.get(t)}}A=A||!(!s.icon||!s.icon.hasSecondary());const z=Dp(g.horizontal)||g.vertical;t.iconsInText||(t.iconsInText=!!z&&z.iconsInText);const L=y*d.textScaleFactor/qc,{defaultShapedIcon:V,verticallyShapedIcon:F}=Ap(t,v,h,s,o,g,L,C,k);"none"!==k&&v&&(Mh(v)||Dh(v))&&(fp(0,M,P,v,V,k,u,n,i),fp(0,E,D,v,V,k,u,n,i),F&&(fp(0,M,P,v,F,k,u,n,i),fp(0,E,D,v,F,k,u,n,i))),v=V;const{iconBBox:R,iconVerticalBBox:O,textBBox:U,textVerticalBBox:N}=hp(t,v,F,h,s,o,m,C,d,i,B,g,y,I);S.push({feature:s,shapedTextOrientations:g,shapedText:z,shapedIcon:v,iconPrimary:P,iconSecondary:D,iconOffset:C,iconAnchor:B,verticallyShapedIcon:F,layoutTextSize:y,layoutIconSize:m,textOffset:I,isSDFIcon:T,iconTextFit:k,iconCollisionBounds:R,iconVerticalCollisionBounds:O,textCollisionBounds:U,textVerticalCollisionBounds:N})}return{featureData:S,sizes:d,hasAnySecondaryIcon:A,textAlongLine:w,symbolPlacement:b}}function hp(t,e,r,n,i,o,s,a,l,u,c,h,p,d){const f=t.layers[0],y=f.appearances;if(0===y.length)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const m={iconBBox:null,iconVerticalBBox:null},g={textBBox:null,textVerticalBBox:null},{baseIconRotate:x,baseTextRotate:v,iconScaleFactor:b}=function(t,e,r){const n=t.get("icon-rotate").evaluate(e,{},r),i=t.get("text-rotate").evaluate(e,{},r),[o,s]=t.get("icon-size-scale-range");return{baseIconRotate:n,baseTextRotate:i,iconScaleFactor:ht(1,o,s)}}(n,i,o);e&&(m.iconBBox=lp(e,m.iconBBox,x,s),r)&&(m.iconVerticalBBox=lp(r,m.iconVerticalBBox,x+90,s));const w=Dp(h.horizontal);w&&(g.textBBox=lp(w,g.textBBox,v,1,d)),h.vertical&&(g.textVerticalBBox=lp(h.vertical,g.textVerticalBBox,v+90,1,d));for(const r of y)r.hasIconProperties()&&pp(m,t,f,r,i,o,a,x,s,l,e,u,b,c),r.hasTextProperties()&&dp(g,f,r,i,o,d,v,p,w,h.vertical);return{iconBBox:m.iconBBox,iconVerticalBBox:m.iconVerticalBBox,textBBox:g.textBBox,textVerticalBBox:g.textVerticalBBox}}function pp(t,e,r,n,i,o,s,a,l,u,c,h,p,d){const{appearanceIconOffset:f,appearanceIconRotate:y,appearanceIconSize:m}=function(t,e,r,n,i,o,s,a){const l=t.hasProperty("icon-offset")?e.getAppearanceValueAndResolveTokens(t,"icon-offset",r,n,[]):null,u=l&&Array.isArray(l)?l:i,c=t.hasProperty("icon-rotate")?e.getAppearanceValueAndResolveTokens(t,"icon-rotate",r,n,[]):null,h="number"==typeof c?c:o,p=t.hasProperty("icon-size")?e.getAppearanceValueAndResolveTokens(t,"icon-size",r,n,[]):null;return{appearanceIconOffset:u,appearanceIconRotate:h,appearanceIconSize:"number"==typeof p?p*a.iconScaleFactor:s}}(n,r,i,o,s,a,l,u);let g=null,x=null,v=null;n.hasProperty("icon-image")?v=function(t,e,r,n,i,o,s){let a=null;const l=e.getAppearanceValueAndResolveTokens(r,"icon-image",n,i,[]);if(l){const e=t.getResolvedImageFromTokens(l),u=r.getUnevaluatedProperty("icon-size"),c=mp(e,Bh(t.zoom,u,t.worldview),u,i,t.zoom,n,t.pixelRatio,s,t.worldview);a=o.get(c.iconPrimary.toString())}return a}(e,r,n,i,o,h,p):c&&(v=c.imagePrimary),v&&(g=Ih(v,null,f,d),e.allowVerticalPlacement&&(x=Ih(v,null,f,d))),g&&(t.iconBBox=lp(g,t.iconBBox,y,m)),x&&(t.iconVerticalBBox=lp(x,t.iconVerticalBBox,y+90,m))}function dp(t,e,r,n,i,o,s,a,l,u){const{appearanceTextOffset:c,appearanceTextRotate:h,appearanceTextSize:p}=function(t,e,r,n,i,o,s){const a=t.hasProperty("text-offset")?e.getAppearanceValueAndResolveTokens(t,"text-offset",r,n,[]):null,l=a&&Array.isArray(a)?[a[0]*qc,a[1]*qc]:i,u=t.hasProperty("text-rotate")?e.getAppearanceValueAndResolveTokens(t,"text-rotate",r,n,[]):null,c="number"==typeof u?u:o,h=t.hasProperty("text-size")?e.getAppearanceValueAndResolveTokens(t,"text-size",r,n,[]):null;return{appearanceTextOffset:l,appearanceTextRotate:c,appearanceTextSize:"number"==typeof h?h:s}}(r,e,n,i,o,s,a),d=p/a;l&&(t.textBBox=lp(l,t.textBBox,h,d,c)),u&&(t.textVerticalBBox=lp(u,t.textVerticalBBox,h+90,d,c))}function fp(t,e,r,n,i,o,s,a,l){if(!e||!e.usvg)return;const u=Eh(n),c=Eh(i),h="both"!==o&&"width"!==o||!Mh(n)?1:c.width/u.width,p="both"!==o&&"height"!==o||!Dh(n)?1:c.height/u.height;r.scaleSelf(h,p);const d=r.toString();s.set(d,r),a.set(d,e);const{imagePosition:f}=Gh(d,e,jh);l.set(d,f)}function yp(t,e,r,n,i,o,s,a,l){if(!t)return;const u=function(t,e,r,n,i,o){if("camera"===t.kind)return t.maxSize;if("composite"===t.kind){const n=e.possiblyEvaluate(new EvaluationParameters(t.maxZoom,{worldview:o}),r).evaluate(i,{},r),s=e.possiblyEvaluate(new EvaluationParameters(t.minZoom,{worldview:o}),r).evaluate(i,{},r);return Math.max(n,s)}return e.possiblyEvaluate(new EvaluationParameters(n,{worldview:o})).evaluate(i,{},r)}(e,r,n,i,o,l);return t.scaleSelf(u*a*s)}function mp(t,e,r,n,i,o,s,a,l){return{iconPrimary:yp(t.getPrimary(),e,r,n,i,o,s,a,l),iconSecondary:yp(t.getSecondary(),e,r,n,i,o,s,a,l)}}function gp(t,e,r){if(!e)return;const n=r.get(t.toString()),i=r.get(e.toString());n&&i&&(n.paddedRect.w===i.paddedRect.w&&n.paddedRect.h===i.paddedRect.h||vt(`Mismatch in icon variant sizes: ${t.toString()} and ${e.toString()}`),n.usvg!==i.usvg&&vt(`Mismatch in icon variant image types: ${t.id} and ${e.id}`))}function xp(t,e,r,n,i,o,s,a,l,u){t.iconAtlasPositions=u.iconPositions;const{featureData:c,hasAnySecondaryIcon:h,sizes:p,textAlongLine:d,symbolPlacement:f}=e;for(const e of c){const{shapedIcon:r,verticallyShapedIcon:o,feature:c,shapedTextOrientations:y,shapedText:m,layoutTextSize:g,textOffset:x,isSDFIcon:v,iconPrimary:b,iconSecondary:w,iconTextFit:_,iconOffset:A,iconCollisionBounds:S,iconVerticalCollisionBounds:I,textCollisionBounds:P}=e;vp(r,u.iconPositions,b,w),vp(o,u.iconPositions,b,w),bp(y,u.iconPositions),gp(b,w,u.iconPositions),(m||r)&&Sp(t,c,y,r,o,l,p,g,0,x,v,n,i,s,a,h,_,A,d,f,S,I,P)}r&&t.generateCollisionDebugBuffers(o,t.collisionBoxArray,p.textScaleFactor)}function vp(t,e,r,n){if(!t)return;const i=e.get(r.toString());if(t.imagePrimary=i,n){const r=e.get(n.toString());t.imageSecondary=r}}function bp(t,e){for(const r in t.horizontal)wp(t.horizontal[r],e);wp(t.vertical,e)}function wp(t,e){if(t)for(const r of t.positionedLines)for(const t of r.positionedGlyphs)if(null!==t.image){const r=t.image.toString();t.rect=e.get(r).paddedRect}}function _p(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Ap(t,e,r,n,i,o,s,a,l){const u=Dp(o.horizontal)||o.vertical,c=r.get("icon-text-fit-padding").evaluate(n,{},i);let h,p=e;return e&&"none"!==l&&(t.allowVerticalPlacement&&o.vertical&&(h=Ph(e,o.vertical,l,c,a,s)),u&&(p=Ph(e,u,l,c,a,s))),{defaultShapedIcon:p,verticallyShapedIcon:h}}function Sp(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g,x,v,b,w,_,A){let S=s.textMaxSize.evaluate(e,{},p);void 0===S?S=a*s.textScaleFactor:S*=s.textScaleFactor;const I=t.layers[0].layout,P=qc,M=a*s.textScaleFactor/P,D=Dp(r.horizontal)||r.vertical;if("none"!==m&&t.appearanceFeatureData&&e.index<t.appearanceFeatureData.length){const r=t.appearanceFeatureData[e.index];r&&(r.textShaping=D,r.iconTextFitPadding=I.get("icon-text-fit-padding").evaluate(e,{},p),r.fontScale=M)}const E="globe"===d.name,C=t.tilePixelRatio*S/P,B=(F=t.overscaling,t.zoom>18&&F>2&&(F>>=1),Math.max(Ue/(512*F),1)*I.get("symbol-spacing")),T=I.get("text-padding")*t.tilePixelRatio,k=I.get("icon-padding")*t.tilePixelRatio,z=ut(I.get("text-max-angle")),L="map"===I.get("icon-rotation-alignment")&&"point"!==v,V=B/2;var F;!1===t.hasAnyIconTextFit&&"none"!==m&&(t.hasAnyIconTextFit=!0);const R=e.properties?+e.properties[ns]:null,O=R&&t.elevationFeatureIdToIndex?t.elevationFeatureIdToIndex.get(R):65535,U=(a,l,v)=>{if(l.x<0||l.x>=Ue||l.y<0||l.y>=Ue)return;let A=null;if(E){const{x:t,y:e,z:r}=d.projectTilePoint(l.x,l.y,v);A={anchor:new Anchor(t,e,r,0,void 0),up:d.upVector(v,l.x,l.y)}}!function(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g,x,v,b,w,_,A,S,I,P,M,D,E,C,B,T){const k=t.addToLineVertexArray(e,n);let z,L,V,F,R,O,U,N=0,j=0,G=0,$=0,q=-1,H=-1;const X={};let Z=co("");const W=r?r.anchor:e,Y="none"!==M;let J=0,K=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const t=l.layout.get("text-offset").evaluate(b,{},S);J=t[0]*qc,K=t[1]*qc}else J=l.layout.get("text-radial-offset").evaluate(b,{},S)*qc,K=op;if(t.allowVerticalPlacement&&i.vertical){const t=i.vertical;if(f)O=Cp(t),a&&(U=Cp(a));else{const r=l.layout.get("text-rotate").evaluate(b,{},S)+90;V=Ep(u,W,e,c,h,p,t,d,r,y,B),a&&(F=Ep(u,W,e,c,h,p,a,g,r,null,C))}}if(o){const n=t.iconSizeData,i=l.layout.get("icon-rotate").evaluate(b,{},S),s=Xh(o,i,_,Y,w.iconScaleFactor),d=a?Xh(a,i,_,Y,w.iconScaleFactor):void 0;L=Ep(u,W,e,c,h,p,o,g,i,null,E);const f=function(t,e,r,n,i,o,s,a){const l=t.layers[0],u=l.appearances;let c=e.length;if(r&&(c=Math.max(c,r.length)),0===u.length)return c;const[h,p]=n.get("icon-size-scale-range"),d=ht(1,h,p);for(const e of u){const r=e.getUnevaluatedProperties();if(void 0!==r._values["icon-image"].value){const n=l.getAppearanceValueAndResolveTokens(e,"icon-image",i,o,[]);if(n){const e=t.getResolvedImageFromTokens(n);if(e){const n=r._values["icon-size"],l=mp(e,Bh(t.zoom,n,t.worldview),n,o,t.zoom,i,t.pixelRatio,d,t.worldview),u=s.get(l.iconPrimary.toString());c=Math.max(c,Zh(u,a))}}}}return c}(t,s,d,l.layout,b,S,t.iconAtlasPositions,Y);N=4*f;let y=null;"source"===n.kind?(y=[Ch*l.layout.get("icon-size").evaluate(b,{},S)*w.iconScaleFactor],y[0]>Pp&&vt(`${t.layerIds[0]}: Value for "icon-size" is >= ${Ip}. Reduce your "icon-size".`)):"composite"===n.kind&&(y=[Ch*w.compositeIconSizes[0].evaluate(b,{},S)*w.iconScaleFactor,Ch*w.compositeIconSizes[1].evaluate(b,{},S)*w.iconScaleFactor],(y[0]>Pp||y[1]>Pp)&&vt(`${t.layerIds[0]}: Value for "icon-size" is >= ${Ip}. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,y,v,x,b,void 0,r,e,k.lineStartIndex,k.lineLength,-1,A,S,I,P,t.symbolInstances.length,f),q=t.icon.placedSymbolArray.length-1,d&&(j=4*f,t.addSymbols(t.icon,d,y,v,x,b,ph.vertical,r,e,k.lineStartIndex,k.lineLength,-1,A,S,I,P,t.symbolInstances.length,f),H=t.icon.placedSymbolArray.length-1)}for(const n in i.horizontal){const o=n,a=i.horizontal[o];z||(Z=co(a.text),f?R=Cp(a):z=Ep(u,W,e,c,h,p,a,d,l.layout.get("text-rotate").evaluate(b,{},S),y,B));const m=1===a.positionedLines.length;if(G+=Mp(t,r,e,a,s,l,f,b,y,k,i.vertical?ph.horizontal:ph.horizontalOnly,m?np(i.horizontal):[o],X,q,w,A,S,t.symbolInstances.length,I),m)break}i.vertical&&($+=Mp(t,r,e,i.vertical,s,l,f,b,y,k,ph.vertical,["vertical"],X,H,w,A,S,t.symbolInstances.length,I));let Q=-1;const tt=(t,e)=>t?Math.max(t,e):e;Q=tt(R,Q),Q=tt(O,Q),Q=tt(U,Q);const et=Q>-1?1:0;t.glyphOffsetArray.length>=ap.MAX_GLYPHS&&vt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,b.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,W.x,W.y,W.z,X.right>=0?X.right:-1,X.center>=0?X.center:-1,X.left>=0?X.left:-1,X.vertical>=0?X.vertical:-1,q,H,Z,void 0!==z?z:t.collisionBoxArray.length,void 0!==z?z+1:t.collisionBoxArray.length,void 0!==V?V:t.collisionBoxArray.length,void 0!==V?V+1:t.collisionBoxArray.length,void 0!==L?L:t.collisionBoxArray.length,void 0!==L?L+1:t.collisionBoxArray.length,F||t.collisionBoxArray.length,F?F+1:t.collisionBoxArray.length,c,G,$,N,j,et,0,J,K,Q,0,Y?1:0,D)}(t,l,A,a,r,n,o,i,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,T,x,u,0,k,L,g,e,s,c,h,p,f,y,m,O,b,w,_)};if("line"===v)for(const i of ql(e.geometry,0,0,Ue,Ue)){const e=Oh(i,B,z,r.vertical||D,n,P,C,t.overscaling,Ue);for(const r of e)D&&Bp(t,D.text,V,r)||U(i,r,p)}else if("line-center"===v){for(const t of e.geometry)if(t.length>1){const e=Rh(t,z,r.vertical||D,n,P,C);e&&U(t,e,p)}}else if("Polygon"===e.type)for(const t of ka(e.geometry,0)){const e=ep(t,16);U(t[0],new Anchor(e.x,e.y,0,0,void 0),p)}else if("LineString"===e.type)for(const t of e.geometry)U(t,new Anchor(t[0].x,t[0].y,0,0,void 0),p);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)U([e],new Anchor(e.x,e.y,0,0,void 0),p)}const Ip=255,Pp=Ip*Ch;function Mp(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g,x){const v=function(t,e,r,n,i,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const u=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=function(t){const e=t[0],r=t[1],n=e*r;return n>0?[e,-r]:n<0?[-e,r]:0===e?[r,e]:[r,-e]}(r);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const p=e.positionedLines.length,d=h/p;let f=e.top-r[1];for(let t=0;t<p;++t){const n=e.positionedLines[t];f=tp(e,d,f,t);for(const t of n.positionedGlyphs){if(!t.rect)continue;const n=t.rect||{};let o=hh+1,h=!0,p=1,d=0;if(t.image){const e=s.get(t.image.toString());if(!e)continue;if(e.sdf){vt("SDF images are not supported in formatted text and will be ignored.");continue}h=!1,p=e.pixelRatio,o=jh/p}const y=(i||a)&&t.vertical,m=t.metrics.advance*t.scale/2,g=t.metrics,x=t.rect;if(null===x)continue;a&&e.verticalizable&&(d=t.image?m-t.metrics.width*t.scale/2:0);const v=i?[t.x+m,t.y]:[0,0];let b=[0,0],w=[0,0],_=!1;i||(y?(w=[t.x+m+c[0],t.y+c[1]-d],_=!0):b=[t.x+m+r[0],t.y+r[1]-d]);const A=x.w*t.scale/(p*(t.localGlyph?$h:1)),S=x.h*t.scale/(p*(t.localGlyph?$h:1));let I,P,M,D;if(y){const e=t.y-f,r=new ot(-m,m-e),n=-Math.PI/2,i=new ot(...w);I=new ot(-m+b[0],b[1]),I._rotateAround(n,r)._add(i),I.x+=-e+m,I.y-=(g.left-o)*t.scale;const s=t.image?g.advance*t.scale:qc*t.scale,a=String.fromCodePoint(t.glyph);Zc(a)?I.x+=(1-o)*t.scale:Wc(a)?I.x+=s-g.height*t.scale+(-o-1)*t.scale:I.x+=t.image||g.width+2*o===x.w&&g.height+2*o===x.h?(s-S)/2:(s-(g.height+2*o)*t.scale)/2,P=new ot(I.x,I.y-A),M=new ot(I.x+S,I.y),D=new ot(I.x+S,I.y-A)}else{const e=(g.left-o)*t.scale-m+b[0],r=(-g.top-o)*t.scale+b[1],n=e+A,i=r+S;I=new ot(e,r),P=new ot(n,r),M=new ot(e,i),D=new ot(n,i)}if(u){let t;t=i?new ot(0,0):_?new ot(c[0],c[1]):new ot(r[0],r[1]),I._rotateAround(u,t),P._rotateAround(u,t),M._rotateAround(u,t),D._rotateAround(u,t)}const E=new ot(0,0),C=new ot(0,0);l.push({tl:I,tr:P,bl:M,br:D,texPrimary:n,texSecondary:void 0,writingMode:e.writingMode,glyphOffset:v,sectionIndex:t.sectionIndex,isSDF:h,pixelOffsetTL:E,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0})}}return l}(0,n,l,o,s,a,i,t.allowVerticalPlacement),b=t.textSizeData;let w=null;"source"===b.kind?(w=[Ch*o.layout.get("text-size").evaluate(a,{},m)*f.textScaleFactor],w[0]>Pp&&vt(`${t.layerIds[0]}: Value for "text-size" is >= ${Ip}. Reduce your "text-size".`)):"composite"===b.kind&&(w=[Ch*f.compositeTextSizes[0].evaluate(a,{},m)*f.textScaleFactor,Ch*f.compositeTextSizes[1].evaluate(a,{},m)*f.textScaleFactor],(w[0]>Pp||w[1]>Pp)&&vt(`${t.layerIds[0]}: Value for "text-size" is >= ${Ip}. Reduce your "text-size".`)),t.addSymbols(t.text,v,w,l,s,a,c,e,r,u.lineStartIndex,u.lineLength,d,y,m,x,!1,g,v.length);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*v.length}function Dp(t){for(const e in t)return t[e];return null}function Ep(t,e,r,n,i,o,s,a,l,u,c){let h,p,d,f;if(h=c?c.top:s.top,p=c?c.bottom:s.bottom,d=c?c.left:s.left,f=c?c.right:s.right,Sh(s)&&s.collisionPadding){const t=s.collisionPadding;d-=t[0],h-=t[1],f+=t[2],p+=t[3]}if(l){const t=new ot(d,h),e=new ot(f,h),r=new ot(d,p),n=new ot(f,p),i=ut(l);let o=new ot(0,0);u&&(o=new ot(u[0],u[1])),t._rotateAround(i,o),e._rotateAround(i,o),r._rotateAround(i,o),n._rotateAround(i,o),d=Math.min(t.x,e.x,r.x,n.x),f=Math.max(t.x,e.x,r.x,n.x),h=Math.min(t.y,e.y,r.y,n.y),p=Math.max(t.y,e.y,r.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,d,h,f,p,a,n,i,o),t.length-1}function Cp(t){Sh(t)&&t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Bp(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])<r)return!0}else i[e]=[];return i[e].push(n),!1}function Tp(t,e){const r=t.fovAboveCenter,n=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,i=(t._camera.position[2]*t.worldSize-n)/Math.cos(t._pitch),o=Math.sin(r)*i/Math.sin(Math.max(Math.PI/2-t._pitch-r,.01));let s=Math.sin(t._pitch)*o+i;const a=i*(1/t._horizonShift);if(!t.elevation||0===t.elevation.exaggeration()){let e=Math.max(t.zoom-17,0);t.isOrthographic&&(e/=10),s*=1+e}return Math.min(1.01*s,a)}function kp(t,e){if(!e.isReprojectedInTileSpace)return{scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:e};const r=Math.pow(2,-t.z),n=t.x*r,i=(t.x+1)*r,o=t.y*r,s=(t.y+1)*r,a=Ro(n),l=Ro(i),u=Oo(o),c=Oo(s),h=e.project(a,u),p=e.project(l,u),d=e.project(l,c),f=e.project(a,c);let y=Math.min(h.x,p.x,d.x,f.x),m=Math.min(h.y,p.y,d.y,f.y),g=Math.max(h.x,p.x,d.x,f.x),x=Math.max(h.y,p.y,d.y,f.y);const v=r/16;function b(t,r,n,i,o,s){const a=(n+o)/2,l=(i+s)/2,u=e.project(Ro(a),Oo(l)),c=Math.max(0,y-u.x,m-u.y,u.x-g,u.y-x);y=Math.min(y,u.x),g=Math.max(g,u.x),m=Math.min(m,u.y),x=Math.max(x,u.y),c>v&&(b(t,u,n,i,a,l),b(u,r,a,l,o,s))}b(h,p,n,o,i,o),b(p,d,i,o,i,s),b(d,f,i,s,n,s),b(f,h,n,s,n,o),y-=v,m-=v,g+=v,x+=v;const w=1/Math.max(g-y,x-m);return{scale:w,x:y*w,y:m*w,x2:g*w,y2:x*w,projection:e}}const zp=o(new Float32Array(16));class Projection{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new LngLat(0,0)}projectTilePoint(t,e,r){return{x:t,y:e,z:0}}locationPoint(t,e,r,n=!0){return t._coordinatePoint(t.locationCoordinate(e,r),n)}pixelsPerMeter(t,e){return Fo(1,t)*e}pixelSpaceConversion(t,e,r){return 1}farthestPixelDistance(t){return Tp(t,t.pixelsPerMeter)}pointCoordinate(t,e,r,n){const i=t.horizonLineFromTop(!1),o=new ot(e,Math.max(i,r));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,r){const n=new ot(e,r);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(t,e.x,e.y);const r=t.horizonLineFromTop();return e.y<r}createInversionMatrix(t,e){return zp}createTileMatrix(t,e,r){let n,i,s;const a=r.canonical,c=o(new Float64Array(16));if(this.isReprojectedInTileSpace){const o=kp(a,this);n=1,i=o.x+r.wrap*o.scale,s=o.y,u(c,c,[n/o.scale,n/o.scale,t.pixelsPerMeter/e])}else n=e/t.zoomScale(a.z),i=(a.x+Math.pow(2,a.z)*r.wrap)*n,s=a.y*n;return l(c,c,[i,s,0]),u(c,c,[n/Ue,n/Ue,1]),c}upVector(t,e,r){return[0,0,1]}upVectorScale(t,e,r){return{metersToTile:1}}}class Albers extends Projection{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];const[e,r]=this.parallels=t.parallels||[29.5,45.5],n=Math.sin(ut(e));this.n=(n+Math.sin(ut(r)))/2,this.c=1+n*(2*this.n-n),this.r0=Math.sqrt(this.c)/this.n}project(t,e){const{n:r,c:n,r0:i}=this,o=ut(t-this.center[0]),s=ut(e),a=Math.sqrt(n-2*r*Math.sin(s))/r;return{x:a*Math.sin(o*r),y:a*Math.cos(o*r)-i,z:0}}unproject(t,e){const{n:r,c:n,r0:i}=this,o=i+e;let s=Math.atan2(t,Math.abs(o))*Math.sign(o);o*r<0&&(s-=Math.PI*Math.sign(t)*Math.sign(o));const a=ut(this.center[0])*r;s=dt(s,-Math.PI-a,Math.PI-a);const l=ht(ct(s/r)+this.center[0],-180,180),u=Math.asin(ht((n-(t*t+o*o)*r*r)/(2*r),-1,1)),c=ht(ct(u),-Uo,Uo);return new LngLat(l,c)}}const Lp=1.340264,Vp=-.081106,Fp=893e-6,Rp=.003796,Op=Math.sqrt(3)/2;class EqualEarth extends Projection{project(t,e){e=e/180*Math.PI,t=t/180*Math.PI;const r=Math.asin(Op*Math.sin(e)),n=r*r,i=n*n*n;return{x:.5*(t*Math.cos(r)/(Op*(Lp+3*Vp*n+i*(7*Fp+9*Rp*n)))/Math.PI+.5),y:1-.5*(r*(Lp+Vp*n+i*(Fp+Rp*n))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=r*r,i=n*n*n;for(let t,o,s,a=0;a<12&&(o=r*(Lp+Vp*n+i*(Fp+Rp*n))-e,s=Lp+3*Vp*n+i*(7*Fp+9*Rp*n),t=o/s,r=ht(r-t,-Math.PI/3,Math.PI/3),n=r*r,i=n*n*n,!(Math.abs(t)<1e-12));++a);const o=Op*t*(Lp+3*Vp*n+i*(7*Fp+9*Rp*n))/Math.cos(r),s=Math.asin(Math.sin(r)/Op),a=ht(180*o/Math.PI,-180,180),l=ht(180*s/Math.PI,-Uo,Uo);return new LngLat(a,l)}}class Equirectangular extends Projection{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){return{x:.5+t/360,y:.5-e/360,z:0}}unproject(t,e){const r=360*(t-.5),n=ht(360*(.5-e),-Uo,Uo);return new LngLat(r,n)}}const Up=Math.PI/2;function Np(t){return Math.tan((Up+t)/2)}class LambertConformalConic extends Projection{constructor(t){super(t),this.center=t.center||[0,30];const[e,r]=this.parallels=t.parallels||[30,30];let n=ut(e),i=ut(r);this.southernCenter=n+i<0,this.southernCenter&&(n=-n,i=-i);const o=Math.cos(n),s=Np(n);this.n=n===i?Math.sin(n):Math.log(o/Math.cos(i))/Math.log(Np(i)/s),this.f=o*Math.pow(Np(n),this.n)/this.n}project(t,e){e=ut(e),this.southernCenter&&(e=-e),t=ut(t-this.center[0]);const r=1e-6,{n,f:i}=this;i>0?e<-Up+r&&(e=-Up+r):e>Up-r&&(e=Up-r);const o=i/Math.pow(Np(e),n);let s=o*Math.sin(n*t),a=i-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:r,f:n}=this,i=n-e,o=Math.sign(i),s=Math.sign(r)*Math.sqrt(t*t+i*i);let a=Math.atan2(t,Math.abs(i))*o;i*r<0&&(a-=Math.PI*Math.sign(t)*o);const l=ht(ct(a/r)+this.center[0],-180,180),u=ht(ct(2*Math.atan(Math.pow(n/s,1/r))-Up),-Uo,Uo);return new LngLat(l,this.southernCenter?-u:u)}}class Mercator extends Projection{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,e){return{x:Lo(t),y:Vo(e),z:0}}unproject(t,e){const r=Ro(t),n=Oo(e);return new LngLat(r,n)}}const jp=ut(Uo);class NaturalEarth extends Projection{project(t,e){const r=(e=ut(e))*e,n=r*r;return{x:.5*((t=ut(t))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=25,i=0,o=r*r;do{o=r*r;const t=o*o;i=(r*(1.007226+o*(.015085+t*(.028874*o-.044475-.005916*t)))-e)/(1.007226+o*(.045255+t*(.259866*o-.311325-.005916*11*t))),r=ht(r-i,-jp,jp)}while(Math.abs(i)>1e-6&&--n>0);o=r*r;const s=ht(ct(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=ct(r);return new LngLat(s,a)}}const Gp=ut(Uo);class WinkelTripel extends Projection{project(t,e){e=ut(e),t=ut(t);const r=Math.cos(e),n=2/Math.PI,i=Math.acos(r*Math.cos(t/2)),o=Math.sin(i)/i,s=.5*(t*n+2*r*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let r=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,i=25;const o=1e-6;let s=0,a=0;do{const i=Math.cos(n),o=Math.sin(n),l=2*o*i,u=o*o,c=i*i,h=Math.cos(r/2),p=Math.sin(r/2),d=2*h*p,f=p*p,y=1-c*h*h,m=y?1/y:0,g=y?Math.acos(i*h)*Math.sqrt(1/y):0,x=.5*(2*g*i*p+2*r/Math.PI)-t,v=.5*(g*o+n)-e,b=.5*m*(c*f+g*i*h*u)+1/Math.PI,w=m*(d*l/4-g*o*p),_=.125*m*(l*p-g*o*c*d),A=.5*m*(u*h+g*f*i)+.5,S=w*_-A*b;s=(v*w-x*A)/S,a=(x*_-v*b)/S,r=ht(r-s,-Math.PI,Math.PI),n=ht(n-a,-Gp,Gp)}while((Math.abs(s)>o||Math.abs(a)>o)&&--i>0);return new LngLat(ct(r),ct(n))}}class CylindricalEqualArea extends Projection{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(ut(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:r,cosPhi:n}=this;return{x:ut(t)*n*r+.5,y:-Math.sin(ut(e))/n*r+.5,z:0}}unproject(t,e){const{scale:r,cosPhi:n}=this,i=-(e-.5)/r,o=ht(ct((t-.5)/r)/n,-180,180),s=Math.asin(ht(i*n,-1,1)),a=ht(ct(s),-Uo,Uo);return new LngLat(o,a)}}class Globe extends Mercator{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,r){const n=Rs(t,e,r);return B(n,n,Ns(Vs(r))),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e,r){const n=Eo(e.lat,e.lng),i=M([],n),s=r?t._centerAltitude+r:t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;A(n,n,i,Fo(1,0)*Ue*s);const l=o(new Float64Array(16));return a(l,t.pixelMatrix,t.globeMatrix),B(n,n,l),new ot(n[0],n[1])}pixelsPerMeter(t,e){return Fo(1,0)*e}pixelSpaceConversion(t,e,r){const n=Fo(1,t)*e,i=Vt(Fo(1,45)*e,n,r);return this.pixelsPerMeter(t,e)/i}createTileMatrix(t,e,r){const n=function(t){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(Us,t.min),r=1/Os(t);return u(e,e,[r,r,r])}(Vs(r.canonical));return a(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:r}=t,n=Ns(Vs(e));return h(n,n,ut(r.lng)),c(n,n,ut(r.lat)),u(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,r,n){return Ls(t,e,r,!0)||new MercatorCoordinate(0,0)}pointCoordinate3D(t,e,r){const n=this.pointCoordinate(t,e,r,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!Ls(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const r=t.cameraToCenterDistance,n=t._centerAltitude*e,i=t._camera,o=t._camera.forward(),s=x([],_([],o,-r),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],u=t.width/t.height,c=Math.tan(t.fovAboveCenter),h=_([],i.up(),c),p=_([],i.right(),c*u),d=M([],x([],x([],o,h),p)),f=[];let m;if(new Ray(s,d).closestPointOnSphere(l,a,f)){const e=x([],f,l),r=L([],e,s);m=Math.cos(t.fovAboveCenter)*y(r)}else{const t=L([],s,l),e=L([],l,s);M(e,e);const r=y(t)-a;m=Math.sqrt(r*(r+2*a));const n=Math.acos(m/(a+r))-Math.acos(D(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),r=Gs(t.zoom);if(r>0){const n=Tp(t,Fo(1,t.center.lat)*t.worldSize),i=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Vt(e,n+i*(1-Math.cos(o)),Math.pow(r,10))}return e}upVector(t,e,r){return Rs(e,r,t,1)}upVectorScale(t){return{metersToTile:(e=Os(Vs(t)),e*_o/Co)};var e}}function $p(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new Mercator(t);case"equirectangular":return new Equirectangular(t);case"naturalEarth":return new NaturalEarth(t);case"equalEarth":return new EqualEarth(t);case"winkelTripel":return new WinkelTripel(t);case"albers":return r?new CylindricalEqualArea(t):new Albers(t);case"lambertConformalConic":return r?new CylindricalEqualArea(t):new LambertConformalConic(t);case"globe":return new Globe(t)}throw new Error(`Invalid projection name: ${t.name}`)}const qp=VectorTileFeature.types,Hp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Xp(t,e,r,n,i,o,s,a,l,u,c,h,p){const d=a?Math.min(Pp,Math.round(a[0])):0,f=a?Math.min(Pp,Math.round(a[1])):0;t.emplaceBack(e,r,Math.round(32*n),Math.round(32*i),o,s,(d<<1)+(l?1:0),0+(f<<1),16*u,16*c,256*h,256*p)}function Zp(t,e,r){t.emplaceBack(e,r)}function Wp(t,e,r,n,i,o,s){t.emplaceBack(e,r,n,i,o,s)}const Yp=(t,e,r,n)=>{for(let i=0;i<e;i++)t.emplaceBack(r[0],r[1],r[2],n[0],n[1],n[2])};function Jp(t,e,r,n,i){t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i)}function Kp(t){for(const e of t.sections)if(pi(e.text))return!0;return!1}class SymbolBuffers{constructor(t){this.layoutVertexArray=new StructArrayLayout4i4ui4i24,this.indexArray=new StructArrayLayout3ui6,this.programConfigurations=t,this.segments=new SegmentVector,this.dynamicLayoutVertexArray=new StructArrayLayout4f16,this.opacityVertexArray=new StructArrayLayout1ul4,this.placedSymbolArray=new PlacedSymbolArray,this.iconTransitioningVertexArray=new StructArrayLayout2ui4,this.globeExtVertexArray=new StructArrayLayout3i3f20,this.zOffsetVertexArray=new StructArrayLayout1f4,this.orientationVertexArray=new StructArrayLayout6f24,this.symbolInstanceIndices=[]}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}getIconVertexData(t,e){const r=[],n=this.layoutVertexArray.uint16;for(let i=0;i<e;++i){const e=12*(t+i);r.push(...n.slice(e,e+12))}return r}updateIconVertexData(t,e,r,n,i,o,s,a,l,u,c,h,p){const d=this.layoutVertexArray.uint16,f=12*t;d[f]=e,d[f+1]=r,d[f+2]=n,d[f+3]=i,d[f+4]=o,d[f+5]=s,d[f+6]=a,d[f+7]=l,d[f+8]=u,d[f+9]=c,d[f+10]=h,d[f+11]=p}upload(t,e,r,n,i,o){this.isEmpty()||(r&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Vc.members,!!o),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Rc.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Hp,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Nc.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Fc.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Oc.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=t.createVertexBuffer(this.orientationVertexArray,Uc.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}Yn(SymbolBuffers,"SymbolBuffers");class CollisionBuffers{constructor(t,e,r){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new r,this.segments=new SegmentVector,this.collisionVertexArray=new StructArrayLayout2ub4f20,this.collisionVertexArrayExt=new StructArrayLayout4f16}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,jc.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Gc.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Yn(CollisionBuffers,"CollisionBuffers");class SymbolBucket{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=o([]),this.placementViewportMatrix=o([]);const e=this.layers[0]._unevaluatedLayout._values;this.worldview=t.worldview,this.localizable=t.localizable,this.textSizeData=Bh(this.zoom,e["text-size"],this.worldview),this.iconSizeData=Bh(this.zoom,e["icon-size"],this.worldview);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");this.lut=t.lut,this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map((t=>ph[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.lastActiveApperance=null,this.featureToAppearanceIndex={}}hasAnyAppearanceProperty(t){const e=this.layers[0].getAppearances();return!(!e||0===e.length)&&e.some((e=>null!=e.getProperty(t)))}createArrays(){this.text=new SymbolBuffers(new ProgramConfigurationSet(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new SymbolBuffers(new ProgramConfigurationSet(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new GlyphOffsetArray,this.lineVertexArray=new SymbolLineVertexArray,this.symbolInstances=new SymbolInstanceArray}calculateGlyphDependencies(t,e,r,n,i){for(const r of t){const t=r.codePointAt(0);if(void 0===t)break;if(e[t]=!0,n&&i&&t<=65535){const t=Xc[r];t&&(e[t.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(t,e,r,n,i,o){let s=1;const a=t.getUnevaluatedProperties()._values["icon-size"],l=Bh(this.zoom,a,this.worldview),u=kh(l,e);if("constant"!==l.kind&&"camera"!==l.kind||(s=u.uSize),"composite"===l.kind){const{minZoom:t,maxZoom:e}=l,o=a.possiblyEvaluate(new EvaluationParameters(t,{worldview:this.worldview}),n),c=a.possiblyEvaluate(new EvaluationParameters(e,{worldview:this.worldview}),n),h=o.evaluate(r,{},n,i);s=h+(c.evaluate(r,{},n,i)-h)*u.uSizeT}return"source"===l.kind&&(s=a.possiblyEvaluate(new EvaluationParameters(this.zoom,{worldview:this.worldview}),n).evaluate(r,{},n,i)),s*o}updateFootprints(t,e){}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);return!cl(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}getResolvedImageFromTokens(t){return"string"==typeof t?ResolvedImage.build(t):t}populate(t,e,r,n){const i=this.layers[0],o=i.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),u=o.get("icon-image"),[c,h]=o.get("icon-size-scale-range"),p=ht(e.scaleFactor||1,c,h),d=("constant"!==l.value.kind||l.value.value instanceof Formatted&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),f="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,y=this.hasAnyAppearanceProperty("icon-image"),m=o.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!d&&!f&&!y)return;const g=e.iconDependencies,x=e.glyphDependencies,v=e.availableImages,b=new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:e.activeFloors}),w=t=>{const e=t.id.toString();g.has(e)?g.get(e).push(t):g.set(e,[t])};for(const e of t){const{feature:t,id:l,index:u,sourceLayerIndex:c}=e,h=i._featureFilter.needGeometry,_=Ko(t,h);if(!i._featureFilter.filter(b,_,r))continue;if(h||(_.geometry=Jo(t,r,n)),s&&1!==t.type&&r.z<=5){const t=_.geometry,e=.98078528056,n=(t,n)=>D(Rs(t.x,t.y,r,1),Rs(n.x,n.y,r,1))<e;for(let e=0;e<t.length;e++)t[e]=Xo(t[e],n)}let A,S;if(d){const t=i.getValueAndResolveTokens("text-field",_,r,v),e=Formatted.factory(t);Kp(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Ai||this.hasRTLText&&Ii.isParsed())&&(A=Hc(e,i,_))}if(f){const t=i.getValueAndResolveTokens("icon-image",_,r,v);S=this.getResolvedImageFromTokens(t)}const I=this.layers[0];let P=!1;if(!S&&y){const t=I.getAppearances();for(const e of t)if(e.getProperty("icon-image")){const t=I.getAppearanceValueAndResolveTokens(e,"icon-image",_,r,v);if(t){S=this.getResolvedImageFromTokens(t),P=!0;break}}}if(!A&&!S)continue;const M=this.sortFeaturesByKey?m.evaluate(_,{},r):void 0,E={id:l,text:A,icon:S,index:u,sourceLayerIndex:c,geometry:_.geometry,properties:t.properties,type:qp[t.type],sortKey:M};if(this.features.push(E),this.featureToAppearanceIndex[u]=this.appearanceFeatureData.length,this.appearanceFeatureData.push({id:l,properties:t.properties,usesAppearanceIconAsPlaceholder:P,isUsingAppearanceVertexData:!1,layoutBasedVertexData:[],activeAppearance:null}),S){const t=I._unevaluatedLayout._values,{iconPrimary:e,iconSecondary:n}=mp(S,this.iconSizeData,t["icon-size"],r,this.zoom,E,this.pixelRatio,p,this.worldview);w(e),n&&(this.hasAnySecondaryIcon=!0,w(n))}const C=I.getAppearances();if(0!==C.length&&C.forEach((t=>{if(!t.getProperty("icon-image"))return;const e=this.getCombinedIconPrimary(t,I,_,r,v,E,p);e&&w(e)})),A){const t=a.evaluate(_,{},r).join(","),e="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(ph.vertical)>=0;for(const r of A.sections)if(r.image){const t=r.image.getPrimary().scaleSelf(this.pixelRatio),e=t.id.toString(),n=g.get(e)||[];n.push(t),g.set(e,n)}else{const n=ii(A.toString()),i=r.fontStack||t,o=x[i]=x[i]||{};this.calculateGlyphDependencies(r.text,o,e,this.allowVerticalPlacement,n)}}}if("line"===o.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function o(e){n.push(t[e]),i++}function s(t,e,i){const o=r[t];return delete r[t],r[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(i[0]),o}function a(t,r,i){const o=e[r];return delete e[r],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=i[0].concat(n[o].geometry[0]),o}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let u=0;u<t.length;u++){const c=t[u],h=c.geometry,p=c.text?c.text.toString():null;if(!p){o(u);continue}const d=l(p,h),f=l(p,h,!0);if(d in r&&f in e&&r[d]!==e[f]){const t=a(d,f,h),i=s(d,f,n[t].geometry);delete e[d],delete r[f],r[l(p,n[i].geometry,!0)]=i,n[t].geometry=null}else d in r?s(d,f,h):f in e?a(d,f,h):(o(u),e[d]=i-1,r[f]=i-1)}return n.filter((t=>t.geometry))}(this.features)),"hd-road-markup"===o.get("symbol-elevation-reference")){if(this.elevationType="road",e.elevationFeatures){!this.elevationFeatures&&e.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const t of e.elevationFeatures)this.elevationFeatureIdToIndex.set(t.id,this.elevationFeatures.length),this.elevationFeatures.push(t)}}else o.get("symbol-z-elevate")&&(this.elevationType="offset");"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}getCombinedIconPrimary(t,e,r,n,i,o,s){let a,l;const u=t.getUnevaluatedProperties();if(void 0!==u._values["icon-image"].value){const o=e.getAppearanceValueAndResolveTokens(t,"icon-image",r,n,i);a=this.getResolvedImageFromTokens(o)}else{const t=e.getValueAndResolveTokens("icon-image",r,n,i);a=this.getResolvedImageFromTokens(t)}if(a){const t=u._values["icon-size"]||e._unevaluatedLayout._values["icon-size"];l=mp(a,Bh(this.zoom,t,this.worldview),t,n,this.zoom,o,this.pixelRatio,s,this.worldview).iconPrimary}return l}updateAppearanceBasedIconTextures(t,e,r,n){if(!this.appearanceFeatureData)return!1;if(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)return!1;const i=this.layers[0];let o=!1,s=0;const a=i.layout,[l,u]=a.get("icon-size-scale-range"),c=ht(1,l,u);for(let a=0;a<this.symbolInstances.length;a++){const l=this.symbolInstances.get(a),u=this.featureToAppearanceIndex[l.featureIndex],h=void 0!==u?this.appearanceFeatureData[u]:void 0;if(h&&l.placedIconSymbolIndex>=0){const a=h.id,u=e&&void 0!==a?e[String(a)]:void 0,p={type:"Point",id:h.id,properties:h.properties,geometry:[]},d=this.layers[0].appearances&&this.layers[0].appearances.find((e=>e.isActive({globals:n,feature:p,canonical:t,featureState:u})));if(h.activeAppearance===d){s+=l.numIconVertices;continue}if(d){h.activeAppearance=d;const e=this.getCombinedIconPrimary(d,i,p,t,r,{sortKey:void 0,text:void 0,icon:null,index:l.featureIndex,sourceLayerIndex:l.featureIndex,geometry:[],properties:h.properties,type:"Point",id:h.id},c);if(!e)continue;const a=e.toString(),u=this.iconAtlasPositions&&this.iconAtlasPositions.get(a);if(u){const e=i.getAppearanceValueAndResolveTokens(d,"icon-offset",p,t,r),a=e&&Array.isArray(e)?e:[0,0];let f=Ih(u,void 0,a,i.layout.get("icon-anchor").evaluate(p,{},t));const y=i.getAppearanceValueAndResolveTokens(d,"icon-rotate",p,t,r),m="number"==typeof y?y:0,g=u.sdf,x=i.layout.get("icon-text-fit").constantOr("none");"none"!==x&&h.textShaping&&h.iconTextFitPadding&&h.fontScale&&(f=Ph(f,h.textShaping,x,h.iconTextFitPadding,a,h.fontScale));const v=this.calculateEffectiveAppearanceIconSize(d,n.zoom,p,t,r,c),b=0,w=1+(Math.min(Pp,Math.round(v*Ch))<<1),_=Xh(f,m,g,"none"!==x,c);h.isUsingAppearanceVertexData||(h.isUsingAppearanceVertexData=!0,h.layoutBasedVertexData=this.icon.getIconVertexData(s,l.numIconVertices));for(let t=0;t<_.length;++t){const e=_[t],r=h.layoutBasedVertexData[0]||l.tileAnchorX,n=h.layoutBasedVertexData[1]||l.tileAnchorY,i=16*e.pixelOffsetTL.x,o=16*e.pixelOffsetTL.y,a=16*e.pixelOffsetBR.x,u=16*e.pixelOffsetBR.y,c=16*e.minFontScaleX,p=16*e.minFontScaleY;this.icon.updateIconVertexData(s,r,n,Math.round(32*e.tl.x),Math.round(32*e.tl.y),e.texPrimary.x,e.texPrimary.y,b,w,i,o,c,p),this.icon.updateIconVertexData(s+1,r,n,Math.round(32*e.tr.x),Math.round(32*e.tr.y),e.texPrimary.x+e.texPrimary.w,e.texPrimary.y,b,w,a,o,c,p),this.icon.updateIconVertexData(s+2,r,n,Math.round(32*e.bl.x),Math.round(32*e.bl.y),e.texPrimary.x,e.texPrimary.y+e.texPrimary.h,b,w,i,u,c,p),this.icon.updateIconVertexData(s+3,r,n,Math.round(32*e.br.x),Math.round(32*e.br.y),e.texPrimary.x+e.texPrimary.w,e.texPrimary.y+e.texPrimary.h,b,w,a,u,c,p),s+=4}const A=l.numIconVertices-4*_.length;for(let t=0;t<A;++t)this.icon.updateIconVertexData(s+t,0,0,0,0,0,0,0,0,0,0,0,0);o=!0}else s+=l.numIconVertices}else if(h.usesAppearanceIconAsPlaceholder)this.layers[0].appearances&&this.layers[0].appearances.length>0&&(this.icon.updateIconVertexData(s,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+3,0,0,0,0,0,0,0,0,0,0,0,0),o=!0),s+=l.numIconVertices,h.activeAppearance=null;else if(h.isUsingAppearanceVertexData){const t=12,e=h.layoutBasedVertexData.length/t;for(let r=0;r<e;++r){const e=r*t;this.icon.updateIconVertexData(s+r,h.layoutBasedVertexData[e+0],h.layoutBasedVertexData[e+1],h.layoutBasedVertexData[e+2],h.layoutBasedVertexData[e+3],h.layoutBasedVertexData[e+4],h.layoutBasedVertexData[e+5],h.layoutBasedVertexData[e+6],h.layoutBasedVertexData[e+7],h.layoutBasedVertexData[e+8],h.layoutBasedVertexData[e+9],h.layoutBasedVertexData[e+10],h.layoutBasedVertexData[e+11])}s+=e,h.isUsingAppearanceVertexData=!1,h.activeAppearance=null,o=!0}else s+=l.numIconVertices,h.activeAppearance=null}}return o}update(t,e,r,n,i,o,s){this.text.programConfigurations.updatePaintArrays(t,e,i,r,n,o,s,this.worldview),this.icon.programConfigurations.updatePaintArrays(t,e,i,r,n,o,s,this.worldview)}updateRoadElevation(t){if("road"!==this.elevationType||!this.elevationFeatures)return;if(this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let e=!1;const r=Go(t),n=1/r;let i=!1,o=!1;for(let t=0;t<this.symbolInstances.length;t++){const s=this.symbolInstances.get(t),a=m(1,0,0),l=m(0,1,0),{numHorizontalGlyphVertices:u,numVerticalGlyphVertices:c,numIconVertices:h,numVerticalIconVertices:p}=s,d=u>0||c>0,f=h>0,y=this.elevationFeatures[s.elevationFeatureIndex];if(y){const t=new ot(s.tileAnchorX,s.tileAnchorY),u=.075+y.pointElevation(t);s.zOffset!==u&&(e=!0,s.zOffset=u),0!==u&&(this.hasAnyZOffset=!0);const c=y.computeSlopeNormal(t,n),h=H(R(),m(0,0,1),c);k(a,a,h),k(l,l,h),a[2]*=r,l[2]*=r,1===a[0]&&0===a[1]&&0===a[2]&&0===l[0]&&1===l[1]&&0===l[2]||(i=i||d,o=o||f)}if(d&&(Yp(this.text.orientationVertexArray,u,a,l),Yp(this.text.orientationVertexArray,c,a,l)),f){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:e}=s;t>=0&&Yp(this.icon.orientationVertexArray,h,a,l),e>=0&&Yp(this.icon.orientationVertexArray,p,a,l)}}i||(this.text.orientationVertexArray=void 0),o||(this.icon.orientationVertexArray=void 0),e&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const t=(t,e,n)=>{r+=e,r>t.length&&t.resize(r);for(let i=-e;i<0;i++)t.emplace(i+r,n)},e=(t,e,r)=>{n+=e,n>t.length&&t.resize(n);for(let i=-e;i<0;i++)t.emplace(i+n,r)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r<this.symbolInstances.length;r++){const n=this.symbolInstances.get(r),{numHorizontalGlyphVertices:i,numVerticalGlyphVertices:o,numIconVertices:s}=n,a=n.zOffset,l=s>0;if((i>0||o>0)&&(t(this.text.zOffsetVertexArray,i,a),t(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:r}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,a),r>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t,e,r,n,i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,!1),null===this.hasAppearances&&(this.hasAppearances=this.layers.some((t=>t.appearances&&t.appearances.length>0))),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(t,e,r,n){return!!(t&&e&&r)&&!(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(t,e,r,n)&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=$p(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:r}of e)this.lineVertexArray.emplaceBack(t,r);return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(t,e,r,n,i,o,s,a,l,u,c,h,p,d,f,y,m,g){const x=t.indexArray,v=t.layoutVertexArray,b=t.globeExtVertexArray,w=t.segments.prepareSegment(4*g,v,x,this.canOverlap?o.sortKey:void 0),_=this.glyphOffsetArray.length,A=w.vertexLength,S=this.allowVerticalPlacement&&s===ph.vertical?Math.PI/2:0,I=o.text&&o.text.sections;for(let n=0;n<e.length;n++){const{tl:i,tr:s,bl:u,br:c,texPrimary:h,texSecondary:m,pixelOffsetTL:g,pixelOffsetBR:_,minFontScaleX:A,minFontScaleY:P,glyphOffset:M,isSDF:D,sectionIndex:E}=e[n],C=w.vertexLength,B=M[1];if(Xp(v,l.x,l.y,i.x,B+i.y,h.x,h.y,r,D,g.x,g.y,A,P),Xp(v,l.x,l.y,s.x,B+s.y,h.x+h.w,h.y,r,D,_.x,g.y,A,P),Xp(v,l.x,l.y,u.x,B+u.y,h.x,h.y+h.h,r,D,g.x,_.y,A,P),Xp(v,l.x,l.y,c.x,B+c.y,h.x+h.w,h.y+h.h,r,D,_.x,_.y,A,P),a){const{x:e,y:r,z:n}=a.anchor,[i,o,s]=a.up;Wp(b,e,r,n,i,o,s),Wp(b,e,r,n,i,o,s),Wp(b,e,r,n,i,o,s),Wp(b,e,r,n,i,o,s),Jp(t.dynamicLayoutVertexArray,e,r,n,S)}else Jp(t.dynamicLayoutVertexArray,l.x,l.y,l.z,S);if(y){const e=m||h;Zp(t.iconTransitioningVertexArray,e.x,e.y),Zp(t.iconTransitioningVertexArray,e.x+e.w,e.y),Zp(t.iconTransitioningVertexArray,e.x,e.y+e.h),Zp(t.iconTransitioningVertexArray,e.x+e.w,e.y+e.h)}x.emplaceBack(C,C+1,C+2),x.emplaceBack(C+1,C+2,C+3),w.vertexLength+=4,w.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(M[0]),n!==e.length-1&&E===e[n+1].sectionIndex||t.programConfigurations.populatePaintArrays(v.length,o,o.index,{},p,d,f,I&&I[E],this.worldview)}const P=g-e.length;0!==P&&this._addNullVertices(P,v,r,a,b,t,y,w,x);const M=a?a.anchor:l;t.placedSymbolArray.emplaceBack(M.x,M.y,M.z,l.x,l.y,_,this.glyphOffsetArray.length-_,A,u,c,l.segment,r?r[0]:0,r?r[1]:0,n[0],n[1],s,0,0,0,h,0),t.symbolInstanceIndices.push(m)}_addNullVertices(t,e,r,n,i,o,s,a,l){for(let u=0;u<t;u++){for(let t=0;t<4;t++)Xp(e,0,0,0,0,0,0,r,!1,0,0,0,0),n?(Wp(i,0,0,0,0,0,0),Jp(o.dynamicLayoutVertexArray,0,0,0,0)):Jp(o.dynamicLayoutVertexArray,0,0,0,0),s&&Zp(o.iconTransitioningVertexArray,0,0);const t=a.vertexLength;l.emplaceBack(t,t+1,t+2),l.emplaceBack(t+1,t+2,t+3),a.vertexLength+=4,a.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0)}}_commitLayoutVertex(t,e,r,n,i,o,s){t.emplaceBack(e,r,n,i,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(t,e,r,n,i,o,s){const a=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),l=a.vertexLength,u=s.tileAnchorX,c=s.tileAnchorY;for(let t=0;t<4;t++)r.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(r.collisionVertexArrayExt,e,t.padding,s.zOffset),this._commitLayoutVertex(r.layoutVertexArray,n,i,o,u,c,new ot(t.x1,t.y1)),this._commitLayoutVertex(r.layoutVertexArray,n,i,o,u,c,new ot(t.x2,t.y1)),this._commitLayoutVertex(r.layoutVertexArray,n,i,o,u,c,new ot(t.x2,t.y2)),this._commitLayoutVertex(r.layoutVertexArray,n,i,o,u,c,new ot(t.x1,t.y2)),a.vertexLength+=4;const h=r.indexArray;h.emplaceBack(l,l+1),h.emplaceBack(l+1,l+2),h.emplaceBack(l+2,l+3),h.emplaceBack(l+3,l),a.primitiveLength+=4}_addTextDebugCollisionBoxes(t,e,r,n,i,o){for(let s=n;s<i;s++){const n=r.get(s),i=this.getSymbolInstanceTextSize(t,o,e,s);this._addCollisionDebugVertices(n,i,this.textCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(t,e,r,n,i,o){for(let s=n;s<i;s++){const n=r.get(s),i=this.getSymbolInstanceIconSize(t,e,o.placedIconSymbolIndex);this._addCollisionDebugVertices(n,i,this.iconCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,o)}}generateCollisionDebugBuffers(t,e,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new CollisionBuffers(StructArrayLayout3i2i2i16,$c.members,StructArrayLayout2ui4),this.iconCollisionBox=new CollisionBuffers(StructArrayLayout3i2i2i16,$c.members,StructArrayLayout2ui4);const n=kh(this.iconSizeData,t),i=kh(this.textSizeData,t,r);for(let r=0;r<this.symbolInstances.length;r++){const o=this.symbolInstances.get(r);this._addTextDebugCollisionBoxes(i,t,e,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(i,t,e,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(n,t,e,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(n,t,e,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(t,e,r,n){const i=this.text.placedSymbolArray.get(e.rightJustifiedTextSymbolIndex>=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Th(this.textSizeData,t,i)/qc;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,r){const n=this.icon.placedSymbolArray.get(r),i=Th(this.iconSizeData,t,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(t,e,r,n){t.emplaceBack(e,-r,-r,n),t.emplaceBack(e,r,-r,n),t.emplaceBack(e,r,r,n),t.emplaceBack(e,-r,r,n)}_updateTextDebugCollisionBoxes(t,e,r,n,i,o,s){for(let s=n;s<i;s++){const n=r.get(s),i=this.getSymbolInstanceTextSize(t,o,e,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,i,n.padding,o.zOffset)}}_updateIconDebugCollisionBoxes(t,e,r,n,i,o,s){for(let s=n;s<i;s++){const n=r.get(s),i=this.getSymbolInstanceIconSize(t,e,o.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,i,n.padding,o.zOffset)}}updateCollisionDebugBuffers(t,e,r,n){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=kh(this.iconSizeData,t,n),o=kh(this.textSizeData,t,r);for(let s=0;s<this.symbolInstances.length;s++){const a=this.symbolInstances.get(s);this._updateTextDebugCollisionBoxes(o,t,e,a.textBoxStartIndex,a.textBoxEndIndex,a,r),this._updateTextDebugCollisionBoxes(o,t,e,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a,r),this._updateIconDebugCollisionBoxes(i,t,e,a.iconBoxStartIndex,a.iconBoxEndIndex,a,n),this._updateIconDebugCollisionBoxes(i,t,e,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex,a,n)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(t,e,r,n,i,o,s,a,l){const u={};if(e<r){const{x1:r,y1:n,x2:i,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p,featureIndex:d}=t.get(e);u.textBox={x1:r,y1:n,x2:i,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p},u.textFeatureIndex=d}if(n<i){const{x1:e,y1:r,x2:i,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p,featureIndex:d}=t.get(n);u.verticalTextBox={x1:e,y1:r,x2:i,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p},u.verticalTextFeatureIndex=d}if(o<s){const{x1:e,y1:r,x2:n,y2:i,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p,featureIndex:d}=t.get(o);u.iconBox={x1:e,y1:r,x2:n,y2:i,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p},u.iconFeatureIndex=d}if(a<l){const{x1:e,y1:r,x2:n,y2:i,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p,featureIndex:d}=t.get(a);u.verticalIconBox={x1:e,y1:r,x2:n,y2:i,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p},u.verticalIconFeatureIndex=d}return u}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const r=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;e<n;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),r=Math.cos(t),n=[],i=[],o=[];for(let t=0;t<this.symbolInstances.length;++t){o.push(t);const s=this.symbolInstances.get(t);n.push(0|Math.round(e*s.tileAnchorX+r*s.tileAnchorY)),i.push(s.featureIndex)}return o.sort(((t,e)=>n[t]-n[e]||i[e]-i[t])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;t<this.symbolInstances.length;++t)this.symbolInstanceIndexesSortedZOffset.push(t)}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort(((t,e)=>this.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),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)}}getElevationFeatureForText(t){const e=this.symbolInstances.get(this.text.symbolInstanceIndices[t]).elevationFeatureIndex;let r;return this.elevationFeatures&&e<this.elevationFeatures.length&&(r=this.elevationFeatures[e]),r}}function Qp(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>r in t?String(t[r]):""))}let td,ed,rd;Yn(SymbolBucket,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),SymbolBucket.addDynamicAttributes=Jp;class FormatSectionOverride{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Rt,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Yn(FormatSectionOverride,"FormatSectionOverride",{omit:["defaultValue"]});const nd=()=>rd||(rd={layout:td||(td=new Properties({"symbol-placement":new DataConstantProperty(Pi.layout_symbol["symbol-placement"]),"symbol-spacing":new DataConstantProperty(Pi.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new DataConstantProperty(Pi.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new DataDrivenProperty(Pi.layout_symbol["symbol-sort-key"]),"symbol-z-order":new DataConstantProperty(Pi.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new DataConstantProperty(Pi.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new DataConstantProperty(Pi.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new DataConstantProperty(Pi.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new DataConstantProperty(Pi.layout_symbol["icon-ignore-placement"]),"icon-optional":new DataConstantProperty(Pi.layout_symbol["icon-optional"]),"icon-rotation-alignment":new DataConstantProperty(Pi.layout_symbol["icon-rotation-alignment"]),"icon-size":new DataDrivenProperty(Pi.layout_symbol["icon-size"]),"icon-size-scale-range":new DataConstantProperty(Pi.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new DataDrivenProperty(Pi.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new DataDrivenProperty(Pi.layout_symbol["icon-text-fit-padding"]),"icon-image":new DataDrivenProperty(Pi.layout_symbol["icon-image"]),"icon-image-use-theme":new DataConstantProperty({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new DataDrivenProperty(Pi.layout_symbol["icon-rotate"]),"icon-padding":new DataConstantProperty(Pi.layout_symbol["icon-padding"]),"icon-keep-upright":new DataConstantProperty(Pi.layout_symbol["icon-keep-upright"]),"icon-offset":new DataDrivenProperty(Pi.layout_symbol["icon-offset"]),"icon-anchor":new DataDrivenProperty(Pi.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new DataConstantProperty(Pi.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new DataConstantProperty(Pi.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new DataConstantProperty(Pi.layout_symbol["text-rotation-alignment"]),"text-field":new DataDrivenProperty(Pi.layout_symbol["text-field"]),"text-font":new DataDrivenProperty(Pi.layout_symbol["text-font"]),"text-size":new DataDrivenProperty(Pi.layout_symbol["text-size"]),"text-size-scale-range":new DataConstantProperty(Pi.layout_symbol["text-size-scale-range"]),"text-max-width":new DataDrivenProperty(Pi.layout_symbol["text-max-width"]),"text-line-height":new DataDrivenProperty(Pi.layout_symbol["text-line-height"]),"text-letter-spacing":new DataDrivenProperty(Pi.layout_symbol["text-letter-spacing"]),"text-justify":new DataDrivenProperty(Pi.layout_symbol["text-justify"]),"text-radial-offset":new DataDrivenProperty(Pi.layout_symbol["text-radial-offset"]),"text-variable-anchor":new DataConstantProperty(Pi.layout_symbol["text-variable-anchor"]),"text-anchor":new DataDrivenProperty(Pi.layout_symbol["text-anchor"]),"text-max-angle":new DataConstantProperty(Pi.layout_symbol["text-max-angle"]),"text-writing-mode":new DataConstantProperty(Pi.layout_symbol["text-writing-mode"]),"text-rotate":new DataDrivenProperty(Pi.layout_symbol["text-rotate"]),"text-padding":new DataConstantProperty(Pi.layout_symbol["text-padding"]),"text-keep-upright":new DataConstantProperty(Pi.layout_symbol["text-keep-upright"]),"text-transform":new DataDrivenProperty(Pi.layout_symbol["text-transform"]),"text-offset":new DataDrivenProperty(Pi.layout_symbol["text-offset"]),"text-allow-overlap":new DataConstantProperty(Pi.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new DataConstantProperty(Pi.layout_symbol["text-ignore-placement"]),"text-optional":new DataConstantProperty(Pi.layout_symbol["text-optional"]),visibility:new DataConstantProperty(Pi.layout_symbol.visibility)})),paint:ed||(ed=new Properties({"icon-opacity":new DataDrivenProperty(Pi.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new DataDrivenProperty(Pi.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new DataDrivenProperty(Pi.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new DataDrivenProperty(Pi.paint_symbol["text-emissive-strength"]),"icon-color":new DataDrivenProperty(Pi.paint_symbol["icon-color"]),"icon-halo-color":new DataDrivenProperty(Pi.paint_symbol["icon-halo-color"]),"icon-halo-width":new DataDrivenProperty(Pi.paint_symbol["icon-halo-width"]),"icon-halo-blur":new DataDrivenProperty(Pi.paint_symbol["icon-halo-blur"]),"icon-translate":new DataConstantProperty(Pi.paint_symbol["icon-translate"]),"icon-translate-anchor":new DataConstantProperty(Pi.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new DataConstantProperty(Pi.paint_symbol["icon-image-cross-fade"]),"text-opacity":new DataDrivenProperty(Pi.paint_symbol["text-opacity"]),"text-occlusion-opacity":new DataDrivenProperty(Pi.paint_symbol["text-occlusion-opacity"]),"text-color":new DataDrivenProperty(Pi.paint_symbol["text-color"],{runtimeType:jt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new DataDrivenProperty(Pi.paint_symbol["text-halo-color"]),"text-halo-width":new DataDrivenProperty(Pi.paint_symbol["text-halo-width"]),"text-halo-blur":new DataDrivenProperty(Pi.paint_symbol["text-halo-blur"]),"text-translate":new DataConstantProperty(Pi.paint_symbol["text-translate"]),"text-translate-anchor":new DataConstantProperty(Pi.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new DataConstantProperty(Pi.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new DataConstantProperty(Pi.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new DataConstantProperty(Pi.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new DataConstantProperty(Pi.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new DataDrivenProperty(Pi.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},rd);class SymbolStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,nd(),e,r,n,t.layout?t.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=o([]),this.hasOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint)}_handleSpecialPaintPropertyUpdate(t){"icon-occlusion-opacity"!==t&&"text-occlusion-opacity"!==t||(this.hasOcclusionOpacityProperties=!0)}recalculate(t,e){super.recalculate(t,e),this.appearances&&this.appearances.forEach((r=>{r.recalculate(t,e,this.iconImageUseTheme)})),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const r=this.layout.get("text-writing-mode");if(r){const t=[];for(const e of r)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(t,e,r,n){return this._saturation===t&&this._contrast===e&&this._brightnessMin===r&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(t,e,r,n){t=function(t){return t>0?1-1/(1.001-t):-t}(t),e=function(t){return t>0?1/(1.001-t):1+t}(e);const o=i(),s=t/3,l=1-2*s,u=[l,s,s,0,s,l,s,0,s,s,l,0,0,0,0,1],c=.5-.5*e,h=n-r;return a(o,[h,0,0,0,0,h,0,0,0,0,h,0,r,r,r,1],[e,0,0,0,0,e,0,0,0,0,e,0,c,c,c,1]),a(o,o,u),o}(t,e,r,n),this._saturation=t,this._contrast=e,this._brightnessMin=r,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||bn(o.value)||!i?i:Qp(e.properties,i)}getAppearanceValueAndResolveTokens(t,e,r,n,i){const o=t.getProperty(e);if(!o)return;const s=o.evaluate(r,{},n,i),a=t.getUnevaluatedProperties()._values[e];return a.isDataDriven()||bn(a.value)||!s||"string"!=typeof s?s:Qp(r.properties,s)}createBucket(t){return new SymbolBucket(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of nd().paint.overridableProperties){if(!SymbolStyleLayer.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new FormatSectionOverride(e),n=new StyleExpression(r,e.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new ZoomConstantExpression("source",n):new ZoomDependentExpression("composite",n,e.value.zoomStops,e.value.interpolationType),this.paint._values[t]=new PossiblyEvaluatedPropertyValue(e.property,i,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,r){return!(!this.layout||e.isDataDriven()||r.isDataDriven())&&SymbolStyleLayer.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=nd().paint.properties[e];let i=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Formatted)o(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof Literal&&ne(e.value)===Ht?o(e.value.sections):e instanceof FormatExpression?o(e.sections):e.eachChild(t))},e=r.value;e._styleExpression&&t(e._styleExpression.expression)}return i}getProgramIds(){return["symbol"]}getDefaultProgramParams(t,e,r){return{config:new ProgramConfiguration(this,{zoom:e,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}let id,od,sd,ad;var ld=Zi([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function ud(t,e,i,o,s,a,l,u){const c=[t,e,1,i,o,1,s,a,1],h=[l,u,1],p=r([],c),[d,f,y]=T(h,h,p);return n(c,c,[d,0,0,0,f,0,0,0,y])}function cd(t,e,i,o,s,a,l,u){const c=function(t,e,i,o,s,a,l,u){const c=ud(0,0,1,0,1,1,0,1),h=ud(t,e,i,o,s,a,l,u);return n(h,h,r([],c))}(t,e,i,o,s,a,l,u);return[c[2]/c[8]/Ue,c[5]/c[8]/Ue]}function hd(t){return[t[0],Math.min(Math.max(t[1],-Uo),Uo)]}class ImageSource extends Evented{constructor(t,e,r,n){super(),this.id=t,this.dispatcher=r,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(t,e){if(this._loaded=e||!1,this.fire(new Event("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=Zn(this.map._requestManager.transformRequest(this.url,Nn.Image),((e,r)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ErrorEvent(e)):r&&(this.image=r instanceof HTMLImageElement?bi.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new UserManagedTexture(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof UserManagedTexture||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],r=t[0][1];for(const n of t)n[1]>r&&(r=n[1]),n[1]<e&&(e=n[1]);const n=(r+e)/2;if(n>Uo?this.onNorthPole=!0:n<-Uo&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const e=t.map(MercatorCoordinate.fromLngLat);this.tileID=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const o of t)e=Math.min(e,o.x),r=Math.min(r,o.y),n=Math.max(n,o.x),i=Math.max(i,o.y);const o=Math.max(n-e,i-r),s=Math.max(0,Math.floor(-Math.log2(o))),a=Math.pow(2,s);let l=Math.floor((e+n)/2*a);return l>1&&(l-=1),new CanonicalTileID(s,l,Math.floor((r+i)/2*a))}(e),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof UserManagedTexture||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(t){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const e=kp(new CanonicalTileID(0,0,0),this.map.transform.projection),i=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,r=t[1].y-t[0].y,n=t[2].x-t[1].x,i=t[2].y-t[1].y,o=t[3].x-t[2].x,s=t[3].y-t[2].y,a=t[0].x-t[3].x,l=t[0].y-t[3].y,u=e*i-n*r,c=n*s-o*i,h=o*l-a*s,p=a*r-e*l;return u>0&&c>0&&h>0&&p>0||u<0&&c<0&&h<0&&p<0}(i))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const o=kp(this.tileID,this.map.transform.projection),[s,a,l,u]=this.coordinates.map((t=>{const e=o.projection.project(t[0],t[1]);return function(t,{x:e,y:r},n=0){return new ot(((e-n)*t.scale-t.x)*Ue,(r*t.scale-t.y)*Ue)}(o,e)._round()}));this.perspectiveTransform=cd(s.x,s.y,a.x,a.y,l.x,l.y,u.x,u.y);const c=this._boundsArray=new StructArrayLayout4i8;c.emplaceBack(s.x,s.y,0,0),c.emplaceBack(a.x,a.y,Ue,0),c.emplaceBack(u.x,u.y,0,Ue),c.emplaceBack(l.x,l.y,Ue,Ue),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(c,ld.members),this.boundsSegments=SegmentVector.simpleSegment(0,0,4,2);const h=[],p=[hd((d=this.coordinates)[0]),hd(d[1]),hd(d[2]),hd(d[3])];var d;const[f,y,m,g]=function(t){let e=t[0][0],r=e,n=t[0][1],i=n;for(let o=1;o<t.length;o++)t[o][0]<e?e=t[o][0]:t[o][0]>r&&(r=t[o][0]),t[o][1]<n?n=t[o][1]:t[o][1]>i&&(i=t[o][1]);return[e,n,r-e,i-n]}(p);{const o=new StructArrayLayout4i8,[s,a,l,u]=function(t){let e=t[0].x,r=e,n=t[0].y,i=n;for(let o=1;o<t.length;o++)t[o].x<e?e=t[o].x:t[o].x>r&&(r=t[o].x),t[o].y<n?n=t[o].y:t[o].y>i&&(i=t[o].y);return[e,n,r-e,i-n]}(i),c=t=>[(t.x-s)/l,(t.y-a)/u],[p,d,x,v]=i.map(c),b=function(t,e,i,o,s,a,l,u){const c=ud(0,0,1,0,1,1,0,1);return n(c,c,r([],ud(t,e,i,o,s,a,l,u)))}(p[0],p[1],d[0],d[1],x[0],x[1],v[0],v[1]);this.elevatedGlobePerspectiveTransform=cd(p[0],p[1],d[0],d[1],x[0],x[1],v[0],v[1]);const w=(t,e)=>{h.push(t.lng);const r=Math.round((t.lng-f)/m*Ue),n=Math.round((t.lat-y)/g*Ue),i=c(e),s=T([],[i[0],i[1],1],b),a=Math.round(s[0]/s[2]*Ue),l=Math.round(s[1]/s[2]*Ue);o.emplaceBack(r,n,a,l)},_=i[3].x-i[0].x,A=i[3].y-i[0].y,S=i[2].x-i[1].x,I=i[2].y-i[1].y;for(let t=0;t<65;t++){const r=t/64,n=[i[0].x+r*_,i[0].y+r*A],o=[i[1].x+r*S,i[1].y+r*I],s=o[0]-n[0],a=o[1]-n[1];for(let t=0;t<65;t++){const r=t/64,i={x:n[0]+s*r,y:n[1]+a*r};w(e.projection.unproject(i.x,i.y),i)}}this.elevatedGlobeVertexBuffer=t.createVertexBuffer(o,ld.members)}{this.maxLongitudeTriangleSize=0;let e=[],r=new StructArrayLayout3ui6;const n=(t,n,i)=>{r.emplaceBack(t,n,i);const o=h[t],s=h[n],a=h[i],l=Math.min(Math.min(o,s),a),u=Math.max(Math.max(o,s),a)-l;u>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=u),e.push(l+u/2)};for(let t=0;t<64;t++)for(let e=0;e<64;e++){const r=65*t+e,i=r+1,o=r+65,s=o+1;n(r,o,i),n(i,o,s)}[e,r]=function(t,e){const r=Array.from({length:t.length},((t,e)=>e));r.sort(((e,r)=>t[e]-t[r]));const n=[],i=new StructArrayLayout3ui6;for(let o=0;o<r.length;o++){const s=r[o];n.push(t[s]);const a=3*s,l=a+1;i.emplaceBack(e.uint16[a],e.uint16[l],e.uint16[l+1])}return[n,i]}(e,r),this.elevatedGlobeTrianglesCenterLongitudes=e,this.elevatedGlobeIndexBuffer=t.createIndexBuffer(r)}this.elevatedGlobeSegments=SegmentVector.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,m/Ue,0,g/Ue,0,0,y,f,0])}prepare(){const t=0!==Object.keys(this.tiles).length;if(this.tileID&&!t)return;const e=this.map.painter.context,r=e.gl;!this._dirty||this.texture instanceof UserManagedTexture||(this.texture?this.texture.update(this.image):(this.texture=new Texture(e,this.image,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE)),this._dirty=!1),t&&this._prepareData(e)}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(t){const e=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!e)return null;const r=this.elevatedGlobeTrianglesCenterLongitudes;let n=(i=t+180)+360*Math.round((r[0]-i)/360);var i;const o=new SegmentVector,s=(t,r)=>{o.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:r,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-n)<=a){const t=Mt(r,0,r.length,n+a);return t===r.length||s(t,Pt(r,t+1,r.length,n+360-a)-t),o}n<r[0]&&(n+=360);const l=Pt(r,0,r.length,n-a);if(l===r.length)return s(0,r.length),o;s(0,l-0);const u=Mt(r,l+1,r.length,n+a);return u!==r.length&&s(u,r.length-u),o}}let pd,dd,fd,yd,md,gd,xd;class CustomStyleLayer extends StyleLayer{constructor(t,e){super(t,{},e,null),this.implementation=t,t.slot&&(this.slot=t.slot)}is3D(t){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(t){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}function vd(t,e,r){const n=[0,0,1],i=O([]);return function(t,e,r){r*=.5;var n=e[0],i=e[1],o=e[2],s=e[3],a=Math.sin(r),l=Math.cos(r);t[0]=n*l-o*a,t[1]=i*l+s*a,t[2]=o*l+n*a,t[3]=s*l-i*a}(i,i,r?-ut(t)+Math.PI:ut(t)),function(t,e,r){r*=.5;var n=e[0],i=e[1],o=e[2],s=e[3],a=Math.sin(r),l=Math.cos(r);t[0]=n*l+s*a,t[1]=i*l+o*a,t[2]=o*l-i*a,t[3]=s*l-n*a}(i,i,-ut(e)),k(n,n,i),M(n,n)}class ModelFeature{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class PerModelAttributes{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new StructArrayLayout16f64,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(t){const e=16*t,r=this.instancedDataArray.float32;let n=Math.floor(r[e+2]);const i=1.05*(r[e+2]-n);return n/=100,[r[e]%1*1.05,r[e+1]%1*1.05,i,n]}tileCoordinatesForInstance(t){const e=16*t,r=this.instancedDataArray.float32;let n=r[e+0];return n=n>Ue?n-Ue:n,new ot(Math.trunc(n),Math.trunc(r[e+1]))}translationForInstance(t){const e=16*t,r=this.instancedDataArray.float32;return[r[e+4],r[e+5],r[e+6]]}rotationScaleForInstance(t){const e=16*t,r=this.instancedDataArray.float32;return[r[e+7],r[e+8],r[e+9],r[e+10],r[e+11],r[e+12],r[e+13],r[e+14],r[e+15]]}transformForInstance(t){const e=16*t,r=this.instancedDataArray.float32;return[r[e+7],r[e+8],r[e+9],r[e+4],r[e+10],r[e+11],r[e+12],r[e+5],r[e+13],r[e+14],r[e+15],r[e+6],0,0,0,1]}}class ModelBucket{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaledZ=this.canonical.z+Math.log2(t.overscaling),this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.worldview=t.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=t.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(t,e){}updateAppearances(t,e,r,n){}populate(t,e,r,n){this.tileToMeter=Go(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of t){const t=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,u=Ko(o,i);if(!this.layers[0]._featureFilter.filter(new EvaluationParameters(this.zoom,{worldview:this.worldview,activeFloors:e.activeFloors}),u,r))continue;const c={id:t,sourceLayerIndex:l,index:a,geometry:i?u.geometry:Jo(o,r,n),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(c,c.geometry,u);h&&e.featureIndex.insert(o,c.geometry,a,l,this.index,this.instancesPerModel[h].instancedDataArray.length,Ue/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const t=this.layers[0].modelManager,e=this.layers[0].scope;let r=0;for(const n of this.modelUris){const i=t.getModel(n,e);if(!i)continue;const o=this.instancesPerModel[n];if(o){const t=.5*S(i.aabb.max,i.aabb.min)*o.maxScale+o.maxXYTranslationDistance,e=Math.min(Ue,Math.max(t/this.tileToMeter,Ue/32));r=Math.max(e,r)}}return r}update(t,e,r,n){for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];for(const e in t)r.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(r.features[r.idToFeaturesIndex[e]],t[e],r,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];for(const e of r.features){const n=this.layers[0],i=e.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(i,{},o),a=n.paint.get("model-scale").evaluate(i,{},o),l=n.paint.get("model-translation").evaluate(i,{},o);z(e.rotation,s)&&z(e.scale,a)&&z(e.translation,l)||(this.evaluate(e,e.featureStates,r,!0),t=!0)}}return t}updateReplacement(t,e,r,n){if(e.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(cl(this.activeReplacements,i))return!1;this.activeReplacements=i;let o=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e],s=i.instancedDataArray;for(const e of i.features){const i=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;e<a;e++){const a=16*(e+i);let l=s.float32[a+0];const u=l>Ue;l=u?l-Ue:l;const c=Math.floor(l),h=Math.floor(s.float32[a+1]);let p=!1;for(const e of this.activeReplacements)if(!al(e,r,1,n)&&!(e.min.x>c||c>e.max.x||e.min.y>h||h>e.max.y)&&(p=dl(pl(c,h,t.canonical,e.footprintTileId.canonical),e.footprint),p))break;s.float32[a]=p?l+Ue:l,o=o||p!==u}}}return o}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=t.createVertexBuffer(r.instancedDataArray,Bu.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(t){for(const t in this.instancesPerModel){const e=this.instancesPerModel[t];0!==e.instancedDataArray.length&&e.instancedDataBuffer&&e.instancedDataBuffer.destroy()}const e=this.layers[0].modelManager;if(t&&e&&this.modelUris&&this.modelsRequested)for(const t of this.modelUris)e.removeModel(t,"",!0)}addFeature(t,e,r){const n=this.layers[0],i=n.layout.get("model-id").evaluate(r,{},this.canonical);if(!i)return vt(`modelId is not evaluated for layer ${n.id} and it is not going to get rendered.`),i;!function(t,e){t.indexOf("://");try{return new URL(t,void 0),!0}catch(t){return!1}}(i)?void 0!==this.styleDefinedModelURLs[i]&&(this.modelUris.includes(i)||this.modelUris.push(i)):this.modelUris.includes(i)||this.modelUris.push(i),this.instancesPerModel[i]||(this.instancesPerModel[i]=new PerModelAttributes);const o=this.instancesPerModel[i],s=o.instancedDataArray,a=new ModelFeature(r,s.length);for(const t of e)for(const e of t){if(e.x<0||e.x>=Ue||e.y<0||e.y>=Ue)continue;if(0!==this.lookupDim){const t=(this.lookupDim-1)/Ue,r=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1}}this.instanceCount++;const t=s.length;s.resize(t+1),o.instancesEvaluatedElevation.push(0),s.float32[16*t]=e.x,s.float32[16*t+1]=e.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(t.id&&(o.idToFeaturesIndex[t.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),i}getModelUris(){return this.modelUris}evaluate(t,e,r,n){const i=this.layers[0],o=t.feature,s=this.canonical,a=t.rotation=i.paint.get("model-rotation").evaluate(o,e,s),l=t.scale=i.paint.get("model-scale").evaluate(o,e,s),u=t.translation=i.paint.get("model-translation").evaluate(o,e,s),c=Object.assign({},i.paint.get("model-color").evaluate(o,e,s));c.a=i.paint.get("model-color-mix-intensity").evaluate(o,e,s);const h=[];this.maxVerticalOffset<u[2]&&(this.maxVerticalOffset=u[2]);const p=u[0]*u[0]+u[1]*u[1],d=p>0?Math.sqrt(p):0;r.maxScale=Math.max(Math.max(r.maxScale,l[0]),Math.max(l[1],l[2])),r.maxXYTranslationDistance=Math.max(r.maxXYTranslationDistance,d),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),ku(h,a,l);const f=Math.round(100*c.a)+c.b/1.05;for(let e=0;e<t.instancedDataCount;++e){const i=t.instancedDataOffset+e,o=16*i,a=r.instancedDataArray.float32;let l=0;n&&(l=a[o+6]-r.instancesEvaluatedElevation[i]);const p=0|a[o+1];a[o]=(0|a[o])+c.r/1.05,a[o+1]=p+c.g/1.05,a[o+2]=f,a[o+3]=1/(s.z>10?this.tileToMeter:Go(s,p)),a[o+4]=u[0],a[o+5]=u[1],a[o+6]=u[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],r.instancesEvaluatedElevation[i]=u[2]}}}Yn(ModelBucket,"ModelBucket",{omit:["layers"]}),Yn(PerModelAttributes,"PerModelAttributes"),Yn(ModelFeature,"ModelFeature");class DEMSampler{constructor(t,e,r){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=r}static create(t,e,r){const n=r||t.findDEMTileFor(e);if(!n||!n.dem)return;const i=n.dem,o=n.tileID,s=1<<e.canonical.z-o.canonical.z;return new DEMSampler(n,i.dim/Ue/s,[(e.canonical.x/s-o.canonical.x)*i.dim,(e.canonical.y/s-o.canonical.y)*i.dim])}tileCoordToPixel(t,e){const r=e*this._scale+this._offset[1];return new ot(Math.floor(t*this._scale+this._offset[0]),Math.floor(r))}getElevationAt(t,e,r,n){const i=t*this._scale+this._offset[0],o=e*this._scale+this._offset[1],s=Math.floor(i),a=Math.floor(o),l=this._dem;return n=!!n,r?Vt(Vt(l.get(s,a,n),l.get(s,a+1,n),o-a),Vt(l.get(s+1,a,n),l.get(s+1,a+1,n),o-a),i-s):l.get(s,a,n)}getElevationAtPixel(t,e,r){return this._dem.get(t,e,!!r)}getMeterToDEM(t){return(1<<this._demTile.tileID.canonical.z)*Fo(1,t)*this._dem.stride}}const bd=new Float32Array(262144),wd=new Uint8Array(262144);function _d(t){let e=0;if(t.meshes)for(const r of t.meshes)e=Math.max(e,r.aabb.max[2]);if(t.children)for(const r of t.children)e=Math.max(e,_d(r));return e}function Ad(t,e,r){if(t.meshes)for(const n of t.meshes){if(n.aabb.min[0]===1/0)continue;const i=Aabb.applyTransform(n.aabb,t.globalMatrix);r.insert(e,i.min[0],i.min[1],i.max[0],i.max[1])}if(t.children)for(const n of t.children)Ad(n,e,r)}const Sd=["","wall","door","roof","window","lamp","logo"];class Tiled3dModelFeature{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedTranslation=[0,0,0],this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.cameraCollisionOpacity=1,this.feature={type:"Point",id:t.id,geometry:[],properties:{height:_d(t)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new Aabb([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new Aabb([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const r of this.node.meshes)this.node.lightMeshIndex!==t&&(r.transformedAabb=Aabb.applyTransformFast(r.aabb,this.node.globalMatrix),e.encapsulate(r.transformedAabb)),t++;this.aabb=e}return this.aabb}}class Tiled3dModelBucket{constructor(t,e,r,n,i,o,s,a){this.id=r,this.layers=t,this.layerIds=this.layers.map((t=>t.fqid)),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=4),i&&(this.modelTraits|=8),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.worldview=a,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const t of e)this.nodesInfo.push(new Tiled3dModelFeature(t)),Ad(t,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(t,e){for(const r of this.getNodesInfo()){const n=r.node;n.footprint&&e.push({footprint:n.footprint,id:t})}}updateAppearances(t,e,r,n){}update(t){const e=0!==Object.keys(t).length;if(e&&!this.stateDependentLayers.length)return;const r=e?this.stateDependentLayers:this.layers;if(!st(t,this.states))for(const e of r)this.evaluate(e,t);this.states=structuredClone(t)}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const r of e){const e=r.node;this.uploaded?this.updatePbrBuffer(e):Nu(e,t,!0)}for(const t of e)ju(t.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const r of t.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),e=!0);return e}needsReEvaluation(t,e,r){const n=t.transform.projectionOptions,i=t.style.getBrightness(),o=this.brightness!==i;if(!this.uploaded||this.dirty||n.name!==this.projection.name||Id(r.paint.get("model-color").value,o)||Id(r.paint.get("model-color-mix-intensity").value,o)||Id(r.paint.get("model-roughness").value,o)||Id(r.paint.get("model-emissive-strength").value,o)||Id(r.paint.get("model-height-based-emissive-strength-multiplier").value,o)){this.projection=n,this.brightness=i;const t=this.getNodesInfo();for(const e of t)e.state=null;return!0}return!1}evaluateTransform(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const r=this.getNodesInfo(),n=this.id.canonical;for(const t of r){const r=t.feature;t.evaluatedTranslation=e.paint.get("model-translation").evaluate(r,{},n),t.evaluatedScale=e.paint.get("model-scale").evaluate(r,{},n)}}evaluate(t,e){const r=this.getNodesInfo();for(const n of r){if(!n.node.meshes)continue;const r=n.feature,i=e&&e[r.id];if(st(i,n.state))continue;n.state=structuredClone(i);const o=n.node.meshes&&n.node.meshes[0].featureData,s=n.evaluatedColor[2],a=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,o){for(let e=0;e<Sd.length;e++){const o=Sd[e];o.length&&(r.properties.part=o);const s=t.paint.get("model-color").evaluate(r,i,l).toPremultipliedRenderColor(null),a=t.paint.get("model-color-mix-intensity").evaluate(r,i,l);n.evaluatedColor[e]=[s.r,s.g,s.b,a],n.evaluatedRMEA[e][0]=t.paint.get("model-roughness").evaluate(r,i,l),n.evaluatedRMEA[e][2]=t.paint.get("model-emissive-strength").evaluate(r,i,l),n.evaluatedRMEA[e][3]=s.a,n.emissionHeightBasedParams[e]=t.paint.get("model-height-based-emissive-strength-multiplier").evaluate(r,i,l),!n.hasTranslucentParts&&s.a<1&&(n.hasTranslucentParts=!0)}delete r.properties.part,Md(n,s!==n.evaluatedColor[2]||a!==n.evaluatedRMEA[2],this.modelTraits)}else n.evaluatedRMEA[0][2]=t.paint.get("model-emissive-strength").evaluate(r,i,l);n.evaluatedTranslation=t.paint.get("model-translation").evaluate(r,i,l),n.evaluatedScale=t.paint.get("model-scale").evaluate(r,i,l),this.updatePbrBuffer(n.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(t,e,r,n){const i=t.findDEMTileFor(r);if(i&&(i.tileID.canonical!==this.terrainTile||e!==this.terrainExaggeration)){if(i.dem&&i.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=i.tileID.overscaledZ;const e=DEMSampler.create(t,r,i);if(!e)return;4&this.modelTraits&&this.updateDEM(t,e,r,n);for(const t of this.getNodesInfo()){const r=t.node;if(!r.footprint||!r.footprint.vertices||!r.footprint.vertices.length)continue;const n=r.footprint.vertices;let i=e.getElevationAt(n[0].x,n[0].y,!0,!0);for(let t=1;t<n.length;t++)i=Math.min(i,e.getElevationAt(n[t].x,n[t].y,!0,!0));r.elevation=i}}this.terrainTile=i.tileID.canonical,this.terrainExaggeration=e}}updateDEM(t,e,r,n){let i=e._dem._modifiedForSources[n];if(void 0===i&&(e._dem._modifiedForSources[n]=[],i=e._dem._modifiedForSources[n]),i.includes(r.canonical))return;const o=e._dem.dim;i.push(r.canonical);let s=!1;for(const t of this.getNodesInfo()){const r=t.node;if(!r.footprint||!r.footprint.grid)continue;const n=r.footprint.grid,i=e.tileCoordToPixel(n.min.x,n.min.y),a=e.tileCoordToPixel(n.max.x,n.max.y),l=Math.min(Math.min(o-a.y,i.x),Math.min(i.y,o-a.x));if(l<0)continue;const u=ht(l,2,5);let c=Math.max(0,i.x-u),h=Math.max(0,i.y-u),p=Math.min(a.x+u,o-1),d=Math.min(a.y+u,o-1);for(let t=h;t<=d;++t)for(let e=c;e<=p;++e)wd[t*o+e]=255;let f=0,y=0;for(let t=0;t<n.cellsY;++t)for(let r=0;r<n.cellsX;++r){if(!n.cells[t*n.cellsX+r])continue;const i=e.tileCoordToPixel(n.min.x+r/n.xScale,n.min.y+t/n.yScale),s=e.tileCoordToPixel(n.min.x+(r+1)/n.xScale,n.min.y+(t+1)/n.yScale);for(let t=i.y;t<=Math.min(s.y+1,o-1);++t)for(let r=i.x;r<=Math.min(s.x+1,o-1);++r)255===wd[t*o+r]&&(wd[t*o+r]=0,f+=e.getElevationAtPixel(r,t),y++)}const m=f/y;c=Math.max(1,i.x-u),h=Math.max(1,i.y-u),p=Math.min(a.x+u,o-2),d=Math.min(a.y+u,o-2),s=!0;for(let t=h;t<=d;++t)for(let r=c;r<=p;++r)0===wd[t*o+r]&&(bd[t*o+r]=e._dem.set(r,t,m));for(let t=1;t<u;++t){c=Math.max(1,i.x-t),h=Math.max(1,i.y-t),p=Math.min(a.x+t,o-2),d=Math.min(a.y+t,o-2);for(let r=h;r<=d;++r)for(let n=c;n<=p;++n){const i=r*o+n;if(255===wd[i]){let s=0,a=0,l=-1,c=-1;for(let e=-1;e<=1;++e)for(let i=-1;i<=1;++i){const u=(r+e)*o+n+i;if(wd[u]>=t)continue;const h=bd[u],p=Math.abs(h);p>a&&(s=h,a=p,l=i,c=e)}if(a>.1){const o=1-(t+.5*Math.abs(l*c))/u;let a=e._dem.get(n,r)+s*o;const h=e._dem.get(n+l,r+c),p=e._dem.get(n-l,r-c,!0);(a-h)*(a-p)>0&&(a=(h+p)/2),bd[i]=e._dem.set(n,r,a),wd[i]=t}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=bi.now())}setFilter(t){this.filter=t?Ei(t):null}getNodesInfo(){return this.filter?this.nodesInfo.filter((t=>this.filter.filter(new EvaluationParameters(this.id.overscaledZ,{worldview:this.worldview}),t.feature,this.id.canonical))):this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)ju(e.node),Gu(e.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped());for(const t of this.getNodesInfo()){const e=t.node.footprint;t.hiddenByReplacement=!!e&&!r.find((t=>t.footprint===e))}}getHeightAtTileCoord(t,e){const r=[],n=[0,0,0],i=o([]);for(const o of this.getNodesInfo()){const a=o.node.meshes[0],l=a.transformedAabb;if(t<l.min[0]||e<l.min[1]||t>l.max[0]||e>l.max[1])continue;if(!0===o.node.hidden)return{height:1/0,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]};s(i,o.node.globalMatrix),n[0]=t,n[1]=e,B(n,n,i);const u=(n[0]-a.aabb.min[0])/(a.aabb.max[0]-a.aabb.min[0])*Fu|0,c=Math.min(Fu-1,(n[1]-a.aabb.min[1])/(a.aabb.max[1]-a.aabb.min[1])*Fu|0)*Fu+Math.min(Fu-1,u),h=a.heightmap[c];if(!(h<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return{height:h,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new ot(t,e),new ot(t,e),r),r.length>0)return{height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function Id(t,e){return t instanceof ZoomConstantExpression&&!t.isLightConstant&&e}function Pd(t,e,r,n,i,o,s,a){let l=(61440&e|(61440&e)>>4)>>8,u=(3840&e|(3840&e)>>4)>>4,c=240&e|(240&e)>>4;r[3]>0&&(l=Vt(l,255*r[0],r[3]),u=Vt(u,255*r[1],r[3]),c=Vt(c,255*r[2],r[3]));const h=l<<8|u,p=c<<8|Math.floor(255*n[3]),d=function(t){const e=ht(t,0,2);return Math.min(Math.round(.5*e*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],f=ht(i[0],0,1),y=ht(i[1],0,1),m=ht(i[2],0,1),g=ht(i[3],0,1);let x,v,b,w;if(f!==y&&s!==o&&y!==f){const t=s-o;v=1/(t*(y-f)),b=-(o+t*f)/(t*(y-f));const e=ht(i[4],-1,1);w=Math.pow(10,e),x=255*m<<8|255*g}else x=65535,v=0,b=1,w=1;if(t.emplaceBack(h,p,d,x,v,b,w),a){const t=a.length;a.clear();for(let e=0;e<t;e++)a.emplaceBack(h,p,d,x,v,b,w)}}function Md(t,e,r){const n=t.node;let i=0;const o=8&r;for(const r of n.meshes){if(n.lights&&n.lightMeshIndex===i)continue;if(!r.featureData)continue;r.featureArray=new StructArrayLayout4ui3f20,r.featureArray.reserve(r.featureData.length);let s=e;for(const e of r.featureData){const i=o?65535&e:e>>16&65535,a=o?e>>16&65535:65535&e,l=(15&a)<8?15&a:0,u=t.evaluatedRMEA[l],c=t.evaluatedColor[l],h=t.emissionHeightBasedParams[l];let p;if(s&&2===l&&n.lights&&(p=new StructArrayLayout4ui3f20,p.resize(10*n.lights.length)),Pd(r.featureArray,i,c,u,h,r.aabb.min[2],r.aabb.max[2],p),p&&s){s=!1;const t=n.meshes[n.lightMeshIndex];t.featureArray=p,t.featureArray._trim()}}r.featureArray._trim(),i++}}Yn(Tiled3dModelBucket,"Tiled3dModelBucket",{omit:["layers"]}),Yn(Tiled3dModelFeature,"Tiled3dModelFeature");const Dd=["id","tile","layer","source","sourceLayer","state"];class Feature{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=r,this._y=n,this.properties=t?t.properties:{},this.id=i}clone(){const t=new Feature(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(t.state=Object.assign({},this.state)),this.layer&&(t.layer=Object.assign({},this.layer)),this.source&&(t.source=this.source),this.sourceLayer&&(t.sourceLayer=this.sourceLayer),t}get geometry(){return void 0===this._geometry&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Dd)void 0!==this[e]&&(t[e]=this[e]);return t}}class ModelSource extends Evented{constructor(t,e,r,n){super(),this.id=t,this.type="model",this.models=[],this._loaded=!1,this._options=e,this._modelsInfo=new Map}load(){const t=[];for(const e in this._options.models){const r=this._options.models[e],n=this._modelsInfo.get(e);if(n){const t=n.model;t.position=null!=r.position?new LngLat(r.position[0],r.position[1]):new LngLat(0,0),t.orientation=null!=r.orientation?r.orientation:[0,0,0],n.modelSpec=r,ModelSource.applyModelSpecification(t,r),t.computeBoundsAndApplyParent(),this.models.push(t)}else{const n=Au(this.map._requestManager.transformRequest(r.uri,Nn.Model).url).then((t=>{if(!t)return;const n=Ju(t),i=new Model(e,r.uri,r.position,r.orientation,n);ModelSource.applyModelSpecification(i,r),i.computeBoundsAndApplyParent(),this.models.push(i),this._modelsInfo.set(e,{modelSpec:r,model:i})})).catch((t=>{this.fire(new ErrorEvent(new Error(`Could not load model ${e} from ${r.uri}: ${t.message}`)))}));t.push(n)}}Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new Event("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((t=>{this._loaded=!0,this.fire(new ErrorEvent(new Error(`Could not load models: ${t.message}`)))}))}static applyModelSpecification(t,e){e.nodeOverrides&&ModelSource.convertNodeOverrides(t,e.nodeOverrides),e.materialOverrides&&ModelSource.convertMaterialOverrides(t,e.materialOverrides),e.nodeOverrideNames&&(t.nodeOverrideNames=[...e.nodeOverrideNames]),e.materialOverrideNames&&(t.materialOverrideNames=[...e.materialOverrideNames]),e.featureProperties&&(t.featureProperties=e.featureProperties)}static convertNodeOverrides(t,e){if(Array.isArray(e)&&e.every((t=>"string"==typeof t))){t.nodeOverrideNames=[];for(const r of e)t.nodeOverrideNames.push(r)}else Object.entries(e).forEach((([e,r])=>{const n={orientation:[0,0,0]};if(r.hasOwnProperty("orientation")){const t=r.orientation;t&&(n.orientation=t)}t.nodeOverrides.set(e,n)}))}static convertMaterialOverrides(t,e){if(Array.isArray(e)&&e.every((t=>"string"==typeof t))){t.materialOverrideNames=[];for(const r of e)t.materialOverrideNames.push(r)}else Object.entries(e).forEach((([e,r])=>{const n={color:new Color(1,1,1),colorMix:0,emissionStrength:0,opacity:1},i=r["model-color"];void 0!==i&&(n.color.r=i[0],n.color.g=i[1],n.color.b=i[2]);const o=r["model-color-mix-intensity"];void 0!==o&&(n.colorMix=o);const s=r["model-emissive-strength"];void 0!==s&&(n.emissionStrength=s);const a=r["model-opacity"];void 0!==a&&(n.opacity=a),t.materialOverrides.set(e,n)}))}onAdd(t){this.map=t,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(t,e){}serialize(){return this._options}setProperty(t,e){return!1}reload(){const t=Ni(this.id,this.scope);this.map.style.clearSource(t),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(t){this.models=[];const e=new Map;for(const r in t){const n=t[r];if(this._modelsInfo.has(r)){const t=this._modelsInfo.get(r);t&&t.modelSpec.uri===n.uri&&e.set(r,t)}}this._modelsInfo=e,this._options.models=t,this._loaded=!1,this.load()}}function Ed(t,e,r,n){const i=1<<t.z;e.lat=Oo((n/Ue+t.y)/i),e.lng=Ro((r/Ue+t.x)/i)}function Cd(t,e,r,n){const i=t.getNodesInfo()[e];if(!i||i.hiddenByReplacement||!i.node.meshes)return;let o=Number.MAX_VALUE;const s=i.node,c=r.tile,h=n.calculatePosMatrix(c.tileID.toUnwrapped(),n.worldSize),p=i.evaluatedScale;let d=0;n.elevation&&s.elevation&&(d=s.elevation*n.elevation.exaggeration()),l(h,h,[(s.anchor?s.anchor[0]:0)*(p[0]-1),(s.anchor?s.anchor[1]:0)*(p[1]-1),d]),u(h,h,p);const f=r.queryGeometry,y=f.isPointQuery()?f.screenBounds:f.screenGeometry,m=function(t){const e=a([],h,t.globalMatrix);a(e,n.expandedFarZProjMatrix,e);for(let r=0;r<t.meshes.length;++r){const i=t.meshes[r];if(r===t.lightMeshIndex)continue;const s=Vu(y,n,e,i.aabb);null!=s&&(o=Math.min(s,o))}if(t.children)for(const e of t.children)m(e)};if(m(s),o===Number.MAX_VALUE)return;const g=new LngLat(0,0);return Ed(c.tileID.canonical,g,i.node.anchor[0],i.node.anchor[1]),{intersectionZ:o,position:g,feature:i.feature}}const Bd={circle:class CircleStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:Cs||(Cs=new Properties({"circle-sort-key":new DataDrivenProperty(Pi.layout_circle["circle-sort-key"]),"circle-elevation-reference":new DataConstantProperty(Pi.layout_circle["circle-elevation-reference"]),visibility:new DataConstantProperty(Pi.layout_circle.visibility)})),paint:Bs||(Bs=new Properties({"circle-radius":new DataDrivenProperty(Pi.paint_circle["circle-radius"]),"circle-color":new DataDrivenProperty(Pi.paint_circle["circle-color"]),"circle-blur":new DataDrivenProperty(Pi.paint_circle["circle-blur"]),"circle-opacity":new DataDrivenProperty(Pi.paint_circle["circle-opacity"]),"circle-translate":new DataConstantProperty(Pi.paint_circle["circle-translate"]),"circle-translate-anchor":new DataConstantProperty(Pi.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new DataConstantProperty(Pi.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new DataConstantProperty(Pi.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new DataDrivenProperty(Pi.paint_circle["circle-stroke-width"]),"circle-stroke-color":new DataDrivenProperty(Pi.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new DataDrivenProperty(Pi.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new DataConstantProperty(Pi.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n)}createBucket(t){return new CircleBucket(t)}queryRadius(t){const e=t;return Ps("circle-radius",this,e)+Ps("circle-stroke-width",this,e)+Ms(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,r,n,i,o,s,a){const l=Es(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r);return $s(t,n,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return["circle"]}getDefaultProgramParams(t,e,r){const n=(t=>{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e})(this);return{config:new ProgramConfiguration(this,{zoom:e,lut:r}),defines:n,overrideFog:!1}}is3D(t){return!t&&!!this.layout&&"none"!==this.layout.get("circle-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("circle-elevation-reference")}},heatmap:class HeatmapStyleLayer extends StyleLayer{createBucket(t){return new HeatmapBucket(t)}constructor(t,e,r,n){super(t,{layout:Ws||(Ws=new Properties({visibility:new DataConstantProperty(Pi.layout_heatmap.visibility)})),paint:Ys||(Ys=new Properties({"heatmap-radius":new DataDrivenProperty(Pi.paint_heatmap["heatmap-radius"]),"heatmap-weight":new DataDrivenProperty(Pi.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new DataConstantProperty(Pi.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ColorRampProperty(Pi.paint_heatmap["heatmap-color"]),"heatmap-opacity":new DataConstantProperty(Pi.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=ra({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}_clear(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}queryRadius(t){return Ps("heatmap-radius",this,t)}queryIntersectsFeature(t,e,r,n,i,o,s,a){const l=this.paint.get("heatmap-radius").evaluate(e,r);return $s(t,n,o,s,a,!0,!0,new ot(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(t,e,r){return"heatmap"===t?{config:new ProgramConfiguration(this,{zoom:e,lut:r}),overrideFog:!1}:{}}},hillshade:class HillshadeStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:Js||(Js=new Properties({visibility:new DataConstantProperty(Pi.layout_hillshade.visibility)})),paint:Ks||(Ks=new Properties({"hillshade-illumination-direction":new DataConstantProperty(Pi.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new DataConstantProperty(Pi.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new DataConstantProperty(Pi.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new DataConstantProperty(Pi.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new DataConstantProperty(Pi.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new DataConstantProperty(Pi.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new DataConstantProperty(Pi.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n)}shouldRedrape(){return this.hasOffscreenPass()&&"viewport"===this.paint.get("hillshade-illumination-anchor")}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(t,e,r){return{overrideFog:!1}}},fill:class FillStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:Ha||(Ha=new Properties({"fill-sort-key":new DataDrivenProperty(Pi.layout_fill["fill-sort-key"]),visibility:new DataConstantProperty(Pi.layout_fill.visibility),"fill-elevation-reference":new DataConstantProperty(Pi.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new DataDrivenProperty(Pi.layout_fill["fill-construct-bridge-guard-rail"])})),paint:Xa||(Xa=new Properties({"fill-antialias":new DataConstantProperty(Pi.paint_fill["fill-antialias"]),"fill-opacity":new DataDrivenProperty(Pi.paint_fill["fill-opacity"]),"fill-color":new DataDrivenProperty(Pi.paint_fill["fill-color"]),"fill-outline-color":new DataDrivenProperty(Pi.paint_fill["fill-outline-color"]),"fill-translate":new DataConstantProperty(Pi.paint_fill["fill-translate"]),"fill-translate-anchor":new DataConstantProperty(Pi.paint_fill["fill-translate-anchor"]),"fill-pattern":new DataDrivenProperty(Pi.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new DataConstantProperty(Pi.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new DataConstantProperty(Pi.paint_fill["fill-emissive-strength"]),"fill-z-offset":new DataDrivenProperty(Pi.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new DataDrivenProperty(Pi.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new DataDrivenProperty(Pi.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),r=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getDefaultProgramParams(t,e,r){return{config:new ProgramConfiguration(this,{zoom:e,lut:r}),overrideFog:!1}}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new FillBucket(t)}queryRadius(){return Ms(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,r,n,i,o){return!t.queryGeometry.isAboveHorizon&&ds(Ds(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),n)}isTileClipped(){return 0===this.paint.get("fill-z-offset").constantOr(1)}is3D(t){if(0!==this.paint.get("fill-z-offset").constantOr(1))return!0;const e=this.layout&&"none"!==this.layout.get("fill-elevation-reference");return null!=t?e&&!t:e}hasElevation(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}hasShadowPass(){return this.layout&&"none"!==this.layout.get("fill-elevation-reference")}},"fill-extrusion":class FillExtrusionStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:Nl||(Nl=new Properties({visibility:new DataConstantProperty(Pi["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new DataConstantProperty(Pi["layout_fill-extrusion"]["fill-extrusion-edge-radius"])})),paint:jl||(jl=new Properties({"fill-extrusion-opacity":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new DataDrivenProperty(Pi["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new DataDrivenProperty(Pi["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new DataDrivenProperty(Pi["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new DataDrivenProperty(Pi["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new DataDrivenProperty(Pi["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new DataDrivenProperty(Pi["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-emissive-strength":new DataDrivenProperty(Pi["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new DataDrivenProperty(Pi["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new DataConstantProperty(Pi["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(t){return new FillExtrusionBucket(t)}queryRadius(){return Ms(this.paint.get("fill-extrusion-translate"))}is3D(t){return!0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(t,e,r,n,i,o,s,a,l){const u=Es(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(e,r),h=this.paint.get("fill-extrusion-base").evaluate(e,r),p=[0,0],d=a&&o.elevation,f=o.elevation?o.elevation.exaggeration():1,y=t.tile.getBucket(this);if(d&&y instanceof FillExtrusionBucket){const t=y.centroidVertexArray,e=l+1;e<t.length&&(p[0]=t.geta_centroid_pos0(e),p[1]=t.geta_centroid_pos1(e))}if(0===p[0]&&1===p[1])return!1;"globe"===o.projection.name&&(n=Ol([n],[new ot(0,0),new ot(Ue,Ue)],t.tileID.canonical).map((t=>t.polygon)).flat());const m=d?a:null,[g,x]=Jl(o,n,h,c,u,s,m,p,f,o.center.lat,t.tileID.canonical),v=t.queryGeometry;return Yl(g,x,v.isPointQuery()?v.screenBounds:v.screenGeometry)}},building:class BuildingStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:gc||(gc=new Properties({visibility:new DataConstantProperty(Pi.layout_building.visibility),"building-facade":new DataDrivenProperty(Pi.layout_building["building-facade"]),"building-facade-floors":new DataDrivenProperty(Pi.layout_building["building-facade-floors"]),"building-facade-unit-width":new DataDrivenProperty(Pi.layout_building["building-facade-unit-width"]),"building-facade-window":new DataDrivenProperty(Pi.layout_building["building-facade-window"]),"building-roof-shape":new DataDrivenProperty(Pi.layout_building["building-roof-shape"]),"building-height":new DataDrivenProperty(Pi.layout_building["building-height"]),"building-base":new DataDrivenProperty(Pi.layout_building["building-base"]),"building-flood-light-wall-radius":new DataDrivenProperty(Pi.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new DataDrivenProperty(Pi.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new DataDrivenProperty(Pi.layout_building["building-flip-roof-orientation"])})),paint:xc||(xc=new Properties({"building-opacity":new DataConstantProperty(Pi.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new DataConstantProperty(Pi.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new DataConstantProperty(Pi.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new DataConstantProperty(Pi.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new DataConstantProperty(Pi.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new DataConstantProperty(Pi.paint_building["building-vertical-scale"]),"building-cast-shadows":new DataConstantProperty(Pi.paint_building["building-cast-shadows"]),"building-color":new DataDrivenProperty(Pi.paint_building["building-color"]),"building-emissive-strength":new DataDrivenProperty(Pi.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new DataConstantProperty(Pi.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new DataConstantProperty(Pi.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new DataConstantProperty(Pi.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new DataConstantProperty(Pi.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new DataConstantProperty(Pi.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(t){return new BuildingBucket(t)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(t){return!0}queryRadius(t){return 0}queryIntersectsFeature(t,e,r,n,i,o,s,a,l){let u=this.layout.get("building-height").evaluate(e,r);const c=this.layout.get("building-base").evaluate(e,r),h=t.tile.getBucket(this).getFootprint(e);if(h){if(0!==h.hiddenFlags)return!1;u=h.height}const[p,d]=Jl(o,n,c,u,new ot(0,0),s,null,[0,0],1,o.center.lat,t.tileID.canonical),f=t.queryGeometry;return Yl(p,d,f.isPointQuery()?f.screenBounds:f.screenGeometry)}},line:class LineStyleLayer extends StyleLayer{constructor(t,e,r,n){const i=kc();super(t,i,e,r,n),i.layout&&(this.layout=new PossiblyEvaluated(i.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof Step,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=(()=>{if(zc)return zc;const t=kc();return zc=new LineFloorwidthProperty(t.paint.properties["line-width"].specification),zc.useIntegerZoom=!0,zc})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new LineBucket(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,r){const n=(t=>{const e=[];(function(t){const e=t.paint.get("line-dasharray").value;return"constant"!==e.kind||e.value})(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const r=t.paint.get("line-trim-offset");0===r[0]&&0===r[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),i=!!t.paint.get("line-pattern").constantOr(1);return n&&i&&e.push("LINE_JOIN_NONE"),e})(this);return{config:new ProgramConfiguration(this,{zoom:e,lut:r}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,r=Lc(Ps("line-width",this,e),Ps("line-gap-width",this,e)),n=Ps("line-offset",this,e);return r/2+Math.abs(n)+Ms(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,n,i,o){if(t.queryGeometry.isAboveHorizon)return!1;const s=Ds(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),a=t.pixelToTileUnitsFactor/2*Lc(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),l=this.paint.get("line-offset").evaluate(e,r);return l&&(n=function(t,e){const r=[],n=new ot(0,0);for(let i=0;i<t.length;i++){const o=t[i],s=[];for(let t=0;t<o.length;t++){const r=o[t],i=o[t+1],a=0===t?n:r.sub(o[t-1])._unit()._perp(),l=t===o.length-1?n:i.sub(r)._unit()._perp(),u=a._add(l)._unit();u._mult(1/(u.x*l.x+u.y*l.y)),s.push(u._mult(e)._add(r))}r.push(s)}return r}(n,l*t.pixelToTileUnitsFactor)),function(t,e,r){for(let n=0;n<e.length;n++){const i=e[n];if(t.length>=3)for(let e=0;e<i.length;e++)if(_s(t,i[e]))return!0;if(fs(t,i,r))return!0}return!1}(s,n,a)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(t){return!this.hasElevatedBuckets||this.layout&&"hd-road-markup"===this.layout.get("line-elevation-reference")}hasElevation(){return this.layout&&"none"!==this.layout.get("line-elevation-reference")}},symbol:SymbolStyleLayer,background:class BackgroundStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:id||(id=new Properties({visibility:new DataConstantProperty(Pi.layout_background.visibility)})),paint:od||(od=new Properties({"background-pitch-alignment":new DataConstantProperty(Pi.paint_background["background-pitch-alignment"]),"background-color":new DataConstantProperty(Pi.paint_background["background-color"]),"background-pattern":new DataConstantProperty(Pi.paint_background["background-pattern"]),"background-opacity":new DataConstantProperty(Pi.paint_background["background-opacity"]),"background-emissive-strength":new DataConstantProperty(Pi.paint_background["background-emissive-strength"]),"background-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(t,e,r){return{overrideFog:!1}}is3D(t){return"viewport"===this.paint.get("background-pitch-alignment")}},raster:class RasterStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:sd||(sd=new Properties({visibility:new DataConstantProperty(Pi.layout_raster.visibility)})),paint:ad||(ad=new Properties({"raster-opacity":new DataConstantProperty(Pi.paint_raster["raster-opacity"]),"raster-color":new ColorRampProperty(Pi.paint_raster["raster-color"]),"raster-color-mix":new DataConstantProperty(Pi.paint_raster["raster-color-mix"]),"raster-color-range":new DataConstantProperty(Pi.paint_raster["raster-color-range"]),"raster-hue-rotate":new DataConstantProperty(Pi.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new DataConstantProperty(Pi.paint_raster["raster-brightness-min"]),"raster-brightness-max":new DataConstantProperty(Pi.paint_raster["raster-brightness-max"]),"raster-saturation":new DataConstantProperty(Pi.paint_raster["raster-saturation"]),"raster-contrast":new DataConstantProperty(Pi.paint_raster["raster-contrast"]),"raster-resampling":new DataConstantProperty(Pi.paint_raster["raster-resampling"]),"raster-fade-duration":new DataConstantProperty(Pi.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new DataConstantProperty(Pi.paint_raster["raster-emissive-strength"]),"raster-array-band":new DataConstantProperty(Pi.paint_raster["raster-array-band"]),"raster-elevation":new DataConstantProperty(Pi.paint_raster["raster-elevation"]),"raster-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n),this.updateColorRamp(),this._curRampRange=[NaN,NaN]}getProgramIds(){return["raster"]}hasColorMap(){return!!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(t){return!(t&&t._source instanceof ImageSource&&(t._source.onNorthPole||t._source.onSouthPole))&&0===this.paint.get("raster-elevation")}_handleSpecialPaintPropertyUpdate(t){"raster-color"!==t&&"raster-color-range"!==t||(this._curRampRange=[NaN,NaN],this.updateColorRamp())}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}updateColorRamp(t){if(!this.hasColorMap())return;if(!this._curRampRange)return;const e=this._transitionablePaint._values["raster-color"].value.expression,[r,n]=t||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(r)&&isNaN(n)||r===this._curRampRange[0]&&n===this._curRampRange[1]||(this.colorRamp=ra({expression:e,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:r,end:n}],resolution:256}),this.colorRampTexture=null,this._curRampRange=[r,n])}},"raster-particle":class RasterParticleStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:pd||(pd=new Properties({visibility:new DataConstantProperty(Pi["layout_raster-particle"].visibility)})),paint:dd||(dd=new Properties({"raster-particle-array-band":new DataConstantProperty(Pi["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new DataConstantProperty(Pi["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new ColorRampProperty(Pi["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new DataConstantProperty(Pi["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new DataConstantProperty(Pi["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new DataConstantProperty(Pi["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new DataConstantProperty(Pi["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new DataConstantProperty(Pi["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n),this._updateColorRamp(),this.lastInvalidatedAt=bi.now()}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null)}onRemove(t){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return"none"!==this.visibility}isDraped(t){return!1}_handleSpecialPaintPropertyUpdate(t){"raster-particle-color"!==t&&"raster-particle-max-speed"!==t||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===t&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;const t=this._transitionablePaint._values["raster-particle-color"].value.expression,e=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=ra({expression:t,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:e}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=bi.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}},sky:class SkyLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:fd||(fd=new Properties({visibility:new DataConstantProperty(Pi.layout_sky.visibility)})),paint:yd||(yd=new Properties({"sky-type":new DataConstantProperty(Pi.paint_sky["sky-type"]),"sky-atmosphere-sun":new DataConstantProperty(Pi.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new DataConstantProperty(Pi.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new DataConstantProperty(Pi.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new DataConstantProperty(Pi.paint_sky["sky-gradient-radius"]),"sky-gradient":new ColorRampProperty(Pi.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new DataConstantProperty(Pi.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new DataConstantProperty(Pi.paint_sky["sky-atmosphere-color"]),"sky-opacity":new DataConstantProperty(Pi.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n),this._updateColorRamp()}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0}_handleSpecialPaintPropertyUpdate(t){"sky-gradient"===t?this._updateColorRamp():"sky-atmosphere-sun"!==t&&"sky-atmosphere-halo-color"!==t&&"sky-atmosphere-color"!==t&&"sky-atmosphere-sun-intensity"!==t||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=ra({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(t,e){if("atmosphere"===this.paint.get("sky-type")){const r=this.paint.get("sky-atmosphere-sun"),n=!r,i=t.style.light,o=i.properties.get("position");return n&&"viewport"===i.properties.get("anchor")&&vt("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),n?vd(o.azimuthal,90-o.polar,e):vd(r[0],90-r[1],e)}const r=this.paint.get("sky-gradient-center");return vd(r[0],90-r[1],e)}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const t=this.paint.get("sky-type");return"atmosphere"===t?["skyboxCapture","skybox"]:"gradient"===t?["skyboxGradient"]:null}},slot:class SlotStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{paint:md||(md=new Properties({}))},e,null)}},model:class ModelStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:gd||(gd=new Properties({visibility:new DataConstantProperty(Pi.layout_model.visibility),"model-id":new DataDrivenProperty(Pi.layout_model["model-id"])})),paint:xd||(xd=new Properties({"model-opacity":new DataDrivenProperty(Pi.paint_model["model-opacity"]),"model-rotation":new DataDrivenProperty(Pi.paint_model["model-rotation"]),"model-scale":new DataDrivenProperty(Pi.paint_model["model-scale"]),"model-translation":new DataDrivenProperty(Pi.paint_model["model-translation"]),"model-color":new DataDrivenProperty(Pi.paint_model["model-color"]),"model-color-mix-intensity":new DataDrivenProperty(Pi.paint_model["model-color-mix-intensity"]),"model-type":new DataConstantProperty(Pi.paint_model["model-type"]),"model-cast-shadows":new DataConstantProperty(Pi.paint_model["model-cast-shadows"]),"model-receive-shadows":new DataConstantProperty(Pi.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new DataConstantProperty(Pi.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new DataDrivenProperty(Pi.paint_model["model-emissive-strength"]),"model-roughness":new DataDrivenProperty(Pi.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new DataDrivenProperty(Pi.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new DataConstantProperty(Pi.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new DataConstantProperty(Pi.paint_model["model-front-cutoff"]),"model-elevation-reference":new DataConstantProperty(Pi.paint_model["model-elevation-reference"]),"model-color-use-theme":new DataDrivenProperty({type:"string",default:"default","property-type":"data-driven"})}))},e,r,n),this.layer=t,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(t){return new ModelBucket(t)}getProgramIds(){return["model"]}is3D(t){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(t){return t instanceof Tiled3dModelBucket?Ue-1:0}queryRenderedFeatures(t,e,r){const n=e.getSource();if(!(n&&n instanceof ModelSource))return{};const i=n,o={};o[this.id]=[];const s=o[this.id];let l=0;for(const n of i.models){const i=e.getFeatureState(this.sourceLayer,n.id),o={type:"Unknown",id:n.id,properties:n.featureProperties},u=this.paint.get("model-rotation").evaluate(o,i),c=this.paint.get("model-scale").evaluate(o,i),h=this.paint.get("model-translation").evaluate(o,i),p=this.paint.get("model-elevation-reference");let d=[];Ru(d,n,r,n.position,u,c,h,"ground"===p,"ground"===p,!1),"globe"===r.projection.name&&(d=Lu(d,r));const f=a([],r.projMatrix,d),y=Vu(t.isPointQuery()?t.screenBounds:t.screenGeometry,r,f,n.aabb);if(null!=y){const t=new Feature(void 0,0,0,0,n.id);t.layer=this.layer,t.properties=structuredClone(n.featureProperties),t.properties.layer=this.id,t.properties.uri=n.uri,t.properties.orientation=n.orientation,t.sourceLayer=this.sourceLayer,t.geometry={type:"Point",coordinates:[n.position.lng,n.position.lat]},t.state=i,t.source=this.source,s.push({featureIndex:l,feature:t,intersectionZ:y})}++l}return o}queryIntersectsFeature(t,e,r,n,i,o){if(!this.modelManager)return!1;const s=this.modelManager,l=t.tile.getBucket(this);if(!(l&&l instanceof ModelBucket))return!1;for(const r in l.instancesPerModel){const n=l.instancesPerModel[r],i=void 0!==e.id?e.id:e.properties&&e.properties.hasOwnProperty("id")?e.properties.id:void 0;if(n.idToFeaturesIndex.hasOwnProperty(i)){const e=n.features[n.idToFeaturesIndex[i]],u=s.getModel(r,this.scope);if(!u)return!1;let c=[];const h=new LngLat(0,0),p=l.canonical;let d=Number.MAX_VALUE;for(let r=0;r<e.instancedDataCount;++r){const i=16*(e.instancedDataOffset+r),s=n.instancedDataArray.float32,l=[s[i+4],s[i+5],s[i+6]];Ed(p,h,Math.floor(s[i]),Math.floor(s[i+1])),Ru(c,u,o,h,e.rotation,e.scale,l,!1,!1,!1),"globe"===o.projection.name&&(c=Lu(c,o));const f=a([],o.projMatrix,c),y=t.queryGeometry,m=Vu(y.isPointQuery()?y.screenBounds:y.screenGeometry,o,f,u.aabb);null!=m&&(d=Math.min(m,d))}return d!==Number.MAX_VALUE&&d}}return!1}_handleOverridablePaintPropertyUpdate(t,e,r){return!(!this.layout||e.isDataDriven()||r.isDataDriven()||"model-color"!==t&&"model-color-mix-intensity"!==t&&"model-rotation"!==t&&"model-scale"!==t&&"model-translation"!==t&&"model-emissive-strength"!==t)}_isPropertyZoomDependent(t){const e=this._transitionablePaint._values[t];return null!=e&&null!=e.value&&null!=e.value.expression&&e.value.expression instanceof ZoomDependentExpression}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class ClipStyleLayer extends StyleLayer{constructor(t,e,r,n){super(t,{layout:Za||(Za=new Properties({"clip-layer-types":new DataConstantProperty(Pi.layout_clip["clip-layer-types"]),"clip-layer-scope":new DataConstantProperty(Pi.layout_clip["clip-layer-scope"])})),paint:Wa||(Wa=new Properties({}))},e,r,n)}recalculate(t,e){super.recalculate(t,e)}createBucket(t){return new ClipBucket(t)}is3D(t){return!0}}};function Td(t,e,r,n){return"custom"===t.type?new CustomStyleLayer(t,e):new Bd[t.type](t,e,r,n)}var kd=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function zd(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${zd(r)},`;return`${e}]`}let e="{";for(const r of Object.keys(t).sort())e+=`${r}:${zd(t[r])},`;return`${e}}`}function Ld(t){let e="";for(const r of kd)e+=`/${zd(t[r])}`;return e}class StyleLayerIndex{constructor(t){this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(t,e,r){this._options=r;for(const e of t)this._layerConfigs[e.id]=e,(this._layers[e.id]=Td(e,this.scope,null,this._options)).compileFilter(r),this.keyCache[e.id]&&delete this.keyCache[e.id];for(const t of e)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const n=function(t,e){const r={};for(let n=0;n<t.length;n++){const i=t[n];let o=e&&e[i.id];o||("symbol"===i.type?o=i.id:(o=Ld(i),"line"===i.type&&i.paint&&function t(e){return"string"==typeof e&&"line-progress"===e||(Array.isArray(e)?e.some(t):!(!e||"object"!=typeof e)&&Object.values(e).some(t))}(i.paint["line-width"])&&(o+=`/${zd(i.paint["line-width"])}`))),e&&(e[i.id]=o);let s=r[o];s||(s=r[o]=[]),s.push(i)}const n=[];for(const t in r)n.push(r[t]);return n}(Object.values(this._layerConfigs),this.keyCache);for(const t of n){const e=t.map((t=>this._layers[t.id])),r=e[0];if("none"===r.visibility)continue;const n=r.source||"";let i=this.familiesBySource[n];i||(i=this.familiesBySource[n]={});const o=r.sourceLayer||"_geojsonTileLayer";let s=i[o];s||(s=i[o]=[]),s.push(e)}}}class DictionaryCoder{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const r=t[e];this._stringToNumber[r]=e,this._numberToString[e]=r}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}class FeatureIndex{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new kt(Ue,16,0),this.featureIndexArray=new FeatureIndexArray,this.promoteId=e,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(t,e,r,n,i,o=0,s=0){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i,o);const l=this.grid;for(let t=0;t<e.length;t++){const r=e[t],n=[1/0,1/0,-1/0,-1/0];for(let t=0;t<r.length;t++){const e=r[t];n[0]=Math.min(n[0],e.x),n[1]=Math.min(n[1],e.y),n[2]=Math.max(n[2],e.x),n[3]=Math.max(n[3],e.y)}0!==s&&(n[0]-=s,n[1]-=s,n[2]+=s,n[3]+=s),n[0]<Ue&&n[1]<Ue&&n[2]>=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new VectorTile(new Qc(this.rawTileData)).layers,this.sourceLayerCoder=new DictionaryCoder(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e){const{tilespaceGeometry:r,transform:n,tileTransform:i,pixelPosMatrix:o,availableImages:s,worldview:a}=e;this.loadVTLayers(),this.serializedLayersCache.clear();const l=e.queryRadius?e.queryRadius:0,u=r.bufferedTilespaceBounds,c=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,((t,e,n,i)=>{const o=function(t,e,r,n,i){for(const o of t)if(e<=o.x&&r<=o.y&&n>=o.x&&i>=o.y)return!0;const o=[new ot(e,r),new ot(e,i),new ot(n,i),new ot(n,r)];if(t.length>2)for(const e of o)if(_s(t,e))return!0;for(let e=0;e<t.length-1;e++)if(As(t[e],t[e+1],o))return!0;return!1}(r.bufferedTilespaceGeometry,t-l,e-l,n+l,i+l);return o}));c.sort(Fd);let h=null;n.elevation&&c.length>0&&(h=DEMSampler.create(n.elevation,this.tileID));const p={};let d;for(let e=0;e<c.length;e++){const l=c[e];if(l===d)continue;d=l;const u=this.featureIndexArray.get(l);let f=null;this.is3DTile?this.loadMatchingModelFeature(p,u,t,r,n,a):this.loadMatchingFeature(p,u,t,s,a,((t,e,s,a=0)=>(f||(f=Jo(t,this.tileID.canonical,i)),e.queryIntersectsFeature(r,t,s,f,this.z,n,o,h,a))))}return p}loadMatchingFeature(t,e,r,n,i,o){const{featureIndex:s,bucketIndex:a,sourceLayerIndex:l,layoutVertexArrayOffset:u}=e,c=this.bucketLayerIDs[a],h=r.layers,p=Object.keys(h);if(p.length&&!gt(p,c))return;const d=r.sourceCache,f=this.sourceLayerCoder.decode(l),y=this.vtLayers[f].feature(s),m=this.getId(y,f);for(let e=0;e<c.length;e++){const r=c[e];if(!h[r])continue;const{styleLayer:a,targets:l}=h[r];let p={};void 0!==m&&(p=d.getFeatureState(a.sourceLayer,m));const f=!o||o(y,a,p,u);if(!f)continue;const g=new Feature(y,this.z,this.x,this.y,m);g.tile=this.tileID.canonical,g.state=p;let x=this.serializedLayersCache.get(r);x||(x=a.serialize(),x.id=r,this.serializedLayersCache.set(r,x)),g.source=x.source,g.sourceLayer=x["source-layer"],g.layer=Object.assign({},x),g.layer.paint=Vd(x.paint,a.paint,y,p,n),g.layer.layout=Vd(x.layout,a.layout,y,p,n);let v=!1;for(const t of l){this.updateFeatureProperties(g,t);const{filter:e}=t;if(e)if(y.properties=g.properties,e.needGeometry){const t=Ko(y,!0);if(!e.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:i}),t,this.tileID.canonical))continue}else if(!e.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:i}),y))continue;v=!0,t.targetId&&this.addFeatureVariant(g,t)}v&&this.appendToResult(t,r,s,g,f)}}loadMatchingModelFeature(t,e,r,n,i,o){const{featureIndex:s,bucketIndex:a}=e,l=this.bucketLayerIDs[a],u=r.layers,c=Object.keys(u);if(!c.length||gt(c,l))for(let e=0;e<l.length;e++){const a=l[e],{styleLayer:c,targets:h}=u[a];if("model"!==c.type)continue;const p=n.tile,d=p.getBucket(c);if(!(d&&d instanceof Tiled3dModelBucket))continue;const f=Cd(d,s,n,i);if(!f)continue;const{z:y,x:m,y:g}=p.tileID.canonical,{feature:x,intersectionZ:v,position:b}=f;let w={};void 0!==x.id&&(w=r.sourceCache.getFeatureState(c.sourceLayer,x.id));const _=new Feature({},y,m,g,x.id);_.tile=this.tileID.canonical,_.state=w,_.properties=x.properties,_.geometry={type:"Point",coordinates:[b.lng,b.lat]};let A=this.serializedLayersCache.get(a);A||(A=c.serialize(),A.id=a,this.serializedLayersCache.set(a,A)),_.source=A.source,_.sourceLayer=A["source-layer"],_.layer=Object.assign({},A);let S=!1;for(const t of h){this.updateFeatureProperties(_,t);const{filter:e}=t;if(e)if(x.properties=_.properties,e.needGeometry){if(!e.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:o}),x,this.tileID.canonical))continue}else if(!e.filter(new EvaluationParameters(this.tileID.overscaledZ,{worldview:o}),x))continue;S=!0,t.targetId&&this.addFeatureVariant(_,t)}S&&this.appendToResult(t,a,s,_,v)}}updateFeatureProperties(t,e,r){if(e.properties){const n={};for(const i in e.properties){const o=e.properties[i].evaluate({zoom:this.z},t._vectorTileFeature,t.state,t.tile,r);null!=o&&(n[i]=o)}t.properties=n}}addFeatureVariant(t,e,r){const n={target:e.target,namespace:e.namespace,uniqueFeatureID:e.uniqueFeatureID};e.properties&&(n.properties=t.properties),t.variants=t.variants||{},t.variants[e.targetId]=t.variants[e.targetId]||[],t.variants[e.targetId].push(n)}appendToResult(t,e,r,n,i){let o=t[e];void 0===o&&(o=t[e]=[]),o.push({featureIndex:r,feature:n,intersectionZ:i})}lookupSymbolFeatures(t,e,r,n,i,o){const s={};this.loadVTLayers();for(const a of t)this.loadMatchingFeature(s,{bucketIndex:e,sourceLayerIndex:r,featureIndex:a,layoutVertexArrayOffset:0},n,i,o);return s}loadFeature(t){const{featureIndex:e,sourceLayerIndex:r}=t;this.loadVTLayers();const n=this.sourceLayerCoder.decode(r),i=this.vtFeatures[n];if(i[e])return i[e];const o=this.vtLayers[n].feature(e);return i[e]=o,o}hasLayer(t){for(const e of this.bucketLayerIDs)for(const r of e)if(t===r)return!0;return!1}getId(t,e){let r=t.id;if(this.promoteId){const n=Array.isArray(this.promoteId)||"object"!=typeof this.promoteId?this.promoteId:this.promoteId[e];if(null!=n)if(Array.isArray(n)){if(!this.promoteIdExpression){const t=wn(n);if("success"!==t.result){const e=t.value.map((t=>`${t.key}: ${t.message}`)).join(", ");return void vt(`Failed to create expression for promoteId: ${e}`)}this.promoteIdExpression=t.value}r=this.promoteIdExpression.evaluate({zoom:0},t)}else r=t.properties[n];"boolean"==typeof r&&(r=Number(r))}return r}}function Vd(t,e,r,n,i){return yt(t,((t,o)=>{const s=e instanceof PossiblyEvaluated?e.get(o):null;return s&&s.evaluate?s.evaluate(r,n,void 0,i):s}))}function Fd(t,e){return e-t}Yn(FeatureIndex,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Rd=1*$h;class GlyphAtlas{constructor(t){const e={},r=[];for(const n in t){const i=t[n],o=e[n]={};for(const t in i.glyphs){const e=i.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const n=e.metrics.localGlyph?Rd:1,s={x:0,y:0,w:e.bitmap.width+2*n,h:e.bitmap.height+2*n};r.push(s),o[t]=s}}const{w:n,h:i}=Nh(r),o=new AlphaImage({width:n||1,height:i||1});for(const r in t){const n=t[r];for(const t in n.glyphs){const i=n.glyphs[+t];if(!i||0===i.bitmap.width||0===i.bitmap.height)continue;const s=e[r][t],a=i.metrics.localGlyph?Rd:1;AlphaImage.copy(i.bitmap,o,{x:0,y:0},{x:s.x+a,y:s.y+a},i.bitmap)}}this.image=o,this.positions=e}}function Od(t,e,r){t[e]?r&&(t[e].center=r):t[e]={floorIds:new Set,center:r||[0,0],floors:{}}}function Ud(t,e,r,n){for(const i of e)Od(t,i),t[i].floors[r]=n,t[i].floorIds.add(r)}function Nd(t){return{id:t.properties.id.toString(),center:t.properties.center.toString().split(";").map(Number)}}function jd(t){return{id:t.properties.id.toString(),isDefault:!!t.properties.is_default&&t.properties.is_default,connections:t.properties.connected_floor_ids?new Set(t.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:t.properties.conflicted_floor_ids?new Set(t.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:t.properties.building_ids?new Set(t.properties.building_ids.toString().split(";")):new Set,name:t.properties.name.toString(),zIndex:t.properties.z_index}}function Gd(t,e){return e.every((e=>t.properties&&null!=t.properties[e]))}function $d(t){return Gd(t,["type","id","name"])&&"building"===t.properties.type}function qd(t){return Gd(t,["type","id","name","z_index"])&&"floor"===t.properties.type}Yn(GlyphAtlas,"GlyphAtlas");class WorkerTile{constructor(t){this.tileID=new OverscaledTileID(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.lut=t.lut,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.request&&t.request.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=kp(t.tileID.canonical,t.projection),this.projection=t.projection,this.worldview=t.worldview,this.localizableLayerIds=t.localizableLayerIds,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep,this.scaleFactor=t.scaleFactor,this.worldview=t.worldview,this.indoor=t.indoor}parse(t,e,r,n,i,o){this.status="parsing",this.data=t,this.collisionBoxArray=new CollisionBoxArray;const s=new DictionaryCoder(Object.keys(t.layers).sort()),a=new FeatureIndex(this.tileID,this.promoteId);a.bucketLayerIDs=[];const l={},u=new LineAtlas(256,256),c={featureIndex:a,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:u,availableImages:r,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const e=this.indoor.indoorState.activeFloorsVisible,r=function(t,e,r){const n=function(t,e){if(!t)return vt("No source layers defined in indoor specification"),e;if(0===t.size)return e;const r=t.difference(e);for(const t of r)vt(`Missing source layer required in indoor specification: ${t}`);return e.intersection(e)}(e.sourceLayers,new Set(Object.keys(t.layers))),i=e.indoorState,o=function(t,e,r,n){const i=new Set,o=new Set,s=new Set,a=new Map,l={},u=t=>{const e=a.get(t)||new Set;for(const r of i)if((a.get(r)||new Set).has(t)||e.has(r))return!0;return!1};for(const r of e){const e=t.layers[r];if(e)for(let t=0;t<e.length;t++){const r=e.feature(t);if($d(r)){const{id:t,center:e}=Nd(r);Od(l,t,e),i.add(t)}else if(qd(r)){const{id:t,isDefault:e,connections:u,conflicts:c,buildings:h,name:p,zIndex:d}=jd(r);Ud(l,h,t,{name:p,zIndex:d}),a.set(t,c),(t===n||u.has(n))&&i.add(t),o.add(t),e&&s.add(t)}}else vt(`indoor source layer not found: ${r}`)}if(r)for(const t of r)o.has(t)&&(u(t)||i.add(t));for(const t of s)i.has(t)||u(t)||i.add(t);return{buildings:l,activeFloors:i}}(t,n,i.lastActiveFloors,i.selectedFloorId);return r.send("setIndoorData",o),o}(t,this.indoor,i);c.activeFloors=e?r.activeFloors:void 0}const h=[],p=e.familiesBySource[this.source];for(const e in p){const i=t.layers[e];if(!i)continue;let o=!1,u=!1,d=!1;for(const t of p[e])"symbol"===t[0].type?o=!0:u=!0,t[0].is3D()&&"model"!==t[0].type&&(d=!0);if(this.extraShadowCaster&&!d)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!u)continue;1===i.version&&vt(`Vector tile source "${this.source}" layer "${e}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=s.encode(e),y=[],m=this.localizableLayerIds&&this.localizableLayerIds.has(e);let g=!1;for(let t=0,r=0;t<i.length;t++){const n=i.feature(t),o=a.getId(n,e),s=n.properties?n.properties.worldview:null;if(m&&this.worldview&&"string"==typeof s)if("all"===s)n.properties.$localized=!0;else{if(!s.split(",").includes(this.worldview))continue;n.properties.$localized=!0,n.properties.worldview=this.worldview}!g&&n.properties&&n.properties.hasOwnProperty(ns)&&(g=!0),y.push({feature:n,id:o,index:r,sourceLayerIndex:f}),r++}g&&!c.elevationFeatures&&t.layers.hasOwnProperty(os)&&(c.elevationFeatures=ElevationFeatures.parseFrom(t.layers[os],this.canonical));for(const t of p[e]){const e=t[0];if(this.extraShadowCaster&&(!e.is3D()||"model"===e.type))continue;if(void 0!==this.isSymbolTile&&"symbol"===e.type!==this.isSymbolTile)continue;if(e.minzoom&&this.zoom<Math.floor(e.minzoom))continue;if(e.maxzoom&&this.zoom>=e.maxzoom)continue;if("none"===e.visibility)continue;Hd(t,this.zoom,c.brightness,r,this.worldview);const i=l[e.id]=e.createBucket({index:a.bucketLayerIDs.length,layers:t,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,styleDefinedModelURLs:n,worldview:this.worldview,localizable:m});a.bucketLayerIDs.push(t.map((t=>Ni(t.id,t.scope))));let o=i.prepare?i.prepare():null;null!=o?(o=o.then((()=>i.populate(y,c,this.tileID.canonical,this.tileTransform))),h.push(o)):i.populate(y,c,this.tileID.canonical,this.tileTransform)}}const d=()=>{let e,n,h,p,d,f;u.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},m=()=>{if(e)return this.status="done",o(e);if(this.extraShadowCaster)this.status="done",o(null,{buckets:Object.values(l).filter((t=>!t.isEmpty())),featureIndex:a,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:c.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(n&&h&&p){const t=new GlyphAtlas(n),e=new Map;for(const[t,r]of h.entries()){const{imagePosition:n}=Gh(t,r,jh);e.set(t,n)}const o={};for(const i in l){const s=l[i];s instanceof SymbolBucket&&(Hd(s.layers,this.zoom,c.brightness,r,this.worldview),o[i]=cp(s,n,t.positions,h,e,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,d,this.worldview))}const s={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(i,h,d,(()=>{s.iconsPending=!1,g(o,t,s)})),this.rasterizeIfNeeded(i,p,f,(()=>{s.patternsPending=!1,g(o,t,s)}))}},g=(t,e,n,i)=>{if(n.iconsPending||n.patternsPending)return;const s=new ImageAtlas(h,p,this.lut);for(const e in l){const n=l[e];if(e in t)xp(n,t[e],this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,h,s);else if(n.hasPattern&&(n instanceof LineBucket||n instanceof FillBucket||n instanceof FillExtrusionBucket)){Hd(n.layers,this.zoom,c.brightness,r,this.worldview);const t=Object.fromEntries(s.patternPositions);n.addFeatures(c,this.tileID.canonical,t,r,this.tileTransform,this.brightness)}}this.status="done",o(null,{buckets:Object.values(l).filter((t=>!t.isEmpty())),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:u,imageAtlas:s,brightness:c.brightness})};if(!this.extraShadowCaster){const t=yt(c.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(t).length?i.send("getGlyphs",{uid:this.uid,stacks:t},((t,r)=>{e||(e=t,n=r,m())}),void 0,!1,y):n={};const r=Array.from(c.iconDependencies.keys()).map((t=>ImageId.parse(t)));r.length?i.send("getImages",{images:r,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((t,r)=>{e||(e=t,h=new Map,d=this.updateImageMapAndGetImageTaskQueue(h,r,c.iconDependencies),m())}),void 0,!1,y):(h=new Map,d=new Map);const o=Array.from(c.patternDependencies.keys()).map((t=>ImageId.parse(t)));o.length?i.send("getImages",{images:o,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((t,r)=>{e||(e=t,p=new Map,f=this.updateImageMapAndGetImageTaskQueue(p,r,c.patternDependencies),m())}),void 0,!1,y):(p=new Map,f=new Map)}if(c.elevationFeatures&&c.elevationFeatures.length>0){const e=[];for(const t of Object.values(l))if(t instanceof FillBucket){const r=t.getUnevaluatedPortalGraph();r&&e.push(r)}const r=ElevationPortalGraph.evaluate(e);for(const e of Object.values(l))if(e instanceof FillBucket){const n=t.layers[s.decode(e.sourceLayerIndex)];e.setEvaluatedPortalGraph(r,n,this.tileID.canonical,c.availableImages,c.brightness)}}m()};h.length>0?Promise.allSettled(h).then(d).catch(o):d()}updateParameters(t){this.scaleFactor=t.scaleFactor,this.showCollisionBoxes=t.showCollisionBoxes,this.projection=t.projection,this.brightness=t.brightness,this.tileTransform=kp(t.tileID.canonical,t.projection),this.extraShadowCaster=t.extraShadowCaster,this.lut=t.lut,this.worldview=t.worldview,this.indoor=t.indoor}rasterizeIfNeeded(t,e,r,n){Array.from(e.values()).some((t=>t.usvg))?this.rasterize(t,e,r,n):n()}updateImageMapAndGetImageTaskQueue(t,e,r){const n=new Map;for(const i of e.keys()){const o=r.get(i)||[];for(const r of o){const i=r.toString(),o=e.get(r.id.toString());o.usvg?n.has(i)||(n.set(i,r),t.set(i,Object.assign({},o))):t.set(i,o)}}return n}rasterize(t,e,r,n){this.rasterizeTask=t.send("rasterizeImages",{scope:this.scope,tasks:r},((t,r)=>{if(!t)for(const[t,n]of r.entries()){const r=Object.assign(e.get(t),{data:n});e.set(t,r)}n()}))}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function Hd(t,e,r,n,i){const o=new EvaluationParameters(e,{brightness:r,worldview:i});for(const e of t)e.recalculate(o,n)}class DedupedRequest{constructor(t){this.entries={},this.scheduler=t}request(t,e,r,n){const i=this.entries[t]=this.entries[t]||{callbacks:[]};if(i.result){const[t,r]=i.result;return this.scheduler?this.scheduler.add((()=>{n(t,r)}),e):n(t,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r(((r,n)=>{i.result=[r,n];for(const t of i.callbacks)this.scheduler?this.scheduler.add((()=>{t(r,n)}),e):t(r,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{i.result||(i.callbacks=i.callbacks.filter((t=>t!==n)),i.callbacks.length||(i.cancel(),delete this.entries[t]))}}}function Xd(t,e,r){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=$n(t.request,((t,n,i)=>{t?e(t):n&&e(null,{rawData:n,vectorTile:r?void 0:new VectorTile(new Qc(n)),responseHeaders:new Map(i.entries())})}));return()=>{n.cancel(),e()}}),e)}class VectorTileWorkerSource extends Evented{constructor(t,e,r,n,i,o,s){super(),this.actor=t,this.layerIndex=e,this.availableImages=r,this.availableModels=n,this.loadVectorData=o||Xd,this.loading={},this.loaded={},this.deduped=new DedupedRequest(t.scheduler),this.isSpriteLoaded=i,this.scheduler=t.scheduler,this.brightness=s}loadTile(t,e){const r=t.uid,n=t&&t.request,i=n&&n.collectResourceTiming,o=this.loading[r]=new WorkerTile(t);o.abort=this.loadVectorData(t,((s,a)=>{const l=!this.loading[r];if(delete this.loading[r],o.cancelRasterize(),l||s||!a)return o.status="done",l||(this.loaded[r]=o),e(s);const u=a.rawData,c={},h=(p=a.responseHeaders)?{cacheControl:p.get("Cache-Control"),expires:p.get("Expires")}:{cacheControl:void 0,expires:void 0};var p;h&&h.expires&&(c.expires=h.expires),h&&h.cacheControl&&(c.cacheControl=h.cacheControl),o.vectorTile=a.vectorTile||new VectorTile(new Qc(u));const d=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,((t,r)=>{if(t||!r)return e(t);const o={};if(i){const t=ti(n);t.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(t)))}e(null,Object.assign({rawTileData:u.slice(0),responseHeaders:a.responseHeaders},r,c,o))}))};this.isSpriteLoaded?d():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(d,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):d()})),this.loaded=this.loaded||{},this.loaded[r]=o}))}reloadTile(t,e){const r=this.loaded,n=t.uid;if(r&&r[n]){const i=r[n];i.updateParameters(t);const o=(t,r)=>{const n=i.reloadCallback;n&&(delete i.reloadCallback,i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,n)),e(t,r)};"parsing"===i.status?i.reloadCallback=o:"done"===i.status&&(i.vectorTile?i.parse(i.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,o):o())}else e(null,void 0)}abortTile(t,e){const r=t.uid,n=this.loading[r];n&&(n.abort&&n.abort(),delete this.loading[r]),e()}removeTile(t,e){const r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e()}}class MipLevel{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,e){const r=this.toIdx(t,e);return{min:this.minimums[r],max:this.maximums[r]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function Zd(t,e,r,n){let i=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(n[s])<1e-15){if(r[s]<t[s]||r[s]>e[s])return null}else{const a=1/n[s];let l=(t[s]-r[s])*a,u=(e[s]-r[s])*a;if(l>u){const t=l;l=u,u=t}if(l>i&&(i=l),u<o&&(o=u),i>o)return null}return i}function Wd(t,e,r,n,i,o,s,a,l,u,c){const h=n-t,p=i-e,d=o-r,f=s-t,y=a-e,m=l-r,g=c[1]*m-c[2]*y,x=c[2]*f-c[0]*m,v=c[0]*y-c[1]*f,b=h*g+p*x+d*v;if(Math.abs(b)<1e-15)return null;const w=1/b,_=u[0]-t,A=u[1]-e,S=u[2]-r,I=(_*g+A*x+S*v)*w;if(I<0||I>1)return null;const P=A*d-S*p,M=S*h-_*d,D=_*p-A*h,E=(c[0]*P+c[1]*M+c[2]*D)*w;return E<0||I+E>1?null:(f*P+y*M+m*D)*w}function Yd(t,e,r){return(t-e)/(r-e)}function Jd(t,e,r,n,i,o,s,a,l){const u=1<<r,c=o-n,h=s-i,p=(t+1)/u*c+n,d=(e+0)/u*h+i,f=(e+1)/u*h+i;a[0]=(t+0)/u*c+n,a[1]=d,l[0]=p,l[1]=f}class DemMinMaxQuadTree{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const e=function(t){const e=Math.ceil(Math.log2(t.dim/8)),r=[];let n=Math.ceil(Math.pow(2,e));const i=1/n,o=(t,e,r,n,i)=>{const o=n?1:0,s=(t+1)*r-o,a=e*r,l=(e+1)*r-o;i[0]=t*r,i[1]=a,i[2]=s,i[3]=l};let s=new MipLevel(n);const a=[];for(let e=0;e<n*n;e++){o(e%n,Math.floor(e/n),i,!1,a);const r=Qd(a[0],a[1],t),l=Qd(a[2],a[1],t),u=Qd(a[2],a[3],t),c=Qd(a[0],a[3],t);s.minimums.push(Math.min(r,l,u,c)),s.maximums.push(Math.max(r,l,u,c)),s.leaves.push(1)}for(r.push(s),n/=2;n>=1;n/=2){const t=r[r.length-1];s=new MipLevel(n);for(let e=0;e<n*n;e++){o(e%n,Math.floor(e/n),2,!0,a);const r=t.getElevation(a[0],a[1]),i=t.getElevation(a[2],a[1]),l=t.getElevation(a[2],a[3]),u=t.getElevation(a[0],a[3]),c=t.isLeaf(a[0],a[1]),h=t.isLeaf(a[2],a[1]),p=t.isLeaf(a[2],a[3]),d=t.isLeaf(a[0],a[3]),f=Math.min(r.min,i.min,l.min,u.min),y=Math.max(r.max,i.max,l.max,u.max),m=c&&h&&p&&d;s.maximums.push(y),s.minimums.push(f),s.leaves.push(y-f<=5&&m?1:0)}r.push(s)}return r}(this.dem),r=e.length-1,n=e[r];this._addNode(n.minimums[0],n.maximums[0],n.leaves[0]),this._construct(e,0,0,r,0)}raycastRoot(t,e,r,n,i,o,s=1){return Zd([t,e,-100],[r,n,this.maximums[0]*s],i,o)}raycast(t,e,r,n,i,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(t,e,r,n,i,o,s);if(null==a)return null;const l=[],u=[],c=[],h=[],p=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:a,t:d,nodex:f,nodey:y,depth:m}=p.pop();if(this.leaves[a]){Jd(f,y,m,t,e,r,n,c,h);const a=1<<m,l=(f+0)/a,u=(f+1)/a,p=(y+0)/a,g=(y+1)/a,x=Qd(l,p,this.dem)*s,v=Qd(u,p,this.dem)*s,b=Qd(u,g,this.dem)*s,w=Qd(l,g,this.dem)*s,_=Wd(c[0],c[1],x,h[0],c[1],v,h[0],h[1],b,i,o),S=Wd(h[0],h[1],b,c[0],h[1],w,c[0],c[1],x,i,o),I=Math.min(null!==_?_:Number.MAX_VALUE,null!==S?S:Number.MAX_VALUE);if(I!==Number.MAX_VALUE)return I;{const t=A([],i,o,d);if(Kd(x,v,w,b,Yd(t[0],c[0],h[0]),Yd(t[1],c[1],h[1]))>=t[2])return d}continue}let g=0;for(let p=0;p<this._siblingOffset.length;p++){Jd((f<<1)+this._siblingOffset[p][0],(y<<1)+this._siblingOffset[p][1],m+1,t,e,r,n,c,h),c[2]=-100,h[2]=this.maximums[this.childOffsets[a]+p]*s;const d=Zd(c,h,i,o);if(null!=d){const t=d;l[p]=t;let e=!1;for(let r=0;r<g&&!e;r++)t>=l[u[r]]&&(u.splice(r,0,p),e=!0);e||(u[g]=p),g++}}for(let t=0;t<g;t++){const e=u[t];p.push({idx:this.childOffsets[a]+e,t:l[e],nodex:(f<<1)+this._siblingOffset[e][0],nodey:(y<<1)+this._siblingOffset[e][1],depth:m+1})}}return null}_addNode(t,e,r){return this.minimums.push(t),this.maximums.push(e),this.leaves.push(r),this.childOffsets.push(0),this.nodeCount++}_construct(t,e,r,n,i){if(1===t[n].isLeaf(e,r))return;this.childOffsets[i]||(this.childOffsets[i]=this.nodeCount);const o=n-1,s=t[o];let a=0,l=0;for(let t=0;t<this._siblingOffset.length;t++){const n=2*e+this._siblingOffset[t][0],i=2*r+this._siblingOffset[t][1],o=s.getElevation(n,i),u=s.isLeaf(n,i),c=this._addNode(o.min,o.max,u);u&&(a|=1<<t),l||(l=c)}for(let n=0;n<this._siblingOffset.length;n++)a&1<<n||this._construct(t,2*e+this._siblingOffset[n][0],2*r+this._siblingOffset[n][1],o,l+n)}}function Kd(t,e,r,n,i,o){return Vt(Vt(t,r,o),Vt(e,n,o),i)}function Qd(t,e,r){const n=r.dim,i=ht(t*n-.5,0,n-1),o=ht(e*n-.5,0,n-1),s=Math.floor(i),a=Math.floor(o),l=Math.min(s+1,n-1),u=Math.min(a+1,n-1);return Kd(r.get(s,a),r.get(l,a),r.get(s,u),r.get(l,u),i-s,o-a)}const tf={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function ef(t,e,r){return(256*t*256+256*e+r)/10-1e4}function rf(t,e,r){return 256*t+e+r/256-32768}class DEMData{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,e,r,n=!1){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(r&&"mapbox"!==r&&"terrarium"!==r)return void vt(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const i=this.dim=e.height-2,o=new Uint32Array(e.data.buffer);if(this.pixels=new Uint8Array(e.data.buffer),this.floatView=new Float32Array(e.data.buffer),this.borderReady=n,this._modifiedForSources={},!n){for(let t=0;t<i;t++)o[this._idx(-1,t)]=o[this._idx(0,t)],o[this._idx(i,t)]=o[this._idx(i-1,t)],o[this._idx(t,-1)]=o[this._idx(t,0)],o[this._idx(t,i)]=o[this._idx(t,i-1)];o[this._idx(-1,-1)]=o[this._idx(0,0)],o[this._idx(i,-1)]=o[this._idx(i-1,0)],o[this._idx(-1,i)]=o[this._idx(0,i-1)],o[this._idx(i,i)]=o[this._idx(i-1,i-1)]}const s="terrarium"===r?rf:ef;for(let t=0;t<o.length;++t){const e=4*t;this.floatView[t]=s(this.pixels[e],this.pixels[e+1],this.pixels[e+2])}this._timestamp=bi.now()}_buildQuadTree(){this._tree=new DemMinMaxQuadTree(this)}get(t,e,r=!1){r&&(t=ht(t,-1,this.dim),e=ht(e,-1,this.dim));const n=this._idx(t,e);return this.floatView[n]}set(t,e,r){const n=this._idx(t,e),i=this.floatView[n];return this.floatView[n]=r,r-i}static getUnpackVector(t){return tf[t]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(e+1)*this.stride+(t+1)}static pack(t,e){const r=[0,0,0,0],n=DEMData.getUnpackVector(e);let i=Math.floor((t+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new Float32Image({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,o=r*this.dim,s=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1}switch(r){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-r*this.dim;for(let e=o;e<s;e++)for(let r=n;r<i;r++){const n=4*this._idx(r,e),i=4*this._idx(r+a,e+l);this.pixels[n+0]=t.pixels[i+0],this.pixels[n+1]=t.pixels[i+1],this.pixels[n+2]=t.pixels[i+2],this.pixels[n+3]=t.pixels[i+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Yn(DEMData,"DEMData"),Yn(DemMinMaxQuadTree,"DemMinMaxQuadTree",{omit:["dem"]});class RasterDEMTileWorkerSource{loadTile(t,e){const{uid:r,encoding:n,rawImageData:i,padding:o}=t,s=ImageBitmap&&i instanceof ImageBitmap?this.getImageData(i,o):i;e(null,new DEMData(r,s,n,o<1))}reloadTile(t,e){e(null,null)}abortTile(t,e){e()}removeTile(t,e){e()}getImageData(t,e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(t.width,t.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=t.width,this.offscreenCanvas.height=t.height,this.offscreenCanvasContext.drawImage(t,0,0,t.width,t.height);const r=this.offscreenCanvasContext.getImageData(-e,-e,t.width+2*e,t.height+2*e);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}class LRUCache{constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;const e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}put(t,e){this.cache.has(t)?this.cache.delete(t):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(t,e)}delete(t){this.cache.delete(t)}}function nf(t,e,r){1===t?e.headerLength=r.readFixed32():2===t?e.x=r.readVarint():3===t?e.y=r.readVarint():4===t?e.z=r.readVarint():5===t&&e.layers.push(function(t,e){return t.readFields(uf,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},e)}(r,r.readVarint()+r.pos))}function of(t,e,r){1===t?(e.delta_filter=function(t,e){return t.readFields(sf,{blockSize:0},e)}(r,r.readVarint()+r.pos),e.filter="delta_filter"):2===t?(r.readVarint(),e.filter="zigzag_filter"):3===t?(r.readVarint(),e.filter="bitshuffle_filter"):4===t&&(r.readVarint(),e.filter="byteshuffle_filter")}function sf(t,e,r){1===t&&(e.blockSize=r.readVarint())}function af(t,e,r){1===t?(r.readVarint(),e.codec="gzip_data"):2===t?(r.readVarint(),e.codec="jpeg_image"):3===t?(r.readVarint(),e.codec="webp_image"):4===t&&(r.readVarint(),e.codec="png_image")}function lf(t,e,r){let n=0,i=0;1===t?e.firstByte=r.readFixed64():2===t?e.lastByte=r.readFixed64():3===t?e.filters.push(function(t,e){return t.readFields(of,{},e)}(r,r.readVarint()+r.pos)):4===t?e.codec=function(t,e){return t.readFields(af,{},e)}(r,r.readVarint()+r.pos):5===t?i=r.readFloat():6===t?n=r.readFloat():7===t?e.bands.push(r.readString()):8===t?e.offset=r.readDouble():9===t&&(e.scale=r.readDouble()),0===e.offset&&(e.offset=i),0===e.scale&&(e.scale=n)}function uf(t,e,r){1===t?e.version=r.readVarint():2===t?e.name=r.readString():3===t?e.units=r.readString():4===t?e.tileSize=r.readVarint():5===t?e.buffer=r.readVarint():6===t?e.pixelFormat=r.readVarint():7===t&&e.dataIndex.push(function(t,e){return t.readFields(lf,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},e)}(r,r.readVarint()+r.pos))}function cf(t,e,r){if(2===t)!function(t,e,r){t.readFields(hf,r,e)}(r,r.readVarint()+r.pos,e);else if(3===t)throw new Error("Not implemented")}function hf(t,e,r){if(1===t){let t=0;const n=r.readVarint()+r.pos;for(;r.pos<n;)e[t++]=r.readVarint()}}function pf(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let r=e[3];for(let n=2;n>=1;n--){const i=1===n?1:0,o=2===n?1:0;for(let n=0;n<e[0];n++){const s=e[1]*n;for(let n=i;n<e[1];n++){const i=e[2]*(n+s);for(let n=o;n<e[2];n++){const o=e[3]*(n+i);for(let n=0;n<e[3];n++){const e=o+n;t[e]+=t[e-r]}}}}r*=e[n]}return t}function df(t){for(let e=0,r=t.length;e<r;e++)t[e]=t[e]>>>1^-(1&t[e]);return t}function ff(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e<t.length;e+=2){const r=t[e],n=t[e+1];t[e]=(240&r)>>4|(61440&r)>>8|(240&n)<<4|61440&n,t[e+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4}return t;case"uint8":for(let e=0;e<t.length;e+=4){const r=t[e],n=t[e+1],i=t[e+2],o=t[e+3];t[e+0]=(192&r)>>6|(192&n)>>4|(192&i)>>2|192&o,t[e+1]=(48&r)>>4|(48&n)>>2|48&i|(48&o)<<2,t[e+2]=(12&r)>>2|12&n|(12&i)<<2|(12&o)<<4,t[e+3]=3&r|(3&n)<<2|(3&i)<<4|(3&o)<<6}return t;default:throw new Error(`Invalid pixel format, "${e}"`)}}Yn(LRUCache,"LRUCache");var yf=Uint8Array,mf=Uint16Array,gf=Int32Array,xf=new yf([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]),vf=new yf([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]),bf=new yf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wf=function(t,e){for(var r=new mf(31),n=0;n<31;++n)r[n]=e+=1<<t[n-1];var i=new gf(r[30]);for(n=1;n<30;++n)for(var o=r[n];o<r[n+1];++o)i[o]=o-r[n]<<5|n;return{b:r,r:i}},_f=wf(xf,2),Af=_f.b,Sf=_f.r;Af[28]=258,Sf[258]=28;for(var If=wf(vf,0).b,Pf=new mf(32768),Mf=0;Mf<32768;++Mf){var Df=(43690&Mf)>>1|(21845&Mf)<<1;Pf[Mf]=((65280&(Df=(61680&(Df=(52428&Df)>>2|(13107&Df)<<2))>>4|(3855&Df)<<4))>>8|(255&Df)<<8)>>1}var Ef=function(t,e,r){for(var n=t.length,i=0,o=new mf(e);i<n;++i)t[i]&&++o[t[i]-1];var s,a=new mf(e);for(i=1;i<e;++i)a[i]=a[i-1]+o[i-1]<<1;s=new mf(1<<e);var l=15-e;for(i=0;i<n;++i)if(t[i])for(var u=i<<4|t[i],c=e-t[i],h=a[t[i]-1]++<<c,p=h|(1<<c)-1;h<=p;++h)s[Pf[h]>>l]=u;return s},Cf=new yf(288);for(Mf=0;Mf<144;++Mf)Cf[Mf]=8;for(Mf=144;Mf<256;++Mf)Cf[Mf]=9;for(Mf=256;Mf<280;++Mf)Cf[Mf]=7;for(Mf=280;Mf<288;++Mf)Cf[Mf]=8;var Bf=new yf(32);for(Mf=0;Mf<32;++Mf)Bf[Mf]=5;var Tf=Ef(Cf,9),kf=Ef(Bf,5),zf=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},Lf=function(t,e,r){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(7&e)&r},Vf=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(7&e)},Ff=["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"],Rf=function(t,e,r){var n=new Error(e||Ff[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,Rf),!r)throw n;return n},Of=new yf(0),Uf="undefined"!=typeof TextDecoder&&new TextDecoder;try{Uf.decode(Of,{stream:!0})}catch(t){}const Nf={gzip_data:"gzip"};class MRTError extends Error{constructor(t){super(t),this.name="MRTError"}}const jf={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Gf={uint32:1,uint16:2,uint8:4},$f={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let qf;class MapboxRasterTile{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}getLayer(t){const e=this.layers[t];if(!e)throw new MRTError(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),r=new DataView(t);if(13!==e[0])throw new MRTError("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),r=this.getHeaderLength(t);if(e.length<r)throw new MRTError(`Expected header with length >= ${r} but got buffer of length ${e.length}`);const n=new qf(e.subarray(0,r)).readFields(nf,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new MRTError(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const t of n.layers)this.layers[t.name]=new MapboxRasterLayer(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],r=this.getLayer(t.layerName);for(let n of t.blockIndices){const i=r.dataIndex[n],o=i.firstByte-t.firstByte,s=i.lastByte-t.firstByte;if(r._blocksInProgress.has(n))continue;const a={layerName:r.name,firstByte:o,lastByte:s,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map((t=>t.filter))};r._blocksInProgress.add(n),e.push(a)}return new MRTDecodingBatch(e,(()=>{e.forEach((t=>r._blocksInProgress.delete(t.blockIndex)))}),((t,n)=>{if(e.forEach((t=>r._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t)}))}))}}class MapboxRasterLayer{constructor({version:t,name:e,units:r,tileSize:n,pixelFormat:i,buffer:o,dataIndex:s},a){if(this.version=t,1!==this.version)throw new MRTError(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=r,this.tileSize=n,this.buffer=o,this.pixelFormat=jf[i],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,Gf[this.pixelFormat]],this._decodedBlocks=new LRUCache(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Gf[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data)}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[r,n]of this.dataIndex.entries()){for(const[i,o]of n.bands.entries())if(o===t)return{bandIndex:e+i,blockIndex:r,blockBandIndex:i};e+=n.bands.length}break;case"number":for(const[r,n]of this.dataIndex.entries()){if(t>=e&&t<e+n.bands.length)return{bandIndex:t,blockIndex:r,blockBandIndex:t-e};e+=n.bands.length}break;default:throw new MRTError(`Invalid band \`${JSON.stringify(t)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(t){let e=1/0,r=-1/0;const n=[],i=new Set;for(const o of t){const{blockIndex:t}=this.getBlockForBand(o);if(t<0)throw new MRTError(`Invalid band: ${JSON.stringify(o)}`);const s=this.dataIndex[t];n.includes(t)||n.push(t),i.add(t),e=Math.min(e,s.firstByte),r=Math.max(r,s.lastByte)}if(i.size>this.cacheSize)throw new MRTError(`Number of blocks to decode (${i.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:e,lastByte:r,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:r}=this.getBlockForBand(t);if(e<0)throw new MRTError(`Band not found: ${JSON.stringify(t)}`);const n=this._decodedBlocks.get(e.toString());if(!n)throw new MRTError(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const i=this.dataIndex[e],o=this.bandShape.reduce(((t,e)=>t*e),1),s=r*o,a=n.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,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:i.offset,scale:i.scale}}}MapboxRasterTile.setPbf=function(t){qf=t};class MRTDecodingBatch{constructor(t,e,r){this.tasks=t,this._onCancel=e,this._onComplete=r,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0)}}MapboxRasterTile.performDecoding=function(t,e){const r=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:i,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:u}=t,c=r.subarray(n,i+1),h=new Uint32Array(s[0]*s[1]*s[2]);let p;if("gzip_data"!==u)throw new MRTError(`Unhandled codec: ${u}`);return p=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((o=function(t){31==t[0]&&139==t[1]&&8==t[2]||Rf(6,"invalid gzip data");var e=t[3],r=10;4&e&&(r+=2+(t[10]|t[11]<<8));for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[r++]);return r+(2&e)}(i=t))+8>i.length&&Rf(6,"invalid gzip data"),function(t,e,r,n){var i=t.length;if(!i||e.f&&!e.l)return r||new yf(0);var o=!r,s=o||2!=e.i,a=e.i;o&&(r=new yf(3*i));var l,u,c=function(t){var e=r.length;if(t>e){var n=new yf(Math.max(2*e,t));n.set(r),r=n}},h=e.f||0,p=e.p||0,d=e.b||0,f=e.l,y=e.d,m=e.m,g=e.n,x=8*i;do{if(!f){h=Lf(t,p,1);var v=Lf(t,p+1,3);if(p+=3,!v){var b=t[(B=4+((p+7)/8|0))-4]|t[B-3]<<8,w=B+b;if(w>i){a&&Rf(0);break}s&&c(d+b),r.set(t.subarray(B,w),d),e.b=d+=b,e.p=p=8*w,e.f=h;continue}if(1==v)f=Tf,y=kf,m=9,g=5;else if(2==v){var _=Lf(t,p,31)+257,A=Lf(t,p+10,15)+4,S=_+Lf(t,p+5,31)+1;p+=14;for(var I=new yf(S),P=new yf(19),M=0;M<A;++M)P[bf[M]]=Lf(t,p+3*M,7);p+=3*A;var D=zf(P),E=(1<<D)-1,C=Ef(P,D);for(M=0;M<S;){var B,T=C[Lf(t,p,E)];if(p+=15&T,(B=T>>4)<16)I[M++]=B;else{var k=0,z=0;for(16==B?(z=3+Lf(t,p,3),p+=2,k=I[M-1]):17==B?(z=3+Lf(t,p,7),p+=3):18==B&&(z=11+Lf(t,p,127),p+=7);z--;)I[M++]=k}}var L=I.subarray(0,_),V=I.subarray(_);m=zf(L),g=zf(V),f=Ef(L,m),y=Ef(V,g)}else Rf(1);if(p>x){a&&Rf(0);break}}s&&c(d+131072);for(var F=(1<<m)-1,R=(1<<g)-1,O=p;;O=p){var U=(k=f[Vf(t,p)&F])>>4;if((p+=15&k)>x){a&&Rf(0);break}if(k||Rf(2),U<256)r[d++]=U;else{if(256==U){O=p,f=null;break}var N=U-254;U>264&&(N=Lf(t,p,(1<<($=xf[M=U-257]))-1)+Af[M],p+=$);var j=y[Vf(t,p)&R],G=j>>4;if(j||Rf(3),p+=15&j,V=If[G],G>3){var $=vf[G];V+=Vf(t,p)&(1<<$)-1,p+=$}if(p>x){a&&Rf(0);break}s&&c(d+131072);var q=d+N;if(d<V){var H=0-V,X=Math.min(V,q);for(H+d<0&&Rf(3);d<X;++d)r[d]=(void 0)[H+d]}for(;d<q;++d)r[d]=r[d-V]}}e.l=f,e.p=O,e.b=d,e.f=h,f&&(h=1,e.m=m,e.d=y,e.n=g)}while(!h);return d!=r.length&&o?(l=r,(null==(u=d)||u>l.length)&&(u=l.length),new yf(l.subarray(0,u))):r.subarray(0,d)}(i.subarray(o,-8),{i:2},new yf(((r=i)[(n=r.length)-4]|r[n-3]<<8|r[n-2]<<16|r[n-1]<<24)>>>0))));var r,n,i,o;const s=Nf[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(a)).arrayBuffer().then((t=>new Uint8Array(t)))}(c,u).then((t=>(function(t,e){t.readFields(cf,e)}(new qf(t),h),new(0,$f[o])(h.buffer)))),p.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":pf(t,s);break;case"zigzag_filter":df(t);break;case"bitshuffle_filter":ff(t,o);break;default:throw new MRTError(`Unhandled filter "${l[e]}"`)}return{layerName:e,blockIndex:a,data:t}})).catch((t=>{throw t}))})))},Yn(MRTDecodingBatch,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),Yn(MapboxRasterTile,"MapboxRasterTile"),Yn(MapboxRasterLayer,"MapboxRasterLayer",{omit:["_blocksInProgress"]}),MapboxRasterTile.setPbf(Qc);class RasterArrayWorkerTile{constructor(t){this._mrt=new MapboxRasterTile(t.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=t.uid,this.tileID=t.tileID,this.source=t.source}parse(t,e){const r=this._mrt;this.status="parsing",this._entireBuffer=t;try{r.parseHeader(t),this._isHeaderLoaded=!0;const n=[];for(const e in r.layers){const i=r.getLayer(e),o=i.getDataRange(i.getBandList()),s=r.createDecodingTask(o),a=t.slice(o.firstByte,o.lastByte+1),l=MapboxRasterTile.performDecoding(a,s).then((t=>s.complete(null,t))).catch((t=>s.complete(t,null)));n.push(l)}Promise.allSettled(n).then((()=>e(null,r))).catch((t=>e(t)))}catch(t){e(t)}}}class RasterArrayTileWorkerSource{constructor(t){this.actor=t,this.loading={},this.loaded={}}loadTile(t,e){const r=t.uid,n=t.request,i=this.loading[r]=new RasterArrayWorkerTile(t),{cancel:o}=$n(n,((t,n,o)=>{const s=!this.loading[r];if(delete this.loading[r],s||t||!n)return i.status="done",s||(this.loaded[r]=i),e(t);i.parse(n,((t,r)=>{if(t||!r)return e(t);e(null,r,o)})),this.loaded[r]=i}));i.abort=o}reloadTile(t,e){e(null,void 0)}abortTile(t,e){const r=t.uid,n=this.loading[r];n&&(n.abort&&n.abort(),delete this.loading[r]),e()}removeTile(t,e){const r=t.uid;this.loaded[r]&&delete this.loaded[r],e()}decodeRasterArray(t,e){MapboxRasterTile.performDecoding(t.buffer,t.task).then((t=>e(null,t))).catch((t=>e(t)))}}const Hf=VectorTileFeature.prototype.toGeoJSON;class FeatureWrapper{constructor(t){this._feature=t,this.extent=Ue,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 e of this._feature.geometry)t.push([new ot(e[0],e[1])]);return t}{const t=[];for(const e of this._feature.geometry){const r=[];for(const t of e)r.push(new ot(t[0],t[1]));t.push(r)}return t}}toGeoJSON(t,e,r){return Hf.call(this,t,e,r)}}class LayerWrapper{constructor(t,e){this.name=t,this.extent=Ue,this.length=e.length,this._jsonFeatures=e}feature(t){return new FeatureWrapper(this._jsonFeatures[t])}}class GeoJSONWrapper{constructor(t){this.layers={},this.extent=Ue;for(const e of Object.keys(t))this.layers[e]=new LayerWrapper(e,t[e])}}const Xf=64/4096,Zf=128;class GeoJSONRT{constructor(){this.features=new Map}clear(){this.features.clear()}load(t=[],e){for(const r of t){const t=r.id;if(null==t)continue;let n=this.features.get(t);n&&this.updateCache(n,e),r.geometry?(n=Yf(r),this.updateCache(n,e),this.features.set(t,n)):this.features.delete(t),this.updateCache(n,e)}}updateCache(t,e){for(const{canonical:r,uid:n}of Object.values(e)){const{z:i,x:o,y:s}=r;Wf(t,Math.pow(2,i),o,s)&&delete e[n]}}getTile(t,e,r){const n=Math.pow(2,t),i=[];for(const t of this.features.values())Wf(t,n,e,r)&&i.push(ty(t,n,e,r));return{features:i}}getFeatures(){return[...this.features.values()]}}function Wf({minX:t,minY:e,maxX:r,maxY:n},i,o,s){return t<(o+1+Xf)/i&&e<(s+1+Xf)/i&&r>(o-Xf)/i&&n>(s-Xf)/i}function Yf(t){const{id:e,geometry:r,properties:n}=t;if(!r)return;if("GeometryCollection"===r.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:i,coordinates:o}=r,s={id:e,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===i)Jf(o,a,s);else if("MultiPoint"===i)for(const t of o)Jf(t,a,s);else if("LineString"===i)s.type=2,Kf(o,a,s);else if("MultiLineString"===i)s.type=2,Qf(o,a,s);else if("Polygon"===i)s.type=3,Qf(o,a,s,!0);else{if("MultiPolygon"!==i)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const t of o)Qf(t,a,s,!0)}return s}function Jf([t,e],r,n){const i=Lo(t);let o=Vo(e);o=o<0?0:o>1?1:o,r.push(i,o),n.minX=Math.min(n.minX,i),n.minY=Math.min(n.minY,o),n.maxX=Math.max(n.maxX,i),n.maxY=Math.max(n.maxY,o)}function Kf(t,e,r,n=!1,i=!1){const o=[];for(const e of t)Jf(e,o,r);e.push(o),n&&function(t,e){let r=0;for(let e=0,n=t.length,i=n-2;e<n;i=e,e+=2)r+=(t[e]-t[i])*(t[e+1]+t[i+1]);if(r>0===e)for(let e=0,r=t.length;e<r/2;e+=2){const n=t[e],i=t[e+1];t[e]=t[r-2-e],t[e+1]=t[r-1-e],t[r-2-e]=n,t[r-1-e]=i}}(o,i)}function Qf(t,e,r,n=!1){for(let i=0;i<t.length;i++)Kf(t[i],e,r,n,0===i)}function ty(t,e,r,n){const{id:i,type:o,geometry:s,tags:a}=t,l=[];if(1===o)!function(t,e,r,n,i){for(let o=0;o<t.length;o+=2){const s=Math.round(Ue*(t[o+0]*e-r)),a=Math.round(Ue*(t[o+1]*e-n));i.push([s,a])}}(s,e,r,n,l);else if(2===o)for(const t of s)ey(t,e,r,n,l);else if(3===o)for(const t of s)ry(t,e,r,n,l);return{id:i,type:o,geometry:l,tags:a}}function ey(t,e,r,n,i){const o=-Zf,s=Ue+Zf;let a;for(let l=0;l<t.length-2;l+=2){let u=Math.round(Ue*(t[l+0]*e-r)),c=Math.round(Ue*(t[l+1]*e-n)),h=Math.round(Ue*(t[l+2]*e-r)),p=Math.round(Ue*(t[l+3]*e-n));const d=h-u,f=p-c;u<o&&h<o||(u<o?(c+=Math.round(f*((o-u)/d)),u=o):h<o&&(p=c+Math.round(f*((o-u)/d)),h=o),c<o&&p<o||(c<o?(u+=Math.round(d*((o-c)/f)),c=o):p<o&&(h=u+Math.round(d*((o-c)/f)),p=o),u>=s&&h>=s||(u>=s?(c+=Math.round(f*((s-u)/d)),u=s):h>=s&&(p=c+Math.round(f*((s-u)/d)),h=s),c>=s&&p>=s||(c>=s?(u+=Math.round(d*((s-c)/f)),c=s):p>=s&&(h=u+Math.round(d*((s-c)/f)),p=s),a&&u===a[a.length-1][0]&&c===a[a.length-1][1]||(a=[[u,c]],i.push(a)),a.push([h,p])))))}}function ry(t,e,r,n,i){const o=(r-Xf)/e,s=(n-Xf)/e,a=(r+1+Xf)/e,l=(n+1+Xf)/e;function u(t,e){let r=0;return t<o?r|=1:t>a&&(r|=2),e<s?r|=4:e>l&&(r|=8),r}let c=[];for(let e=1;e<=8;e*=2){let r=t[t.length-2],n=t[t.length-1],i=!(u(r,n)&e);for(let h=0;h<t.length;h+=2){const p=t[h],d=t[h+1],f=!(u(p,d)&e);f!==i&&(8&e?c.push(r+(p-r)*(l-n)/(d-n),l):4&e?c.push(r+(p-r)*(s-n)/(d-n),s):2&e?c.push(a,n+(d-n)*(a-r)/(p-r)):1&e&&c.push(o,n+(d-n)*(o-r)/(p-r))),f&&c.push(p,d),r=p,n=d,i=f}if(!(t=c).length||8===e)break;c=[]}const h=[];for(let t=0;t<c.length;t+=2)h.push([Math.round(Ue*(c[t]*e-r)),Math.round(Ue*(c[t+1]*e-n))]);i.push(h)}function ny({name:t,features:e},r){r.writeStringField(1,t),r.writeVarintField(5,Ue);const n=new Map,i=new Map,o={keys:n,values:i,feature:null};for(const t of e)o.feature=t,r.writeMessage(2,iy,o);for(const t of n.keys())r.writeStringField(3,t);for(const t of i.keys())r.writeMessage(4,uy,t)}function iy(t,e){const r=t.feature;void 0!==r.id&&Number.isSafeInteger(+r.id)&&e.writeVarintField(1,+r.id),r.tags&&e.writeMessage(2,oy,t),e.writeVarintField(3,r.type),e.writeMessage(4,ly,r)}function oy({keys:t,values:e,feature:r},n){for(const i of Object.keys(r.tags)){let o=r.tags[i];if(null===o)continue;let s=t.get(i);void 0===s&&(s=t.size,t.set(i,s)),n.writeVarint(s);const a=typeof o;"string"!==a&&"boolean"!==a&&"number"!==a&&(o=JSON.stringify(o));let l=e.get(o);void 0===l&&(l=e.size,e.set(o,l)),n.writeVarint(l)}}function sy(t,e){return(e<<3)+(7&t)}function ay(t){return t<<1^t>>31}function ly(t,e){const{geometry:r,type:n}=t;let i=0,o=0;if(1===n){e.writeVarint(sy(1,r.length));for(const t of r){const r=t[0]-i,n=t[1]-o;e.writeVarint(ay(r)),e.writeVarint(ay(n)),i+=r,o+=n}}else for(const t of r){e.writeVarint(sy(1,1));const r=t.length-(3===n?1:0);for(let n=0;n<r;n++){1===n&&e.writeVarint(sy(2,r-1));const s=t[n][0]-i,a=t[n][1]-o;e.writeVarint(ay(s)),e.writeVarint(ay(a)),i+=s,o+=a}3===n&&e.writeVarint(sy(7,1))}}function uy(t,e){const r=typeof t;"string"===r?e.writeStringField(1,t):"boolean"===r?e.writeBooleanField(7,t):"number"===r&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t))}const cy=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class KDBush{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,r]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=r>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=cy[15&r];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new KDBush(s,o,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=cy.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return hy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:s}=this,a=[0,i.length-1,0],l=[];for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let s=h;s<=c;s++){const a=o[2*s],u=o[2*s+1];a>=t&&a<=r&&u>=e&&u<=n&&l.push(i[s])}continue}const p=h+c>>1,d=o[2*p],f=o[2*p+1];d>=t&&d<=r&&f>=e&&f<=n&&l.push(i[p]),(0===u?t<=d:e<=f)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?r>=d:n>=f)&&(a.push(p+1),a.push(c),a.push(1-u))}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=r*r;for(;s.length;){const u=s.pop()||0,c=s.pop()||0,h=s.pop()||0;if(c-h<=o){for(let r=h;r<=c;r++)yy(i[2*r],i[2*r+1],t,e)<=l&&a.push(n[r]);continue}const p=h+c>>1,d=i[2*p],f=i[2*p+1];yy(d,f,t,e)<=l&&a.push(n[p]),(0===u?t-r<=d:e-r<=f)&&(s.push(h),s.push(p-1),s.push(1-u)),(0===u?t+r>=d:e+r>=f)&&(s.push(p+1),s.push(c),s.push(1-u))}return a}}function hy(t,e,r,n,i,o){if(i-n<=r)return;const s=n+i>>1;py(t,e,s,n,i,o),hy(t,e,r,n,s-1,1-o),hy(t,e,r,s+1,i,1-o)}function py(t,e,r,n,i,o){for(;i>n;){if(i-n>600){const s=i-n+1,a=r-n+1,l=Math.log(s),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(s-u)/s)*(a-s/2<0?-1:1);py(t,e,r,Math.max(n,Math.floor(r-a*u/s+c)),Math.min(i,Math.floor(r+(s-a)*u/s+c)),o)}const s=e[2*r+o];let a=n,l=i;for(dy(t,e,n,r),e[2*i+o]>s&&dy(t,e,n,i);a<l;){for(dy(t,e,a,l),a++,l--;e[2*a+o]<s;)a++;for(;e[2*l+o]>s;)l--}e[2*n+o]===s?dy(t,e,n,l):(l++,dy(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1)}}function dy(t,e,r,n){fy(t,r,n),fy(e,2*r,2*n),fy(e,2*r+1,2*n+1)}function fy(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function yy(t,e,r,n){const i=t-r,o=e-n;return i*i+o*o}const my={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},gy=Math.fround||(xy=new Float32Array(1),t=>(xy[0]=+t,xy[0]));var xy;const vy=3,by=5,wy=6;class Supercluster{constructor(t){this.options=Object.assign(Object.create(my),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:r,maxZoom:n}=this.options;e&&console.time("total time");const i=`prepare ${t.length} points`;e&&console.time(i),this.points=t;const o=[];for(let e=0;e<t.length;e++){const r=t[e];if(!r.geometry)continue;const[n,i]=r.geometry.coordinates,s=gy(Sy(n)),a=gy(Iy(i));o.push(s,a,1/0,e,-1,1),this.options.reduce&&o.push(0)}let s=this.trees[n+1]=this._createTree(o);e&&console.timeEnd(i);for(let t=n;t>=r;t--){const r=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-r)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let r=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let i=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,i=180;else if(r>i){const t=this.getClusters([r,n,180,o],e),s=this.getClusters([-180,n,i,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(Sy(r),Iy(o),Sy(i),Iy(n)),l=s.data,u=[];for(const t of a){const e=this.stride*t;u.push(l[e+by]>1?_y(l,e,this.clusterProps):this.points[l[e+vy]])}return u}getChildren(t){const e=this._getOriginId(t),r=this._getOriginZoom(t),n="No cluster with the specified id.",i=this.trees[r];if(!i)throw new Error(n);const o=i.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=i.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const r=e*this.stride;o[r+4]===t&&l.push(o[r+by]>1?_y(o,r,this.clusterProps):this.points[o[r+vy]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,r){const n=[];return this._appendLeaves(n,t,e=e||10,r=r||0,0),n}getTile(t,e,r){const n=this.trees[this._limitZoom(t)],i=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(r-a)/i,u=(r+1+a)/i,c={features:[]};return this._addTileFeatures(n.range((e-a)/i,l,(e+1+a)/i,u),n.data,e,r,i,c),0===e&&this._addTileFeatures(n.range(1-a/i,l,1,u),n.data,i,r,i,c),e===i-1&&this._addTileFeatures(n.range(0,l,a/i,u),n.data,-1,r,i,c),c.features.length?c:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const r=this.getChildren(t);if(e++,1!==r.length)break;t=r[0].properties.cluster_id}return e}_appendLeaves(t,e,r,n,i){const o=this.getChildren(e);for(const e of o){const o=e.properties;if(o&&o.cluster?i+o.point_count<=n?i+=o.point_count:i=this._appendLeaves(t,o.cluster_id,r,n,i):i<n?i++:t.push(e),t.length===r)break}return i}_createTree(t){const e=new KDBush(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let r=0;r<t.length;r+=this.stride)e.add(t[r],t[r+1]);return e.finish(),e.data=t,e}_addTileFeatures(t,e,r,n,i,o){for(const s of t){const t=s*this.stride,a=e[t+by]>1;let l,u,c;if(a)l=Ay(e,t,this.clusterProps),u=e[t],c=e[t+1];else{const r=this.points[e[t+vy]];l=r.properties;const[n,i]=r.geometry.coordinates;u=Sy(n),c=Iy(i)}const h={type:1,geometry:[[Math.round(this.options.extent*(u*i-r)),Math.round(this.options.extent*(c*i-n))]],tags:l};let p;p=a||this.options.generateId?e[t+vy]:this.points[e[t+vy]].id,void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:r,extent:n,reduce:i,minPoints:o}=this.options,s=r/(n*Math.pow(2,e)),a=t.data,l=[],u=this.stride;for(let r=0;r<a.length;r+=u){if(a[r+2]<=e)continue;a[r+2]=e;const n=a[r],c=a[r+1],h=t.within(a[r],a[r+1],s),p=a[r+by];let d=p;for(const t of h){const r=t*u;a[r+2]>e&&(d+=a[r+by])}if(d>p&&d>=o){let t,o=n*p,s=c*p,f=-1;const y=(r/u<<5)+(e+1)+this.points.length;for(const n of h){const l=n*u;if(a[l+2]<=e)continue;a[l+2]=e;const c=a[l+by];o+=a[l]*c,s+=a[l+1]*c,a[l+4]=y,i&&(t||(t=this._map(a,r,!0),f=this.clusterProps.length,this.clusterProps.push(t)),i(t,this._map(a,l)))}a[r+4]=y,l.push(o/d,s/d,1/0,y,-1,d),i&&l.push(f)}else{for(let t=0;t<u;t++)l.push(a[r+t]);if(d>1)for(const t of h){const r=t*u;if(!(a[r+2]<=e)){a[r+2]=e;for(let t=0;t<u;t++)l.push(a[r+t])}}}}return l}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,r){if(t[e+by]>1){const n=this.clusterProps[t[e+wy]];return r?Object.assign({},n):n}const n=this.points[t[e+vy]].properties,i=this.options.map(n);return r&&i===n?Object.assign({},i):i}}function _y(t,e,r){return{type:"Feature",id:t[e+vy],properties:Ay(t,e,r),geometry:{type:"Point",coordinates:[Py(t[e]),My(t[e+1])]}}}function Ay(t,e,r){const n=t[e+by],i=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+wy],s=-1===o?{}:Object.assign({},r[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+vy],point_count:n,point_count_abbreviated:i})}function Sy(t){return t/360+.5}function Iy(t){const e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function Py(t){return 360*(t-.5)}function My(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function Dy(t,e,r,n){let i=n;const o=e+(r-e>>1);let s,a=r-e;const l=t[e],u=t[e+1],c=t[r],h=t[r+1];for(let n=e+3;n<r;n+=3){const e=Ey(t[n],t[n+1],l,u,c,h);if(e>i)s=n,i=e;else if(e===i){const t=Math.abs(n-o);t<a&&(s=n,a=t)}}i>n&&(s-e>3&&Dy(t,e,s,n),t[s+2]=i,r-s>3&&Dy(t,s,r,n))}function Ey(t,e,r,n,i,o){let s=i-r,a=o-n;if(0!==s||0!==a){const l=((t-r)*s+(e-n)*a)/(s*s+a*a);l>1?(r=i,n=o):l>0&&(r+=s*l,n+=a*l)}return s=t-r,a=e-n,s*s+a*a}function Cy(t,e,r,n){const i={id:t??null,type:e,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===e||"MultiPoint"===e||"LineString"===e)By(i,r);else if("Polygon"===e)By(i,r[0]);else if("MultiLineString"===e)for(const t of r)By(i,t);else if("MultiPolygon"===e)for(const t of r)By(i,t[0]);return i}function By(t,e){for(let r=0;r<e.length;r+=3)t.minX=Math.min(t.minX,e[r]),t.minY=Math.min(t.minY,e[r+1]),t.maxX=Math.max(t.maxX,e[r]),t.maxY=Math.max(t.maxY,e[r+1])}function Ty(t,e,r,n){if(!e.geometry)return;const i=e.geometry.coordinates;if(i&&0===i.length)return;const o=e.geometry.type,s=Math.pow(r.tolerance/((1<<r.maxZoom)*r.extent),2);let a=[],l=e.id;if(r.promoteId?l=e.properties[r.promoteId]:r.generateId&&(l=n||0),"Point"===o)ky(i,a);else if("MultiPoint"===o)for(const t of i)ky(t,a);else if("LineString"===o)zy(i,a,s,!1);else if("MultiLineString"===o){if(r.lineMetrics){for(const r of i)a=[],zy(r,a,s,!1),t.push(Cy(l,"LineString",a,e.properties));return}Ly(i,a,s,!1)}else if("Polygon"===o)Ly(i,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(const i of e.geometry.geometries)Ty(t,{id:l,geometry:i,properties:e.properties},r,n);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const t of i){const e=[];Ly(t,e,s,!0),a.push(e)}}t.push(Cy(l,o,a,e.properties))}function ky(t,e){e.push(Vy(t[0]),Fy(t[1]),0)}function zy(t,e,r,n){let i,o,s=0;for(let r=0;r<t.length;r++){const a=Vy(t[r][0]),l=Fy(t[r][1]);e.push(a,l,0),r>0&&(s+=n?(i*l-a*o)/2:Math.sqrt(Math.pow(a-i,2)+Math.pow(l-o,2))),i=a,o=l}const a=e.length-3;e[2]=1,Dy(e,0,a,r),e[a+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function Ly(t,e,r,n){for(let i=0;i<t.length;i++){const o=[];zy(t[i],o,r,n),e.push(o)}}function Vy(t){return t/360+.5}function Fy(t){const e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function Ry(t,e,r,n,i,o,s,a){if(n/=e,o>=(r/=e)&&s<n)return t;if(s<r||o>=n)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===i?e.minX:e.minY,u=0===i?e.maxX:e.maxY;if(s>=r&&u<n){l.push(e);continue}if(u<r||s>=n)continue;let c=[];if("Point"===o||"MultiPoint"===o)Oy(t,c,r,n,i);else if("LineString"===o)Uy(t,c,r,n,i,!1,a.lineMetrics);else if("MultiLineString"===o)jy(t,c,r,n,i,!1);else if("Polygon"===o)jy(t,c,r,n,i,!0);else if("MultiPolygon"===o)for(const e of t){const t=[];jy(e,t,r,n,i,!0),t.length&&c.push(t)}if(c.length){if(a.lineMetrics&&"LineString"===o){for(const t of c)l.push(Cy(e.id,o,t,e.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===c.length?(o="LineString",c=c[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===c.length?"Point":"MultiPoint"),l.push(Cy(e.id,o,c,e.tags))}}return l.length?l:null}function Oy(t,e,r,n,i){for(let o=0;o<t.length;o+=3){const s=t[o+i];s>=r&&s<=n&&Gy(e,t[o],t[o+1],t[o+2])}}function Uy(t,e,r,n,i,o,s){let a=Ny(t);const l=0===i?$y:qy;let u,c,h=t.start;for(let p=0;p<t.length-3;p+=3){const d=t[p],f=t[p+1],y=t[p+2],m=t[p+3],g=t[p+4],x=0===i?d:f,v=0===i?m:g;let b=!1;s&&(u=Math.sqrt(Math.pow(d-m,2)+Math.pow(f-g,2))),x<r?v>r&&(c=l(a,d,f,m,g,r),s&&(a.start=h+u*c)):x>n?v<n&&(c=l(a,d,f,m,g,n),s&&(a.start=h+u*c)):Gy(a,d,f,y),v<r&&x>=r&&(c=l(a,d,f,m,g,r),b=!0),v>n&&x<=n&&(c=l(a,d,f,m,g,n),b=!0),!o&&b&&(s&&(a.end=h+u*c),e.push(a),a=Ny(t)),s&&(h+=u)}let p=t.length-3;const d=t[p],f=t[p+1],y=0===i?d:f;y>=r&&y<=n&&Gy(a,d,f,t[p+2]),p=a.length-3,o&&p>=3&&(a[p]!==a[0]||a[p+1]!==a[1])&&Gy(a,a[0],a[1],a[2]),a.length&&e.push(a)}function Ny(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function jy(t,e,r,n,i,o){for(const s of t)Uy(s,e,r,n,i,o,!1)}function Gy(t,e,r,n){t.push(e,r,n)}function $y(t,e,r,n,i,o){const s=(o-e)/(n-e);return Gy(t,o,r+(i-r)*s,1),s}function qy(t,e,r,n,i,o){const s=(o-r)/(i-r);return Gy(t,e+(n-e)*s,o,1),s}function Hy(t,e){const r=[];for(let n=0;n<t.length;n++){const i=t[n],o=i.type;let s;if("Point"===o||"MultiPoint"===o||"LineString"===o)s=Xy(i.geometry,e);else if("MultiLineString"===o||"Polygon"===o){s=[];for(const t of i.geometry)s.push(Xy(t,e))}else if("MultiPolygon"===o){s=[];for(const t of i.geometry){const r=[];for(const n of t)r.push(Xy(n,e));s.push(r)}}r.push(Cy(i.id,o,s,i.tags))}return r}function Xy(t,e){const r=[];r.size=t.size,void 0!==t.start&&(r.start=t.start,r.end=t.end);for(let n=0;n<t.length;n+=3)r.push(t[n]+e,t[n+1],t[n+2]);return r}function Zy(t,e){if(t.transformed)return t;const r=1<<t.z,n=t.x,i=t.y;for(const o of t.features){const t=o.geometry,s=o.type;if(o.geometry=[],1===s)for(let s=0;s<t.length;s+=2)o.geometry.push(Wy(t[s],t[s+1],e,r,n,i));else for(let s=0;s<t.length;s++){const a=[];for(let o=0;o<t[s].length;o+=2)a.push(Wy(t[s][o],t[s][o+1],e,r,n,i));o.geometry.push(a)}}return t.transformed=!0,t}function Wy(t,e,r,n,i,o){return[Math.round(r*(t*n-i)),Math.round(r*(e*n-o))]}function Yy(t,e,r,n,i){const o=e===i.maxZoom?0:i.tolerance/((1<<e)*i.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:t.length,source:null,x:r,y:n,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const e of t)Jy(s,e,o,i);return s}function Jy(t,e,r,n){const i=e.geometry,o=e.type,s=[];if(t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),"Point"===o||"MultiPoint"===o)for(let e=0;e<i.length;e+=3)s.push(i[e],i[e+1]),t.numPoints++,t.numSimplified++;else if("LineString"===o)Ky(s,i,t,r,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(let e=0;e<i.length;e++)Ky(s,i[e],t,r,"Polygon"===o,0===e);else if("MultiPolygon"===o)for(let e=0;e<i.length;e++){const n=i[e];for(let e=0;e<n.length;e++)Ky(s,n[e],t,r,!0,0===e)}if(s.length){let r=e.tags||null;if("LineString"===o&&n.lineMetrics){r={};for(const t in e.tags)r[t]=e.tags[t];r.mapbox_clip_start=i.start/i.size,r.mapbox_clip_end=i.end/i.size}const a={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:r};null!==e.id&&(a.id=e.id),t.features.push(a)}}function Ky(t,e,r,n,i,o){const s=n*n;if(n>0&&e.size<(i?s:n))return void(r.numPoints+=e.length/3);const a=[];for(let t=0;t<e.length;t+=3)(0===n||e[t+2]>s)&&(r.numSimplified++,a.push(e[t],e[t+1])),r.numPoints++;i&&function(t,e){let r=0;for(let e=0,n=t.length,i=n-2;e<n;i=e,e+=2)r+=(t[e]-t[i])*(t[e+1]+t[i+1]);if(r>0===e)for(let e=0,r=t.length;e<r/2;e+=2){const n=t[e],i=t[e+1];t[e]=t[r-2-e],t[e+1]=t[r-1-e],t[r-2-e]=n,t[r-1-e]=i}}(a,o),t.push(a)}const Qy={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class GeoJSONVT{constructor(t,e){e=this.options=function(t,e){for(const r in e)t[r]=e[r];return t}(Object.create(Qy),e);const r=e.debug;if(r&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");let n=function(t,e){const r=[];if("FeatureCollection"===t.type)for(let n=0;n<t.features.length;n++)Ty(r,t.features[n],e,n);else Ty(r,"Feature"===t.type?t:{geometry:t},e);return r}(t,e);this.tiles={},this.tileCoords=[],r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),n=function(t,e){const r=e.buffer/e.extent;let n=t;const i=Ry(t,1,-1-r,r,0,-1,2,e),o=Ry(t,1,1-r,2+r,0,-1,2,e);return(i||o)&&(n=Ry(t,1,-r,1+r,0,-1,2,e)||[],i&&(n=Hy(i,1).concat(n)),o&&(n=n.concat(Hy(o,-1)))),n}(n,e),n.length&&this.splitTile(n,0,0,0),r&&(n.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(t,e,r,n,i,o,s){const a=[t,e,r,n],l=this.options,u=l.debug;for(;a.length;){n=a.pop(),r=a.pop(),e=a.pop(),t=a.pop();const c=1<<e,h=tm(e,r,n);let p=this.tiles[h];if(!p&&(u>1&&console.time("creation"),p=this.tiles[h]=Yy(t,e,r,n,l),this.tileCoords.push({z:e,x:r,y:n}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));const t=`z${e}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(p.source=t,null==i){if(e===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===i)continue;if(null!=i){const t=i-e;if(r!==o>>t||n!==s>>t)continue}}if(p.source=null,0===t.length)continue;u>1&&console.time("clipping");const d=.5*l.buffer/l.extent,f=.5-d,y=.5+d,m=1+d;let g=null,x=null,v=null,b=null,w=Ry(t,c,r-d,r+y,0,p.minX,p.maxX,l),_=Ry(t,c,r+f,r+m,0,p.minX,p.maxX,l);t=null,w&&(g=Ry(w,c,n-d,n+y,1,p.minY,p.maxY,l),x=Ry(w,c,n+f,n+m,1,p.minY,p.maxY,l),w=null),_&&(v=Ry(_,c,n-d,n+y,1,p.minY,p.maxY,l),b=Ry(_,c,n+f,n+m,1,p.minY,p.maxY,l),_=null),u>1&&console.timeEnd("clipping"),a.push(g||[],e+1,2*r,2*n),a.push(x||[],e+1,2*r,2*n+1),a.push(v||[],e+1,2*r+1,2*n),a.push(b||[],e+1,2*r+1,2*n+1)}}getTile(t,e,r){t=+t,e=+e,r=+r;const n=this.options,{extent:i,debug:o}=n;if(t<0||t>24)return null;const s=1<<t,a=tm(t,e=e+s&s-1,r);if(this.tiles[a])return Zy(this.tiles[a],i);o>1&&console.log("drilling down to z%d-%d-%d",t,e,r);let l,u=t,c=e,h=r;for(;!l&&u>0;)u--,c>>=1,h>>=1,l=this.tiles[tm(u,c,h)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",u,c,h),console.time("drilling down")),this.splitTile(l.source,u,c,h,t,e,r),o>1&&console.timeEnd("drilling down"),this.tiles[a]?Zy(this.tiles[a],i):null):null}}function tm(t,e,r){return 32*((1<<t)*r+e)+t}function em(t,e){const r=t.tileID.canonical;if(!this._geoJSONIndex)return void e(null,null);const n=this._geoJSONIndex.getTile(r.z,r.x,r.y);if(!n)return void e(null,null);const i=t=>t.tags&&"3d_elevation_id"in t.tags&&"source"in t.tags&&"elevation"===t.tags.source,o=n.features.filter((t=>i(t)));let s={_geojsonTileLayer:n.features};o.length>0&&(s={_geojsonTileLayer:n.features.filter((t=>!i(t))),hd_road_elevation:o});const a=new GeoJSONWrapper(s),l=function(t){const e=new Qc;for(const r of Object.keys(t))e.writeMessage(3,ny,{name:r,features:t[r]});return e.finish()}(s).buffer;e(null,{vectorTile:a,rawData:l})}class GeoJSONWorkerSource extends VectorTileWorkerSource{constructor(t,e,r,n,i,o,s){super(t,e,r,n,i,em,s),o&&(this.loadGeoJSON=o),this._dynamicIndex=new GeoJSONRT}loadData(t,e){const r=t&&t.request,n=r&&r.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(t,((i,o)=>{if(i||!o)return e(i);if("object"!=typeof o)return e(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{try{if(t.filter){const e=wn(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));o.features=o.features.filter((t=>e.value.evaluate({zoom:0},t)))}t.dynamic?("Feature"===o.type&&(o={type:"FeatureCollection",features:[o]}),t.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(o.features,this.loaded),t.cluster&&(o.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=t.cluster?new Supercluster(function({superclusterOptions:t,clusterProperties:e}){if(!e||!t)return t;const r={},n={},i={accumulated:null,zoom:0},o={properties:null},s=Object.keys(e);for(const t of s){const[i,o]=e[t],s=wn(o),a=wn("string"==typeof i?[i,["accumulated"],["get",t]]:i);r[t]=s.value,n[t]=a.value}return t.map=t=>{o.properties=t;const e={};for(const t of s)e[t]=r[t].evaluate(i,o);return e},t.reduce=(t,e)=>{o.properties=e;for(const e of s)i.accumulated=t[e],t[e]=n[e].evaluate(i,o)},t}(t)).load(o.features):t.dynamic?this._dynamicIndex:function(t,e){return new GeoJSONVT(t,e)}(o,t.geojsonVtOptions)}catch(t){return e(t)}const i={};if(n){const e=ti(r);e&&(i.resourceTiming={},i.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)))}e(null,i)}}))}reloadTile(t,e){const r=this.loaded;return r&&r[t.uid]?t.partial?e(null,void 0):super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(t,e){if(t.request)!function(t,e){Gn(Object.assign(t,{type:"json"}),e)}(t.request,e);else{if("string"!=typeof t.data)return e(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));setTimeout((()=>{try{return e(null,JSON.parse(t.data))}catch(r){return e(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}),0)}}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class Tiled3dWorkerTile{constructor(t,e,r){this.tileID=new OverscaledTileID(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=e,this.worldview=r}parse(t,e,r,n){this.status="parsing";const i=new OverscaledTileID(r.tileID.overscaledZ,r.tileID.wrap,r.tileID.canonical.z,r.tileID.canonical.x,r.tileID.canonical.y),o=[],s=e.familiesBySource[r.source],a=new FeatureIndex(i,r.promoteId);a.bucketLayerIDs=[],a.is3DTile=!0,function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==mu){const r=new Uint32Array(t,0,7),[,,n,i,o,s]=r;e=r.byteLength+i+o+s+o,(n!==t.byteLength||e>=t.byteLength)&&vt("Invalid b3dm header information.")}return _u(t,e)}(t).then((t=>{if(!t)return n(new Error("Could not parse tile"));const e=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,l=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new EvaluationParameters(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const n in s)for(const c of s[n]){const n=c[0];a.bucketLayerIDs.push(c.map((t=>Ni(t.id,t.scope)))),n.recalculate(u,[]);const s=Ku(t,1/Go(r.tileID.canonical)),h=new Tiled3dModelBucket(c,s,i,e,l,this.brightness,a,this.worldview);e||(h.needsUpload=!0),o.push(h),h.evaluate(n)}this.status="done",n(null,{buckets:o,featureIndex:a,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})})).catch((t=>n(new Error(t.message))))}}class Tiled3dModelWorkerSource{constructor(t,e,r,n,i,o,s,a){this.actor=t,this.layerIndex=e,this.availableImages=r,this.availableModels=n,this.brightness=s,this.loading={},this.loaded={},this.worldview=a}loadTile(t,e){const r=t.uid,n=this.loading[r]=new Tiled3dWorkerTile(t,this.brightness,this.worldview);$n(t.request,((i,o)=>{const s=!this.loading[r];return delete this.loading[r],s||i?(n.status="done",s||(this.loaded[r]=n),e(i)):o&&0!==o.byteLength?void n.parse(o,this.layerIndex,t,((t,i)=>{n.status="done",this.loaded=this.loaded||{},this.loaded[r]=n,t||!i?e(t):e(null,i)})):(n.status="done",this.loaded[r]=n,e())}))}reloadTile(t,e){const r=this.loaded,n=t.uid;if(r&&r[n]){const i=r[n];i.projection=t.projection,i.brightness=t.brightness;const o=(r,n)=>{i.reloadCallback&&(delete i.reloadCallback,this.loadTile(t,e)),e(r,n)};"parsing"===i.status?i.reloadCallback=o:"done"===i.status&&this.loadTile(t,e)}}abortTile(t,e){const r=t.uid;this.loading[r]&&delete this.loading[r],e()}removeTile(t,e){const r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e()}}const rm={PATH_RULE_NON_ZERO:1,PATH_RULE_EVEN_ODD:2},nm={LINE_CAP_BUTT:1,LINE_CAP_ROUND:2,LINE_CAP_SQUARE:3},im={LINE_JOIN_MITER:1,LINE_JOIN_MITER_CLIP:2,LINE_JOIN_ROUND:3,LINE_JOIN_BEVEL:4},om={PAINT_ORDER_FILL_AND_STROKE:1},sm={PATH_COMMAND_MOVE:1,PATH_COMMAND_LINE:2,PATH_COMMAND_QUAD:3,PATH_COMMAND_CUBIC:4,PATH_COMMAND_CLOSE:5},am={MASK_TYPE_LUMINANCE:1};class ColorReplacements{static calculate(t={},e=[]){const r=new Map,n=new Map;if(0===Object.keys(t).length)return r;e.forEach((t=>{n.set(t.name,t.rgb_color||new Color(0,0,0))}));for(const[e,i]of Object.entries(t))n.has(e)?r.set(n.get(e).toString(),i):console.warn(`Ignoring unknown image variable "${e}"`);return r}}function lm(t,e=255,r){const n=e/255,i=t.toString(),o=r.has(i)?r.get(i).clone():t.clone();return o.a*=n,o.toString()}function um(t,e){if(!vi()){const r=document.createElement("canvas");return r.width=t,r.height=e,r}return new OffscreenCanvas(t,e)}let cm,hm=null;function pm(t,e,r,n,i){for(const o of n.children)dm(t,e,r,o,i)}function dm(t,e,r,n,i){n.group?(t.save(),function(t,e,r,n,i){const o=null!=n.mask_idx?r.masks[n.mask_idx]:null,s=null!=n.clip_path_idx?r.clip_paths[n.clip_path_idx]:null;if(n.transform&&(e=_m(n.transform).preMultiplySelf(e)),!function(t,e,r){return 255!==t.opacity||e||r}(n,null!=s,null!=o))return void pm(t,e,r,n,i);const a=um(t.canvas.width,t.canvas.height),l=a.getContext("2d");pm(l,e,r,n,i),s&&bm(l,e,r,s),o&&wm(l,e,r,o,i),t.globalAlpha=n.opacity/255,t.drawImage(a,0,0)}(t,e,r,n.group,i),t.restore()):n.path&&(t.save(),function(t,e,r,n,i){t.setTransform(e),n.paint_order===om.PAINT_ORDER_FILL_AND_STROKE?(fm(t,r,n,i),mm(t,r,n,i)):(mm(t,r,n,i),fm(t,r,n,i))}(t,e,r,n.path,i),t.restore())}function fm(t,e,r,n){const i=r.fill;if(!i)return;const o=i.opacity/255;switch(t.save(),t.beginPath(),Am(r,t),i.paint){case"rgb_color":t.fillStyle=lm(i.rgb_color,i.opacity,n);break;case"linear_gradient_idx":{const r=e.linear_gradients[i.linear_gradient_idx];r.transform&&t.setTransform(_m(r.transform).preMultiplySelf(t.getTransform())),t.fillStyle=gm(t,r,o,n);break}case"radial_gradient_idx":{const r=e.radial_gradients[i.radial_gradient_idx];r.transform&&t.setTransform(_m(r.transform).preMultiplySelf(t.getTransform())),t.fillStyle=xm(t,r,o,n)}}t.fill(ym(r)),t.restore()}function ym(t){return t.rule===rm.PATH_RULE_NON_ZERO?"nonzero":t.rule===rm.PATH_RULE_EVEN_ODD?"evenodd":void 0}function mm(t,e,r,n){const i=r.stroke;if(!i)return;const o=Sm(r);t.lineWidth=i.width,t.miterLimit=i.miterlimit,t.setLineDash(i.dasharray),t.lineDashOffset=i.dashoffset;const s=i.opacity/255;switch(i.paint){case"rgb_color":t.strokeStyle=lm(i.rgb_color,i.opacity,n);break;case"linear_gradient_idx":t.strokeStyle=gm(t,e.linear_gradients[i.linear_gradient_idx],s,n,!0);break;case"radial_gradient_idx":t.strokeStyle=xm(t,e.radial_gradients[i.radial_gradient_idx],s,n,!0)}switch(i.linejoin){case im.LINE_JOIN_MITER_CLIP:case im.LINE_JOIN_MITER:t.lineJoin="miter";break;case im.LINE_JOIN_ROUND:t.lineJoin="round";break;case im.LINE_JOIN_BEVEL:t.lineJoin="bevel"}switch(i.linecap){case nm.LINE_CAP_BUTT:t.lineCap="butt";break;case nm.LINE_CAP_ROUND:t.lineCap="round";break;case nm.LINE_CAP_SQUARE:t.lineCap="square"}t.stroke(o)}function gm(t,e,r,n,i=!1){if(1===e.stops.length){const t=e.stops[0];return lm(t.rgb_color,t.opacity*r,n)}const{x1:o,y1:s,x2:a,y2:l}=e;let u=new DOMPoint(o,s),c=new DOMPoint(a,l);if(i){const t=_m(e.transform);u=t.transformPoint(u),c=t.transformPoint(c)}const h=t.createLinearGradient(u.x,u.y,c.x,c.y);for(const t of e.stops)h.addColorStop(t.offset,lm(t.rgb_color,t.opacity*r,n));return h}function xm(t,e,r,n,i=!1){if(1===e.stops.length){const t=e.stops[0];return lm(t.rgb_color,t.opacity*r,n)}const o=_m(e.transform),{fx:s,fy:a,fr:l,cx:u,cy:c,r:h}=e;let p=new DOMPoint(s,a),d=new DOMPoint(u,c),f=l,y=h;if(i){p=o.transformPoint(p),d=o.transformPoint(d);const t=(o.a+o.d)/2;f=l*t,y=e.r*t}const m=t.createRadialGradient(p.x,p.y,f,d.x,d.y,y);for(const t of e.stops)m.addColorStop(t.offset,lm(t.rgb_color,t.opacity*r,n));return m}function vm(t,e,r,n){const i=n.transform?_m(n.transform).preMultiplySelf(e):e,o=um(t.canvas.width,t.canvas.height),s=o.getContext("2d");for(const t of n.children)if(t.group)vm(s,i,r,t.group);else if(t.path){const e=t.path,r=new Path2D;r.addPath(Sm(e),i),s.fill(r,ym(e))}const a=null!=n.clip_path_idx?r.clip_paths[n.clip_path_idx]:null;a&&bm(s,i,r,a),t.globalCompositeOperation="source-over",t.drawImage(o,0,0)}function bm(t,e,r,n){const i=um(t.canvas.width,t.canvas.height);vm(i.getContext("2d"),e,r,n),t.globalCompositeOperation="destination-in",t.drawImage(i,0,0)}function wm(t,e,r,n,i){if(0===n.children.length)return;const o=null!=n.mask_idx?r.masks[n.mask_idx]:null;o&&wm(t,e,r,o,i);const s=t.canvas.width,a=t.canvas.height,l=um(s,a),u=l.getContext("2d"),c=n.width,h=n.height,p=n.left,d=n.top,f=new Path2D,y=new Path2D;y.rect(p,d,c,h),f.addPath(y,e),u.clip(f);for(const t of n.children)dm(u,e,r,t,i);const m=u.getImageData(0,0,s,a),g=m.data;if(n.mask_type===am.MASK_TYPE_LUMINANCE)for(let t=0;t<g.length;t+=4)g[t+3]=g[t+3]/255*(.2126*g[t]+.7152*g[t+1]+.0722*g[t+2]);u.putImageData(m,0,0),t.globalCompositeOperation="destination-in",t.drawImage(l,0,0)}function _m(t){return t?new DOMMatrix([t.sx,t.ky,t.kx,t.sy,t.tx,t.ty]):new DOMMatrix}function Am(t,e){const r=t.step;let n=t.diffs[0]*r,i=t.diffs[1]*r;e.moveTo(n,i);for(let o=0,s=2;o<t.commands.length;o++)switch(t.commands[o]){case sm.PATH_COMMAND_MOVE:n+=t.diffs[s++]*r,i+=t.diffs[s++]*r,e.moveTo(n,i);break;case sm.PATH_COMMAND_LINE:n+=t.diffs[s++]*r,i+=t.diffs[s++]*r,e.lineTo(n,i);break;case sm.PATH_COMMAND_QUAD:{const o=n+t.diffs[s++]*r,a=i+t.diffs[s++]*r;n=o+t.diffs[s++]*r,i=a+t.diffs[s++]*r,e.quadraticCurveTo(o,a,n,i);break}case sm.PATH_COMMAND_CUBIC:{const o=n+t.diffs[s++]*r,a=i+t.diffs[s++]*r,l=o+t.diffs[s++]*r,u=a+t.diffs[s++]*r;n=l+t.diffs[s++]*r,i=u+t.diffs[s++]*r,e.bezierCurveTo(o,a,l,u,n,i);break}case sm.PATH_COMMAND_CLOSE:e.closePath()}return e}function Sm(t){return Am(t,new Path2D)}class ImageRasterizer{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(t){return new RGBAImage(t,t.data)}getFromCache(t,e,r){return this.cacheMap.has(r)||this.cacheMap.set(r,new LRUCache(150)),this.cacheMap.get(r).get(Ni(t.toString(),e))}setInCache(t,e,r,n){this.cacheDependenciesMap.has(n)||this.cacheDependenciesMap.set(n,new Map),this.cacheMap.has(n)||this.cacheMap.set(n,new LRUCache(150));const i=this.cacheDependenciesMap.get(n),o=Ni(t.id.toString(),r);i.get(o)||i.set(o,new Set);const s=this.cacheMap.get(n),a=t.toString();i.get(o).add(a),s.put(Ni(t.toString(),r),e)}removeImagesFromCacheByIds(t,e,r=0){if(!this.cacheMap.has(r)||!this.cacheDependenciesMap.has(r))return;const n=this.cacheMap.get(r),i=this.cacheDependenciesMap.get(r);for(const r of t){const t=Ni(r.toString(),e);if(i.has(t)){for(const e of i.get(t))n.delete(e);i.delete(t)}}}rasterize(t,e,r,n){const i=this.getFromCache(t,r,n);if(i)return i.clone();const o=function(t,e){const r=ColorReplacements.calculate(e.params,t.metadata?t.metadata.variables:[]),n=t.usvg_tree,i=n.width,o=n.height,s=Math.max(1,Math.round(i*e.sx)),a=Math.max(1,Math.round(o*e.sy)),l=new DOMMatrix([s/i,0,0,a/o,0,0]);return null===hm&&(hm=um(10,10),cm=hm.getContext("2d",{willReadFrequently:!0})),hm.width=s,hm.height=a,pm(cm,l,n,n,r),cm.getImageData(0,0,s,a)}(e.icon,t),s=ImageRasterizer._getImage(o);return this.setInCache(t,s,r,n),s.clone()}}_t(self)&&(self.worker=new class MapWorker{constructor(t){this.self=t,this.actor=new Actor(t,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new ImageRasterizer,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=$p({name:"mercator"}),this.workerSourceTypes={vector:VectorTileWorkerSource,geojson:GeoJSONWorkerSource,"raster-dem":RasterDEMTileWorkerSource,"raster-array":RasterArrayTileWorkerSource,"batched-model":Tiled3dModelWorkerSource},this.workerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=t=>{if(Ii.isParsed())throw new Error("RTL text plugin already registered.");Ii.setState({pluginStatus:_i,pluginURL:Ii.getPluginURL()}),Ii.applyArabicShaping=t.applyArabicShaping,Ii.processBidirectionalText=t.processBidirectionalText,Ii.processStyledBidirectionalText=t.processStyledBidirectionalText;for(const t of this.rtlPluginParsingListeners)t(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(t,e,r){delete this.layerIndexes[t],delete this.availableImages[t],delete this.availableModels[t],delete this.workerSources[t],r()}checkIfReady(t,e,r){r()}setReferrer(t,e){this.referrer=e}spriteLoaded(t,e){this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={});const{scope:r,isLoaded:n}=e;if(this.isSpriteLoaded[t][r]=n,this.workerSources[t]&&this.workerSources[t][r])for(const e in this.workerSources[t][r]){const i=this.workerSources[t][r][e];for(const t in i){const e=i[t];e instanceof VectorTileWorkerSource&&(e.isSpriteLoaded=n,e.fire(new Event("isSpriteLoaded")))}}}setImages(t,e,r){this.availableImages[t]||(this.availableImages[t]={});const{scope:n,images:i}=e;if(this.availableImages[t][n]=i,this.workerSources[t]&&this.workerSources[t][n]){for(const e in this.workerSources[t][n]){const r=this.workerSources[t][n][e];for(const t in r)r[t].availableImages=i}r()}else r()}setModels(t,{scope:e,models:r},n){if(this.availableModels[t]||(this.availableModels[t]={}),this.availableModels[t][e]=r,this.workerSources[t]&&this.workerSources[t][e]){for(const n in this.workerSources[t][e]){const i=this.workerSources[t][e][n];for(const t in i)i[t].availableModels=r}n()}else n()}setProjection(t,e){this.projections[t]=$p(e)}setBrightness(t,e,r){this.brightness=e,r()}setWorldview(t,e,r){this.worldview=e,r()}setLayers(t,e,r){this.getLayerIndex(t,e.scope).replace(e.layers,e.options),r()}updateLayers(t,e,r){this.getLayerIndex(t,e.scope).update(e.layers,e.removedIds,e.options),r()}loadTile(t,e,r){e.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,e.type,e.source,e.scope).loadTile(e,r)}decodeRasterArray(t,e,r){this.getWorkerSource(t,e.type,e.source,e.scope).decodeRasterArray(e,r)}reloadTile(t,e,r){e.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,e.type,e.source,e.scope).reloadTile(e,r)}abortTile(t,e,r){this.getWorkerSource(t,e.type,e.source,e.scope).abortTile(e,r)}removeTile(t,e,r){this.getWorkerSource(t,e.type,e.source,e.scope).removeTile(e,r)}removeSource(t,e,r){if(!(this.workerSources[t]&&this.workerSources[t][e.scope]&&this.workerSources[t][e.scope][e.type]&&this.workerSources[t][e.scope][e.type][e.source]))return;const n=this.workerSources[t][e.scope][e.type][e.source];delete this.workerSources[t][e.scope][e.type][e.source],void 0!==n.removeSource?n.removeSource(e,r):r()}loadWorkerSource(t,e,r){try{this.self.importScripts(e.url),r()}catch(t){r(t)}}syncRTLPluginState(t,e,r){if(Ii.isParsed())r(null,!0);else if(Ii.isParsing())this.rtlPluginParsingListeners.push(r);else try{Ii.setState(e);const t=Ii.getPluginURL();!Ii.isLoaded()||Ii.isParsed()||Ii.isParsing()||null==t||(Ii.setState({pluginStatus:wi,pluginURL:Ii.getPluginURL()}),this.self.importScripts(t),Ii.isParsed()?r(null,!0):this.rtlPluginParsingListeners.push(r))}catch(t){r(t)}}setDracoUrl(t,e){this.dracoUrl=e}getAvailableImages(t,e){this.availableImages[t]||(this.availableImages[t]={});let r=this.availableImages[t][e];return r||(r=[]),r}getAvailableModels(t,e){this.availableModels[t]||(this.availableModels[t]={});let r=this.availableModels[t][e];return r||(r={}),r}getLayerIndex(t,e){this.layerIndexes[t]||(this.layerIndexes[t]={});let r=this.layerIndexes[t][e];return r||(r=this.layerIndexes[t][e]=new StyleLayerIndex,r.scope=e),r}getWorkerSource(t,e,r,n){const i=this.workerSources;return i[t]||(i[t]={}),i[t][n]||(i[t][n]={}),i[t][n][e]||(i[t][n][e]={}),this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),i[t][n][e][r]||(i[t][n][e][r]=new this.workerSourceTypes[e]({send:(e,r,n,i,o,s)=>this.actor.send(e,r,n,t,o,s),scheduler:this.actor.scheduler},this.getLayerIndex(t,n),this.getAvailableImages(t,n),this.getAvailableModels(t,n),this.isSpriteLoaded[t][n],void 0,this.brightness,this.worldview)),i[t][n][e][r]}rasterizeImagesWorker(t,e,r){const n=new Map;for(const[r,{image:i,imageVariant:o}]of e.tasks.entries()){const s=this.imageRasterizer.rasterize(o,i,e.scope,t);n.set(r,s)}r(void 0,n)}removeRasterizedImages(t,e,r){this.imageRasterizer.removeImagesFromCacheByIds(e.imageIds,e.scope,t),r()}enforceCacheSizeLimit(t,e){!function(t){kn(),null!=Bn&&Bn.then((e=>{e.keys().then((r=>{for(let n=0;n<r.length-t;n++)e.delete(r[n]).catch((t=>vt(t.message)))})).catch((t=>vt(t.message)))})).catch((t=>vt(t.message)))}(e)}getWorkerPerformanceMetrics(t,e,r){r(void 0,void 0)}}(self))}();
//# sourceMappingURL=mapbox-gl-csp-worker.js.map