@watergis/maplibre-gl-terradraw 1.7.3 → 1.7.5

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.
@@ -12,14 +12,14 @@ var b;
12
12
  (function(r) {
13
13
  r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
14
14
  })(b || (b = {}));
15
- const k = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT_FEATURE_ID: "selectionPointFeatureId", SELECTION_POINT: "selectionPoint" }, P = { MODE: "mode", CURRENTLY_DRAWING: "currentlyDrawing", EDITED: "edited", CLOSING_POINT: "closingPoint", SNAPPING_POINT: "snappingPoint", COORDINATE_POINT: "coordinatePoint", COORDINATE_POINT_FEATURE_ID: "coordinatePointFeatureId", COORDINATE_POINT_IDS: "coordinatePointIds", PROVISIONAL_COORDINATE_COUNT: "provisionalCoordinateCount", COMMITTED_COORDINATE_COUNT: "committedCoordinateCount" }, j = 10;
16
- function Ot(r) {
15
+ const k = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT_FEATURE_ID: "selectionPointFeatureId", SELECTION_POINT: "selectionPoint" }, S = { MODE: "mode", CURRENTLY_DRAWING: "currentlyDrawing", EDITED: "edited", CLOSING_POINT: "closingPoint", SNAPPING_POINT: "snappingPoint", COORDINATE_POINT: "coordinatePoint", COORDINATE_POINT_FEATURE_ID: "coordinatePointFeatureId", COORDINATE_POINT_IDS: "coordinatePointIds", PROVISIONAL_COORDINATE_COUNT: "provisionalCoordinateCount", COMMITTED_COORDINATE_COUNT: "committedCoordinateCount" }, j = 10;
16
+ function bt(r) {
17
17
  return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
18
18
  }
