@element-editor/ui 0.0.0-stage → 0.2.1

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 (244) hide show
  1. package/AGENTS.md +65 -0
  2. package/LICENSE +21 -0
  3. package/README.md +46 -2
  4. package/dist/BooleanOperations-BRO7NHUY.js +111 -0
  5. package/dist/BooleanOperations-C2uOHRu3.cjs +1 -0
  6. package/dist/DataTable-B-2VjBEz.cjs +2 -0
  7. package/dist/DataTable-CS-3dIqY.js +510 -0
  8. package/dist/DataTablePanel-58LwzXQR.cjs +1 -0
  9. package/dist/DataTablePanel-DDFUmMaM.js +208 -0
  10. package/dist/EditToolbarBtn-Ch9HCLHq.cjs +3 -0
  11. package/dist/EditToolbarBtn-SR4xHd8G.js +378 -0
  12. package/dist/FeatureEditModal-Cc8N6vei.cjs +1 -0
  13. package/dist/FeatureEditModal-Dr10p3nE.js +77 -0
  14. package/dist/FeatureList-Bo9w9nre.js +520 -0
  15. package/dist/FeatureList-VRYesXCq.cjs +1 -0
  16. package/dist/FeatureRowContextMenu-CtBqdC1j.cjs +1 -0
  17. package/dist/FeatureRowContextMenu-DCUIiDwc.js +130 -0
  18. package/dist/GeoJSONModal-BV9Tamf4.js +886 -0
  19. package/dist/GeoJSONModal-Dd-nBufy.cjs +9 -0
  20. package/dist/SchemaEditor-B4L17K1e.cjs +1 -0
  21. package/dist/SchemaEditor-ryoTgaLb.js +293 -0
  22. package/dist/SchemaModal-DvMbWskS.js +95 -0
  23. package/dist/SchemaModal-gAuDkd-L.cjs +1 -0
  24. package/dist/SettingsModal-BScVTjpn.js +237 -0
  25. package/dist/SettingsModal-CqaSFxxR.cjs +1 -0
  26. package/dist/ShortcutsModal-D1Y2bGT8.cjs +1 -0
  27. package/dist/ShortcutsModal-ozuS2Ysb.js +299 -0
  28. package/dist/components/ActiveDrawingToolbar.d.cts +1 -0
  29. package/dist/components/ActiveDrawingToolbar.d.ts +1 -0
  30. package/dist/components/BasemapPicker.d.cts +26 -0
  31. package/dist/components/BasemapPicker.d.ts +26 -0
  32. package/dist/components/BooleanOperations.d.cts +1 -0
  33. package/dist/components/BooleanOperations.d.ts +1 -0
  34. package/dist/components/BufferPanel.d.cts +1 -0
  35. package/dist/components/BufferPanel.d.ts +1 -0
  36. package/dist/components/DataTable.d.cts +9 -0
  37. package/dist/components/DataTable.d.ts +9 -0
  38. package/dist/components/DataTablePanel.d.cts +10 -0
  39. package/dist/components/DataTablePanel.d.ts +10 -0
  40. package/dist/components/EditingToolbar.d.cts +1 -0
  41. package/dist/components/EditingToolbar.d.ts +1 -0
  42. package/dist/components/ElementEditorErrorBoundary.d.cts +28 -0
  43. package/dist/components/ElementEditorErrorBoundary.d.ts +28 -0
  44. package/dist/components/ElementEditorUIProvider.d.cts +50 -0
  45. package/dist/components/ElementEditorUIProvider.d.ts +50 -0
  46. package/dist/components/FeatureMapContextMenu.d.cts +23 -0
  47. package/dist/components/FeatureMapContextMenu.d.ts +23 -0
  48. package/dist/components/FitBoundsButton.d.cts +6 -0
  49. package/dist/components/FitBoundsButton.d.ts +6 -0
  50. package/dist/components/FloatingToolbar.d.cts +3 -0
  51. package/dist/components/FloatingToolbar.d.ts +3 -0
  52. package/dist/components/LocateButton.d.cts +11 -0
  53. package/dist/components/LocateButton.d.ts +11 -0
  54. package/dist/components/ReadonlyBanner.d.cts +1 -0
  55. package/dist/components/ReadonlyBanner.d.ts +1 -0
  56. package/dist/components/ShortcutsModal.d.cts +1 -0
  57. package/dist/components/ShortcutsModal.d.ts +1 -0
  58. package/dist/components/SimplifyPanel.d.cts +1 -0
  59. package/dist/components/SimplifyPanel.d.ts +1 -0
  60. package/dist/components/SmoothPanel.d.cts +1 -0
  61. package/dist/components/SmoothPanel.d.ts +1 -0
  62. package/dist/components/UndoRedoToolbar.d.cts +20 -0
  63. package/dist/components/UndoRedoToolbar.d.ts +20 -0
  64. package/dist/components/VertexSelectionBar.d.cts +12 -0
  65. package/dist/components/VertexSelectionBar.d.ts +12 -0
  66. package/dist/components/ZoomIndicator.d.cts +15 -0
  67. package/dist/components/ZoomIndicator.d.ts +15 -0
  68. package/dist/components/dialogs/DynamicFieldRenderer.d.cts +11 -0
  69. package/dist/components/dialogs/DynamicFieldRenderer.d.ts +11 -0
  70. package/dist/components/dialogs/SettingsModal.d.cts +1 -0
  71. package/dist/components/dialogs/SettingsModal.d.ts +1 -0
  72. package/dist/components/lazyParts.d.cts +12 -0
  73. package/dist/components/lazyParts.d.ts +12 -0
  74. package/dist/components/sidebar/FeatureEditModal.d.cts +6 -0
  75. package/dist/components/sidebar/FeatureEditModal.d.ts +6 -0
  76. package/dist/components/sidebar/FeatureList.d.cts +4 -0
  77. package/dist/components/sidebar/FeatureList.d.ts +4 -0
  78. package/dist/components/sidebar/FeatureRow.d.cts +38 -0
  79. package/dist/components/sidebar/FeatureRow.d.ts +38 -0
  80. package/dist/components/sidebar/FeatureRowContextMenu.d.cts +12 -0
  81. package/dist/components/sidebar/FeatureRowContextMenu.d.ts +12 -0
  82. package/dist/components/sidebar/FeatureSidePanel.d.cts +8 -0
  83. package/dist/components/sidebar/FeatureSidePanel.d.ts +8 -0
  84. package/dist/components/sidebar/GeoJSONModal.d.cts +5 -0
  85. package/dist/components/sidebar/GeoJSONModal.d.ts +5 -0
  86. package/dist/components/sidebar/GroupRow.d.cts +21 -0
  87. package/dist/components/sidebar/GroupRow.d.ts +21 -0
  88. package/dist/components/sidebar/HideLayersToggle.d.cts +2 -0
  89. package/dist/components/sidebar/HideLayersToggle.d.ts +2 -0
  90. package/dist/components/sidebar/LayersPanel.d.cts +5 -0
  91. package/dist/components/sidebar/LayersPanel.d.ts +5 -0
  92. package/dist/components/sidebar/PartSubRow.d.cts +9 -0
  93. package/dist/components/sidebar/PartSubRow.d.ts +9 -0
  94. package/dist/components/sidebar/SchemaEditor.d.cts +4 -0
  95. package/dist/components/sidebar/SchemaEditor.d.ts +4 -0
  96. package/dist/components/sidebar/SchemaModal.d.cts +5 -0
  97. package/dist/components/sidebar/SchemaModal.d.ts +5 -0
  98. package/dist/components/sidebar/codeDock.d.cts +21 -0
  99. package/dist/components/sidebar/codeDock.d.ts +21 -0
  100. package/dist/components/ui/Button.d.cts +9 -0
  101. package/dist/components/ui/Button.d.ts +9 -0
  102. package/dist/components/ui/CloseButton.d.cts +6 -0
  103. package/dist/components/ui/CloseButton.d.ts +6 -0
  104. package/dist/components/ui/ContextMenu.d.cts +28 -0
  105. package/dist/components/ui/ContextMenu.d.ts +28 -0
  106. package/dist/components/ui/EditToolbarBtn.d.cts +13 -0
  107. package/dist/components/ui/EditToolbarBtn.d.ts +13 -0
  108. package/dist/components/ui/ElementToaster.d.cts +3 -0
  109. package/dist/components/ui/ElementToaster.d.ts +3 -0
  110. package/dist/components/ui/GeometryTypeIcon.d.cts +7 -0
  111. package/dist/components/ui/GeometryTypeIcon.d.ts +7 -0
  112. package/dist/components/ui/IconButton.d.cts +28 -0
  113. package/dist/components/ui/IconButton.d.ts +28 -0
  114. package/dist/components/ui/Input.d.cts +14 -0
  115. package/dist/components/ui/Input.d.ts +14 -0
  116. package/dist/components/ui/JsonCode.d.cts +4 -0
  117. package/dist/components/ui/JsonCode.d.ts +4 -0
  118. package/dist/components/ui/Kbd.d.cts +16 -0
  119. package/dist/components/ui/Kbd.d.ts +16 -0
  120. package/dist/components/ui/NoFeaturesEmptyState.d.cts +1 -0
  121. package/dist/components/ui/NoFeaturesEmptyState.d.ts +1 -0
  122. package/dist/components/ui/SearchDropdown.d.cts +28 -0
  123. package/dist/components/ui/SearchDropdown.d.ts +28 -0
  124. package/dist/components/ui/ToolButton.d.cts +19 -0
  125. package/dist/components/ui/ToolButton.d.ts +19 -0
  126. package/dist/components/ui/Tooltip.d.cts +12 -0
  127. package/dist/components/ui/Tooltip.d.ts +12 -0
  128. package/dist/components/ui/panelHeader.d.cts +2 -0
  129. package/dist/components/ui/panelHeader.d.ts +2 -0
  130. package/dist/components/ui/resizeEdge.d.cts +4 -0
  131. package/dist/components/ui/resizeEdge.d.ts +4 -0
  132. package/dist/contexts/ElementEditorConfigContext.d.cts +351 -0
  133. package/dist/contexts/ElementEditorConfigContext.d.ts +351 -0
  134. package/dist/contexts/EventContext.d.cts +69 -0
  135. package/dist/contexts/EventContext.d.ts +69 -0
  136. package/dist/contexts/MapControllerContext.d.cts +24 -0
  137. package/dist/contexts/MapControllerContext.d.ts +24 -0
  138. package/dist/contexts/ShortcutConfigContext.d.cts +16 -0
  139. package/dist/contexts/ShortcutConfigContext.d.ts +16 -0
  140. package/dist/contexts/ThemeContext.d.cts +12 -0
  141. package/dist/contexts/ThemeContext.d.ts +12 -0
  142. package/dist/element-editor-ui.cjs +1 -0
  143. package/dist/element-editor-ui.es.js +102 -0
  144. package/dist/geometryWorker-CCwg4tNC.cjs +1 -0
  145. package/dist/geometryWorker-DgQCFSmD.js +25 -0
  146. package/dist/hooks/dragShield.d.cts +7 -0
  147. package/dist/hooks/dragShield.d.ts +7 -0
  148. package/dist/hooks/themeInputs.d.cts +14 -0
  149. package/dist/hooks/themeInputs.d.ts +14 -0
  150. package/dist/hooks/useAccentPalette.d.cts +15 -0
  151. package/dist/hooks/useAccentPalette.d.ts +15 -0
  152. package/dist/hooks/useAccentStyle.d.cts +39 -0
  153. package/dist/hooks/useAccentStyle.d.ts +39 -0
  154. package/dist/hooks/useAdapterControls.d.cts +280 -0
  155. package/dist/hooks/useAdapterControls.d.ts +280 -0
  156. package/dist/hooks/useBalancedWrap.d.cts +8 -0
  157. package/dist/hooks/useBalancedWrap.d.ts +8 -0
  158. package/dist/hooks/useContextMenu.d.cts +11 -0
  159. package/dist/hooks/useContextMenu.d.ts +11 -0
  160. package/dist/hooks/useDataChangeSubscription.d.cts +9 -0
  161. package/dist/hooks/useDataChangeSubscription.d.ts +9 -0
  162. package/dist/hooks/useDragWindow.d.cts +9 -0
  163. package/dist/hooks/useDragWindow.d.ts +9 -0
  164. package/dist/hooks/useFocusTrap.d.cts +7 -0
  165. package/dist/hooks/useFocusTrap.d.ts +7 -0
  166. package/dist/hooks/useGeoJSONDrop.d.cts +40 -0
  167. package/dist/hooks/useGeoJSONDrop.d.ts +40 -0
  168. package/dist/hooks/useGeoJSONExport.d.cts +69 -0
  169. package/dist/hooks/useGeoJSONExport.d.ts +69 -0
  170. package/dist/hooks/useGeoJSONFileImport.d.cts +24 -0
  171. package/dist/hooks/useGeoJSONFileImport.d.ts +24 -0
  172. package/dist/hooks/useInlineRename.d.cts +26 -0
  173. package/dist/hooks/useInlineRename.d.ts +26 -0
  174. package/dist/hooks/useJumpToFeature.d.cts +3 -0
  175. package/dist/hooks/useJumpToFeature.d.ts +3 -0
  176. package/dist/hooks/useKeyboardShortcuts.d.cts +9 -0
  177. package/dist/hooks/useKeyboardShortcuts.d.ts +9 -0
  178. package/dist/hooks/useNominatim.d.cts +24 -0
  179. package/dist/hooks/useNominatim.d.ts +24 -0
  180. package/dist/hooks/usePanelOffset.d.cts +14 -0
  181. package/dist/hooks/usePanelOffset.d.ts +14 -0
  182. package/dist/hooks/useResizablePanel.d.cts +4 -0
  183. package/dist/hooks/useResizablePanel.d.ts +4 -0
  184. package/dist/hooks/useRootTokens.d.cts +27 -0
  185. package/dist/hooks/useRootTokens.d.ts +27 -0
  186. package/dist/hooks/useSearchState.d.cts +23 -0
  187. package/dist/hooks/useSearchState.d.ts +23 -0
  188. package/dist/hooks/useServiceAttribution.d.cts +13 -0
  189. package/dist/hooks/useServiceAttribution.d.ts +13 -0
  190. package/dist/hooks/useWindowEscape.d.cts +25 -0
  191. package/dist/hooks/useWindowEscape.d.ts +25 -0
  192. package/dist/hooks/useWindowFocus.d.cts +4 -0
  193. package/dist/hooks/useWindowFocus.d.ts +4 -0
  194. package/dist/hooks/useWorkerGeometryPreview.d.cts +22 -0
  195. package/dist/hooks/useWorkerGeometryPreview.d.ts +22 -0
  196. package/dist/index-CILw1Du5.js +3165 -0
  197. package/dist/index-DG4wEjGj.cjs +1 -0
  198. package/dist/index.d.cts +89 -0
  199. package/dist/index.d.ts +89 -0
  200. package/dist/internal.cjs +1 -0
  201. package/dist/internal.d.cts +16 -0
  202. package/dist/internal.d.ts +16 -0
  203. package/dist/internal.es.js +42 -0
  204. package/dist/primitives.cjs +1 -0
  205. package/dist/primitives.d.cts +19 -0
  206. package/dist/primitives.d.ts +19 -0
  207. package/dist/primitives.es.js +17 -0
  208. package/dist/store/StoreContext.d.cts +17 -0
  209. package/dist/store/StoreContext.d.ts +17 -0
  210. package/dist/types/events.d.cts +95 -0
  211. package/dist/types/events.d.ts +95 -0
  212. package/dist/useAccentStyle-CPo2XqAn.js +412 -0
  213. package/dist/useAccentStyle-hsGvyHZc.cjs +1 -0
  214. package/dist/useAdapterControls-BBObhzVX.cjs +1 -0
  215. package/dist/useAdapterControls-DVjkwRZ_.js +691 -0
  216. package/dist/useContextMenu-DJ2Cti85.js +10 -0
  217. package/dist/useContextMenu-DbxMvb1s.cjs +1 -0
  218. package/dist/useFocusTrap-BBjPCfDR.cjs +1 -0
  219. package/dist/useFocusTrap-CKxKT8De.js +25 -0
  220. package/dist/useJumpToFeature-Bdz2hqOC.js +16 -0
  221. package/dist/useJumpToFeature-LwjxGzfy.cjs +1 -0
  222. package/dist/useWindowFocus-DuQVjnHE.js +80 -0
  223. package/dist/useWindowFocus-EemgNOuz.cjs +1 -0
  224. package/dist/utils/booleanValue.d.cts +4 -0
  225. package/dist/utils/booleanValue.d.ts +4 -0
  226. package/dist/utils/clipboardError.d.cts +3 -0
  227. package/dist/utils/clipboardError.d.ts +3 -0
  228. package/dist/utils/download.d.cts +42 -0
  229. package/dist/utils/download.d.ts +42 -0
  230. package/dist/utils/geojsonDocument.d.cts +168 -0
  231. package/dist/utils/geojsonDocument.d.ts +168 -0
  232. package/dist/utils/geometryWorkerClient.d.cts +6 -0
  233. package/dist/utils/geometryWorkerClient.d.ts +6 -0
  234. package/dist/utils/layerOrder.d.cts +9 -0
  235. package/dist/utils/layerOrder.d.ts +9 -0
  236. package/dist/utils/lazyWithPreload.d.cts +24 -0
  237. package/dist/utils/lazyWithPreload.d.ts +24 -0
  238. package/dist/utils/lineSmooth.d.cts +7 -0
  239. package/dist/utils/lineSmooth.d.ts +7 -0
  240. package/dist/utils/platform.d.cts +2 -0
  241. package/dist/utils/platform.d.ts +2 -0
  242. package/dist/workers/geometryWorker.d.cts +1 -0
  243. package/dist/workers/geometryWorker.d.ts +1 -0
  244. package/package.json +133 -3
