@defra/interactive-map 0.0.47-alpha → 0.0.48-alpha

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see im-draw-ol-adapter.js.LICENSE.txt */
2
- "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[722],{706(t,e,n){n.r(e),n.d(e,{OLDrawAdapter:()=>gd});function i(t,e){return t>e?1:t<e?-1:0}function r(t,e){return t<e?1:t>e?-1:0}function o(t,e,n){if(t[0]<=e)return 0;const i=t.length;if(e<=t[i-1])return i-1;if("function"==typeof n){for(let r=1;r<i;++r){const i=t[r];if(i===e)return r;if(i<e)return n(e,t[r-1],i)>0?r-1:r}return i-1}if(n>0){for(let n=1;n<i;++n)if(t[n]<e)return n-1;return i-1}if(n<0){for(let n=1;n<i;++n)if(t[n]<=e)return n;return i-1}for(let n=1;n<i;++n){if(t[n]==e)return n;if(t[n]<e)return t[n-1]-e<e-t[n]?n-1:n}return i-1}function s(t,e,n){for(;e<n;){const i=t[e];t[e]=t[n],t[n]=i,++e,--n}}function a(t,e){const n=Array.isArray(e)?e:[e],i=n.length;for(let e=0;e<i;e++)t[t.length]=n[e]}function l(t,e){const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}function h(t){const e=[1/0,1/0,-1/0,-1/0];for(let n=0,i=t.length;n<i;++n)w(e,t[n]);return e}function c(t,e,n){return n?(n[0]=t[0]-e,n[1]=t[1]-e,n[2]=t[2]+e,n[3]=t[3]+e,n):[t[0]-e,t[1]-e,t[2]+e,t[3]+e]}function u(t,e,n){let i,r;return i=e<t[0]?t[0]-e:t[2]<e?e-t[2]:0,r=n<t[1]?t[1]-n:t[3]<n?n-t[3]:0,i*i+r*r}function d(t,e){return g(t,e[0],e[1])}function f(t,e){return t[0]<=e[0]&&e[2]<=t[2]&&t[1]<=e[1]&&e[3]<=t[3]}function g(t,e,n){return t[0]<=e&&e<=t[2]&&t[1]<=n&&n<=t[3]}function p(t,e){const n=t[0],i=t[1],r=t[2],o=t[3],s=e[0],a=e[1];let l=0;return s<n?l|=16:s>r&&(l|=4),a<i?l|=8:a>o&&(l|=2),0===l&&(l=1),l}function m(t,e,n,i,r){return r?(r[0]=t,r[1]=e,r[2]=n,r[3]=i,r):[t,e,n,i]}function y(t){return m(1/0,1/0,-1/0,-1/0,t)}function _(t,e){const n=t[0],i=t[1];return m(n,i,n,i,e)}function v(t,e,n,i,r){return C(y(r),t,e,n,i)}function x(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function S(t,e){return e[0]<t[0]&&(t[0]=e[0]),e[2]>t[2]&&(t[2]=e[2]),e[1]<t[1]&&(t[1]=e[1]),e[3]>t[3]&&(t[3]=e[3]),t}function w(t,e){e[0]<t[0]&&(t[0]=e[0]),e[0]>t[2]&&(t[2]=e[0]),e[1]<t[1]&&(t[1]=e[1]),e[1]>t[3]&&(t[3]=e[1])}function C(t,e,n,i,r){for(;n<i;n+=r)b(t,e[n],e[n+1]);return t}function b(t,e,n){t[0]=Math.min(t[0],e),t[1]=Math.min(t[1],n),t[2]=Math.max(t[2],e),t[3]=Math.max(t[3],n)}function I(t,e){let n;return n=e(E(t)),n||(n=e(P(t)),n||(n=e(R(t)),n||(n=e(k(t)),n||!1)))}function E(t){return[t[0],t[1]]}function P(t){return[t[2],t[1]]}function T(t){return[(t[0]+t[2])/2,(t[1]+t[3])/2]}function M(t){return t[3]-t[1]}function k(t){return[t[0],t[3]]}function R(t){return[t[2],t[3]]}function F(t){return t[2]-t[0]}function O(t,e){return t[0]<=e[2]&&t[2]>=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function A(t){return t[2]<t[0]||t[3]<t[1]}function L(t,e){const n=e.getExtent(),i=T(t);if(e.canWrapX()&&(i[0]<n[0]||i[0]>=n[2])){const e=F(n),r=Math.floor((i[0]-n[0])/e)*e;t[0]-=r,t[2]-=r}return t}function D(t,e,n){return Math.min(Math.max(t,e),n)}function G(t,e,n,i,r,o){const s=r-n,a=o-i;if(0!==s||0!==a){const l=((t-n)*s+(e-i)*a)/(s*s+a*a);l>1?(n=r,i=o):l>0&&(n+=s*l,i+=a*l)}return j(t,e,n,i)}function j(t,e,n,i){const r=n-t,o=i-e;return r*r+o*o}function V(t){return 180*t/Math.PI}function N(t){return t*Math.PI/180}function W(t,e){const n=t%e;return n*e<0?n+e:n}function B(t,e,n){return t+n*(e-t)}function X(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}function Y(t,e,n){if(t>=e&&t<n)return t;const i=n-e;return((t-e)%i+i)%i+e}function z(t,e){const n=t[0],i=t[1],r=e[0],o=e[1],s=r[0],a=r[1],l=o[0],h=o[1],c=l-s,u=h-a,d=0===c&&0===u?0:(c*(n-s)+u*(i-a))/(c*c+u*u||0);let f,g;return d<=0?(f=s,g=a):d>=1?(f=l,g=h):(f=s+d*c,g=a+d*u),[f,g]}function U(t,e){let n=!0;for(let i=t.length-1;i>=0;--i)if(t[i]!=e[i]){n=!1;break}return n}function H(t,e){const n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function q(t,e){return Math.sqrt(H(t,e))}const $="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"",Z=($.includes("safari")&&!$.includes("chrom")&&($.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test($)),$.includes("webkit")&&$.includes("edge"),$.includes("macintosh"),"undefined"!=typeof devicePixelRatio&&devicePixelRatio,"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope),K="undefined"!=typeof Image&&Image.prototype.decode;function J(t,e,n,i){let r;return r=n&&n.length?n.shift():Z?new class extends OffscreenCanvas{style={}}(t??300,e??150):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("2d",i)}let Q;function tt(){return Q||(Q=J(1,1)),Q}!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}}();const et=2;let nt=1;const it={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937},rt=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||it[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_}},ot=6378137,st=Math.PI*ot,at=[-st,-st,st,st],lt=[-180,-85,180,85],ht=ot*Math.log(Math.tan(Math.PI/2));class ct extends rt{constructor(t){super({code:t,units:"m",extent:at,global:!0,worldExtent:lt,getPointResolution:function(t,e){return t/Math.cosh(e[1]/ot)}})}}const ut=[new ct("EPSG:3857"),new ct("EPSG:102100"),new ct("EPSG:102113"),new ct("EPSG:900913"),new ct("http://www.opengis.net/def/crs/EPSG/0/3857"),new ct("http://www.opengis.net/gml/srs/epsg.xml#3857")];const dt=[-180,-90,180,90],ft=6378137*Math.PI/180;class gt extends rt{constructor(t,e){super({code:t,units:"degrees",extent:dt,axisOrientation:e,global:!0,metersPerUnit:ft,worldExtent:dt})}}const pt=[new gt("CRS:84"),new gt("EPSG:4326","neu"),new gt("urn:ogc:def:crs:OGC:1.3:CRS84"),new gt("urn:ogc:def:crs:OGC:2:84"),new gt("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new gt("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new gt("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let mt={},yt={};function _t(t,e,n){const i=t.getCode(),r=e.getCode();i in yt||(yt[i]={}),yt[i][r]=n}function vt(t,e){return t in yt&&e in yt[t]?yt[t][e]:null}const xt=.9996,St=.00669438,wt=St*St,Ct=wt*St,bt=St/(1-St),It=Math.sqrt(1-St),Et=(1-It)/(1+It),Pt=Et*Et,Tt=Pt*Et,Mt=Tt*Et,kt=Mt*Et,Rt=.9983242984503243,Ft=15*wt/256+45*Ct/1024,Ot=35*Ct/3072,At=1.5*Et-27/32*Tt+269/512*kt,Lt=21/16*Pt-55/32*Mt,Dt=151/96*Tt-417/128*kt,Gt=1097/512*Mt,jt=6378137;function Vt(t,e,n){const i=t-5e5,r=(n.north?e:e-1e7)/xt/(jt*Rt),o=r+At*Math.sin(2*r)+Lt*Math.sin(4*r)+Dt*Math.sin(6*r)+Gt*Math.sin(8*r),s=Math.sin(o),a=s*s,l=Math.cos(o),h=s/l,c=h*h,u=c*c,d=1-St*a,f=Math.sqrt(1-St*a),g=bt*l**2,p=g*g,m=i/(jt/f*xt),y=m*m,_=y*m,v=_*m,x=v*m,S=o-h/((1-St)/d)*(y/2-v/24*(5+3*c+10*g-4*p-9*bt))+x*m/720*(61+90*c+298*g+45*u-252*bt-3*p);let w=(m-_/6*(1+2*c+g)+x/120*(5-2*g+28*c-3*p+8*bt+24*u))/l;return w=Y(w+N(Wt(n.number)),-Math.PI,Math.PI),[V(w),V(S)]}function Nt(t,e,n){t=Y(t,-180,180),e<-80?e=-80:e>84&&(e=84);const i=N(e),r=Math.sin(i),o=Math.cos(i),s=r/o,a=s*s,l=a*a,h=N(t),c=N(Wt(n.number)),u=jt/Math.sqrt(1-St*r**2),d=bt*o**2,f=o*Y(h-c,-Math.PI,Math.PI),g=f*f,p=g*f,m=p*f,y=m*f,_=y*f,v=jt*(Rt*i-.002514607064228144*Math.sin(2*i)+Ft*Math.sin(4*i)-Ot*Math.sin(6*i)),x=xt*u*(f+p/6*(1-a+d)+y/120*(5-18*a+l+72*d-58*bt))+5e5;let S=xt*(v+u*s*(g/2+m/24*(5-a+9*d+4*d**2)+_/720*(61-58*a+l+600*d-330*bt)));return n.north||(S+=1e7),[x,S]}function Wt(t){return 6*(t-1)-180+3}const Bt=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Xt(t){let e=0;for(const n of Bt){const i=t.match(n);if(i){e=parseInt(i[1]);break}}if(!e)return null;let n=0,i=!1;return e>32700&&e<32761?n=e-32700:e>32600&&e<32661&&(i=!0,n=e-32600),n?{number:n,north:i}:null}function Yt(t,e){return function(n,i,r,o){const s=n.length;r=r>1?r:2,o=o??r,i||(i=r>2?n.slice():new Array(s));for(let r=0;r<s;r+=o){const o=n[r],s=n[r+1],a=t(o,s,e);i[r]=a[0],i[r+1]=a[1]}return i}}const zt=[function(t){const e=Xt(t.getCode());return e?{forward:Yt(Nt,e),inverse:Yt(Vt,e)}:null}],Ut=[function(t){return Xt(t)?new rt({code:t,units:"m"}):null}];let Ht=!0;function qt(t,e){if(void 0!==e)for(let n=0,i=t.length;n<i;++n)e[n]=t[n];else e=t.slice();return e}function $t(t){!function(t,e){mt[t]=e}(t.getCode(),t),_t(t,t,qt)}function Zt(t){if("string"!=typeof t)return t;const e=mt[n=t]||mt[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null;var n;if(e)return e;for(const e of Ut){const n=e(t);if(n)return n}return null}function Kt(t){!function(t){t.forEach($t)}(t),t.forEach(function(e){t.forEach(function(t){e!==t&&_t(e,t,qt)})})}function Jt(t,e){return t?"string"==typeof t?Zt(t):t:Zt(e)}function Qt(t,e){const n=t.getCode(),i=e.getCode();let r=vt(n,i);if(r)return r;let o=null,s=null;for(const n of zt)o||(o=n(t)),s||(s=n(e));if(!o&&!s)return null;const a="EPSG:4326";if(s)if(o)r=te(o.inverse,s.forward);else{const t=vt(n,a);t&&(r=te(t,s.forward))}else{const t=vt(a,i);t&&(r=te(o.inverse,t))}return r&&($t(t),$t(e),_t(t,e,r)),r}function te(t,e){return function(n,i,r,o){return i=t(n,i,r,o),e(i,i,r,o)}}function ee(t,e){return Qt(Zt(t),Zt(e))}function ne(t,e,n){const i=ee(e,n);if(!i){const t=Zt(e).getCode(),i=Zt(n).getCode();throw new Error(`No transform available between ${t} and ${i}`)}return i(t,void 0,t.length)}let ie=null;function re(){return ie}function oe(t,e){return t}function se(t,e){return Ht&&!U(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(Ht=!1,function(...t){nt>et||console.warn(...t)}("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t}function ae(t,e){return t}function le(t,e){return t}function he(t,e){return t}var ce,ue,de;Kt(ut),Kt(pt),ce=ut,ue=function(t,e,n,i){const r=t.length;n=n>1?n:2,i=i??n,void 0===e&&(e=n>2?t.slice():new Array(r));for(let n=0;n<r;n+=i){e[n]=st*t[n]/180;let i=ot*Math.log(Math.tan(Math.PI*(+t[n+1]+90)/360));i>ht?i=ht:i<-ht&&(i=-ht),e[n+1]=i}return e},de=function(t,e,n,i){const r=t.length;n=n>1?n:2,i=i??n,void 0===e&&(e=n>2?t.slice():new Array(r));for(let n=0;n<r;n+=i)e[n]=180*t[n]/st,e[n+1]=360*Math.atan(Math.exp(t[n+1]/ot))/Math.PI-90;return e},pt.forEach(function(t){ce.forEach(function(e){_t(t,e,ue),_t(e,t,de)})});const fe="prerender",ge="postrender",pe=[NaN,NaN,NaN,0];let me;const ye=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,_e=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,ve=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,xe=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Se(t,e){return t.endsWith("%")?Number(t.substring(0,t.length-1))/e:Number(t)}function we(t){throw new Error('failed to parse "'+t+'" as color')}function Ce(t){if(t.toLowerCase().startsWith("rgb")){const e=t.match(_e)||t.match(ye)||t.match(ve);if(e){const t=e[4],n=100/255;return[D(Se(e[1],n)+.5|0,0,255),D(Se(e[2],n)+.5|0,0,255),D(Se(e[3],n)+.5|0,0,255),void 0!==t?D(Se(t,100),0,1):1]}we(t)}if(t.startsWith("#")){if(xe.test(t)){const e=t.substring(1),n=e.length<=4?1:2,i=[0,0,0,255];for(let t=0,r=e.length;t<r;t+=n){let r=parseInt(e.substring(t,t+n),16);1===n&&(r+=r<<4),i[t/n]=r}return i[3]=i[3]/255,i}we(t)}const e=(me||(me=J(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),me);e.fillStyle="#abcdef";let n=e.fillStyle;e.fillStyle=t,e.fillStyle===n&&(e.fillStyle="#fedcba",n=e.fillStyle,e.fillStyle=t,e.fillStyle===n&&we(t));const i=e.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return Ce(i);e.clearRect(0,0,1,1),e.fillRect(0,0,1,1);const r=Array.from(e.getImageData(0,0,1,1).data);return r[3]=X(r[3]/255,3),r}const be={};let Ie=0;function Ee(t){if(4===t.length)return t;const e=t.slice();return e[3]=1,e}function Pe(t){return t>.0031308?269.025*Math.pow(t,1/2.4)-14.025:3294.6*t}function Te(t){return t>.2068965?Math.pow(t,3):108/841*(t-4/29)}function Me(t){return t>10.314724?Math.pow((t+14.025)/269.025,2.4):t/3294.6}function ke(t){return t>.0088564?Math.pow(t,1/3):t/(108/841)+4/29}function Re(t){const e=Me(t[0]),n=Me(t[1]),i=Me(t[2]),r=ke(.222488403*e+.716873169*n+.06060791*i),o=500*(ke(.452247074*e+.399439023*n+.148375274*i)-r),s=200*(r-ke(.016863605*e+.117638439*n+.865350722*i)),a=Math.atan2(s,o)*(180/Math.PI);return[116*r-16,Math.sqrt(o*o+s*s),a<0?a+360:a,t[3]]}function Fe(t){if("none"===t)return pe;if(be.hasOwnProperty(t))return be[t];if(Ie>=1024){let t=0;for(const e in be)3&t++||(delete be[e],--Ie)}const e=Ce(t);4!==e.length&&we(t);for(const n of e)isNaN(n)&&we(t);return be[t]=e,++Ie,e}function Oe(t){return Array.isArray(t)?t:Fe(t)}function Ae(t){let e=t[0];e!=(0|e)&&(e=e+.5|0);let n=t[1];n!=(0|n)&&(n=n+.5|0);let i=t[2];return i!=(0|i)&&(i=i+.5|0),"rgba("+e+","+n+","+i+","+(void 0===t[3]?1:Math.round(1e3*t[3])/1e3)+")"}const Le="change",De=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function Ge(){return!0}function je(){return!1}function Ve(){}function Ne(t){let e,n,i;return function(){const r=Array.prototype.slice.call(arguments);return n&&this===i&&l(r,n)||(i=this,n=r,e=t.apply(this,arguments)),e}}function We(t){for(const e in t)delete t[e]}function Be(t){let e;for(e in t)return!1;return!e}const Xe=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},Ye=class extends De{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const n=this.listeners_||(this.listeners_={}),i=n[t]||(n[t]=[]);i.includes(e)||i.push(e)}dispatchEvent(t){const e="string"==typeof t,n=e?t:t.type,i=this.listeners_&&this.listeners_[n];if(!i)return;const r=e?new Xe(t):t;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),s=this.pendingRemovals_||(this.pendingRemovals_={});let a;n in o||(o[n]=0,s[n]=0),++o[n];for(let t=0,e=i.length;t<e;++t)if(a="handleEvent"in i[t]?i[t].handleEvent(r):i[t].call(this,r),!1===a||r.propagationStopped){a=!1;break}if(0===--o[n]){let t=s[n];for(delete s[n];t--;)this.removeEventListener(n,Ve);delete o[n]}return a}disposeInternal(){this.listeners_&&We(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)}removeEventListener(t,e){if(!this.listeners_)return;const n=this.listeners_[t];if(!n)return;const i=n.indexOf(e);-1!==i&&(this.pendingRemovals_&&t in this.pendingRemovals_?(n[i]=Ve,++this.pendingRemovals_[t]):(n.splice(i,1),0===n.length&&delete this.listeners_[t]))}};function ze(t,e){return t+":"+(e?Oe(e):"null")}const Ue=new class{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 n=this.cache_[e];3&t++||n.hasListener()||(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){const n=ze(t,e);return n in this.cache_?this.cache_[n]:null}getPattern(t,e){const n=ze(t,e);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,n,i){const r=ze(t,e),o=r in this.cache_;this.cache_[r]=n,i&&(0===n.getImageState()&&n.load(),1===n.getImageState()?n.ready().then(()=>{this.patternCache_[r]=tt().createPattern(n.getImage(1),"repeat")}):this.patternCache_[r]=tt().createPattern(n.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};let He=null;class qe extends Ye{constructor(t,e,n,i,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=n?.crossOrigin,this.referrerPolicy_=n?.referrerPolicy,this.canvas_={},this.color_=r,this.imageState_=void 0===i?0:i,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(void 0===this.tainted_&&2===this.imageState_){He||(He=J(1,1,void 0,{willReadFrequently:!0})),He.drawImage(this.image_,0,0);try{He.getImageData(0,0,1,1),this.tainted_=!1}catch{He=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(Le)}handleImageError_(){this.imageState_=3,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=2,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_}setImage(t){this.image_=t}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],n=J(t,e);n.fillRect(0,0,t,e),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(0===this.imageState_){this.image_||this.initializeImage_(),this.imageState_=1;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&(t=this.image_,e=this.src_,e&&(t.src=e),t.src&&K?new Promise((e,n)=>t.decode().then(()=>e(t)).catch(i=>t.complete&&t.width?e(t):n(i))):function(t){return new Promise((e,n)=>{function i(){o(),e(t)}function r(){o(),n(new Error("Image load error"))}function o(){t.removeEventListener("load",i),t.removeEventListener("error",r)}t.addEventListener("load",i),t.addEventListener("error",r)})}(t)).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}var t,e}replaceColor_(t){if(!this.color_||this.canvas_[t]||2!==this.imageState_)return;const e=this.image_,n=J(Math.ceil(e.width*t),Math.ceil(e.height*t)),i=n.canvas;var r;n.scale(t,t),n.drawImage(e,0,0),n.globalCompositeOperation="multiply",n.fillStyle="string"==typeof(r=this.color_)?r:Ae(r),n.fillRect(0,0,i.width/t,i.height/t),n.globalCompositeOperation="destination-in",n.drawImage(e,0,0),this.canvas_[t]=i}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(2===this.imageState_||3===this.imageState_)t();else{const e=()=>{2!==this.imageState_&&3!==this.imageState_||(this.removeEventListener(Le,e),t())};this.addEventListener(Le,e)}})),this.ready_}}function $e(t,e,n,i,r,o){let s=void 0===e?void 0:Ue.get(e,r);return s||(s=new qe(t,t&&"src"in t?t.src||void 0:e,n,i,r),Ue.set(e,r,s,o)),o&&s&&!Ue.getPattern(e,r)&&Ue.set(e,r,s,o),s}const Ze=qe;function Ke(t){return t?Array.isArray(t)?Ae(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return Ue.getPattern(t.src,t.color);const e=t.src+":"+t.offset,n=Ue.getPattern(e,t.color);if(n)return n;const i=Ue.get(t.src,null);if(2!==i.getImageState())return null;const r=J(t.size[0],t.size[1]);return r.drawImage(i.getImage(1),t.offset[0],t.offset[1],t.size[0],t.size[1],0,0,t.size[0],t.size[1]),$e(r.canvas,e,void 0,2,t.color,!0),Ue.getPattern(e,t.color)}(t):t:null}function Je(t,e,n,i,r){r=void 0!==r?r:[];let o=0;for(let s=e;s<n;s+=i)r[o++]=t.slice(s,s+i);return r.length=o,r}function Qe(t,e,n,i,r){r=void 0!==r?r:[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=n[s];r[o++]=Je(t,e,a,i,r[o]),e=a}return r.length=o,r}function tn(t,e,n,i,r){r=void 0!==r?r:[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=n[s];r[o++]=1===a.length&&a[0]===e?[]:Qe(t,e,a,i,r[o]),e=a[a.length-1]}return r.length=o,r}const en=class{drawCustom(t,e,n,i,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,n){}drawFeature(t,e,n){}drawGeometryCollection(t,e,n){}drawLineString(t,e,n){}drawMultiLineString(t,e,n){}drawMultiPoint(t,e,n){}drawMultiPolygon(t,e,n){}drawPoint(t,e,n){}drawPolygon(t,e,n){}drawText(t,e,n){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}},nn="propertychange";function rn(t,e,n,i,r){if(r){const r=n;n=function(o){return t.removeEventListener(e,n),r.call(i??this,o)}}else i&&i!==t&&(n=n.bind(i));const o={target:t,type:e,listener:n};return t.addEventListener(e,n),o}function on(t,e,n,i){return rn(t,e,n,i,!0)}function sn(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),We(t))}class an extends Ye{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(Le)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const n=t.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=rn(this,t[r],e);return i}return rn(this,t,e)}onceInternal(t,e){let n;if(Array.isArray(t)){const i=t.length;n=new Array(i);for(let r=0;r<i;++r)n[r]=on(this,t[r],e)}else n=on(this,t,e);return e.ol_key=n,n}unInternal(t,e){const n=e.ol_key;if(n)!function(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;++e)sn(t[e]);else sn(t)}(n);else if(Array.isArray(t))for(let n=0,i=t.length;n<i;++n)this.removeEventListener(t[n],e);else this.removeEventListener(t,e)}}an.prototype.on,an.prototype.once,an.prototype.un;const ln=an;function hn(){throw new Error("Unimplemented abstract method.")}let cn=0;function un(t){return t.ol_uid||(t.ol_uid=String(++cn))}class dn extends Xe{constructor(t,e,n){super(t),this.key=e,this.oldValue=n}}const fn=class extends ln{constructor(t){super(),this.on,this.once,this.un,un(this),this.values_=null,void 0!==t&&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 n;n=`change:${t}`,this.hasListener(n)&&this.dispatchEvent(new dn(n,t,e)),n=nn,this.hasListener(n)&&this.dispatchEvent(new dn(n,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,n){const i=this.values_||(this.values_={});if(n)i[t]=e;else{const n=i[t];i[t]=e,n!==e&&this.notify(t,n)}}setProperties(t,e){for(const n in t)this.set(n,t[n],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const n=this.values_[t];delete this.values_[t],Be(this.values_)&&(this.values_=null),e||this.notify(t,n)}}},gn=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"),pn=["style","variant","weight","size","lineHeight","family"],mn={normal:400,bold:700},yn=function(t){const e=t.match(gn);if(!e)return null;const n={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let t=0,i=pn.length;t<i;++t){const i=e[t+1];void 0!==i&&(n[pn[t]]="string"==typeof i?i.trim():i)}return isNaN(Number(n.weight))&&n.weight in mn&&(n.weight=mn[n.weight]),n.families=n.family.split(/,\s?/).map(t=>t.trim().replace(/^['"]|['"]$/g,"")),n},_n="10px sans-serif",vn="#000",xn="round",Sn=[],wn="round",Cn="#000",bn="center",In="middle",En=[0,0,0,0],Pn=new fn;let Tn,Mn=null;const kn={},Rn=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function Fn(t,e,n){return`${t} ${e} 16px "${n}"`}const On=function(){const t=100;let e,n;async function i(t){await n.ready;const e=await n.load(t);if(0===e.length)return!1;const i=yn(t),r=i.families[0].toLowerCase(),o=i.weight;return e.some(t=>{const e=t.family.replace(/^['"]|['"]$/g,"").toLowerCase(),n=mn[t.weight]||t.weight;return e===r&&t.style===i.style&&n==o})}async function r(){await n.ready;let o=!0;const s=Pn.getProperties(),a=Object.keys(s).filter(e=>s[e]<t);for(let e=a.length-1;e>=0;--e){const n=a[e];let r=s[n];r<t&&(await i(n)?(We(kn),Pn.set(n,t)):(r+=10,Pn.set(n,r,!0),r<t&&(o=!1)))}e=void 0,o||(e=setTimeout(r,100))}return async function(t){n||(n=Z?self.fonts:document.fonts);const i=yn(t);if(!i)return;const o=i.families;let s=!1;for(const t of o){if(Rn.has(t))continue;const e=Fn(i.style,i.weight,t);void 0===Pn.get(e)&&(Pn.set(e,0,!0),s=!0)}s&&(clearTimeout(e),e=setTimeout(r,100))}}(),An=function(){let t;return function(e){let n=kn[e];if(null==n){if(Z){const t=yn(e),i=Ln(e,"Žg");n=(isNaN(Number(t.lineHeight))?1.2:Number(t.lineHeight))*(i.actualBoundingBoxAscent+i.actualBoundingBoxDescent)}else t||(t=document.createElement("div"),t.innerHTML="M",t.style.minHeight="0",t.style.maxHeight="none",t.style.height="auto",t.style.padding="0",t.style.border="none",t.style.position="absolute",t.style.display="block",t.style.left="-99999px"),t.style.font=e,document.body.appendChild(t),n=t.offsetHeight,document.body.removeChild(t);kn[e]=n}return n}}();function Ln(t,e){return Mn||(Mn=J(1,1)),t!=Tn&&(Mn.font=t,Tn=Mn.font),Mn.measureText(e)}function Dn(t,e){return Ln(t,e).width}function Gn(t,e,n){if(e in n)return n[e];const i=e.split("\n").reduce((e,n)=>Math.max(e,Dn(t,n)),0);return n[e]=i,i}const jn={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},Vn=[jn.FILL],Nn=[jn.STROKE],Wn=[jn.BEGIN_PATH],Bn=[jn.CLOSE_PATH],Xn=jn,Yn=class extends en{constructor(t,e,n,i){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=i,this.maxLineWidth=0,this.resolution=n,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 1==e?t:t.map(function(t){return t*e})}appendFlatPointCoordinates(t,e){const n=this.getBufferedMaxExtent(),i=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let s=0,a=t.length;s<a;s+=e)i[0]=t[s],i[1]=t[s+1],d(n,i)&&(r[o++]=i[0],r[o++]=i[1]);return o}appendFlatLineCoordinates(t,e,n,i,r,o){const s=this.coordinates;let a=s.length;const l=this.getBufferedMaxExtent();o&&(e+=i);let h=t[e],c=t[e+1];const u=this.tmpCoordinate_;let d,f,g,m=!0;for(d=e+i;d<n;d+=i)u[0]=t[d],u[1]=t[d+1],g=p(l,u),g!==f?(m&&(s[a++]=h,s[a++]=c,m=!1),s[a++]=u[0],s[a++]=u[1]):1===g?(s[a++]=u[0],s[a++]=u[1],m=!1):m=!0,h=u[0],c=u[1],f=g;return(r&&m||d===e+i)&&(s[a++]=h,s[a++]=c),a}drawCustomCoordinates_(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o],a=this.appendFlatLineCoordinates(t,e,s,i,!1,!1);r.push(a),e=s}return e}drawCustom(t,e,n,i,r){this.beginGeometry(t,e,r);const o=t.getType(),s=t.getStride(),a=this.coordinates.length;let l,h,c,u,d;switch(o){case"MultiPolygon":l=t.getOrientedFlatCoordinates(),u=[];const e=t.getEndss();d=0;for(let t=0,n=e.length;t<n;++t){const n=[];d=this.drawCustomCoordinates_(l,d,e[t],s,n),u.push(n)}this.instructions.push([Xn.CUSTOM,a,u,t,n,tn,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,u,t,i||n,tn,r]);break;case"Polygon":case"MultiLineString":c=[],l="Polygon"==o?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),d=this.drawCustomCoordinates_(l,0,t.getEnds(),s,c),this.instructions.push([Xn.CUSTOM,a,c,t,n,Qe,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,c,t,i||n,Qe,r]);break;case"LineString":case"Circle":l=t.getFlatCoordinates(),h=this.appendFlatLineCoordinates(l,0,l.length,s,!1,!1),this.instructions.push([Xn.CUSTOM,a,h,t,n,Je,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,h,t,i||n,Je,r]);break;case"MultiPoint":l=t.getFlatCoordinates(),h=this.appendFlatPointCoordinates(l,s),h>a&&(this.instructions.push([Xn.CUSTOM,a,h,t,n,Je,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,h,t,i||n,Je,r]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),h=this.coordinates.length,this.instructions.push([Xn.CUSTOM,a,h,t,n,void 0,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,h,t,i||n,void 0,r])}this.endGeometry(e)}beginGeometry(t,e,n){this.beginGeometryInstruction1_=[Xn.BEGIN_GEOMETRY,e,0,t,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[Xn.BEGIN_GEOMETRY,e,0,t,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;let e;t.reverse();const n=t.length;let i,r,o=-1;for(e=0;e<n;++e)i=t[e],r=i[0],r==Xn.END_GEOMETRY?o=e:r==Xn.BEGIN_GEOMETRY&&(i[2]=e,s(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const n=t.getColor();e.fillPatternScale=n&&"object"==typeof n&&"src"in n?this.pixelRatio:1,e.fillStyle=Ke(n||vn)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const n=t.getColor();e.strokeStyle=Ke(n||Cn);const i=t.getLineCap();e.lineCap=void 0!==i?i:xn;const r=t.getLineDash();e.lineDash=r?r.slice():Sn;const o=t.getLineDashOffset();e.lineDashOffset=o||0;const s=t.getLineJoin();e.lineJoin=void 0!==s?s:wn;const a=t.getWidth();e.lineWidth=void 0!==a?a:1;const l=t.getMiterLimit();e.miterLimit=void 0!==l?l:10;const h=t.getOffset();e.strokeOffset=h??0,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,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){const n=this.state;this.fillStyleToState(t,n),this.strokeStyleToState(e,n)}createFill(t){const e=t.fillStyle,n=[Xn.SET_FILL_STYLE,e];return"string"!=typeof e&&n.push(t.fillPatternScale),n}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[Xn.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 n=t.fillStyle;(void 0!==n&&"string"!=typeof n||t.currentFillStyle!=n)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=n)}updateStrokeStyle(t,e){const n=t.strokeStyle,i=t.lineCap,r=t.lineDash,o=t.lineDashOffset,s=t.lineJoin,a=t.lineWidth,h=t.miterLimit,c=t.strokeOffset;(t.currentStrokeStyle!=n||t.currentLineCap!=i||r!=t.currentLineDash&&!l(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=s||t.currentLineWidth!=a||t.currentMiterLimit!=h||t.currentStrokeOffset!=c)&&(e.call(this,t),t.currentStrokeStyle=n,t.currentLineCap=i,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=s,t.currentLineWidth=a,t.currentMiterLimit=h,t.currentStrokeOffset=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[Xn.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=this.maxExtent.slice(),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;c(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}};function zn(t,e,n,i,r,o,s){const a=(n-e)/i;if(a<3){for(;e<n;e+=i)o[s++]=t[e],o[s++]=t[e+1];return s}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[e,n-i];let c=0;for(;h.length>0;){const n=h.pop(),o=h.pop();let s=0;const a=t[o],u=t[o+1],d=t[n],f=t[n+1];for(let e=o+i;e<n;e+=i){const n=G(t[e],t[e+1],a,u,d,f);n>s&&(c=e,s=n)}s>r&&(l[(c-e)/i]=1,o+i<c&&h.push(o,c),c+i<n&&h.push(c,n))}for(let n=0;n<a;++n)l[n]&&(o[s++]=t[e+n*i],o[s++]=t[e+n*i+1]);return s}function Un(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];s=zn(t,e,h,i,r,o,s),a.push(s),e=h}return s}function Hn(t,e){return e*Math.round(t/e)}function qn(t,e,n,i,r,o,s){if(e==n)return s;let a,l,h=Hn(t[e],r),c=Hn(t[e+1],r);e+=i,o[s++]=h,o[s++]=c;do{if(a=Hn(t[e],r),l=Hn(t[e+1],r),(e+=i)==n)return o[s++]=a,o[s++]=l,s}while(a==h&&l==c);for(;e<n;){const n=Hn(t[e],r),u=Hn(t[e+1],r);if(e+=i,n==a&&u==l)continue;const d=a-h,f=l-c,g=n-h,p=u-c;d*p==f*g&&(d<0&&g<d||d==g||d>0&&g>d)&&(f<0&&p<f||f==p||f>0&&p>f)?(a=n,l=u):(o[s++]=a,o[s++]=l,h=a,c=l,a=n,l=u)}return o[s++]=a,o[s++]=l,s}function $n(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];s=qn(t,e,h,i,r,o,s),a.push(s),e=h}return s}const Zn=class extends Yn{constructor(t,e,n,i){super(t,e,n,i)}drawFlatCoordinatess_(t,e,n,i,r){const o=this.state,s=void 0!==o.fillStyle,a=void 0!==o.strokeStyle,l=n.length;this.instructions.push(Wn),this.hitDetectionInstructions.push(Wn);for(let o=0;o<l;++o){const s=n[o],l=this.coordinates.length,h=this.appendFlatLineCoordinates(t,e,s,i,!0,!a);this.instructions.push([Xn.MOVE_TO_LINE_TO,l,h,r*this.pixelRatio,!0]),this.hitDetectionInstructions.push([Xn.MOVE_TO_LINE_TO,l,h,r,!0]),a&&(this.instructions.push(Bn),this.hitDetectionInstructions.push(Bn)),e=s}return s&&(this.instructions.push(Vn),this.hitDetectionInstructions.push(Vn)),a&&(this.instructions.push(Nn),this.hitDetectionInstructions.push(Nn)),e}drawCircle(t,e,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle,s=i.strokeOffset;if(void 0===r&&void 0===o)return;if(this.handleStrokeOffset_(()=>this.drawCircle(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([Xn.SET_FILL_STYLE,vn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[Xn.CIRCLE,h,s];this.instructions.push(Wn,c),this.hitDetectionInstructions.push(Wn,c),void 0!==i.fillStyle&&(this.instructions.push(Vn),this.hitDetectionInstructions.push(Vn)),void 0!==i.strokeStyle&&(this.instructions.push(Nn),this.hitDetectionInstructions.push(Nn)),this.endGeometry(e)}drawPolygon(t,e,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle,s=i.strokeOffset;if(void 0===r&&void 0===o)return;if(this.handleStrokeOffset_(()=>this.drawPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([Xn.SET_FILL_STYLE,vn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),h=t.getStride();this.drawFlatCoordinatess_(l,0,a,h,s),this.endGeometry(e)}drawMultiPolygon(t,e,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle,s=i.strokeOffset;if(void 0===r&&void 0===o)return;if(this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([Xn.SET_FILL_STYLE,vn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),h=t.getStride();let c=0;for(let t=0,e=a.length;t<e;++t)c=this.drawFlatCoordinatess_(l,c,a[t],h,s);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(0!==t){const e=this.coordinates;for(let n=0,i=e.length;n<i;++n)e[n]=Hn(e[n],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}handleStrokeOffset_(t){const e=this.state,n=e.fillStyle,i=e.strokeStyle,r=e.strokeOffset;return Math.abs(r)>0&&void 0!==n&&void 0!==i&&(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=i,e.strokeOffset=r,t(),e.fillStyle=n,!0)}};function Kn(t,e,n,i,r){const o=[];let s=n,a=0,l=e.slice(n,2);for(;a<t&&s+r<i;){const[n,i]=l.slice(-2),h=e[s+r],c=e[s+r+1],u=Math.sqrt((h-n)*(h-n)+(c-i)*(c-i));if(a+=u,a>=t){const e=(t-a+u)/u,d=B(n,h,e),f=B(i,c,e);l.push(d,f),o.push(l),l=[d,f],a==t&&(s+=r),a=0}else if(a<t)l.push(e[s+r],e[s+r+1]),s+=r;else{const t=u-a,e=B(n,h,t/u),d=B(i,c,t/u);l.push(e,d),o.push(l),l=[e,d],a=0,s+=r}}return a>0&&o.push(l),o}function Jn(t,e,n,i,r){let o,s,a,l,h,c,u,d,f,g,p=n,m=n,y=0,_=0,v=n;for(s=n;s<i;s+=r){const n=e[s],i=e[s+1];void 0!==h&&(f=n-h,g=i-c,l=Math.sqrt(f*f+g*g),void 0!==u&&(_+=a,o=Math.acos((u*f+d*g)/(a*l)),o>t&&(_>y&&(y=_,p=v,m=s),_=0,v=s-r)),a=l,u=f,d=g),h=n,c=i}return _+=l,_>y?[v,s]:[p,m]}const Qn={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},ti={Circle:Zn,Default:Yn,Image:class extends Yn{constructor(t,e,n,i){super(t,e,n,i),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,n){if(!this.image_||this.maxExtent&&!d(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,n);const i=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,s=this.appendFlatPointCoordinates(i,r);this.instructions.push([Xn.DRAW_IMAGE,o,s,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([Xn.DRAW_IMAGE,o,s,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,n){if(!this.image_)return;this.beginGeometry(t,e,n);const i=t.getFlatCoordinates(),r=[];for(let e=0,n=i.length;e<n;e+=t.getStride())this.maxExtent&&!d(this.maxExtent,i.slice(e,e+2))||r.push(i[e],i[e+1]);const o=this.coordinates.length,s=this.appendFlatPointCoordinates(r,2);this.instructions.push([Xn.DRAW_IMAGE,o,s,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([Xn.DRAW_IMAGE,o,s,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 n=t.getAnchor(),i=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=n[0],this.anchorY_=n[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=i[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_=i[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}},LineString:class extends Yn{constructor(t,e,n,i){super(t,e,n,i)}drawFlatCoordinates_(t,e,n,i,r){const o=this.coordinates.length,s=this.appendFlatLineCoordinates(t,e,n,i,!1,!1);return this.instructions.push([Xn.MOVE_TO_LINE_TO,o,s,r*this.pixelRatio]),this.hitDetectionInstructions.push([Xn.MOVE_TO_LINE_TO,o,s,r]),n}drawLineString(t,e,n){const i=this.state,r=i.strokeStyle,o=i.lineWidth,s=i.strokeOffset;if(void 0===r||void 0===o)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e,n),this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0],Wn);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l,s),this.hitDetectionInstructions.push(Nn),this.endGeometry(e)}drawMultiLineString(t,e,n){const i=this.state,r=i.strokeStyle,o=i.lineWidth,s=i.strokeOffset;if(void 0===r||void 0===o)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e,n),this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0],Wn);const a=t.getEnds(),l=t.getFlatCoordinates(),h=t.getStride();let c=0;for(let t=0,e=a.length;t<e;++t)c=this.drawFlatCoordinates_(l,c,a[t],h,s);this.hitDetectionInstructions.push(Nn),this.endGeometry(e)}finish(){const t=this.state;return null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Nn),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Nn),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(Wn)}},Polygon:Zn,Text:class extends Yn{constructor(t,e,n,i){super(t,e,n,i),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[vn]={fillStyle:vn},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,n){const i=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(""===this.text_||!o||!i&&!r)return;const s=this.coordinates;let a=s.length;const l=t.getType();let h=null,c=t.getStride();if("line"!==o.placement||"LineString"!=l&&"MultiLineString"!=l&&"Polygon"!=l&&"MultiPolygon"!=l){let i=o.overflow?null:[];switch(l){case"Point":case"MultiPoint":h=t.getFlatCoordinates();break;case"LineString":h=t.getFlatMidpoint();break;case"Circle":h=t.getCenter();break;case"MultiLineString":h=t.getFlatMidpoints(),c=2;break;case"Polygon":h=t.getFlatInteriorPoint(),o.overflow||i.push(h[2]/this.resolution),c=3;break;case"MultiPolygon":const e=t.getFlatInteriorPoints();h=[];for(let t=0,n=e.length;t<n;t+=3)o.overflow||i.push(e[t+2]/this.resolution),h.push(e[t],e[t+1]);if(0===h.length)return;c=2}const r=this.appendFlatPointCoordinates(h,c);if(r===a)return;if(i&&(r-a)/2!==h.length/c){let t=a/2;i=i.filter((e,n)=>{const i=s[2*(t+n)]===h[n*c]&&s[2*(t+n)+1]===h[n*c+1];return i||--t,i})}this.saveTextStates_();const u=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,d=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,n);let f=o.padding;if(f!=En&&(o.scale[0]<0||o.scale[1]<0)){let t=o.padding[0],e=o.padding[1],n=o.padding[2],i=o.padding[3];o.scale[0]<0&&(e=-e,i=-i),o.scale[1]<0&&(t=-t,n=-n),f=[t,e,n,i]}const g=this.pixelRatio;this.instructions.push([Xn.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,f==En?En:f.map(function(t){return t*g}),u,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]);const p=1/g,m=u?u.slice(0):null;m&&(m[1]=vn),this.hitDetectionInstructions.push([Xn.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,this.declutterMode_,this.declutterImageWithText_,f,m,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?vn:this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]),this.endGeometry(e)}else{if(!O(this.maxExtent,t.getExtent()))return;let i;if(h=t.getFlatCoordinates(),"LineString"==l)i=[h.length];else if("MultiLineString"==l)i=t.getEnds();else if("Polygon"==l)i=t.getEnds().slice(0,1);else if("MultiPolygon"==l){const e=t.getEndss();i=[];for(let t=0,n=e.length;t<n;++t)i.push(e[t][0])}this.beginGeometry(t,e,n);const r=o.repeat,u=r?void 0:o.textAlign;let d=0;for(let t=0,e=i.length;t<e;++t){let e;e=r?Kn(r*this.resolution,h,d,i[t],c):[h.slice(d,i[t])];for(let n=0,r=e.length;n<r;++n){const r=e[n];let l=0,h=r.length;if(null==u){const t=Jn(o.maxAngle,r,0,r.length,2);l=t[0],h=t[1]}for(let t=l;t<h;t+=c)s.push(r[t],r[t+1]);const f=s.length;d=i[t],this.drawChars_(a,f),a=f}}this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,n=this.textFillState_,i=this.strokeKey_;t&&(i in this.strokeStates||(this.strokeStates[i]={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||bn,justify:e.justify,textBaseline:e.textBaseline||In,scale:e.scale});const o=this.fillKey_;n&&(o in this.fillStates||(this.fillStates[o]={fillStyle:n.fillStyle}))}drawChars_(t,e){const n=this.textStrokeState_,i=this.textState_,r=this.strokeKey_,o=this.textKey_,s=this.fillKey_;this.saveTextStates_();const a=this.pixelRatio,l=Qn[i.textBaseline],h=this.textOffsetY_*a,c=this.text_,u=n?n.lineWidth*Math.abs(i.scale[0])/2:0;this.instructions.push([Xn.DRAW_CHARS,t,e,l,i.overflow,s,i.maxAngle,a,h,r,u*a,c,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([Xn.DRAW_CHARS,t,e,l,i.overflow,s?vn:s,i.maxAngle,a,h,r,u*a,c,o,1/a,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let n,i,r;if(t){const e=t.getFill();e?(i=this.textFillState_,i||(i={},this.textFillState_=i),i.fillStyle=Ke(e.getColor()||vn)):(i=null,this.textFillState_=i);const o=t.getStroke();if(o){r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const t=o.getLineDash(),e=o.getLineDashOffset(),n=o.getWidth(),i=o.getMiterLimit();r.lineCap=o.getLineCap()||xn,r.lineDash=t?t.slice():Sn,r.lineDashOffset=void 0===e?0:e,r.lineJoin=o.getLineJoin()||wn,r.lineWidth=void 0===n?1:n,r.miterLimit=void 0===i?10:i,r.strokeStyle=Ke(o.getColor()||Cn)}else r=null,this.textStrokeState_=r;n=this.textState_;const s=t.getFont()||_n;On(s);const a=t.getScaleArray();n.overflow=t.getOverflow(),n.font=s,n.maxAngle=t.getMaxAngle(),n.placement=t.getPlacement(),n.textAlign=t.getTextAlign(),n.repeat=t.getRepeat(),n.justify=t.getJustify(),n.textBaseline=t.getTextBaseline()||In,n.backgroundFill=t.getBackgroundFill(),n.backgroundStroke=t.getBackgroundStroke(),n.padding=t.getPadding()||En,n.scale=void 0===a?[1,1]:a;const l=t.getOffsetX(),h=t.getOffsetY(),c=t.getRotateWithView(),u=t.getKeepUpright(),d=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=void 0===l?0:l,this.textOffsetY_=void 0===h?0:h,this.textRotateWithView_=void 0!==c&&c,this.textKeepUpright_=void 0===u||u,this.textRotation_=void 0===d?0:d,this.strokeKey_=r?("string"==typeof r.strokeStyle?r.strokeStyle:un(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=n.font+n.scale+(n.textAlign||"?")+(n.repeat||"?")+(n.justify||"?")+(n.textBaseline||"?"),this.fillKey_=i&&i.fillStyle?"string"==typeof i.fillStyle?i.fillStyle:"|"+un(i.fillStyle):""}else this.text_="";this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}},ei=class{constructor(t,e,n,i){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=i,this.resolution_=n,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const n=this.buildersByZIndex_[e];for(const i in n){const r=n[i].finish();t[e][i]=r}}return t}getBuilder(t,e){const n=void 0!==t?t.toString():"0";let i=this.buildersByZIndex_[n];void 0===i&&(i={},this.buildersByZIndex_[n]=i);let r=i[e];return void 0===r&&(r=new(0,ti[e])(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),i[e]=r),r}};function ni(t,e,n,i,r,o,s){o=o||[],s=s||2;let a=0;for(let l=e;l<n;l+=i){const e=t[l],n=t[l+1];o[a++]=r[0]*e+r[2]*n+r[4],o[a++]=r[1]*e+r[3]*n+r[5];for(let e=2;e<s;e++)o[a++]=t[l+e]}return o&&o.length!=a&&(o.length=a),o}function ii(t,e,n,i,r,o,s){s=s||[];const a=Math.cos(r),l=Math.sin(r),h=o[0],c=o[1];let u=0;for(let r=e;r<n;r+=i){const e=t[r]-h,n=t[r+1]-c;s[u++]=h+e*a-n*l,s[u++]=c+e*l+n*a;for(let e=r+2;e<r+i;++e)s[u++]=t[e]}return s&&s.length!=u&&(s.length=u),s}function ri(t,e){if(!t)throw new Error(e)}function oi(t,e){const n=e[0],i=e[1];return e[0]=t[0]*n+t[2]*i+t[4],e[1]=t[1]*n+t[3]*i+t[5],e}function si(t,e,n,i,r,o,s,a){const l=Math.sin(o),h=Math.cos(o);return t[0]=i*h,t[1]=r*l,t[2]=-i*l,t[3]=r*h,t[4]=s*i*h-a*i*l+e,t[5]=s*r*l+a*r*h+n,t}new Array(6);const ai=[1e5,1e5,1e5,1e5,2,2];function li(t){return t.substring(7,t.length-1).split(",").map(parseFloat)}function hi(t,e,n,i){let r=t[e],o=t[e+1],s=0;for(let a=e+i;a<n;a+=i){const e=t[a],n=t[a+1];s+=Math.sqrt((e-r)*(e-r)+(n-o)*(n-o)),r=e,o=n}return s}function ci(t,e,n,i,r,o,s,a){s=s??[],a=a??i;const l=t[e+i],h=t[e+i+1],c=t[n-2*i],u=t[n-2*i+1];let d,f,g,p,m,y,_,v,x=0;for(let S=e;S<n;S+=i){g=d,p=f,m=void 0,y=void 0,S+i<n&&(m=t[S+i],y=t[S+i+1]),o&&S===e&&(g=c,p=u),o&&S===n-i&&(m=l,y=h),d=t[S],f=t[S+1],[_,v]=ui(d,f,g,p,m,y,r),s[x++]=_,s[x++]=v;for(let e=2;e<a;e++)s[x++]=t[S+e]}return s.length!=x&&(s.length=x),s}function ui(t,e,n,i,r,o,s){let a,l;void 0!==n&&void 0!==i?(a=t-n,l=e-i):void 0!==r&&void 0!==o?(a=r-t,l=o-e):(a=1,l=0);const h=Math.hypot(a,l),c=a/h,u=l/h;if(a=-u,l=c,void 0===n||void 0===i)return[t+a*s,e+l*s];if(void 0===r||void 0===o)return[t+a*s,e+l*s];const d=function(t,e,n){const i=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),r=[(e[0]-t[0])/i,(e[1]-t[1])/i],o=[-r[1],r[0]],s=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),a=[(n[0]-t[0])/s,(n[1]-t[1])/s];let l=0===i||0===s?0:Math.acos(D(a[0]*r[0]+a[1]*r[1],-1,1));return l=Math.max(l,1e-5),a[0]*o[0]+a[1]*o[1]>0?l:2*Math.PI-l}([t,e],[n,i],[r,o]);if(Math.cos(d)>.998)return[t+c*s,e+u*s];const f=Math.cos(d/2),g=Math.sin(d/2);return[t+1/g*(g*a+f*l)*s,e+1/g*(-f*a+g*l)*s]}function di(t,e){for(let n=0,i=t.length-2;n<i;n+=e)for(let i=t.length-2*e;i>n+e;i-=e){const r=t[n],o=t[n+1],s=t[n+e],a=t[n+e+1],l=t[i],h=t[i+1],c=t[i+e],u=t[i+e+1],d=(u-h)*(s-r)-(c-l)*(a-o);if(0===d)continue;const f=((c-l)*(o-h)-(u-h)*(r-l))/d,g=((s-r)*(o-h)-(a-o)*(r-l))/d;if(f>0&&f<1&&g>0&&g<1){const l=r+f*(s-r),h=o+f*(a-o);t[n+e]=l,t[n+e+1]=h,t.splice(n+2*e,i-n-e);break}}return t}function fi(t,e,n,i,r,o,s,a,l,h,c,u,d=!0){let f=t[e],g=t[e+1],p=0,m=0,y=0,_=0;function v(){p=f,m=g,f=t[e+=i],g=t[e+1],_+=y,y=Math.sqrt((f-p)*(f-p)+(g-m)*(g-m))}do{v()}while(e<n-i&&_+y<o);let x=0===y?0:(o-_)/y;const S=B(p,f,x),w=B(m,g,x),C=e-i,b=_,I=o+a*l(h,r,c);for(;e<n-i&&_+y<I;)v();x=0===y?0:(I-_)/y;const E=B(p,f,x),P=B(m,g,x);let T=!1;if(d)if(u){const t=[S,w,E,P];ii(t,0,4,2,u,t,t),T=t[0]>t[2]}else T=S>E;const M=Math.PI,k=[],R=C+i===e;let F;if(y=0,_=b,f=t[e=C],g=t[e+1],R){v(),F=Math.atan2(g-m,f-p),T&&(F+=F>0?-M:M);const t=(E+S)/2,e=(P+w)/2;return k[0]=[t,e,(I-o)/2,F,r],k}for(let t=0,u=(r=r.replace(/\n/g," ")).length;t<u;){v();let d=Math.atan2(g-m,f-p);if(T&&(d+=d>0?-M:M),void 0!==F){let t=d-F;if(t+=t>M?-2*M:t<-M?2*M:0,Math.abs(t)>s)return null}F=d;const S=t;let w=0;for(;t<u;++t){const s=a*l(h,r[T?u-t-1:t],c);if(e+i<n&&_+y<o+w+s/2)break;w+=s}if(t===S)continue;const C=T?r.substring(u-S,u-t):r.substring(S,t);x=0===y?0:(o+w/2-_)/y;const b=B(p,f,x),I=B(m,g,x);k.push([b,I,w/2,d,C]),o+=w}return k}const gi=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(tt(),{get:(t,e)=>{if("function"==typeof tt()[e])return this.push_(e),this.pushMethodArgs_},set:(t,e,n)=>(this.push_(e,n),!0)})}push_(...t){const e=this.instructions_,n=this.zIndex+this.offset_;e[n]||(e[n]=[]),e[n].push(...t)}pushMethodArgs_=(...t)=>(this.push_(t),this);pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let n=0,i=e.length;n<i;++n){const i=e[n];if("function"==typeof i){i(t);continue}const r=e[++n];if("function"==typeof t[i])t[i](...r);else{if("function"==typeof r){t[i]=r(t);continue}t[i]=r}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},pi=[1/0,1/0,-1/0,-1/0],mi=[],yi=[],_i=[],vi=[];function xi(t){return t[3].declutterBox}const Si=new RegExp("["+String.fromCharCode(1425)+"-"+String.fromCharCode(2303)+String.fromCharCode(64285)+"-"+String.fromCharCode(65023)+String.fromCharCode(65136)+"-"+String.fromCharCode(65276)+String.fromCharCode(67584)+"-"+String.fromCharCode(69631)+String.fromCharCode(124928)+"-"+String.fromCharCode(126975)+"]");function wi(t,e){return"start"===e?e=Si.test(t)?"right":"left":"end"===e&&(e=Si.test(t)?"left":"right"),Qn[e]}function Ci(t,e,n){return n>0&&t.push("\n",""),t.push(e,""),t}function bi(t,e,n){return n%2==0&&(t+=e),t}const Ii=class{constructor(t,e,n,i,r){this.overlaps=n,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=i.instructions,this.coordinates=i.coordinates,this.coordinateCache_={},this.renderedTransform_=[1,0,0,1,0,0],this.hitDetectionInstructions=i.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=i.fillStates||{},this.strokeStates=i.strokeStates||{},this.textStates=i.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new gi:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,n,i){const r=t+e+n+i;if(this.labels_[r])return this.labels_[r];const o=i?this.strokeStates[i]:null,s=n?this.fillStates[n]:null,a=this.textStates[e],l=this.pixelRatio,h=[a.scale[0]*l,a.scale[1]*l],c=a.justify?Qn[a.justify]:wi(Array.isArray(t)?t[0]:t,a.textAlign||bn),u=i&&o.lineWidth?o.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(Ci,[]),{width:f,height:g,widths:p,heights:m,lineWidths:y}=function(t,e){const n=[],i=[],r=[];let o=0,s=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){const u=e[h];if("\n"===u||h===c){o=Math.max(o,s),r.push(s),s=0,a+=l,l=0;continue}const d=e[h+1]||t.font,f=Dn(d,u);n.push(f),s+=f;const g=An(d);i.push(g),l=Math.max(l,g)}return{width:o,height:a,widths:n,heights:i,lineWidths:r}}(a,d),_=f+u,v=[],x=(_+2)*h[0],S=(g+u)*h[1],w={width:x<0?Math.floor(x):Math.ceil(x),height:S<0?Math.floor(S):Math.ceil(S),contextInstructions:v};1==h[0]&&1==h[1]||v.push("scale",h),i&&(v.push("strokeStyle",o.strokeStyle),v.push("lineWidth",u),v.push("lineCap",o.lineCap),v.push("lineJoin",o.lineJoin),v.push("miterLimit",o.miterLimit),v.push("setLineDash",[o.lineDash]),v.push("lineDashOffset",o.lineDashOffset)),n&&v.push("fillStyle",s.fillStyle),v.push("textBaseline","middle"),v.push("textAlign","center");const C=.5-c;let b=c*_+C*u;const I=[],E=[];let P,T=0,M=0,k=0,R=0;for(let t=0,e=d.length;t<e;t+=2){const e=d[t];if("\n"===e){M+=T,T=0,b=c*_+C*u,++R;continue}const r=d[t+1]||a.font;r!==P&&(i&&I.push("font",r),n&&E.push("font",r),P=r),T=Math.max(T,m[k]);const o=[e,b+C*p[k]+c*(p[k]-y[R]),.5*(u+T)+M];b+=p[k],i&&I.push("strokeText",o),n&&E.push("fillText",o),++k}return Array.prototype.push.apply(v,I),Array.prototype.push.apply(v,E),this.labels_[r]=w,w}replayTextBackground_(t,e,n,i,r,o,s){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,n),t.lineTo.apply(t,i),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),s&&(this.setStrokeStyle_(t,s),t.stroke())}calculateImageOrLabelDimensions_(t,e,n,i,r,o,s,a,l,h,c,u,d,f,g,p){let y=n-(s*=u[0]),_=i-(a*=u[1]);const v=r+l>t?t-l:r,x=o+h>e?e-h:o,S=f[3]+v*u[0]+f[1],w=f[0]+x*u[1]+f[2],C=y-f[3],b=_-f[0];let I;return(g||0!==c)&&(mi[0]=C,vi[0]=C,mi[1]=b,yi[1]=b,yi[0]=C+S,_i[0]=yi[0],_i[1]=b+w,vi[1]=_i[1]),0!==c?(I=si([1,0,0,1,0,0],n,i,1,1,c,-n,-i),oi(I,mi),oi(I,yi),oi(I,_i),oi(I,vi),m(Math.min(mi[0],yi[0],_i[0],vi[0]),Math.min(mi[1],yi[1],_i[1],vi[1]),Math.max(mi[0],yi[0],_i[0],vi[0]),Math.max(mi[1],yi[1],_i[1],vi[1]),pi)):m(Math.min(C,C+S),Math.min(b,b+w),Math.max(C,C+S),Math.max(b,b+w),pi),d&&(y=Math.round(y),_=Math.round(_)),{drawImageX:y,drawImageY:_,drawImageW:v,drawImageH:x,originX:l,originY:h,declutterBox:{minX:pi[0],minY:pi[1],maxX:pi[2],maxY:pi[3],value:p},canvasTransform:I,scale:u}}replayImageOrLabel_(t,e,n,i,r,o,s){const a=!(!o&&!s),l=i.declutterBox,h=s?s[2]*i.scale[0]/2:0;return l.minX-h<=e[0]&&l.maxX+h>=0&&l.minY-h<=e[1]&&l.maxY+h>=0&&(a&&this.replayTextBackground_(t,mi,yi,_i,vi,o,s),function(t,e,n,i,r,o,s,a,l,h,c){t.save(),1!==n&&(void 0===t.globalAlpha?t.globalAlpha=t=>t.globalAlpha*=n:t.globalAlpha*=n),e&&t.transform.apply(t,e),i.contextInstructions?(t.translate(l,h),t.scale(c[0],c[1]),function(t,e){const n=t.contextInstructions;for(let t=0,i=n.length;t<i;t+=2)Array.isArray(n[t+1])?e[n[t]].apply(e,n[t+1]):e[n[t]]=n[t+1]}(i,t)):c[0]<0||c[1]<0?(t.translate(l,h),t.scale(c[0],c[1]),t.drawImage(i,r,o,s,a,0,0,s,a)):t.drawImage(i,r,o,s,a,l,h,s*c[0],a*c[1]),t.restore()}(t,i.canvasTransform,r,n,i.originX,i.originY,i.drawImageW,i.drawImageH,i.drawImageX,i.drawImageY,i.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const n=oi(this.renderedTransform_,[0,0]),i=512*this.pixelRatio;t.save(),t.translate(n[0]%i,n[1]%i),1!==e&&t.scale(e,e)}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,n,i){const r=this.textStates[e],o=this.createLabel(t,e,i,n),s=this.strokeStates[n],a=this.pixelRatio,l=wi(Array.isArray(t)?t[0]:t,r.textAlign||bn),h=Qn[r.textBaseline||In],c=s&&s.lineWidth?s.lineWidth:0;return{label:o,anchorX:l*(o.width/a-2*r.scale[0])+2*(.5-l)*c,anchorY:h*o.height/a+2*(.5-h)*c}}execute_(t,e,n,i,r,o,s,a){const h=this.zIndexContext_;let c;var u,d;this.pixelCoordinates_&&l(n,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=ni(this.coordinates,0,this.coordinates.length,2,n,this.pixelCoordinates_),d=n,(u=this.renderedTransform_)[0]=d[0],u[1]=d[1],u[2]=d[2],u[3]=d[3],u[4]=d[4],u[5]=d[5]);let f=0;const g=i.length;let p,m=0;const y=[];let _,v,x,S,w,C,b,I,E,P,T,M,k,R=0,F=0;const A=this.coordinateCache_,L=this.viewRotation_,D=Math.round(1e12*Math.atan2(-n[1],n[0]))/1e12,G={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:L},j=this.instructions!=i||this.overlaps?0:200;let V,N,W,B;for(;f<g;){const n=i[f];switch(n[0]){case Xn.BEGIN_GEOMETRY:V=n[1],B=n[3],V.getGeometry()?void 0===s||O(s,B.getExtent())?++f:f=n[2]+1:f=n[2],h&&(h.zIndex=n[4]);break;case Xn.BEGIN_PATH:R>j&&(this.fill_(t),R=0),F>j&&(t.stroke(),F=0),R||F||(t.beginPath(),w=NaN,C=NaN),++f;break;case Xn.CIRCLE:m=n[1],x=n[2]??0;const i=c[m],l=c[m+1],u=c[m+2]-x-i,d=c[m+3]-x-l,g=Math.sqrt(u*u+d*d);t.moveTo(i+g,l),t.arc(i,l,g,0,2*Math.PI,!0),++f;break;case Xn.CLOSE_PATH:t.closePath(),++f;break;case Xn.CUSTOM:m=n[1],p=n[2];const X=n[3],Y=n[4],z=n[5];G.geometry=X,G.feature=V,f in A||(A[f]=[]);const U=A[f];z?z(c,m,p,2,U):(U[0]=c[m],U[1]=c[m+1],U.length=2),h&&(h.zIndex=n[6]),Y(U,G),++f;break;case Xn.DRAW_IMAGE:m=n[1],p=n[2],E=n[3],_=n[4],v=n[5];let H=n[6];const q=n[7],$=n[8],Z=n[9],K=n[10];let J=n[11];const Q=n[12];let tt=n[13];S=n[14]||"declutter";const et=n[15];if(!E&&n.length>=20){P=n[19],T=n[20],M=n[21],k=n[22];const t=this.drawLabelWithPointPlacement_(P,T,M,k);E=t.label,n[3]=E;const e=n[23];_=(t.anchorX-e)*this.pixelRatio,n[4]=_;const i=n[24];v=(t.anchorY-i)*this.pixelRatio,n[5]=v,H=E.height,n[6]=H,tt=E.width,n[13]=tt}let nt,it,rt,ot;n.length>25&&(nt=n[25]),n.length>17?(it=n[16],rt=n[17],ot=n[18]):(it=En,rt=null,ot=null),K&&D?J+=L:K||D||(J-=L);let st=0;for(;m<p;m+=2){if(nt&&nt[st++]<tt/this.pixelRatio)continue;const n=this.calculateImageOrLabelDimensions_(E.width,E.height,c[m],c[m+1],tt,H,_,v,$,Z,J,Q,r,it,!!rt||!!ot,V),i=[t,e,E,n,q,rt,ot];if(a){let t,e,r,o,s;if(et){const n=p-m;if(!et[n]){et[n]={args:i,declutterMode:S};continue}const o=et[n];t=o.args,e=o.declutterMode,delete et[n],r=xi(t)}if(!t||"declutter"===e&&a.collides(r)||(o=!0),"declutter"===S&&a.collides(n.declutterBox)||(s=!0),"declutter"===e&&"declutter"===S){const t=o&&s;o=t,s=t}o&&("none"!==e&&a.insert(r),this.replayImageOrLabel_.apply(this,t)),s&&("none"!==S&&a.insert(n.declutterBox),this.replayImageOrLabel_.apply(this,i))}else this.replayImageOrLabel_.apply(this,i)}++f;break;case Xn.DRAW_CHARS:const at=n[1],lt=n[2],ht=n[3],ct=n[4];k=n[5];const ut=n[6],dt=n[7],ft=n[8];M=n[9];const gt=n[10];P=n[11],Array.isArray(P)&&(P=P.reduce(bi,"")),T=n[12];const pt=[n[13],n[13]];S=n[14]||"declutter";const mt=n[15],yt=this.textStates[T],_t=yt.font,vt=[yt.scale[0]*dt,yt.scale[1]*dt];let xt;_t in this.widths_?xt=this.widths_[_t]:(xt={},this.widths_[_t]=xt);const St=hi(c,at,lt,2),wt=Math.abs(vt[0])*Gn(_t,P,xt);if(ct||wt<=St){const n=fi(c,at,lt,2,P,(St-wt)*wi(P,this.textStates[T].textAlign),ut,Math.abs(vt[0]),Gn,_t,xt,D?0:this.viewRotation_,mt);t:if(n){const i=[];let r,o,s,l,h;if(M)for(r=0,o=n.length;r<o;++r){h=n[r],s=h[4],l=this.createLabel(s,T,"",M),_=h[2]+(vt[0]<0?-gt:gt),v=ht*l.height+2*(.5-ht)*gt*vt[1]/vt[0]-ft;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,_,v,0,0,h[3],pt,!1,En,!1,V);if(a&&"declutter"===S&&a.collides(o.declutterBox))break t;i.push([t,e,l,o,1,null,null])}if(k)for(r=0,o=n.length;r<o;++r){h=n[r],s=h[4],l=this.createLabel(s,T,k,""),_=h[2],v=ht*l.height-ft;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,_,v,0,0,h[3],pt,!1,En,!1,V);if(a&&"declutter"===S&&a.collides(o.declutterBox))break t;i.push([t,e,l,o,1,null,null])}a&&"none"!==S&&a.load(i.map(xi));for(let t=0,e=i.length;t<e;++t)this.replayImageOrLabel_.apply(this,i[t])}}++f;break;case Xn.END_GEOMETRY:if(void 0!==o){V=n[1];const t=o(V,B,S);if(t)return t}++f;break;case Xn.FILL:j?R++:this.fill_(t),++f;break;case Xn.MOVE_TO_LINE_TO:let Ct,bt,It;m=n[1],p=n[2],x=n[3],x?(ci(c,m,p,2,x,n[4]??!1,y),di(y,2),Ct=y,bt=0,It=Ct.length):(Ct=c,bt=m,It=p),N=Ct[bt],W=Ct[bt+1],t.moveTo(N,W),w=N+.5|0,C=W+.5|0;for(let e=bt+2;e<It;e+=2)N=Ct[e],W=Ct[e+1],b=N+.5|0,I=W+.5|0,e!=It-2&&b===w&&I===C||(t.lineTo(N,W),w=b,C=I);++f;break;case Xn.SET_FILL_STYLE:this.alignAndScaleFill_=n[2],R?(this.fill_(t),R=0,F&&(t.stroke(),F=0)):F&&n[1]&&(t.stroke(),F=0),t.fillStyle=n[1],++f;break;case Xn.SET_STROKE_STYLE:R&&n[1]&&(this.fill_(t),R=0),F&&(t.stroke(),F=0),this.setStrokeStyle_(t,n),++f;break;case Xn.STROKE:j?F++:t.stroke(),++f;break;default:++f}}R&&this.fill_(t),F&&t.stroke()}execute(t,e,n,i,r,o){this.viewRotation_=i,this.execute_(t,e,n,this.instructions,r,void 0,void 0,o)}executeHitDetection(t,e,n,i,r){return this.viewRotation_=n,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,i,r)}},Ei=["Polygon","Circle","LineString","Image","Text","Default"],Pi=["Image","Text"],Ti=Ei.filter(t=>!Pi.includes(t));let Mi=!1,ki=!1;const Ri={},Fi=class{constructor(t,e,n,i,r,o,s){this.maxExtent_=t,this.overlaps_=i,this.pixelRatio_=n,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=[1,0,0,1,0,0],this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,s)}clip(t,e){const n=this.getClipCoords(e);t.beginPath(),t.moveTo(n[0],n[1]),t.lineTo(n[2],n[3]),t.lineTo(n[4],n[5]),t.lineTo(n[6],n[7]),t.clip()}createExecutors_(t,e){for(const n in t){let i=this.executorsByZIndex_[n];void 0===i&&(i={},this.executorsByZIndex_[n]=i);const r=t[n];for(const t in r){const n=r[t];i[t]=new Ii(this.resolution_,this.pixelRatio_,this.overlaps_,n,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const n=this.executorsByZIndex_[e];for(let e=0,i=t.length;e<i;++e)if(t[e]in n)return!0}return!1}forEachFeatureAtCoordinate(t,e,n,r,o,s){!1===ki&&function(){let t=0;const e=e=>{const n=J(1,1,null,{willReadFrequently:e});let i=0;const r=performance.now();for(;performance.now()-r<50;++i)n.fillStyle=`rgba(255,0,${i%256},1)`,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1);return t=i>t?i:t,i},n={[e(!0)]:!0,[e(!1)]:!1,[e(void 0)]:void 0};Mi=n[t],ki=!0}();const a=2*(r=Math.round(r))+1,l=si(this.hitDetectionTransform_,r+.5,r+.5,1/e,-1/e,-n,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=J(a,a,null,{willReadFrequently:Mi}));const u=this.hitDetectionContext_;let d;u.canvas.width!==a||u.canvas.height!==a?(u.canvas.width=a,u.canvas.height=a):h||u.clearRect(0,0,a,a),void 0!==this.renderBuffer_&&(d=[1/0,1/0,-1/0,-1/0],w(d,t),c(d,e*(this.renderBuffer_+r),d));const f=function(t){if(void 0!==Ri[t])return Ri[t];const e=2*t+1,n=t*t,i=new Array(n+1);for(let r=0;r<=t;++r)for(let o=0;o<=t;++o){const s=r*r+o*o;if(s>n)break;let a=i[s];a||(a=[],i[s]=a),a.push(4*((t+r)*e+(t+o))+3),r>0&&a.push(4*((t-r)*e+(t+o))+3),o>0&&(a.push(4*((t+r)*e+(t-o))+3),r>0&&a.push(4*((t-r)*e+(t-o))+3))}const r=[];for(let t=0,e=i.length;t<e;++t)i[t]&&r.push(...i[t]);return Ri[t]=r,r}(r);let g;function p(t,e,n){const i=u.getImageData(0,0,a,a).data;for(let l=0,h=f.length;l<h;l++)if(i[f[l]]>0){if(!s||"none"===n||"Image"!==g&&"Text"!==g||s.includes(t)){const n=(f[l]-3)/4,i=r-n%a,s=r-(n/a|0),h=o(t,e,i*i+s*s);if(h)return h}u.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);let y,_,v,x,S;for(m.sort(i),y=m.length-1;y>=0;--y){const t=m[y].toString();for(v=this.executorsByZIndex_[t],_=Ei.length-1;_>=0;--_)if(g=Ei[_],x=v[g],void 0!==x&&(S=x.executeHitDetection(u,l,n,p,d),S))return S}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const n=e[0],i=e[1],r=e[2],o=e[3],s=[n,i,n,o,r,o,r,i];return ni(s,0,8,2,t,s),s}isEmpty(){return Be(this.executorsByZIndex_)}execute(t,e,n,o,s,a,l){const h=Object.keys(this.executorsByZIndex_).map(Number);h.sort(l?r:i),a=a||Ei;const c=Ei.length;for(let i=0,r=h.length;i<r;++i){const r=h[i].toString(),u=this.executorsByZIndex_[r];for(let r=0,d=a.length;r<d;++r){const d=a[r],f=u[d];if(void 0!==f){const r=null===l?void 0:f.getZIndexContext(),a=r?r.getContext():t,u=this.maxExtent_&&"Image"!==d&&"Text"!==d;if(u&&(a.save(),this.clip(a,n)),r&&"Text"!==d&&"Image"!==d?r.pushFunction(t=>f.execute(t,e,n,o,s,l)):f.execute(a,e,n,o,s,l),u&&a.restore(),r){r.offset();const t=h[i]*c+Ei.indexOf(d);this.deferredZIndexContexts_[t]||(this.deferredZIndexContexts_[t]=[]),this.deferredZIndexContexts_[t].push(r)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(i);for(let n=0,i=e.length;n<i;++n)t[e[n]].forEach(t=>{t.draw(this.renderedContext_),t.clear()}),t[e[n]].length=0}};function Oi(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}class Ai{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=Oi(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Ai({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 hn()}getImage(t){return hn()}getHitDetectionImage(){return hn()}getPixelRatio(t){return 1}getImageState(){return hn()}getImageSize(){return hn()}getOrigin(){return hn()}getSize(){return hn()}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_=Oi(t)}listenImageChange(t){hn()}load(){hn()}unlistenImageChange(t){hn()}ready(){return Promise.resolve()}}const Li=Ai;function Di(t,e,n,i){return void 0!==n&&void 0!==i?[n/t,i/e]:void 0!==n?n/t:void 0!==i?i/e:1}class Gi extends Li{constructor(t){const e=void 0!==(t=t||{}).opacity?t.opacity:1,n=void 0!==t.rotation?t.rotation:0,i=void 0!==t.scale?t.scale:1,r=void 0!==t.rotateWithView&&t.rotateWithView;super({opacity:e,rotation:n,scale:i,displacement:void 0!==t.displacement?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=void 0!==t.anchor?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=void 0!==t.anchorOrigin?t.anchorOrigin:"top-left",this.anchorXUnits_=void 0!==t.anchorXUnits?t.anchorXUnits:"fraction",this.anchorYUnits_=void 0!==t.anchorYUnits?t.anchorYUnits:"fraction",this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy;const o=void 0!==t.img?t.img:null;let s,a=t.src;if(ri(!(void 0!==a&&o),"`image` and `src` cannot be provided at the same time"),void 0!==a&&0!==a.length||!o||(a=o.src||un(o)),ri(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),ri(!((void 0!==t.width||void 0!==t.height)&&void 0!==t.scale),"`width` or `height` cannot be provided together with `scale`"),void 0!==t.src?s=0:void 0!==o&&(s="complete"in o?o.complete?o.src?2:0:1:2),this.color_=void 0!==t.color?Oe(t.color):null,this.iconImage_=$e(o,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},s,this.color_),this.offset_=void 0!==t.offset?t.offset:[0,0],this.offsetOrigin_=void 0!==t.offsetOrigin?t.offsetOrigin:"top-left",this.origin_=null,this.size_=void 0!==t.size?t.size:null,this.initialOptions_,void 0!==t.width||void 0!==t.height){let e,n;if(t.size)[e,n]=t.size;else{const i=this.getImage(1);if(i.width&&i.height)e=i.width,n=i.height;else if(i instanceof HTMLImageElement){this.initialOptions_=t;const e=()=>{if(this.unlistenImageChange(e),!this.initialOptions_)return;const n=this.iconImage_.getSize();this.setScale(Di(n[0],n[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale(Di(e,n,t.width,t.height))}}clone(){let t,e,n;return this.initialOptions_?(e=this.initialOptions_.width,n=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new Gi({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_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:n,size:null!==this.size_?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const e=this.getSize();if("fraction"==this.anchorXUnits_||"fraction"==this.anchorYUnits_){if(!e)return null;t=this.anchor_.slice(),"fraction"==this.anchorXUnits_&&(t[0]*=e[0]),"fraction"==this.anchorYUnits_&&(t[1]*=e[1])}if("top-left"!=this.anchorOrigin_){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),"top-right"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[0]=-t[0]+e[0]),"bottom-left"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[1]=-t[1]+e[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),n=this.getScaleArray();return[t[0]-e[0]/n[0],t[1]+e[1]/n[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){const e=t?Oe(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((t,n)=>t===e[n]))return;this.color_=e;const n=this.getSrc(),i=void 0!==n?null:this.getHitDetectionImage(),r=void 0!==n?0:this.iconImage_.getImageState();this.iconImage_=$e(i,n,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},r,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if("top-left"!=this.offsetOrigin_){const e=this.getSize(),n=this.iconImage_.getSize();if(!e||!n)return null;t=t.slice(),"top-right"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[0]=n[0]-e[0]-t[0]),"bottom-left"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[1]=n[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=$e(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},0,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();return this.size_?this.size_[0]*t[0]:2==this.iconImage_.getImageState()?this.iconImage_.getSize()[0]*t[0]:void 0}getHeight(){const t=this.getScaleArray();return this.size_?this.size_[1]*t[1]:2==this.iconImage_.getImageState()?this.iconImage_.getSize()[1]*t[1]:void 0}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(Le,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(Le,t)}ready(){return this.iconImage_.ready()}}const ji=Gi,Vi=[1,0,0,1,0,0],Ni=[NaN,NaN],Wi=class extends fn{constructor(){super(),this.extent_=[1/0,1/0,-1/0,-1/0],this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Ne((t,e,n)=>{if(!n)return this.getSimplifiedGeometry(e);const i=this.clone();return i.applyTransform(n),i.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return hn()}closestPointXY(t,e,n,i){return hn()}containsXY(t,e){return 0===this.closestPointXY(t,e,Ni,Number.MIN_VALUE)}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 hn()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&y(t),this.extentRevision_=this.getRevision()}return function(t,e){return e?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):t}(this.extent_,t)}rotate(t,e){hn()}scale(t,e,n){hn()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return hn()}getType(){return hn()}applyTransform(t){hn()}intersectsExtent(t){return hn()}translate(t,e){hn()}transform(t,e){const n=Zt(t),i="tile-pixels"==n.getUnits()?function(t,i,r){const o=n.getExtent(),s=n.getWorldExtent(),a=M(s)/M(o);si(Vi,s[0],s[3],a,-a,0,0,0);const l=ni(t,0,t.length,r,Vi,i),h=ee(n,e);return h?h(l,l,r):l}:ee(n,e);return this.applyTransform(i),this}};function Bi(t){let e;return 2==t?e="XY":3==t?e="XYZ":4==t&&(e="XYZM"),e}function Xi(t){let e;return"XY"==t?e=2:"XYZ"==t||"XYM"==t?e=3:"XYZM"==t&&(e=4),e}const Yi=class extends Wi{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return v(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return hn()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=Xi(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){hn()}setLayout(t,e,n){let i;if(t)i=Xi(t);else{for(let t=0;t<n;++t){if(0===e.length)return this.layout="XY",void(this.stride=2);e=e[0]}i=e.length,t=Bi(i)}this.layout=t,this.stride=i}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const n=this.getFlatCoordinates();if(n){const i=this.getStride();ii(n,0,n.length,i,t,e,n),this.changed()}}scale(t,e,n){void 0===e&&(e=t),n||(n=T(this.getExtent()));const i=this.getFlatCoordinates();if(i){const r=this.getStride();!function(t,e,n,i,r,o,s,a){a=a||[];const l=s[0],h=s[1];let c=0;for(let e=0;e<n;e+=i){const n=t[e]-l,s=t[e+1]-h;a[c++]=l+r*n,a[c++]=h+o*s;for(let n=e+2;n<e+i;++n)a[c++]=t[n]}a&&a.length!=c&&(a.length=c)}(i,0,i.length,r,t,e,n,i),this.changed()}}translate(t,e){const n=this.getFlatCoordinates();if(n){const i=this.getStride();!function(t,e,n,i,r,o,s){s=s||[];let a=0;for(let e=0;e<n;e+=i){s[a++]=t[e]+r,s[a++]=t[e+1]+o;for(let n=e+2;n<e+i;++n)s[a++]=t[n]}s&&s.length!=a&&(s.length=a)}(n,0,n.length,i,t,e,n),this.changed()}}},zi=class extends en{constructor(t,e,n,i,r,o,s){super(),this.context_=t,this.pixelRatio_=e,this.extent_=n,this.transform_=i,this.transformRotation_=i?X(Math.atan2(i[1],i[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=s,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=[1,0,0,1,0,0]}drawImages_(t,e,n,i){if(!this.image_)return;const r=ni(t,e,n,i,this.transform_,this.pixelCoordinates_),o=this.context_,s=this.tmpLocalTransform_,a=o.globalAlpha;1!=this.imageOpacity_&&(o.globalAlpha=a*this.imageOpacity_);let l=this.imageRotation_;0===this.transformRotation_&&(l-=this.viewRotation_),this.imageRotateWithView_&&(l+=this.viewRotation_);for(let t=0,e=r.length;t<e;t+=2){const e=r[t]-this.imageAnchorX_,n=r[t+1]-this.imageAnchorY_;if(0!==l||1!=this.imageScale_[0]||1!=this.imageScale_[1]){const t=e+this.imageAnchorX_,i=n+this.imageAnchorY_;si(s,t,i,1,1,l,-t,-i),o.save(),o.transform.apply(o,s),o.translate(t,i),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_,e,n,this.imageWidth_,this.imageHeight_)}1!=this.imageOpacity_&&(o.globalAlpha=a)}drawText_(t,e,n,i){if(!this.textState_||""===this.text_)return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=ni(t,e,n,i,this.transform_,this.pixelCoordinates_),o=this.context_;let s=this.textRotation_;for(0===this.transformRotation_&&(s-=this.viewRotation_),this.textRotateWithView_&&(s+=this.viewRotation_);e<n;e+=i){const t=r[e]+this.textOffsetX_,n=r[e+1]+this.textOffsetY_;0!==s||1!=this.textScale_[0]||1!=this.textScale_[1]?(o.save(),o.translate(t-this.textOffsetX_,n-this.textOffsetY_),o.rotate(s),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_,t,n),this.textFillState_&&o.fillText(this.text_,t,n))}}moveToLineTo_(t,e,n,i,r,o){const s=this.context_;let a=ni(t,e,n,i,this.transform_,this.pixelCoordinates_);Math.abs(o)>0&&(a=ci(a,0,a.length,2,o,r,a),di(a,2)),s.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let t=2;t<l;t+=2)s.lineTo(a[t],a[t+1]);return r&&s.closePath(),n}drawRings_(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o)e=this.moveToLineTo_(t,e,n[o],i,!0,r);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),O(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=function(t,e,n){const i=t.getFlatCoordinates();if(!i)return null;const r=t.getStride();return ni(i,0,i.length,r,e,n)}(t,this.transform_,this.pixelCoordinates_),n=e[2]-e[0],i=e[3]-e[1],r=Math.sqrt(n*n+i*i),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)}}drawFeature(t,e){const n=e.getGeometryFunction()(t);n&&(this.setStyle(e),this.drawGeometry(n))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let t=0,n=e.length;t<n;++t)this.drawGeometry(e[t])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),n=t.getStride();this.image_&&this.drawImages_(e,0,e.length,n),""!==this.text_&&this.drawText_(e,0,e.length,n)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),n=t.getStride();this.image_&&this.drawImages_(e,0,e.length,n),""!==this.text_&&this.drawText_(e,0,e.length,n)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),O(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,n=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(n,0,n.length,t.getStride(),!1,this.strokeState_.strokeOffset),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(O(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,n=t.getFlatCoordinates();let i=0;const r=t.getEnds(),o=t.getStride();e.beginPath();for(let t=0,e=r.length;t<e;++t)i=this.moveToLineTo_(n,i,r[t],o,!1,this.strokeState_.strokeOffset);e.stroke()}if(""!==this.text_){const e=t.getFlatMidpoints();this.drawText_(e,0,e.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),O(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.strokeState_?.strokeOffset),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_)),O(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_,n=t.getOrientedFlatCoordinates();let i=0;const r=t.getEndss(),o=t.getStride();e.beginPath();for(let t=0,e=r.length;t<e;++t){const e=r[t];i=this.drawRings_(n,i,e,o,this.strokeState_?.strokeOffset)}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_,n=this.contextFillState_;n?n.fillStyle!=t.fillStyle&&(n.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,n=this.contextStrokeState_;n?(n.lineCap!=t.lineCap&&(n.lineCap=t.lineCap,e.lineCap=t.lineCap),l(n.lineDash,t.lineDash)||e.setLineDash(n.lineDash=t.lineDash),n.lineDashOffset!=t.lineDashOffset&&(n.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),n.lineJoin!=t.lineJoin&&(n.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),n.lineWidth!=t.lineWidth&&(n.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),n.miterLimit!=t.miterLimit&&(n.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),n.strokeStyle!=t.strokeStyle&&(n.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_,n=this.contextTextState_,i=t.textAlign?t.textAlign:bn;n?(n.font!=t.font&&(n.font=t.font,e.font=t.font),n.textAlign!=i&&(n.textAlign=i,e.textAlign=i),n.textBaseline!=t.textBaseline&&(n.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=i,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:i,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(t){const e=t.getColor();this.fillState_={fillStyle:Ke(e||vn)}}else this.fillState_=null;if(e){const t=e.getColor(),n=e.getLineCap(),i=e.getLineDash(),r=e.getLineDashOffset(),o=e.getLineJoin(),s=e.getWidth(),a=e.getMiterLimit(),l=i||Sn,h=e.getOffset();this.strokeState_={lineCap:void 0!==n?n:xn,lineDash:1===this.pixelRatio_?l:l.map(t=>t*this.pixelRatio_),lineDashOffset:(r||0)*this.pixelRatio_,lineJoin:void 0!==o?o:wn,lineWidth:(void 0!==s?s:1)*this.pixelRatio_,miterLimit:void 0!==a?a:10,strokeStyle:Ke(t||Cn),strokeOffset:(h??0)*this.pixelRatio_}}else this.strokeState_=null}setImageStyle(t){let e;if(!t||!(e=t.getSize()))return void(this.image_=null);const n=t.getPixelRatio(this.pixelRatio_),i=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=i[0]*n,this.imageAnchorY_=i[1]*n,this.imageHeight_=e[1]*n,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_/n,o[1]*this.pixelRatio_/n],this.imageWidth_=e[0]*n}setTextStyle(t){if(t){const e=t.getFill();if(e){const t=e.getColor();this.textFillState_={fillStyle:Ke(t||vn)}}else this.textFillState_=null;const n=t.getStroke();if(n){const t=n.getColor(),e=n.getLineCap(),i=n.getLineDash(),r=n.getLineDashOffset(),o=n.getLineJoin(),s=n.getWidth(),a=n.getMiterLimit();this.textStrokeState_={lineCap:void 0!==e?e:xn,lineDash:i||Sn,lineDashOffset:r||0,lineJoin:void 0!==o?o:wn,lineWidth:void 0!==s?s:1,miterLimit:void 0!==a?a:10,strokeStyle:Ke(t||Cn)}}else this.textStrokeState_=null;const i=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),s=t.getRotateWithView(),a=t.getRotation(),l=t.getScaleArray(),h=t.getText(),c=t.getTextAlign(),u=t.getTextBaseline();this.textState_={font:void 0!==i?i:_n,textAlign:void 0!==c?c:bn,textBaseline:void 0!==u?u:In},this.text_=void 0!==h?Array.isArray(h)?h.reduce((t,e,n)=>t+(n%2?" ":e),""):h:"",this.textOffsetX_=void 0!==r?this.pixelRatio_*r:0,this.textOffsetY_=void 0!==o?this.pixelRatio_*o:0,this.textRotateWithView_=void 0!==s&&s,this.textRotation_=void 0!==a?a:0,this.textScale_=[this.pixelRatio_*l[0],this.pixelRatio_*l[1]]}else this.text_=""}},Ui=.5,Hi={Point:function(t,e,n,i,r,o){const s=n.getImage(),a=n.getText(),l=a&&a.getText(),h=o&&s&&l?{}:void 0;if(s){if(2!=s.getImageState())return;const o=t.getBuilder(n.getZIndex(),"Image");o.setImageStyle(s,h),o.drawPoint(e,i,r)}if(l){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(a,h),o.drawText(e,i,r)}},LineString:function(t,e,n,i,r){const o=n.getStroke();if(o){const s=t.getBuilder(n.getZIndex(),"LineString");s.setFillStrokeStyle(null,o),s.drawLineString(e,i,r)}const s=n.getText();if(s&&s.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(s),o.drawText(e,i,r)}},Polygon:function(t,e,n,i,r){const o=n.getFill(),s=n.getStroke();if(o||s){const a=t.getBuilder(n.getZIndex(),"Polygon");a.setFillStrokeStyle(o,s),a.drawPolygon(e,i,r)}const a=n.getText();if(a&&a.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(a),o.drawText(e,i,r)}},MultiPoint:function(t,e,n,i,r,o){const s=n.getImage(),a=s&&0!==s.getOpacity(),l=n.getText(),h=l&&l.getText(),c=o&&a&&h?{}:void 0;if(a){if(2!=s.getImageState())return;const o=t.getBuilder(n.getZIndex(),"Image");o.setImageStyle(s,c),o.drawMultiPoint(e,i,r)}if(h){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(l,c),o.drawText(e,i,r)}},MultiLineString:function(t,e,n,i,r){const o=n.getStroke();if(o){const s=t.getBuilder(n.getZIndex(),"LineString");s.setFillStrokeStyle(null,o),s.drawMultiLineString(e,i,r)}const s=n.getText();if(s&&s.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(s),o.drawText(e,i,r)}},MultiPolygon:function(t,e,n,i,r){const o=n.getFill(),s=n.getStroke();if(s||o){const a=t.getBuilder(n.getZIndex(),"Polygon");a.setFillStrokeStyle(o,s),a.drawMultiPolygon(e,i,r)}const a=n.getText();if(a&&a.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(a),o.drawText(e,i,r)}},GeometryCollection:function(t,e,n,i,r,o){const s=e.getGeometriesArray();let a,l;for(a=0,l=s.length;a<l;++a)(0,Hi[s[a].getType()])(t,s[a],n,i,r,o)},Circle:function(t,e,n,i,r){const o=n.getFill(),s=n.getStroke();if(o||s){const a=t.getBuilder(n.getZIndex(),"Circle");a.setFillStrokeStyle(o,s),a.drawCircle(e,i,r)}const a=n.getText();if(a&&a.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(a),o.drawText(e,i,r)}}};function qi(t,e){return parseInt(un(t),10)-parseInt(un(e),10)}function $i(t,e){const n=Zi(t,e);return n*n}function Zi(t,e){return.5*t/e}function Ki(t,e,n,i,r,o,s,a){const l=[],h=n.getImage();if(h){let t=!0;const e=h.getImageState();2==e||3==e?t=!1:0==e&&h.load(),t&&l.push(h.ready())}const c=n.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>r(null)),function(t,e,n,i,r,o,s){const a=n.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(i,r);n.getRenderer()?Ji(t,l,n,e,s):(0,Hi[l.getType()])(t,l,n,e,s,o)}(t,e,n,i,o,s,a),u}function Ji(t,e,n,i,r){if("GeometryCollection"==e.getType()){const o=e.getGeometries();for(let e=0,s=o.length;e<s;++e)Ji(t,o[e],n,i,r);return}t.getBuilder(n.getZIndex(),"Default").drawCustom(e,i,n.getRenderer(),n.getHitDetectionRenderer(),r)}const Qi=class extends Xe{constructor(t,e,n,i){super(t),this.inversePixelTransform=e,this.frameState=n,this.context=i}},tr=class extends ln{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=5}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return hn()}getData(t){return null}prepareFrame(t){return hn()}renderFrame(t,e){return hn()}forEachFeatureAtCoordinate(t,e,n,i,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;2!==e.getState()&&3!==e.getState()||this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return 2!=e&&3!=e&&t.addEventListener(Le,this.boundHandleImageChange_),0==e&&(t.load(),e=t.getState()),2==e}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}},er=[];let nr=null;const ir=class extends tr{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=[1,0,0,1,0,0],this.pixelTransform=[1,0,0,1,0,0],this.inversePixelTransform=[1,0,0,1,0,0],this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,n){let i;nr||(nr=J(1,1,void 0,{willReadFrequently:!0})),nr.clearRect(0,0,1,1);try{nr.drawImage(t,e,n,1,1,0,0,1,1),i=nr.getImageData(0,0,1,1).data}catch{return nr=null,null}return i}getBackground(t){let e=this.getLayer().getBackground();return"function"==typeof e&&(e=e(t.viewState.resolution)),e||void 0}useContainer(t,e,n){const i=this.getLayer().getClassName();let r,o;if(t&&t.className===i&&(!n||t&&t.style.backgroundColor&&l(Oe(t.style.backgroundColor),Oe(n)))){const e=t.firstElementChild;s=e,("undefined"!=typeof HTMLCanvasElement&&s instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&s instanceof OffscreenCanvas)&&(o=e.getContext("2d"))}var s;if(o&&function(t,e){const n=li(t),i=li(e);for(let t=0;t<6;++t)if(0!==Math.round((n[t]-i[t])*ai[t]))return!1;return!0}(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=Z?new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){const e=this.childNodes.indexOf(t);if(-1===e)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){const n=this.childNodes.indexOf(e);if(-1===n)throw new Error("Reference node not found");return this.childNodes.splice(n,0,t),t},style:{}},{get:(t,e,n)=>"firstElementChild"===e?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,n)}):document.createElement("div"),r.className=i;let t=r.style;t.position="absolute",t.width="100%",t.height="100%",o=J();const e=o.canvas;r.appendChild(e),t=e.style,t.position="absolute",t.left="0",t.transformOrigin="top left",this.container=r,this.context=o}this.containerReused||!n||this.container.style.backgroundColor||(this.container.style.backgroundColor=n)}clipUnrotated(t,e,n){const i=k(n),r=R(n),o=P(n),s=E(n);oi(e.coordinateToPixelTransform,i),oi(e.coordinateToPixelTransform,r),oi(e.coordinateToPixelTransform,o),oi(e.coordinateToPixelTransform,s);const a=this.inversePixelTransform;oi(a,i),oi(a,r),oi(a,o),oi(a,s),t.save(),t.beginPath(),t.moveTo(Math.round(i[0]),Math.round(i[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(s[0]),Math.round(s[1])),t.clip()}prepareContainer(t,e){const n=t.extent,i=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,s=Math.round(F(n)/i*o),a=Math.round(M(n)/i*o);si(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-s/2,-a/2),function(t,e){const n=(i=e)[0]*i[3]-i[1]*i[2];var i;ri(0!==n,"Transformation matrix cannot be inverted");const r=e[0],o=e[1],s=e[2],a=e[3],l=e[4],h=e[5];t[0]=a/n,t[1]=-o/n,t[2]=-s/n,t[3]=r/n,t[4]=(s*h-a*l)/n,t[5]=-(r*h-o*l)/n}(this.inversePixelTransform,this.pixelTransform);const l="matrix("+this.pixelTransform.join(", ")+")";if(this.useContainer(e,l,this.getBackground(t)),!this.containerReused){const t=this.context.canvas;t.width!=s||t.height!=a?(t.width=s,t.height=a):this.context.clearRect(0,0,s,a),l!==t.style.transform&&(t.style.transform=l)}}dispatchRenderEvent_(t,e,n){const i=this.getLayer();if(i.hasListener(t)){const r=new Qi(t,this.inversePixelTransform,n,e);i.dispatchEvent(r)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_(fe,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(ge,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new gi),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(fe,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(ge,this.context,t))}getRenderTransform(t,e,n,i,r,o,s){const a=r/2,l=o/2,h=i/e,c=-h,u=-t[0]+s,d=-t[1];return si(this.tempTransform,a,l,h,c,-n,u,d)}disposeInternal(){delete this.frameState,super.disposeInternal()}},rr=class extends ir{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=[1/0,1/0,-1/0,-1/0],this.wrappedRenderedExtent_=[1/0,1/0,-1/0,-1/0],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,n){const i=e.extent,r=e.viewState,o=r.center,s=r.resolution,a=r.projection,l=r.rotation,h=a.getExtent(),c=this.getLayer().getSource(),u=this.getLayer().getDeclutter(),d=e.pixelRatio,f=e.viewHints,g=!(f[0]||f[1]),p=this.context,m=Math.round(F(i)/s*d),y=Math.round(M(i)/s*d),_=c.getWrapX()&&a.canWrapX(),v=_?F(h):null,x=_?Math.ceil((i[2]-h[2])/v)+(this.extendX_?2:1):1;let S=_?Math.floor((i[0]-h[0])/v)-(this.extendX_?1:0):0;do{let i=this.getRenderTransform(o,s,0,d,m,y,S*v);e.declutter&&(i=i.slice(0)),t.execute(p,[p.canvas.width,p.canvas.height],i,l,g,void 0===n?Ei:n?Pi:Ti,n?u&&e.declutter[u]:void 0)}while(++S<x)}setDrawContext_(){1!==this.opacity_&&(this.targetContext_=this.context,this.context=J(this.context.canvas.width,this.context.canvas.height,er))}resetDrawContext_(){if(1!==this.opacity_&&this.targetContext_){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,function(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}(this.context),er.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.clipExtent_&&this.clipUnrotated(this.context,t,this.clipExtent_),this.replayGroup_.renderDeferred(),this.clipExtent_&&(this.context.restore(),this.clipExtent_=null),this.resetDrawContext_())}renderFrame(t,e){const n=t.layerStatesArray[t.layerIndex];this.opacity_=n.opacity;const i=t.viewState;this.prepareContainer(t,e);const r=this.context,o=this.replayGroup_;let s=o&&!o.isEmpty();if(!s&&!this.getLayer().hasListener(fe)&&!this.getLayer().hasListener(ge))return this.container;this.setDrawContext_(),this.preRender(r,t);i.projection;this.clipExtent_=null;let a=!1;if(s&&n.extent&&this.clipping){const e=le(n.extent);s=O(e,t.extent),s&&!f(e,t.extent)&&(t.declutter?this.clipExtent_=e:(this.clipUnrotated(r,t,e),a=!0))}return s&&this.renderWorlds(o,t,!this.getLayer().getDeclutter()&&void 0),a&&r.restore(),this.postRender(r,t),this.renderedRotation_!==i.rotation&&(this.renderedRotation_=i.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const t=this.frameState.size.slice(),e=this.renderedCenter_,n=this.renderedResolution_,r=this.renderedRotation_,o=this.renderedProjection_,s=this.wrappedRenderedExtent_,a=this.getLayer(),l=[],h=t[0]*Ui,c=t[1]*Ui;l.push(this.getRenderTransform(e,n,r,Ui,h,c,0).slice());const u=a.getSource(),d=o.getExtent();if(u.getWrapX()&&o.canWrapX()&&!f(d,s)){let t=s[0];const i=F(d);let o,a=0;for(;t<d[0];)--a,o=i*a,l.push(this.getRenderTransform(e,n,r,Ui,h,c,o).slice()),t+=i;for(a=0,t=s[2];t>d[2];)++a,o=i*a,l.push(this.getRenderTransform(e,n,r,Ui,h,c,o).slice()),t-=i}const g=re();this.hitDetectionImageData_=function(t,e,n,r,o,s,a,l,h){const c=h?ae(o):o,u=J(t[0]*Ui,t[1]*Ui);u.imageSmoothingEnabled=!1;const d=u.canvas,f=new zi(u,Ui,o,null,a,l,h?Qt(re(),h):null),g=n.length,p=Math.floor(16777215/g),m={};for(let t=1;t<=g;++t){const e=n[t-1],i=e.getStyleFunction()||r;if(!i)continue;let o=i(e,s);if(!o)continue;Array.isArray(o)||(o=[o]);const a=(t*p).toString(16).padStart(7,"#00000");for(let t=0,n=o.length;t<n;++t){const n=o[t],i=n.getGeometryFunction()(e);if(!i||!O(c,i.getExtent()))continue;const r=n.clone(),s=r.getFill();s&&s.setColor(a);const l=r.getStroke();l&&(l.setColor(a),l.setLineDash(null)),r.setText(void 0);const h=n.getImage();if(h){const t=h.getImageSize();if(!t)continue;const e=J(t[0],t[1],void 0,{alpha:!1}),n=e.canvas;e.fillStyle=a,e.fillRect(0,0,n.width,n.height),r.setImage(new ji({img:n,anchor:h.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:h.getOrigin(),opacity:1,size:h.getSize(),scale:h.getScale(),rotation:h.getRotation(),rotateWithView:h.getRotateWithView()}))}const u=r.getZIndex()||0;let d=m[u];d||(d={},m[u]=d,d.Polygon=[],d.Circle=[],d.LineString=[],d.Point=[]);const f=i.getType();if("GeometryCollection"===f){const t=i.getGeometriesArrayRecursive();for(let e=0,n=t.length;e<n;++e){const n=t[e];d[n.getType().replace("Multi","")].push(n,r)}}else d[f.replace("Multi","")].push(i,r)}}const y=Object.keys(m).map(Number).sort(i);for(let t=0,n=y.length;t<n;++t){const n=m[y[t]];for(const t in n){const i=n[t];for(let t=0,n=i.length;t<n;t+=2){f.setStyle(i[t+1]);for(let n=0,r=e.length;n<r;++n)f.setTransform(e[n]),f.drawGeometry(i[t])}}}return u.getImageData(0,0,d.width,d.height)}(t,l,this.renderedFeatures_,a.getStyleFunction(),s,n,r,$i(n,this.renderedPixelRatio_),g?o:null)}e(function(t,e,n){const i=[];if(n){const r=Math.floor(Math.round(t[0])*Ui),o=Math.floor(Math.round(t[1])*Ui),s=4*(D(r,0,n.width-1)+D(o,0,n.height-1)*n.width),a=n.data[s],l=n.data[s+1],h=n.data[s+2]+256*(l+256*a),c=Math.floor(16777215/e.length);h&&h%c===0&&i.push(e[h/c-1])}return i}(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,n,i,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,s=e.viewState.rotation,a=this.getLayer(),l={},h=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,s,n,function(t,e,n){const o=un(t),s=l[o];if(s){if(!0!==s&&n<s.distanceSq){if(0===n)return l[o]=!0,r.splice(r.lastIndexOf(s),1),i(t,a,e);s.geometry=e,s.distanceSq=n}}else{if(0===n)return l[o]=!0,i(t,a,e);r.push(l[o]={feature:t,layer:a,geometry:e,distanceSq:n,callback:i})}},h?e.declutter?.[h]?.all().map(t=>t.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),n=e.getSource();if(!n)return!1;const i=t.viewHints[0],r=t.viewHints[1],o=e.getUpdateWhileAnimating(),s=e.getUpdateWhileInteracting();if(this.ready&&!o&&i||!s&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const a=t.extent,h=t.viewState,u=h.projection,d=h.resolution,g=t.pixelRatio,p=e.getRevision(),m=e.getRenderBuffer();let y=e.getRenderOrder();void 0===y&&(y=qi);const _=h.center.slice(),v=c(a,m*d),x=v.slice(),S=[v.slice()],w=u.getExtent(),C=n.getWrapX()&&u.canWrapX();if(this.extendX_=!1,C){const t=n.getExtent();t&&!A(t)&&(this.extendX_=t[0]<w[0]||t[2]>w[2])}if(C&&(!f(w,t.extent)||this.extendX_)){const t=F(w),e=Math.max(F(v)/2,t);let n=w[0],i=w[2];this.extendX_&&(n-=t,i+=t),v[0]=n-e,v[2]=i+e,function(t,e){if(e.canWrapX()){const n=F(e.getExtent()),i=function(t,e,n){const i=e.getExtent();let r=0;return e.canWrapX()&&(t[0]<i[0]||t[0]>i[2])&&(n=n||F(i),r=Math.floor((t[0]-i[0])/n)),r}(t,e,n);i&&(t[0]-=i*n)}}(_,u);const r=L(S[0],u);r[0]<w[0]&&r[2]<w[2]?S.push([r[0]+t,r[1],r[2]+t,r[3]]):r[0]>w[0]&&r[2]>w[2]&&S.push([r[0]-t,r[1],r[2]-t,r[3]])}if(this.ready&&this.renderedResolution_==d&&this.renderedPixelRatio_===g&&this.renderedRevision_==p&&this.renderedRenderOrder_==y&&this.renderedFrameDeclutter_===!!t.declutter&&f(this.wrappedRenderedExtent_,v))return l(this.renderedExtent_,x)||(this.hitDetectionImageData_=null,this.renderedExtent_=x),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const b=new ei(Zi(d,g),v,d,g),I=re();let E;if(I){for(let t=0,e=S.length;t<e;++t){const e=ae(S[t]);n.loadFeatures(e,he(d),I)}E=Qt(I,u)}else for(let t=0,e=S.length;t<e;++t)n.loadFeatures(S[t],d,u);const P=$i(d,g);let T=!0;const M=(t,n)=>{let i;const r=t.getStyleFunction()||e.getStyleFunction();if(r&&(i=r(t,d)),i){const e=this.renderFeature(t,P,i,b,E,this.getLayer().getDeclutter(),n);T=T&&!e}},k=ae(v),R=n.getFeaturesInExtent(k);y&&R.sort(y);for(let t=0,e=R.length;t<e;++t)M(R[t],t);this.renderedFeatures_=R,this.ready=T;const O=b.finish(),D=new Fi(v,d,g,n.getOverlaps(),O,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=d,this.renderedRevision_=p,this.renderedRenderOrder_=y,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=x,this.wrappedRenderedExtent_=v,this.renderedCenter_=_,this.renderedProjection_=u,this.renderedPixelRatio_=g,this.replayGroup_=D,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,n,i,r,o,s){if(!n)return!1;let a=!1;if(Array.isArray(n))for(let l=0,h=n.length;l<h;++l)a=Ki(i,t,n[l],e,this.boundHandleStyleImageChange_,r,o,s)||a;else a=Ki(i,t,n,e,this.boundHandleStyleImageChange_,r,o,s);return a}};function or(t,e,n=0,i=t.length-1,r=ar){for(;i>n;){if(i-n>600){const o=i-n+1,s=e-n+1,a=Math.log(o),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);or(t,e,Math.max(n,Math.floor(e-s*l/o+h)),Math.min(i,Math.floor(e+(o-s)*l/o+h)),r)}const o=t[e];let s=n,a=i;for(sr(t,n,e),r(t[i],o)>0&&sr(t,n,i);s<a;){for(sr(t,s,a),s++,a--;r(t[s],o)<0;)s++;for(;r(t[a],o)>0;)a--}0===r(t[n],o)?sr(t,n,a):(a++,sr(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function sr(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function ar(t,e){return t<e?-1:t>e?1:0}class lr{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!xr(t,e))return n;const i=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const s=e.children[o],a=e.leaf?i(s):s;xr(t,a)&&(e.leaf?n.push(s):vr(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n}collides(t){let e=this.data;if(!xr(t,e))return!1;const n=[];for(;e;){for(let i=0;i<e.children.length;i++){const r=e.children[i],o=e.leaf?this.toBBox(r):r;if(xr(t,o)){if(e.leaf||vr(t,o))return!0;n.push(r)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Sr([]),this}remove(t,e){if(!t)return this;let n=this.data;const i=this.toBBox(t),r=[],o=[];let s,a,l;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],s=o.pop(),l=!0),n.leaf){const i=hr(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!vr(n,i)?a?(s++,n=a.children[s],l=!1):n=null:(r.push(n),o.push(s),s=0,a=n,n=n.children[0])}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 n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,i){const r=n-e+1;let o,s=this._maxEntries;if(r<=s)return o=Sr(t.slice(e,n+1)),cr(o,this.toBBox),o;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),o=Sr([]),o.leaf=!1,o.height=i;const a=Math.ceil(r/s),l=a*Math.ceil(Math.sqrt(s));wr(t,e,n,l,this.compareMinX);for(let r=e;r<=n;r+=l){const e=Math.min(r+l-1,n);wr(t,r,e,a,this.compareMinY);for(let n=r;n<=e;n+=a){const r=Math.min(n+a-1,e);o.children.push(this._build(t,n,r,i-1))}}return cr(o,this.toBBox),o}_chooseSubtree(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){let n,i=1/0,r=1/0;for(let o=0;o<e.children.length;o++){const s=e.children[o],a=pr(s),l=yr(t,s)-a;l<r?(r=l,i=a<i?a:i,n=s):l===r&&a<i&&(i=a,n=s)}e=n||e.children[0]}return e}_insert(t,e,n){const i=n?t:this.toBBox(t),r=[],o=this._chooseSubtree(i,this.data,e,r);for(o.children.push(t),dr(o,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)}_split(t,e){const n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const o=this._chooseSplitIndex(n,r,i),s=Sr(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,cr(n,this.toBBox),cr(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)}_splitRoot(t,e){this.data=Sr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,cr(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let i,r=1/0,o=1/0;for(let s=e;s<=n-e;s++){const e=ur(t,0,s,this.toBBox),a=ur(t,s,n,this.toBBox),l=_r(e,a),h=pr(e)+pr(a);l<r?(r=l,i=s,o=h<o?h:o):l===r&&h<o&&(o=h,i=s)}return i||n-e}_chooseSplitAxis(t,e,n){const i=t.leaf?this.compareMinX:fr,r=t.leaf?this.compareMinY:gr;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)}_allDistMargin(t,e,n,i){t.children.sort(i);const r=this.toBBox,o=ur(t,0,e,r),s=ur(t,n-e,n,r);let a=mr(o)+mr(s);for(let i=e;i<n-e;i++){const e=t.children[i];dr(o,t.leaf?r(e):e),a+=mr(o)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];dr(s,t.leaf?r(e):e),a+=mr(s)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)dr(e[i],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():cr(t[n],this.toBBox)}}function hr(t,e,n){if(!n)return e.indexOf(t);for(let i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function cr(t,e){ur(t,0,t.children.length,e,t)}function ur(t,e,n,i,r){r||(r=Sr(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let o=e;o<n;o++){const e=t.children[o];dr(r,t.leaf?i(e):e)}return r}function dr(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function fr(t,e){return t.minX-e.minX}function gr(t,e){return t.minY-e.minY}function pr(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function mr(t){return t.maxX-t.minX+(t.maxY-t.minY)}function yr(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function _r(t,e){const n=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,r-n)*Math.max(0,o-i)}function vr(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function xr(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Sr(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function wr(t,e,n,i,r){const o=[e,n];for(;o.length;){if((n=o.pop())-(e=o.pop())<=i)continue;const s=e+Math.ceil((n-e)/i/2)*i;or(t,s,e,n,r),o.push(e,s,s,n)}}let Cr=0;const br=1<<Cr++,Ir=1<<Cr++,Er=1<<Cr++,Pr=1<<Cr++,Tr=1<<Cr++,Mr=1<<Cr++,kr=Math.pow(2,6)-1,Rr={[br]:"boolean",[Ir]:"number",[Er]:"string",[Pr]:"color",[Tr]:"number[]",[Mr]:"size"},Fr=Object.keys(Rr).map(Number).sort(i);function Or(t){const e=[];for(const n of Fr)Ar(t,n)&&e.push(Rr[n]);return 0===e.length?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function Ar(t,e){return(t&e)===e}function Lr(t,e){return t===e}class Dr{constructor(t,e){if(!function(t){return t in Rr}(t))throw new Error(`literal expressions must have a specific type, got ${Or(t)}`);this.type=t,this.value=e}}class Gr{constructor(t,e,...n){this.type=t,this.operator=e,this.args=n}}function jr(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1}}function Vr(t,e,n){switch(typeof t){case"boolean":if(Lr(e,Er))return new Dr(Er,t?"true":"false");if(!Ar(e,br))throw new Error(`got a boolean, but expected ${Or(e)}`);return new Dr(br,t);case"number":if(Lr(e,Mr))return new Dr(Mr,Oi(t));if(Lr(e,br))return new Dr(br,!!t);if(Lr(e,Er))return new Dr(Er,t.toString());if(!Ar(e,Ir))throw new Error(`got a number, but expected ${Or(e)}`);return new Dr(Ir,t);case"string":if(Lr(e,Pr))return new Dr(Pr,Fe(t));if(Lr(e,br))return new Dr(br,!!t);if(!Ar(e,Er))throw new Error(`got a string, but expected ${Or(e)}`);return new Dr(Er,t)}if(!Array.isArray(t))throw new Error("expression must be an array or a primitive value");if(0===t.length)throw new Error("empty expression");if("string"==typeof t[0])return function(t,e,n){const i=t[0],r=Ao[i];if(!r)throw new Error(`unknown operator: ${i}`);return r(t,e,n)}(t,e,n);for(const e of t)if("number"!=typeof e)throw new Error("expected an array of numbers");if(Lr(e,Mr)){if(2!==t.length)throw new Error(`expected an array of two values for a size, got ${t.length}`);return new Dr(Mr,t)}if(Lr(e,Pr)){if(3===t.length)return new Dr(Pr,[...t,1]);if(4===t.length)return new Dr(Pr,t);throw new Error(`expected an array of 3 or 4 values for a color, got ${t.length}`)}if(!Ar(e,Tr))throw new Error(`got an array of numbers, but expected ${Or(e)}`);return new Dr(Tr,t)}const Nr="get",Wr="var",Br="concat",Xr="geometry-type",Yr="line-metric",zr="any",Ur="all",Hr="!",qr="resolution",$r="zoom",Zr="time",Kr="==",Jr="!=",Qr=">",to=">=",eo="<",no="<=",io="*",ro="/",oo="+",so="-",ao="clamp",lo="%",ho="^",co="abs",uo="floor",fo="ceil",go="round",po="sin",mo="cos",yo="atan",_o="sqrt",vo="match",xo="between",So="interpolate",wo="coalesce",Co="case",bo="in",Io="number",Eo="string",Po="array",To="color",Mo="id",ko="band",Ro="palette",Fo="to-string",Oo="has",Ao={[Nr]:Bo(jo(1,1/0),Lo),[Wr]:Bo(jo(1,1),function(t,e,n){const i=t[1];if("string"!=typeof i)throw new Error("expected a string argument for var operation");return n.variables.add(i),[new Dr(Er,i)]}),[Oo]:Bo(jo(1,1/0),Lo),[Mo]:Bo(function(t,e,n){n.featureId=!0},Go),[Br]:Bo(jo(2,1/0),No(Er)),[Xr]:Bo(function(t,e,n){n.geometryType=!0},Go),[Yr]:Bo(function(t,e,n){n.mCoordinate=!0},Go),[qr]:Bo(Do,Go),[$r]:Bo(Do,Go),[Zr]:Bo(Do,Go),[zr]:Bo(jo(2,1/0),No(br)),[Ur]:Bo(jo(2,1/0),No(br)),[Hr]:Bo(jo(1,1),No(br)),[Kr]:Bo(jo(2,2),No(kr)),[Jr]:Bo(jo(2,2),No(kr)),[Qr]:Bo(jo(2,2),No(Ir)),[to]:Bo(jo(2,2),No(Ir)),[eo]:Bo(jo(2,2),No(Ir)),[no]:Bo(jo(2,2),No(Ir)),[io]:Bo(jo(2,1/0),Vo),[wo]:Bo(jo(2,1/0),Vo),[ro]:Bo(jo(2,2),No(Ir)),[oo]:Bo(jo(2,1/0),No(Ir)),[so]:Bo(jo(2,2),No(Ir)),[ao]:Bo(jo(3,3),No(Ir)),[lo]:Bo(jo(2,2),No(Ir)),[ho]:Bo(jo(2,2),No(Ir)),[co]:Bo(jo(1,1),No(Ir)),[uo]:Bo(jo(1,1),No(Ir)),[fo]:Bo(jo(1,1),No(Ir)),[go]:Bo(jo(1,1),No(Ir)),[po]:Bo(jo(1,1),No(Ir)),[mo]:Bo(jo(1,1),No(Ir)),[yo]:Bo(jo(1,2),No(Ir)),[_o]:Bo(jo(1,1),No(Ir)),[vo]:Bo(jo(4,1/0),Wo,function(t,e,n){const i=t.length-1,r=Er|Ir|br,o=Vr(t[1],r,n),s=Vr(t[t.length-1],e,n),a=new Array(i-2);for(let e=0;e<i-2;e+=2){try{const i=Vr(t[e+2],o.type,n);a[e]=i}catch(t){throw new Error(`failed to parse argument ${e+1} of match expression: ${t.message}`)}try{const i=Vr(t[e+3],s.type,n);a[e+1]=i}catch(t){throw new Error(`failed to parse argument ${e+2} of match expression: ${t.message}`)}}return[o,...a,s]}),[xo]:Bo(jo(3,3),No(Ir)),[So]:Bo(jo(6,1/0),Wo,function(t,e,n){const i=t[1];let r;switch(i[0]){case"linear":r=1;break;case"exponential":const t=i[1];if("number"!=typeof t||t<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(t)} instead`);r=t;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const o=new Dr(Ir,r);let s;try{s=Vr(t[2],Ir,n)}catch(t){throw new Error(`failed to parse argument 1 in interpolate expression: ${t.message}`)}const a=new Array(t.length-3);for(let i=0;i<a.length;i+=2){try{const e=Vr(t[i+3],Ir,n);a[i]=e}catch(t){throw new Error(`failed to parse argument ${i+2} for interpolate expression: ${t.message}`)}try{const r=Vr(t[i+4],e,n);a[i+1]=r}catch(t){throw new Error(`failed to parse argument ${i+3} for interpolate expression: ${t.message}`)}}return[o,s,...a]}),[Co]:Bo(jo(3,1/0),function(t,e,n){const i=t[0],r=t.length-1;if(r%2==0)throw new Error(`expected an odd number of arguments for ${i}, got ${r} instead`)},function(t,e,n){const i=Vr(t[t.length-1],e,n),r=new Array(t.length-1);for(let e=0;e<r.length-1;e+=2){try{const i=Vr(t[e+1],br,n);r[e]=i}catch(t){throw new Error(`failed to parse argument ${e} of case expression: ${t.message}`)}try{const o=Vr(t[e+2],i.type,n);r[e+1]=o}catch(t){throw new Error(`failed to parse argument ${e+1} of case expression: ${t.message}`)}}return r[r.length-1]=i,r}),[bo]:Bo(jo(2,2),function(t,e,n){let i,r=t[2];if(!Array.isArray(r))throw new Error('the second argument for the "in" operator must be an array');if("literal"===r[0]){if(r=r[1],!Array.isArray(r))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array')}else if("string"==typeof r[0])throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');i="string"==typeof r[0]?Er:Ir;const o=new Array(r.length);for(let t=0;t<o.length;t++)try{const e=Vr(r[t],i,n);o[t]=e}catch(e){throw new Error(`failed to parse haystack item ${t} for "in" expression: ${e.message}`)}return[Vr(t[1],i,n),...o]}),[Io]:Bo(jo(1,1/0),No(kr)),[Eo]:Bo(jo(1,1/0),No(kr)),[Po]:Bo(jo(1,1/0),No(Ir)),[To]:Bo(jo(1,4),No(Ir)),[ko]:Bo(jo(1,3),No(Ir)),[Ro]:Bo(jo(2,2),function(t,e,n){let i;try{i=Vr(t[1],Ir,n)}catch(t){throw new Error(`failed to parse first argument in palette expression: ${t.message}`)}const r=t[2];if(!Array.isArray(r))throw new Error("the second argument of palette must be an array");const o=new Array(r.length);for(let t=0;t<o.length;t++){let e;try{e=Vr(r[t],Pr,n)}catch(e){throw new Error(`failed to parse color at index ${t} in palette expression: ${e.message}`)}if(!(e instanceof Dr))throw new Error(`the palette color at index ${t} must be a literal value`);o[t]=e}return[i,...o]}),[Fo]:Bo(jo(1,1),No(br|Ir|Er|Pr))};function Lo(t,e,n){const i=t.length-1,r=new Array(i);for(let e=0;e<i;++e){const i=t[e+1];switch(typeof i){case"number":r[e]=new Dr(Ir,i);break;case"string":r[e]=new Dr(Er,i);break;default:throw new Error(`expected a string key or numeric array index for a get operation, got ${i}`)}0===e&&n.properties.add(String(i))}return r}function Do(t,e,n){n.mapState=!0}function Go(t,e,n){const i=t[0];if(1!==t.length)throw new Error(`expected no arguments for ${i} operation`);return[]}function jo(t,e){return function(n,i,r){const o=n[0],s=n.length-1;if(t===e){if(s!==t)throw new Error(`expected ${t} argument${1===t?"":"s"} for ${o}, got ${s}`)}else if(s<t||s>e)throw new Error(`expected ${e===1/0?`${t} or more`:`${t} to ${e}`} arguments for ${o}, got ${s}`)}}function Vo(t,e,n){const i=t.length-1,r=new Array(i);for(let o=0;o<i;++o){const i=Vr(t[o+1],e,n);r[o]=i}return r}function No(t){return function(e,n,i){const r=e.length-1,o=new Array(r);for(let n=0;n<r;++n){const r=Vr(e[n+1],t,i);o[n]=r}return o}}function Wo(t,e,n){const i=t[0],r=t.length-1;if(r%2==1)throw new Error(`expected an even number of arguments for operation ${i}, got ${r} instead`)}function Bo(...t){return function(e,n,i){const r=e[0];let o;for(let r=0;r<t.length;r++){const s=t[r](e,n,i);if(r==t.length-1){if(!s)throw new Error("expected last argument validator to return the parsed args");o=s}}return new Gr(n,r,...o)}}function Xo(t){if(!t)return"";const e=t.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Xo(t.getGeometries()[0]);default:return""}}function Yo(t,e,n){return zo(Vr(t,e,n),n)}function zo(t,e){if(t instanceof Dr){if(t.type===Pr&&"string"==typeof t.value){const e=Fe(t.value);return function(){return e}}return function(){return t.value}}const n=t.operator;switch(n){case Io:case Eo:case wo:return function(t,e){const n=t.operator,i=t.args.length,r=new Array(i);for(let n=0;n<i;++n)r[n]=zo(t.args[n],e);switch(n){case wo:return t=>{for(let e=0;e<i;++e){const n=r[e](t);if(null!=n)return n}throw new Error("Expected one of the values to be non-null")};case Io:case Eo:return t=>{for(let e=0;e<i;++e){const i=r[e](t);if(typeof i===n)return i}throw new Error(`Expected one of the values to be a ${n}`)};default:throw new Error(`Unsupported assertion operator ${n}`)}}(t,e);case Nr:case Wr:case Oo:return function(t){const e=t.args[0].value;switch(t.operator){case Nr:return n=>{const i=t.args;let r=n.properties[e];for(let t=1,e=i.length;t<e;++t)r=r[i[t].value];return r};case Wr:return t=>t.variables[e];case Oo:return n=>{const i=t.args;if(!(e in n.properties))return!1;let r=n.properties[e];for(let t=1,e=i.length;t<e;++t){const e=i[t].value;if(!r||!Object.hasOwn(r,e))return!1;r=r[e]}return!0};default:throw new Error(`Unsupported accessor operator ${t.operator}`)}}(t);case"id":return t=>t.featureId;case Xr:return t=>t.geometryType;case Br:{const n=t.args.map(t=>zo(t,e));return t=>"".concat(...n.map(e=>e(t).toString()))}case qr:return t=>t.resolution;case zr:case Ur:case xo:case bo:case"!":return function(t,e){const n=t.operator,i=t.args.length,r=new Array(i);for(let n=0;n<i;++n)r[n]=zo(t.args[n],e);switch(n){case zr:return t=>{for(let e=0;e<i;++e)if(r[e](t))return!0;return!1};case Ur:return t=>{for(let e=0;e<i;++e)if(!r[e](t))return!1;return!0};case xo:return t=>{const e=r[0](t),n=r[1](t),i=r[2](t);return e>=n&&e<=i};case bo:return t=>{const e=r[0](t);for(let n=1;n<i;++n)if(e===r[n](t))return!0;return!1};case"!":return t=>!r[0](t);default:throw new Error(`Unsupported logical operator ${n}`)}}(t,e);case Kr:case Jr:case"<":case no:case">":case to:return function(t,e){const n=t.operator,i=zo(t.args[0],e),r=zo(t.args[1],e);switch(n){case Kr:return t=>i(t)===r(t);case Jr:return t=>i(t)!==r(t);case"<":return t=>i(t)<r(t);case no:return t=>i(t)<=r(t);case">":return t=>i(t)>r(t);case to:return t=>i(t)>=r(t);default:throw new Error(`Unsupported comparison operator ${n}`)}}(t,e);case"*":case"/":case"+":case"-":case ao:case"%":case"^":case co:case uo:case fo:case go:case po:case mo:case yo:case _o:return function(t,e){const n=t.operator,i=t.args.length,r=new Array(i);for(let n=0;n<i;++n)r[n]=zo(t.args[n],e);switch(n){case"*":return t=>{let e=1;for(let n=0;n<i;++n)e*=r[n](t);return e};case"/":return t=>r[0](t)/r[1](t);case"+":return t=>{let e=0;for(let n=0;n<i;++n)e+=r[n](t);return e};case"-":return t=>r[0](t)-r[1](t);case ao:return t=>{const e=r[0](t),n=r[1](t);if(e<n)return n;const i=r[2](t);return e>i?i:e};case"%":return t=>r[0](t)%r[1](t);case"^":return t=>Math.pow(r[0](t),r[1](t));case co:return t=>Math.abs(r[0](t));case uo:return t=>Math.floor(r[0](t));case fo:return t=>Math.ceil(r[0](t));case go:return t=>Math.round(r[0](t));case po:return t=>Math.sin(r[0](t));case mo:return t=>Math.cos(r[0](t));case yo:return 2===i?t=>Math.atan2(r[0](t),r[1](t)):t=>Math.atan(r[0](t));case _o:return t=>Math.sqrt(r[0](t));default:throw new Error(`Unsupported numeric operator ${n}`)}}(t,e);case Co:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=zo(t.args[r],e);return t=>{for(let e=0;e<n-1;e+=2)if(i[e](t))return i[e+1](t);return i[n-1](t)}}(t,e);case vo:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=zo(t.args[r],e);return t=>{const e=i[0](t);for(let r=1;r<n-1;r+=2)if(e===i[r](t))return i[r+1](t);return i[n-1](t)}}(t,e);case So:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=zo(t.args[r],e);return t=>{const e=i[0](t),r=i[1](t);let o,s;for(let a=2;a<n;a+=2){const n=i[a](t);let l=i[a+1](t);const h=Array.isArray(l);if(h&&(l=Ee(l)),n>=r)return 2===a?l:h?Ho(e,r,o,s,n,l):Uo(e,r,o,s,n,l);o=n,s=l}return s}}(t,e);case Fo:return function(t,e){const n=t.operator,i=t.args.length,r=new Array(i);for(let n=0;n<i;++n)r[n]=zo(t.args[n],e);if(n===Fo)return e=>{const n=r[0](e);return t.args[0].type===Pr?Ae(n):n.toString()};throw new Error(`Unsupported convert operator ${n}`)}(t,e);default:throw new Error(`Unsupported operator ${n}`)}}function Uo(t,e,n,i,r,o){const s=r-n;if(0===s)return i;const a=e-n;return i+(1===t?a/s:(Math.pow(t,a)-1)/(Math.pow(t,s)-1))*(o-i)}function Ho(t,e,n,i,r,o){if(0===r-n)return i;const s=Re(i),a=Re(o);let l=a[2]-s[2];return l>180?l-=360:l<-180&&(l+=360),function(t){const e=(t[0]+16)/116,n=t[1],i=t[2]*Math.PI/180,r=Te(e),o=Te(e+n/500*Math.cos(i)),s=Te(e-n/200*Math.sin(i)),a=Pe(3.021973625*o-1.617392459*r-.404875592*s),l=Pe(-.943766287*o+1.916279586*r+.027607165*s),h=Pe(.069407491*o-.22898585*r+1.159737864*s);return[D(a+.5|0,0,255),D(l+.5|0,0,255),D(h+.5|0,0,255),t[3]]}([Uo(t,e,n,s[0],r,a[0]),Uo(t,e,n,s[1],r,a[1]),s[2]+Uo(t,e,n,0,r,l),Uo(t,e,n,i[3],r,o[3])])}class qo extends Li{constructor(t){super({opacity:1,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,rotation:void 0!==t.rotation?t.rotation:0,scale:void 0!==t.scale?t.scale:1,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=void 0!==t.fill?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=void 0!==t.angle?t.angle:0,this.stroke_=void 0!==t.stroke?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?1:2,1===this.imageState_&&this.ready().then(()=>this.imageState_=2),this.render()}clone(){const t=this.getScale(),e=new qo({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(),n=this.getScaleArray();return[t[0]/2-e[0]/n[0],t[1]/2+e[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),n=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let i=Ue.get(n,null)?.getImage(1);if(!i){const e=this.renderOptions_,r=Math.ceil(e.size*t),o=J(r,r);this.draw_(e,o,t),i=o.canvas;const s=new Ze(i,void 0,null,2,null);Ue.set(n,null,s),createImageBitmap(i).then(t=>{s.setImage(t)})}return i}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,n){if(0===e||this.points_===1/0||"bevel"!==t&&"miter"!==t)return e;let i=this.radius,r=void 0===this.radius2_?i:this.radius2_;if(i<r){const t=i;i=r,r=t}const o=void 0===this.radius2_?this.points_:2*this.points_,s=2*Math.PI/o,a=r*Math.sin(s),l=i-Math.sqrt(r*r-a*a),h=Math.sqrt(a*a+l*l),c=h/a;if("miter"===t&&c<=n)return c*e;const u=e/2/c,d=e/2*(l/h),f=Math.sqrt((i+u)*(i+u)+d*d)-i;if(void 0===this.radius2_||"bevel"===t)return 2*f;const g=i*Math.sin(s),p=r-Math.sqrt(i*i-g*g),m=Math.sqrt(g*g+p*p)/g;if(m<=n){const t=m*e/2-r-i;return 2*Math.max(f,t)}return 2*f}createRenderOptions(){let t,e=xn,n=wn,i=0,r=null,o=0,s=0;this.stroke_&&(t=Ke(this.stroke_.getColor()??Cn),s=this.stroke_.getWidth()??1,r=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset()??0,n=this.stroke_.getLineJoin()??wn,e=this.stroke_.getLineCap()??xn,i=this.stroke_.getMiterLimit()??10);const a=this.calculateLineJoinSize_(n,s,i),l=Math.max(this.radius,this.radius2_||0);return{strokeStyle:t,strokeWidth:s,size:Math.ceil(2*l+a),lineCap:e,lineDash:r,lineDashOffset:o,lineJoin:n,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,n){if(e.scale(n,n),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let t=this.fill_.getColor();null===t&&(t=vn),e.fillStyle=Ke(t),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 n=this.fill_.getColor(),i=0;"string"==typeof n&&(n=Oe(n)),null===n?i=1:Array.isArray(n)&&(i=4===n.length?n[3]:1),0===i&&(e=J(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const n=this.radius;if(e===1/0)t.arc(0,0,n,0,2*Math.PI);else{const i=void 0===this.radius2_?n:this.radius2_;void 0!==this.radius2_&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let s=0;s<e;s++){const e=r+s*o,a=s%2==0?n:i;t.lineTo(a*Math.cos(e),a*Math.sin(e))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=vn,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()}}const $o=qo;class Zo extends $o{constructor(t){super({points:1/0,fill:(t=t||{radius:5}).fill,radius:t.radius,stroke:t.stroke,scale:void 0!==t.scale?t.scale:1,rotation:void 0!==t.rotation?t.rotation:0,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new Zo({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}}const Ko=Zo;class Jo{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,void 0!==t.color&&this.setColor(t.color)}clone(){const t=this.getColor();return new Jo({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(null!==t&&"object"==typeof t&&"src"in t){const e=$e(null,t.src,{crossOrigin:"anonymous"},void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),0===e.getImageState()&&e.load(),1===e.getImageState()&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?un(t):"object"==typeof t&&"src"in t?t.src+":"+t.offset:Oe(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}const Qo=Jo;class ts{constructor(t){t=t||{},this.color_=void 0!==t.color?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=void 0!==t.lineDash?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){const t=this.getColor();return new ts({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(),offset:this.getOffset(),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_}getOffset(){return this.offset_}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}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}}const es=ts;class ns{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=ss,void 0!==t.geometry&&this.setGeometry(t.geometry),this.fill_=void 0!==t.fill?t.fill:null,this.image_=void 0!==t.image?t.image:null,this.renderer_=void 0!==t.renderer?t.renderer:null,this.hitDetectionRenderer_=void 0!==t.hitDetectionRenderer?t.hitDetectionRenderer:null,this.stroke_=void 0!==t.stroke?t.stroke:null,this.text_=void 0!==t.text?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&"object"==typeof t&&(t=t.clone()),new ns({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=ss,this.geometry_=t}setZIndex(t){this.zIndex_=t}}let is=null;function rs(t,e){if(!is){const t=new Qo({color:"rgba(255,255,255,0.4)"}),e=new es({color:"#3399CC",width:1.25});is=[new ns({image:new Ko({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return is}function os(){const t={},e=[255,255,255,1],n=[0,153,255,1];return t.Polygon=[new ns({fill:new Qo({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new ns({stroke:new es({color:e,width:5})}),new ns({stroke:new es({color:n,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new ns({image:new Ko({radius:6,fill:new Qo({color:n}),stroke:new es({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function ss(t){return t.getGeometry()}const as=ns;class ls{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_=Oi(void 0!==t.scale?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=void 0!==t.fill?t.fill:new Qo({color:"#333"}),this.maxAngle_=void 0!==t.maxAngle?t.maxAngle:Math.PI/4,this.placement_=void 0!==t.placement?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=void 0!==t.stroke?t.stroke:null,this.offsetX_=void 0!==t.offsetX?t.offsetX:0,this.offsetY_=void 0!==t.offsetY?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=void 0===t.padding?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new ls({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()instanceof Qo?this.getFill().clone():this.getFill(),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_=Oi(void 0!==t?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}const hs=ls;function cs(t){return!0}function us(t){const e=jr(),n=function(t,e){const n=t.length,i=new Array(n);for(let r=0;r<n;++r){const n=t[r],o="filter"in n?Yo(n.filter,br,e):cs;let s;if(Array.isArray(n.style)){const t=n.style.length;s=new Array(t);for(let i=0;i<t;++i)s[i]=fs(n.style[i],e)}else s=[fs(n.style,e)];i[r]={filter:o,styles:s}}return function(e){const r=[];let o=!1;for(let s=0;s<n;++s)if((0,i[s].filter)(e)&&(!t[s].else||!o)){o=!0;for(const t of i[s].styles){const n=t(e);n&&r.push(n)}}return r}}(t,e),i={variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""};return function(t,r){if(i.properties=t.getPropertiesInternal(),i.resolution=r,e.featureId){const e=t.getId();i.featureId=void 0!==e?e:null}return e.geometryType&&(i.geometryType=Xo(t.getGeometry())),n(i)}}function ds(t){const e=jr(),n=t.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=fs(t[r],e);const r={variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""},o=new Array(n);return function(t,s){if(r.properties=t.getPropertiesInternal(),r.resolution=s,e.featureId){const e=t.getId();r.featureId=void 0!==e?e:null}let a=0;for(let t=0;t<n;++t){const e=i[t](r);e&&(o[a]=e,a+=1)}return o.length=a,o}}function fs(t,e){const n=gs(t,"",e),i=ps(t,"",e),r=function(t,e){const n="text-",i=_s(t,n+"value",e);if(!i)return null;const r=gs(t,n,e),o=gs(t,n+"background-",e),s=ps(t,n,e),a=ps(t,n+"background-",e),l=_s(t,n+"font",e),h=ys(t,n+"max-angle",e),c=ys(t,n+"offset-x",e),u=ys(t,n+"offset-y",e),d=vs(t,n+"overflow",e),f=_s(t,n+"placement",e),g=ys(t,n+"repeat",e),p=bs(t,n+"scale",e),m=vs(t,n+"rotate-with-view",e),y=ys(t,n+"rotation",e),_=_s(t,n+"align",e),v=_s(t,n+"justify",e),x=_s(t,n+"baseline",e),S=vs(t,n+"keep-upright",e),w=Ss(t,n+"padding",e),C=Ts(t,n+"declutter-mode"),b=new hs({declutterMode:C});return function(t){if(b.setText(i(t)),r&&b.setFill(r(t)),o&&b.setBackgroundFill(o(t)),s&&b.setStroke(s(t)),a&&b.setBackgroundStroke(a(t)),l&&b.setFont(l(t)),h&&b.setMaxAngle(h(t)),c&&b.setOffsetX(c(t)),u&&b.setOffsetY(u(t)),d&&b.setOverflow(d(t)),f){const e=f(t);if("point"!==e&&"line"!==e)throw new Error("Expected point or line for text-placement");b.setPlacement(e)}if(g&&b.setRepeat(g(t)),p&&b.setScale(p(t)),m&&b.setRotateWithView(m(t)),y&&b.setRotation(y(t)),_){const e=_(t);if("left"!==e&&"center"!==e&&"right"!==e&&"end"!==e&&"start"!==e)throw new Error("Expected left, right, center, start, or end for text-align");b.setTextAlign(e)}if(v){const e=v(t);if("left"!==e&&"right"!==e&&"center"!==e)throw new Error("Expected left, right, or center for text-justify");b.setJustify(e)}if(x){const e=x(t);if("bottom"!==e&&"top"!==e&&"middle"!==e&&"alphabetic"!==e&&"hanging"!==e)throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");b.setTextBaseline(e)}return w&&b.setPadding(w(t)),S&&b.setKeepUpright(S(t)),b}}(t,e),o=function(t,e){return"icon-src"in t?function(t,e){const n="icon-",i=n+"src",r=ks(t[i],i),o=ws(t,n+"anchor",e),s=bs(t,n+"scale",e),a=ys(t,n+"opacity",e),l=ws(t,n+"displacement",e),h=ys(t,n+"rotation",e),c=vs(t,n+"rotate-with-view",e),u=Es(t,n+"anchor-origin"),d=Ps(t,n+"anchor-x-units"),f=Ps(t,n+"anchor-y-units"),g=ms(t,n+"color");let p,m=null;void 0!==g&&(Array.isArray(g)&&g.length>0&&"string"==typeof g[0]?m=xs(t,n+"color",e):p=Fs(g,n+"color"));const y=function(t,e){const n=t[e];if(void 0!==n){if("string"!=typeof n)throw new Error(`Expected a string for ${e}`);return n}}(t,n+"cross-origin"),_=function(t,e){const n=t[e];if(void 0!==n)return Ms(n,e)}(t,n+"offset"),v=Es(t,n+"offset-origin"),x=Is(t,n+"width"),S=Is(t,n+"height"),w=function(t,e){const n=t[e];if(void 0!==n){if("number"==typeof n)return Oi(n);if(!Array.isArray(n))throw new Error(`Expected a number or size array for ${e}`);if(2!==n.length||"number"!=typeof n[0]||"number"!=typeof n[1])throw new Error(`Expected a number or size array for ${e}`);return n}}(t,n+"size"),C={src:r,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,crossOrigin:y,offset:_,offsetOrigin:v,height:S,width:x,size:w,declutterMode:Ts(t,n+"declutter-mode")};let b=null;return function(t){if(b)m&&b.setColor(m(t));else{const e=m?m(t):p;b=new ji(void 0!==e?Object.assign({},C,{color:e}):Object.assign({},C))}return a&&b.setOpacity(a(t)),l&&b.setDisplacement(l(t)),h&&b.setRotation(h(t)),c&&b.setRotateWithView(c(t)),s&&b.setScale(s(t)),o&&b.setAnchor(o(t)),b}}(t,e):"shape-points"in t?function(t,e){const n="shape-",i=n+"points",r=n+"radius",o=Rs(t[i],i);if(!(r in t))throw new Error(`Expected a number for ${r}`);const s=ys(t,r,e),a="number"==typeof t[r]?t[r]:5,l=n+"radius2",h=ys(t,l,e),c="number"==typeof t[l]?t[l]:void 0,u=gs(t,n,e),d=ps(t,n,e),f=bs(t,n+"scale",e),g=ws(t,n+"displacement",e),p=ys(t,n+"rotation",e),m=vs(t,n+"rotate-with-view",e),y=Is(t,n+"angle"),_=Ts(t,n+"declutter-mode"),v=new $o({points:o,radius:a,radius2:c,angle:y,declutterMode:_});return function(t){return s&&v.setRadius(s(t)),h&&v.setRadius2(h(t)),u&&v.setFill(u(t)),d&&v.setStroke(d(t)),g&&v.setDisplacement(g(t)),p&&v.setRotation(p(t)),m&&v.setRotateWithView(m(t)),f&&v.setScale(f(t)),v}}(t,e):"circle-radius"in t?function(t,e){const n="circle-",i=gs(t,n,e),r=ps(t,n,e),o=ys(t,n+"radius",e),s=bs(t,n+"scale",e),a=ws(t,n+"displacement",e),l=ys(t,n+"rotation",e),h=vs(t,n+"rotate-with-view",e),c=Ts(t,n+"declutter-mode"),u=new Ko({radius:5,declutterMode:c});return function(t){return o&&u.setRadius(o(t)),i&&u.setFill(i(t)),r&&u.setStroke(r(t)),a&&u.setDisplacement(a(t)),l&&u.setRotation(l(t)),h&&u.setRotateWithView(h(t)),s&&u.setScale(s(t)),u}}(t,e):null}(t,e),s=ys(t,"z-index",e);if(!(n||i||r||o||Be(t)))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(t));const a=new as;return function(t){let e=!0;if(n){const i=n(t);i&&(e=!1),a.setFill(i)}if(i){const n=i(t);n&&(e=!1),a.setStroke(n)}if(r){const n=r(t);n&&(e=!1),a.setText(n)}if(o){const n=o(t);n&&(e=!1),a.setImage(n)}return s&&a.setZIndex(s(t)),e?null:a}}function gs(t,e,n){let i;if(e+"fill-pattern-src"in t)i=function(t,e,n){const i=_s(t,e+"pattern-src",n),r=Cs(t,e+"pattern-offset",n),o=Cs(t,e+"pattern-size",n),s=xs(t,e+"color",n);return function(t){return{src:i(t),offset:r&&r(t),size:o&&o(t),color:s&&s(t)}}}(t,e+"fill-",n);else{if("none"===t[e+"fill-color"])return t=>null;i=xs(t,e+"fill-color",n)}if(!i)return null;const r=new Qo;return function(t){const e=i(t);return e===pe?null:(r.setColor(e),r)}}function ps(t,e,n){const i=ys(t,e+"stroke-width",n),r=xs(t,e+"stroke-color",n);if(!i&&!r)return null;const o=_s(t,e+"stroke-line-cap",n),s=_s(t,e+"stroke-line-join",n),a=Ss(t,e+"stroke-line-dash",n),l=ys(t,e+"stroke-line-dash-offset",n),h=ys(t,e+"stroke-miter-limit",n),c=ys(t,e+"stroke-offset",n),u=new es;return function(t){if(r){const e=r(t);if(e===pe)return null;u.setColor(e)}if(i&&u.setWidth(i(t)),o){const e=o(t);if("butt"!==e&&"round"!==e&&"square"!==e)throw new Error("Expected butt, round, or square line cap");u.setLineCap(e)}if(s){const e=s(t);if("bevel"!==e&&"round"!==e&&"miter"!==e)throw new Error("Expected bevel, round, or miter line join");u.setLineJoin(e)}return a&&u.setLineDash(a(t)),l&&u.setLineDashOffset(l(t)),h&&u.setMiterLimit(h(t)),c&&u.setOffset(c(t)),u}}function ms(t,e){if(!(e in t))return;const n=t[e];return void 0===n?void 0:n}function ys(t,e,n){const i=ms(t,e);if(void 0===i)return;const r=Yo(i,Ir,n);return function(t){return Rs(r(t),e)}}function _s(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Er,n);return function(t){return ks(r(t),e)}}function vs(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,br,n);return function(t){const n=r(t);if("boolean"!=typeof n)throw new Error(`Expected a boolean for ${e}`);return n}}function xs(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Pr,n);return function(t){return Fs(r(t),e)}}function Ss(t,e,n){const i=ms(t,e);if(void 0===i)return null;if(Array.isArray(i)&&(0===i.length||"string"!=typeof i[0])){const t=i.map((t,i)=>{if("number"==typeof t)return()=>t;const r=Yo(t,Ir,n);return function(t){return Rs(r(t),`${e}[${i}]`)}});return function(e){const n=new Array(t.length);for(let i=0;i<t.length;++i)n[i]=t[i](e);return n}}const r=Yo(i,Tr,n);return function(t){return Ms(r(t),e)}}function ws(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Tr,n);return function(t){const n=Ms(r(t),e);if(2!==n.length)throw new Error(`Expected two numbers for ${e}`);return n}}function Cs(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Tr,n);return function(t){return Os(r(t),e)}}function bs(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Tr|Ir,n);return function(t){return n=r(t),i=e,"number"==typeof n?n:Os(n,i);var n,i}}function Is(t,e){const n=t[e];if(void 0!==n){if("number"!=typeof n)throw new Error(`Expected a number for ${e}`);return n}}function Es(t,e){const n=t[e];if(void 0!==n){if("bottom-left"!==n&&"bottom-right"!==n&&"top-left"!==n&&"top-right"!==n)throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return n}}function Ps(t,e){const n=t[e];if(void 0!==n){if("pixels"!==n&&"fraction"!==n)throw new Error(`Expected pixels or fraction for ${e}`);return n}}function Ts(t,e){const n=t[e];if(void 0!==n){if("string"!=typeof n)throw new Error(`Expected a string for ${e}`);if("declutter"!==n&&"obstacle"!==n&&"none"!==n)throw new Error(`Expected declutter, obstacle, or none for ${e}`);return n}}function Ms(t,e){if(!Array.isArray(t))throw new Error(`Expected an array for ${e}`);const n=t.length;for(let i=0;i<n;++i)if("number"!=typeof t[i])throw new Error(`Expected an array of numbers for ${e}`);return t}function ks(t,e){if("string"!=typeof t)throw new Error(`Expected a string for ${e}`);return t}function Rs(t,e){if("number"!=typeof t)throw new Error(`Expected a number for ${e}`);return t}function Fs(t,e){if("string"==typeof t)return t;const n=Ms(t,e),i=n.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return n}function Os(t,e){const n=Ms(t,e);if(2!==n.length)throw new Error(`Expected an array of two numbers for ${e}`);return n}const As={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Ls(t,e,n){return function(i,r,o,s,a){if(!i)return;if(!r&&!e)return i;const l=e?0:o[0]*r,h=e?0:o[1]*r,c=a?a[0]:0,u=a?a[1]:0;let d=t[0]+l/2+c,f=t[2]-l/2+c,g=t[1]+h/2+u,p=t[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>p&&(g=(p+g)/2,p=g);let m=D(i[0],d,f),y=D(i[1],g,p);if(s&&n&&r){const t=30*r;m+=-t*Math.log(1+Math.max(0,d-i[0])/t)+t*Math.log(1+Math.max(0,i[0]-f)/t),y+=-t*Math.log(1+Math.max(0,g-i[1])/t)+t*Math.log(1+Math.max(0,i[1]-p)/t)}return[m,y]}}function Ds(t){return t}function Gs(t){return 1-function(t){return Math.pow(t,3)}(1-t)}function js(t){return 3*t*t-2*t*t*t}function Vs(t,e,n,i){let r=0;const o=t[n-i],s=t[n-i+1];let a=0,l=0;for(;e<n;e+=i){const n=t[e]-o,i=t[e+1]-s;r+=l*n-a*i,a=n,l=i}return r/2}function Ns(t,e,n,i){let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o];r+=Vs(t,e,s,i),e=s}return r}function Ws(t,e,n,i,r,o,s){const a=t[e],l=t[e+1],h=t[n]-a,c=t[n+1]-l;let u;if(0===h&&0===c)u=e;else{const d=((r-a)*h+(o-l)*c)/(h*h+c*c);if(d>1)u=n;else{if(d>0){for(let r=0;r<i;++r)s[r]=B(t[e+r],t[n+r],d);return void(s.length=i)}u=e}}for(let e=0;e<i;++e)s[e]=t[u+e];s.length=i}function Bs(t,e,n,i,r){let o=t[e],s=t[e+1];for(e+=i;e<n;e+=i){const n=t[e],i=t[e+1],a=j(o,s,n,i);a>r&&(r=a),o=n,s=i}return r}function Xs(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];r=Bs(t,e,s,i,r),e=s}return r}function Ys(t,e,n,i,r,o,s,a,l,h,c){if(e==n)return h;let u,d;if(0===r){if(d=j(s,a,t[e],t[e+1]),d<h){for(u=0;u<i;++u)l[u]=t[e+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=e+i;for(;f<n;)if(Ws(t,f-i,f,i,s,a,c),d=j(s,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))/r|0,1);if(o&&(Ws(t,n-i,e,i,s,a,c),d=j(s,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 zs(t,e,n,i,r,o,s,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=n.length;u<d;++u){const d=n[u];h=Ys(t,e,d,i,r,o,s,a,l,h,c),e=d}return h}function Us(t,e,n,i){for(let i=0,r=n.length;i<r;++i)t[e++]=n[i];return e}function Hs(t,e,n,i){for(let r=0,o=n.length;r<o;++r){const o=n[r];for(let n=0;n<i;++n)t[e++]=o[n]}return e}function qs(t,e,n,i,r){r=r||[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=Hs(t,e,n[s],i);r[o++]=a,e=a}return r.length=o,r}function $s(t,e,n,i,r){r=r||[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=qs(t,e,n[s],i,r[o]);0===a.length&&(a[0]=e),r[o++]=a,e=a[a.length-1]}return r.length=o,r}class Zs extends Yi{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,void 0===e||Array.isArray(t[0])?this.setCoordinates(t,e):this.setFlatCoordinates(e,t)}clone(){return new Zs(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Bs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ys(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,n,i))}getArea(){return Vs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Je(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=zn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Zs(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Hs(this.flatCoordinates,0,t,this.stride),this.changed()}}const Ks=Zs;class Js extends Yi{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new Js(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){const r=this.flatCoordinates,o=j(t,e,r[0],r[1]);if(o<i){const t=this.stride;for(let e=0;e<t;++e)n[e]=r[e];return n.length=t,o}return i}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return _(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return g(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Us(this.flatCoordinates,0,t,this.stride),this.changed()}}const Qs=Js;function ta(t,e,n,i,r){return!I(r,function(r){return!ea(t,e,n,i,r[0],r[1])})}function ea(t,e,n,i,r,o){let s=0,a=t[n-i],l=t[n-i+1];for(;e<n;e+=i){const n=t[e],i=t[e+1];l<=o?i>o&&(n-a)*(o-l)-(r-a)*(i-l)>0&&s++:i<=o&&(n-a)*(o-l)-(r-a)*(i-l)<0&&s--,a=n,l=i}return 0!==s}function na(t,e,n,i,r,o){if(0===n.length)return!1;if(!ea(t,e,n[0],i,r,o))return!1;for(let e=1,s=n.length;e<s;++e)if(ea(t,n[e-1],n[e],i,r,o))return!1;return!0}function ia(t,e,n,r,o,s,a){let l,h,c,u,d,f,g;const p=o[s+1],m=[];for(let i=0,o=n.length;i<o;++i){const o=n[i];for(u=t[o-r],f=t[o-r+1],l=e;l<o;l+=r)d=t[l],g=t[l+1],(p<=f&&g<=p||f<=p&&p<=g)&&(c=(p-f)/(g-f)*(d-u)+u,m.push(c)),u=d,f=g}let y=NaN,_=-1/0;for(m.sort(i),u=m[0],l=1,h=m.length;l<h;++l){d=m[l];const i=Math.abs(d-u);i>_&&(c=(u+d)/2,na(t,e,n,r,c,p)&&(y=c,_=i)),u=d}return isNaN(y)&&(y=o[s]),a?(a.push(y,p,_),a):[y,p,_]}function ra(t,e,n,i,r){let o=[];for(let s=0,a=n.length;s<a;++s){const a=n[s];o=ia(t,e,a,i,r,2*s,o),e=a[a.length-1]}return o}function oa(t,e,n,i,r){let o;for(e+=i;e<n;e+=i)if(o=r(t.slice(e-i,e),t.slice(e,e+i)),o)return o;return!1}function sa(t,e,n,i,r,o){return o=o??C([1/0,1/0,-1/0,-1/0],t,e,n,i),!!O(r,o)&&(o[0]>=r[0]&&o[2]<=r[2]||o[1]>=r[1]&&o[3]<=r[3]||oa(t,e,n,i,function(t,e){return function(t,e,n){let i=!1;const r=p(t,e),o=p(t,n);if(1===r||1===o)i=!0;else{const s=t[0],a=t[1],l=t[2],h=t[3],c=e[0],u=e[1],d=n[0],f=n[1],g=(f-u)/(d-c);let p,m;2&o&&!(2&r)&&(p=d-(f-h)/g,i=p>=s&&p<=l),i||!(4&o)||4&r||(m=f-(d-l)*g,i=m>=a&&m<=h),i||!(8&o)||8&r||(p=d-(f-a)/g,i=p>=s&&p<=l),i||!(16&o)||16&r||(m=f-(d-s)*g,i=m>=a&&m<=h)}return i}(r,t,e)}))}function aa(t,e,n,i,r){if(!function(t,e,n,i,r){return!!(sa(t,e,n,i,r)||ea(t,e,n,i,r[0],r[1])||ea(t,e,n,i,r[0],r[3])||ea(t,e,n,i,r[2],r[1])||ea(t,e,n,i,r[2],r[3]))}(t,e,n[0],i,r))return!1;if(1===n.length)return!0;for(let e=1,o=n.length;e<o;++e)if(ta(t,n[e-1],n[e],i,r)&&!sa(t,n[e-1],n[e],i,r))return!1;return!0}function la(t,e,n,i){for(;e<n-i;){for(let r=0;r<i;++r){const o=t[e+r];t[e+r]=t[n-i+r],t[n-i+r]=o}e+=i,n-=i}}function ha(t,e,n,i){let r=0,o=t[n-i],s=t[n-i+1];for(;e<n;e+=i){const n=t[e],i=t[e+1];r+=(n-o)*(i+s),o=n,s=i}return 0===r?void 0:r>0}function ca(t,e,n,i,r){r=void 0!==r&&r;for(let o=0,s=n.length;o<s;++o){const s=n[o],a=ha(t,e,s,i);if(0===o){if(r&&a||!r&&!a)return!1}else if(r&&!a||!r&&a)return!1;e=s}return!0}function ua(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];if(!ca(t,e,s,i,r))return!1;s.length&&(e=s[s.length-1])}return!0}function da(t,e,n,i,r){r=void 0!==r&&r;for(let o=0,s=n.length;o<s;++o){const s=n[o],a=ha(t,e,s,i);(0===o?r&&a||!r&&!a:r&&!a||!r&&a)&&la(t,e,s,i),e=s}return e}function fa(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o)e=da(t,e,n[o],i,r);return e}class ga extends Yi{constructor(t,e,n){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,void 0!==e&&n?(this.setFlatCoordinates(e,t),this.ends_=n):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?a(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new ga(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Xs(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zs(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,n,i))}containsXY(t,e){return na(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return Ns(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),da(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Qe(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=T(this.getExtent());this.flatInteriorPoint_=ia(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new Qs(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new Ks(this.flatCoordinates.slice(0===t?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,n=this.ends_,i=[];let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o],a=new Ks(e.slice(r,s),t);i.push(a),r=s}return i}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;ca(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=da(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=$n(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,n),new ga(e,"XY",n)}getType(){return"Polygon"}intersectsExtent(t){return aa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=qs(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}const pa=ga;function ma(t){if(A(t))throw new Error("Cannot create polygon from empty extent");const e=t[0],n=t[1],i=t[2],r=t[3],o=[e,n,e,r,i,r,i,n,e,n];return new ga(o,"XY",[o.length])}function ya(t,e,n){e=e||32;const i=t.getStride(),r=t.getLayout(),o=t.getCenter(),s=i*(e+1),a=new Array(s);for(let t=0;t<s;t+=i){a[t]=0,a[t+1]=0;for(let e=2;e<i;e++)a[t+e]=o[e]}const l=[a.length],h=new ga(a,r,l);return function(t,e,n,i){const r=t.getFlatCoordinates(),o=t.getStride(),s=r.length/o-1,a=i||0;for(let t=0;t<=s;++t){const i=t*o,l=a+2*W(t,s)*Math.PI/s;r[i]=e[0]+n*Math.cos(l),r[i+1]=e[1]+n*Math.sin(l)}t.changed()}(h,o,t.getRadius(),n),h}function _a(t,e,n,i){const r=F(e)/n[0],o=M(e)/n[1];return i?Math.min(t,Math.max(r,o)):Math.min(t,Math.min(r,o))}function va(t,e,n){let i=Math.min(t,e);return i*=Math.log(1+50*Math.max(0,t/e-1))/50+1,n&&(i=Math.max(i,n),i/=Math.log(1+50*Math.max(0,n/t-1))/50+1),D(i,n/2,2*e)}function xa(t,e,n,i,r){return n=void 0===n||n,function(o,s,a,l){if(void 0!==o){const s=i?_a(t,i,a,r):t;return n&&l?va(o,s,e):D(o,e,s)}}}function Sa(t){if(void 0!==t)return 0}function wa(t){if(void 0!==t)return t}function Ca(t,e){setTimeout(function(){t(e)},0)}function ba(t){return!(t.sourceCenter&&t.targetCenter&&!U(t.sourceCenter,t.targetCenter))&&t.sourceResolution===t.targetResolution&&t.sourceRotation===t.targetRotation}function Ia(t,e,n,i,r){const o=Math.cos(-r);let s=Math.sin(-r),a=t[0]*o-t[1]*s,l=t[1]*o+t[0]*s;return a+=(e[0]/2-n[0])*i,l+=(n[1]-e[1]/2)*i,s=-s,[a*o-l*s,l*o+a*s]}const Ea=class extends fn{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Jt(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&&function(t){Ht=!(void 0===t||t)}(),t.center&&(t.center=se(t.center,this.projection_)),t.extent&&(t.extent=le(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const t in As)delete e[t];this.setProperties(e,!0);const n=function(t){let e,n,i;let r=void 0!==t.minZoom?t.minZoom:0,s=void 0!==t.maxZoom?t.maxZoom:28;const a=void 0!==t.zoomFactor?t.zoomFactor:2,l=void 0!==t.multiWorld&&t.multiWorld,h=void 0===t.smoothResolutionConstraint||t.smoothResolutionConstraint,c=void 0!==t.showFullExtent&&t.showFullExtent,u=Jt(t.projection,"EPSG:3857"),d=u.getExtent();let f=t.constrainOnlyCenter,g=t.extent;if(l||g||!u.isGlobal()||(f=!1,g=d),void 0!==t.resolutions){const a=t.resolutions;n=a[r],i=void 0!==a[s]?a[s]:a[a.length-1],e=t.constrainResolution?function(t,e,n,i){return e=void 0===e||e,function(r,s,a,l){if(void 0!==r){const h=t[0],c=t[t.length-1],u=n?_a(h,n,a,i):h;if(l)return e?va(r,u,c):D(r,c,u);const d=Math.min(u,r),f=Math.floor(o(t,d,s));return t[f]>u&&f<t.length-1?t[f+1]:t[f]}}}(a,h,!f&&g,c):xa(n,i,h,!f&&g,c)}else{const o=(d?Math.max(F(d),M(d)):360*it.degrees/u.getMetersPerUnit())/256/Math.pow(2,0),l=o/Math.pow(2,28);n=t.maxResolution,void 0!==n?r=0:n=o/Math.pow(a,r),i=t.minResolution,void 0===i&&(i=void 0!==t.maxZoom?void 0!==t.maxResolution?n/Math.pow(a,s):o/Math.pow(a,s):l),s=r+Math.floor(Math.log(n/i)/Math.log(a)),i=n/Math.pow(a,s-r),e=t.constrainResolution?function(t,e,n,i,r,o){return i=void 0===i||i,n=void 0!==n?n:0,function(s,a,l,h){if(void 0!==s){const c=r?_a(e,r,l,o):e;if(h)return i?va(s,c,n):D(s,n,c);const u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(t)-u),f=-a*(.5-u)+.5,g=Math.min(c,s),p=Math.floor(Math.log(e/g)/Math.log(t)+f),m=Math.max(d,p);return D(e/Math.pow(t,m),n,c)}}}(a,n,i,h,!f&&g,c):xa(n,i,h,!f&&g,c)}return{constraint:e,maxResolution:n,minResolution:i,minZoom:r,zoomFactor:a}}(t);this.maxResolution_=n.maxResolution,this.minResolution_=n.minResolution,this.zoomFactor_=n.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=n.minZoom;const i=function(t){if(void 0!==t.extent){const e=void 0===t.smoothExtentConstraint||t.smoothExtentConstraint;return Ls(t.extent,t.constrainOnlyCenter,e)}const e=Jt(t.projection,"EPSG:3857");if(!0!==t.multiWorld&&e.isGlobal()){const t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,Ls(t,!1,!1)}return Ds}(t),r=n.constraint,s=function(t){if(void 0===t.enableRotation||t.enableRotation){const e=t.constrainRotation;return void 0===e||!0===e?function(){const t=N(5);return function(e,n){return n||void 0===e?e:Math.abs(e)<=t?0:e}}():!1===e?wa:"number"==typeof e?function(t){const e=2*Math.PI/t;return function(t,n){return n?t:void 0!==t?t=Math.floor(t/e+.5)*e:void 0}}(e):wa}return Sa}(t);this.constraints_={center:i,resolution:r,rotation:s},this.setRotation(void 0!==t.rotation?t.rotation:0),this.setCenterInternal(void 0!==t.center?t.center:null),void 0!==t.resolution?this.setResolution(t.resolution):void 0!==t.zoom&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const n=this.getCenterInternal();if(n){const i=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),o=r/2*(i[3]-e[3]+e[1]-i[1]),s=r/2*(i[0]-e[0]+e[2]-i[2]);this.setCenterInternal([n[0]+o,n[1]-s])}}getUpdatedOptions_(t){const e=this.getProperties();return void 0!==e.resolution?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 t=0;t<e.length;++t){let n=arguments[t];n.center&&(n=Object.assign({},n),n.center=se(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=se(n.anchor,this.getProjection())),e[t]=n}this.animateInternal.apply(this,e)}animateInternal(t){let e,n=arguments.length;n>1&&"function"==typeof arguments[n-1]&&(e=arguments[n-1],--n);let i=0;for(;i<n&&!this.isDef();++i){const t=arguments[i];t.center&&this.setCenterInternal(t.center),void 0!==t.zoom?this.setZoom(t.zoom):t.resolution&&this.setResolution(t.resolution),void 0!==t.rotation&&this.setRotation(t.rotation)}if(i===n)return void(e&&Ca(e,!0));let r=Date.now(),o=this.targetCenter_.slice(),s=this.targetResolution_,a=this.targetRotation_;const l=[];for(;i<n;++i){const t=arguments[i],n={start:r,complete:!1,anchor:t.anchor,duration:void 0!==t.duration?t.duration:1e3,easing:t.easing||js,callback:e};if(t.center&&(n.sourceCenter=o,n.targetCenter=t.center.slice(),o=n.targetCenter),void 0!==t.zoom?(n.sourceResolution=s,n.targetResolution=this.getResolutionForZoom(t.zoom),s=n.targetResolution):t.resolution&&(n.sourceResolution=s,n.targetResolution=t.resolution,s=n.targetResolution),void 0!==t.rotation){n.sourceRotation=a;const e=W(t.rotation-a+Math.PI,2*Math.PI)-Math.PI;n.targetRotation=a+e,a=n.targetRotation}ba(n)?n.complete=!0:r+=n.duration,l.push(n)}this.animations_.push(l),this.setHint(0,1),this.updateAnimations_()}getAnimating(){return this.hints_[0]>0}getInteracting(){return this.hints_[1]>0}cancelAnimations(){let t;this.setHint(0,-this.hints_[0]);for(let e=0,n=this.animations_.length;e<n;++e){const n=this.animations_[e];if(n[0].callback&&Ca(n[0].callback,!1),!t)for(let e=0,i=n.length;e<i;++e){const i=n[e];if(!i.complete){t=i.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(void 0!==this.updateAnimationKey_&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let n=this.animations_.length-1;n>=0;--n){const i=this.animations_[n];let r=!0;for(let n=0,o=i.length;n<o;++n){const o=i[n];if(o.complete)continue;const s=t-o.start;let a=o.duration>0?s/o.duration:1;a>=1?(o.complete=!0,a=1):r=!1;const l=o.easing(a);if(o.sourceCenter){const t=o.sourceCenter[0],e=o.sourceCenter[1],n=o.targetCenter[0],i=o.targetCenter[1];this.nextCenter_=o.targetCenter;const r=t+l*(n-t),s=e+l*(i-e);this.targetCenter_=[r,s]}if(o.sourceResolution&&o.targetResolution){const t=1===l?o.targetResolution:o.sourceResolution+l*(o.targetResolution-o.sourceResolution);if(o.anchor){const e=this.getViewportSize_(this.getRotation()),n=this.constraints_.resolution(t,0,e,!0);this.targetCenter_=this.calculateCenterZoom(n,o.anchor)}this.nextResolution_=o.targetResolution,this.targetResolution_=t,this.applyTargetState_(!0)}if(void 0!==o.sourceRotation&&void 0!==o.targetRotation){const t=1===l?W(o.targetRotation+Math.PI,2*Math.PI)-Math.PI:o.sourceRotation+l*(o.targetRotation-o.sourceRotation);if(o.anchor){const e=this.constraints_.rotation(t,!0);this.targetCenter_=this.calculateCenterRotate(e,o.anchor)}this.nextRotation_=o.targetRotation,this.targetRotation_=t}if(this.applyTargetState_(!0),e=!0,!o.complete)break}if(r){this.animations_[n]=null,this.setHint(0,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=i[0].callback;t&&Ca(t,!0)}}this.animations_=this.animations_.filter(Boolean),e&&void 0===this.updateAnimationKey_&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let n;const i=this.getCenterInternal();var r,o;return void 0!==i&&(n=[i[0]-e[0],i[1]-e[1]],function(t,e){const n=Math.cos(e),i=Math.sin(e),r=t[0]*n-t[1]*i,o=t[1]*n+t[0]*i;t[0]=r,t[1]=o}(n,t-this.getRotation()),o=e,(r=n)[0]+=+o[0],r[1]+=+o[1]),n}calculateCenterZoom(t,e){let n;const i=this.getCenterInternal(),r=this.getResolution();return void 0!==i&&void 0!==r&&(n=[e[0]-t*(e[0]-i[0])/r,e[1]-t*(e[1]-i[1])/r]),n}getViewportSize_(t){const e=this.viewportSize_;if(t){const n=e[0],i=e[1];return[Math.abs(n*Math.cos(t))+Math.abs(i*Math.sin(t)),Math.abs(n*Math.sin(t))+Math.abs(i*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?oe(t,this.getProjection()):t}getCenterInternal(){return this.get(As.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return void 0!==t?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){return ae(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();ri(e,"The view center is not defined");const n=this.getResolution();ri(void 0!==n,"The view resolution is not defined");const i=this.getRotation();return ri(void 0!==i,"The view rotation is not defined"),function(t,e,n,i,r){const[o,s,a,l,h,c,u,d]=function(t,e,n,i){const r=e*i[0]/2,o=e*i[1]/2,s=Math.cos(n),a=Math.sin(n),l=r*s,h=r*a,c=o*s,u=o*a,d=t[0],f=t[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]}(t,e,n,i);return m(Math.min(o,a,h,u),Math.min(s,l,c,d),Math.max(o,a,h,u),Math.max(s,l,c,d),r)}(e,n,i,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(As.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(le(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const n=F(t)/e[0],i=M(t)/e[1];return Math.max(n,i)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,i=Math.log(e/n)/Math.log(t);return function(n){return e/Math.pow(t,n*i)}}getRotation(){return this.get(As.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),n=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(n/i)/e;return function(t){return Math.log(n/t)/e/r}}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const n=this.padding_;return n&&(e=[e[0]-n[1]-n[3],e[1]-n[0]-n[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),n=this.getRotation();let i=this.getCenterInternal();const r=this.padding_;if(r){const t=this.getViewportSizeMinusPadding_();i=Ia(i,this.getViewportSize_(),[t[0]/2+r[3],t[1]/2+r[0]],e,n)}return{center:i.slice(0),projection:void 0!==t?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return void 0!==e&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e,n,i=this.minZoom_||0;if(this.resolutions_){const r=o(this.resolutions_,t,1);i=r,e=this.resolutions_[r],n=r==this.resolutions_.length-1?2:e/this.resolutions_[r+1]}else e=this.maxResolution_,n=this.zoomFactor_;return i+Math.log(e/t)/Math.log(n)}getResolutionForZoom(t){if(this.resolutions_?.length){if(1===this.resolutions_.length)return this.resolutions_[0];const e=D(Math.floor(t),0,this.resolutions_.length-2),n=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(n,D(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let n;if(ri(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t))ri(!A(t),"Cannot fit empty extent provided as `geometry`"),n=ma(le(t,this.getProjection()));else if("Circle"===t.getType()){const e=le(t.getExtent(),this.getProjection());n=ma(e),n.rotate(this.getRotation(),T(e))}else{const e=re();n=e?t.clone().transform(e,this.getProjection()):t}this.fitInternal(n,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),n=Math.cos(e),i=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let s=1/0,a=1/0,l=-1/0,h=-1/0;for(let t=0,e=r.length;t<e;t+=o){const e=r[t]*n-r[t+1]*i,o=r[t]*i+r[t+1]*n;s=Math.min(s,e),a=Math.min(a,o),l=Math.max(l,e),h=Math.max(h,o)}return[s,a,l,h]}fitInternal(t,e){let n=(e=e||{}).size;n||(n=this.getViewportSizeMinusPadding_());const i=void 0!==e.padding?e.padding:[0,0,0,0],r=void 0!==e.nearest&&e.nearest;let o;o=void 0!==e.minResolution?e.minResolution:void 0!==e.maxZoom?this.getResolutionForZoom(e.maxZoom):0;const s=this.rotatedExtentForGeometry(t);let a=this.getResolutionForExtentInternal(s,[n[0]-i[1]-i[3],n[1]-i[0]-i[2]]);a=isNaN(a)?o:Math.max(a,o),a=this.getConstrainedResolution(a,r?0:1);const l=this.getRotation(),h=Math.sin(l),c=Math.cos(l),u=T(s);u[0]+=(i[1]-i[3])/2*a,u[1]+=(i[0]-i[2])/2*a;const d=u[0]*c-u[1]*h,f=u[1]*c+u[0]*h,g=this.getConstrainedCenter([d,f],a),p=e.callback?e.callback:Ve;void 0!==e.duration?this.animateInternal({resolution:a,center:g,duration:e.duration,easing:e.easing},p):(this.targetResolution_=a,this.targetCenter_=g,this.applyTargetState_(!1,!0),Ca(p,!0))}centerOn(t,e,n){this.centerOnInternal(se(t,this.getProjection()),e,n)}centerOnInternal(t,e,n){this.setCenterInternal(Ia(t,e,n,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,n,i){let r;const o=this.padding_;if(o&&t){const s=this.getViewportSizeMinusPadding_(-n),a=Ia(t,i,[s[0]/2+o[3],s[1]/2+o[0]],e,n);r=[t[0]-a[0],t[1]-a[1]]}return r}isDef(){return!!this.getCenterInternal()&&void 0!==this.getResolution()}adjustCenter(t){const e=oe(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&&se(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const n=this.getAnimating()||this.getInteracting(),i=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,i,n);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=se(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const n=this.getAnimating()||this.getInteracting(),i=this.constraints_.rotation(this.targetRotation_+t,n);e&&(this.targetCenter_=this.calculateCenterRotate(i,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t?se(t,this.getProjection()):t)}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 n=this.getAnimating()||this.getInteracting()||e,i=this.constraints_.rotation(this.targetRotation_,n),r=this.getViewportSize_(i),o=this.constraints_.resolution(this.targetResolution_,0,r,n),s=this.constraints_.center(this.targetCenter_,o,r,n,this.calculateCenterShift(this.targetCenter_,o,i,r));this.get(As.ROTATION)!==i&&this.set(As.ROTATION,i),this.get(As.RESOLUTION)!==o&&(this.set(As.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),s&&this.get(As.CENTER)&&U(this.get(As.CENTER),s)||this.set(As.CENTER,s),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,n){t=void 0!==t?t:200;const i=e||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),s=this.constraints_.resolution(this.targetResolution_,i,o),a=this.constraints_.center(this.targetCenter_,s,o,!1,this.calculateCenterShift(this.targetCenter_,s,r,o));if(0===t&&!this.cancelAnchor_)return this.targetResolution_=s,this.targetRotation_=r,this.targetCenter_=a,void this.applyTargetState_();n=n||(0===t?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,this.getResolution()===s&&this.getRotation()===r&&this.getCenterInternal()&&U(this.getCenterInternal(),a)||(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:a,resolution:s,duration:t,easing:Gs,anchor:n}))}beginInteraction(){this.resolveConstraints(0),this.setHint(1,1)}endInteraction(t,e,n){n=n&&se(n,this.getProjection()),this.endInteractionInternal(t,e,n)}endInteractionInternal(t,e,n){this.getInteracting()&&(this.setHint(1,-1),this.resolveConstraints(t,e,n))}getConstrainedCenter(t,e){const n=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),n)}getConstrainedZoom(t,e){const n=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(n,e))}getConstrainedResolution(t,e){e=e||0;const n=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,n)}},Pa="opacity",Ta="visible",Ma="extent",ka="zIndex",Ra="maxResolution",Fa="minResolution",Oa="maxZoom",Aa="minZoom",La="source",Da=class extends fn{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);"object"==typeof t.properties&&(delete e.properties,Object.assign(e,t.properties)),e[Pa]=void 0!==t.opacity?t.opacity:1,ri("number"==typeof e[Pa],"Layer opacity must be a number"),e[Ta]=void 0===t.visible||t.visible,e[ka]=t.zIndex,e[Ra]=void 0!==t.maxResolution?t.maxResolution:1/0,e[Fa]=void 0!==t.minResolution?t.minResolution:0,e[Aa]=void 0!==t.minZoom?t.minZoom:-1/0,e[Oa]=void 0!==t.maxZoom?t.maxZoom:1/0,this.className_=void 0!==e.className?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:void 0===t||t},n=this.getZIndex();return e.opacity=D(Math.round(100*this.getOpacity())/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=void 0!==n||e.managed?n:1/0,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return hn()}getLayerStatesArray(t){return hn()}getExtent(){return this.get(Ma)}getMaxResolution(){return this.get(Ra)}getMinResolution(){return this.get(Fa)}getMinZoom(){return this.get(Aa)}getMaxZoom(){return this.get(Oa)}getOpacity(){return this.get(Pa)}getSourceState(){return hn()}getVisible(){return this.get(Ta)}getZIndex(){return this.get(ka)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(Ma,t)}setMaxResolution(t){this.set(Ra,t)}setMinResolution(t){this.set(Fa,t)}setMaxZoom(t){this.set(Oa,t)}setMinZoom(t){this.set(Aa,t)}setOpacity(t){ri("number"==typeof t,"Layer opacity must be a number"),this.set(Pa,t)}setVisible(t){this.set(Ta,t)}setZIndex(t){this.set(ka,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},Ga=class extends Da{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(La,this.handleSourcePropertyChange_);const n=t.source?t.source:null;this.setSource(n)}getLayersArray(t){return(t=t||[]).push(this),t}getLayerStatesArray(t){return(t=t||[]).push(this.getLayerState()),t}getSource(){return this.get(La)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),this.sourceReady_||"ready"!==this.getSource().getState()||(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(sn(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=rn(t,Le,this.handleSourceChange_,this),"ready"===t.getState()&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return this.renderer_&&this.rendered?this.renderer_.getData(t):null}isVisible(t){let e;const n=this.getMapInternal();let i;if(!t&&n&&(t=n.getView()),e=t instanceof Ea?{viewState:t.getState(),extent:t.calculateExtent()}:t,!e.layerStatesArray&&n&&(e.layerStatesArray=n.getLayerGroup().getLayerStatesArray()),e.layerStatesArray){if(i=e.layerStatesArray.find(t=>t.layer===this),!i)return!1}else i=this.getLayerState();const r=this.getExtent();return function(t,e){if(!t.visible)return!1;const n=e.resolution;if(n<t.minResolution||n>=t.maxResolution)return!1;const i=e.zoom;return i>t.minZoom&&i<=t.maxZoom}(i,e.viewState)&&(!r||O(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let n=e(t instanceof Ea?t.getViewStateAndExtent():t);return Array.isArray(n)||(n=[n]),n}render(t,e){const n=this.getRenderer();return n.prepareFrame(t)?(this.rendered=!0,n.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("map",t)}getMapInternal(){return this.get("map")}setMap(t){this.mapPrecomposeKey_&&(sn(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(sn(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=rn(t,"precompose",this.handlePrecompose_,this),this.mapRenderKey_=rn(this,Le,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,n=this.getLayerState(!1);ri(!e.some(t=>t.layer===n.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(n)}setSource(t){this.set(La,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()}},ja="renderOrder",Va=class extends Ga{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=void 0!==t.renderBuffer?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=void 0!==t.updateWhileAnimating&&t.updateWhileAnimating,this.updateWhileInteracting_=void 0!==t.updateWhileInteracting&&t.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(ja)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const n=this.getDeclutter();n in t.declutter==0&&(t.declutter[n]=new lr(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(ja,t)}setStyle(t){this.style_=void 0===t?rs:t;const e=function(t){if(void 0===t)return rs;if(!t)return null;if("function"==typeof t)return t;if(t instanceof as)return t;if(!Array.isArray(t))return ds([t]);if(0===t.length)return[];const e=t.length,n=t[0];if(n instanceof as){const n=new Array(e);for(let i=0;i<e;++i){const e=t[i];if(!(e instanceof as))throw new Error("Expected a list of style instances");n[i]=e}return n}if("style"in n){const n=new Array(e);for(let i=0;i<e;++i){const e=t[i];if(!("style"in e))throw new Error("Expected a list of rules with a style property");n[i]=e}return us(n)}return ds(t)}(t);this.styleFunction_=null===t?void 0:function(t){let e;if("function"==typeof t)e=t;else{let n;Array.isArray(t)?n=t:(ri("function"==typeof t.getZIndex,"Expected an `Style` or an array of `Style`"),n=[t]),e=function(){return n}}return e}(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}},Na=class extends Va{constructor(t){super(t)}createRenderer(){return new rr(this)}},Wa="add",Ba="remove",Xa="length";class Ya extends Xe{constructor(t,e,n){super(t),this.element=e,this.index=n}}const za=class extends fn{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t??[],this.unique_)for(let t=1,e=this.array_.length;t<e;++t)this.assertUnique_(this.array_[t],t);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,n=t.length;e<n;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let n=0,i=e.length;n<i;++n)t(e[n],n,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(Xa)}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 Ya(Wa,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let n=0,i=e.length;n<i;++n)if(e[n]===t)return this.removeAt(n)}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 Ya(Ba,e,t)),e}setAt(t,e){if(t>=this.getLength())return void this.insertAt(t,e);if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const n=this.array_[t];this.array_[t]=e,this.dispatchEvent(new Ya(Ba,n,t)),this.dispatchEvent(new Ya(Wa,e,t))}updateLength_(){this.set(Xa,this.array_.length)}assertUnique_(t,e){const n=this.array_;for(let i=0,r=n.length;i<r;++i)if(n[i]===t&&i!==e)throw new Error("Duplicate item added to a unique collection")}};function Ua(t,e){return function(n,i,r,o,s){!function(t,e,n,i,r,o,s){const a=new XMLHttpRequest;a.open("GET","function"==typeof t?t(n,i,r):t,!0),"arraybuffer"==e.getType()&&(a.responseType="arraybuffer"),a.withCredentials=false,a.onload=function(t){if(!a.status||a.status>=200&&a.status<300){const t=e.getType();try{let i;"text"==t||"json"==t?i=a.responseText:"xml"==t?i=a.responseXML||a.responseText:"arraybuffer"==t&&(i=a.response),i?o(e.readFeatures(i,{extent:n,featureProjection:r}),e.readProjection(i)):s()}catch{s()}}else s()},a.onerror=s,a.send()}(t,e,n,i,r,(t,e)=>{this.addFeatures(t),void 0!==o&&o(t)},()=>{this.changed(),void 0!==s&&s()})}}function Ha(t,e){return[[-1/0,-1/0,1/0,1/0]]}function qa(t,e,n,i){const r=[];let o=[1/0,1/0,-1/0,-1/0];for(let s=0,a=n.length;s<a;++s){const a=n[s];o=v(t,e,a[0],i),r.push((o[0]+o[2])/2,(o[1]+o[3])/2),e=a[a.length-1]}return r}function $a(t,e,n,r,o,s,a){let l,h;const c=(n-e)/r;if(1===c)l=e;else if(2===c)l=e,h=o;else if(0!==c){let s=t[e],a=t[e+1],c=0;const u=[0];for(let i=e+r;i<n;i+=r){const e=t[i],n=t[i+1];c+=Math.sqrt((e-s)*(e-s)+(n-a)*(n-a)),u.push(c),s=e,a=n}const d=o*c,f=function(t,e,n){let r,o;n=n||i;let s=0,a=t.length,l=!1;for(;s<a;)r=s+(a-s>>1),o=+n(t[r],e),o<0?s=r+1:(a=r,l=!o);return l?s:~s}(u,d);f<0?(h=(d-u[-f-2])/(u[-f-1]-u[-f-2]),l=e+(-f-2)*r):l=e+f*r}a=a>1?a:2,s=s||new Array(a);for(let e=0;e<a;++e)s[e]=void 0===l?NaN:void 0===h?t[l+e]:B(t[l+e],t[l+r+e],h);return s}function Za(t,e,n,i,r,o){if(n==e)return null;let s;if(r<t[e+i-1])return o?(s=t.slice(e,e+i),s[i-1]=r,s):null;if(t[n-1]<r)return o?(s=t.slice(n-i,n),s[i-1]=r,s):null;if(r==t[e+i-1])return t.slice(e,e+i);let a=e/i,l=n/i;for(;a<l;){const e=a+l>>1;r<t[(e+1)*i-1]?l=e:a=e+1}const h=t[a*i-1];if(r==h)return t.slice((a-1)*i,(a-1)*i+i);const c=(r-h)/(t[(a+1)*i-1]-h);s=[];for(let e=0;e<i-1;++e)s.push(B(t[(a-1)*i+e],t[a*i+e],c));return s.push(r),s}const Ka=[1,0,0,1,0,0];class Ja{constructor(t,e,n,i,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=n||null,this.properties_=r,this.squaredTolerance_,this.stride_=i,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_="Point"===this.type_?_(this.flatCoordinates_):v(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=T(this.getExtent());this.flatInteriorPoints_=ia(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=function(t,e){const n=[];let i,r=0,o=0;for(let s=0,a=e.length;s<a;++s){const a=e[s],l=ha(t,r,a,2);if(void 0===i&&(i=l),l===i)n.push(e.slice(o,s+1));else{if(0===n.length)continue;n[n.length-1].push(e[o])}o=s+1,r=a}return n}(this.flatCoordinates_,this.ends_),e=qa(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=ra(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=$a(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const n=this.ends_;for(let i=0,r=n.length;i<r;++i){const r=n[i],o=$a(t,e,r,this.stride_,.5);a(this.flatMidpoints_,o),e=r}}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){const e=(t=Zt(t)).getExtent(),n=t.getWorldExtent();if(e&&n){const t=M(n)/M(e);si(Ka,n[0],n[3],t,-t,0,0,0),ni(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,Ka,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new Ja(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Ne((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const n=this.simplifiedGeometry_.getFlatCoordinates();let i;switch(this.type_){case"LineString":n.length=zn(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,n,0),i=[n.length];break;case"MultiLineString":i=[],n.length=Un(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,n,0,i);break;case"Polygon":i=[],n.length=$n(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),n,0,i)}return i&&(this.simplifiedGeometry_=new Ja(this.type_,n,i,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Ja.prototype.getFlatCoordinates=Ja.prototype.getOrientedFlatCoordinates;const Qa=Ja,tl=class{constructor(t){this.rbush_=new lr(t),this.items_={}}insert(t,e){const n={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(n),this.items_[un(e)]=n}load(t,e){const n=new Array(e.length);for(let i=0,r=e.length;i<r;i++){const r=t[i],o=e[i],s={minX:r[0],minY:r[1],maxX:r[2],maxY:r[3],value:o};n[i]=s,this.items_[un(o)]=s}this.rbush_.load(n)}remove(t){const e=un(t),n=this.items_[e];return delete this.items_[e],null!==this.rbush_.remove(n)}update(t,e){const n=this.items_[un(e)];x([n.minX,n.minY,n.maxX,n.maxY],t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(t){return t.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(t){return t.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let n;for(let i=0,r=t.length;i<r;i++)if(n=e(t[i]),n)return n;return n}isEmpty(){return Be(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return m(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]}};function el(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),e=>t):null}const nl=class extends fn{constructor(t){super(),this.projection=Zt(t.projection),this.attributions_=el(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=void 0!==t.state?t.state:"ready",this.wrapX_=void 0!==t.wrapX&&t.wrapX,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(t,n){e.viewResolver=t,e.viewRejector=n})}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_=el(t),this.changed()}setState(t){this.state_=t,this.changed()}},il="addfeature",rl="removefeature";class ol extends Xe{constructor(t,e,n){super(t),this.feature=e,this.features=n}}const sl=class extends nl{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:void 0===t.wrapX||t.wrapX}),this.on,this.once,this.un,this.loader_=Ve,this.format_=t.format||null,this.overlaps_=void 0===t.overlaps||t.overlaps,this.url_=t.url,void 0!==t.loader?this.loader_=t.loader:void 0!==this.url_&&(ri(this.format_,"`format` must be set when `url` is set"),this.loader_=Ua(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:Ha;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let n,i;this.featuresRtree_=e?new tl:null,this.loadedExtentsRtree_=new tl,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null,Array.isArray(t.features)?i=t.features:t.features&&(n=t.features,i=n.getArray()),e||void 0!==n||(n=new za(i)),void 0!==i&&this.addFeaturesInternal(i),void 0!==n&&this.bindFeaturesCollection_(n)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=un(t);if(!this.addToIndex_(e,t))return void(this.featuresCollection_&&this.featuresCollection_.remove(t));this.setupChangeEvents_(e,t);const n=t.getGeometry();if(n){const e=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(e,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new ol(il,t))}setupChangeEvents_(t,e){e instanceof Qa||(this.featureChangeKeys_[t]=[rn(e,Le,this.handleFeatureChange_,this),rn(e,nn,this.handleFeatureChange_,this)])}addToIndex_(t,e){let n=!0;if(void 0!==e.getId()){const t=String(e.getId());if(t in this.idIndex_)if(e instanceof Qa){const i=this.idIndex_[t];i instanceof Qa?Array.isArray(i)?i.push(e):this.idIndex_[t]=[i,e]:n=!1}else n=!1;else this.idIndex_[t]=e}return n&&(ri(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),n}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],n=[],i=[];for(let e=0,i=t.length;e<i;e++){const i=t[e],r=un(i);this.addToIndex_(r,i)&&n.push(i)}for(let t=0,r=n.length;t<r;t++){const r=n[t],o=un(r);this.setupChangeEvents_(o,r);const s=r.getGeometry();if(s){const t=s.getExtent();e.push(t),i.push(r)}else this.nullGeometryFeatures_[o]=r}if(this.featuresRtree_&&this.featuresRtree_.load(e,i),this.hasListener(il))for(let t=0,e=n.length;t<e;t++)this.dispatchEvent(new ol(il,n[t]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(il,function(n){e||(e=!0,t.push(n.feature),e=!1)}),this.addEventListener(rl,function(n){e||(e=!0,t.remove(n.feature),e=!1)}),t.addEventListener(Wa,t=>{e||(e=!0,this.addFeature(t.element),e=!1)}),t.addEventListener(Ba,t=>{e||(e=!0,this.removeFeature(t.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const t in this.featureChangeKeys_)this.featureChangeKeys_[t].forEach(sn);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(t=>{this.removeFeatureInternal(t)});for(const t in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[t])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new ol("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 n=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(n,function(n){const i=n.getGeometry();if(i instanceof Qa||i.intersectsCoordinate(t))return e(n)})}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(n){const i=n.getGeometry();if(i instanceof Qa||i.intersectsExtent(t)){const t=e(n);if(t)return t}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),Be(this.nullGeometryFeatures_)||a(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(t){e.push(t)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const n=function(t,e){if(e.canWrapX()){const n=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[n[0],t[1],n[2],t[3]]];L(t,e);const i=F(n);if(F(t)>i)return[[n[0],t[1],n[2],t[3]]];if(t[0]<n[0])return[[t[0]+i,t[1],n[2],t[3]],[n[0],t[1],t[2],t[3]]];if(t[2]>n[2])return[[t[0],t[1],n[2],t[3]],[n[0],t[1],t[2]-i,t[3]]]}return[t]}(t,e);return[].concat(...n.map(t=>this.featuresRtree_.getInExtent(t)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const n=t[0],i=t[1];let r=null;const o=[NaN,NaN];let s=1/0;const a=[-1/0,-1/0,1/0,1/0];return e=e||Ge,this.featuresRtree_.forEachInExtent(a,function(t){if(e(t)){const e=t.getGeometry(),l=s;if(s=e instanceof Qa?0:e.closestPointXY(n,i,o,s),s<l){r=t;const e=Math.sqrt(s);a[0]=n-e,a[1]=i-e,a[2]=n+e,a[3]=i+e}}}),r}getExtent(t){return this.featuresRtree_?.getExtent(t)??null}getFeatureById(t){const e=this.idIndex_[t.toString()];return void 0!==e?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return void 0!==e?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,n=un(e),i=e.getGeometry();if(i){const t=i.getExtent();n in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[n],this.featuresRtree_&&this.featuresRtree_.insert(t,e)):this.featuresRtree_&&this.featuresRtree_.update(t,e)}else n in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[n]=e);const r=e.getId();if(void 0!==r){const t=r.toString();this.idIndex_[t]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[t]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[n]=e;this.changed(),this.dispatchEvent(new ol("changefeature",e))}hasFeature(t){const e=t.getId();return void 0!==e?e in this.idIndex_:un(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Be(this.nullGeometryFeatures_):!this.featuresCollection_||0===this.featuresCollection_.getLength()}loadFeatures(t,e,n){const i=this.loadedExtentsRtree_,r=this.strategy_(t,e,n);for(let t=0,o=r.length;t<o;++t){const o=r[t];if(!i.forEachInExtent(o,function(t){return f(t.extent,o)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new ol("featuresloadstart"));const t=t=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new ol("featuresloadend",void 0,t))},r=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new ol("featuresloaderror"))};let s=!1;const a=this.loader_.call(this,o,e,n,e=>s||t(e),()=>s||r());a instanceof Promise?(s=!0,a.then(e=>{this.addFeatures(e),t(e)}).catch(r)):this.loader_.length<4&&(this.loading=!1),i.insert(o,{extent:o.slice()})}}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_,n=e.forEachInExtent(t,function(e){if(x(e.extent,t))return e});n&&e.remove(n)}removeFeatures(t){let e=!1;for(let n=0,i=t.length;n<i;++n)e=this.removeFeatureInternal(t[n])||e;e&&this.changed()}removeFeature(t){t&&this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=un(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t);const n=this.featureChangeKeys_[e];n?.forEach(sn),delete this.featureChangeKeys_[e];const i=t.getId();if(void 0!==i){const e=i.toString(),n=this.idIndex_[e];n===t?delete this.idIndex_[e]:Array.isArray(n)&&(n.splice(n.indexOf(t),1),1===n.length&&(this.idIndex_[e]=n[0]))}return delete this.uidIndex_[e],this.hasListener(rl)&&this.dispatchEvent(new ol(rl,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){ri(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(Ua(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}};class al extends fn{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if("function"==typeof t.getSimplifiedGeometry){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new al,e=this.geometryName_;t.setGeometryName(e);const n=this.getPropertiesInternal();if(n){const i=this.getGeometry();for(const r in n)r===e&&i?t.set(r,i.clone()):t.set(r,n[r],!0)}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_&&(sn(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=rn(t,Le,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?function(t){if("function"==typeof t)return t;let e;return Array.isArray(t)?e=t:(ri("function"==typeof t.getZIndex,"Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[t]),function(){return e}}(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){t!==this.geometryName_&&(this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_())}}const ll=al;class hl extends Wi{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(sn),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,n=t.length;e<n;++e)this.changeEventsKeys_.push(rn(t[e],Le,this.changed,this))}clone(){const t=new hl(cl(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,n,i){if(i<u(this.getExtent(),t,e))return i;const r=this.geometries_;for(let o=0,s=r.length;o<s;++o)i=r[o].closestPointXY(t,e,n,i);return i}containsXY(t,e){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)if(n[i].containsXY(t,e))return!0;return!1}computeExtent(t){y(t);const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)S(t,e[n].getExtent());return t}getGeometries(){return cl(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[];const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)e[n].getType()===this.getType()?t=t.concat(e[n].getGeometriesArrayRecursive()):t.push(e[n]);return t}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=[],n=this.geometries_;let i=!1;for(let r=0,o=n.length;r<o;++r){const o=n[r],s=o.getSimplifiedGeometry(t);e.push(s),s!==o&&(i=!0)}return i?new hl(e):(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getType(){return"GeometryCollection"}intersectsExtent(t){const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)if(e[n].intersectsExtent(t))return!0;return!1}isEmpty(){return 0===this.geometries_.length}rotate(t,e){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].rotate(t,e);this.changed()}scale(t,e,n){n||(n=T(this.getExtent()));const i=this.geometries_;for(let r=0,o=i.length;r<o;++r)i[r].scale(t,e,n);this.changed()}setGeometries(t){this.setGeometriesArray(cl(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)e[n].applyTransform(t);this.changed()}translate(t,e){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function cl(t){return t.map(t=>t.clone())}const ul=hl;class dl extends Yi{constructor(t,e){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,void 0===e||Array.isArray(t[0])?this.setCoordinates(t,e):this.setFlatCoordinates(e,t)}appendCoordinate(t){a(this.flatCoordinates,t),this.changed()}clone(){const t=new dl(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Bs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ys(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,n,i))}forEachSegment(t){return oa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){return"XYM"!=this.layout&&"XYZM"!=this.layout?null:(e=void 0!==e&&e,Za(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return Je(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return $a(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return hi(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=zn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new dl(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return sa(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=Hs(this.flatCoordinates,0,t,this.stride),this.changed()}}const fl=dl;class gl extends Yi{constructor(t,e,n){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(void 0!==e&&n)this.setFlatCoordinates(e,t),this.ends_=n;else{const e=t,n=[],i=[];for(let t=0,r=e.length;t<r;++t)a(n,e[t].getFlatCoordinates()),i.push(n.length);const r=0===e.length?this.getLayout():e[0].getLayout();this.setFlatCoordinates(r,n),this.ends_=i}}appendLineString(t){a(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new gl(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Xs(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zs(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,n,i))}getCoordinateAtM(t,e,n){return"XYM"!=this.layout&&"XYZM"!=this.layout||0===this.flatCoordinates.length?null:(e=void 0!==e&&e,n=void 0!==n&&n,function(t,e,n,i,r,o,s){if(s)return Za(t,e,n[n.length-1],i,r,o);let a;if(r<t[i-1])return o?(a=t.slice(0,i),a[i-1]=r,a):null;if(t[t.length-1]<r)return o?(a=t.slice(t.length-i),a[i-1]=r,a):null;for(let o=0,s=n.length;o<s;++o){const s=n[o];if(e!=s){if(r<t[e+i-1])return null;if(r<=t[s-1])return Za(t,e,s,i,r,!1);e=s}}return null}(this.flatCoordinates,0,this.ends_,this.stride,t,e,n))}getCoordinates(){return Qe(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new fl(this.flatCoordinates.slice(0===t?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){const t=this.flatCoordinates,e=this.ends_,n=this.layout,i=[];let r=0;for(let o=0,s=e.length;o<s;++o){const s=e[o],a=new fl(t.slice(r,s),n);i.push(a),r=s}return i}getLength(){const t=this.ends_;let e=0,n=0;for(let i=0,r=t.length;i<r;++i)n+=hi(this.flatCoordinates,e,t[i],this.stride),e=t[i];return n}getFlatMidpoints(){const t=[],e=this.flatCoordinates;let n=0;const i=this.ends_,r=this.stride;for(let o=0,s=i.length;o<s;++o){const s=i[o];a(t,$a(e,n,s,r,.5)),n=s}return t}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=Un(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,n),new gl(e,"XY",n)}getType(){return"MultiLineString"}intersectsExtent(t){return function(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){if(sa(t,e,n[o],i,r))return!0;e=n[o]}return!1}(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=qs(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}const pl=gl;class ml extends Yi{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){a(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){const t=new ml(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){if(i<u(this.getExtent(),t,e))return i;const r=this.flatCoordinates,o=this.stride;for(let s=0,a=r.length;s<a;s+=o){const a=j(t,e,r[s],r[s+1]);if(a<i){i=a;for(let t=0;t<o;++t)n[t]=r[s+t];n.length=o}}return i}getCoordinates(){return Je(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new Qs(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){const t=this.flatCoordinates,e=this.layout,n=this.stride,i=[];for(let r=0,o=t.length;r<o;r+=n){const o=new Qs(t.slice(r,r+n),e);i.push(o)}return i}getType(){return"MultiPoint"}intersectsExtent(t){const e=this.flatCoordinates,n=this.stride;for(let i=0,r=e.length;i<r;i+=n)if(g(t,e[i],e[i+1]))return!0;return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Hs(this.flatCoordinates,0,t,this.stride),this.changed()}}const yl=ml;class _l extends Yi{constructor(t,e,n){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!n&&!Array.isArray(t[0])){const i=t,r=[],o=[];for(let t=0,e=i.length;t<e;++t){const e=i[t],n=r.length,s=e.getEnds();for(let t=0,e=s.length;t<e;++t)s[t]+=n;a(r,e.getFlatCoordinates()),o.push(s)}e=0===i.length?this.getLayout():i[0].getLayout(),t=r,n=o}void 0!==e&&n?(this.setFlatCoordinates(e,t),this.endss_=n):this.setCoordinates(t,e)}appendPolygon(t){let e;if(this.flatCoordinates){const n=this.flatCoordinates.length;a(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let t=0,i=e.length;t<i;++t)e[t]+=n}else this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();this.endss_.push(e),this.changed()}clone(){const t=this.endss_.length,e=new Array(t);for(let n=0;n<t;++n)e[n]=this.endss_[n].slice();const n=new _l(this.flatCoordinates.slice(),this.layout,e);return n.applyProperties(this),n}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(function(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];r=Xs(t,e,s,i,r),e=s[s.length-1]}return r}(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),function(t,e,n,i,r,o,s,a,l,h,c){c=c||[NaN,NaN];for(let o=0,u=n.length;o<u;++o){const u=n[o];h=zs(t,e,u,i,r,true,s,a,l,h,c),e=u[u.length-1]}return h}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,0,t,e,n,i))}containsXY(t,e){return function(t,e,n,i,r,o){if(0===n.length)return!1;for(let s=0,a=n.length;s<a;++s){const a=n[s];if(na(t,e,a,i,r,o))return!0;e=a[a.length-1]}return!1}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return function(t,e,n,i){let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o];r+=Ns(t,e,s,i),e=s[s.length-1]}return r}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),fa(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,tn(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=qa(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=ra(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new yl(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;ua(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=fa(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=function(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l],c=[];s=$n(t,e,h,i,r,o,s,c),a.push(c),e=h[h.length-1]}return s}(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,n),new _l(e,"XY",n)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(0===t)e=0;else{const n=this.endss_[t-1];e=n[n.length-1]}const n=this.endss_[t].slice(),i=n[n.length-1];if(0!==e)for(let t=0,i=n.length;t<i;++t)n[t]-=e;return new pa(this.flatCoordinates.slice(e,i),this.layout,n)}getPolygons(){const t=this.layout,e=this.flatCoordinates,n=this.endss_,i=[];let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o].slice(),a=s[s.length-1];if(0!==r)for(let t=0,e=s.length;t<e;++t)s[t]-=r;const l=new pa(e.slice(r,a),t,s);i.push(l),r=a}return i}getType(){return"MultiPolygon"}intersectsExtent(t){return function(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];if(aa(t,e,s,i,r))return!0;e=s[s.length-1]}return!1}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const n=$s(this.flatCoordinates,0,t,this.stride,this.endss_);if(0===n.length)this.flatCoordinates.length=0;else{const t=n[n.length-1];this.flatCoordinates.length=0===t.length?0:t[t.length-1]}this.changed()}}const vl=_l,xl=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=ll,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let n=e.dataProjection?Zt(e.dataProjection):this.readProjection(t);e.extent&&n&&"tile-pixels"===n.getUnits()&&(n=Zt(n),n.setWorldExtent(e.extent)),e={dataProjection:n,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return hn()}readFeature(t,e){return hn()}readFeatures(t,e){return hn()}readGeometry(t,e){return hn()}readProjection(t){return hn()}writeFeature(t,e){return hn()}writeFeatures(t,e){return hn()}writeGeometry(t,e){return hn()}};function Sl(t,e,n){const i=n?Zt(n.featureProjection):null,r=n?Zt(n.dataProjection):null;let o=t;if(i&&r&&!function(t,e){if(t===e)return!0;const n=t.getUnits()===e.getUnits();return(t.getCode()===e.getCode()||Qt(t,e)===qt)&&n}(i,r)){e&&(o=t.clone());const n=e?i:r,s=e?r:i;"tile-pixels"===n.getUnits()?o.transform(n,s):o.applyTransform(ee(n,s))}if(e&&n&&void 0!==n.decimals){const e=Math.pow(10,n.decimals),i=function(t){for(let n=0,i=t.length;n<i;++n)t[n]=Math.round(t[n]*e)/e;return t};o===t&&(o=t.clone()),o.applyTransform(i)}return o}const wl={Point:Qs,LineString:fl,Polygon:pa,MultiPoint:yl,MultiLineString:pl,MultiPolygon:vl};function Cl(t,e){const n=t.geometry;if(!n)return[];if(Array.isArray(n))return n.map(e=>Cl({...t,geometry:e})).flat();const i="MultiPolygon"===n.type?"Polygon":n.type;if("GeometryCollection"===i||"Circle"===i)throw new Error("Unsupported geometry type: "+i);const r=n.layout.length;return Sl(new Qa(i,"Polygon"===i?function(t,e,n){return Array.isArray(e[0])?(ua(t,0,e,n)||fa(t=t.slice(),0,e,n),t):(ca(t,0,e,n)||da(t=t.slice(),0,e,n),t)}(n.flatCoordinates,n.ends,r):n.flatCoordinates,n.ends?.flat(),r,t.properties||{},t.id).enableSimplifyTransformed(),!1,e)}function bl(t,e){if(!t)return null;if(Array.isArray(t)){const n=t.map(t=>bl(t,e));return new ul(n)}return Sl(new(0,wl[t.type])(t.flatCoordinates,t.layout||"XY",t.ends),!1,e)}function Il(t){if("string"==typeof t){return JSON.parse(t)||null}return null!==t?t:null}const El=class extends xl{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Il(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Il(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return hn()}readFeaturesFromObject(t,e){return hn()}readGeometry(t,e){return this.readGeometryFromObject(Il(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return hn()}readProjection(t){return this.readProjectionFromObject(Il(t))}readProjectionFromObject(t){return hn()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return hn()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return hn()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return hn()}};function Pl(t,e){if(!t)return null;let n;switch(t.type){case"Point":n=function(t){const e=t.coordinates;return{type:"Point",flatCoordinates:e,layout:Bi(e.length)}}(t);break;case"LineString":n=function(t){const e=t.coordinates,n=e.flat();return{type:"LineString",flatCoordinates:n,ends:[n.length],layout:Bi(e[0]?.length||2)}}(t);break;case"Polygon":n=function(t){const e=t.coordinates,n=[],i=e[0]?.[0]?.length;return{type:"Polygon",flatCoordinates:n,ends:qs(n,0,e,i),layout:Bi(i)}}(t);break;case"MultiPoint":n=function(t){const e=t.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:Bi(e[0]?.length||2)}}(t);break;case"MultiLineString":n=function(t){const e=t.coordinates,n=e[0]?.[0]?.length||2,i=[];return{type:"MultiLineString",flatCoordinates:i,ends:qs(i,0,e,n),layout:Bi(n)}}(t);break;case"MultiPolygon":n=function(t){const e=t.coordinates,n=[],i=e[0]?.[0]?.[0].length||2;return{type:"MultiPolygon",flatCoordinates:n,ends:$s(n,0,e,i),layout:Bi(i)}}(t);break;case"GeometryCollection":n=function(t){const e=t.geometries.map(function(t){return Pl(t)});return e}(t);break;default:throw new Error("Unsupported GeoJSON type: "+t.type)}return n}function Tl(t,e){const n=(t=Sl(t,!0,e)).getType();let i;switch(n){case"Point":i=function(t){return{type:"Point",coordinates:t.getCoordinates()}}(t);break;case"LineString":i=function(t){return{type:"LineString",coordinates:t.getCoordinates()}}(t);break;case"Polygon":i=function(t,e){let n;return e&&(n=e.rightHanded),{type:"Polygon",coordinates:t.getCoordinates(n)}}(t,e);break;case"MultiPoint":i=function(t){return{type:"MultiPoint",coordinates:t.getCoordinates()}}(t);break;case"MultiLineString":i=function(t){return{type:"MultiLineString",coordinates:t.getCoordinates()}}(t);break;case"MultiPolygon":i=function(t,e){let n;return e&&(n=e.rightHanded),{type:"MultiPolygon",coordinates:t.getCoordinates(n)}}(t,e);break;case"GeometryCollection":i=function(t,e){delete(e=Object.assign({},e)).featureProjection;return{type:"GeometryCollection",geometries:t.getGeometriesArray().map(function(t){return Tl(t,e)})}}(t,e);break;case"Circle":i={type:"GeometryCollection",geometries:[]};break;default:throw new Error("Unsupported geometry type: "+n)}return i}function Ml(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var kl="EPSG:27700",Rl=new class extends El{constructor(t){t=t||{},super(),this.dataProjection=Zt(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=Zt(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 n=null;n="Feature"===t.type?t:{type:"Feature",geometry:t,properties:null};const i=Pl(n.geometry);if(this.featureClass===Qa)return Cl({geometry:i,id:n.id,properties:n.properties},e);const r=new ll;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&r.setGeometryName(n.geometry_name),r.setGeometry(bl(i,e)),"id"in n&&r.setId(n.id),n.properties&&r.setProperties(n.properties,!0),r}readFeaturesFromObject(t,e){let n=null;if("FeatureCollection"===t.type){n=[];const i=t.features;for(let t=0,r=i.length;t<r;++t){const r=this.readFeatureFromObject(i[t],e);r&&n.push(r)}}else n=[this.readFeatureFromObject(t,e)];return n.flat()}readGeometryFromObject(t,e){return function(t,e){return bl(Pl(t),e)}(t,e)}readProjectionFromObject(t){const e=t.crs;let n;if(e)if("name"==e.type)n=Zt(e.properties.name);else{if("EPSG"!==e.type)throw new Error("Unknown SRS type");n=Zt("EPSG:"+e.properties.code)}else n=this.dataProjection;return n}writeFeatureObject(t,e){e=this.adaptOptions(e);const n={type:"Feature",geometry:null,properties:null},i=t.getId();if(void 0!==i&&(n.id=i),!t.hasProperties())return n;const r=t.getProperties(),o=t.getGeometry();return o&&(n.geometry=Tl(o,e),delete r[t.getGeometryName()]),Be(r)||(n.properties=r),n}writeFeaturesObject(t,e){e=this.adaptOptions(e);const n=[];for(let i=0,r=t.length;i<r;++i)n.push(this.writeFeatureObject(t[i],e));return{type:"FeatureCollection",features:n}}writeGeometryObject(t,e){return Tl(t,this.adaptOptions(e))}}({dataProjection:kl,featureProjection:kl}),Fl=n(610),Ol=n(682),Al={Polygon:2,LineString:1},Ll=function(t){var e,n=t.getType();return("Polygon"===n?null!==(e=t.getCoordinates()[0])&&void 0!==e?e:[]:t.getCoordinates()).slice(0,-Al[n])},Dl=function(t){var e;return null!==(e=Ll(t).at(-1))&&void 0!==e?e:null},Gl=new Map,jl=function(t,e){var n=Gl.get(t);if(n)return n;var i=document.createElement("canvas");return i.width=e.width,i.height=e.height,i.getContext("2d").putImageData(e,0,0),Gl.set(t,i),i},Vl=n(600),Nl=n(121);function Wl(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Bl(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Bl(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Bl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var Xl={outer:Ol.F0.vertexHaloRadius+3,mid:Ol.F0.vertexHaloRadius,inner:Ol.F0.vertexRadius},Yl={outer:Ol.F0.midpointHaloRadius+3,mid:Ol.F0.midpointHaloRadius,inner:Ol.F0.midpointRadius},zl=function(t,e,n,i,r){t.beginPath(),t.arc(e,n,i,0,2*Math.PI),t.fillStyle=r,t.fill()},Ul=function(t,e,n){var i=t.outer,r=t.mid,o=t.inner;return function(t,s){var a=s.context,l=s.pixelRatio,h=Wl(t,2),c=h[0],u=h[1];a.save(),zl(a,c,u,i*l,e.editActive),zl(a,c,u,r*l,e.editHalo),zl(a,c,u,o*l,e[n]),a.restore()}},Hl=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},ql=function(t){var e=function(t){var e=new Ko({radius:Ol.F0.vertexRadius,fill:new Qo({color:t.editVertex})});return{vertexImage:e,vertexStyle:new as({image:e}),selectedVertexStyle:new as({renderer:Ul(Xl,t,"editVertex")})}}(t),n=e.vertexImage,i=e.vertexStyle,r=e.selectedVertexStyle,o=function(t){return{midpointStyle:new as({image:new Ko({radius:Ol.F0.midpointRadius,fill:new Qo({color:t.editMidpoint})})}),selectedMidpointStyle:new as({renderer:Ul(Yl,t,"editMidpoint")})}}(t),s=o.midpointStyle,a=o.selectedMidpointStyle,l=new as({stroke:new es({color:t.editStroke,width:2}),fill:new Qo({color:t.editFill})}),h=new as({stroke:new es({color:t.invalidStroke,width:2,lineDash:[2,4]})}),c=function(t){return{valid:new as({stroke:new es({color:t.editStroke,width:2}),fill:new Qo({color:t.editFill})}),invalid:new as({stroke:new es({color:t.invalidStroke,width:2,lineDash:[2,4]})}),splitValid:new as({stroke:new es({color:t.splitValid,width:2})}),splitInvalid:new as({stroke:new es({color:t.splitInvalid,width:2,lineDash:[2,4]})})}}(t),u=new yl([]),d=new as({image:n,geometry:function(t){var e=Ll(t.getGeometry());return e.length?(u.setCoordinates(e),u):null}}),f=function(t){var e=function(t){return new as({image:new Ko({radius:Ol.F0.vertexRadius+3,fill:new Qo({color:t.shapeFill}),stroke:new es({color:t.shapeStroke,width:2})})})}(t),n=new Map,i=function(t){var e=t[arguments.length>1&&void 0!==arguments[1]?arguments[1]:"symbolImageId"],i=e&&function(t){return Gl.get(t)}(e);if(!i)return null;var r=Vl.a.getSymbolDef(t),o=Wl((0,Nl.Op)(t,r),2),s=o[0],a=o[1],l=t.symbolPixelRatio||1,h="".concat(e,"|").concat(s,"|").concat(a,"|").concat(l),c=n.get(h);return c||(c=new as({image:new ji({img:i,anchor:[s,a],scale:1/l})}),n.set(h,c)),c};return{pointStyleFor:function(t){var n;return null!==(n=i(t.getProperties()))&&void 0!==n?n:e},selectedPointStyleFor:function(t){var n,r,o=t.getProperties();return null!==(n=null!==(r=i(o,"symbolSelectedImageId"))&&void 0!==r?r:i(o))&&void 0!==n?n:e}}}(t),g=f.pointStyleFor;return{vertexStyle:i,selectedVertexStyle:r,midpointStyle:s,selectedMidpointStyle:a,editFeatureStyle:l,editFeatureStyleInvalid:h,selectedPointStyleFor:f.selectedPointStyleFor,createSketchStyle:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function(n){var i=n.getGeometry().getType();if("Point"===i)return[];var r=n.get("splitter"),o=e?c.invalid:c.valid;return"valid"===r&&(o=c.splitValid),"invalid"===r&&(o=c.splitInvalid),i===t?[o,d]:[o]}},createFeatureStyle:function(){return function(e){if("Point"===e.getGeometry().getType())return[g(e)];var n=e.getProperties(),i=t.mapStyleId,r=i&&n["stroke".concat(Hl(i))]||n.stroke||t.shapeStroke,o=i&&n["fill".concat(Hl(i))]||n.fill||t.shapeFill,s=n.strokeWidth||t.strokeWidth;return[new as({stroke:new es({color:r,width:s}),fill:new Qo({color:o})})]}}}},$l=n(473);function Zl(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Jl(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Kl(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||Jl(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jl(t,e){if(t){if("string"==typeof t)return Ql(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ql(t,e):void 0}}function Ql(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var th=function(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i},eh=function(t,e,n){var i=n[0]-e[0],r=n[1]-e[1],o=i*i+r*r;if(0===o)return[e[0],e[1]];var s=Math.max(0,Math.min(1,((t[0]-e[0])*i+(t[1]-e[1])*r)/o));return[e[0]+s*i,e[1]+s*r]},nh=function(t,e){return ih(t,e)?e:t},ih=function(t,e){return t?!!e&&("edge"===t.type&&"vertex"===e.type||("vertex"!==t.type||"edge"!==e.type)&&e.distSq<t.distSq):!!e},rh=function(t,e,n,i){for(var r=null,o=i&&t.length>1?t.length-1:t.length,s=i?o:o-1,a=0;a<o;a++){var l=t[a],h=th(e,l);h<=n&&(r=nh(r,{type:"vertex",coord:[l[0],l[1]],distSq:h}))}for(var c=0;c<s;c++){var u=t[c],d=t[(c+1)%o],f=eh(e,u,d),g=th(e,f);g<=n&&(r=nh(r,{type:"edge",coord:f,distSq:g}))}return r},oh=function(t,e,n,i,r,o){for(var s=null,a=0;a<i;a++){var l=e+2*a,h=e+(a+1)%n*2,c=[t[l],t[l+1]],u=[t[h],t[h+1]],d=eh(r,c,u),f=th(r,d);f<=o&&(s=nh(s,{type:"edge",coord:d,distSq:f,seg:[c,u]}))}return s},sh=function(t,e,n){return[t>0||n?t>0?t-1:e-1:null,t<e-1||n?t<e-1?t+1:0:null]},ah=function(t,e,n,i,r,o){for(var s=i===n,a=function(n){return null===n?null:[t[e+2*n],t[e+2*n+1]]},l=null,h=0;h<n;h++){var c=a(h),u=th(r,c);if(u<=o){var d=Kl(sh(h,n,s),2),f=d[0],g=d[1],p=[a(f),a(g)];l=nh(l,{type:"vertex",coord:c,distSq:u,adjacent:p})}}return l},lh=function(t,e,n,i,r,o){var s=(n-e)/2,a=o?s:s-1;return{vertex:ah(t,e,s,a,i,r),edge:oh(t,e,s,a,i,r)}},hh={point:function(t,e,n){var i=t.getCoordinates(),r=th(e,i);return r<=n?{type:"vertex",coord:[i[0],i[1]],distSq:r}:null},lineString:function(t,e,n){return rh(t.getCoordinates(),e,n,!1)},linearRing:function(t,e,n){return rh(t.getCoordinates(),e,n,!0)},polygon:function(t,e,n){var i,r=null,o=Zl(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s=i.value;r=nh(r,rh(s,e,n,!0))}}catch(t){o.e(t)}finally{o.f()}return r},multiLineString:function(t,e,n){var i,r=null,o=Zl(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s=i.value;r=nh(r,rh(s,e,n,!1))}}catch(t){o.e(t)}finally{o.f()}return r},multiPolygon:function(t,e,n){var i,r=null,o=Zl(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s,a=Zl(i.value);try{for(a.s();!(s=a.n()).done;){var l=s.value;r=nh(r,rh(l,e,n,!0))}}catch(t){a.e(t)}finally{a.f()}}}catch(t){o.e(t)}finally{o.f()}return r}},ch=function(t,e,n){var i=t.getGeometry();if(!i)return null;var r=i.getType(),o=hh[r[0].toLowerCase()+r.slice(1)];return o?o(i,e,n):null};function uh(t){return uh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},uh(t)}function dh(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function fh(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?dh(Object(n),!0).forEach(function(e){gh(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dh(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function gh(t,e,n){return(e=function(t){var e=function(t){if("object"!=uh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=uh(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==uh(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ph(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=yh(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function mh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||yh(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function yh(t,e){if(t){if("string"==typeof t)return _h(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_h(t,e):void 0}}function _h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var vh=function(t,e,n){if(!e||!n)return!1;var i=mh(t.extent,4),r=i[0],o=i[1],s=i[2],a=i[3],l=function(e,n,i){return Math.min(Math.abs(e-n),Math.abs(e-i))<=t.band},h=Math.abs(e[0]-n[0])<=t.eps&&l(e[0],r,s),c=Math.abs(e[1]-n[1])<=t.eps&&l(e[1],o,a);return h||c},xh=function(){return!0===globalThis.DEBUG_SNAP_VISIBILITY},Sh=function(t,e){xh()&&console.log("[snap-candidate-found]",{type:t.type,layerId:null==e?void 0:e.id,layerType:null==e?void 0:e.type,coord:[t.coord[0].toFixed(2),t.coord[1].toFixed(2)],distSq:t.distSq.toFixed(2)})},wh=function(t){var e=t.candidate,n=t.cursorCoord,i=t.mapboxLayer,r=t.boundaryState,o=t.map,s=t.vtLayers,a=t.resolution;return function(t,e){var n,i=function(t,e){if(!t)return null;var n=t.tileGrid,i=t.viewProj,r=t.sourceProj,o=t.zoom,s=function(t){return t?ne(t,i,r):null},a=s(e),l=n.getTileCoordForCoordAndZ(a,o),h=n.getTileCoordExtent(l),c=h[2]-h[0];return{toSource:s,anchor:a,extent:h,band:.0625*c,eps:c/4096*2}}(t,e.coord);if(!i)return!1;if("edge"===e.type){var r=mh(e.seg,2),o=r[0],s=r[1];return vh(i,i.toSource(o),i.toSource(s))}var a=mh(null!==(n=e.adjacent)&&void 0!==n?n:[],2),l=a[0],h=a[1];return vh(i,i.anchor,i.toSource(l))||vh(i,i.anchor,i.toSource(h))}(r,e)?(xh()&&console.log("[snap-filtered] tile clip artefact",e.type),!0):!("edge"!==e.type||"fill"!==(null==i?void 0:i.type)||!function(t,e,n,i,r,o){var s=t[0]-e[0],a=t[1]-e[1],l=s*s+a*a;if(l<1)return!1;var h=Math.sqrt(l),c=4*o,u=[t[0]+s/h*c,t[1]+a/h*c],d=i.getPixelFromCoordinate(u);return!!d&&!!i.forEachFeatureAtPixel(d,function(t){var e;return(null===(e=t.get("mapbox-layer"))||void 0===e?void 0:e.id)===n},{hitTolerance:2,layerFilter:function(t){return r.includes(t)}})}(e.coord,n,i.id,o,s,a)||(xh()&&console.log("[snap-filtered] invisible fill boundary"),0))};function Ch(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var bh=function(t){return function(e,n){var i,r,o=n.context,s=(r=2,function(t){if(Array.isArray(t))return t}(i=e)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(i,r)||function(t,e){if(t){if("string"==typeof t)return Ch(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ch(t,e):void 0}}(i,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=s[0],l=s[1];o.beginPath(),o.arc(a,l,10*n.pixelRatio,0,2*Math.PI),o.fillStyle=t,o.fill()}},Ih=function(t){return{vertex:new as({renderer:bh(t.snapVertex)}),edge:new as({renderer:bh(t.snapEdge)})}};const Eh="active",Ph=class extends fn{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(Eh)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Eh,t)}setMap(t){this.map_=t}};var Th=new Set(["pointermove","pointerdrag","pointerdown","pointerup","singleclick","click"]),Mh=new Set(["pointermove","pointerdrag"]),kh=function(t,e,n,i){if(null==e||!e.length)return null;var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=new Set,i=[],r=function(t){n=new Set,i=[];var e,r=ph(null!=t?t:[]);try{for(r.s();!(e=r.n()).done;){var o=e.value;"string"==typeof o?n.add(o):"function"==typeof(null==o?void 0:o.getSource)&&i.push(o)}}catch(t){r.e(t)}finally{r.f()}};return r(e),{query:function(e,r){xh()&&console.log("[snap-query]",{coord:[e[0].toFixed(2),e[1].toFixed(2)],radiusPx:r,vtLayerCount:n.size,olLayerCount:i.length});var o=t.getView().getResolution();if(!o)return null;for(var s=r*o,a=s*s,l=[e[0]-s,e[1]-s,e[0]+s,e[1]+s],h=null,c=0,u=i;c<u.length;c++){var d=u[c].getSource();if(d){var f,g=ph(d.getFeaturesInExtent(l));try{for(g.s();!(f=g.n()).done;){var p=f.value;h=nh(h,ch(p,e,a))}}catch(t){g.e(t)}finally{g.f()}}}if(n.size>0){var m=function(t){var e=[];return t.getLayers().forEach(function(t){"vectorTile"===t.get("layerType")&&e.push(t)}),e}(t),y=m.length>0?t.getPixelFromCoordinate(e):null;if(y){var _=new Map;t.forEachFeatureAtPixel(y,function(i,r){var s=i.get("mapbox-layer");if(n.has(null==s?void 0:s.id)){var l=function(t,e,n){var i=t.getType(),r=t.getFlatCoordinates(),o=null,s=null;if("Point"===i){var a=th(e,r);a<=n&&(o={type:"vertex",coord:[r[0],r[1]],distSq:a})}else if("LineString"===i){var l=lh(r,0,r.length,e,n,!1);o=l.vertex,s=l.edge}else if("Polygon"===i||"MultiLineString"===i){var h,c=0,u="Polygon"===i,d=Zl(t.getEnds());try{for(d.s();!(h=d.n()).done;){var f=h.value,g=lh(r,c,f,e,n,u);o=nh(o,g.vertex),s=nh(s,g.edge),c=f}}catch(t){d.e(t)}finally{d.f()}}return[o,s].filter(Boolean)}(i,e,a);if(l.length){_.has(r)||_.set(r,function(t,e){var n,i=t.getSource(),r=null==i?void 0:i.getTileGrid();if(!r)return null;var o=e.getView().getProjection(),s=null!==(n=i.getProjection())&&void 0!==n?n:o,a=r.getZForResolution(e.getView().getResolution(),0);return{tileGrid:r,viewProj:o,sourceProj:s,zoom:a}}(r,t));var c=_.get(r);h=function(t,e,n){var i,r=t,o=ph(e);try{for(o.s();!(i=o.n()).done;){var s=i.value;Sh(s,n.mapboxLayer),wh(fh({candidate:s},n))||(r=nh(r,s))}}catch(t){o.e(t)}finally{o.f()}return r}(h,l,{cursorCoord:e,mapboxLayer:s,boundaryState:c,map:t,vtLayers:m,resolution:o})}}},{hitTolerance:r,layerFilter:function(t){return m.includes(t)}})}}return h?{type:h.type,coord:h.coord}:null},setLayers:r}}(t,e),o=function(t,e){var n=Ih(e),i=new sl,r=new Na({source:i,style:function(t){var e;return null!==(e=n[t.get("snapType")])&&void 0!==e?e:null},zIndex:99,updateWhileAnimating:!0,updateWhileInteracting:!0});t.addLayer(r);var o=new ll,s=!1;return{show:function(t,e){o.setGeometry(new Qs(t)),o.set("snapType",e,!0),s?i.changed():(i.addFeature(o),s=!0)},hide:function(){s&&(i.clear(),s=!1)},updateColors:function(t){n=Ih(t),s&&i.changed()},remove:function(){i.clear(),t.removeLayer(r)}}}(t,n),s=!1,a=function(t,e,n,i){var r=new Ph({handleEvent:function(o){return r.getActive()&&function(t,e,n,i,r){var o=t.type;if("pointerout"!==o&&"pointerleave"!==o){if(Th.has(o)){var s=e.query(t.coordinate,i);s&&(t.coordinate=s.coord.slice()),Mh.has(o)&&r()&&(s?n.show(s.coord,s.type):n.hide())}}else n.hide()}(o,t,e,n,i),!0}});return r}(r,o,i,function(){return s});t.addInteraction(a),a.setActive(!1);var l=!1;return{snapRadius:i,apply:function(t){if(!l)return t;var e=r.query(t,i);return e?(o.show(e.coord,e.type),e.coord):(o.hide(),t)},hideIndicator:function(){o.hide()},setIndicatorActive:function(t){s=t,t||o.hide()},setActive:function(t){l=t,a.setActive(t),t||o.hide()},setSnapLayers:function(t){r.setLayers(null==t?e:t)},reattach:function(){t.removeInteraction(a),t.addInteraction(a)},updateColors:function(t){o.updateColors(t)},destroy:function(){t.removeInteraction(a),o.remove()}}};const Rh=class extends Xe{constructor(t,e,n){super(t),this.map=e,this.frameState=void 0!==n?n:null}},Fh=class extends Rh{constructor(t,e,n,i,r,o){super(t,e,r),this.originalEvent=n,this.pixel_=null,this.coordinate_=null,this.dragging=void 0!==i&&i,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()}},Oh="singleclick",Ah="pointerdrag",Lh="pointermove",Dh="pointerdown",Gh=Ge,jh=je,Vh=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},Nh=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Wh=function(t){const e=t.originalEvent;return"pointerId"in e&&e.isPrimary&&0===e.button};class Bh extends Yi{constructor(t,e,n){super(),void 0!==n&&void 0===e?this.setFlatCoordinates(n,t):(e=e||0,this.setCenterAndRadius(t,e,n))}clone(){const t=new Bh(this.flatCoordinates.slice(),void 0,this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){const r=this.flatCoordinates,o=t-r[0],s=e-r[1],a=o*o+s*s;if(a<i){if(0===a)for(let t=0;t<this.stride;++t)n[t]=r[t];else{const t=this.getRadius()/Math.sqrt(a);n[0]=r[0]+t*o,n[1]=r[1]+t*s;for(let t=2;t<this.stride;++t)n[t]=r[t]}return n.length=this.stride,a}return i}containsXY(t,e){const n=this.flatCoordinates,i=t-n[0],r=e-n[1];return i*i+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(t){const e=this.flatCoordinates,n=e[this.stride]-e[0];return m(e[0]-n,e[1]-n,e[0]+n,e[1]+n,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){if(O(t,this.getExtent())){const e=this.getCenter();return t[0]<=e[0]&&t[2]>=e[0]||t[1]<=e[1]&&t[3]>=e[1]||I(t,this.intersectsCoordinate.bind(this))}return!1}setCenter(t){const e=this.stride,n=this.flatCoordinates[e]-this.flatCoordinates[0],i=t.slice();i[e]=i[0]+n;for(let n=1;n<e;++n)i[e+n]=t[n];this.setFlatCoordinates(this.layout,i),this.changed()}setCenterAndRadius(t,e,n){this.setLayout(n,t,0),this.flatCoordinates||(this.flatCoordinates=[]);const i=this.flatCoordinates;let r=Us(i,0,t,this.stride);i[r++]=i[0]+e;for(let t=1,e=this.stride;t<e;++t)i[r++]=i[t];i.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 n=this.getCenter(),i=this.getStride();this.setCenter(ii(n,0,n.length,i,t,e,n)),this.changed()}}Bh.prototype.transform;const Xh=Bh,Yh=class extends Ph{constructor(t){super(t=t||{}),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==Ah)this.handleDragEvent(t),t.originalEvent.preventDefault();else if("pointerup"==t.type){const e=this.handleUpEvent(t);this.handlingDownUpSequence=e&&this.targetPointers.length>0}}else if(t.type==Dh){const n=this.handleDownEvent(t);this.handlingDownUpSequence=n,e=this.stopDown(n)}else t.type==Lh&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function zh(t,e){const n=t.length;return e<0?t[e+n]:e>=n?t[e-n]:t[e]}function Uh(t,e){const n=t.length;let i=Math.floor(e);const r=e-i;i>=n?i-=n:i<0&&(i+=n);let o=i+1;o>=n&&(o-=n);const s=t[i],a=s[0],l=s[1],h=t[o];return[a+(h[0]-a)*r,l+(h[1]-l)*r]}const Hh={index:-1,endIndex:NaN,closestTargetDistance:1/0};function qh(t,e,n,i){const r=t[0],o=t[1];let s=1/0,a=-1,l=NaN;for(let t=0;t<e.targets.length;++t){const n=e.targets[t],i=n.coordinates;let h,c=1/0;for(let t=0;t<i.length-1;++t){const e=ec(r,o,i[t],i[t+1]);e.squaredDistance<c&&(c=e.squaredDistance,h=t+e.along)}c<s&&(s=c,n.ring&&e.targetIndex===t&&(n.endIndex>n.startIndex?h<n.startIndex&&(h+=i.length):n.endIndex<n.startIndex&&h>n.startIndex&&(h-=i.length)),l=h,a=t)}const h=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const t=Uh(h.coordinates,l);q(n.getPixelFromCoordinate(t),n.getPixelFromCoordinate(e.startCoord))>i&&(c=!1)}if(c){const t=h.coordinates,e=t.length,n=h.startIndex,i=l;if(n<i){const r=Qh(t,n,i);Qh(t,n,i-e)<r&&(l-=e)}else{const r=Qh(t,n,i);Qh(t,n,i+e)<r&&(l+=e)}}return Hh.index=a,Hh.endIndex=l,Hh.closestTargetDistance=s,Hh}function $h(t,e){const n=[];for(let i=0;i<e.length;++i)Zh(t,e[i].getGeometry(),n);return n}function Zh(t,e,n){if(e instanceof fl)Kh(t,e.getCoordinates(),!1,n);else{if(e instanceof pl){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Kh(t,i[e],!1,n);return}if(e instanceof pa){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Kh(t,i[e],!0,n);return}if(e instanceof vl){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e){const r=i[e];for(let e=0,i=r.length;e<i;++e)Kh(t,r[e],!0,n)}return}if(e instanceof ul){const i=e.getGeometries();for(let e=0;e<i.length;++e)Zh(t,i[e],n);return}}}function Kh(t,e,n,i){const r=t[0],o=t[1];for(let t=0,s=e.length-1;t<s;++t){const s=ec(r,o,e[t],e[t+1]);if(0===s.squaredDistance){const r=t+s.along;return void i.push({coordinates:e,ring:n,startIndex:r,endIndex:r})}}}function Jh(t,e){return j(t[0],t[1],e[0],e[1])}function Qh(t,e,n){let i,r;e<n?(i=e,r=n):(i=n,r=e);const o=Math.ceil(i),s=Math.floor(r);if(o>s)return Jh(Uh(t,i),Uh(t,r));let a=0;i<o&&(a+=Jh(Uh(t,i),zh(t,o))),s<r&&(a+=Jh(zh(t,s),Uh(t,r)));for(let e=o;e<s-1;++e)a+=Jh(zh(t,e),zh(t,e+1));return a}const tc={along:0,squaredDistance:0};function ec(t,e,n,i){const r=n[0],o=n[1],s=i[0]-r,a=i[1]-o;let l=0,h=r,c=o;return 0===s&&0===a||(l=D(((t-r)*s+(e-o)*a)/(s*s+a*a),0,1),h+=s*l,c+=a*l),tc.along=l,tc.squaredDistance=X(j(t,e,h,c),10),tc}const nc="drawstart";class ic extends Xe{constructor(t,e){super(t),this.feature=e}}function rc(){const t=os();return function(e,n){return t[e.getGeometry().getType()]}}const oc=class extends Yh{constructor(t){const e=t;e.stopDown||(e.stopDown=je),super(e),this.on,this.once,this.un,this.options_=t,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=t.source?t.source:null,this.features_=t.features?t.features:null,this.snapTolerance_=t.snapTolerance?t.snapTolerance:12,this.type_=t.type,this.mode_=function(t){switch(t){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+t)}}(this.type_),this.stopClick_=!!t.stopClick,this.ignoreNextUpEvent_=!1,this.minPoints_=t.minPoints?t.minPoints:"Polygon"===this.mode_?3:2,this.maxPoints_="Circle"===this.mode_?2:t.maxPoints?t.maxPoints:1/0,this.finishCondition_=t.finishCondition?t.finishCondition:Ge,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let n=t.geometryFunction;if(!n){const t=this.mode_;if("Circle"===t)n=(t,e,n)=>{const i=e||new Xh([NaN,NaN]),r=se(t[0]),o=H(r,se(t[t.length-1]));i.setCenterAndRadius(r,Math.sqrt(o),this.geometryLayout_);const s=re();return s&&i.transform(n,s),i};else{let e;"Point"===t?e=Qs:"LineString"===t?e=fl:"Polygon"===t&&(e=pa),n=(n,i,r)=>(i?"Polygon"===t?n[0].length?i.setCoordinates([n[0].concat([n[0][0]])],this.geometryLayout_):i.setCoordinates([],this.geometryLayout_):i.setCoordinates(n,this.geometryLayout_):i=new e(n,this.geometryLayout_),i)}}this.geometryFunction_=n,this.dragVertexDelay_=void 0!==t.dragVertexDelay?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new Na({source:new sl({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:rc(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:Vh,this.freehandCondition_,t.freehand?this.freehandCondition_=Gh:this.freehandCondition_=t.freehandCondition?t.freehandCondition:Nh,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(Eh,this.updateState_)}setTrace(t){let e;e=t?!0===t?Gh:t:jh,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=Gh:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Nh}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(t){"contextmenu"===t.originalEvent.type&&t.originalEvent.preventDefault(),this.freehand_="Point"!==this.mode_&&this.freehandCondition_(t);let e=t.type===Lh,n=!0;return!this.freehand_&&this.lastDragTime_&&t.type===Ah&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&void 0!==this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&t.type===Ah&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),n=!1):this.freehand_&&t.type===Dh?n=!1:e&&this.getPointerCount()<2?(n=t.type===Lh,n&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===Ah&&void 0===this.downTimeout_)&&this.handlePointerMove_(t)):"dblclick"===t.type&&(n=!1),super.handleEvent(t)&&n}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 Fh(Lh,t.map,t.originalEvent,!1,t.frameState))},this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active)return void this.deactivateTrace_();const e=this.getMap(),n=h([e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_])]),i=this.traceSource_.getFeaturesInExtent(n);if(0===i.length)return;const r=$h(t.coordinate,i);r.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:r,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const n=t.startIndex<=t.endIndex;n===t.startIndex<=e?n&&e>t.endIndex||!n&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(n&&e<t.endIndex||!n&&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 n=0;if(t<e){const i=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),n=r-i+1}else{const i=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),n=i-r+1}n>0&&this.removeLastPoints_(n)}addTracedCoordinates_(t,e,n){if(e===n)return;const i=[];if(e<n){const r=Math.ceil(e);let o=Math.floor(n);o===n&&(o-=1);for(let e=r;e<=o;++e)i.push(zh(t.coordinates,e))}else{const r=Math.floor(e);let o=Math.ceil(n);o===n&&(o+=1);for(let e=r;e>=o;--e)i.push(zh(t.coordinates,e))}i.length&&this.appendCoordinates(i)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&q(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.snapTolerance_)return;const n=qh(t.coordinate,e,this.getMap(),this.snapTolerance_);if(e.targetIndex!==n.index){if(-1!==e.targetIndex){const t=e.targets[e.targetIndex];this.removeTracedCoordinates_(t.startIndex,t.endIndex)}const t=e.targets[n.index];this.addTracedCoordinates_(t,t.startIndex,n.endIndex)}else{const t=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(t,n.endIndex)}e.targetIndex=n.index;const i=e.targets[e.targetIndex];i.endIndex=n.endIndex;const r=Uh(i.coordinates,i.endIndex),o=this.getMap().getPixelFromCoordinate(r);t.coordinate=r,t.pixel=[Math.round(o[0]),Math.round(o[1])]}handleDragEvent(t){this.ignoreNextUpEvent_=!0,super.handleDragEvent(t)}handleUpEvent(t){let e=!0;if(0===this.getPointerCount()){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(t);const n=this.traceState_.active;if(this.ignoreNextUpEvent_||this.toggleTraceState_(t),this.shouldHandle_){const i=!this.finishCoordinate_;i&&this.startDrawing_(t.coordinate),!i&&this.freehand_?this.finishDrawing():this.freehand_||i&&"Point"!==this.mode_||(this.atFinish_(t.pixel,n)?this.finishCondition_(t)&&this.finishDrawing():this.addToDrawing_(t.coordinate)),e=!1}else this.freehand_&&this.abortDrawing()}return this.ignoreNextUpEvent_=!1,!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_,n=t.pixel,i=e[0]-n[0],r=e[1]-n[1],o=i*i+r*r;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}this.finishCoordinate_?(this.updateTrace_(t),this.modifyDrawing_(t.coordinate)):this.createOrUpdateSketchPoint_(t.coordinate.slice())}atFinish_(t,e){let n=!1;if(this.sketchFeature_){let i=!1,r=[this.finishCoordinate_];const o=this.mode_;if("Point"===o)n=!0;else if("Circle"===o)n=2===this.sketchCoords_.length;else if("LineString"===o)i=!e&&this.sketchCoords_.length>this.minPoints_;else if("Polygon"===o){const t=this.sketchCoords_;i=t[0].length>this.minPoints_,r=[t[0][0],t[0][t[0].length-2]],r=e?[t[0][0]]:[t[0][0],t[0][t[0].length-2]]}if(i){const e=this.getMap();for(let i=0,o=r.length;i<o;i++){const o=r[i],s=e.getPixelFromCoordinate(o),a=t[0]-s[0],l=t[1]-s[1],h=this.freehand_?1:this.snapTolerance_;if(n=Math.sqrt(a*a+l*l)<=h,n){this.finishCoordinate_=o;break}}}}return n}createOrUpdateSketchPoint_(t){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(t):(this.sketchPoint_=new ll(new Qs(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new ll);const e=t.getLinearRing(0);let n=this.sketchLine_.getGeometry();n?(n.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),n.changed()):(n=new fl(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(n))}startDrawing_(t){const e=this.getMap().getView().getProjection(),n=Xi(this.geometryLayout_);for(;t.length<n;)t.push(0);this.finishCoordinate_=t,"Point"===this.mode_?this.sketchCoords_=t.slice():"Polygon"===this.mode_?(this.sketchCoords_=[[t.slice(),t.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[t.slice(),t.slice()],this.sketchLineCoords_&&(this.sketchLine_=new ll(new fl(this.sketchLineCoords_)));const i=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new ll,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(i),this.updateSketchFeatures_(),this.dispatchEvent(new ic(nc,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),n=this.sketchFeature_.getGeometry(),i=e.getView().getProjection(),r=Xi(this.geometryLayout_);let o,s;for(;t.length<r;)t.push(0);"Point"===this.mode_?s=this.sketchCoords_:"Polygon"===this.mode_?(o=this.sketchCoords_[0],s=o[o.length-1],this.atFinish_(e.getPixelFromCoordinate(t))&&(t=this.finishCoordinate_.slice())):(o=this.sketchCoords_,s=o[o.length-1]),s[0]=t[0],s[1]=t[1],this.geometryFunction_(this.sketchCoords_,n,i),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(t),"Polygon"===n.getType()&&"Polygon"!==this.mode_?this.createOrUpdateCustomSketchLine_(n):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(t){const e=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection();let i,r;const o=this.mode_;return"LineString"===o||"Circle"===o?(this.finishCoordinate_=t.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(t.slice()),this.geometryFunction_(r,e,n)):"Polygon"===o&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(t.slice()),i&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,n)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),i?this.finishDrawing():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection(),i=this.mode_;for(let r=0;r<t;++r){let t;if("LineString"===i||"Circle"===i){if(t=this.sketchCoords_,t.splice(-2,1),t.length>=2){this.finishCoordinate_=t[t.length-2].slice();const e=this.finishCoordinate_.slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}this.geometryFunction_(t,e,n),"Polygon"===e.getType()&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if("Polygon"===i){t=this.sketchCoords_[0],t.splice(-2,1);const i=this.sketchLine_.getGeometry();if(t.length>=2){const e=t[t.length-2].slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}i.setCoordinates(t),this.geometryFunction_(this.sketchCoords_,e,n)}if(1===t.length){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return null;let e=this.sketchCoords_;const n=t.getGeometry(),i=this.getMap().getView().getProjection();return"LineString"===this.mode_?(e.pop(),this.geometryFunction_(e,n,i)):"Polygon"===this.mode_&&(e[0].pop(),this.geometryFunction_(e,n,i),e=n.getCoordinates()),"MultiPoint"===this.type_?t.setGeometry(new yl([e])):"MultiLineString"===this.type_?t.setGeometry(new pl([e])):"MultiPolygon"===this.type_&&t.setGeometry(new vl([e])),this.dispatchEvent(new ic("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 ic("drawabort",t))}appendCoordinates(t){const e=this.mode_,n=!this.sketchFeature_;let i;if(n&&this.startDrawing_(t[0]),"LineString"===e||"Circle"===e)i=this.sketchCoords_;else{if("Polygon"!==e)return;i=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[]}n&&i.shift(),i.pop();for(let e=0;e<t.length;e++)this.addToDrawing_(t[e]);const r=t[t.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(t){const e=t.getGeometry();this.sketchFeature_=t,this.sketchCoords_=e.getCoordinates();const n=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=n.slice(),this.sketchCoords_.push(n.slice()),this.sketchPoint_=new ll(new Qs(n)),this.updateSketchFeatures_(),this.dispatchEvent(new ic(nc,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)}};var sc=function(t,e){var n=t.getPixelFromCoordinate(e);return n?{x:n[0],y:n[1]}:null},ac=function(t,e){return Math.hypot(t.x-e.x,t.y-e.y)},lc=function(t,e,n,i){var r=t.getPixelFromCoordinate(e);return r?t.getCoordinateFromPixel([r[0]+n,r[1]+i]):e};function hc(t){return function(t){if(Array.isArray(t))return cc(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return cc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?cc(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function cc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var uc=function(t){var e=t.drawInteraction,n=t.mapProvider,i=t.snap,r=t.canFinish,o=t.canPlace,s=null,a=null,l=function(){s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=null};e.on("drawstart",function(t){return l(t.feature)}),e.on("drawend",function(){return l()}),e.on("drawabort",function(){return l()});var h=function(){var t=n.getCenter();return i?i.apply(t):t};return{placeVertex:function(){var t=h();if(null==i||i.hideIndicator(),s){var n=s.getGeometry(),l=n.getCoordinates(),c="Polygon"===n.getType()?l[0]||[]:l,u=function(t){var e=t.drawInteraction,n=t.canFinish,i=t.geom,r=t.sketchCoords,o=t.coord,s=t.lastPlacedCoord;if(s&&s[0]===o[0]&&s[1]===o[1])return null!=n&&n()&&e.finishDrawing(),{handled:!0,lastPlacedCoord:null};var a=e.getMap();if(function(t,e,n,i){if("Polygon"!==i||n.length<4)return!1;var r=sc(t,e),o=sc(t,n[0]);return!(!r||!o)&&ac(r,o)<12}(a,o,r,i.getType()))return e.finishDrawing(),{handled:!0,lastPlacedCoord:s};var l=Dl(i);if(l){var h=a.getPixelFromCoordinate(l),c=a.getPixelFromCoordinate(o);if(h&&c){var u=h[0]-c[0],d=h[1]-c[1];if(u*u+d*d<4)return{handled:!0,lastPlacedCoord:o}}}return{handled:!1,lastPlacedCoord:s}}({drawInteraction:e,canFinish:r,geom:n,sketchCoords:c,coord:t,lastPlacedCoord:a});if(a=u.lastPlacedCoord,u.handled)return}o&&!o(t)||(e.appendCoordinates([t]),a=t)},updateRubberbanding:function(){if(s){var t=s.getGeometry();t.getCoordinates().length&&function(t,e){if("LineString"===t.getType()){var n=hc(t.getCoordinates());n[n.length-1]=e,t.setCoordinates(n)}else if("Polygon"===t.getType()){var i=t.getCoordinates().map(function(t,n){if(0!==n)return t;var i=hc(t);return i[i.length-1]=e,i});t.setCoordinates(i)}}(t,h())}else i&&i.apply(n.getCenter())},clearLastCoord:function(){a=null}}},dc=n(195),fc=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),gc=function(t,e){t&&(["touch","keyboard"].includes(e)?t.fixAtCenter():t.hide())},pc=function(t){var e=t.container,n=t.addVertexButtonId,i=t.olView,r=t.onUndo,o=t.getInterfaceType,s=t.setInterfaceType,a=t.clearLastCoord,l=t.updateRubberbanding,h=t.placeVertex,c=function(){("mouse"!==o()||null!=i&&i.getAnimating())&&l()};null==i||i.on("change:center",c);var u=function(t){e.contains(document.activeElement)&&(fc.has(t.key)?s("keyboard"):("Enter"===t.key&&(t.preventDefault(),s("keyboard"),h()),"z"===t.key&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),null==r||r())))},d=function(t){n&&t.target.closest("#".concat(n))&&h()},f=function(t){"touch"!==t.pointerType&&(s("mouse"),a())},g=function(){s("touch")},p=function(){"mouse"!==o()&&l()};return globalThis.addEventListener("keydown",u),globalThis.addEventListener("click",d),e.addEventListener("pointerdown",f),e.addEventListener("touchstart",g,{passive:!0}),e.addEventListener("pointermove",p),globalThis.addEventListener("keyup",dc.z,{capture:!0}),{destroy:function(){null==i||i.un("change:center",c),globalThis.removeEventListener("keydown",u),globalThis.removeEventListener("click",d),e.removeEventListener("pointerdown",f),e.removeEventListener("touchstart",g),e.removeEventListener("pointermove",p),globalThis.removeEventListener("keyup",dc.z,{capture:!0})}}},mc=n(360),yc="styleschanged",_c=n(520),vc=n(9),xc=n(788),Sc=n(715),wc=function(t,e){return!!e&&Ll(e.getGeometry()).length>=vc.n8[t]},Cc=function(t,e,n,i){return function(r){if(!Vh(r))return!1;var o=n();if(!i(r.coordinate))return!1;if(!o||wc(e,o))return!0;var s=Dl(o.getGeometry());if(!s)return!0;var a=t.getPixelFromCoordinate(s);if(!a)return!0;var l=r.pixel[0]-a[0],h=r.pixel[1]-a[1];return l*l+h*h>4}},bc={Polygon:2,LineString:1},Ic=function(t){var e=t.map,n=t.manager,i=t.options,r=i.geometryType,o=i.featureId,s=i.properties,a=void 0===s?{}:s,l=null,h=!1,c=n.styles.createSketchStyle(r),u=function(t,e){var n=0,i=function(n,i){setTimeout(function(){var r,o,s,a,l,h,c=e();c&&t.emit(mc.k.GEOMETRY_CHANGE,{feature:(r=t.store,o=c,s=r.toGeoJSON(o),a=s.geometry.type,l=bc[a],h=("Polygon"===a?s.geometry.coordinates[0]:s.geometry.coordinates).slice(0,-l),{type:"Feature",geometry:"Polygon"===a?{type:"Polygon",coordinates:[h]}:{type:"LineString",coordinates:h},properties:s.properties}),phase:n,vertexIndex:i})},0)};return{resetCount:function(){n=0},updateVertexCount:function(){var r=e();if(r){var o=Ll(r.getGeometry()).length;t.emit(mc.k.VERTEX_CHANGE,{numVertices:o}),o>n&&i("commit-add",o-1),n=o}},emitUndoValidation:function(){var t=e();t&&i("commit-delete",Ll(t.getGeometry()).length)}}}(n,function(){return l}),d=u.updateVertexCount,f=u.resetCount,g=u.emitUndoValidation,p=function(t){var e=t.manager,n=t.geometryType,i=t.getSketch;return function(t){var r=i(),o=(0,_c.$b)({placed:r?Ll(r.getGeometry()):[],point:t,geometryType:n,onGeometryChange:e._geometryValidator});return o.valid||e.emit(mc.k.PLACEMENT_BLOCKED,o.blocked),o.valid}}({manager:n,geometryType:r,getSketch:function(){return l}}),m=new oc({type:r,style:function(t){return c(t)},stopClick:!0,snapTolerance:Ol.vf.snapRadius,condition:Cc(e,r,function(){return l},p),finishCondition:function(){return!1!==n._geometryValid}});e.addInteraction(m);var y=(0,xc.De)({onChange:function(t){h=t,c=n.styles.createSketchStyle(r,h),m.overlay_.changed()}}),_=(0,Sc.O)({onStrokeChange:function(t,e){return y.set(t,e)},onPlaceChange:function(t,e){return n.emit(mc.k.CAN_PLACE_CHANGE,{canPlace:!t,reason:e})}}),v=_c.dV[r],x=function(){c=n.styles.createSketchStyle(r,h),m.overlay_.changed()};n.on(yc,x),m.overlay_.updateWhileAnimating_=!0,function(t,e){var n=e.manager,i=e.featureId,r=e.properties,o=e.onStart,s=e.onSketchChange;t.on("drawstart",function(t){o(t.feature),t.feature.getGeometry().on("change",s)}),t.on("drawend",function(t){return function(t,e,n,i){e.setId(String(n)),e.setProperties(i),t.store.source.addFeature(e),t.emit(mc.k.CREATE,t.store.toGeoJSON(e))}(n,t.feature,i,r)}),t.on("drawabort",function(){n.emit(mc.k.CANCEL)})}(m,{manager:n,featureId:o,properties:a,onStart:function(t){l=t,f()},onSketchChange:function(){d(),function(){if(l){var t=function(t,e){var n,i=e.getGeometry(),r=i.getCoordinates(),o="Polygon"===t?null!==(n=r[0])&&void 0!==n?n:[]:r;return{feature:{type:"Feature",geometry:"Polygon"===t?{type:"Polygon",coordinates:[o]}:{type:"LineString",coordinates:o}},numVertices:Ll(i).length}}(r,l),e=t.feature,i=t.numVertices;_.update({feature:e,context:{mode:v},numVertices:i,onGeometryChange:n._geometryValidator})}}()}});var S=function(t){var e=t.drawInteraction,n=t.options,i=t.geometryType,r=t.getSketch,o=t.updateVertexCount,s=t.emitUndoValidation,a=t.canPlaceVertex;return function(t){var e,n=t.drawInteraction,i=t.options,r=i.container,o=i.addVertexButtonId,s=i.mapProvider,a=i.snap,l=i.onUndo,h=i.canFinish,c=i.canPlace,u=i.crossHair,d=null!==(e=i.interfaceType)&&void 0!==e?e:"mouse",f=function(){return d},g=uc({drawInteraction:n,mapProvider:s,snap:a,canFinish:h,canPlace:c}),p=n.getMap(),m=null==p?void 0:p.getView(),y=pc({container:r,addVertexButtonId:o,olView:m,onUndo:l,getInterfaceType:f,setInterfaceType:function(t){d=t,gc(u,t)},clearLastCoord:g.clearLastCoord,updateRubberbanding:g.updateRubberbanding,placeVertex:g.placeVertex});gc(u,d),u&&(u.activate=g.placeVertex);var _=function(){null!=m&&m.getAnimating()&&g.updateRubberbanding()};return null==p||p.on("postrender",_),{getInterfaceType:f,setInterfaceType:function(t){d=t,gc(u,t),"mouse"!==t&&g.updateRubberbanding()},destroy:function(){(null==u?void 0:u.activate)===g.placeVertex&&(u.activate=null),y.destroy(),null==p||p.un("postrender",_)}}}({drawInteraction:e,options:{container:n.container,interfaceType:n.interfaceType,addVertexButtonId:n.addVertexButtonId,mapProvider:n.mapProvider,snap:n.snap,crossHair:n.crossHair,onUndo:function(){e.removeLastPoint(),o(),s()},canFinish:function(){return wc(i,r())},canPlace:a}})}({drawInteraction:m,options:i,geometryType:r,getSketch:function(){return l},updateVertexCount:d,emitUndoValidation:g,canPlaceVertex:p});return function(t){var e=t.map,n=t.manager,i=t.drawInteraction,r=t.input,o=t.geometryType,s=t.getSketch,a=t.updateVertexCount,l=t.emitUndoValidation,h=t.onStylesChanged,c=t.clearSketch,u=t.liveStroke,d=t.liveDrawChecks;return{done:function(){wc(o,s())&&i.finishDrawing()},cancel:function(){i.abortDrawing()},undo:function(){i.removeLastPoint(),a(),l()},setInvalid:t.setInvalid,setInterfaceType:function(t){r.setInterfaceType(t)},setDrawingPreviewProperty:function(t,e){var n=s();n&&(n.set(t,e),i.overlay_.changed())},destroy:function(){u.destroy(),d.destroy(),n.off(yc,h),n.emit(mc.k.INTERFACE_TYPE_CHANGE,{interfaceType:r.getInterfaceType()}),r.destroy(),e.removeInteraction(i),c()}}}({map:e,manager:n,drawInteraction:m,input:S,geometryType:r,getSketch:function(){return l},updateVertexCount:d,emitUndoValidation:g,onStylesChanged:x,clearSketch:function(){l=null},setInvalid:function(t){return y.set(t)},liveStroke:y,liveDrawChecks:_})};function Ec(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||Tc(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Pc(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Tc(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Tc(t,e){if(t){if("string"==typeof t)return Mc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mc(t,e):void 0}}function Mc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var kc=function(t){if(null==t||!t.coordinates)return[];switch(t.type){case"LineString":return t.coordinates;case"Polygon":return t.coordinates.flatMap(function(t){return t.slice(0,-1)});case"MultiLineString":return t.coordinates.flat(1);case"MultiPolygon":return t.coordinates.flatMap(function(t){return t.flatMap(function(t){return t.slice(0,-1)})});default:return[]}},Rc=function(t){if(null==t||!t.coordinates)return[];var e=[],n=0;switch(t.type){case"LineString":e.push({start:0,length:t.coordinates.length,path:[],closed:!1});break;case"Polygon":t.coordinates.forEach(function(t,i){var r=t.length-1;e.push({start:n,length:r,path:[i],closed:!0}),n+=r});break;case"MultiLineString":t.coordinates.forEach(function(t,i){e.push({start:n,length:t.length,path:[i],closed:!1}),n+=t.length});break;case"MultiPolygon":t.coordinates.forEach(function(t,i){t.forEach(function(t,r){var o=t.length-1;e.push({start:n,length:o,path:[i,r],closed:!0}),n+=o})})}return e},Fc=function(t,e){var n,i=Pc(t);try{for(i.s();!(n=i.n()).done;){var r=n.value;if(e>=r.start&&e<r.start+r.length)return{segment:r,localIdx:e-r.start}}}catch(t){i.e(t)}finally{i.f()}return null},Oc=function(t,e){var n,i=t.coordinates,r=Pc(e);try{for(r.s();!(n=r.n()).done;)i=i[n.value]}catch(t){r.e(t)}finally{r.f()}return i},Ac=function(t){var e=kc(t),n=Rc(t);if(!e.length||!n.length)return[];var i,r=[],o=Pc(n);try{for(o.s();!(i=o.n()).done;)for(var s=i.value,a=s.closed?s.length:s.length-1,l=0;l<a;l++){var h=s.start+l,c=s.start+(l+1)%s.length,u=Ec(e[h],2),d=u[0],f=u[1],g=Ec(e[c],2),p=g[0],m=g[1];r.push([(d+p)/2,(f+m)/2])}}catch(t){o.e(t)}finally{o.f()}return r},Lc=function(t){var e=t.map,n=t.manager,i=t.store,r=t.olFeature,o=t.interfaceType,s=t.layers,a=s.vertexLayer,l=s.midpointLayer,h=s.activeLayer,c={olFeature:r,selectedVertexIndex:-1,selectedVertexType:null,vertices:[],midpoints:[],interfaceType:null!=o?o:"mouse"},u={onDeselect:null,onUpdate:null},d=function(){var t=r.getGeometry();return{type:t.getType(),coordinates:t.getCoordinates()}},f=function(){var t=d();c.vertices=kc(t),c.midpoints=Ac(t),l.update(t),a.update(t),h.update(c)},g=function(t,e,n){return function(i,r){i&&setTimeout(function(){t.emit(mc.k.GEOMETRY_CHANGE,{feature:e.toGeoJSON(n),phase:i,vertexIndex:r})},0)}}(n,i,r),p=function(){return f()};return r.getGeometry().on("change",p),{state:c,getState:function(){return c},setState:function(t){var i,r;Object.assign(c,t),void 0!==t.selectedVertexIndex&&function(t,e){var n,i=e.midpointLayer,r=e.activeLayer,o=e.manager,s=e.hooks;e.vertexLayer.setSelected("vertex"===t.selectedVertexType?t.selectedVertexIndex:-1),i.setSelected("midpoint"===t.selectedVertexType?t.selectedVertexIndex-t.vertices.length:-1),t.selectedVertexIndex<0&&(null===(n=s.onDeselect)||void 0===n||n.call(s)),r.update(t),o.emit(mc.k.VERTEX_SELECTION,{index:"vertex"===t.selectedVertexType?t.selectedVertexIndex:-1,numVertices:t.vertices.length})}(c,{vertexLayer:a,midpointLayer:l,activeLayer:h,manager:n,hooks:u}),void 0!==t.vertices&&(r=d(),l.update(r),a.update(r),c.midpoints=l.getCoords(),h.update(c),null===(i=u.onUpdate)||void 0===i||i.call(u),e.render())},syncGeom:function(){f(),n.emit(mc.k.VERTEX_CHANGE,{numVertices:c.vertices.length}),n.emit(mc.k.UPDATE,i.toGeoJSON(r))},emitGeometryValidation:g,updateLayersFromGeom:f,setHooks:function(t){var e=t.onDeselect,n=t.onUpdate;return Object.assign(u,{onDeselect:e,onUpdate:n})},destroy:function(){r.getGeometry().un("change",p)}}};const Dc=[0,0,0,0],Gc=[],jc="modifyend";function Vc(t,e,n){let i;switch(e){case"LineString":i=t;break;case"MultiLineString":case"Polygon":i=t[n[0]];break;case"MultiPolygon":i=t[n[1]][n[0]]}return i}class Nc extends Xe{constructor(t,e,n){super(t),this.features=e,this.mapBrowserEvent=n}}function Wc(t,e){return t.index-e.index}function Bc(t,e,n){const i=e.geometry;if("Circle"===i.getType()){let r=i;if(1===e.index){const e=re();e&&(r=r.clone().transform(e,n));const i=H(r.getCenter(),se(t)),o=Math.sqrt(i)-r.getRadius();return o*o}}const r=se(t);return Gc[0]=se(e.segment[0]),Gc[1]=se(e.segment[1]),function(t,e){return H(t,z(t,e))}(r,Gc)}function Xc(t,e,n){const i=e.geometry;if("Circle"===i.getType()&&1===e.index){let e=i;const r=re();return r&&(e=e.clone().transform(r,n)),oe(e.getClosestPoint(se(t)))}const r=se(t);return Gc[0]=se(e.segment[0]),Gc[1]=se(e.segment[1]),oe(z(r,Gc))}function Yc(){const t=os();return function(e,n){return t.Point}}const zc=class extends Yh{constructor(t){if(super(t),this.handleSourceAdd_=this.handleSourceAdd_.bind(this),this.handleSourceRemove_=this.handleSourceRemove_.bind(this),this.handleExternalCollectionAdd_=this.handleExternalCollectionAdd_.bind(this),this.handleExternalCollectionRemove_=this.handleExternalCollectionRemove_.bind(this),this.handleFeatureChange_=this.handleFeatureChange_.bind(this),this.on,this.once,this.un,this.condition_=t.condition?t.condition:Wh,this.defaultDeleteCondition_=function(t){return function(t){const e=t.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey}(t)&&function(t){return t.type==Oh}(t)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:Gh,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new tl,this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Na({source:new sl({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:Yc(),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.traceSource_=t.traceSource||t.source||null,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSegments_=null,this.hitDetection_=null,this.filterFunctionWasSupplied_=null!=t.filter,this.filter_=t.filter?t.filter:()=>!0,this.coordinatesEqual_=t.sharedVerticesEqual?t.sharedVerticesEqual:U,!t.features&&!t.source)throw new Error("The modify interaction requires features collection or a source");let e;t.features?(e=t.features.getArray(),t.features.addEventListener(Wa,this.handleExternalCollectionAdd_),t.features.addEventListener(Ba,this.handleExternalCollectionRemove_),this.featuresCollection_=t.features):t.source&&(e=t.source.getFeatures(),t.source.addEventListener(il,this.handleSourceAdd_),t.source.addEventListener(rl,this.handleSourceRemove_),this.source_=t.source),e.forEach(t=>{t.addEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(nn,this.handleFeatureChange_)}),t.hitDetection&&(this.hitDetection_=t.hitDetection),this.features_=[],e.filter(this.filter_).forEach(t=>this.addFeature_(t)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=void 0===t.snapToPointer?!this.hitDetection_:t.snapToPointer}setTrace(t){let e;e=t?!0===t?Gh:t:jh,this.traceCondition_=e}addFeature_(t){this.features_.push(t);const e=t.getGeometry();if(e){const n=this.SEGMENT_WRITERS_[e.getType()];n&&n(t,e)}const n=this.getMap();n&&n.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastCoordinate_)}willModifyFeatures_(t,e){if(!this.featuresBeingModified_){this.featuresBeingModified_=new za;const n=this.featuresBeingModified_.getArray();for(let t=0,i=e.length;t<i;++t){const i=e[t].feature;i&&!n.includes(i)&&this.featuresBeingModified_.push(i)}0===this.featuresBeingModified_.getLength()?this.featuresBeingModified_=null:this.dispatchEvent(new Nc("modifystart",this.featuresBeingModified_,t))}}removeFeature_(t){const e=this.features_.indexOf(t);this.features_.splice(e,1),this.removeFeatureSegmentData_(t),this.vertexFeature_&&0===this.features_.length&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}removeFeatureSegmentData_(t){const e=this.rBush_,n=[];e.forEach(function(e){t===e.feature&&n.push(e)});for(let t=n.length-1;t>=0;--t){const i=n[t];for(let t=this.dragSegments_.length-1;t>=0;--t)this.dragSegments_[t][0]===i&&this.dragSegments_.splice(t,1);e.remove(i)}}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){const e=t.feature;e&&this.externalAddFeatureHandler_(e)}handleSourceRemove_(t){const e=t.feature;e&&this.externalRemoveFeatureHandler_(e)}handleExternalCollectionAdd_(t){const e=t.element;e&&this.externalAddFeatureHandler_(e)}handleExternalCollectionRemove_(t){const e=t.element;e&&this.externalRemoveFeatureHandler_(e)}externalAddFeatureHandler_(t){t.addEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(nn,this.handleFeatureChange_),this.filter_(t)&&this.addFeature_(t)}externalRemoveFeatureHandler_(t){t.removeEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(nn,this.handleFeatureChange_),this.removeFeature_(t)}handleFeatureChange_(t){if(!this.changingFeature_){const e=t.target;this.removeFeature_(e),this.filter_(e)&&this.addFeature_(e)}}writePointGeometry_(t,e){const n=e.getCoordinates(),i={feature:t,geometry:e,segment:[n,n]};this.rBush_.insert(e.getExtent(),i)}writeMultiPointGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i],o={feature:t,geometry:e,depth:[i],index:i,segment:[r,r]};this.rBush_.insert(e.getExtent(),o)}}writeLineStringGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length-1;i<r;++i){const r=n.slice(i,i+2),o={feature:t,geometry:e,index:i,segment:r};this.rBush_.insert(h(r),o)}}writeMultiLineStringGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i];for(let n=0,o=r.length-1;n<o;++n){const o=r.slice(n,n+2),s={feature:t,geometry:e,depth:[i],index:n,segment:o};this.rBush_.insert(h(o),s)}}}writePolygonGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i];for(let n=0,o=r.length-1;n<o;++n){const o=r.slice(n,n+2),s={feature:t,geometry:e,depth:[i],index:n,segment:o};this.rBush_.insert(h(o),s)}}}writeMultiPolygonGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i];for(let n=0,o=r.length;n<o;++n){const o=r[n];for(let r=0,s=o.length-1;r<s;++r){const s=o.slice(r,r+2),a={feature:t,geometry:e,depth:[n,i],index:r,segment:s};this.rBush_.insert(h(s),a)}}}}writeCircleGeometry_(t,e){const n=e.getCenter(),i={feature:t,geometry:e,index:0,segment:[n,n]},r={feature:t,geometry:e,index:1,segment:[n,n]},o=[i,r];i.featureSegments=o,r.featureSegments=o,this.rBush_.insert(_(n),i);let s=e;const a=re();if(a&&this.getMap()){const t=this.getMap().getView().getProjection();s=s.clone().transform(a,t),s=ya(s).transform(t,a)}this.rBush_.insert(s.getExtent(),r)}writeGeometryCollectionGeometry_(t,e){const n=e.getGeometriesArray();for(let e=0;e<n.length;++e){const i=n[e];(0,this.SEGMENT_WRITERS_[i.getType()])(t,i)}}createOrUpdateVertexFeature_(t,e,n,i){let r=this.vertexFeature_;return r?r.getGeometry().setCoordinates(t):(r=new ll(new Qs(t)),this.vertexFeature_=r,this.overlay_.getSource().addFeature(r)),r.set("features",e),r.set("geometries",n),r.set("existing",i),r}handleEvent(t){if(!t.originalEvent)return!0;let e;return this.lastPointerEvent_=t,t.map.getView().getInteracting()||t.type!=Lh||this.handlingDownUpSequence||this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(e=!(t.type!=Oh||!this.ignoreNextSingleClick_)||this.removePoint()),t.type==Oh&&(this.ignoreNextSingleClick_=!1),super.handleEvent(t)&&!e}findInsertVerticesAndUpdateDragSegments_(t){if(this.handlePointerAtPixel_(t),this.dragSegments_.length=0,this.featuresBeingModified_=null,!this.vertexFeature_)return;const e=this.getMap().getView().getProjection(),n=[],i=this.vertexFeature_.getGeometry().getCoordinates(),r=h([i]),o=this.rBush_.getInExtent(r),s={};o.sort(Wc);for(let r=0,a=o.length;r<a;++r){const a=o[r],l=a.segment;let h=un(a.geometry);const c=a.depth;if(c&&(h+="-"+c.join("-")),s[h]||(s[h]=new Array(2)),"Circle"===a.geometry.getType()&&1===a.index){const n=Xc(t,a,e);this.coordinatesEqual_(n,i)&&!s[h][0]&&(this.dragSegments_.push([a,0]),s[h][0]=a);continue}if(!this.coordinatesEqual_(l[0],i)||s[h][0])if(!this.coordinatesEqual_(l[1],i)||s[h][1])!(un(l)in this.vertexSegments_)||s[h][0]||s[h][1]||n.push(a);else{if(s[h][0]&&0===s[h][0].index){let t=a.geometry.getCoordinates();switch(a.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":t=t[c[1]];case"Polygon":if(a.index!==t[c[0]].length-2)continue}}this.dragSegments_.push([a,1]),s[h][1]=a}else this.dragSegments_.push([a,0]),s[h][0]=a}return n}deactivateTrace_(){this.traceState_={active:!1}}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&q(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.pixelTolerance_)return;const n=qh(t.coordinate,e,t.map,this.pixelTolerance_);if(!(-1===e.targetIndex&&Math.sqrt(n.closestTargetDistance)/t.map.getView().getResolution()>this.pixelTolerance_)){if(e.targetIndex!==n.index){if(-1!==e.targetIndex){const t=e.targets[e.targetIndex];this.removeTracedCoordinates_(t.startIndex,t.endIndex)}else for(const t of this.traceSegments_){const e=t[0],n=e.geometry,i=t[1],r=n.getCoordinates();Vc(r,n.getType(),e.depth).splice(e.index+i,1),n.setCoordinates(r),0===i&&(e.index-=1)}const t=e.targets[n.index];this.addTracedCoordinates_(t,t.startIndex,n.endIndex)}else{const t=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(t,n.endIndex)}e.targetIndex=n.index,e.targets[e.targetIndex].endIndex=n.endIndex}}getTraceCandidates_(t){const e=this.getMap(),n=this.pixelTolerance_,i=h([e.getCoordinateFromPixel([t.pixel[0]-n,t.pixel[1]+n]),e.getCoordinateFromPixel([t.pixel[0]+n,t.pixel[1]-n])]);return this.traceSource_.getFeaturesInExtent(i)}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active)return this.deactivateTrace_(),void(this.traceSegments_=null);const e=this.getTraceCandidates_(t);if(0===e.length)return;const n=$h(t.coordinate,e);n.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:n,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const n=t.startIndex<=t.endIndex;n===t.startIndex<=e?n&&e>t.endIndex||!n&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(n&&e<t.endIndex||!n&&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 n=0;if(t<e){const i=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),n=r-i+1}else{const i=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),n=i-r+1}if(n>0)for(const t of this.traceSegments_){const e=t[0],i=e.geometry,r=t[1];let o=t[0].index+1;1===r&&(o-=n);const s=i.getCoordinates();Vc(s,i.getType(),e.depth).splice(o,n),i.setCoordinates(s),1===r&&(e.index-=n)}}addTracedCoordinates_(t,e,n){if(e===n)return;const i=[];if(e<n){const r=Math.ceil(e);let o=Math.floor(n);o===n&&(o-=1);for(let e=r;e<=o;++e)i.push(zh(t.coordinates,e))}else{const r=Math.floor(e);let o=Math.ceil(n);o===n&&(o+=1);for(let e=r;e>=o;--e)i.push(zh(t.coordinates,e))}if(i.length)for(const t of this.traceSegments_){const e=t[0],n=e.geometry,r=t[1],o=e.index+1;0===r&&i.reverse();const s=n.getCoordinates();Vc(s,n.getType(),e.depth).splice(o,0,...i),n.setCoordinates(s),1===r&&(e.index+=i.length)}}updateGeometry_(t,e){const n=e[0],i=n.depth;let r;const o=n.segment,s=n.geometry,a=e[1],l=s.getStride();for(let e=2;e<l;++e)t[e]=o[a][e];switch(t.length=l,s.getType()){case"Point":r=t,o[0]=t,o[1]=t;break;case"MultiPoint":r=s.getCoordinates(),r[n.index]=t,o[0]=t,o[1]=t;break;case"LineString":r=s.getCoordinates(),r[n.index+a]=t,o[a]=t;break;case"MultiLineString":r=s.getCoordinates(),r[i[0]][n.index+a]=t,o[a]=t;break;case"Polygon":{r=s.getCoordinates();const e=r[i[0]],l=n.index+a;e[l][0]===t[0]&&e[l][1]===t[1]?r=null:(e[l]=t,0===l?e[e.length-1]=t:l===e.length-1&&(e[0]=t)),o[a]=t;break}case"MultiPolygon":{r=s.getCoordinates();const e=r[i[1]][i[0]],l=n.index+a;e[l][0]===t[0]&&e[l][1]===t[1]?r=null:(e[l]=t,0===l?e[e.length-1]=t:l===e.length-1&&(e[0]=t)),o[a]=t;break}case"Circle":const e=s;if(o[0]=t,o[1]=t,0===n.index)this.changingFeature_=!0,e.setCenter(t),this.changingFeature_=!1;else{this.changingFeature_=!0;const n=this.getMap().getView().getProjection();let i=q(se(e.getCenter()),se(t));const r=re();if(r){const t=e.clone().transform(r,n);t.setRadius(i),i=t.transform(n,r).getRadius()}e.setRadius(i),this.changingFeature_=!1}}r&&this.setGeometryCoordinates_(s,r)}handleDragEvent(t){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(t,this.dragSegments_.map(([t])=>t));const e=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],n=[],i=[],r=this.traceState_.active&&!this.traceSegments_?this.traceState_.startCoord:null;if(r){this.traceSegments_=[];for(const e of this.dragSegments_)q(z(r,e[0].segment),r)/t.map.getView().getResolution()<1&&this.traceSegments_.push(e)}for(let t=0,r=this.dragSegments_.length;t<r;++t){const r=this.dragSegments_[t],o=r[0],s=o.feature;n.includes(s)||n.push(s);const a=o.geometry;i.includes(a)||i.push(a),this.updateGeometry_(e,r)}this.updateTrace_(t),this.createOrUpdateVertexFeature_(e,n,i,!0)}handleDownEvent(t){if(!this.condition_(t))return!1;const e=t.coordinate,n=this.findInsertVerticesAndUpdateDragSegments_(e);if(n?.length&&this.insertVertexCondition_(t)&&(this.willModifyFeatures_(t,n),this.vertexFeature_)){const t=this.vertexFeature_.getGeometry().getCoordinates();for(let e=n.length-1;e>=0;--e)this.insertVertex_(n[e],t);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(t){for(let e=this.dragSegments_.length-1;e>=0;--e){const n=this.dragSegments_[e][0],i=n.geometry;if("Circle"===i.getType()){const e=i,r=e.getCenter(),o=n.featureSegments[0],s=n.featureSegments[1];o.segment[0]=r,o.segment[1]=r,s.segment[0]=r,s.segment[1]=r,this.rBush_.update(_(r),o);let a=e;const l=re();if(l){const e=t.map.getView().getProjection();a=a.clone().transform(l,e),a=ya(a).transform(e,l)}this.rBush_.update(a.getExtent(),s)}else this.rBush_.update(h(n.segment),n)}return this.featuresBeingModified_&&(this.toggleTraceState_(t),this.dispatchEvent(new Nc(jc,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastCoordinate_=t.coordinate,this.handlePointerAtPixel_(this.lastCoordinate_)}handlePointerAtPixel_(t){const e=this.getMap(),n=e.getPixelFromCoordinate(t),i=e.getView().getProjection(),r=function(e,n){return Bc(t,e,i)-Bc(t,n,i)};let o,s;if(this.hitDetection_){const t="object"==typeof this.hitDetection_?t=>t===this.hitDetection_:void 0;e.forEachFeatureAtPixel(n,(t,e,n)=>{n&&"Point"===n.getType()&&(n=new Qs(oe(n.getCoordinates())));const i=n||t.getGeometry();if(i&&"Point"===i.getType()&&t instanceof ll&&this.features_.includes(t)){s=i;const e=t.getGeometry().getFlatCoordinates().slice(0,2);o=[{feature:t,geometry:s,segment:[e,e]}]}return!0},{layerFilter:t})}if(!o){const n=ae(c(le(_(t,Dc)),e.getView().getResolution()*this.pixelTolerance_,Dc));o=this.rBush_.getInExtent(n)}if(o&&o.length>0){const a=o.sort(r)[0],l=a.segment;let h=Xc(t,a,i);const c=e.getPixelFromCoordinate(h);let u=q(n,c);if(s||u<=this.pixelTolerance_){const n={};if(n[un(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-t[0],this.delta_[1]=h[1]-t[1]),"Circle"===a.geometry.getType()&&1===a.index)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const t=e.getPixelFromCoordinate(l[0]),i=e.getPixelFromCoordinate(l[1]),r=H(c,t),s=H(c,i);if(u=Math.sqrt(Math.min(r,s)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_))return void(this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null));this.snappedToVertex_&&(h=r>s?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const d={};d[un(a.geometry)]=!0;for(let t=1,e=o.length;t<e;++t){const e=o[t].segment;if(!(this.coordinatesEqual_(l[0],e[0])&&this.coordinatesEqual_(l[1],e[1])||this.coordinatesEqual_(l[0],e[1])&&this.coordinatesEqual_(l[1],e[0])))break;{const i=un(o[t].geometry);i in d||(d[i]=!0,n[un(e)]=!0)}}}return void(this.vertexSegments_=n)}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(t,e){const n=t.segment,i=t.feature,r=t.geometry,o=t.depth,s=t.index;let a;for(;e.length<r.getStride();)e.push(0);switch(r.getType()){case"MultiLineString":case"Polygon":a=r.getCoordinates(),a[o[0]].splice(s+1,0,e);break;case"MultiPolygon":a=r.getCoordinates(),a[o[1]][o[0]].splice(s+1,0,e);break;case"LineString":a=r.getCoordinates(),a.splice(s+1,0,e);break;default:return!1}this.setGeometryCoordinates_(r,a);const l=this.rBush_;l.remove(t),this.updateSegmentIndices_(r,s,o,1);const c={segment:[n[0],e],feature:i,geometry:r,depth:o,index:s};l.insert(h(c.segment),c),this.dragSegments_.push([c,1]);const u={segment:[e,n[1]],feature:i,geometry:r,depth:o,index:s+1};return l.insert(h(u.segment),u),this.dragSegments_.push([u,0]),!0}updatePointer_(t){return t&&this.findInsertVerticesAndUpdateDragSegments_(t),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){const t=this.vertexFeature_?.getGeometry().getCoordinates();return t?oe(t,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_)return!1;if(this.vertexFeature_.get("geometries").every(t=>"Circle"===t.getType()||t.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(h([t])).some(({segment:e})=>this.coordinatesEqual_(e[0],t)||this.coordinatesEqual_(e[1],t))}removePoint(t){if(t&&(t=se(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=Ah){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([t])=>t));const e=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Nc(jc,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,e}return!1}removeVertex_(){const t=this.dragSegments_,e={};let n,i,r,o,s,a,l,c,u,d,f,g=!1;for(s=t.length-1;s>=0;--s)r=t[s],d=r[0],f=un(d.feature),d.depth&&(f+="-"+d.depth.join("-")),f in e||(e[f]={}),0===r[1]?(e[f].right=d,e[f].index=d.index):1==r[1]&&(e[f].left=d,e[f].index=d.index+1);for(f in e){switch(u=e[f].right,l=e[f].left,a=e[f].index,c=a-1,d=void 0!==l?l:u,c<0&&(c=0),o=d.geometry,i=o.getCoordinates(),n=i,g=!1,o.getType()){case"MultiLineString":i[d.depth[0]].length>2&&(i[d.depth[0]].splice(a,1),g=!0);break;case"LineString":i.length>2&&(i.splice(a,1),g=!0);break;case"MultiPolygon":n=n[d.depth[1]];case"Polygon":n=n[d.depth[0]],n.length>4&&(a==n.length-1&&(a=0),n.splice(a,1),g=!0,0===a&&(n.pop(),n.push(n[0]),c=n.length-1))}if(g){this.setGeometryCoordinates_(o,i);const e=[];if(void 0!==l&&(this.rBush_.remove(l),e.push(l.segment[0])),void 0!==u&&(this.rBush_.remove(u),e.push(u.segment[1])),void 0!==l&&void 0!==u){const t={depth:d.depth,feature:d.feature,geometry:d.geometry,index:c,segment:e};this.rBush_.insert(h(t.segment),t)}this.updateSegmentIndices_(o,a,d.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return g}canInsertPoint(){if(!this.vertexFeature_)return!1;if(this.vertexFeature_.get("geometries").every(t=>"Circle"===t.getType()||t.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(h([t])).some(({segment:e})=>!(this.coordinatesEqual_(e[0],t)||this.coordinatesEqual_(e[1],t)))}insertPoint(t){const e=t?se(t,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return!!e&&this.findInsertVerticesAndUpdateDragSegments_(e).reduce((t,n)=>t||this.insertVertex_(n,e),!1)}setGeometryCoordinates_(t,e){this.changingFeature_=!0,t.setCoordinates(e),this.changingFeature_=!1}updateSegmentIndices_(t,e,n,i){this.rBush_.forEachInExtent(t.getExtent(),function(r){r.geometry===t&&(void 0===n||void 0===r.depth||l(r.depth,n))&&r.index>e&&(r.index+=i)})}disposeInternal(){if(super.disposeInternal(),this.featuresCollection_){this.featuresCollection_.removeEventListener(Wa,this.handleExternalCollectionAdd_),this.featuresCollection_.removeEventListener(Ba,this.handleExternalCollectionRemove_);for(const t of this.featuresCollection_.getArray())t.removeEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(nn,this.handleFeatureChange_)}else if(this.source_){this.source_.removeEventListener(il,this.handleSourceAdd_),this.source_.removeEventListener(rl,this.handleSourceRemove_);for(const t of this.source_.getFeatures())t.removeEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(nn,this.handleFeatureChange_)}}};var Uc=function(t,e,n,i){var r,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:12;return null!==(r=function(t,e,n){var i=-1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:12;return e.forEach(function(e,o){var s=sc(t,e);if(s){var a=ac(s,n);a<r&&(r=a,i=o)}}),i>=0?{index:i,type:"vertex"}:null}(t,e,i,o))&&void 0!==r?r:function(t,e,n,i){var r=-1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:12;return e.forEach(function(e,i){var s=sc(t,e);if(s){var a=ac(s,n);a<o&&(o=a,r=i)}}),r>=0?{index:i+r,type:"midpoint"}:null}(t,n,i,e.length,o)};function Hc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var qc=function(t,e){if(e.length>t.length){var n=e.findIndex(function(e,n){var i;return e[0]!==(null===(i=t[n])||void 0===i?void 0:i[0])});return{type:"insert_vertex",vertexIndex:Math.max(0,n)}}if(e.length===t.length){var i=e.findIndex(function(e,n){return e[0]!==t[n][0]||e[1]!==t[n][1]});if(i>=0)return{type:"move_vertex",vertexIndex:i,previousCoord:t[i]}}return null},$c=function(t){var e=t.map,n=t.olFeature,i=t.getState,r=t.onModifyEnd,o=t.condition,s=null!=o?o:function(t){var e=t.map,n=t.getState;return function(t){var i=n(),r=i.interfaceType,o=i.vertices,s=i.midpoints;if("touch"===r)return!1;var a=e.getEventPixel(t.originalEvent);return null!==Uc(e,o,s,{x:a[0],y:a[1]})}}({map:e,getState:i}),a=new zc({features:new za([n]),style:function(){return[]},pixelTolerance:12,condition:s});e.addInteraction(a);var l=null;return a.on("modifystart",function(){"touch"!==i().interfaceType&&(l=i().vertices.map(function(t){return function(t){if(Array.isArray(t))return Hc(t)}(e=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return Hc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hc(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var e}))}),a.on("modifyend",function(){if("touch"!==i().interfaceType){var t=l;l=null,r(t)}}),{destroy:function(){e.removeInteraction(a)}}},Zc=n(722);function Kc(t){return function(t){if(Array.isArray(t))return Qc(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Jc(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jc(t,e){if(t){if("string"==typeof t)return Qc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qc(t,e):void 0}}function Qc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var tu=function(t,e,n,i){var r=n-i,o=e[r];if(!o)return null;var s,a=t.getGeometry(),l={type:a.getType(),coordinates:a.getCoordinates()},h=0,c=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Jc(t))){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==e.return||e.return()}finally{if(s)throw r}}}}(Rc(l));try{for(c.s();!(s=c.n()).done;){var u=s.value,d=u.closed?u.length:u.length-1;if(r<h+d){var f=r-h+1,g=u.start+f;return Oc(l,u.path).splice(f,0,Kc(o)),a.setCoordinates(l.coordinates),{insertedIndex:g}}h+=d}}catch(t){c.e(t)}finally{c.f()}return null},eu=function(t,e,n){var i=t.getGeometry(),r={type:i.getType(),coordinates:i.getCoordinates()},o=Rc(r),s=Fc(o,e);if(s){var a=Oc(r,s.segment.path);a[s.localIdx]=Kc(n),s.segment.closed&&0===s.localIdx&&(a[a.length-1]=Kc(n)),i.setCoordinates(r.coordinates)}};function nu(t){return nu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nu(t)}function iu(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function ru(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?iu(Object(n),!0).forEach(function(e){ou(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):iu(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function ou(t,e,n){return(e=function(t){var e=function(t){if("object"!=nu(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=nu(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nu(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function su(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var au=function(t){var e=t.container,n={dragStartCoord:null,dragStartIndex:null,vertexTouchDelta:null,targetTouchDelta:null,tapStart:null},i=ru(ru({},t),{},{drag:n}),r=function(t){return function(t,e){var n,i=e.map,r=e.targetEl,o=e.cssToOl,s=e.getState,a=e.drag,l=t.touches[0],h=(0,Zc.mt)(t.target);if(a.tapStart={x:l.clientX,y:l.clientY,time:Date.now(),onTarget:h},h){var c=s(),u=c.selectedVertexIndex,d=c.vertices[u];if(d){var f=i.getEventPixel({clientX:l.clientX,clientY:l.clientY}),g=sc(i,d),p=getComputedStyle(r),m=o({x:Number.parseFloat(p.left),y:Number.parseFloat(p.top)});a.dragStartCoord=function(t){if(Array.isArray(t))return su(t)}(n=d)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||function(t,e){if(t){if("string"==typeof t)return su(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?su(t,e):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),a.dragStartIndex=u,a.vertexTouchDelta={x:f[0]-g.x,y:f[1]-g.y},a.targetTouchDelta={x:f[0]-m.x,y:f[1]-m.y},t.preventDefault()}}}(t,i)},o=function(t){return function(t,e){var n=e.map,i=e.targetEl,r=e.olToCSS,o=e.getState,s=e.setState,a=e.snap,l=e.drag,h=e.moveCoord;if((0,Zc.mt)(t.target)&&null!=l.dragStartIndex){t.preventDefault();var c=n.getEventPixel({clientX:t.touches[0].clientX,clientY:t.touches[0].clientY}),u=function(t,e){return t.getCoordinateFromPixel([e.x,e.y])}(n,{x:c[0]-l.vertexTouchDelta.x,y:c[1]-l.vertexTouchDelta.y}),d=a?a.apply(u):u,f=o(),g=f.olFeature,p=f.vertices;g&&(h(g,l.dragStartIndex,d),s({vertices:p.map(function(t,e){return e===l.dragStartIndex?d:t})}),(0,Zc.Ox)(i,r({x:c[0]-l.targetTouchDelta.x,y:c[1]-l.targetTouchDelta.y})))}}(t,i)},s=function(t){return function(t,e){var n=e.getState,i=e.onVertexMoved,r=e.drag,o=e.updateTargetPosition;if(null==r.dragStartIndex)return function(t,e){var n=e.map,i=e.getState,r=e.onTap,o=e.drag;if(o.tapStart&&!o.tapStart.onTarget&&0!==t.changedTouches.length){var s=t.changedTouches[0],a=Date.now()-o.tapStart.time;if(Math.hypot(s.clientX-o.tapStart.x,s.clientY-o.tapStart.y)<10&&a<400){var l=n.getEventPixel({clientX:s.clientX,clientY:s.clientY}),h=i();null==r||r(Uc(n,h.vertices,h.midpoints,{x:l[0],y:l[1]},24)),t.preventDefault()}}}(t,e),void(r.tapStart=null);r.tapStart=null,n().vertices[r.dragStartIndex]&&r.dragStartCoord&&i({vertexIndex:r.dragStartIndex,previousCoord:r.dragStartCoord}),r.dragStartCoord=null,r.dragStartIndex=null,r.vertexTouchDelta=null,r.targetTouchDelta=null,o(),t.preventDefault()}(t,i)};return e.addEventListener("touchstart",r,{passive:!1}),e.addEventListener("touchmove",o,{passive:!1}),e.addEventListener("touchend",s,{passive:!1}),e.addEventListener("touchcancel",s,{passive:!1}),{isDragging:function(){return null!=n.dragStartIndex},destroy:function(){e.removeEventListener("touchstart",r),e.removeEventListener("touchmove",o),e.removeEventListener("touchend",s),e.removeEventListener("touchcancel",s)}}},lu=function(t){var e=t.map,n=t.container,i=t.getState,r=t.setState,o=t.onVertexMoved,s=t.onTap,a=t.colors,l=t.snap,h=t.moveCoord,c=void 0===h?eu:h,u=(0,Zc.DD)(n);(0,Zc.ZP)(u,a);var d={scale:1,ox:0,oy:0},f=function(t){return{x:t.x*d.scale+d.ox,y:t.y*d.scale+d.oy}},g=function(){var t=e.getViewport(),i=t.getBoundingClientRect(),r=n.getBoundingClientRect(),o=t.offsetWidth>0?i.width/t.offsetWidth:1,s=n.offsetWidth>0?r.width/n.offsetWidth:1;Object.assign(d,{scale:o/s,ox:(i.left-r.left)/s,oy:(i.top-r.top)/s})},p=function(){var t=i(),n=t.selectedVertexIndex,r=t.vertices,o=t.interfaceType;if(n<0||!r[n]||"touch"!==o)(0,Zc.$X)(u);else{var s=sc(e,r[n]);s?(0,Zc.Ox)(u,f(s)):(0,Zc.$X)(u)}},m=au({container:n,map:e,targetEl:u,olToCSS:f,cssToOl:function(t){return{x:(t.x-d.ox)/d.scale,y:(t.y-d.oy)/d.scale}},getState:i,setState:r,onVertexMoved:o,onTap:s,snap:l,moveCoord:c,updateTargetPosition:p}),y=function(){var t=i(),e=t.selectedVertexIndex,n=t.interfaceType;e>=0&&!m.isDragging()&&"touch"===n&&p()};e.on("postrender",y);var _=function(){g(),e.once("postrender",p)};return e.on("change:size",_),g(),{updateTargetPosition:p,updateColors:function(t){(0,Zc.ZP)(u,t)},hide:function(){(0,Zc.$X)(u)},destroy:function(){e.un("change:size",_),e.un("postrender",y),m.destroy(),(0,Zc.$X)(u)}}},hu=n(107);function cu(t){return function(t){if(Array.isArray(t))return du(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||uu(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function uu(t,e){if(t){if("string"==typeof t)return du(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?du(t,e):void 0}}function du(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var fu=function(t){var e=t.map,n=t.snap,i=t.getState,r=t.setState,o=t.onInserted,s=t.onVertexMoved,a=t.moveCoord,l=void 0===a?eu:a,h={start:null,index:null},c=function(t,o){var s=i(),a=s.selectedVertexIndex,h=s.vertices,c=s.olFeature;if(!c||a<0||!h[a])return null;var u=h[a],d=lc(e,u,t,o),f=n?n.apply(d):d,g=function(t,e,n,i,r,o,s){if(!t)return r;var a=[i[0]-n[0],i[1]-n[1]],l=[r[0]-n[0],r[1]-n[1]],h=Math.pow(a[0],2)+Math.pow(a[1],2);if(h>0&&(l[0]*a[0]+l[1]*a[1])/h<.5){var c=t.snapRadius+1;return lc(e,n,0===o?0:Math.sign(o)*c,0===s?0:Math.sign(s)*c)}return r}(n,e,u,d,f,t,o);return n&&g!==f&&n.hideIndicator(),l(c,a,g),r({vertices:h.map(function(t,e){return e===a?g:t})}),{previousCoord:u,vertexIndex:a}};return{nudge:function(t){var s=i(),a=s.selectedVertexIndex,l=s.selectedVertexType,u=s.vertices,d=s.midpoints,f=s.olFeature;if(f){var g=t.shiftKey?Ol.WQ.nudgeAmount:Ol.WQ.stepAmount,p=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||uu(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}({ArrowUp:[0,-g],ArrowDown:[0,g],ArrowLeft:[-g,0],ArrowRight:[g,0]}[t.key],2),m=p[0],y=p[1];"midpoint"!==l?a<0||!u[a]||(h.start||(h.start=cu(u[a]),h.index=a),c(m,y)):function(t,s,a,l,c,u){var d=tu(t,s,a,l.length);if(d){o({insertedIndex:d.insertedIndex});var f=i().vertices,g=f[d.insertedIndex];if(g){h.start=cu(g),h.index=d.insertedIndex;var p=lc(e,g,c,u),m=n?n.apply(p):p;eu(t,d.insertedIndex,m),r({selectedVertexIndex:d.insertedIndex,selectedVertexType:"vertex",vertices:f.map(function(t,e){return e===d.insertedIndex?m:t})})}}}(f,d,a,u,m,y)}},keyMove:h,nudgeByDelta:function(t,e,n){var i=n?Ol.WQ.stepAmount:Ol.WQ.nudgeAmount,r=c(t*i,e*i);r&&s({vertexIndex:r.vertexIndex,previousCoord:r.previousCoord})}}};function gu(t){return function(t){if(Array.isArray(t))return pu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return pu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pu(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var mu=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),yu=new Set(["INPUT","TEXTAREA","BUTTON","SELECT","A"]),_u=function(t){var e=t.map,n=t.getState,i=t.setState,r=t.nudge,o=t.keyMove,s=t.onUndo,a=t.onKeyboardActive,l=t.isFocused,h=function(t){if(null==a||a()," "===t.key)t.preventDefault(),n().selectedVertexIndex<0&&function(t,e,n){var i=e(),r=i.vertices,o=i.midpoints;if(r.length){var s=sc(t,t.getView().getCenter());if(s){var a=[].concat(gu(r.map(function(e){return sc(t,e)})),gu(o.map(function(e){return sc(t,e)}))).filter(Boolean).map(function(t){return[t.x,t.y]}),l=(0,hu.c)([s.x,s.y],a,void 0);n({selectedVertexIndex:l,selectedVertexType:l<r.length?"vertex":"midpoint"})}}}(e,n,i);else if(mu.has(t.key))!function(t){t.altKey?(t.preventDefault(),t.stopPropagation(),function(t,e,n,i){var r=n(),o=r.selectedVertexIndex,s=r.vertices,a=r.midpoints;if(s.length){var l,h=[].concat(gu(s),gu(a)).map(function(t){return sc(e,t)}).filter(Boolean).map(function(t){return[t.x,t.y]}),c=o>=0?h[o]:(l=sc(e,e.getView().getCenter()))?[l.x,l.y]:null;if(c){var u=(0,hu.c)(c,h,t);i({selectedVertexIndex:u,selectedVertexType:u<s.length?"vertex":"midpoint"})}}}(t.key,e,n,i)):n().selectedVertexIndex>=0&&(t.preventDefault(),t.stopPropagation(),r(t))}(t);else if("z"===t.key&&(t.metaKey||t.ctrlKey)){var o,l=null===(o=document.activeElement)||void 0===o?void 0:o.tagName;yu.has(l)||(t.preventDefault(),t.stopPropagation(),s())}};return function(t){l()||("Escape"===t.key&&n().selectedVertexIndex>=0?(t.preventDefault(),o.start=null,o.index=null,i({selectedVertexIndex:-1,selectedVertexType:null})):h(t))}},vu=function(t){var e,n=t.map,i=t.snap,r=t.getState,o=t.setState,s=t.onVertexMoved,a=t.onInserted,l=t.onDeleted,h=t.onUndo,c=t.onKeyboardActive,u=t.moveCoord,d=fu({map:n,snap:i,getState:r,setState:o,onInserted:a,onVertexMoved:s,moveCoord:u}),f=d.nudge,g=d.keyMove,p=d.nudgeByDelta,m=null!==(e=n.getViewport().closest('[role="application"]'))&&void 0!==e?e:n.getViewport(),y=function(){return function(t){var e=document.activeElement;return!(!e||e===document.body)&&!t.contains(e)&&(yu.has(e.tagName)||e.isContentEditable||e.hasAttribute("tabindex"))}(m)},_=_u({map:n,getState:r,setState:o,nudge:f,keyMove:g,onUndo:h,onKeyboardActive:c,isFocused:y}),v=function(t){var e=t.getState,n=t.keyMove,i=t.onVertexMoved,r=t.onDeleted,o=t.isFocused;return function(t){o()||(e().selectedVertexIndex>=0&&(0,dc.z)(t),mu.has(t.key)&&n.start&&null!=n.index&&(i({vertexIndex:n.index,previousCoord:n.start}),n.start=null,n.index=null),"Delete"===t.key&&r())}}({getState:r,keyMove:g,onVertexMoved:s,onDeleted:l,isFocused:y});return globalThis.addEventListener("keydown",_,{capture:!0}),globalThis.addEventListener("keyup",v,{capture:!0}),{nudgeByDelta:p,destroy:function(){globalThis.removeEventListener("keydown",_,{capture:!0}),globalThis.removeEventListener("keyup",v,{capture:!0})}}};function xu(t){return function(t){if(Array.isArray(t))return wu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Su(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Su(t,e){if(t){if("string"==typeof t)return wu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wu(t,e):void 0}}function wu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var Cu=function(t,e){switch(e.type){case"move_vertex":return function(t,e){var n=e.vertexIndex,i=e.previousCoord,r=t.getGeometry(),o={type:r.getType(),coordinates:r.getCoordinates()},s=Rc(o),a=Fc(s,n);if(!a)return-1;var l=Oc(o,a.segment.path);return l[a.localIdx]=xu(i),a.segment.closed&&0===a.localIdx&&(l[l.length-1]=xu(i)),r.setCoordinates(o.coordinates),n}(t,e);case"insert_vertex":return function(t,e){var n=e.vertexIndex,i=t.getGeometry(),r={type:i.getType(),coordinates:i.getCoordinates()},o=Rc(r),s=Fc(o,n);if(s){var a=Oc(r,s.segment.path);a.splice(s.localIdx,1),s.segment.closed&&(a[a.length-1]=xu(a[0])),i.setCoordinates(r.coordinates)}return-1}(t,e);case"delete_vertex":return function(t,e){var n=e.vertexIndex,i=e.deletedCoord,r=t.getGeometry(),o={type:r.getType(),coordinates:r.getCoordinates()},s=Rc(o),a=Fc(s,n);if(!a){var l,h=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Su(t))){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==e.return||e.return()}finally{if(s)throw r}}}}(s);try{for(h.s();!(l=h.n()).done;){var c=l.value;if(n===c.start+c.length){a={segment:c,localIdx:c.length};break}}}catch(t){h.e(t)}finally{h.f()}}if(!a)return-1;var u=Oc(o,a.segment.path);return u.splice(a.localIdx,0,xu(i)),a.segment.closed&&(u[u.length-1]=xu(u[0])),r.setCoordinates(o.coordinates),n}(t,e);default:return-1}},bu="touch",Iu="vertex",Eu="commit-move",Pu="commit-insert",Tu="commit-delete",Mu={move_vertex:Eu,insert_vertex:Pu,delete_vertex:Tu},ku={move_vertex:Eu,insert_vertex:Tu,delete_vertex:Pu},Ru=function(t){var e=t.map,n=t.manager,i=t.options,r=i.featureId,o=i.container,s=i.interfaceType,a=i.deleteVertexButtonId,l=i.snap,h=n.store,c=n.undoStack,u=h.getOL(r);if(!u)return null;var d=u.getStyle(),f=function(t,e){var n=e,i=-1,r=new sl,o=new Na({source:r,style:function(t){return t.get("midpointIndex")===i?null:[n]},zIndex:101});return t.addLayer(o),{update:function(t){r.clear();var e=Ac(t).map(function(t,e){var n=new ll({geometry:new Qs(t)});return n.set("midpointIndex",e),n});r.addFeatures(e)},setSelected:function(t){i=t,r.changed()},updateStyle:function(t){n=t,r.changed()},getCoords:function(){return r.getFeatures().sort(function(t,e){return t.get("midpointIndex")-e.get("midpointIndex")}).map(function(t){return t.getGeometry().getCoordinates()})},remove:function(){r.clear(),t.removeLayer(o)}}}(e,n.styles.midpointStyle),g=function(t,e){var n=e,i=-1,r=new sl,o=new Na({source:r,style:function(t){return t.get("vertexIndex")===i?null:[n]},zIndex:102});return t.addLayer(o),{update:function(t){r.clear(),kc(t).forEach(function(t,e){var n=new ll({geometry:new Qs(t)});n.set("vertexIndex",e),r.addFeature(n)})},setSelected:function(t){i=t,r.changed()},updateStyle:function(t){n=t,r.changed()},remove:function(){r.clear(),t.removeLayer(o)}}}(e,n.styles.vertexStyle),p=function(t,e){var n=new sl,i=new Na({source:n,zIndex:103});return t.addLayer(i),{update:function(t){if(n.clear(),!(t.selectedVertexIndex<0)){var i,r,o,s,a,l,h=(r=(i=t).selectedVertexIndex,o=i.selectedVertexType,s=i.vertices,a=i.midpoints,l=e(),"vertex"===o?{coord:s[r],style:l.selectedVertexStyle}:"midpoint"===o?{coord:a[r-s.length],style:l.selectedMidpointStyle}:{coord:null,style:null}),c=h.coord,u=h.style;if(c){var d=new ll({geometry:new Qs(c)});d.setStyle(u),n.addFeature(d)}}},remove:function(){n.clear(),t.removeLayer(i)}}}(e,function(){return n.styles}),m=Lc({map:e,manager:n,store:h,olFeature:u,interfaceType:s,layers:{vertexLayer:g,midpointLayer:f,activeLayer:p}}),y=m.state,_=m.getState,v=m.setState,x=m.syncGeom,S=m.emitGeometryValidation,w=$c({map:e,olFeature:u,getState:_,onModifyEnd:function(t){x();var e=t&&qc(t,y.vertices);e&&(c.push(e),S(Mu[e.type],e.vertexIndex),v({selectedVertexIndex:e.vertexIndex,selectedVertexType:Iu}))}});x();var C={vertexLayer:g,midpointLayer:f,activeLayer:p},b=function(t){var e=t.map,n=t.manager,i=t.olFeature,r=!1;i.setStyle(function(){return r?n.styles.editFeatureStyleInvalid:n.styles.editFeatureStyle});var o=(0,xc.De)({onChange:function(t,i){r=t,e.render(),n.emit(mc.k.VALIDITY_CHANGE,{valid:!t,reason:i})}}),s=function(){var t,e,r=i.getGeometry(),s=r.getType(),a=r.getCoordinates(),l="Polygon"===s?Math.max(0,(null!==(t=null===(e=a[0])||void 0===e?void 0:e.length)&&void 0!==t?t:1)-1):a.length;o.update({feature:{type:"Feature",geometry:{type:s,coordinates:a}},context:{mode:"edit_vertex"},numVertices:l,onGeometryChange:n._geometryValidator})};return i.getGeometry().on("change",s),{liveStroke:o,destroy:function(){i.getGeometry().un("change",s),o.destroy()}}}({map:e,manager:n,olFeature:u}),I=function(t){var e=t.map,n=t.container,i=t.manager,r=t.snap,o=t.olFeature,s=t.undoStack,a=t.selection,l=a.state,h=a.getState,c=a.setState,u=a.syncGeom,d=a.emitGeometryValidation,f=function(t){return c({selectedVertexIndex:t,selectedVertexType:Iu})},g=lu({map:e,container:n,getState:h,setState:c,colors:i.colors,snap:r,onVertexMoved:function(t){var e=t.vertexIndex,n=t.previousCoord;s.push({type:"move_vertex",vertexIndex:e,previousCoord:n}),u(),d(Eu,e),f(e),g.updateTargetPosition()},onTap:function(t){if(t){if(t.type===Iu)return f(t.index),void g.updateTargetPosition();var e=tu(o,l.midpoints,t.index,l.vertices.length);e&&(s.push({type:"insert_vertex",vertexIndex:e.insertedIndex}),u(),d(Pu,e.insertedIndex),f(e.insertedIndex),g.updateTargetPosition())}else c({selectedVertexIndex:-1,selectedVertexType:null})}});return a.setHooks({onDeselect:function(){return g.hide()},onUpdate:function(){l.interfaceType===bu&&g.updateTargetPosition()}}),g}({map:e,container:o,manager:n,snap:l,olFeature:u,undoStack:c,selection:m}),E=function(t){var e=t.olFeature,n=t.undoStack,i=t.selection,r=t.getTouchHandler,o=i.state,s=i.setState,a=i.syncGeom,l=i.emitGeometryValidation;return{doDeleteVertex:function(){if(!(o.selectedVertexType!==Iu||o.selectedVertexIndex<0)){var t=function(t,e){var n=t.getGeometry(),i={type:n.getType(),coordinates:n.getCoordinates()},r=kc(i),o=Rc(i),s=Fc(o,e);if(!s)return null;var a=s.segment,l=a.closed?vc.n8.Polygon:vc.n8.LineString;if(a.length<=l)return null;var h=Kc(r[e]),c=Oc(i,a.path);return c.splice(s.localIdx,1),a.closed&&(c[c.length-1]=Kc(c[0])),n.setCoordinates(i.coordinates),{deletedIndex:e,deletedCoord:h}}(e,o.selectedVertexIndex);t&&(n.push({type:"delete_vertex",vertexIndex:t.deletedIndex,deletedCoord:t.deletedCoord}),a(),l(Tu,t.deletedIndex),s({selectedVertexIndex:-1,selectedVertexType:null}))}},doUndo:function(){var t=n.pop();if(t){var i=o.selectedVertexIndex,h=Cu(e,t);a(),l(ku[t.type],h);var c=i>=0?h:-1;s({selectedVertexIndex:c,selectedVertexType:c>=0?Iu:null}),i>=0&&c>=0&&o.interfaceType===bu&&r().updateTargetPosition()}}}}({olFeature:u,undoStack:c,selection:m,getTouchHandler:function(){return I}}),P=function(t){var e=t.map,n=t.container,i=t.snap,r=t.undoStack,o=t.selection,s=t.touchHandler,a=t.actions,l=o.state,h=o.getState,c=o.setState,u=o.syncGeom,d=o.emitGeometryValidation;return vu({map:e,getState:h,setState:c,snap:i,onVertexMoved:function(t){var e=t.vertexIndex,n=t.previousCoord;r.push({type:"move_vertex",vertexIndex:e,previousCoord:n}),u(),d(Eu,e),c({selectedVertexIndex:e,selectedVertexType:Iu})},onInserted:function(t){var e=t.insertedIndex;r.push({type:"insert_vertex",vertexIndex:e}),u(),d(Pu,e)},onDeleted:a.doDeleteVertex,onUndo:a.doUndo,onKeyboardActive:function(){"keyboard"!==l.interfaceType&&(l.interfaceType="keyboard",s.hide(),n.focus({preventScroll:!0}))}})}({map:e,container:o,snap:l,undoStack:c,selection:m,touchHandler:I,actions:E}),T=function(t){var e=t.map,n=t.container,i=t.getState,r=t.setState,o=t.touchHandler,s=t.deleteVertexButtonId,a=t.onDeleteVertex,l=function(t){var n=i(),r=n.vertices,o=n.midpoints,s=e.getEventPixel(t);return Uc(e,r,o,{x:s[0],y:s[1]})},h=function(t){var e=i();if("touch"===t.pointerType)return e.interfaceType="touch",void o.updateTargetPosition();e.interfaceType="mouse";var n=l(t);"vertex"===(null==n?void 0:n.type)&&r({selectedVertexIndex:n.index,selectedVertexType:"vertex"})},c=function(t){if("touch"!==i().interfaceType){var e=l(t);"vertex"===(null==e?void 0:e.type)?r({selectedVertexIndex:e.index,selectedVertexType:"vertex"}):"midpoint"===(null==e?void 0:e.type)||r({selectedVertexIndex:-1,selectedVertexType:null})}},u=function(t){var e=i();"mouse"===t.pointerType&&"mouse"!==e.interfaceType&&(e.interfaceType="mouse",o.hide())},d=function(t){s&&t.target.closest("#".concat(s))&&a()};return n.addEventListener("pointerdown",h),n.addEventListener("pointerenter",u),n.addEventListener("pointermove",u),n.addEventListener("click",c),globalThis.addEventListener("click",d),{destroy:function(){n.removeEventListener("pointerdown",h),n.removeEventListener("pointerenter",u),n.removeEventListener("pointermove",u),n.removeEventListener("click",c),globalThis.removeEventListener("click",d)}}}({map:e,container:o,getState:_,setState:v,touchHandler:I,deleteVertexButtonId:a,onDeleteVertex:E.doDeleteVertex}),M=function(t){var e=t.map,n=t.manager,i=t.layers,r=t.touchHandler,o=t.live,s=t.selection.state,a=function(t){o.liveStroke.refresh(),i.vertexLayer.updateStyle(t.vertexStyle),i.midpointLayer.updateStyle(t.midpointStyle),i.activeLayer.update(s),r.updateColors(n.colors)};n.on(yc,a);var l=function(){s.interfaceType!==bu||s.selectedVertexIndex<0||e.once("postrender",function(){return r.updateTargetPosition()})};return e.on("change:size",l),{destroy:function(){n.off(yc,a),e.un("change:size",l)}}}({map:e,manager:n,layers:C,selection:m,touchHandler:I,live:b});return function(t){var e=t.manager,n=t.store,i=t.olFeature,r=t.originalFeatureStyle,o=t.selection,s=t.actions,a=t.parts,l=t.undoStack,h=o.state,c=o.setState,u=o.syncGeom,d=o.emitGeometryValidation,f=a.touchHandler;return{setInterfaceType:function(t){t!==h.interfaceType&&(h.interfaceType=t,t===bu?f.updateTargetPosition():f.hide())},done:function(){e.emit(mc.k.EDIT_FINISH,n.toGeoJSON(i))},setInvalid:function(t){a.live.liveStroke.set(t)},cancel:function(){},undo:s.doUndo,deleteVertex:s.doDeleteVertex,nudgeSelectedVertex:a.keyboardHandler.nudgeByDelta,getVertexItems:function(){return{vertices:h.vertices,midpoints:h.midpoints}},selectVertex:function(t){c({selectedVertexIndex:t,selectedVertexType:t<h.vertices.length?Iu:"midpoint"}),f.updateTargetPosition()},insertVertexAtMidpoint:function(t){var e=tu(i,h.midpoints,t,h.vertices.length);e&&(l.push({type:"insert_vertex",vertexIndex:e.insertedIndex}),u(),d(Pu,e.insertedIndex),c({selectedVertexIndex:e.insertedIndex,selectedVertexType:Iu}),f.updateTargetPosition())},destroy:function(){a.live.destroy(),i.setStyle(r),o.destroy(),a.mapSync.destroy(),a.pointerHandlers.destroy(),a.modify.destroy(),a.layers.activeLayer.remove(),a.layers.midpointLayer.remove(),a.layers.vertexLayer.remove(),f.destroy(),a.keyboardHandler.destroy()}}}({manager:n,store:h,olFeature:u,originalFeatureStyle:d,selection:m,actions:E,undoStack:c,parts:{touchHandler:I,keyboardHandler:P,pointerHandlers:T,modify:w,mapSync:M,layers:C,live:b}})},Fu=["selectedVertexIndex","selectedVertexType"];function Ou(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function Au(t){return function(t){if(Array.isArray(t))return Lu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Lu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Lu(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var Du=function(t,e,n){t.getGeometry().setCoordinates(Au(n))},Gu="touch",ju="commit-move",Vu=function(t){var e=t.map,n=t.olFeature;return function(t){var i=e.getEventPixel(t.originalEvent);return!!e.forEachFeatureAtPixel(i,function(t){return t===n},{hitTolerance:12})}},Nu=function(t){var e=t.map,n=t.manager,i=t.options,r=i.featureId,o=i.container,s=i.interfaceType,a=i.snap,l=n.store,h=n.undoStack,c=l.getOL(r);if(!c)return null;null==o||o.focus({preventScroll:!0});var u=c.getStyle();c.setStyle(function(){return n.styles.selectedPointStyleFor(c)});var d=function(t){var e=t.manager,n=t.store,i=t.olFeature,r=t.interfaceType,o={olFeature:i,selectedVertexIndex:0,selectedVertexType:"vertex",vertices:[],midpoints:[],interfaceType:null!=r?r:"mouse"},s={onUpdate:null},a=function(){o.vertices=[i.getGeometry().getCoordinates()]},l=function(t,e,n){return function(i,r){i&&setTimeout(function(){t.emit(mc.k.GEOMETRY_CHANGE,{feature:e.toGeoJSON(n),phase:i,vertexIndex:r})},0)}}(e,n,i),h=function(){return a()};return i.getGeometry().on("change",h),a(),e.emit(mc.k.VERTEX_SELECTION,{index:0,numVertices:1}),{state:o,getState:function(){return o},setState:function(t){t.selectedVertexIndex,t.selectedVertexType;var e,n=function(t,e){if(null==t)return{};var n,i,r=function(t,e){if(null==t)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(-1!==e.indexOf(i))continue;n[i]=t[i]}return n}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}(t,Fu);Object.assign(o,n),void 0!==t.vertices&&(null===(e=s.onUpdate)||void 0===e||e.call(s))},syncGeom:function(){a(),e.emit(mc.k.UPDATE,n.toGeoJSON(i))},emitGeometryValidation:l,setHooks:function(t){var e=t.onUpdate;s.onUpdate=e},destroy:function(){i.getGeometry().un("change",h)}}}({manager:n,store:l,olFeature:c,interfaceType:s}),f=d.getState,g=d.setState,p=function(t){var e=t.map,n=t.olFeature,i=t.getState,r=t.condition,o=t.snap,s=t.onModifyEnd,a=null,l=null,h=function(t){return e.getCoordinateFromPixel(t.pixel)},c=new Yh({handleDownEvent:function(t){if("touch"===i().interfaceType||!r(t))return!1;var e,o=n.getGeometry().getCoordinates(),s=h(t);return a=[o[0]-s[0],o[1]-s[1]],l=function(t){if(Array.isArray(t))return Ou(t)}(e=o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return Ou(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ou(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),!0},handleDragEvent:function(t){if(a){var e=h(t),i=[e[0]+a[0],e[1]+a[1]],r=o?o.apply(i):i;n.getGeometry().setCoordinates(r)}},handleUpEvent:function(){return a=null,l&&s([l]),l=null,!1}});return e.addInteraction(c),{destroy:function(){e.removeInteraction(c)}}}({map:e,olFeature:c,getState:f,condition:Vu({map:e,olFeature:c}),snap:a,onModifyEnd:function(t){d.syncGeom();var e=t&&qc(t,f().vertices);e&&(h.push(e),d.emitGeometryValidation(ju,e.vertexIndex))}}),m=function(t){var e=t.olFeature,n=t.undoStack,i=t.selection;return function(){var t=n.pop();t&&(function(t,e){"move_vertex"===e.type&&function(t,e){var n=e.previousCoord;t.getGeometry().setCoordinates(Au(n))}(t,e)}(e,t),i.syncGeom(),i.emitGeometryValidation(ju,0))}}({olFeature:c,undoStack:h,selection:d}),y=function(t){var e=t.manager,n=t.olFeature,i=(0,xc.De)({onChange:function(t,n){e.emit(mc.k.VALIDITY_CHANGE,{valid:!t,reason:n})}}),r=function(){var t=n.getGeometry().getCoordinates();i.update({feature:{type:"Feature",geometry:{type:"Point",coordinates:t}},context:{mode:"edit_point"},numVertices:1,onGeometryChange:e._geometryValidator})};return n.getGeometry().on("change",r),{liveStroke:i,destroy:function(){n.getGeometry().un("change",r),i.destroy()}}}({manager:n,olFeature:c}),_=function(t){var e=t.map,n=t.container,i=t.manager,r=t.snap,o=t.undoStack,s=t.selection,a=s.getState,l=s.setState,h=s.syncGeom,c=s.emitGeometryValidation,u=lu({map:e,container:n,getState:a,setState:l,colors:i.colors,snap:r,moveCoord:Du,onVertexMoved:function(t){var e=t.vertexIndex,n=t.previousCoord;o.push({type:"move_vertex",vertexIndex:e,previousCoord:n}),h(),c(ju,e)},onTap:function(){}});return s.setHooks({onUpdate:function(){a().interfaceType===Gu&&u.updateTargetPosition()}}),u}({map:e,container:o,manager:n,snap:a,undoStack:h,selection:d}),v=function(t){var e=t.map,n=t.container,i=t.snap,r=t.undoStack,o=t.selection,s=t.touchHandler,a=t.doUndo,l=o.getState,h=o.setState,c=o.syncGeom,u=o.emitGeometryValidation;return vu({map:e,getState:l,setState:h,snap:i,moveCoord:Du,onVertexMoved:function(t){var e=t.vertexIndex,n=t.previousCoord;r.push({type:"move_vertex",vertexIndex:e,previousCoord:n}),c(),u(ju,e)},onInserted:function(){},onDeleted:function(){},onUndo:a,onKeyboardActive:function(){"keyboard"!==l().interfaceType&&(l().interfaceType="keyboard",s.hide(),n.focus({preventScroll:!0}))}})}({map:e,container:o,snap:a,undoStack:h,selection:d,touchHandler:_,doUndo:m}),x=function(t){var e=t.map,n=t.manager,i=t.touchHandler,r=t.live,o=t.selection.state,s=function(){r.liveStroke.refresh(),i.updateColors(n.colors)};n.on(yc,s);var a=function(){o.interfaceType===Gu&&e.once("postrender",function(){return i.updateTargetPosition()})};return e.on("change:size",a),{destroy:function(){n.off(yc,s),e.un("change:size",a)}}}({map:e,manager:n,selection:d,touchHandler:_,live:y});return{setInterfaceType:function(t){t!==f().interfaceType&&(g({interfaceType:t}),t===Gu?_.updateTargetPosition():_.hide())},done:function(){n.emit(mc.k.EDIT_FINISH,l.toGeoJSON(c))},setInvalid:function(t){y.liveStroke.set(t)},cancel:function(){},undo:m,deleteVertex:function(){},nudgeSelectedVertex:v.nudgeByDelta,destroy:function(){y.destroy(),c.setStyle(u),d.destroy(),x.destroy(),p.destroy(),_.destroy(),v.destroy()}}},Wu="draw_point",Bu=function(t){var e=t.map,n=t.manager,i=t.options,r=i.featureId,o=i.properties,s=void 0===o?{}:o,a=function(t){return function(e){var n={type:"Feature",geometry:{type:"Point",coordinates:e},properties:{}},i=(0,_c.oK)(n,{mode:Wu,vertexIndex:0},{onGeometryChange:t._geometryValidator}),r=i.valid,o=i.reason;return r||t.emit(mc.k.PLACEMENT_BLOCKED,{feature:n,reason:null!=o?o:null,phase:"place",mode:Wu,vertexIndex:0}),r}}(n),l=new oc({type:"Point",style:function(){return[]},snapTolerance:Ol.vf.snapRadius,condition:function(t){return Vh(t)&&a(t.coordinate)}});e.addInteraction(l),l.on("drawend",function(t){return function(t,e,n,i,r){n.setId(String(i)),n.setProperties(r),t.store.source.addFeature(n),t.emit(mc.k.CREATE,t.store.toGeoJSON(n)),null==e||e(n)}(n,i.resolvePointSymbol,t.feature,r,s)}),l.on("drawabort",function(){n.emit(mc.k.CANCEL)});var h=function(t){var e,n,i=t.drawInteraction,r=t.options,o=t.canPlace,s=r.container,a=r.addVertexButtonId,l=r.mapProvider,h=r.snap,c=r.crossHair,u=null!==(e=r.interfaceType)&&void 0!==e?e:"mouse",d=function(){return u},f=function(){var t=l.getCenter(),e=h?h.apply(t):t;null==h||h.hideIndicator(),o(e)&&(i.appendCoordinates([e]),i.finishDrawing())},g=function(){h&&h.apply(l.getCenter())},p=function(t){u=t,gc(c,t),"mouse"!==t&&g()},m=pc({container:s,addVertexButtonId:a,olView:null===(n=i.getMap())||void 0===n?void 0:n.getView(),onUndo:null,getInterfaceType:d,setInterfaceType:p,clearLastCoord:function(){},updateRubberbanding:g,placeVertex:f});return gc(c,u),c&&(c.activate=f),{getInterfaceType:d,setInterfaceType:p,destroy:function(){(null==c?void 0:c.activate)===f&&(c.activate=null),m.destroy()}}}({drawInteraction:l,options:i,canPlace:a});return{done:function(){},cancel:function(){l.abortDrawing()},undo:function(){},setInterfaceType:function(t){h.setInterfaceType(t)},destroy:function(){n.emit(mc.k.INTERFACE_TYPE_CHANGE,{interfaceType:h.getInterfaceType()}),h.destroy(),e.removeInteraction(l)}}};function Xu(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var l=i&&i.prototype instanceof a?i:a,h=Object.create(l.prototype);return Yu(h,"_invoke",function(n,i,r){var o,a,l,h=0,c=r||[],u=!1,d={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(e,n){return o=e,a=0,l=t,d.n=n,s}};function f(n,i){for(a=n,l=i,e=0;!u&&h&&!r&&e<c.length;e++){var r,o=c[e],f=d.p,g=o[2];n>3?(r=g===i)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=f&&((r=n<2&&f<o[1])?(a=0,d.v=i,d.n=o[1]):f<g&&(r=n<3||o[0]>i||i>g)&&(o[4]=n,o[5]=i,d.n=g,a=0))}if(r||n>1)return s;throw u=!0,i}return function(r,c,g){if(h>1)throw TypeError("Generator is already running");for(u&&1===c&&f(c,g),a=c,l=g;(e=a<2?t:l)||!u;){o||(a?a<3?(a>1&&(d.n=-1),f(a,l)):d.n=l:d.v=l);try{if(h=2,o){if(a||(r="next"),e=o[r]){if(!(e=e.call(o,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=t}else if((e=(u=d.n<0)?l:n.call(i,d))!==s)break}catch(e){o=t,a=1,l=e}finally{h=1}}return{value:e,done:u}}}(n,r,o),!0),h}var s={};function a(){}function l(){}function h(){}e=Object.getPrototypeOf;var c=[][i]?e(e([][i]())):(Yu(e={},i,function(){return this}),e),u=h.prototype=a.prototype=Object.create(c);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,Yu(t,r,"GeneratorFunction")),t.prototype=Object.create(u),t}return l.prototype=h,Yu(u,"constructor",h),Yu(h,"constructor",l),l.displayName="GeneratorFunction",Yu(h,r,"GeneratorFunction"),Yu(u),Yu(u,r,"Generator"),Yu(u,i,function(){return this}),Yu(u,"toString",function(){return"[object Generator]"}),(Xu=function(){return{w:o,m:d}})()}function Yu(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}Yu=function(t,e,n,i){function o(e,n){Yu(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},Yu(t,e,n,i)}function zu(t,e,n,i,r,o,s){try{var a=t[o](s),l=a.value}catch(t){return void n(t)}a.done?e(l):Promise.resolve(l).then(i,r)}var Uu=["normal","active","selected"],Hu={normal:"symbolImageId",active:"symbolActiveImageId",selected:"symbolSelectedImageId"},qu=function(t){return!!(null!=t&&t.symbol||null!=t&&t.symbolSvgContent)},$u=function(t){var e;return(globalThis.devicePixelRatio||1)*(null!==(e=null==t?void 0:t.drawScale)&&void 0!==e?e:1)},Zu=function(){var t,e=(t=Xu().m(function t(e){var n,i,r,o,s,a,l;return Xu().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=e.manager,i=e.mapProvider,r=e.olFeature,o=r.getProperties(),qu(o)){t.n=1;break}return t.a(2);case 1:return s=$u(i),t.p=2,t.n=3,Promise.all(Uu.map(function(t){return Vl.a.rasteriseSymbolImage(o,n.mapStyle,t,s)}));case 3:if((a=t.v)[0]){t.n=4;break}return t.a(2);case 4:if(n.store.source.hasFeature(r)){t.n=5;break}return t.a(2);case 5:Uu.forEach(function(t,e){var n=a[e];n&&(jl(n.imageId,n.imageData),r.set(Hu[t],n.imageId))}),r.set("symbolPixelRatio",s),t.n=7;break;case 6:t.p=6,l=t.v,console.error("[draw] failed to resolve point symbol",r.getId(),l);case 7:return t.a(2)}},t,null,[[2,6]])}),function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){zu(o,i,r,s,a,"next",t)}function a(t){zu(o,i,r,s,a,"throw",t)}s(void 0)})});return function(t){return e.apply(this,arguments)}}(),Ku=function(t){var e=t.manager,n=t.mapProvider,i=e.store.source.getFeatures().filter(function(t){var e;return"Point"===(null===(e=t.getGeometry())||void 0===e?void 0:e.getType())&&qu(t.getProperties())});return Promise.all(i.map(function(t){return Zu({manager:e,mapProvider:n,olFeature:t})}))};function Ju(t){return Ju="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ju(t)}function Qu(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var l=i&&i.prototype instanceof a?i:a,h=Object.create(l.prototype);return td(h,"_invoke",function(n,i,r){var o,a,l,h=0,c=r||[],u=!1,d={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(e,n){return o=e,a=0,l=t,d.n=n,s}};function f(n,i){for(a=n,l=i,e=0;!u&&h&&!r&&e<c.length;e++){var r,o=c[e],f=d.p,g=o[2];n>3?(r=g===i)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=f&&((r=n<2&&f<o[1])?(a=0,d.v=i,d.n=o[1]):f<g&&(r=n<3||o[0]>i||i>g)&&(o[4]=n,o[5]=i,d.n=g,a=0))}if(r||n>1)return s;throw u=!0,i}return function(r,c,g){if(h>1)throw TypeError("Generator is already running");for(u&&1===c&&f(c,g),a=c,l=g;(e=a<2?t:l)||!u;){o||(a?a<3?(a>1&&(d.n=-1),f(a,l)):d.n=l:d.v=l);try{if(h=2,o){if(a||(r="next"),e=o[r]){if(!(e=e.call(o,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=t}else if((e=(u=d.n<0)?l:n.call(i,d))!==s)break}catch(e){o=t,a=1,l=e}finally{h=1}}return{value:e,done:u}}}(n,r,o),!0),h}var s={};function a(){}function l(){}function h(){}e=Object.getPrototypeOf;var c=[][i]?e(e([][i]())):(td(e={},i,function(){return this}),e),u=h.prototype=a.prototype=Object.create(c);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,td(t,r,"GeneratorFunction")),t.prototype=Object.create(u),t}return l.prototype=h,td(u,"constructor",h),td(h,"constructor",l),l.displayName="GeneratorFunction",td(h,r,"GeneratorFunction"),td(u),td(u,r,"Generator"),td(u,i,function(){return this}),td(u,"toString",function(){return"[object Generator]"}),(Qu=function(){return{w:o,m:d}})()}function td(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}td=function(t,e,n,i){function o(e,n){td(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},td(t,e,n,i)}function ed(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function nd(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ed(Object(n),!0).forEach(function(e){id(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ed(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function id(t,e,n){return(e=sd(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rd(t,e,n,i,r,o,s){try{var a=t[o](s),l=a.value}catch(t){return void n(t)}a.done?e(l):Promise.resolve(l).then(i,r)}function od(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,sd(i.key),i)}}function sd(t){var e=function(t){if("object"!=Ju(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ju(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ju(e)?e:e+""}var ad=function(){return t=function t(e){var n,i,r,o=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._map=e,this._pluginConfig=s,this._mode="disabled",this._modeInstance=null,this._listeners=new Map,this.store={source:r=new sl,getOL:function(t){var e;return null!==(e=r.getFeatureById(String(t)))&&void 0!==e?e:null},add:function(t){var e=this.getOL(t.id);e&&r.removeFeature(e);var n=Rl.readFeature(t);return r.addFeature(n),n},get:function(t){var e=this.getOL(t);return e?Rl.writeFeatureObject(e):null},remove:function(t){var e,n=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Ml(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ml(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}(Array.isArray(t)?t:[t]);try{for(n.s();!(e=n.n()).done;){var i=e.value,o=this.getOL(i);o&&r.removeFeature(o)}}catch(t){n.e(t)}finally{n.f()}},clear:function(){r.clear()},toGeoJSON:function(t){return Rl.writeFeatureObject(t)},fromGeoJSON:function(t){return Rl.readFeature(t)}},this.undoStack=(0,Fl.B)(function(t){return o.emit(mc.k.UNDO_CHANGE,t)}),this.mapStyle=null,this.colors=(0,$l.$)(null,s),this.styles=ql(this.colors),this.snap=kh(e,null!==(n=s.snapLayers)&&void 0!==n?n:null,this.colors,null!==(i=s.snapRadius)&&void 0!==i?i:Ol.vf.snapRadius),this._layer=new Na({source:this.store.source,style:this.styles.createFeatureStyle(),zIndex:100}),this._layer.set("layerId","draw"),this._layer.set("layerType","vector"),e.addLayer(this._layer)},e=[{key:"setMapStyle",value:function(t){var e;this.mapStyle=t,this.colors=(0,$l.$)(t,this._pluginConfig),this.styles=ql(this.colors),this._layer.setStyle(this.styles.createFeatureStyle()),this.store.source.changed(),null===(e=this.snap)||void 0===e||e.updateColors(this.colors),this.emit(yc,this.styles)}},{key:"on",value:function(t,e){this._listeners.has(t)||this._listeners.set(t,new Set),this._listeners.get(t).add(e)}},{key:"off",value:function(t,e){var n;null===(n=this._listeners.get(t))||void 0===n||n.delete(e)}},{key:"emit",value:function(t,e){var n=this._listeners.get(t);n&&Array.from(n).forEach(function(t){return t(e)})}},{key:"changeMode",value:(n=Qu().m(function t(e){var n,i,r,o,s,a,l,h=this,c=arguments;return Qu().w(function(t){for(;;)switch(t.n){case 0:o=c.length>1&&void 0!==c[1]?c[1]:{},null===(n=this._modeInstance)||void 0===n||n.destroy(),this._modeInstance=null,this._mode=e,s="draw_polygon"===e||"draw_line"===e||"draw_point"===e||"edit_vertex"===e||"edit_point"===e,null===(i=this.snap)||void 0===i||i.setIndicatorActive(s),a=nd(nd({},o),{},{snap:this.snap}),"draw_polygon"===e||"draw_line"===e?this._modeInstance=Ic({map:this._map,manager:this,options:a}):"draw_point"===e?(l=nd(nd({},a),{},{resolvePointSymbol:function(t){return Zu({manager:h,mapProvider:o.mapProvider,olFeature:t})}}),this._modeInstance=Bu({map:this._map,manager:this,options:l})):"edit_vertex"===e?this._modeInstance=Ru({map:this._map,manager:this,options:a}):"edit_point"===e&&(this._modeInstance=Nu({map:this._map,manager:this,options:a})),null===(r=this.snap)||void 0===r||r.reattach();case 1:return t.a(2)}},t,this)}),i=function(){var t=this,e=arguments;return new Promise(function(i,r){var o=n.apply(t,e);function s(t){rd(o,i,r,s,a,"next",t)}function a(t){rd(o,i,r,s,a,"throw",t)}s(void 0)})},function(t){return i.apply(this,arguments)})},{key:"getMode",value:function(){return this._mode}},{key:"done",value:function(){var t;null===(t=this._modeInstance)||void 0===t||t.done()}},{key:"cancel",value:function(){var t;null===(t=this._modeInstance)||void 0===t||t.cancel(),this.changeMode("disabled")}},{key:"undo",value:function(){var t;null===(t=this._modeInstance)||void 0===t||t.undo()}},{key:"deleteVertex",value:function(){var t;null===(t=this._modeInstance)||void 0===t||t.deleteVertex()}},{key:"nudgeSelectedVertex",value:function(t,e,n){var i,r;null===(i=this._modeInstance)||void 0===i||null===(r=i.nudgeSelectedVertex)||void 0===r||r.call(i,t,e,n)}},{key:"getVertexItems",value:function(){var t,e,n;return null!==(t=null===(e=this._modeInstance)||void 0===e||null===(n=e.getVertexItems)||void 0===n?void 0:n.call(e))&&void 0!==t?t:{vertices:[],midpoints:[]}}},{key:"selectVertex",value:function(t){var e,n;null===(e=this._modeInstance)||void 0===e||null===(n=e.selectVertex)||void 0===n||n.call(e,t)}},{key:"insertVertexAtMidpoint",value:function(t){var e,n;null===(e=this._modeInstance)||void 0===e||null===(n=e.insertVertexAtMidpoint)||void 0===n||n.call(e,t)}},{key:"setInvalid",value:function(t){var e,n;null===(e=this._modeInstance)||void 0===e||null===(n=e.setInvalid)||void 0===n||n.call(e,t)}},{key:"setDrawingPreviewProperty",value:function(t,e){var n,i;null===(n=this._modeInstance)||void 0===n||null===(i=n.setDrawingPreviewProperty)||void 0===i||i.call(n,t,e)}},{key:"setInterfaceType",value:function(t){var e,n;null===(e=this._modeInstance)||void 0===e||null===(n=e.setInterfaceType)||void 0===n||n.call(e,t),this.emit(mc.k.INTERFACE_TYPE_CHANGE,{interfaceType:t})}},{key:"get",value:function(t){return this.store.get(t)}},{key:"add",value:function(t){return this.store.add(t)}},{key:"delete",value:function(t){return this.store.remove(t)}},{key:"deleteAll",value:function(){return this.store.clear()}},{key:"remove",value:function(){var t,e;null===(t=this._modeInstance)||void 0===t||t.destroy(),this._modeInstance=null,null===(e=this.snap)||void 0===e||e.destroy(),this.snap=null,this.store.clear(),this._map.removeLayer(this._layer),this._listeners.clear()}}],e&&od(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,i}();function ld(t){return ld="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ld(t)}function hd(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function cd(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?hd(Object(n),!0).forEach(function(e){dd(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hd(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function ud(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,fd(i.key),i)}}function dd(t,e,n){return(e=fd(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fd(t){var e=function(t){if("object"!=ld(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ld(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ld(e)?e:e+""}var gd=function(){return t=function t(e,n){var i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),dd(this,"_snapEnabled",!1);var r=function(t){var e,n=t.mapProvider,i=t.events,r=t.eventBus,o=t.pluginConfig,s=void 0===o?{}:o,a=t.mapStyle,l=void 0===a?null:a,h=n.map,c=new ad(h,s);l&&c.setMapStyle(l),n.draw=c,n.drawScale=null!==(e=Ol.$y[n.mapSize])&&void 0!==e?e:1;var u=function(){return r.emit(i.MAP_DATA_CHANGE)},d=function(t){var e;n.drawScale=null!==(e=Ol.$y[t])&&void 0!==e?e:1,Ku({manager:c,mapProvider:n}).then(u)};r.on(i.MAP_SET_SIZE,d);var f=function(t){c.setMapStyle(t),Ku({manager:c,mapProvider:n}).then(u)};return r.on(i.MAP_SET_STYLE,f),{manager:c,remove:function(){r.off(i.MAP_SET_SIZE,d),r.off(i.MAP_SET_STYLE,f),c.remove(),n.draw=null}}}({mapProvider:e,events:n.events,eventBus:n.eventBus,pluginConfig:null!==(i=n.pluginConfig)&&void 0!==i?i:{snapLayers:n.snapLayers},mapStyle:n.mapStyle}),o=r.manager,s=r.remove;this._cleanupOLDraw=s,this._manager=o,this._mapProvider=e},e=[{key:"changeMode",value:function(t){var e=cd(cd({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),{},{mapProvider:this._mapProvider});return"draw_polygon"===t&&(e.geometryType="Polygon"),"draw_line"===t&&(e.geometryType="LineString"),this._manager.changeMode(t,e)}},{key:"getMode",value:function(){return this._manager.getMode()}},{key:"setInterfaceType",value:function(t){this._manager.setInterfaceType(t)}},{key:"done",value:function(){this._manager.undoStack.clear(),this._manager.done()}},{key:"cancel",value:function(){this._manager.undoStack.clear(),this._manager.cancel()}},{key:"undo",value:function(){this._manager.undo()}},{key:"deleteVertex",value:function(){this._manager.deleteVertex()}},{key:"nudgeSelectedVertex",value:function(t,e,n){this._manager.nudgeSelectedVertex(t,e,n)}},{key:"getVertexItems",value:function(){return this._manager.getVertexItems()}},{key:"selectVertex",value:function(t){this._manager.selectVertex(t)}},{key:"insertVertexAtMidpoint",value:function(t){this._manager.insertVertexAtMidpoint(t)}},{key:"setGeometryValid",value:function(t){this._manager._geometryValid=t}},{key:"_geometryValidator",get:function(){return this._manager._geometryValidator},set:function(t){this._manager._geometryValidator=t}},{key:"setInvalid",value:function(t){this._manager.setInvalid(t)}},{key:"get",value:function(t){return this._manager.get(t)}},{key:"add",value:function(t){var e,n=this._manager.add(t);return"Point"===(null===(e=t.geometry)||void 0===e?void 0:e.type)&&qu(t.properties)&&Zu({manager:this._manager,mapProvider:this._mapProvider,olFeature:n}),n}},{key:"setStyle",value:function(t,e){var n,i=this._manager.store.getOL(t);i&&(i.setProperties(e),"Point"===(null===(n=i.getGeometry())||void 0===n?void 0:n.getType())&&qu(i.getProperties())&&Zu({manager:this._manager,mapProvider:this._mapProvider,olFeature:i}))}},{key:"delete",value:function(t){return this._manager.delete(t)}},{key:"deleteAll",value:function(){return this._manager.deleteAll()}},{key:"setSnapEnabled",value:function(t){var e;this._snapEnabled=t,null===(e=this._manager.snap)||void 0===e||e.setActive(t)}},{key:"setSnapLayers",value:function(t){var e,n=this,i=null==t?void 0:t.map(function(t){return"stroke-inactive.cold"===t?n._manager._layer:t});null===(e=this._manager.snap)||void 0===e||e.setSnapLayers(i)}},{key:"isSnapEnabled",value:function(){return this._snapEnabled}},{key:"setFeatureProperty",value:function(){}},{key:"setDrawingPreviewProperty",value:function(t,e){this._manager.setDrawingPreviewProperty(t,e)}},{key:"on",value:function(t,e){this._manager.on(t,e)}},{key:"off",value:function(t,e){this._manager.off(t,e)}},{key:"remove",value:function(){this._cleanupOLDraw()}}],e&&ud(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()},473(t,e,n){n.d(e,{$:()=>o});var i=n(682);function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var o=function(t){var e,n,o,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null!==(e=null==t?void 0:t.mapColorScheme)&&void 0!==e?e:"light",l=null!==(n=null==t?void 0:t.id)&&void 0!==n?n:null,h=function(t){var e;return function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return"object"!==r(t)||null===t?t:n&&void 0!==t[n]?t[n]:void 0!==t[e]?t[e]:void 0!==t.light?t.light:Object.values(t)[0]}(null!==(e=s[t])&&void 0!==e?e:i.lm[t],a,l)};return{editStroke:h("editStroke"),editFill:h("editFill"),editVertex:h("editVertex"),editMidpoint:h("editMidpoint"),editActive:h("editActive"),editHalo:h("editHalo"),invalidStroke:h("invalidStroke"),splitValid:h("splitValid"),splitInvalid:h("splitInvalid"),shapeStroke:h("shapeStroke"),strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:i.F0.strokeWidth,shapeFill:h("shapeFill"),snapVertex:h("snapVertex"),snapEdge:h("snapEdge"),mapStyleId:l}}},722(t,e,n){n.d(e,{$X:()=>l,DD:()=>o,Ox:()=>a,ZP:()=>s,mt:()=>h});var i=n(682),r=i.F0.touchTargetSize/2,o=function(t){var e,n,o=t.querySelector("[data-im-draw-touch-target]");return o||(t.insertAdjacentHTML("beforeend",(e=i.F0.touchTargetSize,n=r,"\n <svg width='".concat(e,"' height='").concat(e,"' viewBox='0 0 48 48' fill-rule='evenodd'\n style='display:none;position:absolute;top:0;left:0;margin:").concat(n,"px 0 0 -").concat(n,"px;cursor:grab'\n class='im-draw-touch-target' data-im-draw-touch-target>\n <circle cx='24' cy='24' r='24' fill='var(--draw-halo, #000)'/>\n <path d=\"M37.543 25H34a1 1 0 1 1 0-2h3.629l-.836-.837a1 1 0 0 1 1.414-1.414l2.5 2.501A1 1 0 0 1 41 24a1 1 0 0 1-.487.858l-2.306 2.306a1 1 0 0 1-1.414-1.414l.75-.75zM23 10.414l-.793.793a1 1 0 0 1-1.414-1.414l2.5-2.5C23.481 7.105 23.734 7 24 7s.519.105.707.293l2.5 2.5a1 1 0 0 1-1.414 1.414L25 10.414V14a1 1 0 1 1-2 0v-3.586zM7 24a1 1 0 0 1 .293-.75l2.5-2.501a1 1 0 0 1 1.414 1.414l-.836.837H14a1 1 0 1 1 0 2h-3.543l.75.75a1 1 0 0 1-1.414 1.414l-2.306-2.306A1 1 0 0 1 7 24zm16.293 16.707l-2.5-2.5a1 1 0 0 1 1.414-1.414l.793.793V34a1 1 0 1 1 2 0v3.586l.793-.793a1 1 0 0 1 1.414 1.414l-2.5 2.5c-.188.188-.441.293-.707.293s-.519-.105-.707-.293zM24 20c2.208 0 4 1.792 4 4s-1.792 4-4 4-4-1.792-4-4 1.792-4 4-4z\" fill='var(--draw-bg, #fff)'/>\n </svg>\n "))),o=t.querySelector("[data-im-draw-touch-target]")),o},s=function(t,e){t&&(t.style.setProperty("--draw-halo",e.editActive),t.style.setProperty("--draw-bg",e.editHalo),t.style.setProperty("--draw-primary",e.editVertex))},a=function(t,e){e&&t&&(t.style.left="".concat(e.x,"px"),t.style.top="".concat(e.y,"px"),t.style.display="block")},l=function(t){t&&(t.style.display="none")},h=function(t){if(!t)return!1;var e=t.parentNode;return e instanceof globalThis.SVGElement||null!=(null==e?void 0:e.ownerSVGElement)}},610(t,e,n){n.d(e,{B:()=>i});var i=function(t){var e=[];return{push:function(n){e.push(n),t(e.length)},pop:function(){var n=e.pop();return t(e.length),n},clear:function(){e.length=0,t(e.length)},get length(){return e.length}}}},715(t,e,n){n.d(e,{O:()=>c});var i=n(520),r=n(9),o=n(788);function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach(function(e){h(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function h(t,e,n){return(e=function(t){var e=function(t){if("object"!=s(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==s(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var c=function(t){var e=t.onStrokeChange,n=t.onPlaceChange,s=function(t){var e=!1;return function(n,i){n!==e&&(e=n,t(n,null!=i?i:null))}},a=s(e),h=s(n),c=!1,u=null,d=null,f=null,g=function(){null!=d&&((0,o.WG)(d),d=null),f=null},p=function(t,e,n,r,o){var s,a=(null!==(s=e.numVertices)&&void 0!==s?s:0)<r?{valid:!0}:(0,i.$U)(t,l(l({},e),{},{phase:"preview"}),{rules:n});o(!a.valid||c,a.valid?u:a.reason)},m=function(){var t,e;if(f){var n=f,i=n.feature,o=n.context,s=null!==(t=r.n8[null==i||null===(e=i.geometry)||void 0===e?void 0:e.type])&&void 0!==t?t:0;p(i,o,r.PI,s,a),p(i,o,r.Oo,0,h)}},y=function(){if(d=null,f){var t=f,e=t.feature,n=t.context,r=t.onGeometryChange,o=(0,i.$U)(e,l(l({},n),{},{phase:"preview"}),{rules:[],onGeometryChange:r});c=!o.valid,u=o.reason,m()}};return{update:function(t){var e=t.feature,n=t.context,i=void 0===n?{}:n,r=t.numVertices,s=t.onGeometryChange;f={feature:e,context:l(l({},i),{},{numVertices:r}),onGeometryChange:s},m(),"function"==typeof s&&null==d&&(d=(0,o.PW)(y))},reset:function(){g(),c=!1,u=null,a(!1,null),h(!1,null)},destroy:function(){g()}}}},788(t,e,n){n.d(e,{De:()=>c,PW:()=>l,WG:()=>h});var i=n(520);function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function s(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach(function(e){a(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function a(t,e,n){return(e=function(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var l=function(t){return"function"==typeof requestAnimationFrame?requestAnimationFrame(t):setTimeout(t,16)},h=function(t){return"function"==typeof cancelAnimationFrame?cancelAnimationFrame(t):clearTimeout(t)},c=function(t){var e=t.onChange,n=t.validate,r=void 0===n?i.Uk:n,o=!1,a=null,c=null,u=function(){null!=a&&(h(a),a=null),c=null},d=function(t,n){t!==o&&(o=t,e(t,null!=n?n:null))},f=function(){if(a=null,c){var t=c,e=t.feature,n=t.context,i=t.onGeometryChange,o=r(e,n,{onGeometryChange:i}),s=o.valid,l=o.reason;d(!s,l)}};return{update:function(t){var e=t.feature,n=t.context,i=void 0===n?{}:n,o=t.numVertices,h=t.onGeometryChange,g=s(s({},i),{},{numVertices:o}),p=r(e,g);return p.valid?"function"!=typeof h?(u(),void d(!1,null)):(c={feature:e,context:g,onGeometryChange:h},void(null==a&&(a=l(f)))):(u(),void d(!0,p.reason))},set:function(t,e){u(),d(t,null!=e?e:null)},refresh:function(){e(o,null)},destroy:function(){u()}}}},600(t,e,n){function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}n.d(e,{a:()=>k});var r=function(t,e){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===i(t)){if(e&&t[e])return t[e];var n=Object.values(t)[0];return null!=n?n:null}return null},o={symbol:"pin",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},s={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},a={id:"pin",viewBox:"0 0 44 44",anchor:[.5,.9],graphic:s.dot,svg:'<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},l={id:"circle",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:s.dot,svg:'<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},h={id:"square",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:s.dot,svg:'<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},c=n(121),u={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}},d=function(t,e,n){return new Promise(function(i,r){var o="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(t)),s=new Image(e,n);s.onload=function(){var t=document.createElement("canvas");t.width=e,t.height=n;var r=t.getContext("2d");r.drawImage(s,0,0,e,n),i(r.getImageData(0,0,e,n))},s.onerror=function(){r(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},s.src=o})};function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function g(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var l=i&&i.prototype instanceof a?i:a,h=Object.create(l.prototype);return p(h,"_invoke",function(n,i,r){var o,a,l,h=0,c=r||[],u=!1,d={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(e,n){return o=e,a=0,l=t,d.n=n,s}};function f(n,i){for(a=n,l=i,e=0;!u&&h&&!r&&e<c.length;e++){var r,o=c[e],f=d.p,g=o[2];n>3?(r=g===i)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=f&&((r=n<2&&f<o[1])?(a=0,d.v=i,d.n=o[1]):f<g&&(r=n<3||o[0]>i||i>g)&&(o[4]=n,o[5]=i,d.n=g,a=0))}if(r||n>1)return s;throw u=!0,i}return function(r,c,g){if(h>1)throw TypeError("Generator is already running");for(u&&1===c&&f(c,g),a=c,l=g;(e=a<2?t:l)||!u;){o||(a?a<3?(a>1&&(d.n=-1),f(a,l)):d.n=l:d.v=l);try{if(h=2,o){if(a||(r="next"),e=o[r]){if(!(e=e.call(o,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=t}else if((e=(u=d.n<0)?l:n.call(i,d))!==s)break}catch(e){o=t,a=1,l=e}finally{h=1}}return{value:e,done:u}}}(n,r,o),!0),h}var s={};function a(){}function l(){}function h(){}e=Object.getPrototypeOf;var c=[][i]?e(e([][i]())):(p(e={},i,function(){return this}),e),u=h.prototype=a.prototype=Object.create(c);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,p(t,r,"GeneratorFunction")),t.prototype=Object.create(u),t}return l.prototype=h,p(u,"constructor",h),p(h,"constructor",l),l.displayName="GeneratorFunction",p(h,r,"GeneratorFunction"),p(u),p(u,r,"Generator"),p(u,i,function(){return this}),p(u,"toString",function(){return"[object Generator]"}),(g=function(){return{w:o,m:d}})()}function p(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}p=function(t,e,n,i){function o(e,n){p(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},p(t,e,n,i)}function m(t,e,n,i,r,o,s){try{var a=t[o](s),l=a.value}catch(t){return void n(t)}a.done?e(l):Promise.resolve(l).then(i,r)}function y(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function _(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?y(Object(n),!0).forEach(function(e){v(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function v(t,e,n){return(e=function(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||S(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t,e){if(t){if("string"==typeof t)return w(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(t,e):void 0}}function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var C=new Map,b=new Map,I={},E=function(t){var e,n=0,i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=S(t))){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==e.return||e.return()}finally{if(s)throw r}}}}(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n=Math.trunc((n<<5)-n+r.codePointAt(0))}}catch(t){i.e(t)}finally{i.f()}return Math.abs(n).toString(36)},P=new Set(["id","svg","viewBox","anchor","symbol","symbolSvgContent"]);function T(t,e,n){var i,a,l,h,c=null==n?void 0:n.id,d=Object.fromEntries(Object.entries(t||{}).filter(function(t){var e=x(t,1)[0];return!P.has(e)})),f=Object.fromEntries(Object.entries(I).filter(function(t){var e=x(t,1)[0];return!P.has(e)})),g=Object.fromEntries(Object.entries(e).filter(function(t){return null!=x(t,2)[1]})),p=_(_(_(_({},o),f),d),g),m=null!==(i=u[null==n?void 0:n.mapColorScheme])&&void 0!==i?i:u.light;return p.haloColor=null!==(a=null==n?void 0:n.haloColor)&&void 0!==a?a:m.haloColor,p.selectedColor=null!==(l=null==n?void 0:n.selectedColor)&&void 0!==l?l:m.selectedColor,p.activeColor=null!==(h=null==n?void 0:n.activeColor)&&void 0!==h?h:m.activeColor,"string"==typeof p.graphic&&s[p.graphic]&&(p.graphic=s[p.graphic]),Object.fromEntries(Object.entries(p).map(function(t){var e=x(t,2),n=e[0],i=e[1];return[n,r(i,c)||""]}))}function M(t,e){return Object.entries(e).reduce(function(t,e){var n=x(e,2),i=n[0],r=n[1];return t.replaceAll("{{".concat(i,"}}"),r)},t)}var k={setDefaults:function(t){I=t||{}},getDefaults:function(){return _(_({},o),I)},register:function(t){C.set(t.id,t)},get:function(t){return C.get(t)},list:function(){return function(t){if(Array.isArray(t))return w(t)}(t=C.values())||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var t},clear:function(){C.clear()},initialise:function(){this.register(a),this.register(l),this.register(h)},resolve:function(t,e,n){var i=T(t,e||{},n);return t?(i.selectedColor="none",i.activeColor="none",M(t.svg,i)):""},resolveActive:function(t,e,n){var i=T(t,e||{},n);return t?M(t.svg,i):""},resolveSelected:function(t,e,n){var i=T(t,e||{},n);return t?(i.activeColor="none",M(t.svg,i)):""},getSymbolImageId:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,r=this.getSymbolDef(t);if(!r)return null;var o=(0,c.sR)(t),s=n?this.resolveActive(r,o,e):this.resolve(r,o,e);return"symbol-".concat(n?"act-":"").concat(E(s),"-").concat(i,"x")},getSymbolDef:function(t){return t.symbolSvgContent?{svg:t.symbolSvgContent}:t.symbol?this.get(t.symbol):void 0},rasteriseSymbolImage:function(t,e,n,i){var r,o=this;return(r=g().m(function r(){var s,a,l,h,u,f,p,m,y,_,v,S;return g().w(function(r){for(;;)switch(r.n){case 0:if(s=o.getSymbolDef(t)){r.n=1;break}return r.a(2,null);case 1:if(a=(0,c.sR)(t),"active"===n?(l=o.resolveActive(s,a,e),h="act-"):"selected"===n?(l=o.resolveSelected(s,a,e),h="sel-"):(l=o.resolve(s,a,e),h=""),u="symbol-".concat(h).concat(E(l),"-").concat(i,"x"),f=b.get(u)){r.n=3;break}return p=(0,c.n8)(t,s),m=p.split(" ").map(Number),y=x(m,4),_=y[2],v=y[3],S='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(_*i,'" height="').concat(v*i,'" viewBox="').concat(p,'">').concat(l,"</svg>"),r.n=2,d(S,_*i,v*i);case 2:f=r.v,b.set(u,f);case 3:return r.a(2,{imageId:u,imageData:f})}},r)}),function(){var t=this,e=arguments;return new Promise(function(n,i){var o=r.apply(t,e);function s(t){m(o,n,i,s,a,"next",t)}function a(t){m(o,n,i,s,a,"throw",t)}s(void 0)})})()}};k.initialise()},195(t,e,n){n.d(e,{z:()=>r});var i=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"]),r=function(t){t.altKey&&i.has(t.key)&&t.stopPropagation()}},107(t,e,n){n.d(e,{c:()=>i});var i=function(t,e,n){var i=function(t,e){return t[0]===e[0]&&t[1]===e[1]},r=e.filter(function(e){var r=Math.abs(e[0]-t[0]),o=Math.abs(e[1]-t[1]);return("ArrowUp"===n?e[1]<=t[1]&&o>=r:"ArrowDown"===n?e[1]>t[1]&&o>=r:"ArrowLeft"===n?e[0]<=t[0]&&o<r:"ArrowRight"!==n||e[0]>t[0]&&o<r)&&!i(e,t)});r.length||r.push(t);var o=function(e){return Math.hypot(t[0]-e[0],t[1]-e[1])},s=r.reduce(function(t,e){return o(e)<o(t)?e:t},r[0]);return e.findIndex(function(t){return i(t,s)})}},121(t,e,n){n.d(e,{Op:()=>s,n8:()=>o,sR:()=>r});var i=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),r=function(t){if(!function(t){return!(!t.symbol&&!t.symbolSvgContent)}(t))return{};var e={};return i.forEach(function(n){if(null!=t[n]){var i=n.charAt(6).toLowerCase()+n.slice(7);e[i]=t[n]}}),e},o=function(t,e){var n;return t.symbolViewBox?t.symbolViewBox:null!==(n=null==e?void 0:e.viewBox)&&void 0!==n?n:"0 0 38 38"},s=function(t,e){var n;return t.symbolAnchor?t.symbolAnchor:null!==(n=null==e?void 0:e.anchor)&&void 0!==n?n:[.5,.5]}}}]);
2
+ "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[722],{706(t,e,n){n.r(e),n.d(e,{OLDrawAdapter:()=>gd});function i(t,e){return t>e?1:t<e?-1:0}function r(t,e){return t<e?1:t>e?-1:0}function o(t,e,n){if(t[0]<=e)return 0;const i=t.length;if(e<=t[i-1])return i-1;if("function"==typeof n){for(let r=1;r<i;++r){const i=t[r];if(i===e)return r;if(i<e)return n(e,t[r-1],i)>0?r-1:r}return i-1}if(n>0){for(let n=1;n<i;++n)if(t[n]<e)return n-1;return i-1}if(n<0){for(let n=1;n<i;++n)if(t[n]<=e)return n;return i-1}for(let n=1;n<i;++n){if(t[n]==e)return n;if(t[n]<e)return t[n-1]-e<e-t[n]?n-1:n}return i-1}function s(t,e,n){for(;e<n;){const i=t[e];t[e]=t[n],t[n]=i,++e,--n}}function a(t,e){const n=Array.isArray(e)?e:[e],i=n.length;for(let e=0;e<i;e++)t[t.length]=n[e]}function l(t,e){const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}function h(t){const e=[1/0,1/0,-1/0,-1/0];for(let n=0,i=t.length;n<i;++n)w(e,t[n]);return e}function c(t,e,n){return n?(n[0]=t[0]-e,n[1]=t[1]-e,n[2]=t[2]+e,n[3]=t[3]+e,n):[t[0]-e,t[1]-e,t[2]+e,t[3]+e]}function u(t,e,n){let i,r;return i=e<t[0]?t[0]-e:t[2]<e?e-t[2]:0,r=n<t[1]?t[1]-n:t[3]<n?n-t[3]:0,i*i+r*r}function d(t,e){return g(t,e[0],e[1])}function f(t,e){return t[0]<=e[0]&&e[2]<=t[2]&&t[1]<=e[1]&&e[3]<=t[3]}function g(t,e,n){return t[0]<=e&&e<=t[2]&&t[1]<=n&&n<=t[3]}function p(t,e){const n=t[0],i=t[1],r=t[2],o=t[3],s=e[0],a=e[1];let l=0;return s<n?l|=16:s>r&&(l|=4),a<i?l|=8:a>o&&(l|=2),0===l&&(l=1),l}function m(t,e,n,i,r){return r?(r[0]=t,r[1]=e,r[2]=n,r[3]=i,r):[t,e,n,i]}function y(t){return m(1/0,1/0,-1/0,-1/0,t)}function _(t,e){const n=t[0],i=t[1];return m(n,i,n,i,e)}function v(t,e,n,i,r){return C(y(r),t,e,n,i)}function x(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function S(t,e){return e[0]<t[0]&&(t[0]=e[0]),e[2]>t[2]&&(t[2]=e[2]),e[1]<t[1]&&(t[1]=e[1]),e[3]>t[3]&&(t[3]=e[3]),t}function w(t,e){e[0]<t[0]&&(t[0]=e[0]),e[0]>t[2]&&(t[2]=e[0]),e[1]<t[1]&&(t[1]=e[1]),e[1]>t[3]&&(t[3]=e[1])}function C(t,e,n,i,r){for(;n<i;n+=r)b(t,e[n],e[n+1]);return t}function b(t,e,n){t[0]=Math.min(t[0],e),t[1]=Math.min(t[1],n),t[2]=Math.max(t[2],e),t[3]=Math.max(t[3],n)}function I(t,e){let n;return n=e(E(t)),n||(n=e(P(t)),n||(n=e(R(t)),n||(n=e(k(t)),n||!1)))}function E(t){return[t[0],t[1]]}function P(t){return[t[2],t[1]]}function T(t){return[(t[0]+t[2])/2,(t[1]+t[3])/2]}function M(t){return t[3]-t[1]}function k(t){return[t[0],t[3]]}function R(t){return[t[2],t[3]]}function F(t){return t[2]-t[0]}function O(t,e){return t[0]<=e[2]&&t[2]>=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function A(t){return t[2]<t[0]||t[3]<t[1]}function L(t,e){const n=e.getExtent(),i=T(t);if(e.canWrapX()&&(i[0]<n[0]||i[0]>=n[2])){const e=F(n),r=Math.floor((i[0]-n[0])/e)*e;t[0]-=r,t[2]-=r}return t}function D(t,e,n){return Math.min(Math.max(t,e),n)}function G(t,e,n,i,r,o){const s=r-n,a=o-i;if(0!==s||0!==a){const l=((t-n)*s+(e-i)*a)/(s*s+a*a);l>1?(n=r,i=o):l>0&&(n+=s*l,i+=a*l)}return j(t,e,n,i)}function j(t,e,n,i){const r=n-t,o=i-e;return r*r+o*o}function V(t){return 180*t/Math.PI}function N(t){return t*Math.PI/180}function W(t,e){const n=t%e;return n*e<0?n+e:n}function B(t,e,n){return t+n*(e-t)}function X(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}function Y(t,e,n){if(t>=e&&t<n)return t;const i=n-e;return((t-e)%i+i)%i+e}function z(t,e){const n=t[0],i=t[1],r=e[0],o=e[1],s=r[0],a=r[1],l=o[0],h=o[1],c=l-s,u=h-a,d=0===c&&0===u?0:(c*(n-s)+u*(i-a))/(c*c+u*u||0);let f,g;return d<=0?(f=s,g=a):d>=1?(f=l,g=h):(f=s+d*c,g=a+d*u),[f,g]}function U(t,e){let n=!0;for(let i=t.length-1;i>=0;--i)if(t[i]!=e[i]){n=!1;break}return n}function H(t,e){const n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function q(t,e){return Math.sqrt(H(t,e))}const $="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"",Z=($.includes("safari")&&!$.includes("chrom")&&($.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test($)),$.includes("webkit")&&$.includes("edge"),$.includes("macintosh"),"undefined"!=typeof devicePixelRatio&&devicePixelRatio,"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope),K="undefined"!=typeof Image&&Image.prototype.decode;function J(t,e,n,i){let r;return r=n&&n.length?n.shift():Z?new class extends OffscreenCanvas{style={}}(t??300,e??150):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("2d",i)}let Q;function tt(){return Q||(Q=J(1,1)),Q}!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}}();const et=2;let nt=1;const it={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937},rt=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||it[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_}},ot=6378137,st=Math.PI*ot,at=[-st,-st,st,st],lt=[-180,-85,180,85],ht=ot*Math.log(Math.tan(Math.PI/2));class ct extends rt{constructor(t){super({code:t,units:"m",extent:at,global:!0,worldExtent:lt,getPointResolution:function(t,e){return t/Math.cosh(e[1]/ot)}})}}const ut=[new ct("EPSG:3857"),new ct("EPSG:102100"),new ct("EPSG:102113"),new ct("EPSG:900913"),new ct("http://www.opengis.net/def/crs/EPSG/0/3857"),new ct("http://www.opengis.net/gml/srs/epsg.xml#3857")];const dt=[-180,-90,180,90],ft=6378137*Math.PI/180;class gt extends rt{constructor(t,e){super({code:t,units:"degrees",extent:dt,axisOrientation:e,global:!0,metersPerUnit:ft,worldExtent:dt})}}const pt=[new gt("CRS:84"),new gt("EPSG:4326","neu"),new gt("urn:ogc:def:crs:OGC:1.3:CRS84"),new gt("urn:ogc:def:crs:OGC:2:84"),new gt("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new gt("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new gt("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let mt={},yt={};function _t(t,e,n){const i=t.getCode(),r=e.getCode();i in yt||(yt[i]={}),yt[i][r]=n}function vt(t,e){return t in yt&&e in yt[t]?yt[t][e]:null}const xt=.9996,St=.00669438,wt=St*St,Ct=wt*St,bt=St/(1-St),It=Math.sqrt(1-St),Et=(1-It)/(1+It),Pt=Et*Et,Tt=Pt*Et,Mt=Tt*Et,kt=Mt*Et,Rt=.9983242984503243,Ft=15*wt/256+45*Ct/1024,Ot=35*Ct/3072,At=1.5*Et-27/32*Tt+269/512*kt,Lt=21/16*Pt-55/32*Mt,Dt=151/96*Tt-417/128*kt,Gt=1097/512*Mt,jt=6378137;function Vt(t,e,n){const i=t-5e5,r=(n.north?e:e-1e7)/xt/(jt*Rt),o=r+At*Math.sin(2*r)+Lt*Math.sin(4*r)+Dt*Math.sin(6*r)+Gt*Math.sin(8*r),s=Math.sin(o),a=s*s,l=Math.cos(o),h=s/l,c=h*h,u=c*c,d=1-St*a,f=Math.sqrt(1-St*a),g=bt*l**2,p=g*g,m=i/(jt/f*xt),y=m*m,_=y*m,v=_*m,x=v*m,S=o-h/((1-St)/d)*(y/2-v/24*(5+3*c+10*g-4*p-9*bt))+x*m/720*(61+90*c+298*g+45*u-252*bt-3*p);let w=(m-_/6*(1+2*c+g)+x/120*(5-2*g+28*c-3*p+8*bt+24*u))/l;return w=Y(w+N(Wt(n.number)),-Math.PI,Math.PI),[V(w),V(S)]}function Nt(t,e,n){t=Y(t,-180,180),e<-80?e=-80:e>84&&(e=84);const i=N(e),r=Math.sin(i),o=Math.cos(i),s=r/o,a=s*s,l=a*a,h=N(t),c=N(Wt(n.number)),u=jt/Math.sqrt(1-St*r**2),d=bt*o**2,f=o*Y(h-c,-Math.PI,Math.PI),g=f*f,p=g*f,m=p*f,y=m*f,_=y*f,v=jt*(Rt*i-.002514607064228144*Math.sin(2*i)+Ft*Math.sin(4*i)-Ot*Math.sin(6*i)),x=xt*u*(f+p/6*(1-a+d)+y/120*(5-18*a+l+72*d-58*bt))+5e5;let S=xt*(v+u*s*(g/2+m/24*(5-a+9*d+4*d**2)+_/720*(61-58*a+l+600*d-330*bt)));return n.north||(S+=1e7),[x,S]}function Wt(t){return 6*(t-1)-180+3}const Bt=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Xt(t){let e=0;for(const n of Bt){const i=t.match(n);if(i){e=parseInt(i[1]);break}}if(!e)return null;let n=0,i=!1;return e>32700&&e<32761?n=e-32700:e>32600&&e<32661&&(i=!0,n=e-32600),n?{number:n,north:i}:null}function Yt(t,e){return function(n,i,r,o){const s=n.length;r=r>1?r:2,o=o??r,i||(i=r>2?n.slice():new Array(s));for(let r=0;r<s;r+=o){const o=n[r],s=n[r+1],a=t(o,s,e);i[r]=a[0],i[r+1]=a[1]}return i}}const zt=[function(t){const e=Xt(t.getCode());return e?{forward:Yt(Nt,e),inverse:Yt(Vt,e)}:null}],Ut=[function(t){return Xt(t)?new rt({code:t,units:"m"}):null}];let Ht=!0;function qt(t,e){if(void 0!==e)for(let n=0,i=t.length;n<i;++n)e[n]=t[n];else e=t.slice();return e}function $t(t){!function(t,e){mt[t]=e}(t.getCode(),t),_t(t,t,qt)}function Zt(t){if("string"!=typeof t)return t;const e=mt[n=t]||mt[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null;var n;if(e)return e;for(const e of Ut){const n=e(t);if(n)return n}return null}function Kt(t){!function(t){t.forEach($t)}(t),t.forEach(function(e){t.forEach(function(t){e!==t&&_t(e,t,qt)})})}function Jt(t,e){return t?"string"==typeof t?Zt(t):t:Zt(e)}function Qt(t,e){const n=t.getCode(),i=e.getCode();let r=vt(n,i);if(r)return r;let o=null,s=null;for(const n of zt)o||(o=n(t)),s||(s=n(e));if(!o&&!s)return null;const a="EPSG:4326";if(s)if(o)r=te(o.inverse,s.forward);else{const t=vt(n,a);t&&(r=te(t,s.forward))}else{const t=vt(a,i);t&&(r=te(o.inverse,t))}return r&&($t(t),$t(e),_t(t,e,r)),r}function te(t,e){return function(n,i,r,o){return i=t(n,i,r,o),e(i,i,r,o)}}function ee(t,e){return Qt(Zt(t),Zt(e))}function ne(t,e,n){const i=ee(e,n);if(!i){const t=Zt(e).getCode(),i=Zt(n).getCode();throw new Error(`No transform available between ${t} and ${i}`)}return i(t,void 0,t.length)}let ie=null;function re(){return ie}function oe(t,e){return t}function se(t,e){return Ht&&!U(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(Ht=!1,function(...t){nt>et||console.warn(...t)}("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t}function ae(t,e){return t}function le(t,e){return t}function he(t,e){return t}var ce,ue,de;Kt(ut),Kt(pt),ce=ut,ue=function(t,e,n,i){const r=t.length;n=n>1?n:2,i=i??n,void 0===e&&(e=n>2?t.slice():new Array(r));for(let n=0;n<r;n+=i){e[n]=st*t[n]/180;let i=ot*Math.log(Math.tan(Math.PI*(+t[n+1]+90)/360));i>ht?i=ht:i<-ht&&(i=-ht),e[n+1]=i}return e},de=function(t,e,n,i){const r=t.length;n=n>1?n:2,i=i??n,void 0===e&&(e=n>2?t.slice():new Array(r));for(let n=0;n<r;n+=i)e[n]=180*t[n]/st,e[n+1]=360*Math.atan(Math.exp(t[n+1]/ot))/Math.PI-90;return e},pt.forEach(function(t){ce.forEach(function(e){_t(t,e,ue),_t(e,t,de)})});const fe="prerender",ge="postrender",pe=[NaN,NaN,NaN,0];let me;const ye=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,_e=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,ve=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,xe=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Se(t,e){return t.endsWith("%")?Number(t.substring(0,t.length-1))/e:Number(t)}function we(t){throw new Error('failed to parse "'+t+'" as color')}function Ce(t){if(t.toLowerCase().startsWith("rgb")){const e=t.match(_e)||t.match(ye)||t.match(ve);if(e){const t=e[4],n=100/255;return[D(Se(e[1],n)+.5|0,0,255),D(Se(e[2],n)+.5|0,0,255),D(Se(e[3],n)+.5|0,0,255),void 0!==t?D(Se(t,100),0,1):1]}we(t)}if(t.startsWith("#")){if(xe.test(t)){const e=t.substring(1),n=e.length<=4?1:2,i=[0,0,0,255];for(let t=0,r=e.length;t<r;t+=n){let r=parseInt(e.substring(t,t+n),16);1===n&&(r+=r<<4),i[t/n]=r}return i[3]=i[3]/255,i}we(t)}const e=(me||(me=J(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),me);e.fillStyle="#abcdef";let n=e.fillStyle;e.fillStyle=t,e.fillStyle===n&&(e.fillStyle="#fedcba",n=e.fillStyle,e.fillStyle=t,e.fillStyle===n&&we(t));const i=e.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return Ce(i);e.clearRect(0,0,1,1),e.fillRect(0,0,1,1);const r=Array.from(e.getImageData(0,0,1,1).data);return r[3]=X(r[3]/255,3),r}const be={};let Ie=0;function Ee(t){if(4===t.length)return t;const e=t.slice();return e[3]=1,e}function Pe(t){return t>.0031308?269.025*Math.pow(t,1/2.4)-14.025:3294.6*t}function Te(t){return t>.2068965?Math.pow(t,3):108/841*(t-4/29)}function Me(t){return t>10.314724?Math.pow((t+14.025)/269.025,2.4):t/3294.6}function ke(t){return t>.0088564?Math.pow(t,1/3):t/(108/841)+4/29}function Re(t){const e=Me(t[0]),n=Me(t[1]),i=Me(t[2]),r=ke(.222488403*e+.716873169*n+.06060791*i),o=500*(ke(.452247074*e+.399439023*n+.148375274*i)-r),s=200*(r-ke(.016863605*e+.117638439*n+.865350722*i)),a=Math.atan2(s,o)*(180/Math.PI);return[116*r-16,Math.sqrt(o*o+s*s),a<0?a+360:a,t[3]]}function Fe(t){if("none"===t)return pe;if(be.hasOwnProperty(t))return be[t];if(Ie>=1024){let t=0;for(const e in be)3&t++||(delete be[e],--Ie)}const e=Ce(t);4!==e.length&&we(t);for(const n of e)isNaN(n)&&we(t);return be[t]=e,++Ie,e}function Oe(t){return Array.isArray(t)?t:Fe(t)}function Ae(t){let e=t[0];e!=(0|e)&&(e=e+.5|0);let n=t[1];n!=(0|n)&&(n=n+.5|0);let i=t[2];return i!=(0|i)&&(i=i+.5|0),"rgba("+e+","+n+","+i+","+(void 0===t[3]?1:Math.round(1e3*t[3])/1e3)+")"}const Le="change",De=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function Ge(){return!0}function je(){return!1}function Ve(){}function Ne(t){let e,n,i;return function(){const r=Array.prototype.slice.call(arguments);return n&&this===i&&l(r,n)||(i=this,n=r,e=t.apply(this,arguments)),e}}function We(t){for(const e in t)delete t[e]}function Be(t){let e;for(e in t)return!1;return!e}const Xe=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},Ye=class extends De{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const n=this.listeners_||(this.listeners_={}),i=n[t]||(n[t]=[]);i.includes(e)||i.push(e)}dispatchEvent(t){const e="string"==typeof t,n=e?t:t.type,i=this.listeners_&&this.listeners_[n];if(!i)return;const r=e?new Xe(t):t;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),s=this.pendingRemovals_||(this.pendingRemovals_={});let a;n in o||(o[n]=0,s[n]=0),++o[n];for(let t=0,e=i.length;t<e;++t)if(a="handleEvent"in i[t]?i[t].handleEvent(r):i[t].call(this,r),!1===a||r.propagationStopped){a=!1;break}if(0===--o[n]){let t=s[n];for(delete s[n];t--;)this.removeEventListener(n,Ve);delete o[n]}return a}disposeInternal(){this.listeners_&&We(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)}removeEventListener(t,e){if(!this.listeners_)return;const n=this.listeners_[t];if(!n)return;const i=n.indexOf(e);-1!==i&&(this.pendingRemovals_&&t in this.pendingRemovals_?(n[i]=Ve,++this.pendingRemovals_[t]):(n.splice(i,1),0===n.length&&delete this.listeners_[t]))}};function ze(t,e){return t+":"+(e?Oe(e):"null")}const Ue=new class{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 n=this.cache_[e];3&t++||n.hasListener()||(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){const n=ze(t,e);return n in this.cache_?this.cache_[n]:null}getPattern(t,e){const n=ze(t,e);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,n,i){const r=ze(t,e),o=r in this.cache_;this.cache_[r]=n,i&&(0===n.getImageState()&&n.load(),1===n.getImageState()?n.ready().then(()=>{this.patternCache_[r]=tt().createPattern(n.getImage(1),"repeat")}):this.patternCache_[r]=tt().createPattern(n.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};let He=null;class qe extends Ye{constructor(t,e,n,i,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=n?.crossOrigin,this.referrerPolicy_=n?.referrerPolicy,this.canvas_={},this.color_=r,this.imageState_=void 0===i?0:i,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(void 0===this.tainted_&&2===this.imageState_){He||(He=J(1,1,void 0,{willReadFrequently:!0})),He.drawImage(this.image_,0,0);try{He.getImageData(0,0,1,1),this.tainted_=!1}catch{He=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(Le)}handleImageError_(){this.imageState_=3,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=2,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_}setImage(t){this.image_=t}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],n=J(t,e);n.fillRect(0,0,t,e),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(0===this.imageState_){this.image_||this.initializeImage_(),this.imageState_=1;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&(t=this.image_,e=this.src_,e&&(t.src=e),t.src&&K?new Promise((e,n)=>t.decode().then(()=>e(t)).catch(i=>t.complete&&t.width?e(t):n(i))):function(t){return new Promise((e,n)=>{function i(){o(),e(t)}function r(){o(),n(new Error("Image load error"))}function o(){t.removeEventListener("load",i),t.removeEventListener("error",r)}t.addEventListener("load",i),t.addEventListener("error",r)})}(t)).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}var t,e}replaceColor_(t){if(!this.color_||this.canvas_[t]||2!==this.imageState_)return;const e=this.image_,n=J(Math.ceil(e.width*t),Math.ceil(e.height*t)),i=n.canvas;var r;n.scale(t,t),n.drawImage(e,0,0),n.globalCompositeOperation="multiply",n.fillStyle="string"==typeof(r=this.color_)?r:Ae(r),n.fillRect(0,0,i.width/t,i.height/t),n.globalCompositeOperation="destination-in",n.drawImage(e,0,0),this.canvas_[t]=i}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(2===this.imageState_||3===this.imageState_)t();else{const e=()=>{2!==this.imageState_&&3!==this.imageState_||(this.removeEventListener(Le,e),t())};this.addEventListener(Le,e)}})),this.ready_}}function $e(t,e,n,i,r,o){let s=void 0===e?void 0:Ue.get(e,r);return s||(s=new qe(t,t&&"src"in t?t.src||void 0:e,n,i,r),Ue.set(e,r,s,o)),o&&s&&!Ue.getPattern(e,r)&&Ue.set(e,r,s,o),s}const Ze=qe;function Ke(t){return t?Array.isArray(t)?Ae(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return Ue.getPattern(t.src,t.color);const e=t.src+":"+t.offset,n=Ue.getPattern(e,t.color);if(n)return n;const i=Ue.get(t.src,null);if(2!==i.getImageState())return null;const r=J(t.size[0],t.size[1]);return r.drawImage(i.getImage(1),t.offset[0],t.offset[1],t.size[0],t.size[1],0,0,t.size[0],t.size[1]),$e(r.canvas,e,void 0,2,t.color,!0),Ue.getPattern(e,t.color)}(t):t:null}function Je(t,e,n,i,r){r=void 0!==r?r:[];let o=0;for(let s=e;s<n;s+=i)r[o++]=t.slice(s,s+i);return r.length=o,r}function Qe(t,e,n,i,r){r=void 0!==r?r:[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=n[s];r[o++]=Je(t,e,a,i,r[o]),e=a}return r.length=o,r}function tn(t,e,n,i,r){r=void 0!==r?r:[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=n[s];r[o++]=1===a.length&&a[0]===e?[]:Qe(t,e,a,i,r[o]),e=a[a.length-1]}return r.length=o,r}const en=class{drawCustom(t,e,n,i,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,n){}drawFeature(t,e,n){}drawGeometryCollection(t,e,n){}drawLineString(t,e,n){}drawMultiLineString(t,e,n){}drawMultiPoint(t,e,n){}drawMultiPolygon(t,e,n){}drawPoint(t,e,n){}drawPolygon(t,e,n){}drawText(t,e,n){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}},nn="propertychange";function rn(t,e,n,i,r){if(r){const r=n;n=function(o){return t.removeEventListener(e,n),r.call(i??this,o)}}else i&&i!==t&&(n=n.bind(i));const o={target:t,type:e,listener:n};return t.addEventListener(e,n),o}function on(t,e,n,i){return rn(t,e,n,i,!0)}function sn(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),We(t))}class an extends Ye{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(Le)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const n=t.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=rn(this,t[r],e);return i}return rn(this,t,e)}onceInternal(t,e){let n;if(Array.isArray(t)){const i=t.length;n=new Array(i);for(let r=0;r<i;++r)n[r]=on(this,t[r],e)}else n=on(this,t,e);return e.ol_key=n,n}unInternal(t,e){const n=e.ol_key;if(n)!function(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;++e)sn(t[e]);else sn(t)}(n);else if(Array.isArray(t))for(let n=0,i=t.length;n<i;++n)this.removeEventListener(t[n],e);else this.removeEventListener(t,e)}}an.prototype.on,an.prototype.once,an.prototype.un;const ln=an;function hn(){throw new Error("Unimplemented abstract method.")}let cn=0;function un(t){return t.ol_uid||(t.ol_uid=String(++cn))}class dn extends Xe{constructor(t,e,n){super(t),this.key=e,this.oldValue=n}}const fn=class extends ln{constructor(t){super(),this.on,this.once,this.un,un(this),this.values_=null,void 0!==t&&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 n;n=`change:${t}`,this.hasListener(n)&&this.dispatchEvent(new dn(n,t,e)),n=nn,this.hasListener(n)&&this.dispatchEvent(new dn(n,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,n){const i=this.values_||(this.values_={});if(n)i[t]=e;else{const n=i[t];i[t]=e,n!==e&&this.notify(t,n)}}setProperties(t,e){for(const n in t)this.set(n,t[n],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const n=this.values_[t];delete this.values_[t],Be(this.values_)&&(this.values_=null),e||this.notify(t,n)}}},gn=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"),pn=["style","variant","weight","size","lineHeight","family"],mn={normal:400,bold:700},yn=function(t){const e=t.match(gn);if(!e)return null;const n={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let t=0,i=pn.length;t<i;++t){const i=e[t+1];void 0!==i&&(n[pn[t]]="string"==typeof i?i.trim():i)}return isNaN(Number(n.weight))&&n.weight in mn&&(n.weight=mn[n.weight]),n.families=n.family.split(/,\s?/).map(t=>t.trim().replace(/^['"]|['"]$/g,"")),n},_n="10px sans-serif",vn="#000",xn="round",Sn=[],wn="round",Cn="#000",bn="center",In="middle",En=[0,0,0,0],Pn=new fn;let Tn,Mn=null;const kn={},Rn=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function Fn(t,e,n){return`${t} ${e} 16px "${n}"`}const On=function(){const t=100;let e,n;async function i(t){await n.ready;const e=await n.load(t);if(0===e.length)return!1;const i=yn(t),r=i.families[0].toLowerCase(),o=i.weight;return e.some(t=>{const e=t.family.replace(/^['"]|['"]$/g,"").toLowerCase(),n=mn[t.weight]||t.weight;return e===r&&t.style===i.style&&n==o})}async function r(){await n.ready;let o=!0;const s=Pn.getProperties(),a=Object.keys(s).filter(e=>s[e]<t);for(let e=a.length-1;e>=0;--e){const n=a[e];let r=s[n];r<t&&(await i(n)?(We(kn),Pn.set(n,t)):(r+=10,Pn.set(n,r,!0),r<t&&(o=!1)))}e=void 0,o||(e=setTimeout(r,100))}return async function(t){n||(n=Z?self.fonts:document.fonts);const i=yn(t);if(!i)return;const o=i.families;let s=!1;for(const t of o){if(Rn.has(t))continue;const e=Fn(i.style,i.weight,t);void 0===Pn.get(e)&&(Pn.set(e,0,!0),s=!0)}s&&(clearTimeout(e),e=setTimeout(r,100))}}(),An=function(){let t;return function(e){let n=kn[e];if(null==n){if(Z){const t=yn(e),i=Ln(e,"Žg");n=(isNaN(Number(t.lineHeight))?1.2:Number(t.lineHeight))*(i.actualBoundingBoxAscent+i.actualBoundingBoxDescent)}else t||(t=document.createElement("div"),t.innerHTML="M",t.style.minHeight="0",t.style.maxHeight="none",t.style.height="auto",t.style.padding="0",t.style.border="none",t.style.position="absolute",t.style.display="block",t.style.left="-99999px"),t.style.font=e,document.body.appendChild(t),n=t.offsetHeight,document.body.removeChild(t);kn[e]=n}return n}}();function Ln(t,e){return Mn||(Mn=J(1,1)),t!=Tn&&(Mn.font=t,Tn=Mn.font),Mn.measureText(e)}function Dn(t,e){return Ln(t,e).width}function Gn(t,e,n){if(e in n)return n[e];const i=e.split("\n").reduce((e,n)=>Math.max(e,Dn(t,n)),0);return n[e]=i,i}const jn={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},Vn=[jn.FILL],Nn=[jn.STROKE],Wn=[jn.BEGIN_PATH],Bn=[jn.CLOSE_PATH],Xn=jn,Yn=class extends en{constructor(t,e,n,i){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=i,this.maxLineWidth=0,this.resolution=n,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 1==e?t:t.map(function(t){return t*e})}appendFlatPointCoordinates(t,e){const n=this.getBufferedMaxExtent(),i=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let s=0,a=t.length;s<a;s+=e)i[0]=t[s],i[1]=t[s+1],d(n,i)&&(r[o++]=i[0],r[o++]=i[1]);return o}appendFlatLineCoordinates(t,e,n,i,r,o){const s=this.coordinates;let a=s.length;const l=this.getBufferedMaxExtent();o&&(e+=i);let h=t[e],c=t[e+1];const u=this.tmpCoordinate_;let d,f,g,m=!0;for(d=e+i;d<n;d+=i)u[0]=t[d],u[1]=t[d+1],g=p(l,u),g!==f?(m&&(s[a++]=h,s[a++]=c,m=!1),s[a++]=u[0],s[a++]=u[1]):1===g?(s[a++]=u[0],s[a++]=u[1],m=!1):m=!0,h=u[0],c=u[1],f=g;return(r&&m||d===e+i)&&(s[a++]=h,s[a++]=c),a}drawCustomCoordinates_(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o],a=this.appendFlatLineCoordinates(t,e,s,i,!1,!1);r.push(a),e=s}return e}drawCustom(t,e,n,i,r){this.beginGeometry(t,e,r);const o=t.getType(),s=t.getStride(),a=this.coordinates.length;let l,h,c,u,d;switch(o){case"MultiPolygon":l=t.getOrientedFlatCoordinates(),u=[];const e=t.getEndss();d=0;for(let t=0,n=e.length;t<n;++t){const n=[];d=this.drawCustomCoordinates_(l,d,e[t],s,n),u.push(n)}this.instructions.push([Xn.CUSTOM,a,u,t,n,tn,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,u,t,i||n,tn,r]);break;case"Polygon":case"MultiLineString":c=[],l="Polygon"==o?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),d=this.drawCustomCoordinates_(l,0,t.getEnds(),s,c),this.instructions.push([Xn.CUSTOM,a,c,t,n,Qe,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,c,t,i||n,Qe,r]);break;case"LineString":case"Circle":l=t.getFlatCoordinates(),h=this.appendFlatLineCoordinates(l,0,l.length,s,!1,!1),this.instructions.push([Xn.CUSTOM,a,h,t,n,Je,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,h,t,i||n,Je,r]);break;case"MultiPoint":l=t.getFlatCoordinates(),h=this.appendFlatPointCoordinates(l,s),h>a&&(this.instructions.push([Xn.CUSTOM,a,h,t,n,Je,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,h,t,i||n,Je,r]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),h=this.coordinates.length,this.instructions.push([Xn.CUSTOM,a,h,t,n,void 0,r]),this.hitDetectionInstructions.push([Xn.CUSTOM,a,h,t,i||n,void 0,r])}this.endGeometry(e)}beginGeometry(t,e,n){this.beginGeometryInstruction1_=[Xn.BEGIN_GEOMETRY,e,0,t,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[Xn.BEGIN_GEOMETRY,e,0,t,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;let e;t.reverse();const n=t.length;let i,r,o=-1;for(e=0;e<n;++e)i=t[e],r=i[0],r==Xn.END_GEOMETRY?o=e:r==Xn.BEGIN_GEOMETRY&&(i[2]=e,s(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const n=t.getColor();e.fillPatternScale=n&&"object"==typeof n&&"src"in n?this.pixelRatio:1,e.fillStyle=Ke(n||vn)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const n=t.getColor();e.strokeStyle=Ke(n||Cn);const i=t.getLineCap();e.lineCap=void 0!==i?i:xn;const r=t.getLineDash();e.lineDash=r?r.slice():Sn;const o=t.getLineDashOffset();e.lineDashOffset=o||0;const s=t.getLineJoin();e.lineJoin=void 0!==s?s:wn;const a=t.getWidth();e.lineWidth=void 0!==a?a:1;const l=t.getMiterLimit();e.miterLimit=void 0!==l?l:10;const h=t.getOffset();e.strokeOffset=h??0,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,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){const n=this.state;this.fillStyleToState(t,n),this.strokeStyleToState(e,n)}createFill(t){const e=t.fillStyle,n=[Xn.SET_FILL_STYLE,e];return"string"!=typeof e&&n.push(t.fillPatternScale),n}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[Xn.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 n=t.fillStyle;(void 0!==n&&"string"!=typeof n||t.currentFillStyle!=n)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=n)}updateStrokeStyle(t,e){const n=t.strokeStyle,i=t.lineCap,r=t.lineDash,o=t.lineDashOffset,s=t.lineJoin,a=t.lineWidth,h=t.miterLimit,c=t.strokeOffset;(t.currentStrokeStyle!=n||t.currentLineCap!=i||r!=t.currentLineDash&&!l(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=s||t.currentLineWidth!=a||t.currentMiterLimit!=h||t.currentStrokeOffset!=c)&&(e.call(this,t),t.currentStrokeStyle=n,t.currentLineCap=i,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=s,t.currentLineWidth=a,t.currentMiterLimit=h,t.currentStrokeOffset=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[Xn.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=this.maxExtent.slice(),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;c(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}};function zn(t,e,n,i,r,o,s){const a=(n-e)/i;if(a<3){for(;e<n;e+=i)o[s++]=t[e],o[s++]=t[e+1];return s}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[e,n-i];let c=0;for(;h.length>0;){const n=h.pop(),o=h.pop();let s=0;const a=t[o],u=t[o+1],d=t[n],f=t[n+1];for(let e=o+i;e<n;e+=i){const n=G(t[e],t[e+1],a,u,d,f);n>s&&(c=e,s=n)}s>r&&(l[(c-e)/i]=1,o+i<c&&h.push(o,c),c+i<n&&h.push(c,n))}for(let n=0;n<a;++n)l[n]&&(o[s++]=t[e+n*i],o[s++]=t[e+n*i+1]);return s}function Un(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];s=zn(t,e,h,i,r,o,s),a.push(s),e=h}return s}function Hn(t,e){return e*Math.round(t/e)}function qn(t,e,n,i,r,o,s){if(e==n)return s;let a,l,h=Hn(t[e],r),c=Hn(t[e+1],r);e+=i,o[s++]=h,o[s++]=c;do{if(a=Hn(t[e],r),l=Hn(t[e+1],r),(e+=i)==n)return o[s++]=a,o[s++]=l,s}while(a==h&&l==c);for(;e<n;){const n=Hn(t[e],r),u=Hn(t[e+1],r);if(e+=i,n==a&&u==l)continue;const d=a-h,f=l-c,g=n-h,p=u-c;d*p==f*g&&(d<0&&g<d||d==g||d>0&&g>d)&&(f<0&&p<f||f==p||f>0&&p>f)?(a=n,l=u):(o[s++]=a,o[s++]=l,h=a,c=l,a=n,l=u)}return o[s++]=a,o[s++]=l,s}function $n(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];s=qn(t,e,h,i,r,o,s),a.push(s),e=h}return s}const Zn=class extends Yn{constructor(t,e,n,i){super(t,e,n,i)}drawFlatCoordinatess_(t,e,n,i,r){const o=this.state,s=void 0!==o.fillStyle,a=void 0!==o.strokeStyle,l=n.length;this.instructions.push(Wn),this.hitDetectionInstructions.push(Wn);for(let o=0;o<l;++o){const s=n[o],l=this.coordinates.length,h=this.appendFlatLineCoordinates(t,e,s,i,!0,!a);this.instructions.push([Xn.MOVE_TO_LINE_TO,l,h,r*this.pixelRatio,!0]),this.hitDetectionInstructions.push([Xn.MOVE_TO_LINE_TO,l,h,r,!0]),a&&(this.instructions.push(Bn),this.hitDetectionInstructions.push(Bn)),e=s}return s&&(this.instructions.push(Vn),this.hitDetectionInstructions.push(Vn)),a&&(this.instructions.push(Nn),this.hitDetectionInstructions.push(Nn)),e}drawCircle(t,e,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle,s=i.strokeOffset;if(void 0===r&&void 0===o)return;if(this.handleStrokeOffset_(()=>this.drawCircle(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([Xn.SET_FILL_STYLE,vn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[Xn.CIRCLE,h,s];this.instructions.push(Wn,c),this.hitDetectionInstructions.push(Wn,c),void 0!==i.fillStyle&&(this.instructions.push(Vn),this.hitDetectionInstructions.push(Vn)),void 0!==i.strokeStyle&&(this.instructions.push(Nn),this.hitDetectionInstructions.push(Nn)),this.endGeometry(e)}drawPolygon(t,e,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle,s=i.strokeOffset;if(void 0===r&&void 0===o)return;if(this.handleStrokeOffset_(()=>this.drawPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([Xn.SET_FILL_STYLE,vn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),h=t.getStride();this.drawFlatCoordinatess_(l,0,a,h,s),this.endGeometry(e)}drawMultiPolygon(t,e,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle,s=i.strokeOffset;if(void 0===r&&void 0===o)return;if(this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([Xn.SET_FILL_STYLE,vn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),h=t.getStride();let c=0;for(let t=0,e=a.length;t<e;++t)c=this.drawFlatCoordinatess_(l,c,a[t],h,s);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(0!==t){const e=this.coordinates;for(let n=0,i=e.length;n<i;++n)e[n]=Hn(e[n],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}handleStrokeOffset_(t){const e=this.state,n=e.fillStyle,i=e.strokeStyle,r=e.strokeOffset;return Math.abs(r)>0&&void 0!==n&&void 0!==i&&(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=i,e.strokeOffset=r,t(),e.fillStyle=n,!0)}};function Kn(t,e,n,i,r){const o=[];let s=n,a=0,l=e.slice(n,2);for(;a<t&&s+r<i;){const[n,i]=l.slice(-2),h=e[s+r],c=e[s+r+1],u=Math.sqrt((h-n)*(h-n)+(c-i)*(c-i));if(a+=u,a>=t){const e=(t-a+u)/u,d=B(n,h,e),f=B(i,c,e);l.push(d,f),o.push(l),l=[d,f],a==t&&(s+=r),a=0}else if(a<t)l.push(e[s+r],e[s+r+1]),s+=r;else{const t=u-a,e=B(n,h,t/u),d=B(i,c,t/u);l.push(e,d),o.push(l),l=[e,d],a=0,s+=r}}return a>0&&o.push(l),o}function Jn(t,e,n,i,r){let o,s,a,l,h,c,u,d,f,g,p=n,m=n,y=0,_=0,v=n;for(s=n;s<i;s+=r){const n=e[s],i=e[s+1];void 0!==h&&(f=n-h,g=i-c,l=Math.sqrt(f*f+g*g),void 0!==u&&(_+=a,o=Math.acos((u*f+d*g)/(a*l)),o>t&&(_>y&&(y=_,p=v,m=s),_=0,v=s-r)),a=l,u=f,d=g),h=n,c=i}return _+=l,_>y?[v,s]:[p,m]}const Qn={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},ti={Circle:Zn,Default:Yn,Image:class extends Yn{constructor(t,e,n,i){super(t,e,n,i),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,n){if(!this.image_||this.maxExtent&&!d(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,n);const i=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,s=this.appendFlatPointCoordinates(i,r);this.instructions.push([Xn.DRAW_IMAGE,o,s,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([Xn.DRAW_IMAGE,o,s,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,n){if(!this.image_)return;this.beginGeometry(t,e,n);const i=t.getFlatCoordinates(),r=[];for(let e=0,n=i.length;e<n;e+=t.getStride())this.maxExtent&&!d(this.maxExtent,i.slice(e,e+2))||r.push(i[e],i[e+1]);const o=this.coordinates.length,s=this.appendFlatPointCoordinates(r,2);this.instructions.push([Xn.DRAW_IMAGE,o,s,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([Xn.DRAW_IMAGE,o,s,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 n=t.getAnchor(),i=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=n[0],this.anchorY_=n[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=i[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_=i[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}},LineString:class extends Yn{constructor(t,e,n,i){super(t,e,n,i)}drawFlatCoordinates_(t,e,n,i,r){const o=this.coordinates.length,s=this.appendFlatLineCoordinates(t,e,n,i,!1,!1);return this.instructions.push([Xn.MOVE_TO_LINE_TO,o,s,r*this.pixelRatio]),this.hitDetectionInstructions.push([Xn.MOVE_TO_LINE_TO,o,s,r]),n}drawLineString(t,e,n){const i=this.state,r=i.strokeStyle,o=i.lineWidth,s=i.strokeOffset;if(void 0===r||void 0===o)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e,n),this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0],Wn);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l,s),this.hitDetectionInstructions.push(Nn),this.endGeometry(e)}drawMultiLineString(t,e,n){const i=this.state,r=i.strokeStyle,o=i.lineWidth,s=i.strokeOffset;if(void 0===r||void 0===o)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e,n),this.hitDetectionInstructions.push([Xn.SET_STROKE_STYLE,Cn,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Sn,0],Wn);const a=t.getEnds(),l=t.getFlatCoordinates(),h=t.getStride();let c=0;for(let t=0,e=a.length;t<e;++t)c=this.drawFlatCoordinates_(l,c,a[t],h,s);this.hitDetectionInstructions.push(Nn),this.endGeometry(e)}finish(){const t=this.state;return null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Nn),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Nn),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(Wn)}},Polygon:Zn,Text:class extends Yn{constructor(t,e,n,i){super(t,e,n,i),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[vn]={fillStyle:vn},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,n){const i=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(""===this.text_||!o||!i&&!r)return;const s=this.coordinates;let a=s.length;const l=t.getType();let h=null,c=t.getStride();if("line"!==o.placement||"LineString"!=l&&"MultiLineString"!=l&&"Polygon"!=l&&"MultiPolygon"!=l){let i=o.overflow?null:[];switch(l){case"Point":case"MultiPoint":h=t.getFlatCoordinates();break;case"LineString":h=t.getFlatMidpoint();break;case"Circle":h=t.getCenter();break;case"MultiLineString":h=t.getFlatMidpoints(),c=2;break;case"Polygon":h=t.getFlatInteriorPoint(),o.overflow||i.push(h[2]/this.resolution),c=3;break;case"MultiPolygon":const e=t.getFlatInteriorPoints();h=[];for(let t=0,n=e.length;t<n;t+=3)o.overflow||i.push(e[t+2]/this.resolution),h.push(e[t],e[t+1]);if(0===h.length)return;c=2}const r=this.appendFlatPointCoordinates(h,c);if(r===a)return;if(i&&(r-a)/2!==h.length/c){let t=a/2;i=i.filter((e,n)=>{const i=s[2*(t+n)]===h[n*c]&&s[2*(t+n)+1]===h[n*c+1];return i||--t,i})}this.saveTextStates_();const u=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,d=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,n);let f=o.padding;if(f!=En&&(o.scale[0]<0||o.scale[1]<0)){let t=o.padding[0],e=o.padding[1],n=o.padding[2],i=o.padding[3];o.scale[0]<0&&(e=-e,i=-i),o.scale[1]<0&&(t=-t,n=-n),f=[t,e,n,i]}const g=this.pixelRatio;this.instructions.push([Xn.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,f==En?En:f.map(function(t){return t*g}),u,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]);const p=1/g,m=u?u.slice(0):null;m&&(m[1]=vn),this.hitDetectionInstructions.push([Xn.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,this.declutterMode_,this.declutterImageWithText_,f,m,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?vn:this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]),this.endGeometry(e)}else{if(!O(this.maxExtent,t.getExtent()))return;let i;if(h=t.getFlatCoordinates(),"LineString"==l)i=[h.length];else if("MultiLineString"==l)i=t.getEnds();else if("Polygon"==l)i=t.getEnds().slice(0,1);else if("MultiPolygon"==l){const e=t.getEndss();i=[];for(let t=0,n=e.length;t<n;++t)i.push(e[t][0])}this.beginGeometry(t,e,n);const r=o.repeat,u=r?void 0:o.textAlign;let d=0;for(let t=0,e=i.length;t<e;++t){let e;e=r?Kn(r*this.resolution,h,d,i[t],c):[h.slice(d,i[t])];for(let n=0,r=e.length;n<r;++n){const r=e[n];let l=0,h=r.length;if(null==u){const t=Jn(o.maxAngle,r,0,r.length,2);l=t[0],h=t[1]}for(let t=l;t<h;t+=c)s.push(r[t],r[t+1]);const f=s.length;d=i[t],this.drawChars_(a,f),a=f}}this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,n=this.textFillState_,i=this.strokeKey_;t&&(i in this.strokeStates||(this.strokeStates[i]={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||bn,justify:e.justify,textBaseline:e.textBaseline||In,scale:e.scale});const o=this.fillKey_;n&&(o in this.fillStates||(this.fillStates[o]={fillStyle:n.fillStyle}))}drawChars_(t,e){const n=this.textStrokeState_,i=this.textState_,r=this.strokeKey_,o=this.textKey_,s=this.fillKey_;this.saveTextStates_();const a=this.pixelRatio,l=Qn[i.textBaseline],h=this.textOffsetY_*a,c=this.text_,u=n?n.lineWidth*Math.abs(i.scale[0])/2:0;this.instructions.push([Xn.DRAW_CHARS,t,e,l,i.overflow,s,i.maxAngle,a,h,r,u*a,c,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([Xn.DRAW_CHARS,t,e,l,i.overflow,s?vn:s,i.maxAngle,a,h,r,u*a,c,o,1/a,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let n,i,r;if(t){const e=t.getFill();e?(i=this.textFillState_,i||(i={},this.textFillState_=i),i.fillStyle=Ke(e.getColor()||vn)):(i=null,this.textFillState_=i);const o=t.getStroke();if(o){r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const t=o.getLineDash(),e=o.getLineDashOffset(),n=o.getWidth(),i=o.getMiterLimit();r.lineCap=o.getLineCap()||xn,r.lineDash=t?t.slice():Sn,r.lineDashOffset=void 0===e?0:e,r.lineJoin=o.getLineJoin()||wn,r.lineWidth=void 0===n?1:n,r.miterLimit=void 0===i?10:i,r.strokeStyle=Ke(o.getColor()||Cn)}else r=null,this.textStrokeState_=r;n=this.textState_;const s=t.getFont()||_n;On(s);const a=t.getScaleArray();n.overflow=t.getOverflow(),n.font=s,n.maxAngle=t.getMaxAngle(),n.placement=t.getPlacement(),n.textAlign=t.getTextAlign(),n.repeat=t.getRepeat(),n.justify=t.getJustify(),n.textBaseline=t.getTextBaseline()||In,n.backgroundFill=t.getBackgroundFill(),n.backgroundStroke=t.getBackgroundStroke(),n.padding=t.getPadding()||En,n.scale=void 0===a?[1,1]:a;const l=t.getOffsetX(),h=t.getOffsetY(),c=t.getRotateWithView(),u=t.getKeepUpright(),d=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=void 0===l?0:l,this.textOffsetY_=void 0===h?0:h,this.textRotateWithView_=void 0!==c&&c,this.textKeepUpright_=void 0===u||u,this.textRotation_=void 0===d?0:d,this.strokeKey_=r?("string"==typeof r.strokeStyle?r.strokeStyle:un(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=n.font+n.scale+(n.textAlign||"?")+(n.repeat||"?")+(n.justify||"?")+(n.textBaseline||"?"),this.fillKey_=i&&i.fillStyle?"string"==typeof i.fillStyle?i.fillStyle:"|"+un(i.fillStyle):""}else this.text_="";this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}},ei=class{constructor(t,e,n,i){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=i,this.resolution_=n,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const n=this.buildersByZIndex_[e];for(const i in n){const r=n[i].finish();t[e][i]=r}}return t}getBuilder(t,e){const n=void 0!==t?t.toString():"0";let i=this.buildersByZIndex_[n];void 0===i&&(i={},this.buildersByZIndex_[n]=i);let r=i[e];return void 0===r&&(r=new(0,ti[e])(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),i[e]=r),r}};function ni(t,e,n,i,r,o,s){o=o||[],s=s||2;let a=0;for(let l=e;l<n;l+=i){const e=t[l],n=t[l+1];o[a++]=r[0]*e+r[2]*n+r[4],o[a++]=r[1]*e+r[3]*n+r[5];for(let e=2;e<s;e++)o[a++]=t[l+e]}return o&&o.length!=a&&(o.length=a),o}function ii(t,e,n,i,r,o,s){s=s||[];const a=Math.cos(r),l=Math.sin(r),h=o[0],c=o[1];let u=0;for(let r=e;r<n;r+=i){const e=t[r]-h,n=t[r+1]-c;s[u++]=h+e*a-n*l,s[u++]=c+e*l+n*a;for(let e=r+2;e<r+i;++e)s[u++]=t[e]}return s&&s.length!=u&&(s.length=u),s}function ri(t,e){if(!t)throw new Error(e)}function oi(t,e){const n=e[0],i=e[1];return e[0]=t[0]*n+t[2]*i+t[4],e[1]=t[1]*n+t[3]*i+t[5],e}function si(t,e,n,i,r,o,s,a){const l=Math.sin(o),h=Math.cos(o);return t[0]=i*h,t[1]=r*l,t[2]=-i*l,t[3]=r*h,t[4]=s*i*h-a*i*l+e,t[5]=s*r*l+a*r*h+n,t}new Array(6);const ai=[1e5,1e5,1e5,1e5,2,2];function li(t){return t.substring(7,t.length-1).split(",").map(parseFloat)}function hi(t,e,n,i){let r=t[e],o=t[e+1],s=0;for(let a=e+i;a<n;a+=i){const e=t[a],n=t[a+1];s+=Math.sqrt((e-r)*(e-r)+(n-o)*(n-o)),r=e,o=n}return s}function ci(t,e,n,i,r,o,s,a){s=s??[],a=a??i;const l=t[e+i],h=t[e+i+1],c=t[n-2*i],u=t[n-2*i+1];let d,f,g,p,m,y,_,v,x=0;for(let S=e;S<n;S+=i){g=d,p=f,m=void 0,y=void 0,S+i<n&&(m=t[S+i],y=t[S+i+1]),o&&S===e&&(g=c,p=u),o&&S===n-i&&(m=l,y=h),d=t[S],f=t[S+1],[_,v]=ui(d,f,g,p,m,y,r),s[x++]=_,s[x++]=v;for(let e=2;e<a;e++)s[x++]=t[S+e]}return s.length!=x&&(s.length=x),s}function ui(t,e,n,i,r,o,s){let a,l;void 0!==n&&void 0!==i?(a=t-n,l=e-i):void 0!==r&&void 0!==o?(a=r-t,l=o-e):(a=1,l=0);const h=Math.hypot(a,l),c=a/h,u=l/h;if(a=-u,l=c,void 0===n||void 0===i)return[t+a*s,e+l*s];if(void 0===r||void 0===o)return[t+a*s,e+l*s];const d=function(t,e,n){const i=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),r=[(e[0]-t[0])/i,(e[1]-t[1])/i],o=[-r[1],r[0]],s=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),a=[(n[0]-t[0])/s,(n[1]-t[1])/s];let l=0===i||0===s?0:Math.acos(D(a[0]*r[0]+a[1]*r[1],-1,1));return l=Math.max(l,1e-5),a[0]*o[0]+a[1]*o[1]>0?l:2*Math.PI-l}([t,e],[n,i],[r,o]);if(Math.cos(d)>.998)return[t+c*s,e+u*s];const f=Math.cos(d/2),g=Math.sin(d/2);return[t+1/g*(g*a+f*l)*s,e+1/g*(-f*a+g*l)*s]}function di(t,e){for(let n=0,i=t.length-2;n<i;n+=e)for(let i=t.length-2*e;i>n+e;i-=e){const r=t[n],o=t[n+1],s=t[n+e],a=t[n+e+1],l=t[i],h=t[i+1],c=t[i+e],u=t[i+e+1],d=(u-h)*(s-r)-(c-l)*(a-o);if(0===d)continue;const f=((c-l)*(o-h)-(u-h)*(r-l))/d,g=((s-r)*(o-h)-(a-o)*(r-l))/d;if(f>0&&f<1&&g>0&&g<1){const l=r+f*(s-r),h=o+f*(a-o);t[n+e]=l,t[n+e+1]=h,t.splice(n+2*e,i-n-e);break}}return t}function fi(t,e,n,i,r,o,s,a,l,h,c,u,d=!0){let f=t[e],g=t[e+1],p=0,m=0,y=0,_=0;function v(){p=f,m=g,f=t[e+=i],g=t[e+1],_+=y,y=Math.sqrt((f-p)*(f-p)+(g-m)*(g-m))}do{v()}while(e<n-i&&_+y<o);let x=0===y?0:(o-_)/y;const S=B(p,f,x),w=B(m,g,x),C=e-i,b=_,I=o+a*l(h,r,c);for(;e<n-i&&_+y<I;)v();x=0===y?0:(I-_)/y;const E=B(p,f,x),P=B(m,g,x);let T=!1;if(d)if(u){const t=[S,w,E,P];ii(t,0,4,2,u,t,t),T=t[0]>t[2]}else T=S>E;const M=Math.PI,k=[],R=C+i===e;let F;if(y=0,_=b,f=t[e=C],g=t[e+1],R){v(),F=Math.atan2(g-m,f-p),T&&(F+=F>0?-M:M);const t=(E+S)/2,e=(P+w)/2;return k[0]=[t,e,(I-o)/2,F,r],k}for(let t=0,u=(r=r.replace(/\n/g," ")).length;t<u;){v();let d=Math.atan2(g-m,f-p);if(T&&(d+=d>0?-M:M),void 0!==F){let t=d-F;if(t+=t>M?-2*M:t<-M?2*M:0,Math.abs(t)>s)return null}F=d;const S=t;let w=0;for(;t<u;++t){const s=a*l(h,r[T?u-t-1:t],c);if(e+i<n&&_+y<o+w+s/2)break;w+=s}if(t===S)continue;const C=T?r.substring(u-S,u-t):r.substring(S,t);x=0===y?0:(o+w/2-_)/y;const b=B(p,f,x),I=B(m,g,x);k.push([b,I,w/2,d,C]),o+=w}return k}const gi=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(tt(),{get:(t,e)=>{if("function"==typeof tt()[e])return this.push_(e),this.pushMethodArgs_},set:(t,e,n)=>(this.push_(e,n),!0)})}push_(...t){const e=this.instructions_,n=this.zIndex+this.offset_;e[n]||(e[n]=[]),e[n].push(...t)}pushMethodArgs_=(...t)=>(this.push_(t),this);pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let n=0,i=e.length;n<i;++n){const i=e[n];if("function"==typeof i){i(t);continue}const r=e[++n];if("function"==typeof t[i])t[i](...r);else{if("function"==typeof r){t[i]=r(t);continue}t[i]=r}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},pi=[1/0,1/0,-1/0,-1/0],mi=[],yi=[],_i=[],vi=[];function xi(t){return t[3].declutterBox}const Si=new RegExp("["+String.fromCharCode(1425)+"-"+String.fromCharCode(2303)+String.fromCharCode(64285)+"-"+String.fromCharCode(65023)+String.fromCharCode(65136)+"-"+String.fromCharCode(65276)+String.fromCharCode(67584)+"-"+String.fromCharCode(69631)+String.fromCharCode(124928)+"-"+String.fromCharCode(126975)+"]");function wi(t,e){return"start"===e?e=Si.test(t)?"right":"left":"end"===e&&(e=Si.test(t)?"left":"right"),Qn[e]}function Ci(t,e,n){return n>0&&t.push("\n",""),t.push(e,""),t}function bi(t,e,n){return n%2==0&&(t+=e),t}const Ii=class{constructor(t,e,n,i,r){this.overlaps=n,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=i.instructions,this.coordinates=i.coordinates,this.coordinateCache_={},this.renderedTransform_=[1,0,0,1,0,0],this.hitDetectionInstructions=i.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=i.fillStates||{},this.strokeStates=i.strokeStates||{},this.textStates=i.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new gi:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,n,i){const r=t+e+n+i;if(this.labels_[r])return this.labels_[r];const o=i?this.strokeStates[i]:null,s=n?this.fillStates[n]:null,a=this.textStates[e],l=this.pixelRatio,h=[a.scale[0]*l,a.scale[1]*l],c=a.justify?Qn[a.justify]:wi(Array.isArray(t)?t[0]:t,a.textAlign||bn),u=i&&o.lineWidth?o.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(Ci,[]),{width:f,height:g,widths:p,heights:m,lineWidths:y}=function(t,e){const n=[],i=[],r=[];let o=0,s=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){const u=e[h];if("\n"===u||h===c){o=Math.max(o,s),r.push(s),s=0,a+=l,l=0;continue}const d=e[h+1]||t.font,f=Dn(d,u);n.push(f),s+=f;const g=An(d);i.push(g),l=Math.max(l,g)}return{width:o,height:a,widths:n,heights:i,lineWidths:r}}(a,d),_=f+u,v=[],x=(_+2)*h[0],S=(g+u)*h[1],w={width:x<0?Math.floor(x):Math.ceil(x),height:S<0?Math.floor(S):Math.ceil(S),contextInstructions:v};1==h[0]&&1==h[1]||v.push("scale",h),i&&(v.push("strokeStyle",o.strokeStyle),v.push("lineWidth",u),v.push("lineCap",o.lineCap),v.push("lineJoin",o.lineJoin),v.push("miterLimit",o.miterLimit),v.push("setLineDash",[o.lineDash]),v.push("lineDashOffset",o.lineDashOffset)),n&&v.push("fillStyle",s.fillStyle),v.push("textBaseline","middle"),v.push("textAlign","center");const C=.5-c;let b=c*_+C*u;const I=[],E=[];let P,T=0,M=0,k=0,R=0;for(let t=0,e=d.length;t<e;t+=2){const e=d[t];if("\n"===e){M+=T,T=0,b=c*_+C*u,++R;continue}const r=d[t+1]||a.font;r!==P&&(i&&I.push("font",r),n&&E.push("font",r),P=r),T=Math.max(T,m[k]);const o=[e,b+C*p[k]+c*(p[k]-y[R]),.5*(u+T)+M];b+=p[k],i&&I.push("strokeText",o),n&&E.push("fillText",o),++k}return Array.prototype.push.apply(v,I),Array.prototype.push.apply(v,E),this.labels_[r]=w,w}replayTextBackground_(t,e,n,i,r,o,s){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,n),t.lineTo.apply(t,i),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),s&&(this.setStrokeStyle_(t,s),t.stroke())}calculateImageOrLabelDimensions_(t,e,n,i,r,o,s,a,l,h,c,u,d,f,g,p){let y=n-(s*=u[0]),_=i-(a*=u[1]);const v=r+l>t?t-l:r,x=o+h>e?e-h:o,S=f[3]+v*u[0]+f[1],w=f[0]+x*u[1]+f[2],C=y-f[3],b=_-f[0];let I;return(g||0!==c)&&(mi[0]=C,vi[0]=C,mi[1]=b,yi[1]=b,yi[0]=C+S,_i[0]=yi[0],_i[1]=b+w,vi[1]=_i[1]),0!==c?(I=si([1,0,0,1,0,0],n,i,1,1,c,-n,-i),oi(I,mi),oi(I,yi),oi(I,_i),oi(I,vi),m(Math.min(mi[0],yi[0],_i[0],vi[0]),Math.min(mi[1],yi[1],_i[1],vi[1]),Math.max(mi[0],yi[0],_i[0],vi[0]),Math.max(mi[1],yi[1],_i[1],vi[1]),pi)):m(Math.min(C,C+S),Math.min(b,b+w),Math.max(C,C+S),Math.max(b,b+w),pi),d&&(y=Math.round(y),_=Math.round(_)),{drawImageX:y,drawImageY:_,drawImageW:v,drawImageH:x,originX:l,originY:h,declutterBox:{minX:pi[0],minY:pi[1],maxX:pi[2],maxY:pi[3],value:p},canvasTransform:I,scale:u}}replayImageOrLabel_(t,e,n,i,r,o,s){const a=!(!o&&!s),l=i.declutterBox,h=s?s[2]*i.scale[0]/2:0;return l.minX-h<=e[0]&&l.maxX+h>=0&&l.minY-h<=e[1]&&l.maxY+h>=0&&(a&&this.replayTextBackground_(t,mi,yi,_i,vi,o,s),function(t,e,n,i,r,o,s,a,l,h,c){t.save(),1!==n&&(void 0===t.globalAlpha?t.globalAlpha=t=>t.globalAlpha*=n:t.globalAlpha*=n),e&&t.transform.apply(t,e),i.contextInstructions?(t.translate(l,h),t.scale(c[0],c[1]),function(t,e){const n=t.contextInstructions;for(let t=0,i=n.length;t<i;t+=2)Array.isArray(n[t+1])?e[n[t]].apply(e,n[t+1]):e[n[t]]=n[t+1]}(i,t)):c[0]<0||c[1]<0?(t.translate(l,h),t.scale(c[0],c[1]),t.drawImage(i,r,o,s,a,0,0,s,a)):t.drawImage(i,r,o,s,a,l,h,s*c[0],a*c[1]),t.restore()}(t,i.canvasTransform,r,n,i.originX,i.originY,i.drawImageW,i.drawImageH,i.drawImageX,i.drawImageY,i.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const n=oi(this.renderedTransform_,[0,0]),i=512*this.pixelRatio;t.save(),t.translate(n[0]%i,n[1]%i),1!==e&&t.scale(e,e)}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,n,i){const r=this.textStates[e],o=this.createLabel(t,e,i,n),s=this.strokeStates[n],a=this.pixelRatio,l=wi(Array.isArray(t)?t[0]:t,r.textAlign||bn),h=Qn[r.textBaseline||In],c=s&&s.lineWidth?s.lineWidth:0;return{label:o,anchorX:l*(o.width/a-2*r.scale[0])+2*(.5-l)*c,anchorY:h*o.height/a+2*(.5-h)*c}}execute_(t,e,n,i,r,o,s,a){const h=this.zIndexContext_;let c;var u,d;this.pixelCoordinates_&&l(n,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=ni(this.coordinates,0,this.coordinates.length,2,n,this.pixelCoordinates_),d=n,(u=this.renderedTransform_)[0]=d[0],u[1]=d[1],u[2]=d[2],u[3]=d[3],u[4]=d[4],u[5]=d[5]);let f=0;const g=i.length;let p,m=0;const y=[];let _,v,x,S,w,C,b,I,E,P,T,M,k,R=0,F=0;const A=this.coordinateCache_,L=this.viewRotation_,D=Math.round(1e12*Math.atan2(-n[1],n[0]))/1e12,G={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:L},j=this.instructions!=i||this.overlaps?0:200;let V,N,W,B;for(;f<g;){const n=i[f];switch(n[0]){case Xn.BEGIN_GEOMETRY:V=n[1],B=n[3],V.getGeometry()?void 0===s||O(s,B.getExtent())?++f:f=n[2]+1:f=n[2],h&&(h.zIndex=n[4]);break;case Xn.BEGIN_PATH:R>j&&(this.fill_(t),R=0),F>j&&(t.stroke(),F=0),R||F||(t.beginPath(),w=NaN,C=NaN),++f;break;case Xn.CIRCLE:m=n[1],x=n[2]??0;const i=c[m],l=c[m+1],u=c[m+2]-x-i,d=c[m+3]-x-l,g=Math.sqrt(u*u+d*d);t.moveTo(i+g,l),t.arc(i,l,g,0,2*Math.PI,!0),++f;break;case Xn.CLOSE_PATH:t.closePath(),++f;break;case Xn.CUSTOM:m=n[1],p=n[2];const X=n[3],Y=n[4],z=n[5];G.geometry=X,G.feature=V,f in A||(A[f]=[]);const U=A[f];z?z(c,m,p,2,U):(U[0]=c[m],U[1]=c[m+1],U.length=2),h&&(h.zIndex=n[6]),Y(U,G),++f;break;case Xn.DRAW_IMAGE:m=n[1],p=n[2],E=n[3],_=n[4],v=n[5];let H=n[6];const q=n[7],$=n[8],Z=n[9],K=n[10];let J=n[11];const Q=n[12];let tt=n[13];S=n[14]||"declutter";const et=n[15];if(!E&&n.length>=20){P=n[19],T=n[20],M=n[21],k=n[22];const t=this.drawLabelWithPointPlacement_(P,T,M,k);E=t.label,n[3]=E;const e=n[23];_=(t.anchorX-e)*this.pixelRatio,n[4]=_;const i=n[24];v=(t.anchorY-i)*this.pixelRatio,n[5]=v,H=E.height,n[6]=H,tt=E.width,n[13]=tt}let nt,it,rt,ot;n.length>25&&(nt=n[25]),n.length>17?(it=n[16],rt=n[17],ot=n[18]):(it=En,rt=null,ot=null),K&&D?J+=L:K||D||(J-=L);let st=0;for(;m<p;m+=2){if(nt&&nt[st++]<tt/this.pixelRatio)continue;const n=this.calculateImageOrLabelDimensions_(E.width,E.height,c[m],c[m+1],tt,H,_,v,$,Z,J,Q,r,it,!!rt||!!ot,V),i=[t,e,E,n,q,rt,ot];if(a){let t,e,r,o,s;if(et){const n=p-m;if(!et[n]){et[n]={args:i,declutterMode:S};continue}const o=et[n];t=o.args,e=o.declutterMode,delete et[n],r=xi(t)}if(!t||"declutter"===e&&a.collides(r)||(o=!0),"declutter"===S&&a.collides(n.declutterBox)||(s=!0),"declutter"===e&&"declutter"===S){const t=o&&s;o=t,s=t}o&&("none"!==e&&a.insert(r),this.replayImageOrLabel_.apply(this,t)),s&&("none"!==S&&a.insert(n.declutterBox),this.replayImageOrLabel_.apply(this,i))}else this.replayImageOrLabel_.apply(this,i)}++f;break;case Xn.DRAW_CHARS:const at=n[1],lt=n[2],ht=n[3],ct=n[4];k=n[5];const ut=n[6],dt=n[7],ft=n[8];M=n[9];const gt=n[10];P=n[11],Array.isArray(P)&&(P=P.reduce(bi,"")),T=n[12];const pt=[n[13],n[13]];S=n[14]||"declutter";const mt=n[15],yt=this.textStates[T],_t=yt.font,vt=[yt.scale[0]*dt,yt.scale[1]*dt];let xt;_t in this.widths_?xt=this.widths_[_t]:(xt={},this.widths_[_t]=xt);const St=hi(c,at,lt,2),wt=Math.abs(vt[0])*Gn(_t,P,xt);if(ct||wt<=St){const n=fi(c,at,lt,2,P,(St-wt)*wi(P,this.textStates[T].textAlign),ut,Math.abs(vt[0]),Gn,_t,xt,D?0:this.viewRotation_,mt);t:if(n){const i=[];let r,o,s,l,h;if(M)for(r=0,o=n.length;r<o;++r){h=n[r],s=h[4],l=this.createLabel(s,T,"",M),_=h[2]+(vt[0]<0?-gt:gt),v=ht*l.height+2*(.5-ht)*gt*vt[1]/vt[0]-ft;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,_,v,0,0,h[3],pt,!1,En,!1,V);if(a&&"declutter"===S&&a.collides(o.declutterBox))break t;i.push([t,e,l,o,1,null,null])}if(k)for(r=0,o=n.length;r<o;++r){h=n[r],s=h[4],l=this.createLabel(s,T,k,""),_=h[2],v=ht*l.height-ft;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,_,v,0,0,h[3],pt,!1,En,!1,V);if(a&&"declutter"===S&&a.collides(o.declutterBox))break t;i.push([t,e,l,o,1,null,null])}a&&"none"!==S&&a.load(i.map(xi));for(let t=0,e=i.length;t<e;++t)this.replayImageOrLabel_.apply(this,i[t])}}++f;break;case Xn.END_GEOMETRY:if(void 0!==o){V=n[1];const t=o(V,B,S);if(t)return t}++f;break;case Xn.FILL:j?R++:this.fill_(t),++f;break;case Xn.MOVE_TO_LINE_TO:let Ct,bt,It;m=n[1],p=n[2],x=n[3],x?(ci(c,m,p,2,x,n[4]??!1,y),di(y,2),Ct=y,bt=0,It=Ct.length):(Ct=c,bt=m,It=p),N=Ct[bt],W=Ct[bt+1],t.moveTo(N,W),w=N+.5|0,C=W+.5|0;for(let e=bt+2;e<It;e+=2)N=Ct[e],W=Ct[e+1],b=N+.5|0,I=W+.5|0,e!=It-2&&b===w&&I===C||(t.lineTo(N,W),w=b,C=I);++f;break;case Xn.SET_FILL_STYLE:this.alignAndScaleFill_=n[2],R?(this.fill_(t),R=0,F&&(t.stroke(),F=0)):F&&n[1]&&(t.stroke(),F=0),t.fillStyle=n[1],++f;break;case Xn.SET_STROKE_STYLE:R&&n[1]&&(this.fill_(t),R=0),F&&(t.stroke(),F=0),this.setStrokeStyle_(t,n),++f;break;case Xn.STROKE:j?F++:t.stroke(),++f;break;default:++f}}R&&this.fill_(t),F&&t.stroke()}execute(t,e,n,i,r,o){this.viewRotation_=i,this.execute_(t,e,n,this.instructions,r,void 0,void 0,o)}executeHitDetection(t,e,n,i,r){return this.viewRotation_=n,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,i,r)}},Ei=["Polygon","Circle","LineString","Image","Text","Default"],Pi=["Image","Text"],Ti=Ei.filter(t=>!Pi.includes(t));let Mi=!1,ki=!1;const Ri={},Fi=class{constructor(t,e,n,i,r,o,s){this.maxExtent_=t,this.overlaps_=i,this.pixelRatio_=n,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=[1,0,0,1,0,0],this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,s)}clip(t,e){const n=this.getClipCoords(e);t.beginPath(),t.moveTo(n[0],n[1]),t.lineTo(n[2],n[3]),t.lineTo(n[4],n[5]),t.lineTo(n[6],n[7]),t.clip()}createExecutors_(t,e){for(const n in t){let i=this.executorsByZIndex_[n];void 0===i&&(i={},this.executorsByZIndex_[n]=i);const r=t[n];for(const t in r){const n=r[t];i[t]=new Ii(this.resolution_,this.pixelRatio_,this.overlaps_,n,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const n=this.executorsByZIndex_[e];for(let e=0,i=t.length;e<i;++e)if(t[e]in n)return!0}return!1}forEachFeatureAtCoordinate(t,e,n,r,o,s){!1===ki&&function(){let t=0;const e=e=>{const n=J(1,1,null,{willReadFrequently:e});let i=0;const r=performance.now();for(;performance.now()-r<50;++i)n.fillStyle=`rgba(255,0,${i%256},1)`,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1);return t=i>t?i:t,i},n={[e(!0)]:!0,[e(!1)]:!1,[e(void 0)]:void 0};Mi=n[t],ki=!0}();const a=2*(r=Math.round(r))+1,l=si(this.hitDetectionTransform_,r+.5,r+.5,1/e,-1/e,-n,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=J(a,a,null,{willReadFrequently:Mi}));const u=this.hitDetectionContext_;let d;u.canvas.width!==a||u.canvas.height!==a?(u.canvas.width=a,u.canvas.height=a):h||u.clearRect(0,0,a,a),void 0!==this.renderBuffer_&&(d=[1/0,1/0,-1/0,-1/0],w(d,t),c(d,e*(this.renderBuffer_+r),d));const f=function(t){if(void 0!==Ri[t])return Ri[t];const e=2*t+1,n=t*t,i=new Array(n+1);for(let r=0;r<=t;++r)for(let o=0;o<=t;++o){const s=r*r+o*o;if(s>n)break;let a=i[s];a||(a=[],i[s]=a),a.push(4*((t+r)*e+(t+o))+3),r>0&&a.push(4*((t-r)*e+(t+o))+3),o>0&&(a.push(4*((t+r)*e+(t-o))+3),r>0&&a.push(4*((t-r)*e+(t-o))+3))}const r=[];for(let t=0,e=i.length;t<e;++t)i[t]&&r.push(...i[t]);return Ri[t]=r,r}(r);let g;function p(t,e,n){const i=u.getImageData(0,0,a,a).data;for(let l=0,h=f.length;l<h;l++)if(i[f[l]]>0){if(!s||"none"===n||"Image"!==g&&"Text"!==g||s.includes(t)){const n=(f[l]-3)/4,i=r-n%a,s=r-(n/a|0),h=o(t,e,i*i+s*s);if(h)return h}u.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);let y,_,v,x,S;for(m.sort(i),y=m.length-1;y>=0;--y){const t=m[y].toString();for(v=this.executorsByZIndex_[t],_=Ei.length-1;_>=0;--_)if(g=Ei[_],x=v[g],void 0!==x&&(S=x.executeHitDetection(u,l,n,p,d),S))return S}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const n=e[0],i=e[1],r=e[2],o=e[3],s=[n,i,n,o,r,o,r,i];return ni(s,0,8,2,t,s),s}isEmpty(){return Be(this.executorsByZIndex_)}execute(t,e,n,o,s,a,l){const h=Object.keys(this.executorsByZIndex_).map(Number);h.sort(l?r:i),a=a||Ei;const c=Ei.length;for(let i=0,r=h.length;i<r;++i){const r=h[i].toString(),u=this.executorsByZIndex_[r];for(let r=0,d=a.length;r<d;++r){const d=a[r],f=u[d];if(void 0!==f){const r=null===l?void 0:f.getZIndexContext(),a=r?r.getContext():t,u=this.maxExtent_&&"Image"!==d&&"Text"!==d;if(u&&(a.save(),this.clip(a,n)),r&&"Text"!==d&&"Image"!==d?r.pushFunction(t=>f.execute(t,e,n,o,s,l)):f.execute(a,e,n,o,s,l),u&&a.restore(),r){r.offset();const t=h[i]*c+Ei.indexOf(d);this.deferredZIndexContexts_[t]||(this.deferredZIndexContexts_[t]=[]),this.deferredZIndexContexts_[t].push(r)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(i);for(let n=0,i=e.length;n<i;++n)t[e[n]].forEach(t=>{t.draw(this.renderedContext_),t.clear()}),t[e[n]].length=0}};function Oi(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}class Ai{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=Oi(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Ai({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 hn()}getImage(t){return hn()}getHitDetectionImage(){return hn()}getPixelRatio(t){return 1}getImageState(){return hn()}getImageSize(){return hn()}getOrigin(){return hn()}getSize(){return hn()}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_=Oi(t)}listenImageChange(t){hn()}load(){hn()}unlistenImageChange(t){hn()}ready(){return Promise.resolve()}}const Li=Ai;function Di(t,e,n,i){return void 0!==n&&void 0!==i?[n/t,i/e]:void 0!==n?n/t:void 0!==i?i/e:1}class Gi extends Li{constructor(t){const e=void 0!==(t=t||{}).opacity?t.opacity:1,n=void 0!==t.rotation?t.rotation:0,i=void 0!==t.scale?t.scale:1,r=void 0!==t.rotateWithView&&t.rotateWithView;super({opacity:e,rotation:n,scale:i,displacement:void 0!==t.displacement?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=void 0!==t.anchor?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=void 0!==t.anchorOrigin?t.anchorOrigin:"top-left",this.anchorXUnits_=void 0!==t.anchorXUnits?t.anchorXUnits:"fraction",this.anchorYUnits_=void 0!==t.anchorYUnits?t.anchorYUnits:"fraction",this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy;const o=void 0!==t.img?t.img:null;let s,a=t.src;if(ri(!(void 0!==a&&o),"`image` and `src` cannot be provided at the same time"),void 0!==a&&0!==a.length||!o||(a=o.src||un(o)),ri(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),ri(!((void 0!==t.width||void 0!==t.height)&&void 0!==t.scale),"`width` or `height` cannot be provided together with `scale`"),void 0!==t.src?s=0:void 0!==o&&(s="complete"in o?o.complete?o.src?2:0:1:2),this.color_=void 0!==t.color?Oe(t.color):null,this.iconImage_=$e(o,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},s,this.color_),this.offset_=void 0!==t.offset?t.offset:[0,0],this.offsetOrigin_=void 0!==t.offsetOrigin?t.offsetOrigin:"top-left",this.origin_=null,this.size_=void 0!==t.size?t.size:null,this.initialOptions_,void 0!==t.width||void 0!==t.height){let e,n;if(t.size)[e,n]=t.size;else{const i=this.getImage(1);if(i.width&&i.height)e=i.width,n=i.height;else if(i instanceof HTMLImageElement){this.initialOptions_=t;const e=()=>{if(this.unlistenImageChange(e),!this.initialOptions_)return;const n=this.iconImage_.getSize();this.setScale(Di(n[0],n[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale(Di(e,n,t.width,t.height))}}clone(){let t,e,n;return this.initialOptions_?(e=this.initialOptions_.width,n=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new Gi({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_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:n,size:null!==this.size_?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const e=this.getSize();if("fraction"==this.anchorXUnits_||"fraction"==this.anchorYUnits_){if(!e)return null;t=this.anchor_.slice(),"fraction"==this.anchorXUnits_&&(t[0]*=e[0]),"fraction"==this.anchorYUnits_&&(t[1]*=e[1])}if("top-left"!=this.anchorOrigin_){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),"top-right"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[0]=-t[0]+e[0]),"bottom-left"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[1]=-t[1]+e[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),n=this.getScaleArray();return[t[0]-e[0]/n[0],t[1]+e[1]/n[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){const e=t?Oe(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((t,n)=>t===e[n]))return;this.color_=e;const n=this.getSrc(),i=void 0!==n?null:this.getHitDetectionImage(),r=void 0!==n?0:this.iconImage_.getImageState();this.iconImage_=$e(i,n,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},r,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if("top-left"!=this.offsetOrigin_){const e=this.getSize(),n=this.iconImage_.getSize();if(!e||!n)return null;t=t.slice(),"top-right"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[0]=n[0]-e[0]-t[0]),"bottom-left"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[1]=n[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=$e(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},0,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();return this.size_?this.size_[0]*t[0]:2==this.iconImage_.getImageState()?this.iconImage_.getSize()[0]*t[0]:void 0}getHeight(){const t=this.getScaleArray();return this.size_?this.size_[1]*t[1]:2==this.iconImage_.getImageState()?this.iconImage_.getSize()[1]*t[1]:void 0}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(Le,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(Le,t)}ready(){return this.iconImage_.ready()}}const ji=Gi,Vi=[1,0,0,1,0,0],Ni=[NaN,NaN],Wi=class extends fn{constructor(){super(),this.extent_=[1/0,1/0,-1/0,-1/0],this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Ne((t,e,n)=>{if(!n)return this.getSimplifiedGeometry(e);const i=this.clone();return i.applyTransform(n),i.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return hn()}closestPointXY(t,e,n,i){return hn()}containsXY(t,e){return 0===this.closestPointXY(t,e,Ni,Number.MIN_VALUE)}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 hn()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&y(t),this.extentRevision_=this.getRevision()}return function(t,e){return e?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):t}(this.extent_,t)}rotate(t,e){hn()}scale(t,e,n){hn()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return hn()}getType(){return hn()}applyTransform(t){hn()}intersectsExtent(t){return hn()}translate(t,e){hn()}transform(t,e){const n=Zt(t),i="tile-pixels"==n.getUnits()?function(t,i,r){const o=n.getExtent(),s=n.getWorldExtent(),a=M(s)/M(o);si(Vi,s[0],s[3],a,-a,0,0,0);const l=ni(t,0,t.length,r,Vi,i),h=ee(n,e);return h?h(l,l,r):l}:ee(n,e);return this.applyTransform(i),this}};function Bi(t){let e;return 2==t?e="XY":3==t?e="XYZ":4==t&&(e="XYZM"),e}function Xi(t){let e;return"XY"==t?e=2:"XYZ"==t||"XYM"==t?e=3:"XYZM"==t&&(e=4),e}const Yi=class extends Wi{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return v(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return hn()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=Xi(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){hn()}setLayout(t,e,n){let i;if(t)i=Xi(t);else{for(let t=0;t<n;++t){if(0===e.length)return this.layout="XY",void(this.stride=2);e=e[0]}i=e.length,t=Bi(i)}this.layout=t,this.stride=i}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const n=this.getFlatCoordinates();if(n){const i=this.getStride();ii(n,0,n.length,i,t,e,n),this.changed()}}scale(t,e,n){void 0===e&&(e=t),n||(n=T(this.getExtent()));const i=this.getFlatCoordinates();if(i){const r=this.getStride();!function(t,e,n,i,r,o,s,a){a=a||[];const l=s[0],h=s[1];let c=0;for(let e=0;e<n;e+=i){const n=t[e]-l,s=t[e+1]-h;a[c++]=l+r*n,a[c++]=h+o*s;for(let n=e+2;n<e+i;++n)a[c++]=t[n]}a&&a.length!=c&&(a.length=c)}(i,0,i.length,r,t,e,n,i),this.changed()}}translate(t,e){const n=this.getFlatCoordinates();if(n){const i=this.getStride();!function(t,e,n,i,r,o,s){s=s||[];let a=0;for(let e=0;e<n;e+=i){s[a++]=t[e]+r,s[a++]=t[e+1]+o;for(let n=e+2;n<e+i;++n)s[a++]=t[n]}s&&s.length!=a&&(s.length=a)}(n,0,n.length,i,t,e,n),this.changed()}}},zi=class extends en{constructor(t,e,n,i,r,o,s){super(),this.context_=t,this.pixelRatio_=e,this.extent_=n,this.transform_=i,this.transformRotation_=i?X(Math.atan2(i[1],i[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=s,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=[1,0,0,1,0,0]}drawImages_(t,e,n,i){if(!this.image_)return;const r=ni(t,e,n,i,this.transform_,this.pixelCoordinates_),o=this.context_,s=this.tmpLocalTransform_,a=o.globalAlpha;1!=this.imageOpacity_&&(o.globalAlpha=a*this.imageOpacity_);let l=this.imageRotation_;0===this.transformRotation_&&(l-=this.viewRotation_),this.imageRotateWithView_&&(l+=this.viewRotation_);for(let t=0,e=r.length;t<e;t+=2){const e=r[t]-this.imageAnchorX_,n=r[t+1]-this.imageAnchorY_;if(0!==l||1!=this.imageScale_[0]||1!=this.imageScale_[1]){const t=e+this.imageAnchorX_,i=n+this.imageAnchorY_;si(s,t,i,1,1,l,-t,-i),o.save(),o.transform.apply(o,s),o.translate(t,i),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_,e,n,this.imageWidth_,this.imageHeight_)}1!=this.imageOpacity_&&(o.globalAlpha=a)}drawText_(t,e,n,i){if(!this.textState_||""===this.text_)return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=ni(t,e,n,i,this.transform_,this.pixelCoordinates_),o=this.context_;let s=this.textRotation_;for(0===this.transformRotation_&&(s-=this.viewRotation_),this.textRotateWithView_&&(s+=this.viewRotation_);e<n;e+=i){const t=r[e]+this.textOffsetX_,n=r[e+1]+this.textOffsetY_;0!==s||1!=this.textScale_[0]||1!=this.textScale_[1]?(o.save(),o.translate(t-this.textOffsetX_,n-this.textOffsetY_),o.rotate(s),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_,t,n),this.textFillState_&&o.fillText(this.text_,t,n))}}moveToLineTo_(t,e,n,i,r,o){const s=this.context_;let a=ni(t,e,n,i,this.transform_,this.pixelCoordinates_);Math.abs(o)>0&&(a=ci(a,0,a.length,2,o,r,a),di(a,2)),s.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let t=2;t<l;t+=2)s.lineTo(a[t],a[t+1]);return r&&s.closePath(),n}drawRings_(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o)e=this.moveToLineTo_(t,e,n[o],i,!0,r);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),O(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=function(t,e,n){const i=t.getFlatCoordinates();if(!i)return null;const r=t.getStride();return ni(i,0,i.length,r,e,n)}(t,this.transform_,this.pixelCoordinates_),n=e[2]-e[0],i=e[3]-e[1],r=Math.sqrt(n*n+i*i),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)}}drawFeature(t,e){const n=e.getGeometryFunction()(t);n&&(this.setStyle(e),this.drawGeometry(n))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let t=0,n=e.length;t<n;++t)this.drawGeometry(e[t])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),n=t.getStride();this.image_&&this.drawImages_(e,0,e.length,n),""!==this.text_&&this.drawText_(e,0,e.length,n)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),n=t.getStride();this.image_&&this.drawImages_(e,0,e.length,n),""!==this.text_&&this.drawText_(e,0,e.length,n)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),O(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,n=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(n,0,n.length,t.getStride(),!1,this.strokeState_.strokeOffset),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(O(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,n=t.getFlatCoordinates();let i=0;const r=t.getEnds(),o=t.getStride();e.beginPath();for(let t=0,e=r.length;t<e;++t)i=this.moveToLineTo_(n,i,r[t],o,!1,this.strokeState_.strokeOffset);e.stroke()}if(""!==this.text_){const e=t.getFlatMidpoints();this.drawText_(e,0,e.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),O(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.strokeState_?.strokeOffset),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_)),O(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_,n=t.getOrientedFlatCoordinates();let i=0;const r=t.getEndss(),o=t.getStride();e.beginPath();for(let t=0,e=r.length;t<e;++t){const e=r[t];i=this.drawRings_(n,i,e,o,this.strokeState_?.strokeOffset)}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_,n=this.contextFillState_;n?n.fillStyle!=t.fillStyle&&(n.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,n=this.contextStrokeState_;n?(n.lineCap!=t.lineCap&&(n.lineCap=t.lineCap,e.lineCap=t.lineCap),l(n.lineDash,t.lineDash)||e.setLineDash(n.lineDash=t.lineDash),n.lineDashOffset!=t.lineDashOffset&&(n.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),n.lineJoin!=t.lineJoin&&(n.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),n.lineWidth!=t.lineWidth&&(n.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),n.miterLimit!=t.miterLimit&&(n.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),n.strokeStyle!=t.strokeStyle&&(n.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_,n=this.contextTextState_,i=t.textAlign?t.textAlign:bn;n?(n.font!=t.font&&(n.font=t.font,e.font=t.font),n.textAlign!=i&&(n.textAlign=i,e.textAlign=i),n.textBaseline!=t.textBaseline&&(n.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=i,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:i,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(t){const e=t.getColor();this.fillState_={fillStyle:Ke(e||vn)}}else this.fillState_=null;if(e){const t=e.getColor(),n=e.getLineCap(),i=e.getLineDash(),r=e.getLineDashOffset(),o=e.getLineJoin(),s=e.getWidth(),a=e.getMiterLimit(),l=i||Sn,h=e.getOffset();this.strokeState_={lineCap:void 0!==n?n:xn,lineDash:1===this.pixelRatio_?l:l.map(t=>t*this.pixelRatio_),lineDashOffset:(r||0)*this.pixelRatio_,lineJoin:void 0!==o?o:wn,lineWidth:(void 0!==s?s:1)*this.pixelRatio_,miterLimit:void 0!==a?a:10,strokeStyle:Ke(t||Cn),strokeOffset:(h??0)*this.pixelRatio_}}else this.strokeState_=null}setImageStyle(t){let e;if(!t||!(e=t.getSize()))return void(this.image_=null);const n=t.getPixelRatio(this.pixelRatio_),i=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=i[0]*n,this.imageAnchorY_=i[1]*n,this.imageHeight_=e[1]*n,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_/n,o[1]*this.pixelRatio_/n],this.imageWidth_=e[0]*n}setTextStyle(t){if(t){const e=t.getFill();if(e){const t=e.getColor();this.textFillState_={fillStyle:Ke(t||vn)}}else this.textFillState_=null;const n=t.getStroke();if(n){const t=n.getColor(),e=n.getLineCap(),i=n.getLineDash(),r=n.getLineDashOffset(),o=n.getLineJoin(),s=n.getWidth(),a=n.getMiterLimit();this.textStrokeState_={lineCap:void 0!==e?e:xn,lineDash:i||Sn,lineDashOffset:r||0,lineJoin:void 0!==o?o:wn,lineWidth:void 0!==s?s:1,miterLimit:void 0!==a?a:10,strokeStyle:Ke(t||Cn)}}else this.textStrokeState_=null;const i=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),s=t.getRotateWithView(),a=t.getRotation(),l=t.getScaleArray(),h=t.getText(),c=t.getTextAlign(),u=t.getTextBaseline();this.textState_={font:void 0!==i?i:_n,textAlign:void 0!==c?c:bn,textBaseline:void 0!==u?u:In},this.text_=void 0!==h?Array.isArray(h)?h.reduce((t,e,n)=>t+(n%2?" ":e),""):h:"",this.textOffsetX_=void 0!==r?this.pixelRatio_*r:0,this.textOffsetY_=void 0!==o?this.pixelRatio_*o:0,this.textRotateWithView_=void 0!==s&&s,this.textRotation_=void 0!==a?a:0,this.textScale_=[this.pixelRatio_*l[0],this.pixelRatio_*l[1]]}else this.text_=""}},Ui=.5,Hi={Point:function(t,e,n,i,r,o){const s=n.getImage(),a=n.getText(),l=a&&a.getText(),h=o&&s&&l?{}:void 0;if(s){if(2!=s.getImageState())return;const o=t.getBuilder(n.getZIndex(),"Image");o.setImageStyle(s,h),o.drawPoint(e,i,r)}if(l){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(a,h),o.drawText(e,i,r)}},LineString:function(t,e,n,i,r){const o=n.getStroke();if(o){const s=t.getBuilder(n.getZIndex(),"LineString");s.setFillStrokeStyle(null,o),s.drawLineString(e,i,r)}const s=n.getText();if(s&&s.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(s),o.drawText(e,i,r)}},Polygon:function(t,e,n,i,r){const o=n.getFill(),s=n.getStroke();if(o||s){const a=t.getBuilder(n.getZIndex(),"Polygon");a.setFillStrokeStyle(o,s),a.drawPolygon(e,i,r)}const a=n.getText();if(a&&a.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(a),o.drawText(e,i,r)}},MultiPoint:function(t,e,n,i,r,o){const s=n.getImage(),a=s&&0!==s.getOpacity(),l=n.getText(),h=l&&l.getText(),c=o&&a&&h?{}:void 0;if(a){if(2!=s.getImageState())return;const o=t.getBuilder(n.getZIndex(),"Image");o.setImageStyle(s,c),o.drawMultiPoint(e,i,r)}if(h){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(l,c),o.drawText(e,i,r)}},MultiLineString:function(t,e,n,i,r){const o=n.getStroke();if(o){const s=t.getBuilder(n.getZIndex(),"LineString");s.setFillStrokeStyle(null,o),s.drawMultiLineString(e,i,r)}const s=n.getText();if(s&&s.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(s),o.drawText(e,i,r)}},MultiPolygon:function(t,e,n,i,r){const o=n.getFill(),s=n.getStroke();if(s||o){const a=t.getBuilder(n.getZIndex(),"Polygon");a.setFillStrokeStyle(o,s),a.drawMultiPolygon(e,i,r)}const a=n.getText();if(a&&a.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(a),o.drawText(e,i,r)}},GeometryCollection:function(t,e,n,i,r,o){const s=e.getGeometriesArray();let a,l;for(a=0,l=s.length;a<l;++a)(0,Hi[s[a].getType()])(t,s[a],n,i,r,o)},Circle:function(t,e,n,i,r){const o=n.getFill(),s=n.getStroke();if(o||s){const a=t.getBuilder(n.getZIndex(),"Circle");a.setFillStrokeStyle(o,s),a.drawCircle(e,i,r)}const a=n.getText();if(a&&a.getText()){const o=t.getBuilder(n.getZIndex(),"Text");o.setTextStyle(a),o.drawText(e,i,r)}}};function qi(t,e){return parseInt(un(t),10)-parseInt(un(e),10)}function $i(t,e){const n=Zi(t,e);return n*n}function Zi(t,e){return.5*t/e}function Ki(t,e,n,i,r,o,s,a){const l=[],h=n.getImage();if(h){let t=!0;const e=h.getImageState();2==e||3==e?t=!1:0==e&&h.load(),t&&l.push(h.ready())}const c=n.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>r(null)),function(t,e,n,i,r,o,s){const a=n.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(i,r);n.getRenderer()?Ji(t,l,n,e,s):(0,Hi[l.getType()])(t,l,n,e,s,o)}(t,e,n,i,o,s,a),u}function Ji(t,e,n,i,r){if("GeometryCollection"==e.getType()){const o=e.getGeometries();for(let e=0,s=o.length;e<s;++e)Ji(t,o[e],n,i,r);return}t.getBuilder(n.getZIndex(),"Default").drawCustom(e,i,n.getRenderer(),n.getHitDetectionRenderer(),r)}const Qi=class extends Xe{constructor(t,e,n,i){super(t),this.inversePixelTransform=e,this.frameState=n,this.context=i}},tr=class extends ln{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=5}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return hn()}getData(t){return null}prepareFrame(t){return hn()}renderFrame(t,e){return hn()}forEachFeatureAtCoordinate(t,e,n,i,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;2!==e.getState()&&3!==e.getState()||this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return 2!=e&&3!=e&&t.addEventListener(Le,this.boundHandleImageChange_),0==e&&(t.load(),e=t.getState()),2==e}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}},er=[];let nr=null;const ir=class extends tr{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=[1,0,0,1,0,0],this.pixelTransform=[1,0,0,1,0,0],this.inversePixelTransform=[1,0,0,1,0,0],this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,n){let i;nr||(nr=J(1,1,void 0,{willReadFrequently:!0})),nr.clearRect(0,0,1,1);try{nr.drawImage(t,e,n,1,1,0,0,1,1),i=nr.getImageData(0,0,1,1).data}catch{return nr=null,null}return i}getBackground(t){let e=this.getLayer().getBackground();return"function"==typeof e&&(e=e(t.viewState.resolution)),e||void 0}useContainer(t,e,n){const i=this.getLayer().getClassName();let r,o;if(t&&t.className===i&&(!n||t&&t.style.backgroundColor&&l(Oe(t.style.backgroundColor),Oe(n)))){const e=t.firstElementChild;s=e,("undefined"!=typeof HTMLCanvasElement&&s instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&s instanceof OffscreenCanvas)&&(o=e.getContext("2d"))}var s;if(o&&function(t,e){const n=li(t),i=li(e);for(let t=0;t<6;++t)if(0!==Math.round((n[t]-i[t])*ai[t]))return!1;return!0}(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=Z?new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){const e=this.childNodes.indexOf(t);if(-1===e)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){const n=this.childNodes.indexOf(e);if(-1===n)throw new Error("Reference node not found");return this.childNodes.splice(n,0,t),t},style:{}},{get:(t,e,n)=>"firstElementChild"===e?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,n)}):document.createElement("div"),r.className=i;let t=r.style;t.position="absolute",t.width="100%",t.height="100%",o=J();const e=o.canvas;r.appendChild(e),t=e.style,t.position="absolute",t.left="0",t.transformOrigin="top left",this.container=r,this.context=o}this.containerReused||!n||this.container.style.backgroundColor||(this.container.style.backgroundColor=n)}clipUnrotated(t,e,n){const i=k(n),r=R(n),o=P(n),s=E(n);oi(e.coordinateToPixelTransform,i),oi(e.coordinateToPixelTransform,r),oi(e.coordinateToPixelTransform,o),oi(e.coordinateToPixelTransform,s);const a=this.inversePixelTransform;oi(a,i),oi(a,r),oi(a,o),oi(a,s),t.save(),t.beginPath(),t.moveTo(Math.round(i[0]),Math.round(i[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(s[0]),Math.round(s[1])),t.clip()}prepareContainer(t,e){const n=t.extent,i=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,s=Math.round(F(n)/i*o),a=Math.round(M(n)/i*o);si(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-s/2,-a/2),function(t,e){const n=(i=e)[0]*i[3]-i[1]*i[2];var i;ri(0!==n,"Transformation matrix cannot be inverted");const r=e[0],o=e[1],s=e[2],a=e[3],l=e[4],h=e[5];t[0]=a/n,t[1]=-o/n,t[2]=-s/n,t[3]=r/n,t[4]=(s*h-a*l)/n,t[5]=-(r*h-o*l)/n}(this.inversePixelTransform,this.pixelTransform);const l="matrix("+this.pixelTransform.join(", ")+")";if(this.useContainer(e,l,this.getBackground(t)),!this.containerReused){const t=this.context.canvas;t.width!=s||t.height!=a?(t.width=s,t.height=a):this.context.clearRect(0,0,s,a),l!==t.style.transform&&(t.style.transform=l)}}dispatchRenderEvent_(t,e,n){const i=this.getLayer();if(i.hasListener(t)){const r=new Qi(t,this.inversePixelTransform,n,e);i.dispatchEvent(r)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_(fe,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(ge,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new gi),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(fe,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(ge,this.context,t))}getRenderTransform(t,e,n,i,r,o,s){const a=r/2,l=o/2,h=i/e,c=-h,u=-t[0]+s,d=-t[1];return si(this.tempTransform,a,l,h,c,-n,u,d)}disposeInternal(){delete this.frameState,super.disposeInternal()}},rr=class extends ir{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=[1/0,1/0,-1/0,-1/0],this.wrappedRenderedExtent_=[1/0,1/0,-1/0,-1/0],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,n){const i=e.extent,r=e.viewState,o=r.center,s=r.resolution,a=r.projection,l=r.rotation,h=a.getExtent(),c=this.getLayer().getSource(),u=this.getLayer().getDeclutter(),d=e.pixelRatio,f=e.viewHints,g=!(f[0]||f[1]),p=this.context,m=Math.round(F(i)/s*d),y=Math.round(M(i)/s*d),_=c.getWrapX()&&a.canWrapX(),v=_?F(h):null,x=_?Math.ceil((i[2]-h[2])/v)+(this.extendX_?2:1):1;let S=_?Math.floor((i[0]-h[0])/v)-(this.extendX_?1:0):0;do{let i=this.getRenderTransform(o,s,0,d,m,y,S*v);e.declutter&&(i=i.slice(0)),t.execute(p,[p.canvas.width,p.canvas.height],i,l,g,void 0===n?Ei:n?Pi:Ti,n?u&&e.declutter[u]:void 0)}while(++S<x)}setDrawContext_(){1!==this.opacity_&&(this.targetContext_=this.context,this.context=J(this.context.canvas.width,this.context.canvas.height,er))}resetDrawContext_(){if(1!==this.opacity_&&this.targetContext_){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,function(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}(this.context),er.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.clipExtent_&&this.clipUnrotated(this.context,t,this.clipExtent_),this.replayGroup_.renderDeferred(),this.clipExtent_&&(this.context.restore(),this.clipExtent_=null),this.resetDrawContext_())}renderFrame(t,e){const n=t.layerStatesArray[t.layerIndex];this.opacity_=n.opacity;const i=t.viewState;this.prepareContainer(t,e);const r=this.context,o=this.replayGroup_;let s=o&&!o.isEmpty();if(!s&&!this.getLayer().hasListener(fe)&&!this.getLayer().hasListener(ge))return this.container;this.setDrawContext_(),this.preRender(r,t);i.projection;this.clipExtent_=null;let a=!1;if(s&&n.extent&&this.clipping){const e=le(n.extent);s=O(e,t.extent),s&&!f(e,t.extent)&&(t.declutter?this.clipExtent_=e:(this.clipUnrotated(r,t,e),a=!0))}return s&&this.renderWorlds(o,t,!this.getLayer().getDeclutter()&&void 0),a&&r.restore(),this.postRender(r,t),this.renderedRotation_!==i.rotation&&(this.renderedRotation_=i.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const t=this.frameState.size.slice(),e=this.renderedCenter_,n=this.renderedResolution_,r=this.renderedRotation_,o=this.renderedProjection_,s=this.wrappedRenderedExtent_,a=this.getLayer(),l=[],h=t[0]*Ui,c=t[1]*Ui;l.push(this.getRenderTransform(e,n,r,Ui,h,c,0).slice());const u=a.getSource(),d=o.getExtent();if(u.getWrapX()&&o.canWrapX()&&!f(d,s)){let t=s[0];const i=F(d);let o,a=0;for(;t<d[0];)--a,o=i*a,l.push(this.getRenderTransform(e,n,r,Ui,h,c,o).slice()),t+=i;for(a=0,t=s[2];t>d[2];)++a,o=i*a,l.push(this.getRenderTransform(e,n,r,Ui,h,c,o).slice()),t-=i}const g=re();this.hitDetectionImageData_=function(t,e,n,r,o,s,a,l,h){const c=h?ae(o):o,u=J(t[0]*Ui,t[1]*Ui);u.imageSmoothingEnabled=!1;const d=u.canvas,f=new zi(u,Ui,o,null,a,l,h?Qt(re(),h):null),g=n.length,p=Math.floor(16777215/g),m={};for(let t=1;t<=g;++t){const e=n[t-1],i=e.getStyleFunction()||r;if(!i)continue;let o=i(e,s);if(!o)continue;Array.isArray(o)||(o=[o]);const a=(t*p).toString(16).padStart(7,"#00000");for(let t=0,n=o.length;t<n;++t){const n=o[t],i=n.getGeometryFunction()(e);if(!i||!O(c,i.getExtent()))continue;const r=n.clone(),s=r.getFill();s&&s.setColor(a);const l=r.getStroke();l&&(l.setColor(a),l.setLineDash(null)),r.setText(void 0);const h=n.getImage();if(h){const t=h.getImageSize();if(!t)continue;const e=J(t[0],t[1],void 0,{alpha:!1}),n=e.canvas;e.fillStyle=a,e.fillRect(0,0,n.width,n.height),r.setImage(new ji({img:n,anchor:h.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:h.getOrigin(),opacity:1,size:h.getSize(),scale:h.getScale(),rotation:h.getRotation(),rotateWithView:h.getRotateWithView()}))}const u=r.getZIndex()||0;let d=m[u];d||(d={},m[u]=d,d.Polygon=[],d.Circle=[],d.LineString=[],d.Point=[]);const f=i.getType();if("GeometryCollection"===f){const t=i.getGeometriesArrayRecursive();for(let e=0,n=t.length;e<n;++e){const n=t[e];d[n.getType().replace("Multi","")].push(n,r)}}else d[f.replace("Multi","")].push(i,r)}}const y=Object.keys(m).map(Number).sort(i);for(let t=0,n=y.length;t<n;++t){const n=m[y[t]];for(const t in n){const i=n[t];for(let t=0,n=i.length;t<n;t+=2){f.setStyle(i[t+1]);for(let n=0,r=e.length;n<r;++n)f.setTransform(e[n]),f.drawGeometry(i[t])}}}return u.getImageData(0,0,d.width,d.height)}(t,l,this.renderedFeatures_,a.getStyleFunction(),s,n,r,$i(n,this.renderedPixelRatio_),g?o:null)}e(function(t,e,n){const i=[];if(n){const r=Math.floor(Math.round(t[0])*Ui),o=Math.floor(Math.round(t[1])*Ui),s=4*(D(r,0,n.width-1)+D(o,0,n.height-1)*n.width),a=n.data[s],l=n.data[s+1],h=n.data[s+2]+256*(l+256*a),c=Math.floor(16777215/e.length);h&&h%c===0&&i.push(e[h/c-1])}return i}(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,n,i,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,s=e.viewState.rotation,a=this.getLayer(),l={},h=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,s,n,function(t,e,n){const o=un(t),s=l[o];if(s){if(!0!==s&&n<s.distanceSq){if(0===n)return l[o]=!0,r.splice(r.lastIndexOf(s),1),i(t,a,e);s.geometry=e,s.distanceSq=n}}else{if(0===n)return l[o]=!0,i(t,a,e);r.push(l[o]={feature:t,layer:a,geometry:e,distanceSq:n,callback:i})}},h?e.declutter?.[h]?.all().map(t=>t.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),n=e.getSource();if(!n)return!1;const i=t.viewHints[0],r=t.viewHints[1],o=e.getUpdateWhileAnimating(),s=e.getUpdateWhileInteracting();if(this.ready&&!o&&i||!s&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const a=t.extent,h=t.viewState,u=h.projection,d=h.resolution,g=t.pixelRatio,p=e.getRevision(),m=e.getRenderBuffer();let y=e.getRenderOrder();void 0===y&&(y=qi);const _=h.center.slice(),v=c(a,m*d),x=v.slice(),S=[v.slice()],w=u.getExtent(),C=n.getWrapX()&&u.canWrapX();if(this.extendX_=!1,C){const t=n.getExtent();t&&!A(t)&&(this.extendX_=t[0]<w[0]||t[2]>w[2])}if(C&&(!f(w,t.extent)||this.extendX_)){const t=F(w),e=Math.max(F(v)/2,t);let n=w[0],i=w[2];this.extendX_&&(n-=t,i+=t),v[0]=n-e,v[2]=i+e,function(t,e){if(e.canWrapX()){const n=F(e.getExtent()),i=function(t,e,n){const i=e.getExtent();let r=0;return e.canWrapX()&&(t[0]<i[0]||t[0]>i[2])&&(n=n||F(i),r=Math.floor((t[0]-i[0])/n)),r}(t,e,n);i&&(t[0]-=i*n)}}(_,u);const r=L(S[0],u);r[0]<w[0]&&r[2]<w[2]?S.push([r[0]+t,r[1],r[2]+t,r[3]]):r[0]>w[0]&&r[2]>w[2]&&S.push([r[0]-t,r[1],r[2]-t,r[3]])}if(this.ready&&this.renderedResolution_==d&&this.renderedPixelRatio_===g&&this.renderedRevision_==p&&this.renderedRenderOrder_==y&&this.renderedFrameDeclutter_===!!t.declutter&&f(this.wrappedRenderedExtent_,v))return l(this.renderedExtent_,x)||(this.hitDetectionImageData_=null,this.renderedExtent_=x),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const b=new ei(Zi(d,g),v,d,g),I=re();let E;if(I){for(let t=0,e=S.length;t<e;++t){const e=ae(S[t]);n.loadFeatures(e,he(d),I)}E=Qt(I,u)}else for(let t=0,e=S.length;t<e;++t)n.loadFeatures(S[t],d,u);const P=$i(d,g);let T=!0;const M=(t,n)=>{let i;const r=t.getStyleFunction()||e.getStyleFunction();if(r&&(i=r(t,d)),i){const e=this.renderFeature(t,P,i,b,E,this.getLayer().getDeclutter(),n);T=T&&!e}},k=ae(v),R=n.getFeaturesInExtent(k);y&&R.sort(y);for(let t=0,e=R.length;t<e;++t)M(R[t],t);this.renderedFeatures_=R,this.ready=T;const O=b.finish(),D=new Fi(v,d,g,n.getOverlaps(),O,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=d,this.renderedRevision_=p,this.renderedRenderOrder_=y,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=x,this.wrappedRenderedExtent_=v,this.renderedCenter_=_,this.renderedProjection_=u,this.renderedPixelRatio_=g,this.replayGroup_=D,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,n,i,r,o,s){if(!n)return!1;let a=!1;if(Array.isArray(n))for(let l=0,h=n.length;l<h;++l)a=Ki(i,t,n[l],e,this.boundHandleStyleImageChange_,r,o,s)||a;else a=Ki(i,t,n,e,this.boundHandleStyleImageChange_,r,o,s);return a}};function or(t,e,n=0,i=t.length-1,r=ar){for(;i>n;){if(i-n>600){const o=i-n+1,s=e-n+1,a=Math.log(o),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);or(t,e,Math.max(n,Math.floor(e-s*l/o+h)),Math.min(i,Math.floor(e+(o-s)*l/o+h)),r)}const o=t[e];let s=n,a=i;for(sr(t,n,e),r(t[i],o)>0&&sr(t,n,i);s<a;){for(sr(t,s,a),s++,a--;r(t[s],o)<0;)s++;for(;r(t[a],o)>0;)a--}0===r(t[n],o)?sr(t,n,a):(a++,sr(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function sr(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function ar(t,e){return t<e?-1:t>e?1:0}class lr{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!xr(t,e))return n;const i=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const s=e.children[o],a=e.leaf?i(s):s;xr(t,a)&&(e.leaf?n.push(s):vr(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n}collides(t){let e=this.data;if(!xr(t,e))return!1;const n=[];for(;e;){for(let i=0;i<e.children.length;i++){const r=e.children[i],o=e.leaf?this.toBBox(r):r;if(xr(t,o)){if(e.leaf||vr(t,o))return!0;n.push(r)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Sr([]),this}remove(t,e){if(!t)return this;let n=this.data;const i=this.toBBox(t),r=[],o=[];let s,a,l;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],s=o.pop(),l=!0),n.leaf){const i=hr(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!vr(n,i)?a?(s++,n=a.children[s],l=!1):n=null:(r.push(n),o.push(s),s=0,a=n,n=n.children[0])}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 n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,i){const r=n-e+1;let o,s=this._maxEntries;if(r<=s)return o=Sr(t.slice(e,n+1)),cr(o,this.toBBox),o;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),o=Sr([]),o.leaf=!1,o.height=i;const a=Math.ceil(r/s),l=a*Math.ceil(Math.sqrt(s));wr(t,e,n,l,this.compareMinX);for(let r=e;r<=n;r+=l){const e=Math.min(r+l-1,n);wr(t,r,e,a,this.compareMinY);for(let n=r;n<=e;n+=a){const r=Math.min(n+a-1,e);o.children.push(this._build(t,n,r,i-1))}}return cr(o,this.toBBox),o}_chooseSubtree(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){let n,i=1/0,r=1/0;for(let o=0;o<e.children.length;o++){const s=e.children[o],a=pr(s),l=yr(t,s)-a;l<r?(r=l,i=a<i?a:i,n=s):l===r&&a<i&&(i=a,n=s)}e=n||e.children[0]}return e}_insert(t,e,n){const i=n?t:this.toBBox(t),r=[],o=this._chooseSubtree(i,this.data,e,r);for(o.children.push(t),dr(o,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)}_split(t,e){const n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const o=this._chooseSplitIndex(n,r,i),s=Sr(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,cr(n,this.toBBox),cr(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)}_splitRoot(t,e){this.data=Sr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,cr(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let i,r=1/0,o=1/0;for(let s=e;s<=n-e;s++){const e=ur(t,0,s,this.toBBox),a=ur(t,s,n,this.toBBox),l=_r(e,a),h=pr(e)+pr(a);l<r?(r=l,i=s,o=h<o?h:o):l===r&&h<o&&(o=h,i=s)}return i||n-e}_chooseSplitAxis(t,e,n){const i=t.leaf?this.compareMinX:fr,r=t.leaf?this.compareMinY:gr;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)}_allDistMargin(t,e,n,i){t.children.sort(i);const r=this.toBBox,o=ur(t,0,e,r),s=ur(t,n-e,n,r);let a=mr(o)+mr(s);for(let i=e;i<n-e;i++){const e=t.children[i];dr(o,t.leaf?r(e):e),a+=mr(o)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];dr(s,t.leaf?r(e):e),a+=mr(s)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)dr(e[i],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():cr(t[n],this.toBBox)}}function hr(t,e,n){if(!n)return e.indexOf(t);for(let i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function cr(t,e){ur(t,0,t.children.length,e,t)}function ur(t,e,n,i,r){r||(r=Sr(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let o=e;o<n;o++){const e=t.children[o];dr(r,t.leaf?i(e):e)}return r}function dr(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function fr(t,e){return t.minX-e.minX}function gr(t,e){return t.minY-e.minY}function pr(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function mr(t){return t.maxX-t.minX+(t.maxY-t.minY)}function yr(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function _r(t,e){const n=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,r-n)*Math.max(0,o-i)}function vr(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function xr(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Sr(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function wr(t,e,n,i,r){const o=[e,n];for(;o.length;){if((n=o.pop())-(e=o.pop())<=i)continue;const s=e+Math.ceil((n-e)/i/2)*i;or(t,s,e,n,r),o.push(e,s,s,n)}}let Cr=0;const br=1<<Cr++,Ir=1<<Cr++,Er=1<<Cr++,Pr=1<<Cr++,Tr=1<<Cr++,Mr=1<<Cr++,kr=Math.pow(2,6)-1,Rr={[br]:"boolean",[Ir]:"number",[Er]:"string",[Pr]:"color",[Tr]:"number[]",[Mr]:"size"},Fr=Object.keys(Rr).map(Number).sort(i);function Or(t){const e=[];for(const n of Fr)Ar(t,n)&&e.push(Rr[n]);return 0===e.length?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function Ar(t,e){return(t&e)===e}function Lr(t,e){return t===e}class Dr{constructor(t,e){if(!function(t){return t in Rr}(t))throw new Error(`literal expressions must have a specific type, got ${Or(t)}`);this.type=t,this.value=e}}class Gr{constructor(t,e,...n){this.type=t,this.operator=e,this.args=n}}function jr(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1}}function Vr(t,e,n){switch(typeof t){case"boolean":if(Lr(e,Er))return new Dr(Er,t?"true":"false");if(!Ar(e,br))throw new Error(`got a boolean, but expected ${Or(e)}`);return new Dr(br,t);case"number":if(Lr(e,Mr))return new Dr(Mr,Oi(t));if(Lr(e,br))return new Dr(br,!!t);if(Lr(e,Er))return new Dr(Er,t.toString());if(!Ar(e,Ir))throw new Error(`got a number, but expected ${Or(e)}`);return new Dr(Ir,t);case"string":if(Lr(e,Pr))return new Dr(Pr,Fe(t));if(Lr(e,br))return new Dr(br,!!t);if(!Ar(e,Er))throw new Error(`got a string, but expected ${Or(e)}`);return new Dr(Er,t)}if(!Array.isArray(t))throw new Error("expression must be an array or a primitive value");if(0===t.length)throw new Error("empty expression");if("string"==typeof t[0])return function(t,e,n){const i=t[0],r=Ao[i];if(!r)throw new Error(`unknown operator: ${i}`);return r(t,e,n)}(t,e,n);for(const e of t)if("number"!=typeof e)throw new Error("expected an array of numbers");if(Lr(e,Mr)){if(2!==t.length)throw new Error(`expected an array of two values for a size, got ${t.length}`);return new Dr(Mr,t)}if(Lr(e,Pr)){if(3===t.length)return new Dr(Pr,[...t,1]);if(4===t.length)return new Dr(Pr,t);throw new Error(`expected an array of 3 or 4 values for a color, got ${t.length}`)}if(!Ar(e,Tr))throw new Error(`got an array of numbers, but expected ${Or(e)}`);return new Dr(Tr,t)}const Nr="get",Wr="var",Br="concat",Xr="geometry-type",Yr="line-metric",zr="any",Ur="all",Hr="!",qr="resolution",$r="zoom",Zr="time",Kr="==",Jr="!=",Qr=">",to=">=",eo="<",no="<=",io="*",ro="/",oo="+",so="-",ao="clamp",lo="%",ho="^",co="abs",uo="floor",fo="ceil",go="round",po="sin",mo="cos",yo="atan",_o="sqrt",vo="match",xo="between",So="interpolate",wo="coalesce",Co="case",bo="in",Io="number",Eo="string",Po="array",To="color",Mo="id",ko="band",Ro="palette",Fo="to-string",Oo="has",Ao={[Nr]:Bo(jo(1,1/0),Lo),[Wr]:Bo(jo(1,1),function(t,e,n){const i=t[1];if("string"!=typeof i)throw new Error("expected a string argument for var operation");return n.variables.add(i),[new Dr(Er,i)]}),[Oo]:Bo(jo(1,1/0),Lo),[Mo]:Bo(function(t,e,n){n.featureId=!0},Go),[Br]:Bo(jo(2,1/0),No(Er)),[Xr]:Bo(function(t,e,n){n.geometryType=!0},Go),[Yr]:Bo(function(t,e,n){n.mCoordinate=!0},Go),[qr]:Bo(Do,Go),[$r]:Bo(Do,Go),[Zr]:Bo(Do,Go),[zr]:Bo(jo(2,1/0),No(br)),[Ur]:Bo(jo(2,1/0),No(br)),[Hr]:Bo(jo(1,1),No(br)),[Kr]:Bo(jo(2,2),No(kr)),[Jr]:Bo(jo(2,2),No(kr)),[Qr]:Bo(jo(2,2),No(Ir)),[to]:Bo(jo(2,2),No(Ir)),[eo]:Bo(jo(2,2),No(Ir)),[no]:Bo(jo(2,2),No(Ir)),[io]:Bo(jo(2,1/0),Vo),[wo]:Bo(jo(2,1/0),Vo),[ro]:Bo(jo(2,2),No(Ir)),[oo]:Bo(jo(2,1/0),No(Ir)),[so]:Bo(jo(2,2),No(Ir)),[ao]:Bo(jo(3,3),No(Ir)),[lo]:Bo(jo(2,2),No(Ir)),[ho]:Bo(jo(2,2),No(Ir)),[co]:Bo(jo(1,1),No(Ir)),[uo]:Bo(jo(1,1),No(Ir)),[fo]:Bo(jo(1,1),No(Ir)),[go]:Bo(jo(1,1),No(Ir)),[po]:Bo(jo(1,1),No(Ir)),[mo]:Bo(jo(1,1),No(Ir)),[yo]:Bo(jo(1,2),No(Ir)),[_o]:Bo(jo(1,1),No(Ir)),[vo]:Bo(jo(4,1/0),Wo,function(t,e,n){const i=t.length-1,r=Er|Ir|br,o=Vr(t[1],r,n),s=Vr(t[t.length-1],e,n),a=new Array(i-2);for(let e=0;e<i-2;e+=2){try{const i=Vr(t[e+2],o.type,n);a[e]=i}catch(t){throw new Error(`failed to parse argument ${e+1} of match expression: ${t.message}`)}try{const i=Vr(t[e+3],s.type,n);a[e+1]=i}catch(t){throw new Error(`failed to parse argument ${e+2} of match expression: ${t.message}`)}}return[o,...a,s]}),[xo]:Bo(jo(3,3),No(Ir)),[So]:Bo(jo(6,1/0),Wo,function(t,e,n){const i=t[1];let r;switch(i[0]){case"linear":r=1;break;case"exponential":const t=i[1];if("number"!=typeof t||t<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(t)} instead`);r=t;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const o=new Dr(Ir,r);let s;try{s=Vr(t[2],Ir,n)}catch(t){throw new Error(`failed to parse argument 1 in interpolate expression: ${t.message}`)}const a=new Array(t.length-3);for(let i=0;i<a.length;i+=2){try{const e=Vr(t[i+3],Ir,n);a[i]=e}catch(t){throw new Error(`failed to parse argument ${i+2} for interpolate expression: ${t.message}`)}try{const r=Vr(t[i+4],e,n);a[i+1]=r}catch(t){throw new Error(`failed to parse argument ${i+3} for interpolate expression: ${t.message}`)}}return[o,s,...a]}),[Co]:Bo(jo(3,1/0),function(t,e,n){const i=t[0],r=t.length-1;if(r%2==0)throw new Error(`expected an odd number of arguments for ${i}, got ${r} instead`)},function(t,e,n){const i=Vr(t[t.length-1],e,n),r=new Array(t.length-1);for(let e=0;e<r.length-1;e+=2){try{const i=Vr(t[e+1],br,n);r[e]=i}catch(t){throw new Error(`failed to parse argument ${e} of case expression: ${t.message}`)}try{const o=Vr(t[e+2],i.type,n);r[e+1]=o}catch(t){throw new Error(`failed to parse argument ${e+1} of case expression: ${t.message}`)}}return r[r.length-1]=i,r}),[bo]:Bo(jo(2,2),function(t,e,n){let i,r=t[2];if(!Array.isArray(r))throw new Error('the second argument for the "in" operator must be an array');if("literal"===r[0]){if(r=r[1],!Array.isArray(r))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array')}else if("string"==typeof r[0])throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');i="string"==typeof r[0]?Er:Ir;const o=new Array(r.length);for(let t=0;t<o.length;t++)try{const e=Vr(r[t],i,n);o[t]=e}catch(e){throw new Error(`failed to parse haystack item ${t} for "in" expression: ${e.message}`)}return[Vr(t[1],i,n),...o]}),[Io]:Bo(jo(1,1/0),No(kr)),[Eo]:Bo(jo(1,1/0),No(kr)),[Po]:Bo(jo(1,1/0),No(Ir)),[To]:Bo(jo(1,4),No(Ir)),[ko]:Bo(jo(1,3),No(Ir)),[Ro]:Bo(jo(2,2),function(t,e,n){let i;try{i=Vr(t[1],Ir,n)}catch(t){throw new Error(`failed to parse first argument in palette expression: ${t.message}`)}const r=t[2];if(!Array.isArray(r))throw new Error("the second argument of palette must be an array");const o=new Array(r.length);for(let t=0;t<o.length;t++){let e;try{e=Vr(r[t],Pr,n)}catch(e){throw new Error(`failed to parse color at index ${t} in palette expression: ${e.message}`)}if(!(e instanceof Dr))throw new Error(`the palette color at index ${t} must be a literal value`);o[t]=e}return[i,...o]}),[Fo]:Bo(jo(1,1),No(br|Ir|Er|Pr))};function Lo(t,e,n){const i=t.length-1,r=new Array(i);for(let e=0;e<i;++e){const i=t[e+1];switch(typeof i){case"number":r[e]=new Dr(Ir,i);break;case"string":r[e]=new Dr(Er,i);break;default:throw new Error(`expected a string key or numeric array index for a get operation, got ${i}`)}0===e&&n.properties.add(String(i))}return r}function Do(t,e,n){n.mapState=!0}function Go(t,e,n){const i=t[0];if(1!==t.length)throw new Error(`expected no arguments for ${i} operation`);return[]}function jo(t,e){return function(n,i,r){const o=n[0],s=n.length-1;if(t===e){if(s!==t)throw new Error(`expected ${t} argument${1===t?"":"s"} for ${o}, got ${s}`)}else if(s<t||s>e)throw new Error(`expected ${e===1/0?`${t} or more`:`${t} to ${e}`} arguments for ${o}, got ${s}`)}}function Vo(t,e,n){const i=t.length-1,r=new Array(i);for(let o=0;o<i;++o){const i=Vr(t[o+1],e,n);r[o]=i}return r}function No(t){return function(e,n,i){const r=e.length-1,o=new Array(r);for(let n=0;n<r;++n){const r=Vr(e[n+1],t,i);o[n]=r}return o}}function Wo(t,e,n){const i=t[0],r=t.length-1;if(r%2==1)throw new Error(`expected an even number of arguments for operation ${i}, got ${r} instead`)}function Bo(...t){return function(e,n,i){const r=e[0];let o;for(let r=0;r<t.length;r++){const s=t[r](e,n,i);if(r==t.length-1){if(!s)throw new Error("expected last argument validator to return the parsed args");o=s}}return new Gr(n,r,...o)}}function Xo(t){if(!t)return"";const e=t.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Xo(t.getGeometries()[0]);default:return""}}function Yo(t,e,n){return zo(Vr(t,e,n),n)}function zo(t,e){if(t instanceof Dr){if(t.type===Pr&&"string"==typeof t.value){const e=Fe(t.value);return function(){return e}}return function(){return t.value}}const n=t.operator;switch(n){case Io:case Eo:case wo:return function(t,e){const n=t.operator,i=t.args.length,r=new Array(i);for(let n=0;n<i;++n)r[n]=zo(t.args[n],e);switch(n){case wo:return t=>{for(let e=0;e<i;++e){const n=r[e](t);if(null!=n)return n}throw new Error("Expected one of the values to be non-null")};case Io:case Eo:return t=>{for(let e=0;e<i;++e){const i=r[e](t);if(typeof i===n)return i}throw new Error(`Expected one of the values to be a ${n}`)};default:throw new Error(`Unsupported assertion operator ${n}`)}}(t,e);case Nr:case Wr:case Oo:return function(t){const e=t.args[0].value;switch(t.operator){case Nr:return n=>{const i=t.args;let r=n.properties[e];for(let t=1,e=i.length;t<e;++t)r=r[i[t].value];return r};case Wr:return t=>t.variables[e];case Oo:return n=>{const i=t.args;if(!(e in n.properties))return!1;let r=n.properties[e];for(let t=1,e=i.length;t<e;++t){const e=i[t].value;if(!r||!Object.hasOwn(r,e))return!1;r=r[e]}return!0};default:throw new Error(`Unsupported accessor operator ${t.operator}`)}}(t);case"id":return t=>t.featureId;case Xr:return t=>t.geometryType;case Br:{const n=t.args.map(t=>zo(t,e));return t=>"".concat(...n.map(e=>e(t).toString()))}case qr:return t=>t.resolution;case zr:case Ur:case xo:case bo:case"!":return function(t,e){const n=t.operator,i=t.args.length,r=new Array(i);for(let n=0;n<i;++n)r[n]=zo(t.args[n],e);switch(n){case zr:return t=>{for(let e=0;e<i;++e)if(r[e](t))return!0;return!1};case Ur:return t=>{for(let e=0;e<i;++e)if(!r[e](t))return!1;return!0};case xo:return t=>{const e=r[0](t),n=r[1](t),i=r[2](t);return e>=n&&e<=i};case bo:return t=>{const e=r[0](t);for(let n=1;n<i;++n)if(e===r[n](t))return!0;return!1};case"!":return t=>!r[0](t);default:throw new Error(`Unsupported logical operator ${n}`)}}(t,e);case Kr:case Jr:case"<":case no:case">":case to:return function(t,e){const n=t.operator,i=zo(t.args[0],e),r=zo(t.args[1],e);switch(n){case Kr:return t=>i(t)===r(t);case Jr:return t=>i(t)!==r(t);case"<":return t=>i(t)<r(t);case no:return t=>i(t)<=r(t);case">":return t=>i(t)>r(t);case to:return t=>i(t)>=r(t);default:throw new Error(`Unsupported comparison operator ${n}`)}}(t,e);case"*":case"/":case"+":case"-":case ao:case"%":case"^":case co:case uo:case fo:case go:case po:case mo:case yo:case _o:return function(t,e){const n=t.operator,i=t.args.length,r=new Array(i);for(let n=0;n<i;++n)r[n]=zo(t.args[n],e);switch(n){case"*":return t=>{let e=1;for(let n=0;n<i;++n)e*=r[n](t);return e};case"/":return t=>r[0](t)/r[1](t);case"+":return t=>{let e=0;for(let n=0;n<i;++n)e+=r[n](t);return e};case"-":return t=>r[0](t)-r[1](t);case ao:return t=>{const e=r[0](t),n=r[1](t);if(e<n)return n;const i=r[2](t);return e>i?i:e};case"%":return t=>r[0](t)%r[1](t);case"^":return t=>Math.pow(r[0](t),r[1](t));case co:return t=>Math.abs(r[0](t));case uo:return t=>Math.floor(r[0](t));case fo:return t=>Math.ceil(r[0](t));case go:return t=>Math.round(r[0](t));case po:return t=>Math.sin(r[0](t));case mo:return t=>Math.cos(r[0](t));case yo:return 2===i?t=>Math.atan2(r[0](t),r[1](t)):t=>Math.atan(r[0](t));case _o:return t=>Math.sqrt(r[0](t));default:throw new Error(`Unsupported numeric operator ${n}`)}}(t,e);case Co:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=zo(t.args[r],e);return t=>{for(let e=0;e<n-1;e+=2)if(i[e](t))return i[e+1](t);return i[n-1](t)}}(t,e);case vo:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=zo(t.args[r],e);return t=>{const e=i[0](t);for(let r=1;r<n-1;r+=2)if(e===i[r](t))return i[r+1](t);return i[n-1](t)}}(t,e);case So:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=zo(t.args[r],e);return t=>{const e=i[0](t),r=i[1](t);let o,s;for(let a=2;a<n;a+=2){const n=i[a](t);let l=i[a+1](t);const h=Array.isArray(l);if(h&&(l=Ee(l)),n>=r)return 2===a?l:h?Ho(e,r,o,s,n,l):Uo(e,r,o,s,n,l);o=n,s=l}return s}}(t,e);case Fo:return function(t,e){const n=t.operator,i=t.args.length,r=new Array(i);for(let n=0;n<i;++n)r[n]=zo(t.args[n],e);if(n===Fo)return e=>{const n=r[0](e);return t.args[0].type===Pr?Ae(n):n.toString()};throw new Error(`Unsupported convert operator ${n}`)}(t,e);default:throw new Error(`Unsupported operator ${n}`)}}function Uo(t,e,n,i,r,o){const s=r-n;if(0===s)return i;const a=e-n;return i+(1===t?a/s:(Math.pow(t,a)-1)/(Math.pow(t,s)-1))*(o-i)}function Ho(t,e,n,i,r,o){if(0===r-n)return i;const s=Re(i),a=Re(o);let l=a[2]-s[2];return l>180?l-=360:l<-180&&(l+=360),function(t){const e=(t[0]+16)/116,n=t[1],i=t[2]*Math.PI/180,r=Te(e),o=Te(e+n/500*Math.cos(i)),s=Te(e-n/200*Math.sin(i)),a=Pe(3.021973625*o-1.617392459*r-.404875592*s),l=Pe(-.943766287*o+1.916279586*r+.027607165*s),h=Pe(.069407491*o-.22898585*r+1.159737864*s);return[D(a+.5|0,0,255),D(l+.5|0,0,255),D(h+.5|0,0,255),t[3]]}([Uo(t,e,n,s[0],r,a[0]),Uo(t,e,n,s[1],r,a[1]),s[2]+Uo(t,e,n,0,r,l),Uo(t,e,n,i[3],r,o[3])])}class qo extends Li{constructor(t){super({opacity:1,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,rotation:void 0!==t.rotation?t.rotation:0,scale:void 0!==t.scale?t.scale:1,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=void 0!==t.fill?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=void 0!==t.angle?t.angle:0,this.stroke_=void 0!==t.stroke?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?1:2,1===this.imageState_&&this.ready().then(()=>this.imageState_=2),this.render()}clone(){const t=this.getScale(),e=new qo({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(),n=this.getScaleArray();return[t[0]/2-e[0]/n[0],t[1]/2+e[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),n=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let i=Ue.get(n,null)?.getImage(1);if(!i){const e=this.renderOptions_,r=Math.ceil(e.size*t),o=J(r,r);this.draw_(e,o,t),i=o.canvas;const s=new Ze(i,void 0,null,2,null);Ue.set(n,null,s),createImageBitmap(i).then(t=>{s.setImage(t)})}return i}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,n){if(0===e||this.points_===1/0||"bevel"!==t&&"miter"!==t)return e;let i=this.radius,r=void 0===this.radius2_?i:this.radius2_;if(i<r){const t=i;i=r,r=t}const o=void 0===this.radius2_?this.points_:2*this.points_,s=2*Math.PI/o,a=r*Math.sin(s),l=i-Math.sqrt(r*r-a*a),h=Math.sqrt(a*a+l*l),c=h/a;if("miter"===t&&c<=n)return c*e;const u=e/2/c,d=e/2*(l/h),f=Math.sqrt((i+u)*(i+u)+d*d)-i;if(void 0===this.radius2_||"bevel"===t)return 2*f;const g=i*Math.sin(s),p=r-Math.sqrt(i*i-g*g),m=Math.sqrt(g*g+p*p)/g;if(m<=n){const t=m*e/2-r-i;return 2*Math.max(f,t)}return 2*f}createRenderOptions(){let t,e=xn,n=wn,i=0,r=null,o=0,s=0;this.stroke_&&(t=Ke(this.stroke_.getColor()??Cn),s=this.stroke_.getWidth()??1,r=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset()??0,n=this.stroke_.getLineJoin()??wn,e=this.stroke_.getLineCap()??xn,i=this.stroke_.getMiterLimit()??10);const a=this.calculateLineJoinSize_(n,s,i),l=Math.max(this.radius,this.radius2_||0);return{strokeStyle:t,strokeWidth:s,size:Math.ceil(2*l+a),lineCap:e,lineDash:r,lineDashOffset:o,lineJoin:n,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,n){if(e.scale(n,n),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let t=this.fill_.getColor();null===t&&(t=vn),e.fillStyle=Ke(t),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 n=this.fill_.getColor(),i=0;"string"==typeof n&&(n=Oe(n)),null===n?i=1:Array.isArray(n)&&(i=4===n.length?n[3]:1),0===i&&(e=J(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const n=this.radius;if(e===1/0)t.arc(0,0,n,0,2*Math.PI);else{const i=void 0===this.radius2_?n:this.radius2_;void 0!==this.radius2_&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let s=0;s<e;s++){const e=r+s*o,a=s%2==0?n:i;t.lineTo(a*Math.cos(e),a*Math.sin(e))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=vn,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()}}const $o=qo;class Zo extends $o{constructor(t){super({points:1/0,fill:(t=t||{radius:5}).fill,radius:t.radius,stroke:t.stroke,scale:void 0!==t.scale?t.scale:1,rotation:void 0!==t.rotation?t.rotation:0,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new Zo({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}}const Ko=Zo;class Jo{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,void 0!==t.color&&this.setColor(t.color)}clone(){const t=this.getColor();return new Jo({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(null!==t&&"object"==typeof t&&"src"in t){const e=$e(null,t.src,{crossOrigin:"anonymous"},void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),0===e.getImageState()&&e.load(),1===e.getImageState()&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?un(t):"object"==typeof t&&"src"in t?t.src+":"+t.offset:Oe(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}const Qo=Jo;class ts{constructor(t){t=t||{},this.color_=void 0!==t.color?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=void 0!==t.lineDash?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){const t=this.getColor();return new ts({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(),offset:this.getOffset(),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_}getOffset(){return this.offset_}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}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}}const es=ts;class ns{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=ss,void 0!==t.geometry&&this.setGeometry(t.geometry),this.fill_=void 0!==t.fill?t.fill:null,this.image_=void 0!==t.image?t.image:null,this.renderer_=void 0!==t.renderer?t.renderer:null,this.hitDetectionRenderer_=void 0!==t.hitDetectionRenderer?t.hitDetectionRenderer:null,this.stroke_=void 0!==t.stroke?t.stroke:null,this.text_=void 0!==t.text?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&"object"==typeof t&&(t=t.clone()),new ns({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=ss,this.geometry_=t}setZIndex(t){this.zIndex_=t}}let is=null;function rs(t,e){if(!is){const t=new Qo({color:"rgba(255,255,255,0.4)"}),e=new es({color:"#3399CC",width:1.25});is=[new ns({image:new Ko({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return is}function os(){const t={},e=[255,255,255,1],n=[0,153,255,1];return t.Polygon=[new ns({fill:new Qo({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new ns({stroke:new es({color:e,width:5})}),new ns({stroke:new es({color:n,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new ns({image:new Ko({radius:6,fill:new Qo({color:n}),stroke:new es({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function ss(t){return t.getGeometry()}const as=ns;class ls{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_=Oi(void 0!==t.scale?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=void 0!==t.fill?t.fill:new Qo({color:"#333"}),this.maxAngle_=void 0!==t.maxAngle?t.maxAngle:Math.PI/4,this.placement_=void 0!==t.placement?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=void 0!==t.stroke?t.stroke:null,this.offsetX_=void 0!==t.offsetX?t.offsetX:0,this.offsetY_=void 0!==t.offsetY?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=void 0===t.padding?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new ls({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()instanceof Qo?this.getFill().clone():this.getFill(),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_=Oi(void 0!==t?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}const hs=ls;function cs(t){return!0}function us(t){const e=jr(),n=function(t,e){const n=t.length,i=new Array(n);for(let r=0;r<n;++r){const n=t[r],o="filter"in n?Yo(n.filter,br,e):cs;let s;if(Array.isArray(n.style)){const t=n.style.length;s=new Array(t);for(let i=0;i<t;++i)s[i]=fs(n.style[i],e)}else s=[fs(n.style,e)];i[r]={filter:o,styles:s}}return function(e){const r=[];let o=!1;for(let s=0;s<n;++s)if((0,i[s].filter)(e)&&(!t[s].else||!o)){o=!0;for(const t of i[s].styles){const n=t(e);n&&r.push(n)}}return r}}(t,e),i={variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""};return function(t,r){if(i.properties=t.getPropertiesInternal(),i.resolution=r,e.featureId){const e=t.getId();i.featureId=void 0!==e?e:null}return e.geometryType&&(i.geometryType=Xo(t.getGeometry())),n(i)}}function ds(t){const e=jr(),n=t.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=fs(t[r],e);const r={variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""},o=new Array(n);return function(t,s){if(r.properties=t.getPropertiesInternal(),r.resolution=s,e.featureId){const e=t.getId();r.featureId=void 0!==e?e:null}let a=0;for(let t=0;t<n;++t){const e=i[t](r);e&&(o[a]=e,a+=1)}return o.length=a,o}}function fs(t,e){const n=gs(t,"",e),i=ps(t,"",e),r=function(t,e){const n="text-",i=_s(t,n+"value",e);if(!i)return null;const r=gs(t,n,e),o=gs(t,n+"background-",e),s=ps(t,n,e),a=ps(t,n+"background-",e),l=_s(t,n+"font",e),h=ys(t,n+"max-angle",e),c=ys(t,n+"offset-x",e),u=ys(t,n+"offset-y",e),d=vs(t,n+"overflow",e),f=_s(t,n+"placement",e),g=ys(t,n+"repeat",e),p=bs(t,n+"scale",e),m=vs(t,n+"rotate-with-view",e),y=ys(t,n+"rotation",e),_=_s(t,n+"align",e),v=_s(t,n+"justify",e),x=_s(t,n+"baseline",e),S=vs(t,n+"keep-upright",e),w=Ss(t,n+"padding",e),C=Ts(t,n+"declutter-mode"),b=new hs({declutterMode:C});return function(t){if(b.setText(i(t)),r&&b.setFill(r(t)),o&&b.setBackgroundFill(o(t)),s&&b.setStroke(s(t)),a&&b.setBackgroundStroke(a(t)),l&&b.setFont(l(t)),h&&b.setMaxAngle(h(t)),c&&b.setOffsetX(c(t)),u&&b.setOffsetY(u(t)),d&&b.setOverflow(d(t)),f){const e=f(t);if("point"!==e&&"line"!==e)throw new Error("Expected point or line for text-placement");b.setPlacement(e)}if(g&&b.setRepeat(g(t)),p&&b.setScale(p(t)),m&&b.setRotateWithView(m(t)),y&&b.setRotation(y(t)),_){const e=_(t);if("left"!==e&&"center"!==e&&"right"!==e&&"end"!==e&&"start"!==e)throw new Error("Expected left, right, center, start, or end for text-align");b.setTextAlign(e)}if(v){const e=v(t);if("left"!==e&&"right"!==e&&"center"!==e)throw new Error("Expected left, right, or center for text-justify");b.setJustify(e)}if(x){const e=x(t);if("bottom"!==e&&"top"!==e&&"middle"!==e&&"alphabetic"!==e&&"hanging"!==e)throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");b.setTextBaseline(e)}return w&&b.setPadding(w(t)),S&&b.setKeepUpright(S(t)),b}}(t,e),o=function(t,e){return"icon-src"in t?function(t,e){const n="icon-",i=n+"src",r=ks(t[i],i),o=ws(t,n+"anchor",e),s=bs(t,n+"scale",e),a=ys(t,n+"opacity",e),l=ws(t,n+"displacement",e),h=ys(t,n+"rotation",e),c=vs(t,n+"rotate-with-view",e),u=Es(t,n+"anchor-origin"),d=Ps(t,n+"anchor-x-units"),f=Ps(t,n+"anchor-y-units"),g=ms(t,n+"color");let p,m=null;void 0!==g&&(Array.isArray(g)&&g.length>0&&"string"==typeof g[0]?m=xs(t,n+"color",e):p=Fs(g,n+"color"));const y=function(t,e){const n=t[e];if(void 0!==n){if("string"!=typeof n)throw new Error(`Expected a string for ${e}`);return n}}(t,n+"cross-origin"),_=function(t,e){const n=t[e];if(void 0!==n)return Ms(n,e)}(t,n+"offset"),v=Es(t,n+"offset-origin"),x=Is(t,n+"width"),S=Is(t,n+"height"),w=function(t,e){const n=t[e];if(void 0!==n){if("number"==typeof n)return Oi(n);if(!Array.isArray(n))throw new Error(`Expected a number or size array for ${e}`);if(2!==n.length||"number"!=typeof n[0]||"number"!=typeof n[1])throw new Error(`Expected a number or size array for ${e}`);return n}}(t,n+"size"),C={src:r,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,crossOrigin:y,offset:_,offsetOrigin:v,height:S,width:x,size:w,declutterMode:Ts(t,n+"declutter-mode")};let b=null;return function(t){if(b)m&&b.setColor(m(t));else{const e=m?m(t):p;b=new ji(void 0!==e?Object.assign({},C,{color:e}):Object.assign({},C))}return a&&b.setOpacity(a(t)),l&&b.setDisplacement(l(t)),h&&b.setRotation(h(t)),c&&b.setRotateWithView(c(t)),s&&b.setScale(s(t)),o&&b.setAnchor(o(t)),b}}(t,e):"shape-points"in t?function(t,e){const n="shape-",i=n+"points",r=n+"radius",o=Rs(t[i],i);if(!(r in t))throw new Error(`Expected a number for ${r}`);const s=ys(t,r,e),a="number"==typeof t[r]?t[r]:5,l=n+"radius2",h=ys(t,l,e),c="number"==typeof t[l]?t[l]:void 0,u=gs(t,n,e),d=ps(t,n,e),f=bs(t,n+"scale",e),g=ws(t,n+"displacement",e),p=ys(t,n+"rotation",e),m=vs(t,n+"rotate-with-view",e),y=Is(t,n+"angle"),_=Ts(t,n+"declutter-mode"),v=new $o({points:o,radius:a,radius2:c,angle:y,declutterMode:_});return function(t){return s&&v.setRadius(s(t)),h&&v.setRadius2(h(t)),u&&v.setFill(u(t)),d&&v.setStroke(d(t)),g&&v.setDisplacement(g(t)),p&&v.setRotation(p(t)),m&&v.setRotateWithView(m(t)),f&&v.setScale(f(t)),v}}(t,e):"circle-radius"in t?function(t,e){const n="circle-",i=gs(t,n,e),r=ps(t,n,e),o=ys(t,n+"radius",e),s=bs(t,n+"scale",e),a=ws(t,n+"displacement",e),l=ys(t,n+"rotation",e),h=vs(t,n+"rotate-with-view",e),c=Ts(t,n+"declutter-mode"),u=new Ko({radius:5,declutterMode:c});return function(t){return o&&u.setRadius(o(t)),i&&u.setFill(i(t)),r&&u.setStroke(r(t)),a&&u.setDisplacement(a(t)),l&&u.setRotation(l(t)),h&&u.setRotateWithView(h(t)),s&&u.setScale(s(t)),u}}(t,e):null}(t,e),s=ys(t,"z-index",e);if(!(n||i||r||o||Be(t)))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(t));const a=new as;return function(t){let e=!0;if(n){const i=n(t);i&&(e=!1),a.setFill(i)}if(i){const n=i(t);n&&(e=!1),a.setStroke(n)}if(r){const n=r(t);n&&(e=!1),a.setText(n)}if(o){const n=o(t);n&&(e=!1),a.setImage(n)}return s&&a.setZIndex(s(t)),e?null:a}}function gs(t,e,n){let i;if(e+"fill-pattern-src"in t)i=function(t,e,n){const i=_s(t,e+"pattern-src",n),r=Cs(t,e+"pattern-offset",n),o=Cs(t,e+"pattern-size",n),s=xs(t,e+"color",n);return function(t){return{src:i(t),offset:r&&r(t),size:o&&o(t),color:s&&s(t)}}}(t,e+"fill-",n);else{if("none"===t[e+"fill-color"])return t=>null;i=xs(t,e+"fill-color",n)}if(!i)return null;const r=new Qo;return function(t){const e=i(t);return e===pe?null:(r.setColor(e),r)}}function ps(t,e,n){const i=ys(t,e+"stroke-width",n),r=xs(t,e+"stroke-color",n);if(!i&&!r)return null;const o=_s(t,e+"stroke-line-cap",n),s=_s(t,e+"stroke-line-join",n),a=Ss(t,e+"stroke-line-dash",n),l=ys(t,e+"stroke-line-dash-offset",n),h=ys(t,e+"stroke-miter-limit",n),c=ys(t,e+"stroke-offset",n),u=new es;return function(t){if(r){const e=r(t);if(e===pe)return null;u.setColor(e)}if(i&&u.setWidth(i(t)),o){const e=o(t);if("butt"!==e&&"round"!==e&&"square"!==e)throw new Error("Expected butt, round, or square line cap");u.setLineCap(e)}if(s){const e=s(t);if("bevel"!==e&&"round"!==e&&"miter"!==e)throw new Error("Expected bevel, round, or miter line join");u.setLineJoin(e)}return a&&u.setLineDash(a(t)),l&&u.setLineDashOffset(l(t)),h&&u.setMiterLimit(h(t)),c&&u.setOffset(c(t)),u}}function ms(t,e){if(!(e in t))return;const n=t[e];return void 0===n?void 0:n}function ys(t,e,n){const i=ms(t,e);if(void 0===i)return;const r=Yo(i,Ir,n);return function(t){return Rs(r(t),e)}}function _s(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Er,n);return function(t){return ks(r(t),e)}}function vs(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,br,n);return function(t){const n=r(t);if("boolean"!=typeof n)throw new Error(`Expected a boolean for ${e}`);return n}}function xs(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Pr,n);return function(t){return Fs(r(t),e)}}function Ss(t,e,n){const i=ms(t,e);if(void 0===i)return null;if(Array.isArray(i)&&(0===i.length||"string"!=typeof i[0])){const t=i.map((t,i)=>{if("number"==typeof t)return()=>t;const r=Yo(t,Ir,n);return function(t){return Rs(r(t),`${e}[${i}]`)}});return function(e){const n=new Array(t.length);for(let i=0;i<t.length;++i)n[i]=t[i](e);return n}}const r=Yo(i,Tr,n);return function(t){return Ms(r(t),e)}}function ws(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Tr,n);return function(t){const n=Ms(r(t),e);if(2!==n.length)throw new Error(`Expected two numbers for ${e}`);return n}}function Cs(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Tr,n);return function(t){return Os(r(t),e)}}function bs(t,e,n){const i=ms(t,e);if(void 0===i)return null;const r=Yo(i,Tr|Ir,n);return function(t){return n=r(t),i=e,"number"==typeof n?n:Os(n,i);var n,i}}function Is(t,e){const n=t[e];if(void 0!==n){if("number"!=typeof n)throw new Error(`Expected a number for ${e}`);return n}}function Es(t,e){const n=t[e];if(void 0!==n){if("bottom-left"!==n&&"bottom-right"!==n&&"top-left"!==n&&"top-right"!==n)throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return n}}function Ps(t,e){const n=t[e];if(void 0!==n){if("pixels"!==n&&"fraction"!==n)throw new Error(`Expected pixels or fraction for ${e}`);return n}}function Ts(t,e){const n=t[e];if(void 0!==n){if("string"!=typeof n)throw new Error(`Expected a string for ${e}`);if("declutter"!==n&&"obstacle"!==n&&"none"!==n)throw new Error(`Expected declutter, obstacle, or none for ${e}`);return n}}function Ms(t,e){if(!Array.isArray(t))throw new Error(`Expected an array for ${e}`);const n=t.length;for(let i=0;i<n;++i)if("number"!=typeof t[i])throw new Error(`Expected an array of numbers for ${e}`);return t}function ks(t,e){if("string"!=typeof t)throw new Error(`Expected a string for ${e}`);return t}function Rs(t,e){if("number"!=typeof t)throw new Error(`Expected a number for ${e}`);return t}function Fs(t,e){if("string"==typeof t)return t;const n=Ms(t,e),i=n.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return n}function Os(t,e){const n=Ms(t,e);if(2!==n.length)throw new Error(`Expected an array of two numbers for ${e}`);return n}const As={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Ls(t,e,n){return function(i,r,o,s,a){if(!i)return;if(!r&&!e)return i;const l=e?0:o[0]*r,h=e?0:o[1]*r,c=a?a[0]:0,u=a?a[1]:0;let d=t[0]+l/2+c,f=t[2]-l/2+c,g=t[1]+h/2+u,p=t[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>p&&(g=(p+g)/2,p=g);let m=D(i[0],d,f),y=D(i[1],g,p);if(s&&n&&r){const t=30*r;m+=-t*Math.log(1+Math.max(0,d-i[0])/t)+t*Math.log(1+Math.max(0,i[0]-f)/t),y+=-t*Math.log(1+Math.max(0,g-i[1])/t)+t*Math.log(1+Math.max(0,i[1]-p)/t)}return[m,y]}}function Ds(t){return t}function Gs(t){return 1-function(t){return Math.pow(t,3)}(1-t)}function js(t){return 3*t*t-2*t*t*t}function Vs(t,e,n,i){let r=0;const o=t[n-i],s=t[n-i+1];let a=0,l=0;for(;e<n;e+=i){const n=t[e]-o,i=t[e+1]-s;r+=l*n-a*i,a=n,l=i}return r/2}function Ns(t,e,n,i){let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o];r+=Vs(t,e,s,i),e=s}return r}function Ws(t,e,n,i,r,o,s){const a=t[e],l=t[e+1],h=t[n]-a,c=t[n+1]-l;let u;if(0===h&&0===c)u=e;else{const d=((r-a)*h+(o-l)*c)/(h*h+c*c);if(d>1)u=n;else{if(d>0){for(let r=0;r<i;++r)s[r]=B(t[e+r],t[n+r],d);return void(s.length=i)}u=e}}for(let e=0;e<i;++e)s[e]=t[u+e];s.length=i}function Bs(t,e,n,i,r){let o=t[e],s=t[e+1];for(e+=i;e<n;e+=i){const n=t[e],i=t[e+1],a=j(o,s,n,i);a>r&&(r=a),o=n,s=i}return r}function Xs(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];r=Bs(t,e,s,i,r),e=s}return r}function Ys(t,e,n,i,r,o,s,a,l,h,c){if(e==n)return h;let u,d;if(0===r){if(d=j(s,a,t[e],t[e+1]),d<h){for(u=0;u<i;++u)l[u]=t[e+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=e+i;for(;f<n;)if(Ws(t,f-i,f,i,s,a,c),d=j(s,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))/r|0,1);if(o&&(Ws(t,n-i,e,i,s,a,c),d=j(s,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 zs(t,e,n,i,r,o,s,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=n.length;u<d;++u){const d=n[u];h=Ys(t,e,d,i,r,o,s,a,l,h,c),e=d}return h}function Us(t,e,n,i){for(let i=0,r=n.length;i<r;++i)t[e++]=n[i];return e}function Hs(t,e,n,i){for(let r=0,o=n.length;r<o;++r){const o=n[r];for(let n=0;n<i;++n)t[e++]=o[n]}return e}function qs(t,e,n,i,r){r=r||[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=Hs(t,e,n[s],i);r[o++]=a,e=a}return r.length=o,r}function $s(t,e,n,i,r){r=r||[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=qs(t,e,n[s],i,r[o]);0===a.length&&(a[0]=e),r[o++]=a,e=a[a.length-1]}return r.length=o,r}class Zs extends Yi{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,void 0===e||Array.isArray(t[0])?this.setCoordinates(t,e):this.setFlatCoordinates(e,t)}clone(){return new Zs(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Bs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ys(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,n,i))}getArea(){return Vs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Je(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=zn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Zs(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Hs(this.flatCoordinates,0,t,this.stride),this.changed()}}const Ks=Zs;class Js extends Yi{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new Js(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){const r=this.flatCoordinates,o=j(t,e,r[0],r[1]);if(o<i){const t=this.stride;for(let e=0;e<t;++e)n[e]=r[e];return n.length=t,o}return i}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return _(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return g(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Us(this.flatCoordinates,0,t,this.stride),this.changed()}}const Qs=Js;function ta(t,e,n,i,r){return!I(r,function(r){return!ea(t,e,n,i,r[0],r[1])})}function ea(t,e,n,i,r,o){let s=0,a=t[n-i],l=t[n-i+1];for(;e<n;e+=i){const n=t[e],i=t[e+1];l<=o?i>o&&(n-a)*(o-l)-(r-a)*(i-l)>0&&s++:i<=o&&(n-a)*(o-l)-(r-a)*(i-l)<0&&s--,a=n,l=i}return 0!==s}function na(t,e,n,i,r,o){if(0===n.length)return!1;if(!ea(t,e,n[0],i,r,o))return!1;for(let e=1,s=n.length;e<s;++e)if(ea(t,n[e-1],n[e],i,r,o))return!1;return!0}function ia(t,e,n,r,o,s,a){let l,h,c,u,d,f,g;const p=o[s+1],m=[];for(let i=0,o=n.length;i<o;++i){const o=n[i];for(u=t[o-r],f=t[o-r+1],l=e;l<o;l+=r)d=t[l],g=t[l+1],(p<=f&&g<=p||f<=p&&p<=g)&&(c=(p-f)/(g-f)*(d-u)+u,m.push(c)),u=d,f=g}let y=NaN,_=-1/0;for(m.sort(i),u=m[0],l=1,h=m.length;l<h;++l){d=m[l];const i=Math.abs(d-u);i>_&&(c=(u+d)/2,na(t,e,n,r,c,p)&&(y=c,_=i)),u=d}return isNaN(y)&&(y=o[s]),a?(a.push(y,p,_),a):[y,p,_]}function ra(t,e,n,i,r){let o=[];for(let s=0,a=n.length;s<a;++s){const a=n[s];o=ia(t,e,a,i,r,2*s,o),e=a[a.length-1]}return o}function oa(t,e,n,i,r){let o;for(e+=i;e<n;e+=i)if(o=r(t.slice(e-i,e),t.slice(e,e+i)),o)return o;return!1}function sa(t,e,n,i,r,o){return o=o??C([1/0,1/0,-1/0,-1/0],t,e,n,i),!!O(r,o)&&(o[0]>=r[0]&&o[2]<=r[2]||o[1]>=r[1]&&o[3]<=r[3]||oa(t,e,n,i,function(t,e){return function(t,e,n){let i=!1;const r=p(t,e),o=p(t,n);if(1===r||1===o)i=!0;else{const s=t[0],a=t[1],l=t[2],h=t[3],c=e[0],u=e[1],d=n[0],f=n[1],g=(f-u)/(d-c);let p,m;2&o&&!(2&r)&&(p=d-(f-h)/g,i=p>=s&&p<=l),i||!(4&o)||4&r||(m=f-(d-l)*g,i=m>=a&&m<=h),i||!(8&o)||8&r||(p=d-(f-a)/g,i=p>=s&&p<=l),i||!(16&o)||16&r||(m=f-(d-s)*g,i=m>=a&&m<=h)}return i}(r,t,e)}))}function aa(t,e,n,i,r){if(!function(t,e,n,i,r){return!!(sa(t,e,n,i,r)||ea(t,e,n,i,r[0],r[1])||ea(t,e,n,i,r[0],r[3])||ea(t,e,n,i,r[2],r[1])||ea(t,e,n,i,r[2],r[3]))}(t,e,n[0],i,r))return!1;if(1===n.length)return!0;for(let e=1,o=n.length;e<o;++e)if(ta(t,n[e-1],n[e],i,r)&&!sa(t,n[e-1],n[e],i,r))return!1;return!0}function la(t,e,n,i){for(;e<n-i;){for(let r=0;r<i;++r){const o=t[e+r];t[e+r]=t[n-i+r],t[n-i+r]=o}e+=i,n-=i}}function ha(t,e,n,i){let r=0,o=t[n-i],s=t[n-i+1];for(;e<n;e+=i){const n=t[e],i=t[e+1];r+=(n-o)*(i+s),o=n,s=i}return 0===r?void 0:r>0}function ca(t,e,n,i,r){r=void 0!==r&&r;for(let o=0,s=n.length;o<s;++o){const s=n[o],a=ha(t,e,s,i);if(0===o){if(r&&a||!r&&!a)return!1}else if(r&&!a||!r&&a)return!1;e=s}return!0}function ua(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];if(!ca(t,e,s,i,r))return!1;s.length&&(e=s[s.length-1])}return!0}function da(t,e,n,i,r){r=void 0!==r&&r;for(let o=0,s=n.length;o<s;++o){const s=n[o],a=ha(t,e,s,i);(0===o?r&&a||!r&&!a:r&&!a||!r&&a)&&la(t,e,s,i),e=s}return e}function fa(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o)e=da(t,e,n[o],i,r);return e}class ga extends Yi{constructor(t,e,n){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,void 0!==e&&n?(this.setFlatCoordinates(e,t),this.ends_=n):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?a(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new ga(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Xs(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zs(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,n,i))}containsXY(t,e){return na(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return Ns(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),da(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Qe(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=T(this.getExtent());this.flatInteriorPoint_=ia(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new Qs(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new Ks(this.flatCoordinates.slice(0===t?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,n=this.ends_,i=[];let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o],a=new Ks(e.slice(r,s),t);i.push(a),r=s}return i}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;ca(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=da(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=$n(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,n),new ga(e,"XY",n)}getType(){return"Polygon"}intersectsExtent(t){return aa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=qs(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}const pa=ga;function ma(t){if(A(t))throw new Error("Cannot create polygon from empty extent");const e=t[0],n=t[1],i=t[2],r=t[3],o=[e,n,e,r,i,r,i,n,e,n];return new ga(o,"XY",[o.length])}function ya(t,e,n){e=e||32;const i=t.getStride(),r=t.getLayout(),o=t.getCenter(),s=i*(e+1),a=new Array(s);for(let t=0;t<s;t+=i){a[t]=0,a[t+1]=0;for(let e=2;e<i;e++)a[t+e]=o[e]}const l=[a.length],h=new ga(a,r,l);return function(t,e,n,i){const r=t.getFlatCoordinates(),o=t.getStride(),s=r.length/o-1,a=i||0;for(let t=0;t<=s;++t){const i=t*o,l=a+2*W(t,s)*Math.PI/s;r[i]=e[0]+n*Math.cos(l),r[i+1]=e[1]+n*Math.sin(l)}t.changed()}(h,o,t.getRadius(),n),h}function _a(t,e,n,i){const r=F(e)/n[0],o=M(e)/n[1];return i?Math.min(t,Math.max(r,o)):Math.min(t,Math.min(r,o))}function va(t,e,n){let i=Math.min(t,e);return i*=Math.log(1+50*Math.max(0,t/e-1))/50+1,n&&(i=Math.max(i,n),i/=Math.log(1+50*Math.max(0,n/t-1))/50+1),D(i,n/2,2*e)}function xa(t,e,n,i,r){return n=void 0===n||n,function(o,s,a,l){if(void 0!==o){const s=i?_a(t,i,a,r):t;return n&&l?va(o,s,e):D(o,e,s)}}}function Sa(t){if(void 0!==t)return 0}function wa(t){if(void 0!==t)return t}function Ca(t,e){setTimeout(function(){t(e)},0)}function ba(t){return!(t.sourceCenter&&t.targetCenter&&!U(t.sourceCenter,t.targetCenter))&&t.sourceResolution===t.targetResolution&&t.sourceRotation===t.targetRotation}function Ia(t,e,n,i,r){const o=Math.cos(-r);let s=Math.sin(-r),a=t[0]*o-t[1]*s,l=t[1]*o+t[0]*s;return a+=(e[0]/2-n[0])*i,l+=(n[1]-e[1]/2)*i,s=-s,[a*o-l*s,l*o+a*s]}const Ea=class extends fn{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Jt(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&&function(t){Ht=!(void 0===t||t)}(),t.center&&(t.center=se(t.center,this.projection_)),t.extent&&(t.extent=le(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const t in As)delete e[t];this.setProperties(e,!0);const n=function(t){let e,n,i;let r=void 0!==t.minZoom?t.minZoom:0,s=void 0!==t.maxZoom?t.maxZoom:28;const a=void 0!==t.zoomFactor?t.zoomFactor:2,l=void 0!==t.multiWorld&&t.multiWorld,h=void 0===t.smoothResolutionConstraint||t.smoothResolutionConstraint,c=void 0!==t.showFullExtent&&t.showFullExtent,u=Jt(t.projection,"EPSG:3857"),d=u.getExtent();let f=t.constrainOnlyCenter,g=t.extent;if(l||g||!u.isGlobal()||(f=!1,g=d),void 0!==t.resolutions){const a=t.resolutions;n=a[r],i=void 0!==a[s]?a[s]:a[a.length-1],e=t.constrainResolution?function(t,e,n,i){return e=void 0===e||e,function(r,s,a,l){if(void 0!==r){const h=t[0],c=t[t.length-1],u=n?_a(h,n,a,i):h;if(l)return e?va(r,u,c):D(r,c,u);const d=Math.min(u,r),f=Math.floor(o(t,d,s));return t[f]>u&&f<t.length-1?t[f+1]:t[f]}}}(a,h,!f&&g,c):xa(n,i,h,!f&&g,c)}else{const o=(d?Math.max(F(d),M(d)):360*it.degrees/u.getMetersPerUnit())/256/Math.pow(2,0),l=o/Math.pow(2,28);n=t.maxResolution,void 0!==n?r=0:n=o/Math.pow(a,r),i=t.minResolution,void 0===i&&(i=void 0!==t.maxZoom?void 0!==t.maxResolution?n/Math.pow(a,s):o/Math.pow(a,s):l),s=r+Math.floor(Math.log(n/i)/Math.log(a)),i=n/Math.pow(a,s-r),e=t.constrainResolution?function(t,e,n,i,r,o){return i=void 0===i||i,n=void 0!==n?n:0,function(s,a,l,h){if(void 0!==s){const c=r?_a(e,r,l,o):e;if(h)return i?va(s,c,n):D(s,n,c);const u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(t)-u),f=-a*(.5-u)+.5,g=Math.min(c,s),p=Math.floor(Math.log(e/g)/Math.log(t)+f),m=Math.max(d,p);return D(e/Math.pow(t,m),n,c)}}}(a,n,i,h,!f&&g,c):xa(n,i,h,!f&&g,c)}return{constraint:e,maxResolution:n,minResolution:i,minZoom:r,zoomFactor:a}}(t);this.maxResolution_=n.maxResolution,this.minResolution_=n.minResolution,this.zoomFactor_=n.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=n.minZoom;const i=function(t){if(void 0!==t.extent){const e=void 0===t.smoothExtentConstraint||t.smoothExtentConstraint;return Ls(t.extent,t.constrainOnlyCenter,e)}const e=Jt(t.projection,"EPSG:3857");if(!0!==t.multiWorld&&e.isGlobal()){const t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,Ls(t,!1,!1)}return Ds}(t),r=n.constraint,s=function(t){if(void 0===t.enableRotation||t.enableRotation){const e=t.constrainRotation;return void 0===e||!0===e?function(){const t=N(5);return function(e,n){return n||void 0===e?e:Math.abs(e)<=t?0:e}}():!1===e?wa:"number"==typeof e?function(t){const e=2*Math.PI/t;return function(t,n){return n?t:void 0!==t?t=Math.floor(t/e+.5)*e:void 0}}(e):wa}return Sa}(t);this.constraints_={center:i,resolution:r,rotation:s},this.setRotation(void 0!==t.rotation?t.rotation:0),this.setCenterInternal(void 0!==t.center?t.center:null),void 0!==t.resolution?this.setResolution(t.resolution):void 0!==t.zoom&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const n=this.getCenterInternal();if(n){const i=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),o=r/2*(i[3]-e[3]+e[1]-i[1]),s=r/2*(i[0]-e[0]+e[2]-i[2]);this.setCenterInternal([n[0]+o,n[1]-s])}}getUpdatedOptions_(t){const e=this.getProperties();return void 0!==e.resolution?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 t=0;t<e.length;++t){let n=arguments[t];n.center&&(n=Object.assign({},n),n.center=se(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=se(n.anchor,this.getProjection())),e[t]=n}this.animateInternal.apply(this,e)}animateInternal(t){let e,n=arguments.length;n>1&&"function"==typeof arguments[n-1]&&(e=arguments[n-1],--n);let i=0;for(;i<n&&!this.isDef();++i){const t=arguments[i];t.center&&this.setCenterInternal(t.center),void 0!==t.zoom?this.setZoom(t.zoom):t.resolution&&this.setResolution(t.resolution),void 0!==t.rotation&&this.setRotation(t.rotation)}if(i===n)return void(e&&Ca(e,!0));let r=Date.now(),o=this.targetCenter_.slice(),s=this.targetResolution_,a=this.targetRotation_;const l=[];for(;i<n;++i){const t=arguments[i],n={start:r,complete:!1,anchor:t.anchor,duration:void 0!==t.duration?t.duration:1e3,easing:t.easing||js,callback:e};if(t.center&&(n.sourceCenter=o,n.targetCenter=t.center.slice(),o=n.targetCenter),void 0!==t.zoom?(n.sourceResolution=s,n.targetResolution=this.getResolutionForZoom(t.zoom),s=n.targetResolution):t.resolution&&(n.sourceResolution=s,n.targetResolution=t.resolution,s=n.targetResolution),void 0!==t.rotation){n.sourceRotation=a;const e=W(t.rotation-a+Math.PI,2*Math.PI)-Math.PI;n.targetRotation=a+e,a=n.targetRotation}ba(n)?n.complete=!0:r+=n.duration,l.push(n)}this.animations_.push(l),this.setHint(0,1),this.updateAnimations_()}getAnimating(){return this.hints_[0]>0}getInteracting(){return this.hints_[1]>0}cancelAnimations(){let t;this.setHint(0,-this.hints_[0]);for(let e=0,n=this.animations_.length;e<n;++e){const n=this.animations_[e];if(n[0].callback&&Ca(n[0].callback,!1),!t)for(let e=0,i=n.length;e<i;++e){const i=n[e];if(!i.complete){t=i.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(void 0!==this.updateAnimationKey_&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let n=this.animations_.length-1;n>=0;--n){const i=this.animations_[n];let r=!0;for(let n=0,o=i.length;n<o;++n){const o=i[n];if(o.complete)continue;const s=t-o.start;let a=o.duration>0?s/o.duration:1;a>=1?(o.complete=!0,a=1):r=!1;const l=o.easing(a);if(o.sourceCenter){const t=o.sourceCenter[0],e=o.sourceCenter[1],n=o.targetCenter[0],i=o.targetCenter[1];this.nextCenter_=o.targetCenter;const r=t+l*(n-t),s=e+l*(i-e);this.targetCenter_=[r,s]}if(o.sourceResolution&&o.targetResolution){const t=1===l?o.targetResolution:o.sourceResolution+l*(o.targetResolution-o.sourceResolution);if(o.anchor){const e=this.getViewportSize_(this.getRotation()),n=this.constraints_.resolution(t,0,e,!0);this.targetCenter_=this.calculateCenterZoom(n,o.anchor)}this.nextResolution_=o.targetResolution,this.targetResolution_=t,this.applyTargetState_(!0)}if(void 0!==o.sourceRotation&&void 0!==o.targetRotation){const t=1===l?W(o.targetRotation+Math.PI,2*Math.PI)-Math.PI:o.sourceRotation+l*(o.targetRotation-o.sourceRotation);if(o.anchor){const e=this.constraints_.rotation(t,!0);this.targetCenter_=this.calculateCenterRotate(e,o.anchor)}this.nextRotation_=o.targetRotation,this.targetRotation_=t}if(this.applyTargetState_(!0),e=!0,!o.complete)break}if(r){this.animations_[n]=null,this.setHint(0,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=i[0].callback;t&&Ca(t,!0)}}this.animations_=this.animations_.filter(Boolean),e&&void 0===this.updateAnimationKey_&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let n;const i=this.getCenterInternal();var r,o;return void 0!==i&&(n=[i[0]-e[0],i[1]-e[1]],function(t,e){const n=Math.cos(e),i=Math.sin(e),r=t[0]*n-t[1]*i,o=t[1]*n+t[0]*i;t[0]=r,t[1]=o}(n,t-this.getRotation()),o=e,(r=n)[0]+=+o[0],r[1]+=+o[1]),n}calculateCenterZoom(t,e){let n;const i=this.getCenterInternal(),r=this.getResolution();return void 0!==i&&void 0!==r&&(n=[e[0]-t*(e[0]-i[0])/r,e[1]-t*(e[1]-i[1])/r]),n}getViewportSize_(t){const e=this.viewportSize_;if(t){const n=e[0],i=e[1];return[Math.abs(n*Math.cos(t))+Math.abs(i*Math.sin(t)),Math.abs(n*Math.sin(t))+Math.abs(i*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?oe(t,this.getProjection()):t}getCenterInternal(){return this.get(As.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return void 0!==t?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){return ae(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();ri(e,"The view center is not defined");const n=this.getResolution();ri(void 0!==n,"The view resolution is not defined");const i=this.getRotation();return ri(void 0!==i,"The view rotation is not defined"),function(t,e,n,i,r){const[o,s,a,l,h,c,u,d]=function(t,e,n,i){const r=e*i[0]/2,o=e*i[1]/2,s=Math.cos(n),a=Math.sin(n),l=r*s,h=r*a,c=o*s,u=o*a,d=t[0],f=t[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]}(t,e,n,i);return m(Math.min(o,a,h,u),Math.min(s,l,c,d),Math.max(o,a,h,u),Math.max(s,l,c,d),r)}(e,n,i,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(As.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(le(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const n=F(t)/e[0],i=M(t)/e[1];return Math.max(n,i)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,i=Math.log(e/n)/Math.log(t);return function(n){return e/Math.pow(t,n*i)}}getRotation(){return this.get(As.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),n=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(n/i)/e;return function(t){return Math.log(n/t)/e/r}}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const n=this.padding_;return n&&(e=[e[0]-n[1]-n[3],e[1]-n[0]-n[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),n=this.getRotation();let i=this.getCenterInternal();const r=this.padding_;if(r){const t=this.getViewportSizeMinusPadding_();i=Ia(i,this.getViewportSize_(),[t[0]/2+r[3],t[1]/2+r[0]],e,n)}return{center:i.slice(0),projection:void 0!==t?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return void 0!==e&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e,n,i=this.minZoom_||0;if(this.resolutions_){const r=o(this.resolutions_,t,1);i=r,e=this.resolutions_[r],n=r==this.resolutions_.length-1?2:e/this.resolutions_[r+1]}else e=this.maxResolution_,n=this.zoomFactor_;return i+Math.log(e/t)/Math.log(n)}getResolutionForZoom(t){if(this.resolutions_?.length){if(1===this.resolutions_.length)return this.resolutions_[0];const e=D(Math.floor(t),0,this.resolutions_.length-2),n=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(n,D(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let n;if(ri(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t))ri(!A(t),"Cannot fit empty extent provided as `geometry`"),n=ma(le(t,this.getProjection()));else if("Circle"===t.getType()){const e=le(t.getExtent(),this.getProjection());n=ma(e),n.rotate(this.getRotation(),T(e))}else{const e=re();n=e?t.clone().transform(e,this.getProjection()):t}this.fitInternal(n,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),n=Math.cos(e),i=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let s=1/0,a=1/0,l=-1/0,h=-1/0;for(let t=0,e=r.length;t<e;t+=o){const e=r[t]*n-r[t+1]*i,o=r[t]*i+r[t+1]*n;s=Math.min(s,e),a=Math.min(a,o),l=Math.max(l,e),h=Math.max(h,o)}return[s,a,l,h]}fitInternal(t,e){let n=(e=e||{}).size;n||(n=this.getViewportSizeMinusPadding_());const i=void 0!==e.padding?e.padding:[0,0,0,0],r=void 0!==e.nearest&&e.nearest;let o;o=void 0!==e.minResolution?e.minResolution:void 0!==e.maxZoom?this.getResolutionForZoom(e.maxZoom):0;const s=this.rotatedExtentForGeometry(t);let a=this.getResolutionForExtentInternal(s,[n[0]-i[1]-i[3],n[1]-i[0]-i[2]]);a=isNaN(a)?o:Math.max(a,o),a=this.getConstrainedResolution(a,r?0:1);const l=this.getRotation(),h=Math.sin(l),c=Math.cos(l),u=T(s);u[0]+=(i[1]-i[3])/2*a,u[1]+=(i[0]-i[2])/2*a;const d=u[0]*c-u[1]*h,f=u[1]*c+u[0]*h,g=this.getConstrainedCenter([d,f],a),p=e.callback?e.callback:Ve;void 0!==e.duration?this.animateInternal({resolution:a,center:g,duration:e.duration,easing:e.easing},p):(this.targetResolution_=a,this.targetCenter_=g,this.applyTargetState_(!1,!0),Ca(p,!0))}centerOn(t,e,n){this.centerOnInternal(se(t,this.getProjection()),e,n)}centerOnInternal(t,e,n){this.setCenterInternal(Ia(t,e,n,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,n,i){let r;const o=this.padding_;if(o&&t){const s=this.getViewportSizeMinusPadding_(-n),a=Ia(t,i,[s[0]/2+o[3],s[1]/2+o[0]],e,n);r=[t[0]-a[0],t[1]-a[1]]}return r}isDef(){return!!this.getCenterInternal()&&void 0!==this.getResolution()}adjustCenter(t){const e=oe(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&&se(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const n=this.getAnimating()||this.getInteracting(),i=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,i,n);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=se(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const n=this.getAnimating()||this.getInteracting(),i=this.constraints_.rotation(this.targetRotation_+t,n);e&&(this.targetCenter_=this.calculateCenterRotate(i,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t?se(t,this.getProjection()):t)}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 n=this.getAnimating()||this.getInteracting()||e,i=this.constraints_.rotation(this.targetRotation_,n),r=this.getViewportSize_(i),o=this.constraints_.resolution(this.targetResolution_,0,r,n),s=this.constraints_.center(this.targetCenter_,o,r,n,this.calculateCenterShift(this.targetCenter_,o,i,r));this.get(As.ROTATION)!==i&&this.set(As.ROTATION,i),this.get(As.RESOLUTION)!==o&&(this.set(As.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),s&&this.get(As.CENTER)&&U(this.get(As.CENTER),s)||this.set(As.CENTER,s),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,n){t=void 0!==t?t:200;const i=e||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),s=this.constraints_.resolution(this.targetResolution_,i,o),a=this.constraints_.center(this.targetCenter_,s,o,!1,this.calculateCenterShift(this.targetCenter_,s,r,o));if(0===t&&!this.cancelAnchor_)return this.targetResolution_=s,this.targetRotation_=r,this.targetCenter_=a,void this.applyTargetState_();n=n||(0===t?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,this.getResolution()===s&&this.getRotation()===r&&this.getCenterInternal()&&U(this.getCenterInternal(),a)||(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:a,resolution:s,duration:t,easing:Gs,anchor:n}))}beginInteraction(){this.resolveConstraints(0),this.setHint(1,1)}endInteraction(t,e,n){n=n&&se(n,this.getProjection()),this.endInteractionInternal(t,e,n)}endInteractionInternal(t,e,n){this.getInteracting()&&(this.setHint(1,-1),this.resolveConstraints(t,e,n))}getConstrainedCenter(t,e){const n=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),n)}getConstrainedZoom(t,e){const n=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(n,e))}getConstrainedResolution(t,e){e=e||0;const n=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,n)}},Pa="opacity",Ta="visible",Ma="extent",ka="zIndex",Ra="maxResolution",Fa="minResolution",Oa="maxZoom",Aa="minZoom",La="source",Da=class extends fn{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);"object"==typeof t.properties&&(delete e.properties,Object.assign(e,t.properties)),e[Pa]=void 0!==t.opacity?t.opacity:1,ri("number"==typeof e[Pa],"Layer opacity must be a number"),e[Ta]=void 0===t.visible||t.visible,e[ka]=t.zIndex,e[Ra]=void 0!==t.maxResolution?t.maxResolution:1/0,e[Fa]=void 0!==t.minResolution?t.minResolution:0,e[Aa]=void 0!==t.minZoom?t.minZoom:-1/0,e[Oa]=void 0!==t.maxZoom?t.maxZoom:1/0,this.className_=void 0!==e.className?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:void 0===t||t},n=this.getZIndex();return e.opacity=D(Math.round(100*this.getOpacity())/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=void 0!==n||e.managed?n:1/0,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return hn()}getLayerStatesArray(t){return hn()}getExtent(){return this.get(Ma)}getMaxResolution(){return this.get(Ra)}getMinResolution(){return this.get(Fa)}getMinZoom(){return this.get(Aa)}getMaxZoom(){return this.get(Oa)}getOpacity(){return this.get(Pa)}getSourceState(){return hn()}getVisible(){return this.get(Ta)}getZIndex(){return this.get(ka)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(Ma,t)}setMaxResolution(t){this.set(Ra,t)}setMinResolution(t){this.set(Fa,t)}setMaxZoom(t){this.set(Oa,t)}setMinZoom(t){this.set(Aa,t)}setOpacity(t){ri("number"==typeof t,"Layer opacity must be a number"),this.set(Pa,t)}setVisible(t){this.set(Ta,t)}setZIndex(t){this.set(ka,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},Ga=class extends Da{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(La,this.handleSourcePropertyChange_);const n=t.source?t.source:null;this.setSource(n)}getLayersArray(t){return(t=t||[]).push(this),t}getLayerStatesArray(t){return(t=t||[]).push(this.getLayerState()),t}getSource(){return this.get(La)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),this.sourceReady_||"ready"!==this.getSource().getState()||(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(sn(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=rn(t,Le,this.handleSourceChange_,this),"ready"===t.getState()&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return this.renderer_&&this.rendered?this.renderer_.getData(t):null}isVisible(t){let e;const n=this.getMapInternal();let i;if(!t&&n&&(t=n.getView()),e=t instanceof Ea?{viewState:t.getState(),extent:t.calculateExtent()}:t,!e.layerStatesArray&&n&&(e.layerStatesArray=n.getLayerGroup().getLayerStatesArray()),e.layerStatesArray){if(i=e.layerStatesArray.find(t=>t.layer===this),!i)return!1}else i=this.getLayerState();const r=this.getExtent();return function(t,e){if(!t.visible)return!1;const n=e.resolution;if(n<t.minResolution||n>=t.maxResolution)return!1;const i=e.zoom;return i>t.minZoom&&i<=t.maxZoom}(i,e.viewState)&&(!r||O(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let n=e(t instanceof Ea?t.getViewStateAndExtent():t);return Array.isArray(n)||(n=[n]),n}render(t,e){const n=this.getRenderer();return n.prepareFrame(t)?(this.rendered=!0,n.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("map",t)}getMapInternal(){return this.get("map")}setMap(t){this.mapPrecomposeKey_&&(sn(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(sn(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=rn(t,"precompose",this.handlePrecompose_,this),this.mapRenderKey_=rn(this,Le,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,n=this.getLayerState(!1);ri(!e.some(t=>t.layer===n.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(n)}setSource(t){this.set(La,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()}},ja="renderOrder",Va=class extends Ga{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=void 0!==t.renderBuffer?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=void 0!==t.updateWhileAnimating&&t.updateWhileAnimating,this.updateWhileInteracting_=void 0!==t.updateWhileInteracting&&t.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(ja)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const n=this.getDeclutter();n in t.declutter==0&&(t.declutter[n]=new lr(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(ja,t)}setStyle(t){this.style_=void 0===t?rs:t;const e=function(t){if(void 0===t)return rs;if(!t)return null;if("function"==typeof t)return t;if(t instanceof as)return t;if(!Array.isArray(t))return ds([t]);if(0===t.length)return[];const e=t.length,n=t[0];if(n instanceof as){const n=new Array(e);for(let i=0;i<e;++i){const e=t[i];if(!(e instanceof as))throw new Error("Expected a list of style instances");n[i]=e}return n}if("style"in n){const n=new Array(e);for(let i=0;i<e;++i){const e=t[i];if(!("style"in e))throw new Error("Expected a list of rules with a style property");n[i]=e}return us(n)}return ds(t)}(t);this.styleFunction_=null===t?void 0:function(t){let e;if("function"==typeof t)e=t;else{let n;Array.isArray(t)?n=t:(ri("function"==typeof t.getZIndex,"Expected an `Style` or an array of `Style`"),n=[t]),e=function(){return n}}return e}(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}},Na=class extends Va{constructor(t){super(t)}createRenderer(){return new rr(this)}},Wa="add",Ba="remove",Xa="length";class Ya extends Xe{constructor(t,e,n){super(t),this.element=e,this.index=n}}const za=class extends fn{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t??[],this.unique_)for(let t=1,e=this.array_.length;t<e;++t)this.assertUnique_(this.array_[t],t);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,n=t.length;e<n;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let n=0,i=e.length;n<i;++n)t(e[n],n,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(Xa)}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 Ya(Wa,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let n=0,i=e.length;n<i;++n)if(e[n]===t)return this.removeAt(n)}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 Ya(Ba,e,t)),e}setAt(t,e){if(t>=this.getLength())return void this.insertAt(t,e);if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const n=this.array_[t];this.array_[t]=e,this.dispatchEvent(new Ya(Ba,n,t)),this.dispatchEvent(new Ya(Wa,e,t))}updateLength_(){this.set(Xa,this.array_.length)}assertUnique_(t,e){const n=this.array_;for(let i=0,r=n.length;i<r;++i)if(n[i]===t&&i!==e)throw new Error("Duplicate item added to a unique collection")}};function Ua(t,e){return function(n,i,r,o,s){!function(t,e,n,i,r,o,s){const a=new XMLHttpRequest;a.open("GET","function"==typeof t?t(n,i,r):t,!0),"arraybuffer"==e.getType()&&(a.responseType="arraybuffer"),a.withCredentials=false,a.onload=function(t){if(!a.status||a.status>=200&&a.status<300){const t=e.getType();try{let i;"text"==t||"json"==t?i=a.responseText:"xml"==t?i=a.responseXML||a.responseText:"arraybuffer"==t&&(i=a.response),i?o(e.readFeatures(i,{extent:n,featureProjection:r}),e.readProjection(i)):s()}catch{s()}}else s()},a.onerror=s,a.send()}(t,e,n,i,r,(t,e)=>{this.addFeatures(t),void 0!==o&&o(t)},()=>{this.changed(),void 0!==s&&s()})}}function Ha(t,e){return[[-1/0,-1/0,1/0,1/0]]}function qa(t,e,n,i){const r=[];let o=[1/0,1/0,-1/0,-1/0];for(let s=0,a=n.length;s<a;++s){const a=n[s];o=v(t,e,a[0],i),r.push((o[0]+o[2])/2,(o[1]+o[3])/2),e=a[a.length-1]}return r}function $a(t,e,n,r,o,s,a){let l,h;const c=(n-e)/r;if(1===c)l=e;else if(2===c)l=e,h=o;else if(0!==c){let s=t[e],a=t[e+1],c=0;const u=[0];for(let i=e+r;i<n;i+=r){const e=t[i],n=t[i+1];c+=Math.sqrt((e-s)*(e-s)+(n-a)*(n-a)),u.push(c),s=e,a=n}const d=o*c,f=function(t,e,n){let r,o;n=n||i;let s=0,a=t.length,l=!1;for(;s<a;)r=s+(a-s>>1),o=+n(t[r],e),o<0?s=r+1:(a=r,l=!o);return l?s:~s}(u,d);f<0?(h=(d-u[-f-2])/(u[-f-1]-u[-f-2]),l=e+(-f-2)*r):l=e+f*r}a=a>1?a:2,s=s||new Array(a);for(let e=0;e<a;++e)s[e]=void 0===l?NaN:void 0===h?t[l+e]:B(t[l+e],t[l+r+e],h);return s}function Za(t,e,n,i,r,o){if(n==e)return null;let s;if(r<t[e+i-1])return o?(s=t.slice(e,e+i),s[i-1]=r,s):null;if(t[n-1]<r)return o?(s=t.slice(n-i,n),s[i-1]=r,s):null;if(r==t[e+i-1])return t.slice(e,e+i);let a=e/i,l=n/i;for(;a<l;){const e=a+l>>1;r<t[(e+1)*i-1]?l=e:a=e+1}const h=t[a*i-1];if(r==h)return t.slice((a-1)*i,(a-1)*i+i);const c=(r-h)/(t[(a+1)*i-1]-h);s=[];for(let e=0;e<i-1;++e)s.push(B(t[(a-1)*i+e],t[a*i+e],c));return s.push(r),s}const Ka=[1,0,0,1,0,0];class Ja{constructor(t,e,n,i,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=n||null,this.properties_=r,this.squaredTolerance_,this.stride_=i,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_="Point"===this.type_?_(this.flatCoordinates_):v(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=T(this.getExtent());this.flatInteriorPoints_=ia(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=function(t,e){const n=[];let i,r=0,o=0;for(let s=0,a=e.length;s<a;++s){const a=e[s],l=ha(t,r,a,2);if(void 0===i&&(i=l),l===i)n.push(e.slice(o,s+1));else{if(0===n.length)continue;n[n.length-1].push(e[o])}o=s+1,r=a}return n}(this.flatCoordinates_,this.ends_),e=qa(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=ra(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=$a(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const n=this.ends_;for(let i=0,r=n.length;i<r;++i){const r=n[i],o=$a(t,e,r,this.stride_,.5);a(this.flatMidpoints_,o),e=r}}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){const e=(t=Zt(t)).getExtent(),n=t.getWorldExtent();if(e&&n){const t=M(n)/M(e);si(Ka,n[0],n[3],t,-t,0,0,0),ni(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,Ka,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new Ja(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Ne((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const n=this.simplifiedGeometry_.getFlatCoordinates();let i;switch(this.type_){case"LineString":n.length=zn(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,n,0),i=[n.length];break;case"MultiLineString":i=[],n.length=Un(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,n,0,i);break;case"Polygon":i=[],n.length=$n(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),n,0,i)}return i&&(this.simplifiedGeometry_=new Ja(this.type_,n,i,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Ja.prototype.getFlatCoordinates=Ja.prototype.getOrientedFlatCoordinates;const Qa=Ja,tl=class{constructor(t){this.rbush_=new lr(t),this.items_={}}insert(t,e){const n={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(n),this.items_[un(e)]=n}load(t,e){const n=new Array(e.length);for(let i=0,r=e.length;i<r;i++){const r=t[i],o=e[i],s={minX:r[0],minY:r[1],maxX:r[2],maxY:r[3],value:o};n[i]=s,this.items_[un(o)]=s}this.rbush_.load(n)}remove(t){const e=un(t),n=this.items_[e];return delete this.items_[e],null!==this.rbush_.remove(n)}update(t,e){const n=this.items_[un(e)];x([n.minX,n.minY,n.maxX,n.maxY],t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(t){return t.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(t){return t.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let n;for(let i=0,r=t.length;i<r;i++)if(n=e(t[i]),n)return n;return n}isEmpty(){return Be(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return m(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]}};function el(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),e=>t):null}const nl=class extends fn{constructor(t){super(),this.projection=Zt(t.projection),this.attributions_=el(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=void 0!==t.state?t.state:"ready",this.wrapX_=void 0!==t.wrapX&&t.wrapX,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(t,n){e.viewResolver=t,e.viewRejector=n})}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_=el(t),this.changed()}setState(t){this.state_=t,this.changed()}},il="addfeature",rl="removefeature";class ol extends Xe{constructor(t,e,n){super(t),this.feature=e,this.features=n}}const sl=class extends nl{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:void 0===t.wrapX||t.wrapX}),this.on,this.once,this.un,this.loader_=Ve,this.format_=t.format||null,this.overlaps_=void 0===t.overlaps||t.overlaps,this.url_=t.url,void 0!==t.loader?this.loader_=t.loader:void 0!==this.url_&&(ri(this.format_,"`format` must be set when `url` is set"),this.loader_=Ua(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:Ha;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let n,i;this.featuresRtree_=e?new tl:null,this.loadedExtentsRtree_=new tl,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null,Array.isArray(t.features)?i=t.features:t.features&&(n=t.features,i=n.getArray()),e||void 0!==n||(n=new za(i)),void 0!==i&&this.addFeaturesInternal(i),void 0!==n&&this.bindFeaturesCollection_(n)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=un(t);if(!this.addToIndex_(e,t))return void(this.featuresCollection_&&this.featuresCollection_.remove(t));this.setupChangeEvents_(e,t);const n=t.getGeometry();if(n){const e=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(e,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new ol(il,t))}setupChangeEvents_(t,e){e instanceof Qa||(this.featureChangeKeys_[t]=[rn(e,Le,this.handleFeatureChange_,this),rn(e,nn,this.handleFeatureChange_,this)])}addToIndex_(t,e){let n=!0;if(void 0!==e.getId()){const t=String(e.getId());if(t in this.idIndex_)if(e instanceof Qa){const i=this.idIndex_[t];i instanceof Qa?Array.isArray(i)?i.push(e):this.idIndex_[t]=[i,e]:n=!1}else n=!1;else this.idIndex_[t]=e}return n&&(ri(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),n}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],n=[],i=[];for(let e=0,i=t.length;e<i;e++){const i=t[e],r=un(i);this.addToIndex_(r,i)&&n.push(i)}for(let t=0,r=n.length;t<r;t++){const r=n[t],o=un(r);this.setupChangeEvents_(o,r);const s=r.getGeometry();if(s){const t=s.getExtent();e.push(t),i.push(r)}else this.nullGeometryFeatures_[o]=r}if(this.featuresRtree_&&this.featuresRtree_.load(e,i),this.hasListener(il))for(let t=0,e=n.length;t<e;t++)this.dispatchEvent(new ol(il,n[t]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(il,function(n){e||(e=!0,t.push(n.feature),e=!1)}),this.addEventListener(rl,function(n){e||(e=!0,t.remove(n.feature),e=!1)}),t.addEventListener(Wa,t=>{e||(e=!0,this.addFeature(t.element),e=!1)}),t.addEventListener(Ba,t=>{e||(e=!0,this.removeFeature(t.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const t in this.featureChangeKeys_)this.featureChangeKeys_[t].forEach(sn);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(t=>{this.removeFeatureInternal(t)});for(const t in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[t])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new ol("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 n=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(n,function(n){const i=n.getGeometry();if(i instanceof Qa||i.intersectsCoordinate(t))return e(n)})}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(n){const i=n.getGeometry();if(i instanceof Qa||i.intersectsExtent(t)){const t=e(n);if(t)return t}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),Be(this.nullGeometryFeatures_)||a(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(t){e.push(t)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const n=function(t,e){if(e.canWrapX()){const n=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[n[0],t[1],n[2],t[3]]];L(t,e);const i=F(n);if(F(t)>i)return[[n[0],t[1],n[2],t[3]]];if(t[0]<n[0])return[[t[0]+i,t[1],n[2],t[3]],[n[0],t[1],t[2],t[3]]];if(t[2]>n[2])return[[t[0],t[1],n[2],t[3]],[n[0],t[1],t[2]-i,t[3]]]}return[t]}(t,e);return[].concat(...n.map(t=>this.featuresRtree_.getInExtent(t)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const n=t[0],i=t[1];let r=null;const o=[NaN,NaN];let s=1/0;const a=[-1/0,-1/0,1/0,1/0];return e=e||Ge,this.featuresRtree_.forEachInExtent(a,function(t){if(e(t)){const e=t.getGeometry(),l=s;if(s=e instanceof Qa?0:e.closestPointXY(n,i,o,s),s<l){r=t;const e=Math.sqrt(s);a[0]=n-e,a[1]=i-e,a[2]=n+e,a[3]=i+e}}}),r}getExtent(t){return this.featuresRtree_?.getExtent(t)??null}getFeatureById(t){const e=this.idIndex_[t.toString()];return void 0!==e?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return void 0!==e?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,n=un(e),i=e.getGeometry();if(i){const t=i.getExtent();n in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[n],this.featuresRtree_&&this.featuresRtree_.insert(t,e)):this.featuresRtree_&&this.featuresRtree_.update(t,e)}else n in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[n]=e);const r=e.getId();if(void 0!==r){const t=r.toString();this.idIndex_[t]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[t]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[n]=e;this.changed(),this.dispatchEvent(new ol("changefeature",e))}hasFeature(t){const e=t.getId();return void 0!==e?e in this.idIndex_:un(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Be(this.nullGeometryFeatures_):!this.featuresCollection_||0===this.featuresCollection_.getLength()}loadFeatures(t,e,n){const i=this.loadedExtentsRtree_,r=this.strategy_(t,e,n);for(let t=0,o=r.length;t<o;++t){const o=r[t];if(!i.forEachInExtent(o,function(t){return f(t.extent,o)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new ol("featuresloadstart"));const t=t=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new ol("featuresloadend",void 0,t))},r=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new ol("featuresloaderror"))};let s=!1;const a=this.loader_.call(this,o,e,n,e=>s||t(e),()=>s||r());a instanceof Promise?(s=!0,a.then(e=>{this.addFeatures(e),t(e)}).catch(r)):this.loader_.length<4&&(this.loading=!1),i.insert(o,{extent:o.slice()})}}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_,n=e.forEachInExtent(t,function(e){if(x(e.extent,t))return e});n&&e.remove(n)}removeFeatures(t){let e=!1;for(let n=0,i=t.length;n<i;++n)e=this.removeFeatureInternal(t[n])||e;e&&this.changed()}removeFeature(t){t&&this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=un(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t);const n=this.featureChangeKeys_[e];n?.forEach(sn),delete this.featureChangeKeys_[e];const i=t.getId();if(void 0!==i){const e=i.toString(),n=this.idIndex_[e];n===t?delete this.idIndex_[e]:Array.isArray(n)&&(n.splice(n.indexOf(t),1),1===n.length&&(this.idIndex_[e]=n[0]))}return delete this.uidIndex_[e],this.hasListener(rl)&&this.dispatchEvent(new ol(rl,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){ri(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(Ua(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}};class al extends fn{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if("function"==typeof t.getSimplifiedGeometry){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new al,e=this.geometryName_;t.setGeometryName(e);const n=this.getPropertiesInternal();if(n){const i=this.getGeometry();for(const r in n)r===e&&i?t.set(r,i.clone()):t.set(r,n[r],!0)}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_&&(sn(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=rn(t,Le,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?function(t){if("function"==typeof t)return t;let e;return Array.isArray(t)?e=t:(ri("function"==typeof t.getZIndex,"Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[t]),function(){return e}}(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){t!==this.geometryName_&&(this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_())}}const ll=al;class hl extends Wi{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(sn),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,n=t.length;e<n;++e)this.changeEventsKeys_.push(rn(t[e],Le,this.changed,this))}clone(){const t=new hl(cl(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,n,i){if(i<u(this.getExtent(),t,e))return i;const r=this.geometries_;for(let o=0,s=r.length;o<s;++o)i=r[o].closestPointXY(t,e,n,i);return i}containsXY(t,e){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)if(n[i].containsXY(t,e))return!0;return!1}computeExtent(t){y(t);const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)S(t,e[n].getExtent());return t}getGeometries(){return cl(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[];const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)e[n].getType()===this.getType()?t=t.concat(e[n].getGeometriesArrayRecursive()):t.push(e[n]);return t}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=[],n=this.geometries_;let i=!1;for(let r=0,o=n.length;r<o;++r){const o=n[r],s=o.getSimplifiedGeometry(t);e.push(s),s!==o&&(i=!0)}return i?new hl(e):(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getType(){return"GeometryCollection"}intersectsExtent(t){const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)if(e[n].intersectsExtent(t))return!0;return!1}isEmpty(){return 0===this.geometries_.length}rotate(t,e){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].rotate(t,e);this.changed()}scale(t,e,n){n||(n=T(this.getExtent()));const i=this.geometries_;for(let r=0,o=i.length;r<o;++r)i[r].scale(t,e,n);this.changed()}setGeometries(t){this.setGeometriesArray(cl(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)e[n].applyTransform(t);this.changed()}translate(t,e){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function cl(t){return t.map(t=>t.clone())}const ul=hl;class dl extends Yi{constructor(t,e){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,void 0===e||Array.isArray(t[0])?this.setCoordinates(t,e):this.setFlatCoordinates(e,t)}appendCoordinate(t){a(this.flatCoordinates,t),this.changed()}clone(){const t=new dl(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Bs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ys(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,n,i))}forEachSegment(t){return oa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){return"XYM"!=this.layout&&"XYZM"!=this.layout?null:(e=void 0!==e&&e,Za(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return Je(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return $a(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return hi(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=zn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new dl(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return sa(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=Hs(this.flatCoordinates,0,t,this.stride),this.changed()}}const fl=dl;class gl extends Yi{constructor(t,e,n){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(void 0!==e&&n)this.setFlatCoordinates(e,t),this.ends_=n;else{const e=t,n=[],i=[];for(let t=0,r=e.length;t<r;++t)a(n,e[t].getFlatCoordinates()),i.push(n.length);const r=0===e.length?this.getLayout():e[0].getLayout();this.setFlatCoordinates(r,n),this.ends_=i}}appendLineString(t){a(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new gl(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Xs(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),zs(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,n,i))}getCoordinateAtM(t,e,n){return"XYM"!=this.layout&&"XYZM"!=this.layout||0===this.flatCoordinates.length?null:(e=void 0!==e&&e,n=void 0!==n&&n,function(t,e,n,i,r,o,s){if(s)return Za(t,e,n[n.length-1],i,r,o);let a;if(r<t[i-1])return o?(a=t.slice(0,i),a[i-1]=r,a):null;if(t[t.length-1]<r)return o?(a=t.slice(t.length-i),a[i-1]=r,a):null;for(let o=0,s=n.length;o<s;++o){const s=n[o];if(e!=s){if(r<t[e+i-1])return null;if(r<=t[s-1])return Za(t,e,s,i,r,!1);e=s}}return null}(this.flatCoordinates,0,this.ends_,this.stride,t,e,n))}getCoordinates(){return Qe(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new fl(this.flatCoordinates.slice(0===t?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){const t=this.flatCoordinates,e=this.ends_,n=this.layout,i=[];let r=0;for(let o=0,s=e.length;o<s;++o){const s=e[o],a=new fl(t.slice(r,s),n);i.push(a),r=s}return i}getLength(){const t=this.ends_;let e=0,n=0;for(let i=0,r=t.length;i<r;++i)n+=hi(this.flatCoordinates,e,t[i],this.stride),e=t[i];return n}getFlatMidpoints(){const t=[],e=this.flatCoordinates;let n=0;const i=this.ends_,r=this.stride;for(let o=0,s=i.length;o<s;++o){const s=i[o];a(t,$a(e,n,s,r,.5)),n=s}return t}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=Un(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,n),new gl(e,"XY",n)}getType(){return"MultiLineString"}intersectsExtent(t){return function(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){if(sa(t,e,n[o],i,r))return!0;e=n[o]}return!1}(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=qs(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}const pl=gl;class ml extends Yi{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){a(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){const t=new ml(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){if(i<u(this.getExtent(),t,e))return i;const r=this.flatCoordinates,o=this.stride;for(let s=0,a=r.length;s<a;s+=o){const a=j(t,e,r[s],r[s+1]);if(a<i){i=a;for(let t=0;t<o;++t)n[t]=r[s+t];n.length=o}}return i}getCoordinates(){return Je(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new Qs(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){const t=this.flatCoordinates,e=this.layout,n=this.stride,i=[];for(let r=0,o=t.length;r<o;r+=n){const o=new Qs(t.slice(r,r+n),e);i.push(o)}return i}getType(){return"MultiPoint"}intersectsExtent(t){const e=this.flatCoordinates,n=this.stride;for(let i=0,r=e.length;i<r;i+=n)if(g(t,e[i],e[i+1]))return!0;return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Hs(this.flatCoordinates,0,t,this.stride),this.changed()}}const yl=ml;class _l extends Yi{constructor(t,e,n){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!n&&!Array.isArray(t[0])){const i=t,r=[],o=[];for(let t=0,e=i.length;t<e;++t){const e=i[t],n=r.length,s=e.getEnds();for(let t=0,e=s.length;t<e;++t)s[t]+=n;a(r,e.getFlatCoordinates()),o.push(s)}e=0===i.length?this.getLayout():i[0].getLayout(),t=r,n=o}void 0!==e&&n?(this.setFlatCoordinates(e,t),this.endss_=n):this.setCoordinates(t,e)}appendPolygon(t){let e;if(this.flatCoordinates){const n=this.flatCoordinates.length;a(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let t=0,i=e.length;t<i;++t)e[t]+=n}else this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();this.endss_.push(e),this.changed()}clone(){const t=this.endss_.length,e=new Array(t);for(let n=0;n<t;++n)e[n]=this.endss_[n].slice();const n=new _l(this.flatCoordinates.slice(),this.layout,e);return n.applyProperties(this),n}closestPointXY(t,e,n,i){return i<u(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(function(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];r=Xs(t,e,s,i,r),e=s[s.length-1]}return r}(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),function(t,e,n,i,r,o,s,a,l,h,c){c=c||[NaN,NaN];for(let o=0,u=n.length;o<u;++o){const u=n[o];h=zs(t,e,u,i,r,true,s,a,l,h,c),e=u[u.length-1]}return h}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,0,t,e,n,i))}containsXY(t,e){return function(t,e,n,i,r,o){if(0===n.length)return!1;for(let s=0,a=n.length;s<a;++s){const a=n[s];if(na(t,e,a,i,r,o))return!0;e=a[a.length-1]}return!1}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return function(t,e,n,i){let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o];r+=Ns(t,e,s,i),e=s[s.length-1]}return r}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),fa(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,tn(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=qa(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=ra(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new yl(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;ua(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=fa(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=function(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l],c=[];s=$n(t,e,h,i,r,o,s,c),a.push(c),e=h[h.length-1]}return s}(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,n),new _l(e,"XY",n)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(0===t)e=0;else{const n=this.endss_[t-1];e=n[n.length-1]}const n=this.endss_[t].slice(),i=n[n.length-1];if(0!==e)for(let t=0,i=n.length;t<i;++t)n[t]-=e;return new pa(this.flatCoordinates.slice(e,i),this.layout,n)}getPolygons(){const t=this.layout,e=this.flatCoordinates,n=this.endss_,i=[];let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o].slice(),a=s[s.length-1];if(0!==r)for(let t=0,e=s.length;t<e;++t)s[t]-=r;const l=new pa(e.slice(r,a),t,s);i.push(l),r=a}return i}getType(){return"MultiPolygon"}intersectsExtent(t){return function(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];if(aa(t,e,s,i,r))return!0;e=s[s.length-1]}return!1}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const n=$s(this.flatCoordinates,0,t,this.stride,this.endss_);if(0===n.length)this.flatCoordinates.length=0;else{const t=n[n.length-1];this.flatCoordinates.length=0===t.length?0:t[t.length-1]}this.changed()}}const vl=_l,xl=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=ll,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let n=e.dataProjection?Zt(e.dataProjection):this.readProjection(t);e.extent&&n&&"tile-pixels"===n.getUnits()&&(n=Zt(n),n.setWorldExtent(e.extent)),e={dataProjection:n,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return hn()}readFeature(t,e){return hn()}readFeatures(t,e){return hn()}readGeometry(t,e){return hn()}readProjection(t){return hn()}writeFeature(t,e){return hn()}writeFeatures(t,e){return hn()}writeGeometry(t,e){return hn()}};function Sl(t,e,n){const i=n?Zt(n.featureProjection):null,r=n?Zt(n.dataProjection):null;let o=t;if(i&&r&&!function(t,e){if(t===e)return!0;const n=t.getUnits()===e.getUnits();return(t.getCode()===e.getCode()||Qt(t,e)===qt)&&n}(i,r)){e&&(o=t.clone());const n=e?i:r,s=e?r:i;"tile-pixels"===n.getUnits()?o.transform(n,s):o.applyTransform(ee(n,s))}if(e&&n&&void 0!==n.decimals){const e=Math.pow(10,n.decimals),i=function(t){for(let n=0,i=t.length;n<i;++n)t[n]=Math.round(t[n]*e)/e;return t};o===t&&(o=t.clone()),o.applyTransform(i)}return o}const wl={Point:Qs,LineString:fl,Polygon:pa,MultiPoint:yl,MultiLineString:pl,MultiPolygon:vl};function Cl(t,e){const n=t.geometry;if(!n)return[];if(Array.isArray(n))return n.map(e=>Cl({...t,geometry:e})).flat();const i="MultiPolygon"===n.type?"Polygon":n.type;if("GeometryCollection"===i||"Circle"===i)throw new Error("Unsupported geometry type: "+i);const r=n.layout.length;return Sl(new Qa(i,"Polygon"===i?function(t,e,n){return Array.isArray(e[0])?(ua(t,0,e,n)||fa(t=t.slice(),0,e,n),t):(ca(t,0,e,n)||da(t=t.slice(),0,e,n),t)}(n.flatCoordinates,n.ends,r):n.flatCoordinates,n.ends?.flat(),r,t.properties||{},t.id).enableSimplifyTransformed(),!1,e)}function bl(t,e){if(!t)return null;if(Array.isArray(t)){const n=t.map(t=>bl(t,e));return new ul(n)}return Sl(new(0,wl[t.type])(t.flatCoordinates,t.layout||"XY",t.ends),!1,e)}function Il(t){if("string"==typeof t){return JSON.parse(t)||null}return null!==t?t:null}const El=class extends xl{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Il(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Il(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return hn()}readFeaturesFromObject(t,e){return hn()}readGeometry(t,e){return this.readGeometryFromObject(Il(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return hn()}readProjection(t){return this.readProjectionFromObject(Il(t))}readProjectionFromObject(t){return hn()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return hn()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return hn()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return hn()}};function Pl(t,e){if(!t)return null;let n;switch(t.type){case"Point":n=function(t){const e=t.coordinates;return{type:"Point",flatCoordinates:e,layout:Bi(e.length)}}(t);break;case"LineString":n=function(t){const e=t.coordinates,n=e.flat();return{type:"LineString",flatCoordinates:n,ends:[n.length],layout:Bi(e[0]?.length||2)}}(t);break;case"Polygon":n=function(t){const e=t.coordinates,n=[],i=e[0]?.[0]?.length;return{type:"Polygon",flatCoordinates:n,ends:qs(n,0,e,i),layout:Bi(i)}}(t);break;case"MultiPoint":n=function(t){const e=t.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:Bi(e[0]?.length||2)}}(t);break;case"MultiLineString":n=function(t){const e=t.coordinates,n=e[0]?.[0]?.length||2,i=[];return{type:"MultiLineString",flatCoordinates:i,ends:qs(i,0,e,n),layout:Bi(n)}}(t);break;case"MultiPolygon":n=function(t){const e=t.coordinates,n=[],i=e[0]?.[0]?.[0].length||2;return{type:"MultiPolygon",flatCoordinates:n,ends:$s(n,0,e,i),layout:Bi(i)}}(t);break;case"GeometryCollection":n=function(t){const e=t.geometries.map(function(t){return Pl(t)});return e}(t);break;default:throw new Error("Unsupported GeoJSON type: "+t.type)}return n}function Tl(t,e){const n=(t=Sl(t,!0,e)).getType();let i;switch(n){case"Point":i=function(t){return{type:"Point",coordinates:t.getCoordinates()}}(t);break;case"LineString":i=function(t){return{type:"LineString",coordinates:t.getCoordinates()}}(t);break;case"Polygon":i=function(t,e){let n;return e&&(n=e.rightHanded),{type:"Polygon",coordinates:t.getCoordinates(n)}}(t,e);break;case"MultiPoint":i=function(t){return{type:"MultiPoint",coordinates:t.getCoordinates()}}(t);break;case"MultiLineString":i=function(t){return{type:"MultiLineString",coordinates:t.getCoordinates()}}(t);break;case"MultiPolygon":i=function(t,e){let n;return e&&(n=e.rightHanded),{type:"MultiPolygon",coordinates:t.getCoordinates(n)}}(t,e);break;case"GeometryCollection":i=function(t,e){delete(e=Object.assign({},e)).featureProjection;return{type:"GeometryCollection",geometries:t.getGeometriesArray().map(function(t){return Tl(t,e)})}}(t,e);break;case"Circle":i={type:"GeometryCollection",geometries:[]};break;default:throw new Error("Unsupported geometry type: "+n)}return i}function Ml(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var kl="EPSG:27700",Rl=new class extends El{constructor(t){t=t||{},super(),this.dataProjection=Zt(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=Zt(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 n=null;n="Feature"===t.type?t:{type:"Feature",geometry:t,properties:null};const i=Pl(n.geometry);if(this.featureClass===Qa)return Cl({geometry:i,id:n.id,properties:n.properties},e);const r=new ll;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&r.setGeometryName(n.geometry_name),r.setGeometry(bl(i,e)),"id"in n&&r.setId(n.id),n.properties&&r.setProperties(n.properties,!0),r}readFeaturesFromObject(t,e){let n=null;if("FeatureCollection"===t.type){n=[];const i=t.features;for(let t=0,r=i.length;t<r;++t){const r=this.readFeatureFromObject(i[t],e);r&&n.push(r)}}else n=[this.readFeatureFromObject(t,e)];return n.flat()}readGeometryFromObject(t,e){return function(t,e){return bl(Pl(t),e)}(t,e)}readProjectionFromObject(t){const e=t.crs;let n;if(e)if("name"==e.type)n=Zt(e.properties.name);else{if("EPSG"!==e.type)throw new Error("Unknown SRS type");n=Zt("EPSG:"+e.properties.code)}else n=this.dataProjection;return n}writeFeatureObject(t,e){e=this.adaptOptions(e);const n={type:"Feature",geometry:null,properties:null},i=t.getId();if(void 0!==i&&(n.id=i),!t.hasProperties())return n;const r=t.getProperties(),o=t.getGeometry();return o&&(n.geometry=Tl(o,e),delete r[t.getGeometryName()]),Be(r)||(n.properties=r),n}writeFeaturesObject(t,e){e=this.adaptOptions(e);const n=[];for(let i=0,r=t.length;i<r;++i)n.push(this.writeFeatureObject(t[i],e));return{type:"FeatureCollection",features:n}}writeGeometryObject(t,e){return Tl(t,this.adaptOptions(e))}}({dataProjection:kl,featureProjection:kl}),Fl=n(610),Ol=n(682),Al={Polygon:2,LineString:1},Ll=function(t){var e,n=t.getType();return("Polygon"===n?null!==(e=t.getCoordinates()[0])&&void 0!==e?e:[]:t.getCoordinates()).slice(0,-Al[n])},Dl=function(t){var e;return null!==(e=Ll(t).at(-1))&&void 0!==e?e:null},Gl=new Map,jl=function(t,e){var n=Gl.get(t);if(n)return n;var i=document.createElement("canvas");return i.width=e.width,i.height=e.height,i.getContext("2d").putImageData(e,0,0),Gl.set(t,i),i},Vl=n(600),Nl=n(121);function Wl(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Bl(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Bl(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Bl(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var Xl={outer:Ol.F0.vertexHaloRadius+3,mid:Ol.F0.vertexHaloRadius,inner:Ol.F0.vertexRadius},Yl={outer:Ol.F0.midpointHaloRadius+3,mid:Ol.F0.midpointHaloRadius,inner:Ol.F0.midpointRadius},zl=function(t,e,n,i,r){t.beginPath(),t.arc(e,n,i,0,2*Math.PI),t.fillStyle=r,t.fill()},Ul=function(t,e,n){var i=t.outer,r=t.mid,o=t.inner;return function(t,s){var a=s.context,l=s.pixelRatio,h=Wl(t,2),c=h[0],u=h[1];a.save(),zl(a,c,u,i*l,e.editActive),zl(a,c,u,r*l,e.editHalo),zl(a,c,u,o*l,e[n]),a.restore()}},Hl=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},ql=function(t){var e=function(t){var e=new Ko({radius:Ol.F0.vertexRadius,fill:new Qo({color:t.editVertex})});return{vertexImage:e,vertexStyle:new as({image:e}),selectedVertexStyle:new as({renderer:Ul(Xl,t,"editVertex")})}}(t),n=e.vertexImage,i=e.vertexStyle,r=e.selectedVertexStyle,o=function(t){return{midpointStyle:new as({image:new Ko({radius:Ol.F0.midpointRadius,fill:new Qo({color:t.editMidpoint})})}),selectedMidpointStyle:new as({renderer:Ul(Yl,t,"editMidpoint")})}}(t),s=o.midpointStyle,a=o.selectedMidpointStyle,l=new as({stroke:new es({color:t.editStroke,width:2}),fill:new Qo({color:t.editFill})}),h=new as({stroke:new es({color:t.invalidStroke,width:2,lineDash:[2,4]})}),c=function(t){return{valid:new as({stroke:new es({color:t.editStroke,width:2}),fill:new Qo({color:t.editFill})}),invalid:new as({stroke:new es({color:t.invalidStroke,width:2,lineDash:[2,4]})}),splitValid:new as({stroke:new es({color:t.splitValid,width:2})}),splitInvalid:new as({stroke:new es({color:t.splitInvalid,width:2,lineDash:[2,4]})})}}(t),u=new yl([]),d=new as({image:n,geometry:function(t){var e=Ll(t.getGeometry());return e.length?(u.setCoordinates(e),u):null}}),f=function(t){var e=function(t){return new as({image:new Ko({radius:Ol.F0.vertexRadius+3,fill:new Qo({color:t.shapeFill}),stroke:new es({color:t.shapeStroke,width:2})})})}(t),n=new Map,i=function(t){var e=t[arguments.length>1&&void 0!==arguments[1]?arguments[1]:"symbolImageId"],i=e&&function(t){return Gl.get(t)}(e);if(!i)return null;var r=Vl.a.getSymbolDef(t),o=Wl((0,Nl.Op)(t,r),2),s=o[0],a=o[1],l=t.symbolPixelRatio||1,h="".concat(e,"|").concat(s,"|").concat(a,"|").concat(l),c=n.get(h);return c||(c=new as({image:new ji({img:i,anchor:[s,a],scale:1/l})}),n.set(h,c)),c};return{pointStyleFor:function(t){var n;return null!==(n=i(t.getProperties()))&&void 0!==n?n:e},selectedPointStyleFor:function(t){var n,r,o=t.getProperties();return null!==(n=null!==(r=i(o,"symbolSelectedImageId"))&&void 0!==r?r:i(o))&&void 0!==n?n:e}}}(t),g=f.pointStyleFor;return{vertexStyle:i,selectedVertexStyle:r,midpointStyle:s,selectedMidpointStyle:a,editFeatureStyle:l,editFeatureStyleInvalid:h,selectedPointStyleFor:f.selectedPointStyleFor,createSketchStyle:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function(n){var i=n.getGeometry().getType();if("Point"===i)return[];var r=n.get("splitter"),o=e?c.invalid:c.valid;return"valid"===r&&(o=c.splitValid),"invalid"===r&&(o=c.splitInvalid),i===t?[o,d]:[o]}},createFeatureStyle:function(){return function(e){if("Point"===e.getGeometry().getType())return[g(e)];var n=e.getProperties(),i=t.mapStyleId,r=i&&n["stroke".concat(Hl(i))]||n.stroke||t.shapeStroke,o=i&&n["fill".concat(Hl(i))]||n.fill||t.shapeFill,s=n.strokeWidth||t.strokeWidth;return[new as({stroke:new es({color:r,width:s}),fill:new Qo({color:o})})]}}}},$l=n(473);function Zl(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Jl(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Kl(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||Jl(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jl(t,e){if(t){if("string"==typeof t)return Ql(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ql(t,e):void 0}}function Ql(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var th=function(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i},eh=function(t,e,n){var i=n[0]-e[0],r=n[1]-e[1],o=i*i+r*r;if(0===o)return[e[0],e[1]];var s=Math.max(0,Math.min(1,((t[0]-e[0])*i+(t[1]-e[1])*r)/o));return[e[0]+s*i,e[1]+s*r]},nh=function(t,e){return ih(t,e)?e:t},ih=function(t,e){return t?!!e&&("edge"===t.type&&"vertex"===e.type||("vertex"!==t.type||"edge"!==e.type)&&e.distSq<t.distSq):!!e},rh=function(t,e,n,i){for(var r=null,o=i&&t.length>1?t.length-1:t.length,s=i?o:o-1,a=0;a<o;a++){var l=t[a],h=th(e,l);h<=n&&(r=nh(r,{type:"vertex",coord:[l[0],l[1]],distSq:h}))}for(var c=0;c<s;c++){var u=t[c],d=t[(c+1)%o],f=eh(e,u,d),g=th(e,f);g<=n&&(r=nh(r,{type:"edge",coord:f,distSq:g}))}return r},oh=function(t,e,n,i,r,o){for(var s=null,a=0;a<i;a++){var l=e+2*a,h=e+(a+1)%n*2,c=[t[l],t[l+1]],u=[t[h],t[h+1]],d=eh(r,c,u),f=th(r,d);f<=o&&(s=nh(s,{type:"edge",coord:d,distSq:f,seg:[c,u]}))}return s},sh=function(t,e,n){return[t>0||n?t>0?t-1:e-1:null,t<e-1||n?t<e-1?t+1:0:null]},ah=function(t,e,n,i,r,o){for(var s=i===n,a=function(n){return null===n?null:[t[e+2*n],t[e+2*n+1]]},l=null,h=0;h<n;h++){var c=a(h),u=th(r,c);if(u<=o){var d=Kl(sh(h,n,s),2),f=d[0],g=d[1],p=[a(f),a(g)];l=nh(l,{type:"vertex",coord:c,distSq:u,adjacent:p})}}return l},lh=function(t,e,n,i,r,o){var s=(n-e)/2,a=o?s:s-1;return{vertex:ah(t,e,s,a,i,r),edge:oh(t,e,s,a,i,r)}},hh={point:function(t,e,n){var i=t.getCoordinates(),r=th(e,i);return r<=n?{type:"vertex",coord:[i[0],i[1]],distSq:r}:null},lineString:function(t,e,n){return rh(t.getCoordinates(),e,n,!1)},linearRing:function(t,e,n){return rh(t.getCoordinates(),e,n,!0)},polygon:function(t,e,n){var i,r=null,o=Zl(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s=i.value;r=nh(r,rh(s,e,n,!0))}}catch(t){o.e(t)}finally{o.f()}return r},multiLineString:function(t,e,n){var i,r=null,o=Zl(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s=i.value;r=nh(r,rh(s,e,n,!1))}}catch(t){o.e(t)}finally{o.f()}return r},multiPolygon:function(t,e,n){var i,r=null,o=Zl(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s,a=Zl(i.value);try{for(a.s();!(s=a.n()).done;){var l=s.value;r=nh(r,rh(l,e,n,!0))}}catch(t){a.e(t)}finally{a.f()}}}catch(t){o.e(t)}finally{o.f()}return r}},ch=function(t,e,n){var i=t.getGeometry();if(!i)return null;var r=i.getType(),o=hh[r[0].toLowerCase()+r.slice(1)];return o?o(i,e,n):null};function uh(t){return uh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},uh(t)}function dh(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function fh(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?dh(Object(n),!0).forEach(function(e){gh(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dh(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function gh(t,e,n){return(e=function(t){var e=function(t){if("object"!=uh(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=uh(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==uh(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ph(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=yh(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function mh(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||yh(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function yh(t,e){if(t){if("string"==typeof t)return _h(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_h(t,e):void 0}}function _h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var vh=function(t,e,n){if(!e||!n)return!1;var i=mh(t.extent,4),r=i[0],o=i[1],s=i[2],a=i[3],l=function(e,n,i){return Math.min(Math.abs(e-n),Math.abs(e-i))<=t.band},h=Math.abs(e[0]-n[0])<=t.eps&&l(e[0],r,s),c=Math.abs(e[1]-n[1])<=t.eps&&l(e[1],o,a);return h||c},xh=function(){return!0===globalThis.DEBUG_SNAP_VISIBILITY},Sh=function(t,e){xh()&&console.log("[snap-candidate-found]",{type:t.type,layerId:null==e?void 0:e.id,layerType:null==e?void 0:e.type,coord:[t.coord[0].toFixed(2),t.coord[1].toFixed(2)],distSq:t.distSq.toFixed(2)})},wh=function(t){var e=t.candidate,n=t.cursorCoord,i=t.mapboxLayer,r=t.boundaryState,o=t.map,s=t.vtLayers,a=t.resolution;return function(t,e){var n,i=function(t,e){if(!t)return null;var n=t.tileGrid,i=t.viewProj,r=t.sourceProj,o=t.zoom,s=function(t){return"string"==typeof t?t:t.getCode()},a=function(t){return t?s(r)===s(i)?t:ne(t,i,r):null},l=a(e),h=n.getTileCoordForCoordAndZ(l,o),c=n.getTileCoordExtent(h),u=c[2]-c[0];return{toSource:a,anchor:l,extent:c,band:.0625*u,eps:u/4096*2}}(t,e.coord);if(!i)return!1;if("edge"===e.type){var r=mh(e.seg,2),o=r[0],s=r[1];return vh(i,i.toSource(o),i.toSource(s))}var a=mh(null!==(n=e.adjacent)&&void 0!==n?n:[],2),l=a[0],h=a[1];return vh(i,i.anchor,i.toSource(l))||vh(i,i.anchor,i.toSource(h))}(r,e)?(xh()&&console.log("[snap-filtered] tile clip artefact",e.type),!0):!("edge"!==e.type||"fill"!==(null==i?void 0:i.type)||!function(t,e,n,i,r,o){var s=t[0]-e[0],a=t[1]-e[1],l=s*s+a*a;if(l<1)return!1;var h=Math.sqrt(l),c=4*o,u=[t[0]+s/h*c,t[1]+a/h*c],d=i.getPixelFromCoordinate(u);return!!d&&!!i.forEachFeatureAtPixel(d,function(t){var e;return(null===(e=t.get("mapbox-layer"))||void 0===e?void 0:e.id)===n},{hitTolerance:2,layerFilter:function(t){return r.includes(t)}})}(e.coord,n,i.id,o,s,a)||(xh()&&console.log("[snap-filtered] invisible fill boundary"),0))};function Ch(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var bh=function(t){return function(e,n){var i,r,o=n.context,s=(r=2,function(t){if(Array.isArray(t))return t}(i=e)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(i,r)||function(t,e){if(t){if("string"==typeof t)return Ch(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ch(t,e):void 0}}(i,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=s[0],l=s[1];o.beginPath(),o.arc(a,l,10*n.pixelRatio,0,2*Math.PI),o.fillStyle=t,o.fill()}},Ih=function(t){return{vertex:new as({renderer:bh(t.snapVertex)}),edge:new as({renderer:bh(t.snapEdge)})}};const Eh="active",Ph=class extends fn{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(Eh)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Eh,t)}setMap(t){this.map_=t}};var Th=new Set(["pointermove","pointerdrag","pointerdown","pointerup","singleclick","click"]),Mh=new Set(["pointermove","pointerdrag"]),kh=function(t,e,n,i){if(null==e||!e.length)return null;var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=new Set,i=[],r=function(t){n=new Set,i=[];var e,r=ph(null!=t?t:[]);try{for(r.s();!(e=r.n()).done;){var o=e.value;"string"==typeof o?n.add(o):"function"==typeof(null==o?void 0:o.getSource)&&i.push(o)}}catch(t){r.e(t)}finally{r.f()}};return r(e),{query:function(e,r){xh()&&console.log("[snap-query]",{coord:[e[0].toFixed(2),e[1].toFixed(2)],radiusPx:r,vtLayerCount:n.size,olLayerCount:i.length});var o=t.getView().getResolution();if(!o)return null;for(var s=r*o,a=s*s,l=[e[0]-s,e[1]-s,e[0]+s,e[1]+s],h=null,c=0,u=i;c<u.length;c++){var d=u[c].getSource();if(d){var f,g=ph(d.getFeaturesInExtent(l));try{for(g.s();!(f=g.n()).done;){var p=f.value;h=nh(h,ch(p,e,a))}}catch(t){g.e(t)}finally{g.f()}}}if(n.size>0){var m=function(t){var e=[];return t.getLayers().forEach(function(t){"vectorTile"===t.get("layerType")&&e.push(t)}),e}(t),y=m.length>0?t.getPixelFromCoordinate(e):null;if(y){var _=new Map;t.forEachFeatureAtPixel(y,function(i,r){var s=i.get("mapbox-layer");if(n.has(null==s?void 0:s.id)){var l=function(t,e,n){var i=t.getType(),r=t.getFlatCoordinates(),o=null,s=null;if("Point"===i){var a=th(e,r);a<=n&&(o={type:"vertex",coord:[r[0],r[1]],distSq:a})}else if("LineString"===i){var l=lh(r,0,r.length,e,n,!1);o=l.vertex,s=l.edge}else if("Polygon"===i||"MultiLineString"===i){var h,c=0,u="Polygon"===i,d=Zl(t.getEnds());try{for(d.s();!(h=d.n()).done;){var f=h.value,g=lh(r,c,f,e,n,u);o=nh(o,g.vertex),s=nh(s,g.edge),c=f}}catch(t){d.e(t)}finally{d.f()}}return[o,s].filter(Boolean)}(i,e,a);if(l.length){_.has(r)||_.set(r,function(t,e){var n,i=t.getSource(),r=null==i?void 0:i.getTileGrid();if(!r)return null;var o=e.getView().getProjection(),s=null!==(n=i.getProjection())&&void 0!==n?n:o,a=r.getZForResolution(e.getView().getResolution(),0);return{tileGrid:r,viewProj:o,sourceProj:s,zoom:a}}(r,t));var c=_.get(r);h=function(t,e,n){var i,r=t,o=ph(e);try{for(o.s();!(i=o.n()).done;){var s=i.value;Sh(s,n.mapboxLayer),wh(fh({candidate:s},n))||(r=nh(r,s))}}catch(t){o.e(t)}finally{o.f()}return r}(h,l,{cursorCoord:e,mapboxLayer:s,boundaryState:c,map:t,vtLayers:m,resolution:o})}}},{hitTolerance:r,layerFilter:function(t){return m.includes(t)}})}}return h?{type:h.type,coord:h.coord}:null},setLayers:r}}(t,e),o=function(t,e){var n=Ih(e),i=new sl,r=new Na({source:i,style:function(t){var e;return null!==(e=n[t.get("snapType")])&&void 0!==e?e:null},zIndex:99,updateWhileAnimating:!0,updateWhileInteracting:!0});t.addLayer(r);var o=new ll,s=!1;return{show:function(t,e){o.setGeometry(new Qs(t)),o.set("snapType",e,!0),s?i.changed():(i.addFeature(o),s=!0)},hide:function(){s&&(i.clear(),s=!1)},updateColors:function(t){n=Ih(t),s&&i.changed()},remove:function(){i.clear(),t.removeLayer(r)}}}(t,n),s=!1,a=function(t,e,n,i){var r=new Ph({handleEvent:function(o){return r.getActive()&&function(t,e,n,i,r){var o=t.type;if("pointerout"!==o&&"pointerleave"!==o){if(Th.has(o)){var s=e.query(t.coordinate,i);s&&(t.coordinate=s.coord.slice()),Mh.has(o)&&r()&&(s?n.show(s.coord,s.type):n.hide())}}else n.hide()}(o,t,e,n,i),!0}});return r}(r,o,i,function(){return s});t.addInteraction(a),a.setActive(!1);var l=!1;return{snapRadius:i,apply:function(t){if(!l)return t;var e=r.query(t,i);return e?(o.show(e.coord,e.type),e.coord):(o.hide(),t)},hideIndicator:function(){o.hide()},setIndicatorActive:function(t){s=t,t||o.hide()},setActive:function(t){l=t,a.setActive(t),t||o.hide()},setSnapLayers:function(t){r.setLayers(null==t?e:t)},reattach:function(){t.removeInteraction(a),t.addInteraction(a)},updateColors:function(t){o.updateColors(t)},destroy:function(){t.removeInteraction(a),o.remove()}}};const Rh=class extends Xe{constructor(t,e,n){super(t),this.map=e,this.frameState=void 0!==n?n:null}},Fh=class extends Rh{constructor(t,e,n,i,r,o){super(t,e,r),this.originalEvent=n,this.pixel_=null,this.coordinate_=null,this.dragging=void 0!==i&&i,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()}},Oh="singleclick",Ah="pointerdrag",Lh="pointermove",Dh="pointerdown",Gh=Ge,jh=je,Vh=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},Nh=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Wh=function(t){const e=t.originalEvent;return"pointerId"in e&&e.isPrimary&&0===e.button};class Bh extends Yi{constructor(t,e,n){super(),void 0!==n&&void 0===e?this.setFlatCoordinates(n,t):(e=e||0,this.setCenterAndRadius(t,e,n))}clone(){const t=new Bh(this.flatCoordinates.slice(),void 0,this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){const r=this.flatCoordinates,o=t-r[0],s=e-r[1],a=o*o+s*s;if(a<i){if(0===a)for(let t=0;t<this.stride;++t)n[t]=r[t];else{const t=this.getRadius()/Math.sqrt(a);n[0]=r[0]+t*o,n[1]=r[1]+t*s;for(let t=2;t<this.stride;++t)n[t]=r[t]}return n.length=this.stride,a}return i}containsXY(t,e){const n=this.flatCoordinates,i=t-n[0],r=e-n[1];return i*i+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(t){const e=this.flatCoordinates,n=e[this.stride]-e[0];return m(e[0]-n,e[1]-n,e[0]+n,e[1]+n,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){if(O(t,this.getExtent())){const e=this.getCenter();return t[0]<=e[0]&&t[2]>=e[0]||t[1]<=e[1]&&t[3]>=e[1]||I(t,this.intersectsCoordinate.bind(this))}return!1}setCenter(t){const e=this.stride,n=this.flatCoordinates[e]-this.flatCoordinates[0],i=t.slice();i[e]=i[0]+n;for(let n=1;n<e;++n)i[e+n]=t[n];this.setFlatCoordinates(this.layout,i),this.changed()}setCenterAndRadius(t,e,n){this.setLayout(n,t,0),this.flatCoordinates||(this.flatCoordinates=[]);const i=this.flatCoordinates;let r=Us(i,0,t,this.stride);i[r++]=i[0]+e;for(let t=1,e=this.stride;t<e;++t)i[r++]=i[t];i.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 n=this.getCenter(),i=this.getStride();this.setCenter(ii(n,0,n.length,i,t,e,n)),this.changed()}}Bh.prototype.transform;const Xh=Bh,Yh=class extends Ph{constructor(t){super(t=t||{}),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==Ah)this.handleDragEvent(t),t.originalEvent.preventDefault();else if("pointerup"==t.type){const e=this.handleUpEvent(t);this.handlingDownUpSequence=e&&this.targetPointers.length>0}}else if(t.type==Dh){const n=this.handleDownEvent(t);this.handlingDownUpSequence=n,e=this.stopDown(n)}else t.type==Lh&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function zh(t,e){const n=t.length;return e<0?t[e+n]:e>=n?t[e-n]:t[e]}function Uh(t,e){const n=t.length;let i=Math.floor(e);const r=e-i;i>=n?i-=n:i<0&&(i+=n);let o=i+1;o>=n&&(o-=n);const s=t[i],a=s[0],l=s[1],h=t[o];return[a+(h[0]-a)*r,l+(h[1]-l)*r]}const Hh={index:-1,endIndex:NaN,closestTargetDistance:1/0};function qh(t,e,n,i){const r=t[0],o=t[1];let s=1/0,a=-1,l=NaN;for(let t=0;t<e.targets.length;++t){const n=e.targets[t],i=n.coordinates;let h,c=1/0;for(let t=0;t<i.length-1;++t){const e=ec(r,o,i[t],i[t+1]);e.squaredDistance<c&&(c=e.squaredDistance,h=t+e.along)}c<s&&(s=c,n.ring&&e.targetIndex===t&&(n.endIndex>n.startIndex?h<n.startIndex&&(h+=i.length):n.endIndex<n.startIndex&&h>n.startIndex&&(h-=i.length)),l=h,a=t)}const h=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const t=Uh(h.coordinates,l);q(n.getPixelFromCoordinate(t),n.getPixelFromCoordinate(e.startCoord))>i&&(c=!1)}if(c){const t=h.coordinates,e=t.length,n=h.startIndex,i=l;if(n<i){const r=Qh(t,n,i);Qh(t,n,i-e)<r&&(l-=e)}else{const r=Qh(t,n,i);Qh(t,n,i+e)<r&&(l+=e)}}return Hh.index=a,Hh.endIndex=l,Hh.closestTargetDistance=s,Hh}function $h(t,e){const n=[];for(let i=0;i<e.length;++i)Zh(t,e[i].getGeometry(),n);return n}function Zh(t,e,n){if(e instanceof fl)Kh(t,e.getCoordinates(),!1,n);else{if(e instanceof pl){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Kh(t,i[e],!1,n);return}if(e instanceof pa){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Kh(t,i[e],!0,n);return}if(e instanceof vl){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e){const r=i[e];for(let e=0,i=r.length;e<i;++e)Kh(t,r[e],!0,n)}return}if(e instanceof ul){const i=e.getGeometries();for(let e=0;e<i.length;++e)Zh(t,i[e],n);return}}}function Kh(t,e,n,i){const r=t[0],o=t[1];for(let t=0,s=e.length-1;t<s;++t){const s=ec(r,o,e[t],e[t+1]);if(0===s.squaredDistance){const r=t+s.along;return void i.push({coordinates:e,ring:n,startIndex:r,endIndex:r})}}}function Jh(t,e){return j(t[0],t[1],e[0],e[1])}function Qh(t,e,n){let i,r;e<n?(i=e,r=n):(i=n,r=e);const o=Math.ceil(i),s=Math.floor(r);if(o>s)return Jh(Uh(t,i),Uh(t,r));let a=0;i<o&&(a+=Jh(Uh(t,i),zh(t,o))),s<r&&(a+=Jh(zh(t,s),Uh(t,r)));for(let e=o;e<s-1;++e)a+=Jh(zh(t,e),zh(t,e+1));return a}const tc={along:0,squaredDistance:0};function ec(t,e,n,i){const r=n[0],o=n[1],s=i[0]-r,a=i[1]-o;let l=0,h=r,c=o;return 0===s&&0===a||(l=D(((t-r)*s+(e-o)*a)/(s*s+a*a),0,1),h+=s*l,c+=a*l),tc.along=l,tc.squaredDistance=X(j(t,e,h,c),10),tc}const nc="drawstart";class ic extends Xe{constructor(t,e){super(t),this.feature=e}}function rc(){const t=os();return function(e,n){return t[e.getGeometry().getType()]}}const oc=class extends Yh{constructor(t){const e=t;e.stopDown||(e.stopDown=je),super(e),this.on,this.once,this.un,this.options_=t,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=t.source?t.source:null,this.features_=t.features?t.features:null,this.snapTolerance_=t.snapTolerance?t.snapTolerance:12,this.type_=t.type,this.mode_=function(t){switch(t){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+t)}}(this.type_),this.stopClick_=!!t.stopClick,this.ignoreNextUpEvent_=!1,this.minPoints_=t.minPoints?t.minPoints:"Polygon"===this.mode_?3:2,this.maxPoints_="Circle"===this.mode_?2:t.maxPoints?t.maxPoints:1/0,this.finishCondition_=t.finishCondition?t.finishCondition:Ge,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let n=t.geometryFunction;if(!n){const t=this.mode_;if("Circle"===t)n=(t,e,n)=>{const i=e||new Xh([NaN,NaN]),r=se(t[0]),o=H(r,se(t[t.length-1]));i.setCenterAndRadius(r,Math.sqrt(o),this.geometryLayout_);const s=re();return s&&i.transform(n,s),i};else{let e;"Point"===t?e=Qs:"LineString"===t?e=fl:"Polygon"===t&&(e=pa),n=(n,i,r)=>(i?"Polygon"===t?n[0].length?i.setCoordinates([n[0].concat([n[0][0]])],this.geometryLayout_):i.setCoordinates([],this.geometryLayout_):i.setCoordinates(n,this.geometryLayout_):i=new e(n,this.geometryLayout_),i)}}this.geometryFunction_=n,this.dragVertexDelay_=void 0!==t.dragVertexDelay?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new Na({source:new sl({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:rc(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:Vh,this.freehandCondition_,t.freehand?this.freehandCondition_=Gh:this.freehandCondition_=t.freehandCondition?t.freehandCondition:Nh,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(Eh,this.updateState_)}setTrace(t){let e;e=t?!0===t?Gh:t:jh,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=Gh:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Nh}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(t){"contextmenu"===t.originalEvent.type&&t.originalEvent.preventDefault(),this.freehand_="Point"!==this.mode_&&this.freehandCondition_(t);let e=t.type===Lh,n=!0;return!this.freehand_&&this.lastDragTime_&&t.type===Ah&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&void 0!==this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&t.type===Ah&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),n=!1):this.freehand_&&t.type===Dh?n=!1:e&&this.getPointerCount()<2?(n=t.type===Lh,n&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===Ah&&void 0===this.downTimeout_)&&this.handlePointerMove_(t)):"dblclick"===t.type&&(n=!1),super.handleEvent(t)&&n}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 Fh(Lh,t.map,t.originalEvent,!1,t.frameState))},this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active)return void this.deactivateTrace_();const e=this.getMap(),n=h([e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_])]),i=this.traceSource_.getFeaturesInExtent(n);if(0===i.length)return;const r=$h(t.coordinate,i);r.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:r,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const n=t.startIndex<=t.endIndex;n===t.startIndex<=e?n&&e>t.endIndex||!n&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(n&&e<t.endIndex||!n&&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 n=0;if(t<e){const i=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),n=r-i+1}else{const i=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),n=i-r+1}n>0&&this.removeLastPoints_(n)}addTracedCoordinates_(t,e,n){if(e===n)return;const i=[];if(e<n){const r=Math.ceil(e);let o=Math.floor(n);o===n&&(o-=1);for(let e=r;e<=o;++e)i.push(zh(t.coordinates,e))}else{const r=Math.floor(e);let o=Math.ceil(n);o===n&&(o+=1);for(let e=r;e>=o;--e)i.push(zh(t.coordinates,e))}i.length&&this.appendCoordinates(i)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&q(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.snapTolerance_)return;const n=qh(t.coordinate,e,this.getMap(),this.snapTolerance_);if(e.targetIndex!==n.index){if(-1!==e.targetIndex){const t=e.targets[e.targetIndex];this.removeTracedCoordinates_(t.startIndex,t.endIndex)}const t=e.targets[n.index];this.addTracedCoordinates_(t,t.startIndex,n.endIndex)}else{const t=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(t,n.endIndex)}e.targetIndex=n.index;const i=e.targets[e.targetIndex];i.endIndex=n.endIndex;const r=Uh(i.coordinates,i.endIndex),o=this.getMap().getPixelFromCoordinate(r);t.coordinate=r,t.pixel=[Math.round(o[0]),Math.round(o[1])]}handleDragEvent(t){this.ignoreNextUpEvent_=!0,super.handleDragEvent(t)}handleUpEvent(t){let e=!0;if(0===this.getPointerCount()){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(t);const n=this.traceState_.active;if(this.ignoreNextUpEvent_||this.toggleTraceState_(t),this.shouldHandle_){const i=!this.finishCoordinate_;i&&this.startDrawing_(t.coordinate),!i&&this.freehand_?this.finishDrawing():this.freehand_||i&&"Point"!==this.mode_||(this.atFinish_(t.pixel,n)?this.finishCondition_(t)&&this.finishDrawing():this.addToDrawing_(t.coordinate)),e=!1}else this.freehand_&&this.abortDrawing()}return this.ignoreNextUpEvent_=!1,!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_,n=t.pixel,i=e[0]-n[0],r=e[1]-n[1],o=i*i+r*r;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}this.finishCoordinate_?(this.updateTrace_(t),this.modifyDrawing_(t.coordinate)):this.createOrUpdateSketchPoint_(t.coordinate.slice())}atFinish_(t,e){let n=!1;if(this.sketchFeature_){let i=!1,r=[this.finishCoordinate_];const o=this.mode_;if("Point"===o)n=!0;else if("Circle"===o)n=2===this.sketchCoords_.length;else if("LineString"===o)i=!e&&this.sketchCoords_.length>this.minPoints_;else if("Polygon"===o){const t=this.sketchCoords_;i=t[0].length>this.minPoints_,r=[t[0][0],t[0][t[0].length-2]],r=e?[t[0][0]]:[t[0][0],t[0][t[0].length-2]]}if(i){const e=this.getMap();for(let i=0,o=r.length;i<o;i++){const o=r[i],s=e.getPixelFromCoordinate(o),a=t[0]-s[0],l=t[1]-s[1],h=this.freehand_?1:this.snapTolerance_;if(n=Math.sqrt(a*a+l*l)<=h,n){this.finishCoordinate_=o;break}}}}return n}createOrUpdateSketchPoint_(t){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(t):(this.sketchPoint_=new ll(new Qs(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new ll);const e=t.getLinearRing(0);let n=this.sketchLine_.getGeometry();n?(n.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),n.changed()):(n=new fl(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(n))}startDrawing_(t){const e=this.getMap().getView().getProjection(),n=Xi(this.geometryLayout_);for(;t.length<n;)t.push(0);this.finishCoordinate_=t,"Point"===this.mode_?this.sketchCoords_=t.slice():"Polygon"===this.mode_?(this.sketchCoords_=[[t.slice(),t.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[t.slice(),t.slice()],this.sketchLineCoords_&&(this.sketchLine_=new ll(new fl(this.sketchLineCoords_)));const i=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new ll,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(i),this.updateSketchFeatures_(),this.dispatchEvent(new ic(nc,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),n=this.sketchFeature_.getGeometry(),i=e.getView().getProjection(),r=Xi(this.geometryLayout_);let o,s;for(;t.length<r;)t.push(0);"Point"===this.mode_?s=this.sketchCoords_:"Polygon"===this.mode_?(o=this.sketchCoords_[0],s=o[o.length-1],this.atFinish_(e.getPixelFromCoordinate(t))&&(t=this.finishCoordinate_.slice())):(o=this.sketchCoords_,s=o[o.length-1]),s[0]=t[0],s[1]=t[1],this.geometryFunction_(this.sketchCoords_,n,i),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(t),"Polygon"===n.getType()&&"Polygon"!==this.mode_?this.createOrUpdateCustomSketchLine_(n):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(t){const e=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection();let i,r;const o=this.mode_;return"LineString"===o||"Circle"===o?(this.finishCoordinate_=t.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(t.slice()),this.geometryFunction_(r,e,n)):"Polygon"===o&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(t.slice()),i&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,n)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),i?this.finishDrawing():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection(),i=this.mode_;for(let r=0;r<t;++r){let t;if("LineString"===i||"Circle"===i){if(t=this.sketchCoords_,t.splice(-2,1),t.length>=2){this.finishCoordinate_=t[t.length-2].slice();const e=this.finishCoordinate_.slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}this.geometryFunction_(t,e,n),"Polygon"===e.getType()&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if("Polygon"===i){t=this.sketchCoords_[0],t.splice(-2,1);const i=this.sketchLine_.getGeometry();if(t.length>=2){const e=t[t.length-2].slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}i.setCoordinates(t),this.geometryFunction_(this.sketchCoords_,e,n)}if(1===t.length){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return null;let e=this.sketchCoords_;const n=t.getGeometry(),i=this.getMap().getView().getProjection();return"LineString"===this.mode_?(e.pop(),this.geometryFunction_(e,n,i)):"Polygon"===this.mode_&&(e[0].pop(),this.geometryFunction_(e,n,i),e=n.getCoordinates()),"MultiPoint"===this.type_?t.setGeometry(new yl([e])):"MultiLineString"===this.type_?t.setGeometry(new pl([e])):"MultiPolygon"===this.type_&&t.setGeometry(new vl([e])),this.dispatchEvent(new ic("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 ic("drawabort",t))}appendCoordinates(t){const e=this.mode_,n=!this.sketchFeature_;let i;if(n&&this.startDrawing_(t[0]),"LineString"===e||"Circle"===e)i=this.sketchCoords_;else{if("Polygon"!==e)return;i=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[]}n&&i.shift(),i.pop();for(let e=0;e<t.length;e++)this.addToDrawing_(t[e]);const r=t[t.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(t){const e=t.getGeometry();this.sketchFeature_=t,this.sketchCoords_=e.getCoordinates();const n=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=n.slice(),this.sketchCoords_.push(n.slice()),this.sketchPoint_=new ll(new Qs(n)),this.updateSketchFeatures_(),this.dispatchEvent(new ic(nc,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)}};var sc=function(t,e){var n=t.getPixelFromCoordinate(e);return n?{x:n[0],y:n[1]}:null},ac=function(t,e){return Math.hypot(t.x-e.x,t.y-e.y)},lc=function(t,e,n,i){var r=t.getPixelFromCoordinate(e);return r?t.getCoordinateFromPixel([r[0]+n,r[1]+i]):e};function hc(t){return function(t){if(Array.isArray(t))return cc(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return cc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?cc(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function cc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var uc=function(t){var e=t.drawInteraction,n=t.mapProvider,i=t.snap,r=t.canFinish,o=t.canPlace,s=null,a=null,l=function(){s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,a=null};e.on("drawstart",function(t){return l(t.feature)}),e.on("drawend",function(){return l()}),e.on("drawabort",function(){return l()});var h=function(){var t=n.getCenter();return i?i.apply(t):t};return{placeVertex:function(){var t=h();if(null==i||i.hideIndicator(),s){var n=s.getGeometry(),l=n.getCoordinates(),c="Polygon"===n.getType()?l[0]||[]:l,u=function(t){var e=t.drawInteraction,n=t.canFinish,i=t.geom,r=t.sketchCoords,o=t.coord,s=t.lastPlacedCoord;if(s&&s[0]===o[0]&&s[1]===o[1])return null!=n&&n()&&e.finishDrawing(),{handled:!0,lastPlacedCoord:null};var a=e.getMap();if(function(t,e,n,i){if("Polygon"!==i||n.length<4)return!1;var r=sc(t,e),o=sc(t,n[0]);return!(!r||!o)&&ac(r,o)<12}(a,o,r,i.getType()))return e.finishDrawing(),{handled:!0,lastPlacedCoord:s};var l=Dl(i);if(l){var h=a.getPixelFromCoordinate(l),c=a.getPixelFromCoordinate(o);if(h&&c){var u=h[0]-c[0],d=h[1]-c[1];if(u*u+d*d<4)return{handled:!0,lastPlacedCoord:o}}}return{handled:!1,lastPlacedCoord:s}}({drawInteraction:e,canFinish:r,geom:n,sketchCoords:c,coord:t,lastPlacedCoord:a});if(a=u.lastPlacedCoord,u.handled)return}o&&!o(t)||(e.appendCoordinates([t]),a=t)},updateRubberbanding:function(){if(s){var t=s.getGeometry();t.getCoordinates().length&&function(t,e){if("LineString"===t.getType()){var n=hc(t.getCoordinates());n[n.length-1]=e,t.setCoordinates(n)}else if("Polygon"===t.getType()){var i=t.getCoordinates().map(function(t,n){if(0!==n)return t;var i=hc(t);return i[i.length-1]=e,i});t.setCoordinates(i)}}(t,h())}else i&&i.apply(n.getCenter())},clearLastCoord:function(){a=null}}},dc=n(195),fc=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),gc=function(t,e){t&&(["touch","keyboard"].includes(e)?t.fixAtCenter():t.hide())},pc=function(t){var e=t.container,n=t.addVertexButtonId,i=t.olView,r=t.onUndo,o=t.getInterfaceType,s=t.setInterfaceType,a=t.clearLastCoord,l=t.updateRubberbanding,h=t.placeVertex,c=function(){("mouse"!==o()||null!=i&&i.getAnimating())&&l()};null==i||i.on("change:center",c);var u=function(t){e.contains(document.activeElement)&&(fc.has(t.key)?s("keyboard"):("Enter"===t.key&&(t.preventDefault(),s("keyboard"),h()),"z"===t.key&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),null==r||r())))},d=function(t){n&&t.target.closest("#".concat(n))&&h()},f=function(t){"touch"!==t.pointerType&&(s("mouse"),a())},g=function(){s("touch")},p=function(){"mouse"!==o()&&l()};return globalThis.addEventListener("keydown",u),globalThis.addEventListener("click",d),e.addEventListener("pointerdown",f),e.addEventListener("touchstart",g,{passive:!0}),e.addEventListener("pointermove",p),globalThis.addEventListener("keyup",dc.z,{capture:!0}),{destroy:function(){null==i||i.un("change:center",c),globalThis.removeEventListener("keydown",u),globalThis.removeEventListener("click",d),e.removeEventListener("pointerdown",f),e.removeEventListener("touchstart",g),e.removeEventListener("pointermove",p),globalThis.removeEventListener("keyup",dc.z,{capture:!0})}}},mc=n(360),yc="styleschanged",_c=n(520),vc=n(9),xc=n(788),Sc=n(715),wc=function(t,e){return!!e&&Ll(e.getGeometry()).length>=vc.n8[t]},Cc=function(t,e,n,i){return function(r){if(!Vh(r))return!1;var o=n();if(!i(r.coordinate))return!1;if(!o||wc(e,o))return!0;var s=Dl(o.getGeometry());if(!s)return!0;var a=t.getPixelFromCoordinate(s);if(!a)return!0;var l=r.pixel[0]-a[0],h=r.pixel[1]-a[1];return l*l+h*h>4}},bc={Polygon:2,LineString:1},Ic=function(t){var e=t.map,n=t.manager,i=t.options,r=i.geometryType,o=i.featureId,s=i.properties,a=void 0===s?{}:s,l=null,h=!1,c=n.styles.createSketchStyle(r),u=function(t,e){var n=0,i=function(n,i){setTimeout(function(){var r,o,s,a,l,h,c=e();c&&t.emit(mc.k.GEOMETRY_CHANGE,{feature:(r=t.store,o=c,s=r.toGeoJSON(o),a=s.geometry.type,l=bc[a],h=("Polygon"===a?s.geometry.coordinates[0]:s.geometry.coordinates).slice(0,-l),{type:"Feature",geometry:"Polygon"===a?{type:"Polygon",coordinates:[h]}:{type:"LineString",coordinates:h},properties:s.properties}),phase:n,vertexIndex:i})},0)};return{resetCount:function(){n=0},updateVertexCount:function(){var r=e();if(r){var o=Ll(r.getGeometry()).length;t.emit(mc.k.VERTEX_CHANGE,{numVertices:o}),o>n&&i("commit-add",o-1),n=o}},emitUndoValidation:function(){var t=e();t&&i("commit-delete",Ll(t.getGeometry()).length)}}}(n,function(){return l}),d=u.updateVertexCount,f=u.resetCount,g=u.emitUndoValidation,p=function(t){var e=t.manager,n=t.geometryType,i=t.getSketch;return function(t){var r=i(),o=(0,_c.$b)({placed:r?Ll(r.getGeometry()):[],point:t,geometryType:n,onGeometryChange:e._geometryValidator});return o.valid||e.emit(mc.k.PLACEMENT_BLOCKED,o.blocked),o.valid}}({manager:n,geometryType:r,getSketch:function(){return l}}),m=new oc({type:r,style:function(t){return c(t)},stopClick:!0,snapTolerance:Ol.vf.snapRadius,condition:Cc(e,r,function(){return l},p),finishCondition:function(){return!1!==n._geometryValid}});e.addInteraction(m);var y=(0,xc.De)({onChange:function(t){h=t,c=n.styles.createSketchStyle(r,h),m.overlay_.changed()}}),_=(0,Sc.O)({onStrokeChange:function(t,e){return y.set(t,e)},onPlaceChange:function(t,e){return n.emit(mc.k.CAN_PLACE_CHANGE,{canPlace:!t,reason:e})}}),v=_c.dV[r],x=function(){c=n.styles.createSketchStyle(r,h),m.overlay_.changed()};n.on(yc,x),m.overlay_.updateWhileAnimating_=!0,function(t,e){var n=e.manager,i=e.featureId,r=e.properties,o=e.onStart,s=e.onSketchChange;t.on("drawstart",function(t){o(t.feature),t.feature.getGeometry().on("change",s)}),t.on("drawend",function(t){return function(t,e,n,i){e.setId(String(n)),e.setProperties(i),t.store.source.addFeature(e),t.emit(mc.k.CREATE,t.store.toGeoJSON(e))}(n,t.feature,i,r)}),t.on("drawabort",function(){n.emit(mc.k.CANCEL)})}(m,{manager:n,featureId:o,properties:a,onStart:function(t){l=t,f()},onSketchChange:function(){d(),function(){if(l){var t=function(t,e){var n,i=e.getGeometry(),r=i.getCoordinates(),o="Polygon"===t?null!==(n=r[0])&&void 0!==n?n:[]:r;return{feature:{type:"Feature",geometry:"Polygon"===t?{type:"Polygon",coordinates:[o]}:{type:"LineString",coordinates:o}},numVertices:Ll(i).length}}(r,l),e=t.feature,i=t.numVertices;_.update({feature:e,context:{mode:v},numVertices:i,onGeometryChange:n._geometryValidator})}}()}});var S=function(t){var e=t.drawInteraction,n=t.options,i=t.geometryType,r=t.getSketch,o=t.updateVertexCount,s=t.emitUndoValidation,a=t.canPlaceVertex;return function(t){var e,n=t.drawInteraction,i=t.options,r=i.container,o=i.addVertexButtonId,s=i.mapProvider,a=i.snap,l=i.onUndo,h=i.canFinish,c=i.canPlace,u=i.crossHair,d=null!==(e=i.interfaceType)&&void 0!==e?e:"mouse",f=function(){return d},g=uc({drawInteraction:n,mapProvider:s,snap:a,canFinish:h,canPlace:c}),p=n.getMap(),m=null==p?void 0:p.getView(),y=pc({container:r,addVertexButtonId:o,olView:m,onUndo:l,getInterfaceType:f,setInterfaceType:function(t){d=t,gc(u,t)},clearLastCoord:g.clearLastCoord,updateRubberbanding:g.updateRubberbanding,placeVertex:g.placeVertex});gc(u,d),u&&(u.activate=g.placeVertex);var _=function(){null!=m&&m.getAnimating()&&g.updateRubberbanding()};return null==p||p.on("postrender",_),{getInterfaceType:f,setInterfaceType:function(t){d=t,gc(u,t),"mouse"!==t&&g.updateRubberbanding()},destroy:function(){(null==u?void 0:u.activate)===g.placeVertex&&(u.activate=null),y.destroy(),null==p||p.un("postrender",_)}}}({drawInteraction:e,options:{container:n.container,interfaceType:n.interfaceType,addVertexButtonId:n.addVertexButtonId,mapProvider:n.mapProvider,snap:n.snap,crossHair:n.crossHair,onUndo:function(){e.removeLastPoint(),o(),s()},canFinish:function(){return wc(i,r())},canPlace:a}})}({drawInteraction:m,options:i,geometryType:r,getSketch:function(){return l},updateVertexCount:d,emitUndoValidation:g,canPlaceVertex:p});return function(t){var e=t.map,n=t.manager,i=t.drawInteraction,r=t.input,o=t.geometryType,s=t.getSketch,a=t.updateVertexCount,l=t.emitUndoValidation,h=t.onStylesChanged,c=t.clearSketch,u=t.liveStroke,d=t.liveDrawChecks;return{done:function(){wc(o,s())&&i.finishDrawing()},cancel:function(){i.abortDrawing()},undo:function(){i.removeLastPoint(),a(),l()},setInvalid:t.setInvalid,setInterfaceType:function(t){r.setInterfaceType(t)},setDrawingPreviewProperty:function(t,e){var n=s();n&&(n.set(t,e),i.overlay_.changed())},destroy:function(){u.destroy(),d.destroy(),n.off(yc,h),n.emit(mc.k.INTERFACE_TYPE_CHANGE,{interfaceType:r.getInterfaceType()}),r.destroy(),e.removeInteraction(i),c()}}}({map:e,manager:n,drawInteraction:m,input:S,geometryType:r,getSketch:function(){return l},updateVertexCount:d,emitUndoValidation:g,onStylesChanged:x,clearSketch:function(){l=null},setInvalid:function(t){return y.set(t)},liveStroke:y,liveDrawChecks:_})};function Ec(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||Tc(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Pc(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Tc(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Tc(t,e){if(t){if("string"==typeof t)return Mc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mc(t,e):void 0}}function Mc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var kc=function(t){if(null==t||!t.coordinates)return[];switch(t.type){case"LineString":return t.coordinates;case"Polygon":return t.coordinates.flatMap(function(t){return t.slice(0,-1)});case"MultiLineString":return t.coordinates.flat(1);case"MultiPolygon":return t.coordinates.flatMap(function(t){return t.flatMap(function(t){return t.slice(0,-1)})});default:return[]}},Rc=function(t){if(null==t||!t.coordinates)return[];var e=[],n=0;switch(t.type){case"LineString":e.push({start:0,length:t.coordinates.length,path:[],closed:!1});break;case"Polygon":t.coordinates.forEach(function(t,i){var r=t.length-1;e.push({start:n,length:r,path:[i],closed:!0}),n+=r});break;case"MultiLineString":t.coordinates.forEach(function(t,i){e.push({start:n,length:t.length,path:[i],closed:!1}),n+=t.length});break;case"MultiPolygon":t.coordinates.forEach(function(t,i){t.forEach(function(t,r){var o=t.length-1;e.push({start:n,length:o,path:[i,r],closed:!0}),n+=o})})}return e},Fc=function(t,e){var n,i=Pc(t);try{for(i.s();!(n=i.n()).done;){var r=n.value;if(e>=r.start&&e<r.start+r.length)return{segment:r,localIdx:e-r.start}}}catch(t){i.e(t)}finally{i.f()}return null},Oc=function(t,e){var n,i=t.coordinates,r=Pc(e);try{for(r.s();!(n=r.n()).done;)i=i[n.value]}catch(t){r.e(t)}finally{r.f()}return i},Ac=function(t){var e=kc(t),n=Rc(t);if(!e.length||!n.length)return[];var i,r=[],o=Pc(n);try{for(o.s();!(i=o.n()).done;)for(var s=i.value,a=s.closed?s.length:s.length-1,l=0;l<a;l++){var h=s.start+l,c=s.start+(l+1)%s.length,u=Ec(e[h],2),d=u[0],f=u[1],g=Ec(e[c],2),p=g[0],m=g[1];r.push([(d+p)/2,(f+m)/2])}}catch(t){o.e(t)}finally{o.f()}return r},Lc=function(t){var e=t.map,n=t.manager,i=t.store,r=t.olFeature,o=t.interfaceType,s=t.layers,a=s.vertexLayer,l=s.midpointLayer,h=s.activeLayer,c={olFeature:r,selectedVertexIndex:-1,selectedVertexType:null,vertices:[],midpoints:[],interfaceType:null!=o?o:"mouse"},u={onDeselect:null,onUpdate:null},d=function(){var t=r.getGeometry();return{type:t.getType(),coordinates:t.getCoordinates()}},f=function(){var t=d();c.vertices=kc(t),c.midpoints=Ac(t),l.update(t),a.update(t),h.update(c)},g=function(t,e,n){return function(i,r){i&&setTimeout(function(){t.emit(mc.k.GEOMETRY_CHANGE,{feature:e.toGeoJSON(n),phase:i,vertexIndex:r})},0)}}(n,i,r),p=function(){return f()};return r.getGeometry().on("change",p),{state:c,getState:function(){return c},setState:function(t){var i,r;Object.assign(c,t),void 0!==t.selectedVertexIndex&&function(t,e){var n,i=e.midpointLayer,r=e.activeLayer,o=e.manager,s=e.hooks;e.vertexLayer.setSelected("vertex"===t.selectedVertexType?t.selectedVertexIndex:-1),i.setSelected("midpoint"===t.selectedVertexType?t.selectedVertexIndex-t.vertices.length:-1),t.selectedVertexIndex<0&&(null===(n=s.onDeselect)||void 0===n||n.call(s)),r.update(t),o.emit(mc.k.VERTEX_SELECTION,{index:"vertex"===t.selectedVertexType?t.selectedVertexIndex:-1,numVertices:t.vertices.length})}(c,{vertexLayer:a,midpointLayer:l,activeLayer:h,manager:n,hooks:u}),void 0!==t.vertices&&(r=d(),l.update(r),a.update(r),c.midpoints=l.getCoords(),h.update(c),null===(i=u.onUpdate)||void 0===i||i.call(u),e.render())},syncGeom:function(){f(),n.emit(mc.k.VERTEX_CHANGE,{numVertices:c.vertices.length}),n.emit(mc.k.UPDATE,i.toGeoJSON(r))},emitGeometryValidation:g,updateLayersFromGeom:f,setHooks:function(t){var e=t.onDeselect,n=t.onUpdate;return Object.assign(u,{onDeselect:e,onUpdate:n})},destroy:function(){r.getGeometry().un("change",p)}}};const Dc=[0,0,0,0],Gc=[],jc="modifyend";function Vc(t,e,n){let i;switch(e){case"LineString":i=t;break;case"MultiLineString":case"Polygon":i=t[n[0]];break;case"MultiPolygon":i=t[n[1]][n[0]]}return i}class Nc extends Xe{constructor(t,e,n){super(t),this.features=e,this.mapBrowserEvent=n}}function Wc(t,e){return t.index-e.index}function Bc(t,e,n){const i=e.geometry;if("Circle"===i.getType()){let r=i;if(1===e.index){const e=re();e&&(r=r.clone().transform(e,n));const i=H(r.getCenter(),se(t)),o=Math.sqrt(i)-r.getRadius();return o*o}}const r=se(t);return Gc[0]=se(e.segment[0]),Gc[1]=se(e.segment[1]),function(t,e){return H(t,z(t,e))}(r,Gc)}function Xc(t,e,n){const i=e.geometry;if("Circle"===i.getType()&&1===e.index){let e=i;const r=re();return r&&(e=e.clone().transform(r,n)),oe(e.getClosestPoint(se(t)))}const r=se(t);return Gc[0]=se(e.segment[0]),Gc[1]=se(e.segment[1]),oe(z(r,Gc))}function Yc(){const t=os();return function(e,n){return t.Point}}const zc=class extends Yh{constructor(t){if(super(t),this.handleSourceAdd_=this.handleSourceAdd_.bind(this),this.handleSourceRemove_=this.handleSourceRemove_.bind(this),this.handleExternalCollectionAdd_=this.handleExternalCollectionAdd_.bind(this),this.handleExternalCollectionRemove_=this.handleExternalCollectionRemove_.bind(this),this.handleFeatureChange_=this.handleFeatureChange_.bind(this),this.on,this.once,this.un,this.condition_=t.condition?t.condition:Wh,this.defaultDeleteCondition_=function(t){return function(t){const e=t.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey}(t)&&function(t){return t.type==Oh}(t)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:Gh,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new tl,this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Na({source:new sl({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:Yc(),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.traceSource_=t.traceSource||t.source||null,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSegments_=null,this.hitDetection_=null,this.filterFunctionWasSupplied_=null!=t.filter,this.filter_=t.filter?t.filter:()=>!0,this.coordinatesEqual_=t.sharedVerticesEqual?t.sharedVerticesEqual:U,!t.features&&!t.source)throw new Error("The modify interaction requires features collection or a source");let e;t.features?(e=t.features.getArray(),t.features.addEventListener(Wa,this.handleExternalCollectionAdd_),t.features.addEventListener(Ba,this.handleExternalCollectionRemove_),this.featuresCollection_=t.features):t.source&&(e=t.source.getFeatures(),t.source.addEventListener(il,this.handleSourceAdd_),t.source.addEventListener(rl,this.handleSourceRemove_),this.source_=t.source),e.forEach(t=>{t.addEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(nn,this.handleFeatureChange_)}),t.hitDetection&&(this.hitDetection_=t.hitDetection),this.features_=[],e.filter(this.filter_).forEach(t=>this.addFeature_(t)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=void 0===t.snapToPointer?!this.hitDetection_:t.snapToPointer}setTrace(t){let e;e=t?!0===t?Gh:t:jh,this.traceCondition_=e}addFeature_(t){this.features_.push(t);const e=t.getGeometry();if(e){const n=this.SEGMENT_WRITERS_[e.getType()];n&&n(t,e)}const n=this.getMap();n&&n.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastCoordinate_)}willModifyFeatures_(t,e){if(!this.featuresBeingModified_){this.featuresBeingModified_=new za;const n=this.featuresBeingModified_.getArray();for(let t=0,i=e.length;t<i;++t){const i=e[t].feature;i&&!n.includes(i)&&this.featuresBeingModified_.push(i)}0===this.featuresBeingModified_.getLength()?this.featuresBeingModified_=null:this.dispatchEvent(new Nc("modifystart",this.featuresBeingModified_,t))}}removeFeature_(t){const e=this.features_.indexOf(t);this.features_.splice(e,1),this.removeFeatureSegmentData_(t),this.vertexFeature_&&0===this.features_.length&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}removeFeatureSegmentData_(t){const e=this.rBush_,n=[];e.forEach(function(e){t===e.feature&&n.push(e)});for(let t=n.length-1;t>=0;--t){const i=n[t];for(let t=this.dragSegments_.length-1;t>=0;--t)this.dragSegments_[t][0]===i&&this.dragSegments_.splice(t,1);e.remove(i)}}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){const e=t.feature;e&&this.externalAddFeatureHandler_(e)}handleSourceRemove_(t){const e=t.feature;e&&this.externalRemoveFeatureHandler_(e)}handleExternalCollectionAdd_(t){const e=t.element;e&&this.externalAddFeatureHandler_(e)}handleExternalCollectionRemove_(t){const e=t.element;e&&this.externalRemoveFeatureHandler_(e)}externalAddFeatureHandler_(t){t.addEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(nn,this.handleFeatureChange_),this.filter_(t)&&this.addFeature_(t)}externalRemoveFeatureHandler_(t){t.removeEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(nn,this.handleFeatureChange_),this.removeFeature_(t)}handleFeatureChange_(t){if(!this.changingFeature_){const e=t.target;this.removeFeature_(e),this.filter_(e)&&this.addFeature_(e)}}writePointGeometry_(t,e){const n=e.getCoordinates(),i={feature:t,geometry:e,segment:[n,n]};this.rBush_.insert(e.getExtent(),i)}writeMultiPointGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i],o={feature:t,geometry:e,depth:[i],index:i,segment:[r,r]};this.rBush_.insert(e.getExtent(),o)}}writeLineStringGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length-1;i<r;++i){const r=n.slice(i,i+2),o={feature:t,geometry:e,index:i,segment:r};this.rBush_.insert(h(r),o)}}writeMultiLineStringGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i];for(let n=0,o=r.length-1;n<o;++n){const o=r.slice(n,n+2),s={feature:t,geometry:e,depth:[i],index:n,segment:o};this.rBush_.insert(h(o),s)}}}writePolygonGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i];for(let n=0,o=r.length-1;n<o;++n){const o=r.slice(n,n+2),s={feature:t,geometry:e,depth:[i],index:n,segment:o};this.rBush_.insert(h(o),s)}}}writeMultiPolygonGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i];for(let n=0,o=r.length;n<o;++n){const o=r[n];for(let r=0,s=o.length-1;r<s;++r){const s=o.slice(r,r+2),a={feature:t,geometry:e,depth:[n,i],index:r,segment:s};this.rBush_.insert(h(s),a)}}}}writeCircleGeometry_(t,e){const n=e.getCenter(),i={feature:t,geometry:e,index:0,segment:[n,n]},r={feature:t,geometry:e,index:1,segment:[n,n]},o=[i,r];i.featureSegments=o,r.featureSegments=o,this.rBush_.insert(_(n),i);let s=e;const a=re();if(a&&this.getMap()){const t=this.getMap().getView().getProjection();s=s.clone().transform(a,t),s=ya(s).transform(t,a)}this.rBush_.insert(s.getExtent(),r)}writeGeometryCollectionGeometry_(t,e){const n=e.getGeometriesArray();for(let e=0;e<n.length;++e){const i=n[e];(0,this.SEGMENT_WRITERS_[i.getType()])(t,i)}}createOrUpdateVertexFeature_(t,e,n,i){let r=this.vertexFeature_;return r?r.getGeometry().setCoordinates(t):(r=new ll(new Qs(t)),this.vertexFeature_=r,this.overlay_.getSource().addFeature(r)),r.set("features",e),r.set("geometries",n),r.set("existing",i),r}handleEvent(t){if(!t.originalEvent)return!0;let e;return this.lastPointerEvent_=t,t.map.getView().getInteracting()||t.type!=Lh||this.handlingDownUpSequence||this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(e=!(t.type!=Oh||!this.ignoreNextSingleClick_)||this.removePoint()),t.type==Oh&&(this.ignoreNextSingleClick_=!1),super.handleEvent(t)&&!e}findInsertVerticesAndUpdateDragSegments_(t){if(this.handlePointerAtPixel_(t),this.dragSegments_.length=0,this.featuresBeingModified_=null,!this.vertexFeature_)return;const e=this.getMap().getView().getProjection(),n=[],i=this.vertexFeature_.getGeometry().getCoordinates(),r=h([i]),o=this.rBush_.getInExtent(r),s={};o.sort(Wc);for(let r=0,a=o.length;r<a;++r){const a=o[r],l=a.segment;let h=un(a.geometry);const c=a.depth;if(c&&(h+="-"+c.join("-")),s[h]||(s[h]=new Array(2)),"Circle"===a.geometry.getType()&&1===a.index){const n=Xc(t,a,e);this.coordinatesEqual_(n,i)&&!s[h][0]&&(this.dragSegments_.push([a,0]),s[h][0]=a);continue}if(!this.coordinatesEqual_(l[0],i)||s[h][0])if(!this.coordinatesEqual_(l[1],i)||s[h][1])!(un(l)in this.vertexSegments_)||s[h][0]||s[h][1]||n.push(a);else{if(s[h][0]&&0===s[h][0].index){let t=a.geometry.getCoordinates();switch(a.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":t=t[c[1]];case"Polygon":if(a.index!==t[c[0]].length-2)continue}}this.dragSegments_.push([a,1]),s[h][1]=a}else this.dragSegments_.push([a,0]),s[h][0]=a}return n}deactivateTrace_(){this.traceState_={active:!1}}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&q(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.pixelTolerance_)return;const n=qh(t.coordinate,e,t.map,this.pixelTolerance_);if(!(-1===e.targetIndex&&Math.sqrt(n.closestTargetDistance)/t.map.getView().getResolution()>this.pixelTolerance_)){if(e.targetIndex!==n.index){if(-1!==e.targetIndex){const t=e.targets[e.targetIndex];this.removeTracedCoordinates_(t.startIndex,t.endIndex)}else for(const t of this.traceSegments_){const e=t[0],n=e.geometry,i=t[1],r=n.getCoordinates();Vc(r,n.getType(),e.depth).splice(e.index+i,1),n.setCoordinates(r),0===i&&(e.index-=1)}const t=e.targets[n.index];this.addTracedCoordinates_(t,t.startIndex,n.endIndex)}else{const t=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(t,n.endIndex)}e.targetIndex=n.index,e.targets[e.targetIndex].endIndex=n.endIndex}}getTraceCandidates_(t){const e=this.getMap(),n=this.pixelTolerance_,i=h([e.getCoordinateFromPixel([t.pixel[0]-n,t.pixel[1]+n]),e.getCoordinateFromPixel([t.pixel[0]+n,t.pixel[1]-n])]);return this.traceSource_.getFeaturesInExtent(i)}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active)return this.deactivateTrace_(),void(this.traceSegments_=null);const e=this.getTraceCandidates_(t);if(0===e.length)return;const n=$h(t.coordinate,e);n.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:n,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const n=t.startIndex<=t.endIndex;n===t.startIndex<=e?n&&e>t.endIndex||!n&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(n&&e<t.endIndex||!n&&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 n=0;if(t<e){const i=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),n=r-i+1}else{const i=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),n=i-r+1}if(n>0)for(const t of this.traceSegments_){const e=t[0],i=e.geometry,r=t[1];let o=t[0].index+1;1===r&&(o-=n);const s=i.getCoordinates();Vc(s,i.getType(),e.depth).splice(o,n),i.setCoordinates(s),1===r&&(e.index-=n)}}addTracedCoordinates_(t,e,n){if(e===n)return;const i=[];if(e<n){const r=Math.ceil(e);let o=Math.floor(n);o===n&&(o-=1);for(let e=r;e<=o;++e)i.push(zh(t.coordinates,e))}else{const r=Math.floor(e);let o=Math.ceil(n);o===n&&(o+=1);for(let e=r;e>=o;--e)i.push(zh(t.coordinates,e))}if(i.length)for(const t of this.traceSegments_){const e=t[0],n=e.geometry,r=t[1],o=e.index+1;0===r&&i.reverse();const s=n.getCoordinates();Vc(s,n.getType(),e.depth).splice(o,0,...i),n.setCoordinates(s),1===r&&(e.index+=i.length)}}updateGeometry_(t,e){const n=e[0],i=n.depth;let r;const o=n.segment,s=n.geometry,a=e[1],l=s.getStride();for(let e=2;e<l;++e)t[e]=o[a][e];switch(t.length=l,s.getType()){case"Point":r=t,o[0]=t,o[1]=t;break;case"MultiPoint":r=s.getCoordinates(),r[n.index]=t,o[0]=t,o[1]=t;break;case"LineString":r=s.getCoordinates(),r[n.index+a]=t,o[a]=t;break;case"MultiLineString":r=s.getCoordinates(),r[i[0]][n.index+a]=t,o[a]=t;break;case"Polygon":{r=s.getCoordinates();const e=r[i[0]],l=n.index+a;e[l][0]===t[0]&&e[l][1]===t[1]?r=null:(e[l]=t,0===l?e[e.length-1]=t:l===e.length-1&&(e[0]=t)),o[a]=t;break}case"MultiPolygon":{r=s.getCoordinates();const e=r[i[1]][i[0]],l=n.index+a;e[l][0]===t[0]&&e[l][1]===t[1]?r=null:(e[l]=t,0===l?e[e.length-1]=t:l===e.length-1&&(e[0]=t)),o[a]=t;break}case"Circle":const e=s;if(o[0]=t,o[1]=t,0===n.index)this.changingFeature_=!0,e.setCenter(t),this.changingFeature_=!1;else{this.changingFeature_=!0;const n=this.getMap().getView().getProjection();let i=q(se(e.getCenter()),se(t));const r=re();if(r){const t=e.clone().transform(r,n);t.setRadius(i),i=t.transform(n,r).getRadius()}e.setRadius(i),this.changingFeature_=!1}}r&&this.setGeometryCoordinates_(s,r)}handleDragEvent(t){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(t,this.dragSegments_.map(([t])=>t));const e=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],n=[],i=[],r=this.traceState_.active&&!this.traceSegments_?this.traceState_.startCoord:null;if(r){this.traceSegments_=[];for(const e of this.dragSegments_)q(z(r,e[0].segment),r)/t.map.getView().getResolution()<1&&this.traceSegments_.push(e)}for(let t=0,r=this.dragSegments_.length;t<r;++t){const r=this.dragSegments_[t],o=r[0],s=o.feature;n.includes(s)||n.push(s);const a=o.geometry;i.includes(a)||i.push(a),this.updateGeometry_(e,r)}this.updateTrace_(t),this.createOrUpdateVertexFeature_(e,n,i,!0)}handleDownEvent(t){if(!this.condition_(t))return!1;const e=t.coordinate,n=this.findInsertVerticesAndUpdateDragSegments_(e);if(n?.length&&this.insertVertexCondition_(t)&&(this.willModifyFeatures_(t,n),this.vertexFeature_)){const t=this.vertexFeature_.getGeometry().getCoordinates();for(let e=n.length-1;e>=0;--e)this.insertVertex_(n[e],t);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(t){for(let e=this.dragSegments_.length-1;e>=0;--e){const n=this.dragSegments_[e][0],i=n.geometry;if("Circle"===i.getType()){const e=i,r=e.getCenter(),o=n.featureSegments[0],s=n.featureSegments[1];o.segment[0]=r,o.segment[1]=r,s.segment[0]=r,s.segment[1]=r,this.rBush_.update(_(r),o);let a=e;const l=re();if(l){const e=t.map.getView().getProjection();a=a.clone().transform(l,e),a=ya(a).transform(e,l)}this.rBush_.update(a.getExtent(),s)}else this.rBush_.update(h(n.segment),n)}return this.featuresBeingModified_&&(this.toggleTraceState_(t),this.dispatchEvent(new Nc(jc,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastCoordinate_=t.coordinate,this.handlePointerAtPixel_(this.lastCoordinate_)}handlePointerAtPixel_(t){const e=this.getMap(),n=e.getPixelFromCoordinate(t),i=e.getView().getProjection(),r=function(e,n){return Bc(t,e,i)-Bc(t,n,i)};let o,s;if(this.hitDetection_){const t="object"==typeof this.hitDetection_?t=>t===this.hitDetection_:void 0;e.forEachFeatureAtPixel(n,(t,e,n)=>{n&&"Point"===n.getType()&&(n=new Qs(oe(n.getCoordinates())));const i=n||t.getGeometry();if(i&&"Point"===i.getType()&&t instanceof ll&&this.features_.includes(t)){s=i;const e=t.getGeometry().getFlatCoordinates().slice(0,2);o=[{feature:t,geometry:s,segment:[e,e]}]}return!0},{layerFilter:t})}if(!o){const n=ae(c(le(_(t,Dc)),e.getView().getResolution()*this.pixelTolerance_,Dc));o=this.rBush_.getInExtent(n)}if(o&&o.length>0){const a=o.sort(r)[0],l=a.segment;let h=Xc(t,a,i);const c=e.getPixelFromCoordinate(h);let u=q(n,c);if(s||u<=this.pixelTolerance_){const n={};if(n[un(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-t[0],this.delta_[1]=h[1]-t[1]),"Circle"===a.geometry.getType()&&1===a.index)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const t=e.getPixelFromCoordinate(l[0]),i=e.getPixelFromCoordinate(l[1]),r=H(c,t),s=H(c,i);if(u=Math.sqrt(Math.min(r,s)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_))return void(this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null));this.snappedToVertex_&&(h=r>s?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const d={};d[un(a.geometry)]=!0;for(let t=1,e=o.length;t<e;++t){const e=o[t].segment;if(!(this.coordinatesEqual_(l[0],e[0])&&this.coordinatesEqual_(l[1],e[1])||this.coordinatesEqual_(l[0],e[1])&&this.coordinatesEqual_(l[1],e[0])))break;{const i=un(o[t].geometry);i in d||(d[i]=!0,n[un(e)]=!0)}}}return void(this.vertexSegments_=n)}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(t,e){const n=t.segment,i=t.feature,r=t.geometry,o=t.depth,s=t.index;let a;for(;e.length<r.getStride();)e.push(0);switch(r.getType()){case"MultiLineString":case"Polygon":a=r.getCoordinates(),a[o[0]].splice(s+1,0,e);break;case"MultiPolygon":a=r.getCoordinates(),a[o[1]][o[0]].splice(s+1,0,e);break;case"LineString":a=r.getCoordinates(),a.splice(s+1,0,e);break;default:return!1}this.setGeometryCoordinates_(r,a);const l=this.rBush_;l.remove(t),this.updateSegmentIndices_(r,s,o,1);const c={segment:[n[0],e],feature:i,geometry:r,depth:o,index:s};l.insert(h(c.segment),c),this.dragSegments_.push([c,1]);const u={segment:[e,n[1]],feature:i,geometry:r,depth:o,index:s+1};return l.insert(h(u.segment),u),this.dragSegments_.push([u,0]),!0}updatePointer_(t){return t&&this.findInsertVerticesAndUpdateDragSegments_(t),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){const t=this.vertexFeature_?.getGeometry().getCoordinates();return t?oe(t,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_)return!1;if(this.vertexFeature_.get("geometries").every(t=>"Circle"===t.getType()||t.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(h([t])).some(({segment:e})=>this.coordinatesEqual_(e[0],t)||this.coordinatesEqual_(e[1],t))}removePoint(t){if(t&&(t=se(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=Ah){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([t])=>t));const e=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Nc(jc,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,e}return!1}removeVertex_(){const t=this.dragSegments_,e={};let n,i,r,o,s,a,l,c,u,d,f,g=!1;for(s=t.length-1;s>=0;--s)r=t[s],d=r[0],f=un(d.feature),d.depth&&(f+="-"+d.depth.join("-")),f in e||(e[f]={}),0===r[1]?(e[f].right=d,e[f].index=d.index):1==r[1]&&(e[f].left=d,e[f].index=d.index+1);for(f in e){switch(u=e[f].right,l=e[f].left,a=e[f].index,c=a-1,d=void 0!==l?l:u,c<0&&(c=0),o=d.geometry,i=o.getCoordinates(),n=i,g=!1,o.getType()){case"MultiLineString":i[d.depth[0]].length>2&&(i[d.depth[0]].splice(a,1),g=!0);break;case"LineString":i.length>2&&(i.splice(a,1),g=!0);break;case"MultiPolygon":n=n[d.depth[1]];case"Polygon":n=n[d.depth[0]],n.length>4&&(a==n.length-1&&(a=0),n.splice(a,1),g=!0,0===a&&(n.pop(),n.push(n[0]),c=n.length-1))}if(g){this.setGeometryCoordinates_(o,i);const e=[];if(void 0!==l&&(this.rBush_.remove(l),e.push(l.segment[0])),void 0!==u&&(this.rBush_.remove(u),e.push(u.segment[1])),void 0!==l&&void 0!==u){const t={depth:d.depth,feature:d.feature,geometry:d.geometry,index:c,segment:e};this.rBush_.insert(h(t.segment),t)}this.updateSegmentIndices_(o,a,d.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return g}canInsertPoint(){if(!this.vertexFeature_)return!1;if(this.vertexFeature_.get("geometries").every(t=>"Circle"===t.getType()||t.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(h([t])).some(({segment:e})=>!(this.coordinatesEqual_(e[0],t)||this.coordinatesEqual_(e[1],t)))}insertPoint(t){const e=t?se(t,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return!!e&&this.findInsertVerticesAndUpdateDragSegments_(e).reduce((t,n)=>t||this.insertVertex_(n,e),!1)}setGeometryCoordinates_(t,e){this.changingFeature_=!0,t.setCoordinates(e),this.changingFeature_=!1}updateSegmentIndices_(t,e,n,i){this.rBush_.forEachInExtent(t.getExtent(),function(r){r.geometry===t&&(void 0===n||void 0===r.depth||l(r.depth,n))&&r.index>e&&(r.index+=i)})}disposeInternal(){if(super.disposeInternal(),this.featuresCollection_){this.featuresCollection_.removeEventListener(Wa,this.handleExternalCollectionAdd_),this.featuresCollection_.removeEventListener(Ba,this.handleExternalCollectionRemove_);for(const t of this.featuresCollection_.getArray())t.removeEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(nn,this.handleFeatureChange_)}else if(this.source_){this.source_.removeEventListener(il,this.handleSourceAdd_),this.source_.removeEventListener(rl,this.handleSourceRemove_);for(const t of this.source_.getFeatures())t.removeEventListener(Le,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(nn,this.handleFeatureChange_)}}};var Uc=function(t,e,n,i){var r,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:12;return null!==(r=function(t,e,n){var i=-1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:12;return e.forEach(function(e,o){var s=sc(t,e);if(s){var a=ac(s,n);a<r&&(r=a,i=o)}}),i>=0?{index:i,type:"vertex"}:null}(t,e,i,o))&&void 0!==r?r:function(t,e,n,i){var r=-1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:12;return e.forEach(function(e,i){var s=sc(t,e);if(s){var a=ac(s,n);a<o&&(o=a,r=i)}}),r>=0?{index:i+r,type:"midpoint"}:null}(t,n,i,e.length,o)};function Hc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var qc=function(t,e){if(e.length>t.length){var n=e.findIndex(function(e,n){var i;return e[0]!==(null===(i=t[n])||void 0===i?void 0:i[0])});return{type:"insert_vertex",vertexIndex:Math.max(0,n)}}if(e.length===t.length){var i=e.findIndex(function(e,n){return e[0]!==t[n][0]||e[1]!==t[n][1]});if(i>=0)return{type:"move_vertex",vertexIndex:i,previousCoord:t[i]}}return null},$c=function(t){var e=t.map,n=t.olFeature,i=t.getState,r=t.onModifyEnd,o=t.condition,s=null!=o?o:function(t){var e=t.map,n=t.getState;return function(t){var i=n(),r=i.interfaceType,o=i.vertices,s=i.midpoints;if("touch"===r)return!1;var a=e.getEventPixel(t.originalEvent);return null!==Uc(e,o,s,{x:a[0],y:a[1]})}}({map:e,getState:i}),a=new zc({features:new za([n]),style:function(){return[]},pixelTolerance:12,condition:s});e.addInteraction(a);var l=null;return a.on("modifystart",function(){"touch"!==i().interfaceType&&(l=i().vertices.map(function(t){return function(t){if(Array.isArray(t))return Hc(t)}(e=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return Hc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hc(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var e}))}),a.on("modifyend",function(){if("touch"!==i().interfaceType){var t=l;l=null,r(t)}}),{destroy:function(){e.removeInteraction(a)}}},Zc=n(722);function Kc(t){return function(t){if(Array.isArray(t))return Qc(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Jc(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Jc(t,e){if(t){if("string"==typeof t)return Qc(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qc(t,e):void 0}}function Qc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var tu=function(t,e,n,i){var r=n-i,o=e[r];if(!o)return null;var s,a=t.getGeometry(),l={type:a.getType(),coordinates:a.getCoordinates()},h=0,c=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Jc(t))){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==e.return||e.return()}finally{if(s)throw r}}}}(Rc(l));try{for(c.s();!(s=c.n()).done;){var u=s.value,d=u.closed?u.length:u.length-1;if(r<h+d){var f=r-h+1,g=u.start+f;return Oc(l,u.path).splice(f,0,Kc(o)),a.setCoordinates(l.coordinates),{insertedIndex:g}}h+=d}}catch(t){c.e(t)}finally{c.f()}return null},eu=function(t,e,n){var i=t.getGeometry(),r={type:i.getType(),coordinates:i.getCoordinates()},o=Rc(r),s=Fc(o,e);if(s){var a=Oc(r,s.segment.path);a[s.localIdx]=Kc(n),s.segment.closed&&0===s.localIdx&&(a[a.length-1]=Kc(n)),i.setCoordinates(r.coordinates)}};function nu(t){return nu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nu(t)}function iu(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function ru(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?iu(Object(n),!0).forEach(function(e){ou(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):iu(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function ou(t,e,n){return(e=function(t){var e=function(t){if("object"!=nu(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=nu(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nu(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function su(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var au=function(t){var e=t.container,n={dragStartCoord:null,dragStartIndex:null,vertexTouchDelta:null,targetTouchDelta:null,tapStart:null},i=ru(ru({},t),{},{drag:n}),r=function(t){return function(t,e){var n,i=e.map,r=e.targetEl,o=e.cssToOl,s=e.getState,a=e.drag,l=t.touches[0],h=(0,Zc.mt)(t.target);if(a.tapStart={x:l.clientX,y:l.clientY,time:Date.now(),onTarget:h},h){var c=s(),u=c.selectedVertexIndex,d=c.vertices[u];if(d){var f=i.getEventPixel({clientX:l.clientX,clientY:l.clientY}),g=sc(i,d),p=getComputedStyle(r),m=o({x:Number.parseFloat(p.left),y:Number.parseFloat(p.top)});a.dragStartCoord=function(t){if(Array.isArray(t))return su(t)}(n=d)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||function(t,e){if(t){if("string"==typeof t)return su(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?su(t,e):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),a.dragStartIndex=u,a.vertexTouchDelta={x:f[0]-g.x,y:f[1]-g.y},a.targetTouchDelta={x:f[0]-m.x,y:f[1]-m.y},t.preventDefault()}}}(t,i)},o=function(t){return function(t,e){var n=e.map,i=e.targetEl,r=e.olToCSS,o=e.getState,s=e.setState,a=e.snap,l=e.drag,h=e.moveCoord;if((0,Zc.mt)(t.target)&&null!=l.dragStartIndex){t.preventDefault();var c=n.getEventPixel({clientX:t.touches[0].clientX,clientY:t.touches[0].clientY}),u=function(t,e){return t.getCoordinateFromPixel([e.x,e.y])}(n,{x:c[0]-l.vertexTouchDelta.x,y:c[1]-l.vertexTouchDelta.y}),d=a?a.apply(u):u,f=o(),g=f.olFeature,p=f.vertices;g&&(h(g,l.dragStartIndex,d),s({vertices:p.map(function(t,e){return e===l.dragStartIndex?d:t})}),(0,Zc.Ox)(i,r({x:c[0]-l.targetTouchDelta.x,y:c[1]-l.targetTouchDelta.y})))}}(t,i)},s=function(t){return function(t,e){var n=e.getState,i=e.onVertexMoved,r=e.drag,o=e.updateTargetPosition;if(null==r.dragStartIndex)return function(t,e){var n=e.map,i=e.getState,r=e.onTap,o=e.drag;if(o.tapStart&&!o.tapStart.onTarget&&0!==t.changedTouches.length){var s=t.changedTouches[0],a=Date.now()-o.tapStart.time;if(Math.hypot(s.clientX-o.tapStart.x,s.clientY-o.tapStart.y)<10&&a<400){var l=n.getEventPixel({clientX:s.clientX,clientY:s.clientY}),h=i();null==r||r(Uc(n,h.vertices,h.midpoints,{x:l[0],y:l[1]},24)),t.preventDefault()}}}(t,e),void(r.tapStart=null);r.tapStart=null,n().vertices[r.dragStartIndex]&&r.dragStartCoord&&i({vertexIndex:r.dragStartIndex,previousCoord:r.dragStartCoord}),r.dragStartCoord=null,r.dragStartIndex=null,r.vertexTouchDelta=null,r.targetTouchDelta=null,o(),t.preventDefault()}(t,i)};return e.addEventListener("touchstart",r,{passive:!1}),e.addEventListener("touchmove",o,{passive:!1}),e.addEventListener("touchend",s,{passive:!1}),e.addEventListener("touchcancel",s,{passive:!1}),{isDragging:function(){return null!=n.dragStartIndex},destroy:function(){e.removeEventListener("touchstart",r),e.removeEventListener("touchmove",o),e.removeEventListener("touchend",s),e.removeEventListener("touchcancel",s)}}},lu=function(t){var e=t.map,n=t.container,i=t.getState,r=t.setState,o=t.onVertexMoved,s=t.onTap,a=t.colors,l=t.snap,h=t.moveCoord,c=void 0===h?eu:h,u=(0,Zc.DD)(n);(0,Zc.ZP)(u,a);var d={scale:1,ox:0,oy:0},f=function(t){return{x:t.x*d.scale+d.ox,y:t.y*d.scale+d.oy}},g=function(){var t=e.getViewport(),i=t.getBoundingClientRect(),r=n.getBoundingClientRect(),o=t.offsetWidth>0?i.width/t.offsetWidth:1,s=n.offsetWidth>0?r.width/n.offsetWidth:1;Object.assign(d,{scale:o/s,ox:(i.left-r.left)/s,oy:(i.top-r.top)/s})},p=function(){var t=i(),n=t.selectedVertexIndex,r=t.vertices,o=t.interfaceType;if(n<0||!r[n]||"touch"!==o)(0,Zc.$X)(u);else{var s=sc(e,r[n]);s?(0,Zc.Ox)(u,f(s)):(0,Zc.$X)(u)}},m=au({container:n,map:e,targetEl:u,olToCSS:f,cssToOl:function(t){return{x:(t.x-d.ox)/d.scale,y:(t.y-d.oy)/d.scale}},getState:i,setState:r,onVertexMoved:o,onTap:s,snap:l,moveCoord:c,updateTargetPosition:p}),y=function(){var t=i(),e=t.selectedVertexIndex,n=t.interfaceType;e>=0&&!m.isDragging()&&"touch"===n&&p()};e.on("postrender",y);var _=function(){g(),e.once("postrender",p)};return e.on("change:size",_),g(),{updateTargetPosition:p,updateColors:function(t){(0,Zc.ZP)(u,t)},hide:function(){(0,Zc.$X)(u)},destroy:function(){e.un("change:size",_),e.un("postrender",y),m.destroy(),(0,Zc.$X)(u)}}},hu=n(107);function cu(t){return function(t){if(Array.isArray(t))return du(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||uu(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function uu(t,e){if(t){if("string"==typeof t)return du(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?du(t,e):void 0}}function du(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var fu=function(t){var e=t.map,n=t.snap,i=t.getState,r=t.setState,o=t.onInserted,s=t.onVertexMoved,a=t.moveCoord,l=void 0===a?eu:a,h={start:null,index:null},c=function(t,o){var s=i(),a=s.selectedVertexIndex,h=s.vertices,c=s.olFeature;if(!c||a<0||!h[a])return null;var u=h[a],d=lc(e,u,t,o),f=n?n.apply(d):d,g=function(t,e,n,i,r,o,s){if(!t)return r;var a=[i[0]-n[0],i[1]-n[1]],l=[r[0]-n[0],r[1]-n[1]],h=Math.pow(a[0],2)+Math.pow(a[1],2);if(h>0&&(l[0]*a[0]+l[1]*a[1])/h<.5){var c=t.snapRadius+1;return lc(e,n,0===o?0:Math.sign(o)*c,0===s?0:Math.sign(s)*c)}return r}(n,e,u,d,f,t,o);return n&&g!==f&&n.hideIndicator(),l(c,a,g),r({vertices:h.map(function(t,e){return e===a?g:t})}),{previousCoord:u,vertexIndex:a}};return{nudge:function(t){var s=i(),a=s.selectedVertexIndex,l=s.selectedVertexType,u=s.vertices,d=s.midpoints,f=s.olFeature;if(f){var g=t.shiftKey?Ol.WQ.nudgeAmount:Ol.WQ.stepAmount,p=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||uu(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}({ArrowUp:[0,-g],ArrowDown:[0,g],ArrowLeft:[-g,0],ArrowRight:[g,0]}[t.key],2),m=p[0],y=p[1];"midpoint"!==l?a<0||!u[a]||(h.start||(h.start=cu(u[a]),h.index=a),c(m,y)):function(t,s,a,l,c,u){var d=tu(t,s,a,l.length);if(d){o({insertedIndex:d.insertedIndex});var f=i().vertices,g=f[d.insertedIndex];if(g){h.start=cu(g),h.index=d.insertedIndex;var p=lc(e,g,c,u),m=n?n.apply(p):p;eu(t,d.insertedIndex,m),r({selectedVertexIndex:d.insertedIndex,selectedVertexType:"vertex",vertices:f.map(function(t,e){return e===d.insertedIndex?m:t})})}}}(f,d,a,u,m,y)}},keyMove:h,nudgeByDelta:function(t,e,n){var i=n?Ol.WQ.stepAmount:Ol.WQ.nudgeAmount,r=c(t*i,e*i);r&&s({vertexIndex:r.vertexIndex,previousCoord:r.previousCoord})}}};function gu(t){return function(t){if(Array.isArray(t))return pu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return pu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pu(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var mu=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),yu=new Set(["INPUT","TEXTAREA","BUTTON","SELECT","A"]),_u=function(t){var e=t.map,n=t.getState,i=t.setState,r=t.nudge,o=t.keyMove,s=t.onUndo,a=t.onKeyboardActive,l=t.isFocused,h=function(t){if(null==a||a()," "===t.key)t.preventDefault(),n().selectedVertexIndex<0&&function(t,e,n){var i=e(),r=i.vertices,o=i.midpoints;if(r.length){var s=sc(t,t.getView().getCenter());if(s){var a=[].concat(gu(r.map(function(e){return sc(t,e)})),gu(o.map(function(e){return sc(t,e)}))).filter(Boolean).map(function(t){return[t.x,t.y]}),l=(0,hu.c)([s.x,s.y],a,void 0);n({selectedVertexIndex:l,selectedVertexType:l<r.length?"vertex":"midpoint"})}}}(e,n,i);else if(mu.has(t.key))!function(t){t.altKey?(t.preventDefault(),t.stopPropagation(),function(t,e,n,i){var r=n(),o=r.selectedVertexIndex,s=r.vertices,a=r.midpoints;if(s.length){var l,h=[].concat(gu(s),gu(a)).map(function(t){return sc(e,t)}).filter(Boolean).map(function(t){return[t.x,t.y]}),c=o>=0?h[o]:(l=sc(e,e.getView().getCenter()))?[l.x,l.y]:null;if(c){var u=(0,hu.c)(c,h,t);i({selectedVertexIndex:u,selectedVertexType:u<s.length?"vertex":"midpoint"})}}}(t.key,e,n,i)):n().selectedVertexIndex>=0&&(t.preventDefault(),t.stopPropagation(),r(t))}(t);else if("z"===t.key&&(t.metaKey||t.ctrlKey)){var o,l=null===(o=document.activeElement)||void 0===o?void 0:o.tagName;yu.has(l)||(t.preventDefault(),t.stopPropagation(),s())}};return function(t){l()||("Escape"===t.key&&n().selectedVertexIndex>=0?(t.preventDefault(),o.start=null,o.index=null,i({selectedVertexIndex:-1,selectedVertexType:null})):h(t))}},vu=function(t){var e,n=t.map,i=t.snap,r=t.getState,o=t.setState,s=t.onVertexMoved,a=t.onInserted,l=t.onDeleted,h=t.onUndo,c=t.onKeyboardActive,u=t.moveCoord,d=fu({map:n,snap:i,getState:r,setState:o,onInserted:a,onVertexMoved:s,moveCoord:u}),f=d.nudge,g=d.keyMove,p=d.nudgeByDelta,m=null!==(e=n.getViewport().closest('[role="application"]'))&&void 0!==e?e:n.getViewport(),y=function(){return function(t){var e=document.activeElement;return!(!e||e===document.body)&&!t.contains(e)&&(yu.has(e.tagName)||e.isContentEditable||e.hasAttribute("tabindex"))}(m)},_=_u({map:n,getState:r,setState:o,nudge:f,keyMove:g,onUndo:h,onKeyboardActive:c,isFocused:y}),v=function(t){var e=t.getState,n=t.keyMove,i=t.onVertexMoved,r=t.onDeleted,o=t.isFocused;return function(t){o()||(e().selectedVertexIndex>=0&&(0,dc.z)(t),mu.has(t.key)&&n.start&&null!=n.index&&(i({vertexIndex:n.index,previousCoord:n.start}),n.start=null,n.index=null),"Delete"===t.key&&r())}}({getState:r,keyMove:g,onVertexMoved:s,onDeleted:l,isFocused:y});return globalThis.addEventListener("keydown",_,{capture:!0}),globalThis.addEventListener("keyup",v,{capture:!0}),{nudgeByDelta:p,destroy:function(){globalThis.removeEventListener("keydown",_,{capture:!0}),globalThis.removeEventListener("keyup",v,{capture:!0})}}};function xu(t){return function(t){if(Array.isArray(t))return wu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Su(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Su(t,e){if(t){if("string"==typeof t)return wu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wu(t,e):void 0}}function wu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var Cu=function(t,e){switch(e.type){case"move_vertex":return function(t,e){var n=e.vertexIndex,i=e.previousCoord,r=t.getGeometry(),o={type:r.getType(),coordinates:r.getCoordinates()},s=Rc(o),a=Fc(s,n);if(!a)return-1;var l=Oc(o,a.segment.path);return l[a.localIdx]=xu(i),a.segment.closed&&0===a.localIdx&&(l[l.length-1]=xu(i)),r.setCoordinates(o.coordinates),n}(t,e);case"insert_vertex":return function(t,e){var n=e.vertexIndex,i=t.getGeometry(),r={type:i.getType(),coordinates:i.getCoordinates()},o=Rc(r),s=Fc(o,n);if(s){var a=Oc(r,s.segment.path);a.splice(s.localIdx,1),s.segment.closed&&(a[a.length-1]=xu(a[0])),i.setCoordinates(r.coordinates)}return-1}(t,e);case"delete_vertex":return function(t,e){var n=e.vertexIndex,i=e.deletedCoord,r=t.getGeometry(),o={type:r.getType(),coordinates:r.getCoordinates()},s=Rc(o),a=Fc(s,n);if(!a){var l,h=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Su(t))){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==e.return||e.return()}finally{if(s)throw r}}}}(s);try{for(h.s();!(l=h.n()).done;){var c=l.value;if(n===c.start+c.length){a={segment:c,localIdx:c.length};break}}}catch(t){h.e(t)}finally{h.f()}}if(!a)return-1;var u=Oc(o,a.segment.path);return u.splice(a.localIdx,0,xu(i)),a.segment.closed&&(u[u.length-1]=xu(u[0])),r.setCoordinates(o.coordinates),n}(t,e);default:return-1}},bu="touch",Iu="vertex",Eu="commit-move",Pu="commit-insert",Tu="commit-delete",Mu={move_vertex:Eu,insert_vertex:Pu,delete_vertex:Tu},ku={move_vertex:Eu,insert_vertex:Tu,delete_vertex:Pu},Ru=function(t){var e=t.map,n=t.manager,i=t.options,r=i.featureId,o=i.container,s=i.interfaceType,a=i.deleteVertexButtonId,l=i.snap,h=n.store,c=n.undoStack,u=h.getOL(r);if(!u)return null;var d=u.getStyle(),f=function(t,e){var n=e,i=-1,r=new sl,o=new Na({source:r,style:function(t){return t.get("midpointIndex")===i?null:[n]},zIndex:101});return t.addLayer(o),{update:function(t){r.clear();var e=Ac(t).map(function(t,e){var n=new ll({geometry:new Qs(t)});return n.set("midpointIndex",e),n});r.addFeatures(e)},setSelected:function(t){i=t,r.changed()},updateStyle:function(t){n=t,r.changed()},getCoords:function(){return r.getFeatures().sort(function(t,e){return t.get("midpointIndex")-e.get("midpointIndex")}).map(function(t){return t.getGeometry().getCoordinates()})},remove:function(){r.clear(),t.removeLayer(o)}}}(e,n.styles.midpointStyle),g=function(t,e){var n=e,i=-1,r=new sl,o=new Na({source:r,style:function(t){return t.get("vertexIndex")===i?null:[n]},zIndex:102});return t.addLayer(o),{update:function(t){r.clear(),kc(t).forEach(function(t,e){var n=new ll({geometry:new Qs(t)});n.set("vertexIndex",e),r.addFeature(n)})},setSelected:function(t){i=t,r.changed()},updateStyle:function(t){n=t,r.changed()},remove:function(){r.clear(),t.removeLayer(o)}}}(e,n.styles.vertexStyle),p=function(t,e){var n=new sl,i=new Na({source:n,zIndex:103});return t.addLayer(i),{update:function(t){if(n.clear(),!(t.selectedVertexIndex<0)){var i,r,o,s,a,l,h=(r=(i=t).selectedVertexIndex,o=i.selectedVertexType,s=i.vertices,a=i.midpoints,l=e(),"vertex"===o?{coord:s[r],style:l.selectedVertexStyle}:"midpoint"===o?{coord:a[r-s.length],style:l.selectedMidpointStyle}:{coord:null,style:null}),c=h.coord,u=h.style;if(c){var d=new ll({geometry:new Qs(c)});d.setStyle(u),n.addFeature(d)}}},remove:function(){n.clear(),t.removeLayer(i)}}}(e,function(){return n.styles}),m=Lc({map:e,manager:n,store:h,olFeature:u,interfaceType:s,layers:{vertexLayer:g,midpointLayer:f,activeLayer:p}}),y=m.state,_=m.getState,v=m.setState,x=m.syncGeom,S=m.emitGeometryValidation,w=$c({map:e,olFeature:u,getState:_,onModifyEnd:function(t){x();var e=t&&qc(t,y.vertices);e&&(c.push(e),S(Mu[e.type],e.vertexIndex),v({selectedVertexIndex:e.vertexIndex,selectedVertexType:Iu}))}});x();var C={vertexLayer:g,midpointLayer:f,activeLayer:p},b=function(t){var e=t.map,n=t.manager,i=t.olFeature,r=!1;i.setStyle(function(){return r?n.styles.editFeatureStyleInvalid:n.styles.editFeatureStyle});var o=(0,xc.De)({onChange:function(t,i){r=t,e.render(),n.emit(mc.k.VALIDITY_CHANGE,{valid:!t,reason:i})}}),s=function(){var t,e,r=i.getGeometry(),s=r.getType(),a=r.getCoordinates(),l="Polygon"===s?Math.max(0,(null!==(t=null===(e=a[0])||void 0===e?void 0:e.length)&&void 0!==t?t:1)-1):a.length;o.update({feature:{type:"Feature",geometry:{type:s,coordinates:a}},context:{mode:"edit_vertex"},numVertices:l,onGeometryChange:n._geometryValidator})};return i.getGeometry().on("change",s),{liveStroke:o,destroy:function(){i.getGeometry().un("change",s),o.destroy()}}}({map:e,manager:n,olFeature:u}),I=function(t){var e=t.map,n=t.container,i=t.manager,r=t.snap,o=t.olFeature,s=t.undoStack,a=t.selection,l=a.state,h=a.getState,c=a.setState,u=a.syncGeom,d=a.emitGeometryValidation,f=function(t){return c({selectedVertexIndex:t,selectedVertexType:Iu})},g=lu({map:e,container:n,getState:h,setState:c,colors:i.colors,snap:r,onVertexMoved:function(t){var e=t.vertexIndex,n=t.previousCoord;s.push({type:"move_vertex",vertexIndex:e,previousCoord:n}),u(),d(Eu,e),f(e),g.updateTargetPosition()},onTap:function(t){if(t){if(t.type===Iu)return f(t.index),void g.updateTargetPosition();var e=tu(o,l.midpoints,t.index,l.vertices.length);e&&(s.push({type:"insert_vertex",vertexIndex:e.insertedIndex}),u(),d(Pu,e.insertedIndex),f(e.insertedIndex),g.updateTargetPosition())}else c({selectedVertexIndex:-1,selectedVertexType:null})}});return a.setHooks({onDeselect:function(){return g.hide()},onUpdate:function(){l.interfaceType===bu&&g.updateTargetPosition()}}),g}({map:e,container:o,manager:n,snap:l,olFeature:u,undoStack:c,selection:m}),E=function(t){var e=t.olFeature,n=t.undoStack,i=t.selection,r=t.getTouchHandler,o=i.state,s=i.setState,a=i.syncGeom,l=i.emitGeometryValidation;return{doDeleteVertex:function(){if(!(o.selectedVertexType!==Iu||o.selectedVertexIndex<0)){var t=function(t,e){var n=t.getGeometry(),i={type:n.getType(),coordinates:n.getCoordinates()},r=kc(i),o=Rc(i),s=Fc(o,e);if(!s)return null;var a=s.segment,l=a.closed?vc.n8.Polygon:vc.n8.LineString;if(a.length<=l)return null;var h=Kc(r[e]),c=Oc(i,a.path);return c.splice(s.localIdx,1),a.closed&&(c[c.length-1]=Kc(c[0])),n.setCoordinates(i.coordinates),{deletedIndex:e,deletedCoord:h}}(e,o.selectedVertexIndex);t&&(n.push({type:"delete_vertex",vertexIndex:t.deletedIndex,deletedCoord:t.deletedCoord}),a(),l(Tu,t.deletedIndex),s({selectedVertexIndex:-1,selectedVertexType:null}))}},doUndo:function(){var t=n.pop();if(t){var i=o.selectedVertexIndex,h=Cu(e,t);a(),l(ku[t.type],h);var c=i>=0?h:-1;s({selectedVertexIndex:c,selectedVertexType:c>=0?Iu:null}),i>=0&&c>=0&&o.interfaceType===bu&&r().updateTargetPosition()}}}}({olFeature:u,undoStack:c,selection:m,getTouchHandler:function(){return I}}),P=function(t){var e=t.map,n=t.container,i=t.snap,r=t.undoStack,o=t.selection,s=t.touchHandler,a=t.actions,l=o.state,h=o.getState,c=o.setState,u=o.syncGeom,d=o.emitGeometryValidation;return vu({map:e,getState:h,setState:c,snap:i,onVertexMoved:function(t){var e=t.vertexIndex,n=t.previousCoord;r.push({type:"move_vertex",vertexIndex:e,previousCoord:n}),u(),d(Eu,e),c({selectedVertexIndex:e,selectedVertexType:Iu})},onInserted:function(t){var e=t.insertedIndex;r.push({type:"insert_vertex",vertexIndex:e}),u(),d(Pu,e)},onDeleted:a.doDeleteVertex,onUndo:a.doUndo,onKeyboardActive:function(){"keyboard"!==l.interfaceType&&(l.interfaceType="keyboard",s.hide(),n.focus({preventScroll:!0}))}})}({map:e,container:o,snap:l,undoStack:c,selection:m,touchHandler:I,actions:E}),T=function(t){var e=t.map,n=t.container,i=t.getState,r=t.setState,o=t.touchHandler,s=t.deleteVertexButtonId,a=t.onDeleteVertex,l=function(t){var n=i(),r=n.vertices,o=n.midpoints,s=e.getEventPixel(t);return Uc(e,r,o,{x:s[0],y:s[1]})},h=function(t){var e=i();if("touch"===t.pointerType)return e.interfaceType="touch",void o.updateTargetPosition();e.interfaceType="mouse";var n=l(t);"vertex"===(null==n?void 0:n.type)&&r({selectedVertexIndex:n.index,selectedVertexType:"vertex"})},c=function(t){if("touch"!==i().interfaceType){var e=l(t);"vertex"===(null==e?void 0:e.type)?r({selectedVertexIndex:e.index,selectedVertexType:"vertex"}):"midpoint"===(null==e?void 0:e.type)||r({selectedVertexIndex:-1,selectedVertexType:null})}},u=function(t){var e=i();"mouse"===t.pointerType&&"mouse"!==e.interfaceType&&(e.interfaceType="mouse",o.hide())},d=function(t){s&&t.target.closest("#".concat(s))&&a()};return n.addEventListener("pointerdown",h),n.addEventListener("pointerenter",u),n.addEventListener("pointermove",u),n.addEventListener("click",c),globalThis.addEventListener("click",d),{destroy:function(){n.removeEventListener("pointerdown",h),n.removeEventListener("pointerenter",u),n.removeEventListener("pointermove",u),n.removeEventListener("click",c),globalThis.removeEventListener("click",d)}}}({map:e,container:o,getState:_,setState:v,touchHandler:I,deleteVertexButtonId:a,onDeleteVertex:E.doDeleteVertex}),M=function(t){var e=t.map,n=t.manager,i=t.layers,r=t.touchHandler,o=t.live,s=t.selection.state,a=function(t){o.liveStroke.refresh(),i.vertexLayer.updateStyle(t.vertexStyle),i.midpointLayer.updateStyle(t.midpointStyle),i.activeLayer.update(s),r.updateColors(n.colors)};n.on(yc,a);var l=function(){s.interfaceType!==bu||s.selectedVertexIndex<0||e.once("postrender",function(){return r.updateTargetPosition()})};return e.on("change:size",l),{destroy:function(){n.off(yc,a),e.un("change:size",l)}}}({map:e,manager:n,layers:C,selection:m,touchHandler:I,live:b});return function(t){var e=t.manager,n=t.store,i=t.olFeature,r=t.originalFeatureStyle,o=t.selection,s=t.actions,a=t.parts,l=t.undoStack,h=o.state,c=o.setState,u=o.syncGeom,d=o.emitGeometryValidation,f=a.touchHandler;return{setInterfaceType:function(t){t!==h.interfaceType&&(h.interfaceType=t,t===bu?f.updateTargetPosition():f.hide())},done:function(){e.emit(mc.k.EDIT_FINISH,n.toGeoJSON(i))},setInvalid:function(t){a.live.liveStroke.set(t)},cancel:function(){},undo:s.doUndo,deleteVertex:s.doDeleteVertex,nudgeSelectedVertex:a.keyboardHandler.nudgeByDelta,getVertexItems:function(){return{vertices:h.vertices,midpoints:h.midpoints}},selectVertex:function(t){c({selectedVertexIndex:t,selectedVertexType:t<h.vertices.length?Iu:"midpoint"}),f.updateTargetPosition()},insertVertexAtMidpoint:function(t){var e=tu(i,h.midpoints,t,h.vertices.length);e&&(l.push({type:"insert_vertex",vertexIndex:e.insertedIndex}),u(),d(Pu,e.insertedIndex),c({selectedVertexIndex:e.insertedIndex,selectedVertexType:Iu}),f.updateTargetPosition())},destroy:function(){a.live.destroy(),i.setStyle(r),o.destroy(),a.mapSync.destroy(),a.pointerHandlers.destroy(),a.modify.destroy(),a.layers.activeLayer.remove(),a.layers.midpointLayer.remove(),a.layers.vertexLayer.remove(),f.destroy(),a.keyboardHandler.destroy()}}}({manager:n,store:h,olFeature:u,originalFeatureStyle:d,selection:m,actions:E,undoStack:c,parts:{touchHandler:I,keyboardHandler:P,pointerHandlers:T,modify:w,mapSync:M,layers:C,live:b}})},Fu=["selectedVertexIndex","selectedVertexType"];function Ou(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function Au(t){return function(t){if(Array.isArray(t))return Lu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Lu(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Lu(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lu(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var Du=function(t,e,n){t.getGeometry().setCoordinates(Au(n))},Gu="touch",ju="commit-move",Vu=function(t){var e=t.map,n=t.olFeature;return function(t){var i=e.getEventPixel(t.originalEvent);return!!e.forEachFeatureAtPixel(i,function(t){return t===n},{hitTolerance:12})}},Nu=function(t){var e=t.map,n=t.manager,i=t.options,r=i.featureId,o=i.container,s=i.interfaceType,a=i.snap,l=n.store,h=n.undoStack,c=l.getOL(r);if(!c)return null;null==o||o.focus({preventScroll:!0});var u=c.getStyle();c.setStyle(function(){return n.styles.selectedPointStyleFor(c)});var d=function(t){var e=t.manager,n=t.store,i=t.olFeature,r=t.interfaceType,o={olFeature:i,selectedVertexIndex:0,selectedVertexType:"vertex",vertices:[],midpoints:[],interfaceType:null!=r?r:"mouse"},s={onUpdate:null},a=function(){o.vertices=[i.getGeometry().getCoordinates()]},l=function(t,e,n){return function(i,r){i&&setTimeout(function(){t.emit(mc.k.GEOMETRY_CHANGE,{feature:e.toGeoJSON(n),phase:i,vertexIndex:r})},0)}}(e,n,i),h=function(){return a()};return i.getGeometry().on("change",h),a(),e.emit(mc.k.VERTEX_SELECTION,{index:0,numVertices:1}),{state:o,getState:function(){return o},setState:function(t){t.selectedVertexIndex,t.selectedVertexType;var e,n=function(t,e){if(null==t)return{};var n,i,r=function(t,e){if(null==t)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(-1!==e.indexOf(i))continue;n[i]=t[i]}return n}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}(t,Fu);Object.assign(o,n),void 0!==t.vertices&&(null===(e=s.onUpdate)||void 0===e||e.call(s))},syncGeom:function(){a(),e.emit(mc.k.UPDATE,n.toGeoJSON(i))},emitGeometryValidation:l,setHooks:function(t){var e=t.onUpdate;s.onUpdate=e},destroy:function(){i.getGeometry().un("change",h)}}}({manager:n,store:l,olFeature:c,interfaceType:s}),f=d.getState,g=d.setState,p=function(t){var e=t.map,n=t.olFeature,i=t.getState,r=t.condition,o=t.snap,s=t.onModifyEnd,a=null,l=null,h=function(t){return e.getCoordinateFromPixel(t.pixel)},c=new Yh({handleDownEvent:function(t){if("touch"===i().interfaceType||!r(t))return!1;var e,o=n.getGeometry().getCoordinates(),s=h(t);return a=[o[0]-s[0],o[1]-s[1]],l=function(t){if(Array.isArray(t))return Ou(t)}(e=o)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return Ou(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ou(t,e):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),!0},handleDragEvent:function(t){if(a){var e=h(t),i=[e[0]+a[0],e[1]+a[1]],r=o?o.apply(i):i;n.getGeometry().setCoordinates(r)}},handleUpEvent:function(){return a=null,l&&s([l]),l=null,!1}});return e.addInteraction(c),{destroy:function(){e.removeInteraction(c)}}}({map:e,olFeature:c,getState:f,condition:Vu({map:e,olFeature:c}),snap:a,onModifyEnd:function(t){d.syncGeom();var e=t&&qc(t,f().vertices);e&&(h.push(e),d.emitGeometryValidation(ju,e.vertexIndex))}}),m=function(t){var e=t.olFeature,n=t.undoStack,i=t.selection;return function(){var t=n.pop();t&&(function(t,e){"move_vertex"===e.type&&function(t,e){var n=e.previousCoord;t.getGeometry().setCoordinates(Au(n))}(t,e)}(e,t),i.syncGeom(),i.emitGeometryValidation(ju,0))}}({olFeature:c,undoStack:h,selection:d}),y=function(t){var e=t.manager,n=t.olFeature,i=(0,xc.De)({onChange:function(t,n){e.emit(mc.k.VALIDITY_CHANGE,{valid:!t,reason:n})}}),r=function(){var t=n.getGeometry().getCoordinates();i.update({feature:{type:"Feature",geometry:{type:"Point",coordinates:t}},context:{mode:"edit_point"},numVertices:1,onGeometryChange:e._geometryValidator})};return n.getGeometry().on("change",r),{liveStroke:i,destroy:function(){n.getGeometry().un("change",r),i.destroy()}}}({manager:n,olFeature:c}),_=function(t){var e=t.map,n=t.container,i=t.manager,r=t.snap,o=t.undoStack,s=t.selection,a=s.getState,l=s.setState,h=s.syncGeom,c=s.emitGeometryValidation,u=lu({map:e,container:n,getState:a,setState:l,colors:i.colors,snap:r,moveCoord:Du,onVertexMoved:function(t){var e=t.vertexIndex,n=t.previousCoord;o.push({type:"move_vertex",vertexIndex:e,previousCoord:n}),h(),c(ju,e)},onTap:function(){}});return s.setHooks({onUpdate:function(){a().interfaceType===Gu&&u.updateTargetPosition()}}),u}({map:e,container:o,manager:n,snap:a,undoStack:h,selection:d}),v=function(t){var e=t.map,n=t.container,i=t.snap,r=t.undoStack,o=t.selection,s=t.touchHandler,a=t.doUndo,l=o.getState,h=o.setState,c=o.syncGeom,u=o.emitGeometryValidation;return vu({map:e,getState:l,setState:h,snap:i,moveCoord:Du,onVertexMoved:function(t){var e=t.vertexIndex,n=t.previousCoord;r.push({type:"move_vertex",vertexIndex:e,previousCoord:n}),c(),u(ju,e)},onInserted:function(){},onDeleted:function(){},onUndo:a,onKeyboardActive:function(){"keyboard"!==l().interfaceType&&(l().interfaceType="keyboard",s.hide(),n.focus({preventScroll:!0}))}})}({map:e,container:o,snap:a,undoStack:h,selection:d,touchHandler:_,doUndo:m}),x=function(t){var e=t.map,n=t.manager,i=t.touchHandler,r=t.live,o=t.selection.state,s=function(){r.liveStroke.refresh(),i.updateColors(n.colors)};n.on(yc,s);var a=function(){o.interfaceType===Gu&&e.once("postrender",function(){return i.updateTargetPosition()})};return e.on("change:size",a),{destroy:function(){n.off(yc,s),e.un("change:size",a)}}}({map:e,manager:n,selection:d,touchHandler:_,live:y});return{setInterfaceType:function(t){t!==f().interfaceType&&(g({interfaceType:t}),t===Gu?_.updateTargetPosition():_.hide())},done:function(){n.emit(mc.k.EDIT_FINISH,l.toGeoJSON(c))},setInvalid:function(t){y.liveStroke.set(t)},cancel:function(){},undo:m,deleteVertex:function(){},nudgeSelectedVertex:v.nudgeByDelta,destroy:function(){y.destroy(),c.setStyle(u),d.destroy(),x.destroy(),p.destroy(),_.destroy(),v.destroy()}}},Wu="draw_point",Bu=function(t){var e=t.map,n=t.manager,i=t.options,r=i.featureId,o=i.properties,s=void 0===o?{}:o,a=function(t){return function(e){var n={type:"Feature",geometry:{type:"Point",coordinates:e},properties:{}},i=(0,_c.oK)(n,{mode:Wu,vertexIndex:0},{onGeometryChange:t._geometryValidator}),r=i.valid,o=i.reason;return r||t.emit(mc.k.PLACEMENT_BLOCKED,{feature:n,reason:null!=o?o:null,phase:"place",mode:Wu,vertexIndex:0}),r}}(n),l=new oc({type:"Point",style:function(){return[]},snapTolerance:Ol.vf.snapRadius,condition:function(t){return Vh(t)&&a(t.coordinate)}});e.addInteraction(l),l.on("drawend",function(t){return function(t,e,n,i,r){n.setId(String(i)),n.setProperties(r),t.store.source.addFeature(n),t.emit(mc.k.CREATE,t.store.toGeoJSON(n)),null==e||e(n)}(n,i.resolvePointSymbol,t.feature,r,s)}),l.on("drawabort",function(){n.emit(mc.k.CANCEL)});var h=function(t){var e,n,i=t.drawInteraction,r=t.options,o=t.canPlace,s=r.container,a=r.addVertexButtonId,l=r.mapProvider,h=r.snap,c=r.crossHair,u=null!==(e=r.interfaceType)&&void 0!==e?e:"mouse",d=function(){return u},f=function(){var t=l.getCenter(),e=h?h.apply(t):t;null==h||h.hideIndicator(),o(e)&&(i.appendCoordinates([e]),i.finishDrawing())},g=function(){h&&h.apply(l.getCenter())},p=function(t){u=t,gc(c,t),"mouse"!==t&&g()},m=pc({container:s,addVertexButtonId:a,olView:null===(n=i.getMap())||void 0===n?void 0:n.getView(),onUndo:null,getInterfaceType:d,setInterfaceType:p,clearLastCoord:function(){},updateRubberbanding:g,placeVertex:f});return gc(c,u),c&&(c.activate=f),{getInterfaceType:d,setInterfaceType:p,destroy:function(){(null==c?void 0:c.activate)===f&&(c.activate=null),m.destroy()}}}({drawInteraction:l,options:i,canPlace:a});return{done:function(){},cancel:function(){l.abortDrawing()},undo:function(){},setInterfaceType:function(t){h.setInterfaceType(t)},destroy:function(){n.emit(mc.k.INTERFACE_TYPE_CHANGE,{interfaceType:h.getInterfaceType()}),h.destroy(),e.removeInteraction(l)}}};function Xu(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var l=i&&i.prototype instanceof a?i:a,h=Object.create(l.prototype);return Yu(h,"_invoke",function(n,i,r){var o,a,l,h=0,c=r||[],u=!1,d={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(e,n){return o=e,a=0,l=t,d.n=n,s}};function f(n,i){for(a=n,l=i,e=0;!u&&h&&!r&&e<c.length;e++){var r,o=c[e],f=d.p,g=o[2];n>3?(r=g===i)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=f&&((r=n<2&&f<o[1])?(a=0,d.v=i,d.n=o[1]):f<g&&(r=n<3||o[0]>i||i>g)&&(o[4]=n,o[5]=i,d.n=g,a=0))}if(r||n>1)return s;throw u=!0,i}return function(r,c,g){if(h>1)throw TypeError("Generator is already running");for(u&&1===c&&f(c,g),a=c,l=g;(e=a<2?t:l)||!u;){o||(a?a<3?(a>1&&(d.n=-1),f(a,l)):d.n=l:d.v=l);try{if(h=2,o){if(a||(r="next"),e=o[r]){if(!(e=e.call(o,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=t}else if((e=(u=d.n<0)?l:n.call(i,d))!==s)break}catch(e){o=t,a=1,l=e}finally{h=1}}return{value:e,done:u}}}(n,r,o),!0),h}var s={};function a(){}function l(){}function h(){}e=Object.getPrototypeOf;var c=[][i]?e(e([][i]())):(Yu(e={},i,function(){return this}),e),u=h.prototype=a.prototype=Object.create(c);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,Yu(t,r,"GeneratorFunction")),t.prototype=Object.create(u),t}return l.prototype=h,Yu(u,"constructor",h),Yu(h,"constructor",l),l.displayName="GeneratorFunction",Yu(h,r,"GeneratorFunction"),Yu(u),Yu(u,r,"Generator"),Yu(u,i,function(){return this}),Yu(u,"toString",function(){return"[object Generator]"}),(Xu=function(){return{w:o,m:d}})()}function Yu(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}Yu=function(t,e,n,i){function o(e,n){Yu(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},Yu(t,e,n,i)}function zu(t,e,n,i,r,o,s){try{var a=t[o](s),l=a.value}catch(t){return void n(t)}a.done?e(l):Promise.resolve(l).then(i,r)}var Uu=["normal","active","selected"],Hu={normal:"symbolImageId",active:"symbolActiveImageId",selected:"symbolSelectedImageId"},qu=function(t){return!!(null!=t&&t.symbol||null!=t&&t.symbolSvgContent)},$u=function(t){var e;return(globalThis.devicePixelRatio||1)*(null!==(e=null==t?void 0:t.drawScale)&&void 0!==e?e:1)},Zu=function(){var t,e=(t=Xu().m(function t(e){var n,i,r,o,s,a,l;return Xu().w(function(t){for(;;)switch(t.p=t.n){case 0:if(n=e.manager,i=e.mapProvider,r=e.olFeature,o=r.getProperties(),qu(o)){t.n=1;break}return t.a(2);case 1:return s=$u(i),t.p=2,t.n=3,Promise.all(Uu.map(function(t){return Vl.a.rasteriseSymbolImage(o,n.mapStyle,t,s)}));case 3:if((a=t.v)[0]){t.n=4;break}return t.a(2);case 4:if(n.store.source.hasFeature(r)){t.n=5;break}return t.a(2);case 5:Uu.forEach(function(t,e){var n=a[e];n&&(jl(n.imageId,n.imageData),r.set(Hu[t],n.imageId))}),r.set("symbolPixelRatio",s),t.n=7;break;case 6:t.p=6,l=t.v,console.error("[draw] failed to resolve point symbol",r.getId(),l);case 7:return t.a(2)}},t,null,[[2,6]])}),function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(t){zu(o,i,r,s,a,"next",t)}function a(t){zu(o,i,r,s,a,"throw",t)}s(void 0)})});return function(t){return e.apply(this,arguments)}}(),Ku=function(t){var e=t.manager,n=t.mapProvider,i=e.store.source.getFeatures().filter(function(t){var e;return"Point"===(null===(e=t.getGeometry())||void 0===e?void 0:e.getType())&&qu(t.getProperties())});return Promise.all(i.map(function(t){return Zu({manager:e,mapProvider:n,olFeature:t})}))};function Ju(t){return Ju="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ju(t)}function Qu(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var l=i&&i.prototype instanceof a?i:a,h=Object.create(l.prototype);return td(h,"_invoke",function(n,i,r){var o,a,l,h=0,c=r||[],u=!1,d={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(e,n){return o=e,a=0,l=t,d.n=n,s}};function f(n,i){for(a=n,l=i,e=0;!u&&h&&!r&&e<c.length;e++){var r,o=c[e],f=d.p,g=o[2];n>3?(r=g===i)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=f&&((r=n<2&&f<o[1])?(a=0,d.v=i,d.n=o[1]):f<g&&(r=n<3||o[0]>i||i>g)&&(o[4]=n,o[5]=i,d.n=g,a=0))}if(r||n>1)return s;throw u=!0,i}return function(r,c,g){if(h>1)throw TypeError("Generator is already running");for(u&&1===c&&f(c,g),a=c,l=g;(e=a<2?t:l)||!u;){o||(a?a<3?(a>1&&(d.n=-1),f(a,l)):d.n=l:d.v=l);try{if(h=2,o){if(a||(r="next"),e=o[r]){if(!(e=e.call(o,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=t}else if((e=(u=d.n<0)?l:n.call(i,d))!==s)break}catch(e){o=t,a=1,l=e}finally{h=1}}return{value:e,done:u}}}(n,r,o),!0),h}var s={};function a(){}function l(){}function h(){}e=Object.getPrototypeOf;var c=[][i]?e(e([][i]())):(td(e={},i,function(){return this}),e),u=h.prototype=a.prototype=Object.create(c);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,td(t,r,"GeneratorFunction")),t.prototype=Object.create(u),t}return l.prototype=h,td(u,"constructor",h),td(h,"constructor",l),l.displayName="GeneratorFunction",td(h,r,"GeneratorFunction"),td(u),td(u,r,"Generator"),td(u,i,function(){return this}),td(u,"toString",function(){return"[object Generator]"}),(Qu=function(){return{w:o,m:d}})()}function td(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}td=function(t,e,n,i){function o(e,n){td(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},td(t,e,n,i)}function ed(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function nd(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ed(Object(n),!0).forEach(function(e){id(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ed(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function id(t,e,n){return(e=sd(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rd(t,e,n,i,r,o,s){try{var a=t[o](s),l=a.value}catch(t){return void n(t)}a.done?e(l):Promise.resolve(l).then(i,r)}function od(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,sd(i.key),i)}}function sd(t){var e=function(t){if("object"!=Ju(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ju(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ju(e)?e:e+""}var ad=function(){return t=function t(e){var n,i,r,o=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._map=e,this._pluginConfig=s,this._mode="disabled",this._modeInstance=null,this._listeners=new Map,this.store={source:r=new sl,getOL:function(t){var e;return null!==(e=r.getFeatureById(String(t)))&&void 0!==e?e:null},add:function(t){var e=this.getOL(t.id);e&&r.removeFeature(e);var n=Rl.readFeature(t);return r.addFeature(n),n},get:function(t){var e=this.getOL(t);return e?Rl.writeFeatureObject(e):null},remove:function(t){var e,n=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Ml(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ml(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}(Array.isArray(t)?t:[t]);try{for(n.s();!(e=n.n()).done;){var i=e.value,o=this.getOL(i);o&&r.removeFeature(o)}}catch(t){n.e(t)}finally{n.f()}},clear:function(){r.clear()},toGeoJSON:function(t){return Rl.writeFeatureObject(t)},fromGeoJSON:function(t){return Rl.readFeature(t)}},this.undoStack=(0,Fl.B)(function(t){return o.emit(mc.k.UNDO_CHANGE,t)}),this.mapStyle=null,this.colors=(0,$l.$)(null,s),this.styles=ql(this.colors),this.snap=kh(e,null!==(n=s.snapLayers)&&void 0!==n?n:null,this.colors,null!==(i=s.snapRadius)&&void 0!==i?i:Ol.vf.snapRadius),this._layer=new Na({source:this.store.source,style:this.styles.createFeatureStyle(),zIndex:100}),this._layer.set("layerId","draw"),this._layer.set("layerType","vector"),e.addLayer(this._layer)},e=[{key:"setMapStyle",value:function(t){var e;this.mapStyle=t,this.colors=(0,$l.$)(t,this._pluginConfig),this.styles=ql(this.colors),this._layer.setStyle(this.styles.createFeatureStyle()),this.store.source.changed(),null===(e=this.snap)||void 0===e||e.updateColors(this.colors),this.emit(yc,this.styles)}},{key:"on",value:function(t,e){this._listeners.has(t)||this._listeners.set(t,new Set),this._listeners.get(t).add(e)}},{key:"off",value:function(t,e){var n;null===(n=this._listeners.get(t))||void 0===n||n.delete(e)}},{key:"emit",value:function(t,e){var n=this._listeners.get(t);n&&Array.from(n).forEach(function(t){return t(e)})}},{key:"changeMode",value:(n=Qu().m(function t(e){var n,i,r,o,s,a,l,h=this,c=arguments;return Qu().w(function(t){for(;;)switch(t.n){case 0:o=c.length>1&&void 0!==c[1]?c[1]:{},null===(n=this._modeInstance)||void 0===n||n.destroy(),this._modeInstance=null,this._mode=e,s="draw_polygon"===e||"draw_line"===e||"draw_point"===e||"edit_vertex"===e||"edit_point"===e,null===(i=this.snap)||void 0===i||i.setIndicatorActive(s),a=nd(nd({},o),{},{snap:this.snap}),"draw_polygon"===e||"draw_line"===e?this._modeInstance=Ic({map:this._map,manager:this,options:a}):"draw_point"===e?(l=nd(nd({},a),{},{resolvePointSymbol:function(t){return Zu({manager:h,mapProvider:o.mapProvider,olFeature:t})}}),this._modeInstance=Bu({map:this._map,manager:this,options:l})):"edit_vertex"===e?this._modeInstance=Ru({map:this._map,manager:this,options:a}):"edit_point"===e&&(this._modeInstance=Nu({map:this._map,manager:this,options:a})),null===(r=this.snap)||void 0===r||r.reattach();case 1:return t.a(2)}},t,this)}),i=function(){var t=this,e=arguments;return new Promise(function(i,r){var o=n.apply(t,e);function s(t){rd(o,i,r,s,a,"next",t)}function a(t){rd(o,i,r,s,a,"throw",t)}s(void 0)})},function(t){return i.apply(this,arguments)})},{key:"getMode",value:function(){return this._mode}},{key:"done",value:function(){var t;null===(t=this._modeInstance)||void 0===t||t.done()}},{key:"cancel",value:function(){var t;null===(t=this._modeInstance)||void 0===t||t.cancel(),this.changeMode("disabled")}},{key:"undo",value:function(){var t;null===(t=this._modeInstance)||void 0===t||t.undo()}},{key:"deleteVertex",value:function(){var t;null===(t=this._modeInstance)||void 0===t||t.deleteVertex()}},{key:"nudgeSelectedVertex",value:function(t,e,n){var i,r;null===(i=this._modeInstance)||void 0===i||null===(r=i.nudgeSelectedVertex)||void 0===r||r.call(i,t,e,n)}},{key:"getVertexItems",value:function(){var t,e,n;return null!==(t=null===(e=this._modeInstance)||void 0===e||null===(n=e.getVertexItems)||void 0===n?void 0:n.call(e))&&void 0!==t?t:{vertices:[],midpoints:[]}}},{key:"selectVertex",value:function(t){var e,n;null===(e=this._modeInstance)||void 0===e||null===(n=e.selectVertex)||void 0===n||n.call(e,t)}},{key:"insertVertexAtMidpoint",value:function(t){var e,n;null===(e=this._modeInstance)||void 0===e||null===(n=e.insertVertexAtMidpoint)||void 0===n||n.call(e,t)}},{key:"setInvalid",value:function(t){var e,n;null===(e=this._modeInstance)||void 0===e||null===(n=e.setInvalid)||void 0===n||n.call(e,t)}},{key:"setDrawingPreviewProperty",value:function(t,e){var n,i;null===(n=this._modeInstance)||void 0===n||null===(i=n.setDrawingPreviewProperty)||void 0===i||i.call(n,t,e)}},{key:"setInterfaceType",value:function(t){var e,n;null===(e=this._modeInstance)||void 0===e||null===(n=e.setInterfaceType)||void 0===n||n.call(e,t),this.emit(mc.k.INTERFACE_TYPE_CHANGE,{interfaceType:t})}},{key:"get",value:function(t){return this.store.get(t)}},{key:"add",value:function(t){return this.store.add(t)}},{key:"delete",value:function(t){return this.store.remove(t)}},{key:"deleteAll",value:function(){return this.store.clear()}},{key:"remove",value:function(){var t,e;null===(t=this._modeInstance)||void 0===t||t.destroy(),this._modeInstance=null,null===(e=this.snap)||void 0===e||e.destroy(),this.snap=null,this.store.clear(),this._map.removeLayer(this._layer),this._listeners.clear()}}],e&&od(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,i}();function ld(t){return ld="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ld(t)}function hd(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function cd(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?hd(Object(n),!0).forEach(function(e){dd(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hd(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function ud(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,fd(i.key),i)}}function dd(t,e,n){return(e=fd(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fd(t){var e=function(t){if("object"!=ld(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ld(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ld(e)?e:e+""}var gd=function(){return t=function t(e,n){var i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),dd(this,"_snapEnabled",!1);var r=function(t){var e,n=t.mapProvider,i=t.events,r=t.eventBus,o=t.pluginConfig,s=void 0===o?{}:o,a=t.mapStyle,l=void 0===a?null:a,h=n.map,c=new ad(h,s);l&&c.setMapStyle(l),n.draw=c,n.drawScale=null!==(e=Ol.$y[n.mapSize])&&void 0!==e?e:1;var u=function(){return r.emit(i.MAP_DATA_CHANGE)},d=function(t){var e;n.drawScale=null!==(e=Ol.$y[t])&&void 0!==e?e:1,Ku({manager:c,mapProvider:n}).then(u)};r.on(i.MAP_SET_SIZE,d);var f=function(t){c.setMapStyle(t),Ku({manager:c,mapProvider:n}).then(u)};return r.on(i.MAP_SET_STYLE,f),{manager:c,remove:function(){r.off(i.MAP_SET_SIZE,d),r.off(i.MAP_SET_STYLE,f),c.remove(),n.draw=null}}}({mapProvider:e,events:n.events,eventBus:n.eventBus,pluginConfig:null!==(i=n.pluginConfig)&&void 0!==i?i:{snapLayers:n.snapLayers},mapStyle:n.mapStyle}),o=r.manager,s=r.remove;this._cleanupOLDraw=s,this._manager=o,this._mapProvider=e},e=[{key:"changeMode",value:function(t){var e=cd(cd({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),{},{mapProvider:this._mapProvider});return"draw_polygon"===t&&(e.geometryType="Polygon"),"draw_line"===t&&(e.geometryType="LineString"),this._manager.changeMode(t,e)}},{key:"getMode",value:function(){return this._manager.getMode()}},{key:"setInterfaceType",value:function(t){this._manager.setInterfaceType(t)}},{key:"done",value:function(){this._manager.undoStack.clear(),this._manager.done()}},{key:"cancel",value:function(){this._manager.undoStack.clear(),this._manager.cancel()}},{key:"undo",value:function(){this._manager.undo()}},{key:"deleteVertex",value:function(){this._manager.deleteVertex()}},{key:"nudgeSelectedVertex",value:function(t,e,n){this._manager.nudgeSelectedVertex(t,e,n)}},{key:"getVertexItems",value:function(){return this._manager.getVertexItems()}},{key:"selectVertex",value:function(t){this._manager.selectVertex(t)}},{key:"insertVertexAtMidpoint",value:function(t){this._manager.insertVertexAtMidpoint(t)}},{key:"setGeometryValid",value:function(t){this._manager._geometryValid=t}},{key:"_geometryValidator",get:function(){return this._manager._geometryValidator},set:function(t){this._manager._geometryValidator=t}},{key:"setInvalid",value:function(t){this._manager.setInvalid(t)}},{key:"get",value:function(t){return this._manager.get(t)}},{key:"add",value:function(t){var e,n=this._manager.add(t);return"Point"===(null===(e=t.geometry)||void 0===e?void 0:e.type)&&qu(t.properties)&&Zu({manager:this._manager,mapProvider:this._mapProvider,olFeature:n}),n}},{key:"setStyle",value:function(t,e){var n,i=this._manager.store.getOL(t);i&&(i.setProperties(e),"Point"===(null===(n=i.getGeometry())||void 0===n?void 0:n.getType())&&qu(i.getProperties())&&Zu({manager:this._manager,mapProvider:this._mapProvider,olFeature:i}))}},{key:"delete",value:function(t){return this._manager.delete(t)}},{key:"deleteAll",value:function(){return this._manager.deleteAll()}},{key:"setSnapEnabled",value:function(t){var e;this._snapEnabled=t,null===(e=this._manager.snap)||void 0===e||e.setActive(t)}},{key:"setSnapLayers",value:function(t){var e,n=this,i=null==t?void 0:t.map(function(t){return"stroke-inactive.cold"===t?n._manager._layer:t});null===(e=this._manager.snap)||void 0===e||e.setSnapLayers(i)}},{key:"isSnapEnabled",value:function(){return this._snapEnabled}},{key:"setFeatureProperty",value:function(){}},{key:"setDrawingPreviewProperty",value:function(t,e){this._manager.setDrawingPreviewProperty(t,e)}},{key:"on",value:function(t,e){this._manager.on(t,e)}},{key:"off",value:function(t,e){this._manager.off(t,e)}},{key:"remove",value:function(){this._cleanupOLDraw()}}],e&&ud(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}()},473(t,e,n){n.d(e,{$:()=>o});var i=n(682);function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}var o=function(t){var e,n,o,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null!==(e=null==t?void 0:t.mapColorScheme)&&void 0!==e?e:"light",l=null!==(n=null==t?void 0:t.id)&&void 0!==n?n:null,h=function(t){var e;return function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return"object"!==r(t)||null===t?t:n&&void 0!==t[n]?t[n]:void 0!==t[e]?t[e]:void 0!==t.light?t.light:Object.values(t)[0]}(null!==(e=s[t])&&void 0!==e?e:i.lm[t],a,l)};return{editStroke:h("editStroke"),editFill:h("editFill"),editVertex:h("editVertex"),editMidpoint:h("editMidpoint"),editActive:h("editActive"),editHalo:h("editHalo"),invalidStroke:h("invalidStroke"),splitValid:h("splitValid"),splitInvalid:h("splitInvalid"),shapeStroke:h("shapeStroke"),strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:i.F0.strokeWidth,shapeFill:h("shapeFill"),snapVertex:h("snapVertex"),snapEdge:h("snapEdge"),mapStyleId:l}}},722(t,e,n){n.d(e,{$X:()=>l,DD:()=>o,Ox:()=>a,ZP:()=>s,mt:()=>h});var i=n(682),r=i.F0.touchTargetSize/2,o=function(t){var e,n,o=t.querySelector("[data-im-draw-touch-target]");return o||(t.insertAdjacentHTML("beforeend",(e=i.F0.touchTargetSize,n=r,"\n <svg width='".concat(e,"' height='").concat(e,"' viewBox='0 0 48 48' fill-rule='evenodd'\n style='display:none;position:absolute;top:0;left:0;margin:").concat(n,"px 0 0 -").concat(n,"px;cursor:grab'\n class='im-draw-touch-target' data-im-draw-touch-target>\n <circle cx='24' cy='24' r='24' fill='var(--draw-halo, #000)'/>\n <path d=\"M37.543 25H34a1 1 0 1 1 0-2h3.629l-.836-.837a1 1 0 0 1 1.414-1.414l2.5 2.501A1 1 0 0 1 41 24a1 1 0 0 1-.487.858l-2.306 2.306a1 1 0 0 1-1.414-1.414l.75-.75zM23 10.414l-.793.793a1 1 0 0 1-1.414-1.414l2.5-2.5C23.481 7.105 23.734 7 24 7s.519.105.707.293l2.5 2.5a1 1 0 0 1-1.414 1.414L25 10.414V14a1 1 0 1 1-2 0v-3.586zM7 24a1 1 0 0 1 .293-.75l2.5-2.501a1 1 0 0 1 1.414 1.414l-.836.837H14a1 1 0 1 1 0 2h-3.543l.75.75a1 1 0 0 1-1.414 1.414l-2.306-2.306A1 1 0 0 1 7 24zm16.293 16.707l-2.5-2.5a1 1 0 0 1 1.414-1.414l.793.793V34a1 1 0 1 1 2 0v3.586l.793-.793a1 1 0 0 1 1.414 1.414l-2.5 2.5c-.188.188-.441.293-.707.293s-.519-.105-.707-.293zM24 20c2.208 0 4 1.792 4 4s-1.792 4-4 4-4-1.792-4-4 1.792-4 4-4z\" fill='var(--draw-bg, #fff)'/>\n </svg>\n "))),o=t.querySelector("[data-im-draw-touch-target]")),o},s=function(t,e){t&&(t.style.setProperty("--draw-halo",e.editActive),t.style.setProperty("--draw-bg",e.editHalo),t.style.setProperty("--draw-primary",e.editVertex))},a=function(t,e){e&&t&&(t.style.left="".concat(e.x,"px"),t.style.top="".concat(e.y,"px"),t.style.display="block")},l=function(t){t&&(t.style.display="none")},h=function(t){if(!t)return!1;var e=t.parentNode;return e instanceof globalThis.SVGElement||null!=(null==e?void 0:e.ownerSVGElement)}},610(t,e,n){n.d(e,{B:()=>i});var i=function(t){var e=[];return{push:function(n){e.push(n),t(e.length)},pop:function(){var n=e.pop();return t(e.length),n},clear:function(){e.length=0,t(e.length)},get length(){return e.length}}}},715(t,e,n){n.d(e,{O:()=>c});var i=n(520),r=n(9),o=n(788);function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach(function(e){h(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function h(t,e,n){return(e=function(t){var e=function(t){if("object"!=s(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==s(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var c=function(t){var e=t.onStrokeChange,n=t.onPlaceChange,s=function(t){var e=!1;return function(n,i){n!==e&&(e=n,t(n,null!=i?i:null))}},a=s(e),h=s(n),c=!1,u=null,d=null,f=null,g=function(){null!=d&&((0,o.WG)(d),d=null),f=null},p=function(t,e,n,r,o){var s,a=(null!==(s=e.numVertices)&&void 0!==s?s:0)<r?{valid:!0}:(0,i.$U)(t,l(l({},e),{},{phase:"preview"}),{rules:n});o(!a.valid||c,a.valid?u:a.reason)},m=function(){var t,e;if(f){var n=f,i=n.feature,o=n.context,s=null!==(t=r.n8[null==i||null===(e=i.geometry)||void 0===e?void 0:e.type])&&void 0!==t?t:0;p(i,o,r.PI,s,a),p(i,o,r.Oo,0,h)}},y=function(){if(d=null,f){var t=f,e=t.feature,n=t.context,r=t.onGeometryChange,o=(0,i.$U)(e,l(l({},n),{},{phase:"preview"}),{rules:[],onGeometryChange:r});c=!o.valid,u=o.reason,m()}};return{update:function(t){var e=t.feature,n=t.context,i=void 0===n?{}:n,r=t.numVertices,s=t.onGeometryChange;f={feature:e,context:l(l({},i),{},{numVertices:r}),onGeometryChange:s},m(),"function"==typeof s&&null==d&&(d=(0,o.PW)(y))},reset:function(){g(),c=!1,u=null,a(!1,null),h(!1,null)},destroy:function(){g()}}}},788(t,e,n){n.d(e,{De:()=>c,PW:()=>l,WG:()=>h});var i=n(520);function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function s(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach(function(e){a(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function a(t,e,n){return(e=function(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var l=function(t){return"function"==typeof requestAnimationFrame?requestAnimationFrame(t):setTimeout(t,16)},h=function(t){return"function"==typeof cancelAnimationFrame?cancelAnimationFrame(t):clearTimeout(t)},c=function(t){var e=t.onChange,n=t.validate,r=void 0===n?i.Uk:n,o=!1,a=null,c=null,u=function(){null!=a&&(h(a),a=null),c=null},d=function(t,n){t!==o&&(o=t,e(t,null!=n?n:null))},f=function(){if(a=null,c){var t=c,e=t.feature,n=t.context,i=t.onGeometryChange,o=r(e,n,{onGeometryChange:i}),s=o.valid,l=o.reason;d(!s,l)}};return{update:function(t){var e=t.feature,n=t.context,i=void 0===n?{}:n,o=t.numVertices,h=t.onGeometryChange,g=s(s({},i),{},{numVertices:o}),p=r(e,g);return p.valid?"function"!=typeof h?(u(),void d(!1,null)):(c={feature:e,context:g,onGeometryChange:h},void(null==a&&(a=l(f)))):(u(),void d(!0,p.reason))},set:function(t,e){u(),d(t,null!=e?e:null)},refresh:function(){e(o,null)},destroy:function(){u()}}}},600(t,e,n){function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}n.d(e,{a:()=>k});var r=function(t,e){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===i(t)){if(e&&t[e])return t[e];var n=Object.values(t)[0];return null!=n?n:null}return null},o={symbol:"pin",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},s={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},a={id:"pin",viewBox:"0 0 44 44",anchor:[.5,.9],graphic:s.dot,svg:'<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},l={id:"circle",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:s.dot,svg:'<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},h={id:"square",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:s.dot,svg:'<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},c=n(121),u={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}},d=function(t,e,n){return new Promise(function(i,r){var o="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(t)),s=new Image(e,n);s.onload=function(){var t=document.createElement("canvas");t.width=e,t.height=n;var r=t.getContext("2d");r.drawImage(s,0,0,e,n),i(r.getImageData(0,0,e,n))},s.onerror=function(){r(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},s.src=o})};function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function g(){var t,e,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var l=i&&i.prototype instanceof a?i:a,h=Object.create(l.prototype);return p(h,"_invoke",function(n,i,r){var o,a,l,h=0,c=r||[],u=!1,d={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(e,n){return o=e,a=0,l=t,d.n=n,s}};function f(n,i){for(a=n,l=i,e=0;!u&&h&&!r&&e<c.length;e++){var r,o=c[e],f=d.p,g=o[2];n>3?(r=g===i)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=f&&((r=n<2&&f<o[1])?(a=0,d.v=i,d.n=o[1]):f<g&&(r=n<3||o[0]>i||i>g)&&(o[4]=n,o[5]=i,d.n=g,a=0))}if(r||n>1)return s;throw u=!0,i}return function(r,c,g){if(h>1)throw TypeError("Generator is already running");for(u&&1===c&&f(c,g),a=c,l=g;(e=a<2?t:l)||!u;){o||(a?a<3?(a>1&&(d.n=-1),f(a,l)):d.n=l:d.v=l);try{if(h=2,o){if(a||(r="next"),e=o[r]){if(!(e=e.call(o,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,a<2&&(a=0)}else 1===a&&(e=o.return)&&e.call(o),a<2&&(l=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=t}else if((e=(u=d.n<0)?l:n.call(i,d))!==s)break}catch(e){o=t,a=1,l=e}finally{h=1}}return{value:e,done:u}}}(n,r,o),!0),h}var s={};function a(){}function l(){}function h(){}e=Object.getPrototypeOf;var c=[][i]?e(e([][i]())):(p(e={},i,function(){return this}),e),u=h.prototype=a.prototype=Object.create(c);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,p(t,r,"GeneratorFunction")),t.prototype=Object.create(u),t}return l.prototype=h,p(u,"constructor",h),p(h,"constructor",l),l.displayName="GeneratorFunction",p(h,r,"GeneratorFunction"),p(u),p(u,r,"Generator"),p(u,i,function(){return this}),p(u,"toString",function(){return"[object Generator]"}),(g=function(){return{w:o,m:d}})()}function p(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}p=function(t,e,n,i){function o(e,n){p(t,e,function(t){return this._invoke(e,n,t)})}e?r?r(t,e,{value:n,enumerable:!i,configurable:!i,writable:!i}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},p(t,e,n,i)}function m(t,e,n,i,r,o,s){try{var a=t[o](s),l=a.value}catch(t){return void n(t)}a.done?e(l):Promise.resolve(l).then(i,r)}function y(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function _(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?y(Object(n),!0).forEach(function(e){v(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function v(t,e,n){return(e=function(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function x(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,s,a=[],l=!0,h=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(i=o.call(n)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){h=!0,r=t}finally{try{if(!l&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(h)throw r}}return a}}(t,e)||S(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t,e){if(t){if("string"==typeof t)return w(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?w(t,e):void 0}}function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}var C=new Map,b=new Map,I={},E=function(t){var e,n=0,i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=S(t))){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==e.return||e.return()}finally{if(s)throw r}}}}(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;n=Math.trunc((n<<5)-n+r.codePointAt(0))}}catch(t){i.e(t)}finally{i.f()}return Math.abs(n).toString(36)},P=new Set(["id","svg","viewBox","anchor","symbol","symbolSvgContent"]);function T(t,e,n){var i,a,l,h,c=null==n?void 0:n.id,d=Object.fromEntries(Object.entries(t||{}).filter(function(t){var e=x(t,1)[0];return!P.has(e)})),f=Object.fromEntries(Object.entries(I).filter(function(t){var e=x(t,1)[0];return!P.has(e)})),g=Object.fromEntries(Object.entries(e).filter(function(t){return null!=x(t,2)[1]})),p=_(_(_(_({},o),f),d),g),m=null!==(i=u[null==n?void 0:n.mapColorScheme])&&void 0!==i?i:u.light;return p.haloColor=null!==(a=null==n?void 0:n.haloColor)&&void 0!==a?a:m.haloColor,p.selectedColor=null!==(l=null==n?void 0:n.selectedColor)&&void 0!==l?l:m.selectedColor,p.activeColor=null!==(h=null==n?void 0:n.activeColor)&&void 0!==h?h:m.activeColor,"string"==typeof p.graphic&&s[p.graphic]&&(p.graphic=s[p.graphic]),Object.fromEntries(Object.entries(p).map(function(t){var e=x(t,2),n=e[0],i=e[1];return[n,r(i,c)||""]}))}function M(t,e){return Object.entries(e).reduce(function(t,e){var n=x(e,2),i=n[0],r=n[1];return t.replaceAll("{{".concat(i,"}}"),r)},t)}var k={setDefaults:function(t){I=t||{}},getDefaults:function(){return _(_({},o),I)},register:function(t){C.set(t.id,t)},get:function(t){return C.get(t)},list:function(){return function(t){if(Array.isArray(t))return w(t)}(t=C.values())||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var t},clear:function(){C.clear()},initialise:function(){this.register(a),this.register(l),this.register(h)},resolve:function(t,e,n){var i=T(t,e||{},n);return t?(i.selectedColor="none",i.activeColor="none",M(t.svg,i)):""},resolveActive:function(t,e,n){var i=T(t,e||{},n);return t?M(t.svg,i):""},resolveSelected:function(t,e,n){var i=T(t,e||{},n);return t?(i.activeColor="none",M(t.svg,i)):""},getSymbolImageId:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,r=this.getSymbolDef(t);if(!r)return null;var o=(0,c.sR)(t),s=n?this.resolveActive(r,o,e):this.resolve(r,o,e);return"symbol-".concat(n?"act-":"").concat(E(s),"-").concat(i,"x")},getSymbolDef:function(t){return t.symbolSvgContent?{svg:t.symbolSvgContent}:t.symbol?this.get(t.symbol):void 0},rasteriseSymbolImage:function(t,e,n,i){var r,o=this;return(r=g().m(function r(){var s,a,l,h,u,f,p,m,y,_,v,S;return g().w(function(r){for(;;)switch(r.n){case 0:if(s=o.getSymbolDef(t)){r.n=1;break}return r.a(2,null);case 1:if(a=(0,c.sR)(t),"active"===n?(l=o.resolveActive(s,a,e),h="act-"):"selected"===n?(l=o.resolveSelected(s,a,e),h="sel-"):(l=o.resolve(s,a,e),h=""),u="symbol-".concat(h).concat(E(l),"-").concat(i,"x"),f=b.get(u)){r.n=3;break}return p=(0,c.n8)(t,s),m=p.split(" ").map(Number),y=x(m,4),_=y[2],v=y[3],S='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(_*i,'" height="').concat(v*i,'" viewBox="').concat(p,'">').concat(l,"</svg>"),r.n=2,d(S,_*i,v*i);case 2:f=r.v,b.set(u,f);case 3:return r.a(2,{imageId:u,imageData:f})}},r)}),function(){var t=this,e=arguments;return new Promise(function(n,i){var o=r.apply(t,e);function s(t){m(o,n,i,s,a,"next",t)}function a(t){m(o,n,i,s,a,"throw",t)}s(void 0)})})()}};k.initialise()},195(t,e,n){n.d(e,{z:()=>r});var i=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"]),r=function(t){t.altKey&&i.has(t.key)&&t.stopPropagation()}},107(t,e,n){n.d(e,{c:()=>i});var i=function(t,e,n){var i=function(t,e){return t[0]===e[0]&&t[1]===e[1]},r=e.filter(function(e){var r=Math.abs(e[0]-t[0]),o=Math.abs(e[1]-t[1]);return("ArrowUp"===n?e[1]<=t[1]&&o>=r:"ArrowDown"===n?e[1]>t[1]&&o>=r:"ArrowLeft"===n?e[0]<=t[0]&&o<r:"ArrowRight"!==n||e[0]>t[0]&&o<r)&&!i(e,t)});r.length||r.push(t);var o=function(e){return Math.hypot(t[0]-e[0],t[1]-e[1])},s=r.reduce(function(t,e){return o(e)<o(t)?e:t},r[0]);return e.findIndex(function(t){return i(t,s)})}},121(t,e,n){n.d(e,{Op:()=>s,n8:()=>o,sR:()=>r});var i=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),r=function(t){if(!function(t){return!(!t.symbol&&!t.symbolSvgContent)}(t))return{};var e={};return i.forEach(function(n){if(null!=t[n]){var i=n.charAt(6).toLowerCase()+n.slice(7);e[i]=t[n]}}),e},o=function(t,e){var n;return t.symbolViewBox?t.symbolViewBox:null!==(n=null==e?void 0:e.viewBox)&&void 0!==n?n:"0 0 38 38"},s=function(t,e){var n;return t.symbolAnchor?t.symbolAnchor:null!==(n=null==e?void 0:e.anchor)&&void 0!==n?n:[.5,.5]}}}]);