@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,11 +1,14 @@
1
1
  const initialState = {
2
2
  mode: null,
3
+ action: null, // 'split | merge'
4
+ actionValid: false, // eg. a valid split line for a target feature
3
5
  feature: null,
4
6
  tempFeature: null,
5
7
  selectedVertexIndex: -1,
6
8
  numVertecies: null,
7
9
  snap: false,
8
- hasSnapLayers: false
10
+ hasSnapLayers: false,
11
+ undoStackLength: 0
9
12
  }
10
13
 
11
14
  const setMode = (state, payload) => {
@@ -15,6 +18,14 @@ const setMode = (state, payload) => {
15
18
  }
16
19
  }
17
20
 
21
+ const setAction = (state, payload) => {
22
+ return {
23
+ ...state,
24
+ action: payload.name,
25
+ actionValid: payload.isValid
26
+ }
27
+ }
28
+
18
29
  const setSelectedVertexIndex = (state, payload) => {
19
30
  return {
20
31
  ...state,
@@ -38,6 +49,13 @@ const toggleSnap = (state) => {
38
49
  }
39
50
  }
40
51
 
52
+ const setSnap = (state, payload) => {
53
+ return {
54
+ ...state,
55
+ snap: !!payload
56
+ }
57
+ }
58
+
41
59
  const setHasSnapLayers = (state, payload) => {
42
60
  return {
43
61
  ...state,
@@ -45,12 +63,22 @@ const setHasSnapLayers = (state, payload) => {
45
63
  }
46
64
  }
47
65
 
66
+ const setUndoStackLength = (state, payload) => {
67
+ return {
68
+ ...state,
69
+ undoStackLength: payload
70
+ }
71
+ }
72
+
48
73
  const actions = {
49
74
  SET_MODE: setMode,
75
+ SET_ACTION: setAction,
50
76
  SET_FEATURE: setFeature,
51
77
  SET_SELECTED_VERTEX_INDEX: setSelectedVertexIndex,
52
78
  TOGGLE_SNAP: toggleSnap,
53
- SET_HAS_SNAP_LAYERS: setHasSnapLayers
79
+ SET_SNAP: setSnap,
80
+ SET_HAS_SNAP_LAYERS: setHasSnapLayers,
81
+ SET_UNDO_STACK_LENGTH: setUndoStackLength
54
82
  }
55
83
 
56
84
  export {
@@ -21,7 +21,7 @@ const fillInactive = (mapStyle) => ({
21
21
  const strokeInactive = (mapStyle) => ({
22
22
  id: 'stroke-inactive',
23
23
  type: 'line',
24
- filter: ['all', ['==', '$type', 'Polygon'], ['==', 'active', 'false']],
24
+ filter: ['all', ['any', ['==', '$type', 'Polygon'], ['==', '$type', 'LineString']], ['==', 'active', 'false'], ['!has', 'user_splitter']],
25
25
  layout: { 'line-cap': 'round', 'line-join': 'round' },
26
26
  paint: {
27
27
  'line-color': getUserProp(mapStyle, 'stroke'),
@@ -30,79 +30,105 @@ const strokeInactive = (mapStyle) => ({
30
30
  })
31
31
 
32
32
  // Active lines and fills
33
- const fillActive = (fgColor) => ({
33
+ const fillActive = (foregroundColor) => ({
34
34
  id: 'fill-active',
35
35
  type: 'fill',
36
36
  filter: ['all', ['==', '$type', 'Polygon'], ['==', 'active', 'true']],
37
- paint: { 'fill-color': fgColor, 'fill-opacity': 0.1 }
37
+ paint: { 'fill-color': foregroundColor, 'fill-opacity': 0.1 }
38
38
  })
39
39
 
40
- const strokeActive = (fgColor) => ({
40
+ const strokeActive = (foregroundColor) => ({
41
41
  id: 'stroke-active',
42
42
  type: 'line',
43
- filter: ['all', ['==', '$type', 'Polygon'], ['==', 'active', 'true']],
43
+ filter: ['all', ['any', ['==', '$type', 'Polygon'], ['==', '$type', 'LineString']], ['==', 'active', 'true'], ['!has', 'user_splitter']],
44
+ layout: { 'line-cap': 'round', 'line-join': 'round' },
45
+ paint: { 'line-color': foregroundColor, 'line-width': 2, 'line-opacity': 1 }
46
+ })
47
+
48
+ // Splitter line
49
+ const drawInvalidSplitter = (splitInvalidColor) => ({
50
+ id: 'stroke-invalid-splitter',
51
+ type: 'line',
52
+ filter: ['all', ['==', '$type', 'LineString'], ['==', 'active', 'true'], ['==', 'user_splitter', 'invalid']],
53
+ layout: { 'line-cap': 'round', 'line-join': 'round' },
54
+ paint: {
55
+ 'line-color': splitInvalidColor,
56
+ 'line-width': 2,
57
+ 'line-dasharray': [0.2, 2],
58
+ 'line-opacity': 1
59
+ }
60
+ })
61
+
62
+ const drawValidSplitter = (splitValidColor) => ({
63
+ id: 'stroke-valid-splitter',
64
+ type: 'line',
65
+ filter: ['all', ['==', '$type', 'LineString'], ['==', 'active', 'true'], ['==', 'user_splitter', 'valid']],
44
66
  layout: { 'line-cap': 'round', 'line-join': 'round' },
45
- paint: { 'line-color': fgColor, 'line-width': 2, 'line-opacity': 1 }
67
+ paint: {
68
+ 'line-color': splitValidColor,
69
+ 'line-width': 2,
70
+ 'line-opacity': 1
71
+ }
46
72
  })
47
73
 
48
74
  // Dashed preview line
49
- const drawPreviewLine = (fgColor) => ({
75
+ const drawPreviewLine = (foregroundColor) => ({
50
76
  id: 'stroke-preview-line',
51
77
  type: 'line',
52
- filter: ['all', ['==', '$type', 'LineString'], ['==', 'active', 'true']],
78
+ filter: ['all', ['==', '$type', 'LineString'], ['==', 'active', 'true'], ['!has', 'user_splitter']],
53
79
  layout: { 'line-cap': 'round', 'line-join': 'round' },
54
- paint: { 'line-color': fgColor, 'line-width': 2, 'line-dasharray': [0.2, 2], 'line-opacity': 1 }
80
+ paint: { 'line-color': foregroundColor, 'line-width': 2, 'line-dasharray': [0.2, 2], 'line-opacity': 1 }
55
81
  })
56
82
 
57
83
  // Vertex layers
58
- const vertex = (fgColor) => ({
84
+ const vertex = (foregroundColor) => ({
59
85
  id: 'vertex',
60
86
  type: 'circle',
61
87
  filter: ['all', ['==', '$type', 'Point'], ['==', 'meta', 'vertex']],
62
- paint: { 'circle-radius': 6, 'circle-color': fgColor }
88
+ paint: { 'circle-radius': 6, 'circle-color': foregroundColor }
63
89
  })
64
90
 
65
- const vertexHalo = (bgColor, hColor) => ({
91
+ const vertexHalo = (backgroundColor, haloColor) => ({
66
92
  id: 'vertex-halo',
67
93
  type: 'circle',
68
94
  filter: ['all', ['==', '$type', 'Point'], ['==', 'meta', 'vertex'], ['==', 'active', 'true']],
69
- paint: { 'circle-radius': 8, 'circle-stroke-width': 3, 'circle-color': bgColor, 'circle-stroke-color': hColor }
95
+ paint: { 'circle-radius': 8, 'circle-stroke-width': 3, 'circle-color': backgroundColor, 'circle-stroke-color': haloColor }
70
96
  })
71
97
 
72
- const vertexActive = (fgColor) => ({
98
+ const vertexActive = (foregroundColor) => ({
73
99
  id: 'vertex-active',
74
100
  type: 'circle',
75
101
  filter: ['all', ['==', '$type', 'Point'], ['==', 'meta', 'vertex'], ['==', 'active', 'true']],
76
- paint: { 'circle-radius': 6, 'circle-color': fgColor }
102
+ paint: { 'circle-radius': 6, 'circle-color': foregroundColor }
77
103
  })
78
104
 
79
105
  // Midpoints
80
- const midpoint = (fgColor) => ({
106
+ const midpoint = (foregroundColor) => ({
81
107
  id: 'midpoint',
82
108
  type: 'circle',
83
109
  filter: ['all', ['==', '$type', 'Point'], ['==', 'meta', 'midpoint']],
84
- paint: { 'circle-radius': 4, 'circle-color': fgColor }
110
+ paint: { 'circle-radius': 4, 'circle-color': foregroundColor }
85
111
  })
86
112
 
87
- const midpointHalo = (bgColor, hColor) => ({
113
+ const midpointHalo = (backgroundColor, haloColor) => ({
88
114
  id: 'midpoint-halo',
89
115
  type: 'circle',
90
116
  filter: ['all', ['==', '$type', 'Point'], ['==', 'meta', 'midpoint'], ['==', 'active', 'true']],
91
- paint: { 'circle-radius': 6, 'circle-stroke-width': 3, 'circle-color': bgColor, 'circle-stroke-color': hColor }
117
+ paint: { 'circle-radius': 6, 'circle-stroke-width': 3, 'circle-color': backgroundColor, 'circle-stroke-color': haloColor }
92
118
  })
93
119
 
94
- const midpointActive = (fgColor) => ({
120
+ const midpointActive = (foregroundColor) => ({
95
121
  id: 'midpoint-active',
96
122
  type: 'circle',
97
123
  filter: ['all', ['==', '$type', 'Point'], ['==', 'meta', 'midpoint'], ['==', 'active', 'true']],
98
- paint: { 'circle-radius': 4, 'circle-color': fgColor }
124
+ paint: { 'circle-radius': 4, 'circle-color': foregroundColor }
99
125
  })
100
126
 
101
- const circle = (fgColor) => ({
127
+ const circle = (foregroundColor) => ({
102
128
  id: 'circle',
103
129
  type: 'line',
104
130
  filter: ['==', 'id', 'circle'],
105
- paint: { 'line-color': fgColor, 'line-width': 2, 'line-opacity': 0.8 }
131
+ paint: { 'line-color': foregroundColor, 'line-width': 2, 'line-opacity': 0.8 }
106
132
  })
107
133
 
108
134
  const touchVertexIndicator = () => ({
@@ -113,23 +139,27 @@ const touchVertexIndicator = () => ({
113
139
  })
114
140
 
115
141
  const createDrawStyles = (mapStyle) => {
116
- const fgColor = DEFAULTS.editColorsForeground[getColorScheme(mapStyle)]
117
- const bgColor = DEFAULTS.editColorsBackground[getColorScheme(mapStyle)]
118
- const hColor = DEFAULTS.editColorsHalo[getColorScheme(mapStyle)]
142
+ const foregroundColor = DEFAULTS.editColorsForeground[getColorScheme(mapStyle)]
143
+ const backgroundColor = DEFAULTS.editColorsBackground[getColorScheme(mapStyle)]
144
+ const haloColor = DEFAULTS.editColorsHalo[getColorScheme(mapStyle)]
145
+ const splitInvalidColor = DEFAULTS.splitInvalidColors[getColorScheme(mapStyle)]
146
+ const splitValidColor = DEFAULTS.splitValidColors[getColorScheme(mapStyle)]
119
147
 
120
148
  return [
121
149
  fillInactive(mapStyle),
122
- fillActive(fgColor),
123
- strokeActive(fgColor),
150
+ fillActive(foregroundColor),
151
+ strokeActive(foregroundColor),
124
152
  strokeInactive(mapStyle),
125
- drawPreviewLine(fgColor),
126
- midpoint(fgColor),
127
- midpointHalo(bgColor, hColor),
128
- midpointActive(fgColor),
129
- vertex(fgColor),
130
- vertexHalo(bgColor, hColor),
131
- vertexActive(fgColor),
132
- circle(fgColor),
153
+ drawInvalidSplitter(splitInvalidColor),
154
+ drawValidSplitter(splitValidColor),
155
+ drawPreviewLine(foregroundColor),
156
+ midpoint(foregroundColor),
157
+ midpointHalo(backgroundColor, haloColor),
158
+ midpointActive(foregroundColor),
159
+ vertex(foregroundColor),
160
+ vertexHalo(backgroundColor, haloColor),
161
+ vertexActive(foregroundColor),
162
+ circle(foregroundColor),
133
163
  touchVertexIndicator()
134
164
  ]
135
165
  }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Creates an undo stack manager for draw operations.
3
+ * Fires 'draw.undochange' events when stack changes for UI updates.
4
+ *
5
+ * @param {Object} map - MapLibre map instance
6
+ * @returns {Object} Undo stack manager
7
+ */
8
+ export const createUndoStack = (map) => {
9
+ const stack = []
10
+
11
+ const fireChange = () => {
12
+ map.fire('draw.undochange', { length: stack.length })
13
+ }
14
+
15
+ return {
16
+ /**
17
+ * Push an undo operation onto the stack
18
+ * @param {Object} operation - { type, undo: Function, ...data }
19
+ */
20
+ push(operation) {
21
+ stack.push(operation)
22
+ fireChange()
23
+ },
24
+
25
+ /**
26
+ * Pop and return the last operation (does not execute it)
27
+ * @returns {Object|undefined} The operation or undefined if empty
28
+ */
29
+ pop() {
30
+ const op = stack.pop()
31
+ fireChange()
32
+ return op
33
+ },
34
+
35
+ /**
36
+ * Clear all operations from the stack
37
+ */
38
+ clear() {
39
+ stack.length = 0
40
+ fireChange()
41
+ },
42
+
43
+ /**
44
+ * Get current stack length
45
+ */
46
+ get length() {
47
+ return stack.length
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,16 @@
1
+ // --- Debounce Helper ---
2
+ export const debounce = (fn, delay) => {
3
+ let timeout
4
+
5
+ const debounced = (...args) => {
6
+ clearTimeout(timeout)
7
+ timeout = setTimeout(() => fn(...args), delay)
8
+ }
9
+
10
+ debounced.cancel = () => {
11
+ clearTimeout(timeout)
12
+ timeout = null
13
+ }
14
+
15
+ return debounced
16
+ }
@@ -0,0 +1,258 @@
1
+ import polygonSplitter from 'polygon-splitter'
2
+ import turfBearing from '@turf/bearing'
3
+ import turfDestination from '@turf/destination'
4
+ import turfBooleanValid from '@turf/boolean-valid'
5
+ import turfArea from '@turf/area'
6
+ import {
7
+ featureCollection as turfFeatureCollection,
8
+ polygon as turfPolygon,
9
+ multiPolygon as turfMultiPolygon,
10
+ lineString as turfLineString,
11
+ multiLineString as turfMultiLineString,
12
+ point as turfPoint,
13
+ multiPoint as turfMultiPoint
14
+ } from '@turf/helpers'
15
+
16
+ /**
17
+ * @typedef {import('geojson').Feature<import('geojson').Polygon>} Polygon
18
+ * @typedef {import('geojson').Feature<import('geojson').LineString>} Line
19
+ * @typedef {import('geojson').Feature<import('geojson').Feature>} Feature
20
+ * @typedef {import('geojson').FeatureCollection<import('geojson').FeatureCollection>} FeatureCollection
21
+ */
22
+
23
+ /**
24
+ * Extend a LineString at endpoints AND intermediate vertices.
25
+ * For intermediate vertices on the polygon boundary, this creates small
26
+ * extensions that ensure polygon-splitter recognizes them as crossing points.
27
+ *
28
+ * @param {Feature<LineString>} line
29
+ * @param {number} extendDist (distance to extend in Turf units)
30
+ */
31
+ function extendLine(line, extendDist = 1, units = 'meters') {
32
+ const coords = line.geometry.coordinates
33
+ const result = []
34
+
35
+ // Extend start point backward
36
+ const startBearing = turfBearing(coords[1], coords[0])
37
+ const newStart = turfDestination(coords[0], extendDist, startBearing, { units })
38
+ result.push(newStart.geometry.coordinates)
39
+
40
+ // Process each vertex
41
+ for (let i = 0; i < coords.length; i++) {
42
+ if (i > 0 && i < coords.length - 1) {
43
+ // Intermediate vertex: add extension past it (creates spike for boundary crossing)
44
+ const incomingBearing = turfBearing(coords[i - 1], coords[i])
45
+ const pastPt = turfDestination(coords[i], extendDist, incomingBearing, { units })
46
+ result.push(pastPt.geometry.coordinates)
47
+ }
48
+
49
+ result.push(coords[i])
50
+ }
51
+
52
+ // Extend end point forward
53
+ const endBearing = turfBearing(coords[coords.length - 2], coords[coords.length - 1])
54
+ const newEnd = turfDestination(coords[coords.length - 1], extendDist, endBearing, { units })
55
+ result.push(newEnd.geometry.coordinates)
56
+
57
+ return turfLineString(result)
58
+ }
59
+
60
+ /**
61
+ * Split a polygon using a line.
62
+ * Only accepts splits that result in exactly two polygons.
63
+ *
64
+ * @param {Feature<Polygon>} polygon
65
+ * @param {Feature<LineString>} line
66
+ * @returns {FeatureCollection<Polygon>|null}
67
+ */
68
+ const splitPolygon = (polygon, line) => {
69
+ // Extend only start and end vertices
70
+ const extended = extendLine(line) // assume extendLine only touches start/end now
71
+
72
+ let result
73
+ try {
74
+ result = polygonSplitter(polygon, extended)
75
+ } catch {
76
+ return null
77
+ }
78
+
79
+ // Must result in exactly 2 polygons
80
+ let polygons = []
81
+ if (result.geometry.type === 'MultiPolygon') {
82
+ if (result.geometry.coordinates.length !== 2) {
83
+ return null
84
+ }
85
+ polygons = result.geometry.coordinates.map(coords => turfPolygon(coords, polygon.properties))
86
+ } else {
87
+ return null
88
+ }
89
+
90
+ // Assign IDs & properties
91
+ const baseId = polygon.id ?? polygon.properties?.id ?? 'poly'
92
+ const features = polygons.map((poly, i) =>
93
+ turfPolygon(
94
+ poly.geometry.coordinates,
95
+ { ...polygon.properties, id: baseId },
96
+ { id: `${baseId}-${i + 1}` }
97
+ )
98
+ )
99
+
100
+ return turfFeatureCollection(features)
101
+ }
102
+
103
+ /**
104
+ * Convert a GeoJSON Feature or geometry-like object into a Turf geometry.
105
+ *
106
+ * @param {Object} featureOrGeom - Either a Feature with a `.geometry` property or a raw GeoJSON geometry object.
107
+ * @returns {Object} Turf geometry (Polygon, LineString, Point, etc.)
108
+ *
109
+ * @throws Will throw if the geometry type is not supported.
110
+ */
111
+ const toTurfGeometry = (featureOrGeom) => {
112
+ const geom = featureOrGeom.geometry || featureOrGeom
113
+
114
+ switch (geom.type) {
115
+ case 'Polygon':
116
+ return turfPolygon(geom.coordinates);
117
+ case 'MultiPolygon':
118
+ return turfMultiPolygon(geom.coordinates);
119
+ case 'LineString':
120
+ return turfLineString(geom.coordinates);
121
+ case 'MultiLineString':
122
+ return turfMultiLineString(geom.coordinates);
123
+ case 'Point':
124
+ return turfPoint(geom.coordinates);
125
+ case 'MultiPoint':
126
+ return turfMultiPoint(geom.coordinates);
127
+ default:
128
+ throw new Error(`Unsupported geometry type: ${geom.type}`)
129
+ }
130
+ }
131
+
132
+ const haversine = ([lon1, lat1], [lon2, lat2]) => {
133
+ const toRad = deg => deg * Math.PI / 180
134
+ const R = 6371000 // meters
135
+ const dLat = toRad(lat2 - lat1)
136
+ const dLon = toRad(lon2 - lon1)
137
+ const a = Math.sin(dLat / 2) ** 2 + Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * Math.sin(dLon / 2) ** 2
138
+ return 2 * R * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
139
+ }
140
+
141
+ const isNewCoordinate = (coords, tolerance = 0.01) => {
142
+ // First coord
143
+ if (coords[0].length <= 1) {
144
+ return true
145
+ }
146
+ // Subsequent coordsmust be different
147
+ if (coords[0].length <= 3) {
148
+ for (let i = 0; i < coords[0].length; i++) {
149
+ for (let j = i + 1; j < coords[0].length; j++) {
150
+ if (haversine(coords[0][i], coords[0][j]) < tolerance) {
151
+ return false
152
+ }
153
+ }
154
+ }
155
+ }
156
+ return true
157
+ }
158
+
159
+ const isNewLineCoordinate = (coords, tolerance = 0.01) => {
160
+ // First coord is always valid
161
+ if (coords.length <= 1) {
162
+ return true
163
+ }
164
+ // Check last two coords are different
165
+ if (coords.length >= 2) {
166
+ const last = coords[coords.length - 1]
167
+ const secondLast = coords[coords.length - 2]
168
+ if (haversine(last, secondLast) < tolerance) {
169
+ return false
170
+ }
171
+ }
172
+ return true
173
+ }
174
+
175
+ const isValidLineClick = (coords) => {
176
+ // First coord is always valid
177
+ if (coords.length <= 1) {
178
+ return true
179
+ }
180
+ // Check that the new coordinate is different from the previous one
181
+ return isNewLineCoordinate(coords)
182
+ }
183
+
184
+ const isValidClick = (coords) => {
185
+ // Less than 4 and new coordinates
186
+ if (coords[0].length <= 1 || isNewCoordinate(coords)) {
187
+ return true
188
+ }
189
+
190
+ // Basic checks
191
+ if (!Array.isArray(coords) || coords.length < 4) {
192
+ return false
193
+ }
194
+
195
+ // Check if ring is closed
196
+ const first = coords[0]
197
+ const last = coords[coords.length - 1]
198
+ const isClosed = first[0] === last[0] && first[1] === last[1]
199
+ if (!isClosed) {
200
+ return false
201
+ }
202
+
203
+ // Create a turf polygon
204
+ const turfPoly = turfPolygon([coords])
205
+
206
+ // Check if geometry is valid (non-self-intersecting)
207
+ const valid = turfBooleanValid(turfPoly)
208
+ if (!valid) {
209
+ return false
210
+ }
211
+
212
+ // Check if area is positive
213
+ const polyArea = turfArea(turfPoly)
214
+ if (polyArea <= 0) {
215
+ return false
216
+ }
217
+
218
+ return true
219
+ }
220
+
221
+ const spatialNavigate = (start, pixels, direction) => {
222
+ const quadrant = pixels.filter((p, i) => {
223
+ const offsetX = Math.abs(p[0] - start[0])
224
+ const offsetY = Math.abs(p[1] - start[1])
225
+ let isQuadrant = false
226
+ if (direction === 'ArrowUp') {
227
+ isQuadrant = p[1] <= start[1] && offsetY >= offsetX
228
+ } else if (direction === 'ArrowDown') {
229
+ isQuadrant = p[1] > start[1] && offsetY >= offsetX
230
+ } else if (direction === 'ArrowLeft') {
231
+ isQuadrant = p[0] <= start[0] && offsetY < offsetX
232
+ } else if (direction === 'ArrowRight') {
233
+ isQuadrant = p[0] > start[0] && offsetY < offsetX
234
+ } else {
235
+ isQuadrant = true
236
+ }
237
+ return isQuadrant && (JSON.stringify(p) !== JSON.stringify(start))
238
+ })
239
+
240
+ if (!quadrant.length) {
241
+ quadrant.push(start)
242
+ }
243
+
244
+ const pythagorean = (a, b) => Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2))
245
+ const distances = quadrant.map(p => pythagorean(Math.abs(start[0] - p[0]), Math.abs(start[1] - p[1])))
246
+ const closest = quadrant[distances.indexOf(Math.min(...distances))]
247
+ return pixels.findIndex(i => JSON.stringify(i) === JSON.stringify(closest))
248
+ }
249
+
250
+ export {
251
+ toTurfGeometry,
252
+ splitPolygon,
253
+ extendLine,
254
+ isNewCoordinate,
255
+ isValidClick,
256
+ isValidLineClick,
257
+ spatialNavigate
258
+ }
@@ -0,0 +1 @@
1
+ export const __webpack_esm_id__="im-frame-plugin";export const __webpack_esm_ids__=["im-frame-plugin"];export const __webpack_esm_modules__={"./plugins/beta/frame/src/manifest.js"(e,t,r){function n(e){return n="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},n(e)}function o(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 i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach(function(t){u(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function u(e,t,r){return(t=function(e){var t=function(e){if("object"!=n(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==n(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,{manifest:()=>k}),r.r(t);var a={SET_FRAME:function(e,t){return i(i({},e),{},{frame:t})},SET_FRAME_REFS:function(e,t){return i(i({},e),{},{frameRefs:t})}},c=r("react");function l(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,u,a=[],c=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(l)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(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)?f(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 f(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 p(e){var t;if(null==e||null===(t=e.geometry)||void 0===t||null===(t=t.coordinates)||void 0===t||!t[0])return null;var r=e.geometry.coordinates[0],n=1/0,o=1/0,i=-1/0,u=-1/0;return r.forEach(function(e){var t=l(e,2),r=t[0],a=t[1];r<n&&(n=r),r>i&&(i=r),a<o&&(o=a),a>u&&(u=a)}),[n,o,i,u]}var s=r("react/jsx-runtime");function y(e){return y="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},y(e)}function b(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 m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach(function(t){d(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function d(e,t,r){return(t=function(e){var t=function(e){if("object"!=y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==y(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(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,u,a=[],c=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(l)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(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)?g(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 g(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 O={aspectRatio:1,mobileWidth:"300px",tabletWidth:"360px",desktopWidth:"400px"};function h(e){return h="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},h(e)}function j(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 S(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach(function(t){w(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function w(e,t,r){return(t=function(e){var t=function(e){if("object"!=h(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=h(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==h(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}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 E(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 R(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach(function(t){x(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function x(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 _(e){return _="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},_(e)}function T(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 D(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?T(Object(r),!0).forEach(function(t){M(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function M(e,t,r){return(t=function(e){var t=function(e){if("object"!=_(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=_(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==_(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var A={mobile:{slot:"actions",showLabel:!0},tablet:{slot:"actions",showLabel:!0},desktop:{slot:"actions",showLabel:!0}},k={reducer:{initialState:{frame:null,frameRefs:null},actions:a},InitComponent:function(e){var t,r,n,o,i=e.appState,u=e.mapState,a=e.mapProvider,l=e.pluginConfig,f=e.pluginState,p=e.services,s=e.buttonConfig,y=i.mode,b=i.breakpoint,m=i.layoutRefs,d=p.eventBus,v=s.frameDone,g=s.frameCancel,O=f.dispatch,h=f.frameRefs,j=f.frame,S=null===(t=null===(r=l.includeModes)||void 0===r?void 0:r.includes(y))||void 0===t||t,w=null!==(n=null===(o=l.excludeModes)||void 0===o?void 0:o.includes(y))&&void 0!==n&&n,P=u.isMapReady&&S&&!w;(0,c.useEffect)(function(){if(P)return v.onClick=function(){var e=function(e){var t=e.viewportEl,r=e.mapProvider,n=e.featureId,o=e.scale,i=e.frameEl.getBoundingClientRect(),u=t.getBoundingClientRect(),a={x:(i.left-u.left)/o,y:(i.top-u.top)/o},c={x:(i.right-u.left)/o,y:(i.top-u.top)/o},l={x:(i.right-u.left)/o,y:(i.bottom-u.top)/o},f={x:(i.left-u.left)/o,y:(i.bottom-u.top)/o},p={type:"Feature",geometry:{type:"Polygon",coordinates:[[r.screenToMap(a),r.screenToMap(c),r.screenToMap(l),r.screenToMap(f),r.screenToMap(a)]]},properties:{}};return n&&(p.id=n),p}({frameEl:h.displayRef.current,viewportEl:m.viewportRef.current,featureId:null==j?void 0:j.featureId,scale:{small:1,medium:1.5,large:2}[u.mapSize],mapProvider:a});O({type:"SET_FRAME",payload:null}),d.emit("frame:done",e)},g.onClick=function(){O({type:"SET_FRAME",payload:null}),d.emit("frame:cancel")},function(){v.onClick=null,g.onClick=null}},[u.isMapReady,y,b,j,h,m,a,O,d,v,g])},controls:[{id:"frame",label:"Frame",mobile:{slot:"middle"},tablet:{slot:"middle"},desktop:{slot:"middle"},render:function(e){var t,r=e.appState,n=e.mapState,o=e.pluginState,i=e.mapProvider,u=r.layoutRefs,a=u.actionsRef,l=u.mainRef,f=u.footerRef,p=u.viewportRef,y=o.dispatch,b=(0,c.useRef)(null),d=(0,c.useRef)(null),g=(0,c.useRef)(null),O=v((0,c.useState)("65px"),2),h=O[0],j=O[1],S=v((0,c.useState)(null),2),w=S[0],P=S[1];return(0,c.useEffect)(function(){y({type:"SET_FRAME_REFS",payload:{displayRef:d}})},[]),(0,c.useEffect)(function(){if(o.frame&&b.current){var e=b.current,t=function(){if(a.current&&l.current&&f.current){var t=l.current.offsetHeight,n=f.current.offsetTop,i=a.current.offsetTop,u=t-Math.min(i,n)+10;j("65px 65px ".concat(u,"px 65px"));var c=e.offsetWidth,p=e.offsetHeight;if(t-u-e.offsetTop===e.offsetHeight){var s=function(e,t,r,n){var o=Number.parseInt(r["".concat(n,"Width")]||e,10),i=Math.min(o,e),u=i/r.aspectRatio;return u>t&&(i=(u=t)*r.aspectRatio),{top:(t-u)/2,left:(e-i)/2,width:i,height:u}}(c,p,o.frame,r.breakpoint),y=s.top,b=s.left,m=s.width,d=s.height,v=y+e.offsetTop,g=b+e.offsetLeft;P({top:"".concat(v,"px"),left:"".concat(g,"px"),width:"".concat(m,"px"),height:"".concat(d,"px")})}}},n=new ResizeObserver(t);return n.observe(e),t(),function(){return n.disconnect()}}g.current=null},[o.frame,r.breakpoint,a,l,f]),(0,c.useEffect)(function(){var e;if(null!==(e=o.frame)&&void 0!==e&&e.bounds&&d.current&&p.current&&w){var t=d.current,r=p.current,u=t.getBoundingClientRect(),a=r.getBoundingClientRect(),c={small:1,medium:1.5,large:2}[n.mapSize],l={top:(u.top-a.top)/c,right:(a.right-u.right)/c,bottom:(a.bottom-u.bottom)/c,left:(u.left-a.left)/c};i.setPadding(l),i.fitToBounds(o.frame.bounds,!0)}},[null===(t=o.frame)||void 0===t?void 0:t.bounds,w,i,d,p]),o.frame?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"im-c-frame-spacer",style:{inset:h},ref:b}),w&&(0,s.jsx)("div",{ref:d,className:"im-c-frame-display",style:m({},w)})]}):null}}],buttons:[D({id:"frameDone",label:"Done",variant:"primary",hiddenWhen:function(e){return!e.pluginState.frame}},A),D({id:"frameCancel",label:"Cancel",variant:"tertiary",hiddenWhen:function(e){return!e.pluginState.frame}},A)],api:{addFrame:function(e,t){var r=e.pluginConfig,n=e.pluginState,o=e.services,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=n.dispatch,a=o.eventBus;u({type:"SET_FRAME",payload:S(S(S(S({},O),r),i),{},{featureId:t})}),a.emit("frame:add")},editFeature:function(e,t){var r=e.pluginConfig,n=e.pluginState,o=e.mapProvider,i=e.services,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=n.dispatch,c=i.eventBus,f=p(t),s=function(e,t){var r=p(e);if(!r)return null;var n=l(r,4),o=n[0],i=n[1],u=n[2],a=n[3],c=t.mapToScreen([o,a]),f=t.mapToScreen([u,i]),s=Math.abs(f.x-c.x),y=Math.abs(f.y-c.y);return 0===y?null:Math.round(s/y*1e6)/1e6}(t,o),y=R(R(R(R({},O),r),u),{},{aspectRatio:s,featureId:(null==t?void 0:t.id)||t.properties.id});a({type:"SET_FRAME",payload:R(R({},y),{},{bounds:f})}),c.emit("frame:edit")}}}}};
@@ -0,0 +1,2 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ import*as e from"react";import*as t from"react/jsx-runtime";var r,n,o={react(t,r,n){var o,i;t.exports=(o={useEffect:()=>e.useEffect,useRef:()=>e.useRef,useState:()=>e.useState},i={},n.d(i,o),i)},"react/jsx-runtime"(e,r,n){var o,i;e.exports=(o={Fragment:()=>t.Fragment,jsx:()=>t.jsx,jsxs:()=>t.jsxs},i={},n.d(i,o),i)}},i={};function u(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,u),r.exports}u.m=o,u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.f={},u.e=e=>Promise.all(Object.keys(u.f).reduce((t,r)=>(u.f[r](e,t),t),[])),u.u=e=>"../esm/"+e+".js",u.miniCssF=e=>{},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;if("string"==typeof import.meta.url&&(e=import.meta.url),!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),u.p=e+"../css/"})(),r={index:0},n=e=>{var t,n,{__webpack_esm_ids__:o,__webpack_esm_modules__:i,__webpack_esm_runtime__:c}=e,a=0;for(t in i)u.o(i,t)&&(u.m[t]=i[t]);for(c&&c(u);a<o.length;a++)n=o[a],u.o(r,n)&&r[n]&&r[n][0](),r[o[a]]=0},u.f.j=(e,t)=>{var o=u.o(r,e)?r[e]:void 0;if(0!==o)if(o)t.push(o[1]);else{var i=import("../css/"+u.u(e)).then(n,t=>{throw 0!==r[e]&&(r[e]=void 0),t});i=Promise.race([i,new Promise(t=>o=r[e]=[t])]),t.push(o[1]=i)}};var c={};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 f(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var a=n&&n.prototype instanceof c?n:c,f=Object.create(a.prototype);return s(f,"_invoke",function(r,n,o){var i,c,a,f=0,s=o||[],p=!1,l={p:0,n:0,v:e,a:b,f:b.bind(e,4),d:function(t,r){return i=t,c=0,a=e,l.n=r,u}};function b(r,n){for(c=r,a=n,t=0;!p&&f&&!o&&t<s.length;t++){var o,i=s[t],b=l.p,y=i[2];r>3?(o=y===n)&&(a=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=b&&((o=r<2&&b<i[1])?(c=0,l.v=n,l.n=i[1]):b<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,l.n=y,c=0))}if(o||r>1)return u;throw p=!0,n}return function(o,s,y){if(f>1)throw TypeError("Generator is already running");for(p&&1===s&&b(s,y),c=s,a=y;(t=c<2?e:a)||!p;){i||(c?c<3?(c>1&&(l.n=-1),b(c,a)):l.n=a:l.v=a);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,a)))throw TypeError("iterator result is not an object");if(!t.done)return t;a=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(p=l.n<0)?a:r.call(n,l))!==u)break}catch(t){i=e,c=1,a=t}finally{f=1}}return{value:t,done:p}}}(r,o,i),!0),f}var u={};function c(){}function a(){}function p(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(s(t={},n,function(){return this}),t),b=p.prototype=c.prototype=Object.create(l);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,o,"GeneratorFunction")),e.prototype=Object.create(b),e}return a.prototype=p,s(b,"constructor",p),s(p,"constructor",a),a.displayName="GeneratorFunction",s(p,o,"GeneratorFunction"),s(b),s(b,o,"Generator"),s(b,n,function(){return this}),s(b,"toString",function(){return"[object Generator]"}),(f=function(){return{w:i,m:y}})()}function s(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}s=function(e,t,r,n){function i(t,r){s(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},s(e,t,r,n)}function p(e,t,r,n,o,i,u){try{var c=e[i](u),a=c.value}catch(e){return void r(e)}c.done?t(a):Promise.resolve(a).then(n,o)}function l(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 b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach(function(t){y(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function y(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}function m(){var e,t;return b(b({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"frame",load:(e=f().m(function e(){var t;return f().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,u.e("im-frame-plugin").then(u.bind(u,"./plugins/beta/frame/src/manifest.js"));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function u(e){p(i,n,o,u,c,"next",e)}function c(e){p(i,n,o,u,c,"throw",e)}u(void 0)})},function(){return t.apply(this,arguments)})})}u.d(c,{A:()=>m});const v=c.A;export{v as default};
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[191],{397(t,e,r){function n(t){return n="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},n(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){u(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function u(t,e,r){return(e=function(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.r(e),r.d(e,{manifest:()=>A});var a={SET_FRAME:function(t,e){return i(i({},t),{},{frame:e})},SET_FRAME_REFS:function(t,e){return i(i({},t),{},{frameRefs:e})}},c=r(738);function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(l)throw o}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return f(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function p(t){var e;if(null==t||null===(e=t.geometry)||void 0===e||null===(e=e.coordinates)||void 0===e||!e[0])return null;var r=t.geometry.coordinates[0],n=1/0,o=1/0,i=-1/0,u=-1/0;return r.forEach(function(t){var e=l(t,2),r=e[0],a=e[1];r<n&&(n=r),r>i&&(i=r),a<o&&(o=a),a>u&&(u=a)}),[n,o,i,u]}var s=r(287);function y(t){return y="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},y(t)}function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function m(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach(function(e){d(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function d(t,e,r){return(e=function(t){var e=function(t){if("object"!=y(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==y(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(l)throw o}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return g(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var O={aspectRatio:1,mobileWidth:"300px",tabletWidth:"360px",desktopWidth:"400px"};function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function j(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function S(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?j(Object(r),!0).forEach(function(e){w(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function w(t,e,r){return(e=function(t){var e=function(t){if("object"!=h(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=h(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==h(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(t){return P="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},P(t)}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function R(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach(function(e){T(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function T(t,e,r){return(e=function(t){var e=function(t){if("object"!=P(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=P(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function D(t){return D="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},D(t)}function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function x(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?M(Object(r),!0).forEach(function(e){C(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function C(t,e,r){return(e=function(t){var e=function(t){if("object"!=D(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=D(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==D(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var k={mobile:{slot:"actions",showLabel:!0},tablet:{slot:"actions",showLabel:!0},desktop:{slot:"actions",showLabel:!0}},A={reducer:{initialState:{frame:null,frameRefs:null},actions:a},InitComponent:function(t){var e,r,n,o,i=t.appState,u=t.mapState,a=t.mapProvider,l=t.pluginConfig,f=t.pluginState,p=t.services,s=t.buttonConfig,y=i.mode,b=i.breakpoint,m=i.layoutRefs,d=p.eventBus,v=s.frameDone,g=s.frameCancel,O=f.dispatch,h=f.frameRefs,j=f.frame,S=null===(e=null===(r=l.includeModes)||void 0===r?void 0:r.includes(y))||void 0===e||e,w=null!==(n=null===(o=l.excludeModes)||void 0===o?void 0:o.includes(y))&&void 0!==n&&n,P=u.isMapReady&&S&&!w;(0,c.useEffect)(function(){if(P)return v.onClick=function(){var t=function(t){var e=t.viewportEl,r=t.mapProvider,n=t.featureId,o=t.scale,i=t.frameEl.getBoundingClientRect(),u=e.getBoundingClientRect(),a={x:(i.left-u.left)/o,y:(i.top-u.top)/o},c={x:(i.right-u.left)/o,y:(i.top-u.top)/o},l={x:(i.right-u.left)/o,y:(i.bottom-u.top)/o},f={x:(i.left-u.left)/o,y:(i.bottom-u.top)/o},p={type:"Feature",geometry:{type:"Polygon",coordinates:[[r.screenToMap(a),r.screenToMap(c),r.screenToMap(l),r.screenToMap(f),r.screenToMap(a)]]},properties:{}};return n&&(p.id=n),p}({frameEl:h.displayRef.current,viewportEl:m.viewportRef.current,featureId:null==j?void 0:j.featureId,scale:{small:1,medium:1.5,large:2}[u.mapSize],mapProvider:a});O({type:"SET_FRAME",payload:null}),d.emit("frame:done",t)},g.onClick=function(){O({type:"SET_FRAME",payload:null}),d.emit("frame:cancel")},function(){v.onClick=null,g.onClick=null}},[u.isMapReady,y,b,j,h,m,a,O,d,v,g])},controls:[{id:"frame",label:"Frame",mobile:{slot:"middle"},tablet:{slot:"middle"},desktop:{slot:"middle"},render:function(t){var e,r=t.appState,n=t.mapState,o=t.pluginState,i=t.mapProvider,u=r.layoutRefs,a=u.actionsRef,l=u.mainRef,f=u.footerRef,p=u.viewportRef,y=o.dispatch,b=(0,c.useRef)(null),d=(0,c.useRef)(null),g=(0,c.useRef)(null),O=v((0,c.useState)("65px"),2),h=O[0],j=O[1],S=v((0,c.useState)(null),2),w=S[0],P=S[1];return(0,c.useEffect)(function(){y({type:"SET_FRAME_REFS",payload:{displayRef:d}})},[]),(0,c.useEffect)(function(){if(o.frame&&b.current){var t=b.current,e=function(){if(a.current&&l.current&&f.current){var e=l.current.offsetHeight,n=f.current.offsetTop,i=a.current.offsetTop,u=e-Math.min(i,n)+10;j("65px 65px ".concat(u,"px 65px"));var c=t.offsetWidth,p=t.offsetHeight;if(e-u-t.offsetTop===t.offsetHeight){var s=function(t,e,r,n){var o=Number.parseInt(r["".concat(n,"Width")]||t,10),i=Math.min(o,t),u=i/r.aspectRatio;return u>e&&(i=(u=e)*r.aspectRatio),{top:(e-u)/2,left:(t-i)/2,width:i,height:u}}(c,p,o.frame,r.breakpoint),y=s.top,b=s.left,m=s.width,d=s.height,v=y+t.offsetTop,g=b+t.offsetLeft;P({top:"".concat(v,"px"),left:"".concat(g,"px"),width:"".concat(m,"px"),height:"".concat(d,"px")})}}},n=new ResizeObserver(e);return n.observe(t),e(),function(){return n.disconnect()}}g.current=null},[o.frame,r.breakpoint,a,l,f]),(0,c.useEffect)(function(){var t;if(null!==(t=o.frame)&&void 0!==t&&t.bounds&&d.current&&p.current&&w){var e=d.current,r=p.current,u=e.getBoundingClientRect(),a=r.getBoundingClientRect(),c={small:1,medium:1.5,large:2}[n.mapSize],l={top:(u.top-a.top)/c,right:(a.right-u.right)/c,bottom:(a.bottom-u.bottom)/c,left:(u.left-a.left)/c};i.setPadding(l),i.fitToBounds(o.frame.bounds,!0)}},[null===(e=o.frame)||void 0===e?void 0:e.bounds,w,i,d,p]),o.frame?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"im-c-frame-spacer",style:{inset:h},ref:b}),w&&(0,s.jsx)("div",{ref:d,className:"im-c-frame-display",style:m({},w)})]}):null}}],buttons:[x({id:"frameDone",label:"Done",variant:"primary",hiddenWhen:function(t){return!t.pluginState.frame}},k),x({id:"frameCancel",label:"Cancel",variant:"tertiary",hiddenWhen:function(t){return!t.pluginState.frame}},k)],api:{addFrame:function(t,e){var r=t.pluginConfig,n=t.pluginState,o=t.services,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=n.dispatch,a=o.eventBus;u({type:"SET_FRAME",payload:S(S(S(S({},O),r),i),{},{featureId:e})}),a.emit("frame:add")},editFeature:function(t,e){var r=t.pluginConfig,n=t.pluginState,o=t.mapProvider,i=t.services,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=n.dispatch,c=i.eventBus,f=p(e),s=function(t,e){var r=p(t);if(!r)return null;var n=l(r,4),o=n[0],i=n[1],u=n[2],a=n[3],c=e.mapToScreen([o,a]),f=e.mapToScreen([u,i]),s=Math.abs(f.x-c.x),y=Math.abs(f.y-c.y);return 0===y?null:Math.round(s/y*1e6)/1e6}(e,o),y=R(R(R(R({},O),r),u),{},{aspectRatio:s,featureId:(null==e?void 0:e.id)||e.properties.id});a({type:"SET_FRAME",payload:R(R({},y),{},{bounds:f})}),c.emit("frame:edit")}}}}}]);