@watergis/maplibre-gl-terradraw 1.7.4 → 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.
@@ -13,13 +13,13 @@ var b;
13
13
  r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
14
14
  })(b || (b = {}));
15
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 Ot(r) {
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 {
@@ -184,46 +184,46 @@ function Tt(r) {
184
184
  return s < 0 || s > 1;
185
185
  }
186
186
  function o(s, n, a, l) {
187
- const d = t[s][n], c = t[s][n + 1], h = t[a][l], p = t[a][l + 1], u = (function(m, v, C, f) {
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
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
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
- })(d, c, h, p);
192
- if (u === null) return;
191
+ })(d, c, h, u);
192
+ if (p === null) return;
193
193
  let g, y;
194
- g = c[0] !== d[0] ? (u[0] - d[0]) / (c[0] - d[0]) : (u[1] - d[1]) / (c[1] - d[1]), y = p[0] !== h[0] ? (u[0] - h[0]) / (p[0] - h[0]) : (u[1] - h[1]) / (p[1] - h[1]), i(g) || i(y) || (u.toString(), e.push(u));
194
+ g = c[0] !== d[0] ? (p[0] - d[0]) / (c[0] - d[0]) : (p[1] - d[1]) / (c[1] - d[1]), y = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(g) || i(y) || (p.toString(), e.push(p));
195
195
  }
196
196
  }
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 {
@@ -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, [S.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
  }
@@ -297,16 +297,16 @@ let xe = class extends A {
297
297
  return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
298
298
  })(this.center, [t.lng, t.lat]);
299
299
  i = (function(s) {
300
- const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, p] = n, { x: u, y: g } = O(h, p), y = [];
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), [P, I] = [u + C, g + f], { lng: E, lat: L } = R(P, 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 }]);
@@ -360,16 +360,16 @@ class Oe extends A {
360
360
  }
