@watergis/maplibre-gl-terradraw 0.8.5 → 1.0.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 (33) hide show
  1. package/dist/maplibre-gl-terradraw.es.js +661 -799
  2. package/dist/maplibre-gl-terradraw.es.js.map +1 -1
  3. package/dist/maplibre-gl-terradraw.umd.js +2 -2
  4. package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
  5. package/dist/types/constants/defaultControlOptions.d.ts +1 -1
  6. package/dist/types/constants/defaultControlOptions.d.ts.map +1 -1
  7. package/dist/types/constants/defaultMeasureControlOptions.d.ts +1 -1
  8. package/dist/types/constants/defaultMeasureControlOptions.d.ts.map +1 -1
  9. package/dist/types/constants/getDefaultModeOptions.d.ts +1 -1
  10. package/dist/types/constants/getDefaultModeOptions.d.ts.map +1 -1
  11. package/dist/types/constants/index.d.ts +5 -5
  12. package/dist/types/constants/index.d.ts.map +1 -1
  13. package/dist/types/controls/MaplibreMeasureControl.d.ts +2 -2
  14. package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
  15. package/dist/types/controls/MaplibreTerradrawControl.d.ts +1 -1
  16. package/dist/types/controls/MaplibreTerradrawControl.d.ts.map +1 -1
  17. package/dist/types/controls/index.d.ts +2 -2
  18. package/dist/types/controls/index.d.ts.map +1 -1
  19. package/dist/types/index.d.ts +3 -3
  20. package/dist/types/index.d.ts.map +1 -1
  21. package/dist/types/interfaces/MeasureControlMode.d.ts +1 -1
  22. package/dist/types/interfaces/MeasureControlMode.d.ts.map +1 -1
  23. package/dist/types/interfaces/MeasureControlOptions.d.ts +4 -4
  24. package/dist/types/interfaces/MeasureControlOptions.d.ts.map +1 -1
  25. package/dist/types/interfaces/ModeOptions.d.ts +1 -1
  26. package/dist/types/interfaces/ModeOptions.d.ts.map +1 -1
  27. package/dist/types/interfaces/TerradrawControlOptions.d.ts +6 -4
  28. package/dist/types/interfaces/TerradrawControlOptions.d.ts.map +1 -1
  29. package/dist/types/interfaces/TerradrawMode.d.ts +1 -1
  30. package/dist/types/interfaces/TerradrawMode.d.ts.map +1 -1
  31. package/dist/types/interfaces/index.d.ts +9 -9
  32. package/dist/types/interfaces/index.d.ts.map +1 -1
  33. package/package.json +26 -26
@@ -1,387 +1,34 @@
1
- var kt = Object.defineProperty;
2
- var Wt = (o, e, t) => e in o ? kt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var A = (o, e, t) => Wt(o, typeof e != "symbol" ? e + "" : e, t);
1
+ var Pt = Object.defineProperty;
2
+ var vt = (o, e, t) => e in o ? Pt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var A = (o, e, t) => vt(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  function M() {
5
5
  return M = Object.assign ? Object.assign.bind() : function(o) {
6
6
  for (var e = 1; e < arguments.length; e++) {
7
7
  var t = arguments[e];
8
- for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (o[i] = t[i]);
8
+ for (var i in t) ({}).hasOwnProperty.call(t, i) && (o[i] = t[i]);
9
9
  }
10
10
  return o;
11
- }, M.apply(this, arguments);
11
+ }, M.apply(null, arguments);
12
12
  }
13
- function E(o, e = 9) {
14
- const t = Math.pow(10, e);
15
- return Math.round(o * t) / t;
16
- }
17
- const F = (o, e) => {
18
- const { x: t, y: i } = o, { x: n, y: s } = e, r = n - t, a = s - i;
19
- return Math.sqrt(a * a + r * r);
20
- };
21
- class $ {
22
- constructor({ name: e, callback: t, unregister: i, register: n }) {
23
- this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = e, this.register = () => {
24
- this.registered || (this.registered = !0, n(t));
25
- }, this.unregister = () => {
26
- this.register && (this.registered = !1, i(t));
27
- }, this.callback = t;
28
- }
29
- }
30
- class ct {
31
- constructor(e) {
32
- this._minPixelDragDistance = void 0, this._minPixelDragDistanceDrawing = void 0, this._minPixelDragDistanceSelecting = void 0, this._lastDrawEvent = void 0, this._coordinatePrecision = void 0, this._heldKeys = /* @__PURE__ */ new Set(), this._listeners = [], this._dragState = "not-dragging", this._currentModeCallbacks = void 0, this._minPixelDragDistance = typeof e.minPixelDragDistance == "number" ? e.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof e.minPixelDragDistanceSelecting == "number" ? e.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof e.minPixelDragDistanceDrawing == "number" ? e.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof e.coordinatePrecision == "number" ? e.coordinatePrecision : 9;
33
- }
34
- getButton(e) {
35
- return e.button === -1 ? "neither" : e.button === 0 ? "left" : e.button === 1 ? "middle" : e.button === 2 ? "right" : "neither";
36
- }
37
- getMapElementXYPosition(e) {
38
- const t = this.getMapEventElement(), { left: i, top: n } = t.getBoundingClientRect();
39
- return { containerX: e.clientX - i, containerY: e.clientY - n };
40
- }
41
- getDrawEventFromEvent(e) {
42
- const t = this.getLngLatFromEvent(e);
43
- if (!t) return null;
44
- const { lng: i, lat: n } = t, { containerX: s, containerY: r } = this.getMapElementXYPosition(e), a = this.getButton(e), l = Array.from(this._heldKeys);
45
- return { lng: E(i, this._coordinatePrecision), lat: E(n, this._coordinatePrecision), containerX: s, containerY: r, button: a, heldKeys: l };
46
- }
47
- register(e) {
48
- this._currentModeCallbacks = e, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
49
- t.register();
50
- });
51
- }
52
- getCoordinatePrecision() {
53
- return this._coordinatePrecision;
54
- }
55
- getAdapterListeners() {
56
- return [new $({ name: "pointerdown", callback: (e) => {
57
- if (!this._currentModeCallbacks || !e.isPrimary) return;
58
- const t = this.getDrawEventFromEvent(e);
59
- t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
60
- }, register: (e) => {
61
- this.getMapEventElement().addEventListener("pointerdown", e);
62
- }, unregister: (e) => {
63
- this.getMapEventElement().removeEventListener("pointerdown", e);
64
- } }), new $({ name: "pointermove", callback: (e) => {
65
- if (!this._currentModeCallbacks || !e.isPrimary) return;
66
- e.preventDefault();
67
- const t = this.getDrawEventFromEvent(e);
68
- if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
69
- else if (this._dragState === "pre-dragging") {
70
- if (!this._lastDrawEvent) return;
71
- const i = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, n = { x: t.containerX, y: t.containerY }, s = this._currentModeCallbacks.getState(), r = F(i, n);
72
- let a = !1;
73
- if (a = s === "drawing" ? r < this._minPixelDragDistanceDrawing : s === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, a) return;
74
- this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (l) => {
75
- this.setDraggability.bind(this)(l);
76
- });
77
- } else this._dragState === "dragging" && this._currentModeCallbacks.onDrag(t, (i) => {
78
- this.setDraggability.bind(this)(i);
79
- });
80
- }, register: (e) => {
81
- this.getMapEventElement().addEventListener("pointermove", e);
82
- }, unregister: (e) => {
83
- this.getMapEventElement().removeEventListener("pointermove", e);
84
- } }), new $({ name: "contextmenu", callback: (e) => {
85
- this._currentModeCallbacks && e.preventDefault();
86
- }, register: (e) => {
87
- this.getMapEventElement().addEventListener("contextmenu", e);
88
- }, unregister: (e) => {
89
- this.getMapEventElement().removeEventListener("contextmenu", e);
90
- } }), new $({ name: "pointerup", callback: (e) => {
91
- if (!this._currentModeCallbacks || e.target !== this.getMapEventElement() || !e.isPrimary) return;
92
- const t = this.getDrawEventFromEvent(e);
93
- t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (i) => {
94
- this.setDraggability.bind(this)(i);
95
- }) : this._dragState !== "not-dragging" && this._dragState !== "pre-dragging" || this._currentModeCallbacks.onClick(t), this._dragState = "not-dragging", this.setDraggability(!0));
96
- }, register: (e) => {
97
- this.getMapEventElement().addEventListener("pointerup", e);
98
- }, unregister: (e) => {
99
- this.getMapEventElement().removeEventListener("pointerup", e);
100
- } }), new $({ name: "keyup", callback: (e) => {
101
- this._currentModeCallbacks && (this._heldKeys.delete(e.key), this._currentModeCallbacks.onKeyUp({ key: e.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => e.preventDefault() }));
102
- }, register: (e) => {
103
- this.getMapEventElement().addEventListener("keyup", e);
104
- }, unregister: (e) => {
105
- this.getMapEventElement().removeEventListener("keyup", e);
106
- } }), new $({ name: "keydown", callback: (e) => {
107
- this._currentModeCallbacks && (this._heldKeys.add(e.key), this._currentModeCallbacks.onKeyDown({ key: e.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => e.preventDefault() }));
108
- }, register: (e) => {
109
- this.getMapEventElement().addEventListener("keydown", e);
110
- }, unregister: (e) => {
111
- this.getMapEventElement().removeEventListener("keydown", e);
112
- } })];
113
- }
114
- unregister() {
115
- this._listeners.forEach((e) => {
116
- e.unregister();
117
- }), this.clear();
118
- }
119
- }
120
- class jt extends ct {
121
- constructor(e) {
122
- super(e), this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = e.map, this._container = this._map.getContainer();
123
- }
124
- clearLayers() {
125
- this._rendered && (["point", "linestring", "polygon"].forEach((e) => {
126
- const t = `td-${e.toLowerCase()}`;
127
- this._map.removeLayer(t), e === "polygon" && this._map.removeLayer(t + "-outline"), this._map.removeSource(t);
128
- }), this._rendered = !1, this._nextRender && (cancelAnimationFrame(this._nextRender), this._nextRender = void 0));
129
- }
130
- _addGeoJSONSource(e, t) {
131
- this._map.addSource(e, { type: "geojson", data: { type: "FeatureCollection", features: t }, tolerance: 0 });
132
- }
133
- _addFillLayer(e) {
134
- return this._map.addLayer({ id: e, source: e, type: "fill", paint: { "fill-color": ["get", "polygonFillColor"], "fill-opacity": ["get", "polygonFillOpacity"] } });
135
- }
136
- _addFillOutlineLayer(e) {
137
- return this._map.addLayer({ id: e + "-outline", source: e, type: "line", paint: { "line-width": ["get", "polygonOutlineWidth"], "line-color": ["get", "polygonOutlineColor"] } });
138
- }
139
- _addLineLayer(e) {
140
- return this._map.addLayer({ id: e, source: e, type: "line", paint: { "line-width": ["get", "lineStringWidth"], "line-color": ["get", "lineStringColor"] } });
141
- }
142
- _addPointLayer(e) {
143
- return this._map.addLayer({ id: e, source: e, type: "circle", paint: { "circle-stroke-color": ["get", "pointOutlineColor"], "circle-stroke-width": ["get", "pointOutlineWidth"], "circle-radius": ["get", "pointWidth"], "circle-color": ["get", "pointColor"] } });
144
- }
145
- _addLayer(e, t) {
146
- t === "Point" && this._addPointLayer(e), t === "LineString" && this._addLineLayer(e), t === "Polygon" && (this._addFillLayer(e), this._addFillOutlineLayer(e));
147
- }
148
- _addGeoJSONLayer(e, t) {
149
- const i = `td-${e.toLowerCase()}`;
150
- return this._addGeoJSONSource(i, t), this._addLayer(i, e), i;
151
- }
152
- _setGeoJSONLayerData(e, t) {
153
- const i = `td-${e.toLowerCase()}`;
154
- return this._map.getSource(i).setData({ type: "FeatureCollection", features: t }), i;
155
- }
156
- updateChangedIds(e) {
157
- [...e.updated, ...e.created].forEach((t) => {
158
- t.geometry.type === "Point" ? this.changedIds.points = !0 : t.geometry.type === "LineString" ? this.changedIds.linestrings = !0 : t.geometry.type === "Polygon" && (this.changedIds.polygons = !0);
159
- }), e.deletedIds.length > 0 && (this.changedIds.deletion = !0), e.created.length === 0 && e.updated.length === 0 && e.deletedIds.length === 0 && (this.changedIds.styling = !0);
160
- }
161
- getLngLatFromEvent(e) {
162
- const { left: t, top: i } = this._container.getBoundingClientRect();
163
- return this.unproject(e.clientX - t, e.clientY - i);
164
- }
165
- getMapEventElement() {
166
- return this._map.getCanvas();
167
- }
168
- setDraggability(e) {
169
- e ? (this._map.dragRotate.enable(), this._map.dragPan.enable()) : (this._map.dragRotate.disable(), this._map.dragPan.disable());
170
- }
171
- project(e, t) {
172
- const { x: i, y: n } = this._map.project({ lng: e, lat: t });
173
- return { x: i, y: n };
174
- }
175
- unproject(e, t) {
176
- const { lng: i, lat: n } = this._map.unproject({ x: e, y: t });
177
- return { lng: i, lat: n };
178
- }
179
- setCursor(e) {
180
- const t = this._map.getCanvas();
181
- e === "unset" ? t.style.removeProperty("cursor") : t.style.cursor = e;
182
- }
183
- setDoubleClickToZoom(e) {
184
- e ? this._map.doubleClickZoom.enable() : this._map.doubleClickZoom.disable();
185
- }
186
- render(e, t) {
187
- this.updateChangedIds(e), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
188
- const i = [...e.created, ...e.updated, ...e.unchanged], n = [], s = [], r = [];
189
- for (let a = 0; a < i.length; a++) {
190
- const l = i[a], { properties: d } = l, c = t[d.mode](l);
191
- l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, n.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, s.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, r.push(l));
192
- }
193
- if (this._rendered) {
194
- const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
195
- let c;
196
- (a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", n)), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", r), c && this._map.moveLayer(c);
197
- } else {
198
- const a = this._addGeoJSONLayer("Point", n);
199
- this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon", r), this._rendered = !0, a && this._map.moveLayer(a);
200
- }
201
- this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
202
- });
203
- }
204
- clear() {
205
- this._currentModeCallbacks && (this._currentModeCallbacks.onClear(), this.clearLayers());
206
- }
207
- getCoordinatePrecision() {
208
- return super.getCoordinatePrecision();
209
- }
210
- unregister() {
211
- return super.unregister();
212
- }
213
- register(e) {
214
- var t;
215
- super.register(e), (t = this._currentModeCallbacks) != null && t.onReady && this._currentModeCallbacks.onReady();
216
- }
217
- }
218
- class Bt extends ct {
219
- constructor(e) {
220
- super(e), this.mapboxglAdapter = void 0, this.mapboxglAdapter = new jt(e);
221
- }
222
- register(e) {
223
- this.mapboxglAdapter.register(e);
224
- }
225
- unregister() {
226
- this.mapboxglAdapter.unregister();
227
- }
228
- getCoordinatePrecision() {
229
- return this.mapboxglAdapter.getCoordinatePrecision();
230
- }
231
- getLngLatFromEvent(e) {
232
- return this.mapboxglAdapter.getLngLatFromEvent(e);
233
- }
234
- getMapEventElement() {
235
- return this.mapboxglAdapter.getMapEventElement();
236
- }
237
- setDraggability(e) {
238
- this.mapboxglAdapter.setDraggability(e);
239
- }
240
- project(e, t) {
241
- return this.mapboxglAdapter.project(e, t);
242
- }
243
- unproject(e, t) {
244
- return this.mapboxglAdapter.unproject(e, t);
245
- }
246
- setCursor(e) {
247
- this.mapboxglAdapter.setCursor(e);
248
- }
249
- setDoubleClickToZoom(e) {
250
- this.mapboxglAdapter.setDoubleClickToZoom(e);
251
- }
252
- render(e, t) {
253
- this.mapboxglAdapter.render(e, t);
254
- }
255
- clear() {
256
- this.mapboxglAdapter.clear();
257
- }
258
- }
259
- const Nt = { radians: 6370997 / (2 * Math.PI), degrees: 2 * Math.PI * 6370997 / 360, ft: 0.3048, m: 1, "us-ft": 1200 / 3937 };
260
- var ht = class {
261
- constructor(o) {
262
- this.code_ = o.code, this.units_ = o.units, this.extent_ = o.extent !== void 0 ? o.extent : null, this.worldExtent_ = o.worldExtent !== void 0 ? o.worldExtent : null, this.axisOrientation_ = o.axisOrientation !== void 0 ? o.axisOrientation : "enu", this.global_ = o.global !== void 0 && o.global, this.canWrapX_ = !(!this.global_ || !this.extent_), this.getPointResolutionFunc_ = o.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = o.metersPerUnit;
263
- }
264
- canWrapX() {
265
- return this.canWrapX_;
266
- }
267
- getCode() {
268
- return this.code_;
269
- }
270
- getExtent() {
271
- return this.extent_;
272
- }
273
- getUnits() {
274
- return this.units_;
275
- }
276
- getMetersPerUnit() {
277
- return this.metersPerUnit_ || Nt[this.units_];
278
- }
279
- getWorldExtent() {
280
- return this.worldExtent_;
281
- }
282
- getAxisOrientation() {
283
- return this.axisOrientation_;
284
- }
285
- isGlobal() {
286
- return this.global_;
287
- }
288
- setGlobal(o) {
289
- this.global_ = o, this.canWrapX_ = !(!o || !this.extent_);
290
- }
291
- getDefaultTileGrid() {
292
- return this.defaultTileGrid_;
293
- }
294
- setDefaultTileGrid(o) {
295
- this.defaultTileGrid_ = o;
296
- }
297
- setExtent(o) {
298
- this.extent_ = o, this.canWrapX_ = !(!this.global_ || !o);
299
- }
300
- setWorldExtent(o) {
301
- this.worldExtent_ = o;
302
- }
303
- setGetPointResolution(o) {
304
- this.getPointResolutionFunc_ = o;
305
- }
306
- getPointResolutionFunc() {
307
- return this.getPointResolutionFunc_;
308
- }
309
- };
310
- const re = 6378137, Q = Math.PI * re, At = [-Q, -Q, Q, Q], Gt = [-180, -85, 180, 85], ce = re * Math.log(Math.tan(Math.PI / 2));
311
- class J extends ht {
312
- constructor(e) {
313
- super({ code: e, units: "m", extent: At, global: !0, worldExtent: Gt, getPointResolution: function(t, i) {
314
- return t / Math.cosh(i[1] / re);
315
- } });
316
- }
317
- }
318
- const Ue = [new J("EPSG:3857"), new J("EPSG:102100"), new J("EPSG:102113"), new J("EPSG:900913"), new J("http://www.opengis.net/def/crs/EPSG/0/3857"), new J("http://www.opengis.net/gml/srs/epsg.xml#3857")], Te = [-180, -90, 180, 90], Vt = 6378137 * Math.PI / 180;
319
- class T extends ht {
320
- constructor(e, t) {
321
- super({ code: e, units: "degrees", extent: Te, axisOrientation: t, global: !0, metersPerUnit: Vt, worldExtent: Te });
322
- }
323
- }
324
- const Re = [new T("CRS:84"), new T("EPSG:4326", "neu"), new T("urn:ogc:def:crs:OGC:1.3:CRS84"), new T("urn:ogc:def:crs:OGC:2:84"), new T("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), new T("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), new T("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")];
325
- let Me = {};
326
- function ye(o, e, t) {
327
- const i = o.getCode(), n = e.getCode();
328
- i in Me || (Me[i] = {}), Me[i][n] = t;
329
- }
330
- function ut(o, e) {
331
- if (e !== void 0) for (let t = 0, i = o.length; t < i; ++t) e[t] = o[t];
332
- else e = o.slice();
333
- return e;
334
- }
335
- function Ut(o) {
336
- o.getCode(), ye(o, o, ut);
337
- }
338
- function Xe(o) {
339
- (function(e) {
340
- e.forEach(Ut);
341
- })(o), o.forEach(function(e) {
342
- o.forEach(function(t) {
343
- e !== t && ye(e, t, ut);
344
- });
345
- });
346
- }
347
- var ze, Ke, Ye, b;
348
- Xe(Ue), Xe(Re), ze = Ue, Ke = function(o, e, t) {
349
- const i = o.length;
350
- t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? o.slice() : new Array(i));
351
- for (let n = 0; n < i; n += t) {
352
- e[n] = Q * o[n] / 180;
353
- let s = re * Math.log(Math.tan(Math.PI * (+o[n + 1] + 90) / 360));
354
- s > ce ? s = ce : s < -ce && (s = -ce), e[n + 1] = s;
355
- }
356
- return e;
357
- }, Ye = function(o, e, t) {
358
- const i = o.length;
359
- t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? o.slice() : new Array(i));
360
- for (let n = 0; n < i; n += t) e[n] = 180 * o[n] / Q, e[n + 1] = 360 * Math.atan(Math.exp(o[n + 1] / re)) / Math.PI - 90;
361
- return e;
362
- }, Re.forEach(function(o) {
363
- ze.forEach(function(e) {
364
- ye(o, e, Ke), ye(e, o, Ye);
365
- });
366
- });
13
+ var b;
367
14
  (function(o) {
368
15
  o.Commit = "commit", o.Provisional = "provisional", o.Finish = "finish";
369
16
  })(b || (b = {}));