19
- function Jt(r) {
19
+ function qt(r) {
20
20
  return !!(r && typeof r == "object" && "properties" in r && typeof r.properties == "object" && r.properties !== null && "mode" in r.properties);
21
21
  }
22
- function qt(r) {
22
+ function Zt(r) {
23
23
  return !!(function(t) {
24
24
  return typeof t == "number" && !isNaN(new Date(t).valueOf());
25
25
  })(r);
@@ -82,9 +82,9 @@ class A {
82
82
  if (this._state === "unregistered") throw new Error("Mode must be registered");
83
83
  const e = (function(i, o) {
84
84
  let s;
85
- if (Ot(i)) if (i.id == null) s = "Feature has no id";
85
+ if (bt(i)) if (i.id == null) s = "Feature has no id";
86
86
  else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
87
- else if (o(i.id)) if (Ot(i.geometry)) if (Ot(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
87
+ else if (o(i.id)) if (bt(i.geometry)) if (bt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
88
88
  if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
89
89
  } else s = "Feature coordinates is not an array";
90
90
  else s = "Feature is not Point, LineString or Polygon";
@@ -157,12 +157,12 @@ function w(r, t = 9) {
157
157
  const e = Math.pow(10, t);
158
158
  return Math.round(r * e) / e;
159
159
  }
160
- const Zt = 57.29577951308232, Qt = 0.017453292519943295, Ct = 6378137, O = (r, t) => ({ x: r === 0 ? 0 : r * Qt * Ct, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Qt / 2)) * Ct }), R = (r, t) => ({ lng: r === 0 ? 0 : Zt * (r / Ct), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / Ct)) - Math.PI / 2) * Zt });
160
+ const Qt = 57.29577951308232, te = 0.017453292519943295, Pt = 6378137, O = (r, t) => ({ x: r === 0 ? 0 : r * te * Pt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * te / 2)) * Pt }), R = (r, t) => ({ lng: r === 0 ? 0 : Qt * (r / Pt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / Pt)) - Math.PI / 2) * Qt });
161
161
  function Ze(r, t, e) {
162
162
  const i = D(r[0]), o = D(r[1]), s = D(e), n = Ie(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
163
163
  return [V(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), V(a)];
164
164
  }
165
- function te(r) {
165
+ function ee(r) {
166
166
  const { center: t, radiusKilometers: e, coordinatePrecision: i } = r, o = r.steps ? r.steps : 64, s = [];
167
167
  for (let n = 0; n < o; n++) {
168
168
  const a = Ze(t, e, -360 * n / o);
@@ -170,7 +170,7 @@ function te(r) {
170
170
  }
171
171
  return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
172
172
  }
173
- function Tt(r) {
173
+ function Wt(r) {
174
174
  let t;
175
175
  if (r.geometry.type === "Polygon") t = r.geometry.coordinates;
176
176
  else {
@@ -186,8 +186,8 @@ function Tt(r) {
186
186
  function o(s, n, a, l) {
187
187
  const d = t[s][n], c = t[s][n + 1], h = t[a][l], u = t[a][l + 1], p = (function(m, v, C, f) {
188
188
  if (gt(m, C) || gt(m, f) || gt(v, C) || gt(f, C)) return null;
189
- const S = m[0], I = m[1], E = v[0], L = v[1], M = C[0], N = C[1], _ = f[0], T = f[1], $ = (S - E) * (N - T) - (I - L) * (M - _);
190
- return $ === 0 ? null : [((S * L - I * E) * (M - _) - (S - E) * (M * T - N * _)) / $, ((S * L - I * E) * (N - T) - (I - L) * (M * T - N * _)) / $];
189
+ const P = m[0], I = m[1], E = v[0], L = v[1], M = C[0], N = C[1], _ = f[0], T = f[1], $ = (P - E) * (N - T) - (I - L) * (M - _);
190
+ return $ === 0 ? null : [((P * L - I * E) * (M - _) - (P - E) * (M * T - N * _)) / $, ((P * L - I * E) * (N - T) - (I - L) * (M * T - N * _)) / $];
191
191
  })(d, c, h, u);
192
192
  if (p === null) return;
193
193
  let g, y;
@@ -197,33 +197,33 @@ function Tt(r) {
197
197
  function gt(r, t) {
198
198
  return r[0] === t[0] && r[1] === t[1];
199
199
  }
200
- function It(r, t) {
201
- return ee(r[0]) <= t && ee(r[1]) <= t;
200
+ function xt(r, t) {
201
+ return ie(r[0]) <= t && ie(r[1]) <= t;
202
202
  }
203
- function Wt(r) {
203
+ function Bt(r) {
204
204
  return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (e = r[0]) >= -180 && e <= 180 && (t = r[1]) >= -90 && t <= 90;
205
205
  var t, e;
206
206
  }
207
- function ee(r) {
207
+ function ie(r) {
208
208
  let t = 1, e = 0;
209
209
  for (; Math.round(r * t) / t !== r; ) t *= 10, e++;
210
210
  return e;
211
211
  }
212
212
  const Qe = "Feature has holes", ti = "Feature has less than 4 coordinates", ei = "Feature has invalid coordinates", ii = "Feature coordinates are not closed";
213
- function xt(r, t) {
213
+ function Ot(r, t) {
214
214
  if (r.geometry.type !== "Polygon") return { valid: !1, reason: "Feature is not a Polygon" };
215
215
  if (r.geometry.coordinates.length !== 1) return { valid: !1, reason: Qe };
216
216
  if (r.geometry.coordinates[0].length < 4) return { valid: !1, reason: ti };
217
217
  for (let o = 0; o < r.geometry.coordinates[0].length; o++) {
218
- if (!Wt(r.geometry.coordinates[0][o])) return { valid: !1, reason: ei };
219
- if (!It(r.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
218
+ if (!Bt(r.geometry.coordinates[0][o])) return { valid: !1, reason: ei };
219
+ if (!xt(r.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
220
220
  }
221
221
  return (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: ii } : { valid: !0 };
222
222
  var e, i;
223
223
  }
224
224
  function ut(r, t) {
225
- const e = xt(r, t);
226
- return e.valid ? Tt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
225
+ const e = Ot(r, t);
226
+ return e.valid ? Wt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
227
227
  }
228
228
  const oi = { cancel: "Escape", finish: "Enter" }, si = { start: "crosshair" };
229
229
  let xe = class extends A {
@@ -235,7 +235,7 @@ let xe = class extends A {
235
235
  }
236
236
  close() {
237
237
  if (this.currentCircleId === void 0) return;
238
- this.store.updateProperty([{ id: this.currentCircleId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
238
+ this.store.updateProperty([{ id: this.currentCircleId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
239
239
  const t = this.currentCircleId;
240
240
  if (this.validate && t) {
241
241
  const e = this.store.getGeometryCopy(t);
@@ -252,7 +252,7 @@ let xe = class extends A {
252
252
  onClick(t) {
253
253
  if (t.button === "right" && this.allowPointerEvent(this.pointerEvents.rightClick, t) || t.button === "left" && this.allowPointerEvent(this.pointerEvents.leftClick, t) || t.isContextMenu && this.allowPointerEvent(this.pointerEvents.contextMenu, t)) if (this.clickCount === 0) {
254
254
  this.center = [t.lng, t.lat];
255
- const e = te({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers, [P.CURRENTLY_DRAWING]: !0 } }]);
255
+ const e = ee({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers, [S.CURRENTLY_DRAWING]: !0 } }]);
256
256
  this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
257
257
  } else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
258
258
  }
@@ -299,14 +299,14 @@ let xe = class extends A {
299
299
  i = (function(s) {
300
300
  const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = O(h, u), y = [];
301
301
  for (let m = 0; m < d; m++) {
302
- const v = 360 * m / d * Math.PI / 180, C = c * Math.cos(v), f = c * Math.sin(v), [S, I] = [p + C, g + f], { lng: E, lat: L } = R(S, I);
302
+ const v = 360 * m / d * Math.PI / 180, C = c * Math.cos(v), f = c * Math.sin(v), [P, I] = [p + C, g + f], { lng: E, lat: L } = R(P, I);
303
303
  y.push([w(E, l), w(L, l)]);
304
304
  }
305
305
  return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
306
306
  })({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
307
307
  } else {
308
308
  if (this.projection !== "globe") throw new Error("Invalid projection");
309
- i = te({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
309
+ i = ee({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
310
310
  }
311
311
  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: b.Provisional }).valid) return;
312
312
  this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
@@ -343,7 +343,7 @@ class Oe extends A {
343
343
  if (this.currentId === void 0) return;
344
344
  if (this.currentId) {
345
345
  const e = pt(this.store.getGeometryCopy(this.currentId));
346
- e && this.store.updateGeometry([{ id: this.currentId, geometry: e }]), this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
346
+ e && this.store.updateGeometry([{ id: this.currentId, geometry: e }]), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
347
347
  }
348
348
  const t = this.currentId;
349
349
  if (this.validate && t) {
@@ -375,7 +375,7 @@ class Oe extends A {
375
375
  if (t.button === "right" && this.allowPointerEvent(this.pointerEvents.rightClick, t) || t.button === "left" && this.allowPointerEvent(this.pointerEvents.leftClick, t) || t.isContextMenu && this.allowPointerEvent(this.pointerEvents.contextMenu, t)) {
376
376
  if (this.preventNewFeature) return;
377
377
  if (this.startingClick === !1) {
378
- const [e, i] = 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, [P.CURRENTLY_DRAWING]: !0 } }, { geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: { mode: this.mode, [P.CLOSING_POINT]: !0 } }]);
378
+ const [e, i] = 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, [S.CURRENTLY_DRAWING]: !0 } }, { geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: { mode: this.mode, [S.CLOSING_POINT]: !0 } }]);
379
379
  return this.currentId = e, this.closingPointId = i, this.startingClick = !0, void (this.state !== "drawing" && this.setDrawing());
380
380
  }
381
381
  this.close();
@@ -405,7 +405,7 @@ class Oe extends A {
405
405
  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 = j, 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 = 50), e);
406
406
  }
407
407
  validateFeature(t) {
408
- return this.validateModeFeature(t, (e) => xt(e, this.coordinatePrecision));
408
+ return this.validateModeFeature(t, (e) => Ot(e, this.coordinatePrecision));
409
409
  }
410
410
  afterFeatureUpdated(t) {
411
411
  this.currentId === t.id && (this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.hasLeftStartingPoint = !1);
@@ -438,7 +438,7 @@ class ct extends B {
438
438
  return F({ x: i, y: o }, { x: t.containerX, y: t.containerY });
439
439
  }
440
440
  }
441
- let Pt = class extends B {
441
+ let St = class extends B {
442
442
  constructor(t, e, i) {
443
443
  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;
444
444
  }
@@ -458,7 +458,7 @@ let Pt = class extends B {
458
458
  }), s;
459
459
  }
460
460
  };
461
- function ie(r, t, e) {
461
+ function oe(r, t, e) {
462
462
  const i = D(r[0]), o = D(r[1]), s = D(e), n = Ie(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
463
463
  return [V(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), V(a)];
464
464
  }
@@ -466,7 +466,7 @@ function ht({ x: r, y: t }, e, i) {
466
466
  const o = D(i);
467
467
  return { x: r + e * Math.cos(o), y: t + e * Math.sin(o) };
468
468
  }
469
- function oe(r, t) {
469
+ function se(r, t) {
470
470
  const e = D(r[0]), i = D(t[0]), o = D(r[1]), s = D(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);
471
471
  return V(Math.atan2(n, a));
472
472
  }
@@ -485,9 +485,9 @@ function ai(r, t, e) {
485
485
  for (let c = 0; c < r.length && !(t >= l && c === r.length - 1); c++) {
486
486
  if (l > t && i.length === 0) {
487
487
  if (s = t - l, !s) return i.push(r[c]), i;
488
- n = oe(r[c], r[c - 1]) - 180, a = ie(r[c], s, n), i.push(a);
488
+ n = se(r[c], r[c - 1]) - 180, a = oe(r[c], s, n), i.push(a);
489
489
  }
490
- if (l >= e) return s = e - l, s ? (n = oe(r[c], r[c - 1]) - 180, a = ie(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
490
+ if (l >= e) return s = e - l, s ? (n = se(r[c], r[c - 1]) - 180, a = oe(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
491
491
  if (l >= t && i.push(r[c]), c === r.length - 1) return i;
492
492
  l += U(r[c], r[c + 1]);
493
493
  }
@@ -498,7 +498,7 @@ function ai(r, t, e) {
498
498
  function yt(r) {
499
499
  return r * (Math.PI / 180);
500
500
  }
501
- function se(r) {
501
+ function re(r) {
502
502
  return r * (180 / Math.PI);
503
503
  }
504
504
  class li extends B {
@@ -528,10 +528,10 @@ class li extends B {
528
528
  const g = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
529
529
  if (g === 0 || isNaN(g)) return d;
530
530
  for (let y = 0; y <= l; y++) {
531
- const m = y / l, v = Math.sin((1 - m) * g) / Math.sin(g), C = Math.sin(m * g) / Math.sin(g), f = v * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(p), S = v * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(p), I = v * Math.sin(c) + C * Math.sin(u);
532
- if (isNaN(f) || isNaN(S) || isNaN(I)) continue;
533
- const E = Math.atan2(I, Math.sqrt(f ** 2 + S ** 2)), L = Math.atan2(S, f);
534
- isNaN(E) || isNaN(L) || d.push([se(L), se(E)]);
531
+ const m = y / l, v = Math.sin((1 - m) * g) / Math.sin(g), C = Math.sin(m * g) / Math.sin(g), f = v * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(p), P = v * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(p), I = v * Math.sin(c) + C * Math.sin(u);
532
+ if (isNaN(f) || isNaN(P) || isNaN(I)) continue;
533
+ const E = Math.atan2(I, Math.sqrt(f ** 2 + P ** 2)), L = Math.atan2(P, f);
534
+ isNaN(E) || isNaN(L) || d.push([re(L), re(E)]);
535
535
  }
536
536
  return d.slice(1, -1);
537
537
  })(t, e, Math.floor(o / i));
@@ -544,26 +544,26 @@ class li extends B {
544
544
  function tt(r, t) {
545
545
  return r[0] === t[0] && r[1] === t[1];
546
546
  }
547
- function Bt(r, t) {
547
+ function jt(r, t) {
548
548
  if (r.geometry.type !== "LineString") return { valid: !1, reason: "Feature is not a LineString" };
549
549
  if (r.geometry.coordinates.length < 2) return { valid: !1, reason: "Feature has less than 2 coordinates" };
550
550
  for (let e = 0; e < r.geometry.coordinates.length; e++) {
551
- if (!Wt(r.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
552
- if (!It(r.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
551
+ if (!Bt(r.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
552
+ if (!xt(r.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
553
553
  }
554
554
  return { valid: !0 };
555
555
  }
556
- function re(r) {
556
+ function ne(r) {
557
557
  return Math.sqrt(Math.pow(r[0], 2) + Math.pow(r[1], 2) + Math.pow(r[2], 2));
558
558
  }
559
559
  function Y(r, t) {
560
560
  const e = (function(i, o) {
561
561
  const [s, n, a] = i, [l, d, c] = o;
562
562
  return s * l + n * d + a * c;
563
- })(r, t) / (re(r) * re(t));
563
+ })(r, t) / (ne(r) * ne(t));
564
564
  return Math.acos(Math.min(Math.max(e, -1), 1));
565
565
  }
566
- function bt(r) {
566
+ function Et(r) {
567
567
  const t = D(r[1]), e = D(r[0]);
568
568
  return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
569
569
  }
@@ -572,18 +572,18 @@ function K(r) {
572
572
  return [V(Math.atan2(e, t)), o];
573
573
  }
574
574
  function di(r, t, e) {
575
- const i = bt(r), o = bt(t), s = bt(e), [n, a, l] = s, [d, c, h] = (function(T, $) {
576
- const [Vt, $t, Yt] = T, [Kt, Xt, Ht] = $;
577
- return [$t * Ht - Yt * Xt, Yt * Kt - Vt * Ht, Vt * Xt - $t * Kt];
578
- })(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, m = u * h - g * d, v = p * d - u * c, C = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(m, 2) + Math.pow(v, 2)), f = [y * C, m * C, v * C], S = [-1 * y * C, -1 * m * C, -1 * v * C], I = Y(i, o), E = Y(i, f), L = Y(o, f), M = Y(i, S), N = Y(o, S);
575
+ const i = Et(r), o = Et(t), s = Et(e), [n, a, l] = s, [d, c, h] = (function(T, $) {
576
+ const [$t, Yt, Kt] = T, [Xt, Ht, Jt] = $;
577
+ return [Yt * Jt - Kt * Ht, Kt * Xt - $t * Jt, $t * Ht - Yt * Xt];
578
+ })(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, m = u * h - g * d, v = p * d - u * c, C = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(m, 2) + Math.pow(v, 2)), f = [y * C, m * C, v * C], P = [-1 * y * C, -1 * m * C, -1 * v * C], I = Y(i, o), E = Y(i, f), L = Y(o, f), M = Y(i, P), N = Y(o, P);
579
579
  let _;
580
- return _ = E < M && E < N || L < M && L < N ? f : S, Y(i, _) > I || Y(o, _) > I ? U(K(_), K(i)) <= U(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
580
+ return _ = E < M && E < N || L < M && L < N ? f : P, Y(i, _) > I || Y(o, _) > I ? U(K(_), K(i)) <= U(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
581
581
  }
582
582
  function ci(r, t, e) {
583
583
  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)));
584
584
  return { x: r.x + s * i, y: r.y + s * o };
585
585
  }
586
- class jt extends B {
586
+ class At extends B {
587
587
  constructor(t, e, i) {
588
588
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => {
589
589
  const s = this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode));
@@ -610,23 +610,23 @@ class jt extends B {
610
610
  let g = [1 / 0, 1 / 0], y = 1 / 0, m = 0;
611
611
  for (let v of p) {
612
612
  const C = v[0], f = v[1];
613
- let S, I = 1 / 0;
613
+ let P, I = 1 / 0;
614
614
  const E = O(C[0], C[1]), L = O(f[0], f[1]), M = O(u[0], u[1]);
615
- if (C[0] === u[0] && C[1] === u[1]) S = C;
616
- else if (f[0] === u[0] && f[1] === u[1]) S = f;
615
+ if (C[0] === u[0] && C[1] === u[1]) P = C;
616
+ else if (f[0] === u[0] && f[1] === u[1]) P = f;
617
617
  else {
618
618
  const { x: N, y: _ } = ci(E, L, M), { lng: T, lat: $ } = R(N, _);
619
- S = [T, $];
619
+ P = [T, $];
620
620
  }
621
- S && (I = F(M, O(S[0], S[1])), I < y && (g = S, y = I, m = p.indexOf(v)));
621
+ P && (I = F(M, O(P[0], P[1])), I < y && (g = P, y = I, m = p.indexOf(v)));
622
622
  }
623
623
  return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: m, distance: y };
624
624
  })(c, l) : this.config.projection === "globe" && (d = (function(u, p) {
625
625
  let g = [1 / 0, 1 / 0], y = 1 / 0, m = 0;
626
626
  for (let v of p) {
627
627
  const C = v[0], f = v[1];
628
- let S, I = 1 / 0;
629
- C[0] === u[0] && C[1] === u[1] ? S = C : f[0] === u[0] && f[1] === u[1] ? S = f : [S] = di(C, f, u), S && (I = U(u, S), I < y && (g = S, y = I, m = p.indexOf(v)));
628
+ let P, I = 1 / 0;
629
+ C[0] === u[0] && C[1] === u[1] ? P = C : f[0] === u[0] && f[1] === u[1] ? P = f : [P] = di(C, f, u), P && (I = U(u, P), I < y && (g = P, y = I, m = p.indexOf(v)));
630
630
  }
631
631
  return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: m };
632
632
  })(c, l)), !d) return;
@@ -636,7 +636,7 @@ class jt extends B {
636
636
  }
637
637
  }
638
638
  const hi = { cancel: "Escape", finish: "Enter" }, ui = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
639
- class At extends A {
639
+ class Rt extends A {
640
640
  constructor(t) {
641
641
  super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = hi, this.snapping = void 0, this.cursors = ui, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommittedCoordinates = void 0, this.snappedPointId = void 0, this.lastMouseMoveEvent = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0, this.lineSnapping = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
642
642
  }
@@ -648,7 +648,7 @@ class At extends A {
648
648
  if (e) {
649
649
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
650
650
  else {
651
- const [i] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [P.SNAPPING_POINT]: !0 } }]);
651
+ const [i] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [S.SNAPPING_POINT]: !0 } }]);
652
652
  this.snappedPointId = i;
653
653
  }
654
654
  t.lng = e[0], t.lat = e[1];
@@ -658,7 +658,7 @@ class At extends A {
658
658
  close() {
659
659
  if (this.currentId === void 0) return;
660
660
  const t = this.store.getGeometryCopy(this.currentId);
661
- t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0, b.Commit), this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
661
+ t.coordinates.pop(), this.updateGeometries([...t.coordinates], void 0, b.Commit), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
662
662
  const e = this.currentId;
663
663
  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.lastCommittedCoordinates = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
664
664
  }
@@ -677,12 +677,12 @@ class At extends A {
677
677
  return this.projection === "globe" ? o = this.insertPoint.generateInsertionGeodesicCoordinates(t, e, i) : this.projection === "web-mercator" && (o = this.insertPoint.generateInsertionCoordinates(t, e, i)), o;
678
678
  }
679
679
  createLine(t) {
680
- const [e] = this.store.create([{ geometry: { type: "LineString", coordinates: [t, t] }, properties: { mode: this.mode, [P.CURRENTLY_DRAWING]: !0 } }]);
680
+ const [e] = this.store.create([{ geometry: { type: "LineString", coordinates: [t, t] }, properties: { mode: this.mode, [S.CURRENTLY_DRAWING]: !0 } }]);
681
681
  this.lastCommittedCoordinates = [t, t], this.currentId = e, this.currentCoordinate++, this.setDrawing();
682
682
  }
683
683
  firstUpdateToLine(t) {
684
684
  if (!this.currentId) return;
685
- const e = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...t] }, properties: { mode: this.mode, [P.CLOSING_POINT]: !0 } }]);
685
+ const e = this.store.getGeometryCopy(this.currentId).coordinates, [i] = this.store.create([{ geometry: { type: "Point", coordinates: [...t] }, properties: { mode: this.mode, [S.CLOSING_POINT]: !0 } }]);
686
686
  this.closingPointId = i, this.setCursor(this.cursors.close);
687
687
  const o = [...e, t];
688
688
  this.updateGeometries(o, void 0, b.Commit), this.currentCoordinate++;
@@ -696,7 +696,7 @@ class At extends A {
696
696
  this.updateGeometries(l, i[i.length - 1], b.Commit), this.currentCoordinate++;
697
697
  }
698
698
  registerBehaviors(t) {
699
- this.coordinateSnapping = new Pt(t, new ct(t), new dt(t)), this.insertPoint = new li(t), this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new jt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Pt(t, this.pixelDistance, this.clickBoundingBox);
699
+ this.coordinateSnapping = new St(t, new ct(t), new dt(t)), this.insertPoint = new li(t), this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new At(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new St(t, this.pixelDistance, this.clickBoundingBox);
700
700
  }
701
701
  start() {
702
702
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -758,7 +758,7 @@ class At extends A {
758
758
  }
759
759
  if (this.editedFeatureId && i) {
760
760
  if (!this.editedPointId) {
761
- const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [P.EDITED]: !0 } }]);
761
+ const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [S.EDITED]: !0 } }]);
762
762
  this.editedPointId = o;
763
763
  }
764
764
  this.setCursor(this.cursors.dragStart), e(!1);
@@ -769,10 +769,10 @@ class At extends A {
769
769
  const i = this.store.getGeometryCopy(this.editedFeatureId);
770
770
  this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? i.coordinates[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates.splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
771
771
  const o = { type: "LineString", coordinates: i.coordinates };
772
- this.validate && !this.validate({ type: "Feature", geometry: o, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: o }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: P.EDITED, value: !0 }]));
772
+ this.validate && !this.validate({ type: "Feature", geometry: o, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: o }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !0 }]));
773
773
  }
774
774
  onDragEnd(t, e) {
775
- this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && 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: P.EDITED, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
775
+ this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && 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: S.EDITED, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
776
776
  }
777
777
  cleanUp() {
778
778
  const t = this.currentId, e = this.closingPointId, i = this.snappedPointId;
@@ -786,13 +786,13 @@ class At extends A {
786
786
  const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
787
787
  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 = j, e;
788
788
  if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
789
- const i = t.properties[P.CLOSING_POINT];
789
+ const i = t.properties[S.CLOSING_POINT];
790
790
  return e.pointColor = this.getHexColorStylingValue(i ? this.styles.closingPointColor : this.styles.snappingPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(i ? this.styles.closingPointWidth : this.styles.snappingPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.closingPointOutlineColor : this.styles.snappingPointOutlineColor, "#ffffff", t), e.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.closingPointOutlineWidth : this.styles.snappingPointOutlineWidth, 2, t), e.zIndex = 50, e;
791
791
  }
792
792
  return e;
793
793
  }
794
794
  validateFeature(t) {
795
- return this.validateModeFeature(t, (e) => Bt(e, this.coordinatePrecision));
795
+ return this.validateModeFeature(t, (e) => jt(e, this.coordinatePrecision));
796
796
  }
797
797
  lineStringFilter(t) {
798
798
  return !!(t.geometry.type === "LineString" && t.properties && t.properties.mode === this.mode);
@@ -812,10 +812,10 @@ class At extends A {
812
812
  }
813
813
  const pi = "Feature is not a Point", gi = "Feature has invalid coordinates", yi = "Feature has coordinates with excessive precision";
814
814
  function Ee(r, t) {
815
- return r.geometry.type !== "Point" ? { valid: !1, reason: pi } : Wt(r.geometry.coordinates) ? It(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: yi } : { valid: !1, reason: gi };
815
+ return r.geometry.type !== "Point" ? { valid: !1, reason: pi } : Bt(r.geometry.coordinates) ? xt(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: yi } : { valid: !1, reason: gi };
816
816
  }
817
817
  const fi = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
818
- class Rt extends A {
818
+ class Gt extends A {
819
819
  constructor(t) {
820
820
  super(t, !0), this.mode = "point", this.cursors = fi, this.editable = !1, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
821
821
  }
@@ -850,10 +850,10 @@ class Rt extends A {
850
850
  }
851
851
  }
852
852
  onDrag(t, e) {
853
- this.allowPointerEvent(this.pointerEvents.onDrag, t) && 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: b.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: P.EDITED, value: !0 }])));
853
+ this.allowPointerEvent(this.pointerEvents.onDrag, t) && 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: b.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !0 }])));
854
854
  }
855
855
  onDragEnd(t, e) {
856
- this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && 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: P.EDITED, value: !1 }]), this.editedFeatureId = void 0, e(!0));
856
+ this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && 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: S.EDITED, value: !1 }]), this.editedFeatureId = void 0, e(!0));
857
857
  }
858
858
  registerBehaviors(t) {
859
859
  this.pixelDistance = new ct(t), this.clickBoundingBox = new dt(t);
@@ -907,7 +907,7 @@ class mi extends B {
907
907
  create(t, e) {
908
908
  if (this.ids.length) throw new Error("Opening and closing points already created");
909
909
  if (t.length <= 3) throw new Error("Requires at least 4 coordinates");
910
- this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [P.CLOSING_POINT]: !0 } }, { geometry: { type: "Point", coordinates: t[t.length - 2] }, properties: { mode: e, [P.CLOSING_POINT]: !0 } }]);
910
+ this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [S.CLOSING_POINT]: !0 } }, { geometry: { type: "Point", coordinates: t[t.length - 2] }, properties: { mode: e, [S.CLOSING_POINT]: !0 } }]);
911
911
  }