361
361
  onMouseMove(t) {
362
362
  if (this.currentId === void 0 || this.startingClick === !1) return void this.setCursor(this.cursors.start);
363
- const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l = F({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: p } = this.project(d, c);
364
- if (F({ x: h, y: p }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
363
+ const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l = F({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
364
+ if (F({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
365
365
  if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
366
366
  this.preventNewFeature = !1;
367
367
  }, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
368
368
  } else this.hasLeftStartingPoint = !0, this.setCursor(this.cursors.start);
369
369
  if (l < this.minDistance) return;
370
370
  e.coordinates[0].pop();
371
- const u = { type: "Polygon", coordinates: [[...e.coordinates[0], [t.lng, t.lat], e.coordinates[0][0]]] };
372
- this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: u, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: u }]);
371
+ const p = { type: "Polygon", coordinates: [[...e.coordinates[0], [t.lng, t.lat], e.coordinates[0][0]]] };
372
+ this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
373
373
  }
374
374
  onClick(t) {
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)) {
@@ -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 {
@@ -523,15 +523,15 @@ class li extends B {
523
523
  }
524
524
  generateInsertionGeodesicCoordinates(t, e, i) {
525
525
  const o = U(t, e), s = (function(n, a, l) {
526
- const d = [], c = yt(n[1]), h = yt(n[0]), p = yt(a[1]), u = yt(a[0]);
526
+ const d = [], c = yt(n[1]), h = yt(n[0]), u = yt(a[1]), p = yt(a[0]);
527
527
  l += 1;
528
- const g = 2 * Math.asin(Math.sqrt(Math.sin((p - c) / 2) ** 2 + Math.cos(c) * Math.cos(p) * Math.sin((u - h) / 2) ** 2));
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(p) * Math.cos(u), P = v * Math.cos(c) * Math.sin(h) + C * Math.cos(p) * Math.sin(u), I = v * Math.sin(c) + C * Math.sin(p);
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
532
  if (isNaN(f) || isNaN(P) || isNaN(I)) continue;
533
533
  const E = Math.atan2(I, Math.sqrt(f ** 2 + P ** 2)), L = Math.atan2(P, f);
534
- isNaN(E) || isNaN(L) || d.push([se(L), se(E)]);
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,10 +572,10 @@ 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), p = c * l - h * a, u = h * n - d * l, g = d * a - c * n, y = g * c - u * h, m = p * h - g * d, v = u * d - p * 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);
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
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
  }
@@ -583,7 +583,7 @@ 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));
@@ -603,30 +603,30 @@ class jt extends B {
603
603
  a = n.geometry.coordinates;
604
604
  }
605
605
  const l = [];
606
- for (let p = 0; p < a.length - 1; p++) l.push([a[p], a[p + 1]]);
606
+ for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
607
607
  let d;
608
608
  const c = [t.lng, t.lat];
609
- if (this.config.projection === "web-mercator" ? d = (function(p, u) {
609
+ if (this.config.projection === "web-mercator" ? d = (function(u, p) {
610
610
  let g = [1 / 0, 1 / 0], y = 1 / 0, m = 0;
611
- for (let v of u) {
611
+ for (let v of p) {
612
612
  const C = v[0], f = v[1];
613
613
  let P, I = 1 / 0;
614
- const E = O(C[0], C[1]), L = O(f[0], f[1]), M = O(p[0], p[1]);
615
- if (C[0] === p[0] && C[1] === p[1]) P = C;
616
- else if (f[0] === p[0] && f[1] === p[1]) P = f;
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]) 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
619
  P = [T, $];
620
620
  }
621
- P && (I = F(M, O(P[0], P[1])), I < y && (g = P, y = I, m = u.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
- })(c, l) : this.config.projection === "globe" && (d = (function(p, u) {
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
- for (let v of u) {
626
+ for (let v of p) {
627
627
  const C = v[0], f = v[1];
628
628
  let P, I = 1 / 0;
629
- C[0] === p[0] && C[1] === p[1] ? P = C : f[0] === p[0] && f[1] === p[1] ? P = f : [P] = di(C, f, p), P && (I = U(p, P), I < y && (g = P, y = I, m = u.indexOf(v)));
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
  }
@@ -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);
@@ -792,7 +792,7 @@ class At extends A {
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
  }
@@ -1004,7 +1004,7 @@ class Le extends A {
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);
@@ -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" };
@@ -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);
@@ -1287,18 +1287,18 @@ function Me(r, t, e) {
1287
1287
  const o = i / Se, s = r[0] * Math.PI / 180, n = D(r[1]), a = D(e), l = o * Math.cos(a);
1288
1288
  let d = n + l;
1289
1289
  Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
1290
- const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), p = [(180 * (s + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1291
- return p[0] += p[0] - r[0] > 180 ? -360 : r[0] - p[0] > 180 ? 360 : 0, p;
1290
+ const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (s + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1291
+ return u[0] += u[0] - r[0] > 180 ? -360 : r[0] - u[0] > 180 ? 360 : 0, u;
1292
1292
  }
1293
1293
  function De(r, t, e, i, o) {
1294
1294
  const s = i(r[0], r[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((s.x + n.x) / 2, (s.y + n.y) / 2);
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;
@@ -1327,14 +1327,14 @@ class xi extends B {
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);
@@ -1388,21 +1388,21 @@ class bi extends B {
1388
1388
  find(t, e) {
1389
1389
  let i, o, s, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
1390
1390
  const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
1391
- for (let p = 0; p < h.length; p++) {
1392
- const u = h[p], g = u.geometry;
1391
+ for (let u = 0; u < h.length; u++) {
1392
+ const p = h[u], g = p.geometry;
1393
1393
  if (g.type === "Point") {
1394
- if (u.properties.selectionPoint || u.properties.coordinatePoint || !e && u.properties[k.MID_POINT]) continue;
1394
+ if (p.properties.selectionPoint || p.properties.coordinatePoint || !e && p.properties[k.MID_POINT]) continue;
1395
1395
  const y = this.pixelDistance.measure(t, g.coordinates);
1396
- u.properties[k.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, s = u) : !u.properties[k.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = u);
1396
+ p.properties[k.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, s = p) : !p.properties[k.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
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]));
1401
- C < this.pointerDistance && C < l && (l = C, o = u);
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
+ C < this.pointerDistance && C < l && (l = C, o = p);
1402
1402
  }
1403
1403
  } else if (g.type === "Polygon") {
1404
1404
  if (i || o) continue;
1405
- _e([t.lng, t.lat], g.coordinates) && (n = u);
1405
+ _e([t.lng, t.lat], g.coordinates) && (n = p);
1406
1406
  }
1407
1407
  }
1408
1408
  return { clickedFeature: i || o || n, clickedMidPoint: s };
@@ -1433,16 +1433,16 @@ class Ei extends B {
1433
1433
  if (i.type === "Polygon" ? (s = i.coordinates[0], n = s.length - 1) : (s = i.coordinates, n = s.length), !this.dragPosition) return !1;
1434
1434
  for (let c = 0; c < n; c++) {
1435
1435
  const h = s[c];
1436
- let p, u;
1436
+ let u, p;
1437
1437
  if (this.config.projection === "web-mercator") {
1438
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
- p = P, u = I;
1439
+ u = P, p = I;
1440
1440
  } else {
1441
1441
  const g = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
1442
- p = h[0] - g[0], u = h[1] - g[1];
1442
+ u = h[0] - g[0], p = h[1] - g[1];
1443
1443
  }
1444
- if (p = w(p, this.config.coordinatePrecision), u = w(u, this.config.coordinatePrecision), p > 180 || p < -180 || u > 90 || u < -90) return !1;
1445
- s[c] = [p, u];
1444
+ if (u = w(u, this.config.coordinatePrecision), p = w(p, this.config.coordinatePrecision), u > 180 || u < -180 || p > 90 || p < -90) return !1;
1445
+ s[c] = [u, p];
1446
1446
  }
1447
1447
  i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
1448
1448
  const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [], d = this.coordinatePoints.getUpdated(this.draggedFeatureId, s) || [];
@@ -1496,14 +1496,14 @@ class wi extends B {
1496
1496
  drag(t, e, i, o) {
1497
1497
  const s = this.draggedCoordinate.id;
1498
1498
  if (s === null) return !1;
1499
- const n = this.draggedCoordinate.index, a = this.store.getGeometryCopy(s), l = this.store.getPropertiesCopy(s), d = a.type === "LineString" ? a.coordinates : a.coordinates[0], c = a.type === "Polygon" && (n === d.length - 1 || n === 0), h = { type: "Feature", id: s, geometry: a, properties: l }, p = this.snapCoordinate(t, o, h);
1499
+ const n = this.draggedCoordinate.index, a = this.store.getGeometryCopy(s), l = this.store.getPropertiesCopy(s), d = a.type === "LineString" ? a.coordinates : a.coordinates[0], c = a.type === "Polygon" && (n === d.length - 1 || n === 0), h = { type: "Feature", id: s, geometry: a, properties: l }, u = this.snapCoordinate(t, o, h);
1500
1500
  if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
1501
1501
  if (c) {
1502
1502
  const v = d.length - 1;
1503
- d[0] = p, d[v] = p;
1504
- } else d[n] = p;
1505
- const u = this.selectionPoints.getOneUpdated(n, p), g = u ? [u] : [], 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));
1503
+ d[0] = u, d[v] = u;
1504
+ } else d[n] = u;
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 && 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];
@@ -1537,8 +1537,8 @@ function _t(r) {
1537
1537
  let i = 0, o = 0, s = 0;
1538
1538
  const n = e.length;
1539
1539
  for (let a = 0; a < n - 1; a++) {
1540
- const [l, d] = e[a], [c, h] = e[a + 1], p = l * h - c * d;
1541
- i += p, o += (l + c) * p, s += (d + h) * p;
1540
+ const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
1541
+ i += u, o += (l + c) * u, s += (d + h) * u;
1542
1542
  }
1543
1543
  return i /= 2, o /= 6 * i, s /= 6 * i, { x: o, y: s };
1544
1544
  })(t) : (function(e) {
@@ -1566,19 +1566,19 @@ 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));
1570
- const p = O(t.lng, t.lat);
1571
- if (n = G(this.selectedGeometryWebMercatorCentroid, p), n === 0) return;
1569
+ this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid = kt(a));
1570
+ const u = O(t.lng, t.lat);
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);
1577
- (function(p, u) {
1578
- if (u === 0 || u === 360 || u === -360) return p;
1579
- const g = ae(p);
1580
- (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((y) => {
1581
- const m = Mt(g, y) + u, v = (function(f, P) {
1576
+ if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid = le({ geometry: o })), n = Dt(this.selectedGeometryCentroid, s), !this.lastBearing) return void (this.lastBearing = n + 180);
1577
+ (function(u, p) {
1578
+ if (p === 0 || p === 360 || p === -360) return u;
1579
+ const g = le(u);
1580
+ (u.geometry.type === "Polygon" ? u.geometry.coordinates[0] : u.geometry.coordinates).forEach((y) => {
1581
+ const m = Dt(g, y) + p, v = (function(f, P) {
1582
1582
  f[0] += f[0] - P[0] > 180 ? -360 : P[0] - f[0] > 180 ? 360 : 0;
1583
1583
  const I = Se, E = P[1] * Math.PI / 180, L = f[1] * Math.PI / 180, M = L - E;
1584
1584
  let N = Math.abs(f[0] - P[0]) * Math.PI / 180;
@@ -1591,8 +1591,8 @@ class Li extends B {
1591
1591
  })(a, -(this.lastBearing - (n + 180)));
1592
1592
  }
1593
1593
  const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1594
- l.forEach((p) => {
1595
- p[0] = w(p[0], this.coordinatePrecision), p[1] = w(p[1], this.coordinatePrecision);
1594
+ l.forEach((u) => {
1595
+ u[0] = w(u[0], this.coordinatePrecision), u[1] = w(u[1], this.coordinatePrecision);
1596
1596
  });
1597
1597
  const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [], h = this.coordinatePoints.getUpdated(e, l) || [];
1598
1598
  if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional })) return !1;
@@ -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;
@@ -1731,8 +1731,8 @@ class Mi extends B {
1731
1731
  }
1732
1732
  performWebMercatorScale(t, e, i, o, s) {
1733
1733
  t.forEach((n) => {
1734
- const { x: a, y: l } = O(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * s, { lng: h, lat: p } = R(d, c);
1735
- n[0] = h, n[1] = p;
1734
+ const { x: a, y: l } = O(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * s, { lng: h, lat: u } = R(d, c);
1735
+ n[0] = h, n[1] = u;
1736
1736
  });
1737
1737
  }
1738
1738
  getBBoxWebMercator(t) {
@@ -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();
@@ -1819,9 +1819,9 @@ class Gt extends qe {
1819
1819
  onRightClick(t) {
1820
1820
  if (!this.selectionPoints.ids.length) return;
1821
1821
  let e, i = 1 / 0;
1822
- if (this.selectionPoints.ids.forEach((p) => {
1823
- const u = this.store.getGeometryCopy(p), g = this.pixelDistance.measure(t, u.coordinates);
1824
- g < this.pointerDistance && g < i && (i = g, e = this.store.getPropertiesCopy(p));
1822
+ if (this.selectionPoints.ids.forEach((u) => {
1823
+ const p = this.store.getGeometryCopy(u), g = this.pixelDistance.measure(t, p.coordinates);
1824
+ g < this.pointerDistance && g < i && (i = g, e = this.store.getPropertiesCopy(u));
1825
1825
  }), !e) return;
1826
1826
  const o = e.selectionPointFeatureId, s = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
1827
1827
  if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
@@ -2004,8 +2004,8 @@ class _i extends A {
2004
2004
  function Te(r, t, e, i, o) {
2005
2005
  for (; i > e; ) {
2006
2006
  if (i - e > 600) {
2007
- const l = i - e + 1, d = t - e + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), p = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
2008
- Te(r, t, Math.max(e, Math.floor(t - d * h / l + p)), Math.min(i, Math.floor(t + (l - d) * h / l + p)), o);
2007
+ const l = i - e + 1, d = t - e + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
2008
+ Te(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
2009
2009
  }
2010
2010
  const s = r[t];
2011
2011
  let n = e, a = i;
@@ -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,13 +2156,13 @@ 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);
2163
- for (let p = c; p <= h; p += l) {
2164
- const u = Math.min(p + l - 1, h);
2165
- n.children.push(this._build(t, p, u, o - 1));
2162
+ ce(t, c, h, l, this.compareMinY);
2163
+ for (let u = c; u <= h; u += l) {
2164
+ const p = Math.min(u + l - 1, h);
2165
+ n.children.push(this._build(t, u, p, o - 1));
2166
2166
  }
2167
2167
  }
2168
2168
  return J(n, this.toBBox), n;
@@ -2171,8 +2171,8 @@ 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], p = Et(h), u = (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)) - p);
2175
- u < d ? (d = u, l = p < l ? p : l, a = h) : u === d && p < l && (l = p, a = h);
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
+ 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];
2178
2178
  }
@@ -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;
@@ -2310,10 +2310,10 @@ class Ai {
2310
2310
  }
2311
2311
  if (this.tracked) {
2312
2312
  if (d.properties.createdAt) {
2313
- if (!qt(d.properties.createdAt)) return n.push({ id: d.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2313
+ if (!Zt(d.properties.createdAt)) return n.push({ id: d.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2314
2314
  } else d.properties.createdAt = +/* @__PURE__ */ new Date();
2315
2315
  if (d.properties.updatedAt) {
2316
- if (!qt(d.properties.updatedAt)) return n.push({ id: d.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2316
+ if (!Zt(d.properties.updatedAt)) return n.push({ id: d.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2317
2317
  } else d.properties.updatedAt = +/* @__PURE__ */ new Date();
2318
2318
  }
2319
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);
@@ -2390,8 +2390,8 @@ class Ai {
2390
2390
  return Object.keys(this.store).length;
2391
2391
  }
2392
2392
  }
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 } : Tt(r) ? { valid: !1, reason: Gi } : { valid: !0 };
2394
- 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) {
2395
2395
  const i = G(r, t);
2396
2396
  let o = G(t, e) - i;
2397
2397
  return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
@@ -2424,7 +2424,7 @@ class We extends A {
2424
2424
  const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
2425
2425
  i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
2426
2426
  } else if (this.currentCoordinate === 2) {
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), p = ce(a, l, c), u = h ? 90 - p : ce(a, l, c) - 90, g = F(l, c), y = Math.cos(D(u)) * 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) {
2428
2428
  const M = (L.x - E.x) * (I.y - E.y) - (L.y - E.y) * (I.x - E.x);
2429
2429
  return M > 1e-10 ? "left" : M < -1e-10 ? "right" : "left";
2430
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);
@@ -2516,12 +2516,12 @@ class je extends A {
2516
2516
  const f = Be(a, l, d);
2517
2517
  this.direction = f ? "clockwise" : "anticlockwise";
2518
2518
  }
2519
- const c = F(a, l), h = G(a, l), p = G(a, d), u = this.arcPoints, g = [o], y = X(h), m = X(p);
2519
+ const c = F(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [o], y = X(h), m = X(u);
2520
2520
  let v;
2521
2521
  this.direction === "anticlockwise" ? (v = m - y, v < 0 && (v += 360)) : (v = y - m, v < 0 && (v += 360));
2522
- const C = (this.direction === "anticlockwise" ? 1 : -1) * v / u;
2522
+ const C = (this.direction === "anticlockwise" ? 1 : -1) * v / p;
2523
2523
  g.push(s);
2524
- for (let f = 0; f <= u; f++) {
2524
+ for (let f = 0; f <= p; f++) {
2525
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)];
2526
2526
  L[0] !== g[g.length - 1][0] && L[1] !== g[g.length - 1][1] && g.push(L);
2527
2527
  }
@@ -2603,19 +2603,19 @@ class Ae extends A {
2603
2603
  const C = Be(l, n, a);
2604
2604
  this.direction = C ? "clockwise" : "anticlockwise";
2605
2605
  }
2606
- const c = G(l, n), h = G(l, a), p = this.arcPoints, u = [o], g = X(c), y = X(h);
2606
+ const c = G(l, n), h = G(l, a), u = this.arcPoints, p = [o], g = X(c), y = X(h);
2607
2607
  let m;
2608
2608
  this.direction === "anticlockwise" ? (m = y - g, m < 0 && (m += 360)) : (m = g - y, m < 0 && (m += 360));
2609
- const v = (this.direction === "anticlockwise" ? 1 : -1) * m / p;
2610
- for (let C = 0; C <= p; C++) {
2609
+ const v = (this.direction === "anticlockwise" ? 1 : -1) * m / u;
2610
+ for (let C = 0; C <= u; C++) {
2611
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)];
2612
- E[0] !== u[u.length - 1][0] && E[1] !== u[u.length - 1][1] && u.push(E);
2612
+ E[0] !== p[p.length - 1][0] && E[1] !== p[p.length - 1][1] && p.push(E);
2613
2613
  }
2614
- this.updateLineStringGeometry(this.currentInitialArcId, u, b.Provisional);
2614
+ this.updateLineStringGeometry(this.currentInitialArcId, p, b.Provisional);
2615
2615
  } else if (this.currentCoordinate === 3) {
2616
2616
  const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2617
2617
  if (e.length < 2 || !this.direction) return;
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, p = G(d, n), u = G(d, a), g = G(d, l), y = X(u), m = X(g), v = X(p);
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);
2619
2619
  if (this.notInSector({ normalizedCursor: v, normalizedStart: y, normalizedEnd: m, direction: this.direction })) return;
2620
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 = [];
2621
2621
  for (let L = 0; L <= f; L++) {
@@ -2804,8 +2804,8 @@ class Re extends A {
2804
2804
  }
2805
2805
  onMouseMove(t) {
2806
2806
  if (this.currentId === void 0 || this.startingClick === !1) return void this.setCursor(this.cursors.start);
2807
- const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates.length - 2, [o, s] = e.coordinates[i], { x: n, y: a } = this.project(o, s), l = F({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[e.coordinates.length - 1], { x: h, y: p } = this.project(d, c), u = F({ x: h, y: p }, { x: t.containerX, y: t.containerY });
2808
- if (this.setCursor(u < this.pointerDistance ? this.cursors.close : this.cursors.start), l < this.minDistance) return;
2807
+ const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates.length - 2, [o, s] = e.coordinates[i], { x: n, y: a } = this.project(o, s), l = F({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[e.coordinates.length - 1], { x: h, y: u } = this.project(d, c), p = F({ x: h, y: u }, { x: t.containerX, y: t.containerY });
2808
+ if (this.setCursor(p < this.pointerDistance ? this.cursors.close : this.cursors.start), l < this.minDistance) return;
2809
2809
  const g = { type: "LineString", coordinates: [...e.coordinates, [t.lng, t.lat]] };
2810
2810
  this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.currentId, geometry: g }]), this.closingPointId && this.store.updateGeometry([{ id: this.closingPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]));
2811
2811
  }
@@ -2843,13 +2843,13 @@ class Re extends A {
2843
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);
2844
2844
  }
2845
2845
  validateFeature(t) {
2846
- return this.validateModeFeature(t, (e) => Bt(e, this.coordinatePrecision));
2846
+ return this.validateModeFeature(t, (e) => jt(e, this.coordinatePrecision));
2847
2847
  }
2848
2848
  afterFeatureUpdated(t) {
2849
2849
  this.currentId === t.id && (this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0);
2850
2850
  }
2851
2851
  }
2852
- function kt(r) {
2852
+ function Nt(r) {
2853
2853
  if (r === null || typeof r == "boolean" || typeof r == "string") return !0;
2854
2854
  if (r === void 0) return !1;
2855
2855
  if (typeof r == "number") return Number.isFinite(r);
@@ -2860,9 +2860,9 @@ function kt(r) {
2860
2860
  }
2861
2861
  if (ArrayBuffer.isView(r) && !(r instanceof DataView)) return !1;
2862
2862
  if (Array.isArray(r)) {
2863
- for (const t of r) if (!kt(t)) return !1;
2863
+ for (const t of r) if (!Nt(t)) return !1;
2864
2864
  }
2865
- 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]));
2866
2866
  }
2867
2867
  class Zi {
2868
2868
  constructor(t) {
@@ -2879,33 +2879,33 @@ class Zi {
2879
2879
  }
2880
2880
  }), this._modes = x({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Ai({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2881
2881
  const s = (c) => {
2882
- const h = [], p = this._store.copyAll().filter((u) => !c.includes(u.id) || (h.push(u), !1));
2883
- return { changed: h, unchanged: p };
2882
+ const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
2883
+ return { changed: h, unchanged: u };
2884
2884
  }, n = (c, h) => {
2885
- this._enabled && this._eventListeners.finish.forEach((p) => {
2886
- p(c, h);
2885
+ this._enabled && this._eventListeners.finish.forEach((u) => {
2886
+ u(c, h);
2887
2887
  });
2888
- }, a = (c, h, p) => {
2888
+ }, a = (c, h, u) => {
2889
2889
  if (!this._enabled) return;
2890
2890
  this._eventListeners.change.forEach((y) => {
2891
- y(c, h, p);
2891
+ y(c, h, u);
2892
2892
  });
2893
- const { changed: u, unchanged: g } = s(c);
2894
- h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: g, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles());
2893
+ const { changed: p, unchanged: g } = s(c);
2894
+ h === "create" ? this._adapter.render({ created: p, deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: p }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: g, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles());
2895
2895
  }, l = (c) => {
2896
2896
  if (!this._enabled) return;
2897
- this._eventListeners.select.forEach((u) => {
2898
- u(c);
2897
+ this._eventListeners.select.forEach((p) => {
2898
+ p(c);
2899
2899
  });
2900
- const { changed: h, unchanged: p } = s([c]);
2901
- this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: h }, this.getModeStyles());
2900
+ const { changed: h, unchanged: u } = s([c]);
2901
+ this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2902
2902
  }, d = (c) => {
2903
2903
  if (!this._enabled) return;
2904
- this._eventListeners.deselect.forEach((u) => {
2905
- u();
2904
+ this._eventListeners.deselect.forEach((p) => {
2905
+ p();
2906
2906
  });
2907
- const { changed: h, unchanged: p } = s([c]);
2908
- h && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: h }, this.getModeStyles());
2907
+ const { changed: h, unchanged: u } = s([c]);
2908
+ h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2909
2909
  };
2910
2910
  Object.keys(this._modes).forEach((c) => {
2911
2911
  this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
@@ -2921,44 +2921,44 @@ class Zi {
2921
2921
  }), t;
2922
2922
  }
2923
2923
  featuresAtLocation({ lng: t, lat: e }, i) {
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), p = be({ unproject: d, point: h, pointerDistance: o });
2925
- return this._store.search(p).filter((u) => {
2926
- if (s && (u.properties[k.MID_POINT] || u.properties[k.SELECTION_POINT]) || n && u.properties[S.COORDINATE_POINT] || l && u.properties[S.CLOSING_POINT] || a && u.properties[S.CURRENTLY_DRAWING]) return !1;
2927
- if (u.geometry.type === "Point") {
2928
- const g = u.geometry.coordinates, y = c(g[0], g[1]);
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 });
2925
+ return this._store.search(u).filter((p) => {
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;
2927
+ if (p.geometry.type === "Point") {
2928
+ const g = p.geometry.coordinates, y = c(g[0], g[1]);
2929
2929
  return F(h, y) < o;
2930
2930
  }
2931
- if (u.geometry.type === "LineString") {
2932
- const g = u.geometry.coordinates;
2931
+ if (p.geometry.type === "LineString") {
2932
+ const g = p.geometry.coordinates;
2933
2933
  for (let y = 0; y < g.length - 1; y++) {
2934
2934
  const m = g[y], v = g[y + 1];
2935
- 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;
2936
2936
  }
2937
2937
  return !1;
2938
2938
  }
2939
- if (_e([t, e], u.geometry.coordinates)) return !0;
2939
+ if (_e([t, e], p.geometry.coordinates)) return !0;
2940
2940
  if (i != null && i.includePolygonsWithinPointerDistance) {
2941
- const g = u.geometry.coordinates;
2941
+ const g = p.geometry.coordinates;
2942
2942
  for (const y of g) for (let m = 0; m < y.length - 1; m++) {
2943
2943
  const v = y[m], C = y[m + 1], f = c(v[0], v[1]), P = c(C[0], C[1]);
2944
- if (Dt(h, f, P) < o) return !0;
2944
+ if (_t(h, f, P) < o) return !0;
2945
2945
  }
2946
2946
  }
2947
2947
  return !1;
2948
- }).map((u) => {
2949
- if (i == null || !i.addClosestCoordinateInfoToProperties) return u;
2948
+ }).map((p) => {
2949
+ if (i == null || !i.addClosestCoordinateInfoToProperties) return p;
2950
2950
  let g;
2951
- if (u.geometry.type === "Polygon") g = u.geometry.coordinates[0], g.pop();
2951
+ if (p.geometry.type === "Polygon") g = p.geometry.coordinates[0], g.pop();
2952
2952
  else {
2953
- if (u.geometry.type !== "LineString") return u;
2954
- g = u.geometry.coordinates;
2953
+ if (p.geometry.type !== "LineString") return p;
2954
+ g = p.geometry.coordinates;
2955
2955
  }
2956
2956
  let y, m = -1, v = 1 / 0;
2957
2957
  for (let C = 0; C < g.length; C++) {
2958
2958
  const f = g[C], P = F(c(f[0], f[1]), h);
2959
2959
  P < v && (m = C, v = P, y = f);
2960
2960
  }
2961
- return u.properties.closestCoordinateIndexToEvent = m, u.properties.closestCoordinatePixelDistanceToEvent = v, u.properties.closestCoordinateDistanceKmToEvent = U(y, [t, e]), u;
2961
+ return p.properties.closestCoordinateIndexToEvent = m, p.properties.closestCoordinatePixelDistanceToEvent = v, p.properties.closestCoordinateDistanceKmToEvent = U(y, [t, e]), p;
2962
2962
  });
2963
2963
  }
2964
2964
  getSelectModeOrThrow() {
@@ -3040,7 +3040,7 @@ class Zi {
3040
3040
  const s = Object.entries(e);
3041
3041
  s.forEach(([n, a]) => {
3042
3042
  if (!this.checkIsReservedProperty(n)) throw new Error(`You are trying to update a reserved property name: ${n}. Please choose another name.`);
3043
- 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}`);
3044
3044
  }), this._store.updateProperty(s.map(([n, a]) => ({ id: i.id, property: n, value: a })), { origin: "api" });
3045
3045
  }
3046
3046
  updateFeatureGeometry(t, e) {
@@ -3084,7 +3084,7 @@ class Zi {
3084
3084
  }
3085
3085
  addFeatures(t) {
3086
3086
  return this.checkEnabled(), t.length === 0 ? [] : this._store.load(t, (e) => {
3087
- if (Jt(e)) {
3087
+ if (qt(e)) {
3088
3088
  const i = e.properties.mode, o = this._modes[i];
3089
3089
  if (!o) return { id: e.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
3090
3090
  const s = o.validateFeature.bind(o)(e);
@@ -3092,7 +3092,7 @@ class Zi {
3092
3092
  }
3093
3093
  return { id: e.id, valid: !1, reason: "Mode property does not exist" };
3094
3094
  }, (e) => {
3095
- if (Jt(e)) {
3095
+ if (qt(e)) {
3096
3096
  const i = this._modes[e.properties.mode];
3097
3097
  i && i.afterFeatureAdded && i.afterFeatureAdded(e);
3098
3098
  }
@@ -3206,8 +3206,8 @@ class Qi extends Hi.TerraDrawBaseAdapter {
3206
3206
  if (!this._currentModeCallbacks) return;
3207
3207
  const i = [...t.created, ...t.updated, ...t.unchanged], o = [], s = [], n = [];
3208
3208
  for (let c = 0; c < i.length; c++) {
3209
- const h = i[c], { properties: p } = h, u = e[p.mode](h);
3210
- h.geometry.type === "Point" ? (p.pointColor = u.pointColor, p.pointOutlineColor = u.pointOutlineColor, p.pointOutlineWidth = u.pointOutlineWidth, p.pointWidth = u.pointWidth, p.zIndex = u.zIndex, o.push(h)) : h.geometry.type === "LineString" ? (p.lineStringColor = u.lineStringColor, p.lineStringWidth = u.lineStringWidth, s.push(h)) : h.geometry.type === "Polygon" && (p.polygonFillColor = u.polygonFillColor, p.polygonFillOpacity = u.polygonFillOpacity, p.polygonOutlineColor = u.polygonOutlineColor, p.polygonOutlineWidth = u.polygonOutlineWidth, n.push(h));
3209
+ const h = i[c], { properties: u } = h, p = e[u.mode](h);
3210
+ h.geometry.type === "Point" ? (u.pointColor = p.pointColor, u.pointOutlineColor = p.pointOutlineColor, u.pointOutlineWidth = p.pointOutlineWidth, u.pointWidth = p.pointWidth, u.zIndex = p.zIndex, o.push(h)) : h.geometry.type === "LineString" ? (u.lineStringColor = p.lineStringColor, u.lineStringWidth = p.lineStringWidth, s.push(h)) : h.geometry.type === "Polygon" && (u.polygonFillColor = p.polygonFillColor, u.polygonFillOpacity = p.polygonFillOpacity, u.polygonOutlineColor = p.polygonOutlineColor, u.polygonOutlineWidth = p.polygonOutlineWidth, n.push(h));
3211
3211
  }
3212
3212
  const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
3213
3213
  (a || this.changedIds.points) && this._setGeoJSONLayerData("Point", o), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", n), this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
@@ -3294,7 +3294,7 @@ const zo = [
3294
3294
  open: !1,
3295
3295
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
3296
3296
  modeOptions: {
3297
- point: new Rt({
3297
+ point: new Gt({
3298
3298
  editable: !0,
3299
3299
  styles: {
3300
3300
  pointColor: "#FFFFFF",
@@ -3303,7 +3303,7 @@ const zo = [
3303
3303
  pointOutlineWidth: 1
3304
3304
  }
3305
3305
  }),
3306
- linestring: new At({
3306
+ linestring: new Rt({
3307
3307
  editable: !0,
3308
3308
  styles: {
3309
3309
  lineStringColor: "#666666",
@@ -3393,7 +3393,7 @@ const zo = [
3393
3393
  outlineWidth: 2
3394
3394
  }
3395
3395
  }),
3396
- select: new Gt({
3396
+ select: new Ut({
3397
3397
  flags: {
3398
3398
  point: {
3399
3399
  feature: {
@@ -3657,6 +3657,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3657
3657
  },
3658
3658
  distanceUnit: "kilometers",
3659
3659
  distancePrecision: 2,
3660
+ forceDistanceUnit: "auto",
3660
3661
  areaUnit: "metric",
3661
3662
  areaPrecision: 2,
3662
3663
  forceAreaUnit: "auto",
@@ -3685,7 +3686,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3685
3686
  open: !1,
3686
3687
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
3687
3688
  modeOptions: {
3688
- point: new Rt({
3689
+ point: new Gt({
3689
3690
  editable: !1,
3690
3691
  styles: {
3691
3692
  pointColor: "#FFFFFF",
@@ -3694,7 +3695,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3694
3695
  pointOutlineWidth: 1
3695
3696
  }
3696
3697
  }),
3697
- linestring: new At({
3698
+ linestring: new Rt({
3698
3699
  editable: !1,
3699
3700
  styles: {
3700
3701
  lineStringColor: "#FF0000",
@@ -3705,7 +3706,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3705
3706
  closingPointOutlineWidth: 1
3706
3707
  }
3707
3708
  }),
3708
- select: new Gt({
3709
+ select: new Ut({
3709
3710
  flags: {
3710
3711
  point: {
3711
3712
  feature: {
@@ -3905,10 +3906,10 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3905
3906
  modeName: "render",
3906
3907
  styles: {}
3907
3908
  }),
3908
- point: new Rt({
3909
+ point: new Gt({
3909
3910
  editable: !0
3910
3911
  }),
3911
- linestring: new At({
3912
+ linestring: new Rt({
3912
3913
  editable: !0
3913
3914
  }),
3914
3915
  polygon: new Le({
@@ -3927,7 +3928,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3927
3928
  "freehand-linestring": new Re(),
3928
3929
  sensor: new Ae(),
3929
3930
  sector: new je(),
3930
- select: new Gt({
3931
+ select: new Ut({
3931
3932
  flags: {
3932
3933
  point: {
3933
3934
  feature: {
@@ -4081,7 +4082,7 @@ function so(r, t, e = {}) {
4081
4082
  throw new Error("coordinates must be an Array");
4082
4083
  if (r.length < 2)
4083
4084
  throw new Error("coordinates must be at least 2 numbers long");
4084
- if (!he(r[0]) || !he(r[1]))
4085
+ if (!ue(r[0]) || !ue(r[1]))
4085
4086
  throw new Error("coordinates must contain numbers");
4086
4087
  return oo({
4087
4088
  type: "Point",
@@ -4097,16 +4098,16 @@ function ro(r, t = "kilometers") {
4097
4098
  function vt(r) {
4098
4099
  return r % 360 * Math.PI / 180;
4099
4100
  }
4100
- function he(r) {
4101
+ function ue(r) {
4101
4102
  return !isNaN(r) && r !== null && !Array.isArray(r);
4102
4103
  }
4103
4104
  function Ge(r, t, e) {
4104
4105
  if (r !== null)
4105
- for (var i, o, s, n, a, l, d, c = 0, h = 0, p, u = r.type, g = u === "FeatureCollection", y = u === "Feature", m = g ? r.features.length : 1, v = 0; v < m; v++) {
4106
- d = g ? r.features[v].geometry : y ? r.geometry : r, p = d ? d.type === "GeometryCollection" : !1, a = p ? d.geometries.length : 1;
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++) {
4107
+ d = g ? r.features[v].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
4107
4108
  for (var C = 0; C < a; C++) {
4108
4109
  var f = 0, P = 0;
4109
- if (n = p ? d.geometries[C] : d, n !== null) {
4110
+ if (n = u ? d.geometries[C] : d, n !== null) {
4110
4111
  l = n.coordinates;
4111
4112
  var I = n.type;
4112
4113
  switch (c = I === "Polygon" || I === "MultiPolygon" ? 1 : 0, I) {
@@ -4188,13 +4189,13 @@ function Ge(r, t, e) {
4188
4189
  }
4189
4190
  }
4190
4191
  function no(r, t) {
4191
- var e, i, o, s, n, a, l, d, c, h, p = 0, u = r.type === "FeatureCollection", g = r.type === "Feature", y = u ? r.features.length : 1;
4192
+ var e, i, o, s, n, a, l, d, c, h, u = 0, p = r.type === "FeatureCollection", g = r.type === "Feature", y = p ? r.features.length : 1;
4192
4193
  for (e = 0; e < y; e++) {
4193
- for (a = u ? r.features[e].geometry : g ? r.geometry : r, d = u ? r.features[e].properties : g ? r.properties : {}, c = u ? r.features[e].bbox : g ? r.bbox : void 0, h = u ? r.features[e].id : g ? r.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
4194
+ for (a = p ? r.features[e].geometry : g ? r.geometry : r, d = p ? r.features[e].properties : g ? r.properties : {}, c = p ? r.features[e].bbox : g ? r.bbox : void 0, h = p ? r.features[e].id : g ? r.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
4194
4195
  if (s = l ? a.geometries[o] : a, s === null) {
4195
4196
  if (t(
4196
4197
  null,
4197
- p,
4198
+ u,
4198
4199
  d,
4199
4200
  c,
4200
4201
  h
@@ -4211,7 +4212,7 @@ function no(r, t) {
4211
4212
  case "MultiPolygon": {
4212
4213
  if (t(
4213
4214
  s,
4214
- p,
4215
+ u,
4215
4216
  d,
4216
4217
  c,
4217
4218
  h
@@ -4223,7 +4224,7 @@ function no(r, t) {
4223
4224
  for (i = 0; i < s.geometries.length; i++)
4224
4225
  if (t(
4225
4226
  s.geometries[i],
4226
- p,
4227
+ u,
4227
4228
  d,
4228
4229
  c,
4229
4230
  h
@@ -4235,7 +4236,7 @@ function no(r, t) {
4235
4236
  throw new Error("Unknown Geometry Type");
4236
4237
  }
4237
4238
  }
4238
- p++;
4239
+ u++;
4239
4240
  }
4240
4241
  }
4241
4242
  function ao(r, t, e) {
@@ -4265,10 +4266,10 @@ function co(r) {
4265
4266
  let t = 0, e;
4266
4267
  switch (r.type) {
4267
4268
  case "Polygon":
4268
- return ue(r.coordinates);
4269
+ return pe(r.coordinates);
4269
4270
  case "MultiPolygon":
4270
4271
  for (e = 0; e < r.coordinates.length; e++)
4271
- t += ue(r.coordinates[e]);
4272
+ t += pe(r.coordinates[e]);
4272
4273
  return t;
4273
4274
  case "Point":
4274
4275
  case "MultiPoint":
@@ -4278,22 +4279,22 @@ function co(r) {
4278
4279
  }
4279
4280
  return 0;
4280
4281
  }
4281
- function ue(r) {
4282
+ function pe(r) {
4282
4283
  let t = 0;
4283
4284
  if (r && r.length > 0) {
4284
- t += Math.abs(pe(r[0]));
4285
+ t += Math.abs(ge(r[0]));
4285
4286
  for (let e = 1; e < r.length; e++)
4286
- t -= Math.abs(pe(r[e]));
4287
+ t -= Math.abs(ge(r[e]));
4287
4288
  }
4288
4289
  return t;
4289
4290
  }
4290
- var ho = W * W / 2, Lt = Math.PI / 180;
4291
- function pe(r) {
4291
+ var ho = W * W / 2, Ft = Math.PI / 180;
4292
+ function ge(r) {
4292
4293
  const t = r.length - 1;
4293
4294
  if (t <= 2) return 0;
4294
4295
  let e = 0, i = 0;
4295
4296
  for (; i < t; ) {
4296
- 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;
4297
4298
  e += (d - a) * Math.sin(l), i++;
4298
4299
  }
4299
4300
  return e * ho;
@@ -4347,12 +4348,12 @@ const po = (r, t, e = "auto") => {
4347
4348
  area: e,
4348
4349
  unit: i
4349
4350
  };
4350
- }, ge = (r, t, e, i) => {
4351
+ }, ye = (r, t, e, i) => {
4351
4352
  if (r.geometry.type !== "Polygon") return r;
4352
4353
  const o = uo(r.geometry), s = po(o, t, i);
4353
4354
  return s.area = parseFloat(s.area.toFixed(e)), r.properties.area = s.area, r.properties.unit = s.unit, r;
4354
4355
  };
4355
- function ye(r) {
4356
+ function fe(r) {
4356
4357
  if (!r)
4357
4358
  throw new Error("coord is required");
4358
4359
  if (!Array.isArray(r)) {
@@ -4366,63 +4367,94 @@ function ye(r) {
4366
4367
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
4367
4368
  }
4368
4369
  function go(r, t, e = {}) {
4369
- 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);
4370
4371
  return ro(
4371
4372
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
4372
4373
  e.units
4373
4374
  );
4374
4375
  }
4375
4376
  var yo = go;
4376
- const fe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians" ? "rad" : "km", Ft = (r) => {
4377
- if (r >= 1)
4378
- return {
4379
- distance: r,
4380
- unit: "km"
4381
- };
4382
- const t = r * 1e3;
4383
- return t >= 1 ? {
4384
- distance: t,
4385
- unit: "m"
4386
- } : {
4387
- distance: t * 100,
4388
- 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"
4389
4387
  };
4390
- }, me = (r, t, e, i, o, s) => {
4391
- if (r.geometry.type !== "LineString") return r;
4392
- const n = r.geometry.coordinates;
4393
- let a = 0;
4394
- const l = [];
4395
- for (let d = 0; d < n.length - 1; d++) {
4396
- const c = n[d], h = n[d + 1], p = yo(c, h, { units: t });
4397
- a += p;
4398
- const u = JSON.parse(JSON.stringify(r));
4399
- if (u.id = `${u.id}-${d}`, u.geometry.coordinates = [c, h], u.properties.originalId = r.id, u.properties.distance = p, u.properties.total = a, u.properties.unit = fe(t), u.properties.totalUnit = fe(t), o === !0 && s === void 0) {
4400
- const g = i?.queryTerrainElevation(c);
4401
- g && (u.properties.elevation_start = g);
4402
- const y = i?.queryTerrainElevation(h);
4403
- y && (u.properties.elevation_end = y);
4404
- }
4405
- l.push(u);
4406
- }
4407
- 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") {
4408
- const d = Ft(r.properties.distance);
4409
- r.properties.distance = d.distance, r.properties.unit = d.unit, r.properties.segments.forEach(
4410
- (c) => {
4411
- const h = Ft(c.properties.distance);
4412
- c.properties.distance = h.distance, c.properties.unit = h.unit;
4413
- const p = Ft(c.properties.total);
4414
- c.properties.total = p.distance, c.properties.totalUnit = p.unit;
4415
- }
4416
- );
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;
4417
4410
  }
4418
- 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(
4419
4451
  r.properties.distance.toFixed(e)
4420
4452
  ), r.properties.segments.forEach(
4421
- (d) => {
4422
- d.properties.distance = parseFloat(
4423
- d.properties.distance.toFixed(e)
4424
- ), d.properties.total = parseFloat(
4425
- 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)
4426
4458
  );
4427
4459
  }
4428
4460
  ), r;
@@ -4444,7 +4476,7 @@ const fe = (r) => r === "degrees" ? "°" : r === "miles" ? "mi" : r === "radians
4444
4476
  z.isochronePolygonLayerSpec?.source,
4445
4477
  z.isochroneLineLayerSpec?.source,
4446
4478
  z.isochroneLabelLayerSpec?.source
4447
- ], Ut = (r, t, e = et, i = "td") => {
4479
+ ], zt = (r, t, e = et, i = "td") => {
4448
4480
  e = e.map((s) => s.replace("{prefix}", i));
4449
4481
  const o = JSON.parse(JSON.stringify(r));
4450
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) => {
@@ -4634,26 +4666,26 @@ const Ce = (r, t, e, i) => {
4634
4666
  }
4635
4667
  return r;
4636
4668
  };
4637
- 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;
4638
4670
  function Co(r) {
4639
4671
  return r = r || 256, 2 * Math.PI * 6378137 / r;
4640
4672
  }
4641
4673
  function Po(r, t, e = { enable: !0, decimal: 1 }) {
4642
- r = zt(r);
4643
- var i = r[0], o = r[1], s = i * St / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
4644
- 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];
4645
4677
  }
4646
4678
  function So(r, t, e) {
4647
- 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;
4648
4680
  return [n, a, t];
4649
4681
  }
4650
4682
  function Ve(r, t, e) {
4651
- r = zt(r);
4683
+ r = Vt(r);
4652
4684
  var i = Po(r), o = So(i, t);
4653
4685
  return xo(o);
4654
4686
  }
4655
4687
  function Io(r, t, e) {
4656
- if (r = zt(r), t === 0)
4688
+ if (r = Vt(r), t === 0)
4657
4689
  return [0, 0, 0];
4658
4690
  var i = Ve(r, t);
4659
4691
  return Oo(i);
@@ -4695,7 +4727,7 @@ function $e(r) {
4695
4727
  throw new Error("<zoom> cannot be greater than 32");
4696
4728
  return r;
4697
4729
  }
4698
- function zt(r, t) {
4730
+ function Vt(r, t) {
4699
4731
  var e = Fo(r[0]), i = Lo(r[1]);
4700
4732
  return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
4701
4733
  }
@@ -4775,7 +4807,7 @@ class Ye {
4775
4807
  const h = c.getContext("2d");
4776
4808
  if (!h) return l(new Error("Failed to create canvas context"));
4777
4809
  h.drawImage(d, 0, 0);
4778
- const p = h.getImageData(0, 0, d.width, d.height).data, u = this.pixels2rgba(new Uint8Array(p), e, i, o), g = this.calc(u[0], u[1], u[2], u[3]);
4810
+ const u = h.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), g = this.calc(p[0], p[1], p[2], p[3]);
4779
4811
  a(g);
4780
4812
  }, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
4781
4813
  });
@@ -4791,7 +4823,7 @@ class Ye {
4791
4823
  pixels2rgba(t, e, i, o) {
4792
4824
  const s = [];
4793
4825
  for (let d = 0; d < t.length; d += 4) {
4794
- const c = t[d], h = t[d + 1], p = t[d + 2], u = t[d + 3], g = [c, h, p, u];
4826
+ const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], g = [c, h, u, p];
4795
4827
  s.push(g);
4796
4828
  }
4797
4829
  const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
@@ -4919,27 +4951,27 @@ const _o = (r, t = 8) => {
4919
4951
  s.enabled && (n = i || new ze(s.maxSize, s.ttl));
4920
4952
  let a, l = 15;
4921
4953
  if (t) {
4922
- const d = t.url, c = t.encoding ?? "mapbox", h = t.tileSize ?? 512, p = t.minzoom ?? 5;
4954
+ const d = t.url, c = t.encoding ?? "mapbox", h = t.tileSize ?? 512, u = t.minzoom ?? 5;
4923
4955
  l = t.maxzoom ?? 15;
4924
- const u = t.tms ?? !1;
4925
- a = c === "mapbox" ? new Mo(d, h, p, l, u) : new Do(d, h, p, l, u);
4956
+ const p = t.tms ?? !1;
4957
+ a = c === "mapbox" ? new Mo(d, h, u, l, p) : new Do(d, h, u, l, p);
4926
4958
  }
4927
4959
  for (const d of r)
4928
4960
  o.push(
4929
4961
  new Promise((c) => {
4930
4962
  d.geometry.type !== "Point" && c(d);
4931
- const h = d.geometry.coordinates, p = _o(h, s.precision);
4963
+ const h = d.geometry.coordinates, u = _o(h, s.precision);
4932
4964
  if (n) {
4933
- const u = n.get(p);
4934
- if (u !== void 0) {
4935
- isNaN(u) || (d.properties.elevation = u), c(d);
4965
+ const p = n.get(u);
4966
+ if (p !== void 0) {
4967
+ isNaN(p) || (d.properties.elevation = p), c(d);
4936
4968
  return;
4937
4969
  }
4938
4970
  }
4939
- a ? a.getElevation(d.geometry.coordinates, l).then((u) => {
4940
- u != null && typeof u == "number" && (n && n.set(p, u), d.properties.elevation = u), c(d);
4971
+ a ? a.getElevation(d.geometry.coordinates, l).then((p) => {
4972
+ p != null && typeof p == "number" && (n && n.set(u, p), d.properties.elevation = p), c(d);
4941
4973
  }).catch(() => {
4942
- n && n.has(p) && n.delete(p), c(d);
4974
+ n && n.has(u) && n.delete(u), c(d);
4943
4975
  }) : c(d);
4944
4976
  })
4945
4977
  );
@@ -5014,7 +5046,7 @@ class No {
5014
5046
  return await (await fetch(l)).json();
5015
5047
  }
5016
5048
  }
5017
- const Nt = [
5049
+ const Tt = [
5018
5050
  { value: "pedestrian", label: "Pedestrian" },
5019
5051
  { value: "bicycle", label: "Bicycle" },
5020
5052
  { value: "auto", label: "Car" }
@@ -5087,25 +5119,25 @@ class Wo {
5087
5119
  c = [...c, ...f];
5088
5120
  }), this.tripSummary = l.trip.summary, this.tripSummary.length = Number(this.tripSummary.length.toFixed(2)), this.tripSummary.time = Number((this.tripSummary.time / 60).toFixed());
5089
5121
  const h = [];
5090
- let p = 0, u = 0;
5122
+ let u = 0, p = 0;
5091
5123
  const g = [], y = this.geoPoint(this.tripData.map((f) => [f.lng, f.lat]));
5092
5124
  l.trip.legs.forEach((f, P) => {
5093
5125
  const I = this.decodeShape(f.shape);
5094
- h.push(...I), p += Number(f.summary.length.toFixed(2)), u += Number((f.summary.time / 60).toFixed()), g.push(...f.maneuvers);
5126
+ h.push(...I), u += Number(f.summary.length.toFixed(2)), p += Number((f.summary.time / 60).toFixed()), g.push(...f.maneuvers);
5095
5127
  const E = y.features[P + 1];
5096
5128
  E.properties = {
5097
5129
  ...E.properties,
5098
- distance: p,
5130
+ distance: u,
5099
5131
  distance_unit: i === "kilometers" ? "km" : "mi",
5100
- time: u,
5132
+ time: p,
5101
5133
  maneuvers: f.maneuvers
5102
5134
  };
5103
5135
  });
5104
- 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, {
5105
5137
  costingModel: m,
5106
- distance: p,
5138
+ distance: u,
5107
5139
  distance_unit: i === "kilometers" ? "km" : "mi",
5108
- time: u,
5140
+ time: p,
5109
5141
  maneuvers: g
5110
5142
  }), C = y.features[0];
5111
5143
  return C.properties = {
@@ -5161,7 +5193,7 @@ class Wo {
5161
5193
  * @returns the list of coordinates as [lng, lat] pairs
5162
5194
  */
5163
5195
  decodeShape(t, e = 6) {
5164
- let i = 0, o = 0, s = 0, n = [], a = 0, l = 0, d = null, c, h, p = Math.pow(10, e || 6);
5196
+ let i = 0, o = 0, s = 0, n = [], a = 0, l = 0, d = null, c, h, u = Math.pow(10, e || 6);
5165
5197
  for (; i < t.length; ) {
5166
5198
  d = null, a = 0, l = 0;
5167
5199
  do
@@ -5171,7 +5203,7 @@ class Wo {
5171
5203
  do
5172
5204
  d = t.charCodeAt(i++) - 63, l |= (d & 31) << a, a += 5;
5173
5205
  while (d >= 32);
5174
- h = l & 1 ? ~(l >> 1) : l >> 1, o += c, s += h, n.push([s / p, o / p]);
5206
+ h = l & 1 ? ~(l >> 1) : l >> 1, o += c, s += h, n.push([s / u, o / u]);
5175
5207
  }
5176
5208
  return n;
5177
5209
  }
@@ -5412,7 +5444,7 @@ class Ke {
5412
5444
  * @returns
5413
5445
  */
5414
5446
  cleanStyle(t, e) {
5415
- return Ut(
5447
+ return zt(
5416
5448
  t,
5417
5449
  e,
5418
5450
  et,
@@ -5500,18 +5532,31 @@ class Xo extends Ke {
5500
5532
  }
5501
5533
  set distanceUnit(t) {
5502
5534
  const e = this.measureOptions.distanceUnit === t;
5503
- 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();
5504
5536
  }
5505
5537
  /**
5506
- * 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.
5507
5539
  */
5508
5540
  get distancePrecision() {
5509
- return this.measureOptions.distancePrecision ?? 2;
5541
+ let t = 2;
5542
+ return this.measureOptions.distanceUnit === "degrees" && (t = 6), this.measureOptions.distancePrecision ?? t;
5510
5543
  }
5511
5544
  set distancePrecision(t) {
5512
5545
  const e = this.measureOptions.distancePrecision === t;
5513
5546
  this.measureOptions.distancePrecision = t, e || this.recalc();
5514
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
+ }
5515
5560
  /**
5516
5561
  * The unit of area can be metric (m², ha, km²) or imperial (yd², acre, mi²). Default is metric.
5517
5562
  * The measuring result will be recalculated once new value is set
@@ -5676,7 +5721,7 @@ class Xo extends Ke {
5676
5721
  const s = this.measureOptions.lineLayerLabelSpec?.source;
5677
5722
  s && i.push(s);
5678
5723
  const n = this.measureOptions.pointLayerLabelSpec?.source;
5679
- return n && i.push(n), Ut(
5724
+ return n && i.push(n), zt(
5680
5725
  t,
5681
5726
  e,
5682
5727
  i,
@@ -5916,7 +5961,7 @@ class Xo extends Ke {
5916
5961
  (a) => a.properties?.originalId !== t
5917
5962
  ));
5918
5963
  const n = JSON.parse(JSON.stringify(o));
5919
- 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(
5920
5965
  this.measureOptions.polygonLayerSpec.source
5921
5966
  )?.setData(s.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
5922
5967
  this.measureOptions.lineLayerLabelSpec.id
@@ -5950,6 +5995,7 @@ class Xo extends Ke {
5950
5995
  o,
5951
5996
  this.distanceUnit,
5952
5997
  this.distancePrecision,
5998
+ this.forceDistanceUnit,
5953
5999
  this.map,
5954
6000
  this.computeElevation,
5955
6001
  this.measureOptions.terrainSource
@@ -5958,17 +6004,17 @@ class Xo extends Ke {
5958
6004
  for (let a = 0; a < n.length; a++) {
5959
6005
  const l = n[a], d = l.geometry.coordinates, c = d[0], h = d[1];
5960
6006
  if (a === 0) {
5961
- const u = JSON.parse(JSON.stringify(l));
5962
- u.id = `${l.id}-node-${a}`, u.geometry = {
6007
+ const p = JSON.parse(JSON.stringify(l));
6008
+ p.id = `${l.id}-node-${a}`, p.geometry = {
5963
6009
  type: "Point",
5964
6010
  coordinates: c
5965
- }, u.properties.distance = 0, u.properties.total = 0, l.properties.elevation_start && (u.properties.elevation = l.properties.elevation_start), typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(u);
6011
+ }, p.properties.distance = 0, p.properties.total = 0, l.properties.elevation_start && (p.properties.elevation = l.properties.elevation_start), typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(p);
5966
6012
  }
5967
- const p = JSON.parse(JSON.stringify(l));
5968
- p.id = `${l.id}-node-${a + 1}`, p.geometry = {
6013
+ const u = JSON.parse(JSON.stringify(l));
6014
+ u.id = `${l.id}-node-${a + 1}`, u.geometry = {
5969
6015
  type: "Point",
5970
6016
  coordinates: h
5971
- }, l.properties.elevation_end && (p.properties.elevation = l.properties.elevation_end), typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(p);
6017
+ }, l.properties.elevation_end && (u.properties.elevation = l.properties.elevation_end), typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(u);
5972
6018
  }
5973
6019
  this.map.getSource(
5974
6020
  this.measureOptions.lineLayerLabelSpec.source
@@ -6042,10 +6088,11 @@ class Xo extends Ke {
6042
6088
  o,
6043
6089
  this.distanceUnit,
6044
6090
  this.distancePrecision,
6091
+ this.forceDistanceUnit,
6045
6092
  this.map,
6046
6093
  this.computeElevation,
6047
6094
  this.measureOptions.terrainSource
6048
- ) : 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(
6049
6096
  o,
6050
6097
  this.map,
6051
6098
  this.computeElevation,
@@ -6254,7 +6301,7 @@ class Ho extends Ke {
6254
6301
  const i = et, o = this.controlOptions.routingLineLayerNodeSpec?.source;
6255
6302
  o && i.push(o);
6256
6303
  const s = this.controlOptions.isochronePolygonLayerSpec?.source;
6257
- 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);
6258
6305
  }
6259
6306
  /**
6260
6307
  * Create the settings dialog for Valhalla control
@@ -6302,7 +6349,7 @@ class Ho extends Ke {
6302
6349
  const i = document.createElement("label");
6303
6350
  i.textContent = "Means of Transport", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
6304
6351
  this.settingDialog.createSegmentButtons(
6305
- Nt,
6352
+ Tt,
6306
6353
  this.routingCostingModel,
6307
6354
  (n) => {
6308
6355
  this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.costingModel = n, this.dispatchEvent("setting-changed");
@@ -6343,7 +6390,7 @@ class Ho extends Ke {
6343
6390
  const s = document.createElement("label");
6344
6391
  s.textContent = "Means of Transport", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
6345
6392
  this.settingDialog.createSegmentButtons(
6346
- Nt,
6393
+ Tt,
6347
6394
  this.controlOptions.valhallaOptions?.isochroneOptions?.costingModel || "auto",
6348
6395
  (d) => {
6349
6396
  this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.costingModel = d, this.dispatchEvent("setting-changed");
@@ -6374,15 +6421,15 @@ class Ho extends Ke {
6374
6421
  const l = document.createElement("th");
6375
6422
  o.appendChild(l), i.appendChild(o), e.appendChild(i);
6376
6423
  const d = document.createElement("tbody"), c = this.controlOptions.valhallaOptions?.isochroneOptions?.contours;
6377
- c.forEach((p, u) => {
6378
- const g = this.createContourRow(p, u);
6424
+ c.forEach((u, p) => {
6425
+ const g = this.createContourRow(u, p);
6379
6426
  d.appendChild(g);
6380
6427
  }), e.appendChild(d), t.appendChild(e);
6381
6428
  const h = document.createElement("button");
6382
- return h.type = "button", h.classList.add("add-row-button"), h.textContent = "Add Contour", h.hidden = c.length >= 4, h.addEventListener("click", (p) => {
6383
- p.stopPropagation();
6384
- const u = this.valhallaOptions.isochroneOptions?.contours, g = JSON.parse(JSON.stringify(u[u.length - 1])), y = d.children.length, m = this.createContourRow(g, y);
6385
- d.appendChild(m), u.push(g), this.updateAddRowButtonState(), this.dispatchEvent("setting-changed");
6429
+ return h.type = "button", h.classList.add("add-row-button"), h.textContent = "Add Contour", h.hidden = c.length >= 4, h.addEventListener("click", (u) => {
6430
+ u.stopPropagation();
6431
+ const p = this.valhallaOptions.isochroneOptions?.contours, g = JSON.parse(JSON.stringify(p[p.length - 1])), y = d.children.length, m = this.createContourRow(g, y);
6432
+ d.appendChild(m), p.push(g), this.updateAddRowButtonState(), this.dispatchEvent("setting-changed");
6386
6433
  }), t.appendChild(h), t;
6387
6434
  }
6388
6435
  /**
@@ -6410,10 +6457,10 @@ class Ho extends Ke {
6410
6457
  const c = document.createElement("td");
6411
6458
  if (e > 0) {
6412
6459
  const h = document.createElement("button");
6413
- h.type = "button", h.textContent = "×", h.classList.add("delete-button"), h.addEventListener("click", (p) => {
6414
- p.stopPropagation();
6415
- const u = parseInt(i.getAttribute("data-index") || "0");
6416
- i.remove(), this.valhallaOptions.isochroneOptions?.contours && this.valhallaOptions.isochroneOptions.contours.splice(u, 1);
6460
+ h.type = "button", h.textContent = "×", h.classList.add("delete-button"), h.addEventListener("click", (u) => {
6461
+ u.stopPropagation();
6462
+ const p = parseInt(i.getAttribute("data-index") || "0");
6463
+ i.remove(), this.valhallaOptions.isochroneOptions?.contours && this.valhallaOptions.isochroneOptions.contours.splice(p, 1);
6417
6464
  const g = i.parentElement;
6418
6465
  g && Array.from(g.children).forEach((y, m) => {
6419
6466
  y.setAttribute("data-index", m.toString());
@@ -6650,20 +6697,19 @@ export {
6650
6697
  Yo as TERRADRAW_VALHALLA_SOURCE_IDS,
6651
6698
  No as ValhallaIsochrone,
6652
6699
  Wo as ValhallaRouting,
6653
- ge as calcArea,
6700
+ ye as calcArea,
6654
6701
  me as calcDistance,
6655
6702
  ve as capitalize,
6656
- Ut as cleanMaplibreStyle,
6703
+ zt as cleanMaplibreStyle,
6657
6704
  ko as contourTypeOptions,
6658
6705
  po as convertAreaUnit,
6659
- Ft as convertMetricDistance,
6660
- Nt as costingModelOptions,
6706
+ Mt as convertDistance,
6707
+ Tt as costingModelOptions,
6661
6708
  Ue as debounce,
6662
6709
  to as defaultControlOptions,
6663
6710
  lt as defaultMeasureControlOptions,
6664
6711
  z as defaultValhallaControlOptions,
6665
6712
  eo as getDefaultModeOptions,
6666
- fe as getDistanceUnitName,
6667
6713
  Ce as queryElevationByPoint,
6668
6714
  Pe as queryElevationFromRasterDEM,
6669
6715
  Ko as roundFeatureCoordinates,