370
- const De = "selected", oe = "midPoint", ae = "closingPoint", Oe = "snappingPoint";
371
- function we(o) {
17
+ const T = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, ie = "closingPoint", xe = "snappingPoint";
18
+ function fe(o) {
372
19
  return !!(o && typeof o == "object" && o !== null && !Array.isArray(o));
373
20
  }
374
- function He(o) {
21
+ function ke(o) {
375
22
  return !!function(e) {
376
23
  return typeof e == "number" && !isNaN(new Date(e).valueOf());
377
24
  }(o);
378
25
  }
379
- const Tt = "Feature mode property does not match the mode being added to";
380
- var K;
26
+ const St = "Feature mode property does not match the mode being added to";
27
+ var X;
381
28
  (function(o) {
382
29
  o.Drawing = "drawing", o.Select = "select", o.Static = "static", o.Render = "render";
383
- })(K || (K = {}));
384
- class B {
30
+ })(X || (X = {}));
31
+ class N {
385
32
  get state() {
386
33
  return this._state;
387
34
  }
@@ -398,7 +45,7 @@ class B {
398
45
  registerBehaviors(e) {
399
46
  }
400
47
  constructor(e) {
401
- this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = K.Drawing, this.mode = "base", this._state = "unregistered", this._styles = e && e.styles ? M({}, e.styles) : {}, this.pointerDistance = e && e.pointerDistance || 40, this.validate = e && e.validation, this.projection = e && e.projection || "web-mercator";
48
+ this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = X.Drawing, this.mode = "base", this._state = "unregistered", this._styles = e && e.styles ? M({}, e.styles) : {}, this.pointerDistance = e && e.pointerDistance || 40, this.validate = e && e.validation, this.projection = e && e.projection || "web-mercator";
402
49
  }
403
50
  setDrawing() {
404
51
  if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
@@ -423,9 +70,9 @@ class B {
423
70
  if (this._state === "unregistered") throw new Error("Mode must be registered");
424
71
  const t = function(i, n) {
425
72
  let s;
426
- if (we(i)) if (i.id == null) s = "Feature has no id";
73
+ if (fe(i)) if (i.id == null) s = "Feature has no id";
427
74
  else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
428
- else if (n(i.id)) if (we(i.geometry)) if (we(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
75
+ else if (n(i.id)) if (fe(i.geometry)) if (fe(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
429
76
  if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
430
77
  } else s = "Feature coordinates is not an array";
431
78
  else s = "Feature is not Point, LineString or Polygon";
@@ -443,7 +90,7 @@ class B {
443
90
  }
444
91
  validateModeFeature(e, t) {
445
92
  const i = this.performFeatureValidation(e);
446
- return i.valid ? e.properties.mode !== this.mode ? { valid: !1, reason: Tt } : t(e) : { valid: !1, reason: i.reason };
93
+ return i.valid ? e.properties.mode !== this.mode ? { valid: !1, reason: St } : t(e) : { valid: !1, reason: i.reason };
447
94
  }
448
95
  onFinish(e, t) {
449
96
  }
@@ -475,85 +122,88 @@ class B {
475
122
  return e === void 0 ? t : typeof e == "function" ? e(i) : e;
476
123
  }
477
124
  }
478
- class Rt extends B {
125
+ class xt extends N {
479
126
  constructor(...e) {
480
- super(...e), this.type = K.Select;
127
+ super(...e), this.type = X.Select;
481
128
  }
482
129
  }
483
130
  function V(o, e) {
484
131
  const t = (d) => d * Math.PI / 180, i = t(o[1]), n = t(o[0]), s = t(e[1]), r = s - i, a = t(e[0]) - n, l = Math.sin(r / 2) * Math.sin(r / 2) + Math.cos(i) * Math.cos(s) * Math.sin(a / 2) * Math.sin(a / 2);
485
132
  return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
486
133
  }
487
- const _e = 63710088e-1;
488
- function D(o) {
134
+ const Ze = 63710088e-1;
135
+ function F(o) {
489
136
  return o % 360 * Math.PI / 180;
490
137
  }
491
- function pt(o) {
492
- return o / (_e / 1e3);
138
+ function Qe(o) {
139
+ return o / 6371.0088;
493
140
  }
494
141
  function U(o) {
495
142
  return o % (2 * Math.PI) * 180 / Math.PI;
496
143
  }
497
- const $e = 57.29577951308232, Je = 0.017453292519943295, me = 6378137, S = (o, e) => ({ x: o === 0 ? 0 : o * Je * me, y: e === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + e * Je / 2)) * me }), k = (o, e) => ({ lng: o === 0 ? 0 : $e * (o / me), lat: e === 0 ? 0 : (2 * Math.atan(Math.exp(e / me)) - Math.PI / 2) * $e });
498
- function Xt(o, e, t) {
499
- const i = D(o[0]), n = D(o[1]), s = D(t), r = pt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
144
+ function E(o, e = 9) {
145
+ const t = Math.pow(10, e);
146
+ return Math.round(o * t) / t;
147
+ }
148
+ const We = 57.29577951308232, je = 0.017453292519943295, ce = 6378137, x = (o, e) => ({ x: o === 0 ? 0 : o * je * ce, y: e === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + e * je / 2)) * ce }), k = (o, e) => ({ lng: o === 0 ? 0 : We * (o / ce), lat: e === 0 ? 0 : (2 * Math.atan(Math.exp(e / ce)) - Math.PI / 2) * We });
149
+ function Mt(o, e, t) {
150
+ const i = F(o[0]), n = F(o[1]), s = F(t), r = Qe(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
500
151
  return [U(i + Math.atan2(Math.sin(s) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), U(a)];
501
152
  }
502
- function qe(o) {
153
+ function Ne(o) {
503
154
  const { center: e, radiusKilometers: t, coordinatePrecision: i } = o, n = o.steps ? o.steps : 64, s = [];
504
155
  for (let r = 0; r < n; r++) {
505
- const a = Xt(e, t, -360 * r / n);
156
+ const a = Mt(e, t, -360 * r / n);
506
157
  s.push([E(a[0], i), E(a[1], i)]);
507
158
  }
508
159
  return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
509
160
  }
510
- function Le(o) {
511
- const e = { epsilon: 0 };
512
- let t;
513
- if (o.geometry.type === "Polygon") t = o.geometry.coordinates;
161
+ function Me(o) {
162
+ let e;
163
+ if (o.geometry.type === "Polygon") e = o.geometry.coordinates;
514
164
  else {
515
165
  if (o.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
516
- t = [o.geometry.coordinates];
517
- }
518
- const i = [];
519
- for (let r = 0; r < t.length; r++) for (let a = 0; a < t[r].length - 1; a++) for (let l = 0; l < t.length; l++) for (let d = 0; d < t[l].length - 1; d++) s(r, a, l, d);
520
- return i.length > 0;
521
- function n(r) {
522
- return r < 0 - e.epsilon || r > 1 + e.epsilon;
523
- }
524
- function s(r, a, l, d) {
525
- const c = t[r][a], h = t[r][a + 1], u = t[l][d], p = t[l][d + 1], g = function(y, C, m, v) {
526
- if (he(y, m) || he(y, v) || he(C, m) || he(v, m)) return null;
527
- const x = y[0], w = y[1], I = C[0], O = C[1], N = m[0], _ = m[1], j = v[0], Y = v[1], H = (x - I) * (_ - Y) - (w - O) * (N - j);
528
- return H === 0 ? null : [((x * O - w * I) * (N - j) - (x - I) * (N * Y - _ * j)) / H, ((x * O - w * I) * (_ - Y) - (w - O) * (N * Y - _ * j)) / H];
529
- }(c, h, u, p);
530
- if (g === null) return;
531
- let f, P;
532
- f = h[0] !== c[0] ? (g[0] - c[0]) / (h[0] - c[0]) : (g[1] - c[1]) / (h[1] - c[1]), P = p[0] !== u[0] ? (g[0] - u[0]) / (p[0] - u[0]) : (g[1] - u[1]) / (p[1] - u[1]), n(f) || n(P) || (g.toString(), i.push(g));
533
- }
534
- }
535
- function he(o, e) {
166
+ e = [o.geometry.coordinates];
167
+ }
168
+ const t = [];
169
+ for (let s = 0; s < e.length; s++) for (let r = 0; r < e[s].length - 1; r++) for (let a = 0; a < e.length; a++) for (let l = 0; l < e[a].length - 1; l++) n(s, r, a, l);
170
+ return t.length > 0;
171
+ function i(s) {
172
+ return s < 0 || s > 1;
173
+ }
174
+ function n(s, r, a, l) {
175
+ const d = e[s][r], c = e[s][r + 1], h = e[a][l], u = e[a][l + 1], p = function(P, f, m, C) {
176
+ if (oe(P, m) || oe(P, C) || oe(f, m) || oe(C, m)) return null;
177
+ const v = P[0], S = P[1], w = f[0], I = f[1], O = m[0], B = m[1], _ = C[0], j = C[1], q = (v - w) * (B - j) - (S - I) * (O - _);
178
+ return q === 0 ? null : [((v * I - S * w) * (O - _) - (v - w) * (O * j - B * _)) / q, ((v * I - S * w) * (B - j) - (S - I) * (O * j - B * _)) / q];
179
+ }(d, c, h, u);
180
+ if (p === null) return;
181
+ let g, y;
182
+ g = c[0] !== d[0] ? (p[0] - d[0]) / (c[0] - d[0]) : (p[1] - d[1]) / (c[1] - d[1]), y = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(g) || i(y) || (p.toString(), t.push(p));
183
+ }
184
+ }
185
+ function oe(o, e) {
536
186
  return o[0] === e[0] && o[1] === e[1];
537
187
  }
538
- function xe(o, e) {
539
- return o.length === 2 && typeof o[0] == "number" && typeof o[1] == "number" && o[0] !== 1 / 0 && o[1] !== 1 / 0 && (i = o[0]) >= -180 && i <= 180 && (t = o[1]) >= -90 && t <= 90 && Ze(o[0]) <= e && Ze(o[1]) <= e;
188
+ function ge(o, e) {
189
+ return o.length === 2 && typeof o[0] == "number" && typeof o[1] == "number" && o[0] !== 1 / 0 && o[1] !== 1 / 0 && (i = o[0]) >= -180 && i <= 180 && (t = o[1]) >= -90 && t <= 90 && Be(o[0]) <= e && Be(o[1]) <= e;
540
190
  var t, i;
541
191
  }
542
- function Ze(o) {
192
+ function Be(o) {
543
193
  let e = 1, t = 0;
544
194
  for (; Math.round(o * e) / e !== o; ) e *= 10, t++;
545
195
  return t;
546
196
  }
547
- const zt = "Feature is not a Polygon", Kt = "Feature has holes", Yt = "Feature has less than 4 coordinates", Ht = "Feature has invalid coordinates", $t = "Feature coordinates are not closed";
548
- function Se(o, e) {
549
- return o.geometry.type !== "Polygon" ? { valid: !1, reason: zt } : o.geometry.coordinates.length !== 1 ? { valid: !1, reason: Kt } : o.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Yt } : o.geometry.coordinates[0].every((n) => xe(n, e)) ? (t = o.geometry.coordinates[0][0])[0] !== (i = o.geometry.coordinates[0][o.geometry.coordinates[0].length - 1])[0] || t[1] !== i[1] ? { valid: !1, reason: $t } : { valid: !0 } : { valid: !1, reason: Ht };
197
+ const wt = "Feature has holes", bt = "Feature has less than 4 coordinates", It = "Feature has invalid coordinates", Et = "Feature coordinates are not closed";
198
+ function ye(o, e) {
199
+ return o.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : o.geometry.coordinates.length !== 1 ? { valid: !1, reason: wt } : o.geometry.coordinates[0].length < 4 ? { valid: !1, reason: bt } : o.geometry.coordinates[0].every((n) => ge(n, e)) ? (t = o.geometry.coordinates[0][0])[0] !== (i = o.geometry.coordinates[0][o.geometry.coordinates[0].length - 1])[0] || t[1] !== i[1] ? { valid: !1, reason: Et } : { valid: !0 } : { valid: !1, reason: It };
550
200
  var t, i;
551
201
  }
552
- function de(o, e) {
553
- const t = Se(o, e);
554
- return t.valid ? Le(o) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
202
+ function se(o, e) {
203
+ const t = ye(o, e);
204
+ return t.valid ? Me(o) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
555
205
  }
556
- class gt extends B {
206
+ class et extends N {
557
207
  constructor(e) {
558
208
  var t;
559
209
  super(e), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1;
@@ -583,7 +233,7 @@ class gt extends B {
583
233
  onClick(e) {
584
234
  if (this.clickCount === 0) {
585
235
  this.center = [e.lng, e.lat];
586
- const t = qe({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: t.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
236
+ const t = Ne({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: t.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
587
237
  this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
588
238
  } else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(e), this.close();
589
239
  }
@@ -614,7 +264,7 @@ class gt extends B {
614
264
  return e.type === "Feature" && e.geometry.type === "Polygon" && e.properties.mode === this.mode && (t.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, t.polygonFillColor, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, t.polygonFillOpacity, e), t.zIndex = 10), t;
615
265
  }
616
266
  validateFeature(e) {
617
- return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
267
+ return this.validateModeFeature(e, (t) => se(t, this.coordinatePrecision));
618
268
  }
619
269
  updateCircle(e) {
620
270
  if (this.clickCount === 1 && this.center && this.currentCircleId) {
@@ -624,27 +274,31 @@ class gt extends B {
624
274
  const n = function(s, r) {
625
275
  const a = 1e3 * V(s, r);
626
276
  if (a === 0) return 1;
627
- const { x: l, y: d } = S(s[0], s[1]), { x: c, y: h } = S(r[0], r[1]);
277
+ const { x: l, y: d } = x(s[0], s[1]), { x: c, y: h } = x(r[0], r[1]);
628
278
  return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
629
279
  }(this.center, [e.lng, e.lat]);
630
280
  i = function(s) {
631
- const { center: r, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = r, { x: p, y: g } = S(h, u), f = [];
281
+ const { center: r, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = r, { x: p, y: g } = x(h, u), y = [];
632
282
  for (let P = 0; P < d; P++) {
633
- const y = 360 * P / d * Math.PI / 180, C = c * Math.cos(y), m = c * Math.sin(y), [v, x] = [p + C, g + m], { lng: w, lat: I } = k(v, x);
634
- f.push([E(w, l), E(I, l)]);
283
+ const f = 360 * P / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [v, S] = [p + m, g + C], { lng: w, lat: I } = k(v, S);
284
+ y.push([E(w, l), E(I, l)]);
635
285
  }
636
- return f.push(f[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [f] }, properties: {} };
286
+ return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
637
287
  }({ center: this.center, radiusKilometers: t * n, coordinatePrecision: this.coordinatePrecision });
638
288
  } else {
639
289
  if (this.projection !== "globe") throw new Error("Invalid projection");
640
- i = qe({ center: this.center, radiusKilometers: t, coordinatePrecision: this.coordinatePrecision });
290
+ i = Ne({ center: this.center, radiusKilometers: t, coordinatePrecision: this.coordinatePrecision });
641
291
  }
642
292
  if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: t } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid) return;
643
293
  this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: t }]);
644
294
  }
645
295
  }
646
296
  }
647
- class ft extends B {
297
+ const D = (o, e) => {
298
+ const { x: t, y: i } = o, { x: n, y: s } = e, r = n - t, a = s - i;
299
+ return Math.sqrt(a * a + r * r);
300
+ };
301
+ class tt extends N {
648
302
  constructor(e) {
649
303
  super(e), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = void 0, this.keyEvents = void 0, this.cursors = void 0, this.preventPointsNearClose = void 0, this.autoClose = void 0, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1;
650
304
  const t = { start: "crosshair", close: "pointer" };
@@ -673,8 +327,8 @@ class ft extends B {
673
327
  }
674
328
  onMouseMove(e) {
675
329
  if (this.currentId === void 0 || this.startingClick === !1) return;
676
- const t = this.store.getGeometryCopy(this.currentId), i = t.coordinates[0].length - 2, [n, s] = t.coordinates[0][i], { x: r, y: a } = this.project(n, s), l = F({ x: r, y: a }, { x: e.containerX, y: e.containerY }), [d, c] = t.coordinates[0][0], { x: h, y: u } = this.project(d, c);
677
- if (F({ x: h, y: u }, { x: e.containerX, y: e.containerY }) < this.pointerDistance) {
330
+ const t = this.store.getGeometryCopy(this.currentId), i = t.coordinates[0].length - 2, [n, s] = t.coordinates[0][i], { x: r, y: a } = this.project(n, s), l = D({ x: r, y: a }, { x: e.containerX, y: e.containerY }), [d, c] = t.coordinates[0][0], { x: h, y: u } = this.project(d, c);
331
+ if (D({ x: h, y: u }, { x: e.containerX, y: e.containerY }) < this.pointerDistance) {
678
332
  if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
679
333
  this.preventNewFeature = !1;
680
334
  }, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
@@ -687,7 +341,7 @@ class ft extends B {
687
341
  onClick(e) {
688
342
  if (!this.preventNewFeature) {
689
343
  if (this.startingClick === !1) {
690
- const [t, i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat]]] }, properties: { mode: this.mode } }, { geometry: { type: "Point", coordinates: [e.lng, e.lat] }, properties: { mode: this.mode, [ae]: !0 } }]);
344
+ const [t, i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat], [e.lng, e.lat]]] }, properties: { mode: this.mode } }, { geometry: { type: "Point", coordinates: [e.lng, e.lat] }, properties: { mode: this.mode, [ie]: !0 } }]);
691
345
  return this.currentId = t, this.closingPointId = i, this.startingClick = !0, void this.setDrawing();
692
346
  }
693
347
  this.close();
@@ -717,7 +371,7 @@ class ft extends B {
717
371
  return e.type === "Feature" && e.geometry.type === "Polygon" && e.properties.mode === this.mode ? (t.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, t.polygonFillColor, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, t.polygonFillOpacity, e), t.zIndex = 10, t) : (e.type === "Feature" && e.geometry.type === "Point" && e.properties.mode === this.mode && (t.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, e), t.zIndex = 40), t);
718
372
  }
719
373
  validateFeature(e) {
720
- return this.validateModeFeature(e, (t) => Se(t, this.coordinatePrecision));
374
+ return this.validateModeFeature(e, (t) => ye(t, this.coordinatePrecision));
721
375
  }
722
376
  }
723
377
  class W {
@@ -725,29 +379,29 @@ class W {
725
379
  this.store = void 0, this.mode = void 0, this.project = void 0, this.unproject = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.projection = void 0, this.store = e, this.mode = t, this.project = i, this.unproject = n, this.pointerDistance = s, this.coordinatePrecision = r, this.projection = a;
726
380
  }
727
381
  }
728
- function yt({ unproject: o, point: e, pointerDistance: t }) {
382
+ function it({ unproject: o, point: e, pointerDistance: t }) {
729
383
  const i = t / 2, { x: n, y: s } = e;
730
384
  return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[o(n - i, s - i), o(n + i, s - i), o(n + i, s + i), o(n - i, s + i), o(n - i, s - i)].map((r) => [r.lng, r.lat])] } };
731
385
  }
732
- class ke extends W {
386
+ class we extends W {
733
387
  constructor(e) {
734
388
  super(e);
735
389
  }
736
390
  create(e) {
737
391
  const { containerX: t, containerY: i } = e;
738
- return yt({ unproject: this.unproject, point: { x: t, y: i }, pointerDistance: this.pointerDistance });
392
+ return it({ unproject: this.unproject, point: { x: t, y: i }, pointerDistance: this.pointerDistance });
739
393
  }
740
394
  }
741
- class We extends W {
395
+ class be extends W {
742
396
  constructor(e) {
743
397
  super(e);
744
398
  }
745
399
  measure(e, t) {
746
400
  const { x: i, y: n } = this.project(t[0], t[1]);
747
- return F({ x: i, y: n }, { x: e.containerX, y: e.containerY });
401
+ return D({ x: i, y: n }, { x: e.containerX, y: e.containerY });
748
402
  }
749
403
  }
750
- class mt extends W {
404
+ class nt extends W {
751
405
  constructor(e, t, i) {
752
406
  super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (n, s) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== s)), this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
753
407
  }
@@ -767,34 +421,34 @@ class mt extends W {
767
421
  }), s.coord;
768
422
  }
769
423
  }
770
- function Qe(o, e, t) {
771
- const i = D(o[0]), n = D(o[1]), s = D(t), r = pt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
424
+ function Ae(o, e, t) {
425
+ const i = F(o[0]), n = F(o[1]), s = F(t), r = Qe(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
772
426
  return [U(i + Math.atan2(Math.sin(s) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), U(a)];
773
427
  }
774
- function le({ x: o, y: e }, t, i) {
775
- const n = D(i);
428
+ function ne({ x: o, y: e }, t, i) {
429
+ const n = F(i);
776
430
  return { x: o + t * Math.cos(n), y: e + t * Math.sin(n) };
777
431
  }
778
- function et(o, e) {
779
- const t = D(o[0]), i = D(e[0]), n = D(o[1]), s = D(e[1]), r = Math.sin(i - t) * Math.cos(s), a = Math.cos(n) * Math.sin(s) - Math.sin(n) * Math.cos(s) * Math.cos(i - t);
432
+ function Ge(o, e) {
433
+ const t = F(o[0]), i = F(e[0]), n = F(o[1]), s = F(e[1]), r = Math.sin(i - t) * Math.cos(s), a = Math.cos(n) * Math.sin(s) - Math.sin(n) * Math.cos(s) * Math.cos(i - t);
780
434
  return U(Math.atan2(r, a));
781
435
  }
782
436
  function G({ x: o, y: e }, { x: t, y: i }) {
783
437
  let n = Math.atan2(i - e, t - o);
784
438
  return n *= 180 / Math.PI, n > 180 ? n -= 360 : n < -180 && (n += 360), n;
785
439
  }
786
- function z(o) {
440
+ function K(o) {
787
441
  return (o + 360) % 360;
788
442
  }
789
- function Jt(o, e, t) {
443
+ function Ft(o, e, t) {
790
444
  const i = [], n = o.length;
791
445
  let s, r, a, l = 0;
792
446
  for (let c = 0; c < o.length && !(e >= l && c === o.length - 1); c++) {
793
447
  if (l > e && i.length === 0) {
794
448
  if (s = e - l, !s) return i.push(o[c]), i;
795
- r = et(o[c], o[c - 1]) - 180, a = Qe(o[c], s, r), i.push(a);
449
+ r = Ge(o[c], o[c - 1]) - 180, a = Ae(o[c], s, r), i.push(a);
796
450
  }
797
- if (l >= t) return s = t - l, s ? (r = et(o[c], o[c - 1]) - 180, a = Qe(o[c], s, r), i.push(a), i) : (i.push(o[c]), i);
451
+ if (l >= t) return s = t - l, s ? (r = Ge(o[c], o[c - 1]) - 180, a = Ae(o[c], s, r), i.push(a), i) : (i.push(o[c]), i);
798
452
  if (l >= e && i.push(o[c]), c === o.length - 1) return i;
799
453
  l += V(o[c], o[c + 1]);
800
454
  }
@@ -802,13 +456,13 @@ function Jt(o, e, t) {
802
456
  const d = o[o.length - 1];
803
457
  return [d, d];
804
458
  }
805
- function ue(o) {
459
+ function re(o) {
806
460
  return o * (Math.PI / 180);
807
461
  }
808
- function tt(o) {
462
+ function Ve(o) {
809
463
  return o * (180 / Math.PI);
810
464
  }
811
- class qt extends W {
465
+ class Dt extends W {
812
466
  constructor(e) {
813
467
  super(e), this.config = void 0, this.config = e;
814
468
  }
@@ -821,7 +475,7 @@ class qt extends W {
821
475
  Number.isInteger(r) || (r = Math.floor(r) + 1);
822
476
  const a = [];
823
477
  for (let d = 0; d < r; d++) {
824
- const c = Jt(n, i * d, i * (d + 1));
478
+ const c = Ft(n, i * d, i * (d + 1));
825
479
  a.push(c);
826
480
  }
827
481
  const l = [];
@@ -830,15 +484,15 @@ class qt extends W {
830
484
  }
831
485
  generateInsertionGeodesicCoordinates(e, t, i) {
832
486
  const n = V(e, t), s = function(r, a, l) {
833
- const d = [], c = ue(r[1]), h = ue(r[0]), u = ue(a[1]), p = ue(a[0]);
487
+ const d = [], c = re(r[1]), h = re(r[0]), u = re(a[1]), p = re(a[0]);
834
488
  l += 1;
835
489
  const g = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
836
490
  if (g === 0 || isNaN(g)) return d;
837
- for (let f = 0; f <= l; f++) {
838
- const P = f / l, y = Math.sin((1 - P) * g) / Math.sin(g), C = Math.sin(P * g) / Math.sin(g), m = y * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(p), v = y * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(p), x = y * Math.sin(c) + C * Math.sin(u);
839
- if (isNaN(m) || isNaN(v) || isNaN(x)) continue;
840
- const w = Math.atan2(x, Math.sqrt(m ** 2 + v ** 2)), I = Math.atan2(v, m);
841
- isNaN(w) || isNaN(I) || d.push([tt(I), tt(w)]);
491
+ for (let y = 0; y <= l; y++) {
492
+ const P = y / l, f = Math.sin((1 - P) * g) / Math.sin(g), m = Math.sin(P * g) / Math.sin(g), C = f * Math.cos(c) * Math.cos(h) + m * Math.cos(u) * Math.cos(p), v = f * Math.cos(c) * Math.sin(h) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(c) + m * Math.sin(u);
493
+ if (isNaN(C) || isNaN(v) || isNaN(S)) continue;
494
+ const w = Math.atan2(S, Math.sqrt(C ** 2 + v ** 2)), I = Math.atan2(v, C);
495
+ isNaN(w) || isNaN(I) || d.push([Ve(I), Ve(w)]);
842
496
  }
843
497
  return d.slice(1, -1);
844
498
  }(e, t, Math.floor(n / i));
@@ -848,13 +502,13 @@ class qt extends W {
848
502
  return e.map((t) => [E(t[0], this.config.coordinatePrecision), E(t[1], this.config.coordinatePrecision)]);
849
503
  }
850
504
  }
851
- function ee(o, e) {
505
+ function J(o, e) {
852
506
  return o[0] === e[0] && o[1] === e[1];
853
507
  }
854
- function Ct(o, e) {
855
- return o.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : o.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : o.geometry.coordinates.every((t) => xe(t, e)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
508
+ function st(o, e) {
509
+ return o.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : o.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : o.geometry.coordinates.every((t) => ge(t, e)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
856
510
  }
857
- class Pt extends B {
511
+ class ot extends N {
858
512
  constructor(e) {
859
513
  super(e), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0;
860
514
  const t = { start: "crosshair", close: "pointer" };
@@ -900,13 +554,13 @@ class Pt extends B {
900
554
  updateToLine(e, t) {
901
555
  if (!this.currentId) return;
902
556
  const i = this.store.getGeometryCopy(this.currentId).coordinates, [n, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: r, y: a } = this.project(n, s);
903
- if (F({ x: r, y: a }, { x: t.x, y: t.y }) < this.pointerDistance) return void this.close();
557
+ if (D({ x: r, y: a }, { x: t.x, y: t.y }) < this.pointerDistance) return void this.close();
904
558
  this.setCursor(this.cursors.close);
905
559
  const l = [...i, e];
906
560
  this.updateGeometries(l, i[i.length - 1], b.Commit), this.currentCoordinate++;
907
561
  }
908
562
  registerBehaviors(e) {
909
- this.coordinateSnapping = new mt(e, new We(e), new ke(e)), this.insertPoint = new qt(e);
563
+ this.coordinateSnapping = new nt(e, new be(e), new we(e)), this.insertPoint = new Dt(e);
910
564
  }
911
565
  start() {
912
566
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -920,7 +574,7 @@ class Pt extends B {
920
574
  if (t) {
921
575
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: t } }]);
922
576
  else {
923
- const [r] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [Oe]: !0 } }]);
577
+ const [r] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [xe]: !0 } }]);
924
578
  this.snappedPointId = r;
925
579
  }
926
580
  e.lng = t[0], e.lat = t[1];
@@ -930,12 +584,12 @@ class Pt extends B {
930
584
  const n = this.store.getGeometryCopy(this.currentId).coordinates;
931
585
  if (n.pop(), this.closingPointId) {
932
586
  const [r, a] = n[n.length - 1], { x: l, y: d } = this.project(r, a);
933
- F({ x: l, y: d }, { x: e.containerX, y: e.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
587
+ D({ x: l, y: d }, { x: e.containerX, y: e.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
934
588
  }
935
589
  let s = [...n, i];
936
590
  if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
937
591
  const r = this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1], a = i;
938
- if (!ee(r, a)) {
592
+ if (!J(r, a)) {
939
593
  const l = this.generateInsertCoordinates(r, a);
940
594
  s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
941
595
  }
@@ -970,13 +624,13 @@ class Pt extends B {
970
624
  const t = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
971
625
  if (e.type === "Feature" && e.geometry.type === "LineString" && e.properties.mode === this.mode) return t.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, t.lineStringColor, e), t.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, t.lineStringWidth, e), t.zIndex = 10, t;
972
626
  if (e.type === "Feature" && e.geometry.type === "Point" && e.properties.mode === this.mode) {
973
- const i = e.properties[ae];
627
+ const i = e.properties[ie];
974
628
  return t.pointColor = this.getHexColorStylingValue(i ? this.styles.closingPointColor : this.styles.snappingPointColor, t.pointColor, e), t.pointWidth = this.getNumericStylingValue(i ? this.styles.closingPointWidth : this.styles.snappingPointWidth, t.pointWidth, e), t.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.closingPointOutlineColor : this.styles.snappingPointOutlineColor, "#ffffff", e), t.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.closingPointOutlineWidth : this.styles.snappingPointOutlineWidth, 2, e), t.zIndex = 40, t;
975
629
  }
976
630
  return t;
977
631
  }
978
632
  validateFeature(e) {
979
- return this.validateModeFeature(e, (t) => Ct(t, this.coordinatePrecision));
633
+ return this.validateModeFeature(e, (t) => st(t, this.coordinatePrecision));
980
634
  }
981
635
  snapCoordinate(e) {
982
636
  var t, i;
@@ -984,11 +638,11 @@ class Pt extends B {
984
638
  return (t = this.snapping) != null && t.toCoordinate && (n = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(e, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(e)), (i = this.snapping) != null && i.toCustom && (n = this.snapping.toCustom(e)), n;
985
639
  }
986
640
  }
987
- const Zt = "Feature is not a Point", Qt = "Feature has invalid coordinates";
988
- function vt(o, e) {
989
- return o.geometry.type !== "Point" ? { valid: !1, reason: Zt } : xe(o.geometry.coordinates, e) ? { valid: !0 } : { valid: !1, reason: Qt };
641
+ const Ot = "Feature is not a Point", _t = "Feature has invalid coordinates";
642
+ function rt(o, e) {
643
+ return o.geometry.type !== "Point" ? { valid: !1, reason: Ot } : ge(o.geometry.coordinates, e) ? { valid: !0 } : { valid: !1, reason: _t };
990
644
  }
991
- class ei extends B {
645
+ class Lt extends N {
992
646
  constructor(e) {
993
647
  super(e), this.mode = "point", this.cursors = void 0;
994
648
  const t = { create: "crosshair" };
@@ -1026,10 +680,10 @@ class ei extends B {
1026
680
  return e.type === "Feature" && e.geometry.type === "Point" && e.properties.mode === this.mode && (t.pointWidth = this.getNumericStylingValue(this.styles.pointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(this.styles.pointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.pointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.pointOutlineWidth, 2, e), t.zIndex = 30), t;
1027
681
  }
1028
682
  validateFeature(e) {
1029
- return this.validateModeFeature(e, (t) => vt(t, this.coordinatePrecision));
683
+ return this.validateModeFeature(e, (t) => rt(t, this.coordinatePrecision));
1030
684
  }
1031
685
  }
1032
- class ti extends W {
686
+ class kt extends W {
1033
687
  constructor(e, t) {
1034
688
  super(e), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = e, this.pixelDistance = t;
1035
689
  }
@@ -1041,7 +695,7 @@ class ti extends W {
1041
695
  create(e, t) {
1042
696
  if (this.ids.length) throw new Error("Opening and closing points already created");
1043
697
  if (e.length <= 3) throw new Error("Requires at least 4 coordinates");
1044
- this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: e[0] }, properties: { mode: t, [ae]: !0 } }, { geometry: { type: "Point", coordinates: e[e.length - 2] }, properties: { mode: t, [ae]: !0 } }]);
698
+ this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: e[0] }, properties: { mode: t, [ie]: !0 } }, { geometry: { type: "Point", coordinates: e[e.length - 2] }, properties: { mode: t, [ie]: !0 } }]);
1045
699
  }
1046
700
  delete() {
1047
701
  this.ids.length && (this.store.delete(this.ids), this._startEndPoints = []);
@@ -1055,37 +709,37 @@ class ti extends W {
1055
709
  return { isClosing: n < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
1056
710
  }
1057
711
  }
1058
- function it(o) {
712
+ function Te(o) {
1059
713
  return Math.sqrt(Math.pow(o[0], 2) + Math.pow(o[1], 2) + Math.pow(o[2], 2));
1060
714
  }
1061
715
  function R(o, e) {
1062
716
  const t = function(i, n) {
1063
717
  const [s, r, a] = i, [l, d, c] = n;
1064
718
  return s * l + r * d + a * c;
1065
- }(o, e) / (it(o) * it(e));
719
+ }(o, e) / (Te(o) * Te(e));
1066
720
  return Math.acos(Math.min(Math.max(t, -1), 1));
1067
721
  }
1068
- function be(o) {
1069
- const e = D(o[1]), t = D(o[0]);
722
+ function me(o) {
723
+ const e = F(o[1]), t = F(o[0]);
1070
724
  return [Math.cos(e) * Math.cos(t), Math.cos(e) * Math.sin(t), Math.sin(e)];
1071
725
  }
1072
- function X(o) {
726
+ function z(o) {
1073
727
  const [e, t, i] = o, n = U(Math.asin(i));
1074
728
  return [U(Math.atan2(t, e)), n];
1075
729
  }
1076
- function ii(o, e, t) {
1077
- const i = be(o), n = be(e), s = be(t), [r, a, l] = s, [d, c, h] = function(j, Y) {
1078
- const [H, Be, Ne] = j, [Ae, Ge, Ve] = Y;
1079
- return [Be * Ve - Ne * Ge, Ne * Ae - H * Ve, H * Ge - Be * Ae];
1080
- }(i, n), u = c * l - h * a, p = h * r - d * l, g = d * a - c * r, f = g * c - p * h, P = u * h - g * d, y = p * d - u * c, C = 1 / Math.sqrt(Math.pow(f, 2) + Math.pow(P, 2) + Math.pow(y, 2)), m = [f * C, P * C, y * C], v = [-1 * f * C, -1 * P * C, -1 * y * C], x = R(i, n), w = R(i, m), I = R(n, m), O = R(i, v), N = R(n, v);
730
+ function Wt(o, e, t) {
731
+ const i = me(o), n = me(e), s = me(t), [r, a, l] = s, [d, c, h] = function(j, q) {
732
+ const [Ee, Fe, De] = j, [Oe, _e, Le] = q;
733
+ return [Fe * Le - De * _e, De * Oe - Ee * Le, Ee * _e - Fe * Oe];
734
+ }(i, n), u = c * l - h * a, p = h * r - d * l, g = d * a - c * r, y = g * c - p * h, P = u * h - g * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(P, 2) + Math.pow(f, 2)), C = [y * m, P * m, f * m], v = [-1 * y * m, -1 * P * m, -1 * f * m], S = R(i, n), w = R(i, C), I = R(n, C), O = R(i, v), B = R(n, v);
1081
735
  let _;
1082
- return _ = w < O && w < N || I < O && I < N ? m : v, R(i, _) > x || R(n, _) > x ? V(X(_), X(i)) <= V(X(_), X(n)) ? [X(i), !0, !1] : [X(n), !1, !0] : [X(_), !1, !1];
736
+ return _ = w < O && w < B || I < O && I < B ? C : v, R(i, _) > S || R(n, _) > S ? V(z(_), z(i)) <= V(z(_), z(n)) ? [z(i), !0, !1] : [z(n), !1, !0] : [z(_), !1, !1];
1083
737
  }
1084
- function ni(o, e, t) {
738
+ function jt(o, e, t) {
1085
739
  const i = e.x - o.x, n = e.y - o.y, s = Math.max(0, Math.min(1, ((t.x - o.x) * i + (t.y - o.y) * n) / (i * i + n * n)));
1086
740
  return { x: o.x + s * i, y: o.y + s * n };
1087
741
  }
1088
- class si extends W {
742
+ class Nt extends W {
1089
743
  constructor(e, t, i) {
1090
744
  super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (n, s) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== s)), this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
1091
745
  }
@@ -1103,35 +757,35 @@ class si extends W {
1103
757
  let d;
1104
758
  const c = [e.lng, e.lat];
1105
759
  if (this.config.projection === "web-mercator" ? d = function(u, p) {
1106
- let g = [1 / 0, 1 / 0], f = 1 / 0;
760
+ let g = [1 / 0, 1 / 0], y = 1 / 0;
1107
761
  for (let P of p) {
1108
- const y = P[0], C = P[1];
1109
- let m, v = 1 / 0;
1110
- const x = S(y[0], y[1]), w = S(C[0], C[1]), I = S(u[0], u[1]);
1111
- if (y[0] === u[0] && y[1] === u[1]) m = y;
1112
- else if (C[0] === u[0] && C[1] === u[1]) m = C;
762
+ const f = P[0], m = P[1];
763
+ let C, v = 1 / 0;
764
+ const S = x(f[0], f[1]), w = x(m[0], m[1]), I = x(u[0], u[1]);
765
+ if (f[0] === u[0] && f[1] === u[1]) C = f;
766
+ else if (m[0] === u[0] && m[1] === u[1]) C = m;
1113
767
  else {
1114
- const { x: O, y: N } = ni(x, w, I), { lng: _, lat: j } = k(O, N);
1115
- m = [_, j];
768
+ const { x: O, y: B } = jt(S, w, I), { lng: _, lat: j } = k(O, B);
769
+ C = [_, j];
1116
770
  }
1117
- m && (v = F(I, S(m[0], m[1])), v < f && (g = m, f = v));
771
+ C && (v = D(I, x(C[0], C[1])), v < y && (g = C, y = v));
1118
772
  }
1119
- return f === 1 / 0 ? void 0 : { coordinate: g, distance: f };
773
+ return y === 1 / 0 ? void 0 : { coordinate: g, distance: y };
1120
774
  }(c, l) : this.config.projection === "globe" && (d = function(u, p) {
1121
- let g = [1 / 0, 1 / 0], f = 1 / 0;
775
+ let g = [1 / 0, 1 / 0], y = 1 / 0;
1122
776
  for (let P of p) {
1123
- const y = P[0], C = P[1];
1124
- let m, v = 1 / 0;
1125
- y[0] === u[0] && y[1] === u[1] ? m = y : C[0] === u[0] && C[1] === u[1] ? m = C : [m] = ii(y, C, u), m && (v = V(u, m), v < f && (g = m, f = v));
777
+ const f = P[0], m = P[1];
778
+ let C, v = 1 / 0;
779
+ f[0] === u[0] && f[1] === u[1] ? C = f : m[0] === u[0] && m[1] === u[1] ? C = m : [C] = Wt(f, m, u), C && (v = V(u, C), v < y && (g = C, y = v));
1126
780
  }
1127
- return f === 1 / 0 ? void 0 : { coordinate: g, distance: f };
781
+ return y === 1 / 0 ? void 0 : { coordinate: g, distance: y };
1128
782
  }(c, l)), !d) return;
1129
783
  const h = this.pixelDistance.measure(e, d.coordinate);
1130
784
  h < s.minDistance && h < this.pointerDistance && (s.coord = d.coordinate, s.minDistance = h);
1131
785
  }), s.coord;
1132
786
  }
1133
787
  }
1134
- class xt extends B {
788
+ class at extends N {
1135
789
  constructor(e) {
1136
790
  super(e), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.snappedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
1137
791
  const t = { start: "crosshair", close: "pointer" };
@@ -1149,8 +803,8 @@ class xt extends B {
1149
803
  this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.snappedPointId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
1150
804
  }
1151
805
  registerBehaviors(e) {
1152
- const t = new ke(e);
1153
- this.pixelDistance = new We(e), this.lineSnapping = new si(e, this.pixelDistance, t), this.coordinateSnapping = new mt(e, this.pixelDistance, t), this.closingPoints = new ti(e, this.pixelDistance);
806
+ const t = new we(e);
807
+ this.pixelDistance = new be(e), this.lineSnapping = new Nt(e, this.pixelDistance, t), this.coordinateSnapping = new nt(e, this.pixelDistance, t), this.closingPoints = new kt(e, this.pixelDistance);
1154
808
  }
1155
809
  start() {
1156
810
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -1164,7 +818,7 @@ class xt extends B {
1164
818
  if (t) {
1165
819
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: t } }]);
1166
820
  else {
1167
- const [s] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [Oe]: !0 } }]);
821
+ const [s] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [xe]: !0 } }]);
1168
822
  this.snappedPointId = s;
1169
823
  }
1170
824
  e.lng = t[0], e.lat = t[1];
@@ -1210,20 +864,20 @@ class xt extends B {
1210
864
  const t = this.snapCoordinate(e);
1211
865
  t && (e.lng = t[0], e.lat = t[1]);
1212
866
  const i = this.store.getGeometryCopy(this.currentId);
1213
- if (ee([e.lng, e.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [e.lng, e.lat], [e.lng, e.lat], i.coordinates[0][0]], b.Commit)) return;
867
+ if (J([e.lng, e.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [e.lng, e.lat], [e.lng, e.lat], i.coordinates[0][0]], b.Commit)) return;
1214
868
  this.currentCoordinate++;
1215
869
  } else if (this.currentCoordinate === 2 && this.currentId) {
1216
870
  const t = this.snapCoordinate(e);
1217
871
  t && (e.lng = t[0], e.lat = t[1]);
1218
872
  const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
1219
- if (ee([e.lng, e.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [e.lng, e.lat], [e.lng, e.lat], i[0]], b.Commit)) return;
873
+ if (J([e.lng, e.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [e.lng, e.lat], [e.lng, e.lat], i[0]], b.Commit)) return;
1220
874
  this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.currentCoordinate++;
1221
875
  } else if (this.currentId) {
1222
876
  const t = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: n } = this.closingPoints.isClosingPoint(e);
1223
877
  if (n || i) this.close();
1224
878
  else {
1225
879
  const s = this.snapCoordinate(e);
1226
- if (s && (e.lng = s[0], e.lat = s[1]), ee([e.lng, e.lat], t[this.currentCoordinate - 1])) return;
880
+ if (s && (e.lng = s[0], e.lat = s[1]), J([e.lng, e.lat], t[this.currentCoordinate - 1])) return;
1227
881
  const r = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
1228
882
  return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
1229
883
  }([[...t.slice(0, -1), [e.lng, e.lat], t[0]]]);
@@ -1258,17 +912,17 @@ class xt extends B {
1258
912
  if (e.properties.mode === this.mode) {
1259
913
  if (e.geometry.type === "Polygon") return t.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, t.polygonFillColor, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, t.polygonFillOpacity, e), t.zIndex = 10, t;
1260
914
  if (e.geometry.type === "Point") {
1261
- const i = e.properties[ae], n = e.properties[Oe];
915
+ const i = e.properties[ie], n = e.properties[xe];
1262
916
  return t.pointWidth = this.getNumericStylingValue(i ? this.styles.closingPointWidth : n ? this.styles.snappingPointWidth : t.pointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(i ? this.styles.closingPointColor : n ? this.styles.snappingPointColor : t.pointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.closingPointOutlineColor : n ? this.styles.snappingPointOutlineColor : t.pointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.closingPointOutlineWidth : n ? this.styles.snappingPointOutlineWidth : 2, 2, e), t.zIndex = 30, t;
1263
917
  }
1264
918
  }
1265
919
  return t;
1266
920
  }
1267
921
  validateFeature(e) {
1268
- return this.validateModeFeature(e, (t) => Se(t, this.coordinatePrecision));
922
+ return this.validateModeFeature(e, (t) => ye(t, this.coordinatePrecision));
1269
923
  }
1270
924
  }
1271
- class St extends B {
925
+ class lt extends N {
1272
926
  constructor(e) {
1273
927
  super(e), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
1274
928
  const t = { start: "crosshair" };
@@ -1325,12 +979,12 @@ class St extends B {
1325
979
  return e.type === "Feature" && e.geometry.type === "Polygon" && e.properties.mode === this.mode && (t.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, t.polygonFillColor, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, t.polygonFillOpacity, e), t.zIndex = 10), t;
1326
980
  }
1327
981
  validateFeature(e) {
1328
- return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
982
+ return this.validateModeFeature(e, (t) => se(t, this.coordinatePrecision));
1329
983
  }
1330
984
  }
1331
- class ie extends B {
985
+ class Q extends N {
1332
986
  constructor(e) {
1333
- super({ styles: e.styles }), this.type = K.Render, this.mode = "render", this.mode = e.modeName;
987
+ super({ styles: e.styles }), this.type = X.Render, this.mode = "render", this.mode = e.modeName;
1334
988
  }
1335
989
  registerBehaviors(e) {
1336
990
  this.mode = e.mode;
@@ -1363,50 +1017,50 @@ class ie extends B {
1363
1017
  validateFeature(e) {
1364
1018
  const t = super.validateFeature(e);
1365
1019
  if (t.valid) {
1366
- const i = e, n = vt(i, this.coordinatePrecision).valid || Se(i, this.coordinatePrecision).valid || Ct(i, this.coordinatePrecision).valid;
1020
+ const i = e, n = rt(i, this.coordinatePrecision).valid || ye(i, this.coordinatePrecision).valid || st(i, this.coordinatePrecision).valid;
1367
1021
  return n ? { valid: !0 } : { valid: n, reason: "Feature is not a valid Point, Polygon or LineString feature" };
1368
1022
  }
1369
1023
  return t;
1370
1024
  }
1371
1025
  }
1372
- function Ce(o, e) {
1373
- const t = o, i = e, n = D(t[1]), s = D(i[1]);
1374
- let r = D(i[0] - t[0]);
1026
+ function he(o, e) {
1027
+ const t = o, i = e, n = F(t[1]), s = F(i[1]);
1028
+ let r = F(i[0] - t[0]);
1375
1029
  r > Math.PI && (r -= 2 * Math.PI), r < -Math.PI && (r += 2 * Math.PI);
1376
1030
  const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), l = (U(Math.atan2(r, a)) + 360) % 360;
1377
1031
  return l > 180 ? -(360 - l) : l;
1378
1032
  }
1379
- function je(o, e, t) {
1033
+ function Ie(o, e, t) {
1380
1034
  let i = e;
1381
1035
  e < 0 && (i = -Math.abs(i));
1382
- const n = i / _e, s = o[0] * Math.PI / 180, r = D(o[1]), a = D(t), l = n * Math.cos(a);
1036
+ const n = i / Ze, s = o[0] * Math.PI / 180, r = F(o[1]), a = F(t), l = n * Math.cos(a);
1383
1037
  let d = r + l;
1384
1038
  Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
1385
1039
  const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(r / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(r), u = [(180 * (s + n * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1386
1040
  return u[0] += u[0] - o[0] > 180 ? -360 : o[0] - u[0] > 180 ? 360 : 0, u;
1387
1041
  }
1388
- function Mt(o, e, t, i, n) {
1042
+ function dt(o, e, t, i, n) {
1389
1043
  const s = i(o[0], o[1]), r = i(e[0], e[1]), { lng: a, lat: l } = n((s.x + r.x) / 2, (s.y + r.y) / 2);
1390
1044
  return [E(a, t), E(l, t)];
1391
1045
  }
1392
- function oi(o, e, t) {
1393
- const i = je(o, 1e3 * V(o, e) / 2, Ce(o, e));
1046
+ function Bt(o, e, t) {
1047
+ const i = Ie(o, 1e3 * V(o, e) / 2, he(o, e));
1394
1048
  return [E(i[0], t), E(i[1], t)];
1395
1049
  }
1396
- function nt({ featureCoords: o, precision: e, unproject: t, project: i, projection: n }) {
1050
+ function Ue({ featureCoords: o, precision: e, unproject: t, project: i, projection: n }) {
1397
1051
  const s = [];
1398
1052
  for (let r = 0; r < o.length - 1; r++) {
1399
1053
  let a;
1400
- if (n === "web-mercator") a = Mt(o[r], o[r + 1], e, i, t);
1054
+ if (n === "web-mercator") a = dt(o[r], o[r + 1], e, i, t);
1401
1055
  else {
1402
1056
  if (n !== "globe") throw new Error("Invalid projection");
1403
- a = oi(o[r], o[r + 1], e);
1057
+ a = Bt(o[r], o[r + 1], e);
1404
1058
  }
1405
1059
  s.push(a);
1406
1060
  }
1407
1061
  return s;
1408
1062
  }
1409
- class ri extends W {
1063
+ class At extends W {
1410
1064
  constructor(e, t) {
1411
1065
  super(e), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = e, this.selectionPointBehavior = t;
1412
1066
  }
@@ -1422,17 +1076,17 @@ class ri extends W {
1422
1076
  create(e, t, i) {
1423
1077
  if (!this.store.has(t)) throw new Error("Store does not have feature with this id");
1424
1078
  this._midPoints = this.store.create(function(n, s, r, a, l, d) {
1425
- return nt({ featureCoords: n, precision: r, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1426
- }(e, (n) => ({ mode: this.mode, [oe]: !0, midPointSegment: n, midPointFeatureId: t }), i, this.config.project, this.config.unproject, this.projection));
1079
+ return Ue({ featureCoords: n, precision: r, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1080
+ }(e, (n) => ({ mode: this.mode, [T.MID_POINT]: !0, midPointSegment: n, midPointFeatureId: t }), i, this.config.project, this.config.unproject, this.projection));
1427
1081
  }
1428
1082
  delete() {
1429
1083
  this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
1430
1084
  }
1431
1085
  getUpdated(e) {
1432
- if (this._midPoints.length !== 0) return nt({ featureCoords: e, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((t, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: t } }));
1086
+ if (this._midPoints.length !== 0) return Ue({ featureCoords: e, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((t, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: t } }));
1433
1087
  }
1434
1088
  }
1435
- class ai extends W {
1089
+ class Gt extends W {
1436
1090
  constructor(e) {
1437
1091
  super(e), this._selectionPoints = [];
1438
1092
  }
@@ -1458,7 +1112,7 @@ class ai extends W {
1458
1112
  if (this._selectionPoints[e] !== void 0) return { id: this._selectionPoints[e], geometry: { type: "Point", coordinates: t } };
1459
1113
  }
1460
1114
  }
1461
- function wt(o, e) {
1115
+ function ct(o, e) {
1462
1116
  let t = !1;
1463
1117
  for (let r = 0, a = e.length; r < a; r++) {
1464
1118
  const l = e[r];
@@ -1467,7 +1121,7 @@ function wt(o, e) {
1467
1121
  var i, n, s;
1468
1122
  return t;
1469
1123
  }
1470
- const bt = (o, e, t) => {
1124
+ const ht = (o, e, t) => {
1471
1125
  const i = (s) => s * s, n = (s, r) => i(s.x - r.x) + i(s.y - r.y);
1472
1126
  return Math.sqrt(((s, r, a) => {
1473
1127
  const l = n(r, a);
@@ -1476,7 +1130,7 @@ const bt = (o, e, t) => {
1476
1130
  return d = Math.max(0, Math.min(1, d)), n(s, { x: r.x + d * (a.x - r.x), y: r.y + d * (a.y - r.y) });
1477
1131
  })(o, e, t));
1478
1132
  };
1479
- class li extends W {
1133
+ class Vt extends W {
1480
1134
  constructor(e, t, i) {
1481
1135
  super(e), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = e, this.createClickBoundingBox = t, this.pixelDistance = i;
1482
1136
  }
@@ -1486,24 +1140,24 @@ class li extends W {
1486
1140
  for (let u = 0; u < h.length; u++) {
1487
1141
  const p = h[u], g = p.geometry;
1488
1142
  if (g.type === "Point") {
1489
- if (p.properties.selectionPoint || !t && p.properties[oe]) continue;
1490
- const f = this.pixelDistance.measure(e, g.coordinates);
1491
- p.properties[oe] && f < this.pointerDistance && f < d ? (d = f, s = p) : !p.properties[oe] && f < this.pointerDistance && f < a && (a = f, i = p);
1143
+ if (p.properties.selectionPoint || !t && p.properties[T.MID_POINT]) continue;
1144
+ const y = this.pixelDistance.measure(e, g.coordinates);
1145
+ p.properties[T.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, s = p) : !p.properties[T.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
1492
1146
  } else if (g.type === "LineString") {
1493
1147
  if (i) continue;
1494
- for (let f = 0; f < g.coordinates.length - 1; f++) {
1495
- const P = g.coordinates[f], y = g.coordinates[f + 1], C = bt({ x: e.containerX, y: e.containerY }, this.project(P[0], P[1]), this.project(y[0], y[1]));
1496
- C < this.pointerDistance && C < l && (l = C, n = p);
1148
+ for (let y = 0; y < g.coordinates.length - 1; y++) {
1149
+ const P = g.coordinates[y], f = g.coordinates[y + 1], m = ht({ x: e.containerX, y: e.containerY }, this.project(P[0], P[1]), this.project(f[0], f[1]));
1150
+ m < this.pointerDistance && m < l && (l = m, n = p);
1497
1151
  }
1498
1152
  } else if (g.type === "Polygon") {
1499
1153
  if (i || n) continue;
1500
- wt([e.lng, e.lat], g.coordinates) && (r = p);
1154
+ ct([e.lng, e.lat], g.coordinates) && (r = p);
1501
1155
  }
1502
1156
  }
1503
1157
  return { clickedFeature: i || n || r, clickedMidPoint: s };
1504
1158
  }
1505
1159
  }
1506
- class di extends W {
1160
+ class Tt extends W {
1507
1161
  constructor(e, t, i, n) {
1508
1162
  super(e), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = e, this.featuresAtCursorEvent = t, this.selectionPoints = i, this.midPoints = n;
1509
1163
  }
@@ -1530,8 +1184,8 @@ class di extends W {
1530
1184
  const c = s[d];
1531
1185
  let h, u;
1532
1186
  if (this.config.projection === "web-mercator") {
1533
- const p = S(this.dragPosition[0], this.dragPosition[1]), g = S(n[0], n[1]), f = S(c[0], c[1]), P = { x: p.x - g.x, y: p.y - g.y }, y = f.x - P.x, C = f.y - P.y, { lng: m, lat: v } = k(y, C);
1534
- h = m, u = v;
1187
+ const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(n[0], n[1]), y = x(c[0], c[1]), P = { x: p.x - g.x, y: p.y - g.y }, f = y.x - P.x, m = y.y - P.y, { lng: C, lat: v } = k(f, m);
1188
+ h = C, u = v;
1535
1189
  } else {
1536
1190
  const p = [this.dragPosition[0] - n[0], this.dragPosition[1] - n[1]];
1537
1191
  h = c[0] - p[0], u = c[1] - p[1];
@@ -1546,7 +1200,7 @@ class di extends W {
1546
1200
  } else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: n } }]), this.dragPosition = [e.lng, e.lat]);
1547
1201
  }
1548
1202
  }
1549
- class ci extends W {
1203
+ class Ut extends W {
1550
1204
  constructor(e, t, i, n) {
1551
1205
  super(e), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = e, this.pixelDistance = t, this.selectionPoints = i, this.midPoints = n;
1552
1206
  }
@@ -1581,7 +1235,7 @@ class ci extends W {
1581
1235
  r[0] = a, r[h] = a;
1582
1236
  }
1583
1237
  const l = this.selectionPoints.getOneUpdated(n, a), d = l ? [l] : [], c = this.midPoints.getUpdated(r) || [];
1584
- return !(s.type !== "Point" && !t && Le({ type: "Feature", geometry: s, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...c]), 0));
1238
+ return !(s.type !== "Point" && !t && Me({ type: "Feature", geometry: s, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...c]), 0));
1585
1239
  }
1586
1240
  isDragging() {
1587
1241
  return this.draggedCoordinate.id !== null;
@@ -1593,23 +1247,23 @@ class ci extends W {
1593
1247
  this.draggedCoordinate = { id: null, index: -1 };
1594
1248
  }
1595
1249
  }
1596
- function Pe(o) {
1250
+ function ue(o) {
1597
1251
  let e = 0, t = 0, i = 0;
1598
1252
  return (o.geometry.type === "Polygon" ? o.geometry.coordinates[0].slice(0, -1) : o.geometry.coordinates).forEach((n) => {
1599
1253
  e += n[0], t += n[1], i++;
1600
1254
  }, !0), [e / i, t / i];
1601
1255
  }
1602
- function It(o, e) {
1256
+ function ut(o, e) {
1603
1257
  o[0] += o[0] - e[0] > 180 ? -360 : e[0] - o[0] > 180 ? 360 : 0;
1604
- const t = _e, i = e[1] * Math.PI / 180, n = o[1] * Math.PI / 180, s = n - i;
1258
+ const t = Ze, i = e[1] * Math.PI / 180, n = o[1] * Math.PI / 180, s = n - i;
1605
1259
  let r = Math.abs(o[0] - e[0]) * Math.PI / 180;
1606
1260
  r > Math.PI && (r -= 2 * Math.PI);
1607
1261
  const a = Math.log(Math.tan(n / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? s / a : Math.cos(i);
1608
1262
  return Math.sqrt(s * s + l * l * r * r) * t;
1609
1263
  }
1610
- function ve(o) {
1264
+ function pe(o) {
1611
1265
  const e = (o.geometry.type === "Polygon" ? o.geometry.coordinates[0] : o.geometry.coordinates).map((t) => {
1612
- const { x: i, y: n } = S(t[0], t[1]);
1266
+ const { x: i, y: n } = x(t[0], t[1]);
1613
1267
  return [i, n];
1614
1268
  });
1615
1269
  return o.geometry.type === "Polygon" ? function(t) {
@@ -1630,7 +1284,7 @@ function ve(o) {
1630
1284
  return { x: n / i, y: s / i };
1631
1285
  }(e);
1632
1286
  }
1633
- class hi extends W {
1287
+ class Rt extends W {
1634
1288
  constructor(e, t, i) {
1635
1289
  super(e), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = e, this.selectionPoints = t, this.midPoints = i;
1636
1290
  }
@@ -1644,23 +1298,23 @@ class hi extends W {
1644
1298
  let r;
1645
1299
  const a = { type: "Feature", geometry: n, properties: {} };
1646
1300
  if (this.config.projection === "web-mercator") {
1647
- if (r = G(ve(a), S(e.lng, e.lat)), !this.lastBearing) return void (this.lastBearing = r);
1301
+ if (r = G(pe(a), x(e.lng, e.lat)), !this.lastBearing) return void (this.lastBearing = r);
1648
1302
  ((h, u) => {
1649
1303
  if (u === 0 || u === 360 || u === -360) return h;
1650
- const p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([y, C]) => S(y, C)), f = g.reduce((y, C) => ({ x: y.x + C.x, y: y.y + C.y }), { x: 0, y: 0 });
1651
- f.x /= g.length, f.y /= g.length;
1652
- const P = g.map((y) => ({ x: f.x + (y.x - f.x) * Math.cos(p) - (y.y - f.y) * Math.sin(p), y: f.y + (y.x - f.x) * Math.sin(p) + (y.y - f.y) * Math.cos(p) })).map(({ x: y, y: C }) => [k(y, C).lng, k(y, C).lat]);
1304
+ const p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, m]) => x(f, m)), y = g.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
1305
+ y.x /= g.length, y.y /= g.length;
1306
+ const P = g.map((f) => ({ x: y.x + (f.x - y.x) * Math.cos(p) - (f.y - y.y) * Math.sin(p), y: y.y + (f.x - y.x) * Math.sin(p) + (f.y - y.y) * Math.cos(p) })).map(({ x: f, y: m }) => [k(f, m).lng, k(f, m).lat]);
1653
1307
  h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = P : h.geometry.coordinates = P;
1654
1308
  })(a, -(this.lastBearing - r));
1655
1309
  } else {
1656
1310
  if (this.config.projection !== "globe") throw new Error("Unsupported projection");
1657
- if (r = Ce(Pe({ type: "Feature", geometry: n, properties: {} }), s), !this.lastBearing) return void (this.lastBearing = r + 180);
1311
+ if (r = he(ue({ type: "Feature", geometry: n, properties: {} }), s), !this.lastBearing) return void (this.lastBearing = r + 180);
1658
1312
  (function(h, u) {
1659
1313
  if (u === 0 || u === 360 || u === -360) return h;
1660
- const p = Pe(h);
1314
+ const p = ue(h);
1661
1315
  (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((g) => {
1662
- const f = Ce(p, g) + u, P = It(p, g), y = je(p, P, f);
1663
- g[0] = y[0], g[1] = y[1];
1316
+ const y = he(p, g) + u, P = ut(p, g), f = Ie(p, P, y);
1317
+ g[0] = f[0], g[1] = f[1];
1664
1318
  });
1665
1319
  })(a, -(this.lastBearing - (r + 180)));
1666
1320
  }
@@ -1673,7 +1327,7 @@ class hi extends W {
1673
1327
  this.store.updateGeometry([{ id: t, geometry: n }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = r : this.projection === "globe" && (this.lastBearing = r + 180);
1674
1328
  }
1675
1329
  }
1676
- class ui extends W {
1330
+ class zt extends W {
1677
1331
  constructor(e, t, i) {
1678
1332
  super(e), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = e, this.selectionPoints = t, this.midPoints = i;
1679
1333
  }
@@ -1685,29 +1339,29 @@ class ui extends W {
1685
1339
  if (n.type !== "Polygon" && n.type !== "LineString") return;
1686
1340
  const s = [e.lng, e.lat], r = { type: "Feature", geometry: n, properties: {} };
1687
1341
  let a;
1688
- const l = ve(r);
1342
+ const l = pe(r);
1689
1343
  if (this.config.projection === "web-mercator") {
1690
- const p = S(e.lng, e.lat);
1691
- a = F(l, p);
1344
+ const p = x(e.lng, e.lat);
1345
+ a = D(l, p);
1692
1346
  } else {
1693
1347
  if (this.config.projection !== "globe") throw new Error("Invalid projection");
1694
- a = V(Pe({ type: "Feature", geometry: n, properties: {} }), s);
1348
+ a = V(ue({ type: "Feature", geometry: n, properties: {} }), s);
1695
1349
  }
1696
1350
  if (!this.lastDistance) return void (this.lastDistance = a);
1697
1351
  const d = 1 - (this.lastDistance - a) / a;
1698
1352
  if (this.config.projection === "web-mercator") {
1699
1353
  const { lng: p, lat: g } = k(l.x, l.y);
1700
- (function(f, P, y) {
1701
- if (P === 1) return f;
1702
- const C = (f.geometry.type === "Polygon" ? f.geometry.coordinates[0] : f.geometry.coordinates).map(([x, w]) => S(x, w)), m = S(y[0], y[1]), v = C.map((x) => ({ x: m.x + (x.x - m.x) * P, y: m.y + (x.y - m.y) * P })).map(({ x, y: w }) => [k(x, w).lng, k(x, w).lat]);
1703
- f.geometry.type === "Polygon" ? f.geometry.coordinates[0] = v : f.geometry.coordinates = v;
1354
+ (function(y, P, f) {
1355
+ if (P === 1) return y;
1356
+ const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, w]) => x(S, w)), C = x(f[0], f[1]), v = m.map((S) => ({ x: C.x + (S.x - C.x) * P, y: C.y + (S.y - C.y) * P })).map(({ x: S, y: w }) => [k(S, w).lng, k(S, w).lat]);
1357
+ y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = v : y.geometry.coordinates = v;
1704
1358
  })(r, d, [p, g]);
1705
- } else this.config.projection === "globe" && function(p, g, f, P = "xy") {
1706
- g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((y) => {
1707
- const C = It(f, y), m = Ce(f, y), v = je(f, C * g, m);
1708
- P !== "x" && P !== "xy" || (y[0] = v[0]), P !== "y" && P !== "xy" || (y[1] = v[1]);
1359
+ } else this.config.projection === "globe" && function(p, g, y, P = "xy") {
1360
+ g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
1361
+ const m = ut(y, f), C = he(y, f), v = Ie(y, m * g, C);
1362
+ P !== "x" && P !== "xy" || (f[0] = v[0]), P !== "y" && P !== "xy" || (f[1] = v[1]);
1709
1363
  });
1710
- }(r, d, Pe(r));
1364
+ }(r, d, ue(r));
1711
1365
  const c = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
1712
1366
  c.forEach((p) => {
1713
1367
  p[0] = E(p[0], this.coordinatePrecision), p[1] = E(p[1], this.coordinatePrecision);
@@ -1717,7 +1371,7 @@ class ui extends W {
1717
1371
  this.store.updateGeometry([{ id: t, geometry: n }, ...u, ...h]), this.lastDistance = a;
1718
1372
  }
1719
1373
  }
1720
- class pi extends W {
1374
+ class Kt extends W {
1721
1375
  constructor(e, t, i, n) {
1722
1376
  super(e), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.minimumScale = 1e-4, this.draggedCoordinate = { id: null, index: -1 }, this.boundingBoxMaps = { opposite: { 0: 4, 1: 5, 2: 6, 3: 7, 4: 0, 5: 1, 6: 2, 7: 3 } }, this.config = e, this.pixelDistance = t, this.selectionPoints = i, this.midPoints = n;
1723
1377
  }
@@ -1776,34 +1430,34 @@ class pi extends W {
1776
1430
  centerWebMercatorDrag(e) {
1777
1431
  const t = this.getSelectedFeatureDataWebMercator();
1778
1432
  if (!t) return null;
1779
- const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a = ve(i);
1433
+ const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a = pe(i);
1780
1434
  if (!a) return null;
1781
- const l = S(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), c = S(e.lng, e.lat);
1435
+ const l = x(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), c = x(e.lng, e.lat);
1782
1436
  return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1783
1437
  }
1784
1438
  centerFixedWebMercatorDrag(e) {
1785
1439
  const t = this.getSelectedFeatureDataWebMercator();
1786
1440
  if (!t) return null;
1787
- const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a = ve(i);
1441
+ const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a = pe(i);
1788
1442
  if (!a) return null;
1789
- const l = S(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), c = S(e.lng, e.lat);
1443
+ const l = x(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), c = x(e.lng, e.lat);
1790
1444
  return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1791
1445
  }
1792
1446
  scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: s }) {
1793
1447
  if (!this.isValidDragWebMercator(e, t.x - n.x, t.y - n.y)) return null;
1794
- let r = F(t, n) / F(t, i);
1448
+ let r = D(t, n) / D(t, i);
1795
1449
  return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(s, t.x, t.y, r, r), s;
1796
1450
  }
1797
1451
  oppositeFixedWebMercatorDrag(e) {
1798
1452
  const t = this.getSelectedFeatureDataWebMercator();
1799
1453
  if (!t) return null;
1800
- const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = S(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = S(e.lng, e.lat);
1454
+ const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = x(e.lng, e.lat);
1801
1455
  return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor: c, webMercatorSelected: r, webMercatorOrigin: d }), n;
1802
1456
  }
1803
1457
  oppositeWebMercatorDrag(e) {
1804
1458
  const t = this.getSelectedFeatureDataWebMercator();
1805
1459
  if (!t) return null;
1806
- const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = S(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = S(e.lng, e.lat);
1460
+ const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = x(e.lng, e.lat);
1807
1461
  return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor: c, webMercatorSelected: r, webMercatorOrigin: d }), n;
1808
1462
  }
1809
1463
  scaleWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: s }) {
@@ -1828,14 +1482,14 @@ class pi extends W {
1828
1482
  }
1829
1483
  performWebMercatorScale(e, t, i, n, s) {
1830
1484
  e.forEach((r) => {
1831
- const { x: a, y: l } = S(r[0], r[1]), d = t + (a - t) * n, c = i + (l - i) * s, { lng: h, lat: u } = k(d, c);
1485
+ const { x: a, y: l } = x(r[0], r[1]), d = t + (a - t) * n, c = i + (l - i) * s, { lng: h, lat: u } = k(d, c);
1832
1486
  r[0] = h, r[1] = u;
1833
1487
  });
1834
1488
  }
1835
1489
  getBBoxWebMercator(e) {
1836
1490
  const t = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
1837
1491
  (e = e.map((a) => {
1838
- const { x: l, y: d } = S(a[0], a[1]);
1492
+ const { x: l, y: d } = x(a[0], a[1]);
1839
1493
  return [l, d];
1840
1494
  })).forEach(([a, l]) => {
1841
1495
  a < t[0] && (t[0] = a), l < t[1] && (t[1] = l), a > t[2] && (t[2] = a), l > t[3] && (t[3] = l);
@@ -1846,7 +1500,7 @@ class pi extends W {
1846
1500
  getIndexesWebMercator(e, t) {
1847
1501
  let i, n = 1 / 0;
1848
1502
  for (let s = 0; s < e.length; s++) {
1849
- const r = F({ x: t.x, y: t.y }, { x: e[s][0], y: e[s][1] });
1503
+ const r = D({ x: t.x, y: t.y }, { x: e[s][0], y: e[s][1] });
1850
1504
  r < n && (i = s, n = r);
1851
1505
  }
1852
1506
  if (i === void 0) throw new Error("No closest coordinate found");
@@ -1873,13 +1527,13 @@ class pi extends W {
1873
1527
  if (t === "center" ? s = this.centerWebMercatorDrag(e) : t === "opposite" ? s = this.oppositeWebMercatorDrag(e) : t === "center-fixed" ? s = this.centerFixedWebMercatorDrag(e) : t === "opposite-fixed" && (s = this.oppositeFixedWebMercatorDrag(e)), !s) return !1;
1874
1528
  for (let d = 0; d < s.length; d++) {
1875
1529
  const c = s[d];
1876
- if (c[0] = E(c[0], this.coordinatePrecision), c[1] = E(c[1], this.coordinatePrecision), !xe(c, this.coordinatePrecision)) return !1;
1530
+ if (c[0] = E(c[0], this.coordinatePrecision), c[1] = E(c[1], this.coordinatePrecision), !ge(c, this.coordinatePrecision)) return !1;
1877
1531
  }
1878
1532
  const r = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: n.geometry.type, coordinates: n.geometry.type === "Polygon" ? [s] : s };
1879
1533
  return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: l, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...r]), 0));
1880
1534
  }
1881
1535
  }
1882
- class gi extends Rt {
1536
+ class Xt extends xt {
1883
1537
  constructor(e) {
1884
1538
  var t;
1885
1539
  super(e), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = void 0, this.keyEvents = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.cursors = void 0, this.validations = {}, this.flags = e && e.flags ? e.flags : {};
@@ -1902,13 +1556,13 @@ class gi extends Rt {
1902
1556
  this._state = "selecting";
1903
1557
  }
1904
1558
  registerBehaviors(e) {
1905
- this.pixelDistance = new We(e), this.clickBoundingBox = new ke(e), this.featuresAtMouseEvent = new li(e, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new ai(e), this.midPoints = new ri(e, this.selectionPoints), this.rotateFeature = new hi(e, this.selectionPoints, this.midPoints), this.scaleFeature = new ui(e, this.selectionPoints, this.midPoints), this.dragFeature = new di(e, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new ci(e, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new pi(e, this.pixelDistance, this.selectionPoints, this.midPoints);
1559
+ this.pixelDistance = new be(e), this.clickBoundingBox = new we(e), this.featuresAtMouseEvent = new Vt(e, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Gt(e), this.midPoints = new At(e, this.selectionPoints), this.rotateFeature = new Rt(e, this.selectionPoints, this.midPoints), this.scaleFeature = new zt(e, this.selectionPoints, this.midPoints), this.dragFeature = new Tt(e, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new Ut(e, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Kt(e, this.pixelDistance, this.selectionPoints, this.midPoints);
1906
1560
  }
1907
1561
  deselectFeature() {
1908
1562
  this.deselect();
1909
1563
  }
1910
1564
  deselect() {
1911
- const e = this.selected.filter((t) => this.store.has(t)).map((t) => ({ id: t, property: De, value: !1 }));
1565
+ const e = this.selected.filter((t) => this.store.has(t)).map((t) => ({ id: t, property: T.SELECTED, value: !1 }));
1912
1566
  this.store.updateProperty(e), this.onDeselect(this.selected[0]), this.selected = [], this.selectionPoints.delete(), this.midPoints.delete();
1913
1567
  }
1914
1568
  deleteSelected() {
@@ -2032,7 +1686,7 @@ class gi extends Rt {
2032
1686
  if (e.properties.mode === this.mode && e.geometry.type === "Point") {
2033
1687
  if (e.properties.selectionPoint) return t.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, t.pointOutlineColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, t.pointWidth, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, e), t.zIndex = 30, t;
2034
1688
  if (e.properties.midPoint) return t.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, t.pointOutlineColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, e), t.zIndex = 40, t;
2035
- } else if (e.properties[De]) {
1689
+ } else if (e.properties[T.SELECTED]) {
2036
1690
  if (e.geometry.type === "Polygon") return t.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, t.polygonFillColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, t.polygonOutlineWidth, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, t.polygonOutlineColor, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, t.polygonFillOpacity, e), t.zIndex = 10, t;
2037
1691
  if (e.geometry.type === "LineString") return t.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, t.lineStringColor, e), t.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, t.lineStringWidth, e), t.zIndex = 10, t;
2038
1692
  if (e.geometry.type === "Point") return t.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, t.pointOutlineWidth, e), t.zIndex = 10, t;
@@ -2040,9 +1694,9 @@ class gi extends Rt {
2040
1694
  return t;
2041
1695
  }
2042
1696
  }
2043
- class fi extends B {
1697
+ class Yt extends N {
2044
1698
  constructor(...e) {
2045
- super(...e), this.type = K.Static, this.mode = "static";
1699
+ super(...e), this.type = X.Static, this.mode = "static";
2046
1700
  }
2047
1701
  start() {
2048
1702
  }
@@ -2068,85 +1722,85 @@ class fi extends B {
2068
1722
  return M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2069
1723
  }
2070
1724
  }
2071
- function Et(o, e, t, i, n) {
1725
+ function pt(o, e, t, i, n) {
2072
1726
  for (; i > t; ) {
2073
1727
  if (i - t > 600) {
2074
1728
  const l = i - t + 1, d = e - t + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
2075
- Et(o, e, Math.max(t, Math.floor(e - d * h / l + u)), Math.min(i, Math.floor(e + (l - d) * h / l + u)), n);
1729
+ pt(o, e, Math.max(t, Math.floor(e - d * h / l + u)), Math.min(i, Math.floor(e + (l - d) * h / l + u)), n);
2076
1730
  }
2077
1731
  const s = o[e];
2078
1732
  let r = t, a = i;
2079
- for (te(o, t, e), n(o[i], s) > 0 && te(o, t, i); r < a; ) {
2080
- for (te(o, r, a), r++, a--; n(o[r], s) < 0; ) r++;
1733
+ for (Z(o, t, e), n(o[i], s) > 0 && Z(o, t, i); r < a; ) {
1734
+ for (Z(o, r, a), r++, a--; n(o[r], s) < 0; ) r++;
2081
1735
  for (; n(o[a], s) > 0; ) a--;
2082
1736
  }
2083
- n(o[t], s) === 0 ? te(o, t, a) : (a++, te(o, a, i)), a <= e && (t = a + 1), e <= a && (i = a - 1);
1737
+ n(o[t], s) === 0 ? Z(o, t, a) : (a++, Z(o, a, i)), a <= e && (t = a + 1), e <= a && (i = a - 1);
2084
1738
  }
2085
1739
  }
2086
- function te(o, e, t) {
1740
+ function Z(o, e, t) {
2087
1741
  const i = o[e];
2088
1742
  o[e] = o[t], o[t] = i;
2089
1743
  }
2090
- function q(o, e) {
2091
- ne(o, 0, o.children.length, e, o);
1744
+ function Y(o, e) {
1745
+ ee(o, 0, o.children.length, e, o);
2092
1746
  }
2093
- function ne(o, e, t, i, n) {
2094
- n || (n = Z([])), n.minX = 1 / 0, n.minY = 1 / 0, n.maxX = -1 / 0, n.maxY = -1 / 0;
1747
+ function ee(o, e, t, i, n) {
1748
+ n || (n = $([])), n.minX = 1 / 0, n.minY = 1 / 0, n.maxX = -1 / 0, n.maxY = -1 / 0;
2095
1749
  for (let s = e; s < t; s++) {
2096
1750
  const r = o.children[s];
2097
- se(n, o.leaf ? i(r) : r);
1751
+ te(n, o.leaf ? i(r) : r);
2098
1752
  }
2099
1753
  return n;
2100
1754
  }
2101
- function se(o, e) {
1755
+ function te(o, e) {
2102
1756
  return o.minX = Math.min(o.minX, e.minX), o.minY = Math.min(o.minY, e.minY), o.maxX = Math.max(o.maxX, e.maxX), o.maxY = Math.max(o.maxY, e.maxY), o;
2103
1757
  }
2104
- function yi(o, e) {
1758
+ function Ht(o, e) {
2105
1759
  return o.minX - e.minX;
2106
1760
  }
2107
- function mi(o, e) {
1761
+ function $t(o, e) {
2108
1762
  return o.minY - e.minY;
2109
1763
  }
2110
- function Ie(o) {
1764
+ function Ce(o) {
2111
1765
  return (o.maxX - o.minX) * (o.maxY - o.minY);
2112
1766
  }
2113
- function pe(o) {
1767
+ function ae(o) {
2114
1768
  return o.maxX - o.minX + (o.maxY - o.minY);
2115
1769
  }
2116
- function Ci(o, e) {
1770
+ function Jt(o, e) {
2117
1771
  const t = Math.max(o.minX, e.minX), i = Math.max(o.minY, e.minY), n = Math.min(o.maxX, e.maxX), s = Math.min(o.maxY, e.maxY);
2118
1772
  return Math.max(0, n - t) * Math.max(0, s - i);
2119
1773
  }
2120
- function Ee(o, e) {
1774
+ function Pe(o, e) {
2121
1775
  return o.minX <= e.minX && o.minY <= e.minY && e.maxX <= o.maxX && e.maxY <= o.maxY;
2122
1776
  }
2123
- function ge(o, e) {
1777
+ function le(o, e) {
2124
1778
  return e.minX <= o.maxX && e.minY <= o.maxY && e.maxX >= o.minX && e.maxY >= o.minY;
2125
1779
  }
2126
- function Z(o) {
1780
+ function $(o) {
2127
1781
  return { children: o, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
2128
1782
  }
2129
- function st(o, e, t, i, n) {
1783
+ function Re(o, e, t, i, n) {
2130
1784
  const s = [e, t];
2131
1785
  for (; s.length; ) {
2132
1786
  if ((t = s.pop()) - (e = s.pop()) <= i) continue;
2133
1787
  const r = e + Math.ceil((t - e) / i / 2) * i;
2134
- Et(o, r, e, t, n), s.push(e, r, r, t);
1788
+ pt(o, r, e, t, n), s.push(e, r, r, t);
2135
1789
  }
2136
1790
  }
2137
- class Pi {
1791
+ class qt {
2138
1792
  constructor(e) {
2139
1793
  this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
2140
1794
  }
2141
1795
  search(e) {
2142
1796
  let t = this.data;
2143
1797
  const i = [];
2144
- if (!ge(e, t)) return i;
1798
+ if (!le(e, t)) return i;
2145
1799
  const n = this.toBBox, s = [];
2146
1800
  for (; t; ) {
2147
1801
  for (let r = 0; r < t.children.length; r++) {
2148
1802
  const a = t.children[r], l = t.leaf ? n(a) : a;
2149
- ge(e, l) && (t.leaf ? i.push(a) : Ee(e, l) ? this._all(a, i) : s.push(a));
1803
+ le(e, l) && (t.leaf ? i.push(a) : Pe(e, l) ? this._all(a, i) : s.push(a));
2150
1804
  }
2151
1805
  t = s.pop();
2152
1806
  }
@@ -2154,13 +1808,13 @@ class Pi {
2154
1808
  }
2155
1809
  collides(e) {
2156
1810
  let t = this.data;
2157
- if (ge(e, t)) {
1811
+ if (le(e, t)) {
2158
1812
  const i = [];
2159
1813
  for (; t; ) {
2160
1814
  for (let n = 0; n < t.children.length; n++) {
2161
1815
  const s = t.children[n], r = t.leaf ? this.toBBox(s) : s;
2162
- if (ge(e, r)) {
2163
- if (t.leaf || Ee(e, r)) return !0;
1816
+ if (le(e, r)) {
1817
+ if (t.leaf || Pe(e, r)) return !0;
2164
1818
  i.push(s);
2165
1819
  }
2166
1820
  }
@@ -2189,7 +1843,7 @@ class Pi {
2189
1843
  this._insert(e, this.data.height - 1);
2190
1844
  }
2191
1845
  clear() {
2192
- this.data = Z([]);
1846
+ this.data = $([]);
2193
1847
  }
2194
1848
  remove(e) {
2195
1849
  let t = this.data;
@@ -2200,7 +1854,7 @@ class Pi {
2200
1854
  const d = t.children.indexOf(e);
2201
1855
  d !== -1 && (t.children.splice(d, 1), n.push(t), this._condense(n));
2202
1856
  }
2203
- l || t.leaf || !Ee(t, i) ? a ? (r++, t = a.children[r], l = !1) : t = null : (n.push(t), s.push(r), r = 0, a = t, t = t.children[0]);
1857
+ l || t.leaf || !Pe(t, i) ? a ? (r++, t = a.children[r], l = !1) : t = null : (n.push(t), s.push(r), r = 0, a = t, t = t.children[0]);
2204
1858
  }
2205
1859
  }
2206
1860
  toBBox(e) {
@@ -2220,25 +1874,25 @@ class Pi {
2220
1874
  _build(e, t, i, n) {
2221
1875
  const s = i - t + 1;
2222
1876
  let r, a = this._maxEntries;
2223
- if (s <= a) return r = Z(e.slice(t, i + 1)), q(r, this.toBBox), r;
2224
- n || (n = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, n - 1))), r = Z([]), r.leaf = !1, r.height = n;
1877
+ if (s <= a) return r = $(e.slice(t, i + 1)), Y(r, this.toBBox), r;
1878
+ n || (n = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, n - 1))), r = $([]), r.leaf = !1, r.height = n;
2225
1879
  const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
2226
- st(e, t, i, d, this.compareMinX);
1880
+ Re(e, t, i, d, this.compareMinX);
2227
1881
  for (let c = t; c <= i; c += d) {
2228
1882
  const h = Math.min(c + d - 1, i);
2229
- st(e, c, h, l, this.compareMinY);
1883
+ Re(e, c, h, l, this.compareMinY);
2230
1884
  for (let u = c; u <= h; u += l) {
2231
1885
  const p = Math.min(u + l - 1, h);
2232
1886
  r.children.push(this._build(e, u, p, n - 1));
2233
1887
  }
2234
1888
  }
2235
- return q(r, this.toBBox), r;
1889
+ return Y(r, this.toBBox), r;
2236
1890
  }
2237
1891
  _chooseSubtree(e, t, i, n) {
2238
1892
  for (; n.push(t), !t.leaf && n.length - 1 !== i; ) {
2239
1893
  let a, l = 1 / 0, d = 1 / 0;
2240
1894
  for (let c = 0; c < t.children.length; c++) {
2241
- const h = t.children[c], u = Ie(h), p = (s = e, r = h, (Math.max(r.maxX, s.maxX) - Math.min(r.minX, s.minX)) * (Math.max(r.maxY, s.maxY) - Math.min(r.minY, s.minY)) - u);
1895
+ const h = t.children[c], u = Ce(h), p = (s = e, r = h, (Math.max(r.maxX, s.maxX) - Math.min(r.minX, s.minX)) * (Math.max(r.maxY, s.maxY) - Math.min(r.minY, s.minY)) - u);
2242
1896
  p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
2243
1897
  }
2244
1898
  t = a || t.children[0];
@@ -2248,54 +1902,54 @@ class Pi {
2248
1902
  }
2249
1903
  _insert(e, t, i) {
2250
1904
  const n = i ? e : this.toBBox(e), s = [], r = this._chooseSubtree(n, this.data, t, s);
2251
- for (r.children.push(e), se(r, n); t >= 0 && s[t].children.length > this._maxEntries; ) this._split(s, t), t--;
1905
+ for (r.children.push(e), te(r, n); t >= 0 && s[t].children.length > this._maxEntries; ) this._split(s, t), t--;
2252
1906
  this._adjustParentBBoxes(n, s, t);
2253
1907
  }
2254
1908
  _split(e, t) {
2255
1909
  const i = e[t], n = i.children.length, s = this._minEntries;
2256
1910
  this._chooseSplitAxis(i, s, n);
2257
- const r = this._chooseSplitIndex(i, s, n), a = Z(i.children.splice(r, i.children.length - r));
2258
- a.height = i.height, a.leaf = i.leaf, q(i, this.toBBox), q(a, this.toBBox), t ? e[t - 1].children.push(a) : this._splitRoot(i, a);
1911
+ const r = this._chooseSplitIndex(i, s, n), a = $(i.children.splice(r, i.children.length - r));
1912
+ a.height = i.height, a.leaf = i.leaf, Y(i, this.toBBox), Y(a, this.toBBox), t ? e[t - 1].children.push(a) : this._splitRoot(i, a);
2259
1913
  }
2260
1914
  _splitRoot(e, t) {
2261
- this.data = Z([e, t]), this.data.height = e.height + 1, this.data.leaf = !1, q(this.data, this.toBBox);
1915
+ this.data = $([e, t]), this.data.height = e.height + 1, this.data.leaf = !1, Y(this.data, this.toBBox);
2262
1916
  }
2263
1917
  _chooseSplitIndex(e, t, i) {
2264
1918
  let n, s = 1 / 0, r = 1 / 0;
2265
1919
  for (let a = t; a <= i - t; a++) {
2266
- const l = ne(e, 0, a, this.toBBox), d = ne(e, a, i, this.toBBox), c = Ci(l, d), h = Ie(l) + Ie(d);
1920
+ const l = ee(e, 0, a, this.toBBox), d = ee(e, a, i, this.toBBox), c = Jt(l, d), h = Ce(l) + Ce(d);
2267
1921
  c < s ? (s = c, n = a, r = h < r ? h : r) : c === s && h < r && (r = h, n = a);
2268
1922
  }
2269
1923
  return n || i - t;
2270
1924
  }
2271
1925
  _chooseSplitAxis(e, t, i) {
2272
- const n = e.leaf ? this.compareMinX : yi, s = e.leaf ? this.compareMinY : mi;
1926
+ const n = e.leaf ? this.compareMinX : Ht, s = e.leaf ? this.compareMinY : $t;
2273
1927
  this._allDistMargin(e, t, i, n) < this._allDistMargin(e, t, i, s) && e.children.sort(n);
2274
1928
  }
2275
1929
  _allDistMargin(e, t, i, n) {
2276
1930
  e.children.sort(n);
2277
- const s = this.toBBox, r = ne(e, 0, t, s), a = ne(e, i - t, i, s);
2278
- let l = pe(r) + pe(a);
1931
+ const s = this.toBBox, r = ee(e, 0, t, s), a = ee(e, i - t, i, s);
1932
+ let l = ae(r) + ae(a);
2279
1933
  for (let d = t; d < i - t; d++) {
2280
1934
  const c = e.children[d];
2281
- se(r, e.leaf ? s(c) : c), l += pe(r);
1935
+ te(r, e.leaf ? s(c) : c), l += ae(r);
2282
1936
  }
2283
1937
  for (let d = i - t - 1; d >= t; d--) {
2284
1938
  const c = e.children[d];
2285
- se(a, e.leaf ? s(c) : c), l += pe(a);
1939
+ te(a, e.leaf ? s(c) : c), l += ae(a);
2286
1940
  }
2287
1941
  return l;
2288
1942
  }
2289
1943
  _adjustParentBBoxes(e, t, i) {
2290
- for (let n = i; n >= 0; n--) se(t[n], e);
1944
+ for (let n = i; n >= 0; n--) te(t[n], e);
2291
1945
  }
2292
1946
  _condense(e) {
2293
- for (let t, i = e.length - 1; i >= 0; i--) e[i].children.length === 0 ? i > 0 ? (t = e[i - 1].children, t.splice(t.indexOf(e[i]), 1)) : this.clear() : q(e[i], this.toBBox);
1947
+ for (let t, i = e.length - 1; i >= 0; i--) e[i].children.length === 0 ? i > 0 ? (t = e[i - 1].children, t.splice(t.indexOf(e[i]), 1)) : this.clear() : Y(e[i], this.toBBox);
2294
1948
  }
2295
1949
  }
2296
- class vi {
1950
+ class Zt {
2297
1951
  constructor(e) {
2298
- this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new Pi(e && e.maxEntries ? e.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
1952
+ this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new qt(e && e.maxEntries ? e.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
2299
1953
  }
2300
1954
  setMaps(e, t) {
2301
1955
  this.idToNode.set(e.id, t), this.nodeToId.set(t, e.id);
@@ -2346,14 +2000,14 @@ class vi {
2346
2000
  return this.tree.collides(this.toBBox(e));
2347
2001
  }
2348
2002
  }
2349
- const xi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(o) {
2003
+ const Qt = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(o) {
2350
2004
  const e = 16 * Math.random() | 0;
2351
2005
  return (o == "x" ? e : 3 & e | 8).toString(16);
2352
2006
  }), isValidId: (o) => typeof o == "string" && o.length === 36 };
2353
- class Si {
2007
+ class ei {
2354
2008
  constructor(e) {
2355
2009
  this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
2356
- }, this.store = {}, this.spatialIndex = new vi(), this.tracked = !e || e.tracked !== !1, this.idStrategy = e && e.idStrategy ? e.idStrategy : xi;
2010
+ }, this.store = {}, this.spatialIndex = new Zt(), this.tracked = !e || e.tracked !== !1, this.idStrategy = e && e.idStrategy ? e.idStrategy : Qt;
2357
2011
  }
2358
2012
  clone(e) {
2359
2013
  return JSON.parse(JSON.stringify(e));
@@ -2377,10 +2031,10 @@ class Si {
2377
2031
  }
2378
2032
  if (this.tracked) {
2379
2033
  if (r.properties.createdAt) {
2380
- if (!He(r.properties.createdAt)) return s.push({ id: r.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2034
+ if (!ke(r.properties.createdAt)) return s.push({ id: r.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2381
2035
  } else r.properties.createdAt = +/* @__PURE__ */ new Date();
2382
2036
  if (r.properties.updatedAt) {
2383
- if (!He(r.properties.updatedAt)) return s.push({ id: r.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2037
+ if (!ke(r.properties.updatedAt)) return s.push({ id: r.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2384
2038
  } else r.properties.updatedAt = +/* @__PURE__ */ new Date();
2385
2039
  }
2386
2040
  return this.has(a) ? (s.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = r, n.push(a), s.push({ id: a, valid: !0 }), !0);
@@ -2447,13 +2101,13 @@ class Si {
2447
2101
  return Object.keys(this.store).length;
2448
2102
  }
2449
2103
  }
2450
- const Mi = "Feature is not a Polygon or LineString", wi = "Feature intersects itself", bi = (o) => o.geometry.type !== "Polygon" && o.geometry.type !== "LineString" ? { valid: !1, reason: Mi } : Le(o) ? { valid: !1, reason: wi } : { valid: !0 };
2451
- function ot(o, e, t) {
2104
+ const ti = "Feature is not a Polygon or LineString", ii = "Feature intersects itself", ni = (o) => o.geometry.type !== "Polygon" && o.geometry.type !== "LineString" ? { valid: !1, reason: ti } : Me(o) ? { valid: !1, reason: ii } : { valid: !0 };
2105
+ function ze(o, e, t) {
2452
2106
  const i = G(o, e);
2453
2107
  let n = G(e, t) - i;
2454
2108
  return n < 0 && (n += 360), 180 - Math.abs(n - 90 - 90);
2455
2109
  }
2456
- class Ft extends B {
2110
+ class gt extends N {
2457
2111
  constructor(e) {
2458
2112
  super(e), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
2459
2113
  const t = { start: "crosshair", close: "pointer" };
@@ -2482,11 +2136,11 @@ class Ft extends B {
2482
2136
  const n = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, n);
2483
2137
  i = [t[0], [e.lng, e.lat], [e.lng, e.lat - s], t[0]];
2484
2138
  } else if (this.currentCoordinate === 2) {
2485
- const n = t[0], s = t[1], r = Mt(n, s, this.coordinatePrecision, this.project, this.unproject), a = S(n[0], n[1]), l = S(r[0], r[1]), d = S(s[0], s[1]), c = S(e.lng, e.lat), h = F(c, a) < F(c, d), u = ot(a, l, c), p = h ? 90 - u : ot(a, l, c) - 90, g = F(l, c), f = Math.cos(D(p)) * g, P = G(a, d) + (function(x, w, I) {
2486
- const O = (I.x - w.x) * (x.y - w.y) - (I.y - w.y) * (x.x - w.x);
2139
+ const n = t[0], s = t[1], r = dt(n, s, this.coordinatePrecision, this.project, this.unproject), a = x(n[0], n[1]), l = x(r[0], r[1]), d = x(s[0], s[1]), c = x(e.lng, e.lat), h = D(c, a) < D(c, d), u = ze(a, l, c), p = h ? 90 - u : ze(a, l, c) - 90, g = D(l, c), y = Math.cos(F(p)) * g, P = G(a, d) + (function(S, w, I) {
2140
+ const O = (I.x - w.x) * (S.y - w.y) - (I.y - w.y) * (S.x - w.x);
2487
2141
  return O > 1e-10 ? "left" : O < -1e-10 ? "right" : "left";
2488
- }(a, d, c) === "right" ? -90 : 90), y = le(a, f, P), C = le(d, f, P), m = k(y.x, y.y), v = k(C.x, C.y);
2489
- i = [t[0], t[1], [v.lng, v.lat], [m.lng, m.lat], t[0]];
2142
+ }(a, d, c) === "right" ? -90 : 90), f = ne(a, y, P), m = ne(d, y, P), C = k(f.x, f.y), v = k(m.x, m.y);
2143
+ i = [t[0], t[1], [v.lng, v.lat], [C.lng, C.lat], t[0]];
2490
2144
  }
2491
2145
  i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
2492
2146
  }
@@ -2500,7 +2154,7 @@ class Ft extends B {
2500
2154
  this.currentId = t, this.currentCoordinate++, this.setDrawing();
2501
2155
  } else if (this.currentCoordinate === 1 && this.currentId) {
2502
2156
  const t = this.store.getGeometryCopy(this.currentId);
2503
- if (ee([e.lng, e.lat], t.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [t.coordinates[0][0], [e.lng, e.lat], [e.lng, e.lat], t.coordinates[0][0]], b.Commit)) return;
2157
+ if (J([e.lng, e.lat], t.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [t.coordinates[0][0], [e.lng, e.lat], [e.lng, e.lat], t.coordinates[0][0]], b.Commit)) return;
2504
2158
  this.currentCoordinate++;
2505
2159
  } else this.currentCoordinate === 2 && this.currentId && this.close();
2506
2160
  }
@@ -2527,13 +2181,13 @@ class Ft extends B {
2527
2181
  return e.properties.mode === this.mode && e.geometry.type === "Polygon" && (t.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, t.polygonFillColor, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, t.polygonFillOpacity, e), t.zIndex = 10), t;
2528
2182
  }
2529
2183
  validateFeature(e) {
2530
- return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
2184
+ return this.validateModeFeature(e, (t) => se(t, this.coordinatePrecision));
2531
2185
  }
2532
2186
  }
2533
- function Dt(o, e, t) {
2187
+ function yt(o, e, t) {
2534
2188
  return (e.x - o.x) * (t.y - o.y) - (e.y - o.y) * (t.x - o.x) <= 0;
2535
2189
  }
2536
- class Ot extends B {
2190
+ class ft extends N {
2537
2191
  constructor(e) {
2538
2192
  super(e), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
2539
2193
  const t = { start: "crosshair", close: "pointer" };
@@ -2563,18 +2217,18 @@ class Ot extends B {
2563
2217
  const n = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, n);
2564
2218
  i = [t[0], [e.lng, e.lat], [e.lng, e.lat - s], t[0]];
2565
2219
  } else if (this.currentCoordinate === 2) {
2566
- const n = t[0], s = t[1], r = [e.lng, e.lat], a = S(n[0], n[1]), l = S(s[0], s[1]), d = S(r[0], r[1]);
2220
+ const n = t[0], s = t[1], r = [e.lng, e.lat], a = x(n[0], n[1]), l = x(s[0], s[1]), d = x(r[0], r[1]);
2567
2221
  if (this.direction === void 0) {
2568
- const m = Dt(a, l, d);
2569
- this.direction = m ? "clockwise" : "anticlockwise";
2222
+ const C = yt(a, l, d);
2223
+ this.direction = C ? "clockwise" : "anticlockwise";
2570
2224
  }
2571
- const c = F(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [n], f = z(h), P = z(u);
2572
- let y;
2573
- this.direction === "anticlockwise" ? (y = P - f, y < 0 && (y += 360)) : (y = f - P, y < 0 && (y += 360));
2574
- const C = (this.direction === "anticlockwise" ? 1 : -1) * y / p;
2225
+ const c = D(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [n], y = K(h), P = K(u);
2226
+ let f;
2227
+ this.direction === "anticlockwise" ? (f = P - y, f < 0 && (f += 360)) : (f = y - P, f < 0 && (f += 360));
2228
+ const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
2575
2229
  g.push(s);
2576
- for (let m = 0; m <= p; m++) {
2577
- const v = le(a, c, f + m * C), { lng: x, lat: w } = k(v.x, v.y), I = [E(x, this.coordinatePrecision), E(w, this.coordinatePrecision)];
2230
+ for (let C = 0; C <= p; C++) {
2231
+ const v = ne(a, c, y + C * m), { lng: S, lat: w } = k(v.x, v.y), I = [E(S, this.coordinatePrecision), E(w, this.coordinatePrecision)];
2578
2232
  I[0] !== g[g.length - 1][0] && I[1] !== g[g.length - 1][1] && g.push(I);
2579
2233
  }
2580
2234
  g.push(n), i = [...g];
@@ -2591,7 +2245,7 @@ class Ot extends B {
2591
2245
  this.currentId = t, this.currentCoordinate++, this.setDrawing();
2592
2246
  } else if (this.currentCoordinate === 1 && this.currentId) {
2593
2247
  const t = this.store.getGeometryCopy(this.currentId);
2594
- if (ee([e.lng, e.lat], t.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [t.coordinates[0][0], [e.lng, e.lat], [e.lng, e.lat], t.coordinates[0][0]], b.Commit)) return;
2248
+ if (J([e.lng, e.lat], t.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [t.coordinates[0][0], [e.lng, e.lat], [e.lng, e.lat], t.coordinates[0][0]], b.Commit)) return;
2595
2249
  this.currentCoordinate++;
2596
2250
  } else this.currentCoordinate === 2 && this.currentId && this.close();
2597
2251
  }
@@ -2618,10 +2272,10 @@ class Ot extends B {
2618
2272
  return e.properties.mode === this.mode && e.geometry.type === "Polygon" && (t.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, t.polygonFillColor, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, t.polygonFillOpacity, e), t.zIndex = 10), t;
2619
2273
  }
2620
2274
  validateFeature(e) {
2621
- return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
2275
+ return this.validateModeFeature(e, (t) => se(t, this.coordinatePrecision));
2622
2276
  }
2623
2277
  }
2624
- class _t extends B {
2278
+ class mt extends N {
2625
2279
  constructor(e) {
2626
2280
  super(e), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
2627
2281
  const t = { start: "crosshair", close: "pointer" };
@@ -2646,28 +2300,28 @@ class _t extends B {
2646
2300
  onMouseMove(e) {
2647
2301
  if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
2648
2302
  if (this.currentCoordinate === 2) {
2649
- const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], s = [e.lng, e.lat], r = S(n[0], n[1]), a = S(s[0], s[1]), l = S(i[0], i[1]), d = F(l, r);
2303
+ const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], s = [e.lng, e.lat], r = x(n[0], n[1]), a = x(s[0], s[1]), l = x(i[0], i[1]), d = D(l, r);
2650
2304
  if (this.direction === void 0) {
2651
- const C = Dt(l, r, a);
2652
- this.direction = C ? "clockwise" : "anticlockwise";
2305
+ const m = yt(l, r, a);
2306
+ this.direction = m ? "clockwise" : "anticlockwise";
2653
2307
  }
2654
- const c = G(l, r), h = G(l, a), u = this.arcPoints, p = [n], g = z(c), f = z(h);
2308
+ const c = G(l, r), h = G(l, a), u = this.arcPoints, p = [n], g = K(c), y = K(h);
2655
2309
  let P;
2656
- this.direction === "anticlockwise" ? (P = f - g, P < 0 && (P += 360)) : (P = g - f, P < 0 && (P += 360));
2657
- const y = (this.direction === "anticlockwise" ? 1 : -1) * P / u;
2658
- for (let C = 0; C <= u; C++) {
2659
- const m = le(l, d, g + C * y), { lng: v, lat: x } = k(m.x, m.y), w = [E(v, this.coordinatePrecision), E(x, this.coordinatePrecision)];
2310
+ this.direction === "anticlockwise" ? (P = y - g, P < 0 && (P += 360)) : (P = g - y, P < 0 && (P += 360));
2311
+ const f = (this.direction === "anticlockwise" ? 1 : -1) * P / u;
2312
+ for (let m = 0; m <= u; m++) {
2313
+ const C = ne(l, d, g + m * f), { lng: v, lat: S } = k(C.x, C.y), w = [E(v, this.coordinatePrecision), E(S, this.coordinatePrecision)];
2660
2314
  w[0] !== p[p.length - 1][0] && w[1] !== p[p.length - 1][1] && p.push(w);
2661
2315
  }
2662
2316
  this.updateLineStringGeometry(this.currentInitialArcId, p, b.Provisional);
2663
2317
  } else if (this.currentCoordinate === 3) {
2664
2318
  const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2665
2319
  if (t.length < 2 || !this.direction) return;
2666
- const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], s = t[t.length - 1], r = S(e.lng, e.lat), a = S(n[0], n[1]), l = S(s[0], s[1]), d = S(i[0], i[1]), c = F(d, a), h = F(d, r) < c ? a : r, u = G(d, r), p = G(d, a), g = G(d, l), f = z(p), P = z(g), y = z(u);
2667
- if (this.notInSector({ normalizedCursor: y, normalizedStart: f, normalizedEnd: P, direction: this.direction })) return;
2668
- const C = this.getDeltaBearing(this.direction, f, P), m = this.arcPoints, v = (this.direction === "anticlockwise" ? 1 : -1) * C / m, x = F(d, h), w = [];
2669
- for (let I = 0; I <= m; I++) {
2670
- const O = le(d, x, f + I * v), { lng: N, lat: _ } = k(O.x, O.y), j = [E(N, this.coordinatePrecision), E(_, this.coordinatePrecision)];
2320
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], s = t[t.length - 1], r = x(e.lng, e.lat), a = x(n[0], n[1]), l = x(s[0], s[1]), d = x(i[0], i[1]), c = D(d, a), h = D(d, r) < c ? a : r, u = G(d, r), p = G(d, a), g = G(d, l), y = K(p), P = K(g), f = K(u);
2321
+ if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: P, direction: this.direction })) return;
2322
+ const m = this.getDeltaBearing(this.direction, y, P), C = this.arcPoints, v = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = D(d, h), w = [];
2323
+ for (let I = 0; I <= C; I++) {
2324
+ const O = ne(d, S, y + I * v), { lng: B, lat: _ } = k(O.x, O.y), j = [E(B, this.coordinatePrecision), E(_, this.coordinatePrecision)];
2671
2325
  j[0] !== t[t.length - 1][0] && j[1] !== t[t.length - 1][1] && w.unshift(j);
2672
2326
  }
2673
2327
  t.push(...w), t.push(t[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, t, b.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [t] }, properties: { mode: this.mode } }]);
@@ -2714,7 +2368,7 @@ class _t extends B {
2714
2368
  return e.properties.mode === this.mode && (e.geometry.type === "Polygon" ? (t.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, t.polygonFillColor, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, t.polygonFillOpacity, e), t.zIndex = 10) : e.geometry.type === "LineString" ? (t.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.zIndex = 10) : e.geometry.type === "Point" && (t.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, t.pointColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, t.pointWidth, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, t.pointOutlineWidth, e), t.zIndex = 20)), t;
2715
2369
  }
2716
2370
  validateFeature(e) {
2717
- return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
2371
+ return this.validateModeFeature(e, (t) => se(t, this.coordinatePrecision));
2718
2372
  }
2719
2373
  getDeltaBearing(e, t, i) {
2720
2374
  let n;
@@ -2724,20 +2378,20 @@ class _t extends B {
2724
2378
  return n === "clockwise" ? t <= i ? e >= t && e <= i : e >= t || e <= i : t >= i ? e <= t && e >= i : e <= t || e >= i;
2725
2379
  }
2726
2380
  }
2727
- class Ii {
2381
+ class si {
2728
2382
  constructor(e) {
2729
- this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = e.adapter, this._mode = new fi();
2383
+ this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = e.adapter, this._mode = new Yt();
2730
2384
  const t = /* @__PURE__ */ new Set(), i = e.modes.reduce((c, h) => {
2731
2385
  if (t.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
2732
2386
  return t.add(h.mode), c[h.mode] = h, c;
2733
2387
  }, {}), n = Object.keys(i);
2734
2388
  if (n.length === 0) throw new Error("No modes provided");
2735
2389
  n.forEach((c) => {
2736
- if (i[c].type === K.Select) {
2390
+ if (i[c].type === X.Select) {
2737
2391
  if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
2738
2392
  this._instanceSelectMode = c;
2739
2393
  }
2740
- }), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Si({ tracked: !!e.tracked, idStrategy: e.idStrategy ? e.idStrategy : void 0 });
2394
+ }), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new ei({ tracked: !!e.tracked, idStrategy: e.idStrategy ? e.idStrategy : void 0 });
2741
2395
  const s = (c) => {
2742
2396
  const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
2743
2397
  return { changed: h, unchanged: u };
@@ -2777,26 +2431,26 @@ class Ii {
2777
2431
  getModeStyles() {
2778
2432
  const e = {};
2779
2433
  return Object.keys(this._modes).forEach((t) => {
2780
- e[t] = (i) => this._instanceSelectMode && i.properties[De] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[t].styleFeature.bind(this._modes[t])(i);
2434
+ e[t] = (i) => this._instanceSelectMode && i.properties[T.SELECTED] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[t].styleFeature.bind(this._modes[t])(i);
2781
2435
  }), e;
2782
2436
  }
2783
2437
  featuresAtLocation({ lng: e, lat: t }, i) {
2784
- const n = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, r = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(e, t), d = yt({ unproject: r, point: l, pointerDistance: n });
2438
+ const n = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, r = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(e, t), d = it({ unproject: r, point: l, pointerDistance: n });
2785
2439
  return this._store.search(d).filter((c) => {
2786
- if (s && (c.properties[oe] || c.properties.selectionPoint)) return !1;
2440
+ if (s && (c.properties[T.MID_POINT] || c.properties[T.SELECTION_POINT])) return !1;
2787
2441
  if (c.geometry.type === "Point") {
2788
2442
  const h = c.geometry.coordinates, u = a(h[0], h[1]);
2789
- return F(l, u) < n;
2443
+ return D(l, u) < n;
2790
2444
  }
2791
2445
  if (c.geometry.type === "LineString") {
2792
2446
  const h = c.geometry.coordinates;
2793
2447
  for (let u = 0; u < h.length - 1; u++) {
2794
2448
  const p = h[u], g = h[u + 1];
2795
- if (bt(l, a(p[0], p[1]), a(g[0], g[1])) < n) return !0;
2449
+ if (ht(l, a(p[0], p[1]), a(g[0], g[1])) < n) return !0;
2796
2450
  }
2797
2451
  return !1;
2798
2452
  }
2799
- return !!wt([e, t], c.geometry.coordinates) || void 0;
2453
+ return !!ct([e, t], c.geometry.coordinates) || void 0;
2800
2454
  });
2801
2455
  }
2802
2456
  getSelectMode() {
@@ -2897,7 +2551,215 @@ class Ii {
2897
2551
  i.includes(t) && i.splice(i.indexOf(t), 1);
2898
2552
  }
2899
2553
  }
2900
- const Ri = [
2554
+ var Ke, ve, Xe;
2555
+ function Ye(o, e = 9) {
2556
+ const t = Math.pow(10, e);
2557
+ return Math.round(o * t) / t;
2558
+ }
2559
+ (ve = Ke || (Ke = {})).Commit = "commit", ve.Provisional = "provisional", ve.Finish = "finish", function(o) {
2560
+ o.Drawing = "drawing", o.Select = "select", o.Static = "static", o.Render = "render";
2561
+ }(Xe || (Xe = {}));
2562
+ class H {
2563
+ constructor({ name: e, callback: t, unregister: i, register: n }) {
2564
+ this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = e, this.register = () => {
2565
+ this.registered || (this.registered = !0, n(t));
2566
+ }, this.unregister = () => {
2567
+ this.register && (this.registered = !1, i(t));
2568
+ }, this.callback = t;
2569
+ }
2570
+ }
2571
+ var oi = class {
2572
+ constructor(o) {
2573
+ this._minPixelDragDistance = void 0, this._minPixelDragDistanceDrawing = void 0, this._minPixelDragDistanceSelecting = void 0, this._lastDrawEvent = void 0, this._coordinatePrecision = void 0, this._heldKeys = /* @__PURE__ */ new Set(), this._listeners = [], this._dragState = "not-dragging", this._currentModeCallbacks = void 0, this._minPixelDragDistance = typeof o.minPixelDragDistance == "number" ? o.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof o.minPixelDragDistanceSelecting == "number" ? o.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof o.minPixelDragDistanceDrawing == "number" ? o.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof o.coordinatePrecision == "number" ? o.coordinatePrecision : 9;
2574
+ }
2575
+ getButton(o) {
2576
+ return o.button === -1 ? "neither" : o.button === 0 ? "left" : o.button === 1 ? "middle" : o.button === 2 ? "right" : "neither";
2577
+ }
2578
+ getMapElementXYPosition(o) {
2579
+ const e = this.getMapEventElement(), { left: t, top: i } = e.getBoundingClientRect();
2580
+ return { containerX: o.clientX - t, containerY: o.clientY - i };
2581
+ }
2582
+ getDrawEventFromEvent(o) {
2583
+ const e = this.getLngLatFromEvent(o);
2584
+ if (!e) return null;
2585
+ const { lng: t, lat: i } = e, { containerX: n, containerY: s } = this.getMapElementXYPosition(o), r = this.getButton(o), a = Array.from(this._heldKeys);
2586
+ return { lng: Ye(t, this._coordinatePrecision), lat: Ye(i, this._coordinatePrecision), containerX: n, containerY: s, button: r, heldKeys: a };
2587
+ }
2588
+ register(o) {
2589
+ this._currentModeCallbacks = o, this._listeners = this.getAdapterListeners(), this._listeners.forEach((e) => {
2590
+ e.register();
2591
+ });
2592
+ }
2593
+ getCoordinatePrecision() {
2594
+ return this._coordinatePrecision;
2595
+ }
2596
+ getAdapterListeners() {
2597
+ return [new H({ name: "pointerdown", callback: (o) => {
2598
+ if (!this._currentModeCallbacks || !o.isPrimary) return;
2599
+ const e = this.getDrawEventFromEvent(o);
2600
+ e && (this._dragState = "pre-dragging", this._lastDrawEvent = e);
2601
+ }, register: (o) => {
2602
+ this.getMapEventElement().addEventListener("pointerdown", o);
2603
+ }, unregister: (o) => {
2604
+ this.getMapEventElement().removeEventListener("pointerdown", o);
2605
+ } }), new H({ name: "pointermove", callback: (o) => {
2606
+ if (!this._currentModeCallbacks || !o.isPrimary) return;
2607
+ o.preventDefault();
2608
+ const e = this.getDrawEventFromEvent(o);
2609
+ if (e) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(e), this._lastDrawEvent = e;
2610
+ else if (this._dragState === "pre-dragging") {
2611
+ if (!this._lastDrawEvent) return;
2612
+ const t = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: e.containerX, y: e.containerY }, n = this._currentModeCallbacks.getState(), s = ((a, l) => {
2613
+ const { x: d, y: c } = a, { x: h, y: u } = l, p = h - d, g = u - c;
2614
+ return Math.sqrt(g * g + p * p);
2615
+ })(t, i);
2616
+ let r = !1;
2617
+ if (r = n === "drawing" ? s < this._minPixelDragDistanceDrawing : n === "selecting" ? s < this._minPixelDragDistanceSelecting : s < this._minPixelDragDistance, r) return;
2618
+ this._dragState = "dragging", this._currentModeCallbacks.onDragStart(e, (a) => {
2619
+ this.setDraggability.bind(this)(a);
2620
+ });
2621
+ } else this._dragState === "dragging" && this._currentModeCallbacks.onDrag(e, (t) => {
2622
+ this.setDraggability.bind(this)(t);
2623
+ });
2624
+ }, register: (o) => {
2625
+ this.getMapEventElement().addEventListener("pointermove", o);
2626
+ }, unregister: (o) => {
2627
+ this.getMapEventElement().removeEventListener("pointermove", o);
2628
+ } }), new H({ name: "contextmenu", callback: (o) => {
2629
+ this._currentModeCallbacks && o.preventDefault();
2630
+ }, register: (o) => {
2631
+ this.getMapEventElement().addEventListener("contextmenu", o);
2632
+ }, unregister: (o) => {
2633
+ this.getMapEventElement().removeEventListener("contextmenu", o);
2634
+ } }), new H({ name: "pointerup", callback: (o) => {
2635
+ if (!this._currentModeCallbacks || o.target !== this.getMapEventElement() || !o.isPrimary) return;
2636
+ const e = this.getDrawEventFromEvent(o);
2637
+ e && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(e, (t) => {
2638
+ this.setDraggability.bind(this)(t);
2639
+ }) : this._dragState !== "not-dragging" && this._dragState !== "pre-dragging" || this._currentModeCallbacks.onClick(e), this._dragState = "not-dragging", this.setDraggability(!0));
2640
+ }, register: (o) => {
2641
+ this.getMapEventElement().addEventListener("pointerup", o);
2642
+ }, unregister: (o) => {
2643
+ this.getMapEventElement().removeEventListener("pointerup", o);
2644
+ } }), new H({ name: "keyup", callback: (o) => {
2645
+ this._currentModeCallbacks && (this._heldKeys.delete(o.key), this._currentModeCallbacks.onKeyUp({ key: o.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => o.preventDefault() }));
2646
+ }, register: (o) => {
2647
+ this.getMapEventElement().addEventListener("keyup", o);
2648
+ }, unregister: (o) => {
2649
+ this.getMapEventElement().removeEventListener("keyup", o);
2650
+ } }), new H({ name: "keydown", callback: (o) => {
2651
+ this._currentModeCallbacks && (this._heldKeys.add(o.key), this._currentModeCallbacks.onKeyDown({ key: o.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => o.preventDefault() }));
2652
+ }, register: (o) => {
2653
+ this.getMapEventElement().addEventListener("keydown", o);
2654
+ }, unregister: (o) => {
2655
+ this.getMapEventElement().removeEventListener("keydown", o);
2656
+ } })];
2657
+ }
2658
+ unregister() {
2659
+ this._listeners.forEach((o) => {
2660
+ o.unregister();
2661
+ }), this.clear();
2662
+ }
2663
+ };
2664
+ class ri extends oi {
2665
+ constructor(e) {
2666
+ super(e), this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = e.map, this._container = this._map.getContainer();
2667
+ }
2668
+ clearLayers() {
2669
+ this._rendered && (["point", "linestring", "polygon"].forEach((e) => {
2670
+ const t = `td-${e.toLowerCase()}`;
2671
+ this._map.removeLayer(t), e === "polygon" && this._map.removeLayer(t + "-outline"), this._map.removeSource(t);
2672
+ }), this._rendered = !1, this._nextRender && (cancelAnimationFrame(this._nextRender), this._nextRender = void 0));
2673
+ }
2674
+ _addGeoJSONSource(e, t) {
2675
+ this._map.addSource(e, { type: "geojson", data: { type: "FeatureCollection", features: t }, tolerance: 0 });
2676
+ }
2677
+ _addFillLayer(e) {
2678
+ return this._map.addLayer({ id: e, source: e, type: "fill", paint: { "fill-color": ["get", "polygonFillColor"], "fill-opacity": ["get", "polygonFillOpacity"] } });
2679
+ }
2680
+ _addFillOutlineLayer(e) {
2681
+ return this._map.addLayer({ id: e + "-outline", source: e, type: "line", paint: { "line-width": ["get", "polygonOutlineWidth"], "line-color": ["get", "polygonOutlineColor"] } });
2682
+ }
2683
+ _addLineLayer(e) {
2684
+ return this._map.addLayer({ id: e, source: e, type: "line", paint: { "line-width": ["get", "lineStringWidth"], "line-color": ["get", "lineStringColor"] } });
2685
+ }
2686
+ _addPointLayer(e) {
2687
+ return this._map.addLayer({ id: e, source: e, type: "circle", paint: { "circle-stroke-color": ["get", "pointOutlineColor"], "circle-stroke-width": ["get", "pointOutlineWidth"], "circle-radius": ["get", "pointWidth"], "circle-color": ["get", "pointColor"] } });
2688
+ }
2689
+ _addLayer(e, t) {
2690
+ t === "Point" && this._addPointLayer(e), t === "LineString" && this._addLineLayer(e), t === "Polygon" && (this._addFillLayer(e), this._addFillOutlineLayer(e));
2691
+ }
2692
+ _addGeoJSONLayer(e, t) {
2693
+ const i = `td-${e.toLowerCase()}`;
2694
+ return this._addGeoJSONSource(i, t), this._addLayer(i, e), i;
2695
+ }
2696
+ _setGeoJSONLayerData(e, t) {
2697
+ const i = `td-${e.toLowerCase()}`;
2698
+ return this._map.getSource(i).setData({ type: "FeatureCollection", features: t }), i;
2699
+ }
2700
+ updateChangedIds(e) {
2701
+ [...e.updated, ...e.created].forEach((t) => {
2702
+ t.geometry.type === "Point" ? this.changedIds.points = !0 : t.geometry.type === "LineString" ? this.changedIds.linestrings = !0 : t.geometry.type === "Polygon" && (this.changedIds.polygons = !0);
2703
+ }), e.deletedIds.length > 0 && (this.changedIds.deletion = !0), e.created.length === 0 && e.updated.length === 0 && e.deletedIds.length === 0 && (this.changedIds.styling = !0);
2704
+ }
2705
+ getLngLatFromEvent(e) {
2706
+ const { left: t, top: i } = this._container.getBoundingClientRect();
2707
+ return this.unproject(e.clientX - t, e.clientY - i);
2708
+ }
2709
+ getMapEventElement() {
2710
+ return this._map.getCanvas();
2711
+ }
2712
+ setDraggability(e) {
2713
+ e ? (this._map.dragRotate.enable(), this._map.dragPan.enable()) : (this._map.dragRotate.disable(), this._map.dragPan.disable());
2714
+ }
2715
+ project(e, t) {
2716
+ const { x: i, y: n } = this._map.project({ lng: e, lat: t });
2717
+ return { x: i, y: n };
2718
+ }
2719
+ unproject(e, t) {
2720
+ const { lng: i, lat: n } = this._map.unproject({ x: e, y: t });
2721
+ return { lng: i, lat: n };
2722
+ }
2723
+ setCursor(e) {
2724
+ const t = this._map.getCanvas();
2725
+ e === "unset" ? t.style.removeProperty("cursor") : t.style.cursor = e;
2726
+ }
2727
+ setDoubleClickToZoom(e) {
2728
+ e ? this._map.doubleClickZoom.enable() : this._map.doubleClickZoom.disable();
2729
+ }
2730
+ render(e, t) {
2731
+ this.updateChangedIds(e), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
2732
+ const i = [...e.created, ...e.updated, ...e.unchanged], n = [], s = [], r = [];
2733
+ for (let a = 0; a < i.length; a++) {
2734
+ const l = i[a], { properties: d } = l, c = t[d.mode](l);
2735
+ l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, n.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, s.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, r.push(l));
2736
+ }
2737
+ if (this._rendered) {
2738
+ const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
2739
+ let c;
2740
+ (a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", n)), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", r), c && this._map.moveLayer(c);
2741
+ } else {
2742
+ const a = this._addGeoJSONLayer("Point", n);
2743
+ this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon", r), this._rendered = !0, a && this._map.moveLayer(a);
2744
+ }
2745
+ this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
2746
+ });
2747
+ }
2748
+ clear() {
2749
+ this._currentModeCallbacks && (this._currentModeCallbacks.onClear(), this.clearLayers());
2750
+ }
2751
+ getCoordinatePrecision() {
2752
+ return super.getCoordinatePrecision();
2753
+ }
2754
+ unregister() {
2755
+ return super.unregister();
2756
+ }
2757
+ register(e) {
2758
+ var t;
2759
+ super.register(e), (t = this._currentModeCallbacks) != null && t.onReady && this._currentModeCallbacks.onReady();
2760
+ }
2761
+ }
2762
+ const Mi = [
2901
2763
  "render",
2902
2764
  "point",
2903
2765
  "linestring",
@@ -2912,7 +2774,7 @@ const Ri = [
2912
2774
  "delete-selection",
2913
2775
  "delete",
2914
2776
  "download"
2915
- ], Xi = [
2777
+ ], wi = [
2916
2778
  "render",
2917
2779
  "linestring",
2918
2780
  "polygon",
@@ -2926,7 +2788,7 @@ const Ri = [
2926
2788
  "delete-selection",
2927
2789
  "delete",
2928
2790
  "download"
2929
- ], Ei = {
2791
+ ], ai = {
2930
2792
  modes: [
2931
2793
  "render",
2932
2794
  "point",
@@ -2944,7 +2806,7 @@ const Ri = [
2944
2806
  "download"
2945
2807
  ],
2946
2808
  open: !1
2947
- }, Fi = {
2809
+ }, li = {
2948
2810
  modes: [
2949
2811
  "render",
2950
2812
  "linestring",
@@ -2963,7 +2825,7 @@ const Ri = [
2963
2825
  open: !1,
2964
2826
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
2965
2827
  modeOptions: {
2966
- linestring: new Pt({
2828
+ linestring: new ot({
2967
2829
  styles: {
2968
2830
  lineStringColor: "#232E3D",
2969
2831
  lineStringWidth: 2,
@@ -2973,7 +2835,7 @@ const Ri = [
2973
2835
  closingPointOutlineWidth: 1
2974
2836
  }
2975
2837
  }),
2976
- polygon: new xt({
2838
+ polygon: new at({
2977
2839
  styles: {
2978
2840
  fillColor: "#EDEFF0",
2979
2841
  fillOpacity: 0.7,
@@ -2985,7 +2847,7 @@ const Ri = [
2985
2847
  closingPointOutlineWidth: 1
2986
2848
  }
2987
2849
  }),
2988
- rectangle: new St({
2850
+ rectangle: new lt({
2989
2851
  styles: {
2990
2852
  fillColor: "#EDEFF0",
2991
2853
  fillOpacity: 0.7,
@@ -2993,7 +2855,7 @@ const Ri = [
2993
2855
  outlineWidth: 2
2994
2856
  }
2995
2857
  }),
2996
- "angled-rectangle": new Ft({
2858
+ "angled-rectangle": new gt({
2997
2859
  styles: {
2998
2860
  fillColor: "#EDEFF0",
2999
2861
  fillOpacity: 0.7,
@@ -3001,7 +2863,7 @@ const Ri = [
3001
2863
  outlineWidth: 2
3002
2864
  }
3003
2865
  }),
3004
- circle: new gt({
2866
+ circle: new et({
3005
2867
  styles: {
3006
2868
  fillColor: "#EDEFF0",
3007
2869
  fillOpacity: 0.7,
@@ -3009,7 +2871,7 @@ const Ri = [
3009
2871
  outlineWidth: 2
3010
2872
  }
3011
2873
  }),
3012
- freehand: new ft({
2874
+ freehand: new tt({
3013
2875
  styles: {
3014
2876
  fillColor: "#EDEFF0",
3015
2877
  fillOpacity: 0.7,
@@ -3021,7 +2883,7 @@ const Ri = [
3021
2883
  closingPointOutlineWidth: 1
3022
2884
  }
3023
2885
  }),
3024
- sensor: new _t({
2886
+ sensor: new mt({
3025
2887
  styles: {
3026
2888
  fillColor: "#EDEFF0",
3027
2889
  fillOpacity: 0.7,
@@ -3033,7 +2895,7 @@ const Ri = [
3033
2895
  centerPointOutlineWidth: 1
3034
2896
  }
3035
2897
  }),
3036
- sector: new Ot({
2898
+ sector: new ft({
3037
2899
  styles: {
3038
2900
  fillColor: "#EDEFF0",
3039
2901
  fillOpacity: 0.7,
@@ -3146,28 +3008,28 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3146
3008
  distancePrecision: 2,
3147
3009
  areaUnit: "metric",
3148
3010
  areaPrecision: 2
3149
- }, Di = () => ({
3150
- render: new ie({
3011
+ }, di = () => ({
3012
+ render: new Q({
3151
3013
  modeName: "render",
3152
3014
  styles: {}
3153
3015
  }),
3154
- point: new ei(),
3155
- linestring: new Pt(),
3156
- polygon: new xt({
3016
+ point: new Lt(),
3017
+ linestring: new ot(),
3018
+ polygon: new at({
3157
3019
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3158
3020
  // @ts-ignore
3159
3021
  validation: (e, t) => {
3160
3022
  const i = t.updateType;
3161
- return i === "finish" || i === "commit" ? bi(e) : { valid: !0 };
3023
+ return i === "finish" || i === "commit" ? ni(e) : { valid: !0 };
3162
3024
  }
3163
3025
  }),
3164
- rectangle: new St(),
3165
- "angled-rectangle": new Ft(),
3166
- circle: new gt(),
3167
- freehand: new ft(),
3168
- sensor: new _t(),
3169
- sector: new Ot(),
3170
- select: new gi({
3026
+ rectangle: new lt(),
3027
+ "angled-rectangle": new gt(),
3028
+ circle: new et(),
3029
+ freehand: new tt(),
3030
+ sensor: new mt(),
3031
+ sector: new ft(),
3032
+ select: new Xt({
3171
3033
  flags: {
3172
3034
  point: {
3173
3035
  feature: {
@@ -3268,20 +3130,20 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3268
3130
  }
3269
3131
  }
3270
3132
  }),
3271
- delete: new ie({
3133
+ delete: new Q({
3272
3134
  modeName: "delete",
3273
3135
  styles: {}
3274
3136
  }),
3275
- "delete-selection": new ie({
3137
+ "delete-selection": new Q({
3276
3138
  modeName: "delete-selection",
3277
3139
  styles: {}
3278
3140
  }),
3279
- download: new ie({
3141
+ download: new Q({
3280
3142
  modeName: "download",
3281
3143
  styles: {}
3282
3144
  })
3283
3145
  });
3284
- class Oi {
3146
+ class ci {
3285
3147
  /**
3286
3148
  * Constructor
3287
3149
  * @param options Plugin control options
@@ -3292,7 +3154,7 @@ class Oi {
3292
3154
  A(this, "modeButtons", {});
3293
3155
  A(this, "isExpanded", !1);
3294
3156
  A(this, "terradraw");
3295
- A(this, "options", Ei);
3157
+ A(this, "options", ai);
3296
3158
  A(this, "events", {});
3297
3159
  A(this, "defaultMode", "render");
3298
3160
  this.modeButtons = {}, e && (this.options = Object.assign(this.options, e));
@@ -3314,7 +3176,7 @@ class Oi {
3314
3176
  if (this.options && this.options.modes && this.options.modes.length === 0)
3315
3177
  throw new Error("At least a mode must be enabled.");
3316
3178
  this.map = e;
3317
- const t = Di(), i = [];
3179
+ const t = di(), i = [];
3318
3180
  return (s = (n = this.options) == null ? void 0 : n.modes) == null || s.forEach((d) => {
3319
3181
  if (this.options.modeOptions && this.options.modeOptions[d]) {
3320
3182
  const c = this.options.modeOptions[d];
@@ -3332,12 +3194,12 @@ class Oi {
3332
3194
  }), i.forEach((d) => {
3333
3195
  d.state !== "unregistered" && (d._state = "unregistered");
3334
3196
  }), (a = (r = this.options) == null ? void 0 : r.modes) != null && a.includes("render") || (i.push(
3335
- new ie({
3197
+ new Q({
3336
3198
  modeName: "default",
3337
3199
  styles: {}
3338
3200
  })
3339
- ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Ii({
3340
- adapter: new Bt({ map: e, ...this.options.adapterOptions }),
3201
+ ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new si({
3202
+ adapter: new ri({ map: e, ...this.options.adapterOptions }),
3341
3203
  modes: i
3342
3204
  }), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
3343
3205
  d.mode !== "default" && this.addTerradrawButton(d.mode);
@@ -3522,7 +3384,7 @@ class Oi {
3522
3384
  return e.charAt(0).toUpperCase() + e.slice(1);
3523
3385
  }
3524
3386
  }
3525
- var L = 63710088e-1, _i = {
3387
+ var L = 63710088e-1, hi = {
3526
3388
  centimeters: L * 100,
3527
3389
  centimetres: L * 100,
3528
3390
  degrees: 360 / (2 * Math.PI),
@@ -3539,37 +3401,37 @@ var L = 63710088e-1, _i = {
3539
3401
  radians: 1,
3540
3402
  yards: L * 1.0936
3541
3403
  };
3542
- function Li(o, e, t = {}) {
3404
+ function ui(o, e, t = {}) {
3543
3405
  const i = { type: "Feature" };
3544
3406
  return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = o, i;
3545
3407
  }
3546
- function ki(o, e, t = {}) {
3408
+ function pi(o, e, t = {}) {
3547
3409
  if (!o)
3548
3410
  throw new Error("coordinates is required");
3549
3411
  if (!Array.isArray(o))
3550
3412
  throw new Error("coordinates must be an Array");
3551
3413
  if (o.length < 2)
3552
3414
  throw new Error("coordinates must be at least 2 numbers long");
3553
- if (!rt(o[0]) || !rt(o[1]))
3415
+ if (!He(o[0]) || !He(o[1]))
3554
3416
  throw new Error("coordinates must contain numbers");
3555
- return Li({
3417
+ return ui({
3556
3418
  type: "Point",
3557
3419
  coordinates: o
3558
3420
  }, e, t);
3559
3421
  }
3560
- function Wi(o, e = "kilometers") {
3561
- const t = _i[e];
3422
+ function gi(o, e = "kilometers") {
3423
+ const t = hi[e];
3562
3424
  if (!t)
3563
3425
  throw new Error(e + " units is invalid");
3564
3426
  return o * t;
3565
3427
  }
3566
- function fe(o) {
3428
+ function de(o) {
3567
3429
  return o % 360 * Math.PI / 180;
3568
3430
  }
3569
- function rt(o) {
3431
+ function He(o) {
3570
3432
  return !isNaN(o) && o !== null && !Array.isArray(o);
3571
3433
  }
3572
- function at(o) {
3434
+ function $e(o) {
3573
3435
  if (!o)
3574
3436
  throw new Error("coord is required");
3575
3437
  if (!Array.isArray(o)) {
@@ -3582,35 +3444,35 @@ function at(o) {
3582
3444
  return [...o];
3583
3445
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
3584
3446
  }
3585
- function ji(o, e, t = {}) {
3586
- var i = at(o), n = at(e), s = fe(n[1] - i[1]), r = fe(n[0] - i[0]), a = fe(i[1]), l = fe(n[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(r / 2), 2) * Math.cos(a) * Math.cos(l);
3587
- return Wi(
3447
+ function yi(o, e, t = {}) {
3448
+ var i = $e(o), n = $e(e), s = de(n[1] - i[1]), r = de(n[0] - i[0]), a = de(i[1]), l = de(n[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(r / 2), 2) * Math.cos(a) * Math.cos(l);
3449
+ return gi(
3588
3450
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3589
3451
  t.units
3590
3452
  );
3591
3453
  }
3592
- function Lt(o, e, t) {
3454
+ function Ct(o, e, t) {
3593
3455
  if (o !== null)
3594
- for (var i, n, s, r, a, l, d, c = 0, h = 0, u, p = o.type, g = p === "FeatureCollection", f = p === "Feature", P = g ? o.features.length : 1, y = 0; y < P; y++) {
3595
- d = g ? o.features[y].geometry : f ? o.geometry : o, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
3596
- for (var C = 0; C < a; C++) {
3597
- var m = 0, v = 0;
3598
- if (r = u ? d.geometries[C] : d, r !== null) {
3456
+ for (var i, n, s, r, a, l, d, c = 0, h = 0, u, p = o.type, g = p === "FeatureCollection", y = p === "Feature", P = g ? o.features.length : 1, f = 0; f < P; f++) {
3457
+ d = g ? o.features[f].geometry : y ? o.geometry : o, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
3458
+ for (var m = 0; m < a; m++) {
3459
+ var C = 0, v = 0;
3460
+ if (r = u ? d.geometries[m] : d, r !== null) {
3599
3461
  l = r.coordinates;
3600
- var x = r.type;
3601
- switch (c = x === "Polygon" || x === "MultiPolygon" ? 1 : 0, x) {
3462
+ var S = r.type;
3463
+ switch (c = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
3602
3464
  case null:
3603
3465
  break;
3604
3466
  case "Point":
3605
3467
  if (e(
3606
3468
  l,
3607
3469
  h,
3608
- y,
3609
- m,
3470
+ f,
3471
+ C,
3610
3472
  v
3611
3473
  ) === !1)
3612
3474
  return !1;
3613
- h++, m++;
3475
+ h++, C++;
3614
3476
  break;
3615
3477
  case "LineString":
3616
3478
  case "MultiPoint":
@@ -3618,14 +3480,14 @@ function Lt(o, e, t) {
3618
3480
  if (e(
3619
3481
  l[i],
3620
3482
  h,
3621
- y,
3622
- m,
3483
+ f,
3484
+ C,
3623
3485
  v
3624
3486
  ) === !1)
3625
3487
  return !1;
3626
- h++, x === "MultiPoint" && m++;
3488
+ h++, S === "MultiPoint" && C++;
3627
3489
  }
3628
- x === "LineString" && m++;
3490
+ S === "LineString" && C++;
3629
3491
  break;
3630
3492
  case "Polygon":
3631
3493
  case "MultiLineString":
@@ -3634,16 +3496,16 @@ function Lt(o, e, t) {
3634
3496
  if (e(
3635
3497
  l[i][n],
3636
3498
  h,
3637
- y,
3638
- m,
3499
+ f,
3500
+ C,
3639
3501
  v
3640
3502
  ) === !1)
3641
3503
  return !1;
3642
3504
  h++;
3643
3505
  }
3644
- x === "MultiLineString" && m++, x === "Polygon" && v++;
3506
+ S === "MultiLineString" && C++, S === "Polygon" && v++;
3645
3507
  }
3646
- x === "Polygon" && m++;
3508
+ S === "Polygon" && C++;
3647
3509
  break;
3648
3510
  case "MultiPolygon":
3649
3511
  for (i = 0; i < l.length; i++) {
@@ -3652,8 +3514,8 @@ function Lt(o, e, t) {
3652
3514
  if (e(
3653
3515
  l[i][n][s],
3654
3516
  h,
3655
- y,
3656
- m,
3517
+ f,
3518
+ C,
3657
3519
  v
3658
3520
  ) === !1)
3659
3521
  return !1;
@@ -3661,12 +3523,12 @@ function Lt(o, e, t) {
3661
3523
  }
3662
3524
  v++;
3663
3525
  }
3664
- m++;
3526
+ C++;
3665
3527
  }
3666
3528
  break;
3667
3529
  case "GeometryCollection":
3668
3530
  for (i = 0; i < r.geometries.length; i++)
3669
- if (Lt(r.geometries[i], e) === !1)
3531
+ if (Ct(r.geometries[i], e) === !1)
3670
3532
  return !1;
3671
3533
  break;
3672
3534
  default:
@@ -3676,9 +3538,9 @@ function Lt(o, e, t) {
3676
3538
  }
3677
3539
  }
3678
3540
  }
3679
- function Bi(o, e) {
3680
- var t, i, n, s, r, a, l, d, c, h, u = 0, p = o.type === "FeatureCollection", g = o.type === "Feature", f = p ? o.features.length : 1;
3681
- for (t = 0; t < f; t++) {
3541
+ function fi(o, e) {
3542
+ var t, i, n, s, r, a, l, d, c, h, u = 0, p = o.type === "FeatureCollection", g = o.type === "Feature", y = p ? o.features.length : 1;
3543
+ for (t = 0; t < y; t++) {
3682
3544
  for (a = p ? o.features[t].geometry : g ? o.geometry : o, d = p ? o.features[t].properties : g ? o.properties : {}, c = p ? o.features[t].bbox : g ? o.bbox : void 0, h = p ? o.features[t].id : g ? o.id : void 0, l = a ? a.type === "GeometryCollection" : !1, r = l ? a.geometries.length : 1, n = 0; n < r; n++) {
3683
3545
  if (s = l ? a.geometries[n] : a, s === null) {
3684
3546
  if (e(
@@ -3727,9 +3589,9 @@ function Bi(o, e) {
3727
3589
  u++;
3728
3590
  }
3729
3591
  }
3730
- function Ni(o, e, t) {
3592
+ function mi(o, e, t) {
3731
3593
  var i = t;
3732
- return Bi(
3594
+ return fi(
3733
3595
  o,
3734
3596
  function(n, s, r, a, l) {
3735
3597
  s === 0 && t === void 0 ? i = n : i = e(
@@ -3743,21 +3605,21 @@ function Ni(o, e, t) {
3743
3605
  }
3744
3606
  ), i;
3745
3607
  }
3746
- function Ai(o) {
3747
- return Ni(
3608
+ function Ci(o) {
3609
+ return mi(
3748
3610
  o,
3749
- (e, t) => e + Gi(t),
3611
+ (e, t) => e + Pi(t),
3750
3612
  0
3751
3613
  );
3752
3614
  }
3753
- function Gi(o) {
3615
+ function Pi(o) {
3754
3616
  let e = 0, t;
3755
3617
  switch (o.type) {
3756
3618
  case "Polygon":
3757
- return lt(o.coordinates);
3619
+ return Je(o.coordinates);
3758
3620
  case "MultiPolygon":
3759
3621
  for (t = 0; t < o.coordinates.length; t++)
3760
- e += lt(o.coordinates[t]);
3622
+ e += Je(o.coordinates[t]);
3761
3623
  return e;
3762
3624
  case "Point":
3763
3625
  case "MultiPoint":
@@ -3767,42 +3629,42 @@ function Gi(o) {
3767
3629
  }
3768
3630
  return 0;
3769
3631
  }
3770
- function lt(o) {
3632
+ function Je(o) {
3771
3633
  let e = 0;
3772
3634
  if (o && o.length > 0) {
3773
- e += Math.abs(dt(o[0]));
3635
+ e += Math.abs(qe(o[0]));
3774
3636
  for (let t = 1; t < o.length; t++)
3775
- e -= Math.abs(dt(o[t]));
3637
+ e -= Math.abs(qe(o[t]));
3776
3638
  }
3777
3639
  return e;
3778
3640
  }
3779
- var Vi = L * L / 2, Fe = Math.PI / 180;
3780
- function dt(o) {
3641
+ var vi = L * L / 2, Se = Math.PI / 180;
3642
+ function qe(o) {
3781
3643
  const e = o.length - 1;
3782
3644
  if (e <= 2) return 0;
3783
3645
  let t = 0, i = 0;
3784
3646
  for (; i < e; ) {
3785
- const n = o[i], s = o[i + 1 === e ? 0 : i + 1], r = o[i + 2 >= e ? (i + 2) % e : i + 2], a = n[0] * Fe, l = s[1] * Fe, d = r[0] * Fe;
3647
+ const n = o[i], s = o[i + 1 === e ? 0 : i + 1], r = o[i + 2 >= e ? (i + 2) % e : i + 2], a = n[0] * Se, l = s[1] * Se, d = r[0] * Se;
3786
3648
  t += (d - a) * Math.sin(l), i++;
3787
3649
  }
3788
- return t * Vi;
3650
+ return t * vi;
3789
3651
  }
3790
- function Ui(o, e = {}) {
3652
+ function Si(o, e = {}) {
3791
3653
  let t = 0, i = 0, n = 0;
3792
- return Lt(
3654
+ return Ct(
3793
3655
  o,
3794
3656
  function(s) {
3795
3657
  t += s[0], i += s[1], n++;
3796
3658
  }
3797
- ), ki([t / n, i / n], e.properties);
3659
+ ), pi([t / n, i / n], e.properties);
3798
3660
  }
3799
- class zi extends Oi {
3661
+ class bi extends ci {
3800
3662
  /**
3801
3663
  * Constructor
3802
3664
  * @param options Plugin control options
3803
3665
  */
3804
3666
  constructor(t) {
3805
- let i = Fi;
3667
+ let i = li;
3806
3668
  t && (i = Object.assign(i, t));
3807
3669
  super({
3808
3670
  modes: i.modes,
@@ -4012,7 +3874,7 @@ class zi extends Oi {
4012
3874
  */
4013
3875
  calcArea(t) {
4014
3876
  if (t.geometry.type !== "Polygon") return t;
4015
- const i = Ai(t.geometry);
3877
+ const i = Ci(t.geometry);
4016
3878
  let n = i, s = "m²";
4017
3879
  return this.areaUnit === "metric" ? i >= 1e6 ? (n = i / 1e6, s = "km²") : i >= 1e4 && (n = i / 1e4, s = "ha") : i >= 258998811e-2 ? (n = i / 258998811e-2, s = "mi²") : i >= 4046.856 ? (n = i / 4046.856, s = "acre") : i >= 0.83612736 && (n = i / 0.83612736, s = "yd²"), n = parseFloat(n.toFixed(this.areaPrecision)), t.properties.area = n, t.properties.unit = s, t;
4018
3880
  }
@@ -4036,7 +3898,7 @@ class zi extends Oi {
4036
3898
  let n = 0;
4037
3899
  const s = [];
4038
3900
  for (let l = 0; l < i.length - 1; l++) {
4039
- const d = i[l], c = i[l + 1], h = ji(d, c, { units: this.distanceUnit });
3901
+ const d = i[l], c = i[l + 1], h = yi(d, c, { units: this.distanceUnit });
4040
3902
  n += h;
4041
3903
  const u = JSON.parse(JSON.stringify(t));
4042
3904
  if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, c], u.properties.originalId = t.id, u.properties.distance = parseFloat(h.toFixed(this.distancePrecision)), u.properties.total = parseFloat(n.toFixed(this.distancePrecision)), u.properties.unit = this.getDistanceUnitName(this.distanceUnit), this.measureOptions.computeElevation === !0) {
@@ -4070,7 +3932,7 @@ class zi extends Oi {
4070
3932
  }
4071
3933
  ));
4072
3934
  const l = JSON.parse(JSON.stringify(s));
4073
- l.id = l.id + "-area-label", l.geometry = Ui(s.geometry).geometry, l.properties.originalId = s.id, s = this.calcArea(s), l.properties.area = s.properties.area, l.properties.unit = s.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (r = this.map.getSource(
3935
+ l.id = l.id + "-area-label", l.geometry = Si(s.geometry).geometry, l.properties.originalId = s.id, s = this.calcArea(s), l.properties.area = s.properties.area, l.properties.unit = s.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (r = this.map.getSource(
4074
3936
  this.measureOptions.polygonLayerSpec.source
4075
3937
  )) == null || r.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
4076
3938
  this.measureOptions.lineLayerLabelSpec.id
@@ -4106,11 +3968,11 @@ class zi extends Oi {
4106
3968
  typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
4107
3969
  const h = c.geometry.coordinates, u = h[0], p = h[1];
4108
3970
  if (d === 0) {
4109
- const f = JSON.parse(JSON.stringify(c));
4110
- f.id = `${c.id}-node-${d}`, f.geometry = {
3971
+ const y = JSON.parse(JSON.stringify(c));
3972
+ y.id = `${c.id}-node-${d}`, y.geometry = {
4111
3973
  type: "Point",
4112
3974
  coordinates: u
4113
- }, f.properties.distance = 0, f.properties.total = 0, c.properties.elevation_start && (f.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(f);
3975
+ }, y.properties.distance = 0, y.properties.total = 0, c.properties.elevation_start && (y.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
4114
3976
  }
4115
3977
  const g = JSON.parse(JSON.stringify(c));
4116
3978
  g.id = `${c.id}-node-${d + 1}`, g.geometry = {
@@ -4182,12 +4044,12 @@ class zi extends Oi {
4182
4044
  }
4183
4045
  }
4184
4046
  export {
4185
- Xi as AvailableMeasureModes,
4186
- Ri as AvailableModes,
4187
- zi as MaplibreMeasureControl,
4188
- Oi as MaplibreTerradrawControl,
4189
- Ei as defaultControlOptions,
4190
- Fi as defaultMeasureControlOptions,
4191
- Di as getDefaultModeOptions
4047
+ wi as AvailableMeasureModes,
4048
+ Mi as AvailableModes,
4049
+ bi as MaplibreMeasureControl,
4050
+ ci as MaplibreTerradrawControl,
4051
+ ai as defaultControlOptions,
4052
+ li as defaultMeasureControlOptions,
4053
+ di as getDefaultModeOptions
4192
4054
  };
4193
4055
  //# sourceMappingURL=maplibre-gl-terradraw.es.js.map