@@ -0,0 +1,886 @@
1
+ var Gt = Object.defineProperty;
2
+ var Ut = (e, n, t) => n in e ? Gt(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
+ var nt = (e, n, t) => Ut(e, typeof n != "symbol" ? n + "" : n, t);
4
+ import { jsx as M, jsxs as se } from "react/jsx-runtime";
5
+ import { useState as ce, useContext as Yt, useRef as B, useCallback as $t, useEffect as ge } from "react";
6
+ import { e as Ct, k as qt, E as Kt, f as we, d as Vt } from "./useAdapterControls-DVjkwRZ_.js";
7
+ import { m as Xt, C as Zt, n as Qt, o as en, u as tn, q as nn, a as on, W as rn, t as sn, s as cn } from "./index-CILw1Du5.js";
8
+ import { u as St, e as ln } from "./useAccentStyle-CPo2XqAn.js";
9
+ import { writeStorage as kt, readStorage as an } from "@element-editor/core";
10
+ import { createPortal as un } from "react-dom";
11
+ import { Check as fn, Copy as dn, DownloadSimple as hn, ArrowSquareOut as mn, SidebarSimple as gn, X as pn, WarningCircle as bn } from "@phosphor-icons/react";
12
+ import { u as yn, a as vn, C as xn } from "./useWindowFocus-DuQVjnHE.js";
13
+ import { EditorView as ie, ViewPlugin as wn, Decoration as Mt } from "@codemirror/view";
14
+ import { Text as ee, Compartment as ot, EditorState as Pe, StateField as Cn, Prec as Et, Annotation as Sn, ChangeSet as kn, StateEffect as Mn, RangeSetBuilder as En, Transaction as Ln } from "@codemirror/state";
15
+ import { json as Nn } from "@codemirror/lang-json";
16
+ import { oneDark as On } from "@codemirror/theme-one-dark";
17
+ import { basicSetup as Dn } from "codemirror";
18
+ import { forEachDiagnostic as An, setDiagnostics as In } from "@codemirror/lint";
19
+ import { u as Tn } from "./useFocusTrap-CKxKT8De.js";
20
+ import { u as Rn } from "./useJumpToFeature-Bdz2hqOC.js";
21
+ import { f as Ce } from "./EditToolbarBtn-SR4xHd8G.js";
22
+ function Fn(e) {
23
+ const { _validation: n, ...t } = e, o = JSON.stringify(t, null, 2).split(`
24
+ `);
25
+ for (let r = 0; r < o.length; r++) o[r] = " " + o[r];
26
+ return o;
27
+ }
28
+ function Oe(e, n, t) {
29
+ const o = JSON.stringify({ type: "FeatureCollection", metadata: { schemas: e, groups: n }, features: [] }, null, 2);
30
+ return (t ? o : o.slice(0, -3)).split(`
31
+ `);
32
+ }
33
+ const Lt = [" ]", "}"];
34
+ function Ne(e, n, t = []) {
35
+ for (let o = 0; o < e.length; o++) {
36
+ const r = n(e[o]);
37
+ for (let s = 0; s < r.length; s++) t.push(r[s]);
38
+ o < e.length - 1 && (t[t.length - 1] += ",");
39
+ }
40
+ return t;
41
+ }
42
+ function rt(e, n, t, o) {
43
+ const r = Oe(n, t, e.length === 0), s = { features: e, counts: e.map((g) => o(g).length), headerLines: r.length, schemas: n, groups: t };
44
+ if (!e.length) return { text: ee.of(r), map: s };
45
+ const l = Ne(e, o, r);
46
+ return l.push(...Lt), { text: ee.of(l), map: s };
47
+ }
48
+ function* Pn(e, n, t, o) {
49
+ if (yield Oe(n, t, e.length === 0), !!e.length) {
50
+ for (let r = 0; r < e.length; r++) {
51
+ const s = o(e[r]);
52
+ if (r === e.length - 1) {
53
+ yield s;
54
+ break;
55
+ }
56
+ const l = s.slice();
57
+ l[l.length - 1] += ",", yield l;
58
+ }
59
+ yield Lt;
60
+ }
61
+ }
62
+ function jn(e, n, t, o) {
63
+ return { features: e, counts: e.map((r) => o(r).length), headerLines: Oe(n, t, e.length === 0).length, schemas: n, groups: t };
64
+ }
65
+ const _n = (e, n) => e === n || e.length === n.length && e.every((t, o) => t === n[o]);
66
+ function pe(e) {
67
+ const n = new Array(e.counts.length);
68
+ let t = e.headerLines + 1;
69
+ for (let o = 0; o < e.counts.length; o++)
70
+ n[o] = t, t += e.counts[o];
71
+ return n;
72
+ }
73
+ function Jn(e, n) {
74
+ let t = e.headerLines + 1;
75
+ for (let o = 0; o < e.counts.length; o++) {
76
+ if (n < t) return -1;
77
+ if (n < t + e.counts[o]) return o;
78
+ t += e.counts[o];
79
+ }
80
+ return -1;
81
+ }
82
+ function Wn(e, n, t, o, r, s) {
83
+ const l = n.features;
84
+ if (!l.length || !t.length) return null;
85
+ const g = pe(n), v = (c) => c === l.length - 1, E = (c) => e.line(g[c]).from, i = (c) => e.line(g[c] + n.counts[c] - 1).to - (v(c) ? 0 : 1), p = [];
86
+ let O = n.headerLines;
87
+ if (o !== n.schemas || r !== n.groups) {
88
+ const c = Oe(o, r, !1);
89
+ p.push({ from: 0, to: e.line(n.headerLines).to, insert: ee.of(c) }), O = c.length;
90
+ }
91
+ let w = 0;
92
+ const H = Math.min(l.length, t.length);
93
+ for (; w < H && l[w] === t[w]; ) w++;
94
+ let I = 0;
95
+ for (; I < H - w && l[l.length - 1 - I] === t[t.length - 1 - I]; ) I++;
96
+ const h = l.length - I, R = t.length - I, _ = n.counts.slice(0, w);
97
+ if (h - w === R - w)
98
+ for (let c = w; c < h; c++) {
99
+ if (l[c] === t[c] || _n(s(l[c]), s(t[c]))) {
100
+ _.push(n.counts[c]);
101
+ continue;
102
+ }
103
+ p.push({ from: E(c), to: i(c), insert: ee.of(s(t[c])) }), _.push(s(t[c]).length);
104
+ }
105
+ else {
106
+ const c = t.slice(w, R);
107
+ for (const b of c) _.push(s(b).length);
108
+ if (h > w && c.length)
109
+ p.push({ from: E(w), to: i(h - 1), insert: ee.of(Ne(c, s)) });
110
+ else if (h > w)
111
+ w > 0 ? p.push({ from: i(w - 1), to: i(h - 1) }) : p.push({ from: E(0), to: E(h) });
112
+ else {
113
+ const b = Ne(c, s);
114
+ w > 0 ? p.push({ from: i(w - 1), insert: ee.of([",", ...b]) }) : (b[b.length - 1] += ",", b.push(""), p.push({ from: E(0), insert: ee.of(b) }));
115
+ }
116
+ }
117
+ for (let c = h; c < l.length; c++) _.push(n.counts[c]);
118
+ return { changes: p, map: { features: t, counts: _, headerLines: O, schemas: o, groups: r } };
119
+ }
120
+ const zn = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection"], Nt = (e) => {
121
+ const n = e;
122
+ return !n || typeof n != "object" || !zn.includes(n.type) ? !1 : n.type === "GeometryCollection" ? Array.isArray(n.geometries) && n.geometries.every(Nt) : Array.isArray(n.coordinates);
123
+ };
124
+ function ke(e) {
125
+ return !!e && typeof e == "object" && e.type === "Feature" && Nt(e.geometry);
126
+ }
127
+ function st(e) {
128
+ return !e || typeof e != "object" || Array.isArray(e) ? 'Expected a feature: { "type": "Feature", … }' : e.type !== "Feature" ? 'A feature needs "type": "Feature"' : 'A feature needs a geometry with a valid "type" and "coordinates"';
129
+ }
130
+ function ct(e) {
131
+ const n = e.length;
132
+ let t = 0;
133
+ const o = (i, p = t) => {
134
+ throw new it(p, i);
135
+ }, r = () => {
136
+ for (; t < n; t++) {
137
+ const i = e.charCodeAt(t);
138
+ if (i !== 32 && i !== 10 && i !== 13 && i !== 9) break;
139
+ }
140
+ }, s = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/y, l = '"\\/bfnrt', g = () => {
141
+ const i = t++;
142
+ for (; ; ) {
143
+ t >= n && o("Missing a closing quote", i);
144
+ const p = e.charCodeAt(t);
145
+ if (p === 34) {
146
+ t++;
147
+ return;
148
+ }
149
+ if (p === 92) {
150
+ const O = e[t + 1];
151
+ O === "u" && /^[0-9a-fA-F]{4}$/.test(e.slice(t + 2, t + 6)) ? t += 6 : O !== void 0 && l.includes(O) ? t += 2 : o("Invalid escape in a string (a backslash must be doubled)");
152
+ } else p < 32 ? o(p === 10 ? "Missing a closing quote" : "Control character in a string", p === 10 ? i : t) : t++;
153
+ }
154
+ }, v = (i, p) => {
155
+ t++;
156
+ for (let O = 0; ; O++) {
157
+ r();
158
+ let w = 0;
159
+ for (; e[t] === ","; )
160
+ t++, w++, r();
161
+ if (t >= n && o(`Missing a closing ${i}`), e[t] === i) {
162
+ t++;
163
+ return;
164
+ }
165
+ O && !w && o(`Expected a comma or a closing ${i}`), p();
166
+ }
167
+ }, E = () => {
168
+ r();
169
+ const i = e[t];
170
+ if (i === void 0) o("Expected a value, the text ends here");
171
+ else if (i === "{")
172
+ v("}", () => {
173
+ e[t] !== '"' && o("Expected a property name in double quotes"), g(), r(), e[t] !== ":" && o("Expected a colon after the property name"), t++, E();
174
+ });
175
+ else if (i === "[") v("]", E);
176
+ else if (i === '"') g();
177
+ else if (i === "-" || i >= "0" && i <= "9") {
178
+ s.lastIndex = t;
179
+ const p = s.exec(e);
180
+ p || o("Invalid number"), t += p[0].length;
181
+ } else {
182
+ const p = ["true", "false", "null"].find((O) => e.startsWith(O, t));
183
+ p || o("Expected a value (text needs double quotes)"), t += p.length;
184
+ }
185
+ };
186
+ try {
187
+ if (!e.trim()) return null;
188
+ for (E(), r(); e[t] === ","; )
189
+ t++, r();
190
+ return t < n && o("Unexpected text after the end"), null;
191
+ } catch (i) {
192
+ return i instanceof it ? { pos: i.pos, message: i.message } : null;
193
+ }
194
+ }
195
+ class it {
196
+ constructor(n, t) {
197
+ this.pos = n, this.message = t;
198
+ }
199
+ }
200
+ function Hn(e, n, t, o) {
201
+ const r = n.features.length;
202
+ if (!r) return { kind: "full" };
203
+ const s = pe(n), l = (c) => e.line(s[c]).from, g = (c) => e.line(s[c] + n.counts[c] - 1).to, v = (c) => g(c) - (c === r - 1 ? 0 : 1), E = (c) => {
204
+ const b = e.lineAt(c).number;
205
+ let x = 0, L = r - 1;
206
+ for (; x < L; ) {
207
+ const m = x + L + 1 >> 1;
208
+ s[m] <= b ? x = m : L = m - 1;
209
+ }
210
+ return x;
211
+ }, i = [];
212
+ let p = !1;
213
+ if (t.iterChangedRanges((c, b) => {
214
+ if (p) return;
215
+ if (c < l(0) || b > g(r - 1)) {
216
+ p = !0;
217
+ return;
218
+ }
219
+ let x = E(c), L = Math.max(x, E(b));
220
+ c > v(x) && (L === x ? L = x + 1 : x++), b > v(L) && L < r - 1 && L++;
221
+ const m = i[i.length - 1];
222
+ m && x <= m[1] ? m[1] = Math.max(m[1], L) : i.push([x, L]);
223
+ }), p || !i.length) return { kind: "full" };
224
+ const O = n.features.slice(), w = n.counts.slice(), H = [];
225
+ let I = !1, h = null;
226
+ for (let c = i.length - 1; c >= 0; c--) {
227
+ const [b, x] = i[c], L = t.mapPos(l(b), -1), m = t.mapPos(v(x), 1), D = ze("[" + o.sliceString(L, m) + "]");
228
+ if (!Array.isArray(D) || !D.every(ke)) {
229
+ h = { from: L, to: m };
230
+ continue;
231
+ }
232
+ h || (O.splice(b, x - b + 1, ...D), D.length === 1 ? w.splice(b, x - b + 1, o.lineAt(m).number - o.lineAt(L).number + 1) : D.length ? I = !0 : w.splice(b, x - b + 1), H[c] = D.length);
233
+ }
234
+ if (h) return { kind: "invalid", ...h };
235
+ const R = [];
236
+ let _ = 0;
237
+ return i.forEach(([c, b], x) => {
238
+ const L = c + _;
239
+ for (let m = L - 1; m <= L + H[x]; m++) R.push(m);
240
+ _ += H[x] - (b - c + 1);
241
+ }), { kind: "ok", features: O, counts: I ? null : w, around: R, runs: i.map(([c, b], x) => ({ i: c, j: b, length: H[x] })) };
242
+ }
243
+ function Ot(e, n, t = 0) {
244
+ if (e === n) return null;
245
+ const o = Math.min(e.length, n.length);
246
+ let r = 0;
247
+ for (; r < o && e.charCodeAt(r) === n.charCodeAt(r); ) r++;
248
+ let s = 0;
249
+ for (; s < o - r && e.charCodeAt(e.length - 1 - s) === n.charCodeAt(n.length - 1 - s); ) s++;
250
+ return { from: t + r, to: t + e.length - s, insert: n.slice(r, n.length - s) };
251
+ }
252
+ function Bn(e, n, t, o, r, s, l) {
253
+ const g = n.features.length, v = pe(n), E = (h) => e.line(v[h]).from, i = (h) => e.line(v[h] + n.counts[h] - 1).to, p = [];
254
+ let O = 0;
255
+ for (const h of r) {
256
+ const R = p[p.length - 1];
257
+ R && h.i === R.j + 1 ? (R.j = h.j, R.length += h.length) : p.push({ ...h, at: h.i + O }), O += h.length - (h.j - h.i + 1);
258
+ }
259
+ const w = [], H = [];
260
+ let I = 0;
261
+ for (const { i: h, j: R, at: _, length: c } of p) {
262
+ for (; I < h; I++) H.push(n.counts[I]);
263
+ I = R + 1;
264
+ const b = s.slice(_, _ + c);
265
+ for (const F of b) H.push(l(F).length);
266
+ const x = h > 0, L = R < g - 1, m = t.mapPos(x ? i(h - 1) - 1 : E(0) - 1, -1), D = t.mapPos(L ? E(R + 1) : i(g - 1) + 1, 1), le = c ? (x ? "," : "") + `
267
+ ` + Ne(b, l).join(`
268
+ `) + (L ? "," : "") + `
269
+ ` : (x && L ? "," : "") + `
270
+ `, ae = Ot(o.sliceString(m, D), le, m);
271
+ ae && w.push(ae);
272
+ }
273
+ for (; I < g; I++) H.push(n.counts[I]);
274
+ return { changes: w, counts: H };
275
+ }
276
+ function Gn(e, n, t, o) {
277
+ const r = t.length;
278
+ if (!r) return null;
279
+ const s = pe({ headerLines: n, counts: t }), l = [];
280
+ for (const g of o) {
281
+ if (g < 0 || g >= r) continue;
282
+ const v = s[g], E = v + t[g] - 1;
283
+ if (E + 1 > e.lines || e.line(v).text !== " {") return null;
284
+ const i = e.line(E);
285
+ if (g < r - 1) {
286
+ if (i.text !== " },") return null;
287
+ continue;
288
+ }
289
+ if (e.line(E + 1).text !== " ]") return null;
290
+ if (i.text === " },") l.push({ from: i.to - 1, to: i.to + 1, insert: `
291
+ ` });
292
+ else if (i.text !== " }") return null;
293
+ }
294
+ return l;
295
+ }
296
+ function Un(e, n) {
297
+ const t = [];
298
+ e.iterChangedRanges((r, s) => {
299
+ t.push([r, s]);
300
+ });
301
+ let o = !1;
302
+ return n.iterChangedRanges((r, s) => {
303
+ o || (o = t.some(([l, g]) => l <= s && r <= g));
304
+ }), o;
305
+ }
306
+ function je(e, n, t = 1) {
307
+ let o = 0, r = t, s = -1, l = -1;
308
+ for (const g = e.iterLines(t); !g.next().done; r++) {
309
+ const v = g.value;
310
+ if (v === " {") {
311
+ if (s !== -1) return { start: s, end: r - 1 };
312
+ o++ === n && (s = r);
313
+ } else s !== -1 && l === -1 && (v === " }" || v === " },") && (l = r);
314
+ }
315
+ return s === -1 ? null : { start: s, end: l === -1 ? s : l };
316
+ }
317
+ function ze(e) {
318
+ if (!e.trim()) return { type: "FeatureCollection", features: [] };
319
+ try {
320
+ return JSON.parse(e);
321
+ } catch {
322
+ }
323
+ const n = [];
324
+ let t = 0, o = !1, r = "";
325
+ for (let s = 0; s < e.length; s++) {
326
+ const l = e[s];
327
+ if (o) {
328
+ l === "\\" ? s++ : l === '"' && (o = !1);
329
+ continue;
330
+ }
331
+ if (l === '"') {
332
+ o = !0, r = l;
333
+ continue;
334
+ }
335
+ if (!(l === " " || l === `
336
+ ` || l === "\r" || l === " ")) {
337
+ if (l === ",") {
338
+ let g = s + 1;
339
+ for (; g < e.length && /\s/.test(e[g]); ) g++;
340
+ const v = e[g];
341
+ if (r === "[" || r === "{" || r === "," || v === "]" || v === "}" || v === "," || v === void 0) {
342
+ n.push(e.slice(t, s)), t = s + 1;
343
+ continue;
344
+ }
345
+ }
346
+ r = l;
347
+ }
348
+ }
349
+ n.push(e.slice(t));
350
+ try {
351
+ return JSON.parse(n.join(""));
352
+ } catch {
353
+ return null;
354
+ }
355
+ }
356
+ const lt = "elm_code_win_size", at = 100, ut = 2e6, Yn = {
357
+ syntax: (e) => `Invalid JSON at line ${e}`,
358
+ feature: (e) => `Invalid feature at line ${e}`,
359
+ collection: () => "Not a GeoJSON FeatureCollection"
360
+ }, _e = /* @__PURE__ */ new WeakMap();
361
+ function ft(e, n, t) {
362
+ n = Math.max(0, Math.min(n, e.length));
363
+ const o = e.lineAt(n);
364
+ let r = n;
365
+ for (; r < o.to && (r === n || !/[\s,:{}[\]]/.test(o.text[r - o.from])); ) r++;
366
+ return { kind: "syntax", from: n, to: r, message: t };
367
+ }
368
+ function Je(e, n, t, o) {
369
+ const r = e.line(Math.max(1, Math.min(n, e.lines)));
370
+ return { kind: t, from: r.from + (r.text.length - r.text.trimStart().length), to: r.to, message: o };
371
+ }
372
+ const He = Mn.define(), $n = Mt.line({ class: "cm-feature-highlight" }), Me = Cn.define({
373
+ create: () => null,
374
+ update(e, n) {
375
+ for (const t of n.effects) if (t.is(He)) return t.value;
376
+ return e && n.docChanged ? { from: n.changes.mapPos(e.from, 1), to: n.changes.mapPos(e.to, -1) } : e;
377
+ }
378
+ });
379
+ function dt(e) {
380
+ const n = e.state.field(Me);
381
+ if (!n) return Mt.none;
382
+ const t = e.state.doc, o = new En();
383
+ let r = 0;
384
+ for (const { from: s, to: l } of e.visibleRanges) {
385
+ const g = Math.min(l, n.to);
386
+ for (let v = Math.max(s, n.from, r); v <= g; ) {
387
+ const E = t.lineAt(v);
388
+ o.add(E.from, E.from, $n), v = r = E.to + 1;
389
+ }
390
+ }
391
+ return o.finish();
392
+ }
393
+ const qn = [Me, wn.fromClass(class {
394
+ constructor(e) {
395
+ nt(this, "decorations");
396
+ this.decorations = dt(e);
397
+ }
398
+ update(e) {
399
+ (e.docChanged || e.viewportChanged || e.startState.field(Me) !== e.state.field(Me)) && (this.decorations = dt(e.view));
400
+ }
401
+ }, { decorations: (e) => e.decorations })], Ee = Sn.define(), de = [Ee.of(!0), Ln.addToHistory.of(!1)], We = 5e3, ht = 12, Kn = 200, mt = 2e4;
402
+ function Dt(e, n) {
403
+ if (!e) return 1;
404
+ if (e.type === "GeometryCollection") return e.geometries.reduce((o, r) => o + Dt(r, n), 0);
405
+ const t = (o) => {
406
+ if (!Array.isArray(o) || typeof o[0] == "number") return 1;
407
+ let r = 0;
408
+ for (const s of o)
409
+ if (r += t(s), r > n) break;
410
+ return r;
411
+ };
412
+ return t(e.coordinates);
413
+ }
414
+ const Le = () => {
415
+ const e = globalThis.scheduler;
416
+ return e != null && e.yield ? e.yield() : new Promise((n) => setTimeout(n, 0));
417
+ };
418
+ async function gt(e, n) {
419
+ const o = [];
420
+ for (let r = 0; r < e.length; r += 1048576)
421
+ o.push(e.sliceString(r, Math.min(e.length, r + 1048576))), o.length % 4 === 0 && await Le();
422
+ return new Blob(o, { type: n });
423
+ }
424
+ const Vn = ie.theme({
425
+ "&": { height: "100%", fontSize: "14px" },
426
+ "&.cm-focused": { outline: "none" },
427
+ ".cm-scroller": { fontFamily: "var(--elm-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace)", lineHeight: "1.65", overflow: "auto" }
428
+ }), pt = Et.highest(ie.theme({
429
+ "&": { backgroundColor: "transparent", color: "var(--elm-text, #262626)" },
430
+ ".cm-gutters": { backgroundColor: "transparent", color: "var(--elm-text-subtle, #a3a3a3)", borderRight: "1px solid var(--elm-border, #e5e5e5)" },
431
+ ".cm-activeLine": { backgroundColor: "rgb(0 0 0 / 0.03)" },
432
+ ".cm-activeLineGutter": { backgroundColor: "rgb(0 0 0 / 0.04)", color: "var(--elm-text-secondary, #525252)" },
433
+ ".cm-cursor, .cm-dropCursor": { borderLeftColor: "var(--elm-text, #262626)" },
434
+ "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: "var(--elm-border, #e5e5e5)" },
435
+ ".cm-selectionMatch": { backgroundColor: "rgb(0 0 0 / 0.06)" },
436
+ "&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": { backgroundColor: "rgb(0 0 0 / 0.1)", outline: "none" },
437
+ ".cm-searchMatch": { backgroundColor: "rgb(0 0 0 / 0.08)", outline: "1px solid rgb(0 0 0 / 0.15)" },
438
+ ".cm-foldPlaceholder": { backgroundColor: "var(--elm-surface-hover, #f5f5f5)", border: "1px solid var(--elm-border, #e5e5e5)", color: "var(--elm-text-muted, #737373)" },
439
+ ".cm-tooltip, .cm-panels": { backgroundColor: "var(--elm-surface-raised, #ffffff)", border: "1px solid var(--elm-border, #e5e5e5)" },
440
+ ".cm-feature-highlight": { backgroundColor: "rgb(0 0 0 / 0.05)" }
441
+ })), bt = [On, Et.highest(ie.theme({
442
+ "&": { backgroundColor: "transparent", color: "var(--elm-text, #e5e5e5)" },
443
+ ".cm-gutters": { backgroundColor: "transparent", color: "var(--elm-text-subtle, #737373)", borderRight: "1px solid var(--elm-border, #404040)" },
444
+ ".cm-activeLine": { backgroundColor: "rgb(255 255 255 / 0.04)" },
445
+ ".cm-activeLineGutter": { backgroundColor: "rgb(255 255 255 / 0.06)", color: "var(--elm-text-secondary, #d4d4d4)" },
446
+ ".cm-cursor, .cm-dropCursor": { borderLeftColor: "var(--elm-text, #e5e5e5)" },
447
+ "&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: "var(--elm-border, #404040)" },
448
+ ".cm-selectionMatch": { backgroundColor: "rgb(255 255 255 / 0.1)" },
449
+ "&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": { backgroundColor: "rgb(255 255 255 / 0.15)", outline: "none" },
450
+ ".cm-searchMatch": { backgroundColor: "rgb(255 255 255 / 0.12)", outline: "1px solid rgb(255 255 255 / 0.2)" },
451
+ ".cm-foldPlaceholder": { backgroundColor: "var(--elm-surface-raised, #262626)", border: "1px solid var(--elm-border, #404040)", color: "var(--elm-text-muted, #a3a3a3)" },
452
+ ".cm-tooltip, .cm-panels": { backgroundColor: "var(--elm-surface-raised, #262626)", border: "1px solid var(--elm-border, #404040)" },
453
+ ".cm-feature-highlight": { backgroundColor: "rgb(255 255 255 / 0.07)" }
454
+ }, { dark: !0 }))], yt = 320, vt = 240, xt = 520, wt = 480, Se = `flex ${on}`;
455
+ function yo({ onClose: e }) {
456
+ const { uiStore: n } = Ct(), t = St(), [o, r] = ce(Xt()), [s, l] = ce(() => !qt.has(n));
457
+ return /* @__PURE__ */ M(Xn, { onClose: e, autoFocus: s, docked: o, onToggleDock: () => {
458
+ r(!o), l(!0), kt(Zt, o ? "0" : "1", t);
459
+ } }, String(o));
460
+ }
461
+ function Xn({ onClose: e, autoFocus: n, docked: t, onToggleDock: o }) {
462
+ var Ve;
463
+ const r = (Ve = Yt(Kt)) == null ? void 0 : Ve.emit, { pos: s, onHandleMouseDown: l } = yn("elm_code_win", { x: 100, y: 100 }), g = St(), { zIndex: v, focus: E } = vn(), { dataStore: i, uiStore: p } = Ct(), O = we((a) => a.features), w = we((a) => a.schemas), H = we((a) => a.groups), I = we((a) => a.selectedIds), h = Vt(), R = ln(), _ = Qt(t), c = B(null), b = B(null), x = B(new ot()), L = B(new ot()), m = B(null), D = B(null), le = B(null), ae = B(() => {
464
+ }), F = B(null), Be = B(h), he = B(null), Ge = B(null), De = B(null), Ue = Rn(), Ye = B(Ue);
465
+ Ye.current = Ue;
466
+ const [ne, At] = ce(!0), [It, Tt] = ce(0), [Ae, $e] = ce(!1), [be, Rt] = ce(null), [ye, Ft] = ce(() => {
467
+ try {
468
+ const a = an(lt, g);
469
+ return a ? JSON.parse(a) : { w: xt, h: wt };
470
+ } catch {
471
+ return { w: xt, h: wt };
472
+ }
473
+ }), Pt = $t((a, S) => {
474
+ kt(lt, JSON.stringify({ w: a, h: S }), g);
475
+ }, [g]);
476
+ ge(() => {
477
+ Be.current = h;
478
+ }, [h]), en(he, t), tn(he, !0, e, v, { topWindow: !t });
479
+ function jt(a) {
480
+ a.preventDefault(), a.stopPropagation();
481
+ const S = a.clientX, $ = a.clientY, A = ye.w, X = ye.h, q = cn("se-resize");
482
+ function G(K) {
483
+ const P = Math.max(yt, Math.min(window.innerWidth * 0.9, A + K.clientX - S)), Q = Math.max(vt, Math.min(window.innerHeight * 0.85, X + K.clientY - $));
484
+ Ft({ w: P, h: Q });
485
+ }
486
+ function U() {
487
+ q(), document.removeEventListener("mousemove", G), document.removeEventListener("mouseup", U);
488
+ const K = he.current;
489
+ K && Pt(K.offsetWidth, K.offsetHeight);
490
+ }
491
+ document.addEventListener("mousemove", G), document.addEventListener("mouseup", U);
492
+ }
493
+ ge(() => {
494
+ if (!c.current) return;
495
+ let a = !1, S = !1, $ = !0, A = !1, X = null, q = null;
496
+ const G = /* @__PURE__ */ new WeakMap(), U = (u) => {
497
+ let d = G.get(u);
498
+ return d || (d = Fn(u), G.set(u, d)), d;
499
+ };
500
+ let K = 0;
501
+ function P(u) {
502
+ S || !u && !X || (X = u, N.dispatch(In(N.state, u ? [{ from: u.from, to: u.to, severity: "error", message: u.message }] : [])), Rt(u && { kind: u.kind, line: N.state.doc.lineAt(u.from).number }));
503
+ }
504
+ function Q() {
505
+ A = !1, q = null, P(null);
506
+ }
507
+ function ve(u, d) {
508
+ const f = N.state.doc, C = "[" + f.sliceString(u, d) + "]", y = ct(C), k = y ? null : ze(C);
509
+ if (!Array.isArray(k)) return ft(f, u + (y ? y.pos - 1 : 0), (y == null ? void 0 : y.message) ?? "Invalid JSON");
510
+ const W = Math.max(0, k.findIndex((Y) => !ke(Y))), j = je(f, W, f.lineAt(u).number);
511
+ return Je(f, j ? j.start : f.lineAt(u).number, "feature", st(k[W]));
512
+ }
513
+ function zt(u, d) {
514
+ const f = N.state.doc;
515
+ if (!d) {
516
+ const k = ct(u);
517
+ return ft(f, k ? k.pos : 0, (k == null ? void 0 : k.message) ?? "Invalid JSON");
518
+ }
519
+ if (d.type !== "FeatureCollection" || !Array.isArray(d.features))
520
+ return Je(f, 1, "collection", 'Expected { "type": "FeatureCollection", "features": [ … ] }');
521
+ const C = d.features.findIndex((k) => !ke(k)), y = je(f, C);
522
+ return Je(f, y ? y.start : 1, "feature", st(d.features[C]));
523
+ }
524
+ function me(u = !1) {
525
+ const d = m.current, f = D.current, C = i.getState(), y = C.features;
526
+ if (d && d.features !== y) return;
527
+ let k = null;
528
+ if (d && f) {
529
+ const z = Hn(f.base, d, f.changes, N.state.doc);
530
+ if (z.kind === "ok" && z.features.length) {
531
+ const Re = z.counts && Gn(N.state.doc, d.headerLines, z.counts, z.around);
532
+ C.updateFeaturesFromEditor({ type: "FeatureCollection", features: z.features });
533
+ const fe = i.getState().features;
534
+ if (fe === y) {
535
+ P(null);
536
+ return;
537
+ }
538
+ if (Q(), D.current = null, le.current = fe, Re)
539
+ Re.length && N.dispatch({ changes: Re, annotations: Ee.of(!0) }), m.current = { ...d, features: fe, counts: z.counts };
540
+ else {
541
+ const Fe = Bn(f.base, d, f.changes, N.state.doc, z.runs, fe, U);
542
+ Fe.changes.length && N.dispatch({ changes: Fe.changes, annotations: de }), m.current = { ...d, features: fe, counts: Fe.counts };
543
+ }
544
+ Xe(fe);
545
+ return;
546
+ }
547
+ if (z.kind === "invalid" && (k = z, N.state.doc.length > ut)) {
548
+ P(ve(z.from, z.to));
549
+ return;
550
+ }
551
+ }
552
+ const W = N.state.doc, j = W.length > ut && !u ? W.length / 1e4 - (performance.now() - K) : 0;
553
+ if (j > 0) {
554
+ F.current = setTimeout(me, j);
555
+ return;
556
+ }
557
+ const Y = W.toString(), T = ze(Y);
558
+ if ((T == null ? void 0 : T.type) !== "FeatureCollection" || !Array.isArray(T.features) || !T.features.every(ke)) {
559
+ P(k ? ve(k.from, k.to) : zt(Y, T));
560
+ return;
561
+ }
562
+ C.updateFeaturesFromEditor(T);
563
+ const te = i.getState().features;
564
+ if (te === y) {
565
+ P(null);
566
+ return;
567
+ }
568
+ Q(), D.current = null, le.current = te;
569
+ const { schemas: oe, groups: Z } = i.getState(), { text: V, map: re } = rt(te, oe, Z, U);
570
+ if (V.eq(W)) m.current = re;
571
+ else if (JSON.stringify(T.metadata) === JSON.stringify({ schemas: oe, groups: Z })) {
572
+ const z = Ot(Y, V.toString());
573
+ z && N.dispatch({ changes: z, annotations: de }), m.current = re;
574
+ } else m.current = null;
575
+ Xe(te);
576
+ }
577
+ function Xe(u) {
578
+ const d = p.getState(), f = d.dialogState;
579
+ f.type === "edit" && !u.some((C) => C.id === f.featureId) && d.closeDialog();
580
+ }
581
+ const Ie = i.getState();
582
+ let J = _e.get(i) ?? null;
583
+ _e.delete(i), J && !J.map && !(J.store.features === Ie.features && J.store.schemas === Ie.schemas && J.store.groups === Ie.groups) && (J = null);
584
+ const N = new ie({
585
+ state: Pe.create({
586
+ doc: J ? J.doc : "",
587
+ extensions: [
588
+ Dn,
589
+ Nn(),
590
+ qn,
591
+ L.current.of(Pe.readOnly.of(!0)),
592
+ x.current.of(Be.current === "dark" ? bt : pt),
593
+ Vn,
594
+ ie.updateListener.of((u) => {
595
+ if (u.selectionSet && !u.docChanged && u.transactions.some((f) => f.isUserEvent("select.pointer"))) {
596
+ const f = u.state.selection.main, C = m.current;
597
+ if (f.empty && C && !D.current) {
598
+ const y = C.features[Jn(C, u.state.doc.lineAt(f.head).number)], { selectedIds: k, selectFeature: W } = i.getState();
599
+ y && !(k.length === 1 && k[0] === y.id) && (De.current = y.id, W(y.id), Ye.current(y));
600
+ }
601
+ }
602
+ let d = !1;
603
+ for (const f of u.transactions) {
604
+ if (!f.docChanged || f.annotation(Ee) || (d = !0, !m.current)) continue;
605
+ const C = D.current;
606
+ D.current = C ? { base: C.base, changes: C.changes.compose(f.changes) } : { base: f.startState.doc, changes: f.changes };
607
+ }
608
+ d && (A = !0, K = performance.now(), u.transactions.some((f) => f.docChanged && f.annotation(Ee)) && (m.current = null, D.current = null), F.current && clearTimeout(F.current), F.current = setTimeout(me, at));
609
+ })
610
+ ]
611
+ }),
612
+ parent: c.current
613
+ });
614
+ let Ze = !0;
615
+ const Qe = () => {
616
+ const u = Ze || p.getState().readonly;
617
+ u !== $ && ($ = u, N.dispatch({ effects: L.current.reconfigure(Pe.readOnly.of(u)) }));
618
+ }, et = (u) => {
619
+ Ze = u, Qe();
620
+ }, Ht = p.subscribe((u, d) => {
621
+ u.readonly !== d.readonly && Qe();
622
+ });
623
+ async function Bt(u, d, f) {
624
+ F.current && clearTimeout(F.current), D.current = null, m.current = null, A = !1, P(null);
625
+ let C = 0, y = [];
626
+ const k = async () => {
627
+ for (let j = 0; j < y.length; j += mt) {
628
+ const Y = y.slice(j, j + mt), T = N.state.doc;
629
+ if (N.dispatch({
630
+ changes: C++ ? { from: T.length, insert: ee.of(["", ...Y]) } : { from: 0, to: T.length, insert: ee.of(Y) },
631
+ annotations: de
632
+ }), await Le(), a) return !1;
633
+ }
634
+ return y = [], !0;
635
+ };
636
+ let W = performance.now();
637
+ for (const j of Pn(u, d, f, U)) {
638
+ for (const Y of j) y.push(Y);
639
+ if (C < 2 ? !C || y.length > Kn : performance.now() - W > ht) {
640
+ if (!await k()) return !1;
641
+ W = performance.now();
642
+ }
643
+ }
644
+ return await k() ? (m.current = jn(u, d, f, U), !0) : !1;
645
+ }
646
+ let xe = !1, Te = !1;
647
+ async function tt() {
648
+ if (xe) {
649
+ Te = !0;
650
+ return;
651
+ }
652
+ xe = !0;
653
+ let u = !1;
654
+ try {
655
+ do {
656
+ Te = !1;
657
+ const { features: d, schemas: f, groups: C } = i.getState(), y = m.current, k = y ?? q;
658
+ if (k && k.features === d && k.schemas === f && k.groups === C) continue;
659
+ q = null;
660
+ const W = d.filter((V) => !G.has(V));
661
+ let j = 0;
662
+ for (const V of W)
663
+ if (j += Dt(V.geometry, We), j > We) break;
664
+ const Y = !y || !y.features.length || !d.length;
665
+ if (j > We) {
666
+ if (u = !0, et(!0), Y) {
667
+ if (!await Bt(d, f, C)) return;
668
+ continue;
669
+ }
670
+ if (await Le(), a) return;
671
+ let V = performance.now();
672
+ for (const re of W)
673
+ if (U(re), performance.now() - V > ht) {
674
+ if (await Le(), a) return;
675
+ V = performance.now();
676
+ }
677
+ }
678
+ const T = D.current, te = T ? T.base : N.state.doc, oe = y && !Y ? Wn(te, y, d, f, C, U) : null, Z = oe && kn.of(oe.changes, te.length);
679
+ if (Z && !T)
680
+ N.dispatch({ changes: Z, annotations: de }), m.current = oe.map;
681
+ else if (Z && T && !Un(Z, T.changes))
682
+ N.dispatch({ changes: Z.map(T.changes), annotations: de }), D.current = { base: Z.apply(te), changes: T.changes.map(Z, !0) }, m.current = oe.map, F.current && clearTimeout(F.current), F.current = setTimeout(me, at);
683
+ else {
684
+ F.current && clearTimeout(F.current), D.current = null;
685
+ const { text: V, map: re } = rt(d, f, C, U);
686
+ N.dispatch({ changes: { from: 0, to: N.state.doc.length, insert: V }, annotations: de }), m.current = re, A = !1, P(null);
687
+ }
688
+ } while (Te);
689
+ } finally {
690
+ xe = !1, a || (et(!1), At(!1), u && Tt((d) => d + 1));
691
+ }
692
+ }
693
+ return b.current = N, m.current = J ? J.map : null, D.current = J ? J.edit : null, J && (A = !0, q = J.map ? null : J.store, F.current = setTimeout(me, 0)), ae.current = () => {
694
+ tt();
695
+ }, n && N.focus(), tt(), () => {
696
+ if (Ht(), ae.current = () => {
697
+ }, S = !0, F.current && clearTimeout(F.current), A && !xe && me(!0), a = !0, A) {
698
+ const { features: u, schemas: d, groups: f } = i.getState();
699
+ _e.set(i, { doc: N.state.doc, map: m.current, edit: D.current, store: { features: u, schemas: d, groups: f } });
700
+ }
701
+ N.destroy(), b.current = null;
702
+ };
703
+ }, []), ge(() => {
704
+ if (O === le.current) {
705
+ le.current = null;
706
+ return;
707
+ }
708
+ ae.current();
709
+ }, [O, w, H]), ge(() => {
710
+ const a = b.current, S = h === "dark" ? bt : pt;
711
+ !a || x.current.get(a.state) === S || a.dispatch({ effects: x.current.reconfigure(S) });
712
+ }, [h]), ge(() => {
713
+ const a = b.current;
714
+ if (!a || ne) return;
715
+ const S = I[0] ?? null, $ = S !== Ge.current;
716
+ Ge.current = S;
717
+ const A = De.current === S;
718
+ if (De.current = null, S === null) {
719
+ a.dispatch({ effects: He.of(null) });
720
+ return;
721
+ }
722
+ const X = a.state.doc, q = D.current ? null : m.current;
723
+ let G;
724
+ if (q) {
725
+ const P = q.features.findIndex((ve) => ve.id === S);
726
+ if (P === -1) return;
727
+ const Q = pe(q)[P];
728
+ G = { start: Q, end: Q + q.counts[P] - 1 };
729
+ } else {
730
+ const P = O.findIndex((Q) => Q.id === S);
731
+ if (P === -1) return;
732
+ G = je(X, P);
733
+ }
734
+ if (!G || G.start > X.lines) return;
735
+ const U = X.line(G.start).from, K = $ && !A ? [ie.scrollIntoView(U, { y: "center" })] : [];
736
+ a.dispatch({
737
+ effects: [He.of({ from: U, to: X.line(Math.min(G.end, X.lines)).to }), ...K]
738
+ });
739
+ }, [I, O, ne, It]), Tn(he, !t);
740
+ function _t() {
741
+ const a = b.current;
742
+ if (!a) return;
743
+ const S = a.state.doc;
744
+ Promise.resolve().then(() => typeof ClipboardItem < "u" ? navigator.clipboard.write([new ClipboardItem({ "text/plain": gt(S, "text/plain") })]) : navigator.clipboard.writeText(S.toString())).then(() => {
745
+ $e(!0), setTimeout(() => $e(!1), 2e3);
746
+ }, (A) => r == null ? void 0 : r(sn(A)));
747
+ }
748
+ function Jt() {
749
+ const a = b.current;
750
+ if (!a) return;
751
+ let S = -1;
752
+ An(a.state, ($, A) => {
753
+ S < 0 && (S = A);
754
+ }), !(S < 0) && (a.dispatch({ selection: { anchor: S }, effects: ie.scrollIntoView(S, { y: "center" }) }), a.focus());
755
+ }
756
+ async function Wt() {
757
+ const a = b.current;
758
+ if (!a) return;
759
+ const S = await gt(a.state.doc, "application/geo+json"), $ = URL.createObjectURL(S), A = document.createElement("a");
760
+ A.href = $, A.download = "features.geojson", document.body.appendChild(A), A.click(), document.body.removeChild(A), URL.revokeObjectURL($);
761
+ }
762
+ const qe = O.length, ue = 16, Ke = /* @__PURE__ */ se(
763
+ "div",
764
+ {
765
+ ref: he,
766
+ onMouseDownCapture: t ? void 0 : E,
767
+ role: t ? "region" : "dialog",
768
+ "aria-label": "GeoJSON inspector",
769
+ [rn]: "",
770
+ "aria-busy": ne || void 0,
771
+ "data-loading": ne || void 0,
772
+ "data-elm-code-docked": t || void 0,
773
+ className: t ? _.className : "fixed flex flex-col bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 shadow-elm-raised rounded-elm-window overflow-hidden",
774
+ style: t ? _.style : {
775
+ left: s.x,
776
+ top: s.y,
777
+ zIndex: v,
778
+ minWidth: yt,
779
+ minHeight: vt,
780
+ width: ye.w,
781
+ height: ye.h,
782
+ maxWidth: "90vw",
783
+ maxHeight: "85vh"
784
+ },
785
+ children: [
786
+ t && /* @__PURE__ */ M(
787
+ "div",
788
+ {
789
+ onMouseDown: _.onHandleMouseDown,
790
+ className: nn,
791
+ title: "Drag to resize panel"
792
+ }
793
+ ),
794
+ /* @__PURE__ */ se(
795
+ "div",
796
+ {
797
+ onMouseDown: t ? void 0 : l,
798
+ className: `flex items-center justify-between border-b border-elm-border flex-shrink-0 select-none ${t ? "px-3 py-1.5 bg-elm-surface-sunken" : "px-4 py-3"}`,
799
+ style: t ? void 0 : { cursor: "grab" },
800
+ children: [
801
+ /* @__PURE__ */ M("span", { className: t ? "text-xs font-medium text-elm-text-secondary" : "text-sm font-semibold text-(--elm-text,var(--color-gray-900)) dark:text-(--elm-text,var(--color-gray-100))", children: "GeoJSON" }),
802
+ /* @__PURE__ */ se("div", { className: `flex items-center gap-0.5 ${t ? "h-6" : ""}`, children: [
803
+ /* @__PURE__ */ se("span", { className: "text-xs text-elm-text-subtle mr-1.5", children: [
804
+ qe,
805
+ " feature",
806
+ qe !== 1 ? "s" : ""
807
+ ] }),
808
+ /* @__PURE__ */ M(Ce, { content: Ae ? "Copied" : "Copy", side: "bottom", children: /* @__PURE__ */ M(
809
+ "button",
810
+ {
811
+ onMouseDown: (a) => a.stopPropagation(),
812
+ onClick: _t,
813
+ disabled: ne,
814
+ "aria-label": Ae ? "Copied" : "Copy",
815
+ className: Se,
816
+ children: Ae ? /* @__PURE__ */ M(fn, { size: ue, className: "text-green-500" }) : /* @__PURE__ */ M(dn, { size: ue })
817
+ }
818
+ ) }),
819
+ /* @__PURE__ */ M(Ce, { content: "Download", side: "bottom", children: /* @__PURE__ */ M(
820
+ "button",
821
+ {
822
+ onMouseDown: (a) => a.stopPropagation(),
823
+ onClick: Wt,
824
+ disabled: ne,
825
+ "aria-label": "Download GeoJSON",
826
+ className: Se,
827
+ children: /* @__PURE__ */ M(hn, { size: ue })
828
+ }
829
+ ) }),
830
+ /* @__PURE__ */ M(Ce, { content: t ? "Undock" : "Dock to the side", side: "bottom", children: /* @__PURE__ */ M(
831
+ "button",
832
+ {
833
+ onMouseDown: (a) => a.stopPropagation(),
834
+ onClick: o,
835
+ "aria-label": t ? "Undock GeoJSON inspector" : "Dock GeoJSON inspector",
836
+ className: Se,
837
+ children: t ? /* @__PURE__ */ M(mn, { size: ue }) : /* @__PURE__ */ M(gn, { size: ue, className: "-scale-x-100" })
838
+ }
839
+ ) }),
840
+ t ? /* @__PURE__ */ M(Ce, { content: "Close", side: "bottom", children: /* @__PURE__ */ M("button", { onClick: e, "aria-label": "Close", className: Se, children: /* @__PURE__ */ M(pn, { size: ue }) }) }) : /* @__PURE__ */ M(xn, { onClick: e })
841
+ ] })
842
+ ]
843
+ }
844
+ ),
845
+ /* @__PURE__ */ se("div", { className: "relative flex-1 flex flex-col min-h-0", children: [
846
+ /* @__PURE__ */ M("div", { ref: c, className: "flex-1 overflow-hidden min-h-0" }),
847
+ ne && /* @__PURE__ */ M("div", { className: "absolute bottom-2 right-4 text-xs text-elm-text-subtle pointer-events-none", children: "Loading…" })
848
+ ] }),
849
+ /* @__PURE__ */ M("div", { role: "status", "aria-live": "polite", className: "flex-shrink-0", children: be && /* @__PURE__ */ se(
850
+ "button",
851
+ {
852
+ type: "button",
853
+ onClick: Jt,
854
+ title: "Go to the error",
855
+ "data-elm-inspector-problem": be.kind,
856
+ className: `flex w-full items-center gap-1.5 border-t border-elm-border py-1.5 text-left text-xs text-(--elm-text-secondary,var(--color-gray-600)) dark:text-(--elm-text-secondary,var(--color-gray-300)) hover:bg-(--elm-surface-hover,var(--color-gray-50)) dark:hover:bg-(--elm-surface-hover,color-mix(in_oklab,var(--color-gray-800)_60%,transparent)) ${t ? "px-3" : "pl-4 pr-6"}`,
857
+ children: [
858
+ /* @__PURE__ */ M(bn, { size: 14, className: "flex-shrink-0 text-elm-text-muted" }),
859
+ /* @__PURE__ */ se("span", { className: "min-w-0 truncate", children: [
860
+ Yn[be.kind](be.line),
861
+ " — no changes apply until it's fixed"
862
+ ] })
863
+ ]
864
+ }
865
+ ) }),
866
+ !t && /* @__PURE__ */ M(
867
+ "div",
868
+ {
869
+ onMouseDown: jt,
870
+ className: "absolute bottom-0 right-0 w-4 h-4 cursor-se-resize select-none",
871
+ style: { zIndex: 10 },
872
+ "aria-hidden": !0,
873
+ children: /* @__PURE__ */ M("svg", { width: "10", height: "10", viewBox: "0 0 10 10", className: "absolute bottom-1 right-1 text-elm-text-disabled", children: /* @__PURE__ */ M("path", { d: "M9 1L1 9M9 5L5 9", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) })
874
+ }
875
+ )
876
+ ]
877
+ }
878
+ );
879
+ return t ? Ke : un(
880
+ /* @__PURE__ */ M("div", { "data-elm-theme": h, style: R, children: Ke }),
881
+ document.body
882
+ );
883
+ }
884
+ export {
885
+ yo as default
886
+ };