diff --git a/assets/index-iSzUt6tk.js b/assets/index-D-hFAano.js similarity index 73% rename from assets/index-iSzUt6tk.js rename to assets/index-D-hFAano.js index 45464af..2a0a073 100644 --- a/assets/index-iSzUt6tk.js +++ b/assets/index-D-hFAano.js @@ -1,21 +1,21 @@ -var Xl=Object.defineProperty;var Yl=(n,e,t)=>e in n?Xl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var $r=(n,e,t)=>(Yl(n,typeof e!="symbol"?e+"":e,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();class ct{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}const Ri={PROPERTYCHANGE:"propertychange"};class or{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function jl(n,e,t){let i,s;t=t||wt;let r=0,o=n.length,a=!1;for(;r>1),s=+t(n[i],e),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function wt(n,e){return n>e?1:n0?s-1:s}return i-1}if(t>0){for(let s=1;s0||t&&o===0)})}function qi(){return!0}function Qn(){return!1}function Ti(){}function na(n){let e=!1,t,i,s;return function(){const r=Array.prototype.slice.call(arguments);return(!e||this!==s||!Kt(r,i))&&(e=!0,s=this,i=r,t=n.apply(this,arguments)),t}}function sa(n){function e(){let t;try{t=n()}catch(i){return Promise.reject(i)}return t instanceof Promise?t:Promise.resolve(t)}return e()}function dn(n){for(const e in n)delete n[e]}function Si(n){let e;for(e in n)return!1;return!e}class fn extends or{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const i=this.listeners_||(this.listeners_={}),s=i[e]||(i[e]=[]);s.includes(t)||s.push(t)}dispatchEvent(e){const t=typeof e=="string",i=t?e:e.type,s=this.listeners_&&this.listeners_[i];if(!s)return;const r=t?new ct(e):e;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let c=0,h=s.length;c0:!1}removeEventListener(e,t){if(!this.listeners_)return;const i=this.listeners_[e];if(!i)return;const s=i.indexOf(t);s!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(i[s]=Ti,++this.pendingRemovals_[e]):(i.splice(s,1),i.length===0&&delete this.listeners_[e]))}}const B={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function U(n,e,t,i,s){if(i&&i!==n&&(t=t.bind(i)),s){const o=t;t=function(){n.removeEventListener(e,t),o.apply(this,arguments)}}const r={target:n,type:e,listener:t};return n.addEventListener(e,t),r}function Gn(n,e,t,i){return U(n,e,t,i,!0)}function ie(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),dn(n))}class gn extends fn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(B.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const i=e.length,s=new Array(i);for(let r=0;r0;)this.pop()}extend(e){for(let t=0,i=e.length;tthis.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new Ln(Le.ADD,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){this.unique_&&this.assertUnique_(e);const t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){const t=this.array_;for(let i=0,s=t.length;i=this.getLength())return;const t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new Ln(Le.REMOVE,t,e)),t}setAt(e,t){const i=this.getLength();if(e>=i){this.insertAt(e,t);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);const s=this.array_[e];this.array_[e]=t,this.dispatchEvent(new Ln(Le.REMOVE,s,e)),this.dispatchEvent(new Ln(Le.ADD,t,e))}updateLength_(){this.set(Qr.LENGTH,this.array_.length)}assertUnique_(e,t){for(let i=0,s=this.array_.length;iMath.round(t*eo[i])/eo[i]).join(", ")+")"}const fe={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function to(n){const e=Ue();for(let t=0,i=n.length;ts&&(l=l|fe.RIGHT),ar&&(l=l|fe.ABOVE),l===fe.UNKNOWN&&(l=fe.INTERSECTING),l}function Ue(){return[1/0,1/0,-1/0,-1/0]}function Zt(n,e,t,i,s){return s?(s[0]=n,s[1]=e,s[2]=t,s[3]=i,s):[n,e,t,i]}function ts(n){return Zt(1/0,1/0,-1/0,-1/0,n)}function la(n,e){const t=n[0],i=n[1];return Zt(t,i,t,i,e)}function ur(n,e,t,i,s){const r=ts(s);return ha(r,n,e,t,i)}function Li(n,e){return n[0]==e[0]&&n[2]==e[2]&&n[1]==e[1]&&n[3]==e[3]}function Jl(n,e){return e[0]n[2]&&(n[2]=e[2]),e[1]n[3]&&(n[3]=e[3]),n}function Vi(n,e){e[0]n[2]&&(n[2]=e[0]),e[1]n[3]&&(n[3]=e[1])}function ha(n,e,t,i,s){for(;te[0]?i[0]=n[0]:i[0]=e[0],n[1]>e[1]?i[1]=n[1]:i[1]=e[1],n[2]=e[0]&&n[1]<=e[3]&&n[3]>=e[1]}function Ai(n){return n[2]=o&&m<=l),!i&&r&fe.RIGHT&&!(s&fe.RIGHT)&&(_=f-(d-l)*g,i=_>=a&&_<=c),!i&&r&fe.BELOW&&!(s&fe.BELOW)&&(m=d-(f-a)/g,i=m>=o&&m<=l),!i&&r&fe.LEFT&&!(s&fe.LEFT)&&(_=f-(d-o)*g,i=_>=a&&_<=c)}return i}function ua(n,e){const t=e.getExtent(),i=Tt(n);if(e.canWrapX()&&(i[0]=t[2])){const s=Z(t),o=Math.floor((i[0]-t[0])/s)*s;n[0]-=o,n[2]-=o}return n}function nh(n,e){if(e.canWrapX()){const t=e.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[t[0],n[1],t[2],n[3]]];ua(n,e);const i=Z(t);if(Z(n)>i)return[[t[0],n[1],t[2],n[3]]];if(n[0]t[2])return[[n[0],n[1],t[2],n[3]],[t[0],n[1],n[2]-i,n[3]]]}return[n]}const Ji={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class da{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Ji[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const mn=6378137,Ei=Math.PI*mn,sh=[-Ei,-Ei,Ei,Ei],rh=[-180,-85,180,85],bn=mn*Math.log(Math.tan(Math.PI/2));class ci extends da{constructor(e){super({code:e,units:"m",extent:sh,global:!0,worldExtent:rh,getPointResolution:function(t,i){return t/Math.cosh(i[1]/mn)}})}}const io=[new ci("EPSG:3857"),new ci("EPSG:102100"),new ci("EPSG:102113"),new ci("EPSG:900913"),new ci("http://www.opengis.net/def/crs/EPSG/0/3857"),new ci("http://www.opengis.net/gml/srs/epsg.xml#3857")];function oh(n,e,t){const i=n.length;t=t>1?t:2,e===void 0&&(t>2?e=n.slice():e=new Array(i));for(let s=0;sbn?r=bn:r<-bn&&(r=-bn),e[s+1]=r}return e}function ah(n,e,t){const i=n.length;t=t>1?t:2,e===void 0&&(t>2?e=n.slice():e=new Array(i));for(let s=0;s1?(t=s,i=r):l>0&&(t+=o*l,i+=a*l)}return wi(n,e,t,i)}function wi(n,e,t,i){const s=t-n,r=i-e;return s*s+r*r}function gh(n){const e=n.length;for(let i=0;ir&&(r=l,s=a)}if(r===0)return null;const o=n[s];n[s]=n[i],n[i]=o;for(let a=i+1;a=0;i--){t[i]=n[i][e]/n[i][i];for(let s=i-1;s>=0;s--)n[s][e]-=n[s][i]*t[i]}return t}function Nn(n){return n*Math.PI/180}function si(n,e){const t=n%e;return t*e<0?t+e:t}function We(n,e,t){return n+t*(e-n)}function rs(n,e){const t=Math.pow(10,e);return Math.round(n*t)/t}function ro(n,e){return Math.round(rs(n,e))}function xi(n,e){return Math.floor(rs(n,e))}function Bt(n,e){return Math.ceil(rs(n,e))}function fa(n,e){const t=(""+n).split("."),i=(""+e).split(".");for(let s=0;so)return 1;if(o>r)return-1}return 0}function mh(n,e){return n[0]+=+e[0],n[1]+=+e[1],n}function Wn(n,e){let t=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=e[i]){t=!1;break}return t}function dr(n,e){const t=Math.cos(e),i=Math.sin(e),s=n[0]*t-n[1]*i,r=n[1]*t+n[0]*i;return n[0]=s,n[1]=r,n}function _h(n,e){return n[0]*=e,n[1]*=e,n}function ga(n,e){if(e.canWrapX()){const t=Z(e.getExtent()),i=ph(n,e,t);i&&(n[0]-=i*t)}return n}function ph(n,e,t){const i=e.getExtent();let s=0;return e.canWrapX()&&(n[0]i[2])&&(t=t||Z(i),s=Math.floor((n[0]-i[0])/t)),s}const yh=63710088e-1;function oo(n,e,t){t=t||yh;const i=Nn(n[1]),s=Nn(e[1]),r=(s-i)/2,o=Nn(e[0]-n[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(s);return 2*t*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function ma(...n){console.warn(...n)}let Hs=!0;function Eh(n){Hs=!(n===void 0?!0:n)}function fr(n,e){if(e!==void 0){for(let t=0,i=n.length;t180)&&(t[0]=si(i+180,360)-180),t}function Nt(n,e){if(n===e)return!0;const t=n.getUnits()===e.getUnits();return(n.getCode()===e.getCode()||os(n,e)===fr)&&t}function os(n,e){const t=n.getCode(),i=e.getCode();let s=dh(t,i);return s||(s=_a),s}function Xn(n,e){const t=ve(n),i=ve(e);return os(t,i)}function as(n,e,t){return Xn(e,t)(n,void 0,n.length)}let Ch=null;function Rh(){return Ch}function qs(n,e){return n}function yt(n,e){return Hs&&!Wn(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(Hs=!1,ma("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function mr(n,e){return n}function vt(n,e){return n}function Th(){lo(io),lo(so),vh(so,io,oh,ah)}Th();function Xt(n,e,t,i,s,r){r=r||[];let o=0;for(let a=e;a{if(!i)return this.getSimplifiedGeometry(t);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(t)})}simplifyTransformed(e,t){return this.simplifyTransformedInternal(this.getRevision(),e,t)}clone(){return q()}closestPointXY(e,t,i,s){return q()}containsXY(e,t){const i=this.getClosestPoint([e,t]);return i[0]===e&&i[1]===t}getClosestPoint(e,t){return t=t||[NaN,NaN],this.closestPointXY(e[0],e[1],t,1/0),t}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return q()}getExtent(e){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&ts(t),this.extentRevision_=this.getRevision()}return th(this.extent_,e)}rotate(e,t){q()}scale(e,t,i){q()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return q()}getType(){return q()}applyTransform(e){q()}intersectsExtent(e){return q()}translate(e,t){q()}transform(e,t){const i=ve(e),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),c=i.getWorldExtent(),h=le(c)/le(l);return je(ho,c[0],c[3],h,-h,0,0,0),Xt(r,0,r.length,a,ho,o),Xn(i,t)(r,o,a)}:Xn(i,t);return this.applyTransform(s),this}}class _r extends bh{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return ur(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return q()}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(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const t=this.getSimplifiedGeometryInternal(e);return t.getFlatCoordinates().length1)u=t;else if(d>0){for(let f=0;fs&&(s=c),r=a,o=l}return s}function Dh(n,e,t,i,s){for(let r=0,o=t.length;r0;){const u=c.pop(),d=c.pop();let f=0;const g=n[d],m=n[d+1],_=n[u],p=n[u+1];for(let y=d+i;yf&&(h=y,f=I)}f>s&&(l[(h-e)/i]=1,d+i0&&m>f)&&(g<0&&_0&&_>g)){c=u,h=d;continue}r[o++]=c,r[o++]=h,a=c,l=h,c=u,h=d}return r[o++]=c,r[o++]=h,o}function Ia(n,e,t,i,s,r,o,a){for(let l=0,c=t.length;lr&&(c-a)*(r-l)-(s-a)*(h-l)>0&&o++:h<=r&&(c-a)*(r-l)-(s-a)*(h-l)<0&&o--,a=c,l=h}return o!==0}function Ca(n,e,t,i,s,r){if(t.length===0||!ei(n,e,t[0],i,s,r))return!1;for(let o=1,a=t.length;op&&(c=(h+u)/2,Ca(n,e,t,i,c,g)&&(_=c,p=y)),h=u}return isNaN(_)&&(_=s[r]),o?(o.push(_,g,p),o):[_,g,p]}function zh(n,e,t,i,s){let r=[];for(let o=0,a=t.length;o=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:Wh(n,e,t,i,function(o,a){return ih(s,o,a)}):!1}function Ta(n,e,t,i,s){return!!(Ra(n,e,t,i,s)||ei(n,e,t,i,s[0],s[1])||ei(n,e,t,i,s[0],s[3])||ei(n,e,t,i,s[2],s[1])||ei(n,e,t,i,s[2],s[3]))}function Xh(n,e,t,i,s){if(!Ta(n,e,t[0],i,s))return!1;if(t.length===1)return!0;for(let r=1,o=t.length;r0}function jh(n,e,t,i,s){s=s!==void 0?s:!1;for(let r=0,o=t.length;r.0031308?1.055*Math.pow(r,1/2.4)-.055:r=r*12.92,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=o*12.92,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=a*12.92,r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[r*255,o*255,a*255]};tn.xyz=function(n,e){var t=n[0]/255,i=n[1]/255,s=n[2]/255;t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var r=t*.41239079926595+i*.35758433938387+s*.18048078840183,o=t*.21263900587151+i*.71516867876775+s*.072192315360733,a=t*.019330818715591+i*.11919477979462+s*.95053215224966;return e=e||_e.whitepoint[2].E,[r*e[0],o*e[1],a*e[2]]};const Ir={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(n,e,t){var i,s,r,o,a,l,c,h,u,d,f,g,m;if(r=n[0],o=n[1],a=n[2],r===0)return[0,0,0];var _=.0011070564598794539;return e=e||"D65",t=t||2,u=_e.whitepoint[t][e][0],d=_e.whitepoint[t][e][1],f=_e.whitepoint[t][e][2],g=4*u/(u+15*d+3*f),m=9*d/(u+15*d+3*f),i=o/(13*r)+g||0,s=a/(13*r)+m||0,c=r>8?d*Math.pow((r+16)/116,3):d*r*_,l=c*9*i/(4*s)||0,h=c*(12-3*i-20*s)/(4*s)||0,[l,c,h]}};_e.luv=function(n,e,t){var i,s,r,o,a,l,c,h,u,d,f,g,m,_=.008856451679035631,p=903.2962962962961;e=e||"D65",t=t||2,u=_e.whitepoint[t][e][0],d=_e.whitepoint[t][e][1],f=_e.whitepoint[t][e][2],g=4*u/(u+15*d+3*f),m=9*d/(u+15*d+3*f),l=n[0],c=n[1],h=n[2],i=4*l/(l+15*c+3*h)||0,s=9*c/(l+15*c+3*h)||0;var y=c/d;return r=y<=_?p*y:116*Math.pow(y,1/3)-16,o=13*r*(i-g),a=13*r*(s-m),[r,o,a]};var Sa={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(n){var e=n[0],t=n[1],i=n[2],s,r,o;return o=i/360*2*Math.PI,s=t*Math.cos(o),r=t*Math.sin(o),[e,s,r]},xyz:function(n){return Ir.xyz(Sa.luv(n))}};Ir.lchuv=function(n){var e=n[0],t=n[1],i=n[2],s=Math.sqrt(t*t+i*i),r=Math.atan2(i,t),o=r*360/2/Math.PI;return o<0&&(o+=360),[e,s,o]};_e.lchuv=function(n){return Ir.lchuv(_e.luv(n))};function Zh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Vh={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]};const _o=Zh(Vh);var po={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function Kh(n){var h,u;var e,t=[],i=1,s;if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(n=String(n).toLowerCase(),_o[n])t=_o[n].slice(),s="rgb";else if(n==="transparent")i=0,s="rgb",t=[0,0,0];else if(n[0]==="#"){var r=n.slice(1),o=r.length,a=o<=4;i=1,a?(t=[parseInt(r[0]+r[0],16),parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16)],o===4&&(i=parseInt(r[3]+r[3],16)/255)):(t=[parseInt(r[0]+r[1],16),parseInt(r[2]+r[3],16),parseInt(r[4]+r[5],16)],o===8&&(i=parseInt(r[6]+r[7],16)/255)),t[0]||(t[0]=0),t[1]||(t[1]=0),t[2]||(t[2]=0),s="rgb"}else if(e=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(n)){var l=e[1];s=l.replace(/a$/,"");var c=s==="cmyk"?4:s==="gray"?1:3;t=e[2].trim().split(/\s*[,\/]\s*|\s+/),s==="color"&&(s=t.shift()),t=t.map(function(d,f){if(d[d.length-1]==="%")return d=parseFloat(d)/100,f===3?d:s==="rgb"?d*255:s[0]==="h"||s[0]==="l"&&!f?d*100:s==="lab"?d*125:s==="lch"?f<2?d*150:d*360:s[0]==="o"&&!f?d:s==="oklab"?d*.4:s==="oklch"?f<2?d*.4:d*360:d;if(s[f]==="h"||f===2&&s[s.length-1]==="h"){if(po[d]!==void 0)return po[d];if(d.endsWith("deg"))return parseFloat(d);if(d.endsWith("turn"))return parseFloat(d)*360;if(d.endsWith("grad"))return parseFloat(d)*360/400;if(d.endsWith("rad"))return parseFloat(d)*180/Math.PI}return d==="none"?0:parseFloat(d)}),i=t.length>c?t.pop():1}else/[0-9](?:\s|\/|,)/.test(n)&&(t=n.match(/([0-9]+)/g).map(function(d){return parseFloat(d)}),s=((u=(h=n.match(/([a-z])/ig))==null?void 0:h.join(""))==null?void 0:u.toLowerCase())||"rgb");return{space:s,values:t,alpha:i}}const Ts={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(n){var e=n[0]/360,t=n[1]/100,i=n[2]/100,s,r,o,a,l,c=0;if(t===0)return l=i*255,[l,l,l];for(r=i<.5?i*(1+t):i+t-i*t,s=2*i-r,a=[0,0,0];c<3;)o=e+1/3*-(c-1),o<0?o++:o>1&&o--,l=6*o<1?s+(r-s)*6*o:2*o<1?r:3*o<2?s+(r-s)*(2/3-o)*6:s,a[c++]=l*255;return a}};tn.hsl=function(n){var e=n[0]/255,t=n[1]/255,i=n[2]/255,s=Math.min(e,t,i),r=Math.max(e,t,i),o=r-s,a,l,c;return r===s?a=0:e===r?a=(t-i)/o:t===r?a=2+(i-e)/o:i===r&&(a=4+(e-t)/o),a=Math.min(a*60,360),a<0&&(a+=360),c=(s+r)/2,r===s?l=0:c<=.5?l=o/(r+s):l=o/(2-r-s),[a,l*100,c*100]};function Hh(n){Array.isArray(n)&&n.raw&&(n=String.raw(...arguments)),n instanceof Number&&(n=+n);var e,t=Kh(n);if(!t.space)return[];const i=t.space[0]==="h"?Ts.min:tn.min,s=t.space[0]==="h"?Ts.max:tn.max;return e=Array(3),e[0]=Math.min(Math.max(t.values[0],i[0]),s[0]),e[1]=Math.min(Math.max(t.values[1],i[1]),s[1]),e[2]=Math.min(Math.max(t.values[2],i[2]),s[2]),t.space[0]==="h"&&(e=Ts.rgb(e)),e.push(Math.min(Math.max(t.alpha,0),1)),e}function qh(n){return typeof n=="string"?n:wr(n)}const $h=1024,zi={};let Ss=0;function Jh(n){if(n.length===4)return n;const e=n.slice();return e[3]=1,e}function yo(n){const e=_e.lchuv(tn.xyz(n));return e[3]=n[3],e}function Qh(n){const e=_e.rgb(Sa.xyz(n));return e[3]=n[3],e}function vr(n){if(zi.hasOwnProperty(n))return zi[n];if(Ss>=$h){let t=0;for(const i in zi)t++&3||(delete zi[i],--Ss)}const e=Hh(n);if(e.length!==4)throw new Error('Failed to parse "'+n+'" as color');for(const t of e)if(isNaN(t))throw new Error('Failed to parse "'+n+'" as color');return La(e),zi[n]=e,++Ss,e}function nn(n){return Array.isArray(n)?n:vr(n)}function La(n){return n[0]=he(n[0]+.5|0,0,255),n[1]=he(n[1]+.5|0,0,255),n[2]=he(n[2]+.5|0,0,255),n[3]=he(n[3],0,1),n}function wr(n){let e=n[0];e!=(e|0)&&(e=e+.5|0);let t=n[1];t!=(t|0)&&(t=t+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);const s=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+e+","+t+","+i+","+s+")"}function ec(n){try{return vr(n),!0}catch{return!1}}const Vt=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",tc=Vt.includes("firefox"),ic=Vt.includes("safari")&&!Vt.includes("chrom");ic&&(Vt.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Vt));const nc=Vt.includes("webkit")&&!Vt.includes("edge"),ba=Vt.includes("macintosh"),Ma=typeof devicePixelRatio<"u"?devicePixelRatio:1,Aa=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Cr=typeof Image<"u"&&Image.prototype.decode,sc=typeof createImageBitmap=="function",Da=function(){let n=!1;try{const e=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return n}();function pe(n,e,t,i){let s;return t&&t.length?s=t.shift():Aa?s=new OffscreenCanvas(n||300,e||300):s=document.createElement("canvas"),n&&(s.width=n),e&&(s.height=e),s.getContext("2d",i)}let Ls;function $s(){return Ls||(Ls=pe(1,1)),Ls}function ls(n){const e=n.canvas;e.width=1,e.height=1,n.clearRect(0,0,1,1)}function rc(n){let e=n.offsetWidth;const t=getComputedStyle(n);return e+=parseInt(t.marginLeft,10)+parseInt(t.marginRight,10),e}function oc(n){let e=n.offsetHeight;const t=getComputedStyle(n);return e+=parseInt(t.marginTop,10)+parseInt(t.marginBottom,10),e}function Eo(n,e){const t=e.parentNode;t&&t.replaceChild(n,e)}function jn(n){return n&&n.parentNode?n.parentNode.removeChild(n):null}function Pa(n){for(;n.lastChild;)n.removeChild(n.lastChild)}function ac(n,e){const t=n.childNodes;for(let i=0;;++i){const s=t[i],r=e[i];if(!s&&!r)break;if(s!==r){if(!s){n.appendChild(r);continue}if(!r){n.removeChild(s),--i;continue}n.insertBefore(r,s)}}}class Oa extends fn{constructor(e,t,i,s){super(),this.extent=e,this.pixelRatio_=i,this.resolution=t,this.state=typeof s=="function"?b.IDLE:s,this.image_=null,this.loader=typeof s=="function"?s:null}changed(){this.dispatchEvent(B.CHANGE)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==b.IDLE&&this.loader){this.state=b.LOADING,this.changed();const e=this.getResolution(),t=Array.isArray(e)?e[0]:e;sa(()=>this.loader(this.getExtent(),t,this.getPixelRatio())).then(i=>{"image"in i&&(this.image_=i.image),"extent"in i&&(this.extent=i.extent),"resolution"in i&&(this.resolution=i.resolution),"pixelRatio"in i&&(this.pixelRatio_=i.pixelRatio),(i instanceof HTMLImageElement||i instanceof ImageBitmap||i instanceof HTMLCanvasElement||i instanceof HTMLVideoElement)&&(this.image_=i),this.state=b.LOADED}).catch(i=>{this.state=b.ERROR,console.error(i)}).finally(()=>this.changed())}}setImage(e){this.image_=e}setResolution(e){this.resolution=e}}function lc(n,e,t){const i=n;let s=!0,r=!1,o=!1;const a=[Gn(i,B.LOAD,function(){o=!0,r||e()})];return i.src&&Cr?(r=!0,i.decode().then(function(){s&&e()}).catch(function(l){s&&(o?e():t())})):a.push(Gn(i,B.ERROR,t)),function(){s=!1,a.forEach(ie)}}function hc(n,e){return new Promise((t,i)=>{function s(){o(),t(n)}function r(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",s),n.removeEventListener("error",r)}n.addEventListener("load",s),n.addEventListener("error",r),e&&(n.src=e)})}function ka(n,e){return e&&(n.src=e),n.src&&Cr?new Promise((t,i)=>n.decode().then(()=>t(n)).catch(s=>n.complete&&n.width?t(n):i(s))):hc(n)}function Fa(n,e){return e&&(n.src=e),n.src&&Cr&&sc?n.decode().then(()=>createImageBitmap(n)).catch(t=>{if(n.complete&&n.width)return n;throw t}):ka(n)}class cc{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(const t in this.cache_){const i=this.cache_[t];!(e++&3)&&!i.hasListener()&&(delete this.cache_[t],delete this.patternCache_[t],--this.cacheSize_)}}}get(e,t,i){const s=bs(e,t,i);return s in this.cache_?this.cache_[s]:null}getPattern(e,t,i){const s=bs(e,t,i);return s in this.patternCache_?this.patternCache_[s]:null}set(e,t,i,s,r){const o=bs(e,t,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===b.IDLE&&s.load(),s.getImageState()===b.LOADING?s.ready().then(()=>{this.patternCache_[o]=$s().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=$s().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}}function bs(n,e,t){const i=t?nn(t):"null";return e+":"+n+":"+i}const ot=new cc;let Wi=null;class uc extends fn{constructor(e,t,i,s,r){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?b.IDLE:s,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===b.LOADED){Wi||(Wi=pe(1,1,void 0,{willReadFrequently:!0})),Wi.drawImage(this.image_,0,0);try{Wi.getImageData(0,0,1,1),this.tainted_=!1}catch{Wi=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(B.CHANGE)}handleImageError_(){this.imageState_=b.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=b.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const e=this.size_[0],t=this.size_[1],i=pe(e,t);i.fillRect(0,0,e,t),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===b.IDLE){this.image_||this.initializeImage_(),this.imageState_=b.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&ka(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==b.LOADED)return;const t=this.image_,i=document.createElement("canvas");i.width=Math.ceil(t.width*e),i.height=Math.ceil(t.height*e);const s=i.getContext("2d");s.scale(e,e),s.drawImage(t,0,0),s.globalCompositeOperation="multiply",s.fillStyle=qh(this.color_),s.fillRect(0,0,i.width/e,i.height/e),s.globalCompositeOperation="destination-in",s.drawImage(t,0,0),this.canvas_[e]=i}ready(){return this.ready_||(this.ready_=new Promise(e=>{this.imageState_===b.LOADED||this.imageState_===b.ERROR?e():this.addEventListener(B.CHANGE,function t(){(this.imageState_===b.LOADED||this.imageState_===b.ERROR)&&(this.removeEventListener(B.CHANGE,t),e())})})),this.ready_}}function Rr(n,e,t,i,s,r){let o=e===void 0?void 0:ot.get(e,t,s);return o||(o=new uc(n,n instanceof HTMLImageElement?n.src||void 0:e,t,i,s),ot.set(e,t,s,o,r)),r&&o&&!ot.getPattern(e,t,s)&&ot.set(e,t,s,o,r),o}class _n{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){const e=this.getColor();return new _n({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){const t=Rr(null,e.src,"anonymous",void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));t.ready().then(()=>{this.patternImage_=null}),t.getImageState()===b.IDLE&&t.load(),t.getImageState()===b.LOADING&&(this.patternImage_=t)}this.color_=e}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function xo(n,e,t,i,s,r,o){let a,l;const c=(t-e)/i;if(c===1)a=e;else if(c===2)a=e,l=s;else if(c!==0){let h=n[e],u=n[e+1],d=0;const f=[0];for(let _=e+i;_1?o:2,r=r||new Array(o);for(let h=0;h0&&n[1]>0}function fc(n,e,t){return t===void 0&&(t=[0,0]),t[0]=n[0]*e+.5|0,t[1]=n[1]*e+.5|0,t}function Oe(n,e){return Array.isArray(n)?n:(e===void 0?e=[n,n]:(e[0]=n,e[1]=n),e)}class cs{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=Oe(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new cs({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,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 q()}getImage(e){return q()}getHitDetectionImage(){return q()}getPixelRatio(e){return 1}getImageState(){return q()}getImageSize(){return q()}getOrigin(){return q()}getSize(){return q()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Oe(e)}listenImageChange(e){q()}load(){q()}unlistenImageChange(e){q()}ready(){return Promise.resolve()}}function at(n){return n?Array.isArray(n)?wr(n):typeof n=="object"&&"src"in n?gc(n):n:null}function gc(n){if(!n.offset||!n.size)return ot.getPattern(n.src,"anonymous",n.color);const e=n.src+":"+n.offset,t=ot.getPattern(e,void 0,n.color);if(t)return t;const i=ot.get(n.src,"anonymous",null);if(i.getImageState()!==b.LOADED)return null;const s=pe(n.size[0],n.size[1]);return s.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Rr(s.canvas,e,void 0,b.LOADED,n.color,!0),ot.getPattern(e,void 0,n.color)}const Mn="ol-hidden",mc="ol-selectable",us="ol-unselectable",Tr="ol-control",vo="ol-collapsed",_c=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"),wo=["style","variant","weight","size","lineHeight","family"],Na=function(n){const e=n.match(_c);if(!e)return null;const t={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let i=0,s=wo.length;ie in n?Yl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Qr=(n,e,t)=>(jl(n,typeof e!="symbol"?e+"":e,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();class ct{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}const Ri={PROPERTYCHANGE:"propertychange"};class lr{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function Ul(n,e,t){let i,s;t=t||wt;let r=0,o=n.length,a=!1;for(;r>1),s=+t(n[i],e),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function wt(n,e){return n>e?1:n0?s-1:s}return i-1}if(t>0){for(let s=1;s0||t&&o===0)})}function qi(){return!0}function ts(){return!1}function Ti(){}function sa(n){let e=!1,t,i,s;return function(){const r=Array.prototype.slice.call(arguments);return(!e||this!==s||!Kt(r,i))&&(e=!0,s=this,i=r,t=n.apply(this,arguments)),t}}function ra(n){function e(){let t;try{t=n()}catch(i){return Promise.reject(i)}return t instanceof Promise?t:Promise.resolve(t)}return e()}function dn(n){for(const e in n)delete n[e]}function Si(n){let e;for(e in n)return!1;return!e}class fn extends lr{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const i=this.listeners_||(this.listeners_={}),s=i[e]||(i[e]=[]);s.includes(t)||s.push(t)}dispatchEvent(e){const t=typeof e=="string",i=t?e:e.type,s=this.listeners_&&this.listeners_[i];if(!s)return;const r=t?new ct(e):e;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let c=0,h=s.length;c0:!1}removeEventListener(e,t){if(!this.listeners_)return;const i=this.listeners_[e];if(!i)return;const s=i.indexOf(t);s!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(i[s]=Ti,++this.pendingRemovals_[e]):(i.splice(s,1),i.length===0&&delete this.listeners_[e]))}}const B={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function U(n,e,t,i,s){if(i&&i!==n&&(t=t.bind(i)),s){const o=t;t=function(){n.removeEventListener(e,t),o.apply(this,arguments)}}const r={target:n,type:e,listener:t};return n.addEventListener(e,t),r}function Wn(n,e,t,i){return U(n,e,t,i,!0)}function ie(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),dn(n))}class gn extends fn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(B.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const i=e.length,s=new Array(i);for(let r=0;r0;)this.pop()}extend(e){for(let t=0,i=e.length;tthis.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new Ln(Le.ADD,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){this.unique_&&this.assertUnique_(e);const t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){const t=this.array_;for(let i=0,s=t.length;i=this.getLength())return;const t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new Ln(Le.REMOVE,t,e)),t}setAt(e,t){const i=this.getLength();if(e>=i){this.insertAt(e,t);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);const s=this.array_[e];this.array_[e]=t,this.dispatchEvent(new Ln(Le.REMOVE,s,e)),this.dispatchEvent(new Ln(Le.ADD,t,e))}updateLength_(){this.set(to.LENGTH,this.array_.length)}assertUnique_(e,t){for(let i=0,s=this.array_.length;iMath.round(t*io[i])/io[i]).join(", ")+")"}const fe={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function no(n){const e=Ue();for(let t=0,i=n.length;ts&&(l=l|fe.RIGHT),ar&&(l=l|fe.ABOVE),l===fe.UNKNOWN&&(l=fe.INTERSECTING),l}function Ue(){return[1/0,1/0,-1/0,-1/0]}function Vt(n,e,t,i,s){return s?(s[0]=n,s[1]=e,s[2]=t,s[3]=i,s):[n,e,t,i]}function ns(n){return Vt(1/0,1/0,-1/0,-1/0,n)}function ha(n,e){const t=n[0],i=n[1];return Vt(t,i,t,i,e)}function fr(n,e,t,i,s){const r=ns(s);return ca(r,n,e,t,i)}function Li(n,e){return n[0]==e[0]&&n[2]==e[2]&&n[1]==e[1]&&n[3]==e[3]}function Ql(n,e){return e[0]n[2]&&(n[2]=e[2]),e[1]n[3]&&(n[3]=e[3]),n}function Zi(n,e){e[0]n[2]&&(n[2]=e[0]),e[1]n[3]&&(n[3]=e[1])}function ca(n,e,t,i,s){for(;te[0]?i[0]=n[0]:i[0]=e[0],n[1]>e[1]?i[1]=n[1]:i[1]=e[1],n[2]=e[0]&&n[1]<=e[3]&&n[3]>=e[1]}function Ai(n){return n[2]=o&&m<=l),!i&&r&fe.RIGHT&&!(s&fe.RIGHT)&&(_=f-(d-l)*g,i=_>=a&&_<=c),!i&&r&fe.BELOW&&!(s&fe.BELOW)&&(m=d-(f-a)/g,i=m>=o&&m<=l),!i&&r&fe.LEFT&&!(s&fe.LEFT)&&(_=f-(d-o)*g,i=_>=a&&_<=c)}return i}function da(n,e){const t=e.getExtent(),i=Tt(n);if(e.canWrapX()&&(i[0]=t[2])){const s=V(t),o=Math.floor((i[0]-t[0])/s)*s;n[0]-=o,n[2]-=o}return n}function sh(n,e){if(e.canWrapX()){const t=e.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[t[0],n[1],t[2],n[3]]];da(n,e);const i=V(t);if(V(n)>i)return[[t[0],n[1],t[2],n[3]]];if(n[0]t[2])return[[n[0],n[1],t[2],n[3]],[t[0],n[1],n[2]-i,n[3]]]}return[n]}const Ji={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class fa{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Ji[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const mn=6378137,Ei=Math.PI*mn,rh=[-Ei,-Ei,Ei,Ei],oh=[-180,-85,180,85],bn=mn*Math.log(Math.tan(Math.PI/2));class ci extends fa{constructor(e){super({code:e,units:"m",extent:rh,global:!0,worldExtent:oh,getPointResolution:function(t,i){return t/Math.cosh(i[1]/mn)}})}}const so=[new ci("EPSG:3857"),new ci("EPSG:102100"),new ci("EPSG:102113"),new ci("EPSG:900913"),new ci("http://www.opengis.net/def/crs/EPSG/0/3857"),new ci("http://www.opengis.net/gml/srs/epsg.xml#3857")];function ah(n,e,t){const i=n.length;t=t>1?t:2,e===void 0&&(t>2?e=n.slice():e=new Array(i));for(let s=0;sbn?r=bn:r<-bn&&(r=-bn),e[s+1]=r}return e}function lh(n,e,t){const i=n.length;t=t>1?t:2,e===void 0&&(t>2?e=n.slice():e=new Array(i));for(let s=0;s1?(t=s,i=r):l>0&&(t+=o*l,i+=a*l)}return wi(n,e,t,i)}function wi(n,e,t,i){const s=t-n,r=i-e;return s*s+r*r}function mh(n){const e=n.length;for(let i=0;ir&&(r=l,s=a)}if(r===0)return null;const o=n[s];n[s]=n[i],n[i]=o;for(let a=i+1;a=0;i--){t[i]=n[i][e]/n[i][i];for(let s=i-1;s>=0;s--)n[s][e]-=n[s][i]*t[i]}return t}function Gn(n){return n*Math.PI/180}function si(n,e){const t=n%e;return t*e<0?t+e:t}function We(n,e,t){return n+t*(e-n)}function as(n,e){const t=Math.pow(10,e);return Math.round(n*t)/t}function ao(n,e){return Math.round(as(n,e))}function xi(n,e){return Math.floor(as(n,e))}function Bt(n,e){return Math.ceil(as(n,e))}function ga(n,e){const t=(""+n).split("."),i=(""+e).split(".");for(let s=0;so)return 1;if(o>r)return-1}return 0}function _h(n,e){return n[0]+=+e[0],n[1]+=+e[1],n}function Yn(n,e){let t=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=e[i]){t=!1;break}return t}function gr(n,e){const t=Math.cos(e),i=Math.sin(e),s=n[0]*t-n[1]*i,r=n[1]*t+n[0]*i;return n[0]=s,n[1]=r,n}function ph(n,e){return n[0]*=e,n[1]*=e,n}function ma(n,e){if(e.canWrapX()){const t=V(e.getExtent()),i=yh(n,e,t);i&&(n[0]-=i*t)}return n}function yh(n,e,t){const i=e.getExtent();let s=0;return e.canWrapX()&&(n[0]i[2])&&(t=t||V(i),s=Math.floor((n[0]-i[0])/t)),s}const Eh=63710088e-1;function lo(n,e,t){t=t||Eh;const i=Gn(n[1]),s=Gn(e[1]),r=(s-i)/2,o=Gn(e[0]-n[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(s);return 2*t*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function _a(...n){console.warn(...n)}let $s=!0;function xh(n){$s=!(n===void 0?!0:n)}function mr(n,e){if(e!==void 0){for(let t=0,i=n.length;t180)&&(t[0]=si(i+180,360)-180),t}function Nt(n,e){if(n===e)return!0;const t=n.getUnits()===e.getUnits();return(n.getCode()===e.getCode()||ls(n,e)===mr)&&t}function ls(n,e){const t=n.getCode(),i=e.getCode();let s=fh(t,i);return s||(s=pa),s}function jn(n,e){const t=ve(n),i=ve(e);return ls(t,i)}function hs(n,e,t){return jn(e,t)(n,void 0,n.length)}let Ch=null;function Rh(){return Ch}function Js(n,e){return n}function yt(n,e){return $s&&!Yn(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&($s=!1,_a("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function pr(n,e){return n}function vt(n,e){return n}function Th(){co(so),co(oo),wh(oo,so,ah,lh)}Th();function Xt(n,e,t,i,s,r){r=r||[];let o=0;for(let a=e;a{if(!i)return this.getSimplifiedGeometry(t);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(t)})}simplifyTransformed(e,t){return this.simplifyTransformedInternal(this.getRevision(),e,t)}clone(){return q()}closestPointXY(e,t,i,s){return q()}containsXY(e,t){const i=this.getClosestPoint([e,t]);return i[0]===e&&i[1]===t}getClosestPoint(e,t){return t=t||[NaN,NaN],this.closestPointXY(e[0],e[1],t,1/0),t}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return q()}getExtent(e){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&ns(t),this.extentRevision_=this.getRevision()}return ih(this.extent_,e)}rotate(e,t){q()}scale(e,t,i){q()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return q()}getType(){return q()}applyTransform(e){q()}intersectsExtent(e){return q()}translate(e,t){q()}transform(e,t){const i=ve(e),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),c=i.getWorldExtent(),h=le(c)/le(l);return je(fo,c[0],c[3],h,-h,0,0,0),Xt(r,0,r.length,a,fo,o),jn(i,t)(r,o,a)}:jn(i,t);return this.applyTransform(s),this}}class yr extends bh{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return fr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return q()}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(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const t=this.getSimplifiedGeometryInternal(e);return t.getFlatCoordinates().length1)u=t;else if(d>0){for(let f=0;fs&&(s=c),r=a,o=l}return s}function Dh(n,e,t,i,s){for(let r=0,o=t.length;r0;){const u=c.pop(),d=c.pop();let f=0;const g=n[d],m=n[d+1],_=n[u],p=n[u+1];for(let y=d+i;yf&&(h=y,f=I)}f>s&&(l[(h-e)/i]=1,d+i0&&m>f)&&(g<0&&_0&&_>g)){c=u,h=d;continue}r[o++]=c,r[o++]=h,a=c,l=h,c=u,h=d}return r[o++]=c,r[o++]=h,o}function va(n,e,t,i,s,r,o,a){for(let l=0,c=t.length;lr&&(c-a)*(r-l)-(s-a)*(h-l)>0&&o++:h<=r&&(c-a)*(r-l)-(s-a)*(h-l)<0&&o--,a=c,l=h}return o!==0}function Ra(n,e,t,i,s,r){if(t.length===0||!ei(n,e,t[0],i,s,r))return!1;for(let o=1,a=t.length;op&&(c=(h+u)/2,Ra(n,e,t,i,c,g)&&(_=c,p=y)),h=u}return isNaN(_)&&(_=s[r]),o?(o.push(_,g,p),o):[_,g,p]}function zh(n,e,t,i,s){let r=[];for(let o=0,a=t.length;o=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:Wh(n,e,t,i,function(o,a){return nh(s,o,a)}):!1}function Sa(n,e,t,i,s){return!!(Ta(n,e,t,i,s)||ei(n,e,t,i,s[0],s[1])||ei(n,e,t,i,s[0],s[3])||ei(n,e,t,i,s[2],s[1])||ei(n,e,t,i,s[2],s[3]))}function Xh(n,e,t,i,s){if(!Sa(n,e,t[0],i,s))return!1;if(t.length===1)return!0;for(let r=1,o=t.length;r0}function jh(n,e,t,i,s){s=s!==void 0?s:!1;for(let r=0,o=t.length;r.0031308?1.055*Math.pow(r,1/2.4)-.055:r=r*12.92,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=o*12.92,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=a*12.92,r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[r*255,o*255,a*255]};tn.xyz=function(n,e){var t=n[0]/255,i=n[1]/255,s=n[2]/255;t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var r=t*.41239079926595+i*.35758433938387+s*.18048078840183,o=t*.21263900587151+i*.71516867876775+s*.072192315360733,a=t*.019330818715591+i*.11919477979462+s*.95053215224966;return e=e||_e.whitepoint[2].E,[r*e[0],o*e[1],a*e[2]]};const wr={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(n,e,t){var i,s,r,o,a,l,c,h,u,d,f,g,m;if(r=n[0],o=n[1],a=n[2],r===0)return[0,0,0];var _=.0011070564598794539;return e=e||"D65",t=t||2,u=_e.whitepoint[t][e][0],d=_e.whitepoint[t][e][1],f=_e.whitepoint[t][e][2],g=4*u/(u+15*d+3*f),m=9*d/(u+15*d+3*f),i=o/(13*r)+g||0,s=a/(13*r)+m||0,c=r>8?d*Math.pow((r+16)/116,3):d*r*_,l=c*9*i/(4*s)||0,h=c*(12-3*i-20*s)/(4*s)||0,[l,c,h]}};_e.luv=function(n,e,t){var i,s,r,o,a,l,c,h,u,d,f,g,m,_=.008856451679035631,p=903.2962962962961;e=e||"D65",t=t||2,u=_e.whitepoint[t][e][0],d=_e.whitepoint[t][e][1],f=_e.whitepoint[t][e][2],g=4*u/(u+15*d+3*f),m=9*d/(u+15*d+3*f),l=n[0],c=n[1],h=n[2],i=4*l/(l+15*c+3*h)||0,s=9*c/(l+15*c+3*h)||0;var y=c/d;return r=y<=_?p*y:116*Math.pow(y,1/3)-16,o=13*r*(i-g),a=13*r*(s-m),[r,o,a]};var La={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(n){var e=n[0],t=n[1],i=n[2],s,r,o;return o=i/360*2*Math.PI,s=t*Math.cos(o),r=t*Math.sin(o),[e,s,r]},xyz:function(n){return wr.xyz(La.luv(n))}};wr.lchuv=function(n){var e=n[0],t=n[1],i=n[2],s=Math.sqrt(t*t+i*i),r=Math.atan2(i,t),o=r*360/2/Math.PI;return o<0&&(o+=360),[e,s,o]};_e.lchuv=function(n){return wr.lchuv(_e.luv(n))};function Vh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Zh={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]};const Eo=Vh(Zh);var xo={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function Kh(n){var h,u;var e,t=[],i=1,s;if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(n=String(n).toLowerCase(),Eo[n])t=Eo[n].slice(),s="rgb";else if(n==="transparent")i=0,s="rgb",t=[0,0,0];else if(n[0]==="#"){var r=n.slice(1),o=r.length,a=o<=4;i=1,a?(t=[parseInt(r[0]+r[0],16),parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16)],o===4&&(i=parseInt(r[3]+r[3],16)/255)):(t=[parseInt(r[0]+r[1],16),parseInt(r[2]+r[3],16),parseInt(r[4]+r[5],16)],o===8&&(i=parseInt(r[6]+r[7],16)/255)),t[0]||(t[0]=0),t[1]||(t[1]=0),t[2]||(t[2]=0),s="rgb"}else if(e=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(n)){var l=e[1];s=l.replace(/a$/,"");var c=s==="cmyk"?4:s==="gray"?1:3;t=e[2].trim().split(/\s*[,\/]\s*|\s+/),s==="color"&&(s=t.shift()),t=t.map(function(d,f){if(d[d.length-1]==="%")return d=parseFloat(d)/100,f===3?d:s==="rgb"?d*255:s[0]==="h"||s[0]==="l"&&!f?d*100:s==="lab"?d*125:s==="lch"?f<2?d*150:d*360:s[0]==="o"&&!f?d:s==="oklab"?d*.4:s==="oklch"?f<2?d*.4:d*360:d;if(s[f]==="h"||f===2&&s[s.length-1]==="h"){if(xo[d]!==void 0)return xo[d];if(d.endsWith("deg"))return parseFloat(d);if(d.endsWith("turn"))return parseFloat(d)*360;if(d.endsWith("grad"))return parseFloat(d)*360/400;if(d.endsWith("rad"))return parseFloat(d)*180/Math.PI}return d==="none"?0:parseFloat(d)}),i=t.length>c?t.pop():1}else/[0-9](?:\s|\/|,)/.test(n)&&(t=n.match(/([0-9]+)/g).map(function(d){return parseFloat(d)}),s=((u=(h=n.match(/([a-z])/ig))==null?void 0:h.join(""))==null?void 0:u.toLowerCase())||"rgb");return{space:s,values:t,alpha:i}}const Ls={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(n){var e=n[0]/360,t=n[1]/100,i=n[2]/100,s,r,o,a,l,c=0;if(t===0)return l=i*255,[l,l,l];for(r=i<.5?i*(1+t):i+t-i*t,s=2*i-r,a=[0,0,0];c<3;)o=e+1/3*-(c-1),o<0?o++:o>1&&o--,l=6*o<1?s+(r-s)*6*o:2*o<1?r:3*o<2?s+(r-s)*(2/3-o)*6:s,a[c++]=l*255;return a}};tn.hsl=function(n){var e=n[0]/255,t=n[1]/255,i=n[2]/255,s=Math.min(e,t,i),r=Math.max(e,t,i),o=r-s,a,l,c;return r===s?a=0:e===r?a=(t-i)/o:t===r?a=2+(i-e)/o:i===r&&(a=4+(e-t)/o),a=Math.min(a*60,360),a<0&&(a+=360),c=(s+r)/2,r===s?l=0:c<=.5?l=o/(r+s):l=o/(2-r-s),[a,l*100,c*100]};function Hh(n){Array.isArray(n)&&n.raw&&(n=String.raw(...arguments)),n instanceof Number&&(n=+n);var e,t=Kh(n);if(!t.space)return[];const i=t.space[0]==="h"?Ls.min:tn.min,s=t.space[0]==="h"?Ls.max:tn.max;return e=Array(3),e[0]=Math.min(Math.max(t.values[0],i[0]),s[0]),e[1]=Math.min(Math.max(t.values[1],i[1]),s[1]),e[2]=Math.min(Math.max(t.values[2],i[2]),s[2]),t.space[0]==="h"&&(e=Ls.rgb(e)),e.push(Math.min(Math.max(t.alpha,0),1)),e}function qh(n){return typeof n=="string"?n:Rr(n)}const $h=1024,zi={};let bs=0;function Jh(n){if(n.length===4)return n;const e=n.slice();return e[3]=1,e}function Io(n){const e=_e.lchuv(tn.xyz(n));return e[3]=n[3],e}function Qh(n){const e=_e.rgb(La.xyz(n));return e[3]=n[3],e}function Cr(n){if(zi.hasOwnProperty(n))return zi[n];if(bs>=$h){let t=0;for(const i in zi)t++&3||(delete zi[i],--bs)}const e=Hh(n);if(e.length!==4)throw new Error('Failed to parse "'+n+'" as color');for(const t of e)if(isNaN(t))throw new Error('Failed to parse "'+n+'" as color');return ba(e),zi[n]=e,++bs,e}function nn(n){return Array.isArray(n)?n:Cr(n)}function ba(n){return n[0]=he(n[0]+.5|0,0,255),n[1]=he(n[1]+.5|0,0,255),n[2]=he(n[2]+.5|0,0,255),n[3]=he(n[3],0,1),n}function Rr(n){let e=n[0];e!=(e|0)&&(e=e+.5|0);let t=n[1];t!=(t|0)&&(t=t+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);const s=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+e+","+t+","+i+","+s+")"}function ec(n){try{return Cr(n),!0}catch{return!1}}const Zt=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",tc=Zt.includes("firefox"),ic=Zt.includes("safari")&&!Zt.includes("chrom");ic&&(Zt.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Zt));const nc=Zt.includes("webkit")&&!Zt.includes("edge"),Ma=Zt.includes("macintosh"),Aa=typeof devicePixelRatio<"u"?devicePixelRatio:1,Da=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Tr=typeof Image<"u"&&Image.prototype.decode,sc=typeof createImageBitmap=="function",Pa=function(){let n=!1;try{const e=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return n}();function pe(n,e,t,i){let s;return t&&t.length?s=t.shift():Da?s=new OffscreenCanvas(n||300,e||300):s=document.createElement("canvas"),n&&(s.width=n),e&&(s.height=e),s.getContext("2d",i)}let Ms;function Qs(){return Ms||(Ms=pe(1,1)),Ms}function cs(n){const e=n.canvas;e.width=1,e.height=1,n.clearRect(0,0,1,1)}function rc(n){let e=n.offsetWidth;const t=getComputedStyle(n);return e+=parseInt(t.marginLeft,10)+parseInt(t.marginRight,10),e}function oc(n){let e=n.offsetHeight;const t=getComputedStyle(n);return e+=parseInt(t.marginTop,10)+parseInt(t.marginBottom,10),e}function vo(n,e){const t=e.parentNode;t&&t.replaceChild(n,e)}function Vn(n){return n&&n.parentNode?n.parentNode.removeChild(n):null}function Oa(n){for(;n.lastChild;)n.removeChild(n.lastChild)}function ac(n,e){const t=n.childNodes;for(let i=0;;++i){const s=t[i],r=e[i];if(!s&&!r)break;if(s!==r){if(!s){n.appendChild(r);continue}if(!r){n.removeChild(s),--i;continue}n.insertBefore(r,s)}}}class ka extends fn{constructor(e,t,i,s){super(),this.extent=e,this.pixelRatio_=i,this.resolution=t,this.state=typeof s=="function"?b.IDLE:s,this.image_=null,this.loader=typeof s=="function"?s:null}changed(){this.dispatchEvent(B.CHANGE)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==b.IDLE&&this.loader){this.state=b.LOADING,this.changed();const e=this.getResolution(),t=Array.isArray(e)?e[0]:e;ra(()=>this.loader(this.getExtent(),t,this.getPixelRatio())).then(i=>{"image"in i&&(this.image_=i.image),"extent"in i&&(this.extent=i.extent),"resolution"in i&&(this.resolution=i.resolution),"pixelRatio"in i&&(this.pixelRatio_=i.pixelRatio),(i instanceof HTMLImageElement||i instanceof ImageBitmap||i instanceof HTMLCanvasElement||i instanceof HTMLVideoElement)&&(this.image_=i),this.state=b.LOADED}).catch(i=>{this.state=b.ERROR,console.error(i)}).finally(()=>this.changed())}}setImage(e){this.image_=e}setResolution(e){this.resolution=e}}function lc(n,e,t){const i=n;let s=!0,r=!1,o=!1;const a=[Wn(i,B.LOAD,function(){o=!0,r||e()})];return i.src&&Tr?(r=!0,i.decode().then(function(){s&&e()}).catch(function(l){s&&(o?e():t())})):a.push(Wn(i,B.ERROR,t)),function(){s=!1,a.forEach(ie)}}function hc(n,e){return new Promise((t,i)=>{function s(){o(),t(n)}function r(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",s),n.removeEventListener("error",r)}n.addEventListener("load",s),n.addEventListener("error",r),e&&(n.src=e)})}function Fa(n,e){return e&&(n.src=e),n.src&&Tr?new Promise((t,i)=>n.decode().then(()=>t(n)).catch(s=>n.complete&&n.width?t(n):i(s))):hc(n)}function Na(n,e){return e&&(n.src=e),n.src&&Tr&&sc?n.decode().then(()=>createImageBitmap(n)).catch(t=>{if(n.complete&&n.width)return n;throw t}):Fa(n)}class cc{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(const t in this.cache_){const i=this.cache_[t];!(e++&3)&&!i.hasListener()&&(delete this.cache_[t],delete this.patternCache_[t],--this.cacheSize_)}}}get(e,t,i){const s=As(e,t,i);return s in this.cache_?this.cache_[s]:null}getPattern(e,t,i){const s=As(e,t,i);return s in this.patternCache_?this.patternCache_[s]:null}set(e,t,i,s,r){const o=As(e,t,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===b.IDLE&&s.load(),s.getImageState()===b.LOADING?s.ready().then(()=>{this.patternCache_[o]=Qs().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=Qs().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}}function As(n,e,t){const i=t?nn(t):"null";return e+":"+n+":"+i}const ot=new cc;let Wi=null;class uc extends fn{constructor(e,t,i,s,r){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?b.IDLE:s,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===b.LOADED){Wi||(Wi=pe(1,1,void 0,{willReadFrequently:!0})),Wi.drawImage(this.image_,0,0);try{Wi.getImageData(0,0,1,1),this.tainted_=!1}catch{Wi=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(B.CHANGE)}handleImageError_(){this.imageState_=b.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=b.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const e=this.size_[0],t=this.size_[1],i=pe(e,t);i.fillRect(0,0,e,t),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===b.IDLE){this.image_||this.initializeImage_(),this.imageState_=b.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Fa(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==b.LOADED)return;const t=this.image_,i=document.createElement("canvas");i.width=Math.ceil(t.width*e),i.height=Math.ceil(t.height*e);const s=i.getContext("2d");s.scale(e,e),s.drawImage(t,0,0),s.globalCompositeOperation="multiply",s.fillStyle=qh(this.color_),s.fillRect(0,0,i.width/e,i.height/e),s.globalCompositeOperation="destination-in",s.drawImage(t,0,0),this.canvas_[e]=i}ready(){return this.ready_||(this.ready_=new Promise(e=>{this.imageState_===b.LOADED||this.imageState_===b.ERROR?e():this.addEventListener(B.CHANGE,function t(){(this.imageState_===b.LOADED||this.imageState_===b.ERROR)&&(this.removeEventListener(B.CHANGE,t),e())})})),this.ready_}}function Sr(n,e,t,i,s,r){let o=e===void 0?void 0:ot.get(e,t,s);return o||(o=new uc(n,n instanceof HTMLImageElement?n.src||void 0:e,t,i,s),ot.set(e,t,s,o,r)),r&&o&&!ot.getPattern(e,t,s)&&ot.set(e,t,s,o,r),o}class _n{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){const e=this.getColor();return new _n({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){const t=Sr(null,e.src,"anonymous",void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));t.ready().then(()=>{this.patternImage_=null}),t.getImageState()===b.IDLE&&t.load(),t.getImageState()===b.LOADING&&(this.patternImage_=t)}this.color_=e}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function wo(n,e,t,i,s,r,o){let a,l;const c=(t-e)/i;if(c===1)a=e;else if(c===2)a=e,l=s;else if(c!==0){let h=n[e],u=n[e+1],d=0;const f=[0];for(let _=e+i;_1?o:2,r=r||new Array(o);for(let h=0;h0&&n[1]>0}function fc(n,e,t){return t===void 0&&(t=[0,0]),t[0]=n[0]*e+.5|0,t[1]=n[1]*e+.5|0,t}function Oe(n,e){return Array.isArray(n)?n:(e===void 0?e=[n,n]:(e[0]=n,e[1]=n),e)}class ds{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=Oe(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new ds({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,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 q()}getImage(e){return q()}getHitDetectionImage(){return q()}getPixelRatio(e){return 1}getImageState(){return q()}getImageSize(){return q()}getOrigin(){return q()}getSize(){return q()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Oe(e)}listenImageChange(e){q()}load(){q()}unlistenImageChange(e){q()}ready(){return Promise.resolve()}}function at(n){return n?Array.isArray(n)?Rr(n):typeof n=="object"&&"src"in n?gc(n):n:null}function gc(n){if(!n.offset||!n.size)return ot.getPattern(n.src,"anonymous",n.color);const e=n.src+":"+n.offset,t=ot.getPattern(e,void 0,n.color);if(t)return t;const i=ot.get(n.src,"anonymous",null);if(i.getImageState()!==b.LOADED)return null;const s=pe(n.size[0],n.size[1]);return s.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Sr(s.canvas,e,void 0,b.LOADED,n.color,!0),ot.getPattern(e,void 0,n.color)}const Mn="ol-hidden",mc="ol-selectable",fs="ol-unselectable",Lr="ol-control",Ro="ol-collapsed",_c=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"),To=["style","variant","weight","size","lineHeight","family"],Ba=function(n){const e=n.match(_c);if(!e)return null;const t={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let i=0,s=To.length;iMath.max(s,Zn(n,r)),0);return t[e]=i,i}function Ec(n,e){const t=[],i=[],s=[];let r=0,o=0,a=0,l=0;for(let c=0,h=e.length;c<=h;c+=2){const u=e[c];if(u===` -`||c===h){r=Math.max(r,o),s.push(o),o=0,a+=l;continue}const d=e[c+1]||n.font,f=Zn(d,u);t.push(f),o+=f;const g=yc(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:t,heights:i,lineWidths:s}}function xc(n,e,t,i,s,r,o,a,l,c,h){n.save(),t!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=t:n.globalAlpha*=t),e&&n.transform.apply(n,e),i.contextInstructions?(n.translate(l,c),n.scale(h[0],h[1]),Ic(i,n)):h[0]<0||h[1]<0?(n.translate(l,c),n.scale(h[0],h[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,c,o*h[0],a*h[1]),n.restore()}function Ic(n,e){const t=n.contextInstructions;for(let i=0,s=t.length;ithis.imageState_=b.LOADED),this.render()}clone(){const e=this.getScale(),t=new ds({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(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return t.setOpacity(this.getOpacity()),t}getAnchor(){const e=this.size_,t=this.getDisplacement(),i=this.getScaleArray();return[e[0]/2-t[0]/i[0],e[1]/2+t[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(e){let t=this.canvases_[e];if(!t){const i=this.renderOptions_,s=pe(i.size*e,i.size*e);this.draw_(i,s,e),t=s.canvas,this.canvases_[e]=t}return t}getPixelRatio(e){return e}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(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,t,i){if(t===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return t;let s=this.radius_,r=this.radius2_===void 0?s:this.radius2_;if(sf&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=he(i[0],d,f),p=he(i[1],g,m);if(o&&t&&s){const y=30*s;_+=-y*Math.log(1+Math.max(0,d-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-m)/y)}return[_,p]}}function Tc(n){return n}function br(n,e,t,i){const s=Z(e)/t[0],r=le(e)/t[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function Mr(n,e,t){let i=Math.min(n,e);const s=50;return i*=Math.log(1+s*Math.max(0,n/e-1))/s+1,t&&(i=Math.max(i,t),i/=Math.log(1+s*Math.max(0,t/n-1))/s+1),he(i,t/2,e*2)}function Sc(n,e,t,i){return e=e!==void 0?e:!0,function(s,r,o,a){if(s!==void 0){const l=n[0],c=n[n.length-1],h=t?br(l,t,o,i):l;if(a)return e?Mr(s,h,c):he(s,c,h);const u=Math.min(h,s),d=Math.floor(Jn(n,u,r));return n[d]>h&&d1&&typeof arguments[t-1]=="function"&&(i=arguments[t-1],--t);let s=0;for(;s0}getInteracting(){return this.hints_[ge.INTERACTING]>0}cancelAnimations(){this.setHint(ge.ANIMATING,-this.hints_[ge.ANIMATING]);let e;for(let t=0,i=this.animations_.length;t=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o0?c/l.duration:1;h>=1?(l.complete=!0,h=1):r=!1;const u=l.easing(h);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],m=l.targetCenter[1];this.nextCenter_=l.targetCenter;const _=d+u*(g-d),p=f+u*(m-f);this.targetCenter_=[_,p]}if(l.sourceResolution&&l.targetResolution){const d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=u===1?si(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),t=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(ge.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&An(o,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-t[0],s[1]-t[1]],dr(i,e-this.getRotation()),mh(i,t)),i}calculateCenterZoom(e,t){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=t[0]-e*(t[0]-s[0])/r,a=t[1]-e*(t[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(e){const t=this.viewportSize_;if(e){const i=t[0],s=t[1];return[Math.abs(i*Math.cos(e))+Math.abs(s*Math.sin(e)),Math.abs(i*Math.sin(e))+Math.abs(s*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const e=this.getCenterInternal();return e&&qs(e,this.getProjection())}getCenterInternal(){return this.get(He.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){const t=this.calculateExtentInternal(e);return mr(t,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();const t=this.getCenterInternal();K(t,"The view center is not defined");const i=this.getResolution();K(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return K(s!==void 0,"The view rotation is not defined"),$i(t,i,s,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(He.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(vt(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t=t||this.getViewportSizeMinusPadding_();const i=Z(e)/t[0],s=le(e)/t[1];return Math.max(i,s)}getResolutionForValueFunction(e){e=e||2;const t=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(t/i)/Math.log(e);return function(r){return t/Math.pow(e,r*s)}}getRotation(){return this.get(He.ROTATION)}getValueForResolutionFunction(e){const t=Math.log(e||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/t;return function(o){return Math.log(i/o)/t/r}}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e);const i=this.padding_;return i&&(t=[t[0]-i[1]-i[3],t[1]-i[0]-i[2]]),t}getState(){const e=this.getProjection(),t=this.getResolution(),i=this.getRotation();let s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=Ds(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],t,i)}return{center:s.slice(0),projection:e!==void 0?e:null,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e;const t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,i,s;if(this.resolutions_){const r=Jn(this.resolutions_,e,1);t=r,i=this.resolutions_[r],r==this.resolutions_.length-1?s=2:s=i/this.resolutions_[r+1]}else i=this.maxResolution_,s=this.zoomFactor_;return t+Math.log(i/e)/Math.log(s)}getResolutionForZoom(e){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;const t=he(Math.floor(e),0,this.resolutions_.length-2),i=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/Math.pow(i,he(e-t,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,t){let i;if(K(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){K(!Ai(e),"Cannot fit empty extent provided as `geometry`");const s=vt(e,this.getProjection());i=mo(s)}else if(e.getType()==="Circle"){const s=vt(e.getExtent(),this.getProjection());i=mo(s),i.rotate(this.getRotation(),Tt(s))}else i=e;this.fitInternal(i,t)}rotatedExtentForGeometry(e){const t=this.getRotation(),i=Math.cos(t),s=Math.sin(-t),r=e.getFlatCoordinates(),o=e.getStride();let a=1/0,l=1/0,c=-1/0,h=-1/0;for(let u=0,d=r.length;u{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t;const i=this.getMapInternal();!e&&i&&(e=i.getView()),e instanceof it?t={viewState:e.getState(),extent:e.calculateExtent()}:t=e,!t.layerStatesArray&&i&&(t.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;t.layerStatesArray?s=t.layerStatesArray.find(o=>o.layer===this):s=this.getLayerState();const r=this.getExtent();return Dr(s,t.viewState)&&(!r||Re(r,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];let t;const i=this.getSource();if(i&&(t=i.getAttributions()),!t)return[];const s=e instanceof it?e.getViewStateAndExtent():e;let r=t(s);return Array.isArray(r)||(r=[r]),r}render(e,t){const i=this.getRenderer();return i.prepareFrame(e)?(this.rendered=!0,i.renderFrame(e,t)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,t){}renderDeferred(e){const t=this.getRenderer();t&&t.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(ee.MAP,e)}getMapInternal(){return this.get(ee.MAP)}setMap(e){this.mapPrecomposeKey_&&(ie(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(ie(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=U(e,Xe.PRECOMPOSE,function(t){const s=t.frameState.layerStatesArray,r=this.getLayerState(!1);K(!s.some(function(o){return o.layer===r.layer}),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),s.push(r)},this),this.mapRenderKey_=U(this,B.CHANGE,e.render,e),this.changed())}setSource(e){this.set(ee.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}}function Dr(n,e){if(!n.visible)return!1;const t=e.resolution;if(t=n.maxResolution)return!1;const i=e.zoom;return i>n.minZoom&&i<=n.maxZoom}function Nc(n,e,t,i,s){Xa(n,e,t||0,i||n.length-1,s||Bc)}function Xa(n,e,t,i,s){for(;i>t;){if(i-t>600){var r=i-t+1,o=e-t+1,a=Math.log(r),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(r-l)/r)*(o-r/2<0?-1:1),h=Math.max(t,Math.floor(e-o*l/r+c)),u=Math.min(i,Math.floor(e+(r-o)*l/r+c));Xa(n,e,h,u,s)}var d=n[e],f=t,g=i;for(Xi(n,t,e),s(n[i],d)>0&&Xi(n,t,i);f0;)g--}s(n[t],d)===0?Xi(n,t,g):(g++,Xi(n,g,i)),g<=e&&(t=g+1),e<=g&&(i=g-1)}}function Xi(n,e,t){var i=n[e];n[e]=n[t],n[t]=i}function Bc(n,e){return ne?1:0}let Ya=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!Pn(e,t))return i;const s=this.toBBox,r=[];for(;t;){for(let o=0;o=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(s,r,t)}_split(e,t){const i=e[t],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=_i(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,ui(i,this.toBBox),ui(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=_i([e,t]),this.data.height=e.height+1,this.data.leaf=!1,ui(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let s,r=1/0,o=1/0;for(let a=t;a<=i-t;a++){const l=ji(e,0,a,this.toBBox),c=ji(e,a,i,this.toBBox),h=Yc(l,c),u=Ps(l)+Ps(c);h=t;c--){const h=e.children[c];Ui(a,e.leaf?r(h):h),l+=Dn(a)}return l}_adjustParentBBoxes(e,t,i){for(let s=i;s>=0;s--)Ui(t[s],e)}_condense(e){for(let t=e.length-1,i;t>=0;t--)e[t].children.length===0?t>0?(i=e[t-1].children,i.splice(i.indexOf(e[t]),1)):this.clear():ui(e[t],this.toBBox)}};function Gc(n,e,t){if(!t)return e.indexOf(n);for(let i=0;i=n.minX&&e.maxY>=n.minY}function _i(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function bo(n,e,t,i,s){const r=[e,t];for(;r.length;){if(t=r.pop(),e=r.pop(),t-e<=i)continue;const o=e+Math.ceil((t-e)/i/2)*i;Nc(n,o,e,t,s),r.push(e,o,o,t)}}function Mo(n,e,t,i){return t!==void 0&&i!==void 0?[t/n,i/e]:t!==void 0?t/n:i!==void 0?i/e:1}class yn extends cs{constructor(e){e=e||{};const t=e.opacity!==void 0?e.opacity:1,i=e.rotation!==void 0?e.rotation:0,s=e.scale!==void 0?e.scale:1,r=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:t,rotation:i,scale:s,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:r,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;const o=e.img!==void 0?e.img:null;let a=e.src;K(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||J(o)),K(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),K(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(e.src!==void 0?l=b.IDLE:o!==void 0&&(o instanceof HTMLImageElement?o.complete?l=o.src?b.LOADED:b.IDLE:l=b.LOADING:l=b.LOADED),this.color_=e.color!==void 0?nn(e.color):null,this.iconImage_=Rr(o,a,this.crossOrigin_,l,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,e.width!==void 0||e.height!==void 0){let c,h;if(e.size)[c,h]=e.size;else{const u=this.getImage(1);if(u.width&&u.height)c=u.width,h=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=e;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(Mo(f[0],f[1],e.width,e.height))};this.listenImageChange(d);return}}c!==void 0&&this.setScale(Mo(c,h,e.width,e.height))}}clone(){let e,t,i;return this.initialOptions_?(t=this.initialOptions_.width,i=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new yn({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:e,width:t,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;const s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=s[0]),this.anchorYUnits_=="fraction"&&(e[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+s[1])}this.normalizedAnchor_=e}const t=this.getDisplacement(),i=this.getScaleArray();return[e[0]-t[0]/i[0],e[1]+t[1]/i[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){const t=this.getSize(),i=this.iconImage_.getSize();if(!t||!i)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=i[0]-t[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=i[1]-t[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==b.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){const e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==b.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(B.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(B.CHANGE,e)}ready(){return this.iconImage_.ready()}}let Pi=0;const Oi=0,re=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"},Kc={[v.Get]:N(([n,e])=>e!==void 0?Vc(e.value):Ee,X(1,2),Hc),[v.Var]:N(([n])=>n.type,X(1,1),qc),[v.Id]:N(M|Pe,Yi,$c),[v.Concat]:N(Pe,X(2,1/0),V(Ee)),[v.GeometryType]:N(Pe,Yi,Jc),[v.Resolution]:N(M,Yi),[v.Zoom]:N(M,Yi),[v.Time]:N(M,Yi),[v.Any]:N(re,X(2,1/0),V(re)),[v.All]:N(re,X(2,1/0),V(re)),[v.Not]:N(re,X(1,1),V(re)),[v.Equal]:N(re,X(2,2),V(Ee),Mt),[v.NotEqual]:N(re,X(2,2),V(Ee),Mt),[v.GreaterThan]:N(re,X(2,2),V(Ee),Mt),[v.GreaterThanOrEqualTo]:N(re,X(2,2),V(Ee),Mt),[v.LessThan]:N(re,X(2,2),V(Ee),Mt),[v.LessThanOrEqualTo]:N(re,X(2,2),V(Ee),Mt),[v.Multiply]:N(n=>{let e=M|me;for(let t=0;t{let e=Ee;for(let t=1;t{let e=Ee;for(let t=2;t{let e=me|M;for(let t=3;t{let e=Ee;for(let t=1;tn.length===3||n.length===4?St|me:St,X(1,1/0),V(M)),[v.Color]:N(me,X(1,4),V(M)),[v.Band]:N(M,X(1,3),V(M)),[v.Palette]:N(me,X(2,2),su),[v.ToString]:N(Pe,X(1,1),V(re|M|Pe|me))};function Hc(n,e){const t=$(n[1],e);if(!(t instanceof Gt))throw new Error("Expected a literal argument for get operation");if(typeof t.value!="string")throw new Error("Expected a string argument for get operation");if(e.properties.add(t.value),n.length===3){const i=$(n[2],e);return[t,i]}return[t]}function qc(n,e,t,i){const s=n[1];if(typeof s!="string")throw new Error("Expected a string argument for var operation");if(e.variables.add(s),!("variables"in e.style)||e.style.variables[s]===void 0)return[new Gt(Ee,s)];const r=e.style.variables[s],o=$(r,e);if(o.value=s,i&&!lt(i,o.type))throw new Error(`The variable ${s} has type ${Ie(o.type)} but the following type was expected: ${Ie(i)}`);return[o]}function $c(n,e){e.featureId=!0}function Jc(n,e){e.geometryType=!0}function Yi(n,e){const t=n[0];if(n.length!==1)throw new Error(`Expected no arguments for ${t} operation`);return[]}function X(n,e){return function(t,i){const s=t[0],r=t.length-1;if(n===e){if(r!==n){const o=n===1?"":"s";throw new Error(`Expected ${n} argument${o} for ${s}, got ${r}`)}}else if(re){const o=e===1/0?`${n} or more`:`${n} to ${e}`;throw new Error(`Expected ${o} arguments for ${s}, got ${r}`)}}}function V(n){return function(e,t){const i=e[0],s=e.length-1,r=new Array(s);for(let o=0;oi.featureId;case v.GeometryType:return i=>i.geometryType;case v.Concat:{const i=n.args.map(s=>Je(s));return s=>"".concat(...i.map(r=>r(s).toString()))}case v.Resolution:return i=>i.resolution;case v.Any:case v.All:case v.Between:case v.In:case v.Not:return hu(n);case v.Equal:case v.NotEqual:case v.LessThan:case v.LessThanOrEqualTo:case v.GreaterThan:case v.GreaterThanOrEqualTo:return lu(n);case v.Multiply:case v.Divide:case v.Add:case v.Subtract:case v.Clamp:case v.Mod:case v.Pow:case v.Abs:case v.Floor:case v.Ceil:case v.Round:case v.Sin:case v.Cos:case v.Atan:case v.Sqrt:return cu(n);case v.Case:return uu(n);case v.Match:return du(n);case v.Interpolate:return fu(n);case v.ToString:return gu(n);default:throw new Error(`Unsupported operator ${t}`)}}function ou(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;os.properties[i];case v.Var:return s=>s.variables[i];default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function lu(n,e){const t=n.operator,i=Je(n.args[0]),s=Je(n.args[1]);switch(t){case v.Equal:return r=>i(r)===s(r);case v.NotEqual:return r=>i(r)!==s(r);case v.LessThan:return r=>i(r)i(r)<=s(r);case v.GreaterThan:return r=>i(r)>s(r);case v.GreaterThanOrEqualTo:return r=>i(r)>=s(r);default:throw new Error(`Unsupported comparison operator ${t}`)}}function hu(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;o{const o=s[0](r),a=s[1](r),l=s[2](r);return o>=a&&o<=l};case v.In:return r=>{const o=s[0](r);for(let a=1;a!s[0](r);default:throw new Error(`Unsupported logical operator ${t}`)}}function cu(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{let o=1;for(let a=0;as[0](r)/s[1](r);case v.Add:return r=>{let o=0;for(let a=0;as[0](r)-s[1](r);case v.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(ol?l:o};case v.Mod:return r=>s[0](r)%s[1](r);case v.Pow:return r=>Math.pow(s[0](r),s[1](r));case v.Abs:return r=>Math.abs(s[0](r));case v.Floor:return r=>Math.floor(s[0](r));case v.Ceil:return r=>Math.ceil(s[0](r));case v.Round:return r=>Math.round(s[0](r));case v.Sin:return r=>Math.sin(s[0](r));case v.Cos:return r=>Math.cos(s[0](r));case v.Atan:return i===2?r=>Math.atan2(s[0](r),s[1](r)):r=>Math.atan(s[0](r));case v.Sqrt:return r=>Math.sqrt(s[0](r));default:throw new Error(`Unsupported numeric operator ${t}`)}}function uu(n,e){const t=n.args.length,i=new Array(t);for(let s=0;s{for(let r=0;r{const r=i[0](s);for(let o=1;o{const r=i[0](s),o=i[1](s);let a,l;for(let c=2;c=o)return c===2?u:d?mu(r,o,a,l,h,u):Zi(r,o,a,l,h,u);a=h,l=u}return l}}function gu(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{const o=s[0](r);return n.args[0].type===me?wr(o):o.toString()};default:throw new Error(`Unsupported convert operator ${t}`)}}function Zi(n,e,t,i,s,r){const o=s-t;if(o===0)return i;const a=e-t,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function mu(n,e,t,i,s,r){if(s-t===0)return i;const a=yo(i),l=yo(r);let c=l[2]-a[2];c>180?c-=360:c<-180&&(c+=360);const h=[Zi(n,e,t,a[0],s,l[0]),Zi(n,e,t,a[1],s,l[1]),a[2]+Zi(n,e,t,0,s,c),Zi(n,e,t,i[3],s,r[3])];return La(Qh(h))}function _u(n){return!0}function pu(n){const e=Ua(),t=yu(n,e),i=Va();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,e.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return e.geometryType&&(i.geometryType=Za(s.getGeometry())),t(i)}}function Do(n){const e=Ua(),t=n.length,i=new Array(t);for(let o=0;o4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return t}function $a(n,e){const t=En(n,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function bu(n,e){return typeof n=="number"?n:$a(n,e)}const Fo={RENDER_ORDER:"renderOrder"};class Ja extends pn{constructor(e){e=e||{};const t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Fo.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){const i=this.getDeclutter();i in e.declutter||(e.declutter[i]=new Ya(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(Fo.RENDER_ORDER,e)}setStyle(e){this.style_=Mu(e),this.styleFunction_=e===null?void 0:vc(this.style_),this.changed()}}function Mu(n){if(n===void 0)return wc;if(!n)return null;if(typeof n=="function"||n instanceof Ki)return n;if(!Array.isArray(n))return Do([n]);if(n.length===0)return[];const e=n.length,t=n[0];if(t instanceof Ki){const s=new Array(e);for(let r=0;rl&&(this.instructions.push([A.CUSTOM,l,h,e,i,Ii,r]),this.hitDetectionInstructions.push([A.CUSTOM,l,h,e,s||i,Ii,r]));break;case"Point":c=e.getFlatCoordinates(),this.coordinates.push(c[0],c[1]),h=this.coordinates.length,this.instructions.push([A.CUSTOM,l,h,e,i,void 0,r]),this.hitDetectionInstructions.push([A.CUSTOM,l,h,e,s||i,void 0,r]);break}this.endGeometry(t)}beginGeometry(e,t,i){this.beginGeometryInstruction1_=[A.BEGIN_GEOMETRY,t,0,e,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[A.BEGIN_GEOMETRY,t,0,e,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const e=this.hitDetectionInstructions;e.reverse();let t;const i=e.length;let s,r,o=-1;for(t=0;tthis.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(e){const t=e.fillStyle,i=[A.SET_FILL_STYLE,t];return typeof t!="string"&&i.push(e.fillPatternScale),i}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[A.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,this.applyPixelRatio(e.lineDash),e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){const i=e.fillStyle;(typeof i!="string"||e.currentFillStyle!=i)&&(i!==void 0&&this.instructions.push(t.call(this,e)),e.currentFillStyle=i)}updateStrokeStyle(e,t){const i=e.strokeStyle,s=e.lineCap,r=e.lineDash,o=e.lineDashOffset,a=e.lineJoin,l=e.lineWidth,c=e.miterLimit;(e.currentStrokeStyle!=i||e.currentLineCap!=s||r!=e.currentLineDash&&!Kt(e.currentLineDash,r)||e.currentLineDashOffset!=o||e.currentLineJoin!=a||e.currentLineWidth!=l||e.currentMiterLimit!=c)&&(i!==void 0&&t.call(this,e),e.currentStrokeStyle=i,e.currentLineCap=s,e.currentLineDash=r,e.currentLineDashOffset=o,e.currentLineJoin=a,e.currentLineWidth=l,e.currentMiterLimit=c)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const t=[A.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=ra(this.maxExtent),this.maxLineWidth>0)){const e=this.resolution*(this.maxLineWidth+1)/2;cr(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Au extends xn{constructor(e,t,i,s){super(e,t,i,s),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(e,t,i){if(!this.image_||this.maxExtent&&!ri(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,i);const s=e.getFlatCoordinates(),r=e.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([A.DRAW_IMAGE,o,a,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([A.DRAW_IMAGE,o,a,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(t)}drawMultiPoint(e,t,i){if(!this.image_)return;this.beginGeometry(e,t,i);const s=e.getFlatCoordinates(),r=[];for(let l=0,c=s.length;l=n){const g=(n-a+f)/f,m=We(c,u,g),_=We(h,d,g);l.push(m,_),r.push(l),l=[m,_],a==n&&(o+=s),a=0}else if(a0&&r.push(l),r}function Nu(n,e,t,i,s){let r=t,o=t,a=0,l=0,c=t,h,u,d,f,g,m,_,p,y,E;for(u=t;un&&(l>a&&(a=l,r=c,o=u),l=0,c=u-s)),d=f,_=y,p=E),g=x,m=I}return l+=f,l>a?[c,u]:[r,o]}const Hn={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Bu extends xn{constructor(e,t,i,s){super(e,t,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[be]={fillStyle:be},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 e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,t,i){const s=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!s&&!r)return;const a=this.coordinates;let l=a.length;const c=e.getType();let h=null,u=e.getStride();if(o.placement==="line"&&(c=="LineString"||c=="MultiLineString"||c=="Polygon"||c=="MultiPolygon")){if(!Re(this.maxExtent,e.getExtent()))return;let d;if(h=e.getFlatCoordinates(),c=="LineString")d=[h.length];else if(c=="MultiLineString")d=e.getEnds();else if(c=="Polygon")d=e.getEnds().slice(0,1);else if(c=="MultiPolygon"){const _=e.getEndss();d=[];for(let p=0,y=_.length;p{const I=a[(y+x)*2]===h[x*u]&&a[(y+x)*2+1]===h[x*u+1];return I||--y,I})}this.saveTextStates_(),(o.backgroundFill||o.backgroundStroke)&&(this.setFillStrokeStyle(o.backgroundFill,o.backgroundStroke),o.backgroundFill&&this.updateFillStyle(this.state,this.createFill),o.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(e,t,i);let g=o.padding;if(g!=ti&&(o.scale[0]<0||o.scale[1]<0)){let y=o.padding[0],E=o.padding[1],x=o.padding[2],I=o.padding[3];o.scale[0]<0&&(E=-E,I=-I),o.scale[1]<0&&(y=-y,x=-x),g=[y,E,x,I]}const m=this.pixelRatio;this.instructions.push([A.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==ti?ti:g.map(function(y){return y*m}),!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const _=1/m,p=this.state.fillStyle;o.backgroundFill&&(this.state.fillStyle=be,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([A.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[_,_],NaN,this.declutterMode_,this.declutterImageWithText_,g,!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?be:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),o.backgroundFill&&(this.state.fillStyle=p,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(t)}}saveTextStates_(){const e=this.textStrokeState_,t=this.textState_,i=this.textFillState_,s=this.strokeKey_;e&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:t.font,textAlign:t.textAlign||on,justify:t.justify,textBaseline:t.textBaseline||Un,scale:t.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(e,t){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,c=Hn[s.textBaseline],h=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([A.DRAW_CHARS,e,t,c,s.overflow,a,s.maxAngle,l,h,r,d*l,u,o,1,this.declutterMode_]),this.hitDetectionInstructions.push([A.DRAW_CHARS,e,t,c,s.overflow,a&&be,s.maxAngle,l,h,r,d*l,u,o,1/l,this.declutterMode_])}setTextStyle(e,t){let i,s,r;if(!e)this.text_="";else{const o=e.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=at(o.getColor()||be)):(s=null,this.textFillState_=s);const a=e.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const g=a.getLineDash(),m=a.getLineDashOffset(),_=a.getWidth(),p=a.getMiterLimit();r.lineCap=a.getLineCap()||bi,r.lineDash=g?g.slice():Ct,r.lineDashOffset=m===void 0?Rt:m,r.lineJoin=a.getLineJoin()||Mi,r.lineWidth=_===void 0?an:_,r.miterLimit=p===void 0?sn:p,r.strokeStyle=at(a.getColor()||rn)}i=this.textState_;const l=e.getFont()||Ba;pc(l);const c=e.getScaleArray();i.overflow=e.getOverflow(),i.font=l,i.maxAngle=e.getMaxAngle(),i.placement=e.getPlacement(),i.textAlign=e.getTextAlign(),i.repeat=e.getRepeat(),i.justify=e.getJustify(),i.textBaseline=e.getTextBaseline()||Un,i.backgroundFill=e.getBackgroundFill(),i.backgroundStroke=e.getBackgroundStroke(),i.padding=e.getPadding()||ti,i.scale=c===void 0?[1,1]:c;const h=e.getOffsetX(),u=e.getOffsetY(),d=e.getRotateWithView(),f=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=h===void 0?0:h,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textRotation_=f===void 0?0:f,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:J(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=s&&s.fillStyle?typeof s.fillStyle=="string"?s.fillStyle:"|"+J(s.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}const Gu={Circle:Bo,Default:xn,Image:Du,LineString:Ou,Polygon:Bo,Text:Bu};class zu{constructor(e,t,i,s){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const e={};for(const t in this.buildersByZIndex_){e[t]=e[t]||{};const i=this.buildersByZIndex_[t];for(const s in i){const r=i[s].finish();e[t][s]=r}}return e}getBuilder(e,t){const i=e!==void 0?e.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[t];if(r===void 0){const o=Gu[t];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[t]=r}return r}}class Wu extends gn{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.declutterExecutorGroup=null}getFeatures(e){return q()}getData(e){return null}prepareFrame(e){return q()}renderFrame(e,t){return q()}loadedTileCallback(e,t,i){e[t]||(e[t]={}),e[t][i.tileCoord.toString()]=i}createLoadedTileFinder(e,t,i){return(s,r)=>{const o=this.loadedTileCallback.bind(this,i,s);return e.forEachLoadedTile(t,s,r,o)}}forEachFeatureAtCoordinate(e,t,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){const t=e.target;(t.getState()===b.LOADED||t.getState()===b.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=b.LOADED&&t!=b.ERROR&&e.addEventListener(B.CHANGE,this.boundHandleImageChange_),t==b.IDLE&&(e.load(),t=e.getState()),t==b.LOADED}renderIfReadyAndVisible(){const e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}}class el extends ct{constructor(e,t,i,s){super(e),this.inversePixelTransform=t,this.frameState=i,this.context=s}}class tl{constructor(){$r(this,"pushMethodArgs_",(...e)=>(this.instructions_[this.zIndex+this.offset_].push(e),this));this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(CanvasRenderingContext2D.prototype,{get:(e,t)=>{if(typeof $s()[t]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(t),this.pushMethodArgs_},set:(e,t,i)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(t,i),!0)})}getContext(){return this.context_}draw(e){this.instructions_.forEach(t=>{for(let i=0,s=t.length;iL[2]}else P=x>S;const F=Math.PI,Y=[],G=C+i===e;e=C,_=0,p=R,d=n[e],f=n[e+1];let z;if(G){y(),z=Math.atan2(f-m,d-g),P&&(z+=z>0?-F:F);const L=(S+x)/2,k=(O+I)/2;return Y[0]=[L,k,(w-r)/2,z,s],Y}s=s.replace(/\n/g," ");for(let L=0,k=s.length;L0?-F:F),z!==void 0){let T=W-z;if(T+=T>F?-2*F:T<-F?2*F:0,Math.abs(T)>o)return null}z=W;const te=L;let j=0;for(;L0&&n.push(` -`,""),n.push(e,""),n}class Uu{constructor(e,t,i,s,r){this.overlaps=i,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=qe(),this.hitDetectionInstructions=s.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=s.fillStates||{},this.strokeStates=s.strokeStates||{},this.textStates=s.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new tl:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,i,s){const r=e+t+i+s;if(this.labels_[r])return this.labels_[r];const o=s?this.strokeStates[s]:null,a=i?this.fillStates[i]:null,l=this.textStates[t],c=this.pixelRatio,h=[l.scale[0]*c,l.scale[1]*c],u=Array.isArray(e),d=l.justify?Hn[l.justify]:ks(Array.isArray(e)?e[0]:e,l.textAlign||on),f=s&&o.lineWidth?o.lineWidth:0,g=u?e:e.split(` -`).reduce(ju,[]),{width:m,height:_,widths:p,heights:y,lineWidths:E}=Ec(l,g),x=m+f,I=[],C=(x+2)*h[0],R=(_+f)*h[1],w={width:C<0?Math.floor(C):Math.ceil(C),height:R<0?Math.floor(R):Math.ceil(R),contextInstructions:I};(h[0]!=1||h[1]!=1)&&I.push("scale",h),s&&(I.push("strokeStyle",o.strokeStyle),I.push("lineWidth",f),I.push("lineCap",o.lineCap),I.push("lineJoin",o.lineJoin),I.push("miterLimit",o.miterLimit),I.push("setLineDash",[o.lineDash]),I.push("lineDashOffset",o.lineDashOffset)),i&&I.push("fillStyle",a.fillStyle),I.push("textBaseline","middle"),I.push("textAlign","center");const S=.5-d;let O=d*x+S*f;const P=[],F=[];let Y=0,G=0,z=0,L=0,k;for(let W=0,te=g.length;We?e-c:r,x=o+h>t?t-h:o,I=g[3]+E*d[0]+g[1],C=g[0]+x*d[1]+g[2],R=p-g[3],w=y-g[0];(m||u!==0)&&(At[0]=R,Dt[0]=R,At[1]=w,_t[1]=w,_t[0]=R+I,pt[0]=_t[0],pt[1]=w+C,Dt[1]=pt[1]);let S;return u!==0?(S=je(qe(),i,s,1,1,u,-i,-s),ue(S,At),ue(S,_t),ue(S,pt),ue(S,Dt),Zt(Math.min(At[0],_t[0],pt[0],Dt[0]),Math.min(At[1],_t[1],pt[1],Dt[1]),Math.max(At[0],_t[0],pt[0],Dt[0]),Math.max(At[1],_t[1],pt[1],Dt[1]),di)):Zt(Math.min(R,R+I),Math.min(w,w+C),Math.max(R,R+I),Math.max(w,w+C),di),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:E,drawImageH:x,originX:c,originY:h,declutterBox:{minX:di[0],minY:di[1],maxX:di[2],maxY:di[3],value:_},canvasTransform:S,scale:d}}replayImageOrLabel_(e,t,i,s,r,o,a){const l=!!(o||a),c=s.declutterBox,h=a?a[2]*s.scale[0]/2:0;return c.minX-h<=t[0]&&c.maxX+h>=0&&c.minY-h<=t[1]&&c.maxY+h>=0&&(l&&this.replayTextBackground_(e,At,_t,pt,Dt,o,a),xc(e,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(e){const t=this.alignAndScaleFill_;if(t){const i=ue(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;e.save(),e.translate(i[0]%s,i[1]%s),t!==1&&e.scale(t,t),e.rotate(this.viewRotation_)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6])}drawLabelWithPointPlacement_(e,t,i,s){const r=this.textStates[t],o=this.createLabel(e,t,s,i),a=this.strokeStates[i],l=this.pixelRatio,c=ks(Array.isArray(e)?e[0]:e,r.textAlign||on),h=Hn[r.textBaseline||Un],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=c*d+2*(.5-c)*u,g=h*o.height/l+2*(.5-h)*u;return{label:o,anchorX:f,anchorY:g}}execute_(e,t,i,s,r,o,a,l){const c=this.zIndexContext_;let h;this.pixelCoordinates_&&Kt(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=Xt(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),ql(this.renderedTransform_,i));let u=0;const d=s.length;let f=0,g,m,_,p,y,E,x,I,C,R,w,S,O,P=0,F=0,Y=null,G=null;const z=this.coordinateCache_,L=this.viewRotation_,k=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,W={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:L},te=this.instructions!=s||this.overlaps?0:200;let j,Q,H,ae;for(;ute&&(this.fill_(e),P=0),F>te&&(e.stroke(),F=0),!P&&!F&&(e.beginPath(),y=NaN,E=NaN),++u;break;case A.CIRCLE:f=T[1];const Ae=h[f],ce=h[f+1],Te=h[f+2],Ze=h[f+3],Se=Te-Ae,Fi=Ze-ce,Ht=Math.sqrt(Se*Se+Fi*Fi);e.moveTo(Ae+Ht,ce),e.arc(Ae,ce,Ht,0,2*Math.PI,!0),++u;break;case A.CLOSE_PATH:e.closePath(),++u;break;case A.CUSTOM:f=T[1],g=T[2];const xs=T[3],wn=T[4],Cn=T[5];W.geometry=xs,W.feature=j,u in z||(z[u]=[]);const ke=z[u];Cn?Cn(h,f,g,2,ke):(ke[0]=h[f],ke[1]=h[f+1],ke.length=2),c&&(c.zIndex=T[6]),wn(ke,W),++u;break;case A.DRAW_IMAGE:f=T[1],g=T[2],C=T[3],m=T[4],_=T[5];let ai=T[6];const Rn=T[7],Is=T[8],Tn=T[9],Sn=T[10];let De=T[11];const Ve=T[12];let et=T[13];p=T[14]||"declutter";const Ke=T[15];if(!C&&T.length>=20){R=T[19],w=T[20],S=T[21],O=T[22];const Fe=this.drawLabelWithPointPlacement_(R,w,S,O);C=Fe.label,T[3]=C;const qt=T[23];m=(Fe.anchorX-qt)*this.pixelRatio,T[4]=m;const Ne=T[24];_=(Fe.anchorY-Ne)*this.pixelRatio,T[5]=_,ai=C.height,T[6]=ai,et=C.width,T[13]=et}let li;T.length>25&&(li=T[25]);let hi,bt,dt;T.length>17?(hi=T[16],bt=T[17],dt=T[18]):(hi=ti,bt=!1,dt=!1),Sn&&k?De+=L:!Sn&&!k&&(De-=L);let vs=0;for(;f!il.includes(n));class Vu{constructor(e,t,i,s,r,o,a){this.maxExtent_=e,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=t,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=qe(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(e,t){const i=this.getClipCoords(t);e.beginPath(),e.moveTo(i[0],i[1]),e.lineTo(i[2],i[3]),e.lineTo(i[4],i[5]),e.lineTo(i[6],i[7]),e.clip()}createExecutors_(e,t){for(const i in e){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=e[i];for(const o in r){const a=r[o];s[o]=new Uu(this.resolution_,this.pixelRatio_,this.overlaps_,a,t)}}}hasExecutors(e){for(const t in this.executorsByZIndex_){const i=this.executorsByZIndex_[t];for(let s=0,r=e.length;s0){if(!o||f!=="Image"&&f!=="Text"||o.includes(I)){const O=(d[w]-3)/4,P=s-O%a,F=s-(O/a|0),Y=r(I,C,P*P+F*F);if(Y)return Y}h.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(wt);let _,p,y,E,x;for(_=m.length-1;_>=0;--_){const I=m[_].toString();for(y=this.executorsByZIndex_[I],p=Hi.length-1;p>=0;--p)if(f=Hi[p],E=y[f],E!==void 0&&(x=E.executeHitDetection(h,l,i,g,u),x))return x}}getClipCoords(e){const t=this.maxExtent_;if(!t)return null;const i=t[0],s=t[1],r=t[2],o=t[3],a=[i,s,i,o,r,o,r,s];return Xt(a,0,8,2,e,a),a}isEmpty(){return Si(this.executorsByZIndex_)}execute(e,t,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(wt),o=o||Hi;let c,h,u,d,f,g;for(a&&l.reverse(),c=0,h=l.length;c{r.draw(this.renderedContext_),r.clear()})}}const Fs={};function Ku(n){if(Fs[n]!==void 0)return Fs[n];const e=n*2+1,t=n*n,i=new Array(t+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>t)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*e+(n+o))*4+3),r>0&&l.push(((n-r)*e+(n+o))*4+3),o>0&&(l.push(((n+r)*e+(n-o))*4+3),r>0&&l.push(((n-r)*e+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;ru*this.pixelRatio_),lineDashOffset:(o||Rt)*this.pixelRatio_,lineJoin:a!==void 0?a:Mi,lineWidth:(l!==void 0?l:an)*this.pixelRatio_,miterLimit:c!==void 0?c:sn,strokeStyle:at(i||rn)}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}const i=e.getPixelRatio(this.pixelRatio_),s=e.getAnchor(),r=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[1]*i,this.imageHeight_=t[1]*i,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();const o=e.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=t[0]*i}setTextStyle(e){if(!e)this.text_="";else{const t=e.getFill();if(!t)this.textFillState_=null;else{const f=t.getColor();this.textFillState_={fillStyle:at(f||be)}}const i=e.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),m=i.getLineDash(),_=i.getLineDashOffset(),p=i.getLineJoin(),y=i.getWidth(),E=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:bi,lineDash:m||Ct,lineDashOffset:_||Rt,lineJoin:p!==void 0?p:Mi,lineWidth:y!==void 0?y:an,miterLimit:E!==void 0?E:sn,strokeStyle:at(f||rn)}}const s=e.getFont(),r=e.getOffsetX(),o=e.getOffsetY(),a=e.getRotateWithView(),l=e.getRotation(),c=e.getScaleArray(),h=e.getText(),u=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:s!==void 0?s:Ba,textAlign:u!==void 0?u:on,textBaseline:d!==void 0?d:Un},this.text_=h!==void 0?Array.isArray(h)?h.reduce((f,g,m)=>f+=m%2?" ":g,""):h:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*c[0],this.pixelRatio_*c[1]]}}}const qu=Hu,nt=.5;function $u(n,e,t,i,s,r,o,a,l){const c=l?mr(s):s,h=n[0]*nt,u=n[1]*nt,d=pe(h,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new qu(d,nt,s,null,o,a,l?os(Rh(),l):null),m=t.length,_=Math.floor((256*256*256-1)/m),p={};for(let E=1;E<=m;++E){const x=t[E-1],I=x.getStyleFunction()||i;if(!I)continue;let C=I(x,r);if(!C)continue;Array.isArray(C)||(C=[C]);const w=(E*_).toString(16).padStart(7,"#00000");for(let S=0,O=C.length;S0;return u&&Promise.all(l).then(()=>s(null)),id(n,e,t,i,r,o,a),u}function id(n,e,t,i,s,r,o){const a=t.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(i,s);if(t.getRenderer())rl(n,l,t,e,o);else{const h=nl[l.getType()];h(n,l,t,e,o,r)}}function rl(n,e,t,i,s){if(e.getType()=="GeometryCollection"){const o=e.getGeometries();for(let a=0,l=o.length;a{if(!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=[this.context.canvas.width,this.context.canvas.height];ue(this.pixelTransform,i);const s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,c=this.getLayer(),h=[],u=i[0]*nt,d=i[1]*nt;h.push(this.getRenderTransform(s,r,o,nt,u,d,0).slice());const f=c.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!rt(g,l)){let m=l[0];const _=Z(g);let p=0,y;for(;mg[2];)++p,y=_*p,h.push(this.getRenderTransform(s,r,o,nt,u,d,y).slice()),m-=_}this.hitDetectionImageData_=$u(i,h,this.renderedFeatures_,c.getStyleFunction(),l,r,o,Xo(r,this.renderedPixelRatio_),null)}t(Ju(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,i,s,r){if(!this.replayGroup_)return;const o=t.viewState.resolution,a=t.viewState.rotation,l=this.getLayer(),c={},h=function(g,m,_){const p=J(g),y=c[p];if(y){if(y!==!0&&_u=g.forEachFeatureAtCoordinate(e,o,a,i,h,f&&t.declutter[f]?t.declutter[f].all().map(m=>m.value):null)),u}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){const t=this.getLayer(),i=t.getSource();if(!i)return!1;const s=e.viewHints[ge.ANIMATING],r=e.viewHints[ge.INTERACTING],o=t.getUpdateWhileAnimating(),a=t.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=e.extent,c=e.viewState,h=c.projection,u=c.resolution,d=e.pixelRatio,f=t.getRevision(),g=t.getRenderBuffer();let m=t.getRenderOrder();m===void 0&&(m=ed);const _=c.center.slice(),p=cr(l,g*u),y=p.slice(),E=[p.slice()],x=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!rt(x,e.extent)){const G=Z(x),z=Math.max(Z(p)/2,G);p[0]=x[0]-z,p[2]=x[2]+z,ga(_,h);const L=ua(E[0],h);L[0]x[0]&&L[2]>x[2]&&E.push([L[0]-G,L[1],L[2]-G,L[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&rt(this.wrappedRenderedExtent_,p))return Kt(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const I=new zu(sl(u,d),p,u,d);let C;for(let G=0,z=E.length;G{let L;const k=G.getStyleFunction()||t.getStyleFunction();if(k&&(L=k(G,u)),L){const W=this.renderFeature(G,R,L,I,C,this.getLayer().getDeclutter(),z);w=w&&!W}},O=mr(p),P=i.getFeaturesInExtent(O);m&&P.sort(m);for(let G=0,z=P.length;G{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),t&&this.simplifiedGeometry_.applyTransform(t);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=pr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=Fh(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,i,0,s);break;case"Polygon":s=[],i.length=Ia(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),i,0,s);break}return s&&(this.simplifiedGeometry_=new ze(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}}ze.prototype.getFlatCoordinates=ze.prototype.getOrientedFlatCoordinates;class kr extends Qe{constructor(e){super(),this.projection=ve(e.projection),this.attributions_=Zo(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible!==void 0?e.attributionsCollapsible:!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;const t=this;this.viewPromise_=new Promise(function(i,s){t.viewResolver=i,t.viewRejector=s})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=Zo(e),this.changed()}setState(e){this.state_=e,this.changed()}}function Zo(n){return n?Array.isArray(n)?function(e){return n}:typeof n=="function"?n:function(e){return[n]}:null}const Ge={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function dd(n,e){return[[-1/0,-1/0,1/0,1/0]]}let fd=!1;function gd(n,e,t,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(t,i,s):n,!0),e.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=fd,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const c=e.getType();let h;c=="json"?h=JSON.parse(a.responseText):c=="text"?h=a.responseText:c=="xml"?(h=a.responseXML,h||(h=new DOMParser().parseFromString(a.responseText,"application/xml"))):c=="arraybuffer"&&(h=a.response),h?r(e.readFeatures(h,{extent:t,featureProjection:s}),e.readProjection(h)):o()}else o()},a.onerror=o,a.send()}function Vo(n,e){return function(t,i,s,r,o){const a=this;gd(n,e,t,i,s,function(l,c){a.addFeatures(l),r!==void 0&&r(l)},o||Ti)}}class Pt extends ct{constructor(e,t,i){super(e),this.feature=t,this.features=i}}class al extends kr{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=Ti,this.format_=e.format,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(K(this.format_,"`format` must be set when `url` is set"),this.loader_=Vo(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:dd;const t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new jo:null,this.loadedExtentsRtree_=new jo,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(e.features)?s=e.features:e.features&&(i=e.features,s=i.getArray()),!t&&i===void 0&&(i=new st(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){const t=J(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);const i=e.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new Pt(Ge.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof ze||(this.featureChangeKeys_[e]=[U(t,B.CHANGE,this.handleFeatureChange_,this),U(t,Ri.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let i=!0;if(t.getId()!==void 0){const s=String(t.getId());if(!(s in this.idIndex_))this.idIndex_[s]=t;else if(t instanceof ze){const r=this.idIndex_[s];r instanceof ze?Array.isArray(r)?r.push(t):this.idIndex_[s]=[r,t]:i=!1}else i=!1}return i&&(K(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),i}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){const t=[],i=[],s=[];for(let r=0,o=e.length;r{t||(t=!0,this.addFeature(i.element),t=!1)}),e.addEventListener(Le.REMOVE,i=>{t||(t=!0,this.removeFeature(i.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(ie);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){const i=s=>{this.removeFeatureInternal(s)};this.featuresRtree_.forEach(i);for(const s in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[s])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const t=new Pt(Ge.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){const i=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(i,function(s){const r=s.getGeometry();if(r instanceof ze||r.intersectsCoordinate(e))return t(s)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(i){const s=i.getGeometry();if(s instanceof ze||s.intersectsExtent(e)){const r=t(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),Si(this.nullGeometryFeatures_)||ar(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){const t=[];return this.forEachFeatureAtCoordinateDirect(e,function(i){t.push(i)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);const s=nh(e,t);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){const i=e[0],s=e[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return t=t||qi,this.featuresRtree_.forEachInExtent(l,function(c){if(t(c)){const h=c.getGeometry(),u=a;if(a=h instanceof ze?0:h.closestPointXY(i,s,o,a),a{--this.loadingExtentsCount_,this.dispatchEvent(new Pt(Ge.FEATURESLOADEND,void 0,h))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Pt(Ge.FEATURESLOADERROR))}),s.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){const t=this.loadedExtentsRtree_;let i;t.forEachInExtent(e,function(s){if(Li(s.extent,e))return i=s,!0}),i&&t.remove(i)}removeFeatures(e){const t=[];for(let i=0,s=e.length;i0&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){const t=J(e);t in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[t]:this.featuresRtree_&&this.featuresRtree_.remove(e);const i=this.featureChangeKeys_[t];if(!i)return;i.forEach(ie),delete this.featureChangeKeys_[t];const s=e.getId();return s!==void 0&&delete this.idIndex_[s.toString()],delete this.uidIndex_[t],this.hasListener(Ge.REMOVEFEATURE)&&this.dispatchEvent(new Pt(Ge.REMOVEFEATURE,e)),e}removeFromIdIndex_(e){let t=!1;for(const i in this.idIndex_){const s=this.idIndex_[i];if(e instanceof ze&&Array.isArray(s)&&s.includes(e))s.splice(s.indexOf(e),1);else if(this.idIndex_[i]===e){delete this.idIndex_[i],t=!0;break}}return t}setLoader(e){this.loader_=e}setUrl(e){K(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(Vo(e,this.format_))}}const D={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};class ll extends fn{constructor(e,t,i){super(),i=i||{},this.tileCoord=e,this.state=t,this.interimTile=null,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(B.CHANGE)}release(){this.state===D.ERROR&&this.setState(D.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getInterimTile(){let e=this.interimTile;if(!e)return this;do{if(e.getState()==D.LOADED)return this.transition_=0,e;e=e.interimTile}while(e);return this}refreshInterimChain(){let e=this.interimTile;if(!e)return;let t=this;do{if(e.getState()==D.LOADED){e.interimTile=null;break}e.getState()==D.LOADING?t=e:e.getState()==D.IDLE?t.interimTile=e.interimTile:t=e,e=t.interimTile}while(e)}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==D.ERROR&&this.state>e)throw new Error("Tile load sequence violation");this.state=e,this.changed()}load(){q()}getAlpha(e,t){if(!this.transition_)return 1;let i=this.transitionStarts_[e];if(!i)i=t,this.transitionStarts_[e]=i;else if(i===-1)return 1;const s=t-i+1e3/60;return s>=this.transition_?1:Wa(s/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}}class hl extends ll{constructor(e,t,i,s,r,o){super(e,t,o),this.crossOrigin_=s,this.src_=i,this.key=i,this.image_=new Image,s!==null&&(this.image_.crossOrigin=s),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(e){this.image_=e,this.state=D.LOADED,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=D.ERROR,this.unlistenImage_(),this.image_=md(),this.changed()}handleImageLoad_(){const e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=D.LOADED:this.state=D.EMPTY,this.unlistenImage_(),this.changed()}load(){this.state==D.ERROR&&(this.state=D.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==D.IDLE&&(this.state=D.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=lc(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}}function md(){const n=pe(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}class _d{constructor(e,t,i){this.decay_=e,this.minVelocity_=t,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;const e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]0&&this.points_[i+2]>e;)i-=3;const s=this.points_[t+2]-this.points_[i+2];if(s<1e3/60)return!1;const r=this.points_[t]-this.points_[i],o=this.points_[t+1]-this.points_[i+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/s,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}class pd extends or{constructor(e){super(),this.map_=e}dispatchRenderEvent(e,t){q()}calculateMatrices2D(e){const t=e.viewState,i=e.coordinateToPixelTransform,s=e.pixelToCoordinateTransform;je(i,e.size[0]/2,e.size[1]/2,1/t.resolution,-1/t.resolution,-t.rotation,-t.center[0],-t.center[1]),es(s,i)}forEachFeatureAtCoordinate(e,t,i,s,r,o,a,l){let c;const h=t.viewState;function u(x,I,C,R){return r.call(o,I,x?C:null,R)}const d=h.projection,f=ga(e.slice(),d),g=[[0,0]];if(d.canWrapX()&&s){const x=d.getExtent(),I=Z(x);g.push([-I,0],[I,0])}const m=t.layerStatesArray,_=m.length,p=[],y=[];for(let x=0;x=0;--I){const C=m[I],R=C.layer;if(R.hasRenderer()&&Dr(C,h)&&a.call(l,R)){const w=R.getRenderer(),S=R.getSource();if(w&&S){const O=S.getWrapX()?f:e,P=u.bind(null,C.managed);y[0]=O[0]+g[x][0],y[1]=O[1]+g[x][1],c=w.forEachFeatureAtCoordinate(y,t,i,P,p)}if(c)return c}}if(p.length===0)return;const E=1/p.length;return p.forEach((x,I)=>x.distanceSq+=I*E),p.sort((x,I)=>x.distanceSq-I.distanceSq),p.some(x=>c=x.callback(x.feature,x.layer,x.geometry)),c}hasFeatureAtCoordinate(e,t,i,s,r,o){return this.forEachFeatureAtCoordinate(e,t,i,s,qi,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(e){q()}scheduleExpireIconCache(e){ot.canExpireCache()&&e.postRenderFunctions.push(yd)}}function yd(n,e){ot.expire()}class Ed extends pd{constructor(e){super(e),this.fontChangeListenerKey_=U(Et,Ri.PROPERTYCHANGE,e.redrawText.bind(e)),this.element_=document.createElement("div");const t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=us+" ol-layers";const i=e.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(e,t){const i=this.getMap();if(i.hasListener(e)){const s=new el(e,void 0,t);i.dispatchEvent(s)}}disposeInternal(){ie(this.fontChangeListenerKey_),this.element_.parentNode.removeChild(this.element_),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(Xe.PRECOMPOSE,e);const t=e.layerStatesArray.sort(function(a,l){return a.zIndex-l.zIndex});t.some(a=>a.layer instanceof Ja&&a.layer.getDeclutter())&&(e.declutter={});const s=e.viewState;this.children_.length=0;const r=[];let o=null;for(let a=0,l=t.length;a=0;--i){const s=t[i],r=s.layer;r.getDeclutter()&&r.renderDeclutter(e,s)}t.forEach(i=>i.layer.renderDeferred(e))}}class Ft extends ct{constructor(e,t){super(e),this.layer=t}}const Ns={LAYERS:"layers"};class ki extends za{constructor(e){e=e||{};const t=Object.assign({},e);delete t.layers;let i=e.layers;super(t),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Ns.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new st(i.slice(),{unique:!0}):K(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new st(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(ie),this.layersListenerKeys_.length=0;const e=this.getLayers();this.layersListenerKeys_.push(U(e,Le.ADD,this.handleLayersAdd_,this),U(e,Le.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(ie);dn(this.listenerKeys_);const t=e.getArray();for(let i=0,s=t.length;i{this.clickTimeoutId_=void 0;const i=new kt(oe.SINGLECLICK,this.map_,e);this.dispatchEvent(i)},250)}updateActivePointers_(e){const t=e,i=t.pointerId;if(t.type==oe.POINTERUP||t.type==oe.POINTERCANCEL){delete this.trackedTouches_[i];for(const s in this.trackedTouches_)if(this.trackedTouches_[s].target!==t.target){delete this.trackedTouches_[s];break}}else(t.type==oe.POINTERDOWN||t.type==oe.POINTERMOVE)&&(this.trackedTouches_[i]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);const t=new kt(oe.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(ie),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);const t=new kt(oe.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,"target",{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(U(i,oe.POINTERMOVE,this.handlePointerMove_,this),U(i,oe.POINTERUP,this.handlePointerUp_,this),U(this.element_,oe.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(U(this.element_.getRootNode(),oe.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;const t=new kt(oe.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;const t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new kt(oe.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){const t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!="boolean"||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(ie(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(B.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(ie(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(ie),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const xt={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},xe={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},qn=1/0;class Id{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,dn(this.queuedElements_)}dequeue(){const e=this.elements_,t=this.priorities_,i=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));const s=this.keyFunction_(i);return delete this.queuedElements_[s],i}enqueue(e){K(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const t=this.priorityFunction_(e);return t!=qn?(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){const t=this.elements_,i=this.priorities_,s=t.length,r=t[e],o=i[e],a=e;for(;e>1;){const l=this.getLeftChildIndex_(e),c=this.getRightChildIndex_(e),h=ce;){const a=this.getParentIndex_(t);if(s[a]>o)i[t]=i[a],s[t]=s[a],t=a;else break}i[t]=r,s[t]=o}reprioritize(){const e=this.priorityFunction_,t=this.elements_,i=this.priorities_;let s=0;const r=t.length;let o,a,l;for(a=0;a0;)r=this.dequeue()[0],o=r.getKey(),s=r.getState(),s===D.IDLE&&!(o in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[o]=!0,++this.tilesLoading_,++i,r.load())}}function wd(n,e,t,i,s){if(!n||!(t in n.wantedTiles)||!n.wantedTiles[t][e.getKey()])return qn;const r=n.viewState.center,o=i[0]-r[0],a=i[1]-r[1];return 65536*Math.log(s)+Math.sqrt(o*o+a*a)/s}class ut extends Qe{constructor(e){super();const t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){jn(this.element),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&jn(this.element);for(let t=0,i=this.listenerKeys.length;ts.getAttributions(e)))),i=!this.getMap().getAllLayers().some(s=>s.getSource()&&s.getSource().getAttributionsCollapsible()===!1);return this.overrideCollapsible_||this.setCollapsible(i),t}async updateElement_(e){if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=await Promise.all(this.collectSourceAttributions_(e).map(s=>sa(()=>s))),i=t.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Kt(t,this.renderedAttributions_)){Pa(this.ulElement_);for(let s=0,r=t.length;s0&&i%(2*Math.PI)!==0?t.animate({rotation:0,duration:this.duration_,easing:Di}):t.setRotation(0))}render(e){const t=e.frameState;if(!t)return;const i=t.viewState.rotation;if(i!=this.rotation_){const s="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(Mn);!r&&i===0?this.element.classList.add(Mn):r&&i!==0&&this.element.classList.remove(Mn)}this.label_.style.transform=s}this.rotation_=i}}const Sd=Td;class Ld extends ut{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target});const t=e.className!==void 0?e.className:"ol-zoom",i=e.delta!==void 0?e.delta:1,s=e.zoomInClassName!==void 0?e.zoomInClassName:t+"-in",r=e.zoomOutClassName!==void 0?e.zoomOutClassName:t+"-out",o=e.zoomInLabel!==void 0?e.zoomInLabel:"+",a=e.zoomOutLabel!==void 0?e.zoomOutLabel:"–",l=e.zoomInTipLabel!==void 0?e.zoomInTipLabel:"Zoom in",c=e.zoomOutTipLabel!==void 0?e.zoomOutTipLabel:"Zoom out",h=document.createElement("button");h.className=s,h.setAttribute("type","button"),h.title=l,h.appendChild(typeof o=="string"?document.createTextNode(o):o),h.addEventListener(B.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=c,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(B.CLICK,this.handleClick_.bind(this,-i),!1);const d=t+" "+us+" "+Tr,f=this.element;f.className=d,f.appendChild(h),f.appendChild(u),this.duration_=e.duration!==void 0?e.duration:250}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){const i=this.getMap().getView();if(!i)return;const s=i.getZoom();if(s!==void 0){const r=i.getConstrainedZoom(s+e);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:Di})):i.setZoom(r)}}}const bd=Ld;function cl(n){n=n||{};const e=new st;return(n.zoom!==void 0?n.zoom:!0)&&e.push(new bd(n.zoomOptions)),(n.rotate!==void 0?n.rotate:!0)&&e.push(new Sd(n.rotateOptions)),(n.attribution!==void 0?n.attribution:!0)&&e.push(new Rd(n.attributionOptions)),e}const Ko={ACTIVE:"active"};class In extends Qe{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(Ko.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(Ko.ACTIVE,e)}setMap(e){this.map_=e}}function Md(n,e,t){const i=n.getCenterInternal();if(i){const s=[i[0]+e[0],i[1]+e[1]];n.animateInternal({duration:t!==void 0?t:250,easing:Dc,center:n.getConstrainedCenter(s)})}}function Fr(n,e,t,i){const s=n.getZoom();if(s===void 0)return;const r=n.getConstrainedZoom(s+e),o=n.getResolutionForZoom(r);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:t,duration:i!==void 0?i:250,easing:Di})}class Ad extends In{constructor(e){super(),e=e||{},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:250}handleEvent(e){let t=!1;if(e.type==oe.DBLCLICK){const i=e.originalEvent,s=e.map,r=e.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=s.getView();Fr(a,o,r,this.duration_),i.preventDefault(),t=!0}return!t}}const Dd=Ad;class vn extends In{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let t=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==oe.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==oe.POINTERUP){const i=this.handleUpEvent(e);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(e.type==oe.POINTERDOWN){const i=this.handleDownEvent(e);this.handlingDownUpSequence=i,t=this.stopDown(i)}else e.type==oe.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}}function Nr(n){const e=n.length;let t=0,i=0;for(let s=0;s0&&this.condition_(e)){const i=e.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}const zd=Gd;class Wd extends vn{constructor(e){e=e||{},super({stopDown:Qn}),this.condition_=e.condition?e.condition:Pd,this.lastAngle_=void 0,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){if(!Bs(e))return;const t=e.map,i=t.getView();if(i.getConstraints().rotation===Ar)return;const s=t.getSize(),r=e.pixel,o=Math.atan2(s[1]/2-r[1],r[0]-s[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(e){return Bs(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return Bs(e)&&dl(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class Xd extends or{constructor(e){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const e=this.startPixel_,t=this.endPixel_,i="px",s=this.element_.style;s.left=Math.min(e[0],t[0])+i,s.top=Math.min(e[1],t[1])+i,s.width=Math.abs(t[0]-e[0])+i,s.height=Math.abs(t[1]-e[1])+i}setMap(e){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_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){const e=this.startPixel_,t=this.endPixel_,s=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);s[4]=s[0].slice(),this.geometry_?this.geometry_.setCoordinates([s]):this.geometry_=new en([s])}getGeometry(){return this.geometry_}}const kn={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class Gs extends ct{constructor(e,t,i){super(e),this.coordinate=t,this.mapBrowserEvent=i}}class Yd extends vn{constructor(e){super(),this.on,this.once,this.un,e=e||{},this.box_=new Xd(e.className||"ol-dragbox"),this.minArea_=e.minArea!==void 0?e.minArea:64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition?e.condition:dl,this.boxEndCondition_=e.boxEndCondition?e.boxEndCondition:this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,i){const s=i[0]-t[0],r=i[1]-t[1];return s*s+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new Gs(kn.BOXDRAG,e.coordinate,e))}handleUpEvent(e){this.box_.setMap(null);const t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new Gs(t?kn.BOXEND:kn.BOXCANCEL,e.coordinate,e)),!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new Gs(kn.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}}class jd extends Yd{constructor(e){e=e||{};const t=e.condition?e.condition:Nd;super({condition:t,className:e.className||"ol-dragzoom",minArea:e.minArea}),this.duration_=e.duration!==void 0?e.duration:200,this.out_=e.out!==void 0?e.out:!1}onBoxEnd(e){const i=this.getMap().getView();let s=this.getGeometry();if(this.out_){const r=i.rotatedExtentForGeometry(s),o=i.getResolutionForExtentInternal(r),a=i.getResolution()/o;s=s.clone(),s.scale(a*a)}i.fitInternal(s,{duration:this.duration_,easing:Di})}}const Ud=jd,Jt={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class Zd extends In{constructor(e){super(),e=e||{},this.defaultCondition_=function(t){return fl(t)&&gl(t)},this.condition_=e.condition!==void 0?e.condition:this.defaultCondition_,this.duration_=e.duration!==void 0?e.duration:100,this.pixelDelta_=e.pixelDelta!==void 0?e.pixelDelta:128}handleEvent(e){let t=!1;if(e.type==B.KEYDOWN){const i=e.originalEvent,s=i.key;if(this.condition_(e)&&(s==Jt.DOWN||s==Jt.LEFT||s==Jt.RIGHT||s==Jt.UP)){const o=e.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,c=0;s==Jt.DOWN?c=-a:s==Jt.LEFT?l=-a:s==Jt.RIGHT?l=a:c=a;const h=[l,c];dr(h,o.getRotation()),Md(o,h,this.duration_),i.preventDefault(),t=!0}}return!t}}class Vd extends In{constructor(e){super(),e=e||{},this.condition_=e.condition?e.condition:function(t){return!Fd(t)&&gl(t)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:100}handleEvent(e){let t=!1;if(e.type==B.KEYDOWN||e.type==B.KEYPRESS){const i=e.originalEvent,s=i.key;if(this.condition_(e)&&(s==="+"||s==="-")){const r=e.map,o=s==="+"?this.delta_:-this.delta_,a=r.getView();Fr(a,o,void 0,this.duration_),i.preventDefault(),t=!0}}return!t}}const Kd=Vd;class Hd extends In{constructor(e){e=e||{},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta!==void 0?e.maxDelta:1,this.duration_=e.duration!==void 0?e.duration:250,this.timeout_=e.timeout!==void 0?e.timeout:80,this.useAnchor_=e.useAnchor!==void 0?e.useAnchor:!0,this.constrainResolution_=e.constrainResolution!==void 0?e.constrainResolution:!1;const t=e.condition?e.condition:kd;this.condition_=e.onFocusOnly?nr(ul,t):t,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 e=this.getMap();if(!e)return;e.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_)}handleEvent(e){if(!this.condition_(e)||e.type!==B.WHEEL)return!0;const i=e.map,s=e.originalEvent;s.preventDefault(),this.useAnchor_&&(this.lastAnchor_=e.coordinate);let r;if(e.type==B.WHEEL&&(r=s.deltaY,tc&&s.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(r/=Ma),s.deltaMode===WheelEvent.DOM_DELTA_LINE&&(r*=40)),r===0)return!1;this.lastDelta_=r;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const a=i.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-r/this.deltaPerZoom_,this.lastAnchor_),this.startTime_=o,!1;this.totalDelta_+=r;const l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),l),!1}handleWheelZoom_(e){const t=e.getView();t.getAnimating()&&t.cancelAnimations();let i=-he(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Fr(t,i,this.lastAnchor_,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}}const qd=Hd;class $d extends vn{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Qn),super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold!==void 0?e.threshold:.3,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){let t=0;const i=this.targetPointers[0],s=this.targetPointers[1],r=Math.atan2(s.clientY-i.clientY,s.clientX-i.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),t=l}this.lastAngle_=r;const o=e.map,a=o.getView();a.getConstraints().rotation!==Ar&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Nr(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}class Jd extends vn{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Qn),super(t),this.anchor_=null,this.duration_=e.duration!==void 0?e.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1;const i=this.targetPointers[0],s=this.targetPointers[1],r=i.clientX-s.clientX,o=i.clientY-s.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(t=this.lastDistance_/a),this.lastDistance_=a;const l=e.map,c=l.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Nr(this.targetPointers))),l.render(),c.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){const i=e.map.getView(),s=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,s),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}const Qd=Jd;function ef(n){n=n||{};const e=new st,t=new _d(-.005,.05,100);return(n.altShiftDragRotate!==void 0?n.altShiftDragRotate:!0)&&e.push(new Wd),(n.doubleClickZoom!==void 0?n.doubleClickZoom:!0)&&e.push(new Dd({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan!==void 0?n.dragPan:!0)&&e.push(new zd({onFocusOnly:n.onFocusOnly,kinetic:t})),(n.pinchRotate!==void 0?n.pinchRotate:!0)&&e.push(new $d),(n.pinchZoom!==void 0?n.pinchZoom:!0)&&e.push(new Qd({duration:n.zoomDuration})),(n.keyboard!==void 0?n.keyboard:!0)&&(e.push(new Zd),e.push(new Kd({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom!==void 0?n.mouseWheelZoom:!0)&&e.push(new qd({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom!==void 0?n.shiftDragZoom:!0)&&e.push(new Ud({duration:n.zoomDuration})),e}function ml(n){if(n instanceof pn){n.setMapInternal(null);return}n instanceof ki&&n.getLayers().forEach(ml)}function _l(n,e){if(n instanceof pn){n.setMapInternal(e);return}if(n instanceof ki){const t=n.getLayers().getArray();for(let i=0,s=t.length;ithis.updateSize()),this.controls=t.controls||cl(),this.interactions=t.interactions||ef({onFocusOnly:!0}),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new vd(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(xe.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(xe.VIEW,this.handleViewChanged_),this.addChangeListener(xe.SIZE,this.handleSizeChanged_),this.addChangeListener(xe.TARGET,this.handleTargetChanged_),this.setProperties(t.values);const i=this;e.view&&!(e.view instanceof it)&&e.view.then(function(s){i.setView(new it(s))}),this.controls.addEventListener(Le.ADD,s=>{s.element.setMap(this)}),this.controls.addEventListener(Le.REMOVE,s=>{s.element.setMap(null)}),this.interactions.addEventListener(Le.ADD,s=>{s.element.setMap(this)}),this.interactions.addEventListener(Le.REMOVE,s=>{s.element.setMap(null)}),this.overlays_.addEventListener(Le.ADD,s=>{this.addOverlayInternal_(s.element)}),this.overlays_.addEventListener(Le.REMOVE,s=>{const r=s.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],s.element.setMap(null)}),this.controls.forEach(s=>{s.setMap(this)}),this.interactions.forEach(s=>{s.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){_l(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){const t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,i){if(!this.frameState_||!this.renderer_)return;const s=this.getCoordinateFromPixelInternal(e);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:qi,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(s,this.frameState_,r,a,t,null,o,null)}getFeaturesAtPixel(e,t){const i=[];return this.forEachFeatureAtPixel(e,function(s){i.push(s)},t),i}getAllLayers(){const e=[];function t(i){i.forEach(function(s){s instanceof ki?t(s.getLayers()):e.push(s)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(e);t=t!==void 0?t:{};const s=t.layerFilter!==void 0?t.layerFilter:qi,r=t.hitTolerance!==void 0?t.hitTolerance:0,o=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,s,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){const i=this.viewport_.getBoundingClientRect(),s=this.getSize(),r=i.width/s[0],o=i.height/s[1],a="changedTouches"in e?e.changedTouches[0]:e;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(xe.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return qs(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){const t=this.frameState_;return t?ue(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){const t=this.overlayIdIndex_[e.toString()];return t!==void 0?t:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(xe.LAYERGROUP)}setLayers(e){const t=this.getLayerGroup();if(e instanceof st){t.setLayers(e);return}const i=t.getLayers();i.clear(),i.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const e=this.getLayerGroup().getLayerStatesArray();for(let t=0,i=e.length;t=0;r--){const o=s[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(e)||e.propagationStopped)break}}}handlePostRender(){const e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let s=this.maxTilesLoading_,r=s;if(e){const o=e.viewHints;if(o[ge.ANIMATING]||o[ge.INTERACTING]){const a=Date.now()-e.time>8;s=a?0:8,r=a?0:2}}t.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(e){const t=this.getLayerGroup();t&&this.handleLayerRemove_(new Ft("removelayer",t)),this.set(xe.LAYERGROUP,e)}setSize(e){this.set(xe.SIZE,e)}setTarget(e){this.set(xe.TARGET,e)}setView(e){if(!e||e instanceof it){this.set(xe.VIEW,e);return}this.set(xe.VIEW,new it);const t=this;e.then(function(i){t.setView(new it(i))})}updateSize(){const e=this.getTargetElement();let t;if(e){const s=getComputedStyle(e),r=e.offsetWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight)-parseFloat(s.borderRightWidth),o=e.offsetHeight-parseFloat(s.borderTopWidth)-parseFloat(s.paddingTop)-parseFloat(s.paddingBottom)-parseFloat(s.borderBottomWidth);!isNaN(r)&&!isNaN(o)&&(t=[r,o],!Io(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&ma("No map visible because the map container's width or height are 0."))}const i=this.getSize();t&&(!i||!Kt(t,i))&&(this.setSize(t),this.updateViewportSize_(t))}updateViewportSize_(e){const t=this.getView();t&&t.setViewportSize(e)}}function nf(n){let e=null;n.keyboardEventTarget!==void 0&&(e=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);const t={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new ki({layers:n.layers});t[xe.LAYERGROUP]=i,t[xe.TARGET]=n.target,t[xe.VIEW]=n.view instanceof it?n.view:new it;let s;n.controls!==void 0&&(Array.isArray(n.controls)?s=new st(n.controls.slice()):(K(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),s=n.controls));let r;n.interactions!==void 0&&(Array.isArray(n.interactions)?r=new st(n.interactions.slice()):(K(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=n.interactions));let o;return n.overlays!==void 0?Array.isArray(n.overlays)?o=new st(n.overlays.slice()):(K(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new st,{controls:s,interactions:r,keyboardEventTarget:e,overlays:o,values:t}}const sf=tf,ye={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class rf extends Qe{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=e.insertFirst!==void 0?e.insertFirst:!0,this.stopEvent=e.stopEvent!==void 0?e.stopEvent:!0,this.element=document.createElement("div"),this.element.className=e.className!==void 0?e.className:"ol-overlay-container "+mc,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=e.autoPan===!0?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(ye.ELEMENT,this.handleElementChanged),this.addChangeListener(ye.MAP,this.handleMapChanged),this.addChangeListener(ye.OFFSET,this.handleOffsetChanged),this.addChangeListener(ye.POSITION,this.handlePositionChanged),this.addChangeListener(ye.POSITIONING,this.handlePositioningChanged),e.element!==void 0&&this.setElement(e.element),this.setOffset(e.offset!==void 0?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),e.position!==void 0&&this.setPosition(e.position)}getElement(){return this.get(ye.ELEMENT)}getId(){return this.id}getMap(){return this.get(ye.MAP)||null}getOffset(){return this.get(ye.OFFSET)}getPosition(){return this.get(ye.POSITION)}getPositioning(){return this.get(ye.POSITIONING)}handleElementChanged(){Pa(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){this.mapPostrenderListenerKey&&(jn(this.element),ie(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const e=this.getMap();if(e){this.mapPostrenderListenerKey=U(e,xt.POSTRENDER,this.render,this),this.updatePixelPosition();const t=this.stopEvent?e.getOverlayContainerStopEvent():e.getOverlayContainer();this.insertFirst?t.insertBefore(this.element,t.childNodes[0]||null):t.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(ye.ELEMENT,e)}setMap(e){this.set(ye.MAP,e)}setOffset(e){this.set(ye.OFFSET,e)}setPosition(e){this.set(ye.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(ye.POSITION))return;const i=this.getRect(t.getTargetElement(),t.getSize()),s=this.getElement(),r=this.getRect(s,[rc(s),oc(s)]);e=e||{};const o=e.margin===void 0?20:e.margin;if(!rt(i,r)){const a=r[0]-i[0],l=i[2]-r[2],c=r[1]-i[1],h=i[3]-r[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),c<0?u[1]=c-o:h<0&&(u[1]=Math.abs(h)+o),u[0]!==0||u[1]!==0){const d=t.getView().getCenterInternal(),f=t.getPixelFromCoordinateInternal(d);if(!f)return;const g=[f[0]+u[0],f[1]+u[1]],m=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(g),duration:m.duration,easing:m.easing})}}}getRect(e,t){const i=e.getBoundingClientRect(),s=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[s,r,s+t[0],r+t[1]]}setPositioning(e){this.set(ye.POSITIONING,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t){this.setVisible(!1);return}const i=e.getPixelFromCoordinate(t),s=e.getSize();this.updateRenderedPosition(i,s)}updateRenderedPosition(e,t){const i=this.element.style,s=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=Math.round(e[0]+s[0])+"px",a=Math.round(e[1]+s[1])+"px";let l="0%",c="0%";r=="bottom-right"||r=="center-right"||r=="top-right"?l="-100%":(r=="bottom-center"||r=="center-center"||r=="top-center")&&(l="-50%"),r=="bottom-left"||r=="bottom-center"||r=="bottom-right"?c="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(c="-50%");const h=`translate(${l}, ${c}) translate(${o}, ${a})`;this.rendered.transform_!=h&&(this.rendered.transform_=h,i.transform=h)}getOptions(){return this.options}}class of{constructor(e){this.highWaterMark=e!==void 0?e:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.pop()}clear(){this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){const i=this.entries_[e];return K(i!==void 0,"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(e){const t=this.entries_[e];return K(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.key_;return e}getValues(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){var t;return(t=this.entries_[e])==null?void 0:t.value_}pop(){const e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){K(!(e in this.entries_),"Tried to set a value for a key that is used already");const i={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[e]=i,++this.count_}setSize(e){this.highWaterMark=e}}function Ho(n,e,t,i){return i!==void 0?(i[0]=n,i[1]=e,i[2]=t,i):[n,e,t]}function ys(n,e,t){return n+"/"+e+"/"+t}function pl(n){return ys(n[0],n[1],n[2])}function af(n){return n.split("/").map(Number)}function lf(n){return(n[1]<t||t>e.getMaxZoom())return!1;const r=e.getFullTileRange(t);return r?r.containsXY(i,s):!0}class yl extends of{clear(){for(;this.getCount()>0;)this.pop().release();super.clear()}expireCache(e){for(;this.canExpireCache()&&!(this.peekLast().getKey()in e);)this.pop().release()}pruneExceptNewestZ(){if(this.getCount()===0)return;const e=this.peekFirstKey(),i=af(e)[0];this.forEach(s=>{s.tileCoord[0]!==i&&(this.remove(pl(s.tileCoord)),s.release())})}}class Br{constructor(e,t,i,s){this.minX=e,this.maxX=t,this.minY=i,this.maxY=s}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minXthis.maxX&&(this.maxX=e.maxX),e.minYthis.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}}function fi(n,e,t,i,s){return s!==void 0?(s.minX=n,s.maxX=e,s.minY=t,s.maxY=i,s):new Br(n,e,t,i)}const Fn={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class cf extends pn{constructor(e){e=e||{};const t=Object.assign({},e);delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.setPreload(e.preload!==void 0?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0)}getPreload(){return this.get(Fn.PRELOAD)}setPreload(e){this.set(Fn.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(Fn.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(Fn.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}}const El=.5,uf=10,qo=.25;class xl{constructor(e,t,i,s,r,o){this.sourceProj_=e,this.targetProj_=t;let a={};const l=Xn(this.targetProj_,this.sourceProj_);this.transformInv_=function(y){const E=y[0]+"/"+y[1];return a[E]||(a[E]=l(y)),a[E]},this.maxSourceExtent_=s,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!s&&!!this.sourceProj_.getExtent()&&Z(s)>=Z(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?Z(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?Z(this.targetProj_.getExtent()):null;const c=oi(i),h=ss(i),u=ns(i),d=is(i),f=this.transformInv_(c),g=this.transformInv_(h),m=this.transformInv_(u),_=this.transformInv_(d),p=uf+(o?Math.max(0,Math.ceil(Math.log2(Zs(i)/(o*o*256*256)))):0);if(this.addQuad_(c,h,u,d,f,g,m,_,p),this.wrapsXInSource_){let y=1/0;this.triangles_.forEach(function(E,x,I){y=Math.min(y,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])-y>this.sourceWorldWidth_/2){const x=[[E.source[0][0],E.source[0][1]],[E.source[1][0],E.source[1][1]],[E.source[2][0],E.source[2][1]]];x[0][0]-y>this.sourceWorldWidth_/2&&(x[0][0]-=this.sourceWorldWidth_),x[1][0]-y>this.sourceWorldWidth_/2&&(x[1][0]-=this.sourceWorldWidth_),x[2][0]-y>this.sourceWorldWidth_/2&&(x[2][0]-=this.sourceWorldWidth_);const I=Math.min(x[0][0],x[1][0],x[2][0]);Math.max(x[0][0],x[1][0],x[2][0])-I.5&&u<1;let g=!1;if(c>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=to([e,t,i,s]);g=Z(_)/this.targetWorldWidth_>qo||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>qo||g)}if(!g&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!Re(h,this.maxSourceExtent_))return;let m=0;if(!g&&(!isFinite(r[0])||!isFinite(r[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(c>0)g=!0;else if(m=(!isFinite(r[0])||!isFinite(r[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),m!=1&&m!=2&&m!=4&&m!=8)return}if(c>0){if(!g){const _=[(e[0]+i[0])/2,(e[1]+i[1])/2],p=this.transformInv_(_);let y;f?y=(si(r[0],d)+si(a[0],d))/2-si(p[0],d):y=(r[0]+a[0])/2-p[0];const E=(r[1]+a[1])/2-p[1];g=y*y+E*E>this.errorThresholdSquared_}if(g){if(Math.abs(e[0]-i[0])<=Math.abs(e[1]-i[1])){const _=[(t[0]+i[0])/2,(t[1]+i[1])/2],p=this.transformInv_(_),y=[(s[0]+e[0])/2,(s[1]+e[1])/2],E=this.transformInv_(y);this.addQuad_(e,t,_,y,r,o,p,E,c-1),this.addQuad_(y,_,i,s,E,p,a,l,c-1)}else{const _=[(e[0]+t[0])/2,(e[1]+t[1])/2],p=this.transformInv_(_),y=[(i[0]+s[0])/2,(i[1]+s[1])/2],E=this.transformInv_(y);this.addQuad_(e,_,y,s,r,p,E,l,c-1),this.addQuad_(_,t,i,y,p,o,a,E,c-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}m&11||this.addTriangle_(e,i,s,r,a,l),m&14||this.addTriangle_(e,i,t,r,a,o),m&&(m&13||this.addTriangle_(t,s,e,o,l,r),m&7||this.addTriangle_(t,s,i,o,l,a))}calculateSourceExtent(){const e=Ue();return this.triangles_.forEach(function(t,i,s){const r=t.source;Vi(e,r[0]),Vi(e,r[1]),Vi(e,r[2])}),e}getTriangles(){return this.triangles_}}let zs;const Ci=[];function $o(n,e,t,i,s){n.beginPath(),n.moveTo(0,0),n.lineTo(e,t),n.lineTo(i,s),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(e,i)+1,Math.max(t,s)),n.restore()}function Ws(n,e){return Math.abs(n[e*4]-210)>2||Math.abs(n[e*4+3]-.75*255)>2}function df(){if(zs===void 0){const n=pe(6,6,Ci);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",$o(n,4,5,4,0),$o(n,4,5,0,5);const e=n.getImageData(0,0,3,3).data;zs=Ws(e,0)||Ws(e,4)||Ws(e,8),ls(n),Ci.push(n.canvas)}return zs}function $n(n,e,t,i){const s=as(t,e,n);let r=ao(e,i,t);const o=e.getMetersPerUnit();o!==void 0&&(r*=o);const a=n.getMetersPerUnit();a!==void 0&&(r/=a);const l=n.getExtent();if(!l||ri(l,s)){const c=ao(n,r,s)/r;isFinite(c)&&c>0&&(r/=c)}return r}function ff(n,e,t,i){const s=Tt(t);let r=$n(n,e,s,i);return(!isFinite(r)||r<=0)&&ca(t,function(o){return r=$n(n,e,o,i),isFinite(r)&&r>0}),r}function Il(n,e,t,i,s,r,o,a,l,c,h,u,d,f){const g=pe(Math.round(t*n),Math.round(t*e),Ci);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(t,t);function m(I){return Math.round(I*t)/t}g.globalCompositeOperation="lighter";const _=Ue();l.forEach(function(I,C,R){Jl(_,I.extent)});let p;const y=t/i,E=(u?1:1+Math.pow(2,-24))/y;if(!d||l.length!==1||c!==0){if(p=pe(Math.round(Z(_)*y),Math.round(le(_)*y),Ci),u||(p.imageSmoothingEnabled=!1),s&&f){const I=(s[0]-_[0])*y,C=-(s[3]-_[3])*y,R=Z(s)*y,w=le(s)*y;p.rect(I,C,R,w),p.clip()}l.forEach(function(I,C,R){const w=(I.extent[0]-_[0])*y,S=-(I.extent[3]-_[3])*y,O=Z(I.extent)*y,P=le(I.extent)*y;I.image.width>0&&I.image.height>0&&p.drawImage(I.image,c,c,I.image.width-2*c,I.image.height-2*c,u?w:Math.round(w),u?S:Math.round(S),u?O:Math.round(w+O)-Math.round(w),u?P:Math.round(S+P)-Math.round(S))})}const x=oi(o);return a.getTriangles().forEach(function(I,C,R){const w=I.source,S=I.target;let O=w[0][0],P=w[0][1],F=w[1][0],Y=w[1][1],G=w[2][0],z=w[2][1];const L=m((S[0][0]-x[0])/r),k=m(-(S[0][1]-x[1])/r),W=m((S[1][0]-x[0])/r),te=m(-(S[1][1]-x[1])/r),j=m((S[2][0]-x[0])/r),Q=m(-(S[2][1]-x[1])/r),H=O,ae=P;O=0,P=0,F-=H,Y-=ae,G-=H,z-=ae;const T=[[F,Y,0,0,W-L],[G,z,0,0,j-L],[0,0,F,Y,te-k],[0,0,G,z,Q-k]],ne=gh(T);if(!ne)return;if(g.save(),g.beginPath(),df()||!u){g.moveTo(W,te);const ce=4,Te=L-W,Ze=k-te;for(let Se=0;Se{t&&t.getState()==D.LOADED&&e.push({extent:this.sourceTileGrid_.getTileCoordExtent(t.tileCoord),image:t.getImage()})}),this.sourceTiles_.length=0,e.length===0)this.state=D.ERROR;else{const t=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(t),s=typeof i=="number"?i:i[0],r=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=Il(s,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=D.LOADED}this.changed()}load(){if(this.state==D.IDLE){this.state=D.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(t=>{const i=t.getState();if(i==D.IDLE||i==D.LOADING){e++;const s=U(t,B.CHANGE,function(r){const o=t.getState();(o==D.LOADED||o==D.ERROR||o==D.EMPTY)&&(ie(s),e--,e===0&&(this.unlistenSources_(),this.reproject_()))},this);this.sourcesListenerKeys_.push(s)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function(t,i,s){t.getState()==D.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(ie),this.sourcesListenerKeys_=null}release(){this.canvas_&&(ls(this.canvas_.getContext("2d")),Ci.push(this.canvas_),this.canvas_=null),super.release()}}class gf extends Or{constructor(e){super(e),this.extentChanged=!0,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedRevision,this.renderedTiles=[],this.newTiles_=!1,this.tmpExtent=Ue(),this.tmpTileRange_=new Br(0,0,0,0)}isDrawableTile(e){const t=this.getLayer(),i=e.getState(),s=t.getUseInterimTilesOnError();return i==D.LOADED||i==D.EMPTY||i==D.ERROR&&!s}getTile(e,t,i,s){const r=s.pixelRatio,o=s.viewState.projection,a=this.getLayer();let c=a.getSource().getTile(e,t,i,r,o);return c.getState()==D.ERROR&&a.getUseInterimTilesOnError()&&a.getPreload()>0&&(this.newTiles_=!0),this.isDrawableTile(c)||(c=c.getInterimTile()),c}getData(e){const t=this.frameState;if(!t)return null;const i=this.getLayer(),s=ue(t.pixelToCoordinateTransform,e.slice()),r=i.getExtent();if(r&&!ri(r,s))return null;const o=t.pixelRatio,a=t.viewState.projection,l=t.viewState,c=i.getRenderSource(),h=c.getTileGridForProjection(l.projection),u=c.getTilePixelRatio(t.pixelRatio);for(let d=h.getZForResolution(l.resolution);d>=h.getMinZoom();--d){const f=h.getTileCoordForCoordAndZ(s,d),g=c.getTile(d,f[1],f[2],o,a);if(!(g instanceof hl||g instanceof sr)||g instanceof sr&&g.getState()===D.EMPTY)return null;if(g.getState()!==D.LOADED)continue;const m=h.getOrigin(d),_=Oe(h.getTileSize(d)),p=h.getResolution(d),y=Math.floor(u*((s[0]-m[0])/p-f[1]*_[0])),E=Math.floor(u*((m[1]-s[1])/p-f[2]*_[1])),x=Math.round(u*c.getGutterForProjection(l.projection));return this.getImageData(g.getImage(),y+x,E+x)}return null}loadedTileCallback(e,t,i){return this.isDrawableTile(i)?super.loadedTileCallback(e,t,i):!1}prepareFrame(e){return!!this.getLayer().getSource()}renderFrame(e,t){const i=e.layerStatesArray[e.layerIndex],s=e.viewState,r=s.projection,o=s.resolution,a=s.center,l=s.rotation,c=e.pixelRatio,h=this.getLayer(),u=h.getSource(),d=u.getRevision(),f=u.getTileGridForProjection(r),g=f.getZForResolution(o,u.zDirection),m=f.getResolution(g);let _=e.extent;const p=e.viewState.resolution,y=u.getTilePixelRatio(c),E=Math.round(Z(_)/p*c),x=Math.round(le(_)/p*c),I=i.extent&&vt(i.extent);I&&(_=ni(_,vt(i.extent)));const C=m*E/2/y,R=m*x/2/y,w=[a[0]-C,a[1]-R,a[0]+C,a[1]+R],S=f.getTileRangeForExtentAndZ(_,g),O={};O[g]={};const P=this.createLoadedTileFinder(u,r,O),F=this.tmpExtent,Y=this.tmpTileRange_;this.newTiles_=!1;const G=l?Vs(s.center,p,l,e.size):void 0;for(let ae=S.minX;ae<=S.maxX;++ae)for(let T=S.minY;T<=S.maxY;++T){if(l&&!f.tileCoordIntersectsViewport([g,ae,T],G))continue;const ne=this.getTile(g,ae,T,e);if(this.isDrawableTile(ne)){const Te=J(this);if(ne.getState()==D.LOADED){O[g][ne.tileCoord.toString()]=ne;let Ze=ne.inTransition(Te);Ze&&i.opacity!==1&&(ne.endTransition(Te),Ze=!1),!this.newTiles_&&(Ze||!this.renderedTiles.includes(ne))&&(this.newTiles_=!0)}if(ne.getAlpha(Te,e.time)===1)continue}const Ae=f.getTileCoordChildTileRange(ne.tileCoord,Y,F);let ce=!1;Ae&&(ce=P(g+1,Ae)),ce||f.forEachTileCoordParentTileRange(ne.tileCoord,P,Y,F)}const z=m/o*c/y;je(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/c,1/c,l,-E/2,-x/2);const L=hr(this.pixelTransform);this.useContainer(t,L,this.getBackground(e));const k=this.getRenderContext(e),W=this.context.canvas;es(this.inversePixelTransform,this.pixelTransform),je(this.tempTransform,E/2,x/2,z,z,0,-E/2,-x/2),W.width!=E||W.height!=x?(W.width=E,W.height=x):this.containerReused||k.clearRect(0,0,E,x),I&&this.clipUnrotated(k,e,I),u.getInterpolate()||(k.imageSmoothingEnabled=!1),this.preRender(k,e),this.renderedTiles.length=0;let te=Object.keys(O).map(Number);te.sort(wt);let j,Q,H;i.opacity===1&&(!this.containerReused||u.getOpaque(e.viewState.projection))?te=te.reverse():(j=[],Q=[]);for(let ae=te.length-1;ae>=0;--ae){const T=te[ae],ne=u.getTilePixelSize(T,c,r),ce=f.getResolution(T)/m,Te=ne[0]*ce*z,Ze=ne[1]*ce*z,Se=f.getTileCoordForCoordAndZ(oi(w),T),Fi=f.getTileCoordExtent(Se),Ht=ue(this.tempTransform,[y*(Fi[0]-w[0])/m,y*(w[3]-Fi[3])/m]),xs=y*u.getGutterForProjection(r),wn=O[T];for(const Cn in wn){const ke=wn[Cn],ai=ke.tileCoord,Rn=Se[1]-ai[1],Is=Math.round(Ht[0]-(Rn-1)*Te),Tn=Se[2]-ai[2],Sn=Math.round(Ht[1]-(Tn-1)*Ze),De=Math.round(Ht[0]-Rn*Te),Ve=Math.round(Ht[1]-Tn*Ze),et=Is-De,Ke=Sn-Ve,li=g===T,hi=li&&ke.getAlpha(J(this),e.time)!==1;let bt=!1;if(!hi)if(j){H=[De,Ve,De+et,Ve,De+et,Ve+Ke,De,Ve+Ke];for(let dt=0,vs=j.length;dtr-s,!0),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let s=0,r=this.resolutions_.length-1;s{const o=new Br(Math.min(0,s[0]),Math.max(s[0]-1,-1),Math.min(0,s[1]),Math.max(s[1]-1,-1));if(i){const a=this.getTileRangeForExtentAndZ(i,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(e,t,i){const s=this.getTileRangeForExtentAndZ(e,t);for(let r=s.minX,o=s.maxX;r<=o;++r)for(let a=s.minY,l=s.maxY;a<=l;++a)i([t,r,a])}forEachTileCoordParentTileRange(e,t,i,s){let r,o,a,l=null,c=e[0]-1;for(this.zoomFactor_===2?(o=e[1],a=e[2]):l=this.getTileCoordExtent(e,s);c>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=fi(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,c,i),t(c,r))return!0;--c}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,i){if(e[0]this.maxZoom||t0?i:Math.max(r/t[0],s/t[1]);const o=e+1,a=new Array(o);for(let l=0;li.highWaterMark&&(i.highWaterMark=e)}useTile(e,t,i,s){}}class wf extends ct{constructor(e,t){super(e),this.tile=t}}function Cf(n,e){const t=/\{z\}/g,i=/\{x\}/g,s=/\{y\}/g,r=/\{-y\}/g;return function(o,a,l){if(o)return n.replace(t,o[0].toString()).replace(i,o[1].toString()).replace(s,o[2].toString()).replace(r,function(){const c=o[0],h=e.getFullTileRange(c);if(!h)throw new Error("The {-y} placeholder requires a tile grid with extent");return(h.getHeight()-o[2]-1).toString()})}}function Rf(n,e){const t=n.length,i=new Array(t);for(let s=0;sthis.getTileInternal(_,p,y,E,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return m.key=u,c?(m.interimTile=c,m.refreshInterimChain(),a.replace(h,m)):a.set(h,m),m}getTileInternal(e,t,i,s,r){let o=null;const a=ys(e,t,i),l=this.getKey();if(!this.tileCache.containsKey(a))o=this.createTile_(e,t,i,s,r,l),this.tileCache.set(a,o);else if(o=this.tileCache.get(a),o.key!=l){const c=o;o=this.createTile_(e,t,i,s,r,l),c.getState()==D.IDLE?o.interimTile=c.interimTile:o.interimTile=c,o.refreshInterimChain(),this.tileCache.replace(a,o)}return o}setRenderReprojectionEdges(e){if(this.renderReprojectionEdges_!=e){this.renderReprojectionEdges_=e;for(const t in this.tileCacheForProjection)this.tileCacheForProjection[t].clear();this.changed()}}setTileGridForProjection(e,t){const i=ve(e);if(i){const s=J(i);s in this.tileGridForProjection||(this.tileGridForProjection[s]=t)}}clear(){super.clear();for(const e in this.tileCacheForProjection)this.tileCacheForProjection[e].clear()}}function bf(n,e){n.getImage().src=e}class Mf extends Lf{constructor(e){e=e||{};const t=e.projection!==void 0?e.projection:"EPSG:3857",i=e.tileGrid!==void 0?e.tileGrid:xf({extent:Gr(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,opaque:e.opaque,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}}const Af='© OpenStreetMap contributors.';class Df extends Mf{constructor(e){e=e||{};let t;e.attributions!==void 0?t=e.attributions:t=[Af];const i=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",s=e.url!==void 0?e.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:t,attributionsCollapsible:!1,cacheSize:e.cacheSize,crossOrigin:i,interpolate:e.interpolate,maxZoom:e.maxZoom!==void 0?e.maxZoom:19,opaque:e.opaque!==void 0?e.opaque:!0,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:e.tileLoadFunction,transition:e.transition,url:s,wrapX:e.wrapX,zDirection:e.zDirection})}}const Pf=Df;function rr(n){return Array.isArray(n)?Math.min(...n):n}class Of extends Oa{constructor(e,t,i,s,r,o,a){let l=e.getExtent();l&&e.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);let c=t.getExtent();c&&t.canWrapX()&&(c=c.slice(),c[0]=-1/0,c[2]=1/0);const h=c?ni(i,c):i,u=Tt(h),d=$n(e,t,u,s),f=El,g=new xl(e,t,h,l,d*f,s),m=g.calculateSourceExtent(),_=Ai(m)?null:o(m,d,r),p=_?b.IDLE:b.EMPTY,y=_?_.getPixelRatio():1;super(i,s,y,p),this.targetProj_=t,this.maxSourceExtent_=l,this.triangulation_=g,this.targetResolution_=s,this.targetExtent_=i,this.sourceImage_=_,this.sourcePixelRatio_=y,this.interpolate_=a,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==b.LOADING&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const e=this.sourceImage_.getState();if(e==b.LOADED){const t=Z(this.targetExtent_)/this.targetResolution_,i=le(this.targetExtent_)/this.targetResolution_;this.canvas_=Il(t,i,this.sourcePixelRatio_,rr(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=e,this.changed()}load(){if(this.state==b.IDLE){this.state=b.LOADING,this.changed();const e=this.sourceImage_.getState();e==b.LOADED||e==b.ERROR?this.reproject_():(this.sourceListenerKey_=U(this.sourceImage_,B.CHANGE,function(t){const i=this.sourceImage_.getState();(i==b.LOADED||i==b.ERROR)&&(this.unlistenSource_(),this.reproject_())},this),this.sourceImage_.load())}}unlistenSource_(){ie(this.sourceListenerKey_),this.sourceListenerKey_=null}}const Wt=4,Ys={IMAGELOADSTART:"imageloadstart",IMAGELOADEND:"imageloadend",IMAGELOADERROR:"imageloaderror"};class kf extends ct{constructor(e,t){super(e),this.image=t}}class Ff extends kr{constructor(e){super({attributions:e.attributions,projection:e.projection,state:e.state,interpolate:e.interpolate!==void 0?e.interpolate:!0}),this.on,this.once,this.un,this.loader=e.loader||null,this.resolutions_=e.resolutions!==void 0?e.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=e.loader?e.loader.length===0:!1,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(e){this.resolutions_=e}findNearestResolution(e){const t=this.getResolutions();if(t){const i=Jn(t,e,0);e=t[i]}return e}getImage(e,t,i,s){const r=this.getProjection();if(!r||!s||Nt(r,s))return r&&(s=r),this.getImageInternal(e,t,i,s);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&Nt(this.reprojectedImage_.getProjection(),s)&&this.reprojectedImage_.getResolution()==t&&Li(this.reprojectedImage_.getExtent(),e))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new Of(r,s,e,t,i,(o,a,l)=>this.getImageInternal(o,a,l,r),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(e,t,i,s){if(this.loader){const r=Rl(e,t,i,1),o=this.findNearestResolution(t);if(this.image&&(this.static_||this.wantedProjection_===s&&(this.wantedExtent_&&rt(this.wantedExtent_,r)||rt(this.image.getExtent(),r))&&(this.wantedResolution_&&rr(this.wantedResolution_)===o||rr(this.image.getResolution())===o)))return this.image;this.wantedProjection_=s,this.wantedExtent_=r,this.wantedResolution_=o,this.image=new Oa(r,o,i,this.loader),this.image.addEventListener(B.CHANGE,this.handleImageChange.bind(this))}return this.image}handleImageChange(e){const t=e.target;let i;switch(t.getState()){case b.LOADING:this.loading=!0,i=Ys.IMAGELOADSTART;break;case b.LOADED:this.loading=!1,i=Ys.IMAGELOADEND;break;case b.ERROR:this.loading=!1,i=Ys.IMAGELOADERROR;break;default:return}this.hasListener(i)&&this.dispatchEvent(new kf(i,t))}}function Nf(n,e){n.getImage().src=e}function Rl(n,e,t,i){const s=e/t,r=Tt(n),o=Bt(Z(n)/s,Wt),a=Bt(le(n)/s,Wt),l=Bt((i-1)*o/2,Wt),c=o+2*l,h=Bt((i-1)*a/2,Wt),u=a+2*h;return $i(r,s,0,[c,u])}function Tl(n,e){const t=[];Object.keys(e).forEach(function(s){e[s]!==null&&e[s]!==void 0&&t.push(s+"="+encodeURIComponent(e[s]))});const i=t.join("&");return n=n.replace(/[?&]$/,""),n+=n.includes("?")?"&":"?",n+i}const Sl="1.3.0",Jo=[101,101];function Ll(n,e,t,i,s){s.WIDTH=t[0],s.HEIGHT=t[1];const r=i.getAxisOrientation();let o;const a=fa(s.VERSION,"1.3")>=0;return s[a?"CRS":"SRS"]=i.getCode(),a&&r.substr(0,2)=="ne"?o=[e[1],e[0],e[3],e[2]]:o=e,s.BBOX=o.join(","),Tl(n,s)}function Bf(n,e,t,i,s,r,o){r=Object.assign({REQUEST:"GetMap"},r);const a=e/t,l=[ro(Z(n)/a,Wt),ro(le(n)/a,Wt)];if(t!=1)switch(o){case"geoserver":const h=90*t+.5|0;"FORMAT_OPTIONS"in r?r.FORMAT_OPTIONS+=";dpi:"+h:r.FORMAT_OPTIONS="dpi:"+h;break;case"mapserver":r.MAP_RESOLUTION=90*t;break;case"carmentaserver":case"qgis":r.DPI=90*t;break;default:throw new Error("Unknown `serverType` configured")}return Ll(s,n,l,i,r)}function bl(n,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:Sl,FORMAT:"image/png",STYLES:"",TRANSPARENT:!0},n)}function Gf(n){const e=n.hidpi===void 0?!0:n.hidpi,t=ve(n.projection||"EPSG:3857"),i=n.ratio||1.5,s=n.load||Fa;return(r,o,a)=>{r=Rl(r,o,a,i),a!=1&&(!e||n.serverType===void 0)&&(a=1);const l=Bf(r,o,a,t,n.url,bl(n.params,"GetMap"),n.serverType),c=new Image;return n.crossOrigin!==null&&(c.crossOrigin=n.crossOrigin),s(c,l).then(h=>({image:h,extent:r,pixelRatio:a}))}}function zf(n,e,t){if(n.url===void 0)return;const i=ve(n.projection||"EPSG:3857"),s=$i(e,t,0,Jo),r={QUERY_LAYERS:n.params.LAYERS,INFO_FORMAT:"application/json"};Object.assign(r,bl(n.params,"GetFeatureInfo"),n.params);const o=xi((e[0]-s[0])/t,Wt),a=xi((s[3]-e[1])/t,Wt),l=fa(r.VERSION,"1.3")>=0;return r[l?"I":"X"]=o,r[l?"J":"Y"]=a,Ll(n.url,s,Jo,i,r)}function Wf(n,e){if(n.url===void 0)return;const t={SERVICE:"WMS",VERSION:Sl,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(n.params===void 0||n.params.LAYER===void 0){const i=n.params.LAYERS;if(!(!Array.isArray(i)||i.length===1))return;t.LAYER=i}if(e!==void 0){const i=ve(n.projection||"EPSG:3857").getMetersPerUnit()||1,s=28e-5;t.SCALE=e*i/s}return Object.assign(t,n.params),Tl(n.url,t)}class Ml extends Ff{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:e.interpolate,projection:e.projection,resolutions:e.resolutions}),this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null,this.url_=e.url,this.imageLoadFunction_=e.imageLoadFunction!==void 0?e.imageLoadFunction:Nf,this.params_=Object.assign({},e.params),this.serverType_=e.serverType,this.hidpi_=e.hidpi!==void 0?e.hidpi:!0,this.renderedRevision_=0,this.ratio_=e.ratio!==void 0?e.ratio:1.5,this.loaderProjection_=null}getFeatureInfoUrl(e,t,i,s){const r=ve(i),o=this.getProjection();o&&o!==r&&(t=$n(o,r,e,t),e=as(e,r,o));const a={url:this.url_,params:{...this.params_,...s},projection:o||r};return zf(a,e,t)}getLegendUrl(e,t){return Wf({url:this.url_,params:{...this.params_,...t}},e)}getParams(){return this.params_}getImageInternal(e,t,i,s){return this.url_===void 0?null:((!this.loader||this.loaderProjection_!==s)&&(this.loaderProjection_=s,this.loader=Gf({crossOrigin:this.crossOrigin_,params:this.params_,projection:s,serverType:this.serverType_,hidpi:this.hidpi_,url:this.url_,ratio:this.ratio_,load:(r,o)=>(this.image.setImage(r),this.imageLoadFunction_(this.image,o),Fa(r))})),super.getImageInternal(e,t,i,s))}getImageLoadFunction(){return this.imageLoadFunction_}getUrl(){return this.url_}setImageLoadFunction(e){this.imageLoadFunction_=e,this.changed()}setUrl(e){e!=this.url_&&(this.url_=e,this.loader=null,this.changed())}updateParams(e){Object.assign(this.params_,e),this.changed()}changed(){this.image=null,super.changed()}}class Xf extends pn{constructor(e){e=e||{},super(e)}}class Yf extends Or{constructor(e){super(e),this.image_=null}getImage(){return this.image_?this.image_.getImage():null}prepareFrame(e){const t=e.layerStatesArray[e.layerIndex],i=e.pixelRatio,s=e.viewState,r=s.resolution,o=this.getLayer().getSource(),a=e.viewHints;let l=e.extent;if(t.extent!==void 0&&(l=ni(l,vt(t.extent,s.projection))),!a[ge.ANIMATING]&&!a[ge.INTERACTING]&&!Ai(l))if(o){const c=s.projection,h=o.getImage(l,r,i,c);h&&(this.loadImage(h)?this.image_=h:h.getState()===b.EMPTY&&(this.image_=null))}else this.image_=null;return!!this.image_}getData(e){const t=this.frameState;if(!t)return null;const i=this.getLayer(),s=ue(t.pixelToCoordinateTransform,e.slice()),r=i.getExtent();if(r&&!ri(r,s))return null;const o=this.image_.getExtent(),a=this.image_.getImage(),l=Z(o),c=Math.floor(a.width*((s[0]-o[0])/l));if(c<0||c>=a.width)return null;const h=le(o),u=Math.floor(a.height*((o[3]-s[1])/h));return u<0||u>=a.height?null:this.getImageData(a,c,u)}renderFrame(e,t){const i=this.image_,s=i.getExtent(),r=i.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],l=i.getPixelRatio(),c=e.layerStatesArray[e.layerIndex],h=e.pixelRatio,u=e.viewState,d=u.center,f=u.resolution,g=h*o/(f*l),m=h*a/(f*l),_=e.extent,p=u.resolution,y=u.rotation,E=Math.round(Z(_)/p*h),x=Math.round(le(_)/p*h);je(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/h,1/h,y,-E/2,-x/2),es(this.inversePixelTransform,this.pixelTransform);const I=hr(this.pixelTransform);this.useContainer(t,I,this.getBackground(e));const C=this.getRenderContext(e),R=this.context.canvas;R.width!=E||R.height!=x?(R.width=E,R.height=x):this.containerReused||C.clearRect(0,0,E,x);let w=!1,S=!0;if(c.extent){const G=vt(c.extent,u.projection);S=Re(G,e.extent),w=S&&!rt(G,e.extent),w&&this.clipUnrotated(C,e,G)}const O=i.getImage(),P=je(this.tempTransform,E/2,x/2,g,m,0,l*(s[0]-d[0])/o,l*(d[1]-s[3])/a);this.renderedResolution=a*h/l;const F=O.width*P[0],Y=O.height*P[3];if(this.getLayer().getSource().getInterpolate()||(C.imageSmoothingEnabled=!1),this.preRender(C,e),S&&F>=.5&&Y>=.5){const G=P[4],z=P[5],L=c.opacity;L!==1&&(C.save(),C.globalAlpha=L),C.drawImage(O,0,0,+O.width,+O.height,G,z,F,Y),L!==1&&C.restore()}return this.postRender(this.context,e),w&&C.restore(),C.imageSmoothingEnabled=!0,I!==R.style.transform&&(R.style.transform=I),this.container}}class Al extends Xf{constructor(e){super(e)}createRenderer(){return new Yf(this)}getData(e){return super.getData(e)}}var Dl,Pl,jf=document.getElementById("popup"),de=document.getElementById("popup-content"),Qo=document.getElementById("popup-closer"),$e,Wr,Ye,Ol,kl,Fl,Nl,js=!1,Yt=!1,jt=!1,Ut=!1,ea,ta,Es="https://opendem.info/cgi-bin/",Xr=new rf({element:jf,autoPan:!0,autoPanAnimation:{duration:250}});Qo.onclick=function(){return Xr.setPosition(void 0),Qo.blur(),!1};class Uf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:0px;left:1px; width:30px; height:30px;",i.className="switchDiv",i.id="switchDiv",super({element:i,target:t.target}),i.addEventListener("click",this.handleSwitchDivChange.bind(this),!1)}handleSwitchDivChange(){var e=document.getElementById("switchDiv"),t=document.getElementById("controlEle");t.style.display==="none"?(t.style.display="block",e.className="switchDiv"):(t.style.display="none",e.className="switchDivHide")}}class Zf extends ut{constructor(e){const t=e||{};var i=document.createElement("input");i.type="radio",i.name="radioGrp",i.id="rad1",i.value="myradio1",i.defaultChecked=!0,i.checked=!0;var s=document.createElement("input");s.type="radio",s.name="radioGrp",s.id="rad2",s.value="myradio2";var r=document.createElement("input");r.type="radio",r.name="radioGrp",r.id="rad3",r.value="myradio3";var o=document.createElement("input");o.type="radio",o.name="radioGrp",o.id="rad4",o.value="myradio4";var a=document.createElement("input");a.type="radio",a.name="radioGrp",a.id="rad5",a.value="myradio5";var l=document.createTextNode("3D Model"),c=document.createTextNode("Foto"),h=document.createTextNode("Wikipedia"),u=document.createTextNode("OpenStreetMap"),p=document.createTextNode("Podcast"),d=document.createElement("label");d.style.cssText="position:absolute;top:50px;left:10px",d.htmlFor=i.id,d.appendChild(i),d.appendChild(l);var f=document.createElement("label");f.style.cssText="position:absolute;top:70px;left:10px;",f.htmlFor=s.id,f.appendChild(s),f.appendChild(c);var g=document.createElement("label");g.style.cssText="position:absolute;top:90px;left:10px;",g.htmlFor=r.id,g.appendChild(r),g.appendChild(h);var m=document.createElement("label");m.style.cssText="position:absolute;top:110px;left:10px;",m.htmlFor=o.id,m.appendChild(o),m.appendChild(u);var _=document.createElement("label");_.style.cssText="position:absolute;top:130px;left:10px;",_.htmlFor=a.id,_.appendChild(a),_.appendChild(p);var p=document.createElement("P");p.innerHTML="Was gibt es hier zu pflegen?",p.style.cssText="position:absolute;left:20px";var y=document.createElement("p");y.style.cssText="position:absolute;top:140px;left:5px",y.innerHTML=`
  Vorhanden:
  Ja
+`+g;Et.get(m)===void 0&&(Et.set(m,100,!0),a(h.style,h.weight,g)||(Et.set(m,0,!0),r===void 0&&(r=setInterval(l,32))))}}}(),yc=function(){let n;return function(e){let t=tr[e];if(t==null){if(Da){const i=Ba(e),s=za(e,"Žg");t=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(s.actualBoundingBoxAscent+s.actualBoundingBoxDescent)}else n||(n=document.createElement("div"),n.innerHTML="M",n.style.minHeight="0",n.style.maxHeight="none",n.style.height="auto",n.style.padding="0",n.style.border="none",n.style.position="absolute",n.style.display="block",n.style.left="-99999px"),n.style.font=e,document.body.appendChild(n),t=n.offsetHeight,document.body.removeChild(n);tr[e]=t}return t}}();function za(n,e){return mi||(mi=pe(1,1)),n!=er&&(mi.font=n,er=mi.font),mi.measureText(e)}function Kn(n,e){return za(n,e).width}function So(n,e,t){if(e in t)return t[e];const i=e.split(` +`).reduce((s,r)=>Math.max(s,Kn(n,r)),0);return t[e]=i,i}function Ec(n,e){const t=[],i=[],s=[];let r=0,o=0,a=0,l=0;for(let c=0,h=e.length;c<=h;c+=2){const u=e[c];if(u===` +`||c===h){r=Math.max(r,o),s.push(o),o=0,a+=l;continue}const d=e[c+1]||n.font,f=Kn(d,u);t.push(f),o+=f;const g=yc(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:t,heights:i,lineWidths:s}}function xc(n,e,t,i,s,r,o,a,l,c,h){n.save(),t!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=t:n.globalAlpha*=t),e&&n.transform.apply(n,e),i.contextInstructions?(n.translate(l,c),n.scale(h[0],h[1]),Ic(i,n)):h[0]<0||h[1]<0?(n.translate(l,c),n.scale(h[0],h[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,c,o*h[0],a*h[1]),n.restore()}function Ic(n,e){const t=n.contextInstructions;for(let i=0,s=t.length;ithis.imageState_=b.LOADED),this.render()}clone(){const e=this.getScale(),t=new gs({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(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return t.setOpacity(this.getOpacity()),t}getAnchor(){const e=this.size_,t=this.getDisplacement(),i=this.getScaleArray();return[e[0]/2-t[0]/i[0],e[1]/2+t[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(e){let t=this.canvases_[e];if(!t){const i=this.renderOptions_,s=pe(i.size*e,i.size*e);this.draw_(i,s,e),t=s.canvas,this.canvases_[e]=t}return t}getPixelRatio(e){return e}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(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,t,i){if(t===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return t;let s=this.radius_,r=this.radius2_===void 0?s:this.radius2_;if(sf&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=he(i[0],d,f),p=he(i[1],g,m);if(o&&t&&s){const y=30*s;_+=-y*Math.log(1+Math.max(0,d-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-m)/y)}return[_,p]}}function Tc(n){return n}function Ar(n,e,t,i){const s=V(e)/t[0],r=le(e)/t[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function Dr(n,e,t){let i=Math.min(n,e);const s=50;return i*=Math.log(1+s*Math.max(0,n/e-1))/s+1,t&&(i=Math.max(i,t),i/=Math.log(1+s*Math.max(0,t/n-1))/s+1),he(i,t/2,e*2)}function Sc(n,e,t,i){return e=e!==void 0?e:!0,function(s,r,o,a){if(s!==void 0){const l=n[0],c=n[n.length-1],h=t?Ar(l,t,o,i):l;if(a)return e?Dr(s,h,c):he(s,c,h);const u=Math.min(h,s),d=Math.floor(es(n,u,r));return n[d]>h&&d1&&typeof arguments[t-1]=="function"&&(i=arguments[t-1],--t);let s=0;for(;s0}getInteracting(){return this.hints_[ge.INTERACTING]>0}cancelAnimations(){this.setHint(ge.ANIMATING,-this.hints_[ge.ANIMATING]);let e;for(let t=0,i=this.animations_.length;t=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o0?c/l.duration:1;h>=1?(l.complete=!0,h=1):r=!1;const u=l.easing(h);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],m=l.targetCenter[1];this.nextCenter_=l.targetCenter;const _=d+u*(g-d),p=f+u*(m-f);this.targetCenter_=[_,p]}if(l.sourceResolution&&l.targetResolution){const d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=u===1?si(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),t=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(ge.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&An(o,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-t[0],s[1]-t[1]],gr(i,e-this.getRotation()),_h(i,t)),i}calculateCenterZoom(e,t){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=t[0]-e*(t[0]-s[0])/r,a=t[1]-e*(t[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(e){const t=this.viewportSize_;if(e){const i=t[0],s=t[1];return[Math.abs(i*Math.cos(e))+Math.abs(s*Math.sin(e)),Math.abs(i*Math.sin(e))+Math.abs(s*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const e=this.getCenterInternal();return e&&Js(e,this.getProjection())}getCenterInternal(){return this.get(He.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){const t=this.calculateExtentInternal(e);return pr(t,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();const t=this.getCenterInternal();K(t,"The view center is not defined");const i=this.getResolution();K(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return K(s!==void 0,"The view rotation is not defined"),$i(t,i,s,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(He.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(vt(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t=t||this.getViewportSizeMinusPadding_();const i=V(e)/t[0],s=le(e)/t[1];return Math.max(i,s)}getResolutionForValueFunction(e){e=e||2;const t=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(t/i)/Math.log(e);return function(r){return t/Math.pow(e,r*s)}}getRotation(){return this.get(He.ROTATION)}getValueForResolutionFunction(e){const t=Math.log(e||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/t;return function(o){return Math.log(i/o)/t/r}}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e);const i=this.padding_;return i&&(t=[t[0]-i[1]-i[3],t[1]-i[0]-i[2]]),t}getState(){const e=this.getProjection(),t=this.getResolution(),i=this.getRotation();let s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=Os(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],t,i)}return{center:s.slice(0),projection:e!==void 0?e:null,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e;const t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,i,s;if(this.resolutions_){const r=es(this.resolutions_,e,1);t=r,i=this.resolutions_[r],r==this.resolutions_.length-1?s=2:s=i/this.resolutions_[r+1]}else i=this.maxResolution_,s=this.zoomFactor_;return t+Math.log(i/e)/Math.log(s)}getResolutionForZoom(e){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;const t=he(Math.floor(e),0,this.resolutions_.length-2),i=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/Math.pow(i,he(e-t,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,t){let i;if(K(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){K(!Ai(e),"Cannot fit empty extent provided as `geometry`");const s=vt(e,this.getProjection());i=yo(s)}else if(e.getType()==="Circle"){const s=vt(e.getExtent(),this.getProjection());i=yo(s),i.rotate(this.getRotation(),Tt(s))}else i=e;this.fitInternal(i,t)}rotatedExtentForGeometry(e){const t=this.getRotation(),i=Math.cos(t),s=Math.sin(-t),r=e.getFlatCoordinates(),o=e.getStride();let a=1/0,l=1/0,c=-1/0,h=-1/0;for(let u=0,d=r.length;u{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t;const i=this.getMapInternal();!e&&i&&(e=i.getView()),e instanceof it?t={viewState:e.getState(),extent:e.calculateExtent()}:t=e,!t.layerStatesArray&&i&&(t.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;t.layerStatesArray?s=t.layerStatesArray.find(o=>o.layer===this):s=this.getLayerState();const r=this.getExtent();return Or(s,t.viewState)&&(!r||Re(r,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];let t;const i=this.getSource();if(i&&(t=i.getAttributions()),!t)return[];const s=e instanceof it?e.getViewStateAndExtent():e;let r=t(s);return Array.isArray(r)||(r=[r]),r}render(e,t){const i=this.getRenderer();return i.prepareFrame(e)?(this.rendered=!0,i.renderFrame(e,t)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,t){}renderDeferred(e){const t=this.getRenderer();t&&t.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(ee.MAP,e)}getMapInternal(){return this.get(ee.MAP)}setMap(e){this.mapPrecomposeKey_&&(ie(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(ie(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=U(e,Xe.PRECOMPOSE,function(t){const s=t.frameState.layerStatesArray,r=this.getLayerState(!1);K(!s.some(function(o){return o.layer===r.layer}),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),s.push(r)},this),this.mapRenderKey_=U(this,B.CHANGE,e.render,e),this.changed())}setSource(e){this.set(ee.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}}function Or(n,e){if(!n.visible)return!1;const t=e.resolution;if(t=n.maxResolution)return!1;const i=e.zoom;return i>n.minZoom&&i<=n.maxZoom}function Nc(n,e,t,i,s){Ya(n,e,t||0,i||n.length-1,s||Bc)}function Ya(n,e,t,i,s){for(;i>t;){if(i-t>600){var r=i-t+1,o=e-t+1,a=Math.log(r),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(r-l)/r)*(o-r/2<0?-1:1),h=Math.max(t,Math.floor(e-o*l/r+c)),u=Math.min(i,Math.floor(e+(r-o)*l/r+c));Ya(n,e,h,u,s)}var d=n[e],f=t,g=i;for(Xi(n,t,e),s(n[i],d)>0&&Xi(n,t,i);f0;)g--}s(n[t],d)===0?Xi(n,t,g):(g++,Xi(n,g,i)),g<=e&&(t=g+1),e<=g&&(i=g-1)}}function Xi(n,e,t){var i=n[e];n[e]=n[t],n[t]=i}function Bc(n,e){return ne?1:0}let ja=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!Pn(e,t))return i;const s=this.toBBox,r=[];for(;t;){for(let o=0;o=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(s,r,t)}_split(e,t){const i=e[t],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=_i(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,ui(i,this.toBBox),ui(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=_i([e,t]),this.data.height=e.height+1,this.data.leaf=!1,ui(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let s,r=1/0,o=1/0;for(let a=t;a<=i-t;a++){const l=ji(e,0,a,this.toBBox),c=ji(e,a,i,this.toBBox),h=Yc(l,c),u=ks(l)+ks(c);h=t;c--){const h=e.children[c];Ui(a,e.leaf?r(h):h),l+=Dn(a)}return l}_adjustParentBBoxes(e,t,i){for(let s=i;s>=0;s--)Ui(t[s],e)}_condense(e){for(let t=e.length-1,i;t>=0;t--)e[t].children.length===0?t>0?(i=e[t-1].children,i.splice(i.indexOf(e[t]),1)):this.clear():ui(e[t],this.toBBox)}};function Gc(n,e,t){if(!t)return e.indexOf(n);for(let i=0;i=n.minX&&e.maxY>=n.minY}function _i(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Do(n,e,t,i,s){const r=[e,t];for(;r.length;){if(t=r.pop(),e=r.pop(),t-e<=i)continue;const o=e+Math.ceil((t-e)/i/2)*i;Nc(n,o,e,t,s),r.push(e,o,o,t)}}function Po(n,e,t,i){return t!==void 0&&i!==void 0?[t/n,i/e]:t!==void 0?t/n:i!==void 0?i/e:1}class yn extends ds{constructor(e){e=e||{};const t=e.opacity!==void 0?e.opacity:1,i=e.rotation!==void 0?e.rotation:0,s=e.scale!==void 0?e.scale:1,r=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:t,rotation:i,scale:s,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:r,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;const o=e.img!==void 0?e.img:null;let a=e.src;K(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||J(o)),K(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),K(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(e.src!==void 0?l=b.IDLE:o!==void 0&&(o instanceof HTMLImageElement?o.complete?l=o.src?b.LOADED:b.IDLE:l=b.LOADING:l=b.LOADED),this.color_=e.color!==void 0?nn(e.color):null,this.iconImage_=Sr(o,a,this.crossOrigin_,l,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,e.width!==void 0||e.height!==void 0){let c,h;if(e.size)[c,h]=e.size;else{const u=this.getImage(1);if(u.width&&u.height)c=u.width,h=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=e;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(Po(f[0],f[1],e.width,e.height))};this.listenImageChange(d);return}}c!==void 0&&this.setScale(Po(c,h,e.width,e.height))}}clone(){let e,t,i;return this.initialOptions_?(t=this.initialOptions_.width,i=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new yn({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:e,width:t,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;const s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=s[0]),this.anchorYUnits_=="fraction"&&(e[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+s[1])}this.normalizedAnchor_=e}const t=this.getDisplacement(),i=this.getScaleArray();return[e[0]-t[0]/i[0],e[1]+t[1]/i[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){const t=this.getSize(),i=this.iconImage_.getSize();if(!t||!i)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=i[0]-t[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=i[1]-t[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==b.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){const e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==b.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(B.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(B.CHANGE,e)}ready(){return this.iconImage_.ready()}}let Pi=0;const Oi=0,re=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"},Kc={[w.Get]:N(([n,e])=>e!==void 0?Zc(e.value):Ee,X(1,2),Hc),[w.Var]:N(([n])=>n.type,X(1,1),qc),[w.Id]:N(M|Pe,Yi,$c),[w.Concat]:N(Pe,X(2,1/0),Z(Ee)),[w.GeometryType]:N(Pe,Yi,Jc),[w.Resolution]:N(M,Yi),[w.Zoom]:N(M,Yi),[w.Time]:N(M,Yi),[w.Any]:N(re,X(2,1/0),Z(re)),[w.All]:N(re,X(2,1/0),Z(re)),[w.Not]:N(re,X(1,1),Z(re)),[w.Equal]:N(re,X(2,2),Z(Ee),Mt),[w.NotEqual]:N(re,X(2,2),Z(Ee),Mt),[w.GreaterThan]:N(re,X(2,2),Z(Ee),Mt),[w.GreaterThanOrEqualTo]:N(re,X(2,2),Z(Ee),Mt),[w.LessThan]:N(re,X(2,2),Z(Ee),Mt),[w.LessThanOrEqualTo]:N(re,X(2,2),Z(Ee),Mt),[w.Multiply]:N(n=>{let e=M|me;for(let t=0;t{let e=Ee;for(let t=1;t{let e=Ee;for(let t=2;t{let e=me|M;for(let t=3;t{let e=Ee;for(let t=1;tn.length===3||n.length===4?St|me:St,X(1,1/0),Z(M)),[w.Color]:N(me,X(1,4),Z(M)),[w.Band]:N(M,X(1,3),Z(M)),[w.Palette]:N(me,X(2,2),su),[w.ToString]:N(Pe,X(1,1),Z(re|M|Pe|me))};function Hc(n,e){const t=$(n[1],e);if(!(t instanceof Gt))throw new Error("Expected a literal argument for get operation");if(typeof t.value!="string")throw new Error("Expected a string argument for get operation");if(e.properties.add(t.value),n.length===3){const i=$(n[2],e);return[t,i]}return[t]}function qc(n,e,t,i){const s=n[1];if(typeof s!="string")throw new Error("Expected a string argument for var operation");if(e.variables.add(s),!("variables"in e.style)||e.style.variables[s]===void 0)return[new Gt(Ee,s)];const r=e.style.variables[s],o=$(r,e);if(o.value=s,i&&!lt(i,o.type))throw new Error(`The variable ${s} has type ${Ie(o.type)} but the following type was expected: ${Ie(i)}`);return[o]}function $c(n,e){e.featureId=!0}function Jc(n,e){e.geometryType=!0}function Yi(n,e){const t=n[0];if(n.length!==1)throw new Error(`Expected no arguments for ${t} operation`);return[]}function X(n,e){return function(t,i){const s=t[0],r=t.length-1;if(n===e){if(r!==n){const o=n===1?"":"s";throw new Error(`Expected ${n} argument${o} for ${s}, got ${r}`)}}else if(re){const o=e===1/0?`${n} or more`:`${n} to ${e}`;throw new Error(`Expected ${o} arguments for ${s}, got ${r}`)}}}function Z(n){return function(e,t){const i=e[0],s=e.length-1,r=new Array(s);for(let o=0;oi.featureId;case w.GeometryType:return i=>i.geometryType;case w.Concat:{const i=n.args.map(s=>Je(s));return s=>"".concat(...i.map(r=>r(s).toString()))}case w.Resolution:return i=>i.resolution;case w.Any:case w.All:case w.Between:case w.In:case w.Not:return hu(n);case w.Equal:case w.NotEqual:case w.LessThan:case w.LessThanOrEqualTo:case w.GreaterThan:case w.GreaterThanOrEqualTo:return lu(n);case w.Multiply:case w.Divide:case w.Add:case w.Subtract:case w.Clamp:case w.Mod:case w.Pow:case w.Abs:case w.Floor:case w.Ceil:case w.Round:case w.Sin:case w.Cos:case w.Atan:case w.Sqrt:return cu(n);case w.Case:return uu(n);case w.Match:return du(n);case w.Interpolate:return fu(n);case w.ToString:return gu(n);default:throw new Error(`Unsupported operator ${t}`)}}function ou(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;os.properties[i];case w.Var:return s=>s.variables[i];default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function lu(n,e){const t=n.operator,i=Je(n.args[0]),s=Je(n.args[1]);switch(t){case w.Equal:return r=>i(r)===s(r);case w.NotEqual:return r=>i(r)!==s(r);case w.LessThan:return r=>i(r)i(r)<=s(r);case w.GreaterThan:return r=>i(r)>s(r);case w.GreaterThanOrEqualTo:return r=>i(r)>=s(r);default:throw new Error(`Unsupported comparison operator ${t}`)}}function hu(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;o{const o=s[0](r),a=s[1](r),l=s[2](r);return o>=a&&o<=l};case w.In:return r=>{const o=s[0](r);for(let a=1;a!s[0](r);default:throw new Error(`Unsupported logical operator ${t}`)}}function cu(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{let o=1;for(let a=0;as[0](r)/s[1](r);case w.Add:return r=>{let o=0;for(let a=0;as[0](r)-s[1](r);case w.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(ol?l:o};case w.Mod:return r=>s[0](r)%s[1](r);case w.Pow:return r=>Math.pow(s[0](r),s[1](r));case w.Abs:return r=>Math.abs(s[0](r));case w.Floor:return r=>Math.floor(s[0](r));case w.Ceil:return r=>Math.ceil(s[0](r));case w.Round:return r=>Math.round(s[0](r));case w.Sin:return r=>Math.sin(s[0](r));case w.Cos:return r=>Math.cos(s[0](r));case w.Atan:return i===2?r=>Math.atan2(s[0](r),s[1](r)):r=>Math.atan(s[0](r));case w.Sqrt:return r=>Math.sqrt(s[0](r));default:throw new Error(`Unsupported numeric operator ${t}`)}}function uu(n,e){const t=n.args.length,i=new Array(t);for(let s=0;s{for(let r=0;r{const r=i[0](s);for(let o=1;o{const r=i[0](s),o=i[1](s);let a,l;for(let c=2;c=o)return c===2?u:d?mu(r,o,a,l,h,u):Vi(r,o,a,l,h,u);a=h,l=u}return l}}function gu(n,e){const t=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r{const o=s[0](r);return n.args[0].type===me?Rr(o):o.toString()};default:throw new Error(`Unsupported convert operator ${t}`)}}function Vi(n,e,t,i,s,r){const o=s-t;if(o===0)return i;const a=e-t,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function mu(n,e,t,i,s,r){if(s-t===0)return i;const a=Io(i),l=Io(r);let c=l[2]-a[2];c>180?c-=360:c<-180&&(c+=360);const h=[Vi(n,e,t,a[0],s,l[0]),Vi(n,e,t,a[1],s,l[1]),a[2]+Vi(n,e,t,0,s,c),Vi(n,e,t,i[3],s,r[3])];return ba(Qh(h))}function _u(n){return!0}function pu(n){const e=Va(),t=yu(n,e),i=Ka();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,e.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return e.geometryType&&(i.geometryType=Za(s.getGeometry())),t(i)}}function ko(n){const e=Va(),t=n.length,i=new Array(t);for(let o=0;o4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return t}function Ja(n,e){const t=En(n,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function bu(n,e){return typeof n=="number"?n:Ja(n,e)}const Go={RENDER_ORDER:"renderOrder"};class Qa extends pn{constructor(e){e=e||{};const t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Go.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){const i=this.getDeclutter();i in e.declutter||(e.declutter[i]=new ja(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(Go.RENDER_ORDER,e)}setStyle(e){this.style_=Mu(e),this.styleFunction_=e===null?void 0:vc(this.style_),this.changed()}}function Mu(n){if(n===void 0)return wc;if(!n)return null;if(typeof n=="function"||n instanceof Ki)return n;if(!Array.isArray(n))return ko([n]);if(n.length===0)return[];const e=n.length,t=n[0];if(t instanceof Ki){const s=new Array(e);for(let r=0;rl&&(this.instructions.push([A.CUSTOM,l,h,e,i,Ii,r]),this.hitDetectionInstructions.push([A.CUSTOM,l,h,e,s||i,Ii,r]));break;case"Point":c=e.getFlatCoordinates(),this.coordinates.push(c[0],c[1]),h=this.coordinates.length,this.instructions.push([A.CUSTOM,l,h,e,i,void 0,r]),this.hitDetectionInstructions.push([A.CUSTOM,l,h,e,s||i,void 0,r]);break}this.endGeometry(t)}beginGeometry(e,t,i){this.beginGeometryInstruction1_=[A.BEGIN_GEOMETRY,t,0,e,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[A.BEGIN_GEOMETRY,t,0,e,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const e=this.hitDetectionInstructions;e.reverse();let t;const i=e.length;let s,r,o=-1;for(t=0;tthis.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(e){const t=e.fillStyle,i=[A.SET_FILL_STYLE,t];return typeof t!="string"&&i.push(e.fillPatternScale),i}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[A.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,this.applyPixelRatio(e.lineDash),e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){const i=e.fillStyle;(typeof i!="string"||e.currentFillStyle!=i)&&(i!==void 0&&this.instructions.push(t.call(this,e)),e.currentFillStyle=i)}updateStrokeStyle(e,t){const i=e.strokeStyle,s=e.lineCap,r=e.lineDash,o=e.lineDashOffset,a=e.lineJoin,l=e.lineWidth,c=e.miterLimit;(e.currentStrokeStyle!=i||e.currentLineCap!=s||r!=e.currentLineDash&&!Kt(e.currentLineDash,r)||e.currentLineDashOffset!=o||e.currentLineJoin!=a||e.currentLineWidth!=l||e.currentMiterLimit!=c)&&(i!==void 0&&t.call(this,e),e.currentStrokeStyle=i,e.currentLineCap=s,e.currentLineDash=r,e.currentLineDashOffset=o,e.currentLineJoin=a,e.currentLineWidth=l,e.currentMiterLimit=c)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const t=[A.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=oa(this.maxExtent),this.maxLineWidth>0)){const e=this.resolution*(this.maxLineWidth+1)/2;dr(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Au extends xn{constructor(e,t,i,s){super(e,t,i,s),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(e,t,i){if(!this.image_||this.maxExtent&&!ri(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,i);const s=e.getFlatCoordinates(),r=e.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([A.DRAW_IMAGE,o,a,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([A.DRAW_IMAGE,o,a,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(t)}drawMultiPoint(e,t,i){if(!this.image_)return;this.beginGeometry(e,t,i);const s=e.getFlatCoordinates(),r=[];for(let l=0,c=s.length;l=n){const g=(n-a+f)/f,m=We(c,u,g),_=We(h,d,g);l.push(m,_),r.push(l),l=[m,_],a==n&&(o+=s),a=0}else if(a0&&r.push(l),r}function Nu(n,e,t,i,s){let r=t,o=t,a=0,l=0,c=t,h,u,d,f,g,m,_,p,y,x;for(u=t;un&&(l>a&&(a=l,r=c,o=u),l=0,c=u-s)),d=f,_=y,p=x),g=E,m=I}return l+=f,l>a?[c,u]:[r,o]}const $n={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Bu extends xn{constructor(e,t,i,s){super(e,t,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[be]={fillStyle:be},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 e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,t,i){const s=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!s&&!r)return;const a=this.coordinates;let l=a.length;const c=e.getType();let h=null,u=e.getStride();if(o.placement==="line"&&(c=="LineString"||c=="MultiLineString"||c=="Polygon"||c=="MultiPolygon")){if(!Re(this.maxExtent,e.getExtent()))return;let d;if(h=e.getFlatCoordinates(),c=="LineString")d=[h.length];else if(c=="MultiLineString")d=e.getEnds();else if(c=="Polygon")d=e.getEnds().slice(0,1);else if(c=="MultiPolygon"){const _=e.getEndss();d=[];for(let p=0,y=_.length;p{const I=a[(y+E)*2]===h[E*u]&&a[(y+E)*2+1]===h[E*u+1];return I||--y,I})}this.saveTextStates_(),(o.backgroundFill||o.backgroundStroke)&&(this.setFillStrokeStyle(o.backgroundFill,o.backgroundStroke),o.backgroundFill&&this.updateFillStyle(this.state,this.createFill),o.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(e,t,i);let g=o.padding;if(g!=ti&&(o.scale[0]<0||o.scale[1]<0)){let y=o.padding[0],x=o.padding[1],E=o.padding[2],I=o.padding[3];o.scale[0]<0&&(x=-x,I=-I),o.scale[1]<0&&(y=-y,E=-E),g=[y,x,E,I]}const m=this.pixelRatio;this.instructions.push([A.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==ti?ti:g.map(function(y){return y*m}),!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const _=1/m,p=this.state.fillStyle;o.backgroundFill&&(this.state.fillStyle=be,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([A.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[_,_],NaN,this.declutterMode_,this.declutterImageWithText_,g,!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?be:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),o.backgroundFill&&(this.state.fillStyle=p,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(t)}}saveTextStates_(){const e=this.textStrokeState_,t=this.textState_,i=this.textFillState_,s=this.strokeKey_;e&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:t.font,textAlign:t.textAlign||on,justify:t.justify,textBaseline:t.textBaseline||Zn,scale:t.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(e,t){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,c=$n[s.textBaseline],h=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([A.DRAW_CHARS,e,t,c,s.overflow,a,s.maxAngle,l,h,r,d*l,u,o,1,this.declutterMode_]),this.hitDetectionInstructions.push([A.DRAW_CHARS,e,t,c,s.overflow,a&&be,s.maxAngle,l,h,r,d*l,u,o,1/l,this.declutterMode_])}setTextStyle(e,t){let i,s,r;if(!e)this.text_="";else{const o=e.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=at(o.getColor()||be)):(s=null,this.textFillState_=s);const a=e.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const g=a.getLineDash(),m=a.getLineDashOffset(),_=a.getWidth(),p=a.getMiterLimit();r.lineCap=a.getLineCap()||bi,r.lineDash=g?g.slice():Ct,r.lineDashOffset=m===void 0?Rt:m,r.lineJoin=a.getLineJoin()||Mi,r.lineWidth=_===void 0?an:_,r.miterLimit=p===void 0?sn:p,r.strokeStyle=at(a.getColor()||rn)}i=this.textState_;const l=e.getFont()||Ga;pc(l);const c=e.getScaleArray();i.overflow=e.getOverflow(),i.font=l,i.maxAngle=e.getMaxAngle(),i.placement=e.getPlacement(),i.textAlign=e.getTextAlign(),i.repeat=e.getRepeat(),i.justify=e.getJustify(),i.textBaseline=e.getTextBaseline()||Zn,i.backgroundFill=e.getBackgroundFill(),i.backgroundStroke=e.getBackgroundStroke(),i.padding=e.getPadding()||ti,i.scale=c===void 0?[1,1]:c;const h=e.getOffsetX(),u=e.getOffsetY(),d=e.getRotateWithView(),f=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=h===void 0?0:h,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textRotation_=f===void 0?0:f,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:J(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=s&&s.fillStyle?typeof s.fillStyle=="string"?s.fillStyle:"|"+J(s.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}const Gu={Circle:Wo,Default:xn,Image:Du,LineString:Ou,Polygon:Wo,Text:Bu};class zu{constructor(e,t,i,s){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const e={};for(const t in this.buildersByZIndex_){e[t]=e[t]||{};const i=this.buildersByZIndex_[t];for(const s in i){const r=i[s].finish();e[t][s]=r}}return e}getBuilder(e,t){const i=e!==void 0?e.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[t];if(r===void 0){const o=Gu[t];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[t]=r}return r}}class Wu extends gn{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.declutterExecutorGroup=null}getFeatures(e){return q()}getData(e){return null}prepareFrame(e){return q()}renderFrame(e,t){return q()}loadedTileCallback(e,t,i){e[t]||(e[t]={}),e[t][i.tileCoord.toString()]=i}createLoadedTileFinder(e,t,i){return(s,r)=>{const o=this.loadedTileCallback.bind(this,i,s);return e.forEachLoadedTile(t,s,r,o)}}forEachFeatureAtCoordinate(e,t,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){const t=e.target;(t.getState()===b.LOADED||t.getState()===b.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=b.LOADED&&t!=b.ERROR&&e.addEventListener(B.CHANGE,this.boundHandleImageChange_),t==b.IDLE&&(e.load(),t=e.getState()),t==b.LOADED}renderIfReadyAndVisible(){const e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}}class tl extends ct{constructor(e,t,i,s){super(e),this.inversePixelTransform=t,this.frameState=i,this.context=s}}class il{constructor(){Qr(this,"pushMethodArgs_",(...e)=>(this.instructions_[this.zIndex+this.offset_].push(e),this));this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(CanvasRenderingContext2D.prototype,{get:(e,t)=>{if(typeof Qs()[t]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(t),this.pushMethodArgs_},set:(e,t,i)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(t,i),!0)})}getContext(){return this.context_}draw(e){this.instructions_.forEach(t=>{for(let i=0,s=t.length;iL[2]}else P=E>T;const F=Math.PI,Y=[],G=v+i===e;e=v,_=0,p=R,d=n[e],f=n[e+1];let z;if(G){y(),z=Math.atan2(f-m,d-g),P&&(z+=z>0?-F:F);const L=(T+E)/2,k=(O+I)/2;return Y[0]=[L,k,(C-r)/2,z,s],Y}s=s.replace(/\n/g," ");for(let L=0,k=s.length;L0?-F:F),z!==void 0){let S=W-z;if(S+=S>F?-2*F:S<-F?2*F:0,Math.abs(S)>o)return null}z=W;const te=L;let j=0;for(;L0&&n.push(` +`,""),n.push(e,""),n}class Uu{constructor(e,t,i,s,r){this.overlaps=i,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=qe(),this.hitDetectionInstructions=s.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=s.fillStates||{},this.strokeStates=s.strokeStates||{},this.textStates=s.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new il:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,i,s){const r=e+t+i+s;if(this.labels_[r])return this.labels_[r];const o=s?this.strokeStates[s]:null,a=i?this.fillStates[i]:null,l=this.textStates[t],c=this.pixelRatio,h=[l.scale[0]*c,l.scale[1]*c],u=Array.isArray(e),d=l.justify?$n[l.justify]:Ns(Array.isArray(e)?e[0]:e,l.textAlign||on),f=s&&o.lineWidth?o.lineWidth:0,g=u?e:e.split(` +`).reduce(ju,[]),{width:m,height:_,widths:p,heights:y,lineWidths:x}=Ec(l,g),E=m+f,I=[],v=(E+2)*h[0],R=(_+f)*h[1],C={width:v<0?Math.floor(v):Math.ceil(v),height:R<0?Math.floor(R):Math.ceil(R),contextInstructions:I};(h[0]!=1||h[1]!=1)&&I.push("scale",h),s&&(I.push("strokeStyle",o.strokeStyle),I.push("lineWidth",f),I.push("lineCap",o.lineCap),I.push("lineJoin",o.lineJoin),I.push("miterLimit",o.miterLimit),I.push("setLineDash",[o.lineDash]),I.push("lineDashOffset",o.lineDashOffset)),i&&I.push("fillStyle",a.fillStyle),I.push("textBaseline","middle"),I.push("textAlign","center");const T=.5-d;let O=d*E+T*f;const P=[],F=[];let Y=0,G=0,z=0,L=0,k;for(let W=0,te=g.length;We?e-c:r,E=o+h>t?t-h:o,I=g[3]+x*d[0]+g[1],v=g[0]+E*d[1]+g[2],R=p-g[3],C=y-g[0];(m||u!==0)&&(At[0]=R,Dt[0]=R,At[1]=C,_t[1]=C,_t[0]=R+I,pt[0]=_t[0],pt[1]=C+v,Dt[1]=pt[1]);let T;return u!==0?(T=je(qe(),i,s,1,1,u,-i,-s),de(T,At),de(T,_t),de(T,pt),de(T,Dt),Vt(Math.min(At[0],_t[0],pt[0],Dt[0]),Math.min(At[1],_t[1],pt[1],Dt[1]),Math.max(At[0],_t[0],pt[0],Dt[0]),Math.max(At[1],_t[1],pt[1],Dt[1]),di)):Vt(Math.min(R,R+I),Math.min(C,C+v),Math.max(R,R+I),Math.max(C,C+v),di),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:x,drawImageH:E,originX:c,originY:h,declutterBox:{minX:di[0],minY:di[1],maxX:di[2],maxY:di[3],value:_},canvasTransform:T,scale:d}}replayImageOrLabel_(e,t,i,s,r,o,a){const l=!!(o||a),c=s.declutterBox,h=a?a[2]*s.scale[0]/2:0;return c.minX-h<=t[0]&&c.maxX+h>=0&&c.minY-h<=t[1]&&c.maxY+h>=0&&(l&&this.replayTextBackground_(e,At,_t,pt,Dt,o,a),xc(e,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(e){const t=this.alignAndScaleFill_;if(t){const i=de(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;e.save(),e.translate(i[0]%s,i[1]%s),t!==1&&e.scale(t,t),e.rotate(this.viewRotation_)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6])}drawLabelWithPointPlacement_(e,t,i,s){const r=this.textStates[t],o=this.createLabel(e,t,s,i),a=this.strokeStates[i],l=this.pixelRatio,c=Ns(Array.isArray(e)?e[0]:e,r.textAlign||on),h=$n[r.textBaseline||Zn],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=c*d+2*(.5-c)*u,g=h*o.height/l+2*(.5-h)*u;return{label:o,anchorX:f,anchorY:g}}execute_(e,t,i,s,r,o,a,l){const c=this.zIndexContext_;let h;this.pixelCoordinates_&&Kt(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=Xt(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),$l(this.renderedTransform_,i));let u=0;const d=s.length;let f=0,g,m,_,p,y,x,E,I,v,R,C,T,O,P=0,F=0,Y=null,G=null;const z=this.coordinateCache_,L=this.viewRotation_,k=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,W={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:L},te=this.instructions!=s||this.overlaps?0:200;let j,Q,H,ae;for(;ute&&(this.fill_(e),P=0),F>te&&(e.stroke(),F=0),!P&&!F&&(e.beginPath(),y=NaN,x=NaN),++u;break;case A.CIRCLE:f=S[1];const Ae=h[f],ce=h[f+1],Te=h[f+2],Ve=h[f+3],Se=Te-Ae,Fi=Ve-ce,Ht=Math.sqrt(Se*Se+Fi*Fi);e.moveTo(Ae+Ht,ce),e.arc(Ae,ce,Ht,0,2*Math.PI,!0),++u;break;case A.CLOSE_PATH:e.closePath(),++u;break;case A.CUSTOM:f=S[1],g=S[2];const vs=S[3],wn=S[4],Cn=S[5];W.geometry=vs,W.feature=j,u in z||(z[u]=[]);const ke=z[u];Cn?Cn(h,f,g,2,ke):(ke[0]=h[f],ke[1]=h[f+1],ke.length=2),c&&(c.zIndex=S[6]),wn(ke,W),++u;break;case A.DRAW_IMAGE:f=S[1],g=S[2],v=S[3],m=S[4],_=S[5];let ai=S[6];const Rn=S[7],ws=S[8],Tn=S[9],Sn=S[10];let De=S[11];const Ze=S[12];let et=S[13];p=S[14]||"declutter";const Ke=S[15];if(!v&&S.length>=20){R=S[19],C=S[20],T=S[21],O=S[22];const Fe=this.drawLabelWithPointPlacement_(R,C,T,O);v=Fe.label,S[3]=v;const qt=S[23];m=(Fe.anchorX-qt)*this.pixelRatio,S[4]=m;const Ne=S[24];_=(Fe.anchorY-Ne)*this.pixelRatio,S[5]=_,ai=v.height,S[6]=ai,et=v.width,S[13]=et}let li;S.length>25&&(li=S[25]);let hi,bt,dt;S.length>17?(hi=S[16],bt=S[17],dt=S[18]):(hi=ti,bt=!1,dt=!1),Sn&&k?De+=L:!Sn&&!k&&(De-=L);let Cs=0;for(;f!nl.includes(n));class Zu{constructor(e,t,i,s,r,o,a){this.maxExtent_=e,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=t,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=qe(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(e,t){const i=this.getClipCoords(t);e.beginPath(),e.moveTo(i[0],i[1]),e.lineTo(i[2],i[3]),e.lineTo(i[4],i[5]),e.lineTo(i[6],i[7]),e.clip()}createExecutors_(e,t){for(const i in e){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=e[i];for(const o in r){const a=r[o];s[o]=new Uu(this.resolution_,this.pixelRatio_,this.overlaps_,a,t)}}}hasExecutors(e){for(const t in this.executorsByZIndex_){const i=this.executorsByZIndex_[t];for(let s=0,r=e.length;s0){if(!o||f!=="Image"&&f!=="Text"||o.includes(I)){const O=(d[C]-3)/4,P=s-O%a,F=s-(O/a|0),Y=r(I,v,P*P+F*F);if(Y)return Y}h.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(wt);let _,p,y,x,E;for(_=m.length-1;_>=0;--_){const I=m[_].toString();for(y=this.executorsByZIndex_[I],p=Hi.length-1;p>=0;--p)if(f=Hi[p],x=y[f],x!==void 0&&(E=x.executeHitDetection(h,l,i,g,u),E))return E}}getClipCoords(e){const t=this.maxExtent_;if(!t)return null;const i=t[0],s=t[1],r=t[2],o=t[3],a=[i,s,i,o,r,o,r,s];return Xt(a,0,8,2,e,a),a}isEmpty(){return Si(this.executorsByZIndex_)}execute(e,t,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(wt),o=o||Hi;let c,h,u,d,f,g;for(a&&l.reverse(),c=0,h=l.length;c{r.draw(this.renderedContext_),r.clear()})}}const Bs={};function Ku(n){if(Bs[n]!==void 0)return Bs[n];const e=n*2+1,t=n*n,i=new Array(t+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>t)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*e+(n+o))*4+3),r>0&&l.push(((n-r)*e+(n+o))*4+3),o>0&&(l.push(((n+r)*e+(n-o))*4+3),r>0&&l.push(((n-r)*e+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;ru*this.pixelRatio_),lineDashOffset:(o||Rt)*this.pixelRatio_,lineJoin:a!==void 0?a:Mi,lineWidth:(l!==void 0?l:an)*this.pixelRatio_,miterLimit:c!==void 0?c:sn,strokeStyle:at(i||rn)}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}const i=e.getPixelRatio(this.pixelRatio_),s=e.getAnchor(),r=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[1]*i,this.imageHeight_=t[1]*i,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();const o=e.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=t[0]*i}setTextStyle(e){if(!e)this.text_="";else{const t=e.getFill();if(!t)this.textFillState_=null;else{const f=t.getColor();this.textFillState_={fillStyle:at(f||be)}}const i=e.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),m=i.getLineDash(),_=i.getLineDashOffset(),p=i.getLineJoin(),y=i.getWidth(),x=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:bi,lineDash:m||Ct,lineDashOffset:_||Rt,lineJoin:p!==void 0?p:Mi,lineWidth:y!==void 0?y:an,miterLimit:x!==void 0?x:sn,strokeStyle:at(f||rn)}}const s=e.getFont(),r=e.getOffsetX(),o=e.getOffsetY(),a=e.getRotateWithView(),l=e.getRotation(),c=e.getScaleArray(),h=e.getText(),u=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:s!==void 0?s:Ga,textAlign:u!==void 0?u:on,textBaseline:d!==void 0?d:Zn},this.text_=h!==void 0?Array.isArray(h)?h.reduce((f,g,m)=>f+=m%2?" ":g,""):h:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*c[0],this.pixelRatio_*c[1]]}}}const qu=Hu,nt=.5;function $u(n,e,t,i,s,r,o,a,l){const c=l?pr(s):s,h=n[0]*nt,u=n[1]*nt,d=pe(h,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new qu(d,nt,s,null,o,a,l?ls(Rh(),l):null),m=t.length,_=Math.floor((256*256*256-1)/m),p={};for(let x=1;x<=m;++x){const E=t[x-1],I=E.getStyleFunction()||i;if(!I)continue;let v=I(E,r);if(!v)continue;Array.isArray(v)||(v=[v]);const C=(x*_).toString(16).padStart(7,"#00000");for(let T=0,O=v.length;T0;return u&&Promise.all(l).then(()=>s(null)),id(n,e,t,i,r,o,a),u}function id(n,e,t,i,s,r,o){const a=t.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(i,s);if(t.getRenderer())ol(n,l,t,e,o);else{const h=sl[l.getType()];h(n,l,t,e,o,r)}}function ol(n,e,t,i,s){if(e.getType()=="GeometryCollection"){const o=e.getGeometries();for(let a=0,l=o.length;a{if(!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=[this.context.canvas.width,this.context.canvas.height];de(this.pixelTransform,i);const s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,c=this.getLayer(),h=[],u=i[0]*nt,d=i[1]*nt;h.push(this.getRenderTransform(s,r,o,nt,u,d,0).slice());const f=c.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!rt(g,l)){let m=l[0];const _=V(g);let p=0,y;for(;mg[2];)++p,y=_*p,h.push(this.getRenderTransform(s,r,o,nt,u,d,y).slice()),m-=_}this.hitDetectionImageData_=$u(i,h,this.renderedFeatures_,c.getStyleFunction(),l,r,o,Uo(r,this.renderedPixelRatio_),null)}t(Ju(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,i,s,r){if(!this.replayGroup_)return;const o=t.viewState.resolution,a=t.viewState.rotation,l=this.getLayer(),c={},h=function(g,m,_){const p=J(g),y=c[p];if(y){if(y!==!0&&_u=g.forEachFeatureAtCoordinate(e,o,a,i,h,f&&t.declutter[f]?t.declutter[f].all().map(m=>m.value):null)),u}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){const t=this.getLayer(),i=t.getSource();if(!i)return!1;const s=e.viewHints[ge.ANIMATING],r=e.viewHints[ge.INTERACTING],o=t.getUpdateWhileAnimating(),a=t.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=e.extent,c=e.viewState,h=c.projection,u=c.resolution,d=e.pixelRatio,f=t.getRevision(),g=t.getRenderBuffer();let m=t.getRenderOrder();m===void 0&&(m=ed);const _=c.center.slice(),p=dr(l,g*u),y=p.slice(),x=[p.slice()],E=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!rt(E,e.extent)){const G=V(E),z=Math.max(V(p)/2,G);p[0]=E[0]-z,p[2]=E[2]+z,ma(_,h);const L=da(x[0],h);L[0]E[0]&&L[2]>E[2]&&x.push([L[0]-G,L[1],L[2]-G,L[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&rt(this.wrappedRenderedExtent_,p))return Kt(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const I=new zu(rl(u,d),p,u,d);let v;for(let G=0,z=x.length;G{let L;const k=G.getStyleFunction()||t.getStyleFunction();if(k&&(L=k(G,u)),L){const W=this.renderFeature(G,R,L,I,v,this.getLayer().getDeclutter(),z);C=C&&!W}},O=pr(p),P=i.getFeaturesInExtent(O);m&&P.sort(m);for(let G=0,z=P.length;G{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),t&&this.simplifiedGeometry_.applyTransform(t);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=Er(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=Fh(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,i,0,s);break;case"Polygon":s=[],i.length=va(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),i,0,s);break}return s&&(this.simplifiedGeometry_=new ze(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}}ze.prototype.getFlatCoordinates=ze.prototype.getOrientedFlatCoordinates;class Nr extends Qe{constructor(e){super(),this.projection=ve(e.projection),this.attributions_=Ho(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible!==void 0?e.attributionsCollapsible:!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;const t=this;this.viewPromise_=new Promise(function(i,s){t.viewResolver=i,t.viewRejector=s})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=Ho(e),this.changed()}setState(e){this.state_=e,this.changed()}}function Ho(n){return n?Array.isArray(n)?function(e){return n}:typeof n=="function"?n:function(e){return[n]}:null}const Ge={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function dd(n,e){return[[-1/0,-1/0,1/0,1/0]]}let fd=!1;function gd(n,e,t,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(t,i,s):n,!0),e.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=fd,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const c=e.getType();let h;c=="json"?h=JSON.parse(a.responseText):c=="text"?h=a.responseText:c=="xml"?(h=a.responseXML,h||(h=new DOMParser().parseFromString(a.responseText,"application/xml"))):c=="arraybuffer"&&(h=a.response),h?r(e.readFeatures(h,{extent:t,featureProjection:s}),e.readProjection(h)):o()}else o()},a.onerror=o,a.send()}function qo(n,e){return function(t,i,s,r,o){const a=this;gd(n,e,t,i,s,function(l,c){a.addFeatures(l),r!==void 0&&r(l)},o||Ti)}}class Pt extends ct{constructor(e,t,i){super(e),this.feature=t,this.features=i}}class ll extends Nr{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=Ti,this.format_=e.format,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(K(this.format_,"`format` must be set when `url` is set"),this.loader_=qo(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:dd;const t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Zo:null,this.loadedExtentsRtree_=new Zo,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(e.features)?s=e.features:e.features&&(i=e.features,s=i.getArray()),!t&&i===void 0&&(i=new st(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){const t=J(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);const i=e.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new Pt(Ge.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof ze||(this.featureChangeKeys_[e]=[U(t,B.CHANGE,this.handleFeatureChange_,this),U(t,Ri.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let i=!0;if(t.getId()!==void 0){const s=String(t.getId());if(!(s in this.idIndex_))this.idIndex_[s]=t;else if(t instanceof ze){const r=this.idIndex_[s];r instanceof ze?Array.isArray(r)?r.push(t):this.idIndex_[s]=[r,t]:i=!1}else i=!1}return i&&(K(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),i}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){const t=[],i=[],s=[];for(let r=0,o=e.length;r{t||(t=!0,this.addFeature(i.element),t=!1)}),e.addEventListener(Le.REMOVE,i=>{t||(t=!0,this.removeFeature(i.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(ie);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){const i=s=>{this.removeFeatureInternal(s)};this.featuresRtree_.forEach(i);for(const s in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[s])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const t=new Pt(Ge.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){const i=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(i,function(s){const r=s.getGeometry();if(r instanceof ze||r.intersectsCoordinate(e))return t(s)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(i){const s=i.getGeometry();if(s instanceof ze||s.intersectsExtent(e)){const r=t(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),Si(this.nullGeometryFeatures_)||hr(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){const t=[];return this.forEachFeatureAtCoordinateDirect(e,function(i){t.push(i)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);const s=sh(e,t);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){const i=e[0],s=e[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return t=t||qi,this.featuresRtree_.forEachInExtent(l,function(c){if(t(c)){const h=c.getGeometry(),u=a;if(a=h instanceof ze?0:h.closestPointXY(i,s,o,a),a{--this.loadingExtentsCount_,this.dispatchEvent(new Pt(Ge.FEATURESLOADEND,void 0,h))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Pt(Ge.FEATURESLOADERROR))}),s.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){const t=this.loadedExtentsRtree_;let i;t.forEachInExtent(e,function(s){if(Li(s.extent,e))return i=s,!0}),i&&t.remove(i)}removeFeatures(e){const t=[];for(let i=0,s=e.length;i0&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){const t=J(e);t in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[t]:this.featuresRtree_&&this.featuresRtree_.remove(e);const i=this.featureChangeKeys_[t];if(!i)return;i.forEach(ie),delete this.featureChangeKeys_[t];const s=e.getId();return s!==void 0&&delete this.idIndex_[s.toString()],delete this.uidIndex_[t],this.hasListener(Ge.REMOVEFEATURE)&&this.dispatchEvent(new Pt(Ge.REMOVEFEATURE,e)),e}removeFromIdIndex_(e){let t=!1;for(const i in this.idIndex_){const s=this.idIndex_[i];if(e instanceof ze&&Array.isArray(s)&&s.includes(e))s.splice(s.indexOf(e),1);else if(this.idIndex_[i]===e){delete this.idIndex_[i],t=!0;break}}return t}setLoader(e){this.loader_=e}setUrl(e){K(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(qo(e,this.format_))}}const D={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};class hl extends fn{constructor(e,t,i){super(),i=i||{},this.tileCoord=e,this.state=t,this.interimTile=null,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(B.CHANGE)}release(){this.state===D.ERROR&&this.setState(D.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getInterimTile(){let e=this.interimTile;if(!e)return this;do{if(e.getState()==D.LOADED)return this.transition_=0,e;e=e.interimTile}while(e);return this}refreshInterimChain(){let e=this.interimTile;if(!e)return;let t=this;do{if(e.getState()==D.LOADED){e.interimTile=null;break}e.getState()==D.LOADING?t=e:e.getState()==D.IDLE?t.interimTile=e.interimTile:t=e,e=t.interimTile}while(e)}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==D.ERROR&&this.state>e)throw new Error("Tile load sequence violation");this.state=e,this.changed()}load(){q()}getAlpha(e,t){if(!this.transition_)return 1;let i=this.transitionStarts_[e];if(!i)i=t,this.transitionStarts_[e]=i;else if(i===-1)return 1;const s=t-i+1e3/60;return s>=this.transition_?1:Xa(s/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}}class cl extends hl{constructor(e,t,i,s,r,o){super(e,t,o),this.crossOrigin_=s,this.src_=i,this.key=i,this.image_=new Image,s!==null&&(this.image_.crossOrigin=s),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(e){this.image_=e,this.state=D.LOADED,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=D.ERROR,this.unlistenImage_(),this.image_=md(),this.changed()}handleImageLoad_(){const e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=D.LOADED:this.state=D.EMPTY,this.unlistenImage_(),this.changed()}load(){this.state==D.ERROR&&(this.state=D.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==D.IDLE&&(this.state=D.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=lc(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}}function md(){const n=pe(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}class _d{constructor(e,t,i){this.decay_=e,this.minVelocity_=t,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;const e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]0&&this.points_[i+2]>e;)i-=3;const s=this.points_[t+2]-this.points_[i+2];if(s<1e3/60)return!1;const r=this.points_[t]-this.points_[i],o=this.points_[t+1]-this.points_[i+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/s,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}class pd extends lr{constructor(e){super(),this.map_=e}dispatchRenderEvent(e,t){q()}calculateMatrices2D(e){const t=e.viewState,i=e.coordinateToPixelTransform,s=e.pixelToCoordinateTransform;je(i,e.size[0]/2,e.size[1]/2,1/t.resolution,-1/t.resolution,-t.rotation,-t.center[0],-t.center[1]),is(s,i)}forEachFeatureAtCoordinate(e,t,i,s,r,o,a,l){let c;const h=t.viewState;function u(E,I,v,R){return r.call(o,I,E?v:null,R)}const d=h.projection,f=ma(e.slice(),d),g=[[0,0]];if(d.canWrapX()&&s){const E=d.getExtent(),I=V(E);g.push([-I,0],[I,0])}const m=t.layerStatesArray,_=m.length,p=[],y=[];for(let E=0;E=0;--I){const v=m[I],R=v.layer;if(R.hasRenderer()&&Or(v,h)&&a.call(l,R)){const C=R.getRenderer(),T=R.getSource();if(C&&T){const O=T.getWrapX()?f:e,P=u.bind(null,v.managed);y[0]=O[0]+g[E][0],y[1]=O[1]+g[E][1],c=C.forEachFeatureAtCoordinate(y,t,i,P,p)}if(c)return c}}if(p.length===0)return;const x=1/p.length;return p.forEach((E,I)=>E.distanceSq+=I*x),p.sort((E,I)=>E.distanceSq-I.distanceSq),p.some(E=>c=E.callback(E.feature,E.layer,E.geometry)),c}hasFeatureAtCoordinate(e,t,i,s,r,o){return this.forEachFeatureAtCoordinate(e,t,i,s,qi,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(e){q()}scheduleExpireIconCache(e){ot.canExpireCache()&&e.postRenderFunctions.push(yd)}}function yd(n,e){ot.expire()}class Ed extends pd{constructor(e){super(e),this.fontChangeListenerKey_=U(Et,Ri.PROPERTYCHANGE,e.redrawText.bind(e)),this.element_=document.createElement("div");const t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=fs+" ol-layers";const i=e.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(e,t){const i=this.getMap();if(i.hasListener(e)){const s=new tl(e,void 0,t);i.dispatchEvent(s)}}disposeInternal(){ie(this.fontChangeListenerKey_),this.element_.parentNode.removeChild(this.element_),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(Xe.PRECOMPOSE,e);const t=e.layerStatesArray.sort(function(a,l){return a.zIndex-l.zIndex});t.some(a=>a.layer instanceof Qa&&a.layer.getDeclutter())&&(e.declutter={});const s=e.viewState;this.children_.length=0;const r=[];let o=null;for(let a=0,l=t.length;a=0;--i){const s=t[i],r=s.layer;r.getDeclutter()&&r.renderDeclutter(e,s)}t.forEach(i=>i.layer.renderDeferred(e))}}class Ft extends ct{constructor(e,t){super(e),this.layer=t}}const Gs={LAYERS:"layers"};class ki extends Wa{constructor(e){e=e||{};const t=Object.assign({},e);delete t.layers;let i=e.layers;super(t),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Gs.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new st(i.slice(),{unique:!0}):K(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new st(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(ie),this.layersListenerKeys_.length=0;const e=this.getLayers();this.layersListenerKeys_.push(U(e,Le.ADD,this.handleLayersAdd_,this),U(e,Le.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(ie);dn(this.listenerKeys_);const t=e.getArray();for(let i=0,s=t.length;i{this.clickTimeoutId_=void 0;const i=new kt(oe.SINGLECLICK,this.map_,e);this.dispatchEvent(i)},250)}updateActivePointers_(e){const t=e,i=t.pointerId;if(t.type==oe.POINTERUP||t.type==oe.POINTERCANCEL){delete this.trackedTouches_[i];for(const s in this.trackedTouches_)if(this.trackedTouches_[s].target!==t.target){delete this.trackedTouches_[s];break}}else(t.type==oe.POINTERDOWN||t.type==oe.POINTERMOVE)&&(this.trackedTouches_[i]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);const t=new kt(oe.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(ie),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);const t=new kt(oe.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,"target",{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(U(i,oe.POINTERMOVE,this.handlePointerMove_,this),U(i,oe.POINTERUP,this.handlePointerUp_,this),U(this.element_,oe.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(U(this.element_.getRootNode(),oe.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;const t=new kt(oe.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;const t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new kt(oe.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){const t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!="boolean"||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(ie(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(B.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(ie(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(ie),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const xt={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},xe={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},Jn=1/0;class Id{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,dn(this.queuedElements_)}dequeue(){const e=this.elements_,t=this.priorities_,i=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));const s=this.keyFunction_(i);return delete this.queuedElements_[s],i}enqueue(e){K(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const t=this.priorityFunction_(e);return t!=Jn?(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){const t=this.elements_,i=this.priorities_,s=t.length,r=t[e],o=i[e],a=e;for(;e>1;){const l=this.getLeftChildIndex_(e),c=this.getRightChildIndex_(e),h=ce;){const a=this.getParentIndex_(t);if(s[a]>o)i[t]=i[a],s[t]=s[a],t=a;else break}i[t]=r,s[t]=o}reprioritize(){const e=this.priorityFunction_,t=this.elements_,i=this.priorities_;let s=0;const r=t.length;let o,a,l;for(a=0;a0;)r=this.dequeue()[0],o=r.getKey(),s=r.getState(),s===D.IDLE&&!(o in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[o]=!0,++this.tilesLoading_,++i,r.load())}}function wd(n,e,t,i,s){if(!n||!(t in n.wantedTiles)||!n.wantedTiles[t][e.getKey()])return Jn;const r=n.viewState.center,o=i[0]-r[0],a=i[1]-r[1];return 65536*Math.log(s)+Math.sqrt(o*o+a*a)/s}class ut extends Qe{constructor(e){super();const t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){Vn(this.element),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&Vn(this.element);for(let t=0,i=this.listenerKeys.length;ts.getAttributions(e)))),i=!this.getMap().getAllLayers().some(s=>s.getSource()&&s.getSource().getAttributionsCollapsible()===!1);return this.overrideCollapsible_||this.setCollapsible(i),t}async updateElement_(e){if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=await Promise.all(this.collectSourceAttributions_(e).map(s=>ra(()=>s))),i=t.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Kt(t,this.renderedAttributions_)){Oa(this.ulElement_);for(let s=0,r=t.length;s0&&i%(2*Math.PI)!==0?t.animate({rotation:0,duration:this.duration_,easing:Di}):t.setRotation(0))}render(e){const t=e.frameState;if(!t)return;const i=t.viewState.rotation;if(i!=this.rotation_){const s="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(Mn);!r&&i===0?this.element.classList.add(Mn):r&&i!==0&&this.element.classList.remove(Mn)}this.label_.style.transform=s}this.rotation_=i}}const Sd=Td;class Ld extends ut{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target});const t=e.className!==void 0?e.className:"ol-zoom",i=e.delta!==void 0?e.delta:1,s=e.zoomInClassName!==void 0?e.zoomInClassName:t+"-in",r=e.zoomOutClassName!==void 0?e.zoomOutClassName:t+"-out",o=e.zoomInLabel!==void 0?e.zoomInLabel:"+",a=e.zoomOutLabel!==void 0?e.zoomOutLabel:"–",l=e.zoomInTipLabel!==void 0?e.zoomInTipLabel:"Zoom in",c=e.zoomOutTipLabel!==void 0?e.zoomOutTipLabel:"Zoom out",h=document.createElement("button");h.className=s,h.setAttribute("type","button"),h.title=l,h.appendChild(typeof o=="string"?document.createTextNode(o):o),h.addEventListener(B.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=c,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(B.CLICK,this.handleClick_.bind(this,-i),!1);const d=t+" "+fs+" "+Lr,f=this.element;f.className=d,f.appendChild(h),f.appendChild(u),this.duration_=e.duration!==void 0?e.duration:250}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){const i=this.getMap().getView();if(!i)return;const s=i.getZoom();if(s!==void 0){const r=i.getConstrainedZoom(s+e);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:Di})):i.setZoom(r)}}}const bd=Ld;function ul(n){n=n||{};const e=new st;return(n.zoom!==void 0?n.zoom:!0)&&e.push(new bd(n.zoomOptions)),(n.rotate!==void 0?n.rotate:!0)&&e.push(new Sd(n.rotateOptions)),(n.attribution!==void 0?n.attribution:!0)&&e.push(new Rd(n.attributionOptions)),e}const $o={ACTIVE:"active"};class In extends Qe{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get($o.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set($o.ACTIVE,e)}setMap(e){this.map_=e}}function Md(n,e,t){const i=n.getCenterInternal();if(i){const s=[i[0]+e[0],i[1]+e[1]];n.animateInternal({duration:t!==void 0?t:250,easing:Dc,center:n.getConstrainedCenter(s)})}}function Br(n,e,t,i){const s=n.getZoom();if(s===void 0)return;const r=n.getConstrainedZoom(s+e),o=n.getResolutionForZoom(r);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:t,duration:i!==void 0?i:250,easing:Di})}class Ad extends In{constructor(e){super(),e=e||{},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:250}handleEvent(e){let t=!1;if(e.type==oe.DBLCLICK){const i=e.originalEvent,s=e.map,r=e.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=s.getView();Br(a,o,r,this.duration_),i.preventDefault(),t=!0}return!t}}const Dd=Ad;class vn extends In{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let t=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==oe.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==oe.POINTERUP){const i=this.handleUpEvent(e);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(e.type==oe.POINTERDOWN){const i=this.handleDownEvent(e);this.handlingDownUpSequence=i,t=this.stopDown(i)}else e.type==oe.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}}function Gr(n){const e=n.length;let t=0,i=0;for(let s=0;s0&&this.condition_(e)){const i=e.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}const zd=Gd;class Wd extends vn{constructor(e){e=e||{},super({stopDown:ts}),this.condition_=e.condition?e.condition:Pd,this.lastAngle_=void 0,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){if(!zs(e))return;const t=e.map,i=t.getView();if(i.getConstraints().rotation===Pr)return;const s=t.getSize(),r=e.pixel,o=Math.atan2(s[1]/2-r[1],r[0]-s[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(e){return zs(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return zs(e)&&fl(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class Xd extends lr{constructor(e){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const e=this.startPixel_,t=this.endPixel_,i="px",s=this.element_.style;s.left=Math.min(e[0],t[0])+i,s.top=Math.min(e[1],t[1])+i,s.width=Math.abs(t[0]-e[0])+i,s.height=Math.abs(t[1]-e[1])+i}setMap(e){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_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){const e=this.startPixel_,t=this.endPixel_,s=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);s[4]=s[0].slice(),this.geometry_?this.geometry_.setCoordinates([s]):this.geometry_=new en([s])}getGeometry(){return this.geometry_}}const kn={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class Ws extends ct{constructor(e,t,i){super(e),this.coordinate=t,this.mapBrowserEvent=i}}class Yd extends vn{constructor(e){super(),this.on,this.once,this.un,e=e||{},this.box_=new Xd(e.className||"ol-dragbox"),this.minArea_=e.minArea!==void 0?e.minArea:64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition?e.condition:fl,this.boxEndCondition_=e.boxEndCondition?e.boxEndCondition:this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,i){const s=i[0]-t[0],r=i[1]-t[1];return s*s+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new Ws(kn.BOXDRAG,e.coordinate,e))}handleUpEvent(e){this.box_.setMap(null);const t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new Ws(t?kn.BOXEND:kn.BOXCANCEL,e.coordinate,e)),!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new Ws(kn.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}}class jd extends Yd{constructor(e){e=e||{};const t=e.condition?e.condition:Nd;super({condition:t,className:e.className||"ol-dragzoom",minArea:e.minArea}),this.duration_=e.duration!==void 0?e.duration:200,this.out_=e.out!==void 0?e.out:!1}onBoxEnd(e){const i=this.getMap().getView();let s=this.getGeometry();if(this.out_){const r=i.rotatedExtentForGeometry(s),o=i.getResolutionForExtentInternal(r),a=i.getResolution()/o;s=s.clone(),s.scale(a*a)}i.fitInternal(s,{duration:this.duration_,easing:Di})}}const Ud=jd,Jt={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class Vd extends In{constructor(e){super(),e=e||{},this.defaultCondition_=function(t){return gl(t)&&ml(t)},this.condition_=e.condition!==void 0?e.condition:this.defaultCondition_,this.duration_=e.duration!==void 0?e.duration:100,this.pixelDelta_=e.pixelDelta!==void 0?e.pixelDelta:128}handleEvent(e){let t=!1;if(e.type==B.KEYDOWN){const i=e.originalEvent,s=i.key;if(this.condition_(e)&&(s==Jt.DOWN||s==Jt.LEFT||s==Jt.RIGHT||s==Jt.UP)){const o=e.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,c=0;s==Jt.DOWN?c=-a:s==Jt.LEFT?l=-a:s==Jt.RIGHT?l=a:c=a;const h=[l,c];gr(h,o.getRotation()),Md(o,h,this.duration_),i.preventDefault(),t=!0}}return!t}}class Zd extends In{constructor(e){super(),e=e||{},this.condition_=e.condition?e.condition:function(t){return!Fd(t)&&ml(t)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:100}handleEvent(e){let t=!1;if(e.type==B.KEYDOWN||e.type==B.KEYPRESS){const i=e.originalEvent,s=i.key;if(this.condition_(e)&&(s==="+"||s==="-")){const r=e.map,o=s==="+"?this.delta_:-this.delta_,a=r.getView();Br(a,o,void 0,this.duration_),i.preventDefault(),t=!0}}return!t}}const Kd=Zd;class Hd extends In{constructor(e){e=e||{},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta!==void 0?e.maxDelta:1,this.duration_=e.duration!==void 0?e.duration:250,this.timeout_=e.timeout!==void 0?e.timeout:80,this.useAnchor_=e.useAnchor!==void 0?e.useAnchor:!0,this.constrainResolution_=e.constrainResolution!==void 0?e.constrainResolution:!1;const t=e.condition?e.condition:kd;this.condition_=e.onFocusOnly?rr(dl,t):t,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 e=this.getMap();if(!e)return;e.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_)}handleEvent(e){if(!this.condition_(e)||e.type!==B.WHEEL)return!0;const i=e.map,s=e.originalEvent;s.preventDefault(),this.useAnchor_&&(this.lastAnchor_=e.coordinate);let r;if(e.type==B.WHEEL&&(r=s.deltaY,tc&&s.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(r/=Aa),s.deltaMode===WheelEvent.DOM_DELTA_LINE&&(r*=40)),r===0)return!1;this.lastDelta_=r;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const a=i.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-r/this.deltaPerZoom_,this.lastAnchor_),this.startTime_=o,!1;this.totalDelta_+=r;const l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),l),!1}handleWheelZoom_(e){const t=e.getView();t.getAnimating()&&t.cancelAnimations();let i=-he(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Br(t,i,this.lastAnchor_,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}}const qd=Hd;class $d extends vn{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=ts),super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold!==void 0?e.threshold:.3,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){let t=0;const i=this.targetPointers[0],s=this.targetPointers[1],r=Math.atan2(s.clientY-i.clientY,s.clientX-i.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),t=l}this.lastAngle_=r;const o=e.map,a=o.getView();a.getConstraints().rotation!==Pr&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Gr(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}class Jd extends vn{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=ts),super(t),this.anchor_=null,this.duration_=e.duration!==void 0?e.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1;const i=this.targetPointers[0],s=this.targetPointers[1],r=i.clientX-s.clientX,o=i.clientY-s.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(t=this.lastDistance_/a),this.lastDistance_=a;const l=e.map,c=l.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Gr(this.targetPointers))),l.render(),c.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){const i=e.map.getView(),s=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,s),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}const Qd=Jd;function ef(n){n=n||{};const e=new st,t=new _d(-.005,.05,100);return(n.altShiftDragRotate!==void 0?n.altShiftDragRotate:!0)&&e.push(new Wd),(n.doubleClickZoom!==void 0?n.doubleClickZoom:!0)&&e.push(new Dd({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan!==void 0?n.dragPan:!0)&&e.push(new zd({onFocusOnly:n.onFocusOnly,kinetic:t})),(n.pinchRotate!==void 0?n.pinchRotate:!0)&&e.push(new $d),(n.pinchZoom!==void 0?n.pinchZoom:!0)&&e.push(new Qd({duration:n.zoomDuration})),(n.keyboard!==void 0?n.keyboard:!0)&&(e.push(new Vd),e.push(new Kd({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom!==void 0?n.mouseWheelZoom:!0)&&e.push(new qd({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom!==void 0?n.shiftDragZoom:!0)&&e.push(new Ud({duration:n.zoomDuration})),e}function _l(n){if(n instanceof pn){n.setMapInternal(null);return}n instanceof ki&&n.getLayers().forEach(_l)}function pl(n,e){if(n instanceof pn){n.setMapInternal(e);return}if(n instanceof ki){const t=n.getLayers().getArray();for(let i=0,s=t.length;ithis.updateSize()),this.controls=t.controls||ul(),this.interactions=t.interactions||ef({onFocusOnly:!0}),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new vd(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(xe.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(xe.VIEW,this.handleViewChanged_),this.addChangeListener(xe.SIZE,this.handleSizeChanged_),this.addChangeListener(xe.TARGET,this.handleTargetChanged_),this.setProperties(t.values);const i=this;e.view&&!(e.view instanceof it)&&e.view.then(function(s){i.setView(new it(s))}),this.controls.addEventListener(Le.ADD,s=>{s.element.setMap(this)}),this.controls.addEventListener(Le.REMOVE,s=>{s.element.setMap(null)}),this.interactions.addEventListener(Le.ADD,s=>{s.element.setMap(this)}),this.interactions.addEventListener(Le.REMOVE,s=>{s.element.setMap(null)}),this.overlays_.addEventListener(Le.ADD,s=>{this.addOverlayInternal_(s.element)}),this.overlays_.addEventListener(Le.REMOVE,s=>{const r=s.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],s.element.setMap(null)}),this.controls.forEach(s=>{s.setMap(this)}),this.interactions.forEach(s=>{s.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){pl(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){const t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,i){if(!this.frameState_||!this.renderer_)return;const s=this.getCoordinateFromPixelInternal(e);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:qi,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(s,this.frameState_,r,a,t,null,o,null)}getFeaturesAtPixel(e,t){const i=[];return this.forEachFeatureAtPixel(e,function(s){i.push(s)},t),i}getAllLayers(){const e=[];function t(i){i.forEach(function(s){s instanceof ki?t(s.getLayers()):e.push(s)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(e);t=t!==void 0?t:{};const s=t.layerFilter!==void 0?t.layerFilter:qi,r=t.hitTolerance!==void 0?t.hitTolerance:0,o=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,s,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){const i=this.viewport_.getBoundingClientRect(),s=this.getSize(),r=i.width/s[0],o=i.height/s[1],a="changedTouches"in e?e.changedTouches[0]:e;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(xe.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return Js(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){const t=this.frameState_;return t?de(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){const t=this.overlayIdIndex_[e.toString()];return t!==void 0?t:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(xe.LAYERGROUP)}setLayers(e){const t=this.getLayerGroup();if(e instanceof st){t.setLayers(e);return}const i=t.getLayers();i.clear(),i.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const e=this.getLayerGroup().getLayerStatesArray();for(let t=0,i=e.length;t=0;r--){const o=s[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(e)||e.propagationStopped)break}}}handlePostRender(){const e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let s=this.maxTilesLoading_,r=s;if(e){const o=e.viewHints;if(o[ge.ANIMATING]||o[ge.INTERACTING]){const a=Date.now()-e.time>8;s=a?0:8,r=a?0:2}}t.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(e){const t=this.getLayerGroup();t&&this.handleLayerRemove_(new Ft("removelayer",t)),this.set(xe.LAYERGROUP,e)}setSize(e){this.set(xe.SIZE,e)}setTarget(e){this.set(xe.TARGET,e)}setView(e){if(!e||e instanceof it){this.set(xe.VIEW,e);return}this.set(xe.VIEW,new it);const t=this;e.then(function(i){t.setView(new it(i))})}updateSize(){const e=this.getTargetElement();let t;if(e){const s=getComputedStyle(e),r=e.offsetWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight)-parseFloat(s.borderRightWidth),o=e.offsetHeight-parseFloat(s.borderTopWidth)-parseFloat(s.paddingTop)-parseFloat(s.paddingBottom)-parseFloat(s.borderBottomWidth);!isNaN(r)&&!isNaN(o)&&(t=[r,o],!Co(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&_a("No map visible because the map container's width or height are 0."))}const i=this.getSize();t&&(!i||!Kt(t,i))&&(this.setSize(t),this.updateViewportSize_(t))}updateViewportSize_(e){const t=this.getView();t&&t.setViewportSize(e)}}function nf(n){let e=null;n.keyboardEventTarget!==void 0&&(e=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);const t={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new ki({layers:n.layers});t[xe.LAYERGROUP]=i,t[xe.TARGET]=n.target,t[xe.VIEW]=n.view instanceof it?n.view:new it;let s;n.controls!==void 0&&(Array.isArray(n.controls)?s=new st(n.controls.slice()):(K(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),s=n.controls));let r;n.interactions!==void 0&&(Array.isArray(n.interactions)?r=new st(n.interactions.slice()):(K(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=n.interactions));let o;return n.overlays!==void 0?Array.isArray(n.overlays)?o=new st(n.overlays.slice()):(K(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new st,{controls:s,interactions:r,keyboardEventTarget:e,overlays:o,values:t}}const sf=tf,ye={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class rf extends Qe{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=e.insertFirst!==void 0?e.insertFirst:!0,this.stopEvent=e.stopEvent!==void 0?e.stopEvent:!0,this.element=document.createElement("div"),this.element.className=e.className!==void 0?e.className:"ol-overlay-container "+mc,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=e.autoPan===!0?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(ye.ELEMENT,this.handleElementChanged),this.addChangeListener(ye.MAP,this.handleMapChanged),this.addChangeListener(ye.OFFSET,this.handleOffsetChanged),this.addChangeListener(ye.POSITION,this.handlePositionChanged),this.addChangeListener(ye.POSITIONING,this.handlePositioningChanged),e.element!==void 0&&this.setElement(e.element),this.setOffset(e.offset!==void 0?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),e.position!==void 0&&this.setPosition(e.position)}getElement(){return this.get(ye.ELEMENT)}getId(){return this.id}getMap(){return this.get(ye.MAP)||null}getOffset(){return this.get(ye.OFFSET)}getPosition(){return this.get(ye.POSITION)}getPositioning(){return this.get(ye.POSITIONING)}handleElementChanged(){Oa(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){this.mapPostrenderListenerKey&&(Vn(this.element),ie(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const e=this.getMap();if(e){this.mapPostrenderListenerKey=U(e,xt.POSTRENDER,this.render,this),this.updatePixelPosition();const t=this.stopEvent?e.getOverlayContainerStopEvent():e.getOverlayContainer();this.insertFirst?t.insertBefore(this.element,t.childNodes[0]||null):t.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(ye.ELEMENT,e)}setMap(e){this.set(ye.MAP,e)}setOffset(e){this.set(ye.OFFSET,e)}setPosition(e){this.set(ye.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(ye.POSITION))return;const i=this.getRect(t.getTargetElement(),t.getSize()),s=this.getElement(),r=this.getRect(s,[rc(s),oc(s)]);e=e||{};const o=e.margin===void 0?20:e.margin;if(!rt(i,r)){const a=r[0]-i[0],l=i[2]-r[2],c=r[1]-i[1],h=i[3]-r[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),c<0?u[1]=c-o:h<0&&(u[1]=Math.abs(h)+o),u[0]!==0||u[1]!==0){const d=t.getView().getCenterInternal(),f=t.getPixelFromCoordinateInternal(d);if(!f)return;const g=[f[0]+u[0],f[1]+u[1]],m=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(g),duration:m.duration,easing:m.easing})}}}getRect(e,t){const i=e.getBoundingClientRect(),s=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[s,r,s+t[0],r+t[1]]}setPositioning(e){this.set(ye.POSITIONING,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t){this.setVisible(!1);return}const i=e.getPixelFromCoordinate(t),s=e.getSize();this.updateRenderedPosition(i,s)}updateRenderedPosition(e,t){const i=this.element.style,s=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=Math.round(e[0]+s[0])+"px",a=Math.round(e[1]+s[1])+"px";let l="0%",c="0%";r=="bottom-right"||r=="center-right"||r=="top-right"?l="-100%":(r=="bottom-center"||r=="center-center"||r=="top-center")&&(l="-50%"),r=="bottom-left"||r=="bottom-center"||r=="bottom-right"?c="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(c="-50%");const h=`translate(${l}, ${c}) translate(${o}, ${a})`;this.rendered.transform_!=h&&(this.rendered.transform_=h,i.transform=h)}getOptions(){return this.options}}class of{constructor(e){this.highWaterMark=e!==void 0?e:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.pop()}clear(){this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){const i=this.entries_[e];return K(i!==void 0,"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(e){const t=this.entries_[e];return K(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.key_;return e}getValues(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){var t;return(t=this.entries_[e])==null?void 0:t.value_}pop(){const e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){K(!(e in this.entries_),"Tried to set a value for a key that is used already");const i={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[e]=i,++this.count_}setSize(e){this.highWaterMark=e}}function Jo(n,e,t,i){return i!==void 0?(i[0]=n,i[1]=e,i[2]=t,i):[n,e,t]}function xs(n,e,t){return n+"/"+e+"/"+t}function yl(n){return xs(n[0],n[1],n[2])}function af(n){return n.split("/").map(Number)}function lf(n){return(n[1]<t||t>e.getMaxZoom())return!1;const r=e.getFullTileRange(t);return r?r.containsXY(i,s):!0}class El extends of{clear(){for(;this.getCount()>0;)this.pop().release();super.clear()}expireCache(e){for(;this.canExpireCache()&&!(this.peekLast().getKey()in e);)this.pop().release()}pruneExceptNewestZ(){if(this.getCount()===0)return;const e=this.peekFirstKey(),i=af(e)[0];this.forEach(s=>{s.tileCoord[0]!==i&&(this.remove(yl(s.tileCoord)),s.release())})}}class zr{constructor(e,t,i,s){this.minX=e,this.maxX=t,this.minY=i,this.maxY=s}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minXthis.maxX&&(this.maxX=e.maxX),e.minYthis.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}}function fi(n,e,t,i,s){return s!==void 0?(s.minX=n,s.maxX=e,s.minY=t,s.maxY=i,s):new zr(n,e,t,i)}const Fn={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class cf extends pn{constructor(e){e=e||{};const t=Object.assign({},e);delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.setPreload(e.preload!==void 0?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0)}getPreload(){return this.get(Fn.PRELOAD)}setPreload(e){this.set(Fn.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(Fn.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(Fn.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}}const xl=.5,uf=10,Qo=.25;class Il{constructor(e,t,i,s,r,o){this.sourceProj_=e,this.targetProj_=t;let a={};const l=jn(this.targetProj_,this.sourceProj_);this.transformInv_=function(y){const x=y[0]+"/"+y[1];return a[x]||(a[x]=l(y)),a[x]},this.maxSourceExtent_=s,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!s&&!!this.sourceProj_.getExtent()&&V(s)>=V(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?V(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?V(this.targetProj_.getExtent()):null;const c=oi(i),h=os(i),u=rs(i),d=ss(i),f=this.transformInv_(c),g=this.transformInv_(h),m=this.transformInv_(u),_=this.transformInv_(d),p=uf+(o?Math.max(0,Math.ceil(Math.log2(Ks(i)/(o*o*256*256)))):0);if(this.addQuad_(c,h,u,d,f,g,m,_,p),this.wrapsXInSource_){let y=1/0;this.triangles_.forEach(function(x,E,I){y=Math.min(y,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-y>this.sourceWorldWidth_/2){const E=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];E[0][0]-y>this.sourceWorldWidth_/2&&(E[0][0]-=this.sourceWorldWidth_),E[1][0]-y>this.sourceWorldWidth_/2&&(E[1][0]-=this.sourceWorldWidth_),E[2][0]-y>this.sourceWorldWidth_/2&&(E[2][0]-=this.sourceWorldWidth_);const I=Math.min(E[0][0],E[1][0],E[2][0]);Math.max(E[0][0],E[1][0],E[2][0])-I.5&&u<1;let g=!1;if(c>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=no([e,t,i,s]);g=V(_)/this.targetWorldWidth_>Qo||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>Qo||g)}if(!g&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!Re(h,this.maxSourceExtent_))return;let m=0;if(!g&&(!isFinite(r[0])||!isFinite(r[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(c>0)g=!0;else if(m=(!isFinite(r[0])||!isFinite(r[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),m!=1&&m!=2&&m!=4&&m!=8)return}if(c>0){if(!g){const _=[(e[0]+i[0])/2,(e[1]+i[1])/2],p=this.transformInv_(_);let y;f?y=(si(r[0],d)+si(a[0],d))/2-si(p[0],d):y=(r[0]+a[0])/2-p[0];const x=(r[1]+a[1])/2-p[1];g=y*y+x*x>this.errorThresholdSquared_}if(g){if(Math.abs(e[0]-i[0])<=Math.abs(e[1]-i[1])){const _=[(t[0]+i[0])/2,(t[1]+i[1])/2],p=this.transformInv_(_),y=[(s[0]+e[0])/2,(s[1]+e[1])/2],x=this.transformInv_(y);this.addQuad_(e,t,_,y,r,o,p,x,c-1),this.addQuad_(y,_,i,s,x,p,a,l,c-1)}else{const _=[(e[0]+t[0])/2,(e[1]+t[1])/2],p=this.transformInv_(_),y=[(i[0]+s[0])/2,(i[1]+s[1])/2],x=this.transformInv_(y);this.addQuad_(e,_,y,s,r,p,x,l,c-1),this.addQuad_(_,t,i,y,p,o,a,x,c-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}m&11||this.addTriangle_(e,i,s,r,a,l),m&14||this.addTriangle_(e,i,t,r,a,o),m&&(m&13||this.addTriangle_(t,s,e,o,l,r),m&7||this.addTriangle_(t,s,i,o,l,a))}calculateSourceExtent(){const e=Ue();return this.triangles_.forEach(function(t,i,s){const r=t.source;Zi(e,r[0]),Zi(e,r[1]),Zi(e,r[2])}),e}getTriangles(){return this.triangles_}}let Xs;const Ci=[];function ea(n,e,t,i,s){n.beginPath(),n.moveTo(0,0),n.lineTo(e,t),n.lineTo(i,s),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(e,i)+1,Math.max(t,s)),n.restore()}function Ys(n,e){return Math.abs(n[e*4]-210)>2||Math.abs(n[e*4+3]-.75*255)>2}function df(){if(Xs===void 0){const n=pe(6,6,Ci);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",ea(n,4,5,4,0),ea(n,4,5,0,5);const e=n.getImageData(0,0,3,3).data;Xs=Ys(e,0)||Ys(e,4)||Ys(e,8),cs(n),Ci.push(n.canvas)}return Xs}function Qn(n,e,t,i){const s=hs(t,e,n);let r=ho(e,i,t);const o=e.getMetersPerUnit();o!==void 0&&(r*=o);const a=n.getMetersPerUnit();a!==void 0&&(r/=a);const l=n.getExtent();if(!l||ri(l,s)){const c=ho(n,r,s)/r;isFinite(c)&&c>0&&(r/=c)}return r}function ff(n,e,t,i){const s=Tt(t);let r=Qn(n,e,s,i);return(!isFinite(r)||r<=0)&&ua(t,function(o){return r=Qn(n,e,o,i),isFinite(r)&&r>0}),r}function vl(n,e,t,i,s,r,o,a,l,c,h,u,d,f){const g=pe(Math.round(t*n),Math.round(t*e),Ci);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(t,t);function m(I){return Math.round(I*t)/t}g.globalCompositeOperation="lighter";const _=Ue();l.forEach(function(I,v,R){Ql(_,I.extent)});let p;const y=t/i,x=(u?1:1+Math.pow(2,-24))/y;if(!d||l.length!==1||c!==0){if(p=pe(Math.round(V(_)*y),Math.round(le(_)*y),Ci),u||(p.imageSmoothingEnabled=!1),s&&f){const I=(s[0]-_[0])*y,v=-(s[3]-_[3])*y,R=V(s)*y,C=le(s)*y;p.rect(I,v,R,C),p.clip()}l.forEach(function(I,v,R){const C=(I.extent[0]-_[0])*y,T=-(I.extent[3]-_[3])*y,O=V(I.extent)*y,P=le(I.extent)*y;I.image.width>0&&I.image.height>0&&p.drawImage(I.image,c,c,I.image.width-2*c,I.image.height-2*c,u?C:Math.round(C),u?T:Math.round(T),u?O:Math.round(C+O)-Math.round(C),u?P:Math.round(T+P)-Math.round(T))})}const E=oi(o);return a.getTriangles().forEach(function(I,v,R){const C=I.source,T=I.target;let O=C[0][0],P=C[0][1],F=C[1][0],Y=C[1][1],G=C[2][0],z=C[2][1];const L=m((T[0][0]-E[0])/r),k=m(-(T[0][1]-E[1])/r),W=m((T[1][0]-E[0])/r),te=m(-(T[1][1]-E[1])/r),j=m((T[2][0]-E[0])/r),Q=m(-(T[2][1]-E[1])/r),H=O,ae=P;O=0,P=0,F-=H,Y-=ae,G-=H,z-=ae;const S=[[F,Y,0,0,W-L],[G,z,0,0,j-L],[0,0,F,Y,te-k],[0,0,G,z,Q-k]],ne=mh(S);if(!ne)return;if(g.save(),g.beginPath(),df()||!u){g.moveTo(W,te);const ce=4,Te=L-W,Ve=k-te;for(let Se=0;Se{t&&t.getState()==D.LOADED&&e.push({extent:this.sourceTileGrid_.getTileCoordExtent(t.tileCoord),image:t.getImage()})}),this.sourceTiles_.length=0,e.length===0)this.state=D.ERROR;else{const t=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(t),s=typeof i=="number"?i:i[0],r=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=vl(s,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=D.LOADED}this.changed()}load(){if(this.state==D.IDLE){this.state=D.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(t=>{const i=t.getState();if(i==D.IDLE||i==D.LOADING){e++;const s=U(t,B.CHANGE,function(r){const o=t.getState();(o==D.LOADED||o==D.ERROR||o==D.EMPTY)&&(ie(s),e--,e===0&&(this.unlistenSources_(),this.reproject_()))},this);this.sourcesListenerKeys_.push(s)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function(t,i,s){t.getState()==D.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(ie),this.sourcesListenerKeys_=null}release(){this.canvas_&&(cs(this.canvas_.getContext("2d")),Ci.push(this.canvas_),this.canvas_=null),super.release()}}class gf extends Fr{constructor(e){super(e),this.extentChanged=!0,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedRevision,this.renderedTiles=[],this.newTiles_=!1,this.tmpExtent=Ue(),this.tmpTileRange_=new zr(0,0,0,0)}isDrawableTile(e){const t=this.getLayer(),i=e.getState(),s=t.getUseInterimTilesOnError();return i==D.LOADED||i==D.EMPTY||i==D.ERROR&&!s}getTile(e,t,i,s){const r=s.pixelRatio,o=s.viewState.projection,a=this.getLayer();let c=a.getSource().getTile(e,t,i,r,o);return c.getState()==D.ERROR&&a.getUseInterimTilesOnError()&&a.getPreload()>0&&(this.newTiles_=!0),this.isDrawableTile(c)||(c=c.getInterimTile()),c}getData(e){const t=this.frameState;if(!t)return null;const i=this.getLayer(),s=de(t.pixelToCoordinateTransform,e.slice()),r=i.getExtent();if(r&&!ri(r,s))return null;const o=t.pixelRatio,a=t.viewState.projection,l=t.viewState,c=i.getRenderSource(),h=c.getTileGridForProjection(l.projection),u=c.getTilePixelRatio(t.pixelRatio);for(let d=h.getZForResolution(l.resolution);d>=h.getMinZoom();--d){const f=h.getTileCoordForCoordAndZ(s,d),g=c.getTile(d,f[1],f[2],o,a);if(!(g instanceof cl||g instanceof or)||g instanceof or&&g.getState()===D.EMPTY)return null;if(g.getState()!==D.LOADED)continue;const m=h.getOrigin(d),_=Oe(h.getTileSize(d)),p=h.getResolution(d),y=Math.floor(u*((s[0]-m[0])/p-f[1]*_[0])),x=Math.floor(u*((m[1]-s[1])/p-f[2]*_[1])),E=Math.round(u*c.getGutterForProjection(l.projection));return this.getImageData(g.getImage(),y+E,x+E)}return null}loadedTileCallback(e,t,i){return this.isDrawableTile(i)?super.loadedTileCallback(e,t,i):!1}prepareFrame(e){return!!this.getLayer().getSource()}renderFrame(e,t){const i=e.layerStatesArray[e.layerIndex],s=e.viewState,r=s.projection,o=s.resolution,a=s.center,l=s.rotation,c=e.pixelRatio,h=this.getLayer(),u=h.getSource(),d=u.getRevision(),f=u.getTileGridForProjection(r),g=f.getZForResolution(o,u.zDirection),m=f.getResolution(g);let _=e.extent;const p=e.viewState.resolution,y=u.getTilePixelRatio(c),x=Math.round(V(_)/p*c),E=Math.round(le(_)/p*c),I=i.extent&&vt(i.extent);I&&(_=ni(_,vt(i.extent)));const v=m*x/2/y,R=m*E/2/y,C=[a[0]-v,a[1]-R,a[0]+v,a[1]+R],T=f.getTileRangeForExtentAndZ(_,g),O={};O[g]={};const P=this.createLoadedTileFinder(u,r,O),F=this.tmpExtent,Y=this.tmpTileRange_;this.newTiles_=!1;const G=l?Hs(s.center,p,l,e.size):void 0;for(let ae=T.minX;ae<=T.maxX;++ae)for(let S=T.minY;S<=T.maxY;++S){if(l&&!f.tileCoordIntersectsViewport([g,ae,S],G))continue;const ne=this.getTile(g,ae,S,e);if(this.isDrawableTile(ne)){const Te=J(this);if(ne.getState()==D.LOADED){O[g][ne.tileCoord.toString()]=ne;let Ve=ne.inTransition(Te);Ve&&i.opacity!==1&&(ne.endTransition(Te),Ve=!1),!this.newTiles_&&(Ve||!this.renderedTiles.includes(ne))&&(this.newTiles_=!0)}if(ne.getAlpha(Te,e.time)===1)continue}const Ae=f.getTileCoordChildTileRange(ne.tileCoord,Y,F);let ce=!1;Ae&&(ce=P(g+1,Ae)),ce||f.forEachTileCoordParentTileRange(ne.tileCoord,P,Y,F)}const z=m/o*c/y;je(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/c,1/c,l,-x/2,-E/2);const L=ur(this.pixelTransform);this.useContainer(t,L,this.getBackground(e));const k=this.getRenderContext(e),W=this.context.canvas;is(this.inversePixelTransform,this.pixelTransform),je(this.tempTransform,x/2,E/2,z,z,0,-x/2,-E/2),W.width!=x||W.height!=E?(W.width=x,W.height=E):this.containerReused||k.clearRect(0,0,x,E),I&&this.clipUnrotated(k,e,I),u.getInterpolate()||(k.imageSmoothingEnabled=!1),this.preRender(k,e),this.renderedTiles.length=0;let te=Object.keys(O).map(Number);te.sort(wt);let j,Q,H;i.opacity===1&&(!this.containerReused||u.getOpaque(e.viewState.projection))?te=te.reverse():(j=[],Q=[]);for(let ae=te.length-1;ae>=0;--ae){const S=te[ae],ne=u.getTilePixelSize(S,c,r),ce=f.getResolution(S)/m,Te=ne[0]*ce*z,Ve=ne[1]*ce*z,Se=f.getTileCoordForCoordAndZ(oi(C),S),Fi=f.getTileCoordExtent(Se),Ht=de(this.tempTransform,[y*(Fi[0]-C[0])/m,y*(C[3]-Fi[3])/m]),vs=y*u.getGutterForProjection(r),wn=O[S];for(const Cn in wn){const ke=wn[Cn],ai=ke.tileCoord,Rn=Se[1]-ai[1],ws=Math.round(Ht[0]-(Rn-1)*Te),Tn=Se[2]-ai[2],Sn=Math.round(Ht[1]-(Tn-1)*Ve),De=Math.round(Ht[0]-Rn*Te),Ze=Math.round(Ht[1]-Tn*Ve),et=ws-De,Ke=Sn-Ze,li=g===S,hi=li&&ke.getAlpha(J(this),e.time)!==1;let bt=!1;if(!hi)if(j){H=[De,Ze,De+et,Ze,De+et,Ze+Ke,De,Ze+Ke];for(let dt=0,Cs=j.length;dtr-s,!0),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let s=0,r=this.resolutions_.length-1;s{const o=new zr(Math.min(0,s[0]),Math.max(s[0]-1,-1),Math.min(0,s[1]),Math.max(s[1]-1,-1));if(i){const a=this.getTileRangeForExtentAndZ(i,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(e,t,i){const s=this.getTileRangeForExtentAndZ(e,t);for(let r=s.minX,o=s.maxX;r<=o;++r)for(let a=s.minY,l=s.maxY;a<=l;++a)i([t,r,a])}forEachTileCoordParentTileRange(e,t,i,s){let r,o,a,l=null,c=e[0]-1;for(this.zoomFactor_===2?(o=e[1],a=e[2]):l=this.getTileCoordExtent(e,s);c>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=fi(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,c,i),t(c,r))return!0;--c}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,i){if(e[0]this.maxZoom||t0?i:Math.max(r/t[0],s/t[1]);const o=e+1,a=new Array(o);for(let l=0;li.highWaterMark&&(i.highWaterMark=e)}useTile(e,t,i,s){}}class wf extends ct{constructor(e,t){super(e),this.tile=t}}function Cf(n,e){const t=/\{z\}/g,i=/\{x\}/g,s=/\{y\}/g,r=/\{-y\}/g;return function(o,a,l){if(o)return n.replace(t,o[0].toString()).replace(i,o[1].toString()).replace(s,o[2].toString()).replace(r,function(){const c=o[0],h=e.getFullTileRange(c);if(!h)throw new Error("The {-y} placeholder requires a tile grid with extent");return(h.getHeight()-o[2]-1).toString()})}}function Rf(n,e){const t=n.length,i=new Array(t);for(let s=0;sthis.getTileInternal(_,p,y,x,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return m.key=u,c?(m.interimTile=c,m.refreshInterimChain(),a.replace(h,m)):a.set(h,m),m}getTileInternal(e,t,i,s,r){let o=null;const a=xs(e,t,i),l=this.getKey();if(!this.tileCache.containsKey(a))o=this.createTile_(e,t,i,s,r,l),this.tileCache.set(a,o);else if(o=this.tileCache.get(a),o.key!=l){const c=o;o=this.createTile_(e,t,i,s,r,l),c.getState()==D.IDLE?o.interimTile=c.interimTile:o.interimTile=c,o.refreshInterimChain(),this.tileCache.replace(a,o)}return o}setRenderReprojectionEdges(e){if(this.renderReprojectionEdges_!=e){this.renderReprojectionEdges_=e;for(const t in this.tileCacheForProjection)this.tileCacheForProjection[t].clear();this.changed()}}setTileGridForProjection(e,t){const i=ve(e);if(i){const s=J(i);s in this.tileGridForProjection||(this.tileGridForProjection[s]=t)}}clear(){super.clear();for(const e in this.tileCacheForProjection)this.tileCacheForProjection[e].clear()}}function bf(n,e){n.getImage().src=e}class Mf extends Lf{constructor(e){e=e||{};const t=e.projection!==void 0?e.projection:"EPSG:3857",i=e.tileGrid!==void 0?e.tileGrid:xf({extent:Wr(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,opaque:e.opaque,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}}const Af='© OpenStreetMap contributors.';class Df extends Mf{constructor(e){e=e||{};let t;e.attributions!==void 0?t=e.attributions:t=[Af];const i=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",s=e.url!==void 0?e.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:t,attributionsCollapsible:!1,cacheSize:e.cacheSize,crossOrigin:i,interpolate:e.interpolate,maxZoom:e.maxZoom!==void 0?e.maxZoom:19,opaque:e.opaque!==void 0?e.opaque:!0,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:e.tileLoadFunction,transition:e.transition,url:s,wrapX:e.wrapX,zDirection:e.zDirection})}}const Pf=Df;function ar(n){return Array.isArray(n)?Math.min(...n):n}class Of extends ka{constructor(e,t,i,s,r,o,a){let l=e.getExtent();l&&e.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);let c=t.getExtent();c&&t.canWrapX()&&(c=c.slice(),c[0]=-1/0,c[2]=1/0);const h=c?ni(i,c):i,u=Tt(h),d=Qn(e,t,u,s),f=xl,g=new Il(e,t,h,l,d*f,s),m=g.calculateSourceExtent(),_=Ai(m)?null:o(m,d,r),p=_?b.IDLE:b.EMPTY,y=_?_.getPixelRatio():1;super(i,s,y,p),this.targetProj_=t,this.maxSourceExtent_=l,this.triangulation_=g,this.targetResolution_=s,this.targetExtent_=i,this.sourceImage_=_,this.sourcePixelRatio_=y,this.interpolate_=a,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==b.LOADING&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const e=this.sourceImage_.getState();if(e==b.LOADED){const t=V(this.targetExtent_)/this.targetResolution_,i=le(this.targetExtent_)/this.targetResolution_;this.canvas_=vl(t,i,this.sourcePixelRatio_,ar(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=e,this.changed()}load(){if(this.state==b.IDLE){this.state=b.LOADING,this.changed();const e=this.sourceImage_.getState();e==b.LOADED||e==b.ERROR?this.reproject_():(this.sourceListenerKey_=U(this.sourceImage_,B.CHANGE,function(t){const i=this.sourceImage_.getState();(i==b.LOADED||i==b.ERROR)&&(this.unlistenSource_(),this.reproject_())},this),this.sourceImage_.load())}}unlistenSource_(){ie(this.sourceListenerKey_),this.sourceListenerKey_=null}}const Wt=4,Us={IMAGELOADSTART:"imageloadstart",IMAGELOADEND:"imageloadend",IMAGELOADERROR:"imageloaderror"};class kf extends ct{constructor(e,t){super(e),this.image=t}}class Ff extends Nr{constructor(e){super({attributions:e.attributions,projection:e.projection,state:e.state,interpolate:e.interpolate!==void 0?e.interpolate:!0}),this.on,this.once,this.un,this.loader=e.loader||null,this.resolutions_=e.resolutions!==void 0?e.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=e.loader?e.loader.length===0:!1,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(e){this.resolutions_=e}findNearestResolution(e){const t=this.getResolutions();if(t){const i=es(t,e,0);e=t[i]}return e}getImage(e,t,i,s){const r=this.getProjection();if(!r||!s||Nt(r,s))return r&&(s=r),this.getImageInternal(e,t,i,s);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&Nt(this.reprojectedImage_.getProjection(),s)&&this.reprojectedImage_.getResolution()==t&&Li(this.reprojectedImage_.getExtent(),e))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new Of(r,s,e,t,i,(o,a,l)=>this.getImageInternal(o,a,l,r),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(e,t,i,s){if(this.loader){const r=Tl(e,t,i,1),o=this.findNearestResolution(t);if(this.image&&(this.static_||this.wantedProjection_===s&&(this.wantedExtent_&&rt(this.wantedExtent_,r)||rt(this.image.getExtent(),r))&&(this.wantedResolution_&&ar(this.wantedResolution_)===o||ar(this.image.getResolution())===o)))return this.image;this.wantedProjection_=s,this.wantedExtent_=r,this.wantedResolution_=o,this.image=new ka(r,o,i,this.loader),this.image.addEventListener(B.CHANGE,this.handleImageChange.bind(this))}return this.image}handleImageChange(e){const t=e.target;let i;switch(t.getState()){case b.LOADING:this.loading=!0,i=Us.IMAGELOADSTART;break;case b.LOADED:this.loading=!1,i=Us.IMAGELOADEND;break;case b.ERROR:this.loading=!1,i=Us.IMAGELOADERROR;break;default:return}this.hasListener(i)&&this.dispatchEvent(new kf(i,t))}}function Nf(n,e){n.getImage().src=e}function Tl(n,e,t,i){const s=e/t,r=Tt(n),o=Bt(V(n)/s,Wt),a=Bt(le(n)/s,Wt),l=Bt((i-1)*o/2,Wt),c=o+2*l,h=Bt((i-1)*a/2,Wt),u=a+2*h;return $i(r,s,0,[c,u])}function Sl(n,e){const t=[];Object.keys(e).forEach(function(s){e[s]!==null&&e[s]!==void 0&&t.push(s+"="+encodeURIComponent(e[s]))});const i=t.join("&");return n=n.replace(/[?&]$/,""),n+=n.includes("?")?"&":"?",n+i}const Ll="1.3.0",ta=[101,101];function bl(n,e,t,i,s){s.WIDTH=t[0],s.HEIGHT=t[1];const r=i.getAxisOrientation();let o;const a=ga(s.VERSION,"1.3")>=0;return s[a?"CRS":"SRS"]=i.getCode(),a&&r.substr(0,2)=="ne"?o=[e[1],e[0],e[3],e[2]]:o=e,s.BBOX=o.join(","),Sl(n,s)}function Bf(n,e,t,i,s,r,o){r=Object.assign({REQUEST:"GetMap"},r);const a=e/t,l=[ao(V(n)/a,Wt),ao(le(n)/a,Wt)];if(t!=1)switch(o){case"geoserver":const h=90*t+.5|0;"FORMAT_OPTIONS"in r?r.FORMAT_OPTIONS+=";dpi:"+h:r.FORMAT_OPTIONS="dpi:"+h;break;case"mapserver":r.MAP_RESOLUTION=90*t;break;case"carmentaserver":case"qgis":r.DPI=90*t;break;default:throw new Error("Unknown `serverType` configured")}return bl(s,n,l,i,r)}function Ml(n,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:Ll,FORMAT:"image/png",STYLES:"",TRANSPARENT:!0},n)}function Gf(n){const e=n.hidpi===void 0?!0:n.hidpi,t=ve(n.projection||"EPSG:3857"),i=n.ratio||1.5,s=n.load||Na;return(r,o,a)=>{r=Tl(r,o,a,i),a!=1&&(!e||n.serverType===void 0)&&(a=1);const l=Bf(r,o,a,t,n.url,Ml(n.params,"GetMap"),n.serverType),c=new Image;return n.crossOrigin!==null&&(c.crossOrigin=n.crossOrigin),s(c,l).then(h=>({image:h,extent:r,pixelRatio:a}))}}function zf(n,e,t){if(n.url===void 0)return;const i=ve(n.projection||"EPSG:3857"),s=$i(e,t,0,ta),r={QUERY_LAYERS:n.params.LAYERS,INFO_FORMAT:"application/json"};Object.assign(r,Ml(n.params,"GetFeatureInfo"),n.params);const o=xi((e[0]-s[0])/t,Wt),a=xi((s[3]-e[1])/t,Wt),l=ga(r.VERSION,"1.3")>=0;return r[l?"I":"X"]=o,r[l?"J":"Y"]=a,bl(n.url,s,ta,i,r)}function Wf(n,e){if(n.url===void 0)return;const t={SERVICE:"WMS",VERSION:Ll,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(n.params===void 0||n.params.LAYER===void 0){const i=n.params.LAYERS;if(!(!Array.isArray(i)||i.length===1))return;t.LAYER=i}if(e!==void 0){const i=ve(n.projection||"EPSG:3857").getMetersPerUnit()||1,s=28e-5;t.SCALE=e*i/s}return Object.assign(t,n.params),Sl(n.url,t)}class Al extends Ff{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:e.interpolate,projection:e.projection,resolutions:e.resolutions}),this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null,this.url_=e.url,this.imageLoadFunction_=e.imageLoadFunction!==void 0?e.imageLoadFunction:Nf,this.params_=Object.assign({},e.params),this.serverType_=e.serverType,this.hidpi_=e.hidpi!==void 0?e.hidpi:!0,this.renderedRevision_=0,this.ratio_=e.ratio!==void 0?e.ratio:1.5,this.loaderProjection_=null}getFeatureInfoUrl(e,t,i,s){const r=ve(i),o=this.getProjection();o&&o!==r&&(t=Qn(o,r,e,t),e=hs(e,r,o));const a={url:this.url_,params:{...this.params_,...s},projection:o||r};return zf(a,e,t)}getLegendUrl(e,t){return Wf({url:this.url_,params:{...this.params_,...t}},e)}getParams(){return this.params_}getImageInternal(e,t,i,s){return this.url_===void 0?null:((!this.loader||this.loaderProjection_!==s)&&(this.loaderProjection_=s,this.loader=Gf({crossOrigin:this.crossOrigin_,params:this.params_,projection:s,serverType:this.serverType_,hidpi:this.hidpi_,url:this.url_,ratio:this.ratio_,load:(r,o)=>(this.image.setImage(r),this.imageLoadFunction_(this.image,o),Na(r))})),super.getImageInternal(e,t,i,s))}getImageLoadFunction(){return this.imageLoadFunction_}getUrl(){return this.url_}setImageLoadFunction(e){this.imageLoadFunction_=e,this.changed()}setUrl(e){e!=this.url_&&(this.url_=e,this.loader=null,this.changed())}updateParams(e){Object.assign(this.params_,e),this.changed()}changed(){this.image=null,super.changed()}}class Xf extends pn{constructor(e){e=e||{},super(e)}}class Yf extends Fr{constructor(e){super(e),this.image_=null}getImage(){return this.image_?this.image_.getImage():null}prepareFrame(e){const t=e.layerStatesArray[e.layerIndex],i=e.pixelRatio,s=e.viewState,r=s.resolution,o=this.getLayer().getSource(),a=e.viewHints;let l=e.extent;if(t.extent!==void 0&&(l=ni(l,vt(t.extent,s.projection))),!a[ge.ANIMATING]&&!a[ge.INTERACTING]&&!Ai(l))if(o){const c=s.projection,h=o.getImage(l,r,i,c);h&&(this.loadImage(h)?this.image_=h:h.getState()===b.EMPTY&&(this.image_=null))}else this.image_=null;return!!this.image_}getData(e){const t=this.frameState;if(!t)return null;const i=this.getLayer(),s=de(t.pixelToCoordinateTransform,e.slice()),r=i.getExtent();if(r&&!ri(r,s))return null;const o=this.image_.getExtent(),a=this.image_.getImage(),l=V(o),c=Math.floor(a.width*((s[0]-o[0])/l));if(c<0||c>=a.width)return null;const h=le(o),u=Math.floor(a.height*((o[3]-s[1])/h));return u<0||u>=a.height?null:this.getImageData(a,c,u)}renderFrame(e,t){const i=this.image_,s=i.getExtent(),r=i.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],l=i.getPixelRatio(),c=e.layerStatesArray[e.layerIndex],h=e.pixelRatio,u=e.viewState,d=u.center,f=u.resolution,g=h*o/(f*l),m=h*a/(f*l),_=e.extent,p=u.resolution,y=u.rotation,x=Math.round(V(_)/p*h),E=Math.round(le(_)/p*h);je(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/h,1/h,y,-x/2,-E/2),is(this.inversePixelTransform,this.pixelTransform);const I=ur(this.pixelTransform);this.useContainer(t,I,this.getBackground(e));const v=this.getRenderContext(e),R=this.context.canvas;R.width!=x||R.height!=E?(R.width=x,R.height=E):this.containerReused||v.clearRect(0,0,x,E);let C=!1,T=!0;if(c.extent){const G=vt(c.extent,u.projection);T=Re(G,e.extent),C=T&&!rt(G,e.extent),C&&this.clipUnrotated(v,e,G)}const O=i.getImage(),P=je(this.tempTransform,x/2,E/2,g,m,0,l*(s[0]-d[0])/o,l*(d[1]-s[3])/a);this.renderedResolution=a*h/l;const F=O.width*P[0],Y=O.height*P[3];if(this.getLayer().getSource().getInterpolate()||(v.imageSmoothingEnabled=!1),this.preRender(v,e),T&&F>=.5&&Y>=.5){const G=P[4],z=P[5],L=c.opacity;L!==1&&(v.save(),v.globalAlpha=L),v.drawImage(O,0,0,+O.width,+O.height,G,z,F,Y),L!==1&&v.restore()}return this.postRender(this.context,e),C&&v.restore(),v.imageSmoothingEnabled=!0,I!==R.style.transform&&(R.style.transform=I),this.container}}class Dl extends Xf{constructor(e){super(e)}createRenderer(){return new Yf(this)}getData(e){return super.getData(e)}}var Pl,Ol,jf=document.getElementById("popup"),ue=document.getElementById("popup-content"),ia=document.getElementById("popup-closer"),$e,Yr,Ye,kl,Fl,Nl,Bl,Vs=!1,Yt=!1,jt=!1,Ut=!1,Nn,Bn,Is="https://opendem.info/cgi-bin/",jr=new rf({element:jf,autoPan:!0,autoPanAnimation:{duration:250}});ia.onclick=function(){return jr.setPosition(void 0),ia.blur(),!1};class Uf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:0px;left:1px; width:30px; height:30px;",i.className="switchDiv",i.id="switchDiv",super({element:i,target:t.target}),i.addEventListener("click",this.handleSwitchDivChange.bind(this),!1)}handleSwitchDivChange(){var e=document.getElementById("switchDiv"),t=document.getElementById("controlEle");t.style.display==="none"?(t.style.display="block",e.className="switchDiv"):(t.style.display="none",e.className="switchDivHide")}}class Vf extends ut{constructor(e){const t=e||{};var i=document.createElement("input");i.type="radio",i.name="radioGrp",i.id="rad1",i.value="myradio1",i.defaultChecked=!0,i.checked=!0;var s=document.createElement("input");s.type="radio",s.name="radioGrp",s.id="rad2",s.value="myradio2";var r=document.createElement("input");r.type="radio",r.name="radioGrp",r.id="rad3",r.value="myradio3";var o=document.createElement("input");o.type="radio",o.name="radioGrp",o.id="rad4",o.value="myradio4";var a=document.createElement("input");a.type="radio",a.name="radioGrp",a.id="rad5",a.value="myradio5";var l=document.createElement("input");l.type="radio",l.name="radioGrp",l.id="rad6",l.value="myradio6";var c=document.createTextNode("3D Model"),h=document.createTextNode("Foto"),u=document.createTextNode("Wikipedia"),d=document.createTextNode("OpenStreetMap"),E=document.createTextNode("Podcast"),f=document.createTextNode("3D Viewer Köln"),g=document.createElement("label");g.style.cssText="position:absolute;top:50px;left:10px",g.htmlFor=i.id,g.appendChild(i),g.appendChild(c);var m=document.createElement("label");m.style.cssText="position:absolute;top:70px;left:10px;",m.htmlFor=s.id,m.appendChild(s),m.appendChild(h);var _=document.createElement("label");_.style.cssText="position:absolute;top:90px;left:10px;",_.htmlFor=r.id,_.appendChild(r),_.appendChild(u);var p=document.createElement("label");p.style.cssText="position:absolute;top:110px;left:10px;",p.htmlFor=o.id,p.appendChild(o),p.appendChild(d);var y=document.createElement("label");y.style.cssText="position:absolute;top:130px;left:10px;",y.htmlFor=a.id,y.appendChild(a),y.appendChild(E);var x=document.createElement("label");x.style.cssText="position:absolute;top:150px;left:10px;",x.htmlFor=l.id,x.appendChild(l),x.appendChild(f);var E=document.createElement("P");E.innerHTML="Was gibt es hier zu pflegen?",E.style.cssText="position:absolute;left:20px";var I=document.createElement("p");I.style.cssText="position:absolute;top:160px;left:5px",I.innerHTML=`
  Vorhanden:
  Ja
  In Arbeit
-
  Nein`;var E=document.createElement("div");E.style.cssText="position:relative;top:10px;left:10px;background: lightcyan; width: 225px; height: 240px;",E.className="ol-unselectable ol-control noiseselect",E.id="controlEle",E.appendChild(p),E.appendChild(d),E.appendChild(f),E.appendChild(g),E.appendChild(m),E.appendChild(_),E.appendChild(y),super({element:E,target:t.target}),d.addEventListener("change",this.handleModel3dChange.bind(this),!1),f.addEventListener("change",this.handleOtherChange.bind(this),!1),g.addEventListener("change",this.handleOtherChange.bind(this),!1),m.addEventListener("change",this.handleOtherChange.bind(this),!1),_.addEventListener("change",this.handleOtherChange.bind(this),!1)}handleModel3dChange(){ia(),document.getElementById("kreis_yellow").style.display="block"}handleOtherChange(){document.getElementById("kreis_yellow").style.display="none",ia()}}class Vf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:50px;right:5px; width:40px; height:40px;",i.className="CreateDiv",i.id="CreateDiv",super({element:i,target:t.target}),i.addEventListener("click",this.Create.bind(this),!1)}Create(){Yt===!1?(Yt=!0,document.getElementById("CreateDiv").style.border="2px solid red",document.getElementById("createNonModal").style.display="block",document.getElementById("EditDiv").style.border="0px solid red",document.getElementById("DeleteDiv").style.border="0px solid red",document.getElementById("editNonModal").style.display="none",document.getElementById("deleteNonModal").style.display="none",jt=!1,Ut=!1):(Yt=!1,document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("createNonModal").style.display="none")}}class Kf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:100px;right:5px; width:40px; height:40px;",i.className="EditDiv",i.id="EditDiv",super({element:i,target:t.target}),i.addEventListener("click",this.Edit.bind(this),!1)}Edit(){jt===!1?(jt=!0,document.getElementById("EditDiv").style.border="2px solid red",document.getElementById("editNonModal").style.display="block",document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("DeleteDiv").style.border="0px solid red",document.getElementById("createNonModal").style.display="none",document.getElementById("deleteNonModal").style.display="none",Yt=!1,Ut=!1):(jt=!1,document.getElementById("EditDiv").style.border="0px solid red",document.getElementById("editNonModal").style.display="none")}}class Hf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:150px;right:5px; width:40px; height:40px;",i.className="DeleteDiv",i.id="DeleteDiv",super({element:i,target:t.target}),i.addEventListener("click",this.Delete.bind(this),!1)}Delete(){Ut===!1?(Ut=!0,document.getElementById("DeleteDiv").style.border="2px solid red",document.getElementById("deleteNonModal").style.display="block",document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("EditDiv").style.border="0px solid red",document.getElementById("createNonModal").style.display="none",document.getElementById("editNonModal").style.display="none",Yt=!1,jt=!1):(Ut=!1,document.getElementById("DeleteDiv").style.border="0px solid red",document.getElementById("deleteNonModal").style.display="none")}}class qf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:200px;right:5px; width:40px; height:40px;",i.className="LocationDiv",i.id="LocationDiv",super({element:i,target:t.target}),i.addEventListener("click",this.Location.bind(this),!1)}Location(){navigator.geolocation.getCurrentPosition(e);function e(t){un.getView().setCenter(as([t.coords.longitude,t.coords.latitude],"EPSG:4326","EPSG:3857"))}}}class $f extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:5px;right:5px; width:40px; height:40px;",i.className="LayerSwitchDiv",i.id="LayerSwitchDiv",super({element:i,target:t.target}),i.addEventListener("click",this.LayerSwitch.bind(this),!1)}LayerSwitch(){for(var e=un.getLayers().getArray(),t=e.length-1;t>=0;t--)console.log(e[t].className_),e[t].className_=="dop"&&(js==!1?(e[t].setVisible(!0),js=!0,document.getElementById("LayerSwitchDiv").className="LayerSwitchDivK"):(e[t].setVisible(!1),js=!1,document.getElementById("LayerSwitchDiv").className="LayerSwitchDiv"))}}$e=new Ml({url:"https://www.opendem.info/geoserver/openmaps/wms",params:{LAYERS:"openmaps:denkmaeler"},serverType:"geoserver",crossOrigin:"anonymous",attributions:', Stadt Köln & Denkmal 4D Contributors DL-DE-Zero-2.0'});Wr=new Al({source:$e,className:"wmsLayer",zIndex:2});$e.on("imageloadstart",function(){document.getElementById("loader").style.display="block"});$e.on("imageloadend",function(){document.getElementById("loader").style.display="none"});var Jf=new al({wrapX:!1}),Qf=new ol({source:Jf}),eg=new Ml({url:"https://www.wms.nrw.de/geobasis/wms_nw_dop",params:{LAYERS:"nw_dop_rgb"},serverType:"mapserver",crossOrigin:"anonymous",attributions:', Land NRW, DL-DE Zero 3.0'}),tg=new Al({source:eg,visible:!1,className:"dop",zIndex:1}),Bl=13,Yr=774670,jr=6610915;try{ht().y!=null&&(Yr=parseFloat(ht().y))}catch{}try{ht().x!=null&&(jr=parseFloat(ht().x))}catch{}try{ht().xcoord!=null&&(jr=parseFloat(ht().xcoord))}catch{}try{ht().ycoord!=null&&(Yr=parseFloat(ht().ycoord))}catch{}try{ht().zoomView!=null&&(Bl=Number(ht().zoomView))}catch{}var Bn=new it({center:[Yr,jr],zoom:Bl}),un=new sf({controls:cl().extend([new Vf,new Kf,new Hf,new $f,new Uf,new qf,new Zf]),layers:[new _f({source:new Pf({url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png"})}),Wr,tg,Qf],target:"map",overlays:[Xr],view:Bn});function ia(){var n;document.getElementById("rad1").checked&&(n="openmaps:denkmaeler"),document.getElementById("rad2").checked&&(n="openmaps:denkmaeler_fotos"),document.getElementById("rad3").checked&&(n="openmaps:denkmaeler_wiki"),document.getElementById("rad4").checked&&(n="openmaps:denkmaeler_osm"),document.getElementById("rad5").checked&&(n="openmaps:denkmaeler_podcast"),Wr.getSource().updateParams({styles:n})}un.on("singleclick",function(n){if(Yt===!0){var e=wh(n.coordinate);if(ea=e[0],ta=e[1],Dl=n.coordinate[0],Pl=n.coordinate[1],self=this,document.getElementById("coordinates_create_x").innerText=ea,document.getElementById("coordinates_create_y").innerText=ta,self.dinamicPinLayer!==void 0)self.dinamicPinLayer.getVisible()===!1&&self.dinamicPinLayer.setVisible(!0),console.log("move"),self.iconGeometry.setCoordinates(n.coordinate);else{self.iconGeometry=new wa(n.coordinate);var t=new lr({geometry:self.iconGeometry,name:"marker"}),i=new Ki({image:new yn({anchor:[.5,46],anchorXUnits:"fraction",anchorYUnits:"pixels",size:[48,48],opacity:1,src:"images/icon.png"})});t.setStyle(i);var s=new al({features:[t]});self.dinamicPinLayer=new ol({source:s,zIndex:3,className:"pinVector"}),un.addLayer(self.dinamicPinLayer)}}else if(jt===!0){document.getElementById("edit_modelUrl").value="",document.getElementById("edit_bezeichnung").value="",document.getElementById("edit_fotoUrl").value="",document.getElementById("edit_wikiUrl").value="",document.getElementById("edit_podcastUrl").value="",document.getElementById("edit_osm").checked=!1,document.getElementById("edit_model_care").checked=!1,document.getElementById("edit_denkmalliste").value="",document.getElementById("edit_strasse").value="",document.getElementById("edit_hausnummer").value="",document.getElementById("edit_plz").value="",document.getElementById("edit_stadtbezirk").value="",document.getElementById("edit_kategorie").value="",document.getElementById("edit_architektur").value="",document.getElementById("edit_bezeichnung").value="",document.getElementById("edit_unterschutz").value="",document.getElementById("edit_baujahr").value="",document.getElementById("edit_eigentum").value="";var r=Bn.getResolution(),o=$e.getFeatureInfoUrl(n.coordinate,r,"EPSG:3857",{INFO_FORMAT:"application/json"});n.coordinate,o&&fetch(o).then(function(a){if(!a.ok)alert("Irgendwas ist leider schief gegangen.");else return a.text()}).then(function(a){var l=JSON.parse(a);if(window.document.baemsche=l,l.features.length>0){Ye=l.features[0].id,document.getElementById("edit").style.display="block",document.getElementById("editNonModal").style.display="none",document.getElementById("edit_modelUrl").value=l.features[0].properties.model3durl,Ol=l.features[0].properties.model3d,kl=l.features[0].properties.foto,Fl=l.features[0].properties.wiki,Nl=l.features[0].properties.podcast,document.getElementById("edit_fotoUrl").value=l.features[0].properties.fotourl,document.getElementById("edit_wikiUrl").value=l.features[0].properties.wikiurl,document.getElementById("edit_podcastUrl").value=l.features[0].properties.podcasturl;var c=l.features[0].properties.osm;c==="ja"?document.getElementById("edit_osm").checked=!0:document.getElementById("edit_osm").checked=!1;var h=l.features[0].properties.model3d;h==="work"&&(document.getElementById("edit_model_care").checked=!0),document.getElementById("edit_denkmalliste").value=l.features[0].properties.denkmallistennummer,document.getElementById("edit_strasse").value=l.features[0].properties.strasse,document.getElementById("edit_hausnummer").value=l.features[0].properties.hausnummer,document.getElementById("edit_plz").value=l.features[0].properties.plz,document.getElementById("edit_stadtbezirk").value=l.features[0].properties.stadtbezirk,document.getElementById("edit_kategorie").value=l.features[0].properties.kategorie,document.getElementById("edit_architektur").value=l.features[0].properties.architektur,document.getElementById("edit_bezeichnung").value=l.features[0].properties.kurzbezeichnung;try{var u=l.features[0].properties.unterschutzstellung,d=u.split(".");document.getElementById("edit_unterschutz").value=d[2]+"-"+d[1]+"-"+d[0]}catch{}document.getElementById("edit_baujahr").value=l.features[0].properties.baujahr,document.getElementById("edit_eigentum").value=l.features[0].properties.eigentum;var f=l.features[0].properties.aktualisierung.substr(0,l.features[0].properties.aktualisierung.length-1);document.getElementById("editFooter").innerHTML="Letzte Aktualisierung: "+f}})}else if(Ut===!0){var r=Bn.getResolution(),o=$e.getFeatureInfoUrl(n.coordinate,r,"EPSG:3857",{INFO_FORMAT:"application/json"});n.coordinate,o&&fetch(o).then(function(c){if(!c.ok)alert("Irgendwas ist leider schief gegangen.");else return c.text()}).then(function(c){var h=JSON.parse(c);h.features.length>0&&(document.getElementById("delete").style.display="block",document.getElementById("deleteNonModal").style.display="none",Ye=h.features[0].id)})}else{var r=Bn.getResolution(),o=$e.getFeatureInfoUrl(n.coordinate,r,"EPSG:3857",{INFO_FORMAT:"application/json"});n.coordinate,o&&fetch(o).then(function(c){if(!c.ok)alert("Irgendwas ist leider schief gegangen.");else return c.text()}).then(function(c){var h=JSON.parse(c);if(h.features.length>0){var u=n.coordinate;Ye=h.features[0].id,de.innerHTML="",h.features[0].properties.foto==="ja"?de.innerHTML+='
Bitte die Lizenzbedingungen des Fotos beachten':de.innerHTML+='
',de.innerHTML+="Bezeichnung: "+h.features[0].properties.kurzbezeichnung,de.innerHTML+="
Kategorie: "+h.features[0].properties.kategorie,de.innerHTML+="
Adresse: "+h.features[0].properties.strasse+" "+h.features[0].properties.hausnummer+" "+h.features[0].properties.plz+" Köln",de.innerHTML+="
Stadtbezirk: "+h.features[0].properties.stadtbezirk,de.innerHTML+="
Baujahr: "+h.features[0].properties.baujahr,de.innerHTML+="
Geschützt seit: "+h.features[0].properties.unterschutzstellung,de.innerHTML+="
Eigentum: "+h.features[0].properties.eigentum,de.innerHTML+="
Denkmallisten Nummer: "+h.features[0].properties.denkmallistennummer,h.features[0].properties.architektur!==null&&(de.innerHTML+="
Architektur: "+h.features[0].properties.architektur),h.features[0].properties.model3d==="nein"&&(de.innerHTML+='

Leider noch kein 3D Modell vorhanden, erstelle doch bitte eins!

',de.innerHTML+='

',document.getElementById("careDenkmal").addEventListener("click",ig)),h.features[0].properties.model3d==="work"&&(de.innerHTML+="

Um das 3D Modell wird sich bereits gekümmert

"),h.features[0].properties.model3d==="ja"&&(de.innerHTML+='

Link zum 3d Model

'),h.features[0].properties.wiki==="ja"&&(de.innerHTML+='
Link zum Wikipedia Artikel '),h.features[0].properties.podcast==="ja"&&(de.innerHTML+='
Hier geht es zum Podcast '),Xr.setPosition(u)}})}});document.getElementById("createReady").addEventListener("click",ng);document.getElementById("createDenkmal").addEventListener("click",sg);document.getElementById("resetCreateDenkmal").addEventListener("click",resetCreateDenkmal);document.getElementById("editDenkmal").addEventListener("click",rg);document.getElementById("deleteDenkmal").addEventListener("click",og);function ig(){Ye=Ye.replace("denkmaeler.","");var n=Es+"maintainDenkmal.py?ogc_fid="+Ye,e=new XMLHttpRequest;e.onreadystatechange=function(){if(this.readyState==4&&this.status==200)try{var t=JSON.parse(this.response);t.request==="done"?(alert(`Danke für´s Kümmern! - `),$e.updateParams({update:Math.random()})):alert("Leider ist etwas schief gelaufen.")}catch{alert("Leider ist etwas schief gelaufen.")}},e.onerror=function(){alert("Leider ist etwas schief gelaufen.")},e.open("Get",n,!0),e.send()}function ng(){if(document.getElementById("coordinates_create_x").innerText==="")alert("Bitte in die Karte klicken um den Standort eiens Denkmals anzulegen.");else{document.getElementById("coordinates_create_x").innerText,document.getElementById("coordinates_create_y").innerText,document.getElementById("createNonModal").style.display="none",document.getElementById("create").style.display="block";for(var n=un.getLayers().getArray(),e=n.length-1;e>=0;e--)n[e].className_=="pinVector"&&n[e].setVisible(!1);document.getElementById("create_modelUrl").value="",document.getElementById("create_bezeichnung").value="",document.getElementById("create_fotoUrl").value="",document.getElementById("create_wikiUrl").value="",document.getElementById("create_osm").checked=!1,document.getElementById("create_denkmalliste").value="",document.getElementById("create_strasse").value="",document.getElementById("create_hausnummer").value="",document.getElementById("create_plz").value="",document.getElementById("create_stadtbezirk").value="",document.getElementById("create_kategorie").value="",document.getElementById("create_architektur").value="",document.getElementById("create_bezeichnung").value="",document.getElementById("create_unterschutz").value="",document.getElementById("create_baujahr").value="",document.getElementById("create_eigentum").value=""}}function sg(){if(document.getElementById("license").checked===!1)alert("Bitte zunächst die Lizenz akzeptieren");else{document.getElementById("loader").style.display="block";var n=document.getElementById("create_bezeichnung").value,e=document.getElementById("create_strasse").value,t=document.getElementById("create_hausnummer").value,i=document.getElementById("create_plz").value,s=document.getElementById("create_stadtbezirk").value,r=document.getElementById("create_baujahr").value,o=document.getElementById("create_unterschutz").value,a=document.getElementById("create_eigentum").value,l=document.getElementById("create_denkmalliste").value,c=document.getElementById("create_kategorie").value,h=document.getElementById("create_architektur").value,u=document.getElementById("create_modelUrl").value,d="nein";u.length>0&&(d="ja");var f=document.getElementById("create_fotoUrl").value,g="nein";f.length>0&&(g="ja");var m=document.getElementById("create_wikiUrl").value,_="nein";m.length>0&&(_="ja");var p=document.getElementById("create_podcastUrl").value,y="nein";p.length>0&&(y="ja");var E=document.getElementById("create_osm");E.checked?E="ja":E="nein";var x=`${Es}createDenkmal.py?lat=${Dl}&lon=${Pl}&model=${d}&modelurl=${u}&bezeichnung=${n} +
  Nein`;var v=document.createElement("div");v.style.cssText="position:relative;top:10px;left:10px;background: lightcyan; width: 225px; height: 260px;",v.className="ol-unselectable ol-control noiseselect",v.id="controlEle",v.appendChild(E),v.appendChild(g),v.appendChild(m),v.appendChild(_),v.appendChild(p),v.appendChild(y),v.appendChild(x),v.appendChild(I),super({element:v,target:t.target}),g.addEventListener("change",this.handleModel3dChange.bind(this),!1),m.addEventListener("change",this.handleOtherChange.bind(this),!1),_.addEventListener("change",this.handleOtherChange.bind(this),!1),p.addEventListener("change",this.handleOtherChange.bind(this),!1),y.addEventListener("change",this.handleOtherChange.bind(this),!1),x.addEventListener("change",this.handleOtherChange.bind(this),!1)}handleModel3dChange(){na(),document.getElementById("kreis_yellow").style.display="block"}handleOtherChange(){document.getElementById("kreis_yellow").style.display="none",na()}}class Zf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:50px;right:5px; width:40px; height:40px;",i.className="CreateDiv",i.id="CreateDiv",super({element:i,target:t.target}),i.addEventListener("click",this.Create.bind(this),!1)}Create(){Yt===!1?(Yt=!0,document.getElementById("CreateDiv").style.border="2px solid red",document.getElementById("createNonModal").style.display="block",document.getElementById("EditDiv").style.border="0px solid red",document.getElementById("DeleteDiv").style.border="0px solid red",document.getElementById("editNonModal").style.display="none",document.getElementById("deleteNonModal").style.display="none",jt=!1,Ut=!1):(Yt=!1,document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("createNonModal").style.display="none")}}class Kf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:100px;right:5px; width:40px; height:40px;",i.className="EditDiv",i.id="EditDiv",super({element:i,target:t.target}),i.addEventListener("click",this.Edit.bind(this),!1)}Edit(){jt===!1?(jt=!0,document.getElementById("EditDiv").style.border="2px solid red",document.getElementById("editNonModal").style.display="block",document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("DeleteDiv").style.border="0px solid red",document.getElementById("createNonModal").style.display="none",document.getElementById("deleteNonModal").style.display="none",Yt=!1,Ut=!1):(jt=!1,document.getElementById("EditDiv").style.border="0px solid red",document.getElementById("editNonModal").style.display="none")}}class Hf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:150px;right:5px; width:40px; height:40px;",i.className="DeleteDiv",i.id="DeleteDiv",super({element:i,target:t.target}),i.addEventListener("click",this.Delete.bind(this),!1)}Delete(){Ut===!1?(Ut=!0,document.getElementById("DeleteDiv").style.border="2px solid red",document.getElementById("deleteNonModal").style.display="block",document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("EditDiv").style.border="0px solid red",document.getElementById("createNonModal").style.display="none",document.getElementById("editNonModal").style.display="none",Yt=!1,jt=!1):(Ut=!1,document.getElementById("DeleteDiv").style.border="0px solid red",document.getElementById("deleteNonModal").style.display="none")}}class qf extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:200px;right:5px; width:40px; height:40px;",i.className="LocationDiv",i.id="LocationDiv",super({element:i,target:t.target}),i.addEventListener("click",this.Location.bind(this),!1)}Location(){navigator.geolocation.getCurrentPosition(e);function e(t){un.getView().setCenter(hs([t.coords.longitude,t.coords.latitude],"EPSG:4326","EPSG:3857"))}}}class $f extends ut{constructor(e){const t=e||{};var i=document.createElement("div");i.style.cssText="position:absolute;top:5px;right:5px; width:40px; height:40px;",i.className="LayerSwitchDiv",i.id="LayerSwitchDiv",super({element:i,target:t.target}),i.addEventListener("click",this.LayerSwitch.bind(this),!1)}LayerSwitch(){for(var e=un.getLayers().getArray(),t=e.length-1;t>=0;t--)console.log(e[t].className_),e[t].className_=="dop"&&(Vs==!1?(e[t].setVisible(!0),Vs=!0,document.getElementById("LayerSwitchDiv").className="LayerSwitchDivK"):(e[t].setVisible(!1),Vs=!1,document.getElementById("LayerSwitchDiv").className="LayerSwitchDiv"))}}$e=new Al({url:"https://www.opendem.info/geoserver/openmaps/wms",params:{LAYERS:"openmaps:denkmaeler"},serverType:"geoserver",crossOrigin:"anonymous",attributions:', Stadt Köln & Denkmal 4D Contributors DL-DE-Zero-2.0'});Yr=new Dl({source:$e,className:"wmsLayer",zIndex:2});$e.on("imageloadstart",function(){document.getElementById("loader").style.display="block"});$e.on("imageloadend",function(){document.getElementById("loader").style.display="none"});var Jf=new ll({wrapX:!1}),Qf=new al({source:Jf}),eg=new Al({url:"https://www.wms.nrw.de/geobasis/wms_nw_dop",params:{LAYERS:"nw_dop_rgb"},serverType:"mapserver",crossOrigin:"anonymous",attributions:', Land NRW, DL-DE Zero 3.0'}),tg=new Dl({source:eg,visible:!1,className:"dop",zIndex:1}),Gl=13,Ur=774670,Vr=6610915;try{ht().y!=null&&(Ur=parseFloat(ht().y))}catch{}try{ht().x!=null&&(Vr=parseFloat(ht().x))}catch{}try{ht().xcoord!=null&&(Vr=parseFloat(ht().xcoord))}catch{}try{ht().ycoord!=null&&(Ur=parseFloat(ht().ycoord))}catch{}try{ht().zoomView!=null&&(Gl=Number(ht().zoomView))}catch{}var zn=new it({center:[Ur,Vr],zoom:Gl}),un=new sf({controls:ul().extend([new Zf,new Kf,new Hf,new $f,new Uf,new qf,new Vf]),layers:[new _f({source:new Pf({url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png"})}),Yr,tg,Qf],target:"map",overlays:[jr],view:zn});function na(){debugger;var n;document.getElementById("rad1").checked&&(n="openmaps:denkmaeler"),document.getElementById("rad2").checked&&(n="openmaps:denkmaeler_fotos"),document.getElementById("rad3").checked&&(n="openmaps:denkmaeler_wiki"),document.getElementById("rad4").checked&&(n="openmaps:denkmaeler_osm"),document.getElementById("rad5").checked&&(n="openmaps:denkmaeler_podcast"),document.getElementById("rad6").checked&&(n="openmaps:denkmaeler_viewer3d"),Yr.getSource().updateParams({styles:n})}un.on("singleclick",function(n){if(Yt===!0){var e=uo(n.coordinate);if(Nn=e[0],Bn=e[1],Pl=n.coordinate[0],Ol=n.coordinate[1],self=this,document.getElementById("coordinates_create_x").innerText=Nn,document.getElementById("coordinates_create_y").innerText=Bn,self.dinamicPinLayer!==void 0)self.dinamicPinLayer.getVisible()===!1&&self.dinamicPinLayer.setVisible(!0),console.log("move"),self.iconGeometry.setCoordinates(n.coordinate);else{self.iconGeometry=new Ca(n.coordinate);var t=new cr({geometry:self.iconGeometry,name:"marker"}),i=new Ki({image:new yn({anchor:[.5,46],anchorXUnits:"fraction",anchorYUnits:"pixels",size:[48,48],opacity:1,src:"images/icon.png"})});t.setStyle(i);var s=new ll({features:[t]});self.dinamicPinLayer=new al({source:s,zIndex:3,className:"pinVector"}),un.addLayer(self.dinamicPinLayer)}}else if(jt===!0){document.getElementById("edit_modelUrl").value="",document.getElementById("edit_bezeichnung").value="",document.getElementById("edit_fotoUrl").value="",document.getElementById("edit_wikiUrl").value="",document.getElementById("edit_podcastUrl").value="",document.getElementById("edit_osm").checked=!1,document.getElementById("edit_viewer3d").checked=!1,document.getElementById("edit_model_care").checked=!1,document.getElementById("edit_denkmalliste").value="",document.getElementById("edit_strasse").value="",document.getElementById("edit_hausnummer").value="",document.getElementById("edit_plz").value="",document.getElementById("edit_stadtbezirk").value="",document.getElementById("edit_kategorie").value="",document.getElementById("edit_architektur").value="",document.getElementById("edit_bezeichnung").value="",document.getElementById("edit_unterschutz").value="",document.getElementById("edit_baujahr").value="",document.getElementById("edit_eigentum").value="";var r=zn.getResolution(),o=$e.getFeatureInfoUrl(n.coordinate,r,"EPSG:3857",{INFO_FORMAT:"application/json"});n.coordinate,o&&fetch(o).then(function(a){if(!a.ok)alert("Irgendwas ist leider schief gegangen.");else return a.text()}).then(function(a){var l=JSON.parse(a);if(window.document.baemsche=l,l.features.length>0){Ye=l.features[0].id,document.getElementById("edit").style.display="block",document.getElementById("editNonModal").style.display="none",document.getElementById("edit_modelUrl").value=l.features[0].properties.model3durl,kl=l.features[0].properties.model3d,Fl=l.features[0].properties.foto,Nl=l.features[0].properties.wiki,Bl=l.features[0].properties.podcast,document.getElementById("edit_fotoUrl").value=l.features[0].properties.fotourl,document.getElementById("edit_wikiUrl").value=l.features[0].properties.wikiurl,document.getElementById("edit_podcastUrl").value=l.features[0].properties.podcasturl;var c=l.features[0].properties.osm;c==="ja"?document.getElementById("edit_osm").checked=!0:document.getElementById("edit_osm").checked=!1;var h=l.features[0].properties.viewer3d;h==="ja"?document.getElementById("edit_viewer3d").checked=!0:document.getElementById("edit_viewer3d").checked=!1;var u=l.features[0].properties.model3d;u==="work"&&(document.getElementById("edit_model_care").checked=!0),document.getElementById("edit_denkmalliste").value=l.features[0].properties.denkmallistennummer,document.getElementById("edit_strasse").value=l.features[0].properties.strasse,document.getElementById("edit_hausnummer").value=l.features[0].properties.hausnummer,document.getElementById("edit_plz").value=l.features[0].properties.plz,document.getElementById("edit_stadtbezirk").value=l.features[0].properties.stadtbezirk,document.getElementById("edit_kategorie").value=l.features[0].properties.kategorie,document.getElementById("edit_architektur").value=l.features[0].properties.architektur,document.getElementById("edit_bezeichnung").value=l.features[0].properties.kurzbezeichnung;try{var d=l.features[0].properties.unterschutzstellung,f=d.split(".");document.getElementById("edit_unterschutz").value=f[2]+"-"+f[1]+"-"+f[0]}catch{}document.getElementById("edit_baujahr").value=l.features[0].properties.baujahr,document.getElementById("edit_eigentum").value=l.features[0].properties.eigentum;var g=l.features[0].properties.aktualisierung.substr(0,l.features[0].properties.aktualisierung.length-1);document.getElementById("editFooter").innerHTML="Letzte Aktualisierung: "+g}})}else if(Ut===!0){var r=zn.getResolution(),o=$e.getFeatureInfoUrl(n.coordinate,r,"EPSG:3857",{INFO_FORMAT:"application/json"});n.coordinate,o&&fetch(o).then(function(c){if(!c.ok)alert("Irgendwas ist leider schief gegangen.");else return c.text()}).then(function(c){var h=JSON.parse(c);h.features.length>0&&(document.getElementById("delete").style.display="block",document.getElementById("deleteNonModal").style.display="none",Ye=h.features[0].id)})}else{var r=zn.getResolution(),o=$e.getFeatureInfoUrl(n.coordinate,r,"EPSG:3857",{INFO_FORMAT:"application/json"});n.coordinate,o&&fetch(o).then(function(c){if(!c.ok)alert("Irgendwas ist leider schief gegangen.");else return c.text()}).then(function(c){var h=JSON.parse(c);if(h.features.length>0){var u=n.coordinate;if(Ye=h.features[0].id,ue.innerHTML="",h.features[0].properties.foto==="ja"?ue.innerHTML+='
Bitte die Lizenzbedingungen des Fotos beachten':ue.innerHTML+='
',ue.innerHTML+="Bezeichnung: "+h.features[0].properties.kurzbezeichnung,ue.innerHTML+="
Kategorie: "+h.features[0].properties.kategorie,ue.innerHTML+="
Adresse: "+h.features[0].properties.strasse+" "+h.features[0].properties.hausnummer+" "+h.features[0].properties.plz+" Köln",ue.innerHTML+="
Stadtbezirk: "+h.features[0].properties.stadtbezirk,ue.innerHTML+="
Baujahr: "+h.features[0].properties.baujahr,ue.innerHTML+="
Geschützt seit: "+h.features[0].properties.unterschutzstellung,ue.innerHTML+="
Eigentum: "+h.features[0].properties.eigentum,ue.innerHTML+="
Denkmallisten Nummer: "+h.features[0].properties.denkmallistennummer,h.features[0].properties.architektur!==null&&(ue.innerHTML+="
Architektur: "+h.features[0].properties.architektur),h.features[0].properties.model3d==="nein"&&(ue.innerHTML+='

Leider noch kein 3D Modell vorhanden, erstelle doch bitte eins!

',ue.innerHTML+='

',document.getElementById("careDenkmal").addEventListener("click",ig)),h.features[0].properties.model3d==="work"&&(ue.innerHTML+="
Um das 3D Modell wird sich bereits gekümmert "),h.features[0].properties.model3d==="ja"&&(ue.innerHTML+='
Link zum 3d Model '),h.features[0].properties.wiki==="ja"&&(ue.innerHTML+='
Link zum Wikipedia Artikel '),h.features[0].properties.podcast==="ja"&&(ue.innerHTML+='
Hier geht es zum Podcast '),h.features[0].properties.viewer3d==="ja"){var d=uo(n.coordinate);Bn=d[0],Nn=d[1];const f="https://ertanoz.github.io/Cesium3DHeritageMap/Apps/3DHeritageMapApp.html?lon="+Bn+"&lat="+Nn;ue.innerHTML+='
Modell im 3D Viewer Köln anschauen '}jr.setPosition(u)}})}});document.getElementById("createReady").addEventListener("click",ng);document.getElementById("createDenkmal").addEventListener("click",sg);document.getElementById("resetCreateDenkmal").addEventListener("click",resetCreateDenkmal);document.getElementById("editDenkmal").addEventListener("click",rg);document.getElementById("deleteDenkmal").addEventListener("click",og);function ig(){Ye=Ye.replace("denkmaeler.","");var n=Is+"maintainDenkmal.py?ogc_fid="+Ye,e=new XMLHttpRequest;e.onreadystatechange=function(){if(this.readyState==4&&this.status==200)try{var t=JSON.parse(this.response);t.request==="done"?(alert(`Danke für´s Kümmern! + `),$e.updateParams({update:Math.random()})):alert("Leider ist etwas schief gelaufen.")}catch{alert("Leider ist etwas schief gelaufen.")}},e.onerror=function(){alert("Leider ist etwas schief gelaufen.")},e.open("Get",n,!0),e.send()}function ng(){if(document.getElementById("coordinates_create_x").innerText==="")alert("Bitte in die Karte klicken um den Standort eiens Denkmals anzulegen.");else{document.getElementById("coordinates_create_x").innerText,document.getElementById("coordinates_create_y").innerText,document.getElementById("createNonModal").style.display="none",document.getElementById("create").style.display="block";for(var n=un.getLayers().getArray(),e=n.length-1;e>=0;e--)n[e].className_=="pinVector"&&n[e].setVisible(!1);document.getElementById("create_modelUrl").value="",document.getElementById("create_bezeichnung").value="",document.getElementById("create_fotoUrl").value="",document.getElementById("create_wikiUrl").value="",document.getElementById("create_osm").checked=!1,document.getElementById("create_denkmalliste").value="",document.getElementById("create_strasse").value="",document.getElementById("create_hausnummer").value="",document.getElementById("create_plz").value="",document.getElementById("create_stadtbezirk").value="",document.getElementById("create_kategorie").value="",document.getElementById("create_architektur").value="",document.getElementById("create_bezeichnung").value="",document.getElementById("create_unterschutz").value="",document.getElementById("create_baujahr").value="",document.getElementById("create_eigentum").value=""}}function sg(){if(document.getElementById("license").checked===!1)alert("Bitte zunächst die Lizenz akzeptieren");else{document.getElementById("loader").style.display="block";var n=document.getElementById("create_bezeichnung").value,e=document.getElementById("create_strasse").value,t=document.getElementById("create_hausnummer").value,i=document.getElementById("create_plz").value,s=document.getElementById("create_stadtbezirk").value,r=document.getElementById("create_baujahr").value,o=document.getElementById("create_unterschutz").value,a=document.getElementById("create_eigentum").value,l=document.getElementById("create_denkmalliste").value,c=document.getElementById("create_kategorie").value,h=document.getElementById("create_architektur").value,u=document.getElementById("create_modelUrl").value,d="nein";u.length>0&&(d="ja");var f=document.getElementById("create_fotoUrl").value,g="nein";f.length>0&&(g="ja");var m=document.getElementById("create_wikiUrl").value,_="nein";m.length>0&&(_="ja");var p=document.getElementById("create_podcastUrl").value,y="nein";p.length>0&&(y="ja");var x=document.getElementById("create_osm");x.checked?x="ja":x="nein";var E=`${Is}createDenkmal.py?lat=${Pl}&lon=${Ol}&model=${d}&modelurl=${u}&bezeichnung=${n} &strasse=${e}&hausnummer=${t}&plz=${i}&stadtbezirk=${s}&baujahr=${r} &unterschutzstellung=${o}&eigentum=${a}&denkmalliste=${l}&kategorie=${c}&foto=${g}&fotourl=${f} -&wiki=${_}&wikiurl=${m}&osm=${E}&architektur=${h}&podcast=${y}&podcasturl=${p}`,I=new XMLHttpRequest;I.onreadystatechange=function(){if(this.readyState==4&&this.status==200)try{var C=JSON.parse(this.response);C.request==="done"?(document.getElementById("loader").style.display="none",alert("Danke! Ein neues Denkmal wurde eingepflegt."),document.getElementById("create").style.display="none",document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("coordinates_create_x").innerText="",document.getElementById("coordinates_create_y").innerText="",Yt=!1,$e.updateParams({update:Math.random()})):(alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none")}catch{alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none"}},I.onerror=function(){document.getElementById("loader").style.display="none",alert("Leider ist etwas schief gelaufen.")},I.open("Get",x,!0),I.send()}}function rg(){if(document.getElementById("licenseEdit").checked===!1)alert("Bitte zunächst die Lizenz akzeptieren");else{document.getElementById("loader").style.display="block",Ye=Ye.replace("denkmaeler.","");var n=document.getElementById("edit_modelUrl").value,e=Ol,t=document.getElementById("edit_model_care");t.checked===!1&&(e="nein"),n.length>0?e="ja":e="nein";var i=kl,s=document.getElementById("edit_fotoUrl").value;s.length>0?i="ja":i="nein";var r=Fl,o=document.getElementById("edit_wikiUrl").value;o.length>0?r="ja":r="nein";var a=Nl,l=document.getElementById("edit_podcastUrl").value;l.length>0?a="ja":a="nein";var c=document.getElementById("edit_bezeichnung").value,h=document.getElementById("edit_osm");h.checked===!0?h="ja":h="nein";var u=document.getElementById("edit_strasse").value,d=document.getElementById("edit_hausnummer").value,f=document.getElementById("edit_plz").value,g=document.getElementById("edit_stadtbezirk").value,m=document.getElementById("edit_baujahr").value,_=document.getElementById("edit_unterschutz").value,p=document.getElementById("edit_eigentum").value,y=document.getElementById("edit_denkmalliste").value,E=document.getElementById("edit_kategorie").value,x=document.getElementById("edit_architektur").value,I=new Date;I=I.getFullYear()+"-"+(I.getMonth()+1)+"-"+I.getDate();var C=`${Es}editDenkmal.py?ogc_fid=${Ye}&model=${e}&modelurl=${n}&bezeichnung=${c} -&strasse=${u}&hausnummer=${d}&plz=${f}&stadtbezirk=${g}&baujahr=${m} -&unterschutzstellung=${_}&eigentum=${p}&denkmalliste=${y}&kategorie=${E}&foto=${i} -&fotourl=${s}&wiki=${r}&wikiurl=${o}&osm=${h}&aktualisierung=${I}&architektur=${x} -&podcast=${a}&podcasturl=${l}`,R=new XMLHttpRequest;R.onreadystatechange=function(){if(this.readyState==4&&this.status==200)try{var w=JSON.parse(this.response);w.request==="done"?(document.getElementById("loader").style.display="none",alert("Danke! Die Daten des Denkmals wurden angepasst."),document.getElementById("edit").style.display="none",document.getElementById("EditDiv").style.border="0px solid red",jt=!1,$e.updateParams({update:Math.random()})):(alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none")}catch{alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none"}},R.onerror=function(){document.getElementById("loader").style.display="none",alert("Leider ist etwas schief gelaufen.")},R.open("Get",C,!0),R.send()}}function og(){if(document.getElementById("checkDelete").checked===!1)alert("Bitte zunächst die Checkbox aktivieren, um zu Bestätigen, dass dieses Denkmal wirklich gelöscht werden soll.");else{Ye=Ye.replace("denkmaeler.","");var n=Es+"deleteDenkmal.py?ogc_fid="+Ye,e=new XMLHttpRequest;e.onreadystatechange=function(){if(this.readyState==4&&this.status==200)try{var t=JSON.parse(this.response);t.request==="done"?(alert("Danke! Dieses Denkmal wurde aus dem Datensatz gelöscht."),document.getElementById("delete").style.display="none",document.getElementById("DeleteDiv").style.border="0px solid red",Ut=!1,$e.updateParams({update:Math.random()})):(alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none")}catch{alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none"}},e.onerror=function(){alert("Leider ist etwas schief gelaufen.")},e.open("Get",n,!0),e.send()}}document.getElementById("helpIcon").addEventListener("click",ag);function ag(){document.getElementById("help").style.display="block",document.getElementById("head").style.pointerEvents="none",document.getElementById("head").style.opacity="50%",document.getElementById("map").style.pointerEvents="none",document.getElementById("map").style.opacity="50%"}document.getElementById("closeHelp").addEventListener("click",lg);function lg(){document.getElementById("help").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1"}document.getElementById("legalIcon").addEventListener("click",hg);function hg(){document.getElementById("legal").style.display="block",document.getElementById("head").style.pointerEvents="none",document.getElementById("head").style.opacity="50%",document.getElementById("map").style.pointerEvents="none",document.getElementById("map").style.opacity="50%"}document.getElementById("closeLegal").addEventListener("click",cg);function cg(){document.getElementById("legal").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1"}document.getElementById("storyIcon").addEventListener("click",ug);function ug(){document.getElementById("story").style.display="block",document.getElementById("head").style.pointerEvents="none",document.getElementById("head").style.opacity="50%",document.getElementById("map").style.pointerEvents="none",document.getElementById("map").style.opacity="50%"}document.getElementById("closestory").addEventListener("click",dg);function dg(){document.getElementById("story").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1"}document.getElementById("closeCreate").addEventListener("click",fg);function fg(){document.getElementById("create").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1",document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("coordinates_create_x").innerText="",document.getElementById("coordinates_create_y").innerText="",Yt=!1}document.getElementById("closeEdit").addEventListener("click",gg);function gg(){document.getElementById("edit").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1",document.getElementById("EditDiv").style.border="0px solid red",jt=!1}document.getElementById("closeDelete").addEventListener("click",mg);function mg(){document.getElementById("delete").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1",document.getElementById("DeleteDiv").style.border="0px solid red",Ut=!1}function ht(){var n={};return window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(e,t,i){n[t]=i}),n}function _g(n){if(innerWidth<450){var e=document.getElementById("titleApp");e.style.fontSize="1.1rem",e.style.top="0px"}}document.addEventListener("DOMContentLoaded",_g); -//# sourceMappingURL=index-iSzUt6tk.js.map +&wiki=${_}&wikiurl=${m}&osm=${x}&architektur=${h}&podcast=${y}&podcasturl=${p}`,I=new XMLHttpRequest;I.onreadystatechange=function(){if(this.readyState==4&&this.status==200)try{var v=JSON.parse(this.response);v.request==="done"?(document.getElementById("loader").style.display="none",alert("Danke! Ein neues Denkmal wurde eingepflegt."),document.getElementById("create").style.display="none",document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("coordinates_create_x").innerText="",document.getElementById("coordinates_create_y").innerText="",Yt=!1,$e.updateParams({update:Math.random()})):(alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none")}catch{alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none"}},I.onerror=function(){document.getElementById("loader").style.display="none",alert("Leider ist etwas schief gelaufen.")},I.open("Get",E,!0),I.send()}}function rg(){if(document.getElementById("licenseEdit").checked===!1)alert("Bitte zunächst die Lizenz akzeptieren");else{document.getElementById("loader").style.display="block",Ye=Ye.replace("denkmaeler.","");var n=document.getElementById("edit_modelUrl").value,e=kl,t=document.getElementById("edit_model_care");t.checked===!1&&(e="nein"),n.length>0?e="ja":e="nein";var i=Fl,s=document.getElementById("edit_fotoUrl").value;s.length>0?i="ja":i="nein";var r=Nl,o=document.getElementById("edit_wikiUrl").value;o.length>0?r="ja":r="nein";var a=Bl,l=document.getElementById("edit_podcastUrl").value;l.length>0?a="ja":a="nein";var c=document.getElementById("edit_bezeichnung").value,h=document.getElementById("edit_osm");h.checked===!0?h="ja":h="nein";var u=document.getElementById("edit_viewer3d");u.checked===!0?u="ja":u="nein";var d=document.getElementById("edit_strasse").value,f=document.getElementById("edit_hausnummer").value,g=document.getElementById("edit_plz").value,m=document.getElementById("edit_stadtbezirk").value,_=document.getElementById("edit_baujahr").value,p=document.getElementById("edit_unterschutz").value,y=document.getElementById("edit_eigentum").value,x=document.getElementById("edit_denkmalliste").value,E=document.getElementById("edit_kategorie").value,I=document.getElementById("edit_architektur").value,v=new Date;v=v.getFullYear()+"-"+(v.getMonth()+1)+"-"+v.getDate();var R=`${Is}editDenkmal.py?ogc_fid=${Ye}&model=${e}&modelurl=${n}&bezeichnung=${c} +&strasse=${d}&hausnummer=${f}&plz=${g}&stadtbezirk=${m}&baujahr=${_} +&unterschutzstellung=${p}&eigentum=${y}&denkmalliste=${x}&kategorie=${E}&foto=${i} +&fotourl=${s}&wiki=${r}&wikiurl=${o}&osm=${h}&aktualisierung=${v}&architektur=${I} +&podcast=${a}&podcasturl=${l}&viewer3d=${u}`,C=new XMLHttpRequest;C.onreadystatechange=function(){if(this.readyState==4&&this.status==200)try{var T=JSON.parse(this.response);T.request==="done"?(document.getElementById("loader").style.display="none",alert("Danke! Die Daten des Denkmals wurden angepasst."),document.getElementById("edit").style.display="none",document.getElementById("EditDiv").style.border="0px solid red",jt=!1,$e.updateParams({update:Math.random()})):(alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none")}catch{alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none"}},C.onerror=function(){document.getElementById("loader").style.display="none",alert("Leider ist etwas schief gelaufen.")},C.open("Get",R,!0),C.send()}}function og(){if(document.getElementById("checkDelete").checked===!1)alert("Bitte zunächst die Checkbox aktivieren, um zu Bestätigen, dass dieses Denkmal wirklich gelöscht werden soll.");else{Ye=Ye.replace("denkmaeler.","");var n=Is+"deleteDenkmal.py?ogc_fid="+Ye,e=new XMLHttpRequest;e.onreadystatechange=function(){if(this.readyState==4&&this.status==200)try{var t=JSON.parse(this.response);t.request==="done"?(alert("Danke! Dieses Denkmal wurde aus dem Datensatz gelöscht."),document.getElementById("delete").style.display="none",document.getElementById("DeleteDiv").style.border="0px solid red",Ut=!1,$e.updateParams({update:Math.random()})):(alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none")}catch{alert("Leider ist etwas schief gelaufen."),document.getElementById("loader").style.display="none"}},e.onerror=function(){alert("Leider ist etwas schief gelaufen.")},e.open("Get",n,!0),e.send()}}document.getElementById("helpIcon").addEventListener("click",ag);function ag(){document.getElementById("help").style.display="block",document.getElementById("head").style.pointerEvents="none",document.getElementById("head").style.opacity="50%",document.getElementById("map").style.pointerEvents="none",document.getElementById("map").style.opacity="50%"}document.getElementById("closeHelp").addEventListener("click",lg);function lg(){document.getElementById("help").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1"}document.getElementById("legalIcon").addEventListener("click",hg);function hg(){document.getElementById("legal").style.display="block",document.getElementById("head").style.pointerEvents="none",document.getElementById("head").style.opacity="50%",document.getElementById("map").style.pointerEvents="none",document.getElementById("map").style.opacity="50%"}document.getElementById("closeLegal").addEventListener("click",cg);function cg(){document.getElementById("legal").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1"}document.getElementById("storyIcon").addEventListener("click",ug);function ug(){document.getElementById("story").style.display="block",document.getElementById("head").style.pointerEvents="none",document.getElementById("head").style.opacity="50%",document.getElementById("map").style.pointerEvents="none",document.getElementById("map").style.opacity="50%"}document.getElementById("closestory").addEventListener("click",dg);function dg(){document.getElementById("story").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1"}document.getElementById("closeCreate").addEventListener("click",fg);function fg(){document.getElementById("create").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1",document.getElementById("CreateDiv").style.border="0px solid red",document.getElementById("coordinates_create_x").innerText="",document.getElementById("coordinates_create_y").innerText="",Yt=!1}document.getElementById("closeEdit").addEventListener("click",gg);function gg(){document.getElementById("edit").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1",document.getElementById("EditDiv").style.border="0px solid red",jt=!1}document.getElementById("closeDelete").addEventListener("click",mg);function mg(){document.getElementById("delete").style.display="none",document.getElementById("head").style.pointerEvents="auto",document.getElementById("head").style.opacity="1",document.getElementById("map").style.pointerEvents="auto",document.getElementById("map").style.opacity="1",document.getElementById("DeleteDiv").style.border="0px solid red",Ut=!1}function ht(){var n={};return window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(e,t,i){n[t]=i}),n}function _g(n){if(innerWidth<450){var e=document.getElementById("titleApp");e.style.fontSize="1.1rem",e.style.top="0px"}}document.addEventListener("DOMContentLoaded",_g); +//# sourceMappingURL=index-D-hFAano.js.map diff --git a/assets/index-iSzUt6tk.js.map b/assets/index-D-hFAano.js.map similarity index 75% rename from assets/index-iSzUt6tk.js.map rename to assets/index-D-hFAano.js.map index b93dcaf..2dc1396 100644 --- a/assets/index-iSzUt6tk.js.map +++ b/assets/index-D-hFAano.js.map @@ -1 +1 @@ -{"version":3,"file":"index-iSzUt6tk.js","sources":["../../node_modules/ol/events/Event.js","../../node_modules/ol/ObjectEventType.js","../../node_modules/ol/Disposable.js","../../node_modules/ol/array.js","../../node_modules/ol/functions.js","../../node_modules/ol/obj.js","../../node_modules/ol/events/Target.js","../../node_modules/ol/events/EventType.js","../../node_modules/ol/events.js","../../node_modules/ol/Observable.js","../../node_modules/ol/util.js","../../node_modules/ol/Object.js","../../node_modules/ol/CollectionEventType.js","../../node_modules/ol/Collection.js","../../node_modules/ol/asserts.js","../../node_modules/ol/Feature.js","../../node_modules/ol/transform.js","../../node_modules/ol/extent/Relationship.js","../../node_modules/ol/extent.js","../../node_modules/ol/proj/Units.js","../../node_modules/ol/proj/Projection.js","../../node_modules/ol/proj/epsg3857.js","../../node_modules/ol/proj/epsg4326.js","../../node_modules/ol/proj/projections.js","../../node_modules/ol/proj/transforms.js","../../node_modules/ol/math.js","../../node_modules/ol/string.js","../../node_modules/ol/coordinate.js","../../node_modules/ol/sphere.js","../../node_modules/ol/console.js","../../node_modules/ol/proj.js","../../node_modules/ol/geom/flat/transform.js","../../node_modules/ol/geom/Geometry.js","../../node_modules/ol/geom/SimpleGeometry.js","../../node_modules/ol/geom/flat/closest.js","../../node_modules/ol/geom/flat/deflate.js","../../node_modules/ol/geom/flat/simplify.js","../../node_modules/ol/geom/flat/inflate.js","../../node_modules/ol/geom/flat/area.js","../../node_modules/ol/geom/LinearRing.js","../../node_modules/ol/geom/Point.js","../../node_modules/ol/geom/flat/contains.js","../../node_modules/ol/geom/flat/interiorpoint.js","../../node_modules/ol/geom/flat/segments.js","../../node_modules/ol/geom/flat/intersectsextent.js","../../node_modules/ol/geom/flat/reverse.js","../../node_modules/ol/geom/flat/orient.js","../../node_modules/ol/geom/Polygon.js","../../node_modules/ol/render/EventType.js","../../node_modules/ol/ImageState.js","../../node_modules/color-space/rgb.js","../../node_modules/color-space/xyz.js","../../node_modules/color-space/luv.js","../../node_modules/color-space/lchuv.js","../../node_modules/color-name/index.js","../../node_modules/color-parse/index.js","../../node_modules/color-space/hsl.js","../../node_modules/color-rgba/index.js","../../node_modules/ol/color.js","../../node_modules/ol/has.js","../../node_modules/ol/dom.js","../../node_modules/ol/Image.js","../../node_modules/ol/style/IconImageCache.js","../../node_modules/ol/style/IconImage.js","../../node_modules/ol/style/Fill.js","../../node_modules/ol/geom/flat/interpolate.js","../../node_modules/ol/geom/flat/length.js","../../node_modules/ol/style/Stroke.js","../../node_modules/ol/size.js","../../node_modules/ol/style/Image.js","../../node_modules/ol/colorlike.js","../../node_modules/ol/css.js","../../node_modules/ol/render/canvas.js","../../node_modules/ol/style/RegularShape.js","../../node_modules/ol/style/Circle.js","../../node_modules/ol/style/Style.js","../../node_modules/ol/style/Text.js","../../node_modules/ol/layer/Property.js","../../node_modules/ol/layer/Base.js","../../node_modules/ol/ViewHint.js","../../node_modules/ol/ViewProperty.js","../../node_modules/ol/tilegrid/common.js","../../node_modules/ol/centerconstraint.js","../../node_modules/ol/resolutionconstraint.js","../../node_modules/ol/rotationconstraint.js","../../node_modules/ol/easing.js","../../node_modules/ol/View.js","../../node_modules/ol/layer/Layer.js","../../node_modules/quickselect/index.js","../../node_modules/rbush/index.js","../../node_modules/ol/style/Icon.js","../../node_modules/ol/expr/expression.js","../../node_modules/ol/expr/cpu.js","../../node_modules/ol/render/canvas/style.js","../../node_modules/ol/layer/BaseVector.js","../../node_modules/ol/render/canvas/Instruction.js","../../node_modules/ol/render/VectorContext.js","../../node_modules/ol/render/canvas/Builder.js","../../node_modules/ol/render/canvas/ImageBuilder.js","../../node_modules/ol/render/canvas/LineStringBuilder.js","../../node_modules/ol/render/canvas/PolygonBuilder.js","../../node_modules/ol/geom/flat/linechunk.js","../../node_modules/ol/geom/flat/straightchunk.js","../../node_modules/ol/render/canvas/TextBuilder.js","../../node_modules/ol/render/canvas/BuilderGroup.js","../../node_modules/ol/renderer/Layer.js","../../node_modules/ol/render/Event.js","../../node_modules/ol/render/canvas/ZIndexContext.js","../../node_modules/ol/renderer/canvas/Layer.js","../../node_modules/ol/geom/flat/textpath.js","../../node_modules/ol/render/canvas/Executor.js","../../node_modules/ol/render/canvas/ExecutorGroup.js","../../node_modules/ol/render/canvas/Immediate.js","../../node_modules/ol/render/canvas/hitdetect.js","../../node_modules/ol/renderer/vector.js","../../node_modules/ol/renderer/canvas/VectorLayer.js","../../node_modules/ol/layer/Vector.js","../../node_modules/ol/structs/RBush.js","../../node_modules/ol/geom/flat/center.js","../../node_modules/ol/render/Feature.js","../../node_modules/ol/source/Source.js","../../node_modules/ol/source/VectorEventType.js","../../node_modules/ol/loadingstrategy.js","../../node_modules/ol/featureloader.js","../../node_modules/ol/source/Vector.js","../../node_modules/ol/TileState.js","../../node_modules/ol/Tile.js","../../node_modules/ol/ImageTile.js","../../node_modules/ol/Kinetic.js","../../node_modules/ol/renderer/Map.js","../../node_modules/ol/renderer/Composite.js","../../node_modules/ol/layer/Group.js","../../node_modules/ol/MapEvent.js","../../node_modules/ol/MapBrowserEvent.js","../../node_modules/ol/MapBrowserEventType.js","../../node_modules/ol/pointer/EventType.js","../../node_modules/ol/MapBrowserEventHandler.js","../../node_modules/ol/MapEventType.js","../../node_modules/ol/MapProperty.js","../../node_modules/ol/structs/PriorityQueue.js","../../node_modules/ol/TileQueue.js","../../node_modules/ol/control/Control.js","../../node_modules/ol/control/Attribution.js","../../node_modules/ol/control/Rotate.js","../../node_modules/ol/control/Zoom.js","../../node_modules/ol/control/defaults.js","../../node_modules/ol/interaction/Property.js","../../node_modules/ol/interaction/Interaction.js","../../node_modules/ol/interaction/DoubleClickZoom.js","../../node_modules/ol/interaction/Pointer.js","../../node_modules/ol/events/condition.js","../../node_modules/ol/interaction/DragPan.js","../../node_modules/ol/interaction/DragRotate.js","../../node_modules/ol/render/Box.js","../../node_modules/ol/interaction/DragBox.js","../../node_modules/ol/interaction/DragZoom.js","../../node_modules/ol/events/Key.js","../../node_modules/ol/interaction/KeyboardPan.js","../../node_modules/ol/interaction/KeyboardZoom.js","../../node_modules/ol/interaction/MouseWheelZoom.js","../../node_modules/ol/interaction/PinchRotate.js","../../node_modules/ol/interaction/PinchZoom.js","../../node_modules/ol/interaction/defaults.js","../../node_modules/ol/Map.js","../../node_modules/ol/Overlay.js","../../node_modules/ol/structs/LRUCache.js","../../node_modules/ol/tilecoord.js","../../node_modules/ol/TileCache.js","../../node_modules/ol/TileRange.js","../../node_modules/ol/layer/TileProperty.js","../../node_modules/ol/layer/BaseTile.js","../../node_modules/ol/reproj/common.js","../../node_modules/ol/reproj/Triangulation.js","../../node_modules/ol/reproj.js","../../node_modules/ol/reproj/Tile.js","../../node_modules/ol/renderer/canvas/TileLayer.js","../../node_modules/ol/layer/Tile.js","../../node_modules/ol/source/TileEventType.js","../../node_modules/ol/tilegrid/TileGrid.js","../../node_modules/ol/tilegrid.js","../../node_modules/ol/source/Tile.js","../../node_modules/ol/tileurlfunction.js","../../node_modules/ol/source/UrlTile.js","../../node_modules/ol/source/TileImage.js","../../node_modules/ol/source/XYZ.js","../../node_modules/ol/source/OSM.js","../../node_modules/ol/resolution.js","../../node_modules/ol/reproj/Image.js","../../node_modules/ol/source/common.js","../../node_modules/ol/source/Image.js","../../node_modules/ol/uri.js","../../node_modules/ol/source/wms.js","../../node_modules/ol/source/ImageWMS.js","../../node_modules/ol/layer/BaseImage.js","../../node_modules/ol/renderer/canvas/ImageLayer.js","../../node_modules/ol/layer/Image.js","../../main.js"],"sourcesContent":["/**\n * @module ol/events/Event\n */\n\n/**\n * @classdesc\n * Stripped down implementation of the W3C DOM Level 2 Event interface.\n * See https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface.\n *\n * This implementation only provides `type` and `target` properties, and\n * `stopPropagation` and `preventDefault` methods. It is meant as base class\n * for higher level events defined in the library, and works with\n * {@link module:ol/events/Target~Target}.\n */\nclass BaseEvent {\n /**\n * @param {string} type Type.\n */\n constructor(type) {\n /**\n * @type {boolean}\n */\n this.propagationStopped;\n\n /**\n * @type {boolean}\n */\n this.defaultPrevented;\n\n /**\n * The event type.\n * @type {string}\n * @api\n */\n this.type = type;\n\n /**\n * The event target.\n * @type {Object}\n * @api\n */\n this.target = null;\n }\n\n /**\n * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events\n * will be fired.\n * @api\n */\n preventDefault() {\n this.defaultPrevented = true;\n }\n\n /**\n * Stop event propagation.\n * @api\n */\n stopPropagation() {\n this.propagationStopped = true;\n }\n}\n\n/**\n * @param {Event|import(\"./Event.js\").default} evt Event\n */\nexport function stopPropagation(evt) {\n evt.stopPropagation();\n}\n\n/**\n * @param {Event|import(\"./Event.js\").default} evt Event\n */\nexport function preventDefault(evt) {\n evt.preventDefault();\n}\n\nexport default BaseEvent;\n","/**\n * @module ol/ObjectEventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered when a property is changed.\n * @event module:ol/Object.ObjectEvent#propertychange\n * @api\n */\n PROPERTYCHANGE: 'propertychange',\n};\n\n/**\n * @typedef {'propertychange'} Types\n */\n","/**\n * @module ol/Disposable\n */\n\n/**\n * @classdesc\n * Objects that need to clean up after themselves.\n */\nclass Disposable {\n constructor() {\n /**\n * The object has already been disposed.\n * @type {boolean}\n * @protected\n */\n this.disposed = false;\n }\n\n /**\n * Clean up.\n */\n dispose() {\n if (!this.disposed) {\n this.disposed = true;\n this.disposeInternal();\n }\n }\n\n /**\n * Extension point for disposable objects.\n * @protected\n */\n disposeInternal() {}\n}\n\nexport default Disposable;\n","/**\n * @module ol/array\n */\n\n/**\n * Performs a binary search on the provided sorted list and returns the index of the item if found. If it can't be found it'll return -1.\n * https://github.com/darkskyapp/binary-search\n *\n * @param {Array<*>} haystack Items to search through.\n * @param {*} needle The item to look for.\n * @param {Function} [comparator] Comparator function.\n * @return {number} The index of the item if found, -1 if not.\n */\nexport function binarySearch(haystack, needle, comparator) {\n let mid, cmp;\n comparator = comparator || ascending;\n let low = 0;\n let high = haystack.length;\n let found = false;\n\n while (low < high) {\n /* Note that \"(low + high) >>> 1\" may overflow, and results in a typecast\n * to double (which gives the wrong results). */\n mid = low + ((high - low) >> 1);\n cmp = +comparator(haystack[mid], needle);\n\n if (cmp < 0.0) {\n /* Too low. */\n low = mid + 1;\n } else {\n /* Key found or too high */\n high = mid;\n found = !cmp;\n }\n }\n\n /* Key not found. */\n return found ? low : ~low;\n}\n\n/**\n * Compare function sorting arrays in ascending order. Safe to use for numeric values.\n * @param {*} a The first object to be compared.\n * @param {*} b The second object to be compared.\n * @return {number} A negative number, zero, or a positive number as the first\n * argument is less than, equal to, or greater than the second.\n */\nexport function ascending(a, b) {\n return a > b ? 1 : a < b ? -1 : 0;\n}\n\n/**\n * Compare function sorting arrays in descending order. Safe to use for numeric values.\n * @param {*} a The first object to be compared.\n * @param {*} b The second object to be compared.\n * @return {number} A negative number, zero, or a positive number as the first\n * argument is greater than, equal to, or less than the second.\n */\nexport function descending(a, b) {\n return a < b ? 1 : a > b ? -1 : 0;\n}\n\n/**\n * {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution} can use a function\n * of this type to determine which nearest resolution to use.\n *\n * This function takes a `{number}` representing a value between two array entries,\n * a `{number}` representing the value of the nearest higher entry and\n * a `{number}` representing the value of the nearest lower entry\n * as arguments and returns a `{number}`. If a negative number or zero is returned\n * the lower value will be used, if a positive number is returned the higher value\n * will be used.\n * @typedef {function(number, number, number): number} NearestDirectionFunction\n * @api\n */\n\n/**\n * @param {Array} arr Array in descending order.\n * @param {number} target Target.\n * @param {number|NearestDirectionFunction} direction\n * 0 means return the nearest,\n * > 0 means return the largest nearest,\n * < 0 means return the smallest nearest.\n * @return {number} Index.\n */\nexport function linearFindNearest(arr, target, direction) {\n if (arr[0] <= target) {\n return 0;\n }\n\n const n = arr.length;\n if (target <= arr[n - 1]) {\n return n - 1;\n }\n\n if (typeof direction === 'function') {\n for (let i = 1; i < n; ++i) {\n const candidate = arr[i];\n if (candidate === target) {\n return i;\n }\n if (candidate < target) {\n if (direction(target, arr[i - 1], candidate) > 0) {\n return i - 1;\n }\n return i;\n }\n }\n return n - 1;\n }\n\n if (direction > 0) {\n for (let i = 1; i < n; ++i) {\n if (arr[i] < target) {\n return i - 1;\n }\n }\n return n - 1;\n }\n\n if (direction < 0) {\n for (let i = 1; i < n; ++i) {\n if (arr[i] <= target) {\n return i;\n }\n }\n return n - 1;\n }\n\n for (let i = 1; i < n; ++i) {\n if (arr[i] == target) {\n return i;\n }\n if (arr[i] < target) {\n if (arr[i - 1] - target < target - arr[i]) {\n return i - 1;\n }\n return i;\n }\n }\n return n - 1;\n}\n\n/**\n * @param {Array<*>} arr Array.\n * @param {number} begin Begin index.\n * @param {number} end End index.\n */\nexport function reverseSubArray(arr, begin, end) {\n while (begin < end) {\n const tmp = arr[begin];\n arr[begin] = arr[end];\n arr[end] = tmp;\n ++begin;\n --end;\n }\n}\n\n/**\n * @param {Array} arr The array to modify.\n * @param {!Array|VALUE} data The elements or arrays of elements to add to arr.\n * @template VALUE\n */\nexport function extend(arr, data) {\n const extension = Array.isArray(data) ? data : [data];\n const length = extension.length;\n for (let i = 0; i < length; i++) {\n arr[arr.length] = extension[i];\n }\n}\n\n/**\n * @param {Array} arr The array to modify.\n * @param {VALUE} obj The element to remove.\n * @template VALUE\n * @return {boolean} If the element was removed.\n */\nexport function remove(arr, obj) {\n const i = arr.indexOf(obj);\n const found = i > -1;\n if (found) {\n arr.splice(i, 1);\n }\n return found;\n}\n\n/**\n * @param {Array|Uint8ClampedArray} arr1 The first array to compare.\n * @param {Array|Uint8ClampedArray} arr2 The second array to compare.\n * @return {boolean} Whether the two arrays are equal.\n */\nexport function equals(arr1, arr2) {\n const len1 = arr1.length;\n if (len1 !== arr2.length) {\n return false;\n }\n for (let i = 0; i < len1; i++) {\n if (arr1[i] !== arr2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Sort the passed array such that the relative order of equal elements is preserved.\n * See https://en.wikipedia.org/wiki/Sorting_algorithm#Stability for details.\n * @param {Array<*>} arr The array to sort (modifies original).\n * @param {!function(*, *): number} compareFnc Comparison function.\n * @api\n */\nexport function stableSort(arr, compareFnc) {\n const length = arr.length;\n const tmp = Array(arr.length);\n let i;\n for (i = 0; i < length; i++) {\n tmp[i] = {index: i, value: arr[i]};\n }\n tmp.sort(function (a, b) {\n return compareFnc(a.value, b.value) || a.index - b.index;\n });\n for (i = 0; i < arr.length; i++) {\n arr[i] = tmp[i].value;\n }\n}\n\n/**\n * @param {Array<*>} arr The array to test.\n * @param {Function} [func] Comparison function.\n * @param {boolean} [strict] Strictly sorted (default false).\n * @return {boolean} Return index.\n */\nexport function isSorted(arr, func, strict) {\n const compare = func || ascending;\n return arr.every(function (currentVal, index) {\n if (index === 0) {\n return true;\n }\n const res = compare(arr[index - 1], currentVal);\n return !(res > 0 || (strict && res === 0));\n });\n}\n","/**\n * @module ol/functions\n */\n\nimport {equals as arrayEquals} from './array.js';\n\n/**\n * Always returns true.\n * @return {boolean} true.\n */\nexport function TRUE() {\n return true;\n}\n\n/**\n * Always returns false.\n * @return {boolean} false.\n */\nexport function FALSE() {\n return false;\n}\n\n/**\n * A reusable function, used e.g. as a default for callbacks.\n *\n * @return {void} Nothing.\n */\nexport function VOID() {}\n\n/**\n * Wrap a function in another function that remembers the last return. If the\n * returned function is called twice in a row with the same arguments and the same\n * this object, it will return the value from the first call in the second call.\n *\n * @param {function(...any): ReturnType} fn The function to memoize.\n * @return {function(...any): ReturnType} The memoized function.\n * @template ReturnType\n */\nexport function memoizeOne(fn) {\n let called = false;\n\n /** @type {ReturnType} */\n let lastResult;\n\n /** @type {Array} */\n let lastArgs;\n\n let lastThis;\n\n return function () {\n const nextArgs = Array.prototype.slice.call(arguments);\n if (!called || this !== lastThis || !arrayEquals(nextArgs, lastArgs)) {\n called = true;\n lastThis = this;\n lastArgs = nextArgs;\n lastResult = fn.apply(this, arguments);\n }\n return lastResult;\n };\n}\n\n/**\n * @template T\n * @param {function(): (T | Promise)} getter A function that returns a value or a promise for a value.\n * @return {Promise} A promise for the value.\n */\nexport function toPromise(getter) {\n function promiseGetter() {\n let value;\n try {\n value = getter();\n } catch (err) {\n return Promise.reject(err);\n }\n if (value instanceof Promise) {\n return value;\n }\n return Promise.resolve(value);\n }\n return promiseGetter();\n}\n","/**\n * @module ol/obj\n */\n\n/**\n * Removes all properties from an object.\n * @param {Object} object The object to clear.\n */\nexport function clear(object) {\n for (const property in object) {\n delete object[property];\n }\n}\n\n/**\n * Determine if an object has any properties.\n * @param {Object} object The object to check.\n * @return {boolean} The object is empty.\n */\nexport function isEmpty(object) {\n let property;\n for (property in object) {\n return false;\n }\n return !property;\n}\n","/**\n * @module ol/events/Target\n */\nimport Disposable from '../Disposable.js';\nimport Event from './Event.js';\nimport {VOID} from '../functions.js';\nimport {clear} from '../obj.js';\n\n/**\n * @typedef {EventTarget|Target} EventTargetLike\n */\n\n/**\n * @classdesc\n * A simplified implementation of the W3C DOM Level 2 EventTarget interface.\n * See https://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget.\n *\n * There are two important simplifications compared to the specification:\n *\n * 1. The handling of `useCapture` in `addEventListener` and\n * `removeEventListener`. There is no real capture model.\n * 2. The handling of `stopPropagation` and `preventDefault` on `dispatchEvent`.\n * There is no event target hierarchy. When a listener calls\n * `stopPropagation` or `preventDefault` on an event object, it means that no\n * more listeners after this one will be called. Same as when the listener\n * returns false.\n */\nclass Target extends Disposable {\n /**\n * @param {*} [target] Default event target for dispatched events.\n */\n constructor(target) {\n super();\n\n /**\n * @private\n * @type {*}\n */\n this.eventTarget_ = target;\n\n /**\n * @private\n * @type {Object|null}\n */\n this.pendingRemovals_ = null;\n\n /**\n * @private\n * @type {Object|null}\n */\n this.dispatching_ = null;\n\n /**\n * @private\n * @type {Object>|null}\n */\n this.listeners_ = null;\n }\n\n /**\n * @param {string} type Type.\n * @param {import(\"../events.js\").Listener} listener Listener.\n */\n addEventListener(type, listener) {\n if (!type || !listener) {\n return;\n }\n const listeners = this.listeners_ || (this.listeners_ = {});\n const listenersForType = listeners[type] || (listeners[type] = []);\n if (!listenersForType.includes(listener)) {\n listenersForType.push(listener);\n }\n }\n\n /**\n * Dispatches an event and calls all listeners listening for events\n * of this type. The event parameter can either be a string or an\n * Object with a `type` property.\n *\n * @param {import(\"./Event.js\").default|string} event Event object.\n * @return {boolean|undefined} `false` if anyone called preventDefault on the\n * event object or if any of the listeners returned false.\n * @api\n */\n dispatchEvent(event) {\n const isString = typeof event === 'string';\n const type = isString ? event : event.type;\n const listeners = this.listeners_ && this.listeners_[type];\n if (!listeners) {\n return;\n }\n\n const evt = isString ? new Event(event) : /** @type {Event} */ (event);\n if (!evt.target) {\n evt.target = this.eventTarget_ || this;\n }\n const dispatching = this.dispatching_ || (this.dispatching_ = {});\n const pendingRemovals =\n this.pendingRemovals_ || (this.pendingRemovals_ = {});\n if (!(type in dispatching)) {\n dispatching[type] = 0;\n pendingRemovals[type] = 0;\n }\n ++dispatching[type];\n let propagate;\n for (let i = 0, ii = listeners.length; i < ii; ++i) {\n if ('handleEvent' in listeners[i]) {\n propagate = /** @type {import(\"../events.js\").ListenerObject} */ (\n listeners[i]\n ).handleEvent(evt);\n } else {\n propagate = /** @type {import(\"../events.js\").ListenerFunction} */ (\n listeners[i]\n ).call(this, evt);\n }\n if (propagate === false || evt.propagationStopped) {\n propagate = false;\n break;\n }\n }\n if (--dispatching[type] === 0) {\n let pr = pendingRemovals[type];\n delete pendingRemovals[type];\n while (pr--) {\n this.removeEventListener(type, VOID);\n }\n delete dispatching[type];\n }\n return propagate;\n }\n\n /**\n * Clean up.\n */\n disposeInternal() {\n this.listeners_ && clear(this.listeners_);\n }\n\n /**\n * Get the listeners for a specified event type. Listeners are returned in the\n * order that they will be called in.\n *\n * @param {string} type Type.\n * @return {Array|undefined} Listeners.\n */\n getListeners(type) {\n return (this.listeners_ && this.listeners_[type]) || undefined;\n }\n\n /**\n * @param {string} [type] Type. If not provided,\n * `true` will be returned if this event target has any listeners.\n * @return {boolean} Has listeners.\n */\n hasListener(type) {\n if (!this.listeners_) {\n return false;\n }\n return type\n ? type in this.listeners_\n : Object.keys(this.listeners_).length > 0;\n }\n\n /**\n * @param {string} type Type.\n * @param {import(\"../events.js\").Listener} listener Listener.\n */\n removeEventListener(type, listener) {\n if (!this.listeners_) {\n return;\n }\n const listeners = this.listeners_[type];\n if (!listeners) {\n return;\n }\n const index = listeners.indexOf(listener);\n if (index !== -1) {\n if (this.pendingRemovals_ && type in this.pendingRemovals_) {\n // make listener a no-op, and remove later in #dispatchEvent()\n listeners[index] = VOID;\n ++this.pendingRemovals_[type];\n } else {\n listeners.splice(index, 1);\n if (listeners.length === 0) {\n delete this.listeners_[type];\n }\n }\n }\n }\n}\n\nexport default Target;\n","/**\n * @module ol/events/EventType\n */\n\n/**\n * @enum {string}\n * @const\n */\nexport default {\n /**\n * Generic change event. Triggered when the revision counter is increased.\n * @event module:ol/events/Event~BaseEvent#change\n * @api\n */\n CHANGE: 'change',\n\n /**\n * Generic error event. Triggered when an error occurs.\n * @event module:ol/events/Event~BaseEvent#error\n * @api\n */\n ERROR: 'error',\n\n BLUR: 'blur',\n CLEAR: 'clear',\n CONTEXTMENU: 'contextmenu',\n CLICK: 'click',\n DBLCLICK: 'dblclick',\n DRAGENTER: 'dragenter',\n DRAGOVER: 'dragover',\n DROP: 'drop',\n FOCUS: 'focus',\n KEYDOWN: 'keydown',\n KEYPRESS: 'keypress',\n LOAD: 'load',\n RESIZE: 'resize',\n TOUCHMOVE: 'touchmove',\n WHEEL: 'wheel',\n};\n","/**\n * @module ol/events\n */\nimport {clear} from './obj.js';\n\n/**\n * Key to use with {@link module:ol/Observable.unByKey}.\n * @typedef {Object} EventsKey\n * @property {ListenerFunction} listener Listener.\n * @property {import(\"./events/Target.js\").EventTargetLike} target Target.\n * @property {string} type Type.\n * @api\n */\n\n/**\n * Listener function. This function is called with an event object as argument.\n * When the function returns `false`, event propagation will stop.\n *\n * @typedef {function((Event|import(\"./events/Event.js\").default)): (void|boolean)} ListenerFunction\n * @api\n */\n\n/**\n * @typedef {Object} ListenerObject\n * @property {ListenerFunction} handleEvent HandleEvent listener function.\n */\n\n/**\n * @typedef {ListenerFunction|ListenerObject} Listener\n */\n\n/**\n * Registers an event listener on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * This function efficiently binds a `listener` to a `this` object, and returns\n * a key for use with {@link module:ol/events.unlistenByKey}.\n *\n * @param {import(\"./events/Target.js\").EventTargetLike} target Event target.\n * @param {string} type Event type.\n * @param {ListenerFunction} listener Listener.\n * @param {Object} [thisArg] Object referenced by the `this` keyword in the\n * listener. Default is the `target`.\n * @param {boolean} [once] If true, add the listener as one-off listener.\n * @return {EventsKey} Unique key for the listener.\n */\nexport function listen(target, type, listener, thisArg, once) {\n if (thisArg && thisArg !== target) {\n listener = listener.bind(thisArg);\n }\n if (once) {\n const originalListener = listener;\n listener = function () {\n target.removeEventListener(type, listener);\n originalListener.apply(this, arguments);\n };\n }\n const eventsKey = {\n target: target,\n type: type,\n listener: listener,\n };\n target.addEventListener(type, listener);\n return eventsKey;\n}\n\n/**\n * Registers a one-off event listener on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * This function efficiently binds a `listener` as self-unregistering listener\n * to a `this` object, and returns a key for use with\n * {@link module:ol/events.unlistenByKey} in case the listener needs to be\n * unregistered before it is called.\n *\n * When {@link module:ol/events.listen} is called with the same arguments after this\n * function, the self-unregistering listener will be turned into a permanent\n * listener.\n *\n * @param {import(\"./events/Target.js\").EventTargetLike} target Event target.\n * @param {string} type Event type.\n * @param {ListenerFunction} listener Listener.\n * @param {Object} [thisArg] Object referenced by the `this` keyword in the\n * listener. Default is the `target`.\n * @return {EventsKey} Key for unlistenByKey.\n */\nexport function listenOnce(target, type, listener, thisArg) {\n return listen(target, type, listener, thisArg, true);\n}\n\n/**\n * Unregisters event listeners on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * The argument passed to this function is the key returned from\n * {@link module:ol/events.listen} or {@link module:ol/events.listenOnce}.\n *\n * @param {EventsKey} key The key.\n */\nexport function unlistenByKey(key) {\n if (key && key.target) {\n key.target.removeEventListener(key.type, key.listener);\n clear(key);\n }\n}\n","/**\n * @module ol/Observable\n */\nimport EventTarget from './events/Target.js';\nimport EventType from './events/EventType.js';\nimport {listen, listenOnce, unlistenByKey} from './events.js';\n\n/***\n * @template {string} Type\n * @template {Event|import(\"./events/Event.js\").default} EventClass\n * @template Return\n * @typedef {(type: Type, listener: (event: EventClass) => ?) => Return} OnSignature\n */\n\n/***\n * @template {string} Type\n * @template Return\n * @typedef {(type: Type[], listener: (event: Event|import(\"./events/Event\").default) => ?) => Return extends void ? void : Return[]} CombinedOnSignature\n */\n\n/**\n * @typedef {'change'|'error'} EventTypes\n */\n\n/***\n * @template Return\n * @typedef {OnSignature & CombinedOnSignature} ObservableOnSignature\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * An event target providing convenient methods for listener registration\n * and unregistration. A generic `change` event is always available through\n * {@link module:ol/Observable~Observable#changed}.\n *\n * @fires import(\"./events/Event.js\").default\n * @api\n */\nclass Observable extends EventTarget {\n constructor() {\n super();\n\n this.on =\n /** @type {ObservableOnSignature} */ (\n this.onInternal\n );\n\n this.once =\n /** @type {ObservableOnSignature} */ (\n this.onceInternal\n );\n\n this.un = /** @type {ObservableOnSignature} */ (this.unInternal);\n\n /**\n * @private\n * @type {number}\n */\n this.revision_ = 0;\n }\n\n /**\n * Increases the revision counter and dispatches a 'change' event.\n * @api\n */\n changed() {\n ++this.revision_;\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * Get the version number for this object. Each time the object is modified,\n * its version number will be incremented.\n * @return {number} Revision.\n * @api\n */\n getRevision() {\n return this.revision_;\n }\n\n /**\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener Listener.\n * @return {import(\"./events.js\").EventsKey|Array} Event key.\n * @protected\n */\n onInternal(type, listener) {\n if (Array.isArray(type)) {\n const len = type.length;\n const keys = new Array(len);\n for (let i = 0; i < len; ++i) {\n keys[i] = listen(this, type[i], listener);\n }\n return keys;\n }\n return listen(this, /** @type {string} */ (type), listener);\n }\n\n /**\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener Listener.\n * @return {import(\"./events.js\").EventsKey|Array} Event key.\n * @protected\n */\n onceInternal(type, listener) {\n let key;\n if (Array.isArray(type)) {\n const len = type.length;\n key = new Array(len);\n for (let i = 0; i < len; ++i) {\n key[i] = listenOnce(this, type[i], listener);\n }\n } else {\n key = listenOnce(this, /** @type {string} */ (type), listener);\n }\n /** @type {Object} */ (listener).ol_key = key;\n return key;\n }\n\n /**\n * Unlisten for a certain type of event.\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener Listener.\n * @protected\n */\n unInternal(type, listener) {\n const key = /** @type {Object} */ (listener).ol_key;\n if (key) {\n unByKey(key);\n } else if (Array.isArray(type)) {\n for (let i = 0, ii = type.length; i < ii; ++i) {\n this.removeEventListener(type[i], listener);\n }\n } else {\n this.removeEventListener(type, listener);\n }\n }\n}\n\n/**\n * Listen for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener The listener function.\n * @return {import(\"./events.js\").EventsKey|Array} Unique key for the listener. If\n * called with an array of event types as the first argument, the return\n * will be an array of keys.\n * @api\n */\nObservable.prototype.on;\n\n/**\n * Listen once for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener The listener function.\n * @return {import(\"./events.js\").EventsKey|Array} Unique key for the listener. If\n * called with an array of event types as the first argument, the return\n * will be an array of keys.\n * @api\n */\nObservable.prototype.once;\n\n/**\n * Unlisten for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener The listener function.\n * @api\n */\nObservable.prototype.un;\n\n/**\n * Removes an event listener using the key returned by `on()` or `once()`.\n * @param {import(\"./events.js\").EventsKey|Array} key The key returned by `on()`\n * or `once()` (or an array of keys).\n * @api\n */\nexport function unByKey(key) {\n if (Array.isArray(key)) {\n for (let i = 0, ii = key.length; i < ii; ++i) {\n unlistenByKey(key[i]);\n }\n } else {\n unlistenByKey(/** @type {import(\"./events.js\").EventsKey} */ (key));\n }\n}\n\nexport default Observable;\n","/**\n * @module ol/util\n */\n\n/**\n * @return {never} Any return.\n */\nexport function abstract() {\n throw new Error('Unimplemented abstract method.');\n}\n\n/**\n * Counter for getUid.\n * @type {number}\n * @private\n */\nlet uidCounter_ = 0;\n\n/**\n * Gets a unique ID for an object. This mutates the object so that further calls\n * with the same object as a parameter returns the same value. Unique IDs are generated\n * as a strictly increasing sequence. Adapted from goog.getUid.\n *\n * @param {Object} obj The object to get the unique ID for.\n * @return {string} The unique ID for the object.\n * @api\n */\nexport function getUid(obj) {\n return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));\n}\n\n/**\n * OpenLayers version.\n * @type {string}\n */\nexport const VERSION = '9.1.0';\n","/**\n * @module ol/Object\n */\nimport Event from './events/Event.js';\nimport ObjectEventType from './ObjectEventType.js';\nimport Observable from './Observable.js';\nimport {getUid} from './util.js';\nimport {isEmpty} from './obj.js';\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/Object~BaseObject} instances are instances of this type.\n */\nexport class ObjectEvent extends Event {\n /**\n * @param {string} type The event type.\n * @param {string} key The property name.\n * @param {*} oldValue The old value for `key`.\n */\n constructor(type, key, oldValue) {\n super(type);\n\n /**\n * The name of the property whose value is changing.\n * @type {string}\n * @api\n */\n this.key = key;\n\n /**\n * The old value. To get the new value use `e.target.get(e.key)` where\n * `e` is the event object.\n * @type {*}\n * @api\n */\n this.oldValue = oldValue;\n }\n}\n\n/***\n * @template Return\n * @typedef {import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature &\n * import(\"./Observable\").CombinedOnSignature} ObjectOnSignature\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Most non-trivial classes inherit from this.\n *\n * This extends {@link module:ol/Observable~Observable} with observable\n * properties, where each property is observable as well as the object as a\n * whole.\n *\n * Classes that inherit from this have pre-defined properties, to which you can\n * add your owns. The pre-defined properties are listed in this documentation as\n * 'Observable Properties', and have their own accessors; for example,\n * {@link module:ol/Map~Map} has a `target` property, accessed with\n * `getTarget()` and changed with `setTarget()`. Not all properties are however\n * settable. There are also general-purpose accessors `get()` and `set()`. For\n * example, `get('target')` is equivalent to `getTarget()`.\n *\n * The `set` accessors trigger a change event, and you can monitor this by\n * registering a listener. For example, {@link module:ol/View~View} has a\n * `center` property, so `view.on('change:center', function(evt) {...});` would\n * call the function whenever the value of the center property changes. Within\n * the function, `evt.target` would be the view, so `evt.target.getCenter()`\n * would return the new center.\n *\n * You can add your own observable properties with\n * `object.set('prop', 'value')`, and retrieve that with `object.get('prop')`.\n * You can listen for changes on that property value with\n * `object.on('change:prop', listener)`. You can get a list of all\n * properties with {@link module:ol/Object~BaseObject#getProperties}.\n *\n * Note that the observable properties are separate from standard JS properties.\n * You can, for example, give your map object a title with\n * `map.title='New title'` and with `map.set('title', 'Another title')`. The\n * first will be a `hasOwnProperty`; the second will appear in\n * `getProperties()`. Only the second is observable.\n *\n * Properties can be deleted by using the unset method. E.g.\n * object.unset('foo').\n *\n * @fires ObjectEvent\n * @api\n */\nclass BaseObject extends Observable {\n /**\n * @param {Object} [values] An object with key-value pairs.\n */\n constructor(values) {\n super();\n\n /***\n * @type {ObjectOnSignature}\n */\n this.on;\n\n /***\n * @type {ObjectOnSignature}\n */\n this.once;\n\n /***\n * @type {ObjectOnSignature}\n */\n this.un;\n\n // Call {@link module:ol/util.getUid} to ensure that the order of objects' ids is\n // the same as the order in which they were created. This also helps to\n // ensure that object properties are always added in the same order, which\n // helps many JavaScript engines generate faster code.\n getUid(this);\n\n /**\n * @private\n * @type {Object|null}\n */\n this.values_ = null;\n\n if (values !== undefined) {\n this.setProperties(values);\n }\n }\n\n /**\n * Gets a value.\n * @param {string} key Key name.\n * @return {*} Value.\n * @api\n */\n get(key) {\n let value;\n if (this.values_ && this.values_.hasOwnProperty(key)) {\n value = this.values_[key];\n }\n return value;\n }\n\n /**\n * Get a list of object property names.\n * @return {Array} List of property names.\n * @api\n */\n getKeys() {\n return (this.values_ && Object.keys(this.values_)) || [];\n }\n\n /**\n * Get an object of all property names and values.\n * @return {Object} Object.\n * @api\n */\n getProperties() {\n return (this.values_ && Object.assign({}, this.values_)) || {};\n }\n\n /**\n * Get an object of all property names and values.\n * @return {Object?} Object.\n */\n getPropertiesInternal() {\n return this.values_;\n }\n\n /**\n * @return {boolean} The object has properties.\n */\n hasProperties() {\n return !!this.values_;\n }\n\n /**\n * @param {string} key Key name.\n * @param {*} oldValue Old value.\n */\n notify(key, oldValue) {\n let eventType;\n eventType = `change:${key}`;\n if (this.hasListener(eventType)) {\n this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));\n }\n eventType = ObjectEventType.PROPERTYCHANGE;\n if (this.hasListener(eventType)) {\n this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));\n }\n }\n\n /**\n * @param {string} key Key name.\n * @param {import(\"./events.js\").Listener} listener Listener.\n */\n addChangeListener(key, listener) {\n this.addEventListener(`change:${key}`, listener);\n }\n\n /**\n * @param {string} key Key name.\n * @param {import(\"./events.js\").Listener} listener Listener.\n */\n removeChangeListener(key, listener) {\n this.removeEventListener(`change:${key}`, listener);\n }\n\n /**\n * Sets a value.\n * @param {string} key Key name.\n * @param {*} value Value.\n * @param {boolean} [silent] Update without triggering an event.\n * @api\n */\n set(key, value, silent) {\n const values = this.values_ || (this.values_ = {});\n if (silent) {\n values[key] = value;\n } else {\n const oldValue = values[key];\n values[key] = value;\n if (oldValue !== value) {\n this.notify(key, oldValue);\n }\n }\n }\n\n /**\n * Sets a collection of key-value pairs. Note that this changes any existing\n * properties and adds new ones (it does not remove any existing properties).\n * @param {Object} values Values.\n * @param {boolean} [silent] Update without triggering an event.\n * @api\n */\n setProperties(values, silent) {\n for (const key in values) {\n this.set(key, values[key], silent);\n }\n }\n\n /**\n * Apply any properties from another object without triggering events.\n * @param {BaseObject} source The source object.\n * @protected\n */\n applyProperties(source) {\n if (!source.values_) {\n return;\n }\n Object.assign(this.values_ || (this.values_ = {}), source.values_);\n }\n\n /**\n * Unsets a property.\n * @param {string} key Key name.\n * @param {boolean} [silent] Unset without triggering an event.\n * @api\n */\n unset(key, silent) {\n if (this.values_ && key in this.values_) {\n const oldValue = this.values_[key];\n delete this.values_[key];\n if (isEmpty(this.values_)) {\n this.values_ = null;\n }\n if (!silent) {\n this.notify(key, oldValue);\n }\n }\n }\n}\n\nexport default BaseObject;\n","/**\n * @module ol/CollectionEventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered when an item is added to the collection.\n * @event module:ol/Collection.CollectionEvent#add\n * @api\n */\n ADD: 'add',\n /**\n * Triggered when an item is removed from the collection.\n * @event module:ol/Collection.CollectionEvent#remove\n * @api\n */\n REMOVE: 'remove',\n};\n","/**\n * @module ol/Collection\n */\nimport BaseObject from './Object.js';\nimport CollectionEventType from './CollectionEventType.js';\nimport Event from './events/Event.js';\n\n/**\n * @enum {string}\n * @private\n */\nconst Property = {\n LENGTH: 'length',\n};\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/Collection~Collection} instances are instances of this\n * type.\n * @template T\n */\nexport class CollectionEvent extends Event {\n /**\n * @param {import(\"./CollectionEventType.js\").default} type Type.\n * @param {T} element Element.\n * @param {number} index The index of the added or removed element.\n */\n constructor(type, element, index) {\n super(type);\n\n /**\n * The element that is added to or removed from the collection.\n * @type {T}\n * @api\n */\n this.element = element;\n\n /**\n * The index of the added or removed element.\n * @type {number}\n * @api\n */\n this.index = index;\n }\n}\n\n/***\n * @template T\n * @template Return\n * @typedef {import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature<'add'|'remove', CollectionEvent, Return> &\n * import(\"./Observable\").CombinedOnSignature} CollectionOnSignature\n */\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [unique=false] Disallow the same item from being added to\n * the collection twice.\n */\n\n/**\n * @classdesc\n * An expanded version of standard JS Array, adding convenience methods for\n * manipulation. Add and remove changes to the Collection trigger a Collection\n * event. Note that this does not cover changes to the objects _within_ the\n * Collection; they trigger events on the appropriate object, not on the\n * Collection as a whole.\n *\n * @fires CollectionEvent\n *\n * @template T\n * @api\n */\nclass Collection extends BaseObject {\n /**\n * @param {Array} [array] Array.\n * @param {Options} [options] Collection options.\n */\n constructor(array, options) {\n super();\n\n /***\n * @type {CollectionOnSignature}\n */\n this.on;\n\n /***\n * @type {CollectionOnSignature}\n */\n this.once;\n\n /***\n * @type {CollectionOnSignature}\n */\n this.un;\n\n options = options || {};\n\n /**\n * @private\n * @type {boolean}\n */\n this.unique_ = !!options.unique;\n\n /**\n * @private\n * @type {!Array}\n */\n this.array_ = array ? array : [];\n\n if (this.unique_) {\n for (let i = 0, ii = this.array_.length; i < ii; ++i) {\n this.assertUnique_(this.array_[i], i);\n }\n }\n\n this.updateLength_();\n }\n\n /**\n * Remove all elements from the collection.\n * @api\n */\n clear() {\n while (this.getLength() > 0) {\n this.pop();\n }\n }\n\n /**\n * Add elements to the collection. This pushes each item in the provided array\n * to the end of the collection.\n * @param {!Array} arr Array.\n * @return {Collection} This collection.\n * @api\n */\n extend(arr) {\n for (let i = 0, ii = arr.length; i < ii; ++i) {\n this.push(arr[i]);\n }\n return this;\n }\n\n /**\n * Iterate over each element, calling the provided callback.\n * @param {function(T, number, Array): *} f The function to call\n * for every element. This function takes 3 arguments (the element, the\n * index and the array). The return value is ignored.\n * @api\n */\n forEach(f) {\n const array = this.array_;\n for (let i = 0, ii = array.length; i < ii; ++i) {\n f(array[i], i, array);\n }\n }\n\n /**\n * Get a reference to the underlying Array object. Warning: if the array\n * is mutated, no events will be dispatched by the collection, and the\n * collection's \"length\" property won't be in sync with the actual length\n * of the array.\n * @return {!Array} Array.\n * @api\n */\n getArray() {\n return this.array_;\n }\n\n /**\n * Get the element at the provided index.\n * @param {number} index Index.\n * @return {T} Element.\n * @api\n */\n item(index) {\n return this.array_[index];\n }\n\n /**\n * Get the length of this collection.\n * @return {number} The length of the array.\n * @observable\n * @api\n */\n getLength() {\n return this.get(Property.LENGTH);\n }\n\n /**\n * Insert an element at the provided index.\n * @param {number} index Index.\n * @param {T} elem Element.\n * @api\n */\n insertAt(index, elem) {\n if (index < 0 || index > this.getLength()) {\n throw new Error('Index out of bounds: ' + index);\n }\n if (this.unique_) {\n this.assertUnique_(elem);\n }\n this.array_.splice(index, 0, elem);\n this.updateLength_();\n this.dispatchEvent(\n new CollectionEvent(CollectionEventType.ADD, elem, index),\n );\n }\n\n /**\n * Remove the last element of the collection and return it.\n * Return `undefined` if the collection is empty.\n * @return {T|undefined} Element.\n * @api\n */\n pop() {\n return this.removeAt(this.getLength() - 1);\n }\n\n /**\n * Insert the provided element at the end of the collection.\n * @param {T} elem Element.\n * @return {number} New length of the collection.\n * @api\n */\n push(elem) {\n if (this.unique_) {\n this.assertUnique_(elem);\n }\n const n = this.getLength();\n this.insertAt(n, elem);\n return this.getLength();\n }\n\n /**\n * Remove the first occurrence of an element from the collection.\n * @param {T} elem Element.\n * @return {T|undefined} The removed element or undefined if none found.\n * @api\n */\n remove(elem) {\n const arr = this.array_;\n for (let i = 0, ii = arr.length; i < ii; ++i) {\n if (arr[i] === elem) {\n return this.removeAt(i);\n }\n }\n return undefined;\n }\n\n /**\n * Remove the element at the provided index and return it.\n * Return `undefined` if the collection does not contain this index.\n * @param {number} index Index.\n * @return {T|undefined} Value.\n * @api\n */\n removeAt(index) {\n if (index < 0 || index >= this.getLength()) {\n return undefined;\n }\n const prev = this.array_[index];\n this.array_.splice(index, 1);\n this.updateLength_();\n this.dispatchEvent(\n /** @type {CollectionEvent} */ (\n new CollectionEvent(CollectionEventType.REMOVE, prev, index)\n ),\n );\n return prev;\n }\n\n /**\n * Set the element at the provided index.\n * @param {number} index Index.\n * @param {T} elem Element.\n * @api\n */\n setAt(index, elem) {\n const n = this.getLength();\n if (index >= n) {\n this.insertAt(index, elem);\n return;\n }\n if (index < 0) {\n throw new Error('Index out of bounds: ' + index);\n }\n if (this.unique_) {\n this.assertUnique_(elem, index);\n }\n const prev = this.array_[index];\n this.array_[index] = elem;\n this.dispatchEvent(\n /** @type {CollectionEvent} */ (\n new CollectionEvent(CollectionEventType.REMOVE, prev, index)\n ),\n );\n this.dispatchEvent(\n /** @type {CollectionEvent} */ (\n new CollectionEvent(CollectionEventType.ADD, elem, index)\n ),\n );\n }\n\n /**\n * @private\n */\n updateLength_() {\n this.set(Property.LENGTH, this.array_.length);\n }\n\n /**\n * @private\n * @param {T} elem Element.\n * @param {number} [except] Optional index to ignore.\n */\n assertUnique_(elem, except) {\n for (let i = 0, ii = this.array_.length; i < ii; ++i) {\n if (this.array_[i] === elem && i !== except) {\n throw new Error('Duplicate item added to a unique collection');\n }\n }\n }\n}\n\nexport default Collection;\n","/**\n * @module ol/asserts\n */\n\n/**\n * @param {*} assertion Assertion we expected to be truthy.\n * @param {string} errorMessage Error message.\n */\nexport function assert(assertion, errorMessage) {\n if (!assertion) {\n throw new Error(errorMessage);\n }\n}\n","/**\n * @module ol/Feature\n */\nimport BaseObject from './Object.js';\nimport EventType from './events/EventType.js';\nimport {assert} from './asserts.js';\nimport {listen, unlistenByKey} from './events.js';\n\n/**\n * @typedef {typeof Feature|typeof import(\"./render/Feature.js\").default} FeatureClass\n */\n\n/**\n * @typedef {Feature|import(\"./render/Feature.js\").default} FeatureLike\n */\n\n/***\n * @template Return\n * @typedef {import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature &\n * import(\"./Observable\").CombinedOnSignature} FeatureOnSignature\n */\n\n/***\n * @template {import(\"./geom/Geometry.js\").default} [Geometry=import(\"./geom/Geometry.js\").default]\n * @typedef {Object & { geometry?: Geometry }} ObjectWithGeometry\n */\n\n/**\n * @classdesc\n * A vector object for geographic features with a geometry and other\n * attribute properties, similar to the features in vector file formats like\n * GeoJSON.\n *\n * Features can be styled individually with `setStyle`; otherwise they use the\n * style of their vector layer.\n *\n * Note that attribute properties are set as {@link module:ol/Object~BaseObject} properties on\n * the feature object, so they are observable, and have get/set accessors.\n *\n * Typically, a feature has a single geometry property. You can set the\n * geometry using the `setGeometry` method and get it with `getGeometry`.\n * It is possible to store more than one geometry on a feature using attribute\n * properties. By default, the geometry used for rendering is identified by\n * the property name `geometry`. If you want to use another geometry property\n * for rendering, use the `setGeometryName` method to change the attribute\n * property associated with the geometry for the feature. For example:\n *\n * ```js\n *\n * import Feature from 'ol/Feature.js';\n * import Polygon from 'ol/geom/Polygon.js';\n * import Point from 'ol/geom/Point.js';\n *\n * const feature = new Feature({\n * geometry: new Polygon(polyCoords),\n * labelPoint: new Point(labelCoords),\n * name: 'My Polygon',\n * });\n *\n * // get the polygon geometry\n * const poly = feature.getGeometry();\n *\n * // Render the feature as a point using the coordinates from labelPoint\n * feature.setGeometryName('labelPoint');\n *\n * // get the point geometry\n * const point = feature.getGeometry();\n * ```\n *\n * @api\n * @template {import(\"./geom/Geometry.js\").default} [Geometry=import(\"./geom/Geometry.js\").default]\n */\nclass Feature extends BaseObject {\n /**\n * @param {Geometry|ObjectWithGeometry} [geometryOrProperties]\n * You may pass a Geometry object directly, or an object literal containing\n * properties. If you pass an object literal, you may include a Geometry\n * associated with a `geometry` key.\n */\n constructor(geometryOrProperties) {\n super();\n\n /***\n * @type {FeatureOnSignature}\n */\n this.on;\n\n /***\n * @type {FeatureOnSignature}\n */\n this.once;\n\n /***\n * @type {FeatureOnSignature}\n */\n this.un;\n\n /**\n * @private\n * @type {number|string|undefined}\n */\n this.id_ = undefined;\n\n /**\n * @type {string}\n * @private\n */\n this.geometryName_ = 'geometry';\n\n /**\n * User provided style.\n * @private\n * @type {import(\"./style/Style.js\").StyleLike}\n */\n this.style_ = null;\n\n /**\n * @private\n * @type {import(\"./style/Style.js\").StyleFunction|undefined}\n */\n this.styleFunction_ = undefined;\n\n /**\n * @private\n * @type {?import(\"./events.js\").EventsKey}\n */\n this.geometryChangeKey_ = null;\n\n this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);\n\n if (geometryOrProperties) {\n if (\n typeof (\n /** @type {?} */ (geometryOrProperties).getSimplifiedGeometry\n ) === 'function'\n ) {\n const geometry = /** @type {Geometry} */ (geometryOrProperties);\n this.setGeometry(geometry);\n } else {\n /** @type {Object} */\n const properties = geometryOrProperties;\n this.setProperties(properties);\n }\n }\n }\n\n /**\n * Clone this feature. If the original feature has a geometry it\n * is also cloned. The feature id is not set in the clone.\n * @return {Feature} The clone.\n * @api\n */\n clone() {\n const clone = /** @type {Feature} */ (\n new Feature(this.hasProperties() ? this.getProperties() : null)\n );\n clone.setGeometryName(this.getGeometryName());\n const geometry = this.getGeometry();\n if (geometry) {\n clone.setGeometry(/** @type {Geometry} */ (geometry.clone()));\n }\n const style = this.getStyle();\n if (style) {\n clone.setStyle(style);\n }\n return clone;\n }\n\n /**\n * Get the feature's default geometry. A feature may have any number of named\n * geometries. The \"default\" geometry (the one that is rendered by default) is\n * set when calling {@link module:ol/Feature~Feature#setGeometry}.\n * @return {Geometry|undefined} The default geometry for the feature.\n * @api\n * @observable\n */\n getGeometry() {\n return /** @type {Geometry|undefined} */ (this.get(this.geometryName_));\n }\n\n /**\n * Get the feature identifier. This is a stable identifier for the feature and\n * is either set when reading data from a remote source or set explicitly by\n * calling {@link module:ol/Feature~Feature#setId}.\n * @return {number|string|undefined} Id.\n * @api\n */\n getId() {\n return this.id_;\n }\n\n /**\n * Get the name of the feature's default geometry. By default, the default\n * geometry is named `geometry`.\n * @return {string} Get the property name associated with the default geometry\n * for this feature.\n * @api\n */\n getGeometryName() {\n return this.geometryName_;\n }\n\n /**\n * Get the feature's style. Will return what was provided to the\n * {@link module:ol/Feature~Feature#setStyle} method.\n * @return {import(\"./style/Style.js\").StyleLike|undefined} The feature style.\n * @api\n */\n getStyle() {\n return this.style_;\n }\n\n /**\n * Get the feature's style function.\n * @return {import(\"./style/Style.js\").StyleFunction|undefined} Return a function\n * representing the current style of this feature.\n * @api\n */\n getStyleFunction() {\n return this.styleFunction_;\n }\n\n /**\n * @private\n */\n handleGeometryChange_() {\n this.changed();\n }\n\n /**\n * @private\n */\n handleGeometryChanged_() {\n if (this.geometryChangeKey_) {\n unlistenByKey(this.geometryChangeKey_);\n this.geometryChangeKey_ = null;\n }\n const geometry = this.getGeometry();\n if (geometry) {\n this.geometryChangeKey_ = listen(\n geometry,\n EventType.CHANGE,\n this.handleGeometryChange_,\n this,\n );\n }\n this.changed();\n }\n\n /**\n * Set the default geometry for the feature. This will update the property\n * with the name returned by {@link module:ol/Feature~Feature#getGeometryName}.\n * @param {Geometry|undefined} geometry The new geometry.\n * @api\n * @observable\n */\n setGeometry(geometry) {\n this.set(this.geometryName_, geometry);\n }\n\n /**\n * Set the style for the feature to override the layer style. This can be a\n * single style object, an array of styles, or a function that takes a\n * resolution and returns an array of styles. To unset the feature style, call\n * `setStyle()` without arguments or a falsey value.\n * @param {import(\"./style/Style.js\").StyleLike} [style] Style for this feature.\n * @api\n * @fires module:ol/events/Event~BaseEvent#event:change\n */\n setStyle(style) {\n this.style_ = style;\n this.styleFunction_ = !style ? undefined : createStyleFunction(style);\n this.changed();\n }\n\n /**\n * Set the feature id. The feature id is considered stable and may be used when\n * requesting features or comparing identifiers returned from a remote source.\n * The feature id can be used with the\n * {@link module:ol/source/Vector~VectorSource#getFeatureById} method.\n * @param {number|string|undefined} id The feature id.\n * @api\n * @fires module:ol/events/Event~BaseEvent#event:change\n */\n setId(id) {\n this.id_ = id;\n this.changed();\n }\n\n /**\n * Set the property name to be used when getting the feature's default geometry.\n * When calling {@link module:ol/Feature~Feature#getGeometry}, the value of the property with\n * this name will be returned.\n * @param {string} name The property name of the default geometry.\n * @api\n */\n setGeometryName(name) {\n this.removeChangeListener(this.geometryName_, this.handleGeometryChanged_);\n this.geometryName_ = name;\n this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);\n this.handleGeometryChanged_();\n }\n}\n\n/**\n * Convert the provided object into a feature style function. Functions passed\n * through unchanged. Arrays of Style or single style objects wrapped\n * in a new feature style function.\n * @param {!import(\"./style/Style.js\").StyleFunction|!Array|!import(\"./style/Style.js\").default} obj\n * A feature style function, a single style, or an array of styles.\n * @return {import(\"./style/Style.js\").StyleFunction} A style function.\n */\nexport function createStyleFunction(obj) {\n if (typeof obj === 'function') {\n return obj;\n }\n /**\n * @type {Array}\n */\n let styles;\n if (Array.isArray(obj)) {\n styles = obj;\n } else {\n assert(\n typeof (/** @type {?} */ (obj).getZIndex) === 'function',\n 'Expected an `ol/style/Style` or an array of `ol/style/Style.js`',\n );\n const style = /** @type {import(\"./style/Style.js\").default} */ (obj);\n styles = [style];\n }\n return function () {\n return styles;\n };\n}\nexport default Feature;\n","/**\n * @module ol/transform\n */\nimport {assert} from './asserts.js';\n\n/**\n * An array representing an affine 2d transformation for use with\n * {@link module:ol/transform} functions. The array has 6 elements.\n * @typedef {!Array} Transform\n * @api\n */\n\n/**\n * Collection of affine 2d transformation functions. The functions work on an\n * array of 6 elements. The element order is compatible with the [SVGMatrix\n * interface](https://developer.mozilla.org/en-US/docs/Web/API/SVGMatrix) and is\n * a subset (elements a to f) of a 3×3 matrix:\n * ```\n * [ a c e ]\n * [ b d f ]\n * [ 0 0 1 ]\n * ```\n */\n\n/**\n * @private\n * @type {Transform}\n */\nconst tmp_ = new Array(6);\n\n/**\n * Create an identity transform.\n * @return {!Transform} Identity transform.\n */\nexport function create() {\n return [1, 0, 0, 1, 0, 0];\n}\n\n/**\n * Resets the given transform to an identity transform.\n * @param {!Transform} transform Transform.\n * @return {!Transform} Transform.\n */\nexport function reset(transform) {\n return set(transform, 1, 0, 0, 1, 0, 0);\n}\n\n/**\n * Multiply the underlying matrices of two transforms and return the result in\n * the first transform.\n * @param {!Transform} transform1 Transform parameters of matrix 1.\n * @param {!Transform} transform2 Transform parameters of matrix 2.\n * @return {!Transform} transform1 multiplied with transform2.\n */\nexport function multiply(transform1, transform2) {\n const a1 = transform1[0];\n const b1 = transform1[1];\n const c1 = transform1[2];\n const d1 = transform1[3];\n const e1 = transform1[4];\n const f1 = transform1[5];\n const a2 = transform2[0];\n const b2 = transform2[1];\n const c2 = transform2[2];\n const d2 = transform2[3];\n const e2 = transform2[4];\n const f2 = transform2[5];\n\n transform1[0] = a1 * a2 + c1 * b2;\n transform1[1] = b1 * a2 + d1 * b2;\n transform1[2] = a1 * c2 + c1 * d2;\n transform1[3] = b1 * c2 + d1 * d2;\n transform1[4] = a1 * e2 + c1 * f2 + e1;\n transform1[5] = b1 * e2 + d1 * f2 + f1;\n\n return transform1;\n}\n\n/**\n * Set the transform components a-f on a given transform.\n * @param {!Transform} transform Transform.\n * @param {number} a The a component of the transform.\n * @param {number} b The b component of the transform.\n * @param {number} c The c component of the transform.\n * @param {number} d The d component of the transform.\n * @param {number} e The e component of the transform.\n * @param {number} f The f component of the transform.\n * @return {!Transform} Matrix with transform applied.\n */\nexport function set(transform, a, b, c, d, e, f) {\n transform[0] = a;\n transform[1] = b;\n transform[2] = c;\n transform[3] = d;\n transform[4] = e;\n transform[5] = f;\n return transform;\n}\n\n/**\n * Set transform on one matrix from another matrix.\n * @param {!Transform} transform1 Matrix to set transform to.\n * @param {!Transform} transform2 Matrix to set transform from.\n * @return {!Transform} transform1 with transform from transform2 applied.\n */\nexport function setFromArray(transform1, transform2) {\n transform1[0] = transform2[0];\n transform1[1] = transform2[1];\n transform1[2] = transform2[2];\n transform1[3] = transform2[3];\n transform1[4] = transform2[4];\n transform1[5] = transform2[5];\n return transform1;\n}\n\n/**\n * Transforms the given coordinate with the given transform returning the\n * resulting, transformed coordinate. The coordinate will be modified in-place.\n *\n * @param {Transform} transform The transformation.\n * @param {import(\"./coordinate.js\").Coordinate|import(\"./pixel.js\").Pixel} coordinate The coordinate to transform.\n * @return {import(\"./coordinate.js\").Coordinate|import(\"./pixel.js\").Pixel} return coordinate so that operations can be\n * chained together.\n */\nexport function apply(transform, coordinate) {\n const x = coordinate[0];\n const y = coordinate[1];\n coordinate[0] = transform[0] * x + transform[2] * y + transform[4];\n coordinate[1] = transform[1] * x + transform[3] * y + transform[5];\n return coordinate;\n}\n\n/**\n * Applies rotation to the given transform.\n * @param {!Transform} transform Transform.\n * @param {number} angle Angle in radians.\n * @return {!Transform} The rotated transform.\n */\nexport function rotate(transform, angle) {\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n return multiply(transform, set(tmp_, cos, sin, -sin, cos, 0, 0));\n}\n\n/**\n * Applies scale to a given transform.\n * @param {!Transform} transform Transform.\n * @param {number} x Scale factor x.\n * @param {number} y Scale factor y.\n * @return {!Transform} The scaled transform.\n */\nexport function scale(transform, x, y) {\n return multiply(transform, set(tmp_, x, 0, 0, y, 0, 0));\n}\n\n/**\n * Creates a scale transform.\n * @param {!Transform} target Transform to overwrite.\n * @param {number} x Scale factor x.\n * @param {number} y Scale factor y.\n * @return {!Transform} The scale transform.\n */\nexport function makeScale(target, x, y) {\n return set(target, x, 0, 0, y, 0, 0);\n}\n\n/**\n * Applies translation to the given transform.\n * @param {!Transform} transform Transform.\n * @param {number} dx Translation x.\n * @param {number} dy Translation y.\n * @return {!Transform} The translated transform.\n */\nexport function translate(transform, dx, dy) {\n return multiply(transform, set(tmp_, 1, 0, 0, 1, dx, dy));\n}\n\n/**\n * Creates a composite transform given an initial translation, scale, rotation, and\n * final translation (in that order only, not commutative).\n * @param {!Transform} transform The transform (will be modified in place).\n * @param {number} dx1 Initial translation x.\n * @param {number} dy1 Initial translation y.\n * @param {number} sx Scale factor x.\n * @param {number} sy Scale factor y.\n * @param {number} angle Rotation (in counter-clockwise radians).\n * @param {number} dx2 Final translation x.\n * @param {number} dy2 Final translation y.\n * @return {!Transform} The composite transform.\n */\nexport function compose(transform, dx1, dy1, sx, sy, angle, dx2, dy2) {\n const sin = Math.sin(angle);\n const cos = Math.cos(angle);\n transform[0] = sx * cos;\n transform[1] = sy * sin;\n transform[2] = -sx * sin;\n transform[3] = sy * cos;\n transform[4] = dx2 * sx * cos - dy2 * sx * sin + dx1;\n transform[5] = dx2 * sy * sin + dy2 * sy * cos + dy1;\n return transform;\n}\n\n/**\n * Creates a composite transform given an initial translation, scale, rotation, and\n * final translation (in that order only, not commutative). The resulting transform\n * string can be applied as `transform` property of an HTMLElement's style.\n * @param {number} dx1 Initial translation x.\n * @param {number} dy1 Initial translation y.\n * @param {number} sx Scale factor x.\n * @param {number} sy Scale factor y.\n * @param {number} angle Rotation (in counter-clockwise radians).\n * @param {number} dx2 Final translation x.\n * @param {number} dy2 Final translation y.\n * @return {string} The composite css transform.\n * @api\n */\nexport function composeCssTransform(dx1, dy1, sx, sy, angle, dx2, dy2) {\n return toString(compose(create(), dx1, dy1, sx, sy, angle, dx2, dy2));\n}\n\n/**\n * Invert the given transform.\n * @param {!Transform} source The source transform to invert.\n * @return {!Transform} The inverted (source) transform.\n */\nexport function invert(source) {\n return makeInverse(source, source);\n}\n\n/**\n * Invert the given transform.\n * @param {!Transform} target Transform to be set as the inverse of\n * the source transform.\n * @param {!Transform} source The source transform to invert.\n * @return {!Transform} The inverted (target) transform.\n */\nexport function makeInverse(target, source) {\n const det = determinant(source);\n assert(det !== 0, 'Transformation matrix cannot be inverted');\n\n const a = source[0];\n const b = source[1];\n const c = source[2];\n const d = source[3];\n const e = source[4];\n const f = source[5];\n\n target[0] = d / det;\n target[1] = -b / det;\n target[2] = -c / det;\n target[3] = a / det;\n target[4] = (c * f - d * e) / det;\n target[5] = -(a * f - b * e) / det;\n\n return target;\n}\n\n/**\n * Returns the determinant of the given matrix.\n * @param {!Transform} mat Matrix.\n * @return {number} Determinant.\n */\nexport function determinant(mat) {\n return mat[0] * mat[3] - mat[1] * mat[2];\n}\n\n/**\n * @type {Array}\n */\nconst matrixPrecision = [1e6, 1e6, 1e6, 1e6, 2, 2];\n\n/**\n * A rounded string version of the transform. This can be used\n * for CSS transforms.\n * @param {!Transform} mat Matrix.\n * @return {string} The transform as a string.\n */\nexport function toString(mat) {\n const transformString =\n 'matrix(' +\n mat\n .map(\n (value, i) =>\n Math.round(value * matrixPrecision[i]) / matrixPrecision[i],\n )\n .join(', ') +\n ')';\n return transformString;\n}\n","/**\n * @module ol/extent/Relationship\n */\n\n/**\n * Relationship to an extent.\n * @enum {number}\n */\nexport default {\n UNKNOWN: 0,\n INTERSECTING: 1,\n ABOVE: 2,\n RIGHT: 4,\n BELOW: 8,\n LEFT: 16,\n};\n","/**\n * @module ol/extent\n */\nimport Relationship from './extent/Relationship.js';\n\n/**\n * An array of numbers representing an extent: `[minx, miny, maxx, maxy]`.\n * @typedef {Array} Extent\n * @api\n */\n\n/**\n * Extent corner.\n * @typedef {'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'} Corner\n */\n\n/**\n * Build an extent that includes all given coordinates.\n *\n * @param {Array} coordinates Coordinates.\n * @return {Extent} Bounding extent.\n * @api\n */\nexport function boundingExtent(coordinates) {\n const extent = createEmpty();\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n extendCoordinate(extent, coordinates[i]);\n }\n return extent;\n}\n\n/**\n * @param {Array} xs Xs.\n * @param {Array} ys Ys.\n * @param {Extent} [dest] Destination extent.\n * @private\n * @return {Extent} Extent.\n */\nfunction _boundingExtentXYs(xs, ys, dest) {\n const minX = Math.min.apply(null, xs);\n const minY = Math.min.apply(null, ys);\n const maxX = Math.max.apply(null, xs);\n const maxY = Math.max.apply(null, ys);\n return createOrUpdate(minX, minY, maxX, maxY, dest);\n}\n\n/**\n * Return extent increased by the provided value.\n * @param {Extent} extent Extent.\n * @param {number} value The amount by which the extent should be buffered.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n * @api\n */\nexport function buffer(extent, value, dest) {\n if (dest) {\n dest[0] = extent[0] - value;\n dest[1] = extent[1] - value;\n dest[2] = extent[2] + value;\n dest[3] = extent[3] + value;\n return dest;\n }\n return [\n extent[0] - value,\n extent[1] - value,\n extent[2] + value,\n extent[3] + value,\n ];\n}\n\n/**\n * Creates a clone of an extent.\n *\n * @param {Extent} extent Extent to clone.\n * @param {Extent} [dest] Extent.\n * @return {Extent} The clone.\n */\nexport function clone(extent, dest) {\n if (dest) {\n dest[0] = extent[0];\n dest[1] = extent[1];\n dest[2] = extent[2];\n dest[3] = extent[3];\n return dest;\n }\n return extent.slice();\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {number} Closest squared distance.\n */\nexport function closestSquaredDistanceXY(extent, x, y) {\n let dx, dy;\n if (x < extent[0]) {\n dx = extent[0] - x;\n } else if (extent[2] < x) {\n dx = x - extent[2];\n } else {\n dx = 0;\n }\n if (y < extent[1]) {\n dy = extent[1] - y;\n } else if (extent[3] < y) {\n dy = y - extent[3];\n } else {\n dy = 0;\n }\n return dx * dx + dy * dy;\n}\n\n/**\n * Check if the passed coordinate is contained or on the edge of the extent.\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} The coordinate is contained in the extent.\n * @api\n */\nexport function containsCoordinate(extent, coordinate) {\n return containsXY(extent, coordinate[0], coordinate[1]);\n}\n\n/**\n * Check if one extent contains another.\n *\n * An extent is deemed contained if it lies completely within the other extent,\n * including if they share one or more edges.\n *\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {boolean} The second extent is contained by or on the edge of the\n * first.\n * @api\n */\nexport function containsExtent(extent1, extent2) {\n return (\n extent1[0] <= extent2[0] &&\n extent2[2] <= extent1[2] &&\n extent1[1] <= extent2[1] &&\n extent2[3] <= extent1[3]\n );\n}\n\n/**\n * Check if the passed coordinate is contained or on the edge of the extent.\n *\n * @param {Extent} extent Extent.\n * @param {number} x X coordinate.\n * @param {number} y Y coordinate.\n * @return {boolean} The x, y values are contained in the extent.\n * @api\n */\nexport function containsXY(extent, x, y) {\n return extent[0] <= x && x <= extent[2] && extent[1] <= y && y <= extent[3];\n}\n\n/**\n * Get the relationship between a coordinate and extent.\n * @param {Extent} extent The extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate The coordinate.\n * @return {import(\"./extent/Relationship.js\").default} The relationship (bitwise compare with\n * import(\"./extent/Relationship.js\").Relationship).\n */\nexport function coordinateRelationship(extent, coordinate) {\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const x = coordinate[0];\n const y = coordinate[1];\n let relationship = Relationship.UNKNOWN;\n if (x < minX) {\n relationship = relationship | Relationship.LEFT;\n } else if (x > maxX) {\n relationship = relationship | Relationship.RIGHT;\n }\n if (y < minY) {\n relationship = relationship | Relationship.BELOW;\n } else if (y > maxY) {\n relationship = relationship | Relationship.ABOVE;\n }\n if (relationship === Relationship.UNKNOWN) {\n relationship = Relationship.INTERSECTING;\n }\n return relationship;\n}\n\n/**\n * Create an empty extent.\n * @return {Extent} Empty extent.\n * @api\n */\nexport function createEmpty() {\n return [Infinity, Infinity, -Infinity, -Infinity];\n}\n\n/**\n * Create a new extent or update the provided extent.\n * @param {number} minX Minimum X.\n * @param {number} minY Minimum Y.\n * @param {number} maxX Maximum X.\n * @param {number} maxY Maximum Y.\n * @param {Extent} [dest] Destination extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdate(minX, minY, maxX, maxY, dest) {\n if (dest) {\n dest[0] = minX;\n dest[1] = minY;\n dest[2] = maxX;\n dest[3] = maxY;\n return dest;\n }\n return [minX, minY, maxX, maxY];\n}\n\n/**\n * Create a new empty extent or make the provided one empty.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateEmpty(dest) {\n return createOrUpdate(Infinity, Infinity, -Infinity, -Infinity, dest);\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromCoordinate(coordinate, dest) {\n const x = coordinate[0];\n const y = coordinate[1];\n return createOrUpdate(x, y, x, y, dest);\n}\n\n/**\n * @param {Array} coordinates Coordinates.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromCoordinates(coordinates, dest) {\n const extent = createOrUpdateEmpty(dest);\n return extendCoordinates(extent, coordinates);\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromFlatCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n dest,\n) {\n const extent = createOrUpdateEmpty(dest);\n return extendFlatCoordinates(extent, flatCoordinates, offset, end, stride);\n}\n\n/**\n * @param {Array>} rings Rings.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromRings(rings, dest) {\n const extent = createOrUpdateEmpty(dest);\n return extendRings(extent, rings);\n}\n\n/**\n * Determine if two extents are equivalent.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {boolean} The two extents are equivalent.\n * @api\n */\nexport function equals(extent1, extent2) {\n return (\n extent1[0] == extent2[0] &&\n extent1[2] == extent2[2] &&\n extent1[1] == extent2[1] &&\n extent1[3] == extent2[3]\n );\n}\n\n/**\n * Determine if two extents are approximately equivalent.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @param {number} tolerance Tolerance in extent coordinate units.\n * @return {boolean} The two extents differ by less than the tolerance.\n */\nexport function approximatelyEquals(extent1, extent2, tolerance) {\n return (\n Math.abs(extent1[0] - extent2[0]) < tolerance &&\n Math.abs(extent1[2] - extent2[2]) < tolerance &&\n Math.abs(extent1[1] - extent2[1]) < tolerance &&\n Math.abs(extent1[3] - extent2[3]) < tolerance\n );\n}\n\n/**\n * Modify an extent to include another extent.\n * @param {Extent} extent1 The extent to be modified.\n * @param {Extent} extent2 The extent that will be included in the first.\n * @return {Extent} A reference to the first (extended) extent.\n * @api\n */\nexport function extend(extent1, extent2) {\n if (extent2[0] < extent1[0]) {\n extent1[0] = extent2[0];\n }\n if (extent2[2] > extent1[2]) {\n extent1[2] = extent2[2];\n }\n if (extent2[1] < extent1[1]) {\n extent1[1] = extent2[1];\n }\n if (extent2[3] > extent1[3]) {\n extent1[3] = extent2[3];\n }\n return extent1;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n */\nexport function extendCoordinate(extent, coordinate) {\n if (coordinate[0] < extent[0]) {\n extent[0] = coordinate[0];\n }\n if (coordinate[0] > extent[2]) {\n extent[2] = coordinate[0];\n }\n if (coordinate[1] < extent[1]) {\n extent[1] = coordinate[1];\n }\n if (coordinate[1] > extent[3]) {\n extent[3] = coordinate[1];\n }\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array} coordinates Coordinates.\n * @return {Extent} Extent.\n */\nexport function extendCoordinates(extent, coordinates) {\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n extendCoordinate(extent, coordinates[i]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {Extent} Extent.\n */\nexport function extendFlatCoordinates(\n extent,\n flatCoordinates,\n offset,\n end,\n stride,\n) {\n for (; offset < end; offset += stride) {\n extendXY(extent, flatCoordinates[offset], flatCoordinates[offset + 1]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array>} rings Rings.\n * @return {Extent} Extent.\n */\nexport function extendRings(extent, rings) {\n for (let i = 0, ii = rings.length; i < ii; ++i) {\n extendCoordinates(extent, rings[i]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} x X.\n * @param {number} y Y.\n */\nexport function extendXY(extent, x, y) {\n extent[0] = Math.min(extent[0], x);\n extent[1] = Math.min(extent[1], y);\n extent[2] = Math.max(extent[2], x);\n extent[3] = Math.max(extent[3], y);\n}\n\n/**\n * This function calls `callback` for each corner of the extent. If the\n * callback returns a truthy value the function returns that value\n * immediately. Otherwise the function returns `false`.\n * @param {Extent} extent Extent.\n * @param {function(import(\"./coordinate.js\").Coordinate): S} callback Callback.\n * @return {S|boolean} Value.\n * @template S\n */\nexport function forEachCorner(extent, callback) {\n let val;\n val = callback(getBottomLeft(extent));\n if (val) {\n return val;\n }\n val = callback(getBottomRight(extent));\n if (val) {\n return val;\n }\n val = callback(getTopRight(extent));\n if (val) {\n return val;\n }\n val = callback(getTopLeft(extent));\n if (val) {\n return val;\n }\n return false;\n}\n\n/**\n * Get the size of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Area.\n * @api\n */\nexport function getArea(extent) {\n let area = 0;\n if (!isEmpty(extent)) {\n area = getWidth(extent) * getHeight(extent);\n }\n return area;\n}\n\n/**\n * Get the bottom left coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Bottom left coordinate.\n * @api\n */\nexport function getBottomLeft(extent) {\n return [extent[0], extent[1]];\n}\n\n/**\n * Get the bottom right coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Bottom right coordinate.\n * @api\n */\nexport function getBottomRight(extent) {\n return [extent[2], extent[1]];\n}\n\n/**\n * Get the center coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Center.\n * @api\n */\nexport function getCenter(extent) {\n return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];\n}\n\n/**\n * Get a corner coordinate of an extent.\n * @param {Extent} extent Extent.\n * @param {Corner} corner Corner.\n * @return {import(\"./coordinate.js\").Coordinate} Corner coordinate.\n */\nexport function getCorner(extent, corner) {\n let coordinate;\n if (corner === 'bottom-left') {\n coordinate = getBottomLeft(extent);\n } else if (corner === 'bottom-right') {\n coordinate = getBottomRight(extent);\n } else if (corner === 'top-left') {\n coordinate = getTopLeft(extent);\n } else if (corner === 'top-right') {\n coordinate = getTopRight(extent);\n } else {\n throw new Error('Invalid corner');\n }\n return coordinate;\n}\n\n/**\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {number} Enlarged area.\n */\nexport function getEnlargedArea(extent1, extent2) {\n const minX = Math.min(extent1[0], extent2[0]);\n const minY = Math.min(extent1[1], extent2[1]);\n const maxX = Math.max(extent1[2], extent2[2]);\n const maxY = Math.max(extent1[3], extent2[3]);\n return (maxX - minX) * (maxY - minY);\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} center Center.\n * @param {number} resolution Resolution.\n * @param {number} rotation Rotation.\n * @param {import(\"./size.js\").Size} size Size.\n * @param {Extent} [dest] Destination extent.\n * @return {Extent} Extent.\n */\nexport function getForViewAndSize(center, resolution, rotation, size, dest) {\n const [x0, y0, x1, y1, x2, y2, x3, y3] = getRotatedViewport(\n center,\n resolution,\n rotation,\n size,\n );\n return createOrUpdate(\n Math.min(x0, x1, x2, x3),\n Math.min(y0, y1, y2, y3),\n Math.max(x0, x1, x2, x3),\n Math.max(y0, y1, y2, y3),\n dest,\n );\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} center Center.\n * @param {number} resolution Resolution.\n * @param {number} rotation Rotation.\n * @param {import(\"./size.js\").Size} size Size.\n * @return {Array} Linear ring representing the viewport.\n */\nexport function getRotatedViewport(center, resolution, rotation, size) {\n const dx = (resolution * size[0]) / 2;\n const dy = (resolution * size[1]) / 2;\n const cosRotation = Math.cos(rotation);\n const sinRotation = Math.sin(rotation);\n const xCos = dx * cosRotation;\n const xSin = dx * sinRotation;\n const yCos = dy * cosRotation;\n const ySin = dy * sinRotation;\n const x = center[0];\n const y = center[1];\n return [\n x - xCos + ySin,\n y - xSin - yCos,\n x - xCos - ySin,\n y - xSin + yCos,\n x + xCos - ySin,\n y + xSin + yCos,\n x + xCos + ySin,\n y + xSin - yCos,\n x - xCos + ySin,\n y - xSin - yCos,\n ];\n}\n\n/**\n * Get the height of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Height.\n * @api\n */\nexport function getHeight(extent) {\n return extent[3] - extent[1];\n}\n\n/**\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {number} Intersection area.\n */\nexport function getIntersectionArea(extent1, extent2) {\n const intersection = getIntersection(extent1, extent2);\n return getArea(intersection);\n}\n\n/**\n * Get the intersection of two extents.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @param {Extent} [dest] Optional extent to populate with intersection.\n * @return {Extent} Intersecting extent.\n * @api\n */\nexport function getIntersection(extent1, extent2, dest) {\n const intersection = dest ? dest : createEmpty();\n if (intersects(extent1, extent2)) {\n if (extent1[0] > extent2[0]) {\n intersection[0] = extent1[0];\n } else {\n intersection[0] = extent2[0];\n }\n if (extent1[1] > extent2[1]) {\n intersection[1] = extent1[1];\n } else {\n intersection[1] = extent2[1];\n }\n if (extent1[2] < extent2[2]) {\n intersection[2] = extent1[2];\n } else {\n intersection[2] = extent2[2];\n }\n if (extent1[3] < extent2[3]) {\n intersection[3] = extent1[3];\n } else {\n intersection[3] = extent2[3];\n }\n } else {\n createOrUpdateEmpty(intersection);\n }\n return intersection;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @return {number} Margin.\n */\nexport function getMargin(extent) {\n return getWidth(extent) + getHeight(extent);\n}\n\n/**\n * Get the size (width, height) of an extent.\n * @param {Extent} extent The extent.\n * @return {import(\"./size.js\").Size} The extent size.\n * @api\n */\nexport function getSize(extent) {\n return [extent[2] - extent[0], extent[3] - extent[1]];\n}\n\n/**\n * Get the top left coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Top left coordinate.\n * @api\n */\nexport function getTopLeft(extent) {\n return [extent[0], extent[3]];\n}\n\n/**\n * Get the top right coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Top right coordinate.\n * @api\n */\nexport function getTopRight(extent) {\n return [extent[2], extent[3]];\n}\n\n/**\n * Get the width of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Width.\n * @api\n */\nexport function getWidth(extent) {\n return extent[2] - extent[0];\n}\n\n/**\n * Determine if one extent intersects another.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent.\n * @return {boolean} The two extents intersect.\n * @api\n */\nexport function intersects(extent1, extent2) {\n return (\n extent1[0] <= extent2[2] &&\n extent1[2] >= extent2[0] &&\n extent1[1] <= extent2[3] &&\n extent1[3] >= extent2[1]\n );\n}\n\n/**\n * Determine if an extent is empty.\n * @param {Extent} extent Extent.\n * @return {boolean} Is empty.\n * @api\n */\nexport function isEmpty(extent) {\n return extent[2] < extent[0] || extent[3] < extent[1];\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function returnOrUpdate(extent, dest) {\n if (dest) {\n dest[0] = extent[0];\n dest[1] = extent[1];\n dest[2] = extent[2];\n dest[3] = extent[3];\n return dest;\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} value Value.\n */\nexport function scaleFromCenter(extent, value) {\n const deltaX = ((extent[2] - extent[0]) / 2) * (value - 1);\n const deltaY = ((extent[3] - extent[1]) / 2) * (value - 1);\n extent[0] -= deltaX;\n extent[2] += deltaX;\n extent[1] -= deltaY;\n extent[3] += deltaY;\n}\n\n/**\n * Determine if the segment between two coordinates intersects (crosses,\n * touches, or is contained by) the provided extent.\n * @param {Extent} extent The extent.\n * @param {import(\"./coordinate.js\").Coordinate} start Segment start coordinate.\n * @param {import(\"./coordinate.js\").Coordinate} end Segment end coordinate.\n * @return {boolean} The segment intersects the extent.\n */\nexport function intersectsSegment(extent, start, end) {\n let intersects = false;\n const startRel = coordinateRelationship(extent, start);\n const endRel = coordinateRelationship(extent, end);\n if (\n startRel === Relationship.INTERSECTING ||\n endRel === Relationship.INTERSECTING\n ) {\n intersects = true;\n } else {\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const startX = start[0];\n const startY = start[1];\n const endX = end[0];\n const endY = end[1];\n const slope = (endY - startY) / (endX - startX);\n let x, y;\n if (!!(endRel & Relationship.ABOVE) && !(startRel & Relationship.ABOVE)) {\n // potentially intersects top\n x = endX - (endY - maxY) / slope;\n intersects = x >= minX && x <= maxX;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.RIGHT) &&\n !(startRel & Relationship.RIGHT)\n ) {\n // potentially intersects right\n y = endY - (endX - maxX) * slope;\n intersects = y >= minY && y <= maxY;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.BELOW) &&\n !(startRel & Relationship.BELOW)\n ) {\n // potentially intersects bottom\n x = endX - (endY - minY) / slope;\n intersects = x >= minX && x <= maxX;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.LEFT) &&\n !(startRel & Relationship.LEFT)\n ) {\n // potentially intersects left\n y = endY - (endX - minX) * slope;\n intersects = y >= minY && y <= maxY;\n }\n }\n return intersects;\n}\n\n/**\n * Apply a transform function to the extent.\n * @param {Extent} extent Extent.\n * @param {import(\"./proj.js\").TransformFunction} transformFn Transform function.\n * Called with `[minX, minY, maxX, maxY]` extent coordinates.\n * @param {Extent} [dest] Destination extent.\n * @param {number} [stops] Number of stops per side used for the transform.\n * By default only the corners are used.\n * @return {Extent} Extent.\n * @api\n */\nexport function applyTransform(extent, transformFn, dest, stops) {\n if (isEmpty(extent)) {\n return createOrUpdateEmpty(dest);\n }\n let coordinates = [];\n if (stops > 1) {\n const width = extent[2] - extent[0];\n const height = extent[3] - extent[1];\n for (let i = 0; i < stops; ++i) {\n coordinates.push(\n extent[0] + (width * i) / stops,\n extent[1],\n extent[2],\n extent[1] + (height * i) / stops,\n extent[2] - (width * i) / stops,\n extent[3],\n extent[0],\n extent[3] - (height * i) / stops,\n );\n }\n } else {\n coordinates = [\n extent[0],\n extent[1],\n extent[2],\n extent[1],\n extent[2],\n extent[3],\n extent[0],\n extent[3],\n ];\n }\n transformFn(coordinates, coordinates, 2);\n const xs = [];\n const ys = [];\n for (let i = 0, l = coordinates.length; i < l; i += 2) {\n xs.push(coordinates[i]);\n ys.push(coordinates[i + 1]);\n }\n return _boundingExtentXYs(xs, ys, dest);\n}\n\n/**\n * Modifies the provided extent in-place to be within the real world\n * extent.\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./proj/Projection.js\").default} projection Projection\n * @return {Extent} The extent within the real world extent.\n */\nexport function wrapX(extent, projection) {\n const projectionExtent = projection.getExtent();\n const center = getCenter(extent);\n if (\n projection.canWrapX() &&\n (center[0] < projectionExtent[0] || center[0] >= projectionExtent[2])\n ) {\n const worldWidth = getWidth(projectionExtent);\n const worldsAway = Math.floor(\n (center[0] - projectionExtent[0]) / worldWidth,\n );\n const offset = worldsAway * worldWidth;\n extent[0] -= offset;\n extent[2] -= offset;\n }\n return extent;\n}\n\n/**\n * Fits the extent to the real world\n *\n * If the extent does not cross the anti meridian, this will return the extent in an array\n * If the extent crosses the anti meridian, the extent will be sliced, so each part fits within the\n * real world\n *\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./proj/Projection.js\").default} projection Projection\n * @return {Array} The extent within the real world extent.\n */\nexport function wrapAndSliceX(extent, projection) {\n if (projection.canWrapX()) {\n const projectionExtent = projection.getExtent();\n\n if (!isFinite(extent[0]) || !isFinite(extent[2])) {\n return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];\n }\n\n wrapX(extent, projection);\n const worldWidth = getWidth(projectionExtent);\n\n if (getWidth(extent) > worldWidth) {\n // the extent wraps around on itself\n return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];\n }\n if (extent[0] < projectionExtent[0]) {\n // the extent crosses the anti meridian, so it needs to be sliced\n return [\n [extent[0] + worldWidth, extent[1], projectionExtent[2], extent[3]],\n [projectionExtent[0], extent[1], extent[2], extent[3]],\n ];\n }\n if (extent[2] > projectionExtent[2]) {\n // the extent crosses the anti meridian, so it needs to be sliced\n return [\n [extent[0], extent[1], projectionExtent[2], extent[3]],\n [projectionExtent[0], extent[1], extent[2] - worldWidth, extent[3]],\n ];\n }\n }\n\n return [extent];\n}\n","/**\n * @module ol/proj/Units\n */\n\n/**\n * @typedef {'radians' | 'degrees' | 'ft' | 'm' | 'pixels' | 'tile-pixels' | 'us-ft'} Units\n * Projection units.\n */\n\n/**\n * See http://duff.ess.washington.edu/data/raster/drg/docs/geotiff.txt\n * @type {Object}\n */\nconst unitByCode = {\n '9001': 'm',\n '9002': 'ft',\n '9003': 'us-ft',\n '9101': 'radians',\n '9102': 'degrees',\n};\n\n/**\n * @param {number} code Unit code.\n * @return {Units} Units.\n */\nexport function fromCode(code) {\n return unitByCode[code];\n}\n\n/**\n * @typedef {Object} MetersPerUnitLookup\n * @property {number} radians Radians\n * @property {number} degrees Degrees\n * @property {number} ft Feet\n * @property {number} m Meters\n * @property {number} us-ft US feet\n */\n\n/**\n * Meters per unit lookup table.\n * @const\n * @type {MetersPerUnitLookup}\n * @api\n */\nexport const METERS_PER_UNIT = {\n // use the radius of the Normal sphere\n 'radians': 6370997 / (2 * Math.PI),\n 'degrees': (2 * Math.PI * 6370997) / 360,\n 'ft': 0.3048,\n 'm': 1,\n 'us-ft': 1200 / 3937,\n};\n","/**\n * @module ol/proj/Projection\n */\nimport {METERS_PER_UNIT} from './Units.js';\n\n/**\n * @typedef {Object} Options\n * @property {string} code The SRS identifier code, e.g. `EPSG:4326`.\n * @property {import(\"./Units.js\").Units} [units] Units. Required unless a\n * proj4 projection is defined for `code`.\n * @property {import(\"../extent.js\").Extent} [extent] The validity extent for the SRS.\n * @property {string} [axisOrientation='enu'] The axis orientation as specified in Proj4.\n * @property {boolean} [global=false] Whether the projection is valid for the whole globe.\n * @property {number} [metersPerUnit] The meters per unit for the SRS.\n * If not provided, the `units` are used to get the meters per unit from the {@link METERS_PER_UNIT}\n * lookup table.\n * @property {import(\"../extent.js\").Extent} [worldExtent] The world extent for the SRS.\n * @property {function(number, import(\"../coordinate.js\").Coordinate):number} [getPointResolution]\n * Function to determine resolution at a point. The function is called with a\n * `number` view resolution and a {@link module:ol/coordinate~Coordinate} as arguments, and returns\n * the `number` resolution in projection units at the passed coordinate. If this is `undefined`,\n * the default {@link module:ol/proj.getPointResolution} function will be used.\n */\n\n/**\n * @classdesc\n * Projection definition class. One of these is created for each projection\n * supported in the application and stored in the {@link module:ol/proj} namespace.\n * You can use these in applications, but this is not required, as API params\n * and options use {@link module:ol/proj~ProjectionLike} which means the simple string\n * code will suffice.\n *\n * You can use {@link module:ol/proj.get} to retrieve the object for a particular\n * projection.\n *\n * The library includes definitions for `EPSG:4326` and `EPSG:3857`, together\n * with the following aliases:\n * * `EPSG:4326`: CRS:84, urn:ogc:def:crs:EPSG:6.6:4326,\n * urn:ogc:def:crs:OGC:1.3:CRS84, urn:ogc:def:crs:OGC:2:84,\n * http://www.opengis.net/gml/srs/epsg.xml#4326,\n * urn:x-ogc:def:crs:EPSG:4326\n * * `EPSG:3857`: EPSG:102100, EPSG:102113, EPSG:900913,\n * urn:ogc:def:crs:EPSG:6.18:3:3857,\n * http://www.opengis.net/gml/srs/epsg.xml#3857\n *\n * If you use [proj4js](https://github.com/proj4js/proj4js), aliases can\n * be added using `proj4.defs()`. After all required projection definitions are\n * added, call the {@link module:ol/proj/proj4.register} function.\n *\n * @api\n */\nclass Projection {\n /**\n * @param {Options} options Projection options.\n */\n constructor(options) {\n /**\n * @private\n * @type {string}\n */\n this.code_ = options.code;\n\n /**\n * Units of projected coordinates. When set to `TILE_PIXELS`, a\n * `this.extent_` and `this.worldExtent_` must be configured properly for each\n * tile.\n * @private\n * @type {import(\"./Units.js\").Units}\n */\n this.units_ = /** @type {import(\"./Units.js\").Units} */ (options.units);\n\n /**\n * Validity extent of the projection in projected coordinates. For projections\n * with `TILE_PIXELS` units, this is the extent of the tile in\n * tile pixel space.\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.extent_ = options.extent !== undefined ? options.extent : null;\n\n /**\n * Extent of the world in EPSG:4326. For projections with\n * `TILE_PIXELS` units, this is the extent of the tile in\n * projected coordinate space.\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.worldExtent_ =\n options.worldExtent !== undefined ? options.worldExtent : null;\n\n /**\n * @private\n * @type {string}\n */\n this.axisOrientation_ =\n options.axisOrientation !== undefined ? options.axisOrientation : 'enu';\n\n /**\n * @private\n * @type {boolean}\n */\n this.global_ = options.global !== undefined ? options.global : false;\n\n /**\n * @private\n * @type {boolean}\n */\n this.canWrapX_ = !!(this.global_ && this.extent_);\n\n /**\n * @private\n * @type {function(number, import(\"../coordinate.js\").Coordinate):number|undefined}\n */\n this.getPointResolutionFunc_ = options.getPointResolution;\n\n /**\n * @private\n * @type {import(\"../tilegrid/TileGrid.js\").default}\n */\n this.defaultTileGrid_ = null;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.metersPerUnit_ = options.metersPerUnit;\n }\n\n /**\n * @return {boolean} The projection is suitable for wrapping the x-axis\n */\n canWrapX() {\n return this.canWrapX_;\n }\n\n /**\n * Get the code for this projection, e.g. 'EPSG:4326'.\n * @return {string} Code.\n * @api\n */\n getCode() {\n return this.code_;\n }\n\n /**\n * Get the validity extent for this projection.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getExtent() {\n return this.extent_;\n }\n\n /**\n * Get the units of this projection.\n * @return {import(\"./Units.js\").Units} Units.\n * @api\n */\n getUnits() {\n return this.units_;\n }\n\n /**\n * Get the amount of meters per unit of this projection. If the projection is\n * not configured with `metersPerUnit` or a units identifier, the return is\n * `undefined`.\n * @return {number|undefined} Meters.\n * @api\n */\n getMetersPerUnit() {\n return this.metersPerUnit_ || METERS_PER_UNIT[this.units_];\n }\n\n /**\n * Get the world extent for this projection.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getWorldExtent() {\n return this.worldExtent_;\n }\n\n /**\n * Get the axis orientation of this projection.\n * Example values are:\n * enu - the default easting, northing, elevation.\n * neu - northing, easting, up - useful for \"lat/long\" geographic coordinates,\n * or south orientated transverse mercator.\n * wnu - westing, northing, up - some planetary coordinate systems have\n * \"west positive\" coordinate systems\n * @return {string} Axis orientation.\n * @api\n */\n getAxisOrientation() {\n return this.axisOrientation_;\n }\n\n /**\n * Is this projection a global projection which spans the whole world?\n * @return {boolean} Whether the projection is global.\n * @api\n */\n isGlobal() {\n return this.global_;\n }\n\n /**\n * Set if the projection is a global projection which spans the whole world\n * @param {boolean} global Whether the projection is global.\n * @api\n */\n setGlobal(global) {\n this.global_ = global;\n this.canWrapX_ = !!(global && this.extent_);\n }\n\n /**\n * @return {import(\"../tilegrid/TileGrid.js\").default} The default tile grid.\n */\n getDefaultTileGrid() {\n return this.defaultTileGrid_;\n }\n\n /**\n * @param {import(\"../tilegrid/TileGrid.js\").default} tileGrid The default tile grid.\n */\n setDefaultTileGrid(tileGrid) {\n this.defaultTileGrid_ = tileGrid;\n }\n\n /**\n * Set the validity extent for this projection.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @api\n */\n setExtent(extent) {\n this.extent_ = extent;\n this.canWrapX_ = !!(this.global_ && extent);\n }\n\n /**\n * Set the world extent for this projection.\n * @param {import(\"../extent.js\").Extent} worldExtent World extent\n * [minlon, minlat, maxlon, maxlat].\n * @api\n */\n setWorldExtent(worldExtent) {\n this.worldExtent_ = worldExtent;\n }\n\n /**\n * Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}\n * for this projection.\n * @param {function(number, import(\"../coordinate.js\").Coordinate):number} func Function\n * @api\n */\n setGetPointResolution(func) {\n this.getPointResolutionFunc_ = func;\n }\n\n /**\n * Get the custom point resolution function for this projection (if set).\n * @return {function(number, import(\"../coordinate.js\").Coordinate):number|undefined} The custom point\n * resolution function (if set).\n */\n getPointResolutionFunc() {\n return this.getPointResolutionFunc_;\n }\n}\n\nexport default Projection;\n","/**\n * @module ol/proj/epsg3857\n */\nimport Projection from './Projection.js';\n\n/**\n * Radius of WGS84 sphere\n *\n * @const\n * @type {number}\n */\nexport const RADIUS = 6378137;\n\n/**\n * @const\n * @type {number}\n */\nexport const HALF_SIZE = Math.PI * RADIUS;\n\n/**\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const EXTENT = [-HALF_SIZE, -HALF_SIZE, HALF_SIZE, HALF_SIZE];\n\n/**\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const WORLD_EXTENT = [-180, -85, 180, 85];\n\n/**\n * Maximum safe value in y direction\n * @const\n * @type {number}\n */\nexport const MAX_SAFE_Y = RADIUS * Math.log(Math.tan(Math.PI / 2));\n\n/**\n * @classdesc\n * Projection object for web/spherical Mercator (EPSG:3857).\n */\nclass EPSG3857Projection extends Projection {\n /**\n * @param {string} code Code.\n */\n constructor(code) {\n super({\n code: code,\n units: 'm',\n extent: EXTENT,\n global: true,\n worldExtent: WORLD_EXTENT,\n getPointResolution: function (resolution, point) {\n return resolution / Math.cosh(point[1] / RADIUS);\n },\n });\n }\n}\n\n/**\n * Projections equal to EPSG:3857.\n *\n * @const\n * @type {Array}\n */\nexport const PROJECTIONS = [\n new EPSG3857Projection('EPSG:3857'),\n new EPSG3857Projection('EPSG:102100'),\n new EPSG3857Projection('EPSG:102113'),\n new EPSG3857Projection('EPSG:900913'),\n new EPSG3857Projection('http://www.opengis.net/def/crs/EPSG/0/3857'),\n new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857'),\n];\n\n/**\n * Transformation from EPSG:4326 to EPSG:3857.\n *\n * @param {Array} input Input array of coordinate values.\n * @param {Array} [output] Output array of coordinate values.\n * @param {number} [dimension] Dimension (default is `2`).\n * @return {Array} Output array of coordinate values.\n */\nexport function fromEPSG4326(input, output, dimension) {\n const length = input.length;\n dimension = dimension > 1 ? dimension : 2;\n if (output === undefined) {\n if (dimension > 2) {\n // preserve values beyond second dimension\n output = input.slice();\n } else {\n output = new Array(length);\n }\n }\n for (let i = 0; i < length; i += dimension) {\n output[i] = (HALF_SIZE * input[i]) / 180;\n let y = RADIUS * Math.log(Math.tan((Math.PI * (+input[i + 1] + 90)) / 360));\n if (y > MAX_SAFE_Y) {\n y = MAX_SAFE_Y;\n } else if (y < -MAX_SAFE_Y) {\n y = -MAX_SAFE_Y;\n }\n output[i + 1] = y;\n }\n return output;\n}\n\n/**\n * Transformation from EPSG:3857 to EPSG:4326.\n *\n * @param {Array} input Input array of coordinate values.\n * @param {Array} [output] Output array of coordinate values.\n * @param {number} [dimension] Dimension (default is `2`).\n * @return {Array} Output array of coordinate values.\n */\nexport function toEPSG4326(input, output, dimension) {\n const length = input.length;\n dimension = dimension > 1 ? dimension : 2;\n if (output === undefined) {\n if (dimension > 2) {\n // preserve values beyond second dimension\n output = input.slice();\n } else {\n output = new Array(length);\n }\n }\n for (let i = 0; i < length; i += dimension) {\n output[i] = (180 * input[i]) / HALF_SIZE;\n output[i + 1] =\n (360 * Math.atan(Math.exp(input[i + 1] / RADIUS))) / Math.PI - 90;\n }\n return output;\n}\n","/**\n * @module ol/proj/epsg4326\n */\nimport Projection from './Projection.js';\n\n/**\n * Semi-major radius of the WGS84 ellipsoid.\n *\n * @const\n * @type {number}\n */\nexport const RADIUS = 6378137;\n\n/**\n * Extent of the EPSG:4326 projection which is the whole world.\n *\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const EXTENT = [-180, -90, 180, 90];\n\n/**\n * @const\n * @type {number}\n */\nexport const METERS_PER_UNIT = (Math.PI * RADIUS) / 180;\n\n/**\n * @classdesc\n * Projection object for WGS84 geographic coordinates (EPSG:4326).\n *\n * Note that OpenLayers does not strictly comply with the EPSG definition.\n * The EPSG registry defines 4326 as a CRS for Latitude,Longitude (y,x).\n * OpenLayers treats EPSG:4326 as a pseudo-projection, with x,y coordinates.\n */\nclass EPSG4326Projection extends Projection {\n /**\n * @param {string} code Code.\n * @param {string} [axisOrientation] Axis orientation.\n */\n constructor(code, axisOrientation) {\n super({\n code: code,\n units: 'degrees',\n extent: EXTENT,\n axisOrientation: axisOrientation,\n global: true,\n metersPerUnit: METERS_PER_UNIT,\n worldExtent: EXTENT,\n });\n }\n}\n\n/**\n * Projections equal to EPSG:4326.\n *\n * @const\n * @type {Array}\n */\nexport const PROJECTIONS = [\n new EPSG4326Projection('CRS:84'),\n new EPSG4326Projection('EPSG:4326', 'neu'),\n new EPSG4326Projection('urn:ogc:def:crs:OGC:1.3:CRS84'),\n new EPSG4326Projection('urn:ogc:def:crs:OGC:2:84'),\n new EPSG4326Projection('http://www.opengis.net/def/crs/OGC/1.3/CRS84'),\n new EPSG4326Projection('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),\n new EPSG4326Projection('http://www.opengis.net/def/crs/EPSG/0/4326', 'neu'),\n];\n","/**\n * @module ol/proj/projections\n */\n\n/**\n * @type {Object}\n */\nlet cache = {};\n\n/**\n * Clear the projections cache.\n */\nexport function clear() {\n cache = {};\n}\n\n/**\n * Get a cached projection by code.\n * @param {string} code The code for the projection.\n * @return {import(\"./Projection.js\").default} The projection (if cached).\n */\nexport function get(code) {\n return (\n cache[code] ||\n cache[code.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\\w+)$/, 'EPSG:$3')] ||\n null\n );\n}\n\n/**\n * Add a projection to the cache.\n * @param {string} code The projection code.\n * @param {import(\"./Projection.js\").default} projection The projection to cache.\n */\nexport function add(code, projection) {\n cache[code] = projection;\n}\n","/**\n * @module ol/proj/transforms\n */\nimport {isEmpty} from '../obj.js';\n\n/**\n * @private\n * @type {!Object>}\n */\nlet transforms = {};\n\n/**\n * Clear the transform cache.\n */\nexport function clear() {\n transforms = {};\n}\n\n/**\n * Registers a conversion function to convert coordinates from the source\n * projection to the destination projection.\n *\n * @param {import(\"./Projection.js\").default} source Source.\n * @param {import(\"./Projection.js\").default} destination Destination.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform.\n */\nexport function add(source, destination, transformFn) {\n const sourceCode = source.getCode();\n const destinationCode = destination.getCode();\n if (!(sourceCode in transforms)) {\n transforms[sourceCode] = {};\n }\n transforms[sourceCode][destinationCode] = transformFn;\n}\n\n/**\n * Unregisters the conversion function to convert coordinates from the source\n * projection to the destination projection. This method is used to clean up\n * cached transforms during testing.\n *\n * @param {import(\"./Projection.js\").default} source Source projection.\n * @param {import(\"./Projection.js\").default} destination Destination projection.\n * @return {import(\"../proj.js\").TransformFunction} transformFn The unregistered transform.\n */\nexport function remove(source, destination) {\n const sourceCode = source.getCode();\n const destinationCode = destination.getCode();\n const transform = transforms[sourceCode][destinationCode];\n delete transforms[sourceCode][destinationCode];\n if (isEmpty(transforms[sourceCode])) {\n delete transforms[sourceCode];\n }\n return transform;\n}\n\n/**\n * Get a transform given a source code and a destination code.\n * @param {string} sourceCode The code for the source projection.\n * @param {string} destinationCode The code for the destination projection.\n * @return {import(\"../proj.js\").TransformFunction|undefined} The transform function (if found).\n */\nexport function get(sourceCode, destinationCode) {\n let transform;\n if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {\n transform = transforms[sourceCode][destinationCode];\n }\n return transform;\n}\n","/**\n * @module ol/math\n */\n\n/**\n * Takes a number and clamps it to within the provided bounds.\n * @param {number} value The input number.\n * @param {number} min The minimum value to return.\n * @param {number} max The maximum value to return.\n * @return {number} The input number if it is within bounds, or the nearest\n * number within the bounds.\n */\nexport function clamp(value, min, max) {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Returns the square of the closest distance between the point (x, y) and the\n * line segment (x1, y1) to (x2, y2).\n * @param {number} x X.\n * @param {number} y Y.\n * @param {number} x1 X1.\n * @param {number} y1 Y1.\n * @param {number} x2 X2.\n * @param {number} y2 Y2.\n * @return {number} Squared distance.\n */\nexport function squaredSegmentDistance(x, y, x1, y1, x2, y2) {\n const dx = x2 - x1;\n const dy = y2 - y1;\n if (dx !== 0 || dy !== 0) {\n const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n x1 = x2;\n y1 = y2;\n } else if (t > 0) {\n x1 += dx * t;\n y1 += dy * t;\n }\n }\n return squaredDistance(x, y, x1, y1);\n}\n\n/**\n * Returns the square of the distance between the points (x1, y1) and (x2, y2).\n * @param {number} x1 X1.\n * @param {number} y1 Y1.\n * @param {number} x2 X2.\n * @param {number} y2 Y2.\n * @return {number} Squared distance.\n */\nexport function squaredDistance(x1, y1, x2, y2) {\n const dx = x2 - x1;\n const dy = y2 - y1;\n return dx * dx + dy * dy;\n}\n\n/**\n * Solves system of linear equations using Gaussian elimination method.\n *\n * @param {Array>} mat Augmented matrix (n x n + 1 column)\n * in row-major order.\n * @return {Array|null} The resulting vector.\n */\nexport function solveLinearSystem(mat) {\n const n = mat.length;\n\n for (let i = 0; i < n; i++) {\n // Find max in the i-th column (ignoring i - 1 first rows)\n let maxRow = i;\n let maxEl = Math.abs(mat[i][i]);\n for (let r = i + 1; r < n; r++) {\n const absValue = Math.abs(mat[r][i]);\n if (absValue > maxEl) {\n maxEl = absValue;\n maxRow = r;\n }\n }\n\n if (maxEl === 0) {\n return null; // matrix is singular\n }\n\n // Swap max row with i-th (current) row\n const tmp = mat[maxRow];\n mat[maxRow] = mat[i];\n mat[i] = tmp;\n\n // Subtract the i-th row to make all the remaining rows 0 in the i-th column\n for (let j = i + 1; j < n; j++) {\n const coef = -mat[j][i] / mat[i][i];\n for (let k = i; k < n + 1; k++) {\n if (i == k) {\n mat[j][k] = 0;\n } else {\n mat[j][k] += coef * mat[i][k];\n }\n }\n }\n }\n\n // Solve Ax=b for upper triangular matrix A (mat)\n const x = new Array(n);\n for (let l = n - 1; l >= 0; l--) {\n x[l] = mat[l][n] / mat[l][l];\n for (let m = l - 1; m >= 0; m--) {\n mat[m][n] -= mat[m][l] * x[l];\n }\n }\n return x;\n}\n\n/**\n * Converts radians to to degrees.\n *\n * @param {number} angleInRadians Angle in radians.\n * @return {number} Angle in degrees.\n */\nexport function toDegrees(angleInRadians) {\n return (angleInRadians * 180) / Math.PI;\n}\n\n/**\n * Converts degrees to radians.\n *\n * @param {number} angleInDegrees Angle in degrees.\n * @return {number} Angle in radians.\n */\nexport function toRadians(angleInDegrees) {\n return (angleInDegrees * Math.PI) / 180;\n}\n\n/**\n * Returns the modulo of a / b, depending on the sign of b.\n *\n * @param {number} a Dividend.\n * @param {number} b Divisor.\n * @return {number} Modulo.\n */\nexport function modulo(a, b) {\n const r = a % b;\n return r * b < 0 ? r + b : r;\n}\n\n/**\n * Calculates the linearly interpolated value of x between a and b.\n *\n * @param {number} a Number\n * @param {number} b Number\n * @param {number} x Value to be interpolated.\n * @return {number} Interpolated value.\n */\nexport function lerp(a, b, x) {\n return a + x * (b - a);\n}\n\n/**\n * Returns a number with a limited number of decimal digits.\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The input number with a limited number of decimal digits.\n */\nexport function toFixed(n, decimals) {\n const factor = Math.pow(10, decimals);\n return Math.round(n * factor) / factor;\n}\n\n/**\n * Rounds a number to the nearest integer value considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The nearest integer.\n */\nexport function round(n, decimals) {\n return Math.round(toFixed(n, decimals));\n}\n\n/**\n * Rounds a number to the next smaller integer considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The next smaller integer.\n */\nexport function floor(n, decimals) {\n return Math.floor(toFixed(n, decimals));\n}\n\n/**\n * Rounds a number to the next bigger integer considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The next bigger integer.\n */\nexport function ceil(n, decimals) {\n return Math.ceil(toFixed(n, decimals));\n}\n","/**\n * @module ol/string\n */\n\n/**\n * @param {number} number Number to be formatted\n * @param {number} width The desired width\n * @param {number} [precision] Precision of the output string (i.e. number of decimal places)\n * @return {string} Formatted string\n */\nexport function padNumber(number, width, precision) {\n const numberString =\n precision !== undefined ? number.toFixed(precision) : '' + number;\n let decimal = numberString.indexOf('.');\n decimal = decimal === -1 ? numberString.length : decimal;\n return decimal > width\n ? numberString\n : new Array(1 + width - decimal).join('0') + numberString;\n}\n\n/**\n * Adapted from https://github.com/omichelsen/compare-versions/blob/master/index.js\n * @param {string|number} v1 First version\n * @param {string|number} v2 Second version\n * @return {number} Value\n */\nexport function compareVersions(v1, v2) {\n const s1 = ('' + v1).split('.');\n const s2 = ('' + v2).split('.');\n\n for (let i = 0; i < Math.max(s1.length, s2.length); i++) {\n const n1 = parseInt(s1[i] || '0', 10);\n const n2 = parseInt(s2[i] || '0', 10);\n\n if (n1 > n2) {\n return 1;\n }\n if (n2 > n1) {\n return -1;\n }\n }\n\n return 0;\n}\n","/**\n * @module ol/coordinate\n */\nimport {getWidth} from './extent.js';\nimport {modulo, toFixed} from './math.js';\nimport {padNumber} from './string.js';\n\n/**\n * An array of numbers representing an `xy`, `xyz` or `xyzm` coordinate.\n * Example: `[16, 48]`.\n * @typedef {Array} Coordinate\n * @api\n */\n\n/**\n * A function that takes a {@link module:ol/coordinate~Coordinate} and\n * transforms it into a `{string}`.\n *\n * @typedef {function((Coordinate|undefined)): string} CoordinateFormat\n * @api\n */\n\n/**\n * Add `delta` to `coordinate`. `coordinate` is modified in place and returned\n * by the function.\n *\n * Example:\n *\n * import {add} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * add(coord, [-2, 4]);\n * // coord is now [5.85, 51.983333]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {Coordinate} delta Delta.\n * @return {Coordinate} The input coordinate adjusted by\n * the given delta.\n * @api\n */\nexport function add(coordinate, delta) {\n coordinate[0] += +delta[0];\n coordinate[1] += +delta[1];\n return coordinate;\n}\n\n/**\n * Calculates the point closest to the passed coordinate on the passed circle.\n *\n * @param {Coordinate} coordinate The coordinate.\n * @param {import(\"./geom/Circle.js\").default} circle The circle.\n * @return {Coordinate} Closest point on the circumference.\n */\nexport function closestOnCircle(coordinate, circle) {\n const r = circle.getRadius();\n const center = circle.getCenter();\n const x0 = center[0];\n const y0 = center[1];\n const x1 = coordinate[0];\n const y1 = coordinate[1];\n\n let dx = x1 - x0;\n const dy = y1 - y0;\n if (dx === 0 && dy === 0) {\n dx = 1;\n }\n const d = Math.sqrt(dx * dx + dy * dy);\n\n const x = x0 + (r * dx) / d;\n const y = y0 + (r * dy) / d;\n\n return [x, y];\n}\n\n/**\n * Calculates the point closest to the passed coordinate on the passed segment.\n * This is the foot of the perpendicular of the coordinate to the segment when\n * the foot is on the segment, or the closest segment coordinate when the foot\n * is outside the segment.\n *\n * @param {Coordinate} coordinate The coordinate.\n * @param {Array} segment The two coordinates\n * of the segment.\n * @return {Coordinate} The foot of the perpendicular of\n * the coordinate to the segment.\n */\nexport function closestOnSegment(coordinate, segment) {\n const x0 = coordinate[0];\n const y0 = coordinate[1];\n const start = segment[0];\n const end = segment[1];\n const x1 = start[0];\n const y1 = start[1];\n const x2 = end[0];\n const y2 = end[1];\n const dx = x2 - x1;\n const dy = y2 - y1;\n const along =\n dx === 0 && dy === 0\n ? 0\n : (dx * (x0 - x1) + dy * (y0 - y1)) / (dx * dx + dy * dy || 0);\n let x, y;\n if (along <= 0) {\n x = x1;\n y = y1;\n } else if (along >= 1) {\n x = x2;\n y = y2;\n } else {\n x = x1 + along * dx;\n y = y1 + along * dy;\n }\n return [x, y];\n}\n\n/**\n * Returns a {@link module:ol/coordinate~CoordinateFormat} function that can be\n * used to format\n * a {Coordinate} to a string.\n *\n * Example without specifying the fractional digits:\n *\n * import {createStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const stringifyFunc = createStringXY();\n * const out = stringifyFunc(coord);\n * // out is now '8, 48'\n *\n * Example with explicitly specifying 2 fractional digits:\n *\n * import {createStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const stringifyFunc = createStringXY(2);\n * const out = stringifyFunc(coord);\n * // out is now '7.85, 47.98'\n *\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {CoordinateFormat} Coordinate format.\n * @api\n */\nexport function createStringXY(fractionDigits) {\n return (\n /**\n * @param {Coordinate} coordinate Coordinate.\n * @return {string} String XY.\n */\n function (coordinate) {\n return toStringXY(coordinate, fractionDigits);\n }\n );\n}\n\n/**\n * @param {string} hemispheres Hemispheres.\n * @param {number} degrees Degrees.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} String.\n */\nexport function degreesToStringHDMS(hemispheres, degrees, fractionDigits) {\n const normalizedDegrees = modulo(degrees + 180, 360) - 180;\n const x = Math.abs(3600 * normalizedDegrees);\n const decimals = fractionDigits || 0;\n\n let deg = Math.floor(x / 3600);\n let min = Math.floor((x - deg * 3600) / 60);\n let sec = toFixed(x - deg * 3600 - min * 60, decimals);\n\n if (sec >= 60) {\n sec = 0;\n min += 1;\n }\n\n if (min >= 60) {\n min = 0;\n deg += 1;\n }\n\n let hdms = deg + '\\u00b0';\n if (min !== 0 || sec !== 0) {\n hdms += ' ' + padNumber(min, 2) + '\\u2032';\n }\n if (sec !== 0) {\n hdms += ' ' + padNumber(sec, 2, decimals) + '\\u2033';\n }\n if (normalizedDegrees !== 0) {\n hdms += ' ' + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);\n }\n\n return hdms;\n}\n\n/**\n * Transforms the given {@link module:ol/coordinate~Coordinate} to a string\n * using the given string template. The strings `{x}` and `{y}` in the template\n * will be replaced with the first and second coordinate values respectively.\n *\n * Example without specifying the fractional digits:\n *\n * import {format} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const template = 'Coordinate is ({x}|{y}).';\n * const out = format(coord, template);\n * // out is now 'Coordinate is (8|48).'\n *\n * Example explicitly specifying the fractional digits:\n *\n * import {format} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const template = 'Coordinate is ({x}|{y}).';\n * const out = format(coord, template, 2);\n * // out is now 'Coordinate is (7.85|47.98).'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {string} template A template string with `{x}` and `{y}` placeholders\n * that will be replaced by first and second coordinate values.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} Formatted coordinate.\n * @api\n */\nexport function format(coordinate, template, fractionDigits) {\n if (coordinate) {\n return template\n .replace('{x}', coordinate[0].toFixed(fractionDigits))\n .replace('{y}', coordinate[1].toFixed(fractionDigits));\n }\n return '';\n}\n\n/**\n * @param {Coordinate} coordinate1 First coordinate.\n * @param {Coordinate} coordinate2 Second coordinate.\n * @return {boolean} The two coordinates are equal.\n */\nexport function equals(coordinate1, coordinate2) {\n let equals = true;\n for (let i = coordinate1.length - 1; i >= 0; --i) {\n if (coordinate1[i] != coordinate2[i]) {\n equals = false;\n break;\n }\n }\n return equals;\n}\n\n/**\n * Rotate `coordinate` by `angle`. `coordinate` is modified in place and\n * returned by the function.\n *\n * Example:\n *\n * import {rotate} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const rotateRadians = Math.PI / 2; // 90 degrees\n * rotate(coord, rotateRadians);\n * // coord is now [-47.983333, 7.85]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} angle Angle in radian.\n * @return {Coordinate} Coordinate.\n * @api\n */\nexport function rotate(coordinate, angle) {\n const cosAngle = Math.cos(angle);\n const sinAngle = Math.sin(angle);\n const x = coordinate[0] * cosAngle - coordinate[1] * sinAngle;\n const y = coordinate[1] * cosAngle + coordinate[0] * sinAngle;\n coordinate[0] = x;\n coordinate[1] = y;\n return coordinate;\n}\n\n/**\n * Scale `coordinate` by `scale`. `coordinate` is modified in place and returned\n * by the function.\n *\n * Example:\n *\n * import {scale as scaleCoordinate} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const scale = 1.2;\n * scaleCoordinate(coord, scale);\n * // coord is now [9.42, 57.5799996]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} scale Scale factor.\n * @return {Coordinate} Coordinate.\n */\nexport function scale(coordinate, scale) {\n coordinate[0] *= scale;\n coordinate[1] *= scale;\n return coordinate;\n}\n\n/**\n * @param {Coordinate} coord1 First coordinate.\n * @param {Coordinate} coord2 Second coordinate.\n * @return {number} Squared distance between coord1 and coord2.\n */\nexport function squaredDistance(coord1, coord2) {\n const dx = coord1[0] - coord2[0];\n const dy = coord1[1] - coord2[1];\n return dx * dx + dy * dy;\n}\n\n/**\n * @param {Coordinate} coord1 First coordinate.\n * @param {Coordinate} coord2 Second coordinate.\n * @return {number} Distance between coord1 and coord2.\n */\nexport function distance(coord1, coord2) {\n return Math.sqrt(squaredDistance(coord1, coord2));\n}\n\n/**\n * Calculate the squared distance from a coordinate to a line segment.\n *\n * @param {Coordinate} coordinate Coordinate of the point.\n * @param {Array} segment Line segment (2\n * coordinates).\n * @return {number} Squared distance from the point to the line segment.\n */\nexport function squaredDistanceToSegment(coordinate, segment) {\n return squaredDistance(coordinate, closestOnSegment(coordinate, segment));\n}\n\n/**\n * Format a geographic coordinate with the hemisphere, degrees, minutes, and\n * seconds.\n *\n * Example without specifying fractional digits:\n *\n * import {toStringHDMS} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringHDMS(coord);\n * // out is now '47° 58′ 60″ N 7° 50′ 60″ E'\n *\n * Example explicitly specifying 1 fractional digit:\n *\n * import {toStringHDMS} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringHDMS(coord, 1);\n * // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} Hemisphere, degrees, minutes and seconds.\n * @api\n */\nexport function toStringHDMS(coordinate, fractionDigits) {\n if (coordinate) {\n return (\n degreesToStringHDMS('NS', coordinate[1], fractionDigits) +\n ' ' +\n degreesToStringHDMS('EW', coordinate[0], fractionDigits)\n );\n }\n return '';\n}\n\n/**\n * Format a coordinate as a comma delimited string.\n *\n * Example without specifying fractional digits:\n *\n * import {toStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringXY(coord);\n * // out is now '8, 48'\n *\n * Example explicitly specifying 1 fractional digit:\n *\n * import {toStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringXY(coord, 1);\n * // out is now '7.8, 48.0'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} XY.\n * @api\n */\nexport function toStringXY(coordinate, fractionDigits) {\n return format(coordinate, '{x}, {y}', fractionDigits);\n}\n\n/**\n * Modifies the provided coordinate in-place to be within the real world\n * extent. The lower projection extent boundary is inclusive, the upper one\n * exclusive.\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @return {Coordinate} The coordinate within the real world extent.\n */\nexport function wrapX(coordinate, projection) {\n if (projection.canWrapX()) {\n const worldWidth = getWidth(projection.getExtent());\n const worldsAway = getWorldsAway(coordinate, projection, worldWidth);\n if (worldsAway) {\n coordinate[0] -= worldsAway * worldWidth;\n }\n }\n return coordinate;\n}\n/**\n * @param {Coordinate} coordinate Coordinate.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @param {number} [sourceExtentWidth] Width of the source extent.\n * @return {number} Offset in world widths.\n */\nexport function getWorldsAway(coordinate, projection, sourceExtentWidth) {\n const projectionExtent = projection.getExtent();\n let worldsAway = 0;\n if (\n projection.canWrapX() &&\n (coordinate[0] < projectionExtent[0] || coordinate[0] > projectionExtent[2])\n ) {\n sourceExtentWidth = sourceExtentWidth || getWidth(projectionExtent);\n worldsAway = Math.floor(\n (coordinate[0] - projectionExtent[0]) / sourceExtentWidth,\n );\n }\n return worldsAway;\n}\n","/**\n * @module ol/sphere\n */\nimport {toDegrees, toRadians} from './math.js';\n\n/**\n * Object literal with options for the {@link getLength} or {@link getArea}\n * functions.\n * @typedef {Object} SphereMetricOptions\n * @property {import(\"./proj.js\").ProjectionLike} [projection='EPSG:3857']\n * Projection of the geometry. By default, the geometry is assumed to be in\n * Web Mercator.\n * @property {number} [radius=6371008.8] Sphere radius. By default, the\n * [mean Earth radius](https://en.wikipedia.org/wiki/Earth_radius#Mean_radius)\n * for the WGS84 ellipsoid is used.\n */\n\n/**\n * The mean Earth radius (1/3 * (2a + b)) for the WGS84 ellipsoid.\n * https://en.wikipedia.org/wiki/Earth_radius#Mean_radius\n * @type {number}\n */\nexport const DEFAULT_RADIUS = 6371008.8;\n\n/**\n * Get the great circle distance (in meters) between two geographic coordinates.\n * @param {Array} c1 Starting coordinate.\n * @param {Array} c2 Ending coordinate.\n * @param {number} [radius] The sphere radius to use. Defaults to the Earth's\n * mean radius using the WGS84 ellipsoid.\n * @return {number} The great circle distance between the points (in meters).\n * @api\n */\nexport function getDistance(c1, c2, radius) {\n radius = radius || DEFAULT_RADIUS;\n const lat1 = toRadians(c1[1]);\n const lat2 = toRadians(c2[1]);\n const deltaLatBy2 = (lat2 - lat1) / 2;\n const deltaLonBy2 = toRadians(c2[0] - c1[0]) / 2;\n const a =\n Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) +\n Math.sin(deltaLonBy2) *\n Math.sin(deltaLonBy2) *\n Math.cos(lat1) *\n Math.cos(lat2);\n return 2 * radius * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n}\n\n/**\n * Get the cumulative great circle length of linestring coordinates (geographic).\n * @param {Array} coordinates Linestring coordinates.\n * @param {number} radius The sphere radius to use.\n * @return {number} The length (in meters).\n */\nfunction getLengthInternal(coordinates, radius) {\n let length = 0;\n for (let i = 0, ii = coordinates.length; i < ii - 1; ++i) {\n length += getDistance(coordinates[i], coordinates[i + 1], radius);\n }\n return length;\n}\n\n/**\n * Get the spherical length of a geometry. This length is the sum of the\n * great circle distances between coordinates. For polygons, the length is\n * the sum of all rings. For points, the length is zero. For multi-part\n * geometries, the length is the sum of the length of each part.\n * @param {import(\"./geom/Geometry.js\").default} geometry A geometry.\n * @param {SphereMetricOptions} [options] Options for the\n * length calculation. By default, geometries are assumed to be in 'EPSG:3857'.\n * You can change this by providing a `projection` option.\n * @return {number} The spherical length (in meters).\n * @api\n */\nexport function getLength(geometry, options) {\n options = options || {};\n const radius = options.radius || DEFAULT_RADIUS;\n const projection = options.projection || 'EPSG:3857';\n const type = geometry.getType();\n if (type !== 'GeometryCollection') {\n geometry = geometry.clone().transform(projection, 'EPSG:4326');\n }\n let length = 0;\n let coordinates, coords, i, ii, j, jj;\n switch (type) {\n case 'Point':\n case 'MultiPoint': {\n break;\n }\n case 'LineString':\n case 'LinearRing': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n length = getLengthInternal(coordinates, radius);\n break;\n }\n case 'MultiLineString':\n case 'Polygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n length += getLengthInternal(coordinates[i], radius);\n }\n break;\n }\n case 'MultiPolygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n coords = coordinates[i];\n for (j = 0, jj = coords.length; j < jj; ++j) {\n length += getLengthInternal(coords[j], radius);\n }\n }\n break;\n }\n case 'GeometryCollection': {\n const geometries =\n /** @type {import(\"./geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometries();\n for (i = 0, ii = geometries.length; i < ii; ++i) {\n length += getLength(geometries[i], options);\n }\n break;\n }\n default: {\n throw new Error('Unsupported geometry type: ' + type);\n }\n }\n return length;\n}\n\n/**\n * Returns the spherical area for a list of coordinates.\n *\n * [Reference](https://trs.jpl.nasa.gov/handle/2014/40409)\n * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n * Laboratory, Pasadena, CA, June 2007\n *\n * @param {Array} coordinates List of coordinates of a linear\n * ring. If the ring is oriented clockwise, the area will be positive,\n * otherwise it will be negative.\n * @param {number} radius The sphere radius.\n * @return {number} Area (in square meters).\n */\nfunction getAreaInternal(coordinates, radius) {\n let area = 0;\n const len = coordinates.length;\n let x1 = coordinates[len - 1][0];\n let y1 = coordinates[len - 1][1];\n for (let i = 0; i < len; i++) {\n const x2 = coordinates[i][0];\n const y2 = coordinates[i][1];\n area +=\n toRadians(x2 - x1) *\n (2 + Math.sin(toRadians(y1)) + Math.sin(toRadians(y2)));\n x1 = x2;\n y1 = y2;\n }\n return (area * radius * radius) / 2.0;\n}\n\n/**\n * Get the spherical area of a geometry. This is the area (in meters) assuming\n * that polygon edges are segments of great circles on a sphere.\n * @param {import(\"./geom/Geometry.js\").default} geometry A geometry.\n * @param {SphereMetricOptions} [options] Options for the area\n * calculation. By default, geometries are assumed to be in 'EPSG:3857'.\n * You can change this by providing a `projection` option.\n * @return {number} The spherical area (in square meters).\n * @api\n */\nexport function getArea(geometry, options) {\n options = options || {};\n const radius = options.radius || DEFAULT_RADIUS;\n const projection = options.projection || 'EPSG:3857';\n const type = geometry.getType();\n if (type !== 'GeometryCollection') {\n geometry = geometry.clone().transform(projection, 'EPSG:4326');\n }\n let area = 0;\n let coordinates, coords, i, ii, j, jj;\n switch (type) {\n case 'Point':\n case 'MultiPoint':\n case 'LineString':\n case 'MultiLineString':\n case 'LinearRing': {\n break;\n }\n case 'Polygon': {\n coordinates = /** @type {import(\"./geom/Polygon.js\").default} */ (\n geometry\n ).getCoordinates();\n area = Math.abs(getAreaInternal(coordinates[0], radius));\n for (i = 1, ii = coordinates.length; i < ii; ++i) {\n area -= Math.abs(getAreaInternal(coordinates[i], radius));\n }\n break;\n }\n case 'MultiPolygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n coords = coordinates[i];\n area += Math.abs(getAreaInternal(coords[0], radius));\n for (j = 1, jj = coords.length; j < jj; ++j) {\n area -= Math.abs(getAreaInternal(coords[j], radius));\n }\n }\n break;\n }\n case 'GeometryCollection': {\n const geometries =\n /** @type {import(\"./geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometries();\n for (i = 0, ii = geometries.length; i < ii; ++i) {\n area += getArea(geometries[i], options);\n }\n break;\n }\n default: {\n throw new Error('Unsupported geometry type: ' + type);\n }\n }\n return area;\n}\n\n/**\n * Returns the coordinate at the given distance and bearing from `c1`.\n *\n * @param {import(\"./coordinate.js\").Coordinate} c1 The origin point (`[lon, lat]` in degrees).\n * @param {number} distance The great-circle distance between the origin\n * point and the target point.\n * @param {number} bearing The bearing (in radians).\n * @param {number} [radius] The sphere radius to use. Defaults to the Earth's\n * mean radius using the WGS84 ellipsoid.\n * @return {import(\"./coordinate.js\").Coordinate} The target point.\n */\nexport function offset(c1, distance, bearing, radius) {\n radius = radius || DEFAULT_RADIUS;\n const lat1 = toRadians(c1[1]);\n const lon1 = toRadians(c1[0]);\n const dByR = distance / radius;\n const lat = Math.asin(\n Math.sin(lat1) * Math.cos(dByR) +\n Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing),\n );\n const lon =\n lon1 +\n Math.atan2(\n Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),\n Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat),\n );\n return [toDegrees(lon), toDegrees(lat)];\n}\n","/**\n * @module ol/console\n */\n\n/**\n * @typedef {'info'|'warn'|'error'|'none'} Level\n */\n\n/**\n * @type {Object}\n */\nconst levels = {\n info: 1,\n warn: 2,\n error: 3,\n none: 4,\n};\n\n/**\n * @type {number}\n */\nlet level = levels.info;\n\n/**\n * Set the logging level. By default, the level is set to 'info' and all\n * messages will be logged. Set to 'warn' to only display warnings and errors.\n * Set to 'error' to only display errors. Set to 'none' to silence all messages.\n *\n * @param {Level} l The new level.\n */\nexport function setLevel(l) {\n level = levels[l];\n}\n\n/**\n * @param {...any} args Arguments to log\n */\nexport function log(...args) {\n if (level > levels.info) {\n return;\n }\n console.log(...args); // eslint-disable-line no-console\n}\n\n/**\n * @param {...any} args Arguments to log\n */\nexport function warn(...args) {\n if (level > levels.warn) {\n return;\n }\n console.warn(...args); // eslint-disable-line no-console\n}\n\n/**\n * @param {...any} args Arguments to log\n */\nexport function error(...args) {\n if (level > levels.error) {\n return;\n }\n console.error(...args); // eslint-disable-line no-console\n}\n","/**\n * @module ol/proj\n */\n\n/**\n * The ol/proj module stores:\n * * a list of {@link module:ol/proj/Projection~Projection}\n * objects, one for each projection supported by the application\n * * a list of transform functions needed to convert coordinates in one projection\n * into another.\n *\n * The static functions are the methods used to maintain these.\n * Each transform function can handle not only simple coordinate pairs, but also\n * large arrays of coordinates such as vector geometries.\n *\n * When loaded, the library adds projection objects for EPSG:4326 (WGS84\n * geographic coordinates) and EPSG:3857 (Web or Spherical Mercator, as used\n * for example by Bing Maps or OpenStreetMap), together with the relevant\n * transform functions.\n *\n * Additional transforms may be added by using the http://proj4js.org/\n * library (version 2.2 or later). You can use the full build supplied by\n * Proj4js, or create a custom build to support those projections you need; see\n * the Proj4js website for how to do this. You also need the Proj4js definitions\n * for the required projections. These definitions can be obtained from\n * https://epsg.io/, and are a JS function, so can be loaded in a script\n * tag (as in the examples) or pasted into your application.\n *\n * After all required projection definitions are added to proj4's registry (by\n * using `proj4.defs()`), simply call `register(proj4)` from the `ol/proj/proj4`\n * package. Existing transforms are not changed by this function. See\n * examples/wms-image-custom-proj for an example of this.\n *\n * Additional projection definitions can be registered with `proj4.defs()` any\n * time. Just make sure to call `register(proj4)` again; for example, with user-supplied data where you don't\n * know in advance what projections are needed, you can initially load minimal\n * support and then load whichever are requested.\n *\n * Note that Proj4js does not support projection extents. If you want to add\n * one for creating default tile grids, you can add it after the Projection\n * object has been created with `setExtent`, for example,\n * `get('EPSG:1234').setExtent(extent)`.\n *\n * In addition to Proj4js support, any transform functions can be added with\n * {@link module:ol/proj.addCoordinateTransforms}. To use this, you must first create\n * a {@link module:ol/proj/Projection~Projection} object for the new projection and add it with\n * {@link module:ol/proj.addProjection}. You can then add the forward and inverse\n * functions with {@link module:ol/proj.addCoordinateTransforms}. See\n * examples/wms-custom-proj for an example of this.\n *\n * Note that if no transforms are needed and you only need to define the\n * projection, just add a {@link module:ol/proj/Projection~Projection} with\n * {@link module:ol/proj.addProjection}. See examples/wms-no-proj for an example of\n * this.\n */\nimport Projection from './proj/Projection.js';\nimport {\n PROJECTIONS as EPSG3857_PROJECTIONS,\n fromEPSG4326,\n toEPSG4326,\n} from './proj/epsg3857.js';\nimport {PROJECTIONS as EPSG4326_PROJECTIONS} from './proj/epsg4326.js';\nimport {METERS_PER_UNIT} from './proj/Units.js';\nimport {\n add as addProj,\n clear as clearProj,\n get as getProj,\n} from './proj/projections.js';\nimport {\n add as addTransformFunc,\n clear as clearTransformFuncs,\n get as getTransformFunc,\n} from './proj/transforms.js';\nimport {applyTransform, getWidth} from './extent.js';\nimport {clamp, modulo} from './math.js';\nimport {equals, getWorldsAway} from './coordinate.js';\nimport {getDistance} from './sphere.js';\nimport {warn} from './console.js';\n\n/**\n * A projection as {@link module:ol/proj/Projection~Projection}, SRS identifier\n * string or undefined.\n * @typedef {Projection|string|undefined} ProjectionLike\n * @api\n */\n\n/**\n * A transform function accepts an array of input coordinate values, an optional\n * output array, and an optional dimension (default should be 2). The function\n * transforms the input coordinate values, populates the output array, and\n * returns the output array.\n *\n * @typedef {function(Array, Array=, number=): Array} TransformFunction\n * @api\n */\n\nexport {METERS_PER_UNIT};\n\nexport {Projection};\n\nlet showCoordinateWarning = true;\n\n/**\n * @param {boolean} [disable = true] Disable console info about `useGeographic()`\n */\nexport function disableCoordinateWarning(disable) {\n const hide = disable === undefined ? true : disable;\n showCoordinateWarning = !hide;\n}\n\n/**\n * @param {Array} input Input coordinate array.\n * @param {Array} [output] Output array of coordinate values.\n * @return {Array} Output coordinate array (new array, same coordinate\n * values).\n */\nexport function cloneTransform(input, output) {\n if (output !== undefined) {\n for (let i = 0, ii = input.length; i < ii; ++i) {\n output[i] = input[i];\n }\n output = output;\n } else {\n output = input.slice();\n }\n return output;\n}\n\n/**\n * @param {Array} input Input coordinate array.\n * @param {Array} [output] Output array of coordinate values.\n * @return {Array} Input coordinate array (same array as input).\n */\nexport function identityTransform(input, output) {\n if (output !== undefined && input !== output) {\n for (let i = 0, ii = input.length; i < ii; ++i) {\n output[i] = input[i];\n }\n input = output;\n }\n return input;\n}\n\n/**\n * Add a Projection object to the list of supported projections that can be\n * looked up by their code.\n *\n * @param {Projection} projection Projection instance.\n * @api\n */\nexport function addProjection(projection) {\n addProj(projection.getCode(), projection);\n addTransformFunc(projection, projection, cloneTransform);\n}\n\n/**\n * @param {Array} projections Projections.\n */\nexport function addProjections(projections) {\n projections.forEach(addProjection);\n}\n\n/**\n * Fetches a Projection object for the code specified.\n *\n * @param {ProjectionLike} projectionLike Either a code string which is\n * a combination of authority and identifier such as \"EPSG:4326\", or an\n * existing projection object, or undefined.\n * @return {Projection|null} Projection object, or null if not in list.\n * @api\n */\nexport function get(projectionLike) {\n return typeof projectionLike === 'string'\n ? getProj(/** @type {string} */ (projectionLike))\n : /** @type {Projection} */ (projectionLike) || null;\n}\n\n/**\n * Get the resolution of the point in degrees or distance units.\n * For projections with degrees as the unit this will simply return the\n * provided resolution. For other projections the point resolution is\n * by default estimated by transforming the `point` pixel to EPSG:4326,\n * measuring its width and height on the normal sphere,\n * and taking the average of the width and height.\n * A custom function can be provided for a specific projection, either\n * by setting the `getPointResolution` option in the\n * {@link module:ol/proj/Projection~Projection} constructor or by using\n * {@link module:ol/proj/Projection~Projection#setGetPointResolution} to change an existing\n * projection object.\n * @param {ProjectionLike} projection The projection.\n * @param {number} resolution Nominal resolution in projection units.\n * @param {import(\"./coordinate.js\").Coordinate} point Point to find adjusted resolution at.\n * @param {import(\"./proj/Units.js\").Units} [units] Units to get the point resolution in.\n * Default is the projection's units.\n * @return {number} Point resolution.\n * @api\n */\nexport function getPointResolution(projection, resolution, point, units) {\n projection = get(projection);\n let pointResolution;\n const getter = projection.getPointResolutionFunc();\n if (getter) {\n pointResolution = getter(resolution, point);\n if (units && units !== projection.getUnits()) {\n const metersPerUnit = projection.getMetersPerUnit();\n if (metersPerUnit) {\n pointResolution =\n (pointResolution * metersPerUnit) / METERS_PER_UNIT[units];\n }\n }\n } else {\n const projUnits = projection.getUnits();\n if ((projUnits == 'degrees' && !units) || units == 'degrees') {\n pointResolution = resolution;\n } else {\n // Estimate point resolution by transforming the center pixel to EPSG:4326,\n // measuring its width and height on the normal sphere, and taking the\n // average of the width and height.\n const toEPSG4326 = getTransformFromProjections(\n projection,\n get('EPSG:4326'),\n );\n if (toEPSG4326 === identityTransform && projUnits !== 'degrees') {\n // no transform is available\n pointResolution = resolution * projection.getMetersPerUnit();\n } else {\n let vertices = [\n point[0] - resolution / 2,\n point[1],\n point[0] + resolution / 2,\n point[1],\n point[0],\n point[1] - resolution / 2,\n point[0],\n point[1] + resolution / 2,\n ];\n vertices = toEPSG4326(vertices, vertices, 2);\n const width = getDistance(vertices.slice(0, 2), vertices.slice(2, 4));\n const height = getDistance(vertices.slice(4, 6), vertices.slice(6, 8));\n pointResolution = (width + height) / 2;\n }\n const metersPerUnit = units\n ? METERS_PER_UNIT[units]\n : projection.getMetersPerUnit();\n if (metersPerUnit !== undefined) {\n pointResolution /= metersPerUnit;\n }\n }\n }\n return pointResolution;\n}\n\n/**\n * Registers transformation functions that don't alter coordinates. Those allow\n * to transform between projections with equal meaning.\n *\n * @param {Array} projections Projections.\n * @api\n */\nexport function addEquivalentProjections(projections) {\n addProjections(projections);\n projections.forEach(function (source) {\n projections.forEach(function (destination) {\n if (source !== destination) {\n addTransformFunc(source, destination, cloneTransform);\n }\n });\n });\n}\n\n/**\n * Registers transformation functions to convert coordinates in any projection\n * in projection1 to any projection in projection2.\n *\n * @param {Array} projections1 Projections with equal\n * meaning.\n * @param {Array} projections2 Projections with equal\n * meaning.\n * @param {TransformFunction} forwardTransform Transformation from any\n * projection in projection1 to any projection in projection2.\n * @param {TransformFunction} inverseTransform Transform from any projection\n * in projection2 to any projection in projection1..\n */\nexport function addEquivalentTransforms(\n projections1,\n projections2,\n forwardTransform,\n inverseTransform,\n) {\n projections1.forEach(function (projection1) {\n projections2.forEach(function (projection2) {\n addTransformFunc(projection1, projection2, forwardTransform);\n addTransformFunc(projection2, projection1, inverseTransform);\n });\n });\n}\n\n/**\n * Clear all cached projections and transforms.\n */\nexport function clearAllProjections() {\n clearProj();\n clearTransformFuncs();\n}\n\n/**\n * @param {Projection|string|undefined} projection Projection.\n * @param {string} defaultCode Default code.\n * @return {Projection} Projection.\n */\nexport function createProjection(projection, defaultCode) {\n if (!projection) {\n return get(defaultCode);\n }\n if (typeof projection === 'string') {\n return get(projection);\n }\n return /** @type {Projection} */ (projection);\n}\n\n/**\n * Creates a {@link module:ol/proj~TransformFunction} from a simple 2D coordinate transform\n * function.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} coordTransform Coordinate\n * transform.\n * @return {TransformFunction} Transform function.\n */\nexport function createTransformFromCoordinateTransform(coordTransform) {\n return (\n /**\n * @param {Array} input Input.\n * @param {Array} [output] Output.\n * @param {number} [dimension] Dimension.\n * @return {Array} Output.\n */\n function (input, output, dimension) {\n const length = input.length;\n dimension = dimension !== undefined ? dimension : 2;\n output = output !== undefined ? output : new Array(length);\n for (let i = 0; i < length; i += dimension) {\n const point = coordTransform(input.slice(i, i + dimension));\n const pointLength = point.length;\n for (let j = 0, jj = dimension; j < jj; ++j) {\n output[i + j] = j >= pointLength ? input[i + j] : point[j];\n }\n }\n return output;\n }\n );\n}\n\n/**\n * Registers coordinate transform functions to convert coordinates between the\n * source projection and the destination projection.\n * The forward and inverse functions convert coordinate pairs; this function\n * converts these into the functions used internally which also handle\n * extents and coordinate arrays.\n *\n * @param {ProjectionLike} source Source projection.\n * @param {ProjectionLike} destination Destination projection.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} forward The forward transform\n * function (that is, from the source projection to the destination\n * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns\n * the transformed {@link module:ol/coordinate~Coordinate}.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} inverse The inverse transform\n * function (that is, from the destination projection to the source\n * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns\n * the transformed {@link module:ol/coordinate~Coordinate}. If the transform function can only\n * transform less dimensions than the input coordinate, it is supposeed to return a coordinate\n * with only the length it can transform. The other dimensions will be taken unchanged from the\n * source.\n * @api\n */\nexport function addCoordinateTransforms(source, destination, forward, inverse) {\n const sourceProj = get(source);\n const destProj = get(destination);\n addTransformFunc(\n sourceProj,\n destProj,\n createTransformFromCoordinateTransform(forward),\n );\n addTransformFunc(\n destProj,\n sourceProj,\n createTransformFromCoordinateTransform(inverse),\n );\n}\n\n/**\n * Transforms a coordinate from longitude/latitude to a different projection.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate as longitude and latitude, i.e.\n * an array with longitude as 1st and latitude as 2nd element.\n * @param {ProjectionLike} [projection] Target projection. The\n * default is Web Mercator, i.e. 'EPSG:3857'.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate projected to the target projection.\n * @api\n */\nexport function fromLonLat(coordinate, projection) {\n disableCoordinateWarning();\n return transform(\n coordinate,\n 'EPSG:4326',\n projection !== undefined ? projection : 'EPSG:3857',\n );\n}\n\n/**\n * Transforms a coordinate to longitude/latitude.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Projected coordinate.\n * @param {ProjectionLike} [projection] Projection of the coordinate.\n * The default is Web Mercator, i.e. 'EPSG:3857'.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate as longitude and latitude, i.e. an array\n * with longitude as 1st and latitude as 2nd element.\n * @api\n */\nexport function toLonLat(coordinate, projection) {\n const lonLat = transform(\n coordinate,\n projection !== undefined ? projection : 'EPSG:3857',\n 'EPSG:4326',\n );\n const lon = lonLat[0];\n if (lon < -180 || lon > 180) {\n lonLat[0] = modulo(lon + 180, 360) - 180;\n }\n return lonLat;\n}\n\n/**\n * Checks if two projections are the same, that is every coordinate in one\n * projection does represent the same geographic point as the same coordinate in\n * the other projection.\n *\n * @param {Projection} projection1 Projection 1.\n * @param {Projection} projection2 Projection 2.\n * @return {boolean} Equivalent.\n * @api\n */\nexport function equivalent(projection1, projection2) {\n if (projection1 === projection2) {\n return true;\n }\n const equalUnits = projection1.getUnits() === projection2.getUnits();\n if (projection1.getCode() === projection2.getCode()) {\n return equalUnits;\n }\n const transformFunc = getTransformFromProjections(projection1, projection2);\n return transformFunc === cloneTransform && equalUnits;\n}\n\n/**\n * Searches in the list of transform functions for the function for converting\n * coordinates from the source projection to the destination projection.\n *\n * @param {Projection} sourceProjection Source Projection object.\n * @param {Projection} destinationProjection Destination Projection\n * object.\n * @return {TransformFunction} Transform function.\n */\nexport function getTransformFromProjections(\n sourceProjection,\n destinationProjection,\n) {\n const sourceCode = sourceProjection.getCode();\n const destinationCode = destinationProjection.getCode();\n let transformFunc = getTransformFunc(sourceCode, destinationCode);\n if (!transformFunc) {\n transformFunc = identityTransform;\n }\n return transformFunc;\n}\n\n/**\n * Given the projection-like objects, searches for a transformation\n * function to convert a coordinates array from the source projection to the\n * destination projection.\n *\n * @param {ProjectionLike} source Source.\n * @param {ProjectionLike} destination Destination.\n * @return {TransformFunction} Transform function.\n * @api\n */\nexport function getTransform(source, destination) {\n const sourceProjection = get(source);\n const destinationProjection = get(destination);\n return getTransformFromProjections(sourceProjection, destinationProjection);\n}\n\n/**\n * Transforms a coordinate from source projection to destination projection.\n * This returns a new coordinate (and does not modify the original).\n *\n * See {@link module:ol/proj.transformExtent} for extent transformation.\n * See the transform method of {@link module:ol/geom/Geometry~Geometry} and its\n * subclasses for geometry transforms.\n *\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {ProjectionLike} source Source projection-like.\n * @param {ProjectionLike} destination Destination projection-like.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate.\n * @api\n */\nexport function transform(coordinate, source, destination) {\n const transformFunc = getTransform(source, destination);\n return transformFunc(coordinate, undefined, coordinate.length);\n}\n\n/**\n * Transforms an extent from source projection to destination projection. This\n * returns a new extent (and does not modify the original).\n *\n * @param {import(\"./extent.js\").Extent} extent The extent to transform.\n * @param {ProjectionLike} source Source projection-like.\n * @param {ProjectionLike} destination Destination projection-like.\n * @param {number} [stops] Number of stops per side used for the transform.\n * By default only the corners are used.\n * @return {import(\"./extent.js\").Extent} The transformed extent.\n * @api\n */\nexport function transformExtent(extent, source, destination, stops) {\n const transformFunc = getTransform(source, destination);\n return applyTransform(extent, transformFunc, undefined, stops);\n}\n\n/**\n * Transforms the given point to the destination projection.\n *\n * @param {import(\"./coordinate.js\").Coordinate} point Point.\n * @param {Projection} sourceProjection Source projection.\n * @param {Projection} destinationProjection Destination projection.\n * @return {import(\"./coordinate.js\").Coordinate} Point.\n */\nexport function transformWithProjections(\n point,\n sourceProjection,\n destinationProjection,\n) {\n const transformFunc = getTransformFromProjections(\n sourceProjection,\n destinationProjection,\n );\n return transformFunc(point);\n}\n\n/**\n * @type {Projection|null}\n */\nlet userProjection = null;\n\n/**\n * Set the projection for coordinates supplied from and returned by API methods.\n * This includes all API methods except for those interacting with tile grids,\n * plus {@link import(\"./Map.js\").FrameState} and {@link import(\"./View.js\").State}.\n * @param {ProjectionLike} projection The user projection.\n * @api\n */\nexport function setUserProjection(projection) {\n userProjection = get(projection);\n}\n\n/**\n * Clear the user projection if set.\n * @api\n */\nexport function clearUserProjection() {\n userProjection = null;\n}\n\n/**\n * Get the projection for coordinates supplied from and returned by API methods.\n * @return {Projection|null} The user projection (or null if not set).\n * @api\n */\nexport function getUserProjection() {\n return userProjection;\n}\n\n/**\n * Use geographic coordinates (WGS-84 datum) in API methods.\n * This includes all API methods except for those interacting with tile grids,\n * plus {@link import(\"./Map.js\").FrameState} and {@link import(\"./View.js\").State}.\n * @api\n */\nexport function useGeographic() {\n setUserProjection('EPSG:4326');\n}\n\n/**\n * Return a coordinate transformed into the user projection. If no user projection\n * is set, the original coordinate is returned.\n * @param {Array} coordinate Input coordinate.\n * @param {ProjectionLike} sourceProjection The input coordinate projection.\n * @return {Array} The input coordinate in the user projection.\n */\nexport function toUserCoordinate(coordinate, sourceProjection) {\n if (!userProjection) {\n return coordinate;\n }\n return transform(coordinate, sourceProjection, userProjection);\n}\n\n/**\n * Return a coordinate transformed from the user projection. If no user projection\n * is set, the original coordinate is returned.\n * @param {Array} coordinate Input coordinate.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {Array} The input coordinate transformed.\n */\nexport function fromUserCoordinate(coordinate, destProjection) {\n if (!userProjection) {\n if (\n showCoordinateWarning &&\n !equals(coordinate, [0, 0]) &&\n coordinate[0] >= -180 &&\n coordinate[0] <= 180 &&\n coordinate[1] >= -90 &&\n coordinate[1] <= 90\n ) {\n showCoordinateWarning = false;\n warn(\n 'Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.',\n );\n }\n return coordinate;\n }\n return transform(coordinate, userProjection, destProjection);\n}\n\n/**\n * Return an extent transformed into the user projection. If no user projection\n * is set, the original extent is returned.\n * @param {import(\"./extent.js\").Extent} extent Input extent.\n * @param {ProjectionLike} sourceProjection The input extent projection.\n * @return {import(\"./extent.js\").Extent} The input extent in the user projection.\n */\nexport function toUserExtent(extent, sourceProjection) {\n if (!userProjection) {\n return extent;\n }\n return transformExtent(extent, sourceProjection, userProjection);\n}\n\n/**\n * Return an extent transformed from the user projection. If no user projection\n * is set, the original extent is returned.\n * @param {import(\"./extent.js\").Extent} extent Input extent.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {import(\"./extent.js\").Extent} The input extent transformed.\n */\nexport function fromUserExtent(extent, destProjection) {\n if (!userProjection) {\n return extent;\n }\n return transformExtent(extent, userProjection, destProjection);\n}\n\n/**\n * Return the resolution in user projection units per pixel. If no user projection\n * is set, or source or user projection are missing units, the original resolution\n * is returned.\n * @param {number} resolution Resolution in input projection units per pixel.\n * @param {ProjectionLike} sourceProjection The input projection.\n * @return {number} Resolution in user projection units per pixel.\n */\nexport function toUserResolution(resolution, sourceProjection) {\n if (!userProjection) {\n return resolution;\n }\n const sourceMetersPerUnit = get(sourceProjection).getMetersPerUnit();\n const userMetersPerUnit = userProjection.getMetersPerUnit();\n return sourceMetersPerUnit && userMetersPerUnit\n ? (resolution * sourceMetersPerUnit) / userMetersPerUnit\n : resolution;\n}\n\n/**\n * Return the resolution in user projection units per pixel. If no user projection\n * is set, or source or user projection are missing units, the original resolution\n * is returned.\n * @param {number} resolution Resolution in user projection units per pixel.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {number} Resolution in destination projection units per pixel.\n */\nexport function fromUserResolution(resolution, destProjection) {\n if (!userProjection) {\n return resolution;\n }\n const destMetersPerUnit = get(destProjection).getMetersPerUnit();\n const userMetersPerUnit = userProjection.getMetersPerUnit();\n return destMetersPerUnit && userMetersPerUnit\n ? (resolution * userMetersPerUnit) / destMetersPerUnit\n : resolution;\n}\n\n/**\n * Creates a safe coordinate transform function from a coordinate transform function.\n * \"Safe\" means that it can handle wrapping of x-coordinates for global projections,\n * and that coordinates exceeding the source projection validity extent's range will be\n * clamped to the validity range.\n * @param {Projection} sourceProj Source projection.\n * @param {Projection} destProj Destination projection.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} transform Transform function (source to destination).\n * @return {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} Safe transform function (source to destination).\n */\nexport function createSafeCoordinateTransform(sourceProj, destProj, transform) {\n return function (coord) {\n let transformed, worldsAway;\n if (sourceProj.canWrapX()) {\n const sourceExtent = sourceProj.getExtent();\n const sourceExtentWidth = getWidth(sourceExtent);\n coord = coord.slice(0);\n worldsAway = getWorldsAway(coord, sourceProj, sourceExtentWidth);\n if (worldsAway) {\n // Move x to the real world\n coord[0] = coord[0] - worldsAway * sourceExtentWidth;\n }\n coord[0] = clamp(coord[0], sourceExtent[0], sourceExtent[2]);\n coord[1] = clamp(coord[1], sourceExtent[1], sourceExtent[3]);\n transformed = transform(coord);\n } else {\n transformed = transform(coord);\n }\n if (worldsAway && destProj.canWrapX()) {\n // Move transformed coordinate back to the offset world\n transformed[0] += worldsAway * getWidth(destProj.getExtent());\n }\n return transformed;\n };\n}\n\n/**\n * Add transforms to and from EPSG:4326 and EPSG:3857. This function is called\n * by when this module is executed and should only need to be called again after\n * `clearAllProjections()` is called (e.g. in tests).\n */\nexport function addCommon() {\n // Add transformations that don't alter coordinates to convert within set of\n // projections with equal meaning.\n addEquivalentProjections(EPSG3857_PROJECTIONS);\n addEquivalentProjections(EPSG4326_PROJECTIONS);\n // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like\n // coordinates and back.\n addEquivalentTransforms(\n EPSG4326_PROJECTIONS,\n EPSG3857_PROJECTIONS,\n fromEPSG4326,\n toEPSG4326,\n );\n}\n\naddCommon();\n","/**\n * @module ol/geom/flat/transform\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../transform.js\").Transform} transform Transform.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function transform2D(\n flatCoordinates,\n offset,\n end,\n stride,\n transform,\n dest,\n) {\n dest = dest ? dest : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const x = flatCoordinates[j];\n const y = flatCoordinates[j + 1];\n dest[i++] = transform[0] * x + transform[2] * y + transform[4];\n dest[i++] = transform[1] * x + transform[3] * y + transform[5];\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} angle Angle.\n * @param {Array} anchor Rotation anchor point.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function rotate(\n flatCoordinates,\n offset,\n end,\n stride,\n angle,\n anchor,\n dest,\n) {\n dest = dest ? dest : [];\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const anchorX = anchor[0];\n const anchorY = anchor[1];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const deltaX = flatCoordinates[j] - anchorX;\n const deltaY = flatCoordinates[j + 1] - anchorY;\n dest[i++] = anchorX + deltaX * cos - deltaY * sin;\n dest[i++] = anchorY + deltaX * sin + deltaY * cos;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * Scale the coordinates.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} sx Scale factor in the x-direction.\n * @param {number} sy Scale factor in the y-direction.\n * @param {Array} anchor Scale anchor point.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function scale(\n flatCoordinates,\n offset,\n end,\n stride,\n sx,\n sy,\n anchor,\n dest,\n) {\n dest = dest ? dest : [];\n const anchorX = anchor[0];\n const anchorY = anchor[1];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const deltaX = flatCoordinates[j] - anchorX;\n const deltaY = flatCoordinates[j + 1] - anchorY;\n dest[i++] = anchorX + sx * deltaX;\n dest[i++] = anchorY + sy * deltaY;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function translate(\n flatCoordinates,\n offset,\n end,\n stride,\n deltaX,\n deltaY,\n dest,\n) {\n dest = dest ? dest : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n dest[i++] = flatCoordinates[j] + deltaX;\n dest[i++] = flatCoordinates[j + 1] + deltaY;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n","/**\n * @module ol/geom/Geometry\n */\nimport BaseObject from '../Object.js';\nimport {abstract} from '../util.js';\nimport {\n compose as composeTransform,\n create as createTransform,\n} from '../transform.js';\nimport {\n createEmpty,\n createOrUpdateEmpty,\n getHeight,\n returnOrUpdate,\n} from '../extent.js';\nimport {get as getProjection, getTransform} from '../proj.js';\nimport {memoizeOne} from '../functions.js';\nimport {transform2D} from './flat/transform.js';\n\n/**\n * @typedef {'XY' | 'XYZ' | 'XYM' | 'XYZM'} GeometryLayout\n * The coordinate layout for geometries, indicating whether a 3rd or 4th z ('Z')\n * or measure ('M') coordinate is available.\n */\n\n/**\n * @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | 'Circle'} Type\n * The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,\n * `'Polygon'`, `'MultiPoint'`, `'MultiLineString'`, `'MultiPolygon'`,\n * `'GeometryCollection'`, or `'Circle'`.\n */\n\n/**\n * @type {import(\"../transform.js\").Transform}\n */\nconst tmpTransform = createTransform();\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Base class for vector geometries.\n *\n * To get notified of changes to the geometry, register a listener for the\n * generic `change` event on your geometry instance.\n *\n * @abstract\n * @api\n */\nclass Geometry extends BaseObject {\n constructor() {\n super();\n\n /**\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.extent_ = createEmpty();\n\n /**\n * @private\n * @type {number}\n */\n this.extentRevision_ = -1;\n\n /**\n * @protected\n * @type {number}\n */\n this.simplifiedGeometryMaxMinSquaredTolerance = 0;\n\n /**\n * @protected\n * @type {number}\n */\n this.simplifiedGeometryRevision = 0;\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @abstract\n * @param {number} revision The geometry revision.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {Geometry} Simplified geometry.\n */\n this.simplifyTransformedInternal = memoizeOne(\n (revision, squaredTolerance, transform) => {\n if (!transform) {\n return this.getSimplifiedGeometry(squaredTolerance);\n }\n const clone = this.clone();\n clone.applyTransform(transform);\n return clone.getSimplifiedGeometry(squaredTolerance);\n },\n );\n }\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @abstract\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {Geometry} Simplified geometry.\n */\n simplifyTransformed(squaredTolerance, transform) {\n return this.simplifyTransformedInternal(\n this.getRevision(),\n squaredTolerance,\n transform,\n );\n }\n\n /**\n * Make a complete copy of the geometry.\n * @abstract\n * @return {!Geometry} Clone.\n */\n clone() {\n return abstract();\n }\n\n /**\n * @abstract\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n return abstract();\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\n containsXY(x, y) {\n const coord = this.getClosestPoint([x, y]);\n return coord[0] === x && coord[1] === y;\n }\n\n /**\n * Return the closest point of the geometry to the passed point as\n * {@link module:ol/coordinate~Coordinate coordinate}.\n * @param {import(\"../coordinate.js\").Coordinate} point Point.\n * @param {import(\"../coordinate.js\").Coordinate} [closestPoint] Closest point.\n * @return {import(\"../coordinate.js\").Coordinate} Closest point.\n * @api\n */\n getClosestPoint(point, closestPoint) {\n closestPoint = closestPoint ? closestPoint : [NaN, NaN];\n this.closestPointXY(point[0], point[1], closestPoint, Infinity);\n return closestPoint;\n }\n\n /**\n * Returns true if this geometry includes the specified coordinate. If the\n * coordinate is on the boundary of the geometry, returns false.\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} Contains coordinate.\n * @api\n */\n intersectsCoordinate(coordinate) {\n return this.containsXY(coordinate[0], coordinate[1]);\n }\n\n /**\n * @abstract\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return abstract();\n }\n\n /**\n * Get the extent of the geometry.\n * @param {import(\"../extent.js\").Extent} [extent] Extent.\n * @return {import(\"../extent.js\").Extent} extent Extent.\n * @api\n */\n getExtent(extent) {\n if (this.extentRevision_ != this.getRevision()) {\n const extent = this.computeExtent(this.extent_);\n if (isNaN(extent[0]) || isNaN(extent[1])) {\n createOrUpdateEmpty(extent);\n }\n this.extentRevision_ = this.getRevision();\n }\n return returnOrUpdate(this.extent_, extent);\n }\n\n /**\n * Rotate the geometry around a given coordinate. This modifies the geometry\n * coordinates in place.\n * @abstract\n * @param {number} angle Rotation angle in radians.\n * @param {import(\"../coordinate.js\").Coordinate} anchor The rotation center.\n * @api\n */\n rotate(angle, anchor) {\n abstract();\n }\n\n /**\n * Scale the geometry (with an optional origin). This modifies the geometry\n * coordinates in place.\n * @abstract\n * @param {number} sx The scaling factor in the x-direction.\n * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).\n * @param {import(\"../coordinate.js\").Coordinate} [anchor] The scale origin (defaults to the center\n * of the geometry extent).\n * @api\n */\n scale(sx, sy, anchor) {\n abstract();\n }\n\n /**\n * Create a simplified version of this geometry. For linestrings, this uses\n * the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)\n * algorithm. For polygons, a quantization-based\n * simplification is used to preserve topology.\n * @param {number} tolerance The tolerance distance for simplification.\n * @return {Geometry} A new, simplified version of the original geometry.\n * @api\n */\n simplify(tolerance) {\n return this.getSimplifiedGeometry(tolerance * tolerance);\n }\n\n /**\n * Create a simplified version of this geometry using the Douglas Peucker\n * algorithm.\n * See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.\n * @abstract\n * @param {number} squaredTolerance Squared tolerance.\n * @return {Geometry} Simplified geometry.\n */\n getSimplifiedGeometry(squaredTolerance) {\n return abstract();\n }\n\n /**\n * Get the type of this geometry.\n * @abstract\n * @return {Type} Geometry type.\n */\n getType() {\n return abstract();\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @abstract\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n * Called with a flat array of geometry coordinates.\n */\n applyTransform(transformFn) {\n abstract();\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @abstract\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n */\n intersectsExtent(extent) {\n return abstract();\n }\n\n /**\n * Translate the geometry. This modifies the geometry coordinates in place. If\n * instead you want a new geometry, first `clone()` this geometry.\n * @abstract\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @api\n */\n translate(deltaX, deltaY) {\n abstract();\n }\n\n /**\n * Transform each coordinate of the geometry from one coordinate reference\n * system to another. The geometry is modified in place.\n * For example, a line will be transformed to a line and a circle to a circle.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n *\n * @param {import(\"../proj.js\").ProjectionLike} source The current projection. Can be a\n * string identifier or a {@link module:ol/proj/Projection~Projection} object.\n * @param {import(\"../proj.js\").ProjectionLike} destination The desired projection. Can be a\n * string identifier or a {@link module:ol/proj/Projection~Projection} object.\n * @return {this} This geometry. Note that original geometry is\n * modified in place.\n * @api\n */\n transform(source, destination) {\n /** @type {import(\"../proj/Projection.js\").default} */\n const sourceProj = getProjection(source);\n const transformFn =\n sourceProj.getUnits() == 'tile-pixels'\n ? function (inCoordinates, outCoordinates, stride) {\n const pixelExtent = sourceProj.getExtent();\n const projectedExtent = sourceProj.getWorldExtent();\n const scale = getHeight(projectedExtent) / getHeight(pixelExtent);\n composeTransform(\n tmpTransform,\n projectedExtent[0],\n projectedExtent[3],\n scale,\n -scale,\n 0,\n 0,\n 0,\n );\n transform2D(\n inCoordinates,\n 0,\n inCoordinates.length,\n stride,\n tmpTransform,\n outCoordinates,\n );\n return getTransform(sourceProj, destination)(\n inCoordinates,\n outCoordinates,\n stride,\n );\n }\n : getTransform(sourceProj, destination);\n this.applyTransform(transformFn);\n return this;\n }\n}\n\nexport default Geometry;\n","/**\n * @module ol/geom/SimpleGeometry\n */\nimport Geometry from './Geometry.js';\nimport {abstract} from '../util.js';\nimport {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';\nimport {rotate, scale, transform2D, translate} from './flat/transform.js';\n\n/**\n * @classdesc\n * Abstract base class; only used for creating subclasses; do not instantiate\n * in apps, as cannot be rendered.\n *\n * @abstract\n * @api\n */\nclass SimpleGeometry extends Geometry {\n constructor() {\n super();\n\n /**\n * @protected\n * @type {import(\"./Geometry.js\").GeometryLayout}\n */\n this.layout = 'XY';\n\n /**\n * @protected\n * @type {number}\n */\n this.stride = 2;\n\n /**\n * @protected\n * @type {Array}\n */\n this.flatCoordinates;\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return createOrUpdateFromFlatCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n extent,\n );\n }\n\n /**\n * @abstract\n * @return {Array<*> | null} Coordinates.\n */\n getCoordinates() {\n return abstract();\n }\n\n /**\n * Return the first coordinate of the geometry.\n * @return {import(\"../coordinate.js\").Coordinate} First coordinate.\n * @api\n */\n getFirstCoordinate() {\n return this.flatCoordinates.slice(0, this.stride);\n }\n\n /**\n * @return {Array} Flat coordinates.\n */\n getFlatCoordinates() {\n return this.flatCoordinates;\n }\n\n /**\n * Return the last coordinate of the geometry.\n * @return {import(\"../coordinate.js\").Coordinate} Last point.\n * @api\n */\n getLastCoordinate() {\n return this.flatCoordinates.slice(\n this.flatCoordinates.length - this.stride,\n );\n }\n\n /**\n * Return the {@link import(\"./Geometry.js\").GeometryLayout layout} of the geometry.\n * @return {import(\"./Geometry.js\").GeometryLayout} Layout.\n * @api\n */\n getLayout() {\n return this.layout;\n }\n\n /**\n * Create a simplified version of this geometry using the Douglas Peucker algorithm.\n * @param {number} squaredTolerance Squared tolerance.\n * @return {SimpleGeometry} Simplified geometry.\n */\n getSimplifiedGeometry(squaredTolerance) {\n if (this.simplifiedGeometryRevision !== this.getRevision()) {\n this.simplifiedGeometryMaxMinSquaredTolerance = 0;\n this.simplifiedGeometryRevision = this.getRevision();\n }\n // If squaredTolerance is negative or if we know that simplification will not\n // have any effect then just return this.\n if (\n squaredTolerance < 0 ||\n (this.simplifiedGeometryMaxMinSquaredTolerance !== 0 &&\n squaredTolerance <= this.simplifiedGeometryMaxMinSquaredTolerance)\n ) {\n return this;\n }\n\n const simplifiedGeometry =\n this.getSimplifiedGeometryInternal(squaredTolerance);\n const simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();\n if (simplifiedFlatCoordinates.length < this.flatCoordinates.length) {\n return simplifiedGeometry;\n }\n // Simplification did not actually remove any coordinates. We now know\n // that any calls to getSimplifiedGeometry with a squaredTolerance less\n // than or equal to the current squaredTolerance will also not have any\n // effect. This allows us to short circuit simplification (saving CPU\n // cycles) and prevents the cache of simplified geometries from filling\n // up with useless identical copies of this geometry (saving memory).\n this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;\n return this;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {SimpleGeometry} Simplified geometry.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n return this;\n }\n\n /**\n * @return {number} Stride.\n */\n getStride() {\n return this.stride;\n }\n\n /**\n * @param {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n * @param {Array} flatCoordinates Flat coordinates.\n */\n setFlatCoordinates(layout, flatCoordinates) {\n this.stride = getStrideForLayout(layout);\n this.layout = layout;\n this.flatCoordinates = flatCoordinates;\n }\n\n /**\n * @abstract\n * @param {!Array<*>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n setCoordinates(coordinates, layout) {\n abstract();\n }\n\n /**\n * @param {import(\"./Geometry.js\").GeometryLayout|undefined} layout Layout.\n * @param {Array<*>} coordinates Coordinates.\n * @param {number} nesting Nesting.\n * @protected\n */\n setLayout(layout, coordinates, nesting) {\n let stride;\n if (layout) {\n stride = getStrideForLayout(layout);\n } else {\n for (let i = 0; i < nesting; ++i) {\n if (coordinates.length === 0) {\n this.layout = 'XY';\n this.stride = 2;\n return;\n }\n coordinates = /** @type {Array} */ (coordinates[0]);\n }\n stride = coordinates.length;\n layout = getLayoutForStride(stride);\n }\n this.layout = layout;\n this.stride = stride;\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n * Called with a flat array of geometry coordinates.\n * @api\n */\n applyTransform(transformFn) {\n if (this.flatCoordinates) {\n transformFn(this.flatCoordinates, this.flatCoordinates, this.stride);\n this.changed();\n }\n }\n\n /**\n * Rotate the geometry around a given coordinate. This modifies the geometry\n * coordinates in place.\n * @param {number} angle Rotation angle in counter-clockwise radians.\n * @param {import(\"../coordinate.js\").Coordinate} anchor The rotation center.\n * @api\n */\n rotate(angle, anchor) {\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n rotate(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n angle,\n anchor,\n flatCoordinates,\n );\n this.changed();\n }\n }\n\n /**\n * Scale the geometry (with an optional origin). This modifies the geometry\n * coordinates in place.\n * @param {number} sx The scaling factor in the x-direction.\n * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).\n * @param {import(\"../coordinate.js\").Coordinate} [anchor] The scale origin (defaults to the center\n * of the geometry extent).\n * @api\n */\n scale(sx, sy, anchor) {\n if (sy === undefined) {\n sy = sx;\n }\n if (!anchor) {\n anchor = getCenter(this.getExtent());\n }\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n scale(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n sx,\n sy,\n anchor,\n flatCoordinates,\n );\n this.changed();\n }\n }\n\n /**\n * Translate the geometry. This modifies the geometry coordinates in place. If\n * instead you want a new geometry, first `clone()` this geometry.\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @api\n */\n translate(deltaX, deltaY) {\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n translate(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n deltaX,\n deltaY,\n flatCoordinates,\n );\n this.changed();\n }\n }\n}\n\n/**\n * @param {number} stride Stride.\n * @return {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n */\nexport function getLayoutForStride(stride) {\n let layout;\n if (stride == 2) {\n layout = 'XY';\n } else if (stride == 3) {\n layout = 'XYZ';\n } else if (stride == 4) {\n layout = 'XYZM';\n }\n return /** @type {import(\"./Geometry.js\").GeometryLayout} */ (layout);\n}\n\n/**\n * @param {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n * @return {number} Stride.\n */\nexport function getStrideForLayout(layout) {\n let stride;\n if (layout == 'XY') {\n stride = 2;\n } else if (layout == 'XYZ' || layout == 'XYM') {\n stride = 3;\n } else if (layout == 'XYZM') {\n stride = 4;\n }\n return /** @type {number} */ (stride);\n}\n\n/**\n * @param {SimpleGeometry} simpleGeometry Simple geometry.\n * @param {import(\"../transform.js\").Transform} transform Transform.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed flat coordinates.\n */\nexport function transformGeom2D(simpleGeometry, transform, dest) {\n const flatCoordinates = simpleGeometry.getFlatCoordinates();\n if (!flatCoordinates) {\n return null;\n }\n const stride = simpleGeometry.getStride();\n return transform2D(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n transform,\n dest,\n );\n}\n\nexport default SimpleGeometry;\n","/**\n * @module ol/geom/flat/closest\n */\nimport {lerp, squaredDistance as squaredDx} from '../../math.js';\n\n/**\n * Returns the point on the 2D line segment flatCoordinates[offset1] to\n * flatCoordinates[offset2] that is closest to the point (x, y). Extra\n * dimensions are linearly interpolated.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset1 Offset 1.\n * @param {number} offset2 Offset 2.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n */\nfunction assignClosest(\n flatCoordinates,\n offset1,\n offset2,\n stride,\n x,\n y,\n closestPoint,\n) {\n const x1 = flatCoordinates[offset1];\n const y1 = flatCoordinates[offset1 + 1];\n const dx = flatCoordinates[offset2] - x1;\n const dy = flatCoordinates[offset2 + 1] - y1;\n let offset;\n if (dx === 0 && dy === 0) {\n offset = offset1;\n } else {\n const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n offset = offset2;\n } else if (t > 0) {\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = lerp(\n flatCoordinates[offset1 + i],\n flatCoordinates[offset2 + i],\n t,\n );\n }\n closestPoint.length = stride;\n return;\n } else {\n offset = offset1;\n }\n }\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[offset + i];\n }\n closestPoint.length = stride;\n}\n\n/**\n * Return the squared of the largest distance between any pair of consecutive\n * coordinates.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function maxSquaredDelta(flatCoordinates, offset, end, stride, max) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n for (offset += stride; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n const squaredDelta = squaredDx(x1, y1, x2, y2);\n if (squaredDelta > max) {\n max = squaredDelta;\n }\n x1 = x2;\n y1 = y2;\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function arrayMaxSquaredDelta(\n flatCoordinates,\n offset,\n ends,\n stride,\n max,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n max = maxSquaredDelta(flatCoordinates, offset, end, stride, max);\n offset = end;\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function multiArrayMaxSquaredDelta(\n flatCoordinates,\n offset,\n endss,\n stride,\n max,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n max = arrayMaxSquaredDelta(flatCoordinates, offset, ends, stride, max);\n offset = ends[ends.length - 1];\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestPoint(\n flatCoordinates,\n offset,\n end,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n) {\n if (offset == end) {\n return minSquaredDistance;\n }\n let i, squaredDistance;\n if (maxDelta === 0) {\n // All points are identical, so just test the first point.\n squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[offset],\n flatCoordinates[offset + 1],\n );\n if (squaredDistance < minSquaredDistance) {\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[offset + i];\n }\n closestPoint.length = stride;\n return squaredDistance;\n }\n return minSquaredDistance;\n }\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n let index = offset + stride;\n while (index < end) {\n assignClosest(\n flatCoordinates,\n index - stride,\n index,\n stride,\n x,\n y,\n tmpPoint,\n );\n squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = tmpPoint[i];\n }\n closestPoint.length = stride;\n index += stride;\n } else {\n // Skip ahead multiple points, because we know that all the skipped\n // points cannot be any closer than the closest point we have found so\n // far. We know this because we know how close the current point is, how\n // close the closest point we have found so far is, and the maximum\n // distance between consecutive points. For example, if we're currently\n // at distance 10, the best we've found so far is 3, and that the maximum\n // distance between consecutive points is 2, then we'll need to skip at\n // least (10 - 3) / 2 == 3 (rounded down) points to have any chance of\n // finding a closer point. We use Math.max(..., 1) to ensure that we\n // always advance at least one point, to avoid an infinite loop.\n index +=\n stride *\n Math.max(\n ((Math.sqrt(squaredDistance) - Math.sqrt(minSquaredDistance)) /\n maxDelta) |\n 0,\n 1,\n );\n }\n }\n if (isRing) {\n // Check the closing segment.\n assignClosest(\n flatCoordinates,\n end - stride,\n offset,\n stride,\n x,\n y,\n tmpPoint,\n );\n squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = tmpPoint[i];\n }\n closestPoint.length = stride;\n }\n }\n return minSquaredDistance;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestArrayPoint(\n flatCoordinates,\n offset,\n ends,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n) {\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n minSquaredDistance = assignClosestPoint(\n flatCoordinates,\n offset,\n end,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n );\n offset = end;\n }\n return minSquaredDistance;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestMultiArrayPoint(\n flatCoordinates,\n offset,\n endss,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n) {\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n minSquaredDistance = assignClosestArrayPoint(\n flatCoordinates,\n offset,\n ends,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n );\n offset = ends[ends.length - 1];\n }\n return minSquaredDistance;\n}\n","/**\n * @module ol/geom/flat/deflate\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {import(\"../../coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {number} stride Stride.\n * @return {number} offset Offset.\n */\nexport function deflateCoordinate(flatCoordinates, offset, coordinate, stride) {\n for (let i = 0, ii = coordinate.length; i < ii; ++i) {\n flatCoordinates[offset++] = coordinate[i];\n }\n return offset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} coordinates Coordinates.\n * @param {number} stride Stride.\n * @return {number} offset Offset.\n */\nexport function deflateCoordinates(\n flatCoordinates,\n offset,\n coordinates,\n stride,\n) {\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n const coordinate = coordinates[i];\n for (let j = 0; j < stride; ++j) {\n flatCoordinates[offset++] = coordinate[j];\n }\n }\n return offset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} coordinatess Coordinatess.\n * @param {number} stride Stride.\n * @param {Array} [ends] Ends.\n * @return {Array} Ends.\n */\nexport function deflateCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatess,\n stride,\n ends,\n) {\n ends = ends ? ends : [];\n let i = 0;\n for (let j = 0, jj = coordinatess.length; j < jj; ++j) {\n const end = deflateCoordinates(\n flatCoordinates,\n offset,\n coordinatess[j],\n stride,\n );\n ends[i++] = end;\n offset = end;\n }\n ends.length = i;\n return ends;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>>} coordinatesss Coordinatesss.\n * @param {number} stride Stride.\n * @param {Array>} [endss] Endss.\n * @return {Array>} Endss.\n */\nexport function deflateMultiCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatesss,\n stride,\n endss,\n) {\n endss = endss ? endss : [];\n let i = 0;\n for (let j = 0, jj = coordinatesss.length; j < jj; ++j) {\n const ends = deflateCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatesss[j],\n stride,\n endss[i],\n );\n if (ends.length === 0) {\n ends[0] = offset;\n }\n endss[i++] = ends;\n offset = ends[ends.length - 1];\n }\n endss.length = i;\n return endss;\n}\n","/**\n * @module ol/geom/flat/simplify\n */\n// Based on simplify-js https://github.com/mourner/simplify-js\n// Copyright (c) 2012, Vladimir Agafonkin\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n//\n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n//\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n// POSSIBILITY OF SUCH DAMAGE.\n\nimport {squaredDistance, squaredSegmentDistance} from '../../math.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {boolean} highQuality Highest quality.\n * @param {Array} [simplifiedFlatCoordinates] Simplified flat\n * coordinates.\n * @return {Array} Simplified line string.\n */\nexport function simplifyLineString(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n highQuality,\n simplifiedFlatCoordinates,\n) {\n simplifiedFlatCoordinates =\n simplifiedFlatCoordinates !== undefined ? simplifiedFlatCoordinates : [];\n if (!highQuality) {\n end = radialDistance(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n flatCoordinates = simplifiedFlatCoordinates;\n offset = 0;\n stride = 2;\n }\n simplifiedFlatCoordinates.length = douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n return simplifiedFlatCoordinates;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n) {\n const n = (end - offset) / stride;\n if (n < 3) {\n for (; offset < end; offset += stride) {\n simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + 1];\n }\n return simplifiedOffset;\n }\n /** @type {Array} */\n const markers = new Array(n);\n markers[0] = 1;\n markers[n - 1] = 1;\n /** @type {Array} */\n const stack = [offset, end - stride];\n let index = 0;\n while (stack.length > 0) {\n const last = stack.pop();\n const first = stack.pop();\n let maxSquaredDistance = 0;\n const x1 = flatCoordinates[first];\n const y1 = flatCoordinates[first + 1];\n const x2 = flatCoordinates[last];\n const y2 = flatCoordinates[last + 1];\n for (let i = first + stride; i < last; i += stride) {\n const x = flatCoordinates[i];\n const y = flatCoordinates[i + 1];\n const squaredDistance = squaredSegmentDistance(x, y, x1, y1, x2, y2);\n if (squaredDistance > maxSquaredDistance) {\n index = i;\n maxSquaredDistance = squaredDistance;\n }\n }\n if (maxSquaredDistance > squaredTolerance) {\n markers[(index - offset) / stride] = 1;\n if (first + stride < index) {\n stack.push(first, index);\n }\n if (index + stride < last) {\n stack.push(index, last);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (markers[i]) {\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + i * stride];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + i * stride + 1];\n }\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array} simplifiedEnds Simplified ends.\n * @return {number} Simplified offset.\n */\nexport function douglasPeuckerArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n simplifiedOffset = douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n );\n simplifiedEnds.push(simplifiedOffset);\n offset = end;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array>} simplifiedEndss Simplified endss.\n * @return {number} Simplified offset.\n */\nexport function douglasPeuckerMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEndss,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedOffset = douglasPeuckerArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n );\n simplifiedEndss.push(simplifiedEnds);\n offset = ends[ends.length - 1];\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function radialDistance(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n) {\n if (end <= offset + stride) {\n // zero or one point, no simplification possible, so copy and return\n for (; offset < end; offset += stride) {\n simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + 1];\n }\n return simplifiedOffset;\n }\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n // copy first point\n simplifiedFlatCoordinates[simplifiedOffset++] = x1;\n simplifiedFlatCoordinates[simplifiedOffset++] = y1;\n let x2 = x1;\n let y2 = y1;\n for (offset += stride; offset < end; offset += stride) {\n x2 = flatCoordinates[offset];\n y2 = flatCoordinates[offset + 1];\n if (squaredDistance(x1, y1, x2, y2) > squaredTolerance) {\n // copy point at offset\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n x1 = x2;\n y1 = y2;\n }\n }\n if (x2 != x1 || y2 != y1) {\n // copy last point\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {number} value Value.\n * @param {number} tolerance Tolerance.\n * @return {number} Rounded value.\n */\nexport function snap(value, tolerance) {\n return tolerance * Math.round(value / tolerance);\n}\n\n/**\n * Simplifies a line string using an algorithm designed by Tim Schaub.\n * Coordinates are snapped to the nearest value in a virtual grid and\n * consecutive duplicate coordinates are discarded. This effectively preserves\n * topology as the simplification of any subsection of a line string is\n * independent of the rest of the line string. This means that, for examples,\n * the common edge between two polygons will be simplified to the same line\n * string independently in both polygons. This implementation uses a single\n * pass over the coordinates and eliminates intermediate collinear points.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function quantize(\n flatCoordinates,\n offset,\n end,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n) {\n // do nothing if the line is empty\n if (offset == end) {\n return simplifiedOffset;\n }\n // snap the first coordinate (P1)\n let x1 = snap(flatCoordinates[offset], tolerance);\n let y1 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n // add the first coordinate to the output\n simplifiedFlatCoordinates[simplifiedOffset++] = x1;\n simplifiedFlatCoordinates[simplifiedOffset++] = y1;\n // find the next coordinate that does not snap to the same value as the first\n // coordinate (P2)\n let x2, y2;\n do {\n x2 = snap(flatCoordinates[offset], tolerance);\n y2 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n if (offset == end) {\n // all coordinates snap to the same value, the line collapses to a point\n // push the last snapped value anyway to ensure that the output contains\n // at least two points\n // FIXME should we really return at least two points anyway?\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n return simplifiedOffset;\n }\n } while (x2 == x1 && y2 == y1);\n while (offset < end) {\n // snap the next coordinate (P3)\n const x3 = snap(flatCoordinates[offset], tolerance);\n const y3 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n // skip P3 if it is equal to P2\n if (x3 == x2 && y3 == y2) {\n continue;\n }\n // calculate the delta between P1 and P2\n const dx1 = x2 - x1;\n const dy1 = y2 - y1;\n // calculate the delta between P3 and P1\n const dx2 = x3 - x1;\n const dy2 = y3 - y1;\n // if P1, P2, and P3 are colinear and P3 is further from P1 than P2 is from\n // P1 in the same direction then P2 is on the straight line between P1 and\n // P3\n if (\n dx1 * dy2 == dy1 * dx2 &&\n ((dx1 < 0 && dx2 < dx1) || dx1 == dx2 || (dx1 > 0 && dx2 > dx1)) &&\n ((dy1 < 0 && dy2 < dy1) || dy1 == dy2 || (dy1 > 0 && dy2 > dy1))\n ) {\n // discard P2 and set P2 = P3\n x2 = x3;\n y2 = y3;\n continue;\n }\n // either P1, P2, and P3 are not colinear, or they are colinear but P3 is\n // between P3 and P1 or on the opposite half of the line to P2. add P2,\n // and continue with P1 = P2 and P2 = P3\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n x1 = x2;\n y1 = y2;\n x2 = x3;\n y2 = y3;\n }\n // add the last point (P2)\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array} simplifiedEnds Simplified ends.\n * @return {number} Simplified offset.\n */\nexport function quantizeArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n simplifiedOffset = quantize(\n flatCoordinates,\n offset,\n end,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n );\n simplifiedEnds.push(simplifiedOffset);\n offset = end;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array>} simplifiedEndss Simplified endss.\n * @return {number} Simplified offset.\n */\nexport function quantizeMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEndss,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedOffset = quantizeArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n );\n simplifiedEndss.push(simplifiedEnds);\n offset = ends[ends.length - 1];\n }\n return simplifiedOffset;\n}\n","/**\n * @module ol/geom/flat/inflate\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {Array} [coordinates] Coordinates.\n * @return {Array} Coordinates.\n */\nexport function inflateCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinates,\n) {\n coordinates = coordinates !== undefined ? coordinates : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n coordinates[i++] = flatCoordinates.slice(j, j + stride);\n }\n coordinates.length = i;\n return coordinates;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {Array>} [coordinatess] Coordinatess.\n * @return {Array>} Coordinatess.\n */\nexport function inflateCoordinatesArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n coordinatess,\n) {\n coordinatess = coordinatess !== undefined ? coordinatess : [];\n let i = 0;\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n const end = ends[j];\n coordinatess[i++] = inflateCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinatess[i],\n );\n offset = end;\n }\n coordinatess.length = i;\n return coordinatess;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {Array>>} [coordinatesss]\n * Coordinatesss.\n * @return {Array>>} Coordinatesss.\n */\nexport function inflateMultiCoordinatesArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n coordinatesss,\n) {\n coordinatesss = coordinatesss !== undefined ? coordinatesss : [];\n let i = 0;\n for (let j = 0, jj = endss.length; j < jj; ++j) {\n const ends = endss[j];\n coordinatesss[i++] =\n ends.length === 1 && ends[0] === offset\n ? []\n : inflateCoordinatesArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n coordinatesss[i],\n );\n offset = ends[ends.length - 1];\n }\n coordinatesss.length = i;\n return coordinatesss;\n}\n","/**\n * @module ol/geom/flat/area\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRing(flatCoordinates, offset, end, stride) {\n let twiceArea = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n twiceArea += y1 * x2 - x1 * y2;\n x1 = x2;\n y1 = y2;\n }\n return twiceArea / 2;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRings(flatCoordinates, offset, ends, stride) {\n let area = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n area += linearRing(flatCoordinates, offset, end, stride);\n offset = end;\n }\n return area;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRingss(flatCoordinates, offset, endss, stride) {\n let area = 0;\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n area += linearRings(flatCoordinates, offset, ends, stride);\n offset = ends[ends.length - 1];\n }\n return area;\n}\n","/**\n * @module ol/geom/LinearRing\n */\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport {deflateCoordinates} from './flat/deflate.js';\nimport {douglasPeucker} from './flat/simplify.js';\nimport {inflateCoordinates} from './flat/inflate.js';\nimport {linearRing as linearRingArea} from './flat/area.js';\n\n/**\n * @classdesc\n * Linear ring geometry. Only used as part of polygon; cannot be rendered\n * on its own.\n *\n * @api\n */\nclass LinearRing extends SimpleGeometry {\n /**\n * @param {Array|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n if (layout !== undefined && !Array.isArray(coordinates[0])) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n } else {\n this.setCoordinates(\n /** @type {Array} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!LinearRing} Clone.\n * @api\n */\n clone() {\n return new LinearRing(this.flatCoordinates.slice(), this.layout);\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n maxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestPoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * Return the area of the linear ring on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingArea(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * Return the coordinates of the linear ring.\n * @return {Array} Coordinates.\n * @api\n */\n getCoordinates() {\n return inflateCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {LinearRing} Simplified LinearRing.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n simplifiedFlatCoordinates.length = douglasPeucker(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n return new LinearRing(simplifiedFlatCoordinates, 'XY');\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'LinearRing';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return false;\n }\n\n /**\n * Set the coordinates of the linear ring.\n * @param {!Array} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 1);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinates(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n );\n this.changed();\n }\n}\n\nexport default LinearRing;\n","/**\n * @module ol/geom/Point\n */\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {containsXY, createOrUpdateFromCoordinate} from '../extent.js';\nimport {deflateCoordinate} from './flat/deflate.js';\nimport {squaredDistance as squaredDx} from '../math.js';\n\n/**\n * @classdesc\n * Point geometry.\n *\n * @api\n */\nclass Point extends SimpleGeometry {\n /**\n * @param {import(\"../coordinate.js\").Coordinate} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n this.setCoordinates(coordinates, layout);\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!Point} Clone.\n * @api\n */\n clone() {\n const point = new Point(this.flatCoordinates.slice(), this.layout);\n point.applyProperties(this);\n return point;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n const flatCoordinates = this.flatCoordinates;\n const squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[0],\n flatCoordinates[1],\n );\n if (squaredDistance < minSquaredDistance) {\n const stride = this.stride;\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[i];\n }\n closestPoint.length = stride;\n return squaredDistance;\n }\n return minSquaredDistance;\n }\n\n /**\n * Return the coordinate of the point.\n * @return {import(\"../coordinate.js\").Coordinate} Coordinates.\n * @api\n */\n getCoordinates() {\n return this.flatCoordinates.slice();\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return createOrUpdateFromCoordinate(this.flatCoordinates, extent);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'Point';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return containsXY(extent, this.flatCoordinates[0], this.flatCoordinates[1]);\n }\n\n /**\n * @param {!Array<*>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 0);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinate(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n );\n this.changed();\n }\n}\n\nexport default Point;\n","/**\n * @module ol/geom/flat/contains\n */\nimport {forEachCorner} from '../../extent.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} Contains extent.\n */\nexport function linearRingContainsExtent(\n flatCoordinates,\n offset,\n end,\n stride,\n extent,\n) {\n const outside = forEachCorner(\n extent,\n /**\n * @param {import(\"../../coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} Contains (x, y).\n */\n function (coordinate) {\n return !linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinate[0],\n coordinate[1],\n );\n },\n );\n return !outside;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n x,\n y,\n) {\n // https://geomalgorithms.com/a03-_inclusion.html\n // Copyright 2000 softSurfer, 2012 Dan Sunday\n // This code may be freely used and modified for any purpose\n // providing that this copyright notice is included with it.\n // SoftSurfer makes no warranty for this code, and cannot be held\n // liable for any real or imagined damage resulting from its use.\n // Users of this code must verify correctness for their application.\n let wn = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n if (y1 <= y) {\n if (y2 > y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) > 0) {\n wn++;\n }\n } else if (y2 <= y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) < 0) {\n wn--;\n }\n x1 = x2;\n y1 = y2;\n }\n return wn !== 0;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingsContainsXY(\n flatCoordinates,\n offset,\n ends,\n stride,\n x,\n y,\n) {\n if (ends.length === 0) {\n return false;\n }\n if (!linearRingContainsXY(flatCoordinates, offset, ends[0], stride, x, y)) {\n return false;\n }\n for (let i = 1, ii = ends.length; i < ii; ++i) {\n if (\n linearRingContainsXY(flatCoordinates, ends[i - 1], ends[i], stride, x, y)\n ) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingssContainsXY(\n flatCoordinates,\n offset,\n endss,\n stride,\n x,\n y,\n) {\n if (endss.length === 0) {\n return false;\n }\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {\n return true;\n }\n offset = ends[ends.length - 1];\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/interiorpoint\n */\nimport {ascending} from '../../array.js';\nimport {linearRingsContainsXY} from './contains.js';\n\n/**\n * Calculates a point that is likely to lie in the interior of the linear rings.\n * Inspired by JTS's com.vividsolutions.jts.geom.Geometry#getInteriorPoint.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {Array} flatCenters Flat centers.\n * @param {number} flatCentersOffset Flat center offset.\n * @param {Array} [dest] Destination.\n * @return {Array} Destination point as XYM coordinate, where M is the\n * length of the horizontal intersection that the point belongs to.\n */\nexport function getInteriorPointOfArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n flatCenters,\n flatCentersOffset,\n dest,\n) {\n let i, ii, x, x1, x2, y1, y2;\n const y = flatCenters[flatCentersOffset + 1];\n /** @type {Array} */\n const intersections = [];\n // Calculate intersections with the horizontal line\n for (let r = 0, rr = ends.length; r < rr; ++r) {\n const end = ends[r];\n x1 = flatCoordinates[end - stride];\n y1 = flatCoordinates[end - stride + 1];\n for (i = offset; i < end; i += stride) {\n x2 = flatCoordinates[i];\n y2 = flatCoordinates[i + 1];\n if ((y <= y1 && y2 <= y) || (y1 <= y && y <= y2)) {\n x = ((y - y1) / (y2 - y1)) * (x2 - x1) + x1;\n intersections.push(x);\n }\n x1 = x2;\n y1 = y2;\n }\n }\n // Find the longest segment of the horizontal line that has its center point\n // inside the linear ring.\n let pointX = NaN;\n let maxSegmentLength = -Infinity;\n intersections.sort(ascending);\n x1 = intersections[0];\n for (i = 1, ii = intersections.length; i < ii; ++i) {\n x2 = intersections[i];\n const segmentLength = Math.abs(x2 - x1);\n if (segmentLength > maxSegmentLength) {\n x = (x1 + x2) / 2;\n if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {\n pointX = x;\n maxSegmentLength = segmentLength;\n }\n }\n x1 = x2;\n }\n if (isNaN(pointX)) {\n // There is no horizontal line that has its center point inside the linear\n // ring. Use the center of the the linear ring's extent.\n pointX = flatCenters[flatCentersOffset];\n }\n if (dest) {\n dest.push(pointX, y, maxSegmentLength);\n return dest;\n }\n return [pointX, y, maxSegmentLength];\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {Array} flatCenters Flat centers.\n * @return {Array} Interior points as XYM coordinates, where M is the\n * length of the horizontal intersection that the point belongs to.\n */\nexport function getInteriorPointsOfMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n flatCenters,\n) {\n /** @type {Array} */\n let interiorPoints = [];\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n interiorPoints = getInteriorPointOfArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n flatCenters,\n 2 * i,\n interiorPoints,\n );\n offset = ends[ends.length - 1];\n }\n return interiorPoints;\n}\n","/**\n * @module ol/geom/flat/segments\n */\n\n/**\n * This function calls `callback` for each segment of the flat coordinates\n * array. If the callback returns a truthy value the function returns that\n * value immediately. Otherwise the function returns `false`.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {function(import(\"../../coordinate.js\").Coordinate, import(\"../../coordinate.js\").Coordinate): T} callback Function\n * called for each segment.\n * @return {T|boolean} Value.\n * @template T\n */\nexport function forEach(flatCoordinates, offset, end, stride, callback) {\n let ret;\n offset += stride;\n for (; offset < end; offset += stride) {\n ret = callback(\n flatCoordinates.slice(offset - stride, offset),\n flatCoordinates.slice(offset, offset + stride),\n );\n if (ret) {\n return ret;\n }\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/intersectsextent\n */\nimport {\n containsExtent,\n createEmpty,\n extendFlatCoordinates,\n intersects,\n intersectsSegment,\n} from '../../extent.js';\nimport {forEach as forEachSegment} from './segments.js';\nimport {linearRingContainsExtent, linearRingContainsXY} from './contains.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLineString(\n flatCoordinates,\n offset,\n end,\n stride,\n extent,\n) {\n const coordinatesExtent = extendFlatCoordinates(\n createEmpty(),\n flatCoordinates,\n offset,\n end,\n stride,\n );\n if (!intersects(extent, coordinatesExtent)) {\n return false;\n }\n if (containsExtent(extent, coordinatesExtent)) {\n return true;\n }\n if (coordinatesExtent[0] >= extent[0] && coordinatesExtent[2] <= extent[2]) {\n return true;\n }\n if (coordinatesExtent[1] >= extent[1] && coordinatesExtent[3] <= extent[3]) {\n return true;\n }\n return forEachSegment(\n flatCoordinates,\n offset,\n end,\n stride,\n /**\n * @param {import(\"../../coordinate.js\").Coordinate} point1 Start point.\n * @param {import(\"../../coordinate.js\").Coordinate} point2 End point.\n * @return {boolean} `true` if the segment and the extent intersect,\n * `false` otherwise.\n */\n function (point1, point2) {\n return intersectsSegment(extent, point1, point2);\n },\n );\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLineStringArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n extent,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n if (\n intersectsLineString(flatCoordinates, offset, ends[i], stride, extent)\n ) {\n return true;\n }\n offset = ends[i];\n }\n return false;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRing(\n flatCoordinates,\n offset,\n end,\n stride,\n extent,\n) {\n if (intersectsLineString(flatCoordinates, offset, end, stride, extent)) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[0],\n extent[1],\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[0],\n extent[3],\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[2],\n extent[1],\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[2],\n extent[3],\n )\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRingArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n extent,\n) {\n if (!intersectsLinearRing(flatCoordinates, offset, ends[0], stride, extent)) {\n return false;\n }\n if (ends.length === 1) {\n return true;\n }\n for (let i = 1, ii = ends.length; i < ii; ++i) {\n if (\n linearRingContainsExtent(\n flatCoordinates,\n ends[i - 1],\n ends[i],\n stride,\n extent,\n )\n ) {\n if (\n !intersectsLineString(\n flatCoordinates,\n ends[i - 1],\n ends[i],\n stride,\n extent,\n )\n ) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRingMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n extent,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (\n intersectsLinearRingArray(flatCoordinates, offset, ends, stride, extent)\n ) {\n return true;\n }\n offset = ends[ends.length - 1];\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/reverse\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n */\nexport function coordinates(flatCoordinates, offset, end, stride) {\n while (offset < end - stride) {\n for (let i = 0; i < stride; ++i) {\n const tmp = flatCoordinates[offset + i];\n flatCoordinates[offset + i] = flatCoordinates[end - stride + i];\n flatCoordinates[end - stride + i] = tmp;\n }\n offset += stride;\n end -= stride;\n }\n}\n","/**\n * @module ol/geom/flat/orient\n */\nimport {coordinates as reverseCoordinates} from './reverse.js';\n\n/**\n * Is the linear ring oriented clockwise in a coordinate system with a bottom-left\n * coordinate origin? For a coordinate system with a top-left coordinate origin,\n * the ring's orientation is clockwise when this function returns false.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {boolean|undefined} Is clockwise.\n */\nexport function linearRingIsClockwise(flatCoordinates, offset, end, stride) {\n // https://stackoverflow.com/q/1165647/clockwise-method#1165943\n // https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogrlinearring.cpp\n let edge = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n edge += (x2 - x1) * (y2 + y1);\n x1 = x2;\n y1 = y2;\n }\n return edge === 0 ? undefined : edge > 0;\n}\n\n/**\n * Determines if linear rings are oriented. By default, left-hand orientation\n * is tested (first ring must be clockwise, remaining rings counter-clockwise).\n * To test for right-hand orientation, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Test for right-hand orientation\n * (counter-clockwise exterior ring and clockwise interior rings).\n * @return {boolean} Rings are correctly oriented.\n */\nexport function linearRingsAreOriented(\n flatCoordinates,\n offset,\n ends,\n stride,\n right,\n) {\n right = right !== undefined ? right : false;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const isClockwise = linearRingIsClockwise(\n flatCoordinates,\n offset,\n end,\n stride,\n );\n if (i === 0) {\n if ((right && isClockwise) || (!right && !isClockwise)) {\n return false;\n }\n } else {\n if ((right && !isClockwise) || (!right && isClockwise)) {\n return false;\n }\n }\n offset = end;\n }\n return true;\n}\n\n/**\n * Determines if linear rings are oriented. By default, left-hand orientation\n * is tested (first ring must be clockwise, remaining rings counter-clockwise).\n * To test for right-hand orientation, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Array of array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Test for right-hand orientation\n * (counter-clockwise exterior ring and clockwise interior rings).\n * @return {boolean} Rings are correctly oriented.\n */\nexport function linearRingssAreOriented(\n flatCoordinates,\n offset,\n endss,\n stride,\n right,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (!linearRingsAreOriented(flatCoordinates, offset, ends, stride, right)) {\n return false;\n }\n if (ends.length) {\n offset = ends[ends.length - 1];\n }\n }\n return true;\n}\n\n/**\n * Orient coordinates in a flat array of linear rings. By default, rings\n * are oriented following the left-hand rule (clockwise for exterior and\n * counter-clockwise for interior rings). To orient according to the\n * right-hand rule, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {boolean} [right] Follow the right-hand rule for orientation.\n * @return {number} End.\n */\nexport function orientLinearRings(\n flatCoordinates,\n offset,\n ends,\n stride,\n right,\n) {\n right = right !== undefined ? right : false;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const isClockwise = linearRingIsClockwise(\n flatCoordinates,\n offset,\n end,\n stride,\n );\n const reverse =\n i === 0\n ? (right && isClockwise) || (!right && !isClockwise)\n : (right && !isClockwise) || (!right && isClockwise);\n if (reverse) {\n reverseCoordinates(flatCoordinates, offset, end, stride);\n }\n offset = end;\n }\n return offset;\n}\n\n/**\n * Orient coordinates in a flat array of linear rings. By default, rings\n * are oriented following the left-hand rule (clockwise for exterior and\n * counter-clockwise for interior rings). To orient according to the\n * right-hand rule, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Array of array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Follow the right-hand rule for orientation.\n * @return {number} End.\n */\nexport function orientLinearRingsArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n right,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n offset = orientLinearRings(\n flatCoordinates,\n offset,\n endss[i],\n stride,\n right,\n );\n }\n return offset;\n}\n\n/**\n * Return a two-dimensional endss\n * @param {Array} flatCoordinates Flat coordinates\n * @param {Array} ends Linear ring end indexes\n * @return {Array>} Two dimensional endss array that can\n * be used to construct a MultiPolygon\n */\nexport function inflateEnds(flatCoordinates, ends) {\n const endss = [];\n let offset = 0;\n let prevEndIndex = 0;\n let startOrientation;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n // classifies an array of rings into polygons with outer rings and holes\n const orientation = linearRingIsClockwise(flatCoordinates, offset, end, 2);\n if (startOrientation === undefined) {\n startOrientation = orientation;\n }\n if (orientation === startOrientation) {\n endss.push(ends.slice(prevEndIndex, i + 1));\n } else {\n if (endss.length === 0) {\n continue;\n }\n endss[endss.length - 1].push(ends[prevEndIndex]);\n }\n prevEndIndex = i + 1;\n offset = end;\n }\n return endss;\n}\n","/**\n * @module ol/geom/Polygon\n */\nimport LinearRing from './LinearRing.js';\nimport Point from './Point.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {arrayMaxSquaredDelta, assignClosestArrayPoint} from './flat/closest.js';\nimport {closestSquaredDistanceXY, getCenter, isEmpty} from '../extent.js';\nimport {deflateCoordinatesArray} from './flat/deflate.js';\nimport {extend} from '../array.js';\nimport {getInteriorPointOfArray} from './flat/interiorpoint.js';\nimport {inflateCoordinatesArray} from './flat/inflate.js';\nimport {intersectsLinearRingArray} from './flat/intersectsextent.js';\nimport {linearRingsAreOriented, orientLinearRings} from './flat/orient.js';\nimport {linearRings as linearRingsArea} from './flat/area.js';\nimport {linearRingsContainsXY} from './flat/contains.js';\nimport {modulo} from '../math.js';\nimport {quantizeArray} from './flat/simplify.js';\nimport {offset as sphereOffset} from '../sphere.js';\n\n/**\n * @classdesc\n * Polygon geometry.\n *\n * @api\n */\nclass Polygon extends SimpleGeometry {\n /**\n * @param {!Array>|!Array} coordinates\n * Array of linear rings that define the polygon. The first linear ring of the\n * array defines the outer-boundary or surface of the polygon. Each subsequent\n * linear ring defines a hole in the surface of the polygon. A linear ring is\n * an array of vertices' coordinates where the first coordinate and the last are\n * equivalent. (For internal use, flat coordinates in combination with\n * `layout` and `ends` are also accepted.)\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @param {Array} [ends] Ends (for internal use with flat coordinates).\n */\n constructor(coordinates, layout, ends) {\n super();\n\n /**\n * @type {Array}\n * @private\n */\n this.ends_ = [];\n\n /**\n * @private\n * @type {number}\n */\n this.flatInteriorPointRevision_ = -1;\n\n /**\n * @private\n * @type {import(\"../coordinate.js\").Coordinate|null}\n */\n this.flatInteriorPoint_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.orientedRevision_ = -1;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.orientedFlatCoordinates_ = null;\n\n if (layout !== undefined && ends) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n this.ends_ = ends;\n } else {\n this.setCoordinates(\n /** @type {Array>} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Append the passed linear ring to this polygon.\n * @param {LinearRing} linearRing Linear ring.\n * @api\n */\n appendLinearRing(linearRing) {\n if (!this.flatCoordinates) {\n this.flatCoordinates = linearRing.getFlatCoordinates().slice();\n } else {\n extend(this.flatCoordinates, linearRing.getFlatCoordinates());\n }\n this.ends_.push(this.flatCoordinates.length);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!Polygon} Clone.\n * @api\n */\n clone() {\n const polygon = new Polygon(\n this.flatCoordinates.slice(),\n this.layout,\n this.ends_.slice(),\n );\n polygon.applyProperties(this);\n return polygon;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n arrayMaxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestArrayPoint(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\n containsXY(x, y) {\n return linearRingsContainsXY(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n x,\n y,\n );\n }\n\n /**\n * Return the area of the polygon on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingsArea(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n );\n }\n\n /**\n * Get the coordinate array for this geometry. This array has the structure\n * of a GeoJSON coordinate array for polygons.\n *\n * @param {boolean} [right] Orient coordinates according to the right-hand\n * rule (counter-clockwise for exterior and clockwise for interior rings).\n * If `false`, coordinates will be oriented according to the left-hand rule\n * (clockwise for exterior and counter-clockwise for interior rings).\n * By default, coordinate orientation will depend on how the geometry was\n * constructed.\n * @return {Array>} Coordinates.\n * @api\n */\n getCoordinates(right) {\n let flatCoordinates;\n if (right !== undefined) {\n flatCoordinates = this.getOrientedFlatCoordinates().slice();\n orientLinearRings(flatCoordinates, 0, this.ends_, this.stride, right);\n } else {\n flatCoordinates = this.flatCoordinates;\n }\n\n return inflateCoordinatesArray(flatCoordinates, 0, this.ends_, this.stride);\n }\n\n /**\n * @return {Array} Ends.\n */\n getEnds() {\n return this.ends_;\n }\n\n /**\n * @return {Array} Interior point.\n */\n getFlatInteriorPoint() {\n if (this.flatInteriorPointRevision_ != this.getRevision()) {\n const flatCenter = getCenter(this.getExtent());\n this.flatInteriorPoint_ = getInteriorPointOfArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n flatCenter,\n 0,\n );\n this.flatInteriorPointRevision_ = this.getRevision();\n }\n return /** @type {import(\"../coordinate.js\").Coordinate} */ (\n this.flatInteriorPoint_\n );\n }\n\n /**\n * Return an interior point of the polygon.\n * @return {Point} Interior point as XYM coordinate, where M is the\n * length of the horizontal intersection that the point belongs to.\n * @api\n */\n getInteriorPoint() {\n return new Point(this.getFlatInteriorPoint(), 'XYM');\n }\n\n /**\n * Return the number of rings of the polygon, this includes the exterior\n * ring and any interior rings.\n *\n * @return {number} Number of rings.\n * @api\n */\n getLinearRingCount() {\n return this.ends_.length;\n }\n\n /**\n * Return the Nth linear ring of the polygon geometry. Return `null` if the\n * given index is out of range.\n * The exterior linear ring is available at index `0` and the interior rings\n * at index `1` and beyond.\n *\n * @param {number} index Index.\n * @return {LinearRing|null} Linear ring.\n * @api\n */\n getLinearRing(index) {\n if (index < 0 || this.ends_.length <= index) {\n return null;\n }\n return new LinearRing(\n this.flatCoordinates.slice(\n index === 0 ? 0 : this.ends_[index - 1],\n this.ends_[index],\n ),\n this.layout,\n );\n }\n\n /**\n * Return the linear rings of the polygon.\n * @return {Array} Linear rings.\n * @api\n */\n getLinearRings() {\n const layout = this.layout;\n const flatCoordinates = this.flatCoordinates;\n const ends = this.ends_;\n const linearRings = [];\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const linearRing = new LinearRing(\n flatCoordinates.slice(offset, end),\n layout,\n );\n linearRings.push(linearRing);\n offset = end;\n }\n return linearRings;\n }\n\n /**\n * @return {Array} Oriented flat coordinates.\n */\n getOrientedFlatCoordinates() {\n if (this.orientedRevision_ != this.getRevision()) {\n const flatCoordinates = this.flatCoordinates;\n if (linearRingsAreOriented(flatCoordinates, 0, this.ends_, this.stride)) {\n this.orientedFlatCoordinates_ = flatCoordinates;\n } else {\n this.orientedFlatCoordinates_ = flatCoordinates.slice();\n this.orientedFlatCoordinates_.length = orientLinearRings(\n this.orientedFlatCoordinates_,\n 0,\n this.ends_,\n this.stride,\n );\n }\n this.orientedRevision_ = this.getRevision();\n }\n return /** @type {Array} */ (this.orientedFlatCoordinates_);\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {Polygon} Simplified Polygon.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedFlatCoordinates.length = quantizeArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n Math.sqrt(squaredTolerance),\n simplifiedFlatCoordinates,\n 0,\n simplifiedEnds,\n );\n return new Polygon(simplifiedFlatCoordinates, 'XY', simplifiedEnds);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'Polygon';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return intersectsLinearRingArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n extent,\n );\n }\n\n /**\n * Set the coordinates of the polygon.\n * @param {!Array>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 2);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n const ends = deflateCoordinatesArray(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n this.ends_,\n );\n this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];\n this.changed();\n }\n}\n\nexport default Polygon;\n\n/**\n * Create an approximation of a circle on the surface of a sphere.\n * @param {import(\"../coordinate.js\").Coordinate} center Center (`[lon, lat]` in degrees).\n * @param {number} radius The great-circle distance from the center to\n * the polygon vertices in meters.\n * @param {number} [n] Optional number of vertices for the resulting\n * polygon. Default is `32`.\n * @param {number} [sphereRadius] Optional radius for the sphere (defaults to\n * the Earth's mean radius using the WGS84 ellipsoid).\n * @return {Polygon} The \"circular\" polygon.\n * @api\n */\nexport function circular(center, radius, n, sphereRadius) {\n n = n ? n : 32;\n /** @type {Array} */\n const flatCoordinates = [];\n for (let i = 0; i < n; ++i) {\n extend(\n flatCoordinates,\n sphereOffset(center, radius, (2 * Math.PI * i) / n, sphereRadius),\n );\n }\n flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);\n return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);\n}\n\n/**\n * Create a polygon from an extent. The layout used is `XY`.\n * @param {import(\"../extent.js\").Extent} extent The extent.\n * @return {Polygon} The polygon.\n * @api\n */\nexport function fromExtent(extent) {\n if (isEmpty(extent)) {\n throw new Error('Cannot create polygon from empty extent');\n }\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const flatCoordinates = [\n minX,\n minY,\n minX,\n maxY,\n maxX,\n maxY,\n maxX,\n minY,\n minX,\n minY,\n ];\n return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);\n}\n\n/**\n * Create a regular polygon from a circle.\n * @param {import(\"./Circle.js\").default} circle Circle geometry.\n * @param {number} [sides] Number of sides of the polygon. Default is 32.\n * @param {number} [angle] Start angle for the first vertex of the polygon in\n * counter-clockwise radians. 0 means East. Default is 0.\n * @return {Polygon} Polygon geometry.\n * @api\n */\nexport function fromCircle(circle, sides, angle) {\n sides = sides ? sides : 32;\n const stride = circle.getStride();\n const layout = circle.getLayout();\n const center = circle.getCenter();\n const arrayLength = stride * (sides + 1);\n const flatCoordinates = new Array(arrayLength);\n for (let i = 0; i < arrayLength; i += stride) {\n flatCoordinates[i] = 0;\n flatCoordinates[i + 1] = 0;\n for (let j = 2; j < stride; j++) {\n flatCoordinates[i + j] = center[j];\n }\n }\n const ends = [flatCoordinates.length];\n const polygon = new Polygon(flatCoordinates, layout, ends);\n makeRegular(polygon, center, circle.getRadius(), angle);\n return polygon;\n}\n\n/**\n * Modify the coordinates of a polygon to make it a regular polygon.\n * @param {Polygon} polygon Polygon geometry.\n * @param {import(\"../coordinate.js\").Coordinate} center Center of the regular polygon.\n * @param {number} radius Radius of the regular polygon.\n * @param {number} [angle] Start angle for the first vertex of the polygon in\n * counter-clockwise radians. 0 means East. Default is 0.\n */\nexport function makeRegular(polygon, center, radius, angle) {\n const flatCoordinates = polygon.getFlatCoordinates();\n const stride = polygon.getStride();\n const sides = flatCoordinates.length / stride - 1;\n const startAngle = angle ? angle : 0;\n for (let i = 0; i <= sides; ++i) {\n const offset = i * stride;\n const angle = startAngle + (modulo(i, sides) * 2 * Math.PI) / sides;\n flatCoordinates[offset] = center[0] + radius * Math.cos(angle);\n flatCoordinates[offset + 1] = center[1] + radius * Math.sin(angle);\n }\n polygon.changed();\n}\n","/**\n * @module ol/render/EventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered before a layer is rendered.\n * @event module:ol/render/Event~RenderEvent#prerender\n * @api\n */\n PRERENDER: 'prerender',\n\n /**\n * Triggered after a layer is rendered.\n * @event module:ol/render/Event~RenderEvent#postrender\n * @api\n */\n POSTRENDER: 'postrender',\n\n /**\n * Triggered before layers are composed. When dispatched by the map, the event object will not have\n * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only\n * WebGL layers currently dispatch this event.\n * @event module:ol/render/Event~RenderEvent#precompose\n * @api\n */\n PRECOMPOSE: 'precompose',\n\n /**\n * Triggered after layers are composed. When dispatched by the map, the event object will not have\n * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only\n * WebGL layers currently dispatch this event.\n * @event module:ol/render/Event~RenderEvent#postcompose\n * @api\n */\n POSTCOMPOSE: 'postcompose',\n\n /**\n * Triggered when rendering is complete, i.e. all sources and tiles have\n * finished loading for the current viewport, and all tiles are faded in.\n * The event object will not have a `context` set.\n * @event module:ol/render/Event~RenderEvent#rendercomplete\n * @api\n */\n RENDERCOMPLETE: 'rendercomplete',\n};\n\n/**\n * @typedef {'postrender'|'precompose'|'postcompose'|'rendercomplete'} MapRenderEventTypes\n */\n\n/**\n * @typedef {'postrender'|'prerender'} LayerRenderEventTypes\n */\n","/**\n * @module ol/ImageState\n */\n\n/**\n * @enum {number}\n */\nexport default {\n IDLE: 0,\n LOADING: 1,\n LOADED: 2,\n ERROR: 3,\n EMPTY: 4,\n};\n","/**\n * RGB space.\n *\n * @module color-space/rgb\n */\n\nexport default {\n\tname: 'rgb',\n\tmin: [0,0,0],\n\tmax: [255,255,255],\n\tchannel: ['red', 'green', 'blue'],\n\talias: ['RGB']\n};\n","/**\n * CIE XYZ\n *\n * @module color-space/xyz\n */\nimport rgb from './rgb.js';\n\nvar xyz = {\n\tname: 'xyz',\n\tmin: [0,0,0],\n\tchannel: ['X','Y','Z'],\n\talias: ['XYZ', 'ciexyz', 'cie1931']\n};\n\n\n/**\n * Whitepoint reference values with observer/illuminant\n *\n * http://en.wikipedia.org/wiki/Standard_illuminant\n */\nxyz.whitepoint = {\n\t//1931 2°\n\t2: {\n\t\t//incadescent\n\t\tA:[109.85, 100, 35.585],\n\t\t// B:[],\n\t\tC: [98.074, 100, 118.232],\n\t\tD50: [96.422, 100, 82.521],\n\t\tD55: [95.682, 100, 92.149],\n\t\t//daylight\n\t\tD65: [95.045592705167, 100, 108.9057750759878],\n\t\tD75: [94.972, 100, 122.638],\n\t\t//flourescent\n\t\t// F1: [],\n\t\tF2: [99.187, 100, 67.395],\n\t\t// F3: [],\n\t\t// F4: [],\n\t\t// F5: [],\n\t\t// F6:[],\n\t\tF7: [95.044, 100, 108.755],\n\t\t// F8: [],\n\t\t// F9: [],\n\t\t// F10: [],\n\t\tF11: [100.966, 100, 64.370],\n\t\t// F12: [],\n\t\tE: [100,100,100]\n\t},\n\n\t//1964 10°\n\t10: {\n\t\t//incadescent\n\t\tA:[111.144, 100, 35.200],\n\t\tC: [97.285, 100, 116.145],\n\t\tD50: [96.720, 100, 81.427],\n\t\tD55: [95.799, 100, 90.926],\n\t\t//daylight\n\t\tD65: [94.811, 100, 107.304],\n\t\tD75: [94.416, 100, 120.641],\n\t\t//flourescent\n\t\tF2: [103.280, 100, 69.026],\n\t\tF7: [95.792, 100, 107.687],\n\t\tF11: [103.866, 100, 65.627],\n\t\tE: [100,100,100]\n\t}\n};\n\n\n/**\n * Top values are the whitepoint’s top values, default are D65\n */\nxyz.max = xyz.whitepoint[2].D65;\n\n\n/**\n * Transform xyz to rgb\n *\n * @param {Array} xyz Array of xyz values\n *\n * @return {Array} RGB values\n */\nxyz.rgb = function (_xyz, white) {\n\t//FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then\n\twhite = white || xyz.whitepoint[2].E;\n\n\tvar x = _xyz[0] / white[0],\n\t\ty = _xyz[1] / white[1],\n\t\tz = _xyz[2] / white[2],\n\t\tr, g, b;\n\n\t// assume sRGB\n\t// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n\tr = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293);\n\tg = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175);\n\tb = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878);\n\n\tr = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)\n\t\t: r = (r * 12.92);\n\n\tg = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)\n\t\t: g = (g * 12.92);\n\n\tb = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)\n\t\t: b = (b * 12.92);\n\n\tr = Math.min(Math.max(0, r), 1);\n\tg = Math.min(Math.max(0, g), 1);\n\tb = Math.min(Math.max(0, b), 1);\n\n\treturn [r * 255, g * 255, b * 255];\n}\n\n\n\n/**\n * RGB to XYZ\n *\n * @param {Array} rgb RGB channels\n *\n * @return {Array} XYZ channels\n */\nrgb.xyz = function(rgb, white) {\n\tvar r = rgb[0] / 255,\n\t\t\tg = rgb[1] / 255,\n\t\t\tb = rgb[2] / 255;\n\n\t// assume sRGB\n\tr = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);\n\tg = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);\n\tb = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);\n\n\tvar x = (r * 0.41239079926595) + (g * 0.35758433938387) + (b * 0.18048078840183);\n\tvar y = (r * 0.21263900587151) + (g * 0.71516867876775) + (b * 0.072192315360733);\n\tvar z = (r * 0.019330818715591) + (g * 0.11919477979462) + (b * 0.95053215224966);\n\n\twhite = white || xyz.whitepoint[2].E;\n\n\treturn [x * white[0], y * white[1], z * white[2]];\n};\n\n\n\nexport default xyz;\n","/**\n * CIE LUV (C'est la vie)\n *\n * @module color-space/luv\n */\n import xyz from './xyz.js';\n\nexport default {\n\tname: 'luv',\n\t//NOTE: luv has no rigidly defined limits\n\t//easyrgb fails to get proper coords\n\t//boronine states no rigid limits\n\t//colorMine refers this ones:\n\tmin: [0,-134,-140],\n\tmax: [100,224,122],\n\tchannel: ['lightness', 'u', 'v'],\n\talias: ['LUV', 'cieluv', 'cie1976'],\n\n\txyz: function(arg, i, o){\n\t\tvar _u, _v, l, u, v, x, y, z, xn, yn, zn, un, vn;\n\t\tl = arg[0], u = arg[1], v = arg[2];\n\n\t\tif (l === 0) return [0,0,0];\n\n\t\t//get constants\n\t\t//var e = 0.008856451679035631; //(6/29)^3\n\t\tvar k = 0.0011070564598794539; //(3/29)^3\n\n\t\t//get illuminant/observer\n\t\ti = i || 'D65';\n\t\to = o || 2;\n\n\t\txn = xyz.whitepoint[o][i][0];\n\t\tyn = xyz.whitepoint[o][i][1];\n\t\tzn = xyz.whitepoint[o][i][2];\n\n\t\tun = (4 * xn) / (xn + (15 * yn) + (3 * zn));\n\t\tvn = (9 * yn) / (xn + (15 * yn) + (3 * zn));\n\t\t// un = 0.19783000664283;\n\t\t// vn = 0.46831999493879;\n\n\n\t\t_u = u / (13 * l) + un || 0;\n\t\t_v = v / (13 * l) + vn || 0;\n\n\t\ty = l > 8 ? yn * Math.pow( (l + 16) / 116 , 3) : yn * l * k;\n\n\t\t//wikipedia method\n\t\tx = y * 9 * _u / (4 * _v) || 0;\n\t\tz = y * (12 - 3 * _u - 20 * _v) / (4 * _v) || 0;\n\n\t\t//boronine method\n\t\t//https://github.com/boronine/husl/blob/master/husl.coffee#L201\n\t\t// x = 0 - (9 * y * _u) / ((_u - 4) * _v - _u * _v);\n\t\t// z = (9 * y - (15 * _v * y) - (_v * x)) / (3 * _v);\n\n\t\treturn [x, y, z];\n\t}\n};\n\n// http://www.brucelindbloom.com/index.html?Equations.html\n// https://github.com/boronine/husl/blob/master/husl.coffee\n//i - illuminant\n//o - observer\nxyz.luv = function(arg, i, o) {\n\tvar _u, _v, l, u, v, x, y, z, xn, yn, zn, un, vn;\n\n\t//get constants\n\tvar e = 0.008856451679035631; //(6/29)^3\n\tvar k = 903.2962962962961; //(29/3)^3\n\n\t//get illuminant/observer coords\n\ti = i || 'D65';\n\to = o || 2;\n\n\txn = xyz.whitepoint[o][i][0];\n\tyn = xyz.whitepoint[o][i][1];\n\tzn = xyz.whitepoint[o][i][2];\n\n\tun = (4 * xn) / (xn + (15 * yn) + (3 * zn));\n\tvn = (9 * yn) / (xn + (15 * yn) + (3 * zn));\n\n\n\tx = arg[0], y = arg[1], z = arg[2];\n\n\n\t_u = (4 * x) / (x + (15 * y) + (3 * z)) || 0;\n\t_v = (9 * y) / (x + (15 * y) + (3 * z)) || 0;\n\n\tvar yr = y/yn;\n\n\tl = yr <= e ? k * yr : 116 * Math.pow(yr, 1/3) - 16;\n\n\tu = 13 * l * (_u - un);\n\tv = 13 * l * (_v - vn);\n\n\treturn [l, u, v];\n};\n","/**\n * Cylindrical CIE LUV\n *\n * @module color-space/lchuv\n */\nimport luv from './luv.js';\nimport xyz from './xyz.js';\n\n//cylindrical luv\nvar lchuv = {\n\tname: 'lchuv',\n\tchannel: ['lightness', 'chroma', 'hue'],\n\talias: ['LCHuv', 'cielchuv'],\n\tmin: [0,0,0],\n\tmax: [100,100,360],\n\n\tluv: function(luv){\n\t\tvar l = luv[0],\n\t\tc = luv[1],\n\t\th = luv[2],\n\t\tu, v, hr;\n\n\t\thr = h / 360 * 2 * Math.PI;\n\t\tu = c * Math.cos(hr);\n\t\tv = c * Math.sin(hr);\n\t\treturn [l, u, v];\n\t},\n\n\txyz: function(arg) {\n\t\treturn luv.xyz(lchuv.luv(arg));\n\t}\n};\n\nexport default lchuv;\n\nluv.lchuv = function(luv){\n\tvar l = luv[0], u = luv[1], v = luv[2];\n\n\tvar c = Math.sqrt(u*u + v*v);\n\tvar hr = Math.atan2(v,u);\n\tvar h = hr * 360 / 2 / Math.PI;\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\treturn [l,c,h]\n};\n\nxyz.lchuv = function(arg){\n return luv.lchuv(xyz.luv(arg));\n};\n","'use strict'\r\n\r\nmodule.exports = {\r\n\t\"aliceblue\": [240, 248, 255],\r\n\t\"antiquewhite\": [250, 235, 215],\r\n\t\"aqua\": [0, 255, 255],\r\n\t\"aquamarine\": [127, 255, 212],\r\n\t\"azure\": [240, 255, 255],\r\n\t\"beige\": [245, 245, 220],\r\n\t\"bisque\": [255, 228, 196],\r\n\t\"black\": [0, 0, 0],\r\n\t\"blanchedalmond\": [255, 235, 205],\r\n\t\"blue\": [0, 0, 255],\r\n\t\"blueviolet\": [138, 43, 226],\r\n\t\"brown\": [165, 42, 42],\r\n\t\"burlywood\": [222, 184, 135],\r\n\t\"cadetblue\": [95, 158, 160],\r\n\t\"chartreuse\": [127, 255, 0],\r\n\t\"chocolate\": [210, 105, 30],\r\n\t\"coral\": [255, 127, 80],\r\n\t\"cornflowerblue\": [100, 149, 237],\r\n\t\"cornsilk\": [255, 248, 220],\r\n\t\"crimson\": [220, 20, 60],\r\n\t\"cyan\": [0, 255, 255],\r\n\t\"darkblue\": [0, 0, 139],\r\n\t\"darkcyan\": [0, 139, 139],\r\n\t\"darkgoldenrod\": [184, 134, 11],\r\n\t\"darkgray\": [169, 169, 169],\r\n\t\"darkgreen\": [0, 100, 0],\r\n\t\"darkgrey\": [169, 169, 169],\r\n\t\"darkkhaki\": [189, 183, 107],\r\n\t\"darkmagenta\": [139, 0, 139],\r\n\t\"darkolivegreen\": [85, 107, 47],\r\n\t\"darkorange\": [255, 140, 0],\r\n\t\"darkorchid\": [153, 50, 204],\r\n\t\"darkred\": [139, 0, 0],\r\n\t\"darksalmon\": [233, 150, 122],\r\n\t\"darkseagreen\": [143, 188, 143],\r\n\t\"darkslateblue\": [72, 61, 139],\r\n\t\"darkslategray\": [47, 79, 79],\r\n\t\"darkslategrey\": [47, 79, 79],\r\n\t\"darkturquoise\": [0, 206, 209],\r\n\t\"darkviolet\": [148, 0, 211],\r\n\t\"deeppink\": [255, 20, 147],\r\n\t\"deepskyblue\": [0, 191, 255],\r\n\t\"dimgray\": [105, 105, 105],\r\n\t\"dimgrey\": [105, 105, 105],\r\n\t\"dodgerblue\": [30, 144, 255],\r\n\t\"firebrick\": [178, 34, 34],\r\n\t\"floralwhite\": [255, 250, 240],\r\n\t\"forestgreen\": [34, 139, 34],\r\n\t\"fuchsia\": [255, 0, 255],\r\n\t\"gainsboro\": [220, 220, 220],\r\n\t\"ghostwhite\": [248, 248, 255],\r\n\t\"gold\": [255, 215, 0],\r\n\t\"goldenrod\": [218, 165, 32],\r\n\t\"gray\": [128, 128, 128],\r\n\t\"green\": [0, 128, 0],\r\n\t\"greenyellow\": [173, 255, 47],\r\n\t\"grey\": [128, 128, 128],\r\n\t\"honeydew\": [240, 255, 240],\r\n\t\"hotpink\": [255, 105, 180],\r\n\t\"indianred\": [205, 92, 92],\r\n\t\"indigo\": [75, 0, 130],\r\n\t\"ivory\": [255, 255, 240],\r\n\t\"khaki\": [240, 230, 140],\r\n\t\"lavender\": [230, 230, 250],\r\n\t\"lavenderblush\": [255, 240, 245],\r\n\t\"lawngreen\": [124, 252, 0],\r\n\t\"lemonchiffon\": [255, 250, 205],\r\n\t\"lightblue\": [173, 216, 230],\r\n\t\"lightcoral\": [240, 128, 128],\r\n\t\"lightcyan\": [224, 255, 255],\r\n\t\"lightgoldenrodyellow\": [250, 250, 210],\r\n\t\"lightgray\": [211, 211, 211],\r\n\t\"lightgreen\": [144, 238, 144],\r\n\t\"lightgrey\": [211, 211, 211],\r\n\t\"lightpink\": [255, 182, 193],\r\n\t\"lightsalmon\": [255, 160, 122],\r\n\t\"lightseagreen\": [32, 178, 170],\r\n\t\"lightskyblue\": [135, 206, 250],\r\n\t\"lightslategray\": [119, 136, 153],\r\n\t\"lightslategrey\": [119, 136, 153],\r\n\t\"lightsteelblue\": [176, 196, 222],\r\n\t\"lightyellow\": [255, 255, 224],\r\n\t\"lime\": [0, 255, 0],\r\n\t\"limegreen\": [50, 205, 50],\r\n\t\"linen\": [250, 240, 230],\r\n\t\"magenta\": [255, 0, 255],\r\n\t\"maroon\": [128, 0, 0],\r\n\t\"mediumaquamarine\": [102, 205, 170],\r\n\t\"mediumblue\": [0, 0, 205],\r\n\t\"mediumorchid\": [186, 85, 211],\r\n\t\"mediumpurple\": [147, 112, 219],\r\n\t\"mediumseagreen\": [60, 179, 113],\r\n\t\"mediumslateblue\": [123, 104, 238],\r\n\t\"mediumspringgreen\": [0, 250, 154],\r\n\t\"mediumturquoise\": [72, 209, 204],\r\n\t\"mediumvioletred\": [199, 21, 133],\r\n\t\"midnightblue\": [25, 25, 112],\r\n\t\"mintcream\": [245, 255, 250],\r\n\t\"mistyrose\": [255, 228, 225],\r\n\t\"moccasin\": [255, 228, 181],\r\n\t\"navajowhite\": [255, 222, 173],\r\n\t\"navy\": [0, 0, 128],\r\n\t\"oldlace\": [253, 245, 230],\r\n\t\"olive\": [128, 128, 0],\r\n\t\"olivedrab\": [107, 142, 35],\r\n\t\"orange\": [255, 165, 0],\r\n\t\"orangered\": [255, 69, 0],\r\n\t\"orchid\": [218, 112, 214],\r\n\t\"palegoldenrod\": [238, 232, 170],\r\n\t\"palegreen\": [152, 251, 152],\r\n\t\"paleturquoise\": [175, 238, 238],\r\n\t\"palevioletred\": [219, 112, 147],\r\n\t\"papayawhip\": [255, 239, 213],\r\n\t\"peachpuff\": [255, 218, 185],\r\n\t\"peru\": [205, 133, 63],\r\n\t\"pink\": [255, 192, 203],\r\n\t\"plum\": [221, 160, 221],\r\n\t\"powderblue\": [176, 224, 230],\r\n\t\"purple\": [128, 0, 128],\r\n\t\"rebeccapurple\": [102, 51, 153],\r\n\t\"red\": [255, 0, 0],\r\n\t\"rosybrown\": [188, 143, 143],\r\n\t\"royalblue\": [65, 105, 225],\r\n\t\"saddlebrown\": [139, 69, 19],\r\n\t\"salmon\": [250, 128, 114],\r\n\t\"sandybrown\": [244, 164, 96],\r\n\t\"seagreen\": [46, 139, 87],\r\n\t\"seashell\": [255, 245, 238],\r\n\t\"sienna\": [160, 82, 45],\r\n\t\"silver\": [192, 192, 192],\r\n\t\"skyblue\": [135, 206, 235],\r\n\t\"slateblue\": [106, 90, 205],\r\n\t\"slategray\": [112, 128, 144],\r\n\t\"slategrey\": [112, 128, 144],\r\n\t\"snow\": [255, 250, 250],\r\n\t\"springgreen\": [0, 255, 127],\r\n\t\"steelblue\": [70, 130, 180],\r\n\t\"tan\": [210, 180, 140],\r\n\t\"teal\": [0, 128, 128],\r\n\t\"thistle\": [216, 191, 216],\r\n\t\"tomato\": [255, 99, 71],\r\n\t\"turquoise\": [64, 224, 208],\r\n\t\"violet\": [238, 130, 238],\r\n\t\"wheat\": [245, 222, 179],\r\n\t\"white\": [255, 255, 255],\r\n\t\"whitesmoke\": [245, 245, 245],\r\n\t\"yellow\": [255, 255, 0],\r\n\t\"yellowgreen\": [154, 205, 50]\r\n};\r\n","/**\n * @module color-parse\n */\nimport names from 'color-name'\n\nexport default parse\n\n/**\n * Base hues\n * http://dev.w3.org/csswg/css-color/#typedef-named-hue\n */\n//FIXME: use external hue detector\nvar baseHues = {\n\tred: 0,\n\torange: 60,\n\tyellow: 120,\n\tgreen: 180,\n\tblue: 240,\n\tpurple: 300\n}\n\n/**\n * Parse color from the string passed\n *\n * @return {Object} A space indicator `space`, an array `values` and `alpha`\n */\nfunction parse(cstr) {\n\tvar m, parts = [], alpha = 1, space\n\n\t//numeric case\n\tif (typeof cstr === 'number') {\n\t\treturn { space: 'rgb', values: [cstr >>> 16, (cstr & 0x00ff00) >>> 8, cstr & 0x0000ff], alpha: 1 }\n\t}\n\tif (typeof cstr === 'number') return { space: 'rgb', values: [cstr >>> 16, (cstr & 0x00ff00) >>> 8, cstr & 0x0000ff], alpha: 1 }\n\n\tcstr = String(cstr).toLowerCase();\n\n\t//keyword\n\tif (names[cstr]) {\n\t\tparts = names[cstr].slice()\n\t\tspace = 'rgb'\n\t}\n\n\t//reserved words\n\telse if (cstr === 'transparent') {\n\t\talpha = 0\n\t\tspace = 'rgb'\n\t\tparts = [0, 0, 0]\n\t}\n\n\t//hex\n\telse if (cstr[0] === '#') {\n\t\tvar base = cstr.slice(1)\n\t\tvar size = base.length\n\t\tvar isShort = size <= 4\n\t\talpha = 1\n\n\t\tif (isShort) {\n\t\t\tparts = [\n\t\t\t\tparseInt(base[0] + base[0], 16),\n\t\t\t\tparseInt(base[1] + base[1], 16),\n\t\t\t\tparseInt(base[2] + base[2], 16)\n\t\t\t]\n\t\t\tif (size === 4) {\n\t\t\t\talpha = parseInt(base[3] + base[3], 16) / 255\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tparts = [\n\t\t\t\tparseInt(base[0] + base[1], 16),\n\t\t\t\tparseInt(base[2] + base[3], 16),\n\t\t\t\tparseInt(base[4] + base[5], 16)\n\t\t\t]\n\t\t\tif (size === 8) {\n\t\t\t\talpha = parseInt(base[6] + base[7], 16) / 255\n\t\t\t}\n\t\t}\n\n\t\tif (!parts[0]) parts[0] = 0\n\t\tif (!parts[1]) parts[1] = 0\n\t\tif (!parts[2]) parts[2] = 0\n\n\t\tspace = 'rgb'\n\t}\n\n\t// color space\n\telse if (m = /^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\\s*\\(([^\\)]*)\\)/.exec(cstr)) {\n\t\tvar name = m[1]\n\t\tspace = name.replace(/a$/, '')\n\t\tvar dims = space === 'cmyk' ? 4 : space === 'gray' ? 1 : 3\n\t\tparts = m[2].trim().split(/\\s*[,\\/]\\s*|\\s+/)\n\n\t\t// color(srgb-linear x x x) -> srgb-linear(x x x)\n\t\tif (space === 'color') space = parts.shift()\n\n\t\tparts = parts.map(function (x, i) {\n\t\t\t//\n\t\t\tif (x[x.length - 1] === '%') {\n\t\t\t\tx = parseFloat(x) / 100\n\t\t\t\t// alpha -> 0..1\n\t\t\t\tif (i === 3) return x\n\t\t\t\t// rgb -> 0..255\n\t\t\t\tif (space === 'rgb') return x * 255\n\t\t\t\t// hsl, hwb H -> 0..100\n\t\t\t\tif (space[0] === 'h') return x * 100\n\t\t\t\t// lch, lab L -> 0..100\n\t\t\t\tif (space[0] === 'l' && !i) return x * 100\n\t\t\t\t// lab A B -> -125..125\n\t\t\t\tif (space === 'lab') return x * 125\n\t\t\t\t// lch C -> 0..150, H -> 0..360\n\t\t\t\tif (space === 'lch') return i < 2 ? x * 150 : x * 360\n\t\t\t\t// oklch/oklab L -> 0..1\n\t\t\t\tif (space[0] === 'o' && !i) return x\n\t\t\t\t// oklab A B -> -0.4..0.4\n\t\t\t\tif (space === 'oklab') return x * 0.4\n\t\t\t\t// oklch C -> 0..0.4, H -> 0..360\n\t\t\t\tif (space === 'oklch') return i < 2 ? x * 0.4 : x * 360\n\t\t\t\t// color(xxx) -> 0..1\n\t\t\t\treturn x\n\t\t\t}\n\n\t\t\t//hue\n\t\t\tif (space[i] === 'h' || (i === 2 && space[space.length - 1] === 'h')) {\n\t\t\t\t//\n\t\t\t\tif (baseHues[x] !== undefined) return baseHues[x]\n\t\t\t\t//\n\t\t\t\tif (x.endsWith('deg')) return parseFloat(x)\n\t\t\t\t//\n\t\t\t\tif (x.endsWith('turn')) return parseFloat(x) * 360\n\t\t\t\tif (x.endsWith('grad')) return parseFloat(x) * 360 / 400\n\t\t\t\tif (x.endsWith('rad')) return parseFloat(x) * 180 / Math.PI\n\t\t\t}\n\t\t\tif (x === 'none') return 0\n\t\t\treturn parseFloat(x)\n\t\t});\n\n\t\talpha = parts.length > dims ? parts.pop() : 1\n\t}\n\n\t//named channels case\n\telse if (/[0-9](?:\\s|\\/|,)/.test(cstr)) {\n\t\tparts = cstr.match(/([0-9]+)/g).map(function (value) {\n\t\t\treturn parseFloat(value)\n\t\t})\n\n\t\tspace = cstr.match(/([a-z])/ig)?.join('')?.toLowerCase() || 'rgb'\n\t}\n\n\treturn {\n\t\tspace,\n\t\tvalues: parts,\n\t\talpha\n\t}\n}\n","/**\n * @module color-space/hsl\n */\nimport rgb from './rgb.js';\n\nexport default {\n\tname: 'hsl',\n\tmin: [0,0,0],\n\tmax: [360,100,100],\n\tchannel: ['hue', 'saturation', 'lightness'],\n\talias: ['HSL'],\n\n\trgb: function(hsl) {\n\t\tvar h = hsl[0]/360, s = hsl[1]/100, l = hsl[2]/100, t1, t2, t3, rgb, val, i=0;\n\n\t\tif (s === 0) return val = l * 255, [val, val, val];\n\n\t\tt2 = l < 0.5 ? l * (1 + s) : l + s - l * s;\n\t\tt1 = 2 * l - t2;\n\n\t\trgb = [0, 0, 0];\n\t\tfor (;i<3;) {\n\t\t\tt3 = h + 1 / 3 * - (i - 1);\n\t\t\tt3 < 0 ? t3++ : t3 > 1 && t3--;\n\t\t\tval = 6 * t3 < 1 ? t1 + (t2 - t1) * 6 * t3 :\n\t\t\t2 * t3 < 1 ? t2 :\n\t\t\t3 * t3 < 2 ? t1 + (t2 - t1) * (2 / 3 - t3) * 6 :\n\t\t\tt1;\n\t\t\trgb[i++] = val * 255;\n\t\t}\n\n\t\treturn rgb;\n\t}\n};\n\n\n//extend rgb\nrgb.hsl = function(rgb) {\n\tvar r = rgb[0]/255,\n\t\t\tg = rgb[1]/255,\n\t\t\tb = rgb[2]/255,\n\t\t\tmin = Math.min(r, g, b),\n\t\t\tmax = Math.max(r, g, b),\n\t\t\tdelta = max - min,\n\t\t\th, s, l;\n\n\tif (max === min) {\n\t\th = 0;\n\t}\n\telse if (r === max) {\n\t\th = (g - b) / delta;\n\t}\n\telse if (g === max) {\n\t\th = 2 + (b - r) / delta;\n\t}\n\telse if (b === max) {\n\t\th = 4 + (r - g)/ delta;\n\t}\n\n\th = Math.min(h * 60, 360);\n\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\tl = (min + max) / 2;\n\n\tif (max === min) {\n\t\ts = 0;\n\t}\n\telse if (l <= 0.5) {\n\t\ts = delta / (max + min);\n\t}\n\telse {\n\t\ts = delta / (2 - max - min);\n\t}\n\n\treturn [h, s * 100, l * 100];\n};\n","/** @module color-rgba */\nimport parse from 'color-parse'\nimport rgb from 'color-space/rgb.js'\nimport hsl from 'color-space/hsl.js'\n\nexport default function rgba(color) {\n\t// template literals\n\tif (Array.isArray(color) && color.raw) color = String.raw(...arguments)\n\tif (color instanceof Number) color = +color\n\n\tvar values, i, l\n\n\t//attempt to parse non-array arguments\n\tvar parsed = parse(color)\n\n\tif (!parsed.space) return []\n\n\tconst min = parsed.space[0] === 'h' ? hsl.min : rgb.min\n\tconst max = parsed.space[0] === 'h' ? hsl.max : rgb.max\n\n\tvalues = Array(3)\n\tvalues[0] = Math.min(Math.max(parsed.values[0], min[0]), max[0])\n\tvalues[1] = Math.min(Math.max(parsed.values[1], min[1]), max[1])\n\tvalues[2] = Math.min(Math.max(parsed.values[2], min[2]), max[2])\n\n\tif (parsed.space[0] === 'h') {\n\t\tvalues = hsl.rgb(values)\n\t}\n\n\tvalues.push(Math.min(Math.max(parsed.alpha, 0), 1))\n\n\treturn values\n}\n","/**\n * @module ol/color\n */\nimport lchuv from 'color-space/lchuv.js';\nimport parseRgba from 'color-rgba';\nimport rgb from 'color-space/rgb.js';\nimport xyz from 'color-space/xyz.js';\nimport {clamp} from './math.js';\n\n/**\n * A color represented as a short array [red, green, blue, alpha].\n * red, green, and blue should be integers in the range 0..255 inclusive.\n * alpha should be a float in the range 0..1 inclusive. If no alpha value is\n * given then `1` will be used.\n * @typedef {Array} Color\n * @api\n */\n\n/**\n * Return the color as an rgba string.\n * @param {Color|string} color Color.\n * @return {string} Rgba string.\n * @api\n */\nexport function asString(color) {\n if (typeof color === 'string') {\n return color;\n }\n return toString(color);\n}\n\n/**\n * @type {number}\n */\nconst MAX_CACHE_SIZE = 1024;\n\n/**\n * We maintain a small cache of parsed strings. Whenever the cache grows too large,\n * we delete an arbitrary set of the entries.\n *\n * @type {Object}\n */\nconst cache = {};\n\n/**\n * @type {number}\n */\nlet cacheSize = 0;\n\n/**\n * @param {Color} color A color that may or may not have an alpha channel.\n * @return {Color} The input color with an alpha channel. If the input color has\n * an alpha channel, the input color will be returned unchanged. Otherwise, a new\n * array will be returned with the input color and an alpha channel of 1.\n */\nexport function withAlpha(color) {\n if (color.length === 4) {\n return color;\n }\n const output = color.slice();\n output[3] = 1;\n return output;\n}\n\n/**\n * @param {Color} color RGBA color.\n * @return {Color} LCHuv color with alpha.\n */\nexport function rgbaToLcha(color) {\n const output = xyz.lchuv(rgb.xyz(color));\n output[3] = color[3];\n return output;\n}\n\n/**\n * @param {Color} color LCHuv color with alpha.\n * @return {Color} RGBA color.\n */\nexport function lchaToRgba(color) {\n const output = xyz.rgb(lchuv.xyz(color));\n output[3] = color[3];\n return output;\n}\n\n/**\n * @param {string} s String.\n * @return {Color} Color.\n */\nexport function fromString(s) {\n if (cache.hasOwnProperty(s)) {\n return cache[s];\n }\n if (cacheSize >= MAX_CACHE_SIZE) {\n let i = 0;\n for (const key in cache) {\n if ((i++ & 3) === 0) {\n delete cache[key];\n --cacheSize;\n }\n }\n }\n\n const color = parseRgba(s);\n if (color.length !== 4) {\n throw new Error('Failed to parse \"' + s + '\" as color');\n }\n for (const c of color) {\n if (isNaN(c)) {\n throw new Error('Failed to parse \"' + s + '\" as color');\n }\n }\n normalize(color);\n cache[s] = color;\n ++cacheSize;\n return color;\n}\n\n/**\n * Return the color as an array. This function maintains a cache of calculated\n * arrays which means the result should not be modified.\n * @param {Color|string} color Color.\n * @return {Color} Color.\n * @api\n */\nexport function asArray(color) {\n if (Array.isArray(color)) {\n return color;\n }\n return fromString(color);\n}\n\n/**\n * Exported for the tests.\n * @param {Color} color Color.\n * @return {Color} Clamped color.\n */\nexport function normalize(color) {\n color[0] = clamp((color[0] + 0.5) | 0, 0, 255);\n color[1] = clamp((color[1] + 0.5) | 0, 0, 255);\n color[2] = clamp((color[2] + 0.5) | 0, 0, 255);\n color[3] = clamp(color[3], 0, 1);\n return color;\n}\n\n/**\n * @param {Color} color Color.\n * @return {string} String.\n */\nexport function toString(color) {\n let r = color[0];\n if (r != (r | 0)) {\n r = (r + 0.5) | 0;\n }\n let g = color[1];\n if (g != (g | 0)) {\n g = (g + 0.5) | 0;\n }\n let b = color[2];\n if (b != (b | 0)) {\n b = (b + 0.5) | 0;\n }\n const a = color[3] === undefined ? 1 : Math.round(color[3] * 1000) / 1000;\n return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';\n}\n\n/**\n * @param {string} s String.\n * @return {boolean} Whether the string is actually a valid color\n */\nexport function isStringColor(s) {\n try {\n fromString(s);\n return true;\n } catch (_) {\n return false;\n }\n}\n","/**\n * @module ol/has\n */\n\nconst ua =\n typeof navigator !== 'undefined' && typeof navigator.userAgent !== 'undefined'\n ? navigator.userAgent.toLowerCase()\n : '';\n\n/**\n * User agent string says we are dealing with Firefox as browser.\n * @type {boolean}\n */\nexport const FIREFOX = ua.includes('firefox');\n\n/**\n * User agent string says we are dealing with Safari as browser.\n * @type {boolean}\n */\nexport const SAFARI = ua.includes('safari') && !ua.includes('chrom');\n\n/**\n * https://bugs.webkit.org/show_bug.cgi?id=237906\n * @type {boolean}\n */\nexport const SAFARI_BUG_237906 =\n SAFARI &&\n (ua.includes('version/15.4') ||\n /cpu (os|iphone os) 15_4 like mac os x/.test(ua));\n\n/**\n * User agent string says we are dealing with a WebKit engine.\n * @type {boolean}\n */\nexport const WEBKIT = ua.includes('webkit') && !ua.includes('edge');\n\n/**\n * User agent string says we are dealing with a Mac as platform.\n * @type {boolean}\n */\nexport const MAC = ua.includes('macintosh');\n\n/**\n * The ratio between physical pixels and device-independent pixels\n * (dips) on the device (`window.devicePixelRatio`).\n * @const\n * @type {number}\n * @api\n */\nexport const DEVICE_PIXEL_RATIO =\n typeof devicePixelRatio !== 'undefined' ? devicePixelRatio : 1;\n\n/**\n * The execution context is a worker with OffscreenCanvas available.\n * @const\n * @type {boolean}\n */\nexport const WORKER_OFFSCREEN_CANVAS =\n typeof WorkerGlobalScope !== 'undefined' &&\n typeof OffscreenCanvas !== 'undefined' &&\n self instanceof WorkerGlobalScope; //eslint-disable-line\n\n/**\n * Image.prototype.decode() is supported.\n * @type {boolean}\n */\nexport const IMAGE_DECODE =\n typeof Image !== 'undefined' && Image.prototype.decode;\n\n/**\n * createImageBitmap() is supported.\n * @type {boolean}\n */\nexport const CREATE_IMAGE_BITMAP = typeof createImageBitmap === 'function';\n\n/**\n * @type {boolean}\n */\nexport const PASSIVE_EVENT_LISTENERS = (function () {\n let passive = false;\n try {\n const options = Object.defineProperty({}, 'passive', {\n get: function () {\n passive = true;\n },\n });\n\n // @ts-ignore Ignore invalid event type '_'\n window.addEventListener('_', null, options);\n // @ts-ignore Ignore invalid event type '_'\n window.removeEventListener('_', null, options);\n } catch (error) {\n // passive not supported\n }\n return passive;\n})();\n","import {WORKER_OFFSCREEN_CANVAS} from './has.js';\n\n/**\n * @module ol/dom\n */\n\n//FIXME Move this function to the canvas module\n/**\n * Create an html canvas element and returns its 2d context.\n * @param {number} [width] Canvas width.\n * @param {number} [height] Canvas height.\n * @param {Array} [canvasPool] Canvas pool to take existing canvas from.\n * @param {CanvasRenderingContext2DSettings} [settings] CanvasRenderingContext2DSettings\n * @return {CanvasRenderingContext2D} The context.\n */\nexport function createCanvasContext2D(width, height, canvasPool, settings) {\n /** @type {HTMLCanvasElement|OffscreenCanvas} */\n let canvas;\n if (canvasPool && canvasPool.length) {\n canvas = /** @type {HTMLCanvasElement} */ (canvasPool.shift());\n } else if (WORKER_OFFSCREEN_CANVAS) {\n canvas = new OffscreenCanvas(width || 300, height || 300);\n } else {\n canvas = document.createElement('canvas');\n }\n if (width) {\n canvas.width = width;\n }\n if (height) {\n canvas.height = height;\n }\n //FIXME Allow OffscreenCanvasRenderingContext2D as return type\n return /** @type {CanvasRenderingContext2D} */ (\n canvas.getContext('2d', settings)\n );\n}\n\n/** @type {CanvasRenderingContext2D} */\nlet sharedCanvasContext;\n\n/**\n * @return {CanvasRenderingContext2D} Shared canvas context.\n */\nexport function getSharedCanvasContext2D() {\n if (!sharedCanvasContext) {\n sharedCanvasContext = createCanvasContext2D(1, 1);\n }\n return sharedCanvasContext;\n}\n\n/**\n * Releases canvas memory to avoid exceeding memory limits in Safari.\n * See https://pqina.nl/blog/total-canvas-memory-use-exceeds-the-maximum-limit/\n * @param {CanvasRenderingContext2D} context Context.\n */\nexport function releaseCanvas(context) {\n const canvas = context.canvas;\n canvas.width = 1;\n canvas.height = 1;\n context.clearRect(0, 0, 1, 1);\n}\n\n/**\n * Get the current computed width for the given element including margin,\n * padding and border.\n * Equivalent to jQuery's `$(el).outerWidth(true)`.\n * @param {!HTMLElement} element Element.\n * @return {number} The width.\n */\nexport function outerWidth(element) {\n let width = element.offsetWidth;\n const style = getComputedStyle(element);\n width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);\n\n return width;\n}\n\n/**\n * Get the current computed height for the given element including margin,\n * padding and border.\n * Equivalent to jQuery's `$(el).outerHeight(true)`.\n * @param {!HTMLElement} element Element.\n * @return {number} The height.\n */\nexport function outerHeight(element) {\n let height = element.offsetHeight;\n const style = getComputedStyle(element);\n height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);\n\n return height;\n}\n\n/**\n * @param {Node} newNode Node to replace old node\n * @param {Node} oldNode The node to be replaced\n */\nexport function replaceNode(newNode, oldNode) {\n const parent = oldNode.parentNode;\n if (parent) {\n parent.replaceChild(newNode, oldNode);\n }\n}\n\n/**\n * @param {Node} node The node to remove.\n * @return {Node|null} The node that was removed or null.\n */\nexport function removeNode(node) {\n return node && node.parentNode ? node.parentNode.removeChild(node) : null;\n}\n\n/**\n * @param {Node} node The node to remove the children from.\n */\nexport function removeChildren(node) {\n while (node.lastChild) {\n node.removeChild(node.lastChild);\n }\n}\n\n/**\n * Transform the children of a parent node so they match the\n * provided list of children. This function aims to efficiently\n * remove, add, and reorder child nodes while maintaining a simple\n * implementation (it is not guaranteed to minimize DOM operations).\n * @param {Node} node The parent node whose children need reworking.\n * @param {Array} children The desired children.\n */\nexport function replaceChildren(node, children) {\n const oldChildren = node.childNodes;\n\n for (let i = 0; true; ++i) {\n const oldChild = oldChildren[i];\n const newChild = children[i];\n\n // check if our work is done\n if (!oldChild && !newChild) {\n break;\n }\n\n // check if children match\n if (oldChild === newChild) {\n continue;\n }\n\n // check if a new child needs to be added\n if (!oldChild) {\n node.appendChild(newChild);\n continue;\n }\n\n // check if an old child needs to be removed\n if (!newChild) {\n node.removeChild(oldChild);\n --i;\n continue;\n }\n\n // reorder\n node.insertBefore(newChild, oldChild);\n }\n}\n","/**\n * @module ol/Image\n */\nimport EventTarget from './events/Target.js';\nimport EventType from './events/EventType.js';\nimport ImageState from './ImageState.js';\nimport {CREATE_IMAGE_BITMAP, IMAGE_DECODE} from './has.js';\nimport {listenOnce, unlistenByKey} from './events.js';\nimport {toPromise} from './functions.js';\n\n/**\n * A function that takes an {@link module:ol/Image~ImageWrapper} for the image and a\n * `{string}` for the src as arguments. It is supposed to make it so the\n * underlying image {@link module:ol/Image~ImageWrapper#getImage} is assigned the\n * content specified by the src. If not specified, the default is\n *\n * function(image, src) {\n * image.getImage().src = src;\n * }\n *\n * Providing a custom `imageLoadFunction` can be useful to load images with\n * post requests or - in general - through XHR requests, where the src of the\n * image element would be set to a data URI when the content is loaded.\n *\n * @typedef {function(import(\"./Image.js\").default, string): void} LoadFunction\n * @api\n */\n\n/**\n * @typedef {Object} ImageObject\n * @property {import(\"./extent.js\").Extent} [extent] Extent, if different from the requested one.\n * @property {import(\"./resolution.js\").ResolutionLike} [resolution] Resolution, if different from the requested one.\n * When x and y resolution are different, use the array type (`[xResolution, yResolution]`).\n * @property {number} [pixelRatio] Pixel ratio, if different from the requested one.\n * @property {import('./DataTile.js').ImageLike} image Image.\n */\n\n/**\n * Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.\n * For images that cover any extent and resolution (static images), the loader function should not accept\n * any arguments. The function returns an {@link import(\"./DataTile.js\").ImageLike image}, an\n * {@link import(\"./Image.js\").ImageObject image object}, or a promise for the same.\n * For loaders that generate images, the promise should not resolve until the image is loaded.\n * If the returned image does not match the extent, resolution or pixel ratio passed to the loader,\n * it has to return an {@link import(\"./Image.js\").ImageObject image object} with the `image` and the\n * correct `extent`, `resolution` and `pixelRatio`.\n *\n * @typedef {function(import(\"./extent.js\").Extent, number, number, (function(HTMLImageElement, string): void)=): import(\"./DataTile.js\").ImageLike|ImageObject|Promise} Loader\n * @api\n */\n\n/**\n * Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.\n * The function returns a promise for an {@link import(\"./Image.js\").ImageObject image object}.\n *\n * @typedef {function(import(\"./extent.js\").Extent, number, number, (function(HTMLImageElement, string): void)=): import(\"./DataTile.js\").ImageLike|ImageObject|Promise} ImageObjectPromiseLoader\n */\n\nclass ImageWrapper extends EventTarget {\n /**\n * @param {import(\"./extent.js\").Extent} extent Extent.\n * @param {number|Array|undefined} resolution Resolution. If provided as array, x and y\n * resolution will be assumed.\n * @param {number} pixelRatio Pixel ratio.\n * @param {import(\"./ImageState.js\").default|import(\"./Image.js\").Loader} stateOrLoader State.\n */\n constructor(extent, resolution, pixelRatio, stateOrLoader) {\n super();\n\n /**\n * @protected\n * @type {import(\"./extent.js\").Extent}\n */\n this.extent = extent;\n\n /**\n * @private\n * @type {number}\n */\n this.pixelRatio_ = pixelRatio;\n\n /**\n * @protected\n * @type {number|Array|undefined}\n */\n this.resolution = resolution;\n\n /**\n * @protected\n * @type {import(\"./ImageState.js\").default}\n */\n this.state =\n typeof stateOrLoader === 'function' ? ImageState.IDLE : stateOrLoader;\n\n /**\n * @private\n * @type {import('./DataTile.js').ImageLike|null}\n */\n this.image_ = null;\n\n /**\n * @protected\n * @type {import(\"./Image.js\").Loader}\n */\n this.loader = typeof stateOrLoader === 'function' ? stateOrLoader : null;\n }\n\n /**\n * @protected\n */\n changed() {\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * @return {import(\"./extent.js\").Extent} Extent.\n */\n getExtent() {\n return this.extent;\n }\n\n /**\n * @return {import('./DataTile.js').ImageLike} Image.\n */\n getImage() {\n return this.image_;\n }\n\n /**\n * @return {number} PixelRatio.\n */\n getPixelRatio() {\n return this.pixelRatio_;\n }\n\n /**\n * @return {number|Array} Resolution.\n */\n getResolution() {\n return /** @type {number} */ (this.resolution);\n }\n\n /**\n * @return {import(\"./ImageState.js\").default} State.\n */\n getState() {\n return this.state;\n }\n\n /**\n * Load not yet loaded URI.\n */\n load() {\n if (this.state == ImageState.IDLE) {\n if (this.loader) {\n this.state = ImageState.LOADING;\n this.changed();\n const resolution = this.getResolution();\n const requestResolution = Array.isArray(resolution)\n ? resolution[0]\n : resolution;\n toPromise(() =>\n this.loader(\n this.getExtent(),\n requestResolution,\n this.getPixelRatio(),\n ),\n )\n .then((image) => {\n if ('image' in image) {\n this.image_ = image.image;\n }\n if ('extent' in image) {\n this.extent = image.extent;\n }\n if ('resolution' in image) {\n this.resolution = image.resolution;\n }\n if ('pixelRatio' in image) {\n this.pixelRatio_ = image.pixelRatio;\n }\n if (\n image instanceof HTMLImageElement ||\n image instanceof ImageBitmap ||\n image instanceof HTMLCanvasElement ||\n image instanceof HTMLVideoElement\n ) {\n this.image_ = image;\n }\n this.state = ImageState.LOADED;\n })\n .catch((error) => {\n this.state = ImageState.ERROR;\n console.error(error); // eslint-disable-line no-console\n })\n .finally(() => this.changed());\n }\n }\n }\n\n /**\n * @param {import('./DataTile.js').ImageLike} image The image.\n */\n setImage(image) {\n this.image_ = image;\n }\n\n /**\n * @param {number|Array} resolution Resolution.\n */\n setResolution(resolution) {\n this.resolution = resolution;\n }\n}\n\n/**\n * @param {import('./DataTile.js').ImageLike} image Image element.\n * @param {function():any} loadHandler Load callback function.\n * @param {function():any} errorHandler Error callback function.\n * @return {function():void} Callback to stop listening.\n */\nexport function listenImage(image, loadHandler, errorHandler) {\n const img = /** @type {HTMLImageElement} */ (image);\n let listening = true;\n let decoding = false;\n let loaded = false;\n\n const listenerKeys = [\n listenOnce(img, EventType.LOAD, function () {\n loaded = true;\n if (!decoding) {\n loadHandler();\n }\n }),\n ];\n\n if (img.src && IMAGE_DECODE) {\n decoding = true;\n img\n .decode()\n .then(function () {\n if (listening) {\n loadHandler();\n }\n })\n .catch(function (error) {\n if (listening) {\n if (loaded) {\n loadHandler();\n } else {\n errorHandler();\n }\n }\n });\n } else {\n listenerKeys.push(listenOnce(img, EventType.ERROR, errorHandler));\n }\n\n return function unlisten() {\n listening = false;\n listenerKeys.forEach(unlistenByKey);\n };\n}\n\n/**\n * Loads an image.\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `HTMLImageElement`.\n * @api\n */\nexport function load(image, src) {\n return new Promise((resolve, reject) => {\n function handleLoad() {\n unlisten();\n resolve(image);\n }\n function handleError() {\n unlisten();\n reject(new Error('Image load error'));\n }\n function unlisten() {\n image.removeEventListener('load', handleLoad);\n image.removeEventListener('error', handleError);\n }\n image.addEventListener('load', handleLoad);\n image.addEventListener('error', handleError);\n if (src) {\n image.src = src;\n }\n });\n}\n\n/**\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `HTMLImageElement`.\n */\nexport function decodeFallback(image, src) {\n if (src) {\n image.src = src;\n }\n return image.src && IMAGE_DECODE\n ? new Promise((resolve, reject) =>\n image\n .decode()\n .then(() => resolve(image))\n .catch((e) =>\n image.complete && image.width ? resolve(image) : reject(e),\n ),\n )\n : load(image);\n}\n\n/**\n * Loads an image and decodes it to an `ImageBitmap` if `createImageBitmap()` is supported. Returns\n * the loaded image otherwise.\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `ImageBitmap` or an\n * `HTMLImageElement` if `createImageBitmap()` is not supported.\n * @api\n */\nexport function decode(image, src) {\n if (src) {\n image.src = src;\n }\n return image.src && IMAGE_DECODE && CREATE_IMAGE_BITMAP\n ? image\n .decode()\n .then(() => createImageBitmap(image))\n .catch((e) => {\n if (image.complete && image.width) {\n return image;\n }\n throw e;\n })\n : decodeFallback(image);\n}\n\nexport default ImageWrapper;\n","/**\n * @module ol/style/IconImageCache\n */\nimport ImageState from '../ImageState.js';\nimport {asArray} from '../color.js';\nimport {getSharedCanvasContext2D} from '../dom.js';\n\n/**\n * @classdesc\n * Singleton class. Available through {@link module:ol/style/IconImageCache.shared}.\n */\nclass IconImageCache {\n constructor() {\n /**\n * @type {!Object}\n * @private\n */\n this.cache_ = {};\n\n /**\n * @type {!Object}\n * @private\n */\n this.patternCache_ = {};\n\n /**\n * @type {number}\n * @private\n */\n this.cacheSize_ = 0;\n\n /**\n * @type {number}\n * @private\n */\n this.maxCacheSize_ = 32;\n }\n\n /**\n * FIXME empty description for jsdoc\n */\n clear() {\n this.cache_ = {};\n this.patternCache_ = {};\n this.cacheSize_ = 0;\n }\n\n /**\n * @return {boolean} Can expire cache.\n */\n canExpireCache() {\n return this.cacheSize_ > this.maxCacheSize_;\n }\n\n /**\n * FIXME empty description for jsdoc\n */\n expire() {\n if (this.canExpireCache()) {\n let i = 0;\n for (const key in this.cache_) {\n const iconImage = this.cache_[key];\n if ((i++ & 3) === 0 && !iconImage.hasListener()) {\n delete this.cache_[key];\n delete this.patternCache_[key];\n --this.cacheSize_;\n }\n }\n }\n }\n\n /**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @return {import(\"./IconImage.js\").default} Icon image.\n */\n get(src, crossOrigin, color) {\n const key = getCacheKey(src, crossOrigin, color);\n return key in this.cache_ ? this.cache_[key] : null;\n }\n\n /**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @return {CanvasPattern} Icon image.\n */\n getPattern(src, crossOrigin, color) {\n const key = getCacheKey(src, crossOrigin, color);\n return key in this.patternCache_ ? this.patternCache_[key] : null;\n }\n\n /**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @param {import(\"./IconImage.js\").default|null} iconImage Icon image.\n * @param {boolean} [pattern] Also cache a `'repeat'` pattern with this `iconImage`.\n */\n set(src, crossOrigin, color, iconImage, pattern) {\n const key = getCacheKey(src, crossOrigin, color);\n const update = key in this.cache_;\n this.cache_[key] = iconImage;\n if (pattern) {\n if (iconImage.getImageState() === ImageState.IDLE) {\n iconImage.load();\n }\n if (iconImage.getImageState() === ImageState.LOADING) {\n iconImage.ready().then(() => {\n this.patternCache_[key] = getSharedCanvasContext2D().createPattern(\n iconImage.getImage(1),\n 'repeat',\n );\n });\n } else {\n this.patternCache_[key] = getSharedCanvasContext2D().createPattern(\n iconImage.getImage(1),\n 'repeat',\n );\n }\n }\n if (!update) {\n ++this.cacheSize_;\n }\n }\n\n /**\n * Set the cache size of the icon cache. Default is `32`. Change this value when\n * your map uses more than 32 different icon images and you are not caching icon\n * styles on the application level.\n * @param {number} maxCacheSize Cache max size.\n * @api\n */\n setSize(maxCacheSize) {\n this.maxCacheSize_ = maxCacheSize;\n this.expire();\n }\n}\n\n/**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @return {string} Cache key.\n */\nexport function getCacheKey(src, crossOrigin, color) {\n const colorString = color ? asArray(color) : 'null';\n return crossOrigin + ':' + src + ':' + colorString;\n}\n\nexport default IconImageCache;\n\n/**\n * The {@link module:ol/style/IconImageCache~IconImageCache} for\n * {@link module:ol/style/Icon~Icon} images.\n * @api\n */\nexport const shared = new IconImageCache();\n","/**\n * @module ol/style/IconImage\n */\n\nimport EventTarget from '../events/Target.js';\nimport EventType from '../events/EventType.js';\nimport ImageState from '../ImageState.js';\nimport {asString} from '../color.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {decodeFallback} from '../Image.js';\nimport {shared as iconImageCache} from './IconImageCache.js';\n\n/**\n * @type {CanvasRenderingContext2D}\n */\nlet taintedTestContext = null;\n\nclass IconImage extends EventTarget {\n /**\n * @param {HTMLImageElement|HTMLCanvasElement|ImageBitmap|null} image Image.\n * @param {string|undefined} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../ImageState.js\").default|undefined} imageState Image state.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n */\n constructor(image, src, crossOrigin, imageState, color) {\n super();\n\n /**\n * @private\n * @type {HTMLImageElement|HTMLCanvasElement|ImageBitmap}\n */\n this.hitDetectionImage_ = null;\n\n /**\n * @private\n * @type {HTMLImageElement|HTMLCanvasElement|ImageBitmap|null}\n */\n this.image_ = image;\n\n /**\n * @private\n * @type {string|null}\n */\n this.crossOrigin_ = crossOrigin;\n\n /**\n * @private\n * @type {Object}\n */\n this.canvas_ = {};\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|string|null}\n */\n this.color_ = color;\n\n /**\n * @private\n * @type {import(\"../ImageState.js\").default}\n */\n this.imageState_ = imageState === undefined ? ImageState.IDLE : imageState;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size|null}\n */\n this.size_ =\n image && image.width && image.height ? [image.width, image.height] : null;\n\n /**\n * @private\n * @type {string|undefined}\n */\n this.src_ = src;\n\n /**\n * @private\n */\n this.tainted_;\n\n /**\n * @private\n * @type {Promise|null}\n */\n this.ready_ = null;\n }\n\n /**\n * @private\n */\n initializeImage_() {\n this.image_ = new Image();\n if (this.crossOrigin_ !== null) {\n this.image_.crossOrigin = this.crossOrigin_;\n }\n }\n\n /**\n * @private\n * @return {boolean} The image canvas is tainted.\n */\n isTainted_() {\n if (this.tainted_ === undefined && this.imageState_ === ImageState.LOADED) {\n if (!taintedTestContext) {\n taintedTestContext = createCanvasContext2D(1, 1, undefined, {\n willReadFrequently: true,\n });\n }\n taintedTestContext.drawImage(this.image_, 0, 0);\n try {\n taintedTestContext.getImageData(0, 0, 1, 1);\n this.tainted_ = false;\n } catch (e) {\n taintedTestContext = null;\n this.tainted_ = true;\n }\n }\n return this.tainted_ === true;\n }\n\n /**\n * @private\n */\n dispatchChangeEvent_() {\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * @private\n */\n handleImageError_() {\n this.imageState_ = ImageState.ERROR;\n this.dispatchChangeEvent_();\n }\n\n /**\n * @private\n */\n handleImageLoad_() {\n this.imageState_ = ImageState.LOADED;\n this.size_ = [this.image_.width, this.image_.height];\n this.dispatchChangeEvent_();\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @return {HTMLImageElement|HTMLCanvasElement|ImageBitmap} Image or Canvas element or image bitmap.\n */\n getImage(pixelRatio) {\n if (!this.image_) {\n this.initializeImage_();\n }\n this.replaceColor_(pixelRatio);\n return this.canvas_[pixelRatio] ? this.canvas_[pixelRatio] : this.image_;\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Image or Canvas element.\n */\n getPixelRatio(pixelRatio) {\n this.replaceColor_(pixelRatio);\n return this.canvas_[pixelRatio] ? pixelRatio : 1;\n }\n\n /**\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return this.imageState_;\n }\n\n /**\n * @return {HTMLImageElement|HTMLCanvasElement|ImageBitmap} Image element.\n */\n getHitDetectionImage() {\n if (!this.image_) {\n this.initializeImage_();\n }\n if (!this.hitDetectionImage_) {\n if (this.isTainted_()) {\n const width = this.size_[0];\n const height = this.size_[1];\n const context = createCanvasContext2D(width, height);\n context.fillRect(0, 0, width, height);\n this.hitDetectionImage_ = context.canvas;\n } else {\n this.hitDetectionImage_ = this.image_;\n }\n }\n return this.hitDetectionImage_;\n }\n\n /**\n * Get the size of the icon (in pixels).\n * @return {import(\"../size.js\").Size} Image size.\n */\n getSize() {\n return this.size_;\n }\n\n /**\n * @return {string|undefined} Image src.\n */\n getSrc() {\n return this.src_;\n }\n\n /**\n * Load not yet loaded URI.\n */\n load() {\n if (this.imageState_ !== ImageState.IDLE) {\n return;\n }\n if (!this.image_) {\n this.initializeImage_();\n }\n\n this.imageState_ = ImageState.LOADING;\n try {\n if (this.src_ !== undefined) {\n /** @type {HTMLImageElement} */ (this.image_).src = this.src_;\n }\n } catch (e) {\n this.handleImageError_();\n }\n if (this.image_ instanceof HTMLImageElement) {\n decodeFallback(this.image_, this.src_)\n .then((image) => {\n this.image_ = image;\n this.handleImageLoad_();\n })\n .catch(this.handleImageError_.bind(this));\n }\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @private\n */\n replaceColor_(pixelRatio) {\n if (\n !this.color_ ||\n this.canvas_[pixelRatio] ||\n this.imageState_ !== ImageState.LOADED\n ) {\n return;\n }\n\n const image = this.image_;\n const canvas = document.createElement('canvas');\n canvas.width = Math.ceil(image.width * pixelRatio);\n canvas.height = Math.ceil(image.height * pixelRatio);\n\n const ctx = canvas.getContext('2d');\n ctx.scale(pixelRatio, pixelRatio);\n ctx.drawImage(image, 0, 0);\n\n ctx.globalCompositeOperation = 'multiply';\n ctx.fillStyle = asString(this.color_);\n ctx.fillRect(0, 0, canvas.width / pixelRatio, canvas.height / pixelRatio);\n\n ctx.globalCompositeOperation = 'destination-in';\n ctx.drawImage(image, 0, 0);\n\n this.canvas_[pixelRatio] = canvas;\n }\n\n /**\n * @return {Promise} Promise that resolves when the image is loaded.\n */\n ready() {\n if (!this.ready_) {\n this.ready_ = new Promise((resolve) => {\n if (\n this.imageState_ === ImageState.LOADED ||\n this.imageState_ === ImageState.ERROR\n ) {\n resolve();\n } else {\n this.addEventListener(EventType.CHANGE, function onChange() {\n if (\n this.imageState_ === ImageState.LOADED ||\n this.imageState_ === ImageState.ERROR\n ) {\n this.removeEventListener(EventType.CHANGE, onChange);\n resolve();\n }\n });\n }\n });\n }\n return this.ready_;\n }\n}\n\n/**\n * @param {HTMLImageElement|HTMLCanvasElement|ImageBitmap|null} image Image.\n * @param {string|undefined} cacheKey Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../ImageState.js\").default|undefined} imageState Image state.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @param {boolean} [pattern] Also cache a `repeat` pattern with the icon image.\n * @return {IconImage} Icon image.\n */\nexport function get(image, cacheKey, crossOrigin, imageState, color, pattern) {\n let iconImage =\n cacheKey === undefined\n ? undefined\n : iconImageCache.get(cacheKey, crossOrigin, color);\n if (!iconImage) {\n iconImage = new IconImage(\n image,\n image instanceof HTMLImageElement ? image.src || undefined : cacheKey,\n crossOrigin,\n imageState,\n color,\n );\n iconImageCache.set(cacheKey, crossOrigin, color, iconImage, pattern);\n }\n if (\n pattern &&\n iconImage &&\n !iconImageCache.getPattern(cacheKey, crossOrigin, color)\n ) {\n iconImageCache.set(cacheKey, crossOrigin, color, iconImage, pattern);\n }\n return iconImage;\n}\n\nexport default IconImage;\n","/**\n * @module ol/style/Fill\n */\n\nimport ImageState from '../ImageState.js';\nimport {get as getIconImage} from './IconImage.js';\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null} [color=null] A color,\n * gradient or pattern.\n * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats. For polygon fills (not for {@link import(\"./RegularShape.js\").default} fills),\n * a pattern can also be provided as {@link module:ol/colorlike~PatternDescriptor}.\n * Default null; if null, the Canvas/renderer default black will be used.\n */\n\n/**\n * @classdesc\n * Set fill style for vector features.\n * @api\n */\nclass Fill {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options || {};\n\n /**\n * @private\n * @type {import(\"./IconImage.js\").default|null}\n */\n this.patternImage_ = null;\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null}\n */\n this.color_ = null;\n if (options.color !== undefined) {\n this.setColor(options.color);\n }\n }\n\n /**\n * Clones the style. The color is not cloned if it is an {@link module:ol/colorlike~ColorLike}.\n * @return {Fill} The cloned style.\n * @api\n */\n clone() {\n const color = this.getColor();\n return new Fill({\n color: Array.isArray(color) ? color.slice() : color || undefined,\n });\n }\n\n /**\n * Get the fill color.\n * @return {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null} Color.\n * @api\n */\n getColor() {\n return this.color_;\n }\n\n /**\n * Set the color.\n *\n * @param {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null} color Color.\n * @api\n */\n setColor(color) {\n if (color !== null && typeof color === 'object' && 'src' in color) {\n const patternImage = getIconImage(\n null,\n color.src,\n 'anonymous',\n undefined,\n color.offset ? null : color.color ? color.color : null,\n !(color.offset && color.size),\n );\n patternImage.ready().then(() => {\n this.patternImage_ = null;\n });\n if (patternImage.getImageState() === ImageState.IDLE) {\n patternImage.load();\n }\n if (patternImage.getImageState() === ImageState.LOADING) {\n this.patternImage_ = patternImage;\n }\n }\n this.color_ = color;\n }\n\n /**\n * @return {boolean} The fill style is loading an image pattern.\n */\n loading() {\n return !!this.patternImage_;\n }\n\n /**\n * @return {Promise} `false` or a promise that resolves when the style is ready to use.\n */\n ready() {\n return this.patternImage_ ? this.patternImage_.ready() : Promise.resolve();\n }\n}\n\nexport default Fill;\n","/**\n * @module ol/geom/flat/interpolate\n */\nimport {binarySearch} from '../../array.js';\nimport {lerp} from '../../math.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} fraction Fraction.\n * @param {Array} [dest] Destination.\n * @param {number} [dimension] Destination dimension (default is `2`)\n * @return {Array} Destination.\n */\nexport function interpolatePoint(\n flatCoordinates,\n offset,\n end,\n stride,\n fraction,\n dest,\n dimension,\n) {\n let o, t;\n const n = (end - offset) / stride;\n if (n === 1) {\n o = offset;\n } else if (n === 2) {\n o = offset;\n t = fraction;\n } else if (n !== 0) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n let length = 0;\n const cumulativeLengths = [0];\n for (let i = offset + stride; i < end; i += stride) {\n const x2 = flatCoordinates[i];\n const y2 = flatCoordinates[i + 1];\n length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n cumulativeLengths.push(length);\n x1 = x2;\n y1 = y2;\n }\n const target = fraction * length;\n const index = binarySearch(cumulativeLengths, target);\n if (index < 0) {\n t =\n (target - cumulativeLengths[-index - 2]) /\n (cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]);\n o = offset + (-index - 2) * stride;\n } else {\n o = offset + index * stride;\n }\n }\n dimension = dimension > 1 ? dimension : 2;\n dest = dest ? dest : new Array(dimension);\n for (let i = 0; i < dimension; ++i) {\n dest[i] =\n o === undefined\n ? NaN\n : t === undefined\n ? flatCoordinates[o + i]\n : lerp(flatCoordinates[o + i], flatCoordinates[o + stride + i], t);\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} m M.\n * @param {boolean} extrapolate Extrapolate.\n * @return {import(\"../../coordinate.js\").Coordinate|null} Coordinate.\n */\nexport function lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n end,\n stride,\n m,\n extrapolate,\n) {\n if (end == offset) {\n return null;\n }\n let coordinate;\n if (m < flatCoordinates[offset + stride - 1]) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(offset, offset + stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n if (flatCoordinates[end - 1] < m) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(end - stride, end);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n // FIXME use O(1) search\n if (m == flatCoordinates[offset + stride - 1]) {\n return flatCoordinates.slice(offset, offset + stride);\n }\n let lo = offset / stride;\n let hi = end / stride;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (m < flatCoordinates[(mid + 1) * stride - 1]) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n const m0 = flatCoordinates[lo * stride - 1];\n if (m == m0) {\n return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);\n }\n const m1 = flatCoordinates[(lo + 1) * stride - 1];\n const t = (m - m0) / (m1 - m0);\n coordinate = [];\n for (let i = 0; i < stride - 1; ++i) {\n coordinate.push(\n lerp(\n flatCoordinates[(lo - 1) * stride + i],\n flatCoordinates[lo * stride + i],\n t,\n ),\n );\n }\n coordinate.push(m);\n return coordinate;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} m M.\n * @param {boolean} extrapolate Extrapolate.\n * @param {boolean} interpolate Interpolate.\n * @return {import(\"../../coordinate.js\").Coordinate|null} Coordinate.\n */\nexport function lineStringsCoordinateAtM(\n flatCoordinates,\n offset,\n ends,\n stride,\n m,\n extrapolate,\n interpolate,\n) {\n if (interpolate) {\n return lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n ends[ends.length - 1],\n stride,\n m,\n extrapolate,\n );\n }\n let coordinate;\n if (m < flatCoordinates[stride - 1]) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(0, stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n if (flatCoordinates[flatCoordinates.length - 1] < m) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(flatCoordinates.length - stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n if (offset == end) {\n continue;\n }\n if (m < flatCoordinates[offset + stride - 1]) {\n return null;\n }\n if (m <= flatCoordinates[end - 1]) {\n return lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n end,\n stride,\n m,\n false,\n );\n }\n offset = end;\n }\n return null;\n}\n","/**\n * @module ol/geom/flat/length\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Length.\n */\nexport function lineStringLength(flatCoordinates, offset, end, stride) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n let length = 0;\n for (let i = offset + stride; i < end; i += stride) {\n const x2 = flatCoordinates[i];\n const y2 = flatCoordinates[i + 1];\n length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n x1 = x2;\n y1 = y2;\n }\n return length;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Perimeter.\n */\nexport function linearRingLength(flatCoordinates, offset, end, stride) {\n let perimeter = lineStringLength(flatCoordinates, offset, end, stride);\n const dx = flatCoordinates[end - stride] - flatCoordinates[offset];\n const dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];\n perimeter += Math.sqrt(dx * dx + dy * dy);\n return perimeter;\n}\n","/**\n * @module ol/style/Stroke\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} [color] A color, gradient or pattern.\n * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats.\n * Default null; if null, the Canvas/renderer default black will be used.\n * @property {CanvasLineCap} [lineCap='round'] Line cap style: `butt`, `round`, or `square`.\n * @property {CanvasLineJoin} [lineJoin='round'] Line join style: `bevel`, `round`, or `miter`.\n * @property {Array} [lineDash] Line dash pattern. Default is `null` (no dash).\n * @property {number} [lineDashOffset=0] Line dash offset.\n * @property {number} [miterLimit=10] Miter limit.\n * @property {number} [width] Width.\n */\n\n/**\n * @classdesc\n * Set stroke style for vector features.\n * Note that the defaults given are the Canvas defaults, which will be used if\n * option is not defined. The `get` functions return whatever was entered in\n * the options; they will not return the default.\n * @api\n */\nclass Stroke {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options || {};\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike}\n */\n this.color_ = options.color !== undefined ? options.color : null;\n\n /**\n * @private\n * @type {CanvasLineCap|undefined}\n */\n this.lineCap_ = options.lineCap;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.lineDash_ = options.lineDash !== undefined ? options.lineDash : null;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.lineDashOffset_ = options.lineDashOffset;\n\n /**\n * @private\n * @type {CanvasLineJoin|undefined}\n */\n this.lineJoin_ = options.lineJoin;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.miterLimit_ = options.miterLimit;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.width_ = options.width;\n }\n\n /**\n * Clones the style.\n * @return {Stroke} The cloned style.\n * @api\n */\n clone() {\n const color = this.getColor();\n return new Stroke({\n color: Array.isArray(color) ? color.slice() : color || undefined,\n lineCap: this.getLineCap(),\n lineDash: this.getLineDash() ? this.getLineDash().slice() : undefined,\n lineDashOffset: this.getLineDashOffset(),\n lineJoin: this.getLineJoin(),\n miterLimit: this.getMiterLimit(),\n width: this.getWidth(),\n });\n }\n\n /**\n * Get the stroke color.\n * @return {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} Color.\n * @api\n */\n getColor() {\n return this.color_;\n }\n\n /**\n * Get the line cap type for the stroke.\n * @return {CanvasLineCap|undefined} Line cap.\n * @api\n */\n getLineCap() {\n return this.lineCap_;\n }\n\n /**\n * Get the line dash style for the stroke.\n * @return {Array|null} Line dash.\n * @api\n */\n getLineDash() {\n return this.lineDash_;\n }\n\n /**\n * Get the line dash offset for the stroke.\n * @return {number|undefined} Line dash offset.\n * @api\n */\n getLineDashOffset() {\n return this.lineDashOffset_;\n }\n\n /**\n * Get the line join type for the stroke.\n * @return {CanvasLineJoin|undefined} Line join.\n * @api\n */\n getLineJoin() {\n return this.lineJoin_;\n }\n\n /**\n * Get the miter limit for the stroke.\n * @return {number|undefined} Miter limit.\n * @api\n */\n getMiterLimit() {\n return this.miterLimit_;\n }\n\n /**\n * Get the stroke width.\n * @return {number|undefined} Width.\n * @api\n */\n getWidth() {\n return this.width_;\n }\n\n /**\n * Set the color.\n *\n * @param {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} color Color.\n * @api\n */\n setColor(color) {\n this.color_ = color;\n }\n\n /**\n * Set the line cap.\n *\n * @param {CanvasLineCap|undefined} lineCap Line cap.\n * @api\n */\n setLineCap(lineCap) {\n this.lineCap_ = lineCap;\n }\n\n /**\n * Set the line dash.\n *\n * @param {Array|null} lineDash Line dash.\n * @api\n */\n setLineDash(lineDash) {\n this.lineDash_ = lineDash;\n }\n\n /**\n * Set the line dash offset.\n *\n * @param {number|undefined} lineDashOffset Line dash offset.\n * @api\n */\n setLineDashOffset(lineDashOffset) {\n this.lineDashOffset_ = lineDashOffset;\n }\n\n /**\n * Set the line join.\n *\n * @param {CanvasLineJoin|undefined} lineJoin Line join.\n * @api\n */\n setLineJoin(lineJoin) {\n this.lineJoin_ = lineJoin;\n }\n\n /**\n * Set the miter limit.\n *\n * @param {number|undefined} miterLimit Miter limit.\n * @api\n */\n setMiterLimit(miterLimit) {\n this.miterLimit_ = miterLimit;\n }\n\n /**\n * Set the width.\n *\n * @param {number|undefined} width Width.\n * @api\n */\n setWidth(width) {\n this.width_ = width;\n }\n}\n\nexport default Stroke;\n","/**\n * @module ol/size\n */\n\n/**\n * An array of numbers representing a size: `[width, height]`.\n * @typedef {Array} Size\n * @api\n */\n\n/**\n * Returns a buffered size.\n * @param {Size} size Size.\n * @param {number} num The amount by which to buffer.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} The buffered size.\n */\nexport function buffer(size, num, dest) {\n if (dest === undefined) {\n dest = [0, 0];\n }\n dest[0] = size[0] + 2 * num;\n dest[1] = size[1] + 2 * num;\n return dest;\n}\n\n/**\n * Determines if a size has a positive area.\n * @param {Size} size The size to test.\n * @return {boolean} The size has a positive area.\n */\nexport function hasArea(size) {\n return size[0] > 0 && size[1] > 0;\n}\n\n/**\n * Returns a size scaled by a ratio. The result will be an array of integers.\n * @param {Size} size Size.\n * @param {number} ratio Ratio.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} The scaled size.\n */\nexport function scale(size, ratio, dest) {\n if (dest === undefined) {\n dest = [0, 0];\n }\n dest[0] = (size[0] * ratio + 0.5) | 0;\n dest[1] = (size[1] * ratio + 0.5) | 0;\n return dest;\n}\n\n/**\n * Returns an `Size` array for the passed in number (meaning: square) or\n * `Size` array.\n * (meaning: non-square),\n * @param {number|Size} size Width and height.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} Size.\n * @api\n */\nexport function toSize(size, dest) {\n if (Array.isArray(size)) {\n return size;\n }\n if (dest === undefined) {\n dest = [size, size];\n } else {\n dest[0] = size;\n dest[1] = size;\n }\n return dest;\n}\n","/**\n * @module ol/style/Image\n */\nimport {abstract} from '../util.js';\nimport {toSize} from '../size.js';\n\n/**\n * @typedef {Object} Options\n * @property {number} opacity Opacity.\n * @property {boolean} rotateWithView If the image should get rotated with the view.\n * @property {number} rotation Rotation.\n * @property {number|import(\"../size.js\").Size} scale Scale.\n * @property {Array} displacement Displacement.\n * @property {import('../style/Style.js').DeclutterMode} declutterMode Declutter mode: `declutter`, `obstacle`, `none`.\n */\n\n/**\n * @classdesc\n * A base class used for creating subclasses and not instantiated in\n * apps. Base class for {@link module:ol/style/Icon~Icon}, {@link module:ol/style/Circle~CircleStyle} and\n * {@link module:ol/style/RegularShape~RegularShape}.\n * @abstract\n * @api\n */\nclass ImageStyle {\n /**\n * @param {Options} options Options.\n */\n constructor(options) {\n /**\n * @private\n * @type {number}\n */\n this.opacity_ = options.opacity;\n\n /**\n * @private\n * @type {boolean}\n */\n this.rotateWithView_ = options.rotateWithView;\n\n /**\n * @private\n * @type {number}\n */\n this.rotation_ = options.rotation;\n\n /**\n * @private\n * @type {number|import(\"../size.js\").Size}\n */\n this.scale_ = options.scale;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.scaleArray_ = toSize(options.scale);\n\n /**\n * @private\n * @type {Array}\n */\n this.displacement_ = options.displacement;\n\n /**\n * @private\n * @type {import('../style/Style.js').DeclutterMode}\n */\n this.declutterMode_ = options.declutterMode;\n }\n\n /**\n * Clones the style.\n * @return {ImageStyle} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n return new ImageStyle({\n opacity: this.getOpacity(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n }\n\n /**\n * Get the symbolizer opacity.\n * @return {number} Opacity.\n * @api\n */\n getOpacity() {\n return this.opacity_;\n }\n\n /**\n * Determine whether the symbolizer rotates with the map.\n * @return {boolean} Rotate with map.\n * @api\n */\n getRotateWithView() {\n return this.rotateWithView_;\n }\n\n /**\n * Get the symoblizer rotation.\n * @return {number} Rotation.\n * @api\n */\n getRotation() {\n return this.rotation_;\n }\n\n /**\n * Get the symbolizer scale.\n * @return {number|import(\"../size.js\").Size} Scale.\n * @api\n */\n getScale() {\n return this.scale_;\n }\n\n /**\n * Get the symbolizer scale array.\n * @return {import(\"../size.js\").Size} Scale array.\n */\n getScaleArray() {\n return this.scaleArray_;\n }\n\n /**\n * Get the displacement of the shape\n * @return {Array} Shape's center displacement\n * @api\n */\n getDisplacement() {\n return this.displacement_;\n }\n\n /**\n * Get the declutter mode of the shape\n * @return {import(\"./Style.js\").DeclutterMode} Shape's declutter mode\n * @api\n */\n getDeclutterMode() {\n return this.declutterMode_;\n }\n\n /**\n * Get the anchor point in pixels. The anchor determines the center point for the\n * symbolizer.\n * @abstract\n * @return {Array} Anchor.\n */\n getAnchor() {\n return abstract();\n }\n\n /**\n * Get the image element for the symbolizer.\n * @abstract\n * @param {number} pixelRatio Pixel ratio.\n * @return {import('../DataTile.js').ImageLike} Image element.\n */\n getImage(pixelRatio) {\n return abstract();\n }\n\n /**\n * @abstract\n * @return {import('../DataTile.js').ImageLike} Image element.\n */\n getHitDetectionImage() {\n return abstract();\n }\n\n /**\n * Get the image pixel ratio.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Pixel ratio.\n */\n getPixelRatio(pixelRatio) {\n return 1;\n }\n\n /**\n * @abstract\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return abstract();\n }\n\n /**\n * @abstract\n * @return {import(\"../size.js\").Size} Image size.\n */\n getImageSize() {\n return abstract();\n }\n\n /**\n * Get the origin of the symbolizer.\n * @abstract\n * @return {Array} Origin.\n */\n getOrigin() {\n return abstract();\n }\n\n /**\n * Get the size of the symbolizer (in pixels).\n * @abstract\n * @return {import(\"../size.js\").Size} Size.\n */\n getSize() {\n return abstract();\n }\n\n /**\n * Set the displacement.\n *\n * @param {Array} displacement Displacement.\n * @api\n */\n setDisplacement(displacement) {\n this.displacement_ = displacement;\n }\n\n /**\n * Set the opacity.\n *\n * @param {number} opacity Opacity.\n * @api\n */\n setOpacity(opacity) {\n this.opacity_ = opacity;\n }\n\n /**\n * Set whether to rotate the style with the view.\n *\n * @param {boolean} rotateWithView Rotate with map.\n * @api\n */\n setRotateWithView(rotateWithView) {\n this.rotateWithView_ = rotateWithView;\n }\n\n /**\n * Set the rotation.\n *\n * @param {number} rotation Rotation.\n * @api\n */\n setRotation(rotation) {\n this.rotation_ = rotation;\n }\n\n /**\n * Set the scale.\n *\n * @param {number|import(\"../size.js\").Size} scale Scale.\n * @api\n */\n setScale(scale) {\n this.scale_ = scale;\n this.scaleArray_ = toSize(scale);\n }\n\n /**\n * @abstract\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n listenImageChange(listener) {\n abstract();\n }\n\n /**\n * Load not yet loaded URI.\n * @abstract\n */\n load() {\n abstract();\n }\n\n /**\n * @abstract\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n unlistenImageChange(listener) {\n abstract();\n }\n\n /**\n * @return {Promise} `false` or Promise that resolves when the style is ready to use.\n */\n ready() {\n return Promise.resolve();\n }\n}\n\nexport default ImageStyle;\n","/**\n * @module ol/colorlike\n */\nimport ImageState from './ImageState.js';\nimport {createCanvasContext2D} from './dom.js';\nimport {get as getIconImage} from './style/IconImage.js';\nimport {shared as iconCache} from './style/IconImageCache.js';\nimport {toString} from './color.js';\n\n/**\n * @typedef {Object} PatternDescriptor\n * @property {string} src Pattern image URL\n * @property {import(\"./color.js\").Color|string} [color] Color to tint the pattern with.\n * @property {import(\"./size.js\").Size} [size] Size of the desired slice from the pattern image.\n * Use this together with `offset` when the pattern image is a sprite sheet.\n * @property {import(\"./size.js\").Size} [offset] Offset of the desired slice from the pattern image.\n * Use this together with `size` when the pattern image is a sprite sheet.\n */\n\n/**\n * A type accepted by CanvasRenderingContext2D.fillStyle\n * or CanvasRenderingContext2D.strokeStyle.\n * Represents a color, [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern),\n * or [CanvasGradient](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient). The origin for\n * patterns and gradients as fill style is an increment of 512 css pixels from map coordinate\n * `[0, 0]`. For seamless repeat patterns, width and height of the pattern image\n * must be a factor of two (2, 4, 8, ..., 512).\n *\n * @typedef {string|CanvasPattern|CanvasGradient} ColorLike\n * @api\n */\n\n/**\n * @param {import(\"./color.js\").Color|ColorLike|PatternDescriptor|null} color Color.\n * @return {ColorLike|null} The color as an {@link ol/colorlike~ColorLike}.\n * @api\n */\nexport function asColorLike(color) {\n if (!color) {\n return null;\n }\n if (Array.isArray(color)) {\n return toString(color);\n }\n if (typeof color === 'object' && 'src' in color) {\n return asCanvasPattern(color);\n }\n return color;\n}\n\n/**\n * @param {PatternDescriptor} pattern Pattern descriptor.\n * @return {CanvasPattern|null} Canvas pattern or null if the pattern referenced in the\n * PatternDescriptor was not found in the icon image cache.\n */\nfunction asCanvasPattern(pattern) {\n if (!pattern.offset || !pattern.size) {\n return iconCache.getPattern(pattern.src, 'anonymous', pattern.color);\n }\n\n const cacheKey = pattern.src + ':' + pattern.offset;\n\n const canvasPattern = iconCache.getPattern(\n cacheKey,\n undefined,\n pattern.color,\n );\n if (canvasPattern) {\n return canvasPattern;\n }\n\n const iconImage = iconCache.get(pattern.src, 'anonymous', null);\n if (iconImage.getImageState() !== ImageState.LOADED) {\n return null;\n }\n const patternCanvasContext = createCanvasContext2D(\n pattern.size[0],\n pattern.size[1],\n );\n patternCanvasContext.drawImage(\n iconImage.getImage(1),\n pattern.offset[0],\n pattern.offset[1],\n pattern.size[0],\n pattern.size[1],\n 0,\n 0,\n pattern.size[0],\n pattern.size[1],\n );\n getIconImage(\n patternCanvasContext.canvas,\n cacheKey,\n undefined,\n ImageState.LOADED,\n pattern.color,\n true,\n );\n return iconCache.getPattern(cacheKey, undefined, pattern.color);\n}\n","/**\n * @module ol/css\n */\n\n/**\n * @typedef {Object} FontParameters\n * @property {string} style Style.\n * @property {string} variant Variant.\n * @property {string} weight Weight.\n * @property {string} size Size.\n * @property {string} lineHeight LineHeight.\n * @property {string} family Family.\n * @property {Array} families Families.\n */\n\n/**\n * The CSS class for hidden feature.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_HIDDEN = 'ol-hidden';\n\n/**\n * The CSS class that we'll give the DOM elements to have them selectable.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_SELECTABLE = 'ol-selectable';\n\n/**\n * The CSS class that we'll give the DOM elements to have them unselectable.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_UNSELECTABLE = 'ol-unselectable';\n\n/**\n * The CSS class for unsupported feature.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_UNSUPPORTED = 'ol-unsupported';\n\n/**\n * The CSS class for controls.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_CONTROL = 'ol-control';\n\n/**\n * The CSS class that we'll give the DOM elements that are collapsed, i.e.\n * to those elements which usually can be expanded.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_COLLAPSED = 'ol-collapsed';\n\n/**\n * From https://stackoverflow.com/questions/10135697/regex-to-parse-any-css-font\n * @type {RegExp}\n */\nconst fontRegEx = new RegExp(\n [\n '^\\\\s*(?=(?:(?:[-a-z]+\\\\s*){0,2}(italic|oblique))?)',\n '(?=(?:(?:[-a-z]+\\\\s*){0,2}(small-caps))?)',\n '(?=(?:(?:[-a-z]+\\\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)',\n '(?:(?:normal|\\\\1|\\\\2|\\\\3)\\\\s*){0,3}((?:xx?-)?',\n '(?:small|large)|medium|smaller|larger|[\\\\.\\\\d]+(?:\\\\%|in|[cem]m|ex|p[ctx]))',\n '(?:\\\\s*\\\\/\\\\s*(normal|[\\\\.\\\\d]+(?:\\\\%|in|[cem]m|ex|p[ctx])?))',\n '?\\\\s*([-,\\\\\"\\\\\\'\\\\sa-z]+?)\\\\s*$',\n ].join(''),\n 'i',\n);\n/** @type {Array<'style'|'variant'|'weight'|'size'|'lineHeight'|'family'>} */\nconst fontRegExMatchIndex = [\n 'style',\n 'variant',\n 'weight',\n 'size',\n 'lineHeight',\n 'family',\n];\n\n/**\n * Get the list of font families from a font spec. Note that this doesn't work\n * for font families that have commas in them.\n * @param {string} fontSpec The CSS font property.\n * @return {FontParameters|null} The font parameters (or null if the input spec is invalid).\n */\nexport const getFontParameters = function (fontSpec) {\n const match = fontSpec.match(fontRegEx);\n if (!match) {\n return null;\n }\n const style = /** @type {FontParameters} */ ({\n lineHeight: 'normal',\n size: '1.2em',\n style: 'normal',\n weight: 'normal',\n variant: 'normal',\n });\n for (let i = 0, ii = fontRegExMatchIndex.length; i < ii; ++i) {\n const value = match[i + 1];\n if (value !== undefined) {\n style[fontRegExMatchIndex[i]] = value;\n }\n }\n style.families = style.family.split(/,\\s?/);\n return style;\n};\n","/**\n * @module ol/render/canvas\n */\nimport BaseObject from '../Object.js';\nimport {WORKER_OFFSCREEN_CANVAS} from '../has.js';\nimport {clear} from '../obj.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {getFontParameters} from '../css.js';\n\n/**\n * @typedef {'Circle' | 'Image' | 'LineString' | 'Polygon' | 'Text' | 'Default'} BuilderType\n */\n\n/**\n * @typedef {Object} FillState\n * @property {import(\"../colorlike.js\").ColorLike} fillStyle FillStyle.\n */\n\n/**\n * @typedef Label\n * @property {number} width Width.\n * @property {number} height Height.\n * @property {Array} contextInstructions ContextInstructions.\n */\n\n/**\n * @typedef {Object} FillStrokeState\n * @property {import(\"../colorlike.js\").ColorLike} [currentFillStyle] Current FillStyle.\n * @property {import(\"../colorlike.js\").ColorLike} [currentStrokeStyle] Current StrokeStyle.\n * @property {CanvasLineCap} [currentLineCap] Current LineCap.\n * @property {Array} currentLineDash Current LineDash.\n * @property {number} [currentLineDashOffset] Current LineDashOffset.\n * @property {CanvasLineJoin} [currentLineJoin] Current LineJoin.\n * @property {number} [currentLineWidth] Current LineWidth.\n * @property {number} [currentMiterLimit] Current MiterLimit.\n * @property {number} [lastStroke] Last stroke.\n * @property {import(\"../colorlike.js\").ColorLike} [fillStyle] FillStyle.\n * @property {import(\"../colorlike.js\").ColorLike} [strokeStyle] StrokeStyle.\n * @property {CanvasLineCap} [lineCap] LineCap.\n * @property {Array} lineDash LineDash.\n * @property {number} [lineDashOffset] LineDashOffset.\n * @property {CanvasLineJoin} [lineJoin] LineJoin.\n * @property {number} [lineWidth] LineWidth.\n * @property {number} [miterLimit] MiterLimit.\n * @property {number} [fillPatternScale] Fill pattern scale.\n */\n\n/**\n * @typedef {Object} StrokeState\n * @property {CanvasLineCap} lineCap LineCap.\n * @property {Array} lineDash LineDash.\n * @property {number} lineDashOffset LineDashOffset.\n * @property {CanvasLineJoin} lineJoin LineJoin.\n * @property {number} lineWidth LineWidth.\n * @property {number} miterLimit MiterLimit.\n * @property {import(\"../colorlike.js\").ColorLike} strokeStyle StrokeStyle.\n */\n\n/**\n * @typedef {Object} TextState\n * @property {string} font Font.\n * @property {CanvasTextAlign} [textAlign] TextAlign.\n * @property {number} [repeat] Repeat.\n * @property {import(\"../style/Text.js\").TextJustify} [justify] Justify.\n * @property {CanvasTextBaseline} textBaseline TextBaseline.\n * @property {import(\"../style/Text.js\").TextPlacement} [placement] Placement.\n * @property {number} [maxAngle] MaxAngle.\n * @property {boolean} [overflow] Overflow.\n * @property {import(\"../style/Fill.js\").default} [backgroundFill] BackgroundFill.\n * @property {import(\"../style/Stroke.js\").default} [backgroundStroke] BackgroundStroke.\n * @property {import(\"../size.js\").Size} [scale] Scale.\n * @property {Array} [padding] Padding.\n */\n\n/**\n * @typedef {Object} SerializableInstructions\n * @property {Array<*>} instructions The rendering instructions.\n * @property {Array<*>} hitDetectionInstructions The rendering hit detection instructions.\n * @property {Array} coordinates The array of all coordinates.\n * @property {!Object} [textStates] The text states (decluttering).\n * @property {!Object} [fillStates] The fill states (decluttering).\n * @property {!Object} [strokeStates] The stroke states (decluttering).\n */\n\n/**\n * @typedef {Object} DeclutterImageWithText\n */\n\n/**\n * @const\n * @type {string}\n */\nexport const defaultFont = '10px sans-serif';\n\n/**\n * @const\n * @type {string}\n */\nexport const defaultFillStyle = '#000';\n\n/**\n * @const\n * @type {CanvasLineCap}\n */\nexport const defaultLineCap = 'round';\n\n/**\n * @const\n * @type {Array}\n */\nexport const defaultLineDash = [];\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultLineDashOffset = 0;\n\n/**\n * @const\n * @type {CanvasLineJoin}\n */\nexport const defaultLineJoin = 'round';\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultMiterLimit = 10;\n\n/**\n * @const\n * @type {import(\"../colorlike.js\").ColorLike}\n */\nexport const defaultStrokeStyle = '#000';\n\n/**\n * @const\n * @type {CanvasTextAlign}\n */\nexport const defaultTextAlign = 'center';\n\n/**\n * @const\n * @type {CanvasTextBaseline}\n */\nexport const defaultTextBaseline = 'middle';\n\n/**\n * @const\n * @type {Array}\n */\nexport const defaultPadding = [0, 0, 0, 0];\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultLineWidth = 1;\n\n/**\n * @type {BaseObject}\n */\nexport const checkedFonts = new BaseObject();\n\n/**\n * @type {CanvasRenderingContext2D}\n */\nlet measureContext = null;\n\n/**\n * @type {string}\n */\nlet measureFont;\n\n/**\n * @type {!Object}\n */\nexport const textHeights = {};\n\n/**\n * Clears the label cache when a font becomes available.\n * @param {string} fontSpec CSS font spec.\n */\nexport const registerFont = (function () {\n const retries = 100;\n const size = '32px ';\n const referenceFonts = ['monospace', 'serif'];\n const len = referenceFonts.length;\n const text = 'wmytzilWMYTZIL@#/&?$%10\\uF013';\n let interval, referenceWidth;\n\n /**\n * @param {string} fontStyle Css font-style\n * @param {string} fontWeight Css font-weight\n * @param {*} fontFamily Css font-family\n * @return {boolean} Font with style and weight is available\n */\n function isAvailable(fontStyle, fontWeight, fontFamily) {\n let available = true;\n for (let i = 0; i < len; ++i) {\n const referenceFont = referenceFonts[i];\n referenceWidth = measureTextWidth(\n fontStyle + ' ' + fontWeight + ' ' + size + referenceFont,\n text,\n );\n if (fontFamily != referenceFont) {\n const width = measureTextWidth(\n fontStyle +\n ' ' +\n fontWeight +\n ' ' +\n size +\n fontFamily +\n ',' +\n referenceFont,\n text,\n );\n // If width and referenceWidth are the same, then the fallback was used\n // instead of the font we wanted, so the font is not available.\n available = available && width != referenceWidth;\n }\n }\n if (available) {\n return true;\n }\n return false;\n }\n\n function check() {\n let done = true;\n const fonts = checkedFonts.getKeys();\n for (let i = 0, ii = fonts.length; i < ii; ++i) {\n const font = fonts[i];\n if (checkedFonts.get(font) < retries) {\n if (isAvailable.apply(this, font.split('\\n'))) {\n clear(textHeights);\n // Make sure that loaded fonts are picked up by Safari\n measureContext = null;\n measureFont = undefined;\n checkedFonts.set(font, retries);\n } else {\n checkedFonts.set(font, checkedFonts.get(font) + 1, true);\n done = false;\n }\n }\n }\n if (done) {\n clearInterval(interval);\n interval = undefined;\n }\n }\n\n return function (fontSpec) {\n const font = getFontParameters(fontSpec);\n if (!font) {\n return;\n }\n const families = font.families;\n for (let i = 0, ii = families.length; i < ii; ++i) {\n const family = families[i];\n const key = font.style + '\\n' + font.weight + '\\n' + family;\n if (checkedFonts.get(key) === undefined) {\n checkedFonts.set(key, retries, true);\n if (!isAvailable(font.style, font.weight, family)) {\n checkedFonts.set(key, 0, true);\n if (interval === undefined) {\n interval = setInterval(check, 32);\n }\n }\n }\n }\n };\n})();\n\n/**\n * @param {string} font Font to use for measuring.\n * @return {import(\"../size.js\").Size} Measurement.\n */\nexport const measureTextHeight = (function () {\n /**\n * @type {HTMLDivElement}\n */\n let measureElement;\n return function (fontSpec) {\n let height = textHeights[fontSpec];\n if (height == undefined) {\n if (WORKER_OFFSCREEN_CANVAS) {\n const font = getFontParameters(fontSpec);\n const metrics = measureText(fontSpec, 'Žg');\n const lineHeight = isNaN(Number(font.lineHeight))\n ? 1.2\n : Number(font.lineHeight);\n height =\n lineHeight *\n (metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent);\n } else {\n if (!measureElement) {\n measureElement = document.createElement('div');\n measureElement.innerHTML = 'M';\n measureElement.style.minHeight = '0';\n measureElement.style.maxHeight = 'none';\n measureElement.style.height = 'auto';\n measureElement.style.padding = '0';\n measureElement.style.border = 'none';\n measureElement.style.position = 'absolute';\n measureElement.style.display = 'block';\n measureElement.style.left = '-99999px';\n }\n measureElement.style.font = fontSpec;\n document.body.appendChild(measureElement);\n height = measureElement.offsetHeight;\n document.body.removeChild(measureElement);\n }\n textHeights[fontSpec] = height;\n }\n return height;\n };\n})();\n\n/**\n * @param {string} font Font.\n * @param {string} text Text.\n * @return {TextMetrics} Text metrics.\n */\nfunction measureText(font, text) {\n if (!measureContext) {\n measureContext = createCanvasContext2D(1, 1);\n }\n if (font != measureFont) {\n measureContext.font = font;\n measureFont = measureContext.font;\n }\n return measureContext.measureText(text);\n}\n\n/**\n * @param {string} font Font.\n * @param {string} text Text.\n * @return {number} Width.\n */\nexport function measureTextWidth(font, text) {\n return measureText(font, text).width;\n}\n\n/**\n * Measure text width using a cache.\n * @param {string} font The font.\n * @param {string} text The text to measure.\n * @param {Object} cache A lookup of cached widths by text.\n * @return {number} The text width.\n */\nexport function measureAndCacheTextWidth(font, text, cache) {\n if (text in cache) {\n return cache[text];\n }\n const width = text\n .split('\\n')\n .reduce((prev, curr) => Math.max(prev, measureTextWidth(font, curr)), 0);\n cache[text] = width;\n return width;\n}\n\n/**\n * @param {TextState} baseStyle Base style.\n * @param {Array} chunks Text chunks to measure.\n * @return {{width: number, height: number, widths: Array, heights: Array, lineWidths: Array}}} Text metrics.\n */\nexport function getTextDimensions(baseStyle, chunks) {\n const widths = [];\n const heights = [];\n const lineWidths = [];\n let width = 0;\n let lineWidth = 0;\n let height = 0;\n let lineHeight = 0;\n for (let i = 0, ii = chunks.length; i <= ii; i += 2) {\n const text = chunks[i];\n if (text === '\\n' || i === ii) {\n width = Math.max(width, lineWidth);\n lineWidths.push(lineWidth);\n lineWidth = 0;\n height += lineHeight;\n continue;\n }\n const font = chunks[i + 1] || baseStyle.font;\n const currentWidth = measureTextWidth(font, text);\n widths.push(currentWidth);\n lineWidth += currentWidth;\n const currentHeight = measureTextHeight(font);\n heights.push(currentHeight);\n lineHeight = Math.max(lineHeight, currentHeight);\n }\n return {width, height, widths, heights, lineWidths};\n}\n\n/**\n * @param {CanvasRenderingContext2D} context Context.\n * @param {number} rotation Rotation.\n * @param {number} offsetX X offset.\n * @param {number} offsetY Y offset.\n */\nexport function rotateAtOffset(context, rotation, offsetX, offsetY) {\n if (rotation !== 0) {\n context.translate(offsetX, offsetY);\n context.rotate(rotation);\n context.translate(-offsetX, -offsetY);\n }\n}\n\n/**\n * @param {CanvasRenderingContext2D|import(\"../render/canvas/ZIndexContext.js\").ZIndexContextProxy} context Context.\n * @param {import(\"../transform.js\").Transform|null} transform Transform.\n * @param {number} opacity Opacity.\n * @param {Label|HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} labelOrImage Label.\n * @param {number} originX Origin X.\n * @param {number} originY Origin Y.\n * @param {number} w Width.\n * @param {number} h Height.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../size.js\").Size} scale Scale.\n */\nexport function drawImageOrLabel(\n context,\n transform,\n opacity,\n labelOrImage,\n originX,\n originY,\n w,\n h,\n x,\n y,\n scale,\n) {\n context.save();\n\n if (opacity !== 1) {\n if (context.globalAlpha === undefined) {\n context.globalAlpha = (context) => (context.globalAlpha *= opacity);\n } else {\n context.globalAlpha *= opacity;\n }\n }\n if (transform) {\n context.transform.apply(context, transform);\n }\n\n if (/** @type {*} */ (labelOrImage).contextInstructions) {\n // label\n context.translate(x, y);\n context.scale(scale[0], scale[1]);\n executeLabelInstructions(/** @type {Label} */ (labelOrImage), context);\n } else if (scale[0] < 0 || scale[1] < 0) {\n // flipped image\n context.translate(x, y);\n context.scale(scale[0], scale[1]);\n context.drawImage(\n /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (\n labelOrImage\n ),\n originX,\n originY,\n w,\n h,\n 0,\n 0,\n w,\n h,\n );\n } else {\n // if image not flipped translate and scale can be avoided\n context.drawImage(\n /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (\n labelOrImage\n ),\n originX,\n originY,\n w,\n h,\n x,\n y,\n w * scale[0],\n h * scale[1],\n );\n }\n\n context.restore();\n}\n\n/**\n * @param {Label} label Label.\n * @param {CanvasRenderingContext2D} context Context.\n */\nfunction executeLabelInstructions(label, context) {\n const contextInstructions = label.contextInstructions;\n for (let i = 0, ii = contextInstructions.length; i < ii; i += 2) {\n if (Array.isArray(contextInstructions[i + 1])) {\n context[contextInstructions[i]].apply(\n context,\n contextInstructions[i + 1],\n );\n } else {\n context[contextInstructions[i]] = contextInstructions[i + 1];\n }\n }\n}\n","/**\n * @module ol/style/RegularShape\n */\n\nimport ImageState from '../ImageState.js';\nimport ImageStyle from './Image.js';\nimport {asArray} from '../color.js';\nimport {asColorLike} from '../colorlike.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {\n defaultFillStyle,\n defaultLineCap,\n defaultLineJoin,\n defaultLineWidth,\n defaultMiterLimit,\n defaultStrokeStyle,\n} from '../render/canvas.js';\n\n/**\n * Specify radius for regular polygons, or both radius and radius2 for stars.\n * @typedef {Object} Options\n * @property {import(\"./Fill.js\").default} [fill] Fill style.\n * @property {number} points Number of points for stars and regular polygons. In case of a polygon, the number of points\n * is the number of sides.\n * @property {number} radius Radius of a regular polygon.\n * @property {number} [radius2] Second radius to make a star instead of a regular polygon.\n * @property {number} [angle=0] Shape's angle in radians. A value of 0 will have one of the shape's points facing up.\n * @property {Array} [displacement=[0, 0]] Displacement of the shape in pixels.\n * Positive values will shift the shape right and up.\n * @property {import(\"./Stroke.js\").default} [stroke] Stroke style.\n * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).\n * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view.\n * @property {number|import(\"../size.js\").Size} [scale=1] Scale. Unless two dimensional scaling is required a better\n * result may be obtained with appropriate settings for `radius` and `radius2`.\n * @property {import('./Style.js').DeclutterMode} [declutterMode] Declutter mode.\n */\n\n/**\n * @typedef {Object} RenderOptions\n * @property {import(\"../colorlike.js\").ColorLike|undefined} strokeStyle StrokeStyle.\n * @property {number} strokeWidth StrokeWidth.\n * @property {number} size Size.\n * @property {CanvasLineCap} lineCap LineCap.\n * @property {Array|null} lineDash LineDash.\n * @property {number} lineDashOffset LineDashOffset.\n * @property {CanvasLineJoin} lineJoin LineJoin.\n * @property {number} miterLimit MiterLimit.\n */\n\n/**\n * @classdesc\n * Set regular shape style for vector features. The resulting shape will be\n * a regular polygon when `radius` is provided, or a star when both `radius` and\n * `radius2` are provided.\n * @api\n */\nclass RegularShape extends ImageStyle {\n /**\n * @param {Options} options Options.\n */\n constructor(options) {\n super({\n opacity: 1,\n rotateWithView:\n options.rotateWithView !== undefined ? options.rotateWithView : false,\n rotation: options.rotation !== undefined ? options.rotation : 0,\n scale: options.scale !== undefined ? options.scale : 1,\n displacement:\n options.displacement !== undefined ? options.displacement : [0, 0],\n declutterMode: options.declutterMode,\n });\n\n /**\n * @private\n * @type {Object}\n */\n this.canvases_;\n\n /**\n * @private\n * @type {HTMLCanvasElement|null}\n */\n this.hitDetectionCanvas_ = null;\n\n /**\n * @private\n * @type {import(\"./Fill.js\").default|null}\n */\n this.fill_ = options.fill !== undefined ? options.fill : null;\n\n /**\n * @private\n * @type {Array}\n */\n this.origin_ = [0, 0];\n\n /**\n * @private\n * @type {number}\n */\n this.points_ = options.points;\n\n /**\n * @protected\n * @type {number}\n */\n this.radius_ = options.radius;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.radius2_ = options.radius2;\n\n /**\n * @private\n * @type {number}\n */\n this.angle_ = options.angle !== undefined ? options.angle : 0;\n\n /**\n * @private\n * @type {import(\"./Stroke.js\").default|null}\n */\n this.stroke_ = options.stroke !== undefined ? options.stroke : null;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.size_;\n\n /**\n * @private\n * @type {RenderOptions}\n */\n this.renderOptions_;\n\n this.imageState_ =\n this.fill_ && this.fill_.loading()\n ? ImageState.LOADING\n : ImageState.LOADED;\n if (this.imageState_ === ImageState.LOADING) {\n this.ready().then(() => (this.imageState_ = ImageState.LOADED));\n }\n this.render();\n }\n\n /**\n * Clones the style.\n * @return {RegularShape} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n const style = new RegularShape({\n fill: this.getFill() ? this.getFill().clone() : undefined,\n points: this.getPoints(),\n radius: this.getRadius(),\n radius2: this.getRadius2(),\n angle: this.getAngle(),\n stroke: this.getStroke() ? this.getStroke().clone() : undefined,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n style.setOpacity(this.getOpacity());\n return style;\n }\n\n /**\n * Get the anchor point in pixels. The anchor determines the center point for the\n * symbolizer.\n * @return {Array} Anchor.\n * @api\n */\n getAnchor() {\n const size = this.size_;\n const displacement = this.getDisplacement();\n const scale = this.getScaleArray();\n // anchor is scaled by renderer but displacement should not be scaled\n // so divide by scale here\n return [\n size[0] / 2 - displacement[0] / scale[0],\n size[1] / 2 + displacement[1] / scale[1],\n ];\n }\n\n /**\n * Get the angle used in generating the shape.\n * @return {number} Shape's rotation in radians.\n * @api\n */\n getAngle() {\n return this.angle_;\n }\n\n /**\n * Get the fill style for the shape.\n * @return {import(\"./Fill.js\").default|null} Fill style.\n * @api\n */\n getFill() {\n return this.fill_;\n }\n\n /**\n * Set the fill style.\n * @param {import(\"./Fill.js\").default|null} fill Fill style.\n * @api\n */\n setFill(fill) {\n this.fill_ = fill;\n this.render();\n }\n\n /**\n * @return {HTMLCanvasElement} Image element.\n */\n getHitDetectionImage() {\n if (!this.hitDetectionCanvas_) {\n this.hitDetectionCanvas_ = this.createHitDetectionCanvas_(\n this.renderOptions_,\n );\n }\n return this.hitDetectionCanvas_;\n }\n\n /**\n * Get the image icon.\n * @param {number} pixelRatio Pixel ratio.\n * @return {HTMLCanvasElement} Image or Canvas element.\n * @api\n */\n getImage(pixelRatio) {\n let image = this.canvases_[pixelRatio];\n if (!image) {\n const renderOptions = this.renderOptions_;\n const context = createCanvasContext2D(\n renderOptions.size * pixelRatio,\n renderOptions.size * pixelRatio,\n );\n this.draw_(renderOptions, context, pixelRatio);\n\n image = context.canvas;\n this.canvases_[pixelRatio] = image;\n }\n return image;\n }\n\n /**\n * Get the image pixel ratio.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Pixel ratio.\n */\n getPixelRatio(pixelRatio) {\n return pixelRatio;\n }\n\n /**\n * @return {import(\"../size.js\").Size} Image size.\n */\n getImageSize() {\n return this.size_;\n }\n\n /**\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return this.imageState_;\n }\n\n /**\n * Get the origin of the symbolizer.\n * @return {Array} Origin.\n * @api\n */\n getOrigin() {\n return this.origin_;\n }\n\n /**\n * Get the number of points for generating the shape.\n * @return {number} Number of points for stars and regular polygons.\n * @api\n */\n getPoints() {\n return this.points_;\n }\n\n /**\n * Get the (primary) radius for the shape.\n * @return {number} Radius.\n * @api\n */\n getRadius() {\n return this.radius_;\n }\n\n /**\n * Get the secondary radius for the shape.\n * @return {number|undefined} Radius2.\n * @api\n */\n getRadius2() {\n return this.radius2_;\n }\n\n /**\n * Get the size of the symbolizer (in pixels).\n * @return {import(\"../size.js\").Size} Size.\n * @api\n */\n getSize() {\n return this.size_;\n }\n\n /**\n * Get the stroke style for the shape.\n * @return {import(\"./Stroke.js\").default|null} Stroke style.\n * @api\n */\n getStroke() {\n return this.stroke_;\n }\n\n /**\n * Set the stroke style.\n * @param {import(\"./Stroke.js\").default|null} stroke Stroke style.\n * @api\n */\n setStroke(stroke) {\n this.stroke_ = stroke;\n this.render();\n }\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n listenImageChange(listener) {}\n\n /**\n * Load not yet loaded URI.\n */\n load() {}\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n unlistenImageChange(listener) {}\n\n /**\n * Calculate additional canvas size needed for the miter.\n * @param {string} lineJoin Line join\n * @param {number} strokeWidth Stroke width\n * @param {number} miterLimit Miter limit\n * @return {number} Additional canvas size needed\n * @private\n */\n calculateLineJoinSize_(lineJoin, strokeWidth, miterLimit) {\n if (\n strokeWidth === 0 ||\n this.points_ === Infinity ||\n (lineJoin !== 'bevel' && lineJoin !== 'miter')\n ) {\n return strokeWidth;\n }\n // m | ^\n // i | |\\ .\n // t >| #\\\n // e | |\\ \\ .\n // r \\s\\\n // | \\t\\ . .\n // \\r\\ . .\n // | \\o\\ . . . . .\n // e \\k\\ . . . .\n // | \\e\\ . . . . .\n // d \\ \\ . . . .\n // | _ _a_ _\\# . . .\n // r1 / ` . .\n // | . .\n // b / . .\n // | . .\n // / r2 . .\n // | . .\n // / . .\n // |α . .\n // / . .\n // ° center\n let r1 = this.radius_;\n let r2 = this.radius2_ === undefined ? r1 : this.radius2_;\n if (r1 < r2) {\n const tmp = r1;\n r1 = r2;\n r2 = tmp;\n }\n const points =\n this.radius2_ === undefined ? this.points_ : this.points_ * 2;\n const alpha = (2 * Math.PI) / points;\n const a = r2 * Math.sin(alpha);\n const b = Math.sqrt(r2 * r2 - a * a);\n const d = r1 - b;\n const e = Math.sqrt(a * a + d * d);\n const miterRatio = e / a;\n if (lineJoin === 'miter' && miterRatio <= miterLimit) {\n return miterRatio * strokeWidth;\n }\n // Calculate the distance from center to the stroke corner where\n // it was cut short because of the miter limit.\n // l\n // ----+---- <= distance from center to here is maxr\n // /####|k ##\\\n // /#####^#####\\\n // /#### /+\\# s #\\\n // /### h/+++\\# t #\\\n // /### t/+++++\\# r #\\\n // /### a/+++++++\\# o #\\\n // /### p/++ fill +\\# k #\\\n ///#### /+++++^+++++\\# e #\\\n //#####/+++++/+\\+++++\\#####\\\n const k = strokeWidth / 2 / miterRatio;\n const l = (strokeWidth / 2) * (d / e);\n const maxr = Math.sqrt((r1 + k) * (r1 + k) + l * l);\n const bevelAdd = maxr - r1;\n if (this.radius2_ === undefined || lineJoin === 'bevel') {\n return bevelAdd * 2;\n }\n // If outer miter is over the miter limit the inner miter may reach through the\n // center and be longer than the bevel, same calculation as above but swap r1 / r2.\n const aa = r1 * Math.sin(alpha);\n const bb = Math.sqrt(r1 * r1 - aa * aa);\n const dd = r2 - bb;\n const ee = Math.sqrt(aa * aa + dd * dd);\n const innerMiterRatio = ee / aa;\n if (innerMiterRatio <= miterLimit) {\n const innerLength = (innerMiterRatio * strokeWidth) / 2 - r2 - r1;\n return 2 * Math.max(bevelAdd, innerLength);\n }\n return bevelAdd * 2;\n }\n\n /**\n * @return {RenderOptions} The render options\n * @protected\n */\n createRenderOptions() {\n let lineCap = defaultLineCap;\n let lineJoin = defaultLineJoin;\n let miterLimit = 0;\n let lineDash = null;\n let lineDashOffset = 0;\n let strokeStyle;\n let strokeWidth = 0;\n\n if (this.stroke_) {\n strokeStyle = asColorLike(this.stroke_.getColor() ?? defaultStrokeStyle);\n strokeWidth = this.stroke_.getWidth() ?? defaultLineWidth;\n lineDash = this.stroke_.getLineDash();\n lineDashOffset = this.stroke_.getLineDashOffset() ?? 0;\n lineJoin = this.stroke_.getLineJoin() ?? defaultLineJoin;\n lineCap = this.stroke_.getLineCap() ?? defaultLineCap;\n miterLimit = this.stroke_.getMiterLimit() ?? defaultMiterLimit;\n }\n\n const add = this.calculateLineJoinSize_(lineJoin, strokeWidth, miterLimit);\n const maxRadius = Math.max(this.radius_, this.radius2_ || 0);\n const size = Math.ceil(2 * maxRadius + add);\n\n return {\n strokeStyle: strokeStyle,\n strokeWidth: strokeWidth,\n size: size,\n lineCap: lineCap,\n lineDash: lineDash,\n lineDashOffset: lineDashOffset,\n lineJoin: lineJoin,\n miterLimit: miterLimit,\n };\n }\n\n /**\n * @protected\n */\n render() {\n this.renderOptions_ = this.createRenderOptions();\n const size = this.renderOptions_.size;\n this.canvases_ = {};\n this.hitDetectionCanvas_ = null;\n this.size_ = [size, size];\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @param {CanvasRenderingContext2D} context The rendering context.\n * @param {number} pixelRatio The pixel ratio.\n */\n draw_(renderOptions, context, pixelRatio) {\n context.scale(pixelRatio, pixelRatio);\n // set origin to canvas center\n context.translate(renderOptions.size / 2, renderOptions.size / 2);\n\n this.createPath_(context);\n\n if (this.fill_) {\n let color = this.fill_.getColor();\n if (color === null) {\n color = defaultFillStyle;\n }\n context.fillStyle = asColorLike(color);\n context.fill();\n }\n if (renderOptions.strokeStyle) {\n context.strokeStyle = renderOptions.strokeStyle;\n context.lineWidth = renderOptions.strokeWidth;\n if (renderOptions.lineDash) {\n context.setLineDash(renderOptions.lineDash);\n context.lineDashOffset = renderOptions.lineDashOffset;\n }\n context.lineCap = renderOptions.lineCap;\n context.lineJoin = renderOptions.lineJoin;\n context.miterLimit = renderOptions.miterLimit;\n context.stroke();\n }\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @return {HTMLCanvasElement} Canvas containing the icon\n */\n createHitDetectionCanvas_(renderOptions) {\n let context;\n if (this.fill_) {\n let color = this.fill_.getColor();\n\n // determine if fill is transparent (or pattern or gradient)\n let opacity = 0;\n if (typeof color === 'string') {\n color = asArray(color);\n }\n if (color === null) {\n opacity = 1;\n } else if (Array.isArray(color)) {\n opacity = color.length === 4 ? color[3] : 1;\n }\n if (opacity === 0) {\n // if a transparent fill style is set, create an extra hit-detection image\n // with a default fill style\n context = createCanvasContext2D(renderOptions.size, renderOptions.size);\n this.drawHitDetectionCanvas_(renderOptions, context);\n }\n }\n return context ? context.canvas : this.getImage(1);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} context The context to draw in.\n */\n createPath_(context) {\n let points = this.points_;\n const radius = this.radius_;\n if (points === Infinity) {\n context.arc(0, 0, radius, 0, 2 * Math.PI);\n } else {\n const radius2 = this.radius2_ === undefined ? radius : this.radius2_;\n if (this.radius2_ !== undefined) {\n points *= 2;\n }\n const startAngle = this.angle_ - Math.PI / 2;\n const step = (2 * Math.PI) / points;\n for (let i = 0; i < points; i++) {\n const angle0 = startAngle + i * step;\n const radiusC = i % 2 === 0 ? radius : radius2;\n context.lineTo(radiusC * Math.cos(angle0), radiusC * Math.sin(angle0));\n }\n context.closePath();\n }\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @param {CanvasRenderingContext2D} context The context.\n */\n drawHitDetectionCanvas_(renderOptions, context) {\n // set origin to canvas center\n context.translate(renderOptions.size / 2, renderOptions.size / 2);\n\n this.createPath_(context);\n\n context.fillStyle = defaultFillStyle;\n context.fill();\n if (renderOptions.strokeStyle) {\n context.strokeStyle = renderOptions.strokeStyle;\n context.lineWidth = renderOptions.strokeWidth;\n if (renderOptions.lineDash) {\n context.setLineDash(renderOptions.lineDash);\n context.lineDashOffset = renderOptions.lineDashOffset;\n }\n context.lineJoin = renderOptions.lineJoin;\n context.miterLimit = renderOptions.miterLimit;\n context.stroke();\n }\n }\n\n ready() {\n return this.fill_ ? this.fill_.ready() : Promise.resolve();\n }\n}\n\nexport default RegularShape;\n","/**\n * @module ol/style/Circle\n */\n\nimport RegularShape from './RegularShape.js';\n\n/**\n * @typedef {Object} Options\n * @property {import(\"./Fill.js\").default} [fill] Fill style.\n * @property {number} radius Circle radius.\n * @property {import(\"./Stroke.js\").default} [stroke] Stroke style.\n * @property {Array} [displacement=[0,0]] displacement\n * @property {number|import(\"../size.js\").Size} [scale=1] Scale. A two dimensional scale will produce an ellipse.\n * Unless two dimensional scaling is required a better result may be obtained with an appropriate setting for `radius`.\n * @property {number} [rotation=0] Rotation in radians\n * (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).\n * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view\n * (meaningful only when used in conjunction with a two dimensional scale).\n * @property {import('./Style.js').DeclutterMode} [declutterMode] Declutter mode\n */\n\n/**\n * @classdesc\n * Set circle style for vector features.\n * @api\n */\nclass CircleStyle extends RegularShape {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options ? options : {radius: 5};\n\n super({\n points: Infinity,\n fill: options.fill,\n radius: options.radius,\n stroke: options.stroke,\n scale: options.scale !== undefined ? options.scale : 1,\n rotation: options.rotation !== undefined ? options.rotation : 0,\n rotateWithView:\n options.rotateWithView !== undefined ? options.rotateWithView : false,\n displacement:\n options.displacement !== undefined ? options.displacement : [0, 0],\n declutterMode: options.declutterMode,\n });\n }\n\n /**\n * Clones the style.\n * @return {CircleStyle} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n const style = new CircleStyle({\n fill: this.getFill() ? this.getFill().clone() : undefined,\n stroke: this.getStroke() ? this.getStroke().clone() : undefined,\n radius: this.getRadius(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n style.setOpacity(this.getOpacity());\n return style;\n }\n\n /**\n * Set the circle radius.\n *\n * @param {number} radius Circle radius.\n * @api\n */\n setRadius(radius) {\n this.radius_ = radius;\n this.render();\n }\n}\n\nexport default CircleStyle;\n","/**\n * @module ol/style/Style\n */\n\nimport CircleStyle from './Circle.js';\nimport Fill from './Fill.js';\nimport Stroke from './Stroke.js';\nimport {assert} from '../asserts.js';\n\n/**\n * Defines how symbols and text are decluttered on layers ith `declutter` set to `true`\n * * **declutter**: Overlapping symbols and text are decluttered.\n * * **obstacle**: Symbols and text are rendered, but serve as obstacle for subsequent attempts\n * to place a symbol or text at the same location.\n * * **none**: No decluttering is done.\n *\n * @typedef {\"declutter\"|\"obstacle\"|\"none\"} DeclutterMode\n */\n\n/**\n * A function that takes an {@link module:ol/Feature~Feature} and a `{number}`\n * representing the view's resolution. The function should return a\n * {@link module:ol/style/Style~Style} or an array of them. This way e.g. a\n * vector layer can be styled. If the function returns `undefined`, the\n * feature will not be rendered.\n *\n * @typedef {function(import(\"../Feature.js\").FeatureLike, number):(Style|Array