@watergis/maplibre-gl-terradraw 1.2.3 → 1.3.0

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.
@@ -1,22 +1,22 @@
1
- var Le = Object.defineProperty;
2
- var ke = (r, t, e) => t in r ? Le(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var k = (r, t, e) => ke(r, typeof t != "symbol" ? t + "" : t, e);
1
+ var Be = Object.defineProperty;
2
+ var je = (r, t, e) => t in r ? Be(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var _ = (r, t, e) => je(r, typeof t != "symbol" ? t + "" : t, e);
4
4
  import "maplibre-gl";
5
- function M() {
6
- return M = Object.assign ? Object.assign.bind() : function(r) {
5
+ function I() {
6
+ return I = Object.assign ? Object.assign.bind() : function(r) {
7
7
  for (var t = 1; t < arguments.length; t++) {
8
8
  var e = arguments[t];
9
9
  for (var i in e) ({}).hasOwnProperty.call(e, i) && (r[i] = e[i]);
10
10
  }
11
11
  return r;
12
- }, M.apply(null, arguments);
12
+ }, I.apply(null, arguments);
13
13
  }
14
- var w;
14
+ var M;
15
15
  (function(r) {
16
16
  r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
17
- })(w || (w = {}));
18
- const V = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, J = "edited", st = "closingPoint", Ft = "snappingPoint";
19
- function xt(r) {
17
+ })(M || (M = {}));
18
+ const V = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, J = "edited", st = "closingPoint", Ot = "snappingPoint";
19
+ function It(r) {
20
20
  return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
21
21
  }
22
22
  function Tt(r) {
@@ -24,7 +24,7 @@ function Tt(r) {
24
24
  return typeof t == "number" && !isNaN(new Date(t).valueOf());
25
25
  }(r);
26
26
  }
27
- const We = "Feature mode property does not match the mode being added to";
27
+ const Ne = "Feature mode property does not match the mode being added to";
28
28
  var Y;
29
29
  (function(r) {
30
30
  r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
@@ -46,7 +46,7 @@ class N {
46
46
  registerBehaviors(t) {
47
47
  }
48
48
  constructor(t) {
49
- 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 = Y.Drawing, this.mode = "base", this._state = "unregistered", this._styles = t && t.styles ? M({}, t.styles) : {}, this.pointerDistance = t && t.pointerDistance || 40, this.validate = t && t.validation, this.projection = t && t.projection || "web-mercator";
49
+ 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 = Y.Drawing, this.mode = "base", this._state = "unregistered", this._styles = t && t.styles ? I({}, t.styles) : {}, this.pointerDistance = t && t.pointerDistance || 40, this.validate = t && t.validation, this.projection = t && t.projection || "web-mercator";
50
50
  }
51
51
  setDrawing() {
52
52
  if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
@@ -71,9 +71,9 @@ class N {
71
71
  if (this._state === "unregistered") throw new Error("Mode must be registered");
72
72
  const e = function(i, o) {
73
73
  let s;
74
- if (xt(i)) if (i.id == null) s = "Feature has no id";
74
+ if (It(i)) if (i.id == null) s = "Feature has no id";
75
75
  else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
76
- else if (o(i.id)) if (xt(i.geometry)) if (xt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
76
+ else if (o(i.id)) if (It(i.geometry)) if (It(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
77
77
  if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
78
78
  } else s = "Feature coordinates is not an array";
79
79
  else s = "Feature is not Point, LineString or Polygon";
@@ -84,14 +84,14 @@ class N {
84
84
  return s ? { valid: !1, reason: s } : { valid: !0 };
85
85
  }(t, this.store.idStrategy.isValidId);
86
86
  if (this.validate) {
87
- const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional });
87
+ const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional });
88
88
  return { valid: e.valid && i.valid, reason: i.reason };
89
89
  }
90
90
  return { valid: e.valid, reason: e.reason };
91
91
  }
92
92
  validateModeFeature(t, e) {
93
93
  const i = this.performFeatureValidation(t);
94
- return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: We } : e(t) : { valid: !1, reason: i.reason };
94
+ return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Ne } : e(t) : { valid: !1, reason: i.reason };
95
95
  }
96
96
  onFinish(t, e) {
97
97
  }
@@ -123,7 +123,7 @@ class N {
123
123
  return t === void 0 ? e : typeof t == "function" ? t(i) : t;
124
124
  }
125
125
  }
126
- class Be extends N {
126
+ class Ae extends N {
127
127
  constructor(...t) {
128
128
  super(...t), this.type = Y.Select;
129
129
  }
@@ -132,34 +132,34 @@ function G(r, t) {
132
132
  const e = (d) => d * Math.PI / 180, i = e(r[1]), o = e(r[0]), s = e(t[1]), n = s - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(s) * Math.sin(a / 2) * Math.sin(a / 2);
133
133
  return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
134
134
  }
135
- const ae = 63710088e-1;
136
- function F(r) {
135
+ const le = 63710088e-1;
136
+ function E(r) {
137
137
  return r % 360 * Math.PI / 180;
138
138
  }
139
- function le(r) {
139
+ function de(r) {
140
140
  return r / 6371.0088;
141
141
  }
142
142
  function U(r) {
143
143
  return r % (2 * Math.PI) * 180 / Math.PI;
144
144
  }
145
- function E(r, t = 9) {
145
+ function F(r, t = 9) {
146
146
  const e = Math.pow(10, t);
147
147
  return Math.round(r * e) / e;
148
148
  }
149
- const Gt = 57.29577951308232, Vt = 0.017453292519943295, ut = 6378137, x = (r, t) => ({ x: r === 0 ? 0 : r * Vt * ut, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Vt / 2)) * ut }), W = (r, t) => ({ lng: r === 0 ? 0 : Gt * (r / ut), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ut)) - Math.PI / 2) * Gt });
150
- function je(r, t, e) {
151
- const i = F(r[0]), o = F(r[1]), s = F(e), n = le(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
149
+ const Gt = 57.29577951308232, Vt = 0.017453292519943295, pt = 6378137, x = (r, t) => ({ x: r === 0 ? 0 : r * Vt * pt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Vt / 2)) * pt }), W = (r, t) => ({ lng: r === 0 ? 0 : Gt * (r / pt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / pt)) - Math.PI / 2) * Gt });
150
+ function Te(r, t, e) {
151
+ const i = E(r[0]), o = E(r[1]), s = E(e), n = de(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
152
152
  return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
153
153
  }
154
154
  function Ut(r) {
155
155
  const { center: t, radiusKilometers: e, coordinatePrecision: i } = r, o = r.steps ? r.steps : 64, s = [];
156
156
  for (let n = 0; n < o; n++) {
157
- const a = je(t, e, -360 * n / o);
158
- s.push([E(a[0], i), E(a[1], i)]);
157
+ const a = Te(t, e, -360 * n / o);
158
+ s.push([F(a[0], i), F(a[1], i)]);
159
159
  }
160
160
  return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
161
161
  }
162
- function Ot(r) {
162
+ function Dt(r) {
163
163
  let t;
164
164
  if (r.geometry.type === "Polygon") t = r.geometry.coordinates;
165
165
  else {
@@ -175,8 +175,8 @@ function Ot(r) {
175
175
  function o(s, n, a, l) {
176
176
  const d = t[s][n], c = t[s][n + 1], h = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
177
177
  if (at(v, m) || at(v, C) || at(f, m) || at(C, m)) return null;
178
- const P = v[0], S = v[1], I = f[0], b = f[1], O = m[0], A = m[1], _ = C[0], j = C[1], z = (P - I) * (A - j) - (S - b) * (O - _);
179
- return z === 0 ? null : [((P * b - S * I) * (O - _) - (P - I) * (O * j - A * _)) / z, ((P * b - S * I) * (A - j) - (S - b) * (O * j - A * _)) / z];
178
+ const P = v[0], S = v[1], b = f[0], w = f[1], D = m[0], A = m[1], L = C[0], j = C[1], z = (P - b) * (A - j) - (S - w) * (D - L);
179
+ return z === 0 ? null : [((P * w - S * b) * (D - L) - (P - b) * (D * j - A * L)) / z, ((P * w - S * b) * (A - j) - (S - w) * (D * j - A * L)) / z];
180
180
  }(d, c, h, u);
181
181
  if (p === null) return;
182
182
  let g, y;
@@ -186,7 +186,7 @@ function Ot(r) {
186
186
  function at(r, t) {
187
187
  return r[0] === t[0] && r[1] === t[1];
188
188
  }
189
- function mt(r, t) {
189
+ function vt(r, t) {
190
190
  return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (i = r[0]) >= -180 && i <= 180 && (e = r[1]) >= -90 && e <= 90 && zt(r[0]) <= t && zt(r[1]) <= t;
191
191
  var e, i;
192
192
  }
@@ -195,24 +195,24 @@ function zt(r) {
195
195
  for (; Math.round(r * t) / t !== r; ) t *= 10, e++;
196
196
  return e;
197
197
  }
198
- const Ne = "Feature has holes", Ae = "Feature has less than 4 coordinates", Te = "Feature has invalid coordinates", Ge = "Feature coordinates are not closed";
199
- function vt(r, t) {
200
- return r.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : r.geometry.coordinates.length !== 1 ? { valid: !1, reason: Ne } : r.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Ae } : r.geometry.coordinates[0].every((o) => mt(o, t)) ? (e = r.geometry.coordinates[0][0])[0] !== (i = r.geometry.coordinates[0][r.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: Ge } : { valid: !0 } : { valid: !1, reason: Te };
198
+ const Ge = "Feature has holes", Ve = "Feature has less than 4 coordinates", Ue = "Feature has invalid coordinates", ze = "Feature coordinates are not closed";
199
+ function Ct(r, t) {
200
+ return r.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : r.geometry.coordinates.length !== 1 ? { valid: !1, reason: Ge } : r.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Ve } : r.geometry.coordinates[0].every((o) => vt(o, t)) ? (e = r.geometry.coordinates[0][0])[0] !== (i = r.geometry.coordinates[0][r.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: ze } : { valid: !0 } : { valid: !1, reason: Ue };
201
201
  var e, i;
202
202
  }
203
203
  function nt(r, t) {
204
- const e = vt(r, t);
205
- return e.valid ? Ot(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
204
+ const e = Ct(r, t);
205
+ return e.valid ? Dt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
206
206
  }
207
- class de extends N {
207
+ class ce extends N {
208
208
  constructor(t) {
209
209
  var e;
210
210
  super(t), 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;
211
211
  const i = { start: "crosshair" };
212
- if (this.cursors = t && t.cursors ? M({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
212
+ if (this.cursors = t && t.cursors ? I({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
213
213
  else {
214
214
  const o = { cancel: "Escape", finish: "Enter" };
215
- this.keyEvents = t && t.keyEvents ? M({}, o, t.keyEvents) : o;
215
+ this.keyEvents = t && t.keyEvents ? I({}, o, t.keyEvents) : o;
216
216
  }
217
217
  this.startingRadiusKilometers = (e = t == null ? void 0 : t.startingRadiusKilometers) != null ? e : 1e-5, this.validate = t == null ? void 0 : t.validation;
218
218
  }
@@ -221,7 +221,7 @@ class de extends N {
221
221
  const t = this.currentCircleId;
222
222
  if (this.validate && t) {
223
223
  const e = this.store.getGeometryCopy(t);
224
- if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Finish }).valid) return;
224
+ if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid) return;
225
225
  }
226
226
  this.cursorMovedAfterInitialCursorDown = !1, this.center = void 0, this.currentCircleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
227
227
  }
@@ -261,7 +261,7 @@ class de extends N {
261
261
  }
262
262
  }
263
263
  styleFeature(t) {
264
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
264
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
265
265
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
266
266
  }
267
267
  validateFeature(t) {
@@ -281,8 +281,8 @@ class de extends N {
281
281
  i = function(s) {
282
282
  const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = x(h, u), y = [];
283
283
  for (let v = 0; v < d; v++) {
284
- const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, S] = [p + m, g + C], { lng: I, lat: b } = W(P, S);
285
- y.push([E(I, l), E(b, l)]);
284
+ const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, S] = [p + m, g + C], { lng: b, lat: w } = W(P, S);
285
+ y.push([F(b, l), F(w, l)]);
286
286
  }
287
287
  return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
288
288
  }({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
@@ -290,24 +290,24 @@ class de extends N {
290
290
  if (this.projection !== "globe") throw new Error("Invalid projection");
291
291
  i = Ut({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
292
292
  }
293
- if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional }).valid) return;
293
+ if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid) return;
294
294
  this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
295
295
  }
296
296
  }
297
297
  }
298
- const D = (r, t) => {
298
+ const O = (r, t) => {
299
299
  const { x: e, y: i } = r, { x: o, y: s } = t, n = o - e, a = s - i;
300
300
  return Math.sqrt(a * a + n * n);
301
301
  };
302
- let ce = class extends N {
302
+ let he = class extends N {
303
303
  constructor(t) {
304
304
  super(t), 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;
305
305
  const e = { start: "crosshair", close: "pointer" };
306
- if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.preventPointsNearClose = t && t.preventPointsNearClose || !0, t && t.autoCloseTimeout && !t.autoClose) throw new Error("autoCloseTimeout is set, but autoClose is not enabled");
306
+ if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.preventPointsNearClose = t && t.preventPointsNearClose || !0, t && t.autoCloseTimeout && !t.autoClose) throw new Error("autoCloseTimeout is set, but autoClose is not enabled");
307
307
  if (this.autoClose = t && t.autoClose || !1, this.autoCloseTimeout = t && t.autoCloseTimeout || 500, this.minDistance = t && t.minDistance || 20, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
308
308
  else {
309
309
  const i = { cancel: "Escape", finish: "Enter" };
310
- this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
310
+ this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
311
311
  }
312
312
  this.validate = t == null ? void 0 : t.validation;
313
313
  }
@@ -316,7 +316,7 @@ let ce = class extends N {
316
316
  const t = this.currentId;
317
317
  if (this.validate && t) {
318
318
  const e = this.store.getGeometryCopy(t);
319
- if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Finish }).valid) return;
319
+ if (!this.validate({ type: "Feature", id: t, geometry: e, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid) return;
320
320
  }
321
321
  this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.hasLeftStartingPoint = !1, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
322
322
  }
@@ -328,8 +328,8 @@ let ce = class extends N {
328
328
  }
329
329
  onMouseMove(t) {
330
330
  if (this.currentId === void 0 || this.startingClick === !1) return;
331
- const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l = D({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
332
- if (D({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
331
+ const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l = O({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
332
+ if (O({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
333
333
  if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
334
334
  this.preventNewFeature = !1;
335
335
  }, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
@@ -337,7 +337,7 @@ let ce = class extends N {
337
337
  if (l < this.minDistance) return;
338
338
  e.coordinates[0].pop();
339
339
  const p = { type: "Polygon", coordinates: [[...e.coordinates[0], [t.lng, t.lat], e.coordinates[0][0]]] };
340
- this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
340
+ this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
341
341
  }
342
342
  onClick(t) {
343
343
  if (!this.preventNewFeature) {
@@ -368,40 +368,40 @@ let ce = class extends N {
368
368
  }
369
369
  }
370
370
  styleFeature(t) {
371
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
371
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
372
372
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e) : (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 40), e);
373
373
  }
374
374
  validateFeature(t) {
375
- return this.validateModeFeature(t, (e) => vt(e, this.coordinatePrecision));
375
+ return this.validateModeFeature(t, (e) => Ct(e, this.coordinatePrecision));
376
376
  }
377
377
  }, B = class {
378
378
  constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: s, coordinatePrecision: n, projection: a }) {
379
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 = t, this.mode = e, this.project = i, this.unproject = o, this.pointerDistance = s, this.coordinatePrecision = n, this.projection = a;
380
380
  }
381
381
  };
382
- function he({ unproject: r, point: t, pointerDistance: e }) {
382
+ function ue({ unproject: r, point: t, pointerDistance: e }) {
383
383
  const i = e / 2, { x: o, y: s } = t;
384
384
  return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[r(o - i, s - i), r(o + i, s - i), r(o + i, s + i), r(o - i, s + i), r(o - i, s - i)].map((n) => [n.lng, n.lat])] } };
385
385
  }
386
- let Ct = class extends B {
386
+ let Pt = class extends B {
387
387
  constructor(t) {
388
388
  super(t);
389
389
  }
390
390
  create(t) {
391
391
  const { containerX: e, containerY: i } = t;
392
- return he({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
392
+ return ue({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
393
393
  }
394
394
  };
395
- class Pt extends B {
395
+ class St extends B {
396
396
  constructor(t) {
397
397
  super(t);
398
398
  }
399
399
  measure(t, e) {
400
400
  const { x: i, y: o } = this.project(e[0], e[1]);
401
- return D({ x: i, y: o }, { x: t.containerX, y: t.containerY });
401
+ return O({ x: i, y: o }, { x: t.containerX, y: t.containerY });
402
402
  }
403
403
  }
404
- class ue extends B {
404
+ class pe extends B {
405
405
  constructor(t, e, i) {
406
406
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== s)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
407
407
  }
@@ -422,15 +422,15 @@ class ue extends B {
422
422
  }
423
423
  }
424
424
  function Rt(r, t, e) {
425
- const i = F(r[0]), o = F(r[1]), s = F(e), n = le(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
425
+ const i = E(r[0]), o = E(r[1]), s = E(e), n = de(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
426
426
  return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
427
427
  }
428
428
  function rt({ x: r, y: t }, e, i) {
429
- const o = F(i);
429
+ const o = E(i);
430
430
  return { x: r + e * Math.cos(o), y: t + e * Math.sin(o) };
431
431
  }
432
432
  function Xt(r, t) {
433
- const e = F(r[0]), i = F(t[0]), o = F(r[1]), s = F(t[1]), n = Math.sin(i - e) * Math.cos(s), a = Math.cos(o) * Math.sin(s) - Math.sin(o) * Math.cos(s) * Math.cos(i - e);
433
+ const e = E(r[0]), i = E(t[0]), o = E(r[1]), s = E(t[1]), n = Math.sin(i - e) * Math.cos(s), a = Math.cos(o) * Math.sin(s) - Math.sin(o) * Math.cos(s) * Math.cos(i - e);
434
434
  return U(Math.atan2(n, a));
435
435
  }
436
436
  function T({ x: r, y: t }, { x: e, y: i }) {
@@ -440,7 +440,7 @@ function T({ x: r, y: t }, { x: e, y: i }) {
440
440
  function K(r) {
441
441
  return (r + 360) % 360;
442
442
  }
443
- function Ve(r, t, e) {
443
+ function Re(r, t, e) {
444
444
  const i = [], o = r.length;
445
445
  let s, n, a, l = 0;
446
446
  for (let c = 0; c < r.length && !(t >= l && c === r.length - 1); c++) {
@@ -462,7 +462,7 @@ function lt(r) {
462
462
  function Kt(r) {
463
463
  return r * (180 / Math.PI);
464
464
  }
465
- class Ue extends B {
465
+ class Xe extends B {
466
466
  constructor(t) {
467
467
  super(t), this.config = void 0, this.config = t;
468
468
  }
@@ -475,7 +475,7 @@ class Ue extends B {
475
475
  Number.isInteger(n) || (n = Math.floor(n) + 1);
476
476
  const a = [];
477
477
  for (let d = 0; d < n; d++) {
478
- const c = Ve(o, i * d, i * (d + 1));
478
+ const c = Re(o, i * d, i * (d + 1));
479
479
  a.push(c);
480
480
  }
481
481
  const l = [];
@@ -491,38 +491,38 @@ class Ue extends B {
491
491
  for (let y = 0; y <= l; y++) {
492
492
  const v = y / l, f = Math.sin((1 - v) * g) / Math.sin(g), m = Math.sin(v * g) / Math.sin(g), C = f * Math.cos(c) * Math.cos(h) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(c) * Math.sin(h) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(c) + m * Math.sin(u);
493
493
  if (isNaN(C) || isNaN(P) || isNaN(S)) continue;
494
- const I = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), b = Math.atan2(P, C);
495
- isNaN(I) || isNaN(b) || d.push([Kt(b), Kt(I)]);
494
+ const b = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), w = Math.atan2(P, C);
495
+ isNaN(b) || isNaN(w) || d.push([Kt(w), Kt(b)]);
496
496
  }
497
497
  return d.slice(1, -1);
498
498
  }(t, e, Math.floor(o / i));
499
499
  return this.limitCoordinates(s);
500
500
  }
501
501
  limitCoordinates(t) {
502
- return t.map((e) => [E(e[0], this.config.coordinatePrecision), E(e[1], this.config.coordinatePrecision)]);
502
+ return t.map((e) => [F(e[0], this.config.coordinatePrecision), F(e[1], this.config.coordinatePrecision)]);
503
503
  }
504
504
  }
505
505
  function Z(r, t) {
506
506
  return r[0] === t[0] && r[1] === t[1];
507
507
  }
508
- function pe(r, t) {
509
- return r.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : r.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : r.geometry.coordinates.every((e) => mt(e, t)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
508
+ function ge(r, t) {
509
+ return r.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : r.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : r.geometry.coordinates.every((e) => vt(e, t)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
510
510
  }
511
- class ge extends N {
511
+ class ye extends N {
512
512
  constructor(t) {
513
513
  super(t), 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;
514
514
  const e = { start: "crosshair", close: "pointer" };
515
- if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
515
+ if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
516
516
  else {
517
517
  const i = { cancel: "Escape", finish: "Enter" };
518
- this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
518
+ this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
519
519
  }
520
520
  this.validate = t == null ? void 0 : t.validation, this.insertCoordinates = t == null ? void 0 : t.insertCoordinates;
521
521
  }
522
522
  close() {
523
523
  if (this.currentId === void 0) return;
524
524
  const t = this.store.getGeometryCopy(this.currentId);
525
- t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0, w.Commit);
525
+ t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0, M.Commit);
526
526
  const e = this.currentId;
527
527
  this.closingPointId && this.store.delete([this.closingPointId]), this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.snappedPointId = void 0, this.lastCommitedCoordinates = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
528
528
  }
@@ -549,18 +549,18 @@ class ge extends N {
549
549
  const e = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...t] }, properties: { mode: this.mode } }]);
550
550
  this.closingPointId = i, this.setCursor(this.cursors.close);
551
551
  const o = [...e, t];
552
- this.updateGeometries(o, void 0, w.Commit), this.currentCoordinate++;
552
+ this.updateGeometries(o, void 0, M.Commit), this.currentCoordinate++;
553
553
  }
554
554
  updateToLine(t, e) {
555
555
  if (!this.currentId) return;
556
556
  const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, s);
557
- if (D({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
557
+ if (O({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
558
558
  this.setCursor(this.cursors.close);
559
559
  const l = [...i, t];
560
- this.updateGeometries(l, i[i.length - 1], w.Commit), this.currentCoordinate++;
560
+ this.updateGeometries(l, i[i.length - 1], M.Commit), this.currentCoordinate++;
561
561
  }
562
562
  registerBehaviors(t) {
563
- this.coordinateSnapping = new ue(t, new Pt(t), new Ct(t)), this.insertPoint = new Ue(t);
563
+ this.coordinateSnapping = new pe(t, new St(t), new Pt(t)), this.insertPoint = new Xe(t);
564
564
  }
565
565
  start() {
566
566
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -574,7 +574,7 @@ class ge extends N {
574
574
  if (e) {
575
575
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
576
576
  else {
577
- const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ft]: !0 } }]);
577
+ const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
578
578
  this.snappedPointId = n;
579
579
  }
580
580
  t.lng = e[0], t.lat = e[1];
@@ -584,7 +584,7 @@ class ge extends N {
584
584
  const o = this.store.getGeometryCopy(this.currentId).coordinates;
585
585
  if (o.pop(), this.closingPointId) {
586
586
  const [n, a] = o[o.length - 1], { x: l, y: d } = this.project(n, a);
587
- D({ x: l, y: d }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
587
+ O({ x: l, y: d }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
588
588
  }
589
589
  let s = [...o, i];
590
590
  if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
@@ -594,7 +594,7 @@ class ge extends N {
594
594
  s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
595
595
  }
596
596
  }
597
- this.updateGeometries(s, void 0, w.Provisional);
597
+ this.updateGeometries(s, void 0, M.Provisional);
598
598
  }
599
599
  onClick(t) {
600
600
  this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
@@ -621,7 +621,7 @@ class ge extends N {
621
621
  }
622
622
  }
623
623
  styleFeature(t) {
624
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
624
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
625
625
  if (t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode) return e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex = 10, e;
626
626
  if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
627
627
  const i = t.properties[st];
@@ -630,7 +630,7 @@ class ge extends N {
630
630
  return e;
631
631
  }
632
632
  validateFeature(t) {
633
- return this.validateModeFeature(t, (e) => pe(e, this.coordinatePrecision));
633
+ return this.validateModeFeature(t, (e) => ge(e, this.coordinatePrecision));
634
634
  }
635
635
  snapCoordinate(t) {
636
636
  var e, i;
@@ -638,15 +638,15 @@ class ge extends N {
638
638
  return (e = this.snapping) != null && e.toCoordinate && (o = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t)), (i = this.snapping) != null && i.toCustom && (o = this.snapping.toCustom(t)), o;
639
639
  }
640
640
  }
641
- const ze = "Feature is not a Point", Re = "Feature has invalid coordinates";
642
- function ye(r, t) {
643
- return r.geometry.type !== "Point" ? { valid: !1, reason: ze } : mt(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: Re };
641
+ const Ke = "Feature is not a Point", Ye = "Feature has invalid coordinates";
642
+ function fe(r, t) {
643
+ return r.geometry.type !== "Point" ? { valid: !1, reason: Ke } : vt(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: Ye };
644
644
  }
645
- class Xe extends N {
645
+ class me extends N {
646
646
  constructor(t) {
647
647
  super(t), this.mode = "point", this.cursors = void 0, this.editable = void 0, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0;
648
648
  const e = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
649
- this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.editable = !(!t || !t.editable) && t.editable;
649
+ this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.editable = !(!t || !t.editable) && t.editable;
650
650
  }
651
651
  start() {
652
652
  this.setStarted(), this.setCursor(this.cursors.create);
@@ -657,7 +657,7 @@ class Xe extends N {
657
657
  onClick(t) {
658
658
  if (!this.store) throw new Error("Mode must be registered first");
659
659
  const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
660
- if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Finish }).valid) return;
660
+ if (this.validate && !this.validate({ type: "Feature", geometry: e, properties: i }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid) return;
661
661
  const [o] = this.store.create([{ geometry: e, properties: i }]);
662
662
  this.onFinish(o, { mode: this.mode, action: "draw" });
663
663
  }
@@ -685,16 +685,16 @@ class Xe extends N {
685
685
  this.editedFeatureId && (this.setCursor(this.cursors.dragStart), e(!1));
686
686
  }
687
687
  onDrag(t, e) {
688
- this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !0 }]), e(!0)));
688
+ this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !0 }]), e(!0)));
689
689
  }
690
690
  onDragEnd(t, e) {
691
691
  this.editedFeatureId !== void 0 && (this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.setCursor(this.cursors.dragEnd), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !1 }]), this.editedFeatureId = void 0, e(!0));
692
692
  }
693
693
  registerBehaviors(t) {
694
- this.pixelDistance = new Pt(t), this.clickBoundingBox = new Ct(t);
694
+ this.pixelDistance = new St(t), this.clickBoundingBox = new Pt(t);
695
695
  }
696
696
  styleFeature(t) {
697
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
697
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
698
698
  if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
699
699
  const i = !!(t.id && this.editedFeatureId === t.id);
700
700
  e.pointWidth = this.getNumericStylingValue(i ? this.styles.editedPointWidth : this.styles.pointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(i ? this.styles.editedPointColor : this.styles.pointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.editedPointOutlineColor : this.styles.pointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.editedPointOutlineWidth : this.styles.pointOutlineWidth, 2, t), e.zIndex = 30;
@@ -702,10 +702,10 @@ class Xe extends N {
702
702
  return e;
703
703
  }
704
704
  validateFeature(t) {
705
- return this.validateModeFeature(t, (e) => ye(e, this.coordinatePrecision));
705
+ return this.validateModeFeature(t, (e) => fe(e, this.coordinatePrecision));
706
706
  }
707
707
  }
708
- class Ke extends B {
708
+ class $e extends B {
709
709
  constructor(t, e) {
710
710
  super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
711
711
  }
@@ -741,27 +741,27 @@ function R(r, t) {
741
741
  }(r, t) / (Yt(r) * Yt(t));
742
742
  return Math.acos(Math.min(Math.max(e, -1), 1));
743
743
  }
744
- function Mt(r) {
745
- const t = F(r[1]), e = F(r[0]);
744
+ function bt(r) {
745
+ const t = E(r[1]), e = E(r[0]);
746
746
  return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
747
747
  }
748
748
  function X(r) {
749
749
  const [t, e, i] = r, o = U(Math.asin(i));
750
750
  return [U(Math.atan2(e, t)), o];
751
751
  }
752
- function Ye(r, t, e) {
753
- const i = Mt(r), o = Mt(t), s = Mt(e), [n, a, l] = s, [d, c, h] = function(j, z) {
752
+ function He(r, t, e) {
753
+ const i = bt(r), o = bt(t), s = bt(e), [n, a, l] = s, [d, c, h] = function(j, z) {
754
754
  const [kt, Wt, Bt] = j, [jt, Nt, At] = z;
755
755
  return [Wt * At - Bt * Nt, Bt * jt - kt * At, kt * Nt - Wt * jt];
756
- }(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, v = u * h - g * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], S = R(i, o), I = R(i, C), b = R(o, C), O = R(i, P), A = R(o, P);
757
- let _;
758
- return _ = I < O && I < A || b < O && b < A ? C : P, R(i, _) > S || R(o, _) > S ? G(X(_), X(i)) <= G(X(_), X(o)) ? [X(i), !0, !1] : [X(o), !1, !0] : [X(_), !1, !1];
756
+ }(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, v = u * h - g * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], S = R(i, o), b = R(i, C), w = R(o, C), D = R(i, P), A = R(o, P);
757
+ let L;
758
+ return L = b < D && b < A || w < D && w < A ? C : P, R(i, L) > S || R(o, L) > S ? G(X(L), X(i)) <= G(X(L), X(o)) ? [X(i), !0, !1] : [X(o), !1, !0] : [X(L), !1, !1];
759
759
  }
760
- function $e(r, t, e) {
760
+ function qe(r, t, e) {
761
761
  const i = t.x - r.x, o = t.y - r.y, s = Math.max(0, Math.min(1, ((e.x - r.x) * i + (e.y - r.y) * o) / (i * i + o * o)));
762
762
  return { x: r.x + s * i, y: r.y + s * o };
763
763
  }
764
- class He extends B {
764
+ class Je extends B {
765
765
  constructor(t, e, i) {
766
766
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== s)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
767
767
  }
@@ -783,14 +783,14 @@ class He extends B {
783
783
  for (let f of p) {
784
784
  const m = f[0], C = f[1];
785
785
  let P, S = 1 / 0;
786
- const I = x(m[0], m[1]), b = x(C[0], C[1]), O = x(u[0], u[1]);
786
+ const b = x(m[0], m[1]), w = x(C[0], C[1]), D = x(u[0], u[1]);
787
787
  if (m[0] === u[0] && m[1] === u[1]) P = m;
788
788
  else if (C[0] === u[0] && C[1] === u[1]) P = C;
789
789
  else {
790
- const { x: A, y: _ } = $e(I, b, O), { lng: j, lat: z } = W(A, _);
790
+ const { x: A, y: L } = qe(b, w, D), { lng: j, lat: z } = W(A, L);
791
791
  P = [j, z];
792
792
  }
793
- P && (S = D(O, x(P[0], P[1])), S < y && (g = P, y = S, v = p.indexOf(f)));
793
+ P && (S = O(D, x(P[0], P[1])), S < y && (g = P, y = S, v = p.indexOf(f)));
794
794
  }
795
795
  return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: v, distance: y };
796
796
  }(c, l) : this.config.projection === "globe" && (d = function(u, p) {
@@ -798,7 +798,7 @@ class He extends B {
798
798
  for (let f of p) {
799
799
  const m = f[0], C = f[1];
800
800
  let P, S = 1 / 0;
801
- m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = Ye(m, C, u), P && (S = G(u, P), S < y && (g = P, y = S, v = p.indexOf(f)));
801
+ m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = He(m, C, u), P && (S = G(u, P), S < y && (g = P, y = S, v = p.indexOf(f)));
802
802
  }
803
803
  return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: v };
804
804
  }(c, l)), !d) return;
@@ -807,26 +807,26 @@ class He extends B {
807
807
  }), s;
808
808
  }
809
809
  }
810
- class fe extends N {
810
+ class ve extends N {
811
811
  constructor(t) {
812
812
  super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.editable = void 0, this.snappedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.clickBoundingBox = void 0, this.cursors = void 0, this.mouseMove = !1;
813
813
  const e = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
814
- if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
814
+ if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
815
815
  else {
816
816
  const i = { cancel: "Escape", finish: "Enter" };
817
- this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
817
+ this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
818
818
  }
819
819
  this.editable = !(!t || !t.editable) && t.editable;
820
820
  }
821
821
  close() {
822
822
  if (this.currentId === void 0) return;
823
823
  const t = this.store.getGeometryCopy(this.currentId).coordinates[0];
824
- if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], w.Finish)) return;
824
+ if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], M.Finish)) return;
825
825
  const e = this.currentId;
826
826
  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(e, { mode: this.mode, action: "draw" });
827
827
  }
828
828
  registerBehaviors(t) {
829
- this.clickBoundingBox = new Ct(t), this.pixelDistance = new Pt(t), this.lineSnapping = new He(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new ue(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new Ke(t, this.pixelDistance);
829
+ this.clickBoundingBox = new Pt(t), this.pixelDistance = new St(t), this.lineSnapping = new Je(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new pe(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new $e(t, this.pixelDistance);
830
830
  }
831
831
  start() {
832
832
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -840,7 +840,7 @@ class fe extends N {
840
840
  if (e) {
841
841
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
842
842
  else {
843
- const [s] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ft]: !0 } }]);
843
+ const [s] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
844
844
  this.snappedPointId = s;
845
845
  }
846
846
  t.lng = e[0], t.lat = e[1];
@@ -856,7 +856,7 @@ class fe extends N {
856
856
  const { isClosing: s, isPreviousClosing: n } = this.closingPoints.isClosingPoint(t);
857
857
  n || s ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), o = [...i.slice(0, -2), i[0], i[0]]) : o = [...i.slice(0, -2), [t.lng, t.lat], i[0]];
858
858
  }
859
- this.updatePolygonGeometry(o, w.Provisional);
859
+ this.updatePolygonGeometry(o, M.Provisional);
860
860
  }
861
861
  updatePolygonGeometry(t, e) {
862
862
  if (!this.currentId) return !1;
@@ -886,13 +886,13 @@ class fe extends N {
886
886
  const e = this.snapCoordinate(t);
887
887
  e && (t.lng = e[0], t.lat = e[1]);
888
888
  const i = this.store.getGeometryCopy(this.currentId);
889
- if (Z([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]], w.Commit)) return;
889
+ if (Z([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]], M.Commit)) return;
890
890
  this.currentCoordinate++;
891
891
  } else if (this.currentCoordinate === 2 && this.currentId) {
892
892
  const e = this.snapCoordinate(t);
893
893
  e && (t.lng = e[0], t.lat = e[1]);
894
894
  const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
895
- if (Z([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]], w.Commit)) return;
895
+ if (Z([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]], M.Commit)) return;
896
896
  this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.currentCoordinate++;
897
897
  } else if (this.currentId) {
898
898
  const e = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: o } = this.closingPoints.isClosingPoint(t);
@@ -903,7 +903,7 @@ class fe extends N {
903
903
  const n = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
904
904
  return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
905
905
  }([[...e.slice(0, -1), [t.lng, t.lat], e[0]]]);
906
- if (!this.updatePolygonGeometry(n.geometry.coordinates[0], w.Commit)) return;
906
+ if (!this.updatePolygonGeometry(n.geometry.coordinates[0], M.Commit)) return;
907
907
  this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(n.geometry.coordinates[0]);
908
908
  }
909
909
  }
@@ -935,7 +935,7 @@ class fe extends N {
935
935
  const i = this.store.getGeometryCopy(this.editedFeatureId), o = i.coordinates[0];
936
936
  this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? this.editedFeatureCoordinateIndex === 0 || this.editedFeatureCoordinateIndex === i.coordinates[0].length - 1 ? (o[0] = [t.lng, t.lat], o[o.length - 1] = [t.lng, t.lat]) : o[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates[0].splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
937
937
  const s = { type: "Polygon", coordinates: i.coordinates };
938
- this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: s }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !0 }]), e(!0));
938
+ this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: s }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !0 }]), e(!0));
939
939
  }
940
940
  onDragEnd(t, e) {
941
941
  this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !1 }]), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
