@defra/interactive-map 0.0.3-alpha → 0.0.4-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 (268) hide show
  1. package/README.md +16 -57
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/esm/index.js +1 -1
  4. package/dist/umd/im-core.js +1 -1
  5. package/dist/umd/index.js +1 -1
  6. package/docs/api/button-definition.md +176 -0
  7. package/docs/api/context.md +124 -0
  8. package/docs/api/control-definition.md +72 -0
  9. package/docs/api/icon-definition.md +28 -0
  10. package/docs/api/map-style-config.md +76 -0
  11. package/docs/api/marker-config.md +51 -0
  12. package/docs/api/panel-definition.md +117 -0
  13. package/docs/api/slots.md +25 -0
  14. package/docs/api.md +713 -0
  15. package/docs/architecture.md +139 -0
  16. package/docs/building-a-plugin.md +149 -0
  17. package/docs/getting-started.md +46 -0
  18. package/docs/govuk-prototype.md +0 -0
  19. package/docs/plugins/interact.md +205 -0
  20. package/docs/plugins/map-styles.md +84 -0
  21. package/docs/plugins/plugin-context.md +67 -0
  22. package/docs/plugins/plugin-descriptor.md +71 -0
  23. package/docs/plugins/plugin-manifest.md +118 -0
  24. package/docs/plugins/scale-bar.md +62 -0
  25. package/docs/plugins/search.md +162 -0
  26. package/docs/plugins.md +116 -0
  27. package/govuk-prototype-kit.config.json +7 -7
  28. package/package.json +14 -1
  29. package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -0
  30. package/plugins/beta/datasets/dist/esm/index.js +2 -0
  31. package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -0
  32. package/plugins/beta/datasets/dist/umd/index.js +2 -0
  33. package/plugins/{datasets → beta/datasets}/src/manifest.js +1 -1
  34. package/plugins/{datasets → beta/datasets}/src/mapLayers.js +1 -1
  35. package/plugins/{datasets → beta/datasets}/src/panels/Key.jsx +1 -1
  36. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -0
  37. package/plugins/beta/draw-ml/dist/esm/index.js +2 -0
  38. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -0
  39. package/plugins/beta/draw-ml/dist/umd/index.js +2 -0
  40. package/plugins/{draw-ml → beta/draw-ml}/src/api/editFeature.js +1 -1
  41. package/plugins/beta/draw-ml/src/api/merge.js +9 -0
  42. package/plugins/beta/draw-ml/src/api/newLine.js +43 -0
  43. package/plugins/{draw-ml → beta/draw-ml}/src/api/newPolygon.js +5 -5
  44. package/plugins/beta/draw-ml/src/api/split.js +81 -0
  45. package/plugins/{draw-ml → beta/draw-ml}/src/defaults.js +2 -0
  46. package/plugins/{draw-ml → beta/draw-ml}/src/events.js +105 -3
  47. package/plugins/{draw-ml → beta/draw-ml}/src/manifest.js +17 -11
  48. package/plugins/{draw-ml → beta/draw-ml}/src/mapboxDraw.js +51 -2
  49. package/plugins/{draw-ml → beta/draw-ml}/src/mapboxSnap.js +2 -0
  50. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +496 -0
  51. package/plugins/beta/draw-ml/src/modes/drawLineMode.js +18 -0
  52. package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +16 -0
  53. package/plugins/beta/draw-ml/src/modes/editVertexMode.js +792 -0
  54. package/plugins/{draw-ml → beta/draw-ml}/src/reducer.js +30 -2
  55. package/plugins/{draw-ml → beta/draw-ml}/src/styles.js +66 -36
  56. package/plugins/beta/draw-ml/src/undoStack.js +50 -0
  57. package/plugins/beta/draw-ml/src/utils/debounce.js +16 -0
  58. package/plugins/beta/draw-ml/src/utils/spatial.js +258 -0
  59. package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -0
  60. package/plugins/beta/frame/dist/esm/index.js +2 -0
  61. package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -0
  62. package/plugins/beta/frame/dist/umd/index.js +2 -0
  63. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
  64. package/plugins/beta/map-styles/dist/esm/index.js +2 -0
  65. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
  66. package/plugins/beta/map-styles/dist/umd/index.js +2 -0
  67. package/plugins/{map-styles → beta/map-styles}/src/MapStyles.jsx +1 -1
  68. package/plugins/{map-styles → beta/map-styles}/src/manifest.js +8 -10
  69. package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -0
  70. package/plugins/beta/scale-bar/dist/esm/index.js +2 -0
  71. package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -0
  72. package/plugins/beta/scale-bar/dist/umd/index.js +2 -0
  73. package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -0
  74. package/plugins/beta/use-location/dist/esm/index.js +2 -0
  75. package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -0
  76. package/plugins/beta/use-location/dist/umd/index.js +2 -0
  77. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  78. package/plugins/interact/dist/esm/index.js +1 -1
  79. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  80. package/plugins/interact/dist/umd/index.js +1 -1
  81. package/plugins/interact/src/InteractInit.test.js +97 -0
  82. package/plugins/interact/src/api/clear.test.js +18 -0
  83. package/plugins/interact/src/api/disable.test.js +12 -0
  84. package/plugins/interact/src/api/enable.test.js +48 -0
  85. package/plugins/interact/src/api/selectFeature.test.js +33 -0
  86. package/plugins/interact/src/api/unselectFeature.test.js +33 -0
  87. package/plugins/interact/src/defaults.js +1 -0
  88. package/plugins/interact/src/events.test.js +151 -0
  89. package/plugins/interact/src/hooks/useHighlightSync.test.js +212 -0
  90. package/plugins/interact/src/hooks/useInteractionHandlers.js +14 -7
  91. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +260 -0
  92. package/plugins/interact/src/index.test.js +22 -0
  93. package/plugins/interact/src/manifest.js +1 -1
  94. package/plugins/interact/src/manifest.test.js +94 -0
  95. package/plugins/interact/src/reducer.js +10 -1
  96. package/plugins/interact/src/reducer.test.js +142 -0
  97. package/plugins/interact/src/utils/buildStylesMap.test.js +57 -0
  98. package/plugins/interact/src/utils/featureQueries.test.js +56 -0
  99. package/plugins/interact/src/utils/turfHelpers.js +30 -0
  100. package/plugins/interact/src/utils/turfHelpers.test.js +30 -0
  101. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  102. package/plugins/search/dist/esm/index.js +1 -1
  103. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  104. package/plugins/search/dist/umd/index.js +1 -1
  105. package/plugins/search/src/utils/parseOsNamesResults.js +3 -7
  106. package/providers/{esri → beta/esri}/src/mapEvents.js +2 -2
  107. package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +2 -0
  108. package/providers/beta/open-names/dist/esm/index.js +2 -0
  109. package/providers/beta/open-names/dist/umd/im-reverse-geocode.js +2 -0
  110. package/providers/beta/open-names/dist/umd/index.js +2 -0
  111. package/providers/maplibre/dist/esm/im-maplibre-framework.js +1 -1
  112. package/providers/maplibre/dist/esm/im-maplibre-framework.js.LICENSE.txt +1 -1
  113. package/providers/maplibre/dist/esm/im-maplibre-legacy-framework.js +1 -1
  114. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  115. package/providers/maplibre/dist/esm/index.js +1 -1
  116. package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
  117. package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +1 -1
  118. package/providers/maplibre/dist/umd/im-maplibre-legacy-framework.js +1 -1
  119. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  120. package/providers/maplibre/dist/umd/index.js +1 -1
  121. package/providers/maplibre/src/index.js +14 -1
  122. package/providers/maplibre/src/maplibreProvider.js +127 -0
  123. package/sonar-project.properties +1 -1
  124. package/src/App/hooks/useInterfaceAPI.js +24 -1
  125. package/src/App/renderer/mapButtons.js +1 -1
  126. package/src/App/store/appActionsMap.js +22 -1
  127. package/src/InteractiveMap/InteractiveMap.js +114 -6
  128. package/src/config/defaults.js +29 -20
  129. package/src/config/events.js +110 -4
  130. package/src/index.js +5 -2
  131. package/src/scss/tools/_border-focus.scss +20 -4
  132. package/src/types.js +585 -0
  133. package/webpack.esm.mjs +8 -8
  134. package/webpack.umd.mjs +8 -8
  135. package/plugins/datasets/dist/esm/im-datasets-plugin.js +0 -1
  136. package/plugins/datasets/dist/esm/index.js +0 -2
  137. package/plugins/datasets/dist/umd/im-datasets-plugin.js +0 -1
  138. package/plugins/datasets/dist/umd/index.js +0 -2
  139. package/plugins/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
  140. package/plugins/draw-ml/dist/esm/index.js +0 -2
  141. package/plugins/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
  142. package/plugins/draw-ml/dist/umd/index.js +0 -2
  143. package/plugins/draw-ml/src/modes/drawVertexMode.js +0 -275
  144. package/plugins/draw-ml/src/modes/editVertexMode.js +0 -426
  145. package/plugins/draw-ml/src/utils.js +0 -102
  146. package/plugins/frame/dist/esm/im-frame-plugin.js +0 -1
  147. package/plugins/frame/dist/esm/index.js +0 -2
  148. package/plugins/frame/dist/umd/im-frame-plugin.js +0 -1
  149. package/plugins/frame/dist/umd/index.js +0 -2
  150. package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
  151. package/plugins/map-styles/dist/esm/index.js +0 -2
  152. package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
  153. package/plugins/map-styles/dist/umd/index.js +0 -2
  154. package/plugins/scale-bar/dist/esm/im-scale-bar-plugin.js +0 -1
  155. package/plugins/scale-bar/dist/esm/index.js +0 -2
  156. package/plugins/scale-bar/dist/umd/im-scale-bar-plugin.js +0 -1
  157. package/plugins/scale-bar/dist/umd/index.js +0 -2
  158. package/plugins/use-location/dist/esm/im-use-location-plugin.js +0 -1
  159. package/plugins/use-location/dist/esm/index.js +0 -2
  160. package/plugins/use-location/dist/umd/im-use-location-plugin.js +0 -1
  161. package/plugins/use-location/dist/umd/index.js +0 -2
  162. package/providers/open-names/dist/esm/im-reverse-geocode.js +0 -2
  163. package/providers/open-names/dist/esm/index.js +0 -2
  164. package/providers/open-names/dist/umd/im-reverse-geocode.js +0 -2
  165. package/providers/open-names/dist/umd/index.js +0 -2
  166. /package/docs/architecture/{ARCHITECTURE_DIAGRAMS.md → architecture-diagrams.md} +0 -0
  167. /package/plugins/{datasets → beta/datasets}/dist/css/index.css +0 -0
  168. /package/plugins/{datasets → beta/datasets}/dist/esm/index.js.LICENSE.txt +0 -0
  169. /package/plugins/{datasets → beta/datasets}/dist/umd/index.js.LICENSE.txt +0 -0
  170. /package/plugins/{datasets → beta/datasets}/src/DatasetsInit.jsx +0 -0
  171. /package/plugins/{datasets → beta/datasets}/src/api/addDataset.js +0 -0
  172. /package/plugins/{datasets → beta/datasets}/src/api/hideDataset.js +0 -0
  173. /package/plugins/{datasets → beta/datasets}/src/api/hideFeatures.js +0 -0
  174. /package/plugins/{datasets → beta/datasets}/src/api/removeDataset.js +0 -0
  175. /package/plugins/{datasets → beta/datasets}/src/api/showDataset.js +0 -0
  176. /package/plugins/{datasets → beta/datasets}/src/api/showFeatures.js +0 -0
  177. /package/plugins/{datasets → beta/datasets}/src/datasets.js +0 -0
  178. /package/plugins/{datasets → beta/datasets}/src/datasets.scss +0 -0
  179. /package/plugins/{datasets → beta/datasets}/src/defaults.js +0 -0
  180. /package/plugins/{datasets → beta/datasets}/src/handleSetMapStyle.js +0 -0
  181. /package/plugins/{datasets → beta/datasets}/src/index.js +0 -0
  182. /package/plugins/{datasets → beta/datasets}/src/panels/Key.module.scss +0 -0
  183. /package/plugins/{datasets → beta/datasets}/src/panels/Layers.jsx +0 -0
  184. /package/plugins/{datasets → beta/datasets}/src/panels/Layers.module.scss +0 -0
  185. /package/plugins/{datasets → beta/datasets}/src/reducer.js +0 -0
  186. /package/plugins/{datasets → beta/datasets}/src/utils/bbox.js +0 -0
  187. /package/plugins/{datasets → beta/datasets}/src/utils/debounce.js +0 -0
  188. /package/plugins/{datasets → beta/datasets}/src/utils/filters.js +0 -0
  189. /package/plugins/{draw-es → beta/draw-es}/src/DrawInit.jsx +0 -0
  190. /package/plugins/{draw-es → beta/draw-es}/src/api/addFeature.js +0 -0
  191. /package/plugins/{draw-es → beta/draw-es}/src/api/deleteFeature.js +0 -0
  192. /package/plugins/{draw-es → beta/draw-es}/src/api/editFeature.js +0 -0
  193. /package/plugins/{draw-es → beta/draw-es}/src/api/newPolygon.js +0 -0
  194. /package/plugins/{draw-es → beta/draw-es}/src/events.js +0 -0
  195. /package/plugins/{draw-es → beta/draw-es}/src/graphic.js +0 -0
  196. /package/plugins/{draw-es → beta/draw-es}/src/index.js +0 -0
  197. /package/plugins/{draw-es → beta/draw-es}/src/manifest.js +0 -0
  198. /package/plugins/{draw-es → beta/draw-es}/src/reducer.js +0 -0
  199. /package/plugins/{draw-es → beta/draw-es}/src/sketchViewModel.js +0 -0
  200. /package/plugins/{draw-ml → beta/draw-ml}/dist/css/index.css +0 -0
  201. /package/plugins/{draw-ml → beta/draw-ml}/dist/esm/index.js.LICENSE.txt +0 -0
  202. /package/plugins/{draw-ml → beta/draw-ml}/dist/umd/index.js.LICENSE.txt +0 -0
  203. /package/plugins/{draw-ml → beta/draw-ml}/src/DrawInit.jsx +0 -0
  204. /package/plugins/{draw-ml → beta/draw-ml}/src/api/addFeature.js +0 -0
  205. /package/plugins/{draw-ml → beta/draw-ml}/src/api/deleteFeature.js +0 -0
  206. /package/plugins/{draw-ml → beta/draw-ml}/src/draw.scss +0 -0
  207. /package/plugins/{draw-ml → beta/draw-ml}/src/index.js +0 -0
  208. /package/plugins/{draw-ml → beta/draw-ml}/src/modes/disabledMode.js +0 -0
  209. /package/plugins/{draw-ml/src → beta/draw-ml/src/utils}/snapHelpers.js +0 -0
  210. /package/plugins/{frame → beta/frame}/dist/css/index.css +0 -0
  211. /package/plugins/{frame → beta/frame}/dist/esm/index.js.LICENSE.txt +0 -0
  212. /package/plugins/{frame → beta/frame}/dist/umd/index.js.LICENSE.txt +0 -0
  213. /package/plugins/{frame → beta/frame}/package.json +0 -0
  214. /package/plugins/{frame → beta/frame}/src/Frame.jsx +0 -0
  215. /package/plugins/{frame → beta/frame}/src/FrameInit.jsx +0 -0
  216. /package/plugins/{frame → beta/frame}/src/api/addFrame.js +0 -0
  217. /package/plugins/{frame → beta/frame}/src/api/editFeature.js +0 -0
  218. /package/plugins/{frame → beta/frame}/src/config.js +0 -0
  219. /package/plugins/{frame → beta/frame}/src/frame.scss +0 -0
  220. /package/plugins/{frame → beta/frame}/src/index.js +0 -0
  221. /package/plugins/{frame → beta/frame}/src/manifest.js +0 -0
  222. /package/plugins/{frame → beta/frame}/src/reducer.js +0 -0
  223. /package/plugins/{frame → beta/frame}/src/utils.js +0 -0
  224. /package/plugins/{map-styles → beta/map-styles}/dist/css/index.css +0 -0
  225. /package/plugins/{map-styles → beta/map-styles}/dist/esm/index.js.LICENSE.txt +0 -0
  226. /package/plugins/{map-styles → beta/map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
  227. /package/plugins/{map-styles → beta/map-styles}/src/MapStylesInit.jsx +0 -0
  228. /package/plugins/{map-styles → beta/map-styles}/src/config.js +0 -0
  229. /package/plugins/{map-styles → beta/map-styles}/src/index.js +0 -0
  230. /package/plugins/{map-styles → beta/map-styles}/src/mapStyles.scss +0 -0
  231. /package/plugins/{scale-bar → beta/scale-bar}/dist/css/index.css +0 -0
  232. /package/plugins/{scale-bar → beta/scale-bar}/dist/esm/index.js.LICENSE.txt +0 -0
  233. /package/plugins/{scale-bar → beta/scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
  234. /package/plugins/{scale-bar → beta/scale-bar}/package.json +0 -0
  235. /package/plugins/{scale-bar → beta/scale-bar}/src/ScaleBar.jsx +0 -0
  236. /package/plugins/{scale-bar → beta/scale-bar}/src/ScaleBar.test.jsx +0 -0
  237. /package/plugins/{scale-bar → beta/scale-bar}/src/index.js +0 -0
  238. /package/plugins/{scale-bar → beta/scale-bar}/src/index.test.js +0 -0
  239. /package/plugins/{scale-bar → beta/scale-bar}/src/manifest.js +0 -0
  240. /package/plugins/{scale-bar → beta/scale-bar}/src/scaleBar.scss +0 -0
  241. /package/plugins/{scale-bar → beta/scale-bar}/src/utils.js +0 -0
  242. /package/plugins/{scale-bar → beta/scale-bar}/src/utils.test.js +0 -0
  243. /package/plugins/{use-location → beta/use-location}/dist/esm/index.js.LICENSE.txt +0 -0
  244. /package/plugins/{use-location → beta/use-location}/dist/umd/index.js.LICENSE.txt +0 -0
  245. /package/plugins/{use-location → beta/use-location}/src/UseLocation.jsx +0 -0
  246. /package/plugins/{use-location → beta/use-location}/src/UseLocationInit.jsx +0 -0
  247. /package/plugins/{use-location → beta/use-location}/src/defaults.js +0 -0
  248. /package/plugins/{use-location → beta/use-location}/src/events.js +0 -0
  249. /package/plugins/{use-location → beta/use-location}/src/index.js +0 -0
  250. /package/plugins/{use-location → beta/use-location}/src/manifest.js +0 -0
  251. /package/plugins/{use-location → beta/use-location}/src/reducer.js +0 -0
  252. /package/providers/{esri → beta/esri}/src/appEvents.js +0 -0
  253. /package/providers/{esri → beta/esri}/src/defaults.js +0 -0
  254. /package/providers/{esri → beta/esri}/src/esriProvider.js +0 -0
  255. /package/providers/{esri → beta/esri}/src/esriProvider.scss +0 -0
  256. /package/providers/{esri → beta/esri}/src/index.js +0 -0
  257. /package/providers/{esri → beta/esri}/src/utils/coords.js +0 -0
  258. /package/providers/{esri → beta/esri}/src/utils/detectWebGL.js +0 -0
  259. /package/providers/{esri → beta/esri}/src/utils/esriFixes.js +0 -0
  260. /package/providers/{esri → beta/esri}/src/utils/query.js +0 -0
  261. /package/providers/{esri → beta/esri}/src/utils/spatial.js +0 -0
  262. /package/providers/{open-names → beta/open-names}/dist/esm/im-reverse-geocode.js.LICENSE.txt +0 -0
  263. /package/providers/{open-names → beta/open-names}/dist/esm/index.js.LICENSE.txt +0 -0
  264. /package/providers/{open-names → beta/open-names}/dist/umd/im-reverse-geocode.js.LICENSE.txt +0 -0
  265. /package/providers/{open-names → beta/open-names}/dist/umd/index.js.LICENSE.txt +0 -0
  266. /package/providers/{open-names → beta/open-names}/src/index.js +0 -0
  267. /package/providers/{open-names → beta/open-names}/src/reverseGeocode.js +0 -0
  268. /package/providers/{open-names → beta/open-names}/src/utils/mapToLocationModel.js +0 -0
@@ -1 +0,0 @@
1
- export const __webpack_id__="im-draw-ml-plugin";export const __webpack_ids__=["im-draw-ml-plugin"];export const __webpack_modules__={"./node_modules/@mapbox/geojson-area/index.js":(e,t,r)=>{var n=r("./node_modules/wgs84/index.js");function o(e){var t=0;if(e&&e.length>0){t+=Math.abs(i(e[0]));for(var r=1;r<e.length;r++)t-=Math.abs(i(e[r]))}return t}function i(e){var t,r,o,i,s,u,c=0,l=e.length;if(l>2){for(u=0;u<l;u++)u===l-2?(o=l-2,i=l-1,s=0):u===l-1?(o=l-1,i=0,s=1):(o=u,i=u+1,s=u+2),t=e[o],r=e[i],c+=(a(e[s][0])-a(t[0]))*Math.sin(a(r[1]));c=c*n.RADIUS*n.RADIUS/2}return c}function a(e){return e*Math.PI/180}e.exports.geometry=function e(t){var r,n=0;switch(t.type){case"Polygon":return o(t.coordinates);case"MultiPolygon":for(r=0;r<t.coordinates.length;r++)n+=o(t.coordinates[r]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(r=0;r<t.geometries.length;r++)n+=e(t.geometries[r]);return n}},e.exports.ring=i},"./node_modules/@mapbox/geojson-normalize/index.js":e=>{e.exports=function(e){if(!e||!e.type)return null;var r=t[e.type];return r?"geometry"===r?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:e}]}:"feature"===r?{type:"FeatureCollection",features:[e]}:"featurecollection"===r?e:void 0:null};var t={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},"./node_modules/@turf/bbox/dist/cjs/index.cjs":(e,t,r)=>{var n=r("./node_modules/@turf/meta/dist/cjs/index.cjs");var o=function(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const r=[1/0,1/0,-1/0,-1/0];return n.coordEach.call(void 0,e,e=>{r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])}),r};t.Ay=o},"./node_modules/@turf/helpers/dist/cjs/index.cjs":(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var r=6371008.8,n={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*r,kilometers:6371.0088,kilometres:6371.0088,meters:r,metres:r,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:r/1852,radians:1,yards:6967335.223679999},o={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:2.9155334959812285e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046};function i(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function a(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!y(e[0])||!y(e[1]))throw new Error("coordinates must contain numbers");return i({type:"Point",coordinates:e},t,r)}function s(e,t,r={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return i({type:"Polygon",coordinates:e},t,r)}function u(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return i({type:"LineString",coordinates:e},t,r)}function c(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function l(e,t,r={}){return i({type:"MultiLineString",coordinates:e},t,r)}function d(e,t,r={}){return i({type:"MultiPoint",coordinates:e},t,r)}function p(e,t,r={}){return i({type:"MultiPolygon",coordinates:e},t,r)}function f(e,t="kilometers"){const r=n[t];if(!r)throw new Error(t+" units is invalid");return e*r}function h(e,t="kilometers"){const r=n[t];if(!r)throw new Error(t+" units is invalid");return e/r}function g(e){return e%(2*Math.PI)*180/Math.PI}function y(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}t.areaFactors=o,t.azimuthToBearing=function(e){return(e%=360)>180?e-360:e<-180?e+360:e},t.bearingToAzimuth=function(e){let t=e%360;return t<0&&(t+=360),t},t.convertArea=function(e,t="meters",r="kilometers"){if(!(e>=0))throw new Error("area must be a positive number");const n=o[t];if(!n)throw new Error("invalid original units");const i=o[r];if(!i)throw new Error("invalid final units");return e/n*i},t.convertLength=function(e,t="kilometers",r="kilometers"){if(!(e>=0))throw new Error("length must be a positive number");return f(h(e,t),r)},t.degreesToRadians=function(e){return e%360*Math.PI/180},t.earthRadius=r,t.factors=n,t.feature=i,t.featureCollection=c,t.geometry=function(e,t,r={}){switch(e){case"Point":return a(t).geometry;case"LineString":return u(t).geometry;case"Polygon":return s(t).geometry;case"MultiPoint":return d(t).geometry;case"MultiLineString":return l(t).geometry;case"MultiPolygon":return p(t).geometry;default:throw new Error(e+" is invalid")}},t.geometryCollection=function(e,t,r={}){return i({type:"GeometryCollection",geometries:e},t,r)},t.isNumber=y,t.isObject=function(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)},t.lengthToDegrees=function(e,t){return g(h(e,t))},t.lengthToRadians=h,t.lineString=u,t.lineStrings=function(e,t,r={}){return c(e.map(e=>u(e,t)),r)},t.multiLineString=l,t.multiPoint=d,t.multiPolygon=p,t.point=a,t.points=function(e,t,r={}){return c(e.map(e=>a(e,t)),r)},t.polygon=s,t.polygons=function(e,t,r={}){return c(e.map(e=>s(e,t)),r)},t.radiansToDegrees=g,t.radiansToLength=f,t.round=function(e,t=0){if(t&&!(t>=0))throw new Error("precision must be a positive number");const r=Math.pow(10,t||0);return Math.round(e*r)/r},t.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(e=>{if(!y(e))throw new Error("bbox must only contain numbers")})},t.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},"./node_modules/@turf/meta/dist/cjs/index.cjs":(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=r("./node_modules/@turf/helpers/dist/cjs/index.cjs");function o(e,t,r){if(null!==e)for(var n,i,a,s,u,c,l,d,p=0,f=0,h=e.type,g="FeatureCollection"===h,y="Feature"===h,m=g?e.features.length:1,v=0;v<m;v++){u=(d=!!(l=g?e.features[v].geometry:y?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var E=0,S=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var w=s.type;switch(p=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(c,f,v,E,S))return!1;f++,E++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,E,S))return!1;f++,"MultiPoint"===w&&E++}"LineString"===w&&E++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-p;i++){if(!1===t(c[n][i],f,v,E,S))return!1;f++}"MultiLineString"===w&&E++,"Polygon"===w&&S++}"Polygon"===w&&E++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(S=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-p;a++){if(!1===t(c[n][i][a],f,v,E,S))return!1;f++}S++}E++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,g=f?e.features.length:1;for(r=0;r<g;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}function u(e,t){s(e,function(e,r,o,i,a){var s,u=null===e?null:e.type;switch(u){case null:case"Point":case"LineString":case"Polygon":return!1!==t(n.feature.call(void 0,e,o,{bbox:i,id:a}),r,0)&&void 0}switch(u){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<e.coordinates.length;c++){var l={type:s,coordinates:e.coordinates[c]};if(!1===t(n.feature.call(void 0,l,o),r,c))return!1}})}function c(e,t){u(e,function(e,r,i){var a=0;if(e.geometry){var s=e.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var u,c=0,l=0,d=0;return!1!==o(e,function(o,s,p,f,h){if(void 0===u||r>c||f>l||h>d)return u=o,c=r,l=f,d=h,void(a=0);var g=n.lineString.call(void 0,[u,o],e.properties);if(!1===t(g,r,i,h,a))return!1;a++,u=o})&&void 0}}})}function l(e,t){if(!e)throw new Error("geojson is required");u(e,function(e,r,o){if(null!==e.geometry){var i=e.geometry.type,a=e.geometry.coordinates;switch(i){case"LineString":if(!1===t(e,r,o,0,0))return!1;break;case"Polygon":for(var s=0;s<a.length;s++)if(!1===t(n.lineString.call(void 0,a[s],e.properties),r,o,s))return!1}}})}t.coordAll=function(e){var t=[];return o(e,function(e){t.push(e)}),t},t.coordEach=o,t.coordReduce=function(e,t,r,n){var i=r;return o(e,function(e,n,o,a,s){i=0===n&&void 0===r?e:t(i,e,n,o,a,s)},n),i},t.featureEach=a,t.featureReduce=function(e,t,r){var n=r;return a(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.findPoint=function(e,t){if(t=t||{},!n.isObject.call(void 0,t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.coordIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":return n.point.call(void 0,c,u,t);case"MultiPoint":return i<0&&(i=c.length+i),n.point.call(void 0,c[i],u,t);case"LineString":return s<0&&(s=c.length+s),n.point.call(void 0,c[s],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s),n.point.call(void 0,c[a][s],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),n.point.call(void 0,c[i][s],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s),n.point.call(void 0,c[i][a][s],u,t)}throw new Error("geojson is invalid")},t.findSegment=function(e,t){if(t=t||{},!n.isObject.call(void 0,t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.segmentIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),n.lineString.call(void 0,[c[s],c[s+1]],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s-1),n.lineString.call(void 0,[c[a][s],c[a][s+1]],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),n.lineString.call(void 0,[c[i][s],c[i][s+1]],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s-1),n.lineString.call(void 0,[c[i][a][s],c[i][a][s+1]],u,t)}throw new Error("geojson is invalid")},t.flattenEach=u,t.flattenReduce=function(e,t,r){var n=r;return u(e,function(e,o,i){n=0===o&&0===i&&void 0===r?e:t(n,e,o,i)}),n},t.geomEach=s,t.geomReduce=function(e,t,r){var n=r;return s(e,function(e,o,i,a,s){n=0===o&&void 0===r?e:t(n,e,o,i,a,s)}),n},t.lineEach=l,t.lineReduce=function(e,t,r){var n=r;return l(e,function(e,o,i,a){n=0===o&&void 0===r?e:t(n,e,o,i,a)}),n},t.propEach=i,t.propReduce=function(e,t,r){var n=r;return i(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.segmentEach=c,t.segmentReduce=function(e,t,r){var n=r,o=!1;return c(e,function(e,i,a,s,u){n=!1===o&&void 0===r?e:t(n,e,i,a,s,u),o=!0}),n}},"./node_modules/fast-deep-equal/index.js":e=>{e.exports=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,o,i;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(o=n;0!==o--;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(i=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(o=n;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=n;0!==o--;){var a=i[o];if(!e(t[a],r[a]))return!1}return!0}return t!=t&&r!=r}},"./node_modules/geojson-rbush/index.js":(e,t,r)=>{var n=r("./node_modules/rbush/rbush.min.js"),o=r("./node_modules/geojson-rbush/node_modules/@turf/helpers/dist/js/index.js"),i=r("./node_modules/geojson-rbush/node_modules/@turf/meta/dist/js/index.js"),a=r("./node_modules/@turf/bbox/dist/cjs/index.cjs").Ay,s=i.featureEach,u=(i.coordEach,o.polygon,o.featureCollection);function c(e){var t=new n(e);return t.insert=function(e){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:a(e),n.prototype.insert.call(this,e)},t.load=function(e){var t=[];return Array.isArray(e)?e.forEach(function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:a(e),t.push(e)}):s(e,function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:a(e),t.push(e)}),n.prototype.load.call(this,t)},t.remove=function(e,t){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:a(e),n.prototype.remove.call(this,e,t)},t.clear=function(){return n.prototype.clear.call(this)},t.search=function(e){var t=n.prototype.search.call(this,this.toBBox(e));return u(t)},t.collides=function(e){return n.prototype.collides.call(this,this.toBBox(e))},t.all=function(){var e=n.prototype.all.call(this);return u(e)},t.toJSON=function(){return n.prototype.toJSON.call(this)},t.fromJSON=function(e){return n.prototype.fromJSON.call(this,e)},t.toBBox=function(e){var t;if(e.bbox)t=e.bbox;else if(Array.isArray(e)&&4===e.length)t=e;else if(Array.isArray(e)&&6===e.length)t=[e[0],e[1],e[3],e[4]];else if("Feature"===e.type)t=a(e);else{if("FeatureCollection"!==e.type)throw new Error("invalid geojson");t=a(e)}return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}},t}e.exports=c,e.exports.default=c},"./node_modules/geojson-rbush/node_modules/@turf/helpers/dist/js/index.js":(e,t)=>{function r(e,t,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function n(e,t,n){if(void 0===n&&(n={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(e[0])||!f(e[1]))throw new Error("coordinates must contain numbers");return r({type:"Point",coordinates:e},t,n)}function o(e,t,n){void 0===n&&(n={});for(var o=0,i=e;o<i.length;o++){var a=i[o];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return r({type:"Polygon",coordinates:e},t,n)}function i(e,t,n){if(void 0===n&&(n={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return r({type:"LineString",coordinates:e},t,n)}function a(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function s(e,t,n){return void 0===n&&(n={}),r({type:"MultiLineString",coordinates:e},t,n)}function u(e,t,n){return void 0===n&&(n={}),r({type:"MultiPoint",coordinates:e},t,n)}function c(e,t,n){return void 0===n&&(n={}),r({type:"MultiPolygon",coordinates:e},t,n)}function l(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e*n}function d(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e/n}function p(e){return e%(2*Math.PI)*180/Math.PI}function f(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.earthRadius=6371008.8,t.factors={centimeters:100*t.earthRadius,centimetres:100*t.earthRadius,degrees:t.earthRadius/111325,feet:3.28084*t.earthRadius,inches:39.37*t.earthRadius,kilometers:t.earthRadius/1e3,kilometres:t.earthRadius/1e3,meters:t.earthRadius,metres:t.earthRadius,miles:t.earthRadius/1609.344,millimeters:1e3*t.earthRadius,millimetres:1e3*t.earthRadius,nauticalmiles:t.earthRadius/1852,radians:1,yards:1.0936*t.earthRadius},t.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/t.earthRadius,yards:1.0936133},t.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046},t.feature=r,t.geometry=function(e,t,r){switch(void 0===r&&(r={}),e){case"Point":return n(t).geometry;case"LineString":return i(t).geometry;case"Polygon":return o(t).geometry;case"MultiPoint":return u(t).geometry;case"MultiLineString":return s(t).geometry;case"MultiPolygon":return c(t).geometry;default:throw new Error(e+" is invalid")}},t.point=n,t.points=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return n(e,t)}),r)},t.polygon=o,t.polygons=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return o(e,t)}),r)},t.lineString=i,t.lineStrings=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return i(e,t)}),r)},t.featureCollection=a,t.multiLineString=s,t.multiPoint=u,t.multiPolygon=c,t.geometryCollection=function(e,t,n){return void 0===n&&(n={}),r({type:"GeometryCollection",geometries:e},t,n)},t.round=function(e,t){if(void 0===t&&(t=0),t&&!(t>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,t||0);return Math.round(e*r)/r},t.radiansToLength=l,t.lengthToRadians=d,t.lengthToDegrees=function(e,t){return p(d(e,t))},t.bearingToAzimuth=function(e){var t=e%360;return t<0&&(t+=360),t},t.radiansToDegrees=p,t.degreesToRadians=function(e){return e%360*Math.PI/180},t.convertLength=function(e,t,r){if(void 0===t&&(t="kilometers"),void 0===r&&(r="kilometers"),!(e>=0))throw new Error("length must be a positive number");return l(d(e,t),r)},t.convertArea=function(e,r,n){if(void 0===r&&(r="meters"),void 0===n&&(n="kilometers"),!(e>=0))throw new Error("area must be a positive number");var o=t.areaFactors[r];if(!o)throw new Error("invalid original units");var i=t.areaFactors[n];if(!i)throw new Error("invalid final units");return e/o*i},t.isNumber=f,t.isObject=function(e){return!!e&&e.constructor===Object},t.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(function(e){if(!f(e))throw new Error("bbox must only contain numbers")})},t.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},"./node_modules/geojson-rbush/node_modules/@turf/meta/dist/js/index.js":(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=r("./node_modules/geojson-rbush/node_modules/@turf/helpers/dist/js/index.js");function o(e,t,r){if(null!==e)for(var n,i,a,s,u,c,l,d,p=0,f=0,h=e.type,g="FeatureCollection"===h,y="Feature"===h,m=g?e.features.length:1,v=0;v<m;v++){u=(d=!!(l=g?e.features[v].geometry:y?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var E=0,S=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var w=s.type;switch(p=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(c,f,v,E,S))return!1;f++,E++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,E,S))return!1;f++,"MultiPoint"===w&&E++}"LineString"===w&&E++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-p;i++){if(!1===t(c[n][i],f,v,E,S))return!1;f++}"MultiLineString"===w&&E++,"Polygon"===w&&S++}"Polygon"===w&&E++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(S=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-p;a++){if(!1===t(c[n][i][a],f,v,E,S))return!1;f++}S++}E++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,g=f?e.features.length:1;for(r=0;r<g;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}function u(e,t){s(e,function(e,r,o,i,a){var s,u=null===e?null:e.type;switch(u){case null:case"Point":case"LineString":case"Polygon":return!1!==t(n.feature(e,o,{bbox:i,id:a}),r,0)&&void 0}switch(u){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<e.coordinates.length;c++){var l={type:s,coordinates:e.coordinates[c]};if(!1===t(n.feature(l,o),r,c))return!1}})}function c(e,t){u(e,function(e,r,i){var a=0;if(e.geometry){var s=e.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var u,c=0,l=0,d=0;return!1!==o(e,function(o,s,p,f,h){if(void 0===u||r>c||f>l||h>d)return u=o,c=r,l=f,d=h,void(a=0);var g=n.lineString([u,o],e.properties);if(!1===t(g,r,i,h,a))return!1;a++,u=o})&&void 0}}})}function l(e,t){if(!e)throw new Error("geojson is required");u(e,function(e,r,o){if(null!==e.geometry){var i=e.geometry.type,a=e.geometry.coordinates;switch(i){case"LineString":if(!1===t(e,r,o,0,0))return!1;break;case"Polygon":for(var s=0;s<a.length;s++)if(!1===t(n.lineString(a[s],e.properties),r,o,s))return!1}}})}t.coordAll=function(e){var t=[];return o(e,function(e){t.push(e)}),t},t.coordEach=o,t.coordReduce=function(e,t,r,n){var i=r;return o(e,function(e,n,o,a,s){i=0===n&&void 0===r?e:t(i,e,n,o,a,s)},n),i},t.featureEach=a,t.featureReduce=function(e,t,r){var n=r;return a(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.findPoint=function(e,t){if(t=t||{},!n.isObject(t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.coordIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":return n.point(c,u,t);case"MultiPoint":return i<0&&(i=c.length+i),n.point(c[i],u,t);case"LineString":return s<0&&(s=c.length+s),n.point(c[s],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s),n.point(c[a][s],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),n.point(c[i][s],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s),n.point(c[i][a][s],u,t)}throw new Error("geojson is invalid")},t.findSegment=function(e,t){if(t=t||{},!n.isObject(t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.segmentIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),n.lineString([c[s],c[s+1]],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s-1),n.lineString([c[a][s],c[a][s+1]],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),n.lineString([c[i][s],c[i][s+1]],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s-1),n.lineString([c[i][a][s],c[i][a][s+1]],u,t)}throw new Error("geojson is invalid")},t.flattenEach=u,t.flattenReduce=function(e,t,r){var n=r;return u(e,function(e,o,i){n=0===o&&0===i&&void 0===r?e:t(n,e,o,i)}),n},t.geomEach=s,t.geomReduce=function(e,t,r){var n=r;return s(e,function(e,o,i,a,s){n=0===o&&void 0===r?e:t(n,e,o,i,a,s)}),n},t.lineEach=l,t.lineReduce=function(e,t,r){var n=r;return l(e,function(e,o,i,a){n=0===o&&void 0===r?e:t(n,e,o,i,a)}),n},t.propEach=i,t.propReduce=function(e,t,r){var n=r;return i(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.segmentEach=c,t.segmentReduce=function(e,t,r){var n=r,o=!1;return c(e,function(e,i,a,s,u){n=!1===o&&void 0===r?e:t(n,e,i,a,s,u),o=!0}),n}},"./node_modules/rbush/rbush.min.js":function(e){e.exports=function(){function e(e,n,o,i,a){!function e(r,n,o,i,a){for(;i>o;){if(i-o>600){var s=i-o+1,u=n-o+1,c=Math.log(s),l=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*l*(s-l)/s)*(u-s/2<0?-1:1);e(r,n,Math.max(o,Math.floor(n-u*l/s+d)),Math.min(i,Math.floor(n+(s-u)*l/s+d)),a)}var p=r[n],f=o,h=i;for(t(r,o,n),a(r[i],p)>0&&t(r,o,i);f<h;){for(t(r,f,h),f++,h--;a(r[f],p)<0;)f++;for(;a(r[h],p)>0;)h--}0===a(r[o],p)?t(r,o,h):t(r,++h,i),h<=n&&(o=h+1),n<=h&&(i=h-1)}}(e,n,o||0,i||e.length-1,a||r)}function t(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function r(e,t){return e<t?-1:e>t?1:0}var n=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(e,t,r){if(!r)return t.indexOf(e);for(var n=0;n<t.length;n++)if(r(e,t[n]))return n;return-1}function i(e,t){a(e,0,e.children.length,t,e)}function a(e,t,r,n,o){o||(o=h(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(var i=t;i<r;i++){var a=e.children[i];s(o,e.leaf?n(a):a)}return o}function s(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function u(e,t){return e.minX-t.minX}function c(e,t){return e.minY-t.minY}function l(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function d(e){return e.maxX-e.minX+(e.maxY-e.minY)}function p(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function f(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function h(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function g(t,r,n,o,i){for(var a=[r,n];a.length;)if(!((n=a.pop())-(r=a.pop())<=o)){var s=r+Math.ceil((n-r)/o/2)*o;e(t,s,r,n,i),a.push(r,s,s,n)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(e){var t=this.data,r=[];if(!f(e,t))return r;for(var n=this.toBBox,o=[];t;){for(var i=0;i<t.children.length;i++){var a=t.children[i],s=t.leaf?n(a):a;f(e,s)&&(t.leaf?r.push(a):p(e,s)?this._all(a,r):o.push(a))}t=o.pop()}return r},n.prototype.collides=function(e){var t=this.data;if(!f(e,t))return!1;for(var r=[];t;){for(var n=0;n<t.children.length;n++){var o=t.children[n],i=t.leaf?this.toBBox(o):o;if(f(e,i)){if(t.leaf||p(e,i))return!0;r.push(o)}}t=r.pop()}return!1},n.prototype.load=function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0;t<e.length;t++)this.insert(e[t]);return this}var r=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){var n=this.data;this.data=r,r=n}this._insert(r,this.data.height-r.height-1,!0)}else this.data=r;return this},n.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},n.prototype.clear=function(){return this.data=h([]),this},n.prototype.remove=function(e,t){if(!e)return this;for(var r,n,i,a=this.data,s=this.toBBox(e),u=[],c=[];a||u.length;){if(a||(a=u.pop(),n=u[u.length-1],r=c.pop(),i=!0),a.leaf){var l=o(e,a.children,t);if(-1!==l)return a.children.splice(l,1),u.push(a),this._condense(u),this}i||a.leaf||!p(a,s)?n?(r++,a=n.children[r],i=!1):a=null:(u.push(a),c.push(r),r=0,n=a,a=a.children[0])}return this},n.prototype.toBBox=function(e){return e},n.prototype.compareMinX=function(e,t){return e.minX-t.minX},n.prototype.compareMinY=function(e,t){return e.minY-t.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(e){return this.data=e,this},n.prototype._all=function(e,t){for(var r=[];e;)e.leaf?t.push.apply(t,e.children):r.push.apply(r,e.children),e=r.pop();return t},n.prototype._build=function(e,t,r,n){var o,a=r-t+1,s=this._maxEntries;if(a<=s)return i(o=h(e.slice(t,r+1)),this.toBBox),o;n||(n=Math.ceil(Math.log(a)/Math.log(s)),s=Math.ceil(a/Math.pow(s,n-1))),(o=h([])).leaf=!1,o.height=n;var u=Math.ceil(a/s),c=u*Math.ceil(Math.sqrt(s));g(e,t,r,c,this.compareMinX);for(var l=t;l<=r;l+=c){var d=Math.min(l+c-1,r);g(e,l,d,u,this.compareMinY);for(var p=l;p<=d;p+=u){var f=Math.min(p+u-1,d);o.children.push(this._build(e,p,f,n-1))}}return i(o,this.toBBox),o},n.prototype._chooseSubtree=function(e,t,r,n){for(;n.push(t),!t.leaf&&n.length-1!==r;){for(var o=1/0,i=1/0,a=void 0,s=0;s<t.children.length;s++){var u=t.children[s],c=l(u),d=(p=e,f=u,(Math.max(f.maxX,p.maxX)-Math.min(f.minX,p.minX))*(Math.max(f.maxY,p.maxY)-Math.min(f.minY,p.minY))-c);d<i?(i=d,o=c<o?c:o,a=u):d===i&&c<o&&(o=c,a=u)}t=a||t.children[0]}var p,f;return t},n.prototype._insert=function(e,t,r){var n=r?e:this.toBBox(e),o=[],i=this._chooseSubtree(n,this.data,t,o);for(i.children.push(e),s(i,n);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(n,o,t)},n.prototype._split=function(e,t){var r=e[t],n=r.children.length,o=this._minEntries;this._chooseSplitAxis(r,o,n);var a=this._chooseSplitIndex(r,o,n),s=h(r.children.splice(a,r.children.length-a));s.height=r.height,s.leaf=r.leaf,i(r,this.toBBox),i(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(r,s)},n.prototype._splitRoot=function(e,t){this.data=h([e,t]),this.data.height=e.height+1,this.data.leaf=!1,i(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(e,t,r){for(var n,o,i,s,u,c,d,p=1/0,f=1/0,h=t;h<=r-t;h++){var g=a(e,0,h,this.toBBox),y=a(e,h,r,this.toBBox),m=(o=g,i=y,void 0,void 0,void 0,void 0,s=Math.max(o.minX,i.minX),u=Math.max(o.minY,i.minY),c=Math.min(o.maxX,i.maxX),d=Math.min(o.maxY,i.maxY),Math.max(0,c-s)*Math.max(0,d-u)),v=l(g)+l(y);m<p?(p=m,n=h,f=v<f?v:f):m===p&&v<f&&(f=v,n=h)}return n||r-t},n.prototype._chooseSplitAxis=function(e,t,r){var n=e.leaf?this.compareMinX:u,o=e.leaf?this.compareMinY:c;this._allDistMargin(e,t,r,n)<this._allDistMargin(e,t,r,o)&&e.children.sort(n)},n.prototype._allDistMargin=function(e,t,r,n){e.children.sort(n);for(var o=this.toBBox,i=a(e,0,t,o),u=a(e,r-t,r,o),c=d(i)+d(u),l=t;l<r-t;l++){var p=e.children[l];s(i,e.leaf?o(p):p),c+=d(i)}for(var f=r-t-1;f>=t;f--){var h=e.children[f];s(u,e.leaf?o(h):h),c+=d(u)}return c},n.prototype._adjustParentBBoxes=function(e,t,r){for(var n=r;n>=0;n--)s(t[n],e)},n.prototype._condense=function(e){for(var t=e.length-1,r=void 0;t>=0;t--)0===e[t].children.length?t>0?(r=e[t-1].children).splice(r.indexOf(e[t]),1):this.clear():i(e[t],this.toBBox)},n}()},"./node_modules/wgs84/index.js":e=>{e.exports.RADIUS=6378137,e.exports.FLATTENING=1/298.257223563,e.exports.POLAR_RADIUS=6356752.3142},"./plugins/draw-ml/src/manifest.js":(e,t,r)=>{r.r(t),r.d(t,{manifest:()=>Co});var n={};r.r(n),r.d(n,{LAT_MAX:()=>R,LAT_MIN:()=>N,LAT_RENDERED_MAX:()=>D,LAT_RENDERED_MIN:()=>j,LNG_MAX:()=>U,LNG_MIN:()=>V,activeStates:()=>F,classes:()=>M,cursors:()=>_,events:()=>O,geojsonTypes:()=>C,interactions:()=>k,meta:()=>A,modes:()=>T,sources:()=>P,types:()=>I,updateActions:()=>L});var o={};r.r(o),r.d(o,{isActiveFeature:()=>Ne,isEnterKey:()=>Ge,isEscapeKey:()=>Be,isFeature:()=>De,isInactiveFeature:()=>je,isOfMetaType:()=>Fe,isShiftDown:()=>Ue,isShiftMousedown:()=>ke,isTrue:()=>Ye,isVertex:()=>Ve,noTarget:()=>Re});var i={};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach(function(t){c(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function c(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.r(i),r.d(i,{CommonSelectors:()=>o,ModeHandler:()=>w,StringSet:()=>J,constrainFeatureMovement:()=>rt,createMidPoint:()=>$e,createSupplementaryPoints:()=>He,createVertex:()=>Je,doubleClickZoom:()=>We,euclideanDistance:()=>z,featuresAt:()=>H,getFeatureAtAndSetCursors:()=>K,isClick:()=>te,isEventAtCoordinates:()=>pt,isTap:()=>oe,mapEventToBoundingBox:()=>X,moveFeatures:()=>nt,sortFeatures:()=>Y,stringSetsAreEqual:()=>xt,theme:()=>Ae,toDenseArray:()=>xe});var l={SET_MODE:function(e,t){return u(u({},e),{},{mode:t})},SET_FEATURE:function(e,t){return u(u({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature})},SET_SELECTED_VERTEX_INDEX:function(e,t){return u(u({},e),{},{selectedVertexIndex:t.index,numVertecies:t.numVertecies})},TOGGLE_SNAP:function(e){return u(u({},e),{},{snap:!e.snap})},SET_HAS_SNAP_LAYERS:function(e,t){return u(u({},e),{},{hasSnapLayers:!!t})}},d=r("react");function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach(function(t){g(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function g(e,t,r){return(t=function(e){var t=function(e){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==p(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function y(e){var t;return null!==(t=null==e?void 0:e._snapInstance)&&void 0!==t?t:null}function m(e){var t;return!!(null!=e&&e.status&&null!=e&&e.snapStatus&&(null===(t=e.snapCoords)||void 0===t?void 0:t.length)>=2)}function v(e){return m(e)?{lng:e.snapCoords[0],lat:e.snapCoords[1]}:null}function b(e,t,r){if(!e||!t||!e.status)return!1;var n=t.unproject(r);return e.snapToClosestPoint({point:r,lngLat:n}),!0}function E(e){var t,r,n;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(t=e.snappedFeatures)&&void 0!==t&&t.length&&(e.snappedFeatures.length=0),null!==(r=e.closeFeatures)&&void 0!==r&&r.length&&(e.closeFeatures.length=0),null!==(n=e.lines)&&void 0!==n&&n.length&&(e.lines.length=0))}function S(e){return"function"==typeof(null==e?void 0:e.getSnapEnabled)&&!0===e.getSnapEnabled()}const w=function(e,t){const r={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},n={on(e,t,n){if(void 0===r[e])throw new Error(`Invalid event type: ${e}`);r[e].push({selector:t,fn:n})},render(e){t.store.featureChanged(e)}},o=function(e,o){const i=r[e];let a=i.length;for(;a--;){const e=i[a];if(e.selector(o)){e.fn.call(n,o)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(n),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(e){o("drag",e)},click(e){o("click",e)},mousemove(e){o("mousemove",e)},mousedown(e){o("mousedown",e)},mouseup(e){o("mouseup",e)},mouseout(e){o("mouseout",e)},keydown(e){o("keydown",e)},keyup(e){o("keyup",e)},touchstart(e){o("touchstart",e)},touchmove(e){o("touchmove",e)},touchend(e){o("touchend",e)},tap(e){o("tap",e)}}};var x=r("./node_modules/@mapbox/geojson-area/index.js");const M={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},P={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},_={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},I={POLYGON:"polygon",LINE:"line_string",POINT:"point"},C={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},T={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},O={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},L={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},A={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},F={ACTIVE:"true",INACTIVE:"false"},k=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],N=-90,j=-85,R=90,D=85,V=-270,U=270,B={Point:0,LineString:1,MultiLineString:1,Polygon:2};function G(e,t){const r=B[e.geometry.type]-B[t.geometry.type];return 0===r&&e.geometry.type===C.POLYGON?e.area-t.area:r}const Y=function(e){return e.map(e=>(e.geometry.type===C.POLYGON&&(e.area=x.geometry({type:C.FEATURE,property:{},geometry:e.geometry})),e)).sort(G).map(e=>(delete e.area,e))},X=function(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function q(e){if(this._items={},this._nums={},this._length=e?e.length:0,e)for(let t=0,r=e.length;t<r;t++)this.add(e[t]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}q.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},q.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},q.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},q.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((e,t)=>e.v-t.v).map(e=>e.k)},q.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const J=q,$=[A.FEATURE,A.MIDPOINT,A.VERTEX],H={click:function(e,t,r){return W(e,t,r,r.options.clickBuffer)},touch:function(e,t,r){return W(e,t,r,r.options.touchBuffer)}};function W(e,t,r,n){if(null===r.map)return[];const o=e?X(e,n):t,i={};r.options.styles&&(i.layers=r.options.styles.map(e=>e.id).filter(e=>null!=r.map.getLayer(e)));const a=r.map.queryRenderedFeatures(o,i).filter(e=>-1!==$.indexOf(e.properties.meta)),s=new J,u=[];return a.forEach(e=>{const t=e.properties.id;s.has(t)||(s.add(t),u.push(e))}),Y(u)}function K(e,t){const r=H.click(e,null,t),n={mouse:_.NONE};return r[0]&&(n.mouse=r[0].properties.active===F.ACTIVE?_.MOVE:_.POINTER,n.feature=r[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(n.mouse=_.ADD),t.ui.queueMapClasses(n),t.ui.updateMapClasses(),r[0]}function z(e,t){const r=e.x-t.x,n=e.y-t.y;return Math.sqrt(r*r+n*n)}const Z=4,Q=12,ee=500;function te(e,t,r={}){const n=null!=r.fineTolerance?r.fineTolerance:Z,o=null!=r.grossTolerance?r.grossTolerance:Q,i=null!=r.interval?r.interval:ee;e.point=e.point||t.point,e.time=e.time||t.time;const a=z(e.point,t.point);return a<n||a<o&&t.time-e.time<i}const re=25,ne=250;function oe(e,t,r={}){const n=null!=r.tolerance?r.tolerance:re,o=null!=r.interval?r.interval:ne;return e.point=e.point||t.point,e.time=e.time||t.time,z(e.point,t.point)<n&&t.time-e.time<o}const ie=((e,t=21)=>(r=t)=>{let n="",o=0|r;for(;o--;)n+=e[Math.random()*e.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function ae(){return ie()}const se=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||ae(),this.type=t.geometry.type};se.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},se.prototype.incomingCoords=function(e){this.setCoordinates(e)},se.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},se.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},se.prototype.setProperty=function(e,t){this.properties[e]=t},se.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:C.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},se.prototype.internal=function(e){const t={id:this.id,meta:A.FEATURE,"meta:type":this.type,active:F.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const e in this.properties)t[`user_${e}`]=this.properties[e];return{type:C.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const ue=se,ce=function(e,t){ue.call(this,e,t)};(ce.prototype=Object.create(ue.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},ce.prototype.updateCoordinate=function(e,t,r){this.coordinates=3===arguments.length?[t,r]:[e,t],this.changed()},ce.prototype.getCoordinate=function(){return this.getCoordinates()};const le=ce,de=function(e,t){ue.call(this,e,t)};(de.prototype=Object.create(ue.prototype)).isValid=function(){return this.coordinates.length>1},de.prototype.addCoordinate=function(e,t,r){this.changed();const n=parseInt(e,10);this.coordinates.splice(n,0,[t,r])},de.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},de.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},de.prototype.updateCoordinate=function(e,t,r){const n=parseInt(e,10);this.coordinates[n]=[t,r],this.changed()};const pe=de,fe=function(e,t){ue.call(this,e,t),this.coordinates=this.coordinates.map(e=>e.slice(0,-1))};(fe.prototype=Object.create(ue.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},fe.prototype.incomingCoords=function(e){this.coordinates=e.map(e=>e.slice(0,-1)),this.changed()},fe.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},fe.prototype.addCoordinate=function(e,t,r){this.changed();const n=e.split(".").map(e=>parseInt(e,10));this.coordinates[n[0]].splice(n[1],0,[t,r])},fe.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];r&&(r.splice(t[1],1),r.length<3&&this.coordinates.splice(t[0],1))},fe.prototype.getCoordinate=function(e){const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];return JSON.parse(JSON.stringify(r[t[1]]))},fe.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},fe.prototype.updateCoordinate=function(e,t,r){this.changed();const n=e.split("."),o=parseInt(n[0],10),i=parseInt(n[1],10);void 0===this.coordinates[o]&&(this.coordinates[o]=[]),this.coordinates[o][i]=[t,r]};const he=fe,ge={MultiPoint:le,MultiLineString:pe,MultiPolygon:he},ye=(e,t,r,n,o)=>{const i=r.split("."),a=parseInt(i[0],10),s=i[1]?i.slice(1).join("."):null;return e[a][t](s,n,o)},me=function(e,t){if(ue.call(this,e,t),delete this.coordinates,this.model=ge[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};(me.prototype=Object.create(ue.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(e=>new t(this.ctx,{id:ae(),type:C.FEATURE,properties:{},geometry:{coordinates:e,type:this.type.replace("Multi","")}}))},me.prototype.isValid=function(){return this.features.every(e=>e.isValid())},me.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},me.prototype.getCoordinate=function(e){return ye(this.features,"getCoordinate",e)},me.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===C.POLYGON?e.getCoordinates():e.coordinates)))},me.prototype.updateCoordinate=function(e,t,r){ye(this.features,"updateCoordinate",e,t,r),this.changed()},me.prototype.addCoordinate=function(e,t,r){ye(this.features,"addCoordinate",e,t,r),this.changed()},me.prototype.removeCoordinate=function(e){ye(this.features,"removeCoordinate",e),this.changed()},me.prototype.getFeatures=function(){return this.features};const ve=me;function be(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}be.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},be.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((e,t)=>(void 0===e[t.feature_id]&&(e[t.feature_id]=!0,this._ctx.store.get(t.feature_id).changed()),e),{})},be.prototype.getSelected=function(){return this._ctx.store.getSelected()},be.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},be.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},be.prototype.getFeature=function(e){return this._ctx.store.get(e)},be.prototype.select=function(e){return this._ctx.store.select(e)},be.prototype.deselect=function(e){return this._ctx.store.deselect(e)},be.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},be.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},be.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},be.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},be.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)},be.prototype.changeMode=function(e,t={},r={}){return this._ctx.events.changeMode(e,t,r)},be.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},be.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},be.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},be.prototype.featuresAt=function(e,t,r="click"){if("click"!==r&&"touch"!==r)throw new Error("invalid buffer type");return H[r](e,t,this._ctx)},be.prototype.newFeature=function(e){const t=e.geometry.type;return t===C.POINT?new le(this._ctx,e):t===C.LINE_STRING?new pe(this._ctx,e):t===C.POLYGON?new he(this._ctx,e):new ve(this._ctx,e)},be.prototype.isInstanceOf=function(e,t){if(e===C.POINT)return t instanceof le;if(e===C.LINE_STRING)return t instanceof pe;if(e===C.POLYGON)return t instanceof he;if("MultiFeature"===e)return t instanceof ve;throw new Error(`Unknown feature class: ${e}`)},be.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const Ee=be;be.prototype.onSetup=function(){},be.prototype.onDrag=function(){},be.prototype.onClick=function(){},be.prototype.onMouseMove=function(){},be.prototype.onMouseDown=function(){},be.prototype.onMouseUp=function(){},be.prototype.onMouseOut=function(){},be.prototype.onKeyUp=function(){},be.prototype.onKeyDown=function(){},be.prototype.onTouchStart=function(){},be.prototype.onTouchMove=function(){},be.prototype.onTouchEnd=function(){},be.prototype.onTap=function(){},be.prototype.onStop=function(){},be.prototype.onTrash=function(){},be.prototype.onCombineFeature=function(){},be.prototype.onUncombineFeature=function(){},be.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const Se={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},we=Object.keys(Se);const xe=function(e){return[].concat(e).filter(e=>void 0!==e)};function Me(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(P.HOT))return s();const t=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:t});let r=[],n=[];e.isDirty?n=e.getAllIds():(r=e.getChangedIds().filter(t=>void 0!==e.get(t)),n=e.sources.hot.filter(t=>t.properties.id&&-1===r.indexOf(t.properties.id)&&void 0!==e.get(t.properties.id)).map(e=>e.properties.id)),e.sources.hot=[];const o=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(e=>{const t=e.properties.id||e.properties.parent;return-1===r.indexOf(t)});const i=o!==e.sources.cold.length||n.length>0;function a(r,n){const o=e.get(r).internal(t);e.ctx.events.currentModeRender(o,r=>{r.properties.mode=t,e.sources[n].push(r)})}function s(){e.isDirty=!1,e.clearChangedIds()}r.forEach(e=>a(e,"hot")),n.forEach(e=>a(e,"cold")),i&&e.ctx.map.getSource(P.COLD).setData({type:C.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(P.HOT).setData({type:C.FEATURE_COLLECTION,features:e.sources.hot}),s()}function Pe(e){let t;this._features={},this._featureIds=new J,this._selectedFeatureIds=new J,this._selectedCoordinates=[],this._changedFeatureIds=new J,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,Me.call(this),this._emitSelectionChange&&(this.ctx.events.fire(O.SELECTION_CHANGE,{features:this.getSelected().map(e=>e.toGeoJSON()),points:this.getSelectedCoordinates().map(e=>({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:e.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(O.RENDER,{})}))},this.isDirty=!1}function _e(e,t={}){const r=e._selectedCoordinates.filter(t=>e._selectedFeatureIds.has(t.feature_id));e._selectedCoordinates.length===r.length||t.silent||(e._emitSelectionChange=!0),e._selectedCoordinates=r}Pe.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},Pe.prototype.setDirty=function(){return this.isDirty=!0,this},Pe.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const t=this.get(e);this.ctx.events.fire(O.CREATE,{features:[t.toGeoJSON()]})}return this},Pe.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(O.UPDATE,{action:t.action?t.action:L.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},Pe.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Pe.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Pe.prototype.getAllIds=function(){return this._featureIds.values()},Pe.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},Pe.prototype.delete=function(e,t={}){const r=[];return xe(e).forEach(e=>{this._featureIds.has(e)&&(this._featureIds.delete(e),this._selectedFeatureIds.delete(e),t.silent||-1===r.indexOf(this._features[e])&&r.push(this._features[e].toGeoJSON()),delete this._features[e],this.isDirty=!0)}),r.length&&this.ctx.events.fire(O.DELETE,{features:r}),_e(this,t),this},Pe.prototype.get=function(e){return this._features[e]},Pe.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},Pe.prototype.select=function(e,t={}){return xe(e).forEach(e=>{this._selectedFeatureIds.has(e)||(this._selectedFeatureIds.add(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),this},Pe.prototype.deselect=function(e,t={}){return xe(e).forEach(e=>{this._selectedFeatureIds.has(e)&&(this._selectedFeatureIds.delete(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),_e(this,t),this},Pe.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},Pe.prototype.setSelected=function(e,t={}){return e=xe(e),this.deselect(this._selectedFeatureIds.values().filter(t=>-1===e.indexOf(t)),{silent:t.silent}),this.select(e.filter(e=>!this._selectedFeatureIds.has(e)),{silent:t.silent}),this},Pe.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},Pe.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Pe.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Pe.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},Pe.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)}))},Pe.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},Pe.prototype.setFeatureProperty=function(e,t,r,n={}){this.get(e).setProperty(t,r),this.featureChanged(e,{silent:n.silent,action:L.CHANGE_PROPERTIES})},Pe.prototype.storeMapConfig=function(){k.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},Pe.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},Pe.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const Ie=["mode","feature","mouse"];function Ce(e){let t=null,r=null;const n={onRemove(){return e.map.off("load",n.connect),clearInterval(r),n.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",n.connect),clearInterval(r),n.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(o){if(e.map=o,e.events=function(e){const t=Object.keys(e.options.modes).reduce((t,r)=>(t[r]=function(e){const t=Object.keys(e);return function(r,n={}){let o={};const i=t.reduce((t,r)=>(t[r]=e[r],t),new Ee(r));return{start(){o=i.onSetup(n),we.forEach(t=>{const r=Se[t];let n=()=>!1;var a;e[r]&&(n=()=>!0),this.on(t,n,(a=r,e=>i[a](o,e)))})},stop(){i.onStop(o)},trash(){i.onTrash(o)},combineFeatures(){i.onCombineFeatures(o)},uncombineFeatures(){i.onUncombineFeatures(o)},render(e,t){i.toDisplayFeatures(o,e,t)}}}}(e.options.modes[r]),t),{});let r={},n={};const o={};let i=null,a=null;o.drag=function(t,r){r({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:_.DRAG}),a.drag(t)):t.originalEvent.stopPropagation()},o.mousedrag=function(e){o.drag(e,e=>!te(r,e))},o.touchdrag=function(e){o.drag(e,e=>!oe(n,e))},o.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return o.mousedrag(t);const r=K(t,e);t.featureTarget=r,a.mousemove(t)},o.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};const n=K(t,e);t.featureTarget=n,a.mousedown(t)},o.mouseup=function(t){const n=K(t,e);t.featureTarget=n,te(r,{point:t.point,time:(new Date).getTime()})?a.click(t):a.mouseup(t)},o.mouseout=function(e){a.mouseout(e)},o.touchstart=function(t){if(!e.options.touchEnabled)return;n={time:(new Date).getTime(),point:t.point};const r=H.touch(t,null,e)[0];t.featureTarget=r,a.touchstart(t)},o.touchmove=function(t){if(e.options.touchEnabled)return a.touchmove(t),o.touchdrag(t)},o.touchend=function(t){if(t.originalEvent.preventDefault(),!e.options.touchEnabled)return;const r=H.touch(t,null,e)[0];t.featureTarget=r,oe(n,{time:(new Date).getTime(),point:t.point})?a.tap(t):a.touchend(t)};const s=e=>!(8===e||46===e||e>=48&&e<=57);function u(r,n,o={}){a.stop();const s=t[r];if(void 0===s)throw new Error(`${r} is not valid`);i=r;const u=s(e,n);a=w(u,e),o.silent||e.map.fire(O.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains(M.CANVAS)&&(8!==t.keyCode&&46!==t.keyCode||!e.options.controls.trash?s(t.keyCode)?a.keydown(t):49===t.keyCode&&e.options.controls.point?u(T.DRAW_POINT):50===t.keyCode&&e.options.controls.line_string?u(T.DRAW_LINE_STRING):51===t.keyCode&&e.options.controls.polygon&&u(T.DRAW_POLYGON):(t.preventDefault(),a.trash()))},o.keyup=function(e){s(e.keyCode)&&a.keyup(e)},o.zoomend=function(){e.store.changeZoom()},o.data=function(t){if("style"===t.dataType){const{setup:t,map:r,options:n,store:o}=e;n.styles.some(e=>r.getLayer(e.id))||(t.addLayers(),o.setDirty(),o.render())}};const c={trash:!1,combineFeatures:!1,uncombineFeatures:!1},l={start(){i=e.options.defaultMode,a=w(t[i](e),e)},changeMode:u,actionable:function(t){let r=!1;Object.keys(t).forEach(e=>{if(void 0===c[e])throw new Error("Invalid action type");c[e]!==t[e]&&(r=!0),c[e]=t[e]}),r&&e.map.fire(O.ACTIONABLE,{actions:c})},currentModeName:()=>i,currentModeRender:(e,t)=>a.render(e,t),fire(t,r){e.map&&e.map.fire(t,r)},addEventListeners(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash(e){a.trash(e)},combineFeatures(){a.combineFeatures()},uncombineFeatures(){a.uncombineFeatures()},getMode:()=>i};return l}(e),e.ui=function(e){const t={};let r=null,n={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function i(e){o=Object.assign(o,e)}function a(){if(!e.container)return;const t=[],r=[];Ie.forEach(e=>{o[e]!==n[e]&&(t.push(`${e}-${n[e]}`),null!==o[e]&&r.push(`${e}-${o[e]}`))}),t.length>0&&e.container.classList.remove(...t),r.length>0&&e.container.classList.add(...r),n=Object.assign(n,o)}function s(e,t={}){const n=document.createElement("button");return n.className=`${M.CONTROL_BUTTON} ${t.className}`,n.setAttribute("title",t.title),t.container.appendChild(n),n.addEventListener("click",n=>{if(n.preventDefault(),n.stopPropagation(),n.target===r)return u(),void t.onDeactivate();c(e),t.onActivate()},!0),n}function u(){r&&(r.classList.remove(M.ACTIVE_BUTTON),r=null)}function c(e){u();const n=t[e];n&&n&&"trash"!==e&&(n.classList.add(M.ACTIVE_BUTTON),r=n)}return{setActiveButton:c,queueMapClasses:i,updateMapClasses:a,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),a()},addButtons:function(){const r=e.options.controls,n=document.createElement("div");return n.className=`${M.CONTROL_GROUP} ${M.CONTROL_BASE}`,r?(r[I.LINE]&&(t[I.LINE]=s(I.LINE,{container:n,className:M.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(l)":""),onActivate:()=>e.events.changeMode(T.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),r[I.POLYGON]&&(t[I.POLYGON]=s(I.POLYGON,{container:n,className:M.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(p)":""),onActivate:()=>e.events.changeMode(T.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),r[I.POINT]&&(t[I.POINT]=s(I.POINT,{container:n,className:M.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(m)":""),onActivate:()=>e.events.changeMode(T.DRAW_POINT),onDeactivate:()=>e.events.trash()})),r.trash&&(t.trash=s("trash",{container:n,className:M.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),r.combine_features&&(t.combine_features=s("combineFeatures",{container:n,className:M.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),r.uncombine_features&&(t.uncombine_features=s("uncombineFeatures",{container:n,className:M.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}})),n):n},removeButtons:function(){Object.keys(t).forEach(e=>{const r=t[e];r.parentNode&&r.parentNode.removeChild(r),delete t[e]})}}}(e),e.container=o.getContainer(),e.store=new Pe(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=o.boxZoom.isEnabled(),o.boxZoom.disable();const t=o.dragPan.isEnabled();o.dragPan.disable(),o.dragPan.enable(),t||o.dragPan.disable()}return o.loaded()?n.connect():(o.on("load",n.connect),r=setInterval(()=>{o.loaded()&&n.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(P.COLD,{data:{type:C.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(P.HOT,{data:{type:C.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(t=>{e.map.addLayer(t)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(t=>{e.map.getLayer(t.id)&&e.map.removeLayer(t.id)}),e.map.getSource(P.COLD)&&e.map.removeSource(P.COLD),e.map.getSource(P.HOT)&&e.map.removeSource(P.HOT)}};return e.setup=n,n}const Te="#3bb2d0",Oe="#fbb03b",Le="#fff",Ae=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],Oe,Te],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],Oe,Te],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Le}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],Oe,Te]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Le}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":Oe}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":Oe}}];function Fe(e){return function(t){const r=t.featureTarget;return!!r&&!!r.properties&&r.properties.meta===e}}function ke(e){return!!e.originalEvent&&!!e.originalEvent.shiftKey&&0===e.originalEvent.button}function Ne(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===F.ACTIVE&&e.featureTarget.properties.meta===A.FEATURE}function je(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===F.INACTIVE&&e.featureTarget.properties.meta===A.FEATURE}function Re(e){return void 0===e.featureTarget}function De(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.meta===A.FEATURE}function Ve(e){const t=e.featureTarget;return!!t&&!!t.properties&&t.properties.meta===A.VERTEX}function Ue(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function Be(e){return 27===e.keyCode}function Ge(e){return 13===e.keyCode}function Ye(){return!0}function Xe(e,t){this.x=e,this.y=t}Xe.prototype={clone(){return new Xe(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[0]*this.x+e[1]*this.y,r=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=r,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),r=Math.sin(e),n=t*this.x-r*this.y,o=r*this.x+t*this.y;return this.x=n,this.y=o,this},_rotateAround(e,t){const r=Math.cos(e),n=Math.sin(e),o=t.x+r*(this.x-t.x)-n*(this.y-t.y),i=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=o,this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Xe},Xe.convert=function(e){if(e instanceof Xe)return e;if(Array.isArray(e))return new Xe(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Xe(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const qe=function(e,t){const r=t.getBoundingClientRect();return new Xe(e.clientX-r.left-(t.clientLeft||0),e.clientY-r.top-(t.clientTop||0))};function Je(e,t,r,n){return{type:C.FEATURE,properties:{meta:A.VERTEX,parent:e,coord_path:r,active:n?F.ACTIVE:F.INACTIVE},geometry:{type:C.POINT,coordinates:t}}}function $e(e,t,r){const n=t.geometry.coordinates,o=r.geometry.coordinates;if(n[1]>D||n[1]<j||o[1]>D||o[1]<j)return null;const i={lng:(n[0]+o[0])/2,lat:(n[1]+o[1])/2};return{type:C.FEATURE,properties:{meta:A.MIDPOINT,parent:e,lng:i.lng,lat:i.lat,coord_path:r.properties.coord_path},geometry:{type:C.POINT,coordinates:[i.lng,i.lat]}}}const He=function e(t,r={},n=null){const{type:o,coordinates:i}=t.geometry,a=t.properties&&t.properties.id;let s=[];function u(e,t){let n="",o=null;e.forEach((e,i)=>{const u=null!=t?`${t}.${i}`:String(i),l=Je(a,e,u,c(u));if(r.midpoints&&o){const e=$e(a,o,l);e&&s.push(e)}o=l;const d=JSON.stringify(e);n!==d&&s.push(l),0===i&&(n=d)})}function c(e){return!!r.selectedPaths&&-1!==r.selectedPaths.indexOf(e)}return o===C.POINT?s.push(Je(a,i,n,c(n))):o===C.POLYGON?i.forEach((e,t)=>{u(e,null!==n?`${n}.${t}`:String(t))}):o===C.LINE_STRING?u(i,n):0===o.indexOf(C.MULTI_PREFIX)&&function(){const n=o.replace(C.MULTI_PREFIX,"");i.forEach((o,i)=>{const a={type:C.FEATURE,properties:t.properties,geometry:{type:n,coordinates:o}};s=s.concat(e(a,r,i))})}(),s},We={enable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e._ctx&&e._ctx.store&&e._ctx.store.getInitialConfigValue&&e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e.map.doubleClickZoom.disable()},0)}},{LAT_MIN:Ke,LAT_MAX:ze,LAT_RENDERED_MIN:Ze,LAT_RENDERED_MAX:Qe,LNG_MIN:et,LNG_MAX:tt}=n;function rt(e,t){let r=Ke,n=ze,o=Ke,i=ze,a=tt,s=et;e.forEach(e=>{const t=function(e){const t={Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type],r=[e.geometry.coordinates].flat(t),n=r.map(e=>e[0]),o=r.map(e=>e[1]),i=e=>Math.min.apply(null,e),a=e=>Math.max.apply(null,e);return[i(n),i(o),a(n),a(o)]}(e),u=t[1],c=t[3],l=t[0],d=t[2];u>r&&(r=u),c<n&&(n=c),c>o&&(o=c),u<i&&(i=u),l<a&&(a=l),d>s&&(s=d)});const u=t;return r+u.lat>Qe&&(u.lat=Qe-r),o+u.lat>ze&&(u.lat=ze-o),n+u.lat<Ze&&(u.lat=Ze-n),i+u.lat<Ke&&(u.lat=Ke-i),a+u.lng<=et&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=tt&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function nt(e,t){const r=rt(e.map(e=>e.toGeoJSON()),t);e.forEach(e=>{const t=e.getCoordinates(),n=e=>{const t={lng:e[0]+r.lng,lat:e[1]+r.lat};return[t.lng,t.lat]},o=e=>e.map(e=>n(e));let i;e.type===C.POINT?i=n(t):e.type===C.LINE_STRING||e.type===C.MULTI_POINT?i=t.map(n):e.type===C.POLYGON||e.type===C.MULTI_LINE_STRING?i=t.map(o):e.type===C.MULTI_POLYGON&&(i=t.map(e=>e.map(e=>o(e)))),e.incomingCoords(i)})}const ot={onSetup:function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(e=>void 0!==this.getFeature(e))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(O.UPDATE,{action:L.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(){const e=this.getSelected(),t=e.filter(e=>this.isInstanceOf("MultiFeature",e));let r=!1;if(e.length>1){r=!0;const t=e[0].type.replace("Multi","");e.forEach(e=>{e.type.replace("Multi","")!==t&&(r=!1)})}const n=t.length>0,o=e.length>0;this.setActionableState({combineFeatures:r,uncombineFeatures:n,trash:o})},getUniqueIds:function(e){return e.length?e.map(e=>e.properties.id).filter(e=>void 0!==e).reduce((e,t)=>(e.add(t),e),new J).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){We.enable(this)},onMouseMove:function(e,t){return De(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};ot.onTap=ot.onClick=function(e,t){return Re(t)?this.clickAnywhere(e,t):Fe(A.VERTEX)(t)?this.clickOnVertex(e,t):De(t)?this.clickOnFeature(e,t):void 0},ot.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(e=>this.doRender(e))),We.enable(this),this.stopExtendedInteractions(e)},ot.clickOnVertex=function(e,t){this.changeMode(T.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:_.MOVE})},ot.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},ot.clickOnFeature=function(e,t){We.disable(this),this.stopExtendedInteractions(e);const r=Ue(t),n=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!r&&i&&this.getFeature(o).type!==C.POINT)return this.changeMode(T.DIRECT_SELECT,{featureId:o});i&&r?(this.deselect(o),this.updateUIClasses({mouse:_.POINTER}),1===n.length&&We.enable(this)):!i&&r?(this.select(o),this.updateUIClasses({mouse:_.MOVE})):i||r||(n.forEach(e=>this.doRender(e)),this.setSelected(o),this.updateUIClasses({mouse:_.MOVE})),this.doRender(o)},ot.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),Ne(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&ke(t)?this.startBoxSelect(e,t):void 0},ot.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=qe(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},ot.onTouchStart=function(e,t){if(Ne(t))return this.startOnActiveFeature(e,t)},ot.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},ot.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:_.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(M.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const r=qe(t.originalEvent,this.map.getContainer()),n=Math.min(e.boxSelectStartLocation.x,r.x),o=Math.max(e.boxSelectStartLocation.x,r.x),i=Math.min(e.boxSelectStartLocation.y,r.y),a=Math.max(e.boxSelectStartLocation.y,r.y),s=`translate(${n}px, ${i}px)`;e.boxSelectElement.style.transform=s,e.boxSelectElement.style.WebkitTransform=s,e.boxSelectElement.style.width=o-n+"px",e.boxSelectElement.style.height=a-i+"px"},ot.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};nt(this.getSelected(),r),e.dragMoveLocation=t.lngLat},ot.onTouchEnd=ot.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const r=[e.boxSelectStartLocation,qe(t.originalEvent,this.map.getContainer())],n=this.featuresAt(null,r,"click"),o=this.getUniqueIds(n).filter(e=>!this.isSelected(e));o.length&&(this.select(o),o.forEach(e=>this.doRender(e)),this.updateUIClasses({mouse:_.MOVE}))}this.stopExtendedInteractions(e)},ot.toDisplayFeatures=function(e,t,r){t.properties.active=this.isSelected(t.properties.id)?F.ACTIVE:F.INACTIVE,r(t),this.fireActionable(),t.properties.active===F.ACTIVE&&t.geometry.type!==C.POINT&&He(t).forEach(r)},ot.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},ot.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],r=[],n=e[0].type.replace("Multi","");for(let o=0;o<e.length;o++){const i=e[o];if(i.type.replace("Multi","")!==n)return;i.type.includes("Multi")?i.getCoordinates().forEach(e=>{t.push(e)}):t.push(i.getCoordinates()),r.push(i.toGeoJSON())}if(r.length>1){const e=this.newFeature({type:C.FEATURE,properties:r[0].properties,geometry:{type:`Multi${n}`,coordinates:t}});this.addFeature(e),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([e.id]),this.fire(O.COMBINE_FEATURES,{createdFeatures:[e.toGeoJSON()],deletedFeatures:r})}this.fireActionable()},ot.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],r=[];for(let n=0;n<e.length;n++){const o=e[n];this.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach(e=>{this.addFeature(e),e.properties=o.properties,t.push(e.toGeoJSON()),this.select([e.id])}),this.deleteFeature(o.id,{silent:!0}),r.push(o.toGeoJSON()))}t.length>1&&this.fire(O.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:r}),this.fireActionable()};const it=ot,at=Fe(A.VERTEX),st=Fe(A.MIDPOINT),ut={fireUpdate:function(){this.fire(O.UPDATE,{action:L.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){e.initialDragPanState=this.map.dragPan.isEnabled(),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties,n=e.selectedCoordPaths.indexOf(r.coord_path);Ue(t)||-1!==n?Ue(t)&&-1===n&&e.selectedCoordPaths.push(r.coord_path):e.selectedCoordPaths=[r.coord_path];const o=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(o)},onMidpoint:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties;e.feature.addCoordinate(r.coord_path,r.lng,r.lat),this.fireUpdate(),e.selectedCoordPaths=[r.coord_path]},pathsToCoordinates:function(e,t){return t.map(t=>({feature_id:e,coord_path:t}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,r){nt(this.getSelected(),r),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,r){const n=e.selectedCoordPaths.map(t=>e.feature.getCoordinate(t)),o=rt(n.map(e=>({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:e}})),r);for(let t=0;t<n.length;t++){const r=n[t];e.feature.updateCoordinate(e.selectedCoordPaths[t],r[0]+o.lng,r[1]+o.lat)}},clickNoTarget:function(){this.changeMode(T.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(T.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},onSetup:function(e){const t=e.featureId,r=this.getFeature(t);if(!r)throw new Error("You must provide a featureId to enter direct_select mode");if(r.type===C.POINT)throw new TypeError("direct_select mode doesn't handle point features");const n={featureId:t,feature:r,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,n.selectedCoordPaths)),this.setSelected(t),We.disable(this),this.setActionableState({trash:!0}),n},onStop:function(){We.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,r){e.featureId===t.properties.id?(t.properties.active=F.ACTIVE,r(t),He(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(r)):(t.properties.active=F.INACTIVE,r(t)),this.fireActionable(e)},onTrash:function(e){e.selectedCoordPaths.sort((e,t)=>t.localeCompare(e,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(T.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const r=Ne(t),n=at(t),o=st(t),i=0===e.selectedCoordPaths.length;return r&&i||n&&!i?this.updateUIClasses({mouse:_.MOVE}):this.updateUIClasses({mouse:_.NONE}),(n||r||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};ut.onTouchStart=ut.onMouseDown=function(e,t){return at(t)?this.onVertex(e,t):Ne(t)?this.onFeature(e,t):st(t)?this.onMidpoint(e,t):void 0},ut.onDrag=function(e,t){if(!0!==e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,r):this.dragFeature(e,t,r),e.dragMoveLocation=t.lngLat},ut.onClick=function(e,t){return Re(t)?this.clickNoTarget(e,t):Ne(t)?this.clickActiveFeature(e,t):je(t)?this.clickInactive(e,t):void this.stopDragging(e)},ut.onTap=function(e,t){return Re(t)?this.clickNoTarget(e,t):Ne(t)?this.clickActiveFeature(e,t):je(t)?this.clickInactive(e,t):void 0},ut.onTouchEnd=ut.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const ct=ut,lt={onSetup:function(){const e=this.newFeature({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:_.ADD}),this.activateUIButton(I.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)}};lt.onTap=lt.onClick=function(e,t){this.updateUIClasses({mouse:_.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(O.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.point.id]})},lt.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},lt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.point.id;if(t.properties.active=n?F.ACTIVE:F.INACTIVE,!n)return r(t)},lt.onTrash=lt.stopDrawingAndRemove,lt.onKeyUp=function(e,t){if(Be(t)||Ge(t))return this.stopDrawingAndRemove(e,t)};const dt=lt,pt=function(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},ft={onSetup:function(){const e=this.newFeature({type:C.FEATURE,properties:{},geometry:{type:C.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),We.disable(this),this.updateUIClasses({mouse:_.ADD}),this.activateUIButton(I.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&pt(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:_.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),Ve(t)&&this.updateUIClasses({mouse:_.POINTER})}};ft.onTap=ft.onClick=function(e,t){return Ve(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},ft.onKeyUp=function(e,t){Be(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)):Ge(t)&&this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},ft.onStop=function(e){this.updateUIClasses({mouse:_.NONE}),We.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(O.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT,{},{silent:!0})))},ft.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.polygon.id;if(t.properties.active=n?F.ACTIVE:F.INACTIVE,!n)return r(t);if(0===t.geometry.coordinates.length)return;const o=t.geometry.coordinates[0].length;if(!(o<3)){if(t.properties.meta=A.FEATURE,r(Je(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const n=t.geometry.coordinates[0].length-3;r(Je(e.polygon.id,t.geometry.coordinates[0][n],`0.${n}`,!1))}if(o<=4){const e=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(r({type:C.FEATURE,properties:t.properties,geometry:{coordinates:e,type:C.LINE_STRING}}),3===o)return}return r(t)}},ft.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)};const ht=ft,gt={onSetup:function(e){const t=(e=e||{}).featureId;let r,n,o="forward";if(t){if(r=this.getFeature(t),!r)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const a=r.coordinates.length-1;if(r.coordinates[a][0]===i[0]&&r.coordinates[a][1]===i[1])n=a+1,r.addCoordinate(n,...r.coordinates[a]);else{if(r.coordinates[0][0]!==i[0]||r.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");o="backwards",n=0,r.addCoordinate(n,...r.coordinates[0])}}else r=this.newFeature({type:C.FEATURE,properties:{},geometry:{type:C.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(r);return this.clearSelectedFeatures(),We.disable(this),this.updateUIClasses({mouse:_.ADD}),this.activateUIButton(I.LINE),this.setActionableState({trash:!0}),{line:r,currentVertexPosition:n,direction:o}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&pt(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&pt(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:_.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),Ve(t)&&this.updateUIClasses({mouse:_.POINTER})}};gt.onTap=gt.onClick=function(e,t){if(Ve(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},gt.onKeyUp=function(e,t){Ge(t)?this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.line.id]}):Be(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT))},gt.onStop=function(e){We.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(O.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT,{},{silent:!0})))},gt.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)},gt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.line.id;if(t.properties.active=n?F.ACTIVE:F.INACTIVE,!n)return r(t);t.geometry.coordinates.length<2||(t.properties.meta=A.FEATURE,r(Je(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),r(t))};const yt={simple_select:it,direct_select:ct,draw_point:dt,draw_polygon:ht,draw_line_string:gt},mt={defaultMode:T.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Ae,modes:yt,controls:{},userProperties:!1,suppressAPIEvents:!0},vt={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},bt={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function Et(e,t){return e.map(e=>e.source?e:Object.assign({},e,{id:`${e.id}.${t}`,source:"hot"===t?P.HOT:P.COLD}))}var St=r("./node_modules/fast-deep-equal/index.js"),wt=r("./node_modules/@mapbox/geojson-normalize/index.js");function xt(e,t){return e.length===t.length&&JSON.stringify(e.map(e=>e).sort())===JSON.stringify(t.map(e=>e).sort())}const Mt={Polygon:he,LineString:pe,Point:le,MultiPolygon:ve,MultiLineString:ve,MultiPoint:ve};function Pt(e){!function(e,t){const r={options:e=function(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),!1===e.displayControlsDefault?t.controls=Object.assign({},bt,e.controls):t.controls=Object.assign({},vt,e.controls),t=Object.assign({},mt,t),t.styles=Et(t.styles,"cold").concat(Et(t.styles,"hot")),t}(e)};t=function(e,t){t.modes=T;const r=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(t){return H.click({point:t},null,e).map(e=>e.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:C.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(t=>e.store.get(t)).map(e=>e.toGeoJSON())}},t.getSelectedPoints=function(){return{type:C.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(e=>({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:e.coordinates}}))}},t.set=function(r){if(void 0===r.type||r.type!==C.FEATURE_COLLECTION||!Array.isArray(r.features))throw new Error("Invalid FeatureCollection");const n=e.store.createRenderBatch();let o=e.store.getAllIds().slice();const i=t.add(r),a=new J(i);return o=o.filter(e=>!a.has(e)),o.length&&t.delete(o),n(),i},t.add=function(t){const n=JSON.parse(JSON.stringify(wt(t))).features.map(t=>{if(t.id=t.id||ae(),null===t.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(t.id)||e.store.get(t.id).type!==t.geometry.type){const n=Mt[t.geometry.type];if(void 0===n)throw new Error(`Invalid geometry type: ${t.geometry.type}.`);const o=new n(e,t);e.store.add(o,{silent:r})}else{const n=e.store.get(t.id),o=n.properties;n.properties=t.properties,St(o,t.properties)||e.store.featureChanged(n.id,{silent:r}),St(n.getCoordinates(),t.geometry.coordinates)||n.incomingCoords(t.geometry.coordinates)}return t.id});return e.store.render(),n},t.get=function(t){const r=e.store.get(t);if(r)return r.toGeoJSON()},t.getAll=function(){return{type:C.FEATURE_COLLECTION,features:e.store.getAll().map(e=>e.toGeoJSON())}},t.delete=function(n){return e.store.delete(n,{silent:r}),t.getMode()!==T.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(T.SIMPLE_SELECT,void 0,{silent:r}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:r}),t.getMode()===T.DIRECT_SELECT?e.events.changeMode(T.SIMPLE_SELECT,void 0,{silent:r}):e.store.render(),t},t.changeMode=function(n,o={}){return n===T.SIMPLE_SELECT&&t.getMode()===T.SIMPLE_SELECT?(xt(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:r}),e.store.render()),t):(n===T.DIRECT_SELECT&&t.getMode()===T.DIRECT_SELECT&&o.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(n,o,{silent:r}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:r}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:r}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:r}),t},t.setFeatureProperty=function(n,o,i){return e.store.setFeatureProperty(n,o,i,{silent:r}),t},t}(r,t),r.api=t;const n=Ce(r);t.onAdd=n.onAdd,t.onRemove=n.onRemove,t.types=I,t.options=e}(e,this)}Pt.modes=yt,Pt.constants=n,Pt.lib=i;const _t=Pt;var It={onSetup:function(){return{}},onClick:function(){return!1},onKeyUp:function(){return!1},onDrag:function(){return!1},toDisplayFeatures:function(e,t,r){t.properties.active="false",r(t)}};function Ct(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Tt(e){return"Feature"===e.type?e.geometry:e}function Ot(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function Lt(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Nt(e[0])||!Nt(e[1]))throw new Error("coordinates must contain numbers");return Ot({type:"Point",coordinates:e},t,r)}function At(e,t,r={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return Ot({type:"Polygon",coordinates:e},t,r)}function Ft(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Ot({type:"LineString",coordinates:e},t,r)}function kt(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function Nt(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}Math.PI;const jt=11102230246251565e-32,Rt=134217729,Dt=(3+8*jt)*jt;function Vt(e,t,r,n,o){let i,a,s,u,c=t[0],l=n[0],d=0,p=0;l>c==l>-c?(i=c,c=t[++d]):(i=l,l=n[++p]);let f=0;if(d<e&&p<r)for(l>c==l>-c?(a=c+i,s=i-(a-c),c=t[++d]):(a=l+i,s=i-(a-l),l=n[++p]),i=a,0!==s&&(o[f++]=s);d<e&&p<r;)l>c==l>-c?(a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d]):(a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p]),i=a,0!==s&&(o[f++]=s);for(;d<e;)a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d],i=a,0!==s&&(o[f++]=s);for(;p<r;)a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p],i=a,0!==s&&(o[f++]=s);return 0===i&&0!==f||(o[f++]=i),f}function Ut(e){return new Float64Array(e)}const Bt=Ut(4),Gt=Ut(8),Yt=Ut(12),Xt=Ut(16),qt=Ut(4);function Jt(e,t,r,n,o,i){const a=(t-i)*(r-o),s=(e-o)*(n-i),u=a-s,c=Math.abs(a+s);return Math.abs(u)>=33306690738754716e-32*c?u:-function(e,t,r,n,o,i,a){let s,u,c,l,d,p,f,h,g,y,m,v,b,E,S,w,x,M;const P=e-o,_=r-o,I=t-i,C=n-i;E=P*C,p=Rt*P,f=p-(p-P),h=P-f,p=Rt*C,g=p-(p-C),y=C-g,S=h*y-(E-f*g-h*g-f*y),w=I*_,p=Rt*I,f=p-(p-I),h=I-f,p=Rt*_,g=p-(p-_),y=_-g,x=h*y-(w-f*g-h*g-f*y),m=S-x,d=S-m,Bt[0]=S-(m+d)+(d-x),v=E+m,d=v-E,b=E-(v-d)+(m-d),m=b-w,d=b-m,Bt[1]=b-(m+d)+(d-w),M=v+m,d=M-v,Bt[2]=v-(M-d)+(m-d),Bt[3]=M;let T=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,Bt),O=22204460492503146e-32*a;if(T>=O||-T>=O)return T;if(d=e-P,s=e-(P+d)+(d-o),d=r-_,c=r-(_+d)+(d-o),d=t-I,u=t-(I+d)+(d-i),d=n-C,l=n-(C+d)+(d-i),0===s&&0===u&&0===c&&0===l)return T;if(O=11093356479670487e-47*a+Dt*Math.abs(T),T+=P*l+C*s-(I*c+_*u),T>=O||-T>=O)return T;E=s*C,p=Rt*s,f=p-(p-s),h=s-f,p=Rt*C,g=p-(p-C),y=C-g,S=h*y-(E-f*g-h*g-f*y),w=u*_,p=Rt*u,f=p-(p-u),h=u-f,p=Rt*_,g=p-(p-_),y=_-g,x=h*y-(w-f*g-h*g-f*y),m=S-x,d=S-m,qt[0]=S-(m+d)+(d-x),v=E+m,d=v-E,b=E-(v-d)+(m-d),m=b-w,d=b-m,qt[1]=b-(m+d)+(d-w),M=v+m,d=M-v,qt[2]=v-(M-d)+(m-d),qt[3]=M;const L=Vt(4,Bt,4,qt,Gt);E=P*l,p=Rt*P,f=p-(p-P),h=P-f,p=Rt*l,g=p-(p-l),y=l-g,S=h*y-(E-f*g-h*g-f*y),w=I*c,p=Rt*I,f=p-(p-I),h=I-f,p=Rt*c,g=p-(p-c),y=c-g,x=h*y-(w-f*g-h*g-f*y),m=S-x,d=S-m,qt[0]=S-(m+d)+(d-x),v=E+m,d=v-E,b=E-(v-d)+(m-d),m=b-w,d=b-m,qt[1]=b-(m+d)+(d-w),M=v+m,d=M-v,qt[2]=v-(M-d)+(m-d),qt[3]=M;const A=Vt(L,Gt,4,qt,Yt);E=s*l,p=Rt*s,f=p-(p-s),h=s-f,p=Rt*l,g=p-(p-l),y=l-g,S=h*y-(E-f*g-h*g-f*y),w=u*c,p=Rt*u,f=p-(p-u),h=u-f,p=Rt*c,g=p-(p-c),y=c-g,x=h*y-(w-f*g-h*g-f*y),m=S-x,d=S-m,qt[0]=S-(m+d)+(d-x),v=E+m,d=v-E,b=E-(v-d)+(m-d),m=b-w,d=b-m,qt[1]=b-(m+d)+(d-w),M=v+m,d=M-v,qt[2]=v-(M-d)+(m-d),qt[3]=M;const F=Vt(A,Yt,4,qt,Xt);return Xt[F-1]}(e,t,r,n,o,i,c)}function $t(e,t){var r,n,o,i,a,s,u,c,l,d=0,p=e[0],f=e[1],h=t.length;for(r=0;r<h;r++){n=0;var g=t[r],y=g.length-1;if((c=g[0])[0]!==g[y][0]&&c[1]!==g[y][1])throw new Error("First and last coordinates in a ring must be the same");for(i=c[0]-p,a=c[1]-f;n<y;n++){if(s=(l=g[n+1])[0]-p,u=l[1]-f,0===a&&0===u){if(s<=0&&i>=0||i<=0&&s>=0)return 0}else if(u>=0&&a<=0||u<=0&&a>=0){if(0===(o=Jt(i,s,a,u,0,0)))return 0;(o>0&&u>0&&a<=0||o<0&&u<=0&&a>0)&&d++}c=l,a=u,i=s}}return d%2!=0}function Ht(e,t,r={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=Ct(e),o=Tt(t),i=o.type,a=t.bbox;let s=o.coordinates;if(a&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(n,a))return!1;"Polygon"===i&&(s=[s]);let u=!1;for(var c=0;c<s.length;++c){const e=$t(n,s[c]);if(0===e)return!r.ignoreBoundary;e&&(u=!0)}return u}Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(8),Ut(8),Ut(8),Ut(4),Ut(8),Ut(8),Ut(8),Ut(12),Ut(192),Ut(192),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(8),Ut(8),Ut(8),Ut(8),Ut(8),Ut(8),Ut(8),Ut(8),Ut(8),Ut(4),Ut(4),Ut(4),Ut(8),Ut(16),Ut(16),Ut(16),Ut(32),Ut(32),Ut(48),Ut(64),Ut(1152),Ut(1152),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(4),Ut(24),Ut(24),Ut(24),Ut(24),Ut(24),Ut(24),Ut(24),Ut(24),Ut(24),Ut(24),Ut(1152),Ut(1152),Ut(1152),Ut(1152),Ut(1152),Ut(2304),Ut(2304),Ut(3456),Ut(5760),Ut(8),Ut(8),Ut(8),Ut(16),Ut(24),Ut(48),Ut(48),Ut(96),Ut(192),Ut(384),Ut(384),Ut(384),Ut(768),Ut(96),Ut(96),Ut(96),Ut(1152);class Wt{constructor(e=[],t=Kt){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const o=e-1>>1,i=t[o];if(r(n,i)>=0)break;t[e]=i,e=o}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,o=t[e];for(;e<n;){let n=1+(e<<1),i=t[n];const a=n+1;if(a<this.length&&r(t[a],i)<0&&(n=a,i=t[a]),r(i,o)>=0)break;t[e]=i,e=n}t[e]=o}}function Kt(e,t){return e<t?-1:e>t?1:0}function zt(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function Zt(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class Qt{constructor(e,t,r,n){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=n,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}let er=0,tr=0,rr=0;function nr(e,t){const r="Feature"===e.type?e.geometry:e;let n=r.coordinates;"Polygon"!==r.type&&"MultiLineString"!==r.type||(n=[n]),"LineString"===r.type&&(n=[[n]]);for(let e=0;e<n.length;e++)for(let r=0;r<n[e].length;r++){let o=n[e][r][0],i=null;tr+=1;for(let a=0;a<n[e][r].length-1;a++){i=n[e][r][a+1];const s=new Qt(o,er,tr,rr),u=new Qt(i,er,tr,rr+1);s.otherEvent=u,u.otherEvent=s,zt(s,u)>0?(u.isLeftEndpoint=!0,s.isLeftEndpoint=!1):(s.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(s),t.push(u),o=i,rr+=1}}er+=1}class or{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function ir(e,t){if(null===e||null===t)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const r=e.leftSweepEvent.p.x,n=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,i=e.rightSweepEvent.p.y,a=t.leftSweepEvent.p.x,s=t.leftSweepEvent.p.y,u=t.rightSweepEvent.p.x,c=t.rightSweepEvent.p.y,l=(c-s)*(o-r)-(u-a)*(i-n);if(0===l)return!1;const d=((u-a)*(n-s)-(c-s)*(r-a))/l,p=((o-r)*(n-s)-(i-n)*(r-a))/l;return d>=0&&d<=1&&p>=0&&p<=1&&[r+d*(o-r),n+d*(i-n)]}function ar(e,t,r={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:o=!0}=r;let i=[];"FeatureCollection"===e.type?i=i.concat(e.features):"Feature"===e.type?i.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||i.push(Ot(e)),"FeatureCollection"===t.type?i=i.concat(t.features):"Feature"===t.type?i.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||i.push(Ot(t));const a=function(e,t){const r=new Wt([],zt);return function(e,t){if("FeatureCollection"===e.type){const r=e.features;for(let e=0;e<r.length;e++)nr(r[e],t)}else nr(e,t)}(e,r),function(e,t){t=t||!1;const r=[],n=new Wt([],Zt);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const e=new or(o);for(let i=0;i<n.data.length;i++){const a=n.data[i];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const s=ir(e,a);!1!==s&&r.push(s)}n.push(e)}else!1===o.isLeftEndpoint&&n.pop()}return r}(r,t)}(kt(i),o);let s=[];if(n){const e={};a.forEach(t=>{const r=t.join(",");e[r]||(e[r]=!0,s.push(t))})}else s=a;return kt(s.map(e=>Lt(e)))}function sr(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,g=f?e.features.length:1;for(r=0;r<g;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}function ur(e,t){sr(e,function(e,r,n,o,i){var a,s=null===e?null:e.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==t(Ot(e,n,{bbox:o,id:i}),r,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var u=0;u<e.coordinates.length;u++){var c=e.coordinates[u];if(!1===t(Ot({type:a,coordinates:c},n),r,u))return!1}})}function cr(e,t={}){const r=Tt(e);switch(t.properties||"Feature"!==e.type||(t.properties=e.properties),r.type){case"Polygon":return function(e,t={}){return lr(Tt(e).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}(r,t);case"MultiPolygon":return function(e,t={}){const r=Tt(e).coordinates,n=t.properties?t.properties:"Feature"===e.type?e.properties:{},o=[];return r.forEach(e=>{o.push(lr(e,n))}),kt(o)}(r,t);default:throw new Error("invalid poly")}}function lr(e,t){return e.length>1?function(e,t,r={}){return Ot({type:"MultiLineString",coordinates:e},t,r)}(e,t):Ft(e[0],t)}function dr(e,t,{ignoreSelfIntersections:r=!0}={ignoreSelfIntersections:!0}){let n=!0;return ur(e,e=>{ur(t,t=>{if(!1===n)return!1;n=function(e,t,r){switch(e.type){case"Point":switch(t.type){case"Point":return n=e.coordinates,o=t.coordinates,!(n[0]===o[0]&&n[1]===o[1]);case"LineString":return!pr(t,e);case"Polygon":return!Ht(e,t)}break;case"LineString":switch(t.type){case"Point":return!pr(e,t);case"LineString":return!function(e,t,r){return ar(e,t,{ignoreSelfIntersections:r}).features.length>0}(e,t,r);case"Polygon":return!fr(t,e,r)}break;case"Polygon":switch(t.type){case"Point":return!Ht(t,e);case"LineString":return!fr(e,t,r);case"Polygon":return!function(e,t,r){for(const r of e.coordinates[0])if(Ht(r,t))return!0;for(const r of t.coordinates[0])if(Ht(r,e))return!0;return ar(cr(e),cr(t),{ignoreSelfIntersections:r}).features.length>0}(t,e,r)}}var n,o;return!1}(e.geometry,t.geometry,r)})}),n}function pr(e,t){for(let r=0;r<e.coordinates.length-1;r++)if(hr(e.coordinates[r],e.coordinates[r+1],t.coordinates))return!0;return!1}function fr(e,t,r){for(const r of t.coordinates)if(Ht(r,e))return!0;return ar(t,cr(e),{ignoreSelfIntersections:r}).features.length>0}function hr(e,t,r){const n=r[0]-e[0],o=r[1]-e[1],i=t[0]-e[0],a=t[1]-e[1];return 0===n*a-o*i&&(Math.abs(i)>=Math.abs(a)?i>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:a>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1])}function gr(e,t){var r=Tt(e),n=Tt(t),o=r.type,i=n.type;switch(o){case"MultiPoint":switch(i){case"LineString":return yr(r,n);case"Polygon":return vr(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"LineString":switch(i){case"MultiPoint":return yr(n,r);case"LineString":return function(e,t){if(ar(e,t).features.length>0)for(var r=0;r<e.coordinates.length-1;r++)for(var n=0;n<t.coordinates.length-1;n++){var o=!0;if(0!==n&&n!==t.coordinates.length-2||(o=!1),br(e.coordinates[r],e.coordinates[r+1],t.coordinates[n],o))return!0}return!1}(r,n);case"Polygon":return mr(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"Polygon":switch(i){case"MultiPoint":return vr(n,r);case"LineString":return mr(n,r);default:throw new Error("feature2 "+i+" geometry not supported")}default:throw new Error("feature1 "+o+" geometry not supported")}}function yr(e,t){for(var r=!1,n=!1,o=e.coordinates.length,i=0;i<o&&!r&&!n;){for(var a=0;a<t.coordinates.length-1;a++){var s=!0;0!==a&&a!==t.coordinates.length-2||(s=!1),br(t.coordinates[a],t.coordinates[a+1],e.coordinates[i],s)?r=!0:n=!0}i++}return r&&n}function mr(e,t){return ar(e,cr(t)).features.length>0}function vr(e,t){var r=!1,n=!1,o=e.coordinates.length;for(let i=0;i<o&&(!r||!n);i++)Ht(Lt(e.coordinates[i]),t)?r=!0:n=!0;return n&&r}function br(e,t,r,n){var o=r[0]-e[0],i=r[1]-e[1],a=t[0]-e[0],s=t[1]-e[1];return 0===o*s-i*a&&(n?Math.abs(a)>=Math.abs(s)?a>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:s>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1]:Math.abs(a)>=Math.abs(s)?a>0?e[0]<r[0]&&r[0]<t[0]:t[0]<r[0]&&r[0]<e[0]:s>0?e[1]<r[1]&&r[1]<t[1]:t[1]<r[1]&&r[1]<e[1])}function Er(e,t,r={}){const n=Ct(e),o=function(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}(t);for(let e=0;e<o.length-1;e++){let t=!1;if(r.ignoreEndVertices&&(0===e&&(t="start"),e===o.length-2&&(t="end"),0===e&&e+1===o.length-1&&(t="both")),Sr(o[e],o[e+1],n,t,void 0===r.epsilon?null:r.epsilon))return!0}return!1}function Sr(e,t,r,n,o){const i=r[0],a=r[1],s=e[0],u=e[1],c=t[0],l=t[1],d=c-s,p=l-u,f=(r[0]-s)*p-(r[1]-u)*d;if(null!==o){if(Math.abs(f)>o)return!1}else if(0!==f)return!1;return Math.abs(d)===Math.abs(p)&&0===Math.abs(d)?!n&&r[0]===e[0]&&r[1]===e[1]:n?"start"===n?Math.abs(d)>=Math.abs(p)?d>0?s<i&&i<=c:c<=i&&i<s:p>0?u<a&&a<=l:l<=a&&a<u:"end"===n?Math.abs(d)>=Math.abs(p)?d>0?s<=i&&i<c:c<i&&i<=s:p>0?u<=a&&a<l:l<a&&a<=u:"both"===n&&(Math.abs(d)>=Math.abs(p)?d>0?s<i&&i<c:c<i&&i<s:p>0?u<a&&a<l:l<a&&a<u):Math.abs(d)>=Math.abs(p)?d>0?s<=i&&i<=c:c<=i&&i<=s:p>0?u<=a&&a<=l:l<=a&&a<=u}function wr(e){return e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]}function xr(e){for(var t=0;t<e.length-1;t++)for(var r=e[t],n=t+1;n<e.length-2;n++)if(Er(r,Ft([e[n],e[n+1]])))return!0;return!1}function Mr(e,t,r){for(var n=At(e),o=r+1;o<t.length;o++)if(!dr(n,At(t[o]))&&gr(n,Ft(t[o][0])))return!1;return!0}function Pr(e){let t=0;if(e&&e.length>0){t+=Math.abs(Cr(e[0]));for(let r=1;r<e.length;r++)t-=Math.abs(Cr(e[r]))}return t}var _r=20294876564838.72,Ir=Math.PI/180;function Cr(e){const t=e.length-1;if(t<=2)return 0;let r=0,n=0;for(;n<t;){const o=e[n],i=e[n+1===t?0:n+1],a=e[n+2>=t?(n+2)%t:n+2],s=o[0]*Ir,u=i[1]*Ir;r+=(a[0]*Ir-s)*Math.sin(u),n++}return r*_r}var Tr=function(e){return function(e){var t=0;return sr(e,function(e,r,n,o,i){t=t+function(e){let t,r=0;switch(e.type){case"Polygon":return Pr(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)r+=Pr(e.coordinates[t]);return r;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e)}),t}(e)};function Or(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Lr(e,t)||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 Lr(e,t){if(e){if("string"==typeof e)return Ar(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ar(e,t):void 0}}function Ar(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Fr=function(e,t){var r=Or(e,2),n=r[0],o=r[1],i=Or(t,2),a=i[0],s=i[1],u=function(e){return e*Math.PI/180},c=u(s-o),l=u(a-n),d=Math.pow(Math.sin(c/2),2)+Math.cos(u(o))*Math.cos(u(s))*Math.pow(Math.sin(l/2),2);return 12742e3*Math.atan2(Math.sqrt(d),Math.sqrt(1-d))},kr=function(e){if(e[0].length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e[0].length<=1)return!0;if(e[0].length<=3)for(var r=0;r<e[0].length;r++)for(var n=r+1;n<e[0].length;n++)if(Fr(e[0][r],e[0][n])<t)return!1;return!0}(e))return!0;if(!Array.isArray(e)||e.length<4)return!1;var t=e[0],r=e[e.length-1];if(t[0]!==r[0]||t[1]!==r[1])return!1;var n=At([e]);return!(!function(e){if(!e.type)return!1;const t=Tt(e),r=t.type,n=t.coordinates;switch(r){case"Point":return n.length>1;case"MultiPoint":for(var o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"LineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"MultiLineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"Polygon":for(o=0;o<t.coordinates.length;o++){if(n[o].length<4)return!1;if(!wr(n[o]))return!1;if(xr(n[o]))return!1;if(o>0&&ar(At([n[0]]),At([n[o]])).features.length>1)return!1}return!0;case"MultiPolygon":for(o=0;o<t.coordinates.length;o++)for(var i=t.coordinates[o],a=0;a<i.length;a++){if(i[a].length<4)return!1;if(!wr(i[a]))return!1;if(xr(i[a]))return!1;if(0===a&&!Mr(i,t.coordinates,o))return!1;if(a>0&&ar(At([i[0]]),At([i[a]])).features.length>1)return!1}return!0;default:return!1}}(n)||Tr(n)<=0)},Nr=function(e,t,r){var n=t.filter(function(t,n){var o=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);return("ArrowUp"===r?t[1]<=e[1]&&i>=o:"ArrowDown"===r?t[1]>e[1]&&i>=o:"ArrowLeft"===r?t[0]<=e[0]&&i<o:"ArrowRight"!==r||t[0]>e[0]&&i<o)&&JSON.stringify(t)!==JSON.stringify(e)});n.length||n.push(e);var o,i=n.map(function(t){return r=Math.abs(e[0]-t[0]),n=Math.abs(e[1]-t[1]),Math.sqrt(Math.pow(r,2)+Math.pow(n,2));var r,n}),a=n[i.indexOf(Math.min.apply(Math,(o=i,function(e){if(Array.isArray(e))return Ar(e)}(o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||Lr(o)||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.")}())))];return t.findIndex(function(e){return JSON.stringify(e)===JSON.stringify(a)})};function jr(e){return jr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},jr(e)}function Rr(e){return function(e){if(Array.isArray(e))return Ur(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Vr(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.")}()}function Dr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Vr(e,t)||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 Vr(e,t){if(e){if("string"==typeof e)return Ur(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ur(e,t):void 0}}function Ur(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Br(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Gr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Br(Object(r),!0).forEach(function(t){Yr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Br(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Yr(e,t,r){return(t=function(e){var t=function(e){if("object"!=jr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=jr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==jr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Xr=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"],qr={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},Jr=function(e,t){return{x:e.x*t,y:e.y*t}},$r=function(e){return e instanceof window.SVGElement||e.ownerSVGElement},Hr=Gr(Gr({},ct),{},{onSetup:function(e){var t,r=ct.onSetup.call(this,e);return Object.assign(r,{container:e.container,interfaceType:e.interfaceType,deleteVertexButtonId:e.deleteVertexButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,featureId:r.featureId||e.featureId,selectedVertexIndex:null!==(t=e.selectedVertexIndex)&&void 0!==t?t:-1,selectedVertexType:e.selectedVertexType,scale:e.scale}),r.vertecies=this.getVerticies(r.featureId),r.midpoints=this.getMidpoints(r.featureId),this.setupEventListeners(r),"midpoint"===e.selectedVertexType&&this.updateMidpoint(r.midpoints[e.selectedVertexIndex-r.vertecies.length]),this.addTouchVertexTarget(r),r},setupEventListeners:function(e){var t=this,r=function(r){return function(n){return r.call(t,e,n)}},n=this.handlers={keydown:r(this.onKeydown),keyup:r(this.onKeyup),pointerdown:r(this.onPointerevent),pointermove:r(this.onPointerevent),pointerup:r(this.onPointerevent),click:r(this.onVertexButtonClick),touchstart:r(this.onTouchstart),touchmove:r(this.onTouchmove),touchend:r(this.onTouchend),selectionchange:r(this.onSelectionChange),scalechange:r(this.onScaleChange),update:r(this.onUpdate),move:r(this.onMove)};window.addEventListener("keydown",n.keydown,{capture:!0}),window.addEventListener("keyup",n.keyup,{capture:!0}),window.addEventListener("click",n.click),e.container.addEventListener("pointerdown",n.pointerdown),e.container.addEventListener("pointermove",n.pointermove),e.container.addEventListener("pointerup",n.pointerup),e.container.addEventListener("touchstart",n.touchstart,{passive:!1}),e.container.addEventListener("touchmove",n.touchmove,{passive:!1}),e.container.addEventListener("touchend",n.touchend,{passive:!1}),this.map.on("draw.selectionchange",n.selectionchange),this.map.on("draw.scalechange",n.scalechange),this.map.on("draw.update",n.update),this.map.on("move",n.move)},onSelectionChange:function(e,t){var r,n,o=null===(r=t.points[t.points.length-1])||void 0===r?void 0:r.geometry.coordinates,i=t.features[0].geometry.coordinates.flat(1).findIndex(function(e){return o&&e[0]===o[0]&&e[1]===o[1]});e.selectedVertexIndex="keyboard"===e.interfaceType?e.selectedVertexIndex:i,null!==(n=e.selectedVertexType)&&void 0!==n||(e.selectedVertexType=i>=0?"vertex":null),this.map.fire("draw.vertexselection",{index:"vertex"===e.selectedVertexType?e.selectedVertexIndex:-1,numVertecies:e.vertecies.length}),this.updateTouchVertexTarget(e,o?Jr(this.map.project(o),e.scale):null)},onScaleChange:function(e,t){e.scale=t.scale},onUpdate:function(e){var t,r=new Set(e.vertecies.map(function(e){return JSON.stringify(e)}));r.size!==e.vertecies.length&&(e.selectedVertexIndex=e.vertecies.findIndex(function(e){return!r.has(JSON.stringify(e))}),null!==(t=e.selectedVertexType)&&void 0!==t||(e.selectedVertexType=e.selectedVertexIndex>=0?"vertex":null))},onKeydown:function(e,t){if(e.interfaceType="keyboard",this.hideTouchVertexIndicator(e)," "===t.key&&e.selectedVertexIndex<0)return e.isPanEnabled=!1,this.updateVertex(e);if(!t.altKey&&Xr.includes(t.key)&&e.selectedVertexIndex>=0){if(t.preventDefault(),t.stopPropagation(),"midpoint"===e.selectedVertexType)return this.insertVertex(e,t);var r=y(this.map),n=this.getFeature(e.featureId).coordinates.flat(1)[e.selectedVertexIndex];if(S(e)&&e._isSnapped&&r){var o=function(e){var t,r;return null!==(t=null==e||null===(r=e.options)||void 0===r?void 0:r.radius)&&void 0!==t?t:15}(r)+1,i=this.map.project(n),a=Dr(qr[t.key].map(function(e){return e*o}),2),s=a[0],u=a[1];return e._isSnapped=!1,function(e,t){var r,n,o;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(r=e.snappedFeatures)&&void 0!==r&&r.length&&(e.snappedFeatures.length=0),null!==(n=e.closeFeatures)&&void 0!==n&&n.length&&(e.closeFeatures.length=0),null!==(o=e.lines)&&void 0!==o&&o.length&&(e.lines.length=0)),null!=t&&t.getLayer("snap-helper-circle")&&t.setLayoutProperty("snap-helper-circle","visibility","none")}(r,this.map),this.moveVertex(e,this.map.unproject({x:i.x+s,y:i.y+u}))}var c=this.getNewCoord(e,t);return S(e)&&r&&(b(r,this.map,this.map.project(c)),m(r))?(e._isSnapped=!0,this.moveVertex(e,v(r))):(e._isSnapped=!1,this.moveVertex(e,c))}if(t.altKey&&Xr.includes(t.key)&&e.selectedVertexIndex>=0)return this.updateVertex(e,t.key);"Escape"===t.key&&this.changeMode(e,{isPanEnabled:!0,selectedVertexIndex:-1,selectedVertexType:null})},onKeyup:function(e,t){e.interfaceType="keyboard",Xr.includes(t.key)&&e.selectedVertexIndex>=0&&t.stopPropagation(),"Delete"===t.key&&this.deleteVertex(e)},onMouseDown:function(e,t){var r;E(y(this.map));var n=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta;["vertex","midpoint"].includes(n)&&(e.dragMoveLocation=t.lngLat,e.dragMoving=!1,ct.onMouseDown.call(this,e,t)),"midpoint"===n&&(e.selectedVertexIndex=this.getVertexIndexFromMidpoint(e.vertecies,t.featureTarget.properties.coord_path),e.selectedVertexType="vertex",this.map.fire("draw.vertexselection",{index:e.selectedVertexIndex,numVertecies:e.vertecies.length}))},onMouseUp:function(e,t){E(y(this.map)),e.dragMoving&&this.syncVertices(e),ct.onMouseUp.call(this,e,t)},onPointerevent:function(e,t){e.interfaceType="touch"===t.pointerType?"touch":"pointer",e.isPanEnabled=!0,"touch"!==t.pointerType||"pointermove"!==t.type||$r(t.target.parentNode)||this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,coordPath:null})},onTouchStart:function(){},onTouchMove:function(){},onTouchEnd:function(){},onTouchend:function(e){E(y(this.map)),null!=e&&e.featureId&&this.syncVertices(e)},clickNoTarget:function(e){this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,isPanEnabled:!0})},onTap:function(e,t){var r,n,o=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,i=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;"vertex"===o?this.changeMode(e,{selectedVertexIndex:Number.parseInt(i.split(".")[1],10),selectedVertexType:"vertex",coordPath:i}):"midpoint"===o?this.insertVertex(Gr(Gr({},e),{},{selectedVertexIndex:this.getVertexIndexFromMidpoint(e.vertecies,i),selectedVertexType:"midpoint"})):this.clickNoTarget(e)},onTouchstart:function(e,t){if(E(y(this.map)),!(e.selectedVertexIndex<0)&&$r(t.target.parentNode)){var r=t.touches[0].clientX,n=t.touches[0].clientY,o=window.getComputedStyle(e.touchVertexTarget);e.deltaTarget={x:r-Number.parseFloat(o.left),y:n-Number.parseFloat(o.top)};var i=this.map.project(e.vertecies[e.selectedVertexIndex]);e.deltaVertex={x:r/e.scale-i.x,y:n/e.scale-i.y}}},onTouchmove:function(e,t){if(!(e.selectedVertexIndex<0)&&$r(t.target.parentNode)){var r=t.touches[0].clientX,n=t.touches[0].clientY,o={x:r/e.scale-e.deltaVertex.x,y:n/e.scale-e.deltaVertex.y},i=this.map.unproject(o);if(S(e)){var a=y(this.map);b(a,this.map,o),i=v(a)||i}this.moveVertex(e,i),this.updateTouchVertexTarget(e,{x:r-e.deltaTarget.x,y:n-e.deltaTarget.y})}},onDrag:function(e,t){var r;if("touch"!==e.interfaceType){var n=y(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),S(e)&&null!=n&&n.status){if(null!==(r=e.selectedCoordPaths)&&void 0!==r&&r.length&&e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation(),b(n,this.map,t.point);var o=v(n)||t.lngLat;e.feature.updateCoordinate(e.selectedCoordPaths[0],o.lng,o.lat),e.dragMoveLocation=t.lngLat}}else ct.onDrag.call(this,e,t)}},onMove:function(e){var t=e.vertecies[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,Jr(this.map.project(t),e.scale))},onVertexButtonClick:function(e,t){t.target.closest("#".concat(e.deleteVertexButtonId))&&"vertex"===e.selectedVertexType&&this.deleteVertex(e)},syncVertices:function(e){e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)},getVerticies:function(e){var t;return(null===(t=this.getFeature(e))||void 0===t||null===(t=t.coordinates)||void 0===t?void 0:t.flat(1))||[]},getMidpoints:function(e){var t,r=(null===(t=this.getFeature(e))||void 0===t||null===(t=t.coordinates)||void 0===t?void 0:t.flat(1))||[];return r.map(function(e,t){var n=r[(t+1)%r.length];return[(e[0]+n[0])/2,(e[1]+n[1])/2]})},getVertexOrMidpoint:function(e,t){var r=this,n=function(e){return Object.values(r.map.project(e))},o=[].concat(Rr(e.vertecies.map(n)),Rr(e.midpoints.map(n))),i=o[e.selectedVertexIndex]||Object.values(this.map.project(this.map.getCenter())),a=Nr(i,o,t);return[a,a<e.vertecies.length?"vertex":"midpoint"]},getVertexIndexFromMidpoint:function(e,t){var r=Number.parseInt(t.split(".")[1],10);return e.length+(r-1+e.length)%e.length},addTouchVertexTarget:function(e){var t=e.container.querySelector("[data-touch-vertex-target]");t||(e.container.insertAdjacentHTML("beforeend","\n <svg width='48' height='48' viewBox='0 0 48 48' fill-rule='evenodd' style='display:none;position:absolute;top:50%;left:50%;margin:24px 0 0 -24px' class='touch-vertex-target' data-touch-vertex-target>\n <circle cx='24' cy='24' r='24' fill='currentColor'/>\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=\"#fff\"/>\n </svg>\n"),t=e.container.querySelector("[data-touch-vertex-target]")),e.touchVertexTarget=t},updateTouchVertexTarget:function(e,t){t&&"touch"===e.interfaceType&&e.selectedVertexIndex>=0?Object.assign(e.touchVertexTarget.style,{display:"block",top:"".concat(t.y,"px"),left:"".concat(t.x,"px")}):e.touchVertexTarget.style.display="none"},hideTouchVertexIndicator:function(e){e.touchVertexTarget.style.display="none"},updateMidpoint:function(e){var t=this;setTimeout(function(){t.map.getSource("mapbox-gl-draw-hot").setData({type:"Feature",properties:{meta:"midpoint",active:"true",id:"active-midpoint"},geometry:{type:"Point",coordinates:e}})},0)},updateVertex:function(e,t){var r=Dr(this.getVertexOrMidpoint(e,t),2),n=r[0],o=r[1];this.changeMode(e,Gr({selectedVertexIndex:n,selectedVertexType:o},"vertex"===o&&{coordPath:"0.".concat(n)}))},getOffset:function(e,t){var r=this.map.project(e),n=null!=t&&t.shiftKey?1:5,o=Dr(t?qr[t.key].map(function(e){return e*n}):[0,0],2),i=o[0],a=o[1];return this.map.unproject({x:r.x+i,y:r.y+a})},getNewCoord:function(e,t){return this.getOffset(this.getFeature(e.featureId).coordinates.flat(1)[e.selectedVertexIndex],t)},insertVertex:function(e,t){var r=this.getFeature(e.featureId),n=e.selectedVertexIndex-e.vertecies.length,o=this.getOffset(e.midpoints[n],t),i=r.toGeoJSON();("Polygon"===i.geometry.type?i.geometry.coordinates[0]:i.geometry.coordinates).splice(n+1,0,[o.lng,o.lat]),this._ctx.api.add(i),this.changeMode(e,{selectedVertexIndex:n+1,selectedVertexType:"vertex",coordPath:"0.".concat(n+1)})},moveVertex:function(e,t){if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).checkSnap&&!1!==e.enableSnap){var r,n=this.map._snapInstance;null!=n&&n.snapStatus&&(null===(r=n.snapCoords)||void 0===r?void 0:r.length)>=2&&(t={lng:n.snapCoords[0],lat:n.snapCoords[1]})}var o=this.getFeature(e.featureId).toGeoJSON();"Polygon"===o.geometry.type&&(o.geometry.coordinates[0][e.selectedVertexIndex]=[t.lng,t.lat]),this._ctx.api.add(o),e.vertecies=this.getVerticies(e.featureId)},deleteVertex:function(e){var t=this.getFeature(e.featureId);if(!(e.vertecies.length<=("Polygon"===t.type?3:2))){var r=e.selectedVertexIndex>=e.vertecies.length-1?0:e.selectedVertexIndex;this._ctx.api.trash(),this.changeMode(e,{selectedVertexIndex:r,selectedVertexType:"vertex",coordPath:"0.".concat(r)})}},changeMode:function(e,t){e.featureId&&this._ctx.api.changeMode("edit_vertex",Gr(Gr({},e),t))},onStop:function(e){var t=this.handlers;e.container.removeEventListener("pointerdown",t.pointerdown),e.container.removeEventListener("pointermove",t.pointermove),e.container.removeEventListener("pointerup",t.pointerup),e.container.removeEventListener("touchstart",t.touchstart),e.container.removeEventListener("touchmove",t.touchmove),e.container.removeEventListener("touchend",t.touchend),this.map.off("draw.selectionchange",t.selectionchange),this.map.off("draw.scalechange",t.scalechange),this.map.off("draw.update",t.update),this.map.off("move",t.move),this.map.dragPan.enable(),window.removeEventListener("click",t.click),window.removeEventListener("keydown",t.keydown,{capture:!0}),window.removeEventListener("keyup",t.keyup,{capture:!0}),this.hideTouchVertexIndicator(e)}});function Wr(e){return Wr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Wr(e)}function Kr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return zr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?zr(e,t):void 0}}(e,t)||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 zr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Zr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Qr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Zr(Object(r),!0).forEach(function(t){en(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Zr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function en(e,t,r){return(t=function(e){var t=function(e){if("object"!=Wr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Wr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Wr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var tn=Qr(Qr({},ht),{},{onSetup:function(e){var t=this,r=this.map,n=Qr(Qr({},ht.onSetup.call(this,e)),e),o=n.container,i=n.interfaceType,a=n.vertexMarkerId,s=o.querySelector("#".concat(a));s.style.display=["touch","keyboard"].includes(i)?"block":"none",n.vertexMarker=s;var u={keydownHandler:this.onKeydown,keyupHandler:this.onKeyup,focusHandler:this.onFocus,blurHandler:this.onBlur,createHandler:this.onCreate,moveHandler:this.onMove,pointerdownHandler:this.onPointerdown,pointermoveHandler:this.onPointermove,pointerupHandler:this.onPointerup,vertexButtonClickHandler:this.onVertexButtonClick};return Object.entries(u).forEach(function(e){var r,o,i=Kr(e,2);return r=i[0],o=i[1],t[r]=o.bind(t,n)}),this._listeners=[[window,"keydown",this.keydownHandler],[window,"keyup",this.keyupHandler],[window,"click",this.vertexButtonClickHandler],[o,"focus",this.focusHandler],[o,"blur",this.blurHandler],[o,"pointermove",this.pointermoveHandler],[o,"pointerup",this.pointerupHandler],[r,"pointerdown",this.pointerdownHandler],[r,"draw.create",this.createHandler],[r,"move",this.moveHandler]],this._listeners.forEach(function(e){var t=Kr(e,3),r=t[0],n=t[1],o=t[2];return r.addEventListener?r.addEventListener(n,o):r.on(n,o)}),n},onClick:function(e,t){if(!(t.originalEvent.button>0)){var r=y(this.map);if(S(e)&&m(r))t=function(e,t){var r=v(t);return r?h(h({},e),{},{lngLat:r}):e}(t,r);else{var n=e.polygon.coordinates[0];n.length>0&&(n[n.length-1]=[t.lngLat.lng,t.lngLat.lat])}ht.onClick.call(this,e,t)}},onTap:function(){},doClick:function(e){var t=e.polygon.coordinates;if(this.dispatchVertexChange(t[0]),kr(t)){var r=y(this.map),n=S(e)&&function(e,t){var r=v(t);if(!r)return null;var n=e.project([r.lng,r.lat]);return{lngLat:r,point:n,originalEvent:new MouseEvent("click",{clientX:n.x,clientY:n.y,bubbles:!0,cancelable:!0})}}(this.map,r);n?(ht.onClick.call(this,e,n),this._ctx.store.render()):this._simulateMouse("click",ht.onClick,e)}},dispatchVertexChange:function(e){this.map.fire("draw.vertexchange",{numVertecies:e.length})},_simulateMouse:function(e,t,r){var n=this.map,o=n.getCenter(),i=n.project(o);t.call(this,r,{lngLat:o,point:i,originalEvent:new MouseEvent(e,{clientX:i.x,clientY:i.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render()},_setInterface:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e.interfaceType=t,r&&(e.vertexMarker.style.display="block")},onCreate:function(e,t){var r=this._ctx.api,n=t.features[0];r.delete(n.id),n.id=e.featureId,r.add(n)},onVertexButtonClick:function(e,t){t.target.closest("#".concat(e.addVertexButtonId))&&this.doClick(e)},onTouchStart:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onTouchEnd:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onKeydown:function(e,t){if(document.activeElement===e.container){if("Escape"===t.key)return t.preventDefault();"Enter"===t.key&&(e.isActive=!0),this._setInterface(e,"keyboard"),this.onMove(e,t)}},onKeyup:function(e,t){"Escape"!==t.key&&(this._setInterface(e,"keyboard"),this.onMove(e,t),"Enter"===t.key&&e.isActive&&this.doClick(e))},onFocus:function(e){var t=e.vertexMarker,r=e.interfaceType;t.style.display=["touch","keyboard"].includes(r)?"block":"none"},onBlur:function(e,t){t.target!==e.container&&(e.vertexMarker.style.display="none")},onMouseMove:function(e,t){if(S(e)){var r=y(this.map);b(r,this.map,t.point);var n=v(r);n&&(t=Qr(Qr({},t),{},{lngLat:n}))}ht.onMouseMove.call(this,e,t)},onMove:function(e){if(["touch","keyboard"].includes(e.interfaceType)){S(e)&&function(e,t){if(!e||!t||!e.status)return!1;var r=t.getCenter(),n=t.project(r);e.snapToClosestPoint({point:n,lngLat:r})}(y(this.map),this.map);var t=y(this.map),r=S(e)&&v(t);if(r){var n=this.map.project([r.lng,r.lat]);ht.onMouseMove.call(this,e,{lngLat:r,point:n,originalEvent:new MouseEvent("mousemove",{clientX:n.x,clientY:n.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render()}else this._simulateMouse("mousemove",ht.onMouseMove,e)}},onPointerdown:function(e,t){"touch"!==t.pointerType&&this._setInterface(e,"pointer",!1)},onPointermove:function(e,t){"touch"!==t.pointerType&&(e.vertexMarker.style.display="none")},onPointerup:function(e){this.dispatchVertexChange(e.polygon.coordinates[0])},toDisplayFeatures:function(e,t,r){if(ht.toDisplayFeatures.call(this,e,t,r),"Polygon"===t.geometry.type&&t.id===e.polygon.id)for(var n=t.geometry.coordinates[0],o=1;o<n.length-2;o++)r(Je(t.id,n[o],"0.".concat(o)))},onStop:function(e){ht.onStop.call(this,e),this._listeners.forEach(function(e){var t=Kr(e,3),r=t[0],n=t[1],o=t[2];return r.removeEventListener?r.removeEventListener(n,o):r.off(n,o)}),e.vertexMarker.style.display="none"}}),rn={editColorsForeground:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editColorsBackground:{light:"#ffffff",dark:"rgba(11,12,12,1)"},editColorsHalo:{light:"rgba(11,12,12,1)",dark:"#ffffff"},stroke:"rgba(212,53,28,1)",strokeWidth:2,fill:"rgba(212,53,28,0.1)",snapColors:{vertex:"rgba(212,53,28,1)",midpoint:"rgba(40,161,151,1)",edge:"rgba(29,112,184,1)"},snapRadius:10};function nn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var on=function(e){var t;return null!==(t=e.mapColorScheme)&&void 0!==t?t:"light"},an=function(e,t){return["coalesce",["get","user_".concat(t).concat(e.id.charAt(0).toUpperCase()+e.id.slice(1))],["get","user_".concat(t)],rn[t]]},sn=function(e){return{id:"fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","false"]],paint:{"fill-color":an(e,"fill")}}},un=function(e){return{id:"stroke-inactive",type:"line",filter:["all",["==","$type","Polygon"],["==","active","false"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":an(e,"stroke"),"line-width":an(e,"strokeWidth")}}},cn=function(e){return{id:"fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":e,"fill-opacity":.1}}},ln=function(e){return{id:"stroke-active",type:"line",filter:["all",["==","$type","Polygon"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-opacity":1}}},dn=function(e){return{id:"stroke-preview-line",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}},pn=function(e){return{id:"vertex",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"]],paint:{"circle-radius":6,"circle-color":e}}},fn=function(e,t){return{id:"vertex-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":8,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},hn=function(e){return{id:"vertex-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":e}}},gn=function(e){return{id:"midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":4,"circle-color":e}}},yn=function(e,t){return{id:"midpoint-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},mn=function(e){return{id:"midpoint-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":4,"circle-color":e}}},vn=function(e){return{id:"circle",type:"line",filter:["==","id","circle"],paint:{"line-color":e,"line-width":2,"line-opacity":.8}}},bn=function(e){var t=rn.editColorsForeground[on(e)],r=rn.editColorsBackground[on(e)],n=rn.editColorsHalo[on(e)];return[sn(e),cn(t),ln(t),un(e),dn(t),gn(t),yn(r,n),mn(t),pn(t),fn(r,n),hn(t),vn(t),{id:"touch-vertex-indicator",type:"circle",filter:["all",["==","$type","Point"],["==","meta","touch-vertex-indicator"]],paint:{"circle-radius":30,"circle-color":"#3bb2d0","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":.9}}]},En=6371008.8,Sn={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:En,metres:En,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function wn(e,t,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function xn(e,t,r){if(void 0===r&&(r={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Cn(e[0])||!Cn(e[1]))throw new Error("coordinates must contain numbers");return wn({type:"Point",coordinates:e},t,r)}function Mn(e,t,r){if(void 0===r&&(r={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return wn({type:"LineString",coordinates:e},t,r)}function Pn(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function _n(e){return e%(2*Math.PI)*180/Math.PI}function In(e){return e%360*Math.PI/180}function Cn(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function Tn(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function On(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}const Ln=function(e,t,r){void 0===r&&(r={});var n=Tn(e),o=Tn(t),i=In(o[1]-n[1]),a=In(o[0]-n[0]),s=In(n[1]),u=In(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(u);return function(e,t){void 0===t&&(t="kilometers");var r=Sn[t];if(!r)throw new Error(t+" units is invalid");return e*r}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)};var An=6371008.8,Fn={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:An,metres:An,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function kn(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Rn(e[0])||!Rn(e[1]))throw new Error("coordinates must contain numbers");return function(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}({type:"Point",coordinates:e},t,r)}function Nn(e){return e%(2*Math.PI)*180/Math.PI}function jn(e){return e%360*Math.PI/180}function Rn(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function Dn(e,t,r,n={}){const o=function(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}(e),i=jn(o[0]),a=jn(o[1]),s=jn(r),u=function(e,t="kilometers"){const r=Fn[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s)),l=Nn(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),d=Nn(c);return void 0!==o[2]?kn([l,d,o[2]],n.properties):kn([l,d],n.properties)}function Vn(e,t,r={}){const n=r.steps||64,o=r.properties?r.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},i=[];for(let o=0;o<n;o++)i.push(Dn(e,t,-360*o/n,r).geometry.coordinates);return i.push(i[0]),function(e,t,r={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return function(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}({type:"Polygon",coordinates:e},t,r)}([i],o)}function Un(e,t,r){if(null!==e)for(var n,o,i,a,s,u,c,l,d=0,p=0,f=e.type,h="FeatureCollection"===f,g="Feature"===f,y=h?e.features.length:1,m=0;m<y;m++){s=(l=!!(c=h?e.features[m].geometry:g?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v<s;v++){var b=0,E=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var S=a.type;switch(d=!r||"Polygon"!==S&&"MultiPolygon"!==S?0:1,S){case null:break;case"Point":if(!1===t(u,p,m,b,E))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],p,m,b,E))return!1;p++,"MultiPoint"===S&&b++}"LineString"===S&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<u.length;n++){for(o=0;o<u[n].length-d;o++){if(!1===t(u[n][o],p,m,b,E))return!1;p++}"MultiLineString"===S&&b++,"Polygon"===S&&E++}"Polygon"===S&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(E=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-d;i++){if(!1===t(u[n][o][i],p,m,b,E))return!1;p++}E++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===Un(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Bn(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function Gn(e,t){!function(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,g=f?e.features.length:1;for(r=0;r<g;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}(e,function(e,r,n,o,i){var a,s=null===e?null:e.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==t(wn(e,n,{bbox:o,id:i}),r,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var u=0;u<e.coordinates.length;u++){var c=e.coordinates[u];if(!1===t(wn({type:a,coordinates:c},n),r,u))return!1}})}function Yn(e,t){var r,n,o;return void 0===t&&(t={}),n=("Feature"===(r=e).type?r.geometry:r).coordinates,o=t.properties?t.properties:"Feature"===e.type?e.properties:{},n.length>1?function(e,t,r){return void 0===r&&(r={}),wn({type:"MultiLineString",coordinates:e},t,r)}(n,o):Mn(n[0],o)}function Xn(e){return e%360*Math.PI/180}function qn(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Jn(e,t,r){if(void 0===r&&(r={}),!0===r.final)return function(e,t){var r=Jn(t,e);return(r+180)%360}(e,t);var n=qn(e),o=qn(t),i=Xn(n[0]),a=Xn(o[0]),s=Xn(n[1]),u=Xn(o[1]),c=Math.sin(a-i)*Math.cos(u),l=Math.cos(s)*Math.sin(u)-Math.sin(s)*Math.cos(u)*Math.cos(a-i);return Math.atan2(c,l)%(2*Math.PI)*180/Math.PI}function $n(e,t,r,n){void 0===n&&(n={});var o=Tn(e),i=In(o[0]),a=In(o[1]),s=In(r),u=function(e,t){void 0===t&&(t="kilometers");var r=Sn[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s));return xn([_n(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),_n(c)],n.properties)}Math.PI;const Hn=function(e){if(!e)throw new Error("geojson is required");var t=[];return Gn(e,function(e){!function(e,t){var r=[],n=e.geometry;if(null!==n){switch(n.type){case"Polygon":r=On(n);break;case"LineString":r=[On(n)]}r.forEach(function(r){var n=function(e,t){var r=[];return e.reduce(function(e,n){var o,i,a,s,u,c,l=Mn([e,n],t);return l.bbox=(i=n,a=(o=e)[0],s=o[1],[a<(u=i[0])?a:u,s<(c=i[1])?s:c,a>u?a:u,s>c?s:c]),r.push(l),n}),r}(r,e.properties);n.forEach(function(e){e.id=t.length,t.push(e)})})}}(e,t)}),Pn(t)};var Wn=r("./node_modules/geojson-rbush/index.js");function Kn(e,t){var r=On(e),n=On(t);if(2!==r.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==n.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var o=r[0][0],i=r[0][1],a=r[1][0],s=r[1][1],u=n[0][0],c=n[0][1],l=n[1][0],d=n[1][1],p=(d-c)*(a-o)-(l-u)*(s-i);if(0===p)return null;var f=((l-u)*(i-c)-(d-c)*(o-u))/p,h=((a-o)*(i-c)-(s-i)*(o-u))/p;return f>=0&&f<=1&&h>=0&&h<=1?xn([o+f*(a-o),i+f*(s-i)]):null}const zn=function(e,t){var r={},n=[];if("LineString"===e.type&&(e=wn(e)),"LineString"===t.type&&(t=wn(t)),"Feature"===e.type&&"Feature"===t.type&&null!==e.geometry&&null!==t.geometry&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var o=Kn(e,t);return o&&n.push(o),Pn(n)}var i=Wn();return i.load(Hn(t)),Bn(Hn(e),function(e){Bn(i.search(e),function(t){var o=Kn(e,t);if(o){var i=On(o).join(",");r[i]||(r[i]=!0,n.push(o))}})}),Pn(n)},Zn=function(e,t,r){void 0===r&&(r={});var n=xn([1/0,1/0],{dist:1/0}),o=0;return Gn(e,function(e){for(var i=On(e),a=0;a<i.length-1;a++){var s=xn(i[a]);s.properties.dist=Ln(t,s,r);var u=xn(i[a+1]);u.properties.dist=Ln(t,u,r);var c=Ln(s,u,r),l=Math.max(s.properties.dist,u.properties.dist),d=Jn(s,u),p=$n(t,l,d+90,r),f=$n(t,l,d-90,r),h=zn(Mn([p.geometry.coordinates,f.geometry.coordinates]),Mn([s.geometry.coordinates,u.geometry.coordinates])),g=null;h.features.length>0&&((g=h.features[0]).properties.dist=Ln(t,g,r),g.properties.location=o+Ln(s,g,r)),s.properties.dist<n.properties.dist&&((n=s).properties.index=a,n.properties.location=o),u.properties.dist<n.properties.dist&&((n=u).properties.index=a+1,n.properties.location=o+c),g&&g.properties.dist<n.properties.dist&&((n=g).properties.index=a),o+=c}}),n};var Qn=6371008.8,eo={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:Qn,metres:Qn,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function to(e){return e%(2*Math.PI)*180/Math.PI}function ro(e){return e%360*Math.PI/180}function no(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function oo(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}const io=function(e,t,r){void 0===r&&(r={});var n=oo(e),o=oo(t),i=ro(o[1]-n[1]),a=ro(o[0]-n[0]),s=ro(n[1]),u=ro(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(u);return function(e,t){void 0===t&&(t="kilometers");var r=eo[t];if(!r)throw new Error(t+" units is invalid");return e*r}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)},ao=function(e,t){return function(e,t,r,n){void 0===n&&(n={});var o=oo(e),i=ro(o[0]),a=ro(o[1]),s=ro(r),u=function(e,t){void 0===t&&(t="kilometers");var r=eo[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s));return function(e,t,r){if(void 0===r&&(r={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!no(e[0])||!no(e[1]))throw new Error("coordinates must contain numbers");return function(e,t,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}({type:"Point",coordinates:e},t,r)}([to(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),to(c)],n.properties)}(e,io(e,t)/2,Jn(e,t))};var so=function(){return so=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},so.apply(this,arguments)},uo=function(){function e(e){var t;this.status=null!==(t=e.status)&&void 0!==t&&t,this.map=e.map,this.drawing=e.drawing,this.options=e.options,this.onSnapped=function(t){void 0!==e.onSnapped&&e.onSnapped(t)},this.features={},this.snapStatus=!1,this.snapCoords=[],this.radiusInMeters=0,this.addRadiusCircleLayer(),this.addEvents()}return e.prototype.changeSnappedPoints=function(){for(var e=this.drawing.getAll(),t=[],r=0;r<e.features.length;r++){var n=e.features[r],o=n.id;if(this.features[o]){var i=this.features[o].snapPoints;if(void 0!==this.features.unknow){var a=this.features.unknow.snapPoints;i=so(so({},i),a)}var s=this.doSnap(n,i);t.push(s)}else void 0!==this.features.unknow?(a=this.features.unknow.snapPoints,s=this.doSnap(n,a),t.push(s)):t.push(n)}var u={type:"FeatureCollection",features:t};this.drawing.set(u),this.onSnapped&&this.onSnapped(u)},e.prototype.isPointSnapped=function(e,t){return Ln(xn(e),xn(t),{units:"meters"})<this.radiusInMeters},e.prototype.doSnap=function(e,t){switch(e.geometry.type){case"Point":var r=e.geometry.coordinates;for(var n in t)this.isPointSnapped(r,t[n])&&(e.geometry.coordinates=t[n]);break;case"Polygon":for(var o=e.geometry.coordinates,i=[],a=0;a<o.length;a++){for(var s=o[a],u=[],c=0;c<s.length;c++){var l=s[c],d=!1;for(var n in t)if(this.isPointSnapped(l,t[n])){d=!0,u.push(t[n]);break}0==d&&u.push(l)}i.push(u)}e.geometry.coordinates=i;break;case"LineString":var p=e.geometry.coordinates;for(u=[],c=0;c<p.length;c++){var f=p[c];for(var n in d=!1,t)if(this.isPointSnapped(f,t[n])){d=!0,u.push(t[n]);break}0==d&&u.push(f)}e.geometry.coordinates=u}return e},e.prototype.getMe=function(){return this},e.prototype.setStatus=function(e){this.status=e},e.prototype.setMapData=function(e){var t=this.map.getSource("snap-helper-circle");t&&t.setData(e)},e.prototype.snapToClosestPoint=function(e){if(this.status){var t=e.point,r=this.map.unproject(t),n=[t.x+this.options.radius,t.y],o=this.map.unproject(n),i=Ln(xn([r.lng,r.lat]),xn([o.lng,o.lat]),{units:"meters"});this.radiusInMeters=i;var a=!1,s=this.getCloseFeatures(e,i);s?(this.snapStatus=!0,this.snapCoords=s.coords,a=Vn(s.coords,i,{steps:64,units:"meters",properties:{color:s.color}})):(this.snapStatus=!1,this.snapCoords=[]);var u=Pn(0==a?[]:[a]);this.setMapData(u)}},e.prototype.addEvents=function(){var e=this;this.map.on("mousemove",function(t){e.snapToClosestPoint(t)}),this.map.on("draw.delete",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.update",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.create",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.selectionchange",function(t){t.features.length>0?e.status=!0:(e.status=!1,e.setMapData(Pn([])))}),this.map.on("draw.modechange",function(t){e.status=!0,"simple_select"==t.mode&&(e.status=!1)}),this.map.on("draw.render",function(t){var r=e.map.getSource("mapbox-gl-draw-hot");if(r){var n=r._data;if(e.snapStatus){var o=[e.snapCoords[0],e.snapCoords[1]];n.features.length>0&&(n.features[0].geometry.coordinates=o)}}}),this.map.on("mouseup",function(){e.drawingSnapCheck()}),this.map.on("click",function(){e.drawingSnapCheck()})},e.prototype.drawingSnapCheck=function(){if(this.snapStatus){var e=this.map.getSource("mapbox-gl-draw-hot"),t=[this.snapCoords[0],this.snapCoords[1]],r=t[0].toFixed(6),n=t[1].toFixed(6),o={};if(o["".concat(r,"_").concat(n)]=t,e){var i=e._data;if(i.features.length>0){var a=i.features.find(function(e){return"feature"==e.properties.meta});if(a){var s=a.properties.id;this.features[s]?this.features[s].snapPoints["".concat(r,"_").concat(n)]=t:this.features[s]={id:s,snapPoints:o}}}else this.features.unknow?this.features.unknow.snapPoints["".concat(r,"_").concat(n)]=t:this.features.unknow={id:s,snapPoints:o}}}},e.prototype.searchInVertex=function(e,t,r){var n,o=(n=[],Un(e,function(e){n.push(e)}),n),i=[];if(o.map(function(e){var n=Ln(xn(e),xn([t.lng,t.lat]),{units:"meters"});n<r&&i.push({coords:e,dist:n,color:"#8bc34a"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.getLines=function(e,t,r){var n=[];switch(e.geometry.type){case"LineString":n.push(e);break;case"MultiLineString":e.geometry.coodinates.map(function(e){n.push(Mn(e))});break;case"Polygon":var o=Yn(e.geometry);n.push(o);break;case"MultiPolygon":Yn(e.geometry).coodinates.map(function(e){n.push(Mn(e))})}return n},e.prototype.searchInMidPoint=function(e,t,r){var n=this.getLines(e,t,r),o=[];n.map(function(e){o=o.concat(Hn(e).features)});var i=[];if(o.map(function(e){var n=ao(e.geometry.coordinates[0],e.geometry.coordinates[1]),o=Ln(n,xn([t.lng,t.lat]),{units:"meters"});o<r&&i.push({coords:n.geometry.coordinates,dist:o,color:"#03a9f4"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.searchInEdge=function(e,t,r){for(var n=this.getLines(e,t,r),o=[],i=0;i<n.length;i++){var a=Zn(n[i],xn([t.lng,t.lat]),{units:"meters"});void 0!==a.properties.dist&&a.properties.dist<r&&o.push({coords:a.geometry.coordinates,dist:a.properties.dist,color:"#ff9800"})}if(o.length>0)return o.sort(function(e,t){return e.dist-t.dist}),o[0]},e.prototype.getCloseFeatures=function(e,t){var r=this.map.queryRenderedFeatures(e.point,{layers:this.options.layers});if(r.length>0){for(var n,o=!1,i=0;i<r.length;i++){var a=r[i],s=this.options.rules,u=e.lngLat;if(o=!1,-1!==s.indexOf("vertex")&&null==n&&(n=this.searchInVertex(a,u,t))){o=!0;break}if(-1!==s.indexOf("midpoint")&&null==n&&(n=this.searchInMidPoint(a,u,t))){o=!0;break}if(-1!==s.indexOf("edge")&&null==n&&(n=this.searchInEdge(a,u,t))){o=!0;break}}return!!o&&n}return!1},e.prototype.addRadiusCircleLayer=function(){this.map.addSource("snap-helper-circle",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"snap-helper-circle",type:"fill",source:"snap-helper-circle",paint:{"fill-color":["get","color"],"fill-opacity":.6}})},e}();const co=uo;function lo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function po(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?lo(Object(r),!0).forEach(function(t){fo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):lo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function fo(e,t,r){return(t=function(e){var t=function(e){if("object"!=ho(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ho(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ho(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ho(e){return ho="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ho(e)}var go="snap-helper-circle";function yo(e,t){!function r(){var n=e();n?t(n):requestAnimationFrame(r)}()}function mo(e){var t;if(!(!e||e._data&&Array.isArray(null===(t=e._data)||void 0===t?void 0:t.features))){var r={type:"FeatureCollection",features:[]};Object.defineProperty(e,"_data",{get:function(){return r},set:function(e){r=e&&"object"===ho(e)&&Array.isArray(e.features)?e:{type:"FeatureCollection",features:[]}},configurable:!0})}}function vo(e){return vo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vo(e)}function bo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Eo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?bo(Object(r),!0).forEach(function(t){So(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function So(e,t,r){return(t=function(e){var t=function(e){if("object"!=vo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=vo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==vo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var wo=function(e){var t=e.mapStyle,r=e.mapProvider,n=e.events,o=e.eventBus,i=e.snapLayers,a=r.map;_t.constants.classes.CONTROL_BASE="maplibregl-ctrl",_t.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",_t.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var s=Eo(Eo({},_t.modes),{},{disabled:It,edit_vertex:Hr,draw_vertex:tn}),u=new _t({modes:s,styles:bn(t),displayControlsDefault:!1,userProperties:!0,defaultMode:"disabled"});a.addControl(u),r.draw=u,r.snapEnabled=!1,function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e._snapInitialized)return e._snapInstance;e._snapInitialized=!0;var n=r.layers,o=void 0===n?[]:n,i=r.radius,a=void 0===i?15:i,s=r.rules,u=void 0===s?["vertex","midpoint","edge"]:s,c=r.status,l=void 0!==c&&c,d=r.onSnapped,p=void 0===d?function(){}:d,f=r.colors,h=void 0===f?{}:f;function g(r){if(e._snapInstance||e._snapCreating)return e._snapInstance;e._snapCreating=!0,e.getLayer(go)&&e.removeLayer(go),e.getSource(go)&&e.removeSource(go),mo(r);var n=new co({map:e,drawing:t,options:{layers:o,radius:a,rules:u},status:l,onSnapped:p}),i=l;return Object.defineProperty(n,"status",{get:function(){return i},set:function(){},configurable:!0}),n.setSnapStatus=function(e){i=e},n._defaultLayers=o,n._activeLayers=null,n.setSnapLayers=function(e){null==e?n._activeLayers=null:Array.isArray(e)&&(n._activeLayers=e)},void 0!==e._pendingSnapLayers&&(n.setSnapLayers(e._pendingSnapLayers),delete e._pendingSnapLayers),e._snapInstance=n,n}!function(e){if(!co.prototype.__snapPatched){co.prototype.__snapPatched=!0;var t=co.prototype,r={setMapData:t.setMapData,drawingSnapCheck:t.drawingSnapCheck,getLines:t.getLines,getCloseFeatures:t.getCloseFeatures,searchInVertex:t.searchInVertex,searchInMidPoint:t.searchInMidPoint,searchInEdge:t.searchInEdge,snapToClosestPoint:t.snapToClosestPoint};t.changeSnappedPoints=function(){},t.setMapData=function(e){var t,n;if(this.status){var o=r.setMapData.call(this,e);return(null==e||null===(t=e.features)||void 0===t?void 0:t.length)>0&&null!==(n=this.map)&&void 0!==n&&n.getLayer(go)&&this.map.setLayoutProperty(go,"visibility","visible"),o}},t.drawingSnapCheck=function(){if(this.status)return r.drawingSnapCheck.call(this)},t.getLines=function(e,t,n){var o=e.geometry;if(!o||!o.coordinates)return[];var i=o.coordinates;if(!Array.isArray(i)||0===i.length)return[];try{return"MultiPolygon"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return At(e)}):"MultiLineString"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return Ft(e)}):r.getLines.call(this,e,t,n)}catch(e){return[]}},t.getCloseFeatures=function(e,t){var n=this;if(!this.status)return[];var o=this._activeLayers||this._defaultLayers||[];this.options.layers=o.filter(function(e){return n.map.getLayer(e)});var i=this.options.radius||15,a=e.point;e.point=[[a.x-i,a.y-i],[a.x+i,a.y+i]];var s=r.getCloseFeatures.call(this,e,t);return e.point=a,s},t.searchInVertex=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInVertex.apply(this,n);return i&&(i.color=e.vertex),i},t.searchInMidPoint=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInMidPoint.apply(this,n);return i&&(i.color=e.midpoint),i},t.searchInEdge=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInEdge.apply(this,n);return i&&(i.color=e.edge),i},t.snapToClosestPoint=function(e){if(this.status)try{var t,n,o=r.snapToClosestPoint.call(this,e);return(null===(t=this.closeFeatures)||void 0===t?void 0:t.length)>100&&(this.closeFeatures.length=0),(null===(n=this.lines)||void 0===n?void 0:n.length)>100&&(this.lines.length=0),o}catch(e){return this.snapStatus=!1,void(this.snapCoords=null)}}}}(po(po({},rn.snapColors),h)),e.on("style.load",function(){yo(function(){return e.getSource("mapbox-gl-draw-hot")},function(t){var r;mo(t),e.getSource(go)||e.addSource(go,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(go)||e.addLayer({id:go,type:"fill",source:go,paint:{"fill-color":["get","color"],"fill-opacity":.6},layout:{visibility:null!==(r=e._snapInstance)&&void 0!==r&&r.status?"visible":"none"}}),e._snapInstance||g(t)})}),e.on("zoomstart",function(){e.getLayer(go)&&e.setLayoutProperty(go,"visibility","none")}),e.on("zoomend",function(){var t=e._snapInstance;e.getLayer(go)&&null!=t&&t.status&&e.setLayoutProperty(go,"visibility","visible")}),yo(function(){return e.getSource("mapbox-gl-draw-hot")},g)}(a,u,{layers:i,radius:10,rules:["vertex","edge"]});var c=function(e){a.once("idle",function(){!function(e,t){bn(t).forEach(function(t){Object.entries(t.paint).forEach(function(r){var n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return nn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nn(e,t):void 0}}(e,t)||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.")}()}(r,2),o=n[0],i=n[1];e.getLayer("".concat(t.id,".cold"))&&e.setPaintProperty("".concat(t.id,".cold"),o,i),e.getLayer("".concat(t.id,".hot"))&&e.setPaintProperty("".concat(t.id,".hot"),o,i)})})}(a,e)})};return o.on(n.MAP_SET_STYLE,c),o.on(n.MAP_SET_SIZE,function(e){a.fire("draw.scalechange",{scale:{small:1,medium:1.5,large:2}[e]})}),{draw:u,remove:function(){o.off(n.MAP_SET_STYLE,c),u.deleteAll(),u.changeMode("disabled"),a.removeControl(u)}}};function xo(e){return xo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xo(e)}function Mo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Po(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Mo(Object(r),!0).forEach(function(t){_o(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Mo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _o(e,t,r){return(t=function(e){var t=function(e){if("object"!=xo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=xo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==xo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Io=function(e){return{mobile:{slot:"actions",showLabel:e},tablet:{slot:"actions",showLabel:e},desktop:{slot:"actions",showLabel:e}}},Co={reducer:{initialState:{mode:null,feature:null,tempFeature:null,selectedVertexIndex:-1,numVertecies:null,snap:!1,hasSnapLayers:!1},actions:l},InitComponent:function(e){var t=e.appState,r=e.appConfig,n=e.mapState,o=e.pluginConfig,i=e.pluginState,a=e.services,s=e.mapProvider,u=e.buttonConfig,c=a.events,l=a.eventBus;(0,d.useEffect)(function(){var e,r,a,u,d,p=null===(e=null===(r=o.includeModes)||void 0===r?void 0:r.includes(t.mode))||void 0===e||e,f=null!==(a=null===(u=o.excludeModes)||void 0===u?void 0:u.includes(t.mode))&&void 0!==a&&a;if(n.isMapReady&&p&&!f){var h=wo({mapStyle:n.mapStyle,snapLayers:o.snapLayers,mapProvider:s,events:c,eventBus:l}).remove;return i.dispatch({type:"SET_HAS_SNAP_LAYERS",payload:(null===(d=o.snapLayers)||void 0===d?void 0:d.length)>0}),l.emit("draw:ready"),function(){return h()}}},[n.isMapReady,t.mode]),(0,d.useEffect)(function(){if(s.draw){var e=function(e){var t=e.appState,r=e.appConfig,n=e.mapState,o=e.pluginState,i=e.mapProvider,a=e.buttonConfig,s=e.eventBus,u=a.drawDone,c=a.drawAddPoint,l=a.drawUndo,d=a.drawFinish,p=a.drawDeletePoint,f=a.drawSnap,h=a.drawCancel,g=i.map,m=i.draw,v=o.dispatch,b=o.feature,S=o.tempFeature;u.onClick=function(){m.changeMode("disabled"),v({type:"SET_MODE",payload:null}),v({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),s.emit("draw:done",{newFeature:S})},h.onClick=function(){m.delete(S.id),b&&m.add(b),m.changeMode("disabled"),v({type:"SET_MODE",payload:null}),v({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}}),s.emit("draw:cancel",{originalFeature:b})};var w=0;f.onClick=function(){var e=Date.now();if(!(e-w<300)){w=e;var t=!o.snap;v({type:"TOGGLE_SNAP"}),i.snapEnabled=t;var r=y(g);null!=r&&r.setSnapStatus&&r.setSnapStatus(t),!t&&r&&(E(r),g.getLayer("snap-helper-circle")&&g.setLayoutProperty("snap-helper-circle","visibility","none"))}};var x=function(){var e,t=g.getStyle().layers||[];0===t.length||null!==(e=t[t.length-1].source)&&void 0!==e&&e.startsWith("mapbox-gl-draw")||t.filter(function(e){var t;return null===(t=e.source)||void 0===t?void 0:t.startsWith("mapbox-gl-draw")}).forEach(function(e){return g.moveLayer(e.id)})};g.on("styledata",function(){return x()});var M=function(e){var o=e.features[0];v({type:"SET_FEATURE",payload:{tempFeature:o}}),s.emit("draw:create",e),v({type:"SET_MODE",payload:"edit_vertex"}),setTimeout(function(){m.changeMode("edit_vertex",{container:t.layoutRefs.viewportRef.current,deleteVertexButtonId:"".concat(r.id,"-draw-delete-point"),isPanEnabled:"keyboard"!==t.interfaceType,interfaceType:t.interfaceType,scale:{small:1,medium:1.5,large:2}[n.mapSize],featureId:o.id,getSnapEnabled:function(){return!0===i.snapEnabled}})},0)};g.on("draw.create",M);var P=function(e){v({type:"SET_SELECTED_VERTEX_INDEX",payload:e}),s.emit("draw:vertexselection",e)};return g.on("draw.vertexselection",P),function(){u.onClick=null,c.onClick=null,l.onClick=null,d.onClick=null,p.onClick=null,f.onClick=null,h.onClick=null,g.off("styledata",x),g.off("draw.create",M),g.off("draw.vertexselection",P)}}({appState:t,appConfig:r,mapState:n,mapProvider:s,buttonConfig:u,pluginState:i,events:c,eventBus:l});return function(){return e()}}},[s,t,i])},buttons:[Po({id:"drawDone",label:"Done",variant:"primary",hiddenWhen:function(e){var t=e.appState,r=e.pluginState;return!r.mode||"mouse"!==t.interfaceType&&"edit_vertex"!==r.mode},enableWhen:function(e){return!!e.pluginState.tempFeature}},Io(!0)),Po({id:"drawAddPoint",label:"Add point",variant:"primary",hiddenWhen:function(e){var t=e.appState;return"draw_vertex"!==e.pluginState.mode||"mouse"===t.interfaceType}},Io(!0)),Po({id:"drawUndo",label:"Undo",iconId:"undo",variant:"tertiary",hiddenWhen:function(e){return!e.pluginState.mode},enableWhen:function(e){return e.pluginState,!1}},Io(!1)),Po({id:"drawFinish",label:"Finish shape",iconId:"check",variant:"tertiary",hiddenWhen:function(e){return"draw_vertex"!==e.pluginState.mode},enableWhen:function(e){return e.pluginState.numVertecies>3}},Io(!1)),Po({id:"drawDeletePoint",label:"Delete point",iconId:"close",variant:"tertiary",enableWhen:function(e){var t=e.pluginState;return t.selectedVertexIndex>=0&&t.numVertecies>3},hiddenWhen:function(e){var t=e.pluginState;return!["simple_select","edit_vertex"].includes(t.mode)}},Io(!1)),Po({id:"drawSnap",label:"Snap to line",iconId:"magnet",variant:"tertiary",hiddenWhen:function(e){var t=e.pluginState;return!t.mode||!t.hasSnapLayers},pressedWhen:function(e){return!!e.pluginState.snap}},Io(!1)),Po({id:"drawCancel",label:"Cancel",variant:"tertiary",hiddenWhen:function(e){return!e.pluginState.mode}},Io(!0))],keyboardShortcuts:[{id:"drawStart",group:"Drawing",title:"Edit vertex",command:"<kbd>Spacebar</kbd></dd>"}],icons:[{id:"check",svgContent:'<path d="M20 6 9 17l-5-5"/>'},{id:"undo",svgContent:'<path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/>'},{id:"magnet",svgContent:'<path d="m12 15 4 4"/><path d="M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z"/><path d="m5 8 4 4"/>'}],api:{newPolygon:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginState,a=e.mapProvider,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=i.dispatch,c=a.draw,l=a.map;if(c){var d=y(l);null!=d&&d.setSnapLayers?d.setSnapLayers(s.snapLayers||null):s.snapLayers&&(l._pendingSnapLayers=s.snapLayers),u({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=s.snapLayers)||void 0===r?void 0:r.length)>0}),c.changeMode("draw_vertex",{container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,getSnapEnabled:function(){return!0===a.snapEnabled},featureId:t}),u({type:"SET_MODE",payload:"draw_vertex"})}},editFeature:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.mapState,a=e.pluginState,s=e.mapProvider,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=a.dispatch,l=s.draw,d=s.map;if(l){var p=y(d);null!=p&&p.setSnapLayers?p.setSnapLayers(u.snapLayers||null):u.snapLayers&&(d._pendingSnapLayers=u.snapLayers),c({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=u.snapLayers)||void 0===r?void 0:r.length)>0}),l.changeMode("edit_vertex",{container:n.layoutRefs.viewportRef.current,deleteVertexButtonId:"".concat(o.id,"-draw-delete-point"),isPanEnabled:"keyboard"!==n.interfaceType,interfaceType:n.interfaceType,scale:{small:1,medium:1.5,large:2}[i.mapSize],featureId:t,getSnapEnabled:function(){return!0===s.snapEnabled}});var f=l.get(t);c({type:"SET_FEATURE",payload:{feature:f,tempFeature:f}}),c({type:"SET_MODE",payload:"edit_vertex"})}},addFeature:function(e,t){var r=e.mapProvider,n=e.services,o=r.draw,i=n.eventBus;o&&(o.add(t,{userProperties:!0}),i.emit("draw:add",t))},deleteFeature:function(e,t){var r=e.mapProvider,n=e.services,o=r.draw,i=n.eventBus;o&&(o.delete(t),i.emit("draw:delete",{featureId:t}))}}}}};
@@ -1,2 +0,0 @@
1
- /*! For license information please see index.js.LICENSE.txt */
2
- import*as t from"react";var r,e,n={react:(r,e,n)=>{var o,i;r.exports=(o={useEffect:()=>t.useEffect},i={},n.d(i,o),i)}},o={};function i(t){var r=o[t];if(void 0!==r)return r.exports;var e=o[t]={exports:{}};return n[t].call(e.exports,e,e.exports,i),e.exports}i.m=n,i.d=(t,r)=>{for(var e in r)i.o(r,e)&&!i.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})},i.f={},i.e=t=>Promise.all(Object.keys(i.f).reduce((r,e)=>(i.f[e](t,r),r),[])),i.u=t=>"../esm/"+t+".js",i.miniCssF=t=>{},i.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;if("string"==typeof import.meta.url&&(t=import.meta.url),!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=t+"../css/"})(),r={index:0},e=t=>{var e,n,{__webpack_ids__:o,__webpack_modules__:c,__webpack_runtime__:u}=t,a=0;for(e in c)i.o(c,e)&&(i.m[e]=c[e]);for(u&&u(i);a<o.length;a++)n=o[a],i.o(r,n)&&r[n]&&r[n][0](),r[o[a]]=0},i.f.j=(t,n)=>{var o=i.o(r,t)?r[t]:void 0;if(0!==o)if(o)n.push(o[1]);else{var c=import("../css/"+i.u(t)).then(e,e=>{throw 0!==r[t]&&(r[t]=void 0),e});c=Promise.race([c,new Promise(e=>o=r[t]=[e])]),n.push(o[1]=c)}};var c={};function u(t){return u="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},u(t)}function a(){var t,r,e="function"==typeof Symbol?Symbol:{},n=e.iterator||"@@iterator",o=e.toStringTag||"@@toStringTag";function i(e,n,o,i){var a=n&&n.prototype instanceof u?n:u,p=Object.create(a.prototype);return f(p,"_invoke",function(e,n,o){var i,u,a,f=0,p=o||[],l=!1,s={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(r,e){return i=r,u=0,a=t,s.n=e,c}};function y(e,n){for(u=e,a=n,r=0;!l&&f&&!o&&r<p.length;r++){var o,i=p[r],y=s.p,b=i[2];e>3?(o=b===n)&&(a=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=e<2&&y<i[1])?(u=0,s.v=n,s.n=i[1]):y<b&&(o=e<3||i[0]>n||n>b)&&(i[4]=e,i[5]=n,s.n=b,u=0))}if(o||e>1)return c;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&y(p,b),u=p,a=b;(r=u<2?t:a)||!l;){i||(u?u<3?(u>1&&(s.n=-1),y(u,a)):s.n=a:s.v=a);try{if(f=2,i){if(u||(o="next"),r=i[o]){if(!(r=r.call(i,a)))throw TypeError("iterator result is not an object");if(!r.done)return r;a=r.value,u<2&&(u=0)}else 1===u&&(r=i.return)&&r.call(i),u<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((r=(l=s.n<0)?a:e.call(n,s))!==c)break}catch(r){i=t,u=1,a=r}finally{f=1}}return{value:r,done:l}}}(e,o,i),!0),p}var c={};function u(){}function p(){}function l(){}r=Object.getPrototypeOf;var s=[][n]?r(r([][n]())):(f(r={},n,function(){return this}),r),y=l.prototype=u.prototype=Object.create(s);function b(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,f(t,o,"GeneratorFunction")),t.prototype=Object.create(y),t}return p.prototype=l,f(y,"constructor",l),f(l,"constructor",p),p.displayName="GeneratorFunction",f(l,o,"GeneratorFunction"),f(y),f(y,o,"Generator"),f(y,n,function(){return this}),f(y,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:b}})()}function f(t,r,e,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}f=function(t,r,e,n){if(r)o?o(t,r,{value:e,enumerable:!n,configurable:!n,writable:!n}):t[r]=e;else{function i(r,e){f(t,r,function(t){return this._invoke(r,e,t)})}i("next",0),i("throw",1),i("return",2)}},f(t,r,e,n)}function p(t,r,e,n,o,i,c){try{var u=t[i](c),a=u.value}catch(t){return void e(t)}u.done?r(a):Promise.resolve(a).then(n,o)}function l(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function s(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?l(Object(e),!0).forEach(function(r){y(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):l(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function y(t,r,e){return(r=function(t){var r=function(t){if("object"!=u(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,"string");if("object"!=u(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==u(r)?r:r+""}(r))in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function b(){var t,r;return s(s({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"draw",load:(t=a().m(function t(){var r;return a().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,i.e("im-draw-ml-plugin").then(i.bind(i,"./plugins/draw-ml/src/manifest.js"));case 1:return r=t.v.manifest,t.a(2,r)}},t)}),r=function(){var r=this,e=arguments;return new Promise(function(n,o){var i=t.apply(r,e);function c(t){p(i,n,o,c,u,"next",t)}function u(t){p(i,n,o,c,u,"throw",t)}c(void 0)})},function(){return r.apply(this,arguments)})})}i.d(c,{A:()=>b});const v=c.A;export{v as default};