var ol=function(){"use strict";class t{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}function e(t){t.stopPropagation()}var i="propertychange";class n{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function r(t,e,i){let n,r;i=i||s;let o=0,a=t.length,l=!1;for(;o>1),r=+i(t[n],e),r<0?o=n+1:(a=n,l=!r);return l?o:~o}function s(t,e){return t>e?1:te?-1:0}function a(t,e,i){if(t[0]<=e)return 0;const n=t.length;if(e<=t[n-1])return n-1;if("function"==typeof i){for(let r=1;r0?r-1:r}return n-1}if(i>0){for(let i=1;i0||i&&0===s)}))}function d(){return!0}function g(){return!1}function f(){}function p(t){let e,i,n;return function(){const r=Array.prototype.slice.call(arguments);return i&&this===n&&c(r,i)||(n=this,i=r,e=t.apply(this,arguments)),e}}function m(t){return function(){let e;try{e=t()}catch(t){return Promise.reject(t)}return e instanceof Promise?e:Promise.resolve(e)}()}function _(t){for(const e in t)delete t[e]}function y(t){let e;for(e in t)return!1;return!e}class x extends n{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),n=i[t]||(i[t]=[]);n.includes(e)||n.push(e)}dispatchEvent(e){const i="string"==typeof e,n=i?e:e.type,r=this.listeners_&&this.listeners_[n];if(!r)return;const s=i?new t(e):e;s.target||(s.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});let l;n in o||(o[n]=0,a[n]=0),++o[n];for(let t=0,e=r.length;t0)}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]=f,++this.pendingRemovals_[t]):(i.splice(n,1),0===i.length&&delete this.listeners_[t]))}}var v="change",w="error",E="contextmenu",S="click",T="dblclick",C="dragenter",R="dragover",b="drop",P="keydown",F="keypress",M="load",L="touchmove",I="wheel";function A(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 O(t,e,i,n){return A(t,e,i,n,!0)}function D(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),_(t))}class N extends x{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(v)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let r=0;r0;)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 Y(X,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 Y(V,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 Y(V,i,t)),this.dispatchEvent(new Y(X,e,t))}updateLength_(){this.set(W,this.array_.length)}assertUnique_(t,e){for(let i=0,n=this.array_.length;it)throw new Error("Tile load sequence violation");this.state=t,this.changed()}load(){G()}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:Q(n/this.transition_)}inTransition(t){return!!this.transition_&&-1!==this.transitionStarts_[t]}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}const rt="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"",st=rt.includes("firefox"),ot=rt.includes("safari")&&!rt.includes("chrom"),at=ot&&(rt.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(rt)),lt=rt.includes("webkit")&&!rt.includes("edge"),ht=rt.includes("macintosh"),ct="undefined"!=typeof devicePixelRatio?devicePixelRatio:1,ut="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope,dt="undefined"!=typeof Image&&Image.prototype.decode,gt="function"==typeof createImageBitmap,ft=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 pt(t,e,i,n){let r;return r=i&&i.length?i.shift():ut?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("2d",n)}let mt;function _t(){return mt||(mt=pt(1,1)),mt}function yt(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}function xt(t){let e=t.offsetWidth;const i=getComputedStyle(t);return e+=parseInt(i.marginLeft,10)+parseInt(i.marginRight,10),e}function vt(t){let e=t.offsetHeight;const i=getComputedStyle(t);return e+=parseInt(i.marginTop,10)+parseInt(i.marginBottom,10),e}function wt(t,e){const i=e.parentNode;i&&i.replaceChild(t,e)}function Et(t){for(;t.lastChild;)t.lastChild.remove()}function St(t,e){const i=t.childNodes;for(let n=0;;++n){const r=i[n],s=e[n];if(!r&&!s)break;r!==s&&(r?s?t.insertBefore(s,r):(t.removeChild(r),--n):t.appendChild(s))}}function Tt(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageBitmap?t:null}function Ct(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t instanceof DataView?t:null}const Rt=new Error("disposed");let bt=null;function Pt(t){bt||(bt=pt(t.width,t.height,void 0,{willReadFrequently:!0}));const e=bt.canvas,i=t.width;e.width!==i&&(e.width=i);const n=t.height;return e.height!==n&&(e.height=n),bt.clearRect(0,0,i,n),bt.drawImage(t,0,0),bt.getImageData(0,0,i,n).data}const Ft=[256,256];class Mt extends nt{constructor(t){const e=K;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=Tt(this.data_);return t?[t.width,t.height]:Ft}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==K&&this.state!==$)return;this.state=H,this.changed();const t=this;this.loader_().then((function(e){t.data_=e,t.state=q,t.changed()})).catch((function(e){t.error_=e,t.state=$,t.changed()}))}disposeInternal(){this.controller_&&(this.controller_.abort(Rt),this.controller_=null),super.disposeInternal()}}function Lt(t,e){if(!t)throw new Error(e)}class It extends z{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 It(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_&&(D(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=A(t,v,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?At(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_()}}function At(t){if("function"==typeof t)return t;let e;if(Array.isArray(t))e=t;else{Lt("function"==typeof t.getZIndex,"Expected an `ol/style/Style` or an array of `ol/style/Style.js`");e=[t]}return function(){return e}}const Ot=new Array(6);function Dt(){return[1,0,0,1,0,0]}function Nt(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],c=e[2],u=e[3],d=e[4],g=e[5];return t[0]=i*l+r*h,t[1]=n*l+s*h,t[2]=i*c+r*u,t[3]=n*c+s*u,t[4]=i*d+r*g+o,t[5]=n*d+s*g+a,t}function kt(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 Gt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function jt(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 Ut(t,e,i){return Nt(t,kt(Ot,e,0,0,i,0,0))}function Bt(t,e,i){return Nt(t,kt(Ot,1,0,0,1,e,i))}function zt(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 Xt(t,e){const i=Vt(e);Lt(0!==i,"Transformation matrix cannot be inverted");const n=e[0],r=e[1],s=e[2],o=e[3],a=e[4],l=e[5];return t[0]=o/i,t[1]=-r/i,t[2]=-s/i,t[3]=n/i,t[4]=(s*l-o*a)/i,t[5]=-(n*l-r*a)/i,t}function Vt(t){return t[0]*t[3]-t[1]*t[2]}const Wt=[1e6,1e6,1e6,1e6,2,2];function Yt(t){return"matrix("+t.map(((t,e)=>Math.round(t*Wt[e])/Wt[e])).join(", ")+")"}var Zt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Kt(t){const e=ie();for(let i=0,n=t.length;ir&&(l|=Zt.RIGHT),as&&(l|=Zt.ABOVE),l===Zt.UNKNOWN&&(l=Zt.INTERSECTING),l}function ie(){return[1/0,1/0,-1/0,-1/0]}function ne(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 re(t){return ne(1/0,1/0,-1/0,-1/0,t)}function se(t,e){const i=t[0],n=t[1];return ne(i,n,i,n,e)}function oe(t,e,i,n,r){return de(re(r),t,e,i,n)}function ae(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function le(t,e,i){return Math.abs(t[0]-e[0])t[2]&&(t[2]=e[2]),e[1]t[3]&&(t[3]=e[3]),t}function ce(t,e){e[0]t[2]&&(t[2]=e[0]),e[1]t[3]&&(t[3]=e[1])}function ue(t,e){for(let i=0,n=e.length;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 Fe(t){return t[2]=o&&p<=l),n||!(s&Zt.RIGHT)||r&Zt.RIGHT||(m=g-(d-l)*f,n=m>=a&&m<=h),n||!(s&Zt.BELOW)||r&Zt.BELOW||(p=d-(g-a)/f,n=p>=o&&p<=l),n||!(s&Zt.LEFT)||r&Zt.LEFT||(m=g-(d-o)*f,n=m>=a&&m<=h)}return n}function Ae(t,e,i,n){if(Fe(t))return re(i);let r=[];if(n>1){const e=t[2]-t[0],i=t[3]-t[1];for(let s=0;s=i[2])){const e=be(i),r=Math.floor((n[0]-i[0])/e)*e;t[0]-=r,t[2]-=r}return t}function De(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]]];Oe(t,e);const r=be(n);if(be(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 Ne={9001:"m",9002:"ft",9003:"us-ft",9101:"radians",9102:"degrees"};const ke={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Ge{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_||ke[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 je=6378137,Ue=Math.PI*je,Be=[-Ue,-Ue,Ue,Ue],ze=[-180,-85,180,85],Xe=je*Math.log(Math.tan(Math.PI/2));class Ve extends Ge{constructor(t){super({code:t,units:"m",extent:Be,global:!0,worldExtent:ze,getPointResolution:function(t,e){return t/Math.cosh(e[1]/je)}})}}const We=[new Ve("EPSG:3857"),new Ve("EPSG:102100"),new Ve("EPSG:102113"),new Ve("EPSG:900913"),new Ve("http://www.opengis.net/def/crs/EPSG/0/3857"),new Ve("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Ye(t,e,i,n){const r=t.length;i=i>1?i:2,n=n??i,void 0===e&&(e=i>2?t.slice():new Array(r));for(let i=0;iXe?n=Xe:n<-Xe&&(n=-Xe),e[i+1]=n}return e}function Ze(t,e,i,n){const r=t.length;i=i>1?i:2,n=n??i,void 0===e&&(e=i>2?t.slice():new Array(r));for(let i=0;i1?(i=r,n=s):l>0&&(i+=o*l,n+=a*l)}return hi(t,e,i,n)}function hi(t,e,i,n){const r=i-t,s=n-e;return r*r+s*s}function ci(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}function ui(t){return 180*t/Math.PI}function di(t){return t*Math.PI/180}function gi(t,e){const i=t%e;return i*e<0?i+e:i}function fi(t,e,i){return t+i*(e-t)}function pi(t,e){const i=Math.pow(10,e);return Math.round(t*i)/i}function mi(t,e){return Math.round(pi(t,e))}function _i(t,e){return Math.floor(pi(t,e))}function yi(t,e){return Math.ceil(pi(t,e))}function xi(t,e,i){if(t>=e&&te?n:new Array(1+e-r).join("0")+n}function wi(t,e){const i=(""+t).split("."),n=(""+e).split(".");for(let t=0;tr)return 1;if(r>e)return-1}return 0}function Ei(t,e){return t[0]+=+e[0],t[1]+=+e[1],t}function Si(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 Ti(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],c=l-o,u=h-a,d=0===c&&0===u?0:(c*(i-o)+u*(n-a))/(c*c+u*u||0);let g,f;return d<=0?(g=o,f=a):d>=1?(g=l,f=h):(g=o+d*c,f=a+d*u),[g,f]}function Ci(t,e,i){const n=gi(e+180,360)-180,r=Math.abs(3600*n),s=i||0;let o=Math.floor(r/3600),a=Math.floor((r-3600*o)/60),l=pi(r-3600*o-60*a,s);l>=60&&(l=0,a+=1),a>=60&&(a=0,o+=1);let h=o+"°";return 0===a&&0===l||(h+=" "+vi(a,2)+"′"),0!==l&&(h+=" "+vi(l,2,s)+"″"),0!==n&&(h+=" "+t.charAt(n<0?1:0)),h}function Ri(t,e,i){return t?e.replace("{x}",t[0].toFixed(i)).replace("{y}",t[1].toFixed(i)):""}function bi(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 Pi(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 Fi(t,e){return t[0]*=e,t[1]*=e,t}function Mi(t,e){const i=t[0]-e[0],n=t[1]-e[1];return i*i+n*n}function Li(t,e){return Math.sqrt(Mi(t,e))}function Ii(t,e){return Mi(t,Ti(t,e))}function Ai(t,e){return Ri(t,"{x}, {y}",e)}function Oi(t,e){if(e.canWrapX()){const i=be(e.getExtent()),n=Di(t,e,i);n&&(t[0]-=n*i)}return t}function Di(t,e,i){const n=e.getExtent();let r=0;return e.canWrapX()&&(t[0]n[2])&&(i=i||be(n),r=Math.floor((t[0]-n[0])/i)),r}const Ni=6371008.8;function ki(t,e,i){i=i||Ni;const n=di(t[1]),r=di(e[1]),s=(r-n)/2,o=di(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 Gi(t,e){let i=0;for(let n=0,r=t.length;ncn&&(e=cn);const n=di(e),r=Math.sin(n),s=Math.cos(n),o=r/s,a=o*o,l=a*a,h=di(t),c=di(fn(i.number)),u=an/Math.sqrt(1-zi*r**2),d=Wi*s**2,g=s*xi(h-c,-Math.PI,Math.PI),f=g*g,p=f*g,m=p*g,_=m*g,y=_*g,x=an*(Ji*n-Qi*Math.sin(2*n)+tn*Math.sin(4*n)-en*Math.sin(6*n)),v=Bi*u*(g+p/6*(1-a+d)+_/120*(5-18*a+l+72*d-58*Wi))+5e5;let w=Bi*(x+u*o*(f/2+m/24*(5-a+9*d+4*d**2)+y/720*(61-58*a+l+600*d-330*Wi)));return i.north||(w+=1e7),[v,w]}function fn(t){return 6*(t-1)-180+3}const pn=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function mn(t){let e=0;for(const i of pn){const n=t.match(i);if(n){e=parseInt(n[1]);break}}if(!e)return null;let i=0,n=!1;return e>32700&&e<32761?i=e-32700:e>32600&&e<32661&&(n=!0,i=e-32600),i?{number:i,north:n}:null}function _n(t,e){return function(i,n,r,s){const o=i.length;r=r>1?r:2,s=s??r,n||(n=r>2?i.slice():new Array(o));for(let r=0;rvn.warn||console.warn(...t)}function Sn(...t){wn>vn.error||console.error(...t)}const Tn=[xn],Cn=[yn];let Rn=!0;function bn(t){Rn=!(void 0===t||t)}function Pn(t,e){if(void 0!==e)for(let i=0,n=t.length;i=a?e[o+t]:s[t]}return i}}function Gn(t,e,i,n){const r=In(t),s=In(e);si(r,s,kn(i)),si(s,r,kn(n))}function jn(t,e){const i=Vn(t,void 0!==e?e:"EPSG:3857","EPSG:4326"),n=i[0];return(n<-180||n>180)&&(i[0]=gi(n+180,360)-180),i}function Un(t,e){if(t===e)return!0;const i=t.getUnits()===e.getUnits();if(t.getCode()===e.getCode())return i;return Bn(t,e)===Pn&&i}function Bn(t,e){const i=t.getCode(),n=e.getCode();let r=oi(i,n);if(r)return r;let s=null,o=null;for(const i of Tn)s||(s=i(t)),o||(o=i(e));if(!s&&!o)return null;const a="EPSG:4326";if(o)if(s)r=zn(s.inverse,o.forward);else{const t=oi(i,a);t&&(r=zn(t,o.forward))}else{const t=oi(a,n);t&&(r=zn(s.inverse,t))}return r&&(Mn(t),Mn(e),si(t,e,r)),r}function zn(t,e){return function(i,n,r,s){return n=t(i,n,r,s),e(n,n,r,s)}}function Xn(t,e){return Bn(In(t),In(e))}function Vn(t,e,i){const n=Xn(e,i);if(!n){const t=In(e).getCode(),n=In(i).getCode();throw new Error(`No transform available between ${t} and ${n}`)}return n(t,void 0,t.length)}function Wn(t,e,i,n){return Ae(t,Xn(e,i),void 0,n)}let Yn=null;function Zn(t){Yn=In(t)}function Kn(){return Yn}function Hn(t,e){return Yn?Vn(t,e,Yn):t}function qn(t,e){return Yn?Vn(t,Yn,e):(Rn&&!bi(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(Rn=!1,En("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t)}function $n(t,e){return Yn?Wn(t,e,Yn):t}function Jn(t,e){return Yn?Wn(t,Yn,e):t}function Qn(t,e){if(!Yn)return t;const i=In(e).getMetersPerUnit(),n=Yn.getMetersPerUnit();return i&&n?t*i/n:t}function tr(t,e){if(!Yn)return t;const i=In(e).getMetersPerUnit(),n=Yn.getMetersPerUnit();return i&&n?t*n/i:t}function er(t,e,i){return function(n){let r,s;if(t.canWrapX()){const e=t.getExtent(),o=be(e);s=Di(n=n.slice(0),t,o),s&&(n[0]=n[0]-s*o),n[0]=ai(n[0],e[0],e[2]),n[1]=ai(n[1],e[1],e[3]),r=i(n)}else r=i(n);return s&&e.canWrapX()&&(r[0]+=s*be(e.getExtent())),r}}function ir(){On(We),On(Je),Dn(Je,We,Ye,Ze)}function nr(t,e,i,n,r,s,o){s=s||[],o=o||2;let a=0;for(let l=e;l{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 G()}closestPointXY(t,e,i,n){return G()}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 G()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&re(t),this.extentRevision_=this.getRevision()}return Me(this.extent_,t)}rotate(t,e){G()}scale(t,e,i){G()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return G()}getType(){return G()}applyTransform(t){G()}intersectsExtent(t){return G()}translate(t,e){G()}transform(t,e){const i=In(t),n="tile-pixels"==i.getUnits()?function(t,n,r){const s=i.getExtent(),o=i.getWorldExtent(),a=Se(o)/Se(s);zt(ar,o[0],o[3],a,-a,0,0,0);const l=nr(t,0,t.length,r,ar,n),h=Xn(i,e);return h?h(l,l,r):l}:Xn(i,e);return this.applyTransform(n),this}}class hr extends lr{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return oe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return G()}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().length1)u=i;else{if(d>0){for(let r=0;rr&&(r=a),s=i,o=n}return r}function pr(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],u=t[s+1],d=t[i],g=t[i+1];for(let e=s+n;eo&&(c=e,o=i)}o>r&&(l[(c-e)/n]=1,s+nr&&(s[o++]=h,s[o++]=c,a=h,l=c);return h==a&&c==l||(s[o++]=h,s[o++]=c),o}function br(t,e){return e*Math.round(t/e)}function Pr(t,e,i,n,r,s,o){if(e==i)return o;let a,l,h=br(t[e],r),c=br(t[e+1],r);e+=n,s[o++]=h,s[o++]=c;do{if(a=br(t[e],r),l=br(t[e+1],r),(e+=n)==i)return s[o++]=a,s[o++]=l,o}while(a==h&&l==c);for(;e0&&f>d)&&(g<0&&p0&&p>g)?(a=i,l=u):(s[o++]=a,s[o++]=l,h=a,c=l,a=i,l=u)}return s[o++]=a,s[o++]=l,o}function Fr(t,e,i,n,r,s,o,a){for(let l=0,h=i.length;ls&&(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 Br(t,e,i,n,r,s){if(0===i.length)return!1;if(!Ur(t,e,i[0],n,r,s))return!1;for(let e=1,o=i.length;ey&&(c=(u+d)/2,Br(t,e,i,n,c,p)&&(_=c,y=r)),u=d}return isNaN(_)&&(_=r[o]),a?(a.push(_,p,y),a):[_,p,y]}function Vr(t,e,i,n,r){let s=[];for(let o=0,a=i.length;o=r[0]&&s[2]<=r[2]||(s[1]>=r[1]&&s[3]<=r[3]||Wr(t,e,i,n,(function(t,e){return Ie(r,t,e)})))))}function Zr(t,e,i,n,r){for(let s=0,o=i.length;s0}function Qr(t,e,i,n,r){r=void 0!==r&&r;for(let s=0,o=i.length;sthis.loader(this.getExtent(),e,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=ws.LOADED})).catch((t=>{this.state=ws.ERROR,console.error(t)})).finally((()=>this.changed()))}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}}function Ss(t,e,i){const n=t;let r=!0,s=!1,o=!1;const a=[O(n,M,(function(){o=!0,s||e()}))];return n.src&&dt?(s=!0,n.decode().then((function(){r&&e()})).catch((function(t){r&&(o?e():i())}))):a.push(O(n,w,i)),function(){r=!1,a.forEach(D)}}function Ts(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)}))}function Cs(t,e){return e&&(t.src=e),t.src&&dt?new Promise(((e,i)=>t.decode().then((()=>e(t))).catch((n=>t.complete&&t.width?e(t):i(n))))):Ts(t)}function Rs(t,e){return e&&(t.src=e),t.src&&dt&>?t.decode().then((()=>createImageBitmap(t))).catch((e=>{if(t.complete&&t.width)return t;throw e})):Cs(t)}class bs extends Es{constructor(t,e,i,n,r){super(t,e,i,void 0!==r?ws.IDLE:ws.LOADED),this.loader_=void 0!==r?r:null,this.canvas_=n,this.error_=null}getError(){return this.error_}handleLoad_(t){t?(this.error_=t,this.state=ws.ERROR):this.state=ws.LOADED,this.changed()}load(){this.state==ws.IDLE&&(this.state=ws.LOADING,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}}class Ps extends nt{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=q,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=$,this.unlistenImage_(),this.image_=function(){const t=pt(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=q:this.state=J,this.unlistenImage_(),this.changed()}load(){this.state==$&&(this.state=K,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==K&&(this.state=H,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=Ss(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}}class Fs{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_}}var Ms="opacity",Ls="visible",Is="extent",As="zIndex",Os="maxResolution",Ds="minResolution",Ns="maxZoom",ks="minZoom",Gs="source",js="map";class Us extends z{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);"object"==typeof t.properties&&(delete e.properties,Object.assign(e,t.properties)),e[Ms]=void 0!==t.opacity?t.opacity:1,Lt("number"==typeof e[Ms],"Layer opacity must be a number"),e[Ls]=void 0===t.visible||t.visible,e[As]=t.zIndex,e[Os]=void 0!==t.maxResolution?t.maxResolution:1/0,e[Ds]=void 0!==t.minResolution?t.minResolution:0,e[ks]=void 0!==t.minZoom?t.minZoom:-1/0,e[Ns]=void 0!==t.maxZoom?t.maxZoom:1/0,this.className_=void 0!==e.className?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:void 0===t||t},i=this.getZIndex();return e.opacity=ai(Math.round(100*this.getOpacity())/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=void 0!==i||e.managed?i:1/0,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return G()}getLayerStatesArray(t){return G()}getExtent(){return this.get(Is)}getMaxResolution(){return this.get(Os)}getMinResolution(){return this.get(Ds)}getMinZoom(){return this.get(ks)}getMaxZoom(){return this.get(Ns)}getOpacity(){return this.get(Ms)}getSourceState(){return G()}getVisible(){return this.get(Ls)}getZIndex(){return this.get(As)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(Is,t)}setMaxResolution(t){this.set(Os,t)}setMinResolution(t){this.set(Ds,t)}setMaxZoom(t){this.set(Ns,t)}setMinZoom(t){this.set(ks,t)}setOpacity(t){Lt("number"==typeof t,"Layer opacity must be a number"),this.set(Ms,t)}setVisible(t){this.set(Ls,t)}setZIndex(t){this.set(As,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}var Bs="prerender",zs="postrender",Xs="precompose",Vs="postcompose",Ws="rendercomplete",Ys=0,Zs=1,Ks={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};const Hs=42,qs=256;function $s(t,e,i){return function(n,r,s,o,a){if(!n)return;if(!r&&!e)return n;const l=e?0:s[0]*r,h=e?0:s[1]*r,c=a?a[0]:0,u=a?a[1]:0;let d=t[0]+l/2+c,g=t[2]-l/2+c,f=t[1]+h/2+u,p=t[3]-h/2+u;d>g&&(d=(g+d)/2,g=d),f>p&&(f=(p+f)/2,p=f);let m=ai(n[0],d,g),_=ai(n[1],f,p);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),_+=-t*Math.log(1+Math.max(0,f-n[1])/t)+t*Math.log(1+Math.max(0,n[1]-p)/t)}return[m,_]}}function Js(t){return t}function Qs(t,e,i,n){const r=be(e)/i[0],s=Se(e)/i[1];return n?Math.min(t,Math.max(r,s)):Math.min(t,Math.min(r,s))}function to(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),ai(n,i/2,2*e)}function eo(t,e,i,n){return e=void 0===e||e,function(r,s,o,l){if(void 0!==r){const h=t[0],c=t[t.length-1],u=i?Qs(h,i,o,n):h;if(l)return e?to(r,u,c):ai(r,c,u);const d=Math.min(u,r),g=Math.floor(a(t,d,s));return t[g]>u&&g1&&"function"==typeof arguments[i-1]&&(e=arguments[i-1],--i);let n=0;for(;n0}getInteracting(){return this.hints_[Zs]>0}cancelAnimations(){let t;this.setHint(Ys,-this.hints_[Ys]);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?gi(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(Ys,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=n[0].callback;t&&ho(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();return void 0!==n&&(i=[n[0]-e[0],n[1]-e[1]],Pi(i,t-this.getRotation()),Ei(i,e)),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?Hn(t,this.getProjection()):t}getCenterInternal(){return this.get(Ks.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 $n(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();Lt(e,"The view center is not defined");const i=this.getResolution();Lt(void 0!==i,"The view resolution is not defined");const n=this.getRotation();return Lt(void 0!==n,"The view rotation is not defined"),we(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(Ks.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Jn(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=be(t)/e[0],n=Se(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(Ks.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=po(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=a(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_?.length){if(1===this.resolutions_.length)return this.resolutions_[0];const e=ai(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,ai(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(Lt(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){Lt(!Fe(t),"Cannot fit empty extent provided as `geometry`");i=os(Jn(t,this.getProjection()))}else if("Circle"===t.getType()){const e=Jn(t.getExtent(),this.getProjection());i=os(e),i.rotate(this.getRotation(),xe(e))}else{const e=Kn();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{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;if(!t&&i&&(t=i.getView()),e=t instanceof lo?{viewState:t.getState(),extent:t.calculateExtent()}:t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray()),e.layerStatesArray){if(n=e.layerStatesArray.find((t=>t.layer===this)),!n)return!1}else n=this.getLayerState();const r=this.getExtent();return _o(n,e.viewState)&&(!r||Pe(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let i=e(t instanceof lo?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(js,t)}getMapInternal(){return this.get(js)}setMap(t){this.mapPrecomposeKey_&&(D(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(D(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=A(t,Xs,this.handlePrecompose_,this),this.mapRenderKey_=A(this,v,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);Lt(!e.some((t=>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)}setSource(t){this.set(Gs,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function _o(t,e){if(!t.visible)return!1;const i=e.resolution;if(i=t.maxResolution)return!1;const n=e.zoom;return n>t.minZoom&&n<=t.maxZoom}function yo(t,e,i=0,n=t.length-1,r=vo){for(;n>i;){if(n-i>600){const 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);yo(t,e,Math.max(i,Math.floor(e-o*l/s+h)),Math.min(n,Math.floor(e+(s-o)*l/s+h)),r)}const s=t[e];let o=i,a=n;for(xo(t,i,e),r(t[n],s)>0&&xo(t,i,n);o0;)a--}0===r(t[i],s)?xo(t,i,a):(a++,xo(t,a,n)),a<=e&&(i=a+1),e<=a&&(n=a-1)}}function xo(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function vo(t,e){return te?1:0}let wo=class{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(!Io(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=Ao(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,So(i,this.toBBox),So(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(i,o)}_splitRoot(t,e){this.data=Ao([t,e]),this.data.height=t.height+1,this.data.leaf=!1,So(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=To(t,0,o,this.toBBox),a=To(t,o,i,this.toBBox),l=Mo(e,a),h=Po(e)+Po(a);l=e;n--){const e=t.children[n];Co(o,t.leaf?r(e):e),a+=Fo(o)}return a}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)Co(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():So(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 Ao(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Oo(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;yo(t,o,e,i,r),s.push(e,o,o,i)}}var Do={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]},No={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]}}};No.max=No.whitepoint[2].D65,No.rgb=function(t,e){e=e||No.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))]},Do.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||No.whitepoint[2].E)[0],s*e[1],o*e[2]]};var ko={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,u;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=No.whitepoint[i][e][0])/(h+15*(c=No.whitepoint[i][e][1])+3*(u=No.whitepoint[i][e][2]))||0,r=a/(13*s)+9*c/(h+15*c+3*u)||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]}};No.luv=function(t,e,i){var n,r,s,o,a,l,h,c,u,d,g;e=e||"D65",i=i||2,d=4*(h=No.whitepoint[i][e][0])/(h+15*(c=No.whitepoint[i][e][1])+3*(u=No.whitepoint[i][e][2])),g=9*c/(h+15*c+3*u),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-d),13*s*(r-g)]};var Go,jo,Uo={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 ko.xyz(Uo.luv(t))}};function Bo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}ko.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]},No.lchuv=function(t){return ko.lchuv(No.luv(t))};var zo=Bo(jo?Go:(jo=1,Go={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]})),Xo={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};var Vo={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 Wo(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(),zo[t])n=zo[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!==Xo[t])return Xo[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]?Vo.min:Do.min,r="h"===i.space[0]?Vo.max:Do.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=Vo.rgb(e)),e.push(Math.min(Math.max(i.alpha,0),1)),e}Do.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 Yo=[NaN,NaN,NaN,0];function Zo(t){return"string"==typeof t?t:na(t)}const Ko=1024,Ho={};let qo=0;function $o(t){if(4===t.length)return t;const e=t.slice();return e[3]=1,e}function Jo(t){const e=No.lchuv(Do.xyz(t));return e[3]=t[3],e}function Qo(t){const e=No.rgb(Uo.xyz(t));return e[3]=t[3],e}function ta(t){if("none"===t)return Yo;if(Ho.hasOwnProperty(t))return Ho[t];if(qo>=Ko){let t=0;for(const e in Ho)0==(3&t++)&&(delete Ho[e],--qo)}const e=Wo(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 ia(e),Ho[t]=e,++qo,e}function ea(t){return Array.isArray(t)?t:ta(t)}function ia(t){return t[0]=ai(t[0]+.5|0,0,255),t[1]=ai(t[1]+.5|0,0,255),t[2]=ai(t[2]+.5|0,0,255),t[3]=ai(t[3],0,1),t}function na(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)+")"}class ra{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}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];0!=(3&t++)||i.hasListener()||(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const n=sa(t,e,i);return n in this.cache_?this.cache_[n]:null}getPattern(t,e,i){const n=sa(t,e,i);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,i,n,r){const s=sa(t,e,i),o=s in this.cache_;this.cache_[s]=n,r&&(n.getImageState()===ws.IDLE&&n.load(),n.getImageState()===ws.LOADING?n.ready().then((()=>{this.patternCache_[s]=_t().createPattern(n.getImage(1),"repeat")})):this.patternCache_[s]=_t().createPattern(n.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function sa(t,e,i){return e+":"+t+":"+(i?ea(i):"null")}const oa=new ra;let aa=null;class la extends x{constructor(t,e,i,n,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=void 0===n?ws.IDLE:n,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,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_===ws.LOADED){aa||(aa=pt(1,1,void 0,{willReadFrequently:!0})),aa.drawImage(this.image_,0,0);try{aa.getImageData(0,0,1,1),this.tainted_=!1}catch(t){aa=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(v)}handleImageError_(){this.imageState_=ws.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=ws.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=pt(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_===ws.IDLE){this.image_||this.initializeImage_(),this.imageState_=ws.LOADING;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch(t){this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Cs(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_!==ws.LOADED)return;const e=this.image_,i=pt(Math.ceil(e.width*t),Math.ceil(e.height*t)),n=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Zo(this.color_),i.fillRect(0,0,n.width/t,n.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=n}ready(){return this.ready_||(this.ready_=new Promise((t=>{if(this.imageState_===ws.LOADED||this.imageState_===ws.ERROR)t();else{const e=()=>{this.imageState_!==ws.LOADED&&this.imageState_!==ws.ERROR||(this.removeEventListener(v,e),t())};this.addEventListener(v,e)}}))),this.ready_}}function ha(t,e,i,n,r,s){let o=void 0===e?void 0:oa.get(e,i,r);return o||(o=new la(t,t&&"src"in t?t.src||void 0:e,i,n,r),oa.set(e,i,r,o,s)),s&&o&&!oa.getPattern(e,i,r)&&oa.set(e,i,r,o,s),o}function ca(t){return t[0]>0&&t[1]>0}function ua(t,e,i){return void 0===i&&(i=[0,0]),i[0]=t[0]*e+.5|0,i[1]=t[1]*e+.5|0,i}function da(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}class ga{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=da(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new ga({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 G()}getImage(t){return G()}getHitDetectionImage(){return G()}getPixelRatio(t){return 1}getImageState(){return G()}getImageSize(){return G()}getOrigin(){return G()}getSize(){return G()}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_=da(t)}listenImageChange(t){G()}load(){G()}unlistenImageChange(t){G()}ready(){return Promise.resolve()}}function fa(t){return t?Array.isArray(t)?na(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return oa.getPattern(t.src,"anonymous",t.color);const e=t.src+":"+t.offset,i=oa.getPattern(e,void 0,t.color);if(i)return i;const n=oa.get(t.src,"anonymous",null);if(n.getImageState()!==ws.LOADED)return null;const r=pt(t.size[0],t.size[1]);return r.drawImage(n.getImage(1),t.offset[0],t.offset[1],t.size[0],t.size[1],0,0,t.size[0],t.size[1]),ha(r.canvas,e,void 0,ws.LOADED,t.color,!0),oa.getPattern(e,void 0,t.color)}(t):t:null}const pa="ol-hidden",ma="ol-selectable",_a="ol-unselectable",ya="ol-unsupported",xa="ol-control",va="ol-collapsed",wa=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))","?\\s*([-,\\\"\\'\\sa-z]+?)\\s*$"].join(""),"i"),Ea=["style","variant","weight","size","lineHeight","family"],Sa=function(t){const e=t.match(wa);if(!e)return null;const i={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let t=0,n=Ea.length;tMath.max(e,Ba(t,i))),0);return i[e]=n,n}function Xa(t,e){const i=[],n=[],r=[];let s=0,o=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){const u=e[h];if("\n"===u||h===c){s=Math.max(s,o),r.push(o),o=0,a+=l,l=0;continue}const d=e[h+1]||t.font,g=Ba(d,u);i.push(g),o+=g;const f=ja(d);n.push(f),l=Math.max(l,f)}return{width:s,height:a,widths:i,heights:n,lineWidths:r}}function Va(t,e,i,n,r,s,o,a,l,h,c){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(c[0],c[1]),function(t,e){const i=t.contextInstructions;for(let t=0,n=i.length;tthis.imageState_=ws.LOADED)),this.render()}clone(){const t=this.getScale(),e=new Wa({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){const e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let n=oa.get(i,null,null)?.getImage(1);if(!n){const e=this.renderOptions_,r=Math.ceil(e.size*t),s=pt(r,r);this.draw_(e,s,t),n=s.canvas,oa.set(i,null,null,new la(n,void 0,null,ws.LOADED,null))}return n}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})),e.getImageState()===ws.IDLE&&e.load(),e.getImageState()===ws.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?U(t):"object"==typeof t&&"src"in t?t.src+":"+t.offset:ea(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}class Ka{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 Ka({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}}class Ha{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=tl,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 Ha({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_=tl,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function qa(t){let e;if("function"==typeof t)e=t;else{let i;if(Array.isArray(t))i=t;else{Lt("function"==typeof t.getZIndex,"Expected an `Style` or an array of `Style`");i=[t]}e=function(){return i}}return e}let $a=null;function Ja(t,e){if(!$a){const t=new Za({color:"rgba(255,255,255,0.4)"}),e=new Ka({color:"#3399CC",width:1.25});$a=[new Ha({image:new Ya({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return $a}function Qa(){const t={},e=[255,255,255,1],i=[0,153,255,1];return t.Polygon=[new Ha({fill:new Za({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new Ha({stroke:new Ka({color:e,width:5})}),new Ha({stroke:new Ka({color:i,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new Ha({image:new Ya({radius:6,fill:new Za({color:i}),stroke:new Ka({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function tl(t){return t.getGeometry()}function el(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 il extends ga{constructor(t){const e=void 0!==(t=t||{}).opacity?t.opacity:1,i=void 0!==t.rotation?t.rotation:0,n=void 0!==t.scale?t.scale:1,r=void 0!==t.rotateWithView&&t.rotateWithView;super({opacity:e,rotation:i,scale:n,displacement:void 0!==t.displacement?t.displacement:[0,0],rotateWithView:r,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 s=void 0!==t.img?t.img:null;let o,a=t.src;if(Lt(!(void 0!==a&&s),"`image` and `src` cannot be provided at the same time"),void 0!==a&&0!==a.length||!s||(a=s.src||U(s)),Lt(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),Lt(!((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?o=ws.IDLE:void 0!==s&&(o="complete"in s?s.complete?s.src?ws.LOADED:ws.IDLE:ws.LOADING:ws.LOADED),this.color_=void 0!==t.color?ea(t.color):null,this.iconImage_=ha(s,a,this.crossOrigin_,o,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(el(i[0],i[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale(el(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 il({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()==ws.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()==ws.LOADED?this.iconImage_.getSize()[1]*t[1]:void 0}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(v,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(v,t)}ready(){return this.iconImage_.ready()}}class nl{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=da(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 Za({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 nl({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),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_}getKeepUpright(){return this.keepUpright_}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}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=da(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}}let rl=0;const sl=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",Has:"has"},El={[wl.Get]:Fl(Cl(1,1/0),Sl),[wl.Var]:Fl(Cl(1,1),(function(t,e,i){const n=t[1];if("string"!=typeof n)throw new Error("expected a string argument for var operation");return i.variables.add(n),[new _l(al,n)]})),[wl.Has]:Fl(Cl(1,1/0),Sl),[wl.Id]:Fl((function(t,e,i){i.featureId=!0}),Tl),[wl.Concat]:Fl(Cl(2,1/0),bl(al)),[wl.GeometryType]:Fl((function(t,e,i){i.geometryType=!0}),Tl),[wl.LineMetric]:Fl(Tl),[wl.Resolution]:Fl(Tl),[wl.Zoom]:Fl(Tl),[wl.Time]:Fl(Tl),[wl.Any]:Fl(Cl(2,1/0),bl(sl)),[wl.All]:Fl(Cl(2,1/0),bl(sl)),[wl.Not]:Fl(Cl(1,1),bl(sl)),[wl.Equal]:Fl(Cl(2,2),bl(ul)),[wl.NotEqual]:Fl(Cl(2,2),bl(ul)),[wl.GreaterThan]:Fl(Cl(2,2),bl(ol)),[wl.GreaterThanOrEqualTo]:Fl(Cl(2,2),bl(ol)),[wl.LessThan]:Fl(Cl(2,2),bl(ol)),[wl.LessThanOrEqualTo]:Fl(Cl(2,2),bl(ol)),[wl.Multiply]:Fl(Cl(2,1/0),Rl),[wl.Coalesce]:Fl(Cl(2,1/0),Rl),[wl.Divide]:Fl(Cl(2,2),bl(ol)),[wl.Add]:Fl(Cl(2,1/0),bl(ol)),[wl.Subtract]:Fl(Cl(2,2),bl(ol)),[wl.Clamp]:Fl(Cl(3,3),bl(ol)),[wl.Mod]:Fl(Cl(2,2),bl(ol)),[wl.Pow]:Fl(Cl(2,2),bl(ol)),[wl.Abs]:Fl(Cl(1,1),bl(ol)),[wl.Floor]:Fl(Cl(1,1),bl(ol)),[wl.Ceil]:Fl(Cl(1,1),bl(ol)),[wl.Round]:Fl(Cl(1,1),bl(ol)),[wl.Sin]:Fl(Cl(1,1),bl(ol)),[wl.Cos]:Fl(Cl(1,1),bl(ol)),[wl.Atan]:Fl(Cl(1,2),bl(ol)),[wl.Sqrt]:Fl(Cl(1,1),bl(ol)),[wl.Match]:Fl(Cl(4,1/0),Pl,(function(t,e,i){const n=t.length-1,r=al|ol|sl,s=vl(t[1],r,i),o=vl(t[t.length-1],e,i),a=new Array(n-2);for(let e=0;ee){throw new Error(`expected ${e===1/0?`${t} or more`:`${t} to ${e}`} arguments for ${s}, got ${o}`)}}}function Rl(t,e,i){const n=t.length-1,r=new Array(n);for(let s=0;s{for(let e=0;e{for(let e=0;e{const i=t.args;let r=e.properties[n];for(let t=1,e=i.length;tt.variables[n];case wl.Has:return e=>{const i=t.args;if(!(n in e.properties))return!1;let r=e.properties[n];for(let t=1,e=i.length;tt.featureId;case wl.GeometryType:return t=>t.geometryType;case wl.Concat:{const e=t.args.map((t=>Al(t)));return t=>"".concat(...e.map((e=>e(t).toString())))}case wl.Resolution:return t=>t.resolution;case wl.Any:case wl.All:case wl.Between:case wl.In:case wl.Not:return function(t,e){const i=t.operator,n=t.args.length,r=new Array(n);for(let e=0;e{for(let e=0;e{for(let e=0;e{const e=r[0](t),i=r[1](t),n=r[2](t);return e>=i&&e<=n};case wl.In:return t=>{const e=r[0](t);for(let i=1;i!r[0](t);default:throw new Error(`Unsupported logical operator ${i}`)}}(t);case wl.Equal:case wl.NotEqual:case wl.LessThan:case wl.LessThanOrEqualTo:case wl.GreaterThan:case wl.GreaterThanOrEqualTo:return function(t,e){const i=t.operator,n=Al(t.args[0]),r=Al(t.args[1]);switch(i){case wl.Equal:return t=>n(t)===r(t);case wl.NotEqual:return t=>n(t)!==r(t);case wl.LessThan:return t=>n(t)n(t)<=r(t);case wl.GreaterThan:return t=>n(t)>r(t);case wl.GreaterThanOrEqualTo:return t=>n(t)>=r(t);default:throw new Error(`Unsupported comparison operator ${i}`)}}(t);case wl.Multiply:case wl.Divide:case wl.Add:case wl.Subtract:case wl.Clamp:case wl.Mod:case wl.Pow:case wl.Abs:case wl.Floor:case wl.Ceil:case wl.Round:case wl.Sin:case wl.Cos:case wl.Atan:case wl.Sqrt:return function(t,e){const i=t.operator,n=t.args.length,r=new Array(n);for(let e=0;e{let e=1;for(let i=0;ir[0](t)/r[1](t);case wl.Add:return t=>{let e=0;for(let i=0;ir[0](t)-r[1](t);case wl.Clamp:return t=>{const e=r[0](t),i=r[1](t);if(en?n:e};case wl.Mod:return t=>r[0](t)%r[1](t);case wl.Pow:return t=>Math.pow(r[0](t),r[1](t));case wl.Abs:return t=>Math.abs(r[0](t));case wl.Floor:return t=>Math.floor(r[0](t));case wl.Ceil:return t=>Math.ceil(r[0](t));case wl.Round:return t=>Math.round(r[0](t));case wl.Sin:return t=>Math.sin(r[0](t));case wl.Cos:return t=>Math.cos(r[0](t));case wl.Atan:return 2===n?t=>Math.atan2(r[0](t),r[1](t)):t=>Math.atan(r[0](t));case wl.Sqrt:return t=>Math.sqrt(r[0](t));default:throw new Error(`Unsupported numeric operator ${i}`)}}(t);case wl.Case:return function(t,e){const i=t.args.length,n=new Array(i);for(let e=0;e{for(let e=0;e{const e=n[0](t);for(let r=1;r{const e=n[0](t),r=n[1](t);let s,o;for(let a=2;a=r)return 2===a?l:h?Dl(e,r,s,o,i,l):Ol(e,r,s,o,i,l);s=i,o=l}return o}}(t);case wl.ToString:return function(t,e){const i=t.operator,n=t.args.length,r=new Array(n);for(let e=0;e{const i=r[0](e);return t.args[0].type===ll?na(i):i.toString()};throw new Error(`Unsupported convert operator ${i}`)}(t);default:throw new Error(`Unsupported operator ${i}`)}}function Ol(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 Dl(t,e,i,n,r,s){if(0===r-i)return n;const o=Jo(n),a=Jo(s);let l=a[2]-o[2];l>180?l-=360:l<-180&&(l+=360);return ia(Qo([Ol(t,e,i,o[0],r,a[0]),Ol(t,e,i,o[1],r,a[1]),o[2]+Ol(t,e,i,0,r,l),Ol(t,e,i,n[3],r,s[3])]))}function Nl(t){return!0}function kl(t){const e=xl(),i=jl(t,e),n={variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""};return function(t,r){if(n.properties=t.getPropertiesInternal(),n.resolution=r,e.featureId){const e=t.getId();n.featureId=void 0!==e?e:null}return e.geometryType&&(n.geometryType=Ml(t.getGeometry())),i(n)}}function Gl(t){const e=xl(),i=t.length,n=new Array(i);for(let r=0;rnull;n=Yl(t,e+"fill-color",i)}if(!n)return null;const r=new Za;return function(t){const e=n(t);return e===Yo?null:(r.setColor(e),r)}}function zl(t,e,i){const n=Xl(t,e+"stroke-width",i),r=Yl(t,e+"stroke-color",i);if(!n&&!r)return null;const s=Vl(t,e+"stroke-line-cap",i),o=Vl(t,e+"stroke-line-join",i),a=Zl(t,e+"stroke-line-dash",i),l=Xl(t,e+"stroke-line-dash-offset",i),h=Xl(t,e+"stroke-miter-limit",i),c=new Ka;return function(t){if(r){const e=r(t);if(e===Yo)return null;c.setColor(e)}if(n&&c.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");c.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");c.setLineJoin(e)}return a&&c.setLineDash(a(t)),l&&c.setLineDashOffset(l(t)),h&&c.setMiterLimit(h(t)),c}}function Xl(t,e,i){if(!(e in t))return;const n=Il(t[e],ol,i);return function(t){return nh(n(t),e)}}function Vl(t,e,i){if(!(e in t))return null;const n=Il(t[e],al,i);return function(t){return ih(n(t),e)}}function Wl(t,e,i){if(!(e in t))return null;const n=Il(t[e],sl,i);return function(t){const i=n(t);if("boolean"!=typeof i)throw new Error(`Expected a boolean for ${e}`);return i}}function Yl(t,e,i){if(!(e in t))return null;const n=Il(t[e],ll,i);return function(t){return rh(n(t),e)}}function Zl(t,e,i){if(!(e in t))return null;const n=Il(t[e],hl,i);return function(t){return eh(n(t),e)}}function Kl(t,e,i){if(!(e in t))return null;const n=Il(t[e],hl,i);return function(t){const i=eh(n(t),e);if(2!==i.length)throw new Error(`Expected two numbers for ${e}`);return i}}function Hl(t,e,i){if(!(e in t))return null;const n=Il(t[e],hl,i);return function(t){return sh(n(t),e)}}function ql(t,e,i){if(!(e in t))return null;const n=Il(t[e],hl|ol,i);return function(t){return function(t,e){if("number"==typeof t)return t;return sh(t,e)}(n(t),e)}}function $l(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 Jl(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 Ql(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 th(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 eh(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 sh(t,e){const i=eh(t,e);if(2!==i.length)throw new Error(`Expected an array of two numbers for ${e}`);return i}const oh="renderOrder";class ah extends mo{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(oh)}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 wo(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(oh,t)}setStyle(t){this.style_=void 0===t?Ja:t;const e=function(t){if(void 0===t)return Ja;if(!t)return null;if("function"==typeof t)return t;if(t instanceof Ha)return t;if(!Array.isArray(t))return Gl([t]);if(0===t.length)return[];const e=t.length,i=t[0];if(i instanceof Ha){const i=new Array(e);for(let n=0;n=0;--r){const s=f[r],u=s.layer;if(u.hasRenderer()&&_o(s,h)&&o.call(a,u)){const r=u.getRenderer(),o=u.getSource();if(r&&o){const a=o.getWrapX()?d:t,h=c.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,d,this,r,s)}getMap(){return this.map_}renderFrame(t){G()}scheduleExpireIconCache(t){oa.canExpireCache()&&t.postRenderFunctions.push(hh)}}function hh(t,e){oa.expire()}class ch extends t{constructor(t,e,i,n){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=n}}class uh extends lh{constructor(t){super(t),this.fontChangeListenerKey_=A(Oa,i,t.redrawText,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=_a+" ol-layers";const n=t.getViewport();n.insertBefore(this.element_,n.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const n=new ch(t,void 0,e);i.dispatchEvent(n)}}disposeInternal(){D(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(Xs,t);const e=t.layerStatesArray.sort(((t,e)=>t.zIndex-e.zIndex));e.some((t=>t.layer instanceof ah&&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 dh extends t{constructor(t,e){super(t),this.layer=e}}const gh="layers";class fh extends Us{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(gh,this.handleLayersChanged_),i?Array.isArray(i)?i=new Z(i.slice(),{unique:!0}):Lt("function"==typeof i.getArray,"Expected `layers` to be an array or a `Collection`"):i=new Z(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(D),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(A(t,X,this.handleLayersAdd_,this),A(t,V,this.handleLayersRemove_,this));for(const t in this.listenerKeys_)this.listenerKeys_[t].forEach(D);_(this.listenerKeys_);const e=t.getArray();for(let t=0,i=e.length;t{this.clickTimeoutId_=void 0;const e=new mh(_h.SINGLECLICK,this.map_,t);this.dispatchEvent(e)}),250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==_h.POINTERUP||e.type==_h.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!=_h.POINTERDOWN&&e.type!=_h.POINTERMOVE||(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new mh(_h.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(D),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 mh(_h.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(A(t,_h.POINTERMOVE,this.handlePointerMove_,this),A(t,_h.POINTERUP,this.handlePointerUp_,this),A(this.element_,_h.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==t&&this.dragListenerKeys_.push(A(this.element_.getRootNode(),_h.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new mh(_h.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 mh(_h.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_&&(D(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(L,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(D(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(D),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}var Sh="postrender",Th="movestart",Ch="moveend",Rh="loadstart",bh="loadend",Ph="layergroup",Fh="size",Mh="target",Lh="view";const Ih=1/0;class Ah{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,_(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){Lt(!(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()!==K||e in this.tilesLoadingKeys_||(this.tilesLoadingKeys_[e]=!0,++this.tilesLoading_,++i,t.load())}}}function Dh(t,e,i,n,r){if(!t||!(i in t.wantedTiles))return Ih;if(!t.wantedTiles[i][e.getKey()])return Ih;const s=t.viewState.center,o=n[0]-s[0],a=n[1]-s[1];return 65536*Math.log(r)+Math.sqrt(o*o+a*a)/r}class Nh extends z{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(void 0!==this.attributions_&&(Array.isArray(this.attributions_)?this.attributions_.forEach((t=>i.add(t))):i.add(this.attributions_)),!this.overrideCollapsible_){const t=!e.some((t=>!1===t.getSource()?.getAttributionsCollapsible()));this.setCollapsible(t)}return Array.from(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=>m((()=>t))))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!c(e,this.renderedAttributions_)){Et(this.ulElement_);for(let t=0,i=e.length;t0&&e%(2*Math.PI)!=0?t.animate({rotation:0,duration:this.duration_,easing:tt}):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(pa);t||0!==i?t&&0!==i&&this.element.classList.remove(pa):this.element.classList.add(pa)}this.label_.style.transform=t}this.rotation_=i}}class jh extends Nh{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(S,this.handleClick_.bind(this,i),!1);const c=document.createElement("button");c.className=r,c.setAttribute("type","button"),c.title=l,c.appendChild("string"==typeof o?document.createTextNode(o):o),c.addEventListener(S,this.handleClick_.bind(this,-i),!1);const u=e+" "+_a+" "+xa,d=this.element;d.className=u,d.appendChild(h),d.appendChild(c),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:tt})):e.setZoom(n)}}}function Uh(t){t=t||{};const e=new Z;(void 0===t.zoom||t.zoom)&&e.push(new jh(t.zoomOptions));(void 0===t.rotate||t.rotate)&&e.push(new Gh(t.rotateOptions));return(void 0===t.attribution||t.attribution)&&e.push(new kh(t.attributionOptions)),e}var Bh="active";class zh extends z{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(Bh)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Bh,t)}setMap(t){this.map_=t}}function Xh(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:it,center:t.getConstrainedCenter(r)})}}function Vh(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:tt})}class Wh extends zh{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==_h.DBLCLICK){const i=t.originalEvent,n=t.map,r=t.coordinate,s=i.shiftKey?-this.delta_:this.delta_;Vh(n.getView(),s,r,this.duration_),i.preventDefault(),e=!0}return!e}}class Yh extends zh{constructor(t){super(t=t||{}),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==_h.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==_h.POINTERUP){const e=this.handleUpEvent(t);this.handlingDownUpSequence=e&&this.targetPointers.length>0}}else if(t.type==_h.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==_h.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 Zh(t){const e=t.length;let i=0,n=0;for(let r=0;r0&&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}}class cc extends Yh{constructor(t){t=t||{},super({stopDown:g}),this.condition_=t.condition?t.condition:qh,this.lastAngle_=void 0,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){if(!ac(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===ro)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(!ac(t))return!0;return t.map.getView().endInteraction(this.duration_),!1}handleDownEvent(t){if(!ac(t))return!1;if(tc(t)&&this.condition_(t)){return t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0}return!1}}class uc extends n{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 rs([i])}getGeometry(){return this.geometry_}}const dc="boxstart",gc="boxdrag",fc="boxend",pc="boxcancel";class mc extends t{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class _c extends Yh{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new uc(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??tc,this.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 mc(gc,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new mc(e?fc:pc,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!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 mc(dc,t.coordinate,t)),!0)}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new mc(pc,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new mc(pc,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class yc extends _c{constructor(t){super({condition:(t=t||{}).condition?t.condition:sc,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:tt})}}var xc="ArrowLeft",vc="ArrowUp",wc="ArrowRight",Ec="ArrowDown";class Sc extends zh{constructor(t){super(),t=t||{},this.defaultCondition_=function(t){return nc(t)&&oc(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==P){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==Ec||n==xc||n==wc||n==vc)){const r=t.map.getView(),s=r.getResolution()*this.pixelDelta_;let o=0,a=0;n==Ec?a=-s:n==xc?o=-s:n==wc?o=s:a=s;const l=[o,a];Pi(l,r.getRotation()),Xh(r,l,this.duration_),i.preventDefault(),e=!0}}return!e}}class Tc extends zh{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(t){return!rc(t)&&oc(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==P||t.type==F){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&("+"===n||"-"===n)){const r=t.map,s="+"===n?this.delta_:-this.delta_;Vh(r.getView(),s,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}class Cc extends zh{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:Qh;this.condition_=t.onFocusOnly?Kh(Jh,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_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t))return!0;if(t.type!==I)return!0;const e=t.map,i=t.originalEvent;let n;if(i.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel),t.type==I&&(n=i.deltaY,st&&i.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(n/=ct),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_?e.getCoordinateFromPixel(this.lastAnchor_):null),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=-ai(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Vh(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,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)}}class Rc extends Yh{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=g),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!==ro&&(this.anchor_=s.getCoordinateFromPixelInternal(s.getEventPixel(Zh(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}}class bc extends Yh{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=g),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(Zh(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 Pc(t){t=t||{};const e=new Z,i=new Fs(-.005,.05,100);(void 0===t.altShiftDragRotate||t.altShiftDragRotate)&&e.push(new cc);(void 0===t.doubleClickZoom||t.doubleClickZoom)&&e.push(new Wh({delta:t.zoomDelta,duration:t.zoomDuration}));(void 0===t.dragPan||t.dragPan)&&e.push(new hc({onFocusOnly:t.onFocusOnly,kinetic:i}));(void 0===t.pinchRotate||t.pinchRotate)&&e.push(new Rc);(void 0===t.pinchZoom||t.pinchZoom)&&e.push(new bc({duration:t.zoomDuration}));(void 0===t.keyboard||t.keyboard)&&(e.push(new Sc),e.push(new Tc({delta:t.zoomDelta,duration:t.zoomDuration})));(void 0===t.mouseWheelZoom||t.mouseWheelZoom)&&e.push(new Cc({onFocusOnly:t.onFocusOnly,duration:t.zoomDuration}));return(void 0===t.shiftDragZoom||t.shiftDragZoom)&&e.push(new yc({duration:t.zoomDuration})),e}function Fc(t){t instanceof mo?t.setMapInternal(null):t instanceof fh&&t.getLayers().forEach(Fc)}function Mc(t,e){if(t instanceof mo)t.setMapInternal(e);else if(t instanceof fh){const i=t.getLayers().getArray();for(let t=0,n=i.length;tthis.updateSize())),this.controls=e.controls||Uh(),this.interactions=e.interactions||Pc({onFocusOnly:!0}),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Oh(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Ph,this.handleLayerGroupChanged_),this.addChangeListener(Lh,this.handleViewChanged_),this.addChangeListener(Fh,this.handleSizeChanged_),this.addChangeListener(Mh,this.handleTargetChanged_),this.setProperties(e.values);const i=this;!t.view||t.view instanceof lo||t.view.then((function(t){i.setView(new lo(t))})),this.controls.addEventListener(X,(t=>{t.element.setMap(this)})),this.controls.addEventListener(V,(t=>{t.element.setMap(null)})),this.interactions.addEventListener(X,(t=>{t.element.setMap(this)})),this.interactions.addEventListener(V,(t=>{t.element.setMap(null)})),this.overlays_.addEventListener(X,(t=>{this.addOverlayInternal_(t.element)})),this.overlays_.addEventListener(V,(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){Mc(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:d,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 fh?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:d,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(Mh)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Hn(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?jt(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(Ph)}setLayers(t){const e=this.getLayerGroup();if(t instanceof Z)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[Ys]||e[Zs]){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 dh("removelayer",e)),this.set(Ph,t)}setSize(t){this.set(Fh,t)}setTarget(t){this.set(Mh,t)}setView(t){if(!t||t instanceof lo)return void this.set(Lh,t);this.set(Lh,new lo);const e=this;t.then((function(t){e.setView(new lo(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)],!ca(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&En("No map visible because the map container's width or height are 0."))}const i=this.getSize();!e||i&&c(e,i)||(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}}const Ic="element",Ac="map",Oc="offset",Dc="position",Nc="positioning";class kc extends z{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 "+ma,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(Ic,this.handleElementChanged),this.addChangeListener(Ac,this.handleMapChanged),this.addChangeListener(Oc,this.handleOffsetChanged),this.addChangeListener(Dc,this.handlePositionChanged),this.addChangeListener(Nc,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(Ic)}getId(){return this.id}getMap(){return this.get(Ac)||null}getOffset(){return this.get(Oc)}getPosition(){return this.get(Dc)}getPositioning(){return this.get(Nc)}handleElementChanged(){Et(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),D(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=A(t,Sh,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(Ic,t)}setMap(t){this.set(Ac,t)}setOffset(t){this.set(Oc,t)}setPosition(t){this.set(Dc,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(Dc))return;const i=this.getRect(e.getTargetElement(),e.getSize()),n=this.getElement(),r=this.getRect(n,[xt(n),vt(n)]),s=void 0===(t=t||{}).margin?20:t.margin;if(!Qt(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(Nc,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}}class Gc{constructor(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof n&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}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 Lt(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 Lt(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){Lt(!(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 jc(t,e,i,n){return void 0!==n?(n[0]=t,n[1]=e,n[2]=i,n):[t,e,i]}function Uc(t,e,i){return t+"/"+e+"/"+i}function Bc(t){return Uc(t[0],t[1],t[2])}function zc(t){return t.split("/").map(Number)}function Xc(t){return Vc(t[0],t[1],t[2])}function Vc(t,e,i){return(e<i||i>e.getMaxZoom())return!1;const s=e.getFullTileRange(i);return!s||s.containsXY(n,r)}class Yc{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 Zc(t,e,i,n,r){return void 0!==r?(r.minX=t,r.maxX=e,r.minY=i,r.maxY=n,r):new Yc(t,e,i,n)}const Kc=[];let Hc,qc=!1;function $c(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=qc,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 Jc(t,e){return function(i,n,r,s,o){const a=this;$c(t,e,i,n,r,(function(t,e){a.addFeatures(t),void 0!==s&&s(t)}),o||f)}}function Qc(t,e){return[[-1/0,-1/0,1/0,1/0]]}function tu(t,e,i,n){const r=document.createElement("script"),s="olc_"+U(e);function o(){delete window[s],r.parentNode.removeChild(r)}r.async=!0,r.src=t+(t.includes("?")?"&":"?")+(n||"callback")+"="+s;const a=setTimeout((function(){o(),i&&i()}),1e4);window[s]=function(t){clearTimeout(a),o(),e(t)},document.head.appendChild(r)}class eu extends Error{constructor(t){super("Unexpected response status: "+t.status),this.name="ResponseError",this.response=t}}class iu extends Error{constructor(t){super("Failed to issue request"),this.name="ClientError",this.client=t}}function nu(t){return new Promise((function(e,i){const n=new XMLHttpRequest;n.addEventListener("load",(function(t){const n=t.target;if(!n.status||n.status>=200&&n.status<300){let t;try{t=JSON.parse(n.responseText)}catch(t){const e="Error parsing response text as JSON: "+t.message;return void i(new Error(e))}e(t)}else i(new eu(n))})),n.addEventListener("error",(function(t){i(new iu(t.target))})),n.open("GET",t),n.setRequestHeader("Accept","application/json"),n.send()}))}function ru(t,e){return e.includes("://")?e:new URL(e,t).href}class su{drawCustom(t,e,i,n,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}class ou extends su{constructor(t,e,i,n,r,s,o){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=n,this.transformRotation_=n?pi(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=nr(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:Pa,lineWidth:(void 0!==o?o:1)*this.pixelRatio_,miterLimit:void 0!==a?a:Fa,strokeStyle:fa(t||Ma)}}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:fa(t||Ca)}}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:Ra,lineDash:n||ba,lineDashOffset:r||0,lineJoin:void 0!==s?s:Pa,lineWidth:void 0!==o?o:1,miterLimit:void 0!==a?a:Fa,strokeStyle:fa(t||Ma)}}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(),c=t.getTextAlign(),u=t.getTextBaseline();this.textState_={font:void 0!==n?n:Ta,textAlign:void 0!==c?c:La,textBaseline:void 0!==u?u:Ia},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 au=.5,lu={Point:function(t,e,i,n,r,s){const o=i.getImage(),a=i.getText(),l=a&&a.getText(),h=s&&o&&l?{}:void 0;if(o){if(o.getImageState()!=ws.LOADED)return;const s=t.getBuilder(i.getZIndex(),"Image");s.setImageStyle(o,h),s.drawPoint(e,n,r)}if(l){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(a,h),s.drawText(e,n,r)}},LineString:function(t,e,i,n,r){const s=i.getStroke();if(s){const o=t.getBuilder(i.getZIndex(),"LineString");o.setFillStrokeStyle(null,s),o.drawLineString(e,n,r)}const o=i.getText();if(o&&o.getText()){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(o),s.drawText(e,n,r)}},Polygon:function(t,e,i,n,r){const s=i.getFill(),o=i.getStroke();if(s||o){const a=t.getBuilder(i.getZIndex(),"Polygon");a.setFillStrokeStyle(s,o),a.drawPolygon(e,n,r)}const a=i.getText();if(a&&a.getText()){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,n,r)}},MultiPoint:function(t,e,i,n,r,s){const o=i.getImage(),a=o&&0!==o.getOpacity(),l=i.getText(),h=l&&l.getText(),c=s&&a&&h?{}:void 0;if(a){if(o.getImageState()!=ws.LOADED)return;const s=t.getBuilder(i.getZIndex(),"Image");s.setImageStyle(o,c),s.drawMultiPoint(e,n,r)}if(h){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(l,c),s.drawText(e,n,r)}},MultiLineString:function(t,e,i,n,r){const s=i.getStroke();if(s){const o=t.getBuilder(i.getZIndex(),"LineString");o.setFillStrokeStyle(null,s),o.drawMultiLineString(e,n,r)}const o=i.getText();if(o&&o.getText()){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(o),s.drawText(e,n,r)}},MultiPolygon:function(t,e,i,n,r){const s=i.getFill(),o=i.getStroke();if(o||s){const a=t.getBuilder(i.getZIndex(),"Polygon");a.setFillStrokeStyle(s,o),a.drawMultiPolygon(e,n,r)}const a=i.getText();if(a&&a.getText()){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,n,r)}},GeometryCollection:function(t,e,i,n,r,s){const o=e.getGeometriesArray();let a,l;for(a=0,l=o.length;a0;return u&&Promise.all(l).then((()=>r(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)gu(t,l,i,e,o);else{(0,lu[l.getType()])(t,l,i,e,o,s)}}(t,e,i,n,s,o,a),u}function gu(t,e,i,n,r){if("GeometryCollection"==e.getType()){const s=e.getGeometries();for(let e=0,o=s.length;e2||Math.abs(t[4*e+3]-191.25)>2}function xu(t,e,i,n){const r=Vn(i,e,t);let s=An(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||Jt(l,r)){const e=An(t,s,r)/s;isFinite(e)&&e>0&&(s/=e)}return s}function vu(t,e,i,n){const r=xe(i);let s=xu(t,e,r,n);return(!isFinite(s)||s<=0)&&pe(i,(function(i){return s=xu(t,e,i,n),isFinite(s)&&s>0})),s}function wu(t,e,i,n,r,s,o,a,l,h,c,u,d,g){const f=pt(Math.round(i*t),Math.round(i*e),mu);if(u||(f.imageSmoothingEnabled=!1),0===l.length)return f.canvas;function p(t){return Math.round(t*i)/i}f.scale(i,i),f.globalCompositeOperation="lighter";const m=[1/0,1/0,-1/0,-1/0];let _;l.forEach((function(t,e,i){he(m,t.extent)}));const y=i/n,x=(u?1:1+Math.pow(2,-24))/y;if(!d||1!==l.length||0!==h){if(_=pt(Math.round(be(m)*y),Math.round(Se(m)*y),mu),u||(_.imageSmoothingEnabled=!1),r&&g){const t=(r[0]-m[0])*y,e=-(r[3]-m[3])*y,i=be(r)*y,n=Se(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=be(t.clipExtent)*y,r=Se(t.clipExtent)*y;_.rect(u?e:Math.round(e),u?i:Math.round(i),u?n:Math.round(e+n)-Math.round(e),u?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=be(t.extent)*y,r=Se(t.extent)*y;_.drawImage(t.image,h,h,t.image.width-2*h,t.image.height-2*h,u?e:Math.round(e),u?i:Math.round(i),u?n:Math.round(e+n)-Math.round(e),u?r:Math.round(i+r)-Math.round(i)),t.clipExtent&&_.restore()}}))}const v=Ce(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],c=n[1][1],d=n[2][0],g=n[2][1];const y=p((r[0][0]-v[0])/s),w=p(-(r[0][1]-v[1])/s),E=p((r[1][0]-v[0])/s),S=p(-(r[1][1]-v[1])/s),T=p((r[2][0]-v[0])/s),C=p(-(r[2][1]-v[1])/s),R=o,b=a;o=0,a=0,h-=R,c-=b,d-=R,g-=b;const P=ci([[h,c,0,0,E-y],[d,g,0,0,T-y],[0,0,h,c,S-w],[0,0,d,g,C-w]]);if(!P)return;if(f.save(),f.beginPath(),function(){if(void 0===pu){const t=pt(6,6,mu);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",_u(t,4,5,4,0),_u(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;pu=yu(e,0)||yu(e,4)||yu(e,8),yt(t),mu.push(t.canvas)}return pu}()||!u){f.moveTo(E,S);const t=4,e=y-E,i=w-S;for(let n=0;njt(o,Vn(t,this.targetProj_,this.sourceProj_)))):Xn(this.targetProj_,this.sourceProj_);this.transformInv_=function(t){const e=t[0]+"/"+t[1];return a[e]||(a[e]=l(t)),a[e]},this.maxSourceExtent_=n,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&be(n)>=be(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?be(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?be(this.targetProj_.getExtent()):null;const h=Ce(i),c=Re(i),u=ye(i),d=_e(i),g=this.transformInv_(h),f=this.transformInv_(c),p=this.transformInv_(u),m=this.transformInv_(d),_=10+(s?Math.max(0,Math.ceil(Math.log2(me(i)/(s*s*256*256)))):0);if(this.addQuad_(h,c,u,d,g,f,p,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&&c<1;let g=!1;if(l>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){g=be(Kt([t,e,i,n]))/this.targetWorldWidth_>.25||g}!d&&this.sourceProj_.isGlobal()&&c&&(g=c>.25||g)}if(!g&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!Pe(h,this.maxSourceExtent_))return;let f=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(f=(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!=f&&2!=f&&4!=f&&8!=f)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=(gi(r[0],u)+gi(o[0],u))/2-gi(n[0],u)}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],c=this.transformInv_(h),u=[(n[0]+t[0])/2,(n[1]+t[1])/2],d=this.transformInv_(u);this.addQuad_(t,e,h,u,r,s,c,d,l-1),this.addQuad_(u,h,i,n,d,c,o,a,l-1)}else{const h=[(t[0]+e[0])/2,(t[1]+e[1])/2],c=this.transformInv_(h),u=[(i[0]+n[0])/2,(i[1]+n[1])/2],d=this.transformInv_(u);this.addQuad_(t,h,u,n,r,c,d,a,l-1),this.addQuad_(h,e,i,u,c,s,o,d,l-1)}return}}if(d){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}0==(11&f)&&this.addTriangle_(t,i,n,r,o,a),0==(14&f)&&this.addTriangle_(t,i,e,r,o,s),f&&(0==(13&f)&&this.addTriangle_(e,n,t,s,a,r),0==(7&f)&&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;ce(t,r[0]),ce(t,r[1]),ce(t,r[2])})),t}getTriangles(){return this.triangles_}}class Cu extends nt{constructor(t,e,i,n,r,s,o,a,l,h,c,u){super(r,K,u),this.renderEdges_=void 0!==c&&c,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 f=this.sourceTileGrid_.getExtent();const p=g?Te(d,g):d;if(0===me(p))return void(this.state=J);const m=t.getExtent();m&&(f=f?Te(f,m):m);const _=n.getResolution(this.wrappedTileCoord_[0]),y=vu(t,i,p,_);if(!isFinite(y)||y<=0)return void(this.state=J);const x=void 0!==h?h:Su;if(this.triangulation_=new Tu(t,i,p,f,y*x,_),0===this.triangulation_.getTriangles().length)return void(this.state=J);this.sourceZ_=e.getZForResolution(y);let v=this.triangulation_.calculateSourceExtent();if(f&&(t.canWrapX()?(v[1]=ai(v[1],f[1],f[3]),v[3]=ai(v[3],f[1],f[3])):v=Te(v,f)),me(v)){let i=0,n=0;t.canWrapX()&&(i=be(m),n=Math.floor((v[0]-m[0])/i));De(v.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=J)}else this.state=J}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach((e=>{const i=e.tile;if(i&&i.getState()==q){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=$;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_=wu(n,r,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),s,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=q}this.changed()}load(){if(this.state==K){this.state=H,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach((({tile:e})=>{const i=e.getState();if(i==K||i==H){t++;const i=A(e,v,(n=>{const r=e.getState();r!=q&&r!=$&&r!=J||(D(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()==K&&t.load()}))}}unlistenSources_(){this.sourcesListenerKeys_.forEach(D),this.sourcesListenerKeys_=null}release(){this.canvas_&&(yt(this.canvas_.getContext("2d")),mu.push(this.canvas_),this.canvas_=null),super.release()}}var Ru="tileloadstart",bu="tileloadend",Pu="tileloaderror";class Fu extends z{constructor(t){super(),this.projection=In(t.projection),this.attributions_=Mu(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_=Mu(t),this.changed()}setState(t){this.state_=t,this.changed()}}function Mu(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),e=>t):null}const Lu=[0,0,0];class Iu{constructor(t){let e;if(this.minZoom=void 0!==t.minZoom?t.minZoom:0,this.resolutions_=t.resolutions,Lt(u(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 Yc(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=Zc(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)||i.find((function(i){return e[h]==i[l]||!e[h].includes(":")&&t[h]+":"+e[h]===i[l]})),d){r.push(e[h]);const t=28e-5*e[c]/g,i=e.TileWidth,l=e.TileHeight;f?s.push([e[u][1],e[u][0]]):s.push(e[u]),n.push(t),o.push(i==l?i:[i,l]),a.push([e.MatrixWidth,e.MatrixHeight])}})),new Au({extent:e,origins:s,resolutions:n,matrixIds:r,tileSizes:o,sizes:a})}function Du(t){let e=t.getDefaultTileGrid();return e||(e=Uu(t),t.setDefaultTileGrid(e)),e}function Nu(t,e,i){const n=e[0],r=t.getTileCoordCenter(e),s=Bu(i);if(!Jt(s,r)){const e=be(s),i=Math.ceil((s[0]-r[0])/e);return r[0]+=e*i,t.getTileCoordForCoordAndZ(r,n)}return e}function ku(t,e,i,n){n=void 0!==n?n:"top-left";const r=ju(t,e,i);return new Iu({extent:t,origin:ve(t,n),resolutions:r,tileSize:i})}function Gu(t){const e=t||{},i=e.extent||In("EPSG:3857").getExtent(),n={extent:i,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:ju(i,e.maxZoom,e.tileSize,e.maxResolution)};return new Iu(n)}function ju(t,e,i,n){e=void 0!==e?e:Hs,i=da(void 0!==i?i:qs);const r=Se(t),s=be(t);n=n>0?n:Math.max(s/i[0],r/i[1]);const o=e+1,a=new Array(o);for(let t=0;tthis.getTileInternal(t,e,i,n,s)),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return u.key=a,u}getTileInternal(t,e,i,n,r){const s=this.getKey();return this.createTile_(t,e,i,n,r,s)}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const i=In(t);if(i){const t=U(i);t in this.tileGridForProjection||(this.tileGridForProjection[t]=e)}}}function rd(t,e){t.getImage().src=e}function sd(t){const e=t[0],i=new Array(e);let n,r,s=1<>=1;return i.join("")}class od extends nd{constructor(t){const e=void 0!==(t=t||{}).projection?t.projection:"EPSG:3857",i=void 0!==t.tileGrid?t.tileGrid:Gu({extent:Bu(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_}}class ad{constructor(t){this.rbush_=new wo(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[U(e)]=i}load(t,e){const i=new Array(e.length);for(let n=0,r=e.length;n=e[0]||(t[1]<=e[1]&&t[3]>=e[1]||pe(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()))}function ud(t,e,i,n,s,o,a){let l,h;const c=(i-e)/n;if(1===c)l=e;else if(2===c)l=e,h=s;else if(0!==c){let o=t[e],a=t[e+1],c=0;const u=[0];for(let r=e+n;r1?a:2,o=o||new Array(a);for(let e=0;e>1;r{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=Tr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=Cr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,n);break;case"Polygon":n=[],i.length=Fr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,n)}return n&&(this.simplifiedGeometry_=new wd(this.type_,i,n,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_})),this}}function Ed(t){const e=t.getType();switch(e){case"Point":return new Gr(t.getFlatCoordinates());case"MultiPoint":return new _d(t.getFlatCoordinates(),"XY");case"LineString":return new pd(t.getFlatCoordinates(),"XY");case"MultiLineString":return new md(t.getFlatCoordinates(),"XY",t.getEnds());case"Polygon":const i=t.getFlatCoordinates(),n=t.getEnds(),r=ns(i,n);return r.length>1?new xd(i,"XY",r):new rs(i,"XY",n);default:throw new Error("Invalid geometry type:"+e)}}wd.prototype.getFlatCoordinates=wd.prototype.getOrientedFlatCoordinates;var Sd="addfeature",Td="changefeature",Cd="clear",Rd="removefeature",bd="featuresloadstart",Pd="featuresloadend",Fd="featuresloaderror";class Md extends t{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class Ld extends Fu{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_=f,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_&&(Lt(this.format_,"`format` must be set when `url` is set"),this.loader_=Jc(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:Qc;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let i,n;this.featuresRtree_=e?new ad:null,this.loadedExtentsRtree_=new ad,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 Z(n)),void 0!==n&&this.addFeaturesInternal(n),void 0!==i&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=U(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 Md(Sd,t))}setupChangeEvents_(t,e){e instanceof wd||(this.featureChangeKeys_[t]=[A(e,v,this.handleFeatureChange_,this),A(e,i,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 wd){const n=this.idIndex_[t];n instanceof wd?Array.isArray(n)?n.push(e):this.idIndex_[t]=[n,e]:i=!1}else i=!1;else this.idIndex_[t]=e}return i&&(Lt(!(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(V,(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(D)}this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach((t=>{this.removeFeatureInternal(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 Md(Cd);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 wd||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 wd||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(),y(this.nullGeometryFeatures_)||h(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=De(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||d,this.featuresRtree_.forEachInExtent(a,(function(t){if(e(t)){const e=t.getGeometry(),l=o;if(o=e instanceof wd?0:e.closestPointXY(i,n,s,o),o{--this.loadingExtentsCount_,this.dispatchEvent(new Md(Pd,void 0,t))}),(()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Md(Fd))})),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_,i=e.forEachInExtent(t,(function(e){if(ae(e.extent,t))return e}));i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,n=t.length;i 1.0 ||\n v_texcoord.y > 1.0\n ) {\n discard;\n }\n gl_FragColor = texture2D(u_texture, v_texcoord);\n }\n","\n attribute vec4 a_position;\n attribute vec4 a_texcoord;\n\n uniform mat4 u_matrix;\n uniform mat4 u_textureMatrix;\n\n varying vec2 v_texcoord;\n\n void main() {\n gl_Position = u_matrix * a_position;\n vec2 texcoord = (u_textureMatrix * a_texcoord).xy;\n v_texcoord = texcoord;\n }\n"),this.positionLocation=t.getAttribLocation(this.program_,"a_position"),this.texcoordLocation=t.getAttribLocation(this.program_,"a_texcoord"),this.matrixLocation=t.getUniformLocation(this.program_,"u_matrix"),this.textureMatrixLocation=t.getUniformLocation(this.program_,"u_textureMatrix"),this.textureLocation=t.getUniformLocation(this.program_,"u_texture"),this.positionBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),this.positions=[0,0,0,1,1,0,1,0,0,1,1,1],t.bufferData(t.ARRAY_BUFFER,new Float32Array(this.positions),t.STATIC_DRAW),this.texcoordBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.texcoordBuffer),this.texcoords=[0,0,0,1,1,0,1,0,0,1,1,1],t.bufferData(t.ARRAY_BUFFER,new Float32Array(this.texcoords),t.STATIC_DRAW)}drawImage(t,e,i,n,r,s,o,a,l,h,c,u,d){const g=this.gl_;void 0===a&&(a=n),void 0===l&&(l=r),void 0===s&&(s=e),void 0===o&&(o=i),void 0===h&&(h=s),void 0===c&&(c=o),void 0===u&&(u=g.canvas.width),void 0===d&&(d=g.canvas.height),g.bindTexture(g.TEXTURE_2D,t),g.useProgram(this.program_),g.bindBuffer(g.ARRAY_BUFFER,this.positionBuffer),g.enableVertexAttribArray(this.positionLocation),g.vertexAttribPointer(this.positionLocation,2,g.FLOAT,!1,0,0),g.bindBuffer(g.ARRAY_BUFFER,this.texcoordBuffer),g.enableVertexAttribArray(this.texcoordLocation),g.vertexAttribPointer(this.texcoordLocation,2,g.FLOAT,!1,0,0);let f=Od(0,u,0,d,-1,1);f=Nd(f,a,l,0),f=Dd(f,h,c,1),g.uniformMatrix4fv(this.matrixLocation,!1,f);let p=kd(n/e,r/i,0);p=Dd(p,s/e,o/i,1),g.uniformMatrix4fv(this.textureMatrixLocation,!1,p),g.uniform1i(this.textureLocation,0),g.drawArrays(g.TRIANGLES,0,this.positions.length/2)}}function jd(t,e,i){const n=t.createShader(e);if(null===n)throw new Error("Shader compilation failed");if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(n);if(null===e)throw new Error("Shader info log creation failed");throw new Error(e)}return n}function Ud(t,e,i){const n=t.createProgram(),r=jd(t,t.VERTEX_SHADER,i),s=jd(t,t.FRAGMENT_SHADER,e);if(null===n)throw new Error("Program creation failed");if(t.attachShader(n,r),t.attachShader(n,s),t.linkProgram(n),!t.getProgramParameter(n,t.LINK_STATUS)){if(null===t.getProgramInfoLog(n))throw new Error("Program info log creation failed");throw new Error}return n}function Bd(t,e,i,n){let r;return r=i&&i.length?i.shift():ut?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("webgl",n)}function zd(t){const e=t.canvas;e.width=1,e.height=1,t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT)}const Xd=[];function Vd(t,e,i,n,r,s,o,a,l,h,c,u,d,g){const f=Math.round(n*e),p=Math.round(n*i);let m,_;if(t.canvas.width=f,t.canvas.height=p,_=t.createTexture(),t.bindTexture(t.TEXTURE_2D,_),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),d?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)):(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,f,p,0,t.RGBA,c,null),m=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,m),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,_,0),null===m)throw new Error("Could not create framebuffer");if(null===_)throw new Error("Could not create texture");if(0===l.length)return{width:f,height:p,framebuffer:m,texture:_};const y=[1/0,1/0,-1/0,-1/0];let x,v,w;l.forEach((function(t,e,i){he(y,t.extent)}));const E=1/r;if(g&&1===l.length&&0===h)x=l[0].texture,v=l[0].width,w=l[0].width;else{if(x=t.createTexture(),null===_)throw new Error("Could not create texture");v=Math.round(be(y)*E),w=Math.round(Se(y)*E);const e=t.getParameter(t.MAX_TEXTURE_SIZE),i=Math.max(v,w),n=i>e?e/i:1,r=Math.round(v*n),s=Math.round(w*n);t.bindTexture(t.TEXTURE_2D,x),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),d?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)):(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST)),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,r,s,0,t.RGBA,c,null);const o=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,o),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,x,0);const a=new Gd(t);l.forEach((function(e,i,l){const c=(e.extent[0]-y[0])*E*n,u=-(e.extent[3]-y[3])*E*n,g=be(e.extent)*E*n,f=Se(e.extent)*E*n;if(t.bindFramebuffer(t.FRAMEBUFFER,o),t.viewport(0,0,r,s),e.clipExtent){const i=(e.clipExtent[0]-y[0])*E*n,r=-(e.clipExtent[3]-y[3])*E*n,s=be(e.clipExtent)*E*n,o=Se(e.clipExtent)*E*n;t.enable(t.SCISSOR_TEST),t.scissor(d?i:Math.round(i),d?r:Math.round(r),d?s:Math.round(i+s)-Math.round(i),d?o:Math.round(r+o)-Math.round(r))}a.drawImage(e.texture,e.width,e.height,h,h,e.width-2*h,e.height-2*h,d?c:Math.round(c),d?u:Math.round(u),d?g:Math.round(c+g)-Math.round(c),d?f:Math.round(u+f)-Math.round(u),r,s),t.disable(t.SCISSOR_TEST)})),t.deleteFramebuffer(o)}const S=Ce(o),T=Ce(y),C=t=>{const e=(t[0][0]-S[0])/s*n,i=-(t[0][1]-S[1])/s*n;return{u1:(t[1][0]-S[0])/s*n,v1:-(t[1][1]-S[1])/s*n,u0:e,v0:i,u2:(t[2][0]-S[0])/s*n,v2:-(t[2][1]-S[1])/s*n}};t.bindFramebuffer(t.FRAMEBUFFER,m),t.viewport(0,0,f,p);{const e=[],i=[],n=Ud(t,"\n precision mediump float;\n\n varying vec2 v_texcoord;\n\n uniform sampler2D u_texture;\n\n void main() {\n if (v_texcoord.x < 0.0 || v_texcoord.x > 1.0 || v_texcoord.y < 0.0 || v_texcoord.y > 1.0) {\n discard;\n }\n gl_FragColor = texture2D(u_texture, v_texcoord);\n }\n","\n attribute vec4 a_position;\n attribute vec2 a_texcoord;\n\n varying vec2 v_texcoord;\n\n uniform mat4 u_matrix;\n\n void main() {\n gl_Position = u_matrix * a_position;\n v_texcoord = a_texcoord;\n }\n");t.useProgram(n);const s=t.getUniformLocation(n,"u_texture");t.bindTexture(t.TEXTURE_2D,x),t.uniform1i(s,0),a.getTriangles().forEach((function(t,n,s){const o=t.source,a=t.target,{u1:l,v1:h,u0:c,v0:u,u2:d,v2:g}=C(a),f=(o[0][0]-T[0])/r/v,p=-(o[0][1]-T[1])/r/w,m=(o[1][0]-T[0])/r/v,_=-(o[1][1]-T[1])/r/w,y=(o[2][0]-T[0])/r/v,x=-(o[2][1]-T[1])/r/w;e.push(l,h,c,u,d,g),i.push(m,_,f,p,y,x)}));const o=Od(0,f,p,0,-1,1),l=t.getUniformLocation(n,"u_matrix");t.uniformMatrix4fv(l,!1,o);const h=t.getAttribLocation(n,"a_position"),c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),t.vertexAttribPointer(h,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(h);const u=t.getAttribLocation(n,"a_texcoord"),d=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,d),t.bufferData(t.ARRAY_BUFFER,new Float32Array(i),t.STATIC_DRAW),t.vertexAttribPointer(u,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(u),t.drawArrays(t.TRIANGLES,0,e.length/2)}if(u){const e=Ud(t,"\n precision mediump float;\n\n uniform vec4 u_val;\n void main() {\n gl_FragColor = u_val;\n }\n","\n attribute vec4 a_position;\n\n uniform mat4 u_matrix;\n\n void main() {\n gl_Position = u_matrix * a_position;\n }\n");t.useProgram(e);const i=Od(0,f,p,0,-1,1),n=t.getUniformLocation(e,"u_matrix");t.uniformMatrix4fv(n,!1,i);const r=Array.isArray(u)?u:[0,0,0,255],s=t.getUniformLocation(e,"u_val");t.uniform4fv(s,r);const o=t.getAttribLocation(e,"a_position"),l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(o);const h=a.getTriangles().reduce((function(t,e){const i=e.target,{u1:n,v1:r,u0:s,v0:o,u2:a,v2:l}=C(i);return t.concat([n,r,s,o,s,o,a,l,a,l,n,r])}),[]);t.bufferData(t.ARRAY_BUFFER,new Float32Array(h),t.STATIC_DRAW),t.drawArrays(t.LINES,0,h.length/2)}return{width:f,height:p,framebuffer:m,texture:_}}class Wd extends Mt{constructor(t){super({tileCoord:t.tileCoord,loader:()=>Promise.resolve(new Uint8ClampedArray(4)),interpolate:t.interpolate,transition:t.transition}),this.renderEdges_=void 0!==t.renderEdges&&t.renderEdges,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?Te(i,n):i:n;const r=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),s=this.targetTileGrid_.getExtent();let o=this.sourceTileGrid_.getExtent();const a=s?Te(r,s):r;if(0===me(a))return void(this.state=J);i&&(o=o?Te(o,i):i);const l=this.targetTileGrid_.getResolution(this.wrappedTileCoord_[0]),h=t.targetProj,c=vu(e,h,a,l);if(!isFinite(c)||c<=0)return void(this.state=J);const u=void 0!==t.errorThreshold?t.errorThreshold:Su;if(this.triangulation_=new Tu(e,h,a,o,c*u,l,t.transformMatrix),0===this.triangulation_.getTriangles().length)return void(this.state=J);this.sourceZ_=this.sourceTileGrid_.getZForResolution(c);let d=this.triangulation_.calculateSourceExtent();if(o&&(e.canWrapX()?(d[1]=ai(d[1],o[1],o[3]),d[3]=ai(d[3],o[1],o[3])):d=Te(d,o)),me(d)){let n=0,r=0;e.canWrapX()&&(n=be(i),r=Math.floor((d[0]-i[0])/n));De(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=J)}else this.state=J}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()!==q)return;const r=n.getSize(),s=this.gutter_;let o;const a=Ct(n.getData());a?o=a:(e=!0,o=Pt(Tt(n.getData())));const l=[r[0]+2*s,r[1]+2*s],h=o instanceof Float32Array,c=l[0]*l[1],u=h?Float32Array:Uint8ClampedArray,d=new u(o.buffer),g=u.BYTES_PER_ELEMENT,f=g*d.length/c,p=d.byteLength/l[1],m=Math.floor(p/g/l[0]),_=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);_[0]+=i.offset,_[2]+=i.offset;const y=this.clipExtent_?.slice();y&&(y[0]+=i.offset,y[2]+=i.offset),t.push({extent:_,clipExtent:y,data:d,dataType:u,bytesPerPixel:f,pixelSize:l,bandCount:m})})),this.sourceTiles_.length=0,0===t.length)return this.state=$,void this.changed();const i=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(i),r="number"==typeof n?n:n[0],s="number"==typeof n?n:n[1],o=r*this.pixelRatio_,a=s*this.pixelRatio_,l=this.targetTileGrid_.getResolution(i),h=this.sourceTileGrid_.getResolution(this.sourceZ_),c=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),u=t[0].bandCount,d=new t[0].dataType(u*o*a),g=Bd(o,a,Xd,{premultipliedAlpha:!1,antialias:!1});let f;const p=g.RGBA;let m;if(t[0].dataType==Float32Array){m=g.FLOAT,g.getExtension("WEBGL_color_buffer_float"),g.getExtension("OES_texture_float"),g.getExtension("EXT_float_blend");f=null!==g.getExtension("OES_texture_float_linear")&&this.interpolate}else m=g.UNSIGNED_BYTE,f=this.interpolate;for(let e=Math.ceil(u/4)-1;e>=0;--e){const i=[];for(let n=0,r=t.length;n{const i=e.getState();if(i!==K&&i!==H)return;t++;const n=A(e,v,(()=>{const i=e.getState();i!=q&&i!=$&&i!=J||(D(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()==K&&t.load()}))}unlistenSources_(){this.sourcesListenerKeys_.forEach(D),this.sourcesListenerKeys_=null}}class Yd extends zu{constructor(t){const e=void 0===t.projection?"EPSG:3857":t.projection;let i=t.tileGrid;void 0===i&&e&&(i=Gu({extent:Bu(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize})),super({cacheSize:.1,attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:e,tileGrid:i,state:t.state,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,zDirection:t.zDirection}),this.gutter_=void 0!==t.gutter?t.gutter:0,this.tileSize_=t.tileSize?da(t.tileSize):null,this.tileSizes_=null,this.tileLoadingKeys_={},this.loader_=t.loader,this.handleTileChange_=this.handleTileChange_.bind(this),this.bandCount=void 0===t.bandCount?4:t.bandCount,this.tileGridForProjection_={},this.crossOrigin_=t.crossOrigin||"anonymous",this.transformMatrix=null}setTileSizes(t){this.tileSizes_=t}getTileSize(t){if(this.tileSizes_)return this.tileSizes_[t];if(this.tileSize_)return this.tileSize_;const e=this.getTileGrid();return e?da(e.getTileSize(t)):[256,256]}getGutterForProjection(t){const e=this.getProjection();return e&&!Un(e,t)||this.transformMatrix?0:this.gutter_}setLoader(t){this.loader_=t}getReprojTile_(t,e,i,n,r){const s=this.tileGrid||this.getTileGridForProjection(r||n),o=Math.max.apply(null,s.getResolutions().map(((t,e)=>{const i=da(s.getTileSize(e)),n=this.getTileSize(e);return Math.max(n[0]/i[0],n[1]/i[1])}))),a=this.getTileGridForProjection(n),l=[t,e,i],h=this.getTileCoordForTileUrlFunction(l,n),c=Object.assign({sourceProj:r||n,sourceTileGrid:s,targetProj:n,targetTileGrid:a,tileCoord:l,wrappedTileCoord:h,pixelRatio:o,gutter:this.gutter_,getTileFunction:(t,e,i,n)=>this.getTile(t,e,i,n),transformMatrix:this.transformMatrix},this.tileOptions),u=new Wd(c);return u.key=this.getKey(),u}getTile(t,e,i,n,r){const s=this.getProjection();if(r&&(s&&!Un(s,r)||this.transformMatrix))return this.getReprojTile_(t,e,i,r,s);const o=this.getTileSize(t),a=this.loader_,l=new AbortController,h={signal:l.signal,crossOrigin:this.crossOrigin_},c=this.getTileCoordForTileUrlFunction([t,e,i]);if(!c)return null;const u=c[0],d=c[1],g=c[2],f=this.getTileGrid()?.getFullTileRange(u);f&&(h.maxY=f.getHeight()-1);const p=Object.assign({tileCoord:[t,e,i],loader:function(){return m((function(){return a(u,d,g,h)}))},size:o,controller:l},this.tileOptions),_=new Mt(p);return _.key=this.getKey(),_.addEventListener(v,this.handleTileChange_),_}handleTileChange_(t){const e=t.target,i=U(e),n=e.getState();let r;n==H?(this.tileLoadingKeys_[i]=!0,r=Ru):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==$?Pu:n==q?bu:void 0),r&&this.dispatchEvent(new Xu(r,e))}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||Un(e,t))&&!this.transformMatrix)return this.tileGrid;const i=U(t);return i in this.tileGridForProjection_||(this.tileGridForProjection_[i]=Du(t)),this.tileGridForProjection_[i]}setTileGridForProjection(t,e){const i=In(t);if(i){const t=U(i);t in this.tileGridForProjection_||(this.tileGridForProjection_[t]=e)}}}class Zd extends Es{constructor(t,e,i,n,r,s,o){let a=t.getExtent();a&&t.canWrapX()&&(a=a.slice(),a[0]=-1/0,a[2]=1/0);let l=e.getExtent();l&&e.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);const h=l?Te(i,l):i,c=xu(t,e,xe(h),n),u=new Tu(t,e,h,a,.5*c,n),d=u.calculateSourceExtent(),g=Fe(d)?null:s(d,c,r),f=g?ws.IDLE:ws.EMPTY,p=g?g.getPixelRatio():1;super(i,n,p,f),this.targetProj_=e,this.maxSourceExtent_=a,this.triangulation_=u,this.targetResolution_=n,this.targetExtent_=i,this.sourceImage_=g,this.sourcePixelRatio_=p,this.interpolate_=o,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==ws.LOADING&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const t=this.sourceImage_.getState();if(t==ws.LOADED){const t=be(this.targetExtent_)/this.targetResolution_,e=Se(this.targetExtent_)/this.targetResolution_;this.canvas_=wu(t,e,this.sourcePixelRatio_,Eu(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_,!0)}this.state=t,this.changed()}load(){if(this.state==ws.IDLE){this.state=ws.LOADING,this.changed();const t=this.sourceImage_.getState();t==ws.LOADED||t==ws.ERROR?this.reproject_():(this.sourceListenerKey_=A(this.sourceImage_,v,(t=>{const e=this.sourceImage_.getState();e!=ws.LOADED&&e!=ws.ERROR||(this.unlistenSource_(),this.reproject_())})),this.sourceImage_.load())}}unlistenSource_(){D(this.sourceListenerKey_),this.sourceListenerKey_=null}}const Kd=4,Hd="imageloadstart",qd="imageloadend",$d="imageloaderror";class Jd extends t{constructor(t,e){super(t),this.image=e}}class Qd extends Fu{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[a(e,t,0)]}return t}getImage(t,e,i,n){const r=this.getProjection();if(!r||!n||Un(r,n))return r&&(n=r),this.getImageInternal(t,e,i,n);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&Un(this.reprojectedImage_.getProjection(),n)&&this.reprojectedImage_.getResolution()==e&&ae(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new Zd(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=eg(t,e,i,1),s=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===n&&(this.wantedExtent_&&Qt(this.wantedExtent_,r)||Qt(this.image.getExtent(),r))&&(this.wantedResolution_&&Eu(this.wantedResolution_)===s||Eu(this.image.getResolution())===s)))return this.image;this.wantedProjection_=n,this.wantedExtent_=r,this.wantedResolution_=s,this.image=new Es(r,s,i,this.loader),this.image.addEventListener(v,this.handleImageChange.bind(this))}return this.image}handleImageChange(t){const e=t.target;let i;switch(e.getState()){case ws.LOADING:this.loading=!0,i=Hd;break;case ws.LOADED:this.loading=!1,i=qd;break;case ws.ERROR:this.loading=!1,i=$d;break;default:return}this.hasListener(i)&&this.dispatchEvent(new Jd(i,e))}}function tg(t,e){t.getImage().src=e}function eg(t,e,i,n){const r=e/i,s=xe(t),o=yi(be(t)/r,Kd),a=yi(Se(t)/r,Kd);return we(s,r,0,[o+2*yi((n-1)*o/2,Kd),a+2*yi((n-1)*a/2,Kd)])}function ig(t,e,i,n,r,s){const o=r.getCode().split(/:(?=\d+$)/).pop(),a=i/n,l=[mi(be(e)/a,Kd),mi(Se(e)/a,Kd)];s.SIZE=l[0]+","+l[1],s.BBOX=e.join(","),s.BBOXSR=o,s.IMAGESR=o,s.DPI=Math.round(s.DPI?s.DPI*n:90*n);return Vu(t.replace(/MapServer\/?$/,"MapServer/export").replace(/ImageServer\/?$/,"ImageServer/exportImage"),s)}function ng(t){const e=t.load?t.load:Rs,i=In(t.projection||"EPSG:3857"),n=t.ratio??1.5,r=t.crossOrigin??null;return function(s,o,a){a=t.hidpi?a:1;const l={F:"image",FORMAT:"PNG32",TRANSPARENT:!0};Object.assign(l,t.params),s=eg(s,o,a,n);const h=ig(t.url,s,o,a,i,l),c=new Image;return c.crossOrigin=r,e(c,h).then((t=>{const e=be(s)/t.width*a;return{image:t,extent:s,resolution:e,pixelRatio:a}}))}}function rg(t){const e=t.load||Rs,i=t.imageExtent,n=t.crossOrigin??null;return()=>{const r=new Image;return r.crossOrigin=n,e(r,t.url).then((t=>{const e=be(i)/t.width,n=Se(i)/t.height;return{image:t,extent:i,resolution:e!==n?[e,n]:n,pixelRatio:1}}))}}const sg=new Error("Image failed to load");function og(t,e,i,n,r){return new Promise(((s,o)=>{const a=new Image;a.crossOrigin=r.crossOrigin??null,a.addEventListener("load",(()=>s(a))),a.addEventListener("error",(()=>o(sg))),a.src=Hu(t,e,i,n,r.maxY)}))}function ag(t){return function(e,i,n,r){return og(qu(t,e,i,n),e,i,n,r)}}function lg(t){let e;if(Array.isArray(t))e=ag(t);else if("string"==typeof t){e=ag($u(t))}else{if("function"!=typeof t)throw new Error("The url option must be a single template, an array of templates, or a function for getting a URL");i=t,e=function(t,e,n,r){return og(i(t,e,n,r),t,e,n,r)}}var i;return e}let hg=0;function cg(t){return Array.isArray(t)?t.join("\n"):"string"==typeof t?t:(++hg,"url-function-key-"+hg)}class ug extends Yd{constructor(t){let e,i=(t=t||{}).loader;t.url&&(i=lg(t.url),e=cg(t.url));const n=i?t.state:"loading",r=void 0===t.wrapX||t.wrapX;super({loader:i,key:e,attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize,gutter:t.gutter,maxResolution:t.maxResolution,projection:t.projection,tileGrid:t.tileGrid,state:n,wrapX:r,transition:t.transition,interpolate:!1!==t.interpolate,crossOrigin:t.crossOrigin,zDirection:t.zDirection})}setUrl(t){const e=lg(t);this.setLoader(e),this.setKey(cg(t)),"ready"!==this.getState()&&this.setState("ready")}}const dg="1.3.0",gg=[101,101];function fg(t,e,i,n,r){r.WIDTH=i[0],r.HEIGHT=i[1];const s=n.getAxisOrientation(),o=wi(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(","),Vu(t,r)}function pg(t,e,i,n,r,s,o){s=Object.assign({REQUEST:"GetMap"},s);const a=e/i,l=[mi(be(t)/a,Kd),mi(Se(t)/a,Kd)];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 fg(r,t,l,n,s)}function mg(t,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:dg,FORMAT:"image/png",STYLES:"",TRANSPARENT:!0},t)}function _g(t){const e=void 0===t.hidpi||t.hidpi,i=In(t.projection||"EPSG:3857"),n=t.ratio||1.5,r=t.load||Rs,s=t.crossOrigin??null;return(o,a,l)=>{o=eg(o,a,l,n),1==l||e&&void 0!==t.serverType||(l=1);const h=pg(o,a,l,i,t.url,mg(t.params,"GetMap"),t.serverType),c=new Image;return c.crossOrigin=s,r(c,h).then((t=>({image:t,extent:o,pixelRatio:l})))}}function yg(t,e,i){if(void 0===t.url)return;const n=In(t.projection||"EPSG:3857"),r=we(e,i,0,gg),s={QUERY_LAYERS:t.params.LAYERS,INFO_FORMAT:"application/json"};Object.assign(s,mg(t.params,"GetFeatureInfo"),t.params);const o=_i((e[0]-r[0])/i,Kd),a=_i((r[3]-e[1])/i,Kd),l=wi(s.VERSION,"1.3")>=0;return s[l?"I":"X"]=o,s[l?"J":"Y"]=a,fg(t.url,r,gg,n,s)}function xg(t,e){if(void 0===t.url)return;const i={SERVICE:"WMS",VERSION:dg,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(void 0!==e){const n=In(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 Vu(t.url,i)}const vg={"image/png":!0,"image/jpeg":!0,"image/gif":!0,"image/webp":!0},wg={"application/vnd.mapbox-vector-tile":!0,"application/geo+json":!0};function Eg(t,e){if(!e.length)return t;const i=new URL(t,"file:/");if(i.pathname.split("/").includes("collections"))return Sn('The "collections" query parameter cannot be added to collection endpoints'),t;const n=e.map((t=>encodeURIComponent(t))).join(",");i.searchParams.append("collections",n);return`${t.split("?")[0]}?${decodeURIComponent(i.searchParams.toString())}`}function Sg(t,e,i){let n,r;for(let i=0;it.replace(/E|X|Lon/i,"e").replace(/N|Y|Lat/i,"n"))).join(""):r.getAxisOrientation()).startsWith("en"),a=e.tileMatrices,l={};for(let t=0;tt.maxTileCol||u.tileRowt.maxTileRow)return}Object.assign(u,y);const d=i.replace(/\{(\w+?)\}/g,(function(t,e){return u[e]}));return ru(x,d)}}}function Rg(t){return nu(t.url).then((function(e){return function(t,e){const i=e.tileMatrixSetLimits;let n;if("map"===e.dataType)n=Sg(e.links,t.mediaType,t.collections);else{if("vector"!==e.dataType)throw new Error('Expected tileset data type to be "map" or "vector"');n=Tg(e.links,t.mediaType,t.supportedMediaTypes,t.collections)}if(e.tileMatrixSet)return Cg(t,e.tileMatrixSet,n,i);const r=e.links.find((t=>"http://www.opengis.net/def/rel/ogc/1.0/tiling-scheme"===t.rel));if(!r)throw new Error("Expected http://www.opengis.net/def/rel/ogc/1.0/tiling-scheme link or tileMatrixSet");const s=r.href;return nu(ru(t.url,s)).then((function(e){return Cg(t,e,n,i)}))}(t,e)}))}const bg='© OpenStreetMap contributors.';class Pg extends mo{constructor(t){super(t=t||{})}}class Fg extends N{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=5}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return G()}getData(t){return null}prepareFrame(t){return G()}renderFrame(t,e){return G()}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;e.getState()!==ws.LOADED&&e.getState()!==ws.ERROR||this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=ws.LOADED&&e!=ws.ERROR&&t.addEventListener(v,this.boundHandleImageChange_),e==ws.IDLE&&(t.load(),e=t.getState()),e==ws.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}class Mg{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(_t(),{get:(t,e)=>{if("function"==typeof _t()[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;i=o.width)return null;const h=Se(s),c=Math.floor(o.height*((s[3]-n[1])/h));return c<0||c>=o.height?null:this.getImageData(o,l,c)}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,c=t.viewState,u=c.center,d=c.resolution,g=h*s/(d*a),f=h*o/(d*a);this.prepareContainer(t,e);const p=this.context.canvas.width,m=this.context.canvas.height,_=this.getRenderContext(t);let y=!1,x=!0;if(l.extent){const e=Jn(l.extent,c.projection);x=Pe(e,t.extent),y=x&&!Qt(e,t.extent),y&&this.clipUnrotated(_,t,e)}const v=i.getImage(),w=zt(this.tempTransform,p/2,m/2,g,f,0,a*(n[0]-u[0])/s,a*(u[1]-n[3])/o);this.renderedResolution=o*h/a;const E=v.width*w[0],S=v.height*w[3];if(this.getLayer().getSource().getInterpolate()||(_.imageSmoothingEnabled=!1),this.preRender(_,t),x&&E>=.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,E,S),1!==i&&_.restore()}return this.postRender(this.context,t),y&&_.restore(),_.imageSmoothingEnabled=!0,this.container}}class Dg extends Pg{constructor(t){super(t)}createRenderer(){return new Og(this)}getData(t){return super.getData(t)}}var Ng="preload",kg="useInterimTilesOnError";class Gg extends mo{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(Ng)}setPreload(t){this.set(Ng,t)}getUseInterimTilesOnError(){return this.get(kg)}setUseInterimTilesOnError(t){this.set(kg,t)}getData(t){return super.getData(t)}}function jg(t,e,i,n){return`${t},${Uc(e,i,n)}`}function Ug(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 Bg(t,e,i){const n=t[i];return!!n&&n.delete(e)}function zg(t,e){const i=t.layerStatesArray[t.layerIndex];i.extent&&(e=Te(e,Jn(i.extent,t.viewState.projection)));const n=i.layer.getRenderSource();if(!n.getWrapX()){const i=n.getTileGridForProjection(t.viewState.projection).getExtent();i&&(e=Te(e,i))}return e}class Xg extends Ag{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 Yc(0,0,0,0),this.tempTileCoord_=jc(0,0,0);const i=void 0!==e.cacheSize?e.cacheSize:512;this.tileCache_=new Gc(i),this.maxStaleKeys=.5*i}getTileCache(){return this.tileCache_}getOrCreateTile(t,e,i,n){const r=this.tileCache_,s=this.getLayer().getSource(),o=jg(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=jt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!Jt(r,n))return null;const s=e.viewState,o=i.getRenderSource(),a=o.getTileGridForProjection(s.projection),l=o.getTilePixelRatio(e.pixelRatio);for(let t=a.getZForResolution(s.resolution);t>=a.getMinZoom();--t){const i=a.getTileCoordForCoordAndZ(n,t),r=this.getTile(t,i[1],i[2],e);if(!r||r.getState()!==q)continue;const h=a.getOrigin(t),c=da(a.getTileSize(t)),u=a.getResolution(t);let d;if(r instanceof Ps||r instanceof Cu)d=r.getImage();else{if(!(r instanceof Mt))continue;if(d=Tt(r.getData()),!d)continue}const g=Math.floor(l*((n[0]-h[0])/u-i[1]*c[0])),f=Math.floor(l*((h[1]-n[1])/u-i[2]*c[1])),p=Math.round(l*o.getGutterForProjection(s.projection));return this.getImageData(d,g+p,f+p)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const i=e.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,r){const s=t.viewState,o=this.getLayer(),a=o.getRenderSource(),l=a.getTileGridForProjection(s.projection),h=U(a);h in t.wantedTiles||(t.wantedTiles[h]={});const c=t.wantedTiles[h],u=o.getMapInternal(),d=Math.max(i-r,l.getMinZoom(),l.getZForResolution(Math.min(o.getMaxResolution(),u?u.getView().getResolutionForZoom(Math.max(o.getMinZoom(),0)):l.getResolution(0)),a.zDirection));for(let r=i;r>=d;--r){const i=l.getTileRangeForExtentAndZ(e,r,this.tempTileRange_),s=l.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(!Ug(n,i,r))continue;const a=i.getKey();if(c[a]=!0,i.getState()===K&&!t.tileQueue.isKeyQueued(a)){const n=jc(r,e,o,this.tempTileCoord_);t.tileQueue.enqueue([i,h,l.getTileCoordCenter(n),s])}}}}findStaleTile_(t,e){const i=this.tileCache_,n=t[0],r=t[1],s=t[2],o=this.getStaleKeys();for(let t=0;t0&&setTimeout((()=>{this.enqueueTiles(t,b,f-1,C,R-1)}),0),!(f in C))return this.container;const P=U(this),F=t.time;for(const e of C[f]){const n=e.getState();if((e instanceof Cu||e instanceof Wd)&&n===J)continue;const r=e.tileCoord;if(n===q){if(1===e.getAlpha(P,F)){e.endTransition(P);continue}}n!==K&&(i=!1),n!==$&&(this.renderComplete=!1);if(this.findStaleTile_(r,C)){Bg(C,e,f),t.animate=!0;continue}if(this.findAltTiles_(g,r,f+1,C))continue;const s=g.getMinZoom();for(let t=f-1;t>=s;--t){if(this.findAltTiles_(g,r,t,C))break}}const M=p/a*h/y,L=this.getRenderContext(t);zt(this.tempTransform,x/2,v/2,M,M,0,-x/2,-v/2),n.extent&&this.clipUnrotated(L,t,w),u.getInterpolate()||(L.imageSmoothingEnabled=!1),this.preRender(L,t);const I=Object.keys(C).map(Number);let A;I.sort(s);const O=[],D=[];for(let e=I.length-1;e>=0;--e){const i=I[e],n=u.getTilePixelSize(i,h,o),r=g.getResolution(i)/p,s=n[0]*r*M,a=n[1]*r*M,l=g.getTileCoordForCoordAndZ(Ce(T),i),c=g.getTileCoordExtent(l),d=jt(this.tempTransform,[y*(c[0]-T[0])/p,y*(T[3]-c[3])/p]),f=y*u.getGutterForProjection(o);for(const e of C[i]){if(e.getState()!==q)continue;const n=e.tileCoord,r=l[1]-n[1],o=Math.round(d[0]-(r-1)*s),h=l[2]-n[2],c=Math.round(d[1]-(h-1)*a),g=Math.round(d[0]-r*s),p=Math.round(d[1]-h*a),m=o-g,_=c-p,y=1===I.length;let x=!1;A=[g,p,g+m,p,g+m,p+_,g,p+_];for(let t=0,e=O.length;t{const i=U(u),n=e.wantedTiles[i],r=n?Object.keys(n).length:0;this.updateCacheSize(r),this.tileCache_.expireCache()};t.postRenderFunctions.push(e)}return this.renderComplete||i||(t.animate=!0),this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,2*t)}drawTile(t,e,i,n,r,s,o,a){let l;if(t instanceof Mt){if(l=Tt(t.getData()),!l)throw new Error("Rendering array data is not yet supported")}else l=this.getTileImage(t);if(!l)return;const h=this.getRenderContext(e),c=U(this),u=e.layerStatesArray[e.layerIndex],d=u.opacity*(a?t.getAlpha(c,e.time):1),g=d!==h.globalAlpha;g&&(h.save(),h.globalAlpha=d),h.drawImage(l,o,o,l.width-2*o,l.height-2*o,i,n,r,s),g&&h.restore(),d!==u.opacity?e.animate=!0:a&&t.endTransition(c)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const n=U(e);n in t||(t[n]={}),t[n][i.getKey()]=!0}}class Vg extends Gg{constructor(t){super(t)}createRenderer(){return new Xg(this,{cacheSize:this.getCacheSize()})}}function Wg(t){return function(e){const i=e.buffers,n=e.meta,r=e.imageOps,s=e.width,o=e.height,a=i.length,l=i[0].byteLength;if(r){const e=new Array(a);for(let t=0;tthis.maxQueueLength_;)this.queue_.shift().callback(null,null)}dispatch_(){if(this.running_||0===this.queue_.length)return;const t=this.queue_.shift();this.job_=t;const e=t.inputs[0].width,i=t.inputs[0].height,n=t.inputs.map((function(t){return t.data.buffer})),r=this.workers_.length;if(this.running_=r,1===r)return void this.workers_[0].postMessage({buffers:n,meta:t.meta,imageOps:this.imageOps_,width:e,height:i},n);const s=t.inputs[0].data.length,o=4*Math.ceil(s/4/r);for(let s=0;s=93&&r--,r>=35&&r--,r-=32;let s=null;if(r in this.keys_){const t=this.keys_[r];s=this.data_&&t in this.data_?this.data_[t]:t}return s}forDataAtCoordinate(t,e,i){this.state==J&&!0===i?(this.state=K,O(this,v,(i=>{e(this.getData(t))})),this.loadInternal_()):!0===i?setTimeout((()=>{e(this.getData(t))}),0):e(this.getData(t))}getKey(){return this.src_}handleError_(){this.state=$,this.changed()}handleLoad_(t){this.grid_=t.grid,this.keys_=t.keys,this.data_=t.data,this.state=q,this.changed()}loadInternal_(){if(this.state==K)if(this.state=H,this.jsonp_)tu(this.src_,this.handleLoad_.bind(this),this.handleError_.bind(this));else{const t=new XMLHttpRequest;t.addEventListener("load",this.onXHRLoad_.bind(this)),t.addEventListener("error",this.onXHRError_.bind(this)),t.open("GET",this.src_),t.send()}}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.handleError_()}this.handleLoad_(t)}else this.handleError_()}onXHRError_(t){this.handleError_()}load(){this.preemptive_?this.loadInternal_():this.setState(J)}}const sf="http://www.w3.org/2001/XMLSchema-instance";function of(t,e){return Mf().createElementNS(t,e)}function af(t,e){return lf(t,e,[]).join("")}function lf(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)lf(n,e,i)}return i}function hf(t){return"documentElement"in t}function cf(t,e,i){return t.getAttributeNS(e,i)||""}function uf(t){return(new DOMParser).parseFromString(t,"application/xml")}function df(t,e){return function(i,n){const r=t.call(e??this,i,n);if(void 0!==r){h(n[n.length-1],r)}}}function gf(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 ff(t,e){return function(i,n){const r=t.call(e??this,i,n);void 0!==r&&(n[n.length-1]=r)}}function pf(t,e,i){return function(n,r){const s=t.call(i??this,n,r);if(void 0!==s){const t=r[r.length-1],i=void 0!==e?e:n.localName;let o;i in t?o=t[i]:(o=[],t[i]=o),o.push(s)}}}function mf(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 _f(t,e){return function(i,n,r){t.call(e??this,i,n,r);r[r.length-1].node.appendChild(i)}}function yf(t,e){let i,n;return function(e,r,s){if(void 0===i){i={};const r={};r[e.localName]=t,i[e.namespaceURI]=r,n=xf(e.localName)}Cf(i,n,r,s)}}function xf(t,e){return function(i,n,r){const s=n[n.length-1].node;let o=t;void 0===o&&(o=r);return of(void 0!==e?e:s.namespaceURI,o)}}const vf=xf();function wf(t,e){const i=e.length,n=new Array(i);for(let r=0;ra&&(this.instructions.push([Nf,a,h,t,i,Lr,r]),this.hitDetectionInstructions.push([Nf,a,h,t,n||i,Lr,r]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),h=this.coordinates.length,this.instructions.push([Nf,a,h,t,i,void 0,r]),this.hitDetectionInstructions.push([Nf,a,h,t,n||i,void 0,r])}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[If,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[If,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=[zf,e];return"string"!=typeof e&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[Xf,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&&!c(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=[jf,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=qt(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Ht(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class qf extends Hf{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&&!Jt(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([Gf,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([Gf,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+u)/u,d=fi(i,h,e),g=fi(n,c,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 tp(t,e,i,n,r){let s,o,a,l,h,c,u,d,g,f,p=i,m=i,_=0,y=0,x=i;for(o=i;ot&&(y>_&&(_=y,p=x,m=o),y=0,x=o-r)),a=l,u=g,d=f),h=i,c=n}return y+=l,y>_?[x,o]:[p,m]}const ep={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class ip extends Hf{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.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Ca]={fillStyle:Ca},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,c=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(),c=2;break;case"Polygon":h=t.getFlatInteriorPoint(),s.overflow||n.push(h[2]/this.resolution),c=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*c]&&o[2*(t+i)+1]===h[i*c+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 u=s.padding;if(u!=Aa&&(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),u=[t,e,i,n]}const d=this.pixelRatio;this.instructions.push([Gf,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,u==Aa?Aa:u.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,f=this.state.fillStyle;s.backgroundFill&&(this.state.fillStyle=Ca,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([Gf,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[g,g],NaN,this.declutterMode_,this.declutterImageWithText_,u,!!s.backgroundFill,!!s.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Ca:this.fillKey_,this.textOffsetX_,this.textOffsetY_,n]),s.backgroundFill&&(this.state.fillStyle=f,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(e)}else{if(!Pe(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;tt[2]}else P=w>R;const F=Math.PI,M=[],L=S+n===e;let I;if(_=0,y=T,g=t[e=S],f=t[e+1],L){x(),I=Math.atan2(f-m,g-p),P&&(I+=I>0?-F:F);const t=(R+w)/2,e=(b+E)/2;return M[0]=[t,e,(C-s)/2,I,r],M}for(let t=0,u=(r=r.replace(/\n/g," ")).length;t0?-F:F),void 0!==I){let t=d-I;if(t+=t>F?-2*F:t<-F?2*F:0,Math.abs(t)>o)return null}I=d;const w=t;let E=0;for(;t0&&t.push("\n",""),t.push(e,""),t}class pp{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 Mg: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],c=a.justify?ep[a.justify]:gp(Array.isArray(t)?t[0]:t,a.textAlign||La),u=n&&s.lineWidth?s.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(fp,[]),{width:g,height:f,widths:p,heights:m,lineWidths:_}=Xa(a,d),y=g+u,x=[],v=(y+2)*h[0],w=(f+u)*h[1],E={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",u),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-c;let T=c*y+S*u;const C=[],R=[];let b,P=0,F=0,M=0,L=0;for(let t=0,e=d.length;tt?t-l:r,x=s+h>e?e-h:s,v=g[3]+y*u[0]+g[1],w=g[0]+x*u[1]+g[2],E=m-g[3],S=_-g[0];let T;return(f||0!==c)&&(ap[0]=E,cp[0]=E,ap[1]=S,lp[1]=S,lp[0]=E+v,hp[0]=lp[0],hp[1]=S+w,cp[1]=hp[1]),0!==c?(T=zt([1,0,0,1,0,0],i,n,1,1,c,-i,-n),jt(T,ap),jt(T,lp),jt(T,hp),jt(T,cp),ne(Math.min(ap[0],lp[0],hp[0],cp[0]),Math.min(ap[1],lp[1],hp[1],cp[1]),Math.max(ap[0],lp[0],hp[0],cp[0]),Math.max(ap[1],lp[1],hp[1],cp[1]),op)):ne(Math.min(E,E+v),Math.min(S,S+w),Math.max(E,E+v),Math.max(S,S+w),op),d&&(m=Math.round(m),_=Math.round(_)),{drawImageX:m,drawImageY:_,drawImageW:y,drawImageH:x,originX:l,originY:h,declutterBox:{minX:op[0],minY:op[1],maxX:op[2],maxY:op[3],value:p},canvasTransform:T,scale:u}}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,ap,lp,hp,cp,s,o),Va(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=jt(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=gp(Array.isArray(t)?t[0]:t,r.textAlign||La),h=ep[r.textBaseline||Ia],c=o&&o.lineWidth?o.lineWidth:0;return{label:s,anchorX:l*(s.width/a-2*r.scale[0])+2*(.5-l)*c,anchorY:h*s.height/a+2*(.5-h)*c}}execute_(t,e,i,n,r,s,o,a){const l=this.zIndexContext_;let h;this.pixelCoordinates_&&c(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=nr(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Gt(this.renderedTransform_,i));let u=0;const d=n.length;let g,f,p,m,_,y,x,v,w,E,S,T,C,R=0,b=0,P=0,F=null,M=null;const L=this.coordinateCache_,I=this.viewRotation_,A=Math.round(1e12*Math.atan2(-i[1],i[0]))/1e12,O={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:I},D=this.instructions!=n||this.overlaps?0:200;let N,k,G,j;for(;uD&&(this.fill_(t),b=0),P>D&&(t.stroke(),P=0),b||P||(t.beginPath(),_=NaN,y=NaN),++u;break;case Of:R=i[1];const n=h[R],c=h[R+1],d=h[R+2]-n,U=h[R+3]-c,B=Math.sqrt(d*d+U*U);t.moveTo(n+B,c),t.arc(n,c,B,0,2*Math.PI,!0),++u;break;case Df:t.closePath(),++u;break;case Nf:R=i[1],g=i[2];const z=i[3],X=i[4],V=i[5];O.geometry=z,O.feature=N,u in L||(L[u]=[]);const W=L[u];V?V(h,R,g,2,W):(W[0]=h[R],W[1]=h[R+1],W.length=2),l&&(l.zIndex=i[6]),X(W,O),++u;break;case Gf:R=i[1],g=i[2],w=i[3],f=i[4],p=i[5];let Y=i[6];const Z=i[7],K=i[8],H=i[9],q=i[10];let $=i[11];const J=i[12];let Q=i[13];m=i[14]||"declutter";const tt=i[15];if(!w&&i.length>=20){E=i[19],S=i[20],T=i[21],C=i[22];const t=this.drawLabelWithPointPlacement_(E,S,T,C);w=t.label,i[3]=w;const e=i[23];f=(t.anchorX-e)*this.pixelRatio,i[4]=f;const n=i[24];p=(t.anchorY-n)*this.pixelRatio,i[5]=p,Y=w.height,i[6]=Y,Q=w.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=Aa,nt=!1,rt=!1),q&&A?$+=I:q||A||($-=I);let st=0;for(;R!_p.includes(t)));class xp{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 pp(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;e0){if(!o||"none"===i||"Image"!==g&&"Text"!==g||o.includes(t)){const i=(d[l]-3)/4,s=n-i%a,o=n-(i/a|0),h=r(t,e,s*s+o*o);if(h)return h}c.clearRect(0,0,a,a);break}}const p=Object.keys(this.executorsByZIndex_).map(Number);let m,_,y,x,v;for(p.sort(s),m=p.length-1;m>=0;--m){const t=p[m].toString();for(y=this.executorsByZIndex_[t],_=mp.length-1;_>=0;--_)if(g=mp[_],x=y[g],void 0!==x&&(v=x.executeHitDetection(c,l,i,f,u),v))return v}}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 nr(o,0,8,2,t,o),o}isEmpty(){return y(this.executorsByZIndex_)}execute(t,e,i,n,r,a,l){const h=Object.keys(this.executorsByZIndex_).map(Number);h.sort(l?o:s),a=a||mp;const c=mp.length;for(let s=0,o=h.length;sg.execute(t,e,i,n,r,l))):g.execute(u,e,i,n,r,l),f&&u.restore(),a){a.offset();const t=h[s]*c+o;this.deferredZIndexContexts_[t]||(this.deferredZIndexContexts_[t]=[]),this.deferredZIndexContexts_[t].push(a)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(s);for(let i=0,n=e.length;i{t.draw(this.renderedContext_),t.clear()})),t[e[i]].length=0}}const vp={};function wp(t){if(void 0!==vp[t])return vp[t];const e=2*t+1,i=t*t,n=new Array(i+1);for(let r=0;r<=t;++r)for(let s=0;s<=t;++s){const o=r*r+s*s;if(o>i)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;t{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]*Ep,h=t[1]*Ep;a.push(this.getRenderTransform(e,i,n,Ep,l,h,0).slice());const c=o.getSource(),u=r.getExtent();if(c.getWrapX()&&r.canWrapX()&&!Qt(u,s)){let t=s[0];const r=be(u);let o,c=0;for(;tu[2];)++c,o=r*c,a.push(this.getRenderTransform(e,i,n,Ep,l,h,o).slice()),t-=r}const d=Kn();this.hitDetectionImageData_=Sp(t,a,this.renderedFeatures_,o.getStyleFunction(),s,i,n,cu(i,this.renderedPixelRatio_),d?r:null)}e(Tp(t,this.renderedFeatures_,this.hitDetectionImageData_))}))}forEachFeatureAtCoordinate(t,e,i,n,r){if(!this.replayGroup_)return;const s=e.viewState.resolution,o=e.viewState.rotation,a=this.getLayer(),l={},h=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,s,o,i,(function(t,e,i){const s=U(t),o=l[s];if(o){if(!0!==o&&it.value)):null)}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[Ys],r=t.viewHints[Zs],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,d=t.pixelRatio,g=e.getRevision(),f=e.getRenderBuffer();let p=e.getRenderOrder();void 0===p&&(p=hu);const m=l.center.slice(),_=Ht(a,f*u),y=_.slice(),x=[_.slice()],v=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!Qt(v,t.extent)){const t=be(v),e=Math.max(be(_)/2,t);_[0]=v[0]-e,_[2]=v[2]+e,Oi(m,h);const i=Oe(x[0],h);i[0]v[0]&&i[2]>v[2]&&x.push([i[0]-t,i[1],i[2]-t,i[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==g&&this.renderedRenderOrder_==p&&this.renderedFrameDeclutter_===!!t.declutter&&Qt(this.wrappedRenderedExtent_,_))return c(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const w=new rp(uu(u,d),_,u,d),E=Kn();let S;if(E){for(let t=0,e=x.length;t{let n;const r=t.getStyleFunction()||e.getStyleFunction();if(r&&(n=r(t,u)),n){const e=this.renderFeature(t,T,n,w,S,this.getLayer().getDeclutter(),i);C=C&&!e}},b=$n(_,h),P=i.getFeaturesInExtent(b);p&&P.sort(p);for(let t=0,e=P.length;t{if(f.getState()!==ws.LOADED)return;this.image=g?null:f;const t=f.getPixelRatio(),n=Eu(f.getResolution())*e/t;this.renderedResolution=n,this.coordinateToVectorPixelTransform_=zt(this.coordinateToVectorPixelTransform_,a/2,l/2,1/n,-1/n,0,-i.center[0],-i.center[1])})),f.load()}return this.image&&(this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice()),!!this.image}preRender(){}postRender(){}renderDeclutter(){}forEachFeatureAtCoordinate(t,e,i,n,r){return this.vectorRenderer_?this.vectorRenderer_.forEachFeatureAtCoordinate(t,e,i,n,r):super.forEachFeatureAtCoordinate(t,e,i,n,r)}}let bp=null;function Pp(t){bp=t;const e=Object.keys(t.defs),i=e.length;let n,r;for(n=0;n0&&c.length>0;)f=c.pop(),r=l.pop(),o=h.pop(),_=f.toString(),_ in u||(n.push(o[0],o[1]),u[_]=!0),p=c.pop(),s=l.pop(),a=h.pop(),m=(f+p)/2,d=t(m),g=e(d),li(g[0],g[1],o[0],o[1],a[0],a[1]){this.uniforms_.push({value:t.uniforms[i],location:e.getUniformLocation(this.renderTargetProgram_,i)})}))}getRenderTargetTexture(){return this.renderTargetTexture_}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 r=this.getGL(),s=t.size;if(r.bindFramebuffer(r.FRAMEBUFFER,e?e.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!e){const e=U(r.canvas);if(!t.renderTargets[e]){const i=r.getContextAttributes();i&&i.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),t.renderTargets[e]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,s[0],s[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const o=t.layerStatesArray[t.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,o),this.applyUniforms(t),i&&i(r,t),r.drawArrays(r.TRIANGLES,0,6),n&&n(r,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 Yp="u_projectionMatrix",Zp="u_time",Kp="u_zoom",Hp="u_resolution",qp="u_rotation",$p="u_viewportSizePx",Jp="u_pixelRatio",Qp="u_hitDetection",tm={UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},em={};function im(t){return"shared/"+t}let nm=0;function rm(t){let e=em[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:!at},e);const i=jp.length;for(let n=0;nnew Wp({webGlContext:this.gl_,scaleRatio:t.scaleRatio,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms}))):[new Wp({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_===im(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=U(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=U(t);delete this.bufferCache_[e]}disposeInternal(){const t=this.gl_.canvas;t.removeEventListener(Xp,this.boundHandleWebGLContextLost_),t.removeEventListener(Vp,this.boundHandleWebGLContextRestored_),function(t){const e=em[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 em[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)}bindFrameBuffer(t,e){const i=this.getGL();i.bindFramebuffer(i.FRAMEBUFFER,t),e&&i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0)}bindInitialFrameBuffer(){const t=this.getGL(),e=this.postProcessPasses_[0].getFrameBuffer();t.bindFramebuffer(t.FRAMEBUFFER,e);const i=this.postProcessPasses_[0].getRenderTargetTexture();t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0)}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)}bindAttribute(t,e,i){const n=this.getGL();this.bindBuffer(t);const r=this.getAttributeLocation(e);n.enableVertexAttribArray(r),n.vertexAttribPointer(r,i,n.FLOAT,!1,0,0)}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,Ad(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,e&&(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=U(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=U(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 zt(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;i{this.clearCache(),this.removeHelper()},t.addChangeListener(js,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Xs)){const n=new ch(Xs,void 0,e,t);i.dispatchEvent(n)}}dispatchPostComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Vs)){const n=new ch(Vs,void 0,e,t);i.dispatchEvent(n)}}reset(t){this.uniforms_=t.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(t){if(this.getLayer().getRenderSource()){let e,i=!0,n=-1;for(let r=0,s=t.layerStatesArray.length;rthis.size_[0]||e>=this.size_[1])return lm[0]=0,lm[1]=0,lm[2]=0,lm[3]=0,lm;this.readAll();const i=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return lm[0]=this.data_[4*i],lm[1]=this.data_[4*i+1],lm[2]=this.data_[4*i+2],lm[3]=this.data_[4*i+3],lm}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 cm="GENERATE_POINT_BUFFERS";function um(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}class dm extends am{constructor(t,e){const i=e.uniforms||{},n=[1,0,0,1,0,0];i[Yp]=n,super(t,{uniforms:i,postProcesses:e.postProcesses}),this.sourceRevision_=-1,this.verticesBuffer_=new Bp(Np,Gp),this.indicesBuffer_=new Bp(kp,Gp),this.vertexShader_=e.vertexShader,this.fragmentShader_=e.fragmentShader,this.program_,this.hitDetectionEnabled_=e.hitDetectionEnabled??!0;const r=e.attributes?e.attributes.map((function(t){return{name:"a_"+t.name,size:1,type:tm.FLOAT}})):[];this.attributes=[{name:"a_position",size:2,type:tm.FLOAT},{name:"a_index",size:1,type:tm.FLOAT}],this.hitDetectionEnabled_&&(this.attributes.push({name:"a_hitColor",size:4,type:tm.FLOAT}),this.attributes.push({name:"a_featureUid",size:1,type:tm.FLOAT})),this.attributes.push(...r),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 M=-1,w=-1,m=c;const A=null!==o;if(null!==x){M=d(b,Z,r(s,[...[t[x],t[x+1]]])),Math.cos(M)<=.985&&(m+=Math.tan((M-Math.PI)/2))}if(A){w=d(Z,b,r(s,[...[t[o],t[o+1]]])),Math.cos(w)<=.985&&(m+=Math.tan((Math.PI-w)/2))}function E(t,e){return 0===e?1e4*t:Math.sign(e)*(1e4*t+Math.abs(e))}return u.push(h[0],h[1],v,p[0],p[1],g,M,w,l,E(0,c)),u.push(...f),u.push(h[0],h[1],v,p[0],p[1],g,M,w,l,E(1,c)),u.push(...f),u.push(h[0],h[1],v,p[0],p[1],g,M,w,l,E(2,c)),u.push(...f),u.push(h[0],h[1],v,p[0],p[1],g,M,w,l,E(3,c)),u.push(...f),i.push(y,y+1,y+2,y+1,y+3,y+2),{length:l+Math.sqrt((Z[0]-b[0])*(Z[0]-b[0])+(Z[1]-b[1])*(Z[1]-b[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===cm){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,Xt(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 s=this.getLayer().getSource();this.sourceListenKeys_=[A(s,Sd,this.handleSourceFeatureAdded_,this),A(s,Td,this.handleSourceFeatureChanged_,this),A(s,Rd,this.handleSourceFeatureDelete_,this),A(s,Cd,this.handleSourceFeatureClear_,this)],s.forEachFeature((t=>{this.featureCache_[U(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 hm(this.helper)),this.verticesBuffer_.getArray()&&this.helper.flushBufferData(this.verticesBuffer_),this.indicesBuffer_.getArray()&&this.helper.flushBufferData(this.indicesBuffer_)}handleSourceFeatureAdded_(t){const e=t.feature;this.featureCache_[U(e)]={feature:e,properties:e.getProperties(),geometry:e.getGeometry()},this.featureCount_++}handleSourceFeatureChanged_(t){const e=t.feature;this.featureCache_[U(e)]={feature:e,properties:e.getProperties(),geometry:e.getGeometry()}}handleSourceFeatureDelete_(t){const e=t.feature;delete this.featureCache_[U(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?be(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[Ys]&&!t.viewHints[Zs],s=!ae(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(pm).join(", ")})`}function _m(t){const e=ea(t),i=e.length>3?e[3]:1;return mm([e[0]/255,e[1]/255,e[2]/255,i])}function ym(t){return mm(da(t))}const xm={};let vm=0;function wm(t){return t in xm||(xm[t]=vm++),xm[t]}function Em(t){return pm(wm(t))}function Sm(t){return"u_var_"+t}const Tm="getBandValue",Cm="u_paletteTextures",Rm="featureId",bm="geometryType";function Pm(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},[wl.Id]:t=>{t.featureId=!0;return(t.inFragmentShader?"v_":"a_")+Rm},[wl.GeometryType]:t=>{t.geometryType=!0;return(t.inFragmentShader?"v_":"a_")+bm},[wl.LineMetric]:()=>"currentLineMetric",[wl.Var]:(t,e)=>{const i=e.args[0].value;return i in t.variables||(t.variables[i]={name:i,type:e.type}),Sm(i)},[wl.Resolution]:()=>"u_resolution",[wl.Zoom]:()=>"u_zoom",[wl.Time]:()=>"u_time",[wl.Any]:Pm((t=>`(${t.join(" || ")})`)),[wl.All]:Pm((t=>`(${t.join(" && ")})`)),[wl.Not]:Pm((([t])=>`(!${t})`)),[wl.Equal]:Pm((([t,e])=>`(${t} == ${e})`)),[wl.NotEqual]:Pm((([t,e])=>`(${t} != ${e})`)),[wl.GreaterThan]:Pm((([t,e])=>`(${t} > ${e})`)),[wl.GreaterThanOrEqualTo]:Pm((([t,e])=>`(${t} >= ${e})`)),[wl.LessThan]:Pm((([t,e])=>`(${t} < ${e})`)),[wl.LessThanOrEqualTo]:Pm((([t,e])=>`(${t} <= ${e})`)),[wl.Multiply]:Pm((t=>`(${t.join(" * ")})`)),[wl.Divide]:Pm((([t,e])=>`(${t} / ${e})`)),[wl.Add]:Pm((t=>`(${t.join(" + ")})`)),[wl.Subtract]:Pm((([t,e])=>`(${t} - ${e})`)),[wl.Clamp]:Pm((([t,e,i])=>`clamp(${t}, ${e}, ${i})`)),[wl.Mod]:Pm((([t,e])=>`mod(${t}, ${e})`)),[wl.Pow]:Pm((([t,e])=>`pow(${t}, ${e})`)),[wl.Abs]:Pm((([t])=>`abs(${t})`)),[wl.Floor]:Pm((([t])=>`floor(${t})`)),[wl.Ceil]:Pm((([t])=>`ceil(${t})`)),[wl.Round]:Pm((([t])=>`floor(${t} + 0.5)`)),[wl.Sin]:Pm((([t])=>`sin(${t})`)),[wl.Cos]:Pm((([t])=>`cos(${t})`)),[wl.Atan]:Pm((([t,e])=>void 0!==e?`atan(${t}, ${e})`:`atan(${t})`)),[wl.Sqrt]:Pm((([t])=>`sqrt(${t})`)),[wl.Match]:Pm((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})),[wl.Between]:Pm((([t,e,i])=>`(${t} >= ${e} && ${t} <= ${i})`)),[wl.Interpolate]:Pm((([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})),[wl.In]:Pm((([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(", ")})`)),[wl.Color]:Pm((t=>{if(1===t.length)return`vec4(vec3(${t[0]} / 255.0), 1.0)`;if(2===t.length)return`vec4(vec3(${t[0]} / 255.0), ${t[1]})`;const e=t.slice(0,3).map((t=>`${t} / 255.0`));if(3===t.length)return`vec4(${e.join(", ")}, 1.0)`;const i=t[3];return`vec4(${e.join(", ")}, ${i})`})),[wl.Band]:Pm((([t,e,i],n)=>{if(!(Tm 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 pm(t.value);if((t.type&sl)>0)return t.value.toString();if((t.type&al)>0)return Em(t.value.toString());if((t.type&ll)>0)return _m(t.value);if((t.type&hl)>0)return mm(t.value);if((t.type&cl)>0)return ym(t.value);throw new Error(`Unexpected expression ${t.value} (expected type ${fl(e)})`)}const Lm="#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;\nfloat currentLineMetric = 0.; // an actual value will be used in the stroke shaders\n",Im={"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 Am{constructor(){this.uniforms_=[],this.attributes_=[],this.varyings_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${pm(Im["circle-radius"])} + ${pm(.5*Im["circle-stroke-width"])})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=_m(Im["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_=pm(Im["stroke-width"]),this.strokeColorExpression_=_m(Im["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=Em("round"),this.strokeJoinExpression_=Em("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.hasFill_=!1,this.fillColorExpression_=_m(Im["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_?`${Lm}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nattribute vec2 a_position;\nattribute float a_index;\nattribute vec4 a_hitColor;\n${this.attributes_.map((function(t){return"attribute "+t+";"})).join("\n")}\nvarying vec2 v_texCoord;\nvarying vec2 v_quadCoord;\nvarying vec4 v_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_hitColor = a_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_?`${Lm}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nvarying vec2 v_texCoord;\nvarying vec4 v_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 gl_FragColor.rgb *= gl_FragColor.a;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.05) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}getStrokeVertexShader(){return this.hasStroke_?`${Lm}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nattribute vec2 a_segmentStart;\nattribute vec2 a_segmentEnd;\nattribute float a_measureStart;\nattribute float a_measureEnd;\nattribute float a_parameters;\nattribute float a_distance;\nattribute vec2 a_joinAngles;\nattribute vec4 a_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_hitColor;\nvarying float v_distanceOffsetPx;\nvarying float v_measureStart;\nvarying float v_measureEnd;\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 currentLineMetric = vertexNumber < 1.5 ? a_measureStart : a_measureEnd;\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_hitColor = a_hitColor;\n v_distanceOffsetPx = a_distance / u_resolution - (lineOffsetPx * angleTangentSum);\n v_measureStart = a_measureStart;\n v_measureEnd = a_measureEnd;\n${this.varyings_.map((function(t){return" "+t.name+" = "+t.expression+";"})).join("\n")}\n}`:null}getStrokeFragmentShader(){return this.hasStroke_?`${Lm}\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_hitColor;\nvarying float v_distanceOffsetPx;\nvarying float v_measureStart;\nvarying float v_measureEnd;\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 == ${Em("butt")}) {\n return buttCapDistanceField(point, start, end);\n } else if (capType == ${Em("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 == ${Em("bevel")}) {\n return bevelJoinField(point, start, end, width, joinAngle);\n } else if (joinType == ${Em("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\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 lengthToPoint = max(0., min(dot(segmentTangent, startToPoint), segmentLength));\n float currentLengthPx = lengthToPoint + v_distanceOffsetPx; \n float currentRadiusPx = abs(dot(segmentNormal, startToPoint));\n float currentRadiusRatio = dot(segmentNormal, startToPoint) * 2. / v_width;\n currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPoint / segmentLength);\n\n if (${this.discardExpression_}) { discard; }\n\n vec4 color = ${this.strokeColorExpression_};\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 color.a *= smoothstep(0.5, -0.5, distance);\n gl_FragColor = color;\n gl_FragColor.a *= u_globalAlpha;\n gl_FragColor.rgb *= gl_FragColor.a;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.1) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}getFillVertexShader(){return this.hasFill_?`${Lm}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nattribute vec2 a_position;\nattribute vec4 a_hitColor;\n${this.attributes_.map((function(t){return"attribute "+t+";"})).join("\n")}\nvarying vec4 v_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_hitColor = a_hitColor;\n${this.varyings_.map((function(t){return" "+t.name+" = "+t.expression+";"})).join("\n")}\n}`:null}getFillFragmentShader(){return this.hasFill_?`${Lm}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nvarying vec4 v_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_};\n gl_FragColor.a *= u_globalAlpha;\n gl_FragColor.rgb *= gl_FragColor.a;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.1) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}}const Om="blur",Dm="gradient",Nm="radius",km=["#00f","#0ff","#0f0","#ff0","#f00"];const Gm="addfeatures";class jm extends t{constructor(t,e,i,n){super(t),this.features=i,this.file=e,this.projection=n}}const Um="drawstart",Bm="drawend",zm="drawabort";class Xm extends t{constructor(t,e){super(t),this.feature=e}}function Vm(t,e){return hi(t[0],t[1],e[0],e[1])}function Wm(t,e){const i=t.length;return e<0?t[e+i]:e>=i?t[e-i]:t[e]}function Ym(t,e,i){let n,r;eo){return Vm(Jm(t,n),Jm(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 Qm(){const t=Qa();return function(e,i){return t[e.getGeometry().getType()]}}const t_="extentchanged";class e_ extends t{constructor(t){super(t_),this.extent=t}}function i_(){const t=Qa();return function(e,i){return t.Polygon}}function n_(){const t=Qa();return function(e,i){return t.Point}}function r_(t){return function(e){return Kt([t,e])}}function s_(t,e){return t[0]==e[0]?function(i){return Kt([t,[i[0],e[1]]])}:t[1]==e[1]?function(i){return Kt([t,[e[0],i[1]]])}:null}function o_(t){return parseFloat(t)}function a_(t){return function(t){return pi(t,5)}(t).toString()}function l_(t,e){return!isNaN(t)&&t!==o_(a_(e))}const h_=[0,0,0,0],c_=[],u_="modifystart",d_="modifyend";class g_ extends t{constructor(t,e,i){super(t),this.features=e,this.mapBrowserEvent=i}}function f_(t,e){return t.index-e.index}function p_(t,e,i){const n=e.geometry;if("Circle"===n.getType()){let r=n;if(1===e.index){const e=Kn();e&&(r=r.clone().transform(e,i));const n=Mi(r.getCenter(),qn(t,i)),s=Math.sqrt(n)-r.getRadius();return s*s}}const r=qn(t,i);return c_[0]=qn(e.segment[0],i),c_[1]=qn(e.segment[1],i),Ii(r,c_)}function m_(t,e,i){const n=e.geometry;if("Circle"===n.getType()&&1===e.index){let e=n;const r=Kn();return r&&(e=e.clone().transform(r,i)),Hn(e.getClosestPoint(qn(t,i)),i)}const r=qn(t,i);return c_[0]=qn(e.segment[0],i),c_[1]=qn(e.segment[1],i),Hn(Ti(r,c_),i)}function __(){const t=Qa();return function(e,i){return t.Point}}const y_="select";class x_ extends t{constructor(t,e,i,n){super(t),this.selected=e,this.deselected=i,this.mapBrowserEvent=n}}const v_={};class w_ extends zh{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:ic,this.addCondition_=t.addCondition?t.addCondition:ec,this.removeCondition_=t.removeCondition?t.removeCondition:ec,this.toggleCondition_=t.toggleCondition?t.toggleCondition:sc,this.multi_=!!t.multi&&t.multi,this.filter_=t.filter?t.filter:d,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.style_=void 0!==t.style?t.style:function(){const t=Qa();return h(t.Polygon,t.LineString),h(t.GeometryCollection,t.LineString),function(e){return e.getGeometry()?t[e.getGeometry().getType()]:null}}(),this.features_=t.features||new Z,t.layers)if("function"==typeof t.layers)e=t.layers;else{const i=t.layers;e=function(t){return i.includes(t)}}else e=d;this.layerFilter_=e,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(t,e){this.featureLayerAssociation_[U(t)]=e}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(t){return this.featureLayerAssociation_[U(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(X,this.boundAddFeature_),this.features_.addEventListener(V,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(X,this.boundAddFeature_),this.features_.removeEventListener(V,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 Mp&&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=U(t);e in v_||(v_[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 w_&&n.getStyle()&&-1!==n.getFeatures().getArray().lastIndexOf(t))return void t.setStyle(n.getStyle())}const i=U(t);t.setStyle(v_[i]),delete v_[i]}removeFeatureLayerAssociation_(t){delete this.featureLayerAssociation_[U(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){_(this.featureLayerAssociation_),s.forEachFeatureAtPixel(t.pixel,((t,e)=>{if(t instanceof It&&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 It&&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 x_(y_,l,a,t)),!0}}const E_="snap";class S_ extends t{constructor(t,e){super(t),this.vertex=e.vertex,this.vertexPixel=e.vertexPixel,this.feature=e.feature,this.segment=e.segment}}function T_(t){return t.feature?t.feature:t.element?t.element:null}const C_=[];const R_="translatestart",b_="translating",P_="translateend";class F_ extends t{constructor(t,e,i,n,r){super(t),this.features=e,this.coordinate=i,this.startCoordinate=n,this.mapBrowserEvent=r}}function M_(t,e,i,n,r,s){void 0!==r?s=void 0!==s?s:0:(r=[],s=0);let o=e;for(;oD_({...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 I_(new wd(n,"Polygon"===n?function(t,e,i){return Array.isArray(e[0])?(ts(t,0,e,i)||is(t=t.slice(),0,e,i),t):(Qr(t,0,e,i)||es(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 N_(t,e){if(!t)return null;if(Array.isArray(t)){const i=t.map((t=>N_(t,e)));return new hd(i)}return I_(new(0,O_[t.type])(t.flatCoordinates,t.layout,t.ends),!1,e)}class k_ extends L_{constructor(){super(),this.xmlSerializer_=Ff()}getType(){return"xml"}readFeature(t,e){if(!t)return null;if("string"==typeof t){const i=uf(t);return this.readFeatureFromDocument(i,e)}return hf(t)?this.readFeatureFromDocument(t,e):this.readFeatureFromNode(t,e)}readFeatureFromDocument(t,e){const i=this.readFeaturesFromDocument(t,e);return i.length>0?i[0]:null}readFeatureFromNode(t,e){return null}readFeatures(t,e){if(!t)return[];if("string"==typeof t){const i=uf(t);return this.readFeaturesFromDocument(i,e)}return hf(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&&h(i,this.readFeaturesFromNode(n,e));return i}readFeaturesFromNode(t,e){return G()}readGeometry(t,e){if(!t)return null;if("string"==typeof t){const i=uf(t);return this.readGeometryFromDocument(i,e)}return hf(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=uf(t);return this.readProjectionFromDocument(e)}return hf(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 G_(t){return j_(af(t,!1))}function j_(t){const e=/^\s*(true|1)|(false|0)\s*$/.exec(t);if(e)return void 0!==e[1]||!1}function U_(t){const e=af(t,!1),i=Date.parse(e);return isNaN(i)?void 0:i/1e3}function B_(t){return z_(af(t,!1))}function z_(t){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(t);if(e)return parseFloat(e[1])}function X_(t){return V_(af(t,!1))}function V_(t){const e=/^\s*(\d+)\s*$/.exec(t);if(e)return parseInt(e[1],10)}function W_(t){return af(t,!1).trim()}function Y_(t,e){$_(t,e?"1":"0")}function Z_(t,e){t.appendChild(Mf().createCDATASection(e))}function K_(t,e){const i=new Date(1e3*e),n=i.getUTCFullYear()+"-"+vi(i.getUTCMonth()+1,2)+"-"+vi(i.getUTCDate(),2)+"T"+vi(i.getUTCHours(),2)+":"+vi(i.getUTCMinutes(),2)+":"+vi(i.getUTCSeconds(),2)+"Z";t.appendChild(Mf().createTextNode(n))}function H_(t,e){const i=e.toPrecision();t.appendChild(Mf().createTextNode(i))}function q_(t,e){const i=e.toString();t.appendChild(Mf().createTextNode(i))}function $_(t,e){t.appendChild(Mf().createTextNode(e))}const J_=[null,"http://www.topografix.com/GPX/1/0","http://www.topografix.com/GPX/1/1"],Q_={rte:Fy,trk:My,wpt:Ly},ty=Ef(J_,{rte:gf(Fy),trk:gf(My),wpt:gf(Ly)}),ey=Ef(J_,{text:mf(W_,"linkText"),type:mf(W_,"linkType")}),iy=Ef(J_,{name:mf(W_),email:function(t,e){const i=e[e.length-1],n=t.getAttribute("id"),r=t.getAttribute("domain");null!==n&&null!==r&&(i.email=`${n}@${r}`)},link:by}),ny=Ef(J_,{name:mf(W_),desc:mf(W_),author:mf((function(t,e){const i=Tf({},iy,t,e);if(i)return i;return})),copyright:mf((function(t,e){const i=Tf({},ry,t,e);if(i){const e=t.getAttribute("author");return null!==e&&(i.author=e),i}return})),link:by,time:mf(U_),keywords:mf(W_),bounds:function(t,e){const i=e[e.length-1],n=t.getAttribute("minlat"),r=t.getAttribute("minlon"),s=t.getAttribute("maxlat"),o=t.getAttribute("maxlon");null!==r&&null!==n&&null!==o&&null!==s&&(i.bounds=[[parseFloat(r),parseFloat(n)],[parseFloat(o),parseFloat(s)]])},extensions:Py}),ry=Ef(J_,{year:mf(X_),license:mf(W_)}),sy=Ef(J_,{rte:_f((function(t,e,i){const n=i[0],r=e.getProperties(),s={node:t};s.properties=r;const o=e.getGeometry();if("LineString"==o.getType()){const t=I_(o,!0,n);s.geometryLayout=t.getLayout(),r.rtept=t.getCoordinates()}const a=i[i.length-1].node,l=fy[a.namespaceURI],h=wf(r,l);Rf(s,py,vf,h,i,l)})),trk:_f((function(t,e,i){const n=i[0],r=e.getProperties(),s={node:t};s.properties=r;const o=e.getGeometry();if("MultiLineString"==o.getType()){const t=I_(o,!0,n);r.trkseg=t.getLineStrings()}const a=i[i.length-1].node,l=_y[a.namespaceURI],h=wf(r,l);Rf(s,yy,vf,h,i,l)})),wpt:_f((function(t,e,i){const n=i[0],r=i[i.length-1];r.properties=e.getProperties();const s=e.getGeometry();if("Point"==s.getType()){const e=I_(s,!0,n);r.geometryLayout=e.getLayout(),Ay(t,e.getCoordinates(),i)}}))});const oy=Ef(J_,{name:mf(W_),cmt:mf(W_),desc:mf(W_),src:mf(W_),link:by,number:mf(X_),extensions:Py,type:mf(W_),rtept:function(t,e){const i=Tf({},ay,t,e);if(i){const n=e[e.length-1];Cy(n.flatCoordinates,n.layoutOptions,t,i)}}}),ay=Ef(J_,{ele:mf(B_),time:mf(U_)}),ly=Ef(J_,{name:mf(W_),cmt:mf(W_),desc:mf(W_),src:mf(W_),link:by,number:mf(X_),type:mf(W_),extensions:Py,trkseg:function(t,e){const i=e[e.length-1];Sf(hy,t,e);const n=i.flatCoordinates;i.ends.push(n.length)}}),hy=Ef(J_,{trkpt:function(t,e){const i=Tf({},cy,t,e);if(i){const n=e[e.length-1];Cy(n.flatCoordinates,n.layoutOptions,t,i)}}}),cy=Ef(J_,{ele:mf(B_),time:mf(U_)}),uy=Ef(J_,{ele:mf(B_),time:mf(U_),magvar:mf(B_),geoidheight:mf(B_),name:mf(W_),cmt:mf(W_),desc:mf(W_),src:mf(W_),link:by,sym:mf(W_),type:mf(W_),fix:mf(W_),sat:mf(X_),hdop:mf(B_),vdop:mf(B_),pdop:mf(B_),ageofdgpsdata:mf(B_),dgpsid:mf(X_),extensions:Py}),dy=["text","type"],gy=Ef(J_,{text:_f($_),type:_f($_)}),fy=Ef(J_,["name","cmt","desc","src","link","number","type","rtept"]),py=Ef(J_,{name:_f($_),cmt:_f($_),desc:_f($_),src:_f($_),link:_f(Iy),number:_f(q_),type:_f($_),rtept:yf(_f(Ay))}),my=Ef(J_,["ele","time"]),_y=Ef(J_,["name","cmt","desc","src","link","number","type","trkseg"]),yy=Ef(J_,{name:_f($_),cmt:_f($_),desc:_f($_),src:_f($_),link:_f(Iy),number:_f(q_),type:_f($_),trkseg:yf(_f((function(t,e,i){const n={node:t};n.geometryLayout=e.getLayout(),n.properties={},Rf(n,vy,xy,e.getCoordinates(),i)})))}),xy=xf("trkpt"),vy=Ef(J_,{trkpt:_f(Ay)}),wy=Ef(J_,["ele","time","magvar","geoidheight","name","cmt","desc","src","link","sym","type","fix","sat","hdop","vdop","pdop","ageofdgpsdata","dgpsid"]),Ey=Ef(J_,{ele:_f(H_),time:_f(K_),magvar:_f(H_),geoidheight:_f(H_),name:_f($_),cmt:_f($_),desc:_f($_),src:_f($_),link:_f(Iy),sym:_f($_),type:_f($_),fix:_f($_),sat:_f(q_),hdop:_f(H_),vdop:_f(H_),pdop:_f(H_),ageofdgpsdata:_f(H_),dgpsid:_f(q_)}),Sy={Point:"wpt",LineString:"rte",MultiLineString:"trk"};function Ty(t,e,i){const n=t.getGeometry();if(n){const t=Sy[n.getType()];if(t){return of(e[e.length-1].node.namespaceURI,t)}}}function Cy(t,e,i,n){return t.push(parseFloat(i.getAttribute("lon")),parseFloat(i.getAttribute("lat"))),"ele"in n?(t.push(n.ele),delete n.ele,e.hasZ=!0):t.push(0),"time"in n?(t.push(n.time),delete n.time,e.hasM=!0):t.push(0),t}function Ry(t,e,i){let n="XY",r=2;if(t.hasZ&&t.hasM?(n="XYZM",r=4):t.hasZ?(n="XYZ",r=3):t.hasM&&(n="XYM",r=3),4!==r){for(let i=0,n=e.length/4;i0){e[e.length-1].push(...i)}},outerBoundaryIs:function(t,e){const i=Tf(void 0,rv,t,e);if(i){e[e.length-1][0]=i}}});function Wx(t,e){const i=Tf({},Gx,t,e),n=Tf([null],Vx,t,e);if(n&&n[0]){const t=n[0],e=[t.length];for(let i=1,r=n.length;i0;let o;const a=r.href;let l,h,c;a?o=a:s&&(o=ox);let u="bottom-left";const d=i.hotSpot;let g;d?(l=[d.x,d.y],h=d.xunits,c=d.yunits,u=d.origin):/^https?:\/\/maps\.(?:google|gstatic)\.com\//.test(o)&&(o.includes("pushpin")?(l=ix,h=nx,c=rx):o.includes("arrow-reverse")?(l=[54,42],h=nx,c=rx):o.includes("paddle")&&(l=[32,1],h=nx,c=rx));const f=r.x,p=r.y;let m;void 0!==f&&void 0!==p&&(g=[f,p]);const _=r.w,y=r.h;let x;void 0!==_&&void 0!==y&&(m=[_,y]);const v=i.heading;void 0!==v&&(x=di(v));const w=i.scale,E=i.color;if(s){o==ox&&(m=sx);const t=new il({anchor:l,anchorOrigin:u,anchorXUnits:h,anchorYUnits:c,crossOrigin:this.crossOrigin_,offset:g,offsetOrigin:"bottom-left",rotation:x,scale:w,size:m,src:this.iconUrlFunction_(o),color:E}),e=t.getScaleArray()[0],i=t.getSize();if(null===i){const i=t.getImageState();if(i===ws.IDLE||i===ws.LOADING){const n=function(){const i=t.getImageState();if(i!==ws.IDLE&&i!==ws.LOADING){const i=t.getSize();if(i&&2==i.length){const n=mx(i);t.setScale(e*n)}t.unlistenImageChange(n)}};t.listenImageChange(n),i===ws.IDLE&&t.load()}}else if(2==i.length){const n=mx(i);t.setScale(e*n)}n.imageStyle=t}else n.imageStyle=lx},LabelStyle:function(t,e){const i=Tf({},bx,t,e);if(!i)return;const n=e[e.length-1],r=new nl({fill:new Za({color:"color"in i?i.color:ex}),scale:i.scale});n.textStyle=r},LineStyle:function(t,e){const i=Tf({},Px,t,e);if(!i)return;const n=e[e.length-1],r=new Ka({color:"color"in i?i.color:ex,width:"width"in i?i.width:1});n.strokeStyle=r},PolyStyle:function(t,e){const i=Tf({},Fx,t,e);if(!i)return;const n=e[e.length-1],r=new Za({color:"color"in i?i.color:ex});n.fillStyle=r;const s=i.fill;void 0!==s&&(n.fill=s);const o=i.outline;void 0!==o&&(n.outline=o)}});function Zx(t,e){const i=Tf({},Yx,t,e,this);if(!i)return null;let n="fillStyle"in i?i.fillStyle:ax;const r=i.fill;let s;void 0===r||r||(n=null),"imageStyle"in i?i.imageStyle!=lx&&(s=i.imageStyle):s=hx;const o="textStyle"in i?i.textStyle:dx,a="strokeStyle"in i?i.strokeStyle:ux,l=i.outline;return void 0===l||l?[new Ha({fill:n,image:s,stroke:a,text:o,zIndex:void 0})]:[new Ha({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new hd(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 Ha({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new hd(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 Kx(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=wf(r,o);Rf(n,Fv,Lv,[{names:o,values:t}],i)}const u=i[0];let d=e.getGeometry();d&&(d=I_(d,!0,u)),Rf(n,Fv,vv,[d],i)}const Av=Ef(Yy,["extrude","tessellate","altitudeMode","coordinates"]),Ov=Ef(Yy,{extrude:_f(Y_),tessellate:_f(Y_),altitudeMode:_f($_),coordinates:_f((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;t>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)*Wv;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Wv;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 Hv(t,r,e);if(s=n[i.pos++],r|=(127&s)<<3,s<128)return Hv(t,r,e);if(s=n[i.pos++],r|=(127&s)<<10,s<128)return Hv(t,r,e);if(s=n[i.pos++],r|=(127&s)<<17,s<128)return Hv(t,r,e);if(s=n[i.pos++],r|=(127&s)<<24,s<128)return Hv(t,r,e);if(s=n[i.pos++],r|=(1&s)<<31,s<128)return Hv(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&&Zv?Zv.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&&qv(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&&qv(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,$v,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,Jv,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,ew,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,Qv,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,tw,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,iw,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,nw,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,rw,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,sw,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 Hv(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function qv(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 $v(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 lw(t,e,i){if(1==t)e.id=i.readVarint();else if(2==t){const t=i.readVarint()+i.pos;for(;i.pos>1):i>>1}return e}function Uw(t){let e="";for(let i=0,n=t.length;i=32;)e=63+(32|31&t),i+=String.fromCharCode(e),t>>=5;return e=t+63,i+=String.fromCharCode(e),i}const Xw={Point:function(t,e,i){const n=t.coordinates;e&&i&&Kw(n,e,i);return new Gr(n)},LineString:function(t,e){const i=Vw(t.arcs,e);return new pd(i)},Polygon:function(t,e){const i=[];for(let n=0,r=t.arcs.length;n0&&i.pop(),n>=0){const t=e[n];for(let e=0,n=t.length;e=0;--e)i.push(t[e].slice(0))}return i}function Ww(t,e,i,n,r,s,o){const a=t.geometries,l=[];for(let t=0,h=a.length;t0&&!(t instanceof lr)){t={_content_:t};for(let e=0;e=2,"At least 2 conditions are required")}}class aE extends oE{constructor(t){super("And",Array.prototype.slice.call(arguments))}}class lE extends sE{constructor(t,e,i){if(super("BBOX"),this.geometryName=t,this.extent=e,4!==e.length)throw new Error("Expected an extent with four values ([minX, minY, maxX, maxY])");this.srsName=i}}const hE={"http://www.opengis.net/gml":{boundedBy:mf($w.prototype.readExtentElement,"bounds")},"http://www.opengis.net/wfs/2.0":{member:gf($w.prototype.readFeaturesInternal)}},cE={"http://www.opengis.net/wfs":{totalInserted:mf(X_),totalUpdated:mf(X_),totalDeleted:mf(X_)},"http://www.opengis.net/wfs/2.0":{totalInserted:mf(X_),totalUpdated:mf(X_),totalDeleted:mf(X_)}},uE={"http://www.opengis.net/wfs":{TransactionSummary:mf(EE,"transactionSummary"),InsertResults:mf(RE,"insertIds")},"http://www.opengis.net/wfs/2.0":{TransactionSummary:mf(EE,"transactionSummary"),InsertResults:mf(RE,"insertIds")}},dE={"http://www.opengis.net/wfs":{PropertyName:_f($_)},"http://www.opengis.net/wfs/2.0":{PropertyName:_f($_)}},gE={"http://www.opengis.net/wfs":{Insert:_f(bE),Update:_f(LE),Delete:_f(ME),Property:_f(IE),Native:_f(AE)},"http://www.opengis.net/wfs/2.0":{Insert:_f(bE),Update:_f(LE),Delete:_f(ME),Property:_f(IE),Native:_f(AE)}},fE="feature",pE="http://www.w3.org/2000/xmlns/",mE={"2.0.0":"http://www.opengis.net/ogc/1.1","1.1.0":"http://www.opengis.net/ogc","1.0.0":"http://www.opengis.net/ogc"},_E={"2.0.0":"http://www.opengis.net/wfs/2.0","1.1.0":"http://www.opengis.net/wfs","1.0.0":"http://www.opengis.net/wfs"},yE={"2.0.0":"http://www.opengis.net/fes/2.0","1.1.0":"http://www.opengis.net/fes","1.0.0":"http://www.opengis.net/fes"},xE={"2.0.0":"http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd","1.1.0":"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd","1.0.0":"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd"},vE={"2.0.0":rE,"1.1.0":nE,"1.0.0":tE};function wE(t,e,i,n){Rf(n,gE,xf(t),e,i)}function EE(t,e){return Tf({},cE,t,e)}const SE={"http://www.opengis.net/ogc":{FeatureId:gf((function(t,e){return t.getAttribute("fid")}))},"http://www.opengis.net/ogc/1.1":{FeatureId:gf((function(t,e){return t.getAttribute("fid")}))}};function TE(t,e){Sf(SE,t,e)}const CE={"http://www.opengis.net/wfs":{Feature:TE},"http://www.opengis.net/wfs/2.0":{Feature:TE}};function RE(t,e){return Tf([],CE,t,e)}function bE(t,e,i){const n=i[i.length-1],r=n.featureType,s=n.featureNS,o=n.gmlVersion,a=of(s,r);t.appendChild(a),2===o?tE.prototype.writeFeatureElement(a,e,i):3===o?nE.prototype.writeFeatureElement(a,e,i):rE.prototype.writeFeatureElement(a,e,i)}function PE(t,e,i){const n=i[i.length-1].version,r=mE[n],s=of(r,"Filter"),o=of(r,"FeatureId");s.appendChild(o),o.setAttribute("fid",e),t.appendChild(s)}function FE(t,e){const i=(t=t||fE)+":";return e.startsWith(i)?e:i+e}function ME(t,e,i){const n=i[i.length-1];Lt(void 0!==e.getId(),"Features must have an id set");const r=n.featureType,s=n.featurePrefix,o=n.featureNS,a=FE(s,r);t.setAttribute("typeName",a),t.setAttributeNS(pE,"xmlns:"+s,o);const l=e.getId();void 0!==l&&PE(t,l,i)}function LE(t,e,i){const n=i[i.length-1];Lt(void 0!==e.getId(),"Features must have an id set");const r=n.version,s=n.featureType,o=n.featurePrefix,a=n.featureNS,l=FE(o,s),h=e.getGeometryName();t.setAttribute("typeName",l),t.setAttributeNS(pE,"xmlns:"+o,a);const c=e.getId();if(void 0!==c){const s=e.getKeys(),o=[];for(let t=0,i=s.length;t0;)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=zc(this.peekFirstKey())[0];this.forEach((e=>{e.tileCoord[0]!==t&&(this.remove(Bc(e.tileCoord)),e.release())}))}},FS.TileQueue=Oh,FS.TileQueue.getTilePriority=Dh,FS.TileRange=Yc,FS.TileRange.createOrUpdate=Zc,FS.VectorRenderTile=class extends nt{constructor(t,e,i,n,r){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.removeSourceTiles_=r,this.wrappedTileCoord=i}getContext(){return this.context_||(this.context_=pt(1,1,Kc)),this.context_}hasContext(){return!!this.context_}getImage(){return this.hasContext()?this.getContext().canvas:null}getReplayState(t){const e=U(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(){this.context_&&(yt(this.context_),Kc.push(this.context_.canvas),this.context_=null),this.removeSourceTiles_(this),this.sourceTiles.length=0,super.release()}},FS.View=lo,FS.View.createCenterConstraint=co,FS.View.createResolutionConstraint=uo,FS.View.createRotationConstraint=go,FS.View.isNoopAnimation=fo,FS.array={},FS.array.ascending=s,FS.array.binarySearch=r,FS.array.descending=o,FS.array.equals=c,FS.array.extend=h,FS.array.isSorted=u,FS.array.linearFindNearest=a,FS.array.remove=function(t,e){const i=t.indexOf(e),n=i>-1;return n&&t.splice(i,1),n},FS.array.reverseSubArray=l,FS.array.stableSort=function(t,e){const i=t.length,n=Array(t.length);let r;for(r=0;rvn.info||console.log(...t)},FS.console.setLevel=function(t){wn=vn[t]},FS.console.warn=En,FS.control={},FS.control.Attribution=kh,FS.control.Control=Nh,FS.control.FullScreen=class extends Nh{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target}),this.on,this.once,this.un,this.keys_=void 0!==t.keys&&t.keys,this.source_=t.source,this.isInFullscreen_=!1,this.boundHandleMapTargetChange_=this.handleMapTargetChange_.bind(this),this.cssClassName_=void 0!==t.className?t.className:"ol-full-screen",this.documentListeners_=[],this.activeClassName_=void 0!==t.activeClassName?t.activeClassName.split(" "):[this.cssClassName_+"-true"],this.inactiveClassName_=void 0!==t.inactiveClassName?t.inactiveClassName.split(" "):[this.cssClassName_+"-false"];const e=void 0!==t.label?t.label:"⤢";this.labelNode_="string"==typeof e?document.createTextNode(e):e;const i=void 0!==t.labelActive?t.labelActive:"×";this.labelActiveNode_="string"==typeof i?document.createTextNode(i):i;const n=t.tipLabel?t.tipLabel:"Toggle full-screen";this.button_=document.createElement("button"),this.button_.title=n,this.button_.setAttribute("type","button"),this.button_.appendChild(this.labelNode_),this.button_.addEventListener(S,this.handleClick_.bind(this),!1),this.setClassName_(this.button_,this.isInFullscreen_),this.element.className=`${this.cssClassName_} ${_a} ${xa}`,this.element.appendChild(this.button_)}handleClick_(t){t.preventDefault(),this.handleFullScreen_()}handleFullScreen_(){const t=this.getMap();if(!t)return;const e=t.getOwnerDocument();if(_S(e))if(yS(e))!function(t){t.exitFullscreen?t.exitFullscreen():t.webkitExitFullscreen&&t.webkitExitFullscreen()}(e);else{let i;i=this.source_?"string"==typeof this.source_?e.getElementById(this.source_):this.source_:t.getTargetElement(),this.keys_?function(t){t.webkitRequestFullscreen?t.webkitRequestFullscreen():xS(t)}(i):xS(i)}}handleFullScreenChange_(){const t=this.getMap();if(!t)return;const e=this.isInFullscreen_;this.isInFullscreen_=yS(t.getOwnerDocument()),e!==this.isInFullscreen_&&(this.setClassName_(this.button_,this.isInFullscreen_),this.isInFullscreen_?(wt(this.labelActiveNode_,this.labelNode_),this.dispatchEvent(pS)):(wt(this.labelNode_,this.labelActiveNode_),this.dispatchEvent(mS)),t.updateSize())}setClassName_(t,e){e?(t.classList.remove(...this.inactiveClassName_),t.classList.add(...this.activeClassName_)):(t.classList.remove(...this.activeClassName_),t.classList.add(...this.inactiveClassName_))}setMap(t){const e=this.getMap();e&&e.removeChangeListener(Mh,this.boundHandleMapTargetChange_),super.setMap(t),this.handleMapTargetChange_(),t&&t.addChangeListener(Mh,this.boundHandleMapTargetChange_)}handleMapTargetChange_(){const t=this.documentListeners_;for(let e=0,i=t.length;ec*ES||h>u*ES?this.resetExtent_():Qt(s,n)||this.recenter_()}resetExtent_(){const t=this.getMap(),e=this.ovmap_,i=t.getSize(),n=t.getView().calculateExtentInternal(i),r=e.getView(),s=Math.log(7.5)/Math.LN2;Le(n,1/(Math.pow(2,s/2)*SS)),r.fitInternal(os(n))}recenter_(){const t=this.getMap(),e=this.ovmap_,i=t.getView();e.getView().setCenterInternal(i.getCenterInternal())}updateBox_(){const t=this.getMap(),e=this.ovmap_;if(!t.isRendered()||!e.isRendered())return;const i=t.getSize(),n=t.getView(),r=e.getView(),s=this.rotateWithView_?0:-n.getRotation(),o=this.boxOverlay_,a=this.boxOverlay_.getElement(),l=n.getCenter(),h=n.getResolution(),c=r.getResolution(),u=i[0]*h/c,d=i[1]*h/c;if(o.setPosition(l),a){a.style.width=u+"px",a.style.height=d+"px";const t="rotate("+s+"rad)";a.style.transform=t}}updateBoxAfterOvmapIsRendered_(){this.ovmapPostrenderKey_||(this.ovmapPostrenderKey_=O(this.ovmap_,Sh,(t=>{delete this.ovmapPostrenderKey_,this.updateBox_()})))}handleClick_(t){t.preventDefault(),this.handleToggle_()}handleToggle_(){this.element.classList.toggle(va),this.collapsed_?wt(this.collapseLabel_,this.label_):wt(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_;const t=this.ovmap_;if(!this.collapsed_){if(t.isRendered())return this.viewExtent_=void 0,void t.render();t.updateSize(),this.resetExtent_(),this.updateBoxAfterOvmapIsRendered_()}}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),!t&&this.collapsed_&&this.handleToggle_())}setCollapsed(t){this.collapsible_&&this.collapsed_!==t&&this.handleToggle_()}getCollapsed(){return this.collapsed_}getRotateWithView(){return this.rotateWithView_}setRotateWithView(t){this.rotateWithView_!==t&&(this.rotateWithView_=t,0!==this.getMap().getView().getRotation()&&(this.rotateWithView_?this.handleRotationChanged_():this.ovmap_.getView().setRotation(0),this.viewExtent_=void 0,this.validateExtent_(),this.updateBox_()))}getOverviewMap(){return this.ovmap_}render(t){this.validateExtent_(),this.updateBox_()}},FS.control.Rotate=Gh,FS.control.ScaleLine=class extends Nh{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+" "+_a,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(TS,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(TS)}handleUnitsChanged_(){this.updateElement_()}setUnits(t){this.set(TS,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=An(i,t.resolution,e,r);const o=this.minWidth_*(this.dpi_||RS)/RS,a=void 0!==this.maxWidth_?this.maxWidth_*(this.dpi_||RS)/RS:void 0;let l=o*s,h="";if("degrees"==n){const t=ke.degrees;l*=t,l=a){c=g,u=f,d=p;break}if(u>=o)break;g=c,f=u,p=d,++m}const _=this.scaleBar_?this.createScaleBar(u,c,h):c.toFixed(d<0?-d:0)+" "+h;this.renderedHTML_!=_&&(this.innerElement_.innerHTML=_,this.renderedHTML_=_),this.renderedWidth_!=u&&(this.innerElement_.style.width=u+"px",this.renderedWidth_=u),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 An(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m")*(1e3/25.4)*(this.dpi_||RS)}render(t){const e=t.frameState;this.viewState_=e?e.viewState:null,this.updateElement_()}},FS.control.Zoom=jh,FS.control.ZoomSlider=class extends Nh{constructor(t){super({target:(t=t||{}).target,element:document.createElement("div"),render:t.render}),this.dragListenerKeys_=[],this.currentResolution_=void 0,this.direction_=bS,this.dragging_,this.heightLimit_=0,this.widthLimit_=0,this.startX_,this.startY_,this.thumbSize_=null,this.sliderInitialized_=!1,this.duration_=void 0!==t.duration?t.duration:200;const i=void 0!==t.className?t.className:"ol-zoomslider",n=document.createElement("button");n.setAttribute("type","button"),n.className=i+"-thumb "+_a;const r=this.element;r.className=i+" "+_a+" "+xa,r.appendChild(n),r.addEventListener(xh,this.handleDraggerStart_.bind(this),!1),r.addEventListener(yh,this.handleDraggerDrag_.bind(this),!1),r.addEventListener(vh,this.handleDraggerEnd_.bind(this),!1),r.addEventListener(S,this.handleContainerClick_.bind(this),!1),n.addEventListener(S,e,!1)}setMap(t){super.setMap(t),t&&t.render()}initSlider_(){const t=this.element;let e=t.offsetWidth,i=t.offsetHeight;if(0===e&&0===i)return this.sliderInitialized_=!1;const n=getComputedStyle(t);e-=parseFloat(n.paddingRight)+parseFloat(n.paddingLeft),i-=parseFloat(n.paddingTop)+parseFloat(n.paddingBottom);const r=t.firstElementChild,s=getComputedStyle(r),o=r.offsetWidth+parseFloat(s.marginRight)+parseFloat(s.marginLeft),a=r.offsetHeight+parseFloat(s.marginTop)+parseFloat(s.marginBottom);return this.thumbSize_=[o,a],e>i?(this.direction_=PS,this.widthLimit_=e-o):(this.direction_=bS,this.heightLimit_=i-a),this.sliderInitialized_=!0}handleContainerClick_(t){const e=this.getMap().getView(),i=this.getRelativePosition_(t.offsetX-this.thumbSize_[0]/2,t.offsetY-this.thumbSize_[1]/2),n=this.getResolutionForPosition_(i),r=e.getConstrainedZoom(e.getZoomForResolution(n));e.animateInternal({zoom:r,duration:this.duration_,easing:tt})}handleDraggerStart_(t){if(!this.dragging_&&t.target===this.element.firstElementChild){const e=this.element.firstElementChild;if(this.getMap().getView().beginInteraction(),this.startX_=t.clientX-parseFloat(e.style.left),this.startY_=t.clientY-parseFloat(e.style.top),this.dragging_=!0,0===this.dragListenerKeys_.length){const t=this.handleDraggerDrag_,e=this.handleDraggerEnd_,i=this.getMap().getOwnerDocument();this.dragListenerKeys_.push(A(i,yh,t,this),A(i,vh,e,this))}}}handleDraggerDrag_(t){if(this.dragging_){const e=t.clientX-this.startX_,i=t.clientY-this.startY_,n=this.getRelativePosition_(e,i);this.currentResolution_=this.getResolutionForPosition_(n),this.getMap().getView().setResolution(this.currentResolution_)}}handleDraggerEnd_(t){if(this.dragging_){this.getMap().getView().endInteraction(),this.dragging_=!1,this.startX_=void 0,this.startY_=void 0,this.dragListenerKeys_.forEach(D),this.dragListenerKeys_.length=0}}setThumbPosition_(t){const e=this.getPositionForResolution_(t),i=this.element.firstElementChild;this.direction_==PS?i.style.left=this.widthLimit_*e+"px":i.style.top=this.heightLimit_*e+"px"}getRelativePosition_(t,e){let i;return i=this.direction_===PS?t/this.widthLimit_:e/this.heightLimit_,ai(i,0,1)}getResolutionForPosition_(t){return this.getMap().getView().getResolutionForValueFunction()(1-t)}getPositionForResolution_(t){return ai(1-this.getMap().getView().getValueForResolutionFunction()(t),0,1)}render(t){if(!t.frameState)return;if(!this.sliderInitialized_&&!this.initSlider_())return;const e=t.frameState.viewState.resolution;this.currentResolution_=e,this.setThumbPosition_(e)}},FS.control.ZoomToExtent=class extends Nh{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target}),this.extent=t.extent?t.extent:null;const e=void 0!==t.className?t.className:"ol-zoom-extent",i=void 0!==t.label?t.label:"E",n=void 0!==t.tipLabel?t.tipLabel:"Fit to extent",r=document.createElement("button");r.setAttribute("type","button"),r.title=n,r.appendChild("string"==typeof i?document.createTextNode(i):i),r.addEventListener(S,this.handleClick_.bind(this),!1);const s=e+" "+_a+" "+xa,o=this.element;o.className=s,o.appendChild(r)}handleClick_(t){t.preventDefault(),this.handleZoomToExtent()}handleZoomToExtent(){const t=this.getMap().getView(),e=this.extent?Jn(this.extent,t.getProjection()):t.getProjection().getExtent();t.fitInternal(os(e))}},FS.control.defaults={},FS.control.defaults.defaults=Uh,FS.coordinate={},FS.coordinate.add=Ei,FS.coordinate.closestOnCircle=Si,FS.coordinate.closestOnSegment=Ti,FS.coordinate.createStringXY=function(t){return function(e){return Ai(e,t)}},FS.coordinate.degreesToStringHDMS=Ci,FS.coordinate.distance=Li,FS.coordinate.equals=bi,FS.coordinate.format=Ri,FS.coordinate.getWorldsAway=Di,FS.coordinate.rotate=Pi,FS.coordinate.scale=Fi,FS.coordinate.squaredDistance=Mi,FS.coordinate.squaredDistanceToSegment=Ii,FS.coordinate.toStringHDMS=function(t,e){return t?Ci("NS",t[1],e)+" "+Ci("EW",t[0],e):""},FS.coordinate.toStringXY=Ai,FS.coordinate.wrapX=Oi,FS.css={},FS.css.CLASS_COLLAPSED=va,FS.css.CLASS_CONTROL=xa,FS.css.CLASS_HIDDEN=pa,FS.css.CLASS_SELECTABLE=ma,FS.css.CLASS_UNSELECTABLE=_a,FS.css.CLASS_UNSUPPORTED=ya,FS.css.getFontParameters=Sa,FS.dom={},FS.dom.createCanvasContext2D=pt,FS.dom.getSharedCanvasContext2D=_t,FS.dom.outerHeight=vt,FS.dom.outerWidth=xt,FS.dom.releaseCanvas=yt,FS.dom.removeChildren=Et,FS.dom.replaceChildren=St,FS.dom.replaceNode=wt,FS.easing={},FS.easing.easeIn=Q,FS.easing.easeOut=tt,FS.easing.inAndOut=et,FS.easing.linear=it,FS.easing.upAndDown=function(t){return t<.5?et(2*t):1-et(2*(t-.5))},FS.events={},FS.events.Event=t,FS.events.Event.preventDefault=function(t){t.preventDefault()},FS.events.Event.stopPropagation=e,FS.events.SnapEvent={},FS.events.SnapEvent.SnapEvent=S_,FS.events.Target=x,FS.events.condition={},FS.events.condition.all=Kh,FS.events.condition.altKeyOnly=Hh,FS.events.condition.altShiftKeysOnly=qh,FS.events.condition.always=Qh,FS.events.condition.click=function(t){return t.type==_h.CLICK},FS.events.condition.doubleClick=function(t){return t.type==_h.DBLCLICK},FS.events.condition.focus=$h,FS.events.condition.focusWithTabindex=Jh,FS.events.condition.mouseActionButton=tc,FS.events.condition.mouseOnly=ac,FS.events.condition.never=ec,FS.events.condition.noModifierKeys=nc,FS.events.condition.penOnly=function(t){const e=t.originalEvent;return Lt(void 0!==e,"mapBrowserEvent must originate from a pointer event"),"pen"===e.pointerType},FS.events.condition.platformModifierKey=rc,FS.events.condition.platformModifierKeyOnly=function(t){const e=t.originalEvent;return!e.altKey&&(ht?e.metaKey:e.ctrlKey)&&!e.shiftKey},FS.events.condition.pointerMove=function(t){return"pointermove"==t.type},FS.events.condition.primaryAction=lc,FS.events.condition.shiftKeyOnly=sc,FS.events.condition.singleClick=ic,FS.events.condition.targetNotEditable=oc,FS.events.condition.touchOnly=function(t){const e=t.originalEvent;return Lt(void 0!==e,"mapBrowserEvent must originate from a pointer event"),"touch"===e.pointerType},FS.events.listen=A,FS.events.listenOnce=O,FS.events.unlistenByKey=D,FS.expr={},FS.expr.cpu={},FS.expr.cpu.buildExpression=Il,FS.expr.cpu.newEvaluationContext=Ll,FS.expr.expression={},FS.expr.expression.AnyType=ul,FS.expr.expression.BooleanType=sl,FS.expr.expression.CallExpression=yl,FS.expr.expression.ColorType=ll,FS.expr.expression.LiteralExpression=_l,FS.expr.expression.NoneType=0,FS.expr.expression.NumberArrayType=hl,FS.expr.expression.NumberType=ol,FS.expr.expression.Ops=wl,FS.expr.expression.SizeType=cl,FS.expr.expression.StringType=al,FS.expr.expression.computeGeometryType=Ml,FS.expr.expression.includesType=pl,FS.expr.expression.isType=ml,FS.expr.expression.newParsingContext=xl,FS.expr.expression.overlapsType=function(t,e){return!!(t&e)},FS.expr.expression.parse=vl,FS.expr.expression.typeName=fl,FS.expr.gpu={},FS.expr.gpu.FEATURE_ID_PROPERTY_NAME=Rm,FS.expr.gpu.GEOMETRY_TYPE_PROPERTY_NAME=bm,FS.expr.gpu.PALETTE_TEXTURE_ARRAY=Cm,FS.expr.gpu.arrayToGlsl=mm,FS.expr.gpu.buildExpression=function(t,e,i,n){return Mm(vl(t,e,i),e,n)},FS.expr.gpu.colorToGlsl=_m,FS.expr.gpu.getStringNumberEquivalent=wm,FS.expr.gpu.newCompilationContext=function(){return{inFragmentShader:!1,variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}},FS.expr.gpu.numberToGlsl=pm,FS.expr.gpu.sizeToGlsl=ym,FS.expr.gpu.stringToGlsl=Em,FS.expr.gpu.uniformNameForVariable=Sm,FS.extent={},FS.extent.applyTransform=Ae,FS.extent.approximatelyEquals=le,FS.extent.boundingExtent=Kt,FS.extent.buffer=Ht,FS.extent.clone=qt,FS.extent.closestSquaredDistanceXY=$t,FS.extent.containsCoordinate=Jt,FS.extent.containsExtent=Qt,FS.extent.containsXY=te,FS.extent.coordinateRelationship=ee,FS.extent.createEmpty=ie,FS.extent.createOrUpdate=ne,FS.extent.createOrUpdateEmpty=re,FS.extent.createOrUpdateFromCoordinate=se,FS.extent.createOrUpdateFromCoordinates=function(t,e){return ue(re(e),t)},FS.extent.createOrUpdateFromFlatCoordinates=oe,FS.extent.createOrUpdateFromRings=function(t,e){return ge(re(e),t)},FS.extent.equals=ae,FS.extent.extend=he,FS.extent.extendCoordinate=ce,FS.extent.extendCoordinates=ue,FS.extent.extendFlatCoordinates=de,FS.extent.extendRings=ge,FS.extent.extendXY=fe,FS.extent.forEachCorner=pe,FS.extent.getArea=me,FS.extent.getBottomLeft=_e,FS.extent.getBottomRight=ye,FS.extent.getCenter=xe,FS.extent.getCorner=ve,FS.extent.getEnlargedArea=function(t,e){const i=Math.min(t[0],e[0]),n=Math.min(t[1],e[1]);return(Math.max(t[2],e[2])-i)*(Math.max(t[3],e[3])-n)},FS.extent.getForViewAndSize=we,FS.extent.getHeight=Se,FS.extent.getIntersection=Te,FS.extent.getIntersectionArea=function(t,e){return me(Te(t,e))},FS.extent.getMargin=function(t){return be(t)+Se(t)},FS.extent.getRotatedViewport=Ee,FS.extent.getSize=function(t){return[t[2]-t[0],t[3]-t[1]]},FS.extent.getTopLeft=Ce,FS.extent.getTopRight=Re,FS.extent.getWidth=be,FS.extent.intersects=Pe,FS.extent.intersectsSegment=Ie,FS.extent.isEmpty=Fe,FS.extent.returnOrUpdate=Me,FS.extent.scaleFromCenter=Le,FS.extent.wrapAndSliceX=De,FS.extent.wrapX=Oe,FS.featureloader={},FS.featureloader.loadFeaturesXhr=$c,FS.featureloader.setWithCredentials=function(t){qc=t},FS.featureloader.xhr=Jc,FS.format={},FS.format.Feature=L_,FS.format.Feature.createGeometry=N_,FS.format.Feature.createRenderFeature=D_,FS.format.Feature.transformExtentWithOptions=A_,FS.format.Feature.transformGeometryWithOptions=I_,FS.format.GPX=class extends k_{constructor(t){super(),t=t||{},this.dataProjection=In("EPSG:4326"),this.readExtensions_=t.readExtensions}handleReadExtensions_(t){t||(t=[]);for(let e=0,i=t.length;e0;else{const e=t.getType();a="Point"===e||"MultiPoint"===e}}a&&(l=s.get("name"),a=a&&!!l,a&&/&[^&]+;/.test(l)&&(fx||(fx=document.createElement("textarea")),fx.innerHTML=l,l=fx.value));let c=i;if(t?c=t:e&&(c=yx(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()||dx.getFont()),s.setScale(s.getScale()||dx.getScale()),s.setFill(s.getFill()||dx.getFill()),s.setStroke(s.getStroke()||cx)):s=dx.clone();s.setText(e),s.setOffsetX(i[0]),s.setOffsetY(i[1]),s.setTextAlign(n);const o=new Ha({image:r,text:s});return o}(c[0],l);if(h.length>0){t.setGeometry(new hd(h));return[t,new Ha({geometry:c[0].getGeometry(),image:null,fill:c[0].getFill(),stroke:c[0].getStroke(),text:null})].concat(c.slice(1))}return t}return c}}(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=Zx.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=Cx.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(!Yy.includes(t.namespaceURI))return null;const i=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return i||null}readFeaturesFromNode(t,e){if(!Yy.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&&h(i,t)}return i}return[]}readName(t){if(t){if("string"==typeof t){const e=uf(t);return this.readNameFromDocument(e)}return hf(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(Yy.includes(e.namespaceURI)&&"name"==e.localName)return W_(e);for(let e=t.firstElementChild;e;e=e.nextElementSibling){const t=e.localName;if(Yy.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=uf(t);h(e,this.readNetworkLinksFromDocument(i))}else hf(t)?h(e,this.readNetworkLinksFromDocument(t)):h(e,this.readNetworkLinksFromNode(t));return e}readNetworkLinksFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&h(e,this.readNetworkLinksFromNode(i));return e}readNetworkLinksFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(Yy.includes(i.namespaceURI)&&"NetworkLink"==i.localName){const t=Tf({},Hy,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!Yy.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||h(e,this.readNetworkLinksFromNode(i))}return e}readRegion(t){const e=[];if("string"==typeof t){const i=uf(t);h(e,this.readRegionFromDocument(i))}else hf(t)?h(e,this.readRegionFromDocument(t)):h(e,this.readRegionFromNode(t));return e}readRegionFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&h(e,this.readRegionFromNode(i));return e}readRegionFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(Yy.includes(i.namespaceURI)&&"Region"==i.localName){const t=Tf({},Jy,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!Yy.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||h(e,this.readRegionFromNode(i))}return e}readCamera(t){const e=[];if("string"==typeof t){const i=uf(t);h(e,this.readCameraFromDocument(i))}else hf(t)?h(e,this.readCameraFromDocument(t)):h(e,this.readCameraFromNode(t));return e}readCameraFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType===Node.ELEMENT_NODE&&h(e,this.readCameraFromNode(i));return e}readCameraFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(Yy.includes(i.namespaceURI)&&"Camera"===i.localName){const t=Tf({},$y,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!Yy.includes(i.namespaceURI)||"Document"!==t&&"Folder"!==t&&"Placemark"!==t&&"kml"!==t||h(e,this.readCameraFromNode(i))}return e}writeFeaturesNode(t,e){e=this.adaptOptions(e);const i=of(Yy[4],"kml"),n="http://www.w3.org/2000/xmlns/";i.setAttributeNS(n,"xmlns:gx",Wy[0]),i.setAttributeNS(n,"xmlns:xsi",sf),i.setAttributeNS(sf,"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=Qy[i.namespaceURI],a=wf(s,o);return Rf(r,tx,vf,a,[e],o,this),i}},FS.format.KML.getDefaultFillStyle=function(){return ax},FS.format.KML.getDefaultImageStyle=function(){return hx},FS.format.KML.getDefaultStrokeStyle=function(){return ux},FS.format.KML.getDefaultStyle=function(){return gx},FS.format.KML.getDefaultStyleArray=function(){return px},FS.format.KML.getDefaultTextStyle=function(){return dx},FS.format.KML.readFlatCoordinates=vx,FS.format.MVT=class extends L_{constructor(t){super(),t=t||{},this.dataProjection=new Ge({code:"",units:"tile-pixels"}),this.featureClass=t.featureClass?t.featureClass:wd,this.geometryName_=t.geometryName,this.layerName_=t.layerName?t.layerName:"layer",this.layers_=t.layers?t.layers:null,this.idProperty_=t.idProperty,this.supportedMediaTypes=["application/vnd.mapbox-vector-tile","application/x-protobuf"]}readRawGeometry_(t,e,i,n){t.pos=e.geometry;const r=t.readVarint()+t.pos;let s=1,o=0,a=0,l=0,h=0,c=0;for(;t.pos>3}if(o--,1===s||2===s)a+=t.readSVarint(),l+=t.readSVarint(),1===s&&h>c&&(n.push(h),c=h),i.push(a,l),h+=2;else{if(7!==s)throw new Error("Invalid command found in the PBF");h>c&&(i.push(i[c],i[c+1]),h+=2)}}h>c&&(n.push(h),c=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===wd)r=new this.featureClass(h,a,l,2,s,o),r.transform(i.dataProjection);else{let t;if("Polygon"==h){const e=ns(a,l);t=e.length>1?new xd(a,"XY",e):new rs(a,"XY",l)}else t="Point"===h?new Gr(a,"XY"):"LineString"===h?new pd(a,"XY"):"MultiPoint"===h?new _d(a,"XY"):"MultiLineString"===h?new md(a,"XY",l):null;r=new(0,this.featureClass),this.geometryName_&&r.setGeometryName(this.geometryName_);const e=I_(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=In((e=this.adaptOptions(e)).dataProjection);n.setWorldExtent(e.extent),e.dataProjection=n;const r=new Kv(t),s=r.readFields(ow,{}),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{const r=this.combineBboxAndFilter(n.geometryName,n.bbox,t.srsName,t.filter);Object.assign(i,{geometryName:n.geometryName,filter:r}),$E(e,[n.name],[i])}));return e}combineBboxAndFilter(t,e,i,n){const r=function(t,e,i){return new lE(t,e,i)}(t,e,i);return n?function(t){const e=[null].concat(Array.prototype.slice.call(arguments));return new(Function.prototype.bind.apply(aE,e))}(n,r):r}writeTransaction(t,e,i,n){const r=[],s=n.version?n.version:this.version_,o=of(_E[s],"Transaction");let a;o.setAttribute("service","WFS"),o.setAttribute("version",s),n&&(a=n.gmlOptions?n.gmlOptions:{},n.handle&&o.setAttribute("handle",n.handle)),o.setAttributeNS(sf,"xsi:schemaLocation",xE[s]);const l=function(t,e,i,n){const r=n.featurePrefix?n.featurePrefix:fE;let s;"1.0.0"===i?s=2:"1.1.0"===i?s=3:"2.0.0"===i&&(s=3.2);const o=Object.assign({node:t},{version:i,featureNS:n.featureNS,featureType:n.featureType,featurePrefix:r,gmlVersion:s,hasZ:n.hasZ,srsName:n.srsName},e);return o}(o,a,s,n);return t&&wE("Insert",t,r,l),e&&wE("Update",e,r,l),i&&wE("Delete",i,r,l),n.nativeElements&&wE("Native",n.nativeElements,r,l),o}readProjectionFromDocument(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType==Node.ELEMENT_NODE)return this.readProjectionFromNode(e);return null}readProjectionFromNode(t){if(t.firstElementChild&&t.firstElementChild.firstElementChild)for(let e=(t=t.firstElementChild.firstElementChild).firstElementChild;e;e=e.nextElementSibling)if(0!==e.childNodes.length&&(1!==e.childNodes.length||3!==e.firstChild.nodeType)){const t=[{}];return this.gmlFormat_.readGeometryElement(e,t),In(t.pop().srsName)}return null}},FS.format.WFS.writeFilter=function(t,e){const i=of(JE(e=e||"1.1.0"),"Filter"),n={node:i};return Object.assign(n,{version:e,filter:t}),NE(i,t,[n]),i},FS.format.WMSGetFeatureInfo=class extends k_{constructor(t){super(),t=t||{},this.featureNS_="http://mapserver.gis.umn.edu/mapserver",this.gmlFormat_=new tE,this.layers_=t.layers?t.layers:null}getLayers(){return this.layers_}setLayers(t){this.layers_=t}readFeatures_(t,e){t.setAttribute("namespaceURI",this.featureNS_);const i=t.localName;let n=[];if(0===t.childNodes.length)return n;if("msGMLOutput"==i)for(let i=0,r=t.childNodes.length;i3&&!!Or(t,e,i,n)},FS.geom.flat.transform={},FS.geom.flat.transform.rotate=rr,FS.geom.flat.transform.scale=sr,FS.geom.flat.transform.transform2D=nr,FS.geom.flat.transform.translate=or,FS.has={},FS.has.CREATE_IMAGE_BITMAP=gt,FS.has.DEVICE_PIXEL_RATIO=ct,FS.has.FIREFOX=st,FS.has.IMAGE_DECODE=dt,FS.has.MAC=ht,FS.has.PASSIVE_EVENT_LISTENERS=ft,FS.has.SAFARI=ot,FS.has.SAFARI_BUG_237906=at,FS.has.WEBKIT=lt,FS.has.WORKER_OFFSCREEN_CANVAS=ut,FS.interaction={},FS.interaction.DblClickDragZoom=class extends zh{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==_h.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==_h.POINTERUP){const e=this.handleUpEvent(t);this.handlingDownUpSequence_=e}}else if(t.type==_h.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===_h.POINTERDOWN||e===_h.POINTERDRAG||e===_h.POINTERUP}(t)){const e=t.originalEvent,i=e.pointerId.toString();t.type==_h.POINTERUP?delete this.trackedPointers_[i]:(t.type==_h.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}},FS.interaction.DoubleClickZoom=Wh,FS.interaction.DragAndDrop=class extends zh{constructor(t){t=t||{},super({handleEvent:d}),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 jm(Gm,t,l,s));break}}}registerListeners_(){const t=this.getMap();if(t){const e=this.target?this.target:t.getViewport();this.dropListenKeys_=[A(e,b,this.handleDrop,this),A(e,C,this.handleStop,this),A(e,R,this.handleStop,this),A(e,b,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(D),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!!ac(t)&&(!!this.condition_(t)&&(t.map.getView().beginInteraction(),this.lastAngle_=void 0,this.lastMagnitude_=void 0,!0))}},FS.interaction.DragZoom=yc,FS.interaction.Draw=class extends Yh{constructor(t){const e=t;e.stopDown||(e.stopDown=g),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:d,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 ld([NaN,NaN]),r=qn(t[0],i),s=Mi(r,qn(t[t.length-1],i));n.setCenterAndRadius(r,Math.sqrt(s),this.geometryLayout_);const o=Kn();return o&&n.transform(i,o),n};else{let e;"Point"===t?e=Gr:"LineString"===t?e=pd:"Polygon"===t&&(e=rs),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 Mp({source:new Ld({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:Qm(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:nc,this.freehandCondition_,t.freehand?this.freehandCondition_=Qh:this.freehandCondition_=t.freehandCondition?t.freehandCondition:sc,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(Bh,this.updateState_)}setTrace(t){let e;e=t?!0===t?Qh:t:ec,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}getOverlay(){return this.overlay_}handleEvent(t){t.originalEvent.type===E&&t.originalEvent.preventDefault(),this.freehand_="Point"!==this.mode_&&this.freehandCondition_(t);let e=t.type===_h.POINTERMOVE,i=!0;if(!this.freehand_&&this.lastDragTime_&&t.type===_h.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===_h.POINTERDRAG&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===_h.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===_h.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===_h.POINTERDRAG&&void 0===this.downTimeout_)&&this.handlePointerMove_(t)):t.type===_h.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 mh(_h.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=Kt([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(Wm(t.coordinates,e))}n.length&&this.appendCoordinates(n)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&Li(e.startPx,t.pixel)i.startIndex?hi.startIndex&&(h-=n.length)),l=h,a=t)}const h=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const t=Jm(h.coordinates,l);Li(i.getPixelFromCoordinate(t),e.startPx)>n&&(c=!1)}if(c){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 _d([e])):"MultiLineString"===this.type_?t.setGeometry(new md([e])):"MultiPolygon"===this.type_&&t.setGeometry(new xd([e])),this.dispatchEvent(new Xm(Bm,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 Xm(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(os(t)):e.setGeometry(void 0):(e=new It(t?os(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 It(new Gr(t)),this.vertexFeature_=e,this.vertexOverlay_.getSource().addFeature(e);return e}handleEvent(t){return!t.originalEvent||!this.condition_(t)||(t.type!=_h.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_=r_(s(r)):null!==t?this.pointerHandler_=s_(s([t,n[1]]),s([t,n[3]])):null!==e&&(this.pointerHandler_=s_(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_=r_(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!==me(e)||this.setExtent(null),!1}setMap(t){this.extentOverlay_.setMap(t),this.vertexOverlay_.setMap(t),super.setMap(t)}getExtent(){return $n(this.getExtentInternal(),this.getMap().getView().getProjection())}getExtentInternal(){return this.extent_}setExtent(t){this.extent_=t||null,this.createOrUpdateExtentFeature_(t),this.dispatchEvent(new e_(this.extent_))}},FS.interaction.Extent.ExtentEvent=e_,FS.interaction.Interaction=zh,FS.interaction.Interaction.pan=Xh,FS.interaction.Interaction.zoomByDelta=Vh,FS.interaction.KeyboardPan=Sc,FS.interaction.KeyboardZoom=Tc,FS.interaction.Link=class extends zh{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(A(t,Ch,this.updateUrl_,this),A(t.getLayerGroup(),v,this.updateUrl_,this),A(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;nt)));const e=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],i=[],n=[];for(let r=0,s=this.dragSegments_.length;r=0;--e)this.insertVertex_(i[e],t);this.ignoreNextSingleClick_=!0}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,r=e.getCenter(),s=i.featureSegments[0],o=i.featureSegments[1];s.segment[0]=r,s.segment[1]=r,o.segment[0]=r,o.segment[1]=r,this.rBush_.update(se(r),s);let a=e;const l=Kn();if(l){const e=t.map.getView().getProjection();a=a.clone().transform(l,e),a=as(a).transform(e,l)}this.rBush_.update(a.getExtent(),o)}else this.rBush_.update(Kt(i.segment),i)}return this.featuresBeingModified_&&(this.dispatchEvent(new g_(d_,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastPixel_=t.pixel,this.handlePointerAtPixel_(t.coordinate)}handlePointerAtPixel_(t){const e=this.getMap(),i=e.getPixelFromCoordinate(t),n=e.getView().getProjection(),r=function(e,i){return p_(t,e,n)-p_(t,i,n)};let s,o;if(this.hitDetection_){const t="object"==typeof this.hitDetection_?t=>t===this.hitDetection_:void 0;e.forEachFeatureAtPixel(i,((t,e,i)=>{i&&"Point"===i.getType()&&(i=new Gr(Hn(i.getCoordinates(),n)));const r=i||t.getGeometry();if(r&&"Point"===r.getType()&&t instanceof It&&this.features_.getArray().includes(t)){o=r;const e=t.getGeometry().getFlatCoordinates().slice(0,2);s=[{feature:t,geometry:o,segment:[e,e]}]}return!0}),{layerFilter:t})}if(!s){const i=$n(Ht(Jn(se(t,h_),n),e.getView().getResolution()*this.pixelTolerance_,h_),n);s=this.rBush_.getInExtent(i)}if(s&&s.length>0){const a=s.sort(r)[0],l=a.segment;let h=m_(t,a,n);const c=e.getPixelFromCoordinate(h);let u=Li(i,c);if(o||u<=this.pixelTolerance_){const i={};if(i[U(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-t[0],this.delta_[1]=h[1]-t[1]),"Circle"===a.geometry.getType()&&1===a.index)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const t=e.getPixelFromCoordinate(l[0]),n=e.getPixelFromCoordinate(l[1]),r=Mi(c,t),o=Mi(c,n);u=Math.sqrt(Math.min(r,o)),this.snappedToVertex_=u<=this.pixelTolerance_,this.snappedToVertex_&&(h=r>o?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const d={};d[U(a.geometry)]=!0;for(let t=1,e=s.length;t"Circle"===t.getType()||t.getType().endsWith("Point"))))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Kt([t])).some((({segment:e})=>bi(e[0],t)||bi(e[1],t)))}removePoint(t){if(t&&(t=qn(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=_h.POINTERDRAG){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map((([t])=>t)));const e=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new g_(d_,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,e}return!1}removeVertex_(){const t=this.dragSegments_,e={};let i,n,r,s,o,a,l,h,c,u,d,g=!1;for(o=t.length-1;o>=0;--o)r=t[o],u=r[0],d=U(u.feature),u.depth&&(d+="-"+u.depth.join("-")),d in e||(e[d]={}),0===r[1]?(e[d].right=u,e[d].index=u.index):1==r[1]&&(e[d].left=u,e[d].index=u.index+1);for(d in e){switch(c=e[d].right,l=e[d].left,a=e[d].index,h=a-1,u=void 0!==l?l:c,h<0&&(h=0),s=u.geometry,n=s.getCoordinates(),i=n,g=!1,s.getType()){case"MultiLineString":n[u.depth[0]].length>2&&(n[u.depth[0]].splice(a,1),g=!0);break;case"LineString":n.length>2&&(n.splice(a,1),g=!0);break;case"MultiPolygon":i=i[u.depth[1]];case"Polygon":i=i[u.depth[0]],i.length>4&&(a==i.length-1&&(a=0),i.splice(a,1),g=!0,0===a&&(i.pop(),i.push(i[0]),h=i.length-1))}if(g){this.setGeometryCoordinates_(s,n);const e=[];if(void 0!==l&&(this.rBush_.remove(l),e.push(l.segment[0])),void 0!==c&&(this.rBush_.remove(c),e.push(c.segment[1])),void 0!==l&&void 0!==c){const t={depth:u.depth,feature:u.feature,geometry:u.geometry,index:h,segment:e};this.rBush_.insert(Kt(t.segment),t)}this.updateSegmentIndices_(s,a,u.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return g}canInsertPoint(){if(!this.vertexFeature_)return!1;if(this.vertexFeature_.get("geometries").every((t=>"Circle"===t.getType()||t.getType().endsWith("Point"))))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Kt([t])).some((({segment:e})=>!(bi(e[0],t)||bi(e[1],t))))}insertPoint(t){const e=t?qn(t,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();if(!e)return!1;return this.findInsertVerticesAndUpdateDragSegments_(e).reduce(((t,i)=>t||this.insertVertex_(i,e)),!1)}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||c(r.depth,i))&&r.index>e&&(r.index+=n)}))}},FS.interaction.Modify.ModifyEvent=g_,FS.interaction.MouseWheelZoom=Cc,FS.interaction.PinchRotate=Rc,FS.interaction.PinchZoom=bc,FS.interaction.Pointer=Yh,FS.interaction.Pointer.centroid=Zh,FS.interaction.Select=w_,FS.interaction.Select.SelectEvent=x_,FS.interaction.Snap=class extends Yh{constructor(t){const e=t=t||{};e.handleDownEvent||(e.handleDownEvent=d),e.stopDown||(e.stopDown=g),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 ad,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=U(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(Kt(r[0]),{feature:t,segment:r[0]});else if(r.length>1){const e=r.map((t=>Kt(t))),i=r.map((e=>({feature:t,segment:e})));this.rBush_.load(e,i)}}}e&&(this.featureChangeListenerKeys_[i]=A(t,v,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 S_(E_,{vertex:t.coordinate,vertexPixel:t.pixel,feature:e.feature,segment:e.segment}))),super.handleEvent(t)}handleFeatureAdd_(t){const e=T_(t);e&&this.addFeature(e)}handleFeatureRemove_(t){const e=T_(t);e&&this.removeFeature(e)}handleFeatureChange_(t){const e=t.target;if(this.handlingDownUpSequence){const t=U(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=U(t),r=this.indexedFeaturesExtents_[n];if(r){const e=this.rBush_,i=[];e.forEachInExtent(r,(function(e){t===e.feature&&i.push(e)}));for(let t=i.length-1;t>=0;--t)e.remove(i[t])}i&&(D(this.featureChangeListenerKeys_[n]),delete this.featureChangeListenerKeys_[n])}setMap(t){const e=this.getMap(),i=this.featuresListenerKeys_,n=this.getFeatures_();e&&(i.forEach(D),i.length=0,this.rBush_.clear(),Object.values(this.featureChangeListenerKeys_).forEach(D),this.featureChangeListenerKeys_={}),super.setMap(t),t&&(this.features_?i.push(A(this.features_,X,this.handleFeatureAdd_,this),A(this.features_,V,this.handleFeatureRemove_,this)):this.source_&&i.push(A(this.source_,Sd,this.handleFeatureAdd_,this),A(this.source_,Rd,this.handleFeatureRemove_,this)),n.forEach((t=>this.addFeature(t))))}snapTo(t,e,i){const n=i.getView().getProjection(),r=qn(e,n),s=$n(Ht(Kt([r]),i.getView().getResolution()*this.pixelTolerance_),n),o=this.rBush_.getInExtent(s),a=o.length;if(0===a)return null;let l,h,c=1/0,u=null;const d=this.pixelTolerance_*this.pixelTolerance_,g=()=>{if(l){const e=i.getPixelFromCoordinate(l);if(Mi(t,e)<=d)return{vertex:l,vertexPixel:[Math.round(e[0]),Math.round(e[1])],feature:h,segment:u}}return null};if(this.vertex_){for(let t=0;t{const i=qn(t,n),s=Mi(r,i);s{t.push([e])}))}segmentMultiPolygonGeometry_(t,e){const i=e.getCoordinates();for(let e=0,n=i.length;e{if(t instanceof It&&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")}}},FS.interaction.Translate.TranslateEvent=F_,FS.interaction.defaults={},FS.interaction.defaults.defaults=Pc,FS.layer={},FS.layer.Base=Us,FS.layer.BaseImage=Pg,FS.layer.BaseTile=Gg,FS.layer.BaseVector=ah,FS.layer.Graticule=class extends Mp{constructor(t){t=t||{};const e=Object.assign({updateWhileAnimating:!0,updateWhileInteracting:!0,renderBuffer:0},t);delete e.maxLines,delete e.strokeStyle,delete e.targetSize,delete e.showLabels,delete e.lonLabelFormatter,delete e.latLabelFormatter,delete e.lonLabelPosition,delete e.latLabelPosition,delete e.lonLabelStyle,delete e.latLabelStyle,delete e.intervals,super(e),this.projection_=null,this.maxLat_=1/0,this.maxLon_=1/0,this.minLat_=-1/0,this.minLon_=-1/0,this.maxX_=1/0,this.maxY_=1/0,this.minX_=-1/0,this.minY_=-1/0,this.targetSize_=void 0!==t.targetSize?t.targetSize:100,this.maxLines_=void 0!==t.maxLines?t.maxLines:100,this.meridians_=[],this.parallels_=[],this.strokeStyle_=void 0!==t.strokeStyle?t.strokeStyle:Op,this.fromLonLatTransform_=void 0,this.toLonLatTransform_=void 0,this.projectionCenterLonLat_=null,this.bottomLeft_=null,this.bottomRight_=null,this.topLeft_=null,this.topRight_=null,this.meridiansLabels_=null,this.parallelsLabels_=null,t.showLabels&&(this.lonLabelFormatter_=null==t.lonLabelFormatter?Ci.bind(this,"EW"):t.lonLabelFormatter,this.latLabelFormatter_=null==t.latLabelFormatter?Ci.bind(this,"NS"):t.latLabelFormatter,this.lonLabelPosition_=null==t.lonLabelPosition?0:t.lonLabelPosition,this.latLabelPosition_=null==t.latLabelPosition?1:t.latLabelPosition,this.lonLabelStyleBase_=new Ha({text:void 0!==t.lonLabelStyle?t.lonLabelStyle.clone():new nl({font:"12px Calibri,sans-serif",textBaseline:"bottom",fill:new Za({color:"rgba(0,0,0,1)"}),stroke:new Ka({color:"rgba(255,255,255,1)",width:3})})}),this.lonLabelStyle_=t=>{const e=t.get("graticule_label");return this.lonLabelStyleBase_.getText().setText(e),this.lonLabelStyleBase_},this.latLabelStyleBase_=new Ha({text:void 0!==t.latLabelStyle?t.latLabelStyle.clone():new nl({font:"12px Calibri,sans-serif",textAlign:"right",fill:new Za({color:"rgba(0,0,0,1)"}),stroke:new Ka({color:"rgba(255,255,255,1)",width:3})})}),this.latLabelStyle_=t=>{const e=t.get("graticule_label");return this.latLabelStyleBase_.getText().setText(e),this.latLabelStyleBase_},this.meridiansLabels_=[],this.parallelsLabels_=[],this.addEventListener(zs,this.drawLabels_.bind(this))),this.intervals_=void 0!==t.intervals?t.intervals:Dp,this.setSource(new Ld({loader:this.loaderFunction.bind(this),strategy:this.strategyFunction.bind(this),features:new Z,overlaps:!1,useSpatialIndex:!1,wrapX:t.wrapX})),this.featurePool_=[],this.lineStyle_=new Ha({stroke:this.strokeStyle_}),this.loadedExtent_=null,this.renderedExtent_=null,this.renderedResolution_=null,this.setRenderOrder(null)}strategyFunction(t,e){let i=t.slice();return this.projection_&&this.getSource().getWrapX()&&Oe(i,this.projection_),this.loadedExtent_&&(le(this.loadedExtent_,i,e)?i=this.loadedExtent_.slice():this.getSource().removeLoadedExtent(this.loadedExtent_)),[i]}loaderFunction(t,e,i){this.loadedExtent_=t;const n=this.getSource(),r=Te(this.getExtent()||[-1/0,-1/0,1/0,1/0],t);if(this.renderedExtent_&&ae(this.renderedExtent_,r)&&this.renderedResolution_===e)return;if(this.renderedExtent_=r,this.renderedResolution_=e,Fe(r))return;const s=xe(r),o=e*e/4;(!this.projection_||!Un(this.projection_,i))&&this.updateProjectionInfo_(i),this.createGraticule_(r,s,e,o);let a,l=this.meridians_.length+this.parallels_.length;for(this.meridiansLabels_&&(l+=this.meridians_.length),this.parallelsLabels_&&(l+=this.parallels_.length);l>this.featurePool_.length;)a=new It,this.featurePool_.push(a);const h=n.getFeaturesCollection();h.clear();let c,u,d=0;for(c=0,u=this.meridians_.length;cMath.PI/2}const d=fu(t);for(let t=a;t<=l;++t){let i,n,c,g,f=this.meridians_.length+this.parallels_.length;if(this.meridiansLabels_)for(n=0,c=this.meridiansLabels_.length;n=a?(t[0]=o[0],t[2]=o[2]):s=!0);const l=[ai(e[0],this.minX_,this.maxX_),ai(e[1],this.minY_,this.maxY_)],h=this.toLonLatTransform_(l);isNaN(h[1])&&(h[1]=Math.abs(this.maxLat_)>=Math.abs(this.minLat_)?this.maxLat_:this.minLat_);let c=ai(h[0],this.minLon_,this.maxLon_),u=ai(h[1],this.minLat_,this.maxLat_);const d=this.maxLines_;let g,f,p,m,_=t;s||(_=[ai(t[0],this.minX_,this.maxX_),ai(t[1],this.minY_,this.maxY_),ai(t[2],this.minX_,this.maxX_),ai(t[3],this.minY_,this.maxY_)]);const y=Ae(_,this.toLonLatTransform_,void 0,8);let x=y[3],v=y[2],w=y[1],E=y[0];if(s||(Jt(_,this.bottomLeft_)&&(E=this.minLon_,w=this.minLat_),Jt(_,this.bottomRight_)&&(v=this.maxLon_,w=this.minLat_),Jt(_,this.topLeft_)&&(E=this.minLon_,x=this.maxLat_),Jt(_,this.topRight_)&&(v=this.maxLon_,x=this.maxLat_),x=ai(x,u,this.maxLat_),v=ai(v,c,this.maxLon_),w=ai(w,this.minLat_,u),E=ai(E,this.minLon_,c)),c=Math.floor(c/r)*r,m=ai(c,this.minLon_,this.maxLon_),f=this.addMeridian_(m,w,x,n,t,0),g=0,s)for(;(m-=r)>=E&&g++n[s]&&(r=s,s=1);const o=Math.max(e[1],n[r]),a=Math.min(e[3],n[s]),l=ai(e[1]+Math.abs(e[1]-e[3])*this.lonLabelPosition_,o,a),h=[n[r-1]+(n[s-1]-n[r-1])*(l-n[r])/(n[s]-n[r]),l],c=this.meridiansLabels_[i].geom;return c.setCoordinates(h),c}getMeridians(){return this.meridians_}getParallel_(t,e,i,n,r){const s=Ap(t,e,i,this.projection_,n);let o=this.parallels_[r];return o?(o.setFlatCoordinates("XY",s),o.changed()):o=new pd(s,"XY"),o}getParallelPoint_(t,e,i){const n=t.getFlatCoordinates();let r=0,s=n.length-2;n[r]>n[s]&&(r=s,s=0);const o=Math.max(e[0],n[r]),a=Math.min(e[2],n[s]),l=ai(e[0]+Math.abs(e[0]-e[2])*this.latLabelPosition_,o,a),h=[l,n[r+1]+(n[s+1]-n[r+1])*(l-n[r])/(n[s]-n[r])],c=this.parallelsLabels_[i].geom;return c.setCoordinates(h),c}getParallels(){return this.parallels_}updateProjectionInfo_(t){const e=In("EPSG:4326"),i=t.getWorldExtent();this.maxLat_=i[3],this.maxLon_=i[2],this.minLat_=i[1],this.minLon_=i[0];const n=Xn(t,e);if(this.minLon_=Math.abs(this.minLat_)?this.maxLat_:this.minLat_),this.projection_=t}},FS.layer.Group=fh,FS.layer.Group.GroupEvent=dh,FS.layer.Heatmap=class extends ah{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(Dm,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:km),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(Om)}getGradient(){return this.get(Dm)}getRadius(){return this.get(Nm)}handleGradientChanged_(){this.gradient_=function(t){const e=1,i=256,n=pt(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?ai(e,0,1):1}}],uniforms:{u_size:()=>2*(this.get(Nm)+this.get(Om)),u_blurSlope:()=>this.get(Nm)/Math.max(1,this.get(Om))},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(){}},FS.layer.Image=Dg,FS.layer.Layer=mo,FS.layer.Layer.inView=_o,FS.layer.Tile=Vg,FS.layer.Vector=Mp,FS.layer.VectorImage=class extends ah{constructor(t){t=t||{};const e=Object.assign({},t);delete e.imageRatio,super(e),this.imageRatio_=void 0!==t.imageRatio?t.imageRatio:1}getImageRatio(){return this.imageRatio_}createRenderer(){return new Rp(this)}},FS.loadingstrategy={},FS.loadingstrategy.all=Qc,FS.loadingstrategy.bbox=function(t,e){return[t]},FS.loadingstrategy.tile=function(t){return function(e,i,n){const r=t.getZForResolution(tr(i,n)),s=t.getTileRangeForExtentAndZ(Jn(e,n),r),o=[],a=[r,0,0];for(a[1]=s.minX;a[1]<=s.maxX;++a[1])for(a[2]=s.minY;a[2]<=s.maxY;++a[2])o.push($n(t.getTileCoordExtent(a),n));return o}},FS.math={},FS.math.ceil=yi,FS.math.clamp=ai,FS.math.floor=_i,FS.math.lerp=fi,FS.math.modulo=gi,FS.math.round=mi,FS.math.solveLinearSystem=ci,FS.math.squaredDistance=hi,FS.math.squaredSegmentDistance=li,FS.math.toDegrees=ui,FS.math.toFixed=pi,FS.math.toRadians=di,FS.math.wrap=xi,FS.net={},FS.net.ClientError=iu,FS.net.ResponseError=eu,FS.net.getJSON=nu,FS.net.jsonp=tu,FS.net.overrideXHR=function(t){"undefined"!=typeof XMLHttpRequest&&(Hc=XMLHttpRequest),global.XMLHttpRequest=t},FS.net.resolveUrl=ru,FS.net.restoreXHR=function(){global.XMLHttpRequest=Hc},FS.obj={},FS.obj.clear=_,FS.obj.isEmpty=y,FS.proj={},FS.proj.Projection=Ge,FS.proj.Units={},FS.proj.Units.METERS_PER_UNIT=ke,FS.proj.Units.fromCode=function(t){return Ne[t]},FS.proj.addCommon=ir,FS.proj.addCoordinateTransforms=Gn,FS.proj.addEquivalentProjections=On,FS.proj.addEquivalentTransforms=Dn,FS.proj.addProjection=Mn,FS.proj.addProjections=Ln,FS.proj.clearAllProjections=function(){ti(),ri()},FS.proj.clearUserProjection=function(){Yn=null},FS.proj.cloneTransform=Pn,FS.proj.createProjection=Nn,FS.proj.createSafeCoordinateTransform=er,FS.proj.createTransformFromCoordinateTransform=kn,FS.proj.disableCoordinateWarning=bn,FS.proj.epsg3857={},FS.proj.epsg3857.EXTENT=Be,FS.proj.epsg3857.HALF_SIZE=Ue,FS.proj.epsg3857.MAX_SAFE_Y=Xe,FS.proj.epsg3857.PROJECTIONS=We,FS.proj.epsg3857.RADIUS=je,FS.proj.epsg3857.WORLD_EXTENT=ze,FS.proj.epsg3857.fromEPSG4326=Ye,FS.proj.epsg3857.toEPSG4326=Ze,FS.proj.epsg4326={},FS.proj.epsg4326.EXTENT=He,FS.proj.epsg4326.METERS_PER_UNIT=qe,FS.proj.epsg4326.PROJECTIONS=Je,FS.proj.epsg4326.RADIUS=Ke,FS.proj.equivalent=Un,FS.proj.fromLonLat=function(t,e){return bn(),Vn(t,"EPSG:4326",void 0!==e?e:"EPSG:3857")},FS.proj.fromUserCoordinate=qn,FS.proj.fromUserExtent=Jn,FS.proj.fromUserResolution=tr,FS.proj.get=In,FS.proj.getPointResolution=An,FS.proj.getTransform=Xn,FS.proj.getTransformFromProjections=Bn,FS.proj.getUserProjection=Kn,FS.proj.identityTransform=Fn,FS.proj.proj4={},FS.proj.proj4.epsgLookupMapTiler=function(t){return async function(e){const i=await fetch(`https://api.maptiler.com/coordinates/search/code:${e}.json?transformations=true&exports=true&key=${t}`);if(!i.ok)throw new Error(`Unexpected response from maptiler.com: ${i.status}`);return i.json().then((t=>{const i=t.results;if(i?.length>0){const t=i.filter((t=>"EPSG"===t.id?.authority&&t.id?.code===e))[0];if(t){const e=t.transformations;if(e?.length>0){const i=t.default_transformation;if(e.filter((t=>t.id?.authority===i?.authority&&t.id?.code===i?.code&&0===t.grids?.length)).length>0)return t.exports?.proj4;const n=e.filter((t=>0===t.grids?.length&&"EPSG"===t.target_crs?.authority&&4326===t.target_crs?.code&&!1===t.deprecated&&!0===t.usable)).sort(((t,e)=>t.accuracy-e.accuracy))[0]?.exports?.proj4;if(n)return n}return t.exports?.proj4}}}))}},FS.proj.proj4.fromEPSGCode=async function(t){"string"==typeof t&&(t=parseInt(t.split(":").pop(),10));const e=bp;if(!e)throw new Error("Proj4 must be registered first with register(proj4)");const i="EPSG:"+t;return e.defs(i)||(e.defs(i,await Fp(t)),Pp(e)),ei(i)},FS.proj.proj4.getEPSGLookup=function(){return Fp},FS.proj.proj4.isRegistered=function(){return!!bp},FS.proj.proj4.register=Pp,FS.proj.proj4.setEPSGLookup=function(t){Fp=t},FS.proj.proj4.unregister=function(){bp=null},FS.proj.projections={},FS.proj.projections.add=ii,FS.proj.projections.clear=ti,FS.proj.projections.get=ei,FS.proj.setUserProjection=Zn,FS.proj.toLonLat=jn,FS.proj.toUserCoordinate=Hn,FS.proj.toUserExtent=$n,FS.proj.toUserResolution=Qn,FS.proj.transform=Vn,FS.proj.transformExtent=Wn,FS.proj.transformWithProjections=function(t,e,i){return Bn(e,i)(t)},FS.proj.transforms={},FS.proj.transforms.add=si,FS.proj.transforms.clear=ri,FS.proj.transforms.get=oi,FS.proj.transforms.remove=function(t,e){const i=t.getCode(),n=e.getCode(),r=ni[i][n];return delete ni[i][n],y(ni[i])&&delete ni[i],r},FS.proj.useGeographic=function(){Zn("EPSG:4326")},FS.proj.utm={},FS.proj.utm.makeProjection=yn,FS.proj.utm.makeTransforms=xn,FS.proj.utm.zoneFromCode=mn,FS.render={},FS.render.Box=uc,FS.render.Event=ch,FS.render.Feature=wd,FS.render.Feature.toFeature=function(t,e){const i=t.getId(),n=Ed(t),r=t.getProperties(),s=new It;return void 0!==e&&s.setGeometryName(e),s.setGeometry(n),void 0!==i&&s.setId(i),s.setProperties(r,!0),s},FS.render.Feature.toGeometry=Ed,FS.render.VectorContext=su,FS.render.canvas={},FS.render.canvas.Builder=Hf,FS.render.canvas.BuilderGroup=rp,FS.render.canvas.Executor=pp,FS.render.canvas.ExecutorGroup=xp,FS.render.canvas.ExecutorGroup.ALL=mp,FS.render.canvas.ExecutorGroup.DECLUTTER=_p,FS.render.canvas.ExecutorGroup.NON_DECLUTTER=yp,FS.render.canvas.ExecutorGroup.getPixelIndexArray=wp,FS.render.canvas.ImageBuilder=qf,FS.render.canvas.Immediate=ou,FS.render.canvas.Instruction={},FS.render.canvas.Instruction.beginPathInstruction=Zf,FS.render.canvas.Instruction.closePathInstruction=Kf,FS.render.canvas.Instruction.fillInstruction=Wf,FS.render.canvas.Instruction.strokeInstruction=Yf,FS.render.canvas.LineStringBuilder=$f,FS.render.canvas.PolygonBuilder=Jf,FS.render.canvas.TextBuilder=ip,FS.render.canvas.TextBuilder.TEXT_ALIGN=ep,FS.render.canvas.ZIndexContext=Mg,FS.render.canvas.checkedFonts=Oa,FS.render.canvas.defaultFillStyle=Ca,FS.render.canvas.defaultFont=Ta,FS.render.canvas.defaultLineCap=Ra,FS.render.canvas.defaultLineDash=ba,FS.render.canvas.defaultLineDashOffset=0,FS.render.canvas.defaultLineJoin=Pa,FS.render.canvas.defaultLineWidth=1,FS.render.canvas.defaultMiterLimit=Fa,FS.render.canvas.defaultPadding=Aa,FS.render.canvas.defaultStrokeStyle=Ma,FS.render.canvas.defaultTextAlign=La,FS.render.canvas.defaultTextBaseline=Ia,FS.render.canvas.drawImageOrLabel=Va,FS.render.canvas.getTextDimensions=Xa,FS.render.canvas.hitdetect={},FS.render.canvas.hitdetect.HIT_DETECT_RESOLUTION=Ep,FS.render.canvas.hitdetect.createHitDetectionImageData=Sp,FS.render.canvas.hitdetect.hitDetect=Tp,FS.render.canvas.measureAndCacheTextWidth=za,FS.render.canvas.measureTextHeight=ja,FS.render.canvas.measureTextWidth=Ba,FS.render.canvas.registerFont=Ga,FS.render.canvas.rotateAtOffset=function(t,e,i,n){0!==e&&(t.translate(i,n),t.rotate(e),t.translate(-i,-n))},FS.render.canvas.style={},FS.render.canvas.style.buildRuleSet=jl,FS.render.canvas.style.buildStyle=Ul,FS.render.canvas.style.flatStylesToStyleFunction=Gl,FS.render.canvas.style.rulesToStyleFunction=kl,FS.render.canvas.textHeights=ka,FS.render.getRenderPixel=function(t,e){return jt(t.inversePixelTransform,e.slice(0))},FS.render.getVectorContext=fu,FS.render.toContext=function(t,e){const i=t.canvas,n=(e=e||{}).pixelRatio||ct,r=e.size;r&&(i.width=r[0]*n,i.height=r[1]*n,i.style.width=r[0]+"px",i.style.height=r[1]+"px");const s=[0,0,i.width,i.height],o=Ut([1,0,0,1,0,0],n,n);return new ou(t,n,s,o,0)},FS.renderer={},FS.renderer.Composite=uh,FS.renderer.Layer=Fg,FS.renderer.Map=lh,FS.renderer.canvas={},FS.renderer.canvas.ImageLayer=Og,FS.renderer.canvas.Layer=Ag,FS.renderer.canvas.Layer.canvasPool=Lg,FS.renderer.canvas.TileLayer=Xg,FS.renderer.canvas.VectorImageLayer=Rp,FS.renderer.canvas.VectorLayer=Cp,FS.renderer.vector={},FS.renderer.vector.defaultOrder=hu,FS.renderer.vector.getSquaredTolerance=cu,FS.renderer.vector.getTolerance=uu,FS.renderer.vector.renderFeature=du,FS.reproj={},FS.reproj.DataTile=Wd,FS.reproj.Image=Zd,FS.reproj.Tile=Cu,FS.reproj.Triangulation=Tu,FS.reproj.calculateSourceExtentResolution=vu,FS.reproj.calculateSourceResolution=xu,FS.reproj.canvasPool=mu,FS.reproj.common={},FS.reproj.common.ERROR_THRESHOLD=Su,FS.reproj.glreproj={},FS.reproj.glreproj.canvasGLPool=Xd,FS.reproj.glreproj.createCanvasContextWebGL=Bd,FS.reproj.glreproj.releaseGLCanvas=zd,FS.reproj.glreproj.render=Vd,FS.reproj.render=wu,FS.resolution={},FS.resolution.fromResolutionLike=Eu,FS.resolutionconstraint={},FS.resolutionconstraint.createMinMaxResolution=no,FS.resolutionconstraint.createSnapToPower=io,FS.resolutionconstraint.createSnapToResolutions=eo,FS.rotationconstraint={},FS.rotationconstraint.createSnapToN=oo,FS.rotationconstraint.createSnapToZero=ao,FS.rotationconstraint.disable=ro,FS.rotationconstraint.none=so,FS.size={},FS.size.buffer=function(t,e,i){return void 0===i&&(i=[0,0]),i[0]=t[0]+2*e,i[1]=t[1]+2*e,i},FS.size.hasArea=ca,FS.size.scale=ua,FS.size.toSize=da,FS.source={},FS.source.BingMaps=class extends nd{constructor(t){const e=void 0!==t.hidpi&&t.hidpi;super({cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,projection:In("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=Bu(this.getProjection()),r=this.hidpi_?2:1,s=e.imageWidth==e.imageHeight?e.imageWidth/r:[e.imageWidth/r,e.imageHeight/r],o=Gu({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=td(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;jc(t[0],t[1],t[2],i);const s=new URL(n.replace("{quadkey}",sd(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=Bn(In("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(Pe(Ae([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")}},FS.source.BingMaps.quadKey=sd,FS.source.Cluster=class extends Ld{constructor(t){super({attributions:(t=t||{}).attributions,wrapX:t.wrapX}),this.resolution=void 0,this.distance=void 0!==t.distance?t.distance:20,this.minDistance=t.minDistance||0,this.interpolationRatio=0,this.features=[],this.geometryFunction=t.geometryFunction||function(t){const e=t.getGeometry();return Lt(!e||"Point"===e.getType(),"The default `geometryFunction` can only handle `Point` or null geometries"),e},this.createCustomCluster_=t.createCluster,this.source=null,this.boundRefresh_=this.refresh.bind(this),this.updateDistance(this.distance,this.minDistance),this.setSource(t.source||null)}clear(t){this.features.length=0,super.clear(t)}getDistance(){return this.distance}getSource(){return this.source}loadFeatures(t,e,i){this.source?.loadFeatures(t,e,i),e!==this.resolution&&(this.resolution=e,this.refresh())}setDistance(t){this.updateDistance(t,this.minDistance)}setMinDistance(t){this.updateDistance(this.distance,t)}getMinDistance(){return this.minDistance}setSource(t){this.source&&this.source.removeEventListener(v,this.boundRefresh_),this.source=t,t&&t.addEventListener(v,this.boundRefresh_),this.refresh()}refresh(){this.clear(),this.cluster(),this.addFeatures(this.features)}updateDistance(t,e){const i=0===t?0:Math.min(e,t)/t,n=t!==this.distance||this.interpolationRatio!==i;this.distance=t,this.minDistance=e,this.interpolationRatio=i,n&&this.refresh()}cluster(){if(void 0===this.resolution||!this.source)return;const t=[1/0,1/0,-1/0,-1/0],e=this.distance*this.resolution,i=this.source.getFeatures(),n={};for(let r=0,s=i.length;r=0;--e){const n=this.geometryFunction(t[e]);n?Ei(i,n.getCoordinates()):t.splice(e,1)}Fi(i,1/t.length);const n=xe(e),r=this.interpolationRatio,s=new Gr([i[0]*(1-r)+n[0]*r,i[1]*(1-r)+n[1]*r]);return this.createCustomCluster_?this.createCustomCluster_(s,t):new It({geometry:s,features:t})}},FS.source.DataTile=Yd,FS.source.Google=class extends nd{constructor(t){const e=!!t.highDpi;super({attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,projection:"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.apiKey_=t.key,this.error_=null;const i={mapType:t.mapType||"roadmap",language:t.language||"en-US",region:t.region||"US"};t.imageFormat&&(i.imageFormat=t.imageFormat),t.scale&&(i.scale=t.scale),e&&(i.highDpi=!0),t.layerTypes&&(i.layerTypes=t.layerTypes),t.styles&&(i.styles=t.styles),!0===t.overlay&&(i.overlay=!0),t.apiOptions&&(i.apiOptions=t.apiOptions),this.sessionTokenRequest_=i,this.sessionTokenValue_,this.sessionRefreshId_,this.previousViewportAttribution_,this.previousViewportExtent_,this.createSession_()}getError(){return this.error_}fetchSessionToken(t,e){return fetch(t,e)}async createSession_(){const t="https://tile.googleapis.com/v1/createSession?key="+this.apiKey_,e={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.sessionTokenRequest_)},i=await this.fetchSessionToken(t,e);if(!i.ok){try{const t=await i.json();this.error_=new Error(t.error.message)}catch{this.error_=new Error("Error fetching session token")}return void this.setState("error")}const n=await i.json(),r=this.getTilePixelRatio(1),s=[n.tileWidth/r,n.tileHeight/r];this.tileGrid=Gu({extent:Bu(this.getProjection()),maxZoom:22,tileSize:s});const o=n.session;this.sessionTokenValue_=o;const a=this.apiKey_;this.tileUrlFunction=function(t,e,i){return`https://tile.googleapis.com/v1/2dtiles/${t[0]}/${t[1]}/${t[2]}?session=${o}&key=${a}`};const l=1e3*parseInt(n.expiry,10),h=Math.max(l-Date.now()-6e4,1);this.sessionRefreshId_=setTimeout((()=>this.createSession_()),h),this.setAttributions(this.fetchAttributions_.bind(this)),this.setState("ready")}async fetchAttributions_(t){if(t.viewHints[Ys]||t.viewHints[Zs]||t.animate)return this.previousViewportAttribution_;const[e,i]=jn(_e(t.extent),t.viewState.projection),[n,r]=jn(Re(t.extent),t.viewState.projection),s=`zoom=${this.getTileGrid().getZForResolution(t.viewState.resolution,this.zDirection)}&north=${r}&south=${i}&east=${n}&west=${e}`;if(this.previousViewportExtent_==s)return this.previousViewportAttribution_;this.previousViewportExtent_=s;const o=`https://tile.googleapis.com/tile/v1/viewport?session=${this.sessionTokenValue_}&key=${this.apiKey_}&${s}`;return this.previousViewportAttribution_=await fetch(o).then((t=>t.json())).then((t=>t.copyright)),this.previousViewportAttribution_}disposeInternal(){clearTimeout(this.sessionRefreshId_),super.disposeInternal()}},FS.source.Image=Qd,FS.source.Image.ImageSourceEvent=Jd,FS.source.Image.defaultImageLoadFunction=tg,FS.source.Image.getRequestExtent=eg,FS.source.ImageArcGISRest=class extends Qd{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.hidpi_=void 0===t.hidpi||t.hidpi,this.url_=t.url,this.imageLoadFunction_=void 0!==t.imageLoadFunction?t.imageLoadFunction:tg,this.params_=Object.assign({},t.params),this.imageSize_=[0,0],this.renderedRevision_=0,this.ratio_=void 0!==t.ratio?t.ratio:1.5,this.loaderProjection_=null}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=ng({crossOrigin:this.crossOrigin_,params:this.params_,projection:n,hidpi:this.hidpi_,url:this.url_,ratio:this.ratio_,load:(t,e)=>(this.image.setImage(t),this.imageLoadFunction_(this.image,e),Rs(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()}},FS.source.ImageCanvas=class extends Qd{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions,state:t.state}),this.canvasFunction_=t.canvasFunction,this.canvas_=null,this.renderedRevision_=0,this.ratio_=void 0!==t.ratio?t.ratio:1.5}getImageInternal(t,e,i,n){e=this.findNearestResolution(e);let r=this.canvas_;if(r&&this.renderedRevision_==this.getRevision()&&r.getResolution()==e&&r.getPixelRatio()==i&&Qt(r.getExtent(),t))return r;Le(t=t.slice(),this.ratio_);const s=[be(t)/e*i,Se(t)/e*i],o=this.canvasFunction_.call(this,t,e,i,s,n);return o&&(r=new bs(t,e,i,o)),this.canvas_=r,this.renderedRevision_=this.getRevision(),r}},FS.source.ImageStatic=class extends Qd{constructor(t){const e=void 0!==t.crossOrigin?t.crossOrigin:null,i=void 0!==t.imageLoadFunction?t.imageLoadFunction:tg;super({attributions:t.attributions,interpolate:t.interpolate,projection:In(t.projection)}),this.url_=t.url,this.imageExtent_=t.imageExtent,this.image=null,this.image=new Es(this.imageExtent_,void 0,1,rg({url:t.url,imageExtent:t.imageExtent,crossOrigin:e,load:(t,e)=>(this.image.setImage(t),i(this.image,e),Rs(t))})),this.image.addEventListener(v,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(t,e,i,n){return Pe(t,this.image.getExtent())?this.image:null}getUrl(){return this.url_}},FS.source.ImageTile=ug,FS.source.ImageWMS=class extends Qd{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:tg,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=In(i),s=this.getProjection();s&&s!==r&&(e=xu(s,r,t,e),t=Vn(t,r,s));return yg({url:this.url_,params:{...this.params_,...n},projection:s||r},t,e)}getLegendUrl(t,e){return xg({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=_g({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),Rs(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()}},FS.source.OGCMapTile=class extends nd{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:t.projection,reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition});Rg({url:t.url,projection:this.getProjection(),mediaType:t.mediaType,context:t.context||null,collections:t.collections}).then(this.handleTileSetInfo_.bind(this)).catch(this.handleError_.bind(this))}handleTileSetInfo_(t){this.tileGrid=t.grid,this.projection=t.projection,this.setTileUrlFunction(t.urlFunction,t.urlTemplate),this.setState("ready")}handleError_(t){Sn(t),this.setState("error")}},FS.source.OSM=class extends od{constructor(t){let e;e=void 0!==(t=t||{}).attributions?t.attributions:[bg];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})}},FS.source.OSM.ATTRIBUTION=bg,FS.source.Raster=$g,FS.source.Raster.Processor=Zg,FS.source.Raster.RasterSourceEvent=qg,FS.source.Source=Fu,FS.source.StadiaMaps=class extends od{constructor(t){const e=t.layer.indexOf("-"),i=-1==e?t.layer:t.layer.slice(0,e),n=nf[i]||{minZoom:0,maxZoom:20,retina:!0},r=ef[t.layer],s=t.apiKey?"?api_key="+t.apiKey:"",o=n.retina&&t.retina?"@2x":"",a=void 0!==t.url?t.url:"https://tiles.stadiamaps.com/tiles/"+t.layer+"/{z}/{x}/{y}"+o+"."+r.extension+s,l=['© Stadia Maps','© OpenMapTiles',bg];t.layer.startsWith("stamen_")&&l.splice(1,0,'© Stamen Design'),super({attributions:l,cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,maxZoom:void 0!==t.maxZoom?t.maxZoom:n.maxZoom,minZoom:void 0!==t.minZoom?t.minZoom:n.minZoom,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:a,tilePixelRatio:o?2:1,wrapX:t.wrapX,zDirection:t.zDirection})}},FS.source.Tile=zu,FS.source.Tile.TileSourceEvent=Xu,FS.source.TileArcGISRest=class extends nd{constructor(t){super({attributions:(t=t||{}).attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:t.projection,reprojectionErrorThreshold:t.reprojectionErrorThreshold,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.params_=Object.assign({},t.params),this.hidpi_=void 0===t.hidpi||t.hidpi,this.tmpExtent_=[1/0,1/0,-1/0,-1/0],this.setKey(this.getKeyForParams_())}getKeyForParams_(){let t=0;const e=[];for(const i in this.params_)e[t++]=i+"-"+this.params_[i];return e.join("/")}getParams(){return this.params_}getRequestUrl_(t,e,i,n,r,s){const o=this.urls;if(!o)return;let a;if(1==o.length)a=o[0];else{a=o[gi(Xc(t),o.length)]}return ig(a,i,(this.tileGrid||this.getTileGridForProjection(r)).getResolution(t[0]),n,r,s)}getTilePixelRatio(t){return this.hidpi_?t:1}updateParams(t){Object.assign(this.params_,t),this.setKey(this.getKeyForParams_())}tileUrlFunction(t,e,i){let n=this.getTileGrid();if(n||(n=this.getTileGridForProjection(i)),n.getResolutions().length<=t[0])return;1==e||this.hidpi_||(e=1);const r=n.getTileCoordExtent(t,this.tmpExtent_);let s=da(n.getTileSize(t[0]),this.tmpSize);1!=e&&(s=ua(s,e,this.tmpSize));const o={F:"image",FORMAT:"PNG32",TRANSPARENT:!0};return Object.assign(o,this.params_),this.getRequestUrl_(t,s,r,e,i,o)}},FS.source.TileDebug=class extends ug{constructor(t){const e=(t=t||{}).template||"z:{z} x:{x} y:{y}",i=t.source;super({transition:0,wrapX:void 0!==t.wrapX?t.wrapX:void 0!==i?i.getWrapX():void 0});const n=()=>{this.projection=void 0!==t.projection?In(t.projection):void 0!==i?i.getProjection():this.projection,this.tileGrid=void 0!==t.tileGrid?t.tileGrid:void 0!==i?i.getTileGrid():this.tileGrid,this.zDirection=void 0!==t.zDirection?t.zDirection:void 0!==i?i.zDirection:this.zDirection,i instanceof Yd&&(this.transformMatrix=i.transformMatrix?.slice()||null);const n=this.tileGrid;n&&this.setTileSizes(n.getResolutions().map(((t,e)=>da(n.getTileSize(e)).map((t=>Math.max(Math.floor(t),1)))))),this.setLoader(((t,i,n,r)=>{const s=Hu(e,t,i,n,r.maxY),[o,a]=this.getTileSize(t),l=pt(o,a);return l.strokeStyle="grey",l.strokeRect(.5,.5,o+.5,a+.5),l.fillStyle="grey",l.strokeStyle="white",l.textAlign="center",l.textBaseline="middle",l.font="24px sans-serif",l.lineWidth=4,l.strokeText(s,o/2,a/2,o),l.fillText(s,o/2,a/2,o),l.canvas})),this.setState("ready")};if(void 0===i||"ready"===i.getState())n();else{const t=()=>{"ready"===i.getState()&&(i.removeEventListener(v,t),n())};i.addEventListener(v,t)}}},FS.source.TileImage=nd,FS.source.TileJSON=class extends nd{constructor(t){if(super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:In("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)tu(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=In("EPSG:4326"),i=this.getProjection();let n;if(void 0!==t.bounds){const r=Bn(e,i);n=Ae(t.bounds,r)}const r=Bu(i),s=t.minzoom||0,o=Gu({extent:r,maxZoom:t.maxzoom||22,minZoom:s,tileSize:this.tileSize_});if(this.tileGrid=o,this.tileUrlFunction=Qu(t.tiles,o),t.attribution&&!this.getAttributions()){const e=void 0!==n?n:r;this.setAttributions((function(i){return Pe(e,i.extent)?[t.attribution]:null}))}this.tileJSON_=t,this.setState("ready")}handleTileJSONError(){this.setState("error")}},FS.source.TileWMS=class extends nd{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=In(i),s=this.getProjection()||r;let o=this.getTileGrid();o||(o=this.getTileGridForProjection(s));const a=Vn(t,r,s),l=xu(s,r,t,e),h=o.getZForResolution(l,this.zDirection),c=o.getResolution(h),u=o.getTileCoordForCoordAndZ(a,h);if(o.getResolutions().length<=u[0])return;let d=o.getTileCoordExtent(u,this.tmpExtent_);const g=this.gutter_;0!==g&&(d=Ht(d,c*g,d));const f={QUERY_LAYERS:this.params_.LAYERS};Object.assign(f,mg(this.params_,"GetFeatureInfo"),n);const p=Math.floor((a[0]-d[0])/c),m=Math.floor((d[3]-a[1])/c);return f[this.v13_?"I":"X"]=p,f[this.v13_?"J":"Y"]=m,this.getRequestUrl_(u,d,1,s||r,f)}getLegendUrl(t,e){if(void 0===this.urls[0])return;const i={SERVICE:"WMS",VERSION:dg,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),Vu(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[gi(Xc(t),s.length)]}return pg(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||dg;this.v13_=wi(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=Ht(s,r*o,s));const a=Object.assign({},mg(this.params_,"GetMap"));return this.getRequestUrl_(t,s,e,i,a)}},FS.source.UTFGrid=class extends zu{constructor(t){if(super({projection:In("EPSG:3857"),state:"loading",wrapX:void 0===t.wrapX||t.wrapX,zDirection:t.zDirection}),this.preemptive_=void 0===t.preemptive||t.preemptive,this.tileUrlFunction_=ed,this.template_=void 0,this.jsonp_=t.jsonp||!1,t.url)if(this.jsonp_)tu(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()}getTemplate(){return this.template_}forDataAtCoordinateAndResolution(t,e,i,n){if(this.tileGrid){const r=this.tileGrid.getZForResolution(e,this.zDirection),s=this.tileGrid.getTileCoordForCoordAndZ(t,r);this.getTile(s[0],s[1],s[2],1,this.getProjection()).forDataAtCoordinate(t,i,n)}else!0===n?setTimeout((function(){i(null)}),0):i(null)}handleTileJSONError(){this.setState("error")}handleTileJSONResponse(t){const e=In("EPSG:4326"),i=this.getProjection();let n;if(void 0!==t.bounds){const r=Bn(e,i);n=Ae(t.bounds,r)}const r=Bu(i),s=t.minzoom||0,o=Gu({extent:r,maxZoom:t.maxzoom||22,minZoom:s});this.tileGrid=o,this.template_=t.template;const a=t.grids;if(a){if(this.tileUrlFunction_=Qu(a,o),t.attribution){const e=void 0!==n?n:r;this.setAttributions((function(i){return Pe(e,i.extent)?[t.attribution]:null}))}this.setState("ready")}else this.setState("error")}getTile(t,e,i,n,r){const s=[t,e,i],o=this.getTileCoordForTileUrlFunction(s,r),a=this.tileUrlFunction_(o,n,r);return new rf(s,void 0!==a?K:J,void 0!==a?a:"",this.tileGrid.getTileCoordExtent(s),this.preemptive_,this.jsonp_)}},FS.source.UTFGrid.CustomTile=rf,FS.source.UrlTile=id,FS.source.Vector=Ld,FS.source.Vector.VectorSourceEvent=Md,FS.source.WMTS=class extends nd{constructor(t){const e=void 0!==t.requestEncoding?t.requestEncoding:"KVP",i=t.tileGrid;let n=t.urls;void 0===n&&void 0!==t.url&&(n=$u(t.url)),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:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,urls:n,wrapX:void 0!==t.wrapX&&t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.version_=void 0!==t.version?t.version:"1.0.0",this.format_=void 0!==t.format?t.format:"image/jpeg",this.dimensions_=void 0!==t.dimensions?t.dimensions:{},this.layer_=t.layer,this.matrixSet_=t.matrixSet,this.style_=t.style,this.requestEncoding_=e,this.setKey(this.getKeyForDimensions_()),n&&n.length>0&&(this.tileUrlFunction=td(n.map(this.createFromWMTSTemplate.bind(this))))}setUrls(t){this.urls=t;const e=t.join("\n");this.setTileUrlFunction(td(t.map(this.createFromWMTSTemplate.bind(this))),e)}getDimensions(){return this.dimensions_}getFormat(){return this.format_}getLayer(){return this.layer_}getMatrixSet(){return this.matrixSet_}getRequestEncoding(){return this.requestEncoding_}getStyle(){return this.style_}getVersion(){return this.version_}getKeyForDimensions_(){const t=this.urls?this.urls.slice(0):[];for(const e in this.dimensions_)t.push(e+"-"+this.dimensions_[e]);return t.join("/")}updateDimensions(t){Object.assign(this.dimensions_,t),this.setKey(this.getKeyForDimensions_())}createFromWMTSTemplate(t){const e=this.requestEncoding_,i={layer:this.layer_,style:this.style_,tilematrixset:this.matrixSet_};"KVP"==e&&Object.assign(i,{Service:"WMTS",Request:"GetTile",Version:this.version_,Format:this.format_}),t="KVP"==e?Vu(t,i):t.replace(/\{(\w+?)\}/g,(function(t,e){return e.toLowerCase()in i?i[e.toLowerCase()]:t}));const n=this.tileGrid,r=this.dimensions_;return function(i,s,o){if(!i)return;const a={TileMatrix:n.getMatrixId(i[0]),TileCol:i[1],TileRow:i[2]};Object.assign(a,r);let l=t;return l="KVP"==e?Vu(l,a):l.replace(/\{(\w+?)\}/g,(function(t,e){return encodeURIComponent(a[e])})),l}}},FS.source.WMTS.optionsFromCapabilities=function(t,e){const i=t.Contents.Layer,n=i?.find((function(t){return t.Identifier==e.layer}));if(!n)return null;const r=t.Contents.TileMatrixSet;let s;s=n.TileMatrixSetLink.length>1?"projection"in e?n.TileMatrixSetLink.findIndex((function(t){const i=r.find((function(e){return e.Identifier==t.TileMatrixSet})).SupportedCRS,n=In(i),s=In(e.projection);return n&&s?Un(n,s):i==e.projection})):n.TileMatrixSetLink.findIndex((function(t){return t.TileMatrixSet==e.matrixSet})):0,s<0&&(s=0);const o=n.TileMatrixSetLink[s].TileMatrixSet,a=n.TileMatrixSetLink[s].TileMatrixSetLimits;let l=n.Format[0];"format"in e&&(l=e.format),s=n.Style.findIndex((function(t){return"style"in e?t.Title==e.style:t.isDefault})),s<0&&(s=0);const h=n.Style[s].Identifier,c={};"Dimension"in n&&n.Dimension.forEach((function(t,e,i){const n=t.Identifier;let r=t.Default;void 0===r&&(r=t.Value[0]),c[n]=r}));const u=t.Contents.TileMatrixSet.find((function(t){return t.Identifier==o}));let d;const g=u.SupportedCRS;if(g&&(d=In(g)),"projection"in e){const t=In(e.projection);t&&(d&&!Un(t,d)||(d=t))}let f=!1;const p=d.getAxisOrientation().startsWith("ne");let m=u.TileMatrix[0],_={MinTileCol:0,MinTileRow:0,MaxTileCol:m.MatrixWidth-1,MaxTileRow:m.MatrixHeight-1};if(a){_=a[a.length-1];const t=u.TileMatrix.find((t=>t.Identifier===_.TileMatrix||u.Identifier+":"+t.Identifier===_.TileMatrix));t&&(m=t)}const y=28e-5*m.ScaleDenominator/d.getMetersPerUnit(),x=p?[m.TopLeftCorner[1],m.TopLeftCorner[0]]:m.TopLeftCorner,v=m.TileWidth*y,w=m.TileHeight*y;let E=u.BoundingBox;E&&p&&(E=[E[1],E[0],E[3],E[2]]);let S=[x[0]+v*_.MinTileCol,x[1]-w*(1+_.MaxTileRow),x[0]+v*(1+_.MaxTileCol),x[1]-w*_.MinTileRow];if(void 0!==E&&!Qt(E,S)){const t=n.WGS84BoundingBox,e=In("EPSG:4326").getExtent();if(S=E,t)f=t[0]===e[0]&&t[2]===e[2];else{const t=Wn(E,u.SupportedCRS,"EPSG:4326");f=t[0]-1e-10<=e[0]&&t[2]+1e-10>=e[2]}}const T=Ou(u,S,a),C=[];let R=e.requestEncoding;if(R=void 0!==R?R:"","OperationsMetadata"in t&&"GetTile"in t.OperationsMetadata){const e=t.OperationsMetadata.GetTile.DCP.HTTP.Get;for(let t=0,i=e.length;t{const n=t.toString();if(!i.containsKey(n)){const r=e(t);i.set(n,r)}a.push(i.get(n))})),a}},FS.source.static={},FS.source.static.createLoader=rg,FS.source.wms={},FS.source.wms.DEFAULT_VERSION=dg,FS.source.wms.createLoader=_g,FS.source.wms.getFeatureInfoUrl=yg,FS.source.wms.getImageSrc=pg,FS.source.wms.getLegendUrl=xg,FS.source.wms.getRequestParams=mg,FS.source.wms.getRequestUrl=fg,FS.sphere={},FS.sphere.DEFAULT_RADIUS=Ni,FS.sphere.getArea=function t(e,i){const n=(i=i||{}).radius||Ni,r=i.projection||"EPSG:3857",s=e.getType();"GeometryCollection"!==s&&(e=e.clone().transform(r,"EPSG:4326"));let o,a,l,h,c,u,d=0;switch(s){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":for(o=e.getCoordinates(),d=Math.abs(ji(o[0],n)),l=1,h=o.length;l