912
912
  delete() {
913
913
  this.ids.length && (this.store.delete(this.ids), this._startEndPoints = []);
@@ -962,10 +962,10 @@ class we extends B {
962
962
  if (i.coordinatePointIds) return i.coordinatePointIds.map((o, s) => ({ id: o, geometry: x({}, this.store.getGeometryCopy(o), { coordinates: e[s] }) }));
963
963
  }
964
964
  createPoints(t, e, i) {
965
- return this.store.create(t.map((o, s) => ({ geometry: { type: "Point", coordinates: o }, properties: { mode: e, [P.COORDINATE_POINT]: !0, [P.COORDINATE_POINT_FEATURE_ID]: i, index: s } })));
965
+ return this.store.create(t.map((o, s) => ({ geometry: { type: "Point", coordinates: o }, properties: { mode: e, [S.COORDINATE_POINT]: !0, [S.COORDINATE_POINT_FEATURE_ID]: i, index: s } })));
966
966
  }
967
967
  setFeatureCoordinatePoints(t, e) {
968
- this.store.updateProperty([{ id: t, property: P.COORDINATE_POINT_IDS, value: e }]);
968
+ this.store.updateProperty([{ id: t, property: S.COORDINATE_POINT_IDS, value: e }]);
969
969
  }
970
970
  deleteCoordinatePoints(t) {
971
971
  const e = t.filter((i) => this.store.has(i));
@@ -987,7 +987,7 @@ class Le extends A {
987
987
  this.coordinatePoints.createOrUpdate(e);
988
988
  });
989
989
  else if (this.coordinatePoints && this.showCoordinatePoints === !1) {
990
- const e = this.store.copyAllWhere((i) => i.mode === this.mode && !!i[P.COORDINATE_POINT_IDS]);
990
+ const e = this.store.copyAllWhere((i) => i.mode === this.mode && !!i[S.COORDINATE_POINT_IDS]);
991
991
  this.coordinatePoints.deletePointsByFeatureIds(e.map((i) => i.id));
992
992
  }
993
993
  }
@@ -999,12 +999,12 @@ class Le extends A {
999
999
  const e = this.currentId;
1000
1000
  if (this.currentId) {
1001
1001
  const i = pt(this.store.getGeometryCopy(this.currentId));
1002
- i && (this.store.updateGeometry([{ id: this.currentId, geometry: i }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.currentId)), this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }, { id: this.currentId, property: P.COMMITTED_COORDINATE_COUNT, value: void 0 }, { id: this.currentId, property: P.PROVISIONAL_COORDINATE_COUNT, value: void 0 }]);
1002
+ i && (this.store.updateGeometry([{ id: this.currentId, geometry: i }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.currentId)), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }, { id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: void 0 }, { id: this.currentId, property: S.PROVISIONAL_COORDINATE_COUNT, value: void 0 }]);
1003
1003
  }
1004
1004
  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" });
1005
1005
  }
1006
1006
  registerBehaviors(t) {
1007
- this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new jt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Pt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new mi(t, this.pixelDistance), this.coordinatePoints = new we(t);
1007
+ this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new At(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new St(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new mi(t, this.pixelDistance), this.coordinatePoints = new we(t);
1008
1008
  }
1009
1009
  start() {
1010
1010
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -1017,7 +1017,7 @@ class Le extends A {
1017
1017
  if (e) {
1018
1018
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
1019
1019
  else {
1020
- const [i] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [P.SNAPPING_POINT]: !0 } }]);
1020
+ const [i] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [S.SNAPPING_POINT]: !0 } }]);
1021
1021
  this.snappedPointId = i;
1022
1022
  }
1023
1023
  t.lng = e[0], t.lat = e[1];
@@ -1035,7 +1035,7 @@ class Le extends A {
1035
1035
  const { isClosing: o, isPreviousClosing: s } = this.closingPoints.isClosingPoint(t);
1036
1036
  s || o ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), i = [...e.slice(0, -2), e[0], e[0]]) : i = [...e.slice(0, -2), [t.lng, t.lat], e[0]];
1037
1037
  }
1038
- this.store.updateProperty([{ id: this.currentId, property: P.PROVISIONAL_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.updatePolygonGeometry(i, b.Provisional);
1038
+ this.store.updateProperty([{ id: this.currentId, property: S.PROVISIONAL_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.updatePolygonGeometry(i, b.Provisional);
1039
1039
  }
1040
1040
  updatePolygonGeometry(t, e) {
1041
1041
  if (!this.currentId) return !1;
@@ -1070,20 +1070,20 @@ class Le extends A {
1070
1070
  if (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
1071
1071
  const e = this.snapCoordinate(t);
1072
1072
  e && (t.lng = e[0], t.lat = e[1]);
1073
- const [i] = 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, [P.CURRENTLY_DRAWING]: !0, [P.COMMITTED_COORDINATE_COUNT]: this.currentCoordinate + 1, [P.PROVISIONAL_COORDINATE_COUNT]: this.currentCoordinate + 1 } }]);
1073
+ const [i] = 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, [S.CURRENTLY_DRAWING]: !0, [S.COMMITTED_COORDINATE_COUNT]: this.currentCoordinate + 1, [S.PROVISIONAL_COORDINATE_COUNT]: this.currentCoordinate + 1 } }]);
1074
1074
  this.currentId = i, this.currentCoordinate++, this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(i), this.setDrawing();
1075
1075
  } else if (this.currentCoordinate === 1 && this.currentId) {
1076
1076
  const e = this.snapCoordinate(t);
1077
1077
  e && (t.lng = e[0], t.lat = e[1]);
1078
1078
  const i = this.store.getGeometryCopy(this.currentId);
1079
1079
  if (tt([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]], b.Commit)) return;
1080
- this.store.updateProperty([{ id: this.currentId, property: P.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++;
1080
+ this.store.updateProperty([{ id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++;
1081
1081
  } else if (this.currentCoordinate === 2 && this.currentId) {
1082
1082
  const e = this.snapCoordinate(t);
1083
1083
  e && (t.lng = e[0], t.lat = e[1]);
1084
1084
  const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
1085
1085
  if (tt([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]], b.Commit)) return;
1086
- this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.store.updateProperty([{ id: this.currentId, property: P.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++;
1086
+ this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.store.updateProperty([{ id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++;
1087
1087
  } else if (this.currentId) {
1088
1088
  const e = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: o } = this.closingPoints.isClosingPoint(t);
1089
1089
  if (o || i) this.close();
@@ -1094,7 +1094,7 @@ class Le extends A {
1094
1094
  return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
1095
1095
  })([[...e.slice(0, -1), [t.lng, t.lat], e[0]]]);
1096
1096
  if (!this.updatePolygonGeometry(n.geometry.coordinates[0], b.Commit)) return;
1097
- this.store.updateProperty([{ id: this.currentId, property: P.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(n.geometry.coordinates[0]);
1097
+ this.store.updateProperty([{ id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++, this.closingPoints.ids.length && this.closingPoints.update(n.geometry.coordinates[0]);
1098
1098
  }
1099
1099
  }
1100
1100
  }
@@ -1117,7 +1117,7 @@ class Le extends A {
1117
1117
  }
1118
1118
  if (this.editedFeatureId && i) {
1119
1119
  if (!this.editedPointId) {
1120
- const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [P.EDITED]: !0 } }]);
1120
+ const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [S.EDITED]: !0 } }]);
1121
1121
  this.editedPointId = o;
1122
1122
  }
1123
1123
  this.setCursor(this.cursors.dragStart), e(!1);
@@ -1128,10 +1128,10 @@ class Le extends A {
1128
1128
  const i = this.store.getGeometryCopy(this.editedFeatureId), o = i.coordinates[0];
1129
1129
  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++);
1130
1130
  const s = { type: "Polygon", coordinates: i.coordinates };
1131
- this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: s }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.editedFeatureId), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: P.EDITED, value: !0 }]));
1131
+ this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: s }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.editedFeatureId), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: S.EDITED, value: !0 }]));
1132
1132
  }
1133
1133
  onDragEnd(t, e) {
1134
- this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && 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: P.EDITED, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
1134
+ this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && 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: S.EDITED, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
1135
1135
  }
1136
1136
  cleanUp() {
1137
1137
  const t = this.currentId, e = this.snappedPointId, i = this.editedPointId;
@@ -1146,7 +1146,7 @@ class Le extends A {
1146
1146
  if (t.properties.mode === this.mode) {
1147
1147
  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 = j, e;
1148
1148
  if (t.geometry.type === "Point") {
1149
- const i = t.properties[P.EDITED], o = t.properties[P.COORDINATE_POINT], s = i ? "editedPoint" : t.properties[P.CLOSING_POINT] ? "closingPoint" : t.properties[P.SNAPPING_POINT] ? "snappingPoint" : o ? "coordinatePoint" : void 0;
1149
+ const i = t.properties[S.EDITED], o = t.properties[S.COORDINATE_POINT], s = i ? "editedPoint" : t.properties[S.CLOSING_POINT] ? "closingPoint" : t.properties[S.SNAPPING_POINT] ? "snappingPoint" : o ? "coordinatePoint" : void 0;
1150
1150
  if (!s) return e;
1151
1151
  const n = { 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 }, coordinatePoint: { width: this.styles.coordinatePointWidth, color: this.styles.coordinatePointColor, outlineColor: this.styles.coordinatePointOutlineColor, outlineWidth: this.styles.coordinatePointOutlineWidth } };
1152
1152
  return e.pointWidth = this.getNumericStylingValue(n[s].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(n[s].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(n[s].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(n[s].outlineWidth, 2, t), e.zIndex = i ? 40 : o ? 20 : 30, e;
@@ -1161,7 +1161,7 @@ class Le extends A {
1161
1161
  this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(t.id), this.editedFeatureId === t.id && this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0), this.snappedPointId && this.lastMouseMoveEvent && this.updateSnappedCoordinate(this.lastMouseMoveEvent), this.currentId === t.id && (this.currentCoordinate = 0, this.currentId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted());
1162
1162
  }
1163
1163
  validateFeature(t) {
1164
- return this.validateModeFeature(t, (e) => xt(e, this.coordinatePrecision));
1164
+ return this.validateModeFeature(t, (e) => Ot(e, this.coordinatePrecision));
1165
1165
  }
1166
1166
  }
1167
1167
  const Pi = { cancel: "Escape", finish: "Enter" }, Si = { start: "crosshair" };
@@ -1183,7 +1183,7 @@ class Fe extends A {
1183
1183
  const t = this.currentRectangleId;
1184
1184
  if (t) {
1185
1185
  const e = pt(this.store.getGeometryCopy(t));
1186
- e && this.store.updateGeometry([{ id: t, geometry: e }]), this.store.updateProperty([{ id: t, property: P.CURRENTLY_DRAWING, value: void 0 }]);
1186
+ e && this.store.updateGeometry([{ id: t, geometry: e }]), this.store.updateProperty([{ id: t, property: S.CURRENTLY_DRAWING, value: void 0 }]);
1187
1187
  }
1188
1188
  this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.onFinish(t, { mode: this.mode, action: "draw" });
1189
1189
  }
@@ -1196,7 +1196,7 @@ class Fe extends A {
1196
1196
  onClick(t) {
1197
1197
  if (t.button === "right" && this.allowPointerEvent(this.pointerEvents.rightClick, t) || t.button === "left" && this.allowPointerEvent(this.pointerEvents.leftClick, t) || t.isContextMenu && this.allowPointerEvent(this.pointerEvents.contextMenu, t)) if (this.clickCount === 0) {
1198
1198
  this.center = [t.lng, t.lat];
1199
- 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, [P.CURRENTLY_DRAWING]: !0 } }]);
1199
+ 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, [S.CURRENTLY_DRAWING]: !0 } }]);
1200
1200
  this.currentRectangleId = e, this.clickCount++, this.setDrawing();
1201
1201
  } else this.updateRectangle(t, b.Finish), this.close();
1202
1202
  }
