var maplibregl=function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e=r;function r(t,e){this.x=t,this.y=e}r.prototype={clone:function(){return new r(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),s=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=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},r.convert=function(t){return t instanceof r?t:Array.isArray(t)?new r(t[0],t[1]):t};var n=t(e),s=a;function a(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}a.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 s=this.sampleCurveX(r)-t;if(Math.abs(s)s?o=r:l=r,r=.5*(l-o)+o;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var o=t(s);function l(t,e,r){return Math.min(r,Math.max(e,t))}function u(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}function c(t,e,r){const n={};for(const s in t)n[s]=e.call(r||this,t[s],s,t);return n}function h(t){return Array.isArray(t)?t.map(h):"object"==typeof t&&t?c(t,h):t}new o(.25,.1,.25,1);const p={};function d(t){p[t]||("undefined"!=typeof console&&console.warn(t),p[t]=!0)}function f(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function y(t){let e=0;for(let r,n,s=0,a=t.length,o=a-1;s=c[u+0]&&n>=c[u+1])?(o[p]=!0,a.push(s[p])):o[p]=!1}}}}_forEachCell(t,e,r,n,s,a,o,l){const u=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(r),p=this._convertToCellCoord(n);for(let d=u;d<=h;d++)for(let u=c;u<=p;u++){const c=this.d*u+d;if((!l||l(this._convertFromCellCoord(d),this._convertFromCellCoord(u),this._convertFromCellCoord(d+1),this._convertFromCellCoord(u+1)))&&s.call(this,t,e,r,n,c,a,o,l))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let r=0;for(let t=0;t":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},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:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const S=["type","source","source-layer","minzoom","maxzoom","filter","layout"];class _{constructor(t,e,r,n){this.message=(t?`${t}: `:"")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function I(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}class k extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class A{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r}concat(t){return new A(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 z={kind:"null"},P={kind:"number"},C={kind:"string"},M={kind:"boolean"},B={kind:"color"},V={kind:"object"},E={kind:"value"},T={kind:"collator"},D={kind:"formatted"},F={kind:"padding"},$={kind:"resolvedImage"};function L(t,e){return{kind:"array",itemType:t,N:e}}function O(t){if("array"===t.kind){const e=O(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const U=[z,P,C,M,B,D,V,L(E),F,$];function q(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!q(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 U)if(!q(t,e))return null}return`Expected ${O(t)} but found ${O(e)} instead.`}function j(t,e){return e.some((e=>e.kind===t.kind))}function R(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 N(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Z=.96422,J=.82521,K=4/29,G=6/29,Y=3*G*G,X=G*G*G,H=Math.PI/180,W=180/Math.PI;function Q(t){return(t%=360)<0&&(t+=360),t}function tt([t,e,r,n]){let s,a;const o=rt((.2225045*(t=et(t))+.7168786*(e=et(e))+.0606169*(r=et(r)))/1);t===e&&e===r?s=a=o:(s=rt((.4360747*t+.3850649*e+.1430804*r)/Z),a=rt((.0139322*t+.0971045*e+.7141733*r)/J));const l=116*o-16;return[l<0?0:l,500*(s-o),200*(o-a),n]}function et(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function rt(t){return t>X?Math.pow(t,1/3):t/Y+K}function nt([t,e,r,n]){let s=(t+16)/116,a=isNaN(e)?s:s+e/500,o=isNaN(r)?s:s-r/200;return s=1*st(s),a=Z*st(a),o=J*st(o),[it(3.1338561*a-1.6168667*s-.4906146*o),it(-.9787684*a+1.9161415*s+.033454*o),it(.0719453*a-.2289914*s+1.4052427*o),n]}function it(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function st(t){return t>G?t*t*t:Y*(t-K)}function at(t){return parseInt(t.padEnd(2,t),16)/255}function ot(t,e){return lt(e?t/100:t,0,1)}function lt(t,e,r){return Math.min(Math.max(e,t),r)}function ut(t){return!t.some(Number.isNaN)}const mt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class ct{constructor(t,e,r,n=1,s=!0){this.r=t,this.g=e,this.b=r,this.a=n,s||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,r,n]))}static parse(t){if(t instanceof ct)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase()))return[0,0,0,0];const e=mt[t];if(e){const[t,r,n]=e;return[t/255,r/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let r=1;return[at(t.slice(r,r+=e)),at(t.slice(r,r+=e)),at(t.slice(r,r+=e)),at(t.slice(r,r+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,r,n,s,a,o,l,u,c,h,p,d]=e,f=[s||" ",l||" ",h].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[n,o,c].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[lt(+r/e,0,1),lt(+a/e,0,1),lt(+u/e,0,1),p?ot(+p,d):1];if(ut(t))return t}}return}}const r=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(r){const[t,e,n,s,a,o,l,u,c]=r,h=[n||" ",a||" ",l].join("");if(" "===h||" /"===h||",,"===h||",,,"===h){const t=[+e,lt(+s,0,100),lt(+o,0,100),u?ot(+u,c):1];if(ut(t))return function([t,e,r,n]){function s(n){const s=(n+t/30)%12,a=e*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(s-3,9-s,1))}return t=Q(t),e/=100,r/=100,[s(0),s(8),s(4),n]}(t)}}}(t);return e?new ct(...e,!1):void 0}get rgb(){const{r:t,g:e,b:r,a:n}=this,s=n||1/0;return this.overwriteGetter("rgb",[t/s,e/s,r/s,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,r,n,s]=tt(t),a=Math.sqrt(r*r+n*n);return[Math.round(1e4*a)?Q(Math.atan2(n,r)*W):NaN,a,e,s]}(this.rgb))}get lab(){return this.overwriteGetter("lab",tt(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,r,n]=this.rgb;return`rgba(${[t,e,r].map((t=>Math.round(255*t))).join(",")},${n})`}}ct.black=new ct(0,0,0,1),ct.white=new ct(1,1,1,1),ct.transparent=new ct(0,0,0,0),ct.red=new ct(1,0,0,1);class ht{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 pt{constructor(t,e,r,n,s){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=s}}class dt{constructor(t){this.sections=t}static fromString(t){return new dt([new pt(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof dt?t:dt.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class ft{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof ft)return t;if("number"==typeof t)return new ft([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new ft(t)}}toString(){return JSON.stringify(this.values)}}class yt{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new yt({name:t,available:!1}):null}}function gt(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 xt(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 ct)return!0;if(t instanceof ht)return!0;if(t instanceof dt)return!0;if(t instanceof ft)return!0;if(t instanceof yt)return!0;if(Array.isArray(t)){for(const e of t)if(!xt(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!xt(t[e]))return!1;return!0}return!1}function vt(t){if(null===t)return z;if("string"==typeof t)return C;if("boolean"==typeof t)return M;if("number"==typeof t)return P;if(t instanceof ct)return B;if(t instanceof ht)return T;if(t instanceof dt)return D;if(t instanceof ft)return F;if(t instanceof yt)return $;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=vt(e);if(r){if(r===t)continue;r=E;break}r=t}return L(r||E,e)}return V}function _t(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof ct||t instanceof dt||t instanceof ft||t instanceof yt?t.toString():JSON.stringify(t)}class bt{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(!xt(t[1]))return e.error("invalid value");const r=t[1];let n=vt(r);const s=e.expectedType;return"array"!==n.kind||0!==n.N||!s||"array"!==s.kind||"number"==typeof s.N&&0!==s.N||(n=s),new bt(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class wt{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const kt={string:C,number:P,boolean:M,object:V};class St{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 s=t[0];if("array"===s){let s,a;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in kt)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);s=kt[r],n++}else s=E;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);a=t[2],n++}r=L(s,a)}else{if(!kt[s])throw new Error(`Types doesn't contain name = ${s}`);r=kt[s]}const a=[];for(;nt.outputDefined()))}}const It={"to-boolean":M,"to-color":B,"to-number":P,"to-string":C};class At{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];if(!It[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");const n=It[r],s=[];for(let r=1;r4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:gt(e[0],e[1],e[2],e[3]),!r))return new ct(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new wt(r||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}if("padding"===this.type.kind){let e;for(const r of this.args){e=r.evaluate(t);const n=ft.parse(e);if(n)return n}throw new wt(`Could not parse padding from value '${"string"==typeof e?e: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 wt(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?dt.fromString(_t(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?yt.fromString(_t(this.args[0].evaluate(t))):_t(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ct=["Unknown","Point","LineString","Polygon"];class zt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ct[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||{}}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=ct.parse(t)),e}}class Mt{constructor(t,e,r=[],n,s=new A,a=[]){this.registry=t,this.path=r,this.key=r.map((t=>`[${t}]`)).join(""),this.scope=s,this.errors=a,this.expectedType=n,this._isConstant=e}parse(t,e,r,n,s={}){return e?this.concat(e,r,n)._parse(t,s):this._parse(t,s)}_parse(t,e){function r(t,e,r){return"assert"===r?new St(e,[t]):"coerce"===r?new At(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=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[n];if(s){let n=s.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,s=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==s.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==s.kind&&"string"!==s.kind)if("padding"!==t.kind||"value"!==s.kind&&"number"!==s.kind&&"array"!==s.kind){if(this.checkSubtype(t,s))return null}else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"coerce");else n=r(n,t,e.typeAnnotation||"assert")}if(!(n instanceof bt)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const e=new zt;try{n=new bt(n.type,n.evaluate(e))}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}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){const n="number"==typeof t?this.path.concat(t):this.path,s=r?this.scope.concat(r):this.scope;return new Mt(this.registry,this._isConstant,n,e||null,s,this.errors)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new k(r,t))}checkSubtype(t,e){const r=q(t,e);return r&&this.error(r),r}}class Pt{constructor(t,e,r){this.type=T,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=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,M);if(!n)return null;const s=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,M);if(!s)return null;let a=null;return r.locale&&(a=e.parse(r.locale,1,C),!a)?null:new Pt(n,s,a)}evaluate(t){return new ht(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}}const Bt=8192;function Vt(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 Et(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Tt(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,s=Math.pow(2,e.z);return[Math.round(r*s*Bt),Math.round(n*s*Bt)]}function Dt(t,e,r){const n=t[0]-e[0],s=t[1]-e[1],a=t[0]-r[0],o=t[1]-r[1];return n*o-a*s==0&&n*a<=0&&s*o<=0}function Ft(t,e){let r=!1;for(let o=0,l=e.length;o(n=t)[1]!=(a=l[e+1])[1]>n[1]&&n[0]<(a[0]-s[0])*(n[1]-s[1])/(a[1]-s[1])+s[0]&&(r=!r)}}var n,s,a;return r}function $t(t,e){for(let r=0;r0&&l<0||o<0&&l>0}function Ot(t,e,r){for(const c of r)for(let r=0;rr[2]){const e=.5*n;let s=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===s&&(s=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=s}Vt(e,t)}function Zt(t,e,r,n){const s=Math.pow(2,n.z)*Bt,a=[n.x*Bt,n.y*Bt],o=[];for(const n of t)for(const t of n){const n=[t.x+a[0],t.y+a[1]];Nt(n,e,r,s),o.push(n)}return o}function Yt(t,e,r,n){const s=Math.pow(2,n.z)*Bt,a=[n.x*Bt,n.y*Bt],o=[];for(const r of t){const t=[];for(const n of r){const r=[n.x+a[0],n.y+a[1]];Vt(e,r),t.push(r)}o.push(t)}if(e[2]-e[0]<=s/2){(l=e)[0]=l[1]=1/0,l[2]=l[3]=-1/0;for(const t of o)for(const n of t)Nt(n,e,r,s)}var l;return o}class Jt{constructor(t,e){this.type=M,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(xt(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t!Array.isArray(e)||e.length===t.length-1));let l=null;for(const[n,a]of o){l=new Mt(e.registry,Xt,e.path,null,e.scope);const o=[];let u=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(O).join(", ")})`:`(${O(e.type)}...)`;var e})).join(" | "),n=[];for(let r=1;r{r=e?r&&Xt(t):r&&t instanceof bt})),!!r&&Ht(t)&&Qt(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Ht(t){if(t instanceof Kt){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 Jt)return!1;let e=!0;return t.eachChild((t=>{e&&!Ht(t)&&(e=!1)})),e}function Wt(t){if(t instanceof Kt&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Wt(t)&&(e=!1)})),e}function Qt(t,e){if(t instanceof Kt&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild((t=>{r&&!Qt(t,e)&&(r=!1)})),r}function ee(t,e){const r=t.length-1;let n,s,a=0,o=r,l=0;for(;a<=o;)if(l=Math.floor((a+o)/2),n=t[l],s=t[l+1],n<=e){if(l===r||ee))throw new wt("Input is not a number.");o=l-1}return 0}class te{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,P);if(!r)return null;const n=[];let s=null;e.expectedType&&"value"!==e.expectedType.kind&&(s=e.expectedType);for(let r=1;r=a)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',l);const c=e.parse(o,u,s);if(!c)return null;s=s||c.type,n.push([a,c])}return new te(s,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 s=e.length;return n>=e[s-1]?r[s-1].evaluate(t):r[ee(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()))}}function re(t,e,r){return t+r*(e-t)}function ne(t,e,r){return t.map(((t,n)=>re(t,e[n],r)))}const se={number:re,color:function(t,e,r,n="rgb"){switch(n){case"rgb":{const[n,s,a,o]=ne(t.rgb,e.rgb,r);return new ct(n,s,a,o,!1)}case"hcl":{const[n,s,a,o]=t.hcl,[l,u,c,h]=e.hcl;let p,d;if(isNaN(n)||isNaN(l))isNaN(n)?isNaN(l)?p=NaN:(p=l,1!==a&&0!==a||(d=u)):(p=n,1!==c&&0!==c||(d=s));else{let t=l-n;l>n&&t>180?t-=360:l180&&(t+=360),p=n+r*t}const[f,y,m,g]=function([t,e,r,n]){return t=isNaN(t)?0:t*H,nt([r,Math.cos(t)*e,Math.sin(t)*e,n])}([p,null!=d?d:re(s,u,r),re(a,c,r),re(o,h,r)]);return new ct(f,y,m,g,!1)}case"lab":{const[n,s,a,o]=nt(ne(t.lab,e.lab,r));return new ct(n,s,a,o,!1)}}},array:ne,padding:function(t,e,r){return new ft(ne(t.values,e.values,r))}};class ie{constructor(t,e,r,n,s){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of s)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,r,n){let s=0;if("exponential"===t.name)s=fe(e,t.base,r,n);else if("linear"===t.name)s=fe(e,1,r,n);else if("cubic-bezier"===t.name){const a=t.controlPoints;s=new o(a[0],a[1],a[2],a[3]).solve(fe(e,1,r,n))}return s}static parse(t,e){let[r,n,s,...a]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t}}else{if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(s=e.parse(s,2,P),!s)return null;const o=[];let l=null;"interpolate-hcl"===r||"interpolate-lab"===r?l=B:e.expectedType&&"value"!==e.expectedType.kind&&(l=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',s);const c=e.parse(n,u,l);if(!c)return null;l=l||c.type,o.push([r,c])}return N(l,P)||N(l,B)||N(l,F)||N(l,L(P))?new ie(l,r,n,s,o):e.error(`Type ${O(l)} 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 s=e.length;if(n>=e[s-1])return r[s-1].evaluate(t);const a=ee(e,n),o=ie.interpolationFactor(this.interpolation,n,e[a],e[a+1]),l=r[a].evaluate(t),u=r[a+1].evaluate(t);switch(this.operator){case"interpolate":return se[this.type.kind](l,u,o);case"interpolate-hcl":return se.color(l,u,o,"hcl");case"interpolate-lab":return se.color(l,u,o,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function fe(t,e,r,n){const s=n-r,a=t-r;return 0===s?0:1===e?a/s:(Math.pow(e,a)-1)/(Math.pow(e,s)-1)}class ae{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 s=[];for(const n of t.slice(1)){const t=e.parse(n,1+s.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,s.push(t)}if(!r)throw new Error("No output type");const a=n&&s.some((t=>q(n,t.type)));return new ae(a?E:r,s)}evaluate(t){let e,r=null,n=0;for(const s of this.args)if(n++,r=s.evaluate(t),r&&r instanceof yt&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null!==r)break;return r}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}class oe{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=r.length)throw new wt(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new wt(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class ue{constructor(t,e){this.type=M,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,E),n=e.parse(t[2],2,E);return r&&n?j(r.type,[M,C,P,z,E])?new ue(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${O(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!r)return!1;if(!R(e,["boolean","string","number","null"]))throw new wt(`Expected first argument to be of type boolean, string, number or null, but found ${O(vt(e))} instead.`);if(!R(r,["string","array"]))throw new wt(`Expected second argument to be of type array or string, but found ${O(vt(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class ce{constructor(t,e,r){this.type=P,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,E),n=e.parse(t[2],2,E);if(!r||!n)return null;if(!j(r.type,[M,C,P,z,E]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${O(r.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,P);return s?new ce(r,n,s):null}return new ce(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!R(e,["boolean","string","number","null"]))throw new wt(`Expected first argument to be of type boolean, string, number or null, but found ${O(vt(e))} instead.`);if(!R(r,["string","array"]))throw new wt(`Expected second argument to be of type array or string, but found ${O(vt(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}}class he{constructor(t,e,r,n,s,a){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=s,this.otherwise=a}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const s={},a=[];for(let o=2;oNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(r){if(c.checkSubtype(r,vt(t)))return null}else r=vt(t);if(void 0!==s[String(t)])return c.error("Branch labels must be unique.");s[String(t)]=a.length}const h=e.parse(u,o,n);if(!h)return null;n=n||h.type,a.push(h)}const o=e.parse(t[1],1,E);if(!o)return null;const l=e.parse(t[t.length-1],t.length-1,n);return l?"value"!==o.type.kind&&e.concat(1).checkSubtype(r,o.type)?null:new he(r,n,o,s,a,l):null}evaluate(t){const e=this.input.evaluate(t);return(vt(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()}}class pe{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 s=1;se.outputDefined()))&&this.otherwise.outputDefined()}}class de{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,E),n=e.parse(t[2],2,P);if(!r||!n)return null;if(!j(r.type,[L(E),C,E]))return e.error(`Expected first argument to be of type array or string, but found ${O(r.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,P);return s?new de(r.type,r,n,s):null}return new de(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!R(e,["string","array"]))throw new wt(`Expected first argument to be of type array or string, but found ${O(vt(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}}function ye(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 me(t,e,r,n){return 0===n.compare(e,r)}function ge(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=M,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 s=e.parse(t[1],1,E);if(!s)return null;if(!ye(r,s.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${O(s.type)}'.`);let a=e.parse(t[2],2,E);if(!a)return null;if(!ye(r,a.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${O(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${O(s.type)}' and '${O(a.type)}'.`);n&&("value"===s.type.kind&&"value"!==a.type.kind?s=new St(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new St(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,T),!o)return null}return new i(s,a,o)}evaluate(s){const a=this.lhs.evaluate(s),o=this.rhs.evaluate(s);if(n&&this.hasUntypedArgument){const e=vt(a),r=vt(o);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new wt(`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=vt(a),r=vt(o);if("string"!==t.kind||"string"!==r.kind)return e(s,a,o)}return this.collator?r(s,a,o,this.collator.evaluate(s)):e(s,a,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const xe=ge("==",(function(t,e,r){return e===r}),me),ve=ge("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return!me(0,e,r,n)})),be=ge("<",(function(t,e,r){return e",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),_e=ge("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),ze=ge(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class Se{constructor(t,e,r,n,s){this.type=C,this.number=t,this.locale=e,this.currency=r,this.minFractionDigits=n,this.maxFractionDigits=s}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,P);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 s=null;if(n.locale&&(s=e.parse(n.locale,1,C),!s))return null;let a=null;if(n.currency&&(a=e.parse(n.currency,1,C),!a))return null;let o=null;if(n["min-fraction-digits"]&&(o=e.parse(n["min-fraction-digits"],1,P),!o))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parse(n["max-fraction-digits"],1,P),!l)?null:new Se(r,s,a,o,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class ke{constructor(t){this.type=D,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 s=!1;for(let r=1;r<=t.length-1;++r){const a=t[r];if(s&&"object"==typeof a&&!Array.isArray(a)){s=!1;let t=null;if(a["font-scale"]&&(t=e.parse(a["font-scale"],1,P),!t))return null;let r=null;if(a["text-font"]&&(r=e.parse(a["text-font"],1,L(C)),!r))return null;let o=null;if(a["text-color"]&&(o=e.parse(a["text-color"],1,B),!o))return null;const l=n[n.length-1];l.scale=t,l.font=r,l.textColor=o}else{const a=e.parse(t[r],1,E);if(!a)return null;const o=a.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,n.push({content:a,scale:null,font:null,textColor:null})}}return new ke(n)}evaluate(t){return new dt(this.sections.map((e=>{const r=e.content.evaluate(t);return vt(r)===$?new pt("",r,null,null,null):new pt(_t(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}}class Ae{constructor(t){this.type=$,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,C);return r?new Ae(r):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),r=yt.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r}eachChild(t){t(this.input)}outputDefined(){return!1}}class Ie{constructor(t){this.type=P,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 ${O(r.type)} instead.`):new Ie(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 wt(`Expected value to be of type string or array, but found ${O(vt(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const Pe={"==":xe,"!=":ve,">":we,"<":be,">=":ze,"<=":_e,array:St,at:le,boolean:St,case:pe,coalesce:ae,collator:Pt,format:ke,image:Ae,in:ue,"index-of":ce,interpolate:ie,"interpolate-hcl":ie,"interpolate-lab":ie,length:Ie,let:oe,literal:bt,match:he,number:St,"number-format":Se,object:St,slice:de,step:te,string:St,"to-boolean":At,"to-color":At,"to-number":At,"to-string":At,var:Gt,within:Jt};function Ce(t,[e,r,n,s]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const a=s?s.evaluate(t):1,o=gt(e,r,n,a);if(o)throw new wt(o);return new ct(e/255,r/255,n/255,a,!1)}function Me(t,e){return t in e}function Be(t,e){const r=e[t];return void 0===r?null:r}function Ve(t){return{type:t}}function Ee(t){return{result:"success",value:t}}function Te(t){return{result:"error",value:t}}function De(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function Fe(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function $e(t){return!!t.expression&&t.expression.interpolated}function Le(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Oe(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Ue(t){return t}function qe(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],s=n||!(n||void 0!==t.property),a=t.type||($e(e)?"exponential":"interval");if(r||"padding"===e.type){const n=r?ct.parse:ft.parse;(t=I({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],n(t[1])]))),t.default=n(t.default?t.default:e.default)}if(t.colorSpace&&"rgb"!==(o=t.colorSpace)&&"hcl"!==o&&"lab"!==o)throw new Error(`Unknown color space: "${t.colorSpace}"`);var o;let l,u,c;if("exponential"===a)l=Ze;else if("interval"===a)l=Ne;else if("categorical"===a){l=Re,u=Object.create(null);for(const e of t.stops)u[e[0]]=e[1];c=typeof t.stops[0][0]}else{if("identity"!==a)throw new Error(`Unknown function type "${a}"`);l=Ke}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>Ze({stops:s,base:t.base},e,r).evaluate(r,n)}}if(s){const r="exponential"===a?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:r,interpolationFactor:ie.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>l(t,e,r,u,c)}}return{kind:"source",evaluate(r,n){const s=n&&n.properties?n.properties[t.property]:void 0;return void 0===s?je(t.default,e.default):l(t,e,s,u,c)}}}function je(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function Re(t,e,r,n,s){return je(typeof r===s?n[r]:void 0,t.default,e.default)}function Ne(t,e,r){if("number"!==Le(r))return je(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 s=ee(t.stops.map((t=>t[0])),r);return t.stops[s][1]}function Ze(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==Le(r))return je(t.default,e.default);const s=t.stops.length;if(1===s)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[s-1][0])return t.stops[s-1][1];const a=ee(t.stops.map((t=>t[0])),r),o=function(t,e,r,n){const s=n-r,a=t-r;return 0===s?0:1===e?a/s:(Math.pow(e,a)-1)/(Math.pow(e,s)-1)}(r,n,t.stops[a][0],t.stops[a+1][0]),l=t.stops[a][1],u=t.stops[a+1][1],c=se[e.type]||Ue;return"function"==typeof l.evaluate?{evaluate(...e){const r=l.evaluate.apply(void 0,e),n=u.evaluate.apply(void 0,e);if(void 0!==r&&void 0!==n)return c(r,n,o,t.colorSpace)}}:c(l,u,o,t.colorSpace)}function Ke(t,e,r){switch(e.type){case"color":r=ct.parse(r);break;case"formatted":r=dt.fromString(r.toString());break;case"resolvedImage":r=yt.fromString(r.toString());break;case"padding":r=ft.parse(r);break;default:Le(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0)}return je(r,t.default,e.default)}Kt.register(Pe,{error:[{kind:"error"},[C],(t,[e])=>{throw new wt(e.evaluate(t))}],typeof:[C,[E],(t,[e])=>O(vt(e.evaluate(t)))],"to-rgba":[L(P,4),[B],(t,[e])=>{const[r,n,s,a]=e.evaluate(t).rgb;return[255*r,255*n,255*s,a]}],rgb:[B,[P,P,P],Ce],rgba:[B,[P,P,P,P],Ce],has:{type:M,overloads:[[[C],(t,[e])=>Me(e.evaluate(t),t.properties())],[[C,V],(t,[e,r])=>Me(e.evaluate(t),r.evaluate(t))]]},get:{type:E,overloads:[[[C],(t,[e])=>Be(e.evaluate(t),t.properties())],[[C,V],(t,[e,r])=>Be(e.evaluate(t),r.evaluate(t))]]},"feature-state":[E,[C],(t,[e])=>Be(e.evaluate(t),t.featureState||{})],properties:[V,[],t=>t.properties()],"geometry-type":[C,[],t=>t.geometryType()],id:[E,[],t=>t.id()],zoom:[P,[],t=>t.globals.zoom],"heatmap-density":[P,[],t=>t.globals.heatmapDensity||0],"line-progress":[P,[],t=>t.globals.lineProgress||0],accumulated:[E,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[P,Ve(P),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[P,Ve(P),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:P,overloads:[[[P,P],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[P],(t,[e])=>-e.evaluate(t)]]},"/":[P,[P,P],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[P,[P,P],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[P,[],()=>Math.LN2],pi:[P,[],()=>Math.PI],e:[P,[],()=>Math.E],"^":[P,[P,P],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[P,[P],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[P,[P],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[P,[P],(t,[e])=>Math.log(e.evaluate(t))],log2:[P,[P],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[P,[P],(t,[e])=>Math.sin(e.evaluate(t))],cos:[P,[P],(t,[e])=>Math.cos(e.evaluate(t))],tan:[P,[P],(t,[e])=>Math.tan(e.evaluate(t))],asin:[P,[P],(t,[e])=>Math.asin(e.evaluate(t))],acos:[P,[P],(t,[e])=>Math.acos(e.evaluate(t))],atan:[P,[P],(t,[e])=>Math.atan(e.evaluate(t))],min:[P,Ve(P),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[P,Ve(P),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[P,[P],(t,[e])=>Math.abs(e.evaluate(t))],round:[P,[P],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[P,[P],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[P,[P],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[M,[C,E],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[M,[E],(t,[e])=>t.id()===e.value],"filter-type-==":[M,[C],(t,[e])=>t.geometryType()===e.value],"filter-<":[M,[C,E],(t,[e,r])=>{const n=t.properties()[e.value],s=r.value;return typeof n==typeof s&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r":[M,[C,E],(t,[e,r])=>{const n=t.properties()[e.value],s=r.value;return typeof n==typeof s&&n>s}],"filter-id->":[M,[E],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[M,[C,E],(t,[e,r])=>{const n=t.properties()[e.value],s=r.value;return typeof n==typeof s&&n<=s}],"filter-id-<=":[M,[E],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[M,[C,E],(t,[e,r])=>{const n=t.properties()[e.value],s=r.value;return typeof n==typeof s&&n>=s}],"filter-id->=":[M,[E],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[M,[E],(t,[e])=>e.value in t.properties()],"filter-has-id":[M,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[M,[L(C)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[M,[L(E)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[M,[C,L(E)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[M,[C,L(E)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const s=r+n>>1;if(e[s]===t)return!0;e[s]>t?n=s-1:r=s+1}return!1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:M,overloads:[[[M,M],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[Ve(M),(t,e)=>{for(const r of e)if(!r.evaluate(t))return!1;return!0}]]},any:{type:M,overloads:[[[M,M],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[Ve(M),(t,e)=>{for(const r of e)if(r.evaluate(t))return!0;return!1}]]},"!":[M,[M],(t,[e])=>!e.evaluate(t)],"is-supported-script":[M,[C],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return!r||r(e.evaluate(t))}],upcase:[C,[C],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[C,[C],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[C,Ve(E),(t,e)=>e.map((e=>_t(e.evaluate(t)))).join("")],"resolved-locale":[C,[T],(t,[e])=>e.evaluate(t).resolvedLocale()]});class Je{constructor(t,e){var r;this.expression=t,this._warningHistory={},this._evaluator=new zt,this._defaultValue=e?"color"===(r=e).type&&Oe(r.default)?new ct(0,0,0,0):"color"===r.type?ct.parse(r.default)||null:"padding"===r.type?ft.parse(r.default)||null:void 0===r.default?null:r.default:null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,r,n,s,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=a,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,s,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=a||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 wt(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Ge(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Pe}function He(t,e){const r=new Mt(Pe,Xt,[],e?function(t){const e={color:B,string:C,number:P,enum:C,boolean:M,formatted:D,padding:F,resolvedImage:$};return"array"===t.type?L(e[t.value]||E,t.length):e[t.type]}(e):void 0),n=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?Ee(new Je(n,e)):Te(r.errors)}class Xe{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Wt(e.expression)}evaluateWithoutErrorHandling(t,e,r,n,s,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,s,a)}evaluate(t,e,r,n,s,a){return this._styleExpression.evaluate(t,e,r,n,s,a)}}class Ye{constructor(t,e,r,n){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Wt(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,r,n,s,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,s,a)}evaluate(t,e,r,n,s,a){return this._styleExpression.evaluate(t,e,r,n,s,a)}interpolationFactor(t,e,r){return this.interpolationType?ie.interpolationFactor(this.interpolationType,t,e,r):0}}function Qe(t,e){const r=He(t,e);if("error"===r.result)return r;const n=r.value.expression,s=Ht(n);if(!s&&!De(e))return Te([new k("","data expressions not supported")]);const a=Qt(n,["zoom"]);if(!a&&!Fe(e))return Te([new k("","zoom expressions not supported")]);const o=tr(n);return o||a?o instanceof k?Te([o]):o instanceof ie&&!$e(e)?Te([new k("",'"interpolate" expressions cannot be used with this property')]):Ee(o?new Ye(s?"camera":"composite",r.value,o.labels,o instanceof ie?o.interpolation:void 0):new Xe(s?"constant":"source",r.value)):Te([new k("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class We{constructor(t,e){this._parameters=t,this._specification=e,I(this,qe(this._parameters,this._specification))}static deserialize(t){return new We(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function tr(t){let e=null;if(t instanceof oe)e=tr(t.result);else if(t instanceof ae){for(const r of t.args)if(e=tr(r),e)break}else(t instanceof te||t instanceof ie)&&t.input instanceof Kt&&"zoom"===t.input.name&&(e=t);return e instanceof k||t.eachChild((t=>{const r=tr(t);r instanceof k?e=r:!e&&r?e=new k("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&r&&e!==r&&(e=new k("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function er(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(!er(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const rr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function nr(t){if(null==t)return{filter:()=>!0,needGeometry:!1};er(t)||(t=ar(t));const e=He(t,rr);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,r,n)=>e.value.evaluate(t,r,{},n),needGeometry:sr(t)}}function ir(t,e){return te?1:0}function sr(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?or(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(ar))):"all"===e?["all"].concat(t.slice(1).map(ar)):"none"===e?["all"].concat(t.slice(1).map(ar).map(cr)):"in"===e?lr(t[1],t.slice(2)):"!in"===e?cr(lr(t[1],t.slice(2))):"has"===e?ur(t[1]):"!has"===e?cr(ur(t[1])):"within"!==e||t;var r}function or(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 lr(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(ir)]]:["filter-in-small",t,["literal",e]]}}function ur(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function cr(t){return["!",t]}function hr(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const r of t)e+=`${hr(r)},`;return`${e}]`}const r=Object.keys(t).sort();let n="{";for(let e=0;en.maximum?[new _(e,r,`${r} is greater than the maximum value ${n.maximum}`)]:[]}function vr(t){const e=t.valueSpec,r=fr(t.value.type);let n,s,a,o={};const l="categorical"!==r&&void 0===t.value.property,u=!l,c="array"===Le(t.value.stops)&&"array"===Le(t.value.stops[0])&&"object"===Le(t.value.stops[0][0]),h=mr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return[new _(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(gr({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:p})),"array"===Le(n)&&0===n.length&&e.push(new _(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===r&&l&&h.push(new _(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||h.push(new _(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!$e(t.valueSpec)&&h.push(new _(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(u&&!De(t.valueSpec)?h.push(new _(t.key,t.value,"property functions not supported")):l&&!Fe(t.valueSpec)&&h.push(new _(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!c||void 0!==t.value.property||h.push(new _(t.key,t.value,'"property" property is required')),h;function p(t){let r=[];const n=t.value,l=t.key;if("array"!==Le(n))return[new _(l,n,`array expected, ${Le(n)} found`)];if(2!==n.length)return[new _(l,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Le(n[0]))return[new _(l,n,`object expected, ${Le(n[0])} found`)];if(void 0===n[0].zoom)return[new _(l,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new _(l,n,"object stop key must have value")];if(a&&a>fr(n[0].zoom))return[new _(l,n[0].zoom,"stop zoom values must appear in ascending order")];fr(n[0].zoom)!==a&&(a=fr(n[0].zoom),s=void 0,o={}),r=r.concat(mr({key:`${l}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:xr,value:d}}))}else r=r.concat(d({key:`${l}[0]`,value:n[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},n));return Ge(yr(n[1]))?r.concat([new _(`${l}[1]`,n[1],"expressions are not allowed in function stops.")]):r.concat(t.validateSpec({key:`${l}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function d(t,a){const l=Le(t.value),u=fr(t.value),c=null!==t.value?t.value:a;if(n){if(l!==n)return[new _(t.key,c,`${l} stop domain type must match previous stop domain type ${n}`)]}else n=l;if("number"!==l&&"string"!==l&&"boolean"!==l)return[new _(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==r){let n=`number expected, ${l} found`;return De(e)&&void 0===r&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new _(t.key,c,n)]}return"categorical"!==r||"number"!==l||isFinite(u)&&Math.floor(u)===u?"categorical"!==r&&"number"===l&&void 0!==s&&unew _(`${t.key}${e.key}`,t.value,e.message)));const r=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return[new _(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Wt(r))return[new _(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Wt(r))return[new _(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Qt(r,["zoom","feature-state"]))return[new _(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Ht(r))return[new _(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function wr(t){const e=t.key,r=t.value,n=t.valueSpec,s=[];return Array.isArray(n.values)?-1===n.values.indexOf(fr(r))&&s.push(new _(e,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(fr(r))&&s.push(new _(e,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),s}function _r(t){return er(yr(t.value))?br(I({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):kr(t)}function kr(t){const e=t.value,r=t.key;if("array"!==Le(e))return[new _(r,e,`array expected, ${Le(e)} found`)];const n=t.styleSpec;let s,a=[];if(e.length<1)return[new _(r,e,"filter array must have at least 1 element")];switch(a=a.concat(wr({key:`${r}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),fr(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===fr(e[1])&&a.push(new _(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&a.push(new _(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(s=Le(e[1]),"string"!==s&&a.push(new _(`${r}[1]`,e[1],`string expected, ${s} found`)));for(let o=2;o{t in r&&e.push(new _(n,r[t],`"${t}" is prohibited for ref layers`))})),s.layers.forEach((e=>{fr(e.id)===l&&(t=e)})),t?t.ref?e.push(new _(n,r.ref,"ref cannot reference another ref layer")):o=fr(t.type):e.push(new _(n,r.ref,`ref layer "${l}" not found`))}else if("background"!==o)if(r.source){const t=s.sources&&s.sources[r.source],a=t&&fr(t.type);t?"vector"===a&&"raster"===o?e.push(new _(n,r.source,`layer "${r.id}" requires a raster source`)):"raster"===a&&"raster"!==o?e.push(new _(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==a||r["source-layer"]?"raster-dem"===a&&"hillshade"!==o?e.push(new _(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==o||!r.paint||!r.paint["line-gradient"]||"geojson"===a&&t.lineMetrics||e.push(new _(n,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new _(n,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new _(n,r.source,`source "${r.source}" not found`))}else e.push(new _(n,r,'missing required property "source"'));return e=e.concat(mr({key:n,value:r,valueSpec:a.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${n}.type`,value:r.type,valueSpec:a.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:r,objectKey:"type"}),filter:_r,layout:t=>mr({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Ir(I({layerType:o},t))}}),paint:t=>mr({layer:r,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Ar(I({layerType:o},t))}})}})),e}function Pr(t){const e=t.value,r=t.key,n=Le(e);return"string"!==n?[new _(r,e,`string expected, ${n} found`)]:[]}const Cr={promoteId:function({key:t,value:e}){if("string"===Le(e))return Pr({key:t,value:e});{const r=[];for(const n in e)r.push(...Pr({key:`${t}.${n}`,value:e[n]}));return r}}};function Mr(t){const e=t.value,r=t.key,n=t.styleSpec,s=t.style,a=t.validateSpec;if(!e.type)return[new _(r,e,'"type" is required')];const o=fr(e.type);let l;switch(o){case"vector":case"raster":case"raster-dem":return l=mr({key:r,value:e,valueSpec:n[`source_${o.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:Cr,validateSpec:a}),l;case"geojson":if(l=mr({key:r,value:e,valueSpec:n.source_geojson,style:s,styleSpec:n,validateSpec:a,objectElementValidators:Cr}),e.cluster)for(const t in e.clusterProperties){const[n,s]=e.clusterProperties[t],o="string"==typeof n?[n,["accumulated"],["get",t]]:n;l.push(...br({key:`${r}.${t}.map`,value:s,validateSpec:a,expressionContext:"cluster-map"})),l.push(...br({key:`${r}.${t}.reduce`,value:o,validateSpec:a,expressionContext:"cluster-reduce"}))}return l;case"video":return mr({key:r,value:e,valueSpec:n.source_video,style:s,validateSpec:a,styleSpec:n});case"image":return mr({key:r,value:e,valueSpec:n.source_image,style:s,validateSpec:a,styleSpec:n});case"canvas":return[new _(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return wr({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:s,validateSpec:a,styleSpec:n})}}function Br(t){const e=t.value,r=t.styleSpec,n=r.light,s=t.style;let a=[];const o=Le(e);if(void 0===e)return a;if("object"!==o)return a=a.concat([new _("light",e,`object expected, ${o} found`)]),a;for(const o in e){const l=o.match(/^(.*)-transition$/);a=a.concat(l&&n[l[1]]&&n[l[1]].transition?t.validateSpec({key:o,value:e[o],valueSpec:r.transition,validateSpec:t.validateSpec,style:s,styleSpec:r}):n[o]?t.validateSpec({key:o,value:e[o],valueSpec:n[o],validateSpec:t.validateSpec,style:s,styleSpec:r}):[new _(o,e[o],`unknown property "${o}"`)])}return a}function Vr(t){const e=t.value,r=t.styleSpec,n=r.terrain,s=t.style;let a=[];const o=Le(e);if(void 0===e)return a;if("object"!==o)return a=a.concat([new _("terrain",e,`object expected, ${o} found`)]),a;for(const o in e)a=a.concat(n[o]?t.validateSpec({key:o,value:e[o],valueSpec:n[o],validateSpec:t.validateSpec,style:s,styleSpec:r}):[new _(o,e[o],`unknown property "${o}"`)]);return a}function Er(t){let e=[];const r=t.value,n=t.key;if(Array.isArray(r)){const s=[],a=[];for(const o in r)r[o].id&&s.includes(r[o].id)&&e.push(new _(n,r,`all the sprites' ids must be unique, but ${r[o].id} is duplicated`)),s.push(r[o].id),r[o].url&&a.includes(r[o].url)&&e.push(new _(n,r,`all the sprites' URLs must be unique, but ${r[o].url} is duplicated`)),a.push(r[o].url),e=e.concat(mr({key:`${n}[${o}]`,value:r[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Pr({key:n,value:r})}const Tr={"*":()=>[],array:gr,boolean:function(t){const e=t.value,r=t.key,n=Le(e);return"boolean"!==n?[new _(r,e,`boolean expected, ${n} found`)]:[]},number:xr,color:function(t){const e=t.key,r=t.value,n=Le(r);return"string"!==n?[new _(e,r,`color expected, ${n} found`)]:ct.parse(String(r))?[]:[new _(e,r,`color expected, "${r}" found`)]},constants:dr,enum:wr,filter:_r,function:vr,layer:zr,object:mr,source:Mr,light:Br,terrain:Vr,string:Pr,formatted:function(t){return 0===Pr(t).length?[]:br(t)},resolvedImage:function(t){return 0===Pr(t).length?[]:br(t)},padding:function(t){const e=t.key,r=t.value;if("array"===Le(r)){if(r.length<1||r.length>4)return[new _(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const n={type:"number"};let s=[];for(let a=0;a[]}})),t.constants&&(r=r.concat(dr({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:Dr}))),Or(r)}function Lr(t){return function(e){return t({...e,validateSpec:Dr})}}function Or(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function qr(t){return function(...e){return Or(t.apply(this,e))}}$r.source=qr(Lr(Mr)),$r.sprite=qr(Lr(Er)),$r.glyphs=qr(Lr(Fr)),$r.light=qr(Lr(Br)),$r.terrain=qr(Lr(Vr)),$r.layer=qr(Lr(zr)),$r.filter=qr(Lr(_r)),$r.paintProperty=qr(Lr(Ar)),$r.layoutProperty=qr(Lr(Ir));const jr={};class Ur extends Error{constructor(t,e,r,n){super(`AJAXError: ${e} (${t}): ${r}`),this.status=t,this.statusText=e,this.url=r,this.body=n}}const Rr=m()?()=>self.worker&&self.worker.referrer:()=>("blob:"===window.location.protocol?window.parent:window).location.href;function Nr(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:Rr(),signal:r.signal});let s=!1,a=!1;return"json"===t.type&&n.headers.set("Accept","application/json"),a||fetch(n).then((r=>r.ok?(r=>{("arrayBuffer"===t.type||"image"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{a||(s=!0,e(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")))})).catch((t=>{a||e(new Error(t.message))}))})(r):r.blob().then((n=>e(new Ur(r.status,r.statusText,t.url,n)))))).catch((t=>{20!==t.code&&e(new Error(t.message))})),{cancel:()=>{a=!0,s||r.abort()}}}const Zr=function(t,e){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){if(m()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e);if(!m())return(jr[(r=t.url).substring(0,r.indexOf("://"))]||Nr)(t,e)}var r;if(!(t=>/^file:/.test(t)||/^file:/.test(Rr())&&!/^\w+:/.test(t))(t.url)){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return Nr(t,e);if(m()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}return function(t,e){const r=new XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{e(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===t.type)try{n=JSON.parse(r.response)}catch(t){return e(t)}e(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else{const n=new Blob([r.response],{type:r.getResponseHeader("Content-Type")});e(new Ur(r.status,r.statusText,t.url,n))}},r.send(t.body),{cancel:()=>r.abort()}}(t,e)},Jr={};function Kr(t,e,r={}){if(Jr[t])throw new Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Jr[t]={klass:e,omit:r.omit||[],shallow:r.shallow||[]}}Kr("Object",Object),Kr("TransferableGridIndex",v),Kr("Color",ct),Kr("Error",Error),Kr("AJAXError",Ur),Kr("ResolvedImage",yt),Kr("StylePropertyFunction",We),Kr("StyleExpression",Je,{omit:["_evaluator"]}),Kr("ZoomDependentExpression",Ye),Kr("ZoomConstantExpression",Xe),Kr("CompoundExpression",Kt,{omit:["_evaluate"]});for(const t in Pe)Pe[t]._classRegistryKey||Kr(`Expression_${t}`,Pe[t]);function Gr(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function Xr(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||t instanceof Blob)return t;if(Gr(t))return e&&e.push(t),t;if(b(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const r=t;return e&&e.push(r.buffer),r}if(t instanceof ImageData)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const r=[];for(const n of t)r.push(Xr(n,e));return r}if("object"==typeof t){const r=t.constructor,n=r._classRegistryKey;if(!n)throw new Error("can't serialize object of unregistered class");if(!Jr[n])throw new Error(`${n} is not registered.`);const s=r.serialize?r.serialize(t,e):{};if(r.serialize){if(e&&s===e[e.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const r in t){if(!t.hasOwnProperty(r))continue;if(Jr[n].omit.indexOf(r)>=0)continue;const a=t[r];s[r]=Jr[n].shallow.indexOf(r)>=0?a:Xr(a,e)}t instanceof Error&&(s.message=t.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(s.$name=n),s}throw new Error("can't serialize object of type "+typeof t)}function Wr(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||t instanceof Blob||Gr(t)||b(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Wr);if("object"==typeof t){const e=t.$name||"Object";if(!Jr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=Jr[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 r of Object.keys(t)){if("$name"===r)continue;const s=t[r];n[r]=Jr[e].shallow.indexOf(r)>=0?s:Wr(s)}return n}throw new Error("can't deserialize object of type "+typeof t)}class Yr{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(){delete this._channel,this._callback=()=>{}}}class Hr{constructor(t,e,r){var n;this.target=t,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},n=this,["receive","process"].forEach((t=>{n[t]&&(n[t]=n[t].bind(n))})),this.invoker=new Yr(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=m()?t:window}send(t,e,r,n,s=!1){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(this.callbacks[a]=r);const o=x(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:t,hasCallback:!!r,targetMapId:n,mustQueue:s,sourceMapId:this.mapId,data:Xr(e,o)},o),{cancel:()=>{r&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){delete this.tasks[r];const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t()}else m()||e.mustQueue?(this.tasks[r]=e,this.taskQueue.push(r),this.invoker.trigger()):this.processTask(r,e)}process(){if(!this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,e){if(""===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(Wr(e.error)):r(null,Wr(e.data)))}else{let r=!1;const n=x(this.globalScope)?void 0:[],s=e.hasCallback?(e,s)=>{r=!0,delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Xr(e):null,data:Xr(s,n)},n)}:t=>{r=!0};let a=null;const o=Wr(e.data);if(this.parent[e.type])a=this.parent[e.type](e.sourceMapId,o,s);else if(this.parent.getWorkerSource){const t=e.type.split(".");a=this.parent.getWorkerSource(e.sourceMapId,t[0],o.source)[t[1]](o,s)}else s(new Error(`Could not find function ${e.type}`));!r&&a&&a.cancel&&(this.cancelCallbacks[t]=a.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}}function Qr(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e))}function nn(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}class tn{constructor(t,e={}){u(this,e),this.type=t}}class en extends tn{constructor(t,e={}){super("error",u({error:t},e))}}class rn{on(t,e){return this._listeners=this._listeners||{},Qr(t,e,this._listeners),this}off(t,e){return nn(t,e,this._listeners),nn(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Qr(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new tn(t,e||{}));const r=t.type;if(this.listens(r)){t.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of e)r.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of n)nn(r,e,this._oneTimeListeners),e.call(this,t);const s=this._eventedParent;s&&(u(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),s.fire(t))}else t instanceof en&&console.error(t.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 sn=$r,an=sn.paintProperty,ln=sn.layoutProperty;class on{constructor(){this.first=!0}update(t,e){const r=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=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};function cn(t){for(const e of t)if(dn(e.charCodeAt(0)))return!0;return!1}function hn(t){for(const e of t)if(!pn(e.charCodeAt(0)))return!1;return!0}function pn(t){return!(un.Arabic(t)||un["Arabic Supplement"](t)||un["Arabic Extended-A"](t)||un["Arabic Presentation Forms-A"](t)||un["Arabic Presentation Forms-B"](t))}function dn(t){return!(746!==t&&747!==t&&(t<4352||!(un["Bopomofo Extended"](t)||un.Bopomofo(t)||un["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||un["CJK Compatibility Ideographs"](t)||un["CJK Compatibility"](t)||un["CJK Radicals Supplement"](t)||un["CJK Strokes"](t)||!(!un["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||un["CJK Unified Ideographs Extension A"](t)||un["CJK Unified Ideographs"](t)||un["Enclosed CJK Letters and Months"](t)||un["Hangul Compatibility Jamo"](t)||un["Hangul Jamo Extended-A"](t)||un["Hangul Jamo Extended-B"](t)||un["Hangul Jamo"](t)||un["Hangul Syllables"](t)||un.Hiragana(t)||un["Ideographic Description Characters"](t)||un.Kanbun(t)||un["Kangxi Radicals"](t)||un["Katakana Phonetic Extensions"](t)||un.Katakana(t)&&12540!==t||!(!un["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)||!(!un["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||un["Unified Canadian Aboriginal Syllabics"](t)||un["Unified Canadian Aboriginal Syllabics Extended"](t)||un["Vertical Forms"](t)||un["Yijing Hexagram Symbols"](t)||un["Yi Syllables"](t)||un["Yi Radicals"](t))))}function fn(t){return!(dn(t)||function(t){return!!(un["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||un["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)||un["Letterlike Symbols"](t)||un["Number Forms"](t)||un["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)||un["Control Pictures"](t)&&9251!==t||un["Optical Character Recognition"](t)||un["Enclosed Alphanumerics"](t)||un["Geometric Shapes"](t)||un["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||un["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||un["CJK Symbols and Punctuation"](t)||un.Katakana(t)||un["Private Use Area"](t)||un["CJK Compatibility Forms"](t)||un["Small Form Variants"](t)||un["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 yn(t){return t>=1424&&t<=2303||un["Arabic Presentation Forms-A"](t)||un["Arabic Presentation Forms-B"](t)}function mn(t,e){return!(!e&&yn(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||un.Khmer(t))}function gn(t){for(const e of t)if(yn(e.charCodeAt(0)))return!0;return!1}"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date);let xn="unavailable",vn=null;const Fn={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>"loaded"===xn||null!=Fn.applyArabicShaping,isLoading:()=>"loading"===xn,setState(t){if(!m())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");xn=t.pluginStatus,vn=t.pluginURL},isParsed(){if(!m())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return null!=Fn.applyArabicShaping&&null!=Fn.processBidirectionalText&&null!=Fn.processStyledBidirectionalText},getPluginURL(){if(!m())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return vn}};class bn{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new on,this.transition={})}isSupportedScript(t){return function(t,e){for(const r of t)if(!mn(r.charCodeAt(0),e))return!1;return!0}(t,Fn.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),r=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*e}}}class wn{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Oe(t))return new We(t,e);if(Ge(t)){const r=Qe(t,e);if("error"===r.result)throw new Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return r.value}{let r=t;return"color"===e.type&&"string"==typeof t?r=ct.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)||(r=ft.parse(t)),{kind:"constant",evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class _n{constructor(t){this.property=t,this.value=new wn(t,void 0)}transitioned(t,e){return new kn(this.property,this.value,e,u({},t.transition,this.transition),t.now)}untransitioned(){return new kn(this.property,this.value,null,{},0)}}class Sn{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return h(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new _n(this._values[t].property)),this._values[t].value=new wn(this._values[t].property,null===e?void 0:h(e))}getTransition(t){return h(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new _n(this._values[t].property)),this._values[t].transition=h(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 An(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 An(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class kn{constructor(t,e,r,n,s){this.property=t,this.value=e,this.begin=s+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r)}possiblyEvaluate(t,e,r){const n=t.now||0,s=this.value.possiblyEvaluate(t,e,r),a=this.prior;if(a){if(n>this.end)return this.prior=null,s;if(this.value.isDataDriven())return this.prior=null,s;if(n=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}(o))}}return s}}class An{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,r){const n=new Mn(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].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 In{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return h(this._values[t].value)}setValue(t,e){this._values[t]=new wn(this._values[t].property,null===e?void 0:h(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r)}return t}possiblyEvaluate(t,e,r){const n=new Mn(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].possiblyEvaluate(t,e,r);return n}}class zn{constructor(t,e,r){this.property=t,this.value=e,this.parameters=r}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,r,n){return this.property.evaluate(this.value,this.parameters,t,e,r,n)}}class Mn{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class Pn{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,r){const n=se[this.specification.type];return n?n(t,e,r):t}}class Cn{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,r,n){return new zn(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},r,n)}:t.expression,e)}interpolate(t,e,r){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new zn(this,{kind:"constant",value:void 0},t.parameters);const n=se[this.specification.type];if(n){const s=n(t.value.value,e.value.value,r);return new zn(this,{kind:"constant",value:s},t.parameters)}return t}evaluate(t,e,r,n,s,a){return"constant"===t.kind?t.value:t.evaluate(e,r,n,s,a)}}class Bn extends Cn{possiblyEvaluate(t,e,r,n){if(void 0===t.value)return new zn(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},r,n),a="resolvedImage"===t.property.specification.type&&"string"!=typeof s?s.name:s,o=this._calculate(a,a,a,e);return new zn(this,{kind:"constant",value:o},e)}if("camera"===t.expression.kind){const r=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new zn(this,{kind:"constant",value:r},e)}return new zn(this,t.expression,e)}evaluate(t,e,r,n,s,a){if("source"===t.kind){const o=t.evaluate(e,r,n,s,a);return this._calculate(o,o,o,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},r,n),t.evaluate({zoom:Math.floor(e.zoom)},r,n),t.evaluate({zoom:Math.floor(e.zoom)+1},r,n),e):t.value}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class Vn{constructor(t){this.specification=t}possiblyEvaluate(t,e,r,n){if(void 0!==t.value){if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},r,n);return this._calculate(s,s,s,e)}return this._calculate(t.expression.evaluate(new bn(Math.floor(e.zoom-1),e)),t.expression.evaluate(new bn(Math.floor(e.zoom),e)),t.expression.evaluate(new bn(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,r,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:r,to:e}}interpolate(t){return t}}class En{constructor(t){this.specification=t}possiblyEvaluate(t,e,r,n){return!!t.expression.evaluate(e,null,{},r,n)}interpolate(){return!1}}class Tn{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const r=t[e];r.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new wn(r,void 0),s=this.defaultTransitionablePropertyValues[e]=new _n(r);this.defaultTransitioningPropertyValues[e]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({})}}}Kr("DataDrivenProperty",Cn),Kr("DataConstantProperty",Pn),Kr("CrossFadedDataDrivenProperty",Bn),Kr("CrossFadedProperty",Vn),Kr("ColorRampProperty",En);const $n="-transition";class Dn extends rn{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new In(e.layout)),e.paint)){this._transitionablePaint=new Sn(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Mn(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,r={}){null!=e&&this._validate(ln,`layers.${this.id}.layout.${t}`,t,e,r)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith($n)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,r={}){if(null!=e&&this._validate(an,`layers.${this.id}.paint.${t}`,t,e,r))return!1;if(t.endsWith($n))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const r=this._transitionablePaint._values[t],n="cross-faded-data-driven"===r.property.specification["property-type"],s=r.value.isDataDriven(),a=r.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const o=this._transitionablePaint._values[t].value;return o.isDataDriven()||s||n||this._handleOverridablePaintPropertyUpdate(t,a,o)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,r){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,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 this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),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)))}_validate(t,e,r,n,s={}){return(!s||!1!==s.validate)&&function(t,e){let r=!1;if(e&&e.length)for(const n of e)t.fire(new en(new Error(n.message))),r=!0;return r}(this,t.call(sn,{key:e,layerType:this.type,objectKey:r,value:n,styleSpec:w,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof zn&&De(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Un={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ln{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class On{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function qn(t,e=1){let r=0,n=0;return{members:t.map((t=>{const s=Un[t.type].BYTES_PER_ELEMENT,a=r=Ti(r,Math.max(e,s)),o=t.components||1;return n=Math.max(n,s),r+=s*o,{name:t.name,type:t.type,components:o,offset:a}})),size:Ti(r,Math.max(n,e)),alignment:e}}function Ti(t,e){return Math.ceil(t/e)*e}class jn extends On{_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}}jn.prototype.bytesPerElement=4,Kr("StructArrayLayout2i4",jn);class Rn extends On{_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 s=3*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,t}}Rn.prototype.bytesPerElement=6,Kr("StructArrayLayout3i6",Rn);class Nn extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n)}emplace(t,e,r,n,s){const a=4*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=s,t}}Nn.prototype.bytesPerElement=8,Kr("StructArrayLayout4i8",Nn);class Zn extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,s,a)}emplace(t,e,r,n,s,a,o){const l=6*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+3]=s,this.int16[l+4]=a,this.int16[l+5]=o,t}}Zn.prototype.bytesPerElement=12,Kr("StructArrayLayout2i4i12",Zn);class Jn extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,s,a)}emplace(t,e,r,n,s,a,o){const l=4*t,u=8*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=s,this.uint8[u+6]=a,this.uint8[u+7]=o,t}}Jn.prototype.bytesPerElement=8,Kr("StructArrayLayout2i4ub8",Jn);class Gn extends On{_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}}Gn.prototype.bytesPerElement=8,Kr("StructArrayLayout2f8",Gn);class Kn extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,s,a,o,l,u,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,r,n,s,a,o,l,u,c)}emplace(t,e,r,n,s,a,o,l,u,c,h){const p=10*t;return this.uint16[p+0]=e,this.uint16[p+1]=r,this.uint16[p+2]=n,this.uint16[p+3]=s,this.uint16[p+4]=a,this.uint16[p+5]=o,this.uint16[p+6]=l,this.uint16[p+7]=u,this.uint16[p+8]=c,this.uint16[p+9]=h,t}}Kn.prototype.bytesPerElement=20,Kr("StructArrayLayout10ui20",Kn);class Xn extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,s,a,o,l,u,c,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,r,n,s,a,o,l,u,c,h,p)}emplace(t,e,r,n,s,a,o,l,u,c,h,p,d){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=s,this.uint16[f+4]=a,this.uint16[f+5]=o,this.uint16[f+6]=l,this.uint16[f+7]=u,this.int16[f+8]=c,this.int16[f+9]=h,this.int16[f+10]=p,this.int16[f+11]=d,t}}Xn.prototype.bytesPerElement=24,Kr("StructArrayLayout4i4ui4i24",Xn);class Yn extends On{_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 s=3*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,t}}Yn.prototype.bytesPerElement=12,Kr("StructArrayLayout3f12",Yn);class Hn extends On{_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}}Hn.prototype.bytesPerElement=4,Kr("StructArrayLayout1ul4",Hn);class Wn extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,s,a,o,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,r,n,s,a,o,l,u)}emplace(t,e,r,n,s,a,o,l,u,c){const h=10*t,p=5*t;return this.int16[h+0]=e,this.int16[h+1]=r,this.int16[h+2]=n,this.int16[h+3]=s,this.int16[h+4]=a,this.int16[h+5]=o,this.uint32[p+3]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,t}}Wn.prototype.bytesPerElement=20,Kr("StructArrayLayout6i1ul2ui20",Wn);class Qn extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,s,a)}emplace(t,e,r,n,s,a,o){const l=6*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+3]=s,this.int16[l+4]=a,this.int16[l+5]=o,t}}Qn.prototype.bytesPerElement=12,Kr("StructArrayLayout2i2i2i12",Qn);class ti extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,r,n,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,s)}emplace(t,e,r,n,s,a){const o=4*t,l=8*t;return this.float32[o+0]=e,this.float32[o+1]=r,this.float32[o+2]=n,this.int16[l+6]=s,this.int16[l+7]=a,t}}ti.prototype.bytesPerElement=16,Kr("StructArrayLayout2f1f2i16",ti);class ei extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n)}emplace(t,e,r,n,s){const a=12*t,o=3*t;return this.uint8[a+0]=e,this.uint8[a+1]=r,this.float32[o+1]=n,this.float32[o+2]=s,t}}ei.prototype.bytesPerElement=12,Kr("StructArrayLayout2ub2f12",ei);class ri extends On{_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 s=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=r,this.uint16[s+2]=n,t}}ri.prototype.bytesPerElement=6,Kr("StructArrayLayout3ui6",ri);class ni extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,s,a,o,l,u,c,h,p,d,f,y,m,g){const x=this.length;return this.resize(x+1),this.emplace(x,t,e,r,n,s,a,o,l,u,c,h,p,d,f,y,m,g)}emplace(t,e,r,n,s,a,o,l,u,c,h,p,d,f,y,m,g,x){const b=24*t,w=12*t,S=48*t;return this.int16[b+0]=e,this.int16[b+1]=r,this.uint16[b+2]=n,this.uint16[b+3]=s,this.uint32[w+2]=a,this.uint32[w+3]=o,this.uint32[w+4]=l,this.uint16[b+10]=u,this.uint16[b+11]=c,this.uint16[b+12]=h,this.float32[w+7]=p,this.float32[w+8]=d,this.uint8[S+36]=f,this.uint8[S+37]=y,this.uint8[S+38]=m,this.uint32[w+10]=g,this.int16[b+22]=x,t}}ni.prototype.bytesPerElement=48,Kr("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",ni);class ii extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n,s,a,o,l,u,c,h,p,d,f,y,m,g,x,b,w,S,I,z,P,C,M,B,V){const E=this.length;return this.resize(E+1),this.emplace(E,t,e,r,n,s,a,o,l,u,c,h,p,d,f,y,m,g,x,b,w,S,I,z,P,C,M,B,V)}emplace(t,e,r,n,s,a,o,l,u,c,h,p,d,f,y,m,g,x,b,w,S,I,z,P,C,M,B,V,E){const T=34*t,D=17*t;return this.int16[T+0]=e,this.int16[T+1]=r,this.int16[T+2]=n,this.int16[T+3]=s,this.int16[T+4]=a,this.int16[T+5]=o,this.int16[T+6]=l,this.int16[T+7]=u,this.uint16[T+8]=c,this.uint16[T+9]=h,this.uint16[T+10]=p,this.uint16[T+11]=d,this.uint16[T+12]=f,this.uint16[T+13]=y,this.uint16[T+14]=m,this.uint16[T+15]=g,this.uint16[T+16]=x,this.uint16[T+17]=b,this.uint16[T+18]=w,this.uint16[T+19]=S,this.uint16[T+20]=I,this.uint16[T+21]=z,this.uint16[T+22]=P,this.uint32[D+12]=C,this.float32[D+13]=M,this.float32[D+14]=B,this.float32[D+15]=V,this.float32[D+16]=E,t}}ii.prototype.bytesPerElement=68,Kr("StructArrayLayout8i15ui1ul4f68",ii);class si extends On{_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}}si.prototype.bytesPerElement=4,Kr("StructArrayLayout1f4",si);class ai extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(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 s=4*t;return this.uint32[2*t+0]=e,this.uint16[s+2]=r,this.uint16[s+3]=n,t}}ai.prototype.bytesPerElement=8,Kr("StructArrayLayout1ul2ui8",ai);class oi extends On{_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}}oi.prototype.bytesPerElement=4,Kr("StructArrayLayout2ui4",oi);class li extends On{_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}}li.prototype.bytesPerElement=2,Kr("StructArrayLayout1ui2",li);class ui extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,r,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n)}emplace(t,e,r,n,s){const a=4*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=s,t}}ui.prototype.bytesPerElement=16,Kr("StructArrayLayout4f16",ui);class ci extends Ln{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new n(this.anchorPointX,this.anchorPointY)}}ci.prototype.size=20;class hi extends Wn{get(t){return new ci(this,t)}}Kr("CollisionBoxArray",hi);class pi extends Ln{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}pi.prototype.size=48;class di extends ni{get(t){return new pi(this,t)}}Kr("PlacedSymbolArray",di);class fi extends Ln{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get textOffset0(){return this._structArray.float32[this._pos4+14]}get textOffset1(){return this._structArray.float32[this._pos4+15]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+16]}}fi.prototype.size=68;class yi extends ii{get(t){return new fi(this,t)}}Kr("SymbolInstanceArray",yi);class mi extends si{getoffsetX(t){return this.float32[1*t+0]}}Kr("GlyphOffsetArray",mi);class gi extends Rn{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Kr("SymbolLineVertexArray",gi);class xi extends Ln{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]}}xi.prototype.size=8;class vi extends ai{get(t){return new xi(this,t)}}Kr("FeatureIndexArray",vi);class bi extends jn{}class wi extends jn{}class _i extends jn{}class Si extends Zn{}class ki extends Jn{}class Ai extends Gn{}class Ii extends Kn{}class zi extends Xn{}class Mi extends Yn{}class Pi extends Hn{}class Ci extends Qn{}class Bi extends ei{}class Vi extends ri{}class Ei extends oi{}const Fi=qn([{name:"a_pos",components:2,type:"Int16"}],4),{members:$i}=Fi;class Di{constructor(t=[]){this.segments=t}prepareSegment(t,e,r,n){let s=this.segments[this.segments.length-1];return t>Di.MAX_VERTEX_ARRAY_LENGTH&&d(`Max vertices per segment is ${Di.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!s||s.vertexLength+t>Di.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==n)&&(s={vertexOffset:e.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},void 0!==n&&(s.sortKey=n),this.segments.push(s)),s}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 Di([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Li(t,e){return 256*(t=l(Math.floor(t),0,255))+l(Math.floor(e),0,255)}Di.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Kr("SegmentVector",Di);const Oi=qn([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Ui={exports:{}},qi={exports:{}};qi.exports=function(t,e){var r,n,s,a,o,l,u,c;for(n=t.length-(r=3&t.length),s=e,o=3432918353,l=461845907,c=0;c>>16)*o&65535)<<16)&4294967295)<<15|u>>>17))*l+(((u>>>16)*l&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(u=0,r){case 3:u^=(255&t.charCodeAt(c+2))<<16;case 2:u^=(255&t.charCodeAt(c+1))<<8;case 1:s^=u=(65535&(u=(u=(65535&(u^=255&t.charCodeAt(c)))*o+(((u>>>16)*o&65535)<<16)&4294967295)<<15|u>>>17))*l+(((u>>>16)*l&65535)<<16)&4294967295}return s^=t.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0};var ji=qi.exports,Ri={exports:{}};Ri.exports=function(t,e){for(var r,n=t.length,s=e^n,a=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(a)|(255&t.charCodeAt(++a))<<8|(255&t.charCodeAt(++a))<<16|(255&t.charCodeAt(++a))<<24))+((1540483477*(r>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++a;switch(n){case 3:s^=(255&t.charCodeAt(a+2))<<16;case 2:s^=(255&t.charCodeAt(a+1))<<8;case 1:s=1540483477*(65535&(s^=255&t.charCodeAt(a)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0};var Ni=ji,Zi=Ri.exports;Ui.exports=Ni,Ui.exports.murmur3=Ni,Ui.exports.murmur2=Zi;var Ki=t(Ui.exports);class Ji{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,r,n){this.ids.push(Gi(t)),this.positions.push(e,r,n)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=Gi(t);let r=0,n=this.ids.length-1;for(;r>1;this.ids[t]>=e?n=t:r=t+1}const s=[];for(;this.ids[r]===e;)s.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return s}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Xi(r,n,0,r.length-1),e&&e.push(r.buffer,n.buffer),{ids:r,positions:n}}static deserialize(t){const e=new Ji;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Gi(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Ki(String(t))}function Xi(t,e,r,n){for(;r>1];let a=r-1,o=n+1;for(;;){do{a++}while(t[a]s);if(a>=o)break;ts(t,a,o),ts(e,3*a,3*o),ts(e,3*a+1,3*o+1),ts(e,3*a+2,3*o+2)}o-r`u_${t}`)),this.type=r}setUniform(t,e,r){t.set(r.constantOr(this.value))}getBinding(t,e,r){return"color"===this.type?new Qi(t,e):new Hi(t,e)}}class rs{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setUniform(t,e,r,n){const s="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;s&&t.set(s)}getBinding(t,e,r){return"u_pattern"===r.substr(0,9)?new Wi(t,e):new Hi(t,e)}}class ns{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,s){const a=this.paintVertexArray.length,o=this.expression.evaluate(new bn(0),e,{},n,[],s);this.paintVertexArray.resize(t),this._setPaintValue(a,t,o)}updatePaintArray(t,e,r,n){const s=this.expression.evaluate({zoom:0},r,n);this._setPaintValue(t,e,s)}_setPaintValue(t,e,r){if("color"===this.type){const n=ls(r);for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new a}populatePaintArray(t,e,r,n,s){const a=this.expression.evaluate(new bn(this.zoom),e,{},n,[],s),o=this.expression.evaluate(new bn(this.zoom+1),e,{},n,[],s),l=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(l,t,a,o)}updatePaintArray(t,e,r,n){const s=this.expression.evaluate({zoom:this.zoom},r,n),a=this.expression.evaluate({zoom:this.zoom+1},r,n);this._setPaintValue(t,e,s,a)}_setPaintValue(t,e,r,n){if("color"===this.type){const s=ls(r),a=ls(n);for(let r=t;r`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof ns||r instanceof is)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new as(n,e,r);this.needsUpload=!1,this._featureMap=new Ji,this._bufferOffset=0}populatePaintArrays(t,e,r,n,s,a){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,s,a);void 0!==e.id&&this._featureMap.add(e.id,r,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,r,n){for(const s of r)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,e,s,n)||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()}}function us(t,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function cs(t,e,r){const n={color:{source:Gn,composite:ui},number:{source:si,composite:Gn}},s=function(t){return{"line-pattern":{source:Ii,composite:Ii},"fill-pattern":{source:Ii,composite:Ii},"fill-extrusion-pattern":{source:Ii,composite:Ii}}[t]}(t);return s&&s[r]||n[e][r]}Kr("ConstantBinder",es),Kr("CrossFadedConstantBinder",rs),Kr("SourceExpressionBinder",ns),Kr("CrossFadedCompositeBinder",ss),Kr("CompositeExpressionBinder",is),Kr("ProgramConfiguration",as,{omit:["_buffers"]}),Kr("ProgramConfigurationSet",os);var hs=8192;const ps=Math.pow(2,14)-1,ds=-ps-1;function fs(t){const e=hs/t.extent,r=t.loadGeometry();for(let t=0;tr.x+1||ar.y+1)&&d("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function ys(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?fs(t):[]}}function gs(t,e,r,n,s){t.emplaceBack(2*e+(n+1)/2,2*r+(s+1)/2)}class ms{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new wi,this.indexArray=new Vi,this.segments=new Di,this.programConfigurations=new os(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){const n=this.layers[0],s=[];let a=null,o=!1;"circle"===n.type&&(a=n.layout.get("circle-sort-key"),o=!a.isConstant());for(const{feature:e,id:n,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ys(e,t);if(!this.layers[0]._featureFilter.filter(new bn(this.zoom),c,r))continue;const h=o?a.evaluate(c,{},r):void 0,p={id:n,properties:e.properties,type:e.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:fs(e),patterns:{},sortKey:h};s.push(p)}o&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:s,index:a,sourceLayerIndex:o}=n,l=t[a].feature;this.addFeature(n,s,a,r),e.featureIndex.insert(l,s,a,o,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,$i),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,r,n){for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=hs||n<0||n>=hs)continue;const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;gs(this.layoutVertexArray,r,n,-1,-1),gs(this.layoutVertexArray,r,n,1,-1),gs(this.layoutVertexArray,r,n,1,1),gs(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+3,a+2),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n)}}function xs(t,e){for(let r=0;r1){if(_s(t,e))return!0;for(let n=0;n1?r:r.sub(e)._mult(s)._add(e))}function Is(t,e){let r,n,s,a=!1;for(let o=0;oe.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(a=!a)}return a}function zs(t,e){let r=!1;for(let n=0,s=t.length-1;ne.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}function Ps(t,e,r){const n=r[0],s=r[2];if(t.xs.x&&e.x>s.x||t.ys.y&&e.y>s.y)return!1;const a=f(t,e,r[0]);return a!==f(t,e,r[1])||a!==f(t,e,r[2])||a!==f(t,e,r[3])}function Cs(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 Bs(t,e,r,s,a){if(!e[0]&&!e[1])return t;const o=n.convert(e)._mult(a);"viewport"===r&&o._rotate(-s);const l=[];for(let e=0;et.width||s.height>t.height||r.x>t.width-s.width||r.y>t.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||n.x>e.width-s.width||n.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const o=t.data,l=e.data;if(o===l)throw new Error("srcData equals dstData, so image is already copied");for(let u=0;u80*r){n=a=t[0],s=o=t[1];for(var y=r;ya&&(a=l),u>o&&(o=u);c=0!==(c=Math.max(a-n,o-s))?32767/c:0}return ra(d,f,r,n,s,c,0),f}function ta(t,e,r,n,s){var a,o;if(s===Sa(t,e,r,n)>0)for(a=e;a=e;a-=n)o=wa(a,t[a],t[a+1],o);return o&&ya(o,o.next)&&(_a(o),o=o.next),o}function ea(t,e){if(!t)return t;e||(e=t);var r,n=t;do{if(r=!1,n.steiner||!ya(n,n.next)&&0!==fa(n.prev,n,n.next))n=n.next;else{if(_a(n),(n=e=n.prev)===n.next)break;r=!0}}while(r||n!==e);return e}function ra(t,e,r,n,s,a,o){if(t){!o&&a&&function(t,e,r,n){var s=t;do{0===s.z&&(s.z=ca(s.x,s.y,e,r,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,r,n,s,a,o,l,u,c=1;do{for(r=t,t=null,a=null,o=0;r;){for(o++,n=r,l=0,e=0;e0||u>0&&n;)0!==l&&(0===u||!n||r.z<=n.z)?(s=r,r=r.nextZ,l--):(s=n,n=n.nextZ,u--),a?a.nextZ=s:t=s,s.prevZ=a,a=s;r=n}a.nextZ=null,c*=2}while(o>1)}(s)}(t,n,s,a);for(var l,u,c=t;t.prev!==t.next;)if(l=t.prev,u=t.next,a?ia(t,n,s,a):na(t))e.push(l.i/r|0),e.push(t.i/r|0),e.push(u.i/r|0),_a(t),t=u.next,c=u.next;else if((t=u)===c){o?1===o?ra(t=sa(ea(t),e,r),e,r,n,s,a,2):2===o&&aa(t,e,r,n,s,a):ra(ea(t),e,r,n,s,a,1);break}}}function na(t){var e=t.prev,r=t,n=t.next;if(fa(e,r,n)>=0)return!1;for(var s=e.x,a=r.x,o=n.x,l=e.y,u=r.y,c=n.y,h=sa?s>o?s:o:a>o?a:o,f=l>u?l>c?l:c:u>c?u:c,y=n.next;y!==e;){if(y.x>=h&&y.x<=d&&y.y>=p&&y.y<=f&&pa(s,l,a,u,o,c,y.x,y.y)&&fa(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function ia(t,e,r,n){var s=t.prev,a=t,o=t.next;if(fa(s,a,o)>=0)return!1;for(var l=s.x,u=a.x,c=o.x,h=s.y,p=a.y,d=o.y,f=lu?l>c?l:c:u>c?u:c,g=h>p?h>d?h:d:p>d?p:d,x=ca(f,y,e,r,n),b=ca(m,g,e,r,n),w=t.prevZ,S=t.nextZ;w&&w.z>=x&&S&&S.z<=b;){if(w.x>=f&&w.x<=m&&w.y>=y&&w.y<=g&&w!==s&&w!==o&&pa(l,h,u,p,c,d,w.x,w.y)&&fa(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,S.x>=f&&S.x<=m&&S.y>=y&&S.y<=g&&S!==s&&S!==o&&pa(l,h,u,p,c,d,S.x,S.y)&&fa(S.prev,S,S.next)>=0)return!1;S=S.nextZ}for(;w&&w.z>=x;){if(w.x>=f&&w.x<=m&&w.y>=y&&w.y<=g&&w!==s&&w!==o&&pa(l,h,u,p,c,d,w.x,w.y)&&fa(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;S&&S.z<=b;){if(S.x>=f&&S.x<=m&&S.y>=y&&S.y<=g&&S!==s&&S!==o&&pa(l,h,u,p,c,d,S.x,S.y)&&fa(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function sa(t,e,r){var n=t;do{var s=n.prev,a=n.next.next;!ya(s,a)&&ma(s,n,n.next,a)&&va(s,a)&&va(a,s)&&(e.push(s.i/r|0),e.push(n.i/r|0),e.push(a.i/r|0),_a(n),_a(n.next),n=t=a),n=n.next}while(n!==t);return ea(n)}function aa(t,e,r,n,s,a){var o=t;do{for(var l=o.next.next;l!==o.prev;){if(o.i!==l.i&&da(o,l)){var u=ba(o,l);return o=ea(o,o.next),u=ea(u,u.next),ra(o,e,r,n,s,a,0),void ra(u,e,r,n,s,a,0)}l=l.next}o=o.next}while(o!==t)}function oa(t,e){return t.x-e.x}function la(t,e){var r=function(t,e){var r,n=e,s=t.x,a=t.y,o=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var l=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(l<=s&&l>o&&(o=l,r=n.x=n.x&&n.x>=h&&s!==n.x&&pa(ar.x||n.x===r.x&&ua(r,n)))&&(r=n,d=u)),n=n.next}while(n!==c);return r}(t,e);if(!r)return e;var n=ba(r,t);return ea(n,n.next),ea(r,r.next)}function ua(t,e){return fa(t.prev,t,e.prev)<0&&fa(e.next,t,t.next)<0}function ca(t,e,r,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ha(t){var e=t,r=t;do{(e.x=(t-o)*(a-l)&&(t-o)*(n-l)>=(r-o)*(e-l)&&(r-o)*(a-l)>=(s-o)*(n-l)}function da(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&ma(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(va(t,e)&&va(e,t)&&function(t,e){var r=t,n=!1,s=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&s<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==t);return n}(t,e)&&(fa(t.prev,t,e.prev)||fa(t,e.prev,e))||ya(t,e)&&fa(t.prev,t,t.next)>0&&fa(e.prev,e,e.next)>0)}function fa(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function ya(t,e){return t.x===e.x&&t.y===e.y}function ma(t,e,r,n){var s=xa(fa(t,e,r)),a=xa(fa(t,e,n)),o=xa(fa(r,n,t)),l=xa(fa(r,n,e));return s!==a&&o!==l||!(0!==s||!ga(t,r,e))||!(0!==a||!ga(t,n,e))||!(0!==o||!ga(r,t,n))||!(0!==l||!ga(r,e,n))}function ga(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 xa(t){return t>0?1:t<0?-1:0}function va(t,e){return fa(t.prev,t,t.next)<0?fa(t,e,t.next)>=0&&fa(t,t.prev,e)>=0:fa(t,e,t.prev)<0||fa(t,t.next,e)<0}function ba(t,e){var r=new ka(t.i,t.x,t.y),n=new ka(e.i,e.x,e.y),s=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=s,s.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function wa(t,e,r,n){var s=new ka(t,e,r);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function _a(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 ka(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Sa(t,e,r,n){for(var s=0,a=e,o=r-n;a0&&r.holes.push(n+=t[s-1].length)}return r};var Aa=t(Ws.exports);function Ia(t,e,r,n,s){za(t,e,r||0,n||t.length-1,s||Ca)}function za(t,e,r,n,s){for(;n>r;){if(n-r>600){var a=n-r+1,o=e-r+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);za(t,e,Math.max(r,Math.floor(e-o*u/a+c)),Math.min(n,Math.floor(e+(a-o)*u/a+c)),s)}var h=t[e],p=r,d=n;for(Pa(t,r,e),s(t[n],h)>0&&Pa(t,r,n);p0;)d--}0===s(t[r],h)?Pa(t,r,d):Pa(t,++d,n),d<=e&&(r=d+1),e<=d&&(n=d-1)}}function Pa(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function Ca(t,e){return te?1:0}function Ma(t,e){const r=t.length;if(r<=1)return[t];const n=[];let s,a;for(let e=0;e1)for(let t=0;tt.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new _i,this.indexArray=new Vi,this.indexArray2=new Ei,this.programConfigurations=new os(t.layers,t.zoom),this.segments=new Di,this.segments2=new Di,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.hasPattern=Va("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),s=!n.isConstant(),a=[];for(const{feature:o,id:l,index:u,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=ys(o,t);if(!this.layers[0]._featureFilter.filter(new bn(this.zoom),h,r))continue;const p=s?n.evaluate(h,{},r,e.availableImages):void 0,d={id:l,properties:o.properties,type:o.type,sourceLayerIndex:c,index:u,geometry:t?h.geometry:fs(o),patterns:{},sortKey:p};a.push(d)}s&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of a){const{geometry:s,index:a,sourceLayerIndex:o}=n;if(this.hasPattern){const t=Ta("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,s,a,r,{});e.featureIndex.insert(t[a].feature,s,a,o,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hs),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,r,n,s){for(const t of Ma(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,s=[],a=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&a.push(s.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),s.push(e[0].x),s.push(e[0].y);for(let t=1;t>3}if(s--,1===n||2===n)a+=t.readSVarint(),o+=t.readSVarint(),1===n&&(e&&l.push(e),e=[]),e.push(new ja(a,o));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&l.push(e),l},Na.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,s=0,a=0,o=1/0,l=-1/0,u=1/0,c=-1/0;t.pos>3}if(n--,1===r||2===r)(s+=t.readSVarint())l&&(l=s),(a+=t.readSVarint())c&&(c=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,u,l,c]},Na.prototype.toGeoJSON=function(t,e,r){var n,s,a=this.extent*Math.pow(2,r),o=this.extent*t,l=this.extent*e,u=this.loadGeometry(),c=Na.types[this.type];function h(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(r))}Ya.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Ka(this._pbf,e,this.extent,this._keys,this._values)};var Ha=Ga;function Wa(t,e,r){if(3===t){var n=new Ha(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n)}}qa.VectorTile=function(t,e){this.layers=t.readFields(Wa,{},e)},qa.VectorTileFeature=Ra,qa.VectorTileLayer=Ga;const Qa=qa.VectorTileFeature.types,to=Math.pow(2,13);function ro(t,e,r,n,s,a,o,l){t.emplaceBack(e,r,2*Math.floor(n*to)+o,s*to*2,a*to*2,Math.round(l))}class eo{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Si,this.centroidVertexArray=new bi,this.indexArray=new Vi,this.programConfigurations=new os(t.layers,t.zoom),this.segments=new Di,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.features=[],this.hasPattern=Va("fill-extrusion",this.layers,e);for(const{feature:n,id:s,index:a,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,l=ys(n,t);if(!this.layers[0]._featureFilter.filter(new bn(this.zoom),l,r))continue;const u={id:s,sourceLayerIndex:o,index:a,geometry:t?l.geometry:fs(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Ta("fill-extrusion",this.layers,u,this.zoom,e)):this.addFeature(u,u.geometry,a,r,{}),e.featureIndex.insert(n,u.geometry,a,o,this.index,!0)}}addFeatures(t,e,r){for(const t of this.features){const{geometry:n}=t;this.addFeature(t,n,t.index,e,r)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ua),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Oa.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,r,n,s){const a={x:0,y:0,vertexCount:0};for(const r of Ma(e,500)){let e=0;for(const t of r)e+=t.length;let n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of r){if(0===t.length)continue;if(io(t))continue;let e=0;for(let r=0;r=1){const o=t[r-1];if(!no(s,o)){n.vertexLength+4>Di.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=s.sub(o)._perp()._unit(),r=o.dist(s);e+r>32768&&(e=0),ro(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,0,e),ro(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,1,e),a.x+=2*s.x,a.y+=2*s.y,a.vertexCount+=2,e+=r,ro(this.layoutVertexArray,o.x,o.y,t.x,t.y,0,0,e),ro(this.layoutVertexArray,o.x,o.y,t.x,t.y,0,1,e),a.x+=2*o.x,a.y+=2*o.y,a.vertexCount+=2;const l=n.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),n.vertexLength+=4,n.primitiveLength+=2}}}}if(n.vertexLength+e>Di.MAX_VERTEX_ARRAY_LENGTH&&(n=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==Qa[t.type])continue;const s=[],o=[],l=n.vertexLength;for(const t of r)if(0!==t.length){t!==r[0]&&o.push(s.length/2);for(let e=0;ehs)||t.y===e.y&&(t.y<0||t.y>hs)}function io(t){return t.every((t=>t.x<0))||t.every((t=>t.x>hs))||t.every((t=>t.y<0))||t.every((t=>t.y>hs))}let so;Kr("FillExtrusionBucket",eo,{omit:["layers","features"]});var ao={get paint(){return so=so||new Tn({"fill-extrusion-opacity":new Pn(w["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Cn(w["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Pn(w["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Pn(w["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Bn(w["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Cn(w["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Cn(w["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Pn(w["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};function oo(t,e){return t.x*e.x+t.y*e.y}function lo(t,e){if(1===t.length){let r=0;const n=e[r++];let s;for(;!s||n.equals(s);)if(s=e[r++],!s)return 1/0;for(;rt.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new ki,this.layoutVertexArray2=new Ai,this.indexArray=new Vi,this.programConfigurations=new os(t.layers,t.zoom),this.segments=new Di,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,r){this.hasPattern=Va("line",this.layers,e);const n=this.layers[0].layout.get("line-sort-key"),s=!n.isConstant(),a=[];for(const{feature:e,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ys(e,t);if(!this.layers[0]._featureFilter.filter(new bn(this.zoom),c,r))continue;const h=s?n.evaluate(c,{},r):void 0,p={id:o,properties:e.properties,type:e.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:fs(e),patterns:{},sortKey:h};a.push(p)}s&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of a){const{geometry:s,index:a,sourceLayerIndex:o}=n;if(this.hasPattern){const t=Ta("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,s,a,r,{});e.featureIndex.insert(t[a].feature,s,a,o,this.index)}}update(t,e,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r)}addFeatures(t,e,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r)}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,po)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,co),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,s){const a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),l=a.get("line-cap"),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,l,u,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,s,n)}addLine(t,e,r,n,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[l-1].equals(t[l-2]);)l--;let u=0;for(;u0;if(I&&e>u){const t=p.dist(d);if(t>2*c){const e=p.sub(p.sub(d)._mult(c/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,y,0,0,h),d=e}}const P=d&&f;let C=P?r:o?"butt":n;if(P&&"round"===C&&(ws&&(C="bevel"),"bevel"===C&&(w>2&&(C="flipbevel"),w100)g=m.mult(-1);else{const t=w*y.add(m).mag()/y.sub(m).mag();g._perp()._mult(t*(z?-1:1))}this.addCurrentVertex(p,g,0,0,h),this.addCurrentVertex(p,g.mult(-1),0,0,h)}else if("bevel"===C||"fakeround"===C){const t=-Math.sqrt(w*w-1),e=z?t:0,r=z?0:t;if(d&&this.addCurrentVertex(p,y,e,r,h),"fakeround"===C){const t=Math.round(180*S/Math.PI/20);for(let e=1;e2*c){const e=p.add(f.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,m,0,0,h),p=e}}}}addCurrentVertex(t,e,r,n,s,a=!1){const o=e.y*n-e.x,l=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,a,!1,r,s),this.addHalfVertex(t,o,l,a,!0,-n,s),this.distance>go/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,r,n,s,a))}addHalfVertex({x:t,y:e},r,n,s,a,o,l){const u=.5*(this.lineClips?this.scaledDistance*(go-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(s?1:0),(e<<1)+(a?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===o?0:o<0?-1:1)|(63&u)<<2,u>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),l.primitiveLength++),a?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}let xo,vo;Kr("LineBucket",mo,{omit:["layers","patternFeatures"]});var wo={get paint(){return vo=vo||new Tn({"line-opacity":new Cn(w.paint_line["line-opacity"]),"line-color":new Cn(w.paint_line["line-color"]),"line-translate":new Pn(w.paint_line["line-translate"]),"line-translate-anchor":new Pn(w.paint_line["line-translate-anchor"]),"line-width":new Cn(w.paint_line["line-width"]),"line-gap-width":new Cn(w.paint_line["line-gap-width"]),"line-offset":new Cn(w.paint_line["line-offset"]),"line-blur":new Cn(w.paint_line["line-blur"]),"line-dasharray":new Vn(w.paint_line["line-dasharray"]),"line-pattern":new Bn(w.paint_line["line-pattern"]),"line-gradient":new En(w.paint_line["line-gradient"])})},get layout(){return xo=xo||new Tn({"line-cap":new Pn(w.layout_line["line-cap"]),"line-join":new Cn(w.layout_line["line-join"]),"line-miter-limit":new Pn(w.layout_line["line-miter-limit"]),"line-round-limit":new Pn(w.layout_line["line-round-limit"]),"line-sort-key":new Cn(w.layout_line["line-sort-key"])})}};class bo extends Cn{possiblyEvaluate(t,e){return e=new bn(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=u({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let _o;function ko(t,e){return e>0?e+2*t:t}const So=qn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Ao=qn([{name:"a_projected_pos",components:3,type:"Float32"}],4);qn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Io=qn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);qn([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const zo=qn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4);function Po(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()),Fn.applyArabicShaping&&(t=Fn.applyArabicShaping(t)),t}(t.text,e,r)})),t}qn([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4),qn([{name:"triangle",components:3,type:"Uint16"}]),qn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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"}]),qn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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",name:"textBoxScale"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),qn([{type:"Float32",name:"offsetX"}]),qn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const Co={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Mo=24,Bo=To,Vo=function(t,e,r,n,s){var a,o,l=8*s-n-1,u=(1<>1,h=-7,p=r?s-1:0,d=r?-1:1,f=t[e+p];for(p+=d,a=f&(1<<-h)-1,f>>=-h,h+=l;h>0;a=256*a+t[e+p],p+=d,h-=8);for(o=a&(1<<-h)-1,a>>=-h,h+=n;h>0;o=256*o+t[e+p],p+=d,h-=8);if(0===a)a=1-c;else{if(a===u)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),a-=c}return(f?-1:1)*o*Math.pow(2,a-n)},Eo=function(t,e,r,n,s,a){var o,l,u,c=8*a-s-1,h=(1<>1,d=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-1,y=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+p>=1?d/u:d*Math.pow(2,1-p))*u>=2&&(o++,u/=2),o+p>=h?(l=0,o=h):o+p>=1?(l=(e*u-1)*Math.pow(2,s),o+=p):(l=e*Math.pow(2,p-1)*Math.pow(2,s),o=0));s>=8;t[r+f]=255&l,f+=y,l/=256,s-=8);for(o=o<0;t[r+f]=255&o,f+=y,o/=256,c-=8);t[r+f-y]|=128*m};function To(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}To.Varint=0,To.Fixed64=1,To.Bytes=2,To.Fixed32=5;var Do=4294967296,Fo=1/Do,$o="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Lo(t){return t.type===To.Bytes?t.readVarint()+t.pos:t.pos+1}function Oo(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Uo(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var s=r.pos-1;s>=t;s--)r.buf[s+n]=r.buf[s]}function qo(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Wo(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}To.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&n,t(s,e,this),this.pos===a&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Xo(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Wo(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Xo(this.buf,this.pos)+Xo(this.buf,this.pos+4)*Do;return this.pos+=8,t},readSFixed64:function(){var t=Xo(this.buf,this.pos)+Wo(this.buf,this.pos+4)*Do;return this.pos+=8,t},readFloat:function(){var t=Vo(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Vo(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,s,a=r.buf;if(n=(112&(s=a[r.pos++]))>>4,s<128)return Oo(t,n,e);if(n|=(127&(s=a[r.pos++]))<<3,s<128)return Oo(t,n,e);if(n|=(127&(s=a[r.pos++]))<<10,s<128)return Oo(t,n,e);if(n|=(127&(s=a[r.pos++]))<<17,s<128)return Oo(t,n,e);if(n|=(127&(s=a[r.pos++]))<<24,s<128)return Oo(t,n,e);if(n|=(1&(s=a[r.pos++]))<<31,s<128)return Oo(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&$o?function(t,e,r){return $o.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",s=e;s239?4:u>223?3:u>191?2:1;if(s+h>r)break;1===h?u<128&&(c=u):2===h?128==(192&(a=t[s+1]))&&(c=(31&u)<<6|63&a)<=127&&(c=null):3===h?(o=t[s+2],128==(192&(a=t[s+1]))&&128==(192&o)&&((c=(15&u)<<12|(63&a)<<6|63&o)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(o=t[s+2],l=t[s+3],128==(192&(a=t[s+1]))&&128==(192&o)&&128==(192&l)&&((c=(15&u)<<18|(63&a)<<12|(63&o)<<6|63&l)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),s+=h}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==To.Bytes)return t.push(this.readVarint(e));var r=Lo(this);for(t=t||[];this.pos127;);else if(e===To.Bytes)this.pos=this.readVarint()+this.pos;else if(e===To.Fixed32)this.pos+=4;else{if(e!==To.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7)}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,s,a=0;a55295&&n<57344){if(!s){n>56319||a+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):s=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,s=n;continue}n=s-55296<<10|n-56320|65536,s=null}else s&&(t[r++]=239,t[r++]=191,t[r++]=189,s=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128)}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&Uo(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Eo(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Eo(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&Uo(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,r){this.writeTag(t,To.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,qo,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,jo,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Zo,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,Ro,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,No,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Jo,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Ko,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Go,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Yo,e)},writeBytesField:function(t,e){this.writeTag(t,To.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,To.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,To.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,To.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,To.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,To.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,To.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,To.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,To.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,To.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Qo=t(Bo);const tl=3;function el(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 s=0,a=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,a=Math.max(a,e.y+e.h),s=Math.max(s,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t=0&&r>=t&&cl[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 ol;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(al.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ul(t,e,r,n,s,a,o,l,u,c,h,p,d,f,y,m){const g=ol.fromFeature(t,s);let x;p===sl.vertical&&g.verticalizePunctuation();const{processBidirectionalText:b,processStyledBidirectionalText:w}=Fn;if(b&&1===g.sections.length){x=[];const t=b(g.toString(),gl(g,c,a,e,n,f,y));for(const e of t){const t=new ol;t.text=e,t.sections=g.sections;for(let r=0;r0&&a>I&&(I=a)}else{const t=r[y.fontStack],n=t&&t[g];if(n&&n.rect)z=n.rect,w=n.metrics;else{const t=e[y.fontStack],r=t&&t[g];if(!r)continue;w=r.metrics}x=(s-y.scale)*Mo}M?(t.verticalizable=!0,S.push({glyph:g,imageName:P,x:d,y:f+x,vertical:M,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:w,rect:z}),d+=C*y.scale+c):(S.push({glyph:g,imageName:P,x:d,y:f+x,vertical:M,scale:y.scale,fontStack:y.fontStack,sectionIndex:m,metrics:w,rect:z}),d+=w.advance*y.scale+c)}0!==S.length&&(y=Math.max(d-c,y),vl(S,0,S.length-1,g,I)),d=0;const z=a*s+I;w.lineOffset=Math.max(I,l),f+=z,m=Math.max(z,m),++x}var b;const w=f-ll,{horizontalAlign:S,verticalAlign:I}=xl(o);(function(t,e,r,n,s,a,o,l,u){const c=(e-r)*s;let h=0;h=a!==o?-l*n-ll:(-n*u+.5)*o;for(const e of t)for(const t of e.positionedGlyphs)t.x+=c,t.y+=h})(t.positionedLines,g,S,I,y,m,a,w,s.length),t.top+=-I*w,t.bottom=t.top+w,t.left+=-S*y,t.right=t.left+y}(I,e,r,n,x,o,l,u,p,c,d,m),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(S)&&I}const cl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},hl={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 pl(t,e,r,n,s,a){if(e.imageName){const t=n[e.imageName];return t?t.displaySize[0]*e.scale*Mo/a+s:0}{const n=r[e.fontStack],a=n&&n[t];return a?a.metrics.advance*e.scale+s:0}}function dl(t,e,r,n){const s=Math.pow(t-e,2);return n?t=0;let h=0;for(let r=0;rt.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=$s([]),this.placementViewportMatrix=$s([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Al(this.zoom,e["text-size"]),this.iconSizeData=Al(this.zoom,e["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),s=r.get("symbol-z-order");this.canOverlap="never"!==Il(r,"text-overlap","text-allow-overlap")||"never"!==Il(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map((t=>sl[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Bl(new os(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Bl(new os(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new mi,this.lineVertexArray=new gi,this.symbolInstances=new yi}calculateGlyphDependencies(t,e,r,n,s){for(let a=0;a0)&&("constant"!==a.value.kind||a.value.value.length>0),c="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=s.get("symbol-sort-key");if(this.features=[],!u&&!c)return;const p=e.iconDependencies,d=e.glyphDependencies,f=e.availableImages,y=new bn(this.zoom);for(const{feature:e,id:o,index:l,sourceLayerIndex:m}of t){const t=n._featureFilter.needGeometry,g=ys(e,t);if(!n._featureFilter.filter(y,g,r))continue;let x,b;if(t||(g.geometry=fs(e)),u){const t=n.getValueAndResolveTokens("text-field",g,r,f),e=dt.factory(t);Tl(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===xn||this.hasRTLText&&Fn.isParsed())&&(x=Po(e,n,g))}if(c){const t=n.getValueAndResolveTokens("icon-image",g,r,f);b=t instanceof yt?t:yt.fromString(t)}if(!x&&!b)continue;const w=this.sortFeaturesByKey?h.evaluate(g,{},r):void 0;if(this.features.push({id:o,text:x,icon:b,index:l,sourceLayerIndex:m,geometry:g.geometry,properties:e.properties,type:zl[e.type],sortKey:w}),b&&(p[b.name]=!0),x){const t=a.evaluate(g,{},r).join(","),e="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(sl.vertical)>=0;for(const r of x.sections)if(r.image)p[r.image.name]=!0;else{const n=cn(x.toString()),s=r.fontStack||t,a=d[s]=d[s]||{};this.calculateGlyphDependencies(r.text,a,e,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let s=0;function a(e){n.push(t[e]),s++}function o(t,e,s){const a=r[t];return delete r[t],r[e]=a,n[a].geometry[0].pop(),n[a].geometry[0]=n[a].geometry[0].concat(s[0]),a}function l(t,r,s){const a=e[r];return delete e[r],e[t]=a,n[a].geometry[0].shift(),n[a].geometry[0]=s[0].concat(n[a].geometry[0]),a}function u(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment){let r=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const s={};for(let n=t.segment+1;n=0;r--)s[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:n},r>0&&(n+=e[r-1].dist(e[r]));for(let t=0;t0}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}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||s[e]-s[t])),a}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),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Dl,Fl;Kr("SymbolBucket",El,{omit:["layers","collisionBoxArray","features","compareText"]}),El.MAX_GLYPHS=65535,El.addDynamicAttributes=Ml;var Ol={get paint(){return Fl=Fl||new Tn({"icon-opacity":new Cn(w.paint_symbol["icon-opacity"]),"icon-color":new Cn(w.paint_symbol["icon-color"]),"icon-halo-color":new Cn(w.paint_symbol["icon-halo-color"]),"icon-halo-width":new Cn(w.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Cn(w.paint_symbol["icon-halo-blur"]),"icon-translate":new Pn(w.paint_symbol["icon-translate"]),"icon-translate-anchor":new Pn(w.paint_symbol["icon-translate-anchor"]),"text-opacity":new Cn(w.paint_symbol["text-opacity"]),"text-color":new Cn(w.paint_symbol["text-color"],{runtimeType:B,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Cn(w.paint_symbol["text-halo-color"]),"text-halo-width":new Cn(w.paint_symbol["text-halo-width"]),"text-halo-blur":new Cn(w.paint_symbol["text-halo-blur"]),"text-translate":new Pn(w.paint_symbol["text-translate"]),"text-translate-anchor":new Pn(w.paint_symbol["text-translate-anchor"])})},get layout(){return Dl=Dl||new Tn({"symbol-placement":new Pn(w.layout_symbol["symbol-placement"]),"symbol-spacing":new Pn(w.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Pn(w.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Cn(w.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Pn(w.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Pn(w.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Pn(w.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Pn(w.layout_symbol["icon-ignore-placement"]),"icon-optional":new Pn(w.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Pn(w.layout_symbol["icon-rotation-alignment"]),"icon-size":new Cn(w.layout_symbol["icon-size"]),"icon-text-fit":new Pn(w.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Pn(w.layout_symbol["icon-text-fit-padding"]),"icon-image":new Cn(w.layout_symbol["icon-image"]),"icon-rotate":new Cn(w.layout_symbol["icon-rotate"]),"icon-padding":new Cn(w.layout_symbol["icon-padding"]),"icon-keep-upright":new Pn(w.layout_symbol["icon-keep-upright"]),"icon-offset":new Cn(w.layout_symbol["icon-offset"]),"icon-anchor":new Cn(w.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Pn(w.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Pn(w.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Pn(w.layout_symbol["text-rotation-alignment"]),"text-field":new Cn(w.layout_symbol["text-field"]),"text-font":new Cn(w.layout_symbol["text-font"]),"text-size":new Cn(w.layout_symbol["text-size"]),"text-max-width":new Cn(w.layout_symbol["text-max-width"]),"text-line-height":new Pn(w.layout_symbol["text-line-height"]),"text-letter-spacing":new Cn(w.layout_symbol["text-letter-spacing"]),"text-justify":new Cn(w.layout_symbol["text-justify"]),"text-radial-offset":new Cn(w.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Pn(w.layout_symbol["text-variable-anchor"]),"text-anchor":new Cn(w.layout_symbol["text-anchor"]),"text-max-angle":new Pn(w.layout_symbol["text-max-angle"]),"text-writing-mode":new Pn(w.layout_symbol["text-writing-mode"]),"text-rotate":new Cn(w.layout_symbol["text-rotate"]),"text-padding":new Pn(w.layout_symbol["text-padding"]),"text-keep-upright":new Pn(w.layout_symbol["text-keep-upright"]),"text-transform":new Cn(w.layout_symbol["text-transform"]),"text-offset":new Cn(w.layout_symbol["text-offset"]),"text-allow-overlap":new Pn(w.layout_symbol["text-allow-overlap"]),"text-overlap":new Pn(w.layout_symbol["text-overlap"]),"text-ignore-placement":new Pn(w.layout_symbol["text-ignore-placement"]),"text-optional":new Pn(w.layout_symbol["text-optional"])})}};class $l{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:z,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}}Kr("FormatSectionOverride",$l,{omit:["defaultValue"]});class Ll extends Dn{constructor(t){super(t,Ol)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const r of t)e.indexOf(r)<0&&e.push(r);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,r,n){const s=this.layout.get(t).evaluate(e,{},r,n),a=this._unevaluatedLayout._values[t];return a.isDataDriven()||Ge(a.value)||!s?s:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>r in t?String(t[r]):""))}(e.properties,s)}createBucket(t){return new El(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Ol.paint.overridableProperties){if(!Ll.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new $l(e),n=new Je(r,e.property.specification);let s=null;s="constant"===e.value.kind||"source"===e.value.kind?new Xe("source",n):new Ye("composite",n,e.value.zoomStops),this.paint._values[t]=new zn(e.property,s,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,r){return!(!this.layout||e.isDataDriven()||r.isDataDriven())&&Ll.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=Ol.paint.properties[e];let s=!1;const a=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(s=!0)};if("constant"===r.value.kind&&r.value.value instanceof dt)a(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{s||(e instanceof bt&&vt(e.value)===D?a(e.value.sections):e instanceof ke?a(e.sections):e.eachChild(t))},e=r.value;e._styleExpression&&t(e._styleExpression.expression)}return s}}let Ul;var ql={get paint(){return Ul=Ul||new Tn({"background-color":new Pn(w.paint_background["background-color"]),"background-pattern":new Vn(w.paint_background["background-pattern"]),"background-opacity":new Pn(w.paint_background["background-opacity"])})}};let jl;var Nl={get paint(){return jl=jl||new Tn({"raster-opacity":new Pn(w.paint_raster["raster-opacity"]),"raster-hue-rotate":new Pn(w.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Pn(w.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Pn(w.paint_raster["raster-brightness-max"]),"raster-saturation":new Pn(w.paint_raster["raster-saturation"]),"raster-contrast":new Pn(w.paint_raster["raster-contrast"]),"raster-resampling":new Pn(w.paint_raster["raster-resampling"]),"raster-fade-duration":new Pn(w.paint_raster["raster-fade-duration"])})}};class Rl extends Dn{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}const Zl={circle:class extends Dn{constructor(t){super(t,Ds)}createBucket(t){return new ms(t)}queryRadius(t){const e=t;return Cs("circle-radius",this,e)+Cs("circle-stroke-width",this,e)+Ms(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,r,n,s,a,o,l){const u=Bs(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,o),c=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r),h="map"===this.paint.get("circle-pitch-alignment"),p=h?u:function(t,e){return t.map((t=>Us(t,e)))}(u,l),d=h?c*o:c;for(const t of n)for(const e of t){const t=h?e:Us(e,l);let r=d;const n=Ls([],[e.x,e.y,0,1],l);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?r*=n[3]/a.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(r*=a.cameraToCenterDistance/n[3]),vs(p,t,r))return!0}return!1}},heatmap:class extends Dn{createBucket(t){return new Os(t)}constructor(t){super(t,js),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=function(t){const e={},r=t.resolution||256,n=t.clips?t.clips.length:1,s=t.image||new Js({width:r,height:n});if(Math.log(r)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${r}`);const a=(r,n,a)=>{e[t.evaluationKey]=a;const o=t.expression.evaluate(e);s.data[r+n+0]=Math.floor(255*o.r/o.a),s.data[r+n+1]=Math.floor(255*o.g/o.a),s.data[r+n+2]=Math.floor(255*o.b/o.a),s.data[r+n+3]=Math.floor(255*o.a)};if(t.clips)for(let e=0,s=0;e=3)for(let e=0;ethis._layers[t.id])),r=e[0];if("none"===r.visibility)continue;const n=r.source||"";let s=this.familiesBySource[n];s||(s=this.familiesBySource[n]={});const a=r.sourceLayer||"_geojsonTileLayer";let o=s[a];o||(o=s[a]=[]),o.push(e)}}}class Gl{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Kl{constructor(t,e,r,n,s){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=r,t._y=n,this.properties=t.properties,this.id=s}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class Xl{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new v(hs,16,0),this.grid3D=new v(hs,16,0),this.featureIndexArray=new vi,this.promoteId=e}insert(t,e,r,n,s,a){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,s);const l=a?this.grid3D:this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(o,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new qa.VectorTile(new Qo(this.rawTileData)).layers,this.sourceLayerCoder=new Gl(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,r,s){this.loadVTLayers();const a=t.params||{},o=hs/t.tileSize/t.scale,l=nr(a.filter),u=t.queryGeometry,c=t.queryPadding*o,h=Wl(u),p=this.grid.query(h.minX-c,h.minY-c,h.maxX+c,h.maxY+c),d=Wl(t.cameraQueryGeometry),f=this.grid3D.query(d.minX-c,d.minY-c,d.maxX+c,d.maxY+c,((e,r,s,a)=>function(t,e,r,s,a){for(const n of t)if(e<=n.x&&r<=n.y&&s>=n.x&&a>=n.y)return!0;const o=[new n(e,r),new n(e,a),new n(s,a),new n(s,r)];if(t.length>2)for(const e of o)if(zs(t,e))return!0;for(let e=0;e(d||(d=fs(e)),r.queryIntersectsFeature(u,e,n,d,this.z,t.transform,o,t.pixelPosMatrix))))}return y}loadMatchingFeature(t,e,r,n,s,a,o,l,c,h,p){const d=this.bucketLayerIDs[e];if(a&&!function(t,e){for(let r=0;r=0)return!0;return!1}(a,d))return;const f=this.sourceLayerCoder.decode(r),y=this.vtLayers[f].feature(n);if(s.needGeometry){const t=ys(y,!0);if(!s.filter(new bn(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!s.filter(new bn(this.tileID.overscaledZ),y))return;const m=this.getId(y,f);for(let e=0;e{const o=e instanceof Mn?e.get(a):null;return o&&o.evaluate?o.evaluate(r,n,s):o}))}function Wl(t){let e=1/0,r=1/0,n=-1/0,s=-1/0;for(const a of t)e=Math.min(e,a.x),r=Math.min(r,a.y),n=Math.max(n,a.x),s=Math.max(s,a.y);return{minX:e,minY:r,maxX:n,maxY:s}}function tu(t,e){return e-t}Kr("FeatureIndex",Xl,{omit:["rawTileData","sourceLayerCoder"]});class Ql extends n{constructor(t,e,r,n){super(t,e),this.angle=r,void 0!==n&&(this.segment=n)}clone(){return new Ql(this.x,this.y,this.angle,this.segment)}}function eu(t,e,r,n,s){if(void 0===e.segment)return!0;let a=e,o=e.segment+1,l=0;for(;l>-r/2;){if(o--,o<0)return!1;l-=t[o].dist(a),a=t[o]}l+=t[o].dist(t[o+1]),o++;const u=[];let c=0;for(;ln;)c-=u.shift().angleDelta;if(c>s)return!1;o++,l+=e.dist(r)}return!0}function ru(t){let e=0;for(let r=0;rc){const h=(c-u)/a,p=se.number(n.x,s.x,h),d=se.number(n.y,s.y,h),f=new Ql(p,d,s.angleTo(n),r);return f._round(),!o||eu(t,f,l,o,e)?f:void 0}u+=a}}function au(t,e,r,n,s,a,o,l,u){const c=nu(n,a,o),h=iu(n,s),p=h*o,d=0===t[0].x||t[0].x===u||0===t[0].y||t[0].y===u;return e-p=0&&x=0&&b=0&&d+c<=h){const r=new Ql(x,b,m,e);r._round(),n&&!eu(t,r,a,n,s)||f.push(r)}}p+=y}return l||f.length||o||(f=ou(t,p/2,r,n,s,a,o,!0,u)),f}Kr("Anchor",Ql);const lu=il;function uu(t,e,r,s){const a=[],o=t.image,l=o.pixelRatio,u=o.paddedRect.w-2*lu,c=o.paddedRect.h-2*lu,h=t.right-t.left,p=t.bottom-t.top,d=o.stretchX||[[0,u]],f=o.stretchY||[[0,c]],y=(t,e)=>t+e[1]-e[0],m=d.reduce(y,0),g=f.reduce(y,0),x=u-m,b=c-g;let w=0,S=m,I=0,z=g,P=0,C=x,M=0,B=b;if(o.content&&s){const t=o.content;w=cu(d,0,t[0]),I=cu(f,0,t[1]),S=cu(d,t[0],t[2]),z=cu(f,t[1],t[3]),P=t[0]-w,M=t[1]-I,C=t[2]-t[0]-S,B=t[3]-t[1]-z}const V=(s,a,u,c)=>{const d=pu(s.stretch-w,S,h,t.left),f=yu(s.fixed-P,C,s.stretch,m),y=pu(a.stretch-I,z,p,t.top),x=yu(a.fixed-M,B,a.stretch,g),b=pu(u.stretch-w,S,h,t.left),V=yu(u.fixed-P,C,u.stretch,m),E=pu(c.stretch-I,z,p,t.top),T=yu(c.fixed-M,B,c.stretch,g),D=new n(d,y),F=new n(b,y),$=new n(b,E),L=new n(d,E),O=new n(f/l,x/l),U=new n(V/l,T/l),q=e*Math.PI/180;if(q){const t=Math.sin(q),e=Math.cos(q),r=[e,-t,t,e];D._matMult(r),F._matMult(r),L._matMult(r),$._matMult(r)}const j=s.stretch+s.fixed,R=a.stretch+a.fixed;return{tl:D,tr:F,bl:L,br:$,tex:{x:o.paddedRect.x+lu+j,y:o.paddedRect.y+lu+R,w:u.stretch+u.fixed-j,h:c.stretch+c.fixed-R},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:O,pixelOffsetBR:U,minFontScaleX:C/l/h,minFontScaleY:B/l/p,isSDF:r}};if(s&&(o.stretchX||o.stretchY)){const t=hu(d,x,m),e=hu(f,b,g);for(let r=0;r0&&(n=Math.max(10,n),this.circleDiameter=n)}else{let c=o.top*l-u[0],p=o.bottom*l+u[2],d=o.left*l-u[3],f=o.right*l+u[1];const y=o.collisionPadding;if(y&&(d-=y[0]*l,c-=y[1]*l,f+=y[2]*l,p+=y[3]*l),h){const t=new n(d,c),e=new n(f,c),r=new n(d,p),s=new n(f,p),a=h*Math.PI/180;t._rotate(a),e._rotate(a),r._rotate(a),s._rotate(a),d=Math.min(t.x,e.x,r.x,s.x),f=Math.max(t.x,e.x,r.x,s.x),c=Math.min(t.y,e.y,r.y,s.y),p=Math.max(t.y,e.y,r.y,s.y)}t.emplaceBack(e.x,e.y,d,c,f,p,r,s,a)}this.boxEndIndex=t.length}}class fu{constructor(t=[],e=mu){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.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,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 s=t-1>>1,a=e[s];if(r(n,a)>=0)break;e[t]=a,t=s}e[t]=n}_down(t){const{data:e,compare:r}=this,n=this.length>>1,s=e[t];for(;t=0)break;e[t]=a,t=n}e[t]=s}}function mu(t,e){return te?1:0}function gu(t,e=1,r=!1){let s=1/0,a=1/0,o=-1/0,l=-1/0;const u=t[0];for(let t=0;to)&&(o=e.x),(!t||e.y>l)&&(l=e.y)}const c=Math.min(o-s,l-a);let h=c/2;const p=new fu([],xu);if(0===c)return new n(s,a);for(let e=s;ed.d||!d.d)&&(d=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,f)),n.max-d.d<=e||(h=n.h/2,p.push(new vu(n.p.x-h,n.p.y-h,h,t)),p.push(new vu(n.p.x+h,n.p.y-h,h,t)),p.push(new vu(n.p.x-h,n.p.y+h,h,t)),p.push(new vu(n.p.x+h,n.p.y+h,h,t)),f+=4)}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${d.d}`)),d.p}function xu(t,e){return e.max-t.max}function vu(t,e,r,s){this.p=new n(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let s=0;st.y!=l.y>t.y&&t.x<(l.x-s.x)*(t.y-s.y)/(l.y-s.y)+s.x&&(r=!r),n=Math.min(n,As(t,s,l))}}return(r?1:-1)*Math.sqrt(n)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}const bu=Number.POSITIVE_INFINITY;function wu(t){t.bucket.createArrays(),t.bucket.tilePixelRatio=hs/(512*t.bucket.overscaling),t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;const e=t.bucket.layers[0].layout,r=t.bucket.layers[0]._unevaluatedLayout._values,n={layoutIconSize:r["icon-size"].possiblyEvaluate(new bn(t.bucket.zoom+1),t.canonical),layoutTextSize:r["text-size"].possiblyEvaluate(new bn(t.bucket.zoom+1),t.canonical),textMaxSize:r["text-size"].possiblyEvaluate(new bn(18))};if("composite"===t.bucket.textSizeData.kind){const{minZoom:e,maxZoom:s}=t.bucket.textSizeData;n.compositeTextSizes=[r["text-size"].possiblyEvaluate(new bn(e),t.canonical),r["text-size"].possiblyEvaluate(new bn(s),t.canonical)]}if("composite"===t.bucket.iconSizeData.kind){const{minZoom:e,maxZoom:s}=t.bucket.iconSizeData;n.compositeIconSizes=[r["icon-size"].possiblyEvaluate(new bn(e),t.canonical),r["icon-size"].possiblyEvaluate(new bn(s),t.canonical)]}const s=e.get("text-line-height")*Mo,a="viewport"!==e.get("text-rotation-alignment")&&"point"!==e.get("symbol-placement"),o=e.get("text-keep-upright"),l=e.get("text-size");for(const r of t.bucket.features){const h=e.get("text-font").evaluate(r,{},t.canonical).join(","),p=l.evaluate(r,{},t.canonical),f=n.layoutTextSize.evaluate(r,{},t.canonical),y=n.layoutIconSize.evaluate(r,{},t.canonical),m={horizontal:{},vertical:void 0},g=r.text;let x,b=[0,0];if(g){const n=g.toString(),l=e.get("text-letter-spacing").evaluate(r,{},t.canonical)*Mo,d=hn(n)?l:0,y=e.get("text-anchor").evaluate(r,{},t.canonical),x=e.get("text-variable-anchor");if(!x){const n=e.get("text-radial-offset").evaluate(r,{},t.canonical);n?(u=y,b=(c=[n*Mo,bu])[1]!==bu?function(t,e,r){let n=0,s=0;switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":s=r-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-r}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}return[n,s]}(u,c[0],c[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const s=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":n=s-7;break;case"bottom-right":case"bottom-left":n=7-s;break;case"bottom":n=7-e;break;case"top":n=e-7}switch(t){case"top-right":case"bottom-right":r=-s;break;case"top-left":case"bottom-left":r=s;break;case"left":r=e;break;case"right":r=-e}return[r,n]}(u,c[0])):b=e.get("text-offset").evaluate(r,{},t.canonical).map((t=>t*Mo))}let w=a?"center":e.get("text-justify").evaluate(r,{},t.canonical);const S=e.get("symbol-placement"),I="point"===S?e.get("text-max-width").evaluate(r,{},t.canonical)*Mo:0,z=()=>{t.bucket.allowVerticalPlacement&&cn(n)&&(m.vertical=ul(g,t.glyphMap,t.glyphPositions,t.imagePositions,h,I,s,y,"left",d,b,sl.vertical,!0,S,f,p))};if(!a&&x){const e="auto"===w?x.map((t=>_u(t))):[w];let r=!1;for(let n=0;n{u.x<0||u.x>=hs||u.y<0||u.y>=hs||function(t,e,r,n,s,a,o,l,u,c,h,p,f,y,m,g,x,b,w,S,I,z,P,C,M){const B=t.addToLineVertexArray(e,r);let V,E,T,D,F=0,$=0,L=0,O=0,U=-1,q=-1;const j={};let R=Ki(""),N=0,Z=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[N,Z]=l.layout.get("text-offset").evaluate(I,{},C).map((t=>t*Mo)):(N=l.layout.get("text-radial-offset").evaluate(I,{},C)*Mo,Z=bu),t.allowVerticalPlacement&&n.vertical){const t=l.layout.get("text-rotate").evaluate(I,{},C)+90;T=new du(u,e,c,h,p,n.vertical,f,y,m,t),o&&(D=new du(u,e,c,h,p,o,x,b,m,t))}if(s){const r=l.layout.get("icon-rotate").evaluate(I,{}),n="none"!==l.layout.get("icon-text-fit"),a=uu(s,r,P,n),f=o?uu(o,r,P,n):void 0;E=new du(u,e,c,h,p,s,x,b,!1,r),F=4*a.length;const y=t.iconSizeData;let m=null;"source"===y.kind?(m=[kl*l.layout.get("icon-size").evaluate(I,{})],m[0]>Sl&&d(`${t.layerIds[0]}: Value for "icon-size" is >= ${_l}. Reduce your "icon-size".`)):"composite"===y.kind&&(m=[kl*z.compositeIconSizes[0].evaluate(I,{},C),kl*z.compositeIconSizes[1].evaluate(I,{},C)],(m[0]>Sl||m[1]>Sl)&&d(`${t.layerIds[0]}: Value for "icon-size" is >= ${_l}. Reduce your "icon-size".`)),t.addSymbols(t.icon,a,m,S,w,I,sl.none,e,B.lineStartIndex,B.lineLength,-1,C),U=t.icon.placedSymbolArray.length-1,f&&($=4*f.length,t.addSymbols(t.icon,f,m,S,w,I,sl.vertical,e,B.lineStartIndex,B.lineLength,-1,C),q=t.icon.placedSymbolArray.length-1)}const J=Object.keys(n.horizontal);for(const r of J){const s=n.horizontal[r];if(!V){R=Ki(s.text);const t=l.layout.get("text-rotate").evaluate(I,{},C);V=new du(u,e,c,h,p,s,f,y,m,t)}const o=1===s.positionedLines.length;if(L+=Su(t,e,s,a,l,m,I,g,B,n.vertical?sl.horizontal:sl.horizontalOnly,o?J:[r],j,U,z,C),o)break}n.vertical&&(O+=Su(t,e,n.vertical,a,l,m,I,g,B,sl.vertical,["vertical"],j,q,z,C));const K=V?V.boxStartIndex:t.collisionBoxArray.length,G=V?V.boxEndIndex:t.collisionBoxArray.length,Y=T?T.boxStartIndex:t.collisionBoxArray.length,X=T?T.boxEndIndex:t.collisionBoxArray.length,H=E?E.boxStartIndex:t.collisionBoxArray.length,W=E?E.boxEndIndex:t.collisionBoxArray.length,Q=D?D.boxStartIndex:t.collisionBoxArray.length,tt=D?D.boxEndIndex:t.collisionBoxArray.length;let et=-1;const rt=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;et=rt(V,et),et=rt(T,et),et=rt(E,et),et=rt(D,et);const nt=et>-1?1:0;nt&&(et*=M/Mo),t.glyphOffsetArray.length>=El.MAX_GLYPHS&&d("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==I.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,I.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical||-1,U,q,R,K,G,Y,X,H,W,Q,tt,c,L,O,F,$,nt,0,f,N,Z,et)}(t,u,n,r,s,a,D,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,b,[z,z,z,z],M,c,S,P,B,m,e,o,h,p,l)};if("line"===V)for(const a of function(t,e,r,s,a){const o=[];for(let e=0;e=s&&u.x>=s||(e.x>=s?e=new n(s,e.y+(s-e.x)/(u.x-e.x)*(u.y-e.y))._round():u.x>=s&&(u=new n(s,e.y+(s-e.x)/(u.x-e.x)*(u.y-e.y))._round()),e.y>=a&&u.y>=a||(e.y>=a?e=new n(e.x+(a-e.y)/(u.y-e.y)*(u.x-e.x),a)._round():u.y>=a&&(u=new n(e.x+(a-e.y)/(u.y-e.y)*(u.x-e.x),a)._round()),l&&e.equals(l[l.length-1])||(l=[e],o.push(l)),l.push(u)))))}}return o}(e.geometry,0,0,hs,hs)){const e=au(a,I,C,r.vertical||g,s,24,w,t.overscaling,hs);for(const r of e)g&&zu(t,g.text,E,r)||F(a,r)}else if("line-center"===V){for(const t of e.geometry)if(t.length>1){const e=su(t,C,r.vertical||g,s,24,w);e&&F(t,e)}}else if("Polygon"===e.type)for(const t of Ma(e.geometry,0)){const e=gu(t,16);F(t[0],new Ql(e.x,e.y,0))}else if("LineString"===e.type)for(const t of e.geometry)F(t,new Ql(t[0].x,t[0].y,0));else if("Point"===e.type)for(const t of e.geometry)for(const e of t)F([e],new Ql(e.x,e.y,0))}function Su(t,e,r,s,a,o,l,u,c,h,p,f,y,m,g){const x=function(t,e,r,s,a,o,l,u){const c=s.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=[];for(const t of e.positionedLines)for(const s of t.positionedGlyphs){if(!s.rect)continue;const o=s.rect||{};let p=tl+1,d=!0,f=1,y=0;const m=(a||u)&&s.vertical,g=s.metrics.advance*s.scale/2;if(u&&e.verticalizable&&(y=t.lineOffset/2-(s.imageName?-(Mo-s.metrics.width*s.scale)/2:(s.scale-1)*Mo)),s.imageName){const t=l[s.imageName];d=t.sdf,f=t.pixelRatio,p=il/f}const x=a?[s.x+g,s.y]:[0,0];let b=a?[0,0]:[s.x+g+r[0],s.y+r[1]-y],w=[0,0];m&&(w=b,b=[0,0]);const S=(s.metrics.left-p)*s.scale-g+b[0],I=(-s.metrics.top-p)*s.scale+b[1],z=S+o.w*s.scale/f,P=I+o.h*s.scale/f,C=new n(S,I),M=new n(z,I),B=new n(S,P),V=new n(z,P);if(m){const t=new n(-g,g-ll),e=-Math.PI/2,r=Mo/2-g,a=new n(5-ll-r,-(s.imageName?r:0)),o=new n(...w);C._rotateAround(e,t)._add(a)._add(o),M._rotateAround(e,t)._add(a)._add(o),B._rotateAround(e,t)._add(a)._add(o),V._rotateAround(e,t)._add(a)._add(o)}if(c){const t=Math.sin(c),e=Math.cos(c),r=[e,-t,t,e];C._matMult(r),M._matMult(r),B._matMult(r),V._matMult(r)}const E=new n(0,0),T=new n(0,0);h.push({tl:C,tr:M,bl:B,br:V,tex:o,writingMode:e.writingMode,glyphOffset:x,sectionIndex:s.sectionIndex,isSDF:d,pixelOffsetTL:E,pixelOffsetBR:T,minFontScaleX:0,minFontScaleY:0})}return h}(0,r,u,a,o,l,s,t.allowVerticalPlacement),b=t.textSizeData;let w=null;"source"===b.kind?(w=[kl*a.layout.get("text-size").evaluate(l,{})],w[0]>Sl&&d(`${t.layerIds[0]}: Value for "text-size" is >= ${_l}. Reduce your "text-size".`)):"composite"===b.kind&&(w=[kl*m.compositeTextSizes[0].evaluate(l,{},g),kl*m.compositeTextSizes[1].evaluate(l,{},g)],(w[0]>Sl||w[1]>Sl)&&d(`${t.layerIds[0]}: Value for "text-size" is >= ${_l}. Reduce your "text-size".`)),t.addSymbols(t.text,x,w,u,o,l,h,e,c.lineStartIndex,c.lineLength,y,g);for(const e of p)f[e]=t.text.placedSymbolArray.length-1;return 4*x.length}function Au(t){for(const e in t)return t[e];return null}function zu(t,e,r,n){const s=t.compareText;if(e in s){const t=s[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Pu(function(t,e,r){const n=((t-e)%360+360)%360+e;return n===e?180:n}(this.lng,-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,s=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Mu*Math.acos(Math.min(s,1))}static convert(t){if(t instanceof Pu)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Pu(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Pu(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Bu=2*Math.PI*Mu;function Vu(t){return Bu*Math.cos(t*Math.PI/180)}function $u(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class Eu{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r}static fromLngLat(t,e=0){const r=Pu.convert(t);return new Eu((180+r.lng)/360,(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r.lat*Math.PI/360)))/360,function(t,e){return t/Vu(e)}(e,r.lat))}toLngLat(){return new Pu(360*this.x-180,$u(this.y))}toAltitude(){return this.z*Vu($u(this.y))}meterInMercatorCoordinateUnits(){return 1/Bu*(t=$u(this.y),1/Math.cos(t*Math.PI/180));var t}}class Tu{constructor(t,e,r){if(t<0||t>25||r<0||r>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))throw new Error(`x=${e}, y=${r}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=r,this.key=Ou(0,t,t,e,r)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,r){const n=(a=this.y,o=this.z,l=Cu(256*(s=this.x),256*(a=Math.pow(2,o)-a-1),o),u=Cu(256*(s+1),256*(a+1),o),l[0]+","+l[1]+","+u[0]+","+u[1]);var s,a,o,l,u;const c=function(t,e,r){let n,s="";for(let a=t;a>0;a--)n=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new n((t.x*e-this.x)*hs,(t.y*e-this.y)*hs)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Fu{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Ou(t,e.z,e.z,e.x,e.y)}}class Du{constructor(t,e,r,n,s){if(t= z; overscaledZ = ${t}; z = ${r}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Tu(r,+n,+s),this.key=Ou(e,t,r,n,s)}clone(){return new Du(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new Du(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Du(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-t;return t>this.canonical.z?Ou(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Ou(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>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Du(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 Du(e,this.wrap,e,r,n),new Du(e,this.wrap,e,r+1,n),new Du(e,this.wrap,e,r,n+1),new Du(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y=e.maxzoom||"none"!==e.visibility&&(qu(t,this.zoom,r),(l[e.id]=e.createBucket({index:o.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:s,sourceID:this.source})).populate(c,u,this.tileID.canonical),o.bucketLayerIDs.push(t.map((t=>t.id))))}}let p,f,y,m;const g=c(u.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(g).length?n.send("getGlyphs",{uid:this.uid,stacks:g,source:this.source,tileID:this.tileID,type:"glyphs"},((t,e)=>{p||(p=t,f=e,w.call(this))})):f={};const x=Object.keys(u.iconDependencies);x.length?n.send("getImages",{icons:x,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{p||(p=t,y=e,w.call(this))})):y={};const b=Object.keys(u.patternDependencies);function w(){if(p)return s(p);if(f&&y&&m){const t=new Iu(f),e=new nl(y,m);for(const n in l){const s=l[n];s instanceof El?(qu(s.layers,this.zoom,r),wu({bucket:s,glyphMap:f,glyphPositions:t.positions,imageMap:y,imagePositions:e.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):s.hasPattern&&(s instanceof mo||s instanceof Ea||s instanceof eo)&&(qu(s.layers,this.zoom,r),s.addFeatures(u,this.tileID.canonical,e.patternPositions))}this.status="done",s(null,{buckets:Object.values(l).filter((t=>!t.isEmpty())),featureIndex:o,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,imageAtlas:e,glyphMap:this.returnDependencies?f:null,iconMap:this.returnDependencies?y:null,glyphPositions:this.returnDependencies?t.positions:null})}}b.length?n.send("getImages",{icons:b,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{p||(p=t,m=e,w.call(this))})):m={},w.call(this)}}function qu(t,e,r){const n=new bn(e);for(const e of t)e.recalculate(n,r)}var ju;!function(t){t.create="create",t.load="load",t.fullLoad="fullLoad"}(ju||(ju={}));class Uu{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}}function Ju(t,e){const r=function(t,e){return Zr(u(t,{type:"arrayBuffer"}),e)}(t.request,((t,r,n,s)=>{t?e(t):r&&e(null,{vectorTile:new qa.VectorTile(new Qo(r)),rawData:r,cacheControl:n,expires:s})}));return()=>{r.cancel(),e()}}class Ru{constructor(t,e,r,n){this.actor=t,this.layerIndex=e,this.availableImages=r,this.loadVectorData=n||Ju,this.loading={},this.loaded={}}loadTile(t,e){const r=t.uid;this.loading||(this.loading={});const n=!!(t&&t.request&&t.request.collectResourceTiming)&&new Uu(t.request),s=this.loading[r]=new Lu(t);s.abort=this.loadVectorData(t,((t,a)=>{if(delete this.loading[r],t||!a)return s.status="done",this.loaded[r]=s,e(t);const o=a.rawData,l={};a.expires&&(l.expires=a.expires),a.cacheControl&&(l.cacheControl=a.cacheControl);const c={};if(n){const t=n.finish();t&&(c.resourceTiming=JSON.parse(JSON.stringify(t)))}s.vectorTile=a.vectorTile,s.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,r)=>{if(t||!r)return e(t);e(null,u({rawTileData:o.slice(0)},r,l,c))})),this.loaded=this.loaded||{},this.loaded[r]=s}))}reloadTile(t,e){const r=this.loaded,n=t.uid,s=this;if(r&&r[n]){const a=r[n];a.showCollisionBoxes=t.showCollisionBoxes;const o=(t,r)=>{const n=a.reloadCallback;n&&(delete a.reloadCallback,a.parse(a.vectorTile,s.layerIndex,this.availableImages,s.actor,n)),e(t,r)};"parsing"===a.status?a.reloadCallback=o:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,o):o())}}abortTile(t,e){const r=this.loading,n=t.uid;r&&r[n]&&r[n].abort&&(r[n].abort(),delete r[n]),e()}removeTile(t,e){const r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e()}}class Nu{constructor(t,e,r){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(r&&"mapbox"!==r&&"terrarium"!==r)return void d(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const n=this.dim=e.height-2;this.data=new Uint32Array(e.data.buffer),this.encoding=r||"mapbox";for(let t=0;tthis.max&&(this.max=r),r=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)}_unpackMapbox(t,e,r){return(256*t*256+256*e+r)/10-1e4}_unpackTerrarium(t,e,r){return 256*t+e+r/256-32768}getPixels(){return new Js({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,s=e*this.dim+this.dim,a=r*this.dim,o=r*this.dim+this.dim;switch(e){case-1:n=s-1;break;case 1:s=n+1}switch(r){case-1:a=o-1;break;case 1:o=a+1}const l=-e*this.dim,u=-r*this.dim;for(let e=a;e=Math.abs(l)?r-u+l:l-u+r,r=u}r+n>=0!=!!e&&t.reverse()}var Yu=t((function t(e,r){var n,s=e&&e.type;if("FeatureCollection"===s)for(n=0;n>31}function hc(t,e){for(var r=t.loadGeometry(),n=t.type,s=0,a=0,o=r.length,l=0;l>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const s=yc[15&r];if(!s)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new fc(o,a,s,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 s=yc.indexOf(this.ArrayType),a=2*t*this.ArrayType.BYTES_PER_ELEMENT,o=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-o%8)%8;if(s<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+o+l,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+a+o+l),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+l,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+s]),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 mc(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:s,coords:a,nodeSize:o}=this,l=[0,s.length-1,0],u=[];for(;l.length;){const c=l.pop()||0,h=l.pop()||0,p=l.pop()||0;if(h-p<=o){for(let o=p;o<=h;o++){const l=a[2*o],c=a[2*o+1];l>=t&&l<=r&&c>=e&&c<=n&&u.push(s[o])}continue}const d=p+h>>1,f=a[2*d],y=a[2*d+1];f>=t&&f<=r&&y>=e&&y<=n&&u.push(s[d]),(0===c?t<=f:e<=y)&&(l.push(p),l.push(d-1),l.push(1-c)),(0===c?r>=f:n>=y)&&(l.push(d+1),l.push(h),l.push(1-c))}return u}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:a}=this,o=[0,n.length-1,0],l=[],u=r*r;for(;o.length;){const c=o.pop()||0,h=o.pop()||0,p=o.pop()||0;if(h-p<=a){for(let r=p;r<=h;r++)bc(s[2*r],s[2*r+1],t,e)<=u&&l.push(n[r]);continue}const d=p+h>>1,f=s[2*d],y=s[2*d+1];bc(f,y,t,e)<=u&&l.push(n[d]),(0===c?t-r<=f:e-r<=y)&&(o.push(p),o.push(d-1),o.push(1-c)),(0===c?t+r>=f:e+r>=y)&&(o.push(d+1),o.push(h),o.push(1-c))}return l}}function mc(t,e,r,n,s,a){if(s-n<=r)return;const o=n+s>>1;gc(t,e,o,n,s,a),mc(t,e,r,n,o-1,1-a),mc(t,e,r,o+1,s,1-a)}function gc(t,e,r,n,s,a){for(;s>n;){if(s-n>600){const o=s-n+1,l=r-n+1,u=Math.log(o),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(o-c)/o)*(l-o/2<0?-1:1);gc(t,e,r,Math.max(n,Math.floor(r-l*c/o+h)),Math.min(s,Math.floor(r+(o-l)*c/o+h)),a)}const o=e[2*r+a];let l=n,u=s;for(xc(t,e,n,r),e[2*s+a]>o&&xc(t,e,n,s);lo;)u--}e[2*n+a]===o?xc(t,e,n,u):(u++,xc(t,e,u,s)),u<=r&&(n=u+1),r<=u&&(s=u-1)}}function xc(t,e,r,n){vc(t,r,n),vc(e,2*r,2*n),vc(e,2*r+1,2*n+1)}function vc(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function bc(t,e,r,n){const s=t-r,a=e-n;return s*s+a*a}const wc={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},_c=Math.fround||(kc=new Float32Array(1),t=>(kc[0]=+t,kc[0]));var kc;const Sc=3,Ac=5,zc=6;class Ic{constructor(t){this.options=Object.assign(Object.create(wc),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 s=`prepare ${t.length} points`;e&&console.time(s),this.points=t;const a=[];for(let e=0;e=r;t--){const r=+Date.now();o=this.trees[t]=this._createTree(this._cluster(o,t)),e&&console.log("z%d: %d clusters in %dms",t,o.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 s=180===t[2]?180:((t[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,s=180;else if(r>s){const t=this.getClusters([r,n,180,a],e),o=this.getClusters([-180,n,s,a],e);return t.concat(o)}const o=this.trees[this._limitZoom(e)],l=o.range(Mc(r),Bc(a),Mc(s),Bc(n)),u=o.data,c=[];for(const t of l){const e=this.stride*t;c.push(u[e+Ac]>1?Pc(u,e,this.clusterProps):this.points[u[e+Sc]])}return c}getChildren(t){const e=this._getOriginId(t),r=this._getOriginZoom(t),n="No cluster with the specified id.",s=this.trees[r];if(!s)throw new Error(n);const a=s.data;if(e*this.stride>=a.length)throw new Error(n);const o=this.options.radius/(this.options.extent*Math.pow(2,r-1)),l=s.within(a[e*this.stride],a[e*this.stride+1],o),u=[];for(const e of l){const r=e*this.stride;a[r+4]===t&&u.push(a[r+Ac]>1?Pc(a,r,this.clusterProps):this.points[a[r+Sc]])}if(0===u.length)throw new Error(n);return u}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)],s=Math.pow(2,t),{extent:a,radius:o}=this.options,l=o/a,u=(r-l)/s,c=(r+1+l)/s,h={features:[]};return this._addTileFeatures(n.range((e-l)/s,u,(e+1+l)/s,c),n.data,e,r,s,h),0===e&&this._addTileFeatures(n.range(1-l/s,u,1,c),n.data,s,r,s,h),e===s-1&&this._addTileFeatures(n.range(0,u,l/s,c),n.data,-1,r,s,h),h.features.length?h: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,s){const a=this.getChildren(e);for(const e of a){const a=e.properties;if(a&&a.cluster?s+a.point_count<=n?s+=a.point_count:s=this._appendLeaves(t,a.cluster_id,r,n,s):s1;let u,c,h;if(l)u=Cc(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const r=this.points[e[t+Sc]];u=r.properties;const[n,s]=r.geometry.coordinates;c=Mc(n),h=Bc(s)}const p={type:1,geometry:[[Math.round(this.options.extent*(c*s-r)),Math.round(this.options.extent*(h*s-n))]],tags:u};let d;d=l||this.options.generateId?e[t+Sc]:this.points[e[t+Sc]].id,void 0!==d&&(p.id=d),a.features.push(p)}}_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:s,minPoints:a}=this.options,o=r/(n*Math.pow(2,e)),l=t.data,u=[],c=this.stride;for(let r=0;re&&(f+=l[r+Ac])}if(f>d&&f>=a){let t,a=n*d,o=h*d,y=-1;const m=((r/c|0)<<5)+(e+1)+this.points.length;for(const n of p){const u=n*c;if(l[u+2]<=e)continue;l[u+2]=e;const h=l[u+Ac];a+=l[u]*h,o+=l[u+1]*h,l[u+4]=m,s&&(t||(t=this._map(l,r,!0),y=this.clusterProps.length,this.clusterProps.push(t)),s(t,this._map(l,u)))}l[r+4]=m,u.push(a/f,o/f,1/0,m,-1,f),s&&u.push(y)}else{for(let t=0;t1)for(const t of p){const r=t*c;if(!(l[r+2]<=e)){l[r+2]=e;for(let t=0;t>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,r){if(t[e+Ac]>1){const n=this.clusterProps[t[e+zc]];return r?Object.assign({},n):n}const n=this.points[t[e+Sc]].properties,s=this.options.map(n);return r&&s===n?Object.assign({},s):s}}function Pc(t,e,r){return{type:"Feature",id:t[e+Sc],properties:Cc(t,e,r),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),Vc(t[e+1])]}};var n}function Cc(t,e,r){const n=t[e+Ac],s=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,a=t[e+zc],o=-1===a?{}:Object.assign({},r[a]);return Object.assign(o,{cluster:!0,cluster_id:t[e+Sc],point_count:n,point_count_abbreviated:s})}function Mc(t){return t/360+.5}function Bc(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 Vc(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function Ec(t,e,r,n){for(var s,a=n,o=r-e>>1,l=r-e,u=t[e],c=t[e+1],h=t[r],p=t[r+1],d=e+3;da)s=d,a=f;else if(f===a){var y=Math.abs(d-o);yn&&(s-e>3&&Ec(t,e,s,n),t[s+2]=a,r-s>3&&Ec(t,s,r,n))}function Tc(t,e,r,n,s,a){var o=s-r,l=a-n;if(0!==o||0!==l){var u=((t-r)*o+(e-n)*l)/(o*o+l*l);u>1?(r=s,n=a):u>0&&(r+=o*u,n+=l*u)}return(o=t-r)*o+(l=e-n)*l}function Dc(t,e,r,n){var s={id:void 0===t?null:t,type:e,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,r=t.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)Fc(t,e);else if("Polygon"===r||"MultiLineString"===r)for(var n=0;n0&&(o+=n?(s*c-u*a)/2:Math.sqrt(Math.pow(u-s,2)+Math.pow(c-a,2))),s=u,a=c}var h=e.length-3;e[2]=1,Ec(e,0,h,r),e[h+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function Uc(t,e,r,n){for(var s=0;s1?1:r}function Rc(t,e,r,n,s,a,o,l){if(n/=e,a>=(r/=e)&&o=n)return null;for(var u=[],c=0;c=r&&y=n)){var m=[];if("Point"===d||"MultiPoint"===d)Nc(p,m,r,n,s);else if("LineString"===d)Zc(p,m,r,n,s,!1,l.lineMetrics);else if("MultiLineString"===d)Kc(p,m,r,n,s,!1);else if("Polygon"===d)Kc(p,m,r,n,s,!0);else if("MultiPolygon"===d)for(var g=0;g=r&&o<=n&&(e.push(t[a]),e.push(t[a+1]),e.push(t[a+2]))}}function Zc(t,e,r,n,s,a,o){for(var l,u,c=Jc(t),h=0===s?Yc:Xc,p=t.start,d=0;dr&&(u=h(c,f,y,g,x,r),o&&(c.start=p+l*u)):b>n?w=r&&(u=h(c,f,y,g,x,r),S=!0),w>n&&b<=n&&(u=h(c,f,y,g,x,n),S=!0),!a&&S&&(o&&(c.end=p+l*u),e.push(c),c=Jc(t)),o&&(p+=l)}var I=t.length-3;f=t[I],y=t[I+1],m=t[I+2],(b=0===s?f:y)>=r&&b<=n&&Gc(c,f,y,m),I=c.length-3,a&&I>=3&&(c[I]!==c[0]||c[I+1]!==c[1])&&Gc(c,c[0],c[1],c[2]),c.length&&e.push(c)}function Jc(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function Kc(t,e,r,n,s,a){for(var o=0;oo.maxX&&(o.maxX=h),p>o.maxY&&(o.maxY=p)}return o}function rh(t,e,r,n){var s=e.geometry,a=e.type,o=[];if("Point"===a||"MultiPoint"===a)for(var l=0;l0&&e.size<(s?o:n))r.numPoints+=e.length/3;else{for(var l=[],u=0;uo)&&(r.numSimplified++,l.push(e[u]),l.push(e[u+1])),r.numPoints++;s&&function(t,e){for(var r=0,n=0,s=t.length,a=s-2;n0===e)for(n=0,s=t.length;n24)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.");var n=function(t,e){var r=[];if("FeatureCollection"===t.type)for(var n=0;n1&&console.time("creation"),d=this.tiles[p]=eh(t,e,r,n,u),this.tileCoords.push({z:e,x:r,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,r,n,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var f="z"+e;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(d.source=t,s){if(e===u.maxZoom||e===s)continue;var y=1<1&&console.time("clipping");var m,g,x,b,w,S,I=.5*u.buffer/u.extent,z=.5-I,P=.5+I,C=1+I;m=g=x=b=null,w=Rc(t,h,r-I,r+P,0,d.minX,d.maxX,u),S=Rc(t,h,r+z,r+C,0,d.minX,d.maxX,u),t=null,w&&(m=Rc(w,h,n-I,n+P,1,d.minY,d.maxY,u),g=Rc(w,h,n+z,n+C,1,d.minY,d.maxY,u),w=null),S&&(x=Rc(S,h,n-I,n+P,1,d.minY,d.maxY,u),b=Rc(S,h,n+z,n+C,1,d.minY,d.maxY,u),S=null),c>1&&console.timeEnd("clipping"),l.push(m||[],e+1,2*r,2*n),l.push(g||[],e+1,2*r,2*n+1),l.push(x||[],e+1,2*r+1,2*n),l.push(b||[],e+1,2*r+1,2*n+1)}}},ih.prototype.getTile=function(t,e,r){var n=this.options,s=n.extent,a=n.debug;if(t<0||t>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",t,e,r);for(var u,c=t,h=e,p=r;!u&&c>0;)c--,h=Math.floor(h/2),p=Math.floor(p/2),u=this.tiles[sh(c,h,p)];return u&&u.source?(a>1&&console.log("found parent tile z%d-%d-%d",c,h,p),a>1&&console.time("drilling down"),this.splitTile(u.source,c,h,p,t,e,r),a>1&&console.timeEnd("drilling down"),this.tiles[l]?Qc(this.tiles[l],s):null):null};class uh extends Ru{constructor(t,e,r,n){super(t,e,r,hh),this._dataUpdateable=new Map,this.loadGeoJSON=(t,e)=>{const{promoteId:r}=t;if(t.request)return function(t,e){return Zr(u(t,{type:"json"}),e)}(t.request,((t,n,s,a)=>{this._dataUpdateable=oh(n,r)?lh(n,r):void 0,e(t,n,s,a)}));if("string"==typeof t.data)try{const n=JSON.parse(t.data);this._dataUpdateable=oh(n,r)?lh(n,r):void 0,e(null,n)}catch(r){e(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}else t.dataDiff?this._dataUpdateable?(function(t,e,r){var n,s,a,o;if(e.removeAll&&t.clear(),e.remove)for(const r of e.remove)t.delete(r);if(e.add)for(const n of e.add){const e=ah(n,r);null!=e&&t.set(e,n)}if(e.update)for(const r of e.update){let e=t.get(r.id);if(null==e)continue;const l=!r.removeAllProperties&&((null===(n=r.removeProperties)||void 0===n?void 0:n.length)>0||(null===(s=r.addOrUpdateProperties)||void 0===s?void 0:s.length)>0);if((r.newGeometry||r.removeAllProperties||l)&&(e={...e},t.set(r.id,e),l&&(e.properties={...e.properties})),r.newGeometry&&(e.geometry=r.newGeometry),r.removeAllProperties)e.properties={};else if((null===(a=r.removeProperties)||void 0===a?void 0:a.length)>0)for(const t of r.removeProperties)Object.prototype.hasOwnProperty.call(e.properties,t)&&delete e.properties[t];if((null===(o=r.addOrUpdateProperties)||void 0===o?void 0:o.length)>0)for(const{key:t,value:n}of r.addOrUpdateProperties)e.properties[t]=n}}(this._dataUpdateable,t.dataDiff,r),e(null,{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())})):e(new Error(`Cannot update existing geojson data in ${t.source}`)):e(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}},n&&(this.loadGeoJSON=n)}loadData(t,e){var r;null===(r=this._pendingRequest)||void 0===r||r.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const n=!!(t&&t.request&&t.request.collectResourceTiming)&&new Uu(t.request);this._pendingCallback=e,this._pendingRequest=this.loadGeoJSON(t,((r,s)=>{if(delete this._pendingCallback,delete this._pendingRequest,r||!s)return e(r);if("object"!=typeof s)return e(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{Yu(s,!0);try{if(t.filter){const e=He(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(", "));const r=s.features.filter((t=>e.value.evaluate({zoom:0},t)));s={type:"FeatureCollection",features:r}}this._geoJSONIndex=t.cluster?new Ic(function({superclusterOptions:t,clusterProperties:e}){if(!e||!t)return t;const r={},n={},s={accumulated:null,zoom:0},a={properties:null},o=Object.keys(e);for(const t of o){const[s,a]=e[t],o=He(a),l=He("string"==typeof s?[s,["accumulated"],["get",t]]:s);r[t]=o.value,n[t]=l.value}return t.map=t=>{a.properties=t;const e={};for(const t of o)e[t]=r[t].evaluate(s,a);return e},t.reduce=(t,e)=>{a.properties=e;for(const e of o)s.accumulated=t[e],t[e]=n[e].evaluate(s,a)},t}(t)).load(s.features):function(t,e){return new ih(t,e)}(s,t.geojsonVtOptions)}catch(r){return e(r)}this.loaded={};const a={};if(n){const e=n.finish();e&&(a.resourceTiming={},a.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)))}e(null,a)}}))}reloadTile(t,e){const r=this.loaded;return r&&r[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}removeSource(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),e()}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 ch{constructor(t){this.self=t,this.actor=new Hr(t,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:Ru,geojson:uh},this.workerSources={},this.demWorkerSources={},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(Fn.isParsed())throw new Error("RTL text plugin already registered.");Fn.applyArabicShaping=t.applyArabicShaping,Fn.processBidirectionalText=t.processBidirectionalText,Fn.processStyledBidirectionalText=t.processStyledBidirectionalText}}setReferrer(t,e){this.referrer=e}setImages(t,e,r){this.availableImages[t]=e;for(const r in this.workerSources[t]){const n=this.workerSources[t][r];for(const t in n)n[t].availableImages=e}r()}setLayers(t,e,r){this.getLayerIndex(t).replace(e),r()}updateLayers(t,e,r){this.getLayerIndex(t).update(e.layers,e.removedIds),r()}loadTile(t,e,r){this.getWorkerSource(t,e.type,e.source).loadTile(e,r)}loadDEMTile(t,e,r){this.getDEMWorkerSource(t,e.source).loadTile(e,r)}reloadTile(t,e,r){this.getWorkerSource(t,e.type,e.source).reloadTile(e,r)}abortTile(t,e,r){this.getWorkerSource(t,e.type,e.source).abortTile(e,r)}removeTile(t,e,r){this.getWorkerSource(t,e.type,e.source).removeTile(e,r)}removeDEMTile(t,e){this.getDEMWorkerSource(t,e.source).removeTile(e)}removeSource(t,e,r){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const n=this.workerSources[t][e.type][e.source];delete this.workerSources[t][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.toString())}}syncRTLPluginState(t,e,r){try{Fn.setState(e);const t=Fn.getPluginURL();if(Fn.isLoaded()&&!Fn.isParsed()&&null!=t){this.self.importScripts(t);const e=Fn.isParsed();r(e?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),e)}}catch(t){r(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new Jl),e}getWorkerSource(t,e,r){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][r]){const n={send:(e,r,n)=>{this.actor.send(e,r,n,t)}};this.workerSources[t][e][r]=new this.workerSourceTypes[e](n,this.getLayerIndex(t),this.getAvailableImages(t))}return this.workerSources[t][e][r]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new Zu),this.demWorkerSources[t][e]}}return m()&&(self.worker=new ch(self)),ch}();