!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ol={})}(this,(function(t){"use strict";var e={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function i(){throw new Error("Unimplemented abstract method.")}let n=0;function r(t){return t.ol_uid||(t.ol_uid=String(++n))}function s(t){return t[0]>0&&t[1]>0}function o(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}class a{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=o(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new a({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return i()}getImage(t){return i()}getHitDetectionImage(){return i()}getPixelRatio(t){return 1}getImageState(){return i()}getImageSize(){return i()}getOrigin(){return i()}getSize(){return i()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=o(t)}listenImageChange(t){i()}load(){i()}unlistenImageChange(t){i()}ready(){return Promise.resolve()}}var l=a,h={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]},u={name:"xyz",min:[0,0,0],channel:["X","Y","Z"],alias:["XYZ","ciexyz","cie1931"],whitepoint:{2:{A:[109.85,100,35.585],C:[98.074,100,118.232],D50:[96.422,100,82.521],D55:[95.682,100,92.149],D65:[95.045592705167,100,108.9057750759878],D75:[94.972,100,122.638],F2:[99.187,100,67.395],F7:[95.044,100,108.755],F11:[100.966,100,64.37],E:[100,100,100]},10:{A:[111.144,100,35.2],C:[97.285,100,116.145],D50:[96.72,100,81.427],D55:[95.799,100,90.926],D65:[94.811,100,107.304],D75:[94.416,100,120.641],F2:[103.28,100,69.026],F7:[95.792,100,107.687],F11:[103.866,100,65.627],E:[100,100,100]}}};u.max=u.whitepoint[2].D65,u.rgb=function(t,e){e=e||u.whitepoint[2].E;var i,n,r,s=t[0]/e[0],o=t[1]/e[1],a=t[2]/e[2];return n=-.96924363628087*s+1.87596750150772*o+.041555057407175*a,r=.055630079696993*s+-.20397695888897*o+1.056971514242878*a,i=(i=3.240969941904521*s+-1.537383177570093*o+-.498610760293*a)>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*=12.92,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n*=12.92,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r*=12.92,[255*(i=Math.min(Math.max(0,i),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},h.xyz=function(t,e){var i=t[0]/255,n=t[1]/255,r=t[2]/255,s=.21263900587151*(i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92)+.71516867876775*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.072192315360733*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92),o=.019330818715591*i+.11919477979462*n+.95053215224966*r;return[(.41239079926595*i+.35758433938387*n+.18048078840183*r)*(e=e||u.whitepoint[2].E)[0],s*e[1],o*e[2]]};var c={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(t,e,i){var n,r,s,o,a,l,h,c,d;if(s=t[0],o=t[1],a=t[2],0===s)return[0,0,0];return e=e||"D65",i=i||2,n=o/(13*s)+4*(h=u.whitepoint[i][e][0])/(h+15*(c=u.whitepoint[i][e][1])+3*(d=u.whitepoint[i][e][2]))||0,r=a/(13*s)+9*c/(h+15*c+3*d)||0,[9*(l=s>8?c*Math.pow((s+16)/116,3):c*s*.0011070564598794539)*n/(4*r)||0,l,l*(12-3*n-20*r)/(4*r)||0]}};u.luv=function(t,e,i){var n,r,s,o,a,l,h,c,d,g,p;e=e||"D65",i=i||2,g=4*(h=u.whitepoint[i][e][0])/(h+15*(c=u.whitepoint[i][e][1])+3*(d=u.whitepoint[i][e][2])),p=9*c/(h+15*c+3*d),n=4*(o=t[0])/(o+15*(a=t[1])+3*(l=t[2]))||0,r=9*a/(o+15*a+3*l)||0;var f=a/c;return[s=f<=.008856451679035631?903.2962962962961*f:116*Math.pow(f,1/3)-16,13*s*(n-g),13*s*(r-p)]};var d={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(t){var e,i=t[0],n=t[1];return e=t[2]/360*2*Math.PI,[i,n*Math.cos(e),n*Math.sin(e)]},xyz:function(t){return c.xyz(d.luv(t))}};c.lchuv=function(t){var e=t[0],i=t[1],n=t[2],r=Math.sqrt(i*i+n*n),s=360*Math.atan2(n,i)/2/Math.PI;return s<0&&(s+=360),[e,r,s]},u.lchuv=function(t){return c.lchuv(u.luv(t))};var g={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]},p={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};var f={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(t){var e,i,n,r,s,o=t[0]/360,a=t[1]/100,l=t[2]/100,h=0;if(0===a)return[s=255*l,s,s];for(e=2*l-(i=l<.5?l*(1+a):l+a-l*a),r=[0,0,0];h<3;)(n=o+1/3*-(h-1))<0?n++:n>1&&n--,s=6*n<1?e+6*(i-e)*n:2*n<1?i:3*n<2?e+(i-e)*(2/3-n)*6:e,r[h++]=255*s;return r}};function m(t){var e;Array.isArray(t)&&t.raw&&(t=String.raw(...arguments)),t instanceof Number&&(t=+t);var i=function(t){var e,i,n=[],r=1;if("number"==typeof t)return{space:"rgb",values:[t>>>16,(65280&t)>>>8,255&t],alpha:1};if("number"==typeof t)return{space:"rgb",values:[t>>>16,(65280&t)>>>8,255&t],alpha:1};if(t=String(t).toLowerCase(),g[t])n=g[t].slice(),i="rgb";else if("transparent"===t)r=0,i="rgb",n=[0,0,0];else if("#"===t[0]){var s=t.slice(1),o=s.length;r=1,o<=4?(n=[parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16)],4===o&&(r=parseInt(s[3]+s[3],16)/255)):(n=[parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16)],8===o&&(r=parseInt(s[6]+s[7],16)/255)),n[0]||(n[0]=0),n[1]||(n[1]=0),n[2]||(n[2]=0),i="rgb"}else if(e=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(t)){var a=e[1],l="cmyk"===(i=a.replace(/a$/,""))?4:"gray"===i?1:3;n=e[2].trim().split(/\s*[,\/]\s*|\s+/),"color"===i&&(i=n.shift()),r=(n=n.map((function(t,e){if("%"===t[t.length-1])return t=parseFloat(t)/100,3===e?t:"rgb"===i?255*t:"h"===i[0]?100*t:"l"!==i[0]||e?"lab"===i?125*t:"lch"===i?e<2?150*t:360*t:"o"!==i[0]||e?"oklab"===i?.4*t:"oklch"===i?e<2?.4*t:360*t:t:t:100*t;if("h"===i[e]||2===e&&"h"===i[i.length-1]){if(void 0!==p[t])return p[t];if(t.endsWith("deg"))return parseFloat(t);if(t.endsWith("turn"))return 360*parseFloat(t);if(t.endsWith("grad"))return 360*parseFloat(t)/400;if(t.endsWith("rad"))return 180*parseFloat(t)/Math.PI}return"none"===t?0:parseFloat(t)}))).length>l?n.pop():1}else/[0-9](?:\s|\/|,)/.test(t)&&(n=t.match(/([0-9]+)/g).map((function(t){return parseFloat(t)})),i=t.match(/([a-z])/gi)?.join("")?.toLowerCase()||"rgb");return{space:i,values:n,alpha:r}}(t);if(!i.space)return[];const n="h"===i.space[0]?f.min:h.min,r="h"===i.space[0]?f.max:h.max;return(e=Array(3))[0]=Math.min(Math.max(i.values[0],n[0]),r[0]),e[1]=Math.min(Math.max(i.values[1],n[1]),r[1]),e[2]=Math.min(Math.max(i.values[2],n[2]),r[2]),"h"===i.space[0]&&(e=f.rgb(e)),e.push(Math.min(Math.max(i.alpha,0),1)),e}function _(t,e,i){return Math.min(Math.max(t,e),i)}function y(t,e,i,n,r,s){const o=r-i,a=s-n;if(0!==o||0!==a){const l=((t-i)*o+(e-n)*a)/(o*o+a*a);l>1?(i=r,n=s):l>0&&(i+=o*l,n+=a*l)}return x(t,e,i,n)}function x(t,e,i,n){const r=i-t,s=n-e;return r*r+s*s}function v(t){return 180*t/Math.PI}function w(t){return t*Math.PI/180}function b(t,e){const i=t%e;return i*e<0?i+e:i}function S(t,e,i){return t+i*(e-t)}function E(t,e){const i=Math.pow(10,e);return Math.round(t*i)/i}function C(t,e){return Math.round(E(t,e))}function T(t,e){return Math.floor(E(t,e))}function R(t,e){return Math.ceil(E(t,e))}h.hsl=function(t){var e,i,n=t[0]/255,r=t[1]/255,s=t[2]/255,o=Math.min(n,r,s),a=Math.max(n,r,s),l=a-o;return a===o?e=0:n===a?e=(r-s)/l:r===a?e=2+(s-n)/l:s===a&&(e=4+(n-r)/l),(e=Math.min(60*e,360))<0&&(e+=360),i=(o+a)/2,[e,100*(a===o?0:i<=.5?l/(a+o):l/(2-a-o)),100*i]};const P=1024,F={};let I=0;function M(t){if(4===t.length)return t;const e=t.slice();return e[3]=1,e}function L(t){const e=u.lchuv(h.xyz(t));return e[3]=t[3],e}function k(t){if(F.hasOwnProperty(t))return F[t];if(I>=P){let t=0;for(const e in F)3&t++||(delete F[e],--I)}const e=m(t);if(4!==e.length)throw new Error('failed to parse "'+t+'" as color');for(const i of e)if(isNaN(i))throw new Error('failed to parse "'+t+'" as color');return A(e),F[t]=e,++I,e}function D(t){return Array.isArray(t)?t:k(t)}function A(t){return t[0]=_(t[0]+.5|0,0,255),t[1]=_(t[1]+.5|0,0,255),t[2]=_(t[2]+.5|0,0,255),t[3]=_(t[3],0,1),t}function O(t){let e=t[0];e!=(0|e)&&(e=e+.5|0);let i=t[1];i!=(0|i)&&(i=i+.5|0);let n=t[2];n!=(0|n)&&(n=n+.5|0);return"rgba("+e+","+i+","+n+","+(void 0===t[3]?1:Math.round(1e3*t[3])/1e3)+")"}const z="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"",G=z.includes("firefox"),N=z.includes("safari")&&!z.includes("chrom")&&(z.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(z)),j=z.includes("webkit")&&!z.includes("edge"),U=z.includes("macintosh"),$="undefined"!=typeof devicePixelRatio?devicePixelRatio:1,B="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope,V="undefined"!=typeof Image&&Image.prototype.decode,W="function"==typeof createImageBitmap,X=function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch(t){}return t}();function q(t,e,i,n){let r;return r=i&&i.length?i.shift():B?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("2d",n)}let Y;function Z(){return Y||(Y=q(1,1)),Y}function K(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}function H(t){let e=t.offsetWidth;const i=getComputedStyle(t);return e+=parseInt(i.marginLeft,10)+parseInt(i.marginRight,10),e}function J(t){let e=t.offsetHeight;const i=getComputedStyle(t);return e+=parseInt(i.marginTop,10)+parseInt(i.marginBottom,10),e}function Q(t,e){const i=e.parentNode;i&&i.replaceChild(t,e)}function tt(t){for(;t.lastChild;)t.lastChild.remove()}var et=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};var it=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};function nt(t,e){return t>e?1:t0?r-1:r}return n-1}if(i>0){for(let i=1;i0)}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const n=i.indexOf(e);-1!==n&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[n]=ut,++this.pendingRemovals_[t]):(i.splice(n,1),0===i.length&&delete this.listeners_[t]))}},mt="change",_t="error",yt="contextmenu",xt="click",vt="dblclick",wt="dragenter",bt="dragover",St="drop",Et="keydown",Ct="keypress",Tt="load",Rt="touchmove",Pt="wheel";function Ft(t,e,i,n,r){if(r){const r=i;i=function(){t.removeEventListener(e,i),r.apply(n??this,arguments)}}else n&&n!==t&&(i=i.bind(n));const s={target:t,type:e,listener:i};return t.addEventListener(e,i),s}function It(t,e,i,n){return Ft(t,e,i,n,!0)}function Mt(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),gt(t))}function Lt(t,e){return e&&(t.src=e),t.src&&V?new Promise(((e,i)=>t.decode().then((()=>e(t))).catch((n=>t.complete&&t.width?e(t):i(n))))):function(t,e){return new Promise(((i,n)=>{function r(){o(),i(t)}function s(){o(),n(new Error("Image load error"))}function o(){t.removeEventListener("load",r),t.removeEventListener("error",s)}t.addEventListener("load",r),t.addEventListener("error",s),e&&(t.src=e)}))}(t)}function kt(t,e){return e&&(t.src=e),t.src&&V&&W?t.decode().then((()=>createImageBitmap(t))).catch((e=>{if(t.complete&&t.width)return t;throw e})):Lt(t)}var Dt=class extends ft{constructor(t,i,n,r){super(),this.extent=t,this.pixelRatio_=n,this.resolution=i,this.state="function"==typeof r?e.IDLE:r,this.image_=null,this.loader="function"==typeof r?r:null}changed(){this.dispatchEvent(mt)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==e.IDLE&&this.loader){this.state=e.LOADING,this.changed();const t=this.getResolution(),i=Array.isArray(t)?t[0]:t;dt((()=>this.loader(this.getExtent(),i,this.getPixelRatio()))).then((t=>{"image"in t&&(this.image_=t.image),"extent"in t&&(this.extent=t.extent),"resolution"in t&&(this.resolution=t.resolution),"pixelRatio"in t&&(this.pixelRatio_=t.pixelRatio),(t instanceof HTMLImageElement||t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)&&(this.image_=t),this.state=e.LOADED})).catch((t=>{this.state=e.ERROR,console.error(t)})).finally((()=>this.changed()))}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}};function At(t,e,i){return e+":"+t+":"+(i?D(i):"null")}const Ot=new class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];3&t++||i.hasListener()||(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const n=At(t,e,i);return n in this.cache_?this.cache_[n]:null}getPattern(t,e,i){const n=At(t,e,i);return n in this.patternCache_?this.patternCache_[n]:null}set(t,i,n,r,s){const o=At(t,i,n),a=o in this.cache_;this.cache_[o]=r,s&&(r.getImageState()===e.IDLE&&r.load(),r.getImageState()===e.LOADING?r.ready().then((()=>{this.patternCache_[o]=Z().createPattern(r.getImage(1),"repeat")})):this.patternCache_[o]=Z().createPattern(r.getImage(1),"repeat")),a||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};let zt=null;class Gt extends ft{constructor(t,i,n,r,s){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=n,this.canvas_={},this.color_=s,this.imageState_=void 0===r?e.IDLE:r,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=i,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(void 0===this.tainted_&&this.imageState_===e.LOADED){zt||(zt=q(1,1,void 0,{willReadFrequently:!0})),zt.drawImage(this.image_,0,0);try{zt.getImageData(0,0,1,1),this.tainted_=!1}catch(t){zt=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(mt)}handleImageError_(){this.imageState_=e.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=e.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=q(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===e.IDLE){this.image_||this.initializeImage_(),this.imageState_=e.LOADING;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch(t){this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Lt(this.image_,this.src_).then((t=>{this.image_=t,this.handleImageLoad_()})).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==e.LOADED)return;const i=this.image_,n=document.createElement("canvas");n.width=Math.ceil(i.width*t),n.height=Math.ceil(i.height*t);const r=n.getContext("2d");r.scale(t,t),r.drawImage(i,0,0),r.globalCompositeOperation="multiply",r.fillStyle=function(t){return"string"==typeof t?t:O(t)}(this.color_),r.fillRect(0,0,n.width/t,n.height/t),r.globalCompositeOperation="destination-in",r.drawImage(i,0,0),this.canvas_[t]=n}ready(){return this.ready_||(this.ready_=new Promise((t=>{if(this.imageState_===e.LOADED||this.imageState_===e.ERROR)t();else{const i=()=>{this.imageState_!==e.LOADED&&this.imageState_!==e.ERROR||(this.removeEventListener(mt,i),t())};this.addEventListener(mt,i)}}))),this.ready_}}function Nt(t,e,i,n,r,s){let o=void 0===e?void 0:Ot.get(e,i,r);return o||(o=new Gt(t,t&&"src"in t?t.src||void 0:e,i,n,r),Ot.set(e,i,r,o,s)),s&&o&&!Ot.getPattern(e,i,r)&&Ot.set(e,i,r,o,s),o}function jt(t){return t?Array.isArray(t)?O(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return Ot.getPattern(t.src,"anonymous",t.color);const i=t.src+":"+t.offset,n=Ot.getPattern(i,void 0,t.color);if(n)return n;const r=Ot.get(t.src,"anonymous",null);if(r.getImageState()!==e.LOADED)return null;const s=q(t.size[0],t.size[1]);return s.drawImage(r.getImage(1),t.offset[0],t.offset[1],t.size[0],t.size[1],0,0,t.size[0],t.size[1]),Nt(s.canvas,i,void 0,e.LOADED,t.color,!0),Ot.getPattern(i,void 0,t.color)}(t):t:null}var Ut="propertychange";class $t extends ft{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(mt)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let r=0;rMath.max(e,_e(t,i))),0);return i[e]=n,n}function xe(t,e,i,n,r,s,o,a,l,h,u){t.save(),1!==i&&(void 0===t.globalAlpha?t.globalAlpha=t=>t.globalAlpha*=i:t.globalAlpha*=i),e&&t.transform.apply(t,e),n.contextInstructions?(t.translate(l,h),t.scale(u[0],u[1]),function(t,e){const i=t.contextInstructions;for(let t=0,n=i.length;tthis.imageState_=e.LOADED)),this.render()}clone(){const t=this.getScale(),e=new ve({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){let e=this.canvases_[t];if(!e){const i=this.renderOptions_,n=q(i.size*t,i.size*t);this.draw_(i,n,t),e=n.canvas,this.canvases_[t]=e}return e}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(0===e||this.points_===1/0||"bevel"!==t&&"miter"!==t)return e;let n=this.radius,r=void 0===this.radius2_?n:this.radius2_;if(n{this.patternImage_=null})),i.getImageState()===e.IDLE&&i.load(),i.getImageState()===e.LOADING&&(this.patternImage_=i)}this.color_=t}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}var Ce=Ee;function Te(t,e){if(!t)throw new Error(e)}function Re(t,e,i,n){return void 0!==i&&void 0!==n?[i/t,n/e]:void 0!==i?i/t:void 0!==n?n/e:1}class Pe extends l{constructor(t){const i=void 0!==(t=t||{}).opacity?t.opacity:1,n=void 0!==t.rotation?t.rotation:0,s=void 0!==t.scale?t.scale:1,o=void 0!==t.rotateWithView&&t.rotateWithView;super({opacity:i,rotation:n,scale:s,displacement:void 0!==t.displacement?t.displacement:[0,0],rotateWithView:o,declutterMode:t.declutterMode}),this.anchor_=void 0!==t.anchor?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=void 0!==t.anchorOrigin?t.anchorOrigin:"top-left",this.anchorXUnits_=void 0!==t.anchorXUnits?t.anchorXUnits:"fraction",this.anchorYUnits_=void 0!==t.anchorYUnits?t.anchorYUnits:"fraction",this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null;const a=void 0!==t.img?t.img:null;let l,h=t.src;if(Te(!(void 0!==h&&a),"`image` and `src` cannot be provided at the same time"),void 0!==h&&0!==h.length||!a||(h=a.src||r(a)),Te(void 0!==h&&h.length>0,"A defined and non-empty `src` or `image` must be provided"),Te(!((void 0!==t.width||void 0!==t.height)&&void 0!==t.scale),"`width` or `height` cannot be provided together with `scale`"),void 0!==t.src?l=e.IDLE:void 0!==a&&(l="complete"in a?a.complete?a.src?e.LOADED:e.IDLE:e.LOADING:e.LOADED),this.color_=void 0!==t.color?D(t.color):null,this.iconImage_=Nt(a,h,this.crossOrigin_,l,this.color_),this.offset_=void 0!==t.offset?t.offset:[0,0],this.offsetOrigin_=void 0!==t.offsetOrigin?t.offsetOrigin:"top-left",this.origin_=null,this.size_=void 0!==t.size?t.size:null,this.initialOptions_,void 0!==t.width||void 0!==t.height){let e,i;if(t.size)[e,i]=t.size;else{const n=this.getImage(1);if(n.width&&n.height)e=n.width,i=n.height;else if(n instanceof HTMLImageElement){this.initialOptions_=t;const e=()=>{if(this.unlistenImageChange(e),!this.initialOptions_)return;const i=this.iconImage_.getSize();this.setScale(Re(i[0],i[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale(Re(e,i,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new Pe({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:null!==this.size_?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const e=this.getSize();if("fraction"==this.anchorXUnits_||"fraction"==this.anchorYUnits_){if(!e)return null;t=this.anchor_.slice(),"fraction"==this.anchorXUnits_&&(t[0]*=e[0]),"fraction"==this.anchorYUnits_&&(t[1]*=e[1])}if("top-left"!=this.anchorOrigin_){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),"top-right"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[0]=-t[0]+e[0]),"bottom-left"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[1]=-t[1]+e[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if("top-left"!=this.offsetOrigin_){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),"top-right"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[0]=i[0]-e[0]-t[0]),"bottom-left"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();return this.size_?this.size_[0]*t[0]:this.iconImage_.getImageState()==e.LOADED?this.iconImage_.getSize()[0]*t[0]:void 0}getHeight(){const t=this.getScaleArray();return this.size_?this.size_[1]*t[1]:this.iconImage_.getImageState()==e.LOADED?this.iconImage_.getSize()[1]*t[1]:void 0}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(mt,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(mt,t)}ready(){return this.iconImage_.ready()}}var Fe=Pe;class Ie extends qt{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if("function"==typeof t.getSimplifiedGeometry){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new Ie(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());const e=this.getGeometry();e&&t.setGeometry(e.clone());const i=this.getStyle();return i&&t.setStyle(i),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(Mt(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=Ft(t,mt,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?function(t){if("function"==typeof t)return t;let e;if(Array.isArray(t))e=t;else{Te("function"==typeof t.getZIndex,"Expected an `ol/style/Style` or an array of `ol/style/Style.js`");e=[t]}return function(){return e}}(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}var Me=Ie;const Le=new Array(6);function ke(t){return Ae(t,1,0,0,1,0,0)}function De(t,e){const i=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=e[0],h=e[1],u=e[2],c=e[3],d=e[4],g=e[5];return t[0]=i*l+r*h,t[1]=n*l+s*h,t[2]=i*u+r*c,t[3]=n*u+s*c,t[4]=i*d+r*g+o,t[5]=n*d+s*g+a,t}function Ae(t,e,i,n,r,s,o){return t[0]=e,t[1]=i,t[2]=n,t[3]=r,t[4]=s,t[5]=o,t}function Oe(t,e){const i=e[0],n=e[1];return e[0]=t[0]*i+t[2]*n+t[4],e[1]=t[1]*i+t[3]*n+t[5],e}function ze(t,e,i){return De(t,Ae(Le,e,0,0,i,0,0))}function Ge(t,e,i){return De(t,Ae(Le,1,0,0,1,e,i))}function Ne(t,e,i,n,r,s,o,a){const l=Math.sin(s),h=Math.cos(s);return t[0]=n*h,t[1]=r*l,t[2]=-n*l,t[3]=r*h,t[4]=o*n*h-a*n*l+e,t[5]=o*r*l+a*r*h+i,t}function je(t,e){const i=(n=e)[0]*n[3]-n[1]*n[2];var n;Te(0!==i,"Transformation matrix cannot be inverted");const r=e[0],s=e[1],o=e[2],a=e[3],l=e[4],h=e[5];return t[0]=a/i,t[1]=-s/i,t[2]=-o/i,t[3]=r/i,t[4]=(o*h-a*l)/i,t[5]=-(r*h-s*l)/i,t}const Ue=[1e6,1e6,1e6,1e6,2,2];var $e={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Be(t){const e=He();for(let i=0,n=t.length;ir&&(l|=$e.RIGHT),as&&(l|=$e.ABOVE),l===$e.UNKNOWN&&(l=$e.INTERSECTING),l}function He(){return[1/0,1/0,-1/0,-1/0]}function Je(t,e,i,n,r){return r?(r[0]=t,r[1]=e,r[2]=i,r[3]=n,r):[t,e,i,n]}function Qe(t){return Je(1/0,1/0,-1/0,-1/0,t)}function ti(t,e){const i=t[0],n=t[1];return Je(i,n,i,n,e)}function ei(t,e,i,n,r){return si(Qe(r),t,e,i,n)}function ii(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function ni(t,e){return e[0]t[2]&&(t[2]=e[2]),e[1]t[3]&&(t[3]=e[3]),t}function ri(t,e){e[0]t[2]&&(t[2]=e[0]),e[1]t[3]&&(t[3]=e[1])}function si(t,e,i,n,r){for(;ie[0]?n[0]=t[0]:n[0]=e[0],t[1]>e[1]?n[1]=t[1]:n[1]=e[1],t[2]=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function vi(t){return t[2]1){const e=t[2]-t[0],i=t[3]-t[1];for(let s=0;s=i[2])){const e=yi(i),r=Math.floor((n[0]-i[0])/e)*e;t[0]-=r,t[2]-=r}return t}function Si(t,e,i){if(e.canWrapX()){const n=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[n[0],t[1],n[2],t[3]]];bi(t,e);const r=yi(n);if(yi(t)>r&&!i)return[[n[0],t[1],n[2],t[3]]];if(t[0]n[2])return[[t[0],t[1],n[2],t[3]],[n[0],t[1],t[2]-r,t[3]]]}return[t]}const Ei={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var Ci=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Ei[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!(!t||!this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!(!this.global_||!t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}};const Ti=6378137,Ri=Math.PI*Ti,Pi=[-Ri,-Ri,Ri,Ri],Fi=[-180,-85,180,85],Ii=Ti*Math.log(Math.tan(Math.PI/2));class Mi extends Ci{constructor(t){super({code:t,units:"m",extent:Pi,global:!0,worldExtent:Fi,getPointResolution:function(t,e){return t/Math.cosh(e[1]/Ti)}})}}const Li=[new Mi("EPSG:3857"),new Mi("EPSG:102100"),new Mi("EPSG:102113"),new Mi("EPSG:900913"),new Mi("http://www.opengis.net/def/crs/EPSG/0/3857"),new Mi("http://www.opengis.net/gml/srs/epsg.xml#3857")];function ki(t,e,i){const n=t.length;i=i>1?i:2,void 0===e&&(e=i>2?t.slice():new Array(n));for(let r=0;rIi?i=Ii:i<-Ii&&(i=-Ii),e[r+1]=i}return e}function Di(t,e,i){const n=t.length;i=i>1?i:2,void 0===e&&(e=i>2?t.slice():new Array(n));for(let r=0;rr)return 1;if(r>e)return-1}return 0}function Bi(t,e){const i=e.getRadius(),n=e.getCenter(),r=n[0],s=n[1];let o=t[0]-r;const a=t[1]-s;0===o&&0===a&&(o=1);const l=Math.sqrt(o*o+a*a);return[r+i*o/l,s+i*a/l]}function Vi(t,e){const i=t[0],n=t[1],r=e[0],s=e[1],o=r[0],a=r[1],l=s[0],h=s[1],u=l-o,c=h-a,d=0===u&&0===c?0:(u*(i-o)+c*(n-a))/(u*u+c*c||0);let g,p;return d<=0?(g=o,p=a):d>=1?(g=l,p=h):(g=o+d*u,p=a+d*c),[g,p]}function Wi(t,e){let i=!0;for(let n=t.length-1;n>=0;--n)if(t[n]!=e[n]){i=!1;break}return i}function Xi(t,e){const i=Math.cos(e),n=Math.sin(e),r=t[0]*i-t[1]*n,s=t[1]*i+t[0]*n;return t[0]=r,t[1]=s,t}function qi(t,e){const i=t[0]-e[0],n=t[1]-e[1];return i*i+n*n}function Yi(t,e){return Math.sqrt(qi(t,e))}function Zi(t,e){return qi(t,Vi(t,e))}function Ki(t,e){if(e.canWrapX()){const i=yi(e.getExtent()),n=Hi(t,e,i);n&&(t[0]-=n*i)}return t}function Hi(t,e,i){const n=e.getExtent();let r=0;return e.canWrapX()&&(t[0]n[2])&&(i=i||yi(n),r=Math.floor((t[0]-n[0])/i)),r}const Ji=6371008.8;function Qi(t,e,i){i=i||Ji;const n=w(t[1]),r=w(e[1]),s=(r-n)/2,o=w(e[0]-t[0])/2,a=Math.sin(s)*Math.sin(s)+Math.sin(o)*Math.sin(o)*Math.cos(n)*Math.cos(r);return 2*i*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function tn(t,e){let i=0;for(let n=0,r=t.length;nrn.warn||console.warn(...t)}let an=!0;function ln(t){an=!(void 0===t||t)}function hn(t,e){if(void 0!==e)for(let i=0,n=t.length;i=o?e[s+t]:r[t]}return i}}function xn(t,e){return ln(),Sn(t,"EPSG:4326",void 0!==e?e:"EPSG:3857")}function vn(t,e){if(t===e)return!0;const i=t.getUnits()===e.getUnits();if(t.getCode()===e.getCode())return i;return wn(t,e)===hn&&i}function wn(t,e){let i=function(t,e){let i;return t in ji&&e in ji[t]&&(i=ji[t][e]),i}(t.getCode(),e.getCode());return i||(i=un),i}function bn(t,e){return wn(gn(t),gn(e))}function Sn(t,e,i){return bn(e,i)(t,void 0,t.length)}function En(t,e,i,n){return wi(t,bn(e,i),void 0,n)}let Cn=null;function Tn(t){Cn=gn(t)}function Rn(){return Cn}function Pn(t,e){return Cn?Sn(t,e,Cn):t}function Fn(t,e){return Cn?Sn(t,Cn,e):(an&&!Wi(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(an=!1,on("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t)}function In(t,e){return Cn?En(t,e,Cn):t}function Mn(t,e){return Cn?En(t,Cn,e):t}function Ln(t,e){if(!Cn)return t;const i=gn(e).getMetersPerUnit(),n=Cn.getMetersPerUnit();return i&&n?t*i/n:t}function kn(){fn(Li),fn(Gi),mn(Gi,Li,ki,Di)}kn();var Dn=Object.freeze({__proto__:null,METERS_PER_UNIT:Ei,Projection:Ci,disableCoordinateWarning:ln,cloneTransform:hn,identityTransform:un,addProjection:cn,addProjections:dn,get:gn,getPointResolution:pn,addEquivalentProjections:fn,addEquivalentTransforms:mn,clearAllProjections:function(){Ni={},ji={}},createProjection:_n,createTransformFromCoordinateTransform:yn,addCoordinateTransforms:function(t,e,i,n){const r=gn(t),s=gn(e);Ui(r,s,yn(i)),Ui(s,r,yn(n))},fromLonLat:xn,toLonLat:function(t,e){const i=Sn(t,void 0!==e?e:"EPSG:3857","EPSG:4326"),n=i[0];return(n<-180||n>180)&&(i[0]=b(n+180,360)-180),i},equivalent:vn,getTransformFromProjections:wn,getTransform:bn,transform:Sn,transformExtent:En,transformWithProjections:function(t,e,i){return wn(e,i)(t)},setUserProjection:Tn,clearUserProjection:function(){Cn=null},getUserProjection:Rn,useGeographic:function(){Tn("EPSG:4326")},toUserCoordinate:Pn,fromUserCoordinate:Fn,toUserExtent:In,fromUserExtent:Mn,toUserResolution:Ln,fromUserResolution:function(t,e){if(!Cn)return t;const i=gn(e).getMetersPerUnit(),n=Cn.getMetersPerUnit();return i&&n?t*n/i:t},createSafeCoordinateTransform:function(t,e,i){return function(n){let r,s;if(t.canWrapX()){const e=t.getExtent(),o=yi(e);s=Hi(n=n.slice(0),t,o),s&&(n[0]=n[0]-s*o),n[0]=_(n[0],e[0],e[2]),n[1]=_(n[1],e[1],e[3]),r=i(n)}else r=i(n);return s&&e.canWrapX()&&(r[0]+=s*yi(e.getExtent())),r}},addCommon:kn});function An(t,e,i,n,r,s){s=s||[];let o=0;for(let a=e;a{if(!i)return this.getSimplifiedGeometry(e);const n=this.clone();return n.applyTransform(i),n.getSimplifiedGeometry(e)}))}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return i()}closestPointXY(t,e,n,r){return i()}containsXY(t,e){const i=this.getClosestPoint([t,e]);return i[0]===t&&i[1]===e}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return i()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&Qe(t),this.extentRevision_=this.getRevision()}return function(t,e){return e?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):t}(this.extent_,t)}rotate(t,e){i()}scale(t,e,n){i()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return i()}getType(){return i()}applyTransform(t){i()}intersectsExtent(t){return i()}translate(t,e){i()}transform(t,e){const i=gn(t),n="tile-pixels"==i.getUnits()?function(t,n,r){const s=i.getExtent(),o=i.getWorldExtent(),a=pi(o)/pi(s);return Ne(zn,o[0],o[3],a,-a,0,0,0),An(t,0,t.length,r,zn,n),bn(i,e)(t,n,r)}:bn(i,e);return this.applyTransform(n),this}};class Nn extends Gn{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return ei(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return i()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length=e[0]||(t[1]<=e[1]&&t[3]>=e[1]||ai(t,this.intersectsCoordinate.bind(this)))}return!1}setCenter(t){const e=this.stride,i=this.flatCoordinates[e]-this.flatCoordinates[0],n=t.slice();n[e]=n[0]+i;for(let i=1;it.clone()))}var Kn=Yn;function Hn(t,e,i,n,r,s,o){const a=t[e],l=t[e+1],h=t[i]-a,u=t[i+1]-l;let c;if(0===h&&0===u)c=e;else{const d=((r-a)*h+(s-l)*u)/(h*h+u*u);if(d>1)c=i;else{if(d>0){for(let r=0;rr&&(r=a),s=i,o=n}return r}function Qn(t,e,i,n,r){for(let s=0,o=i.length;s0;){const i=h.pop(),s=h.pop();let o=0;const a=t[s],c=t[s+1],d=t[i],g=t[i+1];for(let e=s+n;eo&&(u=e,o=i)}o>r&&(l[(u-e)/n]=1,s+n0&&p>d)&&(g<0&&f0&&f>g)?(a=i,l=c):(s[o++]=a,s[o++]=l,h=a,u=l,a=i,l=c)}return s[o++]=a,s[o++]=l,o}function or(t,e,i,n,r,s,o,a){for(let l=0,h=i.length;l>1),r=+i(t[n],e),r<0?s=n+1:(o=n,a=!r);return a?s:~s}(u,c);d<0?(l=(c-u[-d-2])/(u[-d-1]-u[-d-2]),a=e+(-d-2)*n):a=e+d*n}o=o>1?o:2,s=s||new Array(o);for(let e=0;e>1;rs&&(i-a)*(s-l)-(r-a)*(n-l)>0&&o++:n<=s&&(i-a)*(s-l)-(r-a)*(n-l)<0&&o--,a=i,l=n}return 0!==o}function xr(t,e,i,n,r,s){if(0===i.length)return!1;if(!yr(t,e,i[0],n,r,s))return!1;for(let e=1,o=i.length;e=r[0]&&s[2]<=r[2]||(s[1]>=r[1]&&s[3]<=r[3]||pr(t,e,i,n,(function(t,e){return function(t,e,i){let n=!1;const r=Ke(t,e),s=Ke(t,i);if(r===$e.INTERSECTING||s===$e.INTERSECTING)n=!0;else{const o=t[0],a=t[1],l=t[2],h=t[3],u=e[0],c=e[1],d=i[0],g=i[1],p=(g-c)/(d-u);let f,m;s&$e.ABOVE&&!(r&$e.ABOVE)&&(f=d-(g-h)/p,n=f>=o&&f<=l),n||!(s&$e.RIGHT)||r&$e.RIGHT||(m=g-(d-l)*p,n=m>=a&&m<=h),n||!(s&$e.BELOW)||r&$e.BELOW||(f=d-(g-a)/p,n=f>=o&&f<=l),n||!(s&$e.LEFT)||r&$e.LEFT||(m=g-(d-o)*p,n=m>=a&&m<=h)}return n}(r,t,e)})))))}function wr(t,e,i,n,r){return!!vr(t,e,i,n,r)||(!!yr(t,e,i,n,r[0],r[1])||(!!yr(t,e,i,n,r[0],r[3])||(!!yr(t,e,i,n,r[2],r[1])||!!yr(t,e,i,n,r[2],r[3]))))}function br(t,e,i,n,r){if(!wr(t,e,i[0],n,r))return!1;if(1===i.length)return!0;for(let e=1,s=i.length;e_&&(h=(u+c)/2,xr(t,e,i,n,h,p)&&(m=h,_=r)),u=c}return isNaN(m)&&(m=r[s]),o?(o.push(m,p,_),o):[m,p,_]}function kr(t,e,i,n,r){let s=[];for(let o=0,a=i.length;o0}function Or(t,e,i,n,r){r=void 0!==r&&r;for(let s=0,o=i.length;s{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let n;switch(this.type_){case"LineString":i.length=ir(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=nr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,n);break;case"Polygon":n=[],i.length=or(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,n)}return n&&(this.simplifiedGeometry_=new Yr(this.type_,i,n,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_})),this}}Yr.prototype.getFlatCoordinates=Yr.prototype.getOrientedFlatCoordinates;var Zr=Yr;class Kr{constructor(t){t=t||{},this.color_=void 0!==t.color?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=void 0!==t.lineDash?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){const t=this.getColor();return new Kr({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}}var Hr=Kr;class Jr{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=is,void 0!==t.geometry&&this.setGeometry(t.geometry),this.fill_=void 0!==t.fill?t.fill:null,this.image_=void 0!==t.image?t.image:null,this.renderer_=void 0!==t.renderer?t.renderer:null,this.hitDetectionRenderer_=void 0!==t.hitDetectionRenderer?t.hitDetectionRenderer:null,this.stroke_=void 0!==t.stroke?t.stroke:null,this.text_=void 0!==t.text?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&"object"==typeof t&&(t=t.clone()),new Jr({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=is,this.geometry_=t}setZIndex(t){this.zIndex_=t}}let Qr=null;function ts(t,e){if(!Qr){const t=new Ce({color:"rgba(255,255,255,0.4)"}),e=new Hr({color:"#3399CC",width:1.25});Qr=[new Jr({image:new Se({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return Qr}function es(){const t={},e=[255,255,255,1],i=[0,153,255,1];return t.Polygon=[new Jr({fill:new Ce({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new Jr({stroke:new Hr({color:e,width:5})}),new Jr({stroke:new Hr({color:i,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new Jr({image:new Se({radius:6,fill:new Ce({color:i}),stroke:new Hr({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function is(t){return t.getGeometry()}var ns=Jr;class rs{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.scale_=t.scale,this.scaleArray_=o(void 0!==t.scale?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=void 0!==t.fill?t.fill:new Ce({color:"#333"}),this.maxAngle_=void 0!==t.maxAngle?t.maxAngle:Math.PI/4,this.placement_=void 0!==t.placement?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=void 0!==t.stroke?t.stroke:null,this.offsetX_=void 0!==t.offsetX?t.offsetX:0,this.offsetY_=void 0!==t.offsetY?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=void 0===t.padding?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new rs({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=o(void 0!==t?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}var ss=rs,os={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4},as="add",ls="remove";const hs="length";class us extends it{constructor(t,e,i){super(t),this.element=e,this.index=i}}var cs=class extends qt{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t||[],this.unique_)for(let t=0,e=this.array_.length;t0;)this.pop()}extend(t){for(let e=0,i=t.length;ethis.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new us(as,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){this.unique_&&this.assertUnique_(t);const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,n=e.length;i=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new us(ls,e,t)),e}setAt(t,e){if(t>=this.getLength())return void this.insertAt(t,e);if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const i=this.array_[t];this.array_[t]=e,this.dispatchEvent(new us(ls,i,t)),this.dispatchEvent(new us(as,e,t))}updateLength_(){this.set(hs,this.array_.length)}assertUnique_(t,e){for(let i=0,n=this.array_.length;ig&&(d=(g+d)/2,g=d),p>f&&(p=(f+p)/2,f=p);let m=_(n[0],d,g),y=_(n[1],p,f);if(o&&i&&r){const t=30*r;m+=-t*Math.log(1+Math.max(0,d-n[0])/t)+t*Math.log(1+Math.max(0,n[0]-g)/t),y+=-t*Math.log(1+Math.max(0,p-n[1])/t)+t*Math.log(1+Math.max(0,n[1]-f)/t)}return[m,y]}}function Ds(t){return t}function As(t,e,i,n){const r=yi(e)/i[0],s=pi(e)/i[1];return n?Math.min(t,Math.max(r,s)):Math.min(t,Math.min(r,s))}function Os(t,e,i){let n=Math.min(t,e);return n*=Math.log(1+50*Math.max(0,t/e-1))/50+1,i&&(n=Math.max(n,i),n/=Math.log(1+50*Math.max(0,i/t-1))/50+1),_(n,i/2,2*e)}function zs(t,e,i,n,r){return i=void 0===i||i,function(s,o,a,l){if(void 0!==s){const o=n?As(t,n,a,r):t;return i&&l?Os(s,o,e):_(s,e,o)}}}function Gs(t){if(void 0!==t)return 0}function Ns(t){if(void 0!==t)return t}function js(t){return Math.pow(t,3)}function Us(t){return 1-js(1-t)}function $s(t){return 3*t*t-2*t*t*t}function Bs(t){return t}function Vs(t,e){setTimeout((function(){t(e)}),0)}function Ws(t){return!(t.sourceCenter&&t.targetCenter&&!Wi(t.sourceCenter,t.targetCenter))&&(t.sourceResolution===t.targetResolution&&t.sourceRotation===t.targetRotation)}function Xs(t,e,i,n,r){const s=Math.cos(-r);let o=Math.sin(-r),a=t[0]*s-t[1]*o,l=t[1]*s+t[0]*o;a+=(e[0]/2-i[0])*n,l+=(i[1]-e[1]/2)*n,o=-o;return[a*s-l*o,l*s+a*o]}var qs=class extends qt{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=_n(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&ln(),t.center&&(t.center=Fn(t.center,this.projection_)),t.extent&&(t.extent=Mn(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const t in Is)delete e[t];this.setProperties(e,!0);const i=function(t){let e,i,n;const r=28,s=2;let o=void 0!==t.minZoom?t.minZoom:0,a=void 0!==t.maxZoom?t.maxZoom:r;const l=void 0!==t.zoomFactor?t.zoomFactor:s,h=void 0!==t.multiWorld&&t.multiWorld,u=void 0===t.smoothResolutionConstraint||t.smoothResolutionConstraint,c=void 0!==t.showFullExtent&&t.showFullExtent,d=_n(t.projection,"EPSG:3857"),g=d.getExtent();let p=t.constrainOnlyCenter,f=t.extent;h||f||!d.isGlobal()||(p=!1,f=g);if(void 0!==t.resolutions){const r=t.resolutions;i=r[o],n=void 0!==r[a]?r[a]:r[r.length-1],e=t.constrainResolution?function(t,e,i,n){return e=void 0===e||e,function(r,s,o,a){if(void 0!==r){const l=t[0],h=t[t.length-1],u=i?As(l,i,o,n):l;if(a)return e?Os(r,u,h):_(r,h,u);const c=Math.min(u,r),d=Math.floor(rt(t,c,s));return t[d]>u&&d1&&"function"==typeof arguments[i-1]&&(e=arguments[i-1],--i);let n=0;for(;n0}getInteracting(){return this.hints_[Fs]>0}cancelAnimations(){let t;this.setHint(Ps,-this.hints_[Ps]);for(let e=0,i=this.animations_.length;e=0;--i){const n=this.animations_[i];let r=!0;for(let i=0,s=n.length;i0?o/s.duration:1;a>=1?(s.complete=!0,a=1):r=!1;const l=s.easing(a);if(s.sourceCenter){const t=s.sourceCenter[0],e=s.sourceCenter[1],i=s.targetCenter[0],n=s.targetCenter[1];this.nextCenter_=s.targetCenter;const r=t+l*(i-t),o=e+l*(n-e);this.targetCenter_=[r,o]}if(s.sourceResolution&&s.targetResolution){const t=1===l?s.targetResolution:s.sourceResolution+l*(s.targetResolution-s.sourceResolution);if(s.anchor){const e=this.getViewportSize_(this.getRotation()),i=this.constraints_.resolution(t,0,e,!0);this.targetCenter_=this.calculateCenterZoom(i,s.anchor)}this.nextResolution_=s.targetResolution,this.targetResolution_=t,this.applyTargetState_(!0)}if(void 0!==s.sourceRotation&&void 0!==s.targetRotation){const t=1===l?b(s.targetRotation+Math.PI,2*Math.PI)-Math.PI:s.sourceRotation+l*(s.targetRotation-s.sourceRotation);if(s.anchor){const e=this.constraints_.rotation(t,!0);this.targetCenter_=this.calculateCenterRotate(e,s.anchor)}this.nextRotation_=s.targetRotation,this.targetRotation_=t}if(this.applyTargetState_(!0),e=!0,!s.complete)break}if(r){this.animations_[i]=null,this.setHint(Ps,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=n[0].callback;t&&Vs(t,!0)}}this.animations_=this.animations_.filter(Boolean),e&&void 0===this.updateAnimationKey_&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const n=this.getCenterInternal();var r,s;return void 0!==n&&(i=[n[0]-e[0],n[1]-e[1]],Xi(i,t-this.getRotation()),s=e,(r=i)[0]+=+s[0],r[1]+=+s[1]),i}calculateCenterZoom(t,e){let i;const n=this.getCenterInternal(),r=this.getResolution();if(void 0!==n&&void 0!==r){i=[e[0]-t*(e[0]-n[0])/r,e[1]-t*(e[1]-n[1])/r]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],n=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(n*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(n*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t?Pn(t,this.getProjection()):t}getCenterInternal(){return this.get(Is.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return void 0!==t?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){return In(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();Te(e,"The view center is not defined");const i=this.getResolution();Te(void 0!==i,"The view resolution is not defined");const n=this.getRotation();return Te(void 0!==n,"The view rotation is not defined"),gi(e,i,n,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(Is.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Mn(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=yi(t)/e[0],n=pi(t)/e[1];return Math.max(i,n)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,n=Math.log(e/i)/Math.log(t);return function(i){return e/Math.pow(t,i*n)}}getRotation(){return this.get(Is.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,r=Math.log(i/n)/e;return function(t){return Math.log(i/t)/e/r}}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let n=this.getCenterInternal();const r=this.padding_;if(r){const t=this.getViewportSizeMinusPadding_();n=Xs(n,this.getViewportSize_(),[t[0]/2+r[3],t[1]/2+r[0]],e,i)}return{center:n.slice(0),projection:void 0!==t?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return void 0!==e&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e,i,n=this.minZoom_||0;if(this.resolutions_){const r=rt(this.resolutions_,t,1);n=r,e=this.resolutions_[r],i=r==this.resolutions_.length-1?2:e/this.resolutions_[r+1]}else e=this.maxResolution_,i=this.zoomFactor_;return n+Math.log(e/t)/Math.log(i)}getResolutionForZoom(t){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;const e=_(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,_(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(Te(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){Te(!vi(t),"Cannot fit empty extent provided as `geometry`");i=$r(Mn(t,this.getProjection()))}else if("Circle"===t.getType()){const e=Mn(t.getExtent(),this.getProjection());i=$r(e),i.rotate(this.getRotation(),ci(e))}else{const e=Rn();i=e?t.clone().transform(e,this.getProjection()):t}this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),n=Math.sin(-e),r=t.getFlatCoordinates(),s=t.getStride();let o=1/0,a=1/0,l=-1/0,h=-1/0;for(let t=0,e=r.length;t=t.maxResolution)return!1;const n=e.zoom;return n>t.minZoom&&n<=t.maxZoom}var Zs=class extends Rs{constructor(t){const e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(Cs,this.handleSourcePropertyChange_);const i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return(t=t||[]).push(this),t}getLayerStatesArray(t){return(t=t||[]).push(this.getLayerState()),t}getSource(){return this.get(Cs)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),this.sourceReady_||"ready"!==this.getSource().getState()||(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(Mt(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=Ft(t,mt,this.handleSourceChange_,this),"ready"===t.getState()&&(this.sourceReady_=!0,setTimeout((()=>{this.dispatchEvent("sourceready")}),0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return this.renderer_&&this.rendered?this.renderer_.getData(t):null}isVisible(t){let e;const i=this.getMapInternal();let n;!t&&i&&(t=i.getView()),e=t instanceof qs?{viewState:t.getState(),extent:t.calculateExtent()}:t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray()),n=e.layerStatesArray?e.layerStatesArray.find((t=>t.layer===this)):this.getLayerState();const r=this.getExtent();return Ys(n,e.viewState)&&(!r||xi(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let i=e(t instanceof qs?t.getViewStateAndExtent():t);return Array.isArray(i)||(i=[i]),i}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(Ts,t)}getMapInternal(){return this.get(Ts)}setMap(t){this.mapPrecomposeKey_&&(Mt(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(Mt(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=Ft(t,ps,(t=>{const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);Te(!e.some((function(t){return t.layer===i.layer})),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)})),this.mapRenderKey_=Ft(this,mt,t.render,t),this.changed())}setSource(t){this.set(Cs,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}};function Ks(t,e,i,n,r){Hs(t,e,i||0,n||t.length-1,r||Qs)}function Hs(t,e,i,n,r){for(;n>i;){if(n-i>600){var s=n-i+1,o=e-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Hs(t,e,Math.max(i,Math.floor(e-o*l/s+h)),Math.min(n,Math.floor(e+(s-o)*l/s+h)),r)}var u=t[e],c=i,d=n;for(Js(t,i,e),r(t[n],u)>0&&Js(t,i,n);c0;)d--}0===r(t[i],u)?Js(t,i,d):Js(t,++d,n),d<=e&&(i=d+1),e<=d&&(n=d-1)}}function Js(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Qs(t,e){return te?1:0}class to{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!co(t,e))return i;const n=this.toBBox,r=[];for(;e;){for(let s=0;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)}_split(t,e){const i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const s=this._chooseSplitIndex(i,r,n),o=go(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,io(i,this.toBBox),io(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(i,o)}_splitRoot(t,e){this.data=go([t,e]),this.data.height=t.height+1,this.data.leaf=!1,io(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,r=1/0,s=1/0;for(let o=e;o<=i-e;o++){const e=no(t,0,o,this.toBBox),a=no(t,o,i,this.toBBox),l=ho(e,a),h=ao(e)+ao(a);l=e;n--){const e=t.children[n];ro(o,t.leaf?r(e):e),a+=lo(o)}return a}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)ro(e[n],t)}_condense(t){for(let e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children,e.splice(e.indexOf(t[i]),1)):this.clear():io(t[i],this.toBBox)}}function eo(t,e,i){if(!i)return e.indexOf(t);for(let n=0;n=t.minX&&e.maxY>=t.minY}function go(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function po(t,e,i,n,r){const s=[e,i];for(;s.length;){if((i=s.pop())-(e=s.pop())<=n)continue;const o=e+Math.ceil((i-e)/n/2)*n;Ks(t,o,e,i,r),s.push(e,o,o,i)}}let fo=0;const mo=1<",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string"},ko={[Lo.Get]:No(Ao(1,1/0),(function(t,e,i){const n=t.length-1,r=new Array(n);for(let e=0;ee){throw new Error(`expected ${e===1/0?`${t} or more`:`${t} to ${e}`} arguments for ${s}, got ${o}`)}}}function Oo(t,e,i){const n=t.length-1,r=new Array(n);for(let s=0;s{for(let e=0;e{for(let r=0;r{const n=t.args;let r=e.properties[i];for(let t=1,e=n.length;tt.variables[i];default:throw new Error(`Unsupported accessor operator ${t.operator}`)}}(t);case Lo.Id:return t=>t.featureId;case Lo.GeometryType:return t=>t.geometryType;case Lo.Concat:{const e=t.args.map((t=>$o(t)));return t=>"".concat(...e.map((e=>e(t).toString())))}case Lo.Resolution:return t=>t.resolution;case Lo.Any:case Lo.All:case Lo.Between:case Lo.In:case Lo.Not:return function(t){const e=t.operator,i=t.args.length,n=new Array(i);for(let e=0;e{for(let e=0;e{for(let e=0;e{const e=n[0](t),i=n[1](t),r=n[2](t);return e>=i&&e<=r};case Lo.In:return t=>{const e=n[0](t);for(let r=1;r!n[0](t);default:throw new Error(`Unsupported logical operator ${e}`)}}(t);case Lo.Equal:case Lo.NotEqual:case Lo.LessThan:case Lo.LessThanOrEqualTo:case Lo.GreaterThan:case Lo.GreaterThanOrEqualTo:return function(t){const e=t.operator,i=$o(t.args[0]),n=$o(t.args[1]);switch(e){case Lo.Equal:return t=>i(t)===n(t);case Lo.NotEqual:return t=>i(t)!==n(t);case Lo.LessThan:return t=>i(t)i(t)<=n(t);case Lo.GreaterThan:return t=>i(t)>n(t);case Lo.GreaterThanOrEqualTo:return t=>i(t)>=n(t);default:throw new Error(`Unsupported comparison operator ${e}`)}}(t);case Lo.Multiply:case Lo.Divide:case Lo.Add:case Lo.Subtract:case Lo.Clamp:case Lo.Mod:case Lo.Pow:case Lo.Abs:case Lo.Floor:case Lo.Ceil:case Lo.Round:case Lo.Sin:case Lo.Cos:case Lo.Atan:case Lo.Sqrt:return function(t){const e=t.operator,i=t.args.length,n=new Array(i);for(let e=0;e{let e=1;for(let r=0;rn[0](t)/n[1](t);case Lo.Add:return t=>{let e=0;for(let r=0;rn[0](t)-n[1](t);case Lo.Clamp:return t=>{const e=n[0](t),i=n[1](t);if(er?r:e};case Lo.Mod:return t=>n[0](t)%n[1](t);case Lo.Pow:return t=>Math.pow(n[0](t),n[1](t));case Lo.Abs:return t=>Math.abs(n[0](t));case Lo.Floor:return t=>Math.floor(n[0](t));case Lo.Ceil:return t=>Math.ceil(n[0](t));case Lo.Round:return t=>Math.round(n[0](t));case Lo.Sin:return t=>Math.sin(n[0](t));case Lo.Cos:return t=>Math.cos(n[0](t));case Lo.Atan:return 2===i?t=>Math.atan2(n[0](t),n[1](t)):t=>Math.atan(n[0](t));case Lo.Sqrt:return t=>Math.sqrt(n[0](t));default:throw new Error(`Unsupported numeric operator ${e}`)}}(t);case Lo.Case:return function(t){const e=t.args.length,i=new Array(e);for(let n=0;n{for(let n=0;n{const n=i[0](t);for(let r=1;r{const n=i[0](t),r=i[1](t);let s,o;for(let a=2;a=r)return 2===a?l:h?Vo(n,r,s,o,e,l):Bo(n,r,s,o,e,l);s=e,o=l}return o}}(t);case Lo.ToString:return function(t){const e=t.operator,i=t.args.length,n=new Array(i);for(let e=0;e{const i=n[0](e);return t.args[0].type===xo?O(i):i.toString()};throw new Error(`Unsupported convert operator ${e}`)}(t);default:throw new Error(`Unsupported operator ${i}`)}}function Bo(t,e,i,n,r,s){const o=r-i;if(0===o)return n;const a=e-i;return n+(1===t?a/o:(Math.pow(t,a)-1)/(Math.pow(t,o)-1))*(s-n)}function Vo(t,e,i,n,r,s){if(0===r-i)return n;const o=L(n),a=L(s);let l=a[2]-o[2];l>180?l-=360:l<-180&&(l+=360);return A(function(t){const e=u.rgb(d.xyz(t));return e[3]=t[3],e}([Bo(t,e,i,o[0],r,a[0]),Bo(t,e,i,o[1],r,a[1]),o[2]+Bo(t,e,i,0,r,l),Bo(t,e,i,n[3],r,s[3])]))}function Wo(t){return!0}function Xo(t){const e=Io(),i=function(t,e){const i=t.length,n=new Array(i);for(let r=0;rnull;n=ta(t,e+"fill-color",i)}if(!n)return null;const r=new Ce;return function(t){const e=n(t);return"none"===e?null:(r.setColor(e),r)}}function Ko(t,e,i){const n=Ho(t,e+"stroke-width",i),r=ta(t,e+"stroke-color",i);if(!n&&!r)return null;const s=Jo(t,e+"stroke-line-cap",i),o=Jo(t,e+"stroke-line-join",i),a=ea(t,e+"stroke-line-dash",i),l=Ho(t,e+"stroke-line-dash-offset",i),h=Ho(t,e+"stroke-miter-limit",i),u=new Hr;return function(t){if(r){const e=r(t);if("none"===e)return null;u.setColor(e)}if(n&&u.setWidth(n(t)),s){const e=s(t);if("butt"!==e&&"round"!==e&&"square"!==e)throw new Error("Expected butt, round, or square line cap");u.setLineCap(e)}if(o){const e=o(t);if("bevel"!==e&&"round"!==e&&"miter"!==e)throw new Error("Expected bevel, round, or miter line join");u.setLineJoin(e)}return a&&u.setLineDash(a(t)),l&&u.setLineDashOffset(l(t)),h&&u.setMiterLimit(h(t)),u}}function Ho(t,e,i){if(!(e in t))return;const n=Uo(t[e],_o,i);return function(t){return ca(n(t),e)}}function Jo(t,e,i){if(!(e in t))return null;const n=Uo(t[e],yo,i);return function(t){return ua(n(t),e)}}function Qo(t,e,i){if(!(e in t))return null;const n=Uo(t[e],mo,i);return function(t){const i=n(t);if("boolean"!=typeof i)throw new Error(`Expected a boolean for ${e}`);return i}}function ta(t,e,i){if(!(e in t))return null;const n=Uo(t[e],xo,i);return function(t){return da(n(t),e)}}function ea(t,e,i){if(!(e in t))return null;const n=Uo(t[e],vo,i);return function(t){return ha(n(t),e)}}function ia(t,e,i){if(!(e in t))return null;const n=Uo(t[e],vo,i);return function(t){const i=ha(n(t),e);if(2!==i.length)throw new Error(`Expected two numbers for ${e}`);return i}}function na(t,e,i){if(!(e in t))return null;const n=Uo(t[e],vo,i);return function(t){return ga(n(t),e)}}function ra(t,e,i){if(!(e in t))return null;const n=Uo(t[e],vo|_o,i);return function(t){return function(t,e){if("number"==typeof t)return t;return ga(t,e)}(n(t),e)}}function sa(t,e){const i=t[e];if(void 0!==i){if("number"!=typeof i)throw new Error(`Expected a number for ${e}`);return i}}function oa(t,e){const i=t[e];if(void 0!==i){if("bottom-left"!==i&&"bottom-right"!==i&&"top-left"!==i&&"top-right"!==i)throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return i}}function aa(t,e){const i=t[e];if(void 0!==i){if("pixels"!==i&&"fraction"!==i)throw new Error(`Expected pixels or fraction for ${e}`);return i}}function la(t,e){const i=t[e];if(void 0!==i){if("string"!=typeof i)throw new Error(`Expected a string for ${e}`);if("declutter"!==i&&"obstacle"!==i&&"none"!==i)throw new Error(`Expected declutter, obstacle, or none for ${e}`);return i}}function ha(t,e){if(!Array.isArray(t))throw new Error(`Expected an array for ${e}`);const i=t.length;for(let n=0;n4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return i}function ga(t,e){const i=ha(t,e);if(2!==i.length)throw new Error(`Expected an array of two numbers for ${e}`);return i}const pa="renderOrder";var fa=class extends Zs{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=void 0!==t.renderBuffer?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=void 0!==t.updateWhileAnimating&&t.updateWhileAnimating,this.updateWhileInteracting_=void 0!==t.updateWhileInteracting&&t.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(pa)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter==!1&&(t.declutter[i]=new to(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(pa,t)}setStyle(t){this.style_=void 0===t?ts:t;const e=function(t){if(void 0===t)return ts;if(!t)return null;if("function"==typeof t)return t;if(t instanceof ns)return t;if(!Array.isArray(t))return qo([t]);if(0===t.length)return[];const e=t.length,i=t[0];if(i instanceof ns){const i=new Array(e);for(let n=0;na&&(this.instructions.push([wa.CUSTOM,a,h,t,i,ar,r]),this.hitDetectionInstructions.push([wa.CUSTOM,a,h,t,n||i,ar,r]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),h=this.coordinates.length,this.instructions.push([wa.CUSTOM,a,h,t,i,void 0,r]),this.hitDetectionInstructions.push([wa.CUSTOM,a,h,t,n||i,void 0,r])}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[wa.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[wa.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;let e;t.reverse();const i=t.length;let n,r,s=-1;for(e=0;ethis.maxLineWidth&&(this.maxLineWidth=i.lineWidth,this.bufferedMaxExtent_=null)}else i.strokeStyle=void 0,i.lineCap=void 0,i.lineDash=null,i.lineDashOffset=void 0,i.lineJoin=void 0,i.lineWidth=void 0,i.miterLimit=void 0}createFill(t){const e=t.fillStyle,i=[wa.SET_FILL_STYLE,e];return"string"!=typeof e&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[wa.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,this.applyPixelRatio(t.lineDash),t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;"string"==typeof i&&t.currentFillStyle==i||(void 0!==i&&this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,n=t.lineCap,r=t.lineDash,s=t.lineDashOffset,o=t.lineJoin,a=t.lineWidth,l=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=n||r!=t.currentLineDash&&!at(t.currentLineDash,r)||t.currentLineDashOffset!=s||t.currentLineJoin!=o||t.currentLineWidth!=a||t.currentMiterLimit!=l)&&(void 0!==i&&e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=n,t.currentLineDash=r,t.currentLineDashOffset=s,t.currentLineJoin=o,t.currentLineWidth=a,t.currentMiterLimit=l)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[wa.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=We(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Ve(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}};var Ea=class extends Sa{constructor(t,e,i,n){super(t,e,i,n),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,i){if(!this.image_||this.maxExtent&&!qe(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const n=t.getFlatCoordinates(),r=t.getStride(),s=this.coordinates.length,o=this.appendFlatPointCoordinates(n,r);this.instructions.push([wa.DRAW_IMAGE,s,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([wa.DRAW_IMAGE,s,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);const n=t.getFlatCoordinates(),r=[];for(let e=0,i=n.length;e=t){const e=(t-a+c)/c,d=S(i,h,e),g=S(n,u,e);l.push(d,g),s.push(l),l=[d,g],a==t&&(o+=r),a=0}else if(a0&&s.push(l),s}function Pa(t,e,i,n,r){let s,o,a,l,h,u,c,d,g,p,f=i,m=i,_=0,y=0,x=i;for(o=i;ot&&(y>_&&(_=y,f=x,m=o),y=0,x=o-r)),a=l,c=g,d=p),h=i,u=n}return y+=l,y>_?[x,o]:[f,m]}const Fa={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};const Ia={Circle:Ta,Default:Sa,Image:Ea,LineString:Ca,Polygon:Ta,Text:class extends Sa{constructor(t,e,i,n){super(t,e,i,n),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[ie]={fillStyle:ie},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const n=this.textFillState_,r=this.textStrokeState_,s=this.textState_;if(""===this.text_||!s||!n&&!r)return;const o=this.coordinates;let a=o.length;const l=t.getType();let h=null,u=t.getStride();if("line"!==s.placement||"LineString"!=l&&"MultiLineString"!=l&&"Polygon"!=l&&"MultiPolygon"!=l){let n=s.overflow?null:[];switch(l){case"Point":case"MultiPoint":h=t.getFlatCoordinates();break;case"LineString":h=t.getFlatMidpoint();break;case"Circle":h=t.getCenter();break;case"MultiLineString":h=t.getFlatMidpoints(),u=2;break;case"Polygon":h=t.getFlatInteriorPoint(),s.overflow||n.push(h[2]/this.resolution),u=3;break;case"MultiPolygon":const e=t.getFlatInteriorPoints();h=[];for(let t=0,i=e.length;t{const n=o[2*(t+i)]===h[i*u]&&o[2*(t+i)+1]===h[i*u+1];return n||--t,n}))}this.saveTextStates_(),(s.backgroundFill||s.backgroundStroke)&&(this.setFillStrokeStyle(s.backgroundFill,s.backgroundStroke),s.backgroundFill&&this.updateFillStyle(this.state,this.createFill),s.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(t,e,i);let c=s.padding;if(c!=he&&(s.scale[0]<0||s.scale[1]<0)){let t=s.padding[0],e=s.padding[1],i=s.padding[2],n=s.padding[3];s.scale[0]<0&&(e=-e,n=-n),s.scale[1]<0&&(t=-t,i=-i),c=[t,e,i,n]}const d=this.pixelRatio;this.instructions.push([wa.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,c==he?he:c.map((function(t){return t*d})),!!s.backgroundFill,!!s.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,n]);const g=1/d,p=this.state.fillStyle;s.backgroundFill&&(this.state.fillStyle=ie,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([wa.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[g,g],NaN,this.declutterMode_,this.declutterImageWithText_,c,!!s.backgroundFill,!!s.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?ie:this.fillKey_,this.textOffsetX_,this.textOffsetY_,n]),s.backgroundFill&&(this.state.fillStyle=p,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(e)}else{if(!xi(this.maxExtent,t.getExtent()))return;let n;if(h=t.getFlatCoordinates(),"LineString"==l)n=[h.length];else if("MultiLineString"==l)n=t.getEnds();else if("Polygon"==l)n=t.getEnds().slice(0,1);else if("MultiPolygon"==l){const e=t.getEndss();n=[];for(let t=0,i=e.length;tthis.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return i()}getData(t){return null}prepareFrame(t){return i()}renderFrame(t,e){return i()}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const i=t.target;i.getState()!==e.LOADED&&i.getState()!==e.ERROR||this.renderIfReadyAndVisible()}loadImage(t){let i=t.getState();return i!=e.LOADED&&i!=e.ERROR&&t.addEventListener(mt,this.boundHandleImageChange_),i==e.IDLE&&(t.load(),i=t.getState()),i==e.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}};var ka=class extends it{constructor(t,e,i,n){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=n}};var Da=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Z(),{get:(t,e)=>{if("function"==typeof Z()[e])return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e),this.pushMethodArgs_},set:(t,e,i)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e,i),!0)})}pushMethodArgs_=(...t)=>(this.instructions_[this.zIndex+this.offset_].push(t),this);pushFunction(t){this.instructions_[this.zIndex+this.offset_].push(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach((e=>{for(let i=0,n=e.length;iMath.round(t*Ue[e])/Ue[e])).join(", ")+")";if(this.useContainer(e,l,this.getBackground(t)),!this.containerReused){const t=this.context.canvas;t.width!=o||t.height!=a?(t.width=o,t.height=a):this.context.clearRect(0,0,o,a),l!==t.style.transform&&(t.style.transform=l)}}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){const r=new ka(t,this.inversePixelTransform,i,e);n.dispatchEvent(r)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_(ds,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(gs,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new Da),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(ds,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(gs,this.context,t))}getRenderTransform(t,e,i,n,r,s,o){const a=r/2,l=s/2,h=n/e,u=-h,c=-t[0]+o,d=-t[1];return Ne(this.tempTransform,a,l,h,u,-i,c,d)}disposeInternal(){delete this.frameState,super.disposeInternal()}};function Ga(t,e,i,n,r,s,o,a,l,h,u,c){let d=t[e],g=t[e+1],p=0,f=0,m=0,_=0;function y(){p=d,f=g,d=t[e+=n],g=t[e+1],_+=m,m=Math.sqrt((d-p)*(d-p)+(g-f)*(g-f))}do{y()}while(et[2]}else P=v>T;const F=Math.PI,I=[],M=b+n===e;let L;if(m=0,_=E,d=t[e=b],g=t[e+1],M){y(),L=Math.atan2(g-f,d-p),P&&(L+=L>0?-F:F);const t=(T+v)/2,e=(R+w)/2;return I[0]=[t,e,(C-s)/2,L,r],I}for(let t=0,c=(r=r.replace(/\n/g," ")).length;t0?-F:F),void 0!==L){let t=v-L;if(t+=t>F?-2*F:t<-F?2*F:0,Math.abs(t)>o)return null}L=v;const w=t;let b=0;for(;t0&&t.push("\n",""),t.push(e,""),t}var Ya=class{constructor(t,e,i,n,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=n.instructions,this.coordinates=n.coordinates,this.coordinateCache_={},this.renderedTransform_=[1,0,0,1,0,0],this.hitDetectionInstructions=n.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=n.fillStates||{},this.strokeStates=n.strokeStates||{},this.textStates=n.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new Da:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,n){const r=t+e+i+n;if(this.labels_[r])return this.labels_[r];const s=n?this.strokeStates[n]:null,o=i?this.fillStates[i]:null,a=this.textStates[e],l=this.pixelRatio,h=[a.scale[0]*l,a.scale[1]*l],u=a.justify?Fa[a.justify]:Xa(Array.isArray(t)?t[0]:t,a.textAlign||ae),c=n&&s.lineWidth?s.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(qa,[]),{width:g,height:p,widths:f,heights:m,lineWidths:_}=function(t,e){const i=[],n=[],r=[];let s=0,o=0,a=0,l=0;for(let h=0,u=e.length;h<=u;h+=2){const c=e[h];if("\n"===c||h===u){s=Math.max(s,o),r.push(o),o=0,a+=l,l=0;continue}const d=e[h+1]||t.font,g=_e(d,c);i.push(g),o+=g;const p=fe(d);n.push(p),l=Math.max(l,p)}return{width:s,height:a,widths:i,heights:n,lineWidths:r}}(a,d),y=g+c,x=[],v=(y+2)*h[0],w=(p+c)*h[1],b={width:v<0?Math.floor(v):Math.ceil(v),height:w<0?Math.floor(w):Math.ceil(w),contextInstructions:x};1==h[0]&&1==h[1]||x.push("scale",h),n&&(x.push("strokeStyle",s.strokeStyle),x.push("lineWidth",c),x.push("lineCap",s.lineCap),x.push("lineJoin",s.lineJoin),x.push("miterLimit",s.miterLimit),x.push("setLineDash",[s.lineDash]),x.push("lineDashOffset",s.lineDashOffset)),i&&x.push("fillStyle",o.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const S=.5-u;let E=u*y+S*c;const C=[],T=[];let R,P=0,F=0,I=0,M=0;for(let t=0,e=d.length;tt?t-l:r,x=s+h>e?e-h:s,v=g[3]+y*c[0]+g[1],w=g[0]+x*c[1]+g[2],b=m-g[3],S=_-g[0];let E;return(p||0!==u)&&(ja[0]=b,Ba[0]=b,ja[1]=S,Ua[1]=S,Ua[0]=b+v,$a[0]=Ua[0],$a[1]=S+w,Ba[1]=$a[1]),0!==u?(E=Ne([1,0,0,1,0,0],i,n,1,1,u,-i,-n),Oe(E,ja),Oe(E,Ua),Oe(E,$a),Oe(E,Ba),Je(Math.min(ja[0],Ua[0],$a[0],Ba[0]),Math.min(ja[1],Ua[1],$a[1],Ba[1]),Math.max(ja[0],Ua[0],$a[0],Ba[0]),Math.max(ja[1],Ua[1],$a[1],Ba[1]),Na)):Je(Math.min(b,b+v),Math.min(S,S+w),Math.max(b,b+v),Math.max(S,S+w),Na),d&&(m=Math.round(m),_=Math.round(_)),{drawImageX:m,drawImageY:_,drawImageW:y,drawImageH:x,originX:l,originY:h,declutterBox:{minX:Na[0],minY:Na[1],maxX:Na[2],maxY:Na[3],value:f},canvasTransform:E,scale:c}}replayImageOrLabel_(t,e,i,n,r,s,o){const a=!(!s&&!o),l=n.declutterBox,h=o?o[2]*n.scale[0]/2:0;return l.minX-h<=e[0]&&l.maxX+h>=0&&l.minY-h<=e[1]&&l.maxY+h>=0&&(a&&this.replayTextBackground_(t,ja,Ua,$a,Ba,s,o),xe(t,n.canvasTransform,r,i,n.originX,n.originY,n.drawImageW,n.drawImageH,n.drawImageX,n.drawImageY,n.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=Oe(this.renderedTransform_,[0,0]),n=512*this.pixelRatio;t.save(),t.translate(i[0]%n,i[1]%n),1!==e&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6])}drawLabelWithPointPlacement_(t,e,i,n){const r=this.textStates[e],s=this.createLabel(t,e,n,i),o=this.strokeStates[i],a=this.pixelRatio,l=Xa(Array.isArray(t)?t[0]:t,r.textAlign||ae),h=Fa[r.textBaseline||le],u=o&&o.lineWidth?o.lineWidth:0;return{label:s,anchorX:l*(s.width/a-2*r.scale[0])+2*(.5-l)*u,anchorY:h*s.height/a+2*(.5-h)*u}}execute_(t,e,i,n,r,s,o,a){const l=this.zIndexContext_;let h;var u,c;this.pixelCoordinates_&&at(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=An(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),u=this.renderedTransform_,c=i,u[0]=c[0],u[1]=c[1],u[2]=c[2],u[3]=c[3],u[4]=c[4],u[5]=c[5]);let d=0;const g=n.length;let p,f,m,_,y,x,v,w,b,S,E,C,T,R=0,P=0,F=0,I=null,M=null;const L=this.coordinateCache_,k=this.viewRotation_,D=Math.round(1e12*Math.atan2(-i[1],i[0]))/1e12,A={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:k},O=this.instructions!=n||this.overlaps?0:200;let z,G,N,j;for(;dO&&(this.fill_(t),P=0),F>O&&(t.stroke(),F=0),P||F||(t.beginPath(),y=NaN,x=NaN),++d;break;case wa.CIRCLE:R=i[1];const n=h[R],u=h[R+1],c=h[R+2]-n,g=h[R+3]-u,U=Math.sqrt(c*c+g*g);t.moveTo(n+U,u),t.arc(n,u,U,0,2*Math.PI,!0),++d;break;case wa.CLOSE_PATH:t.closePath(),++d;break;case wa.CUSTOM:R=i[1],p=i[2];const $=i[3],B=i[4],V=i[5];A.geometry=$,A.feature=z,d in L||(L[d]=[]);const W=L[d];V?V(h,R,p,2,W):(W[0]=h[R],W[1]=h[R+1],W.length=2),l&&(l.zIndex=i[6]),B(W,A),++d;break;case wa.DRAW_IMAGE:R=i[1],p=i[2],b=i[3],f=i[4],m=i[5];let X=i[6];const q=i[7],Y=i[8],Z=i[9],K=i[10];let H=i[11];const J=i[12];let Q=i[13];_=i[14]||"declutter";const tt=i[15];if(!b&&i.length>=20){S=i[19],E=i[20],C=i[21],T=i[22];const t=this.drawLabelWithPointPlacement_(S,E,C,T);b=t.label,i[3]=b;const e=i[23];f=(t.anchorX-e)*this.pixelRatio,i[4]=f;const n=i[24];m=(t.anchorY-n)*this.pixelRatio,i[5]=m,X=b.height,i[6]=X,Q=b.width,i[13]=Q}let et,it,nt,rt;i.length>25&&(et=i[25]),i.length>17?(it=i[16],nt=i[17],rt=i[18]):(it=he,nt=!1,rt=!1),K&&D?H+=k:K||D||(H-=k);let st=0;for(;R!Ka.includes(t)));const Ja={};var Qa=class{constructor(t,e,i,n,r,s,o){this.maxExtent_=t,this.overlaps_=n,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=s,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=[1,0,0,1,0,0],this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,o)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(const i in t){let n=this.executorsByZIndex_[i];void 0===n&&(n={},this.executorsByZIndex_[i]=n);const r=t[i];for(const t in r){const i=r[t];n[t]=new Ya(this.resolution_,this.pixelRatio_,this.overlaps_,i,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let e=0,n=t.length;ei)break;let a=n[o];a||(a=[],n[o]=a),a.push(4*((t+r)*e+(t+s))+3),r>0&&a.push(4*((t-r)*e+(t+s))+3),s>0&&(a.push(4*((t+r)*e+(t-s))+3),r>0&&a.push(4*((t-r)*e+(t-s))+3))}const r=[];for(let t=0,e=n.length;t0){if(!s||"none"===i||"Image"!==d&&"Text"!==d||s.includes(t)){const i=(c[l]-3)/4,s=n-i%o,a=n-(i/o|0),h=r(t,e,s*s+a*a);if(h)return h}h.clearRect(0,0,o,o);break}}const p=Object.keys(this.executorsByZIndex_).map(Number);let f,m,_,y,x;for(p.sort(nt),f=p.length-1;f>=0;--f){const t=p[f].toString();for(_=this.executorsByZIndex_[t],m=Za.length-1;m>=0;--m)if(d=Za[m],y=_[d],void 0!==y&&(x=y.executeHitDetection(h,a,i,g,u),x))return x}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],n=e[1],r=e[2],s=e[3],o=[i,n,i,s,r,s,r,n];return An(o,0,8,2,t,o),o}isEmpty(){return pt(this.executorsByZIndex_)}execute(t,e,i,n,r,s,o){const a=Object.keys(this.executorsByZIndex_).map(Number);a.sort(nt),s=s||Za;const l=Za.length;let h,u,c,d,g;for(o&&a.reverse(),h=0,u=a.length;hd.execute(t,e,i,n,r,o))):d.execute(g,e,i,n,r,o),p&&g.restore(),s){s.offset();const t=a[h]*l+c;this.deferredZIndexContexts_[t]||(this.deferredZIndexContexts_[t]=[]),this.deferredZIndexContexts_[t].push(s)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(nt);for(let i=0,n=e.length;i{t.draw(this.renderedContext_),t.clear()})),t[e[i]].length=0}};var tl=class extends ba{constructor(t,e,i,n,r,s,o){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=n,this.transformRotation_=n?E(Math.atan2(n[1],n[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=s,this.userTransform_=o,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=[1,0,0,1,0,0]}drawImages_(t,e,i,n){if(!this.image_)return;const r=An(t,e,i,n,this.transform_,this.pixelCoordinates_),s=this.context_,o=this.tmpLocalTransform_,a=s.globalAlpha;1!=this.imageOpacity_&&(s.globalAlpha=a*this.imageOpacity_);let l=this.imageRotation_;0===this.transformRotation_&&(l-=this.viewRotation_),this.imageRotateWithView_&&(l+=this.viewRotation_);for(let t=0,e=r.length;tt*this.pixelRatio_)),lineDashOffset:(r||0)*this.pixelRatio_,lineJoin:void 0!==s?s:se,lineWidth:(void 0!==o?o:1)*this.pixelRatio_,miterLimit:void 0!==a?a:10,strokeStyle:jt(t||oe)}}else this.strokeState_=null}setImageStyle(t){let e;if(!t||!(e=t.getSize()))return void(this.image_=null);const i=t.getPixelRatio(this.pixelRatio_),n=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=n[0]*i,this.imageAnchorY_=n[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const s=t.getScaleArray();this.imageScale_=[s[0]*this.pixelRatio_/i,s[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(t){const e=t.getFill();if(e){const t=e.getColor();this.textFillState_={fillStyle:jt(t||ie)}}else this.textFillState_=null;const i=t.getStroke();if(i){const t=i.getColor(),e=i.getLineCap(),n=i.getLineDash(),r=i.getLineDashOffset(),s=i.getLineJoin(),o=i.getWidth(),a=i.getMiterLimit();this.textStrokeState_={lineCap:void 0!==e?e:ne,lineDash:n||re,lineDashOffset:r||0,lineJoin:void 0!==s?s:se,lineWidth:void 0!==o?o:1,miterLimit:void 0!==a?a:10,strokeStyle:jt(t||oe)}}else this.textStrokeState_=null;const n=t.getFont(),r=t.getOffsetX(),s=t.getOffsetY(),o=t.getRotateWithView(),a=t.getRotation(),l=t.getScaleArray(),h=t.getText(),u=t.getTextAlign(),c=t.getTextBaseline();this.textState_={font:void 0!==n?n:ee,textAlign:void 0!==u?u:ae,textBaseline:void 0!==c?c:le},this.text_=void 0!==h?Array.isArray(h)?h.reduce(((t,e,i)=>t+(i%2?" ":e)),""):h:"",this.textOffsetX_=void 0!==r?this.pixelRatio_*r:0,this.textOffsetY_=void 0!==s?this.pixelRatio_*s:0,this.textRotateWithView_=void 0!==o&&o,this.textRotation_=void 0!==a?a:0,this.textScale_=[this.pixelRatio_*l[0],this.pixelRatio_*l[1]]}else this.text_=""}};const el=.5;function il(t,e,i,n,r,s,o,a,l){const h=l?In(r,l):r,u=q(t[0]*el,t[1]*el);u.imageSmoothingEnabled=!1;const c=u.canvas,d=new tl(u,el,r,null,o,a,l?wn(Rn(),l):null),g=i.length,p=Math.floor(16777215/g),f={};for(let t=1;t<=g;++t){const e=i[t-1],r=e.getStyleFunction()||n;if(!r)continue;let o=r(e,s);if(!o)continue;Array.isArray(o)||(o=[o]);const a=(t*p).toString(16).padStart(7,"#00000");for(let t=0,i=o.length;t0;return d&&Promise.all(h).then((()=>s(null))),function(t,e,i,n,r,s,o){const a=i.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(n,r),h=i.getRenderer();if(h)ul(t,l,i,e,o);else{(0,sl[l.getType()])(t,l,i,e,o,s)}}(t,i,n,r,o,a,l),d}function ul(t,e,i,n,r){if("GeometryCollection"==e.getType()){const s=e.getGeometries();for(let e=0,o=s.length;e{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const t=this.frameState.size.slice(),e=this.renderedCenter_,i=this.renderedResolution_,n=this.renderedRotation_,r=this.renderedProjection_,s=this.wrappedRenderedExtent_,o=this.getLayer(),a=[],l=t[0]*el,h=t[1]*el;a.push(this.getRenderTransform(e,i,n,el,l,h,0).slice());const u=o.getSource(),c=r.getExtent();if(u.getWrapX()&&r.canWrapX()&&!Ye(c,s)){let t=s[0];const r=yi(c);let o,u=0;for(;tc[2];)++u,o=r*u,a.push(this.getRenderTransform(e,i,n,el,l,h,o).slice()),t-=r}const d=Rn();this.hitDetectionImageData_=il(t,a,this.renderedFeatures_,o.getStyleFunction(),s,i,n,al(i,this.renderedPixelRatio_),d?r:null)}e(nl(t,this.renderedFeatures_,this.hitDetectionImageData_))}))}forEachFeatureAtCoordinate(t,e,i,n,s){if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},u=function(t,e,i){const o=r(t),a=h[o];if(a){if(!0!==a&&ic=n.forEachFeatureAtCoordinate(t,o,a,i,u,g&&e.declutter[g]?e.declutter[g].all().map((t=>t.value)):null))),c}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const n=t.viewHints[Ps],r=t.viewHints[Fs],s=e.getUpdateWhileAnimating(),o=e.getUpdateWhileInteracting();if(this.ready&&!s&&n||!o&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const a=t.extent,l=t.viewState,h=l.projection,u=l.resolution,c=t.pixelRatio,d=e.getRevision(),g=e.getRenderBuffer();let p=e.getRenderOrder();void 0===p&&(p=ol);const f=l.center.slice(),m=Ve(a,g*u),_=m.slice(),y=[m.slice()],x=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!Ye(x,t.extent)){const t=yi(x),e=Math.max(yi(m)/2,t);m[0]=x[0]-e,m[2]=x[2]+e,Ki(f,h);const i=bi(y[0],h);i[0]x[0]&&i[2]>x[2]&&y.push([i[0]-t,i[1],i[2]-t,i[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==d&&this.renderedRenderOrder_==p&&this.renderedFrameDeclutter_===!!t.declutter&&Ye(this.wrappedRenderedExtent_,m))return at(this.renderedExtent_,_)||(this.hitDetectionImageData_=null,this.renderedExtent_=_),this.renderedCenter_=f,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const v=new Ma(ll(u,c),m,u,c),w=Rn();let b;if(w){for(let t=0,e=y.length;t{let n;const r=t.getStyleFunction()||e.getStyleFunction();if(r&&(n=r(t,u)),n){const e=this.renderFeature(t,S,n,v,b,this.getLayer().getDeclutter(),i);E=E&&!e}},T=In(m,h),R=i.getFeaturesInExtent(T);p&&R.sort(p);for(let t=0,e=R.length;tt):null}var fl=class extends qt{constructor(t){super(),this.projection=gn(t.projection),this.attributions_=pl(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=void 0!==t.state?t.state:"ready",this.wrapX_=void 0!==t.wrapX&&t.wrapX,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise((function(t,i){e.viewResolver=t,e.viewRejector=i}))}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=pl(t),this.changed()}setState(t){this.state_=t,this.changed()}},ml="addfeature",_l="changefeature",yl="clear",xl="removefeature",vl="featuresloadstart",wl="featuresloadend",bl="featuresloaderror";function Sl(t,e){return[[-1/0,-1/0,1/0,1/0]]}function El(t,e){return[t]}let Cl=!1;function Tl(t,e,i,n,r,s,o){const a=new XMLHttpRequest;a.open("GET","function"==typeof t?t(i,n,r):t,!0),"arraybuffer"==e.getType()&&(a.responseType="arraybuffer"),a.withCredentials=Cl,a.onload=function(t){if(!a.status||a.status>=200&&a.status<300){const t=e.getType();try{let n;"text"==t||"json"==t?n=a.responseText:"xml"==t?n=a.responseXML||a.responseText:"arraybuffer"==t&&(n=a.response),n?s(e.readFeatures(n,{extent:i,featureProjection:r}),e.readProjection(n)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function Rl(t,e){return function(i,n,r,s,o){const a=this;Tl(t,e,i,n,r,(function(t,e){a.addFeatures(t),void 0!==s&&s(t)}),o||ut)}}class Pl extends it{constructor(t,e,i){super(t),this.feature=e,this.features=i}}var Fl=class extends fl{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:void 0===t.wrapX||t.wrapX}),this.on,this.once,this.un,this.loader_=ut,this.format_=t.format||null,this.overlaps_=void 0===t.overlaps||t.overlaps,this.url_=t.url,void 0!==t.loader?this.loader_=t.loader:void 0!==this.url_&&(Te(this.format_,"`format` must be set when `url` is set"),this.loader_=Rl(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:Sl;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let i,n;this.featuresRtree_=e?new gl:null,this.loadedExtentsRtree_=new gl,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null,Array.isArray(t.features)?n=t.features:t.features&&(i=t.features,n=i.getArray()),e||void 0!==i||(i=new cs(n)),void 0!==n&&this.addFeaturesInternal(n),void 0!==i&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=r(t);if(!this.addToIndex_(e,t))return void(this.featuresCollection_&&this.featuresCollection_.remove(t));this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const e=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(e,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Pl(ml,t))}setupChangeEvents_(t,e){e instanceof Zr||(this.featureChangeKeys_[t]=[Ft(e,mt,this.handleFeatureChange_,this),Ft(e,Ut,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(void 0!==e.getId()){const t=String(e.getId());if(t in this.idIndex_)if(e instanceof Zr){const n=this.idIndex_[t];n instanceof Zr?Array.isArray(n)?n.push(e):this.idIndex_[t]=[n,e]:i=!1}else i=!1;else this.idIndex_[t]=e}return i&&(Te(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],n=[];for(let e=0,n=t.length;e{e||(e=!0,this.addFeature(t.element),e=!1)})),t.addEventListener(ls,(t=>{e||(e=!0,this.removeFeature(t.element),e=!1)})),this.featuresCollection_=t}clear(t){if(t){for(const t in this.featureChangeKeys_){this.featureChangeKeys_[t].forEach(Mt)}this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){const t=t=>{this.removeFeatureInternal(t)};this.featuresRtree_.forEach(t);for(const t in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[t])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new Pl(yl);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,(function(i){const n=i.getGeometry();if(n instanceof Zr||n.intersectsCoordinate(t))return e(i)}))}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,(function(i){const n=i.getGeometry();if(n instanceof Zr||n.intersectsExtent(t)){const t=e(i);if(t)return t}}))}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),pt(this.nullGeometryFeatures_)||ot(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,(function(t){e.push(t)})),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const i=Si(t,e);return[].concat(...i.map((t=>this.featuresRtree_.getInExtent(t))))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],n=t[1];let r=null;const s=[NaN,NaN];let o=1/0;const a=[-1/0,-1/0,1/0,1/0];return e=e||lt,this.featuresRtree_.forEachInExtent(a,(function(t){if(e(t)){const e=t.getGeometry(),l=o;if(o=e instanceof Zr?0:e.closestPointXY(i,n,s,o),o{--this.loadingExtentsCount_,this.dispatchEvent(new Pl(wl,void 0,t))}),(()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Pl(bl))})),n.insert(s,{extent:s.slice()}))}this.loading=!(this.loader_.length<4)&&this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_;let i;e.forEachInExtent(t,(function(e){if(ii(e.extent,t))return i=e,!0})),i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,n=t.length;it)throw new Error("Tile load sequence violation");this.state=t,this.changed()}load(){i()}getAlpha(t,e){if(!this.transition_)return 1;let i=this.transitionStarts_[t];if(i){if(-1===i)return 1}else i=e,this.transitionStarts_[t]=i;const n=e-i+1e3/60;return n>=this.transition_?1:js(n/this.transition_)}inTransition(t){return!!this.transition_&&-1!==this.transitionStarts_[t]}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}};var Ml=class extends Il{constructor(t,e,i,n,r,s){super(t,e,s),this.crossOrigin_=n,this.src_=i,this.key=i,this.image_=new Image,null!==n&&(this.image_.crossOrigin=n),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=os.LOADED,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=os.ERROR,this.unlistenImage_(),this.image_=function(){const t=q(1,1);return t.fillStyle="rgba(0,0,0,0)",t.fillRect(0,0,1,1),t.canvas}(),this.changed()}handleImageLoad_(){const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=os.LOADED:this.state=os.EMPTY,this.unlistenImage_(),this.changed()}load(){this.state==os.ERROR&&(this.state=os.IDLE,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==os.IDLE&&(this.state=os.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=function(t,e,i){const n=t;let r=!0,s=!1,o=!1;const a=[It(n,Tt,(function(){o=!0,s||e()}))];return n.src&&V?(s=!0,n.decode().then((function(){r&&e()})).catch((function(t){r&&(o?e():i())}))):a.push(It(n,_t,i)),function(){r=!1,a.forEach(Mt)}}(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}};var Ll=class{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]0&&this.points_[i+2]>t;)i-=3;const n=this.points_[e+2]-this.points_[i+2];if(n<1e3/60)return!1;const r=this.points_[e]-this.points_[i],s=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(s,r),this.initialVelocity_=Math.sqrt(r*r+s*s)/n,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}};function kl(t,e){Ot.expire()}var Dl=class extends et{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){i()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,n=t.pixelToCoordinateTransform;Ne(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),je(n,i)}forEachFeatureAtCoordinate(t,e,i,n,r,s,o,a){let l;const h=e.viewState;function u(t,e,i,n){return r.call(s,e,t?i:null,n)}const c=h.projection,d=Ki(t.slice(),c),g=[[0,0]];if(c.canWrapX()&&n){const t=yi(c.getExtent());g.push([-t,0],[t,0])}const p=e.layerStatesArray,f=p.length,m=[],_=[];for(let n=0;n=0;--r){const s=p[r],c=s.layer;if(c.hasRenderer()&&Ys(s,h)&&o.call(a,c)){const r=c.getRenderer(),o=c.getSource();if(r&&o){const a=o.getWrapX()?d:t,h=u.bind(null,s.managed);_[0]=a[0]+g[n][0],_[1]=a[1]+g[n][1],l=r.forEachFeatureAtCoordinate(_,e,i,h,m)}if(l)return l}}if(0===m.length)return;const y=1/m.length;return m.forEach(((t,e)=>t.distanceSq+=e*y)),m.sort(((t,e)=>t.distanceSq-e.distanceSq)),m.some((t=>l=t.callback(t.feature,t.layer,t.geometry))),l}hasFeatureAtCoordinate(t,e,i,n,r,s){return void 0!==this.forEachFeatureAtCoordinate(t,e,i,n,lt,this,r,s)}getMap(){return this.map_}renderFrame(t){i()}scheduleExpireIconCache(t){Ot.canExpireCache()&&t.postRenderFunctions.push(kl)}};var Al=class extends Dl{constructor(t){super(t),this.fontChangeListenerKey_=Ft(ue,Ut,t.redrawText.bind(t)),this.element_=document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=Zt+" ol-layers";const i=t.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const n=new ka(t,void 0,e);i.dispatchEvent(n)}}disposeInternal(){Mt(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t)return void(this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1));this.calculateMatrices2D(t),this.dispatchRenderEvent(ps,t);const e=t.layerStatesArray.sort(((t,e)=>t.zIndex-e.zIndex));e.some((t=>t.layer instanceof fa&&t.layer.getDeclutter()))&&(t.declutter={});const i=t.viewState;this.children_.length=0;const n=[];let r=null;for(let s=0,o=e.length;s=0;--i){const n=e[i],r=n.layer;r.getDeclutter()&&r.renderDeclutter(t,n)}e.forEach((e=>e.layer.renderDeferred(t)))}}};class Ol extends it{constructor(t,e){super(t),this.layer=e}}const zl="layers";class Gl extends Rs{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(zl,this.handleLayersChanged_),i?Array.isArray(i)?i=new cs(i.slice(),{unique:!0}):Te("function"==typeof i.getArray,"Expected `layers` to be an array or a `Collection`"):i=new cs(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(Mt),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(Ft(t,as,this.handleLayersAdd_,this),Ft(t,ls,this.handleLayersRemove_,this));for(const t in this.listenerKeys_)this.listenerKeys_[t].forEach(Mt);gt(this.listenerKeys_);const e=t.getArray();for(let t=0,i=e.length;t{this.clickTimeoutId_=void 0;const e=new $l(Bl.SINGLECLICK,this.map_,t);this.dispatchEvent(e)}),250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==Bl.POINTERUP||e.type==Bl.POINTERCANCEL){delete this.trackedTouches_[i];for(const t in this.trackedTouches_)if(this.trackedTouches_[t].target!==e.target){delete this.trackedTouches_[t];break}}else e.type!=Bl.POINTERDOWN&&e.type!=Bl.POINTERMOVE||(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new $l(Bl.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),0===this.activePointers_.length&&(this.dragListenerKeys_.forEach(Mt),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return 0===t.button}handlePointerDown_(t){this.emulateClicks_=0===this.activePointers_.length,this.updateActivePointers_(t);const e=new $l(Bl.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),0===this.dragListenerKeys_.length){const t=this.map_.getOwnerDocument();this.dragListenerKeys_.push(Ft(t,Bl.POINTERMOVE,this.handlePointerMove_,this),Ft(t,Bl.POINTERUP,this.handlePointerUp_,this),Ft(this.element_,Bl.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==t&&this.dragListenerKeys_.push(Ft(this.element_.getRootNode(),Bl.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new $l(Bl.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!(!this.down_||!this.isMoving_(t));this.dispatchEvent(new $l(Bl.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;e&&!e.defaultPrevented||"boolean"==typeof t.cancelable&&!0!==t.cancelable||t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(Mt(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(Rt,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(Mt(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(Mt),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},ql="postrender",Yl="movestart",Zl="moveend",Kl="loadstart",Hl="loadend",Jl="layergroup",Ql="size",th="target",eh="view";const ih=1/0;var nh=class{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,gt(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,i=t[0];1==t.length?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const n=this.keyFunction_(i);return delete this.queuedElements_[n],i}enqueue(t){Te(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=ih&&(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0)}getCount(){return this.elements_.length}getLeftChildIndex_(t){return 2*t+1}getRightChildIndex_(t){return 2*t+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return 0===this.elements_.length}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,i=this.priorities_,n=e.length,r=e[t],s=i[t],o=t;for(;t>1;){const r=this.getLeftChildIndex_(t),s=this.getRightChildIndex_(t),o=st;){const t=this.getParentIndex_(e);if(!(n[t]>s))break;i[e]=i[t],n[e]=n[t],e=t}i[e]=r,n[e]=s}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let n=0;const r=e.length;let s,o,a;for(o=0;o0;){const t=this.dequeue()[0],e=t.getKey();t.getState()!==os.IDLE||e in this.tilesLoadingKeys_||(this.tilesLoadingKeys_[e]=!0,++this.tilesLoading_,++i,t.load())}}};class sh extends qt{constructor(t){super();const e=t.element;!e||t.target||e.style.pointerEvents||(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let t=0,e=this.listenerKeys.length;te.getAttributions(t)))));if(!this.overrideCollapsible_){const t=!e.some((t=>!1===t.getSource()?.getAttributionsCollapsible()));this.setCollapsible(t)}return i}async updateElement_(t){if(!t)return void(this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1));const e=await Promise.all(this.collectSourceAttributions_(t).map((t=>dt((()=>t))))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!at(e,this.renderedAttributions_)){tt(this.ulElement_);for(let t=0,i=e.length;t0&&e%(2*Math.PI)!=0?t.animate({rotation:0,duration:this.duration_,easing:Us}):t.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const t="rotate("+i+"rad)";if(this.autoHide_){const t=this.element.classList.contains(Yt);t||0!==i?t&&0!==i&&this.element.classList.remove(Yt):this.element.classList.add(Yt)}this.label_.style.transform=t}this.rotation_=i}};var hh=class extends sh{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=void 0!==t.className?t.className:"ol-zoom",i=void 0!==t.delta?t.delta:1,n=void 0!==t.zoomInClassName?t.zoomInClassName:e+"-in",r=void 0!==t.zoomOutClassName?t.zoomOutClassName:e+"-out",s=void 0!==t.zoomInLabel?t.zoomInLabel:"+",o=void 0!==t.zoomOutLabel?t.zoomOutLabel:"–",a=void 0!==t.zoomInTipLabel?t.zoomInTipLabel:"Zoom in",l=void 0!==t.zoomOutTipLabel?t.zoomOutTipLabel:"Zoom out",h=document.createElement("button");h.className=n,h.setAttribute("type","button"),h.title=a,h.appendChild("string"==typeof s?document.createTextNode(s):s),h.addEventListener(xt,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=l,u.appendChild("string"==typeof o?document.createTextNode(o):o),u.addEventListener(xt,this.handleClick_.bind(this,-i),!1);const c=e+" "+Zt+" "+Kt,d=this.element;d.className=c,d.appendChild(h),d.appendChild(u),this.duration_=void 0!==t.duration?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const e=this.getMap().getView();if(!e)return;const i=e.getZoom();if(void 0!==i){const n=e.getConstrainedZoom(i+t);this.duration_>0?(e.getAnimating()&&e.cancelAnimations(),e.animate({zoom:n,duration:this.duration_,easing:Us})):e.setZoom(n)}}};var uh="active";function ch(t,e,i,n){const r=t.getZoom();if(void 0===r)return;const s=t.getConstrainedZoom(r+e),o=t.getResolutionForZoom(s);t.getAnimating()&&t.cancelAnimations(),t.animate({resolution:o,anchor:i,duration:void 0!==n?n:250,easing:Us})}var dh=class extends qt{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(uh)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(uh,t)}setMap(t){this.map_=t}};var gh=class extends dh{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:250}handleEvent(t){let e=!1;if(t.type==Bl.DBLCLICK){const i=t.originalEvent,n=t.map,r=t.coordinate,s=i.shiftKey?-this.delta_:this.delta_;ch(n.getView(),s,r,this.duration_),i.preventDefault(),e=!0}return!e}};function ph(t){const e=t.length;let i=0,n=0;for(let r=0;r0}}else if(t.type==Bl.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==Bl.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function mh(t){const e=arguments;return function(t){let i=!0;for(let n=0,r=e.length;n0&&this.condition_(t)){const e=t.map.getView();return this.lastCentroid=null,e.getAnimating()&&e.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}};var Fh=class extends fh{constructor(t){t=t||{},super({stopDown:ht}),this.condition_=t.condition?t.condition:_h,this.lastAngle_=void 0,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){if(!Th(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===Gs)return;const n=e.getSize(),r=t.pixel,s=Math.atan2(n[1]/2-r[1],r[0]-n[0]/2);if(void 0!==this.lastAngle_){const t=s-this.lastAngle_;i.adjustRotationInternal(-t)}this.lastAngle_=s}handleUpEvent(t){if(!Th(t))return!0;return t.map.getView().endInteraction(this.duration_),!1}handleDownEvent(t){if(!Th(t))return!1;if(vh(t)&&this.condition_(t)){return t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0}return!1}};var Ih=class extends et{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,i="px",n=this.element_.style;n.left=Math.min(t[0],e[0])+i,n.top=Math.min(t[1],e[1])+i,n.width=Math.abs(e[0]-t[0])+i,n.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const t=this.startPixel_,e=this.endPixel_,i=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);i[4]=i[0].slice(),this.geometry_?this.geometry_.setCoordinates([i]):this.geometry_=new Ur([i])}getGeometry(){return this.geometry_}};const Mh="boxstart",Lh="boxdrag",kh="boxend",Dh="boxcancel";class Ah extends it{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}var Oh=class extends fh{constructor(t){super(),this.on,this.once,this.un,t=t||{},this.box_=new Ih(t.className||"ol-dragbox"),this.minArea_=void 0!==t.minArea?t.minArea:64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition?t.condition:vh,this.boxEndCondition_=t.boxEndCondition?t.boxEndCondition:this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const n=i[0]-e[0],r=i[1]-e[1];return n*n+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new Ah(Lh,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;this.box_.setMap(null);const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new Ah(e?kh:Dh,t.coordinate,t)),!1}handleDownEvent(t){return!!this.condition_(t)&&(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new Ah(Mh,t.coordinate,t)),!0)}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Ah(Dh,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}};var zh=class extends Oh{constructor(t){super({condition:(t=t||{}).condition?t.condition:Eh,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=void 0!==t.duration?t.duration:200,this.out_=void 0!==t.out&&t.out}onBoxEnd(t){const e=this.getMap().getView();let i=this.getGeometry();if(this.out_){const t=e.rotatedExtentForGeometry(i),n=e.getResolutionForExtentInternal(t),r=e.getResolution()/n;i=i.clone(),i.scale(r*r)}e.fitInternal(i,{duration:this.duration_,easing:Us})}},Gh="ArrowLeft",Nh="ArrowUp",jh="ArrowRight",Uh="ArrowDown";var $h=class extends dh{constructor(t){super(),t=t||{},this.defaultCondition_=function(t){return Sh(t)&&Ch(t)},this.condition_=void 0!==t.condition?t.condition:this.defaultCondition_,this.duration_=void 0!==t.duration?t.duration:100,this.pixelDelta_=void 0!==t.pixelDelta?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==Et){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==Uh||n==Gh||n==jh||n==Nh)){const r=t.map.getView(),s=r.getResolution()*this.pixelDelta_;let o=0,a=0;n==Uh?a=-s:n==Gh?o=-s:n==jh?o=s:a=s;const l=[o,a];Xi(l,r.getRotation()),function(t,e,i){const n=t.getCenterInternal();if(n){const r=[n[0]+e[0],n[1]+e[1]];t.animateInternal({duration:void 0!==i?i:250,easing:Bs,center:t.getConstrainedCenter(r)})}}(r,l,this.duration_),i.preventDefault(),e=!0}}return!e}};var Bh=class extends dh{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(t){return!function(t){const e=t.originalEvent;return U?e.metaKey:e.ctrlKey}(t)&&Ch(t)},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:100}handleEvent(t){let e=!1;if(t.type==Et||t.type==Ct){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&("+"===n||"-"===n)){const r=t.map,s="+"===n?this.delta_:-this.delta_;ch(r.getView(),s,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}};var Vh=class extends dh{constructor(t){super(t=t||{}),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=void 0!==t.maxDelta?t.maxDelta:1,this.duration_=void 0!==t.duration?t.duration:250,this.timeout_=void 0!==t.timeout?t.timeout:80,this.useAnchor_=void 0===t.useAnchor||t.useAnchor,this.constrainResolution_=void 0!==t.constrainResolution&&t.constrainResolution;const e=t.condition?t.condition:xh;this.condition_=t.onFocusOnly?mh(yh,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;t.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_)}handleEvent(t){if(!this.condition_(t))return!0;if(t.type!==Pt)return!0;const e=t.map,i=t.originalEvent;let n;if(i.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.coordinate),t.type==Pt&&(n=i.deltaY,G&&i.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(n/=$),i.deltaMode===WheelEvent.DOM_DELTA_LINE&&(n*=40)),0===n)return!1;this.lastDelta_=n;const r=Date.now();void 0===this.startTime_&&(this.startTime_=r),(!this.mode_||r-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(n)<4?"trackpad":"wheel");const s=e.getView();if("trackpad"===this.mode_&&!s.getConstrainResolution()&&!this.constrainResolution_)return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(s.getAnimating()&&s.cancelAnimations(),s.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),s.adjustZoom(-n/this.deltaPerZoom_,this.lastAnchor_),this.startTime_=r,!1;this.totalDelta_+=n;const o=Math.max(this.timeout_-(r-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,e),o),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-_(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),ch(e,i,this.lastAnchor_,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}};var Wh=class extends fh{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=ht),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=void 0!==t.threshold?t.threshold:.3,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){let e=0;const i=this.targetPointers[0],n=this.targetPointers[1],r=Math.atan2(n.clientY-i.clientY,n.clientX-i.clientX);if(void 0!==this.lastAngle_){const t=r-this.lastAngle_;this.rotationDelta_+=t,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=t}this.lastAngle_=r;const s=t.map,o=s.getView();o.getConstraints().rotation!==Gs&&(this.anchor_=s.getCoordinateFromPixelInternal(s.getEventPixel(ph(this.targetPointers))),this.rotating_&&(s.render(),o.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){if(this.targetPointers.length<2){return t.map.getView().endInteraction(this.duration_),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}};var Xh=class extends fh{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=ht),super(e),this.anchor_=null,this.duration_=void 0!==t.duration?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1;const i=this.targetPointers[0],n=this.targetPointers[1],r=i.clientX-n.clientX,s=i.clientY-n.clientY,o=Math.sqrt(r*r+s*s);void 0!==this.lastDistance_&&(e=this.lastDistance_/o),this.lastDistance_=o;const a=t.map,l=a.getView();1!=e&&(this.lastScaleDelta_=e),this.anchor_=a.getCoordinateFromPixelInternal(a.getEventPixel(ph(this.targetPointers))),a.render(),l.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const e=t.map.getView(),i=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,i),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}};function qh(t){t=t||{};const e=new cs,i=new Ll(-.005,.05,100);(void 0===t.altShiftDragRotate||t.altShiftDragRotate)&&e.push(new Fh);(void 0===t.doubleClickZoom||t.doubleClickZoom)&&e.push(new gh({delta:t.zoomDelta,duration:t.zoomDuration}));(void 0===t.dragPan||t.dragPan)&&e.push(new Ph({onFocusOnly:t.onFocusOnly,kinetic:i}));(void 0===t.pinchRotate||t.pinchRotate)&&e.push(new Wh);(void 0===t.pinchZoom||t.pinchZoom)&&e.push(new Xh({duration:t.zoomDuration}));(void 0===t.keyboard||t.keyboard)&&(e.push(new $h),e.push(new Bh({delta:t.zoomDelta,duration:t.zoomDuration})));(void 0===t.mouseWheelZoom||t.mouseWheelZoom)&&e.push(new Vh({onFocusOnly:t.onFocusOnly,duration:t.zoomDuration}));return(void 0===t.shiftDragZoom||t.shiftDragZoom)&&e.push(new zh({duration:t.zoomDuration})),e}function Yh(t){t instanceof Zs?t.setMapInternal(null):t instanceof Nl&&t.getLayers().forEach(Yh)}function Zh(t,e){if(t instanceof Zs)t.setMapInternal(e);else if(t instanceof Nl){const i=t.getLayers().getArray();for(let t=0,n=i.length;tthis.updateSize())),this.controls=e.controls||function(t){t=t||{};const e=new cs;return(void 0===t.zoom||t.zoom)&&e.push(new hh(t.zoomOptions)),(void 0===t.rotate||t.rotate)&&e.push(new lh(t.rotateOptions)),(void 0===t.attribution||t.attribution)&&e.push(new ah(t.attributionOptions)),e}(),this.interactions=e.interactions||qh({onFocusOnly:!0}),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new rh(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Jl,this.handleLayerGroupChanged_),this.addChangeListener(eh,this.handleViewChanged_),this.addChangeListener(Ql,this.handleSizeChanged_),this.addChangeListener(th,this.handleTargetChanged_),this.setProperties(e.values);const i=this;!t.view||t.view instanceof qs||t.view.then((function(t){i.setView(new qs(t))})),this.controls.addEventListener(as,(t=>{t.element.setMap(this)})),this.controls.addEventListener(ls,(t=>{t.element.setMap(null)})),this.interactions.addEventListener(as,(t=>{t.element.setMap(this)})),this.interactions.addEventListener(ls,(t=>{t.element.setMap(null)})),this.overlays_.addEventListener(as,(t=>{this.addOverlayInternal_(t.element)})),this.overlays_.addEventListener(ls,(t=>{const e=t.element.getId();void 0!==e&&delete this.overlayIdIndex_[e.toString()],t.element.setMap(null)})),this.controls.forEach((t=>{t.setMap(this)})),this.interactions.forEach((t=>{t.setMap(this)})),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){Zh(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();void 0!==e&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;const n=this.getCoordinateFromPixelInternal(t),r=void 0!==(i=void 0!==i?i:{}).hitTolerance?i.hitTolerance:0,s=void 0!==i.layerFilter?i.layerFilter:lt,o=!1!==i.checkWrapped;return this.renderer_.forEachFeatureAtCoordinate(n,this.frameState_,r,o,e,null,s,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,(function(t){i.push(t)}),e),i}getAllLayers(){const t=[];return function e(i){i.forEach((function(i){i instanceof Nl?e(i.getLayers()):t.push(i)}))}(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(t),n=void 0!==(e=void 0!==e?e:{}).layerFilter?e.layerFilter:lt,r=void 0!==e.hitTolerance?e.hitTolerance:0,s=!1!==e.checkWrapped;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,s,n,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const e=this.viewport_.getBoundingClientRect(),i=this.getSize(),n=e.width/i[0],r=e.height/i[1],s="changedTouches"in t?t.changedTouches[0]:t;return[(s.clientX-e.left)/n,(s.clientY-e.top)/r]}getTarget(){return this.get(th)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Pn(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?Oe(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return void 0!==e?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Jl)}setLayers(t){const e=this.getLayerGroup();if(t instanceof cs)return void e.setLayers(t);const i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e=0;i--){const n=e[i];if(n.getMap()!==this||!n.getActive()||!this.getTargetElement())continue;if(!n.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let i=this.maxTilesLoading_,n=i;if(t){const e=t.viewHints;if(e[Ps]||e[Fs]){const e=Date.now()-t.time>8;i=e?0:8,n=e?0:2}}e.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()}),0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new Ol("removelayer",e)),this.set(Jl,t)}setSize(t){this.set(Ql,t)}setTarget(t){this.set(th,t)}setView(t){if(!t||t instanceof qs)return void this.set(eh,t);this.set(eh,new qs);const e=this;t.then((function(t){e.setView(new qs(t))}))}updateSize(){const t=this.getTargetElement();let e;if(t){const i=getComputedStyle(t),n=t.offsetWidth-parseFloat(i.borderLeftWidth)-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight)-parseFloat(i.borderRightWidth),r=t.offsetHeight-parseFloat(i.borderTopWidth)-parseFloat(i.paddingTop)-parseFloat(i.paddingBottom)-parseFloat(i.borderBottomWidth);isNaN(n)||isNaN(r)||(e=[Math.max(0,n),Math.max(0,r)],!s(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&on("No map visible because the map container's width or height are 0."))}const i=this.getSize();!e||i&&at(e,i)||(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};const Hh="element",Jh="map",Qh="offset",tu="position",eu="positioning";var iu=class extends qt{constructor(t){super(),this.on,this.once,this.un,this.options=t,this.id=t.id,this.insertFirst=void 0===t.insertFirst||t.insertFirst,this.stopEvent=void 0===t.stopEvent||t.stopEvent,this.element=document.createElement("div"),this.element.className=void 0!==t.className?t.className:"ol-overlay-container ol-selectable",this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=!0===t.autoPan?{}:t.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(Hh,this.handleElementChanged),this.addChangeListener(Jh,this.handleMapChanged),this.addChangeListener(Qh,this.handleOffsetChanged),this.addChangeListener(tu,this.handlePositionChanged),this.addChangeListener(eu,this.handlePositioningChanged),void 0!==t.element&&this.setElement(t.element),this.setOffset(void 0!==t.offset?t.offset:[0,0]),this.setPositioning(t.positioning||"top-left"),void 0!==t.position&&this.setPosition(t.position)}getElement(){return this.get(Hh)}getId(){return this.id}getMap(){return this.get(Jh)||null}getOffset(){return this.get(Qh)}getPosition(){return this.get(tu)}getPositioning(){return this.get(eu)}handleElementChanged(){tt(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),Mt(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=Ft(t,ql,this.render,this),this.updatePixelPosition();const e=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?e.insertBefore(this.element,e.childNodes[0]||null):e.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(t){this.set(Hh,t)}setMap(t){this.set(Jh,t)}setOffset(t){this.set(Qh,t)}setPosition(t){this.set(tu,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(tu))return;const i=this.getRect(e.getTargetElement(),e.getSize()),n=this.getElement(),r=this.getRect(n,[H(n),J(n)]),s=void 0===(t=t||{}).margin?20:t.margin;if(!Ye(i,r)){const n=r[0]-i[0],o=i[2]-r[2],a=r[1]-i[1],l=i[3]-r[3],h=[0,0];if(n<0?h[0]=n-s:o<0&&(h[0]=Math.abs(o)+s),a<0?h[1]=a-s:l<0&&(h[1]=Math.abs(l)+s),0!==h[0]||0!==h[1]){const i=e.getView().getCenterInternal(),n=e.getPixelFromCoordinateInternal(i);if(!n)return;const r=[n[0]+h[0],n[1]+h[1]],s=t.animation||{};e.getView().animateInternal({center:e.getCoordinateFromPixelInternal(r),duration:s.duration,easing:s.easing})}}}getRect(t,e){const i=t.getBoundingClientRect(),n=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[n,r,n+e[0],r+e[1]]}setPositioning(t){this.set(eu,t)}setVisible(t){this.rendered.visible!==t&&(this.element.style.display=t?"":"none",this.rendered.visible=t)}updatePixelPosition(){const t=this.getMap(),e=this.getPosition();if(!t||!t.isRendered()||!e)return void this.setVisible(!1);const i=t.getPixelFromCoordinate(e),n=t.getSize();this.updateRenderedPosition(i,n)}updateRenderedPosition(t,e){const i=this.element.style,n=this.getOffset(),r=this.getPositioning();this.setVisible(!0);let s="0%",o="0%";"bottom-right"==r||"center-right"==r||"top-right"==r?s="-100%":"bottom-center"!=r&&"center-center"!=r&&"top-center"!=r||(s="-50%"),"bottom-left"==r||"bottom-center"==r||"bottom-right"==r?o="-100%":"center-left"!=r&&"center-center"!=r&&"center-right"!=r||(o="-50%");const a=`translate(${s}, ${o}) translate(${Math.round(t[0]+n[0])+"px"}, ${Math.round(t[1]+n[1])+"px"})`;this.rendered.transform_!=a&&(this.rendered.transform_=a,i.transform=a)}getOptions(){return this.options}};var nu=class{constructor(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.pop()}clear(){this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const i=this.entries_[t];return Te(void 0!==i,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(t){const e=this.entries_[t];return Te(void 0!==e,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e,i=0;for(e=this.newest_;e;e=e.older)t[i++]=e.key_;return t}getValues(){const t=new Array(this.count_);let e,i=0;for(e=this.newest_;e;e=e.older)t[i++]=e.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){Te(!(t in this.entries_),"Tried to set a value for a key that is used already");const i={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[t]=i,++this.count_}setSize(t){this.highWaterMark=t}};function ru(t,e,i,n){return void 0!==n?(n[0]=t,n[1]=e,n[2]=i,n):[t,e,i]}function su(t,e,i){return t+"/"+e+"/"+i}function ou(t){return su(t[0],t[1],t[2])}function au(t){return e=t[0],i=t[1],n=t[2],(i<0;)this.pop().release();super.clear()}expireCache(t){for(;this.canExpireCache();){if(this.peekLast().getKey()in t)break;this.pop().release()}}pruneExceptNewestZ(){if(0===this.getCount())return;const t=function(t){return t.split("/").map(Number)}(this.peekFirstKey()),e=t[0];this.forEach((t=>{t.tileCoord[0]!==e&&(this.remove(ou(t.tileCoord)),t.release())}))}};class hu{constructor(t,e,i,n){this.minX=t,this.maxX=e,this.minY=i,this.maxY=n}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minXthis.maxX&&(this.maxX=t.maxX),t.minYthis.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}}function uu(t,e,i,n,r){return void 0!==r?(r.minX=t,r.maxX=e,r.minY=i,r.maxY=n,r):new hu(t,e,i,n)}var cu=hu;const du=[];var gu=class extends Il{constructor(t,e,i,n){super(t,e,{transition:0}),this.context_=null,this.executorGroups=[],this.loadingSourceTiles=0,this.hitDetectionImageData={},this.replayState_={},this.sourceTiles=[],this.errorTileKeys={},this.wantedResolution,this.getSourceTiles=n.bind(void 0,this),this.wrappedTileCoord=i}getContext(){return this.context_||(this.context_=q(1,1,du)),this.context_}hasContext(){return!!this.context_}getImage(){return this.hasContext()?this.getContext().canvas:null}getReplayState(t){const e=r(t);return e in this.replayState_||(this.replayState_[e]={dirty:!1,renderedRenderOrder:null,renderedResolution:NaN,renderedRevision:-1,renderedTileResolution:NaN,renderedTileRevision:-1,renderedTileZ:-1}),this.replayState_[e]}load(){this.getSourceTiles()}release(){K(this.context_),du.push(this.context_.canvas),this.context_=null,super.release()}};var pu=class extends Il{constructor(t,e,i,n,r,s){super(t,e,s),this.extent=null,this.format_=n,this.features_=null,this.loader_,this.projection=null,this.resolution,this.tileLoadFunction_=r,this.url_=i,this.key=i}getFormat(){return this.format_}getFeatures(){return this.features_}load(){this.state==os.IDLE&&(this.setState(os.LOADING),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))}onLoad(t,e){this.setFeatures(t)}onError(){this.setState(os.ERROR)}setFeatures(t){this.features_=t,this.setState(os.LOADED)}setLoader(t){this.loader_=t}};function fu(t,e){const i=[];Object.keys(e).forEach((function(t){null!==e[t]&&void 0!==e[t]&&i.push(t+"="+encodeURIComponent(e[t]))}));const n=i.join("&");return t=t.replace(/[?&]$/,""),(t+=t.includes("?")?"&":"?")+n}const mu=/\{z\}/g,_u=/\{x\}/g,yu=/\{y\}/g,xu=/\{-y\}/g;function vu(t){const e=[];let i=/\{([a-z])-([a-z])\}/.exec(t);if(i){const n=i[1].charCodeAt(0),r=i[2].charCodeAt(0);let s;for(s=n;s<=r;++s)e.push(t.replace(i[0],String.fromCharCode(s)));return e}if(i=/\{(\d+)-(\d+)\}/.exec(t),i){const n=parseInt(i[2],10);for(let r=parseInt(i[1],10);r<=n;r++)e.push(t.replace(i[0],r.toString()));return e}return e.push(t),e}function wu(t,e){return function(i,n,r){if(!i)return;let s;const o=i[0];if(e){const t=e.getFullTileRange(o);t&&(s=t.getHeight()-1)}return function(t,e,i,n,r){return t.replace(mu,e.toString()).replace(_u,i.toString()).replace(yu,n.toString()).replace(xu,(function(){if(void 0===r)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(r-n).toString()}))}(t,o,i[1],i[2],s)}}function bu(t,e){const i=t.length,n=new Array(i);for(let r=0;rRu({...t,geometry:e}))).flat();const n="MultiPolygon"===i.type?"Polygon":i.type;if("GeometryCollection"===n||"Circle"===n)throw new Error("Unsupported geometry type: "+n);const r=i.layout.length;return Cu(new Zr(n,"Polygon"===n?function(t,e,i){return Array.isArray(e[0])?(zr(t,0,e,i)||Nr(t=t.slice(),0,e,i),t):(Or(t,0,e,i)||Gr(t=t.slice(),0,e,i),t)}(i.flatCoordinates,i.ends,r):i.flatCoordinates,i.ends?.flat(),r,t.properties||{},t.id).enableSimplifyTransformed(),!1,e)}function Pu(t,e){if(!t)return null;if(Array.isArray(t)){const i=t.map((t=>Pu(t,e)));return new Kn(i)}return Cu(new(0,Tu[t.type])(t.flatCoordinates,t.layout,t.ends),!1,e)}function Fu(t){if("string"==typeof t){const e=JSON.parse(t);return e||null}return null!==t?t:null}var Iu=class extends Eu{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Fu(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Fu(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return i()}readFeaturesFromObject(t,e){return i()}readGeometry(t,e){return this.readGeometryFromObject(Fu(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return i()}readProjection(t){return this.readProjectionFromObject(Fu(t))}readProjectionFromObject(t){return i()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return i()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return i()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return i()}};function Mu(t,e){if(!t)return null;let i;switch(t.type){case"Point":i=function(t){const e=t.coordinates;return{type:"Point",flatCoordinates:e,layout:jn(e.length)}}(t);break;case"LineString":i=function(t){const e=t.coordinates,i=e.flat();return{type:"LineString",flatCoordinates:i,ends:[i.length],layout:jn(e[0]?.length||2)}}(t);break;case"Polygon":i=function(t){const e=t.coordinates,i=[],n=e[0]?.[0]?.length,r=Vn(i,0,e,n);return{type:"Polygon",flatCoordinates:i,ends:r,layout:jn(n)}}(t);break;case"MultiPoint":i=function(t){const e=t.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:jn(e[0]?.length||2)}}(t);break;case"MultiLineString":i=function(t){const e=t.coordinates,i=e[0]?.[0]?.length||2,n=[],r=Vn(n,0,e,i);return{type:"MultiLineString",flatCoordinates:n,ends:r,layout:jn(i)}}(t);break;case"MultiPolygon":i=function(t){const e=t.coordinates,i=[],n=e[0]?.[0]?.[0].length||2,r=Wn(i,0,e,n);return{type:"MultiPolygon",flatCoordinates:i,ends:r,layout:jn(n)}}(t);break;case"GeometryCollection":i=function(t){const e=t.geometries.map((function(t){return Mu(t)}));return e}(t);break;default:throw new Error("Unsupported GeoJSON type: "+t.type)}return i}function Lu(t,e){const i=(t=Cu(t,!0,e)).getType();let n;switch(i){case"Point":n=function(t){return{type:"Point",coordinates:t.getCoordinates()}}(t);break;case"LineString":n=function(t){return{type:"LineString",coordinates:t.getCoordinates()}}(t);break;case"Polygon":n=function(t,e){let i;e&&(i=e.rightHanded);return{type:"Polygon",coordinates:t.getCoordinates(i)}}(t,e);break;case"MultiPoint":n=function(t){return{type:"MultiPoint",coordinates:t.getCoordinates()}}(t);break;case"MultiLineString":n=function(t){return{type:"MultiLineString",coordinates:t.getCoordinates()}}(t);break;case"MultiPolygon":n=function(t,e){let i;e&&(i=e.rightHanded);return{type:"MultiPolygon",coordinates:t.getCoordinates(i)}}(t,e);break;case"GeometryCollection":n=function(t,e){e=Object.assign({},e),delete e.featureProjection;const i=t.getGeometriesArray().map((function(t){return Lu(t,e)}));return{type:"GeometryCollection",geometries:i}}(t,e);break;case"Circle":n={type:"GeometryCollection",geometries:[]};break;default:throw new Error("Unsupported geometry type: "+i)}return n}var ku=class extends Iu{constructor(t){t=t||{},super(),this.dataProjection=gn(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=gn(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let i=null;i="Feature"===t.type?t:{type:"Feature",geometry:t,properties:null};const n=Mu(i.geometry);if(this.featureClass===Zr)return Ru({geometry:n,id:i.id,properties:i.properties},e);const r=new Me;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&r.setGeometryName(i.geometry_name),r.setGeometry(Pu(n,e)),"id"in i&&r.setId(i.id),i.properties&&r.setProperties(i.properties,!0),r}readFeaturesFromObject(t,e){let i=null;if("FeatureCollection"===t.type){i=[];const n=t.features;for(let t=0,r=n.length;t=o.width)return null;const h=pi(s),u=Math.floor(o.height*((s[3]-n[1])/h));return u<0||u>=o.height?null:this.getImageData(o,l,u)}renderFrame(t,e){const i=this.image,n=i.getExtent(),r=i.getResolution(),[s,o]=Array.isArray(r)?r:[r,r],a=i.getPixelRatio(),l=t.layerStatesArray[t.layerIndex],h=t.pixelRatio,u=t.viewState,c=u.center,d=u.resolution,g=h*s/(d*a),p=h*o/(d*a);this.prepareContainer(t,e);const f=this.context.canvas.width,m=this.context.canvas.height,_=this.getRenderContext(t);let y=!1,x=!0;if(l.extent){const e=Mn(l.extent,u.projection);x=xi(e,t.extent),y=x&&!Ye(e,t.extent),y&&this.clipUnrotated(_,t,e)}const v=i.getImage(),w=Ne(this.tempTransform,f/2,m/2,g,p,0,a*(n[0]-c[0])/s,a*(c[1]-n[3])/o);this.renderedResolution=o*h/a;const b=v.width*w[0],S=v.height*w[3];if(this.getLayer().getSource().getInterpolate()||(_.imageSmoothingEnabled=!1),this.preRender(_,t),x&&b>=.5&&S>=.5){const t=w[4],e=w[5],i=l.opacity;1!==i&&(_.save(),_.globalAlpha=i),_.drawImage(v,0,0,+v.width,+v.height,t,e,b,S),1!==i&&_.restore()}return this.postRender(this.context,t),y&&_.restore(),_.imageSmoothingEnabled=!0,this.container}};var Ou=class extends Du{constructor(t){super(t)}createRenderer(){return new Au(this)}getData(t){return super.getData(t)}};const zu=4294967296,Gu=1/zu,Nu="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class ju{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,i=this.length){for(;this.pos>3,r=this.pos;this.type=7&i,t(n,e,this),this.pos===r&&this.skip(i)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*zu;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*zu;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let i,n;return n=e[this.pos++],i=127&n,n<128?i:(n=e[this.pos++],i|=(127&n)<<7,n<128?i:(n=e[this.pos++],i|=(127&n)<<14,n<128?i:(n=e[this.pos++],i|=(127&n)<<21,n<128?i:(n=e[this.pos],i|=(15&n)<<28,function(t,e,i){const n=i.buf;let r,s;if(s=n[i.pos++],r=(112&s)>>4,s<128)return Uu(t,r,e);if(s=n[i.pos++],r|=(127&s)<<3,s<128)return Uu(t,r,e);if(s=n[i.pos++],r|=(127&s)<<10,s<128)return Uu(t,r,e);if(s=n[i.pos++],r|=(127&s)<<17,s<128)return Uu(t,r,e);if(s=n[i.pos++],r|=(127&s)<<24,s<128)return Uu(t,r,e);if(s=n[i.pos++],r|=(1&s)<<31,s<128)return Uu(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(i,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Nu?Nu.decode(this.buf.subarray(e,t)):function(t,e,i){let n="",r=e;for(;r239?4:e>223?3:e>191?2:1;if(r+h>i)break;1===h?e<128&&(l=e):2===h?(s=t[r+1],128==(192&s)&&(l=(31&e)<<6|63&s,l<=127&&(l=null))):3===h?(s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(l=(15&e)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===h&&(s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&e)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,h=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=h}return n}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const i=this.readPackedEnd();for(;this.pos127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e268435455||t<0?function(t,e){let i,n;t>=0?(i=t%4294967296|0,n=t/4294967296|0):(i=~(-t%4294967296),n=~(-t/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos]=127&t}(i,0,e),function(t,e){const i=(7&t)<<4;if(e.buf[e.pos++]|=i|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const e=this.pos;this.pos=function(t,e,i){for(let n,r,s=0;s55295&&n<57344){if(!r){n>56319||s+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n<56320){t[i++]=239,t[i++]=191,t[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(t[i++]=239,t[i++]=191,t[i++]=189,r=null);n<128?t[i++]=n:(n<2048?t[i++]=n>>6|192:(n<65536?t[i++]=n>>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);const i=this.pos-e;i>=128&&$u(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e);for(let i=0;i=128&&$u(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(t,e,i){this.writeTag(t,2),this.writeRawMessage(e,i)}writePackedVarint(t,e){e.length&&this.writeMessage(t,Bu,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,Vu,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,qu,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,Wu,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,Xu,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,Yu,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,Zu,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,Ku,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,Hu,e)}writeBytesField(t,e){this.writeTag(t,2),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,5),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,5),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,1),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,1),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,0),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,0),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,2),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,5),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,1),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}}function Uu(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function $u(t,e,i){const n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(let e=i.pos-1;e>=t;e--)i.buf[e+n]=i.buf[e]}function Bu(t,e){for(let i=0;i>3)?i.readString():2===t?i.readFloat():3===t?i.readDouble():4===t?i.readVarint64():5===t?i.readVarint():6===t?i.readSVarint():7===t?i.readBoolean():null;e.values.push(n)}}function tc(t,e,i){if(1==t)e.id=i.readVarint();else if(2==t){const t=i.readVarint()+i.pos;for(;i.pos>3}if(o--,1===s||2===s)a+=t.readSVarint(),l+=t.readSVarint(),1===s&&h>u&&(n.push(h),u=h),i.push(a,l),h+=2;else{if(7!==s)throw new Error("Invalid command found in the PBF");h>u&&(i.push(i[u],i[u+1]),h+=2)}}h>u&&(n.push(h),u=h)}createFeature_(t,e,i){const n=e.type;if(0===n)return null;let r;const s=e.properties;let o;this.idProperty_?(o=s[this.idProperty_],delete s[this.idProperty_]):o=e.id,s[this.layerName_]=e.layer.name;const a=[],l=[];this.readRawGeometry_(t,e,a,l);const h=function(t,e){let i;1===t?i=1===e?"Point":"MultiPoint":2===t?i=1===e?"LineString":"MultiLineString":3===t&&(i="Polygon");return i}(n,l.length);if(this.featureClass===Zr)r=new this.featureClass(h,a,l,2,s,o),r.transform(i.dataProjection);else{let t;if("Polygon"==h){const e=jr(a,l);t=e.length>1?new Xr(a,"XY",e):new Ur(a,"XY",l)}else t="Point"===h?new Fr(a,"XY"):"LineString"===h?new Cr(a,"XY"):"MultiPoint"===h?new Mr(a,"XY"):"MultiLineString"===h?new Rr(a,"XY",l):null;r=new(0,this.featureClass),this.geometryName_&&r.setGeometryName(this.geometryName_);const e=Cu(t,!1,i);r.setGeometry(e),void 0!==o&&r.setId(o),r.setProperties(s,!0)}return r}getType(){return"arraybuffer"}readFeatures(t,e){const i=this.layers_,n=gn((e=this.adaptOptions(e)).dataProjection);n.setWorldExtent(e.extent),e.dataProjection=n;const r=new ju(t),s=r.readFields(Ju,{}),o=[];for(const t in s){if(i&&!i.includes(t))continue;const a=s[t],l=a?[0,0,a.extent,a.extent]:null;n.setExtent(l);for(let t=0,i=a.length;t=yi(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?yi(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?yi(this.targetProj_.getExtent()):null;const l=mi(i),h=_i(i),u=ui(i),c=hi(i),d=this.transformInv_(l),g=this.transformInv_(h),p=this.transformInv_(u),f=this.transformInv_(c),m=10+(s?Math.max(0,Math.ceil(Math.log2(li(i)/(s*s*256*256)))):0);if(this.addQuad_(l,h,u,c,d,g,p,f,m),this.wrapsXInSource_){let t=1/0;this.triangles_.forEach((function(e,i,n){t=Math.min(t,e.source[0][0],e.source[1][0],e.source[2][0])})),this.triangles_.forEach((e=>{if(Math.max(e.source[0][0],e.source[1][0],e.source[2][0])-t>this.sourceWorldWidth_/2){const i=[[e.source[0][0],e.source[0][1]],[e.source[1][0],e.source[1][1]],[e.source[2][0],e.source[2][1]]];i[0][0]-t>this.sourceWorldWidth_/2&&(i[0][0]-=this.sourceWorldWidth_),i[1][0]-t>this.sourceWorldWidth_/2&&(i[1][0]-=this.sourceWorldWidth_),i[2][0]-t>this.sourceWorldWidth_/2&&(i[2][0]-=this.sourceWorldWidth_);const n=Math.min(i[0][0],i[1][0],i[2][0]);Math.max(i[0][0],i[1][0],i[2][0])-n.5&&u<1;let g=!1;if(l>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){g=yi(Be([t,e,i,n]))/this.targetWorldWidth_>.25||g}!d&&this.sourceProj_.isGlobal()&&u&&(g=u>.25||g)}if(!g&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!xi(h,this.maxSourceExtent_))return;let p=0;if(!(g||isFinite(r[0])&&isFinite(r[1])&&isFinite(s[0])&&isFinite(s[1])&&isFinite(o[0])&&isFinite(o[1])&&isFinite(a[0])&&isFinite(a[1])))if(l>0)g=!0;else if(p=(isFinite(r[0])&&isFinite(r[1])?0:8)+(isFinite(s[0])&&isFinite(s[1])?0:4)+(isFinite(o[0])&&isFinite(o[1])?0:2)+(isFinite(a[0])&&isFinite(a[1])?0:1),1!=p&&2!=p&&4!=p&&8!=p)return;if(l>0){if(!g){const e=[(t[0]+i[0])/2,(t[1]+i[1])/2],n=this.transformInv_(e);let s;if(d){s=(b(r[0],c)+b(o[0],c))/2-b(n[0],c)}else s=(r[0]+o[0])/2-n[0];const a=(r[1]+o[1])/2-n[1];g=s*s+a*a>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const h=[(e[0]+i[0])/2,(e[1]+i[1])/2],u=this.transformInv_(h),c=[(n[0]+t[0])/2,(n[1]+t[1])/2],d=this.transformInv_(c);this.addQuad_(t,e,h,c,r,s,u,d,l-1),this.addQuad_(c,h,i,n,d,u,o,a,l-1)}else{const h=[(t[0]+e[0])/2,(t[1]+e[1])/2],u=this.transformInv_(h),c=[(i[0]+n[0])/2,(i[1]+n[1])/2],d=this.transformInv_(c);this.addQuad_(t,h,c,n,r,u,d,a,l-1),this.addQuad_(h,e,i,c,u,s,o,d,l-1)}return}}if(d){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}11&p||this.addTriangle_(t,i,n,r,o,a),14&p||this.addTriangle_(t,i,e,r,o,s),p&&(13&p||this.addTriangle_(e,n,t,s,a,r),7&p||this.addTriangle_(e,n,i,s,a,o))}calculateSourceExtent(){const t=[1/0,1/0,-1/0,-1/0];return this.triangles_.forEach((function(e,i,n){const r=e.source;ri(t,r[0]),ri(t,r[1]),ri(t,r[2])})),t}getTriangles(){return this.triangles_}};let rc;const sc=[];function oc(t,e,i,n,r){t.beginPath(),t.moveTo(0,0),t.lineTo(e,i),t.lineTo(n,r),t.closePath(),t.save(),t.clip(),t.fillRect(0,0,Math.max(e,n)+1,Math.max(i,r)),t.restore()}function ac(t,e){return Math.abs(t[4*e]-210)>2||Math.abs(t[4*e+3]-191.25)>2}function lc(t,e,i,n){const r=Sn(i,e,t);let s=pn(e,n,i);const o=e.getMetersPerUnit();void 0!==o&&(s*=o);const a=t.getMetersPerUnit();void 0!==a&&(s/=a);const l=t.getExtent();if(!l||qe(l,r)){const e=pn(t,s,r)/s;isFinite(e)&&e>0&&(s/=e)}return s}function hc(t,e,i,n){const r=ci(i);let s=lc(t,e,r,n);return(!isFinite(s)||s<=0)&&ai(i,(function(i){return s=lc(t,e,i,n),isFinite(s)&&s>0})),s}function uc(t,e,i,n,r,s,o,a,l,h,u,c,d,g){const p=q(Math.round(i*t),Math.round(i*e),sc);if(c||(p.imageSmoothingEnabled=!1),0===l.length)return p.canvas;function f(t){return Math.round(t*i)/i}p.scale(i,i),p.globalCompositeOperation="lighter";const m=[1/0,1/0,-1/0,-1/0];let _;l.forEach((function(t,e,i){ni(m,t.extent)}));const y=i/n,x=(c?1:1+Math.pow(2,-24))/y;if(!d||1!==l.length||0!==h){if(_=q(Math.round(yi(m)*y),Math.round(pi(m)*y),sc),c||(_.imageSmoothingEnabled=!1),r&&g){const t=(r[0]-m[0])*y,e=-(r[3]-m[3])*y,i=yi(r)*y,n=pi(r)*y;_.rect(t,e,i,n),_.clip()}l.forEach((function(t,e,i){if(t.image.width>0&&t.image.height>0){if(t.clipExtent){_.save();const e=(t.clipExtent[0]-m[0])*y,i=-(t.clipExtent[3]-m[3])*y,n=yi(t.clipExtent)*y,r=pi(t.clipExtent)*y;_.rect(c?e:Math.round(e),c?i:Math.round(i),c?n:Math.round(e+n)-Math.round(e),c?r:Math.round(i+r)-Math.round(i)),_.clip()}const e=(t.extent[0]-m[0])*y,i=-(t.extent[3]-m[3])*y,n=yi(t.extent)*y,r=pi(t.extent)*y;_.drawImage(t.image,h,h,t.image.width-2*h,t.image.height-2*h,c?e:Math.round(e),c?i:Math.round(i),c?n:Math.round(e+n)-Math.round(e),c?r:Math.round(i+r)-Math.round(i)),t.clipExtent&&_.restore()}}))}const v=mi(o);return a.getTriangles().forEach((function(t,e,i){const n=t.source,r=t.target;let o=n[0][0],a=n[0][1],h=n[1][0],u=n[1][1],d=n[2][0],g=n[2][1];const y=f((r[0][0]-v[0])/s),w=f(-(r[0][1]-v[1])/s),b=f((r[1][0]-v[0])/s),S=f(-(r[1][1]-v[1])/s),E=f((r[2][0]-v[0])/s),C=f(-(r[2][1]-v[1])/s),T=o,R=a;o=0,a=0,h-=T,u-=R,d-=T,g-=R;const P=function(t){const e=t.length;for(let i=0;ir&&(r=e,n=s)}if(0===r)return null;const s=t[n];t[n]=t[i],t[i]=s;for(let n=i+1;n=0;n--){i[n]=t[n][e]/t[n][n];for(let r=n-1;r>=0;r--)t[r][e]-=t[r][n]*i[n]}return i}([[h,u,0,0,b-y],[d,g,0,0,E-y],[0,0,h,u,S-w],[0,0,d,g,C-w]]);if(!P)return;if(p.save(),p.beginPath(),function(){if(void 0===rc){const t=q(6,6,sc);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",oc(t,4,5,4,0),oc(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;rc=ac(e,0)||ac(e,4)||ac(e,8),K(t),sc.push(t.canvas)}return rc}()||!c){p.moveTo(b,S);const t=4,e=y-b,i=w-S;for(let n=0;n{const i=this.sourceImage_.getState();i!=e.LOADED&&i!=e.ERROR||(this.unlistenSource_(),this.reproject_())})),this.sourceImage_.load())}}unlistenSource_(){Mt(this.sourceListenerKey_),this.sourceListenerKey_=null}};const gc=4,pc="imageloadstart",fc="imageloadend",mc="imageloaderror";class _c extends it{constructor(t,e){super(t),this.image=e}}function yc(t,e){t.getImage().src=e}function xc(t,e,i,n){const r=e/i,s=ci(t),o=R(yi(t)/r,gc),a=R(pi(t)/r,gc);return gi(s,r,0,[o+2*R((n-1)*o/2,gc),a+2*R((n-1)*a/2,gc)])}var vc=class extends fl{constructor(t){super({attributions:t.attributions,projection:t.projection,state:t.state,interpolate:void 0===t.interpolate||t.interpolate}),this.on,this.once,this.un,this.loader=t.loader||null,this.resolutions_=void 0!==t.resolutions?t.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=!!t.loader&&0===t.loader.length,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(t){this.resolutions_=t}findNearestResolution(t){const e=this.getResolutions();if(e){t=e[rt(e,t,0)]}return t}getImage(t,e,i,n){const r=this.getProjection();if(!r||!n||vn(r,n))return r&&(n=r),this.getImageInternal(t,e,i,n);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&vn(this.reprojectedImage_.getProjection(),n)&&this.reprojectedImage_.getResolution()==e&&ii(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new dc(r,n,t,e,i,((t,e,i)=>this.getImageInternal(t,e,i,r)),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(t,e,i,n){if(this.loader){const r=xc(t,e,i,1),s=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===n&&(this.wantedExtent_&&Ye(this.wantedExtent_,r)||Ye(this.image.getExtent(),r))&&(this.wantedResolution_&&cc(this.wantedResolution_)===s||cc(this.image.getResolution())===s)))return this.image;this.wantedProjection_=n,this.wantedExtent_=r,this.wantedResolution_=s,this.image=new Dt(r,s,i,this.loader),this.image.addEventListener(mt,this.handleImageChange.bind(this))}return this.image}handleImageChange(t){const i=t.target;let n;switch(i.getState()){case e.LOADING:this.loading=!0,n=pc;break;case e.LOADED:this.loading=!1,n=fc;break;case e.ERROR:this.loading=!1,n=mc;break;default:return}this.hasListener(n)&&this.dispatchEvent(new _c(n,i))}},wc="preload",bc="useInterimTilesOnError";var Sc=class extends Zs{constructor(t){t=t||{};const e=Object.assign({},t),i=t.cacheSize;delete t.cacheSize,delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(void 0!==t.preload?t.preload:0),this.setUseInterimTilesOnError(void 0===t.useInterimTilesOnError||t.useInterimTilesOnError)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(wc)}setPreload(t){this.set(wc,t)}getUseInterimTilesOnError(){return this.get(bc)}setUseInterimTilesOnError(t){this.set(bc,t)}getData(t){return super.getData(t)}};function Ec(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageBitmap?t:null}const Cc=new Error("disposed");let Tc=null;const Rc=[256,256];var Pc=class extends Il{constructor(t){const e=os.IDLE;super(t.tileCoord,e,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=Ec(this.data_);return t?[t.width,t.height]:Rc}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==os.IDLE&&this.state!==os.ERROR)return;this.state=os.LOADING,this.changed();const t=this;this.loader_().then((function(e){t.data_=e,t.state=os.LOADED,t.changed()})).catch((function(e){t.error_=e,t.state=os.ERROR,t.changed()}))}disposeInternal(){this.controller_&&(this.controller_.abort(Cc),this.controller_=null),super.disposeInternal()}};var Fc=class extends Pc{constructor(t){super({tileCoord:t.tileCoord,loader:()=>Promise.resolve(new Uint8ClampedArray(4)),interpolate:t.interpolate,transition:t.transition}),this.pixelRatio_=t.pixelRatio,this.gutter_=t.gutter,this.reprojData_=null,this.reprojError_=null,this.reprojSize_=void 0,this.sourceTileGrid_=t.sourceTileGrid,this.targetTileGrid_=t.targetTileGrid,this.wrappedTileCoord_=t.wrappedTileCoord||t.tileCoord,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0;const e=t.sourceProj,i=e.getExtent(),n=t.sourceTileGrid.getExtent();this.clipExtent_=e.canWrapX()?n?fi(i,n):i:n;const r=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),s=this.targetTileGrid_.getExtent();let o=this.sourceTileGrid_.getExtent();const a=s?fi(r,s):r;if(0===li(a))return void(this.state=os.EMPTY);i&&(o=o?fi(o,i):i);const l=this.targetTileGrid_.getResolution(this.wrappedTileCoord_[0]),h=t.targetProj,u=hc(e,h,a,l);if(!isFinite(u)||u<=0)return void(this.state=os.EMPTY);const c=void 0!==t.errorThreshold?t.errorThreshold:.5;if(this.triangulation_=new nc(e,h,a,o,u*c,l),0===this.triangulation_.getTriangles().length)return void(this.state=os.EMPTY);this.sourceZ_=this.sourceTileGrid_.getZForResolution(u);let d=this.triangulation_.calculateSourceExtent();if(o&&(e.canWrapX()?(d[1]=_(d[1],o[1],o[3]),d[3]=_(d[3],o[1],o[3])):d=fi(d,o)),li(d)){let n=0,r=0;e.canWrapX()&&(n=yi(i),r=Math.floor((d[0]-i[0])/n));Si(d.slice(),e,!0).forEach((e=>{const i=this.sourceTileGrid_.getTileRangeForExtentAndZ(e,this.sourceZ_),s=t.getTileFunction;for(let t=i.minX;t<=i.maxX;t++)for(let e=i.minY;e<=i.maxY;e++){const i=s(this.sourceZ_,t,e,this.pixelRatio_);if(i){const t=r*n;this.sourceTiles_.push({tile:i,offset:t})}}++r})),0===this.sourceTiles_.length&&(this.state=os.EMPTY)}else this.state=os.EMPTY}getSize(){return this.reprojSize_}getData(){return this.reprojData_}getError(){return this.reprojError_}reproject_(){const t=[];let e=!1;if(this.sourceTiles_.forEach((i=>{const n=i.tile;if(!n||n.getState()!==os.LOADED)return;const r=n.getSize(),s=this.gutter_;let o;const a=(l=n.getData())instanceof Uint8Array||l instanceof Uint8ClampedArray||l instanceof Float32Array||l instanceof DataView?l:null;var l;a?o=a:(e=!0,o=function(t){Tc||(Tc=q(t.width,t.height,void 0,{willReadFrequently:!0}));const e=Tc.canvas,i=t.width;e.width!==i&&(e.width=i);const n=t.height;return e.height!==n&&(e.height=n),Tc.clearRect(0,0,i,n),Tc.drawImage(t,0,0),Tc.getImageData(0,0,i,n).data}(Ec(n.getData())));const h=[r[0]+2*s,r[1]+2*s],u=o instanceof Float32Array,c=h[0]*h[1],d=u?Float32Array:Uint8ClampedArray,g=new d(o.buffer),p=d.BYTES_PER_ELEMENT,f=p*g.length/c,m=g.byteLength/h[1],_=Math.floor(m/p/h[0]),y=c*_;let x=g;if(g.length!==y){x=new d(y);let t=0,e=0;const i=h[0]*_;for(let n=0;n=0;--e){const i=[];for(let n=0,r=t.length;n{const i=e.getState();if(i!==os.IDLE&&i!==os.LOADING)return;t++;const n=Ft(e,mt,(()=>{const i=e.getState();i!=os.LOADED&&i!=os.ERROR&&i!=os.EMPTY||(Mt(n),t--,0===t&&(this.unlistenSources_(),this.reproject_()))}));this.sourcesListenerKeys_.push(n)})),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach((function({tile:t}){t.getState()==os.IDLE&&t.load()}))}unlistenSources_(){this.sourcesListenerKeys_.forEach(Mt),this.sourcesListenerKeys_=null}};var Ic=class extends Il{constructor(t,e,i,n,r,s,o,a,l,h,u,c){super(r,os.IDLE,c),this.renderEdges_=void 0!==u&&u,this.pixelRatio_=o,this.gutter_=a,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=n,this.wrappedTileCoord_=s||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const d=n.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let p=this.sourceTileGrid_.getExtent();const f=g?fi(d,g):d;if(0===li(f))return void(this.state=os.EMPTY);const m=t.getExtent();m&&(p=p?fi(p,m):m);const y=n.getResolution(this.wrappedTileCoord_[0]),x=hc(t,i,f,y);if(!isFinite(x)||x<=0)return void(this.state=os.EMPTY);const v=void 0!==h?h:.5;if(this.triangulation_=new nc(t,i,f,p,x*v,y),0===this.triangulation_.getTriangles().length)return void(this.state=os.EMPTY);this.sourceZ_=e.getZForResolution(x);let w=this.triangulation_.calculateSourceExtent();if(p&&(t.canWrapX()?(w[1]=_(w[1],p[1],p[3]),w[3]=_(w[3],p[1],p[3])):w=fi(w,p)),li(w)){let i=0,n=0;t.canWrapX()&&(i=yi(m),n=Math.floor((w[0]-m[0])/i));Si(w.slice(),t,!0).forEach((t=>{const r=e.getTileRangeForExtentAndZ(t,this.sourceZ_);for(let t=r.minX;t<=r.maxX;t++)for(let e=r.minY;e<=r.maxY;e++){const r=l(this.sourceZ_,t,e,o);if(r){const t=n*i;this.sourceTiles_.push({tile:r,offset:t})}}++n})),0===this.sourceTiles_.length&&(this.state=os.EMPTY)}else this.state=os.EMPTY}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach((e=>{const i=e.tile;if(i&&i.getState()==os.LOADED){const n=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);n[0]+=e.offset,n[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:n,clipExtent:r,image:i.getImage()})}})),this.sourceTiles_.length=0,0===t.length)this.state=os.ERROR;else{const e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),n="number"==typeof i?i:i[0],r="number"==typeof i?i:i[1],s=this.targetTileGrid_.getResolution(e),o=this.sourceTileGrid_.getResolution(this.sourceZ_),a=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=uc(n,r,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),s,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=os.LOADED}this.changed()}load(){if(this.state==os.IDLE){this.state=os.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach((({tile:e})=>{const i=e.getState();if(i==os.IDLE||i==os.LOADING){t++;const i=Ft(e,mt,(n=>{const r=e.getState();r!=os.LOADED&&r!=os.ERROR&&r!=os.EMPTY||(Mt(i),t--,0===t&&(this.unlistenSources_(),this.reproject_()))}));this.sourcesListenerKeys_.push(i)}})),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach((function({tile:t},e,i){t.getState()==os.IDLE&&t.load()}))}}unlistenSources_(){this.sourcesListenerKeys_.forEach(Mt),this.sourcesListenerKeys_=null}release(){this.canvas_&&(K(this.canvas_.getContext("2d")),sc.push(this.canvas_),this.canvas_=null),super.release()}};function Mc(t,e,i,n){return`${t},${su(e,i,n)}`}function Lc(t,e,i){if(!(i in t))return t[i]=new Set([e]),!0;const n=t[i],r=n.has(e);return r||n.add(e),!r}function kc(t,e,i){const n=t[i];return!!n&&n.delete(e)}function Dc(t,e){const i=t.layerStatesArray[t.layerIndex];i.extent&&(e=fi(e,Mn(i.extent,t.viewState.projection)));const n=i.layer.getRenderSource();if(!n.getWrapX()){const i=n.getTileGridForProjection(t.viewState.projection).getExtent();i&&(e=fi(e,i))}return e}var Ac=class extends za{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedRevision,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=[1/0,1/0,-1/0,-1/0],this.tempTileRange_=new cu(0,0,0,0),this.tempTileCoord_=ru(0,0,0);const i=void 0!==e.cacheSize?e.cacheSize:512;this.tileCache_=new nu(i),this.maxStaleKeys=.5*i}getTileCache(){return this.tileCache_}getOrCreateTile(t,e,i,n){const r=this.tileCache_,s=this.getLayer().getSource(),o=Mc(s.getKey(),t,e,i);let a;if(r.containsKey(o))a=r.get(o);else{if(a=s.getTile(t,e,i,n.pixelRatio,n.viewState.projection),!a)return null;r.set(o,a)}return a}getTile(t,e,i,n){const r=this.getOrCreateTile(t,e,i,n);return r||null}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),n=Oe(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!qe(r,n))return null;const s=e.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(s.projection),h=a.getTilePixelRatio(e.pixelRatio);for(let t=l.getZForResolution(s.resolution);t>=l.getMinZoom();--t){const i=l.getTileCoordForCoordAndZ(n,t),r=this.getTile(t,i[1],i[2],e);if(!r||r.getState()!==os.LOADED)continue;const u=l.getOrigin(t),c=o(l.getTileSize(t)),d=l.getResolution(t);let g;if(r instanceof Ml)g=r.getImage();else{if(!(r instanceof Pc))continue;if(g=Ec(r.getData()),!g)continue}const p=Math.floor(h*((n[0]-u[0])/d-i[1]*c[0])),f=Math.floor(h*((u[1]-n[1])/d-i[2]*c[1])),m=Math.round(h*a.getGutterForProjection(s.projection));return this.getImageData(g,p+m,f+m)}return null}prepareFrame(t){const e=this.getLayer().getSource();if(!e)return!1;const i=this.getLayer().getSource().getRevision();return this.renderedRevision_?this.renderedRevision_!==i&&(this.renderedRevision_=i,this.renderedSourceKey_===e.getKey()&&this.tileCache_.clear()):this.renderedRevision_=i,!0}enqueueTiles(t,e,i,n,s){const o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),u=r(l);u in t.wantedTiles||(t.wantedTiles[u]={});const c=t.wantedTiles[u],d=a.getMapInternal(),g=Math.max(i-s,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection));for(let r=i;r>=g;--r){const i=h.getTileRangeForExtentAndZ(e,r,this.tempTileRange_),s=h.getResolution(r);for(let e=i.minX;e<=i.maxX;++e)for(let o=i.minY;o<=i.maxY;++o){const i=this.getTile(r,e,o,t);if(!i)continue;if(!Lc(n,i,r))continue;const a=i.getKey();if(c[a]=!0,i.getState()===os.IDLE&&!t.tileQueue.isKeyQueued(a)){const n=ru(r,e,o,this.tempTileCoord_);t.tileQueue.enqueue([i,u,h.getTileCoordCenter(n),s])}}}}findStaleTile_(t,e){const i=this.tileCache_,n=t[0],s=t[1],o=t[2],a=this.getStaleKeys();for(let t=0;t0&&setTimeout((()=>{this.enqueueTiles(t,T,g-1,E,C-1)}),0);const R=r(this),P=t.time;for(const e of E[g]){const i=e.getState();if((e instanceof Ic||e instanceof Fc)&&i===os.EMPTY)continue;const n=e.tileCoord;if(i===os.LOADED){if(1===e.getAlpha(R,P)){e.endTransition(R);continue}}this.renderComplete=!1;if(this.findStaleTile_(n,E)){kc(E,e,g),t.animate=!0;continue}if(this.findAltTiles_(d,n,g+1,E))continue;const r=d.getMinZoom();for(let t=g-1;t>=r;--t){if(this.findAltTiles_(d,n,t,E))break}}const F=p/o*l/_,I=this.getRenderContext(t);Ne(this.tempTransform,y/2,x/2,F,F,0,-y/2,-x/2),i.extent&&this.clipUnrotated(I,t,v),u.getInterpolate()||(I.imageSmoothingEnabled=!1),this.preRender(I,t),this.renderedTiles.length=0;const M=Object.keys(E).map(Number);let L;M.sort(nt);const k=[],D=[];for(let e=M.length-1;e>=0;--e){const i=M[e],n=u.getTilePixelSize(i,l,s),r=d.getResolution(i)/p,o=n[0]*r*F,a=n[1]*r*F,h=d.getTileCoordForCoordAndZ(mi(S),i),c=d.getTileCoordExtent(h),g=Oe(this.tempTransform,[_*(c[0]-S[0])/p,_*(S[3]-c[3])/p]),f=_*u.getGutterForProjection(s);for(const e of E[i]){if(e.getState()!==os.LOADED)continue;const n=e.tileCoord,r=h[1]-n[1],s=Math.round(g[0]-(r-1)*o),l=h[2]-n[2],c=Math.round(g[1]-(l-1)*a),d=Math.round(g[0]-r*o),p=Math.round(g[1]-l*a),m=s-d,_=c-p,y=1===M.length;let x=!1;L=[d,p,d+m,p,d+m,p+_,d,p+_];for(let t=0,e=k.length;t{const i=r(u),n=e.wantedTiles[i],s=n?Object.keys(n).length:0;this.updateCacheSize(s),this.tileCache_.expireCache()})),this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,2*t)}drawTile(t,e,i,n,s,o,a,l){let h;if(t instanceof Pc){if(h=Ec(t.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(t);if(!h)return;const u=this.getRenderContext(e),c=r(this),d=e.layerStatesArray[e.layerIndex],g=d.opacity*(l?t.getAlpha(c,e.time):1),p=g!==u.globalAlpha;p&&(u.save(),u.globalAlpha=g),u.drawImage(h,a,a,h.width-2*a,h.height-2*a,i,n,s,o),p&&u.restore(),g!==d.opacity?e.animate=!0:l&&t.endTransition(c)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const n=r(e);n in t||(t[n]={}),t[n][i.getKey()]=!0}};var Oc=class extends Sc{constructor(t){super(t)}createRenderer(){return new Ac(this,{cacheSize:this.getCacheSize()})}};const zc=[0,0,0];var Gc=class{constructor(t){let e;if(this.minZoom=void 0!==t.minZoom?t.minZoom:0,this.resolutions_=t.resolutions,Te(function(t,e,i){const n=e||nt;return t.every((function(e,r){if(0===r)return!0;const s=n(t[r-1],e);return!(s>0||i&&0===s)}))}(this.resolutions_,((t,e)=>e-t),!0),"`resolutions` must be sorted in descending order"),!t.origins)for(let t=0,i=this.resolutions_.length-1;t{const n=new cu(Math.min(0,t[0]),Math.max(t[0]-1,-1),Math.min(0,t[1]),Math.max(t[1]-1,-1));if(i){const t=this.getTileRangeForExtentAndZ(i,e);n.minX=Math.max(t.minX,n.minX),n.maxX=Math.min(t.maxX,n.maxX),n.minY=Math.max(t.minY,n.minY),n.maxY=Math.min(t.maxY,n.maxY)}return n})):i&&this.calculateTileRanges_(i)}forEachTileCoord(t,e,i){const n=this.getTileRangeForExtentAndZ(t,e);for(let t=n.minX,r=n.maxX;t<=r;++t)for(let r=n.minY,s=n.maxY;r<=s;++r)i([e,t,r])}forEachTileCoordParentTileRange(t,e,i,n){let r,s,o,a=null,l=t[0]-1;for(2===this.zoomFactor_?(s=t[1],o=t[2]):a=this.getTileCoordExtent(t,n);l>=this.minZoom;){if(void 0!==s&&void 0!==o?(s=Math.floor(s/2),o=Math.floor(o/2),r=uu(s,s,o,o,i)):r=this.getTileRangeForExtentAndZ(a,l,i),e(l,r))return!0;--l}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]this.maxZoom||e0?n:Math.max(s/i[0],r/i[1]);const a=e+1,l=new Array(a);for(let t=0;ti||i>e.getMaxZoom())return!1;const s=e.getFullTileRange(i);return!s||s.containsXY(n,r)}(t,i)?t:null}clear(){this.tileCache.clear()}refresh(){this.clear(),super.refresh()}useTile(t,e,i,n){}},Kc="tileloadstart",Hc="tileloadend",Jc="tileloaderror";class Qc extends Zc{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===Qc.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,i=r(e),n=e.getState();let s;n==os.LOADING?(this.tileLoadingKeys_[i]=!0,s=Kc):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],s=n==os.ERROR?Jc:n==os.LOADED?Hc:void 0),null!=s&&this.dispatchEvent(new Yc(s,e))}setTileLoadFunction(t){this.tileCache.clear(),this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,this.tileCache.pruneExceptNewestZ(),void 0!==e?this.setKey(e):this.changed()}setUrl(t){const e=vu(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join("\n");this.generateTileUrlFunction_?this.setTileUrlFunction(bu(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}useTile(t,e,i){const n=su(t,e,i);this.tileCache.containsKey(n)&&this.tileCache.get(n)}}var td=Qc;function ed(t,e){t.getImage().src=e}var id=class extends td{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:ed,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:void 0===t.interpolate||t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=void 0!==t.crossOrigin?t.crossOrigin:null,this.tileClass=void 0!==t.tileClass?t.tileClass:Ml,this.tileCacheForProjection={},this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}canExpireCache(){if(this.tileCache.canExpireCache())return!0;for(const t in this.tileCacheForProjection)if(this.tileCacheForProjection[t].canExpireCache())return!0;return!1}expireCache(t,e){const i=this.getTileCacheForProjection(t);this.tileCache.expireCache(this.tileCache==i?e:{});for(const t in this.tileCacheForProjection){const n=this.tileCacheForProjection[t];n.expireCache(n==i?e:{})}}getGutterForProjection(t){return this.getProjection()&&t&&!vn(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||vn(e,t)))return this.tileGrid;const i=r(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=jc(t)),this.tileGridForProjection[i]}getTileCacheForProjection(t){const e=this.getProjection();if(!e||vn(e,t))return this.tileCache;const i=r(t);return i in this.tileCacheForProjection||(this.tileCacheForProjection[i]=new lu(this.tileCache.highWaterMark)),this.tileCacheForProjection[i]}createTile_(t,e,i,n,r,s){const o=[t,e,i],a=this.getTileCoordForTileUrlFunction(o,r),l=a?this.tileUrlFunction(a,n,r):void 0,h=new this.tileClass(o,void 0!==l?os.IDLE:os.EMPTY,void 0!==l?l:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return h.key=s,h.addEventListener(mt,this.handleTileChange.bind(this)),h}getTile(t,e,i,n,r){const s=this.getProjection();if(!s||!r||vn(s,r))return this.getTileInternal(t,e,i,n,s||r);const o=this.getTileCacheForProjection(r),a=[t,e,i];let l;const h=ou(a);o.containsKey(h)&&(l=o.get(h));const u=this.getKey();if(l&&l.key==u)return l;const c=this.getTileGridForProjection(s),d=this.getTileGridForProjection(r),g=this.getTileCoordForTileUrlFunction(a,r),p=new Ic(s,c,r,d,a,g,this.getTilePixelRatio(n),this.getGutter(),((t,e,i,n)=>this.getTileInternal(t,e,i,n,s)),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return p.key=u,l?o.replace(h,p):o.set(h,p),p}getTileInternal(t,e,i,n,r){const s=su(t,e,i),o=this.getKey();if(!this.tileCache.containsKey(s)){const a=this.createTile_(t,e,i,n,r,o);return this.tileCache.set(s,a),a}let a=this.tileCache.get(s);return a.key!=o&&(a=this.createTile_(t,e,i,n,r,o),this.tileCache.replace(s,a)),a}setRenderReprojectionEdges(t){if(this.renderReprojectionEdges_!=t){this.renderReprojectionEdges_=t;for(const t in this.tileCacheForProjection)this.tileCacheForProjection[t].clear();this.changed()}}setTileGridForProjection(t,e){const i=gn(t);if(i){const t=r(i);t in this.tileGridForProjection||(this.tileGridForProjection[t]=e)}}clear(){super.clear();for(const t in this.tileCacheForProjection)this.tileCacheForProjection[t].clear()}};var nd=class extends id{constructor(t){if(super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:gn("EPSG:3857"),reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.tileJSON_=null,this.tileSize_=t.tileSize,t.url)if(t.jsonp)!function(t,e,i,n){const s=document.createElement("script"),o="olc_"+r(e);function a(){delete window[o],s.parentNode.removeChild(s)}s.async=!0,s.src=t+(t.includes("?")?"&":"?")+(n||"callback")+"="+o;const l=setTimeout((function(){a(),i&&i()}),1e4);window[o]=function(t){clearTimeout(l),a(),e(t)},document.head.appendChild(s)}(t.url,this.handleTileJSONResponse.bind(this),this.handleTileJSONError.bind(this));else{const e=new XMLHttpRequest;e.addEventListener("load",this.onXHRLoad_.bind(this)),e.addEventListener("error",this.onXHRError_.bind(this)),e.open("GET",t.url),e.send()}else{if(!t.tileJSON)throw new Error("Either `url` or `tileJSON` options must be provided");this.handleTileJSONResponse(t.tileJSON)}}onXHRLoad_(t){const e=t.target;if(!e.status||e.status>=200&&e.status<300){let t;try{t=JSON.parse(e.responseText)}catch(t){return void this.handleTileJSONError()}this.handleTileJSONResponse(t)}else this.handleTileJSONError()}onXHRError_(t){this.handleTileJSONError()}getTileJSON(){return this.tileJSON_}handleTileJSONResponse(t){const e=gn("EPSG:4326"),i=this.getProjection();let n;if(void 0!==t.bounds){const r=wn(e,i);n=wi(t.bounds,r)}const r=Xc(i),s=t.minzoom||0,o=Bc({extent:r,maxZoom:t.maxzoom||22,minZoom:s,tileSize:this.tileSize_});if(this.tileGrid=o,this.tileUrlFunction=bu(t.tiles,o),t.attribution&&!this.getAttributions()){const e=void 0!==n?n:r;this.setAttributions((function(i){return xi(e,i.extent)?[t.attribution]:null}))}this.tileJSON_=t,this.setState("ready")}handleTileJSONError(){this.setState("error")}};const rd={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},sd={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};var od=class extends Ac{constructor(t,e){super(t,e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=[1,0,0,1,0,0],this.tileClipContexts_=null}drawTile(t,e,i,n,r,s,o,a){this.updateExecutorGroup_(t,e.pixelRatio,e.viewState.projection),this.tileImageNeedsRender_(t)&&this.renderTileImage_(t,e),super.drawTile(t,e,i,n,r,s,o,a)}getTile(t,e,i,n){const r=this.getOrCreateTile(t,e,i,n);if(!r)return null;const s=n.viewState.resolution,o=n.viewHints;return!!(o[Ps]||o[Fs])&&r.wantedResolution||(r.wantedResolution=s),r}prepareFrame(t){const e=this.getLayer().getRevision();return this.renderedLayerRevision_!==e&&(this.renderedLayerRevision_=e,this.renderedTiles.length=0),super.prepareFrame(t)}updateExecutorGroup_(t,e,i){const n=this.getLayer(),s=n.getRevision(),o=n.getRenderOrder()||null,a=t.wantedResolution,l=t.getReplayState(n);if(!l.dirty&&l.renderedResolution===a&&l.renderedRevision==s&&l.renderedRenderOrder==o)return;const h=n.getSource(),u=!!n.getDeclutter(),c=h.getTileGrid(),d=h.getTileGridForProjection(i).getTileCoordExtent(t.wrappedTileCoord),g=h.getSourceTiles(e,i,t),p=r(n);delete t.hitDetectionImageData[p],t.executorGroups[p]=[],l.dirty=!1;for(let i=0,r=g.length;i{const r=m?e.declutter[m].all().map((t=>t.value)):null;for(let e=0,s=n.length;e{const n=this.getLayer(),s=r(n),a=n.getSource(),l=this.renderedProjection,h=l.getExtent(),u=this.renderedResolution,c=a.getTileGridForProjection(l),d=Oe(this.renderedPixelToCoordinateTransform_,t.slice()),g=c.getTileCoordForCoordAndResolution(d,u);let p;for(let t=0,e=this.renderedTiles.length;t0)return void e([]);const f=mi(c.getTileCoordExtent(p.wrappedTileCoord)),m=[(d[0]-f[0])/u,(f[1]-d[1])/u],_=p.getSourceTiles().reduce((function(t,e){return t.concat(e.getFeatures())}),[]);let y=p.hitDetectionImageData[s];if(!y){const t=o(c.getTileSize(c.getZForResolution(u,a.zDirection))),e=this.renderedRotation_;y=il(t,[this.getRenderTransform(c.getTileCoordCenter(p.wrappedTileCoord),u,0,el,t[0]*el,t[1]*el,0)],_,n.getStyleFunction(),c.getTileCoordExtent(p.wrappedTileCoord),p.getReplayState(n).renderedResolution,e),p.hitDetectionImageData[s]=y}e(nl(m,_,y))}))}getFeaturesInExtent(t){const e=[],i=this.getTileCache();if(0===i.getCount())return e;const n=this.getLayer().getSource().tileGrid,r=n.getZForResolution(this.renderedResolution);return i.forEach((i=>{if(i.tileCoord[0]!==r||i.getState()!==os.LOADED)return;const s=i.getSourceTiles();for(let i=0,r=s.length;i=0;--e)n[e].execute(this.context,[this.context.canvas.width,this.context.canvas.height],this.getTileRenderTransform(i,t),t.viewState.rotation,o,Ka,s?t.declutter[s]:void 0)}i.globalAlpha=n}renderDeferredInternal(t){const e=this.renderedTiles.reduce(((t,e,i)=>(e.executorGroups[r(this.getLayer())].forEach((e=>t.push({executorGroup:e,index:i}))),t)),[]),i=e.map((({executorGroup:t})=>t.getDeferredZIndexContexts())),n={};for(let t=0,i=e.length;t{i.forEach(((i,n)=>{i[t]&&(i[t].forEach((t=>{const{executorGroup:i,index:r}=e[n],s=i.getRenderedContext(),o=s.globalAlpha;s.globalAlpha=this.renderedOpacity_;const a=this.tileClipContexts_[r];a&&a.draw(s),t.draw(s),a&&s.restore(),s.globalAlpha=o,t.clear()})),i[t].length=0)}))}))}getTileRenderTransform(t,e){const i=e.pixelRatio,n=e.viewState,r=n.center,s=n.resolution,o=n.rotation,a=e.size,l=Math.round(a[0]*i),h=Math.round(a[1]*i),u=this.getLayer().getSource().getTileGridForProjection(e.viewState.projection),c=t.tileCoord,d=u.getTileCoordExtent(t.wrappedTileCoord),g=u.getTileCoordExtent(c,this.tempExtent)[0]-d[0];return De(ze(this.inversePixelTransform.slice(),1/i,1/i),this.getRenderTransform(r,s,o,i,l,h,g))}postRender(t,e){const i=e.viewHints,n=!(i[Ps]||i[Fs]);this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice(),this.renderedRotation_=e.viewState.rotation,this.renderedOpacity_=e.layerStatesArray[e.layerIndex].opacity;const s=this.getLayer(),o=s.getRenderMode(),a=t.globalAlpha;t.globalAlpha=this.renderedOpacity_;const l=s.getDeclutter(),h=l?sd[o].filter((t=>!Ka.includes(t))):sd[o],u=e.viewState,c=u.rotation,d=s.getSource(),g=d.getTileGridForProjection(u.projection).getZForResolution(u.resolution,d.zDirection),p=this.renderedTiles,f=[],m=[],_=[];let y=!0;for(let i=p.length-1;i>=0;--i){const o=p[i];y=y&&!o.getReplayState(s).dirty;const a=o.executorGroups[r(s)].filter((t=>t.hasExecutors(h)));if(0===a.length)continue;const u=this.getTileRenderTransform(o,e),d=o.tileCoord[0];let x=!1;const v=a[0].getClipCoords(u);let w,b=t;if(v){w=new Da,b=w.getContext();for(let t=0,e=f.length;t{const n=function(t){const[e,i,n]=t.substring(t.lastIndexOf("/")+1,t.length).split(",").map(Number);return su(e,i,n)}(e),r=i.peek(n);if(r){const e=r.sourceTiles;for(let i=0,n=e.length;i{const r=this.tileUrlFunction(n,t,e),s=this.sourceTileCache_.containsKey(r)?this.sourceTileCache_.get(r):new this.tileClass(n,r?os.IDLE:os.EMPTY,r,this.format_,this.tileLoadFunction);i.sourceTiles.push(s);const o=s.getState();if(o{this.handleTileChange(e);const n=s.getState();if(n===os.LOADED||n===os.ERROR){const e=s.getKey();e in i.errorTileKeys?s.getState()===os.LOADED&&delete i.errorTileKeys[e]:i.loadingSourceTiles--,n===os.ERROR?i.errorTileKeys[e]=!0:s.removeEventListener(mt,t),0===i.loadingSourceTiles&&i.setState(pt(i.errorTileKeys)?os.LOADED:os.ERROR)}};s.addEventListener(mt,t),i.loadingSourceTiles++}o===os.IDLE&&(s.extent=l.getTileCoordExtent(n),s.projection=e,s.resolution=l.getResolution(n[0]),this.sourceTileCache_.set(r,s),s.load())})),i.loadingSourceTiles||i.setState(i.sourceTiles.some((t=>t.getState()===os.ERROR))?os.ERROR:os.LOADED)}return i.sourceTiles}getTile(t,e,i,n,r){const s=[t,e,i];let o=this.getTileCoordForTileUrlFunction(s,r);const a=this.getTileGrid().getExtent(),l=this.getTileGridForProjection(r);if(o&&a){const e=l.getTileCoordExtent(o);Ve(e,-l.getResolution(t),e),xi(a,e)||(o=null)}let h=!0;if(null!==o){const e=this.tileGrid,i=l.getResolution(t),s=e.getZForResolution(i,1),a=l.getTileCoordExtent(o);Ve(a,-i,a),e.forEachTileCoord(a,s,(t=>{h=h&&!this.tileUrlFunction(t,n,r)}))}const u=new gu(s,h?os.EMPTY:os.IDLE,o,this.getSourceTiles.bind(this,n,r));return u.key=this.getKey(),u}getTileGridForProjection(t){const e=t.getCode();let i=this.tileGrids_[e];if(!i){const t=this.tileGrid,n=t.getResolutions().slice(),r=n.map((function(e,i){return t.getOrigin(i)})),s=n.map((function(e,i){return t.getTileSize(i)})),o=Ms+1;for(let t=n.length;t255?255:t}function pd(t){return t<0?0:t>1?1:t}function fd(t){return"%"===t[t.length-1]?gd(parseFloat(t)/100*255):gd(parseInt(t))}function md(t){return"%"===t[t.length-1]?pd(parseFloat(t)/100):pd(parseFloat(t))}function _d(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{cd={}.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in dd)return dd[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var n=i.indexOf("("),r=i.indexOf(")");if(-1!==n&&r+1===i.length){var s=i.substr(0,n),o=i.substr(n+1,r-(n+1)).split(","),a=1;switch(s){case"rgba":if(4!==o.length)return null;a=md(o.pop());case"rgb":return 3!==o.length?null:[fd(o[0]),fd(o[1]),fd(o[2]),a];case"hsla":if(4!==o.length)return null;a=md(o.pop());case"hsl":if(3!==o.length)return null;var l=(parseFloat(o[0])%360+360)%360/360,h=md(o[1]),u=md(o[2]),c=u<=.5?u*(h+1):u+h-u*h,d=2*u-c;return[gd(255*_d(d,c,l+1/3)),gd(255*_d(d,c,l)),gd(255*_d(d,c,l-1/3)),a];default:return null}}return null}}catch(t){}class yd{constructor(t,e,i,n=1){this.r=t,this.g=e,this.b=i,this.a=n}static parse(t){if(!t)return;if(t instanceof yd)return t;if("string"!=typeof t)return;const e=cd(t);return e?new yd(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,n]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${n})`}toArray(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*i/n,n]}toArray01(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,i/n,n]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:i,a:n}=this;return[t,e,i,n]}}yd.black=new yd(0,0,0,1),yd.white=new yd(1,1,1,1),yd.transparent=new yd(0,0,0,0),yd.red=new yd(1,0,0,1),yd.blue=new yd(0,0,1,1);var xd=yd;function vd(t){return"object"==typeof t?["literal",t]:t}function wd(t,e){let i=t.stops;if(!i)return function(t,e){const i=["get",t.property];if(void 0===t.default)return"string"===e.type?["string",i]:i;if("enum"===e.type)return["match",i,Object.keys(e.values),i,t.default];{const n=["color"===e.type?"to-color":e.type,i,vd(t.default)];return"array"===e.type&&n.splice(1,0,e.value,e.length||null),n}}(t,e);const n=i&&"object"==typeof i[0][0],r=n||void 0!==t.property,s=n||!r;return i=i.map((t=>!r&&e.tokens&&"string"==typeof t[1]?[t[0],Pd(t[1])]:[t[0],vd(t[1])])),n?function(t,e,i){const n={},r={},s=[];for(let e=0;e3&&e===t[t.length-2]||(n&&2===t.length||t.push(e),t.push(i))}function Rd(t,e){return t.type?t.type:e.expression.interpolated?"exponential":"interval"}function Pd(t){const e=["concat"],i=/{([^{}]+)}/g;let n=0;for(let r=i.exec(t);null!==r;r=i.exec(t)){const s=t.slice(n,i.lastIndex-r[0].length);n=i.lastIndex,s.length>0&&e.push(s),e.push(["get",r[1]])}if(1===e.length)return t;if(n`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Wd=[kd,Dd,Ad,Od,zd,Ud,Gd,Bd(Nd),$d];function Xd(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Xd(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 Wd)if(!Xd(t,e))return null}return`Expected ${Vd(t)} but found ${Vd(e)} instead.`}function qd(t,e){return e.some((e=>e.kind===t.kind))}function Yd(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))}class Zd{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,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 Kd{constructor(t,e,i,n,r){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=n,this.textColor=r}}class Hd{constructor(t){this.sections=t}static fromString(t){return new Hd([new Kd(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 Hd?t:Hd.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(i)}return t}}class Jd{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Jd({name:t,available:!1}):null}serialize(){return["image",this.name]}}function Qd(t,e,i,n){if(!("number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255)){return`Invalid rgba value [${("number"==typeof n?[t,e,i,n]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}return void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,i,n].join(", ")}]: 'a' must be between 0 and 1.`}function tg(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 xd)return!0;if(t instanceof Zd)return!0;if(t instanceof Hd)return!0;if(t instanceof Jd)return!0;if(Array.isArray(t)){for(const e of t)if(!tg(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!tg(t[e]))return!1;return!0}return!1}function eg(t){if(null===t)return kd;if("string"==typeof t)return Ad;if("boolean"==typeof t)return Od;if("number"==typeof t)return Dd;if(t instanceof xd)return zd;if(t instanceof Zd)return jd;if(t instanceof Hd)return Ud;if(t instanceof Jd)return $d;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=eg(e);if(i){if(i===t)continue;i=Nd;break}i=t}return Bd(i||Nd,e)}return Gd}function ig(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof xd||t instanceof Hd||t instanceof Jd?t.toString():JSON.stringify(t)}class ng{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(!tg(t[1]))return e.error("invalid value");const i=t[1];let n=eg(i);const r=e.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new ng(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof xd?["rgba"].concat(this.value.toArray()):this.value instanceof Hd?this.value.serialize():this.value}}var rg=ng;var sg=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const og={string:Ad,number:Dd,boolean:Od,object:Gd};class ag{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 i,n=1;const r=t[0];if("array"===r){let r,s;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in og)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);r=og[i],n++}else r=Nd;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);s=t[2],n++}i=Bd(r,s)}else i=og[r];const s=[];for(;nt.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n)}}return e.concat(this.args.map((t=>t.serialize())))}}var lg=ag;class hg{constructor(t){this.type=Ud,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const n=[];let r=!1;for(let i=1;i<=t.length-1;++i){const s=t[i];if(r&&"object"==typeof s&&!Array.isArray(s)){r=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Dd),!t))return null;let i=null;if(s["text-font"]&&(i=e.parse(s["text-font"],1,Bd(Ad)),!i))return null;let o=null;if(s["text-color"]&&(o=e.parse(s["text-color"],1,zd),!o))return null;const a=n[n.length-1];a.scale=t,a.font=i,a.textColor=o}else{const s=e.parse(t[i],1,Nd);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,n.push({content:s,scale:null,font:null,textColor:null})}}return new hg(n)}evaluate(t){return new Hd(this.sections.map((e=>{const i=e.content.evaluate(t);return eg(i)===$d?new Kd("",i,null,null,null):new Kd(ig(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class ug{constructor(t){this.type=$d,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Ad);return i?new ug(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Jd.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const cg={"to-boolean":Od,"to-color":zd,"to-number":Dd,"to-string":Ad};class dg{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 i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const n=cg[i],r=[];for(let i=1;i4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Qd(e[0],e[1],e[2],e[3]),!i))return new xd(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new sg(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new sg(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Hd.fromString(ig(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Jd.fromString(ig(this.args[0].evaluate(t))):ig(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new hg([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new ug(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}var gg=dg;const pg=["Unknown","Point","LineString","Polygon"];var fg=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?pg[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||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord,r=i*e-t[0],s=n*e-t[1];return this.featureDistanceData.bearing[0]*r+this.featureDistanceData.bearing[1]*s}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=xd.parse(t)),e}};class mg{constructor(t,e,i,n){this.name=t,this.type=e,this._evaluate=i,this.args=n}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],n=mg.definitions[i];if(!n)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,o=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[n,s]of o){a=new Wg(e.registry,e.path,null,e.scope);const o=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(Vd).join(", ")})`:`(${Vd(e.type)}...)`;var e})).join(" | "),n=[];for(let i=1;i=e[2])&&(!(t[1]<=e[1])&&!(t[3]>=e[3])))}function bg(t,e){const i=(180+t[0])/360;const n=(r=t[1],(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360);var r;const s=Math.pow(2,e.z);return[Math.round(i*s*xg),Math.round(n*s*xg)]}function Sg(t,e,i){const n=t[0]-e[0],r=t[1]-e[1],s=t[0]-i[0],o=t[1]-i[1];return n*o-s*r==0&&n*s<=0&&r*o<=0}function Eg(t,e,i){return e[1]>t[1]!=i[1]>t[1]&&t[0]<(i[0]-e[0])*(t[1]-e[1])/(i[1]-e[1])+e[0]}function Cg(t,e){let i=!1;for(let n=0,r=e.length;n0&&c<0||u<0&&c>0}function Pg(t,e,i,n){const r=[e[0]-t[0],e[1]-t[1]],s=[n[0]-i[0],n[1]-i[1]];return 0!=(o=s)[0]*(a=r)[1]-o[1]*a[0]&&!(!Rg(t,e,i,n)||!Rg(i,n,t,e));var o,a}function Fg(t,e,i){for(const n of i)for(let i=0;ii[2]){const e=.5*n;let r=t[0]-i[0]>e?-n:i[0]-t[0]>e?n:0;0===r&&(r=t[0]-i[2]>e?-n:i[2]-t[0]>e?n:0),t[0]+=r}vg(e,t)}function Ag(t,e,i,n){const r=Math.pow(2,n.z)*xg,s=[n.x*xg,n.y*xg],o=[];if(!t)return o;for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];Dg(n,e,i,r),o.push(n)}return o}function Og(t,e,i,n){const r=Math.pow(2,n.z)*xg,s=[n.x*xg,n.y*xg],o=[];if(!t)return o;for(const i of t){const t=[];for(const n of i){const i=[n.x+s[0],n.y+s[1]];vg(e,i),t.push(i)}o.push(t)}if(e[2]-e[0]<=r/2){!function(t){t[0]=t[1]=1/0,t[2]=t[3]=-1/0}(e);for(const t of o)for(const n of t)Dg(n,e,i,r)}return o}class zg{constructor(t,e){this.type=Od,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(tg(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t{e&&!Ng(t)&&(e=!1)})),e}function jg(t){if(t instanceof _g&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!jg(t)&&(e=!1)})),e}function Ug(t,e){if(t instanceof _g&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Ug(t,e)&&(i=!1)})),i}class $g{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new $g(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var Bg=$g;class Vg{constructor(t,e=[],i,n=new Ld,r=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i}parse(t,e,i,n,r={}){return e?this.concat(e,i,n)._parse(t,r):this._parse(t,r)}_parse(t,e){function i(t,e,i){return"assert"===i?new lg(e,[t]):"coerce"===i?new gg(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 r=this.registry[n];if(r){let n=r.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,r=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==r.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(t,r))return null}else n=i(n,t,e.typeAnnotation||"coerce");else n=i(n,t,e.typeAnnotation||"assert")}if(!(n instanceof rg)&&"resolvedImage"!==n.type.kind&&Xg(n)){const t=new fg;try{n=new rg(n.type,n.evaluate(t))}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 void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const n="number"==typeof t?this.path.concat(t):this.path,r=i?this.scope.concat(i):this.scope;return new Vg(this.registry,n,e||null,r,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Id(i,t))}checkSubtype(t,e){const i=Xd(t,e);return i&&this.error(i),i}}var Wg=Vg;function Xg(t){if(t instanceof Bg)return Xg(t.boundExpression);if(t instanceof _g&&"error"===t.name)return!1;if(t instanceof yg)return!1;if(t instanceof Gg)return!1;const e=t instanceof gg||t instanceof lg;let i=!0;return t.eachChild((t=>{i=e?i&&Xg(t):i&&t instanceof rg})),!!i&&(Ng(t)&&Ug(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"]))}function qg(t,e){const i=t.length-1;let n,r,s=0,o=i,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),n=t[a],r=t[a+1],n<=e){if(a===i||ee))throw new sg("Input is not a number.");o=a-1}return 0}class Yg{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)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 i=e.parse(t[1],1,Dd);if(!i)return null;const n=[];let r=null;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);for(let i=1;i=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const h=e.parse(o,l,r);if(!h)return null;r=r||h.type,n.push([s,h])}return new Yg(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return i[0].evaluate(t);const r=e.length;if(n>=e[r-1])return i[r-1].evaluate(t);return i[qg(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}var Zg=Yg,Kg=Hg;function Hg(t,e,i,n){this.cx=3*t,this.bx=3*(i-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=n,this.p2x=i,this.p2y=n}Hg.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},Hg.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},Hg.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},Hg.prototype.solveCurveX=function(t,e){var i,n,r,s,o;for(void 0===e&&(e=1e-6),r=t,o=0;o<8;o++){if(s=this.sampleCurveX(r)-t,Math.abs(s)(n=1))return n;for(;is?i=r:n=r,r=.5*(n-i)+i}return r},Hg.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var Jg=ud(Kg);function Qg(t,e,i){return t*(1-i)+e*i}var tp=Object.freeze({__proto__:null,number:Qg,color:function(t,e,i){return new xd(Qg(t.r,e.r,i),Qg(t.g,e.g,i),Qg(t.b,e.b,i),Qg(t.a,e.a,i))},array:function(t,e,i){return t.map(((t,n)=>Qg(t,e[n],i)))}});const ep=.95047,ip=1,np=1.08883,rp=4/29,sp=6/29,op=3*sp*sp,ap=sp*sp*sp,lp=Math.PI/180,hp=180/Math.PI;function up(t){return t>ap?Math.pow(t,1/3):t/op+rp}function cp(t){return t>sp?t*t*t:op*(t-rp)}function dp(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function gp(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function pp(t){const e=gp(t.r),i=gp(t.g),n=gp(t.b),r=up((.4124564*e+.3575761*i+.1804375*n)/ep),s=up((.2126729*e+.7151522*i+.072175*n)/ip);return{l:116*s-16,a:500*(r-s),b:200*(s-up((.0193339*e+.119192*i+.9503041*n)/np)),alpha:t.a}}function fp(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=ip*cp(e),i=ep*cp(i),n=np*cp(n),new xd(dp(3.2404542*i-1.5371385*e-.4985314*n),dp(-.969266*i+1.8760108*e+.041556*n),dp(.0556434*i-.2040259*e+1.0572252*n),t.alpha)}function mp(t,e,i){const n=e-t;return t+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const _p={forward:pp,reverse:fp,interpolate:function(t,e,i){return{l:Qg(t.l,e.l,i),a:Qg(t.a,e.a,i),b:Qg(t.b,e.b,i),alpha:Qg(t.alpha,e.alpha,i)}}},yp={forward:function(t){const{l:e,a:i,b:n}=pp(t),r=Math.atan2(n,i)*hp;return{h:r<0?r+360:r,c:Math.sqrt(i*i+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*lp,i=t.c;return fp({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:mp(t.h,e.h,i),c:Qg(t.c,e.c,i),l:Qg(t.l,e.l,i),alpha:Qg(t.alpha,e.alpha,i)}}};class xp{constructor(t,e,i,n,r){this.type=t,this.operator=e,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,n){let r=0;if("exponential"===t.name)r=vp(e,t.base,i,n);else if("linear"===t.name)r=vp(e,1,i,n);else if("cubic-bezier"===t.name){const s=t.controlPoints;r=new Jg(s[0],s[1],s[2],s[3]).solve(vp(e,1,i,n))}return r}static parse(t,e){let[i,n,r,...s]=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(r=e.parse(r,2,Dd),!r)return null;const o=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=zd:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const h=e.parse(n,l,a);if(!h)return null;a=a||h.type,o.push([i,h])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new xp(a,i,n,r,o):e.error(`Type ${Vd(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return i[0].evaluate(t);const r=e.length;if(n>=e[r-1])return i[r-1].evaluate(t);const s=qg(e,n),o=e[s],a=e[s+1],l=xp.interpolationFactor(this.interpolation,n,o,a),h=i[s].evaluate(t),u=i[s+1].evaluate(t);return"interpolate"===this.operator?tp[this.type.kind.toLowerCase()](h,u,l):"interpolate-hcl"===this.operator?yp.reverse(yp.interpolate(yp.forward(h),yp.forward(u),l)):_p.reverse(_p.interpolate(_p.forward(h),_p.forward(u),l))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tXd(n,t.type)));return new bp(s?Nd:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof Jd&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Sp=bp;class Ep{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 i=[];for(let n=1;n=i.length)throw new sg(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new sg(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Rp=Tp;class Pp{constructor(t,e){this.type=Od,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 i=e.parse(t[1],1,Nd),n=e.parse(t[2],2,Nd);return i&&n?qd(i.type,[Od,Ad,Dd,kd,Nd])?new Pp(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Vd(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!Yd(e,["boolean","string","number","null"]))throw new sg(`Expected first argument to be of type boolean, string, number or null, but found ${Vd(eg(e))} instead.`);if(!Yd(i,["string","array"]))throw new sg(`Expected second argument to be of type array or string, but found ${Vd(eg(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Fp=Pp;class Ip{constructor(t,e,i){this.type=Dd,this.needle=t,this.haystack=e,this.fromIndex=i}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 i=e.parse(t[1],1,Nd),n=e.parse(t[2],2,Nd);if(!i||!n)return null;if(!qd(i.type,[Od,Ad,Dd,kd,Nd]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Vd(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Dd);return r?new Ip(i,n,r):null}return new Ip(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Yd(e,["boolean","string","number","null"]))throw new sg(`Expected first argument to be of type boolean, string, number or null, but found ${Vd(eg(e))} instead.`);if(!Yd(i,["string","array"]))throw new sg(`Expected second argument to be of type array or string, but found ${Vd(eg(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Mp=Ip;class Lp{constructor(t,e,i,n,r,s){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=s}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 i,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const r={},s=[];for(let o=2;oNumber.MAX_SAFE_INTEGER)return h.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return h.error("Numeric branch labels must be integer values.");if(i){if(h.checkSubtype(i,eg(t)))return null}else i=eg(t);if(void 0!==r[String(t)])return h.error("Branch labels must be unique.");r[String(t)]=s.length}const u=e.parse(l,o,n);if(!u)return null;n=n||u.type,s.push(u)}const o=e.parse(t[1],1,Nd);if(!o)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==o.type.kind&&e.concat(1).checkSubtype(i,o.type)?null:new Lp(i,n,o,r,s,a):null}evaluate(t){const e=this.input.evaluate(t);return(eg(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)1===n.length?t.push(r(n[0])):t.push(n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}var kp=Lp;class Dp{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}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 i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const n=[];for(let r=1;re.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Ap=Dp;class Op{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,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 i=e.parse(t[1],1,Nd),n=e.parse(t[2],2,Dd);if(!i||!n)return null;if(!qd(i.type,[Bd(Nd),Ad,Nd]))return e.error(`Expected first argument to be of type array or string, but found ${Vd(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,Dd);return r?new Op(i.type,i,n,r):null}return new Op(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!Yd(e,["string","array"]))throw new sg(`Expected first argument to be of type array or string, but found ${Vd(eg(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var zp=Op;function Gp(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 Np(t,e,i,n){return 0===n.compare(e,i)}function jp(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=Od,this.lhs=t,this.rhs=e,this.collator=i,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 i=t[0];let s=e.parse(t[1],1,Nd);if(!s)return null;if(!Gp(i,s.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Vd(s.type)}'.`);let o=e.parse(t[2],2,Nd);if(!o)return null;if(!Gp(i,o.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Vd(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${Vd(s.type)}' and '${Vd(o.type)}'.`);n&&("value"===s.type.kind&&"value"!==o.type.kind?s=new lg(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new lg(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,jd),!a)return null}return new r(s,o,a)}evaluate(r){const s=this.lhs.evaluate(r),o=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=eg(s),i=eg(o);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new sg(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=eg(s),i=eg(o);if("string"!==t.kind||"string"!==i.kind)return e(r,s,o)}return this.collator?i(r,s,o,this.collator.evaluate(r)):e(r,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const Up=jp("==",(function(t,e,i){return e===i}),Np),$p=jp("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!Np(0,e,i,n)})),Bp=jp("<",(function(t,e,i){return e",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),Wp=jp("<=",(function(t,e,i){return e<=i}),(function(t,e,i,n){return n.compare(e,i)<=0})),Xp=jp(">=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class qp{constructor(t,e,i,n,r,s){this.type=Ad,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=s}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Dd);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parse(n.locale,1,Ad),!r))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,Ad),!s))return null;let o=null;if(n.unit&&(o=e.parse(n.unit,1,Ad),!o))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Dd),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parse(n["max-fraction-digits"],1,Dd),!l)?null:new qp(i,r,s,o,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Yp{constructor(t){this.type=Dd,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Vd(i.type)} instead.`):new Yp(i):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 sg(`Expected value to be of type string or array, but found ${Vd(eg(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const Zp={"==":Up,"!=":$p,">":Vp,"<":Bp,">=":Xp,"<=":Wp,array:lg,at:Rp,boolean:lg,case:Ap,coalesce:Sp,collator:yg,format:hg,image:ug,in:Fp,"index-of":Mp,interpolate:wp,"interpolate-hcl":wp,"interpolate-lab":wp,length:Yp,let:Cp,literal:rg,match:kp,number:lg,"number-format":qp,object:lg,slice:zp,step:Zg,string:lg,"to-boolean":gg,"to-color":gg,"to-number":gg,"to-string":gg,var:Bg,within:Gg};function Kp(t,[e,i,n,r]){e=e.evaluate(t),i=i.evaluate(t),n=n.evaluate(t);const s=r?r.evaluate(t):1,o=Qd(e,i,n,s);if(o)throw new sg(o);return new xd(e/255*s,i/255*s,n/255*s,s)}function Hp(t,e){return t in e}function Jp(t,e){const i=e[t];return void 0===i?null:i}function Qp(t){return{type:t}}_g.register(Zp,{error:[{kind:"error"},[Ad],(t,[e])=>{throw new sg(e.evaluate(t))}],typeof:[Ad,[Nd],(t,[e])=>Vd(eg(e.evaluate(t)))],"to-rgba":[Bd(Dd,4),[zd],(t,[e])=>e.evaluate(t).toArray()],rgb:[zd,[Dd,Dd,Dd],Kp],rgba:[zd,[Dd,Dd,Dd,Dd],Kp],has:{type:Od,overloads:[[[Ad],(t,[e])=>Hp(e.evaluate(t),t.properties())],[[Ad,Gd],(t,[e,i])=>Hp(e.evaluate(t),i.evaluate(t))]]},get:{type:Nd,overloads:[[[Ad],(t,[e])=>Jp(e.evaluate(t),t.properties())],[[Ad,Gd],(t,[e,i])=>Jp(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Nd,[Ad],(t,[e])=>Jp(e.evaluate(t),t.featureState||{})],properties:[Gd,[],t=>t.properties()],"geometry-type":[Ad,[],t=>t.geometryType()],id:[Nd,[],t=>t.id()],zoom:[Dd,[],t=>t.globals.zoom],pitch:[Dd,[],t=>t.globals.pitch||0],"distance-from-center":[Dd,[],t=>t.distanceFromCenter()],"heatmap-density":[Dd,[],t=>t.globals.heatmapDensity||0],"line-progress":[Dd,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[Dd,[],t=>t.globals.skyRadialProgress||0],accumulated:[Nd,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Dd,Qp(Dd),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[Dd,Qp(Dd),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:Dd,overloads:[[[Dd,Dd],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Dd],(t,[e])=>-e.evaluate(t)]]},"/":[Dd,[Dd,Dd],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Dd,[Dd,Dd],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Dd,[],()=>Math.LN2],pi:[Dd,[],()=>Math.PI],e:[Dd,[],()=>Math.E],"^":[Dd,[Dd,Dd],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Dd,[Dd],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Dd,[Dd],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Dd,[Dd],(t,[e])=>Math.log(e.evaluate(t))],log2:[Dd,[Dd],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Dd,[Dd],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Dd,[Dd],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Dd,[Dd],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Dd,[Dd],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Dd,[Dd],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Dd,[Dd],(t,[e])=>Math.atan(e.evaluate(t))],min:[Dd,Qp(Dd),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Dd,Qp(Dd),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Dd,[Dd],(t,[e])=>Math.abs(e.evaluate(t))],round:[Dd,[Dd],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Dd,[Dd],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Dd,[Dd],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Od,[Ad,Nd],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Od,[Nd],(t,[e])=>t.id()===e.value],"filter-type-==":[Od,[Ad],(t,[e])=>t.geometryType()===e.value],"filter-<":[Od,[Ad,Nd],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[Od,[Ad,Nd],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Od,[Nd],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-<=":[Od,[Ad,Nd],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[Od,[Nd],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<=n}],"filter->=":[Od,[Ad,Nd],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Od,[Nd],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Od,[Nd],(t,[e])=>e.value in t.properties()],"filter-has-id":[Od,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Od,[Bd(Ad)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Od,[Bd(Nd)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Od,[Ad,Bd(Nd)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Od,[Ad,Bd(Nd)],(t,[e,i])=>function(t,e,i,n){for(;i<=n;){const r=i+n>>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Od,overloads:[[[Od,Od],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Qp(Od),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Od,overloads:[[[Od,Od],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Qp(Od),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Od,[Od],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Od,[Ad],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Ad,[Ad],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Ad,[Ad],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Ad,Qp(Nd),(t,e)=>e.map((e=>ig(e.evaluate(t)))).join("")],"resolved-locale":[Ad,[jd],(t,[e])=>e.evaluate(t).resolvedLocale()]});var tf=Zp;function ef(t){return{result:"success",value:t}}function nf(t){return{result:"error",value:t}}function rf(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}class sf{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new fg,this._defaultValue=e?function(t){return"color"===t.type&&(rf(t.default)||Array.isArray(t.default))?new xd(0,0,0,0):"color"===t.type?xd.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,n,r,s,o,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=s,this._evaluator.featureTileCoord=o||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,n,r,s,o,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=s||null,this._evaluator.featureTileCoord=o||null,this._evaluator.featureDistanceData=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 sg(`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 of(t,e){const i=new Wg(tf,[],e?function(t){const e={color:zd,string:Ad,number:Dd,enum:Ad,boolean:Od,formatted:Ud,resolvedImage:$d};if("array"===t.type)return Bd(e[t.value]||Nd,t.length);return e[t.type]}(e):void 0),n=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?ef(new sf(n,e)):nf(i.errors)}class af{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!jg(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,s)}evaluate(t,e,i,n,r,s){return this._styleExpression.evaluate(t,e,i,n,r,s)}}class lf{constructor(t,e,i,n){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!jg(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,s)}evaluate(t,e,i,n,r,s){return this._styleExpression.evaluate(t,e,i,n,r,s)}interpolationFactor(t,e,i){return this.interpolationType?wp.interpolationFactor(this.interpolationType,t,e,i):0}}function hf(t,e){if("error"===(t=of(t,e)).result)return t;const i=t.value.expression,n=Ng(i);if(!n&&!function(t){return"data-driven"===t["property-type"]}(e))return nf([new Id("","data expressions not supported")]);const r=Ug(i,["zoom","pitch","distance-from-center"]);if(!r&&!function(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}(e))return nf([new Id("","zoom expressions not supported")]);const s=uf(i);if(!s&&!r)return nf([new Id("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(s instanceof Id)return nf([s]);if(s instanceof wp&&!function(t){return!!t.expression&&t.expression.interpolated}(e))return nf([new Id("",'"interpolate" expressions cannot be used with this property')]);if(!s)return ef(new af(n?"constant":"source",t.value));const o=s instanceof wp?s.interpolation:void 0;return ef(new lf(n?"camera":"composite",t.value,s.labels,o))}function uf(t){let e=null;if(t instanceof Cp)e=uf(t.result);else if(t instanceof Sp){for(const i of t.args)if(e=uf(i),e)break}else(t instanceof Zg||t instanceof wp)&&t.input instanceof _g&&"zoom"===t.input.name&&(e=t);return e instanceof Id||t.eachChild((t=>{const i=uf(t);i instanceof Id?e=i:!e&&i?e=new Id("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new Id("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function cf(t){if(Array.isArray(t))return t.map(cf);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=cf(t[i]);return e}return function(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}(t)}var df={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},terrain:{type:"terrain"},fog:{type:"fog"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},projection:{type:"projection"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{},sky:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_sky:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"},"fill-extrusion-edge-radius":{type:"number",private:!0,default:0,minimum:0,maximum:1,"property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_symbol:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature","pitch","distance-from-center"]}},filter_fill:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},filter_line:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},filter_circle:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},"filter_fill-extrusion":{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},filter_heatmap:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},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},expression_name:{type:"enum",values:{let:{group:"Variable binding"},var:{group:"Variable binding"},literal:{group:"Types"},array:{group:"Types"},at:{group:"Lookup"},in:{group:"Lookup"},"index-of":{group:"Lookup"},slice:{group:"Lookup"},case:{group:"Decision"},match:{group:"Decision"},coalesce:{group:"Decision"},step:{group:"Ramps, scales, curves"},interpolate:{group:"Ramps, scales, curves"},"interpolate-hcl":{group:"Ramps, scales, curves"},"interpolate-lab":{group:"Ramps, scales, curves"},ln2:{group:"Math"},pi:{group:"Math"},e:{group:"Math"},typeof:{group:"Types"},string:{group:"Types"},number:{group:"Types"},boolean:{group:"Types"},object:{group:"Types"},collator:{group:"Types"},format:{group:"Types"},image:{group:"Types"},"number-format":{group:"Types"},"to-string":{group:"Types"},"to-number":{group:"Types"},"to-boolean":{group:"Types"},"to-rgba":{group:"Color"},"to-color":{group:"Types"},rgb:{group:"Color"},rgba:{group:"Color"},get:{group:"Lookup"},has:{group:"Lookup"},length:{group:"Lookup"},properties:{group:"Feature data"},"feature-state":{group:"Feature data"},"geometry-type":{group:"Feature data"},id:{group:"Feature data"},zoom:{group:"Camera"},pitch:{group:"Camera"},"distance-from-center":{group:"Camera"},"heatmap-density":{group:"Heatmap"},"line-progress":{group:"Feature data"},"sky-radial-progress":{group:"sky"},accumulated:{group:"Feature data"},"+":{group:"Math"},"*":{group:"Math"},"-":{group:"Math"},"/":{group:"Math"},"%":{group:"Math"},"^":{group:"Math"},sqrt:{group:"Math"},log10:{group:"Math"},ln:{group:"Math"},log2:{group:"Math"},sin:{group:"Math"},cos:{group:"Math"},tan:{group:"Math"},asin:{group:"Math"},acos:{group:"Math"},atan:{group:"Math"},min:{group:"Math"},max:{group:"Math"},round:{group:"Math"},abs:{group:"Math"},ceil:{group:"Math"},floor:{group:"Math"},distance:{group:"Math"},"==":{group:"Decision"},"!=":{group:"Decision"},">":{group:"Decision"},"<":{group:"Decision"},">=":{group:"Decision"},"<=":{group:"Decision"},all:{group:"Decision"},any:{group:"Decision"},"!":{group:"Decision"},within:{group:"Decision"},"is-supported-script":{group:"String"},upcase:{group:"String"},downcase:{group:"String"},concat:{group:"String"},"resolved-locale":{group:"String"}}},fog:{range:{type:"array",default:[.5,10],minimum:-20,maximum:20,length:2,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},"high-color":{type:"color","property-type":"data-constant",default:"#245cdf",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"space-color":{type:"color","property-type":"data-constant",default:["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-blend":{type:"number","property-type":"data-constant",default:["interpolate",["linear"],["zoom"],4,.2,7,.1],minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"star-intensity":{type:"number","property-type":"data-constant",default:["interpolate",["linear"],["zoom"],5,.35,6,0],minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},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}},projection:{name:{type:"enum",values:{albers:{},equalEarth:{},equirectangular:{},lambertConformalConic:{},mercator:{},naturalEarth:{},winkelTripel:{},globe:{}},default:"mercator",required:!0},center:{type:"array",length:2,value:"number","property-type":"data-constant",minimum:[-180,-90],maximum:[180,90],transition:!1,requires:[{name:["albers","lambertConformalConic"]}]},parallels:{type:"array",length:2,value:"number","property-type":"data-constant",minimum:[-90,-90],maximum:[90,90],transition:!1,requires:[{name:["albers","lambertConformalConic"]}]}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number","property-type":"data-constant",default:1,minimum:0,maximum:1e3,expression:{interpolated:!0,parameters:["zoom"]},transition:!0,requires:["source"]}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],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:!1,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"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:!1,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"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"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant",type:"number",private:!0,default:0,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant",type:"number",private:!0,default:3,minimum:0,expression:{interpolated:!0,parameters:["zoom"]},transition:!0,requires:["fill-extrusion-edge-radius"]}},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:!1,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{type:"resolvedImage",transition:!1,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{type:"array",value:"number",length:2,default:[0,0],minimum:[0,0],maximum:[1,1],transition:!1,requires:[{source:"geojson",has:{lineMetrics:!0}}],"property-type":"constant"}},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:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_sky:{"sky-type":{type:"enum",values:{gradient:{},atmosphere:{}},default:"atmosphere",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{type:"array",value:"number",length:2,units:"degrees",minimum:[0,0],maximum:[360,180],transition:!1,requires:[{"sky-type":"atmosphere"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{type:"number",requires:[{"sky-type":"atmosphere"}],default:10,minimum:0,maximum:100,transition:!1,"property-type":"data-constant"},"sky-gradient-center":{type:"array",requires:[{"sky-type":"gradient"}],value:"number",default:[0,0],length:2,units:"degrees",minimum:[0,0],maximum:[360,180],transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{type:"number",requires:[{"sky-type":"gradient"}],default:90,minimum:0,maximum:180,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-gradient":{type:"color",default:["interpolate",["linear"],["sky-radial-progress"],.8,"#87ceeb",1,"white"],transition:!1,requires:[{"sky-type":"gradient"}],expression:{interpolated:!0,parameters:["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{type:"color",default:"white",transition:!1,requires:[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{type:"color",default:"white",transition:!1,requires:[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-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"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};function gf(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(!gf(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function pf(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};gf(t)||(t=wf(t));const i=t;let n=!0;try{n=function(t){if(!_f(t))return t;let e=cf(t);return mf(e),e=ff(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const r=df[`filter_${e}`],s=of(n,r);let o=null;if("error"===s.result)throw new Error(s.value.map((t=>`${t.key}: ${t.message}`)).join(", "));o=(t,e,i)=>s.value.evaluate(t,e,{},i);let a=null,l=null;if(n!==i){const t=of(i,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,n,r,s)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,s),l=!Ng(t.value.expression)}return{filter:o,dynamicFilter:a||void 0,needGeometry:vf(n),needFeature:!!l}}function ff(t){if(!Array.isArray(t))return t;const e=function(t){if(yf.has(t[0]))for(let e=1;eff(t)))}function mf(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","<","<=","to-boolean"]);function xf(t,e){return te?1:0}function vf(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?bf(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(wf))):"all"===e?["all"].concat(t.slice(1).map(wf)):"none"===e?["all"].concat(t.slice(1).map(wf).map(Cf)):"in"===e?Sf(t[1],t.slice(2)):"!in"===e?Cf(Sf(t[1],t.slice(2))):"has"===e?Ef(t[1]):"!has"===e?Cf(Ef(t[1])):"within"!==e||t}function bf(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function Sf(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(xf)]]:["filter-in-small",t,["literal",e]]}}function Ef(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Cf(t){return["!",t]}var Tf=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Rf(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return Tf.forEach((t=>{t in e&&(i[t]=e[t])})),i}var Pf={thin:100,hairline:100,"ultra-light":200,"extra-light":200,light:300,book:300,regular:400,normal:400,plain:400,roman:400,standard:400,medium:500,"semi-bold":600,"demi-bold":600,bold:700,"extra-bold":800,"ultra-bold":800,heavy:900,black:900,"heavy-black":900,fat:900,poster:900,"ultra-black":950,"extra-black":950},Ff=" ",If=/(italic|oblique)$/i,Mf={},Lf=function(t,e,i){var n=Mf[t];if(!n){Array.isArray(t)||(t=[t]);for(var r,s,o=400,a="normal",l=[],h=0,u=t.length;h1?c[c.length-2].toLowerCase():"";if(d==g||d==g.replace("-","")||p+"-"+d==g){o=r?o:Pf[g],c.pop(),p&&g.startsWith(p)&&c.pop();break}}r||"number"!=typeof d||(o=d,r=!0);var f=c.join(Ff).replace("Klokantech Noto Sans","Noto Sans");-1!==f.indexOf(Ff)&&(f='"'+f+'"'),l.push(f)}n=Mf[t]=[a,o,l]}return n[0]+Ff+n[1]+Ff+e+"px"+(i?"/"+i:"")+Ff+n[2]},kf=ud(Lf);const Df="https://api.mapbox.com";function Af(t){const e="mapbox://";return 0!==t.indexOf(e)?"":t.slice(9)}function Of(t,e){const i=Af(t);if(!i)return decodeURI(new URL(t,location.href).href);const n="styles/";if(0!==i.indexOf(n))throw new Error(`unexpected style url: ${t}`);const r=i.slice(7);return`${Df}/styles/v1/${r}?&access_token=${e}`}function zf(t,e,i,n){const r=new URL(t,n),s=Af(t);if(!s)return e?(r.searchParams.has(i)||r.searchParams.set(i,e),decodeURI(r.href)):decodeURI(r.href);if("mapbox.satellite"===s){return`https://api.mapbox.com/v4/${s}/{z}/{x}/{y}${window.devicePixelRatio>=1.5?"@2x":""}.webp?access_token=${e}`}return`https://{a-d}.tiles.mapbox.com/v4/${s}/{z}/{x}/{y}.vector.pbf?access_token=${e}`}const Gf={},Nf={};let jf=0;function Uf(t){return t.id||(t.id=jf++),t.id}function $f(t){return t*Math.PI/180}const Bf=function(){const t=[];for(let e=78271.51696402048;t.length<=24;e/=2)t.push(e);return t}();function Vf(t,e){if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(t,e);const i=document.createElement("canvas");return i.width=t,i.height=e,i}function Wf(t,e){let i=0;const n=e.length;for(;ir)).then((t=>(t instanceof Request||(t=new Request(t)),t.headers.get("Accept")||t.headers.set("Accept","application/json"),n&&(n.request=t),fetch(t).then((function(t){return delete Xf[e],t.ok?t.json():Promise.reject(new Error("Error fetching source "+e))})).catch((function(t){return delete Xf[e],Promise.reject(new Error("Error fetching source "+e))})))));return Xf[e]=[r,s],s}function Yf(t,e){if("string"!=typeof t)return Promise.resolve(t);if(!t.trim().startsWith("{"))return qf("Style",t=Of(t,e.accessToken),e);try{const e=JSON.parse(t);return Promise.resolve(e)}catch(t){return Promise.reject(t)}}const Zf={};function Kf(t,e,i,n){const r=[2*i*e.pixelRatio+e.width,2*i*e.pixelRatio+e.height],s=Vf(r[0],r[1]),o=s.getContext("2d");o.drawImage(t,e.x,e.y,e.width,e.height,i*e.pixelRatio,i*e.pixelRatio,e.width,e.height);const a=o.getImageData(0,0,r[0],r[1]);o.globalCompositeOperation="destination-over",o.fillStyle=`rgba(${255*n.r},${255*n.g},${255*n.b},${n.a})`;const l=a.data;for(let t=0,n=a.width;t0&&o.arc(t,r,i*e.pixelRatio,0,2*Math.PI)}return o.fill(),s}function Hf(t,e,i){const n=Math.max(0,Math.min(1,(i-t)/(e-t)));return n*n*(3-2*n)}function Jf(t,e,i){const n=Vf(e.width,e.height),r=n.getContext("2d");r.drawImage(t,e.x,e.y,e.width,e.height,0,0,e.width,e.height);const s=r.getImageData(0,0,e.width,e.height),o=s.data;for(let t=0,e=s.width;t0?(o[r+0]=Math.round(255*i.r*l),o[r+1]=Math.round(255*i.g*l),o[r+2]=Math.round(255*i.b*l),o[r+3]=Math.round(255*l)):o[r+3]=0}return r.putImageData(s,0,0),n}const Qf=Array(256).join(" ");function tm(t,e){if(e>=.05){let i="";const n=t.split("\n"),r=Qf.slice(0,Math.round(e/.1));for(let t=0,e=n.length;t0&&(i+="\n"),i+=n[t].split("").join(r);return i}return t}let em;function im(){return em||(em=Vf(1,1).getContext("2d")),em}function nm(t,e){return im().measureText(t).width+(t.length-1)*e}const rm={};function sm(t,e,i,n){if(-1!==t.indexOf("\n")){const r=t.split("\n"),s=[];for(let t=0,o=r.length;t1){const t=im();t.font=e;const r=t.measureText("M").width*i;let a="";const l=[];for(let t=0,e=o.length;t1;++t){const i=l[t];if(nm(i,n)<.35*r){const r=t>0?nm(l[t-1],n):1/0,s=t.7*r&&nm(s,n)<.6*r){const o=i.split(" "),a=o.pop();nm(a,n)<.2*r&&(l[t]=o.join(" "),l[t+1]=a+" "+s),e-=1}}s=l.join("\n")}else s=t;s=tm(s,n),rm[r]=s}return s}const om=/font-family: ?([^;]*);/,am=/("|')/g;let lm;function hm(t){if(!lm){lm={};const t=document.styleSheets;for(let e=0,i=t.length;e`${t.key}: ${t.message}`)).join(", "));return i.value},pm={},fm={zoom:0};let mm,_m;function ym(t,e,i,n,r,s,o){const a=t.id;s||(s={},console.warn("No functionCache provided to getValue()")),s[a]||(s[a]={});const l=s[a];if(!l[i]){let n=(t[e]||pm)[i];const r=df[`${e}_${t.type}`][i];void 0===n&&(n=r.default);let s=(h=n,Array.isArray(h)&&h.length>0&&"string"==typeof h[0]&&h[0]in tf);if(!s&&rf(n)&&(n=wd(n,r),s=!0),s){const t=gm(n,r);l[i]=t.evaluate.bind(t)}else"color"==r.type&&(n=xd.parse(n)),l[i]=function(){return n}}var h;return fm.zoom=n,l[i](fm,r,o)}function xm(t,e,i,n,r){if(!ym(t,"layout",`${n}-allow-overlap`,e,i,r))return"declutter";return ym(t,"layout",`${n}-ignore-placement`,e,i,r)?"none":"obstacle"}function vm(t,e,i,n,r){return r||console.warn("No filterCache provided to evaluateFilter()"),t in r||(r[t]=pf(e).filter),fm.zoom=n,r[t](fm,i)}function wm(t,e){if(t){if(0===t.a||0===e)return;const i=t.a;return e=void 0===e?1:e,0===i?"transparent":"rgba("+Math.round(255*t.r/i)+","+Math.round(255*t.g/i)+","+Math.round(255*t.b/i)+","+i*e+")"}return t}const bm=/\{[^{}}]*\}/g;function Sm(t,e){return t.replace(bm,(function(t){return e[t.slice(1,-1)]||""}))}const Em={};function Cm(t,e,i,n=Bf,s=void 0,o=void 0,a=void 0,l=void 0){if("string"==typeof e&&(e=JSON.parse(e)),8!=e.version)throw new Error("glStyle version 8 required.");let h,u,c;if(Em[function(t,e){return Uf(t)+"."+r(e)}(e,t)]=Array.from(arguments),o)if("undefined"!=typeof Image){const e=new Image;let i;dt((()=>o)).then((t=>{t instanceof Request?fetch(t).then((t=>t.blob())).then((t=>{i=URL.createObjectURL(t),e.src=i})).catch((()=>{})):(e.crossOrigin="anonymous",e.src=t,i&&URL.revokeObjectURL(i))})),e.onload=function(){h=e,u=[e.width,e.height],t.changed(),e.onload=null}}else if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){const t=self;t.postMessage({action:"loadImage",src:o}),t.addEventListener("message",(function(t){"imageLoaded"===t.data.action&&t.data.src===o&&(h=t.data.image,u=[h.width,h.height])}))}const d=function(t){t=t.slice();const e=Object.create(null);for(let i=0;i=R.maxzoom)continue;const M=R.filter;if(!M||vm(P,M,E,x,y)){let n,o,p,y,P,M;const L=g.index;if(3==S&&("fill"==R.type||"fill-extrusion"==R.type))if(o=ym(R,"paint",R.type+"-opacity",x,E,_,C),R.type+"-pattern"in I){const t=ym(R,"paint",R.type+"-pattern",x,E,_,C);if(t){const e="string"==typeof t?Sm(t,d):t.toString();if(h&&s&&s[e]){++T,M=b[T],M&&M.getFill()&&!M.getStroke()&&!M.getText()||(M=new ns({fill:new Ce}),b[T]=M),p=M.getFill(),M.setZIndex(L);const t=e+"."+o;let i=m[t];if(!i){const n=s[e],r=Vf(n.width,n.height),a=r.getContext("2d");a.globalAlpha=o,a.drawImage(h,n.x,n.y,n.width,n.height,0,0,n.width,n.height),i=a.createPattern(r,"repeat"),m[t]=i}p.setColor(i)}}}else n=wm(ym(R,"paint",R.type+"-color",x,E,_,C),o),R.type+"-outline-color"in I&&(P=wm(ym(R,"paint",R.type+"-outline-color",x,E,_,C),o)),P||(P=n),(n||P)&&(++T,M=b[T],(!M||n&&!M.getFill()||!n&&M.getFill()||P&&!M.getStroke()||!P&&M.getStroke()||M.getText())&&(M=new ns({fill:n?new Ce:void 0,stroke:P?new Hr:void 0}),b[T]=M),n&&(p=M.getFill(),p.setColor(n)),P&&(y=M.getStroke(),y.setColor(P),y.setWidth(.5)),M.setZIndex(L));if(1!=S&&"line"==R.type){n="line-pattern"in I?void 0:wm(ym(R,"paint","line-color",x,E,_,C),ym(R,"paint","line-opacity",x,E,_,C));const t=ym(R,"paint","line-width",x,E,_,C);n&&t>0&&(++T,M=b[T],M&&M.getStroke()&&!M.getFill()&&!M.getText()||(M=new ns({stroke:new Hr}),b[T]=M),y=M.getStroke(),y.setLineCap(ym(R,"layout","line-cap",x,E,_,C)),y.setLineJoin(ym(R,"layout","line-join",x,E,_,C)),y.setMiterLimit(ym(R,"layout","line-miter-limit",x,E,_,C)),y.setColor(n),y.setWidth(t),y.setLineDash(I["line-dasharray"]?ym(R,"paint","line-dasharray",x,E,_,C).map((function(e){return e*t})):null),M.setZIndex(L))}let k,D,A,O,z,G,N,j,U,$=!1,B=null,V=0;if((1==S||2==S)&&"icon-image"in F){const e=ym(R,"layout","icon-image",x,E,_,C);if(e){let n;k="string"==typeof e?Sm(e,d):e.toString();const o=l?l(t,k):void 0;if(h&&s&&s[k]||o){const t=ym(R,"layout","icon-rotation-alignment",x,E,_,C);if(2==S){const e=i.getGeometry();if(e.getFlatMidpoint||e.getFlatMidpoints){const i=e.getExtent();if(Math.sqrt(Math.max(Math.pow((i[2]-i[0])/r,2),Math.pow((i[3]-i[1])/r,2)))>150){const i="MultiLineString"===e.getType()?e.getFlatMidpoints():e.getFlatMidpoint();_m||(mm=[NaN,NaN],_m=new Zr("Point",mm,[],2,{},void 0)),n=_m,mm[0]=i[0],mm[1]=i[1];if("line"===ym(R,"layout","symbol-placement",x,E,_,C)&&"map"===t){const t=e.getStride(),n=e.getFlatCoordinates();for(let e=0,r=n.length-t;e=l&&i[0]<=u&&i[1]>=h&&i[1]<=c){V=Math.atan2(s-a,o-r);break}}}}}}if(2!==S||n){const e=ym(R,"layout","icon-size",x,E,_,C),i=void 0!==I["icon-color"]?ym(R,"paint","icon-color",x,E,_,C):null;if(!i||0!==i.a){const n=ym(R,"paint","icon-halo-color",x,E,_,C),r=ym(R,"paint","icon-halo-width",x,E,_,C);let a=`${k}.${e}.${r}.${n}`;if(null!==i&&(a+=`.${i}`),D=f[a],!D){const l=xm(R,x,E,"icon",_);let d;"icon-offset"in F&&(d=ym(R,"layout","icon-offset",x,E,_,C).slice(0),d[0]*=e,d[1]*=-e);let g=i?[255*i.r,255*i.g,255*i.b,i.a]:void 0;if(o){const i={color:g,rotateWithView:"map"===t,displacement:d,declutterMode:l,scale:e};"string"==typeof o?i.src=o:(i.img=o,i.imgSize=[o.width,o.height]),D=new Fe(i)}else{const o=s[k];let a,p,f;r?o.sdf?(a=Kf(Jf(h,o,i||[0,0,0,1]),{x:0,y:0,width:o.width,height:o.height,pixelRatio:o.pixelRatio},r,n),g=void 0):a=Kf(h,o,r,n):(o.sdf?(c||(c=Jf(h,{x:0,y:0,width:u[0],height:u[1]},{r:1,g:1,b:1,a:1})),a=c):a=h,p=[o.width,o.height],f=[o.x,o.y]),D=new Fe({color:g,img:a,imgSize:u,size:p,offset:f,rotateWithView:"map"===t,scale:e/o.pixelRatio,displacement:d,declutterMode:l})}f[a]=D}}D&&(++T,M=b[T],M&&M.getImage()&&!M.getFill()&&!M.getStroke()||(M=new ns,b[T]=M),M.setGeometry(n),D.setRotation(V+$f(ym(R,"layout","icon-rotate",x,E,_,C))),D.setOpacity(ym(R,"paint","icon-opacity",x,E,_,C)),D.setAnchor(dm[ym(R,"layout","icon-anchor",x,E,_,C)]),M.setImage(D),B=M.getText(),M.setText(void 0),M.setZIndex(L),$=!0,A=!1)}else A=!0}}}if(1==S&&"circle"===R.type){++T,M=b[T],M&&M.getImage()&&!M.getFill()&&!M.getStroke()||(M=new ns,b[T]=M);const t="circle-radius"in I?ym(R,"paint","circle-radius",x,E,_,C):5,e=wm(ym(R,"paint","circle-stroke-color",x,E,_,C),ym(R,"paint","circle-stroke-opacity",x,E,_,C)),i=ym(R,"paint","circle-translate",x,E,_,C),n=wm(ym(R,"paint","circle-color",x,E,_,C),ym(R,"paint","circle-opacity",x,E,_,C)),r=ym(R,"paint","circle-stroke-width",x,E,_,C),s=t+"."+e+"."+n+"."+r+"."+i[0]+"."+i[1];D=f[s],D||(D=new Se({radius:t,displacement:[i[0],-i[1]],stroke:e&&r>0?new Hr({width:r,color:e}):void 0,fill:n?new Ce({color:n}):void 0,declutterMode:"none"}),f[s]=D),M.setImage(D),B=M.getText(),M.setText(void 0),M.setGeometry(void 0),M.setZIndex(L),$=!0}if("text-field"in F){N=Math.round(ym(R,"layout","text-size",x,E,_,C));const t=ym(R,"layout","text-font",x,E,_,C);G=ym(R,"layout","text-line-height",x,E,_,C),z=kf(a?a(t,e.metadata?e.metadata["ol:webfonts"]:void 0):t,N,G),z.includes("sans-serif")||(z+=",sans-serif"),j=ym(R,"layout","text-letter-spacing",x,E,_,C),U=ym(R,"layout","text-max-width",x,E,_,C);const i=ym(R,"layout","text-field",x,E,_,C);O="object"==typeof i&&i.sections?1===i.sections.length?i.toString():i.sections.reduce(((e,i,n)=>{const r=i.fontStack?i.fontStack.split(","):t,s=kf(a?a(r):r,N*(i.scale||1),G);let o=i.text;if("\n"===o)return e.push("\n",""),e;if(2!=S){o=sm(o,s,U,j).split("\n");for(let t=0,i=o.length;t0&&e.push("\n",""),e.push(o[t],s);return e}e.push(tm(o,j),s)}),[]):Sm(i,d).trim(),o=ym(R,"paint","text-opacity",x,E,_,C)}if(O&&o&&!A){$||(++T,M=b[T],M&&M.getText()&&!M.getFill()&&!M.getStroke()||(M=new ns,b[T]=M),M.setImage(void 0),M.setGeometry(void 0));const t=xm(R,x,E,"text",_);M.getText()||M.setText(B),B=M.getText(),(!B||"getDeclutterMode"in B&&B.getDeclutterMode()!==t)&&(B=new ss({padding:[2,2,2,2],declutterMode:t}),M.setText(B));const e=ym(R,"layout","text-transform",x,E,_,C);"uppercase"==e?O=Array.isArray(O)?O.map(((t,e)=>e%2?t:t.toUpperCase())):O.toUpperCase():"lowercase"==e&&(O=Array.isArray(O)?O.map(((t,e)=>e%2?t:t.toLowerCase())):O.toLowerCase());const i=Array.isArray(O)?O:2==S?tm(O,j):sm(O,z,U,j);B.setText(i),B.setFont(z),B.setRotation($f(ym(R,"layout","text-rotate",x,E,_,C)));const n=ym(R,"layout","text-anchor",x,E,_,C),r=$||1==S?"point":ym(R,"layout","symbol-placement",x,E,_,C);let s;if("line-center"===r?(B.setPlacement("line"),s="center"):B.setPlacement(r),"line"===r&&"function"==typeof B.setRepeat){const t=ym(R,"layout","symbol-spacing",x,E,_,C);B.setRepeat(2*t)}B.setOverflow("point"===r);let a=ym(R,"paint","text-halo-width",x,E,_,C);const l=ym(R,"layout","text-offset",x,E,_,C),h=ym(R,"paint","text-translate",x,E,_,C);let u=0,c=0;if("point"==r){s="center",-1!==n.indexOf("left")?(s="left",c=a):-1!==n.indexOf("right")&&(s="right",c=-a);const t=ym(R,"layout","text-rotation-alignment",x,E,_,C);B.setRotateWithView("map"==t)}else B.setMaxAngle($f(ym(R,"layout","text-max-angle",x,E,_,C))*O.length/i.length),B.setRotateWithView(!1);B.setTextAlign(s);let d="middle";0==n.indexOf("bottom")?(d="bottom",u=-a-.5*(G-1)*N):0==n.indexOf("top")&&(d="top",u=a+.5*(G-1)*N),B.setTextBaseline(d);const g=ym(R,"layout","text-justify",x,E,_,C);B.setJustify("auto"===g?void 0:g),B.setOffsetX(l[0]*N+c+h[0]),B.setOffsetY(l[1]*N+u+h[1]),w.setColor(wm(ym(R,"paint","text-color",x,E,_,C),o)),B.setFill(w);const p=wm(ym(R,"paint","text-halo-color",x,E,_,C),o);if(p&&a>0){v.setColor(p),a*=2;const t=.5*N;v.setWidth(a<=t?a:t),B.setStroke(v)}else B.setStroke(void 0);const f=ym(R,"layout","text-padding",x,E,_,C),m=B.getPadding();f!==m[0]&&(m[0]=f,m[1]=f,m[2]=f,m[3]=f),M.setZIndex(L)}}}return T>-1?(b.length=T+1,b):void 0};return t.setStyle(S),t.set("mapbox-source",x),t.set("mapbox-layers",p),t.set("mapbox-featurestate",t.get("mapbox-featurestate")||{}),S}function Tm(t,e=512){return t.getExtent()?Bc({extent:t.getExtent(),tileSize:e,maxZoom:22}).getResolutions():Bf}function Rm(t,e,i="",n={},r=void 0){let s,o,a,l,h=!0;return"string"==typeof i||Array.isArray(i)?l=i:(a=i,l=a.source||a.layers,n=a),"string"==typeof n?(s=n,a={}):(s=n.styleUrl,a=n),!1===a.updateSource&&(h=!1),r||(r=a.resolutions),s||"string"!=typeof e||e.trim().startsWith("{")||(s=e),s&&(s=s.startsWith("data:")?location.href:Of(s,a.accessToken),a=function(t,e){e.accessToken||(e=Object.assign({},e),new URL(t).searchParams.forEach(((t,i)=>{e.accessToken=t,e.accessTokenParam=i})));return e}(s,a)),new Promise((function(i,n){Yf(e,a).then((function(e){if(8!=e.version)return n(new Error("glStyle version 8 required."));if(!(t instanceof dl||t instanceof ad))return n(new Error("Can only apply to VectorLayer or VectorTileLayer"));const u=t instanceof ad?"vector":"geojson";if(l?o=Array.isArray(l)?e.layers.find((function(t){return t.id===l[0]})).source:l:(o=Object.keys(e.sources).find((function(t){return e.sources[t].type===u})),l=o),!o)return n(new Error(`No ${u} source found in the glStyle.`));function c(){if(!h)return Promise.resolve();if(t instanceof ad)return function(t,e,i){return new Promise((function(n,r){(function(t,e,i={}){const n=[e,JSON.stringify(t)].toString();let r=Zf[n];if(!r||i.transformRequest){let s;i.transformRequest&&(s=(t,e)=>{const n=i.transformRequest&&i.transformRequest(e,"Tiles")||e;if(t instanceof pu)t.setLoader(((e,i,r)=>{dt((()=>n)).then((i=>{fetch(i).then((t=>t.arrayBuffer())).then((i=>{const n=t.getFormat().readFeatures(i,{extent:e,featureProjection:r});t.setFeatures(n)})).catch((e=>t.setState(os.ERROR)))}))}));else{const e=t.getImage();dt((()=>n)).then((i=>{i instanceof Request?fetch(i).then((t=>t.blob())).then((t=>{const i=URL.createObjectURL(t);e.addEventListener("load",(()=>URL.revokeObjectURL(i))),e.addEventListener("error",(()=>URL.revokeObjectURL(i))),e.src=i})).catch((e=>t.setState(os.ERROR))):e.src=i}))}});const o=t.url;if(o&&!t.tiles){const n=zf(o,i.accessToken,i.accessTokenParam||"access_token",e||location.href);if(o.startsWith("mapbox://"))r=Promise.resolve({tileJson:Object.assign({},t,{url:void 0,tiles:vu(n)}),tileLoadFunction:s});else{const t={};r=qf("Source",n,i,t).then((function(e){return e.tiles=e.tiles.map((function(n){return"tms"===e.scheme&&(n=n.replace("{y}","{-y}")),zf(n,i.accessToken,i.accessTokenParam||"access_token",t.request.url)})),Promise.resolve({tileJson:e,tileLoadFunction:s})}))}}else t=Object.assign({},t,{tiles:t.tiles.map((function(n){return"tms"===t.scheme&&(n=n.replace("{y}","{-y}")),zf(n,i.accessToken,i.accessTokenParam||"access_token",e||location.href)}))}),r=Promise.resolve({tileJson:Object.assign({},t),tileLoadFunction:s});Zf[n]=r}return r})(t,e,i).then((function({tileJson:e,tileLoadFunction:r}){const s=function(t,e,i){const n=new nd({tileJSON:e,tileSize:t.tileSize||e.tileSize||512}),r=n.getTileJSON(),s=n.getTileGrid(),o=gn(i.projection||"EPSG:3857"),a=function(t,e){const i=t.bounds;if(i){const t=xn([i[0],i[1]],e),n=xn([i[2],i[3]],e);return[t[0],t[1],n[0],n[1]]}return gn(e).getExtent()}(r,o),l=o.getExtent(),h=r.minzoom||0,u=r.maxzoom||22,c={attributions:n.getAttributions(),projection:o,tileGrid:new Gc({origin:l?mi(l):s.getOrigin(0),extent:a||s.getExtent(),minZoom:h,resolutions:Tm(o,e.tileSize).slice(0,u+1),tileSize:s.getTileSize(0)})};Array.isArray(r.tiles)?c.urls=r.tiles:c.url=r.tiles;return c}(t,e,i);s.tileLoadFunction=r,s.format=new ic,n(new ld(s))})).catch(r)}))}(e.sources[o],s,a).then((function(e){const i=t.getSource();i?e!==i&&(i.setTileUrlFunction(e.getTileUrlFunction()),"function"==typeof i.setUrls&&"function"==typeof e.getUrls&&i.setUrls(e.getUrls()),i.format_||(i.format_=e.format_),i.getAttributions()||i.setAttributions(e.getAttributions()),i.getTileLoadFunction()===hd&&i.setTileLoadFunction(e.getTileLoadFunction()),vn(i.getProjection(),e.getProjection())&&(i.tileGrid=e.getTileGrid())):t.setSource(e);const n=t.getSource().getTileGrid();!isFinite(t.getMaxResolution())&&!isFinite(t.getMinZoom())&&n.getMinZoom()>0&&t.setMaxResolution(function(t,e){const i=Math.floor(t),n=Math.pow(2,t-i);return e[i]/n}(Math.max(0,n.getMinZoom()-1e-12),n.getResolutions()))}));const i=e.sources[o];let n=t.getSource();n&&n.get("mapbox-source")===i||(n=function(t,e,i){const n=i.projection?new ku({dataProjection:i.projection}):new ku,r=t.data,s={};if("string"==typeof r){const s=zf(r,i.accessToken,i.accessTokenParam||"access_token",e||location.href);if(/\{bbox-[0-9a-z-]+\}/.test(s)){const e=(t,e,i)=>{const n=function(t){const e=t?t.getCode():"EPSG:3857";return`{bbox-${e.toLowerCase().replace(/[^a-z0-9]/g,"-")}}`}(i);return s.replace(n,`${t.join(",")}`)},r=new Fl({attributions:t.attribution,format:n,loader:(t,n,s,o,a)=>{qf("GeoJSON","function"==typeof e?e(t,n,s):e,i).then((t=>{const e=r.getFormat().readFeatures(t,{featureProjection:s});r.addFeatures(e),o(e)})).catch((e=>{r.removeLoadedExtent(t),a()}))},strategy:El});return r.set("mapbox-source",t),r}const o=new Fl({attributions:t.attribution,format:n,url:s,loader:(t,e,n,r,a)=>{qf("GeoJSON",s,i).then((t=>{const e=o.getFormat().readFeatures(t,{featureProjection:n});o.addFeatures(e),r(e)})).catch((e=>{o.removeLoadedExtent(t),a()}))}});return o}s.features=n.readFeatures(r,{featureProjection:Rn()||"EPSG:3857"});const o=new Fl(Object.assign({attributions:t.attribution,format:n},s));return o.set("mapbox-source",t),o}(i,s,a));const r=t.getSource();return r?n!==r&&(r.getAttributions()||r.setAttributions(n.getAttributions()),r.format_||(r.format_=n.getFormat()),r.url_=n.getUrl()):t.setSource(n),Promise.resolve()}let d,g,p,f;function m(){if(f||e.sprite&&!g)f?(t.setStyle(f),c().then(i).catch(n)):n(new Error("Something went wrong trying to apply style."));else{if(a.projection&&!r){const t=gn(a.projection).getUnits();"m"!==t&&(r=Bf.map((e=>e/Ei[t])))}f=Cm(t,e,l,r,g,p,((t,e=a.webfonts)=>function(t,e="https://cdn.jsdelivr.net/npm/@fontsource/{font-family}/{fontweight}{-fontstyle}.css"){const i=t.toString();if(i in um)return um[i];const n=[];for(let e=0,i=t.length;e=1.5?.5:1;const i=.5==d?"@2x":"";let r=t.origin+t.pathname+i+".json"+t.search;new Promise((function(e,i){qf("Sprite",r,a).then(e).catch((function(n){r=t.origin+t.pathname+".json"+t.search,qf("Sprite",r,a).then(e).catch(i)}))})).then((function(e){if(void 0===e&&n(new Error("No sprites found.")),g=e,p=t.origin+t.pathname+i+".png"+t.search,a.transformRequest){const t=a.transformRequest(p,"SpriteImage")||p;(t instanceof Request||t instanceof Promise)&&(p=t)}m()})).catch((function(t){n(new Error(`Sprites cannot be loaded: ${r}: ${t.message}`))}))}else m()})).catch(n)}))}const Pm={};function Fm(t,e,i){e.layers.some((function(e){if("background"===e.type){if(t instanceof Zs)return t.setBackground((function(t){return Im(e,t,i,{})})),!0;if(t instanceof Kh||t instanceof Nl)return t.getLayers().insertAt(0,function(t,e,i){const n=document.createElement("div");return n.className="ol-mapbox-style-background",n.style.position="absolute",n.style.width="100%",n.style.height="100%",new Zs({source:new fl({}),render(r){const s=Im(t,r.viewState.resolution,e,i);return n.style.backgroundColor=s,n}})}(e,i,{})),!0}}))}function Im(t,e,i,n){const r={id:t.id,type:t.type},s=t.layout||{},o=t.paint||{};r.paint=o;const a=Wf(e,i.resolutions||Bf);let l;const h=ym(r,"paint","background-color",a,Pm,n);return void 0!==o["background-opacity"]&&(l=ym(r,"paint","background-opacity",a,Pm,n)),"none"==s.visibility?void 0:wm(h,l)}class Mm extends it{constructor(t){super(_t),this.error=t}}const Lm="units",km=[1,2,5],Dm=25.4/.28;var Am=class extends sh{constructor(t){t=t||{};const e=document.createElement("div");e.style.pointerEvents="none",super({element:e,render:t.render,target:t.target}),this.on,this.once,this.un;const i=void 0!==t.className?t.className:t.bar?"ol-scale-bar":"ol-scale-line";this.innerElement_=document.createElement("div"),this.innerElement_.className=i+"-inner",this.element.className=i+" "+Zt,this.element.appendChild(this.innerElement_),this.viewState_=null,this.minWidth_=void 0!==t.minWidth?t.minWidth:64,this.maxWidth_=t.maxWidth,this.renderedVisible_=!1,this.renderedWidth_=void 0,this.renderedHTML_="",this.addChangeListener(Lm,this.handleUnitsChanged_),this.setUnits(t.units||"metric"),this.scaleBar_=t.bar||!1,this.scaleBarSteps_=t.steps||4,this.scaleBarText_=t.text||!1,this.dpi_=t.dpi||void 0}getUnits(){return this.get(Lm)}handleUnitsChanged_(){this.updateElement_()}setUnits(t){this.set(Lm,t)}setDpi(t){this.dpi_=t}updateElement_(){const t=this.viewState_;if(!t)return void(this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1));const e=t.center,i=t.projection,n=this.getUnits(),r="degrees"==n?"degrees":"m";let s=pn(i,t.resolution,e,r);const o=this.minWidth_*(this.dpi_||Dm)/Dm,a=void 0!==this.maxWidth_?this.maxWidth_*(this.dpi_||Dm)/Dm:void 0;let l=o*s,h="";if("degrees"==n){const t=Ei.degrees;l*=t,l=a){u=g,c=p,d=f;break}if(c>=o)break;g=u,p=c,f=d,++m}const _=this.scaleBar_?this.createScaleBar(c,u,h):u.toFixed(d<0?-d:0)+" "+h;this.renderedHTML_!=_&&(this.innerElement_.innerHTML=_,this.renderedHTML_=_),this.renderedWidth_!=c&&(this.innerElement_.style.width=c+"px",this.renderedWidth_=c),this.renderedVisible_||(this.element.style.display="",this.renderedVisible_=!0)}createScaleBar(t,e,i){const n=this.getScaleForResolution(),r=n<1?Math.round(1/n).toLocaleString()+" : 1":"1 : "+Math.round(n).toLocaleString(),s=this.scaleBarSteps_,o=t/s,a=[this.createMarker("absolute")];for(let n=0;n
`+this.createMarker("relative")+(n%2==0||2===s?this.createStepText(n,t,!1,e,i):"")+"")}a.push(this.createStepText(s,t,!0,e,i));return(this.scaleBarText_?`
`+r+"
":"")+a.join("")}createMarker(t){return`
`}createStepText(t,e,i,n,r){const s=(0===t?0:Math.round(n/this.scaleBarSteps_*t*100)/100)+(0===t?"":" "+r);return`
`+s+"
"}getScaleForResolution(){return pn(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m")*(1e3/25.4)*(this.dpi_||Dm)}render(t){const e=t.frameState;this.viewState_=e?e.viewState:null,this.updateElement_()}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Om(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})})),e}var zm={exports:{}},Gm=Om(oh),Nm=Om(Wt),jm=Om(jl);!function(t){t.exports=function(t,e,i){t="default"in t?t.default:t,i="default"in i?i.default:i;const n="layer-switcher-";class r extends t{constructor(t){const e=Object.assign({},t),i=document.createElement("div");super({element:i,target:e.target}),this.activationMode=e.activationMode||"mouseover",this.startActive=!0===e.startActive,this.label=void 0!==e.label?e.label:"",this.collapseLabel=void 0!==e.collapseLabel?e.collapseLabel:"»",this.tipLabel=e.tipLabel?e.tipLabel:"Legend",this.collapseTipLabel=e.collapseTipLabel?e.collapseTipLabel:"Collapse legend",this.groupSelectStyle=r.getGroupSelectStyle(e.groupSelectStyle),this.reverse=!1!==e.reverse,this.mapListeners=[],this.hiddenClassName="ol-unselectable ol-control layer-switcher",r.isTouchDevice_()&&(this.hiddenClassName+=" touch"),this.shownClassName="shown",i.className=this.hiddenClassName,this.button=document.createElement("button"),i.appendChild(this.button),this.panel=document.createElement("div"),this.panel.className="panel",i.appendChild(this.panel),r.enableTouchScroll_(this.panel),i.classList.add(n+"group-select-style-"+this.groupSelectStyle),i.classList.add(n+"activation-mode-"+this.activationMode),"click"===this.activationMode?(i.classList.add("activationModeClick"),this.button.onclick=t=>{const e=t||window.event;this.element.classList.contains(this.shownClassName)?this.hidePanel():this.showPanel(),e.preventDefault()}):(this.button.onmouseover=()=>{this.showPanel()},this.button.onclick=t=>{const e=t||window.event;this.showPanel(),e.preventDefault()},this.panel.onmouseout=t=>{this.panel.contains(t.relatedTarget)||this.hidePanel()}),this.updateButton()}setMap(t){for(let t=0;t{this.hidePanel()}))))}showPanel(){this.element.classList.contains(this.shownClassName)||(this.element.classList.add(this.shownClassName),this.updateButton(),this.renderPanel()),this.dispatchEvent("show")}hidePanel(){this.element.classList.contains(this.shownClassName)&&(this.element.classList.remove(this.shownClassName),this.updateButton()),this.dispatchEvent("hide")}updateButton(){this.element.classList.contains(this.shownClassName)?(this.button.textContent=this.collapseLabel,this.button.setAttribute("title",this.collapseTipLabel),this.button.setAttribute("aria-label",this.collapseTipLabel)):(this.button.textContent=this.label,this.button.setAttribute("title",this.tipLabel),this.button.setAttribute("aria-label",this.tipLabel))}renderPanel(){this.dispatchEvent("render"),r.renderPanel(this.getMap(),this.panel,{groupSelectStyle:this.groupSelectStyle,reverse:this.reverse}),this.dispatchEvent("rendercomplete")}static renderPanel(t,e,i){const n=new Event("render");for(e.dispatchEvent(n),(i=i||{}).groupSelectStyle=r.getGroupSelectStyle(i.groupSelectStyle),r.ensureTopVisibleBaseLayerShown(t,i.groupSelectStyle);e.firstChild;)e.removeChild(e.firstChild);r.forEachRecursive(t,(function(t,e,i){t.set("indeterminate",!1)})),"children"===i.groupSelectStyle||"none"===i.groupSelectStyle?r.setGroupVisibility(t):"group"===i.groupSelectStyle&&r.setChildVisibility(t);const s=document.createElement("ul");e.appendChild(s),r.renderLayers_(t,t,s,i,(function(n){r.renderPanel(t,e,i)}));const o=new Event("rendercomplete");e.dispatchEvent(o)}static isBaseGroup(t){if(t instanceof i){const e=t.getLayers().getArray();return e.length&&"base"===e[0].get("type")}return!1}static setGroupVisibility(t){r.getGroupsAndLayers(t,(function(t){return t instanceof i&&!t.get("combine")&&!r.isBaseGroup(t)})).reverse().forEach((function(t){const e=t.getLayersArray().map((function(t){return t.getVisible()}));e.every((function(t){return!0===t}))?(t.setVisible(!0),t.set("indeterminate",!1)):e.every((function(t){return!1===t}))?(t.setVisible(!1),t.set("indeterminate",!1)):(t.setVisible(!0),t.set("indeterminate",!0))}))}static setChildVisibility(t){r.getGroupsAndLayers(t,(function(t){return t instanceof i&&!t.get("combine")&&!r.isBaseGroup(t)})).forEach((function(t){const e=t,i=e.getVisible(),n=e.get("indeterminate");e.getLayers().getArray().forEach((function(t){t.set("indeterminate",!1),i&&!n||!t.getVisible()||t.set("indeterminate",!0)}))}))}static ensureTopVisibleBaseLayerShown(t,e){let i;r.forEachRecursive(t,(function(t,e,n){"base"===t.get("type")&&t.getVisible()&&(i=t)})),i&&r.setVisible_(t,i,!0,e)}static getGroupsAndLayers(t,e){const i=[];return e=e||function(t,e,i){return!0},r.forEachRecursive(t,(function(t,n,r){t.get("title")&&e(t,n,r)&&i.push(t)})),i}static setVisible_(t,e,n,s){e.setVisible(n),n&&"base"===e.get("type")&&r.forEachRecursive(t,(function(t,i,n){t!=e&&"base"===t.get("type")&&t.setVisible(!1)})),e instanceof i&&!e.get("combine")&&"children"===s&&e.getLayers().forEach((i=>{r.setVisible_(t,i,e.getVisible(),s)}))}static renderLayer_(t,e,s,o,a){const l=document.createElement("li"),h=e.get("title"),u=r.uuid(),c=document.createElement("label");if(e instanceof i&&!e.get("combine")){const i=r.isBaseGroup(e);if(l.classList.add("group"),i&&l.classList.add(n+"base-group"),e.get("fold")){l.classList.add(n+"fold"),l.classList.add(n+e.get("fold"));const t=document.createElement("button");t.onclick=function(t){const i=t||window.event;r.toggleFold_(e,l),i.preventDefault()},l.appendChild(t)}if(!i&&"none"!=o.groupSelectStyle){const i=document.createElement("input");i.type="checkbox",i.id=u,i.checked=e.getVisible(),i.indeterminate=e.get("indeterminate"),i.onchange=function(i){const n=i.target;r.setVisible_(t,e,n.checked,o.groupSelectStyle),a(e)},l.appendChild(i),c.htmlFor=u}c.innerHTML=h,l.appendChild(c);const s=document.createElement("ul");l.appendChild(s),r.renderLayers_(t,e,s,o,a)}else{l.className="layer";const i=document.createElement("input");"base"===e.get("type")?i.type="radio":i.type="checkbox",i.id=u,i.checked=e.get("visible"),i.indeterminate=e.get("indeterminate"),i.onchange=function(i){const n=i.target;r.setVisible_(t,e,n.checked,o.groupSelectStyle),a(e)},l.appendChild(i),c.htmlFor=u,c.innerHTML=h;const n=t.getView().getResolution();if(n>=e.getMaxResolution()||ne.getMaxZoom())&&(c.className+=" disabled")}l.appendChild(c)}return l}static renderLayers_(t,e,i,n,s){let o=e.getLayers().getArray().slice();n.reverse&&(o=o.reverse());for(let e,a=0;a=0?t:"children"}}return window.ol&&window.ol.control&&(window.ol.control.LayerSwitcher=r),r}(Gm,Nm,jm)}(zm);var Um=zm.exports;var $m=class extends dh{constructor(t){const e=t||{};super(e),e.stopDown&&(this.stopDown=e.stopDown),this.scaleDeltaByPixel_=e.delta?e.delta:.01,this.duration_=void 0!==e.duration?e.duration:250,this.handlingDownUpSequence_=!1,this.handlingDoubleDownSequence_=!1,this.doubleTapTimeoutId_=void 0,this.trackedPointers_={},this.targetPointers=[]}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence_){if(t.type==Bl.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Bl.POINTERUP){const e=this.handleUpEvent(t);this.handlingDownUpSequence_=e}}else if(t.type==Bl.POINTERDOWN)if(this.handlingDoubleDownSequence_){this.handlingDoubleDownSequence_=!1;const i=this.handleDownEvent(t);this.handlingDownUpSequence_=i,e=this.stopDown(i)}else e=this.stopDown(!1),this.waitForDblTap_();return!e}handleDragEvent(t){let e=1;const i=this.targetPointers[0],n=this.down_.originalEvent,r=i.clientY-n.clientY;void 0!==this.lastDistance_&&(e=1-(this.lastDistance_-r)*this.scaleDeltaByPixel_),this.lastDistance_=r,1!=e&&(this.lastScaleDelta_=e);const s=t.map,o=s.getView();s.render(),o.adjustResolutionInternal(e)}handleDownEvent(t){if(1==this.targetPointers.length){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.down_=t,this.handlingDownUpSequence_||e.getView().beginInteraction(),!0}return!1}handleUpEvent(t){if(0==this.targetPointers.length){const e=t.map.getView(),i=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,i),this.handlingDownUpSequence_=!1,this.handlingDoubleDownSequence_=!1,!1}return!0}stopDown(t){return t}updateTrackedPointers_(t){if(function(t){const e=t.type;return e===Bl.POINTERDOWN||e===Bl.POINTERDRAG||e===Bl.POINTERUP}(t)){const e=t.originalEvent,i=e.pointerId.toString();t.type==Bl.POINTERUP?delete this.trackedPointers_[i]:(t.type==Bl.POINTERDOWN||i in this.trackedPointers_)&&(this.trackedPointers_[i]=e),this.targetPointers=Object.values(this.trackedPointers_)}}waitForDblTap_(){void 0!==this.doubleTapTimeoutId_?(clearTimeout(this.doubleTapTimeoutId_),this.doubleTapTimeoutId_=void 0):(this.handlingDoubleDownSequence_=!0,this.doubleTapTimeoutId_=setTimeout(this.endInteraction_.bind(this),250))}endInteraction_(){this.handlingDoubleDownSequence_=!1,this.doubleTapTimeoutId_=void 0}};const Bm="addfeatures";class Vm extends it{constructor(t,e,i,n){super(t),this.features=i,this.file=e,this.projection=n}}var Wm=class extends dh{constructor(t){t=t||{},super({handleEvent:lt}),this.on,this.once,this.un,this.readAsBuffer_=!1,this.formats_=[];const e=t.formatConstructors?t.formatConstructors:[];for(let t=0,i=e.length;t0){this.source_&&(this.source_.clear(),this.source_.addFeatures(l)),this.dispatchEvent(new Vm(Bm,t,l,s));break}}}registerListeners_(){const t=this.getMap();if(t){const e=this.target?this.target:t.getViewport();this.dropListenKeys_=[Ft(e,St,this.handleDrop,this),Ft(e,wt,this.handleStop,this),Ft(e,bt,this.handleStop,this),Ft(e,St,this.handleStop,this)]}}setActive(t){!this.getActive()&&t&&this.registerListeners_(),this.getActive()&&!t&&this.unregisterListeners_(),super.setActive(t)}setMap(t){this.unregisterListeners_(),super.setMap(t),this.getActive()&&this.registerListeners_()}tryReadFeatures_(t,e,i){try{return t.readFeatures(e,i)}catch(t){return null}}unregisterListeners_(){this.dropListenKeys_&&(this.dropListenKeys_.forEach(Mt),this.dropListenKeys_=null)}handleDrop(t){const e=t.dataTransfer.files;for(let t=0,i=e.length;t1?1:-1;return e.endInteraction(this.duration_,i),this.lastScaleDelta_=0,!1}handleDownEvent(t){return!!Th(t)&&(!!this.condition_(t)&&(t.map.getView().beginInteraction(),this.lastAngle_=void 0,this.lastMagnitude_=void 0,!0))}};const qm="drawstart",Ym="drawend",Zm="drawabort";class Km extends it{constructor(t,e){super(t),this.feature=e}}function Hm(t,e){return x(t[0],t[1],e[0],e[1])}function Jm(t,e){const i=t.length;return e<0?t[e+i]:e>=i?t[e-i]:t[e]}function Qm(t,e,i){let n,r;eo){return Hm(s_(t,n),s_(t,r))}let a=0;if(n=i?n-=i:n<0&&(n+=i);let s=n+1;s>=i&&(s-=i);const o=t[n],a=o[0],l=o[1],h=t[s];return[a+(h[0]-a)*r,l+(h[1]-l)*r]}function o_(){const t=es();return function(e,i){return t[e.getGeometry().getType()]}}var a_=class extends fh{constructor(t){const e=t;e.stopDown||(e.stopDown=ht),super(e),this.on,this.once,this.un,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=t.source?t.source:null,this.features_=t.features?t.features:null,this.snapTolerance_=t.snapTolerance?t.snapTolerance:12,this.type_=t.type,this.mode_=function(t){switch(t){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+t)}}(this.type_),this.stopClick_=!!t.stopClick,this.minPoints_=t.minPoints?t.minPoints:"Polygon"===this.mode_?3:2,this.maxPoints_="Circle"===this.mode_?2:t.maxPoints?t.maxPoints:1/0,this.finishCondition_=t.finishCondition?t.finishCondition:lt,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let i=t.geometryFunction;if(!i){const t=this.mode_;if("Circle"===t)i=(t,e,i)=>{const n=e||new qn([NaN,NaN]),r=Fn(t[0],i),s=qi(r,Fn(t[t.length-1],i));n.setCenterAndRadius(r,Math.sqrt(s),this.geometryLayout_);const o=Rn();return o&&n.transform(i,o),n};else{let e;"Point"===t?e=Fr:"LineString"===t?e=Cr:"Polygon"===t&&(e=Ur),i=(i,n,r)=>(n?"Polygon"===t?i[0].length?n.setCoordinates([i[0].concat([i[0][0]])],this.geometryLayout_):n.setCoordinates([],this.geometryLayout_):n.setCoordinates(i,this.geometryLayout_):n=new e(i,this.geometryLayout_),n)}}this.geometryFunction_=i,this.dragVertexDelay_=void 0!==t.dragVertexDelay?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new dl({source:new Fl({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:o_(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:Sh,this.freehandCondition_,t.freehand?this.freehandCondition_=xh:this.freehandCondition_=t.freehandCondition?t.freehandCondition:Eh,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(uh,this.updateState_)}setTrace(t){let e;e=t?!0===t?xh:t:wh,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}getOverlay(){return this.overlay_}handleEvent(t){t.originalEvent.type===yt&&t.originalEvent.preventDefault(),this.freehand_="Point"!==this.mode_&&this.freehandCondition_(t);let e=t.type===Bl.POINTERMOVE,i=!0;if(!this.freehand_&&this.lastDragTime_&&t.type===Bl.POINTERDRAG){Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&void 0!==this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)}return this.freehand_&&t.type===Bl.POINTERDRAG&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===Bl.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===Bl.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===Bl.POINTERDRAG&&void 0===this.downTimeout_)&&this.handlePointerMove_(t)):t.type===Bl.DBLCLICK&&(i=!1),super.handleEvent(t)&&i}handleDownEvent(t){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=t.pixel,this.finishCoordinate_||this.startDrawing_(t.coordinate),!0):this.condition_(t)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout((()=>{this.handlePointerMove_(new $l(Bl.POINTERMOVE,t.map,t.originalEvent,!1,t.frameState))}),this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active)return void this.deactivateTrace_();const e=this.getMap(),i=Be([e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_])]),n=this.traceSource_.getFeaturesInExtent(i);if(0===n.length)return;const r=function(t,e){const i=[];for(let n=0;nt.endIndex||!i&&et.endIndex)&&this.removeTracedCoordinates_(e,t.endIndex):(this.removeTracedCoordinates_(t.startIndex,t.endIndex),this.addTracedCoordinates_(t,t.startIndex,e))}removeTracedCoordinates_(t,e){if(t===e)return;let i=0;if(t0&&this.removeLastPoints_(i)}addTracedCoordinates_(t,e,i){if(e===i)return;const n=[];if(e=s;--e)n.push(Jm(t.coordinates,e))}n.length&&this.appendCoordinates(n)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&Yi(e.startPx,t.pixel)i.startIndex?hi.startIndex&&(h-=n.length)),l=h,a=t)}const h=e.targets[a];let u=h.ring;if(e.targetIndex===a&&u){const t=s_(h.coordinates,l);Yi(i.getPixelFromCoordinate(t),e.startPx)>n&&(u=!1)}if(u){const t=h.coordinates,e=t.length,i=h.startIndex,n=l;if(ithis.squaredClickTolerance_:s<=this.squaredClickTolerance_,!this.shouldHandle_)return}this.finishCoordinate_?(this.updateTrace_(t),this.modifyDrawing_(t.coordinate)):this.createOrUpdateSketchPoint_(t.coordinate.slice())}atFinish_(t,e){let i=!1;if(this.sketchFeature_){let n=!1,r=[this.finishCoordinate_];const s=this.mode_;if("Point"===s)i=!0;else if("Circle"===s)i=2===this.sketchCoords_.length;else if("LineString"===s)n=!e&&this.sketchCoords_.length>this.minPoints_;else if("Polygon"===s){const t=this.sketchCoords_;n=t[0].length>this.minPoints_,r=[t[0][0],t[0][t[0].length-2]],r=e?[t[0][0]]:[t[0][0],t[0][t[0].length-2]]}if(n){const e=this.getMap();for(let n=0,s=r.length;n=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),this.geometryFunction_(r,e,i)):"Polygon"===s&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),n&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,i)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),n?this.finishDrawing():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),n=this.mode_;for(let r=0;r=2){this.finishCoordinate_=t[t.length-2].slice();const e=this.finishCoordinate_.slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}this.geometryFunction_(t,e,i),"Polygon"===e.getType()&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if("Polygon"===n){t=this.sketchCoords_[0],t.splice(-2,1);const n=this.sketchLine_.getGeometry();if(t.length>=2){const e=t[t.length-2].slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}n.setCoordinates(t),this.geometryFunction_(this.sketchCoords_,e,i)}if(1===t.length){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return null;let e=this.sketchCoords_;const i=t.getGeometry(),n=this.getMap().getView().getProjection();return"LineString"===this.mode_?(e.pop(),this.geometryFunction_(e,i,n)):"Polygon"===this.mode_&&(e[0].pop(),this.geometryFunction_(e,i,n),e=i.getCoordinates()),"MultiPoint"===this.type_?t.setGeometry(new Mr([e])):"MultiLineString"===this.type_?t.setGeometry(new Rr([e])):"MultiPolygon"===this.type_&&t.setGeometry(new Xr([e])),this.dispatchEvent(new Km(Ym,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t),t}abortDrawing_(){this.finishCoordinate_=null;const t=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),t}abortDrawing(){const t=this.abortDrawing_();t&&this.dispatchEvent(new Km(Zm,t))}appendCoordinates(t){const e=this.mode_,i=!this.sketchFeature_;let n;if(i&&this.startDrawing_(t[0]),"LineString"===e||"Circle"===e)n=this.sketchCoords_;else{if("Polygon"!==e)return;n=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[]}i&&n.shift(),n.pop();for(let e=0;er?o[1]:o[0]),a}}return null}handlePointerMove_(t){const e=t.pixel,i=t.map;let n=this.snapToVertex_(e,i);n||(n=i.getCoordinateFromPixelInternal(e)),this.createOrUpdatePointerFeature_(n)}createOrUpdateExtentFeature_(t){let e=this.extentFeature_;return e?t?e.setGeometry($r(t)):e.setGeometry(void 0):(e=new Me(t?$r(t):{}),this.extentFeature_=e,this.extentOverlay_.getSource().addFeature(e)),e}createOrUpdatePointerFeature_(t){let e=this.vertexFeature_;if(e){e.getGeometry().setCoordinates(t)}else e=new Me(new Fr(t)),this.vertexFeature_=e,this.vertexOverlay_.getSource().addFeature(e);return e}handleEvent(t){return!t.originalEvent||!this.condition_(t)||(t.type!=Bl.POINTERMOVE||this.handlingDownUpSequence||this.handlePointerMove_(t),super.handleEvent(t),!1)}handleDownEvent(t){const e=t.pixel,i=t.map,n=this.getExtentInternal();let r=this.snapToVertex_(e,i);const s=function(t){let e=null,i=null;return t[0]==n[0]?e=n[2]:t[0]==n[2]&&(e=n[0]),t[1]==n[1]?i=n[3]:t[1]==n[3]&&(i=n[1]),null!==e&&null!==i?[e,i]:null};if(r&&n){const t=r[0]==n[0]||r[0]==n[2]?r[0]:null,e=r[1]==n[1]||r[1]==n[3]?r[1]:null;null!==t&&null!==e?this.pointerHandler_=d_(s(r)):null!==t?this.pointerHandler_=g_(s([t,n[1]]),s([t,n[3]])):null!==e&&(this.pointerHandler_=g_(s([n[0],e]),s([n[2],e])))}else r=i.getCoordinateFromPixelInternal(e),this.setExtent([r[0],r[1],r[0],r[1]]),this.pointerHandler_=d_(r);return!0}handleDragEvent(t){if(this.pointerHandler_){const e=t.coordinate;this.setExtent(this.pointerHandler_(e)),this.createOrUpdatePointerFeature_(e)}}handleUpEvent(t){this.pointerHandler_=null;const e=this.getExtentInternal();return e&&0!==li(e)||this.setExtent(null),!1}setMap(t){this.extentOverlay_.setMap(t),this.vertexOverlay_.setMap(t),super.setMap(t)}getExtent(){return In(this.getExtentInternal(),this.getMap().getView().getProjection())}getExtentInternal(){return this.extent_}setExtent(t){this.extent_=t||null,this.createOrUpdateExtentFeature_(t),this.dispatchEvent(new h_(this.extent_))}};function f_(t){return parseFloat(t)}function m_(t){return function(t){return E(t,5)}(t).toString()}function __(t,e){return!isNaN(t)&&t!==f_(m_(e))}var y_=class extends dh{constructor(t){let e;super(),e=!0===(t=Object.assign({animate:!0,params:["x","y","z","r","l"],replace:!1,prefix:""},t||{})).animate?{duration:250}:t.animate?t.animate:null,this.animationOptions_=e,this.params_=t.params.reduce(((t,e)=>(t[e]=!0,t)),{}),this.replace_=t.replace,this.prefix_=t.prefix,this.listenerKeys_=[],this.initial_=!0,this.updateState_=this.updateState_.bind(this),this.trackedCallbacks_={},this.trackedValues_={}}getParamName_(t){return this.prefix_?this.prefix_+t:t}get_(t,e){return t.get(this.getParamName_(e))}set_(t,e,i){e in this.params_&&t.set(this.getParamName_(e),i)}delete_(t,e){e in this.params_&&t.delete(this.getParamName_(e))}setMap(t){const e=this.getMap();super.setMap(t),t!==e&&(e&&this.unregisterListeners_(e),t&&(this.initial_=!0,this.updateState_(),this.registerListeners_(t)))}registerListeners_(t){this.listenerKeys_.push(Ft(t,Zl,this.updateUrl_,this),Ft(t.getLayerGroup(),mt,this.updateUrl_,this),Ft(t,"change:layergroup",this.handleChangeLayerGroup_,this)),this.replace_||addEventListener("popstate",this.updateState_)}unregisterListeners_(t){for(let t=0,e=this.listenerKeys_.length;t=0;--t){const n=i[t];for(let t=this.dragSegments_.length-1;t>=0;--t)this.dragSegments_[t][0]===n&&this.dragSegments_.splice(t,1);e.remove(n)}}setActive(t){this.vertexFeature_&&!t&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(t)}setMap(t){this.overlay_.setMap(t),super.setMap(t)}getOverlay(){return this.overlay_}handleSourceAdd_(t){t.feature&&this.features_.push(t.feature)}handleSourceRemove_(t){t.feature&&this.features_.remove(t.feature)}handleFeatureAdd_(t){this.addFeature_(t.element)}handleFeatureChange_(t){if(!this.changingFeature_){const e=t.target;this.removeFeature_(e),this.addFeature_(e)}}handleFeatureRemove_(t){this.removeFeature_(t.element)}writePointGeometry_(t,e){const i=e.getCoordinates(),n={feature:t,geometry:e,segment:[i,i]};this.rBush_.insert(e.getExtent(),n)}writeMultiPointGeometry_(t,e){const i=e.getCoordinates();for(let n=0,r=i.length;n=0;--t)this.insertVertex_(s[t],o)}return!!this.vertexFeature_}handleUpEvent(t){for(let e=this.dragSegments_.length-1;e>=0;--e){const i=this.dragSegments_[e][0],n=i.geometry;if("Circle"===n.getType()){const e=n.getCenter(),r=i.featureSegments[0],s=i.featureSegments[1];r.segment[0]=e,r.segment[1]=e,s.segment[0]=e,s.segment[1]=e,this.rBush_.update(ti(e),r);let o=n;const a=Rn();if(a){const e=t.map.getView().getProjection();o=o.clone().transform(a,e),o=Br(o).transform(e,a)}this.rBush_.update(o.getExtent(),s)}else this.rBush_.update(Be(i.segment),i)}return this.featuresBeingModified_&&(this.dispatchEvent(new S_(b_,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastPixel_=t.pixel,this.handlePointerAtPixel_(t.pixel,t.map,t.coordinate)}handlePointerAtPixel_(t,e,i){const n=i||e.getCoordinateFromPixel(t),s=e.getView().getProjection(),o=function(t,e){return C_(n,t,s)-C_(n,e,s)};let a,l;if(this.hitDetection_){const i="object"==typeof this.hitDetection_?t=>t===this.hitDetection_:void 0;e.forEachFeatureAtPixel(t,((t,e,i)=>{i&&"Point"===i.getType()&&(i=new Fr(Pn(i.getCoordinates(),s)));const n=i||t.getGeometry();if(t instanceof Me&&this.features_.getArray().includes(t)){l=n;const e=t.getGeometry().getFlatCoordinates().slice(0,2);a=[{feature:t,geometry:l,segment:[e,e]}]}return!0}),{layerFilter:i})}if(!a){const t=In(Ve(Mn(ti(n,x_),s),e.getView().getResolution()*this.pixelTolerance_,x_),s);a=this.rBush_.getInExtent(t)}if(a&&a.length>0){const i=a.sort(o)[0],h=i.segment;let u=T_(n,i,s);const c=e.getPixelFromCoordinate(u);let d=Yi(t,c);if(l||d<=this.pixelTolerance_){const t={};if(t[r(h)]=!0,this.snapToPointer_||(this.delta_[0]=u[0]-n[0],this.delta_[1]=u[1]-n[1]),"Circle"===i.geometry.getType()&&1===i.index)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(u,[i.feature],[i.geometry]);else{const n=e.getPixelFromCoordinate(h[0]),s=e.getPixelFromCoordinate(h[1]),o=qi(c,n),l=qi(c,s);d=Math.sqrt(Math.min(o,l)),this.snappedToVertex_=d<=this.pixelTolerance_,this.snappedToVertex_&&(u=o>l?h[1]:h[0]),this.createOrUpdateVertexFeature_(u,[i.feature],[i.geometry]);const g={};g[r(i.geometry)]=!0;for(let e=1,i=a.length;e=0;--a)s=t[a],d=s[0],g=r(d.feature),d.depth&&(g+="-"+d.depth.join("-")),g in e||(e[g]={}),0===s[1]?(e[g].right=d,e[g].index=d.index):1==s[1]&&(e[g].left=d,e[g].index=d.index+1);for(g in e){switch(c=e[g].right,h=e[g].left,l=e[g].index,u=l-1,d=void 0!==h?h:c,u<0&&(u=0),o=d.geometry,n=o.getCoordinates(),i=n,p=!1,o.getType()){case"MultiLineString":n[d.depth[0]].length>2&&(n[d.depth[0]].splice(l,1),p=!0);break;case"LineString":n.length>2&&(n.splice(l,1),p=!0);break;case"MultiPolygon":i=i[d.depth[1]];case"Polygon":i=i[d.depth[0]],i.length>4&&(l==i.length-1&&(l=0),i.splice(l,1),p=!0,0===l&&(i.pop(),i.push(i[0]),u=i.length-1))}if(p){this.setGeometryCoordinates_(o,n);const e=[];if(void 0!==h&&(this.rBush_.remove(h),e.push(h.segment[0])),void 0!==c&&(this.rBush_.remove(c),e.push(c.segment[1])),void 0!==h&&void 0!==c){const t={depth:d.depth,feature:d.feature,geometry:d.geometry,index:u,segment:e};this.rBush_.insert(Be(t.segment),t)}this.updateSegmentIndices_(o,l,d.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return p}setGeometryCoordinates_(t,e){this.changingFeature_=!0,t.setCoordinates(e),this.changingFeature_=!1}updateSegmentIndices_(t,e,i,n){this.rBush_.forEachInExtent(t.getExtent(),(function(r){r.geometry===t&&(void 0===i||void 0===r.depth||at(r.depth,i))&&r.index>e&&(r.index+=n)}))}};const F_="select";class I_ extends it{constructor(t,e,i,n){super(t),this.selected=e,this.deselected=i,this.mapBrowserEvent=n}}const M_={};class L_ extends dh{constructor(t){let e;if(super(),this.on,this.once,this.un,t=t||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=t.condition?t.condition:bh,this.addCondition_=t.addCondition?t.addCondition:wh,this.removeCondition_=t.removeCondition?t.removeCondition:wh,this.toggleCondition_=t.toggleCondition?t.toggleCondition:Eh,this.multi_=!!t.multi&&t.multi,this.filter_=t.filter?t.filter:lt,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.style_=void 0!==t.style?t.style:function(){const t=es();return ot(t.Polygon,t.LineString),ot(t.GeometryCollection,t.LineString),function(e){return e.getGeometry()?t[e.getGeometry().getType()]:null}}(),this.features_=t.features||new cs,t.layers)if("function"==typeof t.layers)e=t.layers;else{const i=t.layers;e=function(t){return i.includes(t)}}else e=lt;this.layerFilter_=e,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(t,e){this.featureLayerAssociation_[r(t)]=e}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(t){return this.featureLayerAssociation_[r(t)]}setHitTolerance(t){this.hitTolerance_=t}setMap(t){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(t),t?(this.features_.addEventListener(as,this.boundAddFeature_),this.features_.addEventListener(ls,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(as,this.boundAddFeature_),this.features_.removeEventListener(ls,this.boundRemoveFeature_))}addFeature_(t){const e=t.element;if(this.style_&&this.applySelectedStyle_(e),!this.getLayer(e)){const t=this.getMap().getAllLayers().find((function(t){if(t instanceof dl&&t.getSource()&&t.getSource().hasFeature(e))return t}));t&&this.addFeatureLayerAssociation_(e,t)}}removeFeature_(t){this.style_&&this.restorePreviousStyle_(t.element)}getStyle(){return this.style_}applySelectedStyle_(t){const e=r(t);e in M_||(M_[e]=t.getStyle()),t.setStyle(this.style_)}restorePreviousStyle_(t){const e=this.getMap().getInteractions().getArray();for(let i=e.length-1;i>=0;--i){const n=e[i];if(n!==this&&n instanceof L_&&n.getStyle()&&-1!==n.getFeatures().getArray().lastIndexOf(t))return void t.setStyle(n.getStyle())}const i=r(t);t.setStyle(M_[i]),delete M_[i]}removeFeatureLayerAssociation_(t){delete this.featureLayerAssociation_[r(t)]}handleEvent(t){if(!this.condition_(t))return!0;const e=this.addCondition_(t),i=this.removeCondition_(t),n=this.toggleCondition_(t),r=!e&&!i&&!n,s=t.map,o=this.getFeatures(),a=[],l=[];if(r){gt(this.featureLayerAssociation_),s.forEachFeatureAtPixel(t.pixel,((t,e)=>{if(t instanceof Me&&this.filter_(t,e))return this.addFeatureLayerAssociation_(t,e),l.push(t),!this.multi_}),{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let t=o.getLength()-1;t>=0;--t){const e=o.item(t),i=l.indexOf(e);i>-1?l.splice(i,1):(o.remove(e),a.push(e))}0!==l.length&&o.extend(l)}else{s.forEachFeatureAtPixel(t.pixel,((t,r)=>{if(t instanceof Me&&this.filter_(t,r))return!e&&!n||o.getArray().includes(t)?(i||n)&&o.getArray().includes(t)&&(a.push(t),this.removeFeatureLayerAssociation_(t)):(this.addFeatureLayerAssociation_(t,r),l.push(t)),!this.multi_}),{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let t=a.length-1;t>=0;--t)o.remove(a[t]);o.extend(l)}return(l.length>0||a.length>0)&&this.dispatchEvent(new I_(F_,l,a,t)),!0}}var k_=L_;const D_="snap";class A_ extends it{constructor(t,e){super(t),this.vertex=e.vertex,this.vertexPixel=e.vertexPixel,this.feature=e.feature,this.segment=e.segment}}function O_(t){return t.feature?t.feature:t.element?t.element:null}const z_=[];var G_=class extends fh{constructor(t){const e=t=t||{};e.handleDownEvent||(e.handleDownEvent=lt),e.stopDown||(e.stopDown=ht),super(e),this.on,this.once,this.un,this.source_=t.source?t.source:null,this.vertex_=void 0===t.vertex||t.vertex,this.edge_=void 0===t.edge||t.edge,this.features_=t.features?t.features:null,this.featuresListenerKeys_=[],this.featureChangeListenerKeys_={},this.indexedFeaturesExtents_={},this.pendingFeatures_={},this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.rBush_=new gl,this.GEOMETRY_SEGMENTERS_={Point:this.segmentPointGeometry_.bind(this),LineString:this.segmentLineStringGeometry_.bind(this),LinearRing:this.segmentLineStringGeometry_.bind(this),Polygon:this.segmentPolygonGeometry_.bind(this),MultiPoint:this.segmentMultiPointGeometry_.bind(this),MultiLineString:this.segmentMultiLineStringGeometry_.bind(this),MultiPolygon:this.segmentMultiPolygonGeometry_.bind(this),GeometryCollection:this.segmentGeometryCollectionGeometry_.bind(this),Circle:this.segmentCircleGeometry_.bind(this)}}addFeature(t,e){e=void 0===e||e;const i=r(t),n=t.getGeometry();if(n){const e=this.GEOMETRY_SEGMENTERS_[n.getType()];if(e){this.indexedFeaturesExtents_[i]=n.getExtent([1/0,1/0,-1/0,-1/0]);const r=[];if(e(r,n),1===r.length)this.rBush_.insert(Be(r[0]),{feature:t,segment:r[0]});else if(r.length>1){const e=r.map((t=>Be(t))),i=r.map((e=>({feature:t,segment:e})));this.rBush_.load(e,i)}}}e&&(this.featureChangeListenerKeys_[i]=Ft(t,mt,this.handleFeatureChange_,this))}getFeatures_(){let t;return this.features_?t=this.features_:this.source_&&(t=this.source_.getFeatures()),t}handleEvent(t){const e=this.snapTo(t.pixel,t.coordinate,t.map);return e&&(t.coordinate=e.vertex.slice(0,2),t.pixel=e.vertexPixel,this.dispatchEvent(new A_(D_,{vertex:t.coordinate,vertexPixel:t.pixel,feature:e.feature,segment:e.segment}))),super.handleEvent(t)}handleFeatureAdd_(t){const e=O_(t);e&&this.addFeature(e)}handleFeatureRemove_(t){const e=O_(t);e&&this.removeFeature(e)}handleFeatureChange_(t){const e=t.target;if(this.handlingDownUpSequence){const t=r(e);t in this.pendingFeatures_||(this.pendingFeatures_[t]=e)}else this.updateFeature_(e)}handleUpEvent(t){const e=Object.values(this.pendingFeatures_);return e.length&&(e.forEach(this.updateFeature_.bind(this)),this.pendingFeatures_={}),!1}removeFeature(t,e){const i=void 0===e||e,n=r(t),s=this.indexedFeaturesExtents_[n];if(s){const e=this.rBush_,i=[];e.forEachInExtent(s,(function(e){t===e.feature&&i.push(e)}));for(let t=i.length-1;t>=0;--t)e.remove(i[t])}i&&(Mt(this.featureChangeListenerKeys_[n]),delete this.featureChangeListenerKeys_[n])}setMap(t){const e=this.getMap(),i=this.featuresListenerKeys_,n=this.getFeatures_();e&&(i.forEach(Mt),i.length=0,this.rBush_.clear(),Object.values(this.featureChangeListenerKeys_).forEach(Mt),this.featureChangeListenerKeys_={}),super.setMap(t),t&&(this.features_?i.push(Ft(this.features_,as,this.handleFeatureAdd_,this),Ft(this.features_,ls,this.handleFeatureRemove_,this)):this.source_&&i.push(Ft(this.source_,ml,this.handleFeatureAdd_,this),Ft(this.source_,xl,this.handleFeatureRemove_,this)),n.forEach((t=>this.addFeature(t))))}snapTo(t,e,i){const n=i.getView().getProjection(),r=Fn(e,n),s=In(Ve(Be([r]),i.getView().getResolution()*this.pixelTolerance_),n),o=this.rBush_.getInExtent(s),a=o.length;if(0===a)return null;let l,h,u=1/0,c=null;const d=this.pixelTolerance_*this.pixelTolerance_,g=()=>{if(l){const e=i.getPixelFromCoordinate(l);if(qi(t,e)<=d)return{vertex:l,vertexPixel:[Math.round(e[0]),Math.round(e[1])],feature:h,segment:c}}return null};if(this.vertex_){for(let t=0;t{const i=Fn(t,n),s=qi(r,i);s{t.push([e])}))}segmentMultiPolygonGeometry_(t,e){const i=e.getCoordinates();for(let e=0,n=i.length;e{if(t instanceof Me&&this.filter_(t,e)&&(!this.features_||this.features_.getArray().includes(t)))return t}),{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_})}getHitTolerance(){return this.hitTolerance_}setHitTolerance(t){this.hitTolerance_=t}setMap(t){const e=this.getMap();super.setMap(t),this.updateState_(e)}handleActiveChanged_(){this.updateState_(null)}updateState_(t){let e=this.getMap();const i=this.getActive();if((!e||!i)&&(e=e||t,e)){e.getViewport().classList.remove("ol-grab","ol-grabbing")}}},V_=Object.freeze({__proto__:null,DoubleClickZoom:gh,DblClickDragZoom:$m,DragAndDrop:Wm,DragBox:Oh,DragPan:Ph,DragRotate:Fh,DragRotateAndZoom:Xm,DragZoom:zh,Draw:a_,Extent:p_,Interaction:dh,KeyboardPan:$h,KeyboardZoom:Bh,Link:y_,Modify:P_,MouseWheelZoom:Vh,PinchRotate:Wh,PinchZoom:Xh,Pointer:fh,Select:k_,Snap:G_,Translate:B_,defaults:qh});const W_="http://www.w3.org/2001/XMLSchema-instance";function X_(t,e){return cy().createElementNS(t,e)}function q_(t,e){return Y_(t,e,[]).join("")}function Y_(t,e,i){if(t.nodeType==Node.CDATA_SECTION_NODE||t.nodeType==Node.TEXT_NODE)e?i.push(String(t.nodeValue).replace(/(\r\n|\r|\n)/g,"")):i.push(t.nodeValue);else{let n;for(n=t.firstChild;n;n=n.nextSibling)Y_(n,e,i)}return i}function Z_(t){return"documentElement"in t}function K_(t){return(new DOMParser).parseFromString(t,"application/xml")}function H_(t,e){return function(i,n){const r=t.call(e??this,i,n);if(void 0!==r){ot(n[n.length-1],r)}}}function J_(t,e){return function(i,n){const r=t.call(e??this,i,n);if(void 0!==r){n[n.length-1].push(r)}}}function Q_(t,e){return function(i,n){const r=t.call(e??this,i,n);void 0!==r&&(n[n.length-1]=r)}}function ty(t,e,i){return function(n,r){const s=t.call(i??this,n,r);if(void 0!==s){r[r.length-1][void 0!==e?e:n.localName]=s}}}function ey(t,e){return function(i,n,r){t.call(e??this,i,n,r);r[r.length-1].node.appendChild(i)}}function iy(t,e){return function(i,n,r){const s=n[n.length-1].node;let o=t;void 0===o&&(o=r);return X_(void 0!==e?e:s.namespaceURI,o)}}const ny=iy();function ry(t,e){const i=e.length,n=new Array(i);for(let r=0;r0?i[0]:null}readFeatureFromNode(t,e){return null}readFeatures(t,e){if(!t)return[];if("string"==typeof t){const i=K_(t);return this.readFeaturesFromDocument(i,e)}return Z_(t)?this.readFeaturesFromDocument(t,e):this.readFeaturesFromNode(t,e)}readFeaturesFromDocument(t,e){const i=[];for(let n=t.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&ot(i,this.readFeaturesFromNode(n,e));return i}readFeaturesFromNode(t,e){return i()}readGeometry(t,e){if(!t)return null;if("string"==typeof t){const i=K_(t);return this.readGeometryFromDocument(i,e)}return Z_(t)?this.readGeometryFromDocument(t,e):this.readGeometryFromNode(t,e)}readGeometryFromDocument(t,e){return null}readGeometryFromNode(t,e){return null}readProjection(t){if(!t)return null;if("string"==typeof t){const e=K_(t);return this.readProjectionFromDocument(e)}return Z_(t)?this.readProjectionFromDocument(t):this.readProjectionFromNode(t)}readProjectionFromDocument(t){return this.dataProjection}readProjectionFromNode(t){return this.dataProjection}writeFeature(t,e){const i=this.writeFeatureNode(t,e);return this.xmlSerializer_.serializeToString(i)}writeFeatureNode(t,e){return null}writeFeatures(t,e){const i=this.writeFeaturesNode(t,e);return this.xmlSerializer_.serializeToString(i)}writeFeaturesNode(t,e){return null}writeGeometry(t,e){const i=this.writeGeometryNode(t,e);return this.xmlSerializer_.serializeToString(i)}writeGeometryNode(t,e){return null}};function gy(t){return function(t){const e=/^\s*(true|1)|(false|0)\s*$/.exec(t);if(e)return void 0!==e[1]||!1;return}(q_(t,!1))}function py(t){return function(t){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(t);if(e)return parseFloat(e[1]);return}(q_(t,!1))}function fy(t){return q_(t,!1).trim()}function my(t,e){yy(t,e?"1":"0")}function _y(t,e){const i=e.toPrecision();t.appendChild(cy().createTextNode(i))}function yy(t,e){t.appendChild(cy().createTextNode(e))}const xy=["http://www.google.com/kml/ext/2.2"],vy=[null,"http://earth.google.com/kml/2.0","http://earth.google.com/kml/2.1","http://earth.google.com/kml/2.2","http://www.opengis.net/kml/2.2"],wy={fraction:"fraction",pixels:"pixels",insetPixels:"pixels"},by=sy(vy,{ExtendedData:Cx,Region:Tx,MultiGeometry:ty(mx,"geometry"),LineString:ty(gx,"geometry"),LinearRing:ty(px,"geometry"),Point:ty(_x,"geometry"),Polygon:ty(xx,"geometry"),Style:ty(wx),StyleMap:function(t,e){const i=Qy.call(this,t,e);if(!i)return;const n=e[e.length-1];if(Array.isArray(i))n.Style=i;else{if("string"!=typeof i)throw new Error("`styleMapValue` has an unknown type");n.styleUrl=i}},address:ty(fy),description:ty(fy),name:ty(fy),open:ty(gy),phoneNumber:ty(fy),styleUrl:ty(Ky),visibility:ty(gy)},sy(xy,{MultiTrack:ty((function(t,e){const i=ay([],ox,t,e);if(!i)return;return new Rr(i)}),"geometry"),Track:ty(lx,"geometry")})),Sy=sy(vy,{ExtendedData:Cx,Region:Tx,Link:function(t,e){oy(Ey,t,e)},address:ty(fy),description:ty(fy),name:ty(fy),open:ty(gy),phoneNumber:ty(fy),visibility:ty(gy)}),Ey=sy(vy,{href:ty(Zy)}),Cy=sy(vy,{Altitude:ty(py),Longitude:ty(py),Latitude:ty(py),Tilt:ty(py),AltitudeMode:ty(fy),Heading:ty(py),Roll:ty(py)}),Ty=sy(vy,{LatLonAltBox:function(t,e){const i=ay({},Fx,t,e);if(!i)return;const n=e[e.length-1],r=[parseFloat(i.west),parseFloat(i.south),parseFloat(i.east),parseFloat(i.north)];n.extent=r,n.altitudeMode=i.altitudeMode,n.minAltitude=parseFloat(i.minAltitude),n.maxAltitude=parseFloat(i.maxAltitude)},Lod:function(t,e){const i=ay({},Ix,t,e);if(!i)return;const n=e[e.length-1];n.minLodPixels=parseFloat(i.minLodPixels),n.maxLodPixels=parseFloat(i.maxLodPixels),n.minFadeExtent=parseFloat(i.minFadeExtent),n.maxFadeExtent=parseFloat(i.maxFadeExtent)}}),Ry=sy(vy,["Document","Placemark"]),Py=sy(vy,{Document:ey((function(t,e,i){ly({node:t},Ax,Ox,e,i,void 0,this)})),Placemark:ey(ov)});let Fy,Iy,My,Ly,ky,Dy,Ay,Oy,zy,Gy=null,Ny=null,jy=null,Uy=null,$y=null,By=null;function Vy(t){return 32/Math.min(t[0],t[1])}function Wy(t){return t}function Xy(t,e,i){return Array.isArray(t)?t:"string"==typeof t?Xy(i[t],e,i):e}function qy(t){const e=q_(t,!1),i=/^\s*#?\s*([0-9A-Fa-f]{8})\s*$/.exec(e);if(i){const t=i[1];return[parseInt(t.substr(6,2),16),parseInt(t.substr(4,2),16),parseInt(t.substr(2,2),16),parseInt(t.substr(0,2),16)/255]}}function Yy(t){let e=q_(t,!1);const i=[];e=e.replace(/\s*,\s*/g,",");const n=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?),([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|,|$)(?:([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|$))?\s*/i;let r;for(;r=n.exec(e);){const t=parseFloat(r[1]),n=parseFloat(r[2]),s=r[3]?parseFloat(r[3]):0;i.push(t,n,s),e=e.substr(r[0].length)}if(""===e)return i}function Zy(t){const e=q_(t,!1).trim();let i=t.baseURI;if(i&&"about:blank"!=i||(i=window.location.href),i){return new URL(e,i).href}return e}function Ky(t){const e=q_(t,!1).trim().replace(/^(?!.*#)/,"#");let i=t.baseURI;if(i&&"about:blank"!=i||(i=window.location.href),i){return new URL(e,i).href}return e}function Hy(t){return py(t)}const Jy=sy(vy,{Pair:function(t,e){const i=ay({},Rx,t,e,this);if(!i)return;const n=i.key;if(n&&"normal"==n){const t=i.styleUrl;t&&(e[e.length-1]=t);const n=i.Style;n&&(e[e.length-1]=n)}}});function Qy(t,e){return ay(void 0,Jy,t,e,this)}const tx=sy(vy,{Icon:ty((function(t,e){const i=ay({},hx,t,e);if(i)return i;return null})),color:ty(qy),heading:ty(py),hotSpot:ty((function(t){const e=t.getAttribute("xunits"),i=t.getAttribute("yunits");let n;return n="insetPixels"!==e?"insetPixels"!==i?"bottom-left":"top-left":"insetPixels"!==i?"bottom-right":"top-right",{x:parseFloat(t.getAttribute("x")),xunits:wy[e],y:parseFloat(t.getAttribute("y")),yunits:wy[i],origin:n}})),scale:ty(Hy)});const ex=sy(vy,{color:ty(qy),scale:ty(Hy)});const ix=sy(vy,{color:ty(qy),width:ty(py)});const nx=sy(vy,{color:ty(qy),fill:ty(gy),outline:ty(gy)});const rx=sy(vy,{coordinates:Q_(Yy)});function sx(t,e){return ay(null,rx,t,e)}const ox=sy(xy,{Track:J_(lx)});const ax=sy(vy,{when:function(t,e){const i=e[e.length-1].whens,n=q_(t,!1),r=Date.parse(n);i.push(isNaN(r)?0:r)}},sy(xy,{coord:function(t,e){const i=e[e.length-1].coordinates,n=q_(t,!1),r=/^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*$/i.exec(n);if(r){const t=parseFloat(r[1]),e=parseFloat(r[2]),n=parseFloat(r[3]);i.push([t,e,n])}else i.push([])}}));function lx(t,e){const i=ay({coordinates:[],whens:[]},ax,t,e);if(!i)return;const n=[],r=i.coordinates,s=i.whens;for(let t=0,e=Math.min(r.length,s.length);t0){e[e.length-1].push(...i)}},outerBoundaryIs:function(t,e){const i=ay(void 0,Lx,t,e);if(i){e[e.length-1][0]=i}}});function xx(t,e){const i=ay({},dx,t,e),n=ay([null],yx,t,e);if(n&&n[0]){const t=n[0],e=[t.length];for(let i=1,r=n.length;i0;let a;const l=s.href;let h,u,c;l?a=l:o&&(a=Dy);let d="bottom-left";const g=n.hotSpot;let p;g?(h=[g.x,g.y],u=g.xunits,c=g.yunits,d=g.origin):/^https?:\/\/maps\.(?:google|gstatic)\.com\//.test(a)&&(a.includes("pushpin")?(h=Iy,u=My,c=Ly):a.includes("arrow-reverse")?(h=[54,42],u=My,c=Ly):a.includes("paddle")&&(h=[32,1],u=My,c=Ly));const f=s.x,m=s.y;let _;void 0!==f&&void 0!==m&&(p=[f,m]);const y=s.w,x=s.h;let v;void 0!==y&&void 0!==x&&(_=[y,x]);const b=n.heading;void 0!==b&&(v=w(b));const S=n.scale,E=n.color;if(o){a==Dy&&(_=ky);const t=new Fe({anchor:h,anchorOrigin:d,anchorXUnits:u,anchorYUnits:c,crossOrigin:this.crossOrigin_,offset:p,offsetOrigin:"bottom-left",rotation:v,scale:S,size:_,src:this.iconUrlFunction_(a),color:E}),i=t.getScaleArray()[0],n=t.getSize();if(null===n){const n=t.getImageState();if(n===e.IDLE||n===e.LOADING){const r=function(){const n=t.getImageState();if(n!==e.IDLE&&n!==e.LOADING){const e=t.getSize();if(e&&2==e.length){const n=Vy(e);t.setScale(i*n)}t.unlistenImageChange(r)}};t.listenImageChange(r),n===e.IDLE&&t.load()}}else if(2==n.length){const e=Vy(n);t.setScale(i*e)}r.imageStyle=t}else r.imageStyle=Ay},LabelStyle:function(t,e){const i=ay({},ex,t,e);if(!i)return;const n=e[e.length-1],r=new ss({fill:new Ce({color:"color"in i?i.color:Fy}),scale:i.scale});n.textStyle=r},LineStyle:function(t,e){const i=ay({},ix,t,e);if(!i)return;const n=e[e.length-1],r=new Hr({color:"color"in i?i.color:Fy,width:"width"in i?i.width:1});n.strokeStyle=r},PolyStyle:function(t,e){const i=ay({},nx,t,e);if(!i)return;const n=e[e.length-1],r=new Ce({color:"color"in i?i.color:Fy});n.fillStyle=r;const s=i.fill;void 0!==s&&(n.fill=s);const o=i.outline;void 0!==o&&(n.outline=o)}});function wx(t,e){const i=ay({},vx,t,e,this);if(!i)return null;let n="fillStyle"in i?i.fillStyle:Gy;const r=i.fill;let s;void 0===r||r||(n=null),"imageStyle"in i?i.imageStyle!=Ay&&(s=i.imageStyle):s=Ny;const o="textStyle"in i?i.textStyle:Uy,a="strokeStyle"in i?i.strokeStyle:jy,l=i.outline;return void 0===l||l?[new ns({fill:n,image:s,stroke:a,text:o,zIndex:void 0})]:[new ns({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new Kn(e.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return"Polygon"!==e&&"MultiPolygon"!==e})))}if("Polygon"!==i&&"MultiPolygon"!==i)return e},fill:n,image:s,stroke:a,text:o,zIndex:void 0}),new ns({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new Kn(e.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return"Polygon"===e||"MultiPolygon"===e})))}if("Polygon"===i||"MultiPolygon"===i)return e},fill:n,stroke:null,zIndex:void 0})]}function bx(t,e){const i=e.length,n=new Array(e.length),r=new Array(e.length),s=new Array(e.length);let o,a,l;o=!1,a=!1,l=!1;for(let t=0;t0){const t=ry(r,o);ly(n,nv,sv,[{names:o,values:t}],i)}const c=i[0];let d=e.getGeometry();d&&(d=Cu(d,!0,c)),ly(n,nv,Yx,[d],i)}const av=sy(vy,["extrude","tessellate","altitudeMode","coordinates"]),lv=sy(vy,{extrude:ey(my),tessellate:ey(my),altitudeMode:ey(yy),coordinates:ey((function(t,e,i){const n=i[i.length-1],r=n.layout,s=n.stride;let o;if("XY"==r||"XYM"==r)o=2;else{if("XYZ"!=r&&"XYZM"!=r)throw new Error("Invalid geometry layout");o=3}const a=e.length;let l="";if(a>0){l+=e[0];for(let t=1;t0;else{const e=t.getType();a="Point"===e||"MultiPoint"===e}}a&&(l=s.get("name"),a=a&&!!l,a&&/&[^&]+;/.test(l)&&(zy||(zy=document.createElement("textarea")),zy.innerHTML=l,l=zy.value));let u=i;if(t?u=t:e&&(u=Xy(e,i,n)),a){const t=function(t,e){const i=[0,0];let n="start";const r=t.getImage();if(r){const t=r.getSize();if(t&&2==t.length){const e=r.getScaleArray(),s=r.getAnchor();i[0]=e[0]*(t[0]-s[0]),i[1]=e[1]*(t[1]/2-s[1]),n="left"}}let s=t.getText();s?(s=s.clone(),s.setFont(s.getFont()||Uy.getFont()),s.setScale(s.getScale()||Uy.getScale()),s.setFill(s.getFill()||Uy.getFill()),s.setStroke(s.getStroke()||Oy)):s=Uy.clone();s.setText(e),s.setOffsetX(i[0]),s.setOffsetY(i[1]),s.setTextAlign(n);const o=new ns({image:r,text:s});return o}(u[0],l);if(h.length>0){t.setGeometry(new Kn(h));return[t,new ns({geometry:u[0].getGeometry(),image:null,fill:u[0].getFill(),stroke:u[0].getStroke(),text:null})].concat(u.slice(1))}return t}return u}}(i.Style,i.styleUrl,this.defaultStyle_,this.sharedStyles_,this.showPointNames_);n.setStyle(t)}return delete i.Style,n.setProperties(i,!0),n}readSharedStyle_(t,e){const i=t.getAttribute("id");if(null!==i){const n=wx.call(this,t,e);if(n){let e,r=t.baseURI;if(r&&"about:blank"!=r||(r=window.location.href),r){e=new URL("#"+i,r).href}else e="#"+i;this.sharedStyles_[e]=n}}}readSharedStyleMap_(t,e){const i=t.getAttribute("id");if(null===i)return;const n=Qy.call(this,t,e);if(!n)return;let r,s=t.baseURI;if(s&&"about:blank"!=s||(s=window.location.href),s){r=new URL("#"+i,s).href}else r="#"+i;this.sharedStyles_[r]=n}readFeatureFromNode(t,e){if(!vy.includes(t.namespaceURI))return null;const i=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return i||null}readFeaturesFromNode(t,e){if(!vy.includes(t.namespaceURI))return[];let i;const n=t.localName;if("Document"==n||"Folder"==n)return i=this.readDocumentOrFolder_(t,[this.getReadOptions(t,e)]),i||[];if("Placemark"==n){const i=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return i?[i]:[]}if("kml"==n){i=[];for(let n=t.firstElementChild;n;n=n.nextElementSibling){const t=this.readFeaturesFromNode(n,e);t&&ot(i,t)}return i}return[]}readName(t){if(t){if("string"==typeof t){const e=K_(t);return this.readNameFromDocument(e)}return Z_(t)?this.readNameFromDocument(t):this.readNameFromNode(t)}}readNameFromDocument(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType==Node.ELEMENT_NODE){const t=this.readNameFromNode(e);if(t)return t}}readNameFromNode(t){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(vy.includes(e.namespaceURI)&&"name"==e.localName)return fy(e);for(let e=t.firstElementChild;e;e=e.nextElementSibling){const t=e.localName;if(vy.includes(e.namespaceURI)&&("Document"==t||"Folder"==t||"Placemark"==t||"kml"==t)){const t=this.readNameFromNode(e);if(t)return t}}}readNetworkLinks(t){const e=[];if("string"==typeof t){const i=K_(t);ot(e,this.readNetworkLinksFromDocument(i))}else Z_(t)?ot(e,this.readNetworkLinksFromDocument(t)):ot(e,this.readNetworkLinksFromNode(t));return e}readNetworkLinksFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&ot(e,this.readNetworkLinksFromNode(i));return e}readNetworkLinksFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(vy.includes(i.namespaceURI)&&"NetworkLink"==i.localName){const t=ay({},Sy,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!vy.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||ot(e,this.readNetworkLinksFromNode(i))}return e}readRegion(t){const e=[];if("string"==typeof t){const i=K_(t);ot(e,this.readRegionFromDocument(i))}else Z_(t)?ot(e,this.readRegionFromDocument(t)):ot(e,this.readRegionFromNode(t));return e}readRegionFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&ot(e,this.readRegionFromNode(i));return e}readRegionFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(vy.includes(i.namespaceURI)&&"Region"==i.localName){const t=ay({},Ty,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!vy.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||ot(e,this.readRegionFromNode(i))}return e}readCamera(t){const e=[];if("string"==typeof t){const i=K_(t);ot(e,this.readCameraFromDocument(i))}else Z_(t)?ot(e,this.readCameraFromDocument(t)):ot(e,this.readCameraFromNode(t));return e}readCameraFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType===Node.ELEMENT_NODE&&ot(e,this.readCameraFromNode(i));return e}readCameraFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(vy.includes(i.namespaceURI)&&"Camera"===i.localName){const t=ay({},Cy,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!vy.includes(i.namespaceURI)||"Document"!==t&&"Folder"!==t&&"Placemark"!==t&&"kml"!==t||ot(e,this.readCameraFromNode(i))}return e}writeFeaturesNode(t,e){e=this.adaptOptions(e);const i=X_(vy[4],"kml"),n="http://www.w3.org/2000/xmlns/";i.setAttributeNS(n,"xmlns:gx",xy[0]),i.setAttributeNS(n,"xmlns:xsi",W_),i.setAttributeNS(W_,"xsi:schemaLocation","http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd");const r={node:i},s={};t.length>1?s.Document=t:1==t.length&&(s.Placemark=t[0]);const o=Ry[i.namespaceURI],a=ry(s,o);return ly(r,Py,ny,a,[e],o,this),i}};const vv=34962,wv=34963,bv=35048,Sv=["experimental-webgl","webgl","webkit-3d","moz-webgl"];const Ev=35044;function Cv(t){switch(t){case vv:return Float32Array;case wv:return Uint32Array;default:return Float32Array}}var Tv=class{constructor(t,e){this.array_=null,this.type_=t,Te(t===vv||t===wv,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=void 0!==e?e:Ev}ofSize(t){return this.array_=new(Cv(this.type_))(t),this}fromArray(t){return this.array_=Cv(this.type_).from(t),this}fromArrayBuffer(t){return this.array_=new(Cv(this.type_))(t),this}getType(){return this.type_}getArray(){return this.array_}getUsage(){return this.usage_}getSize(){return this.array_?this.array_.length:0}},Rv="webglcontextlost",Pv="webglcontextrestored";var Fv=class{constructor(t){this.gl_=t.webGlContext;const e=this.gl_;this.scaleRatio_=t.scaleRatio||1,this.renderTargetTexture_=e.createTexture(),this.renderTargetTextureSize_=null,this.frameBuffer_=e.createFramebuffer(),this.depthBuffer_=e.createRenderbuffer();const i=e.createShader(e.VERTEX_SHADER);e.shaderSource(i,t.vertexShader||"\n precision mediump float;\n\n attribute vec2 a_position;\n varying vec2 v_texCoord;\n varying vec2 v_screenCoord;\n\n uniform vec2 u_screenSize;\n\n void main() {\n v_texCoord = a_position * 0.5 + 0.5;\n v_screenCoord = v_texCoord * u_screenSize;\n gl_Position = vec4(a_position, 0.0, 1.0);\n }\n"),e.compileShader(i);const n=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(n,t.fragmentShader||"\n precision mediump float;\n\n uniform sampler2D u_image;\n uniform float u_opacity;\n\n varying vec2 v_texCoord;\n\n void main() {\n gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;\n }\n"),e.compileShader(n),this.renderTargetProgram_=e.createProgram(),e.attachShader(this.renderTargetProgram_,i),e.attachShader(this.renderTargetProgram_,n),e.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,-1,1,1,-1,1]),e.STATIC_DRAW),this.renderTargetAttribLocation_=e.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],t.uniforms&&Object.keys(t.uniforms).forEach((i=>{this.uniforms_.push({value:t.uniforms[i],location:e.getUniformLocation(this.renderTargetProgram_,i)})}))}getGL(){return this.gl_}init(t){const e=this.getGL(),i=[e.drawingBufferWidth*this.scaleRatio_,e.drawingBufferHeight*this.scaleRatio_];if(e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer()),e.bindRenderbuffer(e.RENDERBUFFER,this.getDepthBuffer()),e.viewport(0,0,i[0],i[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==i[0]||this.renderTargetTextureSize_[1]!==i[1]){this.renderTargetTextureSize_=i;const t=0,n=e.RGBA,r=0,s=e.RGBA,o=e.UNSIGNED_BYTE,a=null;e.bindTexture(e.TEXTURE_2D,this.renderTargetTexture_),e.texImage2D(e.TEXTURE_2D,t,n,i[0],i[1],r,s,o,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.renderTargetTexture_,0),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i[0],i[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthBuffer_)}}apply(t,e,i,n){const s=this.getGL(),o=t.size;if(s.bindFramebuffer(s.FRAMEBUFFER,e?e.getFrameBuffer():null),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.renderTargetTexture_),!e){const e=r(s.canvas);if(!t.renderTargets[e]){const i=s.getContextAttributes();i&&i.preserveDrawingBuffer&&(s.clearColor(0,0,0,0),s.clearDepth(1),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT)),t.renderTargets[e]=!0}}s.disable(s.DEPTH_TEST),s.enable(s.BLEND),s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA),s.viewport(0,0,s.drawingBufferWidth,s.drawingBufferHeight),s.bindBuffer(s.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),s.useProgram(this.renderTargetProgram_),s.enableVertexAttribArray(this.renderTargetAttribLocation_),s.vertexAttribPointer(this.renderTargetAttribLocation_,2,s.FLOAT,!1,0,0),s.uniform2f(this.renderTargetUniformLocation_,o[0],o[1]),s.uniform1i(this.renderTargetTextureLocation_,0);const a=t.layerStatesArray[t.layerIndex].opacity;s.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(t),i&&i(s,t),s.drawArrays(s.TRIANGLES,0,6),n&&n(s,t)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(t){const e=this.getGL();let i,n=1;this.uniforms_.forEach((function(r){if(i="function"==typeof r.value?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof ImageData)r.texture||(r.texture=e.createTexture()),e.activeTexture(e[`TEXTURE${n}`]),e.bindTexture(e.TEXTURE_2D,r.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),i instanceof ImageData?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,i.width,i.height,0,e.UNSIGNED_BYTE,new Uint8Array(i.data)):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i),e.uniform1i(r.location,n++);else if(Array.isArray(i))switch(i.length){case 2:return void e.uniform2f(r.location,i[0],i[1]);case 3:return void e.uniform3f(r.location,i[0],i[1],i[2]);case 4:return void e.uniform4f(r.location,i[0],i[1],i[2],i[3]);default:return}else"number"==typeof i&&e.uniform1f(r.location,i)}))}};const Iv="u_projectionMatrix",Mv="u_time",Lv="u_zoom",kv="u_resolution",Dv="u_rotation",Av="u_viewportSizePx",Ov="u_pixelRatio",zv="u_hitDetection",Gv={UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},Nv={};function jv(t){return"shared/"+t}let Uv=0;function $v(t){let e=Nv[t];if(!e){const i=document.createElement("canvas");i.width=1,i.height=1,i.style.position="absolute",i.style.left="0";const n=function(t,e){e=Object.assign({preserveDrawingBuffer:!0,antialias:!N},e);const i=Sv.length;for(let n=0;nnew Fv({webGlContext:this.gl_,scaleRatio:t.scaleRatio,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms}))):[new Fv({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now()}setUniforms(t){this.uniforms_=[],this.addUniforms(t)}addUniforms(t){for(const e in t)this.uniforms_.push({name:e,value:t[e]})}canvasCacheKeyMatches(t){return this.canvasCacheKey_===jv(t)}getExtension(t){if(t in this.extensionCache_)return this.extensionCache_[t];const e=this.gl_.getExtension(t);return this.extensionCache_[t]=e,e}bindBuffer(t){const e=this.gl_,i=r(t);let n=this.bufferCache_[i];if(!n){n={buffer:t,webGlBuffer:e.createBuffer()},this.bufferCache_[i]=n}e.bindBuffer(t.getType(),n.webGlBuffer)}flushBufferData(t){const e=this.gl_;this.bindBuffer(t),e.bufferData(t.getType(),t.getArray(),t.getUsage())}deleteBuffer(t){const e=this.gl_,i=r(t),n=this.bufferCache_[i];n&&!e.isContextLost()&&e.deleteBuffer(n.webGlBuffer),delete this.bufferCache_[i]}disposeInternal(){const t=this.gl_.canvas;t.removeEventListener(Rv,this.boundHandleWebGLContextLost_),t.removeEventListener(Pv,this.boundHandleWebGLContextRestored_),function(t){const e=Nv[t];if(!e)return;if(e.users-=1,e.users>0)return;const i=e.context,n=i.getExtension("WEBGL_lose_context");n&&n.loseContext();const r=i.canvas;r.width=1,r.height=1,delete Nv[t]}(this.canvasCacheKey_),delete this.gl_}prepareDraw(t,e,i){const n=this.gl_,r=this.getCanvas(),s=t.size,o=t.pixelRatio;r.width===s[0]*o&&r.height===s[1]*o||(r.width=s[0]*o,r.height=s[1]*o,r.style.width=s[0]+"px",r.style.height=s[1]+"px");for(let e=this.postProcessPasses_.length-1;e>=0;e--)this.postProcessPasses_[e].init(t);n.bindTexture(n.TEXTURE_2D,null),n.clearColor(0,0,0,0),n.depthRange(0,1),n.clearDepth(1),n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.ONE,e?n.ZERO:n.ONE_MINUS_SRC_ALPHA),i?(n.enable(n.DEPTH_TEST),n.depthFunc(n.LEQUAL)):n.disable(n.DEPTH_TEST)}bindTexture(t,e,i){const n=this.gl_;n.activeTexture(n.TEXTURE0+e),n.bindTexture(n.TEXTURE_2D,t),n.uniform1i(this.getUniformLocation(i),e)}prepareDrawToRenderTarget(t,e,i,n){const r=this.gl_,s=e.getSize();r.bindFramebuffer(r.FRAMEBUFFER,e.getFramebuffer()),r.bindRenderbuffer(r.RENDERBUFFER,e.getDepthbuffer()),r.viewport(0,0,s[0],s[1]),r.bindTexture(r.TEXTURE_2D,e.getTexture()),r.clearColor(0,0,0,0),r.depthRange(0,1),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),r.enable(r.BLEND),r.blendFunc(r.ONE,i?r.ZERO:r.ONE_MINUS_SRC_ALPHA),n?(r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL)):r.disable(r.DEPTH_TEST)}drawElements(t,e){const i=this.gl_;this.getExtension("OES_element_index_uint");const n=i.UNSIGNED_INT,r=e-t,s=4*t;i.drawElements(i.TRIANGLES,r,n,s)}finalizeDraw(t,e,i){for(let n=0,r=this.postProcessPasses_.length;n{if(i="function"==typeof r.value?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof ImageData||i instanceof WebGLTexture){i instanceof WebGLTexture&&!r.texture?(r.prevValue=void 0,r.texture=i):r.texture||(r.prevValue=void 0,r.texture=e.createTexture()),this.bindTexture(r.texture,n,r.name),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);const t=!(i instanceof HTMLImageElement)||i.complete;i instanceof WebGLTexture||!t||r.prevValue===i||(r.prevValue=i,e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i)),n++}else if(Array.isArray(i)&&6===i.length)this.setUniformMatrixValue(r.name,function(t,e){return t[0]=e[0],t[1]=e[1],t[4]=e[2],t[5]=e[3],t[12]=e[4],t[13]=e[5],t}(this.tmpMat4_,i));else if(Array.isArray(i)&&i.length<=4)switch(i.length){case 2:return void e.uniform2f(this.getUniformLocation(r.name),i[0],i[1]);case 3:return void e.uniform3f(this.getUniformLocation(r.name),i[0],i[1],i[2]);case 4:return void e.uniform4f(this.getUniformLocation(r.name),i[0],i[1],i[2],i[3]);default:return}else"number"==typeof i&&e.uniform1f(this.getUniformLocation(r.name),i)}))}useProgram(t,e){this.gl_.useProgram(t),this.currentProgram_=t,this.applyFrameState(e),this.applyUniforms(e)}compileShader(t,e){const i=this.gl_,n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}getProgram(t,e){const i=this.gl_,n=this.compileShader(t,i.FRAGMENT_SHADER),r=this.compileShader(e,i.VERTEX_SHADER),s=i.createProgram();if(i.attachShader(s,n),i.attachShader(s,r),i.linkProgram(s),!i.getShaderParameter(n,i.COMPILE_STATUS)){const t=`Fragment shader compilation failed: ${i.getShaderInfoLog(n)}`;throw new Error(t)}if(i.deleteShader(n),!i.getShaderParameter(r,i.COMPILE_STATUS)){const t=`Vertex shader compilation failed: ${i.getShaderInfoLog(r)}`;throw new Error(t)}if(i.deleteShader(r),!i.getProgramParameter(s,i.LINK_STATUS)){const t=`GL program linking failed: ${i.getProgramInfoLog(s)}`;throw new Error(t)}return s}getUniformLocation(t){const e=r(this.currentProgram_);return void 0===this.uniformLocationsByProgram_[e]&&(this.uniformLocationsByProgram_[e]={}),void 0===this.uniformLocationsByProgram_[e][t]&&(this.uniformLocationsByProgram_[e][t]=this.gl_.getUniformLocation(this.currentProgram_,t)),this.uniformLocationsByProgram_[e][t]}getAttributeLocation(t){const e=r(this.currentProgram_);return void 0===this.attribLocationsByProgram_[e]&&(this.attribLocationsByProgram_[e]={}),void 0===this.attribLocationsByProgram_[e][t]&&(this.attribLocationsByProgram_[e][t]=this.gl_.getAttribLocation(this.currentProgram_,t)),this.attribLocationsByProgram_[e][t]}makeProjectionTransform(t,e){const i=t.size,n=t.viewState.rotation,r=t.viewState.resolution,s=t.viewState.center;return Ne(e,0,0,2/(r*i[0]),2/(r*i[1]),-n,-s[0],-s[1]),e}setUniformFloatValue(t,e){this.gl_.uniform1f(this.getUniformLocation(t),e)}setUniformFloatVec2(t,e){this.gl_.uniform2fv(this.getUniformLocation(t),e)}setUniformFloatVec4(t,e){this.gl_.uniform4fv(this.getUniformLocation(t),e)}setUniformMatrixValue(t,e){this.gl_.uniformMatrix4fv(this.getUniformLocation(t),!1,e)}enableAttributeArray_(t,e,i,n,r){const s=this.getAttributeLocation(t);s<0||(this.gl_.enableVertexAttribArray(s),this.gl_.vertexAttribPointer(s,e,i,!1,n,r))}enableAttributes(t){const e=function(t){let e=0;for(let i=0;ithis.size_[0]||e>=this.size_[1])return qv[0]=0,qv[1]=0,qv[2]=0,qv[3]=0,qv;this.readAll();const i=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return qv[0]=this.data_[4*i],qv[1]=this.data_[4*i+1],qv[2]=this.data_[4*i+2],qv[3]=this.data_[4*i+3],qv}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){const t=this.size_,e=this.helper_.getGL();this.texture_=this.helper_.createTexture(t,null,this.texture_),e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.viewport(0,0,t[0],t[1]),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture_,0),e.bindRenderbuffer(e.RENDERBUFFER,this.depthbuffer_),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,t[0],t[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(t[0]*t[1]*4)}};const Zv="GENERATE_POINT_BUFFERS";function Kv(t,e){const i=256,n=255;return(e=e||[])[0]=Math.floor(t/i/i/i)/n,e[1]=Math.floor(t/i/i)%i/n,e[2]=Math.floor(t/i)%i/n,e[3]=t%i/n,e}var Hv=class extends Xv{constructor(t,e){const i=e.uniforms||{},n=[1,0,0,1,0,0];i[Iv]=n,super(t,{uniforms:i,postProcesses:e.postProcesses}),this.sourceRevision_=-1,this.verticesBuffer_=new Tv(vv,bv),this.indicesBuffer_=new Tv(wv,bv),this.vertexShader_=e.vertexShader,this.fragmentShader_=e.fragmentShader,this.program_,this.hitDetectionEnabled_=e.hitDetectionEnabled??!0;const s=e.attributes?e.attributes.map((function(t){return{name:"a_prop_"+t.name,size:1,type:Gv.FLOAT}})):[];this.attributes=[{name:"a_position",size:2,type:Gv.FLOAT},{name:"a_index",size:1,type:Gv.FLOAT}],this.hitDetectionEnabled_&&(this.attributes.push({name:"a_prop_hitColor",size:4,type:Gv.FLOAT}),this.attributes.push({name:"a_featureUid",size:1,type:Gv.FLOAT})),this.attributes.push(...s),this.customAttributes=e.attributes?e.attributes:[],this.previousExtent_=[1/0,1/0,-1/0,-1/0],this.currentTransform_=n,this.renderTransform_=[1,0,0,1,0,0],this.invertRenderTransform_=[1,0,0,1,0,0],this.renderInstructions_=new Float32Array(0),this.hitRenderTarget_,this.lastSentId=0,this.worker_=function(){const t='const t="GENERATE_POLYGON_BUFFERS",e="GENERATE_POINT_BUFFERS",n="GENERATE_LINE_STRING_BUFFERS";function r(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function x(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,"Transformation matrix cannot be inverted");const x=e[0],o=e[1],u=e[2],i=e[3],f=e[4],s=e[5];return t[0]=i/n,t[1]=-o/n,t[2]=-u/n,t[3]=x/n,t[4]=(u*s-i*f)/n,t[5]=-(x*s-o*f)/n,t}function o(t,e,n=2){const r=e&&e.length,x=r?e[0]*n:t.length;let o=u(t,0,x,n,!0);const i=[];if(!o||o.next===o.prev)return i;let s,l,c;if(r&&(o=function(t,e,n,r){const x=[];for(let n=0,o=e.length;n80*n){s=1/0,l=1/0;let e=-1/0,r=-1/0;for(let o=n;oe&&(e=n),x>r&&(r=x)}c=Math.max(e-s,r-l),c=0!==c?32767/c:0}return f(o,i,n,s,l,c,0),i}function u(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,u=n-r;o0)for(let x=e;x=e;x-=r)o=z(x/r|0,t[x],t[x+1],o);return o&&M(o,o.next)&&(F(o),o=o.next),o}function i(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!M(r,r.next)&&0!==d(r.prev,r,r.next))r=r.next;else{if(F(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function f(t,e,n,r,x,o,u){if(!t)return;!u&&o&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=v(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let u=x,i=0;for(let t=0;t0||f>0&&u;)0!==i&&(0===f||!u||x.z<=u.z)?(r=x,x=x.nextZ,i--):(r=u,u=u.nextZ,f--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=u}o.nextZ=null,n*=2}while(e>1)}(x)}(t,r,x,o);let y=t;for(;t.prev!==t.next;){const h=t.prev,p=t.next;if(o?l(t,r,x,o):s(t))e.push(h.i,t.i,p.i),F(t),t=p.next,y=p.next;else if((t=p)===y){u?1===u?f(t=c(i(t),e),e,n,r,x,o,2):2===u&&a(t,e,n,r,x,o):f(i(t),e,n,r,x,o,1);break}}}function s(t){const e=t.prev,n=t,r=t.next;if(d(e,n,r)>=0)return!1;const x=e.x,o=n.x,u=r.x,i=e.y,f=n.y,s=r.y,l=xo?x>u?x:u:o>u?o:u,y=i>f?i>s?i:s:f>s?f:s;let h=r.next;for(;h!==e;){if(h.x>=l&&h.x<=a&&h.y>=c&&h.y<=y&&b(x,i,o,f,u,s,h.x,h.y)&&d(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function l(t,e,n,r){const x=t.prev,o=t,u=t.next;if(d(x,o,u)>=0)return!1;const i=x.x,f=o.x,s=u.x,l=x.y,c=o.y,a=u.y,y=if?i>s?i:s:f>s?f:s,g=l>c?l>a?l:a:c>a?c:a,Z=v(y,h,e,n,r),M=v(p,g,e,n,r);let w=t.prevZ,m=t.nextZ;for(;w&&w.z>=Z&&m&&m.z<=M;){if(w.x>=y&&w.x<=p&&w.y>=h&&w.y<=g&&w!==x&&w!==u&&b(i,l,f,c,s,a,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,m.x>=y&&m.x<=p&&m.y>=h&&m.y<=g&&m!==x&&m!==u&&b(i,l,f,c,s,a,m.x,m.y)&&d(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;w&&w.z>=Z;){if(w.x>=y&&w.x<=p&&w.y>=h&&w.y<=g&&w!==x&&w!==u&&b(i,l,f,c,s,a,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;m&&m.z<=M;){if(m.x>=y&&m.x<=p&&m.y>=h&&m.y<=g&&m!==x&&m!==u&&b(i,l,f,c,s,a,m.x,m.y)&&d(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function c(t,e){let n=t;do{const r=n.prev,x=n.next.next;!M(r,x)&&w(r,n,n.next,x)&&E(r,x)&&E(x,r)&&(e.push(r.i,n.i,x.i),F(n),F(n.next),n=t=x),n=n.next}while(n!==t);return i(n)}function a(t,e,n,r,x,o){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&Z(u,t)){let s=I(u,t);return u=i(u,u.next),s=i(s,s.next),f(u,e,n,r,x,o,0),void f(s,e,n,r,x,o,0)}t=t.next}u=u.next}while(u!==t)}function y(t,e){return t.x-e.x}function h(t,e){const n=function(t,e){let n=e;const r=t.x,x=t.y;let o,u=-1/0;do{if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>u&&(u=t,o=n.x=n.x&&n.x>=f&&r!==n.x&&b(xo.x||n.x===o.x&&p(o,n)))&&(o=n,l=e)}n=n.next}while(n!==i);return o}(t,e);if(!n)return e;const r=I(n,t);return i(r,r.next),i(n,n.next)}function p(t,e){return d(t.prev,t,e.prev)<0&&d(e.next,t,t.next)<0}function v(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function g(t){let e=t,n=t;do{(e.x=(t-u)*(o-i)&&(t-u)*(r-i)>=(n-u)*(e-i)&&(n-u)*(o-i)>=(x-u)*(r-i)}function Z(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&w(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(E(t,e)&&E(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(d(t.prev,t,e.prev)||d(t,e.prev,e))||M(t,e)&&d(t.prev,t,t.next)>0&&d(e.prev,e,e.next)>0)}function d(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function M(t,e){return t.x===e.x&&t.y===e.y}function w(t,e,n,r){const x=A(d(t,e,n)),o=A(d(t,e,r)),u=A(d(n,r,t)),i=A(d(n,r,e));return x!==o&&u!==i||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==u||!m(n,t,r))||!(0!==i||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function E(t,e){return d(t.prev,t,t.next)<0?d(t,e,t.next)>=0&&d(t,t.prev,e)>=0:d(t,e,t.prev)<0||d(t,t.next,e)<0}function I(t,e){const n=P(t.i,t.x,t.y),r=P(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function z(t,e,n,r){const x=P(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function F(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 P(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}new Array(6);const B=[],N={vertexPosition:0,indexPosition:0};function R(t,e,n,r,x){t[e+0]=n,t[e+1]=r,t[e+2]=x}function S(t,e,n,r,x,o){const u=3+x,i=t[e+0],f=t[e+1],s=B;s.length=x;for(let n=0;n0?f:2*Math.PI-f}let Z=-1,d=-1,M=c;const w=null!==o;if(null!==x){Z=b(v,g,r(s,[...[t[x],t[x+1]]])),Math.cos(Z)<=.985&&(M+=Math.tan((Z-Math.PI)/2))}if(w){d=b(g,v,r(s,[...[t[o],t[o+1]]])),Math.cos(d)<=.985&&(M+=Math.tan((Math.PI-d)/2))}function m(t,e){return 0===e?1e4*t:Math.sign(e)*(1e4*t+Math.abs(e))}return u.push(h[0],h[1],p[0],p[1],Z,d,l,m(0,c)),u.push(...f),u.push(h[0],h[1],p[0],p[1],Z,d,l,m(1,c)),u.push(...f),u.push(h[0],h[1],p[0],p[1],Z,d,l,m(2,c)),u.push(...f),u.push(h[0],h[1],p[0],p[1],Z,d,l,m(3,c)),u.push(...f),i.push(y,y+1,y+2,y+1,y+3,y+2),{length:l+Math.sqrt((g[0]-v[0])*(g[0]-v[0])+(g[1]-v[1])*(g[1]-v[1])),angle:M}}function _(t,e,n,r,x){const u=2+x;let i=e;const f=t.slice(i,i+x);i+=x;const s=t[i++];let l=0;const c=new Array(s-1);for(let e=0;e{const o=r.data;switch(o.type){case e:{const t=3,e=2,n=o.customAttributesSize,r=e+n,x=new Float32Array(o.renderInstructions),u=x.length/r,i=4*u*(n+t),f=new Uint32Array(6*u),s=new Float32Array(i);let l;for(let t=0;t0?h=i+(n-1)*r:c&&(h=o-r);let p=null;n{const e=t.data;if(e.type===Zv){const i=e.projectionTransform;this.verticesBuffer_.fromArrayBuffer(e.vertexBuffer),this.helper.flushBufferData(this.verticesBuffer_),this.indicesBuffer_.fromArrayBuffer(e.indexBuffer),this.helper.flushBufferData(this.indicesBuffer_),this.renderTransform_=i,je(this.invertRenderTransform_,this.renderTransform_),this.renderInstructions_=new Float32Array(t.data.renderInstructions),e.id===this.lastSentId&&(this.ready=!0),this.getLayer().changed()}})),this.featureCache_={},this.featureCount_=0;const o=this.getLayer().getSource();this.sourceListenKeys_=[Ft(o,ml,this.handleSourceFeatureAdded_,this),Ft(o,_l,this.handleSourceFeatureChanged_,this),Ft(o,xl,this.handleSourceFeatureDelete_,this),Ft(o,yl,this.handleSourceFeatureClear_,this)],o.forEachFeature((t=>{this.featureCache_[r(t)]={feature:t,properties:t.getProperties(),geometry:t.getGeometry()},this.featureCount_++}))}afterHelperCreated(){this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new Yv(this.helper))}handleSourceFeatureAdded_(t){const e=t.feature;this.featureCache_[r(e)]={feature:e,properties:e.getProperties(),geometry:e.getGeometry()},this.featureCount_++}handleSourceFeatureChanged_(t){const e=t.feature;this.featureCache_[r(e)]={feature:e,properties:e.getProperties(),geometry:e.getGeometry()}}handleSourceFeatureDelete_(t){const e=t.feature;delete this.featureCache_[r(e)],this.featureCount_--}handleSourceFeatureClear_(){this.featureCache_={},this.featureCount_=0}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[i,n,r]=function(t,e){const i=t.viewState.projection,n=e.getSource().getWrapX()&&i.canWrapX(),r=i.getExtent(),s=t.extent,o=n?yi(r):null,a=n?Math.ceil((s[2]-r[2])/o)+1:1;return[n?Math.floor((s[0]-r[0])/o):0,a,o]}(t,this.getLayer());this.renderWorlds(t,!1,i,n,r),this.helper.finalizeDraw(t,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent),this.hitDetectionEnabled_&&(this.renderWorlds(t,!0,i,n,r),this.hitRenderTarget_.clearCachedData()),this.postRender(e,t);return this.helper.getCanvas()}prepareFrameInternal(t){const e=this.getLayer(),i=e.getSource(),n=t.viewState,r=!t.viewHints[Ps]&&!t.viewHints[Fs],s=!ii(this.previousExtent_,t.extent),o=this.sourceRevision_4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${t.length}(${t.map(tw).join(", ")})`}function iw(t){const e=D(t),i=e.length>3?e[3]:1;return ew([e[0]/255*i,e[1]/255*i,e[2]/255*i,i])}const nw={};let rw=0;function sw(t){return t in nw||(nw[t]=rw++),nw[t]}function ow(t){return tw(sw(t))}function aw(t){return"u_var_"+t}const lw="getBandValue";function hw(t){return(e,i,n)=>{const r=i.args.length,s=new Array(r);for(let t=0;t{const i=e.args[0].value;i in t.properties||(t.properties[i]={name:i,type:e.type});return(t.inFragmentShader?"v_prop_":"a_prop_")+i},[Lo.GeometryType]:(t,e,i)=>{const n="geometryType";n in t.properties||(t.properties[n]={name:n,type:yo,evaluator:t=>jo(t.getGeometry())});return(t.inFragmentShader?"v_prop_":"a_prop_")+n},[Lo.Var]:(t,e)=>{const i=e.args[0].value;return i in t.variables||(t.variables[i]={name:i,type:e.type}),aw(i)},[Lo.Resolution]:()=>"u_resolution",[Lo.Zoom]:()=>"u_zoom",[Lo.Time]:()=>"u_time",[Lo.Any]:hw((t=>`(${t.join(" || ")})`)),[Lo.All]:hw((t=>`(${t.join(" && ")})`)),[Lo.Not]:hw((([t])=>`(!${t})`)),[Lo.Equal]:hw((([t,e])=>`(${t} == ${e})`)),[Lo.NotEqual]:hw((([t,e])=>`(${t} != ${e})`)),[Lo.GreaterThan]:hw((([t,e])=>`(${t} > ${e})`)),[Lo.GreaterThanOrEqualTo]:hw((([t,e])=>`(${t} >= ${e})`)),[Lo.LessThan]:hw((([t,e])=>`(${t} < ${e})`)),[Lo.LessThanOrEqualTo]:hw((([t,e])=>`(${t} <= ${e})`)),[Lo.Multiply]:hw((t=>`(${t.join(" * ")})`)),[Lo.Divide]:hw((([t,e])=>`(${t} / ${e})`)),[Lo.Add]:hw((t=>`(${t.join(" + ")})`)),[Lo.Subtract]:hw((([t,e])=>`(${t} - ${e})`)),[Lo.Clamp]:hw((([t,e,i])=>`clamp(${t}, ${e}, ${i})`)),[Lo.Mod]:hw((([t,e])=>`mod(${t}, ${e})`)),[Lo.Pow]:hw((([t,e])=>`pow(${t}, ${e})`)),[Lo.Abs]:hw((([t])=>`abs(${t})`)),[Lo.Floor]:hw((([t])=>`floor(${t})`)),[Lo.Ceil]:hw((([t])=>`ceil(${t})`)),[Lo.Round]:hw((([t])=>`floor(${t} + 0.5)`)),[Lo.Sin]:hw((([t])=>`sin(${t})`)),[Lo.Cos]:hw((([t])=>`cos(${t})`)),[Lo.Atan]:hw((([t,e])=>void 0!==e?`atan(${t}, ${e})`:`atan(${t})`)),[Lo.Sqrt]:hw((([t])=>`sqrt(${t})`)),[Lo.Match]:hw((t=>{const e=t[0],i=t[t.length-1];let n=null;for(let r=t.length-3;r>=1;r-=2){n=`(${e} == ${t[r]} ? ${t[r+1]} : ${n||i})`}return n})),[Lo.Between]:hw((([t,e,i])=>`(${t} >= ${e} && ${t} <= ${i})`)),[Lo.Interpolate]:hw((([t,e,...i])=>{let n="";for(let r=0;r{const e=t[t.length-1];let i=null;for(let n=t.length-3;n>=0;n-=2){i=`(${t[n]} ? ${t[n+1]} : ${i||e})`}return i})),[Lo.In]:hw((([t,...e],i)=>{const n=function(t,e){return`operator_${t}_${Object.keys(e.functions).length}`}("in",i),r=[];for(let t=0;t`vec${t.length}(${t.join(", ")})`)),[Lo.Color]:hw((t=>{if(1===t.length)return`vec4(vec3(${t[0]} / 255.0), 1.0)`;if(2===t.length)return`(${t[1]} * vec4(vec3(${t[0]} / 255.0), 1.0))`;const e=t.slice(0,3).map((t=>`${t} / 255.0`));if(3===t.length)return`vec4(${e.join(", ")}, 1.0)`;return`(${t[3]} * vec4(${e.join(", ")}, 1.0))`})),[Lo.Band]:hw((([t,e,i],n)=>{if(!(lw in n.functions)){let t="";const e=n.bandCount||1;for(let i=0;i{const[i,...n]=e.args,r=n.length,s=new Uint8Array(4*r);for(let t=0;t0)return tw(t.value);if((t.type&mo)>0)return t.value.toString();if((t.type&yo)>0)return ow(t.value.toString());if((t.type&xo)>0)return iw(t.value);if((t.type&vo)>0)return ew(t.value);if((t.type&wo)>0)return ew(o(t.value));throw new Error(`Unexpected expression ${t.value} (expected type ${Co(e)})`)}const dw="#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_screenToWorldMatrix;\nuniform vec2 u_viewportSizePx;\nuniform float u_pixelRatio;\nuniform float u_globalAlpha;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform float u_rotation;\nuniform vec4 u_renderExtent;\nuniform vec2 u_patternOrigin;\nuniform float u_depth;\nuniform mediump int u_hitDetection;\n\nconst float PI = 3.141592653589793238;\nconst float TWO_PI = 2.0 * PI;\n\n// this used to produce an alpha-premultiplied color from a texture\nvec4 samplePremultiplied(sampler2D sampler, vec2 texCoord) {\n vec4 color = texture2D(sampler, texCoord);\n return vec4(color.rgb * color.a, color.a);\n}\n",gw={"fill-color":"rgba(255,255,255,0.4)","stroke-color":"#3399CC","stroke-width":1.25,"circle-radius":5,"circle-fill-color":"rgba(255,255,255,0.4)","circle-stroke-width":1.25,"circle-stroke-color":"#3399CC"};class pw{constructor(){this.uniforms_=[],this.attributes_=[],this.varyings_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${tw(gw["circle-radius"])} + ${tw(.5*gw["circle-stroke-width"])})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=iw(gw["circle-fill-color"]),this.texCoordExpression_="vec4(0.0, 0.0, 1.0, 1.0)",this.discardExpression_="false",this.symbolRotateWithView_=!1,this.hasStroke_=!1,this.strokeWidthExpression_=tw(gw["stroke-width"]),this.strokeColorExpression_=iw(gw["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=ow("round"),this.strokeJoinExpression_=ow("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.hasFill_=!1,this.fillColorExpression_=iw(gw["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(t){return this.uniforms_.push(t),this}addAttribute(t){return this.attributes_.push(t),this}addVarying(t,e,i){return this.varyings_.push({name:t,type:e,expression:i}),this}setSymbolSizeExpression(t){return this.hasSymbol_=!0,this.symbolSizeExpression_=t,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(t){return this.symbolRotationExpression_=t,this}setSymbolOffsetExpression(t){return this.symbolOffsetExpression_=t,this}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}setSymbolColorExpression(t){return this.hasSymbol_=!0,this.symbolColorExpression_=t,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(t){return this.texCoordExpression_=t,this}setFragmentDiscardExpression(t){return this.discardExpression_=t,this}getFragmentDiscardExpression(){return this.discardExpression_}setSymbolRotateWithView(t){return this.symbolRotateWithView_=t,this}setStrokeWidthExpression(t){return this.hasStroke_=!0,this.strokeWidthExpression_=t,this}setStrokeColorExpression(t){return this.hasStroke_=!0,this.strokeColorExpression_=t,this}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(t){return this.strokeOffsetExpression_=t,this}setStrokeCapExpression(t){return this.strokeCapExpression_=t,this}setStrokeJoinExpression(t){return this.strokeJoinExpression_=t,this}setStrokeMiterLimitExpression(t){return this.strokeMiterLimitExpression_=t,this}setStrokeDistanceFieldExpression(t){return this.strokeDistanceFieldExpression_=t,this}setFillColorExpression(t){return this.hasFill_=!0,this.fillColorExpression_=t,this}getFillColorExpression(){return this.fillColorExpression_}addVertexShaderFunction(t){this.vertexShaderFunctions_.includes(t)||this.vertexShaderFunctions_.push(t)}addFragmentShaderFunction(t){this.fragmentShaderFunctions_.includes(t)||this.fragmentShaderFunctions_.push(t)}getSymbolVertexShader(){return this.hasSymbol_?`${dw}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nattribute vec2 a_position;\nattribute float a_index;\nattribute vec4 a_prop_hitColor;\n${this.attributes_.map((function(t){return"attribute "+t+";"})).join("\n")}\nvarying vec2 v_texCoord;\nvarying vec2 v_quadCoord;\nvarying vec4 v_prop_hitColor;\nvarying vec2 v_centerPx;\nvarying float v_angle;\nvarying vec2 v_quadSizePx;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvec2 pxToScreen(vec2 coordPx) {\n vec2 scaled = coordPx / u_viewportSizePx / 0.5;\n return scaled;\n}\n\nvec2 screenToPx(vec2 coordScreen) {\n return (coordScreen * 0.5 + 0.5) * u_viewportSizePx;\n}\n\nvoid main(void) {\n v_quadSizePx = ${this.symbolSizeExpression_};\n vec2 halfSizePx = v_quadSizePx * 0.5;\n vec2 centerOffsetPx = ${this.symbolOffsetExpression_};\n vec2 offsetPx = centerOffsetPx;\n if (a_index == 0.0) {\n offsetPx -= halfSizePx;\n } else if (a_index == 1.0) {\n offsetPx += halfSizePx * vec2(1., -1.);\n } else if (a_index == 2.0) {\n offsetPx += halfSizePx;\n } else {\n offsetPx += halfSizePx * vec2(-1., 1.);\n }\n float angle = ${this.symbolRotationExpression_};\n ${this.symbolRotateWithView_?"angle += u_rotation;":""}\n float c = cos(-angle);\n float s = sin(-angle);\n offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);\n vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);\n vec4 texCoord = ${this.texCoordExpression_};\n float u = a_index == 0.0 || a_index == 3.0 ? texCoord.s : texCoord.p;\n float v = a_index == 2.0 || a_index == 3.0 ? texCoord.t : texCoord.q;\n v_texCoord = vec2(u, v);\n v_prop_hitColor = a_prop_hitColor;\n v_angle = angle;\n c = cos(-v_angle);\n s = sin(-v_angle);\n centerOffsetPx = vec2(c * centerOffsetPx.x - s * centerOffsetPx.y, s * centerOffsetPx.x + c * centerOffsetPx.y); \n v_centerPx = screenToPx(center.xy) + centerOffsetPx;\n${this.varyings_.map((function(t){return" "+t.name+" = "+t.expression+";"})).join("\n")}\n}`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${dw}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nvarying vec2 v_texCoord;\nvarying vec4 v_prop_hitColor;\nvarying vec2 v_centerPx;\nvarying float v_angle;\nvarying vec2 v_quadSizePx;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\n\nvoid main(void) {\n if (${this.discardExpression_}) { discard; }\n vec2 coordsPx = gl_FragCoord.xy / u_pixelRatio - v_centerPx; // relative to center\n float c = cos(v_angle);\n float s = sin(v_angle);\n coordsPx = vec2(c * coordsPx.x - s * coordsPx.y, s * coordsPx.x + c * coordsPx.y);\n gl_FragColor = ${this.symbolColorExpression_};\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.05) { discard; };\n gl_FragColor = v_prop_hitColor;\n }\n}`:null}getStrokeVertexShader(){return this.hasStroke_?`${dw}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nattribute vec2 a_position;\nattribute float a_index;\nattribute vec2 a_segmentStart;\nattribute vec2 a_segmentEnd;\nattribute float a_parameters;\nattribute float a_distance;\nattribute vec2 a_joinAngles;\nattribute vec4 a_prop_hitColor;\n${this.attributes_.map((function(t){return"attribute "+t+";"})).join("\n")}\nvarying vec2 v_segmentStart;\nvarying vec2 v_segmentEnd;\nvarying float v_angleStart;\nvarying float v_angleEnd;\nvarying float v_width;\nvarying vec4 v_prop_hitColor;\nvarying float v_distanceOffsetPx;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvec2 worldToPx(vec2 worldPos) {\n vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);\n return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;\n}\n\nvec4 pxToScreen(vec2 pxPos) {\n vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;\n return vec4(screenPos, u_depth, 1.0);\n}\n\nbool isCap(float joinAngle) {\n return joinAngle < -0.1;\n}\n\nvec2 getJoinOffsetDirection(vec2 normalPx, float joinAngle) {\n float halfAngle = joinAngle / 2.0;\n float c = cos(halfAngle);\n float s = sin(halfAngle);\n vec2 angleBisectorNormal = vec2(s * normalPx.x + c * normalPx.y, -c * normalPx.x + s * normalPx.y);\n float length = 1.0 / s;\n return angleBisectorNormal * length;\n}\n\nvec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {\n // if on a cap or the join angle is too high, offset the line along the segment normal\n if (cos(joinAngle) > 0.998 || isCap(joinAngle)) {\n return point - normal * offsetPx;\n }\n // offset is applied along the inverted normal (positive offset goes "right" relative to line direction)\n return point - getJoinOffsetDirection(normal, joinAngle) * offsetPx;\n}\n\nvoid main(void) {\n v_angleStart = a_joinAngles.x;\n v_angleEnd = a_joinAngles.y;\n float vertexNumber = floor(abs(a_parameters) / 10000. + 0.5);\n // we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)\n float angleTangentSum = fract(abs(a_parameters) / 10000.) * 10000. * sign(a_parameters);\n\n float lineWidth = ${this.strokeWidthExpression_};\n float lineOffsetPx = ${this.strokeOffsetExpression_};\n\n // compute segment start/end in px with offset\n vec2 segmentStartPx = worldToPx(a_segmentStart);\n vec2 segmentEndPx = worldToPx(a_segmentEnd);\n vec2 tangentPx = normalize(segmentEndPx - segmentStartPx);\n vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);\n segmentStartPx = getOffsetPoint(segmentStartPx, normalPx, v_angleStart, lineOffsetPx),\n segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);\n \n // compute current vertex position\n float normalDir = vertexNumber < 0.5 || (vertexNumber > 1.5 && vertexNumber < 2.5) ? 1.0 : -1.0;\n float tangentDir = vertexNumber < 1.5 ? 1.0 : -1.0;\n float angle = vertexNumber < 1.5 ? v_angleStart : v_angleEnd;\n vec2 joinDirection;\n vec2 positionPx = vertexNumber < 1.5 ? segmentStartPx : segmentEndPx;\n // if angle is too high, do not make a proper join\n if (cos(angle) > 0.985 || isCap(angle)) {\n joinDirection = normalPx * normalDir - tangentPx * tangentDir;\n } else {\n joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);\n }\n positionPx = positionPx + joinDirection * (lineWidth * 0.5 + 1.); // adding 1 pixel for antialiasing\n gl_Position = pxToScreen(positionPx);\n\n v_segmentStart = segmentStartPx;\n v_segmentEnd = segmentEndPx;\n v_width = lineWidth;\n v_prop_hitColor = a_prop_hitColor;\n v_distanceOffsetPx = a_distance / u_resolution - (lineOffsetPx * angleTangentSum);\n${this.varyings_.map((function(t){return" "+t.name+" = "+t.expression+";"})).join("\n")}\n}`:null}getStrokeFragmentShader(){return this.hasStroke_?`${dw}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nvarying vec2 v_segmentStart;\nvarying vec2 v_segmentEnd;\nvarying float v_angleStart;\nvarying float v_angleEnd;\nvarying float v_width;\nvarying vec4 v_prop_hitColor;\nvarying float v_distanceOffsetPx;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\n\nvec2 pxToWorld(vec2 pxPos) {\n vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;\n return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;\n}\n\nbool isCap(float joinAngle) {\n return joinAngle < -0.1;\n}\n\nfloat segmentDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n vec2 tangent = normalize(end - start);\n vec2 normal = vec2(-tangent.y, tangent.x);\n vec2 startToPoint = point - start;\n return abs(dot(startToPoint, normal)) - width * 0.5;\n}\n\nfloat buttCapDistanceField(vec2 point, vec2 start, vec2 end) {\n vec2 startToPoint = point - start;\n vec2 tangent = normalize(end - start);\n return dot(startToPoint, -tangent);\n}\n\nfloat squareCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n return buttCapDistanceField(point, start, end) - width * 0.5;\n}\n\nfloat roundCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n float onSegment = max(0., 1000. * dot(point - start, end - start)); // this is very high when inside the segment\n return length(point - start) - width * 0.5 - onSegment;\n}\n\nfloat roundJoinDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n return roundCapDistanceField(point, start, end, width);\n}\n\nfloat bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {\n vec2 startToPoint = point - start;\n vec2 tangent = normalize(end - start);\n float c = cos(joinAngle * 0.5);\n float s = sin(joinAngle * 0.5);\n float direction = -sign(sin(joinAngle));\n vec2 bisector = vec2(c * tangent.x - s * tangent.y, s * tangent.x + c * tangent.y);\n float radius = width * 0.5 * s;\n return dot(startToPoint, bisector * direction) - radius;\n}\n\nfloat miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {\n if (cos(joinAngle) > 0.985) { // avoid risking a division by zero\n return bevelJoinField(point, start, end, width, joinAngle);\n }\n float miterLength = 1. / sin(joinAngle * 0.5);\n float miterLimit = ${this.strokeMiterLimitExpression_};\n if (miterLength > miterLimit) {\n return bevelJoinField(point, start, end, width, joinAngle);\n }\n return -1000.;\n}\n\nfloat capDistanceField(vec2 point, vec2 start, vec2 end, float width, float capType) {\n if (capType == ${ow("butt")}) {\n return buttCapDistanceField(point, start, end);\n } else if (capType == ${ow("square")}) {\n return squareCapDistanceField(point, start, end, width);\n }\n return roundCapDistanceField(point, start, end, width);\n}\n\nfloat joinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float joinType) {\n if (joinType == ${ow("bevel")}) {\n return bevelJoinField(point, start, end, width, joinAngle);\n } else if (joinType == ${ow("miter")}) {\n return miterJoinDistanceField(point, start, end, width, joinAngle);\n }\n return roundJoinDistanceField(point, start, end, width);\n}\n\nfloat computeSegmentPointDistance(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float capType, float joinType) {\n if (isCap(joinAngle)) {\n return capDistanceField(point, start, end, width, capType);\n }\n return joinDistanceField(point, start, end, width, joinAngle, joinType);\n}\n\nvoid main(void) {\n vec2 currentPoint = gl_FragCoord.xy / u_pixelRatio;\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n vec2 worldPos = pxToWorld(currentPoint);\n if (\n abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (\n worldPos[0] < u_renderExtent[0] ||\n worldPos[1] < u_renderExtent[1] ||\n worldPos[0] > u_renderExtent[2] ||\n worldPos[1] > u_renderExtent[3]\n )\n ) {\n discard;\n }\n #endif\n if (${this.discardExpression_}) { discard; }\n\n float segmentLength = length(v_segmentEnd - v_segmentStart);\n vec2 segmentTangent = (v_segmentEnd - v_segmentStart) / segmentLength;\n vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);\n vec2 startToPoint = currentPoint - v_segmentStart;\n float currentLengthPx = max(0., min(dot(segmentTangent, startToPoint), segmentLength)) + v_distanceOffsetPx; \n float currentRadiusPx = abs(dot(segmentNormal, startToPoint));\n float currentRadiusRatio = dot(segmentNormal, startToPoint) * 2. / v_width;\n vec4 color = ${this.strokeColorExpression_} * u_globalAlpha;\n float capType = ${this.strokeCapExpression_};\n float joinType = ${this.strokeJoinExpression_};\n float segmentStartDistance = computeSegmentPointDistance(currentPoint, v_segmentStart, v_segmentEnd, v_width, v_angleStart, capType, joinType);\n float segmentEndDistance = computeSegmentPointDistance(currentPoint, v_segmentEnd, v_segmentStart, v_width, v_angleEnd, capType, joinType);\n float distance = max(\n segmentDistanceField(currentPoint, v_segmentStart, v_segmentEnd, v_width),\n max(segmentStartDistance, segmentEndDistance)\n );\n distance = max(distance, ${this.strokeDistanceFieldExpression_});\n gl_FragColor = color * smoothstep(0.5, -0.5, distance);\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.1) { discard; };\n gl_FragColor = v_prop_hitColor;\n }\n}`:null}getFillVertexShader(){return this.hasFill_?`${dw}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nattribute vec2 a_position;\nattribute vec4 a_prop_hitColor;\n${this.attributes_.map((function(t){return"attribute "+t+";"})).join("\n")}\nvarying vec4 v_prop_hitColor;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);\n v_prop_hitColor = a_prop_hitColor;\n${this.varyings_.map((function(t){return" "+t.name+" = "+t.expression+";"})).join("\n")}\n}`:null}getFillFragmentShader(){return this.hasFill_?`${dw}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nvarying vec4 v_prop_hitColor;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\nvec2 pxToWorld(vec2 pxPos) {\n vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;\n return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;\n}\n\nvec2 worldToPx(vec2 worldPos) {\n vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);\n return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;\n}\n\nvoid main(void) {\n vec2 pxPos = gl_FragCoord.xy / u_pixelRatio;\n vec2 pxOrigin = worldToPx(u_patternOrigin);\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n vec2 worldPos = pxToWorld(pxPos);\n if (\n abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (\n worldPos[0] < u_renderExtent[0] ||\n worldPos[1] < u_renderExtent[1] ||\n worldPos[0] > u_renderExtent[2] ||\n worldPos[1] > u_renderExtent[3]\n )\n ) {\n discard;\n }\n #endif\n if (${this.discardExpression_}) { discard; }\n gl_FragColor = ${this.fillColorExpression_} * u_globalAlpha;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.1) { discard; };\n gl_FragColor = v_prop_hitColor;\n }\n}`:null}}const fw="blur",mw="gradient",_w="radius",yw=["#00f","#0ff","#0f0","#ff0","#f00"];var xw=class extends fa{constructor(t){t=t||{};const e=Object.assign({},t);delete e.gradient,delete e.radius,delete e.blur,delete e.weight,super(e),this.gradient_=null,this.addChangeListener(mw,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:yw),this.setBlur(void 0!==t.blur?t.blur:15),this.setRadius(void 0!==t.radius?t.radius:8);const i=t.weight?t.weight:"weight";this.weightFunction_="string"==typeof i?t=>t.get(i):i,this.setRenderOrder(null)}getBlur(){return this.get(fw)}getGradient(){return this.get(mw)}getRadius(){return this.get(_w)}handleGradientChanged_(){this.gradient_=function(t){const e=1,i=256,n=q(e,i),r=n.createLinearGradient(0,0,e,i),s=1/(t.length-1);for(let e=0,i=t.length;e{const e=this.weightFunction_(t);return void 0!==e?_(e,0,1):1}}],uniforms:{u_size:()=>2*(this.get(_w)+this.get(fw)),u_blurSlope:()=>this.get(_w)/Math.max(1,this.get(fw))},hitDetectionEnabled:!0,vertexShader:t.getSymbolVertexShader(),fragmentShader:t.getSymbolFragmentShader(),postProcesses:[{fragmentShader:"\n precision mediump float;\n\n uniform sampler2D u_image;\n uniform sampler2D u_gradientTexture;\n uniform float u_opacity;\n\n varying vec2 v_texCoord;\n\n void main() {\n vec4 color = texture2D(u_image, v_texCoord);\n gl_FragColor.a = color.a * u_opacity;\n gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;\n gl_FragColor.rgb *= gl_FragColor.a;\n }",uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}renderDeclutter(){}};function vw(t,e,i){return function(t,e,i,n){return cw(Mo(t,e,i),e,n)}(e,i,Io(),t)}function ww(t){const e=D(t);return[256*e[0]+e[1],256*e[2]+Math.round(255*e[3])]}function bw(t){return t===xo||t===wo?2:t===vo?4:1}function Sw(t){const e=bw(t);return e>1?`vec${e}`:"float"}function Ew(t){return(JSON.stringify(t).split("").reduce(((t,e)=>(t<<5)-t+e.charCodeAt(0)),0)>>>0).toString()}function Cw(t,e,i,n){if(`${n}radius`in t&&"icon-"!==n){let r=vw(i,t[`${n}radius`],_o);if(`${n}radius2`in t){r=`max(${r}, ${vw(i,t[`${n}radius2`],_o)})`}`${n}stroke-width`in t&&(r=`(${r} + ${vw(i,t[`${n}stroke-width`],_o)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${r} * 2. + 0.5)`)}if(`${n}scale`in t){const r=vw(i,t[`${n}scale`],wo);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${r}`)}`${n}displacement`in t&&e.setSymbolOffsetExpression(vw(i,t[`${n}displacement`],vo)),`${n}rotation`in t&&e.setSymbolRotationExpression(vw(i,t[`${n}rotation`],_o)),`${n}rotate-with-view`in t&&e.setSymbolRotateWithView(!!t[`${n}rotate-with-view`])}function Tw(t,e,i,n,r){let s="vec4(0.)";if(null!==e&&(s=e),null!==i&&null!==n){s=`mix(${i}, ${s}, ${`smoothstep(-${n} + 0.63, -${n} - 0.58, ${t})`})`}let o=`${s} * ${`(1.0 - smoothstep(-0.63, 0.58, ${t}))`}`;return null!==r&&(o=`${o} * ${r}`),o}function Rw(t,e,i,n,r){const s=new Image;let o;return s.crossOrigin=void 0===t[`${n}cross-origin`]?"anonymous":t[`${n}cross-origin`],s.src=t[`${n}src`],s.complete&&s.width&&s.height?o=ew([s.width,s.height]):(i[`u_texture${r}_size`]=()=>s.complete?[s.width,s.height]:[0,0],e.addUniform(`vec2 u_texture${r}_size`),o=`u_texture${r}_size`),i[`u_texture${r}`]=s,e.addUniform(`sampler2D u_texture${r}`),o}function Pw(t,e,i,n,r){let s=vw(i,t[`${e}offset`],vo);if(`${e}offset-origin`in t)switch(t[`${e}offset-origin`]){case"top-right":s=`vec2(${n}.x, 0.) + ${r} * vec2(-1., 0.) + ${s} * vec2(-1., 1.)`;break;case"bottom-left":s=`vec2(0., ${n}.y) + ${r} * vec2(0., -1.) + ${s} * vec2(1., -1.)`;break;case"bottom-right":s=`${n} - ${r} - ${s}`}return s}function Fw(t){const e={inFragmentShader:!1,properties:{},variables:{},functions:{},style:t},i={inFragmentShader:!0,variables:e.variables,properties:{},functions:{},style:t},n=new pw,r={};if("icon-src"in t?function(t,e,i,n,r){let s="vec4(1.0)";"icon-color"in t&&(s=vw(r,t["icon-color"],xo)),"icon-opacity"in t&&(s=`${s} * ${vw(r,t["icon-opacity"],_o)}`);const o=Ew(t["icon-src"]),a=Rw(t,e,i,"icon-",o);if(e.setSymbolColorExpression(`${s} * samplePremultiplied(u_texture${o}, v_texCoord)`).setSymbolSizeExpression(a),"icon-width"in t&&"icon-height"in t&&e.setSymbolSizeExpression(`vec2(${vw(n,t["icon-width"],_o)}, ${vw(n,t["icon-height"],_o)})`),"icon-offset"in t&&"icon-size"in t){const i=vw(n,t["icon-size"],vo),r=e.getSymbolSizeExpression();e.setSymbolSizeExpression(i);const s=Pw(t,"icon-",n,"v_quadSizePx",i);e.setTextureCoordinateExpression(`(vec4((${s}).xyxy) + vec4(0., 0., ${i})) / (${r}).xyxy`)}if(Cw(t,e,n,"icon-"),"icon-anchor"in t){const i=vw(n,t["icon-anchor"],vo);let r,s="1.0";"icon-scale"in t&&(s=vw(n,t["icon-scale"],wo)),r="pixels"===t["icon-anchor-x-units"]&&"pixels"===t["icon-anchor-y-units"]?`${i} * ${s}`:"pixels"===t["icon-anchor-x-units"]?`${i} * vec2(vec2(${s}).x, v_quadSizePx.y)`:"pixels"===t["icon-anchor-y-units"]?`${i} * vec2(v_quadSizePx.x, vec2(${s}).x)`:`${i} * v_quadSizePx`;let o=`v_quadSizePx * vec2(0.5, -0.5) + ${r} * vec2(-1., 1.)`;if("icon-anchor-origin"in t)switch(t["icon-anchor-origin"]){case"top-right":o=`v_quadSizePx * -0.5 + ${r}`;break;case"bottom-left":o=`v_quadSizePx * 0.5 - ${r}`;break;case"bottom-right":o=`v_quadSizePx * vec2(-0.5, 0.5) + ${r} * vec2(1., -1.)`}e.setSymbolOffsetExpression(`${e.getSymbolOffsetExpression()} + ${o}`)}}(t,n,r,e,i):"shape-points"in t?function(t,e,i,n,r){r.functions.round="float round(float v) {\n return sign(v) * floor(abs(v) + 0.5);\n}",r.functions.starDistanceField="float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {\n float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle\n float c = cos(startAngle);\n float s = sin(startAngle);\n vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);\n float alpha = TWO_PI / numPoints; // the angle of one sector\n float beta = atan(pointRotated.y, pointRotated.x);\n float gamma = round(beta / alpha) * alpha; // angle in sector\n c = cos(-gamma);\n s = sin(-gamma);\n vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));\n vec2 tipToPoint = inSector + vec2(-radius, 0.);\n vec2 edgeNormal = vec2(radius2 * sin(alpha * 0.5), -radius2 * cos(alpha * 0.5) + radius);\n return dot(normalize(edgeNormal), tipToPoint);\n}",r.functions.regularDistanceField="float regularDistanceField(vec2 point, float numPoints, float radius, float angle) {\n float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle\n float c = cos(startAngle);\n float s = sin(startAngle);\n vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);\n float alpha = TWO_PI / numPoints; // the angle of one sector\n float radiusIn = radius * cos(PI / numPoints);\n float beta = atan(pointRotated.y, pointRotated.x);\n float gamma = round((beta - alpha * 0.5) / alpha) * alpha + alpha * 0.5; // angle in sector from mid\n c = cos(-gamma);\n s = sin(-gamma);\n vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));\n return inSector.x - radiusIn;\n}",Cw(t,e,n,"shape-");let s=null;"shape-opacity"in t&&(s=vw(r,t["shape-opacity"],_o));let o="coordsPx";"shape-scale"in t&&(o=`coordsPx / ${vw(r,t["shape-scale"],wo)}`);let a=null;"shape-fill-color"in t&&(a=vw(r,t["shape-fill-color"],xo));let l=null;"shape-stroke-color"in t&&(l=vw(r,t["shape-stroke-color"],xo));let h=null;"shape-stroke-width"in t&&(h=vw(r,t["shape-stroke-width"],_o));const u=vw(r,t["shape-points"],_o);let c,d="0.";"shape-angle"in t&&(d=vw(r,t["shape-angle"],_o));let g=vw(r,t["shape-radius"],_o);if(null!==h&&(g=`${g} + ${h} * 0.5`),"shape-radius2"in t){let e=vw(r,t["shape-radius2"],_o);null!==h&&(e=`${e} + ${h} * 0.5`),c=`starDistanceField(${o}, ${u}, ${g}, ${e}, ${d})`}else c=`regularDistanceField(${o}, ${u}, ${g}, ${d})`;const p=Tw(c,a,l,h,s);e.setSymbolColorExpression(p)}(t,n,0,e,i):"circle-radius"in t&&function(t,e,i,n,r){r.functions.circleDistanceField="float circleDistanceField(vec2 point, float radius) {\n return length(point) - radius;\n}",Cw(t,e,n,"circle-");let s=null;"circle-opacity"in t&&(s=vw(r,t["circle-opacity"],_o));let o="coordsPx";"circle-scale"in t&&(o=`coordsPx / ${vw(r,t["circle-scale"],wo)}`);let a=null;"circle-fill-color"in t&&(a=vw(r,t["circle-fill-color"],xo));let l=null;"circle-stroke-color"in t&&(l=vw(r,t["circle-stroke-color"],xo));let h=vw(r,t["circle-radius"],_o),u=null;"circle-stroke-width"in t&&(u=vw(r,t["circle-stroke-width"],_o),h=`(${h} + ${u} * 0.5)`);const c=Tw(`circleDistanceField(${o}, ${h})`,a,l,u,s);e.setSymbolColorExpression(c)}(t,n,0,e,i),function(t,e,i,n,r){if("stroke-color"in t&&e.setStrokeColorExpression(vw(r,t["stroke-color"],xo)),"stroke-pattern-src"in t){const n=Ew(t["stroke-pattern-src"]),s=Rw(t,e,i,"stroke-pattern-",n);let o=s,a="vec2(0.)";"stroke-pattern-offset"in t&&"stroke-pattern-size"in t&&(o=vw(r,t["stroke-pattern-size"],vo),a=Pw(t,"stroke-pattern-",r,s,o));let l="0.";"stroke-pattern-spacing"in t&&(l=vw(r,t["stroke-pattern-spacing"],_o)),r.functions.sampleStrokePattern="vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {\n float currentLengthScaled = currentLengthPx * sampleSize.y / lineWidth;\n float spacingScaled = spacingPx * sampleSize.y / lineWidth;\n float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));\n // make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels\n uCoordPx = clamp(uCoordPx, 0.5, sampleSize.x - 0.5);\n float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;\n vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;\n return samplePremultiplied(texture, texCoord);\n}";const h=`u_texture${n}`;let u="1.";"stroke-color"in t&&(u=e.getStrokeColorExpression()),e.setStrokeColorExpression(`${u} * sampleStrokePattern(${h}, ${s}, ${a}, ${o}, ${l}, currentLengthPx, currentRadiusRatio, v_width)`)}if("stroke-width"in t&&e.setStrokeWidthExpression(vw(n,t["stroke-width"],_o)),"stroke-offset"in t&&e.setStrokeOffsetExpression(vw(n,t["stroke-offset"],_o)),"stroke-line-cap"in t&&e.setStrokeCapExpression(vw(n,t["stroke-line-cap"],yo)),"stroke-line-join"in t&&e.setStrokeJoinExpression(vw(n,t["stroke-line-join"],yo)),"stroke-miter-limit"in t&&e.setStrokeMiterLimitExpression(vw(n,t["stroke-miter-limit"],_o)),"stroke-line-dash"in t){r.functions.getSingleDashDistance=`float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType) {\n float localDistance = mod(distance, dashLengthTotal);\n float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;\n distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);\n if (capType == ${ow("square")}) {\n distanceSegment -= v_width * 0.5;\n } else if (capType == ${ow("round")}) {\n distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - v_width * 0.5);\n }\n return distanceSegment;\n}`;let i=t["stroke-line-dash"].map((t=>vw(r,t,_o)));i.length%2==1&&(i=[...i,...i]);let s="0.";"stroke-line-dash-offset"in t&&(s=vw(n,t["stroke-line-dash-offset"],_o));const o=`dashDistanceField_${Ew(t["stroke-line-dash"])}`,a=i.map(((t,e)=>`float dashLength${e} = ${t};`)),l=i.map(((t,e)=>`dashLength${e}`)).join(" + ");let h="0.",u=`getSingleDashDistance(distance, radius, ${h}, dashLength0, totalDashLength, capType)`;for(let t=2;t{const e=t.variables[s.name];return"number"==typeof e?e:"boolean"==typeof e?e?1:0:s.type===xo?ww([...D(e||"#eee")]):"string"==typeof e?sw(e):e}}for(const t in i.properties){const r=i.properties[t];e.properties[t]||(e.properties[t]=r);let s=Sw(r.type),o=`a_prop_${r.name}`;r.type===xo&&(s="vec4",o=`unpackColor(${o})`,n.addVertexShaderFunction("vec4 unpackColor(vec2 packedColor) {\n return fract(packedColor[1] / 256.0) * vec4(\n fract(floor(packedColor[0] / 256.0) / 256.0),\n fract(packedColor[0] / 256.0),\n fract(floor(packedColor[1] / 256.0) / 256.0),\n 1.0\n );\n}")),n.addVarying(`v_prop_${r.name}`,s,o)}for(const t in e.properties){const i=e.properties[t];n.addAttribute(`${Sw(i.type)} a_prop_${i.name}`)}for(const t in e.functions)n.addVertexShaderFunction(e.functions[t]);for(const t in i.functions)n.addFragmentShaderFunction(i.functions[t]);const s={};for(const t in e.properties){const i=e.properties[t];let n;n=i.evaluator?i.evaluator:t=>{const e=t.get(i.name);return i.type===xo?ww([...D(e||"#eee")]):"string"==typeof e?sw(e):"boolean"==typeof e?e?1:0:e},s[i.name]={size:bw(i.type),callback:n}}return{builder:n,attributes:s,uniforms:r}}var Iw=class extends Zs{constructor(t){super(Object.assign({},t)),this.parseResult_=Fw(t.style),this.styleVariables_=t.style.variables||{},this.hitDetectionDisabled_=!!t.disableHitDetection}createRenderer(){const t=Object.keys(this.parseResult_.attributes).map((t=>({name:t,...this.parseResult_.attributes[t]})));return new Hv(this,{vertexShader:this.parseResult_.builder.getSymbolVertexShader(),fragmentShader:this.parseResult_.builder.getSymbolFragmentShader(),hitDetectionEnabled:!this.hitDetectionDisabled_,uniforms:this.parseResult_.uniforms,attributes:t})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}};var Mw=class extends id{constructor(t){const e=void 0!==t.hidpi&&t.hidpi;super({cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,projection:gn("EPSG:3857"),reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,tilePixelRatio:e?2:1,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.hidpi_=e,this.culture_=void 0!==t.culture?t.culture:"en-us",this.maxZoom_=void 0!==t.maxZoom?t.maxZoom:-1,this.apiKey_=t.key,this.imagerySet_=t.imagerySet,this.placeholderTiles_=t.placeholderTiles;const i="https://dev.virtualearth.net/REST/v1/Imagery/Metadata/"+this.imagerySet_+"?uriScheme=https&include=ImageryProviders&key="+this.apiKey_+"&c="+this.culture_;fetch(i).then((t=>t.json())).then((t=>this.handleImageryMetadataResponse(t)))}getApiKey(){return this.apiKey_}getImagerySet(){return this.imagerySet_}handleImageryMetadataResponse(t){if(200!=t.statusCode||"OK"!=t.statusDescription||"ValidCredentials"!=t.authenticationResultCode||1!=t.resourceSets.length||1!=t.resourceSets[0].resources.length)return void this.setState("error");const e=t.resourceSets[0].resources[0],i=-1==this.maxZoom_?e.zoomMax:this.maxZoom_,n=Xc(this.getProjection()),r=this.hidpi_?2:1,s=e.imageWidth==e.imageHeight?e.imageWidth/r:[e.imageWidth/r,e.imageHeight/r],o=Bc({extent:n,minZoom:e.zoomMin,maxZoom:i,tileSize:s});this.tileGrid=o;const a=this.culture_,l=this.hidpi_,h=this.placeholderTiles_;if(this.tileUrlFunction=Su(e.imageUrlSubdomains.map((function(t){const i=[0,0,0],n=e.imageUrl.replace("{subdomain}",t).replace("{culture}",a);return function(t,e,r){if(!t)return;ru(t[0],t[1],t[2],i);const s=new URL(n.replace("{quadkey}",function(t){const e=t[0],i=new Array(e);let n,r,s=1<>=1;return i.join("")}(i))),o=s.searchParams;return l&&(o.set("dpi","d1"),o.set("device","mobile")),!0===h?o.delete("n"):!1===h&&o.set("n","z"),s.toString()}}))),e.imageryProviders){const t=wn(gn("EPSG:4326"),this.getProjection());this.setAttributions((i=>{const n=[],r=i.viewState,s=this.getTileGrid(),o=s.getZForResolution(r.resolution,this.zDirection),a=s.getTileCoordForCoordAndZ(r.center,o)[0];return e.imageryProviders.map((function(e){let r=!1;const s=e.coverageAreas;for(let e=0,n=s.length;e=n.zoomMin&&a<=n.zoomMax){const e=n.bbox;if(xi(wi([e[1],e[0],e[3],e[2]],t),i.extent)){r=!0;break}}}r&&n.push(e.attribution)})),n.push('Terms of Use'),n}))}this.setState("ready")}};var Lw=class extends id{constructor(t){const e=void 0!==(t=t||{}).projection?t.projection:"EPSG:3857",i=void 0!==t.tileGrid?t.tileGrid:Bc({extent:Xc(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=void 0!==t.gutter?t.gutter:0}getGutter(){return this.gutter_}};var kw=class extends vc{constructor(t){const e=void 0!==t.crossOrigin?t.crossOrigin:null,i=void 0!==t.imageLoadFunction?t.imageLoadFunction:yc;super({attributions:t.attributions,interpolate:t.interpolate,projection:gn(t.projection)}),this.url_=t.url,this.imageExtent_=t.imageExtent,this.image=null,this.image=new Dt(this.imageExtent_,void 0,1,function(t){const e=t.load||kt,i=t.imageExtent,n=t.crossOrigin??null;return()=>{const r=new Image;return r.crossOrigin=n,e(r,t.url).then((t=>{const e=yi(i)/t.width,n=pi(i)/t.height;return{image:t,extent:i,resolution:e!==n?[e,n]:n,pixelRatio:1}}))}}({url:t.url,imageExtent:t.imageExtent,crossOrigin:e,load:(t,e)=>(this.image.setImage(t),i(this.image,e),kt(t))})),this.image.addEventListener(mt,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(t,e,i,n){return xi(t,this.image.getExtent())?this.image:null}getUrl(){return this.url_}};const Dw="1.3.0",Aw=[101,101];function Ow(t,e,i,n,r){r.WIDTH=i[0],r.HEIGHT=i[1];const s=n.getAxisOrientation(),o=$i(r.VERSION,"1.3")>=0;r[o?"CRS":"SRS"]=n.getCode();const a=o&&s.startsWith("ne")?[e[1],e[0],e[3],e[2]]:e;return r.BBOX=a.join(","),fu(t,r)}function zw(t,e,i,n,r,s,o){s=Object.assign({REQUEST:"GetMap"},s);const a=e/i,l=[C(yi(t)/a,gc),C(pi(t)/a,gc)];if(1!=i)switch(o){case"geoserver":const t=90*i+.5|0;"FORMAT_OPTIONS"in s?s.FORMAT_OPTIONS+=";dpi:"+t:s.FORMAT_OPTIONS="dpi:"+t;break;case"mapserver":s.MAP_RESOLUTION=90*i;break;case"carmentaserver":case"qgis":s.DPI=90*i;break;default:throw new Error("Unknown `serverType` configured")}return Ow(r,t,l,n,s)}function Gw(t,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:Dw,FORMAT:"image/png",STYLES:"",TRANSPARENT:!0},t)}var Nw=class extends vc{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions}),this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.url_=t.url,this.imageLoadFunction_=void 0!==t.imageLoadFunction?t.imageLoadFunction:yc,this.params_=Object.assign({},t.params),this.serverType_=t.serverType,this.hidpi_=void 0===t.hidpi||t.hidpi,this.renderedRevision_=0,this.ratio_=void 0!==t.ratio?t.ratio:1.5,this.loaderProjection_=null}getFeatureInfoUrl(t,e,i,n){const r=gn(i),s=this.getProjection();s&&s!==r&&(e=lc(s,r,t,e),t=Sn(t,r,s));return function(t,e,i){if(void 0===t.url)return;const n=gn(t.projection||"EPSG:3857"),r=gi(e,i,0,Aw),s={QUERY_LAYERS:t.params.LAYERS,INFO_FORMAT:"application/json"};Object.assign(s,Gw(t.params,"GetFeatureInfo"),t.params);const o=T((e[0]-r[0])/i,gc),a=T((r[3]-e[1])/i,gc),l=$i(s.VERSION,"1.3")>=0;return s[l?"I":"X"]=o,s[l?"J":"Y"]=a,Ow(t.url,r,Aw,n,s)}({url:this.url_,params:{...this.params_,...n},projection:s||r},t,e)}getLegendUrl(t,e){return function(t,e){if(void 0===t.url)return;const i={SERVICE:"WMS",VERSION:Dw,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(void 0!==e){const n=gn(t.projection||"EPSG:3857").getMetersPerUnit()||1,r=28e-5;i.SCALE=e*n/r}if(Object.assign(i,t.params),void 0!==t.params&&void 0===i.LAYER){const t=i.LAYERS;if(Array.isArray(t)&&1===t.length)return;i.LAYER=t}return fu(t.url,i)}({url:this.url_,params:{...this.params_,...e}},t)}getParams(){return this.params_}getImageInternal(t,e,i,n){return void 0===this.url_?null:(this.loader&&this.loaderProjection_===n||(this.loaderProjection_=n,this.loader=function(t){const e=void 0===t.hidpi||t.hidpi,i=gn(t.projection||"EPSG:3857"),n=t.ratio||1.5,r=t.load||kt,s=t.crossOrigin??null;return(o,a,l)=>{o=xc(o,a,l,n),1==l||e&&void 0!==t.serverType||(l=1);const h=zw(o,a,l,i,t.url,Gw(t.params,"GetMap"),t.serverType),u=new Image;return u.crossOrigin=s,r(u,h).then((t=>({image:t,extent:o,pixelRatio:l})))}}({crossOrigin:this.crossOrigin_,params:this.params_,projection:n,serverType:this.serverType_,hidpi:this.hidpi_,url:this.url_,ratio:this.ratio_,load:(t,e)=>(this.image.setImage(t),this.imageLoadFunction_(this.image,e),kt(t))})),super.getImageInternal(t,e,i,n))}getImageLoadFunction(){return this.imageLoadFunction_}getUrl(){return this.url_}setImageLoadFunction(t){this.imageLoadFunction_=t,this.changed()}setUrl(t){t!=this.url_&&(this.url_=t,this.loader=null,this.changed())}updateParams(t){Object.assign(this.params_,t),this.changed()}changed(){this.image=null,super.changed()}};var jw=class extends Lw{constructor(t){let e;e=void 0!==(t=t||{}).attributions?t.attributions:['© OpenStreetMap contributors.'];const i=void 0!==t.crossOrigin?t.crossOrigin:"anonymous",n=void 0!==t.url?t.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:e,attributionsCollapsible:!1,cacheSize:t.cacheSize,crossOrigin:i,interpolate:t.interpolate,maxZoom:void 0!==t.maxZoom?t.maxZoom:19,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:n,wrapX:t.wrapX,zDirection:t.zDirection})}};var Uw=class extends id{constructor(t){t=t||{};const e=Object.assign({},t.params);super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:t.projection,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileClass:t.tileClass,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.gutter_=void 0!==t.gutter?t.gutter:0,this.params_=e,this.v13_=!0,this.serverType_=t.serverType,this.hidpi_=void 0===t.hidpi||t.hidpi,this.tmpExtent_=[1/0,1/0,-1/0,-1/0],this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(t,e,i,n){const r=gn(i),s=this.getProjection()||r;let o=this.getTileGrid();o||(o=this.getTileGridForProjection(s));const a=Sn(t,r,s),l=lc(s,r,t,e),h=o.getZForResolution(l,this.zDirection),u=o.getResolution(h),c=o.getTileCoordForCoordAndZ(a,h);if(o.getResolutions().length<=c[0])return;let d=o.getTileCoordExtent(c,this.tmpExtent_);const g=this.gutter_;0!==g&&(d=Ve(d,u*g,d));const p={QUERY_LAYERS:this.params_.LAYERS};Object.assign(p,Gw(this.params_,"GetFeatureInfo"),n);const f=Math.floor((a[0]-d[0])/u),m=Math.floor((d[3]-a[1])/u);return p[this.v13_?"I":"X"]=f,p[this.v13_?"J":"Y"]=m,this.getRequestUrl_(c,d,1,s||r,p)}getLegendUrl(t,e){if(void 0===this.urls[0])return;const i={SERVICE:"WMS",VERSION:Dw,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(void 0===e||void 0===e.LAYER){const t=this.params_.LAYERS;if(!(!Array.isArray(t)||1===t.length))return;i.LAYER=t}if(void 0!==t){const e=this.getProjection()?this.getProjection().getMetersPerUnit():1,n=28e-5;i.SCALE=t*e/n}return Object.assign(i,e),fu(this.urls[0],i)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(t,e,i,n,r){const s=this.urls;if(!s)return;let o;if(1==s.length)o=s[0];else{o=s[b(au(t),s.length)]}return zw(e,(this.tileGrid||this.getTileGridForProjection(n)).getResolution(t[0]),i,n,o,r,this.serverType_)}getTilePixelRatio(t){return this.hidpi_&&void 0!==this.serverType_?t:1}getKeyForParams_(){let t=0;const e=[];for(const i in this.params_)e[t++]=i+"-"+this.params_[i];return e.join("/")}updateParams(t){Object.assign(this.params_,t),this.updateV13_(),this.setKey(this.getKeyForParams_())}updateV13_(){const t=this.params_.VERSION||Dw;this.v13_=$i(t,"1.3")>=0}tileUrlFunction(t,e,i){let n=this.getTileGrid();if(n||(n=this.getTileGridForProjection(i)),n.getResolutions().length<=t[0])return;1==e||this.hidpi_&&void 0!==this.serverType_||(e=1);const r=n.getResolution(t[0]);let s=n.getTileCoordExtent(t,this.tmpExtent_);const o=this.gutter_;0!==o&&(s=Ve(s,r*o,s));const a=Object.assign({},Gw(this.params_,"GetMap"));return this.getRequestUrl_(t,s,e,i,a)}};Vt.unByKey=Bt;let $w={Control:sh,Zoom:hh,Attribution:ah,ScaleLine:Am,LayerSwitcher:Um},Bw={GeoJSON:ku,KML:xv,MVT:ic},Vw={Group:Nl,Tile:Oc,Vector:dl,VectorTile:ad,WebGLPoints:Iw,Heatmap:xw,Image:Ou},Ww={LineString:Cr,Point:Fr,MultiPoint:Mr},Xw={Icon:Fe,Style:ns,Text:ss,Stroke:Hr,Fill:Ce,Circle:Se},qw={OSM:jw,XYZ:Lw,TileWMS:Uw,BingMaps:Mw,Vector:Fl,VectorTile:ld,ImageWMS:Nw,ImageStatic:kw};t.Collection=cs,t.Feature=Me,t.Map=Kh,t.MapboxVectorLayer=class extends ad{constructor(t){const e=!("declutter"in t)||t.declutter,i=new ld({state:"loading",format:new ic});super({source:i,background:!1===t.background?null:t.background,declutter:e,className:t.className,opacity:t.opacity,visible:t.visible,zIndex:t.zIndex,minResolution:t.minResolution,maxResolution:t.maxResolution,minZoom:t.minZoom,maxZoom:t.maxZoom,renderOrder:t.renderOrder,renderBuffer:t.renderBuffer,renderMode:t.renderMode,map:t.map,updateWhileAnimating:t.updateWhileAnimating,updateWhileInteracting:t.updateWhileInteracting,preload:t.preload,useInterimTilesOnError:t.useInterimTilesOnError,properties:t.properties}),t.accessToken&&(this.accessToken=t.accessToken);const n=[Rm(this,t.styleUrl,t.layers||t.source,{accessToken:this.accessToken})];void 0===this.getBackground()&&n.push(function(t,e,i={}){return Yf(e,i).then((function(e){Fm(t,e,i)}))}(this,t.styleUrl,{accessToken:this.accessToken})),Promise.all(n).then((()=>{i.setState("ready")})).catch((t=>{this.dispatchEvent(new Mm(t));this.getSource().setState("error")}))}},t.Observable=Vt,t.Overlay=iu,t.View=qs,t.applyStyle=Rm,t.control=$w,t.format=Bw,t.geom=Ww,t.interaction=V_,t.layer=Vw,t.proj=Dn,t.source=qw,t.sphere=nn,t.style=Xw,t.stylefunction=Cm,t.tilegrid=qc,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ol-custom.js.map