@@ -1268,13 +1268,13 @@ class Q extends A {
1268
1268
  validateFeature(t) {
1269
1269
  const e = super.validateFeature(t);
1270
1270
  if (e.valid) {
1271
- const i = t, o = Ee(i, this.coordinatePrecision).valid || xt(i, this.coordinatePrecision).valid || Bt(i, this.coordinatePrecision).valid;
1271
+ const i = t, o = Ee(i, this.coordinatePrecision).valid || Ot(i, this.coordinatePrecision).valid || jt(i, this.coordinatePrecision).valid;
1272
1272
  return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
1273
1273
  }
1274
1274
  return e;
1275
1275
  }
1276
1276
  }
1277
- function Mt(r, t) {
1277
+ function Dt(r, t) {
1278
1278
  const e = r, i = t, o = D(e[1]), s = D(i[1]);
1279
1279
  let n = D(i[0] - e[0]);
1280
1280
  n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
@@ -1295,10 +1295,10 @@ function De(r, t, e, i, o) {
1295
1295
  return [w(a, e), w(l, e)];
1296
1296
  }
1297
1297
  function Ii(r, t, e) {
1298
- const i = Me(r, 1e3 * U(r, t) / 2, Mt(r, t));
1298
+ const i = Me(r, 1e3 * U(r, t) / 2, Dt(r, t));
1299
1299
  return [w(i[0], e), w(i[1], e)];
1300
1300
  }
1301
- function ne({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
1301
+ function ae({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
1302
1302
  const s = [];
1303
1303
  for (let n = 0; n < r.length - 1; n++) {
1304
1304
  let a;
@@ -1322,19 +1322,19 @@ class xi extends B {
1322
1322
  }
1323
1323
  insert(t, e, i) {
1324
1324
  const o = this.store.getGeometryCopy(e), { midPointFeatureId: s, midPointSegment: n } = this.store.getPropertiesCopy(e), a = this.store.getGeometryCopy(s), l = a.type === "Polygon" ? a.coordinates[0] : a.coordinates;
1325
- l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id: s, geometry: a }]), this.store.getPropertiesCopy(t)[P.COORDINATE_POINT_IDS] && this.coordinatePointBehavior.createOrUpdate(t), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(l, s, i), this.selectionPointBehavior.create(l, a.type, s);
1325
+ l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id: s, geometry: a }]), this.store.getPropertiesCopy(t)[S.COORDINATE_POINT_IDS] && this.coordinatePointBehavior.createOrUpdate(t), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(l, s, i), this.selectionPointBehavior.create(l, a.type, s);
1326
1326
  }
1327
1327
  create(t, e, i) {
1328
1328
  if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
1329
1329
  this._midPoints = this.store.create((function(o, s, n, a, l, d) {
1330
- return ne({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1330
+ return ae({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1331
1331
  })(t, (o) => ({ mode: this.mode, [k.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
1332
1332
  }
1333
1333
  delete() {
1334
1334
  this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
1335
1335
  }
1336
1336
  getUpdated(t) {
1337
- if (this._midPoints.length !== 0) return ne({ 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 } }));
1337
+ if (this._midPoints.length !== 0) return ae({ 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 } }));
1338
1338
  }
1339
1339
  }
1340
1340
  class Oi extends B {
@@ -1372,7 +1372,7 @@ function _e(r, t) {
1372
1372
  var i, o, s;
1373
1373
  return e;
1374
1374
  }
1375
- const Dt = (r, t, e) => {
1375
+ const _t = (r, t, e) => {
1376
1376
  const i = (s) => s * s, o = (s, n) => i(s.x - n.x) + i(s.y - n.y);
1377
1377
  return Math.sqrt(((s, n, a) => {
1378
1378
  const l = o(n, a);
@@ -1397,7 +1397,7 @@ class bi extends B {
1397
1397
  } else if (g.type === "LineString") {
1398
1398
  if (i) continue;
1399
1399
  for (let y = 0; y < g.coordinates.length - 1; y++) {
1400
- const m = g.coordinates[y], v = g.coordinates[y + 1], C = Dt({ x: t.containerX, y: t.containerY }, this.project(m[0], m[1]), this.project(v[0], v[1]));
1400
+ const m = g.coordinates[y], v = g.coordinates[y + 1], C = _t({ x: t.containerX, y: t.containerY }, this.project(m[0], m[1]), this.project(v[0], v[1]));
1401
1401
  C < this.pointerDistance && C < l && (l = C, o = p);
1402
1402
  }
1403
1403
  } else if (g.type === "Polygon") {
@@ -1435,8 +1435,8 @@ class Ei extends B {
1435
1435
  const h = s[c];
1436
1436
  let u, p;
1437
1437
  if (this.config.projection === "web-mercator") {
1438
- const g = O(this.dragPosition[0], this.dragPosition[1]), y = O(o[0], o[1]), m = O(h[0], h[1]), v = { x: g.x - y.x, y: g.y - y.y }, C = m.x - v.x, f = m.y - v.y, { lng: S, lat: I } = R(C, f);
1439
- u = S, p = I;
1438
+ const g = O(this.dragPosition[0], this.dragPosition[1]), y = O(o[0], o[1]), m = O(h[0], h[1]), v = { x: g.x - y.x, y: g.y - y.y }, C = m.x - v.x, f = m.y - v.y, { lng: P, lat: I } = R(C, f);
1439
+ u = P, p = I;
1440
1440
  } else {
1441
1441
  const g = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
1442
1442
  u = h[0] - g[0], p = h[1] - g[1];
@@ -1503,7 +1503,7 @@ class wi extends B {
1503
1503
  d[0] = u, d[v] = u;
1504
1504
  } else d[n] = u;
1505
1505
  const p = this.selectionPoints.getOneUpdated(n, u), g = p ? [p] : [], y = this.midPoints.getUpdated(d) || [], m = this.coordinatePoints.getUpdated(s, d) || [];
1506
- return !(a.type !== "Point" && !e && Tt({ geometry: a }) || i && !i(h, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: s, geometry: a }, ...g, ...y, ...m]), 0));
1506
+ return !(a.type !== "Point" && !e && Wt({ geometry: a }) || i && !i(h, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: s, geometry: a }, ...g, ...y, ...m]), 0));
1507
1507
  }
1508
1508
  isDragging() {
1509
1509
  return this.draggedCoordinate.id !== null;
@@ -1515,7 +1515,7 @@ class wi extends B {
1515
1515
  this.draggedCoordinate = { id: null, index: -1 };
1516
1516
  }
1517
1517
  }
1518
- function ae(r) {
1518
+ function le(r) {
1519
1519
  let t = 0, e = 0, i = 0;
1520
1520
  return (r.geometry.type === "Polygon" ? r.geometry.coordinates[0].slice(0, -1) : r.geometry.coordinates).forEach((o) => {
1521
1521
  t += o[0], e += o[1], i++;
@@ -1528,7 +1528,7 @@ const ke = (r, t) => {
1528
1528
  const s = i.map((n) => ({ x: o.x + (n.x - o.x) * Math.cos(e) - (n.y - o.y) * Math.sin(e), y: o.y + (n.x - o.x) * Math.sin(e) + (n.y - o.y) * Math.cos(e) })).map(({ x: n, y: a }) => [R(n, a).lng, R(n, a).lat]);
1529
1529
  return r.geometry.type === "Polygon" ? r.geometry.coordinates[0] = s : r.geometry.coordinates = s, r;
1530
1530
  };
1531
- function _t(r) {
1531
+ function kt(r) {
1532
1532
  const t = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map((e) => {
1533
1533
  const { x: i, y: o } = O(e[0], e[1]);
1534
1534
  return [i, o];
@@ -1566,22 +1566,22 @@ class Li extends B {
1566
1566
  let n;
1567
1567
  const a = { type: "Feature", geometry: o, properties: {} };
1568
1568
  if (this.config.projection === "web-mercator") {
1569
- this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid = _t(a));
1569
+ this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid = kt(a));
1570
1570
  const u = O(t.lng, t.lat);
1571
1571
  if (n = G(this.selectedGeometryWebMercatorCentroid, u), n === 0) return;
1572
1572
  if (!this.lastBearing) return void (this.lastBearing = n);
1573
1573
  ke(a, -(this.lastBearing - n));
1574
1574
  } else {
1575
1575
  if (this.config.projection !== "globe") throw new Error("Unsupported projection");
1576
- if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid = ae({ geometry: o })), n = Mt(this.selectedGeometryCentroid, s), !this.lastBearing) return void (this.lastBearing = n + 180);
1576
+ if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid = le({ geometry: o })), n = Dt(this.selectedGeometryCentroid, s), !this.lastBearing) return void (this.lastBearing = n + 180);
1577
1577
  (function(u, p) {
1578
1578
  if (p === 0 || p === 360 || p === -360) return u;
1579
- const g = ae(u);
1579
+ const g = le(u);
1580
1580
  (u.geometry.type === "Polygon" ? u.geometry.coordinates[0] : u.geometry.coordinates).forEach((y) => {
1581
- const m = Mt(g, y) + p, v = (function(f, S) {
1582
- f[0] += f[0] - S[0] > 180 ? -360 : S[0] - f[0] > 180 ? 360 : 0;
1583
- const I = Se, E = S[1] * Math.PI / 180, L = f[1] * Math.PI / 180, M = L - E;
1584
- let N = Math.abs(f[0] - S[0]) * Math.PI / 180;
1581
+ const m = Dt(g, y) + p, v = (function(f, P) {
1582
+ f[0] += f[0] - P[0] > 180 ? -360 : P[0] - f[0] > 180 ? 360 : 0;
1583
+ const I = Se, E = P[1] * Math.PI / 180, L = f[1] * Math.PI / 180, M = L - E;
1584
+ let N = Math.abs(f[0] - P[0]) * Math.PI / 180;
1585
1585
  N > Math.PI && (N -= 2 * Math.PI);
1586
1586
  const _ = Math.log(Math.tan(L / 2 + Math.PI / 4) / Math.tan(E / 2 + Math.PI / 4)), T = Math.abs(_) > 1e-11 ? M / _ : Math.cos(E);
1587
1587
  return Math.sqrt(M * M + T * T * N * N) * I;
@@ -1679,7 +1679,7 @@ class Mi extends B {
1679
1679
  centerWebMercatorDrag(t) {
1680
1680
  const e = this.getSelectedFeatureDataWebMercator();
1681
1681
  if (!e) return null;
1682
- const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = _t(i);
1682
+ const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = kt(i);
1683
1683
  if (!a) return null;
1684
1684
  const l = O(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = O(t.lng, t.lat);
1685
1685
  return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
@@ -1687,7 +1687,7 @@ class Mi extends B {
1687
1687
  centerFixedWebMercatorDrag(t) {
1688
1688
  const e = this.getSelectedFeatureDataWebMercator();
1689
1689
  if (!e) return null;
1690
- const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = _t(i);
1690
+ const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = kt(i);
1691
1691
  if (!a) return null;
1692
1692
  const l = O(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = O(t.lng, t.lat);
1693
1693
  return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
@@ -1776,19 +1776,19 @@ class Mi extends B {
1776
1776
  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;
1777
1777
  for (let c = 0; c < s.length; c++) {
1778
1778
  const h = s[c];
1779
- if (h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision), !It(h, this.coordinatePrecision)) return !1;
1779
+ if (h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision), !xt(h, this.coordinatePrecision)) return !1;
1780
1780
  }
1781
1781
  const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = this.coordinatePoints.getUpdated(o.id, s) || [], d = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
1782
1782
  return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: d, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: d }, ...a, ...n, ...l]), 0));
1783
1783
  }
1784
1784
  }
1785
- const Di = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, le = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
1786
- class Gt extends qe {
1785
+ const Di = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, de = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
1786
+ class Ut extends qe {
1787
1787
  constructor(t) {
1788
- super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = Di, this.cursors = le, this.validations = {}, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinateSnap = 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.coordinatePoints = void 0, this.lineSnap = void 0, this.updateOptions(t);
1788
+ super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = Di, this.cursors = de, this.validations = {}, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinateSnap = 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.coordinatePoints = void 0, this.lineSnap = void 0, this.updateOptions(t);
1789
1789
  }
1790
1790
  updateOptions(t) {
1791
- if (super.updateOptions(t), this.cursors = t && t.cursors ? x({}, this.cursors, t.cursors) : le, t?.keyEvents === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t?.dragEventThrottle !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), t?.allowManualDeselection !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
1791
+ if (super.updateOptions(t), this.cursors = t && t.cursors ? x({}, this.cursors, t.cursors) : de, t?.keyEvents === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t?.dragEventThrottle !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), t?.allowManualDeselection !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
1792
1792
  this.flags = x({}, this.flags, t.flags), this.validations = {};
1793
1793
  for (const e in this.flags) {
1794
1794
  const i = this.flags[e].feature;
@@ -1804,7 +1804,7 @@ class Gt extends qe {
1804
1804
  this._state = "selecting";
1805
1805
  }
1806
1806
  registerBehaviors(t) {
1807
- this.pixelDistance = new ct(t), this.clickBoundingBox = new dt(t), this.featuresAtMouseEvent = new bi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Oi(t), this.coordinatePoints = new we(t), this.midPoints = new xi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new Pt(t, this.pixelDistance, this.clickBoundingBox), this.lineSnap = new jt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Li(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Ei(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new wi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap, this.lineSnap), this.dragCoordinateResizeFeature = new Mi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new Fi(t, this.dragCoordinateResizeFeature);
1807
+ this.pixelDistance = new ct(t), this.clickBoundingBox = new dt(t), this.featuresAtMouseEvent = new bi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Oi(t), this.coordinatePoints = new we(t), this.midPoints = new xi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new St(t, this.pixelDistance, this.clickBoundingBox), this.lineSnap = new At(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Li(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Ei(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new wi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap, this.lineSnap), this.dragCoordinateResizeFeature = new Mi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new Fi(t, this.dragCoordinateResizeFeature);
1808
1808
  }
1809
1809
  deselectFeature() {
1810
1810
  this.deselect();
@@ -2040,7 +2040,7 @@ function ki(r, t) {
2040
2040
  function Ni(r, t) {
2041
2041
  return r.minY - t.minY;
2042
2042
  }
2043
- function Et(r) {
2043
+ function wt(r) {
2044
2044
  return (r.maxX - r.minX) * (r.maxY - r.minY);
2045
2045
  }
2046
2046
  function ft(r) {
@@ -2050,7 +2050,7 @@ function Ti(r, t) {
2050
2050
  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);
2051
2051
  return Math.max(0, o - e) * Math.max(0, s - i);
2052
2052
  }
2053
- function wt(r, t) {
2053
+ function Lt(r, t) {
2054
2054
  return r.minX <= t.minX && r.minY <= t.minY && t.maxX <= r.maxX && t.maxY <= r.maxY;
2055
2055
  }
2056
2056
  function mt(r, t) {
@@ -2059,7 +2059,7 @@ function mt(r, t) {
2059
2059
  function Z(r) {
2060
2060
  return { children: r, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
2061
2061
  }
2062
- function de(r, t, e, i, o) {
2062
+ function ce(r, t, e, i, o) {
2063
2063
  const s = [t, e];
2064
2064
  for (; s.length; ) {
2065
2065
  if ((e = s.pop()) - (t = s.pop()) <= i) continue;
@@ -2079,7 +2079,7 @@ class Wi {
2079
2079
  for (; e; ) {
2080
2080
  for (let n = 0; n < e.children.length; n++) {
2081
2081
  const a = e.children[n], l = e.leaf ? o(a) : a;
2082
- mt(t, l) && (e.leaf ? i.push(a) : wt(t, l) ? this._all(a, i) : s.push(a));
2082
+ mt(t, l) && (e.leaf ? i.push(a) : Lt(t, l) ? this._all(a, i) : s.push(a));
2083
2083
  }
2084
2084
  e = s.pop();
2085
2085
  }
@@ -2093,7 +2093,7 @@ class Wi {
2093
2093
  for (let o = 0; o < e.children.length; o++) {
2094
2094
  const s = e.children[o], n = e.leaf ? this.toBBox(s) : s;
2095
2095
  if (mt(t, n)) {
2096
- if (e.leaf || wt(t, n)) return !0;
2096
+ if (e.leaf || Lt(t, n)) return !0;
2097
2097
  i.push(s);
2098
2098
  }
2099
2099
  }
@@ -2133,7 +2133,7 @@ class Wi {
2133
2133
  const d = e.children.indexOf(t);
2134
2134
  d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
2135
2135
  }
2136
- l || e.leaf || !wt(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), s.push(n), n = 0, a = e, e = e.children[0]);
2136
+ l || e.leaf || !Lt(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), s.push(n), n = 0, a = e, e = e.children[0]);
2137
2137
  }
2138
2138
  }
2139
2139
  toBBox(t) {
@@ -2156,10 +2156,10 @@ class Wi {
2156
2156
  if (s <= a) return n = Z(t.slice(e, i + 1)), J(n, this.toBBox), n;
2157
2157
  o || (o = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, o - 1))), n = Z([]), n.leaf = !1, n.height = o;
2158
2158
  const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
2159
- de(t, e, i, d, this.compareMinX);
2159
+ ce(t, e, i, d, this.compareMinX);
2160
2160
  for (let c = e; c <= i; c += d) {
2161
2161
  const h = Math.min(c + d - 1, i);
2162
- de(t, c, h, l, this.compareMinY);
2162
+ ce(t, c, h, l, this.compareMinY);
2163
2163
  for (let u = c; u <= h; u += l) {
2164
2164
  const p = Math.min(u + l - 1, h);
2165
2165
  n.children.push(this._build(t, u, p, o - 1));
@@ -2171,7 +2171,7 @@ class Wi {
2171
2171
  for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
2172
2172
  let a, l = 1 / 0, d = 1 / 0;
2173
2173
  for (let c = 0; c < e.children.length; c++) {
2174
- const h = e.children[c], u = Et(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);
2174
+ const h = e.children[c], u = wt(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);
2175
2175
  p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
2176
2176
  }
2177
2177
  e = a || e.children[0];
@@ -2196,7 +2196,7 @@ class Wi {
2196
2196
  _chooseSplitIndex(t, e, i) {
2197
2197
  let o, s = 1 / 0, n = 1 / 0;
2198
2198
  for (let a = e; a <= i - e; a++) {
2199
- const l = nt(t, 0, a, this.toBBox), d = nt(t, a, i, this.toBBox), c = Ti(l, d), h = Et(l) + Et(d);
2199
+ const l = nt(t, 0, a, this.toBBox), d = nt(t, a, i, this.toBBox), c = Ti(l, d), h = wt(l) + wt(d);
2200
2200
  c < s ? (s = c, o = a, n = h < n ? h : n) : c === s && h < n && (n = h, o = a);
2201
2201
  }
2202
2202
  return o || i - e;
@@ -2301,23 +2301,27 @@ class Ai {
2301
2301
  if (t.length === 0) return [];
2302
2302
  let s = this.clone(t);
2303
2303
  const n = [], a = [];
2304
- return s = s.filter((l) => {
2305
- l.id == null && (l.id = this.idStrategy.getId());
2306
- const d = l.id;
2304
+ s = s.filter((d) => {
2305
+ d.id == null && (d.id = this.idStrategy.getId());
2306
+ const c = d.id;
2307
2307
  if (e) {
2308
- const c = e(l);
2309
- if (!c.valid) return a.push({ id: d, valid: !1, reason: c.reason }), !1;
2308
+ const h = e(d);
2309
+ if (!h.valid) return n.push({ id: c, valid: !1, reason: h.reason }), !1;
2310
2310
  }
2311
2311
  if (this.tracked) {
2312
- if (l.properties.createdAt) {
2313
- if (!qt(l.properties.createdAt)) return a.push({ id: l.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2314
- } else l.properties.createdAt = +/* @__PURE__ */ new Date();
2315
- if (l.properties.updatedAt) {
2316
- if (!qt(l.properties.updatedAt)) return a.push({ id: l.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2317
- } else l.properties.updatedAt = +/* @__PURE__ */ new Date();
2312
+ if (d.properties.createdAt) {
2313
+ if (!Zt(d.properties.createdAt)) return n.push({ id: d.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2314
+ } else d.properties.createdAt = +/* @__PURE__ */ new Date();
2315
+ if (d.properties.updatedAt) {
2316
+ if (!Zt(d.properties.updatedAt)) return n.push({ id: d.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2317
+ } else d.properties.updatedAt = +/* @__PURE__ */ new Date();
2318
2318
  }
2319
- return this.has(d) ? (a.push({ id: d, valid: !1, reason: `Feature already exists with this id: ${d}` }), !1) : (this.store[d] = l, n.push(d), i && i(l), a.push({ id: d, valid: !0 }), !0);
2320
- }), this.spatialIndex.load(s), n.length > 0 && this._onChange(n, "create", o), a;
2319
+ return this.has(c) ? (n.push({ id: c, valid: !1, reason: `Feature already exists with this id: ${c}` }), !1) : (this.store[c] = d, a.push(d), n.push({ id: c, valid: !0 }), !0);
2320
+ }), this.spatialIndex.load(s);
2321
+ const l = a.map(({ id: d }) => d);
2322
+ return l.length > 0 && (this._onChange(l, "create", o), i && a.forEach((d) => {
2323
+ i(d);
2324
+ })), n;
2321
2325
  }
2322
2326
  search(t, e) {
2323
2327
  const i = this.spatialIndex.search(t).map((o) => this.store[o]);
@@ -2386,8 +2390,8 @@ class Ai {
2386
2390
  return Object.keys(this.store).length;
2387
2391
  }
2388
2392
  }
2389
- const Ri = "Feature is not a Polygon or LineString", Gi = "Feature intersects itself", Ui = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: Ri } : Tt(r) ? { valid: !1, reason: Gi } : { valid: !0 };
2390
- function ce(r, t, e) {
2393
+ const Ri = "Feature is not a Polygon or LineString", Gi = "Feature intersects itself", Ui = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: Ri } : Wt(r) ? { valid: !1, reason: Gi } : { valid: !0 };
2394
+ function he(r, t, e) {
2391
2395
  const i = G(r, t);
2392
2396
  let o = G(t, e) - i;
2393
2397
  return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
@@ -2402,7 +2406,7 @@ class We extends A {
2402
2406
  }
2403
2407
  close() {
2404
2408
  if (this.currentId === void 0) return;
2405
- this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
2409
+ this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
2406
2410
  const t = this.currentId;
2407
2411
  this.currentCoordinate = 0, this.currentId = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
2408
2412
  }
@@ -2420,11 +2424,11 @@ class We extends A {
2420
2424
  const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
2421
2425
  i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
2422
2426
  } else if (this.currentCoordinate === 2) {
2423
- const o = e[0], s = e[1], n = De(o, s, this.coordinatePrecision, this.project, this.unproject), a = O(o[0], o[1]), l = O(n[0], n[1]), d = O(s[0], s[1]), c = O(t.lng, t.lat), h = F(c, a) < F(c, d), u = ce(a, l, c), p = h ? 90 - u : ce(a, l, c) - 90, g = F(l, c), y = Math.cos(D(p)) * g, m = G(a, d) + ((function(I, E, L) {
2427
+ const o = e[0], s = e[1], n = De(o, s, this.coordinatePrecision, this.project, this.unproject), a = O(o[0], o[1]), l = O(n[0], n[1]), d = O(s[0], s[1]), c = O(t.lng, t.lat), h = F(c, a) < F(c, d), u = he(a, l, c), p = h ? 90 - u : he(a, l, c) - 90, g = F(l, c), y = Math.cos(D(p)) * g, m = G(a, d) + ((function(I, E, L) {
2424
2428
  const M = (L.x - E.x) * (I.y - E.y) - (L.y - E.y) * (I.x - E.x);
2425
2429
  return M > 1e-10 ? "left" : M < -1e-10 ? "right" : "left";
2426
- })(a, d, c) === "right" ? -90 : 90), v = ht(a, y, m), C = ht(d, y, m), f = R(v.x, v.y), S = R(C.x, C.y);
2427
- i = [e[0], e[1], [S.lng, S.lat], [f.lng, f.lat], e[0]];
2430
+ })(a, d, c) === "right" ? -90 : 90), v = ht(a, y, m), C = ht(d, y, m), f = R(v.x, v.y), P = R(C.x, C.y);
2431
+ i = [e[0], e[1], [P.lng, P.lat], [f.lng, f.lat], e[0]];
2428
2432
  }
2429
2433
  i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
2430
2434
  }
@@ -2434,7 +2438,7 @@ class We extends A {
2434
2438
  }
2435
2439
  onClick(t) {
2436
2440
  if (t.button === "right" && this.allowPointerEvent(this.pointerEvents.rightClick, t) || t.button === "left" && this.allowPointerEvent(this.pointerEvents.leftClick, t) || t.isContextMenu && this.allowPointerEvent(this.pointerEvents.contextMenu, t)) if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.currentCoordinate === 0) {
2437
- 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, [P.CURRENTLY_DRAWING]: !0 } }]);
2441
+ 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, [S.CURRENTLY_DRAWING]: !0 } }]);
2438
2442
  this.currentId = e, this.currentCoordinate++, this.setDrawing();
2439
2443
  } else if (this.currentCoordinate === 1 && this.currentId) {
2440
2444
  const e = this.store.getGeometryCopy(this.currentId);
@@ -2489,7 +2493,7 @@ class je extends A {
2489
2493
  close() {
2490
2494
  if (this.currentId === void 0) return;
2491
2495
  const t = pt(this.store.getGeometryCopy(this.currentId));
2492
- t && this.store.updateGeometry([{ id: this.currentId, geometry: t }]), this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
2496
+ t && this.store.updateGeometry([{ id: this.currentId, geometry: t }]), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
2493
2497
  const e = this.currentId;
2494
2498
  this.currentCoordinate = 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
2495
2499
  }
@@ -2518,7 +2522,7 @@ class je extends A {
2518
2522
  const C = (this.direction === "anticlockwise" ? 1 : -1) * v / p;
2519
2523
  g.push(s);
2520
2524
  for (let f = 0; f <= p; f++) {
2521
- const S = ht(a, c, y + f * C), { lng: I, lat: E } = R(S.x, S.y), L = [w(I, this.coordinatePrecision), w(E, this.coordinatePrecision)];
2525
+ const P = ht(a, c, y + f * C), { lng: I, lat: E } = R(P.x, P.y), L = [w(I, this.coordinatePrecision), w(E, this.coordinatePrecision)];
2522
2526
  L[0] !== g[g.length - 1][0] && L[1] !== g[g.length - 1][1] && g.push(L);
2523
2527
  }
2524
2528
  g.push(o), i = [...g];
@@ -2531,7 +2535,7 @@ class je extends A {
2531
2535
  }
2532
2536
  onClick(t) {
2533
2537
  if (t.button === "right" && this.allowPointerEvent(this.pointerEvents.rightClick, t) || t.button === "left" && this.allowPointerEvent(this.pointerEvents.leftClick, t) || t.isContextMenu && this.allowPointerEvent(this.pointerEvents.contextMenu, t)) if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.currentCoordinate === 0) {
2534
- 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, [P.CURRENTLY_DRAWING]: !0 } }]);
2538
+ 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, [S.CURRENTLY_DRAWING]: !0 } }]);
2535
2539
  this.currentId = e, this.currentCoordinate++, this.setDrawing();
2536
2540
  } else if (this.currentCoordinate === 1 && this.currentId) {
2537
2541
  const e = this.store.getGeometryCopy(this.currentId);
@@ -2581,7 +2585,7 @@ class Ae extends A {
2581
2585
  const t = this.currentStartingPointId, e = this.currentInitialArcId, i = this.currentId;
2582
2586
  if (t && this.store.delete([t]), e && this.store.delete([e]), this.currentId) {
2583
2587
  const o = pt(this.store.getGeometryCopy(this.currentId));
2584
- o && this.store.updateGeometry([{ id: this.currentId, geometry: o }]), this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
2588
+ o && this.store.updateGeometry([{ id: this.currentId, geometry: o }]), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
2585
2589
  }
2586
2590
  this.currentCoordinate = 0, this.currentStartingPointId = void 0, this.currentInitialArcId = void 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), i && this.onFinish(i, { mode: this.mode, action: "draw" });
2587
2591
  }
@@ -2604,7 +2608,7 @@ class Ae extends A {
2604
2608
  this.direction === "anticlockwise" ? (m = y - g, m < 0 && (m += 360)) : (m = g - y, m < 0 && (m += 360));
2605
2609
  const v = (this.direction === "anticlockwise" ? 1 : -1) * m / u;
2606
2610
  for (let C = 0; C <= u; C++) {
2607
- const f = ht(l, d, g + C * v), { lng: S, lat: I } = R(f.x, f.y), E = [w(S, this.coordinatePrecision), w(I, this.coordinatePrecision)];
2611
+ const f = ht(l, d, g + C * v), { lng: P, lat: I } = R(f.x, f.y), E = [w(P, this.coordinatePrecision), w(I, this.coordinatePrecision)];
2608
2612
  E[0] !== p[p.length - 1][0] && E[1] !== p[p.length - 1][1] && p.push(E);
2609
2613
  }
2610
2614
  this.updateLineStringGeometry(this.currentInitialArcId, p, b.Provisional);
@@ -2613,12 +2617,12 @@ class Ae extends A {
2613
2617
  if (e.length < 2 || !this.direction) return;
2614
2618
  const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = O(t.lng, t.lat), a = O(o[0], o[1]), l = O(s[0], s[1]), d = O(i[0], i[1]), c = F(d, a), h = F(d, n) < c ? a : n, u = G(d, n), p = G(d, a), g = G(d, l), y = X(p), m = X(g), v = X(u);
2615
2619
  if (this.notInSector({ normalizedCursor: v, normalizedStart: y, normalizedEnd: m, direction: this.direction })) return;
2616
- const C = this.getDeltaBearing(this.direction, y, m), f = this.arcPoints, S = (this.direction === "anticlockwise" ? 1 : -1) * C / f, I = F(d, h), E = [];
2620
+ const C = this.getDeltaBearing(this.direction, y, m), f = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * C / f, I = F(d, h), E = [];
2617
2621
  for (let L = 0; L <= f; L++) {
2618
- const M = ht(d, I, y + L * S), { lng: N, lat: _ } = R(M.x, M.y), T = [w(N, this.coordinatePrecision), w(_, this.coordinatePrecision)];
2622
+ const M = ht(d, I, y + L * P), { lng: N, lat: _ } = R(M.x, M.y), T = [w(N, this.coordinatePrecision), w(_, this.coordinatePrecision)];
2619
2623
  T[0] !== e[e.length - 1][0] && T[1] !== e[e.length - 1][1] && E.unshift(T);
2620
2624
  }
2621
- e.push(...E), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, b.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode, [P.CURRENTLY_DRAWING]: !0 } }]);
2625
+ e.push(...E), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, b.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode, [S.CURRENTLY_DRAWING]: !0 } }]);
2622
2626
  }
2623
2627
  }
2624
2628
  }
@@ -2784,7 +2788,7 @@ class Re extends A {
2784
2788
  }
2785
2789
  close() {
2786
2790
  if (this.currentId === void 0) return;
2787
- this.currentId && this.store.updateProperty([{ id: this.currentId, property: P.CURRENTLY_DRAWING, value: void 0 }]);
2791
+ this.currentId && this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
2788
2792
  const t = this.currentId;
2789
2793
  if (this.validate && t) {
2790
2794
  const e = this.store.getGeometryCopy(t);
@@ -2809,7 +2813,7 @@ class Re extends A {
2809
2813
  if (t.button === "right" && this.allowPointerEvent(this.pointerEvents.rightClick, t) || t.button === "left" && this.allowPointerEvent(this.pointerEvents.leftClick, t) || t.isContextMenu && this.allowPointerEvent(this.pointerEvents.contextMenu, t)) {
2810
2814
  if (this.preventNewFeature) return;
2811
2815
  if (this.startingClick === !1) {
2812
- const [e, i] = this.store.create([{ geometry: { type: "LineString", coordinates: [[t.lng, t.lat], [t.lng, t.lat]] }, properties: { mode: this.mode, [P.CURRENTLY_DRAWING]: !0 } }, { geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: { mode: this.mode, [P.CLOSING_POINT]: !0 } }]);
2816
+ const [e, i] = this.store.create([{ geometry: { type: "LineString", coordinates: [[t.lng, t.lat], [t.lng, t.lat]] }, properties: { mode: this.mode, [S.CURRENTLY_DRAWING]: !0 } }, { geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: { mode: this.mode, [S.CLOSING_POINT]: !0 } }]);
2813
2817
  return this.currentId = e, this.closingPointId = i, this.startingClick = !0, void (this.state !== "drawing" && this.setDrawing());
2814
2818
  }
2815
2819
  this.close();
@@ -2839,13 +2843,13 @@ class Re extends A {
2839
2843
  return t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex = j, 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 = 50), e);
2840
2844
  }
2841
2845
  validateFeature(t) {
2842
- return this.validateModeFeature(t, (e) => Bt(e, this.coordinatePrecision));
2846
+ return this.validateModeFeature(t, (e) => jt(e, this.coordinatePrecision));
2843
2847
  }
2844
2848
  afterFeatureUpdated(t) {
2845
2849
  this.currentId === t.id && (this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0);
2846
2850
  }
2847
2851
  }
2848
- function kt(r) {
2852
+ function Nt(r) {
2849
2853
  if (r === null || typeof r == "boolean" || typeof r == "string") return !0;
2850
2854
  if (r === void 0) return !1;
2851
2855
  if (typeof r == "number") return Number.isFinite(r);
@@ -2856,9 +2860,9 @@ function kt(r) {
2856
2860
  }
2857
2861
  if (ArrayBuffer.isView(r) && !(r instanceof DataView)) return !1;
2858
2862
  if (Array.isArray(r)) {
2859
- for (const t of r) if (!kt(t)) return !1;
2863
+ for (const t of r) if (!Nt(t)) return !1;
2860
2864
  }
2861
- return typeof r == "object" && Object.keys(r).every((t) => typeof t == "string" && kt(r[t]));
2865
+ return typeof r == "object" && Object.keys(r).every((t) => typeof t == "string" && Nt(r[t]));
2862
2866
  }
2863
2867
  class Zi {
2864
2868
  constructor(t) {
@@ -2919,7 +2923,7 @@ class Zi {
2919
2923
  featuresAtLocation({ lng: t, lat: e }, i) {
2920
2924
  const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = !(!i || i.ignoreCoordinatePoints === void 0) && i.ignoreCoordinatePoints, a = !(!i || i.ignoreCurrentlyDrawing === void 0) && i.ignoreCurrentlyDrawing, l = !(!i || i.ignoreClosingPoints === void 0) && i.ignoreClosingPoints, d = this._adapter.unproject.bind(this._adapter), c = this._adapter.project.bind(this._adapter), h = c(t, e), u = be({ unproject: d, point: h, pointerDistance: o });
2921
2925
  return this._store.search(u).filter((p) => {
2922
- if (s && (p.properties[k.MID_POINT] || p.properties[k.SELECTION_POINT]) || n && p.properties[P.COORDINATE_POINT] || l && p.properties[P.CLOSING_POINT] || a && p.properties[P.CURRENTLY_DRAWING]) return !1;
2926
+ if (s && (p.properties[k.MID_POINT] || p.properties[k.SELECTION_POINT]) || n && p.properties[S.COORDINATE_POINT] || l && p.properties[S.CLOSING_POINT] || a && p.properties[S.CURRENTLY_DRAWING]) return !1;
2923
2927
  if (p.geometry.type === "Point") {
2924
2928
  const g = p.geometry.coordinates, y = c(g[0], g[1]);
2925
2929
  return F(h, y) < o;
@@ -2928,7 +2932,7 @@ class Zi {
2928
2932
  const g = p.geometry.coordinates;
2929
2933
  for (let y = 0; y < g.length - 1; y++) {
2930
2934
  const m = g[y], v = g[y + 1];
2931
- if (Dt(h, c(m[0], m[1]), c(v[0], v[1])) < o) return !0;
2935
+ if (_t(h, c(m[0], m[1]), c(v[0], v[1])) < o) return !0;
2932
2936
  }
2933
2937
  return !1;
2934
2938
  }
@@ -2936,11 +2940,25 @@ class Zi {
2936
2940
  if (i != null && i.includePolygonsWithinPointerDistance) {
2937
2941
  const g = p.geometry.coordinates;
2938
2942
  for (const y of g) for (let m = 0; m < y.length - 1; m++) {
2939
- const v = y[m], C = y[m + 1], f = c(v[0], v[1]), S = c(C[0], C[1]);
2940
- if (Dt(h, f, S) < o) return !0;
2943
+ const v = y[m], C = y[m + 1], f = c(v[0], v[1]), P = c(C[0], C[1]);
2944
+ if (_t(h, f, P) < o) return !0;
2941
2945
  }
2942
2946
  }
2943
2947
  return !1;
2948
+ }).map((p) => {
2949
+ if (i == null || !i.addClosestCoordinateInfoToProperties) return p;
2950
+ let g;
2951
+ if (p.geometry.type === "Polygon") g = p.geometry.coordinates[0], g.pop();
2952
+ else {
2953
+ if (p.geometry.type !== "LineString") return p;
2954
+ g = p.geometry.coordinates;
2955
+ }
2956
+ let y, m = -1, v = 1 / 0;
2957
+ for (let C = 0; C < g.length; C++) {
2958
+ const f = g[C], P = F(c(f[0], f[1]), h);
2959
+ P < v && (m = C, v = P, y = f);
2960
+ }
2961
+ return p.properties.closestCoordinateIndexToEvent = m, p.properties.closestCoordinatePixelDistanceToEvent = v, p.properties.closestCoordinateDistanceKmToEvent = U(y, [t, e]), p;
2944
2962
  });
2945
2963
  }
2946
2964
  getSelectModeOrThrow() {
@@ -2954,7 +2972,7 @@ class Zi {
2954
2972
  return t && e !== this._instanceSelectMode && this.setMode(this._instanceSelectMode), this._modes[this._instanceSelectMode];
2955
2973
  }
2956
2974
  isGuidanceFeature(t) {
2957
- return !!(t.properties[k.MID_POINT] || t.properties[k.SELECTION_POINT] || t.properties[P.COORDINATE_POINT] || t.properties[P.SNAPPING_POINT]);
2975
+ return !!(t.properties[k.MID_POINT] || t.properties[k.SELECTION_POINT] || t.properties[S.COORDINATE_POINT] || t.properties[S.SNAPPING_POINT]);
2958
2976
  }
2959
2977
  setModeStyles(t, e) {
2960
2978
  if (this.checkEnabled(), !this._modes[t]) throw new Error("No mode with this name present");
@@ -2995,7 +3013,7 @@ class Zi {
2995
3013
  t.forEach((i) => {
2996
3014
  if (!this._store.has(i)) throw new Error(`No feature with id ${i}, can not delete`);
2997
3015
  const o = this._store.copy(i);
2998
- o.properties[k.SELECTED] && this.deselectFeature(i), o.properties[P.COORDINATE_POINT_IDS] && e.push(...o.properties[P.COORDINATE_POINT_IDS]);
3016
+ o.properties[k.SELECTED] && this.deselectFeature(i), o.properties[S.COORDINATE_POINT_IDS] && e.push(...o.properties[S.COORDINATE_POINT_IDS]);
2999
3017
  }), this._store.delete([...t, ...e], { origin: "api" });
3000
3018
  }
3001
3019
  selectFeature(t) {
@@ -3011,7 +3029,7 @@ class Zi {
3011
3029
  return this._store.has(t);
3012
3030
  }
3013
3031
  checkIsReservedProperty(t) {
3014
- return ![...Object.values(k), ...Object.values(P)].includes(t);
3032
+ return ![...Object.values(k), ...Object.values(S)].includes(t);
3015
3033
  }
3016
3034
  updateFeatureProperties(t, e) {
3017
3035
  if (!this._store.has(t)) throw new Error(`No feature with id ${t} present in store`);
@@ -3022,7 +3040,7 @@ class Zi {
3022
3040
  const s = Object.entries(e);
3023
3041
  s.forEach(([n, a]) => {
3024
3042
  if (!this.checkIsReservedProperty(n)) throw new Error(`You are trying to update a reserved property name: ${n}. Please choose another name.`);
3025
- if (a !== void 0 && !kt(a)) throw new Error(`Invalid JSON value provided for property ${n}`);
3043
+ if (a !== void 0 && !Nt(a)) throw new Error(`Invalid JSON value provided for property ${n}`);
3026
3044
  }), this._store.updateProperty(s.map(([n, a]) => ({ id: i.id, property: n, value: a })), { origin: "api" });
3027
3045
  }
3028
3046
  updateFeatureGeometry(t, e) {
@@ -3066,7 +3084,7 @@ class Zi {
3066
3084
  }
3067
3085
  addFeatures(t) {
3068
3086
  return this.checkEnabled(), t.length === 0 ? [] : this._store.load(t, (e) => {
3069
- if (Jt(e)) {
3087
+ if (qt(e)) {
3070
3088
  const i = e.properties.mode, o = this._modes[i];
3071
3089
  if (!o) return { id: e.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
3072
3090
  const s = o.validateFeature.bind(o)(e);
@@ -3074,7 +3092,7 @@ class Zi {
3074
3092
  }
3075
3093
  return { id: e.id, valid: !1, reason: "Mode property does not exist" };
3076
3094
  }, (e) => {
3077
- if (Jt(e)) {
3095
+ if (qt(e)) {
3078
3096
  const i = this._modes[e.properties.mode];
3079
3097
  i && i.afterFeatureAdded && i.afterFeatureAdded(e);
3080
3098
  }
@@ -3276,7 +3294,7 @@ const zo = [
3276
3294
  open: !1,
3277
3295
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
3278
3296
  modeOptions: {
3279
- point: new Rt({
3297
+ point: new Gt({
3280
3298
  editable: !0,
3281
3299
  styles: {
3282
3300
  pointColor: "#FFFFFF",
@@ -3285,7 +3303,7 @@ const zo = [
3285
3303
  pointOutlineWidth: 1
3286
3304
  }
3287
3305
  }),
3288
- linestring: new At({
3306
+ linestring: new Rt({
3289
3307
  editable: !0,
3290
3308
  styles: {
3291
3309
  lineStringColor: "#666666",
@@ -3375,7 +3393,7 @@ const zo = [
3375
3393
  outlineWidth: 2
3376
3394
  }
3377
3395
  }),
3378
- select: new Gt({
3396
+ select: new Ut({
3379
3397
  flags: {
3380
3398
  point: {
3381
3399
  feature: {
@@ -3639,6 +3657,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3639
3657
  },
3640
3658
  distanceUnit: "kilometers",
3641
3659
  distancePrecision: 2,
3660
+ forceDistanceUnit: "auto",
3642
3661
  areaUnit: "metric",
3643
3662
  areaPrecision: 2,
3644
3663
  forceAreaUnit: "auto",
@@ -3667,7 +3686,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3667
3686
  open: !1,
3668
3687
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
3669
3688
  modeOptions: {
3670
- point: new Rt({
3689
+ point: new Gt({
3671
3690
  editable: !1,
3672
3691
  styles: {
3673
3692
  pointColor: "#FFFFFF",
@@ -3676,7 +3695,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3676
3695
  pointOutlineWidth: 1
3677
3696
  }
3678
3697
  }),
3679
- linestring: new At({
3698
+ linestring: new Rt({
3680
3699
  editable: !1,
3681
3700
  styles: {
3682
3701
  lineStringColor: "#FF0000",
@@ -3687,7 +3706,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3687
3706
  closingPointOutlineWidth: 1
3688
3707
  }
3689
3708
  }),
3690
- select: new Gt({
3709
+ select: new Ut({
3691
3710
  flags: {
3692
3711
  point: {
3693
3712
  feature: {
@@ -3887,10 +3906,10 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3887
3906
  modeName: "render",
3888
3907
  styles: {}
3889
3908
  }),
3890
- point: new Rt({
3909
+ point: new Gt({
3891
3910
  editable: !0
3892
3911
  }),
3893
- linestring: new At({
3912
+ linestring: new Rt({
3894
3913
  editable: !0
3895
3914
  }),
3896
3915
  polygon: new Le({
@@ -3909,7 +3928,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3909
3928
  "freehand-linestring": new Re(),
3910
3929
  sensor: new Ae(),
3911
3930
  sector: new je(),
3912
- select: new Gt({
3931
+ select: new Ut({
3913
3932
  flags: {
3914
3933
  point: {
3915
3934
  feature: {
@@ -4063,7 +4082,7 @@ function so(r, t, e = {}) {
4063
4082
  throw new Error("coordinates must be an Array");
4064
4083
  if (r.length < 2)
4065
4084
  throw new Error("coordinates must be at least 2 numbers long");
4066
- if (!he(r[0]) || !he(r[1]))
4085
+ if (!ue(r[0]) || !ue(r[1]))
4067
4086
  throw new Error("coordinates must contain numbers");
4068
4087
  return oo({
4069
4088
  type: "Point",
@@ -4079,7 +4098,7 @@ function ro(r, t = "kilometers") {
4079
4098
  function vt(r) {
4080
4099
  return r % 360 * Math.PI / 180;
4081
4100
  }
4082
- function he(r) {
4101
+ function ue(r) {
4083
4102
  return !isNaN(r) && r !== null && !Array.isArray(r);
4084
4103
  }
4085
4104
  function Ge(r, t, e) {
@@ -4087,7 +4106,7 @@ function Ge(r, t, e) {
4087
4106
  for (var i, o, s, n, a, l, d, c = 0, h = 0, u, p = r.type, g = p === "FeatureCollection", y = p === "Feature", m = g ? r.features.length : 1, v = 0; v < m; v++) {
4088
4107
  d = g ? r.features[v].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
4089
4108
  for (var C = 0; C < a; C++) {
4090
- var f = 0, S = 0;
4109
+ var f = 0, P = 0;
4091
4110
  if (n = u ? d.geometries[C] : d, n !== null) {
4092
4111
  l = n.coordinates;
4093
4112
  var I = n.type;
@@ -4100,7 +4119,7 @@ function Ge(r, t, e) {
4100
4119
  h,
4101
4120
  v,
4102
4121
  f,
4103
- S
4122
+ P
4104
4123
  ) === !1)
4105
4124
  return !1;
4106
4125
  h++, f++;
@@ -4113,7 +4132,7 @@ function Ge(r, t, e) {
4113
4132
  h,
4114
4133
  v,
4115
4134
  f,
4116
- S
4135
+ P
4117
4136
  ) === !1)
4118
4137
  return !1;
4119
4138
  h++, I === "MultiPoint" && f++;
@@ -4129,30 +4148,30 @@ function Ge(r, t, e) {
4129
4148
  h,
4130
4149
  v,
4131
4150
  f,
4132
- S
4151
+ P
4133
4152
  ) === !1)
4134
4153
  return !1;
4135
4154
  h++;
4136
4155
  }
4137
- I === "MultiLineString" && f++, I === "Polygon" && S++;
4156
+ I === "MultiLineString" && f++, I === "Polygon" && P++;
4138
4157
  }
4139
4158
  I === "Polygon" && f++;
4140
4159
  break;
4141
4160
  case "MultiPolygon":
4142
4161
  for (i = 0; i < l.length; i++) {
4143
- for (S = 0, o = 0; o < l[i].length; o++) {
4162
+ for (P = 0, o = 0; o < l[i].length; o++) {
4144
4163
  for (s = 0; s < l[i][o].length - c; s++) {
4145
4164
  if (t(
4146
4165
  l[i][o][s],
4147
4166
  h,
4148
4167
  v,
4149
4168
  f,
4150
- S
4169
+ P
4151
4170
  ) === !1)
4152
4171
  return !1;
4153
4172
  h++;
4154
4173
  }
4155
- S++;
4174
+ P++;
4156
4175
  }
4157
4176
  f++;
4158
4177
  }
@@ -4247,10 +4266,10 @@ function co(r) {
4247
4266
  let t = 0, e;
4248
4267
  switch (r.type) {
4249
4268
  case "Polygon":
4250
- return ue(r.coordinates);
4269
+ return pe(r.coordinates);
4251
4270
  case "MultiPolygon":
4252
4271
  for (e = 0; e < r.coordinates.length; e++)
4253
- t += ue(r.coordinates[e]);
4272
+ t += pe(r.coordinates[e]);
4254
4273
  return t;
4255
4274
  case "Point":
4256
4275
  case "MultiPoint":
@@ -4260,22 +4279,22 @@ function co(r) {
4260
4279
  }
4261
4280
  return 0;
4262
4281
  }
4263
- function ue(r) {
4282
+ function pe(r) {
4264
4283
  let t = 0;
4265
4284
  if (r && r.length > 0) {
4266
- t += Math.abs(pe(r[0]));
4285
+ t += Math.abs(ge(r[0]));
4267
4286
  for (let e = 1; e < r.length; e++)
4268
- t -= Math.abs(pe(r[e]));
4287
+ t -= Math.abs(ge(r[e]));
4269
4288
  }
4270
4289
  return t;
4271
4290
  }
4272
- var ho = W * W / 2, Lt = Math.PI / 180;
4273
- function pe(r) {
4291
+ var ho = W * W / 2, Ft = Math.PI / 180;
4292
+ function ge(r) {
4274
4293
  const t = r.length - 1;
4275
4294
  if (t <= 2) return 0;
4276
4295
  let e = 0, i = 0;
4277
4296
  for (; i < t; ) {
4278
- 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] * Lt, l = s[1] * Lt, d = n[0] * Lt;
4297
+ 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] * Ft, l = s[1] * Ft, d = n[0] * Ft;
4279
4298
  e += (d - a) * Math.sin(l), i++;
4280
4299
  }
4281
4300
  return e * ho;
@@ -4329,12 +4348,12 @@ const po = (r, t, e = "auto") => {
4329
4348
  area: e,
4330
4349
  unit: i
4331
4350
  };
4332
- }, ge = (r, t, e, i) => {
4351
+ }, ye = (r, t, e, i) => {
4333
4352
  if (r.geometry.type !== "Polygon") return r;
4334
4353
  const o = uo(r.geometry), s = po(o, t, i);
4335
4354
  return s.area = parseFloat(s.area.toFixed(e)), r.properties.area = s.area, r.properties.unit = s.unit, r;
4336
4355
  };
4337
- function ye(r) {
4356
+ function fe(r) {
4338
4357
  if (!r)
4339
4358
  throw new Error("coord is required");
4340
4359
  if (!Array.isArray(r)) {
@@ -4348,63 +4367,94 @@ function ye(r) {
4348
4367
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
4349
4368
  }
4350
4369
  function go(r, t, e = {}) {
4351
- var i = ye(r), o = ye(t), s = vt(o[1] - i[1]), n = vt(o[0] - i[0]), a = vt(i[1]), l = vt(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
4370
+ var i = fe(r), o = fe(t), s = vt(o[1] - i[1]), n = vt(o[0] - i[0]), a = vt(i[1]), l = vt(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
4352
4371
  return ro(
4353
4372
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
4354
4373
  e.units
4355
4374
  );
4356
4375
  }
4357
4376
  var yo = go;
4358
- const fe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians" ? "rad" : "km", Ft = (r) => {
4359
- if (r >= 1)
4360
- return {
4361
- distance: r,
4362
- unit: "km"
4363
- };
4364
- const t = r * 1e3;
4365
- return t >= 1 ? {
4366
- distance: t,
4367
- unit: "m"
4368
- } : {
4369
- distance: t * 100,
4370
- unit: "cm"
4377
+ const Mt = (r, t = "kilometers", e = "auto") => {
4378
+ const i = ["cm", "m", "km"];
4379
+ let o = e;
4380
+ if (e !== "auto") {
4381
+ const n = i.includes(e);
4382
+ t === "kilometers" && !n && (o = "auto");
4383
+ }
4384
+ let s = {
4385
+ distance: r,
4386
+ unit: "km"
4371
4387
  };
4372
- }, me = (r, t, e, i, o, s) => {
4373
- if (r.geometry.type !== "LineString") return r;
4374
- const n = r.geometry.coordinates;
4375
- let a = 0;
4376
- const l = [];
4377
- for (let d = 0; d < n.length - 1; d++) {
4378
- const c = n[d], h = n[d + 1], u = yo(c, h, { units: t });
4379
- a += u;
4380
- const p = JSON.parse(JSON.stringify(r));
4381
- if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [c, h], p.properties.originalId = r.id, p.properties.distance = u, p.properties.total = a, p.properties.unit = fe(t), p.properties.totalUnit = fe(t), o === !0 && s === void 0) {
4382
- const g = i?.queryTerrainElevation(c);
4383
- g && (p.properties.elevation_start = g);
4384
- const y = i?.queryTerrainElevation(h);
4385
- y && (p.properties.elevation_end = y);
4386
- }
4387
- l.push(p);
4388
- }
4389
- if (r.properties.distance = l[l.length - 1].properties.total, r.properties.unit = l[l.length - 1].properties.unit, r.properties.segments = JSON.parse(JSON.stringify(l)), t === "kilometers") {
4390
- const d = Ft(r.properties.distance);
4391
- r.properties.distance = d.distance, r.properties.unit = d.unit, r.properties.segments.forEach(
4392
- (c) => {
4393
- const h = Ft(c.properties.distance);
4394
- c.properties.distance = h.distance, c.properties.unit = h.unit;
4395
- const u = Ft(c.properties.total);
4396
- c.properties.total = u.distance, c.properties.totalUnit = u.unit;
4397
- }
4398
- );
4388
+ return t === "kilometers" ? s = Ct(r, o) : t === "degrees" ? s.unit = "°" : t === "miles" ? s.unit = "mi" : t === "radians" && (s.unit = "rad"), s;
4389
+ }, Ct = (r, t) => {
4390
+ let e = {
4391
+ distance: r,
4392
+ unit: "km"
4393
+ };
4394
+ switch (t) {
4395
+ case "km":
4396
+ e.distance = r, e.unit = "km";
4397
+ break;
4398
+ case "m":
4399
+ e.distance = r * 1e3, e.unit = "m";
4400
+ break;
4401
+ case "cm":
4402
+ e.distance = r * 1e5, e.unit = "cm";
4403
+ break;
4404
+ case "auto":
4405
+ r >= 1 ? e = Ct(r, "km") : r * 1e3 >= 1 ? e = Ct(r, "m") : e = Ct(r, "cm");
4406
+ break;
4407
+ default:
4408
+ e.distance = r, e.unit = "km";
4409
+ break;
4399
4410
  }
4400
- return r.properties.distance = parseFloat(
4411
+ return e;
4412
+ }, me = (r, t, e, i, o, s, n) => {
4413
+ if (r.geometry.type !== "LineString") return r;
4414
+ const a = r.geometry.coordinates;
4415
+ let l = 0;
4416
+ const d = [];
4417
+ for (let h = 0; h < a.length - 1; h++) {
4418
+ const u = a[h], p = a[h + 1], g = yo(u, p, { units: t });
4419
+ l += g;
4420
+ const y = JSON.parse(JSON.stringify(r));
4421
+ if (y.id = `${y.id}-${h}`, y.geometry.coordinates = [u, p], y.properties.originalId = r.id, y.properties.distance = g, y.properties.total = l, s === !0 && n === void 0) {
4422
+ const m = o?.queryTerrainElevation(u);
4423
+ m && (y.properties.elevation_start = m);
4424
+ const v = o?.queryTerrainElevation(p);
4425
+ v && (y.properties.elevation_end = v);
4426
+ }
4427
+ d.push(y);
4428
+ }
4429
+ r.properties.distance = d[d.length - 1].properties.total, r.properties.segments = JSON.parse(JSON.stringify(d));
4430
+ const c = Mt(
4431
+ r.properties.distance,
4432
+ t,
4433
+ i
4434
+ );
4435
+ return r.properties.distance = c.distance, r.properties.unit = c.unit, r.properties.segments.forEach(
4436
+ (h) => {
4437
+ const u = Mt(
4438
+ h.properties.distance,
4439
+ t,
4440
+ i
4441
+ );
4442
+ h.properties.distance = u.distance, h.properties.unit = u.unit;
4443
+ const p = Mt(
4444
+ h.properties.total,
4445
+ t,
4446
+ i
4447
+ );
4448
+ h.properties.total = p.distance, h.properties.totalUnit = p.unit;
4449
+ }
4450
+ ), r.properties.distance = parseFloat(
4401
4451
  r.properties.distance.toFixed(e)
4402
4452
  ), r.properties.segments.forEach(
4403
- (d) => {
4404
- d.properties.distance = parseFloat(
4405
- d.properties.distance.toFixed(e)
4406
- ), d.properties.total = parseFloat(
4407
- d.properties.total.toFixed(e)
4453
+ (h) => {
4454
+ h.properties.distance = parseFloat(
4455
+ h.properties.distance.toFixed(e)
4456
+ ), h.properties.total = parseFloat(
4457
+ h.properties.total.toFixed(e)
4408
4458
  );
4409
4459
  }
4410
4460
  ), r;
@@ -4426,7 +4476,7 @@ const fe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians
4426
4476
  z.isochronePolygonLayerSpec?.source,
4427
4477
  z.isochroneLineLayerSpec?.source,
4428
4478
  z.isochroneLabelLayerSpec?.source
4429
- ], Ut = (r, t, e = et, i = "td") => {
4479
+ ], zt = (r, t, e = et, i = "td") => {
4430
4480
  e = e.map((s) => s.replace("{prefix}", i));
4431
4481
  const o = JSON.parse(JSON.stringify(r));
4432
4482
  return t && (t.onlyTerraDrawLayers === !0 ? (o.layers = o.layers.filter((s) => "source" in s && e.includes(s.source)), Object.keys(o.sources).forEach((s) => {
@@ -4616,26 +4666,26 @@ const Ce = (r, t, e, i) => {
4616
4666
  }
4617
4667
  return r;
4618
4668
  };
4619
- var mo = Object.defineProperty, vo = (r, t, e) => t in r ? mo(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, rt = (r, t, e) => vo(r, typeof t != "symbol" ? t + "" : t, e), St = 2 * Math.PI * 6378137 / 2;
4669
+ var mo = Object.defineProperty, vo = (r, t, e) => t in r ? mo(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, rt = (r, t, e) => vo(r, typeof t != "symbol" ? t + "" : t, e), It = 2 * Math.PI * 6378137 / 2;
4620
4670
  function Co(r) {
4621
4671
  return r = r || 256, 2 * Math.PI * 6378137 / r;
4622
4672
  }
4623
4673
  function Po(r, t, e = { enable: !0, decimal: 1 }) {
4624
- r = zt(r);
4625
- var i = r[0], o = r[1], s = i * St / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
4626
- return n = n * St / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
4674
+ r = Vt(r);
4675
+ var i = r[0], o = r[1], s = i * It / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
4676
+ return n = n * It / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
4627
4677
  }
4628
4678
  function So(r, t, e) {
4629
- var i = r[0], o = r[1], s = wo(t, e), n = (i + St) / s, a = (o + St) / s;
4679
+ var i = r[0], o = r[1], s = wo(t, e), n = (i + It) / s, a = (o + It) / s;
4630
4680
  return [n, a, t];
4631
4681
  }
4632
4682
  function Ve(r, t, e) {
4633
- r = zt(r);
4683
+ r = Vt(r);
4634
4684
  var i = Po(r), o = So(i, t);
4635
4685
  return xo(o);
4636
4686
  }
4637
4687
  function Io(r, t, e) {
4638
- if (r = zt(r), t === 0)
4688
+ if (r = Vt(r), t === 0)
4639
4689
  return [0, 0, 0];
4640
4690
  var i = Ve(r, t);
4641
4691
  return Oo(i);
@@ -4677,7 +4727,7 @@ function $e(r) {
4677
4727
  throw new Error("<zoom> cannot be greater than 32");
4678
4728
  return r;
4679
4729
  }
4680
- function zt(r, t) {
4730
+ function Vt(r, t) {
4681
4731
  var e = Fo(r[0]), i = Lo(r[1]);
4682
4732
  return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
4683
4733
  }
@@ -4996,7 +5046,7 @@ class No {
4996
5046
  return await (await fetch(l)).json();
4997
5047
  }
4998
5048
  }
4999
- const Nt = [
5049
+ const Tt = [
5000
5050
  { value: "pedestrian", label: "Pedestrian" },
5001
5051
  { value: "bicycle", label: "Bicycle" },
5002
5052
  { value: "auto", label: "Car" }
@@ -5071,10 +5121,10 @@ class Wo {
5071
5121
  const h = [];
5072
5122
  let u = 0, p = 0;
5073
5123
  const g = [], y = this.geoPoint(this.tripData.map((f) => [f.lng, f.lat]));
5074
- l.trip.legs.forEach((f, S) => {
5124
+ l.trip.legs.forEach((f, P) => {
5075
5125
  const I = this.decodeShape(f.shape);
5076
5126
  h.push(...I), u += Number(f.summary.length.toFixed(2)), p += Number((f.summary.time / 60).toFixed()), g.push(...f.maneuvers);
5077
- const E = y.features[S + 1];
5127
+ const E = y.features[P + 1];
5078
5128
  E.properties = {
5079
5129
  ...E.properties,
5080
5130
  distance: u,
@@ -5083,7 +5133,7 @@ class Wo {
5083
5133
  maneuvers: f.maneuvers
5084
5134
  };
5085
5135
  });
5086
- const m = Nt.find((f) => f.value === e)?.label, v = this.geoLineString(h, {
5136
+ const m = Tt.find((f) => f.value === e)?.label, v = this.geoLineString(h, {
5087
5137
  costingModel: m,
5088
5138
  distance: u,
5089
5139
  distance_unit: i === "kilometers" ? "km" : "mi",
@@ -5394,7 +5444,7 @@ class Ke {
5394
5444
  * @returns
5395
5445
  */
5396
5446
  cleanStyle(t, e) {
5397
- return Ut(
5447
+ return zt(
5398
5448
  t,
5399
5449
  e,
5400
5450
  et,
@@ -5482,18 +5532,31 @@ class Xo extends Ke {
5482
5532
  }
5483
5533
  set distanceUnit(t) {
5484
5534
  const e = this.measureOptions.distanceUnit === t;
5485
- this.measureOptions.distanceUnit = t, this.measureOptions.distanceUnit === "degrees" ? this.distancePrecision = 6 : this.distancePrecision = 2, e || this.recalc();
5535
+ this.measureOptions.distanceUnit = t, e || this.recalc();
5486
5536
  }
5487
5537
  /**
5488
- * The precision of distance value. It will be set different value dwhen distance unit is changed. Using setter to override the value if you want.
5538
+ * The precision of distance value. It will be set different value when distance unit is changed. Using setter to override the value if you want.
5489
5539
  */
5490
5540
  get distancePrecision() {
5491
- return this.measureOptions.distancePrecision ?? 2;
5541
+ let t = 2;
5542
+ return this.measureOptions.distanceUnit === "degrees" && (t = 6), this.measureOptions.distancePrecision ?? t;
5492
5543
  }
5493
5544
  set distancePrecision(t) {
5494
5545
  const e = this.measureOptions.distancePrecision === t;
5495
5546
  this.measureOptions.distancePrecision = t, e || this.recalc();
5496
5547
  }
5548
+ /**
5549
+ * Default is `auto`. If `auto` is set, unit is converted depending on the value in metric. If a specific unit is specified, it returns the value always the same.
5550
+ * This property is only effective when distanceUnit is set to 'kilometers'. If distanceUnit is set to other than 'kilometers', it will be ignored, and `auto` will be applied.
5551
+ * If you need to force other unit type, please use DistanceUnit property.
5552
+ */
5553
+ get forceDistanceUnit() {
5554
+ return this.measureOptions.forceDistanceUnit ?? "auto";
5555
+ }
5556
+ set forceDistanceUnit(t) {
5557
+ const e = this.measureOptions.forceDistanceUnit === t;
5558
+ this.measureOptions.forceDistanceUnit = t, e || this.recalc();
5559
+ }
5497
5560
  /**
5498
5561
  * The unit of area can be metric (m², ha, km²) or imperial (yd², acre, mi²). Default is metric.
5499
5562
  * The measuring result will be recalculated once new value is set
@@ -5658,7 +5721,7 @@ class Xo extends Ke {
5658
5721
  const s = this.measureOptions.lineLayerLabelSpec?.source;
5659
5722
  s && i.push(s);
5660
5723
  const n = this.measureOptions.pointLayerLabelSpec?.source;
5661
- return n && i.push(n), Ut(
5724
+ return n && i.push(n), zt(
5662
5725
  t,
5663
5726
  e,
5664
5727
  i,
@@ -5898,7 +5961,7 @@ class Xo extends Ke {
5898
5961
  (a) => a.properties?.originalId !== t
5899
5962
  ));
5900
5963
  const n = JSON.parse(JSON.stringify(o));
5901
- n.id = n.id + "-area-label", n.geometry = Bo(o.geometry).geometry, n.properties.originalId = o.id, o = ge(o, this.areaUnit, this.areaPrecision, this.forceAreaUnit), n.properties.area = o.properties.area, n.properties.unit = o.properties.unit, typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(n), this.map.getSource(
5964
+ n.id = n.id + "-area-label", n.geometry = Bo(o.geometry).geometry, n.properties.originalId = o.id, o = ye(o, this.areaUnit, this.areaPrecision, this.forceAreaUnit), n.properties.area = o.properties.area, n.properties.unit = o.properties.unit, typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(n), this.map.getSource(
5902
5965
  this.measureOptions.polygonLayerSpec.source
5903
5966
  )?.setData(s.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
5904
5967
  this.measureOptions.lineLayerLabelSpec.id
@@ -5932,6 +5995,7 @@ class Xo extends Ke {
5932
5995
  o,
5933
5996
  this.distanceUnit,
5934
5997
  this.distancePrecision,
5998
+ this.forceDistanceUnit,
5935
5999
  this.map,
5936
6000
  this.computeElevation,
5937
6001
  this.measureOptions.terrainSource
@@ -6024,10 +6088,11 @@ class Xo extends Ke {
6024
6088
  o,
6025
6089
  this.distanceUnit,
6026
6090
  this.distancePrecision,
6091
+ this.forceDistanceUnit,
6027
6092
  this.map,
6028
6093
  this.computeElevation,
6029
6094
  this.measureOptions.terrainSource
6030
- ) : s === "Polygon" ? e.features[i] = ge(o, this.areaUnit, this.areaPrecision, this.forceAreaUnit) : s === "Point" && (e.features[i] = Ce(
6095
+ ) : s === "Polygon" ? e.features[i] = ye(o, this.areaUnit, this.areaPrecision, this.forceAreaUnit) : s === "Point" && (e.features[i] = Ce(
6031
6096
  o,
6032
6097
  this.map,
6033
6098
  this.computeElevation,
@@ -6236,7 +6301,7 @@ class Ho extends Ke {
6236
6301
  const i = et, o = this.controlOptions.routingLineLayerNodeSpec?.source;
6237
6302
  o && i.push(o);
6238
6303
  const s = this.controlOptions.isochronePolygonLayerSpec?.source;
6239
- return s && i.push(s), Ut(t, e, i, this.options.adapterOptions?.prefixId);
6304
+ return s && i.push(s), zt(t, e, i, this.options.adapterOptions?.prefixId);
6240
6305
  }
6241
6306
  /**
6242
6307
  * Create the settings dialog for Valhalla control
@@ -6284,7 +6349,7 @@ class Ho extends Ke {
6284
6349
  const i = document.createElement("label");
6285
6350
  i.textContent = "Means of Transport", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
6286
6351
  this.settingDialog.createSegmentButtons(
6287
- Nt,
6352
+ Tt,
6288
6353
  this.routingCostingModel,
6289
6354
  (n) => {
6290
6355
  this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.costingModel = n, this.dispatchEvent("setting-changed");
@@ -6325,7 +6390,7 @@ class Ho extends Ke {
6325
6390
  const s = document.createElement("label");
6326
6391
  s.textContent = "Means of Transport", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
6327
6392
  this.settingDialog.createSegmentButtons(
6328
- Nt,
6393
+ Tt,
6329
6394
  this.controlOptions.valhallaOptions?.isochroneOptions?.costingModel || "auto",
6330
6395
  (d) => {
6331
6396
  this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.costingModel = d, this.dispatchEvent("setting-changed");
@@ -6632,20 +6697,19 @@ export {
6632
6697
  Yo as TERRADRAW_VALHALLA_SOURCE_IDS,
6633
6698
  No as ValhallaIsochrone,
6634
6699
  Wo as ValhallaRouting,
6635
- ge as calcArea,
6700
+ ye as calcArea,
6636
6701
  me as calcDistance,
6637
6702
  ve as capitalize,
6638
- Ut as cleanMaplibreStyle,
6703
+ zt as cleanMaplibreStyle,
6639
6704
  ko as contourTypeOptions,
6640
6705
  po as convertAreaUnit,
6641
- Ft as convertMetricDistance,
6642
- Nt as costingModelOptions,
6706
+ Mt as convertDistance,
6707
+ Tt as costingModelOptions,
6643
6708
  Ue as debounce,
6644
6709
  to as defaultControlOptions,
6645
6710
  lt as defaultMeasureControlOptions,
6646
6711
  z as defaultValhallaControlOptions,
6647
6712
  eo as getDefaultModeOptions,
6648
- fe as getDistanceUnitName,
6649
6713
  Ce as queryElevationByPoint,
6650
6714
  Pe as queryElevationFromRasterDEM,
6651
6715
  Ko as roundFeatureCoordinates,