@@ -949,11 +949,11 @@ class fe extends N {
949
949
  }
950
950
  }
951
951
  styleFeature(t) {
952
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
952
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
953
953
  if (t.properties.mode === this.mode) {
954
954
  if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
955
955
  if (t.geometry.type === "Point") {
956
- const i = t.properties[J], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[Ft] ? "snappingPoint" : void 0;
956
+ const i = t.properties[J], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[Ot] ? "snappingPoint" : void 0;
957
957
  if (!o) return e;
958
958
  const s = { editedPoint: { width: this.styles.editedPointOutlineWidth, color: this.styles.editedPointColor, outlineColor: this.styles.editedPointOutlineColor, outlineWidth: this.styles.editedPointOutlineWidth }, closingPoint: { width: this.styles.closingPointWidth, color: this.styles.closingPointColor, outlineColor: this.styles.closingPointOutlineColor, outlineWidth: this.styles.closingPointOutlineWidth }, snappingPoint: { width: this.styles.snappingPointWidth, color: this.styles.snappingPointColor, outlineColor: this.styles.snappingPointOutlineColor, outlineWidth: this.styles.snappingPointOutlineWidth } };
959
959
  return e.pointWidth = this.getNumericStylingValue(s[o].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(s[o].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(s[o].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(s[o].outlineWidth, 2, t), e.zIndex = i ? 35 : 30, e;
@@ -962,17 +962,17 @@ class fe extends N {
962
962
  return e;
963
963
  }
964
964
  validateFeature(t) {
965
- return this.validateModeFeature(t, (e) => vt(e, this.coordinatePrecision));
965
+ return this.validateModeFeature(t, (e) => Ct(e, this.coordinatePrecision));
966
966
  }
967
967
  }
968
- class me extends N {
968
+ class Ce extends N {
969
969
  constructor(t) {
970
970
  super(t), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
971
971
  const e = { start: "crosshair" };
972
- if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
972
+ if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
973
973
  else {
974
974
  const i = { cancel: "Escape", finish: "Enter" };
975
- this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
975
+ this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
976
976
  }
977
977
  }
978
978
  updateRectangle(t, e) {
@@ -997,10 +997,10 @@ class me extends N {
997
997
  this.center = [t.lng, t.lat];
998
998
  const [e] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode } }]);
999
999
  this.currentRectangleId = e, this.clickCount++, this.setDrawing();
1000
- } else this.updateRectangle(t, w.Finish), this.close();
1000
+ } else this.updateRectangle(t, M.Finish), this.close();
1001
1001
  }
1002
1002
  onMouseMove(t) {
1003
- this.updateRectangle(t, w.Provisional);
1003
+ this.updateRectangle(t, M.Provisional);
1004
1004
  }
1005
1005
  onKeyDown() {
1006
1006
  }
@@ -1018,7 +1018,7 @@ class me extends N {
1018
1018
  this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.store.delete([t]);
1019
1019
  }
1020
1020
  styleFeature(t) {
1021
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1021
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1022
1022
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
1023
1023
  }
1024
1024
  validateFeature(t) {
@@ -1060,50 +1060,50 @@ class et extends N {
1060
1060
  validateFeature(t) {
1061
1061
  const e = super.validateFeature(t);
1062
1062
  if (e.valid) {
1063
- const i = t, o = ye(i, this.coordinatePrecision).valid || vt(i, this.coordinatePrecision).valid || pe(i, this.coordinatePrecision).valid;
1063
+ const i = t, o = fe(i, this.coordinatePrecision).valid || Ct(i, this.coordinatePrecision).valid || ge(i, this.coordinatePrecision).valid;
1064
1064
  return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
1065
1065
  }
1066
1066
  return e;
1067
1067
  }
1068
1068
  }
1069
- function pt(r, t) {
1070
- const e = r, i = t, o = F(e[1]), s = F(i[1]);
1071
- let n = F(i[0] - e[0]);
1069
+ function gt(r, t) {
1070
+ const e = r, i = t, o = E(e[1]), s = E(i[1]);
1071
+ let n = E(i[0] - e[0]);
1072
1072
  n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
1073
1073
  const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (U(Math.atan2(n, a)) + 360) % 360;
1074
1074
  return l > 180 ? -(360 - l) : l;
1075
1075
  }
1076
- function _t(r, t, e) {
1076
+ function Lt(r, t, e) {
1077
1077
  let i = t;
1078
1078
  t < 0 && (i = -Math.abs(i));
1079
- const o = i / ae, s = r[0] * Math.PI / 180, n = F(r[1]), a = F(e), l = o * Math.cos(a);
1079
+ const o = i / le, s = r[0] * Math.PI / 180, n = E(r[1]), a = E(e), l = o * Math.cos(a);
1080
1080
  let d = n + l;
1081
1081
  Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
1082
1082
  const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (s + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1083
1083
  return u[0] += u[0] - r[0] > 180 ? -360 : r[0] - u[0] > 180 ? 360 : 0, u;
1084
1084
  }
1085
- function ve(r, t, e, i, o) {
1085
+ function Pe(r, t, e, i, o) {
1086
1086
  const s = i(r[0], r[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((s.x + n.x) / 2, (s.y + n.y) / 2);
1087
- return [E(a, e), E(l, e)];
1087
+ return [F(a, e), F(l, e)];
1088
1088
  }
1089
- function qe(r, t, e) {
1090
- const i = _t(r, 1e3 * G(r, t) / 2, pt(r, t));
1091
- return [E(i[0], e), E(i[1], e)];
1089
+ function Ze(r, t, e) {
1090
+ const i = Lt(r, 1e3 * G(r, t) / 2, gt(r, t));
1091
+ return [F(i[0], e), F(i[1], e)];
1092
1092
  }
1093
1093
  function $t({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
1094
1094
  const s = [];
1095
1095
  for (let n = 0; n < r.length - 1; n++) {
1096
1096
  let a;
1097
- if (o === "web-mercator") a = ve(r[n], r[n + 1], t, i, e);
1097
+ if (o === "web-mercator") a = Pe(r[n], r[n + 1], t, i, e);
1098
1098
  else {
1099
1099
  if (o !== "globe") throw new Error("Invalid projection");
1100
- a = qe(r[n], r[n + 1], t);
1100
+ a = Ze(r[n], r[n + 1], t);
1101
1101
  }
1102
1102
  s.push(a);
1103
1103
  }
1104
1104
  return s;
1105
1105
  }
1106
- class Je extends B {
1106
+ class Qe extends B {
1107
1107
  constructor(t, e) {
1108
1108
  super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
1109
1109
  }
@@ -1129,7 +1129,7 @@ class Je extends B {
1129
1129
  if (this._midPoints.length !== 0) return $t({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
1130
1130
  }
1131
1131
  }
1132
- class Ze extends B {
1132
+ class ti extends B {
1133
1133
  constructor(t) {
1134
1134
  super(t), this._selectionPoints = [];
1135
1135
  }
@@ -1155,7 +1155,7 @@ class Ze extends B {
1155
1155
  if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
1156
1156
  }
1157
1157
  }
1158
- function Ce(r, t) {
1158
+ function Se(r, t) {
1159
1159
  let e = !1;
1160
1160
  for (let n = 0, a = t.length; n < a; n++) {
1161
1161
  const l = t[n];
@@ -1164,7 +1164,7 @@ function Ce(r, t) {
1164
1164
  var i, o, s;
1165
1165
  return e;
1166
1166
  }
1167
- const Pe = (r, t, e) => {
1167
+ const xe = (r, t, e) => {
1168
1168
  const i = (s) => s * s, o = (s, n) => i(s.x - n.x) + i(s.y - n.y);
1169
1169
  return Math.sqrt(((s, n, a) => {
1170
1170
  const l = o(n, a);
@@ -1173,7 +1173,7 @@ const Pe = (r, t, e) => {
1173
1173
  return d = Math.max(0, Math.min(1, d)), o(s, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
1174
1174
  })(r, t, e));
1175
1175
  };
1176
- class Qe extends B {
1176
+ class ei extends B {
1177
1177
  constructor(t, e, i) {
1178
1178
  super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
1179
1179
  }
@@ -1189,18 +1189,18 @@ class Qe extends B {
1189
1189
  } else if (g.type === "LineString") {
1190
1190
  if (i) continue;
1191
1191
  for (let y = 0; y < g.coordinates.length - 1; y++) {
1192
- const v = g.coordinates[y], f = g.coordinates[y + 1], m = Pe({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
1192
+ const v = g.coordinates[y], f = g.coordinates[y + 1], m = xe({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
1193
1193
  m < this.pointerDistance && m < l && (l = m, o = p);
1194
1194
  }
1195
1195
  } else if (g.type === "Polygon") {
1196
1196
  if (i || o) continue;
1197
- Ce([t.lng, t.lat], g.coordinates) && (n = p);
1197
+ Se([t.lng, t.lat], g.coordinates) && (n = p);
1198
1198
  }
1199
1199
  }
1200
1200
  return { clickedFeature: i || o || n, clickedMidPoint: s };
1201
1201
  }
1202
1202
  }
1203
- class ti extends B {
1203
+ class ii extends B {
1204
1204
  constructor(t, e, i, o) {
1205
1205
  super(t), 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 = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o;
1206
1206
  }
@@ -1233,17 +1233,17 @@ class ti extends B {
1233
1233
  const p = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
1234
1234
  h = c[0] - p[0], u = c[1] - p[1];
1235
1235
  }
1236
- if (h = E(h, this.config.coordinatePrecision), u = E(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
1236
+ if (h = F(h, this.config.coordinatePrecision), u = F(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
1237
1237
  s[d] = [h, u];
1238
1238
  }
1239
1239
  i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
1240
1240
  const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [];
1241
- if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional }).valid) return !1;
1241
+ if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional }).valid) return !1;
1242
1242
  this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [t.lng, t.lat];
1243
1243
  } else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
1244
1244
  }
1245
1245
  }
1246
- class ei extends B {
1246
+ class oi extends B {
1247
1247
  constructor(t, e, i, o) {
1248
1248
  super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
1249
1249
  }
@@ -1278,7 +1278,7 @@ class ei extends B {
1278
1278
  n[0] = a, n[h] = a;
1279
1279
  }
1280
1280
  const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(n) || [];
1281
- return !(s.type !== "Point" && !e && Ot({ geometry: s }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...c]), 0));
1281
+ return !(s.type !== "Point" && !e && Dt({ geometry: s }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...c]), 0));
1282
1282
  }
1283
1283
  isDragging() {
1284
1284
  return this.draggedCoordinate.id !== null;
@@ -1290,21 +1290,21 @@ class ei extends B {
1290
1290
  this.draggedCoordinate = { id: null, index: -1 };
1291
1291
  }
1292
1292
  }
1293
- function gt(r) {
1293
+ function yt(r) {
1294
1294
  let t = 0, e = 0, i = 0;
1295
1295
  return (r.geometry.type === "Polygon" ? r.geometry.coordinates[0].slice(0, -1) : r.geometry.coordinates).forEach((o) => {
1296
1296
  t += o[0], e += o[1], i++;
1297
1297
  }, !0), [t / i, e / i];
1298
1298
  }
1299
- function Se(r, t) {
1299
+ function Ie(r, t) {
1300
1300
  r[0] += r[0] - t[0] > 180 ? -360 : t[0] - r[0] > 180 ? 360 : 0;
1301
- const e = ae, i = t[1] * Math.PI / 180, o = r[1] * Math.PI / 180, s = o - i;
1301
+ const e = le, i = t[1] * Math.PI / 180, o = r[1] * Math.PI / 180, s = o - i;
1302
1302
  let n = Math.abs(r[0] - t[0]) * Math.PI / 180;
1303
1303
  n > Math.PI && (n -= 2 * Math.PI);
1304
1304
  const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? s / a : Math.cos(i);
1305
1305
  return Math.sqrt(s * s + l * l * n * n) * e;
1306
1306
  }
1307
- function yt(r) {
1307
+ function ft(r) {
1308
1308
  const t = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map((e) => {
1309
1309
  const { x: i, y: o } = x(e[0], e[1]);
1310
1310
  return [i, o];
@@ -1327,7 +1327,7 @@ function yt(r) {
1327
1327
  return { x: o / i, y: s / i };
1328
1328
  }(t);
1329
1329
  }
1330
- class ii extends B {
1330
+ class si extends B {
1331
1331
  constructor(t, e, i) {
1332
1332
  super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
1333
1333
  }
@@ -1341,7 +1341,7 @@ class ii extends B {
1341
1341
  let n;
1342
1342
  const a = { type: "Feature", geometry: o, properties: {} };
1343
1343
  if (this.config.projection === "web-mercator") {
1344
- if (n = T(yt(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
1344
+ if (n = T(ft(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
1345
1345
  ((h, u) => {
1346
1346
  if (u === 0 || u === 360 || u === -360) return h;
1347
1347
  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 });
@@ -1351,26 +1351,26 @@ class ii extends B {
1351
1351
  })(a, -(this.lastBearing - n));
1352
1352
  } else {
1353
1353
  if (this.config.projection !== "globe") throw new Error("Unsupported projection");
1354
- if (n = pt(gt({ geometry: o }), s), !this.lastBearing) return void (this.lastBearing = n + 180);
1354
+ if (n = gt(yt({ geometry: o }), s), !this.lastBearing) return void (this.lastBearing = n + 180);
1355
1355
  (function(h, u) {
1356
1356
  if (u === 0 || u === 360 || u === -360) return h;
1357
- const p = gt(h);
1357
+ const p = yt(h);
1358
1358
  (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((g) => {
1359
- const y = pt(p, g) + u, v = Se(p, g), f = _t(p, v, y);
1359
+ const y = gt(p, g) + u, v = Ie(p, g), f = Lt(p, v, y);
1360
1360
  g[0] = f[0], g[1] = f[1];
1361
1361
  });
1362
1362
  })(a, -(this.lastBearing - (n + 180)));
1363
1363
  }
1364
1364
  const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1365
1365
  l.forEach((h) => {
1366
- h[0] = E(h[0], this.coordinatePrecision), h[1] = E(h[1], this.coordinatePrecision);
1366
+ h[0] = F(h[0], this.coordinatePrecision), h[1] = F(h[1], this.coordinatePrecision);
1367
1367
  });
1368
1368
  const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [];
1369
- if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional })) return !1;
1369
+ if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional })) return !1;
1370
1370
  this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
1371
1371
  }
1372
1372
  }
1373
- class oi extends B {
1373
+ class ri extends B {
1374
1374
  constructor(t, e, i) {
1375
1375
  super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
1376
1376
  }
@@ -1382,13 +1382,13 @@ class oi extends B {
1382
1382
  if (o.type !== "Polygon" && o.type !== "LineString") return;
1383
1383
  const s = [t.lng, t.lat], n = { type: "Feature", geometry: o, properties: {} };
1384
1384
  let a;
1385
- const l = yt(n);
1385
+ const l = ft(n);
1386
1386
  if (this.config.projection === "web-mercator") {
1387
1387
  const p = x(t.lng, t.lat);
1388
- a = D(l, p);
1388
+ a = O(l, p);
1389
1389
  } else {
1390
1390
  if (this.config.projection !== "globe") throw new Error("Invalid projection");
1391
- a = G(gt({ geometry: o }), s);
1391
+ a = G(yt({ geometry: o }), s);
1392
1392
  }
1393
1393
  if (!this.lastDistance) return void (this.lastDistance = a);
1394
1394
  const d = 1 - (this.lastDistance - a) / a;
@@ -1396,25 +1396,25 @@ class oi extends B {
1396
1396
  const { lng: p, lat: g } = W(l.x, l.y);
1397
1397
  (function(y, v, f) {
1398
1398
  if (v === 1) return y;
1399
- const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, I]) => x(S, I)), C = x(f[0], f[1]), P = m.map((S) => ({ x: C.x + (S.x - C.x) * v, y: C.y + (S.y - C.y) * v })).map(({ x: S, y: I }) => [W(S, I).lng, W(S, I).lat]);
1399
+ const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, b]) => x(S, b)), C = x(f[0], f[1]), P = m.map((S) => ({ x: C.x + (S.x - C.x) * v, y: C.y + (S.y - C.y) * v })).map(({ x: S, y: b }) => [W(S, b).lng, W(S, b).lat]);
1400
1400
  y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = P : y.geometry.coordinates = P;
1401
1401
  })(n, d, [p, g]);
1402
1402
  } else this.config.projection === "globe" && function(p, g, y, v = "xy") {
1403
1403
  g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
1404
- const m = Se(y, f), C = pt(y, f), P = _t(y, m * g, C);
1404
+ const m = Ie(y, f), C = gt(y, f), P = Lt(y, m * g, C);
1405
1405
  v !== "x" && v !== "xy" || (f[0] = P[0]), v !== "y" && v !== "xy" || (f[1] = P[1]);
1406
1406
  });
1407
- }(n, d, gt(n));
1407
+ }(n, d, yt(n));
1408
1408
  const c = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1409
1409
  c.forEach((p) => {
1410
- p[0] = E(p[0], this.coordinatePrecision), p[1] = E(p[1], this.coordinatePrecision);
1410
+ p[0] = F(p[0], this.coordinatePrecision), p[1] = F(p[1], this.coordinatePrecision);
1411
1411
  });
1412
1412
  const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
1413
- if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional })) return !1;
1413
+ if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional })) return !1;
1414
1414
  this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...h]), this.lastDistance = a;
1415
1415
  }
1416
1416
  }
1417
- class si extends B {
1417
+ class ni extends B {
1418
1418
  constructor(t, e, i, o) {
1419
1419
  super(t), 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 = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
1420
1420
  }
@@ -1473,7 +1473,7 @@ class si extends B {
1473
1473
  centerWebMercatorDrag(t) {
1474
1474
  const e = this.getSelectedFeatureDataWebMercator();
1475
1475
  if (!e) return null;
1476
- const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = yt(i);
1476
+ const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = ft(i);
1477
1477
  if (!a) return null;
1478
1478
  const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
1479
1479
  return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
@@ -1481,14 +1481,14 @@ class si extends B {
1481
1481
  centerFixedWebMercatorDrag(t) {
1482
1482
  const e = this.getSelectedFeatureDataWebMercator();
1483
1483
  if (!e) return null;
1484
- const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = yt(i);
1484
+ const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = ft(i);
1485
1485
  if (!a) return null;
1486
1486
  const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
1487
1487
  return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1488
1488
  }
1489
1489
  scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
1490
1490
  if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
1491
- let n = D(e, o) / D(e, i);
1491
+ let n = O(e, o) / O(e, i);
1492
1492
  return n < 0 && (n = this.minimumScale), this.performWebMercatorScale(s, e.x, e.y, n, n), s;
1493
1493
  }
1494
1494
  oppositeFixedWebMercatorDrag(t) {
@@ -1543,7 +1543,7 @@ class si extends B {
1543
1543
  getIndexesWebMercator(t, e) {
1544
1544
  let i, o = 1 / 0;
1545
1545
  for (let s = 0; s < t.length; s++) {
1546
- const n = D({ x: e.x, y: e.y }, { x: t[s][0], y: t[s][1] });
1546
+ const n = O({ x: e.x, y: e.y }, { x: t[s][0], y: t[s][1] });
1547
1547
  n < o && (i = s, o = n);
1548
1548
  }
1549
1549
  if (i === void 0) throw new Error("No closest coordinate found");
@@ -1570,21 +1570,21 @@ class si extends B {
1570
1570
  if (e === "center" ? s = this.centerWebMercatorDrag(t) : e === "opposite" ? s = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? s = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (s = this.oppositeFixedWebMercatorDrag(t)), !s) return !1;
1571
1571
  for (let d = 0; d < s.length; d++) {
1572
1572
  const c = s[d];
1573
- if (c[0] = E(c[0], this.coordinatePrecision), c[1] = E(c[1], this.coordinatePrecision), !mt(c, this.coordinatePrecision)) return !1;
1573
+ if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !vt(c, this.coordinatePrecision)) return !1;
1574
1574
  }
1575
1575
  const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
1576
- 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: w.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
1576
+ 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: M.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
1577
1577
  }
1578
1578
  }
1579
- class ri extends Be {
1579
+ class be extends Ae {
1580
1580
  constructor(t) {
1581
1581
  var e;
1582
1582
  super(t), 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 = t && t.flags ? t.flags : {};
1583
1583
  const i = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
1584
- if (this.cursors = t && t.cursors ? M({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null };
1584
+ if (this.cursors = t && t.cursors ? I({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null };
1585
1585
  else {
1586
1586
  const o = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] };
1587
- this.keyEvents = t && t.keyEvents ? M({}, o, t.keyEvents) : o;
1587
+ this.keyEvents = t && t.keyEvents ? I({}, o, t.keyEvents) : o;
1588
1588
  }
1589
1589
  if (this.dragEventThrottle = t && t.dragEventThrottle !== void 0 && t.dragEventThrottle || 5, this.allowManualDeselection = (e = t == null ? void 0 : t.allowManualDeselection) == null || e, t && t.flags && t.flags) for (const o in t.flags) {
1590
1590
  const s = t.flags[o].feature;
@@ -1599,7 +1599,7 @@ class ri extends Be {
1599
1599
  this._state = "selecting";
1600
1600
  }
1601
1601
  registerBehaviors(t) {
1602
- this.pixelDistance = new Pt(t), this.clickBoundingBox = new Ct(t), this.featuresAtMouseEvent = new Qe(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Ze(t), this.midPoints = new Je(t, this.selectionPoints), this.rotateFeature = new ii(t, this.selectionPoints, this.midPoints), this.scaleFeature = new oi(t, this.selectionPoints, this.midPoints), this.dragFeature = new ti(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new ei(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new si(t, this.pixelDistance, this.selectionPoints, this.midPoints);
1602
+ this.pixelDistance = new St(t), this.clickBoundingBox = new Pt(t), this.featuresAtMouseEvent = new ei(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new ti(t), this.midPoints = new Qe(t, this.selectionPoints), this.rotateFeature = new si(t, this.selectionPoints, this.midPoints), this.scaleFeature = new ri(t, this.selectionPoints, this.midPoints), this.dragFeature = new ii(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new oi(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new ni(t, this.pixelDistance, this.selectionPoints, this.midPoints);
1603
1603
  }
1604
1604
  deselectFeature() {
1605
1605
  this.deselect();
@@ -1625,7 +1625,7 @@ class ri extends Be {
1625
1625
  if (d.type === "Polygon") {
1626
1626
  if (c = d.coordinates[0], c.length <= 4) return;
1627
1627
  } else if (d.type === "LineString" && (c = d.coordinates, c.length <= 2)) return;
1628
- c && (d.type !== "Polygon" || s !== 0 && s !== c.length - 1 ? c.splice(s, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision)));
1628
+ c && (d.type !== "Polygon" || s !== 0 && s !== c.length - 1 ? c.splice(s, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision)));
1629
1629
  }
1630
1630
  select(t, e = !0) {
1631
1631
  if (this.selected[0] === t) return;
@@ -1722,7 +1722,7 @@ class ri extends Be {
1722
1722
  this.setCursor(this.selected.length > 0 && (o && o.id === this.selected[0] || i) ? this.cursors.pointerOver : "unset");
1723
1723
  }
1724
1724
  styleFeature(t) {
1725
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1725
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1726
1726
  if (t.properties.mode === this.mode && t.geometry.type === "Point") {
1727
1727
  if (t.properties.selectionPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, e.pointWidth, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, t), e.zIndex = 30, e;
1728
1728
  if (t.properties.midPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, t), e.zIndex = 40, e;
@@ -1734,7 +1734,7 @@ class ri extends Be {
1734
1734
  return e;
1735
1735
  }
1736
1736
  }
1737
- class ni extends N {
1737
+ class ai extends N {
1738
1738
  constructor(...t) {
1739
1739
  super(...t), this.type = Y.Static, this.mode = "static";
1740
1740
  }
@@ -1759,14 +1759,14 @@ class ni extends N {
1759
1759
  cleanUp() {
1760
1760
  }
1761
1761
  styleFeature() {
1762
- 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 });
1762
+ return I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1763
1763
  }
1764
1764
  }
1765
- function xe(r, t, e, i, o) {
1765
+ function Me(r, t, e, i, o) {
1766
1766
  for (; i > e; ) {
1767
1767
  if (i - e > 600) {
1768
1768
  const l = i - e + 1, d = t - e + 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);
1769
- xe(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
1769
+ Me(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
1770
1770
  }
1771
1771
  const s = r[t];
1772
1772
  let n = e, a = i;
@@ -1795,19 +1795,19 @@ function it(r, t, e, i, o) {
1795
1795
  function ot(r, t) {
1796
1796
  return r.minX = Math.min(r.minX, t.minX), r.minY = Math.min(r.minY, t.minY), r.maxX = Math.max(r.maxX, t.maxX), r.maxY = Math.max(r.maxY, t.maxY), r;
1797
1797
  }
1798
- function ai(r, t) {
1798
+ function li(r, t) {
1799
1799
  return r.minX - t.minX;
1800
1800
  }
1801
- function li(r, t) {
1801
+ function di(r, t) {
1802
1802
  return r.minY - t.minY;
1803
1803
  }
1804
- function It(r) {
1804
+ function Mt(r) {
1805
1805
  return (r.maxX - r.minX) * (r.maxY - r.minY);
1806
1806
  }
1807
1807
  function dt(r) {
1808
1808
  return r.maxX - r.minX + (r.maxY - r.minY);
1809
1809
  }
1810
- function di(r, t) {
1810
+ function ci(r, t) {
1811
1811
  const e = Math.max(r.minX, t.minX), i = Math.max(r.minY, t.minY), o = Math.min(r.maxX, t.maxX), s = Math.min(r.maxY, t.maxY);
1812
1812
  return Math.max(0, o - e) * Math.max(0, s - i);
1813
1813
  }
@@ -1825,10 +1825,10 @@ function Ht(r, t, e, i, o) {
1825
1825
  for (; s.length; ) {
1826
1826
  if ((e = s.pop()) - (t = s.pop()) <= i) continue;
1827
1827
  const n = t + Math.ceil((e - t) / i / 2) * i;
1828
- xe(r, n, t, e, o), s.push(t, n, n, e);
1828
+ Me(r, n, t, e, o), s.push(t, n, n, e);
1829
1829
  }
1830
1830
  }
1831
- class ci {
1831
+ class hi {
1832
1832
  constructor(t) {
1833
1833
  this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
1834
1834
  }
@@ -1932,7 +1932,7 @@ class ci {
1932
1932
  for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
1933
1933
  let a, l = 1 / 0, d = 1 / 0;
1934
1934
  for (let c = 0; c < e.children.length; c++) {
1935
- const h = e.children[c], u = It(h), p = (s = t, n = h, (Math.max(n.maxX, s.maxX) - Math.min(n.minX, s.minX)) * (Math.max(n.maxY, s.maxY) - Math.min(n.minY, s.minY)) - u);
1935
+ const h = e.children[c], u = Mt(h), p = (s = t, n = h, (Math.max(n.maxX, s.maxX) - Math.min(n.minX, s.minX)) * (Math.max(n.maxY, s.maxY) - Math.min(n.minY, s.minY)) - u);
1936
1936
  p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
1937
1937
  }
1938
1938
  e = a || e.children[0];
@@ -1957,13 +1957,13 @@ class ci {
1957
1957
  _chooseSplitIndex(t, e, i) {
1958
1958
  let o, s = 1 / 0, n = 1 / 0;
1959
1959
  for (let a = e; a <= i - e; a++) {
1960
- const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), c = di(l, d), h = It(l) + It(d);
1960
+ const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), c = ci(l, d), h = Mt(l) + Mt(d);
1961
1961
  c < s ? (s = c, o = a, n = h < n ? h : n) : c === s && h < n && (n = h, o = a);
1962
1962
  }
1963
1963
  return o || i - e;
1964
1964
  }
1965
1965
  _chooseSplitAxis(t, e, i) {
1966
- const o = t.leaf ? this.compareMinX : ai, s = t.leaf ? this.compareMinY : li;
1966
+ const o = t.leaf ? this.compareMinX : li, s = t.leaf ? this.compareMinY : di;
1967
1967
  this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, s) && t.children.sort(o);
1968
1968
  }
1969
1969
  _allDistMargin(t, e, i, o) {
@@ -1987,9 +1987,9 @@ class ci {
1987
1987
  for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() : $(t[i], this.toBBox);
1988
1988
  }
1989
1989
  }
1990
- class hi {
1990
+ class ui {
1991
1991
  constructor(t) {
1992
- this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new ci(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
1992
+ this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new hi(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
1993
1993
  }
1994
1994
  setMaps(t, e) {
1995
1995
  this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
@@ -2040,14 +2040,14 @@ class hi {
2040
2040
  return this.tree.collides(this.toBBox(t));
2041
2041
  }
2042
2042
  }
2043
- const ui = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
2043
+ const pi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
2044
2044
  const t = 16 * Math.random() | 0;
2045
2045
  return (r == "x" ? t : 3 & t | 8).toString(16);
2046
2046
  }), isValidId: (r) => typeof r == "string" && r.length === 36 };
2047
- class pi {
2047
+ class gi {
2048
2048
  constructor(t) {
2049
2049
  this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
2050
- }, this.store = {}, this.spatialIndex = new hi(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : ui;
2050
+ }, this.store = {}, this.spatialIndex = new ui(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : pi;
2051
2051
  }
2052
2052
  clone(t) {
2053
2053
  return JSON.parse(JSON.stringify(t));
@@ -2119,7 +2119,7 @@ class pi {
2119
2119
  create(t) {
2120
2120
  const e = [];
2121
2121
  return t.forEach(({ geometry: i, properties: o }) => {
2122
- let s, n = M({}, o);
2122
+ let s, n = I({}, o);
2123
2123
  this.tracked && (s = +/* @__PURE__ */ new Date(), o ? (n.createdAt = typeof o.createdAt == "number" ? o.createdAt : s, n.updatedAt = typeof o.updatedAt == "number" ? o.updatedAt : s) : n = { createdAt: s, updatedAt: s });
2124
2124
  const a = this.getId(), l = { id: a, type: "Feature", geometry: i, properties: n };
2125
2125
  this.store[a] = l, this.spatialIndex.insert(l), e.push(a);
@@ -2141,20 +2141,20 @@ class pi {
2141
2141
  return Object.keys(this.store).length;
2142
2142
  }
2143
2143
  }
2144
- const gi = "Feature is not a Polygon or LineString", yi = "Feature intersects itself", fi = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: gi } : Ot(r) ? { valid: !1, reason: yi } : { valid: !0 };
2144
+ const yi = "Feature is not a Polygon or LineString", fi = "Feature intersects itself", mi = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: yi } : Dt(r) ? { valid: !1, reason: fi } : { valid: !0 };
2145
2145
  function qt(r, t, e) {
2146
2146
  const i = T(r, t);
2147
2147
  let o = T(t, e) - i;
2148
2148
  return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
2149
2149
  }
2150
- class Me extends N {
2150
+ class we extends N {
2151
2151
  constructor(t) {
2152
2152
  super(t), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
2153
2153
  const e = { start: "crosshair", close: "pointer" };
2154
- if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2154
+ if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2155
2155
  else {
2156
2156
  const i = { cancel: "Escape", finish: "Enter" };
2157
- this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
2157
+ this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
2158
2158
  }
2159
2159
  }
2160
2160
  close() {
@@ -2176,13 +2176,13 @@ class Me extends N {
2176
2176
  const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
2177
2177
  i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
2178
2178
  } else if (this.currentCoordinate === 2) {
2179
- const o = e[0], s = e[1], n = ve(o, s, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(s[0], s[1]), c = x(t.lng, t.lat), h = D(c, a) < D(c, d), u = qt(a, l, c), p = h ? 90 - u : qt(a, l, c) - 90, g = D(l, c), y = Math.cos(F(p)) * g, v = T(a, d) + (function(S, I, b) {
2180
- const O = (b.x - I.x) * (S.y - I.y) - (b.y - I.y) * (S.x - I.x);
2181
- return O > 1e-10 ? "left" : O < -1e-10 ? "right" : "left";
2179
+ const o = e[0], s = e[1], n = Pe(o, s, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(s[0], s[1]), c = x(t.lng, t.lat), h = O(c, a) < O(c, d), u = qt(a, l, c), p = h ? 90 - u : qt(a, l, c) - 90, g = O(l, c), y = Math.cos(E(p)) * g, v = T(a, d) + (function(S, b, w) {
2180
+ const D = (w.x - b.x) * (S.y - b.y) - (w.y - b.y) * (S.x - b.x);
2181
+ return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
2182
2182
  }(a, d, c) === "right" ? -90 : 90), f = rt(a, y, v), m = rt(d, y, v), C = W(f.x, f.y), P = W(m.x, m.y);
2183
2183
  i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
2184
2184
  }
2185
- i && this.updatePolygonGeometry(this.currentId, i, w.Provisional);
2185
+ i && this.updatePolygonGeometry(this.currentId, i, M.Provisional);
2186
2186
  }
2187
2187
  updatePolygonGeometry(t, e, i) {
2188
2188
  const o = { type: "Polygon", coordinates: [e] };
@@ -2194,7 +2194,7 @@ class Me extends N {
2194
2194
  this.currentId = e, this.currentCoordinate++, this.setDrawing();
2195
2195
  } else if (this.currentCoordinate === 1 && this.currentId) {
2196
2196
  const e = this.store.getGeometryCopy(this.currentId);
2197
- if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], w.Commit)) return;
2197
+ if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], M.Commit)) return;
2198
2198
  this.currentCoordinate++;
2199
2199
  } else this.currentCoordinate === 2 && this.currentId && this.close();
2200
2200
  }
@@ -2217,24 +2217,24 @@ class Me extends N {
2217
2217
  this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
2218
2218
  }
2219
2219
  styleFeature(t) {
2220
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2220
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2221
2221
  return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
2222
2222
  }
2223
2223
  validateFeature(t) {
2224
2224
  return this.validateModeFeature(t, (e) => nt(e, this.coordinatePrecision));
2225
2225
  }
2226
2226
  }
2227
- function Ie(r, t, e) {
2227
+ function Fe(r, t, e) {
2228
2228
  return (t.x - r.x) * (e.y - r.y) - (t.y - r.y) * (e.x - r.x) <= 0;
2229
2229
  }
2230
- class we extends N {
2230
+ class Ee extends N {
2231
2231
  constructor(t) {
2232
2232
  super(t), 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;
2233
2233
  const e = { start: "crosshair", close: "pointer" };
2234
- if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2234
+ if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2235
2235
  else {
2236
2236
  const i = { cancel: "Escape", finish: "Enter" };
2237
- this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
2237
+ this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
2238
2238
  }
2239
2239
  this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
2240
2240
  }
@@ -2259,21 +2259,21 @@ class we extends N {
2259
2259
  } else if (this.currentCoordinate === 2) {
2260
2260
  const o = e[0], s = e[1], n = [t.lng, t.lat], a = x(o[0], o[1]), l = x(s[0], s[1]), d = x(n[0], n[1]);
2261
2261
  if (this.direction === void 0) {
2262
- const C = Ie(a, l, d);
2262
+ const C = Fe(a, l, d);
2263
2263
  this.direction = C ? "clockwise" : "anticlockwise";
2264
2264
  }
2265
- const c = D(a, l), h = T(a, l), u = T(a, d), p = this.arcPoints, g = [o], y = K(h), v = K(u);
2265
+ const c = O(a, l), h = T(a, l), u = T(a, d), p = this.arcPoints, g = [o], y = K(h), v = K(u);
2266
2266
  let f;
2267
2267
  this.direction === "anticlockwise" ? (f = v - y, f < 0 && (f += 360)) : (f = y - v, f < 0 && (f += 360));
2268
2268
  const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
2269
2269
  g.push(s);
2270
2270
  for (let C = 0; C <= p; C++) {
2271
- const P = rt(a, c, y + C * m), { lng: S, lat: I } = W(P.x, P.y), b = [E(S, this.coordinatePrecision), E(I, this.coordinatePrecision)];
2272
- b[0] !== g[g.length - 1][0] && b[1] !== g[g.length - 1][1] && g.push(b);
2271
+ const P = rt(a, c, y + C * m), { lng: S, lat: b } = W(P.x, P.y), w = [F(S, this.coordinatePrecision), F(b, this.coordinatePrecision)];
2272
+ w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
2273
2273
  }
2274
2274
  g.push(o), i = [...g];
2275
2275
  }
2276
- i && this.updatePolygonGeometry(this.currentId, i, w.Provisional);
2276
+ i && this.updatePolygonGeometry(this.currentId, i, M.Provisional);
2277
2277
  }
2278
2278
  updatePolygonGeometry(t, e, i) {
2279
2279
  const o = { type: "Polygon", coordinates: [e] };
@@ -2285,7 +2285,7 @@ class we extends N {
2285
2285
  this.currentId = e, this.currentCoordinate++, this.setDrawing();
2286
2286
  } else if (this.currentCoordinate === 1 && this.currentId) {
2287
2287
  const e = this.store.getGeometryCopy(this.currentId);
2288
- if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], w.Commit)) return;
2288
+ if (Z([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], M.Commit)) return;
2289
2289
  this.currentCoordinate++;
2290
2290
  } else this.currentCoordinate === 2 && this.currentId && this.close();
2291
2291
  }
@@ -2308,21 +2308,21 @@ class we extends N {
2308
2308
  this.currentId = void 0, this.direction = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
2309
2309
  }
2310
2310
  styleFeature(t) {
2311
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2311
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2312
2312
  return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
2313
2313
  }
2314
2314
  validateFeature(t) {
2315
2315
  return this.validateModeFeature(t, (e) => nt(e, this.coordinatePrecision));
2316
2316
  }
2317
2317
  }
2318
- class be extends N {
2318
+ class Oe extends N {
2319
2319
  constructor(t) {
2320
2320
  super(t), 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;
2321
2321
  const e = { start: "crosshair", close: "pointer" };
2322
- if (this.cursors = t && t.cursors ? M({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2322
+ if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2323
2323
  else {
2324
2324
  const i = { cancel: "Escape", finish: "Enter" };
2325
- this.keyEvents = t && t.keyEvents ? M({}, i, t.keyEvents) : i;
2325
+ this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
2326
2326
  }
2327
2327
  this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
2328
2328
  }
@@ -2340,9 +2340,9 @@ class be extends N {
2340
2340
  onMouseMove(t) {
2341
2341
  if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
2342
2342
  if (this.currentCoordinate === 2) {
2343
- const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n = x(o[0], o[1]), a = x(s[0], s[1]), l = x(i[0], i[1]), d = D(l, n);
2343
+ const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n = x(o[0], o[1]), a = x(s[0], s[1]), l = x(i[0], i[1]), d = O(l, n);
2344
2344
  if (this.direction === void 0) {
2345
- const m = Ie(l, n, a);
2345
+ const m = Fe(l, n, a);
2346
2346
  this.direction = m ? "clockwise" : "anticlockwise";
2347
2347
  }
2348
2348
  const c = T(l, n), h = T(l, a), u = this.arcPoints, p = [o], g = K(c), y = K(h);
@@ -2350,21 +2350,21 @@ class be extends N {
2350
2350
  this.direction === "anticlockwise" ? (v = y - g, v < 0 && (v += 360)) : (v = g - y, v < 0 && (v += 360));
2351
2351
  const f = (this.direction === "anticlockwise" ? 1 : -1) * v / u;
2352
2352
  for (let m = 0; m <= u; m++) {
2353
- const C = rt(l, d, g + m * f), { lng: P, lat: S } = W(C.x, C.y), I = [E(P, this.coordinatePrecision), E(S, this.coordinatePrecision)];
2354
- I[0] !== p[p.length - 1][0] && I[1] !== p[p.length - 1][1] && p.push(I);
2353
+ const C = rt(l, d, g + m * f), { lng: P, lat: S } = W(C.x, C.y), b = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
2354
+ b[0] !== p[p.length - 1][0] && b[1] !== p[p.length - 1][1] && p.push(b);
2355
2355
  }
2356
- this.updateLineStringGeometry(this.currentInitialArcId, p, w.Provisional);
2356
+ this.updateLineStringGeometry(this.currentInitialArcId, p, M.Provisional);
2357
2357
  } else if (this.currentCoordinate === 3) {
2358
2358
  const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2359
2359
  if (e.length < 2 || !this.direction) return;
2360
- const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(s[0], s[1]), d = x(i[0], i[1]), c = D(d, a), h = D(d, n) < c ? a : n, u = T(d, n), p = T(d, a), g = T(d, l), y = K(p), v = K(g), f = K(u);
2360
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(s[0], s[1]), d = x(i[0], i[1]), c = O(d, a), h = O(d, n) < c ? a : n, u = T(d, n), p = T(d, a), g = T(d, l), y = K(p), v = K(g), f = K(u);
2361
2361
  if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: v, direction: this.direction })) return;
2362
- const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = D(d, h), I = [];
2363
- for (let b = 0; b <= C; b++) {
2364
- const O = rt(d, S, y + b * P), { lng: A, lat: _ } = W(O.x, O.y), j = [E(A, this.coordinatePrecision), E(_, this.coordinatePrecision)];
2365
- j[0] !== e[e.length - 1][0] && j[1] !== e[e.length - 1][1] && I.unshift(j);
2362
+ const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = O(d, h), b = [];
2363
+ for (let w = 0; w <= C; w++) {
2364
+ const D = rt(d, S, y + w * P), { lng: A, lat: L } = W(D.x, D.y), j = [F(A, this.coordinatePrecision), F(L, this.coordinatePrecision)];
2365
+ j[0] !== e[e.length - 1][0] && j[1] !== e[e.length - 1][1] && b.unshift(j);
2366
2366
  }
2367
- e.push(...I), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, w.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
2367
+ e.push(...b), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, M.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
2368
2368
  }
2369
2369
  }
2370
2370
  }
@@ -2404,7 +2404,7 @@ class be extends N {
2404
2404
  this.currentStartingPointId = void 0, this.direction = void 0, this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
2405
2405
  }
2406
2406
  styleFeature(t) {
2407
- const e = M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2407
+ const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2408
2408
  return t.properties.mode === this.mode && (t.geometry.type === "Polygon" ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10) : t.geometry.type === "LineString" ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.zIndex = 10) : t.geometry.type === "Point" && (e.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 20)), e;
2409
2409
  }
2410
2410
  validateFeature(t) {
@@ -2418,9 +2418,9 @@ class be extends N {
2418
2418
  return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
2419
2419
  }
2420
2420
  }
2421
- class mi {
2421
+ class vi {
2422
2422
  constructor(t) {
2423
- 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 = t.adapter, this._mode = new ni();
2423
+ 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 = t.adapter, this._mode = new ai();
2424
2424
  const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
2425
2425
  if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
2426
2426
  return e.add(h.mode), c[h.mode] = h, c;
@@ -2431,7 +2431,7 @@ class mi {
2431
2431
  if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
2432
2432
  this._instanceSelectMode = c;
2433
2433
  }
2434
- }), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new pi({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2434
+ }), this._modes = I({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new gi({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2435
2435
  const s = (c) => {
2436
2436
  const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
2437
2437
  return { changed: h, unchanged: u };
@@ -2475,22 +2475,22 @@ class mi {
2475
2475
  }), t;
2476
2476
  }
2477
2477
  featuresAtLocation({ lng: t, lat: e }, i) {
2478
- const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = he({ unproject: n, point: l, pointerDistance: o });
2478
+ const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = ue({ unproject: n, point: l, pointerDistance: o });
2479
2479
  return this._store.search(d).filter((c) => {
2480
2480
  if (s && (c.properties[V.MID_POINT] || c.properties[V.SELECTION_POINT])) return !1;
2481
2481
  if (c.geometry.type === "Point") {
2482
2482
  const h = c.geometry.coordinates, u = a(h[0], h[1]);
2483
- return D(l, u) < o;
2483
+ return O(l, u) < o;
2484
2484
  }
2485
2485
  if (c.geometry.type === "LineString") {
2486
2486
  const h = c.geometry.coordinates;
2487
2487
  for (let u = 0; u < h.length - 1; u++) {
2488
2488
  const p = h[u], g = h[u + 1];
2489
- if (Pe(l, a(p[0], p[1]), a(g[0], g[1])) < o) return !0;
2489
+ if (xe(l, a(p[0], p[1]), a(g[0], g[1])) < o) return !0;
2490
2490
  }
2491
2491
  return !1;
2492
2492
  }
2493
- return !!Ce([t, e], c.geometry.coordinates) || void 0;
2493
+ return !!Se([t, e], c.geometry.coordinates) || void 0;
2494
2494
  });
2495
2495
  }
2496
2496
  getSelectMode() {
@@ -2591,12 +2591,12 @@ class mi {
2591
2591
  i.includes(e) && i.splice(i.indexOf(e), 1);
2592
2592
  }
2593
2593
  }
2594
- var Jt, bt, Zt;
2594
+ var Jt, Ft, Zt;
2595
2595
  function Qt(r, t = 9) {
2596
2596
  const e = Math.pow(10, t);
2597
2597
  return Math.round(r * e) / e;
2598
2598
  }
2599
- (bt = Jt || (Jt = {})).Commit = "commit", bt.Provisional = "provisional", bt.Finish = "finish", function(r) {
2599
+ (Ft = Jt || (Jt = {})).Commit = "commit", Ft.Provisional = "provisional", Ft.Finish = "finish", function(r) {
2600
2600
  r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
2601
2601
  }(Zt || (Zt = {}));
2602
2602
  class H {
@@ -2608,7 +2608,7 @@ class H {
2608
2608
  }, this.callback = e;
2609
2609
  }
2610
2610
  }
2611
- var vi = class {
2611
+ var Ci = class {
2612
2612
  constructor(r) {
2613
2613
  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 r.minPixelDragDistance == "number" ? r.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof r.minPixelDragDistanceSelecting == "number" ? r.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof r.minPixelDragDistanceDrawing == "number" ? r.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof r.coordinatePrecision == "number" ? r.coordinatePrecision : 9;
2614
2614
  }
@@ -2701,7 +2701,7 @@ var vi = class {
2701
2701
  }), this.clear();
2702
2702
  }
2703
2703
  };
2704
- class Ci extends vi {
2704
+ class Pi extends Ci {
2705
2705
  constructor(t) {
2706
2706
  super(t), 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 = t.map, this._container = this._map.getContainer();
2707
2707
  }
@@ -2799,7 +2799,7 @@ class Ci extends vi {
2799
2799
  super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
2800
2800
  }
2801
2801
  }
2802
- const eo = [
2802
+ const io = [
2803
2803
  "render",
2804
2804
  "point",
2805
2805
  "linestring",
@@ -2814,21 +2814,7 @@ const eo = [
2814
2814
  "delete-selection",
2815
2815
  "delete",
2816
2816
  "download"
2817
- ], io = [
2818
- "render",
2819
- "linestring",
2820
- "polygon",
2821
- "rectangle",
2822
- "circle",
2823
- "freehand",
2824
- "angled-rectangle",
2825
- "sensor",
2826
- "sector",
2827
- "select",
2828
- "delete-selection",
2829
- "delete",
2830
- "download"
2831
- ], Pi = {
2817
+ ], Si = {
2832
2818
  modes: [
2833
2819
  "render",
2834
2820
  "point",
@@ -2846,9 +2832,10 @@ const eo = [
2846
2832
  "download"
2847
2833
  ],
2848
2834
  open: !1
2849
- }, Dt = {
2835
+ }, ut = {
2850
2836
  modes: [
2851
2837
  "render",
2838
+ "point",
2852
2839
  "linestring",
2853
2840
  "polygon",
2854
2841
  "rectangle",
@@ -2865,7 +2852,15 @@ const eo = [
2865
2852
  open: !1,
2866
2853
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
2867
2854
  modeOptions: {
2868
- linestring: new ge({
2855
+ point: new me({
2856
+ styles: {
2857
+ pointColor: "#FFFFFF",
2858
+ pointWidth: 5,
2859
+ pointOutlineColor: "#232E3D",
2860
+ pointOutlineWidth: 1
2861
+ }
2862
+ }),
2863
+ linestring: new ye({
2869
2864
  styles: {
2870
2865
  lineStringColor: "#232E3D",
2871
2866
  lineStringWidth: 2,
@@ -2875,7 +2870,7 @@ const eo = [
2875
2870
  closingPointOutlineWidth: 1
2876
2871
  }
2877
2872
  }),
2878
- polygon: new fe({
2873
+ polygon: new ve({
2879
2874
  styles: {
2880
2875
  fillColor: "#EDEFF0",
2881
2876
  fillOpacity: 0.7,
@@ -2887,7 +2882,7 @@ const eo = [
2887
2882
  closingPointOutlineWidth: 1
2888
2883
  }
2889
2884
  }),
2890
- rectangle: new me({
2885
+ rectangle: new Ce({
2891
2886
  styles: {
2892
2887
  fillColor: "#EDEFF0",
2893
2888
  fillOpacity: 0.7,
@@ -2895,7 +2890,7 @@ const eo = [
2895
2890
  outlineWidth: 2
2896
2891
  }
2897
2892
  }),
2898
- "angled-rectangle": new Me({
2893
+ "angled-rectangle": new we({
2899
2894
  styles: {
2900
2895
  fillColor: "#EDEFF0",
2901
2896
  fillOpacity: 0.7,
@@ -2903,7 +2898,7 @@ const eo = [
2903
2898
  outlineWidth: 2
2904
2899
  }
2905
2900
  }),
2906
- circle: new de({
2901
+ circle: new ce({
2907
2902
  styles: {
2908
2903
  fillColor: "#EDEFF0",
2909
2904
  fillOpacity: 0.7,
@@ -2911,7 +2906,7 @@ const eo = [
2911
2906
  outlineWidth: 2
2912
2907
  }
2913
2908
  }),
2914
- freehand: new ce({
2909
+ freehand: new he({
2915
2910
  styles: {
2916
2911
  fillColor: "#EDEFF0",
2917
2912
  fillOpacity: 0.7,
@@ -2923,7 +2918,7 @@ const eo = [
2923
2918
  closingPointOutlineWidth: 1
2924
2919
  }
2925
2920
  }),
2926
- sensor: new be({
2921
+ sensor: new Oe({
2927
2922
  styles: {
2928
2923
  fillColor: "#EDEFF0",
2929
2924
  fillOpacity: 0.7,
@@ -2935,15 +2930,156 @@ const eo = [
2935
2930
  centerPointOutlineWidth: 1
2936
2931
  }
2937
2932
  }),
2938
- sector: new we({
2933
+ sector: new Ee({
2939
2934
  styles: {
2940
2935
  fillColor: "#EDEFF0",
2941
2936
  fillOpacity: 0.7,
2942
2937
  outlineColor: "#232E3D",
2943
2938
  outlineWidth: 2
2944
2939
  }
2940
+ }),
2941
+ select: new be({
2942
+ flags: {
2943
+ point: {
2944
+ feature: {
2945
+ draggable: !1
2946
+ }
2947
+ },
2948
+ polygon: {
2949
+ feature: {
2950
+ draggable: !0,
2951
+ rotateable: !0,
2952
+ scaleable: !0,
2953
+ coordinates: {
2954
+ midpoints: !0,
2955
+ draggable: !0,
2956
+ deletable: !0
2957
+ }
2958
+ }
2959
+ },
2960
+ linestring: {
2961
+ feature: {
2962
+ draggable: !0,
2963
+ rotateable: !0,
2964
+ scaleable: !0,
2965
+ coordinates: {
2966
+ midpoints: !0,
2967
+ draggable: !0,
2968
+ deletable: !0
2969
+ }
2970
+ }
2971
+ },
2972
+ freehand: {
2973
+ feature: {
2974
+ draggable: !0,
2975
+ coordinates: {
2976
+ midpoints: !0,
2977
+ draggable: !0,
2978
+ deletable: !0
2979
+ }
2980
+ }
2981
+ },
2982
+ circle: {
2983
+ feature: {
2984
+ draggable: !0,
2985
+ coordinates: {
2986
+ midpoints: !0,
2987
+ draggable: !0,
2988
+ deletable: !0
2989
+ }
2990
+ }
2991
+ },
2992
+ rectangle: {
2993
+ feature: {
2994
+ draggable: !0,
2995
+ rotateable: !0,
2996
+ scaleable: !0,
2997
+ coordinates: {
2998
+ midpoints: !0,
2999
+ draggable: !0,
3000
+ deletable: !0
3001
+ }
3002
+ }
3003
+ },
3004
+ "angled-rectangle": {
3005
+ feature: {
3006
+ draggable: !0,
3007
+ rotateable: !0,
3008
+ scaleable: !0,
3009
+ coordinates: {
3010
+ midpoints: !0,
3011
+ draggable: !0,
3012
+ deletable: !0
3013
+ }
3014
+ }
3015
+ },
3016
+ sensor: {
3017
+ feature: {
3018
+ draggable: !0,
3019
+ rotateable: !0,
3020
+ scaleable: !0,
3021
+ coordinates: {
3022
+ midpoints: !0,
3023
+ draggable: !0,
3024
+ deletable: !0
3025
+ }
3026
+ }
3027
+ },
3028
+ sector: {
3029
+ feature: {
3030
+ draggable: !0,
3031
+ rotateable: !0,
3032
+ scaleable: !0,
3033
+ coordinates: {
3034
+ midpoints: !0,
3035
+ draggable: !0,
3036
+ deletable: !0
3037
+ }
3038
+ }
3039
+ }
3040
+ }
2945
3041
  })
2946
3042
  },
3043
+ pointLayerLabelSpec: {
3044
+ id: "terradraw-measure-point-label",
3045
+ type: "symbol",
3046
+ source: "terradraw-measure-point-source",
3047
+ filter: ["all", ["==", "$type", "Point"], ["==", "mode", "point"]],
3048
+ layout: {
3049
+ "text-field": [
3050
+ "case",
3051
+ ["all", ["has", "elevation"], [">", ["get", "elevation"], 0]],
3052
+ ["concat", "Alt. ", ["to-string", ["floor", ["get", "elevation"]]], " m"],
3053
+ ""
3054
+ ],
3055
+ "symbol-placement": "point",
3056
+ "text-size": [
3057
+ "interpolate",
3058
+ ["linear"],
3059
+ ["zoom"],
3060
+ 5,
3061
+ 10,
3062
+ 10,
3063
+ 12,
3064
+ 13,
3065
+ 14,
3066
+ 14,
3067
+ 16,
3068
+ 18,
3069
+ 18
3070
+ ],
3071
+ "text-overlap": "always",
3072
+ "text-variable-anchor": ["left", "right", "top", "bottom"],
3073
+ "text-radial-offset": 0.5,
3074
+ "text-justify": "center",
3075
+ "text-letter-spacing": 0.05
3076
+ },
3077
+ paint: {
3078
+ "text-halo-color": "#F7F7F7",
3079
+ "text-halo-width": 2,
3080
+ "text-color": "#232E3D"
3081
+ }
3082
+ },
2947
3083
  lineLayerLabelSpec: {
2948
3084
  id: "terradraw-measure-line-label",
2949
3085
  type: "symbol",
@@ -3056,28 +3192,28 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3056
3192
  distancePrecision: 2,
3057
3193
  areaUnit: "metric",
3058
3194
  areaPrecision: 2
3059
- }, Si = () => ({
3195
+ }, xi = () => ({
3060
3196
  render: new et({
3061
3197
  modeName: "render",
3062
3198
  styles: {}
3063
3199
  }),
3064
- point: new Xe(),
3065
- linestring: new ge(),
3066
- polygon: new fe({
3200
+ point: new me(),
3201
+ linestring: new ye(),
3202
+ polygon: new ve({
3067
3203
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3068
3204
  // @ts-ignore
3069
3205
  validation: (t, e) => {
3070
3206
  const i = e.updateType;
3071
- return i === "finish" || i === "commit" ? fi(t) : { valid: !0 };
3207
+ return i === "finish" || i === "commit" ? mi(t) : { valid: !0 };
3072
3208
  }
3073
3209
  }),
3074
- rectangle: new me(),
3075
- "angled-rectangle": new Me(),
3076
- circle: new de(),
3077
- freehand: new ce(),
3078
- sensor: new be(),
3079
- sector: new we(),
3080
- select: new ri({
3210
+ rectangle: new Ce(),
3211
+ "angled-rectangle": new we(),
3212
+ circle: new ce(),
3213
+ freehand: new he(),
3214
+ sensor: new Oe(),
3215
+ sector: new Ee(),
3216
+ select: new be({
3081
3217
  flags: {
3082
3218
  point: {
3083
3219
  feature: {
@@ -3190,39 +3326,40 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3190
3326
  modeName: "download",
3191
3327
  styles: {}
3192
3328
  })
3193
- }), te = (r) => r.charAt(0).toUpperCase() + r.slice(1), St = ["td-point", "td-linestring", "td-polygon"];
3194
- var re, ne;
3329
+ }), te = (r) => r.charAt(0).toUpperCase() + r.slice(1), xt = ["td-point", "td-linestring", "td-polygon"];
3330
+ var re, ne, ae;
3195
3331
  const oo = [
3196
- ...St,
3197
- (re = Dt.polygonLayerSpec) == null ? void 0 : re.source,
3198
- (ne = Dt.lineLayerLabelSpec) == null ? void 0 : ne.source
3199
- ], Ee = (r, t, e = St) => {
3332
+ ...xt,
3333
+ (re = ut.polygonLayerSpec) == null ? void 0 : re.source,
3334
+ (ne = ut.lineLayerLabelSpec) == null ? void 0 : ne.source,
3335
+ (ae = ut.pointLayerLabelSpec) == null ? void 0 : ae.source
3336
+ ], De = (r, t, e = xt) => {
3200
3337
  const i = JSON.parse(JSON.stringify(r));
3201
3338
  return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
3202
3339
  e.includes(o) || delete i.sources[o];
3203
3340
  })) : t.excludeTerraDrawLayers === !0 && (i.layers = i.layers.filter((o) => "source" in o && !e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
3204
3341
  e.includes(o) && delete i.sources[o];
3205
3342
  }))), i;
3206
- }, xi = (r, t = 250) => {
3343
+ }, Ii = (r, t = 250) => {
3207
3344
  let e;
3208
3345
  return (...i) => {
3209
3346
  clearTimeout(e), e = setTimeout(() => r(...i), t);
3210
3347
  };
3211
3348
  };
3212
- class Mi {
3349
+ class bi {
3213
3350
  /**
3214
3351
  * Constructor
3215
3352
  * @param options Plugin control options
3216
3353
  */
3217
3354
  constructor(t) {
3218
- k(this, "controlContainer");
3219
- k(this, "map");
3220
- k(this, "modeButtons", {});
3221
- k(this, "_isExpanded", !1);
3222
- k(this, "terradraw");
3223
- k(this, "options", Pi);
3224
- k(this, "events", {});
3225
- k(this, "defaultMode", "render");
3355
+ _(this, "controlContainer");
3356
+ _(this, "map");
3357
+ _(this, "modeButtons", {});
3358
+ _(this, "_isExpanded", !1);
3359
+ _(this, "terradraw");
3360
+ _(this, "options", Si);
3361
+ _(this, "events", {});
3362
+ _(this, "defaultMode", "render");
3226
3363
  this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
3227
3364
  }
3228
3365
  /**
@@ -3264,7 +3401,7 @@ class Mi {
3264
3401
  if (this.options && this.options.modes && this.options.modes.length === 0)
3265
3402
  throw new Error("At least a mode must be enabled.");
3266
3403
  this.map = t;
3267
- const e = Si(), i = [];
3404
+ const e = xi(), i = [];
3268
3405
  return (s = (o = this.options) == null ? void 0 : o.modes) == null || s.forEach((d) => {
3269
3406
  if (this.options.modeOptions && this.options.modeOptions[d]) {
3270
3407
  const c = this.options.modeOptions[d];
@@ -3286,8 +3423,8 @@ class Mi {
3286
3423
  modeName: "default",
3287
3424
  styles: {}
3288
3425
  })
3289
- ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new mi({
3290
- adapter: new Ci({ map: t, ...this.options.adapterOptions }),
3426
+ ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new vi({
3427
+ adapter: new Pi({ map: t, ...this.options.adapterOptions }),
3291
3428
  modes: i
3292
3429
  }), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
3293
3430
  d.mode !== "default" && this.addTerradrawButton(d.mode);
@@ -3325,12 +3462,17 @@ class Mi {
3325
3462
  /**
3326
3463
  * Dispatch an event. Pass the current snapshot of features and mode
3327
3464
  * @param event event type
3465
+ * @param args additional arguments
3328
3466
  */
3329
- dispatchEvent(t) {
3330
- this.events[t] && this.events[t].forEach((e) => {
3331
- var s, n;
3332
- const i = (s = this.terradraw) == null ? void 0 : s.getSnapshot(), o = i == null ? void 0 : i.filter((a) => a.properties.selected === !0);
3333
- e({ feature: o, mode: (n = this.terradraw) == null ? void 0 : n.getMode() });
3467
+ dispatchEvent(t, e) {
3468
+ this.events[t] && this.events[t].forEach((i) => {
3469
+ var n, a;
3470
+ const o = (n = this.terradraw) == null ? void 0 : n.getSnapshot(), s = o == null ? void 0 : o.filter((l) => l.properties.selected === !0);
3471
+ i({
3472
+ feature: s,
3473
+ mode: (a = this.terradraw) == null ? void 0 : a.getMode(),
3474
+ ...e
3475
+ });
3334
3476
  });
3335
3477
  }
3336
3478
  /**
@@ -3386,10 +3528,11 @@ class Mi {
3386
3528
  if (!this.terradraw || !this.terradraw.enabled) return;
3387
3529
  const o = ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((n) => n.properties.selected === !0);
3388
3530
  if (o.length > 0) {
3389
- const n = this.terradraw.getMode();
3390
- this.terradraw.setMode(this.defaultMode);
3391
- const a = o.map((l) => l.id);
3392
- this.terradraw.removeFeatures(a), this.terradraw.setMode(n), this.dispatchEvent("feature-deleted");
3531
+ const n = o.map((a) => a.id);
3532
+ this.terradraw.removeFeatures(n);
3533
+ for (const a of n)
3534
+ this.terradraw.deselectFeature(a);
3535
+ this.dispatchEvent("feature-deleted", { deletedIds: n });
3393
3536
  }
3394
3537
  this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
3395
3538
  })) : t === "download" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", this.handleDownload.bind(this))) : (e.classList.add(`maplibregl-terradraw-add-${t}-button`), e.addEventListener("click", () => {
@@ -3428,7 +3571,7 @@ class Mi {
3428
3571
  * @returns
3429
3572
  */
3430
3573
  cleanStyle(t, e) {
3431
- return Ee(t, e, St);
3574
+ return De(t, e, xt);
3432
3575
  }
3433
3576
  /**
3434
3577
  * Download button click event handler
@@ -3474,28 +3617,28 @@ class Mi {
3474
3617
  }
3475
3618
  }
3476
3619
  }
3477
- var L = 63710088e-1, Ii = {
3478
- centimeters: L * 100,
3479
- centimetres: L * 100,
3620
+ var k = 63710088e-1, Mi = {
3621
+ centimeters: k * 100,
3622
+ centimetres: k * 100,
3480
3623
  degrees: 360 / (2 * Math.PI),
3481
- feet: L * 3.28084,
3482
- inches: L * 39.37,
3483
- kilometers: L / 1e3,
3484
- kilometres: L / 1e3,
3485
- meters: L,
3486
- metres: L,
3487
- miles: L / 1609.344,
3488
- millimeters: L * 1e3,
3489
- millimetres: L * 1e3,
3490
- nauticalmiles: L / 1852,
3624
+ feet: k * 3.28084,
3625
+ inches: k * 39.37,
3626
+ kilometers: k / 1e3,
3627
+ kilometres: k / 1e3,
3628
+ meters: k,
3629
+ metres: k,
3630
+ miles: k / 1609.344,
3631
+ millimeters: k * 1e3,
3632
+ millimetres: k * 1e3,
3633
+ nauticalmiles: k / 1852,
3491
3634
  radians: 1,
3492
- yards: L * 1.0936
3635
+ yards: k * 1.0936
3493
3636
  };
3494
3637
  function wi(r, t, e = {}) {
3495
3638
  const i = { type: "Feature" };
3496
3639
  return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
3497
3640
  }
3498
- function bi(r, t, e = {}) {
3641
+ function Fi(r, t, e = {}) {
3499
3642
  if (!r)
3500
3643
  throw new Error("coordinates is required");
3501
3644
  if (!Array.isArray(r))
@@ -3510,7 +3653,7 @@ function bi(r, t, e = {}) {
3510
3653
  }, t, e);
3511
3654
  }
3512
3655
  function Ei(r, t = "kilometers") {
3513
- const e = Ii[t];
3656
+ const e = Mi[t];
3514
3657
  if (!e)
3515
3658
  throw new Error(t + " units is invalid");
3516
3659
  return r * e;
@@ -3534,14 +3677,14 @@ function ie(r) {
3534
3677
  return [...r];
3535
3678
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
3536
3679
  }
3537
- function Fi(r, t, e = {}) {
3680
+ function Oi(r, t, e = {}) {
3538
3681
  var i = ie(r), o = ie(t), s = ht(o[1] - i[1]), n = ht(o[0] - i[0]), a = ht(i[1]), l = ht(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3539
3682
  return Ei(
3540
3683
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3541
3684
  e.units
3542
3685
  );
3543
3686
  }
3544
- function Fe(r, t, e) {
3687
+ function Le(r, t, e) {
3545
3688
  if (r !== null)
3546
3689
  for (var i, o, s, n, a, l, d, c = 0, h = 0, u, p = r.type, g = p === "FeatureCollection", y = p === "Feature", v = g ? r.features.length : 1, f = 0; f < v; f++) {
3547
3690
  d = g ? r.features[f].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
@@ -3618,7 +3761,7 @@ function Fe(r, t, e) {
3618
3761
  break;
3619
3762
  case "GeometryCollection":
3620
3763
  for (i = 0; i < n.geometries.length; i++)
3621
- if (Fe(n.geometries[i], t) === !1)
3764
+ if (Le(n.geometries[i], t) === !1)
3622
3765
  return !1;
3623
3766
  break;
3624
3767
  default:
@@ -3679,7 +3822,7 @@ function Di(r, t) {
3679
3822
  u++;
3680
3823
  }
3681
3824
  }
3682
- function Oi(r, t, e) {
3825
+ function Li(r, t, e) {
3683
3826
  var i = e;
3684
3827
  return Di(
3685
3828
  r,
@@ -3696,13 +3839,13 @@ function Oi(r, t, e) {
3696
3839
  ), i;
3697
3840
  }
3698
3841
  function _i(r) {
3699
- return Oi(
3842
+ return Li(
3700
3843
  r,
3701
- (t, e) => t + Li(e),
3844
+ (t, e) => t + ki(e),
3702
3845
  0
3703
3846
  );
3704
3847
  }
3705
- function Li(r) {
3848
+ function ki(r) {
3706
3849
  let t = 0, e;
3707
3850
  switch (r.type) {
3708
3851
  case "Polygon":
@@ -3728,7 +3871,7 @@ function oe(r) {
3728
3871
  }
3729
3872
  return t;
3730
3873
  }
3731
- var ki = L * L / 2, Et = Math.PI / 180;
3874
+ var Wi = k * k / 2, Et = Math.PI / 180;
3732
3875
  function se(r) {
3733
3876
  const t = r.length - 1;
3734
3877
  if (t <= 2) return 0;
@@ -3737,69 +3880,69 @@ function se(r) {
3737
3880
  const o = r[i], s = r[i + 1 === t ? 0 : i + 1], n = r[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Et, l = s[1] * Et, d = n[0] * Et;
3738
3881
  e += (d - a) * Math.sin(l), i++;
3739
3882
  }
3740
- return e * ki;
3883
+ return e * Wi;
3741
3884
  }
3742
- function Wi(r, t = {}) {
3885
+ function Bi(r, t = {}) {
3743
3886
  let e = 0, i = 0, o = 0;
3744
- return Fe(
3887
+ return Le(
3745
3888
  r,
3746
3889
  function(s) {
3747
3890
  e += s[0], i += s[1], o++;
3748
3891
  }
3749
- ), bi([e / o, i / o], t.properties);
3892
+ ), Fi([e / o, i / o], t.properties);
3750
3893
  }
3751
- var Bi = Object.defineProperty, ji = (r, t, e) => t in r ? Bi(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, tt = (r, t, e) => ji(r, typeof t != "symbol" ? t + "" : t, e), ft = 2 * Math.PI * 6378137 / 2;
3752
- function Ni(r) {
3894
+ var ji = Object.defineProperty, Ni = (r, t, e) => t in r ? ji(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, tt = (r, t, e) => Ni(r, typeof t != "symbol" ? t + "" : t, e), mt = 2 * Math.PI * 6378137 / 2;
3895
+ function Ai(r) {
3753
3896
  return r = r || 256, 2 * Math.PI * 6378137 / r;
3754
3897
  }
3755
- function Ai(r, t, e = { enable: !0, decimal: 1 }) {
3756
- r = Lt(r);
3757
- var i = r[0], o = r[1], s = i * ft / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
3758
- return n = n * ft / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
3898
+ function Ti(r, t, e = { enable: !0, decimal: 1 }) {
3899
+ r = _t(r);
3900
+ var i = r[0], o = r[1], s = i * mt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
3901
+ return n = n * mt / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
3759
3902
  }
3760
- function Ti(r, t, e) {
3761
- var i = r[0], o = r[1], s = Xi(t, e), n = (i + ft) / s, a = (o + ft) / s;
3903
+ function Gi(r, t, e) {
3904
+ var i = r[0], o = r[1], s = Ki(t, e), n = (i + mt) / s, a = (o + mt) / s;
3762
3905
  return [n, a, t];
3763
3906
  }
3764
- function De(r, t, e) {
3765
- r = Lt(r);
3766
- var i = Ai(r), o = Ti(i, t);
3767
- return Vi(o);
3907
+ function _e(r, t, e) {
3908
+ r = _t(r);
3909
+ var i = Ti(r), o = Gi(i, t);
3910
+ return Ui(o);
3768
3911
  }
3769
- function Gi(r, t, e) {
3770
- if (r = Lt(r), t === 0)
3912
+ function Vi(r, t, e) {
3913
+ if (r = _t(r), t === 0)
3771
3914
  return [0, 0, 0];
3772
- var i = De(r, t);
3773
- return Ui(i);
3915
+ var i = _e(r, t);
3916
+ return zi(i);
3774
3917
  }
3775
- function Vi(r, t, e) {
3918
+ function Ui(r, t, e) {
3776
3919
  t = t || 256;
3777
3920
  var i = r[0], o = r[1], s = r[2];
3778
3921
  if (s === 0) return [0, 0, 0];
3779
- Oe(s);
3922
+ ke(s);
3780
3923
  var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
3781
3924
  return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, s];
3782
3925
  }
3783
- function Ui(r, t) {
3784
- zi(r);
3926
+ function zi(r, t) {
3927
+ Ri(r);
3785
3928
  var e = r[0], i = r[1], o = r[2];
3786
3929
  if (o === 0)
3787
3930
  return [0, 0, 0];
3788
3931
  var s = e, n = Math.pow(2, o) - 1 - i;
3789
3932
  return [s, n, o];
3790
3933
  }
3791
- function zi(r, t) {
3934
+ function Ri(r, t) {
3792
3935
  var e = r[0], i = r[1], o = r[2];
3793
3936
  if (o == null) throw new Error("<zoom> is required");
3794
3937
  if (e == null) throw new Error("<x> is required");
3795
3938
  if (i == null) throw new Error("<y> is required");
3796
- return o = Oe(o), r = Ri(r), r;
3939
+ return o = ke(o), r = Xi(r), r;
3797
3940
  }
3798
- function Ri(r) {
3941
+ function Xi(r) {
3799
3942
  var t = r[0], e = r[1], i = r[2], o = Math.pow(2, i);
3800
3943
  return t = t % o, t < 0 && (t = t + o), [t, e, i];
3801
3944
  }
3802
- function Oe(r) {
3945
+ function ke(r) {
3803
3946
  if (r === !1) return r;
3804
3947
  if (r == null)
3805
3948
  throw new Error("<zoom> is required");
@@ -3809,22 +3952,22 @@ function Oe(r) {
3809
3952
  throw new Error("<zoom> cannot be greater than 32");
3810
3953
  return r;
3811
3954
  }
3812
- function Lt(r, t) {
3813
- var e = Yi(r[0]), i = Ki(r[1]);
3955
+ function _t(r, t) {
3956
+ var e = $i(r[0]), i = Yi(r[1]);
3814
3957
  return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
3815
3958
  }
3816
- function Xi(r, t) {
3817
- return Ni(t) / Math.pow(2, r);
3959
+ function Ki(r, t) {
3960
+ return Ai(t) / Math.pow(2, r);
3818
3961
  }
3819
- function Ki(r) {
3962
+ function Yi(r) {
3820
3963
  if (r == null) throw new Error("lat is required");
3821
3964
  return (r > 90 || r < -90) && (r = r % 180, r > 90 && (r = -180 + r), r < -90 && (r = 180 + r), r === 0 && (r = 0)), r;
3822
3965
  }
3823
- function Yi(r) {
3966
+ function $i(r) {
3824
3967
  if (r == null) throw new Error("lng is required");
3825
3968
  return (r > 180 || r < -180) && (r = r % 360, r > 180 && (r = -360 + r), r < -180 && (r = 360 + r), r === 0 && (r = 0)), r;
3826
3969
  }
3827
- class _e {
3970
+ class We {
3828
3971
  /**
3829
3972
  * Constructor
3830
3973
  * @param url URL for terrain RGB raster tilesets
@@ -3849,7 +3992,7 @@ class _e {
3849
3992
  const s = t[0], n = t[1];
3850
3993
  let a = e;
3851
3994
  e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
3852
- const l = this.tms ? De([s, n], a) : Gi([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
3995
+ const l = this.tms ? _e([s, n], a) : Vi([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
3853
3996
  let c = this.getUrlExtension(d);
3854
3997
  switch (c || (c = "png"), c) {
3855
3998
  case "png":
@@ -3951,7 +4094,7 @@ class _e {
3951
4094
  return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
3952
4095
  }
3953
4096
  }
3954
- class $i extends _e {
4097
+ class Hi extends We {
3955
4098
  /**
3956
4099
  * Constructor
3957
4100
  * @param url URL for terrain RGB raster tilesets
@@ -3983,7 +4126,7 @@ class $i extends _e {
3983
4126
  return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
3984
4127
  }
3985
4128
  }
3986
- class Hi extends _e {
4129
+ class qi extends We {
3987
4130
  /**
3988
4131
  * Constructor
3989
4132
  * @param url URL for terrarium raster tilesets
@@ -4017,84 +4160,98 @@ class Hi extends _e {
4017
4160
  return parseInt(o.toFixed(0));
4018
4161
  }
4019
4162
  }
4020
- class so extends Mi {
4163
+ class so extends bi {
4021
4164
  /**
4022
4165
  * Constructor
4023
4166
  * @param options Plugin control options
4024
4167
  */
4025
4168
  constructor(e) {
4026
- let i = Dt;
4169
+ let i = ut;
4027
4170
  e && (i = Object.assign(i, e));
4028
4171
  super({
4029
4172
  modes: i.modes,
4030
4173
  open: i.open,
4031
4174
  modeOptions: i.modeOptions
4032
4175
  });
4033
- k(this, "measureOptions");
4176
+ _(this, "measureOptions");
4034
4177
  /**
4035
4178
  * Handle deselect event of terradraw
4036
- * @param id Feature ID
4037
4179
  */
4038
- k(this, "handleTerradrawDeselect", () => {
4180
+ _(this, "handleTerradrawDeselect", () => {
4039
4181
  if (this.map && this.computeElevation === !0 && this.measureOptions.terrainSource !== void 0) {
4040
4182
  const e = this.getTerraDrawInstance();
4041
4183
  if (!e) return;
4042
- const o = e.getSnapshot().filter(
4043
- (s) => s.properties.mode === "linestring" && s.geometry.type === "LineString"
4184
+ const i = e.getSnapshot(), o = i.filter(
4185
+ (n) => n.properties.mode === "linestring" && n.geometry.type === "LineString"
4044
4186
  );
4045
4187
  if (o.length > 0)
4046
- for (const s of o)
4047
- this.computeElevationByFeatureID(s.id);
4188
+ for (const n of o)
4189
+ this.computeElevationByLineFeatureID(n.id);
4190
+ const s = i.filter(
4191
+ (n) => n.properties.mode === "point" && n.geometry.type === "Point"
4192
+ );
4193
+ if (s.length > 0)
4194
+ for (const n of s)
4195
+ this.computeElevationByPointFeatureID(n.id);
4048
4196
  }
4049
4197
  });
4050
4198
  /**
4051
4199
  * Handle finish event of terradraw. It will be called after finishing adding a feature
4052
4200
  * @param id Feature ID
4053
4201
  */
4054
- k(this, "handleTerradrawFeatureReady", xi((e) => {
4055
- this.map && this.computeElevationByFeatureID(e);
4202
+ _(this, "handleTerradrawFeatureReady", Ii((e) => {
4203
+ this.map && (this.computeElevationByLineFeatureID(e), this.computeElevationByPointFeatureID(e));
4056
4204
  }, 300));
4057
4205
  /**
4058
4206
  * Compute elevation by a LineString feature ID
4059
4207
  * @param id FeatureID
4060
4208
  */
4061
- k(this, "computeElevationByFeatureID", async (e) => {
4062
- var i;
4209
+ _(this, "computeElevationByLineFeatureID", async (e) => {
4063
4210
  if (this.map && this.computeElevation === !0) {
4064
- const o = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
4065
- if (o && typeof o.data != "string" && o.data.type === "FeatureCollection") {
4066
- const s = o.data.features.filter(
4067
- (n) => {
4068
- var a;
4069
- return ((a = n.properties) == null ? void 0 : a.originalId) === e && n.geometry.type === "Point";
4211
+ const i = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
4212
+ if (i && typeof i.data != "string" && i.data.type === "FeatureCollection") {
4213
+ const o = i.data.features.filter(
4214
+ (s) => {
4215
+ var n;
4216
+ return ((n = s.properties) == null ? void 0 : n.originalId) === e && s.geometry.type === "Point";
4070
4217
  }
4071
4218
  );
4072
- if (s && s.length > 0) {
4073
- const n = await this.queryTerrainElevation(
4074
- s
4075
- ), a = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
4076
- if (a && typeof a.data != "string" && a.data.type === "FeatureCollection") {
4077
- const l = n.map((d) => d.id);
4078
- if (typeof a.data != "string" && a.data.type === "FeatureCollection") {
4079
- a.data.features = [
4080
- ...a.data.features = a.data.features.filter(
4081
- (c) => {
4082
- var h;
4083
- return !(l.includes((h = c.properties) == null ? void 0 : h.originalId) && c.geometry.type === "Point");
4084
- }
4085
- ),
4086
- ...n
4087
- ];
4088
- const d = {};
4089
- a.data.features.forEach((c) => {
4090
- var u;
4091
- const h = c.id;
4092
- d[h] ? !d[h].properties.elevation && ((u = c.properties) != null && u.elevation) && (d[h] = c) : d[h] = c;
4093
- }), a.data.features = Array.from(Object.values(d)), (i = this.map.getSource(
4094
- this.measureOptions.lineLayerLabelSpec.source
4095
- )) == null || i.setData(a.data);
4096
- }
4219
+ if (o && o.length > 0) {
4220
+ const s = await this.queryTerrainElevation(
4221
+ o
4222
+ );
4223
+ this.replaceGeoJSONSource(
4224
+ s,
4225
+ this.measureOptions.lineLayerLabelSpec.source,
4226
+ "linestring"
4227
+ );
4228
+ }
4229
+ }
4230
+ }
4231
+ });
4232
+ /**
4233
+ * Compute elevation by a Point feature ID
4234
+ * @param id FeatureID
4235
+ */
4236
+ _(this, "computeElevationByPointFeatureID", async (e) => {
4237
+ if (this.map && this.computeElevation === !0) {
4238
+ const i = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
4239
+ if (i && typeof i.data != "string" && i.data.type === "FeatureCollection") {
4240
+ const o = i.data.features.filter(
4241
+ (s) => {
4242
+ var n;
4243
+ return s.id === e && s.geometry.type === "Point" && ((n = s.properties) == null ? void 0 : n.mode) === "point";
4097
4244
  }
4245
+ );
4246
+ if (o && o.length > 0) {
4247
+ const s = await this.queryTerrainElevation(
4248
+ o
4249
+ );
4250
+ this.replaceGeoJSONSource(
4251
+ s,
4252
+ this.measureOptions.pointLayerLabelSpec.source,
4253
+ "point"
4254
+ );
4098
4255
  }
4099
4256
  }
4100
4257
  }
@@ -4104,10 +4261,10 @@ class so extends Mi {
4104
4261
  * @param feature GeoJSON feature
4105
4262
  * @returns updated GeoJSON feature
4106
4263
  */
4107
- k(this, "updateFeatureProperties", (e) => {
4264
+ _(this, "updateFeatureProperties", (e) => {
4108
4265
  if (!this.map || !this.map.loaded()) return e;
4109
4266
  const i = e.geometry.type;
4110
- return i === "LineString" ? e = this.calcDistance(e) : i === "Polygon" && (e = this.calcArea(e)), e;
4267
+ return i === "LineString" ? e = this.calcDistance(e) : i === "Polygon" ? e = this.calcArea(e) : i === "Point" && (e = this.queryElevationByPoint(e)), e;
4111
4268
  });
4112
4269
  this.measureOptions = i;
4113
4270
  }
@@ -4205,7 +4362,7 @@ class so extends Mi {
4205
4362
  const i = e.getSnapshot();
4206
4363
  for (const o of i) {
4207
4364
  const s = o.id, n = o.geometry.type, a = o.properties.mode;
4208
- a === "linestring" && n === "LineString" ? (this.measureLine(s), this.computeElevationByFeatureID(s)) : !["point", "linestring", "select", "render"].includes(a) && n === "Polygon" && this.measurePolygon(s);
4365
+ a === "linestring" && n === "LineString" ? (this.measureLine(s), this.computeElevationByLineFeatureID(s)) : a === "point" && n === "Point" ? (this.measurePoint(s), this.computeElevationByPointFeatureID(s)) : !["point", "linestring", "select", "render"].includes(a) && n === "Polygon" && this.measurePolygon(s);
4209
4366
  }
4210
4367
  }
4211
4368
  }
@@ -4225,20 +4382,30 @@ class so extends Mi {
4225
4382
  * @returns
4226
4383
  */
4227
4384
  cleanStyle(e, i) {
4228
- var a, l;
4229
- const o = St, s = (a = this.measureOptions.polygonLayerSpec) == null ? void 0 : a.source;
4385
+ var l, d, c;
4386
+ const o = xt, s = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
4230
4387
  s && o.push(s);
4231
- const n = (l = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : l.source;
4232
- return n && o.push(n), Ee(e, i, o);
4388
+ const n = (d = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : d.source;
4389
+ n && o.push(n);
4390
+ const a = (c = this.measureOptions.pointLayerLabelSpec) == null ? void 0 : c.source;
4391
+ return a && o.push(a), De(e, i, o);
4233
4392
  }
4234
4393
  /**
4235
4394
  * Register measure control related maplibre sources and layers
4236
4395
  */
4237
4396
  registerMesureControl() {
4238
- var o, s;
4397
+ var s, n, a;
4239
4398
  if (!this.map) return;
4240
- const e = (o = this.options.modes) == null ? void 0 : o.filter((n) => ["linestring"].includes(n));
4241
- e && e.length > 0 && (this.map.getSource(
4399
+ const e = (s = this.options.modes) == null ? void 0 : s.filter((l) => ["linestring"].includes(l));
4400
+ ((n = this.options.modes) == null ? void 0 : n.find((l) => l === "point")) && (this.map.getSource(
4401
+ this.measureOptions.pointLayerLabelSpec.source
4402
+ ) || this.map.addSource(
4403
+ this.measureOptions.pointLayerLabelSpec.source,
4404
+ {
4405
+ type: "geojson",
4406
+ data: { type: "FeatureCollection", features: [] }
4407
+ }
4408
+ ), this.map.getLayer(this.measureOptions.pointLayerLabelSpec.id) || this.map.addLayer(this.measureOptions.pointLayerLabelSpec)), e && e.length > 0 && (this.map.getSource(
4242
4409
  this.measureOptions.lineLayerLabelSpec.source
4243
4410
  ) || this.map.addSource(
4244
4411
  this.measureOptions.lineLayerLabelSpec.source,
@@ -4247,8 +4414,8 @@ class so extends Mi {
4247
4414
  data: { type: "FeatureCollection", features: [] }
4248
4415
  }
4249
4416
  ), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) || this.map.addLayer(this.measureOptions.lineLayerNodeSpec), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) || this.map.addLayer(this.measureOptions.lineLayerLabelSpec));
4250
- const i = (s = this.options.modes) == null ? void 0 : s.filter(
4251
- (n) => [
4417
+ const o = (a = this.options.modes) == null ? void 0 : a.filter(
4418
+ (l) => [
4252
4419
  "polygon",
4253
4420
  "rectangle",
4254
4421
  "angled-rectangle",
@@ -4256,9 +4423,9 @@ class so extends Mi {
4256
4423
  "sector",
4257
4424
  "sensor",
4258
4425
  "freehand"
4259
- ].includes(n)
4426
+ ].includes(l)
4260
4427
  );
4261
- if (i && i.length > 0 && (this.map.getSource(
4428
+ if (o && o.length > 0 && (this.map.getSource(
4262
4429
  this.measureOptions.polygonLayerSpec.source
4263
4430
  ) || this.map.addSource(
4264
4431
  this.measureOptions.polygonLayerSpec.source,
@@ -4266,9 +4433,9 @@ class so extends Mi {
4266
4433
  type: "geojson",
4267
4434
  data: { type: "FeatureCollection", features: [] }
4268
4435
  }
4269
- ), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) || this.map.addLayer(this.measureOptions.polygonLayerSpec)), e && e.length > 0 || i && i.length > 0) {
4270
- const n = this.getTerraDrawInstance();
4271
- n && (n.on("change", this.handleTerradrawFeatureChanged.bind(this)), n.on("finish", this.handleTerradrawFeatureReady.bind(this)), n.on("deselect", this.handleTerradrawDeselect.bind(this)), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
4436
+ ), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) || this.map.addLayer(this.measureOptions.polygonLayerSpec)), e && e.length > 0 || o && o.length > 0) {
4437
+ const l = this.getTerraDrawInstance();
4438
+ l && (l.on("change", this.handleTerradrawFeatureChanged.bind(this)), l.on("finish", this.handleTerradrawFeatureReady.bind(this)), l.on("deselect", this.handleTerradrawDeselect.bind(this)), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
4272
4439
  }
4273
4440
  }
4274
4441
  /**
@@ -4284,7 +4451,7 @@ class so extends Mi {
4284
4451
  const n = o.find((a) => a.id === s);
4285
4452
  if (n) {
4286
4453
  const a = n.geometry.type, l = n.properties.mode;
4287
- l === "linestring" && a === "LineString" ? this.measureLine(s) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(s);
4454
+ l === "linestring" && a === "LineString" ? this.measureLine(s) : l === "point" && a === "Point" ? this.measurePoint(s) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(s);
4288
4455
  } else
4289
4456
  this.clearMeasureFeatures(
4290
4457
  s,
@@ -4295,6 +4462,9 @@ class so extends Mi {
4295
4462
  ), this.clearMeasureFeatures(
4296
4463
  s,
4297
4464
  this.measureOptions.polygonLayerSpec.source
4465
+ ), this.clearMeasureFeatures(
4466
+ s,
4467
+ this.measureOptions.pointLayerLabelSpec.source
4298
4468
  );
4299
4469
  }
4300
4470
  }
@@ -4302,7 +4472,13 @@ class so extends Mi {
4302
4472
  * Unregister measure control related maplibre sources and layers
4303
4473
  */
4304
4474
  unregisterMesureControl() {
4305
- this.off("feature-deleted", this.onFeatureDeleted.bind(this)), this.map && (this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerNodeSpec.id), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.removeLayer(this.measureOptions.polygonLayerSpec.id), this.map.getSource(
4475
+ this.off("feature-deleted", this.onFeatureDeleted.bind(this)), this.map && (this.map.getLayer(this.measureOptions.pointLayerLabelSpec.id) && this.map.removeLayer(
4476
+ this.measureOptions.pointLayerLabelSpec.id
4477
+ ), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerNodeSpec.id), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.removeLayer(this.measureOptions.polygonLayerSpec.id), this.map.getSource(
4478
+ this.measureOptions.pointLayerLabelSpec.source
4479
+ ) && this.map.removeSource(
4480
+ this.measureOptions.pointLayerLabelSpec.source
4481
+ ), this.map.getSource(
4306
4482
  this.measureOptions.lineLayerLabelSpec.source
4307
4483
  ) && this.map.removeSource(
4308
4484
  this.measureOptions.lineLayerLabelSpec.source
@@ -4346,6 +4522,42 @@ class so extends Mi {
4346
4522
  getDistanceUnitName(e) {
4347
4523
  return e === "degrees" ? "°" : e === "miles" ? "mi" : e === "radians" ? "rad" : "km";
4348
4524
  }
4525
+ /**
4526
+ * Replace GeoJSON source with updated features for a given source ID
4527
+ * @param updatedFeatures Updated GeoJSON features
4528
+ * @param sourceId Source ID to update
4529
+ * @param type either 'linestring' or 'point'
4530
+ */
4531
+ replaceGeoJSONSource(e, i, o) {
4532
+ var n;
4533
+ if (!this.map) return;
4534
+ const s = this.map.getStyle().sources[i];
4535
+ if (s && typeof s.data != "string" && s.data.type === "FeatureCollection") {
4536
+ const a = e.map((l) => l.id);
4537
+ if (typeof s.data != "string" && s.data.type === "FeatureCollection") {
4538
+ o === "linestring" ? s.data.features = [
4539
+ ...s.data.features = s.data.features.filter(
4540
+ (d) => {
4541
+ var c;
4542
+ return !(a.includes((c = d.properties) == null ? void 0 : c.originalId) && d.geometry.type === "Point");
4543
+ }
4544
+ ),
4545
+ ...e
4546
+ ] : o === "point" && (s.data.features = [
4547
+ ...s.data.features = s.data.features.filter(
4548
+ (d) => !(a.includes(d.id) && d.geometry.type === "Point")
4549
+ ),
4550
+ ...e
4551
+ ]);
4552
+ const l = {};
4553
+ s.data.features.forEach((d) => {
4554
+ var h;
4555
+ const c = d.id;
4556
+ l[c] ? !l[c].properties.elevation && ((h = d.properties) != null && h.elevation) && (l[c] = d) : l[c] = d;
4557
+ }), s.data.features = Array.from(Object.values(l)), (n = this.map.getSource(i)) == null || n.setData(s.data);
4558
+ }
4559
+ }
4560
+ }
4349
4561
  /**
4350
4562
  * Query terrain elvation for point features
4351
4563
  * @param point Point GeoJSON features
@@ -4361,7 +4573,7 @@ class so extends Mi {
4361
4573
  const n = this.measureOptions.terrainSource;
4362
4574
  if (n) {
4363
4575
  const a = n.url, l = n.encoding ?? "mapbox", d = n.tileSize ?? 512, c = n.minzoom ?? 5, h = n.maxzoom ?? 15, u = n.tms ?? !1;
4364
- (l === "mapbox" ? new $i(a, d, c, h, u) : new Hi(a, d, c, h, u)).getElevation(o.geometry.coordinates, h).then((p) => {
4576
+ (l === "mapbox" ? new Hi(a, d, c, h, u) : new qi(a, d, c, h, u)).getElevation(o.geometry.coordinates, h).then((p) => {
4365
4577
  p && (o.properties.elevation = p), s(o);
4366
4578
  }).catch(() => s(o));
4367
4579
  } else
@@ -4370,6 +4582,16 @@ class so extends Mi {
4370
4582
  );
4371
4583
  return await Promise.all(i);
4372
4584
  }
4585
+ queryElevationByPoint(e) {
4586
+ var o;
4587
+ if (e.geometry.type !== "Point") return e;
4588
+ const i = e.geometry.coordinates;
4589
+ if (this.computeElevation === !0 && this.measureOptions.terrainSource === void 0) {
4590
+ const s = (o = this.map) == null ? void 0 : o.queryTerrainElevation(i);
4591
+ s && (e.properties.elevation = s);
4592
+ }
4593
+ return e;
4594
+ }
4373
4595
  /**
4374
4596
  * Caclulate distance for each segment on a given feature
4375
4597
  * @param feature LineString GeoJSON feature
@@ -4382,7 +4604,7 @@ class so extends Mi {
4382
4604
  let o = 0;
4383
4605
  const s = [];
4384
4606
  for (let l = 0; l < i.length - 1; l++) {
4385
- const d = i[l], c = i[l + 1], h = Fi(d, c, { units: this.distanceUnit });
4607
+ const d = i[l], c = i[l + 1], h = Oi(d, c, { units: this.distanceUnit });
4386
4608
  o += h;
4387
4609
  const u = JSON.parse(JSON.stringify(e));
4388
4610
  if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, c], u.properties.originalId = e.id, u.properties.distance = parseFloat(h.toFixed(this.distancePrecision)), u.properties.total = parseFloat(o.toFixed(this.distancePrecision)), u.properties.unit = this.getDistanceUnitName(this.distanceUnit), this.computeElevation === !0 && this.measureOptions.terrainSource === void 0) {
@@ -4416,12 +4638,16 @@ class so extends Mi {
4416
4638
  }
4417
4639
  ));
4418
4640
  const l = JSON.parse(JSON.stringify(s));
4419
- l.id = l.id + "-area-label", l.geometry = Wi(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), (n = this.map.getSource(
4641
+ l.id = l.id + "-area-label", l.geometry = Bi(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), (n = this.map.getSource(
4420
4642
  this.measureOptions.polygonLayerSpec.source
4421
4643
  )) == null || n.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
4422
4644
  this.measureOptions.lineLayerLabelSpec.id
4423
4645
  ), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) && this.map.moveLayer(
4424
4646
  this.measureOptions.lineLayerNodeSpec.id
4647
+ ), this.map.getLayer(
4648
+ this.measureOptions.pointLayerLabelSpec.id
4649
+ ) && this.map.moveLayer(
4650
+ this.measureOptions.pointLayerLabelSpec.id
4425
4651
  );
4426
4652
  }
4427
4653
  }
@@ -4466,52 +4692,70 @@ class so extends Mi {
4466
4692
  }
4467
4693
  (n = this.map.getSource(
4468
4694
  this.measureOptions.lineLayerLabelSpec.source
4469
- )) == null || n.setData(a.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.moveLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.moveLayer(this.measureOptions.lineLayerNodeSpec.id);
4695
+ )) == null || n.setData(a.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.moveLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.moveLayer(this.measureOptions.lineLayerNodeSpec.id), this.map.getLayer(
4696
+ this.measureOptions.pointLayerLabelSpec.id
4697
+ ) && this.map.moveLayer(
4698
+ this.measureOptions.pointLayerLabelSpec.id
4699
+ );
4470
4700
  }
4471
4701
  }
4472
4702
  }
4703
+ /**
4704
+ * measure point elevation for given feature ID
4705
+ * @param id terradraw feature id
4706
+ */
4707
+ measurePoint(e) {
4708
+ var n;
4709
+ if (!this.map) return;
4710
+ const i = this.getTerraDrawInstance();
4711
+ if (!i) return;
4712
+ const o = i.getSnapshot();
4713
+ let s = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Point");
4714
+ if (s) {
4715
+ const a = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
4716
+ a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
4717
+ (l) => {
4718
+ var d;
4719
+ return ((d = l.properties) == null ? void 0 : d.originalId) !== e;
4720
+ }
4721
+ )), s = this.queryElevationByPoint(s), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(s), (n = this.map.getSource(
4722
+ this.measureOptions.pointLayerLabelSpec.source
4723
+ )) == null || n.setData(a.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && (this.map.moveLayer(
4724
+ this.measureOptions.lineLayerLabelSpec.id
4725
+ ), this.map.moveLayer(
4726
+ this.measureOptions.lineLayerNodeSpec.id
4727
+ )), this.map.moveLayer(
4728
+ this.measureOptions.pointLayerLabelSpec.id
4729
+ ));
4730
+ }
4731
+ }
4473
4732
  /**
4474
4733
  * Event definition when feature is deleted by terradraw
4475
4734
  */
4476
- onFeatureDeleted() {
4477
- var i, o;
4735
+ onFeatureDeleted(e) {
4736
+ var o, s;
4478
4737
  if (!this.map) return;
4479
- const e = this.getTerraDrawInstance();
4480
- if (e) {
4481
- const s = [
4482
- this.measureOptions.lineLayerLabelSpec.source,
4483
- this.measureOptions.polygonLayerSpec.source
4738
+ if (this.getTerraDrawInstance()) {
4739
+ let n = [];
4740
+ typeof e == "object" && e !== null && "deletedIds" in e && (n = e.deletedIds);
4741
+ const a = [
4742
+ this.measureOptions.pointLayerLabelSpec,
4743
+ this.measureOptions.lineLayerLabelSpec,
4744
+ this.measureOptions.polygonLayerSpec
4484
4745
  ];
4485
- for (const n of s) {
4486
- const a = this.map.getStyle().sources[n];
4487
- if (a) {
4488
- const l = e.getSnapshot(), c = (l == null ? void 0 : l.filter(
4489
- (h) => ["LineString", "Polygon"].includes(h.geometry.type)
4490
- )).map((h) => h.id);
4491
- typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
4492
- (h) => {
4493
- var u;
4494
- return c.includes((u = h.properties) == null ? void 0 : u.originalId);
4495
- }
4496
- )), n === this.measureOptions.lineLayerLabelSpec.source ? ((i = this.map.getSource(
4497
- this.measureOptions.lineLayerLabelSpec.source
4498
- )) == null || i.setData(a.data), this.map.getLayer(
4499
- this.measureOptions.lineLayerNodeSpec.id
4500
- ) && this.map.moveLayer(
4501
- this.measureOptions.lineLayerNodeSpec.id
4502
- ), this.map.getLayer(
4503
- this.measureOptions.lineLayerLabelSpec.id
4504
- ) && this.map.moveLayer(
4505
- this.measureOptions.lineLayerLabelSpec.id
4506
- )) : n === this.measureOptions.polygonLayerSpec.source && ((o = this.map.getSource(
4507
- this.measureOptions.polygonLayerSpec.source
4508
- )) == null || o.setData(a.data), this.map.getLayer(
4509
- this.measureOptions.polygonLayerSpec.id
4510
- ) && this.map.moveLayer(
4511
- this.measureOptions.polygonLayerSpec.id
4512
- ));
4746
+ if (n && n.length > 0)
4747
+ for (const l of a) {
4748
+ const d = this.map.getStyle().sources[l.source];
4749
+ d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = d.data.features.filter((c) => {
4750
+ var h;
4751
+ return (h = c.properties) != null && h.originalId ? !n.includes(c.properties.originalId) : !n.includes(c.id);
4752
+ })), (o = this.map.getSource(l.source)) == null || o.setData(d.data));
4753
+ }
4754
+ else
4755
+ for (const l of a) {
4756
+ const d = this.map.getStyle().sources[l.source];
4757
+ d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = []), (s = this.map.getSource(l.source)) == null || s.setData(d.data));
4513
4758
  }
4514
- }
4515
4759
  }
4516
4760
  }
4517
4761
  /**
@@ -4528,17 +4772,16 @@ class so extends Mi {
4528
4772
  }
4529
4773
  }
4530
4774
  export {
4531
- io as AvailableMeasureModes,
4532
- eo as AvailableModes,
4775
+ io as AvailableModes,
4533
4776
  so as MaplibreMeasureControl,
4534
- Mi as MaplibreTerradrawControl,
4777
+ bi as MaplibreTerradrawControl,
4535
4778
  oo as TERRADRAW_MEASURE_SOURCE_IDS,
4536
- St as TERRADRAW_SOURCE_IDS,
4779
+ xt as TERRADRAW_SOURCE_IDS,
4537
4780
  te as capitalize,
4538
- Ee as cleanMaplibreStyle,
4539
- xi as debounce,
4540
- Pi as defaultControlOptions,
4541
- Dt as defaultMeasureControlOptions,
4542
- Si as getDefaultModeOptions
4781
+ De as cleanMaplibreStyle,
4782
+ Ii as debounce,
4783
+ Si as defaultControlOptions,
4784
+ ut as defaultMeasureControlOptions,
4785
+ xi as getDefaultModeOptions
4543
4786
  };
4544
4787
  //# sourceMappingURL=maplibre-gl-terradraw.es.js.map