@watergis/maplibre-gl-terradraw 1.3.7 → 1.3.9

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.
@@ -15,8 +15,8 @@ var M;
15
15
  (function(s) {
16
16
  s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
17
17
  })(M || (M = {}));
18
- const V = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, U = "edited", st = "closingPoint", _t = "snappingPoint", Lt = "coordinatePoint", kt = "coordinatePointIds";
19
- function Mt(s) {
18
+ const T = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, V = "edited", st = "closingPoint", Lt = "snappingPoint", kt = "coordinatePoint", rt = "coordinatePointIds";
19
+ function wt(s) {
20
20
  return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
21
21
  }
22
22
  function zt(s) {
@@ -27,11 +27,11 @@ function Xt(s) {
27
27
  return typeof t == "number" && !isNaN(new Date(t).valueOf());
28
28
  }(s);
29
29
  }
30
- const Ye = "Feature mode property does not match the mode being added to";
31
- var $;
30
+ const $e = "Feature mode property does not match the mode being added to";
31
+ var Y;
32
32
  (function(s) {
33
33
  s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
34
- })($ || ($ = {}));
34
+ })(Y || (Y = {}));
35
35
  let N = class {
36
36
  get state() {
37
37
  return this._state;
@@ -49,7 +49,7 @@ let N = class {
49
49
  registerBehaviors(t) {
50
50
  }
51
51
  constructor(t, e = !1) {
52
- this._state = "unregistered", this._styles = {}, this.behaviors = [], this.validate = void 0, this.pointerDistance = 40, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.projection = "web-mercator", this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.type = $.Drawing, this.mode = "base", e || this.updateOptions(t);
52
+ this._state = "unregistered", this._styles = {}, this.behaviors = [], this.validate = void 0, this.pointerDistance = 40, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.projection = "web-mercator", this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.type = Y.Drawing, this.mode = "base", e || this.updateOptions(t);
53
53
  }
54
54
  updateOptions(t) {
55
55
  t != null && t.styles && (this.styles = I({}, this._styles, t.styles)), t != null && t.pointerDistance && (this.pointerDistance = t.pointerDistance), t != null && t.validation && (this.validate = t && t.validation), t != null && t.projection && (this.projection = t.projection);
@@ -79,9 +79,9 @@ let N = class {
79
79
  if (this._state === "unregistered") throw new Error("Mode must be registered");
80
80
  const e = function(i, o) {
81
81
  let r;
82
- if (Mt(i)) if (i.id == null) r = "Feature has no id";
82
+ if (wt(i)) if (i.id == null) r = "Feature has no id";
83
83
  else if (typeof i.id != "string" && typeof i.id != "number") r = "Feature must be string or number as per GeoJSON spec";
84
- else if (o(i.id)) if (Mt(i.geometry)) if (Mt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
84
+ else if (o(i.id)) if (wt(i.geometry)) if (wt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
85
85
  if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
86
86
  } else r = "Feature coordinates is not an array";
87
87
  else r = "Feature is not Point, LineString or Polygon";
@@ -99,7 +99,7 @@ let N = class {
99
99
  }
100
100
  validateModeFeature(t, e) {
101
101
  const i = this.performFeatureValidation(t);
102
- return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Ye } : e(t) : { valid: !1, reason: i.reason };
102
+ return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: $e } : e(t) : { valid: !1, reason: i.reason };
103
103
  }
104
104
  onFinish(t, e) {
105
105
  }
@@ -130,12 +130,12 @@ let N = class {
130
130
  getStylingValue(t, e, i) {
131
131
  return t === void 0 ? e : typeof t == "function" ? t(i) : t;
132
132
  }
133
- }, $e = class extends N {
133
+ }, Ye = class extends N {
134
134
  constructor(...t) {
135
- super(...t), this.type = $.Select;
135
+ super(...t), this.type = Y.Select;
136
136
  }
137
137
  };
138
- function T(s, t) {
138
+ function U(s, t) {
139
139
  const e = (d) => d * Math.PI / 180, i = e(s[1]), o = e(s[0]), r = e(t[1]), n = r - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(r) * Math.sin(a / 2) * Math.sin(a / 2);
140
140
  return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
141
141
  }
@@ -153,12 +153,12 @@ function F(s, t = 9) {
153
153
  const e = Math.pow(10, t);
154
154
  return Math.round(s * e) / e;
155
155
  }
156
- const Kt = 57.29577951308232, Yt = 0.017453292519943295, ft = 6378137, x = (s, t) => ({ x: s === 0 ? 0 : s * Yt * ft, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Yt / 2)) * ft }), W = (s, t) => ({ lng: s === 0 ? 0 : Kt * (s / ft), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ft)) - Math.PI / 2) * Kt });
156
+ const Kt = 57.29577951308232, $t = 0.017453292519943295, mt = 6378137, x = (s, t) => ({ x: s === 0 ? 0 : s * $t * mt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * $t / 2)) * mt }), W = (s, t) => ({ lng: s === 0 ? 0 : Kt * (s / mt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / mt)) - Math.PI / 2) * Kt });
157
157
  function He(s, t, e) {
158
158
  const i = O(s[0]), o = O(s[1]), r = O(e), n = ve(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
159
159
  return [R(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), R(a)];
160
160
  }
161
- function $t(s) {
161
+ function Yt(s) {
162
162
  const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, r = [];
163
163
  for (let n = 0; n < o; n++) {
164
164
  const a = He(t, e, -360 * n / o);
@@ -181,7 +181,7 @@ function Bt(s) {
181
181
  }
182
182
  function o(r, n, a, l) {
183
183
  const d = t[r][n], h = t[r][n + 1], c = t[a][l], u = t[a][l + 1], p = function(m, v, f, C) {
184
- if (ht(m, f) || ht(m, C) || ht(v, f) || ht(C, f)) return null;
184
+ if (ct(m, f) || ct(m, C) || ct(v, f) || ct(C, f)) return null;
185
185
  const P = m[0], S = m[1], b = v[0], w = v[1], D = f[0], G = f[1], _ = C[0], j = C[1], z = (P - b) * (G - j) - (S - w) * (D - _);
186
186
  return z === 0 ? null : [((P * w - S * b) * (D - _) - (P - b) * (D * j - G * _)) / z, ((P * w - S * b) * (G - j) - (S - w) * (D * j - G * _)) / z];
187
187
  }(d, h, c, u);
@@ -190,10 +190,10 @@ function Bt(s) {
190
190
  g = h[0] !== d[0] ? (p[0] - d[0]) / (h[0] - d[0]) : (p[1] - d[1]) / (h[1] - d[1]), y = u[0] !== c[0] ? (p[0] - c[0]) / (u[0] - c[0]) : (p[1] - c[1]) / (u[1] - c[1]), i(g) || i(y) || (p.toString(), e.push(p));
191
191
  }
192
192
  }
193
- function ht(s, t) {
193
+ function ct(s, t) {
194
194
  return s[0] === t[0] && s[1] === t[1];
195
195
  }
196
- function xt(s, t) {
196
+ function It(s, t) {
197
197
  return Ht(s[0]) <= t && Ht(s[1]) <= t;
198
198
  }
199
199
  function Wt(s) {
@@ -205,20 +205,20 @@ function Ht(s) {
205
205
  for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
206
206
  return e;
207
207
  }
208
- const qe = "Feature has holes", Je = "Feature has less than 4 coordinates", Ze = "Feature has invalid coordinates", Qe = "Feature coordinates are not closed";
209
- function It(s, t) {
208
+ const Je = "Feature has holes", qe = "Feature has less than 4 coordinates", Ze = "Feature has invalid coordinates", Qe = "Feature coordinates are not closed";
209
+ function bt(s, t) {
210
210
  if (s.geometry.type !== "Polygon") return { valid: !1, reason: "Feature is not a Polygon" };
211
- if (s.geometry.coordinates.length !== 1) return { valid: !1, reason: qe };
212
- if (s.geometry.coordinates[0].length < 4) return { valid: !1, reason: Je };
211
+ if (s.geometry.coordinates.length !== 1) return { valid: !1, reason: Je };
212
+ if (s.geometry.coordinates[0].length < 4) return { valid: !1, reason: qe };
213
213
  for (let o = 0; o < s.geometry.coordinates[0].length; o++) {
214
214
  if (!Wt(s.geometry.coordinates[0][o])) return { valid: !1, reason: Ze };
215
- if (!xt(s.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
215
+ if (!It(s.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
216
216
  }
217
217
  return (e = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: Qe } : { valid: !0 };
218
218
  var e, i;
219
219
  }
220
- function lt(s, t) {
221
- const e = It(s, t);
220
+ function dt(s, t) {
221
+ const e = bt(s, t);
222
222
  return e.valid ? Bt(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
223
223
  }
224
224
  const ti = { cancel: "Escape", finish: "Enter" }, ei = { start: "crosshair" };
@@ -247,7 +247,7 @@ class Ce extends N {
247
247
  onClick(t) {
248
248
  if (this.clickCount === 0) {
249
249
  this.center = [t.lng, t.lat];
250
- const e = $t({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
250
+ const e = Yt({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
251
251
  this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
252
252
  } else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
253
253
  }
@@ -278,15 +278,15 @@ class Ce extends N {
278
278
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
279
279
  }
280
280
  validateFeature(t) {
281
- return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
281
+ return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
282
282
  }
283
283
  updateCircle(t) {
284
284
  if (this.clickCount === 1 && this.center && this.currentCircleId) {
285
- const e = T(this.center, [t.lng, t.lat]);
285
+ const e = U(this.center, [t.lng, t.lat]);
286
286
  let i;
287
287
  if (this.projection === "web-mercator") {
288
288
  const o = function(r, n) {
289
- const a = 1e3 * T(r, n);
289
+ const a = 1e3 * U(r, n);
290
290
  if (a === 0) return 1;
291
291
  const { x: l, y: d } = x(r[0], r[1]), { x: h, y: c } = x(n[0], n[1]);
292
292
  return Math.sqrt(Math.pow(h - l, 2) + Math.pow(c - d, 2)) / a;
@@ -301,7 +301,7 @@ class Ce extends N {
301
301
  }({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
302
302
  } else {
303
303
  if (this.projection !== "globe") throw new Error("Invalid projection");
304
- i = $t({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
304
+ i = Yt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
305
305
  }
306
306
  if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid) return;
307
307
  this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
@@ -312,7 +312,7 @@ const E = (s, t) => {
312
312
  const { x: e, y: i } = s, { x: o, y: r } = t, n = o - e, a = r - i;
313
313
  return Math.sqrt(a * a + n * n);
314
314
  };
315
- function dt(s) {
315
+ function ht(s) {
316
316
  if (!function(e) {
317
317
  const i = e.coordinates[0];
318
318
  let o = 0;
@@ -334,7 +334,7 @@ class Pe extends N {
334
334
  close() {
335
335
  if (this.currentId === void 0) return;
336
336
  if (this.currentId) {
337
- const e = dt(this.store.getGeometryCopy(this.currentId));
337
+ const e = ht(this.store.getGeometryCopy(this.currentId));
338
338
  e && this.store.updateGeometry([{ id: this.currentId, geometry: e }]);
339
339
  }
340
340
  const t = this.currentId;
@@ -396,7 +396,7 @@ class Pe extends N {
396
396
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e) : (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 40), e);
397
397
  }
398
398
  validateFeature(t) {
399
- return this.validateModeFeature(t, (e) => It(e, this.coordinatePrecision));
399
+ return this.validateModeFeature(t, (e) => bt(e, this.coordinatePrecision));
400
400
  }
401
401
  }
402
402
  class k {
@@ -408,7 +408,7 @@ function Se({ unproject: s, point: t, pointerDistance: e }) {
408
408
  const i = e / 2, { x: o, y: r } = t;
409
409
  return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[s(o - i, r - i), s(o + i, r - i), s(o + i, r + i), s(o - i, r + i), s(o - i, r - i)].map((n) => [n.lng, n.lat])] } };
410
410
  }
411
- class rt extends k {
411
+ class nt extends k {
412
412
  constructor(t) {
413
413
  super(t);
414
414
  }
@@ -417,7 +417,7 @@ class rt extends k {
417
417
  return Se({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
418
418
  }
419
419
  }
420
- class nt extends k {
420
+ class at extends k {
421
421
  constructor(t) {
422
422
  super(t);
423
423
  }
@@ -426,7 +426,7 @@ class nt extends k {
426
426
  return E({ x: i, y: o }, { x: t.containerX, y: t.containerY });
427
427
  }
428
428
  }
429
- class mt extends k {
429
+ class vt extends k {
430
430
  constructor(t, e, i) {
431
431
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
432
432
  }
@@ -446,15 +446,15 @@ class mt extends k {
446
446
  }), r;
447
447
  }
448
448
  }
449
- function qt(s, t, e) {
449
+ function Jt(s, t, e) {
450
450
  const i = O(s[0]), o = O(s[1]), r = O(e), n = ve(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
451
451
  return [R(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), R(a)];
452
452
  }
453
- function at({ x: s, y: t }, e, i) {
453
+ function lt({ x: s, y: t }, e, i) {
454
454
  const o = O(i);
455
455
  return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
456
456
  }
457
- function Jt(s, t) {
457
+ function qt(s, t) {
458
458
  const e = O(s[0]), i = O(t[0]), o = O(s[1]), r = O(t[1]), n = Math.sin(i - e) * Math.cos(r), a = Math.cos(o) * Math.sin(r) - Math.sin(o) * Math.cos(r) * Math.cos(i - e);
459
459
  return R(Math.atan2(n, a));
460
460
  }
@@ -462,7 +462,7 @@ function A({ x: s, y: t }, { x: e, y: i }) {
462
462
  let o = Math.atan2(i - t, e - s);
463
463
  return o *= 180 / Math.PI, o > 180 ? o -= 360 : o < -180 && (o += 360), o;
464
464
  }
465
- function Y(s) {
465
+ function $(s) {
466
466
  return (s + 360) % 360;
467
467
  }
468
468
  function si(s, t, e) {
@@ -471,17 +471,17 @@ function si(s, t, e) {
471
471
  for (let h = 0; h < s.length && !(t >= l && h === s.length - 1); h++) {
472
472
  if (l > t && i.length === 0) {
473
473
  if (r = t - l, !r) return i.push(s[h]), i;
474
- n = Jt(s[h], s[h - 1]) - 180, a = qt(s[h], r, n), i.push(a);
474
+ n = qt(s[h], s[h - 1]) - 180, a = Jt(s[h], r, n), i.push(a);
475
475
  }
476
- if (l >= e) return r = e - l, r ? (n = Jt(s[h], s[h - 1]) - 180, a = qt(s[h], r, n), i.push(a), i) : (i.push(s[h]), i);
476
+ if (l >= e) return r = e - l, r ? (n = qt(s[h], s[h - 1]) - 180, a = Jt(s[h], r, n), i.push(a), i) : (i.push(s[h]), i);
477
477
  if (l >= t && i.push(s[h]), h === s.length - 1) return i;
478
- l += T(s[h], s[h + 1]);
478
+ l += U(s[h], s[h + 1]);
479
479
  }
480
480
  if (l < t && s.length === o) throw new Error("Start position is beyond line");
481
481
  const d = s[s.length - 1];
482
482
  return [d, d];
483
483
  }
484
- function ct(s) {
484
+ function ut(s) {
485
485
  return s * (Math.PI / 180);
486
486
  }
487
487
  function Zt(s) {
@@ -494,7 +494,7 @@ class ri extends k {
494
494
  generateInsertionCoordinates(t, e, i) {
495
495
  const o = [t, e];
496
496
  let r = 0;
497
- for (let d = 0; d < o.length - 1; d++) r += T(o[0], o[1]);
497
+ for (let d = 0; d < o.length - 1; d++) r += U(o[0], o[1]);
498
498
  if (r <= i) return o;
499
499
  let n = r / i - 1;
500
500
  Number.isInteger(n) || (n = Math.floor(n) + 1);
@@ -508,8 +508,8 @@ class ri extends k {
508
508
  return this.limitCoordinates(l);
509
509
  }
510
510
  generateInsertionGeodesicCoordinates(t, e, i) {
511
- const o = T(t, e), r = function(n, a, l) {
512
- const d = [], h = ct(n[1]), c = ct(n[0]), u = ct(a[1]), p = ct(a[0]);
511
+ const o = U(t, e), r = function(n, a, l) {
512
+ const d = [], h = ut(n[1]), c = ut(n[0]), u = ut(a[1]), p = ut(a[0]);
513
513
  l += 1;
514
514
  const g = 2 * Math.asin(Math.sqrt(Math.sin((u - h) / 2) ** 2 + Math.cos(h) * Math.cos(u) * Math.sin((p - c) / 2) ** 2));
515
515
  if (g === 0 || isNaN(g)) return d;
@@ -535,7 +535,7 @@ function xe(s, t) {
535
535
  if (s.geometry.coordinates.length < 2) return { valid: !1, reason: "Feature has less than 2 coordinates" };
536
536
  for (let e = 0; e < s.geometry.coordinates.length; e++) {
537
537
  if (!Wt(s.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
538
- if (!xt(s.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
538
+ if (!It(s.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
539
539
  }
540
540
  return { valid: !0 };
541
541
  }
@@ -549,7 +549,7 @@ function X(s, t) {
549
549
  }(s, t) / (Qt(s) * Qt(t));
550
550
  return Math.acos(Math.min(Math.max(e, -1), 1));
551
551
  }
552
- function wt(s) {
552
+ function Ft(s) {
553
553
  const t = O(s[1]), e = O(s[0]);
554
554
  return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
555
555
  }
@@ -558,12 +558,12 @@ function K(s) {
558
558
  return [R(Math.atan2(e, t)), o];
559
559
  }
560
560
  function ni(s, t, e) {
561
- const i = wt(s), o = wt(t), r = wt(e), [n, a, l] = r, [d, h, c] = function(j, z) {
561
+ const i = Ft(s), o = Ft(t), r = Ft(e), [n, a, l] = r, [d, h, c] = function(j, z) {
562
562
  const [Gt, At, Tt] = j, [Ut, Vt, Rt] = z;
563
563
  return [At * Rt - Tt * Vt, Tt * Ut - Gt * Rt, Gt * Vt - At * Ut];
564
564
  }(i, o), u = h * l - c * a, p = c * n - d * l, g = d * a - h * n, y = g * h - p * c, m = u * c - g * d, v = p * d - u * h, f = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(m, 2) + Math.pow(v, 2)), C = [y * f, m * f, v * f], P = [-1 * y * f, -1 * m * f, -1 * v * f], S = X(i, o), b = X(i, C), w = X(o, C), D = X(i, P), G = X(o, P);
565
565
  let _;
566
- return _ = b < D && b < G || w < D && w < G ? C : P, X(i, _) > S || X(o, _) > S ? T(K(_), K(i)) <= T(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
566
+ return _ = b < D && b < G || w < D && w < G ? C : P, X(i, _) > S || X(o, _) > S ? U(K(_), K(i)) <= U(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
567
567
  }
568
568
  function ai(s, t, e) {
569
569
  const i = t.x - s.x, o = t.y - s.y, r = Math.max(0, Math.min(1, ((e.x - s.x) * i + (e.y - s.y) * o) / (i * i + o * o)));
@@ -606,7 +606,7 @@ class Ie extends k {
606
606
  for (let v of p) {
607
607
  const f = v[0], C = v[1];
608
608
  let P, S = 1 / 0;
609
- f[0] === u[0] && f[1] === u[1] ? P = f : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = ni(f, C, u), P && (S = T(u, P), S < y && (g = P, y = S, m = p.indexOf(v)));
609
+ f[0] === u[0] && f[1] === u[1] ? P = f : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = ni(f, C, u), P && (S = U(u, P), S < y && (g = P, y = S, m = p.indexOf(v)));
610
610
  }
611
611
  return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: m };
612
612
  }(h, l)), !d) return;
@@ -640,7 +640,7 @@ class be extends N {
640
640
  generateInsertCoordinates(t, e) {
641
641
  if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
642
642
  if (this.insertCoordinates.strategy !== "amount") throw new Error("Strategy does not exist");
643
- const i = T(t, e) / (this.insertCoordinates.value + 1);
643
+ const i = U(t, e) / (this.insertCoordinates.value + 1);
644
644
  let o = [];
645
645
  return this.projection === "globe" ? o = this.insertPoint.generateInsertionGeodesicCoordinates(t, e, i) : this.projection === "web-mercator" && (o = this.insertPoint.generateInsertionCoordinates(t, e, i)), o;
646
646
  }
@@ -664,7 +664,7 @@ class be extends N {
664
664
  this.updateGeometries(l, i[i.length - 1], M.Commit), this.currentCoordinate++;
665
665
  }
666
666
  registerBehaviors(t) {
667
- this.coordinateSnapping = new mt(t, new nt(t), new rt(t)), this.insertPoint = new ri(t), this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new Ie(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new mt(t, this.pixelDistance, this.clickBoundingBox);
667
+ this.coordinateSnapping = new vt(t, new at(t), new nt(t)), this.insertPoint = new ri(t), this.clickBoundingBox = new nt(t), this.pixelDistance = new at(t), this.lineSnapping = new Ie(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new vt(t, this.pixelDistance, this.clickBoundingBox);
668
668
  }
669
669
  start() {
670
670
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -678,7 +678,7 @@ class be extends N {
678
678
  if (e) {
679
679
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
680
680
  else {
681
- const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [_t]: !0 } }]);
681
+ const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Lt]: !0 } }]);
682
682
  this.snappedPointId = n;
683
683
  }
684
684
  t.lng = e[0], t.lat = e[1];
@@ -735,7 +735,7 @@ class be extends N {
735
735
  }
736
736
  if (this.editedFeatureId && i) {
737
737
  if (!this.editedPointId) {
738
- const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [U]: !0 } }]);
738
+ const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [V]: !0 } }]);
739
739
  this.editedPointId = o;
740
740
  }
741
741
  this.setCursor(this.cursors.dragStart), e(!1);
@@ -746,10 +746,10 @@ class be extends N {
746
746
  const i = this.store.getGeometryCopy(this.editedFeatureId);
747
747
  this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? i.coordinates[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates.splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
748
748
  const o = { type: "LineString", coordinates: i.coordinates };
749
- this.validate && !this.validate({ type: "Feature", geometry: o, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: o }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: U, value: !0 }]), e(!0));
749
+ this.validate && !this.validate({ type: "Feature", geometry: o, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: o }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !0 }]), e(!0));
750
750
  }
751
751
  onDragEnd(t, e) {
752
- this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: U, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
752
+ this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
753
753
  }
754
754
  cleanUp() {
755
755
  const t = this.currentId, e = this.closingPointId, i = this.snappedPointId;
@@ -782,7 +782,7 @@ class be extends N {
782
782
  }
783
783
  const hi = "Feature is not a Point", ci = "Feature has invalid coordinates", ui = "Feature has coordinates with excessive precision";
784
784
  function Me(s, t) {
785
- return s.geometry.type !== "Point" ? { valid: !1, reason: hi } : Wt(s.geometry.coordinates) ? xt(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: ui } : { valid: !1, reason: ci };
785
+ return s.geometry.type !== "Point" ? { valid: !1, reason: hi } : Wt(s.geometry.coordinates) ? It(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: ui } : { valid: !1, reason: ci };
786
786
  }
787
787
  const pi = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
788
788
  class we extends N {
@@ -819,13 +819,13 @@ class we extends N {
819
819
  this.editedFeatureId && (this.setCursor(this.cursors.dragStart), e(!1));
820
820
  }
821
821
  onDrag(t, e) {
822
- this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: U, value: !0 }]), e(!0)));
822
+ this.editedFeatureId !== void 0 && (this.validate && !this.validate({ type: "Feature", geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Finish }).valid || (this.store.updateGeometry([{ id: this.editedFeatureId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !0 }]), e(!0)));
823
823
  }
824
824
  onDragEnd(t, e) {
825
- this.editedFeatureId !== void 0 && (this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.setCursor(this.cursors.dragEnd), this.store.updateProperty([{ id: this.editedFeatureId, property: U, value: !1 }]), this.editedFeatureId = void 0, e(!0));
825
+ this.editedFeatureId !== void 0 && (this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.setCursor(this.cursors.dragEnd), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !1 }]), this.editedFeatureId = void 0, e(!0));
826
826
  }
827
827
  registerBehaviors(t) {
828
- this.pixelDistance = new nt(t), this.clickBoundingBox = new rt(t);
828
+ this.pixelDistance = new at(t), this.clickBoundingBox = new nt(t);
829
829
  }
830
830
  styleFeature(t) {
831
831
  const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
@@ -899,19 +899,25 @@ class Fe extends k {
899
899
  if (e.type !== "LineString") return;
900
900
  o = e.coordinates;
901
901
  }
902
- const r = this.store.getPropertiesCopy(t);
903
- if (r.coordinatePointIds) {
904
- const n = r.coordinatePointIds, a = n.map((l) => this.store.getGeometryCopy(l).coordinates);
905
- if (n.length !== o.length) {
906
- this.deleteCoordinatePoints(n);
907
- const l = this.createPoints(o, i.mode);
908
- this.setFeatureCoordinatePoints(t, l);
909
- } else o.forEach((l, d) => {
910
- l[0] === a[d][0] && l[1] === a[d][1] || this.store.updateGeometry([{ id: n[d], geometry: { type: "Point", coordinates: l } }]);
902
+ const r = this.store.getPropertiesCopy(t), n = r.coordinatePointIds;
903
+ if (n) if (n && n.every((a) => this.store.has(a))) {
904
+ const a = r.coordinatePointIds, l = a.map((d) => this.store.getGeometryCopy(d).coordinates);
905
+ if (a.length !== o.length) {
906
+ this.deleteCoordinatePoints(a);
907
+ const d = this.createPoints(o, i.mode);
908
+ this.setFeatureCoordinatePoints(t, d);
909
+ } else o.forEach((d, h) => {
910
+ d[0] === l[h][0] && d[1] === l[h][1] || this.store.updateGeometry([{ id: a[h], geometry: { type: "Point", coordinates: d } }]);
911
911
  });
912
912
  } else {
913
- const n = this.createPoints(o, i.mode);
914
- this.setFeatureCoordinatePoints(t, n);
913
+ const a = n.filter((d) => this.store.has(d));
914
+ a.length && this.deleteCoordinatePoints(a);
915
+ const l = this.createPoints(o, i.mode);
916
+ this.setFeatureCoordinatePoints(t, l);
917
+ }
918
+ else {
919
+ const a = this.createPoints(o, i.mode);
920
+ this.setFeatureCoordinatePoints(t, a);
915
921
  }
916
922
  }
917
923
  deletePointsByFeatureIds(t) {
@@ -922,17 +928,18 @@ class Fe extends k {
922
928
  if (i.coordinatePointIds) return i.coordinatePointIds.map((o, r) => ({ id: o, geometry: I({}, this.store.getGeometryCopy(o), { coordinates: e[r] }) }));
923
929
  }
924
930
  createPoints(t, e) {
925
- return this.store.create(t.map((i) => ({ geometry: { type: "Point", coordinates: i }, properties: { mode: e, [Lt]: !0 } })));
931
+ return this.store.create(t.map((i) => ({ geometry: { type: "Point", coordinates: i }, properties: { mode: e, [kt]: !0 } })));
926
932
  }
927
933
  setFeatureCoordinatePoints(t, e) {
928
- this.store.updateProperty([{ id: t, property: kt, value: e }]);
934
+ this.store.updateProperty([{ id: t, property: rt, value: e }]);
929
935
  }
930
936
  deleteCoordinatePoints(t) {
931
- this.store.delete(t);
937
+ const e = t.filter((i) => this.store.has(i));
938
+ this.store.delete(e);
932
939
  }
933
940
  deleteIfPresent(t) {
934
- const e = this.store.getPropertiesCopy(t);
935
- e.coordinatePointIds && (this.deleteCoordinatePoints(e.coordinatePointIds), this.setFeatureCoordinatePoints(t, null));
941
+ const e = this.store.getPropertiesCopy(t).coordinatePointIds;
942
+ e && (this.deleteCoordinatePoints(e), this.setFeatureCoordinatePoints(t, null));
936
943
  }
937
944
  }
938
945
  const yi = { cancel: "Escape", finish: "Enter" }, fi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
@@ -946,7 +953,7 @@ class Ee extends N {
946
953
  this.coordinatePoints.createOrUpdate(e);
947
954
  });
948
955
  else if (this.coordinatePoints && this.showCoordinatePoints === !1) {
949
- const e = this.store.copyAllWhere((i) => i.mode === this.mode && !!i[kt]);
956
+ const e = this.store.copyAllWhere((i) => i.mode === this.mode && !!i[rt]);
950
957
  this.coordinatePoints.deletePointsByFeatureIds(e.map((i) => i.id));
951
958
  }
952
959
  }
@@ -957,13 +964,13 @@ class Ee extends N {
957
964
  if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], M.Finish)) return;
958
965
  const e = this.currentId;
959
966
  if (this.currentId) {
960
- const i = dt(this.store.getGeometryCopy(this.currentId));
967
+ const i = ht(this.store.getGeometryCopy(this.currentId));
961
968
  i && this.store.updateGeometry([{ id: this.currentId, geometry: i }]);
962
969
  }
963
970
  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" });
964
971
  }
965
972
  registerBehaviors(t) {
966
- this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new Ie(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new mt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new gi(t, this.pixelDistance), this.coordinatePoints = new Fe(t);
973
+ this.clickBoundingBox = new nt(t), this.pixelDistance = new at(t), this.lineSnapping = new Ie(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new vt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new gi(t, this.pixelDistance), this.coordinatePoints = new Fe(t);
967
974
  }
968
975
  start() {
969
976
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -977,7 +984,7 @@ class Ee extends N {
977
984
  if (e) {
978
985
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
979
986
  else {
980
- const [r] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [_t]: !0 } }]);
987
+ const [r] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Lt]: !0 } }]);
981
988
  this.snappedPointId = r;
982
989
  }
983
990
  t.lng = e[0], t.lat = e[1];
@@ -1075,7 +1082,7 @@ class Ee extends N {
1075
1082
  }
1076
1083
  if (this.editedFeatureId && i) {
1077
1084
  if (!this.editedPointId) {
1078
- const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [U]: !0 } }]);
1085
+ const [o] = this.store.create([{ geometry: { type: "Point", coordinates: i }, properties: { mode: this.mode, [V]: !0 } }]);
1079
1086
  this.editedPointId = o;
1080
1087
  }
1081
1088
  this.setCursor(this.cursors.dragStart), e(!1);
@@ -1086,10 +1093,10 @@ class Ee extends N {
1086
1093
  const i = this.store.getGeometryCopy(this.editedFeatureId), o = i.coordinates[0];
1087
1094
  this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? this.editedFeatureCoordinateIndex === 0 || this.editedFeatureCoordinateIndex === i.coordinates[0].length - 1 ? (o[0] = [t.lng, t.lat], o[o.length - 1] = [t.lng, t.lat]) : o[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates[0].splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
1088
1095
  const r = { type: "Polygon", coordinates: i.coordinates };
1089
- this.validate && !this.validate({ type: "Feature", geometry: r, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: r }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.editedFeatureId), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: U, value: !0 }]), e(!0));
1096
+ this.validate && !this.validate({ type: "Feature", geometry: r, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: r }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.editedFeatureId), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !0 }]), e(!0));
1090
1097
  }
1091
1098
  onDragEnd(t, e) {
1092
- this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: U, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
1099
+ this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !1 }]), this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
1093
1100
  }
1094
1101
  cleanUp() {
1095
1102
  const t = this.currentId, e = this.snappedPointId, i = this.editedPointId;
@@ -1104,7 +1111,7 @@ class Ee extends N {
1104
1111
  if (t.properties.mode === this.mode) {
1105
1112
  if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
1106
1113
  if (t.geometry.type === "Point") {
1107
- const i = t.properties[U], o = t.properties[Lt], r = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[_t] ? "snappingPoint" : o ? "coordinatePoint" : void 0;
1114
+ const i = t.properties[V], o = t.properties[kt], r = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[Lt] ? "snappingPoint" : o ? "coordinatePoint" : void 0;
1108
1115
  if (!r) return e;
1109
1116
  const n = { editedPoint: { width: this.styles.editedPointOutlineWidth, color: this.styles.editedPointColor, outlineColor: this.styles.editedPointOutlineColor, outlineWidth: this.styles.editedPointOutlineWidth }, closingPoint: { width: this.styles.closingPointWidth, color: this.styles.closingPointColor, outlineColor: this.styles.closingPointOutlineColor, outlineWidth: this.styles.closingPointOutlineWidth }, snappingPoint: { width: this.styles.snappingPointWidth, color: this.styles.snappingPointColor, outlineColor: this.styles.snappingPointOutlineColor, outlineWidth: this.styles.snappingPointOutlineWidth }, coordinatePoint: { width: this.styles.coordinatePointWidth, color: this.styles.coordinatePointColor, outlineColor: this.styles.coordinatePointOutlineColor, outlineWidth: this.styles.coordinatePointOutlineWidth } };
1110
1117
  return e.pointWidth = this.getNumericStylingValue(n[r].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(n[r].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(n[r].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(n[r].outlineWidth, 2, t), e.zIndex = i ? 35 : o ? 25 : 30, e;
@@ -1116,7 +1123,7 @@ class Ee extends N {
1116
1123
  this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(t.id);
1117
1124
  }
1118
1125
  validateFeature(t) {
1119
- return this.validateModeFeature(t, (e) => It(e, this.coordinatePrecision));
1126
+ return this.validateModeFeature(t, (e) => bt(e, this.coordinatePrecision));
1120
1127
  }
1121
1128
  }
1122
1129
  const mi = { cancel: "Escape", finish: "Enter" }, vi = { start: "crosshair" };
@@ -1137,7 +1144,7 @@ class Oe extends N {
1137
1144
  close() {
1138
1145
  const t = this.currentRectangleId;
1139
1146
  if (t) {
1140
- const e = dt(this.store.getGeometryCopy(t));
1147
+ const e = ht(this.store.getGeometryCopy(t));
1141
1148
  e && this.store.updateGeometry([{ id: t, geometry: e }]);
1142
1149
  }
1143
1150
  this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.onFinish(t, { mode: this.mode, action: "draw" });
@@ -1178,13 +1185,13 @@ class Oe extends N {
1178
1185
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
1179
1186
  }
1180
1187
  validateFeature(t) {
1181
- return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
1188
+ return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
1182
1189
  }
1183
1190
  }
1184
1191
  class et extends N {
1185
1192
  constructor(t) {
1186
1193
  if (!t.modeName) throw new Error("Mode name is required for TerraDrawRenderMode");
1187
- super(t, !0), this.type = $.Render, this.mode = "render", this.updateOptions(t);
1194
+ super(t, !0), this.type = Y.Render, this.mode = "render", this.updateOptions(t);
1188
1195
  }
1189
1196
  updateOptions(t) {
1190
1197
  super.updateOptions(t), t != null && t.modeName && (this.mode = t.modeName);
@@ -1220,13 +1227,13 @@ class et extends N {
1220
1227
  validateFeature(t) {
1221
1228
  const e = super.validateFeature(t);
1222
1229
  if (e.valid) {
1223
- const i = t, o = Me(i, this.coordinatePrecision).valid || It(i, this.coordinatePrecision).valid || xe(i, this.coordinatePrecision).valid;
1230
+ const i = t, o = Me(i, this.coordinatePrecision).valid || bt(i, this.coordinatePrecision).valid || xe(i, this.coordinatePrecision).valid;
1224
1231
  return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
1225
1232
  }
1226
1233
  return e;
1227
1234
  }
1228
1235
  }
1229
- function vt(s, t) {
1236
+ function Ct(s, t) {
1230
1237
  const e = s, i = t, o = O(e[1]), r = O(i[1]);
1231
1238
  let n = O(i[0] - e[0]);
1232
1239
  n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
@@ -1247,7 +1254,7 @@ function De(s, t, e, i, o) {
1247
1254
  return [F(a, e), F(l, e)];
1248
1255
  }
1249
1256
  function Ci(s, t, e) {
1250
- const i = jt(s, 1e3 * T(s, t) / 2, vt(s, t));
1257
+ const i = jt(s, 1e3 * U(s, t) / 2, Ct(s, t));
1251
1258
  return [F(i[0], e), F(i[1], e)];
1252
1259
  }
1253
1260
  function te({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
@@ -1274,13 +1281,13 @@ class Pi extends k {
1274
1281
  }
1275
1282
  insert(t, e, i) {
1276
1283
  const o = this.store.getGeometryCopy(e), { midPointFeatureId: r, midPointSegment: n } = this.store.getPropertiesCopy(e), a = this.store.getGeometryCopy(r), l = a.type === "Polygon" ? a.coordinates[0] : a.coordinates;
1277
- l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id: r, geometry: a }]), this.store.getPropertiesCopy(t)[kt] && this.coordinatePointBehavior.createOrUpdate(t), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(l, r, i), this.selectionPointBehavior.create(l, a.type, r);
1284
+ l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id: r, geometry: a }]), this.store.getPropertiesCopy(t)[rt] && this.coordinatePointBehavior.createOrUpdate(t), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(l, r, i), this.selectionPointBehavior.create(l, a.type, r);
1278
1285
  }
1279
1286
  create(t, e, i) {
1280
1287
  if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
1281
1288
  this._midPoints = this.store.create(function(o, r, n, a, l, d) {
1282
1289
  return te({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((h, c) => ({ geometry: { type: "Point", coordinates: h }, properties: r(c) }));
1283
- }(t, (o) => ({ mode: this.mode, [V.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
1290
+ }(t, (o) => ({ mode: this.mode, [T.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
1284
1291
  }
1285
1292
  delete() {
1286
1293
  this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
@@ -1343,9 +1350,9 @@ class xi extends k {
1343
1350
  for (let u = 0; u < c.length; u++) {
1344
1351
  const p = c[u], g = p.geometry;
1345
1352
  if (g.type === "Point") {
1346
- if (p.properties.selectionPoint || p.properties.coordinatePoint || !e && p.properties[V.MID_POINT]) continue;
1353
+ if (p.properties.selectionPoint || p.properties.coordinatePoint || !e && p.properties[T.MID_POINT]) continue;
1347
1354
  const y = this.pixelDistance.measure(t, g.coordinates);
1348
- p.properties[V.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, r = p) : !p.properties[V.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
1355
+ p.properties[T.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, r = p) : !p.properties[T.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
1349
1356
  } else if (g.type === "LineString") {
1350
1357
  if (i) continue;
1351
1358
  for (let y = 0; y < g.coordinates.length - 1; y++) {
@@ -1454,7 +1461,7 @@ class bi extends k {
1454
1461
  this.draggedCoordinate = { id: null, index: -1 };
1455
1462
  }
1456
1463
  }
1457
- function Ct(s) {
1464
+ function Pt(s) {
1458
1465
  let t = 0, e = 0, i = 0;
1459
1466
  return (s.geometry.type === "Polygon" ? s.geometry.coordinates[0].slice(0, -1) : s.geometry.coordinates).forEach((o) => {
1460
1467
  t += o[0], e += o[1], i++;
@@ -1468,7 +1475,7 @@ function ke(s, t) {
1468
1475
  const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? r / a : Math.cos(i);
1469
1476
  return Math.sqrt(r * r + l * l * n * n) * e;
1470
1477
  }
1471
- function Pt(s) {
1478
+ function St(s) {
1472
1479
  const t = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.geometry.coordinates).map((e) => {
1473
1480
  const { x: i, y: o } = x(e[0], e[1]);
1474
1481
  return [i, o];
@@ -1505,7 +1512,7 @@ class Mi extends k {
1505
1512
  let n;
1506
1513
  const a = { type: "Feature", geometry: o, properties: {} };
1507
1514
  if (this.config.projection === "web-mercator") {
1508
- if (n = A(Pt(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
1515
+ if (n = A(St(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
1509
1516
  ((u, p) => {
1510
1517
  if (p === 0 || p === 360 || p === -360) return u;
1511
1518
  const g = 0.017453292519943295 * p, y = (u.geometry.type === "Polygon" ? u.geometry.coordinates[0] : u.geometry.coordinates).map(([f, C]) => x(f, C)), m = y.reduce((f, C) => ({ x: f.x + C.x, y: f.y + C.y }), { x: 0, y: 0 });
@@ -1515,12 +1522,12 @@ class Mi extends k {
1515
1522
  })(a, -(this.lastBearing - n));
1516
1523
  } else {
1517
1524
  if (this.config.projection !== "globe") throw new Error("Unsupported projection");
1518
- if (n = vt(Ct({ geometry: o }), r), !this.lastBearing) return void (this.lastBearing = n + 180);
1525
+ if (n = Ct(Pt({ geometry: o }), r), !this.lastBearing) return void (this.lastBearing = n + 180);
1519
1526
  (function(u, p) {
1520
1527
  if (p === 0 || p === 360 || p === -360) return u;
1521
- const g = Ct(u);
1528
+ const g = Pt(u);
1522
1529
  (u.geometry.type === "Polygon" ? u.geometry.coordinates[0] : u.geometry.coordinates).forEach((y) => {
1523
- const m = vt(g, y) + p, v = ke(g, y), f = jt(g, v, m);
1530
+ const m = Ct(g, y) + p, v = ke(g, y), f = jt(g, v, m);
1524
1531
  y[0] = f[0], y[1] = f[1];
1525
1532
  });
1526
1533
  })(a, -(this.lastBearing - (n + 180)));
@@ -1546,13 +1553,13 @@ class wi extends k {
1546
1553
  if (o.type !== "Polygon" && o.type !== "LineString") return;
1547
1554
  const r = [t.lng, t.lat], n = { type: "Feature", geometry: o, properties: {} };
1548
1555
  let a;
1549
- const l = Pt(n);
1556
+ const l = St(n);
1550
1557
  if (this.config.projection === "web-mercator") {
1551
1558
  const g = x(t.lng, t.lat);
1552
1559
  a = E(l, g);
1553
1560
  } else {
1554
1561
  if (this.config.projection !== "globe") throw new Error("Invalid projection");
1555
- a = T(Ct({ geometry: o }), r);
1562
+ a = U(Pt({ geometry: o }), r);
1556
1563
  }
1557
1564
  if (!this.lastDistance) return void (this.lastDistance = a);
1558
1565
  const d = 1 - (this.lastDistance - a) / a;
@@ -1565,10 +1572,10 @@ class wi extends k {
1565
1572
  })(n, d, [g, y]);
1566
1573
  } else this.config.projection === "globe" && function(g, y, m, v = "xy") {
1567
1574
  y === 1 || (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.geometry.coordinates).forEach((f) => {
1568
- const C = ke(m, f), P = vt(m, f), S = jt(m, C * y, P);
1575
+ const C = ke(m, f), P = Ct(m, f), S = jt(m, C * y, P);
1569
1576
  v !== "x" && v !== "xy" || (f[0] = S[0]), v !== "y" && v !== "xy" || (f[1] = S[1]);
1570
1577
  });
1571
- }(n, d, Ct(n));
1578
+ }(n, d, Pt(n));
1572
1579
  const h = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1573
1580
  h.forEach((g) => {
1574
1581
  g[0] = F(g[0], this.coordinatePrecision), g[1] = F(g[1], this.coordinatePrecision);
@@ -1637,7 +1644,7 @@ class Fi extends k {
1637
1644
  centerWebMercatorDrag(t) {
1638
1645
  const e = this.getSelectedFeatureDataWebMercator();
1639
1646
  if (!e) return null;
1640
- const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Pt(i);
1647
+ const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = St(i);
1641
1648
  if (!a) return null;
1642
1649
  const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = x(t.lng, t.lat);
1643
1650
  return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), r;
@@ -1645,7 +1652,7 @@ class Fi extends k {
1645
1652
  centerFixedWebMercatorDrag(t) {
1646
1653
  const e = this.getSelectedFeatureDataWebMercator();
1647
1654
  if (!e) return null;
1648
- const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Pt(i);
1655
+ const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = St(i);
1649
1656
  if (!a) return null;
1650
1657
  const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = x(t.lng, t.lat);
1651
1658
  return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), r;
@@ -1734,14 +1741,14 @@ class Fi extends k {
1734
1741
  if (e === "center" ? r = this.centerWebMercatorDrag(t) : e === "opposite" ? r = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? r = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (r = this.oppositeFixedWebMercatorDrag(t)), !r) return !1;
1735
1742
  for (let h = 0; h < r.length; h++) {
1736
1743
  const c = r[h];
1737
- if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !xt(c, this.coordinatePrecision)) return !1;
1744
+ if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !It(c, this.coordinatePrecision)) return !1;
1738
1745
  }
1739
1746
  const n = this.midPoints.getUpdated(r) || [], a = this.selectionPoints.getUpdated(r) || [], l = this.coordinatePoints.getUpdated(o.id, r) || [], d = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [r] : r };
1740
1747
  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: M.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: d }, ...a, ...n, ...l]), 0));
1741
1748
  }
1742
1749
  }
1743
1750
  const Ei = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, ee = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
1744
- class Be extends $e {
1751
+ class Be extends Ye {
1745
1752
  constructor(t) {
1746
1753
  super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = Ei, this.cursors = ee, 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.updateOptions(t);
1747
1754
  }
@@ -1757,7 +1764,7 @@ class Be extends $e {
1757
1764
  createOrUpdateCoordinatePoint(t) {
1758
1765
  const e = this.store.getPropertiesCopy(t);
1759
1766
  e.coordinatePointIds && this.store.delete(e.coordinatePointIds);
1760
- const i = this.store.getGeometryCopy(t), o = this.store.create(i.coordinates[0].map((r) => ({ geometry: { type: "Point", coordinates: r }, properties: { mode: this.mode, [Lt]: !0 } })));
1767
+ const i = this.store.getGeometryCopy(t), o = this.store.create(i.coordinates[0].map((r) => ({ geometry: { type: "Point", coordinates: r }, properties: { mode: this.mode, [kt]: !0 } })));
1761
1768
  this.store.updateProperty([{ id: t, property: "coordinatePointIds", value: o }]);
1762
1769
  }
1763
1770
  selectFeature(t) {
@@ -1768,13 +1775,13 @@ class Be extends $e {
1768
1775
  this._state = "selecting";
1769
1776
  }
1770
1777
  registerBehaviors(t) {
1771
- this.pixelDistance = new nt(t), this.clickBoundingBox = new rt(t), this.featuresAtMouseEvent = new xi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Si(t), this.coordinatePoints = new Fe(t), this.midPoints = new Pi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new mt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Mi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new wi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Ii(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new bi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap), this.dragCoordinateResizeFeature = new Fi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints);
1778
+ this.pixelDistance = new at(t), this.clickBoundingBox = new nt(t), this.featuresAtMouseEvent = new xi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Si(t), this.coordinatePoints = new Fe(t), this.midPoints = new Pi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new vt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Mi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new wi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Ii(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new bi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap), this.dragCoordinateResizeFeature = new Fi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints);
1772
1779
  }
1773
1780
  deselectFeature() {
1774
1781
  this.deselect();
1775
1782
  }
1776
1783
  deselect() {
1777
- const t = this.selected.filter((e) => this.store.has(e)).map((e) => ({ id: e, property: V.SELECTED, value: !1 }));
1784
+ const t = this.selected.filter((e) => this.store.has(e)).map((e) => ({ id: e, property: T.SELECTED, value: !1 }));
1778
1785
  this.store.updateProperty(t), this.onDeselect(this.selected[0]), this.selected = [], this.selectionPoints.delete(), this.midPoints.delete();
1779
1786
  }
1780
1787
  deleteSelected() {
@@ -1807,7 +1814,7 @@ class Be extends $e {
1807
1814
  if (r === t) return;
1808
1815
  this.deselect();
1809
1816
  }
1810
- e && this.setCursor(this.cursors.pointerOver), this.selected = [t], this.store.updateProperty([{ id: t, property: "selected", value: !0 }]), this.onSelect(t);
1817
+ e && this.setCursor(this.cursors.pointerOver), this.selected = [t], this.store.updateProperty([{ id: t, property: T.SELECTED, value: !0 }]), this.onSelect(t);
1811
1818
  const { type: n, coordinates: a } = this.store.getGeometryCopy(t);
1812
1819
  if (n !== "LineString" && n !== "Polygon") return;
1813
1820
  const l = n === "LineString" ? a : a[0];
@@ -1910,7 +1917,7 @@ class Be extends $e {
1910
1917
  if (t.properties.mode === this.mode && t.geometry.type === "Point") {
1911
1918
  if (t.properties.selectionPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, e.pointWidth, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, t), e.zIndex = 30, e;
1912
1919
  if (t.properties.midPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, t), e.zIndex = 40, e;
1913
- } else if (t.properties[V.SELECTED]) {
1920
+ } else if (t.properties[T.SELECTED]) {
1914
1921
  if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, e.polygonFillColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, e.polygonOutlineWidth, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, e.polygonOutlineColor, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
1915
1922
  if (t.geometry.type === "LineString") return e.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, e.lineStringWidth, t), e.zIndex = 10, e;
1916
1923
  if (t.geometry.type === "Point") return e.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 10, e;
@@ -1920,7 +1927,7 @@ class Be extends $e {
1920
1927
  }
1921
1928
  class Oi extends N {
1922
1929
  constructor(...t) {
1923
- super(...t), this.type = $.Static, this.mode = "static";
1930
+ super(...t), this.type = Y.Static, this.mode = "static";
1924
1931
  }
1925
1932
  start() {
1926
1933
  }
@@ -1969,7 +1976,7 @@ function H(s, t) {
1969
1976
  it(s, 0, s.children.length, t, s);
1970
1977
  }
1971
1978
  function it(s, t, e, i, o) {
1972
- o || (o = J([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
1979
+ o || (o = q([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
1973
1980
  for (let r = t; r < e; r++) {
1974
1981
  const n = s.children[r];
1975
1982
  ot(o, s.leaf ? i(n) : n);
@@ -1985,23 +1992,23 @@ function Di(s, t) {
1985
1992
  function _i(s, t) {
1986
1993
  return s.minY - t.minY;
1987
1994
  }
1988
- function Ft(s) {
1995
+ function Et(s) {
1989
1996
  return (s.maxX - s.minX) * (s.maxY - s.minY);
1990
1997
  }
1991
- function ut(s) {
1998
+ function pt(s) {
1992
1999
  return s.maxX - s.minX + (s.maxY - s.minY);
1993
2000
  }
1994
2001
  function Li(s, t) {
1995
2002
  const e = Math.max(s.minX, t.minX), i = Math.max(s.minY, t.minY), o = Math.min(s.maxX, t.maxX), r = Math.min(s.maxY, t.maxY);
1996
2003
  return Math.max(0, o - e) * Math.max(0, r - i);
1997
2004
  }
1998
- function Et(s, t) {
2005
+ function Ot(s, t) {
1999
2006
  return s.minX <= t.minX && s.minY <= t.minY && t.maxX <= s.maxX && t.maxY <= s.maxY;
2000
2007
  }
2001
- function pt(s, t) {
2008
+ function gt(s, t) {
2002
2009
  return t.minX <= s.maxX && t.minY <= s.maxY && t.maxX >= s.minX && t.maxY >= s.minY;
2003
2010
  }
2004
- function J(s) {
2011
+ function q(s) {
2005
2012
  return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
2006
2013
  }
2007
2014
  function ie(s, t, e, i, o) {
@@ -2019,12 +2026,12 @@ class ki {
2019
2026
  search(t) {
2020
2027
  let e = this.data;
2021
2028
  const i = [];
2022
- if (!pt(t, e)) return i;
2029
+ if (!gt(t, e)) return i;
2023
2030
  const o = this.toBBox, r = [];
2024
2031
  for (; e; ) {
2025
2032
  for (let n = 0; n < e.children.length; n++) {
2026
2033
  const a = e.children[n], l = e.leaf ? o(a) : a;
2027
- pt(t, l) && (e.leaf ? i.push(a) : Et(t, l) ? this._all(a, i) : r.push(a));
2034
+ gt(t, l) && (e.leaf ? i.push(a) : Ot(t, l) ? this._all(a, i) : r.push(a));
2028
2035
  }
2029
2036
  e = r.pop();
2030
2037
  }
@@ -2032,13 +2039,13 @@ class ki {
2032
2039
  }
2033
2040
  collides(t) {
2034
2041
  let e = this.data;
2035
- if (pt(t, e)) {
2042
+ if (gt(t, e)) {
2036
2043
  const i = [];
2037
2044
  for (; e; ) {
2038
2045
  for (let o = 0; o < e.children.length; o++) {
2039
2046
  const r = e.children[o], n = e.leaf ? this.toBBox(r) : r;
2040
- if (pt(t, n)) {
2041
- if (e.leaf || Et(t, n)) return !0;
2047
+ if (gt(t, n)) {
2048
+ if (e.leaf || Ot(t, n)) return !0;
2042
2049
  i.push(r);
2043
2050
  }
2044
2051
  }
@@ -2067,7 +2074,7 @@ class ki {
2067
2074
  this._insert(t, this.data.height - 1);
2068
2075
  }
2069
2076
  clear() {
2070
- this.data = J([]);
2077
+ this.data = q([]);
2071
2078
  }
2072
2079
  remove(t) {
2073
2080
  let e = this.data;
@@ -2078,7 +2085,7 @@ class ki {
2078
2085
  const d = e.children.indexOf(t);
2079
2086
  d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
2080
2087
  }
2081
- l || e.leaf || !Et(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), r.push(n), n = 0, a = e, e = e.children[0]);
2088
+ l || e.leaf || !Ot(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), r.push(n), n = 0, a = e, e = e.children[0]);
2082
2089
  }
2083
2090
  }
2084
2091
  toBBox(t) {
@@ -2098,8 +2105,8 @@ class ki {
2098
2105
  _build(t, e, i, o) {
2099
2106
  const r = i - e + 1;
2100
2107
  let n, a = this._maxEntries;
2101
- if (r <= a) return n = J(t.slice(e, i + 1)), H(n, this.toBBox), n;
2102
- o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n = J([]), n.leaf = !1, n.height = o;
2108
+ if (r <= a) return n = q(t.slice(e, i + 1)), H(n, this.toBBox), n;
2109
+ o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n = q([]), n.leaf = !1, n.height = o;
2103
2110
  const l = Math.ceil(r / a), d = l * Math.ceil(Math.sqrt(a));
2104
2111
  ie(t, e, i, d, this.compareMinX);
2105
2112
  for (let h = e; h <= i; h += d) {
@@ -2116,7 +2123,7 @@ class ki {
2116
2123
  for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
2117
2124
  let a, l = 1 / 0, d = 1 / 0;
2118
2125
  for (let h = 0; h < e.children.length; h++) {
2119
- const c = e.children[h], u = Ft(c), p = (r = t, n = c, (Math.max(n.maxX, r.maxX) - Math.min(n.minX, r.minX)) * (Math.max(n.maxY, r.maxY) - Math.min(n.minY, r.minY)) - u);
2126
+ const c = e.children[h], u = Et(c), p = (r = t, n = c, (Math.max(n.maxX, r.maxX) - Math.min(n.minX, r.minX)) * (Math.max(n.maxY, r.maxY) - Math.min(n.minY, r.minY)) - u);
2120
2127
  p < d ? (d = p, l = u < l ? u : l, a = c) : p === d && u < l && (l = u, a = c);
2121
2128
  }
2122
2129
  e = a || e.children[0];
@@ -2132,16 +2139,16 @@ class ki {
2132
2139
  _split(t, e) {
2133
2140
  const i = t[e], o = i.children.length, r = this._minEntries;
2134
2141
  this._chooseSplitAxis(i, r, o);
2135
- const n = this._chooseSplitIndex(i, r, o), a = J(i.children.splice(n, i.children.length - n));
2142
+ const n = this._chooseSplitIndex(i, r, o), a = q(i.children.splice(n, i.children.length - n));
2136
2143
  a.height = i.height, a.leaf = i.leaf, H(i, this.toBBox), H(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
2137
2144
  }
2138
2145
  _splitRoot(t, e) {
2139
- this.data = J([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, H(this.data, this.toBBox);
2146
+ this.data = q([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, H(this.data, this.toBBox);
2140
2147
  }
2141
2148
  _chooseSplitIndex(t, e, i) {
2142
2149
  let o, r = 1 / 0, n = 1 / 0;
2143
2150
  for (let a = e; a <= i - e; a++) {
2144
- const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), h = Li(l, d), c = Ft(l) + Ft(d);
2151
+ const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), h = Li(l, d), c = Et(l) + Et(d);
2145
2152
  h < r ? (r = h, o = a, n = c < n ? c : n) : h === r && c < n && (n = c, o = a);
2146
2153
  }
2147
2154
  return o || i - e;
@@ -2153,14 +2160,14 @@ class ki {
2153
2160
  _allDistMargin(t, e, i, o) {
2154
2161
  t.children.sort(o);
2155
2162
  const r = this.toBBox, n = it(t, 0, e, r), a = it(t, i - e, i, r);
2156
- let l = ut(n) + ut(a);
2163
+ let l = pt(n) + pt(a);
2157
2164
  for (let d = e; d < i - e; d++) {
2158
2165
  const h = t.children[d];
2159
- ot(n, t.leaf ? r(h) : h), l += ut(n);
2166
+ ot(n, t.leaf ? r(h) : h), l += pt(n);
2160
2167
  }
2161
2168
  for (let d = i - e - 1; d >= e; d--) {
2162
2169
  const h = t.children[d];
2163
- ot(a, t.leaf ? r(h) : h), l += ut(a);
2170
+ ot(a, t.leaf ? r(h) : h), l += pt(a);
2164
2171
  }
2165
2172
  return l;
2166
2173
  }
@@ -2311,7 +2318,7 @@ class ji {
2311
2318
  }
2312
2319
  delete(t) {
2313
2320
  t.forEach((e) => {
2314
- if (!this.store[e]) throw new Error("No feature with this id, can not delete");
2321
+ if (!this.store[e]) throw new Error(`No feature with id ${e}, can not delete`);
2315
2322
  delete this.store[e], this.spatialIndex.remove(e);
2316
2323
  }), this._onChange && this._onChange([...t], "delete");
2317
2324
  }
@@ -2367,7 +2374,7 @@ class je extends N {
2367
2374
  const o = e[0], r = e[1], n = De(o, r, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(r[0], r[1]), h = x(t.lng, t.lat), c = E(h, a) < E(h, d), u = oe(a, l, h), p = c ? 90 - u : oe(a, l, h) - 90, g = E(l, h), y = Math.cos(O(p)) * g, m = A(a, d) + (function(S, b, w) {
2368
2375
  const D = (w.x - b.x) * (S.y - b.y) - (w.y - b.y) * (S.x - b.x);
2369
2376
  return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
2370
- }(a, d, h) === "right" ? -90 : 90), v = at(a, y, m), f = at(d, y, m), C = W(v.x, v.y), P = W(f.x, f.y);
2377
+ }(a, d, h) === "right" ? -90 : 90), v = lt(a, y, m), f = lt(d, y, m), C = W(v.x, v.y), P = W(f.x, f.y);
2371
2378
  i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
2372
2379
  }
2373
2380
  i && this.updatePolygonGeometry(this.currentId, i, M.Provisional);
@@ -2413,7 +2420,7 @@ class je extends N {
2413
2420
  return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
2414
2421
  }
2415
2422
  validateFeature(t) {
2416
- return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
2423
+ return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
2417
2424
  }
2418
2425
  }
2419
2426
  function Ne(s, t, e) {
@@ -2429,7 +2436,7 @@ class Ge extends N {
2429
2436
  }
2430
2437
  close() {
2431
2438
  if (this.currentId === void 0) return;
2432
- const t = dt(this.store.getGeometryCopy(this.currentId));
2439
+ const t = ht(this.store.getGeometryCopy(this.currentId));
2433
2440
  t && this.store.updateGeometry([{ id: this.currentId, geometry: t }]);
2434
2441
  const e = this.currentId;
2435
2442
  this.currentCoordinate = 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
@@ -2453,13 +2460,13 @@ class Ge extends N {
2453
2460
  const C = Ne(a, l, d);
2454
2461
  this.direction = C ? "clockwise" : "anticlockwise";
2455
2462
  }
2456
- const h = E(a, l), c = A(a, l), u = A(a, d), p = this.arcPoints, g = [o], y = Y(c), m = Y(u);
2463
+ const h = E(a, l), c = A(a, l), u = A(a, d), p = this.arcPoints, g = [o], y = $(c), m = $(u);
2457
2464
  let v;
2458
2465
  this.direction === "anticlockwise" ? (v = m - y, v < 0 && (v += 360)) : (v = y - m, v < 0 && (v += 360));
2459
2466
  const f = (this.direction === "anticlockwise" ? 1 : -1) * v / p;
2460
2467
  g.push(r);
2461
2468
  for (let C = 0; C <= p; C++) {
2462
- const P = at(a, h, y + C * f), { lng: S, lat: b } = W(P.x, P.y), w = [F(S, this.coordinatePrecision), F(b, this.coordinatePrecision)];
2469
+ const P = lt(a, h, y + C * f), { lng: S, lat: b } = W(P.x, P.y), w = [F(S, this.coordinatePrecision), F(b, this.coordinatePrecision)];
2463
2470
  w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
2464
2471
  }
2465
2472
  g.push(o), i = [...g];
@@ -2503,7 +2510,7 @@ class Ge extends N {
2503
2510
  return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
2504
2511
  }
2505
2512
  validateFeature(t) {
2506
- return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
2513
+ return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
2507
2514
  }
2508
2515
  }
2509
2516
  const zi = { cancel: "Escape", finish: "Enter" }, Xi = { start: "crosshair", close: "pointer" };
@@ -2518,7 +2525,7 @@ class Ae extends N {
2518
2525
  if (this.currentStartingPointId === void 0) return;
2519
2526
  const t = this.currentStartingPointId, e = this.currentInitialArcId, i = this.currentId;
2520
2527
  if (t && this.store.delete([t]), e && this.store.delete([e]), this.currentId) {
2521
- const o = dt(this.store.getGeometryCopy(this.currentId));
2528
+ const o = ht(this.store.getGeometryCopy(this.currentId));
2522
2529
  o && this.store.updateGeometry([{ id: this.currentId, geometry: o }]);
2523
2530
  }
2524
2531
  this.currentCoordinate = 0, this.currentStartingPointId = void 0, this.currentInitialArcId = void 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), i && this.onFinish(i, { mode: this.mode, action: "draw" });
@@ -2537,23 +2544,23 @@ class Ae extends N {
2537
2544
  const f = Ne(l, n, a);
2538
2545
  this.direction = f ? "clockwise" : "anticlockwise";
2539
2546
  }
2540
- const h = A(l, n), c = A(l, a), u = this.arcPoints, p = [o], g = Y(h), y = Y(c);
2547
+ const h = A(l, n), c = A(l, a), u = this.arcPoints, p = [o], g = $(h), y = $(c);
2541
2548
  let m;
2542
2549
  this.direction === "anticlockwise" ? (m = y - g, m < 0 && (m += 360)) : (m = g - y, m < 0 && (m += 360));
2543
2550
  const v = (this.direction === "anticlockwise" ? 1 : -1) * m / u;
2544
2551
  for (let f = 0; f <= u; f++) {
2545
- const C = at(l, d, g + f * v), { lng: P, lat: S } = W(C.x, C.y), b = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
2552
+ const C = lt(l, d, g + f * v), { lng: P, lat: S } = W(C.x, C.y), b = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
2546
2553
  b[0] !== p[p.length - 1][0] && b[1] !== p[p.length - 1][1] && p.push(b);
2547
2554
  }
2548
2555
  this.updateLineStringGeometry(this.currentInitialArcId, p, M.Provisional);
2549
2556
  } else if (this.currentCoordinate === 3) {
2550
2557
  const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2551
2558
  if (e.length < 2 || !this.direction) return;
2552
- const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]), h = E(d, a), c = E(d, n) < h ? a : n, u = A(d, n), p = A(d, a), g = A(d, l), y = Y(p), m = Y(g), v = Y(u);
2559
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]), h = E(d, a), c = E(d, n) < h ? a : n, u = A(d, n), p = A(d, a), g = A(d, l), y = $(p), m = $(g), v = $(u);
2553
2560
  if (this.notInSector({ normalizedCursor: v, normalizedStart: y, normalizedEnd: m, direction: this.direction })) return;
2554
2561
  const f = this.getDeltaBearing(this.direction, y, m), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * f / C, S = E(d, c), b = [];
2555
2562
  for (let w = 0; w <= C; w++) {
2556
- const D = at(d, S, y + w * P), { lng: G, lat: _ } = W(D.x, D.y), j = [F(G, this.coordinatePrecision), F(_, this.coordinatePrecision)];
2563
+ const D = lt(d, S, y + w * P), { lng: G, lat: _ } = W(D.x, D.y), j = [F(G, this.coordinatePrecision), F(_, this.coordinatePrecision)];
2557
2564
  j[0] !== e[e.length - 1][0] && j[1] !== e[e.length - 1][1] && b.unshift(j);
2558
2565
  }
2559
2566
  e.push(...b), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, M.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
@@ -2600,7 +2607,7 @@ class Ae extends N {
2600
2607
  return t.properties.mode === this.mode && (t.geometry.type === "Polygon" ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10) : t.geometry.type === "LineString" ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.zIndex = 10) : t.geometry.type === "Point" && (e.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 20)), e;
2601
2608
  }
2602
2609
  validateFeature(t) {
2603
- return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
2610
+ return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
2604
2611
  }
2605
2612
  getDeltaBearing(t, e, i) {
2606
2613
  let o;
@@ -2610,7 +2617,7 @@ class Ae extends N {
2610
2617
  return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
2611
2618
  }
2612
2619
  }
2613
- class q {
2620
+ class J {
2614
2621
  constructor({ name: t, callback: e, unregister: i, register: o }) {
2615
2622
  this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
2616
2623
  this.registered || (this.registered = !0, o(e));
@@ -2645,7 +2652,7 @@ var Ki = { __proto__: null, TerraDrawBaseAdapter: class {
2645
2652
  return this._coordinatePrecision;
2646
2653
  }
2647
2654
  getAdapterListeners() {
2648
- return [new q({ name: "pointerdown", callback: (s) => {
2655
+ return [new J({ name: "pointerdown", callback: (s) => {
2649
2656
  if (!this._currentModeCallbacks || !s.isPrimary) return;
2650
2657
  const t = this.getDrawEventFromEvent(s);
2651
2658
  t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
@@ -2653,7 +2660,7 @@ var Ki = { __proto__: null, TerraDrawBaseAdapter: class {
2653
2660
  this.getMapEventElement().addEventListener("pointerdown", s);
2654
2661
  }, unregister: (s) => {
2655
2662
  this.getMapEventElement().removeEventListener("pointerdown", s);
2656
- } }), new q({ name: "pointermove", callback: (s) => {
2663
+ } }), new J({ name: "pointermove", callback: (s) => {
2657
2664
  if (!this._currentModeCallbacks || !s.isPrimary) return;
2658
2665
  s.preventDefault();
2659
2666
  const t = this.getDrawEventFromEvent(s);
@@ -2673,13 +2680,13 @@ var Ki = { __proto__: null, TerraDrawBaseAdapter: class {
2673
2680
  this.getMapEventElement().addEventListener("pointermove", s);
2674
2681
  }, unregister: (s) => {
2675
2682
  this.getMapEventElement().removeEventListener("pointermove", s);
2676
- } }), new q({ name: "contextmenu", callback: (s) => {
2683
+ } }), new J({ name: "contextmenu", callback: (s) => {
2677
2684
  this._currentModeCallbacks && s.preventDefault();
2678
2685
  }, register: (s) => {
2679
2686
  this.getMapEventElement().addEventListener("contextmenu", s);
2680
2687
  }, unregister: (s) => {
2681
2688
  this.getMapEventElement().removeEventListener("contextmenu", s);
2682
- } }), new q({ name: "pointerup", callback: (s) => {
2689
+ } }), new J({ name: "pointerup", callback: (s) => {
2683
2690
  if (!this._currentModeCallbacks || s.target !== this.getMapEventElement() || !s.isPrimary) return;
2684
2691
  const t = this.getDrawEventFromEvent(s);
2685
2692
  t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (e) => {
@@ -2689,13 +2696,13 @@ var Ki = { __proto__: null, TerraDrawBaseAdapter: class {
2689
2696
  this.getMapEventElement().addEventListener("pointerup", s);
2690
2697
  }, unregister: (s) => {
2691
2698
  this.getMapEventElement().removeEventListener("pointerup", s);
2692
- } }), new q({ name: "keyup", callback: (s) => {
2699
+ } }), new J({ name: "keyup", callback: (s) => {
2693
2700
  this._currentModeCallbacks && (this._heldKeys.delete(s.key), this._currentModeCallbacks.onKeyUp({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
2694
2701
  }, register: (s) => {
2695
2702
  this.getMapEventElement().addEventListener("keyup", s);
2696
2703
  }, unregister: (s) => {
2697
2704
  this.getMapEventElement().removeEventListener("keyup", s);
2698
- } }), new q({ name: "keydown", callback: (s) => {
2705
+ } }), new J({ name: "keydown", callback: (s) => {
2699
2706
  this._currentModeCallbacks && (this._heldKeys.add(s.key), this._currentModeCallbacks.onKeyDown({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
2700
2707
  }, register: (s) => {
2701
2708
  this.getMapEventElement().addEventListener("keydown", s);
@@ -2709,7 +2716,7 @@ var Ki = { __proto__: null, TerraDrawBaseAdapter: class {
2709
2716
  }), this.clear();
2710
2717
  }
2711
2718
  } };
2712
- class Yi {
2719
+ class $i {
2713
2720
  constructor(t) {
2714
2721
  this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new Oi();
2715
2722
  const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((h, c) => {
@@ -2718,7 +2725,7 @@ class Yi {
2718
2725
  }, {}), o = Object.keys(i);
2719
2726
  if (o.length === 0) throw new Error("No modes provided");
2720
2727
  o.forEach((h) => {
2721
- if (i[h].type === $.Select) {
2728
+ if (i[h].type === Y.Select) {
2722
2729
  if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
2723
2730
  this._instanceSelectMode = h;
2724
2731
  }
@@ -2762,13 +2769,13 @@ class Yi {
2762
2769
  getModeStyles() {
2763
2770
  const t = {};
2764
2771
  return Object.keys(this._modes).forEach((e) => {
2765
- t[e] = (i) => this._instanceSelectMode && i.properties[V.SELECTED] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[e].styleFeature.bind(this._modes[e])(i);
2772
+ t[e] = (i) => this._instanceSelectMode && i.properties[T.SELECTED] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[e].styleFeature.bind(this._modes[e])(i);
2766
2773
  }), t;
2767
2774
  }
2768
2775
  featuresAtLocation({ lng: t, lat: e }, i) {
2769
2776
  const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = Se({ unproject: n, point: l, pointerDistance: o });
2770
2777
  return this._store.search(d).filter((h) => {
2771
- if (r && (h.properties[V.MID_POINT] || h.properties[V.SELECTION_POINT])) return !1;
2778
+ if (r && (h.properties[T.MID_POINT] || h.properties[T.SELECTION_POINT])) return !1;
2772
2779
  if (h.geometry.type === "Point") {
2773
2780
  const c = h.geometry.coordinates, u = a(c[0], c[1]);
2774
2781
  return E(l, u) < o;
@@ -2819,7 +2826,13 @@ class Yi {
2819
2826
  this._mode.stop(), this._mode = this._modes[t], this._mode.start();
2820
2827
  }
2821
2828
  removeFeatures(t) {
2822
- this.checkEnabled(), this._store.delete(t);
2829
+ this.checkEnabled();
2830
+ const e = [];
2831
+ t.forEach((i) => {
2832
+ if (!this._store.has(i)) throw new Error(`No feature with id ${i}, can not delete`);
2833
+ const o = this._store.copy(i);
2834
+ o.properties[T.SELECTED] && this.deselectFeature(i), o.properties[rt] && e.push(...o.properties[rt]);
2835
+ }), this._store.delete([...t, ...e]);
2823
2836
  }
2824
2837
  selectFeature(t) {
2825
2838
  this.getSelectMode().selectFeature(t);
@@ -2892,14 +2905,14 @@ class Yi {
2892
2905
  i.includes(e) && i.splice(i.indexOf(e), 1);
2893
2906
  }
2894
2907
  }
2895
- class $i extends Ki.TerraDrawBaseAdapter {
2908
+ class Yi extends Ki.TerraDrawBaseAdapter {
2896
2909
  constructor(t) {
2897
2910
  super(t), this._initialDragPan = void 0, this._initialDragRotate = void 0, this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer(), this._initialDragRotate = this._map.dragRotate.isEnabled(), this._initialDragPan = this._map.dragPan.isEnabled();
2898
2911
  }
2899
2912
  clearLayers() {
2900
2913
  this._rendered && (["point", "linestring", "polygon"].forEach((t) => {
2901
2914
  const e = `td-${t.toLowerCase()}`;
2902
- this._map.removeLayer(e), t === "polygon" && this._map.removeLayer(e + "-outline"), this._map.removeSource(e);
2915
+ this._map.removeLayer(e), t === "polygon" && this._map.removeLayer(e + "-outline"), t === "point" && (this._map.removeLayer(e + "-lower"), this._map.removeSource(e + "-lower")), this._map.removeSource(e);
2903
2916
  }), this._rendered = !1, this._nextRender && (cancelAnimationFrame(this._nextRender), this._nextRender = void 0));
2904
2917
  }
2905
2918
  _addGeoJSONSource(t, e) {
@@ -2920,13 +2933,13 @@ class $i extends Ki.TerraDrawBaseAdapter {
2920
2933
  _addLayer(t, e) {
2921
2934
  e === "Point" && this._addPointLayer(t), e === "LineString" && this._addLineLayer(t), e === "Polygon" && (this._addFillLayer(t), this._addFillOutlineLayer(t));
2922
2935
  }
2923
- _addGeoJSONLayer(t, e) {
2924
- const i = `td-${t.toLowerCase()}`;
2925
- return this._addGeoJSONSource(i, e), this._addLayer(i, t), i;
2936
+ _addGeoJSONLayer(t, e, i) {
2937
+ const o = `td-${t.toLowerCase()}${i ? `-${i}` : ""}`;
2938
+ return this._addGeoJSONSource(o, e), this._addLayer(o, t), o;
2926
2939
  }
2927
- _setGeoJSONLayerData(t, e) {
2928
- const i = `td-${t.toLowerCase()}`;
2929
- return this._map.getSource(i).setData({ type: "FeatureCollection", features: e }), i;
2940
+ _setGeoJSONLayerData(t, e, i) {
2941
+ const o = `td-${t.toLowerCase()}${i ? `-${i}` : ""}`;
2942
+ return this._map.getSource(o).setData({ type: "FeatureCollection", features: e }), o;
2930
2943
  }
2931
2944
  updateChangedIds(t) {
2932
2945
  [...t.updated, ...t.created].forEach((e) => {
@@ -2960,18 +2973,15 @@ class $i extends Ki.TerraDrawBaseAdapter {
2960
2973
  }
2961
2974
  render(t, e) {
2962
2975
  this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
2963
- const i = [...t.created, ...t.updated, ...t.unchanged], o = [], r = [], n = [];
2964
- for (let a = 0; a < i.length; a++) {
2965
- const l = i[a], { properties: d } = l, h = e[d.mode](l);
2966
- l.geometry.type === "Point" ? (d.pointColor = h.pointColor, d.pointOutlineColor = h.pointOutlineColor, d.pointOutlineWidth = h.pointOutlineWidth, d.pointWidth = h.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = h.lineStringColor, d.lineStringWidth = h.lineStringWidth, r.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = h.polygonFillColor, d.polygonFillOpacity = h.polygonFillOpacity, d.polygonOutlineColor = h.polygonOutlineColor, d.polygonOutlineWidth = h.polygonOutlineWidth, n.push(l));
2976
+ const i = [...t.created, ...t.updated, ...t.unchanged], o = [], r = [], n = [], a = [];
2977
+ for (let l = 0; l < i.length; l++) {
2978
+ const d = i[l], { properties: h } = d, c = e[h.mode](d);
2979
+ d.geometry.type === "Point" ? (h.pointColor = c.pointColor, h.pointOutlineColor = c.pointOutlineColor, h.pointOutlineWidth = c.pointOutlineWidth, h.pointWidth = c.pointWidth, c.zIndex < 30 ? o.push(d) : r.push(d)) : d.geometry.type === "LineString" ? (h.lineStringColor = c.lineStringColor, h.lineStringWidth = c.lineStringWidth, n.push(d)) : d.geometry.type === "Polygon" && (h.polygonFillColor = c.polygonFillColor, h.polygonFillOpacity = c.polygonFillOpacity, h.polygonOutlineColor = c.polygonOutlineColor, h.polygonOutlineWidth = c.polygonOutlineWidth, a.push(d));
2967
2980
  }
2968
2981
  if (this._rendered) {
2969
- const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
2970
- let h;
2971
- (a || this.changedIds.points) && (h = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", r), d && this._setGeoJSONLayerData("Polygon", n), h && this._map.moveLayer(h);
2972
- } else {
2973
- const a = this._addGeoJSONLayer("Point", o);
2974
- this._addGeoJSONLayer("LineString", r), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
2982
+ const l = this.changedIds.deletion || this.changedIds.styling, d = l || this.changedIds.linestrings, h = l || this.changedIds.polygons;
2983
+ let c, u;
2984
+ (l || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", r), u = this._setGeoJSONLayerData("Point", o, "lower")), d && this._setGeoJSONLayerData("LineString", n), h && this._setGeoJSONLayerData("Polygon", a), c && (this._map.moveLayer(c), u && this._map.moveLayer(u, c));
2975
2985
  }
2976
2986
  this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
2977
2987
  });
@@ -2987,7 +2997,9 @@ class $i extends Ki.TerraDrawBaseAdapter {
2987
2997
  }
2988
2998
  register(t) {
2989
2999
  var e;
2990
- super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
3000
+ super.register(t);
3001
+ const i = this._addGeoJSONLayer("Point", []), o = this._addGeoJSONLayer("Point", [], "lower");
3002
+ this._addGeoJSONLayer("LineString", []), this._addGeoJSONLayer("Polygon", []), i && (this._map.moveLayer(i), o && this._map.moveLayer(o, i)), this._rendered = !0, (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
2991
3003
  }
2992
3004
  }
2993
3005
  const ko = [
@@ -3023,7 +3035,7 @@ const ko = [
3023
3035
  "download"
3024
3036
  ],
3025
3037
  open: !1
3026
- }, yt = {
3038
+ }, ft = {
3027
3039
  modes: [
3028
3040
  "render",
3029
3041
  "point",
@@ -3386,7 +3398,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3386
3398
  distancePrecision: 2,
3387
3399
  areaUnit: "metric",
3388
3400
  areaPrecision: 2
3389
- }, qi = () => ({
3401
+ }, Ji = () => ({
3390
3402
  render: new et({
3391
3403
  modeName: "render",
3392
3404
  styles: {}
@@ -3526,7 +3538,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3526
3538
  styles: {}
3527
3539
  })
3528
3540
  });
3529
- var L = 63710088e-1, Ji = {
3541
+ var L = 63710088e-1, qi = {
3530
3542
  centimeters: L * 100,
3531
3543
  centimetres: L * 100,
3532
3544
  degrees: 360 / (2 * Math.PI),
@@ -3562,12 +3574,12 @@ function Qi(s, t, e = {}) {
3562
3574
  }, t, e);
3563
3575
  }
3564
3576
  function to(s, t = "kilometers") {
3565
- const e = Ji[t];
3577
+ const e = qi[t];
3566
3578
  if (!e)
3567
3579
  throw new Error(t + " units is invalid");
3568
3580
  return s * e;
3569
3581
  }
3570
- function gt(s) {
3582
+ function yt(s) {
3571
3583
  return s % 360 * Math.PI / 180;
3572
3584
  }
3573
3585
  function se(s) {
@@ -3760,13 +3772,13 @@ function re(s) {
3760
3772
  }
3761
3773
  return t;
3762
3774
  }
3763
- var ro = L * L / 2, Ot = Math.PI / 180;
3775
+ var ro = L * L / 2, Dt = Math.PI / 180;
3764
3776
  function ne(s) {
3765
3777
  const t = s.length - 1;
3766
3778
  if (t <= 2) return 0;
3767
3779
  let e = 0, i = 0;
3768
3780
  for (; i < t; ) {
3769
- const o = s[i], r = s[i + 1 === t ? 0 : i + 1], n = s[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Ot, l = r[1] * Ot, d = n[0] * Ot;
3781
+ const o = s[i], r = s[i + 1 === t ? 0 : i + 1], n = s[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Dt, l = r[1] * Dt, d = n[0] * Dt;
3770
3782
  e += (d - a) * Math.sin(l), i++;
3771
3783
  }
3772
3784
  return e * ro;
@@ -3794,14 +3806,14 @@ function le(s) {
3794
3806
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
3795
3807
  }
3796
3808
  function lo(s, t, e = {}) {
3797
- var i = le(s), o = le(t), r = gt(o[1] - i[1]), n = gt(o[0] - i[0]), a = gt(i[1]), l = gt(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3809
+ var i = le(s), o = le(t), r = yt(o[1] - i[1]), n = yt(o[0] - i[0]), a = yt(i[1]), l = yt(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3798
3810
  return to(
3799
3811
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3800
3812
  e.units
3801
3813
  );
3802
3814
  }
3803
3815
  var ho = lo;
3804
- const de = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians" ? "rad" : "km", Dt = (s) => {
3816
+ const de = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians" ? "rad" : "km", _t = (s) => {
3805
3817
  if (s >= 1)
3806
3818
  return {
3807
3819
  distance: s,
@@ -3833,12 +3845,12 @@ const de = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians
3833
3845
  l.push(p);
3834
3846
  }
3835
3847
  if (s.properties.distance = l[l.length - 1].properties.total, s.properties.unit = l[l.length - 1].properties.unit, s.properties.segments = JSON.parse(JSON.stringify(l)), t === "kilometers") {
3836
- const d = Dt(s.properties.distance);
3848
+ const d = _t(s.properties.distance);
3837
3849
  s.properties.distance = d.distance, s.properties.unit = d.unit, s.properties.segments.forEach(
3838
3850
  (h) => {
3839
- const c = Dt(h.properties.distance);
3851
+ const c = _t(h.properties.distance);
3840
3852
  h.properties.distance = c.distance, h.properties.unit = c.unit;
3841
- const u = Dt(h.properties.total);
3853
+ const u = _t(h.properties.total);
3842
3854
  h.properties.total = u.distance, h.properties.totalUnit = u.unit;
3843
3855
  }
3844
3856
  );
@@ -3854,14 +3866,14 @@ const de = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians
3854
3866
  );
3855
3867
  }
3856
3868
  ), s;
3857
- }, ce = (s) => s.charAt(0).toUpperCase() + s.slice(1), bt = ["td-point", "td-linestring", "td-polygon"];
3869
+ }, ce = (s) => s.charAt(0).toUpperCase() + s.slice(1), Mt = ["td-point", "td-linestring", "td-polygon"];
3858
3870
  var ge, ye, fe;
3859
3871
  const Bo = [
3860
- ...bt,
3861
- (ge = yt.polygonLayerSpec) == null ? void 0 : ge.source,
3862
- (ye = yt.lineLayerLabelSpec) == null ? void 0 : ye.source,
3863
- (fe = yt.pointLayerLabelSpec) == null ? void 0 : fe.source
3864
- ], Ue = (s, t, e = bt) => {
3872
+ ...Mt,
3873
+ (ge = ft.polygonLayerSpec) == null ? void 0 : ge.source,
3874
+ (ye = ft.lineLayerLabelSpec) == null ? void 0 : ye.source,
3875
+ (fe = ft.pointLayerLabelSpec) == null ? void 0 : fe.source
3876
+ ], Ue = (s, t, e = Mt) => {
3865
3877
  const i = JSON.parse(JSON.stringify(s));
3866
3878
  return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
3867
3879
  e.includes(o) || delete i.sources[o];
@@ -3882,17 +3894,17 @@ const Bo = [
3882
3894
  }
3883
3895
  return s;
3884
3896
  };
3885
- var uo = Object.defineProperty, po = (s, t, e) => t in s ? uo(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, tt = (s, t, e) => po(s, typeof t != "symbol" ? t + "" : t, e), St = 2 * Math.PI * 6378137 / 2;
3897
+ var uo = Object.defineProperty, po = (s, t, e) => t in s ? uo(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, tt = (s, t, e) => po(s, typeof t != "symbol" ? t + "" : t, e), xt = 2 * Math.PI * 6378137 / 2;
3886
3898
  function go(s) {
3887
3899
  return s = s || 256, 2 * Math.PI * 6378137 / s;
3888
3900
  }
3889
3901
  function yo(s, t, e = { enable: !0, decimal: 1 }) {
3890
3902
  s = Nt(s);
3891
- var i = s[0], o = s[1], r = i * St / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
3892
- return n = n * St / 180, e.enable && (r = Number(r.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [r, n];
3903
+ var i = s[0], o = s[1], r = i * xt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
3904
+ return n = n * xt / 180, e.enable && (r = Number(r.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [r, n];
3893
3905
  }
3894
3906
  function fo(s, t, e) {
3895
- var i = s[0], o = s[1], r = xo(t, e), n = (i + St) / r, a = (o + St) / r;
3907
+ var i = s[0], o = s[1], r = xo(t, e), n = (i + xt) / r, a = (o + xt) / r;
3896
3908
  return [n, a, t];
3897
3909
  }
3898
3910
  function Ve(s, t, e) {
@@ -4252,41 +4264,44 @@ class Fo {
4252
4264
  * @returns HTML Element
4253
4265
  */
4254
4266
  onAdd(t) {
4255
- var o, r, n, a, l;
4267
+ var o, r, n, a, l, d, h;
4256
4268
  if (this.options && this.options.modes && this.options.modes.length === 0)
4257
4269
  throw new Error("At least a mode must be enabled.");
4258
4270
  this.map = t;
4259
- const e = qi(), i = [];
4260
- return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((d) => {
4261
- if (this.options.modeOptions && this.options.modeOptions[d]) {
4262
- const h = this.options.modeOptions[d];
4263
- if (d === "select") {
4264
- const c = e[d];
4265
- if (c) {
4266
- const u = c.flags;
4267
- Object.keys(u).forEach((p) => {
4268
- h.flags[p] || (h.flags[p] = u[p]);
4271
+ const e = Ji(), i = [];
4272
+ return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((c) => {
4273
+ if (this.options.modeOptions && this.options.modeOptions[c]) {
4274
+ const u = this.options.modeOptions[c];
4275
+ if (c === "select") {
4276
+ const p = e[c];
4277
+ if (p) {
4278
+ const g = p.flags;
4279
+ Object.keys(g).forEach((y) => {
4280
+ u.flags[y] || (u.flags[y] = g[y]);
4269
4281
  });
4270
4282
  }
4271
4283
  }
4272
- i.push(h);
4273
- } else e[d] && i.push(e[d]);
4274
- }), i.forEach((d) => {
4275
- d.state !== "unregistered" && (d._state = "unregistered");
4284
+ i.push(u);
4285
+ } else e[c] && i.push(e[c]);
4286
+ }), i.forEach((c) => {
4287
+ c.state !== "unregistered" && (c._state = "unregistered");
4276
4288
  }), (a = (n = this.options) == null ? void 0 : n.modes) != null && a.includes("render") || (i.push(
4277
4289
  new et({
4278
4290
  modeName: "default",
4279
4291
  styles: {}
4280
4292
  })
4281
- ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Yi({
4282
- adapter: new $i({ map: t, ...this.options.adapterOptions }),
4293
+ ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new $i({
4294
+ adapter: new Yi({ map: t, ...this.options.adapterOptions }),
4283
4295
  modes: i
4284
- }), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
4285
- d.mode !== "default" && this.addTerradrawButton(d.mode);
4286
- }), Object.values(this.modeButtons).forEach((d) => {
4287
- var h;
4288
- (h = this.controlContainer) == null || h.appendChild(d);
4289
- }), (l = this.terradraw) == null || l.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
4296
+ }), (l = this.map) != null && l.loaded() ? this.terradraw.start() : (d = this.map) == null || d.once("load", () => {
4297
+ var c;
4298
+ (c = this.terradraw) == null || c.start();
4299
+ }), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((c) => {
4300
+ c.mode !== "default" && this.addTerradrawButton(c.mode);
4301
+ }), Object.values(this.modeButtons).forEach((c) => {
4302
+ var u;
4303
+ (u = this.controlContainer) == null || u.appendChild(c);
4304
+ }), (h = this.terradraw) == null || h.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
4290
4305
  }
4291
4306
  /**
4292
4307
  * Remove the plugin control from maplibre
@@ -4426,7 +4441,7 @@ class Fo {
4426
4441
  * @returns
4427
4442
  */
4428
4443
  cleanStyle(t, e) {
4429
- return Ue(t, e, bt);
4444
+ return Ue(t, e, Mt);
4430
4445
  }
4431
4446
  /**
4432
4447
  * Download button click event handler
@@ -4487,7 +4502,7 @@ class jo extends Fo {
4487
4502
  * @param options Plugin control options
4488
4503
  */
4489
4504
  constructor(e) {
4490
- let i = yt;
4505
+ let i = ft;
4491
4506
  e && (i = Object.assign(i, e));
4492
4507
  super({
4493
4508
  modes: i.modes,
@@ -4696,7 +4711,7 @@ class jo extends Fo {
4696
4711
  */
4697
4712
  cleanStyle(e, i) {
4698
4713
  var l, d, h;
4699
- const o = bt, r = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
4714
+ const o = Mt, r = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
4700
4715
  r && o.push(r);
4701
4716
  const n = (d = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : d.source;
4702
4717
  n && o.push(n);
@@ -5023,17 +5038,17 @@ export {
5023
5038
  jo as MaplibreMeasureControl,
5024
5039
  Fo as MaplibreTerradrawControl,
5025
5040
  Bo as TERRADRAW_MEASURE_SOURCE_IDS,
5026
- bt as TERRADRAW_SOURCE_IDS,
5041
+ Mt as TERRADRAW_SOURCE_IDS,
5027
5042
  ae as calcArea,
5028
5043
  he as calcDistance,
5029
5044
  ce as capitalize,
5030
5045
  Ue as cleanMaplibreStyle,
5031
5046
  ao as convertAreaUnit,
5032
- Dt as convertMetricDistance,
5047
+ _t as convertMetricDistance,
5033
5048
  co as debounce,
5034
5049
  Hi as defaultControlOptions,
5035
- yt as defaultMeasureControlOptions,
5036
- qi as getDefaultModeOptions,
5050
+ ft as defaultMeasureControlOptions,
5051
+ Ji as getDefaultModeOptions,
5037
5052
  de as getDistanceUnitName,
5038
5053
  ue as queryElevationByPoint,
5039
5054
  pe as queryElevationFromRasterDEM,