@plannco-ppe/ppe-core 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.iife.js +1 -1
- package/dist/index.js +6 -1
- package/dist/index.umd.js +6 -6
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
(function(ht,Pt){typeof exports=="object"&&typeof module<"u"?Pt(exports,require("jspdf")):typeof define=="function"&&define.amd?define(["exports","jspdf"],Pt):(ht=typeof globalThis<"u"?globalThis:ht||self,Pt(ht.ppe={},ht.jspdf))})(this,(function(ht,Pt){"use strict";var C_=Object.defineProperty;var w_=(ht,Pt,et)=>Pt in ht?C_(ht,Pt,{enumerable:!0,configurable:!0,writable:!0,value:et}):ht[Pt]=et;var vh=(ht,Pt,et)=>w_(ht,typeof Pt!="symbol"?Pt+"":Pt,et);const et={ANIMATING:0,INTERACTING:1};function Th(n,t,e){let i,s;e=e||Ge;let r=0,o=n.length,a=!1;for(;r<o;)i=r+(o-r>>1),s=+e(n[i],t),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function Ge(n,t){return n>t?1:n<t?-1:0}function Ph(n,t){return n<t?1:n>t?-1:0}function Fs(n,t,e){if(n[0]<=t)return 0;const i=n.length;if(t<=n[i-1])return i-1;if(typeof e=="function"){for(let s=1;s<i;++s){const r=n[s];if(r===t)return s;if(r<t)return e(t,n[s-1],r)>0?s-1:s}return i-1}if(e>0){for(let s=1;s<i;++s)if(n[s]<t)return s-1;return i-1}if(e<0){for(let s=1;s<i;++s)if(n[s]<=t)return s;return i-1}for(let s=1;s<i;++s){if(n[s]==t)return s;if(n[s]<t)return n[s-1]-t<t-n[s]?s-1:s}return i-1}function Mh(n,t,e){for(;t<e;){const i=n[t];n[t]=n[e],n[e]=i,++t,--e}}function Ot(n,t){const e=Array.isArray(t)?t:[t],i=e.length;for(let s=0;s<i;s++)n[n.length]=e[s]}function oe(n,t){const e=n.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(n[i]!==t[i])return!1;return!0}const ct={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function ut(n){const t=kt();for(let e=0,i=n.length;e<i;++e)Wi(t,n[e]);return t}function Oi(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function Go(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function ze(n,t,e){let i,s;return t<n[0]?i=n[0]-t:n[2]<t?i=t-n[2]:i=0,e<n[1]?s=n[1]-e:n[3]<e?s=e-n[3]:s=0,i*i+s*s}function ki(n,t){return bs(n,t[0],t[1])}function ae(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function bs(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function Ds(n,t){const e=n[0],i=n[1],s=n[2],r=n[3],o=t[0],a=t[1];let l=ct.UNKNOWN;return o<e?l=l|ct.LEFT:o>s&&(l=l|ct.RIGHT),a<i?l=l|ct.BELOW:a>r&&(l=l|ct.ABOVE),l===ct.UNKNOWN&&(l=ct.INTERSECTING),l}function kt(){return[1/0,1/0,-1/0,-1/0]}function We(n,t,e,i,s){return s?(s[0]=n,s[1]=t,s[2]=e,s[3]=i,s):[n,t,e,i]}function Ni(n){return We(1/0,1/0,-1/0,-1/0,n)}function Gi(n,t){const e=n[0],i=n[1];return We(e,i,e,i,t)}function Os(n,t,e,i,s){const r=Ni(s);return Wo(r,n,t,e,i)}function zi(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function zo(n,t){return t[0]<n[0]&&(n[0]=t[0]),t[2]>n[2]&&(n[2]=t[2]),t[1]<n[1]&&(n[1]=t[1]),t[3]>n[3]&&(n[3]=t[3]),n}function Wi(n,t){t[0]<n[0]&&(n[0]=t[0]),t[0]>n[2]&&(n[2]=t[0]),t[1]<n[1]&&(n[1]=t[1]),t[1]>n[3]&&(n[3]=t[1])}function Wo(n,t,e,i,s){for(;e<i;e+=s)Lh(n,t[e],t[e+1]);return n}function Lh(n,t,e){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}function jo(n,t){let e;return e=t(ks(n)),e||(e=t(Ns(n)),e)||(e=t(zs(n)),e)||(e=t(An(n)),e)?e:!1}function Ah(n){let t=0;return si(n)||(t=K(n)*dt(n)),t}function ks(n){return[n[0],n[1]]}function Ns(n){return[n[2],n[1]]}function Xt(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function Ln(n,t,e,i,s){const[r,o,a,l,h,c,u,d]=Fh(n,t,e,i);return We(Math.min(r,a,h,u),Math.min(o,l,c,d),Math.max(r,a,h,u),Math.max(o,l,c,d),s)}function Fh(n,t,e,i){const s=t*i[0]/2,r=t*i[1]/2,o=Math.cos(e),a=Math.sin(e),l=s*o,h=s*a,c=r*o,u=r*a,d=n[0],f=n[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function dt(n){return n[3]-n[1]}function Gs(n,t,e){const i=e||kt();return _t(n,t)?(n[0]>t[0]?i[0]=n[0]:i[0]=t[0],n[1]>t[1]?i[1]=n[1]:i[1]=t[1],n[2]<t[2]?i[2]=n[2]:i[2]=t[2],n[3]<t[3]?i[3]=n[3]:i[3]=t[3]):Ni(i),i}function An(n){return[n[0],n[3]]}function zs(n){return[n[2],n[3]]}function K(n){return n[2]-n[0]}function _t(n,t){return n[0]<=t[2]&&n[2]>=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function si(n){return n[2]<n[0]||n[3]<n[1]}function bh(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function Dh(n,t,e){let i=!1;const s=Ds(n,t),r=Ds(n,e);if(s===ct.INTERSECTING||r===ct.INTERSECTING)i=!0;else{const o=n[0],a=n[1],l=n[2],h=n[3],c=t[0],u=t[1],d=e[0],f=e[1],g=(f-u)/(d-c);let m,_;r&ct.ABOVE&&!(s&ct.ABOVE)&&(m=d-(f-h)/g,i=m>=o&&m<=l),!i&&r&ct.RIGHT&&!(s&ct.RIGHT)&&(_=f-(d-l)*g,i=_>=a&&_<=h),!i&&r&ct.BELOW&&!(s&ct.BELOW)&&(m=d-(f-a)/g,i=m>=o&&m<=l),!i&&r&ct.LEFT&&!(s&ct.LEFT)&&(_=f-(d-o)*g,i=_>=a&&_<=h)}return i}function Vo(n,t){const e=t.getExtent(),i=Xt(n);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){const s=K(e),o=Math.floor((i[0]-e[0])/s)*s;n[0]-=o,n[2]-=o}return n}function Oh(n,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];Vo(n,t);const s=K(i);if(K(n)>s)return[[i[0],n[1],i[2],n[3]]];if(n[0]<i[0])return[[n[0]+s,n[1],i[2],n[3]],[i[0],n[1],n[2],n[3]]];if(n[2]>i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-s,n[3]]]}return[n]}function rt(n,t,e){return Math.min(Math.max(n,t),e)}function kh(n,t,e,i,s,r){const o=s-e,a=r-i;if(o!==0||a!==0){const l=((n-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=s,i=r):l>0&&(e+=o*l,i+=a*l)}return le(n,t,e,i)}function le(n,t,e,i){const s=e-n,r=i-t;return s*s+r*r}function Nh(n){const t=n.length;for(let i=0;i<t;i++){let s=i,r=Math.abs(n[i][i]);for(let a=i+1;a<t;a++){const l=Math.abs(n[a][i]);l>r&&(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<t;a++){const l=-n[a][i]/n[i][i];for(let h=i;h<t+1;h++)i==h?n[a][h]=0:n[a][h]+=l*n[i][h]}}const e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=n[i][t]/n[i][i];for(let s=i-1;s>=0;s--)n[s][t]-=n[s][i]*e[i]}return e}function Xo(n){return n*180/Math.PI}function Re(n){return n*Math.PI/180}function ri(n,t){const e=n%t;return e*t<0?e+t:e}function bt(n,t,e){return n+e*(t-n)}function Fn(n,t){const e=Math.pow(10,t);return Math.round(n*e)/e}function bn(n,t){return Math.ceil(Fn(n,t))}function Ws(n,t,e){if(n>=t&&n<e)return n;const i=e-t;return((n-t)%i+i)%i+t}function Gh(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function zh(n,t){const e=t.getRadius(),i=t.getCenter(),s=i[0],r=i[1],o=n[0],a=n[1];let l=o-s;const h=a-r;l===0&&h===0&&(l=1);const c=Math.sqrt(l*l+h*h),u=s+e*l/c,d=r+e*h/c;return[u,d]}function js(n,t){const e=n[0],i=n[1],s=t[0],r=t[1],o=s[0],a=s[1],l=r[0],h=r[1],c=l-o,u=h-a,d=c===0&&u===0?0:(c*(e-o)+u*(i-a))/(c*c+u*u||0);let f,g;return d<=0?(f=o,g=a):d>=1?(f=l,g=h):(f=o+d*c,g=a+d*u),[f,g]}function It(n,t){let e=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Vs(n,t){const e=Math.cos(t),i=Math.sin(t),s=n[0]*e-n[1]*i,r=n[1]*e+n[0]*i;return n[0]=s,n[1]=r,n}function Wh(n,t){return n[0]*=t,n[1]*=t,n}function he(n,t){const e=n[0]-t[0],i=n[1]-t[1];return e*e+i*i}function Dn(n,t){return Math.sqrt(he(n,t))}function jh(n,t){return he(n,js(n,t))}function Bo(n,t){if(t.canWrapX()){const e=K(t.getExtent()),i=Vh(n,t,e);i&&(n[0]-=i*e)}return n}function Vh(n,t,e){const i=t.getExtent();let s=0;return t.canWrapX()&&(n[0]<i[0]||n[0]>i[2])&&(e=e||K(i),s=Math.floor((n[0]-i[0])/e)),s}const je=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"";je.includes("safari")&&!je.includes("chrom")&&(je.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(je));const Xh=je.includes("webkit")&&!je.includes("edge"),Xs=je.includes("macintosh"),Bh=typeof devicePixelRatio<"u"?devicePixelRatio:1,Bs=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Yo=typeof Image<"u"&&Image.prototype.decode,Zo=typeof createImageBitmap=="function",Ko=(function(){let n=!1;try{const t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n})();function ft(n,t,e,i){let s;return e&&e.length?s=e.shift():Bs?s=new OffscreenCanvas(n||300,t||300):s=document.createElement("canvas"),n&&(s.width=n),t&&(s.height=t),s.getContext("2d",i)}let Ys;function On(){return Ys||(Ys=ft(1,1)),Ys}function Zs(n){const t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function Yh(n){let t=n.offsetWidth;const e=getComputedStyle(n);return t+=parseInt(e.marginLeft,10)+parseInt(e.marginRight,10),t}function Zh(n){let t=n.offsetHeight;const e=getComputedStyle(n);return t+=parseInt(e.marginTop,10)+parseInt(e.marginBottom,10),t}function Uo(n,t){const e=t.parentNode;e&&e.replaceChild(n,t)}function Ho(n){for(;n.lastChild;)n.lastChild.remove()}function Kh(n,t){const e=n.childNodes;for(let i=0;;++i){const s=e[i],r=t[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)}}}function qo(...n){console.warn(...n)}const $o={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class kn{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||$o[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const ji=6378137,oi=Math.PI*ji,Uh=[-oi,-oi,oi,oi],Hh=[-180,-85,180,85],Nn=ji*Math.log(Math.tan(Math.PI/2));class ai extends kn{constructor(t){super({code:t,units:"m",extent:Uh,global:!0,worldExtent:Hh,getPointResolution:function(e,i){return e/Math.cosh(i[1]/ji)}})}}const Jo=[new ai("EPSG:3857"),new ai("EPSG:102100"),new ai("EPSG:102113"),new ai("EPSG:900913"),new ai("http://www.opengis.net/def/crs/EPSG/0/3857"),new ai("http://www.opengis.net/gml/srs/epsg.xml#3857")];function qh(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i){t[r]=oi*n[r]/180;let o=ji*Math.log(Math.tan(Math.PI*(+n[r+1]+90)/360));o>Nn?o=Nn:o<-Nn&&(o=-Nn),t[r+1]=o}return t}function $h(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i)t[r]=180*n[r]/oi,t[r+1]=360*Math.atan(Math.exp(n[r+1]/ji))/Math.PI-90;return t}const Jh=6378137,Qo=[-180,-90,180,90],Qh=Math.PI*Jh/180;class Ve extends kn{constructor(t,e){super({code:t,units:"degrees",extent:Qo,axisOrientation:e,global:!0,metersPerUnit:Qh,worldExtent:Qo})}}const ta=[new Ve("CRS:84"),new Ve("EPSG:4326","neu"),new Ve("urn:ogc:def:crs:OGC:1.3:CRS84"),new Ve("urn:ogc:def:crs:OGC:2:84"),new Ve("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Ve("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Ve("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Ks={};function tc(n){return Ks[n]||Ks[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function ec(n,t){Ks[n]=t}function li(n){for(const t in n)delete n[t]}function Xe(n){let t;for(t in n)return!1;return!t}let hi={};function Vi(n,t,e){const i=n.getCode(),s=t.getCode();i in hi||(hi[i]={}),hi[i][s]=e}function Us(n,t){return n in hi&&t in hi[n]?hi[n][t]:null}const Gn=.9996,Nt=.00669438,zn=Nt*Nt,Wn=zn*Nt,Be=Nt/(1-Nt),ea=Math.sqrt(1-Nt),ci=(1-ea)/(1+ea),ia=ci*ci,Hs=ia*ci,qs=Hs*ci,na=qs*ci,sa=1-Nt/4-3*zn/64-5*Wn/256,ic=3*Nt/8+3*zn/32+45*Wn/1024,nc=15*zn/256+45*Wn/1024,sc=35*Wn/3072,rc=3/2*ci-27/32*Hs+269/512*na,oc=21/16*ia-55/32*qs,ac=151/96*Hs-417/128*na,lc=1097/512*qs,jn=6378137;function hc(n,t,e){const i=n-5e5,o=(e.north?t:t-1e7)/Gn/(jn*sa),a=o+rc*Math.sin(2*o)+oc*Math.sin(4*o)+ac*Math.sin(6*o)+lc*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-Nt*h,m=Math.sqrt(1-Nt*h),_=jn/m,y=(1-Nt)/g,p=Be*c**2,E=p*p,x=i/(_*Gn),C=x*x,S=C*x,T=S*x,I=T*x,R=I*x,M=a-u/y*(C/2-T/24*(5+3*d+10*p-4*E-9*Be))+R/720*(61+90*d+298*p+45*f-252*Be-3*E);let k=(x-S/6*(1+2*d+p)+I/120*(5-2*p+28*d-3*E+8*Be+24*f))/c;return k=Ws(k+Re(aa(e.number)),-Math.PI,Math.PI),[Xo(k),Xo(M)]}const ra=-80,oa=84,cc=-180,uc=180;function dc(n,t,e){n=Ws(n,cc,uc),t<ra?t=ra:t>oa&&(t=oa);const i=Re(t),s=Math.sin(i),r=Math.cos(i),o=s/r,a=o*o,l=a*a,h=Re(n),c=aa(e.number),u=Re(c),d=jn/Math.sqrt(1-Nt*s**2),f=Be*r**2,g=r*Ws(h-u,-Math.PI,Math.PI),m=g*g,_=m*g,y=_*g,p=y*g,E=p*g,x=jn*(sa*i-ic*Math.sin(2*i)+nc*Math.sin(4*i)-sc*Math.sin(6*i)),C=Gn*d*(g+_/6*(1-a+f)+p/120*(5-18*a+l+72*f-58*Be))+5e5;let S=Gn*(x+d*o*(m/2+y/24*(5-a+9*f+4*f**2)+E/720*(61-58*a+l+600*f-330*Be)));return e.north||(S+=1e7),[C,S]}function aa(n){return(n-1)*6-180+3}const fc=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function la(n){let t=0;for(const s of fc){const r=n.match(s);if(r){t=parseInt(r[1]);break}}if(!t)return null;let e=0,i=!1;return t>32700&&t<32761?e=t-32700:t>32600&&t<32661&&(i=!0,e=t-32600),e?{number:e,north:i}:null}function ha(n,t){return function(e,i,s,r){const o=e.length;s=s>1?s:2,r=r??s,i||(s>2?i=e.slice():i=new Array(o));for(let a=0;a<o;a+=r){const l=e[a],h=e[a+1],c=n(l,h,t);i[a]=c[0],i[a+1]=c[1]}return i}}function gc(n){return la(n)?new kn({code:n,units:"m"}):null}function _c(n){const t=la(n.getCode());return t?{forward:ha(dc,t),inverse:ha(hc,t)}:null}const mc=63710088e-1;function ca(n,t,e){e=e||mc;const i=Re(n[1]),s=Re(t[1]),r=(s-i)/2,o=Re(t[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*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}const yc=[_c],pc=[gc];let $s=!0;function xc(n){$s=!1}function Js(n,t){if(t!==void 0){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];t=t}else t=n.slice();return t}function Qs(n){ec(n.getCode(),n),Vi(n,n,Js)}function Ec(n){n.forEach(Qs)}function ot(n){if(typeof n!="string")return n;const t=tc(n);if(t)return t;for(const e of pc){const i=e(n);if(i)return i}return null}function ua(n,t,e,i){n=ot(n);let s;const r=n.getPointResolutionFunc();if(r)s=r(t,e);else{const o=n.getUnits();if(o=="degrees"&&!i||i=="degrees")s=t;else{const a=ir(n,ot("EPSG:4326"));if(!a&&o!=="degrees")s=t*n.getMetersPerUnit();else{let h=[e[0]-t/2,e[1],e[0]+t/2,e[1],e[0],e[1]-t/2,e[0],e[1]+t/2];h=a(h,h,2);const c=ca(h.slice(0,2),h.slice(2,4)),u=ca(h.slice(4,6),h.slice(6,8));s=(c+u)/2}const l=n.getMetersPerUnit();l!==void 0&&(s/=l)}}return s}function da(n){Ec(n),n.forEach(function(t){n.forEach(function(e){t!==e&&Vi(t,e,Js)})})}function Cc(n,t,e,i){n.forEach(function(s){t.forEach(function(r){Vi(s,r,e),Vi(r,s,i)})})}function tr(n,t){return n?typeof n=="string"?ot(n):n:ot(t)}function wc(n){return(function(t,e,i,s){const r=t.length;i=i!==void 0?i:2,s=s??i,e=e!==void 0?e:new Array(r);for(let o=0;o<r;o+=s){const a=n(t.slice(o,o+i)),l=a.length;for(let h=0,c=s;h<c;++h)e[o+h]=h>=l?t[o+h]:a[h]}return e})}function er(n,t){if(n===t)return!0;const e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||ir(n,t)===Js)&&e}function ir(n,t){const e=n.getCode(),i=t.getCode();let s=Us(e,i);if(s)return s;let r=null,o=null;for(const l of yc)r||(r=l(n)),o||(o=l(t));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)s=nr(r.inverse,o.forward);else{const l=Us(e,a);l&&(s=nr(l,o.forward))}else{const l=Us(a,i);l&&(s=nr(r.inverse,l))}return s&&(Qs(n),Qs(t),Vi(n,t,s)),s}function nr(n,t){return function(e,i,s,r){return i=n(e,i,s,r),t(i,i,s,r)}}function Xi(n,t){const e=ot(n),i=ot(t);return ir(e,i)}function fa(n,t,e){const i=Xi(t,e);if(!i){const s=ot(t).getCode(),r=ot(e).getCode();throw new Error(`No transform available between ${s} and ${r}`)}return i(n,void 0,n.length)}function ve(n,t){return n}function U(n,t){return $s&&!It(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&($s=!1,qo("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function Vn(n,t){return n}function Te(n,t){return n}function Sc(){da(Jo),da(ta),Cc(ta,Jo,qh,$h)}Sc();const Gt={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"},P={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4},sr=[NaN,NaN,NaN,0];let rr;function Ic(){return rr||(rr=ft(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),rr}const Rc=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,vc=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Tc=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Pc=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Xn(n,t){return n.endsWith("%")?Number(n.substring(0,n.length-1))/t:Number(n)}function Bi(n){throw new Error('failed to parse "'+n+'" as color')}function ga(n){if(n.toLowerCase().startsWith("rgb")){const r=n.match(vc)||n.match(Rc)||n.match(Tc);if(r){const o=r[4],a=100/255;return[rt(Xn(r[1],a)+.5|0,0,255),rt(Xn(r[2],a)+.5|0,0,255),rt(Xn(r[3],a)+.5|0,0,255),o!==void 0?rt(Xn(o,100),0,1):1]}Bi(n)}if(n.startsWith("#")){if(Pc.test(n)){const r=n.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l<h;l+=o){let c=parseInt(r.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}Bi(n)}const t=Ic();t.fillStyle="#abcdef";let e=t.fillStyle;t.fillStyle=n,t.fillStyle===e&&(t.fillStyle="#fedcba",e=t.fillStyle,t.fillStyle=n,t.fillStyle===e&&Bi(n));const i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return ga(i);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);const s=Array.from(t.getImageData(0,0,1,1).data);return s[3]=Fn(s[3]/255,3),s}function Mc(n){return typeof n=="string"?n:dr(n)}const Lc=1024,Yi={};let or=0;function Ac(n){if(n.length===4)return n;const t=n.slice();return t[3]=1,t}function ar(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function lr(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function hr(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function cr(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function _a(n){const t=hr(n[0]),e=hr(n[1]),i=hr(n[2]),s=cr(t*.222488403+e*.716873169+i*.06060791),r=500*(cr(t*.452247074+e*.399439023+i*.148375274)-s),o=200*(s-cr(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*s-16,Math.sqrt(r*r+o*o),a<0?a+360:a,n[3]]}function Fc(n){const t=(n[0]+16)/116,e=n[1],i=n[2]*Math.PI/180,s=lr(t),r=lr(t+e/500*Math.cos(i)),o=lr(t-e/200*Math.sin(i)),a=ar(r*3.021973625-s*1.617392459-o*.404875592),l=ar(r*-.943766287+s*1.916279586+o*.027607165),h=ar(r*.069407491-s*.22898585+o*1.159737864);return[rt(a+.5|0,0,255),rt(l+.5|0,0,255),rt(h+.5|0,0,255),n[3]]}function ur(n){if(n==="none")return sr;if(Yi.hasOwnProperty(n))return Yi[n];if(or>=Lc){let e=0;for(const i in Yi)(e++&3)===0&&(delete Yi[i],--or)}const t=ga(n);t.length!==4&&Bi(n);for(const e of t)isNaN(e)&&Bi(n);return Yi[n]=t,++or,t}function ui(n){return Array.isArray(n)?n:ur(n)}function dr(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.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("+t+","+e+","+i+","+s+")"}const D={CHANGE:"change",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class fr{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function Bt(){return!0}function Ye(){return!1}function Zi(){}function ma(n){let t,e,i;return function(){const s=Array.prototype.slice.call(arguments);return(!e||this!==i||!oe(s,e))&&(i=this,e=s,t=n.apply(this,arguments)),t}}function ya(n){function t(){let e;try{e=n()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}class Mt{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Bn extends fr{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),s=i[t]||(i[t]=[]);s.includes(e)||s.push(e)}dispatchEvent(t){const e=typeof t=="string",i=e?t:t.type,s=this.listeners_&&this.listeners_[i];if(!s)return;const r=e?new Mt(t):t;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 h=0,c=s.length;h<c;++h)if("handleEvent"in s[h]?l=s[h].handleEvent(r):l=s[h].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,Zi);delete o[i]}return l}disposeInternal(){this.listeners_&&li(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return this.listeners_?t?t in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const s=i.indexOf(e);s!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[s]=Zi,++this.pendingRemovals_[t]):(i.splice(s,1),i.length===0&&delete this.listeners_[t]))}}function z(n,t,e,i,s){if(s){const o=e;e=function(a){return n.removeEventListener(t,e),o.call(i??this,a)}}else i&&i!==n&&(e=e.bind(i));const r={target:n,type:t,listener:e};return n.addEventListener(t,e),r}function pa(n,t,e,i){return z(n,t,e,i,!0)}function $(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),li(n))}class gr extends Bn{constructor(t,e,i,s){super(),this.extent=t,this.pixelRatio_=i,this.resolution=e,this.state=typeof s=="function"?P.IDLE:s,this.image_=null,this.loader=typeof s=="function"?s:null}changed(){this.dispatchEvent(D.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==P.IDLE&&this.loader){this.state=P.LOADING,this.changed();const t=this.getResolution(),e=Array.isArray(t)?t[0]:t;ya(()=>this.loader(this.getExtent(),e,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||Zo&&i instanceof ImageBitmap||i instanceof HTMLCanvasElement||i instanceof HTMLVideoElement)&&(this.image_=i),this.state=P.LOADED}).catch(i=>{this.state=P.ERROR,console.error(i)}).finally(()=>this.changed())}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}}function bc(n,t){return new Promise((e,i)=>{function s(){o(),e(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)})}function xa(n,t){return t&&(n.src=t),n.src&&Yo?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(s=>n.complete&&n.width?e(n):i(s))):bc(n)}function Ea(n,t){return t&&(n.src=t),n.src&&Yo&&Zo?n.decode().then(()=>createImageBitmap(n)).catch(e=>{if(n.complete&&n.width)return n;throw e}):xa(n)}class Dc{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const s=_r(t,e,i);return s in this.cache_?this.cache_[s]:null}getPattern(t,e,i){const s=_r(t,e,i);return s in this.patternCache_?this.patternCache_[s]:null}set(t,e,i,s,r){const o=_r(t,e,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===P.IDLE&&s.load(),s.getImageState()===P.LOADING?s.ready().then(()=>{this.patternCache_[o]=On().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=On().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function _r(n,t,e){const i=e?ui(e):"null";return t+":"+n+":"+i}const zt=new Dc;let Ki=null;class Ca extends Bn{constructor(t,e,i,s,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?P.IDLE:s,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===P.LOADED){Ki||(Ki=ft(1,1,void 0,{willReadFrequently:!0})),Ki.drawImage(this.image_,0,0);try{Ki.getImageData(0,0,1,1),this.tainted_=!1}catch{Ki=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(D.CHANGE)}handleImageError_(){this.imageState_=P.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=P.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=ft(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===P.IDLE){this.image_||this.initializeImage_(),this.imageState_=P.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&xa(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==P.LOADED)return;const e=this.image_,i=ft(Math.ceil(e.width*t),Math.ceil(e.height*t)),s=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Mc(this.color_),i.fillRect(0,0,s.width/t,s.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=s}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===P.LOADED||this.imageState_===P.ERROR)t();else{const e=()=>{(this.imageState_===P.LOADED||this.imageState_===P.ERROR)&&(this.removeEventListener(D.CHANGE,e),t())};this.addEventListener(D.CHANGE,e)}})),this.ready_}}function mr(n,t,e,i,s,r){let o=t===void 0?void 0:zt.get(t,e,s);return o||(o=new Ca(n,n&&"src"in n?n.src||void 0:t,e,i,s),zt.set(t,e,s,o,r)),r&&o&&!zt.getPattern(t,e,s)&&zt.set(t,e,s,o,r),o}function Jt(n){return n?Array.isArray(n)?dr(n):typeof n=="object"&&"src"in n?Oc(n):n:null}function Oc(n){if(!n.offset||!n.size)return zt.getPattern(n.src,"anonymous",n.color);const t=n.src+":"+n.offset,e=zt.getPattern(t,void 0,n.color);if(e)return e;const i=zt.get(n.src,"anonymous",null);if(i.getImageState()!==P.LOADED)return null;const s=ft(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]),mr(s.canvas,t,void 0,P.LOADED,n.color,!0),zt.getPattern(t,void 0,n.color)}function Pe(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=t;o<e;o+=i)s[r++]=n.slice(o,o+i);return s.length=r,s}function Ui(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=Pe(n,t,l,i,s[r]),t=l}return s.length=r,s}function yr(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=l.length===1&&l[0]===t?[]:Ui(n,t,l,i,s[r]),t=l[l.length-1]}return s.length=r,s}class wa{drawCustom(t,e,i,s,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}const di={PROPERTYCHANGE:"propertychange"};class Hi extends Bn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(D.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=z(this,t[r],e);return s}return z(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const s=t.length;i=new Array(s);for(let r=0;r<s;++r)i[r]=pa(this,t[r],e)}else i=pa(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)kc(i);else if(Array.isArray(t))for(let s=0,r=t.length;s<r;++s)this.removeEventListener(t[s],e);else this.removeEventListener(t,e)}}Hi.prototype.on,Hi.prototype.once,Hi.prototype.un;function kc(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)$(n[t]);else $(n)}function O(){throw new Error("Unimplemented abstract method.")}let Nc=0;function X(n){return n.ol_uid||(n.ol_uid=String(++Nc))}class Sa extends Mt{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class Yt extends Hi{constructor(t){super(),this.on,this.once,this.un,X(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new Sa(i,t,e)),i=di.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new Sa(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const s=this.values_||(this.values_={});if(i)s[t]=e;else{const r=s[t];s[t]=e,r!==e&&this.notify(t,r)}}setProperties(t,e){for(const i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const i=this.values_[t];delete this.values_[t],Xe(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}const Yn="ol-hidden",Gc="ol-selectable",Zn="ol-unselectable",pr="ol-control",Ia="ol-collapsed",zc=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-z0-9]+?)\\s*$`].join(""),"i"),Ra=["style","variant","weight","size","lineHeight","family"],xr={normal:400,bold:700},Er=function(n){const t=n.match(zc);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,s=Ra.length;i<s;++i){const r=t[i+1];r!==void 0&&(e[Ra[i]]=typeof r=="string"?r.trim():r)}return isNaN(Number(e.weight))&&e.weight in xr&&(e.weight=xr[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e},va="10px sans-serif",Lt="#000",fi="round",ce=[],ue=0,gi="round",qi=10,$i="#000",Ji="center",Kn="middle",Ze=[0,0,0,0],Qi=1,_i=new Yt;let tn=null,Ta;const Cr={},Wc=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function jc(n,t,e){return`${n} ${t} 16px "${e}"`}const Vc=(function(){let t,e;async function i(r){await e.ready;const o=await e.load(r);if(o.length===0)return!1;const a=Er(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=xr[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function s(){await e.ready;let r=!0;const o=_i.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await i(h)?(li(Cr),_i.set(h,100)):(c+=10,_i.set(h,c,!0),c<100&&(r=!1)))}t=void 0,r||(t=setTimeout(s,100))}return async function(r){e||(e=Bs?self.fonts:document.fonts);const o=Er(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(Wc.has(h))continue;const c=jc(o.style,o.weight,h);_i.get(c)===void 0&&(_i.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(s,100))}})(),Xc=(function(){let n;return function(t){let e=Cr[t];if(e==null){if(Bs){const i=Er(t),s=Pa(t,"Žg");e=(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=t,document.body.appendChild(n),e=n.offsetHeight,document.body.removeChild(n);Cr[t]=e}return e}})();function Pa(n,t){return tn||(tn=ft(1,1)),n!=Ta&&(tn.font=n,Ta=tn.font),tn.measureText(t)}function Ma(n,t){return Pa(n,t).width}function La(n,t,e){if(t in e)return e[t];const i=t.split(`
|
|
1
|
+
(function(ht,Pt){typeof exports=="object"&&typeof module<"u"?Pt(exports,require("jspdf")):typeof define=="function"&&define.amd?define(["exports","jspdf"],Pt):(ht=typeof globalThis<"u"?globalThis:ht||self,Pt(ht.ppe={},ht.jspdf))})(this,(function(ht,Pt){"use strict";var C_=Object.defineProperty;var w_=(ht,Pt,et)=>Pt in ht?C_(ht,Pt,{enumerable:!0,configurable:!0,writable:!0,value:et}):ht[Pt]=et;var Rh=(ht,Pt,et)=>w_(ht,typeof Pt!="symbol"?Pt+"":Pt,et);const et={ANIMATING:0,INTERACTING:1};function Th(n,t,e){let i,s;e=e||Ge;let r=0,o=n.length,a=!1;for(;r<o;)i=r+(o-r>>1),s=+e(n[i],t),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function Ge(n,t){return n>t?1:n<t?-1:0}function Ph(n,t){return n<t?1:n>t?-1:0}function Fs(n,t,e){if(n[0]<=t)return 0;const i=n.length;if(t<=n[i-1])return i-1;if(typeof e=="function"){for(let s=1;s<i;++s){const r=n[s];if(r===t)return s;if(r<t)return e(t,n[s-1],r)>0?s-1:s}return i-1}if(e>0){for(let s=1;s<i;++s)if(n[s]<t)return s-1;return i-1}if(e<0){for(let s=1;s<i;++s)if(n[s]<=t)return s;return i-1}for(let s=1;s<i;++s){if(n[s]==t)return s;if(n[s]<t)return n[s-1]-t<t-n[s]?s-1:s}return i-1}function Mh(n,t,e){for(;t<e;){const i=n[t];n[t]=n[e],n[e]=i,++t,--e}}function Ot(n,t){const e=Array.isArray(t)?t:[t],i=e.length;for(let s=0;s<i;s++)n[n.length]=e[s]}function oe(n,t){const e=n.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(n[i]!==t[i])return!1;return!0}const ct={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function ut(n){const t=kt();for(let e=0,i=n.length;e<i;++e)Wi(t,n[e]);return t}function Oi(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function Go(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function ze(n,t,e){let i,s;return t<n[0]?i=n[0]-t:n[2]<t?i=t-n[2]:i=0,e<n[1]?s=n[1]-e:n[3]<e?s=e-n[3]:s=0,i*i+s*s}function ki(n,t){return bs(n,t[0],t[1])}function ae(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function bs(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function Ds(n,t){const e=n[0],i=n[1],s=n[2],r=n[3],o=t[0],a=t[1];let l=ct.UNKNOWN;return o<e?l=l|ct.LEFT:o>s&&(l=l|ct.RIGHT),a<i?l=l|ct.BELOW:a>r&&(l=l|ct.ABOVE),l===ct.UNKNOWN&&(l=ct.INTERSECTING),l}function kt(){return[1/0,1/0,-1/0,-1/0]}function We(n,t,e,i,s){return s?(s[0]=n,s[1]=t,s[2]=e,s[3]=i,s):[n,t,e,i]}function Ni(n){return We(1/0,1/0,-1/0,-1/0,n)}function Gi(n,t){const e=n[0],i=n[1];return We(e,i,e,i,t)}function Os(n,t,e,i,s){const r=Ni(s);return Wo(r,n,t,e,i)}function zi(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function zo(n,t){return t[0]<n[0]&&(n[0]=t[0]),t[2]>n[2]&&(n[2]=t[2]),t[1]<n[1]&&(n[1]=t[1]),t[3]>n[3]&&(n[3]=t[3]),n}function Wi(n,t){t[0]<n[0]&&(n[0]=t[0]),t[0]>n[2]&&(n[2]=t[0]),t[1]<n[1]&&(n[1]=t[1]),t[1]>n[3]&&(n[3]=t[1])}function Wo(n,t,e,i,s){for(;e<i;e+=s)Lh(n,t[e],t[e+1]);return n}function Lh(n,t,e){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}function jo(n,t){let e;return e=t(ks(n)),e||(e=t(Ns(n)),e)||(e=t(zs(n)),e)||(e=t(An(n)),e)?e:!1}function Ah(n){let t=0;return si(n)||(t=K(n)*dt(n)),t}function ks(n){return[n[0],n[1]]}function Ns(n){return[n[2],n[1]]}function Xt(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function Ln(n,t,e,i,s){const[r,o,a,l,h,c,u,d]=Fh(n,t,e,i);return We(Math.min(r,a,h,u),Math.min(o,l,c,d),Math.max(r,a,h,u),Math.max(o,l,c,d),s)}function Fh(n,t,e,i){const s=t*i[0]/2,r=t*i[1]/2,o=Math.cos(e),a=Math.sin(e),l=s*o,h=s*a,c=r*o,u=r*a,d=n[0],f=n[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function dt(n){return n[3]-n[1]}function Gs(n,t,e){const i=e||kt();return _t(n,t)?(n[0]>t[0]?i[0]=n[0]:i[0]=t[0],n[1]>t[1]?i[1]=n[1]:i[1]=t[1],n[2]<t[2]?i[2]=n[2]:i[2]=t[2],n[3]<t[3]?i[3]=n[3]:i[3]=t[3]):Ni(i),i}function An(n){return[n[0],n[3]]}function zs(n){return[n[2],n[3]]}function K(n){return n[2]-n[0]}function _t(n,t){return n[0]<=t[2]&&n[2]>=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function si(n){return n[2]<n[0]||n[3]<n[1]}function bh(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function Dh(n,t,e){let i=!1;const s=Ds(n,t),r=Ds(n,e);if(s===ct.INTERSECTING||r===ct.INTERSECTING)i=!0;else{const o=n[0],a=n[1],l=n[2],h=n[3],c=t[0],u=t[1],d=e[0],f=e[1],g=(f-u)/(d-c);let m,_;r&ct.ABOVE&&!(s&ct.ABOVE)&&(m=d-(f-h)/g,i=m>=o&&m<=l),!i&&r&ct.RIGHT&&!(s&ct.RIGHT)&&(_=f-(d-l)*g,i=_>=a&&_<=h),!i&&r&ct.BELOW&&!(s&ct.BELOW)&&(m=d-(f-a)/g,i=m>=o&&m<=l),!i&&r&ct.LEFT&&!(s&ct.LEFT)&&(_=f-(d-o)*g,i=_>=a&&_<=h)}return i}function Vo(n,t){const e=t.getExtent(),i=Xt(n);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){const s=K(e),o=Math.floor((i[0]-e[0])/s)*s;n[0]-=o,n[2]-=o}return n}function Oh(n,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];Vo(n,t);const s=K(i);if(K(n)>s)return[[i[0],n[1],i[2],n[3]]];if(n[0]<i[0])return[[n[0]+s,n[1],i[2],n[3]],[i[0],n[1],n[2],n[3]]];if(n[2]>i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-s,n[3]]]}return[n]}function rt(n,t,e){return Math.min(Math.max(n,t),e)}function kh(n,t,e,i,s,r){const o=s-e,a=r-i;if(o!==0||a!==0){const l=((n-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=s,i=r):l>0&&(e+=o*l,i+=a*l)}return le(n,t,e,i)}function le(n,t,e,i){const s=e-n,r=i-t;return s*s+r*r}function Nh(n){const t=n.length;for(let i=0;i<t;i++){let s=i,r=Math.abs(n[i][i]);for(let a=i+1;a<t;a++){const l=Math.abs(n[a][i]);l>r&&(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<t;a++){const l=-n[a][i]/n[i][i];for(let h=i;h<t+1;h++)i==h?n[a][h]=0:n[a][h]+=l*n[i][h]}}const e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=n[i][t]/n[i][i];for(let s=i-1;s>=0;s--)n[s][t]-=n[s][i]*e[i]}return e}function Xo(n){return n*180/Math.PI}function ve(n){return n*Math.PI/180}function ri(n,t){const e=n%t;return e*t<0?e+t:e}function bt(n,t,e){return n+e*(t-n)}function Fn(n,t){const e=Math.pow(10,t);return Math.round(n*e)/e}function bn(n,t){return Math.ceil(Fn(n,t))}function Ws(n,t,e){if(n>=t&&n<e)return n;const i=e-t;return((n-t)%i+i)%i+t}function Gh(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function zh(n,t){const e=t.getRadius(),i=t.getCenter(),s=i[0],r=i[1],o=n[0],a=n[1];let l=o-s;const h=a-r;l===0&&h===0&&(l=1);const c=Math.sqrt(l*l+h*h),u=s+e*l/c,d=r+e*h/c;return[u,d]}function js(n,t){const e=n[0],i=n[1],s=t[0],r=t[1],o=s[0],a=s[1],l=r[0],h=r[1],c=l-o,u=h-a,d=c===0&&u===0?0:(c*(e-o)+u*(i-a))/(c*c+u*u||0);let f,g;return d<=0?(f=o,g=a):d>=1?(f=l,g=h):(f=o+d*c,g=a+d*u),[f,g]}function It(n,t){let e=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Vs(n,t){const e=Math.cos(t),i=Math.sin(t),s=n[0]*e-n[1]*i,r=n[1]*e+n[0]*i;return n[0]=s,n[1]=r,n}function Wh(n,t){return n[0]*=t,n[1]*=t,n}function he(n,t){const e=n[0]-t[0],i=n[1]-t[1];return e*e+i*i}function Dn(n,t){return Math.sqrt(he(n,t))}function jh(n,t){return he(n,js(n,t))}function Bo(n,t){if(t.canWrapX()){const e=K(t.getExtent()),i=Vh(n,t,e);i&&(n[0]-=i*e)}return n}function Vh(n,t,e){const i=t.getExtent();let s=0;return t.canWrapX()&&(n[0]<i[0]||n[0]>i[2])&&(e=e||K(i),s=Math.floor((n[0]-i[0])/e)),s}const je=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"";je.includes("safari")&&!je.includes("chrom")&&(je.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(je));const Xh=je.includes("webkit")&&!je.includes("edge"),Xs=je.includes("macintosh"),Bh=typeof devicePixelRatio<"u"?devicePixelRatio:1,Bs=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Yo=typeof Image<"u"&&Image.prototype.decode,Zo=typeof createImageBitmap=="function",Ko=(function(){let n=!1;try{const t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n})();function ft(n,t,e,i){let s;return e&&e.length?s=e.shift():Bs?s=new OffscreenCanvas(n||300,t||300):s=document.createElement("canvas"),n&&(s.width=n),t&&(s.height=t),s.getContext("2d",i)}let Ys;function On(){return Ys||(Ys=ft(1,1)),Ys}function Zs(n){const t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function Yh(n){let t=n.offsetWidth;const e=getComputedStyle(n);return t+=parseInt(e.marginLeft,10)+parseInt(e.marginRight,10),t}function Zh(n){let t=n.offsetHeight;const e=getComputedStyle(n);return t+=parseInt(e.marginTop,10)+parseInt(e.marginBottom,10),t}function Uo(n,t){const e=t.parentNode;e&&e.replaceChild(n,t)}function Ho(n){for(;n.lastChild;)n.lastChild.remove()}function Kh(n,t){const e=n.childNodes;for(let i=0;;++i){const s=e[i],r=t[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)}}}function qo(...n){console.warn(...n)}const $o={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class kn{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||$o[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const ji=6378137,oi=Math.PI*ji,Uh=[-oi,-oi,oi,oi],Hh=[-180,-85,180,85],Nn=ji*Math.log(Math.tan(Math.PI/2));class ai extends kn{constructor(t){super({code:t,units:"m",extent:Uh,global:!0,worldExtent:Hh,getPointResolution:function(e,i){return e/Math.cosh(i[1]/ji)}})}}const Jo=[new ai("EPSG:3857"),new ai("EPSG:102100"),new ai("EPSG:102113"),new ai("EPSG:900913"),new ai("http://www.opengis.net/def/crs/EPSG/0/3857"),new ai("http://www.opengis.net/gml/srs/epsg.xml#3857")];function qh(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i){t[r]=oi*n[r]/180;let o=ji*Math.log(Math.tan(Math.PI*(+n[r+1]+90)/360));o>Nn?o=Nn:o<-Nn&&(o=-Nn),t[r+1]=o}return t}function $h(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i)t[r]=180*n[r]/oi,t[r+1]=360*Math.atan(Math.exp(n[r+1]/ji))/Math.PI-90;return t}const Jh=6378137,Qo=[-180,-90,180,90],Qh=Math.PI*Jh/180;class Ve extends kn{constructor(t,e){super({code:t,units:"degrees",extent:Qo,axisOrientation:e,global:!0,metersPerUnit:Qh,worldExtent:Qo})}}const ta=[new Ve("CRS:84"),new Ve("EPSG:4326","neu"),new Ve("urn:ogc:def:crs:OGC:1.3:CRS84"),new Ve("urn:ogc:def:crs:OGC:2:84"),new Ve("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Ve("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Ve("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Ks={};function tc(n){return Ks[n]||Ks[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function ec(n,t){Ks[n]=t}function li(n){for(const t in n)delete n[t]}function Xe(n){let t;for(t in n)return!1;return!t}let hi={};function Vi(n,t,e){const i=n.getCode(),s=t.getCode();i in hi||(hi[i]={}),hi[i][s]=e}function Us(n,t){return n in hi&&t in hi[n]?hi[n][t]:null}const Gn=.9996,Nt=.00669438,zn=Nt*Nt,Wn=zn*Nt,Be=Nt/(1-Nt),ea=Math.sqrt(1-Nt),ci=(1-ea)/(1+ea),ia=ci*ci,Hs=ia*ci,qs=Hs*ci,na=qs*ci,sa=1-Nt/4-3*zn/64-5*Wn/256,ic=3*Nt/8+3*zn/32+45*Wn/1024,nc=15*zn/256+45*Wn/1024,sc=35*Wn/3072,rc=3/2*ci-27/32*Hs+269/512*na,oc=21/16*ia-55/32*qs,ac=151/96*Hs-417/128*na,lc=1097/512*qs,jn=6378137;function hc(n,t,e){const i=n-5e5,o=(e.north?t:t-1e7)/Gn/(jn*sa),a=o+rc*Math.sin(2*o)+oc*Math.sin(4*o)+ac*Math.sin(6*o)+lc*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-Nt*h,m=Math.sqrt(1-Nt*h),_=jn/m,y=(1-Nt)/g,p=Be*c**2,E=p*p,x=i/(_*Gn),C=x*x,S=C*x,T=S*x,I=T*x,v=I*x,M=a-u/y*(C/2-T/24*(5+3*d+10*p-4*E-9*Be))+v/720*(61+90*d+298*p+45*f-252*Be-3*E);let k=(x-S/6*(1+2*d+p)+I/120*(5-2*p+28*d-3*E+8*Be+24*f))/c;return k=Ws(k+ve(aa(e.number)),-Math.PI,Math.PI),[Xo(k),Xo(M)]}const ra=-80,oa=84,cc=-180,uc=180;function dc(n,t,e){n=Ws(n,cc,uc),t<ra?t=ra:t>oa&&(t=oa);const i=ve(t),s=Math.sin(i),r=Math.cos(i),o=s/r,a=o*o,l=a*a,h=ve(n),c=aa(e.number),u=ve(c),d=jn/Math.sqrt(1-Nt*s**2),f=Be*r**2,g=r*Ws(h-u,-Math.PI,Math.PI),m=g*g,_=m*g,y=_*g,p=y*g,E=p*g,x=jn*(sa*i-ic*Math.sin(2*i)+nc*Math.sin(4*i)-sc*Math.sin(6*i)),C=Gn*d*(g+_/6*(1-a+f)+p/120*(5-18*a+l+72*f-58*Be))+5e5;let S=Gn*(x+d*o*(m/2+y/24*(5-a+9*f+4*f**2)+E/720*(61-58*a+l+600*f-330*Be)));return e.north||(S+=1e7),[C,S]}function aa(n){return(n-1)*6-180+3}const fc=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function la(n){let t=0;for(const s of fc){const r=n.match(s);if(r){t=parseInt(r[1]);break}}if(!t)return null;let e=0,i=!1;return t>32700&&t<32761?e=t-32700:t>32600&&t<32661&&(i=!0,e=t-32600),e?{number:e,north:i}:null}function ha(n,t){return function(e,i,s,r){const o=e.length;s=s>1?s:2,r=r??s,i||(s>2?i=e.slice():i=new Array(o));for(let a=0;a<o;a+=r){const l=e[a],h=e[a+1],c=n(l,h,t);i[a]=c[0],i[a+1]=c[1]}return i}}function gc(n){return la(n)?new kn({code:n,units:"m"}):null}function _c(n){const t=la(n.getCode());return t?{forward:ha(dc,t),inverse:ha(hc,t)}:null}const mc=63710088e-1;function ca(n,t,e){e=e||mc;const i=ve(n[1]),s=ve(t[1]),r=(s-i)/2,o=ve(t[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*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}const yc=[_c],pc=[gc];let $s=!0;function xc(n){$s=!1}function Js(n,t){if(t!==void 0){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];t=t}else t=n.slice();return t}function Qs(n){ec(n.getCode(),n),Vi(n,n,Js)}function Ec(n){n.forEach(Qs)}function ot(n){if(typeof n!="string")return n;const t=tc(n);if(t)return t;for(const e of pc){const i=e(n);if(i)return i}return null}function ua(n,t,e,i){n=ot(n);let s;const r=n.getPointResolutionFunc();if(r)s=r(t,e);else{const o=n.getUnits();if(o=="degrees"&&!i||i=="degrees")s=t;else{const a=ir(n,ot("EPSG:4326"));if(!a&&o!=="degrees")s=t*n.getMetersPerUnit();else{let h=[e[0]-t/2,e[1],e[0]+t/2,e[1],e[0],e[1]-t/2,e[0],e[1]+t/2];h=a(h,h,2);const c=ca(h.slice(0,2),h.slice(2,4)),u=ca(h.slice(4,6),h.slice(6,8));s=(c+u)/2}const l=n.getMetersPerUnit();l!==void 0&&(s/=l)}}return s}function da(n){Ec(n),n.forEach(function(t){n.forEach(function(e){t!==e&&Vi(t,e,Js)})})}function Cc(n,t,e,i){n.forEach(function(s){t.forEach(function(r){Vi(s,r,e),Vi(r,s,i)})})}function tr(n,t){return n?typeof n=="string"?ot(n):n:ot(t)}function wc(n){return(function(t,e,i,s){const r=t.length;i=i!==void 0?i:2,s=s??i,e=e!==void 0?e:new Array(r);for(let o=0;o<r;o+=s){const a=n(t.slice(o,o+i)),l=a.length;for(let h=0,c=s;h<c;++h)e[o+h]=h>=l?t[o+h]:a[h]}return e})}function er(n,t){if(n===t)return!0;const e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||ir(n,t)===Js)&&e}function ir(n,t){const e=n.getCode(),i=t.getCode();let s=Us(e,i);if(s)return s;let r=null,o=null;for(const l of yc)r||(r=l(n)),o||(o=l(t));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)s=nr(r.inverse,o.forward);else{const l=Us(e,a);l&&(s=nr(l,o.forward))}else{const l=Us(a,i);l&&(s=nr(r.inverse,l))}return s&&(Qs(n),Qs(t),Vi(n,t,s)),s}function nr(n,t){return function(e,i,s,r){return i=n(e,i,s,r),t(i,i,s,r)}}function Xi(n,t){const e=ot(n),i=ot(t);return ir(e,i)}function fa(n,t,e){const i=Xi(t,e);if(!i){const s=ot(t).getCode(),r=ot(e).getCode();throw new Error(`No transform available between ${s} and ${r}`)}return i(n,void 0,n.length)}function Re(n,t){return n}function U(n,t){return $s&&!It(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&($s=!1,qo("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function Vn(n,t){return n}function Te(n,t){return n}function Sc(){da(Jo),da(ta),Cc(ta,Jo,qh,$h)}Sc();const Gt={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"},P={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4},sr=[NaN,NaN,NaN,0];let rr;function Ic(){return rr||(rr=ft(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),rr}const vc=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Rc=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Tc=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Pc=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Xn(n,t){return n.endsWith("%")?Number(n.substring(0,n.length-1))/t:Number(n)}function Bi(n){throw new Error('failed to parse "'+n+'" as color')}function ga(n){if(n.toLowerCase().startsWith("rgb")){const r=n.match(Rc)||n.match(vc)||n.match(Tc);if(r){const o=r[4],a=100/255;return[rt(Xn(r[1],a)+.5|0,0,255),rt(Xn(r[2],a)+.5|0,0,255),rt(Xn(r[3],a)+.5|0,0,255),o!==void 0?rt(Xn(o,100),0,1):1]}Bi(n)}if(n.startsWith("#")){if(Pc.test(n)){const r=n.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l<h;l+=o){let c=parseInt(r.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}Bi(n)}const t=Ic();t.fillStyle="#abcdef";let e=t.fillStyle;t.fillStyle=n,t.fillStyle===e&&(t.fillStyle="#fedcba",e=t.fillStyle,t.fillStyle=n,t.fillStyle===e&&Bi(n));const i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return ga(i);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);const s=Array.from(t.getImageData(0,0,1,1).data);return s[3]=Fn(s[3]/255,3),s}function Mc(n){return typeof n=="string"?n:dr(n)}const Lc=1024,Yi={};let or=0;function Ac(n){if(n.length===4)return n;const t=n.slice();return t[3]=1,t}function ar(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function lr(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function hr(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function cr(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function _a(n){const t=hr(n[0]),e=hr(n[1]),i=hr(n[2]),s=cr(t*.222488403+e*.716873169+i*.06060791),r=500*(cr(t*.452247074+e*.399439023+i*.148375274)-s),o=200*(s-cr(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*s-16,Math.sqrt(r*r+o*o),a<0?a+360:a,n[3]]}function Fc(n){const t=(n[0]+16)/116,e=n[1],i=n[2]*Math.PI/180,s=lr(t),r=lr(t+e/500*Math.cos(i)),o=lr(t-e/200*Math.sin(i)),a=ar(r*3.021973625-s*1.617392459-o*.404875592),l=ar(r*-.943766287+s*1.916279586+o*.027607165),h=ar(r*.069407491-s*.22898585+o*1.159737864);return[rt(a+.5|0,0,255),rt(l+.5|0,0,255),rt(h+.5|0,0,255),n[3]]}function ur(n){if(n==="none")return sr;if(Yi.hasOwnProperty(n))return Yi[n];if(or>=Lc){let e=0;for(const i in Yi)(e++&3)===0&&(delete Yi[i],--or)}const t=ga(n);t.length!==4&&Bi(n);for(const e of t)isNaN(e)&&Bi(n);return Yi[n]=t,++or,t}function ui(n){return Array.isArray(n)?n:ur(n)}function dr(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.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("+t+","+e+","+i+","+s+")"}const D={CHANGE:"change",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class fr{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function Bt(){return!0}function Ye(){return!1}function Zi(){}function ma(n){let t,e,i;return function(){const s=Array.prototype.slice.call(arguments);return(!e||this!==i||!oe(s,e))&&(i=this,e=s,t=n.apply(this,arguments)),t}}function ya(n){function t(){let e;try{e=n()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}class Mt{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Bn extends fr{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),s=i[t]||(i[t]=[]);s.includes(e)||s.push(e)}dispatchEvent(t){const e=typeof t=="string",i=e?t:t.type,s=this.listeners_&&this.listeners_[i];if(!s)return;const r=e?new Mt(t):t;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 h=0,c=s.length;h<c;++h)if("handleEvent"in s[h]?l=s[h].handleEvent(r):l=s[h].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,Zi);delete o[i]}return l}disposeInternal(){this.listeners_&&li(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return this.listeners_?t?t in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const s=i.indexOf(e);s!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[s]=Zi,++this.pendingRemovals_[t]):(i.splice(s,1),i.length===0&&delete this.listeners_[t]))}}function z(n,t,e,i,s){if(s){const o=e;e=function(a){return n.removeEventListener(t,e),o.call(i??this,a)}}else i&&i!==n&&(e=e.bind(i));const r={target:n,type:t,listener:e};return n.addEventListener(t,e),r}function pa(n,t,e,i){return z(n,t,e,i,!0)}function $(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),li(n))}class gr extends Bn{constructor(t,e,i,s){super(),this.extent=t,this.pixelRatio_=i,this.resolution=e,this.state=typeof s=="function"?P.IDLE:s,this.image_=null,this.loader=typeof s=="function"?s:null}changed(){this.dispatchEvent(D.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==P.IDLE&&this.loader){this.state=P.LOADING,this.changed();const t=this.getResolution(),e=Array.isArray(t)?t[0]:t;ya(()=>this.loader(this.getExtent(),e,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||Zo&&i instanceof ImageBitmap||i instanceof HTMLCanvasElement||i instanceof HTMLVideoElement)&&(this.image_=i),this.state=P.LOADED}).catch(i=>{this.state=P.ERROR,console.error(i)}).finally(()=>this.changed())}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}}function bc(n,t){return new Promise((e,i)=>{function s(){o(),e(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)})}function xa(n,t){return t&&(n.src=t),n.src&&Yo?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(s=>n.complete&&n.width?e(n):i(s))):bc(n)}function Ea(n,t){return t&&(n.src=t),n.src&&Yo&&Zo?n.decode().then(()=>createImageBitmap(n)).catch(e=>{if(n.complete&&n.width)return n;throw e}):xa(n)}class Dc{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const s=_r(t,e,i);return s in this.cache_?this.cache_[s]:null}getPattern(t,e,i){const s=_r(t,e,i);return s in this.patternCache_?this.patternCache_[s]:null}set(t,e,i,s,r){const o=_r(t,e,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===P.IDLE&&s.load(),s.getImageState()===P.LOADING?s.ready().then(()=>{this.patternCache_[o]=On().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=On().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function _r(n,t,e){const i=e?ui(e):"null";return t+":"+n+":"+i}const zt=new Dc;let Ki=null;class Ca extends Bn{constructor(t,e,i,s,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?P.IDLE:s,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===P.LOADED){Ki||(Ki=ft(1,1,void 0,{willReadFrequently:!0})),Ki.drawImage(this.image_,0,0);try{Ki.getImageData(0,0,1,1),this.tainted_=!1}catch{Ki=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(D.CHANGE)}handleImageError_(){this.imageState_=P.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=P.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=ft(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===P.IDLE){this.image_||this.initializeImage_(),this.imageState_=P.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&xa(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==P.LOADED)return;const e=this.image_,i=ft(Math.ceil(e.width*t),Math.ceil(e.height*t)),s=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Mc(this.color_),i.fillRect(0,0,s.width/t,s.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=s}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===P.LOADED||this.imageState_===P.ERROR)t();else{const e=()=>{(this.imageState_===P.LOADED||this.imageState_===P.ERROR)&&(this.removeEventListener(D.CHANGE,e),t())};this.addEventListener(D.CHANGE,e)}})),this.ready_}}function mr(n,t,e,i,s,r){let o=t===void 0?void 0:zt.get(t,e,s);return o||(o=new Ca(n,n&&"src"in n?n.src||void 0:t,e,i,s),zt.set(t,e,s,o,r)),r&&o&&!zt.getPattern(t,e,s)&&zt.set(t,e,s,o,r),o}function Jt(n){return n?Array.isArray(n)?dr(n):typeof n=="object"&&"src"in n?Oc(n):n:null}function Oc(n){if(!n.offset||!n.size)return zt.getPattern(n.src,"anonymous",n.color);const t=n.src+":"+n.offset,e=zt.getPattern(t,void 0,n.color);if(e)return e;const i=zt.get(n.src,"anonymous",null);if(i.getImageState()!==P.LOADED)return null;const s=ft(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]),mr(s.canvas,t,void 0,P.LOADED,n.color,!0),zt.getPattern(t,void 0,n.color)}function Pe(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=t;o<e;o+=i)s[r++]=n.slice(o,o+i);return s.length=r,s}function Ui(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=Pe(n,t,l,i,s[r]),t=l}return s.length=r,s}function yr(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=l.length===1&&l[0]===t?[]:Ui(n,t,l,i,s[r]),t=l[l.length-1]}return s.length=r,s}class wa{drawCustom(t,e,i,s,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}const di={PROPERTYCHANGE:"propertychange"};class Hi extends Bn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(D.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=z(this,t[r],e);return s}return z(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const s=t.length;i=new Array(s);for(let r=0;r<s;++r)i[r]=pa(this,t[r],e)}else i=pa(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)kc(i);else if(Array.isArray(t))for(let s=0,r=t.length;s<r;++s)this.removeEventListener(t[s],e);else this.removeEventListener(t,e)}}Hi.prototype.on,Hi.prototype.once,Hi.prototype.un;function kc(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)$(n[t]);else $(n)}function O(){throw new Error("Unimplemented abstract method.")}let Nc=0;function X(n){return n.ol_uid||(n.ol_uid=String(++Nc))}class Sa extends Mt{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class Yt extends Hi{constructor(t){super(),this.on,this.once,this.un,X(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new Sa(i,t,e)),i=di.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new Sa(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const s=this.values_||(this.values_={});if(i)s[t]=e;else{const r=s[t];s[t]=e,r!==e&&this.notify(t,r)}}setProperties(t,e){for(const i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const i=this.values_[t];delete this.values_[t],Xe(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}const Yn="ol-hidden",Gc="ol-selectable",Zn="ol-unselectable",pr="ol-control",Ia="ol-collapsed",zc=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-z0-9]+?)\\s*$`].join(""),"i"),va=["style","variant","weight","size","lineHeight","family"],xr={normal:400,bold:700},Er=function(n){const t=n.match(zc);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,s=va.length;i<s;++i){const r=t[i+1];r!==void 0&&(e[va[i]]=typeof r=="string"?r.trim():r)}return isNaN(Number(e.weight))&&e.weight in xr&&(e.weight=xr[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e},Ra="10px sans-serif",Lt="#000",fi="round",ce=[],ue=0,gi="round",qi=10,$i="#000",Ji="center",Kn="middle",Ze=[0,0,0,0],Qi=1,_i=new Yt;let tn=null,Ta;const Cr={},Wc=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function jc(n,t,e){return`${n} ${t} 16px "${e}"`}const Vc=(function(){let t,e;async function i(r){await e.ready;const o=await e.load(r);if(o.length===0)return!1;const a=Er(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=xr[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function s(){await e.ready;let r=!0;const o=_i.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await i(h)?(li(Cr),_i.set(h,100)):(c+=10,_i.set(h,c,!0),c<100&&(r=!1)))}t=void 0,r||(t=setTimeout(s,100))}return async function(r){e||(e=Bs?self.fonts:document.fonts);const o=Er(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(Wc.has(h))continue;const c=jc(o.style,o.weight,h);_i.get(c)===void 0&&(_i.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(s,100))}})(),Xc=(function(){let n;return function(t){let e=Cr[t];if(e==null){if(Bs){const i=Er(t),s=Pa(t,"Žg");e=(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=t,document.body.appendChild(n),e=n.offsetHeight,document.body.removeChild(n);Cr[t]=e}return e}})();function Pa(n,t){return tn||(tn=ft(1,1)),n!=Ta&&(tn.font=n,Ta=tn.font),tn.measureText(t)}function Ma(n,t){return Pa(n,t).width}function La(n,t,e){if(t in e)return e[t];const i=t.split(`
|
|
2
2
|
`).reduce((s,r)=>Math.max(s,Ma(n,r)),0);return e[t]=i,i}function Bc(n,t){const e=[],i=[],s=[];let r=0,o=0,a=0,l=0;for(let h=0,c=t.length;h<=c;h+=2){const u=t[h];if(u===`
|
|
3
|
-
`||h===c){r=Math.max(r,o),s.push(o),o=0,a+=l,l=0;continue}const d=t[h+1]||n.font,f=Ma(d,u);e.push(f),o+=f;const g=Xc(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:s}}function Yc(n,t,e,i,s,r,o,a,l,h,c){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,h),n.scale(c[0],c[1]),Zc(i,n)):c[0]<0||c[1]<0?(n.translate(l,h),n.scale(c[0],c[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,h,o*c[0],a*c[1]),n.restore()}function Zc(n,t){const e=n.contextInstructions;for(let i=0,s=e.length;i<s;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}const L={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Un=[L.FILL],Me=[L.STROKE],Ke=[L.BEGIN_PATH],Aa=[L.CLOSE_PATH];class en extends wa{constructor(t,e,i,s){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=s,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){const e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){const i=this.getBufferedMaxExtent(),s=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=t.length;a<l;a+=e)s[0]=t[a],s[1]=t[a+1],ki(i,s)&&(r[o++]=s[0],r[o++]=s[1]);return o}appendFlatLineCoordinates(t,e,i,s,r,o){const a=this.coordinates;let l=a.length;const h=this.getBufferedMaxExtent();o&&(e+=s);let c=t[e],u=t[e+1];const d=this.tmpCoordinate_;let f=!0,g,m,_;for(g=e+s;g<i;g+=s)d[0]=t[g],d[1]=t[g+1],_=Ds(h,d),_!==m?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):_===ct.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],m=_;return(r&&f||g===e+s)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(t,e,i,s,r){for(let o=0,a=i.length;o<a;++o){const l=i[o],h=this.appendFlatLineCoordinates(t,e,l,s,!1,!1);r.push(h),e=l}return e}drawCustom(t,e,i,s,r){this.beginGeometry(t,e,r);const o=t.getType(),a=t.getStride(),l=this.coordinates.length;let h,c,u,d,f;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),d=[];const g=t.getEndss();f=0;for(let m=0,_=g.length;m<_;++m){const y=[];f=this.drawCustomCoordinates_(h,f,g[m],a,y),d.push(y)}this.instructions.push([L.CUSTOM,l,d,t,i,yr,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,d,t,s||i,yr,r]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,t.getEnds(),a,u),this.instructions.push([L.CUSTOM,l,u,t,i,Ui,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,u,t,s||i,Ui,r]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([L.CUSTOM,l,c,t,i,Pe,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,c,t,s||i,Pe,r]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([L.CUSTOM,l,c,t,i,Pe,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,c,t,s||i,Pe,r]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([L.CUSTOM,l,c,t,i,void 0,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,c,t,s||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[L.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[L.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;t.reverse();let e;const i=t.length;let s,r,o=-1;for(e=0;e<i;++e)s=t[e],r=s[0],r==L.END_GEOMETRY?o=e:r==L.BEGIN_GEOMETRY&&(s[2]=e,Mh(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=Jt(i||Lt)}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const i=t.getColor();e.strokeStyle=Jt(i||$i);const s=t.getLineCap();e.lineCap=s!==void 0?s:fi;const r=t.getLineDash();e.lineDash=r?r.slice():ce;const o=t.getLineDashOffset();e.lineDashOffset=o||ue;const a=t.getLineJoin();e.lineJoin=a!==void 0?a:gi;const l=t.getWidth();e.lineWidth=l!==void 0?l:Qi;const h=t.getMiterLimit();e.miterLimit=h!==void 0?h:qi,e.lineWidth>this.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0;return e}setFillStrokeStyle(t,e){const i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){const e=t.fillStyle,i=[L.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[L.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,s=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=s||r!=t.currentLineDash&&!oe(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=s,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[L.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Go(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Oi(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Kc extends en{constructor(t,e,i,s){super(t,e,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(t,e,i){if(!this.image_||this.maxExtent&&!ki(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([L.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([L.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(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=[];for(let l=0,h=s.length;l<h;l+=t.getStride())(!this.maxExtent||ki(this.maxExtent,s.slice(l,l+2)))&&r.push(s[l],s[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([L.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([L.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(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){const i=t.getAnchor(),s=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=s[1],this.opacity_=t.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=s[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}class Uc extends en{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinates_(t,e,i,s){const r=this.coordinates.length,o=this.appendFlatLineCoordinates(t,e,i,s,!1,!1),a=[L.MOVE_TO_LINE_TO,r,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),i}drawLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue],Ke);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l),this.hitDetectionInstructions.push(Me),this.endGeometry(e)}drawMultiLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue],Ke);const a=t.getEnds(),l=t.getFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinates_(l,c,a[u],h);this.hitDetectionInstructions.push(Me),this.endGeometry(e)}finish(){const t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Me),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Me),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(Ke)}}function Hn(n,t,e,i,s,r,o){const a=(e-t)/i;if(a<3){for(;t<e;t+=i)r[o++]=n[t],r[o++]=n[t+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[t,e-i];let c=0;for(;h.length>0;){const u=h.pop(),d=h.pop();let f=0;const g=n[d],m=n[d+1],_=n[u],y=n[u+1];for(let p=d+i;p<u;p+=i){const E=n[p],x=n[p+1],C=kh(E,x,g,m,_,y);C>f&&(c=p,f=C)}f>s&&(l[(c-t)/i]=1,d+i<c&&h.push(d,c),c+i<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(r[o++]=n[t+u*i],r[o++]=n[t+u*i+1]);return o}function Fa(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=Hn(n,t,c,i,s,r,o),a.push(o),t=c}return o}function Ue(n,t){return t*Math.round(n/t)}function Hc(n,t,e,i,s,r,o){if(t==e)return o;let a=Ue(n[t],s),l=Ue(n[t+1],s);t+=i,r[o++]=a,r[o++]=l;let h,c;do if(h=Ue(n[t],s),c=Ue(n[t+1],s),t+=i,t==e)return r[o++]=h,r[o++]=c,o;while(h==a&&c==l);for(;t<e;){const u=Ue(n[t],s),d=Ue(n[t+1],s);if(t+=i,u==h&&d==c)continue;const f=h-a,g=c-l,m=u-a,_=d-l;if(f*_==g*m&&(f<0&&m<f||f==m||f>0&&m>f)&&(g<0&&_<g||g==_||g>0&&_>g)){h=u,c=d;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=u,c=d}return r[o++]=h,r[o++]=c,o}function wr(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=Hc(n,t,c,i,s,r,o),a.push(o),t=c}return o}function qc(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l],u=[];o=wr(n,t,c,i,s,r,o,u),a.push(u),t=c[c.length-1]}return o}class ba extends en{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinatess_(t,e,i,s){const r=this.state,o=r.fillStyle!==void 0,a=r.strokeStyle!==void 0,l=i.length;this.instructions.push(Ke),this.hitDetectionInstructions.push(Ke);for(let h=0;h<l;++h){const c=i[h],u=this.coordinates.length,d=this.appendFlatLineCoordinates(t,e,c,s,!0,!a),f=[L.MOVE_TO_LINE_TO,u,d];this.instructions.push(f),this.hitDetectionInstructions.push(f),a&&(this.instructions.push(Aa),this.hitDetectionInstructions.push(Aa)),e=c}return o&&(this.instructions.push(Un),this.hitDetectionInstructions.push(Un)),a&&(this.instructions.push(Me),this.hitDetectionInstructions.push(Me)),e}drawCircle(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_FILL_STYLE,Lt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[L.CIRCLE,h];this.instructions.push(Ke,c),this.hitDetectionInstructions.push(Ke,c),s.fillStyle!==void 0&&(this.instructions.push(Un),this.hitDetectionInstructions.push(Un)),s.strokeStyle!==void 0&&(this.instructions.push(Me),this.hitDetectionInstructions.push(Me)),this.endGeometry(e)}drawPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_FILL_STYLE,Lt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),h=t.getStride();this.drawFlatCoordinatess_(l,0,a,h),this.endGeometry(e)}drawMultiPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_FILL_STYLE,Lt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinatess_(l,c,a[u],h);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(t!==0){const e=this.coordinates;for(let i=0,s=e.length;i<s;++i)e[i]=Ue(e[i],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}}function $c(n,t,e,i,s){const r=[];let o=e,a=0,l=t.slice(e,2);for(;a<n&&o+s<i;){const[h,c]=l.slice(-2),u=t[o+s],d=t[o+s+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=n){const g=(n-a+f)/f,m=bt(h,u,g),_=bt(c,d,g);l.push(m,_),r.push(l),l=[m,_],a==n&&(o+=s),a=0}else if(a<n)l.push(t[o+s],t[o+s+1]),o+=s;else{const g=f-a,m=bt(h,u,g/f),_=bt(c,d,g/f);l.push(m,_),r.push(l),l=[m,_],a=0,o+=s}}return a>0&&r.push(l),r}function Jc(n,t,e,i,s){let r=e,o=e,a=0,l=0,h=e,c,u,d,f,g,m,_,y,p,E;for(u=e;u<i;u+=s){const x=t[u],C=t[u+1];g!==void 0&&(p=x-g,E=C-m,f=Math.sqrt(p*p+E*E),_!==void 0&&(l+=d,c=Math.acos((_*p+y*E)/(d*f)),c>n&&(l>a&&(a=l,r=h,o=u),l=0,h=u-s)),d=f,_=p,y=E),g=x,m=C}return l+=f,l>a?[h,u]:[r,o]}const qn={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Qc extends en{constructor(t,e,i,s){super(t,e,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Lt]={fillStyle:Lt},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const 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 h=t.getType();let c=null,u=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!_t(this.maxExtent,t.getExtent()))return;let d;if(c=t.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=t.getEnds();else if(h=="Polygon")d=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){const _=t.getEndss();d=[];for(let y=0,p=_.length;y<p;++y)d.push(_[y][0])}this.beginGeometry(t,e,i);const f=o.repeat,g=f?void 0:o.textAlign;let m=0;for(let _=0,y=d.length;_<y;++_){let p;f?p=$c(f*this.resolution,c,m,d[_],u):p=[c.slice(m,d[_])];for(let E=0,x=p.length;E<x;++E){const C=p[E];let S=0,T=C.length;if(g==null){const R=Jc(o.maxAngle,C,0,C.length,2);S=R[0],T=R[1]}for(let R=S;R<T;R+=u)a.push(C[R],C[R+1]);const I=a.length;m=d[_],this.drawChars_(l,I),l=I}}this.endGeometry(e)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=t.getFlatCoordinates();break;case"LineString":c=t.getFlatMidpoint();break;case"Circle":c=t.getCenter();break;case"MultiLineString":c=t.getFlatMidpoints(),u=2;break;case"Polygon":c=t.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":const x=t.getFlatInteriorPoints();c=[];for(let C=0,S=x.length;C<S;C+=3)o.overflow||d.push(x[C+2]/this.resolution),c.push(x[C],x[C+1]);if(c.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((C,S)=>{const T=a[(x+S)*2]===c[S*u]&&a[(x+S)*2+1]===c[S*u+1];return T||--x,T})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,m=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let _=o.padding;if(_!=Ze&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],C=o.padding[1],S=o.padding[2],T=o.padding[3];o.scale[0]<0&&(C=-C,T=-T),o.scale[1]<0&&(x=-x,S=-S),_=[x,C,S,T]}const y=this.pixelRatio;this.instructions.push([L.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,_==Ze?Ze:_.map(function(x){return x*y}),g,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const p=1/y,E=g?g.slice(0):null;E&&(E[1]=Lt),this.hitDetectionInstructions.push([L.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,this.declutterMode_,this.declutterImageWithText_,_,E,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Lt:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,s=this.strokeKey_;t&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||Ji,justify:e.justify,textBaseline:e.textBaseline||Kn,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=qn[s.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([L.DRAW_CHARS,t,e,h,s.overflow,a,s.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([L.DRAW_CHARS,t,e,h,s.overflow,a&&Lt,s.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,s,r;if(!t)this.text_="";else{const o=t.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=Jt(o.getColor()||Lt)):(s=null,this.textFillState_=s);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const m=a.getLineDash(),_=a.getLineDashOffset(),y=a.getWidth(),p=a.getMiterLimit();r.lineCap=a.getLineCap()||fi,r.lineDash=m?m.slice():ce,r.lineDashOffset=_===void 0?ue:_,r.lineJoin=a.getLineJoin()||gi,r.lineWidth=y===void 0?Qi:y,r.miterLimit=p===void 0?qi:p,r.strokeStyle=Jt(a.getColor()||$i)}i=this.textState_;const l=t.getFont()||va;Vc(l);const h=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||Kn,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||Ze,i.scale=h===void 0?[1,1]:h;const c=t.getOffsetX(),u=t.getOffsetY(),d=t.getRotateWithView(),f=t.getKeepUpright(),g=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:X(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:"|"+X(s.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const tu={Circle:ba,Default:en,Image:Kc,LineString:Uc,Polygon:ba,Text:Qc};class eu{constructor(t,e,i,s){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const s in i){const r=i[s].finish();t[e][s]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[e];if(r===void 0){const o=tu[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[e]=r}return r}}function Le(n,t,e,i,s,r,o){r=r||[],o=o||2;let a=0;for(let l=t;l<e;l+=i){const h=n[l],c=n[l+1];r[a++]=s[0]*h+s[2]*c+s[4],r[a++]=s[1]*h+s[3]*c+s[5];for(let u=2;u<o;u++)r[a++]=n[l+u]}return r&&r.length!=a&&(r.length=a),r}function Sr(n,t,e,i,s,r,o){o=o||[];const a=Math.cos(s),l=Math.sin(s),h=r[0],c=r[1];let u=0;for(let d=t;d<e;d+=i){const f=n[d]-h,g=n[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let m=d+2;m<d+i;++m)o[u++]=n[m]}return o&&o.length!=u&&(o.length=u),o}function iu(n,t,e,i,s,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let u=t;u<e;u+=i){const d=n[u]-l,f=n[u+1]-h;a[c++]=l+s*d,a[c++]=h+r*f;for(let g=u+2;g<u+i;++g)a[c++]=n[g]}return a&&a.length!=c&&(a.length=c),a}function nu(n,t,e,i,s,r,o){o=o||[];let a=0;for(let l=t;l<e;l+=i){o[a++]=n[l]+s,o[a++]=n[l+1]+r;for(let h=l+2;h<l+i;++h)o[a++]=n[h]}return o&&o.length!=a&&(o.length=a),o}function it(n,t){if(!n)throw new Error(t)}new Array(6);function Zt(){return[1,0,0,1,0,0]}function su(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n}function mt(n,t){const e=t[0],i=t[1];return t[0]=n[0]*e+n[2]*i+n[4],t[1]=n[1]*e+n[3]*i+n[5],t}function de(n,t,e,i,s,r,o,a){const l=Math.sin(r),h=Math.cos(r);return n[0]=i*h,n[1]=s*l,n[2]=-i*l,n[3]=s*h,n[4]=o*i*h-a*i*l+t,n[5]=o*s*l+a*s*h+e,n}function Da(n,t){const e=ru(t);it(e!==0,"Transformation matrix cannot be inverted");const i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],l=t[5];return n[0]=o/e,n[1]=-s/e,n[2]=-r/e,n[3]=i/e,n[4]=(r*l-o*a)/e,n[5]=-(i*l-s*a)/e,n}function ru(n){return n[0]*n[3]-n[1]*n[2]}const ou=[1e5,1e5,1e5,1e5,2,2];function au(n){return"matrix("+n.join(", ")+")"}function Oa(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function lu(n,t){const e=Oa(n),i=Oa(t);for(let s=0;s<6;++s)if(Math.round((e[s]-i[s])*ou[s])!==0)return!1;return!0}function Ir(n,t,e,i){let s=n[t],r=n[t+1],o=0;for(let a=t+i;a<e;a+=i){const l=n[a],h=n[a+1];o+=Math.sqrt((l-s)*(l-s)+(h-r)*(h-r)),s=l,r=h}return o}function hu(n,t,e,i,s,r,o,a,l,h,c,u,d=!0){let f=n[t],g=n[t+1],m=0,_=0,y=0,p=0;function E(){m=f,_=g,t+=i,f=n[t],g=n[t+1],p+=y,y=Math.sqrt((f-m)*(f-m)+(g-_)*(g-_))}do E();while(t<e-i&&p+y<r);let x=y===0?0:(r-p)/y;const C=bt(m,f,x),S=bt(_,g,x),T=t-i,I=p,R=r+a*l(h,s,c);for(;t<e-i&&p+y<R;)E();x=y===0?0:(R-p)/y;const M=bt(m,f,x),k=bt(_,g,x);let N=!1;if(d)if(u){const W=[C,S,M,k];Sr(W,0,4,2,u,W,W),N=W[0]>W[2]}else N=C>M;const j=Math.PI,F=[],q=T+i===t;t=T,y=0,p=I,f=n[t],g=n[t+1];let b;if(q){E(),b=Math.atan2(g-_,f-m),N&&(b+=b>0?-j:j);const W=(M+C)/2,V=(k+S)/2;return F[0]=[W,V,(R-r)/2,b,s],F}s=s.replace(/\n/g," ");for(let W=0,V=s.length;W<V;){E();let Q=Math.atan2(g-_,f-m);if(N&&(Q+=Q>0?-j:j),b!==void 0){let St=Q-b;if(St+=St>j?-2*j:St<-j?2*j:0,Math.abs(St)>o)return null}b=Q;const J=W;let tt=0;for(;W<V;++W){const St=N?V-W-1:W,ne=a*l(h,s[St],c);if(t+i<e&&p+y<r+tt+ne/2)break;tt+=ne}if(W===J)continue;const v=N?s.substring(V-J,V-W):s.substring(J,W);x=y===0?0:(r+tt/2-p)/y;const Ce=bt(m,f,x),ii=bt(_,g,x);F.push([Ce,ii,tt/2,Q,v]),r+=tt}return F}class ka{constructor(){vh(this,"pushMethodArgs_",(...t)=>(this.push_(t),this));this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(On(),{get:(t,e)=>{if(typeof On()[e]=="function")return this.push_(e),this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){const e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,s=e.length;i<s;++i){const r=e[i];if(typeof r=="function"){r(t);continue}const o=e[++i];if(typeof t[r]=="function")t[r](...o);else{if(typeof o=="function"){t[r]=o(t);continue}t[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const mi=kt(),Ae=[],fe=[],ge=[],Fe=[];function Na(n){return n[3].declutterBox}const Ga=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function Rr(n,t){return t==="start"?t=Ga.test(n)?"right":"left":t==="end"&&(t=Ga.test(n)?"left":"right"),qn[t]}function cu(n,t,e){return e>0&&n.push(`
|
|
4
|
-
`,""),n.push(t,""),n}function uu(n,t,e){return e%2===0&&(n+=t),n}class du{constructor(t,e,i,s,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=Zt(),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 ka:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,s){const r=t+e+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[e],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?qn[l.justify]:
|
|
5
|
-
`).reduce(cu,[]),{width:g,height:m,widths:_,heights:y,lineWidths:p}=Bc(l,f),E=g+d,x=[],C=(E+2)*c[0],S=(m+d)*c[1],T={width:C<0?Math.floor(C):Math.ceil(C),height:S<0?Math.floor(S):Math.ceil(S),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),s&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",d),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),i&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const I=.5-u;let
|
|
6
|
-
`){j+=N,N=0,R=u*E+I*d,++q;continue}const J=f[W+1]||l.font;J!==b&&(s&&M.push("font",J),i&&k.push("font",J),b=J),N=Math.max(N,y[F]);const tt=[Q,R+I*_[F]+u*(_[F]-p[q]),.5*(d+N)+j];R+=_[F],s&&M.push("strokeText",tt),i&&k.push("fillText",tt),++F}return Array.prototype.push.apply(x,M),Array.prototype.push.apply(x,k),this.labels_[r]=T,T}replayTextBackground_(t,e,i,s,r,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,s),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,s,r,o,a,l,h,c,u,d,f,g,m,_){a*=d[0],l*=d[1];let y=i-a,p=s-l;const E=r+h>t?t-h:r,x=o+c>e?e-c:o,C=g[3]+E*d[0]+g[1],S=g[0]+x*d[1]+g[2],T=y-g[3],I=p-g[0];(m||u!==0)&&(Ae[0]=T,Fe[0]=T,Ae[1]=I,fe[1]=I,fe[0]=T+C,ge[0]=fe[0],ge[1]=I+S,Fe[1]=ge[1]);let R;return u!==0?(R=de(Zt(),i,s,1,1,u,-i,-s),mt(R,Ae),mt(R,fe),mt(R,ge),mt(R,Fe),We(Math.min(Ae[0],fe[0],ge[0],Fe[0]),Math.min(Ae[1],fe[1],ge[1],Fe[1]),Math.max(Ae[0],fe[0],ge[0],Fe[0]),Math.max(Ae[1],fe[1],ge[1],Fe[1]),mi)):We(Math.min(T,T+C),Math.min(I,I+S),Math.max(T,T+C),Math.max(I,I+S),mi),f&&(y=Math.round(y),p=Math.round(p)),{drawImageX:y,drawImageY:p,drawImageW:E,drawImageH:x,originX:h,originY:c,declutterBox:{minX:mi[0],minY:mi[1],maxX:mi[2],maxY:mi[3],value:_},canvasTransform:R,scale:d}}replayImageOrLabel_(t,e,i,s,r,o,a){const l=!!(o||a),h=s.declutterBox,c=a?a[2]*s.scale[0]/2:0;return h.minX-c<=e[0]&&h.maxX+c>=0&&h.minY-c<=e[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(t,Ae,fe,ge,Fe,o,a),Yc(t,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=mt(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;t.save(),t.translate(i[0]%s,i[1]%s),e!==1&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,s){const r=this.textStates[e],o=this.createLabel(t,e,s,i),a=this.strokeStates[i],l=this.pixelRatio,h=Rr(Array.isArray(t)?t[0]:t,r.textAlign||Ji),c=qn[r.textBaseline||Kn],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,s,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&oe(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Le(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),su(this.renderedTransform_,i));let u=0;const d=s.length;let f=0,g,m,_,y,p,E,x,C,S,T,I,R,M,k=0,N=0;const j=this.coordinateCache_,F=this.viewRotation_,q=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,b={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:F},W=this.instructions!=s||this.overlaps?0:200;let V,Q,J,tt;for(;u<d;){const v=s[u];switch(v[0]){case L.BEGIN_GEOMETRY:V=v[1],tt=v[3],V.getGeometry()?a!==void 0&&!_t(a,tt.getExtent())?u=v[2]+1:++u:u=v[2],h&&(h.zIndex=v[4]);break;case L.BEGIN_PATH:k>W&&(this.fill_(t),k=0),N>W&&(t.stroke(),N=0),!k&&!N&&(t.beginPath(),p=NaN,E=NaN),++u;break;case L.CIRCLE:f=v[1];const ii=c[f],St=c[f+1],ne=c[f+2],$t=c[f+3],Ne=ne-ii,In=$t-St,se=Math.sqrt(Ne*Ne+In*In);t.moveTo(ii+se,St),t.arc(ii,St,se,0,2*Math.PI,!0),++u;break;case L.CLOSE_PATH:t.closePath(),++u;break;case L.CUSTOM:f=v[1],g=v[2];const c_=v[3],u_=v[4],yh=v[5];b.geometry=c_,b.feature=V,u in j||(j[u]=[]);const Rn=j[u];yh?yh(c,f,g,2,Rn):(Rn[0]=c[f],Rn[1]=c[f+1],Rn.length=2),h&&(h.zIndex=v[6]),u_(Rn,b),++u;break;case L.DRAW_IMAGE:f=v[1],g=v[2],S=v[3],m=v[4],_=v[5];let Ao=v[6];const d_=v[7],f_=v[8],g_=v[9],ph=v[10];let Fo=v[11];const __=v[12];let Ms=v[13];y=v[14]||"declutter";const vn=v[15];if(!S&&v.length>=20){T=v[19],I=v[20],R=v[21],M=v[22];const Wt=this.drawLabelWithPointPlacement_(T,I,R,M);S=Wt.label,v[3]=S;const ni=v[23];m=(Wt.anchorX-ni)*this.pixelRatio,v[4]=m;const jt=v[24];_=(Wt.anchorY-jt)*this.pixelRatio,v[5]=_,Ao=S.height,v[6]=Ao,Ms=S.width,v[13]=Ms}let bo;v.length>25&&(bo=v[25]);let Do,Ls,As;v.length>17?(Do=v[16],Ls=v[17],As=v[18]):(Do=Ze,Ls=null,As=null),ph&&q?Fo+=F:!ph&&!q&&(Fo-=F);let m_=0;for(;f<g;f+=2){if(bo&&bo[m_++]<Ms/this.pixelRatio)continue;const Wt=this.calculateImageOrLabelDimensions_(S.width,S.height,c[f],c[f+1],Ms,Ao,m,_,f_,g_,Fo,__,r,Do,!!Ls||!!As,V),ni=[t,e,S,Wt,d_,Ls,As];if(l){let jt,re,Vt;if(vn){const st=g-f;if(!vn[st]){vn[st]={args:ni,declutterMode:y};continue}const Tt=vn[st];jt=Tt.args,re=Tt.declutterMode,delete vn[st],Vt=Na(jt)}let we,Se;if(jt&&(re!=="declutter"||!l.collides(Vt))&&(we=!0),(y!=="declutter"||!l.collides(Wt.declutterBox))&&(Se=!0),re==="declutter"&&y==="declutter"){const st=we&&Se;we=st,Se=st}we&&(re!=="none"&&l.insert(Vt),this.replayImageOrLabel_.apply(this,jt)),Se&&(y!=="none"&&l.insert(Wt.declutterBox),this.replayImageOrLabel_.apply(this,ni))}else this.replayImageOrLabel_.apply(this,ni)}++u;break;case L.DRAW_CHARS:const xh=v[1],Eh=v[2],Oo=v[3],y_=v[4];M=v[5];const p_=v[6],Ch=v[7],wh=v[8];R=v[9];const ko=v[10];T=v[11],Array.isArray(T)&&(T=T.reduce(uu,"")),I=v[12];const Sh=[v[13],v[13]];y=v[14]||"declutter";const x_=v[15],No=this.textStates[I],Tn=No.font,Pn=[No.scale[0]*Ch,No.scale[1]*Ch];let Mn;Tn in this.widths_?Mn=this.widths_[Tn]:(Mn={},this.widths_[Tn]=Mn);const Ih=Ir(c,xh,Eh,2),Rh=Math.abs(Pn[0])*La(Tn,T,Mn);if(y_||Rh<=Ih){const Wt=this.textStates[I].textAlign,ni=(Ih-Rh)*Rr(T,Wt),jt=hu(c,xh,Eh,2,T,ni,p_,Math.abs(Pn[0]),La,Tn,Mn,q?0:this.viewRotation_,x_);t:if(jt){const re=[];let Vt,we,Se,st,Tt;if(R)for(Vt=0,we=jt.length;Vt<we;++Vt){Tt=jt[Vt],Se=Tt[4],st=this.createLabel(Se,I,"",R),m=Tt[2]+(Pn[0]<0?-ko:ko),_=Oo*st.height+(.5-Oo)*2*ko*Pn[1]/Pn[0]-wh;const Ie=this.calculateImageOrLabelDimensions_(st.width,st.height,Tt[0],Tt[1],st.width,st.height,m,_,0,0,Tt[3],Sh,!1,Ze,!1,V);if(l&&y==="declutter"&&l.collides(Ie.declutterBox))break t;re.push([t,e,st,Ie,1,null,null])}if(M)for(Vt=0,we=jt.length;Vt<we;++Vt){Tt=jt[Vt],Se=Tt[4],st=this.createLabel(Se,I,M,""),m=Tt[2],_=Oo*st.height-wh;const Ie=this.calculateImageOrLabelDimensions_(st.width,st.height,Tt[0],Tt[1],st.width,st.height,m,_,0,0,Tt[3],Sh,!1,Ze,!1,V);if(l&&y==="declutter"&&l.collides(Ie.declutterBox))break t;re.push([t,e,st,Ie,1,null,null])}l&&y!=="none"&&l.load(re.map(Na));for(let Ie=0,E_=re.length;Ie<E_;++Ie)this.replayImageOrLabel_.apply(this,re[Ie])}}++u;break;case L.END_GEOMETRY:if(o!==void 0){V=v[1];const Wt=o(V,tt,y);if(Wt)return Wt}++u;break;case L.FILL:W?k++:this.fill_(t),++u;break;case L.MOVE_TO_LINE_TO:for(f=v[1],g=v[2],Q=c[f],J=c[f+1],t.moveTo(Q,J),p=Q+.5|0,E=J+.5|0,f+=2;f<g;f+=2)Q=c[f],J=c[f+1],x=Q+.5|0,C=J+.5|0,(f==g-2||x!==p||C!==E)&&(t.lineTo(Q,J),p=x,E=C);++u;break;case L.SET_FILL_STYLE:this.alignAndScaleFill_=v[2],k&&(this.fill_(t),k=0,N&&(t.stroke(),N=0)),t.fillStyle=v[1],++u;break;case L.SET_STROKE_STYLE:N&&(t.stroke(),N=0),this.setStrokeStyle_(t,v),++u;break;case L.STROKE:W?N++:t.stroke(),++u;break;default:++u;break}}k&&this.fill_(t),N&&t.stroke()}execute(t,e,i,s,r,o){this.viewRotation_=s,this.execute_(t,e,i,this.instructions,r,void 0,void 0,o)}executeHitDetection(t,e,i,s,r){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,s,r)}}const He=["Polygon","Circle","LineString","Image","Text","Default"],za=["Image","Text"],fu=He.filter(n=>!za.includes(n));class gu{constructor(t,e,i,s,r,o,a){this.maxExtent_=t,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Zt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(const i in t){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=t[i];for(const o in r){const a=r[o];s[o]=new du(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let s=0,r=t.length;s<r;++s)if(t[s]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,s,r,o){s=Math.round(s);const a=s*2+1,l=de(this.hitDetectionTransform_,s+.5,s+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=ft(a,a));const c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=kt(),Wi(u,t),Oi(u,e*(this.renderBuffer_+s),u));const d=_u(s);let f;function g(C,S,T){const I=c.getImageData(0,0,a,a).data;for(let R=0,M=d.length;R<M;R++)if(I[d[R]]>0){if(!o||T==="none"||f!=="Image"&&f!=="Text"||o.includes(C)){const k=(d[R]-3)/4,N=s-k%a,j=s-(k/a|0),F=r(C,S,N*N+j*j);if(F)return F}c.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(Ge);let _,y,p,E,x;for(_=m.length-1;_>=0;--_){const C=m[_].toString();for(p=this.executorsByZIndex_[C],y=He.length-1;y>=0;--y)if(f=He[y],E=p[f],E!==void 0&&(x=E.executeHitDetection(c,l,i,g,u),x))return x}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],s=e[1],r=e[2],o=e[3],a=[i,s,i,o,r,o,r,s];return Le(a,0,8,2,t,a),a}isEmpty(){return Xe(this.executorsByZIndex_)}execute(t,e,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?Ph:Ge),o=o||He;const h=He.length;for(let c=0,u=l.length;c<u;++c){const d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,m=o.length;g<m;++g){const _=o[g],y=f[_];if(y!==void 0){const p=a===null?void 0:y.getZIndexContext(),E=p?p.getContext():t,x=this.maxExtent_&&_!=="Image"&&_!=="Text";if(x&&(E.save(),this.clip(E,i)),!p||_==="Text"||_==="Image"?y.execute(E,e,i,s,r,a):p.pushFunction(C=>y.execute(C,e,i,s,r,a)),x&&E.restore(),p){p.offset();const C=l[c]*h+He.indexOf(_);this.deferredZIndexContexts_[C]||(this.deferredZIndexContexts_[C]=[]),this.deferredZIndexContexts_[C].push(p)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(Ge);for(let i=0,s=e.length;i<s;++i)t[e[i]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const vr={};function _u(n){if(vr[n]!==void 0)return vr[n];const t=n*2+1,e=n*n,i=new Array(e+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*t+(n+o))*4+3),r>0&&l.push(((n-r)*t+(n+o))*4+3),o>0&&(l.push(((n+r)*t+(n-o))*4+3),r>0&&l.push(((n-r)*t+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;r<o;++r)i[r]&&s.push(...i[r]);return vr[n]=s,s}function Wa(n){return n[0]>0&&n[1]>0}function yi(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}class $n{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=yi(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new $n({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return O()}getImage(t){return O()}getHitDetectionImage(){return O()}getPixelRatio(t){return 1}getImageState(){return O()}getImageSize(){return O()}getOrigin(){return O()}getSize(){return O()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=yi(t)}listenImageChange(t){O()}load(){O()}unlistenImageChange(t){O()}ready(){return Promise.resolve()}}class Jn extends $n{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?P.LOADING:P.LOADED,this.imageState_===P.LOADING&&this.ready().then(()=>this.imageState_=P.LOADED),this.render()}clone(){const t=this.getScale(),e=new Jn({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){var r,o;const e=(r=this.fill_)==null?void 0:r.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let s=(o=zt.get(i,null,null))==null?void 0:o.getImage(1);if(!s){const a=this.renderOptions_,l=Math.ceil(a.size*t),h=ft(l,l);this.draw_(a,h,t),s=h.canvas,zt.set(i,null,null,new Ca(s,void 0,null,P.LOADED,null))}return s}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let s=this.radius,r=this.radius2_===void 0?s:this.radius2_;if(s<r){const S=s;s=r,r=S}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=s-h,u=Math.sqrt(l*l+c*c),d=u/l;if(t==="miter"&&d<=i)return d*e;const f=e/2/d,g=e/2*(c/u),_=Math.sqrt((s+f)*(s+f)+g*g)-s;if(this.radius2_===void 0||t==="bevel")return _*2;const y=s*Math.sin(a),p=Math.sqrt(s*s-y*y),E=r-p,C=Math.sqrt(y*y+E*E)/y;if(C<=i){const S=C*e/2-r-s;return 2*Math.max(_,S)}return _*2}createRenderOptions(){let t=fi,e=gi,i=0,s=null,r=0,o,a=0;this.stroke_&&(o=Jt(this.stroke_.getColor()??$i),a=this.stroke_.getWidth()??Qi,s=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??gi,t=this.stroke_.getLineCap()??fi,i=this.stroke_.getMiterLimit()??qi);const l=this.calculateLineJoinSize_(e,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:t,lineDash:s,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let s=this.fill_.getColor();s===null&&(s=Lt),e.fillStyle=Jt(s),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),s=0;typeof i=="string"&&(i=ui(i)),i===null?s=1:Array.isArray(i)&&(s=i.length===4?i[3]:1),s===0&&(e=ft(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{const s=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let a=0;a<e;a++){const l=r+a*o,h=a%2===0?i:s;t.lineTo(h*Math.cos(l),h*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Lt,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class nn extends Jn{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new nn({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}setRadius(t){this.radius=t,this.render()}}class yt{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){const t=this.getColor();return new yt({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){const e=mr(null,t.src,"anonymous",void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===P.IDLE&&e.load(),e.getImageState()===P.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?X(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:ui(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function ja(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}class Qn extends $n{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,s=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:s,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;const o=t.img!==void 0?t.img:null;let a=t.src;it(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||X(o)),it(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),it(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=P.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?P.LOADED:P.IDLE:l=P.LOADING:l=P.LOADED),this.color_=t.color!==void 0?ui(t.color):null,this.iconImage_=mr(o,a,this.crossOrigin_,l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let h,c;if(t.size)[h,c]=t.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(ja(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(ja(h,c,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new Qn({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=s[0]),this.anchorYUnits_=="fraction"&&(t[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+s[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==P.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){const t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==P.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(D.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(D.CHANGE,t)}ready(){return this.iconImage_.ready()}}class Qt{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){const t=this.getColor();return new Qt({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}}class at{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Xa,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new at({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=Xa,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function mu(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(it(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}let Tr=null;function Va(n,t){if(!Tr){const e=new yt({color:"rgba(255,255,255,0.4)"}),i=new Qt({color:"#3399CC",width:1.25});Tr=[new at({image:new nn({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return Tr}function Pr(){const n={},t=[255,255,255,1],e=[0,153,255,1],i=3;return n.Polygon=[new at({fill:new yt({color:[255,255,255,.5]})})],n.MultiPolygon=n.Polygon,n.LineString=[new at({stroke:new Qt({color:t,width:i+2})}),new at({stroke:new Qt({color:e,width:i})})],n.MultiLineString=n.LineString,n.Circle=n.Polygon.concat(n.LineString),n.Point=[new at({image:new nn({radius:i*2,fill:new yt({color:e}),stroke:new Qt({color:t,width:i/2})}),zIndex:1/0})],n.MultiPoint=n.Point,n.GeometryCollection=n.Polygon.concat(n.LineString,n.Point),n}function Xa(n){return n.getGeometry()}const yu="#333";class qe{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=yi(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new yt({color:yu}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new qe({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=yi(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}const Ba=Zt(),pu=[NaN,NaN];class Ya extends Yt{constructor(){super(),this.extent_=kt(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=ma((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return O()}closestPointXY(t,e,i,s){return O()}containsXY(t,e){return this.closestPointXY(t,e,pu,Number.MIN_VALUE)===0}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return O()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Ni(e),this.extentRevision_=this.getRevision()}return bh(this.extent_,t)}rotate(t,e){O()}scale(t,e,i){O()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return O()}getType(){return O()}applyTransform(t){O()}intersectsExtent(t){return O()}translate(t,e){O()}transform(t,e){const i=ot(t),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=dt(h)/dt(l);de(Ba,h[0],h[3],c,-c,0,0,0);const u=Le(r,0,r.length,a,Ba,o),d=Xi(i,e);return d?d(u,u,a):u}:Xi(i,e);return this.applyTransform(s),this}}class be extends Ya{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Os(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return O()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=ts(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){O()}setLayout(t,e,i){let s;if(t)s=ts(t);else{for(let r=0;r<i;++r){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}s=e.length,t=$e(s)}this.layout=t,this.stride=s}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();Sr(i,0,i.length,s,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=Xt(this.getExtent()));const s=this.getFlatCoordinates();if(s){const r=this.getStride();iu(s,0,s.length,r,t,e,i,s),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();nu(i,0,i.length,s,t,e,i),this.changed()}}}function $e(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function ts(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function xu(n,t,e){const i=n.getFlatCoordinates();if(!i)return null;const s=n.getStride();return Le(i,0,i.length,s,t,e)}class Eu extends wa{constructor(t,e,i,s,r,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=s,this.transformRotation_=s?Fn(Math.atan2(s[1],s[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=Zt()}drawImages_(t,e,i,s){if(!this.image_)return;const r=Le(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=r.length;c<u;c+=2){const d=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,m=f+this.imageAnchorY_;de(a,g,m,1,1,h,-g,-m),o.save(),o.transform.apply(o,a),o.translate(g,m),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(t,e,i,s){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Le(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=s){const l=r[e]+this.textOffsetX_,h=r[e+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(t,e,i,s,r){const o=this.context_,a=Le(t,e,i,s,this.transform_,this.pixelCoordinates_);o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let h=2;h<l;h+=2)o.lineTo(a[h],a[h+1]);return r&&o.closePath(),i}drawRings_(t,e,i,s){for(let r=0,o=i.length;r<o;++r)e=this.moveToLineTo_(t,e,i[r],s,!0);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!_t(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=xu(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],s=e[3]-e[1],r=Math.sqrt(i*i+s*s),o=this.context_;o.beginPath(),o.arc(e[0],e[1],r,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break}}drawFeature(t,e){const i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let i=0,s=e.length;i<s;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!_t(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1),e.stroke()}if(this.text_!==""){const e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getExtent();if(_t(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const i=this.context_,s=t.getFlatCoordinates();let r=0;const o=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)r=this.moveToLineTo_(s,r,o[l],a,!1);i.stroke()}if(this.text_!==""){const i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!_t(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride()),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!_t(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getOrientedFlatCoordinates();let s=0;const r=t.getEndss(),o=t.getStride();e.beginPath();for(let a=0,l=r.length;a<l;++a){const h=r[a];s=this.drawRings_(i,s,h,o)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){const e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),oe(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){const e=this.context_,i=this.contextTextState_,s=t.textAlign?t.textAlign:Ji;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=s&&(i.textAlign=s,e.textAlign=s),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=s,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:s,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{const i=t.getColor();this.fillState_={fillStyle:Jt(i||Lt)}}if(!e)this.strokeState_=null;else{const i=e.getColor(),s=e.getLineCap(),r=e.getLineDash(),o=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),h=e.getMiterLimit(),c=r||ce;this.strokeState_={lineCap:s!==void 0?s:fi,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||ue)*this.pixelRatio_,lineJoin:a!==void 0?a:gi,lineWidth:(l!==void 0?l:Qi)*this.pixelRatio_,miterLimit:h!==void 0?h:qi,strokeStyle:Jt(i||$i)}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),s=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{const e=t.getFill();if(!e)this.textFillState_=null;else{const f=e.getColor();this.textFillState_={fillStyle:Jt(f||Lt)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),m=i.getLineDash(),_=i.getLineDashOffset(),y=i.getLineJoin(),p=i.getWidth(),E=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:fi,lineDash:m||ce,lineDashOffset:_||ue,lineJoin:y!==void 0?y:gi,lineWidth:p!==void 0?p:Qi,miterLimit:E!==void 0?E:qi,strokeStyle:Jt(f||$i)}}const s=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:s!==void 0?s:va,textAlign:u!==void 0?u:Ji,textBaseline:d!==void 0?d:Kn},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,m)=>f+=m%2?" ":g,""):c:"",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_*h[0],this.pixelRatio_*h[1]]}}}const te=.5;function Cu(n,t,e,i,s,r,o,a,l){const h=s,c=n[0]*te,u=n[1]*te,d=ft(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new Eu(d,te,s,null,o,a,null),m=e.length,_=Math.floor((256*256*256-1)/m),y={};for(let E=1;E<=m;++E){const x=e[E-1],C=x.getStyleFunction()||i;if(!C)continue;let S=C(x,r);if(!S)continue;Array.isArray(S)||(S=[S]);const I=(E*_).toString(16).padStart(7,"#00000");for(let R=0,M=S.length;R<M;++R){const k=S[R],N=k.getGeometryFunction()(x);if(!N||!_t(h,N.getExtent()))continue;const j=k.clone(),F=j.getFill();F&&F.setColor(I);const q=j.getStroke();q&&(q.setColor(I),q.setLineDash(null)),j.setText(void 0);const b=k.getImage();if(b){const J=b.getImageSize();if(!J)continue;const tt=ft(J[0],J[1],void 0,{alpha:!1}),v=tt.canvas;tt.fillStyle=I,tt.fillRect(0,0,v.width,v.height),j.setImage(new Qn({img:v,anchor:b.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:b.getOrigin(),opacity:1,size:b.getSize(),scale:b.getScale(),rotation:b.getRotation(),rotateWithView:b.getRotateWithView()}))}const W=j.getZIndex()||0;let V=y[W];V||(V={},y[W]=V,V.Polygon=[],V.Circle=[],V.LineString=[],V.Point=[]);const Q=N.getType();if(Q==="GeometryCollection"){const J=N.getGeometriesArrayRecursive();for(let tt=0,v=J.length;tt<v;++tt){const Ce=J[tt];V[Ce.getType().replace("Multi","")].push(Ce,j)}}else V[Q.replace("Multi","")].push(N,j)}}const p=Object.keys(y).map(Number).sort(Ge);for(let E=0,x=p.length;E<x;++E){const C=y[p[E]];for(const S in C){const T=C[S];for(let I=0,R=T.length;I<R;I+=2){g.setStyle(T[I+1]);for(let M=0,k=t.length;M<k;++M)g.setTransform(t[M]),g.drawGeometry(T[I])}}}return d.getImageData(0,0,f.width,f.height)}function wu(n,t,e){const i=[];if(e){const s=Math.floor(Math.round(n[0])*te),r=Math.floor(Math.round(n[1])*te),o=(rt(s,0,e.width-1)+rt(r,0,e.height-1)*e.width)*4,a=e.data[o],l=e.data[o+1],c=e.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/t.length);c&&c%u===0&&i.push(t[c/u-1])}return i}const Su=.5,Za={Point:Au,LineString:Pu,Polygon:bu,MultiPoint:Fu,MultiLineString:Mu,MultiPolygon:Lu,GeometryCollection:Tu,Circle:Ru};function Iu(n,t){return parseInt(X(n),10)-parseInt(X(t),10)}function Ka(n,t){const e=Ua(n,t);return e*e}function Ua(n,t){return Su*n/t}function Ru(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i)}}function Ha(n,t,e,i,s,r,o,a){const l=[],h=e.getImage();if(h){let d=!0;const f=h.getImageState();f==P.LOADED||f==P.ERROR?d=!1:f==P.IDLE&&h.load(),d&&l.push(h.ready())}const c=e.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>s(null)),vu(n,t,e,i,r,o,a),u}function vu(n,t,e,i,s,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,s);if(e.getRenderer())qa(n,l,e,t,o);else{const c=Za[l.getType()];c(n,l,e,t,o,r)}}function qa(n,t,e,i,s){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)qa(n,o[a],e,i,s);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),s)}function Tu(n,t,e,i,s,r){const o=t.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=Za[o[a].getType()];h(n,o[a],e,i,s,r)}}function Pu(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function Mu(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function Lu(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(o||r){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}function Au(n,t,e,i,s,r){const o=e.getImage(),a=e.getText(),l=a&&a.getText(),h=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=P.LOADED)return;const c=n.getBuilder(e.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(t,i,s)}if(l){const c=n.getBuilder(e.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(t,i,s)}}function Fu(n,t,e,i,s,r){const o=e.getImage(),a=o&&o.getOpacity()!==0,l=e.getText(),h=l&&l.getText(),c=r&&a&&h?{}:void 0;if(a){if(o.getImageState()!=P.LOADED)return;const u=n.getBuilder(e.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(t,i,s)}if(h){const u=n.getBuilder(e.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(t,i,s)}}function bu(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}class $a extends Mt{constructor(t,e,i,s){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=s}}const Du=5;class Ou extends Hi{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=Du}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return O()}getData(t){return null}prepareFrame(t){return O()}renderFrame(t,e){return O()}forEachFeatureAtCoordinate(t,e,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===P.LOADED||e.getState()===P.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=P.LOADED&&e!=P.ERROR&&t.addEventListener(D.CHANGE,this.boundHandleImageChange_),e==P.IDLE&&(t.load(),e=t.getState()),e==P.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Ja=[];let pi=null;function ku(){pi=ft(1,1,void 0,{willReadFrequently:!0})}class Qa extends Ou{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=Zt(),this.pixelTransform=Zt(),this.inversePixelTransform=Zt(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){pi||ku(),pi.clearRect(0,0,1,1);let s;try{pi.drawImage(t,e,i,1,1,0,0,1,1),s=pi.getImageData(0,0,1,1).data}catch{return pi=null,null}return s}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i){const s=this.getLayer().getClassName();let r,o;if(t&&t.className===s&&(!i||t&&t.style.backgroundColor&&oe(ui(t.style.backgroundColor),ui(i)))){const a=t.firstElementChild;a instanceof HTMLCanvasElement&&(o=a.getContext("2d"))}if(o&&lu(o.canvas.style.transform,e)?(this.container=t,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=document.createElement("div"),r.className=s;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=ft();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){const s=An(i),r=zs(i),o=Ns(i),a=ks(i);mt(e.coordinateToPixelTransform,s),mt(e.coordinateToPixelTransform,r),mt(e.coordinateToPixelTransform,o),mt(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;mt(l,s),mt(l,r),mt(l,o),mt(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()}prepareContainer(t,e){const i=t.extent,s=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,a=Math.round(K(i)/s*o),l=Math.round(dt(i)/s*o);de(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),Da(this.inversePixelTransform,this.pixelTransform);const h=au(this.pixelTransform);if(this.useContainer(e,h,this.getBackground(t)),!this.containerReused){const c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(t,e,i){const s=this.getLayer();if(s.hasListener(t)){const r=new $a(t,this.inversePixelTransform,i,e);s.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Gt.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Gt.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new ka),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Gt.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Gt.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,s,r,o,a){const l=r/2,h=o/2,c=s/e,u=-c,d=-t[0]+a,f=-t[1];return de(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class Nu extends Qa{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=kt(),this.wrappedRenderedExtent_=kt(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,i){const s=e.extent,r=e.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,m=!(g[et.ANIMATING]||g[et.INTERACTING]),_=this.context,y=Math.round(K(s)/a*f),p=Math.round(dt(s)/a*f),E=u.getWrapX()&&l.canWrapX(),x=E?K(c):null,C=E?Math.ceil((s[2]-c[2])/x)+1:1;let S=E?Math.floor((s[0]-c[0])/x):0;do{let T=this.getRenderTransform(o,a,0,f,y,p,S*x);e.declutter&&(T=T.slice(0)),t.execute(_,[_.canvas.width,_.canvas.height],T,h,m,i===void 0?He:i?za:fu,i?d&&e.declutter[d]:void 0)}while(++S<C)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=ft(this.context.canvas.width,this.context.canvas.height,Ja))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,Zs(this.context),Ja.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(t,e){const i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;const s=t.viewState;this.prepareContainer(t,e);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Gt.PRERENDER)||this.getLayer().hasListener(Gt.POSTRENDER)))return this.container;if(this.setDrawContext_(),this.preRender(r,t),s.projection,this.clipped_=!1,a&&i.extent&&this.clipping){const l=Te(i.extent);a=_t(l,t.extent),this.clipped_=a&&!ae(l,t.extent),this.clipped_&&this.clipUnrotated(r,t,l)}return a&&this.renderWorlds(o,t,this.getLayer().getDeclutter()?!1:void 0),!t.declutter&&this.clipped_&&r.restore(),this.postRender(r,t),this.renderedRotation_!==s.rotation&&(this.renderedRotation_=s.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*te,d=i[1]*te;c.push(this.getRenderTransform(s,r,o,te,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!ae(g,l)){let m=l[0];const _=K(g);let y=0,p;for(;m<g[0];)--y,p=_*y,c.push(this.getRenderTransform(s,r,o,te,u,d,p).slice()),m+=_;for(y=0,m=l[2];m>g[2];)++y,p=_*y,c.push(this.getRenderTransform(s,r,o,te,u,d,p).slice()),m-=_}this.hitDetectionImageData_=Cu(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,Ka(r,this.renderedPixelRatio_))}e(wu(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,s,r){var d,f;if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(g,m,_){const y=X(g),p=h[y];if(p){if(p!==!0&&_<p.distanceSq){if(_===0)return h[y]=!0,r.splice(r.lastIndexOf(p),1),s(g,l,m);p.geometry=m,p.distanceSq=_}}else{if(_===0)return h[y]=!0,s(g,l,m);r.push(h[y]={feature:g,layer:l,geometry:m,distanceSq:_,callback:s})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,u?(f=(d=e.declutter)==null?void 0:d[u])==null?void 0:f.all().map(g=>g.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const s=t.viewHints[et.ANIMATING],r=t.viewHints[et.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,h=t.viewState,c=h.projection,u=h.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let m=e.getRenderOrder();m===void 0&&(m=Iu);const _=h.center.slice(),y=Oi(l,g*u),p=y.slice(),E=[y.slice()],x=c.getExtent();if(i.getWrapX()&&c.canWrapX()&&!ae(x,t.extent)){const F=K(x),q=Math.max(K(y)/2,F);y[0]=x[0]-q,y[2]=x[2]+q,Bo(_,c);const b=Vo(E[0],c);b[0]<x[0]&&b[2]<x[2]?E.push([b[0]+F,b[1],b[2]+F,b[3]]):b[0]>x[0]&&b[2]>x[2]&&E.push([b[0]-F,b[1],b[2]-F,b[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!t.declutter&&ae(this.wrappedRenderedExtent_,y))return oe(this.renderedExtent_,p)||(this.hitDetectionImageData_=null,this.renderedExtent_=p),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const C=new eu(Ua(u,d),y,u,d);let S;for(let F=0,q=E.length;F<q;++F)i.loadFeatures(E[F],u,c);const T=Ka(u,d);let I=!0;const R=(F,q)=>{let b;const W=F.getStyleFunction()||e.getStyleFunction();if(W&&(b=W(F,u)),b){const V=this.renderFeature(F,T,b,C,S,this.getLayer().getDeclutter(),q);I=I&&!V}},M=Vn(y),k=i.getFeaturesInExtent(M);m&&k.sort(m);for(let F=0,q=k.length;F<q;++F)R(k[F],F);this.renderedFeatures_=k,this.ready=I;const N=C.finish(),j=new gu(y,u,d,i.getOverlaps(),N,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=p,this.wrappedRenderedExtent_=y,this.renderedCenter_=_,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=j,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,s,r,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=Ha(s,t,i[h],e,this.boundHandleStyleImageChange_,r,o,a)||l;else l=Ha(s,t,i,e,this.boundHandleStyleImageChange_,r,o,a);return l}}function tl(n,t,e=0,i=n.length-1,s=Gu){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),g=Math.min(i,Math.floor(t+(l-h)*u/l+d));tl(n,t,f,g,s)}const r=n[t];let o=e,a=i;for(sn(n,e,t),s(n[i],r)>0&&sn(n,e,i);o<a;){for(sn(n,o,a),o++,a--;s(n[o],r)<0;)o++;for(;s(n[a],r)>0;)a--}s(n[e],r)===0?sn(n,e,a):(a++,sn(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function sn(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function Gu(n,t){return n<t?-1:n>t?1:0}let el=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!is(t,e))return i;const s=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;is(t,l)&&(e.leaf?i.push(a):Lr(t,l)?this._all(a,i):r.push(a))}e=r.pop()}return i}collides(t){let e=this.data;if(!is(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const r=e.children[s],o=e.leaf?this.toBBox(r):r;if(is(t,o)){if(e.leaf||Lr(t,o))return!0;i.push(r)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Ei([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),r=[],o=[];let a,l,h;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),i.leaf){const c=zu(t,i.children,e);if(c!==-1)return i.children.splice(c,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&Lr(i,s)?(r.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const r=i-e+1;let o=this._maxEntries,a;if(r<=o)return a=Ei(t.slice(e,i+1)),xi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,s-1))),a=Ei([]),a.leaf=!1,a.height=s;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));il(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);il(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return xi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let r=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=Mr(h),u=Vu(t,h)-c;u<o?(o=u,r=c<r?c:r,a=h):u===o&&c<r&&(r=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),r=[],o=this._chooseSubtree(s,this.data,e,r);for(o.children.push(t),on(o,s);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)}_split(t,e){const i=t[e],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=Ei(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,xi(i,this.toBBox),xi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Ei([t,e]),this.data.height=t.height+1,this.data.leaf=!1,xi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=rn(t,0,a,this.toBBox),h=rn(t,a,i,this.toBBox),c=Xu(l,h),u=Mr(l)+Mr(h);c<r?(r=c,s=a,o=u<o?u:o):c===r&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:Wu,r=t.leaf?this.compareMinY:ju,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,r);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const r=this.toBBox,o=rn(t,0,e,r),a=rn(t,i-e,i,r);let l=es(o)+es(a);for(let h=e;h<i-e;h++){const c=t.children[h];on(o,t.leaf?r(c):c),l+=es(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];on(a,t.leaf?r(c):c),l+=es(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)on(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():xi(t[e],this.toBBox)}};function zu(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i<t.length;i++)if(e(n,t[i]))return i;return-1}function xi(n,t){rn(n,0,n.children.length,t,n)}function rn(n,t,e,i,s){s||(s=Ei(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=t;r<e;r++){const o=n.children[r];on(s,n.leaf?i(o):o)}return s}function on(n,t){return n.minX=Math.min(n.minX,t.minX),n.minY=Math.min(n.minY,t.minY),n.maxX=Math.max(n.maxX,t.maxX),n.maxY=Math.max(n.maxY,t.maxY),n}function Wu(n,t){return n.minX-t.minX}function ju(n,t){return n.minY-t.minY}function Mr(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function es(n){return n.maxX-n.minX+(n.maxY-n.minY)}function Vu(n,t){return(Math.max(t.maxX,n.maxX)-Math.min(t.minX,n.minX))*(Math.max(t.maxY,n.maxY)-Math.min(t.minY,n.minY))}function Xu(n,t){const e=Math.max(n.minX,t.minX),i=Math.max(n.minY,t.minY),s=Math.min(n.maxX,t.maxX),r=Math.min(n.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,r-i)}function Lr(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function is(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function Ei(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function il(n,t,e,i,s){const r=[t,e];for(;r.length;){if(e=r.pop(),t=r.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;tl(n,o,t,e,s),r.push(t,o,o,e)}}let Je=0;const Rt=1<<Je++,Y=1<<Je++,At=1<<Je++,Kt=1<<Je++,Qe=1<<Je++,an=1<<Je++,ns=Math.pow(2,Je)-1,Ar={[Rt]:"boolean",[Y]:"number",[At]:"string",[Kt]:"color",[Qe]:"number[]",[an]:"size"},Bu=Object.keys(Ar).map(Number).sort(Ge);function Yu(n){return n in Ar}function ln(n){const t=[];for(const e of Bu)hn(n,e)&&t.push(Ar[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function hn(n,t){return(n&t)===t}function De(n,t){return n===t}class lt{constructor(t,e){if(!Yu(t))throw new Error(`literal expressions must have a specific type, got ${ln(t)}`);this.type=t,this.value=e}}class Zu{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function nl(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function pt(n,t,e){switch(typeof n){case"boolean":{if(De(t,At))return new lt(At,n?"true":"false");if(!hn(t,Rt))throw new Error(`got a boolean, but expected ${ln(t)}`);return new lt(Rt,n)}case"number":{if(De(t,an))return new lt(an,yi(n));if(De(t,Rt))return new lt(Rt,!!n);if(De(t,At))return new lt(At,n.toString());if(!hn(t,Y))throw new Error(`got a number, but expected ${ln(t)}`);return new lt(Y,n)}case"string":{if(De(t,Kt))return new lt(Kt,ur(n));if(De(t,Rt))return new lt(Rt,!!n);if(!hn(t,At))throw new Error(`got a string, but expected ${ln(t)}`);return new lt(At,n)}}if(!Array.isArray(n))throw new Error("expression must be an array or a primitive value");if(n.length===0)throw new Error("empty expression");if(typeof n[0]=="string")return nd(n,t,e);for(const i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(De(t,an)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new lt(an,n)}if(De(t,Kt)){if(n.length===3)return new lt(Kt,[...n,1]);if(n.length===4)return new lt(Kt,n);throw new Error(`expected an array of 3 or 4 values for a color, got ${n.length}`)}if(!hn(t,Qe))throw new Error(`got an array of numbers, but expected ${ln(t)}`);return new lt(Qe,n)}const w={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},Ku={[w.Get]:A(G(1,1/0),sl),[w.Var]:A(G(1,1),Uu),[w.Has]:A(G(1,1/0),sl),[w.Id]:A(Hu,Ci),[w.Concat]:A(G(2,1/0),Z(At)),[w.GeometryType]:A(qu,Ci),[w.LineMetric]:A(Ci),[w.Resolution]:A(Fr,Ci),[w.Zoom]:A(Fr,Ci),[w.Time]:A(Fr,Ci),[w.Any]:A(G(2,1/0),Z(Rt)),[w.All]:A(G(2,1/0),Z(Rt)),[w.Not]:A(G(1,1),Z(Rt)),[w.Equal]:A(G(2,2),Z(ns)),[w.NotEqual]:A(G(2,2),Z(ns)),[w.GreaterThan]:A(G(2,2),Z(Y)),[w.GreaterThanOrEqualTo]:A(G(2,2),Z(Y)),[w.LessThan]:A(G(2,2),Z(Y)),[w.LessThanOrEqualTo]:A(G(2,2),Z(Y)),[w.Multiply]:A(G(2,1/0),rl),[w.Coalesce]:A(G(2,1/0),rl),[w.Divide]:A(G(2,2),Z(Y)),[w.Add]:A(G(2,1/0),Z(Y)),[w.Subtract]:A(G(2,2),Z(Y)),[w.Clamp]:A(G(3,3),Z(Y)),[w.Mod]:A(G(2,2),Z(Y)),[w.Pow]:A(G(2,2),Z(Y)),[w.Abs]:A(G(1,1),Z(Y)),[w.Floor]:A(G(1,1),Z(Y)),[w.Ceil]:A(G(1,1),Z(Y)),[w.Round]:A(G(1,1),Z(Y)),[w.Sin]:A(G(1,1),Z(Y)),[w.Cos]:A(G(1,1),Z(Y)),[w.Atan]:A(G(1,2),Z(Y)),[w.Sqrt]:A(G(1,1),Z(Y)),[w.Match]:A(G(4,1/0),ol,Ju),[w.Between]:A(G(3,3),Z(Y)),[w.Interpolate]:A(G(6,1/0),ol,Qu),[w.Case]:A(G(3,1/0),$u,td),[w.In]:A(G(2,2),ed),[w.Number]:A(G(1,1/0),Z(ns)),[w.String]:A(G(1,1/0),Z(ns)),[w.Array]:A(G(1,1/0),Z(Y)),[w.Color]:A(G(1,4),Z(Y)),[w.Band]:A(G(1,3),Z(Y)),[w.Palette]:A(G(2,2),id),[w.ToString]:A(G(1,1),Z(Rt|Y|At|Kt))};function sl(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=n[r+1];switch(typeof o){case"number":{s[r]=new lt(Y,o);break}case"string":{s[r]=new lt(At,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&e.properties.add(String(o))}return s}function Uu(n,t,e){const i=n[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return e.variables.add(i),[new lt(At,i)]}function Hu(n,t,e){e.featureId=!0}function qu(n,t,e){e.geometryType=!0}function Fr(n,t,e){e.mapState=!0}function Ci(n,t,e){const i=n[0];if(n.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function G(n,t){return function(e,i,s){const r=e[0],o=e.length-1;if(n===t){if(o!==n){const a=n===1?"":"s";throw new Error(`expected ${n} argument${a} for ${r}, got ${o}`)}}else if(o<n||o>t){const a=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function rl(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=pt(n[r+1],t,e);s[r]=o}return s}function Z(n){return function(t,e,i){const s=t.length-1,r=new Array(s);for(let o=0;o<s;++o){const a=pt(t[o+1],n,i);r[o]=a}return r}}function $u(n,t,e){const i=n[0],s=n.length-1;if(s%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${s} instead`)}function ol(n,t,e){const i=n[0],s=n.length-1;if(s%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${s} instead`)}function Ju(n,t,e){const i=n.length-1,s=At|Y|Rt,r=pt(n[1],s,e),o=pt(n[n.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const h=pt(n[l+2],r.type,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{const h=pt(n[l+3],o.type,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[r,...a,o]}function Qu(n,t,e){const i=n[1];let s;switch(i[0]){case"linear":s=1;break;case"exponential":const l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);s=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const r=new lt(Y,s);let o;try{o=pt(n[2],Y,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(n.length-3);for(let l=0;l<a.length;l+=2){try{const h=pt(n[l+3],Y,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=pt(n[l+4],t,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[r,o,...a]}function td(n,t,e){const i=pt(n[n.length-1],t,e),s=new Array(n.length-1);for(let r=0;r<s.length-1;r+=2){try{const o=pt(n[r+1],Rt,e);s[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=pt(n[r+2],i.type,e);s[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return s[s.length-1]=i,s}function ed(n,t,e){let i=n[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let s;if(typeof i[0]=="string"){if(i[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(i[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');i=i[1],s=At}else s=Y;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=pt(i[a],s,e);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[pt(n[1],s,e),...r]}function id(n,t,e){let i;try{i=pt(n[1],Y,e)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const s=n[2];if(!Array.isArray(s))throw new Error("the second argument of palette must be an array");const r=new Array(s.length);for(let o=0;o<r.length;o++){let a;try{a=pt(s[o],Kt,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof lt))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function A(...n){return function(t,e,i){const s=t[0];let r;for(let o=0;o<n.length;o++){const a=n[o](t,e,i);if(o==n.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new Zu(e,s,...r)}}function nd(n,t,e){const i=n[0],s=Ku[i];if(!s)throw new Error(`unknown operator: ${i}`);return s(n,t,e)}function al(n){if(!n)return"";const t=n.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return al(n.getGeometries()[0]);default:return""}}function ll(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function _e(n,t,e){const i=pt(n,t,e);return Ut(i)}function Ut(n,t){if(n instanceof lt){if(n.type===Kt&&typeof n.value=="string"){const i=ur(n.value);return function(){return i}}return function(){return n.value}}const e=n.operator;switch(e){case w.Number:case w.String:case w.Coalesce:return sd(n);case w.Get:case w.Var:case w.Has:return rd(n);case w.Id:return i=>i.featureId;case w.GeometryType:return i=>i.geometryType;case w.Concat:{const i=n.args.map(s=>Ut(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 ad(n);case w.Equal:case w.NotEqual:case w.LessThan:case w.LessThanOrEqualTo:case w.GreaterThan:case w.GreaterThanOrEqualTo:return od(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 ld(n);case w.Case:return hd(n);case w.Match:return cd(n);case w.Interpolate:return ud(n);case w.ToString:return dd(n);default:throw new Error(`Unsupported operator ${e}`)}}function sd(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Ut(n.args[r]);switch(e){case w.Coalesce:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case w.Number:case w.String:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a===e)return a}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}function rd(n,t){const i=n.args[0].value;switch(n.operator){case w.Get:return s=>{const r=n.args;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;o=o[c]}return o};case w.Var:return s=>s.variables[i];case w.Has:return s=>{const r=n.args;if(!(i in s.properties))return!1;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function od(n,t){const e=n.operator,i=Ut(n.args[0]),s=Ut(n.args[1]);switch(e){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)<s(r);case w.LessThanOrEqualTo:return 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 ${e}`)}}function ad(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Ut(n.args[r]);switch(e){case w.Any:return r=>{for(let o=0;o<i;++o)if(s[o](r))return!0;return!1};case w.All:return r=>{for(let o=0;o<i;++o)if(!s[o](r))return!1;return!0};case w.Between:return r=>{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<i;++a)if(o===s[a](r))return!0;return!1};case w.Not:return r=>!s[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function ld(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Ut(n.args[r]);switch(e){case w.Multiply:return r=>{let o=1;for(let a=0;a<i;++a)o*=s[a](r);return o};case w.Divide:return r=>s[0](r)/s[1](r);case w.Add:return r=>{let o=0;for(let a=0;a<i;++a)o+=s[a](r);return o};case w.Subtract:return r=>s[0](r)-s[1](r);case w.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(o<a)return a;const l=s[2](r);return o>l?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 ${e}`)}}function hd(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Ut(n.args[s]);return s=>{for(let r=0;r<e-1;r+=2)if(i[r](s))return i[r+1](s);return i[e-1](s)}}function cd(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Ut(n.args[s]);return s=>{const r=i[0](s);for(let o=1;o<e-1;o+=2)if(r===i[o](s))return i[o+1](s);return i[e-1](s)}}function ud(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Ut(n.args[s]);return s=>{const r=i[0](s),o=i[1](s);let a,l;for(let h=2;h<e;h+=2){const c=i[h](s);let u=i[h+1](s);const d=Array.isArray(u);if(d&&(u=Ac(u)),c>=o)return h===2?u:d?fd(r,o,a,l,c,u):cn(r,o,a,l,c,u);a=c,l=u}return l}}function dd(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Ut(n.args[r]);switch(e){case w.ToString:return r=>{const o=s[0](r);return n.args[0].type===Kt?dr(o):o.toString()};default:throw new Error(`Unsupported convert operator ${e}`)}}function cn(n,t,e,i,s,r){const o=s-e;if(o===0)return i;const a=t-e,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function fd(n,t,e,i,s,r){if(s-e===0)return i;const a=_a(i),l=_a(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[cn(n,t,e,a[0],s,l[0]),cn(n,t,e,a[1],s,l[1]),a[2]+cn(n,t,e,0,s,h),cn(n,t,e,i[3],s,r[3])];return Fc(c)}function gd(n){return!0}function _d(n){const t=nl(),e=md(n,t),i=ll();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,t.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=al(s.getGeometry())),e(i)}}function hl(n){const t=nl(),e=n.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=br(n[o],t);const s=ll(),r=new Array(e);return function(o,a){if(s.properties=o.getPropertiesInternal(),s.resolution=a,t.featureId){const h=o.getId();h!==void 0?s.featureId=h:s.featureId=null}let l=0;for(let h=0;h<e;++h){const c=i[h](s);c&&(r[l]=c,l+=1)}return r.length=l,r}}function md(n,t){const e=n.length,i=new Array(e);for(let s=0;s<e;++s){const r=n[s],o="filter"in r?_e(r.filter,Rt,t):gd;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=br(r.style[h],t)}else a=[br(r.style,t)];i[s]={filter:o,styles:a}}return function(s){const r=[];let o=!1;for(let a=0;a<e;++a){const l=i[a].filter;if(l(s)&&!(n[a].else&&o)){o=!0;for(const h of i[a].styles){const c=h(s);c&&r.push(c)}}}return r}}function br(n,t){const e=un(n,"",t),i=dn(n,"",t),s=yd(n,t),r=pd(n,t),o=Ft(n,"z-index",t);if(!e&&!i&&!s&&!r&&!Xe(n))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(n));const a=new at;return function(l){let h=!0;if(e){const c=e(l);c&&(h=!1),a.setFill(c)}if(i){const c=i(l);c&&(h=!1),a.setStroke(c)}if(s){const c=s(l);c&&(h=!1),a.setText(c)}if(r){const c=r(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function un(n,t,e){let i;if(t+"fill-pattern-src"in n)i=wd(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return r=>null;i=Dr(n,t+"fill-color",e)}if(!i)return null;const s=new yt;return function(r){const o=i(r);return o===sr?null:(s.setColor(o),s)}}function dn(n,t,e){const i=Ft(n,t+"stroke-width",e),s=Dr(n,t+"stroke-color",e);if(!i&&!s)return null;const r=me(n,t+"stroke-line-cap",e),o=me(n,t+"stroke-line-join",e),a=cl(n,t+"stroke-line-dash",e),l=Ft(n,t+"stroke-line-dash-offset",e),h=Ft(n,t+"stroke-miter-limit",e),c=new Qt;return function(u){if(s){const d=s(u);if(d===sr)return null;c.setColor(d)}if(i&&c.setWidth(i(u)),r){const d=r(u);if(d!=="butt"&&d!=="round"&&d!=="square")throw new Error("Expected butt, round, or square line cap");c.setLineCap(d)}if(o){const d=o(u);if(d!=="bevel"&&d!=="round"&&d!=="miter")throw new Error("Expected bevel, round, or miter line join");c.setLineJoin(d)}return a&&c.setLineDash(a(u)),l&&c.setLineDashOffset(l(u)),h&&c.setMiterLimit(h(u)),c}}function yd(n,t){const e="text-",i=me(n,e+"value",t);if(!i)return null;const s=un(n,e,t),r=un(n,e+"background-",t),o=dn(n,e,t),a=dn(n,e+"background-",t),l=me(n,e+"font",t),h=Ft(n,e+"max-angle",t),c=Ft(n,e+"offset-x",t),u=Ft(n,e+"offset-y",t),d=wi(n,e+"overflow",t),f=me(n,e+"placement",t),g=Ft(n,e+"repeat",t),m=rs(n,e+"scale",t),_=wi(n,e+"rotate-with-view",t),y=Ft(n,e+"rotation",t),p=me(n,e+"align",t),E=me(n,e+"justify",t),x=me(n,e+"baseline",t),C=wi(n,e+"keep-upright",t),S=cl(n,e+"padding",t),T=as(n,e+"declutter-mode"),I=new qe({declutterMode:T});return function(R){if(I.setText(i(R)),s&&I.setFill(s(R)),r&&I.setBackgroundFill(r(R)),o&&I.setStroke(o(R)),a&&I.setBackgroundStroke(a(R)),l&&I.setFont(l(R)),h&&I.setMaxAngle(h(R)),c&&I.setOffsetX(c(R)),u&&I.setOffsetY(u(R)),d&&I.setOverflow(d(R)),f){const M=f(R);if(M!=="point"&&M!=="line")throw new Error("Expected point or line for text-placement");I.setPlacement(M)}if(g&&I.setRepeat(g(R)),m&&I.setScale(m(R)),_&&I.setRotateWithView(_(R)),y&&I.setRotation(y(R)),p){const M=p(R);if(M!=="left"&&M!=="center"&&M!=="right"&&M!=="end"&&M!=="start")throw new Error("Expected left, right, center, start, or end for text-align");I.setTextAlign(M)}if(E){const M=E(R);if(M!=="left"&&M!=="right"&&M!=="center")throw new Error("Expected left, right, or center for text-justify");I.setJustify(M)}if(x){const M=x(R);if(M!=="bottom"&&M!=="top"&&M!=="middle"&&M!=="alphabetic"&&M!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");I.setTextBaseline(M)}return S&&I.setPadding(S(R)),C&&I.setKeepUpright(C(R)),I}}function pd(n,t){return"icon-src"in n?xd(n,t):"shape-points"in n?Ed(n,t):"circle-radius"in n?Cd(n,t):null}function xd(n,t){const e="icon-",i=e+"src",s=gl(n[i],i),r=ss(n,e+"anchor",t),o=rs(n,e+"scale",t),a=Ft(n,e+"opacity",t),l=ss(n,e+"displacement",t),h=Ft(n,e+"rotation",t),c=wi(n,e+"rotate-with-view",t),u=dl(n,e+"anchor-origin"),d=fl(n,e+"anchor-x-units"),f=fl(n,e+"anchor-y-units"),g=vd(n,e+"color"),m=Id(n,e+"cross-origin"),_=Rd(n,e+"offset"),y=dl(n,e+"offset-origin"),p=os(n,e+"width"),E=os(n,e+"height"),x=Sd(n,e+"size"),C=as(n,e+"declutter-mode"),S=new Qn({src:s,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:m,offset:_,offsetOrigin:y,height:E,width:p,size:x,declutterMode:C});return function(T){return a&&S.setOpacity(a(T)),l&&S.setDisplacement(l(T)),h&&S.setRotation(h(T)),c&&S.setRotateWithView(c(T)),o&&S.setScale(o(T)),r&&S.setAnchor(r(T)),S}}function Ed(n,t){const e="shape-",i=e+"points",s=e+"radius",r=Or(n[i],i),o=Or(n[s],s),a=un(n,e,t),l=dn(n,e,t),h=rs(n,e+"scale",t),c=ss(n,e+"displacement",t),u=Ft(n,e+"rotation",t),d=wi(n,e+"rotate-with-view",t),f=os(n,e+"radius2"),g=os(n,e+"angle"),m=as(n,e+"declutter-mode"),_=new Jn({points:r,radius:o,radius2:f,angle:g,declutterMode:m});return function(y){return a&&_.setFill(a(y)),l&&_.setStroke(l(y)),c&&_.setDisplacement(c(y)),u&&_.setRotation(u(y)),d&&_.setRotateWithView(d(y)),h&&_.setScale(h(y)),_}}function Cd(n,t){const e="circle-",i=un(n,e,t),s=dn(n,e,t),r=Ft(n,e+"radius",t),o=rs(n,e+"scale",t),a=ss(n,e+"displacement",t),l=Ft(n,e+"rotation",t),h=wi(n,e+"rotate-with-view",t),c=as(n,e+"declutter-mode"),u=new nn({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),i&&u.setFill(i(d)),s&&u.setStroke(s(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function Ft(n,t,e){if(!(t in n))return;const i=_e(n[t],Y,e);return function(s){return Or(i(s),t)}}function me(n,t,e){if(!(t in n))return null;const i=_e(n[t],At,e);return function(s){return gl(i(s),t)}}function wd(n,t,e){const i=me(n,t+"pattern-src",e),s=ul(n,t+"pattern-offset",e),r=ul(n,t+"pattern-size",e),o=Dr(n,t+"color",e);return function(a){return{src:i(a),offset:s&&s(a),size:r&&r(a),color:o&&o(a)}}}function wi(n,t,e){if(!(t in n))return null;const i=_e(n[t],Rt,e);return function(s){const r=i(s);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${t}`);return r}}function Dr(n,t,e){if(!(t in n))return null;const i=_e(n[t],Kt,e);return function(s){return _l(i(s),t)}}function cl(n,t,e){if(!(t in n))return null;const i=_e(n[t],Qe,e);return function(s){return fn(i(s),t)}}function ss(n,t,e){if(!(t in n))return null;const i=_e(n[t],Qe,e);return function(s){const r=fn(i(s),t);if(r.length!==2)throw new Error(`Expected two numbers for ${t}`);return r}}function ul(n,t,e){if(!(t in n))return null;const i=_e(n[t],Qe,e);return function(s){return ml(i(s),t)}}function rs(n,t,e){if(!(t in n))return null;const i=_e(n[t],Qe|Y,e);return function(s){return Td(i(s),t)}}function os(n,t){const e=n[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function Sd(n,t){const e=n[t];if(e!==void 0){if(typeof e=="number")return yi(e);if(!Array.isArray(e))throw new Error(`Expected a number or size array for ${t}`);if(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return e}}function Id(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function dl(n,t){const e=n[t];if(e!==void 0){if(e!=="bottom-left"&&e!=="bottom-right"&&e!=="top-left"&&e!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return e}}function fl(n,t){const e=n[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function Rd(n,t){const e=n[t];if(e!==void 0)return fn(e,t)}function as(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);if(e!=="declutter"&&e!=="obstacle"&&e!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return e}}function vd(n,t){const e=n[t];if(e!==void 0)return _l(e,t)}function fn(n,t){if(!Array.isArray(n))throw new Error(`Expected an array for ${t}`);const e=n.length;for(let i=0;i<e;++i)if(typeof n[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return n}function gl(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function Or(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function _l(n,t){if(typeof n=="string")return n;const e=fn(n,t),i=e.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function ml(n,t){const e=fn(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function Td(n,t){return typeof n=="number"?n:ml(n,t)}const Ht={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function yl(n,t,e){return(function(i,s,r,o,a){if(!i)return;if(!s&&!t)return i;const l=t?0:r[0]*s,h=t?0:r[1]*s,c=a?a[0]:0,u=a?a[1]:0;let d=n[0]+l/2+c,f=n[2]-l/2+c,g=n[1]+h/2+u,m=n[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=rt(i[0],d,f),y=rt(i[1],g,m);if(o&&e&&s){const p=30*s;_+=-p*Math.log(1+Math.max(0,d-i[0])/p)+p*Math.log(1+Math.max(0,i[0]-f)/p),y+=-p*Math.log(1+Math.max(0,g-i[1])/p)+p*Math.log(1+Math.max(0,i[1]-m)/p)}return[_,y]})}function Pd(n){return n}function Md(n){return Math.pow(n,3)}function Si(n){return 1-Md(1-n)}function Ld(n){return 3*n*n-2*n*n*n}function Ad(n){return n}function pl(n,t,e,i){let s=0;const r=n[e-i],o=n[e-i+1];let a=0,l=0;for(;t<e;t+=i){const h=n[t]-r,c=n[t+1]-o;s+=l*h-a*c,a=h,l=c}return s/2}function xl(n,t,e,i){let s=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];s+=pl(n,t,a,i),t=a}return s}function Fd(n,t,e,i){let s=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];s+=xl(n,t,a,i),t=a[a.length-1]}return s}function El(n,t,e,i,s,r,o){const a=n[t],l=n[t+1],h=n[e]-a,c=n[e+1]-l;let u;if(h===0&&c===0)u=t;else{const d=((s-a)*h+(r-l)*c)/(h*h+c*c);if(d>1)u=e;else if(d>0){for(let f=0;f<i;++f)o[f]=bt(n[t+f],n[e+f],d);o.length=i;return}else u=t}for(let d=0;d<i;++d)o[d]=n[u+d];o.length=i}function kr(n,t,e,i,s){let r=n[t],o=n[t+1];for(t+=i;t<e;t+=i){const a=n[t],l=n[t+1],h=le(r,o,a,l);h>s&&(s=h),r=a,o=l}return s}function Nr(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];s=kr(n,t,a,i,s),t=a}return s}function bd(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];s=Nr(n,t,a,i,s),t=a[a.length-1]}return s}function Gr(n,t,e,i,s,r,o,a,l,h,c){if(t==e)return h;let u,d;if(s===0){if(d=le(o,a,n[t],n[t+1]),d<h){for(u=0;u<i;++u)l[u]=n[t+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=t+i;for(;f<e;)if(El(n,f-i,f,i,o,a,c),d=le(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/s|0,1);if(r&&(El(n,e-i,t,i,o,a,c),d=le(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function zr(n,t,e,i,s,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=Gr(n,t,f,i,s,r,o,a,l,h,c),t=f}return h}function Dd(n,t,e,i,s,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=zr(n,t,f,i,s,r,o,a,l,h,c),t=f[f.length-1]}return h}function Cl(n,t,e,i){for(let s=0,r=e.length;s<r;++s)n[t++]=e[s];return t}function ls(n,t,e,i){for(let s=0,r=e.length;s<r;++s){const o=e[s];for(let a=0;a<i;++a)n[t++]=o[a]}return t}function gn(n,t,e,i,s){s=s||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=ls(n,t,e[o],i);s[r++]=l,t=l}return s.length=r,s}function wl(n,t,e,i,s){s=s||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=gn(n,t,e[o],i,s[r]);l.length===0&&(l[0]=t),s[r++]=l,t=l[l.length-1]}return s.length=r,s}class _n extends be{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}clone(){return new _n(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Gr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,s))}getArea(){return pl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Pe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=Hn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new _n(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ls(this.flatCoordinates,0,t,this.stride),this.changed()}}class vt extends be{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new vt(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){const r=this.flatCoordinates,o=le(t,e,r[0],r[1]);if(o<s){const a=this.stride;for(let l=0;l<a;++l)i[l]=r[l];return i.length=a,o}return s}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return Gi(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return bs(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Cl(this.flatCoordinates,0,t,this.stride),this.changed()}}function Od(n,t,e,i,s){return!jo(s,function(o){return!ti(n,t,e,i,o[0],o[1])})}function ti(n,t,e,i,s,r){let o=0,a=n[e-i],l=n[e-i+1];for(;t<e;t+=i){const h=n[t],c=n[t+1];l<=r?c>r&&(h-a)*(r-l)-(s-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(s-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function Wr(n,t,e,i,s,r){if(e.length===0||!ti(n,t,e[0],i,s,r))return!1;for(let o=1,a=e.length;o<a;++o)if(ti(n,e[o-1],e[o],i,s,r))return!1;return!0}function kd(n,t,e,i,s,r){if(e.length===0)return!1;for(let o=0,a=e.length;o<a;++o){const l=e[o];if(Wr(n,t,l,i,s,r))return!0;t=l[l.length-1]}return!1}function jr(n,t,e,i,s,r,o){let a,l,h,c,u,d,f;const g=s[r+1],m=[];for(let p=0,E=e.length;p<E;++p){const x=e[p];for(c=n[x-i],d=n[x-i+1],a=t;a<x;a+=i)u=n[a],f=n[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,m.push(h)),c=u,d=f}let _=NaN,y=-1/0;for(m.sort(Ge),c=m[0],a=1,l=m.length;a<l;++a){u=m[a];const p=Math.abs(u-c);p>y&&(h=(c+u)/2,Wr(n,t,e,i,h,g)&&(_=h,y=p)),c=u}return isNaN(_)&&(_=s[r]),o?(o.push(_,g,y),o):[_,g,y]}function Sl(n,t,e,i,s){let r=[];for(let o=0,a=e.length;o<a;++o){const l=e[o];r=jr(n,t,l,i,s,2*o,r),t=l[l.length-1]}return r}function Il(n,t,e,i,s){let r;for(t+=i;t<e;t+=i)if(r=s(n.slice(t-i,t),n.slice(t,t+i)),r)return r;return!1}function Rl(n,t){const[e,i]=n,[s,r]=t,o=((e[0]-s[0])*(s[1]-r[1])-(e[1]-s[1])*(s[0]-r[0]))/((e[0]-i[0])*(s[1]-r[1])-(e[1]-i[1])*(s[0]-r[0])),a=((e[0]-s[0])*(e[1]-i[1])-(e[1]-s[1])*(e[0]-i[0]))/((e[0]-i[0])*(s[1]-r[1])-(e[1]-i[1])*(s[0]-r[0]));if(0<=o&&o<=1&&0<=a&&a<=1)return[e[0]+o*(i[0]-e[0]),e[1]+o*(i[1]-e[1])]}function hs(n,t,e,i,s,r){return r=r??Wo(kt(),n,t,e,i),_t(s,r)?r[0]>=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:Il(n,t,e,i,function(o,a){return Dh(s,o,a)}):!1}function Nd(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){if(hs(n,t,e[r],i,s))return!0;t=e[r]}return!1}function Gd(n,t,e,i,s){return!!(hs(n,t,e,i,s)||ti(n,t,e,i,s[0],s[1])||ti(n,t,e,i,s[0],s[3])||ti(n,t,e,i,s[2],s[1])||ti(n,t,e,i,s[2],s[3]))}function vl(n,t,e,i,s){if(!Gd(n,t,e[0],i,s))return!1;if(e.length===1)return!0;for(let r=1,o=e.length;r<o;++r)if(Od(n,e[r-1],e[r],i,s)&&!hs(n,e[r-1],e[r],i,s))return!1;return!0}function zd(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(vl(n,t,a,i,s))return!0;t=a[a.length-1]}return!1}function Wd(n,t,e,i){for(;t<e-i;){for(let s=0;s<i;++s){const r=n[t+s];n[t+s]=n[e-i+s],n[e-i+s]=r}t+=i,e-=i}}function Vr(n,t,e,i){let s=0,r=n[e-i],o=n[e-i+1];for(;t<e;t+=i){const a=n[t],l=n[t+1];s+=(a-r)*(l+o),r=a,o=l}return s===0?void 0:s>0}function Xr(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=Vr(n,t,a,i);if(r===0){if(s&&l||!s&&!l)return!1}else if(s&&!l||!s&&l)return!1;t=a}return!0}function Tl(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(!Xr(n,t,a,i,s))return!1;a.length&&(t=a[a.length-1])}return!0}function cs(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=Vr(n,t,a,i);(r===0?s&&l||!s&&!l:s&&!l||!s&&l)&&Wd(n,t,a,i),t=a}return t}function Br(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r)t=cs(n,t,e[r],i,s);return t}function jd(n,t){const e=[];let i=0,s=0,r;for(let o=0,a=t.length;o<a;++o){const l=t[o],h=Vr(n,i,l,2);if(r===void 0&&(r=h),h===r)e.push(t.slice(s,o+1));else{if(e.length===0)continue;e[e.length-1].push(t[s])}s=o+1,i=l}return e}class qt extends be{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,e!==void 0&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?Ot(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new qt(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Nr(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zr(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,s))}containsXY(t,e){return Wr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return xl(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),cs(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Ui(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=Xt(this.getExtent());this.flatInteriorPoint_=jr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new vt(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new _n(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,i=this.ends_,s=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o],h=new _n(e.slice(r,l),t);s.push(h),r=l}return s}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Xr(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=cs(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=wr(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new qt(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return vl(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=gn(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function Pl(n){if(si(n))throw new Error("Cannot create polygon from empty extent");const t=n[0],e=n[1],i=n[2],s=n[3],r=[t,e,t,s,i,s,i,e,t,e];return new qt(r,"XY",[r.length])}function Vd(n,t,e){t=t||32;const i=n.getStride(),s=n.getLayout(),r=n.getCenter(),o=i*(t+1),a=new Array(o);for(let c=0;c<o;c+=i){a[c]=0,a[c+1]=0;for(let u=2;u<i;u++)a[c+u]=r[u]}const l=[a.length],h=new qt(a,s,l);return Xd(h,r,n.getRadius()),h}function Xd(n,t,e,i){const s=n.getFlatCoordinates(),r=n.getStride(),o=s.length/r-1,a=0;for(let l=0;l<=o;++l){const h=l*r,c=a+ri(l,o)*2*Math.PI/o;s[h]=t[0]+e*Math.cos(c),s[h+1]=t[1]+e*Math.sin(c)}n.changed()}function Yr(n,t,e,i){const s=K(t)/e[0],r=dt(t)/e[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function Zr(n,t,e){let i=Math.min(n,t);const s=50;return i*=Math.log(1+s*Math.max(0,n/t-1))/s+1,e&&(i=Math.max(i,e),i/=Math.log(1+s*Math.max(0,e/n-1))/s+1),rt(i,e/2,t*2)}function Bd(n,t,e,i){return t=t!==void 0?t:!0,(function(s,r,o,a){if(s!==void 0){const l=n[0],h=n[n.length-1],c=e?Yr(l,e,o,i):l;if(a)return t?Zr(s,c,h):rt(s,h,c);const u=Math.min(c,s),d=Math.floor(Fs(n,u,r));return n[d]>c&&d<n.length-1?n[d+1]:n[d]}})}function Yd(n,t,e,i,s,r){return i=i!==void 0?i:!0,e=e!==void 0?e:0,(function(o,a,l,h){if(o!==void 0){const c=s?Yr(t,s,l,r):t;if(h)return i?Zr(o,c,e):rt(o,e,c);const u=1e-9,d=Math.ceil(Math.log(t/c)/Math.log(n)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),m=Math.floor(Math.log(t/g)/Math.log(n)+f),_=Math.max(d,m),y=t/Math.pow(n,_);return rt(y,e,c)}})}function Ml(n,t,e,i,s){return e=e!==void 0?e:!0,(function(r,o,a,l){if(r!==void 0){const h=i?Yr(n,i,a,s):n;return!e||!l?rt(r,t,h):Zr(r,h,t)}})}function Kr(n){if(n!==void 0)return 0}function Ll(n){if(n!==void 0)return n}function Zd(n){const t=2*Math.PI/n;return(function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e})}function Kd(n){const t=Re(5);return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}const Ud=256,Ur=0;class ee extends Yt{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=tr(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&xc(),t.center&&(t.center=U(t.center,this.projection_)),t.extent&&(t.extent=Te(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const a in Ht)delete e[a];this.setProperties(e,!0);const i=qd(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;const s=Hd(t),r=i.constraint,o=$d(t);this.constraints_={center:s,resolution:r,rotation:o},this.setRotation(t.rotation!==void 0?t.rotation:0),this.setCenterInternal(t.center!==void 0?t.center:null),t.resolution!==void 0?this.setResolution(t.resolution):t.zoom!==void 0&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const i=this.getCenterInternal();if(i){const s=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),o=r/2*(s[3]-e[3]+e[1]-s[1]),a=r/2*(s[0]-e[0]+e[2]-s[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(t){const e=this.getProperties();return e.resolution!==void 0?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const e=new Array(arguments.length);for(let i=0;i<e.length;++i){let s=arguments[i];s.center&&(s=Object.assign({},s),s.center=U(s.center,this.getProjection())),s.anchor&&(s=Object.assign({},s),s.anchor=U(s.anchor,this.getProjection())),e[i]=s}this.animateInternal.apply(this,e)}animateInternal(t){let e=arguments.length,i;e>1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let s=0;for(;s<e&&!this.isDef();++s){const c=arguments[s];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(s===e){i&&us(i,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const h=[];for(;s<e;++s){const c=arguments[s],u={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||Ld,callback:i};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;const d=ri(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}Jd(u)?u.complete=!0:r+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(et.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[et.ANIMATING]>0}getInteracting(){return this.hints_[et.INTERACTING]>0}cancelAnimations(){this.setHint(et.ANIMATING,-this.hints_[et.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){const s=this.animations_[e];if(s[0].callback&&us(s[0].callback,!1),!t)for(let r=0,o=s.length;r<o;++r){const a=s[r];if(!a.complete){t=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let i=this.animations_.length-1;i>=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o<a;++o){const l=s[o];if(l.complete)continue;const h=t-l.start;let c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);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),y=f+u*(m-f);this.targetCenter_=[_,y]}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?ri(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),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(et.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&us(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-e[0],s[1]-e[1]],Vs(i,t-this.getRotation()),Gh(i,e)),i}calculateCenterZoom(t,e){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-s[0])/r,a=e[1]-t*(e[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],s=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(s*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(s*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t&&ve(t,this.getProjection())}getCenterInternal(){return this.get(Ht.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){const e=this.calculateExtentInternal(t);return Vn(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();it(e,"The view center is not defined");const i=this.getResolution();it(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return it(s!==void 0,"The view rotation is not defined"),Ln(e,i,s,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(Ht.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Te(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=K(t)/e[0],s=dt(t)/e[1];return Math.max(i,s)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(e/i)/Math.log(t);return(function(r){return e/Math.pow(t,r*s)})}getRotation(){return this.get(Ht.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/e;return(function(o){return Math.log(i/o)/e/r})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=Hr(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:s.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,s;if(this.resolutions_){const r=Fs(this.resolutions_,t,1);e=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 e+Math.log(i/t)/Math.log(s)}getResolutionForZoom(t){var e;if((e=this.resolutions_)!=null&&e.length){if(this.resolutions_.length===1)return this.resolutions_[0];const i=rt(Math.floor(t),0,this.resolutions_.length-2),s=this.resolutions_[i]/this.resolutions_[i+1];return this.resolutions_[i]/Math.pow(s,rt(t-i,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(it(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){it(!si(t),"Cannot fit empty extent provided as `geometry`");const s=Te(t,this.getProjection());i=Pl(s)}else if(t.getType()==="Circle"){const s=Te(t.getExtent(),this.getProjection());i=Pl(s),i.rotate(this.getRotation(),Xt(s))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),s=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*i-r[u+1]*s,g=r[u]*s+r[u+1]*i;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(t,e){e=e||{};let i=e.size;i||(i=this.getViewportSizeMinusPadding_());const s=e.padding!==void 0?e.padding:[0,0,0,0],r=e.nearest!==void 0?e.nearest:!1;let o;e.minResolution!==void 0?o=e.minResolution:e.maxZoom!==void 0?o=this.getResolutionForZoom(e.maxZoom):o=0;const a=this.rotatedExtentForGeometry(t);let l=this.getResolutionForExtentInternal(a,[i[0]-s[1]-s[3],i[1]-s[0]-s[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,r?0:1);const h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=Xt(a);d[0]+=(s[1]-s[3])/2*l,d[1]+=(s[0]-s[2])/2*l;const f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,m=this.getConstrainedCenter([f,g],l),_=e.callback?e.callback:Zi;e.duration!==void 0?this.animateInternal({resolution:l,center:m,duration:e.duration,easing:e.easing},_):(this.targetResolution_=l,this.targetCenter_=m,this.applyTargetState_(!1,!0),us(_,!0))}centerOn(t,e,i){this.centerOnInternal(U(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(Hr(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,s){let r;const o=this.padding_;if(o&&t){const a=this.getViewportSizeMinusPadding_(-i),l=Hr(t,s,[a[0]/2+o[3],a[1]/2+o[0]],e,i);r=[t[0]-l[0],t[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){const e=ve(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){const e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&U(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,s,i);e&&(this.targetCenter_=this.calculateCenterZoom(r,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=U(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(s,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&U(t,this.getProjection()))}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){const i=this.getAnimating()||this.getInteracting()||e,s=this.constraints_.rotation(this.targetRotation_,i),r=this.getViewportSize_(s),o=this.constraints_.resolution(this.targetResolution_,0,r,i),a=this.constraints_.center(this.targetCenter_,o,r,i,this.calculateCenterShift(this.targetCenter_,o,s,r));this.get(Ht.ROTATION)!==s&&this.set(Ht.ROTATION,s),this.get(Ht.RESOLUTION)!==o&&(this.set(Ht.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(Ht.CENTER)||!It(this.get(Ht.CENTER),a))&&this.set(Ht.CENTER,a),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=t!==void 0?t:200;const s=e||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,s,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!It(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:t,easing:Si,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(et.INTERACTING,1)}endInteraction(t,e,i){i=i&&U(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(et.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){const i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){const i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;const i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}}function us(n,t){setTimeout(function(){n(t)},0)}function Hd(n){if(n.extent!==void 0){const e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return yl(n.extent,n.constrainOnlyCenter,e)}const t=tr(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){const e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,yl(e,!1,!1)}return Pd}function qd(n){let t,e,i,o=n.minZoom!==void 0?n.minZoom:Ur,a=n.maxZoom!==void 0?n.maxZoom:28;const l=n.zoomFactor!==void 0?n.zoomFactor:2,h=n.multiWorld!==void 0?n.multiWorld:!1,c=n.smoothResolutionConstraint!==void 0?n.smoothResolutionConstraint:!0,u=n.showFullExtent!==void 0?n.showFullExtent:!1,d=tr(n.projection,"EPSG:3857"),f=d.getExtent();let g=n.constrainOnlyCenter,m=n.extent;if(!h&&!m&&d.isGlobal()&&(g=!1,m=f),n.resolutions!==void 0){const _=n.resolutions;e=_[o],i=_[a]!==void 0?_[a]:_[_.length-1],n.constrainResolution?t=Bd(_,c,!g&&m,u):t=Ml(e,i,c,!g&&m,u)}else{const y=(f?Math.max(K(f),dt(f)):360*$o.degrees/d.getMetersPerUnit())/Ud/Math.pow(2,Ur),p=y/Math.pow(2,28-Ur);e=n.maxResolution,e!==void 0?o=0:e=y/Math.pow(l,o),i=n.minResolution,i===void 0&&(n.maxZoom!==void 0?n.maxResolution!==void 0?i=e/Math.pow(l,a):i=y/Math.pow(l,a):i=p),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),n.constrainResolution?t=Yd(l,e,i,c,!g&&m,u):t=Ml(e,i,c,!g&&m,u)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function $d(n){if(n.enableRotation!==void 0?n.enableRotation:!0){const e=n.constrainRotation;return e===void 0||e===!0?Kd():e===!1?Ll:typeof e=="number"?Zd(e):Ll}return Kr}function Jd(n){return!(n.sourceCenter&&n.targetCenter&&!It(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function Hr(n,t,e,i,s){const r=Math.cos(-s);let o=Math.sin(-s),a=n[0]*r-n[1]*o,l=n[1]*r+n[0]*o;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,o=-o;const h=a*r-l*o,c=l*r+a*o;return[h,c]}const H={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};class Al extends Yt{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[H.OPACITY]=t.opacity!==void 0?t.opacity:1,it(typeof e[H.OPACITY]=="number","Layer opacity must be a number"),e[H.VISIBLE]=t.visible!==void 0?t.visible:!0,e[H.Z_INDEX]=t.zIndex,e[H.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[H.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[H.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[H.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=rt(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return O()}getLayerStatesArray(t){return O()}getExtent(){return this.get(H.EXTENT)}getMaxResolution(){return this.get(H.MAX_RESOLUTION)}getMinResolution(){return this.get(H.MIN_RESOLUTION)}getMinZoom(){return this.get(H.MIN_ZOOM)}getMaxZoom(){return this.get(H.MAX_ZOOM)}getOpacity(){return this.get(H.OPACITY)}getSourceState(){return O()}getVisible(){return this.get(H.VISIBLE)}getZIndex(){return this.get(H.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(H.EXTENT,t)}setMaxResolution(t){this.set(H.MAX_RESOLUTION,t)}setMinResolution(t){this.set(H.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(H.MAX_ZOOM,t)}setMinZoom(t){this.set(H.MIN_ZOOM,t)}setOpacity(t){it(typeof t=="number","Layer opacity must be a number"),this.set(H.OPACITY,t)}setVisible(t){this.set(H.VISIBLE,t)}setZIndex(t){this.set(H.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}let ds=class extends Al{constructor(t){const e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(H.SOURCE,this.handleSourcePropertyChange_);const i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return t=t||[],t.push(this),t}getLayerStatesArray(t){return t=t||[],t.push(this.getLayerState()),t}getSource(){return this.get(H.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&($(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=z(t,D.CHANGE,this.handleSourceChange_,this),t.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e;const i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof ee?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;if(e.layerStatesArray){if(s=e.layerStatesArray.find(o=>o.layer===this),!s)return!1}else s=this.getLayerState();const r=this.getExtent();return qr(s,e.viewState)&&(!r||_t(r,e.extent))}getAttributions(t){var r;if(!this.isVisible(t))return[];const e=(r=this.getSource())==null?void 0:r.getAttributions();if(!e)return[];const i=t instanceof ee?t.getViewStateAndExtent():t;let s=e(i);return Array.isArray(s)||(s=[s]),s}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(H.MAP,t)}getMapInternal(){return this.get(H.MAP)}setMap(t){this.mapPrecomposeKey_&&($(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&($(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=z(t,Gt.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=z(this,D.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);it(!e.some(s=>s.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)}setSource(t){this.set(H.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function qr(n,t){if(!n.visible)return!1;const e=t.resolution;if(e<n.minResolution||e>=n.maxResolution)return!1;const i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}const Fl={RENDER_ORDER:"renderOrder"};class bl extends ds{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Fl.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new el(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Fl.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Va:t;const e=Qd(t);this.styleFunction_=t===null?void 0:mu(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}function Qd(n){if(n===void 0)return Va;if(!n)return null;if(typeof n=="function"||n instanceof at)return n;if(!Array.isArray(n))return hl([n]);if(n.length===0)return[];const t=n.length,e=n[0];if(e instanceof at){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!(o instanceof at))throw new Error("Expected a list of style instances");s[r]=o}return s}if("style"in e){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");s[r]=o}return _d(s)}return hl(n)}class Ii extends bl{constructor(t){super(t)}createRenderer(){return new Nu(this)}}const nt={ADD:"add",REMOVE:"remove"},Dl={LENGTH:"length"};class fs extends Mt{constructor(t,e,i){super(t),this.element=e,this.index=i}}class xt extends Yt{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t||[],this.unique_)for(let i=0,s=this.array_.length;i<s;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(Dl.LENGTH)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new fs(nt.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){this.unique_&&this.assertUnique_(t);const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new fs(nt.REMOVE,e,t)),e}setAt(t,e){const i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const s=this.array_[t];this.array_[t]=e,this.dispatchEvent(new fs(nt.REMOVE,s,t)),this.dispatchEvent(new fs(nt.ADD,e,t))}updateLength_(){this.set(Dl.LENGTH,this.array_.length)}assertUnique_(t,e){for(let i=0,s=this.array_.length;i<s;++i)if(this.array_[i]===t&&i!==e)throw new Error("Duplicate item added to a unique collection")}}let tf=!1;function ef(n,t,e,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,s):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=tf,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const h=t.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(t.readFeatures(c,{extent:e,featureProjection:s}),t.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function Ol(n,t){return function(e,i,s,r,o){ef(n,t,e,i,s,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function nf(n,t){return[[-1/0,-1/0,1/0,1/0]]}class gt extends Yt{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if(typeof t.getSimplifiedGeometry=="function"){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new gt(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());const e=this.getGeometry();e&&t.setGeometry(e.clone());const i=this.getStyle();return i&&t.setStyle(i),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&($(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=z(t,D.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?sf(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function sf(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(it(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}function kl(n,t,e,i){const s=[];let r=kt();for(let o=0,a=e.length;o<a;++o){const l=e[o];r=Os(n,t,l[0],i),s.push((r[0]+r[2])/2,(r[1]+r[3])/2),t=l[l.length-1]}return s}function gs(n,t,e,i,s,r,o){let a,l;const h=(e-t)/i;if(h===1)a=t;else if(h===2)a=t,l=s;else if(h!==0){let c=n[t],u=n[t+1],d=0;const f=[0];for(let _=t+i;_<e;_+=i){const y=n[_],p=n[_+1];d+=Math.sqrt((y-c)*(y-c)+(p-u)*(p-u)),f.push(d),c=y,u=p}const g=s*d,m=Th(f,g);m<0?(l=(g-f[-m-2])/(f[-m-1]-f[-m-2]),a=t+(-m-2)*i):a=t+m*i}o=o>1?o:2,r=r||new Array(o);for(let c=0;c<o;++c)r[c]=a===void 0?NaN:l===void 0?n[a+c]:bt(n[a+c],n[a+i+c],l);return r}function $r(n,t,e,i,s,r){if(e==t)return null;let o;if(s<n[t+i-1])return r?(o=n.slice(t,t+i),o[i-1]=s,o):null;if(n[e-1]<s)return r?(o=n.slice(e-i,e),o[i-1]=s,o):null;if(s==n[t+i-1])return n.slice(t,t+i);let a=t/i,l=e/i;for(;a<l;){const d=a+l>>1;s<n[(d+1)*i-1]?l=d:a=d+1}const h=n[a*i-1];if(s==h)return n.slice((a-1)*i,(a-1)*i+i);const c=n[(a+1)*i-1],u=(s-h)/(c-h);o=[];for(let d=0;d<i-1;++d)o.push(bt(n[(a-1)*i+d],n[a*i+d],u));return o.push(s),o}function rf(n,t,e,i,s,r,o){if(o)return $r(n,t,e[e.length-1],i,s,r);let a;if(s<n[i-1])return r?(a=n.slice(0,i),a[i-1]=s,a):null;if(n[n.length-1]<s)return r?(a=n.slice(n.length-i),a[i-1]=s,a):null;for(let l=0,h=e.length;l<h;++l){const c=e[l];if(t!=c){if(s<n[t+i-1])return null;if(s<=n[c-1])return $r(n,t,c,i,s,!1);t=c}}return null}class _s extends be{constructor(t,e,i){super(),i!==void 0&&e===void 0?this.setFlatCoordinates(i,t):(e=e||0,this.setCenterAndRadius(t,e,i))}clone(){const t=new _s(this.flatCoordinates.slice(),void 0,this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){const r=this.flatCoordinates,o=t-r[0],a=e-r[1],l=o*o+a*a;if(l<s){if(l===0)for(let h=0;h<this.stride;++h)i[h]=r[h];else{const h=this.getRadius()/Math.sqrt(l);i[0]=r[0]+h*o,i[1]=r[1]+h*a;for(let c=2;c<this.stride;++c)i[c]=r[c]}return i.length=this.stride,l}return s}containsXY(t,e){const i=this.flatCoordinates,s=t-i[0],r=e-i[1];return s*s+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(t){const e=this.flatCoordinates,i=e[this.stride]-e[0];return We(e[0]-i,e[1]-i,e[0]+i,e[1]+i,t)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){const t=this.flatCoordinates[this.stride]-this.flatCoordinates[0],e=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return t*t+e*e}getType(){return"Circle"}intersectsExtent(t){const e=this.getExtent();if(_t(t,e)){const i=this.getCenter();return t[0]<=i[0]&&t[2]>=i[0]||t[1]<=i[1]&&t[3]>=i[1]?!0:jo(t,this.intersectsCoordinate.bind(this))}return!1}setCenter(t){const e=this.stride,i=this.flatCoordinates[e]-this.flatCoordinates[0],s=t.slice();s[e]=s[0]+i;for(let r=1;r<e;++r)s[e+r]=t[r];this.setFlatCoordinates(this.layout,s),this.changed()}setCenterAndRadius(t,e,i){this.setLayout(i,t,0),this.flatCoordinates||(this.flatCoordinates=[]);const s=this.flatCoordinates;let r=Cl(s,0,t,this.stride);s[r++]=s[0]+e;for(let o=1,a=this.stride;o<a;++o)s[r++]=s[o];s.length=r,this.changed()}getCoordinates(){return null}setCoordinates(t,e){}setRadius(t){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+t,this.changed()}rotate(t,e){const i=this.getCenter(),s=this.getStride();this.setCenter(Sr(i,0,i.length,s,t,e,i)),this.changed()}}_s.prototype.transform;class mn extends Ya{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach($),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,i=t.length;e<i;++e)this.changeEventsKeys_.push(z(t[e],D.CHANGE,this.changed,this))}clone(){const t=new mn(Jr(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,i,s){if(s<ze(this.getExtent(),t,e))return s;const r=this.geometries_;for(let o=0,a=r.length;o<a;++o)s=r[o].closestPointXY(t,e,i,s);return s}containsXY(t,e){const i=this.geometries_;for(let s=0,r=i.length;s<r;++s)if(i[s].containsXY(t,e))return!0;return!1}computeExtent(t){Ni(t);const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)zo(t,e[i].getExtent());return t}getGeometries(){return Jr(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[];const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)e[i].getType()===this.getType()?t=t.concat(e[i].getGeometriesArrayRecursive()):t.push(e[i]);return t}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=[],i=this.geometries_;let s=!1;for(let r=0,o=i.length;r<o;++r){const a=i[r],l=a.getSimplifiedGeometry(t);e.push(l),l!==a&&(s=!0)}return s?new mn(e):(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getType(){return"GeometryCollection"}intersectsExtent(t){const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)if(e[i].intersectsExtent(t))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(t,e){const i=this.geometries_;for(let s=0,r=i.length;s<r;++s)i[s].rotate(t,e);this.changed()}scale(t,e,i){i||(i=Xt(this.getExtent()));const s=this.geometries_;for(let r=0,o=s.length;r<o;++r)s[r].scale(t,e,i);this.changed()}setGeometries(t){this.setGeometriesArray(Jr(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)e[i].applyTransform(t);this.changed()}translate(t,e){const i=this.geometries_;for(let s=0,r=i.length;s<r;++s)i[s].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function Jr(n){return n.map(t=>t.clone())}class ie extends be{constructor(t,e){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendCoordinate(t){Ot(this.flatCoordinates,t),this.changed()}clone(){const t=new ie(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Gr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,s))}forEachSegment(t){return Il(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){return this.layout!="XYM"&&this.layout!="XYZM"?null:(e=e!==void 0?e:!1,$r(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return Pe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return gs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return Ir(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(t){const e=[];return e.length=Hn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new ie(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return hs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,this.getExtent())}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ls(this.flatCoordinates,0,t,this.stride),this.changed()}}class Ri extends be{constructor(t,e,i){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(e!==void 0&&i)this.setFlatCoordinates(e,t),this.ends_=i;else{const s=t,r=[],o=[];for(let l=0,h=s.length;l<h;++l){const c=s[l];Ot(r,c.getFlatCoordinates()),o.push(r.length)}const a=s.length===0?this.getLayout():s[0].getLayout();this.setFlatCoordinates(a,r),this.ends_=o}}appendLineString(t){Ot(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Ri(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Nr(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zr(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,i,s))}getCoordinateAtM(t,e,i){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(e=e!==void 0?e:!1,i=i!==void 0?i:!1,rf(this.flatCoordinates,0,this.ends_,this.stride,t,e,i))}getCoordinates(){return Ui(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new ie(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){const t=this.flatCoordinates,e=this.ends_,i=this.layout,s=[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o],h=new ie(t.slice(r,l),i);s.push(h),r=l}return s}getLength(){const t=this.ends_;let e=0,i=0;for(let s=0,r=t.length;s<r;++s)i+=Ir(this.flatCoordinates,e,t[s],this.stride),e=t[s];return i}getFlatMidpoints(){const t=[],e=this.flatCoordinates;let i=0;const s=this.ends_,r=this.stride;for(let o=0,a=s.length;o<a;++o){const l=s[o],h=gs(e,i,l,r,.5);Ot(t,h),i=l}return t}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Fa(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,i),new Ri(e,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(t){return Nd(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=gn(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}class yn extends be{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){Ot(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){const t=new yn(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){if(s<ze(this.getExtent(),t,e))return s;const r=this.flatCoordinates,o=this.stride;for(let a=0,l=r.length;a<l;a+=o){const h=le(t,e,r[a],r[a+1]);if(h<s){s=h;for(let c=0;c<o;++c)i[c]=r[a+c];i.length=o}}return s}getCoordinates(){return Pe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new vt(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){const t=this.flatCoordinates,e=this.layout,i=this.stride,s=[];for(let r=0,o=t.length;r<o;r+=i){const a=new vt(t.slice(r,r+i),e);s.push(a)}return s}getType(){return"MultiPoint"}intersectsExtent(t){const e=this.flatCoordinates,i=this.stride;for(let s=0,r=e.length;s<r;s+=i){const o=e[s],a=e[s+1];if(bs(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ls(this.flatCoordinates,0,t,this.stride),this.changed()}}class vi extends be{constructor(t,e,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(t[0])){const s=t,r=[],o=[];for(let a=0,l=s.length;a<l;++a){const h=s[a],c=r.length,u=h.getEnds();for(let d=0,f=u.length;d<f;++d)u[d]+=c;Ot(r,h.getFlatCoordinates()),o.push(u)}e=s.length===0?this.getLayout():s[0].getLayout(),t=r,i=o}e!==void 0&&i?(this.setFlatCoordinates(e,t),this.endss_=i):this.setCoordinates(t,e)}appendPolygon(t){let e;if(!this.flatCoordinates)this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();else{const i=this.flatCoordinates.length;Ot(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let s=0,r=e.length;s<r;++s)e[s]+=i}this.endss_.push(e),this.changed()}clone(){const t=this.endss_.length,e=new Array(t);for(let s=0;s<t;++s)e[s]=this.endss_[s].slice();const i=new vi(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(bd(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Dd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,s))}containsXY(t,e){return kd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return Fd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Br(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,yr(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=kl(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Sl(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new yn(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Tl(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Br(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=qc(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new vi(e,"XY",i)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(t===0)e=0;else{const r=this.endss_[t-1];e=r[r.length-1]}const i=this.endss_[t].slice(),s=i[i.length-1];if(e!==0)for(let r=0,o=i.length;r<o;++r)i[r]-=e;return new qt(this.flatCoordinates.slice(e,s),this.layout,i)}getPolygons(){const t=this.layout,e=this.flatCoordinates,i=this.endss_,s=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o].slice(),h=l[l.length-1];if(r!==0)for(let u=0,d=l.length;u<d;++u)l[u]-=r;const c=new qt(e.slice(r,h),t,l);s.push(c),r=h}return s}getType(){return"MultiPolygon"}intersectsExtent(t){return zd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const i=wl(this.flatCoordinates,0,t,this.stride,this.endss_);if(i.length===0)this.flatCoordinates.length=0;else{const s=i[i.length-1];this.flatCoordinates.length=s.length===0?0:s[s.length-1]}this.changed()}}const Nl=Zt();class Dt{constructor(t,e,i,s,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=r,this.squaredTolerance_,this.stride_=s,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Gi(this.flatCoordinates_):Os(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=Xt(this.getExtent());this.flatInteriorPoints_=jr(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=jd(this.flatCoordinates_,this.ends_),e=kl(this.flatCoordinates_,0,t,2);this.flatInteriorPoints_=Sl(this.flatCoordinates_,0,t,2,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=gs(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const i=this.ends_;for(let s=0,r=i.length;s<r;++s){const o=i[s],a=gs(t,e,o,2,.5);Ot(this.flatMidpoints_,a),e=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=ot(t);const e=t.getExtent(),i=t.getWorldExtent();if(e&&i){const s=dt(i)/dt(e);de(Nl,i[0],i[3],s,-s,0,0,0),Le(this.flatCoordinates_,0,this.flatCoordinates_.length,2,Nl,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){var t;return new Dt(this.type_,this.flatCoordinates_.slice(),(t=this.ends_)==null?void 0:t.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=ma((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=Hn(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=Fa(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,s);break;case"Polygon":s=[],i.length=wr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,s);break}return s&&(this.simplifiedGeometry_=new Dt(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Dt.prototype.getFlatCoordinates=Dt.prototype.getOrientedFlatCoordinates;class ms{constructor(t){this.rbush_=new el(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[X(e)]=i}load(t,e){const i=new Array(e.length);for(let s=0,r=e.length;s<r;s++){const o=t[s],a=e[s],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[s]=l,this.items_[X(a)]=l}this.rbush_.load(i)}remove(t){const e=X(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){const i=this.items_[X(e)],s=[i.minX,i.minY,i.maxX,i.maxY];zi(s,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(s){return s.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let s=0,r=t.length;s<r;s++)if(i=e(t[s]),i)return i;return i}isEmpty(){return Xe(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return We(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(const e in t.items_)this.items_[e]=t.items_[e]}}class Gl extends Yt{constructor(t){super(),this.projection=ot(t.projection),this.attributions_=zl(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(i,s){e.viewResolver=i,e.viewRejector=s})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=zl(t),this.changed()}setState(t){this.state_=t,this.changed()}}function zl(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}const Et={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class Oe extends Mt{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class pn extends Gl{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=Zi,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(it(this.format_,"`format` must be set when `url` is set"),this.loader_=Ol(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:nf;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new ms:null,this.loadedExtentsRtree_=new ms,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(t.features)?s=t.features:t.features&&(i=t.features,s=i.getArray()),!e&&i===void 0&&(i=new xt(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=X(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Oe(Et.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Dt||(this.featureChangeKeys_[t]=[z(e,D.CHANGE,this.handleFeatureChange_,this),z(e,di.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const s=String(e.getId());if(!(s in this.idIndex_))this.idIndex_[s]=e;else if(e instanceof Dt){const r=this.idIndex_[s];r instanceof Dt?Array.isArray(r)?r.push(e):this.idIndex_[s]=[r,e]:i=!1}else i=!1}return i&&(it(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],s=[];for(let r=0,o=t.length;r<o;r++){const a=t[r],l=X(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=X(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();e.push(c),s.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,s),this.hasListener(Et.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new Oe(Et.ADDFEATURE,i[r]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(Et.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(Et.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(nt.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(nt.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach($);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(const i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new Oe(Et.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(s){const r=s.getGeometry();if(r instanceof Dt||r.intersectsCoordinate(t))return e(s)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){const s=i.getGeometry();if(s instanceof Dt||s.intersectsExtent(t)){const r=e(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),Xe(this.nullGeometryFeatures_)||Ot(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const s=Oh(t,e);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],s=t[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return e=e||Bt,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){const c=h.getGeometry(),u=a;if(a=c instanceof Dt?0:c.closestPointXY(i,s,o,a),a<u){r=h;const d=Math.sqrt(a);l[0]=i-d,l[1]=s-d,l[2]=i+d,l[3]=s+d}}}),r}getExtent(t){return this.featuresRtree_.getExtent(t)}getFeatureById(t){const e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,i=X(e),s=e.getGeometry();if(!s)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{const o=s.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}const r=e.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new Oe(Et.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return e!==void 0?e in this.idIndex_:X(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Xe(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){const s=this.loadedExtentsRtree_,r=this.strategy_(t,e,i);for(let o=0,a=r.length;o<a;++o){const l=r[o];s.forEachInExtent(l,function(c){return ae(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Oe(Et.FEATURESLOADSTART)),this.loader_.call(this,l,e,i,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new Oe(Et.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Oe(Et.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(t){const e=this.loadedExtentsRtree_,i=e.forEachInExtent(t,function(s){if(zi(s.extent,t))return s});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,s=t.length;i<s;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=X(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t);const i=this.featureChangeKeys_[e];i==null||i.forEach($),delete this.featureChangeKeys_[e];const s=t.getId();if(s!==void 0){const r=s.toString(),o=this.idIndex_[r];o===t?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[e],this.hasListener(Et.REMOVEFEATURE)&&this.dispatchEvent(new Oe(Et.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(const e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){it(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(Ol(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}}const B={SINGLECLICK:"singleclick",CLICK:D.CLICK,DBLCLICK:D.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},ys={ACTIVE:"active"};class Ti extends Yt{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(ys.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(ys.ACTIVE,t)}setMap(t){this.map_=t}}function of(n,t,e){const i=n.getCenterInternal();if(i){const s=[i[0]+t[0],i[1]+t[1]];n.animateInternal({duration:e!==void 0?e:250,easing:Ad,center:n.getConstrainedCenter(s)})}}function Qr(n,t,e,i){const s=n.getZoom();if(s===void 0)return;const r=n.getConstrainedZoom(s+t),o=n.getResolutionForZoom(r);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:e,duration:i!==void 0?i:250,easing:Si})}class af extends Ti{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:250}handleEvent(t){let e=!1;if(t.type==B.DBLCLICK){const i=t.originalEvent,s=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=s.getView();Qr(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}function to(n){const t=arguments;return function(e){let i=!0;for(let s=0,r=t.length;s<r&&(i=i&&t[s](e),!!i);++s);return i}}const lf=function(n){const t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},hf=function(n){const t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},cf=function(n){const t=n.map.getTargetElement(),e=t.getRootNode(),i=n.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},Wl=function(n){const t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?cf(n):!0},xn=Bt,uf=function(n){return n.type==B.CLICK},jl=function(n){const t=n.originalEvent;return"pointerId"in t&&t.button==0&&!(Xh&&Xs&&t.ctrlKey)},eo=Ye,Vl=function(n){return n.type==B.SINGLECLICK},io=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},df=function(n){const t=n.originalEvent;return!t.altKey&&(Xs?t.metaKey:t.ctrlKey)&&!t.shiftKey},ff=function(n){const t=n.originalEvent;return Xs?t.metaKey:t.ctrlKey},no=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Xl=function(n){const t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},so=function(n){const t=n.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"},Bl=function(n){const t=n.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};class gf extends fr{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,i="px",s=this.element_.style;s.left=Math.min(t[0],e[0])+i,s.top=Math.min(t[1],e[1])+i,s.width=Math.abs(e[0]-t[0])+i,s.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const e=this.element_.style;e.left="inherit",e.top="inherit",e.width="inherit",e.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const t=this.startPixel_,e=this.endPixel_,s=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);s[4]=s[0].slice(),this.geometry_?this.geometry_.setCoordinates([s]):this.geometry_=new qt([s])}getGeometry(){return this.geometry_}}class ye extends Ti{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==B.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==B.POINTERUP){const i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==B.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==B.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}}function ro(n){const t=n.length;let e=0,i=0;for(let s=0;s<t;s++)e+=n[s].clientX,i+=n[s].clientY;return{clientX:e/t,clientY:i/t}}const Pi={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class En extends Mt{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class _f extends ye{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new gf(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??jl,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const s=i[0]-e[0],r=i[1]-e[1];return s*s+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new En(Pi.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new En(e?Pi.BOXEND:Pi.BOXCANCEL,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return this.condition_(t)?(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new En(Pi.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new En(Pi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new En(Pi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class mf extends ye{constructor(t){super({stopDown:Ye}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:to(io,Bl);this.condition_=t.onFocusOnly?to(Wl,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const i=this.targetPointers,s=e.getEventPixel(ro(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(s[0],s[1]),this.lastCentroid){const r=[this.lastCentroid[0]-s[0],s[1]-this.lastCentroid[1]],a=t.map.getView();Wh(r,a.getResolution()),Vs(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=s,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const s=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-s*Math.cos(r),a[1]-s*Math.sin(r)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:Si})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){const i=t.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class yf extends ye{constructor(t){t=t||{},super({stopDown:Ye}),this.condition_=t.condition?t.condition:hf,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!so(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===Kr)return;const s=e.getSize(),r=t.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(t){return so(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return so(t)&&jl(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class pf extends _f{constructor(t){t=t||{};const e=t.condition?t.condition:no;super({condition:e,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=t.duration!==void 0?t.duration:200,this.out_=t.out!==void 0?t.out:!1}onBoxEnd(t){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:Si})}}class Mi extends Mt{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}}class pe extends Mi{constructor(t,e,i,s,r,o){super(t,e,r),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=s!==void 0?s:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const ps={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class xs extends Mt{constructor(t,e){super(t),this.feature=e}}function xf(n,t){const e=[];for(let i=0;i<t.length;++i){const r=t[i].getGeometry();Yl(n,r,e)}return e}function Es(n,t){return le(n[0],n[1],t[0],t[1])}function Li(n,t){const e=n.length;return t<0?n[t+e]:t>=e?n[t-e]:n[t]}function Cs(n,t,e){let i,s;t<e?(i=t,s=e):(i=e,s=t);const r=Math.ceil(i),o=Math.floor(s);if(r>o){const l=Ai(n,i),h=Ai(n,s);return Es(l,h)}let a=0;if(i<r){const l=Ai(n,i),h=Li(n,r);a+=Es(l,h)}if(o<s){const l=Li(n,o),h=Ai(n,s);a+=Es(l,h)}for(let l=r;l<o-1;++l){const h=Li(n,l),c=Li(n,l+1);a+=Es(h,c)}return a}function Yl(n,t,e){if(t instanceof ie){ws(n,t.getCoordinates(),!1,e);return}if(t instanceof Ri){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s)ws(n,i[s],!1,e);return}if(t instanceof qt){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s)ws(n,i[s],!0,e);return}if(t instanceof vi){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length;a<l;++a)ws(n,o[a],!0,e)}return}if(t instanceof mn){const i=t.getGeometries();for(let s=0;s<i.length;++s)Yl(n,i[s],e);return}}const oo={index:-1,endIndex:NaN};function Ef(n,t,e,i){const s=n[0],r=n[1];let o=1/0,a=-1,l=NaN;for(let u=0;u<t.targets.length;++u){const d=t.targets[u],f=d.coordinates;let g=1/0,m;for(let _=0;_<f.length-1;++_){const y=f[_],p=f[_+1],E=Zl(s,r,y,p);E.squaredDistance<g&&(g=E.squaredDistance,m=_+E.along)}g<o&&(o=g,d.ring&&t.targetIndex===u&&(d.endIndex>d.startIndex?m<d.startIndex&&(m+=f.length):d.endIndex<d.startIndex&&m>d.startIndex&&(m-=f.length)),l=m,a=u)}const h=t.targets[a];let c=h.ring;if(t.targetIndex===a&&c){const u=Ai(h.coordinates,l),d=e.getPixelFromCoordinate(u);Dn(d,t.startPx)>i&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(f<g){const m=Cs(u,f,g);Cs(u,f,g-d)<m&&(l-=d)}else{const m=Cs(u,f,g);Cs(u,f,g+d)<m&&(l+=d)}}return oo.index=a,oo.endIndex=l,oo}function ws(n,t,e,i){const s=n[0],r=n[1];for(let o=0,a=t.length-1;o<a;++o){const l=t[o],h=t[o+1],c=Zl(s,r,l,h);if(c.squaredDistance===0){const u=o+c.along;i.push({coordinates:t,ring:e,startIndex:u,endIndex:u});return}}}const ao={along:0,squaredDistance:0};function Zl(n,t,e,i){const s=e[0],r=e[1],o=i[0],a=i[1],l=o-s,h=a-r;let c=0,u=s,d=r;return(l!==0||h!==0)&&(c=rt(((n-s)*l+(t-r)*h)/(l*l+h*h),0,1),u+=l*c,d+=h*c),ao.along=c,ao.squaredDistance=Fn(le(n,t,u,d),10),ao}function Ai(n,t){const e=n.length;let i=Math.floor(t);const s=t-i;i>=e?i-=e:i<0&&(i+=e);let r=i+1;r>=e&&(r-=e);const o=n[i],a=o[0],l=o[1],h=n[r],c=h[0]-a,u=h[1]-l;return[a+c*s,l+u*s]}class Cf extends ye{constructor(t){const e=t;e.stopDown||(e.stopDown=Ye),super(e),this.on,this.once,this.un,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=t.source?t.source:null,this.features_=t.features?t.features:null,this.snapTolerance_=t.snapTolerance?t.snapTolerance:12,this.type_=t.type,this.mode_=Sf(this.type_),this.stopClick_=!!t.stopClick,this.minPoints_=t.minPoints?t.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:t.maxPoints?t.maxPoints:1/0,this.finishCondition_=t.finishCondition?t.finishCondition:Bt,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let i=t.geometryFunction;if(!i){const s=this.mode_;if(s==="Circle")i=(r,o,a)=>{const l=o||new _s([NaN,NaN]),h=U(r[0]),c=he(h,U(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;s==="Point"?r=vt:s==="LineString"?r=ie:s==="Polygon"&&(r=qt),i=(o,a,l)=>(a?s==="Polygon"?o[0].length?a.setCoordinates([o[0].concat([o[0][0]])],this.geometryLayout_):a.setCoordinates([],this.geometryLayout_):a.setCoordinates(o,this.geometryLayout_):a=new r(o,this.geometryLayout_),a)}}this.geometryFunction_=i,this.dragVertexDelay_=t.dragVertexDelay!==void 0?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new Ii({source:new pn({useSpatialIndex:!1,wrapX:t.wrapX?t.wrapX:!1}),style:t.style?t.style:wf(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:io,this.freehandCondition_,t.freehand?this.freehandCondition_=xn:this.freehandCondition_=t.freehandCondition?t.freehandCondition:no,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(ys.ACTIVE,this.updateState_)}setTrace(t){let e;t?t===!0?e=xn:e=t:e=eo,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}getOverlay(){return this.overlay_}handleEvent(t){t.originalEvent.type===D.CONTEXTMENU&&t.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(t);let e=t.type===B.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&t.type===B.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&t.type===B.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===B.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===B.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):(t.originalEvent.pointerType==="mouse"||t.type===B.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(t)):t.type===B.DBLCLICK&&(i=!1),super.handleEvent(t)&&i}handleDownEvent(t){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=t.pixel,this.finishCoordinate_||this.startDrawing_(t.coordinate),!0):this.condition_(t)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new pe(B.POINTERMOVE,t.map,t.originalEvent,!1,t.frameState))},this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active){this.deactivateTrace_();return}const e=this.getMap(),i=e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),s=e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_]),r=ut([i,s]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=xf(t.coordinate,o);a.length&&(this.traceState_={active:!0,startPx:t.pixel.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const i=t.startIndex<=t.endIndex,s=t.startIndex<=e;i===s?i&&e>t.endIndex||!i&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(i&&e<t.endIndex||!i&&e>t.endIndex)&&this.removeTracedCoordinates_(e,t.endIndex):(this.removeTracedCoordinates_(t.startIndex,t.endIndex),this.addTracedCoordinates_(t,t.startIndex,e))}removeTracedCoordinates_(t,e){if(t===e)return;let i=0;if(t<e){const s=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),i=r-s+1}else{const s=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),i=s-r+1}i>0&&this.removeLastPoints_(i)}addTracedCoordinates_(t,e,i){if(e===i)return;const s=[];if(e<i){const r=Math.ceil(e);let o=Math.floor(i);o===i&&(o-=1);for(let a=r;a<=o;++a)s.push(Li(t.coordinates,a))}else{const r=Math.floor(e);let o=Math.ceil(i);o===i&&(o+=1);for(let a=r;a>=o;--a)s.push(Li(t.coordinates,a))}s.length&&this.appendCoordinates(s)}updateTrace_(t){const e=this.traceState_;if(!e.active||e.targetIndex===-1&&Dn(e.startPx,t.pixel)<this.snapTolerance_)return;const i=Ef(t.coordinate,e,this.getMap(),this.snapTolerance_);if(e.targetIndex!==i.index){if(e.targetIndex!==-1){const l=e.targets[e.targetIndex];this.removeTracedCoordinates_(l.startIndex,l.endIndex)}const a=e.targets[i.index];this.addTracedCoordinates_(a,a.startIndex,i.endIndex)}else{const a=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(a,i.endIndex)}e.targetIndex=i.index;const s=e.targets[e.targetIndex];s.endIndex=i.endIndex;const r=Ai(s.coordinates,s.endIndex),o=this.getMap().getPixelFromCoordinate(r);t.coordinate=r,t.pixel=[Math.round(o[0]),Math.round(o[1])]}handleUpEvent(t){let e=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(t);const i=this.traceState_.active;if(this.toggleTraceState_(t),this.shouldHandle_){const s=!this.finishCoordinate_;s&&this.startDrawing_(t.coordinate),!s&&this.freehand_?this.finishDrawing():!this.freehand_&&(!s||this.mode_==="Point")&&(this.atFinish_(t.pixel,i)?this.finishCondition_(t)&&this.finishDrawing():this.addToDrawing_(t.coordinate)),e=!1}else this.freehand_&&this.abortDrawing()}return!e&&this.stopClick_&&t.preventDefault(),e}handlePointerMove_(t){if(this.pointerType_=t.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const e=this.downPx_,i=t.pixel,s=e[0]-i[0],r=e[1]-i[1],o=s*s+r*r;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(t.coordinate.slice());return}this.updateTrace_(t),this.modifyDrawing_(t.coordinate)}atFinish_(t,e){let i=!1;if(this.sketchFeature_){let s=!1,r=[this.finishCoordinate_];const o=this.mode_;if(o==="Point")i=!0;else if(o==="Circle")i=this.sketchCoords_.length===2;else if(o==="LineString")s=!e&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){const a=this.sketchCoords_;s=a[0].length>this.minPoints_,r=[a[0][0],a[0][a[0].length-2]],e?r=[a[0][0]]:r=[a[0][0],a[0][a[0].length-2]]}if(s){const a=this.getMap();for(let l=0,h=r.length;l<h;l++){const c=r[l],u=a.getPixelFromCoordinate(c),d=t[0]-u[0],f=t[1]-u[1],g=this.freehand_?1:this.snapTolerance_;if(i=Math.sqrt(d*d+f*f)<=g,i){this.finishCoordinate_=c;break}}}}return i}createOrUpdateSketchPoint_(t){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(t):(this.sketchPoint_=new gt(new vt(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new gt);const e=t.getLinearRing(0);let i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),i.changed()):(i=new ie(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(t){const e=this.getMap().getView().getProjection(),i=ts(this.geometryLayout_);for(;t.length<i;)t.push(0);this.finishCoordinate_=t,this.mode_==="Point"?this.sketchCoords_=t.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[t.slice(),t.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[t.slice(),t.slice()],this.sketchLineCoords_&&(this.sketchLine_=new gt(new ie(this.sketchLineCoords_)));const s=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new gt,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(s),this.updateSketchFeatures_(),this.dispatchEvent(new xs(ps.DRAWSTART,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),i=this.sketchFeature_.getGeometry(),s=e.getView().getProjection(),r=ts(this.geometryLayout_);let o,a;for(;t.length<r;)t.push(0);this.mode_==="Point"?a=this.sketchCoords_:this.mode_==="Polygon"?(o=this.sketchCoords_[0],a=o[o.length-1],this.atFinish_(e.getPixelFromCoordinate(t))&&(t=this.finishCoordinate_.slice())):(o=this.sketchCoords_,a=o[o.length-1]),a[0]=t[0],a[1]=t[1],this.geometryFunction_(this.sketchCoords_,i,s),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(t),i.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(i):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(t){const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection();let s,r;const o=this.mode_;return o==="LineString"||o==="Circle"?(this.finishCoordinate_=t.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():s=!0),r.push(t.slice()),this.geometryFunction_(r,e,i)):o==="Polygon"&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():s=!0),r.push(t.slice()),s&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,i)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),s?this.finishDrawing():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),s=this.mode_;for(let r=0;r<t;++r){let o;if(s==="LineString"||s==="Circle"){if(o=this.sketchCoords_,o.splice(-2,1),o.length>=2){this.finishCoordinate_=o[o.length-2].slice();const a=this.finishCoordinate_.slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}this.geometryFunction_(o,e,i),e.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if(s==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);const a=this.sketchLine_.getGeometry();if(o.length>=2){const l=o[o.length-2].slice();o[o.length-1]=l,this.createOrUpdateSketchPoint_(l)}a.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,e,i)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return null;let e=this.sketchCoords_;const i=t.getGeometry(),s=this.getMap().getView().getProjection();return this.mode_==="LineString"?(e.pop(),this.geometryFunction_(e,i,s)):this.mode_==="Polygon"&&(e[0].pop(),this.geometryFunction_(e,i,s),e=i.getCoordinates()),this.type_==="MultiPoint"?t.setGeometry(new yn([e])):this.type_==="MultiLineString"?t.setGeometry(new Ri([e])):this.type_==="MultiPolygon"&&t.setGeometry(new vi([e])),this.dispatchEvent(new xs(ps.DRAWEND,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t),t}abortDrawing_(){this.finishCoordinate_=null;const t=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),t}abortDrawing(){const t=this.abortDrawing_();t&&this.dispatchEvent(new xs(ps.DRAWABORT,t))}appendCoordinates(t){const e=this.mode_,i=!this.sketchFeature_;i&&this.startDrawing_(t[0]);let s;if(e==="LineString"||e==="Circle")s=this.sketchCoords_;else if(e==="Polygon")s=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;i&&s.shift(),s.pop();for(let o=0;o<t.length;o++)this.addToDrawing_(t[o]);const r=t[t.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(t){const i=t.getGeometry();this.sketchFeature_=t,this.sketchCoords_=i.getCoordinates();const s=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=s.slice(),this.sketchCoords_.push(s.slice()),this.sketchPoint_=new gt(new vt(s)),this.updateSketchFeatures_(),this.dispatchEvent(new xs(ps.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){const t=[];this.sketchFeature_&&t.push(this.sketchFeature_),this.sketchLine_&&t.push(this.sketchLine_),this.sketchPoint_&&t.push(this.sketchPoint_);const e=this.overlay_.getSource();e.clear(!0),e.addFeatures(t)}updateState_(){const t=this.getMap(),e=this.getActive();(!t||!e)&&this.abortDrawing(),this.overlay_.setMap(e?t:null)}}function wf(){const n=Pr();return function(t,e){return n[t.getGeometry().getType()]}}function Sf(n){switch(n){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+n)}}const ei={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class If extends Ti{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return io(e)&&Xl(e)},this.condition_=t.condition!==void 0?t.condition:this.defaultCondition_,this.duration_=t.duration!==void 0?t.duration:100,this.pixelDelta_=t.pixelDelta!==void 0?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==D.KEYDOWN){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==ei.DOWN||s==ei.LEFT||s==ei.RIGHT||s==ei.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;s==ei.DOWN?h=-a:s==ei.LEFT?l=-a:s==ei.RIGHT?l=a:h=a;const c=[l,h];Vs(c,o.getRotation()),of(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}}class Rf extends Ti{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!ff(e)&&Xl(e)},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:100}handleEvent(t){let e=!1;if(t.type==D.KEYDOWN||t.type==D.KEYPRESS){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==="+"||s==="-")){const r=t.map,o=s==="+"?this.delta_:-this.delta_,a=r.getView();Qr(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}const xe={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Kl=0,Cn=1,Ul=[0,0,0,0],Fi=[],lo={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"};class ho extends Mt{constructor(t,e,i){super(t),this.features=e,this.mapBrowserEvent=i}}class vf extends ye{constructor(t){super(t),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=t.condition?t.condition:Bl,this.defaultDeleteCondition_=function(i){return lf(i)&&Vl(i)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:xn,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new ms,this.pixelTolerance_=t.pixelTolerance!==void 0?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Ii({source:new pn({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:Pf(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let e;if(t.features?e=t.features:t.source&&(this.source_=t.source,e=new xt(this.source_.getFeatures()),this.source_.addEventListener(Et.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Et.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!e)throw new Error("The modify interaction requires features, a source or a layer");t.hitDetection&&(this.hitDetection_=t.hitDetection),this.features_=e,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(nt.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(nt.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=t.snapToPointer===void 0?!this.hitDetection_:t.snapToPointer}addFeature_(t){const e=t.getGeometry();if(e){const s=this.SEGMENT_WRITERS_[e.getType()];s&&s(t,e)}const i=this.getMap();i&&i.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(i.getCoordinateFromPixel(this.lastPixel_)),t.addEventListener(D.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(t,e){if(!this.featuresBeingModified_){this.featuresBeingModified_=new xt;const i=this.featuresBeingModified_.getArray();for(let s=0,r=e.length;s<r;++s){const o=e[s].feature;o&&!i.includes(o)&&this.featuresBeingModified_.push(o)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new ho(lo.MODIFYSTART,this.featuresBeingModified_,t))}}removeFeature_(t){this.removeFeatureSegmentData_(t),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.removeEventListener(D.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(t){const e=this.rBush_,i=[];e.forEach(function(s){t===s.feature&&i.push(s)});for(let s=i.length-1;s>=0;--s){const r=i[s];for(let o=this.dragSegments_.length-1;o>=0;--o)this.dragSegments_[o][0]===r&&this.dragSegments_.splice(o,1);e.remove(r)}}setActive(t){this.vertexFeature_&&!t&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(t)}setMap(t){this.overlay_.setMap(t),super.setMap(t)}getOverlay(){return this.overlay_}handleSourceAdd_(t){t.feature&&this.features_.push(t.feature)}handleSourceRemove_(t){t.feature&&this.features_.remove(t.feature)}handleFeatureAdd_(t){this.addFeature_(t.element)}handleFeatureChange_(t){if(!this.changingFeature_){const e=t.target;this.removeFeature_(e),this.addFeature_(e)}}handleFeatureRemove_(t){this.removeFeature_(t.element)}writePointGeometry_(t,e){const i=e.getCoordinates(),s={feature:t,geometry:e,segment:[i,i]};this.rBush_.insert(e.getExtent(),s)}writeMultiPointGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s],a={feature:t,geometry:e,depth:[s],index:s,segment:[o,o]};this.rBush_.insert(e.getExtent(),a)}}writeLineStringGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length-1;s<r;++s){const o=i.slice(s,s+2),a={feature:t,geometry:e,index:s,segment:o};this.rBush_.insert(ut(o),a)}}writeMultiLineStringGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:t,geometry:e,depth:[s],index:a,segment:h};this.rBush_.insert(ut(h),c)}}}writePolygonGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:t,geometry:e,depth:[s],index:a,segment:h};this.rBush_.insert(ut(h),c)}}}writeMultiPolygonGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length;a<l;++a){const h=o[a];for(let c=0,u=h.length-1;c<u;++c){const d=h.slice(c,c+2),f={feature:t,geometry:e,depth:[a,s],index:c,segment:d};this.rBush_.insert(ut(d),f)}}}}writeCircleGeometry_(t,e){const i=e.getCenter(),s={feature:t,geometry:e,index:Kl,segment:[i,i]},r={feature:t,geometry:e,index:Cn,segment:[i,i]},o=[s,r];s.featureSegments=o,r.featureSegments=o,this.rBush_.insert(Gi(i),s);let a=e;this.rBush_.insert(a.getExtent(),r)}writeGeometryCollectionGeometry_(t,e){const i=e.getGeometriesArray();for(let s=0;s<i.length;++s){const r=i[s],o=this.SEGMENT_WRITERS_[r.getType()];o(t,r)}}createOrUpdateVertexFeature_(t,e,i,s){let r=this.vertexFeature_;return r?r.getGeometry().setCoordinates(t):(r=new gt(new vt(t)),this.vertexFeature_=r,this.overlay_.getSource().addFeature(r)),r.set("features",e),r.set("geometries",i),r.set("existing",s),r}handleEvent(t){if(!t.originalEvent)return!0;this.lastPointerEvent_=t;let e;return!t.map.getView().getInteracting()&&t.type==B.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(t.type!=B.SINGLECLICK||!this.ignoreNextSingleClick_?e=this.removePoint():e=!0),t.type==B.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(t)&&!e}findInsertVerticesAndUpdateDragSegments_(t){this.handlePointerAtPixel_(t),this.dragSegments_.length=0,this.featuresBeingModified_=null;const e=this.vertexFeature_;if(!e)return;this.getMap().getView().getProjection();const i=[],s=e.getGeometry().getCoordinates(),r=ut([s]),o=this.rBush_.getInExtent(r),a={};o.sort(Tf);for(let l=0,h=o.length;l<h;++l){const c=o[l],u=c.segment;let d=X(c.geometry);const f=c.depth;if(f&&(d+="-"+f.join("-")),a[d]||(a[d]=new Array(2)),c.geometry.getType()==="Circle"&&c.index===Cn){const g=ql(t,c);It(g,s)&&!a[d][0]&&(this.dragSegments_.push([c,0]),a[d][0]=c);continue}if(It(u[0],s)&&!a[d][0]){this.dragSegments_.push([c,0]),a[d][0]=c;continue}if(It(u[1],s)&&!a[d][1]){if(a[d][0]&&a[d][0].index===0){let g=c.geometry.getCoordinates();switch(c.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":g=g[f[1]];case"Polygon":if(c.index!==g[f[0]].length-2)continue;break}}this.dragSegments_.push([c,1]),a[d][1]=c;continue}X(u)in this.vertexSegments_&&!a[d][0]&&!a[d][1]&&i.push(c)}return i}handleDragEvent(t){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(t,this.dragSegments_.map(([r])=>r));const e=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],i=[],s=[];for(let r=0,o=this.dragSegments_.length;r<o;++r){const a=this.dragSegments_[r],l=a[0],h=l.feature;i.includes(h)||i.push(h);const c=l.geometry;s.includes(c)||s.push(c);const u=l.depth;let d;const f=l.segment,g=a[1];for(;e.length<c.getStride();)e.push(f[g][e.length]);switch(c.getType()){case"Point":d=e,f[0]=e,f[1]=e;break;case"MultiPoint":d=c.getCoordinates(),d[l.index]=e,f[0]=e,f[1]=e;break;case"LineString":d=c.getCoordinates(),d[l.index+g]=e,f[g]=e;break;case"MultiLineString":d=c.getCoordinates(),d[u[0]][l.index+g]=e,f[g]=e;break;case"Polygon":d=c.getCoordinates(),d[u[0]][l.index+g]=e,f[g]=e;break;case"MultiPolygon":d=c.getCoordinates(),d[u[1]][u[0]][l.index+g]=e,f[g]=e;break;case"Circle":const m=c;if(f[0]=e,f[1]=e,l.index===Kl)this.changingFeature_=!0,m.setCenter(e),this.changingFeature_=!1;else{this.changingFeature_=!0,t.map.getView().getProjection();let _=Dn(U(m.getCenter()),U(e));m.setRadius(_),this.changingFeature_=!1}break}d&&this.setGeometryCoordinates_(c,d)}this.createOrUpdateVertexFeature_(e,i,s,!0)}handleDownEvent(t){if(!this.condition_(t))return!1;const e=t.coordinate,i=this.findInsertVerticesAndUpdateDragSegments_(e);if(i!=null&&i.length&&this.insertVertexCondition_(t)&&(this.willModifyFeatures_(t,i),this.vertexFeature_)){const s=this.vertexFeature_.getGeometry().getCoordinates();for(let r=i.length-1;r>=0;--r)this.insertVertex_(i[r],s);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(t){for(let e=this.dragSegments_.length-1;e>=0;--e){const i=this.dragSegments_[e][0],s=i.geometry;if(s.getType()==="Circle"){const r=s,o=r.getCenter(),a=i.featureSegments[0],l=i.featureSegments[1];a.segment[0]=o,a.segment[1]=o,l.segment[0]=o,l.segment[1]=o,this.rBush_.update(Gi(o),a);let h=r;this.rBush_.update(h.getExtent(),l)}else this.rBush_.update(ut(i.segment),i)}return this.featuresBeingModified_&&(this.dispatchEvent(new ho(lo.MODIFYEND,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastPixel_=t.pixel,this.handlePointerAtPixel_(t.coordinate)}handlePointerAtPixel_(t){const e=this.getMap(),i=e.getPixelFromCoordinate(t);e.getView().getProjection();const s=function(a,l){return Hl(t,a)-Hl(t,l)};let r,o;if(this.hitDetection_){const a=typeof this.hitDetection_=="object"?l=>l===this.hitDetection_:void 0;e.forEachFeatureAtPixel(i,(l,h,c)=>{c&&c.getType()==="Point"&&(c=new vt(ve(c.getCoordinates())));const u=c||l.getGeometry();if(u&&u.getType()==="Point"&&l instanceof gt&&this.features_.getArray().includes(l)){o=u;const d=l.getGeometry().getFlatCoordinates().slice(0,2);r=[{feature:l,geometry:o,segment:[d,d]}]}return!0},{layerFilter:a})}if(!r){const a=Te(Gi(t,Ul)),l=e.getView().getResolution()*this.pixelTolerance_,h=Vn(Oi(a,l,Ul));r=this.rBush_.getInExtent(h)}if(r&&r.length>0){const a=r.sort(s)[0],l=a.segment;let h=ql(t,a);const c=e.getPixelFromCoordinate(h);let u=Dn(i,c);if(o||u<=this.pixelTolerance_){const d={};if(d[X(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-t[0],this.delta_[1]=h[1]-t[1]),a.geometry.getType()==="Circle"&&a.index===Cn)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const f=e.getPixelFromCoordinate(l[0]),g=e.getPixelFromCoordinate(l[1]),m=he(c,f),_=he(c,g);if(u=Math.sqrt(Math.min(m,_)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_)){this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null);return}this.snappedToVertex_&&(h=m>_?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const y={};y[X(a.geometry)]=!0;for(let p=1,E=r.length;p<E;++p){const x=r[p].segment;if(It(l[0],x[0])&&It(l[1],x[1])||It(l[0],x[1])&&It(l[1],x[0])){const C=X(r[p].geometry);C in y||(y[C]=!0,d[X(x)]=!0)}else break}}this.vertexSegments_=d;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(t,e){const i=t.segment,s=t.feature,r=t.geometry,o=t.depth,a=t.index;let l;for(;e.length<r.getStride();)e.push(0);switch(r.getType()){case"MultiLineString":l=r.getCoordinates(),l[o[0]].splice(a+1,0,e);break;case"Polygon":l=r.getCoordinates(),l[o[0]].splice(a+1,0,e);break;case"MultiPolygon":l=r.getCoordinates(),l[o[1]][o[0]].splice(a+1,0,e);break;case"LineString":l=r.getCoordinates(),l.splice(a+1,0,e);break;default:return!1}this.setGeometryCoordinates_(r,l);const h=this.rBush_;h.remove(t),this.updateSegmentIndices_(r,a,o,1);const c={segment:[i[0],e],feature:s,geometry:r,depth:o,index:a};h.insert(ut(c.segment),c),this.dragSegments_.push([c,1]);const u={segment:[e,i[1]],feature:s,geometry:r,depth:o,index:a+1};return h.insert(ut(u.segment),u),this.dragSegments_.push([u,0]),!0}updatePointer_(t){var e;return t&&this.findInsertVerticesAndUpdateDragSegments_(t),(e=this.vertexFeature_)==null?void 0:e.getGeometry().getCoordinates()}getPoint(){var e;const t=(e=this.vertexFeature_)==null?void 0:e.getGeometry().getCoordinates();return t?ve(t,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(i=>i.getType()==="Circle"||i.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ut([t])).some(({segment:i})=>It(i[0],t)||It(i[1],t))}removePoint(t){if(t&&(t=U(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=B.POINTERDRAG){const e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_.map(([s])=>s));const i=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new ho(lo.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null,i}return!1}removeVertex_(){const t=this.dragSegments_,e={};let i=!1,s,r,o,a,l,h,c,u,d,f,g;for(l=t.length-1;l>=0;--l)o=t[l],f=o[0],g=X(f.feature),f.depth&&(g+="-"+f.depth.join("-")),g in e||(e[g]={}),o[1]===0?(e[g].right=f,e[g].index=f.index):o[1]==1&&(e[g].left=f,e[g].index=f.index+1);for(g in e){switch(d=e[g].right,c=e[g].left,h=e[g].index,u=h-1,c!==void 0?f=c:f=d,u<0&&(u=0),a=f.geometry,r=a.getCoordinates(),s=r,i=!1,a.getType()){case"MultiLineString":r[f.depth[0]].length>2&&(r[f.depth[0]].splice(h,1),i=!0);break;case"LineString":r.length>2&&(r.splice(h,1),i=!0);break;case"MultiPolygon":s=s[f.depth[1]];case"Polygon":s=s[f.depth[0]],s.length>4&&(h==s.length-1&&(h=0),s.splice(h,1),i=!0,h===0&&(s.pop(),s.push(s[0]),u=s.length-1));break}if(i){this.setGeometryCoordinates_(a,r);const m=[];if(c!==void 0&&(this.rBush_.remove(c),m.push(c.segment[0])),d!==void 0&&(this.rBush_.remove(d),m.push(d.segment[1])),c!==void 0&&d!==void 0){const _={depth:f.depth,feature:f.feature,geometry:f.geometry,index:u,segment:m};this.rBush_.insert(ut(_.segment),_)}this.updateSegmentIndices_(a,h,f.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return i}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(i=>i.getType()==="Circle"||i.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ut([t])).some(({segment:i})=>!(It(i[0],t)||It(i[1],t)))}insertPoint(t){var s;const e=t?U(t,this.getMap().getView().getProjection()):(s=this.vertexFeature_)==null?void 0:s.getGeometry().getCoordinates();return e?this.findInsertVerticesAndUpdateDragSegments_(e).reduce((r,o)=>r||this.insertVertex_(o,e),!1):!1}setGeometryCoordinates_(t,e){this.changingFeature_=!0,t.setCoordinates(e),this.changingFeature_=!1}updateSegmentIndices_(t,e,i,s){this.rBush_.forEachInExtent(t.getExtent(),function(r){r.geometry===t&&(i===void 0||r.depth===void 0||oe(r.depth,i))&&r.index>e&&(r.index+=s)})}}function Tf(n,t){return n.index-t.index}function Hl(n,t,e){const i=t.geometry;if(i.getType()==="Circle"){let r=i;if(t.index===Cn){const o=he(r.getCenter(),U(n)),a=Math.sqrt(o)-r.getRadius();return a*a}}const s=U(n);return Fi[0]=U(t.segment[0]),Fi[1]=U(t.segment[1]),jh(s,Fi)}function ql(n,t,e){const i=t.geometry;if(i.getType()==="Circle"&&t.index===Cn)return ve(i.getClosestPoint(U(n)));const s=U(n);return Fi[0]=U(t.segment[0]),Fi[1]=U(t.segment[1]),ve(js(s,Fi))}function Pf(){const n=Pr();return function(t,e){return n.Point}}const Mf=40,Lf=300;class Af extends Ti{constructor(t){t=t||{},super(t),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=t.maxDelta!==void 0?t.maxDelta:1,this.duration_=t.duration!==void 0?t.duration:250,this.timeout_=t.timeout!==void 0?t.timeout:80,this.useAnchor_=t.useAnchor!==void 0?t.useAnchor:!0,this.constrainResolution_=t.constrainResolution!==void 0?t.constrainResolution:!1;const e=t.condition?t.condition:xn;this.condition_=t.onFocusOnly?to(Wl,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;t.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t)||t.type!==D.WHEEL)return!0;const i=t.map,s=t.originalEvent;s.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel);let r=s.deltaY;switch(s.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=Mf;break;case WheelEvent.DOM_DELTA_PAGE:r*=Lf;break}if(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_?i.getCoordinateFromPixel(this.lastAnchor_):null),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_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-rt(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Qr(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}}class Ff extends ye{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Ye),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=t.threshold!==void 0?t.threshold:.3,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){let e=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),e=l}this.lastAngle_=r;const o=t.map,a=o.getView();a.getConstraints().rotation!==Kr&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(ro(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return this.targetPointers.length<2?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}class bf extends ye{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Ye),super(e),this.anchor_=null,this.duration_=t.duration!==void 0?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=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&&(e=this.lastDistance_/a),this.lastDistance_=a;const l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(ro(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const i=t.map.getView(),s=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,s),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}const Df={SELECT:"select"};class Of extends Mt{constructor(t,e,i,s){super(t),this.selected=e,this.deselected=i,this.mapBrowserEvent=s}}const Ss={};class co extends Ti{constructor(t){super(),this.on,this.once,this.un,t=t||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=t.condition?t.condition:Vl,this.addCondition_=t.addCondition?t.addCondition:eo,this.removeCondition_=t.removeCondition?t.removeCondition:eo,this.toggleCondition_=t.toggleCondition?t.toggleCondition:no,this.multi_=t.multi?t.multi:!1,this.filter_=t.filter?t.filter:Bt,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.style_=t.style!==void 0?t.style:kf(),this.features_=t.features||new xt;let e;if(t.layers)if(typeof t.layers=="function")e=t.layers;else{const i=t.layers;e=function(s){return i.includes(s)}}else e=Bt;this.layerFilter_=e,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(t,e){this.featureLayerAssociation_[X(t)]=e}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(t){return this.featureLayerAssociation_[X(t)]}setHitTolerance(t){this.hitTolerance_=t}setMap(t){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(t),t?(this.features_.addEventListener(nt.ADD,this.boundAddFeature_),this.features_.addEventListener(nt.REMOVE,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(nt.ADD,this.boundAddFeature_),this.features_.removeEventListener(nt.REMOVE,this.boundRemoveFeature_))}addFeature_(t){const e=t.element;if(this.style_&&this.applySelectedStyle_(e),!this.getLayer(e)){const i=this.getMap().getAllLayers().find(function(s){if(s instanceof Ii&&s.getSource()&&s.getSource().hasFeature(e))return s});i&&this.addFeatureLayerAssociation_(e,i)}}removeFeature_(t){this.style_&&this.restorePreviousStyle_(t.element)}getStyle(){return this.style_}applySelectedStyle_(t){const e=X(t);e in Ss||(Ss[e]=t.getStyle()),t.setStyle(this.style_)}restorePreviousStyle_(t){const e=this.getMap().getInteractions().getArray();for(let s=e.length-1;s>=0;--s){const r=e[s];if(r!==this&&r instanceof co&&r.getStyle()&&r.getFeatures().getArray().lastIndexOf(t)!==-1){t.setStyle(r.getStyle());return}}const i=X(t);t.setStyle(Ss[i]),delete Ss[i]}removeFeatureLayerAssociation_(t){delete this.featureLayerAssociation_[X(t)]}handleEvent(t){if(!this.condition_(t))return!0;const e=this.addCondition_(t),i=this.removeCondition_(t),s=this.toggleCondition_(t),r=!e&&!i&&!s,o=t.map,a=this.getFeatures(),l=[],h=[];if(r){li(this.featureLayerAssociation_),o.forEachFeatureAtPixel(t.pixel,(c,u)=>{if(!(!(c instanceof gt)||!this.filter_(c,u)))return this.addFeatureLayerAssociation_(c,u),h.push(c),!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let c=a.getLength()-1;c>=0;--c){const u=a.item(c),d=h.indexOf(u);d>-1?h.splice(d,1):(a.remove(u),l.push(u))}h.length!==0&&a.extend(h)}else{o.forEachFeatureAtPixel(t.pixel,(c,u)=>{if(!(!(c instanceof gt)||!this.filter_(c,u)))return(e||s)&&!a.getArray().includes(c)?(this.addFeatureLayerAssociation_(c,u),h.push(c)):(i||s)&&a.getArray().includes(c)&&(l.push(c),this.removeFeatureLayerAssociation_(c)),!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let c=l.length-1;c>=0;--c)a.remove(l[c]);a.extend(h)}return(h.length>0||l.length>0)&&this.dispatchEvent(new Of(Df.SELECT,h,l,t)),!0}}function kf(){const n=Pr();return Ot(n.Polygon,n.LineString),Ot(n.GeometryCollection,n.LineString),function(t){return t.getGeometry()?n[t.getGeometry().getType()]:null}}const uo={SNAP:"snap",UNSNAP:"unsnap"};class fo extends Mt{constructor(t,e){super(t),this.vertex=e.vertex,this.vertexPixel=e.vertexPixel,this.feature=e.feature,this.segment=e.segment}}const go={Circle(n,t){const i=Vd(n);return go.Polygon(i)},GeometryCollection(n,t){const e=[],i=n.getGeometriesArray();for(let s=0;s<i.length;++s){const r=go[i[s].getType()];r&&e.push(r(i[s],t))}return e.flat()},LineString(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride();for(let s=0,r=e.length-i;s<r;s+=i)t.push([e.slice(s,s+2),e.slice(s+i,s+i+2)]);return t},MultiLineString(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride(),s=n.getEnds();let r=0;for(let o=0,a=s.length;o<a;++o){const l=s[o];for(let h=r,c=l-i;h<c;h+=i)t.push([e.slice(h,h+2),e.slice(h+i,h+i+2)]);r=l}return t},MultiPoint(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride();for(let s=0,r=e.length;s<r;s+=i)t.push([e.slice(s,s+2)]);return t},MultiPolygon(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride(),s=n.getEndss();let r=0;for(let o=0,a=s.length;o<a;++o){const l=s[o];for(let h=0,c=l.length;h<c;++h){const u=l[h];for(let d=r,f=u-i;d<f;d+=i)t.push([e.slice(d,d+2),e.slice(d+i,d+i+2)]);r=u}}return t},Point(n){return[[n.getFlatCoordinates().slice(0,2)]]},Polygon(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride(),s=n.getEnds();let r=0;for(let o=0,a=s.length;o<a;++o){const l=s[o];for(let h=r,c=l-i;h<c;h+=i)t.push([e.slice(h,h+2),e.slice(h+i,h+i+2)]);r=l}return t}};function $l(n){return n.feature?n.feature:n.element?n.element:null}const _o=[],Ee=[],bi=[];class Nf extends ye{constructor(t){t=t||{};const e=t;e.handleDownEvent||(e.handleDownEvent=Bt),e.stopDown||(e.stopDown=Ye),super(e),this.on,this.once,this.un,this.source_=t.source?t.source:null,this.vertex_=t.vertex!==void 0?t.vertex:!0,this.edge_=t.edge!==void 0?t.edge:!0,this.intersection_=t.intersection!==void 0?t.intersection:!1,this.features_=t.features?t.features:null,this.featuresListenerKeys_=[],this.featureChangeListenerKeys_={},this.indexedFeaturesExtents_={},this.pendingFeatures_={},this.pixelTolerance_=t.pixelTolerance!==void 0?t.pixelTolerance:10,this.rBush_=new ms,this.snapped_=null,this.segmenters_=Object.assign({},go,t.segmenters)}addFeature(t,e){e=e!==void 0?e:!0;const i=X(t),s=t.getGeometry();if(s){const r=this.segmenters_[s.getType()];if(r){this.indexedFeaturesExtents_[i]=s.getExtent(kt());const o=r(s,this.getMap().getView().getProjection());let a=o.length;for(let l=0;l<a;++l){const h=o[l];Ee[l]=ut(h),bi[l]={feature:t,segment:h}}if(Ee.length=a,bi.length=a,this.intersection_)for(let l=0,h=o.length;l<h;++l){const c=o[l];if(c.length===1)continue;const u=Ee[l];for(let f=0,g=o.length;f<g;++f){if(l===f||l-1===f||l+1===f)continue;const m=o[f];if(!_t(u,Ee[f]))continue;const _=Rl(c,m);if(!_)continue;const y=[_];Ee[a]=ut(y),bi[a++]={feature:t,segment:y,isIntersection:!0}}const d=this.rBush_.getInExtent(Ee[l]);for(const{segment:f}of d){if(f.length===1)continue;const g=Rl(c,f);if(!g)continue;const m=[g];Ee[a]=ut(m),bi[a++]={feature:t,segment:m,isIntersection:!0}}}a===1?this.rBush_.insert(Ee[0],bi[0]):this.rBush_.load(Ee,bi)}}e&&(this.featureChangeListenerKeys_[i]=z(t,D.CHANGE,this.handleFeatureChange_,this))}getFeatures_(){let t;return this.features_?t=this.features_:this.source_&&(t=this.source_.getFeatures()),t}areSnapDataEqual_(t,e){return t.segment===e.segment&&t.feature===e.feature}handleEvent(t){const e=this.snapTo(t.pixel,t.coordinate,t.map);return e?(t.coordinate=e.vertex.slice(0,2),t.pixel=e.vertexPixel,this.snapped_&&!this.areSnapDataEqual_(this.snapped_,e)&&this.dispatchEvent(new fo(uo.UNSNAP,this.snapped_)),this.snapped_={vertex:t.coordinate,vertexPixel:t.pixel,feature:e.feature,segment:e.segment},this.dispatchEvent(new fo(uo.SNAP,this.snapped_))):this.snapped_&&(this.dispatchEvent(new fo(uo.UNSNAP,this.snapped_)),this.snapped_=null),super.handleEvent(t)}handleFeatureAdd_(t){const e=$l(t);e&&this.addFeature(e)}handleFeatureRemove_(t){const e=$l(t);e&&this.removeFeature(e)}handleFeatureChange_(t){const e=t.target;if(this.handlingDownUpSequence){const i=X(e);i in this.pendingFeatures_||(this.pendingFeatures_[i]=e)}else this.updateFeature_(e)}handleUpEvent(t){const e=Object.values(this.pendingFeatures_);if(e.length)for(const i of e)this.updateFeature_(i);return!1}removeFeature(t,e){const i=e!==void 0?e:!0,s=X(t),r=this.indexedFeaturesExtents_[s];if(r){const o=this.rBush_,a=[];o.forEachInExtent(r,function(l){t===l.feature&&a.push(l)});for(let l=a.length-1;l>=0;--l)o.remove(a[l])}i&&($(this.featureChangeListenerKeys_[s]),delete this.featureChangeListenerKeys_[s])}setMap(t){const e=this.getMap(),i=this.featuresListenerKeys_;let s=this.getFeatures_();if(Array.isArray(s)||(s=s.getArray()),e&&(i.forEach($),i.length=0,this.rBush_.clear(),Object.values(this.featureChangeListenerKeys_).forEach($),this.featureChangeListenerKeys_={}),super.setMap(t),t){this.features_?i.push(z(this.features_,nt.ADD,this.handleFeatureAdd_,this),z(this.features_,nt.REMOVE,this.handleFeatureRemove_,this)):this.source_&&i.push(z(this.source_,Et.ADDFEATURE,this.handleFeatureAdd_,this),z(this.source_,Et.REMOVEFEATURE,this.handleFeatureRemove_,this));for(const r of s)this.addFeature(r)}}snapTo(t,e,i){i.getView().getProjection();const s=U(e),r=Vn(Oi(ut([s]),i.getView().getResolution()*this.pixelTolerance_)),o=this.rBush_.getInExtent(r),a=o.length;if(a===0)return null;let l,h=1/0,c,u=null,d;const f=this.pixelTolerance_*this.pixelTolerance_,g=()=>{if(l){const m=i.getPixelFromCoordinate(l);if(he(t,m)<=f&&(d&&this.intersection_||!d&&(this.vertex_||this.edge_)))return{vertex:l,vertexPixel:[Math.round(m[0]),Math.round(m[1])],feature:c,segment:u}}return null};if(this.vertex_||this.intersection_){for(let _=0;_<a;++_){const y=o[_];if(y.feature.getGeometry().getType()!=="Circle")for(const p of y.segment){const E=U(p),x=he(s,E);x<h&&(l=p,h=x,c=y.feature,d=y.isIntersection)}}const m=g();if(m)return m}if(this.edge_){for(let _=0;_<a;++_){let y=null;const p=o[_];if(p.feature.getGeometry().getType()==="Circle"){let E=p.feature.getGeometry();y=zh(s,E)}else{const[E,x]=p.segment;x&&(_o[0]=U(E),_o[1]=U(x),y=js(s,_o))}if(y){const E=he(s,y);E<h&&(l=ve(y),u=p.feature.getGeometry().getType()==="Circle"?null:p.segment,h=E,c=p.feature)}}const m=g();if(m)return m}return null}updateFeature_(t){this.removeFeature(t,!1),this.addFeature(t,!1)}}const mo={TRANSLATESTART:"translatestart",TRANSLATING:"translating",TRANSLATEEND:"translateend"};class yo extends Mt{constructor(t,e,i,s,r){super(t),this.features=e,this.coordinate=i,this.startCoordinate=s,this.mapBrowserEvent=r}}class Gf extends ye{constructor(t){t=t||{},super(t),this.on,this.once,this.un,this.lastCoordinate_=null,this.startCoordinate_=null,this.features_=t.features!==void 0?t.features:null;let e;if(t.layers&&!this.features_)if(typeof t.layers=="function")e=t.layers;else{const i=t.layers;e=function(s){return i.includes(s)}}else e=Bt;this.layerFilter_=e,this.filter_=t.filter&&!this.features_?t.filter:Bt,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.condition_=t.condition?t.condition:xn,this.lastFeature_=null,this.addChangeListener(ys.ACTIVE,this.handleActiveChanged_)}handleDownEvent(t){if(!t.originalEvent||!this.condition_(t))return!1;if(this.lastFeature_=this.featuresAtPixel_(t.pixel,t.map),!this.lastCoordinate_&&this.lastFeature_){this.startCoordinate_=t.coordinate,this.lastCoordinate_=t.coordinate,this.handleMoveEvent(t);const e=this.features_||new xt([this.lastFeature_]);return this.dispatchEvent(new yo(mo.TRANSLATESTART,e,t.coordinate,this.startCoordinate_,t)),!0}return!1}handleUpEvent(t){if(this.lastCoordinate_){this.lastCoordinate_=null,this.handleMoveEvent(t);const e=this.features_||new xt([this.lastFeature_]);return this.dispatchEvent(new yo(mo.TRANSLATEEND,e,t.coordinate,this.startCoordinate_,t)),this.startCoordinate_=null,!0}return!1}handleDragEvent(t){if(this.lastCoordinate_){const e=t.coordinate;t.map.getView().getProjection();const i=U(e),s=U(this.lastCoordinate_),r=i[0]-s[0],o=i[1]-s[1],a=this.features_||new xt([this.lastFeature_]);a.forEach(function(l){const h=l.getGeometry();h.translate(r,o),l.setGeometry(h)}),this.lastCoordinate_=e,this.dispatchEvent(new yo(mo.TRANSLATING,a,e,this.startCoordinate_,t))}}handleMoveEvent(t){const e=t.map.getViewport();this.featuresAtPixel_(t.pixel,t.map)?(e.classList.remove(this.lastCoordinate_?"ol-grab":"ol-grabbing"),e.classList.add(this.lastCoordinate_?"ol-grabbing":"ol-grab")):e.classList.remove("ol-grab","ol-grabbing")}featuresAtPixel_(t,e){return e.forEachFeatureAtPixel(t,(i,s)=>{if(!(!(i instanceof gt)||!this.filter_(i,s))&&!(this.features_&&!this.features_.getArray().includes(i)))return i},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_})}getHitTolerance(){return this.hitTolerance_}setHitTolerance(t){this.hitTolerance_=t}setMap(t){const e=this.getMap();super.setMap(t),this.updateState_(e)}handleActiveChanged_(){this.updateState_(null)}updateState_(t){let e=this.getMap();const i=this.getActive();(!e||!i)&&(e=e||t,e&&e.getViewport().classList.remove("ol-grab","ol-grabbing"))}}class zf{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;const s=this.points_[e+2]-this.points_[i+2];if(s<1e3/60)return!1;const r=this.points_[e]-this.points_[i],o=this.points_[e+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_}}function Wf(n){n=n||{};const t=new xt,e=new zf(-.005,.05,100);return(n.altShiftDragRotate!==void 0?n.altShiftDragRotate:!0)&&t.push(new yf),(n.doubleClickZoom!==void 0?n.doubleClickZoom:!0)&&t.push(new af({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan!==void 0?n.dragPan:!0)&&t.push(new mf({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate!==void 0?n.pinchRotate:!0)&&t.push(new Ff),(n.pinchZoom!==void 0?n.pinchZoom:!0)&&t.push(new bf({duration:n.zoomDuration})),(n.keyboard!==void 0?n.keyboard:!0)&&(t.push(new If),t.push(new Rf({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom!==void 0?n.mouseWheelZoom:!0)&&t.push(new Af({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom!==void 0?n.shiftDragZoom:!0)&&t.push(new pf({duration:n.zoomDuration})),t}const wn={IDLE:0,LOADED:2,ERROR:3,EMPTY:4},po={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class jf extends Bn{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=e===void 0?1:e,this.down_=null;const i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=z(i,po.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=z(i,po.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(D.TOUCHMOVE,this.boundHandleTouchMove_,Ko?{passive:!1}:!1)}emulateClick_(t){let e=new pe(B.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new pe(B.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new pe(B.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==B.POINTERUP||e.type==B.POINTERCANCEL){delete this.trackedTouches_[i];for(const s in this.trackedTouches_)if(this.trackedTouches_[s].target!==e.target){delete this.trackedTouches_[s];break}}else(e.type==B.POINTERDOWN||e.type==B.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new pe(B.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach($),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return t.button===0}handlePointerDown_(t){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(t);const e=new pe(B.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(z(i,B.POINTERMOVE,this.handlePointerMove_,this),z(i,B.POINTERUP,this.handlePointerUp_,this),z(this.element_,B.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(z(this.element_.getRootNode(),B.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new pe(B.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!!(this.down_&&this.isMoving_(t));this.dispatchEvent(new pe(B.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;(!e||e.defaultPrevented)&&(typeof t.cancelable!="boolean"||t.cancelable===!0)&&t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&($(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(D.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&($(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach($),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Ct={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},Is=1/0;class Vf{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,li(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,i=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const s=this.keyFunction_(i);return delete this.queuedElements_[s],i}enqueue(t){it(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=Is?(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(t){return t*2+1}getRightChildIndex_(t){return t*2+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return this.elements_.length===0}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,i=this.priorities_,s=e.length,r=e[t],o=i[t],a=t;for(;t<s>>1;){const l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=h<s&&i[h]<i[l]?h:l;e[t]=e[c],i[t]=i[c],t=c}e[t]=r,i[t]=o,this.siftDown_(a,t)}siftDown_(t,e){const i=this.elements_,s=this.priorities_,r=i[e],o=s[e];for(;e>t;){const a=this.getParentIndex_(e);if(s[a]>o)i[e]=i[a],s[e]=s[a],e=a;else break}i[e]=r,s[e]=o}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let s=0;const r=e.length;let o,a,l;for(a=0;a<r;++a)o=e[a],l=t(o),l==Is?delete this.queuedElements_[this.keyFunction_(o)]:(i[s]=l,e[s++]=o);e.length=s,i.length=s,this.heapify_()}}class Xf extends Vf{constructor(t,e){super(i=>t.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);return e&&t[0].addEventListener(D.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===wn.LOADED||i===wn.ERROR||i===wn.EMPTY){i!==wn.ERROR&&e.removeEventListener(D.CHANGE,this.boundHandleTileChange_);const s=e.getKey();s in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[s],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){const s=this.dequeue()[0],r=s.getKey();s.getState()===wn.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,s.load())}}}function Bf(n,t,e,i,s){if(!n||!(e in n.wantedTiles)||!n.wantedTiles[e][t.getKey()])return Is;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 xo extends Yt{constructor(t){super();const e=t.element;e&&!t.target&&!e.style.pointerEvents&&(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){var t;(t=this.element)==null||t.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){var e;this.map_&&((e=this.element)==null||e.remove());for(let i=0,s=this.listenerKeys.length;i<s;++i)$(this.listenerKeys[i]);if(this.listenerKeys.length=0,this.map_=t,t){const i=this.target_??t.getOverlayContainerStopEvent();this.element&&i.appendChild(this.element),this.render!==Zi&&this.listenerKeys.push(z(t,xe.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}}class Yf extends xo{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=t.collapsed!==void 0?t.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=t.collapsible!==void 0,this.collapsible_=t.collapsible!==void 0?t.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;const e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",s=t.expandClassName!==void 0?t.expandClassName:e+"-expand",r=t.collapseLabel!==void 0?t.collapseLabel:"›",o=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=s):this.label_=a;const l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(D.CLICK,this.handleClick_.bind(this),!1);const h=e+" "+Zn+" "+pr+(this.collapsed_&&this.collapsible_?" "+Ia:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){const e=this.getMap().getAllLayers(),i=new Set(e.flatMap(s=>s.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(s=>i.add(s)):i.add(this.attributions_)),!this.overrideCollapsible_){const s=!e.some(r=>{var o;return((o=r.getSource())==null?void 0:o.getAttributionsCollapsible())===!1});this.setCollapsible(s)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const e=await Promise.all(this.collectSourceAttributions_(t).map(s=>ya(()=>s))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!oe(e,this.renderedAttributions_)){Ho(this.ulElement_);for(let s=0,r=e.length;s<r;++s){const o=document.createElement("li");o.innerHTML=e[s],this.ulElement_.appendChild(o)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(Ia),this.collapsed_?Uo(this.collapseLabel_,this.label_):Uo(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,!(!this.collapsible_||this.collapsed_===t)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}}class Zf extends xo{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});const e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"⇧",s=t.compassClassName!==void 0?t.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=s,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(s));const r=t.tipLabel?t.tipLabel:"Reset rotation",o=document.createElement("button");o.className=e+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(D.CLICK,this.handleClick_.bind(this),!1);const a=e+" "+Zn+" "+pr,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(Yn)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const e=this.getMap().getView();if(!e)return;const i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:Si}):e.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const s="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(Yn);!r&&i===0?this.element.classList.add(Yn):r&&i!==0&&this.element.classList.remove(Yn)}this.label_.style.transform=s}this.rotation_=i}}class Kf extends xo{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,s=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",r=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",o=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"–",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",h=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=s,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(D.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(D.CLICK,this.handleClick_.bind(this,-i),!1);const d=e+" "+Zn+" "+pr,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const i=this.getMap().getView();if(!i)return;const s=i.getZoom();if(s!==void 0){const r=i.getConstrainedZoom(s+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:Si})):i.setZoom(r)}}}function Uf(n){n=n||{};const t=new xt;return(n.zoom!==void 0?n.zoom:!0)&&t.push(new Kf(n.zoomOptions)),(n.rotate!==void 0?n.rotate:!0)&&t.push(new Zf(n.rotateOptions)),(n.attribution!==void 0?n.attribution:!0)&&t.push(new Yf(n.attributionOptions)),t}class ke extends Mt{constructor(t,e){super(t),this.layer=e}}const Eo={LAYERS:"layers"};class Di extends Al{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Eo.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new xt(i.slice(),{unique:!0}):it(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new xt(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach($),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(z(t,nt.ADD,this.handleLayersAdd_,this),z(t,nt.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach($);li(this.listenerKeys_);const e=t.getArray();for(let i=0,s=e.length;i<s;i++){const r=e[i];this.registerLayerListeners_(r),this.dispatchEvent(new ke("addlayer",r))}this.changed()}registerLayerListeners_(t){const e=[z(t,di.PROPERTYCHANGE,this.handleLayerChange_,this),z(t,D.CHANGE,this.handleLayerChange_,this)];t instanceof Di&&e.push(z(t,"addlayer",this.handleLayerGroupAdd_,this),z(t,"removelayer",this.handleLayerGroupRemove_,this)),this.listenerKeys_[X(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new ke("addlayer",t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new ke("removelayer",t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new ke("addlayer",e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=X(e);this.listenerKeys_[i].forEach($),delete this.listenerKeys_[i],this.dispatchEvent(new ke("removelayer",e)),this.changed()}getLayers(){return this.get(Eo.LAYERS)}setLayers(t){const e=this.getLayers();if(e){const i=e.getArray();for(let s=0,r=i.length;s<r;++s)this.dispatchEvent(new ke("removelayer",i[s]))}this.set(Eo.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){const e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(e)});const s=this.getLayerState();let r=s.zIndex;!t&&s.zIndex===void 0&&(r=0);for(let o=i,a=e.length;o<a;o++){const l=e[o];l.opacity*=s.opacity,l.visible=l.visible&&s.visible,l.maxResolution=Math.min(l.maxResolution,s.maxResolution),l.minResolution=Math.max(l.minResolution,s.minResolution),l.minZoom=Math.max(l.minZoom,s.minZoom),l.maxZoom=Math.min(l.maxZoom,s.maxZoom),s.extent!==void 0&&(l.extent!==void 0?l.extent=Gs(l.extent,s.extent):l.extent=s.extent),l.zIndex===void 0&&(l.zIndex=r)}return e}getSourceState(){return"ready"}}class Hf extends fr{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){O()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,s=t.pixelToCoordinateTransform;de(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Da(s,i)}forEachFeatureAtCoordinate(t,e,i,s,r,o,a,l){let h;const c=e.viewState;function u(x,C,S,T){return r.call(o,C,x?S:null,T)}const d=c.projection,f=Bo(t.slice(),d),g=[[0,0]];if(d.canWrapX()&&s){const x=d.getExtent(),C=K(x);g.push([-C,0],[C,0])}const m=e.layerStatesArray,_=m.length,y=[],p=[];for(let x=0;x<g.length;x++)for(let C=_-1;C>=0;--C){const S=m[C],T=S.layer;if(T.hasRenderer()&&qr(S,c)&&a.call(l,T)){const I=T.getRenderer(),R=T.getSource();if(I&&R){const M=R.getWrapX()?f:t,k=u.bind(null,S.managed);p[0]=M[0]+g[x][0],p[1]=M[1]+g[x][1],h=I.forEachFeatureAtCoordinate(p,e,i,k,y)}if(h)return h}}if(y.length===0)return;const E=1/y.length;return y.forEach((x,C)=>x.distanceSq+=C*E),y.sort((x,C)=>x.distanceSq-C.distanceSq),y.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(t,e,i,s,r,o){return this.forEachFeatureAtCoordinate(t,e,i,s,Bt,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){O()}scheduleExpireIconCache(t){zt.canExpireCache()&&t.postRenderFunctions.push(qf)}}function qf(n,t){zt.expire()}class $f extends Hf{constructor(t){super(t),this.fontChangeListenerKey_=z(_i,di.PROPERTYCHANGE,t.redrawText,t),this.element_=document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=Zn+" ol-layers";const i=t.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const s=new $a(t,void 0,e);i.dispatchEvent(s)}}disposeInternal(){$(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(Gt.PRECOMPOSE,t);const e=t.layerStatesArray.sort((a,l)=>a.zIndex-l.zIndex);e.some(a=>a.layer instanceof bl&&a.layer.getDeclutter())&&(t.declutter={});const s=t.viewState;this.children_.length=0;const r=[];let o=null;for(let a=0,l=e.length;a<l;++a){const h=e[a];t.layerIndex=a;const c=h.layer,u=c.getSourceState();if(!qr(h,s)||u!="ready"&&u!="undefined"){c.unrender();continue}const d=c.render(t,o);d&&(d!==o&&(this.children_.push(d),o=d),r.push(h))}this.declutter(t,r),Kh(this.element_,this.children_),this.dispatchRenderEvent(Gt.POSTCOMPOSE,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let i=e.length-1;i>=0;--i){const s=e[i],r=s.layer;r.getDeclutter()&&r.renderDeclutter(t,s)}e.forEach(i=>i.layer.renderDeferred(t))}}}function Jl(n){if(n instanceof ds){n.setMapInternal(null);return}n instanceof Di&&n.getLayers().forEach(Jl)}function Ql(n,t){if(n instanceof ds){n.setMapInternal(t);return}if(n instanceof Di){const e=n.getLayers().getArray();for(let i=0,s=e.length;i<s;++i)Ql(e[i],t)}}class Jf extends Yt{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=Qf(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=t.maxTilesLoading!==void 0?t.maxTilesLoading:16,this.pixelRatio_=t.pixelRatio!==void 0?t.pixelRatio:Bh,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Zt(),this.pixelToCoordinateTransform_=Zt(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,this.resizeObserver_=new ResizeObserver(()=>this.updateSize()),this.controls=e.controls||Uf(),this.interactions=e.interactions||Wf({onFocusOnly:!0}),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Xf(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Ct.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Ct.VIEW,this.handleViewChanged_),this.addChangeListener(Ct.SIZE,this.handleSizeChanged_),this.addChangeListener(Ct.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof ee)&&t.view.then(function(s){i.setView(new ee(s))}),this.controls.addEventListener(nt.ADD,s=>{s.element.setMap(this)}),this.controls.addEventListener(nt.REMOVE,s=>{s.element.setMap(null)}),this.interactions.addEventListener(nt.ADD,s=>{s.element.setMap(this)}),this.interactions.addEventListener(nt.REMOVE,s=>{s.element.setMap(null)}),this.overlays_.addEventListener(nt.ADD,s=>{this.addOverlayInternal_(s.element)}),this.overlays_.addEventListener(nt.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(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){Ql(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();e!==void 0&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;const s=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:Bt,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(s,this.frameState_,r,a,e,null,o,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,function(s){i.push(s)},e),i}getAllLayers(){const t=[];function e(i){i.forEach(function(s){s instanceof Di?e(s.getLayers()):t.push(s)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};const s=e.layerFilter!==void 0?e.layerFilter:Bt,r=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,s,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const i=this.viewport_.getBoundingClientRect(),s=this.getSize(),r=i.width/s[0],o=i.height/s[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(Ct.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return ve(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?mt(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Ct.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof xt){e.setLayers(t);return}const i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const s=t[e];if(!s.visible)continue;const r=s.layer.getRenderer();if(r&&!r.ready)return!0;const o=s.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(t){const e=U(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?mt(e.coordinateToPixelTransform,t.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(Ct.SIZE)}getView(){return this.get(Ct.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,s){return Bf(this.frameState_,t,e,i,s)}handleBrowserEvent(t,e){e=e||t.type;const i=new pe(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===po.POINTERDOWN||i===D.WHEEL||i===D.KEYDOWN){const s=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():s,o=e.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===s?s.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){const s=this.getInteractions().getArray().slice();for(let r=s.length-1;r>=0;r--){const o=s[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let s=this.maxTilesLoading_,r=s;if(t){const o=t.viewHints;if(o[et.ANIMATING]||o[et.INTERACTING]){const a=Date.now()-t.time>8;s=a?0:8,r=a?0:2}}e.getTilesLoading()<s&&(e.reprioritize(),e.loadMoreTiles(s,r))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Gt.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Gt.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new Mi(xe.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new Mi(xe.LOADSTART,this,t))));const i=this.postRenderFunctions_;if(t)for(let s=0,r=i.length;s<r;++s)i[s](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,s=this.targetChangeHandlerKeys_.length;i<s;++i)$(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(D.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(D.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_){this.resizeObserver_.unobserve(this.targetElement_);const i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}const t=this.getTarget(),e=typeof t=="string"?document.getElementById(t):t;if(this.targetElement_=e,!e)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new $f(this)),this.mapBrowserEventHandler_=new jf(this,this.moveTolerance_);for(const r in B)this.mapBrowserEventHandler_.addEventListener(B[r],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(D.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(D.WHEEL,this.boundHandleBrowserEvent_,Ko?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{const r=e.getRootNode();i=r instanceof ShadowRoot?r.host:e}this.targetChangeHandlerKeys_=[z(i,D.KEYDOWN,this.handleBrowserEvent,this),z(i,D.KEYPRESS,this.handleBrowserEvent,this)];const s=e.getRootNode();s instanceof ShadowRoot&&this.resizeObserver_.observe(s.host),this.resizeObserver_.observe(e)}this.updateSize()}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&($(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&($(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=z(t,di.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=z(t,D.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach($),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new ke("addlayer",t)),this.layerGroupPropertyListenerKeys_=[z(t,di.PROPERTYCHANGE,this.render,this),z(t,D.CHANGE,this.render,this),z(t,"addlayer",this.handleLayerAdd_,this),z(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;const t=this.frameState_.layerStatesArray;for(let e=0,i=t.length;e<i;++e){const s=t[e].layer;s.hasRenderer()&&s.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){Jl(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){const e=this.getSize(),i=this.getView(),s=this.frameState_;let r=null;if(e!==void 0&&Wa(e)&&i&&i.isDef()){const o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:Ln(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:X(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=Ln(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),s&&(!this.previousExtent_||!si(this.previousExtent_)&&!zi(r.extent,this.previousExtent_))&&(this.dispatchEvent(new Mi(xe.MOVESTART,this,s)),this.previousExtent_=Ni(this.previousExtent_)),this.previousExtent_&&!r.viewHints[et.ANIMATING]&&!r.viewHints[et.INTERACTING]&&!zi(r.extent,this.previousExtent_)&&(this.dispatchEvent(new Mi(xe.MOVEEND,this,r)),Go(r.extent,this.previousExtent_))),this.dispatchEvent(new Mi(xe.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(xe.LOADSTART)||this.hasListener(xe.LOADEND)||this.hasListener(Gt.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new ke("removelayer",e)),this.set(Ct.LAYERGROUP,t)}setSize(t){this.set(Ct.SIZE,t)}setTarget(t){this.set(Ct.TARGET,t)}setView(t){if(!t||t instanceof ee){this.set(Ct.VIEW,t);return}this.set(Ct.VIEW,new ee);const e=this;t.then(function(i){e.setView(new ee(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){const s=getComputedStyle(t),r=t.offsetWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight)-parseFloat(s.borderRightWidth),o=t.offsetHeight-parseFloat(s.borderTopWidth)-parseFloat(s.paddingTop)-parseFloat(s.paddingBottom)-parseFloat(s.borderBottomWidth);!isNaN(r)&&!isNaN(o)&&(e=[Math.max(0,r),Math.max(0,o)],!Wa(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&qo("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!oe(e,i))&&(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}}function Qf(n){let t=null;n.keyboardEventTarget!==void 0&&(t=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);const e={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new Di({layers:n.layers});e[Ct.LAYERGROUP]=i,e[Ct.TARGET]=n.target,e[Ct.VIEW]=n.view instanceof ee?n.view:new ee;let s;n.controls!==void 0&&(Array.isArray(n.controls)?s=new xt(n.controls.slice()):(it(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 xt(n.interactions.slice()):(it(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 xt(n.overlays.slice()):(it(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new xt,{controls:s,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}const wt={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class tg extends Yt{constructor(t){super(),this.on,this.once,this.un,this.options=t,this.id=t.id,this.insertFirst=t.insertFirst!==void 0?t.insertFirst:!0,this.stopEvent=t.stopEvent!==void 0?t.stopEvent:!0,this.element=document.createElement("div"),this.element.className=t.className!==void 0?t.className:"ol-overlay-container "+Gc,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=t.autoPan===!0?{}:t.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(wt.ELEMENT,this.handleElementChanged),this.addChangeListener(wt.MAP,this.handleMapChanged),this.addChangeListener(wt.OFFSET,this.handleOffsetChanged),this.addChangeListener(wt.POSITION,this.handlePositionChanged),this.addChangeListener(wt.POSITIONING,this.handlePositioningChanged),t.element!==void 0&&this.setElement(t.element),this.setOffset(t.offset!==void 0?t.offset:[0,0]),this.setPositioning(t.positioning||"top-left"),t.position!==void 0&&this.setPosition(t.position)}getElement(){return this.get(wt.ELEMENT)}getId(){return this.id}getMap(){return this.get(wt.MAP)||null}getOffset(){return this.get(wt.OFFSET)}getPosition(){return this.get(wt.POSITION)}getPositioning(){return this.get(wt.POSITIONING)}handleElementChanged(){Ho(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){var e;this.mapPostrenderListenerKey&&((e=this.element)==null||e.remove(),$(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=z(t,xe.POSTRENDER,this.render,this),this.updatePixelPosition();const i=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?i.insertBefore(this.element,i.childNodes[0]||null):i.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(t){this.set(wt.ELEMENT,t)}setMap(t){this.set(wt.MAP,t)}setOffset(t){this.set(wt.OFFSET,t)}setPosition(t){this.set(wt.POSITION,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(wt.POSITION))return;const i=this.getRect(e.getTargetElement(),e.getSize()),s=this.getElement(),r=this.getRect(s,[Yh(s),Zh(s)]);t=t||{};const o=t.margin===void 0?20:t.margin;if(!ae(i,r)){const a=r[0]-i[0],l=i[2]-r[2],h=r[1]-i[1],c=i[3]-r[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),h<0?u[1]=h-o:c<0&&(u[1]=Math.abs(c)+o),u[0]!==0||u[1]!==0){const d=e.getView().getCenterInternal(),f=e.getPixelFromCoordinateInternal(d);if(!f)return;const g=[f[0]+u[0],f[1]+u[1]],m=t.animation||{};e.getView().animateInternal({center:e.getCoordinateFromPixelInternal(g),duration:m.duration,easing:m.easing})}}}getRect(t,e){const i=t.getBoundingClientRect(),s=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[s,r,s+e[0],r+e[1]]}setPositioning(t){this.set(wt.POSITIONING,t)}setVisible(t){this.rendered.visible!==t&&(this.element.style.display=t?"":"none",this.rendered.visible=t)}updatePixelPosition(){const t=this.getMap(),e=this.getPosition();if(!t||!t.isRendered()||!e){this.setVisible(!1);return}const i=t.getPixelFromCoordinate(e),s=t.getSize();this.updateRenderedPosition(i,s)}updateRenderedPosition(t,e){const i=this.element.style,s=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=`${t[0]+s[0]}px`,a=`${t[1]+s[1]}px`;let l="0%",h="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"?h="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(h="-50%");const c=`translate(${l}, ${h}) translate(${o}, ${a})`;this.rendered.transform_!=c&&(this.rendered.transform_=c,i.transform=c)}getOptions(){return this.options}}class eg{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=gt,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let i=e.dataProjection?ot(e.dataProjection):this.readProjection(t);e.extent&&i&&i.getUnits()==="tile-pixels"&&(i=ot(i),i.setWorldExtent(e.extent)),e={dataProjection:i,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return O()}readFeature(t,e){return O()}readFeatures(t,e){return O()}readGeometry(t,e){return O()}readProjection(t){return O()}writeFeature(t,e){return O()}writeFeatures(t,e){return O()}writeGeometry(t,e){return O()}}function Co(n,t,e){const i=e?ot(e.featureProjection):null,s=e?ot(e.dataProjection):null;let r=n;if(i&&s&&!er(i,s)){t&&(r=n.clone());const o=t?i:s,a=t?s:i;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(Xi(o,a))}if(t&&e&&e.decimals!==void 0){const o=Math.pow(10,e.decimals),a=function(l){for(let h=0,c=l.length;h<c;++h)l[h]=Math.round(l[h]*o)/o;return l};r===n&&(r=n.clone()),r.applyTransform(a)}return r}const ig={Point:vt,LineString:ie,Polygon:qt,MultiPoint:yn,MultiLineString:Ri,MultiPolygon:vi};function ng(n,t,e){return Array.isArray(t[0])?(Tl(n,0,t,e)||(n=n.slice(),Br(n,0,t,e)),n):(Xr(n,0,t,e)||(n=n.slice(),cs(n,0,t,e)),n)}function th(n,t){var r;const e=n.geometry;if(!e)return[];if(Array.isArray(e))return e.map(o=>th({...n,geometry:o})).flat();const i=e.type==="MultiPolygon"?"Polygon":e.type;if(i==="GeometryCollection"||i==="Circle")throw new Error("Unsupported geometry type: "+i);const s=e.layout.length;return Co(new Dt(i,i==="Polygon"?ng(e.flatCoordinates,e.ends,s):e.flatCoordinates,(r=e.ends)==null?void 0:r.flat(),s,n.properties||{},n.id).enableSimplifyTransformed(),!1,t)}function wo(n,t){if(!n)return null;if(Array.isArray(n)){const i=n.map(s=>wo(s,t));return new mn(i)}const e=ig[n.type];return Co(new e(n.flatCoordinates,n.layout||"XY",n.ends),!1,t)}class sg extends eg{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Rs(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Rs(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return O()}readFeaturesFromObject(t,e){return O()}readGeometry(t,e){return this.readGeometryFromObject(Rs(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return O()}readProjection(t){return this.readProjectionFromObject(Rs(t))}readProjectionFromObject(t){return O()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return O()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return O()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return O()}}function Rs(n){if(typeof n=="string"){const t=JSON.parse(n);return t||null}return n!==null?n:null}class eh extends sg{constructor(t){t=t||{},super(),this.dataProjection=ot(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=ot(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let i=null;t.type==="Feature"?i=t:i={type:"Feature",geometry:t,properties:null};const s=So(i.geometry);if(this.featureClass===Dt)return th({geometry:s,id:i.id,properties:i.properties},e);const r=new gt;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&r.setGeometryName(i.geometry_name),r.setGeometry(wo(s,e)),"id"in i&&r.setId(i.id),i.properties&&r.setProperties(i.properties,!0),r}readFeaturesFromObject(t,e){const i=t;let s=null;if(i.type==="FeatureCollection"){const r=t;s=[];const o=r.features;for(let a=0,l=o.length;a<l;++a){const h=this.readFeatureFromObject(o[a],e);h&&s.push(h)}}else s=[this.readFeatureFromObject(t,e)];return s.flat()}readGeometryFromObject(t,e){return rg(t,e)}readProjectionFromObject(t){const e=t.crs;let i;if(e)if(e.type=="name")i=ot(e.properties.name);else if(e.type==="EPSG")i=ot("EPSG:"+e.properties.code);else throw new Error("Unknown SRS type");else i=this.dataProjection;return i}writeFeatureObject(t,e){e=this.adaptOptions(e);const i={type:"Feature",geometry:null,properties:null},s=t.getId();if(s!==void 0&&(i.id=s),!t.hasProperties())return i;const r=t.getProperties(),o=t.getGeometry();return o&&(i.geometry=Io(o,e),delete r[t.getGeometryName()]),Xe(r)||(i.properties=r),i}writeFeaturesObject(t,e){e=this.adaptOptions(e);const i=[];for(let s=0,r=t.length;s<r;++s)i.push(this.writeFeatureObject(t[s],e));return{type:"FeatureCollection",features:i}}writeGeometryObject(t,e){return Io(t,this.adaptOptions(e))}}function So(n,t){if(!n)return null;let e;switch(n.type){case"Point":{e=ag(n);break}case"LineString":{e=lg(n);break}case"Polygon":{e=dg(n);break}case"MultiPoint":{e=cg(n);break}case"MultiLineString":{e=hg(n);break}case"MultiPolygon":{e=ug(n);break}case"GeometryCollection":{e=og(n);break}default:throw new Error("Unsupported GeoJSON type: "+n.type)}return e}function rg(n,t){const e=So(n);return wo(e,t)}function og(n,t){return n.geometries.map(function(i){return So(i)})}function ag(n){const t=n.coordinates;return{type:"Point",flatCoordinates:t,layout:$e(t.length)}}function lg(n){var i;const t=n.coordinates,e=t.flat();return{type:"LineString",flatCoordinates:e,ends:[e.length],layout:$e(((i=t[0])==null?void 0:i.length)||2)}}function hg(n){var r,o;const t=n.coordinates,e=((o=(r=t[0])==null?void 0:r[0])==null?void 0:o.length)||2,i=[],s=gn(i,0,t,e);return{type:"MultiLineString",flatCoordinates:i,ends:s,layout:$e(e)}}function cg(n){var e;const t=n.coordinates;return{type:"MultiPoint",flatCoordinates:t.flat(),layout:$e(((e=t[0])==null?void 0:e.length)||2)}}function ug(n){var r,o;const t=n.coordinates,e=[],i=((o=(r=t[0])==null?void 0:r[0])==null?void 0:o[0].length)||2,s=wl(e,0,t,i);return{type:"MultiPolygon",flatCoordinates:e,ends:s,layout:$e(i)}}function dg(n){var r,o;const t=n.coordinates,e=[],i=(o=(r=t[0])==null?void 0:r[0])==null?void 0:o.length,s=gn(e,0,t,i);return{type:"Polygon",flatCoordinates:e,ends:s,layout:$e(i)}}function Io(n,t){n=Co(n,!0,t);const e=n.getType();let i;switch(e){case"Point":{i=pg(n);break}case"LineString":{i=gg(n);break}case"Polygon":{i=xg(n,t);break}case"MultiPoint":{i=mg(n);break}case"MultiLineString":{i=_g(n);break}case"MultiPolygon":{i=yg(n,t);break}case"GeometryCollection":{i=fg(n,t);break}case"Circle":{i={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+e)}return i}function fg(n,t){return t=Object.assign({},t),delete t.featureProjection,{type:"GeometryCollection",geometries:n.getGeometriesArray().map(function(i){return Io(i,t)})}}function gg(n,t){return{type:"LineString",coordinates:n.getCoordinates()}}function _g(n,t){return{type:"MultiLineString",coordinates:n.getCoordinates()}}function mg(n,t){return{type:"MultiPoint",coordinates:n.getCoordinates()}}function yg(n,t){let e;return t&&(e=t.rightHanded),{type:"MultiPolygon",coordinates:n.getCoordinates(e)}}function pg(n,t){return{type:"Point",coordinates:n.getCoordinates()}}function xg(n,t){let e;return t&&(e=t.rightHanded),{type:"Polygon",coordinates:n.getCoordinates(e)}}function vs(n,t){t.feature.set("__type","zone");const e=n.getView().getProjection(),{geometry:i}=new eh().writeFeatureObject(t.feature,{featureProjection:e,dataProjection:e});return i}function Eg(n){return{type:"Feature",id:n.id,geometry:n.geometry,properties:{id:n.id,name:n.name,color:n.color,__type:"zone"}}}function Cg(n){return{type:"FeatureCollection",features:n.filter(t=>t.geometry).map(Eg)}}function ih(n,t){const e=n.getView().getProjection();return new eh().readFeatures(Cg(t),{featureProjection:e,dataProjection:e})}function wg({colors:n,angles:t=[45,-45],gap:e=32,lineWidth:i=32,background:s=null,lineCap:r="butt",dash:o}){return(!n||n.length===0)&&(n=["#000"]),new at({renderer(a,l){a=a;const h=l.context,c=l.geometry.clone();c.setCoordinates(a),h.save(),h.beginPath(),a[0].forEach(([p,E],x)=>{x===0?h.moveTo(p,E):h.lineTo(p,E)}),h.closePath(),h.clip("nonzero"),s&&(h.fillStyle=s,h.fill("nonzero"));const[u,d,f,g]=c.getExtent(),m=f-u,_=g-d;if(m<=0||_<=0){h.restore();return}const y=Math.hypot(m,_);h.lineWidth=i,h.lineCap=r,o&&o.length&&h.setLineDash(o),t.forEach(p=>{if(p>0)return;h.save();const E=u+m/2,x=d+_/2;h.translate(E,x),h.rotate(p*Math.PI/180),h.translate(-E,-x);const C=d-y,S=g+y;let T=0;for(let I=C;I<=S;I+=e,T++)h.strokeStyle=n[T%n.length],h.beginPath(),h.moveTo(u-y,I),h.lineTo(f+y,I),h.stroke();h.restore()}),o&&o.length&&h.setLineDash([]),h.restore()}})}const nh={name:"ppe-zoning",getInitialState:n=>{const{layer:t,source:e}=kg(n==null?void 0:n._extent),{layer:i,source:s}=Ng(n==null?void 0:n._extent),r=new co({layers:[t],condition:uf,style:l=>{const h=l.getProperties();return Gg(h)}}),o=new vf({source:e,features:r.getFeatures()}),a=new Gf({layers:[t],condition:df,features:r.getFeatures()});return{zones:[],_zoneLayer:t,_zoneSource:e,_zoneLabelLayer:i,_zoneLabelSource:s,_zoneModify:o,_zoneSelect:r,_zoneTranslate:a,_editMode:"editing",_selectedZoneId:null,_currentAction:"none",_currentDrawingZone:null,...n}},createPlanEditor:n=>{var r;const t=n.initialState,{_zoneLayer:e,_zoneLabelLayer:i}=t;e&&n.addLayer(e),i&&n.addLayer(i),Sg(n),Og(n),Ig(n);const s=((r=n.options.zoningConfig)==null?void 0:r.editMode)||"editing";t._editMode=s,sh(n,s),n.drawZone=o=>rh(n,o),n.deleteZone=o=>oh(n,o),n.updateZone=o=>Lg(n,o),n.setZoningMode=o=>bg(n,o),n.setEditMode=o=>Rg(n,o),n.selectZone=o=>vg(n,o),n.deselectZone=()=>Ro(n),n.getSelectedZone=()=>Tg(n),n.startDrawingZone=o=>Mg(n,o),n.cancelCurrentAction=()=>Ts(n),n.deleteSelectedZone=()=>ah(n),n.updateZoneOccupationColors=()=>Dg(n)}};function Sg(n){const{zones:t}=n.getState();n.initialState._zoneSource.addFeatures(ih(n,t))}function Ig(n){document.addEventListener("keydown",t=>{const e=n.initialState;t.key==="Escape"&&(t.preventDefault(),Ts(n)),(t.key==="Delete"||t.key==="Backspace")&&e._editMode==="editing"&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement||(t.preventDefault(),ah(n)))})}function Rg(n,t){const e=n.initialState;e._editMode!==t&&(e._editMode=t,sh(n,t))}function sh(n,t){const e=n.initialState;Ts(n),t==="readonly"?(e._zoneSelect&&n.removeInteraction(e._zoneSelect),e._zoneModify&&n.removeInteraction(e._zoneModify),e._zoneTranslate&&n.removeInteraction(e._zoneTranslate)):t==="editing"&&(e._zoneSelect&&(n.addInteraction(e._zoneSelect),Pg(n)),e._zoneModify&&(n.addInteraction(e._zoneModify),Ag(n)),e._zoneTranslate&&(n.addInteraction(e._zoneTranslate),Fg(n)))}function vg(n,t){var o,a,l;const e=n.initialState,{zones:i}=n.getState(),s=i.find(h=>h.id===t);if(!s||!s.geometry)return;const r=(o=e._zoneSource)==null?void 0:o.getFeatureById(t);r&&(e._selectedZoneId=t,e._zoneSelect&&(e._zoneSelect.getFeatures().clear(),e._zoneSelect.getFeatures().push(r)),(l=(a=n.options).onZoneSelected)==null||l.call(a,s))}function Ro(n){var e,i;const t=n.initialState;t._selectedZoneId=null,t._zoneSelect&&t._zoneSelect.getFeatures().clear(),(i=(e=n.options).onZoneSelected)==null||i.call(e,null)}function Tg(n){const t=n.initialState,{zones:e}=n.getState();return t._selectedZoneId&&e.find(i=>i.id===t._selectedZoneId)||null}function Pg(n){var e,i;const t=n.initialState;t._selectListener&&((e=t._zoneSelect)==null||e.un("select",t._selectListener)),t._selectListener=(i=t._zoneSelect)==null?void 0:i.on("select",s=>{var a,l,h,c;const r=s.selected,o=s.deselected;if(r.length>0){const d=r[0].getId();t._selectedZoneId=d;const{zones:f}=n.getState(),g=f.find(m=>m.id===d);g&&((l=(a=n.options).onZoneSelected)==null||l.call(a,g))}else o.length>0&&(t._selectedZoneId=null,(c=(h=n.options).onZoneSelected)==null||c.call(h,null))})}function Mg(n,t){rh(n,t)}function rh(n,t){const e=n.initialState;Ts(n),e._zoneSelect&&n.removeInteraction(e._zoneSelect),e._zoneModify&&n.removeInteraction(e._zoneModify),e._zoneTranslate&&n.removeInteraction(e._zoneTranslate),e._zoneDraw=new Cf({source:e._zoneSource,type:"Polygon",geometryName:"zone"}),e._zoneSnap=new Nf({source:e._zoneSource}),n.addInteraction(e._zoneDraw),n.addInteraction(e._zoneSnap),e._currentAction="drawing",e._currentDrawingZone=t,e._zoneDraw.on("drawend",i=>{var r,o;i.feature.setId(t.id),i.feature.setProperties({id:t.id,name:t.name,color:t.color,__type:"zone"});const s=vs(n,i);(o=(r=n.options).onZoneDrawn)==null||o.call(r,{...t,geometry:s}),e._zoneDraw&&n.removeInteraction(e._zoneDraw),e._zoneSnap&&n.removeInteraction(e._zoneSnap),e._zoneDraw=void 0,e._zoneSnap=void 0,e._currentAction="none",e._currentDrawingZone=null,e._editMode==="editing"&&(e._zoneSelect&&n.addInteraction(e._zoneSelect),e._zoneModify&&n.addInteraction(e._zoneModify),e._zoneTranslate&&n.addInteraction(e._zoneTranslate))})}function Lg(n,t){var s,r;const e=n.initialState,i=(s=e._zoneSource)==null?void 0:s.getFeatureById(t.id);if(i){const{geometry:o,...a}=t;i.setProperties(a),(r=e._zoneLayer)==null||r.changed()}}function Ag(n){var e,i,s;const t=n.initialState;t._modifyListener&&((e=t._zoneModify)==null||e.un("modifystart",t._modifyListener)),t._modifyListener=(i=t._zoneModify)==null?void 0:i.on("modifystart",r=>{var a,l;t._currentAction="modifying";const o=r.features.getArray()[0];if(o){const{zones:h}=n.getState(),c=h.find(u=>u.id===o.getId());c&&((l=(a=n.options).onZoneModifyStart)==null||l.call(a,c))}}),(s=t._zoneModify)==null||s.on("modifyend",r=>{var a,l,h,c;t._currentAction="none";const o=r.features.getArray()[0];if(o){const{zones:u}=n.getState(),d=u.find(f=>f.id===o.getId());if(d){const f=vs(n,{feature:o});(l=(a=n.options).onZoneUpdated)==null||l.call(a,{...d,geometry:f}),(c=(h=n.options).onZoneModifyEnd)==null||c.call(h,d)}}})}function Fg(n){var e,i,s;const t=n.initialState;t._translateListener&&((e=t._zoneTranslate)==null||e.un("translatestart",t._translateListener)),t._translateListener=(i=t._zoneTranslate)==null?void 0:i.on("translatestart",r=>{t._currentAction="translating"}),(s=t._zoneTranslate)==null||s.on("translateend",r=>{var a,l,h,c;t._currentAction="none";const o=r.features.getArray();if(o.length>0){const u=o[0],{zones:d}=n.getState(),f=d.find(g=>g.id===u.getId());if(f){const g=vs(n,{feature:u});(l=(a=n.options).onZoneUpdated)==null||l.call(a,{...f,geometry:g}),(c=(h=n.options).onZoneModifyEnd)==null||c.call(h,{...f,geometry:g})}}})}function oh(n,t){var i,s,r,o;const e=(i=n.initialState._zoneSource)==null?void 0:i.getFeatureById(t);e&&((s=n.initialState._zoneSource)==null||s.removeFeature(e)),n.initialState._selectedZoneId===t&&Ro(n),(o=(r=n.options).onZoneDeleted)==null||o.call(r,t)}function ah(n){const t=n.initialState;t._selectedZoneId&&oh(n,t._selectedZoneId)}function Ts(n){const t=n.initialState;t._currentAction==="drawing"&&(t._zoneDraw&&(n.removeInteraction(t._zoneDraw),t._zoneDraw=void 0),t._zoneSnap&&(n.removeInteraction(t._zoneSnap),t._zoneSnap=void 0),t._currentAction="none",t._currentDrawingZone=null,t._editMode==="editing"&&(t._zoneSelect&&n.addInteraction(t._zoneSelect),t._zoneModify&&n.addInteraction(t._zoneModify),t._zoneTranslate&&n.addInteraction(t._zoneTranslate))),t._selectedZoneId&&Ro(n)}function bg(n,t){const{_zoneLayer:e,_zoneLabelSource:i}=n.initialState;t==="occupation"?(e.setStyle(s=>{var l,h;const r=s.getProperties(),o=((h=(l=n.options).getZoneOccupationColors)==null?void 0:h.call(l,r))??[];if(o.length===0)return[new at({stroke:new Qt({color:r.color,width:2,lineDash:[5,5]}),fill:new yt({color:"rgba(0,0,0,0)"})})];const a=o.length?o:[r.color];return[...vo(s.getProperties()),wg({colors:a})]}),lh(n)):(e.setStyle(s=>vo(s.getProperties())),i.clear())}function Dg(n){const{_zoneLayer:t}=n.initialState;t.changed(),lh(n)}function lh(n){const{_zoneLabelSource:t,_zoneSource:e}=n.initialState;t.clear(),e.getFeatures().forEach(s=>{const r=s.getProperties(),o=s.getGeometry();if(!o)return;const a=Xt(o.getExtent());if(n.options.renderZoneLabels){const l=n.options.renderZoneLabels(r,a);if(l.title){const h=new gt({geometry:new vt(a),__type:"zone-label"});h.setStyle(new at({text:new qe({text:l.title.text,font:l.title.font||"bold 14px Arial",fill:new yt({color:l.title.textColor||"#000"}),backgroundFill:l.title.backgroundColor?new yt({color:l.title.backgroundColor}):void 0,padding:l.title.padding||[2,4,2,4],offsetY:l.title.offsetY||0,textAlign:l.title.textAlign||"center"})})),t.addFeature(h)}l.items&&l.items.forEach(h=>{const c=new gt({geometry:new vt(a),__type:"zone-label"});c.setStyle(new at({text:new qe({text:h.text,font:h.font||"12px Arial",fill:new yt({color:h.textColor||"#000"}),backgroundFill:h.backgroundColor?new yt({color:h.backgroundColor}):void 0,padding:h.padding||[3,6,3,6],offsetY:h.offsetY||0,textAlign:h.textAlign||"left"})})),t.addFeature(c)})}else if(n.options.getZoneOccupationLabels){const l=n.options.getZoneOccupationLabels(r);if(l.title){const h=new gt({geometry:new vt(a),__type:"zone-label"});h.setStyle(new at({text:new qe({text:l.title,font:"bold 14px Arial",fill:new yt({color:"#000"}),offsetY:-l.items.length*10-10})})),t.addFeature(h)}l.items.forEach((h,c)=>{const u=new gt({geometry:new vt(a),__type:"zone-label"});u.setStyle(new at({text:new qe({text:h.text,font:"12px Arial",fill:new yt({color:"#ffffff"}),backgroundFill:new yt({color:h.color}),padding:[3,6,3,6],offsetY:c*20-l.items.length*5,textAlign:"left"})})),t.addFeature(u)})}})}function Og(n){n.on("pointermove",t=>{var s;if(n.initialState._currentAction==="drawing"){n._hidePopup();return}const i=n.forEachFeatureAtPixel(t.pixel,r=>r);if(i&&i.get("__type")==="zone"){const r=i.getProperties(),o=(s=n.options.zoningConfig)==null?void 0:s.popup,a=o&&o.template?o.template(r):zg(r);n._showPopup({event:t,content:a})}else i||n._hidePopup()})}function kg(n){const t=new pn({wrapX:!1}),e=new Ii({source:t,style:i=>vo(i.getProperties())});return n&&e.setExtent(n),{layer:e,source:t}}function Ng(n){const t=new pn({wrapX:!1}),e=new Ii({source:t});return n&&e.setExtent(n),{layer:e,source:t}}function vo({color:n}){return[new at({stroke:new Qt({color:n,width:3}),fill:new yt({color:n+"80"})})]}function Gg({color:n}){return[new at({stroke:new Qt({color:n,width:5}),fill:new yt({color:n+"A0"})})]}function zg(n){return`
|
|
3
|
+
`||h===c){r=Math.max(r,o),s.push(o),o=0,a+=l,l=0;continue}const d=t[h+1]||n.font,f=Ma(d,u);e.push(f),o+=f;const g=Xc(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:s}}function Yc(n,t,e,i,s,r,o,a,l,h,c){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,h),n.scale(c[0],c[1]),Zc(i,n)):c[0]<0||c[1]<0?(n.translate(l,h),n.scale(c[0],c[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,h,o*c[0],a*c[1]),n.restore()}function Zc(n,t){const e=n.contextInstructions;for(let i=0,s=e.length;i<s;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}const L={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Un=[L.FILL],Me=[L.STROKE],Ke=[L.BEGIN_PATH],Aa=[L.CLOSE_PATH];class en extends wa{constructor(t,e,i,s){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=s,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){const e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){const i=this.getBufferedMaxExtent(),s=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=t.length;a<l;a+=e)s[0]=t[a],s[1]=t[a+1],ki(i,s)&&(r[o++]=s[0],r[o++]=s[1]);return o}appendFlatLineCoordinates(t,e,i,s,r,o){const a=this.coordinates;let l=a.length;const h=this.getBufferedMaxExtent();o&&(e+=s);let c=t[e],u=t[e+1];const d=this.tmpCoordinate_;let f=!0,g,m,_;for(g=e+s;g<i;g+=s)d[0]=t[g],d[1]=t[g+1],_=Ds(h,d),_!==m?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):_===ct.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],m=_;return(r&&f||g===e+s)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(t,e,i,s,r){for(let o=0,a=i.length;o<a;++o){const l=i[o],h=this.appendFlatLineCoordinates(t,e,l,s,!1,!1);r.push(h),e=l}return e}drawCustom(t,e,i,s,r){this.beginGeometry(t,e,r);const o=t.getType(),a=t.getStride(),l=this.coordinates.length;let h,c,u,d,f;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),d=[];const g=t.getEndss();f=0;for(let m=0,_=g.length;m<_;++m){const y=[];f=this.drawCustomCoordinates_(h,f,g[m],a,y),d.push(y)}this.instructions.push([L.CUSTOM,l,d,t,i,yr,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,d,t,s||i,yr,r]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,t.getEnds(),a,u),this.instructions.push([L.CUSTOM,l,u,t,i,Ui,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,u,t,s||i,Ui,r]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([L.CUSTOM,l,c,t,i,Pe,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,c,t,s||i,Pe,r]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([L.CUSTOM,l,c,t,i,Pe,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,c,t,s||i,Pe,r]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([L.CUSTOM,l,c,t,i,void 0,r]),this.hitDetectionInstructions.push([L.CUSTOM,l,c,t,s||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[L.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[L.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;t.reverse();let e;const i=t.length;let s,r,o=-1;for(e=0;e<i;++e)s=t[e],r=s[0],r==L.END_GEOMETRY?o=e:r==L.BEGIN_GEOMETRY&&(s[2]=e,Mh(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=Jt(i||Lt)}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const i=t.getColor();e.strokeStyle=Jt(i||$i);const s=t.getLineCap();e.lineCap=s!==void 0?s:fi;const r=t.getLineDash();e.lineDash=r?r.slice():ce;const o=t.getLineDashOffset();e.lineDashOffset=o||ue;const a=t.getLineJoin();e.lineJoin=a!==void 0?a:gi;const l=t.getWidth();e.lineWidth=l!==void 0?l:Qi;const h=t.getMiterLimit();e.miterLimit=h!==void 0?h:qi,e.lineWidth>this.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0;return e}setFillStrokeStyle(t,e){const i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){const e=t.fillStyle,i=[L.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[L.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,s=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=s||r!=t.currentLineDash&&!oe(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=s,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[L.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Go(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Oi(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Kc extends en{constructor(t,e,i,s){super(t,e,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(t,e,i){if(!this.image_||this.maxExtent&&!ki(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([L.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([L.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(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=[];for(let l=0,h=s.length;l<h;l+=t.getStride())(!this.maxExtent||ki(this.maxExtent,s.slice(l,l+2)))&&r.push(s[l],s[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([L.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([L.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(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){const i=t.getAnchor(),s=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=s[1],this.opacity_=t.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=s[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}class Uc extends en{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinates_(t,e,i,s){const r=this.coordinates.length,o=this.appendFlatLineCoordinates(t,e,i,s,!1,!1),a=[L.MOVE_TO_LINE_TO,r,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),i}drawLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue],Ke);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l),this.hitDetectionInstructions.push(Me),this.endGeometry(e)}drawMultiLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue],Ke);const a=t.getEnds(),l=t.getFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinates_(l,c,a[u],h);this.hitDetectionInstructions.push(Me),this.endGeometry(e)}finish(){const t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Me),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Me),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(Ke)}}function Hn(n,t,e,i,s,r,o){const a=(e-t)/i;if(a<3){for(;t<e;t+=i)r[o++]=n[t],r[o++]=n[t+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[t,e-i];let c=0;for(;h.length>0;){const u=h.pop(),d=h.pop();let f=0;const g=n[d],m=n[d+1],_=n[u],y=n[u+1];for(let p=d+i;p<u;p+=i){const E=n[p],x=n[p+1],C=kh(E,x,g,m,_,y);C>f&&(c=p,f=C)}f>s&&(l[(c-t)/i]=1,d+i<c&&h.push(d,c),c+i<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(r[o++]=n[t+u*i],r[o++]=n[t+u*i+1]);return o}function Fa(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=Hn(n,t,c,i,s,r,o),a.push(o),t=c}return o}function Ue(n,t){return t*Math.round(n/t)}function Hc(n,t,e,i,s,r,o){if(t==e)return o;let a=Ue(n[t],s),l=Ue(n[t+1],s);t+=i,r[o++]=a,r[o++]=l;let h,c;do if(h=Ue(n[t],s),c=Ue(n[t+1],s),t+=i,t==e)return r[o++]=h,r[o++]=c,o;while(h==a&&c==l);for(;t<e;){const u=Ue(n[t],s),d=Ue(n[t+1],s);if(t+=i,u==h&&d==c)continue;const f=h-a,g=c-l,m=u-a,_=d-l;if(f*_==g*m&&(f<0&&m<f||f==m||f>0&&m>f)&&(g<0&&_<g||g==_||g>0&&_>g)){h=u,c=d;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=u,c=d}return r[o++]=h,r[o++]=c,o}function wr(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=Hc(n,t,c,i,s,r,o),a.push(o),t=c}return o}function qc(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l],u=[];o=wr(n,t,c,i,s,r,o,u),a.push(u),t=c[c.length-1]}return o}class ba extends en{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinatess_(t,e,i,s){const r=this.state,o=r.fillStyle!==void 0,a=r.strokeStyle!==void 0,l=i.length;this.instructions.push(Ke),this.hitDetectionInstructions.push(Ke);for(let h=0;h<l;++h){const c=i[h],u=this.coordinates.length,d=this.appendFlatLineCoordinates(t,e,c,s,!0,!a),f=[L.MOVE_TO_LINE_TO,u,d];this.instructions.push(f),this.hitDetectionInstructions.push(f),a&&(this.instructions.push(Aa),this.hitDetectionInstructions.push(Aa)),e=c}return o&&(this.instructions.push(Un),this.hitDetectionInstructions.push(Un)),a&&(this.instructions.push(Me),this.hitDetectionInstructions.push(Me)),e}drawCircle(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_FILL_STYLE,Lt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[L.CIRCLE,h];this.instructions.push(Ke,c),this.hitDetectionInstructions.push(Ke,c),s.fillStyle!==void 0&&(this.instructions.push(Un),this.hitDetectionInstructions.push(Un)),s.strokeStyle!==void 0&&(this.instructions.push(Me),this.hitDetectionInstructions.push(Me)),this.endGeometry(e)}drawPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_FILL_STYLE,Lt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),h=t.getStride();this.drawFlatCoordinatess_(l,0,a,h),this.endGeometry(e)}drawMultiPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_FILL_STYLE,Lt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([L.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,ce,ue]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinatess_(l,c,a[u],h);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(t!==0){const e=this.coordinates;for(let i=0,s=e.length;i<s;++i)e[i]=Ue(e[i],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}}function $c(n,t,e,i,s){const r=[];let o=e,a=0,l=t.slice(e,2);for(;a<n&&o+s<i;){const[h,c]=l.slice(-2),u=t[o+s],d=t[o+s+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=n){const g=(n-a+f)/f,m=bt(h,u,g),_=bt(c,d,g);l.push(m,_),r.push(l),l=[m,_],a==n&&(o+=s),a=0}else if(a<n)l.push(t[o+s],t[o+s+1]),o+=s;else{const g=f-a,m=bt(h,u,g/f),_=bt(c,d,g/f);l.push(m,_),r.push(l),l=[m,_],a=0,o+=s}}return a>0&&r.push(l),r}function Jc(n,t,e,i,s){let r=e,o=e,a=0,l=0,h=e,c,u,d,f,g,m,_,y,p,E;for(u=e;u<i;u+=s){const x=t[u],C=t[u+1];g!==void 0&&(p=x-g,E=C-m,f=Math.sqrt(p*p+E*E),_!==void 0&&(l+=d,c=Math.acos((_*p+y*E)/(d*f)),c>n&&(l>a&&(a=l,r=h,o=u),l=0,h=u-s)),d=f,_=p,y=E),g=x,m=C}return l+=f,l>a?[h,u]:[r,o]}const qn={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Qc extends en{constructor(t,e,i,s){super(t,e,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Lt]={fillStyle:Lt},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const 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 h=t.getType();let c=null,u=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!_t(this.maxExtent,t.getExtent()))return;let d;if(c=t.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=t.getEnds();else if(h=="Polygon")d=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){const _=t.getEndss();d=[];for(let y=0,p=_.length;y<p;++y)d.push(_[y][0])}this.beginGeometry(t,e,i);const f=o.repeat,g=f?void 0:o.textAlign;let m=0;for(let _=0,y=d.length;_<y;++_){let p;f?p=$c(f*this.resolution,c,m,d[_],u):p=[c.slice(m,d[_])];for(let E=0,x=p.length;E<x;++E){const C=p[E];let S=0,T=C.length;if(g==null){const v=Jc(o.maxAngle,C,0,C.length,2);S=v[0],T=v[1]}for(let v=S;v<T;v+=u)a.push(C[v],C[v+1]);const I=a.length;m=d[_],this.drawChars_(l,I),l=I}}this.endGeometry(e)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=t.getFlatCoordinates();break;case"LineString":c=t.getFlatMidpoint();break;case"Circle":c=t.getCenter();break;case"MultiLineString":c=t.getFlatMidpoints(),u=2;break;case"Polygon":c=t.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":const x=t.getFlatInteriorPoints();c=[];for(let C=0,S=x.length;C<S;C+=3)o.overflow||d.push(x[C+2]/this.resolution),c.push(x[C],x[C+1]);if(c.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((C,S)=>{const T=a[(x+S)*2]===c[S*u]&&a[(x+S)*2+1]===c[S*u+1];return T||--x,T})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,m=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let _=o.padding;if(_!=Ze&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],C=o.padding[1],S=o.padding[2],T=o.padding[3];o.scale[0]<0&&(C=-C,T=-T),o.scale[1]<0&&(x=-x,S=-S),_=[x,C,S,T]}const y=this.pixelRatio;this.instructions.push([L.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,_==Ze?Ze:_.map(function(x){return x*y}),g,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const p=1/y,E=g?g.slice(0):null;E&&(E[1]=Lt),this.hitDetectionInstructions.push([L.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,this.declutterMode_,this.declutterImageWithText_,_,E,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Lt:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,s=this.strokeKey_;t&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||Ji,justify:e.justify,textBaseline:e.textBaseline||Kn,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=qn[s.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([L.DRAW_CHARS,t,e,h,s.overflow,a,s.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([L.DRAW_CHARS,t,e,h,s.overflow,a&&Lt,s.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,s,r;if(!t)this.text_="";else{const o=t.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=Jt(o.getColor()||Lt)):(s=null,this.textFillState_=s);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const m=a.getLineDash(),_=a.getLineDashOffset(),y=a.getWidth(),p=a.getMiterLimit();r.lineCap=a.getLineCap()||fi,r.lineDash=m?m.slice():ce,r.lineDashOffset=_===void 0?ue:_,r.lineJoin=a.getLineJoin()||gi,r.lineWidth=y===void 0?Qi:y,r.miterLimit=p===void 0?qi:p,r.strokeStyle=Jt(a.getColor()||$i)}i=this.textState_;const l=t.getFont()||Ra;Vc(l);const h=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||Kn,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||Ze,i.scale=h===void 0?[1,1]:h;const c=t.getOffsetX(),u=t.getOffsetY(),d=t.getRotateWithView(),f=t.getKeepUpright(),g=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:X(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:"|"+X(s.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const tu={Circle:ba,Default:en,Image:Kc,LineString:Uc,Polygon:ba,Text:Qc};class eu{constructor(t,e,i,s){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const s in i){const r=i[s].finish();t[e][s]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[e];if(r===void 0){const o=tu[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[e]=r}return r}}function Le(n,t,e,i,s,r,o){r=r||[],o=o||2;let a=0;for(let l=t;l<e;l+=i){const h=n[l],c=n[l+1];r[a++]=s[0]*h+s[2]*c+s[4],r[a++]=s[1]*h+s[3]*c+s[5];for(let u=2;u<o;u++)r[a++]=n[l+u]}return r&&r.length!=a&&(r.length=a),r}function Sr(n,t,e,i,s,r,o){o=o||[];const a=Math.cos(s),l=Math.sin(s),h=r[0],c=r[1];let u=0;for(let d=t;d<e;d+=i){const f=n[d]-h,g=n[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let m=d+2;m<d+i;++m)o[u++]=n[m]}return o&&o.length!=u&&(o.length=u),o}function iu(n,t,e,i,s,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let u=t;u<e;u+=i){const d=n[u]-l,f=n[u+1]-h;a[c++]=l+s*d,a[c++]=h+r*f;for(let g=u+2;g<u+i;++g)a[c++]=n[g]}return a&&a.length!=c&&(a.length=c),a}function nu(n,t,e,i,s,r,o){o=o||[];let a=0;for(let l=t;l<e;l+=i){o[a++]=n[l]+s,o[a++]=n[l+1]+r;for(let h=l+2;h<l+i;++h)o[a++]=n[h]}return o&&o.length!=a&&(o.length=a),o}function it(n,t){if(!n)throw new Error(t)}new Array(6);function Zt(){return[1,0,0,1,0,0]}function su(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n}function mt(n,t){const e=t[0],i=t[1];return t[0]=n[0]*e+n[2]*i+n[4],t[1]=n[1]*e+n[3]*i+n[5],t}function de(n,t,e,i,s,r,o,a){const l=Math.sin(r),h=Math.cos(r);return n[0]=i*h,n[1]=s*l,n[2]=-i*l,n[3]=s*h,n[4]=o*i*h-a*i*l+t,n[5]=o*s*l+a*s*h+e,n}function Da(n,t){const e=ru(t);it(e!==0,"Transformation matrix cannot be inverted");const i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],l=t[5];return n[0]=o/e,n[1]=-s/e,n[2]=-r/e,n[3]=i/e,n[4]=(r*l-o*a)/e,n[5]=-(i*l-s*a)/e,n}function ru(n){return n[0]*n[3]-n[1]*n[2]}const ou=[1e5,1e5,1e5,1e5,2,2];function au(n){return"matrix("+n.join(", ")+")"}function Oa(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function lu(n,t){const e=Oa(n),i=Oa(t);for(let s=0;s<6;++s)if(Math.round((e[s]-i[s])*ou[s])!==0)return!1;return!0}function Ir(n,t,e,i){let s=n[t],r=n[t+1],o=0;for(let a=t+i;a<e;a+=i){const l=n[a],h=n[a+1];o+=Math.sqrt((l-s)*(l-s)+(h-r)*(h-r)),s=l,r=h}return o}function hu(n,t,e,i,s,r,o,a,l,h,c,u,d=!0){let f=n[t],g=n[t+1],m=0,_=0,y=0,p=0;function E(){m=f,_=g,t+=i,f=n[t],g=n[t+1],p+=y,y=Math.sqrt((f-m)*(f-m)+(g-_)*(g-_))}do E();while(t<e-i&&p+y<r);let x=y===0?0:(r-p)/y;const C=bt(m,f,x),S=bt(_,g,x),T=t-i,I=p,v=r+a*l(h,s,c);for(;t<e-i&&p+y<v;)E();x=y===0?0:(v-p)/y;const M=bt(m,f,x),k=bt(_,g,x);let N=!1;if(d)if(u){const W=[C,S,M,k];Sr(W,0,4,2,u,W,W),N=W[0]>W[2]}else N=C>M;const j=Math.PI,F=[],q=T+i===t;t=T,y=0,p=I,f=n[t],g=n[t+1];let b;if(q){E(),b=Math.atan2(g-_,f-m),N&&(b+=b>0?-j:j);const W=(M+C)/2,V=(k+S)/2;return F[0]=[W,V,(v-r)/2,b,s],F}s=s.replace(/\n/g," ");for(let W=0,V=s.length;W<V;){E();let Q=Math.atan2(g-_,f-m);if(N&&(Q+=Q>0?-j:j),b!==void 0){let St=Q-b;if(St+=St>j?-2*j:St<-j?2*j:0,Math.abs(St)>o)return null}b=Q;const J=W;let tt=0;for(;W<V;++W){const St=N?V-W-1:W,ne=a*l(h,s[St],c);if(t+i<e&&p+y<r+tt+ne/2)break;tt+=ne}if(W===J)continue;const R=N?s.substring(V-J,V-W):s.substring(J,W);x=y===0?0:(r+tt/2-p)/y;const Ce=bt(m,f,x),ii=bt(_,g,x);F.push([Ce,ii,tt/2,Q,R]),r+=tt}return F}class ka{constructor(){Rh(this,"pushMethodArgs_",(...t)=>(this.push_(t),this));this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(On(),{get:(t,e)=>{if(typeof On()[e]=="function")return this.push_(e),this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){const e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,s=e.length;i<s;++i){const r=e[i];if(typeof r=="function"){r(t);continue}const o=e[++i];if(typeof t[r]=="function")t[r](...o);else{if(typeof o=="function"){t[r]=o(t);continue}t[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const mi=kt(),Ae=[],fe=[],ge=[],Fe=[];function Na(n){return n[3].declutterBox}const Ga=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function vr(n,t){return t==="start"?t=Ga.test(n)?"right":"left":t==="end"&&(t=Ga.test(n)?"left":"right"),qn[t]}function cu(n,t,e){return e>0&&n.push(`
|
|
4
|
+
`,""),n.push(t,""),n}function uu(n,t,e){return e%2===0&&(n+=t),n}class du{constructor(t,e,i,s,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=Zt(),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 ka:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,s){const r=t+e+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[e],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?qn[l.justify]:vr(Array.isArray(t)?t[0]:t,l.textAlign||Ji),d=s&&o.lineWidth?o.lineWidth:0,f=Array.isArray(t)?t:String(t).split(`
|
|
5
|
+
`).reduce(cu,[]),{width:g,height:m,widths:_,heights:y,lineWidths:p}=Bc(l,f),E=g+d,x=[],C=(E+2)*c[0],S=(m+d)*c[1],T={width:C<0?Math.floor(C):Math.ceil(C),height:S<0?Math.floor(S):Math.ceil(S),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),s&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",d),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),i&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const I=.5-u;let v=u*E+I*d;const M=[],k=[];let N=0,j=0,F=0,q=0,b;for(let W=0,V=f.length;W<V;W+=2){const Q=f[W];if(Q===`
|
|
6
|
+
`){j+=N,N=0,v=u*E+I*d,++q;continue}const J=f[W+1]||l.font;J!==b&&(s&&M.push("font",J),i&&k.push("font",J),b=J),N=Math.max(N,y[F]);const tt=[Q,v+I*_[F]+u*(_[F]-p[q]),.5*(d+N)+j];v+=_[F],s&&M.push("strokeText",tt),i&&k.push("fillText",tt),++F}return Array.prototype.push.apply(x,M),Array.prototype.push.apply(x,k),this.labels_[r]=T,T}replayTextBackground_(t,e,i,s,r,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,s),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,s,r,o,a,l,h,c,u,d,f,g,m,_){a*=d[0],l*=d[1];let y=i-a,p=s-l;const E=r+h>t?t-h:r,x=o+c>e?e-c:o,C=g[3]+E*d[0]+g[1],S=g[0]+x*d[1]+g[2],T=y-g[3],I=p-g[0];(m||u!==0)&&(Ae[0]=T,Fe[0]=T,Ae[1]=I,fe[1]=I,fe[0]=T+C,ge[0]=fe[0],ge[1]=I+S,Fe[1]=ge[1]);let v;return u!==0?(v=de(Zt(),i,s,1,1,u,-i,-s),mt(v,Ae),mt(v,fe),mt(v,ge),mt(v,Fe),We(Math.min(Ae[0],fe[0],ge[0],Fe[0]),Math.min(Ae[1],fe[1],ge[1],Fe[1]),Math.max(Ae[0],fe[0],ge[0],Fe[0]),Math.max(Ae[1],fe[1],ge[1],Fe[1]),mi)):We(Math.min(T,T+C),Math.min(I,I+S),Math.max(T,T+C),Math.max(I,I+S),mi),f&&(y=Math.round(y),p=Math.round(p)),{drawImageX:y,drawImageY:p,drawImageW:E,drawImageH:x,originX:h,originY:c,declutterBox:{minX:mi[0],minY:mi[1],maxX:mi[2],maxY:mi[3],value:_},canvasTransform:v,scale:d}}replayImageOrLabel_(t,e,i,s,r,o,a){const l=!!(o||a),h=s.declutterBox,c=a?a[2]*s.scale[0]/2:0;return h.minX-c<=e[0]&&h.maxX+c>=0&&h.minY-c<=e[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(t,Ae,fe,ge,Fe,o,a),Yc(t,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=mt(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;t.save(),t.translate(i[0]%s,i[1]%s),e!==1&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,s){const r=this.textStates[e],o=this.createLabel(t,e,s,i),a=this.strokeStates[i],l=this.pixelRatio,h=vr(Array.isArray(t)?t[0]:t,r.textAlign||Ji),c=qn[r.textBaseline||Kn],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,s,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&oe(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Le(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),su(this.renderedTransform_,i));let u=0;const d=s.length;let f=0,g,m,_,y,p,E,x,C,S,T,I,v,M,k=0,N=0;const j=this.coordinateCache_,F=this.viewRotation_,q=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,b={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:F},W=this.instructions!=s||this.overlaps?0:200;let V,Q,J,tt;for(;u<d;){const R=s[u];switch(R[0]){case L.BEGIN_GEOMETRY:V=R[1],tt=R[3],V.getGeometry()?a!==void 0&&!_t(a,tt.getExtent())?u=R[2]+1:++u:u=R[2],h&&(h.zIndex=R[4]);break;case L.BEGIN_PATH:k>W&&(this.fill_(t),k=0),N>W&&(t.stroke(),N=0),!k&&!N&&(t.beginPath(),p=NaN,E=NaN),++u;break;case L.CIRCLE:f=R[1];const ii=c[f],St=c[f+1],ne=c[f+2],$t=c[f+3],Ne=ne-ii,In=$t-St,se=Math.sqrt(Ne*Ne+In*In);t.moveTo(ii+se,St),t.arc(ii,St,se,0,2*Math.PI,!0),++u;break;case L.CLOSE_PATH:t.closePath(),++u;break;case L.CUSTOM:f=R[1],g=R[2];const c_=R[3],u_=R[4],yh=R[5];b.geometry=c_,b.feature=V,u in j||(j[u]=[]);const vn=j[u];yh?yh(c,f,g,2,vn):(vn[0]=c[f],vn[1]=c[f+1],vn.length=2),h&&(h.zIndex=R[6]),u_(vn,b),++u;break;case L.DRAW_IMAGE:f=R[1],g=R[2],S=R[3],m=R[4],_=R[5];let Ao=R[6];const d_=R[7],f_=R[8],g_=R[9],ph=R[10];let Fo=R[11];const __=R[12];let Ms=R[13];y=R[14]||"declutter";const Rn=R[15];if(!S&&R.length>=20){T=R[19],I=R[20],v=R[21],M=R[22];const Wt=this.drawLabelWithPointPlacement_(T,I,v,M);S=Wt.label,R[3]=S;const ni=R[23];m=(Wt.anchorX-ni)*this.pixelRatio,R[4]=m;const jt=R[24];_=(Wt.anchorY-jt)*this.pixelRatio,R[5]=_,Ao=S.height,R[6]=Ao,Ms=S.width,R[13]=Ms}let bo;R.length>25&&(bo=R[25]);let Do,Ls,As;R.length>17?(Do=R[16],Ls=R[17],As=R[18]):(Do=Ze,Ls=null,As=null),ph&&q?Fo+=F:!ph&&!q&&(Fo-=F);let m_=0;for(;f<g;f+=2){if(bo&&bo[m_++]<Ms/this.pixelRatio)continue;const Wt=this.calculateImageOrLabelDimensions_(S.width,S.height,c[f],c[f+1],Ms,Ao,m,_,f_,g_,Fo,__,r,Do,!!Ls||!!As,V),ni=[t,e,S,Wt,d_,Ls,As];if(l){let jt,re,Vt;if(Rn){const st=g-f;if(!Rn[st]){Rn[st]={args:ni,declutterMode:y};continue}const Tt=Rn[st];jt=Tt.args,re=Tt.declutterMode,delete Rn[st],Vt=Na(jt)}let we,Se;if(jt&&(re!=="declutter"||!l.collides(Vt))&&(we=!0),(y!=="declutter"||!l.collides(Wt.declutterBox))&&(Se=!0),re==="declutter"&&y==="declutter"){const st=we&&Se;we=st,Se=st}we&&(re!=="none"&&l.insert(Vt),this.replayImageOrLabel_.apply(this,jt)),Se&&(y!=="none"&&l.insert(Wt.declutterBox),this.replayImageOrLabel_.apply(this,ni))}else this.replayImageOrLabel_.apply(this,ni)}++u;break;case L.DRAW_CHARS:const xh=R[1],Eh=R[2],Oo=R[3],y_=R[4];M=R[5];const p_=R[6],Ch=R[7],wh=R[8];v=R[9];const ko=R[10];T=R[11],Array.isArray(T)&&(T=T.reduce(uu,"")),I=R[12];const Sh=[R[13],R[13]];y=R[14]||"declutter";const x_=R[15],No=this.textStates[I],Tn=No.font,Pn=[No.scale[0]*Ch,No.scale[1]*Ch];let Mn;Tn in this.widths_?Mn=this.widths_[Tn]:(Mn={},this.widths_[Tn]=Mn);const Ih=Ir(c,xh,Eh,2),vh=Math.abs(Pn[0])*La(Tn,T,Mn);if(y_||vh<=Ih){const Wt=this.textStates[I].textAlign,ni=(Ih-vh)*vr(T,Wt),jt=hu(c,xh,Eh,2,T,ni,p_,Math.abs(Pn[0]),La,Tn,Mn,q?0:this.viewRotation_,x_);t:if(jt){const re=[];let Vt,we,Se,st,Tt;if(v)for(Vt=0,we=jt.length;Vt<we;++Vt){Tt=jt[Vt],Se=Tt[4],st=this.createLabel(Se,I,"",v),m=Tt[2]+(Pn[0]<0?-ko:ko),_=Oo*st.height+(.5-Oo)*2*ko*Pn[1]/Pn[0]-wh;const Ie=this.calculateImageOrLabelDimensions_(st.width,st.height,Tt[0],Tt[1],st.width,st.height,m,_,0,0,Tt[3],Sh,!1,Ze,!1,V);if(l&&y==="declutter"&&l.collides(Ie.declutterBox))break t;re.push([t,e,st,Ie,1,null,null])}if(M)for(Vt=0,we=jt.length;Vt<we;++Vt){Tt=jt[Vt],Se=Tt[4],st=this.createLabel(Se,I,M,""),m=Tt[2],_=Oo*st.height-wh;const Ie=this.calculateImageOrLabelDimensions_(st.width,st.height,Tt[0],Tt[1],st.width,st.height,m,_,0,0,Tt[3],Sh,!1,Ze,!1,V);if(l&&y==="declutter"&&l.collides(Ie.declutterBox))break t;re.push([t,e,st,Ie,1,null,null])}l&&y!=="none"&&l.load(re.map(Na));for(let Ie=0,E_=re.length;Ie<E_;++Ie)this.replayImageOrLabel_.apply(this,re[Ie])}}++u;break;case L.END_GEOMETRY:if(o!==void 0){V=R[1];const Wt=o(V,tt,y);if(Wt)return Wt}++u;break;case L.FILL:W?k++:this.fill_(t),++u;break;case L.MOVE_TO_LINE_TO:for(f=R[1],g=R[2],Q=c[f],J=c[f+1],t.moveTo(Q,J),p=Q+.5|0,E=J+.5|0,f+=2;f<g;f+=2)Q=c[f],J=c[f+1],x=Q+.5|0,C=J+.5|0,(f==g-2||x!==p||C!==E)&&(t.lineTo(Q,J),p=x,E=C);++u;break;case L.SET_FILL_STYLE:this.alignAndScaleFill_=R[2],k&&(this.fill_(t),k=0,N&&(t.stroke(),N=0)),t.fillStyle=R[1],++u;break;case L.SET_STROKE_STYLE:N&&(t.stroke(),N=0),this.setStrokeStyle_(t,R),++u;break;case L.STROKE:W?N++:t.stroke(),++u;break;default:++u;break}}k&&this.fill_(t),N&&t.stroke()}execute(t,e,i,s,r,o){this.viewRotation_=s,this.execute_(t,e,i,this.instructions,r,void 0,void 0,o)}executeHitDetection(t,e,i,s,r){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,s,r)}}const He=["Polygon","Circle","LineString","Image","Text","Default"],za=["Image","Text"],fu=He.filter(n=>!za.includes(n));class gu{constructor(t,e,i,s,r,o,a){this.maxExtent_=t,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Zt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(const i in t){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=t[i];for(const o in r){const a=r[o];s[o]=new du(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let s=0,r=t.length;s<r;++s)if(t[s]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,s,r,o){s=Math.round(s);const a=s*2+1,l=de(this.hitDetectionTransform_,s+.5,s+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=ft(a,a));const c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=kt(),Wi(u,t),Oi(u,e*(this.renderBuffer_+s),u));const d=_u(s);let f;function g(C,S,T){const I=c.getImageData(0,0,a,a).data;for(let v=0,M=d.length;v<M;v++)if(I[d[v]]>0){if(!o||T==="none"||f!=="Image"&&f!=="Text"||o.includes(C)){const k=(d[v]-3)/4,N=s-k%a,j=s-(k/a|0),F=r(C,S,N*N+j*j);if(F)return F}c.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(Ge);let _,y,p,E,x;for(_=m.length-1;_>=0;--_){const C=m[_].toString();for(p=this.executorsByZIndex_[C],y=He.length-1;y>=0;--y)if(f=He[y],E=p[f],E!==void 0&&(x=E.executeHitDetection(c,l,i,g,u),x))return x}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],s=e[1],r=e[2],o=e[3],a=[i,s,i,o,r,o,r,s];return Le(a,0,8,2,t,a),a}isEmpty(){return Xe(this.executorsByZIndex_)}execute(t,e,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?Ph:Ge),o=o||He;const h=He.length;for(let c=0,u=l.length;c<u;++c){const d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,m=o.length;g<m;++g){const _=o[g],y=f[_];if(y!==void 0){const p=a===null?void 0:y.getZIndexContext(),E=p?p.getContext():t,x=this.maxExtent_&&_!=="Image"&&_!=="Text";if(x&&(E.save(),this.clip(E,i)),!p||_==="Text"||_==="Image"?y.execute(E,e,i,s,r,a):p.pushFunction(C=>y.execute(C,e,i,s,r,a)),x&&E.restore(),p){p.offset();const C=l[c]*h+He.indexOf(_);this.deferredZIndexContexts_[C]||(this.deferredZIndexContexts_[C]=[]),this.deferredZIndexContexts_[C].push(p)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(Ge);for(let i=0,s=e.length;i<s;++i)t[e[i]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const Rr={};function _u(n){if(Rr[n]!==void 0)return Rr[n];const t=n*2+1,e=n*n,i=new Array(e+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*t+(n+o))*4+3),r>0&&l.push(((n-r)*t+(n+o))*4+3),o>0&&(l.push(((n+r)*t+(n-o))*4+3),r>0&&l.push(((n-r)*t+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;r<o;++r)i[r]&&s.push(...i[r]);return Rr[n]=s,s}function Wa(n){return n[0]>0&&n[1]>0}function yi(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}class $n{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=yi(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new $n({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return O()}getImage(t){return O()}getHitDetectionImage(){return O()}getPixelRatio(t){return 1}getImageState(){return O()}getImageSize(){return O()}getOrigin(){return O()}getSize(){return O()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=yi(t)}listenImageChange(t){O()}load(){O()}unlistenImageChange(t){O()}ready(){return Promise.resolve()}}class Jn extends $n{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?P.LOADING:P.LOADED,this.imageState_===P.LOADING&&this.ready().then(()=>this.imageState_=P.LOADED),this.render()}clone(){const t=this.getScale(),e=new Jn({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){var r,o;const e=(r=this.fill_)==null?void 0:r.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let s=(o=zt.get(i,null,null))==null?void 0:o.getImage(1);if(!s){const a=this.renderOptions_,l=Math.ceil(a.size*t),h=ft(l,l);this.draw_(a,h,t),s=h.canvas,zt.set(i,null,null,new Ca(s,void 0,null,P.LOADED,null))}return s}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let s=this.radius,r=this.radius2_===void 0?s:this.radius2_;if(s<r){const S=s;s=r,r=S}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=s-h,u=Math.sqrt(l*l+c*c),d=u/l;if(t==="miter"&&d<=i)return d*e;const f=e/2/d,g=e/2*(c/u),_=Math.sqrt((s+f)*(s+f)+g*g)-s;if(this.radius2_===void 0||t==="bevel")return _*2;const y=s*Math.sin(a),p=Math.sqrt(s*s-y*y),E=r-p,C=Math.sqrt(y*y+E*E)/y;if(C<=i){const S=C*e/2-r-s;return 2*Math.max(_,S)}return _*2}createRenderOptions(){let t=fi,e=gi,i=0,s=null,r=0,o,a=0;this.stroke_&&(o=Jt(this.stroke_.getColor()??$i),a=this.stroke_.getWidth()??Qi,s=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??gi,t=this.stroke_.getLineCap()??fi,i=this.stroke_.getMiterLimit()??qi);const l=this.calculateLineJoinSize_(e,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:t,lineDash:s,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let s=this.fill_.getColor();s===null&&(s=Lt),e.fillStyle=Jt(s),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),s=0;typeof i=="string"&&(i=ui(i)),i===null?s=1:Array.isArray(i)&&(s=i.length===4?i[3]:1),s===0&&(e=ft(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{const s=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let a=0;a<e;a++){const l=r+a*o,h=a%2===0?i:s;t.lineTo(h*Math.cos(l),h*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Lt,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class nn extends Jn{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new nn({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}setRadius(t){this.radius=t,this.render()}}class yt{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){const t=this.getColor();return new yt({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){const e=mr(null,t.src,"anonymous",void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===P.IDLE&&e.load(),e.getImageState()===P.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?X(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:ui(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function ja(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}class Qn extends $n{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,s=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:s,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;const o=t.img!==void 0?t.img:null;let a=t.src;it(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||X(o)),it(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),it(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=P.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?P.LOADED:P.IDLE:l=P.LOADING:l=P.LOADED),this.color_=t.color!==void 0?ui(t.color):null,this.iconImage_=mr(o,a,this.crossOrigin_,l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let h,c;if(t.size)[h,c]=t.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(ja(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(ja(h,c,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new Qn({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=s[0]),this.anchorYUnits_=="fraction"&&(t[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+s[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==P.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){const t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==P.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(D.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(D.CHANGE,t)}ready(){return this.iconImage_.ready()}}class Qt{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){const t=this.getColor();return new Qt({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}}class at{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Xa,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new at({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=Xa,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function mu(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(it(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}let Tr=null;function Va(n,t){if(!Tr){const e=new yt({color:"rgba(255,255,255,0.4)"}),i=new Qt({color:"#3399CC",width:1.25});Tr=[new at({image:new nn({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return Tr}function Pr(){const n={},t=[255,255,255,1],e=[0,153,255,1],i=3;return n.Polygon=[new at({fill:new yt({color:[255,255,255,.5]})})],n.MultiPolygon=n.Polygon,n.LineString=[new at({stroke:new Qt({color:t,width:i+2})}),new at({stroke:new Qt({color:e,width:i})})],n.MultiLineString=n.LineString,n.Circle=n.Polygon.concat(n.LineString),n.Point=[new at({image:new nn({radius:i*2,fill:new yt({color:e}),stroke:new Qt({color:t,width:i/2})}),zIndex:1/0})],n.MultiPoint=n.Point,n.GeometryCollection=n.Polygon.concat(n.LineString,n.Point),n}function Xa(n){return n.getGeometry()}const yu="#333";class qe{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=yi(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new yt({color:yu}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new qe({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=yi(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}const Ba=Zt(),pu=[NaN,NaN];class Ya extends Yt{constructor(){super(),this.extent_=kt(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=ma((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return O()}closestPointXY(t,e,i,s){return O()}containsXY(t,e){return this.closestPointXY(t,e,pu,Number.MIN_VALUE)===0}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return O()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Ni(e),this.extentRevision_=this.getRevision()}return bh(this.extent_,t)}rotate(t,e){O()}scale(t,e,i){O()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return O()}getType(){return O()}applyTransform(t){O()}intersectsExtent(t){return O()}translate(t,e){O()}transform(t,e){const i=ot(t),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=dt(h)/dt(l);de(Ba,h[0],h[3],c,-c,0,0,0);const u=Le(r,0,r.length,a,Ba,o),d=Xi(i,e);return d?d(u,u,a):u}:Xi(i,e);return this.applyTransform(s),this}}class be extends Ya{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Os(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return O()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=ts(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){O()}setLayout(t,e,i){let s;if(t)s=ts(t);else{for(let r=0;r<i;++r){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}s=e.length,t=$e(s)}this.layout=t,this.stride=s}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();Sr(i,0,i.length,s,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=Xt(this.getExtent()));const s=this.getFlatCoordinates();if(s){const r=this.getStride();iu(s,0,s.length,r,t,e,i,s),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();nu(i,0,i.length,s,t,e,i),this.changed()}}}function $e(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function ts(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function xu(n,t,e){const i=n.getFlatCoordinates();if(!i)return null;const s=n.getStride();return Le(i,0,i.length,s,t,e)}class Eu extends wa{constructor(t,e,i,s,r,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=s,this.transformRotation_=s?Fn(Math.atan2(s[1],s[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=Zt()}drawImages_(t,e,i,s){if(!this.image_)return;const r=Le(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=r.length;c<u;c+=2){const d=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,m=f+this.imageAnchorY_;de(a,g,m,1,1,h,-g,-m),o.save(),o.transform.apply(o,a),o.translate(g,m),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(t,e,i,s){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Le(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=s){const l=r[e]+this.textOffsetX_,h=r[e+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(t,e,i,s,r){const o=this.context_,a=Le(t,e,i,s,this.transform_,this.pixelCoordinates_);o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let h=2;h<l;h+=2)o.lineTo(a[h],a[h+1]);return r&&o.closePath(),i}drawRings_(t,e,i,s){for(let r=0,o=i.length;r<o;++r)e=this.moveToLineTo_(t,e,i[r],s,!0);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!_t(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=xu(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],s=e[3]-e[1],r=Math.sqrt(i*i+s*s),o=this.context_;o.beginPath(),o.arc(e[0],e[1],r,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break}}drawFeature(t,e){const i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let i=0,s=e.length;i<s;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!_t(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1),e.stroke()}if(this.text_!==""){const e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getExtent();if(_t(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const i=this.context_,s=t.getFlatCoordinates();let r=0;const o=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)r=this.moveToLineTo_(s,r,o[l],a,!1);i.stroke()}if(this.text_!==""){const i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!_t(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride()),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!_t(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getOrientedFlatCoordinates();let s=0;const r=t.getEndss(),o=t.getStride();e.beginPath();for(let a=0,l=r.length;a<l;++a){const h=r[a];s=this.drawRings_(i,s,h,o)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){const e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),oe(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){const e=this.context_,i=this.contextTextState_,s=t.textAlign?t.textAlign:Ji;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=s&&(i.textAlign=s,e.textAlign=s),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=s,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:s,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{const i=t.getColor();this.fillState_={fillStyle:Jt(i||Lt)}}if(!e)this.strokeState_=null;else{const i=e.getColor(),s=e.getLineCap(),r=e.getLineDash(),o=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),h=e.getMiterLimit(),c=r||ce;this.strokeState_={lineCap:s!==void 0?s:fi,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||ue)*this.pixelRatio_,lineJoin:a!==void 0?a:gi,lineWidth:(l!==void 0?l:Qi)*this.pixelRatio_,miterLimit:h!==void 0?h:qi,strokeStyle:Jt(i||$i)}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),s=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{const e=t.getFill();if(!e)this.textFillState_=null;else{const f=e.getColor();this.textFillState_={fillStyle:Jt(f||Lt)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),m=i.getLineDash(),_=i.getLineDashOffset(),y=i.getLineJoin(),p=i.getWidth(),E=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:fi,lineDash:m||ce,lineDashOffset:_||ue,lineJoin:y!==void 0?y:gi,lineWidth:p!==void 0?p:Qi,miterLimit:E!==void 0?E:qi,strokeStyle:Jt(f||$i)}}const s=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:s!==void 0?s:Ra,textAlign:u!==void 0?u:Ji,textBaseline:d!==void 0?d:Kn},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,m)=>f+=m%2?" ":g,""):c:"",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_*h[0],this.pixelRatio_*h[1]]}}}const te=.5;function Cu(n,t,e,i,s,r,o,a,l){const h=s,c=n[0]*te,u=n[1]*te,d=ft(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new Eu(d,te,s,null,o,a,null),m=e.length,_=Math.floor((256*256*256-1)/m),y={};for(let E=1;E<=m;++E){const x=e[E-1],C=x.getStyleFunction()||i;if(!C)continue;let S=C(x,r);if(!S)continue;Array.isArray(S)||(S=[S]);const I=(E*_).toString(16).padStart(7,"#00000");for(let v=0,M=S.length;v<M;++v){const k=S[v],N=k.getGeometryFunction()(x);if(!N||!_t(h,N.getExtent()))continue;const j=k.clone(),F=j.getFill();F&&F.setColor(I);const q=j.getStroke();q&&(q.setColor(I),q.setLineDash(null)),j.setText(void 0);const b=k.getImage();if(b){const J=b.getImageSize();if(!J)continue;const tt=ft(J[0],J[1],void 0,{alpha:!1}),R=tt.canvas;tt.fillStyle=I,tt.fillRect(0,0,R.width,R.height),j.setImage(new Qn({img:R,anchor:b.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:b.getOrigin(),opacity:1,size:b.getSize(),scale:b.getScale(),rotation:b.getRotation(),rotateWithView:b.getRotateWithView()}))}const W=j.getZIndex()||0;let V=y[W];V||(V={},y[W]=V,V.Polygon=[],V.Circle=[],V.LineString=[],V.Point=[]);const Q=N.getType();if(Q==="GeometryCollection"){const J=N.getGeometriesArrayRecursive();for(let tt=0,R=J.length;tt<R;++tt){const Ce=J[tt];V[Ce.getType().replace("Multi","")].push(Ce,j)}}else V[Q.replace("Multi","")].push(N,j)}}const p=Object.keys(y).map(Number).sort(Ge);for(let E=0,x=p.length;E<x;++E){const C=y[p[E]];for(const S in C){const T=C[S];for(let I=0,v=T.length;I<v;I+=2){g.setStyle(T[I+1]);for(let M=0,k=t.length;M<k;++M)g.setTransform(t[M]),g.drawGeometry(T[I])}}}return d.getImageData(0,0,f.width,f.height)}function wu(n,t,e){const i=[];if(e){const s=Math.floor(Math.round(n[0])*te),r=Math.floor(Math.round(n[1])*te),o=(rt(s,0,e.width-1)+rt(r,0,e.height-1)*e.width)*4,a=e.data[o],l=e.data[o+1],c=e.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/t.length);c&&c%u===0&&i.push(t[c/u-1])}return i}const Su=.5,Za={Point:Au,LineString:Pu,Polygon:bu,MultiPoint:Fu,MultiLineString:Mu,MultiPolygon:Lu,GeometryCollection:Tu,Circle:vu};function Iu(n,t){return parseInt(X(n),10)-parseInt(X(t),10)}function Ka(n,t){const e=Ua(n,t);return e*e}function Ua(n,t){return Su*n/t}function vu(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i)}}function Ha(n,t,e,i,s,r,o,a){const l=[],h=e.getImage();if(h){let d=!0;const f=h.getImageState();f==P.LOADED||f==P.ERROR?d=!1:f==P.IDLE&&h.load(),d&&l.push(h.ready())}const c=e.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>s(null)),Ru(n,t,e,i,r,o,a),u}function Ru(n,t,e,i,s,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,s);if(e.getRenderer())qa(n,l,e,t,o);else{const c=Za[l.getType()];c(n,l,e,t,o,r)}}function qa(n,t,e,i,s){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)qa(n,o[a],e,i,s);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),s)}function Tu(n,t,e,i,s,r){const o=t.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=Za[o[a].getType()];h(n,o[a],e,i,s,r)}}function Pu(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function Mu(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function Lu(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(o||r){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}function Au(n,t,e,i,s,r){const o=e.getImage(),a=e.getText(),l=a&&a.getText(),h=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=P.LOADED)return;const c=n.getBuilder(e.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(t,i,s)}if(l){const c=n.getBuilder(e.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(t,i,s)}}function Fu(n,t,e,i,s,r){const o=e.getImage(),a=o&&o.getOpacity()!==0,l=e.getText(),h=l&&l.getText(),c=r&&a&&h?{}:void 0;if(a){if(o.getImageState()!=P.LOADED)return;const u=n.getBuilder(e.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(t,i,s)}if(h){const u=n.getBuilder(e.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(t,i,s)}}function bu(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}class $a extends Mt{constructor(t,e,i,s){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=s}}const Du=5;class Ou extends Hi{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=Du}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return O()}getData(t){return null}prepareFrame(t){return O()}renderFrame(t,e){return O()}forEachFeatureAtCoordinate(t,e,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===P.LOADED||e.getState()===P.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=P.LOADED&&e!=P.ERROR&&t.addEventListener(D.CHANGE,this.boundHandleImageChange_),e==P.IDLE&&(t.load(),e=t.getState()),e==P.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Ja=[];let pi=null;function ku(){pi=ft(1,1,void 0,{willReadFrequently:!0})}class Qa extends Ou{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=Zt(),this.pixelTransform=Zt(),this.inversePixelTransform=Zt(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){pi||ku(),pi.clearRect(0,0,1,1);let s;try{pi.drawImage(t,e,i,1,1,0,0,1,1),s=pi.getImageData(0,0,1,1).data}catch{return pi=null,null}return s}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i){const s=this.getLayer().getClassName();let r,o;if(t&&t.className===s&&(!i||t&&t.style.backgroundColor&&oe(ui(t.style.backgroundColor),ui(i)))){const a=t.firstElementChild;a instanceof HTMLCanvasElement&&(o=a.getContext("2d"))}if(o&&lu(o.canvas.style.transform,e)?(this.container=t,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=document.createElement("div"),r.className=s;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=ft();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){const s=An(i),r=zs(i),o=Ns(i),a=ks(i);mt(e.coordinateToPixelTransform,s),mt(e.coordinateToPixelTransform,r),mt(e.coordinateToPixelTransform,o),mt(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;mt(l,s),mt(l,r),mt(l,o),mt(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()}prepareContainer(t,e){const i=t.extent,s=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,a=Math.round(K(i)/s*o),l=Math.round(dt(i)/s*o);de(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),Da(this.inversePixelTransform,this.pixelTransform);const h=au(this.pixelTransform);if(this.useContainer(e,h,this.getBackground(t)),!this.containerReused){const c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(t,e,i){const s=this.getLayer();if(s.hasListener(t)){const r=new $a(t,this.inversePixelTransform,i,e);s.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Gt.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Gt.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new ka),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Gt.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Gt.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,s,r,o,a){const l=r/2,h=o/2,c=s/e,u=-c,d=-t[0]+a,f=-t[1];return de(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class Nu extends Qa{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=kt(),this.wrappedRenderedExtent_=kt(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,i){const s=e.extent,r=e.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,m=!(g[et.ANIMATING]||g[et.INTERACTING]),_=this.context,y=Math.round(K(s)/a*f),p=Math.round(dt(s)/a*f),E=u.getWrapX()&&l.canWrapX(),x=E?K(c):null,C=E?Math.ceil((s[2]-c[2])/x)+1:1;let S=E?Math.floor((s[0]-c[0])/x):0;do{let T=this.getRenderTransform(o,a,0,f,y,p,S*x);e.declutter&&(T=T.slice(0)),t.execute(_,[_.canvas.width,_.canvas.height],T,h,m,i===void 0?He:i?za:fu,i?d&&e.declutter[d]:void 0)}while(++S<C)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=ft(this.context.canvas.width,this.context.canvas.height,Ja))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,Zs(this.context),Ja.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(t,e){const i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;const s=t.viewState;this.prepareContainer(t,e);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Gt.PRERENDER)||this.getLayer().hasListener(Gt.POSTRENDER)))return this.container;if(this.setDrawContext_(),this.preRender(r,t),s.projection,this.clipped_=!1,a&&i.extent&&this.clipping){const l=Te(i.extent);a=_t(l,t.extent),this.clipped_=a&&!ae(l,t.extent),this.clipped_&&this.clipUnrotated(r,t,l)}return a&&this.renderWorlds(o,t,this.getLayer().getDeclutter()?!1:void 0),!t.declutter&&this.clipped_&&r.restore(),this.postRender(r,t),this.renderedRotation_!==s.rotation&&(this.renderedRotation_=s.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*te,d=i[1]*te;c.push(this.getRenderTransform(s,r,o,te,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!ae(g,l)){let m=l[0];const _=K(g);let y=0,p;for(;m<g[0];)--y,p=_*y,c.push(this.getRenderTransform(s,r,o,te,u,d,p).slice()),m+=_;for(y=0,m=l[2];m>g[2];)++y,p=_*y,c.push(this.getRenderTransform(s,r,o,te,u,d,p).slice()),m-=_}this.hitDetectionImageData_=Cu(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,Ka(r,this.renderedPixelRatio_))}e(wu(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,s,r){var d,f;if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(g,m,_){const y=X(g),p=h[y];if(p){if(p!==!0&&_<p.distanceSq){if(_===0)return h[y]=!0,r.splice(r.lastIndexOf(p),1),s(g,l,m);p.geometry=m,p.distanceSq=_}}else{if(_===0)return h[y]=!0,s(g,l,m);r.push(h[y]={feature:g,layer:l,geometry:m,distanceSq:_,callback:s})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,u?(f=(d=e.declutter)==null?void 0:d[u])==null?void 0:f.all().map(g=>g.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const s=t.viewHints[et.ANIMATING],r=t.viewHints[et.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,h=t.viewState,c=h.projection,u=h.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let m=e.getRenderOrder();m===void 0&&(m=Iu);const _=h.center.slice(),y=Oi(l,g*u),p=y.slice(),E=[y.slice()],x=c.getExtent();if(i.getWrapX()&&c.canWrapX()&&!ae(x,t.extent)){const F=K(x),q=Math.max(K(y)/2,F);y[0]=x[0]-q,y[2]=x[2]+q,Bo(_,c);const b=Vo(E[0],c);b[0]<x[0]&&b[2]<x[2]?E.push([b[0]+F,b[1],b[2]+F,b[3]]):b[0]>x[0]&&b[2]>x[2]&&E.push([b[0]-F,b[1],b[2]-F,b[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!t.declutter&&ae(this.wrappedRenderedExtent_,y))return oe(this.renderedExtent_,p)||(this.hitDetectionImageData_=null,this.renderedExtent_=p),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const C=new eu(Ua(u,d),y,u,d);let S;for(let F=0,q=E.length;F<q;++F)i.loadFeatures(E[F],u,c);const T=Ka(u,d);let I=!0;const v=(F,q)=>{let b;const W=F.getStyleFunction()||e.getStyleFunction();if(W&&(b=W(F,u)),b){const V=this.renderFeature(F,T,b,C,S,this.getLayer().getDeclutter(),q);I=I&&!V}},M=Vn(y),k=i.getFeaturesInExtent(M);m&&k.sort(m);for(let F=0,q=k.length;F<q;++F)v(k[F],F);this.renderedFeatures_=k,this.ready=I;const N=C.finish(),j=new gu(y,u,d,i.getOverlaps(),N,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=p,this.wrappedRenderedExtent_=y,this.renderedCenter_=_,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=j,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,s,r,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=Ha(s,t,i[h],e,this.boundHandleStyleImageChange_,r,o,a)||l;else l=Ha(s,t,i,e,this.boundHandleStyleImageChange_,r,o,a);return l}}function tl(n,t,e=0,i=n.length-1,s=Gu){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),g=Math.min(i,Math.floor(t+(l-h)*u/l+d));tl(n,t,f,g,s)}const r=n[t];let o=e,a=i;for(sn(n,e,t),s(n[i],r)>0&&sn(n,e,i);o<a;){for(sn(n,o,a),o++,a--;s(n[o],r)<0;)o++;for(;s(n[a],r)>0;)a--}s(n[e],r)===0?sn(n,e,a):(a++,sn(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function sn(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function Gu(n,t){return n<t?-1:n>t?1:0}let el=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!is(t,e))return i;const s=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;is(t,l)&&(e.leaf?i.push(a):Lr(t,l)?this._all(a,i):r.push(a))}e=r.pop()}return i}collides(t){let e=this.data;if(!is(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const r=e.children[s],o=e.leaf?this.toBBox(r):r;if(is(t,o)){if(e.leaf||Lr(t,o))return!0;i.push(r)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Ei([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),r=[],o=[];let a,l,h;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),i.leaf){const c=zu(t,i.children,e);if(c!==-1)return i.children.splice(c,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&Lr(i,s)?(r.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const r=i-e+1;let o=this._maxEntries,a;if(r<=o)return a=Ei(t.slice(e,i+1)),xi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,s-1))),a=Ei([]),a.leaf=!1,a.height=s;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));il(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);il(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return xi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let r=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=Mr(h),u=Vu(t,h)-c;u<o?(o=u,r=c<r?c:r,a=h):u===o&&c<r&&(r=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),r=[],o=this._chooseSubtree(s,this.data,e,r);for(o.children.push(t),on(o,s);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)}_split(t,e){const i=t[e],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=Ei(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,xi(i,this.toBBox),xi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Ei([t,e]),this.data.height=t.height+1,this.data.leaf=!1,xi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=rn(t,0,a,this.toBBox),h=rn(t,a,i,this.toBBox),c=Xu(l,h),u=Mr(l)+Mr(h);c<r?(r=c,s=a,o=u<o?u:o):c===r&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:Wu,r=t.leaf?this.compareMinY:ju,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,r);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const r=this.toBBox,o=rn(t,0,e,r),a=rn(t,i-e,i,r);let l=es(o)+es(a);for(let h=e;h<i-e;h++){const c=t.children[h];on(o,t.leaf?r(c):c),l+=es(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];on(a,t.leaf?r(c):c),l+=es(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)on(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():xi(t[e],this.toBBox)}};function zu(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i<t.length;i++)if(e(n,t[i]))return i;return-1}function xi(n,t){rn(n,0,n.children.length,t,n)}function rn(n,t,e,i,s){s||(s=Ei(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=t;r<e;r++){const o=n.children[r];on(s,n.leaf?i(o):o)}return s}function on(n,t){return n.minX=Math.min(n.minX,t.minX),n.minY=Math.min(n.minY,t.minY),n.maxX=Math.max(n.maxX,t.maxX),n.maxY=Math.max(n.maxY,t.maxY),n}function Wu(n,t){return n.minX-t.minX}function ju(n,t){return n.minY-t.minY}function Mr(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function es(n){return n.maxX-n.minX+(n.maxY-n.minY)}function Vu(n,t){return(Math.max(t.maxX,n.maxX)-Math.min(t.minX,n.minX))*(Math.max(t.maxY,n.maxY)-Math.min(t.minY,n.minY))}function Xu(n,t){const e=Math.max(n.minX,t.minX),i=Math.max(n.minY,t.minY),s=Math.min(n.maxX,t.maxX),r=Math.min(n.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,r-i)}function Lr(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function is(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function Ei(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function il(n,t,e,i,s){const r=[t,e];for(;r.length;){if(e=r.pop(),t=r.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;tl(n,o,t,e,s),r.push(t,o,o,e)}}let Je=0;const vt=1<<Je++,Y=1<<Je++,At=1<<Je++,Kt=1<<Je++,Qe=1<<Je++,an=1<<Je++,ns=Math.pow(2,Je)-1,Ar={[vt]:"boolean",[Y]:"number",[At]:"string",[Kt]:"color",[Qe]:"number[]",[an]:"size"},Bu=Object.keys(Ar).map(Number).sort(Ge);function Yu(n){return n in Ar}function ln(n){const t=[];for(const e of Bu)hn(n,e)&&t.push(Ar[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function hn(n,t){return(n&t)===t}function De(n,t){return n===t}class lt{constructor(t,e){if(!Yu(t))throw new Error(`literal expressions must have a specific type, got ${ln(t)}`);this.type=t,this.value=e}}class Zu{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function nl(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function pt(n,t,e){switch(typeof n){case"boolean":{if(De(t,At))return new lt(At,n?"true":"false");if(!hn(t,vt))throw new Error(`got a boolean, but expected ${ln(t)}`);return new lt(vt,n)}case"number":{if(De(t,an))return new lt(an,yi(n));if(De(t,vt))return new lt(vt,!!n);if(De(t,At))return new lt(At,n.toString());if(!hn(t,Y))throw new Error(`got a number, but expected ${ln(t)}`);return new lt(Y,n)}case"string":{if(De(t,Kt))return new lt(Kt,ur(n));if(De(t,vt))return new lt(vt,!!n);if(!hn(t,At))throw new Error(`got a string, but expected ${ln(t)}`);return new lt(At,n)}}if(!Array.isArray(n))throw new Error("expression must be an array or a primitive value");if(n.length===0)throw new Error("empty expression");if(typeof n[0]=="string")return nd(n,t,e);for(const i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(De(t,an)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new lt(an,n)}if(De(t,Kt)){if(n.length===3)return new lt(Kt,[...n,1]);if(n.length===4)return new lt(Kt,n);throw new Error(`expected an array of 3 or 4 values for a color, got ${n.length}`)}if(!hn(t,Qe))throw new Error(`got an array of numbers, but expected ${ln(t)}`);return new lt(Qe,n)}const w={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},Ku={[w.Get]:A(G(1,1/0),sl),[w.Var]:A(G(1,1),Uu),[w.Has]:A(G(1,1/0),sl),[w.Id]:A(Hu,Ci),[w.Concat]:A(G(2,1/0),Z(At)),[w.GeometryType]:A(qu,Ci),[w.LineMetric]:A(Ci),[w.Resolution]:A(Fr,Ci),[w.Zoom]:A(Fr,Ci),[w.Time]:A(Fr,Ci),[w.Any]:A(G(2,1/0),Z(vt)),[w.All]:A(G(2,1/0),Z(vt)),[w.Not]:A(G(1,1),Z(vt)),[w.Equal]:A(G(2,2),Z(ns)),[w.NotEqual]:A(G(2,2),Z(ns)),[w.GreaterThan]:A(G(2,2),Z(Y)),[w.GreaterThanOrEqualTo]:A(G(2,2),Z(Y)),[w.LessThan]:A(G(2,2),Z(Y)),[w.LessThanOrEqualTo]:A(G(2,2),Z(Y)),[w.Multiply]:A(G(2,1/0),rl),[w.Coalesce]:A(G(2,1/0),rl),[w.Divide]:A(G(2,2),Z(Y)),[w.Add]:A(G(2,1/0),Z(Y)),[w.Subtract]:A(G(2,2),Z(Y)),[w.Clamp]:A(G(3,3),Z(Y)),[w.Mod]:A(G(2,2),Z(Y)),[w.Pow]:A(G(2,2),Z(Y)),[w.Abs]:A(G(1,1),Z(Y)),[w.Floor]:A(G(1,1),Z(Y)),[w.Ceil]:A(G(1,1),Z(Y)),[w.Round]:A(G(1,1),Z(Y)),[w.Sin]:A(G(1,1),Z(Y)),[w.Cos]:A(G(1,1),Z(Y)),[w.Atan]:A(G(1,2),Z(Y)),[w.Sqrt]:A(G(1,1),Z(Y)),[w.Match]:A(G(4,1/0),ol,Ju),[w.Between]:A(G(3,3),Z(Y)),[w.Interpolate]:A(G(6,1/0),ol,Qu),[w.Case]:A(G(3,1/0),$u,td),[w.In]:A(G(2,2),ed),[w.Number]:A(G(1,1/0),Z(ns)),[w.String]:A(G(1,1/0),Z(ns)),[w.Array]:A(G(1,1/0),Z(Y)),[w.Color]:A(G(1,4),Z(Y)),[w.Band]:A(G(1,3),Z(Y)),[w.Palette]:A(G(2,2),id),[w.ToString]:A(G(1,1),Z(vt|Y|At|Kt))};function sl(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=n[r+1];switch(typeof o){case"number":{s[r]=new lt(Y,o);break}case"string":{s[r]=new lt(At,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&e.properties.add(String(o))}return s}function Uu(n,t,e){const i=n[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return e.variables.add(i),[new lt(At,i)]}function Hu(n,t,e){e.featureId=!0}function qu(n,t,e){e.geometryType=!0}function Fr(n,t,e){e.mapState=!0}function Ci(n,t,e){const i=n[0];if(n.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function G(n,t){return function(e,i,s){const r=e[0],o=e.length-1;if(n===t){if(o!==n){const a=n===1?"":"s";throw new Error(`expected ${n} argument${a} for ${r}, got ${o}`)}}else if(o<n||o>t){const a=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function rl(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=pt(n[r+1],t,e);s[r]=o}return s}function Z(n){return function(t,e,i){const s=t.length-1,r=new Array(s);for(let o=0;o<s;++o){const a=pt(t[o+1],n,i);r[o]=a}return r}}function $u(n,t,e){const i=n[0],s=n.length-1;if(s%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${s} instead`)}function ol(n,t,e){const i=n[0],s=n.length-1;if(s%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${s} instead`)}function Ju(n,t,e){const i=n.length-1,s=At|Y|vt,r=pt(n[1],s,e),o=pt(n[n.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const h=pt(n[l+2],r.type,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{const h=pt(n[l+3],o.type,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[r,...a,o]}function Qu(n,t,e){const i=n[1];let s;switch(i[0]){case"linear":s=1;break;case"exponential":const l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);s=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const r=new lt(Y,s);let o;try{o=pt(n[2],Y,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(n.length-3);for(let l=0;l<a.length;l+=2){try{const h=pt(n[l+3],Y,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=pt(n[l+4],t,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[r,o,...a]}function td(n,t,e){const i=pt(n[n.length-1],t,e),s=new Array(n.length-1);for(let r=0;r<s.length-1;r+=2){try{const o=pt(n[r+1],vt,e);s[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=pt(n[r+2],i.type,e);s[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return s[s.length-1]=i,s}function ed(n,t,e){let i=n[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let s;if(typeof i[0]=="string"){if(i[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(i[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');i=i[1],s=At}else s=Y;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=pt(i[a],s,e);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[pt(n[1],s,e),...r]}function id(n,t,e){let i;try{i=pt(n[1],Y,e)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const s=n[2];if(!Array.isArray(s))throw new Error("the second argument of palette must be an array");const r=new Array(s.length);for(let o=0;o<r.length;o++){let a;try{a=pt(s[o],Kt,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof lt))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function A(...n){return function(t,e,i){const s=t[0];let r;for(let o=0;o<n.length;o++){const a=n[o](t,e,i);if(o==n.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new Zu(e,s,...r)}}function nd(n,t,e){const i=n[0],s=Ku[i];if(!s)throw new Error(`unknown operator: ${i}`);return s(n,t,e)}function al(n){if(!n)return"";const t=n.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return al(n.getGeometries()[0]);default:return""}}function ll(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function _e(n,t,e){const i=pt(n,t,e);return Ut(i)}function Ut(n,t){if(n instanceof lt){if(n.type===Kt&&typeof n.value=="string"){const i=ur(n.value);return function(){return i}}return function(){return n.value}}const e=n.operator;switch(e){case w.Number:case w.String:case w.Coalesce:return sd(n);case w.Get:case w.Var:case w.Has:return rd(n);case w.Id:return i=>i.featureId;case w.GeometryType:return i=>i.geometryType;case w.Concat:{const i=n.args.map(s=>Ut(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 ad(n);case w.Equal:case w.NotEqual:case w.LessThan:case w.LessThanOrEqualTo:case w.GreaterThan:case w.GreaterThanOrEqualTo:return od(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 ld(n);case w.Case:return hd(n);case w.Match:return cd(n);case w.Interpolate:return ud(n);case w.ToString:return dd(n);default:throw new Error(`Unsupported operator ${e}`)}}function sd(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Ut(n.args[r]);switch(e){case w.Coalesce:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case w.Number:case w.String:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a===e)return a}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}function rd(n,t){const i=n.args[0].value;switch(n.operator){case w.Get:return s=>{const r=n.args;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;o=o[c]}return o};case w.Var:return s=>s.variables[i];case w.Has:return s=>{const r=n.args;if(!(i in s.properties))return!1;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function od(n,t){const e=n.operator,i=Ut(n.args[0]),s=Ut(n.args[1]);switch(e){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)<s(r);case w.LessThanOrEqualTo:return 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 ${e}`)}}function ad(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Ut(n.args[r]);switch(e){case w.Any:return r=>{for(let o=0;o<i;++o)if(s[o](r))return!0;return!1};case w.All:return r=>{for(let o=0;o<i;++o)if(!s[o](r))return!1;return!0};case w.Between:return r=>{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<i;++a)if(o===s[a](r))return!0;return!1};case w.Not:return r=>!s[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function ld(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Ut(n.args[r]);switch(e){case w.Multiply:return r=>{let o=1;for(let a=0;a<i;++a)o*=s[a](r);return o};case w.Divide:return r=>s[0](r)/s[1](r);case w.Add:return r=>{let o=0;for(let a=0;a<i;++a)o+=s[a](r);return o};case w.Subtract:return r=>s[0](r)-s[1](r);case w.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(o<a)return a;const l=s[2](r);return o>l?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 ${e}`)}}function hd(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Ut(n.args[s]);return s=>{for(let r=0;r<e-1;r+=2)if(i[r](s))return i[r+1](s);return i[e-1](s)}}function cd(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Ut(n.args[s]);return s=>{const r=i[0](s);for(let o=1;o<e-1;o+=2)if(r===i[o](s))return i[o+1](s);return i[e-1](s)}}function ud(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Ut(n.args[s]);return s=>{const r=i[0](s),o=i[1](s);let a,l;for(let h=2;h<e;h+=2){const c=i[h](s);let u=i[h+1](s);const d=Array.isArray(u);if(d&&(u=Ac(u)),c>=o)return h===2?u:d?fd(r,o,a,l,c,u):cn(r,o,a,l,c,u);a=c,l=u}return l}}function dd(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Ut(n.args[r]);switch(e){case w.ToString:return r=>{const o=s[0](r);return n.args[0].type===Kt?dr(o):o.toString()};default:throw new Error(`Unsupported convert operator ${e}`)}}function cn(n,t,e,i,s,r){const o=s-e;if(o===0)return i;const a=t-e,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function fd(n,t,e,i,s,r){if(s-e===0)return i;const a=_a(i),l=_a(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[cn(n,t,e,a[0],s,l[0]),cn(n,t,e,a[1],s,l[1]),a[2]+cn(n,t,e,0,s,h),cn(n,t,e,i[3],s,r[3])];return Fc(c)}function gd(n){return!0}function _d(n){const t=nl(),e=md(n,t),i=ll();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,t.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=al(s.getGeometry())),e(i)}}function hl(n){const t=nl(),e=n.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=br(n[o],t);const s=ll(),r=new Array(e);return function(o,a){if(s.properties=o.getPropertiesInternal(),s.resolution=a,t.featureId){const h=o.getId();h!==void 0?s.featureId=h:s.featureId=null}let l=0;for(let h=0;h<e;++h){const c=i[h](s);c&&(r[l]=c,l+=1)}return r.length=l,r}}function md(n,t){const e=n.length,i=new Array(e);for(let s=0;s<e;++s){const r=n[s],o="filter"in r?_e(r.filter,vt,t):gd;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=br(r.style[h],t)}else a=[br(r.style,t)];i[s]={filter:o,styles:a}}return function(s){const r=[];let o=!1;for(let a=0;a<e;++a){const l=i[a].filter;if(l(s)&&!(n[a].else&&o)){o=!0;for(const h of i[a].styles){const c=h(s);c&&r.push(c)}}}return r}}function br(n,t){const e=un(n,"",t),i=dn(n,"",t),s=yd(n,t),r=pd(n,t),o=Ft(n,"z-index",t);if(!e&&!i&&!s&&!r&&!Xe(n))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(n));const a=new at;return function(l){let h=!0;if(e){const c=e(l);c&&(h=!1),a.setFill(c)}if(i){const c=i(l);c&&(h=!1),a.setStroke(c)}if(s){const c=s(l);c&&(h=!1),a.setText(c)}if(r){const c=r(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function un(n,t,e){let i;if(t+"fill-pattern-src"in n)i=wd(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return r=>null;i=Dr(n,t+"fill-color",e)}if(!i)return null;const s=new yt;return function(r){const o=i(r);return o===sr?null:(s.setColor(o),s)}}function dn(n,t,e){const i=Ft(n,t+"stroke-width",e),s=Dr(n,t+"stroke-color",e);if(!i&&!s)return null;const r=me(n,t+"stroke-line-cap",e),o=me(n,t+"stroke-line-join",e),a=cl(n,t+"stroke-line-dash",e),l=Ft(n,t+"stroke-line-dash-offset",e),h=Ft(n,t+"stroke-miter-limit",e),c=new Qt;return function(u){if(s){const d=s(u);if(d===sr)return null;c.setColor(d)}if(i&&c.setWidth(i(u)),r){const d=r(u);if(d!=="butt"&&d!=="round"&&d!=="square")throw new Error("Expected butt, round, or square line cap");c.setLineCap(d)}if(o){const d=o(u);if(d!=="bevel"&&d!=="round"&&d!=="miter")throw new Error("Expected bevel, round, or miter line join");c.setLineJoin(d)}return a&&c.setLineDash(a(u)),l&&c.setLineDashOffset(l(u)),h&&c.setMiterLimit(h(u)),c}}function yd(n,t){const e="text-",i=me(n,e+"value",t);if(!i)return null;const s=un(n,e,t),r=un(n,e+"background-",t),o=dn(n,e,t),a=dn(n,e+"background-",t),l=me(n,e+"font",t),h=Ft(n,e+"max-angle",t),c=Ft(n,e+"offset-x",t),u=Ft(n,e+"offset-y",t),d=wi(n,e+"overflow",t),f=me(n,e+"placement",t),g=Ft(n,e+"repeat",t),m=rs(n,e+"scale",t),_=wi(n,e+"rotate-with-view",t),y=Ft(n,e+"rotation",t),p=me(n,e+"align",t),E=me(n,e+"justify",t),x=me(n,e+"baseline",t),C=wi(n,e+"keep-upright",t),S=cl(n,e+"padding",t),T=as(n,e+"declutter-mode"),I=new qe({declutterMode:T});return function(v){if(I.setText(i(v)),s&&I.setFill(s(v)),r&&I.setBackgroundFill(r(v)),o&&I.setStroke(o(v)),a&&I.setBackgroundStroke(a(v)),l&&I.setFont(l(v)),h&&I.setMaxAngle(h(v)),c&&I.setOffsetX(c(v)),u&&I.setOffsetY(u(v)),d&&I.setOverflow(d(v)),f){const M=f(v);if(M!=="point"&&M!=="line")throw new Error("Expected point or line for text-placement");I.setPlacement(M)}if(g&&I.setRepeat(g(v)),m&&I.setScale(m(v)),_&&I.setRotateWithView(_(v)),y&&I.setRotation(y(v)),p){const M=p(v);if(M!=="left"&&M!=="center"&&M!=="right"&&M!=="end"&&M!=="start")throw new Error("Expected left, right, center, start, or end for text-align");I.setTextAlign(M)}if(E){const M=E(v);if(M!=="left"&&M!=="right"&&M!=="center")throw new Error("Expected left, right, or center for text-justify");I.setJustify(M)}if(x){const M=x(v);if(M!=="bottom"&&M!=="top"&&M!=="middle"&&M!=="alphabetic"&&M!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");I.setTextBaseline(M)}return S&&I.setPadding(S(v)),C&&I.setKeepUpright(C(v)),I}}function pd(n,t){return"icon-src"in n?xd(n,t):"shape-points"in n?Ed(n,t):"circle-radius"in n?Cd(n,t):null}function xd(n,t){const e="icon-",i=e+"src",s=gl(n[i],i),r=ss(n,e+"anchor",t),o=rs(n,e+"scale",t),a=Ft(n,e+"opacity",t),l=ss(n,e+"displacement",t),h=Ft(n,e+"rotation",t),c=wi(n,e+"rotate-with-view",t),u=dl(n,e+"anchor-origin"),d=fl(n,e+"anchor-x-units"),f=fl(n,e+"anchor-y-units"),g=Rd(n,e+"color"),m=Id(n,e+"cross-origin"),_=vd(n,e+"offset"),y=dl(n,e+"offset-origin"),p=os(n,e+"width"),E=os(n,e+"height"),x=Sd(n,e+"size"),C=as(n,e+"declutter-mode"),S=new Qn({src:s,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:m,offset:_,offsetOrigin:y,height:E,width:p,size:x,declutterMode:C});return function(T){return a&&S.setOpacity(a(T)),l&&S.setDisplacement(l(T)),h&&S.setRotation(h(T)),c&&S.setRotateWithView(c(T)),o&&S.setScale(o(T)),r&&S.setAnchor(r(T)),S}}function Ed(n,t){const e="shape-",i=e+"points",s=e+"radius",r=Or(n[i],i),o=Or(n[s],s),a=un(n,e,t),l=dn(n,e,t),h=rs(n,e+"scale",t),c=ss(n,e+"displacement",t),u=Ft(n,e+"rotation",t),d=wi(n,e+"rotate-with-view",t),f=os(n,e+"radius2"),g=os(n,e+"angle"),m=as(n,e+"declutter-mode"),_=new Jn({points:r,radius:o,radius2:f,angle:g,declutterMode:m});return function(y){return a&&_.setFill(a(y)),l&&_.setStroke(l(y)),c&&_.setDisplacement(c(y)),u&&_.setRotation(u(y)),d&&_.setRotateWithView(d(y)),h&&_.setScale(h(y)),_}}function Cd(n,t){const e="circle-",i=un(n,e,t),s=dn(n,e,t),r=Ft(n,e+"radius",t),o=rs(n,e+"scale",t),a=ss(n,e+"displacement",t),l=Ft(n,e+"rotation",t),h=wi(n,e+"rotate-with-view",t),c=as(n,e+"declutter-mode"),u=new nn({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),i&&u.setFill(i(d)),s&&u.setStroke(s(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function Ft(n,t,e){if(!(t in n))return;const i=_e(n[t],Y,e);return function(s){return Or(i(s),t)}}function me(n,t,e){if(!(t in n))return null;const i=_e(n[t],At,e);return function(s){return gl(i(s),t)}}function wd(n,t,e){const i=me(n,t+"pattern-src",e),s=ul(n,t+"pattern-offset",e),r=ul(n,t+"pattern-size",e),o=Dr(n,t+"color",e);return function(a){return{src:i(a),offset:s&&s(a),size:r&&r(a),color:o&&o(a)}}}function wi(n,t,e){if(!(t in n))return null;const i=_e(n[t],vt,e);return function(s){const r=i(s);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${t}`);return r}}function Dr(n,t,e){if(!(t in n))return null;const i=_e(n[t],Kt,e);return function(s){return _l(i(s),t)}}function cl(n,t,e){if(!(t in n))return null;const i=_e(n[t],Qe,e);return function(s){return fn(i(s),t)}}function ss(n,t,e){if(!(t in n))return null;const i=_e(n[t],Qe,e);return function(s){const r=fn(i(s),t);if(r.length!==2)throw new Error(`Expected two numbers for ${t}`);return r}}function ul(n,t,e){if(!(t in n))return null;const i=_e(n[t],Qe,e);return function(s){return ml(i(s),t)}}function rs(n,t,e){if(!(t in n))return null;const i=_e(n[t],Qe|Y,e);return function(s){return Td(i(s),t)}}function os(n,t){const e=n[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function Sd(n,t){const e=n[t];if(e!==void 0){if(typeof e=="number")return yi(e);if(!Array.isArray(e))throw new Error(`Expected a number or size array for ${t}`);if(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return e}}function Id(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function dl(n,t){const e=n[t];if(e!==void 0){if(e!=="bottom-left"&&e!=="bottom-right"&&e!=="top-left"&&e!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return e}}function fl(n,t){const e=n[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function vd(n,t){const e=n[t];if(e!==void 0)return fn(e,t)}function as(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);if(e!=="declutter"&&e!=="obstacle"&&e!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return e}}function Rd(n,t){const e=n[t];if(e!==void 0)return _l(e,t)}function fn(n,t){if(!Array.isArray(n))throw new Error(`Expected an array for ${t}`);const e=n.length;for(let i=0;i<e;++i)if(typeof n[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return n}function gl(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function Or(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function _l(n,t){if(typeof n=="string")return n;const e=fn(n,t),i=e.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function ml(n,t){const e=fn(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function Td(n,t){return typeof n=="number"?n:ml(n,t)}const Ht={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function yl(n,t,e){return(function(i,s,r,o,a){if(!i)return;if(!s&&!t)return i;const l=t?0:r[0]*s,h=t?0:r[1]*s,c=a?a[0]:0,u=a?a[1]:0;let d=n[0]+l/2+c,f=n[2]-l/2+c,g=n[1]+h/2+u,m=n[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=rt(i[0],d,f),y=rt(i[1],g,m);if(o&&e&&s){const p=30*s;_+=-p*Math.log(1+Math.max(0,d-i[0])/p)+p*Math.log(1+Math.max(0,i[0]-f)/p),y+=-p*Math.log(1+Math.max(0,g-i[1])/p)+p*Math.log(1+Math.max(0,i[1]-m)/p)}return[_,y]})}function Pd(n){return n}function Md(n){return Math.pow(n,3)}function Si(n){return 1-Md(1-n)}function Ld(n){return 3*n*n-2*n*n*n}function Ad(n){return n}function pl(n,t,e,i){let s=0;const r=n[e-i],o=n[e-i+1];let a=0,l=0;for(;t<e;t+=i){const h=n[t]-r,c=n[t+1]-o;s+=l*h-a*c,a=h,l=c}return s/2}function xl(n,t,e,i){let s=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];s+=pl(n,t,a,i),t=a}return s}function Fd(n,t,e,i){let s=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];s+=xl(n,t,a,i),t=a[a.length-1]}return s}function El(n,t,e,i,s,r,o){const a=n[t],l=n[t+1],h=n[e]-a,c=n[e+1]-l;let u;if(h===0&&c===0)u=t;else{const d=((s-a)*h+(r-l)*c)/(h*h+c*c);if(d>1)u=e;else if(d>0){for(let f=0;f<i;++f)o[f]=bt(n[t+f],n[e+f],d);o.length=i;return}else u=t}for(let d=0;d<i;++d)o[d]=n[u+d];o.length=i}function kr(n,t,e,i,s){let r=n[t],o=n[t+1];for(t+=i;t<e;t+=i){const a=n[t],l=n[t+1],h=le(r,o,a,l);h>s&&(s=h),r=a,o=l}return s}function Nr(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];s=kr(n,t,a,i,s),t=a}return s}function bd(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];s=Nr(n,t,a,i,s),t=a[a.length-1]}return s}function Gr(n,t,e,i,s,r,o,a,l,h,c){if(t==e)return h;let u,d;if(s===0){if(d=le(o,a,n[t],n[t+1]),d<h){for(u=0;u<i;++u)l[u]=n[t+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=t+i;for(;f<e;)if(El(n,f-i,f,i,o,a,c),d=le(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/s|0,1);if(r&&(El(n,e-i,t,i,o,a,c),d=le(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function zr(n,t,e,i,s,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=Gr(n,t,f,i,s,r,o,a,l,h,c),t=f}return h}function Dd(n,t,e,i,s,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=zr(n,t,f,i,s,r,o,a,l,h,c),t=f[f.length-1]}return h}function Cl(n,t,e,i){for(let s=0,r=e.length;s<r;++s)n[t++]=e[s];return t}function ls(n,t,e,i){for(let s=0,r=e.length;s<r;++s){const o=e[s];for(let a=0;a<i;++a)n[t++]=o[a]}return t}function gn(n,t,e,i,s){s=s||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=ls(n,t,e[o],i);s[r++]=l,t=l}return s.length=r,s}function wl(n,t,e,i,s){s=s||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=gn(n,t,e[o],i,s[r]);l.length===0&&(l[0]=t),s[r++]=l,t=l[l.length-1]}return s.length=r,s}class _n extends be{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}clone(){return new _n(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Gr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,s))}getArea(){return pl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Pe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=Hn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new _n(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ls(this.flatCoordinates,0,t,this.stride),this.changed()}}class Rt extends be{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new Rt(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){const r=this.flatCoordinates,o=le(t,e,r[0],r[1]);if(o<s){const a=this.stride;for(let l=0;l<a;++l)i[l]=r[l];return i.length=a,o}return s}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return Gi(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return bs(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Cl(this.flatCoordinates,0,t,this.stride),this.changed()}}function Od(n,t,e,i,s){return!jo(s,function(o){return!ti(n,t,e,i,o[0],o[1])})}function ti(n,t,e,i,s,r){let o=0,a=n[e-i],l=n[e-i+1];for(;t<e;t+=i){const h=n[t],c=n[t+1];l<=r?c>r&&(h-a)*(r-l)-(s-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(s-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function Wr(n,t,e,i,s,r){if(e.length===0||!ti(n,t,e[0],i,s,r))return!1;for(let o=1,a=e.length;o<a;++o)if(ti(n,e[o-1],e[o],i,s,r))return!1;return!0}function kd(n,t,e,i,s,r){if(e.length===0)return!1;for(let o=0,a=e.length;o<a;++o){const l=e[o];if(Wr(n,t,l,i,s,r))return!0;t=l[l.length-1]}return!1}function jr(n,t,e,i,s,r,o){let a,l,h,c,u,d,f;const g=s[r+1],m=[];for(let p=0,E=e.length;p<E;++p){const x=e[p];for(c=n[x-i],d=n[x-i+1],a=t;a<x;a+=i)u=n[a],f=n[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,m.push(h)),c=u,d=f}let _=NaN,y=-1/0;for(m.sort(Ge),c=m[0],a=1,l=m.length;a<l;++a){u=m[a];const p=Math.abs(u-c);p>y&&(h=(c+u)/2,Wr(n,t,e,i,h,g)&&(_=h,y=p)),c=u}return isNaN(_)&&(_=s[r]),o?(o.push(_,g,y),o):[_,g,y]}function Sl(n,t,e,i,s){let r=[];for(let o=0,a=e.length;o<a;++o){const l=e[o];r=jr(n,t,l,i,s,2*o,r),t=l[l.length-1]}return r}function Il(n,t,e,i,s){let r;for(t+=i;t<e;t+=i)if(r=s(n.slice(t-i,t),n.slice(t,t+i)),r)return r;return!1}function vl(n,t){const[e,i]=n,[s,r]=t,o=((e[0]-s[0])*(s[1]-r[1])-(e[1]-s[1])*(s[0]-r[0]))/((e[0]-i[0])*(s[1]-r[1])-(e[1]-i[1])*(s[0]-r[0])),a=((e[0]-s[0])*(e[1]-i[1])-(e[1]-s[1])*(e[0]-i[0]))/((e[0]-i[0])*(s[1]-r[1])-(e[1]-i[1])*(s[0]-r[0]));if(0<=o&&o<=1&&0<=a&&a<=1)return[e[0]+o*(i[0]-e[0]),e[1]+o*(i[1]-e[1])]}function hs(n,t,e,i,s,r){return r=r??Wo(kt(),n,t,e,i),_t(s,r)?r[0]>=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:Il(n,t,e,i,function(o,a){return Dh(s,o,a)}):!1}function Nd(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){if(hs(n,t,e[r],i,s))return!0;t=e[r]}return!1}function Gd(n,t,e,i,s){return!!(hs(n,t,e,i,s)||ti(n,t,e,i,s[0],s[1])||ti(n,t,e,i,s[0],s[3])||ti(n,t,e,i,s[2],s[1])||ti(n,t,e,i,s[2],s[3]))}function Rl(n,t,e,i,s){if(!Gd(n,t,e[0],i,s))return!1;if(e.length===1)return!0;for(let r=1,o=e.length;r<o;++r)if(Od(n,e[r-1],e[r],i,s)&&!hs(n,e[r-1],e[r],i,s))return!1;return!0}function zd(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(Rl(n,t,a,i,s))return!0;t=a[a.length-1]}return!1}function Wd(n,t,e,i){for(;t<e-i;){for(let s=0;s<i;++s){const r=n[t+s];n[t+s]=n[e-i+s],n[e-i+s]=r}t+=i,e-=i}}function Vr(n,t,e,i){let s=0,r=n[e-i],o=n[e-i+1];for(;t<e;t+=i){const a=n[t],l=n[t+1];s+=(a-r)*(l+o),r=a,o=l}return s===0?void 0:s>0}function Xr(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=Vr(n,t,a,i);if(r===0){if(s&&l||!s&&!l)return!1}else if(s&&!l||!s&&l)return!1;t=a}return!0}function Tl(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];if(!Xr(n,t,a,i,s))return!1;a.length&&(t=a[a.length-1])}return!0}function cs(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=Vr(n,t,a,i);(r===0?s&&l||!s&&!l:s&&!l||!s&&l)&&Wd(n,t,a,i),t=a}return t}function Br(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r)t=cs(n,t,e[r],i,s);return t}function jd(n,t){const e=[];let i=0,s=0,r;for(let o=0,a=t.length;o<a;++o){const l=t[o],h=Vr(n,i,l,2);if(r===void 0&&(r=h),h===r)e.push(t.slice(s,o+1));else{if(e.length===0)continue;e[e.length-1].push(t[s])}s=o+1,i=l}return e}class qt extends be{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,e!==void 0&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?Ot(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new qt(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Nr(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zr(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,s))}containsXY(t,e){return Wr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return xl(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),cs(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Ui(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=Xt(this.getExtent());this.flatInteriorPoint_=jr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new Rt(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new _n(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,i=this.ends_,s=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o],h=new _n(e.slice(r,l),t);s.push(h),r=l}return s}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Xr(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=cs(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=wr(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new qt(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return Rl(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=gn(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function Pl(n){if(si(n))throw new Error("Cannot create polygon from empty extent");const t=n[0],e=n[1],i=n[2],s=n[3],r=[t,e,t,s,i,s,i,e,t,e];return new qt(r,"XY",[r.length])}function Vd(n,t,e){t=t||32;const i=n.getStride(),s=n.getLayout(),r=n.getCenter(),o=i*(t+1),a=new Array(o);for(let c=0;c<o;c+=i){a[c]=0,a[c+1]=0;for(let u=2;u<i;u++)a[c+u]=r[u]}const l=[a.length],h=new qt(a,s,l);return Xd(h,r,n.getRadius()),h}function Xd(n,t,e,i){const s=n.getFlatCoordinates(),r=n.getStride(),o=s.length/r-1,a=0;for(let l=0;l<=o;++l){const h=l*r,c=a+ri(l,o)*2*Math.PI/o;s[h]=t[0]+e*Math.cos(c),s[h+1]=t[1]+e*Math.sin(c)}n.changed()}function Yr(n,t,e,i){const s=K(t)/e[0],r=dt(t)/e[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function Zr(n,t,e){let i=Math.min(n,t);const s=50;return i*=Math.log(1+s*Math.max(0,n/t-1))/s+1,e&&(i=Math.max(i,e),i/=Math.log(1+s*Math.max(0,e/n-1))/s+1),rt(i,e/2,t*2)}function Bd(n,t,e,i){return t=t!==void 0?t:!0,(function(s,r,o,a){if(s!==void 0){const l=n[0],h=n[n.length-1],c=e?Yr(l,e,o,i):l;if(a)return t?Zr(s,c,h):rt(s,h,c);const u=Math.min(c,s),d=Math.floor(Fs(n,u,r));return n[d]>c&&d<n.length-1?n[d+1]:n[d]}})}function Yd(n,t,e,i,s,r){return i=i!==void 0?i:!0,e=e!==void 0?e:0,(function(o,a,l,h){if(o!==void 0){const c=s?Yr(t,s,l,r):t;if(h)return i?Zr(o,c,e):rt(o,e,c);const u=1e-9,d=Math.ceil(Math.log(t/c)/Math.log(n)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),m=Math.floor(Math.log(t/g)/Math.log(n)+f),_=Math.max(d,m),y=t/Math.pow(n,_);return rt(y,e,c)}})}function Ml(n,t,e,i,s){return e=e!==void 0?e:!0,(function(r,o,a,l){if(r!==void 0){const h=i?Yr(n,i,a,s):n;return!e||!l?rt(r,t,h):Zr(r,h,t)}})}function Kr(n){if(n!==void 0)return 0}function Ll(n){if(n!==void 0)return n}function Zd(n){const t=2*Math.PI/n;return(function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e})}function Kd(n){const t=ve(5);return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}const Ud=256,Ur=0;class ee extends Yt{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=tr(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&xc(),t.center&&(t.center=U(t.center,this.projection_)),t.extent&&(t.extent=Te(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const a in Ht)delete e[a];this.setProperties(e,!0);const i=qd(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;const s=Hd(t),r=i.constraint,o=$d(t);this.constraints_={center:s,resolution:r,rotation:o},this.setRotation(t.rotation!==void 0?t.rotation:0),this.setCenterInternal(t.center!==void 0?t.center:null),t.resolution!==void 0?this.setResolution(t.resolution):t.zoom!==void 0&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const i=this.getCenterInternal();if(i){const s=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),o=r/2*(s[3]-e[3]+e[1]-s[1]),a=r/2*(s[0]-e[0]+e[2]-s[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(t){const e=this.getProperties();return e.resolution!==void 0?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const e=new Array(arguments.length);for(let i=0;i<e.length;++i){let s=arguments[i];s.center&&(s=Object.assign({},s),s.center=U(s.center,this.getProjection())),s.anchor&&(s=Object.assign({},s),s.anchor=U(s.anchor,this.getProjection())),e[i]=s}this.animateInternal.apply(this,e)}animateInternal(t){let e=arguments.length,i;e>1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let s=0;for(;s<e&&!this.isDef();++s){const c=arguments[s];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(s===e){i&&us(i,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const h=[];for(;s<e;++s){const c=arguments[s],u={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||Ld,callback:i};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;const d=ri(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}Jd(u)?u.complete=!0:r+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(et.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[et.ANIMATING]>0}getInteracting(){return this.hints_[et.INTERACTING]>0}cancelAnimations(){this.setHint(et.ANIMATING,-this.hints_[et.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){const s=this.animations_[e];if(s[0].callback&&us(s[0].callback,!1),!t)for(let r=0,o=s.length;r<o;++r){const a=s[r];if(!a.complete){t=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let i=this.animations_.length-1;i>=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o<a;++o){const l=s[o];if(l.complete)continue;const h=t-l.start;let c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);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),y=f+u*(m-f);this.targetCenter_=[_,y]}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?ri(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),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(et.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&us(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-e[0],s[1]-e[1]],Vs(i,t-this.getRotation()),Gh(i,e)),i}calculateCenterZoom(t,e){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-s[0])/r,a=e[1]-t*(e[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],s=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(s*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(s*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t&&Re(t,this.getProjection())}getCenterInternal(){return this.get(Ht.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){const e=this.calculateExtentInternal(t);return Vn(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();it(e,"The view center is not defined");const i=this.getResolution();it(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return it(s!==void 0,"The view rotation is not defined"),Ln(e,i,s,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(Ht.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Te(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=K(t)/e[0],s=dt(t)/e[1];return Math.max(i,s)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(e/i)/Math.log(t);return(function(r){return e/Math.pow(t,r*s)})}getRotation(){return this.get(Ht.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/e;return(function(o){return Math.log(i/o)/e/r})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=Hr(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:s.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,s;if(this.resolutions_){const r=Fs(this.resolutions_,t,1);e=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 e+Math.log(i/t)/Math.log(s)}getResolutionForZoom(t){var e;if((e=this.resolutions_)!=null&&e.length){if(this.resolutions_.length===1)return this.resolutions_[0];const i=rt(Math.floor(t),0,this.resolutions_.length-2),s=this.resolutions_[i]/this.resolutions_[i+1];return this.resolutions_[i]/Math.pow(s,rt(t-i,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(it(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){it(!si(t),"Cannot fit empty extent provided as `geometry`");const s=Te(t,this.getProjection());i=Pl(s)}else if(t.getType()==="Circle"){const s=Te(t.getExtent(),this.getProjection());i=Pl(s),i.rotate(this.getRotation(),Xt(s))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),s=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*i-r[u+1]*s,g=r[u]*s+r[u+1]*i;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(t,e){e=e||{};let i=e.size;i||(i=this.getViewportSizeMinusPadding_());const s=e.padding!==void 0?e.padding:[0,0,0,0],r=e.nearest!==void 0?e.nearest:!1;let o;e.minResolution!==void 0?o=e.minResolution:e.maxZoom!==void 0?o=this.getResolutionForZoom(e.maxZoom):o=0;const a=this.rotatedExtentForGeometry(t);let l=this.getResolutionForExtentInternal(a,[i[0]-s[1]-s[3],i[1]-s[0]-s[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,r?0:1);const h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=Xt(a);d[0]+=(s[1]-s[3])/2*l,d[1]+=(s[0]-s[2])/2*l;const f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,m=this.getConstrainedCenter([f,g],l),_=e.callback?e.callback:Zi;e.duration!==void 0?this.animateInternal({resolution:l,center:m,duration:e.duration,easing:e.easing},_):(this.targetResolution_=l,this.targetCenter_=m,this.applyTargetState_(!1,!0),us(_,!0))}centerOn(t,e,i){this.centerOnInternal(U(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(Hr(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,s){let r;const o=this.padding_;if(o&&t){const a=this.getViewportSizeMinusPadding_(-i),l=Hr(t,s,[a[0]/2+o[3],a[1]/2+o[0]],e,i);r=[t[0]-l[0],t[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){const e=Re(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){const e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&U(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,s,i);e&&(this.targetCenter_=this.calculateCenterZoom(r,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=U(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(s,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&U(t,this.getProjection()))}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){const i=this.getAnimating()||this.getInteracting()||e,s=this.constraints_.rotation(this.targetRotation_,i),r=this.getViewportSize_(s),o=this.constraints_.resolution(this.targetResolution_,0,r,i),a=this.constraints_.center(this.targetCenter_,o,r,i,this.calculateCenterShift(this.targetCenter_,o,s,r));this.get(Ht.ROTATION)!==s&&this.set(Ht.ROTATION,s),this.get(Ht.RESOLUTION)!==o&&(this.set(Ht.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(Ht.CENTER)||!It(this.get(Ht.CENTER),a))&&this.set(Ht.CENTER,a),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=t!==void 0?t:200;const s=e||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,s,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!It(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:t,easing:Si,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(et.INTERACTING,1)}endInteraction(t,e,i){i=i&&U(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(et.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){const i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){const i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;const i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}}function us(n,t){setTimeout(function(){n(t)},0)}function Hd(n){if(n.extent!==void 0){const e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return yl(n.extent,n.constrainOnlyCenter,e)}const t=tr(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){const e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,yl(e,!1,!1)}return Pd}function qd(n){let t,e,i,o=n.minZoom!==void 0?n.minZoom:Ur,a=n.maxZoom!==void 0?n.maxZoom:28;const l=n.zoomFactor!==void 0?n.zoomFactor:2,h=n.multiWorld!==void 0?n.multiWorld:!1,c=n.smoothResolutionConstraint!==void 0?n.smoothResolutionConstraint:!0,u=n.showFullExtent!==void 0?n.showFullExtent:!1,d=tr(n.projection,"EPSG:3857"),f=d.getExtent();let g=n.constrainOnlyCenter,m=n.extent;if(!h&&!m&&d.isGlobal()&&(g=!1,m=f),n.resolutions!==void 0){const _=n.resolutions;e=_[o],i=_[a]!==void 0?_[a]:_[_.length-1],n.constrainResolution?t=Bd(_,c,!g&&m,u):t=Ml(e,i,c,!g&&m,u)}else{const y=(f?Math.max(K(f),dt(f)):360*$o.degrees/d.getMetersPerUnit())/Ud/Math.pow(2,Ur),p=y/Math.pow(2,28-Ur);e=n.maxResolution,e!==void 0?o=0:e=y/Math.pow(l,o),i=n.minResolution,i===void 0&&(n.maxZoom!==void 0?n.maxResolution!==void 0?i=e/Math.pow(l,a):i=y/Math.pow(l,a):i=p),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),n.constrainResolution?t=Yd(l,e,i,c,!g&&m,u):t=Ml(e,i,c,!g&&m,u)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function $d(n){if(n.enableRotation!==void 0?n.enableRotation:!0){const e=n.constrainRotation;return e===void 0||e===!0?Kd():e===!1?Ll:typeof e=="number"?Zd(e):Ll}return Kr}function Jd(n){return!(n.sourceCenter&&n.targetCenter&&!It(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function Hr(n,t,e,i,s){const r=Math.cos(-s);let o=Math.sin(-s),a=n[0]*r-n[1]*o,l=n[1]*r+n[0]*o;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,o=-o;const h=a*r-l*o,c=l*r+a*o;return[h,c]}const H={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};class Al extends Yt{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[H.OPACITY]=t.opacity!==void 0?t.opacity:1,it(typeof e[H.OPACITY]=="number","Layer opacity must be a number"),e[H.VISIBLE]=t.visible!==void 0?t.visible:!0,e[H.Z_INDEX]=t.zIndex,e[H.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[H.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[H.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[H.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=rt(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return O()}getLayerStatesArray(t){return O()}getExtent(){return this.get(H.EXTENT)}getMaxResolution(){return this.get(H.MAX_RESOLUTION)}getMinResolution(){return this.get(H.MIN_RESOLUTION)}getMinZoom(){return this.get(H.MIN_ZOOM)}getMaxZoom(){return this.get(H.MAX_ZOOM)}getOpacity(){return this.get(H.OPACITY)}getSourceState(){return O()}getVisible(){return this.get(H.VISIBLE)}getZIndex(){return this.get(H.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(H.EXTENT,t)}setMaxResolution(t){this.set(H.MAX_RESOLUTION,t)}setMinResolution(t){this.set(H.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(H.MAX_ZOOM,t)}setMinZoom(t){this.set(H.MIN_ZOOM,t)}setOpacity(t){it(typeof t=="number","Layer opacity must be a number"),this.set(H.OPACITY,t)}setVisible(t){this.set(H.VISIBLE,t)}setZIndex(t){this.set(H.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}let ds=class extends Al{constructor(t){const e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(H.SOURCE,this.handleSourcePropertyChange_);const i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return t=t||[],t.push(this),t}getLayerStatesArray(t){return t=t||[],t.push(this.getLayerState()),t}getSource(){return this.get(H.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&($(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=z(t,D.CHANGE,this.handleSourceChange_,this),t.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e;const i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof ee?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;if(e.layerStatesArray){if(s=e.layerStatesArray.find(o=>o.layer===this),!s)return!1}else s=this.getLayerState();const r=this.getExtent();return qr(s,e.viewState)&&(!r||_t(r,e.extent))}getAttributions(t){var r;if(!this.isVisible(t))return[];const e=(r=this.getSource())==null?void 0:r.getAttributions();if(!e)return[];const i=t instanceof ee?t.getViewStateAndExtent():t;let s=e(i);return Array.isArray(s)||(s=[s]),s}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(H.MAP,t)}getMapInternal(){return this.get(H.MAP)}setMap(t){this.mapPrecomposeKey_&&($(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&($(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=z(t,Gt.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=z(this,D.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);it(!e.some(s=>s.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)}setSource(t){this.set(H.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function qr(n,t){if(!n.visible)return!1;const e=t.resolution;if(e<n.minResolution||e>=n.maxResolution)return!1;const i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}const Fl={RENDER_ORDER:"renderOrder"};class bl extends ds{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Fl.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new el(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Fl.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Va:t;const e=Qd(t);this.styleFunction_=t===null?void 0:mu(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}function Qd(n){if(n===void 0)return Va;if(!n)return null;if(typeof n=="function"||n instanceof at)return n;if(!Array.isArray(n))return hl([n]);if(n.length===0)return[];const t=n.length,e=n[0];if(e instanceof at){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!(o instanceof at))throw new Error("Expected a list of style instances");s[r]=o}return s}if("style"in e){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");s[r]=o}return _d(s)}return hl(n)}class Ii extends bl{constructor(t){super(t)}createRenderer(){return new Nu(this)}}const nt={ADD:"add",REMOVE:"remove"},Dl={LENGTH:"length"};class fs extends Mt{constructor(t,e,i){super(t),this.element=e,this.index=i}}class xt extends Yt{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t||[],this.unique_)for(let i=0,s=this.array_.length;i<s;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(Dl.LENGTH)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new fs(nt.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){this.unique_&&this.assertUnique_(t);const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new fs(nt.REMOVE,e,t)),e}setAt(t,e){const i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const s=this.array_[t];this.array_[t]=e,this.dispatchEvent(new fs(nt.REMOVE,s,t)),this.dispatchEvent(new fs(nt.ADD,e,t))}updateLength_(){this.set(Dl.LENGTH,this.array_.length)}assertUnique_(t,e){for(let i=0,s=this.array_.length;i<s;++i)if(this.array_[i]===t&&i!==e)throw new Error("Duplicate item added to a unique collection")}}let tf=!1;function ef(n,t,e,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,s):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=tf,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const h=t.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(t.readFeatures(c,{extent:e,featureProjection:s}),t.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function Ol(n,t){return function(e,i,s,r,o){ef(n,t,e,i,s,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function nf(n,t){return[[-1/0,-1/0,1/0,1/0]]}class gt extends Yt{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if(typeof t.getSimplifiedGeometry=="function"){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new gt(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());const e=this.getGeometry();e&&t.setGeometry(e.clone());const i=this.getStyle();return i&&t.setStyle(i),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&($(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=z(t,D.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?sf(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function sf(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(it(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}function kl(n,t,e,i){const s=[];let r=kt();for(let o=0,a=e.length;o<a;++o){const l=e[o];r=Os(n,t,l[0],i),s.push((r[0]+r[2])/2,(r[1]+r[3])/2),t=l[l.length-1]}return s}function gs(n,t,e,i,s,r,o){let a,l;const h=(e-t)/i;if(h===1)a=t;else if(h===2)a=t,l=s;else if(h!==0){let c=n[t],u=n[t+1],d=0;const f=[0];for(let _=t+i;_<e;_+=i){const y=n[_],p=n[_+1];d+=Math.sqrt((y-c)*(y-c)+(p-u)*(p-u)),f.push(d),c=y,u=p}const g=s*d,m=Th(f,g);m<0?(l=(g-f[-m-2])/(f[-m-1]-f[-m-2]),a=t+(-m-2)*i):a=t+m*i}o=o>1?o:2,r=r||new Array(o);for(let c=0;c<o;++c)r[c]=a===void 0?NaN:l===void 0?n[a+c]:bt(n[a+c],n[a+i+c],l);return r}function $r(n,t,e,i,s,r){if(e==t)return null;let o;if(s<n[t+i-1])return r?(o=n.slice(t,t+i),o[i-1]=s,o):null;if(n[e-1]<s)return r?(o=n.slice(e-i,e),o[i-1]=s,o):null;if(s==n[t+i-1])return n.slice(t,t+i);let a=t/i,l=e/i;for(;a<l;){const d=a+l>>1;s<n[(d+1)*i-1]?l=d:a=d+1}const h=n[a*i-1];if(s==h)return n.slice((a-1)*i,(a-1)*i+i);const c=n[(a+1)*i-1],u=(s-h)/(c-h);o=[];for(let d=0;d<i-1;++d)o.push(bt(n[(a-1)*i+d],n[a*i+d],u));return o.push(s),o}function rf(n,t,e,i,s,r,o){if(o)return $r(n,t,e[e.length-1],i,s,r);let a;if(s<n[i-1])return r?(a=n.slice(0,i),a[i-1]=s,a):null;if(n[n.length-1]<s)return r?(a=n.slice(n.length-i),a[i-1]=s,a):null;for(let l=0,h=e.length;l<h;++l){const c=e[l];if(t!=c){if(s<n[t+i-1])return null;if(s<=n[c-1])return $r(n,t,c,i,s,!1);t=c}}return null}class _s extends be{constructor(t,e,i){super(),i!==void 0&&e===void 0?this.setFlatCoordinates(i,t):(e=e||0,this.setCenterAndRadius(t,e,i))}clone(){const t=new _s(this.flatCoordinates.slice(),void 0,this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){const r=this.flatCoordinates,o=t-r[0],a=e-r[1],l=o*o+a*a;if(l<s){if(l===0)for(let h=0;h<this.stride;++h)i[h]=r[h];else{const h=this.getRadius()/Math.sqrt(l);i[0]=r[0]+h*o,i[1]=r[1]+h*a;for(let c=2;c<this.stride;++c)i[c]=r[c]}return i.length=this.stride,l}return s}containsXY(t,e){const i=this.flatCoordinates,s=t-i[0],r=e-i[1];return s*s+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(t){const e=this.flatCoordinates,i=e[this.stride]-e[0];return We(e[0]-i,e[1]-i,e[0]+i,e[1]+i,t)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){const t=this.flatCoordinates[this.stride]-this.flatCoordinates[0],e=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return t*t+e*e}getType(){return"Circle"}intersectsExtent(t){const e=this.getExtent();if(_t(t,e)){const i=this.getCenter();return t[0]<=i[0]&&t[2]>=i[0]||t[1]<=i[1]&&t[3]>=i[1]?!0:jo(t,this.intersectsCoordinate.bind(this))}return!1}setCenter(t){const e=this.stride,i=this.flatCoordinates[e]-this.flatCoordinates[0],s=t.slice();s[e]=s[0]+i;for(let r=1;r<e;++r)s[e+r]=t[r];this.setFlatCoordinates(this.layout,s),this.changed()}setCenterAndRadius(t,e,i){this.setLayout(i,t,0),this.flatCoordinates||(this.flatCoordinates=[]);const s=this.flatCoordinates;let r=Cl(s,0,t,this.stride);s[r++]=s[0]+e;for(let o=1,a=this.stride;o<a;++o)s[r++]=s[o];s.length=r,this.changed()}getCoordinates(){return null}setCoordinates(t,e){}setRadius(t){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+t,this.changed()}rotate(t,e){const i=this.getCenter(),s=this.getStride();this.setCenter(Sr(i,0,i.length,s,t,e,i)),this.changed()}}_s.prototype.transform;class mn extends Ya{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach($),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,i=t.length;e<i;++e)this.changeEventsKeys_.push(z(t[e],D.CHANGE,this.changed,this))}clone(){const t=new mn(Jr(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,i,s){if(s<ze(this.getExtent(),t,e))return s;const r=this.geometries_;for(let o=0,a=r.length;o<a;++o)s=r[o].closestPointXY(t,e,i,s);return s}containsXY(t,e){const i=this.geometries_;for(let s=0,r=i.length;s<r;++s)if(i[s].containsXY(t,e))return!0;return!1}computeExtent(t){Ni(t);const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)zo(t,e[i].getExtent());return t}getGeometries(){return Jr(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[];const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)e[i].getType()===this.getType()?t=t.concat(e[i].getGeometriesArrayRecursive()):t.push(e[i]);return t}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=[],i=this.geometries_;let s=!1;for(let r=0,o=i.length;r<o;++r){const a=i[r],l=a.getSimplifiedGeometry(t);e.push(l),l!==a&&(s=!0)}return s?new mn(e):(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getType(){return"GeometryCollection"}intersectsExtent(t){const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)if(e[i].intersectsExtent(t))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(t,e){const i=this.geometries_;for(let s=0,r=i.length;s<r;++s)i[s].rotate(t,e);this.changed()}scale(t,e,i){i||(i=Xt(this.getExtent()));const s=this.geometries_;for(let r=0,o=s.length;r<o;++r)s[r].scale(t,e,i);this.changed()}setGeometries(t){this.setGeometriesArray(Jr(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)e[i].applyTransform(t);this.changed()}translate(t,e){const i=this.geometries_;for(let s=0,r=i.length;s<r;++s)i[s].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function Jr(n){return n.map(t=>t.clone())}class ie extends be{constructor(t,e){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendCoordinate(t){Ot(this.flatCoordinates,t),this.changed()}clone(){const t=new ie(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Gr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,s))}forEachSegment(t){return Il(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){return this.layout!="XYM"&&this.layout!="XYZM"?null:(e=e!==void 0?e:!1,$r(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return Pe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return gs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return Ir(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(t){const e=[];return e.length=Hn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new ie(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return hs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,this.getExtent())}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ls(this.flatCoordinates,0,t,this.stride),this.changed()}}class vi extends be{constructor(t,e,i){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(e!==void 0&&i)this.setFlatCoordinates(e,t),this.ends_=i;else{const s=t,r=[],o=[];for(let l=0,h=s.length;l<h;++l){const c=s[l];Ot(r,c.getFlatCoordinates()),o.push(r.length)}const a=s.length===0?this.getLayout():s[0].getLayout();this.setFlatCoordinates(a,r),this.ends_=o}}appendLineString(t){Ot(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new vi(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Nr(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zr(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,i,s))}getCoordinateAtM(t,e,i){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(e=e!==void 0?e:!1,i=i!==void 0?i:!1,rf(this.flatCoordinates,0,this.ends_,this.stride,t,e,i))}getCoordinates(){return Ui(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new ie(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){const t=this.flatCoordinates,e=this.ends_,i=this.layout,s=[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o],h=new ie(t.slice(r,l),i);s.push(h),r=l}return s}getLength(){const t=this.ends_;let e=0,i=0;for(let s=0,r=t.length;s<r;++s)i+=Ir(this.flatCoordinates,e,t[s],this.stride),e=t[s];return i}getFlatMidpoints(){const t=[],e=this.flatCoordinates;let i=0;const s=this.ends_,r=this.stride;for(let o=0,a=s.length;o<a;++o){const l=s[o],h=gs(e,i,l,r,.5);Ot(t,h),i=l}return t}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Fa(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,i),new vi(e,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(t){return Nd(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=gn(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}class yn extends be{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){Ot(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){const t=new yn(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){if(s<ze(this.getExtent(),t,e))return s;const r=this.flatCoordinates,o=this.stride;for(let a=0,l=r.length;a<l;a+=o){const h=le(t,e,r[a],r[a+1]);if(h<s){s=h;for(let c=0;c<o;++c)i[c]=r[a+c];i.length=o}}return s}getCoordinates(){return Pe(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new Rt(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){const t=this.flatCoordinates,e=this.layout,i=this.stride,s=[];for(let r=0,o=t.length;r<o;r+=i){const a=new Rt(t.slice(r,r+i),e);s.push(a)}return s}getType(){return"MultiPoint"}intersectsExtent(t){const e=this.flatCoordinates,i=this.stride;for(let s=0,r=e.length;s<r;s+=i){const o=e[s],a=e[s+1];if(bs(t,o,a))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ls(this.flatCoordinates,0,t,this.stride),this.changed()}}class Ri extends be{constructor(t,e,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(t[0])){const s=t,r=[],o=[];for(let a=0,l=s.length;a<l;++a){const h=s[a],c=r.length,u=h.getEnds();for(let d=0,f=u.length;d<f;++d)u[d]+=c;Ot(r,h.getFlatCoordinates()),o.push(u)}e=s.length===0?this.getLayout():s[0].getLayout(),t=r,i=o}e!==void 0&&i?(this.setFlatCoordinates(e,t),this.endss_=i):this.setCoordinates(t,e)}appendPolygon(t){let e;if(!this.flatCoordinates)this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();else{const i=this.flatCoordinates.length;Ot(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let s=0,r=e.length;s<r;++s)e[s]+=i}this.endss_.push(e),this.changed()}clone(){const t=this.endss_.length,e=new Array(t);for(let s=0;s<t;++s)e[s]=this.endss_[s].slice();const i=new Ri(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,s){return s<ze(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(bd(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Dd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,s))}containsXY(t,e){return kd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return Fd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Br(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,yr(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=kl(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Sl(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new yn(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Tl(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Br(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=qc(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new Ri(e,"XY",i)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(t===0)e=0;else{const r=this.endss_[t-1];e=r[r.length-1]}const i=this.endss_[t].slice(),s=i[i.length-1];if(e!==0)for(let r=0,o=i.length;r<o;++r)i[r]-=e;return new qt(this.flatCoordinates.slice(e,s),this.layout,i)}getPolygons(){const t=this.layout,e=this.flatCoordinates,i=this.endss_,s=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o].slice(),h=l[l.length-1];if(r!==0)for(let u=0,d=l.length;u<d;++u)l[u]-=r;const c=new qt(e.slice(r,h),t,l);s.push(c),r=h}return s}getType(){return"MultiPolygon"}intersectsExtent(t){return zd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const i=wl(this.flatCoordinates,0,t,this.stride,this.endss_);if(i.length===0)this.flatCoordinates.length=0;else{const s=i[i.length-1];this.flatCoordinates.length=s.length===0?0:s[s.length-1]}this.changed()}}const Nl=Zt();class Dt{constructor(t,e,i,s,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=r,this.squaredTolerance_,this.stride_=s,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Gi(this.flatCoordinates_):Os(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=Xt(this.getExtent());this.flatInteriorPoints_=jr(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=jd(this.flatCoordinates_,this.ends_),e=kl(this.flatCoordinates_,0,t,2);this.flatInteriorPoints_=Sl(this.flatCoordinates_,0,t,2,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=gs(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const i=this.ends_;for(let s=0,r=i.length;s<r;++s){const o=i[s],a=gs(t,e,o,2,.5);Ot(this.flatMidpoints_,a),e=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=ot(t);const e=t.getExtent(),i=t.getWorldExtent();if(e&&i){const s=dt(i)/dt(e);de(Nl,i[0],i[3],s,-s,0,0,0),Le(this.flatCoordinates_,0,this.flatCoordinates_.length,2,Nl,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){var t;return new Dt(this.type_,this.flatCoordinates_.slice(),(t=this.ends_)==null?void 0:t.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=ma((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=Hn(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=Fa(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,s);break;case"Polygon":s=[],i.length=wr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,s);break}return s&&(this.simplifiedGeometry_=new Dt(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Dt.prototype.getFlatCoordinates=Dt.prototype.getOrientedFlatCoordinates;class ms{constructor(t){this.rbush_=new el(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[X(e)]=i}load(t,e){const i=new Array(e.length);for(let s=0,r=e.length;s<r;s++){const o=t[s],a=e[s],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[s]=l,this.items_[X(a)]=l}this.rbush_.load(i)}remove(t){const e=X(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){const i=this.items_[X(e)],s=[i.minX,i.minY,i.maxX,i.maxY];zi(s,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(s){return s.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let s=0,r=t.length;s<r;s++)if(i=e(t[s]),i)return i;return i}isEmpty(){return Xe(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return We(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(const e in t.items_)this.items_[e]=t.items_[e]}}class Gl extends Yt{constructor(t){super(),this.projection=ot(t.projection),this.attributions_=zl(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(i,s){e.viewResolver=i,e.viewRejector=s})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=zl(t),this.changed()}setState(t){this.state_=t,this.changed()}}function zl(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}const Et={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class Oe extends Mt{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class pn extends Gl{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=Zi,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(it(this.format_,"`format` must be set when `url` is set"),this.loader_=Ol(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:nf;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new ms:null,this.loadedExtentsRtree_=new ms,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(t.features)?s=t.features:t.features&&(i=t.features,s=i.getArray()),!e&&i===void 0&&(i=new xt(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=X(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Oe(Et.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Dt||(this.featureChangeKeys_[t]=[z(e,D.CHANGE,this.handleFeatureChange_,this),z(e,di.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const s=String(e.getId());if(!(s in this.idIndex_))this.idIndex_[s]=e;else if(e instanceof Dt){const r=this.idIndex_[s];r instanceof Dt?Array.isArray(r)?r.push(e):this.idIndex_[s]=[r,e]:i=!1}else i=!1}return i&&(it(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],s=[];for(let r=0,o=t.length;r<o;r++){const a=t[r],l=X(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=X(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();e.push(c),s.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,s),this.hasListener(Et.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new Oe(Et.ADDFEATURE,i[r]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(Et.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(Et.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(nt.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(nt.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach($);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(const i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new Oe(Et.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(s){const r=s.getGeometry();if(r instanceof Dt||r.intersectsCoordinate(t))return e(s)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){const s=i.getGeometry();if(s instanceof Dt||s.intersectsExtent(t)){const r=e(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),Xe(this.nullGeometryFeatures_)||Ot(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const s=Oh(t,e);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],s=t[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return e=e||Bt,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){const c=h.getGeometry(),u=a;if(a=c instanceof Dt?0:c.closestPointXY(i,s,o,a),a<u){r=h;const d=Math.sqrt(a);l[0]=i-d,l[1]=s-d,l[2]=i+d,l[3]=s+d}}}),r}getExtent(t){return this.featuresRtree_.getExtent(t)}getFeatureById(t){const e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,i=X(e),s=e.getGeometry();if(!s)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{const o=s.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}const r=e.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new Oe(Et.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return e!==void 0?e in this.idIndex_:X(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Xe(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){const s=this.loadedExtentsRtree_,r=this.strategy_(t,e,i);for(let o=0,a=r.length;o<a;++o){const l=r[o];s.forEachInExtent(l,function(c){return ae(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Oe(Et.FEATURESLOADSTART)),this.loader_.call(this,l,e,i,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new Oe(Et.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Oe(Et.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(t){const e=this.loadedExtentsRtree_,i=e.forEachInExtent(t,function(s){if(zi(s.extent,t))return s});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,s=t.length;i<s;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=X(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t);const i=this.featureChangeKeys_[e];i==null||i.forEach($),delete this.featureChangeKeys_[e];const s=t.getId();if(s!==void 0){const r=s.toString(),o=this.idIndex_[r];o===t?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[e],this.hasListener(Et.REMOVEFEATURE)&&this.dispatchEvent(new Oe(Et.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(const e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){it(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(Ol(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}}const B={SINGLECLICK:"singleclick",CLICK:D.CLICK,DBLCLICK:D.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},ys={ACTIVE:"active"};class Ti extends Yt{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(ys.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(ys.ACTIVE,t)}setMap(t){this.map_=t}}function of(n,t,e){const i=n.getCenterInternal();if(i){const s=[i[0]+t[0],i[1]+t[1]];n.animateInternal({duration:e!==void 0?e:250,easing:Ad,center:n.getConstrainedCenter(s)})}}function Qr(n,t,e,i){const s=n.getZoom();if(s===void 0)return;const r=n.getConstrainedZoom(s+t),o=n.getResolutionForZoom(r);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:e,duration:i!==void 0?i:250,easing:Si})}class af extends Ti{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:250}handleEvent(t){let e=!1;if(t.type==B.DBLCLICK){const i=t.originalEvent,s=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=s.getView();Qr(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}function to(n){const t=arguments;return function(e){let i=!0;for(let s=0,r=t.length;s<r&&(i=i&&t[s](e),!!i);++s);return i}}const lf=function(n){const t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},hf=function(n){const t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},cf=function(n){const t=n.map.getTargetElement(),e=t.getRootNode(),i=n.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},Wl=function(n){const t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?cf(n):!0},xn=Bt,uf=function(n){return n.type==B.CLICK},jl=function(n){const t=n.originalEvent;return"pointerId"in t&&t.button==0&&!(Xh&&Xs&&t.ctrlKey)},eo=Ye,Vl=function(n){return n.type==B.SINGLECLICK},io=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},df=function(n){const t=n.originalEvent;return!t.altKey&&(Xs?t.metaKey:t.ctrlKey)&&!t.shiftKey},ff=function(n){const t=n.originalEvent;return Xs?t.metaKey:t.ctrlKey},no=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Xl=function(n){const t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},so=function(n){const t=n.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"},Bl=function(n){const t=n.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};class gf extends fr{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,i="px",s=this.element_.style;s.left=Math.min(t[0],e[0])+i,s.top=Math.min(t[1],e[1])+i,s.width=Math.abs(e[0]-t[0])+i,s.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const e=this.element_.style;e.left="inherit",e.top="inherit",e.width="inherit",e.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const t=this.startPixel_,e=this.endPixel_,s=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);s[4]=s[0].slice(),this.geometry_?this.geometry_.setCoordinates([s]):this.geometry_=new qt([s])}getGeometry(){return this.geometry_}}class ye extends Ti{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==B.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==B.POINTERUP){const i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==B.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==B.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}}function ro(n){const t=n.length;let e=0,i=0;for(let s=0;s<t;s++)e+=n[s].clientX,i+=n[s].clientY;return{clientX:e/t,clientY:i/t}}const Pi={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class En extends Mt{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class _f extends ye{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new gf(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??jl,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const s=i[0]-e[0],r=i[1]-e[1];return s*s+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new En(Pi.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new En(e?Pi.BOXEND:Pi.BOXCANCEL,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return this.condition_(t)?(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new En(Pi.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new En(Pi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new En(Pi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class mf extends ye{constructor(t){super({stopDown:Ye}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:to(io,Bl);this.condition_=t.onFocusOnly?to(Wl,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const i=this.targetPointers,s=e.getEventPixel(ro(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(s[0],s[1]),this.lastCentroid){const r=[this.lastCentroid[0]-s[0],s[1]-this.lastCentroid[1]],a=t.map.getView();Wh(r,a.getResolution()),Vs(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=s,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const s=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-s*Math.cos(r),a[1]-s*Math.sin(r)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:Si})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){const i=t.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class yf extends ye{constructor(t){t=t||{},super({stopDown:Ye}),this.condition_=t.condition?t.condition:hf,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!so(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===Kr)return;const s=e.getSize(),r=t.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(t){return so(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return so(t)&&jl(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class pf extends _f{constructor(t){t=t||{};const e=t.condition?t.condition:no;super({condition:e,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=t.duration!==void 0?t.duration:200,this.out_=t.out!==void 0?t.out:!1}onBoxEnd(t){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:Si})}}class Mi extends Mt{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}}class pe extends Mi{constructor(t,e,i,s,r,o){super(t,e,r),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=s!==void 0?s:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const ps={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class xs extends Mt{constructor(t,e){super(t),this.feature=e}}function xf(n,t){const e=[];for(let i=0;i<t.length;++i){const r=t[i].getGeometry();Yl(n,r,e)}return e}function Es(n,t){return le(n[0],n[1],t[0],t[1])}function Li(n,t){const e=n.length;return t<0?n[t+e]:t>=e?n[t-e]:n[t]}function Cs(n,t,e){let i,s;t<e?(i=t,s=e):(i=e,s=t);const r=Math.ceil(i),o=Math.floor(s);if(r>o){const l=Ai(n,i),h=Ai(n,s);return Es(l,h)}let a=0;if(i<r){const l=Ai(n,i),h=Li(n,r);a+=Es(l,h)}if(o<s){const l=Li(n,o),h=Ai(n,s);a+=Es(l,h)}for(let l=r;l<o-1;++l){const h=Li(n,l),c=Li(n,l+1);a+=Es(h,c)}return a}function Yl(n,t,e){if(t instanceof ie){ws(n,t.getCoordinates(),!1,e);return}if(t instanceof vi){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s)ws(n,i[s],!1,e);return}if(t instanceof qt){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s)ws(n,i[s],!0,e);return}if(t instanceof Ri){const i=t.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length;a<l;++a)ws(n,o[a],!0,e)}return}if(t instanceof mn){const i=t.getGeometries();for(let s=0;s<i.length;++s)Yl(n,i[s],e);return}}const oo={index:-1,endIndex:NaN};function Ef(n,t,e,i){const s=n[0],r=n[1];let o=1/0,a=-1,l=NaN;for(let u=0;u<t.targets.length;++u){const d=t.targets[u],f=d.coordinates;let g=1/0,m;for(let _=0;_<f.length-1;++_){const y=f[_],p=f[_+1],E=Zl(s,r,y,p);E.squaredDistance<g&&(g=E.squaredDistance,m=_+E.along)}g<o&&(o=g,d.ring&&t.targetIndex===u&&(d.endIndex>d.startIndex?m<d.startIndex&&(m+=f.length):d.endIndex<d.startIndex&&m>d.startIndex&&(m-=f.length)),l=m,a=u)}const h=t.targets[a];let c=h.ring;if(t.targetIndex===a&&c){const u=Ai(h.coordinates,l),d=e.getPixelFromCoordinate(u);Dn(d,t.startPx)>i&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(f<g){const m=Cs(u,f,g);Cs(u,f,g-d)<m&&(l-=d)}else{const m=Cs(u,f,g);Cs(u,f,g+d)<m&&(l+=d)}}return oo.index=a,oo.endIndex=l,oo}function ws(n,t,e,i){const s=n[0],r=n[1];for(let o=0,a=t.length-1;o<a;++o){const l=t[o],h=t[o+1],c=Zl(s,r,l,h);if(c.squaredDistance===0){const u=o+c.along;i.push({coordinates:t,ring:e,startIndex:u,endIndex:u});return}}}const ao={along:0,squaredDistance:0};function Zl(n,t,e,i){const s=e[0],r=e[1],o=i[0],a=i[1],l=o-s,h=a-r;let c=0,u=s,d=r;return(l!==0||h!==0)&&(c=rt(((n-s)*l+(t-r)*h)/(l*l+h*h),0,1),u+=l*c,d+=h*c),ao.along=c,ao.squaredDistance=Fn(le(n,t,u,d),10),ao}function Ai(n,t){const e=n.length;let i=Math.floor(t);const s=t-i;i>=e?i-=e:i<0&&(i+=e);let r=i+1;r>=e&&(r-=e);const o=n[i],a=o[0],l=o[1],h=n[r],c=h[0]-a,u=h[1]-l;return[a+c*s,l+u*s]}class Cf extends ye{constructor(t){const e=t;e.stopDown||(e.stopDown=Ye),super(e),this.on,this.once,this.un,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=t.source?t.source:null,this.features_=t.features?t.features:null,this.snapTolerance_=t.snapTolerance?t.snapTolerance:12,this.type_=t.type,this.mode_=Sf(this.type_),this.stopClick_=!!t.stopClick,this.minPoints_=t.minPoints?t.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:t.maxPoints?t.maxPoints:1/0,this.finishCondition_=t.finishCondition?t.finishCondition:Bt,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let i=t.geometryFunction;if(!i){const s=this.mode_;if(s==="Circle")i=(r,o,a)=>{const l=o||new _s([NaN,NaN]),h=U(r[0]),c=he(h,U(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;s==="Point"?r=Rt:s==="LineString"?r=ie:s==="Polygon"&&(r=qt),i=(o,a,l)=>(a?s==="Polygon"?o[0].length?a.setCoordinates([o[0].concat([o[0][0]])],this.geometryLayout_):a.setCoordinates([],this.geometryLayout_):a.setCoordinates(o,this.geometryLayout_):a=new r(o,this.geometryLayout_),a)}}this.geometryFunction_=i,this.dragVertexDelay_=t.dragVertexDelay!==void 0?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new Ii({source:new pn({useSpatialIndex:!1,wrapX:t.wrapX?t.wrapX:!1}),style:t.style?t.style:wf(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:io,this.freehandCondition_,t.freehand?this.freehandCondition_=xn:this.freehandCondition_=t.freehandCondition?t.freehandCondition:no,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(ys.ACTIVE,this.updateState_)}setTrace(t){let e;t?t===!0?e=xn:e=t:e=eo,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}getOverlay(){return this.overlay_}handleEvent(t){t.originalEvent.type===D.CONTEXTMENU&&t.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(t);let e=t.type===B.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&t.type===B.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&t.type===B.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===B.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===B.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):(t.originalEvent.pointerType==="mouse"||t.type===B.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(t)):t.type===B.DBLCLICK&&(i=!1),super.handleEvent(t)&&i}handleDownEvent(t){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=t.pixel,this.finishCoordinate_||this.startDrawing_(t.coordinate),!0):this.condition_(t)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new pe(B.POINTERMOVE,t.map,t.originalEvent,!1,t.frameState))},this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active){this.deactivateTrace_();return}const e=this.getMap(),i=e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),s=e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_]),r=ut([i,s]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=xf(t.coordinate,o);a.length&&(this.traceState_={active:!0,startPx:t.pixel.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const i=t.startIndex<=t.endIndex,s=t.startIndex<=e;i===s?i&&e>t.endIndex||!i&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(i&&e<t.endIndex||!i&&e>t.endIndex)&&this.removeTracedCoordinates_(e,t.endIndex):(this.removeTracedCoordinates_(t.startIndex,t.endIndex),this.addTracedCoordinates_(t,t.startIndex,e))}removeTracedCoordinates_(t,e){if(t===e)return;let i=0;if(t<e){const s=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),i=r-s+1}else{const s=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),i=s-r+1}i>0&&this.removeLastPoints_(i)}addTracedCoordinates_(t,e,i){if(e===i)return;const s=[];if(e<i){const r=Math.ceil(e);let o=Math.floor(i);o===i&&(o-=1);for(let a=r;a<=o;++a)s.push(Li(t.coordinates,a))}else{const r=Math.floor(e);let o=Math.ceil(i);o===i&&(o+=1);for(let a=r;a>=o;--a)s.push(Li(t.coordinates,a))}s.length&&this.appendCoordinates(s)}updateTrace_(t){const e=this.traceState_;if(!e.active||e.targetIndex===-1&&Dn(e.startPx,t.pixel)<this.snapTolerance_)return;const i=Ef(t.coordinate,e,this.getMap(),this.snapTolerance_);if(e.targetIndex!==i.index){if(e.targetIndex!==-1){const l=e.targets[e.targetIndex];this.removeTracedCoordinates_(l.startIndex,l.endIndex)}const a=e.targets[i.index];this.addTracedCoordinates_(a,a.startIndex,i.endIndex)}else{const a=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(a,i.endIndex)}e.targetIndex=i.index;const s=e.targets[e.targetIndex];s.endIndex=i.endIndex;const r=Ai(s.coordinates,s.endIndex),o=this.getMap().getPixelFromCoordinate(r);t.coordinate=r,t.pixel=[Math.round(o[0]),Math.round(o[1])]}handleUpEvent(t){let e=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(t);const i=this.traceState_.active;if(this.toggleTraceState_(t),this.shouldHandle_){const s=!this.finishCoordinate_;s&&this.startDrawing_(t.coordinate),!s&&this.freehand_?this.finishDrawing():!this.freehand_&&(!s||this.mode_==="Point")&&(this.atFinish_(t.pixel,i)?this.finishCondition_(t)&&this.finishDrawing():this.addToDrawing_(t.coordinate)),e=!1}else this.freehand_&&this.abortDrawing()}return!e&&this.stopClick_&&t.preventDefault(),e}handlePointerMove_(t){if(this.pointerType_=t.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const e=this.downPx_,i=t.pixel,s=e[0]-i[0],r=e[1]-i[1],o=s*s+r*r;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(t.coordinate.slice());return}this.updateTrace_(t),this.modifyDrawing_(t.coordinate)}atFinish_(t,e){let i=!1;if(this.sketchFeature_){let s=!1,r=[this.finishCoordinate_];const o=this.mode_;if(o==="Point")i=!0;else if(o==="Circle")i=this.sketchCoords_.length===2;else if(o==="LineString")s=!e&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){const a=this.sketchCoords_;s=a[0].length>this.minPoints_,r=[a[0][0],a[0][a[0].length-2]],e?r=[a[0][0]]:r=[a[0][0],a[0][a[0].length-2]]}if(s){const a=this.getMap();for(let l=0,h=r.length;l<h;l++){const c=r[l],u=a.getPixelFromCoordinate(c),d=t[0]-u[0],f=t[1]-u[1],g=this.freehand_?1:this.snapTolerance_;if(i=Math.sqrt(d*d+f*f)<=g,i){this.finishCoordinate_=c;break}}}}return i}createOrUpdateSketchPoint_(t){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(t):(this.sketchPoint_=new gt(new Rt(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new gt);const e=t.getLinearRing(0);let i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),i.changed()):(i=new ie(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(t){const e=this.getMap().getView().getProjection(),i=ts(this.geometryLayout_);for(;t.length<i;)t.push(0);this.finishCoordinate_=t,this.mode_==="Point"?this.sketchCoords_=t.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[t.slice(),t.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[t.slice(),t.slice()],this.sketchLineCoords_&&(this.sketchLine_=new gt(new ie(this.sketchLineCoords_)));const s=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new gt,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(s),this.updateSketchFeatures_(),this.dispatchEvent(new xs(ps.DRAWSTART,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),i=this.sketchFeature_.getGeometry(),s=e.getView().getProjection(),r=ts(this.geometryLayout_);let o,a;for(;t.length<r;)t.push(0);this.mode_==="Point"?a=this.sketchCoords_:this.mode_==="Polygon"?(o=this.sketchCoords_[0],a=o[o.length-1],this.atFinish_(e.getPixelFromCoordinate(t))&&(t=this.finishCoordinate_.slice())):(o=this.sketchCoords_,a=o[o.length-1]),a[0]=t[0],a[1]=t[1],this.geometryFunction_(this.sketchCoords_,i,s),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(t),i.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(i):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(t){const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection();let s,r;const o=this.mode_;return o==="LineString"||o==="Circle"?(this.finishCoordinate_=t.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():s=!0),r.push(t.slice()),this.geometryFunction_(r,e,i)):o==="Polygon"&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():s=!0),r.push(t.slice()),s&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,i)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),s?this.finishDrawing():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),s=this.mode_;for(let r=0;r<t;++r){let o;if(s==="LineString"||s==="Circle"){if(o=this.sketchCoords_,o.splice(-2,1),o.length>=2){this.finishCoordinate_=o[o.length-2].slice();const a=this.finishCoordinate_.slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}this.geometryFunction_(o,e,i),e.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if(s==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);const a=this.sketchLine_.getGeometry();if(o.length>=2){const l=o[o.length-2].slice();o[o.length-1]=l,this.createOrUpdateSketchPoint_(l)}a.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,e,i)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return null;let e=this.sketchCoords_;const i=t.getGeometry(),s=this.getMap().getView().getProjection();return this.mode_==="LineString"?(e.pop(),this.geometryFunction_(e,i,s)):this.mode_==="Polygon"&&(e[0].pop(),this.geometryFunction_(e,i,s),e=i.getCoordinates()),this.type_==="MultiPoint"?t.setGeometry(new yn([e])):this.type_==="MultiLineString"?t.setGeometry(new vi([e])):this.type_==="MultiPolygon"&&t.setGeometry(new Ri([e])),this.dispatchEvent(new xs(ps.DRAWEND,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t),t}abortDrawing_(){this.finishCoordinate_=null;const t=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),t}abortDrawing(){const t=this.abortDrawing_();t&&this.dispatchEvent(new xs(ps.DRAWABORT,t))}appendCoordinates(t){const e=this.mode_,i=!this.sketchFeature_;i&&this.startDrawing_(t[0]);let s;if(e==="LineString"||e==="Circle")s=this.sketchCoords_;else if(e==="Polygon")s=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;i&&s.shift(),s.pop();for(let o=0;o<t.length;o++)this.addToDrawing_(t[o]);const r=t[t.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(t){const i=t.getGeometry();this.sketchFeature_=t,this.sketchCoords_=i.getCoordinates();const s=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=s.slice(),this.sketchCoords_.push(s.slice()),this.sketchPoint_=new gt(new Rt(s)),this.updateSketchFeatures_(),this.dispatchEvent(new xs(ps.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){const t=[];this.sketchFeature_&&t.push(this.sketchFeature_),this.sketchLine_&&t.push(this.sketchLine_),this.sketchPoint_&&t.push(this.sketchPoint_);const e=this.overlay_.getSource();e.clear(!0),e.addFeatures(t)}updateState_(){const t=this.getMap(),e=this.getActive();(!t||!e)&&this.abortDrawing(),this.overlay_.setMap(e?t:null)}}function wf(){const n=Pr();return function(t,e){return n[t.getGeometry().getType()]}}function Sf(n){switch(n){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+n)}}const ei={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class If extends Ti{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return io(e)&&Xl(e)},this.condition_=t.condition!==void 0?t.condition:this.defaultCondition_,this.duration_=t.duration!==void 0?t.duration:100,this.pixelDelta_=t.pixelDelta!==void 0?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==D.KEYDOWN){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==ei.DOWN||s==ei.LEFT||s==ei.RIGHT||s==ei.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;s==ei.DOWN?h=-a:s==ei.LEFT?l=-a:s==ei.RIGHT?l=a:h=a;const c=[l,h];Vs(c,o.getRotation()),of(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}}class vf extends Ti{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!ff(e)&&Xl(e)},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:100}handleEvent(t){let e=!1;if(t.type==D.KEYDOWN||t.type==D.KEYPRESS){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==="+"||s==="-")){const r=t.map,o=s==="+"?this.delta_:-this.delta_,a=r.getView();Qr(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}const xe={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Kl=0,Cn=1,Ul=[0,0,0,0],Fi=[],lo={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"};class ho extends Mt{constructor(t,e,i){super(t),this.features=e,this.mapBrowserEvent=i}}class Rf extends ye{constructor(t){super(t),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=t.condition?t.condition:Bl,this.defaultDeleteCondition_=function(i){return lf(i)&&Vl(i)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:xn,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new ms,this.pixelTolerance_=t.pixelTolerance!==void 0?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Ii({source:new pn({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:Pf(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let e;if(t.features?e=t.features:t.source&&(this.source_=t.source,e=new xt(this.source_.getFeatures()),this.source_.addEventListener(Et.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Et.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!e)throw new Error("The modify interaction requires features, a source or a layer");t.hitDetection&&(this.hitDetection_=t.hitDetection),this.features_=e,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(nt.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(nt.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=t.snapToPointer===void 0?!this.hitDetection_:t.snapToPointer}addFeature_(t){const e=t.getGeometry();if(e){const s=this.SEGMENT_WRITERS_[e.getType()];s&&s(t,e)}const i=this.getMap();i&&i.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(i.getCoordinateFromPixel(this.lastPixel_)),t.addEventListener(D.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(t,e){if(!this.featuresBeingModified_){this.featuresBeingModified_=new xt;const i=this.featuresBeingModified_.getArray();for(let s=0,r=e.length;s<r;++s){const o=e[s].feature;o&&!i.includes(o)&&this.featuresBeingModified_.push(o)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new ho(lo.MODIFYSTART,this.featuresBeingModified_,t))}}removeFeature_(t){this.removeFeatureSegmentData_(t),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.removeEventListener(D.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(t){const e=this.rBush_,i=[];e.forEach(function(s){t===s.feature&&i.push(s)});for(let s=i.length-1;s>=0;--s){const r=i[s];for(let o=this.dragSegments_.length-1;o>=0;--o)this.dragSegments_[o][0]===r&&this.dragSegments_.splice(o,1);e.remove(r)}}setActive(t){this.vertexFeature_&&!t&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(t)}setMap(t){this.overlay_.setMap(t),super.setMap(t)}getOverlay(){return this.overlay_}handleSourceAdd_(t){t.feature&&this.features_.push(t.feature)}handleSourceRemove_(t){t.feature&&this.features_.remove(t.feature)}handleFeatureAdd_(t){this.addFeature_(t.element)}handleFeatureChange_(t){if(!this.changingFeature_){const e=t.target;this.removeFeature_(e),this.addFeature_(e)}}handleFeatureRemove_(t){this.removeFeature_(t.element)}writePointGeometry_(t,e){const i=e.getCoordinates(),s={feature:t,geometry:e,segment:[i,i]};this.rBush_.insert(e.getExtent(),s)}writeMultiPointGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s],a={feature:t,geometry:e,depth:[s],index:s,segment:[o,o]};this.rBush_.insert(e.getExtent(),a)}}writeLineStringGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length-1;s<r;++s){const o=i.slice(s,s+2),a={feature:t,geometry:e,index:s,segment:o};this.rBush_.insert(ut(o),a)}}writeMultiLineStringGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:t,geometry:e,depth:[s],index:a,segment:h};this.rBush_.insert(ut(h),c)}}}writePolygonGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:t,geometry:e,depth:[s],index:a,segment:h};this.rBush_.insert(ut(h),c)}}}writeMultiPolygonGeometry_(t,e){const i=e.getCoordinates();for(let s=0,r=i.length;s<r;++s){const o=i[s];for(let a=0,l=o.length;a<l;++a){const h=o[a];for(let c=0,u=h.length-1;c<u;++c){const d=h.slice(c,c+2),f={feature:t,geometry:e,depth:[a,s],index:c,segment:d};this.rBush_.insert(ut(d),f)}}}}writeCircleGeometry_(t,e){const i=e.getCenter(),s={feature:t,geometry:e,index:Kl,segment:[i,i]},r={feature:t,geometry:e,index:Cn,segment:[i,i]},o=[s,r];s.featureSegments=o,r.featureSegments=o,this.rBush_.insert(Gi(i),s);let a=e;this.rBush_.insert(a.getExtent(),r)}writeGeometryCollectionGeometry_(t,e){const i=e.getGeometriesArray();for(let s=0;s<i.length;++s){const r=i[s],o=this.SEGMENT_WRITERS_[r.getType()];o(t,r)}}createOrUpdateVertexFeature_(t,e,i,s){let r=this.vertexFeature_;return r?r.getGeometry().setCoordinates(t):(r=new gt(new Rt(t)),this.vertexFeature_=r,this.overlay_.getSource().addFeature(r)),r.set("features",e),r.set("geometries",i),r.set("existing",s),r}handleEvent(t){if(!t.originalEvent)return!0;this.lastPointerEvent_=t;let e;return!t.map.getView().getInteracting()&&t.type==B.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(t.type!=B.SINGLECLICK||!this.ignoreNextSingleClick_?e=this.removePoint():e=!0),t.type==B.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(t)&&!e}findInsertVerticesAndUpdateDragSegments_(t){this.handlePointerAtPixel_(t),this.dragSegments_.length=0,this.featuresBeingModified_=null;const e=this.vertexFeature_;if(!e)return;this.getMap().getView().getProjection();const i=[],s=e.getGeometry().getCoordinates(),r=ut([s]),o=this.rBush_.getInExtent(r),a={};o.sort(Tf);for(let l=0,h=o.length;l<h;++l){const c=o[l],u=c.segment;let d=X(c.geometry);const f=c.depth;if(f&&(d+="-"+f.join("-")),a[d]||(a[d]=new Array(2)),c.geometry.getType()==="Circle"&&c.index===Cn){const g=ql(t,c);It(g,s)&&!a[d][0]&&(this.dragSegments_.push([c,0]),a[d][0]=c);continue}if(It(u[0],s)&&!a[d][0]){this.dragSegments_.push([c,0]),a[d][0]=c;continue}if(It(u[1],s)&&!a[d][1]){if(a[d][0]&&a[d][0].index===0){let g=c.geometry.getCoordinates();switch(c.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":g=g[f[1]];case"Polygon":if(c.index!==g[f[0]].length-2)continue;break}}this.dragSegments_.push([c,1]),a[d][1]=c;continue}X(u)in this.vertexSegments_&&!a[d][0]&&!a[d][1]&&i.push(c)}return i}handleDragEvent(t){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(t,this.dragSegments_.map(([r])=>r));const e=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],i=[],s=[];for(let r=0,o=this.dragSegments_.length;r<o;++r){const a=this.dragSegments_[r],l=a[0],h=l.feature;i.includes(h)||i.push(h);const c=l.geometry;s.includes(c)||s.push(c);const u=l.depth;let d;const f=l.segment,g=a[1];for(;e.length<c.getStride();)e.push(f[g][e.length]);switch(c.getType()){case"Point":d=e,f[0]=e,f[1]=e;break;case"MultiPoint":d=c.getCoordinates(),d[l.index]=e,f[0]=e,f[1]=e;break;case"LineString":d=c.getCoordinates(),d[l.index+g]=e,f[g]=e;break;case"MultiLineString":d=c.getCoordinates(),d[u[0]][l.index+g]=e,f[g]=e;break;case"Polygon":d=c.getCoordinates(),d[u[0]][l.index+g]=e,f[g]=e;break;case"MultiPolygon":d=c.getCoordinates(),d[u[1]][u[0]][l.index+g]=e,f[g]=e;break;case"Circle":const m=c;if(f[0]=e,f[1]=e,l.index===Kl)this.changingFeature_=!0,m.setCenter(e),this.changingFeature_=!1;else{this.changingFeature_=!0,t.map.getView().getProjection();let _=Dn(U(m.getCenter()),U(e));m.setRadius(_),this.changingFeature_=!1}break}d&&this.setGeometryCoordinates_(c,d)}this.createOrUpdateVertexFeature_(e,i,s,!0)}handleDownEvent(t){if(!this.condition_(t))return!1;const e=t.coordinate,i=this.findInsertVerticesAndUpdateDragSegments_(e);if(i!=null&&i.length&&this.insertVertexCondition_(t)&&(this.willModifyFeatures_(t,i),this.vertexFeature_)){const s=this.vertexFeature_.getGeometry().getCoordinates();for(let r=i.length-1;r>=0;--r)this.insertVertex_(i[r],s);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(t){for(let e=this.dragSegments_.length-1;e>=0;--e){const i=this.dragSegments_[e][0],s=i.geometry;if(s.getType()==="Circle"){const r=s,o=r.getCenter(),a=i.featureSegments[0],l=i.featureSegments[1];a.segment[0]=o,a.segment[1]=o,l.segment[0]=o,l.segment[1]=o,this.rBush_.update(Gi(o),a);let h=r;this.rBush_.update(h.getExtent(),l)}else this.rBush_.update(ut(i.segment),i)}return this.featuresBeingModified_&&(this.dispatchEvent(new ho(lo.MODIFYEND,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastPixel_=t.pixel,this.handlePointerAtPixel_(t.coordinate)}handlePointerAtPixel_(t){const e=this.getMap(),i=e.getPixelFromCoordinate(t);e.getView().getProjection();const s=function(a,l){return Hl(t,a)-Hl(t,l)};let r,o;if(this.hitDetection_){const a=typeof this.hitDetection_=="object"?l=>l===this.hitDetection_:void 0;e.forEachFeatureAtPixel(i,(l,h,c)=>{c&&c.getType()==="Point"&&(c=new Rt(Re(c.getCoordinates())));const u=c||l.getGeometry();if(u&&u.getType()==="Point"&&l instanceof gt&&this.features_.getArray().includes(l)){o=u;const d=l.getGeometry().getFlatCoordinates().slice(0,2);r=[{feature:l,geometry:o,segment:[d,d]}]}return!0},{layerFilter:a})}if(!r){const a=Te(Gi(t,Ul)),l=e.getView().getResolution()*this.pixelTolerance_,h=Vn(Oi(a,l,Ul));r=this.rBush_.getInExtent(h)}if(r&&r.length>0){const a=r.sort(s)[0],l=a.segment;let h=ql(t,a);const c=e.getPixelFromCoordinate(h);let u=Dn(i,c);if(o||u<=this.pixelTolerance_){const d={};if(d[X(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-t[0],this.delta_[1]=h[1]-t[1]),a.geometry.getType()==="Circle"&&a.index===Cn)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const f=e.getPixelFromCoordinate(l[0]),g=e.getPixelFromCoordinate(l[1]),m=he(c,f),_=he(c,g);if(u=Math.sqrt(Math.min(m,_)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_)){this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null);return}this.snappedToVertex_&&(h=m>_?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const y={};y[X(a.geometry)]=!0;for(let p=1,E=r.length;p<E;++p){const x=r[p].segment;if(It(l[0],x[0])&&It(l[1],x[1])||It(l[0],x[1])&&It(l[1],x[0])){const C=X(r[p].geometry);C in y||(y[C]=!0,d[X(x)]=!0)}else break}}this.vertexSegments_=d;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(t,e){const i=t.segment,s=t.feature,r=t.geometry,o=t.depth,a=t.index;let l;for(;e.length<r.getStride();)e.push(0);switch(r.getType()){case"MultiLineString":l=r.getCoordinates(),l[o[0]].splice(a+1,0,e);break;case"Polygon":l=r.getCoordinates(),l[o[0]].splice(a+1,0,e);break;case"MultiPolygon":l=r.getCoordinates(),l[o[1]][o[0]].splice(a+1,0,e);break;case"LineString":l=r.getCoordinates(),l.splice(a+1,0,e);break;default:return!1}this.setGeometryCoordinates_(r,l);const h=this.rBush_;h.remove(t),this.updateSegmentIndices_(r,a,o,1);const c={segment:[i[0],e],feature:s,geometry:r,depth:o,index:a};h.insert(ut(c.segment),c),this.dragSegments_.push([c,1]);const u={segment:[e,i[1]],feature:s,geometry:r,depth:o,index:a+1};return h.insert(ut(u.segment),u),this.dragSegments_.push([u,0]),!0}updatePointer_(t){var e;return t&&this.findInsertVerticesAndUpdateDragSegments_(t),(e=this.vertexFeature_)==null?void 0:e.getGeometry().getCoordinates()}getPoint(){var e;const t=(e=this.vertexFeature_)==null?void 0:e.getGeometry().getCoordinates();return t?Re(t,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(i=>i.getType()==="Circle"||i.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ut([t])).some(({segment:i})=>It(i[0],t)||It(i[1],t))}removePoint(t){if(t&&(t=U(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=B.POINTERDRAG){const e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_.map(([s])=>s));const i=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new ho(lo.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null,i}return!1}removeVertex_(){const t=this.dragSegments_,e={};let i=!1,s,r,o,a,l,h,c,u,d,f,g;for(l=t.length-1;l>=0;--l)o=t[l],f=o[0],g=X(f.feature),f.depth&&(g+="-"+f.depth.join("-")),g in e||(e[g]={}),o[1]===0?(e[g].right=f,e[g].index=f.index):o[1]==1&&(e[g].left=f,e[g].index=f.index+1);for(g in e){switch(d=e[g].right,c=e[g].left,h=e[g].index,u=h-1,c!==void 0?f=c:f=d,u<0&&(u=0),a=f.geometry,r=a.getCoordinates(),s=r,i=!1,a.getType()){case"MultiLineString":r[f.depth[0]].length>2&&(r[f.depth[0]].splice(h,1),i=!0);break;case"LineString":r.length>2&&(r.splice(h,1),i=!0);break;case"MultiPolygon":s=s[f.depth[1]];case"Polygon":s=s[f.depth[0]],s.length>4&&(h==s.length-1&&(h=0),s.splice(h,1),i=!0,h===0&&(s.pop(),s.push(s[0]),u=s.length-1));break}if(i){this.setGeometryCoordinates_(a,r);const m=[];if(c!==void 0&&(this.rBush_.remove(c),m.push(c.segment[0])),d!==void 0&&(this.rBush_.remove(d),m.push(d.segment[1])),c!==void 0&&d!==void 0){const _={depth:f.depth,feature:f.feature,geometry:f.geometry,index:u,segment:m};this.rBush_.insert(ut(_.segment),_)}this.updateSegmentIndices_(a,h,f.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return i}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(i=>i.getType()==="Circle"||i.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ut([t])).some(({segment:i})=>!(It(i[0],t)||It(i[1],t)))}insertPoint(t){var s;const e=t?U(t,this.getMap().getView().getProjection()):(s=this.vertexFeature_)==null?void 0:s.getGeometry().getCoordinates();return e?this.findInsertVerticesAndUpdateDragSegments_(e).reduce((r,o)=>r||this.insertVertex_(o,e),!1):!1}setGeometryCoordinates_(t,e){this.changingFeature_=!0,t.setCoordinates(e),this.changingFeature_=!1}updateSegmentIndices_(t,e,i,s){this.rBush_.forEachInExtent(t.getExtent(),function(r){r.geometry===t&&(i===void 0||r.depth===void 0||oe(r.depth,i))&&r.index>e&&(r.index+=s)})}}function Tf(n,t){return n.index-t.index}function Hl(n,t,e){const i=t.geometry;if(i.getType()==="Circle"){let r=i;if(t.index===Cn){const o=he(r.getCenter(),U(n)),a=Math.sqrt(o)-r.getRadius();return a*a}}const s=U(n);return Fi[0]=U(t.segment[0]),Fi[1]=U(t.segment[1]),jh(s,Fi)}function ql(n,t,e){const i=t.geometry;if(i.getType()==="Circle"&&t.index===Cn)return Re(i.getClosestPoint(U(n)));const s=U(n);return Fi[0]=U(t.segment[0]),Fi[1]=U(t.segment[1]),Re(js(s,Fi))}function Pf(){const n=Pr();return function(t,e){return n.Point}}const Mf=40,Lf=300;class Af extends Ti{constructor(t){t=t||{},super(t),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=t.maxDelta!==void 0?t.maxDelta:1,this.duration_=t.duration!==void 0?t.duration:250,this.timeout_=t.timeout!==void 0?t.timeout:80,this.useAnchor_=t.useAnchor!==void 0?t.useAnchor:!0,this.constrainResolution_=t.constrainResolution!==void 0?t.constrainResolution:!1;const e=t.condition?t.condition:xn;this.condition_=t.onFocusOnly?to(Wl,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;t.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t)||t.type!==D.WHEEL)return!0;const i=t.map,s=t.originalEvent;s.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel);let r=s.deltaY;switch(s.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=Mf;break;case WheelEvent.DOM_DELTA_PAGE:r*=Lf;break}if(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_?i.getCoordinateFromPixel(this.lastAnchor_):null),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_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-rt(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Qr(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}}class Ff extends ye{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Ye),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=t.threshold!==void 0?t.threshold:.3,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){let e=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),e=l}this.lastAngle_=r;const o=t.map,a=o.getView();a.getConstraints().rotation!==Kr&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(ro(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return this.targetPointers.length<2?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}class bf extends ye{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Ye),super(e),this.anchor_=null,this.duration_=t.duration!==void 0?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=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&&(e=this.lastDistance_/a),this.lastDistance_=a;const l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(ro(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const i=t.map.getView(),s=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,s),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}const Df={SELECT:"select"};class Of extends Mt{constructor(t,e,i,s){super(t),this.selected=e,this.deselected=i,this.mapBrowserEvent=s}}const Ss={};class co extends Ti{constructor(t){super(),this.on,this.once,this.un,t=t||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=t.condition?t.condition:Vl,this.addCondition_=t.addCondition?t.addCondition:eo,this.removeCondition_=t.removeCondition?t.removeCondition:eo,this.toggleCondition_=t.toggleCondition?t.toggleCondition:no,this.multi_=t.multi?t.multi:!1,this.filter_=t.filter?t.filter:Bt,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.style_=t.style!==void 0?t.style:kf(),this.features_=t.features||new xt;let e;if(t.layers)if(typeof t.layers=="function")e=t.layers;else{const i=t.layers;e=function(s){return i.includes(s)}}else e=Bt;this.layerFilter_=e,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(t,e){this.featureLayerAssociation_[X(t)]=e}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(t){return this.featureLayerAssociation_[X(t)]}setHitTolerance(t){this.hitTolerance_=t}setMap(t){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(t),t?(this.features_.addEventListener(nt.ADD,this.boundAddFeature_),this.features_.addEventListener(nt.REMOVE,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(nt.ADD,this.boundAddFeature_),this.features_.removeEventListener(nt.REMOVE,this.boundRemoveFeature_))}addFeature_(t){const e=t.element;if(this.style_&&this.applySelectedStyle_(e),!this.getLayer(e)){const i=this.getMap().getAllLayers().find(function(s){if(s instanceof Ii&&s.getSource()&&s.getSource().hasFeature(e))return s});i&&this.addFeatureLayerAssociation_(e,i)}}removeFeature_(t){this.style_&&this.restorePreviousStyle_(t.element)}getStyle(){return this.style_}applySelectedStyle_(t){const e=X(t);e in Ss||(Ss[e]=t.getStyle()),t.setStyle(this.style_)}restorePreviousStyle_(t){const e=this.getMap().getInteractions().getArray();for(let s=e.length-1;s>=0;--s){const r=e[s];if(r!==this&&r instanceof co&&r.getStyle()&&r.getFeatures().getArray().lastIndexOf(t)!==-1){t.setStyle(r.getStyle());return}}const i=X(t);t.setStyle(Ss[i]),delete Ss[i]}removeFeatureLayerAssociation_(t){delete this.featureLayerAssociation_[X(t)]}handleEvent(t){if(!this.condition_(t))return!0;const e=this.addCondition_(t),i=this.removeCondition_(t),s=this.toggleCondition_(t),r=!e&&!i&&!s,o=t.map,a=this.getFeatures(),l=[],h=[];if(r){li(this.featureLayerAssociation_),o.forEachFeatureAtPixel(t.pixel,(c,u)=>{if(!(!(c instanceof gt)||!this.filter_(c,u)))return this.addFeatureLayerAssociation_(c,u),h.push(c),!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let c=a.getLength()-1;c>=0;--c){const u=a.item(c),d=h.indexOf(u);d>-1?h.splice(d,1):(a.remove(u),l.push(u))}h.length!==0&&a.extend(h)}else{o.forEachFeatureAtPixel(t.pixel,(c,u)=>{if(!(!(c instanceof gt)||!this.filter_(c,u)))return(e||s)&&!a.getArray().includes(c)?(this.addFeatureLayerAssociation_(c,u),h.push(c)):(i||s)&&a.getArray().includes(c)&&(l.push(c),this.removeFeatureLayerAssociation_(c)),!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let c=l.length-1;c>=0;--c)a.remove(l[c]);a.extend(h)}return(h.length>0||l.length>0)&&this.dispatchEvent(new Of(Df.SELECT,h,l,t)),!0}}function kf(){const n=Pr();return Ot(n.Polygon,n.LineString),Ot(n.GeometryCollection,n.LineString),function(t){return t.getGeometry()?n[t.getGeometry().getType()]:null}}const uo={SNAP:"snap",UNSNAP:"unsnap"};class fo extends Mt{constructor(t,e){super(t),this.vertex=e.vertex,this.vertexPixel=e.vertexPixel,this.feature=e.feature,this.segment=e.segment}}const go={Circle(n,t){const i=Vd(n);return go.Polygon(i)},GeometryCollection(n,t){const e=[],i=n.getGeometriesArray();for(let s=0;s<i.length;++s){const r=go[i[s].getType()];r&&e.push(r(i[s],t))}return e.flat()},LineString(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride();for(let s=0,r=e.length-i;s<r;s+=i)t.push([e.slice(s,s+2),e.slice(s+i,s+i+2)]);return t},MultiLineString(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride(),s=n.getEnds();let r=0;for(let o=0,a=s.length;o<a;++o){const l=s[o];for(let h=r,c=l-i;h<c;h+=i)t.push([e.slice(h,h+2),e.slice(h+i,h+i+2)]);r=l}return t},MultiPoint(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride();for(let s=0,r=e.length;s<r;s+=i)t.push([e.slice(s,s+2)]);return t},MultiPolygon(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride(),s=n.getEndss();let r=0;for(let o=0,a=s.length;o<a;++o){const l=s[o];for(let h=0,c=l.length;h<c;++h){const u=l[h];for(let d=r,f=u-i;d<f;d+=i)t.push([e.slice(d,d+2),e.slice(d+i,d+i+2)]);r=u}}return t},Point(n){return[[n.getFlatCoordinates().slice(0,2)]]},Polygon(n){const t=[],e=n.getFlatCoordinates(),i=n.getStride(),s=n.getEnds();let r=0;for(let o=0,a=s.length;o<a;++o){const l=s[o];for(let h=r,c=l-i;h<c;h+=i)t.push([e.slice(h,h+2),e.slice(h+i,h+i+2)]);r=l}return t}};function $l(n){return n.feature?n.feature:n.element?n.element:null}const _o=[],Ee=[],bi=[];class Nf extends ye{constructor(t){t=t||{};const e=t;e.handleDownEvent||(e.handleDownEvent=Bt),e.stopDown||(e.stopDown=Ye),super(e),this.on,this.once,this.un,this.source_=t.source?t.source:null,this.vertex_=t.vertex!==void 0?t.vertex:!0,this.edge_=t.edge!==void 0?t.edge:!0,this.intersection_=t.intersection!==void 0?t.intersection:!1,this.features_=t.features?t.features:null,this.featuresListenerKeys_=[],this.featureChangeListenerKeys_={},this.indexedFeaturesExtents_={},this.pendingFeatures_={},this.pixelTolerance_=t.pixelTolerance!==void 0?t.pixelTolerance:10,this.rBush_=new ms,this.snapped_=null,this.segmenters_=Object.assign({},go,t.segmenters)}addFeature(t,e){e=e!==void 0?e:!0;const i=X(t),s=t.getGeometry();if(s){const r=this.segmenters_[s.getType()];if(r){this.indexedFeaturesExtents_[i]=s.getExtent(kt());const o=r(s,this.getMap().getView().getProjection());let a=o.length;for(let l=0;l<a;++l){const h=o[l];Ee[l]=ut(h),bi[l]={feature:t,segment:h}}if(Ee.length=a,bi.length=a,this.intersection_)for(let l=0,h=o.length;l<h;++l){const c=o[l];if(c.length===1)continue;const u=Ee[l];for(let f=0,g=o.length;f<g;++f){if(l===f||l-1===f||l+1===f)continue;const m=o[f];if(!_t(u,Ee[f]))continue;const _=vl(c,m);if(!_)continue;const y=[_];Ee[a]=ut(y),bi[a++]={feature:t,segment:y,isIntersection:!0}}const d=this.rBush_.getInExtent(Ee[l]);for(const{segment:f}of d){if(f.length===1)continue;const g=vl(c,f);if(!g)continue;const m=[g];Ee[a]=ut(m),bi[a++]={feature:t,segment:m,isIntersection:!0}}}a===1?this.rBush_.insert(Ee[0],bi[0]):this.rBush_.load(Ee,bi)}}e&&(this.featureChangeListenerKeys_[i]=z(t,D.CHANGE,this.handleFeatureChange_,this))}getFeatures_(){let t;return this.features_?t=this.features_:this.source_&&(t=this.source_.getFeatures()),t}areSnapDataEqual_(t,e){return t.segment===e.segment&&t.feature===e.feature}handleEvent(t){const e=this.snapTo(t.pixel,t.coordinate,t.map);return e?(t.coordinate=e.vertex.slice(0,2),t.pixel=e.vertexPixel,this.snapped_&&!this.areSnapDataEqual_(this.snapped_,e)&&this.dispatchEvent(new fo(uo.UNSNAP,this.snapped_)),this.snapped_={vertex:t.coordinate,vertexPixel:t.pixel,feature:e.feature,segment:e.segment},this.dispatchEvent(new fo(uo.SNAP,this.snapped_))):this.snapped_&&(this.dispatchEvent(new fo(uo.UNSNAP,this.snapped_)),this.snapped_=null),super.handleEvent(t)}handleFeatureAdd_(t){const e=$l(t);e&&this.addFeature(e)}handleFeatureRemove_(t){const e=$l(t);e&&this.removeFeature(e)}handleFeatureChange_(t){const e=t.target;if(this.handlingDownUpSequence){const i=X(e);i in this.pendingFeatures_||(this.pendingFeatures_[i]=e)}else this.updateFeature_(e)}handleUpEvent(t){const e=Object.values(this.pendingFeatures_);if(e.length)for(const i of e)this.updateFeature_(i);return!1}removeFeature(t,e){const i=e!==void 0?e:!0,s=X(t),r=this.indexedFeaturesExtents_[s];if(r){const o=this.rBush_,a=[];o.forEachInExtent(r,function(l){t===l.feature&&a.push(l)});for(let l=a.length-1;l>=0;--l)o.remove(a[l])}i&&($(this.featureChangeListenerKeys_[s]),delete this.featureChangeListenerKeys_[s])}setMap(t){const e=this.getMap(),i=this.featuresListenerKeys_;let s=this.getFeatures_();if(Array.isArray(s)||(s=s.getArray()),e&&(i.forEach($),i.length=0,this.rBush_.clear(),Object.values(this.featureChangeListenerKeys_).forEach($),this.featureChangeListenerKeys_={}),super.setMap(t),t){this.features_?i.push(z(this.features_,nt.ADD,this.handleFeatureAdd_,this),z(this.features_,nt.REMOVE,this.handleFeatureRemove_,this)):this.source_&&i.push(z(this.source_,Et.ADDFEATURE,this.handleFeatureAdd_,this),z(this.source_,Et.REMOVEFEATURE,this.handleFeatureRemove_,this));for(const r of s)this.addFeature(r)}}snapTo(t,e,i){i.getView().getProjection();const s=U(e),r=Vn(Oi(ut([s]),i.getView().getResolution()*this.pixelTolerance_)),o=this.rBush_.getInExtent(r),a=o.length;if(a===0)return null;let l,h=1/0,c,u=null,d;const f=this.pixelTolerance_*this.pixelTolerance_,g=()=>{if(l){const m=i.getPixelFromCoordinate(l);if(he(t,m)<=f&&(d&&this.intersection_||!d&&(this.vertex_||this.edge_)))return{vertex:l,vertexPixel:[Math.round(m[0]),Math.round(m[1])],feature:c,segment:u}}return null};if(this.vertex_||this.intersection_){for(let _=0;_<a;++_){const y=o[_];if(y.feature.getGeometry().getType()!=="Circle")for(const p of y.segment){const E=U(p),x=he(s,E);x<h&&(l=p,h=x,c=y.feature,d=y.isIntersection)}}const m=g();if(m)return m}if(this.edge_){for(let _=0;_<a;++_){let y=null;const p=o[_];if(p.feature.getGeometry().getType()==="Circle"){let E=p.feature.getGeometry();y=zh(s,E)}else{const[E,x]=p.segment;x&&(_o[0]=U(E),_o[1]=U(x),y=js(s,_o))}if(y){const E=he(s,y);E<h&&(l=Re(y),u=p.feature.getGeometry().getType()==="Circle"?null:p.segment,h=E,c=p.feature)}}const m=g();if(m)return m}return null}updateFeature_(t){this.removeFeature(t,!1),this.addFeature(t,!1)}}const mo={TRANSLATESTART:"translatestart",TRANSLATING:"translating",TRANSLATEEND:"translateend"};class yo extends Mt{constructor(t,e,i,s,r){super(t),this.features=e,this.coordinate=i,this.startCoordinate=s,this.mapBrowserEvent=r}}class Gf extends ye{constructor(t){t=t||{},super(t),this.on,this.once,this.un,this.lastCoordinate_=null,this.startCoordinate_=null,this.features_=t.features!==void 0?t.features:null;let e;if(t.layers&&!this.features_)if(typeof t.layers=="function")e=t.layers;else{const i=t.layers;e=function(s){return i.includes(s)}}else e=Bt;this.layerFilter_=e,this.filter_=t.filter&&!this.features_?t.filter:Bt,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.condition_=t.condition?t.condition:xn,this.lastFeature_=null,this.addChangeListener(ys.ACTIVE,this.handleActiveChanged_)}handleDownEvent(t){if(!t.originalEvent||!this.condition_(t))return!1;if(this.lastFeature_=this.featuresAtPixel_(t.pixel,t.map),!this.lastCoordinate_&&this.lastFeature_){this.startCoordinate_=t.coordinate,this.lastCoordinate_=t.coordinate,this.handleMoveEvent(t);const e=this.features_||new xt([this.lastFeature_]);return this.dispatchEvent(new yo(mo.TRANSLATESTART,e,t.coordinate,this.startCoordinate_,t)),!0}return!1}handleUpEvent(t){if(this.lastCoordinate_){this.lastCoordinate_=null,this.handleMoveEvent(t);const e=this.features_||new xt([this.lastFeature_]);return this.dispatchEvent(new yo(mo.TRANSLATEEND,e,t.coordinate,this.startCoordinate_,t)),this.startCoordinate_=null,!0}return!1}handleDragEvent(t){if(this.lastCoordinate_){const e=t.coordinate;t.map.getView().getProjection();const i=U(e),s=U(this.lastCoordinate_),r=i[0]-s[0],o=i[1]-s[1],a=this.features_||new xt([this.lastFeature_]);a.forEach(function(l){const h=l.getGeometry();h.translate(r,o),l.setGeometry(h)}),this.lastCoordinate_=e,this.dispatchEvent(new yo(mo.TRANSLATING,a,e,this.startCoordinate_,t))}}handleMoveEvent(t){const e=t.map.getViewport();this.featuresAtPixel_(t.pixel,t.map)?(e.classList.remove(this.lastCoordinate_?"ol-grab":"ol-grabbing"),e.classList.add(this.lastCoordinate_?"ol-grabbing":"ol-grab")):e.classList.remove("ol-grab","ol-grabbing")}featuresAtPixel_(t,e){return e.forEachFeatureAtPixel(t,(i,s)=>{if(!(!(i instanceof gt)||!this.filter_(i,s))&&!(this.features_&&!this.features_.getArray().includes(i)))return i},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_})}getHitTolerance(){return this.hitTolerance_}setHitTolerance(t){this.hitTolerance_=t}setMap(t){const e=this.getMap();super.setMap(t),this.updateState_(e)}handleActiveChanged_(){this.updateState_(null)}updateState_(t){let e=this.getMap();const i=this.getActive();(!e||!i)&&(e=e||t,e&&e.getViewport().classList.remove("ol-grab","ol-grabbing"))}}class zf{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;const s=this.points_[e+2]-this.points_[i+2];if(s<1e3/60)return!1;const r=this.points_[e]-this.points_[i],o=this.points_[e+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_}}function Wf(n){n=n||{};const t=new xt,e=new zf(-.005,.05,100);return(n.altShiftDragRotate!==void 0?n.altShiftDragRotate:!0)&&t.push(new yf),(n.doubleClickZoom!==void 0?n.doubleClickZoom:!0)&&t.push(new af({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan!==void 0?n.dragPan:!0)&&t.push(new mf({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate!==void 0?n.pinchRotate:!0)&&t.push(new Ff),(n.pinchZoom!==void 0?n.pinchZoom:!0)&&t.push(new bf({duration:n.zoomDuration})),(n.keyboard!==void 0?n.keyboard:!0)&&(t.push(new If),t.push(new vf({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom!==void 0?n.mouseWheelZoom:!0)&&t.push(new Af({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom!==void 0?n.shiftDragZoom:!0)&&t.push(new pf({duration:n.zoomDuration})),t}const wn={IDLE:0,LOADED:2,ERROR:3,EMPTY:4},po={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class jf extends Bn{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=e===void 0?1:e,this.down_=null;const i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=z(i,po.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=z(i,po.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(D.TOUCHMOVE,this.boundHandleTouchMove_,Ko?{passive:!1}:!1)}emulateClick_(t){let e=new pe(B.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new pe(B.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new pe(B.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==B.POINTERUP||e.type==B.POINTERCANCEL){delete this.trackedTouches_[i];for(const s in this.trackedTouches_)if(this.trackedTouches_[s].target!==e.target){delete this.trackedTouches_[s];break}}else(e.type==B.POINTERDOWN||e.type==B.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new pe(B.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach($),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return t.button===0}handlePointerDown_(t){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(t);const e=new pe(B.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(z(i,B.POINTERMOVE,this.handlePointerMove_,this),z(i,B.POINTERUP,this.handlePointerUp_,this),z(this.element_,B.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(z(this.element_.getRootNode(),B.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new pe(B.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!!(this.down_&&this.isMoving_(t));this.dispatchEvent(new pe(B.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;(!e||e.defaultPrevented)&&(typeof t.cancelable!="boolean"||t.cancelable===!0)&&t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&($(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(D.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&($(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach($),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Ct={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},Is=1/0;class Vf{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,li(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,i=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const s=this.keyFunction_(i);return delete this.queuedElements_[s],i}enqueue(t){it(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=Is?(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(t){return t*2+1}getRightChildIndex_(t){return t*2+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return this.elements_.length===0}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,i=this.priorities_,s=e.length,r=e[t],o=i[t],a=t;for(;t<s>>1;){const l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=h<s&&i[h]<i[l]?h:l;e[t]=e[c],i[t]=i[c],t=c}e[t]=r,i[t]=o,this.siftDown_(a,t)}siftDown_(t,e){const i=this.elements_,s=this.priorities_,r=i[e],o=s[e];for(;e>t;){const a=this.getParentIndex_(e);if(s[a]>o)i[e]=i[a],s[e]=s[a],e=a;else break}i[e]=r,s[e]=o}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let s=0;const r=e.length;let o,a,l;for(a=0;a<r;++a)o=e[a],l=t(o),l==Is?delete this.queuedElements_[this.keyFunction_(o)]:(i[s]=l,e[s++]=o);e.length=s,i.length=s,this.heapify_()}}class Xf extends Vf{constructor(t,e){super(i=>t.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);return e&&t[0].addEventListener(D.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===wn.LOADED||i===wn.ERROR||i===wn.EMPTY){i!==wn.ERROR&&e.removeEventListener(D.CHANGE,this.boundHandleTileChange_);const s=e.getKey();s in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[s],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){const s=this.dequeue()[0],r=s.getKey();s.getState()===wn.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,s.load())}}}function Bf(n,t,e,i,s){if(!n||!(e in n.wantedTiles)||!n.wantedTiles[e][t.getKey()])return Is;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 xo extends Yt{constructor(t){super();const e=t.element;e&&!t.target&&!e.style.pointerEvents&&(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){var t;(t=this.element)==null||t.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){var e;this.map_&&((e=this.element)==null||e.remove());for(let i=0,s=this.listenerKeys.length;i<s;++i)$(this.listenerKeys[i]);if(this.listenerKeys.length=0,this.map_=t,t){const i=this.target_??t.getOverlayContainerStopEvent();this.element&&i.appendChild(this.element),this.render!==Zi&&this.listenerKeys.push(z(t,xe.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}}class Yf extends xo{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=t.collapsed!==void 0?t.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=t.collapsible!==void 0,this.collapsible_=t.collapsible!==void 0?t.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;const e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",s=t.expandClassName!==void 0?t.expandClassName:e+"-expand",r=t.collapseLabel!==void 0?t.collapseLabel:"›",o=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=s):this.label_=a;const l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(D.CLICK,this.handleClick_.bind(this),!1);const h=e+" "+Zn+" "+pr+(this.collapsed_&&this.collapsible_?" "+Ia:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){const e=this.getMap().getAllLayers(),i=new Set(e.flatMap(s=>s.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(s=>i.add(s)):i.add(this.attributions_)),!this.overrideCollapsible_){const s=!e.some(r=>{var o;return((o=r.getSource())==null?void 0:o.getAttributionsCollapsible())===!1});this.setCollapsible(s)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const e=await Promise.all(this.collectSourceAttributions_(t).map(s=>ya(()=>s))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!oe(e,this.renderedAttributions_)){Ho(this.ulElement_);for(let s=0,r=e.length;s<r;++s){const o=document.createElement("li");o.innerHTML=e[s],this.ulElement_.appendChild(o)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(Ia),this.collapsed_?Uo(this.collapseLabel_,this.label_):Uo(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,!(!this.collapsible_||this.collapsed_===t)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}}class Zf extends xo{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});const e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"⇧",s=t.compassClassName!==void 0?t.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=s,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(s));const r=t.tipLabel?t.tipLabel:"Reset rotation",o=document.createElement("button");o.className=e+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(D.CLICK,this.handleClick_.bind(this),!1);const a=e+" "+Zn+" "+pr,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(Yn)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const e=this.getMap().getView();if(!e)return;const i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:Si}):e.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const s="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(Yn);!r&&i===0?this.element.classList.add(Yn):r&&i!==0&&this.element.classList.remove(Yn)}this.label_.style.transform=s}this.rotation_=i}}class Kf extends xo{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,s=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",r=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",o=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"–",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",h=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=s,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(D.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(D.CLICK,this.handleClick_.bind(this,-i),!1);const d=e+" "+Zn+" "+pr,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const i=this.getMap().getView();if(!i)return;const s=i.getZoom();if(s!==void 0){const r=i.getConstrainedZoom(s+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:Si})):i.setZoom(r)}}}function Uf(n){n=n||{};const t=new xt;return(n.zoom!==void 0?n.zoom:!0)&&t.push(new Kf(n.zoomOptions)),(n.rotate!==void 0?n.rotate:!0)&&t.push(new Zf(n.rotateOptions)),(n.attribution!==void 0?n.attribution:!0)&&t.push(new Yf(n.attributionOptions)),t}class ke extends Mt{constructor(t,e){super(t),this.layer=e}}const Eo={LAYERS:"layers"};class Di extends Al{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Eo.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new xt(i.slice(),{unique:!0}):it(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new xt(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach($),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(z(t,nt.ADD,this.handleLayersAdd_,this),z(t,nt.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach($);li(this.listenerKeys_);const e=t.getArray();for(let i=0,s=e.length;i<s;i++){const r=e[i];this.registerLayerListeners_(r),this.dispatchEvent(new ke("addlayer",r))}this.changed()}registerLayerListeners_(t){const e=[z(t,di.PROPERTYCHANGE,this.handleLayerChange_,this),z(t,D.CHANGE,this.handleLayerChange_,this)];t instanceof Di&&e.push(z(t,"addlayer",this.handleLayerGroupAdd_,this),z(t,"removelayer",this.handleLayerGroupRemove_,this)),this.listenerKeys_[X(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new ke("addlayer",t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new ke("removelayer",t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new ke("addlayer",e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=X(e);this.listenerKeys_[i].forEach($),delete this.listenerKeys_[i],this.dispatchEvent(new ke("removelayer",e)),this.changed()}getLayers(){return this.get(Eo.LAYERS)}setLayers(t){const e=this.getLayers();if(e){const i=e.getArray();for(let s=0,r=i.length;s<r;++s)this.dispatchEvent(new ke("removelayer",i[s]))}this.set(Eo.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){const e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(e)});const s=this.getLayerState();let r=s.zIndex;!t&&s.zIndex===void 0&&(r=0);for(let o=i,a=e.length;o<a;o++){const l=e[o];l.opacity*=s.opacity,l.visible=l.visible&&s.visible,l.maxResolution=Math.min(l.maxResolution,s.maxResolution),l.minResolution=Math.max(l.minResolution,s.minResolution),l.minZoom=Math.max(l.minZoom,s.minZoom),l.maxZoom=Math.min(l.maxZoom,s.maxZoom),s.extent!==void 0&&(l.extent!==void 0?l.extent=Gs(l.extent,s.extent):l.extent=s.extent),l.zIndex===void 0&&(l.zIndex=r)}return e}getSourceState(){return"ready"}}class Hf extends fr{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){O()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,s=t.pixelToCoordinateTransform;de(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Da(s,i)}forEachFeatureAtCoordinate(t,e,i,s,r,o,a,l){let h;const c=e.viewState;function u(x,C,S,T){return r.call(o,C,x?S:null,T)}const d=c.projection,f=Bo(t.slice(),d),g=[[0,0]];if(d.canWrapX()&&s){const x=d.getExtent(),C=K(x);g.push([-C,0],[C,0])}const m=e.layerStatesArray,_=m.length,y=[],p=[];for(let x=0;x<g.length;x++)for(let C=_-1;C>=0;--C){const S=m[C],T=S.layer;if(T.hasRenderer()&&qr(S,c)&&a.call(l,T)){const I=T.getRenderer(),v=T.getSource();if(I&&v){const M=v.getWrapX()?f:t,k=u.bind(null,S.managed);p[0]=M[0]+g[x][0],p[1]=M[1]+g[x][1],h=I.forEachFeatureAtCoordinate(p,e,i,k,y)}if(h)return h}}if(y.length===0)return;const E=1/y.length;return y.forEach((x,C)=>x.distanceSq+=C*E),y.sort((x,C)=>x.distanceSq-C.distanceSq),y.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(t,e,i,s,r,o){return this.forEachFeatureAtCoordinate(t,e,i,s,Bt,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){O()}scheduleExpireIconCache(t){zt.canExpireCache()&&t.postRenderFunctions.push(qf)}}function qf(n,t){zt.expire()}class $f extends Hf{constructor(t){super(t),this.fontChangeListenerKey_=z(_i,di.PROPERTYCHANGE,t.redrawText,t),this.element_=document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=Zn+" ol-layers";const i=t.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const s=new $a(t,void 0,e);i.dispatchEvent(s)}}disposeInternal(){$(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(Gt.PRECOMPOSE,t);const e=t.layerStatesArray.sort((a,l)=>a.zIndex-l.zIndex);e.some(a=>a.layer instanceof bl&&a.layer.getDeclutter())&&(t.declutter={});const s=t.viewState;this.children_.length=0;const r=[];let o=null;for(let a=0,l=e.length;a<l;++a){const h=e[a];t.layerIndex=a;const c=h.layer,u=c.getSourceState();if(!qr(h,s)||u!="ready"&&u!="undefined"){c.unrender();continue}const d=c.render(t,o);d&&(d!==o&&(this.children_.push(d),o=d),r.push(h))}this.declutter(t,r),Kh(this.element_,this.children_),this.dispatchRenderEvent(Gt.POSTCOMPOSE,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let i=e.length-1;i>=0;--i){const s=e[i],r=s.layer;r.getDeclutter()&&r.renderDeclutter(t,s)}e.forEach(i=>i.layer.renderDeferred(t))}}}function Jl(n){if(n instanceof ds){n.setMapInternal(null);return}n instanceof Di&&n.getLayers().forEach(Jl)}function Ql(n,t){if(n instanceof ds){n.setMapInternal(t);return}if(n instanceof Di){const e=n.getLayers().getArray();for(let i=0,s=e.length;i<s;++i)Ql(e[i],t)}}class Jf extends Yt{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=Qf(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=t.maxTilesLoading!==void 0?t.maxTilesLoading:16,this.pixelRatio_=t.pixelRatio!==void 0?t.pixelRatio:Bh,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Zt(),this.pixelToCoordinateTransform_=Zt(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,this.resizeObserver_=new ResizeObserver(()=>this.updateSize()),this.controls=e.controls||Uf(),this.interactions=e.interactions||Wf({onFocusOnly:!0}),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Xf(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Ct.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Ct.VIEW,this.handleViewChanged_),this.addChangeListener(Ct.SIZE,this.handleSizeChanged_),this.addChangeListener(Ct.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof ee)&&t.view.then(function(s){i.setView(new ee(s))}),this.controls.addEventListener(nt.ADD,s=>{s.element.setMap(this)}),this.controls.addEventListener(nt.REMOVE,s=>{s.element.setMap(null)}),this.interactions.addEventListener(nt.ADD,s=>{s.element.setMap(this)}),this.interactions.addEventListener(nt.REMOVE,s=>{s.element.setMap(null)}),this.overlays_.addEventListener(nt.ADD,s=>{this.addOverlayInternal_(s.element)}),this.overlays_.addEventListener(nt.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(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){Ql(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();e!==void 0&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;const s=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:Bt,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(s,this.frameState_,r,a,e,null,o,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,function(s){i.push(s)},e),i}getAllLayers(){const t=[];function e(i){i.forEach(function(s){s instanceof Di?e(s.getLayers()):t.push(s)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};const s=e.layerFilter!==void 0?e.layerFilter:Bt,r=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,s,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const i=this.viewport_.getBoundingClientRect(),s=this.getSize(),r=i.width/s[0],o=i.height/s[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(Ct.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Re(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?mt(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Ct.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof xt){e.setLayers(t);return}const i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const s=t[e];if(!s.visible)continue;const r=s.layer.getRenderer();if(r&&!r.ready)return!0;const o=s.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(t){const e=U(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?mt(e.coordinateToPixelTransform,t.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(Ct.SIZE)}getView(){return this.get(Ct.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,s){return Bf(this.frameState_,t,e,i,s)}handleBrowserEvent(t,e){e=e||t.type;const i=new pe(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===po.POINTERDOWN||i===D.WHEEL||i===D.KEYDOWN){const s=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():s,o=e.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===s?s.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){const s=this.getInteractions().getArray().slice();for(let r=s.length-1;r>=0;r--){const o=s[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let s=this.maxTilesLoading_,r=s;if(t){const o=t.viewHints;if(o[et.ANIMATING]||o[et.INTERACTING]){const a=Date.now()-t.time>8;s=a?0:8,r=a?0:2}}e.getTilesLoading()<s&&(e.reprioritize(),e.loadMoreTiles(s,r))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Gt.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Gt.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new Mi(xe.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new Mi(xe.LOADSTART,this,t))));const i=this.postRenderFunctions_;if(t)for(let s=0,r=i.length;s<r;++s)i[s](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,s=this.targetChangeHandlerKeys_.length;i<s;++i)$(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(D.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(D.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_){this.resizeObserver_.unobserve(this.targetElement_);const i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}const t=this.getTarget(),e=typeof t=="string"?document.getElementById(t):t;if(this.targetElement_=e,!e)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new $f(this)),this.mapBrowserEventHandler_=new jf(this,this.moveTolerance_);for(const r in B)this.mapBrowserEventHandler_.addEventListener(B[r],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(D.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(D.WHEEL,this.boundHandleBrowserEvent_,Ko?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{const r=e.getRootNode();i=r instanceof ShadowRoot?r.host:e}this.targetChangeHandlerKeys_=[z(i,D.KEYDOWN,this.handleBrowserEvent,this),z(i,D.KEYPRESS,this.handleBrowserEvent,this)];const s=e.getRootNode();s instanceof ShadowRoot&&this.resizeObserver_.observe(s.host),this.resizeObserver_.observe(e)}this.updateSize()}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&($(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&($(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=z(t,di.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=z(t,D.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach($),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new ke("addlayer",t)),this.layerGroupPropertyListenerKeys_=[z(t,di.PROPERTYCHANGE,this.render,this),z(t,D.CHANGE,this.render,this),z(t,"addlayer",this.handleLayerAdd_,this),z(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;const t=this.frameState_.layerStatesArray;for(let e=0,i=t.length;e<i;++e){const s=t[e].layer;s.hasRenderer()&&s.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){Jl(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){const e=this.getSize(),i=this.getView(),s=this.frameState_;let r=null;if(e!==void 0&&Wa(e)&&i&&i.isDef()){const o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:Ln(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:X(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=Ln(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),s&&(!this.previousExtent_||!si(this.previousExtent_)&&!zi(r.extent,this.previousExtent_))&&(this.dispatchEvent(new Mi(xe.MOVESTART,this,s)),this.previousExtent_=Ni(this.previousExtent_)),this.previousExtent_&&!r.viewHints[et.ANIMATING]&&!r.viewHints[et.INTERACTING]&&!zi(r.extent,this.previousExtent_)&&(this.dispatchEvent(new Mi(xe.MOVEEND,this,r)),Go(r.extent,this.previousExtent_))),this.dispatchEvent(new Mi(xe.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(xe.LOADSTART)||this.hasListener(xe.LOADEND)||this.hasListener(Gt.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new ke("removelayer",e)),this.set(Ct.LAYERGROUP,t)}setSize(t){this.set(Ct.SIZE,t)}setTarget(t){this.set(Ct.TARGET,t)}setView(t){if(!t||t instanceof ee){this.set(Ct.VIEW,t);return}this.set(Ct.VIEW,new ee);const e=this;t.then(function(i){e.setView(new ee(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){const s=getComputedStyle(t),r=t.offsetWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight)-parseFloat(s.borderRightWidth),o=t.offsetHeight-parseFloat(s.borderTopWidth)-parseFloat(s.paddingTop)-parseFloat(s.paddingBottom)-parseFloat(s.borderBottomWidth);!isNaN(r)&&!isNaN(o)&&(e=[Math.max(0,r),Math.max(0,o)],!Wa(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&qo("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!oe(e,i))&&(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}}function Qf(n){let t=null;n.keyboardEventTarget!==void 0&&(t=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);const e={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new Di({layers:n.layers});e[Ct.LAYERGROUP]=i,e[Ct.TARGET]=n.target,e[Ct.VIEW]=n.view instanceof ee?n.view:new ee;let s;n.controls!==void 0&&(Array.isArray(n.controls)?s=new xt(n.controls.slice()):(it(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 xt(n.interactions.slice()):(it(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 xt(n.overlays.slice()):(it(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new xt,{controls:s,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}const wt={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class tg extends Yt{constructor(t){super(),this.on,this.once,this.un,this.options=t,this.id=t.id,this.insertFirst=t.insertFirst!==void 0?t.insertFirst:!0,this.stopEvent=t.stopEvent!==void 0?t.stopEvent:!0,this.element=document.createElement("div"),this.element.className=t.className!==void 0?t.className:"ol-overlay-container "+Gc,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=t.autoPan===!0?{}:t.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(wt.ELEMENT,this.handleElementChanged),this.addChangeListener(wt.MAP,this.handleMapChanged),this.addChangeListener(wt.OFFSET,this.handleOffsetChanged),this.addChangeListener(wt.POSITION,this.handlePositionChanged),this.addChangeListener(wt.POSITIONING,this.handlePositioningChanged),t.element!==void 0&&this.setElement(t.element),this.setOffset(t.offset!==void 0?t.offset:[0,0]),this.setPositioning(t.positioning||"top-left"),t.position!==void 0&&this.setPosition(t.position)}getElement(){return this.get(wt.ELEMENT)}getId(){return this.id}getMap(){return this.get(wt.MAP)||null}getOffset(){return this.get(wt.OFFSET)}getPosition(){return this.get(wt.POSITION)}getPositioning(){return this.get(wt.POSITIONING)}handleElementChanged(){Ho(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){var e;this.mapPostrenderListenerKey&&((e=this.element)==null||e.remove(),$(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=z(t,xe.POSTRENDER,this.render,this),this.updatePixelPosition();const i=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?i.insertBefore(this.element,i.childNodes[0]||null):i.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(t){this.set(wt.ELEMENT,t)}setMap(t){this.set(wt.MAP,t)}setOffset(t){this.set(wt.OFFSET,t)}setPosition(t){this.set(wt.POSITION,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(wt.POSITION))return;const i=this.getRect(e.getTargetElement(),e.getSize()),s=this.getElement(),r=this.getRect(s,[Yh(s),Zh(s)]);t=t||{};const o=t.margin===void 0?20:t.margin;if(!ae(i,r)){const a=r[0]-i[0],l=i[2]-r[2],h=r[1]-i[1],c=i[3]-r[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),h<0?u[1]=h-o:c<0&&(u[1]=Math.abs(c)+o),u[0]!==0||u[1]!==0){const d=e.getView().getCenterInternal(),f=e.getPixelFromCoordinateInternal(d);if(!f)return;const g=[f[0]+u[0],f[1]+u[1]],m=t.animation||{};e.getView().animateInternal({center:e.getCoordinateFromPixelInternal(g),duration:m.duration,easing:m.easing})}}}getRect(t,e){const i=t.getBoundingClientRect(),s=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[s,r,s+e[0],r+e[1]]}setPositioning(t){this.set(wt.POSITIONING,t)}setVisible(t){this.rendered.visible!==t&&(this.element.style.display=t?"":"none",this.rendered.visible=t)}updatePixelPosition(){const t=this.getMap(),e=this.getPosition();if(!t||!t.isRendered()||!e){this.setVisible(!1);return}const i=t.getPixelFromCoordinate(e),s=t.getSize();this.updateRenderedPosition(i,s)}updateRenderedPosition(t,e){const i=this.element.style,s=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=`${t[0]+s[0]}px`,a=`${t[1]+s[1]}px`;let l="0%",h="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"?h="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(h="-50%");const c=`translate(${l}, ${h}) translate(${o}, ${a})`;this.rendered.transform_!=c&&(this.rendered.transform_=c,i.transform=c)}getOptions(){return this.options}}class eg{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=gt,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let i=e.dataProjection?ot(e.dataProjection):this.readProjection(t);e.extent&&i&&i.getUnits()==="tile-pixels"&&(i=ot(i),i.setWorldExtent(e.extent)),e={dataProjection:i,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return O()}readFeature(t,e){return O()}readFeatures(t,e){return O()}readGeometry(t,e){return O()}readProjection(t){return O()}writeFeature(t,e){return O()}writeFeatures(t,e){return O()}writeGeometry(t,e){return O()}}function Co(n,t,e){const i=e?ot(e.featureProjection):null,s=e?ot(e.dataProjection):null;let r=n;if(i&&s&&!er(i,s)){t&&(r=n.clone());const o=t?i:s,a=t?s:i;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(Xi(o,a))}if(t&&e&&e.decimals!==void 0){const o=Math.pow(10,e.decimals),a=function(l){for(let h=0,c=l.length;h<c;++h)l[h]=Math.round(l[h]*o)/o;return l};r===n&&(r=n.clone()),r.applyTransform(a)}return r}const ig={Point:Rt,LineString:ie,Polygon:qt,MultiPoint:yn,MultiLineString:vi,MultiPolygon:Ri};function ng(n,t,e){return Array.isArray(t[0])?(Tl(n,0,t,e)||(n=n.slice(),Br(n,0,t,e)),n):(Xr(n,0,t,e)||(n=n.slice(),cs(n,0,t,e)),n)}function th(n,t){var r;const e=n.geometry;if(!e)return[];if(Array.isArray(e))return e.map(o=>th({...n,geometry:o})).flat();const i=e.type==="MultiPolygon"?"Polygon":e.type;if(i==="GeometryCollection"||i==="Circle")throw new Error("Unsupported geometry type: "+i);const s=e.layout.length;return Co(new Dt(i,i==="Polygon"?ng(e.flatCoordinates,e.ends,s):e.flatCoordinates,(r=e.ends)==null?void 0:r.flat(),s,n.properties||{},n.id).enableSimplifyTransformed(),!1,t)}function wo(n,t){if(!n)return null;if(Array.isArray(n)){const i=n.map(s=>wo(s,t));return new mn(i)}const e=ig[n.type];return Co(new e(n.flatCoordinates,n.layout||"XY",n.ends),!1,t)}class sg extends eg{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(vs(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(vs(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return O()}readFeaturesFromObject(t,e){return O()}readGeometry(t,e){return this.readGeometryFromObject(vs(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return O()}readProjection(t){return this.readProjectionFromObject(vs(t))}readProjectionFromObject(t){return O()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return O()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return O()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return O()}}function vs(n){if(typeof n=="string"){const t=JSON.parse(n);return t||null}return n!==null?n:null}class eh extends sg{constructor(t){t=t||{},super(),this.dataProjection=ot(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=ot(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let i=null;t.type==="Feature"?i=t:i={type:"Feature",geometry:t,properties:null};const s=So(i.geometry);if(this.featureClass===Dt)return th({geometry:s,id:i.id,properties:i.properties},e);const r=new gt;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&r.setGeometryName(i.geometry_name),r.setGeometry(wo(s,e)),"id"in i&&r.setId(i.id),i.properties&&r.setProperties(i.properties,!0),r}readFeaturesFromObject(t,e){const i=t;let s=null;if(i.type==="FeatureCollection"){const r=t;s=[];const o=r.features;for(let a=0,l=o.length;a<l;++a){const h=this.readFeatureFromObject(o[a],e);h&&s.push(h)}}else s=[this.readFeatureFromObject(t,e)];return s.flat()}readGeometryFromObject(t,e){return rg(t,e)}readProjectionFromObject(t){const e=t.crs;let i;if(e)if(e.type=="name")i=ot(e.properties.name);else if(e.type==="EPSG")i=ot("EPSG:"+e.properties.code);else throw new Error("Unknown SRS type");else i=this.dataProjection;return i}writeFeatureObject(t,e){e=this.adaptOptions(e);const i={type:"Feature",geometry:null,properties:null},s=t.getId();if(s!==void 0&&(i.id=s),!t.hasProperties())return i;const r=t.getProperties(),o=t.getGeometry();return o&&(i.geometry=Io(o,e),delete r[t.getGeometryName()]),Xe(r)||(i.properties=r),i}writeFeaturesObject(t,e){e=this.adaptOptions(e);const i=[];for(let s=0,r=t.length;s<r;++s)i.push(this.writeFeatureObject(t[s],e));return{type:"FeatureCollection",features:i}}writeGeometryObject(t,e){return Io(t,this.adaptOptions(e))}}function So(n,t){if(!n)return null;let e;switch(n.type){case"Point":{e=ag(n);break}case"LineString":{e=lg(n);break}case"Polygon":{e=dg(n);break}case"MultiPoint":{e=cg(n);break}case"MultiLineString":{e=hg(n);break}case"MultiPolygon":{e=ug(n);break}case"GeometryCollection":{e=og(n);break}default:throw new Error("Unsupported GeoJSON type: "+n.type)}return e}function rg(n,t){const e=So(n);return wo(e,t)}function og(n,t){return n.geometries.map(function(i){return So(i)})}function ag(n){const t=n.coordinates;return{type:"Point",flatCoordinates:t,layout:$e(t.length)}}function lg(n){var i;const t=n.coordinates,e=t.flat();return{type:"LineString",flatCoordinates:e,ends:[e.length],layout:$e(((i=t[0])==null?void 0:i.length)||2)}}function hg(n){var r,o;const t=n.coordinates,e=((o=(r=t[0])==null?void 0:r[0])==null?void 0:o.length)||2,i=[],s=gn(i,0,t,e);return{type:"MultiLineString",flatCoordinates:i,ends:s,layout:$e(e)}}function cg(n){var e;const t=n.coordinates;return{type:"MultiPoint",flatCoordinates:t.flat(),layout:$e(((e=t[0])==null?void 0:e.length)||2)}}function ug(n){var r,o;const t=n.coordinates,e=[],i=((o=(r=t[0])==null?void 0:r[0])==null?void 0:o[0].length)||2,s=wl(e,0,t,i);return{type:"MultiPolygon",flatCoordinates:e,ends:s,layout:$e(i)}}function dg(n){var r,o;const t=n.coordinates,e=[],i=(o=(r=t[0])==null?void 0:r[0])==null?void 0:o.length,s=gn(e,0,t,i);return{type:"Polygon",flatCoordinates:e,ends:s,layout:$e(i)}}function Io(n,t){n=Co(n,!0,t);const e=n.getType();let i;switch(e){case"Point":{i=pg(n);break}case"LineString":{i=gg(n);break}case"Polygon":{i=xg(n,t);break}case"MultiPoint":{i=mg(n);break}case"MultiLineString":{i=_g(n);break}case"MultiPolygon":{i=yg(n,t);break}case"GeometryCollection":{i=fg(n,t);break}case"Circle":{i={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+e)}return i}function fg(n,t){return t=Object.assign({},t),delete t.featureProjection,{type:"GeometryCollection",geometries:n.getGeometriesArray().map(function(i){return Io(i,t)})}}function gg(n,t){return{type:"LineString",coordinates:n.getCoordinates()}}function _g(n,t){return{type:"MultiLineString",coordinates:n.getCoordinates()}}function mg(n,t){return{type:"MultiPoint",coordinates:n.getCoordinates()}}function yg(n,t){let e;return t&&(e=t.rightHanded),{type:"MultiPolygon",coordinates:n.getCoordinates(e)}}function pg(n,t){return{type:"Point",coordinates:n.getCoordinates()}}function xg(n,t){let e;return t&&(e=t.rightHanded),{type:"Polygon",coordinates:n.getCoordinates(e)}}function Rs(n,t){t.feature.set("__type","zone");const e=n.getView().getProjection(),{geometry:i}=new eh().writeFeatureObject(t.feature,{featureProjection:e,dataProjection:e});return i}function Eg(n){return{type:"Feature",id:n.id,geometry:n.geometry,properties:{id:n.id,name:n.name,color:n.color,__type:"zone"}}}function Cg(n){return{type:"FeatureCollection",features:n.filter(t=>t.geometry).map(Eg)}}function ih(n,t){const e=n.getView().getProjection();return new eh().readFeatures(Cg(t),{featureProjection:e,dataProjection:e})}function wg({colors:n,angles:t=[45,-45],gap:e=32,lineWidth:i=32,background:s=null,lineCap:r="butt",dash:o}){return(!n||n.length===0)&&(n=["#000"]),new at({renderer(a,l){a=a;const h=l.context,c=l.geometry.clone();c.setCoordinates(a),h.save(),h.beginPath(),a[0].forEach(([p,E],x)=>{x===0?h.moveTo(p,E):h.lineTo(p,E)}),h.closePath(),h.clip("nonzero"),s&&(h.fillStyle=s,h.fill("nonzero"));const[u,d,f,g]=c.getExtent(),m=f-u,_=g-d;if(m<=0||_<=0){h.restore();return}const y=Math.hypot(m,_);h.lineWidth=i,h.lineCap=r,o&&o.length&&h.setLineDash(o),t.forEach(p=>{if(p>0)return;h.save();const E=u+m/2,x=d+_/2;h.translate(E,x),h.rotate(p*Math.PI/180),h.translate(-E,-x);const C=d-y,S=g+y;let T=0;for(let I=C;I<=S;I+=e,T++)h.strokeStyle=n[T%n.length],h.beginPath(),h.moveTo(u-y,I),h.lineTo(f+y,I),h.stroke();h.restore()}),o&&o.length&&h.setLineDash([]),h.restore()}})}const nh={name:"ppe-zoning",getInitialState:n=>{const{layer:t,source:e}=kg(n==null?void 0:n._extent),{layer:i,source:s}=Ng(n==null?void 0:n._extent),r=new co({layers:[t],condition:uf,style:l=>{const h=l.getProperties();return Gg(h)}}),o=new Rf({source:e,features:r.getFeatures()}),a=new Gf({layers:[t],condition:df,features:r.getFeatures()});return{zones:[],_zoneLayer:t,_zoneSource:e,_zoneLabelLayer:i,_zoneLabelSource:s,_zoneModify:o,_zoneSelect:r,_zoneTranslate:a,_editMode:"editing",_selectedZoneId:null,_currentAction:"none",_currentDrawingZone:null,...n}},createPlanEditor:n=>{var r;const t=n.initialState,{_zoneLayer:e,_zoneLabelLayer:i}=t;e&&n.addLayer(e),i&&n.addLayer(i),Sg(n),Og(n),Ig(n);const s=((r=n.options.zoningConfig)==null?void 0:r.editMode)||"editing";t._editMode=s,sh(n,s),n.drawZone=o=>rh(n,o),n.deleteZone=o=>oh(n,o),n.updateZone=o=>Lg(n,o),n.setZoningMode=o=>bg(n,o),n.setEditMode=o=>vg(n,o),n.selectZone=o=>Rg(n,o),n.deselectZone=()=>vo(n),n.getSelectedZone=()=>Tg(n),n.startDrawingZone=o=>Mg(n,o),n.cancelCurrentAction=()=>Ts(n),n.deleteSelectedZone=()=>ah(n),n.updateZoneOccupationColors=()=>Dg(n)}};function Sg(n){const{zones:t}=n.getState();n.initialState._zoneSource.addFeatures(ih(n,t))}function Ig(n){document.addEventListener("keydown",t=>{const e=n.initialState;t.key==="Escape"&&(t.preventDefault(),Ts(n)),(t.key==="Delete"||t.key==="Backspace")&&e._editMode==="editing"&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement||(t.preventDefault(),ah(n)))})}function vg(n,t){const e=n.initialState;e._editMode!==t&&(e._editMode=t,sh(n,t))}function sh(n,t){const e=n.initialState;Ts(n),t==="readonly"?(e._zoneSelect&&n.removeInteraction(e._zoneSelect),e._zoneModify&&n.removeInteraction(e._zoneModify),e._zoneTranslate&&n.removeInteraction(e._zoneTranslate)):t==="editing"&&(e._zoneSelect&&(n.addInteraction(e._zoneSelect),Pg(n)),e._zoneModify&&(n.addInteraction(e._zoneModify),Ag(n)),e._zoneTranslate&&(n.addInteraction(e._zoneTranslate),Fg(n)))}function Rg(n,t){var o,a,l;const e=n.initialState,{zones:i}=n.getState(),s=i.find(h=>h.id===t);if(!s||!s.geometry)return;const r=(o=e._zoneSource)==null?void 0:o.getFeatureById(t);r&&(e._selectedZoneId=t,e._zoneSelect&&(e._zoneSelect.getFeatures().clear(),e._zoneSelect.getFeatures().push(r)),(l=(a=n.options).onZoneSelected)==null||l.call(a,s))}function vo(n){var e,i;const t=n.initialState;t._selectedZoneId=null,t._zoneSelect&&t._zoneSelect.getFeatures().clear(),(i=(e=n.options).onZoneSelected)==null||i.call(e,null)}function Tg(n){const t=n.initialState,{zones:e}=n.getState();return t._selectedZoneId&&e.find(i=>i.id===t._selectedZoneId)||null}function Pg(n){var e,i;const t=n.initialState;t._selectListener&&((e=t._zoneSelect)==null||e.un("select",t._selectListener)),t._selectListener=(i=t._zoneSelect)==null?void 0:i.on("select",s=>{var a,l,h,c;const r=s.selected,o=s.deselected;if(r.length>0){const d=r[0].getId();t._selectedZoneId=d;const{zones:f}=n.getState(),g=f.find(m=>m.id===d);g&&((l=(a=n.options).onZoneSelected)==null||l.call(a,g))}else o.length>0&&(t._selectedZoneId=null,(c=(h=n.options).onZoneSelected)==null||c.call(h,null))})}function Mg(n,t){rh(n,t)}function rh(n,t){const e=n.initialState;Ts(n),e._zoneSelect&&n.removeInteraction(e._zoneSelect),e._zoneModify&&n.removeInteraction(e._zoneModify),e._zoneTranslate&&n.removeInteraction(e._zoneTranslate),e._zoneDraw=new Cf({source:e._zoneSource,type:"Polygon",geometryName:"zone"}),e._zoneSnap=new Nf({source:e._zoneSource}),n.addInteraction(e._zoneDraw),n.addInteraction(e._zoneSnap),e._currentAction="drawing",e._currentDrawingZone=t,e._zoneDraw.on("drawend",i=>{var r,o;i.feature.setId(t.id),i.feature.setProperties({id:t.id,name:t.name,color:t.color,__type:"zone"});const s=Rs(n,i);(o=(r=n.options).onZoneDrawn)==null||o.call(r,{...t,geometry:s}),e._zoneDraw&&n.removeInteraction(e._zoneDraw),e._zoneSnap&&n.removeInteraction(e._zoneSnap),e._zoneDraw=void 0,e._zoneSnap=void 0,e._currentAction="none",e._currentDrawingZone=null,e._editMode==="editing"&&(e._zoneSelect&&n.addInteraction(e._zoneSelect),e._zoneModify&&n.addInteraction(e._zoneModify),e._zoneTranslate&&n.addInteraction(e._zoneTranslate))})}function Lg(n,t){var s,r;const e=n.initialState,i=(s=e._zoneSource)==null?void 0:s.getFeatureById(t.id);if(i){const{geometry:o,...a}=t;i.setProperties(a),(r=e._zoneLayer)==null||r.changed()}}function Ag(n){var e,i,s;const t=n.initialState;t._modifyListener&&((e=t._zoneModify)==null||e.un("modifystart",t._modifyListener)),t._modifyListener=(i=t._zoneModify)==null?void 0:i.on("modifystart",r=>{var a,l;t._currentAction="modifying";const o=r.features.getArray()[0];if(o){const{zones:h}=n.getState(),c=h.find(u=>u.id===o.getId());c&&((l=(a=n.options).onZoneModifyStart)==null||l.call(a,c))}}),(s=t._zoneModify)==null||s.on("modifyend",r=>{var a,l,h,c;t._currentAction="none";const o=r.features.getArray()[0];if(o){const{zones:u}=n.getState(),d=u.find(f=>f.id===o.getId());if(d){const f=Rs(n,{feature:o});(l=(a=n.options).onZoneUpdated)==null||l.call(a,{...d,geometry:f}),(c=(h=n.options).onZoneModifyEnd)==null||c.call(h,d)}}})}function Fg(n){var e,i,s;const t=n.initialState;t._translateListener&&((e=t._zoneTranslate)==null||e.un("translatestart",t._translateListener)),t._translateListener=(i=t._zoneTranslate)==null?void 0:i.on("translatestart",r=>{t._currentAction="translating"}),(s=t._zoneTranslate)==null||s.on("translateend",r=>{var a,l,h,c;t._currentAction="none";const o=r.features.getArray();if(o.length>0){const u=o[0],{zones:d}=n.getState(),f=d.find(g=>g.id===u.getId());if(f){const g=Rs(n,{feature:u});(l=(a=n.options).onZoneUpdated)==null||l.call(a,{...f,geometry:g}),(c=(h=n.options).onZoneModifyEnd)==null||c.call(h,{...f,geometry:g})}}})}function oh(n,t){var i,s,r,o;const e=(i=n.initialState._zoneSource)==null?void 0:i.getFeatureById(t);e&&((s=n.initialState._zoneSource)==null||s.removeFeature(e)),n.initialState._selectedZoneId===t&&vo(n),(o=(r=n.options).onZoneDeleted)==null||o.call(r,t)}function ah(n){const t=n.initialState;t._selectedZoneId&&oh(n,t._selectedZoneId)}function Ts(n){const t=n.initialState;t._currentAction==="drawing"&&(t._zoneDraw&&(n.removeInteraction(t._zoneDraw),t._zoneDraw=void 0),t._zoneSnap&&(n.removeInteraction(t._zoneSnap),t._zoneSnap=void 0),t._currentAction="none",t._currentDrawingZone=null,t._editMode==="editing"&&(t._zoneSelect&&n.addInteraction(t._zoneSelect),t._zoneModify&&n.addInteraction(t._zoneModify),t._zoneTranslate&&n.addInteraction(t._zoneTranslate))),t._selectedZoneId&&vo(n)}function bg(n,t){const{_zoneLayer:e,_zoneLabelSource:i}=n.initialState;t==="occupation"?(e.setStyle(s=>{var l,h;const r=s.getProperties(),o=((h=(l=n.options).getZoneOccupationColors)==null?void 0:h.call(l,r))??[];if(o.length===0)return[new at({stroke:new Qt({color:r.color,width:2,lineDash:[5,5]}),fill:new yt({color:"rgba(0,0,0,0)"})})];const a=o.length?o:[r.color];return[...Ro(s.getProperties()),wg({colors:a})]}),lh(n)):(e.setStyle(s=>Ro(s.getProperties())),i.clear())}function Dg(n){const{_zoneLayer:t}=n.initialState;t.changed(),lh(n)}function lh(n){const{_zoneLabelSource:t,_zoneSource:e}=n.initialState;t.clear(),e.getFeatures().forEach(s=>{const r=s.getProperties(),o=s.getGeometry();if(!o)return;const a=Xt(o.getExtent());if(n.options.renderZoneLabels){const l=n.options.renderZoneLabels(r,a);if(l.title){const h=new gt({geometry:new Rt(a),__type:"zone-label"});h.setStyle(new at({text:new qe({text:l.title.text,font:l.title.font||"bold 14px Arial",fill:new yt({color:l.title.textColor||"#000"}),backgroundFill:l.title.backgroundColor?new yt({color:l.title.backgroundColor}):void 0,padding:l.title.padding||[2,4,2,4],offsetY:l.title.offsetY||0,textAlign:l.title.textAlign||"center"})})),t.addFeature(h)}l.items&&l.items.forEach(h=>{const c=new gt({geometry:new Rt(a),__type:"zone-label"});c.setStyle(new at({text:new qe({text:h.text,font:h.font||"12px Arial",fill:new yt({color:h.textColor||"#000"}),backgroundFill:h.backgroundColor?new yt({color:h.backgroundColor}):void 0,padding:h.padding||[3,6,3,6],offsetY:h.offsetY||0,textAlign:h.textAlign||"left"})})),t.addFeature(c)})}else if(n.options.getZoneOccupationLabels){const l=n.options.getZoneOccupationLabels(r);if(l.title){const h=new gt({geometry:new Rt(a),__type:"zone-label"});h.setStyle(new at({text:new qe({text:l.title,font:"bold 14px Arial",fill:new yt({color:"#000"}),offsetY:-l.items.length*10-10})})),t.addFeature(h)}l.items.forEach((h,c)=>{const u=new gt({geometry:new Rt(a),__type:"zone-label"});u.setStyle(new at({text:new qe({text:h.text,font:"12px Arial",fill:new yt({color:"#ffffff"}),backgroundFill:new yt({color:h.color}),padding:[3,6,3,6],offsetY:c*20-l.items.length*5,textAlign:"left"})})),t.addFeature(u)})}})}function Og(n){n.on("pointermove",t=>{var s;if(n.initialState._currentAction==="drawing"){n._hidePopup();return}const i=n.forEachFeatureAtPixel(t.pixel,r=>r);if(i&&i.get("__type")==="zone"){const r=i.getProperties(),o=(s=n.options.zoningConfig)==null?void 0:s.popup,a=o&&o.template?o.template(r):zg(r);n._showPopup({event:t,content:a})}else i||n._hidePopup()})}function kg(n){const t=new pn({wrapX:!1}),e=new Ii({source:t,style:i=>Ro(i.getProperties())});return n&&e.setExtent(n),{layer:e,source:t}}function Ng(n){const t=new pn({wrapX:!1}),e=new Ii({source:t});return n&&e.setExtent(n),{layer:e,source:t}}function Ro({color:n}){return[new at({stroke:new Qt({color:n,width:3}),fill:new yt({color:n+"80"})})]}function Gg({color:n}){return[new at({stroke:new Qt({color:n,width:5}),fill:new yt({color:n+"A0"})})]}function zg(n){return`
|
|
7
7
|
<div style="display: flex; gap: 1rem; background-color: rgba(220,220,220,0.75); padding: 1rem">
|
|
8
8
|
<div style="height: 1rem; width: 1rem; background-color: ${n.color}"></div>
|
|
9
9
|
<div>${n.name}</div>
|
|
10
10
|
</div>
|
|
11
|
-
`}const Wg={a0:[1189,841],a1:[841,594],a2:[594,420],a3:[420,297],a4:[297,210],a5:[210,148]},hh={name:"ppe-pdf-export",getInitialState:n=>({...n}),createPlanEditor:n=>{n.exportToPdf=t=>jg(n,t),n.exportPeriodicPdf=t=>Vg(n,t)}};async function ch(n,t,e){return new Promise(i=>{n.once("rendercomplete",function(){setTimeout(()=>{const s=document.createElement("canvas");s.width=t,s.height=e;const r=s.getContext("2d");if(!r){console.error("Unable to get canvas context"),i("");return}r.fillStyle="#FFFFFF",r.fillRect(0,0,t,e);const o=n.getViewport().querySelectorAll(".ol-layer canvas, canvas.ol-layer");Array.from(o).forEach(a=>{var l,h;if(a instanceof HTMLCanvasElement&&a.width>0){const c=((l=a.parentNode)==null?void 0:l.style.opacity)||"1";r.globalAlpha=parseFloat(c);const d=(h=a.style.transform.match(/^matrix\(([^(]*)\)$/))==null?void 0:h[1].split(",").map(Number);d&&r.setTransform(...d),r.drawImage(a,0,0),r.setTransform(1,0,0,1,0,0),r.globalAlpha=1}}),i(s.toDataURL("image/jpeg",1))},100)}),n.renderSync()})}function uh(n){const t=n.getTarget(),e=n.getSize();return{size:e?[e[0],e[1]]:[0,0],view:{center:n.getView().getCenter()||[0,0],zoom:n.getView().getZoom()||1,rotation:n.getView().getRotation()||0},containerStyles:{width:t.style.width,height:t.style.height,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight}}}function dh(n,t){const e=n.getTarget();e.style.width=t.containerStyles.width,e.style.height=t.containerStyles.height,e.style.maxWidth=t.containerStyles.maxWidth,e.style.maxHeight=t.containerStyles.maxHeight,n.setSize(t.size),n.getView().setCenter(t.view.center),n.getView().setZoom(t.view.zoom),n.getView().setRotation(t.view.rotation)}function fh(n,t,e,i){const s=Wg[t],[r,o]=e==="landscape"?[s[0],s[1]]:[s[1],s[0]],a=i/25.4,l=Math.round(r*a),h=Math.round(o*a),c=n.getTarget();return c.style.width=`${l}px`,c.style.height=`${h}px`,c.style.maxWidth="none",c.style.maxHeight="none",n.setSize([l,h]),{width:r,height:o,canvasWidth:l,canvasHeight:h}}async function jg(n,t){const e=(t==null?void 0:t.format)||"a4",i=(t==null?void 0:t.orientation)||"landscape",s=(t==null?void 0:t.resolution)||350,r=(t==null?void 0:t.filename)||"map.pdf",o=(t==null?void 0:t.fitContent)!==!1,a=new Pt.jsPDF(i,"mm",e),l=uh(n);try{const{width:h,height:c,canvasWidth:u,canvasHeight:d}=fh(n,e,i,s);o&&(n.fitToContent(),await new Promise(g=>setTimeout(g,500)));const f=await ch(n,u,d);f&&a.addImage(f,"JPEG",0,0,h,c,void 0,"FAST"),a.save(r)}finally{dh(n,l)}}async function Vg(n,t){var h,c,u;const e=t.format||"a4",i=t.orientation||"landscape",s=t.resolution||350,r=t.filename||"periodic-export.pdf",o=t.periods;if(!o||o.length===0)throw new Error("No periods provided for periodic export");const a=new Pt.jsPDF(i,"mm",e),l=uh(n);try{const{width:d,height:f,canvasWidth:g,canvasHeight:m}=fh(n,e,i,s);n.fitToContent(),await new Promise(_=>setTimeout(_,500));for(let _=0;_<o.length&&!((h=t.onCancel)!=null&&h.call(t));_++){const y=o[_];await t.updateTasksForPeriod(y);const p=await ch(n,g,m);(c=t.onProgress)==null||c.call(t,_+1,o.length,y.label,p),_>0&&a.addPage(),p&&(a.addImage(p,"JPEG",0,0,d,f,void 0,"FAST"),a.setFontSize(10),a.setTextColor(0,0,0),a.text(`Période: ${y.label}`,10,f-10))}(u=t.onCancel)!=null&&u.call(t)||a.save(r)}finally{dh(n,l)}}let To;const Sn=[];function gh(n,t,e,i,s){n.beginPath(),n.moveTo(0,0),n.lineTo(t,e),n.lineTo(i,s),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(t,i)+1,Math.max(e,s)),n.restore()}function Po(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function Xg(){if(To===void 0){const n=ft(6,6,Sn);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",gh(n,4,5,4,0),gh(n,4,5,0,5);const t=n.getImageData(0,0,3,3).data;To=Po(t,0)||Po(t,4)||Po(t,8),Zs(n),Sn.push(n.canvas)}return To}function Bg(n,t,e,i){const s=fa(e,t,n);let r=ua(t,i,e);const o=t.getMetersPerUnit();o!==void 0&&(r*=o);const a=n.getMetersPerUnit();a!==void 0&&(r/=a);const l=n.getExtent();if(!l||ki(l,s)){const h=ua(n,r,s)/r;isFinite(h)&&h>0&&(r/=h)}return r}function Yg(n,t,e,i,s,r,o,a,l,h,c,u,d,f){const g=ft(Math.round(e*n),Math.round(e*t),Sn);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function m(C){return Math.round(C*e)/e}g.globalCompositeOperation="lighter";const _=kt();l.forEach(function(C,S,T){zo(_,C.extent)});let y;const p=e/i,E=(u?1:1+Math.pow(2,-24))/p;(l.length!==1||h!==0)&&(y=ft(Math.round(K(_)*p),Math.round(dt(_)*p),Sn),u||(y.imageSmoothingEnabled=!1),l.forEach(function(C,S,T){if(C.image.width>0&&C.image.height>0){if(C.clipExtent){y.save();const N=(C.clipExtent[0]-_[0])*p,j=-(C.clipExtent[3]-_[3])*p,F=K(C.clipExtent)*p,q=dt(C.clipExtent)*p;y.rect(u?N:Math.round(N),u?j:Math.round(j),u?F:Math.round(N+F)-Math.round(N),u?q:Math.round(j+q)-Math.round(j)),y.clip()}const I=(C.extent[0]-_[0])*p,R=-(C.extent[3]-_[3])*p,M=K(C.extent)*p,k=dt(C.extent)*p;y.drawImage(C.image,h,h,C.image.width-2*h,C.image.height-2*h,u?I:Math.round(I),u?R:Math.round(R),u?M:Math.round(I+M)-Math.round(I),u?k:Math.round(R+k)-Math.round(R)),C.clipExtent&&y.restore()}}));const x=An(o);return a.getTriangles().forEach(function(C,S,T){const I=C.source,R=C.target;let M=I[0][0],k=I[0][1],N=I[1][0],j=I[1][1],F=I[2][0],q=I[2][1];const b=m((R[0][0]-x[0])/r),W=m(-(R[0][1]-x[1])/r),V=m((R[1][0]-x[0])/r),Q=m(-(R[1][1]-x[1])/r),J=m((R[2][0]-x[0])/r),tt=m(-(R[2][1]-x[1])/r),v=M,Ce=k;M=0,k=0,N-=v,j-=Ce,F-=v,q-=Ce;const ii=[[N,j,0,0,V-b],[F,q,0,0,J-b],[0,0,N,j,Q-W],[0,0,F,q,tt-W]],St=Nh(ii);if(!St)return;if(g.save(),g.beginPath(),Xg()||!u){g.moveTo(V,Q);const $t=4,Ne=b-V,In=W-Q;for(let se=0;se<$t;se++)g.lineTo(V+m((se+1)*Ne/$t),Q+m(se*In/($t-1))),se!=$t-1&&g.lineTo(V+m((se+1)*Ne/$t),Q+m((se+1)*In/($t-1)));g.lineTo(J,tt)}else g.moveTo(V,Q),g.lineTo(b,W),g.lineTo(J,tt);g.clip(),g.transform(St[0],St[2],St[1],St[3],b,W),g.translate(_[0]-v,_[3]-Ce);let ne;if(y)ne=y.canvas,g.scale(E,-E);else{const $t=l[0],Ne=$t.extent;ne=$t.image,g.scale(K(Ne)/ne.width,-dt(Ne)/ne.height)}g.drawImage(ne,0,0),g.restore()}),y&&(Zs(y),Sn.push(y.canvas)),g.canvas}function Mo(n){return Array.isArray(n)?Math.min(...n):n}const Zg=10,_h=.25;class Kg{constructor(t,e,i,s,r,o,a){this.sourceProj_=t,this.targetProj_=e;let l={};const h=a?wc(E=>mt(a,fa(E,this.targetProj_,this.sourceProj_))):Xi(this.targetProj_,this.sourceProj_);this.transformInv_=function(E){const x=E[0]+"/"+E[1];return l[x]||(l[x]=h(E)),l[x]},this.maxSourceExtent_=s,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!s&&!!this.sourceProj_.getExtent()&&K(s)>=K(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?K(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?K(this.targetProj_.getExtent()):null;const c=An(i),u=zs(i),d=Ns(i),f=ks(i),g=this.transformInv_(c),m=this.transformInv_(u),_=this.transformInv_(d),y=this.transformInv_(f),p=Zg+(o?Math.max(0,Math.ceil(Math.log2(Ah(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,m,_,y,p),this.wrapsXInSource_){let E=1/0;this.triangles_.forEach(function(x,C,S){E=Math.min(E,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])-E>this.sourceWorldWidth_/2){const C=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];C[0][0]-E>this.sourceWorldWidth_/2&&(C[0][0]-=this.sourceWorldWidth_),C[1][0]-E>this.sourceWorldWidth_/2&&(C[1][0]-=this.sourceWorldWidth_),C[2][0]-E>this.sourceWorldWidth_/2&&(C[2][0]-=this.sourceWorldWidth_);const S=Math.min(C[0][0],C[1][0],C[2][0]);Math.max(C[0][0],C[1][0],C[2][0])-S<this.sourceWorldWidth_/2&&(x.source=C)}})}l={}}addTriangle_(t,e,i,s,r,o){this.triangles_.push({source:[s,r,o],target:[t,e,i]})}addQuad_(t,e,i,s,r,o,a,l,h){const c=ut([r,o,a,l]),u=this.sourceWorldWidth_?K(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=ut([t,e,i,s]);g=K(_)/this.targetWorldWidth_>_h||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>_h||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!_t(c,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(h>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(h>0){if(!g){const _=[(t[0]+i[0])/2,(t[1]+i[1])/2],y=this.transformInv_(_);let p;f?p=(ri(r[0],d)+ri(a[0],d))/2-ri(y[0],d):p=(r[0]+a[0])/2-y[0];const E=(r[1]+a[1])/2-y[1];g=p*p+E*E>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const _=[(e[0]+i[0])/2,(e[1]+i[1])/2],y=this.transformInv_(_),p=[(s[0]+t[0])/2,(s[1]+t[1])/2],E=this.transformInv_(p);this.addQuad_(t,e,_,p,r,o,y,E,h-1),this.addQuad_(p,_,i,s,E,y,a,l,h-1)}else{const _=[(t[0]+e[0])/2,(t[1]+e[1])/2],y=this.transformInv_(_),p=[(i[0]+s[0])/2,(i[1]+s[1])/2],E=this.transformInv_(p);this.addQuad_(t,_,p,s,r,y,E,l,h-1),this.addQuad_(_,e,i,p,y,o,a,E,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(t,i,s,r,a,l),(m&14)==0&&this.addTriangle_(t,i,e,r,a,o),m&&((m&13)==0&&this.addTriangle_(e,s,t,o,l,r),(m&7)==0&&this.addTriangle_(e,s,i,o,l,a))}calculateSourceExtent(){const t=kt();return this.triangles_.forEach(function(e,i,s){const r=e.source;Wi(t,r[0]),Wi(t,r[1]),Wi(t,r[2])}),t}getTriangles(){return this.triangles_}}const Ug=.5;class Hg extends gr{constructor(t,e,i,s,r,o,a){let l=t.getExtent();l&&t.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);let h=e.getExtent();h&&e.canWrapX()&&(h=h.slice(),h[0]=-1/0,h[2]=1/0);const c=h?Gs(i,h):i,u=Xt(c),d=Bg(t,e,u,s),f=Ug,g=new Kg(t,e,c,l,d*f,s),m=g.calculateSourceExtent(),_=si(m)?null:o(m,d,r),y=_?P.IDLE:P.EMPTY,p=_?_.getPixelRatio():1;super(i,s,p,y),this.targetProj_=e,this.maxSourceExtent_=l,this.triangulation_=g,this.targetResolution_=s,this.targetExtent_=i,this.sourceImage_=_,this.sourcePixelRatio_=p,this.interpolate_=a,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==P.LOADING&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const t=this.sourceImage_.getState();if(t==P.LOADED){const e=K(this.targetExtent_)/this.targetResolution_,i=dt(this.targetExtent_)/this.targetResolution_;this.canvas_=Yg(e,i,this.sourcePixelRatio_,Mo(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_)}this.state=t,this.changed()}load(){if(this.state==P.IDLE){this.state=P.LOADING,this.changed();const t=this.sourceImage_.getState();t==P.LOADED||t==P.ERROR?this.reproject_():(this.sourceListenerKey_=z(this.sourceImage_,D.CHANGE,e=>{const i=this.sourceImage_.getState();(i==P.LOADED||i==P.ERROR)&&(this.unlistenSource_(),this.reproject_())}),this.sourceImage_.load())}}unlistenSource_(){$(this.sourceListenerKey_),this.sourceListenerKey_=null}}const Ps=4,Lo={IMAGELOADSTART:"imageloadstart",IMAGELOADEND:"imageloadend",IMAGELOADERROR:"imageloaderror"};class qg extends Mt{constructor(t,e){super(t),this.image=e}}class $g extends Gl{constructor(t){super({attributions:t.attributions,projection:t.projection,state:t.state,interpolate:t.interpolate!==void 0?t.interpolate:!0}),this.on,this.once,this.un,this.loader=t.loader||null,this.resolutions_=t.resolutions!==void 0?t.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=t.loader?t.loader.length===0:!1,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(t){this.resolutions_=t}findNearestResolution(t){const e=this.getResolutions();if(e){const i=Fs(e,t,0);t=e[i]}return t}getImage(t,e,i,s){const r=this.getProjection();if(!r||!s||er(r,s))return r&&(s=r),this.getImageInternal(t,e,i,s);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&er(this.reprojectedImage_.getProjection(),s)&&this.reprojectedImage_.getResolution()==e&&zi(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new Hg(r,s,t,e,i,(o,a,l)=>this.getImageInternal(o,a,l,r),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(t,e,i,s){if(this.loader){const r=Qg(t,e,i,1),o=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===s&&(this.wantedExtent_&&ae(this.wantedExtent_,r)||ae(this.image.getExtent(),r))&&(this.wantedResolution_&&Mo(this.wantedResolution_)===o||Mo(this.image.getResolution())===o)))return this.image;this.wantedProjection_=s,this.wantedExtent_=r,this.wantedResolution_=o,this.image=new gr(r,o,i,this.loader),this.image.addEventListener(D.CHANGE,this.handleImageChange.bind(this))}return this.image}handleImageChange(t){const e=t.target;let i;switch(e.getState()){case P.LOADING:this.loading=!0,i=Lo.IMAGELOADSTART;break;case P.LOADED:this.loading=!1,i=Lo.IMAGELOADEND;break;case P.ERROR:this.loading=!1,i=Lo.IMAGELOADERROR;break;default:return}this.hasListener(i)&&this.dispatchEvent(new qg(i,e))}}function Jg(n,t){n.getImage().src=t}function Qg(n,t,e,i){const s=t/e,r=Xt(n),o=bn(K(n)/s,Ps),a=bn(dt(n)/s,Ps),l=bn((i-1)*o/2,Ps),h=o+2*l,c=bn((i-1)*a/2,Ps),u=a+2*c;return Ln(r,s,0,[h,u])}function t_(n){const t=n.load||Ea,e=n.imageExtent,i=n.crossOrigin??null;return()=>{const s=new Image;return s.crossOrigin=i,t(s,n.url).then(r=>{const o=K(e)/r.width,a=dt(e)/r.height;return{image:r,extent:e,resolution:o!==a?[o,a]:a,pixelRatio:1}})}}class e_ extends $g{constructor(t){const e=t.crossOrigin!==void 0?t.crossOrigin:null,i=t.imageLoadFunction!==void 0?t.imageLoadFunction:Jg;super({attributions:t.attributions,interpolate:t.interpolate,projection:ot(t.projection)}),this.url_=t.url,this.imageExtent_=t.imageExtent,this.image=null,this.image=new gr(this.imageExtent_,void 0,1,t_({url:t.url,imageExtent:t.imageExtent,crossOrigin:e,load:(s,r)=>(this.image.setImage(s),i(this.image,r),Ea(s))})),this.image.addEventListener(D.CHANGE,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(t,e,i,s){return _t(t,this.image.getExtent())?this.image:null}getUrl(){return this.url_}}class i_ extends Qa{constructor(t){super(t),this.image=null}getImage(){return this.image?this.image.getImage():null}prepareFrame(t){const e=t.layerStatesArray[t.layerIndex],i=t.pixelRatio,s=t.viewState,r=s.resolution,o=this.getLayer().getSource(),a=t.viewHints;let l=t.extent;if(e.extent!==void 0&&(l=Gs(l,Te(e.extent,s.projection))),!a[et.ANIMATING]&&!a[et.INTERACTING]&&!si(l))if(o){const h=s.projection,c=o.getImage(l,r,i,h);c&&(this.loadImage(c)?this.image=c:c.getState()===P.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),s=mt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!ki(r,s))return null;const o=this.image.getExtent(),a=this.image.getImage(),l=K(o),h=Math.floor(a.width*((s[0]-o[0])/l));if(h<0||h>=a.width)return null;const c=dt(o),u=Math.floor(a.height*((o[3]-s[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(t,e){const i=this.image,s=i.getExtent(),r=i.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],l=i.getPixelRatio(),h=t.layerStatesArray[t.layerIndex],c=t.pixelRatio,u=t.viewState,d=u.center,f=u.resolution,g=c*o/(f*l),m=c*a/(f*l);this.prepareContainer(t,e);const _=this.context.canvas.width,y=this.context.canvas.height,p=this.getRenderContext(t);let E=!1,x=!0;if(h.extent){const R=Te(h.extent,u.projection);x=_t(R,t.extent),E=x&&!ae(R,t.extent),E&&this.clipUnrotated(p,t,R)}const C=i.getImage(),S=de(this.tempTransform,_/2,y/2,g,m,0,l*(s[0]-d[0])/o,l*(d[1]-s[3])/a);this.renderedResolution=a*c/l;const T=C.width*S[0],I=C.height*S[3];if(this.getLayer().getSource().getInterpolate()||(p.imageSmoothingEnabled=!1),this.preRender(p,t),x&&T>=.5&&I>=.5){const R=S[4],M=S[5],k=h.opacity;k!==1&&(p.save(),p.globalAlpha=k),p.drawImage(C,0,0,+C.width,+C.height,R,M,T,I),k!==1&&p.restore()}return this.postRender(this.context,t),E&&p.restore(),p.imageSmoothingEnabled=!0,this.container}}class n_ extends ds{constructor(t){t=t||{},super(t)}}class s_ extends n_{constructor(t){super(t)}createRenderer(){return new i_(this)}getData(t){return super.getData(t)}}function r_(n,t){return typeof n=="function"?n(t):n}const o_={name:"ppe-popup",getInitialState:n=>({...n}),createPlanEditor:n=>{const{overlay:t,closerElement:e,popupElement:i}=l_();n.addOverlay(t),e.addEventListener("click",()=>(t.setPosition(void 0),e.blur(),!1)),n._showPopup=(s,r)=>{t.setPosition(s.event.coordinate),i.innerHTML=s.content,r!=null&&r.offset&&t.setOffset(r.offset),t.setPositioning(a_(n,s.event,r==null?void 0:r.positioning))},n._hidePopup=()=>{t.setPosition(void 0)}}};function a_(n,t,e){if(e&&e!="auto")return e;const i=n.getSize();if(!i)return"top-right";const[s,r]=n.getPixelFromCoordinate(t.coordinate),[o,a]=i,l=s<o/2?"left":"right";return`${r<a/2?"top":"bottom"}-${l}`}function l_(){const n=document.createElement("div");n.id="ppe-popup",n.className="ppe-popup";const t=document.createElement("button");t.className="ppe-popup-closer";const e=document.createElement("div");return e.className="ppe-popup-content",n.insertAdjacentElement("beforeend",t),n.insertAdjacentElement("beforeend",e),{overlay:new tg({element:n,stopEvent:!1}),popupElement:n,closerElement:t}}const mh=[nh,{name:"ppe-layer",getInitialState:n=>({...n}),createPlanEditor:n=>{n.addVectorLayer=()=>{const t=new pn({wrapX:!1}),e=new Ii({source:t});return n.initialState._extent&&e.setExtent(n.initialState._extent),e}}},o_,hh];function h_(n){var m;const t=[...mh,...n._plugins??[]],{plan:e}=n,i=[0,0,e.file.width,e.file.height],s=new kn({code:"",units:"pixels",extent:i}),r=new e_({imageExtent:i,projection:s,url:e.file.original_url,crossOrigin:"anonymous"}),o=new s_({source:r}),a=new ee({projection:s,center:Xt(i),zoom:2,minZoom:0,maxZoom:10}),l=new Jf({target:n.target??"map",layers:[o],view:a}),h={_extent:i,_projection:s},c=l;c._plugins=t;const u=c._plugins.reduce((_,y)=>{var p;return Object.assign(_,(p=y.getDefaultOptions)==null?void 0:p.call(y,c))},{});let d={...h,...n.initialState??{}};c._plugins.forEach(_=>{var y;d=((y=_.getInitialState)==null?void 0:y.call(_,d))??d});const f=_=>c.options.mergeOptions?c.options.mergeOptions(u,_):{...u,..._},g={_plugins:t,options:{...u,...n},initialState:d,reset:()=>{c.setState(c.initialState)},getState:()=>c.options.state,setState:_=>{var y,p;(p=(y=c.options).onStateChange)==null||p.call(y,_)},setOptions:_=>{const y=r_(_,c.options),p=c.getTarget(),E=f(y);c.options=E,E.target&&E.target!==p&&c.setTarget(E.target)},fitToContent:()=>{const _=c.getView(),y=c.getSize();y&&i&&_.fit(i,{size:y,padding:[0,0,0,0],duration:500})}};Object.assign(c,g);for(const _ of c._plugins)(m=_==null?void 0:_.createPlanEditor)==null||m.call(_,c);return c}ht.PdfExportPlugin=hh,ht.ZoningPlugin=nh,ht.convertToZoneGeometry=vs,ht.convertZoneToGeometryFeatures=ih,ht.createPlanEditor=h_,ht.defaultPlugins=mh,Object.defineProperty(ht,Symbol.toStringTag,{value:"Module"})}));
|
|
11
|
+
`}const Wg={a0:[1189,841],a1:[841,594],a2:[594,420],a3:[420,297],a4:[297,210],a5:[210,148]},hh={name:"ppe-pdf-export",getInitialState:n=>({...n}),createPlanEditor:n=>{n.exportToPdf=t=>jg(n,t),n.exportPeriodicPdf=t=>Vg(n,t)}};async function ch(n,t,e){return new Promise(i=>{n.once("rendercomplete",function(){setTimeout(()=>{const s=document.createElement("canvas");s.width=t,s.height=e;const r=s.getContext("2d");if(!r){console.error("Unable to get canvas context"),i("");return}r.fillStyle="#FFFFFF",r.fillRect(0,0,t,e);const o=n.getViewport().querySelectorAll(".ol-layer canvas, canvas.ol-layer");Array.from(o).forEach(a=>{var l,h;if(a instanceof HTMLCanvasElement&&a.width>0){const c=((l=a.parentNode)==null?void 0:l.style.opacity)||"1";r.globalAlpha=parseFloat(c);const d=(h=a.style.transform.match(/^matrix\(([^(]*)\)$/))==null?void 0:h[1].split(",").map(Number);d&&r.setTransform(...d),r.drawImage(a,0,0),r.setTransform(1,0,0,1,0,0),r.globalAlpha=1}}),i(s.toDataURL("image/jpeg",1))},100)}),n.renderSync()})}function uh(n){const t=n.getTarget(),e=n.getSize();return{size:e?[e[0],e[1]]:[0,0],view:{center:n.getView().getCenter()||[0,0],zoom:n.getView().getZoom()||1,rotation:n.getView().getRotation()||0},containerStyles:{width:t.style.width,height:t.style.height,maxWidth:t.style.maxWidth,maxHeight:t.style.maxHeight}}}function dh(n,t){const e=n.getTarget();e.style.width=t.containerStyles.width,e.style.height=t.containerStyles.height,e.style.maxWidth=t.containerStyles.maxWidth,e.style.maxHeight=t.containerStyles.maxHeight,n.setSize(t.size),n.getView().setCenter(t.view.center),n.getView().setZoom(t.view.zoom),n.getView().setRotation(t.view.rotation)}function fh(n,t,e,i){const s=Wg[t];if(!s)throw new Error(`Invalid PDF format: ${t}`);const[r,o]=e==="landscape"?[s[0],s[1]]:[s[1],s[0]],a=i/25.4,l=Math.round(r*a),h=Math.round(o*a),c=n.getTarget();if(!c)throw new Error("Unable to get editor container");return c.style.width=`${l}px`,c.style.height=`${h}px`,c.style.maxWidth="none",c.style.maxHeight="none",n.setSize([l,h]),{width:r,height:o,canvasWidth:l,canvasHeight:h}}async function jg(n,t){const e=(t==null?void 0:t.format)||"a4",i=(t==null?void 0:t.orientation)||"landscape",s=(t==null?void 0:t.resolution)||350,r=(t==null?void 0:t.filename)||"map.pdf",o=(t==null?void 0:t.fitContent)!==!1,a=new Pt.jsPDF(i,"mm",e),l=uh(n);try{const{width:h,height:c,canvasWidth:u,canvasHeight:d}=fh(n,e,i,s);o&&(n.fitToContent(),await new Promise(g=>setTimeout(g,500)));const f=await ch(n,u,d);f&&a.addImage(f,"JPEG",0,0,h,c,void 0,"FAST"),a.save(r)}finally{dh(n,l)}}async function Vg(n,t){var h,c,u;const e=t.format||"a4",i=t.orientation||"landscape",s=t.resolution||350,r=t.filename||"periodic-export.pdf",o=t.periods;if(!o||o.length===0)throw new Error("No periods provided for periodic export");const a=new Pt.jsPDF(i,"mm",e),l=uh(n);try{const{width:d,height:f,canvasWidth:g,canvasHeight:m}=fh(n,e,i,s);n.fitToContent(),await new Promise(_=>setTimeout(_,500));for(let _=0;_<o.length&&!((h=t.onCancel)!=null&&h.call(t));_++){const y=o[_];await t.updateTasksForPeriod(y);const p=await ch(n,g,m);(c=t.onProgress)==null||c.call(t,_+1,o.length,y.label,p),_>0&&a.addPage(),p&&(a.addImage(p,"JPEG",0,0,d,f,void 0,"FAST"),a.setFontSize(10),a.setTextColor(0,0,0),a.text(`Période: ${y.label}`,10,f-10))}(u=t.onCancel)!=null&&u.call(t)||a.save(r)}finally{dh(n,l)}}let To;const Sn=[];function gh(n,t,e,i,s){n.beginPath(),n.moveTo(0,0),n.lineTo(t,e),n.lineTo(i,s),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(t,i)+1,Math.max(e,s)),n.restore()}function Po(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function Xg(){if(To===void 0){const n=ft(6,6,Sn);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",gh(n,4,5,4,0),gh(n,4,5,0,5);const t=n.getImageData(0,0,3,3).data;To=Po(t,0)||Po(t,4)||Po(t,8),Zs(n),Sn.push(n.canvas)}return To}function Bg(n,t,e,i){const s=fa(e,t,n);let r=ua(t,i,e);const o=t.getMetersPerUnit();o!==void 0&&(r*=o);const a=n.getMetersPerUnit();a!==void 0&&(r/=a);const l=n.getExtent();if(!l||ki(l,s)){const h=ua(n,r,s)/r;isFinite(h)&&h>0&&(r/=h)}return r}function Yg(n,t,e,i,s,r,o,a,l,h,c,u,d,f){const g=ft(Math.round(e*n),Math.round(e*t),Sn);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function m(C){return Math.round(C*e)/e}g.globalCompositeOperation="lighter";const _=kt();l.forEach(function(C,S,T){zo(_,C.extent)});let y;const p=e/i,E=(u?1:1+Math.pow(2,-24))/p;(l.length!==1||h!==0)&&(y=ft(Math.round(K(_)*p),Math.round(dt(_)*p),Sn),u||(y.imageSmoothingEnabled=!1),l.forEach(function(C,S,T){if(C.image.width>0&&C.image.height>0){if(C.clipExtent){y.save();const N=(C.clipExtent[0]-_[0])*p,j=-(C.clipExtent[3]-_[3])*p,F=K(C.clipExtent)*p,q=dt(C.clipExtent)*p;y.rect(u?N:Math.round(N),u?j:Math.round(j),u?F:Math.round(N+F)-Math.round(N),u?q:Math.round(j+q)-Math.round(j)),y.clip()}const I=(C.extent[0]-_[0])*p,v=-(C.extent[3]-_[3])*p,M=K(C.extent)*p,k=dt(C.extent)*p;y.drawImage(C.image,h,h,C.image.width-2*h,C.image.height-2*h,u?I:Math.round(I),u?v:Math.round(v),u?M:Math.round(I+M)-Math.round(I),u?k:Math.round(v+k)-Math.round(v)),C.clipExtent&&y.restore()}}));const x=An(o);return a.getTriangles().forEach(function(C,S,T){const I=C.source,v=C.target;let M=I[0][0],k=I[0][1],N=I[1][0],j=I[1][1],F=I[2][0],q=I[2][1];const b=m((v[0][0]-x[0])/r),W=m(-(v[0][1]-x[1])/r),V=m((v[1][0]-x[0])/r),Q=m(-(v[1][1]-x[1])/r),J=m((v[2][0]-x[0])/r),tt=m(-(v[2][1]-x[1])/r),R=M,Ce=k;M=0,k=0,N-=R,j-=Ce,F-=R,q-=Ce;const ii=[[N,j,0,0,V-b],[F,q,0,0,J-b],[0,0,N,j,Q-W],[0,0,F,q,tt-W]],St=Nh(ii);if(!St)return;if(g.save(),g.beginPath(),Xg()||!u){g.moveTo(V,Q);const $t=4,Ne=b-V,In=W-Q;for(let se=0;se<$t;se++)g.lineTo(V+m((se+1)*Ne/$t),Q+m(se*In/($t-1))),se!=$t-1&&g.lineTo(V+m((se+1)*Ne/$t),Q+m((se+1)*In/($t-1)));g.lineTo(J,tt)}else g.moveTo(V,Q),g.lineTo(b,W),g.lineTo(J,tt);g.clip(),g.transform(St[0],St[2],St[1],St[3],b,W),g.translate(_[0]-R,_[3]-Ce);let ne;if(y)ne=y.canvas,g.scale(E,-E);else{const $t=l[0],Ne=$t.extent;ne=$t.image,g.scale(K(Ne)/ne.width,-dt(Ne)/ne.height)}g.drawImage(ne,0,0),g.restore()}),y&&(Zs(y),Sn.push(y.canvas)),g.canvas}function Mo(n){return Array.isArray(n)?Math.min(...n):n}const Zg=10,_h=.25;class Kg{constructor(t,e,i,s,r,o,a){this.sourceProj_=t,this.targetProj_=e;let l={};const h=a?wc(E=>mt(a,fa(E,this.targetProj_,this.sourceProj_))):Xi(this.targetProj_,this.sourceProj_);this.transformInv_=function(E){const x=E[0]+"/"+E[1];return l[x]||(l[x]=h(E)),l[x]},this.maxSourceExtent_=s,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!s&&!!this.sourceProj_.getExtent()&&K(s)>=K(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?K(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?K(this.targetProj_.getExtent()):null;const c=An(i),u=zs(i),d=Ns(i),f=ks(i),g=this.transformInv_(c),m=this.transformInv_(u),_=this.transformInv_(d),y=this.transformInv_(f),p=Zg+(o?Math.max(0,Math.ceil(Math.log2(Ah(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,m,_,y,p),this.wrapsXInSource_){let E=1/0;this.triangles_.forEach(function(x,C,S){E=Math.min(E,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])-E>this.sourceWorldWidth_/2){const C=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];C[0][0]-E>this.sourceWorldWidth_/2&&(C[0][0]-=this.sourceWorldWidth_),C[1][0]-E>this.sourceWorldWidth_/2&&(C[1][0]-=this.sourceWorldWidth_),C[2][0]-E>this.sourceWorldWidth_/2&&(C[2][0]-=this.sourceWorldWidth_);const S=Math.min(C[0][0],C[1][0],C[2][0]);Math.max(C[0][0],C[1][0],C[2][0])-S<this.sourceWorldWidth_/2&&(x.source=C)}})}l={}}addTriangle_(t,e,i,s,r,o){this.triangles_.push({source:[s,r,o],target:[t,e,i]})}addQuad_(t,e,i,s,r,o,a,l,h){const c=ut([r,o,a,l]),u=this.sourceWorldWidth_?K(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=ut([t,e,i,s]);g=K(_)/this.targetWorldWidth_>_h||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>_h||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!_t(c,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(h>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(h>0){if(!g){const _=[(t[0]+i[0])/2,(t[1]+i[1])/2],y=this.transformInv_(_);let p;f?p=(ri(r[0],d)+ri(a[0],d))/2-ri(y[0],d):p=(r[0]+a[0])/2-y[0];const E=(r[1]+a[1])/2-y[1];g=p*p+E*E>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const _=[(e[0]+i[0])/2,(e[1]+i[1])/2],y=this.transformInv_(_),p=[(s[0]+t[0])/2,(s[1]+t[1])/2],E=this.transformInv_(p);this.addQuad_(t,e,_,p,r,o,y,E,h-1),this.addQuad_(p,_,i,s,E,y,a,l,h-1)}else{const _=[(t[0]+e[0])/2,(t[1]+e[1])/2],y=this.transformInv_(_),p=[(i[0]+s[0])/2,(i[1]+s[1])/2],E=this.transformInv_(p);this.addQuad_(t,_,p,s,r,y,E,l,h-1),this.addQuad_(_,e,i,p,y,o,a,E,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(t,i,s,r,a,l),(m&14)==0&&this.addTriangle_(t,i,e,r,a,o),m&&((m&13)==0&&this.addTriangle_(e,s,t,o,l,r),(m&7)==0&&this.addTriangle_(e,s,i,o,l,a))}calculateSourceExtent(){const t=kt();return this.triangles_.forEach(function(e,i,s){const r=e.source;Wi(t,r[0]),Wi(t,r[1]),Wi(t,r[2])}),t}getTriangles(){return this.triangles_}}const Ug=.5;class Hg extends gr{constructor(t,e,i,s,r,o,a){let l=t.getExtent();l&&t.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);let h=e.getExtent();h&&e.canWrapX()&&(h=h.slice(),h[0]=-1/0,h[2]=1/0);const c=h?Gs(i,h):i,u=Xt(c),d=Bg(t,e,u,s),f=Ug,g=new Kg(t,e,c,l,d*f,s),m=g.calculateSourceExtent(),_=si(m)?null:o(m,d,r),y=_?P.IDLE:P.EMPTY,p=_?_.getPixelRatio():1;super(i,s,p,y),this.targetProj_=e,this.maxSourceExtent_=l,this.triangulation_=g,this.targetResolution_=s,this.targetExtent_=i,this.sourceImage_=_,this.sourcePixelRatio_=p,this.interpolate_=a,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==P.LOADING&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const t=this.sourceImage_.getState();if(t==P.LOADED){const e=K(this.targetExtent_)/this.targetResolution_,i=dt(this.targetExtent_)/this.targetResolution_;this.canvas_=Yg(e,i,this.sourcePixelRatio_,Mo(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_)}this.state=t,this.changed()}load(){if(this.state==P.IDLE){this.state=P.LOADING,this.changed();const t=this.sourceImage_.getState();t==P.LOADED||t==P.ERROR?this.reproject_():(this.sourceListenerKey_=z(this.sourceImage_,D.CHANGE,e=>{const i=this.sourceImage_.getState();(i==P.LOADED||i==P.ERROR)&&(this.unlistenSource_(),this.reproject_())}),this.sourceImage_.load())}}unlistenSource_(){$(this.sourceListenerKey_),this.sourceListenerKey_=null}}const Ps=4,Lo={IMAGELOADSTART:"imageloadstart",IMAGELOADEND:"imageloadend",IMAGELOADERROR:"imageloaderror"};class qg extends Mt{constructor(t,e){super(t),this.image=e}}class $g extends Gl{constructor(t){super({attributions:t.attributions,projection:t.projection,state:t.state,interpolate:t.interpolate!==void 0?t.interpolate:!0}),this.on,this.once,this.un,this.loader=t.loader||null,this.resolutions_=t.resolutions!==void 0?t.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=t.loader?t.loader.length===0:!1,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(t){this.resolutions_=t}findNearestResolution(t){const e=this.getResolutions();if(e){const i=Fs(e,t,0);t=e[i]}return t}getImage(t,e,i,s){const r=this.getProjection();if(!r||!s||er(r,s))return r&&(s=r),this.getImageInternal(t,e,i,s);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&er(this.reprojectedImage_.getProjection(),s)&&this.reprojectedImage_.getResolution()==e&&zi(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new Hg(r,s,t,e,i,(o,a,l)=>this.getImageInternal(o,a,l,r),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(t,e,i,s){if(this.loader){const r=Qg(t,e,i,1),o=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===s&&(this.wantedExtent_&&ae(this.wantedExtent_,r)||ae(this.image.getExtent(),r))&&(this.wantedResolution_&&Mo(this.wantedResolution_)===o||Mo(this.image.getResolution())===o)))return this.image;this.wantedProjection_=s,this.wantedExtent_=r,this.wantedResolution_=o,this.image=new gr(r,o,i,this.loader),this.image.addEventListener(D.CHANGE,this.handleImageChange.bind(this))}return this.image}handleImageChange(t){const e=t.target;let i;switch(e.getState()){case P.LOADING:this.loading=!0,i=Lo.IMAGELOADSTART;break;case P.LOADED:this.loading=!1,i=Lo.IMAGELOADEND;break;case P.ERROR:this.loading=!1,i=Lo.IMAGELOADERROR;break;default:return}this.hasListener(i)&&this.dispatchEvent(new qg(i,e))}}function Jg(n,t){n.getImage().src=t}function Qg(n,t,e,i){const s=t/e,r=Xt(n),o=bn(K(n)/s,Ps),a=bn(dt(n)/s,Ps),l=bn((i-1)*o/2,Ps),h=o+2*l,c=bn((i-1)*a/2,Ps),u=a+2*c;return Ln(r,s,0,[h,u])}function t_(n){const t=n.load||Ea,e=n.imageExtent,i=n.crossOrigin??null;return()=>{const s=new Image;return s.crossOrigin=i,t(s,n.url).then(r=>{const o=K(e)/r.width,a=dt(e)/r.height;return{image:r,extent:e,resolution:o!==a?[o,a]:a,pixelRatio:1}})}}class e_ extends $g{constructor(t){const e=t.crossOrigin!==void 0?t.crossOrigin:null,i=t.imageLoadFunction!==void 0?t.imageLoadFunction:Jg;super({attributions:t.attributions,interpolate:t.interpolate,projection:ot(t.projection)}),this.url_=t.url,this.imageExtent_=t.imageExtent,this.image=null,this.image=new gr(this.imageExtent_,void 0,1,t_({url:t.url,imageExtent:t.imageExtent,crossOrigin:e,load:(s,r)=>(this.image.setImage(s),i(this.image,r),Ea(s))})),this.image.addEventListener(D.CHANGE,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(t,e,i,s){return _t(t,this.image.getExtent())?this.image:null}getUrl(){return this.url_}}class i_ extends Qa{constructor(t){super(t),this.image=null}getImage(){return this.image?this.image.getImage():null}prepareFrame(t){const e=t.layerStatesArray[t.layerIndex],i=t.pixelRatio,s=t.viewState,r=s.resolution,o=this.getLayer().getSource(),a=t.viewHints;let l=t.extent;if(e.extent!==void 0&&(l=Gs(l,Te(e.extent,s.projection))),!a[et.ANIMATING]&&!a[et.INTERACTING]&&!si(l))if(o){const h=s.projection,c=o.getImage(l,r,i,h);c&&(this.loadImage(c)?this.image=c:c.getState()===P.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),s=mt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!ki(r,s))return null;const o=this.image.getExtent(),a=this.image.getImage(),l=K(o),h=Math.floor(a.width*((s[0]-o[0])/l));if(h<0||h>=a.width)return null;const c=dt(o),u=Math.floor(a.height*((o[3]-s[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(t,e){const i=this.image,s=i.getExtent(),r=i.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],l=i.getPixelRatio(),h=t.layerStatesArray[t.layerIndex],c=t.pixelRatio,u=t.viewState,d=u.center,f=u.resolution,g=c*o/(f*l),m=c*a/(f*l);this.prepareContainer(t,e);const _=this.context.canvas.width,y=this.context.canvas.height,p=this.getRenderContext(t);let E=!1,x=!0;if(h.extent){const v=Te(h.extent,u.projection);x=_t(v,t.extent),E=x&&!ae(v,t.extent),E&&this.clipUnrotated(p,t,v)}const C=i.getImage(),S=de(this.tempTransform,_/2,y/2,g,m,0,l*(s[0]-d[0])/o,l*(d[1]-s[3])/a);this.renderedResolution=a*c/l;const T=C.width*S[0],I=C.height*S[3];if(this.getLayer().getSource().getInterpolate()||(p.imageSmoothingEnabled=!1),this.preRender(p,t),x&&T>=.5&&I>=.5){const v=S[4],M=S[5],k=h.opacity;k!==1&&(p.save(),p.globalAlpha=k),p.drawImage(C,0,0,+C.width,+C.height,v,M,T,I),k!==1&&p.restore()}return this.postRender(this.context,t),E&&p.restore(),p.imageSmoothingEnabled=!0,this.container}}class n_ extends ds{constructor(t){t=t||{},super(t)}}class s_ extends n_{constructor(t){super(t)}createRenderer(){return new i_(this)}getData(t){return super.getData(t)}}function r_(n,t){return typeof n=="function"?n(t):n}const o_={name:"ppe-popup",getInitialState:n=>({...n}),createPlanEditor:n=>{const{overlay:t,closerElement:e,popupElement:i}=l_();n.addOverlay(t),e.addEventListener("click",()=>(t.setPosition(void 0),e.blur(),!1)),n._showPopup=(s,r)=>{t.setPosition(s.event.coordinate),i.innerHTML=s.content,r!=null&&r.offset&&t.setOffset(r.offset),t.setPositioning(a_(n,s.event,r==null?void 0:r.positioning))},n._hidePopup=()=>{t.setPosition(void 0)}}};function a_(n,t,e){if(e&&e!="auto")return e;const i=n.getSize();if(!i)return"top-right";const[s,r]=n.getPixelFromCoordinate(t.coordinate),[o,a]=i,l=s<o/2?"left":"right";return`${r<a/2?"top":"bottom"}-${l}`}function l_(){const n=document.createElement("div");n.id="ppe-popup",n.className="ppe-popup";const t=document.createElement("button");t.className="ppe-popup-closer";const e=document.createElement("div");return e.className="ppe-popup-content",n.insertAdjacentElement("beforeend",t),n.insertAdjacentElement("beforeend",e),{overlay:new tg({element:n,stopEvent:!1}),popupElement:n,closerElement:t}}const mh=[nh,{name:"ppe-layer",getInitialState:n=>({...n}),createPlanEditor:n=>{n.addVectorLayer=()=>{const t=new pn({wrapX:!1}),e=new Ii({source:t});return n.initialState._extent&&e.setExtent(n.initialState._extent),e}}},o_,hh];function h_(n){var m;const t=[...mh,...n._plugins??[]],{plan:e}=n,i=[0,0,e.file.width,e.file.height],s=new kn({code:"",units:"pixels",extent:i}),r=new e_({imageExtent:i,projection:s,url:e.file.original_url,crossOrigin:"anonymous"}),o=new s_({source:r}),a=new ee({projection:s,center:Xt(i),zoom:2,minZoom:0,maxZoom:10}),l=new Jf({target:n.target??"map",layers:[o],view:a}),h={_extent:i,_projection:s},c=l;c._plugins=t;const u=c._plugins.reduce((_,y)=>{var p;return Object.assign(_,(p=y.getDefaultOptions)==null?void 0:p.call(y,c))},{});let d={...h,...n.initialState??{}};c._plugins.forEach(_=>{var y;d=((y=_.getInitialState)==null?void 0:y.call(_,d))??d});const f=_=>c.options.mergeOptions?c.options.mergeOptions(u,_):{...u,..._},g={_plugins:t,options:{...u,...n},initialState:d,reset:()=>{c.setState(c.initialState)},getState:()=>c.options.state,setState:_=>{var y,p;(p=(y=c.options).onStateChange)==null||p.call(y,_)},setOptions:_=>{const y=r_(_,c.options),p=c.getTarget(),E=f(y);c.options=E,E.target&&E.target!==p&&c.setTarget(E.target)},fitToContent:()=>{const _=c.getView(),y=c.getSize();y&&i&&_.fit(i,{size:y,padding:[0,0,0,0],duration:500})}};Object.assign(c,g);for(const _ of c._plugins)(m=_==null?void 0:_.createPlanEditor)==null||m.call(_,c);return c}ht.PdfExportPlugin=hh,ht.ZoningPlugin=nh,ht.convertToZoneGeometry=Rs,ht.convertZoneToGeometryFeatures=ih,ht.createPlanEditor=h_,ht.defaultPlugins=mh,Object.defineProperty(ht,Symbol.toStringTag,{value:"Module"})}));
|