@defra/interactive-map 0.0.38-alpha → 0.0.40-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.
Files changed (84) hide show
  1. package/dist/css/index.css +1 -1
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/esm/im-shell.js +1 -1
  4. package/dist/umd/im-core.js +1 -1
  5. package/dist/umd/index.js +1 -1
  6. package/docs/api.md +4 -4
  7. package/docs/plugins/draw.md +1 -1
  8. package/package.json +1 -1
  9. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
  10. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
  11. package/plugins/beta/map-styles/dist/umd/index.js +1 -1
  12. package/plugins/datasets/dist/esm/esriLayerAdapter.js +1 -1
  13. package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  14. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  15. package/plugins/datasets/dist/umd/im-datasets-esri-adapter.js +1 -1
  16. package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  17. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  18. package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +2 -3
  19. package/plugins/datasets/src/adapters/esri/registry/esriDataset.js +1 -1
  20. package/plugins/datasets/src/adapters/loadLayerAdapter.js +1 -1
  21. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +1 -3
  22. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +3 -3
  23. package/plugins/datasets/src/initialise/initialiseDatasets.js +0 -1
  24. package/plugins/datasets/src/registry/dataset.js +5 -4
  25. package/plugins/datasets/src/registry/datasetRegistry.js +30 -27
  26. package/plugins/datasets/src/registry/datasetRegistry.test.js +26 -19
  27. package/plugins/datasets/src/registry/globalDataset.js +0 -3
  28. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  29. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  30. package/plugins/draw/src/DrawInit.jsx +2 -2
  31. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +1 -1
  32. package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.js +1 -1
  33. package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.test.js +1 -1
  34. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.js +1 -1
  35. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.js +3 -3
  36. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.test.js +1 -1
  37. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.test.js +1 -1
  38. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +1 -0
  39. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -1
  40. package/plugins/draw/src/adapters/openlayers/draw/drawInput.js +17 -3
  41. package/plugins/draw/src/adapters/openlayers/draw/drawInput.test.js +47 -3
  42. package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +1 -1
  43. package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +1 -1
  44. package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.test.js +1 -1
  45. package/plugins/draw/src/adapters/openlayers/edit/nudge.js +2 -2
  46. package/plugins/draw/src/adapters/openlayers/edit/nudge.test.js +2 -2
  47. package/plugins/draw/src/events.js +4 -4
  48. package/plugins/draw/src/events.test.js +1 -1
  49. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  50. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  51. package/plugins/interact/dist/umd/index.js +1 -1
  52. package/plugins/interact/src/hooks/useCrossHairVisibility.js +12 -4
  53. package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +88 -1
  54. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  55. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  56. package/plugins/search/src/Search.jsx +5 -2
  57. package/sonar-project.properties +7 -1
  58. package/src/App/components/Attributions/Attributions.module.scss +10 -0
  59. package/src/App/components/Hints/Hints.jsx +7 -2
  60. package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +2 -3
  61. package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +3 -6
  62. package/src/App/components/{MoveControl/MoveControl.jsx → MoveControls/MoveControls.jsx} +10 -10
  63. package/src/App/components/{MoveControl/MoveControl.module.scss → MoveControls/MoveControls.module.scss} +24 -24
  64. package/src/App/components/{MoveControl/MoveControl.test.jsx → MoveControls/MoveControls.test.jsx} +48 -48
  65. package/src/App/components/Viewport/Viewport.jsx +9 -1
  66. package/src/App/components/Viewport/Viewport.test.jsx +11 -0
  67. package/src/App/initialiseApp.js +11 -8
  68. package/src/App/initialiseApp.test.js +15 -3
  69. package/src/App/layout/Layout.jsx +3 -1
  70. package/src/App/registry/keyboardShortcutRegistry.js +25 -13
  71. package/src/App/registry/keyboardShortcutRegistry.test.js +49 -32
  72. package/src/App/registry/pluginRegistry.js +1 -2
  73. package/src/App/registry/pluginRegistry.test.js +4 -3
  74. package/src/App/store/AppProvider.jsx +3 -2
  75. package/src/InteractiveMap/InteractiveMap.js +8 -2
  76. package/src/InteractiveMap/InteractiveMap.test.js +20 -3
  77. package/src/config/appConfig.js +17 -15
  78. package/src/config/appConfig.test.js +22 -22
  79. package/src/config/defaults.js +3 -1
  80. package/src/config/mergeConfig.js +7 -0
  81. package/src/config/mergeConfig.test.js +20 -0
  82. package/src/scss/main.scss +1 -1
  83. package/src/test-utils.js +5 -0
  84. package/src/types.js +14 -6
@@ -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],{854(t,e,n){n.r(e),n.d(e,{OLDrawAdapter:()=>Ed});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)C(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 f(t,e[0],e[1])}function g(t,e){return t[0]<=e[0]&&e[2]<=t[2]&&t[1]<=e[1]&&e[3]<=t[3]}function f(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 _(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 m(t){return _(1/0,1/0,-1/0,-1/0,t)}function y(t,e){const n=t[0],i=t[1];return _(n,i,n,i,e)}function v(t,e,n,i,r){return w(m(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 C(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 w(t,e,n,i,r){for(;n<i;n+=r)I(t,e[n],e[n+1]);return t}function I(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 b(t,e){let n;return n=e(E(t)),n||(n=e(P(t)),n||(n=e(A(t)),n||(n=e(O(t)),n||!1)))}function T(t){let e=0;return G(t)||(e=L(t)*F(t)),e}function E(t){return[t[0],t[1]]}function P(t){return[t[2],t[1]]}function M(t){return[(t[0]+t[2])/2,(t[1]+t[3])/2]}function R(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],g=t[1];return[d-l+u,g-h-c,d-l-u,g-h+c,d+l-u,g+h+c,d+l+u,g+h-c,d-l+u,g-h-c]}function F(t){return t[3]-t[1]}function k(t,e,n){const i=n||[1/0,1/0,-1/0,-1/0];return D(t,e)?(t[0]>e[0]?i[0]=t[0]:i[0]=e[0],t[1]>e[1]?i[1]=t[1]:i[1]=e[1],t[2]<e[2]?i[2]=t[2]:i[2]=e[2],t[3]<e[3]?i[3]=t[3]:i[3]=e[3]):m(i),i}function O(t){return[t[0],t[3]]}function A(t){return[t[2],t[3]]}function L(t){return t[2]-t[0]}function D(t,e){return t[0]<=e[2]&&t[2]>=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function G(t){return t[2]<t[0]||t[3]<t[1]}function j(t,e){const n=e.getExtent(),i=M(t);if(e.canWrapX()&&(i[0]<n[0]||i[0]>=n[2])){const e=L(n),r=Math.floor((i[0]-n[0])/e)*e;t[0]-=r,t[2]-=r}return t}function V(t,e,n){if(e.canWrapX()){const i=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[i[0],t[1],i[2],t[3]]];j(t,e);const r=L(i);if(L(t)>r&&!n)return[[i[0],t[1],i[2],t[3]]];if(t[0]<i[0])return[[t[0]+r,t[1],i[2],t[3]],[i[0],t[1],t[2],t[3]]];if(t[2]>i[2])return[[t[0],t[1],i[2],t[3]],[i[0],t[1],t[2]-r,t[3]]]}return[t]}function W(t,e,n){return Math.min(Math.max(t,e),n)}function X(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 N(t,e,n,i)}function N(t,e,n,i){const r=n-t,o=i-e;return r*r+o*o}function Y(t){return 180*t/Math.PI}function B(t){return t*Math.PI/180}function z(t,e){const n=t%e;return n*e<0?n+e:n}function U(t,e,n){return t+n*(e-t)}function q(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}function Z(t,e,n){if(t>=e&&t<n)return t;const i=n-e;return((t-e)%i+i)%i+e}function K(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 g,f;return d<=0?(g=s,f=a):d>=1?(g=l,f=h):(g=s+d*c,f=a+d*u),[g,f]}function H(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 $(t,e){const n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function J(t,e){return Math.sqrt($(t,e))}function Q(t,e){if(e.canWrapX()){const n=L(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||L(i),r=Math.floor((t[0]-i[0])/n)),r}(t,e,n);i&&(t[0]-=i*n)}return t}const tt="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"",et=(tt.includes("safari")&&!tt.includes("chrom")&&(tt.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(tt)),tt.includes("webkit")&&tt.includes("edge"),tt.includes("macintosh"),"undefined"!=typeof devicePixelRatio&&devicePixelRatio,"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope),nt="undefined"!=typeof Image&&Image.prototype.decode;function it(t,e,n,i){let r;return r=n&&n.length?n.shift():et?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 rt;function ot(){return rt||(rt=it(1,1)),rt}function st(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}}();const at=2;let lt=1;const ht={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937},ct=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_||ht[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_}},ut=6378137,dt=Math.PI*ut,gt=[-dt,-dt,dt,dt],ft=[-180,-85,180,85],pt=ut*Math.log(Math.tan(Math.PI/2));class _t extends ct{constructor(t){super({code:t,units:"m",extent:gt,global:!0,worldExtent:ft,getPointResolution:function(t,e){return t/Math.cosh(e[1]/ut)}})}}const mt=[new _t("EPSG:3857"),new _t("EPSG:102100"),new _t("EPSG:102113"),new _t("EPSG:900913"),new _t("http://www.opengis.net/def/crs/EPSG/0/3857"),new _t("http://www.opengis.net/gml/srs/epsg.xml#3857")];const yt=[-180,-90,180,90],vt=6378137*Math.PI/180;class xt extends ct{constructor(t,e){super({code:t,units:"degrees",extent:yt,axisOrientation:e,global:!0,metersPerUnit:vt,worldExtent:yt})}}const St=[new xt("CRS:84"),new xt("EPSG:4326","neu"),new xt("urn:ogc:def:crs:OGC:1.3:CRS84"),new xt("urn:ogc:def:crs:OGC:2:84"),new xt("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new xt("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new xt("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Ct={},wt={};function It(t,e,n){const i=t.getCode(),r=e.getCode();i in wt||(wt[i]={}),wt[i][r]=n}function bt(t,e){return t in wt&&e in wt[t]?wt[t][e]:null}const Tt=.9996,Et=.00669438,Pt=Et*Et,Mt=Pt*Et,Rt=Et/(1-Et),Ft=Math.sqrt(1-Et),kt=(1-Ft)/(1+Ft),Ot=kt*kt,At=Ot*kt,Lt=At*kt,Dt=Lt*kt,Gt=.9983242984503243,jt=15*Pt/256+45*Mt/1024,Vt=35*Mt/3072,Wt=1.5*kt-27/32*At+269/512*Dt,Xt=21/16*Ot-55/32*Lt,Nt=151/96*At-417/128*Dt,Yt=1097/512*Lt,Bt=6378137;function zt(t,e,n){const i=t-5e5,r=(n.north?e:e-1e7)/Tt/(Bt*Gt),o=r+Wt*Math.sin(2*r)+Xt*Math.sin(4*r)+Nt*Math.sin(6*r)+Yt*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-Et*a,g=Math.sqrt(1-Et*a),f=Rt*l**2,p=f*f,_=i/(Bt/g*Tt),m=_*_,y=m*_,v=y*_,x=v*_,S=o-h/((1-Et)/d)*(m/2-v/24*(5+3*c+10*f-4*p-9*Rt))+x*_/720*(61+90*c+298*f+45*u-252*Rt-3*p);let C=(_-y/6*(1+2*c+f)+x/120*(5-2*f+28*c-3*p+8*Rt+24*u))/l;return C=Z(C+B(qt(n.number)),-Math.PI,Math.PI),[Y(C),Y(S)]}function Ut(t,e,n){t=Z(t,-180,180),e<-80?e=-80:e>84&&(e=84);const i=B(e),r=Math.sin(i),o=Math.cos(i),s=r/o,a=s*s,l=a*a,h=B(t),c=B(qt(n.number)),u=Bt/Math.sqrt(1-Et*r**2),d=Rt*o**2,g=o*Z(h-c,-Math.PI,Math.PI),f=g*g,p=f*g,_=p*g,m=_*g,y=m*g,v=Bt*(Gt*i-.002514607064228144*Math.sin(2*i)+jt*Math.sin(4*i)-Vt*Math.sin(6*i)),x=Tt*u*(g+p/6*(1-a+d)+m/120*(5-18*a+l+72*d-58*Rt))+5e5;let S=Tt*(v+u*s*(f/2+_/24*(5-a+9*d+4*d**2)+y/720*(61-58*a+l+600*d-330*Rt)));return n.north||(S+=1e7),[x,S]}function qt(t){return 6*(t-1)-180+3}const Zt=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Kt(t){let e=0;for(const n of Zt){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 Ht(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}}function $t(t,e,n){n=n||6371008.8;const i=B(t[1]),r=B(e[1]),o=(r-i)/2,s=B(e[0]-t[0])/2,a=Math.sin(o)*Math.sin(o)+Math.sin(s)*Math.sin(s)*Math.cos(i)*Math.cos(r);return 2*n*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}const Jt=[function(t){const e=Kt(t.getCode());return e?{forward:Ht(Ut,e),inverse:Ht(zt,e)}:null}],Qt=[function(t){return Kt(t)?new ct({code:t,units:"m"}):null}];let te=!0;function ee(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 ne(t){!function(t,e){Ct[t]=e}(t.getCode(),t),It(t,t,ee)}function ie(t){if("string"!=typeof t)return t;const e=Ct[n=t]||Ct[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null;var n;if(e)return e;for(const e of Qt){const n=e(t);if(n)return n}return null}function re(t,e,n,i){let r;const o=(t=ie(t)).getPointResolutionFunc();if(o){if(r=o(e,n),i&&i!==t.getUnits()){const e=t.getMetersPerUnit();e&&(r=r*e/ht[i])}}else{const o=t.getUnits();if("degrees"==o&&!i||"degrees"==i)r=e;else{const s=le(t,ie("EPSG:4326"));if(s||"degrees"===o){let t=[n[0]-e/2,n[1],n[0]+e/2,n[1],n[0],n[1]-e/2,n[0],n[1]+e/2];t=s(t,t,2),r=($t(t.slice(0,2),t.slice(2,4))+$t(t.slice(4,6),t.slice(6,8)))/2}else r=e*t.getMetersPerUnit();const a=i?ht[i]:t.getMetersPerUnit();void 0!==a&&(r/=a)}}return r}function oe(t){!function(t){t.forEach(ne)}(t),t.forEach(function(e){t.forEach(function(t){e!==t&&It(e,t,ee)})})}function se(t,e){return t?"string"==typeof t?ie(t):t:ie(e)}function ae(t,e){if(t===e)return!0;const n=t.getUnits()===e.getUnits();return(t.getCode()===e.getCode()||le(t,e)===ee)&&n}function le(t,e){const n=t.getCode(),i=e.getCode();let r=bt(n,i);if(r)return r;let o=null,s=null;for(const n of Jt)o||(o=n(t)),s||(s=n(e));if(!o&&!s)return null;const a="EPSG:4326";if(s)if(o)r=he(o.inverse,s.forward);else{const t=bt(n,a);t&&(r=he(t,s.forward))}else{const t=bt(a,i);t&&(r=he(o.inverse,t))}return r&&(ne(t),ne(e),It(t,e,r)),r}function he(t,e){return function(n,i,r,o){return i=t(n,i,r,o),e(i,i,r,o)}}function ce(t,e){return le(ie(t),ie(e))}function ue(t,e,n){const i=ce(e,n);if(!i){const t=ie(e).getCode(),i=ie(n).getCode();throw new Error(`No transform available between ${t} and ${i}`)}return i(t,void 0,t.length)}function de(t,e,n,i){return function(t,e,n,i){if(G(t))return m(n);let r=[];if(i>1){const e=t[2]-t[0],n=t[3]-t[1];for(let o=0;o<i;++o)r.push(t[0]+e*o/i,t[1],t[2],t[1]+n*o/i,t[2]-e*o/i,t[3],t[0],t[3]-n*o/i)}else r=[t[0],t[1],t[2],t[1],t[2],t[3],t[0],t[3]];e(r,r,2);const o=[],s=[];for(let t=0,e=r.length;t<e;t+=2)o.push(r[t]),s.push(r[t+1]);return function(t,e,n){return _(Math.min.apply(null,t),Math.min.apply(null,e),Math.max.apply(null,t),Math.max.apply(null,e),n)}(o,s,n)}(t,ce(e,n),void 0,i)}let ge=null;function fe(){return ge}function pe(t,e){return t}function _e(t,e){return te&&!H(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(te=!1,function(...t){lt>at||console.warn(...t)}("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t}function me(t,e){return t}function ye(t,e){return t}function ve(t,e){return t}var xe,Se,Ce;oe(mt),oe(St),xe=mt,Se=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]=dt*t[n]/180;let i=ut*Math.log(Math.tan(Math.PI*(+t[n+1]+90)/360));i>pt?i=pt:i<-pt&&(i=-pt),e[n+1]=i}return e},Ce=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]/dt,e[n+1]=360*Math.atan(Math.exp(t[n+1]/ut))/Math.PI-90;return e},St.forEach(function(t){xe.forEach(function(e){It(t,e,Se),It(e,t,Ce)})});const we="prerender",Ie="postrender",be=[NaN,NaN,NaN,0];let Te;const Ee=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Pe=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Me=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Re=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Fe(t,e){return t.endsWith("%")?Number(t.substring(0,t.length-1))/e:Number(t)}function ke(t){throw new Error('failed to parse "'+t+'" as color')}function Oe(t){if(t.toLowerCase().startsWith("rgb")){const e=t.match(Pe)||t.match(Ee)||t.match(Me);if(e){const t=e[4],n=100/255;return[W(Fe(e[1],n)+.5|0,0,255),W(Fe(e[2],n)+.5|0,0,255),W(Fe(e[3],n)+.5|0,0,255),void 0!==t?W(Fe(t,100),0,1):1]}ke(t)}if(t.startsWith("#")){if(Re.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}ke(t)}const e=(Te||(Te=it(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Te);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&&ke(t));const i=e.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return Oe(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]=q(r[3]/255,3),r}const Ae={};let Le=0;function De(t){if(4===t.length)return t;const e=t.slice();return e[3]=1,e}function Ge(t){return t>.0031308?269.025*Math.pow(t,1/2.4)-14.025:3294.6*t}function je(t){return t>.2068965?Math.pow(t,3):108/841*(t-4/29)}function Ve(t){return t>10.314724?Math.pow((t+14.025)/269.025,2.4):t/3294.6}function We(t){return t>.0088564?Math.pow(t,1/3):t/(108/841)+4/29}function Xe(t){const e=Ve(t[0]),n=Ve(t[1]),i=Ve(t[2]),r=We(.222488403*e+.716873169*n+.06060791*i),o=500*(We(.452247074*e+.399439023*n+.148375274*i)-r),s=200*(r-We(.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 Ne(t){if("none"===t)return be;if(Ae.hasOwnProperty(t))return Ae[t];if(Le>=1024){let t=0;for(const e in Ae)3&t++||(delete Ae[e],--Le)}const e=Oe(t);4!==e.length&&ke(t);for(const n of e)isNaN(n)&&ke(t);return Ae[t]=e,++Le,e}function Ye(t){return Array.isArray(t)?t:Ne(t)}function Be(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)+")"}function ze(t){for(const e in t)delete t[e]}function Ue(t){let e;for(e in t)return!1;return!e}function qe(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 Ze(t,e,n,i){return qe(t,e,n,i,!0)}function Ke(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),ze(t))}const He="change",$e=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function Je(){return!0}function Qe(){return!1}function tn(){}function en(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}}const nn=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},rn=class extends $e{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 nn(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,tn);delete o[n]}return a}disposeInternal(){this.listeners_&&ze(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]=tn,++this.pendingRemovals_[t]):(n.splice(i,1),0===n.length&&delete this.listeners_[t]))}};function on(t,e){return t+":"+(e?Ye(e):"null")}const sn=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=on(t,e);return n in this.cache_?this.cache_[n]:null}getPattern(t,e){const n=on(t,e);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,n,i){const r=on(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]=ot().createPattern(n.getImage(1),"repeat")}):this.patternCache_[r]=ot().createPattern(n.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};let an=null;class ln extends rn{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_){an||(an=it(1,1,void 0,{willReadFrequently:!0})),an.drawImage(this.image_,0,0);try{an.getImageData(0,0,1,1),this.tainted_=!1}catch{an=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(He)}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=it(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&&nt?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=it(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:Be(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(He,e),t())};this.addEventListener(He,e)}})),this.ready_}}function hn(t,e,n,i,r,o){let s=void 0===e?void 0:sn.get(e,r);return s||(s=new ln(t,t&&"src"in t?t.src||void 0:e,n,i,r),sn.set(e,r,s,o)),o&&s&&!sn.getPattern(e,r)&&sn.set(e,r,s,o),s}const cn=ln;function un(t){return t?Array.isArray(t)?Be(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return sn.getPattern(t.src,t.color);const e=t.src+":"+t.offset,n=sn.getPattern(e,t.color);if(n)return n;const i=sn.get(t.src,null);if(2!==i.getImageState())return null;const r=it(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]),hn(r.canvas,e,void 0,2,t.color,!0),sn.getPattern(e,t.color)}(t):t:null}function dn(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 gn(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++]=dn(t,e,a,i,r[o]),e=a}return r.length=o,r}function fn(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?[]:gn(t,e,a,i,r[o]),e=a[a.length-1]}return r.length=o,r}const pn=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){}},_n="propertychange";class mn extends rn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(He)}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]=qe(this,t[r],e);return i}return qe(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]=Ze(this,t[r],e)}else n=Ze(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)Ke(t[e]);else Ke(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)}}mn.prototype.on,mn.prototype.once,mn.prototype.un;const yn=mn;function vn(){throw new Error("Unimplemented abstract method.")}let xn=0;function Sn(t){return t.ol_uid||(t.ol_uid=String(++xn))}class Cn extends nn{constructor(t,e,n){super(t),this.key=e,this.oldValue=n}}const wn=class extends yn{constructor(t){super(),this.on,this.once,this.un,Sn(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 Cn(n,t,e)),n=_n,this.hasListener(n)&&this.dispatchEvent(new Cn(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],Ue(this.values_)&&(this.values_=null),e||this.notify(t,n)}}},In=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"),bn=["style","variant","weight","size","lineHeight","family"],Tn={normal:400,bold:700},En=function(t){const e=t.match(In);if(!e)return null;const n={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let t=0,i=bn.length;t<i;++t){const i=e[t+1];void 0!==i&&(n[bn[t]]="string"==typeof i?i.trim():i)}return isNaN(Number(n.weight))&&n.weight in Tn&&(n.weight=Tn[n.weight]),n.families=n.family.split(/,\s?/).map(t=>t.trim().replace(/^['"]|['"]$/g,"")),n},Pn="10px sans-serif",Mn="#000",Rn="round",Fn=[],kn="round",On="#000",An="center",Ln="middle",Dn=[0,0,0,0],Gn=new wn;let jn,Vn=null;const Wn={},Xn=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function Nn(t,e,n){return`${t} ${e} 16px "${n}"`}const Yn=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=En(t),r=i.families[0].toLowerCase(),o=i.weight;return e.some(t=>{const e=t.family.replace(/^['"]|['"]$/g,"").toLowerCase(),n=Tn[t.weight]||t.weight;return e===r&&t.style===i.style&&n==o})}async function r(){await n.ready;let o=!0;const s=Gn.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)?(ze(Wn),Gn.set(n,t)):(r+=10,Gn.set(n,r,!0),r<t&&(o=!1)))}e=void 0,o||(e=setTimeout(r,100))}return async function(t){n||(n=et?self.fonts:document.fonts);const i=En(t);if(!i)return;const o=i.families;let s=!1;for(const t of o){if(Xn.has(t))continue;const e=Nn(i.style,i.weight,t);void 0===Gn.get(e)&&(Gn.set(e,0,!0),s=!0)}s&&(clearTimeout(e),e=setTimeout(r,100))}}(),Bn=function(){let t;return function(e){let n=Wn[e];if(null==n){if(et){const t=En(e),i=zn(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);Wn[e]=n}return n}}();function zn(t,e){return Vn||(Vn=it(1,1)),t!=jn&&(Vn.font=t,jn=Vn.font),Vn.measureText(e)}function Un(t,e){return zn(t,e).width}function qn(t,e,n){if(e in n)return n[e];const i=e.split("\n").reduce((e,n)=>Math.max(e,Un(t,n)),0);return n[e]=i,i}const Zn={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},Kn=[Zn.FILL],Hn=[Zn.STROKE],$n=[Zn.BEGIN_PATH],Jn=[Zn.CLOSE_PATH],Qn=Zn,ti=class extends pn{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,g,f,_=!0;for(d=e+i;d<n;d+=i)u[0]=t[d],u[1]=t[d+1],f=p(l,u),f!==g?(_&&(s[a++]=h,s[a++]=c,_=!1),s[a++]=u[0],s[a++]=u[1]):1===f?(s[a++]=u[0],s[a++]=u[1],_=!1):_=!0,h=u[0],c=u[1],g=f;return(r&&_||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([Qn.CUSTOM,a,u,t,n,fn,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,u,t,i||n,fn,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([Qn.CUSTOM,a,c,t,n,gn,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,c,t,i||n,gn,r]);break;case"LineString":case"Circle":l=t.getFlatCoordinates(),h=this.appendFlatLineCoordinates(l,0,l.length,s,!1,!1),this.instructions.push([Qn.CUSTOM,a,h,t,n,dn,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,h,t,i||n,dn,r]);break;case"MultiPoint":l=t.getFlatCoordinates(),h=this.appendFlatPointCoordinates(l,s),h>a&&(this.instructions.push([Qn.CUSTOM,a,h,t,n,dn,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,h,t,i||n,dn,r]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),h=this.coordinates.length,this.instructions.push([Qn.CUSTOM,a,h,t,n,void 0,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,h,t,i||n,void 0,r])}this.endGeometry(e)}beginGeometry(t,e,n){this.beginGeometryInstruction1_=[Qn.BEGIN_GEOMETRY,e,0,t,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[Qn.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==Qn.END_GEOMETRY?o=e:r==Qn.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=un(n||Mn)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const n=t.getColor();e.strokeStyle=un(n||On);const i=t.getLineCap();e.lineCap=void 0!==i?i:Rn;const r=t.getLineDash();e.lineDash=r?r.slice():Fn;const o=t.getLineDashOffset();e.lineDashOffset=o||0;const s=t.getLineJoin();e.lineJoin=void 0!==s?s:kn;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=[Qn.SET_FILL_STYLE,e];return"string"!=typeof e&&n.push(t.fillPatternScale),n}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[Qn.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=[Qn.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 ei(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],g=t[n+1];for(let e=o+i;e<n;e+=i){const n=X(t[e],t[e+1],a,u,d,g);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 ni(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];s=ei(t,e,h,i,r,o,s),a.push(s),e=h}return s}function ii(t,e){return e*Math.round(t/e)}function ri(t,e,n,i,r,o,s){if(e==n)return s;let a,l,h=ii(t[e],r),c=ii(t[e+1],r);e+=i,o[s++]=h,o[s++]=c;do{if(a=ii(t[e],r),l=ii(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=ii(t[e],r),u=ii(t[e+1],r);if(e+=i,n==a&&u==l)continue;const d=a-h,g=l-c,f=n-h,p=u-c;d*p==g*f&&(d<0&&f<d||d==f||d>0&&f>d)&&(g<0&&p<g||g==p||g>0&&p>g)?(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 oi(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];s=ri(t,e,h,i,r,o,s),a.push(s),e=h}return s}const si=class extends ti{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($n),this.hitDetectionInstructions.push($n);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([Qn.MOVE_TO_LINE_TO,l,h,r*this.pixelRatio,!0]),this.hitDetectionInstructions.push([Qn.MOVE_TO_LINE_TO,l,h,r,!0]),a&&(this.instructions.push(Jn),this.hitDetectionInstructions.push(Jn)),e=s}return s&&(this.instructions.push(Kn),this.hitDetectionInstructions.push(Kn)),a&&(this.instructions.push(Hn),this.hitDetectionInstructions.push(Hn)),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([Qn.SET_FILL_STYLE,Mn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,0]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[Qn.CIRCLE,h,s];this.instructions.push($n,c),this.hitDetectionInstructions.push($n,c),void 0!==i.fillStyle&&(this.instructions.push(Kn),this.hitDetectionInstructions.push(Kn)),void 0!==i.strokeStyle&&(this.instructions.push(Hn),this.hitDetectionInstructions.push(Hn)),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([Qn.SET_FILL_STYLE,Mn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,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([Qn.SET_FILL_STYLE,Mn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,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]=ii(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 ai(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=U(n,h,e),g=U(i,c,e);l.push(d,g),o.push(l),l=[d,g],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=U(n,h,t/u),d=U(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 li(t,e,n,i,r){let o,s,a,l,h,c,u,d,g,f,p=n,_=n,m=0,y=0,v=n;for(s=n;s<i;s+=r){const n=e[s],i=e[s+1];void 0!==h&&(g=n-h,f=i-c,l=Math.sqrt(g*g+f*f),void 0!==u&&(y+=a,o=Math.acos((u*g+d*f)/(a*l)),o>t&&(y>m&&(m=y,p=v,_=s),y=0,v=s-r)),a=l,u=g,d=f),h=n,c=i}return y+=l,y>m?[v,s]:[p,_]}const hi={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},ci={Circle:si,Default:ti,Image:class extends ti{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([Qn.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([Qn.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([Qn.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([Qn.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 ti{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([Qn.MOVE_TO_LINE_TO,o,s,r*this.pixelRatio]),this.hitDetectionInstructions.push([Qn.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([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,0],$n);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l,s),this.hitDetectionInstructions.push(Hn),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([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,0],$n);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(Hn),this.endGeometry(e)}finish(){const t=this.state;return null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Hn),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Hn),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push($n)}},Polygon:si,Text:class extends ti{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[Mn]={fillStyle:Mn},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 g=o.padding;if(g!=Dn&&(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),g=[t,e,n,i]}const f=this.pixelRatio;this.instructions.push([Qn.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==Dn?Dn:g.map(function(t){return t*f}),u,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]);const p=1/f,_=u?u.slice(0):null;_&&(_[1]=Mn),this.hitDetectionInstructions.push([Qn.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,this.declutterMode_,this.declutterImageWithText_,g,_,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Mn:this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]),this.endGeometry(e)}else{if(!D(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?ai(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=li(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 g=s.length;d=i[t],this.drawChars_(a,g),a=g}}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||An,justify:e.justify,textBaseline:e.textBaseline||Ln,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=hi[i.textBaseline],h=this.textOffsetY_*a,c=this.text_,u=n?n.lineWidth*Math.abs(i.scale[0])/2:0;this.instructions.push([Qn.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([Qn.DRAW_CHARS,t,e,l,i.overflow,s?Mn: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=un(e.getColor()||Mn)):(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()||Rn,r.lineDash=t?t.slice():Fn,r.lineDashOffset=void 0===e?0:e,r.lineJoin=o.getLineJoin()||kn,r.lineWidth=void 0===n?1:n,r.miterLimit=void 0===i?10:i,r.strokeStyle=un(o.getColor()||On)}else r=null,this.textStrokeState_=r;n=this.textState_;const s=t.getFont()||Pn;Yn(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()||Ln,n.backgroundFill=t.getBackgroundFill(),n.backgroundStroke=t.getBackgroundStroke(),n.padding=t.getPadding()||Dn,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:Sn(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:"|"+Sn(i.fillStyle):""}else this.text_="";this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}},ui=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,ci[e])(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),i[e]=r),r}};function di(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 gi(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 fi(t,e){if(!t)throw new Error(e)}const pi=new Array(6);function _i(t){return yi(t,1,0,0,1,0,0)}function mi(t,e){const n=t[0],i=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=e[0],h=e[1],c=e[2],u=e[3],d=e[4],g=e[5];return t[0]=n*l+r*h,t[1]=i*l+o*h,t[2]=n*c+r*u,t[3]=i*c+o*u,t[4]=n*d+r*g+s,t[5]=i*d+o*g+a,t}function yi(t,e,n,i,r,o,s){return t[0]=e,t[1]=n,t[2]=i,t[3]=r,t[4]=o,t[5]=s,t}function vi(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 xi(t,e,n){return mi(t,yi(pi,e,0,0,n,0,0))}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}const Ci=[1e5,1e5,1e5,1e5,2,2];function wi(t){return t.substring(7,t.length-1).split(",").map(parseFloat)}function Ii(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 bi(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,g,f,p,_,m,y,v,x=0;for(let S=e;S<n;S+=i){f=d,p=g,_=void 0,m=void 0,S+i<n&&(_=t[S+i],m=t[S+i+1]),o&&S===e&&(f=c,p=u),o&&S===n-i&&(_=l,m=h),d=t[S],g=t[S+1],[y,v]=Ti(d,g,f,p,_,m,r),s[x++]=y,s[x++]=v;for(let e=2;e<a;e++)s[x++]=t[S+e]}return s.length!=x&&(s.length=x),s}function Ti(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(W(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 g=Math.cos(d/2),f=Math.sin(d/2);return[t+1/f*(f*a+g*l)*s,e+1/f*(-g*a+f*l)*s]}function Ei(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 g=((c-l)*(o-h)-(u-h)*(r-l))/d,f=((s-r)*(o-h)-(a-o)*(r-l))/d;if(g>0&&g<1&&f>0&&f<1){const l=r+g*(s-r),h=o+g*(a-o);t[n+e]=l,t[n+e+1]=h,t.splice(n+2*e,i-n-e);break}}return t}function Pi(t,e,n,i,r,o,s,a,l,h,c,u,d=!0){let g=t[e],f=t[e+1],p=0,_=0,m=0,y=0;function v(){p=g,_=f,g=t[e+=i],f=t[e+1],y+=m,m=Math.sqrt((g-p)*(g-p)+(f-_)*(f-_))}do{v()}while(e<n-i&&y+m<o);let x=0===m?0:(o-y)/m;const S=U(p,g,x),C=U(_,f,x),w=e-i,I=y,b=o+a*l(h,r,c);for(;e<n-i&&y+m<b;)v();x=0===m?0:(b-y)/m;const T=U(p,g,x),E=U(_,f,x);let P=!1;if(d)if(u){const t=[S,C,T,E];gi(t,0,4,2,u,t,t),P=t[0]>t[2]}else P=S>T;const M=Math.PI,R=[],F=w+i===e;let k;if(m=0,y=I,g=t[e=w],f=t[e+1],F){v(),k=Math.atan2(f-_,g-p),P&&(k+=k>0?-M:M);const t=(T+S)/2,e=(E+C)/2;return R[0]=[t,e,(b-o)/2,k,r],R}for(let t=0,u=(r=r.replace(/\n/g," ")).length;t<u;){v();let d=Math.atan2(f-_,g-p);if(P&&(d+=d>0?-M:M),void 0!==k){let t=d-k;if(t+=t>M?-2*M:t<-M?2*M:0,Math.abs(t)>s)return null}k=d;const S=t;let C=0;for(;t<u;++t){const s=a*l(h,r[P?u-t-1:t],c);if(e+i<n&&y+m<o+C+s/2)break;C+=s}if(t===S)continue;const w=P?r.substring(u-S,u-t):r.substring(S,t);x=0===m?0:(o+C/2-y)/m;const I=U(p,g,x),b=U(_,f,x);R.push([I,b,C/2,d,w]),o+=C}return R}const Mi=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(ot(),{get:(t,e)=>{if("function"==typeof ot()[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}},Ri=[1/0,1/0,-1/0,-1/0],Fi=[],ki=[],Oi=[],Ai=[];function Li(t){return t[3].declutterBox}const Di=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 Gi(t,e){return"start"===e?e=Di.test(t)?"right":"left":"end"===e&&(e=Di.test(t)?"left":"right"),hi[e]}function ji(t,e,n){return n>0&&t.push("\n",""),t.push(e,""),t}function Vi(t,e,n){return n%2==0&&(t+=e),t}const Wi=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 Mi: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?hi[a.justify]:Gi(Array.isArray(t)?t[0]:t,a.textAlign||An),u=i&&o.lineWidth?o.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(ji,[]),{width:g,height:f,widths:p,heights:_,lineWidths:m}=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,g=Un(d,u);n.push(g),s+=g;const f=Bn(d);i.push(f),l=Math.max(l,f)}return{width:o,height:a,widths:n,heights:i,lineWidths:r}}(a,d),y=g+u,v=[],x=(y+2)*h[0],S=(f+u)*h[1],C={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 w=.5-c;let I=c*y+w*u;const b=[],T=[];let E,P=0,M=0,R=0,F=0;for(let t=0,e=d.length;t<e;t+=2){const e=d[t];if("\n"===e){M+=P,P=0,I=c*y+w*u,++F;continue}const r=d[t+1]||a.font;r!==E&&(i&&b.push("font",r),n&&T.push("font",r),E=r),P=Math.max(P,_[R]);const o=[e,I+w*p[R]+c*(p[R]-m[F]),.5*(u+P)+M];I+=p[R],i&&b.push("strokeText",o),n&&T.push("fillText",o),++R}return Array.prototype.push.apply(v,b),Array.prototype.push.apply(v,T),this.labels_[r]=C,C}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,g,f,p){let m=n-(s*=u[0]),y=i-(a*=u[1]);const v=r+l>t?t-l:r,x=o+h>e?e-h:o,S=g[3]+v*u[0]+g[1],C=g[0]+x*u[1]+g[2],w=m-g[3],I=y-g[0];let b;return(f||0!==c)&&(Fi[0]=w,Ai[0]=w,Fi[1]=I,ki[1]=I,ki[0]=w+S,Oi[0]=ki[0],Oi[1]=I+C,Ai[1]=Oi[1]),0!==c?(b=Si([1,0,0,1,0,0],n,i,1,1,c,-n,-i),vi(b,Fi),vi(b,ki),vi(b,Oi),vi(b,Ai),_(Math.min(Fi[0],ki[0],Oi[0],Ai[0]),Math.min(Fi[1],ki[1],Oi[1],Ai[1]),Math.max(Fi[0],ki[0],Oi[0],Ai[0]),Math.max(Fi[1],ki[1],Oi[1],Ai[1]),Ri)):_(Math.min(w,w+S),Math.min(I,I+C),Math.max(w,w+S),Math.max(I,I+C),Ri),d&&(m=Math.round(m),y=Math.round(y)),{drawImageX:m,drawImageY:y,drawImageW:v,drawImageH:x,originX:l,originY:h,declutterBox:{minX:Ri[0],minY:Ri[1],maxX:Ri[2],maxY:Ri[3],value:p},canvasTransform:b,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,Fi,ki,Oi,Ai,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=vi(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=Gi(Array.isArray(t)?t[0]:t,r.textAlign||An),h=hi[r.textBaseline||Ln],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=di(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 g=0;const f=i.length;let p,_=0;const m=[];let y,v,x,S,C,w,I,b,T,E,P,M,R,F=0,k=0;const O=this.coordinateCache_,A=this.viewRotation_,L=Math.round(1e12*Math.atan2(-n[1],n[0]))/1e12,G={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:A},j=this.instructions!=i||this.overlaps?0:200;let V,W,X,N;for(;g<f;){const n=i[g];switch(n[0]){case Qn.BEGIN_GEOMETRY:V=n[1],N=n[3],V.getGeometry()?void 0===s||D(s,N.getExtent())?++g:g=n[2]+1:g=n[2],h&&(h.zIndex=n[4]);break;case Qn.BEGIN_PATH:F>j&&(this.fill_(t),F=0),k>j&&(t.stroke(),k=0),F||k||(t.beginPath(),C=NaN,w=NaN),++g;break;case Qn.CIRCLE:_=n[1],x=n[2]??0;const i=c[_],l=c[_+1],u=c[_+2]-x-i,d=c[_+3]-x-l,f=Math.sqrt(u*u+d*d);t.moveTo(i+f,l),t.arc(i,l,f,0,2*Math.PI,!0),++g;break;case Qn.CLOSE_PATH:t.closePath(),++g;break;case Qn.CUSTOM:_=n[1],p=n[2];const Y=n[3],B=n[4],z=n[5];G.geometry=Y,G.feature=V,g in O||(O[g]=[]);const U=O[g];z?z(c,_,p,2,U):(U[0]=c[_],U[1]=c[_+1],U.length=2),h&&(h.zIndex=n[6]),B(U,G),++g;break;case Qn.DRAW_IMAGE:_=n[1],p=n[2],T=n[3],y=n[4],v=n[5];let q=n[6];const Z=n[7],K=n[8],H=n[9],$=n[10];let J=n[11];const Q=n[12];let tt=n[13];S=n[14]||"declutter";const et=n[15];if(!T&&n.length>=20){E=n[19],P=n[20],M=n[21],R=n[22];const t=this.drawLabelWithPointPlacement_(E,P,M,R);T=t.label,n[3]=T;const e=n[23];y=(t.anchorX-e)*this.pixelRatio,n[4]=y;const i=n[24];v=(t.anchorY-i)*this.pixelRatio,n[5]=v,q=T.height,n[6]=q,tt=T.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=Dn,rt=null,ot=null),$&&L?J+=A:$||L||(J-=A);let st=0;for(;_<p;_+=2){if(nt&&nt[st++]<tt/this.pixelRatio)continue;const n=this.calculateImageOrLabelDimensions_(T.width,T.height,c[_],c[_+1],tt,q,y,v,K,H,J,Q,r,it,!!rt||!!ot,V),i=[t,e,T,n,Z,rt,ot];if(a){let t,e,r,o,s;if(et){const n=p-_;if(!et[n]){et[n]={args:i,declutterMode:S};continue}const o=et[n];t=o.args,e=o.declutterMode,delete et[n],r=Li(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)}++g;break;case Qn.DRAW_CHARS:const at=n[1],lt=n[2],ht=n[3],ct=n[4];R=n[5];const ut=n[6],dt=n[7],gt=n[8];M=n[9];const ft=n[10];E=n[11],Array.isArray(E)&&(E=E.reduce(Vi,"")),P=n[12];const pt=[n[13],n[13]];S=n[14]||"declutter";const _t=n[15],mt=this.textStates[P],yt=mt.font,vt=[mt.scale[0]*dt,mt.scale[1]*dt];let xt;yt in this.widths_?xt=this.widths_[yt]:(xt={},this.widths_[yt]=xt);const St=Ii(c,at,lt,2),Ct=Math.abs(vt[0])*qn(yt,E,xt);if(ct||Ct<=St){const n=Pi(c,at,lt,2,E,(St-Ct)*Gi(E,this.textStates[P].textAlign),ut,Math.abs(vt[0]),qn,yt,xt,L?0:this.viewRotation_,_t);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,P,"",M),y=h[2]+(vt[0]<0?-ft:ft),v=ht*l.height+2*(.5-ht)*ft*vt[1]/vt[0]-gt;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,y,v,0,0,h[3],pt,!1,Dn,!1,V);if(a&&"declutter"===S&&a.collides(o.declutterBox))break t;i.push([t,e,l,o,1,null,null])}if(R)for(r=0,o=n.length;r<o;++r){h=n[r],s=h[4],l=this.createLabel(s,P,R,""),y=h[2],v=ht*l.height-gt;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,y,v,0,0,h[3],pt,!1,Dn,!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(Li));for(let t=0,e=i.length;t<e;++t)this.replayImageOrLabel_.apply(this,i[t])}}++g;break;case Qn.END_GEOMETRY:if(void 0!==o){V=n[1];const t=o(V,N,S);if(t)return t}++g;break;case Qn.FILL:j?F++:this.fill_(t),++g;break;case Qn.MOVE_TO_LINE_TO:let wt,It,bt;_=n[1],p=n[2],x=n[3],x?(bi(c,_,p,2,x,n[4]??!1,m),Ei(m,2),wt=m,It=0,bt=wt.length):(wt=c,It=_,bt=p),W=wt[It],X=wt[It+1],t.moveTo(W,X),C=W+.5|0,w=X+.5|0;for(let e=It+2;e<bt;e+=2)W=wt[e],X=wt[e+1],I=W+.5|0,b=X+.5|0,e!=bt-2&&I===C&&b===w||(t.lineTo(W,X),C=I,w=b);++g;break;case Qn.SET_FILL_STYLE:this.alignAndScaleFill_=n[2],F?(this.fill_(t),F=0,k&&(t.stroke(),k=0)):k&&n[1]&&(t.stroke(),k=0),t.fillStyle=n[1],++g;break;case Qn.SET_STROKE_STYLE:F&&n[1]&&(this.fill_(t),F=0),k&&(t.stroke(),k=0),this.setStrokeStyle_(t,n),++g;break;case Qn.STROKE:j?k++:t.stroke(),++g;break;default:++g}}F&&this.fill_(t),k&&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)}},Xi=["Polygon","Circle","LineString","Image","Text","Default"],Ni=["Image","Text"],Yi=Xi.filter(t=>!Ni.includes(t));let Bi=!1,zi=!1;const Ui={},qi=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 Wi(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===zi&&function(){let t=0;const e=e=>{const n=it(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};Bi=n[t],zi=!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_=it(a,a,null,{willReadFrequently:Bi}));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],C(d,t),c(d,e*(this.renderBuffer_+r),d));const g=function(t){if(void 0!==Ui[t])return Ui[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 Ui[t]=r,r}(r);let f;function p(t,e,n){const i=u.getImageData(0,0,a,a).data;for(let l=0,h=g.length;l<h;l++)if(i[g[l]]>0){if(!s||"none"===n||"Image"!==f&&"Text"!==f||s.includes(t)){const n=(g[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 _=Object.keys(this.executorsByZIndex_).map(Number);let m,y,v,x,S;for(_.sort(i),m=_.length-1;m>=0;--m){const t=_[m].toString();for(v=this.executorsByZIndex_[t],y=Xi.length-1;y>=0;--y)if(f=Xi[y],x=v[f],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 di(s,0,8,2,t,s),s}isEmpty(){return Ue(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||Xi;const c=Xi.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],g=u[d];if(void 0!==g){const r=null===l?void 0:g.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=>g.execute(t,e,n,o,s,l)):g.execute(a,e,n,o,s,l),u&&a.restore(),r){r.offset();const t=h[i]*c+Xi.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 Zi(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}class Ki{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=Zi(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Ki({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 vn()}getImage(t){return vn()}getHitDetectionImage(){return vn()}getPixelRatio(t){return 1}getImageState(){return vn()}getImageSize(){return vn()}getOrigin(){return vn()}getSize(){return vn()}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_=Zi(t)}listenImageChange(t){vn()}load(){vn()}unlistenImageChange(t){vn()}ready(){return Promise.resolve()}}const Hi=Ki;function $i(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 Ji extends Hi{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(fi(!(void 0!==a&&o),"`image` and `src` cannot be provided at the same time"),void 0!==a&&0!==a.length||!o||(a=o.src||Sn(o)),fi(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),fi(!((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?Ye(t.color):null,this.iconImage_=hn(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($i(n[0],n[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale($i(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 Ji({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?Ye(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_=hn(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_=hn(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(He,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(He,t)}ready(){return this.iconImage_.ready()}}const Qi=Ji,tr=[1,0,0,1,0,0],er=[NaN,NaN],nr=class extends wn{constructor(){super(),this.extent_=[1/0,1/0,-1/0,-1/0],this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=en((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 vn()}closestPointXY(t,e,n,i){return vn()}containsXY(t,e){return 0===this.closestPointXY(t,e,er,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 vn()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&m(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){vn()}scale(t,e,n){vn()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return vn()}getType(){return vn()}applyTransform(t){vn()}intersectsExtent(t){return vn()}translate(t,e){vn()}transform(t,e){const n=ie(t),i="tile-pixels"==n.getUnits()?function(t,i,r){const o=n.getExtent(),s=n.getWorldExtent(),a=F(s)/F(o);Si(tr,s[0],s[3],a,-a,0,0,0);const l=di(t,0,t.length,r,tr,i),h=ce(n,e);return h?h(l,l,r):l}:ce(n,e);return this.applyTransform(i),this}};function ir(t){let e;return 2==t?e="XY":3==t?e="XYZ":4==t&&(e="XYZM"),e}function rr(t){let e;return"XY"==t?e=2:"XYZ"==t||"XYM"==t?e=3:"XYZM"==t&&(e=4),e}const or=class extends nr{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 vn()}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=rr(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){vn()}setLayout(t,e,n){let i;if(t)i=rr(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=ir(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();gi(n,0,n.length,i,t,e,n),this.changed()}}scale(t,e,n){void 0===e&&(e=t),n||(n=M(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()}}},sr=class extends pn{constructor(t,e,n,i,r,o,s){super(),this.context_=t,this.pixelRatio_=e,this.extent_=n,this.transform_=i,this.transformRotation_=i?q(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=di(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=di(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=di(t,e,n,i,this.transform_,this.pixelCoordinates_);Math.abs(o)>0&&(a=bi(a,0,a.length,2,o,r,a),Ei(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_)),D(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 di(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_)),D(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(D(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_)),D(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_)),D(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:An;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:un(e||Mn)}}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||Fn,h=e.getOffset();this.strokeState_={lineCap:void 0!==n?n:Rn,lineDash:1===this.pixelRatio_?l:l.map(t=>t*this.pixelRatio_),lineDashOffset:(r||0)*this.pixelRatio_,lineJoin:void 0!==o?o:kn,lineWidth:(void 0!==s?s:1)*this.pixelRatio_,miterLimit:void 0!==a?a:10,strokeStyle:un(t||On),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:un(t||Mn)}}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:Rn,lineDash:i||Fn,lineDashOffset:r||0,lineJoin:void 0!==o?o:kn,lineWidth:void 0!==s?s:1,miterLimit:void 0!==a?a:10,strokeStyle:un(t||On)}}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:Pn,textAlign:void 0!==c?c:An,textBaseline:void 0!==u?u:Ln},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_=""}},ar=.5;function lr(t,e,n,r,o,s,a,l,h){const c=h?me(o):o,u=it(t[0]*ar,t[1]*ar);u.imageSmoothingEnabled=!1;const d=u.canvas,g=new sr(u,ar,o,null,a,l,h?le(fe(),h):null),f=n.length,p=Math.floor(16777215/f),_={};for(let t=1;t<=f;++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||!D(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=it(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 Qi({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=_[u];d||(d={},_[u]=d,d.Polygon=[],d.Circle=[],d.LineString=[],d.Point=[]);const g=i.getType();if("GeometryCollection"===g){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[g.replace("Multi","")].push(i,r)}}const m=Object.keys(_).map(Number).sort(i);for(let t=0,n=m.length;t<n;++t){const n=_[m[t]];for(const t in n){const i=n[t];for(let t=0,n=i.length;t<n;t+=2){g.setStyle(i[t+1]);for(let n=0,r=e.length;n<r;++n)g.setTransform(e[n]),g.drawGeometry(i[t])}}}return u.getImageData(0,0,d.width,d.height)}function hr(t,e,n){const i=[];if(n){const r=Math.floor(Math.round(t[0])*ar),o=Math.floor(Math.round(t[1])*ar),s=4*(W(r,0,n.width-1)+W(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}const cr={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,cr[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 ur(t,e){return parseInt(Sn(t),10)-parseInt(Sn(e),10)}function dr(t,e){const n=gr(t,e);return n*n}function gr(t,e){return.5*t/e}function fr(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()?pr(t,l,n,e,s):(0,cr[l.getType()])(t,l,n,e,s,o)}(t,e,n,i,o,s,a),u}function pr(t,e,n,i,r){if("GeometryCollection"==e.getType()){const o=e.getGeometries();for(let e=0,s=o.length;e<s;++e)pr(t,o[e],n,i,r);return}t.getBuilder(n.getZIndex(),"Default").drawCustom(e,i,n.getRenderer(),n.getHitDetectionRenderer(),r)}const _r=class extends nn{constructor(t,e,n,i){super(t),this.inversePixelTransform=e,this.frameState=n,this.context=i}},mr=class extends yn{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 vn()}getData(t){return null}prepareFrame(t){return vn()}renderFrame(t,e){return vn()}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(He,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()}},yr=[];let vr=null;const xr=class extends mr{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;vr||(vr=it(1,1,void 0,{willReadFrequently:!0})),vr.clearRect(0,0,1,1);try{vr.drawImage(t,e,n,1,1,0,0,1,1),i=vr.getImageData(0,0,1,1).data}catch{return vr=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(Ye(t.style.backgroundColor),Ye(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=wi(t),i=wi(e);for(let t=0;t<6;++t)if(0!==Math.round((n[t]-i[t])*Ci[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=et?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=it();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=O(n),r=A(n),o=P(n),s=E(n);vi(e.coordinateToPixelTransform,i),vi(e.coordinateToPixelTransform,r),vi(e.coordinateToPixelTransform,o),vi(e.coordinateToPixelTransform,s);const a=this.inversePixelTransform;vi(a,i),vi(a,r),vi(a,o),vi(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(L(n)/i*o),a=Math.round(F(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;fi(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 _r(t,this.inversePixelTransform,n,e);i.dispatchEvent(r)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_(we,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Ie,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new Mi),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(we,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Ie,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()}},Sr=class extends xr{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,g=e.viewHints,f=!(g[0]||g[1]),p=this.context,_=Math.round(L(i)/s*d),m=Math.round(F(i)/s*d),y=c.getWrapX()&&a.canWrapX(),v=y?L(h):null,x=y?Math.ceil((i[2]-h[2])/v)+(this.extendX_?2:1):1;let S=y?Math.floor((i[0]-h[0])/v)-(this.extendX_?1:0):0;do{let i=this.getRenderTransform(o,s,0,d,_,m,S*v);e.declutter&&(i=i.slice(0)),t.execute(p,[p.canvas.width,p.canvas.height],i,l,f,void 0===n?Xi:n?Ni:Yi,n?u&&e.declutter[u]:void 0)}while(++S<x)}setDrawContext_(){1!==this.opacity_&&(this.targetContext_=this.context,this.context=it(this.context.canvas.width,this.context.canvas.height,yr))}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,st(this.context),yr.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(we)&&!this.getLayer().hasListener(Ie))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=ye(n.extent);s=D(e,t.extent),s&&!g(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_,i=this.renderedRotation_,r=this.renderedProjection_,o=this.wrappedRenderedExtent_,s=this.getLayer(),a=[],l=t[0]*ar,h=t[1]*ar;a.push(this.getRenderTransform(e,n,i,ar,l,h,0).slice());const c=s.getSource(),u=r.getExtent();if(c.getWrapX()&&r.canWrapX()&&!g(u,o)){let t=o[0];const r=L(u);let s,c=0;for(;t<u[0];)--c,s=r*c,a.push(this.getRenderTransform(e,n,i,ar,l,h,s).slice()),t+=r;for(c=0,t=o[2];t>u[2];)++c,s=r*c,a.push(this.getRenderTransform(e,n,i,ar,l,h,s).slice()),t-=r}const d=fe();this.hitDetectionImageData_=lr(t,a,this.renderedFeatures_,s.getStyleFunction(),o,n,i,dr(n,this.renderedPixelRatio_),d?r:null)}e(hr(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=Sn(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,f=t.pixelRatio,p=e.getRevision(),_=e.getRenderBuffer();let m=e.getRenderOrder();void 0===m&&(m=ur);const y=h.center.slice(),v=c(a,_*d),x=v.slice(),S=[v.slice()],C=u.getExtent(),w=n.getWrapX()&&u.canWrapX();if(this.extendX_=!1,w){const t=n.getExtent();t&&!G(t)&&(this.extendX_=t[0]<C[0]||t[2]>C[2])}if(w&&(!g(C,t.extent)||this.extendX_)){const t=L(C),e=Math.max(L(v)/2,t);let n=C[0],i=C[2];this.extendX_&&(n-=t,i+=t),v[0]=n-e,v[2]=i+e,Q(y,u);const r=j(S[0],u);r[0]<C[0]&&r[2]<C[2]?S.push([r[0]+t,r[1],r[2]+t,r[3]]):r[0]>C[0]&&r[2]>C[2]&&S.push([r[0]-t,r[1],r[2]-t,r[3]])}if(this.ready&&this.renderedResolution_==d&&this.renderedPixelRatio_===f&&this.renderedRevision_==p&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!t.declutter&&g(this.wrappedRenderedExtent_,v))return l(this.renderedExtent_,x)||(this.hitDetectionImageData_=null,this.renderedExtent_=x),this.renderedCenter_=y,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const I=new ui(gr(d,f),v,d,f),b=fe();let T;if(b){for(let t=0,e=S.length;t<e;++t){const e=me(S[t]);n.loadFeatures(e,ve(d),b)}T=le(b,u)}else for(let t=0,e=S.length;t<e;++t)n.loadFeatures(S[t],d,u);const E=dr(d,f);let P=!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,E,i,I,T,this.getLayer().getDeclutter(),n);P=P&&!e}},R=me(v),F=n.getFeaturesInExtent(R);m&&F.sort(m);for(let t=0,e=F.length;t<e;++t)M(F[t],t);this.renderedFeatures_=F,this.ready=P;const k=I.finish(),O=new qi(v,d,f,n.getOverlaps(),k,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=d,this.renderedRevision_=p,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=x,this.wrappedRenderedExtent_=v,this.renderedCenter_=y,this.renderedProjection_=u,this.renderedPixelRatio_=f,this.replayGroup_=O,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=fr(i,t,n[l],e,this.boundHandleStyleImageChange_,r,o,s)||a;else a=fr(i,t,n,e,this.boundHandleStyleImageChange_,r,o,s);return a}};function Cr(t,e,n=0,i=t.length-1,r=Ir){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);Cr(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(wr(t,n,e),r(t[i],o)>0&&wr(t,n,i);s<a;){for(wr(t,s,a),s++,a--;r(t[s],o)<0;)s++;for(;r(t[a],o)>0;)a--}0===r(t[n],o)?wr(t,n,a):(a++,wr(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function wr(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function Ir(t,e){return t<e?-1:t>e?1:0}class br{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(!Gr(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;Gr(t,a)&&(e.leaf?n.push(s):Dr(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n}collides(t){let e=this.data;if(!Gr(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(Gr(t,o)){if(e.leaf||Dr(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=jr([]),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=Tr(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!Dr(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=jr(t.slice(e,n+1)),Er(o,this.toBBox),o;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),o=jr([]),o.leaf=!1,o.height=i;const a=Math.ceil(r/s),l=a*Math.ceil(Math.sqrt(s));Vr(t,e,n,l,this.compareMinX);for(let r=e;r<=n;r+=l){const e=Math.min(r+l-1,n);Vr(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 Er(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=kr(s),l=Ar(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),Mr(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=jr(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,Er(n,this.toBBox),Er(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)}_splitRoot(t,e){this.data=jr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Er(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=Pr(t,0,s,this.toBBox),a=Pr(t,s,n,this.toBBox),l=Lr(e,a),h=kr(e)+kr(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:Rr,r=t.leaf?this.compareMinY:Fr;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=Pr(t,0,e,r),s=Pr(t,n-e,n,r);let a=Or(o)+Or(s);for(let i=e;i<n-e;i++){const e=t.children[i];Mr(o,t.leaf?r(e):e),a+=Or(o)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];Mr(s,t.leaf?r(e):e),a+=Or(s)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)Mr(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():Er(t[n],this.toBBox)}}function Tr(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 Er(t,e){Pr(t,0,t.children.length,e,t)}function Pr(t,e,n,i,r){r||(r=jr(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];Mr(r,t.leaf?i(e):e)}return r}function Mr(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 Rr(t,e){return t.minX-e.minX}function Fr(t,e){return t.minY-e.minY}function kr(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Or(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Ar(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 Lr(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 Dr(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Gr(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function jr(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Vr(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;Cr(t,s,e,n,r),o.push(e,s,s,n)}}let Wr=0;const Xr=1<<Wr++,Nr=1<<Wr++,Yr=1<<Wr++,Br=1<<Wr++,zr=1<<Wr++,Ur=1<<Wr++,qr=Math.pow(2,6)-1,Zr={[Xr]:"boolean",[Nr]:"number",[Yr]:"string",[Br]:"color",[zr]:"number[]",[Ur]:"size"},Kr=Object.keys(Zr).map(Number).sort(i);function Hr(t){const e=[];for(const n of Kr)$r(t,n)&&e.push(Zr[n]);return 0===e.length?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function $r(t,e){return(t&e)===e}function Jr(t,e){return t===e}class Qr{constructor(t,e){if(!function(t){return t in Zr}(t))throw new Error(`literal expressions must have a specific type, got ${Hr(t)}`);this.type=t,this.value=e}}class to{constructor(t,e,...n){this.type=t,this.operator=e,this.args=n}}function eo(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1}}function no(t,e,n){switch(typeof t){case"boolean":if(Jr(e,Yr))return new Qr(Yr,t?"true":"false");if(!$r(e,Xr))throw new Error(`got a boolean, but expected ${Hr(e)}`);return new Qr(Xr,t);case"number":if(Jr(e,Ur))return new Qr(Ur,Zi(t));if(Jr(e,Xr))return new Qr(Xr,!!t);if(Jr(e,Yr))return new Qr(Yr,t.toString());if(!$r(e,Nr))throw new Error(`got a number, but expected ${Hr(e)}`);return new Qr(Nr,t);case"string":if(Jr(e,Br))return new Qr(Br,Ne(t));if(Jr(e,Xr))return new Qr(Xr,!!t);if(!$r(e,Yr))throw new Error(`got a string, but expected ${Hr(e)}`);return new Qr(Yr,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=$o[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(Jr(e,Ur)){if(2!==t.length)throw new Error(`expected an array of two values for a size, got ${t.length}`);return new Qr(Ur,t)}if(Jr(e,Br)){if(3===t.length)return new Qr(Br,[...t,1]);if(4===t.length)return new Qr(Br,t);throw new Error(`expected an array of 3 or 4 values for a color, got ${t.length}`)}if(!$r(e,zr))throw new Error(`got an array of numbers, but expected ${Hr(e)}`);return new Qr(zr,t)}const io="get",ro="var",oo="concat",so="geometry-type",ao="line-metric",lo="any",ho="all",co="!",uo="resolution",go="zoom",fo="time",po="==",_o="!=",mo=">",yo=">=",vo="<",xo="<=",So="*",Co="/",wo="+",Io="-",bo="clamp",To="%",Eo="^",Po="abs",Mo="floor",Ro="ceil",Fo="round",ko="sin",Oo="cos",Ao="atan",Lo="sqrt",Do="match",Go="between",jo="interpolate",Vo="coalesce",Wo="case",Xo="in",No="number",Yo="string",Bo="array",zo="color",Uo="id",qo="band",Zo="palette",Ko="to-string",Ho="has",$o={[io]:os(es(1,1/0),Jo),[ro]:os(es(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 Qr(Yr,i)]}),[Ho]:os(es(1,1/0),Jo),[Uo]:os(function(t,e,n){n.featureId=!0},ts),[oo]:os(es(2,1/0),is(Yr)),[so]:os(function(t,e,n){n.geometryType=!0},ts),[ao]:os(function(t,e,n){n.mCoordinate=!0},ts),[uo]:os(Qo,ts),[go]:os(Qo,ts),[fo]:os(Qo,ts),[lo]:os(es(2,1/0),is(Xr)),[ho]:os(es(2,1/0),is(Xr)),[co]:os(es(1,1),is(Xr)),[po]:os(es(2,2),is(qr)),[_o]:os(es(2,2),is(qr)),[mo]:os(es(2,2),is(Nr)),[yo]:os(es(2,2),is(Nr)),[vo]:os(es(2,2),is(Nr)),[xo]:os(es(2,2),is(Nr)),[So]:os(es(2,1/0),ns),[Vo]:os(es(2,1/0),ns),[Co]:os(es(2,2),is(Nr)),[wo]:os(es(2,1/0),is(Nr)),[Io]:os(es(2,2),is(Nr)),[bo]:os(es(3,3),is(Nr)),[To]:os(es(2,2),is(Nr)),[Eo]:os(es(2,2),is(Nr)),[Po]:os(es(1,1),is(Nr)),[Mo]:os(es(1,1),is(Nr)),[Ro]:os(es(1,1),is(Nr)),[Fo]:os(es(1,1),is(Nr)),[ko]:os(es(1,1),is(Nr)),[Oo]:os(es(1,1),is(Nr)),[Ao]:os(es(1,2),is(Nr)),[Lo]:os(es(1,1),is(Nr)),[Do]:os(es(4,1/0),rs,function(t,e,n){const i=t.length-1,r=Yr|Nr|Xr,o=no(t[1],r,n),s=no(t[t.length-1],e,n),a=new Array(i-2);for(let e=0;e<i-2;e+=2){try{const i=no(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=no(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]}),[Go]:os(es(3,3),is(Nr)),[jo]:os(es(6,1/0),rs,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 Qr(Nr,r);let s;try{s=no(t[2],Nr,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=no(t[i+3],Nr,n);a[i]=e}catch(t){throw new Error(`failed to parse argument ${i+2} for interpolate expression: ${t.message}`)}try{const r=no(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]}),[Wo]:os(es(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=no(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=no(t[e+1],Xr,n);r[e]=i}catch(t){throw new Error(`failed to parse argument ${e} of case expression: ${t.message}`)}try{const o=no(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}),[Xo]:os(es(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]?Yr:Nr;const o=new Array(r.length);for(let t=0;t<o.length;t++)try{const e=no(r[t],i,n);o[t]=e}catch(e){throw new Error(`failed to parse haystack item ${t} for "in" expression: ${e.message}`)}return[no(t[1],i,n),...o]}),[No]:os(es(1,1/0),is(qr)),[Yo]:os(es(1,1/0),is(qr)),[Bo]:os(es(1,1/0),is(Nr)),[zo]:os(es(1,4),is(Nr)),[qo]:os(es(1,3),is(Nr)),[Zo]:os(es(2,2),function(t,e,n){let i;try{i=no(t[1],Nr,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=no(r[t],Br,n)}catch(e){throw new Error(`failed to parse color at index ${t} in palette expression: ${e.message}`)}if(!(e instanceof Qr))throw new Error(`the palette color at index ${t} must be a literal value`);o[t]=e}return[i,...o]}),[Ko]:os(es(1,1),is(Xr|Nr|Yr|Br))};function Jo(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 Qr(Nr,i);break;case"string":r[e]=new Qr(Yr,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 Qo(t,e,n){n.mapState=!0}function ts(t,e,n){const i=t[0];if(1!==t.length)throw new Error(`expected no arguments for ${i} operation`);return[]}function es(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 ns(t,e,n){const i=t.length-1,r=new Array(i);for(let o=0;o<i;++o){const i=no(t[o+1],e,n);r[o]=i}return r}function is(t){return function(e,n,i){const r=e.length-1,o=new Array(r);for(let n=0;n<r;++n){const r=no(e[n+1],t,i);o[n]=r}return o}}function rs(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 os(...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 to(n,r,...o)}}function ss(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 ss(t.getGeometries()[0]);default:return""}}function as(t,e,n){return ls(no(t,e,n),n)}function ls(t,e){if(t instanceof Qr){if(t.type===Br&&"string"==typeof t.value){const e=Ne(t.value);return function(){return e}}return function(){return t.value}}const n=t.operator;switch(n){case No:case Yo:case Vo: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]=ls(t.args[n],e);switch(n){case Vo: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 No:case Yo: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 io:case ro:case Ho:return function(t){const e=t.args[0].value;switch(t.operator){case io: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 ro:return t=>t.variables[e];case Ho: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 so:return t=>t.geometryType;case oo:{const n=t.args.map(t=>ls(t,e));return t=>"".concat(...n.map(e=>e(t).toString()))}case uo:return t=>t.resolution;case lo:case ho:case Go:case Xo: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]=ls(t.args[n],e);switch(n){case lo:return t=>{for(let e=0;e<i;++e)if(r[e](t))return!0;return!1};case ho:return t=>{for(let e=0;e<i;++e)if(!r[e](t))return!1;return!0};case Go:return t=>{const e=r[0](t),n=r[1](t),i=r[2](t);return e>=n&&e<=i};case Xo: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 po:case _o:case"<":case xo:case">":case yo:return function(t,e){const n=t.operator,i=ls(t.args[0],e),r=ls(t.args[1],e);switch(n){case po:return t=>i(t)===r(t);case _o:return t=>i(t)!==r(t);case"<":return t=>i(t)<r(t);case xo:return t=>i(t)<=r(t);case">":return t=>i(t)>r(t);case yo:return t=>i(t)>=r(t);default:throw new Error(`Unsupported comparison operator ${n}`)}}(t,e);case"*":case"/":case"+":case"-":case bo:case"%":case"^":case Po:case Mo:case Ro:case Fo:case ko:case Oo:case Ao:case Lo: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]=ls(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 bo: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 Po:return t=>Math.abs(r[0](t));case Mo:return t=>Math.floor(r[0](t));case Ro:return t=>Math.ceil(r[0](t));case Fo:return t=>Math.round(r[0](t));case ko:return t=>Math.sin(r[0](t));case Oo:return t=>Math.cos(r[0](t));case Ao:return 2===i?t=>Math.atan2(r[0](t),r[1](t)):t=>Math.atan(r[0](t));case Lo:return t=>Math.sqrt(r[0](t));default:throw new Error(`Unsupported numeric operator ${n}`)}}(t,e);case Wo:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=ls(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 Do:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=ls(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 jo:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=ls(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=De(l)),n>=r)return 2===a?l:h?cs(e,r,o,s,n,l):hs(e,r,o,s,n,l);o=n,s=l}return s}}(t,e);case Ko: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]=ls(t.args[n],e);if(n===Ko)return e=>{const n=r[0](e);return t.args[0].type===Br?Be(n):n.toString()};throw new Error(`Unsupported convert operator ${n}`)}(t,e);default:throw new Error(`Unsupported operator ${n}`)}}function hs(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 cs(t,e,n,i,r,o){if(0===r-n)return i;const s=Xe(i),a=Xe(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=je(e),o=je(e+n/500*Math.cos(i)),s=je(e-n/200*Math.sin(i)),a=Ge(3.021973625*o-1.617392459*r-.404875592*s),l=Ge(-.943766287*o+1.916279586*r+.027607165*s),h=Ge(.069407491*o-.22898585*r+1.159737864*s);return[W(a+.5|0,0,255),W(l+.5|0,0,255),W(h+.5|0,0,255),t[3]]}([hs(t,e,n,s[0],r,a[0]),hs(t,e,n,s[1],r,a[1]),s[2]+hs(t,e,n,0,r,l),hs(t,e,n,i[3],r,o[3])])}class us extends Hi{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 us({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=sn.get(n,null)?.getImage(1);if(!i){const e=this.renderOptions_,r=Math.ceil(e.size*t),o=it(r,r);this.draw_(e,o,t),i=o.canvas;const s=new cn(i,void 0,null,2,null);sn.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),g=Math.sqrt((i+u)*(i+u)+d*d)-i;if(void 0===this.radius2_||"bevel"===t)return 2*g;const f=i*Math.sin(s),p=r-Math.sqrt(i*i-f*f),_=Math.sqrt(f*f+p*p)/f;if(_<=n){const t=_*e/2-r-i;return 2*Math.max(g,t)}return 2*g}createRenderOptions(){let t,e=Rn,n=kn,i=0,r=null,o=0,s=0;this.stroke_&&(t=un(this.stroke_.getColor()??On),s=this.stroke_.getWidth()??1,r=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset()??0,n=this.stroke_.getLineJoin()??kn,e=this.stroke_.getLineCap()??Rn,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=Mn),e.fillStyle=un(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=Ye(n)),null===n?i=1:Array.isArray(n)&&(i=4===n.length?n[3]:1),0===i&&(e=it(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=Mn,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 ds=us;class gs extends ds{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 gs({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 fs=gs;class ps{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 ps({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=hn(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?Sn(t):"object"==typeof t&&"src"in t?t.src+":"+t.offset:Ye(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}const _s=ps;class ms{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 ms({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 ys=ms;class vs{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=ws,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 vs({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_=ws,this.geometry_=t}setZIndex(t){this.zIndex_=t}}let xs=null;function Ss(t,e){if(!xs){const t=new _s({color:"rgba(255,255,255,0.4)"}),e=new ys({color:"#3399CC",width:1.25});xs=[new vs({image:new fs({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return xs}function Cs(){const t={},e=[255,255,255,1],n=[0,153,255,1];return t.Polygon=[new vs({fill:new _s({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new vs({stroke:new ys({color:e,width:5})}),new vs({stroke:new ys({color:n,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new vs({image:new fs({radius:6,fill:new _s({color:n}),stroke:new ys({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function ws(t){return t.getGeometry()}const Is=vs;class bs{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_=Zi(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 _s({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 bs({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 _s?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_=Zi(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 Ts=bs;function Es(t){return!0}function Ps(t){const e=eo(),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?as(n.filter,Xr,e):Es;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]=Rs(n.style[i],e)}else s=[Rs(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=ss(t.getGeometry())),n(i)}}function Ms(t){const e=eo(),n=t.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=Rs(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 Rs(t,e){const n=Fs(t,"",e),i=ks(t,"",e),r=function(t,e){const n="text-",i=Ls(t,n+"value",e);if(!i)return null;const r=Fs(t,n,e),o=Fs(t,n+"background-",e),s=ks(t,n,e),a=ks(t,n+"background-",e),l=Ls(t,n+"font",e),h=As(t,n+"max-angle",e),c=As(t,n+"offset-x",e),u=As(t,n+"offset-y",e),d=Ds(t,n+"overflow",e),g=Ls(t,n+"placement",e),f=As(t,n+"repeat",e),p=Xs(t,n+"scale",e),_=Ds(t,n+"rotate-with-view",e),m=As(t,n+"rotation",e),y=Ls(t,n+"align",e),v=Ls(t,n+"justify",e),x=Ls(t,n+"baseline",e),S=Ds(t,n+"keep-upright",e),C=js(t,n+"padding",e),w=zs(t,n+"declutter-mode"),I=new Ts({declutterMode:w});return function(t){if(I.setText(i(t)),r&&I.setFill(r(t)),o&&I.setBackgroundFill(o(t)),s&&I.setStroke(s(t)),a&&I.setBackgroundStroke(a(t)),l&&I.setFont(l(t)),h&&I.setMaxAngle(h(t)),c&&I.setOffsetX(c(t)),u&&I.setOffsetY(u(t)),d&&I.setOverflow(d(t)),g){const e=g(t);if("point"!==e&&"line"!==e)throw new Error("Expected point or line for text-placement");I.setPlacement(e)}if(f&&I.setRepeat(f(t)),p&&I.setScale(p(t)),_&&I.setRotateWithView(_(t)),m&&I.setRotation(m(t)),y){const e=y(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");I.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");I.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");I.setTextBaseline(e)}return C&&I.setPadding(C(t)),S&&I.setKeepUpright(S(t)),I}}(t,e),o=function(t,e){return"icon-src"in t?function(t,e){const n="icon-",i=n+"src",r=qs(t[i],i),o=Vs(t,n+"anchor",e),s=Xs(t,n+"scale",e),a=As(t,n+"opacity",e),l=Vs(t,n+"displacement",e),h=As(t,n+"rotation",e),c=Ds(t,n+"rotate-with-view",e),u=Ys(t,n+"anchor-origin"),d=Bs(t,n+"anchor-x-units"),g=Bs(t,n+"anchor-y-units"),f=Os(t,n+"color");let p,_=null;void 0!==f&&(Array.isArray(f)&&f.length>0&&"string"==typeof f[0]?_=Gs(t,n+"color",e):p=Ks(f,n+"color"));const m=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"),y=function(t,e){const n=t[e];if(void 0!==n)return Us(n,e)}(t,n+"offset"),v=Ys(t,n+"offset-origin"),x=Ns(t,n+"width"),S=Ns(t,n+"height"),C=function(t,e){const n=t[e];if(void 0!==n){if("number"==typeof n)return Zi(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"),w={src:r,anchorOrigin:u,anchorXUnits:d,anchorYUnits:g,crossOrigin:m,offset:y,offsetOrigin:v,height:S,width:x,size:C,declutterMode:zs(t,n+"declutter-mode")};let I=null;return function(t){if(I)_&&I.setColor(_(t));else{const e=_?_(t):p;I=new Qi(void 0!==e?Object.assign({},w,{color:e}):Object.assign({},w))}return a&&I.setOpacity(a(t)),l&&I.setDisplacement(l(t)),h&&I.setRotation(h(t)),c&&I.setRotateWithView(c(t)),s&&I.setScale(s(t)),o&&I.setAnchor(o(t)),I}}(t,e):"shape-points"in t?function(t,e){const n="shape-",i=n+"points",r=n+"radius",o=Zs(t[i],i);if(!(r in t))throw new Error(`Expected a number for ${r}`);const s=As(t,r,e),a="number"==typeof t[r]?t[r]:5,l=n+"radius2",h=As(t,l,e),c="number"==typeof t[l]?t[l]:void 0,u=Fs(t,n,e),d=ks(t,n,e),g=Xs(t,n+"scale",e),f=Vs(t,n+"displacement",e),p=As(t,n+"rotation",e),_=Ds(t,n+"rotate-with-view",e),m=Ns(t,n+"angle"),y=zs(t,n+"declutter-mode"),v=new ds({points:o,radius:a,radius2:c,angle:m,declutterMode:y});return function(t){return s&&v.setRadius(s(t)),h&&v.setRadius2(h(t)),u&&v.setFill(u(t)),d&&v.setStroke(d(t)),f&&v.setDisplacement(f(t)),p&&v.setRotation(p(t)),_&&v.setRotateWithView(_(t)),g&&v.setScale(g(t)),v}}(t,e):"circle-radius"in t?function(t,e){const n="circle-",i=Fs(t,n,e),r=ks(t,n,e),o=As(t,n+"radius",e),s=Xs(t,n+"scale",e),a=Vs(t,n+"displacement",e),l=As(t,n+"rotation",e),h=Ds(t,n+"rotate-with-view",e),c=zs(t,n+"declutter-mode"),u=new fs({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=As(t,"z-index",e);if(!(n||i||r||o||Ue(t)))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(t));const a=new Is;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 Fs(t,e,n){let i;if(e+"fill-pattern-src"in t)i=function(t,e,n){const i=Ls(t,e+"pattern-src",n),r=Ws(t,e+"pattern-offset",n),o=Ws(t,e+"pattern-size",n),s=Gs(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=Gs(t,e+"fill-color",n)}if(!i)return null;const r=new _s;return function(t){const e=i(t);return e===be?null:(r.setColor(e),r)}}function ks(t,e,n){const i=As(t,e+"stroke-width",n),r=Gs(t,e+"stroke-color",n);if(!i&&!r)return null;const o=Ls(t,e+"stroke-line-cap",n),s=Ls(t,e+"stroke-line-join",n),a=js(t,e+"stroke-line-dash",n),l=As(t,e+"stroke-line-dash-offset",n),h=As(t,e+"stroke-miter-limit",n),c=As(t,e+"stroke-offset",n),u=new ys;return function(t){if(r){const e=r(t);if(e===be)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 Os(t,e){if(!(e in t))return;const n=t[e];return void 0===n?void 0:n}function As(t,e,n){const i=Os(t,e);if(void 0===i)return;const r=as(i,Nr,n);return function(t){return Zs(r(t),e)}}function Ls(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,Yr,n);return function(t){return qs(r(t),e)}}function Ds(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,Xr,n);return function(t){const n=r(t);if("boolean"!=typeof n)throw new Error(`Expected a boolean for ${e}`);return n}}function Gs(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,Br,n);return function(t){return Ks(r(t),e)}}function js(t,e,n){const i=Os(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=as(t,Nr,n);return function(t){return Zs(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=as(i,zr,n);return function(t){return Us(r(t),e)}}function Vs(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,zr,n);return function(t){const n=Us(r(t),e);if(2!==n.length)throw new Error(`Expected two numbers for ${e}`);return n}}function Ws(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,zr,n);return function(t){return Hs(r(t),e)}}function Xs(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,zr|Nr,n);return function(t){return n=r(t),i=e,"number"==typeof n?n:Hs(n,i);var n,i}}function Ns(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 Ys(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 Bs(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 zs(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 Us(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 qs(t,e){if("string"!=typeof t)throw new Error(`Expected a string for ${e}`);return t}function Zs(t,e){if("number"!=typeof t)throw new Error(`Expected a number for ${e}`);return t}function Ks(t,e){if("string"==typeof t)return t;const n=Us(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 Hs(t,e){const n=Us(t,e);if(2!==n.length)throw new Error(`Expected an array of two numbers for ${e}`);return n}const $s={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Js(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,g=t[2]-l/2+c,f=t[1]+h/2+u,p=t[3]-h/2+u;d>g&&(d=(g+d)/2,g=d),f>p&&(f=(p+f)/2,p=f);let _=W(i[0],d,g),m=W(i[1],f,p);if(s&&n&&r){const t=30*r;_+=-t*Math.log(1+Math.max(0,d-i[0])/t)+t*Math.log(1+Math.max(0,i[0]-g)/t),m+=-t*Math.log(1+Math.max(0,f-i[1])/t)+t*Math.log(1+Math.max(0,i[1]-p)/t)}return[_,m]}}function Qs(t){return t}function ta(t){return Math.pow(t,3)}function ea(t){return 1-ta(1-t)}function na(t){return 3*t*t-2*t*t*t}function ia(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 ra(t,e,n,i){let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o];r+=ia(t,e,s,i),e=s}return r}function oa(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]=U(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 sa(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=N(o,s,n,i);a>r&&(r=a),o=n,s=i}return r}function aa(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];r=sa(t,e,s,i,r),e=s}return r}function la(t,e,n,i,r,o,s,a,l,h,c){if(e==n)return h;let u,d;if(0===r){if(d=N(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 g=e+i;for(;g<n;)if(oa(t,g-i,g,i,s,a,c),d=N(s,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,g+=i}else g+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/r|0,1);if(o&&(oa(t,n-i,e,i,s,a,c),d=N(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 ha(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=la(t,e,d,i,r,o,s,a,l,h,c),e=d}return h}function ca(t,e,n,i){for(let i=0,r=n.length;i<r;++i)t[e++]=n[i];return e}function ua(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 da(t,e,n,i,r){r=r||[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=ua(t,e,n[s],i);r[o++]=a,e=a}return r.length=o,r}function ga(t,e,n,i,r){r=r||[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=da(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 fa extends or{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 fa(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(sa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),la(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,n,i))}getArea(){return ia(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return dn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=ei(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new fa(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ua(this.flatCoordinates,0,t,this.stride),this.changed()}}const pa=fa;class _a extends or{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new _a(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){const r=this.flatCoordinates,o=N(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 y(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return f(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ca(this.flatCoordinates,0,t,this.stride),this.changed()}}const ma=_a;function ya(t,e,n,i,r){return!b(r,function(r){return!va(t,e,n,i,r[0],r[1])})}function va(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 xa(t,e,n,i,r,o){if(0===n.length)return!1;if(!va(t,e,n[0],i,r,o))return!1;for(let e=1,s=n.length;e<s;++e)if(va(t,n[e-1],n[e],i,r,o))return!1;return!0}function Sa(t,e,n,r,o,s,a){let l,h,c,u,d,g,f;const p=o[s+1],_=[];for(let i=0,o=n.length;i<o;++i){const o=n[i];for(u=t[o-r],g=t[o-r+1],l=e;l<o;l+=r)d=t[l],f=t[l+1],(p<=g&&f<=p||g<=p&&p<=f)&&(c=(p-g)/(f-g)*(d-u)+u,_.push(c)),u=d,g=f}let m=NaN,y=-1/0;for(_.sort(i),u=_[0],l=1,h=_.length;l<h;++l){d=_[l];const i=Math.abs(d-u);i>y&&(c=(u+d)/2,xa(t,e,n,r,c,p)&&(m=c,y=i)),u=d}return isNaN(m)&&(m=o[s]),a?(a.push(m,p,y),a):[m,p,y]}function Ca(t,e,n,i,r){let o=[];for(let s=0,a=n.length;s<a;++s){const a=n[s];o=Sa(t,e,a,i,r,2*s,o),e=a[a.length-1]}return o}function wa(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 Ia(t,e,n,i,r,o){return o=o??w([1/0,1/0,-1/0,-1/0],t,e,n,i),!!D(r,o)&&(o[0]>=r[0]&&o[2]<=r[2]||o[1]>=r[1]&&o[3]<=r[3]||wa(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],g=n[1],f=(g-u)/(d-c);let p,_;2&o&&!(2&r)&&(p=d-(g-h)/f,i=p>=s&&p<=l),i||!(4&o)||4&r||(_=g-(d-l)*f,i=_>=a&&_<=h),i||!(8&o)||8&r||(p=d-(g-a)/f,i=p>=s&&p<=l),i||!(16&o)||16&r||(_=g-(d-s)*f,i=_>=a&&_<=h)}return i}(r,t,e)}))}function ba(t,e,n,i,r){if(!function(t,e,n,i,r){return!!(Ia(t,e,n,i,r)||va(t,e,n,i,r[0],r[1])||va(t,e,n,i,r[0],r[3])||va(t,e,n,i,r[2],r[1])||va(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(ya(t,n[e-1],n[e],i,r)&&!Ia(t,n[e-1],n[e],i,r))return!1;return!0}function Ta(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 Ea(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 Pa(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=Ea(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 Ma(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];if(!Pa(t,e,s,i,r))return!1;s.length&&(e=s[s.length-1])}return!0}function Ra(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=Ea(t,e,s,i);(0===o?r&&a||!r&&!a:r&&!a||!r&&a)&&Ta(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=Ra(t,e,n[o],i,r);return e}class ka extends or{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 ka(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(aa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ha(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,n,i))}containsXY(t,e){return xa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return ra(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),Ra(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,gn(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=M(this.getExtent());this.flatInteriorPoint_=Sa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new ma(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new pa(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 pa(e.slice(r,s),t);i.push(a),r=s}return i}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Pa(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Ra(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=oi(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,n),new ka(e,"XY",n)}getType(){return"Polygon"}intersectsExtent(t){return ba(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=da(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}const Oa=ka;function Aa(t){if(G(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 ka(o,"XY",[o.length])}function La(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 ka(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*z(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 Da(t,e,n,i){const r=L(e)/n[0],o=F(e)/n[1];return i?Math.min(t,Math.max(r,o)):Math.min(t,Math.min(r,o))}function Ga(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),W(i,n/2,2*e)}function ja(t,e,n,i,r){return n=void 0===n||n,function(o,s,a,l){if(void 0!==o){const s=i?Da(t,i,a,r):t;return n&&l?Ga(o,s,e):W(o,e,s)}}}function Va(t){if(void 0!==t)return 0}function Wa(t){if(void 0!==t)return t}function Xa(t,e){setTimeout(function(){t(e)},0)}function Na(t){return!(t.sourceCenter&&t.targetCenter&&!H(t.sourceCenter,t.targetCenter))&&t.sourceResolution===t.targetResolution&&t.sourceRotation===t.targetRotation}function Ya(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 Ba=class extends wn{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=se(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){te=!(void 0===t||t)}(),t.center&&(t.center=_e(t.center,this.projection_)),t.extent&&(t.extent=ye(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const t in $s)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=se(t.projection,"EPSG:3857"),d=u.getExtent();let g=t.constrainOnlyCenter,f=t.extent;if(l||f||!u.isGlobal()||(g=!1,f=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?Da(h,n,a,i):h;if(l)return e?Ga(r,u,c):W(r,c,u);const d=Math.min(u,r),g=Math.floor(o(t,d,s));return t[g]>u&&g<t.length-1?t[g+1]:t[g]}}}(a,h,!g&&f,c):ja(n,i,h,!g&&f,c)}else{const o=(d?Math.max(L(d),F(d)):360*ht.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?Da(e,r,l,o):e;if(h)return i?Ga(s,c,n):W(s,n,c);const u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(t)-u),g=-a*(.5-u)+.5,f=Math.min(c,s),p=Math.floor(Math.log(e/f)/Math.log(t)+g),_=Math.max(d,p);return W(e/Math.pow(t,_),n,c)}}}(a,n,i,h,!g&&f,c):ja(n,i,h,!g&&f,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 Js(t.extent,t.constrainOnlyCenter,e)}const e=se(t.projection,"EPSG:3857");if(!0!==t.multiWorld&&e.isGlobal()){const t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,Js(t,!1,!1)}return Qs}(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=B(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 Va}(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=_e(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=_e(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&&Xa(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||na,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=z(t.rotation-a+Math.PI,2*Math.PI)-Math.PI;n.targetRotation=a+e,a=n.targetRotation}Na(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&&Xa(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?z(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&&Xa(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?pe(t,this.getProjection()):t}getCenterInternal(){return this.get($s.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 me(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();fi(e,"The view center is not defined");const n=this.getResolution();fi(void 0!==n,"The view resolution is not defined");const i=this.getRotation();return fi(void 0!==i,"The view rotation is not defined"),function(t,e,n,i){const[r,o,s,a,l,h,c,u]=R(t,e,n,i);return _(Math.min(r,s,l,c),Math.min(o,a,h,u),Math.max(r,s,l,c),Math.max(o,a,h,u),void 0)}(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($s.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(ye(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const n=L(t)/e[0],i=F(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($s.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=Ya(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=W(Math.floor(t),0,this.resolutions_.length-2),n=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(n,W(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let n;if(fi(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t))fi(!G(t),"Cannot fit empty extent provided as `geometry`"),n=Aa(ye(t,this.getProjection()));else if("Circle"===t.getType()){const e=ye(t.getExtent(),this.getProjection());n=Aa(e),n.rotate(this.getRotation(),M(e))}else{const e=fe();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=M(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,g=u[1]*c+u[0]*h,f=this.getConstrainedCenter([d,g],a),p=e.callback?e.callback:tn;void 0!==e.duration?this.animateInternal({resolution:a,center:f,duration:e.duration,easing:e.easing},p):(this.targetResolution_=a,this.targetCenter_=f,this.applyTargetState_(!1,!0),Xa(p,!0))}centerOn(t,e,n){this.centerOnInternal(_e(t,this.getProjection()),e,n)}centerOnInternal(t,e,n){this.setCenterInternal(Ya(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=Ya(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=pe(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&&_e(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=_e(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?_e(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($s.ROTATION)!==i&&this.set($s.ROTATION,i),this.get($s.RESOLUTION)!==o&&(this.set($s.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),s&&this.get($s.CENTER)&&H(this.get($s.CENTER),s)||this.set($s.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()&&H(this.getCenterInternal(),a)||(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:a,resolution:s,duration:t,easing:ea,anchor:n}))}beginInteraction(){this.resolveConstraints(0),this.setHint(1,1)}endInteraction(t,e,n){n=n&&_e(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)}},za="opacity",Ua="visible",qa="extent",Za="zIndex",Ka="maxResolution",Ha="minResolution",$a="maxZoom",Ja="minZoom",Qa="source",tl=class extends wn{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[za]=void 0!==t.opacity?t.opacity:1,fi("number"==typeof e[za],"Layer opacity must be a number"),e[Ua]=void 0===t.visible||t.visible,e[Za]=t.zIndex,e[Ka]=void 0!==t.maxResolution?t.maxResolution:1/0,e[Ha]=void 0!==t.minResolution?t.minResolution:0,e[Ja]=void 0!==t.minZoom?t.minZoom:-1/0,e[$a]=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=W(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 vn()}getLayerStatesArray(t){return vn()}getExtent(){return this.get(qa)}getMaxResolution(){return this.get(Ka)}getMinResolution(){return this.get(Ha)}getMinZoom(){return this.get(Ja)}getMaxZoom(){return this.get($a)}getOpacity(){return this.get(za)}getSourceState(){return vn()}getVisible(){return this.get(Ua)}getZIndex(){return this.get(Za)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(qa,t)}setMaxResolution(t){this.set(Ka,t)}setMinResolution(t){this.set(Ha,t)}setMaxZoom(t){this.set($a,t)}setMinZoom(t){this.set(Ja,t)}setOpacity(t){fi("number"==typeof t,"Layer opacity must be a number"),this.set(za,t)}setVisible(t){this.set(Ua,t)}setZIndex(t){this.set(Za,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},el=class extends tl{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(Qa,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(Qa)||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_&&(Ke(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=qe(t,He,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 Ba?{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||D(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let n=e(t instanceof Ba?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_&&(Ke(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(Ke(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=qe(t,"precompose",this.handlePrecompose_,this),this.mapRenderKey_=qe(this,He,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,n=this.getLayerState(!1);fi(!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(Qa,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()}},nl="renderOrder",il=class extends el{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(nl)}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 br(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(nl,t)}setStyle(t){this.style_=void 0===t?Ss:t;const e=function(t){if(void 0===t)return Ss;if(!t)return null;if("function"==typeof t)return t;if(t instanceof Is)return t;if(!Array.isArray(t))return Ms([t]);if(0===t.length)return[];const e=t.length,n=t[0];if(n instanceof Is){const n=new Array(e);for(let i=0;i<e;++i){const e=t[i];if(!(e instanceof Is))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 Ps(n)}return Ms(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:(fi("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()}},rl=class extends il{constructor(t){super(t)}createRenderer(){return new Sr(this)}},ol="add",sl="remove",al="length";class ll extends nn{constructor(t,e,n){super(t),this.element=e,this.index=n}}const hl=class extends wn{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(al)}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 ll(ol,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 ll(sl,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 ll(sl,n,t)),this.dispatchEvent(new ll(ol,e,t))}updateLength_(){this.set(al,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 cl(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 ul(t,e){return[[-1/0,-1/0,1/0,1/0]]}function dl(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 gl(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,g=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);g<0?(h=(d-u[-g-2])/(u[-g-1]-u[-g-2]),l=e+(-g-2)*r):l=e+g*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]:U(t[l+e],t[l+r+e],h);return s}function fl(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(U(t[(a-1)*i+e],t[a*i+e],c));return s.push(r),s}const pl=[1,0,0,1,0,0];class _l{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_?y(this.flatCoordinates_):v(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=M(this.getExtent());this.flatInteriorPoints_=Sa(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=Ea(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=dl(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=Ca(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=gl(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=gl(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=ie(t)).getExtent(),n=t.getWorldExtent();if(e&&n){const t=F(n)/F(e);Si(pl,n[0],n[3],t,-t,0,0,0),di(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,pl,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new _l(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=en((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=ei(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,n,0),i=[n.length];break;case"MultiLineString":i=[],n.length=ni(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,n,0,i);break;case"Polygon":i=[],n.length=oi(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),n,0,i)}return i&&(this.simplifiedGeometry_=new _l(this.type_,n,i,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}_l.prototype.getFlatCoordinates=_l.prototype.getOrientedFlatCoordinates;const ml=_l,yl=class{constructor(t){this.rbush_=new br(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_[Sn(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_[Sn(o)]=s}this.rbush_.load(n)}remove(t){const e=Sn(t),n=this.items_[e];return delete this.items_[e],null!==this.rbush_.remove(n)}update(t,e){const n=this.items_[Sn(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 Ue(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return _(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 vl(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),e=>t):null}const xl=class extends wn{constructor(t){super(),this.projection=ie(t.projection),this.attributions_=vl(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_=vl(t),this.changed()}setState(t){this.state_=t,this.changed()}},Sl="addfeature",Cl="removefeature";class wl extends nn{constructor(t,e,n){super(t),this.feature=e,this.features=n}}const Il=class extends xl{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_=tn,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_&&(fi(this.format_,"`format` must be set when `url` is set"),this.loader_=cl(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:ul;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let n,i;this.featuresRtree_=e?new yl:null,this.loadedExtentsRtree_=new yl,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 hl(i)),void 0!==i&&this.addFeaturesInternal(i),void 0!==n&&this.bindFeaturesCollection_(n)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=Sn(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 wl(Sl,t))}setupChangeEvents_(t,e){e instanceof ml||(this.featureChangeKeys_[t]=[qe(e,He,this.handleFeatureChange_,this),qe(e,_n,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 ml){const i=this.idIndex_[t];i instanceof ml?Array.isArray(i)?i.push(e):this.idIndex_[t]=[i,e]:n=!1}else n=!1;else this.idIndex_[t]=e}return n&&(fi(!(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=Sn(i);this.addToIndex_(r,i)&&n.push(i)}for(let t=0,r=n.length;t<r;t++){const r=n[t],o=Sn(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(Sl))for(let t=0,e=n.length;t<e;t++)this.dispatchEvent(new wl(Sl,n[t]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(Sl,function(n){e||(e=!0,t.push(n.feature),e=!1)}),this.addEventListener(Cl,function(n){e||(e=!0,t.remove(n.feature),e=!1)}),t.addEventListener(ol,t=>{e||(e=!0,this.addFeature(t.element),e=!1)}),t.addEventListener(sl,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(Ke);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 wl("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 ml||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 ml||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(),Ue(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=V(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||Je,this.featuresRtree_.forEachInExtent(a,function(t){if(e(t)){const e=t.getGeometry(),l=s;if(s=e instanceof ml?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=Sn(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 wl("changefeature",e))}hasFeature(t){const e=t.getId();return void 0!==e?e in this.idIndex_:Sn(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Ue(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 g(t.extent,o)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new wl("featuresloadstart"));const t=t=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new wl("featuresloadend",void 0,t))},r=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new wl("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=Sn(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(Ke),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(Cl)&&this.dispatchEvent(new wl(Cl,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){fi(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(cl(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}};class bl extends wn{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 bl,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_&&(Ke(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=qe(t,He,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:(fi("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 Tl=bl;class El extends nr{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(Ke),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,n=t.length;e<n;++e)this.changeEventsKeys_.push(qe(t[e],He,this.changed,this))}clone(){const t=new El(Pl(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){m(t);const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)S(t,e[n].getExtent());return t}getGeometries(){return Pl(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 El(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=M(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(Pl(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 Pl(t){return t.map(t=>t.clone())}const Ml=El;class Rl extends or{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 Rl(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(sa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),la(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,n,i))}forEachSegment(t){return wa(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,fl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return dn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return gl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return Ii(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=ei(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Rl(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return Ia(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=ua(this.flatCoordinates,0,t,this.stride),this.changed()}}const Fl=Rl;class kl extends or{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 kl(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(aa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ha(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 fl(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 fl(t,e,s,i,r,!1);e=s}}return null}(this.flatCoordinates,0,this.ends_,this.stride,t,e,n))}getCoordinates(){return gn(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+=Ii(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,gl(e,n,s,r,.5)),n=s}return t}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=ni(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,n),new kl(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(Ia(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=da(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}const Ol=kl;class Al extends or{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 Al(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=N(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 dn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new ma(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 ma(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(f(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=ua(this.flatCoordinates,0,t,this.stride),this.changed()}}const Ll=Al;class Dl extends or{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 Dl(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=aa(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=ha(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(xa(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+=ra(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,fn(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=dl(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Ca(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new Ll(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Ma(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=oi(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 Dl(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 Oa(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 Oa(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(ba(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=ga(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 Gl=Dl,jl=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=Tl,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let n=e.dataProjection?ie(e.dataProjection):this.readProjection(t);e.extent&&n&&"tile-pixels"===n.getUnits()&&(n=ie(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 vn()}readFeature(t,e){return vn()}readFeatures(t,e){return vn()}readGeometry(t,e){return vn()}readProjection(t){return vn()}writeFeature(t,e){return vn()}writeFeatures(t,e){return vn()}writeGeometry(t,e){return vn()}};function Vl(t,e,n){const i=n?ie(n.featureProjection):null,r=n?ie(n.dataProjection):null;let o=t;if(i&&r&&!ae(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(ce(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:ma,LineString:Fl,Polygon:Oa,MultiPoint:Ll,MultiLineString:Ol,MultiPolygon:Gl};function Xl(t,e){const n=t.geometry;if(!n)return[];if(Array.isArray(n))return n.map(e=>Xl({...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 Vl(new ml(i,"Polygon"===i?function(t,e,n){return Array.isArray(e[0])?(Ma(t,0,e,n)||Fa(t=t.slice(),0,e,n),t):(Pa(t,0,e,n)||Ra(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 Nl(t,e){if(!t)return null;if(Array.isArray(t)){const n=t.map(t=>Nl(t,e));return new Ml(n)}return Vl(new(0,Wl[t.type])(t.flatCoordinates,t.layout||"XY",t.ends),!1,e)}function Yl(t){if("string"==typeof t){return JSON.parse(t)||null}return null!==t?t:null}const Bl=class extends jl{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Yl(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Yl(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return vn()}readFeaturesFromObject(t,e){return vn()}readGeometry(t,e){return this.readGeometryFromObject(Yl(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return vn()}readProjection(t){return this.readProjectionFromObject(Yl(t))}readProjectionFromObject(t){return vn()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return vn()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return vn()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return vn()}};function zl(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:ir(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:ir(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:da(n,0,e,i),layout:ir(i)}}(t);break;case"MultiPoint":n=function(t){const e=t.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:ir(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:da(i,0,e,n),layout:ir(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:ga(n,0,e,i),layout:ir(i)}}(t);break;case"GeometryCollection":n=function(t){const e=t.geometries.map(function(t){return zl(t)});return e}(t);break;default:throw new Error("Unsupported GeoJSON type: "+t.type)}return n}function Ul(t,e){const n=(t=Vl(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 Ul(t,e)})}}(t,e);break;case"Circle":i={type:"GeometryCollection",geometries:[]};break;default:throw new Error("Unsupported geometry type: "+n)}return i}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 Zl="EPSG:27700",Kl=new class extends Bl{constructor(t){t=t||{},super(),this.dataProjection=ie(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=ie(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=zl(n.geometry);if(this.featureClass===ml)return Xl({geometry:i,id:n.id,properties:n.properties},e);const r=new Tl;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&r.setGeometryName(n.geometry_name),r.setGeometry(Nl(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 Nl(zl(t),e)}(t,e)}readProjectionFromObject(t){const e=t.crs;let n;if(e)if("name"==e.type)n=ie(e.properties.name);else{if("EPSG"!==e.type)throw new Error("Unknown SRS type");n=ie("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=Ul(o,e),delete r[t.getGeometryName()]),Ue(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 Ul(t,this.adaptOptions(e))}}({dataProjection:Zl,featureProjection:Zl}),Hl=n(610),$l=n(682),Jl={Polygon:2,LineString:1},Ql=function(t){var e,n=t.getType();return("Polygon"===n?null!==(e=t.getCoordinates()[0])&&void 0!==e?e:[]:t.getCoordinates()).slice(0,-Jl[n])},th=function(t){var e;return null!==(e=Ql(t).at(-1))&&void 0!==e?e:null};function eh(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 nh={outer:$l.F0.vertexHaloRadius+3,mid:$l.F0.vertexHaloRadius,inner:$l.F0.vertexRadius},ih={outer:$l.F0.midpointHaloRadius+3,mid:$l.F0.midpointHaloRadius,inner:$l.F0.midpointRadius},rh=function(t,e,n,i,r){t.beginPath(),t.arc(e,n,i,0,2*Math.PI),t.fillStyle=r,t.fill()},oh=function(t,e,n){var i=t.outer,r=t.mid,o=t.inner;return function(t,s){var a,l,h=s.context,c=s.pixelRatio,u=(l=2,function(t){if(Array.isArray(t))return t}(a=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}}(a,l)||function(t,e){if(t){if("string"==typeof t)return eh(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)?eh(t,e):void 0}}(a,l)||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.")}()),d=u[0],g=u[1];h.save(),rh(h,d,g,i*c,e.editActive),rh(h,d,g,r*c,e.editHalo),rh(h,d,g,o*c,e[n]),h.restore()}},sh=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},ah=function(t){var e=function(t){var e=new fs({radius:$l.F0.vertexRadius,fill:new _s({color:t.editVertex})});return{vertexImage:e,vertexStyle:new Is({image:e}),selectedVertexStyle:new Is({renderer:oh(nh,t,"editVertex")})}}(t),n=e.vertexImage,i=e.vertexStyle,r=e.selectedVertexStyle,o=function(t){return{midpointStyle:new Is({image:new fs({radius:$l.F0.midpointRadius,fill:new _s({color:t.editMidpoint})})}),selectedMidpointStyle:new Is({renderer:oh(ih,t,"editMidpoint")})}}(t),s=o.midpointStyle,a=o.selectedMidpointStyle,l=new Is({stroke:new ys({color:t.editStroke,width:2}),fill:new _s({color:t.editFill})}),h=new Is({stroke:new ys({color:t.invalidStroke,width:2,lineDash:[2,4]})}),c=function(t){return{valid:new Is({stroke:new ys({color:t.editStroke,width:2}),fill:new _s({color:t.editFill})}),invalid:new Is({stroke:new ys({color:t.invalidStroke,width:2,lineDash:[2,4]})}),splitValid:new Is({stroke:new ys({color:t.splitValid,width:2})}),splitInvalid:new Is({stroke:new ys({color:t.splitInvalid,width:2,lineDash:[2,4]})})}}(t),u=new Ll([]),d=new Is({image:n,geometry:function(t){var e=Ql(t.getGeometry());return e.length?(u.setCoordinates(e),u):null}});return{vertexStyle:i,selectedVertexStyle:r,midpointStyle:s,selectedMidpointStyle:a,editFeatureStyle:l,editFeatureStyleInvalid:h,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){var n=e.getProperties(),i=t.mapStyleId,r=i&&n["stroke".concat(sh(i))]||n.stroke||t.shapeStroke,o=i&&n["fill".concat(sh(i))]||n.fill||t.shapeFill,s=n.strokeWidth||t.strokeWidth;return[new Is({stroke:new ys({color:r,width:s}),fill:new _s({color:o})})]}}}},lh=n(473);const hh=class extends rn{constructor(t,e,n){super(),n=n||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=void 0===n.transition?250:n.transition,this.transitionStarts_={},this.interpolate=!!n.interpolate}changed(){this.dispatchEvent(He)}release(){this.setState(4)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(4!==this.state){if(3!==this.state&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){vn()}getAlpha(t,e){if(!this.transition_)return 1;let n=this.transitionStarts_[t];if(n){if(-1===n)return 1}else n=e,this.transitionStarts_[t]=n;const i=e-n+1e3/60;return i>=this.transition_?1:ta(i/this.transition_)}inTransition(t){return!!this.transition_&&-1!==this.transitionStarts_[t]}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}};function ch(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageBitmap?t:null}const uh=new Error("disposed"),dh=[256,256],gh=class extends hh{constructor(t){super(t.tileCoord,0,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=ch(this.data_);return t?[t.width,t.height]:dh}getData(){return this.data_}getError(){return this.error_}load(){if(0!==this.state&&3!==this.state)return;this.state=1,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=2,t.changed()}).catch(function(e){t.error_=e,t.state=3,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(uh),this.controller_=null),super.disposeInternal()}},fh=class extends hh{constructor(t,e,n,i,r,o){super(t,e,o),this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.src_=n,this.key=n,this.image_,et?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=2,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=3,this.unlistenImage_(),this.image_=function(){const t=it(1,1);return t.fillStyle="rgba(0,0,0,0)",t.fillRect(0,0,1,1),t.canvas}(),this.changed()}handleImageLoad_(){if(et)this.state=2;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=2:this.state=4}this.unlistenImage_(),this.changed()}load(){3==this.state&&(this.state=0,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),0==this.state&&(this.state=1,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=function(t,e,n){const i=t;let r=!0,o=!1,s=!1;const a=[Ze(i,"load",function(){s=!0,o||e()})];return i.src&&nt?(o=!0,i.decode().then(function(){r&&e()}).catch(function(t){r&&(s?e():n())})):a.push(Ze(i,"error",n)),function(){r=!1,a.forEach(Ke)}}(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}};const ph=class{constructor(t,e,n,i){this.minX=t,this.maxX=e,this.minY=n,this.maxY=i}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}};let _h;const mh=[];function yh(t,e,n,i,r){t.beginPath(),t.moveTo(0,0),t.lineTo(e,n),t.lineTo(i,r),t.closePath(),t.save(),t.clip(),t.fillRect(0,0,Math.max(e,i)+1,Math.max(n,r)),t.restore()}function vh(t,e){return Math.abs(t[4*e]-210)>2||Math.abs(t[4*e+3]-191.25)>2}function xh(t,e,n,i){const r=ue(n,e,t);let o=re(e,i,n);const s=e.getMetersPerUnit();void 0!==s&&(o*=s);const a=t.getMetersPerUnit();void 0!==a&&(o/=a);const l=t.getExtent();if(!l||d(l,r)){const e=re(t,o,r)/o;isFinite(e)&&e>0&&(o/=e)}return o}const Sh=class{constructor(t,e,n,i,r,o,s){this.sourceProj_=t,this.targetProj_=e;let a={};const l=s?(h=t=>vi(s,ue(t,this.targetProj_,this.sourceProj_)),function(t,e,n,i){const r=t.length;n=void 0!==n?n:2,i=i??n,e=void 0!==e?e:new Array(r);for(let o=0;o<r;o+=i){const r=h(t.slice(o,o+n)),s=r.length;for(let n=0,a=i;n<a;++n)e[o+n]=n>=s?t[o+n]:r[n]}return e}):ce(this.targetProj_,this.sourceProj_);var h;this.transformInv_=function(t){const e=t[0]+"/"+t[1];return a[e]||(a[e]=l(t)),a[e]},this.maxSourceExtent_=i,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!i&&!!this.sourceProj_.getExtent()&&L(i)>=L(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?L(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?L(this.targetProj_.getExtent()):null;const c=O(n),u=A(n),d=P(n),g=E(n),f=this.transformInv_(c),p=this.transformInv_(u),_=this.transformInv_(d),m=this.transformInv_(g),y=10+(o?Math.max(0,Math.ceil(Math.log2(T(n)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,g,f,p,_,m,y),this.wrapsXInSource_){let t=1/0;this.triangles_.forEach(function(e,n,i){t=Math.min(t,e.source[0][0],e.source[1][0],e.source[2][0])}),this.triangles_.forEach(e=>{if(Math.max(e.source[0][0],e.source[1][0],e.source[2][0])-t>this.sourceWorldWidth_/2){const n=[[e.source[0][0],e.source[0][1]],[e.source[1][0],e.source[1][1]],[e.source[2][0],e.source[2][1]]];n[0][0]-t>this.sourceWorldWidth_/2&&(n[0][0]-=this.sourceWorldWidth_),n[1][0]-t>this.sourceWorldWidth_/2&&(n[1][0]-=this.sourceWorldWidth_),n[2][0]-t>this.sourceWorldWidth_/2&&(n[2][0]-=this.sourceWorldWidth_);const i=Math.min(n[0][0],n[1][0],n[2][0]);Math.max(n[0][0],n[1][0],n[2][0])-i<this.sourceWorldWidth_/2&&(e.source=n)}})}a={}}addTriangle_(t,e,n,i,r,o){this.triangles_.push({source:[i,r,o],target:[t,e,n]})}addQuad_(t,e,n,i,r,o,s,a,l){const c=h([r,o,s,a]),u=this.sourceWorldWidth_?L(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,g=this.sourceProj_.canWrapX()&&u>.5&&u<1;let f=!1;if(l>0&&(this.targetProj_.isGlobal()&&this.targetWorldWidth_&&(f=L(h([t,e,n,i]))/this.targetWorldWidth_>.25||f),!g&&this.sourceProj_.isGlobal()&&u&&(f=u>.25||f)),!f&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!D(c,this.maxSourceExtent_))return;let p=0;if(!(f||isFinite(r[0])&&isFinite(r[1])&&isFinite(o[0])&&isFinite(o[1])&&isFinite(s[0])&&isFinite(s[1])&&isFinite(a[0])&&isFinite(a[1])))if(l>0)f=!0;else if(p=(isFinite(r[0])&&isFinite(r[1])?0:8)+(isFinite(o[0])&&isFinite(o[1])?0:4)+(isFinite(s[0])&&isFinite(s[1])?0:2)+(isFinite(a[0])&&isFinite(a[1])?0:1),1!=p&&2!=p&&4!=p&&8!=p)return;if(l>0){if(!f){const e=[(t[0]+n[0])/2,(t[1]+n[1])/2],i=this.transformInv_(e);let o;o=g?(z(r[0],d)+z(s[0],d))/2-z(i[0],d):(r[0]+s[0])/2-i[0];const a=(r[1]+s[1])/2-i[1];f=o*o+a*a>this.errorThresholdSquared_}if(f){if(Math.abs(t[0]-n[0])<=Math.abs(t[1]-n[1])){const h=[(e[0]+n[0])/2,(e[1]+n[1])/2],c=this.transformInv_(h),u=[(i[0]+t[0])/2,(i[1]+t[1])/2],d=this.transformInv_(u);this.addQuad_(t,e,h,u,r,o,c,d,l-1),this.addQuad_(u,h,n,i,d,c,s,a,l-1)}else{const h=[(t[0]+e[0])/2,(t[1]+e[1])/2],c=this.transformInv_(h),u=[(n[0]+i[0])/2,(n[1]+i[1])/2],d=this.transformInv_(u);this.addQuad_(t,h,u,i,r,c,d,a,l-1),this.addQuad_(h,e,n,u,c,o,s,d,l-1)}return}}if(g){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}11&p||this.addTriangle_(t,n,i,r,s,a),14&p||this.addTriangle_(t,n,e,r,s,o),p&&(13&p||this.addTriangle_(e,i,t,o,a,r),7&p||this.addTriangle_(e,i,n,o,a,s))}calculateSourceExtent(){const t=[1/0,1/0,-1/0,-1/0];return this.triangles_.forEach(function(e,n,i){const r=e.source;C(t,r[0]),C(t,r[1]),C(t,r[2])}),t}getTriangles(){return this.triangles_}},Ch=class extends hh{constructor(t,e,n,i,r,o,s,a,l,h,c,u){super(r,0,u),this.renderEdges_=void 0!==c&&c,this.pixelRatio_=s,this.gutter_=a,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=i,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const d=i.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let f=this.sourceTileGrid_.getExtent();const p=g?k(d,g):d;if(0===T(p))return void(this.state=4);const _=t.getExtent();_&&(f=f?k(f,_):_);const m=i.getResolution(this.wrappedTileCoord_[0]),y=function(t,e,n,i){const r=M(n);let o=xh(t,e,r,i);return(!isFinite(o)||o<=0)&&b(n,function(n){return o=xh(t,e,n,i),isFinite(o)&&o>0}),o}(t,n,p,m);if(!isFinite(y)||y<=0)return void(this.state=4);const v=void 0!==h?h:.5;if(this.triangulation_=new Sh(t,n,p,f,y*v,m),0===this.triangulation_.getTriangles().length)return void(this.state=4);this.sourceZ_=e.getZForResolution(y);let x=this.triangulation_.calculateSourceExtent();if(f&&(t.canWrapX()?(x[1]=W(x[1],f[1],f[3]),x[3]=W(x[3],f[1],f[3])):x=k(x,f)),T(x)){let n=0,i=0;t.canWrapX()&&(n=L(_),i=Math.floor((x[0]-_[0])/n)),V(x.slice(),t,!0).forEach(t=>{const r=e.getTileRangeForExtentAndZ(t,this.sourceZ_);for(let t=r.minX;t<=r.maxX;t++)for(let e=r.minY;e<=r.maxY;e++){const r=i*n;this.sourceTiles_.push({getTile:()=>l(this.sourceZ_,t,e,s),offset:r})}++i}),0===this.sourceTiles_.length&&(this.state=4)}else this.state=4}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const n=e.tile;if(n&&2==n.getState()){const i=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);i[0]+=e.offset,i[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:i,clipExtent:r,image:n.getImage()})}}),this.sourceTiles_.length=0,0===t.length)this.state=3;else{const e=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(e),i="number"==typeof n?n:n[0],r="number"==typeof n?n:n[1],o=this.targetTileGrid_.getResolution(e),s=this.sourceTileGrid_.getResolution(this.sourceZ_),a=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=function(t,e,n,i,r,o,s,a,l,h,c,u,d,g){const f=it(Math.round(n*t),Math.round(n*e),mh);if(u||(f.imageSmoothingEnabled=!1),0===l.length)return f.canvas;function p(t){return Math.round(t*n)/n}f.scale(n,n),f.globalCompositeOperation="lighter";const _=[1/0,1/0,-1/0,-1/0];let m;l.forEach(function(t,e,n){S(_,t.extent)});const y=n/i,v=(u?1:1+Math.pow(2,-24))/y;if(!d||1!==l.length||0!==h){if(m=it(Math.round(L(_)*y),Math.round(F(_)*y),mh),u||(m.imageSmoothingEnabled=!1),r&&g){const t=(r[0]-_[0])*y,e=-(r[3]-_[3])*y,n=L(r)*y,i=F(r)*y;m.rect(t,e,n,i),m.clip()}l.forEach(function(t,e,n){if(t.image.width>0&&t.image.height>0){if(t.clipExtent){m.save();const e=(t.clipExtent[0]-_[0])*y,n=-(t.clipExtent[3]-_[3])*y,i=L(t.clipExtent)*y,r=F(t.clipExtent)*y;m.rect(u?e:Math.round(e),u?n:Math.round(n),u?i:Math.round(e+i)-Math.round(e),u?r:Math.round(n+r)-Math.round(n)),m.clip()}const e=(t.extent[0]-_[0])*y,n=-(t.extent[3]-_[3])*y,i=L(t.extent)*y,r=F(t.extent)*y;m.drawImage(t.image,h,h,t.image.width-2*h,t.image.height-2*h,u?e:Math.round(e),u?n:Math.round(n),u?i:Math.round(e+i)-Math.round(e),u?r:Math.round(n+r)-Math.round(n)),t.clipExtent&&m.restore()}})}const x=O(s);return a.getTriangles().forEach(function(t,e,n){const i=t.source,r=t.target;let s=i[0][0],a=i[0][1],h=i[1][0],c=i[1][1],d=i[2][0],g=i[2][1];const y=p((r[0][0]-x[0])/o),S=p(-(r[0][1]-x[1])/o),C=p((r[1][0]-x[0])/o),w=p(-(r[1][1]-x[1])/o),I=p((r[2][0]-x[0])/o),b=p(-(r[2][1]-x[1])/o),T=s,E=a;s=0,a=0,h-=T,c-=E,d-=T,g-=E;const P=function(t){const e=t.length;for(let n=0;n<e;n++){let i=n,r=Math.abs(t[n][n]);for(let o=n+1;o<e;o++){const e=Math.abs(t[o][n]);e>r&&(r=e,i=o)}if(0===r)return null;const o=t[i];t[i]=t[n],t[n]=o;for(let i=n+1;i<e;i++){const r=-t[i][n]/t[n][n];for(let o=n;o<e+1;o++)n==o?t[i][o]=0:t[i][o]+=r*t[n][o]}}const n=new Array(e);for(let i=e-1;i>=0;i--){n[i]=t[i][e]/t[i][i];for(let r=i-1;r>=0;r--)t[r][e]-=t[r][i]*n[i]}return n}([[h,c,0,0,C-y],[d,g,0,0,I-y],[0,0,h,c,w-S],[0,0,d,g,b-S]]);if(!P)return;if(f.save(),f.beginPath(),function(){if(void 0===_h){const t=it(6,6,mh);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",yh(t,4,5,4,0),yh(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;_h=vh(e,0)||vh(e,4)||vh(e,8),st(t),mh.push(t.canvas)}return _h}()||!u){f.moveTo(C,w);const t=4,e=y-C,n=S-w;for(let i=0;i<t;i++)f.lineTo(C+p((i+1)*e/t),w+p(i*n/(t-1))),i!=t-1&&f.lineTo(C+p((i+1)*e/t),w+p((i+1)*n/(t-1)));f.lineTo(I,b)}else f.moveTo(C,w),f.lineTo(y,S),f.lineTo(I,b);let M;if(f.clip(),f.transform(P[0],P[2],P[1],P[3],y,S),f.translate(_[0]-T,_[3]-E),m)M=m.canvas,f.scale(v,-v);else{const t=l[0],e=t.extent;M=t.image,f.scale(L(e)/M.width,-F(e)/M.height)}f.drawImage(M,0,0),f.restore()}),m&&(st(m),mh.push(m.canvas)),c&&(f.save(),f.globalCompositeOperation="source-over",f.strokeStyle="black",f.lineWidth=1,a.getTriangles().forEach(function(t,e,n){const i=t.target,r=(i[0][0]-x[0])/o,s=-(i[0][1]-x[1])/o,a=(i[1][0]-x[0])/o,l=-(i[1][1]-x[1])/o,h=(i[2][0]-x[0])/o,c=-(i[2][1]-x[1])/o;f.beginPath(),f.moveTo(a,l),f.lineTo(r,s),f.lineTo(h,c),f.closePath(),f.stroke()}),f.restore()),f.canvas}(i,r,this.pixelRatio_,s,this.sourceTileGrid_.getExtent(),o,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=2}this.changed()}load(){for(const t of this.sourceTiles_)t.tile=t.getTile();if(0==this.state){this.state=1,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const n=e.getState();if(0==n||1==n){t++;const n=qe(e,He,i=>{const r=e.getState();2!=r&&3!=r&&4!=r||(Ke(n),t--,0===t&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},e,n){0==t.getState()&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(Ke),this.sourcesListenerKeys_=null}release(){this.canvas_&&(st(this.canvas_.getContext("2d")),mh.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},wh=class{constructor(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof $e&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const n=this.entries_[t];return fi(void 0!==n,"Tried to get a value for a key that does not exist in the cache"),n===this.newest_||(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n),n.value_}remove(t){const e=this.entries_[t];return fi(void 0!==e,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.key_;return t}getValues(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){fi(!(t in this.entries_),"Tried to set a value for a key that is used already");const n={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[t]=n,++this.count_}setSize(t){this.highWaterMark=t}};function Ih(t,e,n,i){return void 0!==i?(i[0]=t,i[1]=e,i[2]=n,i):[t,e,n]}function bh(t,e,n,i,r){return`${Sn(t)},${e},${function(t,e,n){return t+"/"+e+"/"+n}(n,i,r)}`}function Th(t,e,n){if(!(n in t))return t[n]=new Set([e]),!0;const i=t[n],r=i.has(e);return r||i.add(e),!r}function Eh(t,e,n){const i=t[n];return!!i&&i.delete(e)}function Ph(t,e){const n=t.layerStatesArray[t.layerIndex];n.extent&&(e=k(e,ye(n.extent,t.viewState.projection)));const i=n.layer.getRenderSource();if(!i.getWrapX()){const n=i.getTileGridForProjection(t.viewState.projection).getExtent();n&&(e=k(e,n))}return e}const Mh=class extends xr{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=[1/0,1/0,-1/0,-1/0],this.tempTileRange_=new ph(0,0,0,0),this.tempTileCoord_=Ih(0,0,0);const n=void 0!==e.cacheSize?e.cacheSize:512;this.tileCache_=new wh(n),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=.5*n}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new wh(512)),this.sourceTileCache_}getOrCreateTile(t,e,n,i){const r=this.tileCache_,o=this.getLayer().getSource(),s=bh(o,o.getKey(),t,e,n);let a;if(r.containsKey(s))a=r.get(s);else{const l=i.viewState.projection,h=o.getProjection();if(a=o.getTile(t,e,n,i.pixelRatio,l,!h||ae(h,l)?void 0:this.getSourceTileCache()),!a)return null;r.set(s,a)}return a}getTile(t,e,n,i){return this.getOrCreateTile(t,e,n,i)||null}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),i=vi(e.pixelToCoordinateTransform,t.slice()),r=n.getExtent();if(r&&!d(r,i))return null;const o=e.viewState,s=n.getRenderSource(),a=s.getTileGridForProjection(o.projection),l=s.getTilePixelRatio(e.pixelRatio);for(let t=a.getZForResolution(o.resolution);t>=a.getMinZoom();--t){const n=a.getTileCoordForCoordAndZ(i,t),r=this.getTile(t,n[1],n[2],e);if(!r||2!==r.getState())continue;const h=a.getOrigin(t),c=Zi(a.getTileSize(t)),u=a.getResolution(t);let d;if(r instanceof fh||r instanceof Ch)d=r.getImage();else{if(!(r instanceof gh))continue;if(d=ch(r.getData()),!d)continue}const g=Math.floor(l*((i[0]-h[0])/u-n[1]*c[0])),f=Math.floor(l*((h[1]-i[1])/u-n[2]*c[1])),p=Math.round(l*s.getGutterForProjection(o.projection));return this.getImageData(d,g+p,f+p)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const n=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==n&&(this.renderedSourceRevision_=n,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=n,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,n,i,r){const o=t.viewState,s=this.getLayer(),a=s.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=Sn(a);h in t.wantedTiles||(t.wantedTiles[h]={});const c=t.wantedTiles[h],u=s.getMapInternal(),d=Math.max(n-r,l.getMinZoom(),l.getZForResolution(Math.min(s.getMaxResolution(),u?u.getView().getResolutionForZoom(Math.max(s.getMinZoom(),0)):l.getResolution(0)),a.zDirection)),g=o.rotation,f=g?R(o.center,o.resolution,g,t.size):void 0;for(let r=n;r>=d;--r){const n=l.getTileRangeForExtentAndZ(e,r,this.tempTileRange_),o=l.getResolution(r);for(let e=n.minX;e<=n.maxX;++e)for(let s=n.minY;s<=n.maxY;++s){if(g&&!l.tileCoordIntersectsViewport([r,e,s],f))continue;const n=this.getTile(r,e,s,t);if(!n)continue;if(!Th(i,n,r))continue;const a=n.getKey();if(c[a]=!0,0===n.getState()&&!t.tileQueue.isKeyQueued(a)){const i=Ih(r,e,s,this.tempTileCoord_);t.tileQueue.enqueue([n,h,l.getTileCoordCenter(i),o])}}}}findStaleTile_(t,e){const n=this.tileCache_,i=t[0],r=t[1],o=t[2],s=this.getStaleKeys();for(let t=0;t<s.length;++t){const a=bh(this.getLayer().getSource(),s[t],i,r,o);if(n.containsKey(a)){const t=n.peek(a);if(2===t.getState())return t.endTransition(Sn(this)),Th(e,t,i),!0}}return!1}findAltTiles_(t,e,n,i){const r=t.getTileRangeForTileCoordAndZ(e,n,this.tempTileRange_);if(!r)return!1;let o=!0;const s=this.tileCache_,a=this.getLayer().getRenderSource(),l=a.getKey();for(let t=r.minX;t<=r.maxX;++t)for(let e=r.minY;e<=r.maxY;++e){const r=bh(a,l,n,t,e);let h=!1;if(s.containsKey(r)){const t=s.peek(r);2===t.getState()&&(Th(i,t,n),h=!0)}h||(o=!1)}return o}renderFrame(t,e){this.renderComplete=!0;const n=t.layerStatesArray[t.layerIndex],r=t.viewState,o=r.projection,s=r.resolution,a=r.center,l=t.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(o),d=u.getZForResolution(s,c.zDirection),g=u.getResolution(d),f=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==f&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=f):this.renderedSourceKey_=f;let p=t.extent;const _=c.getTilePixelRatio(l);this.prepareContainer(t,e);const m=this.context.canvas.width,y=this.context.canvas.height;this.layerExtent=n.extent?ye(n.extent):null,this.layerExtent&&(p=k(p,this.layerExtent));const v=g*m/2/_,S=g*y/2/_,C=[a[0]-v,a[1]-S,a[0]+v,a[1]+S],w={};this.renderedTiles.length=0;const I=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){const e=u.getZForResolution(r.nextResolution,c.zDirection),n=Ph(t,t.nextExtent);this.enqueueTiles(t,n,e,w,I)}const b=Ph(t,p);if(this.enqueueTiles(t,b,d,w,0),I>0&&setTimeout(()=>{this.enqueueTiles(t,b,d-1,w,I-1)},0),!(d in w))return this.container;const T=Sn(this),E=t.time;for(const e of w[d]){const n=e.getState();if(4===n)continue;const i=e.tileCoord;if(2===n&&1===e.getAlpha(T,E)){e.endTransition(T);continue}if(3!==n&&(this.renderComplete=!1),this.findStaleTile_(i,w)){Eh(w,e,d),t.animate=!0;continue}if(this.findAltTiles_(u,i,d+1,w))continue;const r=u.getMinZoom();for(let t=d-1;t>=r&&!this.findAltTiles_(u,i,t,w);--t);}const P=g/s*l/_,M=this.getRenderContext(t);Si(this.tempTransform,m/2,y/2,P,P,0,-m/2,-y/2),this.layerExtent&&this.clipUnrotated(M,t,this.layerExtent),c.getInterpolate()||(M.imageSmoothingEnabled=!1),this.preRender(M,t);const R=Object.keys(w).map(Number);let F;R.sort(i);const A=[],L=[];for(let e=R.length-1;e>=0;--e){const n=R[e],i=c.getTilePixelSize(n,l,o),r=u.getResolution(n)/g,s=i[0]*r*P,a=i[1]*r*P,h=u.getTileCoordForCoordAndZ(O(C),n),d=u.getTileCoordExtent(h),f=vi(this.tempTransform,[_*(d[0]-C[0])/g,_*(C[3]-d[3])/g]),p=_*c.getGutterForProjection(o);for(const e of w[n]){if(2!==e.getState())continue;const i=e.tileCoord,r=h[1]-i[1],o=Math.round(f[0]-(r-1)*s),l=h[2]-i[2],u=Math.round(f[1]-(l-1)*a),d=Math.round(f[0]-r*s),g=Math.round(f[1]-l*a),_=o-d,m=u-g,y=1===R.length;let v=!1;F=[d,g,d+_,g,d+_,g+m,d,g+m];for(let t=0,e=A.length;t<e;++t)if(!y&&n<L[t]){const e=A[t];D([d,g,d+_,g+m],[e[0],e[3],e[4],e[7]])&&(v||(M.save(),v=!0),M.beginPath(),M.moveTo(F[0],F[1]),M.lineTo(F[2],F[3]),M.lineTo(F[4],F[5]),M.lineTo(F[6],F[7]),M.moveTo(e[6],e[7]),M.lineTo(e[4],e[5]),M.lineTo(e[2],e[3]),M.lineTo(e[0],e[1]),M.clip())}A.push(F),L.push(n),this.drawTile(e,t,d,g,_,m,p,y),v&&M.restore(),this.renderedTiles.unshift(e),this.updateUsedTiles(t.usedTiles,c,e)}}if(this.renderedResolution=g,this.extentChanged=!this.renderedExtent_||!x(this.renderedExtent_,C),this.renderedExtent_=C,this.renderedPixelRatio=l,this.postRender(this.context,t),this.layerExtent&&M.restore(),M.imageSmoothingEnabled=!0,this.renderComplete){const e=(t,e)=>{const n=Sn(c),i=e.wantedTiles[n],r=i?Object.keys(i).length:0;this.updateCacheSize(r),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(e)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,2*t)}drawTile(t,e,n,i,r,o,s,a){let l;if(t instanceof gh){if(l=ch(t.getData()),!l)throw new Error("Rendering array data is not yet supported")}else l=this.getTileImage(t);if(!l)return;const h=this.getRenderContext(e),c=Sn(this),u=e.layerStatesArray[e.layerIndex],d=u.opacity*(a?t.getAlpha(c,e.time):1),g=d!==h.globalAlpha;g&&(h.save(),h.globalAlpha=d),h.drawImage(l,s,s,l.width-2*s,l.height-2*s,n,i,r,o),g&&h.restore(),d!==u.opacity?e.animate=!0:a&&t.endTransition(c)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,n){const i=Sn(e);i in t||(t[i]={}),t[i][n.getKey()]=!0}},Rh={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},Fh={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]},kh=class extends Mh{constructor(t,e){super(t,e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=[1,0,0,1,0,0],this.tileClipContexts_=null}enqueueTilesForNextExtent(){return"vector"!==this.getLayer().getRenderMode()}drawTile(t,e,n,i,r,o,s,a){this.updateExecutorGroup_(t,e.pixelRatio,e.viewState.projection),this.tileImageNeedsRender_(t)&&this.renderTileImage_(t,e),super.drawTile(t,e,n,i,r,o,s,a)}getTile(t,e,n,i){const r=this.getOrCreateTile(t,e,n,i);if(!r)return null;const o=i.viewState,s=o.resolution,a=i.viewHints,l=this.getLayer().getSource(),h=l.getTileGridForProjection(o.projection),c=!(a[0]||a[1]),u=h.getZForResolution(s,l.zDirection)===t;return c&&u?r.wantedResolution=s:r.wantedResolution||(r.wantedResolution=h.getResolution(t)),r}prepareFrame(t){const e=this.getLayer().getRevision();return this.renderedLayerRevision_!==e&&(this.renderedLayerRevision_=e,this.renderedTiles.length=0),super.prepareFrame(t)}updateExecutorGroup_(t,e,n){const i=this.getLayer(),r=i.getRevision(),o=i.getRenderOrder()||null,s=t.wantedResolution,a=t.getReplayState(i);if(!a.dirty&&a.renderedResolution===s&&a.renderedRevision==r&&a.renderedPixelRatio===e&&a.renderedRenderOrder==o)return;const l=i.getSource(),h=!!i.getDeclutter(),u=l.getTileGrid(),d=l.getTileGridForProjection(n).getTileCoordExtent(t.wrappedTileCoord),g=l.getSourceTiles(e,n,t),f=Sn(i);delete t.hitDetectionImageData[f],t.executorGroups[f]=[],a.dirty=!1;for(let r=0,p=g.length;r<p;++r){const p=g[r];if(2!=p.getState())continue;const _=l.getProjection(),m=p.tileCoord;let y=u.getTileCoordExtent(m);n&&_&&!ae(n,_)&&(y=de(y,_,n,32));const v=k(d,y),S=c(v,i.getRenderBuffer()*s,this.tempExtent),C=x(y,v)?null:S,w=new ui(0,v,s,e),I=dr(s,e),b=function(t,e){let n;const r=t.getStyleFunction()||i.getStyleFunction();if(r&&(n=r(t,s)),n){const i=this.renderFeature(t,I,n,w,h,e);a.dirty=a.dirty||i}},T=p.getFeatures();o&&o!==a.renderedRenderOrder&&T.sort(o);for(let t=0,e=T.length;t<e;++t){let e=T[t];n&&p.projection&&!ae(n,p.projection)&&(e=e.clone(),e.getGeometry().applyTransform(ce(p.projection,n))),C&&!D(C,e.getGeometry().getExtent())||b.call(this,e,t)}const E=w.finish(),P="vector"!==i.getRenderMode()&&h&&1===g.length?null:v,M=new qi(P,s,e,l.getOverlaps(),E,i.getRenderBuffer(),!0);t.executorGroups[f].push(M)}a.renderedRevision=r,a.renderedPixelRatio=e,a.renderedRenderOrder=o,a.renderedResolution=s}forEachFeatureAtCoordinate(t,e,n,i,r){const o=e.viewState.resolution,s=e.viewState.rotation;n=null==n?0:n;const a=this.getLayer(),l=a.getSource().getTileGridForProjection(e.viewState.projection),u=a.getRenderBuffer(),d=h([t]);c(d,o*(u+n),d);const g={},f=function(t,e,n){let o=t.getId();void 0===o&&(o=Sn(t));const s=g[o];if(s){if(!0!==s&&n<s.distanceSq){if(0===n)return g[o]=!0,r.splice(r.lastIndexOf(s),1),i(t,a,e);s.geometry=e,s.distanceSq=n}}else{if(0===n)return g[o]=!0,i(t,a,e);r.push(g[o]={feature:t,layer:a,geometry:e,distanceSq:n,callback:i})}},p=this.renderedTiles,_=Sn(a),m=a.getDeclutter(),y=m?e.declutter?.[m]?.all().map(t=>t.value):null;let v;t:for(let e=p.length-1;e>=0;--e){const i=p[e];if(!D(l.getTileCoordExtent(i.wrappedTileCoord),d))continue;const r=i.executorGroups[_];for(let e=0,i=r.length;e<i;++e)if(v=r[e].forEachFeatureAtCoordinate(t,o,s,n,f,y),v)break t}return v}getFeatures(t){return 0===this.renderedTiles.length?Promise.resolve([]):new Promise((e,n)=>{const i=this.getLayer(),r=i.getSource(),o=this.renderedProjection,s=o.getExtent(),a=this.renderedResolution,l=r.getTileGridForProjection(o),h=vi(this.renderedPixelToCoordinateTransform_,t.slice()),c=l.getTileCoordForCoordAndResolution(h,a).toString(),u=this.renderedTiles.find(t=>t.tileCoord.toString()===c&&2===t.getState());if(!u||u.loadingSourceTiles>0)return void e([]);r.getWrapX()&&o.canWrapX()&&!g(s,l.getTileCoordExtent(u.tileCoord))&&Q(h,o);const d=Sn(i),f=O(l.getTileCoordExtent(u.wrappedTileCoord)),p=[(h[0]-f[0])/a,(f[1]-h[1])/a],_=u.getSourceTiles().reduce((t,e)=>t.concat(e.getFeatures()),[]);let m=u.hitDetectionImageData[d];if(!m){const t=Zi(l.getTileSize(l.getZForResolution(a,r.zDirection))),e=this.renderedRotation_;m=lr(t,[this.getRenderTransform(l.getTileCoordCenter(u.wrappedTileCoord),a,0,ar,t[0]*ar,t[1]*ar,0)],_,i.getStyleFunction(),l.getTileCoordExtent(u.wrappedTileCoord),u.getReplayState(i).renderedResolution,e),u.hitDetectionImageData[d]=m}e(hr(p,_,m))})}getFeaturesInExtent(t){const e=[],n=this.getTileCache();if(0===n.getCount())return e;const i=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),r=i.getZForResolution(this.renderedResolution),o={};return n.forEach(n=>{if(n.tileCoord[0]!==r||2!==n.getState())return;const s=n.getSourceTiles();for(let n=0,r=s.length;n<r;++n){const r=s[n],a=r.getKey();if(a in o)continue;o[a]=!0;const l=r.tileCoord;if(D(t,i.getTileCoordExtent(l))){const n=r.getFeatures();if(n)for(let i=0,r=n.length;i<r;++i){const r=n[i],o=r.getGeometry();D(t,o.getExtent())&&e.push(r)}}}}),e}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&void 0!==this.renderedLayerRevision_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}renderDeclutter(t,e){const n=this.context,i=n.globalAlpha;n.globalAlpha=e.opacity;const r=t.viewHints,o=!(r[0]||r[1]),s=[this.context.canvas.width,this.context.canvas.height],a=this.getLayer().getDeclutter(),l=a?t.declutter?.[a]:void 0,h=Sn(this.getLayer()),c=this.renderedTiles;for(let e=0,n=c.length;e<n;++e){const n=c[e],i=n.executorGroups[h];if(i)for(let e=i.length-1;e>=0;--e)i[e].execute(this.context,s,this.getTileRenderTransform(n,t),t.viewState.rotation,o,Ni,l)}n.globalAlpha=i}renderDeferredInternal(t){const e=this.renderedTiles,n=Sn(this.getLayer()),r=e.reduce((t,e,i)=>(e.executorGroups[n].forEach(e=>t.push({executorGroup:e,index:i})),t),[]),o=r.map(({executorGroup:t})=>t.getDeferredZIndexContexts()),s={};for(let t=0,e=r.length;t<e;++t){const e=r[t].executorGroup.getDeferredZIndexContexts();for(const t in e)s[t]=!0}const a=Object.keys(s).map(Number).sort(i);this.layerExtent&&this.clipUnrotated(this.context,t,this.layerExtent),a.forEach(t=>{o.forEach((e,n)=>{e[t]&&(e[t].forEach(t=>{const{executorGroup:e,index:i}=r[n],o=e.getRenderedContext(),s=o.globalAlpha;o.globalAlpha=this.renderedOpacity_;const a=this.tileClipContexts_[i];a&&a.draw(o),t.draw(o),a&&o.restore(),o.globalAlpha=s,t.clear()}),e[t].length=0)})}),this.layerExtent&&this.context.restore()}getTileRenderTransform(t,e){const n=e.pixelRatio,i=e.viewState,r=i.center,o=i.resolution,s=i.rotation,a=e.size,l=Math.round(a[0]*n),h=Math.round(a[1]*n),c=this.getLayer().getSource().getTileGridForProjection(e.viewState.projection),u=t.tileCoord,d=c.getTileCoordExtent(t.wrappedTileCoord),g=c.getTileCoordExtent(u,this.tempExtent)[0]-d[0];return mi(xi(this.inversePixelTransform.slice(),1/n,1/n),this.getRenderTransform(r,o,s,n,l,h,g))}postRender(t,e){const n=e.viewHints,i=!(n[0]||n[1]);this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice(),this.renderedRotation_=e.viewState.rotation,this.renderedOpacity_=e.layerStatesArray[e.layerIndex].opacity;const r=this.getLayer(),o=r.getRenderMode(),s=t.globalAlpha;t.globalAlpha=this.renderedOpacity_;const a=r.getDeclutter(),l=a?Fh[o].filter(t=>!Ni.includes(t)):Fh[o],h=e.viewState,c=h.rotation;this.layerExtent&&this.clipUnrotated(t,e,this.layerExtent);const u=r.getSource(),d=u.getTileGridForProjection(h.projection).getZForResolution(h.resolution,u.zDirection),g=this.renderedTiles,f=[],p=[],_=[],m=Sn(r);let y=!0;for(let n=g.length-1;n>=0;--n){const o=g[n];y=y&&!o.getReplayState(r).dirty;const s=o.executorGroups[m].filter(t=>t.hasExecutors(l));if(0===s.length)continue;const h=this.getTileRenderTransform(o,e),u=o.tileCoord[0];let v=!1;const x=s[0].getClipCoords(h);let S,C=t;if(x){S=new Mi,C=S.getContext();for(let t=0,e=f.length;t<e;++t)if(d!==u&&u<p[t]){const e=f[t];D([x[0],x[3],x[4],x[7]],[e[0],e[3],e[4],e[7]])&&(v||(C.save(),v=!0),C.beginPath(),C.moveTo(x[0],x[1]),C.lineTo(x[2],x[3]),C.lineTo(x[4],x[5]),C.lineTo(x[6],x[7]),C.moveTo(e[6],e[7]),C.lineTo(e[4],e[5]),C.lineTo(e[2],e[3]),C.lineTo(e[0],e[1]),C.clip())}f.push(x),p.push(u)}for(let n=0,r=s.length;n<r;++n)s[n].execute(t,[t.canvas.width,t.canvas.height],h,c,i,l,e.declutter?.[a]);v&&(C===t?C.restore():_[n]=S)}this.layerExtent&&t.restore(),t.globalAlpha=s,this.ready=y,this.tileClipContexts_=_,e.declutter||this.renderDeferredInternal(e),super.postRender(t,e)}renderFeature(t,e,n,i,r,o){if(!n)return!1;let s=!1;if(Array.isArray(n))for(let a=0,l=n.length;a<l;++a)s=fr(i,t,n[a],e,this.boundHandleStyleImageChange_,void 0,r,o)||s;else s=fr(i,t,n,e,this.boundHandleStyleImageChange_,void 0,r,o);return s}tileImageNeedsRender_(t){const e=this.getLayer();if("vector"===e.getRenderMode())return!1;const n=t.getReplayState(e),i=e.getRevision(),r=t.wantedResolution;return n.renderedTileResolution!==r||n.renderedTileRevision!==i}renderTileImage_(t,e){const n=this.getLayer(),i=t.getReplayState(n),r=n.getRevision(),o=t.executorGroups[Sn(n)];i.renderedTileRevision=r;const s=t.wrappedTileCoord,a=s[0],l=n.getSource();let h=e.pixelRatio;const c=e.viewState.projection,u=l.getTileGridForProjection(c),d=u.getResolution(t.tileCoord[0]),g=e.pixelRatio/t.wantedResolution*d,f=u.getResolution(a),p=t.getContext();h=Math.round(Math.max(h,g/h));const _=l.getTilePixelSize(a,h,c);p.canvas.width=_[0],p.canvas.height=_[1];const m=h/g;if(1!==m){const t=_i(this.tmpTransform_);xi(t,m,m),p.setTransform.apply(p,t)}const y=u.getTileCoordExtent(s,this.tempExtent),v=g/f,x=_i(this.tmpTransform_);xi(x,v,-v),function(t,e,n){mi(t,yi(pi,1,0,0,1,e,n))}(x,-y[0],-y[3]);for(let t=0,e=o.length;t<e;++t)o[t].execute(p,[p.canvas.width*m,p.canvas.height*m],x,0,!0,Rh[n.getRenderMode()],null);i.renderedTileResolution=t.wantedResolution}},Oh="preload",Ah="useInterimTilesOnError",Lh=class extends il{constructor(t){t=t||{};const e=Object.assign({},t);delete e.preload;const n=void 0===t.cacheSize?0:t.cacheSize;delete t.cacheSize,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=n;const i=t.renderMode||"hybrid";fi("hybrid"==i||"vector"==i,"`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=i,this.setPreload(t.preload?t.preload:0),this.setUseInterimTilesOnError(void 0===t.useInterimTilesOnError||t.useInterimTilesOnError),this.getBackground,this.setBackground}createRenderer(){return new kh(this,{cacheSize:this.cacheSize_})}getFeatures(t){return super.getFeatures(t)}getFeaturesInExtent(t){return this.getRenderer().getFeaturesInExtent(t)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(Oh)}getUseInterimTilesOnError(){return this.get(Ah)}setPreload(t){this.set(Oh,t)}setUseInterimTilesOnError(t){this.set(Ah,t)}};function Dh(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=jh(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 Gh(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)||jh(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 jh(t,e){if(t){if("string"==typeof t)return Vh(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)?Vh(t,e):void 0}}function Vh(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 Wh=function(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i},Xh=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 Yh(t,e)?e:t},Yh=function(t,e){return t?!!e&&("edge"===t.type&&"vertex"===e.type||("vertex"!==t.type||"edge"!==e.type)&&e.distSq<t.distSq):!!e},Bh=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=Wh(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],g=Xh(e,u,d),f=Wh(e,g);f<=n&&(r=Nh(r,{type:"edge",coord:g,distSq:f}))}return r},zh=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=Xh(r,c,u),g=Wh(r,d);g<=o&&(s=Nh(s,{type:"edge",coord:d,distSq:g,seg:[c,u]}))}return s},Uh=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]},qh=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=Wh(r,c);if(u<=o){var d=Gh(Uh(h,n,s),2),g=d[0],f=d[1],p=[a(g),a(f)];l=Nh(l,{type:"vertex",coord:c,distSq:u,adjacent:p})}}return l},Zh=function(t,e,n,i,r,o){var s=(n-e)/2,a=o?s:s-1;return{vertex:qh(t,e,s,a,i,r),edge:zh(t,e,s,a,i,r)}},Kh={point:function(t,e,n){var i=t.getCoordinates(),r=Wh(e,i);return r<=n?{type:"vertex",coord:[i[0],i[1]],distSq:r}:null},lineString:function(t,e,n){return Bh(t.getCoordinates(),e,n,!1)},linearRing:function(t,e,n){return Bh(t.getCoordinates(),e,n,!0)},polygon:function(t,e,n){var i,r=null,o=Dh(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s=i.value;r=Nh(r,Bh(s,e,n,!0))}}catch(t){o.e(t)}finally{o.f()}return r},multiLineString:function(t,e,n){var i,r=null,o=Dh(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s=i.value;r=Nh(r,Bh(s,e,n,!1))}}catch(t){o.e(t)}finally{o.f()}return r},multiPolygon:function(t,e,n){var i,r=null,o=Dh(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s,a=Dh(i.value);try{for(a.s();!(s=a.n()).done;){var l=s.value;r=Nh(r,Bh(l,e,n,!0))}}catch(t){a.e(t)}finally{a.f()}}}catch(t){o.e(t)}finally{o.f()}return r}},Hh=function(t,e,n){var i=t.getGeometry();if(!i)return null;var r=i.getType(),o=Kh[r[0].toLowerCase()+r.slice(1)];return o?o(i,e,n):null};function $h(t){return $h="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},$h(t)}function Jh(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 Qh(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Jh(Object(n),!0).forEach(function(e){tc(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Jh(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function tc(t,e,n){return(e=function(t){var e=function(t){if("object"!=$h(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=$h(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$h(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ec(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=ic(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 nc(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)||ic(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 ic(t,e){if(t){if("string"==typeof t)return rc(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)?rc(t,e):void 0}}function rc(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 oc=function(t,e,n){if(!e||!n)return!1;var i=nc(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},sc=function(){return!0===globalThis.DEBUG_SNAP_VISIBILITY},ac=function(t,e){sc()&&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)})},lc=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?ue(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=nc(e.seg,2),o=r[0],s=r[1];return oc(i,i.toSource(o),i.toSource(s))}var a=nc(null!==(n=e.adjacent)&&void 0!==n?n:[],2),l=a[0],h=a[1];return oc(i,i.anchor,i.toSource(l))||oc(i,i.anchor,i.toSource(h))}(r,e)?(sc()&&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)||(sc()&&console.log("[snap-filtered] invisible fill boundary"),0))};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 cc=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 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}}(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()}},uc=function(t){return{vertex:new Is({renderer:cc(t.snapVertex)}),edge:new Is({renderer:cc(t.snapEdge)})}};const dc="active",gc=class extends wn{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(dc)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(dc,t)}setMap(t){this.map_=t}};var fc=new Set(["pointermove","pointerdrag","pointerdown","pointerup","singleclick","click"]),pc=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=ec(null!=t?t:[]);try{for(r.s();!(e=r.n()).done;){var o=e.value;"string"==typeof o?n.add(o):o instanceof rl&&i.push(o)}}catch(t){r.e(t)}finally{r.f()}};return r(e),{query:function(e,r){sc()&&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 g,f=ec(d.getFeaturesInExtent(l));try{for(f.s();!(g=f.n()).done;){var p=g.value;h=Nh(h,Hh(p,e,a))}}catch(t){f.e(t)}finally{f.f()}}}if(n.size>0){var _=function(t){var e=[];return t.getLayers().forEach(function(t){t instanceof Lh&&e.push(t)}),e}(t),m=_.length>0?t.getPixelFromCoordinate(e):null;if(m){var y=new Map;t.forEachFeatureAtPixel(m,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=Wh(e,r);a<=n&&(o={type:"vertex",coord:[r[0],r[1]],distSq:a})}else if("LineString"===i){var l=Zh(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=Dh(t.getEnds());try{for(d.s();!(h=d.n()).done;){var g=h.value,f=Zh(r,c,g,e,n,u);o=Nh(o,f.vertex),s=Nh(s,f.edge),c=g}}catch(t){d.e(t)}finally{d.f()}}return[o,s].filter(Boolean)}(i,e,a);if(l.length){y.has(r)||y.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=y.get(r);h=function(t,e,n){var i,r=t,o=ec(e);try{for(o.s();!(i=o.n()).done;){var s=i.value;ac(s,n.mapboxLayer),lc(Qh({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:_,resolution:o})}}},{hitTolerance:r,layerFilter:function(t){return _.includes(t)}})}}return h?{type:h.type,coord:h.coord}:null},setLayers:r}}(t,e),o=function(t,e){var n=uc(e),i=new Il,r=new rl({source:i,style:function(t){var e;return null!==(e=n[t.get("snapType")])&&void 0!==e?e:null},zIndex:200,updateWhileAnimating:!0,updateWhileInteracting:!0});t.addLayer(r);var o=new Tl,s=!1;return{show:function(t,e){o.setGeometry(new ma(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=uc(t),s&&i.changed()},remove:function(){i.clear(),t.removeLayer(r)}}}(t,n),s=!1,a=function(t,e,n,i){var r=new gc({handleEvent:function(o){return r.getActive()&&function(t,e,n,i,r){var o=t.type;if("pointerout"!==o&&"pointerleave"!==o){if(fc.has(o)){var s=e.query(t.coordinate,i);s&&(t.coordinate=s.coord.slice()),"pointermove"===o&&r()?s?n.show(s.coord,s.type):n.hide():"pointerdrag"===o&&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 _c=class extends nn{constructor(t,e,n){super(t),this.map=e,this.frameState=void 0!==n?n:null}},mc=class extends _c{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()}},yc="singleclick",vc="pointerdrag",xc="pointermove",Sc="pointerdown",Cc=Je,wc=Qe,Ic=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},bc=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Tc=function(t){const e=t.originalEvent;return"pointerId"in e&&e.isPrimary&&0===e.button};class Ec extends or{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 Ec(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 _(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(D(t,this.getExtent())){const e=this.getCenter();return t[0]<=e[0]&&t[2]>=e[0]||t[1]<=e[1]&&t[3]>=e[1]||b(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=ca(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(gi(n,0,n.length,i,t,e,n)),this.changed()}}Ec.prototype.transform;const Pc=Ec,Mc=class extends gc{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==vc)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==Sc){const n=this.handleDownEvent(t);this.handlingDownUpSequence=n,e=this.stopDown(n)}else t.type==xc&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function Rc(t,e){const n=t.length;return e<0?t[e+n]:e>=n?t[e-n]:t[e]}function Fc(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 kc={index:-1,endIndex:NaN,closestTargetDistance:1/0};function Oc(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=Wc(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=Fc(h.coordinates,l);J(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=jc(t,n,i);jc(t,n,i-e)<r&&(l-=e)}else{const r=jc(t,n,i);jc(t,n,i+e)<r&&(l+=e)}}return kc.index=a,kc.endIndex=l,kc.closestTargetDistance=s,kc}function Ac(t,e){const n=[];for(let i=0;i<e.length;++i)Lc(t,e[i].getGeometry(),n);return n}function Lc(t,e,n){if(e instanceof Fl)Dc(t,e.getCoordinates(),!1,n);else{if(e instanceof Ol){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Dc(t,i[e],!1,n);return}if(e instanceof Oa){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Dc(t,i[e],!0,n);return}if(e instanceof Gl){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)Dc(t,r[e],!0,n)}return}if(e instanceof Ml){const i=e.getGeometries();for(let e=0;e<i.length;++e)Lc(t,i[e],n);return}}}function Dc(t,e,n,i){const r=t[0],o=t[1];for(let t=0,s=e.length-1;t<s;++t){const s=Wc(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 Gc(t,e){return N(t[0],t[1],e[0],e[1])}function jc(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 Gc(Fc(t,i),Fc(t,r));let a=0;i<o&&(a+=Gc(Fc(t,i),Rc(t,o))),s<r&&(a+=Gc(Rc(t,s),Fc(t,r)));for(let e=o;e<s-1;++e)a+=Gc(Rc(t,e),Rc(t,e+1));return a}const Vc={along:0,squaredDistance:0};function Wc(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=W(((t-r)*s+(e-o)*a)/(s*s+a*a),0,1),h+=s*l,c+=a*l),Vc.along=l,Vc.squaredDistance=q(N(t,e,h,c),10),Vc}const Xc="drawstart";class Nc extends nn{constructor(t,e){super(t),this.feature=e}}function Yc(){const t=Cs();return function(e,n){return t[e.getGeometry().getType()]}}const Bc=class extends Mc{constructor(t){const e=t;e.stopDown||(e.stopDown=Qe),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:Je,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 Pc([NaN,NaN]),r=_e(t[0]),o=$(r,_e(t[t.length-1]));i.setCenterAndRadius(r,Math.sqrt(o),this.geometryLayout_);const s=fe();return s&&i.transform(n,s),i};else{let e;"Point"===t?e=ma:"LineString"===t?e=Fl:"Polygon"===t&&(e=Oa),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 rl({source:new Il({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:Yc(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:Ic,this.freehandCondition_,t.freehand?this.freehandCondition_=Cc:this.freehandCondition_=t.freehandCondition?t.freehandCondition:bc,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(dc,this.updateState_)}setTrace(t){let e;e=t?!0===t?Cc:t:wc,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=Cc:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:bc}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===xc,n=!0;return!this.freehand_&&this.lastDragTime_&&t.type===vc&&(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===vc&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),n=!1):this.freehand_&&t.type===Sc?n=!1:e&&this.getPointerCount()<2?(n=t.type===xc,n&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===vc&&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 mc(xc,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=Ac(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(Rc(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(Rc(t.coordinates,e))}i.length&&this.appendCoordinates(i)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&J(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.snapTolerance_)return;const n=Oc(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=Fc(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 Tl(new ma(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new Tl);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=rr(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 Tl(new Fl(this.sketchLineCoords_)));const i=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new Tl,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(i),this.updateSketchFeatures_(),this.dispatchEvent(new Nc(Xc,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),n=this.sketchFeature_.getGeometry(),i=e.getView().getProjection(),r=rr(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 Ll([e])):"MultiLineString"===this.type_?t.setGeometry(new Ol([e])):"MultiPolygon"===this.type_&&t.setGeometry(new Gl([e])),this.dispatchEvent(new Nc("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 Nc("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 Tl(new ma(n)),this.updateSketchFeatures_(),this.dispatchEvent(new Nc(Xc,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 zc=function(t,e){var n=t.getPixelFromCoordinate(e);return n?{x:n[0],y:n[1]}:null},Uc=function(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))},qc=function(t,e,n,i){var r=t.getPixelFromCoordinate(e);return r?t.getCoordinateFromPixel([r[0]+n,r[1]+i]):e};function Zc(t){return function(t){if(Array.isArray(t))return Kc(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 Kc(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)?Kc(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 Kc(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 Hc=function(t){var e=t.drawInteraction,n=t.mapProvider,i=t.snap,r=t.canFinish,o=t.canPlace,s=t.getInterfaceType,a=null,l=null,h=function(){a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,l=null};e.on("drawstart",function(t){return h(t.feature)}),e.on("drawend",function(){return h()}),e.on("drawabort",function(){return h()});var c=function(){var t=n.getCenter();return"mouse"!==s()&&i?i.apply(t):t};return{placeVertex:function(){var t=c();if(null==i||i.hideIndicator(),a){var n=a.getGeometry(),s=n.getCoordinates(),h="Polygon"===n.getType()?s[0]||[]:s,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=zc(t,e),o=zc(t,n[0]);return!(!r||!o)&&Uc(r,o)<12}(a,o,r,i.getType()))return e.finishDrawing(),{handled:!0,lastPlacedCoord:s};var l=th(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:h,coord:t,lastPlacedCoord:l});if(l=u.lastPlacedCoord,u.handled)return}o&&!o(t)||(e.appendCoordinates([t]),l=t)},updateRubberbanding:function(){if(a){var t=a.getGeometry();t.getCoordinates().length&&function(t,e){if("LineString"===t.getType()){var n=Zc(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=Zc(t);return i[i.length-1]=e,i});t.setCoordinates(i)}}(t,c())}else"mouse"!==s()&&i&&i.apply(n.getCenter())},clearLastCoord:function(){l=null}}},$c=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),Jc=n(360),Qc="styleschanged",tu=n(520),eu=n(9),nu=n(788),iu=n(715),ru=function(t,e){return!!e&&Ql(e.getGeometry()).length>=eu.n8[t]},ou=function(t,e,n,i){return function(r){if(!Ic(r))return!1;var o=n();if(!i(r.coordinate))return!1;if(!o||ru(e,o))return!0;var s=th(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}},su={Polygon:2,LineString:1},au=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(Jc.k.GEOMETRY_CHANGE,{feature:(r=t.store,o=c,s=r.toGeoJSON(o),a=s.geometry.type,l=su[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=Ql(r.getGeometry()).length;t.emit(Jc.k.VERTEX_CHANGE,{numVertices:o}),o>n&&i("commit-add",o-1),n=o}},emitUndoValidation:function(){var t=e();t&&i("commit-delete",Ql(t.getGeometry()).length)}}}(n,function(){return l}),d=u.updateVertexCount,g=u.resetCount,f=u.emitUndoValidation,p=function(t){var e=t.manager,n=t.geometryType,i=t.getSketch;return function(t){var r=i(),o=(0,tu.$b)({placed:r?Ql(r.getGeometry()):[],point:t,geometryType:n,onGeometryChange:e._geometryValidator});return o.valid||e.emit(Jc.k.PLACEMENT_BLOCKED,o.blocked),o.valid}}({manager:n,geometryType:r,getSketch:function(){return l}}),_=new Bc({type:r,style:function(t){return c(t)},stopClick:!0,snapTolerance:$l.vf.snapRadius,condition:ou(e,r,function(){return l},p),finishCondition:function(){return!1!==n._geometryValid}});e.addInteraction(_);var m=(0,nu.De)({onChange:function(t){h=t,c=n.styles.createSketchStyle(r,h),_.overlay_.changed()}}),y=(0,iu.O)({onStrokeChange:function(t,e){return m.set(t,e)},onPlaceChange:function(t,e){return n.emit(Jc.k.CAN_PLACE_CHANGE,{canPlace:!t,reason:e})}}),v=tu.dV[r],x=function(){c=n.styles.createSketchStyle(r,h),_.overlay_.changed()};n.on(Qc,x),_.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(Jc.k.CREATE,t.store.toGeoJSON(e))}(n,t.feature,i,r)}),t.on("drawabort",function(){n.emit(Jc.k.CANCEL)})}(_,{manager:n,featureId:o,properties:a,onStart:function(t){l=t,g()},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:Ql(i).length}}(r,l),e=t.feature,i=t.numVertices;y.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=null!==(e=i.interfaceType)&&void 0!==e?e:"mouse",d=function(){return u},g=Hc({drawInteraction:n,mapProvider:s,snap:a,canFinish:h,canPlace:c,getInterfaceType:d}),f=n.getMap(),p=null==f?void 0:f.getView(),_=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()&&l()};null==i||i.on("change:center",c);var u=function(t){e.contains(document.activeElement)&&($c.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()},g=function(t){"touch"!==t.pointerType&&(s("mouse"),a())},f=function(){s("touch")},p=function(){"mouse"!==o()&&l()};return globalThis.addEventListener("keydown",u),globalThis.addEventListener("click",d),e.addEventListener("pointerdown",g),e.addEventListener("touchstart",f,{passive:!0}),e.addEventListener("pointermove",p),{destroy:function(){null==i||i.un("change:center",c),globalThis.removeEventListener("keydown",u),globalThis.removeEventListener("click",d),e.removeEventListener("pointerdown",g),e.removeEventListener("touchstart",f),e.removeEventListener("pointermove",p)}}}({container:r,addVertexButtonId:o,olView:p,onUndo:l,getInterfaceType:d,setInterfaceType:function(t){u=t},clearLastCoord:g.clearLastCoord,updateRubberbanding:g.updateRubberbanding,placeVertex:g.placeVertex}),m=function(){"mouse"!==u&&null!=p&&p.getAnimating()&&g.updateRubberbanding()};return null==f||f.on("postrender",m),{getInterfaceType:d,setInterfaceType:function(t){u=t,"mouse"!==t&&g.updateRubberbanding()},destroy:function(){_.destroy(),null==f||f.un("postrender",m)}}}({drawInteraction:e,options:{container:n.container,interfaceType:n.interfaceType,addVertexButtonId:n.addVertexButtonId,mapProvider:n.mapProvider,snap:n.snap,onUndo:function(){e.removeLastPoint(),o(),s()},canFinish:function(){return ru(i,r())},canPlace:a}})}({drawInteraction:_,options:i,geometryType:r,getSketch:function(){return l},updateVertexCount:d,emitUndoValidation:f,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(){ru(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(Qc,h),n.emit(Jc.k.INTERFACE_TYPE_CHANGE,{interfaceType:r.getInterfaceType()}),r.destroy(),e.removeInteraction(i),c()}}}({map:e,manager:n,drawInteraction:_,input:S,geometryType:r,getSketch:function(){return l},updateVertexCount:d,emitUndoValidation:f,onStylesChanged:x,clearSketch:function(){l=null},setInvalid:function(t){return m.set(t)},liveStroke:m,liveDrawChecks:y})};function lu(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)||cu(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 hu(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=cu(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 cu(t,e){if(t){if("string"==typeof t)return uu(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)?uu(t,e):void 0}}function uu(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){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[]}},gu=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},fu=function(t,e){var n,i=hu(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},pu=function(t,e){var n,i=t.coordinates,r=hu(e);try{for(r.s();!(n=r.n()).done;)i=i[n.value]}catch(t){r.e(t)}finally{r.f()}return i},_u=function(t){var e=du(t),n=gu(t);if(!e.length||!n.length)return[];var i,r=[],o=hu(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=lu(e[h],2),d=u[0],g=u[1],f=lu(e[c],2),p=f[0],_=f[1];r.push([(d+p)/2,(g+_)/2])}}catch(t){o.e(t)}finally{o.f()}return r},mu=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()}},g=function(){var t=d();c.vertices=du(t),c.midpoints=_u(t),l.update(t),a.update(t),h.update(c)},f=function(t,e,n){return function(i,r){i&&setTimeout(function(){t.emit(Jc.k.GEOMETRY_CHANGE,{feature:e.toGeoJSON(n),phase:i,vertexIndex:r})},0)}}(n,i,r),p=function(){return g()};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(Jc.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(){g(),n.emit(Jc.k.VERTEX_CHANGE,{numVertices:c.vertices.length}),n.emit(Jc.k.UPDATE,i.toGeoJSON(r))},emitGeometryValidation:f,updateLayersFromGeom:g,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 yu=[0,0,0,0],vu=[],xu="modifyend";function Su(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 Cu extends nn{constructor(t,e,n){super(t),this.features=e,this.mapBrowserEvent=n}}function wu(t,e){return t.index-e.index}function Iu(t,e,n){const i=e.geometry;if("Circle"===i.getType()){let r=i;if(1===e.index){const e=fe();e&&(r=r.clone().transform(e,n));const i=$(r.getCenter(),_e(t)),o=Math.sqrt(i)-r.getRadius();return o*o}}const r=_e(t);return vu[0]=_e(e.segment[0]),vu[1]=_e(e.segment[1]),function(t,e){return $(t,K(t,e))}(r,vu)}function bu(t,e,n){const i=e.geometry;if("Circle"===i.getType()&&1===e.index){let e=i;const r=fe();return r&&(e=e.clone().transform(r,n)),pe(e.getClosestPoint(_e(t)))}const r=_e(t);return vu[0]=_e(e.segment[0]),vu[1]=_e(e.segment[1]),pe(K(r,vu))}function Tu(){const t=Cs();return function(e,n){return t.Point}}const Eu=class extends Mc{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:Tc,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==yc}(t)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:Cc,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new yl,this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new rl({source:new Il({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:Tu(),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:H,!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(ol,this.handleExternalCollectionAdd_),t.features.addEventListener(sl,this.handleExternalCollectionRemove_),this.featuresCollection_=t.features):t.source&&(e=t.source.getFeatures(),t.source.addEventListener(Sl,this.handleSourceAdd_),t.source.addEventListener(Cl,this.handleSourceRemove_),this.source_=t.source),e.forEach(t=>{t.addEventListener(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(_n,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?Cc:t:wc,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 hl;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 Cu("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(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(_n,this.handleFeatureChange_),this.filter_(t)&&this.addFeature_(t)}externalRemoveFeatureHandler_(t){t.removeEventListener(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(_n,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(y(n),i);let s=e;const a=fe();if(a&&this.getMap()){const t=this.getMap().getView().getProjection();s=s.clone().transform(a,t),s=La(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 Tl(new ma(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!=xc||this.handlingDownUpSequence||this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(e=!(t.type!=yc||!this.ignoreNextSingleClick_)||this.removePoint()),t.type==yc&&(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(wu);for(let r=0,a=o.length;r<a;++r){const a=o[r],l=a.segment;let h=Sn(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=bu(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])!(Sn(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&&J(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.pixelTolerance_)return;const n=Oc(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();Su(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=Ac(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();Su(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(Rc(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(Rc(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();Su(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=J(_e(e.getCenter()),_e(t));const r=fe();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_)J(K(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(y(r),o);let a=e;const l=fe();if(l){const e=t.map.getView().getProjection();a=a.clone().transform(l,e),a=La(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 Cu(xu,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 Iu(t,e,i)-Iu(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 ma(pe(n.getCoordinates())));const i=n||t.getGeometry();if(i&&"Point"===i.getType()&&t instanceof Tl&&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=me(c(ye(y(t,yu)),e.getView().getResolution()*this.pixelTolerance_,yu));o=this.rBush_.getInExtent(n)}if(o&&o.length>0){const a=o.sort(r)[0],l=a.segment;let h=bu(t,a,i);const c=e.getPixelFromCoordinate(h);let u=J(n,c);if(s||u<=this.pixelTolerance_){const n={};if(n[Sn(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=$(c,t),s=$(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[Sn(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=Sn(o[t].geometry);i in d||(d[i]=!0,n[Sn(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?pe(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=_e(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=vc){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([t])=>t));const e=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Cu(xu,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,g,f=!1;for(s=t.length-1;s>=0;--s)r=t[s],d=r[0],g=Sn(d.feature),d.depth&&(g+="-"+d.depth.join("-")),g in e||(e[g]={}),0===r[1]?(e[g].right=d,e[g].index=d.index):1==r[1]&&(e[g].left=d,e[g].index=d.index+1);for(g in e){switch(u=e[g].right,l=e[g].left,a=e[g].index,c=a-1,d=void 0!==l?l:u,c<0&&(c=0),o=d.geometry,i=o.getCoordinates(),n=i,f=!1,o.getType()){case"MultiLineString":i[d.depth[0]].length>2&&(i[d.depth[0]].splice(a,1),f=!0);break;case"LineString":i.length>2&&(i.splice(a,1),f=!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),f=!0,0===a&&(n.pop(),n.push(n[0]),c=n.length-1))}if(f){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 f}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?_e(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(ol,this.handleExternalCollectionAdd_),this.featuresCollection_.removeEventListener(sl,this.handleExternalCollectionRemove_);for(const t of this.featuresCollection_.getArray())t.removeEventListener(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(_n,this.handleFeatureChange_)}else if(this.source_){this.source_.removeEventListener(Sl,this.handleSourceAdd_),this.source_.removeEventListener(Cl,this.handleSourceRemove_);for(const t of this.source_.getFeatures())t.removeEventListener(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(_n,this.handleFeatureChange_)}}};var Pu=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=zc(t,e);if(s){var a=Uc(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=zc(t,e);if(s){var a=Uc(s,n);a<o&&(o=a,r=i)}}),r>=0?{index:i+r,type:"midpoint"}:null}(t,n,i,e.length,o)};function Mu(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 Ru=function(t){var e=t.map,n=t.olFeature,i=t.getState,r=t.onModifyEnd,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!==Pu(e,o,s,{x:a[0],y:a[1]})}}({map:e,getState:i}),s=new Eu({features:new hl([n]),style:function(){return[]},pixelTolerance:12,condition:o});e.addInteraction(s);var a=null;return s.on("modifystart",function(){"touch"!==i().interfaceType&&(a=i().vertices.map(function(t){return function(t){if(Array.isArray(t))return Mu(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 Mu(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)?Mu(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}))}),s.on("modifyend",function(){if("touch"!==i().interfaceType){var t=a;a=null,r(t)}}),{destroy:function(){e.removeInteraction(s)}}},Fu=n(722);function ku(t){return function(t){if(Array.isArray(t))return Au(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Ou(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 Ou(t,e){if(t){if("string"==typeof t)return Au(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)?Au(t,e):void 0}}function Au(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 Lu=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=Ou(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}}}}(gu(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 g=r-h+1,f=u.start+g;return pu(l,u.path).splice(g,0,ku(o)),a.setCoordinates(l.coordinates),{insertedIndex:f}}h+=d}}catch(t){c.e(t)}finally{c.f()}return null},Du=function(t,e,n){var i=t.getGeometry(),r={type:i.getType(),coordinates:i.getCoordinates()},o=gu(r),s=fu(o,e);if(s){var a=pu(r,s.segment.path);a[s.localIdx]=ku(n),s.segment.closed&&0===s.localIdx&&(a[a.length-1]=ku(n)),i.setCoordinates(r.coordinates)}};function Gu(t){return Gu="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},Gu(t)}function ju(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 Vu(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ju(Object(n),!0).forEach(function(e){Wu(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ju(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Wu(t,e,n){return(e=function(t){var e=function(t){if("object"!=Gu(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Gu(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Gu(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Xu(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 Nu=function(t){var e=t.container,n={dragStartCoord:null,dragStartIndex:null,vertexTouchDelta:null,targetTouchDelta:null,tapStart:null},i=Vu(Vu({},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,Fu.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 g=i.getEventPixel({clientX:l.clientX,clientY:l.clientY}),f=zc(i,d),p=getComputedStyle(r),_=o({x:Number.parseFloat(p.left),y:Number.parseFloat(p.top)});a.dragStartCoord=function(t){if(Array.isArray(t))return Xu(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 Xu(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)?Xu(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:g[0]-f.x,y:g[1]-f.y},a.targetTouchDelta={x:g[0]-_.x,y:g[1]-_.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;if((0,Fu.mt)(t.target)&&null!=l.dragStartIndex){t.preventDefault();var h=n.getEventPixel({clientX:t.touches[0].clientX,clientY:t.touches[0].clientY}),c=function(t,e){return t.getCoordinateFromPixel([e.x,e.y])}(n,{x:h[0]-l.vertexTouchDelta.x,y:h[1]-l.vertexTouchDelta.y}),u=a?a.apply(c):c;null==a||a.hideIndicator();var d=o(),g=d.olFeature,f=d.vertices;g&&(Du(g,l.dragStartIndex,u),s({vertices:f.map(function(t,e){return e===l.dragStartIndex?u:t})}),(0,Fu.Ox)(i,r({x:h[0]-l.targetTouchDelta.x,y:h[1]-l.targetTouchDelta.y})))}}(t,i)},s=function(t){return function(t,e){var n=e.getState,i=e.onVertexMoved,r=e.snap,o=e.drag;if(null==o.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(Pu(n,h.vertices,h.midpoints,{x:l[0],y:l[1]},24)),t.preventDefault()}}}(t,e),void(o.tapStart=null);o.tapStart=null,n().vertices[o.dragStartIndex]&&o.dragStartCoord&&i({vertexIndex:o.dragStartIndex,previousCoord:o.dragStartCoord}),null==r||r.hideIndicator(),o.dragStartCoord=null,o.dragStartIndex=null,o.vertexTouchDelta=null,o.targetTouchDelta=null,t.preventDefault()}(t,i)};return e.addEventListener("touchstart",r,{passive:!1}),e.addEventListener("touchmove",o,{passive:!1}),e.addEventListener("touchend",s,{passive:!1}),{isDragging:function(){return null!=n.dragStartIndex},destroy:function(){e.removeEventListener("touchstart",r),e.removeEventListener("touchmove",o),e.removeEventListener("touchend",s)}}},Yu=n(704);function Bu(t){return function(t){if(Array.isArray(t))return Uu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||zu(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 zu(t,e){if(t){if("string"==typeof t)return Uu(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)?Uu(t,e):void 0}}function Uu(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 qu=function(t){var e=t.map,n=t.snap,i=t.getState,r=t.setState,o=t.onInserted,s=t.onVertexMoved,a={start:null,index:null},l=function(t,o){var s=i(),a=s.selectedVertexIndex,l=s.vertices,h=s.olFeature;if(!h||a<0||!l[a])return null;var c=l[a],u=qc(e,c,t,o),d=n?n.apply(u):u;null==n||n.hideIndicator();var 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 qc(e,n,0===o?0:Math.sign(o)*c,0===s?0:Math.sign(s)*c)}return r}(n,e,c,u,d,t,o);return Du(h,a,g),r({vertices:l.map(function(t,e){return e===a?g:t})}),{previousCoord:c,vertexIndex:a}};return{nudge:function(t){var s=i(),h=s.selectedVertexIndex,c=s.selectedVertexType,u=s.vertices,d=s.midpoints,g=s.olFeature;if(g){var f=t.shiftKey?$l.WQ.nudgeAmount:$l.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)||zu(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,-f],ArrowDown:[0,f],ArrowLeft:[-f,0],ArrowRight:[f,0]}[t.key],2),_=p[0],m=p[1];"midpoint"!==c?h<0||!u[h]||(a.start||(a.start=Bu(u[h]),a.index=h),l(_,m)):function(t,s,l,h,c,u){var d=Lu(t,s,l,h.length);if(d){o({insertedIndex:d.insertedIndex});var g=i().vertices,f=g[d.insertedIndex];if(f){a.start=Bu(f),a.index=d.insertedIndex;var p=qc(e,f,c,u),_=n?n.apply(p):p;Du(t,d.insertedIndex,_),r({selectedVertexIndex:d.insertedIndex,selectedVertexType:"vertex",vertices:g.map(function(t,e){return e===d.insertedIndex?_:t})})}}}(g,d,h,u,_,m)}},keyMove:a,nudgeByDelta:function(t,e,n){var i=n?$l.WQ.stepAmount:$l.WQ.nudgeAmount,r=l(t*i,e*i);r&&s({vertexIndex:r.vertexIndex,previousCoord:r.previousCoord})}}};function Zu(t){return function(t){if(Array.isArray(t))return Ku(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 Ku(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)?Ku(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 Ku(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 Hu=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),$u=new Set(["INPUT","TEXTAREA","BUTTON","SELECT","A"]),Ju=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=zc(t,t.getView().getCenter());if(s){var a=[].concat(Zu(r.map(function(e){return zc(t,e)})),Zu(o.map(function(e){return zc(t,e)}))).filter(Boolean).map(function(t){return[t.x,t.y]}),l=(0,Yu.cj)([s.x,s.y],a,void 0);n({selectedVertexIndex:l,selectedVertexType:l<r.length?"vertex":"midpoint"})}}}(e,n,i);else if(Hu.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(Zu(s),Zu(a)).map(function(t){return zc(e,t)}).filter(Boolean).map(function(t){return[t.x,t.y]}),c=o>=0?h[o]:(l=zc(e,e.getView().getCenter()))?[l.x,l.y]:null;if(c){var u=(0,Yu.cj)(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;$u.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))}};function Qu(t){return function(t){if(Array.isArray(t))return ed(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||td(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 td(t,e){if(t){if("string"==typeof t)return ed(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)?ed(t,e):void 0}}function ed(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 nd=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=gu(o),a=fu(s,n);if(!a)return-1;var l=pu(o,a.segment.path);return l[a.localIdx]=Qu(i),a.segment.closed&&0===a.localIdx&&(l[l.length-1]=Qu(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=gu(r),s=fu(o,n);if(s){var a=pu(r,s.segment.path);a.splice(s.localIdx,1),s.segment.closed&&(a[a.length-1]=Qu(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=gu(o),a=fu(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=td(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=pu(o,a.segment.path);return u.splice(a.localIdx,0,Qu(i)),a.segment.closed&&(u[u.length-1]=Qu(u[0])),r.setCoordinates(o.coordinates),n}(t,e);default:return-1}},id="touch",rd="vertex",od="commit-move",sd="commit-insert",ad="commit-delete",ld={move_vertex:od,insert_vertex:sd,delete_vertex:ad},hd={move_vertex:od,insert_vertex:ad,delete_vertex:sd},cd=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(),g=function(t,e){var n=e,i=-1,r=new Il,o=new rl({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=_u(t).map(function(t,e){var n=new Tl({geometry:new ma(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),f=function(t,e){var n=e,i=-1,r=new Il,o=new rl({source:r,style:function(t){return t.get("vertexIndex")===i?null:[n]},zIndex:102});return t.addLayer(o),{update:function(t){r.clear(),du(t).forEach(function(t,e){var n=new Tl({geometry:new ma(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 Il,i=new rl({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 Tl({geometry:new ma(c)});d.setStyle(u),n.addFeature(d)}}},remove:function(){n.clear(),t.removeLayer(i)}}}(e,function(){return n.styles}),_=mu({map:e,manager:n,store:h,olFeature:u,interfaceType:s,layers:{vertexLayer:f,midpointLayer:g,activeLayer:p}}),m=_.state,y=_.getState,v=_.setState,x=_.syncGeom,S=_.emitGeometryValidation,C=Ru({map:e,olFeature:u,getState:y,onModifyEnd:function(t){x();var e=t&&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}(t,m.vertices);e&&(c.push(e),S(ld[e.type],e.vertexIndex),v({selectedVertexIndex:e.vertexIndex,selectedVertexType:rd}))}});x();var w={vertexLayer:f,midpointLayer:g,activeLayer:p},I=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,nu.De)({onChange:function(t,i){r=t,e.render(),n.emit(Jc.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}),b=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,g=function(t){return c({selectedVertexIndex:t,selectedVertexType:rd})},f=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=(0,Fu.DD)(n);(0,Fu.ZP)(h,a);var c={scale:1,ox:0,oy:0},u=function(t){return{x:t.x*c.scale+c.ox,y:t.y*c.scale+c.oy}},d=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(c,{scale:o/s,ox:(i.left-r.left)/s,oy:(i.top-r.top)/s})},g=Nu({container:n,map:e,targetEl:h,olToCSS:u,cssToOl:function(t){return{x:(t.x-c.ox)/c.scale,y:(t.y-c.oy)/c.scale}},getState:i,setState:r,onVertexMoved:o,onTap:s,snap:l}),f=function(){var t=i(),n=t.selectedVertexIndex,r=t.vertices,o=t.interfaceType;if(n<0||!r[n]||"touch"!==o)(0,Fu.$X)(h);else{var s=zc(e,r[n]);s?(0,Fu.Ox)(h,u(s)):(0,Fu.$X)(h)}},p=function(){var t=i(),e=t.selectedVertexIndex,n=t.interfaceType;e>=0&&!g.isDragging()&&"touch"===n&&f()};e.on("postrender",p);var _=function(){d(),e.once("postrender",f)};return e.on("change:size",_),d(),{updateTargetPosition:f,updateColors:function(t){(0,Fu.ZP)(h,t)},hide:function(){(0,Fu.$X)(h)},destroy:function(){e.un("change:size",_),e.un("postrender",p),g.destroy(),(0,Fu.$X)(h)}}}({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(od,e),g(e),f.updateTargetPosition()},onTap:function(t){if(t){if(t.type===rd)return g(t.index),void f.updateTargetPosition();var e=Lu(o,l.midpoints,t.index,l.vertices.length);e&&(s.push({type:"insert_vertex",vertexIndex:e.insertedIndex}),u(),d(sd,e.insertedIndex),g(e.insertedIndex),f.updateTargetPosition())}else c({selectedVertexIndex:-1,selectedVertexType:null})}});return a.setHooks({onDeselect:function(){return f.hide()},onUpdate:function(){l.interfaceType===id&&f.updateTargetPosition()}}),f}({map:e,container:o,manager:n,snap:l,olFeature:u,undoStack:c,selection:_}),T=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!==rd||o.selectedVertexIndex<0)){var t=function(t,e){var n=t.getGeometry(),i={type:n.getType(),coordinates:n.getCoordinates()},r=du(i),o=gu(i),s=fu(o,e);if(!s)return null;var a=s.segment,l=a.closed?eu.n8.Polygon:eu.n8.LineString;if(a.length<=l)return null;var h=ku(r[e]),c=pu(i,a.path);return c.splice(s.localIdx,1),a.closed&&(c[c.length-1]=ku(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(ad,t.deletedIndex),s({selectedVertexIndex:-1,selectedVertexType:null}))}},doUndo:function(){var t=n.pop();if(t){var i=o.selectedVertexIndex,h=nd(e,t);a(),l(hd[t.type],h);var c=i>=0?h:-1;s({selectedVertexIndex:c,selectedVertexType:c>=0?rd:null}),i>=0&&c>=0&&o.interfaceType===id&&r().updateTargetPosition()}}}}({olFeature:u,undoStack:c,selection:_,getTouchHandler:function(){return b}}),E=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 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=qu({map:n,snap:i,getState:r,setState:o,onInserted:a,onVertexMoved:s}),d=u.nudge,g=u.keyMove,f=u.nudgeByDelta,p=null!==(e=n.getViewport().closest('[role="application"]'))&&void 0!==e?e:n.getViewport(),_=function(){return function(t){var e=document.activeElement;return!(!e||e===document.body)&&!t.contains(e)&&($u.has(e.tagName)||e.isContentEditable||e.hasAttribute("tabindex"))}(p)},m=Ju({map:n,getState:r,setState:o,nudge:d,keyMove:g,onUndo:h,onKeyboardActive:c,isFocused:_}),y=function(t){var e=t.snap,n=t.keyMove,i=t.onVertexMoved,r=t.onDeleted,o=t.isFocused;return function(t){o()||(Hu.has(t.key)&&n.start&&null!=n.index&&(null==e||e.hideIndicator(),i({vertexIndex:n.index,previousCoord:n.start}),n.start=null,n.index=null),"Delete"===t.key&&r())}}({snap:i,keyMove:g,onVertexMoved:s,onDeleted:l,isFocused:_});return globalThis.addEventListener("keydown",m,{capture:!0}),globalThis.addEventListener("keyup",y,{capture:!0}),{nudgeByDelta:f,destroy:function(){globalThis.removeEventListener("keydown",m,{capture:!0}),globalThis.removeEventListener("keyup",y,{capture:!0})}}}({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(od,e),c({selectedVertexIndex:e,selectedVertexType:rd})},onInserted:function(t){var e=t.insertedIndex;r.push({type:"insert_vertex",vertexIndex:e}),u(),d(sd,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:_,touchHandler:b,actions:T}),P=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 Pu(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:y,setState:v,touchHandler:b,deleteVertexButtonId:a,onDeleteVertex:T.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(Qc,a);var l=function(){s.interfaceType!==id||s.selectedVertexIndex<0||e.once("postrender",function(){return r.updateTargetPosition()})};return e.on("change:size",l),{destroy:function(){n.off(Qc,a),e.un("change:size",l)}}}({map:e,manager:n,layers:w,selection:_,touchHandler:b,live:I});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=o.state,h=a.touchHandler;return{setInterfaceType:function(t){t!==l.interfaceType&&(l.interfaceType=t,t===id?h.updateTargetPosition():h.hide())},done:function(){e.emit(Jc.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,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(),h.destroy(),a.keyboardHandler.destroy()}}}({manager:n,store:h,olFeature:u,originalFeatureStyle:d,selection:_,actions:T,parts:{touchHandler:b,keyboardHandler:E,pointerHandlers:P,modify:C,mapSync:M,layers:w,live:I}})};function ud(t){return ud="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},ud(t)}function dd(){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 gd(h,"_invoke",function(n,i,r){var o,a,l,h=0,c=r||[],u=!1,d={p:0,n:0,v:t,a:g,f:g.bind(t,4),d:function(e,n){return o=e,a=0,l=t,d.n=n,s}};function g(n,i){for(a=n,l=i,e=0;!u&&h&&!r&&e<c.length;e++){var r,o=c[e],g=d.p,f=o[2];n>3?(r=f===i)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=g&&((r=n<2&&g<o[1])?(a=0,d.v=i,d.n=o[1]):g<f&&(r=n<3||o[0]>i||i>f)&&(o[4]=n,o[5]=i,d.n=f,a=0))}if(r||n>1)return s;throw u=!0,i}return function(r,c,f){if(h>1)throw TypeError("Generator is already running");for(u&&1===c&&g(c,f),a=c,l=f;(e=a<2?t:l)||!u;){o||(a?a<3?(a>1&&(d.n=-1),g(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]())):(gd(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,gd(t,r,"GeneratorFunction")),t.prototype=Object.create(u),t}return l.prototype=h,gd(u,"constructor",h),gd(h,"constructor",l),l.displayName="GeneratorFunction",gd(h,r,"GeneratorFunction"),gd(u),gd(u,r,"Generator"),gd(u,i,function(){return this}),gd(u,"toString",function(){return"[object Generator]"}),(dd=function(){return{w:o,m:d}})()}function gd(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}gd=function(t,e,n,i){function o(e,n){gd(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))},gd(t,e,n,i)}function fd(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 pd(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?fd(Object(n),!0).forEach(function(e){_d(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fd(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _d(t,e,n){return(e=vd(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function md(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 yd(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,vd(i.key),i)}}function vd(t){var e=function(t){if("object"!=ud(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ud(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ud(e)?e:e+""}var xd=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 Il,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=Kl.readFeature(t);return r.addFeature(n),n},get:function(t){var e=this.getOL(t);return e?Kl.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 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}}(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 Kl.writeFeatureObject(t)},fromGeoJSON:function(t){return Kl.readFeature(t)}},this.undoStack=(0,Hl.B)(function(t){return o.emit(Jc.k.UNDO_CHANGE,t)}),this.colors=(0,lh.$)(null,s),this.styles=ah(this.colors),this.snap=pc(e,null!==(n=s.snapLayers)&&void 0!==n?n:null,this.colors,null!==(i=s.snapRadius)&&void 0!==i?i:$l.vf.snapRadius),this._layer=new rl({source:this.store.source,style:this.styles.createFeatureStyle(),zIndex:100}),this._layer.set("layerId","draw"),e.addLayer(this._layer)},e=[{key:"setMapStyle",value:function(t){var e;this.colors=(0,lh.$)(t,this._pluginConfig),this.styles=ah(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(Qc,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=dd().m(function t(e){var n,i,r,o,s,a,l=arguments;return dd().w(function(t){for(;;)switch(t.n){case 0:o=l.length>1&&void 0!==l[1]?l[1]:{},null===(n=this._modeInstance)||void 0===n||n.destroy(),this._modeInstance=null,this._mode=e,s="draw_polygon"===e||"draw_line"===e||"edit_vertex"===e,null===(i=this.snap)||void 0===i||i.setIndicatorActive(s),a=pd(pd({},o),{},{snap:this.snap}),"draw_polygon"===e||"draw_line"===e?this._modeInstance=au({map:this._map,manager:this,options:a}):"edit_vertex"===e&&(this._modeInstance=cd({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){md(o,i,r,s,a,"next",t)}function a(t){md(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:"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(Jc.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&&yd(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,i}();function Sd(t){return Sd="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},Sd(t)}function Cd(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 wd(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Cd(Object(n),!0).forEach(function(e){bd(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Cd(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Id(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,Td(i.key),i)}}function bd(t,e,n){return(e=Td(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Td(t){var e=function(t){if("object"!=Sd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Sd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sd(e)?e:e+""}var Ed=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),bd(this,"_snapEnabled",!1);var r=function(t){var e=t.mapProvider,n=t.events,i=t.eventBus,r=t.pluginConfig,o=void 0===r?{}:r,s=t.mapStyle,a=void 0===s?null:s,l=e.map,h=new xd(l,o);a&&h.setMapStyle(a),e.draw=h;var c=function(t){var n;e.drawScale=null!==(n=$l.$y[t])&&void 0!==n?n:1};i.on(n.MAP_SET_SIZE,c);var u=function(t){h.setMapStyle(t)};return i.on(n.MAP_SET_STYLE,u),{manager:h,remove:function(){i.off(n.MAP_SET_SIZE,c),i.off(n.MAP_SET_STYLE,u),h.remove(),e.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=wd(wd({},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:"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){return this._manager.add(t)}},{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&&Id(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,g=null,f=function(){null!=d&&((0,o.WG)(d),d=null),g=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)},_=function(){var t,e;if(g){var n=g,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)}},m=function(){if(d=null,g){var t=g,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,_()}};return{update:function(t){var e=t.feature,n=t.context,i=void 0===n?{}:n,r=t.numVertices,s=t.onGeometryChange;g={feature:e,context:l(l({},i),{},{numVertices:r}),onGeometryChange:s},_(),"function"==typeof s&&null==d&&(d=(0,o.PW)(m))},reset:function(){f(),c=!1,u=null,a(!1,null),h(!1,null)},destroy:function(){f()}}}},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))},g=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,f=s(s({},i),{},{numVertices:o}),p=r(e,f);return p.valid?"function"!=typeof h?(u(),void d(!1,null)):(c={feature:e,context:f,onGeometryChange:h},void(null==a&&(a=l(g)))):(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()}}}}}]);
2
+ "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[722],{854(t,e,n){n.r(e),n.d(e,{OLDrawAdapter:()=>Pd});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)C(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 f(t,e[0],e[1])}function g(t,e){return t[0]<=e[0]&&e[2]<=t[2]&&t[1]<=e[1]&&e[3]<=t[3]}function f(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 _(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 m(t){return _(1/0,1/0,-1/0,-1/0,t)}function y(t,e){const n=t[0],i=t[1];return _(n,i,n,i,e)}function v(t,e,n,i,r){return w(m(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 C(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 w(t,e,n,i,r){for(;n<i;n+=r)I(t,e[n],e[n+1]);return t}function I(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 b(t,e){let n;return n=e(E(t)),n||(n=e(P(t)),n||(n=e(A(t)),n||(n=e(O(t)),n||!1)))}function T(t){let e=0;return G(t)||(e=L(t)*F(t)),e}function E(t){return[t[0],t[1]]}function P(t){return[t[2],t[1]]}function M(t){return[(t[0]+t[2])/2,(t[1]+t[3])/2]}function R(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],g=t[1];return[d-l+u,g-h-c,d-l-u,g-h+c,d+l-u,g+h+c,d+l+u,g+h-c,d-l+u,g-h-c]}function F(t){return t[3]-t[1]}function k(t,e,n){const i=n||[1/0,1/0,-1/0,-1/0];return D(t,e)?(t[0]>e[0]?i[0]=t[0]:i[0]=e[0],t[1]>e[1]?i[1]=t[1]:i[1]=e[1],t[2]<e[2]?i[2]=t[2]:i[2]=e[2],t[3]<e[3]?i[3]=t[3]:i[3]=e[3]):m(i),i}function O(t){return[t[0],t[3]]}function A(t){return[t[2],t[3]]}function L(t){return t[2]-t[0]}function D(t,e){return t[0]<=e[2]&&t[2]>=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function G(t){return t[2]<t[0]||t[3]<t[1]}function j(t,e){const n=e.getExtent(),i=M(t);if(e.canWrapX()&&(i[0]<n[0]||i[0]>=n[2])){const e=L(n),r=Math.floor((i[0]-n[0])/e)*e;t[0]-=r,t[2]-=r}return t}function V(t,e,n){if(e.canWrapX()){const i=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[i[0],t[1],i[2],t[3]]];j(t,e);const r=L(i);if(L(t)>r&&!n)return[[i[0],t[1],i[2],t[3]]];if(t[0]<i[0])return[[t[0]+r,t[1],i[2],t[3]],[i[0],t[1],t[2],t[3]]];if(t[2]>i[2])return[[t[0],t[1],i[2],t[3]],[i[0],t[1],t[2]-r,t[3]]]}return[t]}function W(t,e,n){return Math.min(Math.max(t,e),n)}function X(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 N(t,e,n,i)}function N(t,e,n,i){const r=n-t,o=i-e;return r*r+o*o}function Y(t){return 180*t/Math.PI}function B(t){return t*Math.PI/180}function z(t,e){const n=t%e;return n*e<0?n+e:n}function U(t,e,n){return t+n*(e-t)}function q(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}function Z(t,e,n){if(t>=e&&t<n)return t;const i=n-e;return((t-e)%i+i)%i+e}function K(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 g,f;return d<=0?(g=s,f=a):d>=1?(g=l,f=h):(g=s+d*c,f=a+d*u),[g,f]}function H(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 $(t,e){const n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function J(t,e){return Math.sqrt($(t,e))}function Q(t,e){if(e.canWrapX()){const n=L(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||L(i),r=Math.floor((t[0]-i[0])/n)),r}(t,e,n);i&&(t[0]-=i*n)}return t}const tt="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"",et=(tt.includes("safari")&&!tt.includes("chrom")&&(tt.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(tt)),tt.includes("webkit")&&tt.includes("edge"),tt.includes("macintosh"),"undefined"!=typeof devicePixelRatio&&devicePixelRatio,"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope),nt="undefined"!=typeof Image&&Image.prototype.decode;function it(t,e,n,i){let r;return r=n&&n.length?n.shift():et?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 rt;function ot(){return rt||(rt=it(1,1)),rt}function st(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}}();const at=2;let lt=1;const ht={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937},ct=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_||ht[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_}},ut=6378137,dt=Math.PI*ut,gt=[-dt,-dt,dt,dt],ft=[-180,-85,180,85],pt=ut*Math.log(Math.tan(Math.PI/2));class _t extends ct{constructor(t){super({code:t,units:"m",extent:gt,global:!0,worldExtent:ft,getPointResolution:function(t,e){return t/Math.cosh(e[1]/ut)}})}}const mt=[new _t("EPSG:3857"),new _t("EPSG:102100"),new _t("EPSG:102113"),new _t("EPSG:900913"),new _t("http://www.opengis.net/def/crs/EPSG/0/3857"),new _t("http://www.opengis.net/gml/srs/epsg.xml#3857")];const yt=[-180,-90,180,90],vt=6378137*Math.PI/180;class xt extends ct{constructor(t,e){super({code:t,units:"degrees",extent:yt,axisOrientation:e,global:!0,metersPerUnit:vt,worldExtent:yt})}}const St=[new xt("CRS:84"),new xt("EPSG:4326","neu"),new xt("urn:ogc:def:crs:OGC:1.3:CRS84"),new xt("urn:ogc:def:crs:OGC:2:84"),new xt("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new xt("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new xt("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Ct={},wt={};function It(t,e,n){const i=t.getCode(),r=e.getCode();i in wt||(wt[i]={}),wt[i][r]=n}function bt(t,e){return t in wt&&e in wt[t]?wt[t][e]:null}const Tt=.9996,Et=.00669438,Pt=Et*Et,Mt=Pt*Et,Rt=Et/(1-Et),Ft=Math.sqrt(1-Et),kt=(1-Ft)/(1+Ft),Ot=kt*kt,At=Ot*kt,Lt=At*kt,Dt=Lt*kt,Gt=.9983242984503243,jt=15*Pt/256+45*Mt/1024,Vt=35*Mt/3072,Wt=1.5*kt-27/32*At+269/512*Dt,Xt=21/16*Ot-55/32*Lt,Nt=151/96*At-417/128*Dt,Yt=1097/512*Lt,Bt=6378137;function zt(t,e,n){const i=t-5e5,r=(n.north?e:e-1e7)/Tt/(Bt*Gt),o=r+Wt*Math.sin(2*r)+Xt*Math.sin(4*r)+Nt*Math.sin(6*r)+Yt*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-Et*a,g=Math.sqrt(1-Et*a),f=Rt*l**2,p=f*f,_=i/(Bt/g*Tt),m=_*_,y=m*_,v=y*_,x=v*_,S=o-h/((1-Et)/d)*(m/2-v/24*(5+3*c+10*f-4*p-9*Rt))+x*_/720*(61+90*c+298*f+45*u-252*Rt-3*p);let C=(_-y/6*(1+2*c+f)+x/120*(5-2*f+28*c-3*p+8*Rt+24*u))/l;return C=Z(C+B(qt(n.number)),-Math.PI,Math.PI),[Y(C),Y(S)]}function Ut(t,e,n){t=Z(t,-180,180),e<-80?e=-80:e>84&&(e=84);const i=B(e),r=Math.sin(i),o=Math.cos(i),s=r/o,a=s*s,l=a*a,h=B(t),c=B(qt(n.number)),u=Bt/Math.sqrt(1-Et*r**2),d=Rt*o**2,g=o*Z(h-c,-Math.PI,Math.PI),f=g*g,p=f*g,_=p*g,m=_*g,y=m*g,v=Bt*(Gt*i-.002514607064228144*Math.sin(2*i)+jt*Math.sin(4*i)-Vt*Math.sin(6*i)),x=Tt*u*(g+p/6*(1-a+d)+m/120*(5-18*a+l+72*d-58*Rt))+5e5;let S=Tt*(v+u*s*(f/2+_/24*(5-a+9*d+4*d**2)+y/720*(61-58*a+l+600*d-330*Rt)));return n.north||(S+=1e7),[x,S]}function qt(t){return 6*(t-1)-180+3}const Zt=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Kt(t){let e=0;for(const n of Zt){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 Ht(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}}function $t(t,e,n){n=n||6371008.8;const i=B(t[1]),r=B(e[1]),o=(r-i)/2,s=B(e[0]-t[0])/2,a=Math.sin(o)*Math.sin(o)+Math.sin(s)*Math.sin(s)*Math.cos(i)*Math.cos(r);return 2*n*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}const Jt=[function(t){const e=Kt(t.getCode());return e?{forward:Ht(Ut,e),inverse:Ht(zt,e)}:null}],Qt=[function(t){return Kt(t)?new ct({code:t,units:"m"}):null}];let te=!0;function ee(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 ne(t){!function(t,e){Ct[t]=e}(t.getCode(),t),It(t,t,ee)}function ie(t){if("string"!=typeof t)return t;const e=Ct[n=t]||Ct[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null;var n;if(e)return e;for(const e of Qt){const n=e(t);if(n)return n}return null}function re(t,e,n,i){let r;const o=(t=ie(t)).getPointResolutionFunc();if(o){if(r=o(e,n),i&&i!==t.getUnits()){const e=t.getMetersPerUnit();e&&(r=r*e/ht[i])}}else{const o=t.getUnits();if("degrees"==o&&!i||"degrees"==i)r=e;else{const s=le(t,ie("EPSG:4326"));if(s||"degrees"===o){let t=[n[0]-e/2,n[1],n[0]+e/2,n[1],n[0],n[1]-e/2,n[0],n[1]+e/2];t=s(t,t,2),r=($t(t.slice(0,2),t.slice(2,4))+$t(t.slice(4,6),t.slice(6,8)))/2}else r=e*t.getMetersPerUnit();const a=i?ht[i]:t.getMetersPerUnit();void 0!==a&&(r/=a)}}return r}function oe(t){!function(t){t.forEach(ne)}(t),t.forEach(function(e){t.forEach(function(t){e!==t&&It(e,t,ee)})})}function se(t,e){return t?"string"==typeof t?ie(t):t:ie(e)}function ae(t,e){if(t===e)return!0;const n=t.getUnits()===e.getUnits();return(t.getCode()===e.getCode()||le(t,e)===ee)&&n}function le(t,e){const n=t.getCode(),i=e.getCode();let r=bt(n,i);if(r)return r;let o=null,s=null;for(const n of Jt)o||(o=n(t)),s||(s=n(e));if(!o&&!s)return null;const a="EPSG:4326";if(s)if(o)r=he(o.inverse,s.forward);else{const t=bt(n,a);t&&(r=he(t,s.forward))}else{const t=bt(a,i);t&&(r=he(o.inverse,t))}return r&&(ne(t),ne(e),It(t,e,r)),r}function he(t,e){return function(n,i,r,o){return i=t(n,i,r,o),e(i,i,r,o)}}function ce(t,e){return le(ie(t),ie(e))}function ue(t,e,n){const i=ce(e,n);if(!i){const t=ie(e).getCode(),i=ie(n).getCode();throw new Error(`No transform available between ${t} and ${i}`)}return i(t,void 0,t.length)}function de(t,e,n,i){return function(t,e,n,i){if(G(t))return m(n);let r=[];if(i>1){const e=t[2]-t[0],n=t[3]-t[1];for(let o=0;o<i;++o)r.push(t[0]+e*o/i,t[1],t[2],t[1]+n*o/i,t[2]-e*o/i,t[3],t[0],t[3]-n*o/i)}else r=[t[0],t[1],t[2],t[1],t[2],t[3],t[0],t[3]];e(r,r,2);const o=[],s=[];for(let t=0,e=r.length;t<e;t+=2)o.push(r[t]),s.push(r[t+1]);return function(t,e,n){return _(Math.min.apply(null,t),Math.min.apply(null,e),Math.max.apply(null,t),Math.max.apply(null,e),n)}(o,s,n)}(t,ce(e,n),void 0,i)}let ge=null;function fe(){return ge}function pe(t,e){return t}function _e(t,e){return te&&!H(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(te=!1,function(...t){lt>at||console.warn(...t)}("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t}function me(t,e){return t}function ye(t,e){return t}function ve(t,e){return t}var xe,Se,Ce;oe(mt),oe(St),xe=mt,Se=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]=dt*t[n]/180;let i=ut*Math.log(Math.tan(Math.PI*(+t[n+1]+90)/360));i>pt?i=pt:i<-pt&&(i=-pt),e[n+1]=i}return e},Ce=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]/dt,e[n+1]=360*Math.atan(Math.exp(t[n+1]/ut))/Math.PI-90;return e},St.forEach(function(t){xe.forEach(function(e){It(t,e,Se),It(e,t,Ce)})});const we="prerender",Ie="postrender",be=[NaN,NaN,NaN,0];let Te;const Ee=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Pe=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Me=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Re=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Fe(t,e){return t.endsWith("%")?Number(t.substring(0,t.length-1))/e:Number(t)}function ke(t){throw new Error('failed to parse "'+t+'" as color')}function Oe(t){if(t.toLowerCase().startsWith("rgb")){const e=t.match(Pe)||t.match(Ee)||t.match(Me);if(e){const t=e[4],n=100/255;return[W(Fe(e[1],n)+.5|0,0,255),W(Fe(e[2],n)+.5|0,0,255),W(Fe(e[3],n)+.5|0,0,255),void 0!==t?W(Fe(t,100),0,1):1]}ke(t)}if(t.startsWith("#")){if(Re.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}ke(t)}const e=(Te||(Te=it(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Te);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&&ke(t));const i=e.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return Oe(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]=q(r[3]/255,3),r}const Ae={};let Le=0;function De(t){if(4===t.length)return t;const e=t.slice();return e[3]=1,e}function Ge(t){return t>.0031308?269.025*Math.pow(t,1/2.4)-14.025:3294.6*t}function je(t){return t>.2068965?Math.pow(t,3):108/841*(t-4/29)}function Ve(t){return t>10.314724?Math.pow((t+14.025)/269.025,2.4):t/3294.6}function We(t){return t>.0088564?Math.pow(t,1/3):t/(108/841)+4/29}function Xe(t){const e=Ve(t[0]),n=Ve(t[1]),i=Ve(t[2]),r=We(.222488403*e+.716873169*n+.06060791*i),o=500*(We(.452247074*e+.399439023*n+.148375274*i)-r),s=200*(r-We(.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 Ne(t){if("none"===t)return be;if(Ae.hasOwnProperty(t))return Ae[t];if(Le>=1024){let t=0;for(const e in Ae)3&t++||(delete Ae[e],--Le)}const e=Oe(t);4!==e.length&&ke(t);for(const n of e)isNaN(n)&&ke(t);return Ae[t]=e,++Le,e}function Ye(t){return Array.isArray(t)?t:Ne(t)}function Be(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)+")"}function ze(t){for(const e in t)delete t[e]}function Ue(t){let e;for(e in t)return!1;return!e}function qe(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 Ze(t,e,n,i){return qe(t,e,n,i,!0)}function Ke(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),ze(t))}const He="change",$e=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function Je(){return!0}function Qe(){return!1}function tn(){}function en(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}}const nn=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},rn=class extends $e{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 nn(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,tn);delete o[n]}return a}disposeInternal(){this.listeners_&&ze(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]=tn,++this.pendingRemovals_[t]):(n.splice(i,1),0===n.length&&delete this.listeners_[t]))}};function on(t,e){return t+":"+(e?Ye(e):"null")}const sn=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=on(t,e);return n in this.cache_?this.cache_[n]:null}getPattern(t,e){const n=on(t,e);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,n,i){const r=on(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]=ot().createPattern(n.getImage(1),"repeat")}):this.patternCache_[r]=ot().createPattern(n.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};let an=null;class ln extends rn{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_){an||(an=it(1,1,void 0,{willReadFrequently:!0})),an.drawImage(this.image_,0,0);try{an.getImageData(0,0,1,1),this.tainted_=!1}catch{an=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(He)}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=it(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&&nt?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=it(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:Be(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(He,e),t())};this.addEventListener(He,e)}})),this.ready_}}function hn(t,e,n,i,r,o){let s=void 0===e?void 0:sn.get(e,r);return s||(s=new ln(t,t&&"src"in t?t.src||void 0:e,n,i,r),sn.set(e,r,s,o)),o&&s&&!sn.getPattern(e,r)&&sn.set(e,r,s,o),s}const cn=ln;function un(t){return t?Array.isArray(t)?Be(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return sn.getPattern(t.src,t.color);const e=t.src+":"+t.offset,n=sn.getPattern(e,t.color);if(n)return n;const i=sn.get(t.src,null);if(2!==i.getImageState())return null;const r=it(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]),hn(r.canvas,e,void 0,2,t.color,!0),sn.getPattern(e,t.color)}(t):t:null}function dn(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 gn(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++]=dn(t,e,a,i,r[o]),e=a}return r.length=o,r}function fn(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?[]:gn(t,e,a,i,r[o]),e=a[a.length-1]}return r.length=o,r}const pn=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){}},_n="propertychange";class mn extends rn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(He)}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]=qe(this,t[r],e);return i}return qe(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]=Ze(this,t[r],e)}else n=Ze(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)Ke(t[e]);else Ke(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)}}mn.prototype.on,mn.prototype.once,mn.prototype.un;const yn=mn;function vn(){throw new Error("Unimplemented abstract method.")}let xn=0;function Sn(t){return t.ol_uid||(t.ol_uid=String(++xn))}class Cn extends nn{constructor(t,e,n){super(t),this.key=e,this.oldValue=n}}const wn=class extends yn{constructor(t){super(),this.on,this.once,this.un,Sn(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 Cn(n,t,e)),n=_n,this.hasListener(n)&&this.dispatchEvent(new Cn(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],Ue(this.values_)&&(this.values_=null),e||this.notify(t,n)}}},In=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"),bn=["style","variant","weight","size","lineHeight","family"],Tn={normal:400,bold:700},En=function(t){const e=t.match(In);if(!e)return null;const n={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let t=0,i=bn.length;t<i;++t){const i=e[t+1];void 0!==i&&(n[bn[t]]="string"==typeof i?i.trim():i)}return isNaN(Number(n.weight))&&n.weight in Tn&&(n.weight=Tn[n.weight]),n.families=n.family.split(/,\s?/).map(t=>t.trim().replace(/^['"]|['"]$/g,"")),n},Pn="10px sans-serif",Mn="#000",Rn="round",Fn=[],kn="round",On="#000",An="center",Ln="middle",Dn=[0,0,0,0],Gn=new wn;let jn,Vn=null;const Wn={},Xn=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function Nn(t,e,n){return`${t} ${e} 16px "${n}"`}const Yn=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=En(t),r=i.families[0].toLowerCase(),o=i.weight;return e.some(t=>{const e=t.family.replace(/^['"]|['"]$/g,"").toLowerCase(),n=Tn[t.weight]||t.weight;return e===r&&t.style===i.style&&n==o})}async function r(){await n.ready;let o=!0;const s=Gn.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)?(ze(Wn),Gn.set(n,t)):(r+=10,Gn.set(n,r,!0),r<t&&(o=!1)))}e=void 0,o||(e=setTimeout(r,100))}return async function(t){n||(n=et?self.fonts:document.fonts);const i=En(t);if(!i)return;const o=i.families;let s=!1;for(const t of o){if(Xn.has(t))continue;const e=Nn(i.style,i.weight,t);void 0===Gn.get(e)&&(Gn.set(e,0,!0),s=!0)}s&&(clearTimeout(e),e=setTimeout(r,100))}}(),Bn=function(){let t;return function(e){let n=Wn[e];if(null==n){if(et){const t=En(e),i=zn(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);Wn[e]=n}return n}}();function zn(t,e){return Vn||(Vn=it(1,1)),t!=jn&&(Vn.font=t,jn=Vn.font),Vn.measureText(e)}function Un(t,e){return zn(t,e).width}function qn(t,e,n){if(e in n)return n[e];const i=e.split("\n").reduce((e,n)=>Math.max(e,Un(t,n)),0);return n[e]=i,i}const Zn={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},Kn=[Zn.FILL],Hn=[Zn.STROKE],$n=[Zn.BEGIN_PATH],Jn=[Zn.CLOSE_PATH],Qn=Zn,ti=class extends pn{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,g,f,_=!0;for(d=e+i;d<n;d+=i)u[0]=t[d],u[1]=t[d+1],f=p(l,u),f!==g?(_&&(s[a++]=h,s[a++]=c,_=!1),s[a++]=u[0],s[a++]=u[1]):1===f?(s[a++]=u[0],s[a++]=u[1],_=!1):_=!0,h=u[0],c=u[1],g=f;return(r&&_||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([Qn.CUSTOM,a,u,t,n,fn,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,u,t,i||n,fn,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([Qn.CUSTOM,a,c,t,n,gn,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,c,t,i||n,gn,r]);break;case"LineString":case"Circle":l=t.getFlatCoordinates(),h=this.appendFlatLineCoordinates(l,0,l.length,s,!1,!1),this.instructions.push([Qn.CUSTOM,a,h,t,n,dn,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,h,t,i||n,dn,r]);break;case"MultiPoint":l=t.getFlatCoordinates(),h=this.appendFlatPointCoordinates(l,s),h>a&&(this.instructions.push([Qn.CUSTOM,a,h,t,n,dn,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,h,t,i||n,dn,r]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),h=this.coordinates.length,this.instructions.push([Qn.CUSTOM,a,h,t,n,void 0,r]),this.hitDetectionInstructions.push([Qn.CUSTOM,a,h,t,i||n,void 0,r])}this.endGeometry(e)}beginGeometry(t,e,n){this.beginGeometryInstruction1_=[Qn.BEGIN_GEOMETRY,e,0,t,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[Qn.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==Qn.END_GEOMETRY?o=e:r==Qn.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=un(n||Mn)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const n=t.getColor();e.strokeStyle=un(n||On);const i=t.getLineCap();e.lineCap=void 0!==i?i:Rn;const r=t.getLineDash();e.lineDash=r?r.slice():Fn;const o=t.getLineDashOffset();e.lineDashOffset=o||0;const s=t.getLineJoin();e.lineJoin=void 0!==s?s:kn;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=[Qn.SET_FILL_STYLE,e];return"string"!=typeof e&&n.push(t.fillPatternScale),n}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[Qn.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=[Qn.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 ei(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],g=t[n+1];for(let e=o+i;e<n;e+=i){const n=X(t[e],t[e+1],a,u,d,g);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 ni(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];s=ei(t,e,h,i,r,o,s),a.push(s),e=h}return s}function ii(t,e){return e*Math.round(t/e)}function ri(t,e,n,i,r,o,s){if(e==n)return s;let a,l,h=ii(t[e],r),c=ii(t[e+1],r);e+=i,o[s++]=h,o[s++]=c;do{if(a=ii(t[e],r),l=ii(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=ii(t[e],r),u=ii(t[e+1],r);if(e+=i,n==a&&u==l)continue;const d=a-h,g=l-c,f=n-h,p=u-c;d*p==g*f&&(d<0&&f<d||d==f||d>0&&f>d)&&(g<0&&p<g||g==p||g>0&&p>g)?(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 oi(t,e,n,i,r,o,s,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];s=ri(t,e,h,i,r,o,s),a.push(s),e=h}return s}const si=class extends ti{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($n),this.hitDetectionInstructions.push($n);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([Qn.MOVE_TO_LINE_TO,l,h,r*this.pixelRatio,!0]),this.hitDetectionInstructions.push([Qn.MOVE_TO_LINE_TO,l,h,r,!0]),a&&(this.instructions.push(Jn),this.hitDetectionInstructions.push(Jn)),e=s}return s&&(this.instructions.push(Kn),this.hitDetectionInstructions.push(Kn)),a&&(this.instructions.push(Hn),this.hitDetectionInstructions.push(Hn)),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([Qn.SET_FILL_STYLE,Mn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,0]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[Qn.CIRCLE,h,s];this.instructions.push($n,c),this.hitDetectionInstructions.push($n,c),void 0!==i.fillStyle&&(this.instructions.push(Kn),this.hitDetectionInstructions.push(Kn)),void 0!==i.strokeStyle&&(this.instructions.push(Hn),this.hitDetectionInstructions.push(Hn)),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([Qn.SET_FILL_STYLE,Mn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,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([Qn.SET_FILL_STYLE,Mn]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,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]=ii(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 ai(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=U(n,h,e),g=U(i,c,e);l.push(d,g),o.push(l),l=[d,g],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=U(n,h,t/u),d=U(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 li(t,e,n,i,r){let o,s,a,l,h,c,u,d,g,f,p=n,_=n,m=0,y=0,v=n;for(s=n;s<i;s+=r){const n=e[s],i=e[s+1];void 0!==h&&(g=n-h,f=i-c,l=Math.sqrt(g*g+f*f),void 0!==u&&(y+=a,o=Math.acos((u*g+d*f)/(a*l)),o>t&&(y>m&&(m=y,p=v,_=s),y=0,v=s-r)),a=l,u=g,d=f),h=n,c=i}return y+=l,y>m?[v,s]:[p,_]}const hi={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},ci={Circle:si,Default:ti,Image:class extends ti{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([Qn.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([Qn.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([Qn.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([Qn.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 ti{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([Qn.MOVE_TO_LINE_TO,o,s,r*this.pixelRatio]),this.hitDetectionInstructions.push([Qn.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([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,0],$n);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l,s),this.hitDetectionInstructions.push(Hn),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([Qn.SET_STROKE_STYLE,On,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Fn,0],$n);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(Hn),this.endGeometry(e)}finish(){const t=this.state;return null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Hn),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Hn),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push($n)}},Polygon:si,Text:class extends ti{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[Mn]={fillStyle:Mn},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 g=o.padding;if(g!=Dn&&(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),g=[t,e,n,i]}const f=this.pixelRatio;this.instructions.push([Qn.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==Dn?Dn:g.map(function(t){return t*f}),u,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]);const p=1/f,_=u?u.slice(0):null;_&&(_[1]=Mn),this.hitDetectionInstructions.push([Qn.DRAW_IMAGE,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,this.declutterMode_,this.declutterImageWithText_,g,_,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Mn:this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]),this.endGeometry(e)}else{if(!D(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?ai(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=li(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 g=s.length;d=i[t],this.drawChars_(a,g),a=g}}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||An,justify:e.justify,textBaseline:e.textBaseline||Ln,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=hi[i.textBaseline],h=this.textOffsetY_*a,c=this.text_,u=n?n.lineWidth*Math.abs(i.scale[0])/2:0;this.instructions.push([Qn.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([Qn.DRAW_CHARS,t,e,l,i.overflow,s?Mn: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=un(e.getColor()||Mn)):(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()||Rn,r.lineDash=t?t.slice():Fn,r.lineDashOffset=void 0===e?0:e,r.lineJoin=o.getLineJoin()||kn,r.lineWidth=void 0===n?1:n,r.miterLimit=void 0===i?10:i,r.strokeStyle=un(o.getColor()||On)}else r=null,this.textStrokeState_=r;n=this.textState_;const s=t.getFont()||Pn;Yn(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()||Ln,n.backgroundFill=t.getBackgroundFill(),n.backgroundStroke=t.getBackgroundStroke(),n.padding=t.getPadding()||Dn,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:Sn(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:"|"+Sn(i.fillStyle):""}else this.text_="";this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}},ui=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,ci[e])(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),i[e]=r),r}};function di(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 gi(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 fi(t,e){if(!t)throw new Error(e)}const pi=new Array(6);function _i(t){return yi(t,1,0,0,1,0,0)}function mi(t,e){const n=t[0],i=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=e[0],h=e[1],c=e[2],u=e[3],d=e[4],g=e[5];return t[0]=n*l+r*h,t[1]=i*l+o*h,t[2]=n*c+r*u,t[3]=i*c+o*u,t[4]=n*d+r*g+s,t[5]=i*d+o*g+a,t}function yi(t,e,n,i,r,o,s){return t[0]=e,t[1]=n,t[2]=i,t[3]=r,t[4]=o,t[5]=s,t}function vi(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 xi(t,e,n){return mi(t,yi(pi,e,0,0,n,0,0))}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}const Ci=[1e5,1e5,1e5,1e5,2,2];function wi(t){return t.substring(7,t.length-1).split(",").map(parseFloat)}function Ii(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 bi(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,g,f,p,_,m,y,v,x=0;for(let S=e;S<n;S+=i){f=d,p=g,_=void 0,m=void 0,S+i<n&&(_=t[S+i],m=t[S+i+1]),o&&S===e&&(f=c,p=u),o&&S===n-i&&(_=l,m=h),d=t[S],g=t[S+1],[y,v]=Ti(d,g,f,p,_,m,r),s[x++]=y,s[x++]=v;for(let e=2;e<a;e++)s[x++]=t[S+e]}return s.length!=x&&(s.length=x),s}function Ti(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(W(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 g=Math.cos(d/2),f=Math.sin(d/2);return[t+1/f*(f*a+g*l)*s,e+1/f*(-g*a+f*l)*s]}function Ei(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 g=((c-l)*(o-h)-(u-h)*(r-l))/d,f=((s-r)*(o-h)-(a-o)*(r-l))/d;if(g>0&&g<1&&f>0&&f<1){const l=r+g*(s-r),h=o+g*(a-o);t[n+e]=l,t[n+e+1]=h,t.splice(n+2*e,i-n-e);break}}return t}function Pi(t,e,n,i,r,o,s,a,l,h,c,u,d=!0){let g=t[e],f=t[e+1],p=0,_=0,m=0,y=0;function v(){p=g,_=f,g=t[e+=i],f=t[e+1],y+=m,m=Math.sqrt((g-p)*(g-p)+(f-_)*(f-_))}do{v()}while(e<n-i&&y+m<o);let x=0===m?0:(o-y)/m;const S=U(p,g,x),C=U(_,f,x),w=e-i,I=y,b=o+a*l(h,r,c);for(;e<n-i&&y+m<b;)v();x=0===m?0:(b-y)/m;const T=U(p,g,x),E=U(_,f,x);let P=!1;if(d)if(u){const t=[S,C,T,E];gi(t,0,4,2,u,t,t),P=t[0]>t[2]}else P=S>T;const M=Math.PI,R=[],F=w+i===e;let k;if(m=0,y=I,g=t[e=w],f=t[e+1],F){v(),k=Math.atan2(f-_,g-p),P&&(k+=k>0?-M:M);const t=(T+S)/2,e=(E+C)/2;return R[0]=[t,e,(b-o)/2,k,r],R}for(let t=0,u=(r=r.replace(/\n/g," ")).length;t<u;){v();let d=Math.atan2(f-_,g-p);if(P&&(d+=d>0?-M:M),void 0!==k){let t=d-k;if(t+=t>M?-2*M:t<-M?2*M:0,Math.abs(t)>s)return null}k=d;const S=t;let C=0;for(;t<u;++t){const s=a*l(h,r[P?u-t-1:t],c);if(e+i<n&&y+m<o+C+s/2)break;C+=s}if(t===S)continue;const w=P?r.substring(u-S,u-t):r.substring(S,t);x=0===m?0:(o+C/2-y)/m;const I=U(p,g,x),b=U(_,f,x);R.push([I,b,C/2,d,w]),o+=C}return R}const Mi=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(ot(),{get:(t,e)=>{if("function"==typeof ot()[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}},Ri=[1/0,1/0,-1/0,-1/0],Fi=[],ki=[],Oi=[],Ai=[];function Li(t){return t[3].declutterBox}const Di=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 Gi(t,e){return"start"===e?e=Di.test(t)?"right":"left":"end"===e&&(e=Di.test(t)?"left":"right"),hi[e]}function ji(t,e,n){return n>0&&t.push("\n",""),t.push(e,""),t}function Vi(t,e,n){return n%2==0&&(t+=e),t}const Wi=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 Mi: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?hi[a.justify]:Gi(Array.isArray(t)?t[0]:t,a.textAlign||An),u=i&&o.lineWidth?o.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(ji,[]),{width:g,height:f,widths:p,heights:_,lineWidths:m}=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,g=Un(d,u);n.push(g),s+=g;const f=Bn(d);i.push(f),l=Math.max(l,f)}return{width:o,height:a,widths:n,heights:i,lineWidths:r}}(a,d),y=g+u,v=[],x=(y+2)*h[0],S=(f+u)*h[1],C={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 w=.5-c;let I=c*y+w*u;const b=[],T=[];let E,P=0,M=0,R=0,F=0;for(let t=0,e=d.length;t<e;t+=2){const e=d[t];if("\n"===e){M+=P,P=0,I=c*y+w*u,++F;continue}const r=d[t+1]||a.font;r!==E&&(i&&b.push("font",r),n&&T.push("font",r),E=r),P=Math.max(P,_[R]);const o=[e,I+w*p[R]+c*(p[R]-m[F]),.5*(u+P)+M];I+=p[R],i&&b.push("strokeText",o),n&&T.push("fillText",o),++R}return Array.prototype.push.apply(v,b),Array.prototype.push.apply(v,T),this.labels_[r]=C,C}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,g,f,p){let m=n-(s*=u[0]),y=i-(a*=u[1]);const v=r+l>t?t-l:r,x=o+h>e?e-h:o,S=g[3]+v*u[0]+g[1],C=g[0]+x*u[1]+g[2],w=m-g[3],I=y-g[0];let b;return(f||0!==c)&&(Fi[0]=w,Ai[0]=w,Fi[1]=I,ki[1]=I,ki[0]=w+S,Oi[0]=ki[0],Oi[1]=I+C,Ai[1]=Oi[1]),0!==c?(b=Si([1,0,0,1,0,0],n,i,1,1,c,-n,-i),vi(b,Fi),vi(b,ki),vi(b,Oi),vi(b,Ai),_(Math.min(Fi[0],ki[0],Oi[0],Ai[0]),Math.min(Fi[1],ki[1],Oi[1],Ai[1]),Math.max(Fi[0],ki[0],Oi[0],Ai[0]),Math.max(Fi[1],ki[1],Oi[1],Ai[1]),Ri)):_(Math.min(w,w+S),Math.min(I,I+C),Math.max(w,w+S),Math.max(I,I+C),Ri),d&&(m=Math.round(m),y=Math.round(y)),{drawImageX:m,drawImageY:y,drawImageW:v,drawImageH:x,originX:l,originY:h,declutterBox:{minX:Ri[0],minY:Ri[1],maxX:Ri[2],maxY:Ri[3],value:p},canvasTransform:b,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,Fi,ki,Oi,Ai,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=vi(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=Gi(Array.isArray(t)?t[0]:t,r.textAlign||An),h=hi[r.textBaseline||Ln],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=di(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 g=0;const f=i.length;let p,_=0;const m=[];let y,v,x,S,C,w,I,b,T,E,P,M,R,F=0,k=0;const O=this.coordinateCache_,A=this.viewRotation_,L=Math.round(1e12*Math.atan2(-n[1],n[0]))/1e12,G={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:A},j=this.instructions!=i||this.overlaps?0:200;let V,W,X,N;for(;g<f;){const n=i[g];switch(n[0]){case Qn.BEGIN_GEOMETRY:V=n[1],N=n[3],V.getGeometry()?void 0===s||D(s,N.getExtent())?++g:g=n[2]+1:g=n[2],h&&(h.zIndex=n[4]);break;case Qn.BEGIN_PATH:F>j&&(this.fill_(t),F=0),k>j&&(t.stroke(),k=0),F||k||(t.beginPath(),C=NaN,w=NaN),++g;break;case Qn.CIRCLE:_=n[1],x=n[2]??0;const i=c[_],l=c[_+1],u=c[_+2]-x-i,d=c[_+3]-x-l,f=Math.sqrt(u*u+d*d);t.moveTo(i+f,l),t.arc(i,l,f,0,2*Math.PI,!0),++g;break;case Qn.CLOSE_PATH:t.closePath(),++g;break;case Qn.CUSTOM:_=n[1],p=n[2];const Y=n[3],B=n[4],z=n[5];G.geometry=Y,G.feature=V,g in O||(O[g]=[]);const U=O[g];z?z(c,_,p,2,U):(U[0]=c[_],U[1]=c[_+1],U.length=2),h&&(h.zIndex=n[6]),B(U,G),++g;break;case Qn.DRAW_IMAGE:_=n[1],p=n[2],T=n[3],y=n[4],v=n[5];let q=n[6];const Z=n[7],K=n[8],H=n[9],$=n[10];let J=n[11];const Q=n[12];let tt=n[13];S=n[14]||"declutter";const et=n[15];if(!T&&n.length>=20){E=n[19],P=n[20],M=n[21],R=n[22];const t=this.drawLabelWithPointPlacement_(E,P,M,R);T=t.label,n[3]=T;const e=n[23];y=(t.anchorX-e)*this.pixelRatio,n[4]=y;const i=n[24];v=(t.anchorY-i)*this.pixelRatio,n[5]=v,q=T.height,n[6]=q,tt=T.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=Dn,rt=null,ot=null),$&&L?J+=A:$||L||(J-=A);let st=0;for(;_<p;_+=2){if(nt&&nt[st++]<tt/this.pixelRatio)continue;const n=this.calculateImageOrLabelDimensions_(T.width,T.height,c[_],c[_+1],tt,q,y,v,K,H,J,Q,r,it,!!rt||!!ot,V),i=[t,e,T,n,Z,rt,ot];if(a){let t,e,r,o,s;if(et){const n=p-_;if(!et[n]){et[n]={args:i,declutterMode:S};continue}const o=et[n];t=o.args,e=o.declutterMode,delete et[n],r=Li(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)}++g;break;case Qn.DRAW_CHARS:const at=n[1],lt=n[2],ht=n[3],ct=n[4];R=n[5];const ut=n[6],dt=n[7],gt=n[8];M=n[9];const ft=n[10];E=n[11],Array.isArray(E)&&(E=E.reduce(Vi,"")),P=n[12];const pt=[n[13],n[13]];S=n[14]||"declutter";const _t=n[15],mt=this.textStates[P],yt=mt.font,vt=[mt.scale[0]*dt,mt.scale[1]*dt];let xt;yt in this.widths_?xt=this.widths_[yt]:(xt={},this.widths_[yt]=xt);const St=Ii(c,at,lt,2),Ct=Math.abs(vt[0])*qn(yt,E,xt);if(ct||Ct<=St){const n=Pi(c,at,lt,2,E,(St-Ct)*Gi(E,this.textStates[P].textAlign),ut,Math.abs(vt[0]),qn,yt,xt,L?0:this.viewRotation_,_t);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,P,"",M),y=h[2]+(vt[0]<0?-ft:ft),v=ht*l.height+2*(.5-ht)*ft*vt[1]/vt[0]-gt;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,y,v,0,0,h[3],pt,!1,Dn,!1,V);if(a&&"declutter"===S&&a.collides(o.declutterBox))break t;i.push([t,e,l,o,1,null,null])}if(R)for(r=0,o=n.length;r<o;++r){h=n[r],s=h[4],l=this.createLabel(s,P,R,""),y=h[2],v=ht*l.height-gt;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,y,v,0,0,h[3],pt,!1,Dn,!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(Li));for(let t=0,e=i.length;t<e;++t)this.replayImageOrLabel_.apply(this,i[t])}}++g;break;case Qn.END_GEOMETRY:if(void 0!==o){V=n[1];const t=o(V,N,S);if(t)return t}++g;break;case Qn.FILL:j?F++:this.fill_(t),++g;break;case Qn.MOVE_TO_LINE_TO:let wt,It,bt;_=n[1],p=n[2],x=n[3],x?(bi(c,_,p,2,x,n[4]??!1,m),Ei(m,2),wt=m,It=0,bt=wt.length):(wt=c,It=_,bt=p),W=wt[It],X=wt[It+1],t.moveTo(W,X),C=W+.5|0,w=X+.5|0;for(let e=It+2;e<bt;e+=2)W=wt[e],X=wt[e+1],I=W+.5|0,b=X+.5|0,e!=bt-2&&I===C&&b===w||(t.lineTo(W,X),C=I,w=b);++g;break;case Qn.SET_FILL_STYLE:this.alignAndScaleFill_=n[2],F?(this.fill_(t),F=0,k&&(t.stroke(),k=0)):k&&n[1]&&(t.stroke(),k=0),t.fillStyle=n[1],++g;break;case Qn.SET_STROKE_STYLE:F&&n[1]&&(this.fill_(t),F=0),k&&(t.stroke(),k=0),this.setStrokeStyle_(t,n),++g;break;case Qn.STROKE:j?k++:t.stroke(),++g;break;default:++g}}F&&this.fill_(t),k&&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)}},Xi=["Polygon","Circle","LineString","Image","Text","Default"],Ni=["Image","Text"],Yi=Xi.filter(t=>!Ni.includes(t));let Bi=!1,zi=!1;const Ui={},qi=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 Wi(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===zi&&function(){let t=0;const e=e=>{const n=it(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};Bi=n[t],zi=!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_=it(a,a,null,{willReadFrequently:Bi}));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],C(d,t),c(d,e*(this.renderBuffer_+r),d));const g=function(t){if(void 0!==Ui[t])return Ui[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 Ui[t]=r,r}(r);let f;function p(t,e,n){const i=u.getImageData(0,0,a,a).data;for(let l=0,h=g.length;l<h;l++)if(i[g[l]]>0){if(!s||"none"===n||"Image"!==f&&"Text"!==f||s.includes(t)){const n=(g[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 _=Object.keys(this.executorsByZIndex_).map(Number);let m,y,v,x,S;for(_.sort(i),m=_.length-1;m>=0;--m){const t=_[m].toString();for(v=this.executorsByZIndex_[t],y=Xi.length-1;y>=0;--y)if(f=Xi[y],x=v[f],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 di(s,0,8,2,t,s),s}isEmpty(){return Ue(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||Xi;const c=Xi.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],g=u[d];if(void 0!==g){const r=null===l?void 0:g.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=>g.execute(t,e,n,o,s,l)):g.execute(a,e,n,o,s,l),u&&a.restore(),r){r.offset();const t=h[i]*c+Xi.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 Zi(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}class Ki{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=Zi(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Ki({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 vn()}getImage(t){return vn()}getHitDetectionImage(){return vn()}getPixelRatio(t){return 1}getImageState(){return vn()}getImageSize(){return vn()}getOrigin(){return vn()}getSize(){return vn()}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_=Zi(t)}listenImageChange(t){vn()}load(){vn()}unlistenImageChange(t){vn()}ready(){return Promise.resolve()}}const Hi=Ki;function $i(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 Ji extends Hi{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(fi(!(void 0!==a&&o),"`image` and `src` cannot be provided at the same time"),void 0!==a&&0!==a.length||!o||(a=o.src||Sn(o)),fi(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),fi(!((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?Ye(t.color):null,this.iconImage_=hn(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($i(n[0],n[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale($i(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 Ji({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?Ye(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_=hn(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_=hn(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(He,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(He,t)}ready(){return this.iconImage_.ready()}}const Qi=Ji,tr=[1,0,0,1,0,0],er=[NaN,NaN],nr=class extends wn{constructor(){super(),this.extent_=[1/0,1/0,-1/0,-1/0],this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=en((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 vn()}closestPointXY(t,e,n,i){return vn()}containsXY(t,e){return 0===this.closestPointXY(t,e,er,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 vn()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&m(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){vn()}scale(t,e,n){vn()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return vn()}getType(){return vn()}applyTransform(t){vn()}intersectsExtent(t){return vn()}translate(t,e){vn()}transform(t,e){const n=ie(t),i="tile-pixels"==n.getUnits()?function(t,i,r){const o=n.getExtent(),s=n.getWorldExtent(),a=F(s)/F(o);Si(tr,s[0],s[3],a,-a,0,0,0);const l=di(t,0,t.length,r,tr,i),h=ce(n,e);return h?h(l,l,r):l}:ce(n,e);return this.applyTransform(i),this}};function ir(t){let e;return 2==t?e="XY":3==t?e="XYZ":4==t&&(e="XYZM"),e}function rr(t){let e;return"XY"==t?e=2:"XYZ"==t||"XYM"==t?e=3:"XYZM"==t&&(e=4),e}const or=class extends nr{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 vn()}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=rr(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){vn()}setLayout(t,e,n){let i;if(t)i=rr(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=ir(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();gi(n,0,n.length,i,t,e,n),this.changed()}}scale(t,e,n){void 0===e&&(e=t),n||(n=M(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()}}},sr=class extends pn{constructor(t,e,n,i,r,o,s){super(),this.context_=t,this.pixelRatio_=e,this.extent_=n,this.transform_=i,this.transformRotation_=i?q(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=di(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=di(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=di(t,e,n,i,this.transform_,this.pixelCoordinates_);Math.abs(o)>0&&(a=bi(a,0,a.length,2,o,r,a),Ei(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_)),D(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 di(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_)),D(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(D(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_)),D(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_)),D(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:An;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:un(e||Mn)}}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||Fn,h=e.getOffset();this.strokeState_={lineCap:void 0!==n?n:Rn,lineDash:1===this.pixelRatio_?l:l.map(t=>t*this.pixelRatio_),lineDashOffset:(r||0)*this.pixelRatio_,lineJoin:void 0!==o?o:kn,lineWidth:(void 0!==s?s:1)*this.pixelRatio_,miterLimit:void 0!==a?a:10,strokeStyle:un(t||On),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:un(t||Mn)}}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:Rn,lineDash:i||Fn,lineDashOffset:r||0,lineJoin:void 0!==o?o:kn,lineWidth:void 0!==s?s:1,miterLimit:void 0!==a?a:10,strokeStyle:un(t||On)}}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:Pn,textAlign:void 0!==c?c:An,textBaseline:void 0!==u?u:Ln},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_=""}},ar=.5;function lr(t,e,n,r,o,s,a,l,h){const c=h?me(o):o,u=it(t[0]*ar,t[1]*ar);u.imageSmoothingEnabled=!1;const d=u.canvas,g=new sr(u,ar,o,null,a,l,h?le(fe(),h):null),f=n.length,p=Math.floor(16777215/f),_={};for(let t=1;t<=f;++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||!D(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=it(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 Qi({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=_[u];d||(d={},_[u]=d,d.Polygon=[],d.Circle=[],d.LineString=[],d.Point=[]);const g=i.getType();if("GeometryCollection"===g){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[g.replace("Multi","")].push(i,r)}}const m=Object.keys(_).map(Number).sort(i);for(let t=0,n=m.length;t<n;++t){const n=_[m[t]];for(const t in n){const i=n[t];for(let t=0,n=i.length;t<n;t+=2){g.setStyle(i[t+1]);for(let n=0,r=e.length;n<r;++n)g.setTransform(e[n]),g.drawGeometry(i[t])}}}return u.getImageData(0,0,d.width,d.height)}function hr(t,e,n){const i=[];if(n){const r=Math.floor(Math.round(t[0])*ar),o=Math.floor(Math.round(t[1])*ar),s=4*(W(r,0,n.width-1)+W(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}const cr={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,cr[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 ur(t,e){return parseInt(Sn(t),10)-parseInt(Sn(e),10)}function dr(t,e){const n=gr(t,e);return n*n}function gr(t,e){return.5*t/e}function fr(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()?pr(t,l,n,e,s):(0,cr[l.getType()])(t,l,n,e,s,o)}(t,e,n,i,o,s,a),u}function pr(t,e,n,i,r){if("GeometryCollection"==e.getType()){const o=e.getGeometries();for(let e=0,s=o.length;e<s;++e)pr(t,o[e],n,i,r);return}t.getBuilder(n.getZIndex(),"Default").drawCustom(e,i,n.getRenderer(),n.getHitDetectionRenderer(),r)}const _r=class extends nn{constructor(t,e,n,i){super(t),this.inversePixelTransform=e,this.frameState=n,this.context=i}},mr=class extends yn{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 vn()}getData(t){return null}prepareFrame(t){return vn()}renderFrame(t,e){return vn()}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(He,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()}},yr=[];let vr=null;const xr=class extends mr{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;vr||(vr=it(1,1,void 0,{willReadFrequently:!0})),vr.clearRect(0,0,1,1);try{vr.drawImage(t,e,n,1,1,0,0,1,1),i=vr.getImageData(0,0,1,1).data}catch{return vr=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(Ye(t.style.backgroundColor),Ye(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=wi(t),i=wi(e);for(let t=0;t<6;++t)if(0!==Math.round((n[t]-i[t])*Ci[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=et?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=it();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=O(n),r=A(n),o=P(n),s=E(n);vi(e.coordinateToPixelTransform,i),vi(e.coordinateToPixelTransform,r),vi(e.coordinateToPixelTransform,o),vi(e.coordinateToPixelTransform,s);const a=this.inversePixelTransform;vi(a,i),vi(a,r),vi(a,o),vi(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(L(n)/i*o),a=Math.round(F(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;fi(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 _r(t,this.inversePixelTransform,n,e);i.dispatchEvent(r)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_(we,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Ie,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new Mi),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(we,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Ie,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()}},Sr=class extends xr{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,g=e.viewHints,f=!(g[0]||g[1]),p=this.context,_=Math.round(L(i)/s*d),m=Math.round(F(i)/s*d),y=c.getWrapX()&&a.canWrapX(),v=y?L(h):null,x=y?Math.ceil((i[2]-h[2])/v)+(this.extendX_?2:1):1;let S=y?Math.floor((i[0]-h[0])/v)-(this.extendX_?1:0):0;do{let i=this.getRenderTransform(o,s,0,d,_,m,S*v);e.declutter&&(i=i.slice(0)),t.execute(p,[p.canvas.width,p.canvas.height],i,l,f,void 0===n?Xi:n?Ni:Yi,n?u&&e.declutter[u]:void 0)}while(++S<x)}setDrawContext_(){1!==this.opacity_&&(this.targetContext_=this.context,this.context=it(this.context.canvas.width,this.context.canvas.height,yr))}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,st(this.context),yr.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(we)&&!this.getLayer().hasListener(Ie))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=ye(n.extent);s=D(e,t.extent),s&&!g(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_,i=this.renderedRotation_,r=this.renderedProjection_,o=this.wrappedRenderedExtent_,s=this.getLayer(),a=[],l=t[0]*ar,h=t[1]*ar;a.push(this.getRenderTransform(e,n,i,ar,l,h,0).slice());const c=s.getSource(),u=r.getExtent();if(c.getWrapX()&&r.canWrapX()&&!g(u,o)){let t=o[0];const r=L(u);let s,c=0;for(;t<u[0];)--c,s=r*c,a.push(this.getRenderTransform(e,n,i,ar,l,h,s).slice()),t+=r;for(c=0,t=o[2];t>u[2];)++c,s=r*c,a.push(this.getRenderTransform(e,n,i,ar,l,h,s).slice()),t-=r}const d=fe();this.hitDetectionImageData_=lr(t,a,this.renderedFeatures_,s.getStyleFunction(),o,n,i,dr(n,this.renderedPixelRatio_),d?r:null)}e(hr(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=Sn(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,f=t.pixelRatio,p=e.getRevision(),_=e.getRenderBuffer();let m=e.getRenderOrder();void 0===m&&(m=ur);const y=h.center.slice(),v=c(a,_*d),x=v.slice(),S=[v.slice()],C=u.getExtent(),w=n.getWrapX()&&u.canWrapX();if(this.extendX_=!1,w){const t=n.getExtent();t&&!G(t)&&(this.extendX_=t[0]<C[0]||t[2]>C[2])}if(w&&(!g(C,t.extent)||this.extendX_)){const t=L(C),e=Math.max(L(v)/2,t);let n=C[0],i=C[2];this.extendX_&&(n-=t,i+=t),v[0]=n-e,v[2]=i+e,Q(y,u);const r=j(S[0],u);r[0]<C[0]&&r[2]<C[2]?S.push([r[0]+t,r[1],r[2]+t,r[3]]):r[0]>C[0]&&r[2]>C[2]&&S.push([r[0]-t,r[1],r[2]-t,r[3]])}if(this.ready&&this.renderedResolution_==d&&this.renderedPixelRatio_===f&&this.renderedRevision_==p&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!t.declutter&&g(this.wrappedRenderedExtent_,v))return l(this.renderedExtent_,x)||(this.hitDetectionImageData_=null,this.renderedExtent_=x),this.renderedCenter_=y,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const I=new ui(gr(d,f),v,d,f),b=fe();let T;if(b){for(let t=0,e=S.length;t<e;++t){const e=me(S[t]);n.loadFeatures(e,ve(d),b)}T=le(b,u)}else for(let t=0,e=S.length;t<e;++t)n.loadFeatures(S[t],d,u);const E=dr(d,f);let P=!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,E,i,I,T,this.getLayer().getDeclutter(),n);P=P&&!e}},R=me(v),F=n.getFeaturesInExtent(R);m&&F.sort(m);for(let t=0,e=F.length;t<e;++t)M(F[t],t);this.renderedFeatures_=F,this.ready=P;const k=I.finish(),O=new qi(v,d,f,n.getOverlaps(),k,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=d,this.renderedRevision_=p,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=x,this.wrappedRenderedExtent_=v,this.renderedCenter_=y,this.renderedProjection_=u,this.renderedPixelRatio_=f,this.replayGroup_=O,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=fr(i,t,n[l],e,this.boundHandleStyleImageChange_,r,o,s)||a;else a=fr(i,t,n,e,this.boundHandleStyleImageChange_,r,o,s);return a}};function Cr(t,e,n=0,i=t.length-1,r=Ir){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);Cr(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(wr(t,n,e),r(t[i],o)>0&&wr(t,n,i);s<a;){for(wr(t,s,a),s++,a--;r(t[s],o)<0;)s++;for(;r(t[a],o)>0;)a--}0===r(t[n],o)?wr(t,n,a):(a++,wr(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function wr(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function Ir(t,e){return t<e?-1:t>e?1:0}class br{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(!Gr(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;Gr(t,a)&&(e.leaf?n.push(s):Dr(t,a)?this._all(s,n):r.push(s))}e=r.pop()}return n}collides(t){let e=this.data;if(!Gr(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(Gr(t,o)){if(e.leaf||Dr(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=jr([]),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=Tr(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!Dr(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=jr(t.slice(e,n+1)),Er(o,this.toBBox),o;i||(i=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,i-1))),o=jr([]),o.leaf=!1,o.height=i;const a=Math.ceil(r/s),l=a*Math.ceil(Math.sqrt(s));Vr(t,e,n,l,this.compareMinX);for(let r=e;r<=n;r+=l){const e=Math.min(r+l-1,n);Vr(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 Er(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=kr(s),l=Ar(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),Mr(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=jr(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,Er(n,this.toBBox),Er(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)}_splitRoot(t,e){this.data=jr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Er(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=Pr(t,0,s,this.toBBox),a=Pr(t,s,n,this.toBBox),l=Lr(e,a),h=kr(e)+kr(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:Rr,r=t.leaf?this.compareMinY:Fr;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=Pr(t,0,e,r),s=Pr(t,n-e,n,r);let a=Or(o)+Or(s);for(let i=e;i<n-e;i++){const e=t.children[i];Mr(o,t.leaf?r(e):e),a+=Or(o)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];Mr(s,t.leaf?r(e):e),a+=Or(s)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)Mr(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():Er(t[n],this.toBBox)}}function Tr(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 Er(t,e){Pr(t,0,t.children.length,e,t)}function Pr(t,e,n,i,r){r||(r=jr(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];Mr(r,t.leaf?i(e):e)}return r}function Mr(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 Rr(t,e){return t.minX-e.minX}function Fr(t,e){return t.minY-e.minY}function kr(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Or(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Ar(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 Lr(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 Dr(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Gr(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function jr(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Vr(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;Cr(t,s,e,n,r),o.push(e,s,s,n)}}let Wr=0;const Xr=1<<Wr++,Nr=1<<Wr++,Yr=1<<Wr++,Br=1<<Wr++,zr=1<<Wr++,Ur=1<<Wr++,qr=Math.pow(2,6)-1,Zr={[Xr]:"boolean",[Nr]:"number",[Yr]:"string",[Br]:"color",[zr]:"number[]",[Ur]:"size"},Kr=Object.keys(Zr).map(Number).sort(i);function Hr(t){const e=[];for(const n of Kr)$r(t,n)&&e.push(Zr[n]);return 0===e.length?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function $r(t,e){return(t&e)===e}function Jr(t,e){return t===e}class Qr{constructor(t,e){if(!function(t){return t in Zr}(t))throw new Error(`literal expressions must have a specific type, got ${Hr(t)}`);this.type=t,this.value=e}}class to{constructor(t,e,...n){this.type=t,this.operator=e,this.args=n}}function eo(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1}}function no(t,e,n){switch(typeof t){case"boolean":if(Jr(e,Yr))return new Qr(Yr,t?"true":"false");if(!$r(e,Xr))throw new Error(`got a boolean, but expected ${Hr(e)}`);return new Qr(Xr,t);case"number":if(Jr(e,Ur))return new Qr(Ur,Zi(t));if(Jr(e,Xr))return new Qr(Xr,!!t);if(Jr(e,Yr))return new Qr(Yr,t.toString());if(!$r(e,Nr))throw new Error(`got a number, but expected ${Hr(e)}`);return new Qr(Nr,t);case"string":if(Jr(e,Br))return new Qr(Br,Ne(t));if(Jr(e,Xr))return new Qr(Xr,!!t);if(!$r(e,Yr))throw new Error(`got a string, but expected ${Hr(e)}`);return new Qr(Yr,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=$o[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(Jr(e,Ur)){if(2!==t.length)throw new Error(`expected an array of two values for a size, got ${t.length}`);return new Qr(Ur,t)}if(Jr(e,Br)){if(3===t.length)return new Qr(Br,[...t,1]);if(4===t.length)return new Qr(Br,t);throw new Error(`expected an array of 3 or 4 values for a color, got ${t.length}`)}if(!$r(e,zr))throw new Error(`got an array of numbers, but expected ${Hr(e)}`);return new Qr(zr,t)}const io="get",ro="var",oo="concat",so="geometry-type",ao="line-metric",lo="any",ho="all",co="!",uo="resolution",go="zoom",fo="time",po="==",_o="!=",mo=">",yo=">=",vo="<",xo="<=",So="*",Co="/",wo="+",Io="-",bo="clamp",To="%",Eo="^",Po="abs",Mo="floor",Ro="ceil",Fo="round",ko="sin",Oo="cos",Ao="atan",Lo="sqrt",Do="match",Go="between",jo="interpolate",Vo="coalesce",Wo="case",Xo="in",No="number",Yo="string",Bo="array",zo="color",Uo="id",qo="band",Zo="palette",Ko="to-string",Ho="has",$o={[io]:os(es(1,1/0),Jo),[ro]:os(es(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 Qr(Yr,i)]}),[Ho]:os(es(1,1/0),Jo),[Uo]:os(function(t,e,n){n.featureId=!0},ts),[oo]:os(es(2,1/0),is(Yr)),[so]:os(function(t,e,n){n.geometryType=!0},ts),[ao]:os(function(t,e,n){n.mCoordinate=!0},ts),[uo]:os(Qo,ts),[go]:os(Qo,ts),[fo]:os(Qo,ts),[lo]:os(es(2,1/0),is(Xr)),[ho]:os(es(2,1/0),is(Xr)),[co]:os(es(1,1),is(Xr)),[po]:os(es(2,2),is(qr)),[_o]:os(es(2,2),is(qr)),[mo]:os(es(2,2),is(Nr)),[yo]:os(es(2,2),is(Nr)),[vo]:os(es(2,2),is(Nr)),[xo]:os(es(2,2),is(Nr)),[So]:os(es(2,1/0),ns),[Vo]:os(es(2,1/0),ns),[Co]:os(es(2,2),is(Nr)),[wo]:os(es(2,1/0),is(Nr)),[Io]:os(es(2,2),is(Nr)),[bo]:os(es(3,3),is(Nr)),[To]:os(es(2,2),is(Nr)),[Eo]:os(es(2,2),is(Nr)),[Po]:os(es(1,1),is(Nr)),[Mo]:os(es(1,1),is(Nr)),[Ro]:os(es(1,1),is(Nr)),[Fo]:os(es(1,1),is(Nr)),[ko]:os(es(1,1),is(Nr)),[Oo]:os(es(1,1),is(Nr)),[Ao]:os(es(1,2),is(Nr)),[Lo]:os(es(1,1),is(Nr)),[Do]:os(es(4,1/0),rs,function(t,e,n){const i=t.length-1,r=Yr|Nr|Xr,o=no(t[1],r,n),s=no(t[t.length-1],e,n),a=new Array(i-2);for(let e=0;e<i-2;e+=2){try{const i=no(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=no(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]}),[Go]:os(es(3,3),is(Nr)),[jo]:os(es(6,1/0),rs,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 Qr(Nr,r);let s;try{s=no(t[2],Nr,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=no(t[i+3],Nr,n);a[i]=e}catch(t){throw new Error(`failed to parse argument ${i+2} for interpolate expression: ${t.message}`)}try{const r=no(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]}),[Wo]:os(es(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=no(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=no(t[e+1],Xr,n);r[e]=i}catch(t){throw new Error(`failed to parse argument ${e} of case expression: ${t.message}`)}try{const o=no(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}),[Xo]:os(es(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]?Yr:Nr;const o=new Array(r.length);for(let t=0;t<o.length;t++)try{const e=no(r[t],i,n);o[t]=e}catch(e){throw new Error(`failed to parse haystack item ${t} for "in" expression: ${e.message}`)}return[no(t[1],i,n),...o]}),[No]:os(es(1,1/0),is(qr)),[Yo]:os(es(1,1/0),is(qr)),[Bo]:os(es(1,1/0),is(Nr)),[zo]:os(es(1,4),is(Nr)),[qo]:os(es(1,3),is(Nr)),[Zo]:os(es(2,2),function(t,e,n){let i;try{i=no(t[1],Nr,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=no(r[t],Br,n)}catch(e){throw new Error(`failed to parse color at index ${t} in palette expression: ${e.message}`)}if(!(e instanceof Qr))throw new Error(`the palette color at index ${t} must be a literal value`);o[t]=e}return[i,...o]}),[Ko]:os(es(1,1),is(Xr|Nr|Yr|Br))};function Jo(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 Qr(Nr,i);break;case"string":r[e]=new Qr(Yr,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 Qo(t,e,n){n.mapState=!0}function ts(t,e,n){const i=t[0];if(1!==t.length)throw new Error(`expected no arguments for ${i} operation`);return[]}function es(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 ns(t,e,n){const i=t.length-1,r=new Array(i);for(let o=0;o<i;++o){const i=no(t[o+1],e,n);r[o]=i}return r}function is(t){return function(e,n,i){const r=e.length-1,o=new Array(r);for(let n=0;n<r;++n){const r=no(e[n+1],t,i);o[n]=r}return o}}function rs(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 os(...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 to(n,r,...o)}}function ss(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 ss(t.getGeometries()[0]);default:return""}}function as(t,e,n){return ls(no(t,e,n),n)}function ls(t,e){if(t instanceof Qr){if(t.type===Br&&"string"==typeof t.value){const e=Ne(t.value);return function(){return e}}return function(){return t.value}}const n=t.operator;switch(n){case No:case Yo:case Vo: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]=ls(t.args[n],e);switch(n){case Vo: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 No:case Yo: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 io:case ro:case Ho:return function(t){const e=t.args[0].value;switch(t.operator){case io: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 ro:return t=>t.variables[e];case Ho: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 so:return t=>t.geometryType;case oo:{const n=t.args.map(t=>ls(t,e));return t=>"".concat(...n.map(e=>e(t).toString()))}case uo:return t=>t.resolution;case lo:case ho:case Go:case Xo: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]=ls(t.args[n],e);switch(n){case lo:return t=>{for(let e=0;e<i;++e)if(r[e](t))return!0;return!1};case ho:return t=>{for(let e=0;e<i;++e)if(!r[e](t))return!1;return!0};case Go:return t=>{const e=r[0](t),n=r[1](t),i=r[2](t);return e>=n&&e<=i};case Xo: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 po:case _o:case"<":case xo:case">":case yo:return function(t,e){const n=t.operator,i=ls(t.args[0],e),r=ls(t.args[1],e);switch(n){case po:return t=>i(t)===r(t);case _o:return t=>i(t)!==r(t);case"<":return t=>i(t)<r(t);case xo:return t=>i(t)<=r(t);case">":return t=>i(t)>r(t);case yo:return t=>i(t)>=r(t);default:throw new Error(`Unsupported comparison operator ${n}`)}}(t,e);case"*":case"/":case"+":case"-":case bo:case"%":case"^":case Po:case Mo:case Ro:case Fo:case ko:case Oo:case Ao:case Lo: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]=ls(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 bo: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 Po:return t=>Math.abs(r[0](t));case Mo:return t=>Math.floor(r[0](t));case Ro:return t=>Math.ceil(r[0](t));case Fo:return t=>Math.round(r[0](t));case ko:return t=>Math.sin(r[0](t));case Oo:return t=>Math.cos(r[0](t));case Ao:return 2===i?t=>Math.atan2(r[0](t),r[1](t)):t=>Math.atan(r[0](t));case Lo:return t=>Math.sqrt(r[0](t));default:throw new Error(`Unsupported numeric operator ${n}`)}}(t,e);case Wo:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=ls(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 Do:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=ls(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 jo:return function(t,e){const n=t.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=ls(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=De(l)),n>=r)return 2===a?l:h?cs(e,r,o,s,n,l):hs(e,r,o,s,n,l);o=n,s=l}return s}}(t,e);case Ko: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]=ls(t.args[n],e);if(n===Ko)return e=>{const n=r[0](e);return t.args[0].type===Br?Be(n):n.toString()};throw new Error(`Unsupported convert operator ${n}`)}(t,e);default:throw new Error(`Unsupported operator ${n}`)}}function hs(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 cs(t,e,n,i,r,o){if(0===r-n)return i;const s=Xe(i),a=Xe(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=je(e),o=je(e+n/500*Math.cos(i)),s=je(e-n/200*Math.sin(i)),a=Ge(3.021973625*o-1.617392459*r-.404875592*s),l=Ge(-.943766287*o+1.916279586*r+.027607165*s),h=Ge(.069407491*o-.22898585*r+1.159737864*s);return[W(a+.5|0,0,255),W(l+.5|0,0,255),W(h+.5|0,0,255),t[3]]}([hs(t,e,n,s[0],r,a[0]),hs(t,e,n,s[1],r,a[1]),s[2]+hs(t,e,n,0,r,l),hs(t,e,n,i[3],r,o[3])])}class us extends Hi{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 us({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=sn.get(n,null)?.getImage(1);if(!i){const e=this.renderOptions_,r=Math.ceil(e.size*t),o=it(r,r);this.draw_(e,o,t),i=o.canvas;const s=new cn(i,void 0,null,2,null);sn.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),g=Math.sqrt((i+u)*(i+u)+d*d)-i;if(void 0===this.radius2_||"bevel"===t)return 2*g;const f=i*Math.sin(s),p=r-Math.sqrt(i*i-f*f),_=Math.sqrt(f*f+p*p)/f;if(_<=n){const t=_*e/2-r-i;return 2*Math.max(g,t)}return 2*g}createRenderOptions(){let t,e=Rn,n=kn,i=0,r=null,o=0,s=0;this.stroke_&&(t=un(this.stroke_.getColor()??On),s=this.stroke_.getWidth()??1,r=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset()??0,n=this.stroke_.getLineJoin()??kn,e=this.stroke_.getLineCap()??Rn,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=Mn),e.fillStyle=un(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=Ye(n)),null===n?i=1:Array.isArray(n)&&(i=4===n.length?n[3]:1),0===i&&(e=it(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=Mn,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 ds=us;class gs extends ds{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 gs({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 fs=gs;class ps{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 ps({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=hn(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?Sn(t):"object"==typeof t&&"src"in t?t.src+":"+t.offset:Ye(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}const _s=ps;class ms{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 ms({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 ys=ms;class vs{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=ws,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 vs({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_=ws,this.geometry_=t}setZIndex(t){this.zIndex_=t}}let xs=null;function Ss(t,e){if(!xs){const t=new _s({color:"rgba(255,255,255,0.4)"}),e=new ys({color:"#3399CC",width:1.25});xs=[new vs({image:new fs({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return xs}function Cs(){const t={},e=[255,255,255,1],n=[0,153,255,1];return t.Polygon=[new vs({fill:new _s({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new vs({stroke:new ys({color:e,width:5})}),new vs({stroke:new ys({color:n,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new vs({image:new fs({radius:6,fill:new _s({color:n}),stroke:new ys({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function ws(t){return t.getGeometry()}const Is=vs;class bs{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_=Zi(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 _s({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 bs({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 _s?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_=Zi(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 Ts=bs;function Es(t){return!0}function Ps(t){const e=eo(),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?as(n.filter,Xr,e):Es;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]=Rs(n.style[i],e)}else s=[Rs(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=ss(t.getGeometry())),n(i)}}function Ms(t){const e=eo(),n=t.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=Rs(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 Rs(t,e){const n=Fs(t,"",e),i=ks(t,"",e),r=function(t,e){const n="text-",i=Ls(t,n+"value",e);if(!i)return null;const r=Fs(t,n,e),o=Fs(t,n+"background-",e),s=ks(t,n,e),a=ks(t,n+"background-",e),l=Ls(t,n+"font",e),h=As(t,n+"max-angle",e),c=As(t,n+"offset-x",e),u=As(t,n+"offset-y",e),d=Ds(t,n+"overflow",e),g=Ls(t,n+"placement",e),f=As(t,n+"repeat",e),p=Xs(t,n+"scale",e),_=Ds(t,n+"rotate-with-view",e),m=As(t,n+"rotation",e),y=Ls(t,n+"align",e),v=Ls(t,n+"justify",e),x=Ls(t,n+"baseline",e),S=Ds(t,n+"keep-upright",e),C=js(t,n+"padding",e),w=zs(t,n+"declutter-mode"),I=new Ts({declutterMode:w});return function(t){if(I.setText(i(t)),r&&I.setFill(r(t)),o&&I.setBackgroundFill(o(t)),s&&I.setStroke(s(t)),a&&I.setBackgroundStroke(a(t)),l&&I.setFont(l(t)),h&&I.setMaxAngle(h(t)),c&&I.setOffsetX(c(t)),u&&I.setOffsetY(u(t)),d&&I.setOverflow(d(t)),g){const e=g(t);if("point"!==e&&"line"!==e)throw new Error("Expected point or line for text-placement");I.setPlacement(e)}if(f&&I.setRepeat(f(t)),p&&I.setScale(p(t)),_&&I.setRotateWithView(_(t)),m&&I.setRotation(m(t)),y){const e=y(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");I.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");I.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");I.setTextBaseline(e)}return C&&I.setPadding(C(t)),S&&I.setKeepUpright(S(t)),I}}(t,e),o=function(t,e){return"icon-src"in t?function(t,e){const n="icon-",i=n+"src",r=qs(t[i],i),o=Vs(t,n+"anchor",e),s=Xs(t,n+"scale",e),a=As(t,n+"opacity",e),l=Vs(t,n+"displacement",e),h=As(t,n+"rotation",e),c=Ds(t,n+"rotate-with-view",e),u=Ys(t,n+"anchor-origin"),d=Bs(t,n+"anchor-x-units"),g=Bs(t,n+"anchor-y-units"),f=Os(t,n+"color");let p,_=null;void 0!==f&&(Array.isArray(f)&&f.length>0&&"string"==typeof f[0]?_=Gs(t,n+"color",e):p=Ks(f,n+"color"));const m=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"),y=function(t,e){const n=t[e];if(void 0!==n)return Us(n,e)}(t,n+"offset"),v=Ys(t,n+"offset-origin"),x=Ns(t,n+"width"),S=Ns(t,n+"height"),C=function(t,e){const n=t[e];if(void 0!==n){if("number"==typeof n)return Zi(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"),w={src:r,anchorOrigin:u,anchorXUnits:d,anchorYUnits:g,crossOrigin:m,offset:y,offsetOrigin:v,height:S,width:x,size:C,declutterMode:zs(t,n+"declutter-mode")};let I=null;return function(t){if(I)_&&I.setColor(_(t));else{const e=_?_(t):p;I=new Qi(void 0!==e?Object.assign({},w,{color:e}):Object.assign({},w))}return a&&I.setOpacity(a(t)),l&&I.setDisplacement(l(t)),h&&I.setRotation(h(t)),c&&I.setRotateWithView(c(t)),s&&I.setScale(s(t)),o&&I.setAnchor(o(t)),I}}(t,e):"shape-points"in t?function(t,e){const n="shape-",i=n+"points",r=n+"radius",o=Zs(t[i],i);if(!(r in t))throw new Error(`Expected a number for ${r}`);const s=As(t,r,e),a="number"==typeof t[r]?t[r]:5,l=n+"radius2",h=As(t,l,e),c="number"==typeof t[l]?t[l]:void 0,u=Fs(t,n,e),d=ks(t,n,e),g=Xs(t,n+"scale",e),f=Vs(t,n+"displacement",e),p=As(t,n+"rotation",e),_=Ds(t,n+"rotate-with-view",e),m=Ns(t,n+"angle"),y=zs(t,n+"declutter-mode"),v=new ds({points:o,radius:a,radius2:c,angle:m,declutterMode:y});return function(t){return s&&v.setRadius(s(t)),h&&v.setRadius2(h(t)),u&&v.setFill(u(t)),d&&v.setStroke(d(t)),f&&v.setDisplacement(f(t)),p&&v.setRotation(p(t)),_&&v.setRotateWithView(_(t)),g&&v.setScale(g(t)),v}}(t,e):"circle-radius"in t?function(t,e){const n="circle-",i=Fs(t,n,e),r=ks(t,n,e),o=As(t,n+"radius",e),s=Xs(t,n+"scale",e),a=Vs(t,n+"displacement",e),l=As(t,n+"rotation",e),h=Ds(t,n+"rotate-with-view",e),c=zs(t,n+"declutter-mode"),u=new fs({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=As(t,"z-index",e);if(!(n||i||r||o||Ue(t)))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(t));const a=new Is;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 Fs(t,e,n){let i;if(e+"fill-pattern-src"in t)i=function(t,e,n){const i=Ls(t,e+"pattern-src",n),r=Ws(t,e+"pattern-offset",n),o=Ws(t,e+"pattern-size",n),s=Gs(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=Gs(t,e+"fill-color",n)}if(!i)return null;const r=new _s;return function(t){const e=i(t);return e===be?null:(r.setColor(e),r)}}function ks(t,e,n){const i=As(t,e+"stroke-width",n),r=Gs(t,e+"stroke-color",n);if(!i&&!r)return null;const o=Ls(t,e+"stroke-line-cap",n),s=Ls(t,e+"stroke-line-join",n),a=js(t,e+"stroke-line-dash",n),l=As(t,e+"stroke-line-dash-offset",n),h=As(t,e+"stroke-miter-limit",n),c=As(t,e+"stroke-offset",n),u=new ys;return function(t){if(r){const e=r(t);if(e===be)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 Os(t,e){if(!(e in t))return;const n=t[e];return void 0===n?void 0:n}function As(t,e,n){const i=Os(t,e);if(void 0===i)return;const r=as(i,Nr,n);return function(t){return Zs(r(t),e)}}function Ls(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,Yr,n);return function(t){return qs(r(t),e)}}function Ds(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,Xr,n);return function(t){const n=r(t);if("boolean"!=typeof n)throw new Error(`Expected a boolean for ${e}`);return n}}function Gs(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,Br,n);return function(t){return Ks(r(t),e)}}function js(t,e,n){const i=Os(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=as(t,Nr,n);return function(t){return Zs(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=as(i,zr,n);return function(t){return Us(r(t),e)}}function Vs(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,zr,n);return function(t){const n=Us(r(t),e);if(2!==n.length)throw new Error(`Expected two numbers for ${e}`);return n}}function Ws(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,zr,n);return function(t){return Hs(r(t),e)}}function Xs(t,e,n){const i=Os(t,e);if(void 0===i)return null;const r=as(i,zr|Nr,n);return function(t){return n=r(t),i=e,"number"==typeof n?n:Hs(n,i);var n,i}}function Ns(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 Ys(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 Bs(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 zs(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 Us(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 qs(t,e){if("string"!=typeof t)throw new Error(`Expected a string for ${e}`);return t}function Zs(t,e){if("number"!=typeof t)throw new Error(`Expected a number for ${e}`);return t}function Ks(t,e){if("string"==typeof t)return t;const n=Us(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 Hs(t,e){const n=Us(t,e);if(2!==n.length)throw new Error(`Expected an array of two numbers for ${e}`);return n}const $s={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Js(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,g=t[2]-l/2+c,f=t[1]+h/2+u,p=t[3]-h/2+u;d>g&&(d=(g+d)/2,g=d),f>p&&(f=(p+f)/2,p=f);let _=W(i[0],d,g),m=W(i[1],f,p);if(s&&n&&r){const t=30*r;_+=-t*Math.log(1+Math.max(0,d-i[0])/t)+t*Math.log(1+Math.max(0,i[0]-g)/t),m+=-t*Math.log(1+Math.max(0,f-i[1])/t)+t*Math.log(1+Math.max(0,i[1]-p)/t)}return[_,m]}}function Qs(t){return t}function ta(t){return Math.pow(t,3)}function ea(t){return 1-ta(1-t)}function na(t){return 3*t*t-2*t*t*t}function ia(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 ra(t,e,n,i){let r=0;for(let o=0,s=n.length;o<s;++o){const s=n[o];r+=ia(t,e,s,i),e=s}return r}function oa(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]=U(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 sa(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=N(o,s,n,i);a>r&&(r=a),o=n,s=i}return r}function aa(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];r=sa(t,e,s,i,r),e=s}return r}function la(t,e,n,i,r,o,s,a,l,h,c){if(e==n)return h;let u,d;if(0===r){if(d=N(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 g=e+i;for(;g<n;)if(oa(t,g-i,g,i,s,a,c),d=N(s,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,g+=i}else g+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/r|0,1);if(o&&(oa(t,n-i,e,i,s,a,c),d=N(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 ha(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=la(t,e,d,i,r,o,s,a,l,h,c),e=d}return h}function ca(t,e,n,i){for(let i=0,r=n.length;i<r;++i)t[e++]=n[i];return e}function ua(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 da(t,e,n,i,r){r=r||[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=ua(t,e,n[s],i);r[o++]=a,e=a}return r.length=o,r}function ga(t,e,n,i,r){r=r||[];let o=0;for(let s=0,a=n.length;s<a;++s){const a=da(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 fa extends or{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 fa(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(sa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),la(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,n,i))}getArea(){return ia(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return dn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=ei(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new fa(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ua(this.flatCoordinates,0,t,this.stride),this.changed()}}const pa=fa;class _a extends or{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new _a(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){const r=this.flatCoordinates,o=N(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 y(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return f(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ca(this.flatCoordinates,0,t,this.stride),this.changed()}}const ma=_a;function ya(t,e,n,i,r){return!b(r,function(r){return!va(t,e,n,i,r[0],r[1])})}function va(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 xa(t,e,n,i,r,o){if(0===n.length)return!1;if(!va(t,e,n[0],i,r,o))return!1;for(let e=1,s=n.length;e<s;++e)if(va(t,n[e-1],n[e],i,r,o))return!1;return!0}function Sa(t,e,n,r,o,s,a){let l,h,c,u,d,g,f;const p=o[s+1],_=[];for(let i=0,o=n.length;i<o;++i){const o=n[i];for(u=t[o-r],g=t[o-r+1],l=e;l<o;l+=r)d=t[l],f=t[l+1],(p<=g&&f<=p||g<=p&&p<=f)&&(c=(p-g)/(f-g)*(d-u)+u,_.push(c)),u=d,g=f}let m=NaN,y=-1/0;for(_.sort(i),u=_[0],l=1,h=_.length;l<h;++l){d=_[l];const i=Math.abs(d-u);i>y&&(c=(u+d)/2,xa(t,e,n,r,c,p)&&(m=c,y=i)),u=d}return isNaN(m)&&(m=o[s]),a?(a.push(m,p,y),a):[m,p,y]}function Ca(t,e,n,i,r){let o=[];for(let s=0,a=n.length;s<a;++s){const a=n[s];o=Sa(t,e,a,i,r,2*s,o),e=a[a.length-1]}return o}function wa(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 Ia(t,e,n,i,r,o){return o=o??w([1/0,1/0,-1/0,-1/0],t,e,n,i),!!D(r,o)&&(o[0]>=r[0]&&o[2]<=r[2]||o[1]>=r[1]&&o[3]<=r[3]||wa(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],g=n[1],f=(g-u)/(d-c);let p,_;2&o&&!(2&r)&&(p=d-(g-h)/f,i=p>=s&&p<=l),i||!(4&o)||4&r||(_=g-(d-l)*f,i=_>=a&&_<=h),i||!(8&o)||8&r||(p=d-(g-a)/f,i=p>=s&&p<=l),i||!(16&o)||16&r||(_=g-(d-s)*f,i=_>=a&&_<=h)}return i}(r,t,e)}))}function ba(t,e,n,i,r){if(!function(t,e,n,i,r){return!!(Ia(t,e,n,i,r)||va(t,e,n,i,r[0],r[1])||va(t,e,n,i,r[0],r[3])||va(t,e,n,i,r[2],r[1])||va(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(ya(t,n[e-1],n[e],i,r)&&!Ia(t,n[e-1],n[e],i,r))return!1;return!0}function Ta(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 Ea(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 Pa(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=Ea(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 Ma(t,e,n,i,r){for(let o=0,s=n.length;o<s;++o){const s=n[o];if(!Pa(t,e,s,i,r))return!1;s.length&&(e=s[s.length-1])}return!0}function Ra(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=Ea(t,e,s,i);(0===o?r&&a||!r&&!a:r&&!a||!r&&a)&&Ta(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=Ra(t,e,n[o],i,r);return e}class ka extends or{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 ka(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(aa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ha(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,n,i))}containsXY(t,e){return xa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return ra(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),Ra(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,gn(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=M(this.getExtent());this.flatInteriorPoint_=Sa(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new ma(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new pa(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 pa(e.slice(r,s),t);i.push(a),r=s}return i}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Pa(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Ra(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=oi(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,n),new ka(e,"XY",n)}getType(){return"Polygon"}intersectsExtent(t){return ba(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=da(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}const Oa=ka;function Aa(t){if(G(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 ka(o,"XY",[o.length])}function La(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 ka(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*z(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 Da(t,e,n,i){const r=L(e)/n[0],o=F(e)/n[1];return i?Math.min(t,Math.max(r,o)):Math.min(t,Math.min(r,o))}function Ga(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),W(i,n/2,2*e)}function ja(t,e,n,i,r){return n=void 0===n||n,function(o,s,a,l){if(void 0!==o){const s=i?Da(t,i,a,r):t;return n&&l?Ga(o,s,e):W(o,e,s)}}}function Va(t){if(void 0!==t)return 0}function Wa(t){if(void 0!==t)return t}function Xa(t,e){setTimeout(function(){t(e)},0)}function Na(t){return!(t.sourceCenter&&t.targetCenter&&!H(t.sourceCenter,t.targetCenter))&&t.sourceResolution===t.targetResolution&&t.sourceRotation===t.targetRotation}function Ya(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 Ba=class extends wn{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=se(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){te=!(void 0===t||t)}(),t.center&&(t.center=_e(t.center,this.projection_)),t.extent&&(t.extent=ye(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const t in $s)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=se(t.projection,"EPSG:3857"),d=u.getExtent();let g=t.constrainOnlyCenter,f=t.extent;if(l||f||!u.isGlobal()||(g=!1,f=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?Da(h,n,a,i):h;if(l)return e?Ga(r,u,c):W(r,c,u);const d=Math.min(u,r),g=Math.floor(o(t,d,s));return t[g]>u&&g<t.length-1?t[g+1]:t[g]}}}(a,h,!g&&f,c):ja(n,i,h,!g&&f,c)}else{const o=(d?Math.max(L(d),F(d)):360*ht.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?Da(e,r,l,o):e;if(h)return i?Ga(s,c,n):W(s,n,c);const u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(t)-u),g=-a*(.5-u)+.5,f=Math.min(c,s),p=Math.floor(Math.log(e/f)/Math.log(t)+g),_=Math.max(d,p);return W(e/Math.pow(t,_),n,c)}}}(a,n,i,h,!g&&f,c):ja(n,i,h,!g&&f,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 Js(t.extent,t.constrainOnlyCenter,e)}const e=se(t.projection,"EPSG:3857");if(!0!==t.multiWorld&&e.isGlobal()){const t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,Js(t,!1,!1)}return Qs}(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=B(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 Va}(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=_e(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=_e(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&&Xa(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||na,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=z(t.rotation-a+Math.PI,2*Math.PI)-Math.PI;n.targetRotation=a+e,a=n.targetRotation}Na(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&&Xa(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?z(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&&Xa(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?pe(t,this.getProjection()):t}getCenterInternal(){return this.get($s.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 me(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();fi(e,"The view center is not defined");const n=this.getResolution();fi(void 0!==n,"The view resolution is not defined");const i=this.getRotation();return fi(void 0!==i,"The view rotation is not defined"),function(t,e,n,i){const[r,o,s,a,l,h,c,u]=R(t,e,n,i);return _(Math.min(r,s,l,c),Math.min(o,a,h,u),Math.max(r,s,l,c),Math.max(o,a,h,u),void 0)}(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($s.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(ye(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const n=L(t)/e[0],i=F(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($s.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=Ya(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=W(Math.floor(t),0,this.resolutions_.length-2),n=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(n,W(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let n;if(fi(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t))fi(!G(t),"Cannot fit empty extent provided as `geometry`"),n=Aa(ye(t,this.getProjection()));else if("Circle"===t.getType()){const e=ye(t.getExtent(),this.getProjection());n=Aa(e),n.rotate(this.getRotation(),M(e))}else{const e=fe();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=M(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,g=u[1]*c+u[0]*h,f=this.getConstrainedCenter([d,g],a),p=e.callback?e.callback:tn;void 0!==e.duration?this.animateInternal({resolution:a,center:f,duration:e.duration,easing:e.easing},p):(this.targetResolution_=a,this.targetCenter_=f,this.applyTargetState_(!1,!0),Xa(p,!0))}centerOn(t,e,n){this.centerOnInternal(_e(t,this.getProjection()),e,n)}centerOnInternal(t,e,n){this.setCenterInternal(Ya(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=Ya(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=pe(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&&_e(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=_e(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?_e(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($s.ROTATION)!==i&&this.set($s.ROTATION,i),this.get($s.RESOLUTION)!==o&&(this.set($s.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),s&&this.get($s.CENTER)&&H(this.get($s.CENTER),s)||this.set($s.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()&&H(this.getCenterInternal(),a)||(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:a,resolution:s,duration:t,easing:ea,anchor:n}))}beginInteraction(){this.resolveConstraints(0),this.setHint(1,1)}endInteraction(t,e,n){n=n&&_e(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)}},za="opacity",Ua="visible",qa="extent",Za="zIndex",Ka="maxResolution",Ha="minResolution",$a="maxZoom",Ja="minZoom",Qa="source",tl=class extends wn{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[za]=void 0!==t.opacity?t.opacity:1,fi("number"==typeof e[za],"Layer opacity must be a number"),e[Ua]=void 0===t.visible||t.visible,e[Za]=t.zIndex,e[Ka]=void 0!==t.maxResolution?t.maxResolution:1/0,e[Ha]=void 0!==t.minResolution?t.minResolution:0,e[Ja]=void 0!==t.minZoom?t.minZoom:-1/0,e[$a]=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=W(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 vn()}getLayerStatesArray(t){return vn()}getExtent(){return this.get(qa)}getMaxResolution(){return this.get(Ka)}getMinResolution(){return this.get(Ha)}getMinZoom(){return this.get(Ja)}getMaxZoom(){return this.get($a)}getOpacity(){return this.get(za)}getSourceState(){return vn()}getVisible(){return this.get(Ua)}getZIndex(){return this.get(Za)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(qa,t)}setMaxResolution(t){this.set(Ka,t)}setMinResolution(t){this.set(Ha,t)}setMaxZoom(t){this.set($a,t)}setMinZoom(t){this.set(Ja,t)}setOpacity(t){fi("number"==typeof t,"Layer opacity must be a number"),this.set(za,t)}setVisible(t){this.set(Ua,t)}setZIndex(t){this.set(Za,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},el=class extends tl{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(Qa,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(Qa)||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_&&(Ke(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=qe(t,He,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 Ba?{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||D(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let n=e(t instanceof Ba?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_&&(Ke(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(Ke(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=qe(t,"precompose",this.handlePrecompose_,this),this.mapRenderKey_=qe(this,He,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,n=this.getLayerState(!1);fi(!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(Qa,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()}},nl="renderOrder",il=class extends el{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(nl)}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 br(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(nl,t)}setStyle(t){this.style_=void 0===t?Ss:t;const e=function(t){if(void 0===t)return Ss;if(!t)return null;if("function"==typeof t)return t;if(t instanceof Is)return t;if(!Array.isArray(t))return Ms([t]);if(0===t.length)return[];const e=t.length,n=t[0];if(n instanceof Is){const n=new Array(e);for(let i=0;i<e;++i){const e=t[i];if(!(e instanceof Is))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 Ps(n)}return Ms(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:(fi("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()}},rl=class extends il{constructor(t){super(t)}createRenderer(){return new Sr(this)}},ol="add",sl="remove",al="length";class ll extends nn{constructor(t,e,n){super(t),this.element=e,this.index=n}}const hl=class extends wn{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(al)}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 ll(ol,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 ll(sl,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 ll(sl,n,t)),this.dispatchEvent(new ll(ol,e,t))}updateLength_(){this.set(al,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 cl(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 ul(t,e){return[[-1/0,-1/0,1/0,1/0]]}function dl(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 gl(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,g=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);g<0?(h=(d-u[-g-2])/(u[-g-1]-u[-g-2]),l=e+(-g-2)*r):l=e+g*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]:U(t[l+e],t[l+r+e],h);return s}function fl(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(U(t[(a-1)*i+e],t[a*i+e],c));return s.push(r),s}const pl=[1,0,0,1,0,0];class _l{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_?y(this.flatCoordinates_):v(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=M(this.getExtent());this.flatInteriorPoints_=Sa(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=Ea(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=dl(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=Ca(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=gl(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=gl(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=ie(t)).getExtent(),n=t.getWorldExtent();if(e&&n){const t=F(n)/F(e);Si(pl,n[0],n[3],t,-t,0,0,0),di(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,pl,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new _l(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=en((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=ei(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,n,0),i=[n.length];break;case"MultiLineString":i=[],n.length=ni(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,n,0,i);break;case"Polygon":i=[],n.length=oi(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),n,0,i)}return i&&(this.simplifiedGeometry_=new _l(this.type_,n,i,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}_l.prototype.getFlatCoordinates=_l.prototype.getOrientedFlatCoordinates;const ml=_l,yl=class{constructor(t){this.rbush_=new br(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_[Sn(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_[Sn(o)]=s}this.rbush_.load(n)}remove(t){const e=Sn(t),n=this.items_[e];return delete this.items_[e],null!==this.rbush_.remove(n)}update(t,e){const n=this.items_[Sn(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 Ue(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return _(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 vl(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),e=>t):null}const xl=class extends wn{constructor(t){super(),this.projection=ie(t.projection),this.attributions_=vl(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_=vl(t),this.changed()}setState(t){this.state_=t,this.changed()}},Sl="addfeature",Cl="removefeature";class wl extends nn{constructor(t,e,n){super(t),this.feature=e,this.features=n}}const Il=class extends xl{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_=tn,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_&&(fi(this.format_,"`format` must be set when `url` is set"),this.loader_=cl(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:ul;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let n,i;this.featuresRtree_=e?new yl:null,this.loadedExtentsRtree_=new yl,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 hl(i)),void 0!==i&&this.addFeaturesInternal(i),void 0!==n&&this.bindFeaturesCollection_(n)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=Sn(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 wl(Sl,t))}setupChangeEvents_(t,e){e instanceof ml||(this.featureChangeKeys_[t]=[qe(e,He,this.handleFeatureChange_,this),qe(e,_n,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 ml){const i=this.idIndex_[t];i instanceof ml?Array.isArray(i)?i.push(e):this.idIndex_[t]=[i,e]:n=!1}else n=!1;else this.idIndex_[t]=e}return n&&(fi(!(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=Sn(i);this.addToIndex_(r,i)&&n.push(i)}for(let t=0,r=n.length;t<r;t++){const r=n[t],o=Sn(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(Sl))for(let t=0,e=n.length;t<e;t++)this.dispatchEvent(new wl(Sl,n[t]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(Sl,function(n){e||(e=!0,t.push(n.feature),e=!1)}),this.addEventListener(Cl,function(n){e||(e=!0,t.remove(n.feature),e=!1)}),t.addEventListener(ol,t=>{e||(e=!0,this.addFeature(t.element),e=!1)}),t.addEventListener(sl,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(Ke);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 wl("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 ml||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 ml||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(),Ue(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=V(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||Je,this.featuresRtree_.forEachInExtent(a,function(t){if(e(t)){const e=t.getGeometry(),l=s;if(s=e instanceof ml?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=Sn(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 wl("changefeature",e))}hasFeature(t){const e=t.getId();return void 0!==e?e in this.idIndex_:Sn(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Ue(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 g(t.extent,o)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new wl("featuresloadstart"));const t=t=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new wl("featuresloadend",void 0,t))},r=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new wl("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=Sn(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(Ke),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(Cl)&&this.dispatchEvent(new wl(Cl,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){fi(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(cl(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}};class bl extends wn{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 bl,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_&&(Ke(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=qe(t,He,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:(fi("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 Tl=bl;class El extends nr{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(Ke),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,n=t.length;e<n;++e)this.changeEventsKeys_.push(qe(t[e],He,this.changed,this))}clone(){const t=new El(Pl(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){m(t);const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)S(t,e[n].getExtent());return t}getGeometries(){return Pl(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 El(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=M(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(Pl(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 Pl(t){return t.map(t=>t.clone())}const Ml=El;class Rl extends or{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 Rl(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(sa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),la(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,n,i))}forEachSegment(t){return wa(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,fl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return dn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return gl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return Ii(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=ei(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Rl(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return Ia(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=ua(this.flatCoordinates,0,t,this.stride),this.changed()}}const Fl=Rl;class kl extends or{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 kl(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(aa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ha(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 fl(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 fl(t,e,s,i,r,!1);e=s}}return null}(this.flatCoordinates,0,this.ends_,this.stride,t,e,n))}getCoordinates(){return gn(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+=Ii(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,gl(e,n,s,r,.5)),n=s}return t}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=ni(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,n),new kl(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(Ia(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=da(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}const Ol=kl;class Al extends or{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 Al(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=N(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 dn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new ma(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 ma(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(f(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=ua(this.flatCoordinates,0,t,this.stride),this.changed()}}const Ll=Al;class Dl extends or{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 Dl(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=aa(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=ha(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(xa(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+=ra(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,fn(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=dl(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Ca(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new Ll(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Ma(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=oi(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 Dl(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 Oa(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 Oa(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(ba(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=ga(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 Gl=Dl,jl=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=Tl,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let n=e.dataProjection?ie(e.dataProjection):this.readProjection(t);e.extent&&n&&"tile-pixels"===n.getUnits()&&(n=ie(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 vn()}readFeature(t,e){return vn()}readFeatures(t,e){return vn()}readGeometry(t,e){return vn()}readProjection(t){return vn()}writeFeature(t,e){return vn()}writeFeatures(t,e){return vn()}writeGeometry(t,e){return vn()}};function Vl(t,e,n){const i=n?ie(n.featureProjection):null,r=n?ie(n.dataProjection):null;let o=t;if(i&&r&&!ae(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(ce(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:ma,LineString:Fl,Polygon:Oa,MultiPoint:Ll,MultiLineString:Ol,MultiPolygon:Gl};function Xl(t,e){const n=t.geometry;if(!n)return[];if(Array.isArray(n))return n.map(e=>Xl({...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 Vl(new ml(i,"Polygon"===i?function(t,e,n){return Array.isArray(e[0])?(Ma(t,0,e,n)||Fa(t=t.slice(),0,e,n),t):(Pa(t,0,e,n)||Ra(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 Nl(t,e){if(!t)return null;if(Array.isArray(t)){const n=t.map(t=>Nl(t,e));return new Ml(n)}return Vl(new(0,Wl[t.type])(t.flatCoordinates,t.layout||"XY",t.ends),!1,e)}function Yl(t){if("string"==typeof t){return JSON.parse(t)||null}return null!==t?t:null}const Bl=class extends jl{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Yl(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Yl(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return vn()}readFeaturesFromObject(t,e){return vn()}readGeometry(t,e){return this.readGeometryFromObject(Yl(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return vn()}readProjection(t){return this.readProjectionFromObject(Yl(t))}readProjectionFromObject(t){return vn()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return vn()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return vn()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return vn()}};function zl(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:ir(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:ir(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:da(n,0,e,i),layout:ir(i)}}(t);break;case"MultiPoint":n=function(t){const e=t.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:ir(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:da(i,0,e,n),layout:ir(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:ga(n,0,e,i),layout:ir(i)}}(t);break;case"GeometryCollection":n=function(t){const e=t.geometries.map(function(t){return zl(t)});return e}(t);break;default:throw new Error("Unsupported GeoJSON type: "+t.type)}return n}function Ul(t,e){const n=(t=Vl(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 Ul(t,e)})}}(t,e);break;case"Circle":i={type:"GeometryCollection",geometries:[]};break;default:throw new Error("Unsupported geometry type: "+n)}return i}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 Zl="EPSG:27700",Kl=new class extends Bl{constructor(t){t=t||{},super(),this.dataProjection=ie(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=ie(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=zl(n.geometry);if(this.featureClass===ml)return Xl({geometry:i,id:n.id,properties:n.properties},e);const r=new Tl;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&r.setGeometryName(n.geometry_name),r.setGeometry(Nl(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 Nl(zl(t),e)}(t,e)}readProjectionFromObject(t){const e=t.crs;let n;if(e)if("name"==e.type)n=ie(e.properties.name);else{if("EPSG"!==e.type)throw new Error("Unknown SRS type");n=ie("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=Ul(o,e),delete r[t.getGeometryName()]),Ue(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 Ul(t,this.adaptOptions(e))}}({dataProjection:Zl,featureProjection:Zl}),Hl=n(610),$l=n(682),Jl={Polygon:2,LineString:1},Ql=function(t){var e,n=t.getType();return("Polygon"===n?null!==(e=t.getCoordinates()[0])&&void 0!==e?e:[]:t.getCoordinates()).slice(0,-Jl[n])},th=function(t){var e;return null!==(e=Ql(t).at(-1))&&void 0!==e?e:null};function eh(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 nh={outer:$l.F0.vertexHaloRadius+3,mid:$l.F0.vertexHaloRadius,inner:$l.F0.vertexRadius},ih={outer:$l.F0.midpointHaloRadius+3,mid:$l.F0.midpointHaloRadius,inner:$l.F0.midpointRadius},rh=function(t,e,n,i,r){t.beginPath(),t.arc(e,n,i,0,2*Math.PI),t.fillStyle=r,t.fill()},oh=function(t,e,n){var i=t.outer,r=t.mid,o=t.inner;return function(t,s){var a,l,h=s.context,c=s.pixelRatio,u=(l=2,function(t){if(Array.isArray(t))return t}(a=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}}(a,l)||function(t,e){if(t){if("string"==typeof t)return eh(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)?eh(t,e):void 0}}(a,l)||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.")}()),d=u[0],g=u[1];h.save(),rh(h,d,g,i*c,e.editActive),rh(h,d,g,r*c,e.editHalo),rh(h,d,g,o*c,e[n]),h.restore()}},sh=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},ah=function(t){var e=function(t){var e=new fs({radius:$l.F0.vertexRadius,fill:new _s({color:t.editVertex})});return{vertexImage:e,vertexStyle:new Is({image:e}),selectedVertexStyle:new Is({renderer:oh(nh,t,"editVertex")})}}(t),n=e.vertexImage,i=e.vertexStyle,r=e.selectedVertexStyle,o=function(t){return{midpointStyle:new Is({image:new fs({radius:$l.F0.midpointRadius,fill:new _s({color:t.editMidpoint})})}),selectedMidpointStyle:new Is({renderer:oh(ih,t,"editMidpoint")})}}(t),s=o.midpointStyle,a=o.selectedMidpointStyle,l=new Is({stroke:new ys({color:t.editStroke,width:2}),fill:new _s({color:t.editFill})}),h=new Is({stroke:new ys({color:t.invalidStroke,width:2,lineDash:[2,4]})}),c=function(t){return{valid:new Is({stroke:new ys({color:t.editStroke,width:2}),fill:new _s({color:t.editFill})}),invalid:new Is({stroke:new ys({color:t.invalidStroke,width:2,lineDash:[2,4]})}),splitValid:new Is({stroke:new ys({color:t.splitValid,width:2})}),splitInvalid:new Is({stroke:new ys({color:t.splitInvalid,width:2,lineDash:[2,4]})})}}(t),u=new Ll([]),d=new Is({image:n,geometry:function(t){var e=Ql(t.getGeometry());return e.length?(u.setCoordinates(e),u):null}});return{vertexStyle:i,selectedVertexStyle:r,midpointStyle:s,selectedMidpointStyle:a,editFeatureStyle:l,editFeatureStyleInvalid:h,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){var n=e.getProperties(),i=t.mapStyleId,r=i&&n["stroke".concat(sh(i))]||n.stroke||t.shapeStroke,o=i&&n["fill".concat(sh(i))]||n.fill||t.shapeFill,s=n.strokeWidth||t.strokeWidth;return[new Is({stroke:new ys({color:r,width:s}),fill:new _s({color:o})})]}}}},lh=n(473);const hh=class extends rn{constructor(t,e,n){super(),n=n||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=void 0===n.transition?250:n.transition,this.transitionStarts_={},this.interpolate=!!n.interpolate}changed(){this.dispatchEvent(He)}release(){this.setState(4)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(4!==this.state){if(3!==this.state&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){vn()}getAlpha(t,e){if(!this.transition_)return 1;let n=this.transitionStarts_[t];if(n){if(-1===n)return 1}else n=e,this.transitionStarts_[t]=n;const i=e-n+1e3/60;return i>=this.transition_?1:ta(i/this.transition_)}inTransition(t){return!!this.transition_&&-1!==this.transitionStarts_[t]}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}};function ch(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageBitmap?t:null}const uh=new Error("disposed"),dh=[256,256],gh=class extends hh{constructor(t){super(t.tileCoord,0,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=ch(this.data_);return t?[t.width,t.height]:dh}getData(){return this.data_}getError(){return this.error_}load(){if(0!==this.state&&3!==this.state)return;this.state=1,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=2,t.changed()}).catch(function(e){t.error_=e,t.state=3,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(uh),this.controller_=null),super.disposeInternal()}},fh=class extends hh{constructor(t,e,n,i,r,o){super(t,e,o),this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.src_=n,this.key=n,this.image_,et?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=2,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=3,this.unlistenImage_(),this.image_=function(){const t=it(1,1);return t.fillStyle="rgba(0,0,0,0)",t.fillRect(0,0,1,1),t.canvas}(),this.changed()}handleImageLoad_(){if(et)this.state=2;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=2:this.state=4}this.unlistenImage_(),this.changed()}load(){3==this.state&&(this.state=0,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),0==this.state&&(this.state=1,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=function(t,e,n){const i=t;let r=!0,o=!1,s=!1;const a=[Ze(i,"load",function(){s=!0,o||e()})];return i.src&&nt?(o=!0,i.decode().then(function(){r&&e()}).catch(function(t){r&&(s?e():n())})):a.push(Ze(i,"error",n)),function(){r=!1,a.forEach(Ke)}}(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}};const ph=class{constructor(t,e,n,i){this.minX=t,this.maxX=e,this.minY=n,this.maxY=i}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}};let _h;const mh=[];function yh(t,e,n,i,r){t.beginPath(),t.moveTo(0,0),t.lineTo(e,n),t.lineTo(i,r),t.closePath(),t.save(),t.clip(),t.fillRect(0,0,Math.max(e,i)+1,Math.max(n,r)),t.restore()}function vh(t,e){return Math.abs(t[4*e]-210)>2||Math.abs(t[4*e+3]-191.25)>2}function xh(t,e,n,i){const r=ue(n,e,t);let o=re(e,i,n);const s=e.getMetersPerUnit();void 0!==s&&(o*=s);const a=t.getMetersPerUnit();void 0!==a&&(o/=a);const l=t.getExtent();if(!l||d(l,r)){const e=re(t,o,r)/o;isFinite(e)&&e>0&&(o/=e)}return o}const Sh=class{constructor(t,e,n,i,r,o,s){this.sourceProj_=t,this.targetProj_=e;let a={};const l=s?(h=t=>vi(s,ue(t,this.targetProj_,this.sourceProj_)),function(t,e,n,i){const r=t.length;n=void 0!==n?n:2,i=i??n,e=void 0!==e?e:new Array(r);for(let o=0;o<r;o+=i){const r=h(t.slice(o,o+n)),s=r.length;for(let n=0,a=i;n<a;++n)e[o+n]=n>=s?t[o+n]:r[n]}return e}):ce(this.targetProj_,this.sourceProj_);var h;this.transformInv_=function(t){const e=t[0]+"/"+t[1];return a[e]||(a[e]=l(t)),a[e]},this.maxSourceExtent_=i,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!i&&!!this.sourceProj_.getExtent()&&L(i)>=L(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?L(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?L(this.targetProj_.getExtent()):null;const c=O(n),u=A(n),d=P(n),g=E(n),f=this.transformInv_(c),p=this.transformInv_(u),_=this.transformInv_(d),m=this.transformInv_(g),y=10+(o?Math.max(0,Math.ceil(Math.log2(T(n)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,g,f,p,_,m,y),this.wrapsXInSource_){let t=1/0;this.triangles_.forEach(function(e,n,i){t=Math.min(t,e.source[0][0],e.source[1][0],e.source[2][0])}),this.triangles_.forEach(e=>{if(Math.max(e.source[0][0],e.source[1][0],e.source[2][0])-t>this.sourceWorldWidth_/2){const n=[[e.source[0][0],e.source[0][1]],[e.source[1][0],e.source[1][1]],[e.source[2][0],e.source[2][1]]];n[0][0]-t>this.sourceWorldWidth_/2&&(n[0][0]-=this.sourceWorldWidth_),n[1][0]-t>this.sourceWorldWidth_/2&&(n[1][0]-=this.sourceWorldWidth_),n[2][0]-t>this.sourceWorldWidth_/2&&(n[2][0]-=this.sourceWorldWidth_);const i=Math.min(n[0][0],n[1][0],n[2][0]);Math.max(n[0][0],n[1][0],n[2][0])-i<this.sourceWorldWidth_/2&&(e.source=n)}})}a={}}addTriangle_(t,e,n,i,r,o){this.triangles_.push({source:[i,r,o],target:[t,e,n]})}addQuad_(t,e,n,i,r,o,s,a,l){const c=h([r,o,s,a]),u=this.sourceWorldWidth_?L(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,g=this.sourceProj_.canWrapX()&&u>.5&&u<1;let f=!1;if(l>0&&(this.targetProj_.isGlobal()&&this.targetWorldWidth_&&(f=L(h([t,e,n,i]))/this.targetWorldWidth_>.25||f),!g&&this.sourceProj_.isGlobal()&&u&&(f=u>.25||f)),!f&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!D(c,this.maxSourceExtent_))return;let p=0;if(!(f||isFinite(r[0])&&isFinite(r[1])&&isFinite(o[0])&&isFinite(o[1])&&isFinite(s[0])&&isFinite(s[1])&&isFinite(a[0])&&isFinite(a[1])))if(l>0)f=!0;else if(p=(isFinite(r[0])&&isFinite(r[1])?0:8)+(isFinite(o[0])&&isFinite(o[1])?0:4)+(isFinite(s[0])&&isFinite(s[1])?0:2)+(isFinite(a[0])&&isFinite(a[1])?0:1),1!=p&&2!=p&&4!=p&&8!=p)return;if(l>0){if(!f){const e=[(t[0]+n[0])/2,(t[1]+n[1])/2],i=this.transformInv_(e);let o;o=g?(z(r[0],d)+z(s[0],d))/2-z(i[0],d):(r[0]+s[0])/2-i[0];const a=(r[1]+s[1])/2-i[1];f=o*o+a*a>this.errorThresholdSquared_}if(f){if(Math.abs(t[0]-n[0])<=Math.abs(t[1]-n[1])){const h=[(e[0]+n[0])/2,(e[1]+n[1])/2],c=this.transformInv_(h),u=[(i[0]+t[0])/2,(i[1]+t[1])/2],d=this.transformInv_(u);this.addQuad_(t,e,h,u,r,o,c,d,l-1),this.addQuad_(u,h,n,i,d,c,s,a,l-1)}else{const h=[(t[0]+e[0])/2,(t[1]+e[1])/2],c=this.transformInv_(h),u=[(n[0]+i[0])/2,(n[1]+i[1])/2],d=this.transformInv_(u);this.addQuad_(t,h,u,i,r,c,d,a,l-1),this.addQuad_(h,e,n,u,c,o,s,d,l-1)}return}}if(g){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}11&p||this.addTriangle_(t,n,i,r,s,a),14&p||this.addTriangle_(t,n,e,r,s,o),p&&(13&p||this.addTriangle_(e,i,t,o,a,r),7&p||this.addTriangle_(e,i,n,o,a,s))}calculateSourceExtent(){const t=[1/0,1/0,-1/0,-1/0];return this.triangles_.forEach(function(e,n,i){const r=e.source;C(t,r[0]),C(t,r[1]),C(t,r[2])}),t}getTriangles(){return this.triangles_}},Ch=class extends hh{constructor(t,e,n,i,r,o,s,a,l,h,c,u){super(r,0,u),this.renderEdges_=void 0!==c&&c,this.pixelRatio_=s,this.gutter_=a,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=i,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const d=i.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let f=this.sourceTileGrid_.getExtent();const p=g?k(d,g):d;if(0===T(p))return void(this.state=4);const _=t.getExtent();_&&(f=f?k(f,_):_);const m=i.getResolution(this.wrappedTileCoord_[0]),y=function(t,e,n,i){const r=M(n);let o=xh(t,e,r,i);return(!isFinite(o)||o<=0)&&b(n,function(n){return o=xh(t,e,n,i),isFinite(o)&&o>0}),o}(t,n,p,m);if(!isFinite(y)||y<=0)return void(this.state=4);const v=void 0!==h?h:.5;if(this.triangulation_=new Sh(t,n,p,f,y*v,m),0===this.triangulation_.getTriangles().length)return void(this.state=4);this.sourceZ_=e.getZForResolution(y);let x=this.triangulation_.calculateSourceExtent();if(f&&(t.canWrapX()?(x[1]=W(x[1],f[1],f[3]),x[3]=W(x[3],f[1],f[3])):x=k(x,f)),T(x)){let n=0,i=0;t.canWrapX()&&(n=L(_),i=Math.floor((x[0]-_[0])/n)),V(x.slice(),t,!0).forEach(t=>{const r=e.getTileRangeForExtentAndZ(t,this.sourceZ_);for(let t=r.minX;t<=r.maxX;t++)for(let e=r.minY;e<=r.maxY;e++){const r=i*n;this.sourceTiles_.push({getTile:()=>l(this.sourceZ_,t,e,s),offset:r})}++i}),0===this.sourceTiles_.length&&(this.state=4)}else this.state=4}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const n=e.tile;if(n&&2==n.getState()){const i=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);i[0]+=e.offset,i[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:i,clipExtent:r,image:n.getImage()})}}),this.sourceTiles_.length=0,0===t.length)this.state=3;else{const e=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(e),i="number"==typeof n?n:n[0],r="number"==typeof n?n:n[1],o=this.targetTileGrid_.getResolution(e),s=this.sourceTileGrid_.getResolution(this.sourceZ_),a=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=function(t,e,n,i,r,o,s,a,l,h,c,u,d,g){const f=it(Math.round(n*t),Math.round(n*e),mh);if(u||(f.imageSmoothingEnabled=!1),0===l.length)return f.canvas;function p(t){return Math.round(t*n)/n}f.scale(n,n),f.globalCompositeOperation="lighter";const _=[1/0,1/0,-1/0,-1/0];let m;l.forEach(function(t,e,n){S(_,t.extent)});const y=n/i,v=(u?1:1+Math.pow(2,-24))/y;if(!d||1!==l.length||0!==h){if(m=it(Math.round(L(_)*y),Math.round(F(_)*y),mh),u||(m.imageSmoothingEnabled=!1),r&&g){const t=(r[0]-_[0])*y,e=-(r[3]-_[3])*y,n=L(r)*y,i=F(r)*y;m.rect(t,e,n,i),m.clip()}l.forEach(function(t,e,n){if(t.image.width>0&&t.image.height>0){if(t.clipExtent){m.save();const e=(t.clipExtent[0]-_[0])*y,n=-(t.clipExtent[3]-_[3])*y,i=L(t.clipExtent)*y,r=F(t.clipExtent)*y;m.rect(u?e:Math.round(e),u?n:Math.round(n),u?i:Math.round(e+i)-Math.round(e),u?r:Math.round(n+r)-Math.round(n)),m.clip()}const e=(t.extent[0]-_[0])*y,n=-(t.extent[3]-_[3])*y,i=L(t.extent)*y,r=F(t.extent)*y;m.drawImage(t.image,h,h,t.image.width-2*h,t.image.height-2*h,u?e:Math.round(e),u?n:Math.round(n),u?i:Math.round(e+i)-Math.round(e),u?r:Math.round(n+r)-Math.round(n)),t.clipExtent&&m.restore()}})}const x=O(s);return a.getTriangles().forEach(function(t,e,n){const i=t.source,r=t.target;let s=i[0][0],a=i[0][1],h=i[1][0],c=i[1][1],d=i[2][0],g=i[2][1];const y=p((r[0][0]-x[0])/o),S=p(-(r[0][1]-x[1])/o),C=p((r[1][0]-x[0])/o),w=p(-(r[1][1]-x[1])/o),I=p((r[2][0]-x[0])/o),b=p(-(r[2][1]-x[1])/o),T=s,E=a;s=0,a=0,h-=T,c-=E,d-=T,g-=E;const P=function(t){const e=t.length;for(let n=0;n<e;n++){let i=n,r=Math.abs(t[n][n]);for(let o=n+1;o<e;o++){const e=Math.abs(t[o][n]);e>r&&(r=e,i=o)}if(0===r)return null;const o=t[i];t[i]=t[n],t[n]=o;for(let i=n+1;i<e;i++){const r=-t[i][n]/t[n][n];for(let o=n;o<e+1;o++)n==o?t[i][o]=0:t[i][o]+=r*t[n][o]}}const n=new Array(e);for(let i=e-1;i>=0;i--){n[i]=t[i][e]/t[i][i];for(let r=i-1;r>=0;r--)t[r][e]-=t[r][i]*n[i]}return n}([[h,c,0,0,C-y],[d,g,0,0,I-y],[0,0,h,c,w-S],[0,0,d,g,b-S]]);if(!P)return;if(f.save(),f.beginPath(),function(){if(void 0===_h){const t=it(6,6,mh);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",yh(t,4,5,4,0),yh(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;_h=vh(e,0)||vh(e,4)||vh(e,8),st(t),mh.push(t.canvas)}return _h}()||!u){f.moveTo(C,w);const t=4,e=y-C,n=S-w;for(let i=0;i<t;i++)f.lineTo(C+p((i+1)*e/t),w+p(i*n/(t-1))),i!=t-1&&f.lineTo(C+p((i+1)*e/t),w+p((i+1)*n/(t-1)));f.lineTo(I,b)}else f.moveTo(C,w),f.lineTo(y,S),f.lineTo(I,b);let M;if(f.clip(),f.transform(P[0],P[2],P[1],P[3],y,S),f.translate(_[0]-T,_[3]-E),m)M=m.canvas,f.scale(v,-v);else{const t=l[0],e=t.extent;M=t.image,f.scale(L(e)/M.width,-F(e)/M.height)}f.drawImage(M,0,0),f.restore()}),m&&(st(m),mh.push(m.canvas)),c&&(f.save(),f.globalCompositeOperation="source-over",f.strokeStyle="black",f.lineWidth=1,a.getTriangles().forEach(function(t,e,n){const i=t.target,r=(i[0][0]-x[0])/o,s=-(i[0][1]-x[1])/o,a=(i[1][0]-x[0])/o,l=-(i[1][1]-x[1])/o,h=(i[2][0]-x[0])/o,c=-(i[2][1]-x[1])/o;f.beginPath(),f.moveTo(a,l),f.lineTo(r,s),f.lineTo(h,c),f.closePath(),f.stroke()}),f.restore()),f.canvas}(i,r,this.pixelRatio_,s,this.sourceTileGrid_.getExtent(),o,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=2}this.changed()}load(){for(const t of this.sourceTiles_)t.tile=t.getTile();if(0==this.state){this.state=1,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const n=e.getState();if(0==n||1==n){t++;const n=qe(e,He,i=>{const r=e.getState();2!=r&&3!=r&&4!=r||(Ke(n),t--,0===t&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},e,n){0==t.getState()&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(Ke),this.sourcesListenerKeys_=null}release(){this.canvas_&&(st(this.canvas_.getContext("2d")),mh.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},wh=class{constructor(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof $e&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const n=this.entries_[t];return fi(void 0!==n,"Tried to get a value for a key that does not exist in the cache"),n===this.newest_||(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n),n.value_}remove(t){const e=this.entries_[t];return fi(void 0!==e,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.key_;return t}getValues(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){fi(!(t in this.entries_),"Tried to set a value for a key that is used already");const n={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[t]=n,++this.count_}setSize(t){this.highWaterMark=t}};function Ih(t,e,n,i){return void 0!==i?(i[0]=t,i[1]=e,i[2]=n,i):[t,e,n]}function bh(t,e,n,i,r){return`${Sn(t)},${e},${function(t,e,n){return t+"/"+e+"/"+n}(n,i,r)}`}function Th(t,e,n){if(!(n in t))return t[n]=new Set([e]),!0;const i=t[n],r=i.has(e);return r||i.add(e),!r}function Eh(t,e,n){const i=t[n];return!!i&&i.delete(e)}function Ph(t,e){const n=t.layerStatesArray[t.layerIndex];n.extent&&(e=k(e,ye(n.extent,t.viewState.projection)));const i=n.layer.getRenderSource();if(!i.getWrapX()){const n=i.getTileGridForProjection(t.viewState.projection).getExtent();n&&(e=k(e,n))}return e}const Mh=class extends xr{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=[1/0,1/0,-1/0,-1/0],this.tempTileRange_=new ph(0,0,0,0),this.tempTileCoord_=Ih(0,0,0);const n=void 0!==e.cacheSize?e.cacheSize:512;this.tileCache_=new wh(n),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=.5*n}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new wh(512)),this.sourceTileCache_}getOrCreateTile(t,e,n,i){const r=this.tileCache_,o=this.getLayer().getSource(),s=bh(o,o.getKey(),t,e,n);let a;if(r.containsKey(s))a=r.get(s);else{const l=i.viewState.projection,h=o.getProjection();if(a=o.getTile(t,e,n,i.pixelRatio,l,!h||ae(h,l)?void 0:this.getSourceTileCache()),!a)return null;r.set(s,a)}return a}getTile(t,e,n,i){return this.getOrCreateTile(t,e,n,i)||null}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),i=vi(e.pixelToCoordinateTransform,t.slice()),r=n.getExtent();if(r&&!d(r,i))return null;const o=e.viewState,s=n.getRenderSource(),a=s.getTileGridForProjection(o.projection),l=s.getTilePixelRatio(e.pixelRatio);for(let t=a.getZForResolution(o.resolution);t>=a.getMinZoom();--t){const n=a.getTileCoordForCoordAndZ(i,t),r=this.getTile(t,n[1],n[2],e);if(!r||2!==r.getState())continue;const h=a.getOrigin(t),c=Zi(a.getTileSize(t)),u=a.getResolution(t);let d;if(r instanceof fh||r instanceof Ch)d=r.getImage();else{if(!(r instanceof gh))continue;if(d=ch(r.getData()),!d)continue}const g=Math.floor(l*((i[0]-h[0])/u-n[1]*c[0])),f=Math.floor(l*((h[1]-i[1])/u-n[2]*c[1])),p=Math.round(l*s.getGutterForProjection(o.projection));return this.getImageData(d,g+p,f+p)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const n=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==n&&(this.renderedSourceRevision_=n,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=n,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,n,i,r){const o=t.viewState,s=this.getLayer(),a=s.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=Sn(a);h in t.wantedTiles||(t.wantedTiles[h]={});const c=t.wantedTiles[h],u=s.getMapInternal(),d=Math.max(n-r,l.getMinZoom(),l.getZForResolution(Math.min(s.getMaxResolution(),u?u.getView().getResolutionForZoom(Math.max(s.getMinZoom(),0)):l.getResolution(0)),a.zDirection)),g=o.rotation,f=g?R(o.center,o.resolution,g,t.size):void 0;for(let r=n;r>=d;--r){const n=l.getTileRangeForExtentAndZ(e,r,this.tempTileRange_),o=l.getResolution(r);for(let e=n.minX;e<=n.maxX;++e)for(let s=n.minY;s<=n.maxY;++s){if(g&&!l.tileCoordIntersectsViewport([r,e,s],f))continue;const n=this.getTile(r,e,s,t);if(!n)continue;if(!Th(i,n,r))continue;const a=n.getKey();if(c[a]=!0,0===n.getState()&&!t.tileQueue.isKeyQueued(a)){const i=Ih(r,e,s,this.tempTileCoord_);t.tileQueue.enqueue([n,h,l.getTileCoordCenter(i),o])}}}}findStaleTile_(t,e){const n=this.tileCache_,i=t[0],r=t[1],o=t[2],s=this.getStaleKeys();for(let t=0;t<s.length;++t){const a=bh(this.getLayer().getSource(),s[t],i,r,o);if(n.containsKey(a)){const t=n.peek(a);if(2===t.getState())return t.endTransition(Sn(this)),Th(e,t,i),!0}}return!1}findAltTiles_(t,e,n,i){const r=t.getTileRangeForTileCoordAndZ(e,n,this.tempTileRange_);if(!r)return!1;let o=!0;const s=this.tileCache_,a=this.getLayer().getRenderSource(),l=a.getKey();for(let t=r.minX;t<=r.maxX;++t)for(let e=r.minY;e<=r.maxY;++e){const r=bh(a,l,n,t,e);let h=!1;if(s.containsKey(r)){const t=s.peek(r);2===t.getState()&&(Th(i,t,n),h=!0)}h||(o=!1)}return o}renderFrame(t,e){this.renderComplete=!0;const n=t.layerStatesArray[t.layerIndex],r=t.viewState,o=r.projection,s=r.resolution,a=r.center,l=t.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(o),d=u.getZForResolution(s,c.zDirection),g=u.getResolution(d),f=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==f&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=f):this.renderedSourceKey_=f;let p=t.extent;const _=c.getTilePixelRatio(l);this.prepareContainer(t,e);const m=this.context.canvas.width,y=this.context.canvas.height;this.layerExtent=n.extent?ye(n.extent):null,this.layerExtent&&(p=k(p,this.layerExtent));const v=g*m/2/_,S=g*y/2/_,C=[a[0]-v,a[1]-S,a[0]+v,a[1]+S],w={};this.renderedTiles.length=0;const I=h.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){const e=u.getZForResolution(r.nextResolution,c.zDirection),n=Ph(t,t.nextExtent);this.enqueueTiles(t,n,e,w,I)}const b=Ph(t,p);if(this.enqueueTiles(t,b,d,w,0),I>0&&setTimeout(()=>{this.enqueueTiles(t,b,d-1,w,I-1)},0),!(d in w))return this.container;const T=Sn(this),E=t.time;for(const e of w[d]){const n=e.getState();if(4===n)continue;const i=e.tileCoord;if(2===n&&1===e.getAlpha(T,E)){e.endTransition(T);continue}if(3!==n&&(this.renderComplete=!1),this.findStaleTile_(i,w)){Eh(w,e,d),t.animate=!0;continue}if(this.findAltTiles_(u,i,d+1,w))continue;const r=u.getMinZoom();for(let t=d-1;t>=r&&!this.findAltTiles_(u,i,t,w);--t);}const P=g/s*l/_,M=this.getRenderContext(t);Si(this.tempTransform,m/2,y/2,P,P,0,-m/2,-y/2),this.layerExtent&&this.clipUnrotated(M,t,this.layerExtent),c.getInterpolate()||(M.imageSmoothingEnabled=!1),this.preRender(M,t);const R=Object.keys(w).map(Number);let F;R.sort(i);const A=[],L=[];for(let e=R.length-1;e>=0;--e){const n=R[e],i=c.getTilePixelSize(n,l,o),r=u.getResolution(n)/g,s=i[0]*r*P,a=i[1]*r*P,h=u.getTileCoordForCoordAndZ(O(C),n),d=u.getTileCoordExtent(h),f=vi(this.tempTransform,[_*(d[0]-C[0])/g,_*(C[3]-d[3])/g]),p=_*c.getGutterForProjection(o);for(const e of w[n]){if(2!==e.getState())continue;const i=e.tileCoord,r=h[1]-i[1],o=Math.round(f[0]-(r-1)*s),l=h[2]-i[2],u=Math.round(f[1]-(l-1)*a),d=Math.round(f[0]-r*s),g=Math.round(f[1]-l*a),_=o-d,m=u-g,y=1===R.length;let v=!1;F=[d,g,d+_,g,d+_,g+m,d,g+m];for(let t=0,e=A.length;t<e;++t)if(!y&&n<L[t]){const e=A[t];D([d,g,d+_,g+m],[e[0],e[3],e[4],e[7]])&&(v||(M.save(),v=!0),M.beginPath(),M.moveTo(F[0],F[1]),M.lineTo(F[2],F[3]),M.lineTo(F[4],F[5]),M.lineTo(F[6],F[7]),M.moveTo(e[6],e[7]),M.lineTo(e[4],e[5]),M.lineTo(e[2],e[3]),M.lineTo(e[0],e[1]),M.clip())}A.push(F),L.push(n),this.drawTile(e,t,d,g,_,m,p,y),v&&M.restore(),this.renderedTiles.unshift(e),this.updateUsedTiles(t.usedTiles,c,e)}}if(this.renderedResolution=g,this.extentChanged=!this.renderedExtent_||!x(this.renderedExtent_,C),this.renderedExtent_=C,this.renderedPixelRatio=l,this.postRender(this.context,t),this.layerExtent&&M.restore(),M.imageSmoothingEnabled=!0,this.renderComplete){const e=(t,e)=>{const n=Sn(c),i=e.wantedTiles[n],r=i?Object.keys(i).length:0;this.updateCacheSize(r),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(e)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,2*t)}drawTile(t,e,n,i,r,o,s,a){let l;if(t instanceof gh){if(l=ch(t.getData()),!l)throw new Error("Rendering array data is not yet supported")}else l=this.getTileImage(t);if(!l)return;const h=this.getRenderContext(e),c=Sn(this),u=e.layerStatesArray[e.layerIndex],d=u.opacity*(a?t.getAlpha(c,e.time):1),g=d!==h.globalAlpha;g&&(h.save(),h.globalAlpha=d),h.drawImage(l,s,s,l.width-2*s,l.height-2*s,n,i,r,o),g&&h.restore(),d!==u.opacity?e.animate=!0:a&&t.endTransition(c)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,n){const i=Sn(e);i in t||(t[i]={}),t[i][n.getKey()]=!0}},Rh={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},Fh={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]},kh=class extends Mh{constructor(t,e){super(t,e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=[1,0,0,1,0,0],this.tileClipContexts_=null}enqueueTilesForNextExtent(){return"vector"!==this.getLayer().getRenderMode()}drawTile(t,e,n,i,r,o,s,a){this.updateExecutorGroup_(t,e.pixelRatio,e.viewState.projection),this.tileImageNeedsRender_(t)&&this.renderTileImage_(t,e),super.drawTile(t,e,n,i,r,o,s,a)}getTile(t,e,n,i){const r=this.getOrCreateTile(t,e,n,i);if(!r)return null;const o=i.viewState,s=o.resolution,a=i.viewHints,l=this.getLayer().getSource(),h=l.getTileGridForProjection(o.projection),c=!(a[0]||a[1]),u=h.getZForResolution(s,l.zDirection)===t;return c&&u?r.wantedResolution=s:r.wantedResolution||(r.wantedResolution=h.getResolution(t)),r}prepareFrame(t){const e=this.getLayer().getRevision();return this.renderedLayerRevision_!==e&&(this.renderedLayerRevision_=e,this.renderedTiles.length=0),super.prepareFrame(t)}updateExecutorGroup_(t,e,n){const i=this.getLayer(),r=i.getRevision(),o=i.getRenderOrder()||null,s=t.wantedResolution,a=t.getReplayState(i);if(!a.dirty&&a.renderedResolution===s&&a.renderedRevision==r&&a.renderedPixelRatio===e&&a.renderedRenderOrder==o)return;const l=i.getSource(),h=!!i.getDeclutter(),u=l.getTileGrid(),d=l.getTileGridForProjection(n).getTileCoordExtent(t.wrappedTileCoord),g=l.getSourceTiles(e,n,t),f=Sn(i);delete t.hitDetectionImageData[f],t.executorGroups[f]=[],a.dirty=!1;for(let r=0,p=g.length;r<p;++r){const p=g[r];if(2!=p.getState())continue;const _=l.getProjection(),m=p.tileCoord;let y=u.getTileCoordExtent(m);n&&_&&!ae(n,_)&&(y=de(y,_,n,32));const v=k(d,y),S=c(v,i.getRenderBuffer()*s,this.tempExtent),C=x(y,v)?null:S,w=new ui(0,v,s,e),I=dr(s,e),b=function(t,e){let n;const r=t.getStyleFunction()||i.getStyleFunction();if(r&&(n=r(t,s)),n){const i=this.renderFeature(t,I,n,w,h,e);a.dirty=a.dirty||i}},T=p.getFeatures();o&&o!==a.renderedRenderOrder&&T.sort(o);for(let t=0,e=T.length;t<e;++t){let e=T[t];n&&p.projection&&!ae(n,p.projection)&&(e=e.clone(),e.getGeometry().applyTransform(ce(p.projection,n))),C&&!D(C,e.getGeometry().getExtent())||b.call(this,e,t)}const E=w.finish(),P="vector"!==i.getRenderMode()&&h&&1===g.length?null:v,M=new qi(P,s,e,l.getOverlaps(),E,i.getRenderBuffer(),!0);t.executorGroups[f].push(M)}a.renderedRevision=r,a.renderedPixelRatio=e,a.renderedRenderOrder=o,a.renderedResolution=s}forEachFeatureAtCoordinate(t,e,n,i,r){const o=e.viewState.resolution,s=e.viewState.rotation;n=null==n?0:n;const a=this.getLayer(),l=a.getSource().getTileGridForProjection(e.viewState.projection),u=a.getRenderBuffer(),d=h([t]);c(d,o*(u+n),d);const g={},f=function(t,e,n){let o=t.getId();void 0===o&&(o=Sn(t));const s=g[o];if(s){if(!0!==s&&n<s.distanceSq){if(0===n)return g[o]=!0,r.splice(r.lastIndexOf(s),1),i(t,a,e);s.geometry=e,s.distanceSq=n}}else{if(0===n)return g[o]=!0,i(t,a,e);r.push(g[o]={feature:t,layer:a,geometry:e,distanceSq:n,callback:i})}},p=this.renderedTiles,_=Sn(a),m=a.getDeclutter(),y=m?e.declutter?.[m]?.all().map(t=>t.value):null;let v;t:for(let e=p.length-1;e>=0;--e){const i=p[e];if(!D(l.getTileCoordExtent(i.wrappedTileCoord),d))continue;const r=i.executorGroups[_];for(let e=0,i=r.length;e<i;++e)if(v=r[e].forEachFeatureAtCoordinate(t,o,s,n,f,y),v)break t}return v}getFeatures(t){return 0===this.renderedTiles.length?Promise.resolve([]):new Promise((e,n)=>{const i=this.getLayer(),r=i.getSource(),o=this.renderedProjection,s=o.getExtent(),a=this.renderedResolution,l=r.getTileGridForProjection(o),h=vi(this.renderedPixelToCoordinateTransform_,t.slice()),c=l.getTileCoordForCoordAndResolution(h,a).toString(),u=this.renderedTiles.find(t=>t.tileCoord.toString()===c&&2===t.getState());if(!u||u.loadingSourceTiles>0)return void e([]);r.getWrapX()&&o.canWrapX()&&!g(s,l.getTileCoordExtent(u.tileCoord))&&Q(h,o);const d=Sn(i),f=O(l.getTileCoordExtent(u.wrappedTileCoord)),p=[(h[0]-f[0])/a,(f[1]-h[1])/a],_=u.getSourceTiles().reduce((t,e)=>t.concat(e.getFeatures()),[]);let m=u.hitDetectionImageData[d];if(!m){const t=Zi(l.getTileSize(l.getZForResolution(a,r.zDirection))),e=this.renderedRotation_;m=lr(t,[this.getRenderTransform(l.getTileCoordCenter(u.wrappedTileCoord),a,0,ar,t[0]*ar,t[1]*ar,0)],_,i.getStyleFunction(),l.getTileCoordExtent(u.wrappedTileCoord),u.getReplayState(i).renderedResolution,e),u.hitDetectionImageData[d]=m}e(hr(p,_,m))})}getFeaturesInExtent(t){const e=[],n=this.getTileCache();if(0===n.getCount())return e;const i=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),r=i.getZForResolution(this.renderedResolution),o={};return n.forEach(n=>{if(n.tileCoord[0]!==r||2!==n.getState())return;const s=n.getSourceTiles();for(let n=0,r=s.length;n<r;++n){const r=s[n],a=r.getKey();if(a in o)continue;o[a]=!0;const l=r.tileCoord;if(D(t,i.getTileCoordExtent(l))){const n=r.getFeatures();if(n)for(let i=0,r=n.length;i<r;++i){const r=n[i],o=r.getGeometry();D(t,o.getExtent())&&e.push(r)}}}}),e}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&void 0!==this.renderedLayerRevision_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}renderDeclutter(t,e){const n=this.context,i=n.globalAlpha;n.globalAlpha=e.opacity;const r=t.viewHints,o=!(r[0]||r[1]),s=[this.context.canvas.width,this.context.canvas.height],a=this.getLayer().getDeclutter(),l=a?t.declutter?.[a]:void 0,h=Sn(this.getLayer()),c=this.renderedTiles;for(let e=0,n=c.length;e<n;++e){const n=c[e],i=n.executorGroups[h];if(i)for(let e=i.length-1;e>=0;--e)i[e].execute(this.context,s,this.getTileRenderTransform(n,t),t.viewState.rotation,o,Ni,l)}n.globalAlpha=i}renderDeferredInternal(t){const e=this.renderedTiles,n=Sn(this.getLayer()),r=e.reduce((t,e,i)=>(e.executorGroups[n].forEach(e=>t.push({executorGroup:e,index:i})),t),[]),o=r.map(({executorGroup:t})=>t.getDeferredZIndexContexts()),s={};for(let t=0,e=r.length;t<e;++t){const e=r[t].executorGroup.getDeferredZIndexContexts();for(const t in e)s[t]=!0}const a=Object.keys(s).map(Number).sort(i);this.layerExtent&&this.clipUnrotated(this.context,t,this.layerExtent),a.forEach(t=>{o.forEach((e,n)=>{e[t]&&(e[t].forEach(t=>{const{executorGroup:e,index:i}=r[n],o=e.getRenderedContext(),s=o.globalAlpha;o.globalAlpha=this.renderedOpacity_;const a=this.tileClipContexts_[i];a&&a.draw(o),t.draw(o),a&&o.restore(),o.globalAlpha=s,t.clear()}),e[t].length=0)})}),this.layerExtent&&this.context.restore()}getTileRenderTransform(t,e){const n=e.pixelRatio,i=e.viewState,r=i.center,o=i.resolution,s=i.rotation,a=e.size,l=Math.round(a[0]*n),h=Math.round(a[1]*n),c=this.getLayer().getSource().getTileGridForProjection(e.viewState.projection),u=t.tileCoord,d=c.getTileCoordExtent(t.wrappedTileCoord),g=c.getTileCoordExtent(u,this.tempExtent)[0]-d[0];return mi(xi(this.inversePixelTransform.slice(),1/n,1/n),this.getRenderTransform(r,o,s,n,l,h,g))}postRender(t,e){const n=e.viewHints,i=!(n[0]||n[1]);this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice(),this.renderedRotation_=e.viewState.rotation,this.renderedOpacity_=e.layerStatesArray[e.layerIndex].opacity;const r=this.getLayer(),o=r.getRenderMode(),s=t.globalAlpha;t.globalAlpha=this.renderedOpacity_;const a=r.getDeclutter(),l=a?Fh[o].filter(t=>!Ni.includes(t)):Fh[o],h=e.viewState,c=h.rotation;this.layerExtent&&this.clipUnrotated(t,e,this.layerExtent);const u=r.getSource(),d=u.getTileGridForProjection(h.projection).getZForResolution(h.resolution,u.zDirection),g=this.renderedTiles,f=[],p=[],_=[],m=Sn(r);let y=!0;for(let n=g.length-1;n>=0;--n){const o=g[n];y=y&&!o.getReplayState(r).dirty;const s=o.executorGroups[m].filter(t=>t.hasExecutors(l));if(0===s.length)continue;const h=this.getTileRenderTransform(o,e),u=o.tileCoord[0];let v=!1;const x=s[0].getClipCoords(h);let S,C=t;if(x){S=new Mi,C=S.getContext();for(let t=0,e=f.length;t<e;++t)if(d!==u&&u<p[t]){const e=f[t];D([x[0],x[3],x[4],x[7]],[e[0],e[3],e[4],e[7]])&&(v||(C.save(),v=!0),C.beginPath(),C.moveTo(x[0],x[1]),C.lineTo(x[2],x[3]),C.lineTo(x[4],x[5]),C.lineTo(x[6],x[7]),C.moveTo(e[6],e[7]),C.lineTo(e[4],e[5]),C.lineTo(e[2],e[3]),C.lineTo(e[0],e[1]),C.clip())}f.push(x),p.push(u)}for(let n=0,r=s.length;n<r;++n)s[n].execute(t,[t.canvas.width,t.canvas.height],h,c,i,l,e.declutter?.[a]);v&&(C===t?C.restore():_[n]=S)}this.layerExtent&&t.restore(),t.globalAlpha=s,this.ready=y,this.tileClipContexts_=_,e.declutter||this.renderDeferredInternal(e),super.postRender(t,e)}renderFeature(t,e,n,i,r,o){if(!n)return!1;let s=!1;if(Array.isArray(n))for(let a=0,l=n.length;a<l;++a)s=fr(i,t,n[a],e,this.boundHandleStyleImageChange_,void 0,r,o)||s;else s=fr(i,t,n,e,this.boundHandleStyleImageChange_,void 0,r,o);return s}tileImageNeedsRender_(t){const e=this.getLayer();if("vector"===e.getRenderMode())return!1;const n=t.getReplayState(e),i=e.getRevision(),r=t.wantedResolution;return n.renderedTileResolution!==r||n.renderedTileRevision!==i}renderTileImage_(t,e){const n=this.getLayer(),i=t.getReplayState(n),r=n.getRevision(),o=t.executorGroups[Sn(n)];i.renderedTileRevision=r;const s=t.wrappedTileCoord,a=s[0],l=n.getSource();let h=e.pixelRatio;const c=e.viewState.projection,u=l.getTileGridForProjection(c),d=u.getResolution(t.tileCoord[0]),g=e.pixelRatio/t.wantedResolution*d,f=u.getResolution(a),p=t.getContext();h=Math.round(Math.max(h,g/h));const _=l.getTilePixelSize(a,h,c);p.canvas.width=_[0],p.canvas.height=_[1];const m=h/g;if(1!==m){const t=_i(this.tmpTransform_);xi(t,m,m),p.setTransform.apply(p,t)}const y=u.getTileCoordExtent(s,this.tempExtent),v=g/f,x=_i(this.tmpTransform_);xi(x,v,-v),function(t,e,n){mi(t,yi(pi,1,0,0,1,e,n))}(x,-y[0],-y[3]);for(let t=0,e=o.length;t<e;++t)o[t].execute(p,[p.canvas.width*m,p.canvas.height*m],x,0,!0,Rh[n.getRenderMode()],null);i.renderedTileResolution=t.wantedResolution}},Oh="preload",Ah="useInterimTilesOnError",Lh=class extends il{constructor(t){t=t||{};const e=Object.assign({},t);delete e.preload;const n=void 0===t.cacheSize?0:t.cacheSize;delete t.cacheSize,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=n;const i=t.renderMode||"hybrid";fi("hybrid"==i||"vector"==i,"`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=i,this.setPreload(t.preload?t.preload:0),this.setUseInterimTilesOnError(void 0===t.useInterimTilesOnError||t.useInterimTilesOnError),this.getBackground,this.setBackground}createRenderer(){return new kh(this,{cacheSize:this.cacheSize_})}getFeatures(t){return super.getFeatures(t)}getFeaturesInExtent(t){return this.getRenderer().getFeaturesInExtent(t)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(Oh)}getUseInterimTilesOnError(){return this.get(Ah)}setPreload(t){this.set(Oh,t)}setUseInterimTilesOnError(t){this.set(Ah,t)}};function Dh(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=jh(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 Gh(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)||jh(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 jh(t,e){if(t){if("string"==typeof t)return Vh(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)?Vh(t,e):void 0}}function Vh(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 Wh=function(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i},Xh=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 Yh(t,e)?e:t},Yh=function(t,e){return t?!!e&&("edge"===t.type&&"vertex"===e.type||("vertex"!==t.type||"edge"!==e.type)&&e.distSq<t.distSq):!!e},Bh=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=Wh(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],g=Xh(e,u,d),f=Wh(e,g);f<=n&&(r=Nh(r,{type:"edge",coord:g,distSq:f}))}return r},zh=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=Xh(r,c,u),g=Wh(r,d);g<=o&&(s=Nh(s,{type:"edge",coord:d,distSq:g,seg:[c,u]}))}return s},Uh=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]},qh=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=Wh(r,c);if(u<=o){var d=Gh(Uh(h,n,s),2),g=d[0],f=d[1],p=[a(g),a(f)];l=Nh(l,{type:"vertex",coord:c,distSq:u,adjacent:p})}}return l},Zh=function(t,e,n,i,r,o){var s=(n-e)/2,a=o?s:s-1;return{vertex:qh(t,e,s,a,i,r),edge:zh(t,e,s,a,i,r)}},Kh={point:function(t,e,n){var i=t.getCoordinates(),r=Wh(e,i);return r<=n?{type:"vertex",coord:[i[0],i[1]],distSq:r}:null},lineString:function(t,e,n){return Bh(t.getCoordinates(),e,n,!1)},linearRing:function(t,e,n){return Bh(t.getCoordinates(),e,n,!0)},polygon:function(t,e,n){var i,r=null,o=Dh(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s=i.value;r=Nh(r,Bh(s,e,n,!0))}}catch(t){o.e(t)}finally{o.f()}return r},multiLineString:function(t,e,n){var i,r=null,o=Dh(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s=i.value;r=Nh(r,Bh(s,e,n,!1))}}catch(t){o.e(t)}finally{o.f()}return r},multiPolygon:function(t,e,n){var i,r=null,o=Dh(t.getCoordinates());try{for(o.s();!(i=o.n()).done;){var s,a=Dh(i.value);try{for(a.s();!(s=a.n()).done;){var l=s.value;r=Nh(r,Bh(l,e,n,!0))}}catch(t){a.e(t)}finally{a.f()}}}catch(t){o.e(t)}finally{o.f()}return r}},Hh=function(t,e,n){var i=t.getGeometry();if(!i)return null;var r=i.getType(),o=Kh[r[0].toLowerCase()+r.slice(1)];return o?o(i,e,n):null};function $h(t){return $h="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},$h(t)}function Jh(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 Qh(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Jh(Object(n),!0).forEach(function(e){tc(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Jh(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function tc(t,e,n){return(e=function(t){var e=function(t){if("object"!=$h(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=$h(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==$h(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ec(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=ic(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 nc(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)||ic(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 ic(t,e){if(t){if("string"==typeof t)return rc(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)?rc(t,e):void 0}}function rc(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 oc=function(t,e,n){if(!e||!n)return!1;var i=nc(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},sc=function(){return!0===globalThis.DEBUG_SNAP_VISIBILITY},ac=function(t,e){sc()&&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)})},lc=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?ue(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=nc(e.seg,2),o=r[0],s=r[1];return oc(i,i.toSource(o),i.toSource(s))}var a=nc(null!==(n=e.adjacent)&&void 0!==n?n:[],2),l=a[0],h=a[1];return oc(i,i.anchor,i.toSource(l))||oc(i,i.anchor,i.toSource(h))}(r,e)?(sc()&&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)||(sc()&&console.log("[snap-filtered] invisible fill boundary"),0))};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 cc=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 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}}(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()}},uc=function(t){return{vertex:new Is({renderer:cc(t.snapVertex)}),edge:new Is({renderer:cc(t.snapEdge)})}};const dc="active",gc=class extends wn{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(dc)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(dc,t)}setMap(t){this.map_=t}};var fc=new Set(["pointermove","pointerdrag","pointerdown","pointerup","singleclick","click"]),pc=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=ec(null!=t?t:[]);try{for(r.s();!(e=r.n()).done;){var o=e.value;"string"==typeof o?n.add(o):o instanceof rl&&i.push(o)}}catch(t){r.e(t)}finally{r.f()}};return r(e),{query:function(e,r){sc()&&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 g,f=ec(d.getFeaturesInExtent(l));try{for(f.s();!(g=f.n()).done;){var p=g.value;h=Nh(h,Hh(p,e,a))}}catch(t){f.e(t)}finally{f.f()}}}if(n.size>0){var _=function(t){var e=[];return t.getLayers().forEach(function(t){t instanceof Lh&&e.push(t)}),e}(t),m=_.length>0?t.getPixelFromCoordinate(e):null;if(m){var y=new Map;t.forEachFeatureAtPixel(m,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=Wh(e,r);a<=n&&(o={type:"vertex",coord:[r[0],r[1]],distSq:a})}else if("LineString"===i){var l=Zh(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=Dh(t.getEnds());try{for(d.s();!(h=d.n()).done;){var g=h.value,f=Zh(r,c,g,e,n,u);o=Nh(o,f.vertex),s=Nh(s,f.edge),c=g}}catch(t){d.e(t)}finally{d.f()}}return[o,s].filter(Boolean)}(i,e,a);if(l.length){y.has(r)||y.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=y.get(r);h=function(t,e,n){var i,r=t,o=ec(e);try{for(o.s();!(i=o.n()).done;){var s=i.value;ac(s,n.mapboxLayer),lc(Qh({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:_,resolution:o})}}},{hitTolerance:r,layerFilter:function(t){return _.includes(t)}})}}return h?{type:h.type,coord:h.coord}:null},setLayers:r}}(t,e),o=function(t,e){var n=uc(e),i=new Il,r=new rl({source:i,style:function(t){var e;return null!==(e=n[t.get("snapType")])&&void 0!==e?e:null},zIndex:200,updateWhileAnimating:!0,updateWhileInteracting:!0});t.addLayer(r);var o=new Tl,s=!1;return{show:function(t,e){o.setGeometry(new ma(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=uc(t),s&&i.changed()},remove:function(){i.clear(),t.removeLayer(r)}}}(t,n),s=!1,a=function(t,e,n,i){var r=new gc({handleEvent:function(o){return r.getActive()&&function(t,e,n,i,r){var o=t.type;if("pointerout"!==o&&"pointerleave"!==o){if(fc.has(o)){var s=e.query(t.coordinate,i);s&&(t.coordinate=s.coord.slice()),"pointermove"===o&&r()?s?n.show(s.coord,s.type):n.hide():"pointerdrag"===o&&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 _c=class extends nn{constructor(t,e,n){super(t),this.map=e,this.frameState=void 0!==n?n:null}},mc=class extends _c{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()}},yc="singleclick",vc="pointerdrag",xc="pointermove",Sc="pointerdown",Cc=Je,wc=Qe,Ic=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},bc=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Tc=function(t){const e=t.originalEvent;return"pointerId"in e&&e.isPrimary&&0===e.button};class Ec extends or{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 Ec(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 _(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(D(t,this.getExtent())){const e=this.getCenter();return t[0]<=e[0]&&t[2]>=e[0]||t[1]<=e[1]&&t[3]>=e[1]||b(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=ca(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(gi(n,0,n.length,i,t,e,n)),this.changed()}}Ec.prototype.transform;const Pc=Ec,Mc=class extends gc{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==vc)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==Sc){const n=this.handleDownEvent(t);this.handlingDownUpSequence=n,e=this.stopDown(n)}else t.type==xc&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function Rc(t,e){const n=t.length;return e<0?t[e+n]:e>=n?t[e-n]:t[e]}function Fc(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 kc={index:-1,endIndex:NaN,closestTargetDistance:1/0};function Oc(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=Wc(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=Fc(h.coordinates,l);J(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=jc(t,n,i);jc(t,n,i-e)<r&&(l-=e)}else{const r=jc(t,n,i);jc(t,n,i+e)<r&&(l+=e)}}return kc.index=a,kc.endIndex=l,kc.closestTargetDistance=s,kc}function Ac(t,e){const n=[];for(let i=0;i<e.length;++i)Lc(t,e[i].getGeometry(),n);return n}function Lc(t,e,n){if(e instanceof Fl)Dc(t,e.getCoordinates(),!1,n);else{if(e instanceof Ol){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Dc(t,i[e],!1,n);return}if(e instanceof Oa){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Dc(t,i[e],!0,n);return}if(e instanceof Gl){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)Dc(t,r[e],!0,n)}return}if(e instanceof Ml){const i=e.getGeometries();for(let e=0;e<i.length;++e)Lc(t,i[e],n);return}}}function Dc(t,e,n,i){const r=t[0],o=t[1];for(let t=0,s=e.length-1;t<s;++t){const s=Wc(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 Gc(t,e){return N(t[0],t[1],e[0],e[1])}function jc(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 Gc(Fc(t,i),Fc(t,r));let a=0;i<o&&(a+=Gc(Fc(t,i),Rc(t,o))),s<r&&(a+=Gc(Rc(t,s),Fc(t,r)));for(let e=o;e<s-1;++e)a+=Gc(Rc(t,e),Rc(t,e+1));return a}const Vc={along:0,squaredDistance:0};function Wc(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=W(((t-r)*s+(e-o)*a)/(s*s+a*a),0,1),h+=s*l,c+=a*l),Vc.along=l,Vc.squaredDistance=q(N(t,e,h,c),10),Vc}const Xc="drawstart";class Nc extends nn{constructor(t,e){super(t),this.feature=e}}function Yc(){const t=Cs();return function(e,n){return t[e.getGeometry().getType()]}}const Bc=class extends Mc{constructor(t){const e=t;e.stopDown||(e.stopDown=Qe),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:Je,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 Pc([NaN,NaN]),r=_e(t[0]),o=$(r,_e(t[t.length-1]));i.setCenterAndRadius(r,Math.sqrt(o),this.geometryLayout_);const s=fe();return s&&i.transform(n,s),i};else{let e;"Point"===t?e=ma:"LineString"===t?e=Fl:"Polygon"===t&&(e=Oa),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 rl({source:new Il({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:Yc(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:Ic,this.freehandCondition_,t.freehand?this.freehandCondition_=Cc:this.freehandCondition_=t.freehandCondition?t.freehandCondition:bc,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(dc,this.updateState_)}setTrace(t){let e;e=t?!0===t?Cc:t:wc,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=Cc:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:bc}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===xc,n=!0;return!this.freehand_&&this.lastDragTime_&&t.type===vc&&(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===vc&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),n=!1):this.freehand_&&t.type===Sc?n=!1:e&&this.getPointerCount()<2?(n=t.type===xc,n&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===vc&&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 mc(xc,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=Ac(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(Rc(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(Rc(t.coordinates,e))}i.length&&this.appendCoordinates(i)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&J(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.snapTolerance_)return;const n=Oc(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=Fc(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 Tl(new ma(t)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new Tl);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=rr(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 Tl(new Fl(this.sketchLineCoords_)));const i=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new Tl,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(i),this.updateSketchFeatures_(),this.dispatchEvent(new Nc(Xc,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),n=this.sketchFeature_.getGeometry(),i=e.getView().getProjection(),r=rr(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 Ll([e])):"MultiLineString"===this.type_?t.setGeometry(new Ol([e])):"MultiPolygon"===this.type_&&t.setGeometry(new Gl([e])),this.dispatchEvent(new Nc("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 Nc("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 Tl(new ma(n)),this.updateSketchFeatures_(),this.dispatchEvent(new Nc(Xc,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 zc=function(t,e){var n=t.getPixelFromCoordinate(e);return n?{x:n[0],y:n[1]}:null},Uc=function(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))},qc=function(t,e,n,i){var r=t.getPixelFromCoordinate(e);return r?t.getCoordinateFromPixel([r[0]+n,r[1]+i]):e};function Zc(t){return function(t){if(Array.isArray(t))return Kc(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 Kc(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)?Kc(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 Kc(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 Hc=function(t){var e=t.drawInteraction,n=t.mapProvider,i=t.snap,r=t.canFinish,o=t.canPlace,s=t.getInterfaceType,a=null,l=null,h=function(){a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,l=null};e.on("drawstart",function(t){return h(t.feature)}),e.on("drawend",function(){return h()}),e.on("drawabort",function(){return h()});var c=function(){var t=n.getCenter();return"mouse"!==s()&&i?i.apply(t):t};return{placeVertex:function(){var t=c();if(null==i||i.hideIndicator(),a){var n=a.getGeometry(),s=n.getCoordinates(),h="Polygon"===n.getType()?s[0]||[]:s,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=zc(t,e),o=zc(t,n[0]);return!(!r||!o)&&Uc(r,o)<12}(a,o,r,i.getType()))return e.finishDrawing(),{handled:!0,lastPlacedCoord:s};var l=th(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:h,coord:t,lastPlacedCoord:l});if(l=u.lastPlacedCoord,u.handled)return}o&&!o(t)||(e.appendCoordinates([t]),l=t)},updateRubberbanding:function(){if(a){var t=a.getGeometry();t.getCoordinates().length&&function(t,e){if("LineString"===t.getType()){var n=Zc(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=Zc(t);return i[i.length-1]=e,i});t.setCoordinates(i)}}(t,c())}else"mouse"!==s()&&i&&i.apply(n.getCenter())},clearLastCoord:function(){l=null}}},$c=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),Jc=function(t,e){t&&(["touch","keyboard"].includes(e)?t.fixAtCenter():t.hide())},Qc=n(360),tu="styleschanged",eu=n(520),nu=n(9),iu=n(788),ru=n(715),ou=function(t,e){return!!e&&Ql(e.getGeometry()).length>=nu.n8[t]},su=function(t,e,n,i){return function(r){if(!Ic(r))return!1;var o=n();if(!i(r.coordinate))return!1;if(!o||ou(e,o))return!0;var s=th(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}},au={Polygon:2,LineString:1},lu=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(Qc.k.GEOMETRY_CHANGE,{feature:(r=t.store,o=c,s=r.toGeoJSON(o),a=s.geometry.type,l=au[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=Ql(r.getGeometry()).length;t.emit(Qc.k.VERTEX_CHANGE,{numVertices:o}),o>n&&i("commit-add",o-1),n=o}},emitUndoValidation:function(){var t=e();t&&i("commit-delete",Ql(t.getGeometry()).length)}}}(n,function(){return l}),d=u.updateVertexCount,g=u.resetCount,f=u.emitUndoValidation,p=function(t){var e=t.manager,n=t.geometryType,i=t.getSketch;return function(t){var r=i(),o=(0,eu.$b)({placed:r?Ql(r.getGeometry()):[],point:t,geometryType:n,onGeometryChange:e._geometryValidator});return o.valid||e.emit(Qc.k.PLACEMENT_BLOCKED,o.blocked),o.valid}}({manager:n,geometryType:r,getSketch:function(){return l}}),_=new Bc({type:r,style:function(t){return c(t)},stopClick:!0,snapTolerance:$l.vf.snapRadius,condition:su(e,r,function(){return l},p),finishCondition:function(){return!1!==n._geometryValid}});e.addInteraction(_);var m=(0,iu.De)({onChange:function(t){h=t,c=n.styles.createSketchStyle(r,h),_.overlay_.changed()}}),y=(0,ru.O)({onStrokeChange:function(t,e){return m.set(t,e)},onPlaceChange:function(t,e){return n.emit(Qc.k.CAN_PLACE_CHANGE,{canPlace:!t,reason:e})}}),v=eu.dV[r],x=function(){c=n.styles.createSketchStyle(r,h),_.overlay_.changed()};n.on(tu,x),_.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(Qc.k.CREATE,t.store.toGeoJSON(e))}(n,t.feature,i,r)}),t.on("drawabort",function(){n.emit(Qc.k.CANCEL)})}(_,{manager:n,featureId:o,properties:a,onStart:function(t){l=t,g()},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:Ql(i).length}}(r,l),e=t.feature,i=t.numVertices;y.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",g=function(){return d},f=Hc({drawInteraction:n,mapProvider:s,snap:a,canFinish:h,canPlace:c,getInterfaceType:g}),p=n.getMap(),_=null==p?void 0:p.getView(),m=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()&&l()};null==i||i.on("change:center",c);var u=function(t){e.contains(document.activeElement)&&($c.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()},g=function(t){"touch"!==t.pointerType&&(s("mouse"),a())},f=function(){s("touch")},p=function(){"mouse"!==o()&&l()};return globalThis.addEventListener("keydown",u),globalThis.addEventListener("click",d),e.addEventListener("pointerdown",g),e.addEventListener("touchstart",f,{passive:!0}),e.addEventListener("pointermove",p),{destroy:function(){null==i||i.un("change:center",c),globalThis.removeEventListener("keydown",u),globalThis.removeEventListener("click",d),e.removeEventListener("pointerdown",g),e.removeEventListener("touchstart",f),e.removeEventListener("pointermove",p)}}}({container:r,addVertexButtonId:o,olView:_,onUndo:l,getInterfaceType:g,setInterfaceType:function(t){d=t,Jc(u,t)},clearLastCoord:f.clearLastCoord,updateRubberbanding:f.updateRubberbanding,placeVertex:f.placeVertex});Jc(u,d);var y=function(){"mouse"!==d&&null!=_&&_.getAnimating()&&f.updateRubberbanding()};return null==p||p.on("postrender",y),{getInterfaceType:g,setInterfaceType:function(t){d=t,Jc(u,t),"mouse"!==t&&f.updateRubberbanding()},destroy:function(){m.destroy(),null==p||p.un("postrender",y)}}}({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 ou(i,r())},canPlace:a}})}({drawInteraction:_,options:i,geometryType:r,getSketch:function(){return l},updateVertexCount:d,emitUndoValidation:f,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(){ou(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(tu,h),n.emit(Qc.k.INTERFACE_TYPE_CHANGE,{interfaceType:r.getInterfaceType()}),r.destroy(),e.removeInteraction(i),c()}}}({map:e,manager:n,drawInteraction:_,input:S,geometryType:r,getSketch:function(){return l},updateVertexCount:d,emitUndoValidation:f,onStylesChanged:x,clearSketch:function(){l=null},setInvalid:function(t){return m.set(t)},liveStroke:m,liveDrawChecks:y})};function hu(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.")}()}function cu(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=uu(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 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 gu=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[]}},fu=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},pu=function(t,e){var n,i=cu(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},_u=function(t,e){var n,i=t.coordinates,r=cu(e);try{for(r.s();!(n=r.n()).done;)i=i[n.value]}catch(t){r.e(t)}finally{r.f()}return i},mu=function(t){var e=gu(t),n=fu(t);if(!e.length||!n.length)return[];var i,r=[],o=cu(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=hu(e[h],2),d=u[0],g=u[1],f=hu(e[c],2),p=f[0],_=f[1];r.push([(d+p)/2,(g+_)/2])}}catch(t){o.e(t)}finally{o.f()}return r},yu=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()}},g=function(){var t=d();c.vertices=gu(t),c.midpoints=mu(t),l.update(t),a.update(t),h.update(c)},f=function(t,e,n){return function(i,r){i&&setTimeout(function(){t.emit(Qc.k.GEOMETRY_CHANGE,{feature:e.toGeoJSON(n),phase:i,vertexIndex:r})},0)}}(n,i,r),p=function(){return g()};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(Qc.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(){g(),n.emit(Qc.k.VERTEX_CHANGE,{numVertices:c.vertices.length}),n.emit(Qc.k.UPDATE,i.toGeoJSON(r))},emitGeometryValidation:f,updateLayersFromGeom:g,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 vu=[0,0,0,0],xu=[],Su="modifyend";function Cu(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 wu extends nn{constructor(t,e,n){super(t),this.features=e,this.mapBrowserEvent=n}}function Iu(t,e){return t.index-e.index}function bu(t,e,n){const i=e.geometry;if("Circle"===i.getType()){let r=i;if(1===e.index){const e=fe();e&&(r=r.clone().transform(e,n));const i=$(r.getCenter(),_e(t)),o=Math.sqrt(i)-r.getRadius();return o*o}}const r=_e(t);return xu[0]=_e(e.segment[0]),xu[1]=_e(e.segment[1]),function(t,e){return $(t,K(t,e))}(r,xu)}function Tu(t,e,n){const i=e.geometry;if("Circle"===i.getType()&&1===e.index){let e=i;const r=fe();return r&&(e=e.clone().transform(r,n)),pe(e.getClosestPoint(_e(t)))}const r=_e(t);return xu[0]=_e(e.segment[0]),xu[1]=_e(e.segment[1]),pe(K(r,xu))}function Eu(){const t=Cs();return function(e,n){return t.Point}}const Pu=class extends Mc{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:Tc,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==yc}(t)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:Cc,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new yl,this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new rl({source:new Il({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:Eu(),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:H,!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(ol,this.handleExternalCollectionAdd_),t.features.addEventListener(sl,this.handleExternalCollectionRemove_),this.featuresCollection_=t.features):t.source&&(e=t.source.getFeatures(),t.source.addEventListener(Sl,this.handleSourceAdd_),t.source.addEventListener(Cl,this.handleSourceRemove_),this.source_=t.source),e.forEach(t=>{t.addEventListener(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(_n,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?Cc:t:wc,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 hl;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 wu("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(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(_n,this.handleFeatureChange_),this.filter_(t)&&this.addFeature_(t)}externalRemoveFeatureHandler_(t){t.removeEventListener(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(_n,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(y(n),i);let s=e;const a=fe();if(a&&this.getMap()){const t=this.getMap().getView().getProjection();s=s.clone().transform(a,t),s=La(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 Tl(new ma(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!=xc||this.handlingDownUpSequence||this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(e=!(t.type!=yc||!this.ignoreNextSingleClick_)||this.removePoint()),t.type==yc&&(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(Iu);for(let r=0,a=o.length;r<a;++r){const a=o[r],l=a.segment;let h=Sn(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=Tu(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])!(Sn(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&&J(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.pixelTolerance_)return;const n=Oc(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();Cu(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=Ac(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();Cu(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(Rc(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(Rc(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();Cu(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=J(_e(e.getCenter()),_e(t));const r=fe();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_)J(K(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(y(r),o);let a=e;const l=fe();if(l){const e=t.map.getView().getProjection();a=a.clone().transform(l,e),a=La(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 wu(Su,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 bu(t,e,i)-bu(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 ma(pe(n.getCoordinates())));const i=n||t.getGeometry();if(i&&"Point"===i.getType()&&t instanceof Tl&&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=me(c(ye(y(t,vu)),e.getView().getResolution()*this.pixelTolerance_,vu));o=this.rBush_.getInExtent(n)}if(o&&o.length>0){const a=o.sort(r)[0],l=a.segment;let h=Tu(t,a,i);const c=e.getPixelFromCoordinate(h);let u=J(n,c);if(s||u<=this.pixelTolerance_){const n={};if(n[Sn(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=$(c,t),s=$(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[Sn(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=Sn(o[t].geometry);i in d||(d[i]=!0,n[Sn(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?pe(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=_e(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=vc){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([t])=>t));const e=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new wu(Su,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,g,f=!1;for(s=t.length-1;s>=0;--s)r=t[s],d=r[0],g=Sn(d.feature),d.depth&&(g+="-"+d.depth.join("-")),g in e||(e[g]={}),0===r[1]?(e[g].right=d,e[g].index=d.index):1==r[1]&&(e[g].left=d,e[g].index=d.index+1);for(g in e){switch(u=e[g].right,l=e[g].left,a=e[g].index,c=a-1,d=void 0!==l?l:u,c<0&&(c=0),o=d.geometry,i=o.getCoordinates(),n=i,f=!1,o.getType()){case"MultiLineString":i[d.depth[0]].length>2&&(i[d.depth[0]].splice(a,1),f=!0);break;case"LineString":i.length>2&&(i.splice(a,1),f=!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),f=!0,0===a&&(n.pop(),n.push(n[0]),c=n.length-1))}if(f){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 f}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?_e(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(ol,this.handleExternalCollectionAdd_),this.featuresCollection_.removeEventListener(sl,this.handleExternalCollectionRemove_);for(const t of this.featuresCollection_.getArray())t.removeEventListener(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(_n,this.handleFeatureChange_)}else if(this.source_){this.source_.removeEventListener(Sl,this.handleSourceAdd_),this.source_.removeEventListener(Cl,this.handleSourceRemove_);for(const t of this.source_.getFeatures())t.removeEventListener(He,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(_n,this.handleFeatureChange_)}}};var Mu=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=zc(t,e);if(s){var a=Uc(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=zc(t,e);if(s){var a=Uc(s,n);a<o&&(o=a,r=i)}}),r>=0?{index:i+r,type:"midpoint"}:null}(t,n,i,e.length,o)};function Ru(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.olFeature,i=t.getState,r=t.onModifyEnd,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!==Mu(e,o,s,{x:a[0],y:a[1]})}}({map:e,getState:i}),s=new Pu({features:new hl([n]),style:function(){return[]},pixelTolerance:12,condition:o});e.addInteraction(s);var a=null;return s.on("modifystart",function(){"touch"!==i().interfaceType&&(a=i().vertices.map(function(t){return function(t){if(Array.isArray(t))return Ru(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 Ru(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)?Ru(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}))}),s.on("modifyend",function(){if("touch"!==i().interfaceType){var t=a;a=null,r(t)}}),{destroy:function(){e.removeInteraction(s)}}},ku=n(722);function Ou(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)||Au(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 Au(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}}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,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=Au(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}}}}(fu(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 g=r-h+1,f=u.start+g;return _u(l,u.path).splice(g,0,Ou(o)),a.setCoordinates(l.coordinates),{insertedIndex:f}}h+=d}}catch(t){c.e(t)}finally{c.f()}return null},Gu=function(t,e,n){var i=t.getGeometry(),r={type:i.getType(),coordinates:i.getCoordinates()},o=fu(r),s=pu(o,e);if(s){var a=_u(r,s.segment.path);a[s.localIdx]=Ou(n),s.segment.closed&&0===s.localIdx&&(a[a.length-1]=Ou(n)),i.setCoordinates(r.coordinates)}};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 Vu(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 Wu(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Vu(Object(n),!0).forEach(function(e){Xu(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Vu(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Xu(t,e,n){return(e=function(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+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nu(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 Yu=function(t){var e=t.container,n={dragStartCoord:null,dragStartIndex:null,vertexTouchDelta:null,targetTouchDelta:null,tapStart:null},i=Wu(Wu({},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,ku.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 g=i.getEventPixel({clientX:l.clientX,clientY:l.clientY}),f=zc(i,d),p=getComputedStyle(r),_=o({x:Number.parseFloat(p.left),y:Number.parseFloat(p.top)});a.dragStartCoord=function(t){if(Array.isArray(t))return Nu(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 Nu(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)?Nu(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:g[0]-f.x,y:g[1]-f.y},a.targetTouchDelta={x:g[0]-_.x,y:g[1]-_.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;if((0,ku.mt)(t.target)&&null!=l.dragStartIndex){t.preventDefault();var h=n.getEventPixel({clientX:t.touches[0].clientX,clientY:t.touches[0].clientY}),c=function(t,e){return t.getCoordinateFromPixel([e.x,e.y])}(n,{x:h[0]-l.vertexTouchDelta.x,y:h[1]-l.vertexTouchDelta.y}),u=a?a.apply(c):c;null==a||a.hideIndicator();var d=o(),g=d.olFeature,f=d.vertices;g&&(Gu(g,l.dragStartIndex,u),s({vertices:f.map(function(t,e){return e===l.dragStartIndex?u:t})}),(0,ku.Ox)(i,r({x:h[0]-l.targetTouchDelta.x,y:h[1]-l.targetTouchDelta.y})))}}(t,i)},s=function(t){return function(t,e){var n=e.getState,i=e.onVertexMoved,r=e.snap,o=e.drag;if(null==o.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(Mu(n,h.vertices,h.midpoints,{x:l[0],y:l[1]},24)),t.preventDefault()}}}(t,e),void(o.tapStart=null);o.tapStart=null,n().vertices[o.dragStartIndex]&&o.dragStartCoord&&i({vertexIndex:o.dragStartIndex,previousCoord:o.dragStartCoord}),null==r||r.hideIndicator(),o.dragStartCoord=null,o.dragStartIndex=null,o.vertexTouchDelta=null,o.targetTouchDelta=null,t.preventDefault()}(t,i)};return e.addEventListener("touchstart",r,{passive:!1}),e.addEventListener("touchmove",o,{passive:!1}),e.addEventListener("touchend",s,{passive:!1}),{isDragging:function(){return null!=n.dragStartIndex},destroy:function(){e.removeEventListener("touchstart",r),e.removeEventListener("touchmove",o),e.removeEventListener("touchend",s)}}},Bu=n(704);function zu(t){return function(t){if(Array.isArray(t))return qu(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 qu(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)?qu(t,e):void 0}}function qu(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 Zu=function(t){var e=t.map,n=t.snap,i=t.getState,r=t.setState,o=t.onInserted,s=t.onVertexMoved,a={start:null,index:null},l=function(t,o){var s=i(),a=s.selectedVertexIndex,l=s.vertices,h=s.olFeature;if(!h||a<0||!l[a])return null;var c=l[a],u=qc(e,c,t,o),d=n?n.apply(u):u;null==n||n.hideIndicator();var 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 qc(e,n,0===o?0:Math.sign(o)*c,0===s?0:Math.sign(s)*c)}return r}(n,e,c,u,d,t,o);return Gu(h,a,g),r({vertices:l.map(function(t,e){return e===a?g:t})}),{previousCoord:c,vertexIndex:a}};return{nudge:function(t){var s=i(),h=s.selectedVertexIndex,c=s.selectedVertexType,u=s.vertices,d=s.midpoints,g=s.olFeature;if(g){var f=t.shiftKey?$l.WQ.nudgeAmount:$l.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,-f],ArrowDown:[0,f],ArrowLeft:[-f,0],ArrowRight:[f,0]}[t.key],2),_=p[0],m=p[1];"midpoint"!==c?h<0||!u[h]||(a.start||(a.start=zu(u[h]),a.index=h),l(_,m)):function(t,s,l,h,c,u){var d=Du(t,s,l,h.length);if(d){o({insertedIndex:d.insertedIndex});var g=i().vertices,f=g[d.insertedIndex];if(f){a.start=zu(f),a.index=d.insertedIndex;var p=qc(e,f,c,u),_=n?n.apply(p):p;Gu(t,d.insertedIndex,_),r({selectedVertexIndex:d.insertedIndex,selectedVertexType:"vertex",vertices:g.map(function(t,e){return e===d.insertedIndex?_:t})})}}}(g,d,h,u,_,m)}},keyMove:a,nudgeByDelta:function(t,e,n){var i=n?$l.WQ.stepAmount:$l.WQ.nudgeAmount,r=l(t*i,e*i);r&&s({vertexIndex:r.vertexIndex,previousCoord:r.previousCoord})}}};function Ku(t){return function(t){if(Array.isArray(t))return Hu(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 Hu(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)?Hu(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 Hu(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 $u=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),Ju=new Set(["INPUT","TEXTAREA","BUTTON","SELECT","A"]),Qu=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=zc(t,t.getView().getCenter());if(s){var a=[].concat(Ku(r.map(function(e){return zc(t,e)})),Ku(o.map(function(e){return zc(t,e)}))).filter(Boolean).map(function(t){return[t.x,t.y]}),l=(0,Bu.cj)([s.x,s.y],a,void 0);n({selectedVertexIndex:l,selectedVertexType:l<r.length?"vertex":"midpoint"})}}}(e,n,i);else if($u.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(Ku(s),Ku(a)).map(function(t){return zc(e,t)}).filter(Boolean).map(function(t){return[t.x,t.y]}),c=o>=0?h[o]:(l=zc(e,e.getView().getCenter()))?[l.x,l.y]:null;if(c){var u=(0,Bu.cj)(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;Ju.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))}};function td(t){return function(t){if(Array.isArray(t))return nd(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ed(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 ed(t,e){if(t){if("string"==typeof t)return nd(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)?nd(t,e):void 0}}function nd(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 id=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=fu(o),a=pu(s,n);if(!a)return-1;var l=_u(o,a.segment.path);return l[a.localIdx]=td(i),a.segment.closed&&0===a.localIdx&&(l[l.length-1]=td(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=fu(r),s=pu(o,n);if(s){var a=_u(r,s.segment.path);a.splice(s.localIdx,1),s.segment.closed&&(a[a.length-1]=td(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=fu(o),a=pu(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=ed(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=_u(o,a.segment.path);return u.splice(a.localIdx,0,td(i)),a.segment.closed&&(u[u.length-1]=td(u[0])),r.setCoordinates(o.coordinates),n}(t,e);default:return-1}},rd="touch",od="vertex",sd="commit-move",ad="commit-insert",ld="commit-delete",hd={move_vertex:sd,insert_vertex:ad,delete_vertex:ld},cd={move_vertex:sd,insert_vertex:ld,delete_vertex:ad},ud=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(),g=function(t,e){var n=e,i=-1,r=new Il,o=new rl({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=mu(t).map(function(t,e){var n=new Tl({geometry:new ma(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),f=function(t,e){var n=e,i=-1,r=new Il,o=new rl({source:r,style:function(t){return t.get("vertexIndex")===i?null:[n]},zIndex:102});return t.addLayer(o),{update:function(t){r.clear(),gu(t).forEach(function(t,e){var n=new Tl({geometry:new ma(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 Il,i=new rl({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 Tl({geometry:new ma(c)});d.setStyle(u),n.addFeature(d)}}},remove:function(){n.clear(),t.removeLayer(i)}}}(e,function(){return n.styles}),_=yu({map:e,manager:n,store:h,olFeature:u,interfaceType:s,layers:{vertexLayer:f,midpointLayer:g,activeLayer:p}}),m=_.state,y=_.getState,v=_.setState,x=_.syncGeom,S=_.emitGeometryValidation,C=Fu({map:e,olFeature:u,getState:y,onModifyEnd:function(t){x();var e=t&&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}(t,m.vertices);e&&(c.push(e),S(hd[e.type],e.vertexIndex),v({selectedVertexIndex:e.vertexIndex,selectedVertexType:od}))}});x();var w={vertexLayer:f,midpointLayer:g,activeLayer:p},I=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,iu.De)({onChange:function(t,i){r=t,e.render(),n.emit(Qc.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}),b=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,g=function(t){return c({selectedVertexIndex:t,selectedVertexType:od})},f=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=(0,ku.DD)(n);(0,ku.ZP)(h,a);var c={scale:1,ox:0,oy:0},u=function(t){return{x:t.x*c.scale+c.ox,y:t.y*c.scale+c.oy}},d=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(c,{scale:o/s,ox:(i.left-r.left)/s,oy:(i.top-r.top)/s})},g=Yu({container:n,map:e,targetEl:h,olToCSS:u,cssToOl:function(t){return{x:(t.x-c.ox)/c.scale,y:(t.y-c.oy)/c.scale}},getState:i,setState:r,onVertexMoved:o,onTap:s,snap:l}),f=function(){var t=i(),n=t.selectedVertexIndex,r=t.vertices,o=t.interfaceType;if(n<0||!r[n]||"touch"!==o)(0,ku.$X)(h);else{var s=zc(e,r[n]);s?(0,ku.Ox)(h,u(s)):(0,ku.$X)(h)}},p=function(){var t=i(),e=t.selectedVertexIndex,n=t.interfaceType;e>=0&&!g.isDragging()&&"touch"===n&&f()};e.on("postrender",p);var _=function(){d(),e.once("postrender",f)};return e.on("change:size",_),d(),{updateTargetPosition:f,updateColors:function(t){(0,ku.ZP)(h,t)},hide:function(){(0,ku.$X)(h)},destroy:function(){e.un("change:size",_),e.un("postrender",p),g.destroy(),(0,ku.$X)(h)}}}({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(sd,e),g(e),f.updateTargetPosition()},onTap:function(t){if(t){if(t.type===od)return g(t.index),void f.updateTargetPosition();var e=Du(o,l.midpoints,t.index,l.vertices.length);e&&(s.push({type:"insert_vertex",vertexIndex:e.insertedIndex}),u(),d(ad,e.insertedIndex),g(e.insertedIndex),f.updateTargetPosition())}else c({selectedVertexIndex:-1,selectedVertexType:null})}});return a.setHooks({onDeselect:function(){return f.hide()},onUpdate:function(){l.interfaceType===rd&&f.updateTargetPosition()}}),f}({map:e,container:o,manager:n,snap:l,olFeature:u,undoStack:c,selection:_}),T=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!==od||o.selectedVertexIndex<0)){var t=function(t,e){var n=t.getGeometry(),i={type:n.getType(),coordinates:n.getCoordinates()},r=gu(i),o=fu(i),s=pu(o,e);if(!s)return null;var a=s.segment,l=a.closed?nu.n8.Polygon:nu.n8.LineString;if(a.length<=l)return null;var h=Ou(r[e]),c=_u(i,a.path);return c.splice(s.localIdx,1),a.closed&&(c[c.length-1]=Ou(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(ld,t.deletedIndex),s({selectedVertexIndex:-1,selectedVertexType:null}))}},doUndo:function(){var t=n.pop();if(t){var i=o.selectedVertexIndex,h=id(e,t);a(),l(cd[t.type],h);var c=i>=0?h:-1;s({selectedVertexIndex:c,selectedVertexType:c>=0?od:null}),i>=0&&c>=0&&o.interfaceType===rd&&r().updateTargetPosition()}}}}({olFeature:u,undoStack:c,selection:_,getTouchHandler:function(){return b}}),E=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 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=Zu({map:n,snap:i,getState:r,setState:o,onInserted:a,onVertexMoved:s}),d=u.nudge,g=u.keyMove,f=u.nudgeByDelta,p=null!==(e=n.getViewport().closest('[role="application"]'))&&void 0!==e?e:n.getViewport(),_=function(){return function(t){var e=document.activeElement;return!(!e||e===document.body)&&!t.contains(e)&&(Ju.has(e.tagName)||e.isContentEditable||e.hasAttribute("tabindex"))}(p)},m=Qu({map:n,getState:r,setState:o,nudge:d,keyMove:g,onUndo:h,onKeyboardActive:c,isFocused:_}),y=function(t){var e=t.snap,n=t.keyMove,i=t.onVertexMoved,r=t.onDeleted,o=t.isFocused;return function(t){o()||($u.has(t.key)&&n.start&&null!=n.index&&(null==e||e.hideIndicator(),i({vertexIndex:n.index,previousCoord:n.start}),n.start=null,n.index=null),"Delete"===t.key&&r())}}({snap:i,keyMove:g,onVertexMoved:s,onDeleted:l,isFocused:_});return globalThis.addEventListener("keydown",m,{capture:!0}),globalThis.addEventListener("keyup",y,{capture:!0}),{nudgeByDelta:f,destroy:function(){globalThis.removeEventListener("keydown",m,{capture:!0}),globalThis.removeEventListener("keyup",y,{capture:!0})}}}({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(sd,e),c({selectedVertexIndex:e,selectedVertexType:od})},onInserted:function(t){var e=t.insertedIndex;r.push({type:"insert_vertex",vertexIndex:e}),u(),d(ad,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:_,touchHandler:b,actions:T}),P=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 Mu(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:y,setState:v,touchHandler:b,deleteVertexButtonId:a,onDeleteVertex:T.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(tu,a);var l=function(){s.interfaceType!==rd||s.selectedVertexIndex<0||e.once("postrender",function(){return r.updateTargetPosition()})};return e.on("change:size",l),{destroy:function(){n.off(tu,a),e.un("change:size",l)}}}({map:e,manager:n,layers:w,selection:_,touchHandler:b,live:I});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=o.state,h=a.touchHandler;return{setInterfaceType:function(t){t!==l.interfaceType&&(l.interfaceType=t,t===rd?h.updateTargetPosition():h.hide())},done:function(){e.emit(Qc.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,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(),h.destroy(),a.keyboardHandler.destroy()}}}({manager:n,store:h,olFeature:u,originalFeatureStyle:d,selection:_,actions:T,parts:{touchHandler:b,keyboardHandler:E,pointerHandlers:P,modify:C,mapSync:M,layers:w,live:I}})};function dd(t){return dd="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},dd(t)}function gd(){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 fd(h,"_invoke",function(n,i,r){var o,a,l,h=0,c=r||[],u=!1,d={p:0,n:0,v:t,a:g,f:g.bind(t,4),d:function(e,n){return o=e,a=0,l=t,d.n=n,s}};function g(n,i){for(a=n,l=i,e=0;!u&&h&&!r&&e<c.length;e++){var r,o=c[e],g=d.p,f=o[2];n>3?(r=f===i)&&(l=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=t):o[0]<=g&&((r=n<2&&g<o[1])?(a=0,d.v=i,d.n=o[1]):g<f&&(r=n<3||o[0]>i||i>f)&&(o[4]=n,o[5]=i,d.n=f,a=0))}if(r||n>1)return s;throw u=!0,i}return function(r,c,f){if(h>1)throw TypeError("Generator is already running");for(u&&1===c&&g(c,f),a=c,l=f;(e=a<2?t:l)||!u;){o||(a?a<3?(a>1&&(d.n=-1),g(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]())):(fd(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,fd(t,r,"GeneratorFunction")),t.prototype=Object.create(u),t}return l.prototype=h,fd(u,"constructor",h),fd(h,"constructor",l),l.displayName="GeneratorFunction",fd(h,r,"GeneratorFunction"),fd(u),fd(u,r,"Generator"),fd(u,i,function(){return this}),fd(u,"toString",function(){return"[object Generator]"}),(gd=function(){return{w:o,m:d}})()}function fd(t,e,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(t){r=0}fd=function(t,e,n,i){function o(e,n){fd(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))},fd(t,e,n,i)}function pd(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 _d(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?pd(Object(n),!0).forEach(function(e){md(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pd(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function md(t,e,n){return(e=xd(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yd(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 vd(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,xd(i.key),i)}}function xd(t){var e=function(t){if("object"!=dd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=dd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==dd(e)?e:e+""}var Sd=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 Il,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=Kl.readFeature(t);return r.addFeature(n),n},get:function(t){var e=this.getOL(t);return e?Kl.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 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}}(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 Kl.writeFeatureObject(t)},fromGeoJSON:function(t){return Kl.readFeature(t)}},this.undoStack=(0,Hl.B)(function(t){return o.emit(Qc.k.UNDO_CHANGE,t)}),this.colors=(0,lh.$)(null,s),this.styles=ah(this.colors),this.snap=pc(e,null!==(n=s.snapLayers)&&void 0!==n?n:null,this.colors,null!==(i=s.snapRadius)&&void 0!==i?i:$l.vf.snapRadius),this._layer=new rl({source:this.store.source,style:this.styles.createFeatureStyle(),zIndex:100}),this._layer.set("layerId","draw"),e.addLayer(this._layer)},e=[{key:"setMapStyle",value:function(t){var e;this.colors=(0,lh.$)(t,this._pluginConfig),this.styles=ah(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(tu,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=gd().m(function t(e){var n,i,r,o,s,a,l=arguments;return gd().w(function(t){for(;;)switch(t.n){case 0:o=l.length>1&&void 0!==l[1]?l[1]:{},null===(n=this._modeInstance)||void 0===n||n.destroy(),this._modeInstance=null,this._mode=e,s="draw_polygon"===e||"draw_line"===e||"edit_vertex"===e,null===(i=this.snap)||void 0===i||i.setIndicatorActive(s),a=_d(_d({},o),{},{snap:this.snap}),"draw_polygon"===e||"draw_line"===e?this._modeInstance=lu({map:this._map,manager:this,options:a}):"edit_vertex"===e&&(this._modeInstance=ud({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){yd(o,i,r,s,a,"next",t)}function a(t){yd(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:"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(Qc.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&&vd(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,i}();function Cd(t){return Cd="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},Cd(t)}function wd(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 Id(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?wd(Object(n),!0).forEach(function(e){Td(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wd(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function bd(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,Ed(i.key),i)}}function Td(t,e,n){return(e=Ed(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ed(t){var e=function(t){if("object"!=Cd(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Cd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Cd(e)?e:e+""}var Pd=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),Td(this,"_snapEnabled",!1);var r=function(t){var e=t.mapProvider,n=t.events,i=t.eventBus,r=t.pluginConfig,o=void 0===r?{}:r,s=t.mapStyle,a=void 0===s?null:s,l=e.map,h=new Sd(l,o);a&&h.setMapStyle(a),e.draw=h;var c=function(t){var n;e.drawScale=null!==(n=$l.$y[t])&&void 0!==n?n:1};i.on(n.MAP_SET_SIZE,c);var u=function(t){h.setMapStyle(t)};return i.on(n.MAP_SET_STYLE,u),{manager:h,remove:function(){i.off(n.MAP_SET_SIZE,c),i.off(n.MAP_SET_STYLE,u),h.remove(),e.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=Id(Id({},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:"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){return this._manager.add(t)}},{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&&bd(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,g=null,f=function(){null!=d&&((0,o.WG)(d),d=null),g=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)},_=function(){var t,e;if(g){var n=g,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)}},m=function(){if(d=null,g){var t=g,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,_()}};return{update:function(t){var e=t.feature,n=t.context,i=void 0===n?{}:n,r=t.numVertices,s=t.onGeometryChange;g={feature:e,context:l(l({},i),{},{numVertices:r}),onGeometryChange:s},_(),"function"==typeof s&&null==d&&(d=(0,o.PW)(m))},reset:function(){f(),c=!1,u=null,a(!1,null),h(!1,null)},destroy:function(){f()}}}},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))},g=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,f=s(s({},i),{},{numVertices:o}),p=r(e,f);return p.valid?"function"!=typeof h?(u(),void d(!1,null)):(c={feature:e,context:f,onGeometryChange:h},void(null==a&&(a=l(g)))):(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()}}}}}]);