@watergis/maplibre-gl-terradraw 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- var Lt = Object.defineProperty;
2
- var Wt = (s, e, t) => e in s ? Lt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var L = (s, e, t) => Wt(s, typeof e != "symbol" ? e + "" : e, t);
1
+ var kt = Object.defineProperty;
2
+ var Wt = (s, e, t) => e in s ? kt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var k = (s, e, t) => Wt(s, typeof e != "symbol" ? e + "" : e, t);
4
4
  function M() {
5
5
  return M = Object.assign ? Object.assign.bind() : function(s) {
6
6
  for (var e = 1; e < arguments.length; e++) {
@@ -10,15 +10,15 @@ function M() {
10
10
  return s;
11
11
  }, M.apply(this, arguments);
12
12
  }
13
- function F(s, e = 9) {
13
+ function E(s, e = 9) {
14
14
  const t = Math.pow(10, e);
15
15
  return Math.round(s * t) / t;
16
16
  }
17
- const E = (s, e) => {
17
+ const F = (s, e) => {
18
18
  const { x: t, y: i } = s, { x: n, y: o } = e, r = n - t, a = o - i;
19
19
  return Math.sqrt(a * a + r * r);
20
20
  };
21
- class J {
21
+ class $ {
22
22
  constructor({ name: e, callback: t, unregister: i, register: n }) {
23
23
  this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = e, this.register = () => {
24
24
  this.registered || (this.registered = !0, n(t));
@@ -42,7 +42,7 @@ class ct {
42
42
  const t = this.getLngLatFromEvent(e);
43
43
  if (!t) return null;
44
44
  const { lng: i, lat: n } = t, { containerX: o, containerY: r } = this.getMapElementXYPosition(e), a = this.getButton(e), l = Array.from(this._heldKeys);
45
- return { lng: F(i, this._coordinatePrecision), lat: F(n, this._coordinatePrecision), containerX: o, containerY: r, button: a, heldKeys: l };
45
+ return { lng: E(i, this._coordinatePrecision), lat: E(n, this._coordinatePrecision), containerX: o, containerY: r, button: a, heldKeys: l };
46
46
  }
47
47
  register(e) {
48
48
  this._currentModeCallbacks = e, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
@@ -53,7 +53,7 @@ class ct {
53
53
  return this._coordinatePrecision;
54
54
  }
55
55
  getAdapterListeners() {
56
- return [new J({ name: "pointerdown", callback: (e) => {
56
+ return [new $({ name: "pointerdown", callback: (e) => {
57
57
  if (!this._currentModeCallbacks || !e.isPrimary) return;
58
58
  const t = this.getDrawEventFromEvent(e);
59
59
  t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
@@ -61,14 +61,14 @@ class ct {
61
61
  this.getMapEventElement().addEventListener("pointerdown", e);
62
62
  }, unregister: (e) => {
63
63
  this.getMapEventElement().removeEventListener("pointerdown", e);
64
- } }), new J({ name: "pointermove", callback: (e) => {
64
+ } }), new $({ name: "pointermove", callback: (e) => {
65
65
  if (!this._currentModeCallbacks || !e.isPrimary) return;
66
66
  e.preventDefault();
67
67
  const t = this.getDrawEventFromEvent(e);
68
68
  if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
69
69
  else if (this._dragState === "pre-dragging") {
70
70
  if (!this._lastDrawEvent) return;
71
- const i = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, n = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), r = E(i, n);
71
+ const i = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, n = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), r = F(i, n);
72
72
  let a = !1;
73
73
  if (a = o === "drawing" ? r < this._minPixelDragDistanceDrawing : o === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, a) return;
74
74
  this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (l) => {
@@ -81,13 +81,13 @@ class ct {
81
81
  this.getMapEventElement().addEventListener("pointermove", e);
82
82
  }, unregister: (e) => {
83
83
  this.getMapEventElement().removeEventListener("pointermove", e);
84
- } }), new J({ name: "contextmenu", callback: (e) => {
84
+ } }), new $({ name: "contextmenu", callback: (e) => {
85
85
  this._currentModeCallbacks && e.preventDefault();
86
86
  }, register: (e) => {
87
87
  this.getMapEventElement().addEventListener("contextmenu", e);
88
88
  }, unregister: (e) => {
89
89
  this.getMapEventElement().removeEventListener("contextmenu", e);
90
- } }), new J({ name: "pointerup", callback: (e) => {
90
+ } }), new $({ name: "pointerup", callback: (e) => {
91
91
  if (!this._currentModeCallbacks || e.target !== this.getMapEventElement() || !e.isPrimary) return;
92
92
  const t = this.getDrawEventFromEvent(e);
93
93
  t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (i) => {
@@ -97,13 +97,13 @@ class ct {
97
97
  this.getMapEventElement().addEventListener("pointerup", e);
98
98
  }, unregister: (e) => {
99
99
  this.getMapEventElement().removeEventListener("pointerup", e);
100
- } }), new J({ name: "keyup", callback: (e) => {
100
+ } }), new $({ name: "keyup", callback: (e) => {
101
101
  this._currentModeCallbacks && (this._heldKeys.delete(e.key), this._currentModeCallbacks.onKeyUp({ key: e.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => e.preventDefault() }));
102
102
  }, register: (e) => {
103
103
  this.getMapEventElement().addEventListener("keyup", e);
104
104
  }, unregister: (e) => {
105
105
  this.getMapEventElement().removeEventListener("keyup", e);
106
- } }), new J({ name: "keydown", callback: (e) => {
106
+ } }), new $({ name: "keydown", callback: (e) => {
107
107
  this._currentModeCallbacks && (this._heldKeys.add(e.key), this._currentModeCallbacks.onKeyDown({ key: e.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => e.preventDefault() }));
108
108
  }, register: (e) => {
109
109
  this.getMapEventElement().addEventListener("keydown", e);
@@ -307,23 +307,23 @@ var ht = class {
307
307
  return this.getPointResolutionFunc_;
308
308
  }
309
309
  };
310
- const re = 6378137, Q = Math.PI * re, Gt = [-Q, -Q, Q, Q], At = [-180, -85, 180, 85], ce = re * Math.log(Math.tan(Math.PI / 2));
311
- class $ extends ht {
310
+ const re = 6378137, Q = Math.PI * re, At = [-Q, -Q, Q, Q], Gt = [-180, -85, 180, 85], ce = re * Math.log(Math.tan(Math.PI / 2));
311
+ class J extends ht {
312
312
  constructor(e) {
313
- super({ code: e, units: "m", extent: Gt, global: !0, worldExtent: At, getPointResolution: function(t, i) {
313
+ super({ code: e, units: "m", extent: At, global: !0, worldExtent: Gt, getPointResolution: function(t, i) {
314
314
  return t / Math.cosh(i[1] / re);
315
315
  } });
316
316
  }
317
317
  }
318
- const Ue = [new $("EPSG:3857"), new $("EPSG:102100"), new $("EPSG:102113"), new $("EPSG:900913"), new $("http://www.opengis.net/def/crs/EPSG/0/3857"), new $("http://www.opengis.net/gml/srs/epsg.xml#3857")], Te = [-180, -90, 180, 90], Vt = 6378137 * Math.PI / 180;
319
- class T extends ht {
318
+ const Te = [new J("EPSG:3857"), new J("EPSG:102100"), new J("EPSG:102113"), new J("EPSG:900913"), new J("http://www.opengis.net/def/crs/EPSG/0/3857"), new J("http://www.opengis.net/gml/srs/epsg.xml#3857")], Ue = [-180, -90, 180, 90], Vt = 6378137 * Math.PI / 180;
319
+ class U extends ht {
320
320
  constructor(e, t) {
321
- super({ code: e, units: "degrees", extent: Te, axisOrientation: t, global: !0, metersPerUnit: Vt, worldExtent: Te });
321
+ super({ code: e, units: "degrees", extent: Ue, axisOrientation: t, global: !0, metersPerUnit: Vt, worldExtent: Ue });
322
322
  }
323
323
  }
324
- const Re = [new T("CRS:84"), new T("EPSG:4326", "neu"), new T("urn:ogc:def:crs:OGC:1.3:CRS84"), new T("urn:ogc:def:crs:OGC:2:84"), new T("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), new T("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), new T("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")];
324
+ const Re = [new U("CRS:84"), new U("EPSG:4326", "neu"), new U("urn:ogc:def:crs:OGC:1.3:CRS84"), new U("urn:ogc:def:crs:OGC:2:84"), new U("http://www.opengis.net/def/crs/OGC/1.3/CRS84"), new U("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"), new U("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")];
325
325
  let Me = {};
326
- function ye(s, e, t) {
326
+ function fe(s, e, t) {
327
327
  const i = s.getCode(), n = e.getCode();
328
328
  i in Me || (Me[i] = {}), Me[i][n] = t;
329
329
  }
@@ -332,20 +332,20 @@ function ut(s, e) {
332
332
  else e = s.slice();
333
333
  return e;
334
334
  }
335
- function Ut(s) {
336
- s.getCode(), ye(s, s, ut);
335
+ function Tt(s) {
336
+ s.getCode(), fe(s, s, ut);
337
337
  }
338
338
  function Xe(s) {
339
339
  (function(e) {
340
- e.forEach(Ut);
340
+ e.forEach(Tt);
341
341
  })(s), s.forEach(function(e) {
342
342
  s.forEach(function(t) {
343
- e !== t && ye(e, t, ut);
343
+ e !== t && fe(e, t, ut);
344
344
  });
345
345
  });
346
346
  }
347
- var Ke, ze, Ye, b;
348
- Xe(Ue), Xe(Re), Ke = Ue, ze = function(s, e, t) {
347
+ var ze, Ke, Ye, b;
348
+ Xe(Te), Xe(Re), ze = Te, Ke = function(s, e, t) {
349
349
  const i = s.length;
350
350
  t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? s.slice() : new Array(i));
351
351
  for (let n = 0; n < i; n += t) {
@@ -360,14 +360,14 @@ Xe(Ue), Xe(Re), Ke = Ue, ze = function(s, e, t) {
360
360
  for (let n = 0; n < i; n += t) e[n] = 180 * s[n] / Q, e[n + 1] = 360 * Math.atan(Math.exp(s[n + 1] / re)) / Math.PI - 90;
361
361
  return e;
362
362
  }, Re.forEach(function(s) {
363
- Ke.forEach(function(e) {
364
- ye(s, e, ze), ye(e, s, Ye);
363
+ ze.forEach(function(e) {
364
+ fe(s, e, Ke), fe(e, s, Ye);
365
365
  });
366
366
  });
367
367
  (function(s) {
368
368
  s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
369
369
  })(b || (b = {}));
370
- const _e = "selected", se = "midPoint", ae = "closingPoint", De = "snappingPoint";
370
+ const De = "selected", se = "midPoint", ae = "closingPoint", _e = "snappingPoint";
371
371
  function we(s) {
372
372
  return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
373
373
  }
@@ -376,11 +376,11 @@ function He(s) {
376
376
  return typeof e == "number" && !isNaN(new Date(e).valueOf());
377
377
  }(s);
378
378
  }
379
- const Tt = "Feature mode property does not match the mode being added to";
380
- var z;
379
+ const Ut = "Feature mode property does not match the mode being added to";
380
+ var K;
381
381
  (function(s) {
382
382
  s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
383
- })(z || (z = {}));
383
+ })(K || (K = {}));
384
384
  class N {
385
385
  get state() {
386
386
  return this._state;
@@ -398,7 +398,7 @@ class N {
398
398
  registerBehaviors(e) {
399
399
  }
400
400
  constructor(e) {
401
- this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = z.Drawing, this.mode = "base", this._state = "unregistered", this._styles = e && e.styles ? M({}, e.styles) : {}, this.pointerDistance = e && e.pointerDistance || 40, this.validate = e && e.validation, this.projection = e && e.projection || "web-mercator";
401
+ this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = K.Drawing, this.mode = "base", this._state = "unregistered", this._styles = e && e.styles ? M({}, e.styles) : {}, this.pointerDistance = e && e.pointerDistance || 40, this.validate = e && e.validation, this.projection = e && e.projection || "web-mercator";
402
402
  }
403
403
  setDrawing() {
404
404
  if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
@@ -443,7 +443,7 @@ class N {
443
443
  }
444
444
  validateModeFeature(e, t) {
445
445
  const i = this.performFeatureValidation(e);
446
- return i.valid ? e.properties.mode !== this.mode ? { valid: !1, reason: Tt } : t(e) : { valid: !1, reason: i.reason };
446
+ return i.valid ? e.properties.mode !== this.mode ? { valid: !1, reason: Ut } : t(e) : { valid: !1, reason: i.reason };
447
447
  }
448
448
  onFinish(e, t) {
449
449
  }
@@ -477,7 +477,7 @@ class N {
477
477
  }
478
478
  class Rt extends N {
479
479
  constructor(...e) {
480
- super(...e), this.type = z.Select;
480
+ super(...e), this.type = K.Select;
481
481
  }
482
482
  }
483
483
  function V(s, e) {
@@ -485,29 +485,29 @@ function V(s, e) {
485
485
  return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
486
486
  }
487
487
  const Oe = 63710088e-1;
488
- function _(s) {
488
+ function D(s) {
489
489
  return s % 360 * Math.PI / 180;
490
490
  }
491
491
  function gt(s) {
492
492
  return s / (Oe / 1e3);
493
493
  }
494
- function U(s) {
494
+ function T(s) {
495
495
  return s % (2 * Math.PI) * 180 / Math.PI;
496
496
  }
497
- const Je = 57.29577951308232, $e = 0.017453292519943295, me = 6378137, S = (s, e) => ({ x: s === 0 ? 0 : s * $e * me, y: e === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + e * $e / 2)) * me }), W = (s, e) => ({ lng: s === 0 ? 0 : Je * (s / me), lat: e === 0 ? 0 : (2 * Math.atan(Math.exp(e / me)) - Math.PI / 2) * Je });
497
+ const $e = 57.29577951308232, Je = 0.017453292519943295, me = 6378137, S = (s, e) => ({ x: s === 0 ? 0 : s * Je * me, y: e === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + e * Je / 2)) * me }), W = (s, e) => ({ lng: s === 0 ? 0 : $e * (s / me), lat: e === 0 ? 0 : (2 * Math.atan(Math.exp(e / me)) - Math.PI / 2) * $e });
498
498
  function Xt(s, e, t) {
499
- const i = _(s[0]), n = _(s[1]), o = _(t), r = gt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(o));
500
- return [U(i + Math.atan2(Math.sin(o) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), U(a)];
499
+ const i = D(s[0]), n = D(s[1]), o = D(t), r = gt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(o));
500
+ return [T(i + Math.atan2(Math.sin(o) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), T(a)];
501
501
  }
502
502
  function qe(s) {
503
503
  const { center: e, radiusKilometers: t, coordinatePrecision: i } = s, n = s.steps ? s.steps : 64, o = [];
504
504
  for (let r = 0; r < n; r++) {
505
505
  const a = Xt(e, t, -360 * r / n);
506
- o.push([F(a[0], i), F(a[1], i)]);
506
+ o.push([E(a[0], i), E(a[1], i)]);
507
507
  }
508
508
  return o.push(o[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [o] }, properties: {} };
509
509
  }
510
- function ke(s) {
510
+ function Le(s) {
511
511
  const e = { epsilon: 0 };
512
512
  let t;
513
513
  if (s.geometry.type === "Polygon") t = s.geometry.coordinates;
@@ -522,14 +522,14 @@ function ke(s) {
522
522
  return r < 0 - e.epsilon || r > 1 + e.epsilon;
523
523
  }
524
524
  function o(r, a, l, d) {
525
- const c = t[r][a], h = t[r][a + 1], u = t[l][d], g = t[l][d + 1], p = function(y, C, m, v) {
526
- if (he(y, m) || he(y, v) || he(C, m) || he(v, m)) return null;
527
- const x = y[0], w = y[1], I = C[0], D = C[1], G = m[0], O = m[1], B = v[0], Y = v[1], H = (x - I) * (O - Y) - (w - D) * (G - B);
528
- return H === 0 ? null : [((x * D - w * I) * (G - B) - (x - I) * (G * Y - O * B)) / H, ((x * D - w * I) * (O - Y) - (w - D) * (G * Y - O * B)) / H];
525
+ const c = t[r][a], h = t[r][a + 1], u = t[l][d], g = t[l][d + 1], p = function(f, C, m, v) {
526
+ if (he(f, m) || he(f, v) || he(C, m) || he(v, m)) return null;
527
+ const x = f[0], w = f[1], I = C[0], _ = C[1], A = m[0], O = m[1], B = v[0], Y = v[1], H = (x - I) * (O - Y) - (w - _) * (A - B);
528
+ return H === 0 ? null : [((x * _ - w * I) * (A - B) - (x - I) * (A * Y - O * B)) / H, ((x * _ - w * I) * (O - Y) - (w - _) * (A * Y - O * B)) / H];
529
529
  }(c, h, u, g);
530
530
  if (p === null) return;
531
- let f, P;
532
- f = h[0] !== c[0] ? (p[0] - c[0]) / (h[0] - c[0]) : (p[1] - c[1]) / (h[1] - c[1]), P = g[0] !== u[0] ? (p[0] - u[0]) / (g[0] - u[0]) : (p[1] - u[1]) / (g[1] - u[1]), n(f) || n(P) || (p.toString(), i.push(p));
531
+ let y, P;
532
+ y = h[0] !== c[0] ? (p[0] - c[0]) / (h[0] - c[0]) : (p[1] - c[1]) / (h[1] - c[1]), P = g[0] !== u[0] ? (p[0] - u[0]) / (g[0] - u[0]) : (p[1] - u[1]) / (g[1] - u[1]), n(y) || n(P) || (p.toString(), i.push(p));
533
533
  }
534
534
  }
535
535
  function he(s, e) {
@@ -544,14 +544,14 @@ function Ze(s) {
544
544
  for (; Math.round(s * e) / e !== s; ) e *= 10, t++;
545
545
  return t;
546
546
  }
547
- const Kt = "Feature is not a Polygon", zt = "Feature has holes", Yt = "Feature has less than 4 coordinates", Ht = "Feature has invalid coordinates", Jt = "Feature coordinates are not closed";
547
+ const zt = "Feature is not a Polygon", Kt = "Feature has holes", Yt = "Feature has less than 4 coordinates", Ht = "Feature has invalid coordinates", $t = "Feature coordinates are not closed";
548
548
  function Se(s, e) {
549
- return s.geometry.type !== "Polygon" ? { valid: !1, reason: Kt } : s.geometry.coordinates.length !== 1 ? { valid: !1, reason: zt } : s.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Yt } : s.geometry.coordinates[0].every((n) => xe(n, e)) ? (t = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || t[1] !== i[1] ? { valid: !1, reason: Jt } : { valid: !0 } : { valid: !1, reason: Ht };
549
+ return s.geometry.type !== "Polygon" ? { valid: !1, reason: zt } : s.geometry.coordinates.length !== 1 ? { valid: !1, reason: Kt } : s.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Yt } : s.geometry.coordinates[0].every((n) => xe(n, e)) ? (t = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || t[1] !== i[1] ? { valid: !1, reason: $t } : { valid: !0 } : { valid: !1, reason: Ht };
550
550
  var t, i;
551
551
  }
552
552
  function de(s, e) {
553
553
  const t = Se(s, e);
554
- return t.valid ? ke(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
554
+ return t.valid ? Le(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
555
555
  }
556
556
  class pt extends N {
557
557
  constructor(e) {
@@ -628,12 +628,12 @@ class pt extends N {
628
628
  return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
629
629
  }(this.center, [e.lng, e.lat]);
630
630
  i = function(o) {
631
- const { center: r, radiusKilometers: a, coordinatePrecision: l } = o, d = o.steps ? o.steps : 64, c = 1e3 * a, [h, u] = r, { x: g, y: p } = S(h, u), f = [];
631
+ const { center: r, radiusKilometers: a, coordinatePrecision: l } = o, d = o.steps ? o.steps : 64, c = 1e3 * a, [h, u] = r, { x: g, y: p } = S(h, u), y = [];
632
632
  for (let P = 0; P < d; P++) {
633
- const y = 360 * P / d * Math.PI / 180, C = c * Math.cos(y), m = c * Math.sin(y), [v, x] = [g + C, p + m], { lng: w, lat: I } = W(v, x);
634
- f.push([F(w, l), F(I, l)]);
633
+ const f = 360 * P / d * Math.PI / 180, C = c * Math.cos(f), m = c * Math.sin(f), [v, x] = [g + C, p + m], { lng: w, lat: I } = W(v, x);
634
+ y.push([E(w, l), E(I, l)]);
635
635
  }
636
- return f.push(f[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [f] }, properties: {} };
636
+ return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
637
637
  }({ center: this.center, radiusKilometers: t * n, coordinatePrecision: this.coordinatePrecision });
638
638
  } else {
639
639
  if (this.projection !== "globe") throw new Error("Invalid projection");
@@ -644,7 +644,7 @@ class pt extends N {
644
644
  }
645
645
  }
646
646
  }
647
- class ft extends N {
647
+ class yt extends N {
648
648
  constructor(e) {
649
649
  super(e), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = void 0, this.keyEvents = void 0, this.cursors = void 0, this.preventPointsNearClose = void 0, this.autoClose = void 0, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1;
650
650
  const t = { start: "crosshair", close: "pointer" };
@@ -673,8 +673,8 @@ class ft extends N {
673
673
  }
674
674
  onMouseMove(e) {
675
675
  if (this.currentId === void 0 || this.startingClick === !1) return;
676
- const t = this.store.getGeometryCopy(this.currentId), i = t.coordinates[0].length - 2, [n, o] = t.coordinates[0][i], { x: r, y: a } = this.project(n, o), l = E({ x: r, y: a }, { x: e.containerX, y: e.containerY }), [d, c] = t.coordinates[0][0], { x: h, y: u } = this.project(d, c);
677
- if (E({ x: h, y: u }, { x: e.containerX, y: e.containerY }) < this.pointerDistance) {
676
+ const t = this.store.getGeometryCopy(this.currentId), i = t.coordinates[0].length - 2, [n, o] = t.coordinates[0][i], { x: r, y: a } = this.project(n, o), l = F({ x: r, y: a }, { x: e.containerX, y: e.containerY }), [d, c] = t.coordinates[0][0], { x: h, y: u } = this.project(d, c);
677
+ if (F({ x: h, y: u }, { x: e.containerX, y: e.containerY }) < this.pointerDistance) {
678
678
  if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
679
679
  this.preventNewFeature = !1;
680
680
  }, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
@@ -725,17 +725,17 @@ class j {
725
725
  this.store = void 0, this.mode = void 0, this.project = void 0, this.unproject = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.projection = void 0, this.store = e, this.mode = t, this.project = i, this.unproject = n, this.pointerDistance = o, this.coordinatePrecision = r, this.projection = a;
726
726
  }
727
727
  }
728
- function yt({ unproject: s, point: e, pointerDistance: t }) {
728
+ function ft({ unproject: s, point: e, pointerDistance: t }) {
729
729
  const i = t / 2, { x: n, y: o } = e;
730
730
  return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[s(n - i, o - i), s(n + i, o - i), s(n + i, o + i), s(n - i, o + i), s(n - i, o - i)].map((r) => [r.lng, r.lat])] } };
731
731
  }
732
- class Le extends j {
732
+ class ke extends j {
733
733
  constructor(e) {
734
734
  super(e);
735
735
  }
736
736
  create(e) {
737
737
  const { containerX: t, containerY: i } = e;
738
- return yt({ unproject: this.unproject, point: { x: t, y: i }, pointerDistance: this.pointerDistance });
738
+ return ft({ unproject: this.unproject, point: { x: t, y: i }, pointerDistance: this.pointerDistance });
739
739
  }
740
740
  }
741
741
  class We extends j {
@@ -744,7 +744,7 @@ class We extends j {
744
744
  }
745
745
  measure(e, t) {
746
746
  const { x: i, y: n } = this.project(t[0], t[1]);
747
- return E({ x: i, y: n }, { x: e.containerX, y: e.containerY });
747
+ return F({ x: i, y: n }, { x: e.containerX, y: e.containerY });
748
748
  }
749
749
  }
750
750
  class mt extends j {
@@ -768,25 +768,25 @@ class mt extends j {
768
768
  }
769
769
  }
770
770
  function Qe(s, e, t) {
771
- const i = _(s[0]), n = _(s[1]), o = _(t), r = gt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(o));
772
- return [U(i + Math.atan2(Math.sin(o) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), U(a)];
771
+ const i = D(s[0]), n = D(s[1]), o = D(t), r = gt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(o));
772
+ return [T(i + Math.atan2(Math.sin(o) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), T(a)];
773
773
  }
774
774
  function le({ x: s, y: e }, t, i) {
775
- const n = _(i);
775
+ const n = D(i);
776
776
  return { x: s + t * Math.cos(n), y: e + t * Math.sin(n) };
777
777
  }
778
778
  function et(s, e) {
779
- const t = _(s[0]), i = _(e[0]), n = _(s[1]), o = _(e[1]), r = Math.sin(i - t) * Math.cos(o), a = Math.cos(n) * Math.sin(o) - Math.sin(n) * Math.cos(o) * Math.cos(i - t);
780
- return U(Math.atan2(r, a));
779
+ const t = D(s[0]), i = D(e[0]), n = D(s[1]), o = D(e[1]), r = Math.sin(i - t) * Math.cos(o), a = Math.cos(n) * Math.sin(o) - Math.sin(n) * Math.cos(o) * Math.cos(i - t);
780
+ return T(Math.atan2(r, a));
781
781
  }
782
- function A({ x: s, y: e }, { x: t, y: i }) {
782
+ function G({ x: s, y: e }, { x: t, y: i }) {
783
783
  let n = Math.atan2(i - e, t - s);
784
784
  return n *= 180 / Math.PI, n > 180 ? n -= 360 : n < -180 && (n += 360), n;
785
785
  }
786
- function K(s) {
786
+ function z(s) {
787
787
  return (s + 360) % 360;
788
788
  }
789
- function $t(s, e, t) {
789
+ function Jt(s, e, t) {
790
790
  const i = [], n = s.length;
791
791
  let o, r, a, l = 0;
792
792
  for (let c = 0; c < s.length && !(e >= l && c === s.length - 1); c++) {
@@ -821,7 +821,7 @@ class qt extends j {
821
821
  Number.isInteger(r) || (r = Math.floor(r) + 1);
822
822
  const a = [];
823
823
  for (let d = 0; d < r; d++) {
824
- const c = $t(n, i * d, i * (d + 1));
824
+ const c = Jt(n, i * d, i * (d + 1));
825
825
  a.push(c);
826
826
  }
827
827
  const l = [];
@@ -834,8 +834,8 @@ class qt extends j {
834
834
  l += 1;
835
835
  const p = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((g - h) / 2) ** 2));
836
836
  if (p === 0 || isNaN(p)) return d;
837
- for (let f = 0; f <= l; f++) {
838
- const P = f / l, y = Math.sin((1 - P) * p) / Math.sin(p), C = Math.sin(P * p) / Math.sin(p), m = y * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(g), v = y * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(g), x = y * Math.sin(c) + C * Math.sin(u);
837
+ for (let y = 0; y <= l; y++) {
838
+ const P = y / l, f = Math.sin((1 - P) * p) / Math.sin(p), C = Math.sin(P * p) / Math.sin(p), m = f * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(g), v = f * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(g), x = f * Math.sin(c) + C * Math.sin(u);
839
839
  if (isNaN(m) || isNaN(v) || isNaN(x)) continue;
840
840
  const w = Math.atan2(x, Math.sqrt(m ** 2 + v ** 2)), I = Math.atan2(v, m);
841
841
  isNaN(w) || isNaN(I) || d.push([tt(I), tt(w)]);
@@ -845,7 +845,7 @@ class qt extends j {
845
845
  return this.limitCoordinates(o);
846
846
  }
847
847
  limitCoordinates(e) {
848
- return e.map((t) => [F(t[0], this.config.coordinatePrecision), F(t[1], this.config.coordinatePrecision)]);
848
+ return e.map((t) => [E(t[0], this.config.coordinatePrecision), E(t[1], this.config.coordinatePrecision)]);
849
849
  }
850
850
  }
851
851
  function ee(s, e) {
@@ -900,13 +900,13 @@ class Pt extends N {
900
900
  updateToLine(e, t) {
901
901
  if (!this.currentId) return;
902
902
  const i = this.store.getGeometryCopy(this.currentId).coordinates, [n, o] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: r, y: a } = this.project(n, o);
903
- if (E({ x: r, y: a }, { x: t.x, y: t.y }) < this.pointerDistance) return void this.close();
903
+ if (F({ x: r, y: a }, { x: t.x, y: t.y }) < this.pointerDistance) return void this.close();
904
904
  this.setCursor(this.cursors.close);
905
905
  const l = [...i, e];
906
906
  this.updateGeometries(l, i[i.length - 1], b.Commit), this.currentCoordinate++;
907
907
  }
908
908
  registerBehaviors(e) {
909
- this.coordinateSnapping = new mt(e, new We(e), new Le(e)), this.insertPoint = new qt(e);
909
+ this.coordinateSnapping = new mt(e, new We(e), new ke(e)), this.insertPoint = new qt(e);
910
910
  }
911
911
  start() {
912
912
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -920,7 +920,7 @@ class Pt extends N {
920
920
  if (t) {
921
921
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: t } }]);
922
922
  else {
923
- const [r] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [De]: !0 } }]);
923
+ const [r] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [_e]: !0 } }]);
924
924
  this.snappedPointId = r;
925
925
  }
926
926
  e.lng = t[0], e.lat = t[1];
@@ -930,7 +930,7 @@ class Pt extends N {
930
930
  const n = this.store.getGeometryCopy(this.currentId).coordinates;
931
931
  if (n.pop(), this.closingPointId) {
932
932
  const [r, a] = n[n.length - 1], { x: l, y: d } = this.project(r, a);
933
- E({ x: l, y: d }, { x: e.containerX, y: e.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
933
+ F({ x: l, y: d }, { x: e.containerX, y: e.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
934
934
  }
935
935
  let o = [...n, i];
936
936
  if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
@@ -1066,20 +1066,20 @@ function R(s, e) {
1066
1066
  return Math.acos(Math.min(Math.max(t, -1), 1));
1067
1067
  }
1068
1068
  function be(s) {
1069
- const e = _(s[1]), t = _(s[0]);
1069
+ const e = D(s[1]), t = D(s[0]);
1070
1070
  return [Math.cos(e) * Math.cos(t), Math.cos(e) * Math.sin(t), Math.sin(e)];
1071
1071
  }
1072
1072
  function X(s) {
1073
- const [e, t, i] = s, n = U(Math.asin(i));
1074
- return [U(Math.atan2(t, e)), n];
1073
+ const [e, t, i] = s, n = T(Math.asin(i));
1074
+ return [T(Math.atan2(t, e)), n];
1075
1075
  }
1076
1076
  function ii(s, e, t) {
1077
1077
  const i = be(s), n = be(e), o = be(t), [r, a, l] = o, [d, c, h] = function(B, Y) {
1078
- const [H, Be, Ne] = B, [Ge, Ae, Ve] = Y;
1079
- return [Be * Ve - Ne * Ae, Ne * Ge - H * Ve, H * Ae - Be * Ge];
1080
- }(i, n), u = c * l - h * a, g = h * r - d * l, p = d * a - c * r, f = p * c - g * h, P = u * h - p * d, y = g * d - u * c, C = 1 / Math.sqrt(Math.pow(f, 2) + Math.pow(P, 2) + Math.pow(y, 2)), m = [f * C, P * C, y * C], v = [-1 * f * C, -1 * P * C, -1 * y * C], x = R(i, n), w = R(i, m), I = R(n, m), D = R(i, v), G = R(n, v);
1078
+ const [H, Be, Ne] = B, [Ae, Ge, Ve] = Y;
1079
+ return [Be * Ve - Ne * Ge, Ne * Ae - H * Ve, H * Ge - Be * Ae];
1080
+ }(i, n), u = c * l - h * a, g = h * r - d * l, p = d * a - c * r, y = p * c - g * h, P = u * h - p * d, f = g * d - u * c, C = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(P, 2) + Math.pow(f, 2)), m = [y * C, P * C, f * C], v = [-1 * y * C, -1 * P * C, -1 * f * C], x = R(i, n), w = R(i, m), I = R(n, m), _ = R(i, v), A = R(n, v);
1081
1081
  let O;
1082
- return O = w < D && w < G || I < D && I < G ? m : v, R(i, O) > x || R(n, O) > x ? V(X(O), X(i)) <= V(X(O), X(n)) ? [X(i), !0, !1] : [X(n), !1, !0] : [X(O), !1, !1];
1082
+ return O = w < _ && w < A || I < _ && I < A ? m : v, R(i, O) > x || R(n, O) > x ? V(X(O), X(i)) <= V(X(O), X(n)) ? [X(i), !0, !1] : [X(n), !1, !0] : [X(O), !1, !1];
1083
1083
  }
1084
1084
  function ni(s, e, t) {
1085
1085
  const i = e.x - s.x, n = e.y - s.y, o = Math.max(0, Math.min(1, ((t.x - s.x) * i + (t.y - s.y) * n) / (i * i + n * n)));
@@ -1103,28 +1103,28 @@ class oi extends j {
1103
1103
  let d;
1104
1104
  const c = [e.lng, e.lat];
1105
1105
  if (this.config.projection === "web-mercator" ? d = function(u, g) {
1106
- let p = [1 / 0, 1 / 0], f = 1 / 0;
1106
+ let p = [1 / 0, 1 / 0], y = 1 / 0;
1107
1107
  for (let P of g) {
1108
- const y = P[0], C = P[1];
1108
+ const f = P[0], C = P[1];
1109
1109
  let m, v = 1 / 0;
1110
- const x = S(y[0], y[1]), w = S(C[0], C[1]), I = S(u[0], u[1]);
1111
- if (y[0] === u[0] && y[1] === u[1]) m = y;
1110
+ const x = S(f[0], f[1]), w = S(C[0], C[1]), I = S(u[0], u[1]);
1111
+ if (f[0] === u[0] && f[1] === u[1]) m = f;
1112
1112
  else if (C[0] === u[0] && C[1] === u[1]) m = C;
1113
1113
  else {
1114
- const { x: D, y: G } = ni(x, w, I), { lng: O, lat: B } = W(D, G);
1114
+ const { x: _, y: A } = ni(x, w, I), { lng: O, lat: B } = W(_, A);
1115
1115
  m = [O, B];
1116
1116
  }
1117
- m && (v = E(I, S(m[0], m[1])), v < f && (p = m, f = v));
1117
+ m && (v = F(I, S(m[0], m[1])), v < y && (p = m, y = v));
1118
1118
  }
1119
- return f === 1 / 0 ? void 0 : { coordinate: p, distance: f };
1119
+ return y === 1 / 0 ? void 0 : { coordinate: p, distance: y };
1120
1120
  }(c, l) : this.config.projection === "globe" && (d = function(u, g) {
1121
- let p = [1 / 0, 1 / 0], f = 1 / 0;
1121
+ let p = [1 / 0, 1 / 0], y = 1 / 0;
1122
1122
  for (let P of g) {
1123
- const y = P[0], C = P[1];
1123
+ const f = P[0], C = P[1];
1124
1124
  let m, v = 1 / 0;
1125
- y[0] === u[0] && y[1] === u[1] ? m = y : C[0] === u[0] && C[1] === u[1] ? m = C : [m] = ii(y, C, u), m && (v = V(u, m), v < f && (p = m, f = v));
1125
+ f[0] === u[0] && f[1] === u[1] ? m = f : C[0] === u[0] && C[1] === u[1] ? m = C : [m] = ii(f, C, u), m && (v = V(u, m), v < y && (p = m, y = v));
1126
1126
  }
1127
- return f === 1 / 0 ? void 0 : { coordinate: p, distance: f };
1127
+ return y === 1 / 0 ? void 0 : { coordinate: p, distance: y };
1128
1128
  }(c, l)), !d) return;
1129
1129
  const h = this.pixelDistance.measure(e, d.coordinate);
1130
1130
  h < o.minDistance && h < this.pointerDistance && (o.coord = d.coordinate, o.minDistance = h);
@@ -1149,7 +1149,7 @@ class xt extends N {
1149
1149
  this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.snappedPointId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(t, { mode: this.mode, action: "draw" });
1150
1150
  }
1151
1151
  registerBehaviors(e) {
1152
- const t = new Le(e);
1152
+ const t = new ke(e);
1153
1153
  this.pixelDistance = new We(e), this.lineSnapping = new oi(e, this.pixelDistance, t), this.coordinateSnapping = new mt(e, this.pixelDistance, t), this.closingPoints = new ti(e, this.pixelDistance);
1154
1154
  }
1155
1155
  start() {
@@ -1164,7 +1164,7 @@ class xt extends N {
1164
1164
  if (t) {
1165
1165
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: t } }]);
1166
1166
  else {
1167
- const [o] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [De]: !0 } }]);
1167
+ const [o] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [_e]: !0 } }]);
1168
1168
  this.snappedPointId = o;
1169
1169
  }
1170
1170
  e.lng = t[0], e.lat = t[1];
@@ -1258,7 +1258,7 @@ class xt extends N {
1258
1258
  if (e.properties.mode === this.mode) {
1259
1259
  if (e.geometry.type === "Polygon") return t.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, t.polygonFillColor, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, t.polygonOutlineColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, t.polygonOutlineWidth, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, t.polygonFillOpacity, e), t.zIndex = 10, t;
1260
1260
  if (e.geometry.type === "Point") {
1261
- const i = e.properties[ae], n = e.properties[De];
1261
+ const i = e.properties[ae], n = e.properties[_e];
1262
1262
  return t.pointWidth = this.getNumericStylingValue(i ? this.styles.closingPointWidth : n ? this.styles.snappingPointWidth : t.pointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(i ? this.styles.closingPointColor : n ? this.styles.snappingPointColor : t.pointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.closingPointOutlineColor : n ? this.styles.snappingPointOutlineColor : t.pointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.closingPointOutlineWidth : n ? this.styles.snappingPointOutlineWidth : 2, 2, e), t.zIndex = 30, t;
1263
1263
  }
1264
1264
  }
@@ -1330,7 +1330,7 @@ class St extends N {
1330
1330
  }
1331
1331
  class ie extends N {
1332
1332
  constructor(e) {
1333
- super({ styles: e.styles }), this.type = z.Render, this.mode = "render", this.mode = e.modeName;
1333
+ super({ styles: e.styles }), this.type = K.Render, this.mode = "render", this.mode = e.modeName;
1334
1334
  }
1335
1335
  registerBehaviors(e) {
1336
1336
  this.mode = e.mode;
@@ -1370,16 +1370,16 @@ class ie extends N {
1370
1370
  }
1371
1371
  }
1372
1372
  function Ce(s, e) {
1373
- const t = s, i = e, n = _(t[1]), o = _(i[1]);
1374
- let r = _(i[0] - t[0]);
1373
+ const t = s, i = e, n = D(t[1]), o = D(i[1]);
1374
+ let r = D(i[0] - t[0]);
1375
1375
  r > Math.PI && (r -= 2 * Math.PI), r < -Math.PI && (r += 2 * Math.PI);
1376
- const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), l = (U(Math.atan2(r, a)) + 360) % 360;
1376
+ const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), l = (T(Math.atan2(r, a)) + 360) % 360;
1377
1377
  return l > 180 ? -(360 - l) : l;
1378
1378
  }
1379
1379
  function je(s, e, t) {
1380
1380
  let i = e;
1381
1381
  e < 0 && (i = -Math.abs(i));
1382
- const n = i / Oe, o = s[0] * Math.PI / 180, r = _(s[1]), a = _(t), l = n * Math.cos(a);
1382
+ const n = i / Oe, o = s[0] * Math.PI / 180, r = D(s[1]), a = D(t), l = n * Math.cos(a);
1383
1383
  let d = r + l;
1384
1384
  Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
1385
1385
  const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(r / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(r), u = [(180 * (o + n * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
@@ -1387,11 +1387,11 @@ function je(s, e, t) {
1387
1387
  }
1388
1388
  function Mt(s, e, t, i, n) {
1389
1389
  const o = i(s[0], s[1]), r = i(e[0], e[1]), { lng: a, lat: l } = n((o.x + r.x) / 2, (o.y + r.y) / 2);
1390
- return [F(a, t), F(l, t)];
1390
+ return [E(a, t), E(l, t)];
1391
1391
  }
1392
1392
  function si(s, e, t) {
1393
1393
  const i = je(s, 1e3 * V(s, e) / 2, Ce(s, e));
1394
- return [F(i[0], t), F(i[1], t)];
1394
+ return [E(i[0], t), E(i[1], t)];
1395
1395
  }
1396
1396
  function nt({ featureCoords: s, precision: e, unproject: t, project: i, projection: n }) {
1397
1397
  const o = [];
@@ -1487,12 +1487,12 @@ class li extends j {
1487
1487
  const g = h[u], p = g.geometry;
1488
1488
  if (p.type === "Point") {
1489
1489
  if (g.properties.selectionPoint || !t && g.properties[se]) continue;
1490
- const f = this.pixelDistance.measure(e, p.coordinates);
1491
- g.properties[se] && f < this.pointerDistance && f < d ? (d = f, o = g) : !g.properties[se] && f < this.pointerDistance && f < a && (a = f, i = g);
1490
+ const y = this.pixelDistance.measure(e, p.coordinates);
1491
+ g.properties[se] && y < this.pointerDistance && y < d ? (d = y, o = g) : !g.properties[se] && y < this.pointerDistance && y < a && (a = y, i = g);
1492
1492
  } else if (p.type === "LineString") {
1493
1493
  if (i) continue;
1494
- for (let f = 0; f < p.coordinates.length - 1; f++) {
1495
- const P = p.coordinates[f], y = p.coordinates[f + 1], C = bt({ x: e.containerX, y: e.containerY }, this.project(P[0], P[1]), this.project(y[0], y[1]));
1494
+ for (let y = 0; y < p.coordinates.length - 1; y++) {
1495
+ const P = p.coordinates[y], f = p.coordinates[y + 1], C = bt({ x: e.containerX, y: e.containerY }, this.project(P[0], P[1]), this.project(f[0], f[1]));
1496
1496
  C < this.pointerDistance && C < l && (l = C, n = g);
1497
1497
  }
1498
1498
  } else if (p.type === "Polygon") {
@@ -1530,13 +1530,13 @@ class di extends j {
1530
1530
  const c = o[d];
1531
1531
  let h, u;
1532
1532
  if (this.config.projection === "web-mercator") {
1533
- const g = S(this.dragPosition[0], this.dragPosition[1]), p = S(n[0], n[1]), f = S(c[0], c[1]), P = { x: g.x - p.x, y: g.y - p.y }, y = f.x - P.x, C = f.y - P.y, { lng: m, lat: v } = W(y, C);
1533
+ const g = S(this.dragPosition[0], this.dragPosition[1]), p = S(n[0], n[1]), y = S(c[0], c[1]), P = { x: g.x - p.x, y: g.y - p.y }, f = y.x - P.x, C = y.y - P.y, { lng: m, lat: v } = W(f, C);
1534
1534
  h = m, u = v;
1535
1535
  } else {
1536
1536
  const g = [this.dragPosition[0] - n[0], this.dragPosition[1] - n[1]];
1537
1537
  h = c[0] - g[0], u = c[1] - g[1];
1538
1538
  }
1539
- if (h = F(h, this.config.coordinatePrecision), u = F(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
1539
+ if (h = E(h, this.config.coordinatePrecision), u = E(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
1540
1540
  o[d] = [h, u];
1541
1541
  }
1542
1542
  i.type === "Polygon" && (o[o.length - 1] = [o[0][0], o[0][1]]);
@@ -1581,7 +1581,7 @@ class ci extends j {
1581
1581
  r[0] = a, r[h] = a;
1582
1582
  }
1583
1583
  const l = this.selectionPoints.getOneUpdated(n, a), d = l ? [l] : [], c = this.midPoints.getUpdated(r) || [];
1584
- return !(o.type !== "Point" && !t && ke({ type: "Feature", geometry: o, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: o }, ...d, ...c]), 0));
1584
+ return !(o.type !== "Point" && !t && Le({ type: "Feature", geometry: o, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: o }, ...d, ...c]), 0));
1585
1585
  }
1586
1586
  isDragging() {
1587
1587
  return this.draggedCoordinate.id !== null;
@@ -1644,12 +1644,12 @@ class hi extends j {
1644
1644
  let r;
1645
1645
  const a = { type: "Feature", geometry: n, properties: {} };
1646
1646
  if (this.config.projection === "web-mercator") {
1647
- if (r = A(ve(a), S(e.lng, e.lat)), !this.lastBearing) return void (this.lastBearing = r);
1647
+ if (r = G(ve(a), S(e.lng, e.lat)), !this.lastBearing) return void (this.lastBearing = r);
1648
1648
  ((h, u) => {
1649
1649
  if (u === 0 || u === 360 || u === -360) return h;
1650
- const g = 0.017453292519943295 * u, p = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([y, C]) => S(y, C)), f = p.reduce((y, C) => ({ x: y.x + C.x, y: y.y + C.y }), { x: 0, y: 0 });
1651
- f.x /= p.length, f.y /= p.length;
1652
- const P = p.map((y) => ({ x: f.x + (y.x - f.x) * Math.cos(g) - (y.y - f.y) * Math.sin(g), y: f.y + (y.x - f.x) * Math.sin(g) + (y.y - f.y) * Math.cos(g) })).map(({ x: y, y: C }) => [W(y, C).lng, W(y, C).lat]);
1650
+ const g = 0.017453292519943295 * u, p = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, C]) => S(f, C)), y = p.reduce((f, C) => ({ x: f.x + C.x, y: f.y + C.y }), { x: 0, y: 0 });
1651
+ y.x /= p.length, y.y /= p.length;
1652
+ const P = p.map((f) => ({ x: y.x + (f.x - y.x) * Math.cos(g) - (f.y - y.y) * Math.sin(g), y: y.y + (f.x - y.x) * Math.sin(g) + (f.y - y.y) * Math.cos(g) })).map(({ x: f, y: C }) => [W(f, C).lng, W(f, C).lat]);
1653
1653
  h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = P : h.geometry.coordinates = P;
1654
1654
  })(a, -(this.lastBearing - r));
1655
1655
  } else {
@@ -1659,14 +1659,14 @@ class hi extends j {
1659
1659
  if (u === 0 || u === 360 || u === -360) return h;
1660
1660
  const g = Pe(h);
1661
1661
  (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((p) => {
1662
- const f = Ce(g, p) + u, P = It(g, p), y = je(g, P, f);
1663
- p[0] = y[0], p[1] = y[1];
1662
+ const y = Ce(g, p) + u, P = It(g, p), f = je(g, P, y);
1663
+ p[0] = f[0], p[1] = f[1];
1664
1664
  });
1665
1665
  })(a, -(this.lastBearing - (r + 180)));
1666
1666
  }
1667
1667
  const l = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
1668
1668
  l.forEach((h) => {
1669
- h[0] = F(h[0], this.coordinatePrecision), h[1] = F(h[1], this.coordinatePrecision);
1669
+ h[0] = E(h[0], this.coordinatePrecision), h[1] = E(h[1], this.coordinatePrecision);
1670
1670
  });
1671
1671
  const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [];
1672
1672
  if (i && !i({ id: t, type: "Feature", geometry: n, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional })) return !1;
@@ -1688,7 +1688,7 @@ class ui extends j {
1688
1688
  const l = ve(r);
1689
1689
  if (this.config.projection === "web-mercator") {
1690
1690
  const g = S(e.lng, e.lat);
1691
- a = E(l, g);
1691
+ a = F(l, g);
1692
1692
  } else {
1693
1693
  if (this.config.projection !== "globe") throw new Error("Invalid projection");
1694
1694
  a = V(Pe({ type: "Feature", geometry: n, properties: {} }), o);
@@ -1697,20 +1697,20 @@ class ui extends j {
1697
1697
  const d = 1 - (this.lastDistance - a) / a;
1698
1698
  if (this.config.projection === "web-mercator") {
1699
1699
  const { lng: g, lat: p } = W(l.x, l.y);
1700
- (function(f, P, y) {
1701
- if (P === 1) return f;
1702
- const C = (f.geometry.type === "Polygon" ? f.geometry.coordinates[0] : f.geometry.coordinates).map(([x, w]) => S(x, w)), m = S(y[0], y[1]), v = C.map((x) => ({ x: m.x + (x.x - m.x) * P, y: m.y + (x.y - m.y) * P })).map(({ x, y: w }) => [W(x, w).lng, W(x, w).lat]);
1703
- f.geometry.type === "Polygon" ? f.geometry.coordinates[0] = v : f.geometry.coordinates = v;
1700
+ (function(y, P, f) {
1701
+ if (P === 1) return y;
1702
+ const C = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([x, w]) => S(x, w)), m = S(f[0], f[1]), v = C.map((x) => ({ x: m.x + (x.x - m.x) * P, y: m.y + (x.y - m.y) * P })).map(({ x, y: w }) => [W(x, w).lng, W(x, w).lat]);
1703
+ y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = v : y.geometry.coordinates = v;
1704
1704
  })(r, d, [g, p]);
1705
- } else this.config.projection === "globe" && function(g, p, f, P = "xy") {
1706
- p === 1 || (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.geometry.coordinates).forEach((y) => {
1707
- const C = It(f, y), m = Ce(f, y), v = je(f, C * p, m);
1708
- P !== "x" && P !== "xy" || (y[0] = v[0]), P !== "y" && P !== "xy" || (y[1] = v[1]);
1705
+ } else this.config.projection === "globe" && function(g, p, y, P = "xy") {
1706
+ p === 1 || (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.geometry.coordinates).forEach((f) => {
1707
+ const C = It(y, f), m = Ce(y, f), v = je(y, C * p, m);
1708
+ P !== "x" && P !== "xy" || (f[0] = v[0]), P !== "y" && P !== "xy" || (f[1] = v[1]);
1709
1709
  });
1710
1710
  }(r, d, Pe(r));
1711
1711
  const c = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
1712
1712
  c.forEach((g) => {
1713
- g[0] = F(g[0], this.coordinatePrecision), g[1] = F(g[1], this.coordinatePrecision);
1713
+ g[0] = E(g[0], this.coordinatePrecision), g[1] = E(g[1], this.coordinatePrecision);
1714
1714
  });
1715
1715
  const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
1716
1716
  if (i && !i({ id: t, type: "Feature", geometry: n, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional })) return !1;
@@ -1791,7 +1791,7 @@ class gi extends j {
1791
1791
  }
1792
1792
  scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: o }) {
1793
1793
  if (!this.isValidDragWebMercator(e, t.x - n.x, t.y - n.y)) return null;
1794
- let r = E(t, n) / E(t, i);
1794
+ let r = F(t, n) / F(t, i);
1795
1795
  return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(o, t.x, t.y, r, r), o;
1796
1796
  }
1797
1797
  oppositeFixedWebMercatorDrag(e) {
@@ -1846,7 +1846,7 @@ class gi extends j {
1846
1846
  getIndexesWebMercator(e, t) {
1847
1847
  let i, n = 1 / 0;
1848
1848
  for (let o = 0; o < e.length; o++) {
1849
- const r = E({ x: t.x, y: t.y }, { x: e[o][0], y: e[o][1] });
1849
+ const r = F({ x: t.x, y: t.y }, { x: e[o][0], y: e[o][1] });
1850
1850
  r < n && (i = o, n = r);
1851
1851
  }
1852
1852
  if (i === void 0) throw new Error("No closest coordinate found");
@@ -1873,7 +1873,7 @@ class gi extends j {
1873
1873
  if (t === "center" ? o = this.centerWebMercatorDrag(e) : t === "opposite" ? o = this.oppositeWebMercatorDrag(e) : t === "center-fixed" ? o = this.centerFixedWebMercatorDrag(e) : t === "opposite-fixed" && (o = this.oppositeFixedWebMercatorDrag(e)), !o) return !1;
1874
1874
  for (let d = 0; d < o.length; d++) {
1875
1875
  const c = o[d];
1876
- if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !xe(c, this.coordinatePrecision)) return !1;
1876
+ if (c[0] = E(c[0], this.coordinatePrecision), c[1] = E(c[1], this.coordinatePrecision), !xe(c, this.coordinatePrecision)) return !1;
1877
1877
  }
1878
1878
  const r = this.midPoints.getUpdated(o) || [], a = this.selectionPoints.getUpdated(o) || [], l = { type: n.geometry.type, coordinates: n.geometry.type === "Polygon" ? [o] : o };
1879
1879
  return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: l, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...r]), 0));
@@ -1902,13 +1902,13 @@ class pi extends Rt {
1902
1902
  this._state = "selecting";
1903
1903
  }
1904
1904
  registerBehaviors(e) {
1905
- this.pixelDistance = new We(e), this.clickBoundingBox = new Le(e), this.featuresAtMouseEvent = new li(e, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new ai(e), this.midPoints = new ri(e, this.selectionPoints), this.rotateFeature = new hi(e, this.selectionPoints, this.midPoints), this.scaleFeature = new ui(e, this.selectionPoints, this.midPoints), this.dragFeature = new di(e, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new ci(e, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new gi(e, this.pixelDistance, this.selectionPoints, this.midPoints);
1905
+ this.pixelDistance = new We(e), this.clickBoundingBox = new ke(e), this.featuresAtMouseEvent = new li(e, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new ai(e), this.midPoints = new ri(e, this.selectionPoints), this.rotateFeature = new hi(e, this.selectionPoints, this.midPoints), this.scaleFeature = new ui(e, this.selectionPoints, this.midPoints), this.dragFeature = new di(e, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new ci(e, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new gi(e, this.pixelDistance, this.selectionPoints, this.midPoints);
1906
1906
  }
1907
1907
  deselectFeature() {
1908
1908
  this.deselect();
1909
1909
  }
1910
1910
  deselect() {
1911
- const e = this.selected.filter((t) => this.store.has(t)).map((t) => ({ id: t, property: _e, value: !1 }));
1911
+ const e = this.selected.filter((t) => this.store.has(t)).map((t) => ({ id: t, property: De, value: !1 }));
1912
1912
  this.store.updateProperty(e), this.onDeselect(this.selected[0]), this.selected = [], this.selectionPoints.delete(), this.midPoints.delete();
1913
1913
  }
1914
1914
  deleteSelected() {
@@ -2032,7 +2032,7 @@ class pi extends Rt {
2032
2032
  if (e.properties.mode === this.mode && e.geometry.type === "Point") {
2033
2033
  if (e.properties.selectionPoint) return t.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, t.pointOutlineColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, t.pointWidth, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, e), t.zIndex = 30, t;
2034
2034
  if (e.properties.midPoint) return t.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, t.pointOutlineColor, e), t.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, e), t.zIndex = 40, t;
2035
- } else if (e.properties[_e]) {
2035
+ } else if (e.properties[De]) {
2036
2036
  if (e.geometry.type === "Polygon") return t.polygonFillColor = this.getHexColorStylingValue(this.styles.selectedPolygonColor, t.polygonFillColor, e), t.polygonOutlineWidth = this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth, t.polygonOutlineWidth, e), t.polygonOutlineColor = this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor, t.polygonOutlineColor, e), t.polygonFillOpacity = this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity, t.polygonFillOpacity, e), t.zIndex = 10, t;
2037
2037
  if (e.geometry.type === "LineString") return t.lineStringColor = this.getHexColorStylingValue(this.styles.selectedLineStringColor, t.lineStringColor, e), t.lineStringWidth = this.getNumericStylingValue(this.styles.selectedLineStringWidth, t.lineStringWidth, e), t.zIndex = 10, t;
2038
2038
  if (e.geometry.type === "Point") return t.pointWidth = this.getNumericStylingValue(this.styles.selectedPointWidth, t.pointWidth, e), t.pointColor = this.getHexColorStylingValue(this.styles.selectedPointColor, t.pointColor, e), t.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectedPointOutlineColor, t.pointOutlineColor, e), t.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectedPointOutlineWidth, t.pointOutlineWidth, e), t.zIndex = 10, t;
@@ -2040,9 +2040,9 @@ class pi extends Rt {
2040
2040
  return t;
2041
2041
  }
2042
2042
  }
2043
- class fi extends N {
2043
+ class yi extends N {
2044
2044
  constructor(...e) {
2045
- super(...e), this.type = z.Static, this.mode = "static";
2045
+ super(...e), this.type = K.Static, this.mode = "static";
2046
2046
  }
2047
2047
  start() {
2048
2048
  }
@@ -2068,11 +2068,11 @@ class fi extends N {
2068
2068
  return M({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2069
2069
  }
2070
2070
  }
2071
- function Ft(s, e, t, i, n) {
2071
+ function Et(s, e, t, i, n) {
2072
2072
  for (; i > t; ) {
2073
2073
  if (i - t > 600) {
2074
2074
  const l = i - t + 1, d = e - t + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
2075
- Ft(s, e, Math.max(t, Math.floor(e - d * h / l + u)), Math.min(i, Math.floor(e + (l - d) * h / l + u)), n);
2075
+ Et(s, e, Math.max(t, Math.floor(e - d * h / l + u)), Math.min(i, Math.floor(e + (l - d) * h / l + u)), n);
2076
2076
  }
2077
2077
  const o = s[e];
2078
2078
  let r = t, a = i;
@@ -2101,7 +2101,7 @@ function ne(s, e, t, i, n) {
2101
2101
  function oe(s, e) {
2102
2102
  return s.minX = Math.min(s.minX, e.minX), s.minY = Math.min(s.minY, e.minY), s.maxX = Math.max(s.maxX, e.maxX), s.maxY = Math.max(s.maxY, e.maxY), s;
2103
2103
  }
2104
- function yi(s, e) {
2104
+ function fi(s, e) {
2105
2105
  return s.minX - e.minX;
2106
2106
  }
2107
2107
  function mi(s, e) {
@@ -2117,7 +2117,7 @@ function Ci(s, e) {
2117
2117
  const t = Math.max(s.minX, e.minX), i = Math.max(s.minY, e.minY), n = Math.min(s.maxX, e.maxX), o = Math.min(s.maxY, e.maxY);
2118
2118
  return Math.max(0, n - t) * Math.max(0, o - i);
2119
2119
  }
2120
- function Fe(s, e) {
2120
+ function Ee(s, e) {
2121
2121
  return s.minX <= e.minX && s.minY <= e.minY && e.maxX <= s.maxX && e.maxY <= s.maxY;
2122
2122
  }
2123
2123
  function pe(s, e) {
@@ -2131,7 +2131,7 @@ function ot(s, e, t, i, n) {
2131
2131
  for (; o.length; ) {
2132
2132
  if ((t = o.pop()) - (e = o.pop()) <= i) continue;
2133
2133
  const r = e + Math.ceil((t - e) / i / 2) * i;
2134
- Ft(s, r, e, t, n), o.push(e, r, r, t);
2134
+ Et(s, r, e, t, n), o.push(e, r, r, t);
2135
2135
  }
2136
2136
  }
2137
2137
  class Pi {
@@ -2146,7 +2146,7 @@ class Pi {
2146
2146
  for (; t; ) {
2147
2147
  for (let r = 0; r < t.children.length; r++) {
2148
2148
  const a = t.children[r], l = t.leaf ? n(a) : a;
2149
- pe(e, l) && (t.leaf ? i.push(a) : Fe(e, l) ? this._all(a, i) : o.push(a));
2149
+ pe(e, l) && (t.leaf ? i.push(a) : Ee(e, l) ? this._all(a, i) : o.push(a));
2150
2150
  }
2151
2151
  t = o.pop();
2152
2152
  }
@@ -2160,7 +2160,7 @@ class Pi {
2160
2160
  for (let n = 0; n < t.children.length; n++) {
2161
2161
  const o = t.children[n], r = t.leaf ? this.toBBox(o) : o;
2162
2162
  if (pe(e, r)) {
2163
- if (t.leaf || Fe(e, r)) return !0;
2163
+ if (t.leaf || Ee(e, r)) return !0;
2164
2164
  i.push(o);
2165
2165
  }
2166
2166
  }
@@ -2200,7 +2200,7 @@ class Pi {
2200
2200
  const d = t.children.indexOf(e);
2201
2201
  d !== -1 && (t.children.splice(d, 1), n.push(t), this._condense(n));
2202
2202
  }
2203
- l || t.leaf || !Fe(t, i) ? a ? (r++, t = a.children[r], l = !1) : t = null : (n.push(t), o.push(r), r = 0, a = t, t = t.children[0]);
2203
+ l || t.leaf || !Ee(t, i) ? a ? (r++, t = a.children[r], l = !1) : t = null : (n.push(t), o.push(r), r = 0, a = t, t = t.children[0]);
2204
2204
  }
2205
2205
  }
2206
2206
  toBBox(e) {
@@ -2269,7 +2269,7 @@ class Pi {
2269
2269
  return n || i - t;
2270
2270
  }
2271
2271
  _chooseSplitAxis(e, t, i) {
2272
- const n = e.leaf ? this.compareMinX : yi, o = e.leaf ? this.compareMinY : mi;
2272
+ const n = e.leaf ? this.compareMinX : fi, o = e.leaf ? this.compareMinY : mi;
2273
2273
  this._allDistMargin(e, t, i, n) < this._allDistMargin(e, t, i, o) && e.children.sort(n);
2274
2274
  }
2275
2275
  _allDistMargin(e, t, i, n) {
@@ -2447,13 +2447,13 @@ class Si {
2447
2447
  return Object.keys(this.store).length;
2448
2448
  }
2449
2449
  }
2450
- const Mi = "Feature is not a Polygon or LineString", wi = "Feature intersects itself", bi = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: Mi } : ke(s) ? { valid: !1, reason: wi } : { valid: !0 };
2450
+ const Mi = "Feature is not a Polygon or LineString", wi = "Feature intersects itself", bi = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: Mi } : Le(s) ? { valid: !1, reason: wi } : { valid: !0 };
2451
2451
  function st(s, e, t) {
2452
- const i = A(s, e);
2453
- let n = A(e, t) - i;
2452
+ const i = G(s, e);
2453
+ let n = G(e, t) - i;
2454
2454
  return n < 0 && (n += 360), 180 - Math.abs(n - 90 - 90);
2455
2455
  }
2456
- class Et extends N {
2456
+ class Ft extends N {
2457
2457
  constructor(e) {
2458
2458
  super(e), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
2459
2459
  const t = { start: "crosshair", close: "pointer" };
@@ -2482,10 +2482,10 @@ class Et extends N {
2482
2482
  const n = 1 / Math.pow(10, this.coordinatePrecision - 1), o = Math.max(1e-6, n);
2483
2483
  i = [t[0], [e.lng, e.lat], [e.lng, e.lat - o], t[0]];
2484
2484
  } else if (this.currentCoordinate === 2) {
2485
- const n = t[0], o = t[1], r = Mt(n, o, this.coordinatePrecision, this.project, this.unproject), a = S(n[0], n[1]), l = S(r[0], r[1]), d = S(o[0], o[1]), c = S(e.lng, e.lat), h = E(c, a) < E(c, d), u = st(a, l, c), g = h ? 90 - u : st(a, l, c) - 90, p = E(l, c), f = Math.cos(_(g)) * p, P = A(a, d) + (function(x, w, I) {
2486
- const D = (I.x - w.x) * (x.y - w.y) - (I.y - w.y) * (x.x - w.x);
2487
- return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
2488
- }(a, d, c) === "right" ? -90 : 90), y = le(a, f, P), C = le(d, f, P), m = W(y.x, y.y), v = W(C.x, C.y);
2485
+ const n = t[0], o = t[1], r = Mt(n, o, this.coordinatePrecision, this.project, this.unproject), a = S(n[0], n[1]), l = S(r[0], r[1]), d = S(o[0], o[1]), c = S(e.lng, e.lat), h = F(c, a) < F(c, d), u = st(a, l, c), g = h ? 90 - u : st(a, l, c) - 90, p = F(l, c), y = Math.cos(D(g)) * p, P = G(a, d) + (function(x, w, I) {
2486
+ const _ = (I.x - w.x) * (x.y - w.y) - (I.y - w.y) * (x.x - w.x);
2487
+ return _ > 1e-10 ? "left" : _ < -1e-10 ? "right" : "left";
2488
+ }(a, d, c) === "right" ? -90 : 90), f = le(a, y, P), C = le(d, y, P), m = W(f.x, f.y), v = W(C.x, C.y);
2489
2489
  i = [t[0], t[1], [v.lng, v.lat], [m.lng, m.lat], t[0]];
2490
2490
  }
2491
2491
  i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
@@ -2530,10 +2530,10 @@ class Et extends N {
2530
2530
  return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
2531
2531
  }
2532
2532
  }
2533
- function _t(s, e, t) {
2533
+ function Dt(s, e, t) {
2534
2534
  return (e.x - s.x) * (t.y - s.y) - (e.y - s.y) * (t.x - s.x) <= 0;
2535
2535
  }
2536
- class Dt extends N {
2536
+ class _t extends N {
2537
2537
  constructor(e) {
2538
2538
  super(e), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
2539
2539
  const t = { start: "crosshair", close: "pointer" };
@@ -2565,16 +2565,16 @@ class Dt extends N {
2565
2565
  } else if (this.currentCoordinate === 2) {
2566
2566
  const n = t[0], o = t[1], r = [e.lng, e.lat], a = S(n[0], n[1]), l = S(o[0], o[1]), d = S(r[0], r[1]);
2567
2567
  if (this.direction === void 0) {
2568
- const m = _t(a, l, d);
2568
+ const m = Dt(a, l, d);
2569
2569
  this.direction = m ? "clockwise" : "anticlockwise";
2570
2570
  }
2571
- const c = E(a, l), h = A(a, l), u = A(a, d), g = this.arcPoints, p = [n], f = K(h), P = K(u);
2572
- let y;
2573
- this.direction === "anticlockwise" ? (y = P - f, y < 0 && (y += 360)) : (y = f - P, y < 0 && (y += 360));
2574
- const C = (this.direction === "anticlockwise" ? 1 : -1) * y / g;
2571
+ const c = F(a, l), h = G(a, l), u = G(a, d), g = this.arcPoints, p = [n], y = z(h), P = z(u);
2572
+ let f;
2573
+ this.direction === "anticlockwise" ? (f = P - y, f < 0 && (f += 360)) : (f = y - P, f < 0 && (f += 360));
2574
+ const C = (this.direction === "anticlockwise" ? 1 : -1) * f / g;
2575
2575
  p.push(o);
2576
2576
  for (let m = 0; m <= g; m++) {
2577
- const v = le(a, c, f + m * C), { lng: x, lat: w } = W(v.x, v.y), I = [F(x, this.coordinatePrecision), F(w, this.coordinatePrecision)];
2577
+ const v = le(a, c, y + m * C), { lng: x, lat: w } = W(v.x, v.y), I = [E(x, this.coordinatePrecision), E(w, this.coordinatePrecision)];
2578
2578
  I[0] !== p[p.length - 1][0] && I[1] !== p[p.length - 1][1] && p.push(I);
2579
2579
  }
2580
2580
  p.push(n), i = [...p];
@@ -2646,28 +2646,28 @@ class Ot extends N {
2646
2646
  onMouseMove(e) {
2647
2647
  if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
2648
2648
  if (this.currentCoordinate === 2) {
2649
- const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], o = [e.lng, e.lat], r = S(n[0], n[1]), a = S(o[0], o[1]), l = S(i[0], i[1]), d = E(l, r);
2649
+ const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], o = [e.lng, e.lat], r = S(n[0], n[1]), a = S(o[0], o[1]), l = S(i[0], i[1]), d = F(l, r);
2650
2650
  if (this.direction === void 0) {
2651
- const C = _t(l, r, a);
2651
+ const C = Dt(l, r, a);
2652
2652
  this.direction = C ? "clockwise" : "anticlockwise";
2653
2653
  }
2654
- const c = A(l, r), h = A(l, a), u = this.arcPoints, g = [n], p = K(c), f = K(h);
2654
+ const c = G(l, r), h = G(l, a), u = this.arcPoints, g = [n], p = z(c), y = z(h);
2655
2655
  let P;
2656
- this.direction === "anticlockwise" ? (P = f - p, P < 0 && (P += 360)) : (P = p - f, P < 0 && (P += 360));
2657
- const y = (this.direction === "anticlockwise" ? 1 : -1) * P / u;
2656
+ this.direction === "anticlockwise" ? (P = y - p, P < 0 && (P += 360)) : (P = p - y, P < 0 && (P += 360));
2657
+ const f = (this.direction === "anticlockwise" ? 1 : -1) * P / u;
2658
2658
  for (let C = 0; C <= u; C++) {
2659
- const m = le(l, d, p + C * y), { lng: v, lat: x } = W(m.x, m.y), w = [F(v, this.coordinatePrecision), F(x, this.coordinatePrecision)];
2659
+ const m = le(l, d, p + C * f), { lng: v, lat: x } = W(m.x, m.y), w = [E(v, this.coordinatePrecision), E(x, this.coordinatePrecision)];
2660
2660
  w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
2661
2661
  }
2662
2662
  this.updateLineStringGeometry(this.currentInitialArcId, g, b.Provisional);
2663
2663
  } else if (this.currentCoordinate === 3) {
2664
2664
  const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2665
2665
  if (t.length < 2 || !this.direction) return;
2666
- const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], o = t[t.length - 1], r = S(e.lng, e.lat), a = S(n[0], n[1]), l = S(o[0], o[1]), d = S(i[0], i[1]), c = E(d, a), h = E(d, r) < c ? a : r, u = A(d, r), g = A(d, a), p = A(d, l), f = K(g), P = K(p), y = K(u);
2667
- if (this.notInSector({ normalizedCursor: y, normalizedStart: f, normalizedEnd: P, direction: this.direction })) return;
2668
- const C = this.getDeltaBearing(this.direction, f, P), m = this.arcPoints, v = (this.direction === "anticlockwise" ? 1 : -1) * C / m, x = E(d, h), w = [];
2666
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], o = t[t.length - 1], r = S(e.lng, e.lat), a = S(n[0], n[1]), l = S(o[0], o[1]), d = S(i[0], i[1]), c = F(d, a), h = F(d, r) < c ? a : r, u = G(d, r), g = G(d, a), p = G(d, l), y = z(g), P = z(p), f = z(u);
2667
+ if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: P, direction: this.direction })) return;
2668
+ const C = this.getDeltaBearing(this.direction, y, P), m = this.arcPoints, v = (this.direction === "anticlockwise" ? 1 : -1) * C / m, x = F(d, h), w = [];
2669
2669
  for (let I = 0; I <= m; I++) {
2670
- const D = le(d, x, f + I * v), { lng: G, lat: O } = W(D.x, D.y), B = [F(G, this.coordinatePrecision), F(O, this.coordinatePrecision)];
2670
+ const _ = le(d, x, y + I * v), { lng: A, lat: O } = W(_.x, _.y), B = [E(A, this.coordinatePrecision), E(O, this.coordinatePrecision)];
2671
2671
  B[0] !== t[t.length - 1][0] && B[1] !== t[t.length - 1][1] && w.unshift(B);
2672
2672
  }
2673
2673
  t.push(...w), t.push(t[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, t, b.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [t] }, properties: { mode: this.mode } }]);
@@ -2726,14 +2726,14 @@ class Ot extends N {
2726
2726
  }
2727
2727
  class Ii {
2728
2728
  constructor(e) {
2729
- this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = e.adapter, this._mode = new fi();
2729
+ this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = e.adapter, this._mode = new yi();
2730
2730
  const t = /* @__PURE__ */ new Set(), i = e.modes.reduce((c, h) => {
2731
2731
  if (t.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
2732
2732
  return t.add(h.mode), c[h.mode] = h, c;
2733
2733
  }, {}), n = Object.keys(i);
2734
2734
  if (n.length === 0) throw new Error("No modes provided");
2735
2735
  n.forEach((c) => {
2736
- if (i[c].type === z.Select) {
2736
+ if (i[c].type === K.Select) {
2737
2737
  if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
2738
2738
  this._instanceSelectMode = c;
2739
2739
  }
@@ -2777,16 +2777,16 @@ class Ii {
2777
2777
  getModeStyles() {
2778
2778
  const e = {};
2779
2779
  return Object.keys(this._modes).forEach((t) => {
2780
- e[t] = (i) => this._instanceSelectMode && i.properties[_e] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[t].styleFeature.bind(this._modes[t])(i);
2780
+ e[t] = (i) => this._instanceSelectMode && i.properties[De] ? this._modes[this._instanceSelectMode].styleFeature.bind(this._modes[this._instanceSelectMode])(i) : this._modes[t].styleFeature.bind(this._modes[t])(i);
2781
2781
  }), e;
2782
2782
  }
2783
2783
  featuresAtLocation({ lng: e, lat: t }, i) {
2784
- const n = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, o = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, r = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(e, t), d = yt({ unproject: r, point: l, pointerDistance: n });
2784
+ const n = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, o = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, r = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(e, t), d = ft({ unproject: r, point: l, pointerDistance: n });
2785
2785
  return this._store.search(d).filter((c) => {
2786
2786
  if (o && (c.properties[se] || c.properties.selectionPoint)) return !1;
2787
2787
  if (c.geometry.type === "Point") {
2788
2788
  const h = c.geometry.coordinates, u = a(h[0], h[1]);
2789
- return E(l, u) < n;
2789
+ return F(l, u) < n;
2790
2790
  }
2791
2791
  if (c.geometry.type === "LineString") {
2792
2792
  const h = c.geometry.coordinates;
@@ -2926,7 +2926,7 @@ const Ri = [
2926
2926
  "delete-selection",
2927
2927
  "delete",
2928
2928
  "download"
2929
- ], Fi = {
2929
+ ], Ei = {
2930
2930
  modes: [
2931
2931
  "render",
2932
2932
  "point",
@@ -2944,7 +2944,7 @@ const Ri = [
2944
2944
  "download"
2945
2945
  ],
2946
2946
  open: !1
2947
- }, Ei = {
2947
+ }, Fi = {
2948
2948
  modes: [
2949
2949
  "render",
2950
2950
  "linestring",
@@ -2965,75 +2965,79 @@ const Ri = [
2965
2965
  modeOptions: {
2966
2966
  linestring: new Pt({
2967
2967
  styles: {
2968
- lineStringColor: "#000000",
2968
+ lineStringColor: "#232E3D",
2969
2969
  lineStringWidth: 2,
2970
2970
  closingPointColor: "#FFFFFF",
2971
- closingPointWidth: 5,
2972
- closingPointOutlineColor: "#000000",
2971
+ closingPointWidth: 3,
2972
+ closingPointOutlineColor: "#232E3D",
2973
2973
  closingPointOutlineWidth: 1
2974
2974
  }
2975
2975
  }),
2976
2976
  polygon: new xt({
2977
2977
  styles: {
2978
- fillColor: "#FFFFFF",
2978
+ fillColor: "#EDEFF0",
2979
2979
  fillOpacity: 0.7,
2980
- outlineColor: "#000000",
2980
+ outlineColor: "#232E3D",
2981
2981
  outlineWidth: 2,
2982
- closingPointColor: "#FFFFFF",
2983
- closingPointWidth: 5,
2984
- closingPointOutlineColor: "#000000",
2982
+ closingPointColor: "#FAFAFA",
2983
+ closingPointWidth: 3,
2984
+ closingPointOutlineColor: "#232E3D",
2985
2985
  closingPointOutlineWidth: 1
2986
2986
  }
2987
2987
  }),
2988
2988
  rectangle: new St({
2989
2989
  styles: {
2990
- fillColor: "#FFFFFF",
2990
+ fillColor: "#EDEFF0",
2991
2991
  fillOpacity: 0.7,
2992
- outlineColor: "#000000",
2992
+ outlineColor: "#232E3D",
2993
2993
  outlineWidth: 2
2994
2994
  }
2995
2995
  }),
2996
- "angled-rectangle": new Et({
2996
+ "angled-rectangle": new Ft({
2997
2997
  styles: {
2998
- fillColor: "#FFFFFF",
2998
+ fillColor: "#EDEFF0",
2999
2999
  fillOpacity: 0.7,
3000
- outlineColor: "#000000",
3000
+ outlineColor: "#232E3D",
3001
3001
  outlineWidth: 2
3002
3002
  }
3003
3003
  }),
3004
3004
  circle: new pt({
3005
3005
  styles: {
3006
- fillColor: "#FFFFFF",
3006
+ fillColor: "#EDEFF0",
3007
3007
  fillOpacity: 0.7,
3008
- outlineColor: "#000000",
3008
+ outlineColor: "#232E3D",
3009
3009
  outlineWidth: 2
3010
3010
  }
3011
3011
  }),
3012
- freehand: new ft({
3012
+ freehand: new yt({
3013
3013
  styles: {
3014
- fillColor: "#FFFFFF",
3014
+ fillColor: "#EDEFF0",
3015
3015
  fillOpacity: 0.7,
3016
- outlineColor: "#000000",
3017
- outlineWidth: 2
3016
+ outlineColor: "#232E3D",
3017
+ outlineWidth: 2,
3018
+ closingPointColor: "#FAFAFA",
3019
+ closingPointWidth: 3,
3020
+ closingPointOutlineColor: "#232E3D",
3021
+ closingPointOutlineWidth: 1
3018
3022
  }
3019
3023
  }),
3020
3024
  sensor: new Ot({
3021
3025
  styles: {
3022
- fillColor: "#FFFFFF",
3026
+ fillColor: "#EDEFF0",
3023
3027
  fillOpacity: 0.7,
3024
- outlineColor: "#000000",
3028
+ outlineColor: "#232E3D",
3025
3029
  outlineWidth: 2,
3026
- centerPointColor: "#FFFFFF",
3027
- centerPointWidth: 5,
3028
- centerPointOutlineColor: "#000000",
3030
+ centerPointColor: "#FAFAFA",
3031
+ centerPointWidth: 3,
3032
+ centerPointOutlineColor: "#232E3D",
3029
3033
  centerPointOutlineWidth: 1
3030
3034
  }
3031
3035
  }),
3032
- sector: new Dt({
3036
+ sector: new _t({
3033
3037
  styles: {
3034
- fillColor: "#FFFFFF",
3038
+ fillColor: "#EDEFF0",
3035
3039
  fillOpacity: 0.7,
3036
- outlineColor: "#000000",
3040
+ outlineColor: "#232E3D",
3037
3041
  outlineWidth: 2
3038
3042
  }
3039
3043
  })
@@ -3042,7 +3046,7 @@ const Ri = [
3042
3046
  id: "terradraw-measure-line-label",
3043
3047
  type: "symbol",
3044
3048
  source: "terradraw-measure-line-source",
3045
- filter: ["match", ["geometry-type"], ["Point"], !0, !1],
3049
+ filter: ["==", "$type", "Point"],
3046
3050
  layout: {
3047
3051
  "text-field": [
3048
3052
  "concat",
@@ -3065,27 +3069,41 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3065
3069
  ]
3066
3070
  ],
3067
3071
  "symbol-placement": "point",
3068
- "text-font": ["Open Sans Semibold"],
3069
- "text-size": 12,
3072
+ "text-size": [
3073
+ "interpolate",
3074
+ ["linear"],
3075
+ ["zoom"],
3076
+ 5,
3077
+ 10,
3078
+ 10,
3079
+ 12,
3080
+ 13,
3081
+ 14,
3082
+ 14,
3083
+ 16,
3084
+ 18,
3085
+ 18
3086
+ ],
3070
3087
  "text-overlap": "always",
3071
3088
  "text-variable-anchor": ["left", "right", "top", "bottom"],
3072
- "text-radial-offset": 1,
3073
- "text-justify": "center"
3089
+ "text-radial-offset": 0.5,
3090
+ "text-justify": "center",
3091
+ "text-letter-spacing": 0.05
3074
3092
  },
3075
3093
  paint: {
3076
- "text-halo-color": "#ffffff",
3077
- "text-halo-width": 10,
3078
- "text-color": "#000000"
3094
+ "text-halo-color": "#F7F7F7",
3095
+ "text-halo-width": 2,
3096
+ "text-color": "#232E3D"
3079
3097
  }
3080
3098
  },
3081
3099
  lineLayerNodeSpec: {
3082
3100
  id: "terradraw-measure-line-node",
3083
3101
  type: "circle",
3084
3102
  source: "terradraw-measure-line-source",
3085
- filter: ["match", ["geometry-type"], ["Point"], !0, !1],
3103
+ filter: ["==", "$type", "Point"],
3086
3104
  layout: {},
3087
3105
  paint: {
3088
- "circle-radius": 5,
3106
+ "circle-radius": 3,
3089
3107
  "circle-color": "#FFFFFF",
3090
3108
  "circle-stroke-color": "#000000",
3091
3109
  "circle-stroke-width": 1
@@ -3095,21 +3113,35 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3095
3113
  id: "terradraw-measure-polygon-label",
3096
3114
  type: "symbol",
3097
3115
  source: "terradraw-measure-polygon-source",
3098
- filter: ["match", ["geometry-type"], ["Point"], !0, !1],
3116
+ filter: ["==", "$type", "Point"],
3099
3117
  layout: {
3100
3118
  "text-field": ["concat", ["to-string", ["get", "area"]], " ", ["get", "unit"]],
3101
3119
  "symbol-placement": "point",
3102
- "text-font": ["Open Sans Semibold"],
3103
- "text-size": 12,
3104
- "text-overlap": "always"
3120
+ "text-size": [
3121
+ "interpolate",
3122
+ ["linear"],
3123
+ ["zoom"],
3124
+ 5,
3125
+ 10,
3126
+ 10,
3127
+ 12,
3128
+ 13,
3129
+ 14,
3130
+ 14,
3131
+ 16,
3132
+ 18,
3133
+ 18
3134
+ ],
3135
+ "text-overlap": "always",
3136
+ "text-letter-spacing": 0.05
3105
3137
  },
3106
3138
  paint: {
3107
- "text-halo-color": "#ffffff",
3108
- "text-halo-width": 4,
3109
- "text-color": "#000000"
3139
+ "text-halo-color": "#F7F7F7",
3140
+ "text-halo-width": 2,
3141
+ "text-color": "#232E3D"
3110
3142
  }
3111
3143
  }
3112
- }, _i = () => ({
3144
+ }, Di = () => ({
3113
3145
  render: new ie({
3114
3146
  modeName: "render",
3115
3147
  styles: {}
@@ -3125,11 +3157,11 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3125
3157
  }
3126
3158
  }),
3127
3159
  rectangle: new St(),
3128
- "angled-rectangle": new Et(),
3160
+ "angled-rectangle": new Ft(),
3129
3161
  circle: new pt(),
3130
- freehand: new ft(),
3162
+ freehand: new yt(),
3131
3163
  sensor: new Ot(),
3132
- sector: new Dt(),
3164
+ sector: new _t(),
3133
3165
  select: new pi({
3134
3166
  flags: {
3135
3167
  point: {
@@ -3244,20 +3276,20 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3244
3276
  styles: {}
3245
3277
  })
3246
3278
  });
3247
- class Di {
3279
+ class _i {
3248
3280
  /**
3249
3281
  * Constructor
3250
3282
  * @param options Plugin control options
3251
3283
  */
3252
3284
  constructor(e) {
3253
- L(this, "controlContainer");
3254
- L(this, "map");
3255
- L(this, "modeButtons", {});
3256
- L(this, "isExpanded", !1);
3257
- L(this, "terradraw");
3258
- L(this, "options", Fi);
3259
- L(this, "events", {});
3260
- L(this, "defaultMode", "render");
3285
+ k(this, "controlContainer");
3286
+ k(this, "map");
3287
+ k(this, "modeButtons", {});
3288
+ k(this, "isExpanded", !1);
3289
+ k(this, "terradraw");
3290
+ k(this, "options", Ei);
3291
+ k(this, "events", {});
3292
+ k(this, "defaultMode", "render");
3261
3293
  this.modeButtons = {}, e && (this.options = Object.assign(this.options, e));
3262
3294
  }
3263
3295
  /**
@@ -3277,7 +3309,7 @@ class Di {
3277
3309
  if (this.options && this.options.modes && this.options.modes.length === 0)
3278
3310
  throw new Error("At least a mode must be enabled.");
3279
3311
  this.map = e;
3280
- const t = _i(), i = [];
3312
+ const t = Di(), i = [];
3281
3313
  return (o = (n = this.options) == null ? void 0 : n.modes) == null || o.forEach((d) => {
3282
3314
  if (this.options.modeOptions && this.options.modeOptions[d]) {
3283
3315
  const c = this.options.modeOptions[d];
@@ -3485,28 +3517,28 @@ class Di {
3485
3517
  return e.charAt(0).toUpperCase() + e.slice(1);
3486
3518
  }
3487
3519
  }
3488
- var k = 63710088e-1, Oi = {
3489
- centimeters: k * 100,
3490
- centimetres: k * 100,
3520
+ var L = 63710088e-1, Oi = {
3521
+ centimeters: L * 100,
3522
+ centimetres: L * 100,
3491
3523
  degrees: 360 / (2 * Math.PI),
3492
- feet: k * 3.28084,
3493
- inches: k * 39.37,
3494
- kilometers: k / 1e3,
3495
- kilometres: k / 1e3,
3496
- meters: k,
3497
- metres: k,
3498
- miles: k / 1609.344,
3499
- millimeters: k * 1e3,
3500
- millimetres: k * 1e3,
3501
- nauticalmiles: k / 1852,
3524
+ feet: L * 3.28084,
3525
+ inches: L * 39.37,
3526
+ kilometers: L / 1e3,
3527
+ kilometres: L / 1e3,
3528
+ meters: L,
3529
+ metres: L,
3530
+ miles: L / 1609.344,
3531
+ millimeters: L * 1e3,
3532
+ millimetres: L * 1e3,
3533
+ nauticalmiles: L / 1852,
3502
3534
  radians: 1,
3503
- yards: k * 1.0936
3535
+ yards: L * 1.0936
3504
3536
  };
3505
- function ki(s, e, t = {}) {
3537
+ function Li(s, e, t = {}) {
3506
3538
  const i = { type: "Feature" };
3507
3539
  return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = s, i;
3508
3540
  }
3509
- function Li(s, e, t = {}) {
3541
+ function ki(s, e, t = {}) {
3510
3542
  if (!s)
3511
3543
  throw new Error("coordinates is required");
3512
3544
  if (!Array.isArray(s))
@@ -3515,7 +3547,7 @@ function Li(s, e, t = {}) {
3515
3547
  throw new Error("coordinates must be at least 2 numbers long");
3516
3548
  if (!rt(s[0]) || !rt(s[1]))
3517
3549
  throw new Error("coordinates must contain numbers");
3518
- return ki({
3550
+ return Li({
3519
3551
  type: "Point",
3520
3552
  coordinates: s
3521
3553
  }, e, t);
@@ -3526,7 +3558,7 @@ function Wi(s, e = "kilometers") {
3526
3558
  throw new Error(e + " units is invalid");
3527
3559
  return s * t;
3528
3560
  }
3529
- function fe(s) {
3561
+ function ye(s) {
3530
3562
  return s % 360 * Math.PI / 180;
3531
3563
  }
3532
3564
  function rt(s) {
@@ -3546,16 +3578,16 @@ function at(s) {
3546
3578
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
3547
3579
  }
3548
3580
  function ji(s, e, t = {}) {
3549
- var i = at(s), n = at(e), o = fe(n[1] - i[1]), r = fe(n[0] - i[0]), a = fe(i[1]), l = fe(n[1]), d = Math.pow(Math.sin(o / 2), 2) + Math.pow(Math.sin(r / 2), 2) * Math.cos(a) * Math.cos(l);
3581
+ var i = at(s), n = at(e), o = ye(n[1] - i[1]), r = ye(n[0] - i[0]), a = ye(i[1]), l = ye(n[1]), d = Math.pow(Math.sin(o / 2), 2) + Math.pow(Math.sin(r / 2), 2) * Math.cos(a) * Math.cos(l);
3550
3582
  return Wi(
3551
3583
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3552
3584
  t.units
3553
3585
  );
3554
3586
  }
3555
- function kt(s, e, t) {
3587
+ function Lt(s, e, t) {
3556
3588
  if (s !== null)
3557
- for (var i, n, o, r, a, l, d, c = 0, h = 0, u, g = s.type, p = g === "FeatureCollection", f = g === "Feature", P = p ? s.features.length : 1, y = 0; y < P; y++) {
3558
- d = p ? s.features[y].geometry : f ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
3589
+ for (var i, n, o, r, a, l, d, c = 0, h = 0, u, g = s.type, p = g === "FeatureCollection", y = g === "Feature", P = p ? s.features.length : 1, f = 0; f < P; f++) {
3590
+ d = p ? s.features[f].geometry : y ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
3559
3591
  for (var C = 0; C < a; C++) {
3560
3592
  var m = 0, v = 0;
3561
3593
  if (r = u ? d.geometries[C] : d, r !== null) {
@@ -3568,7 +3600,7 @@ function kt(s, e, t) {
3568
3600
  if (e(
3569
3601
  l,
3570
3602
  h,
3571
- y,
3603
+ f,
3572
3604
  m,
3573
3605
  v
3574
3606
  ) === !1)
@@ -3581,7 +3613,7 @@ function kt(s, e, t) {
3581
3613
  if (e(
3582
3614
  l[i],
3583
3615
  h,
3584
- y,
3616
+ f,
3585
3617
  m,
3586
3618
  v
3587
3619
  ) === !1)
@@ -3597,7 +3629,7 @@ function kt(s, e, t) {
3597
3629
  if (e(
3598
3630
  l[i][n],
3599
3631
  h,
3600
- y,
3632
+ f,
3601
3633
  m,
3602
3634
  v
3603
3635
  ) === !1)
@@ -3615,7 +3647,7 @@ function kt(s, e, t) {
3615
3647
  if (e(
3616
3648
  l[i][n][o],
3617
3649
  h,
3618
- y,
3650
+ f,
3619
3651
  m,
3620
3652
  v
3621
3653
  ) === !1)
@@ -3629,7 +3661,7 @@ function kt(s, e, t) {
3629
3661
  break;
3630
3662
  case "GeometryCollection":
3631
3663
  for (i = 0; i < r.geometries.length; i++)
3632
- if (kt(r.geometries[i], e) === !1)
3664
+ if (Lt(r.geometries[i], e) === !1)
3633
3665
  return !1;
3634
3666
  break;
3635
3667
  default:
@@ -3640,8 +3672,8 @@ function kt(s, e, t) {
3640
3672
  }
3641
3673
  }
3642
3674
  function Bi(s, e) {
3643
- var t, i, n, o, r, a, l, d, c, h, u = 0, g = s.type === "FeatureCollection", p = s.type === "Feature", f = g ? s.features.length : 1;
3644
- for (t = 0; t < f; t++) {
3675
+ var t, i, n, o, r, a, l, d, c, h, u = 0, g = s.type === "FeatureCollection", p = s.type === "Feature", y = g ? s.features.length : 1;
3676
+ for (t = 0; t < y; t++) {
3645
3677
  for (a = g ? s.features[t].geometry : p ? s.geometry : s, d = g ? s.features[t].properties : p ? s.properties : {}, c = g ? s.features[t].bbox : p ? s.bbox : void 0, h = g ? s.features[t].id : p ? s.id : void 0, l = a ? a.type === "GeometryCollection" : !1, r = l ? a.geometries.length : 1, n = 0; n < r; n++) {
3646
3678
  if (o = l ? a.geometries[n] : a, o === null) {
3647
3679
  if (e(
@@ -3706,14 +3738,14 @@ function Ni(s, e, t) {
3706
3738
  }
3707
3739
  ), i;
3708
3740
  }
3709
- function Gi(s) {
3741
+ function Ai(s) {
3710
3742
  return Ni(
3711
3743
  s,
3712
- (e, t) => e + Ai(t),
3744
+ (e, t) => e + Gi(t),
3713
3745
  0
3714
3746
  );
3715
3747
  }
3716
- function Ai(s) {
3748
+ function Gi(s) {
3717
3749
  let e = 0, t;
3718
3750
  switch (s.type) {
3719
3751
  case "Polygon":
@@ -3739,49 +3771,49 @@ function lt(s) {
3739
3771
  }
3740
3772
  return e;
3741
3773
  }
3742
- var Vi = k * k / 2, Ee = Math.PI / 180;
3774
+ var Vi = L * L / 2, Fe = Math.PI / 180;
3743
3775
  function dt(s) {
3744
3776
  const e = s.length - 1;
3745
3777
  if (e <= 2) return 0;
3746
3778
  let t = 0, i = 0;
3747
3779
  for (; i < e; ) {
3748
- const n = s[i], o = s[i + 1 === e ? 0 : i + 1], r = s[i + 2 >= e ? (i + 2) % e : i + 2], a = n[0] * Ee, l = o[1] * Ee, d = r[0] * Ee;
3780
+ const n = s[i], o = s[i + 1 === e ? 0 : i + 1], r = s[i + 2 >= e ? (i + 2) % e : i + 2], a = n[0] * Fe, l = o[1] * Fe, d = r[0] * Fe;
3749
3781
  t += (d - a) * Math.sin(l), i++;
3750
3782
  }
3751
3783
  return t * Vi;
3752
3784
  }
3753
- function Ui(s, e = {}) {
3785
+ function Ti(s, e = {}) {
3754
3786
  let t = 0, i = 0, n = 0;
3755
- return kt(
3787
+ return Lt(
3756
3788
  s,
3757
3789
  function(o) {
3758
3790
  t += o[0], i += o[1], n++;
3759
3791
  }
3760
- ), Li([t / n, i / n], e.properties);
3792
+ ), ki([t / n, i / n], e.properties);
3761
3793
  }
3762
- class Ki extends Di {
3794
+ class zi extends _i {
3763
3795
  /**
3764
3796
  * Constructor
3765
3797
  * @param options Plugin control options
3766
3798
  */
3767
3799
  constructor(t) {
3768
- let i = Ei;
3800
+ let i = Fi;
3769
3801
  t && (i = Object.assign(i, t));
3770
3802
  super({
3771
3803
  modes: i.modes,
3772
3804
  open: i.open,
3773
3805
  modeOptions: i.modeOptions
3774
3806
  });
3775
- L(this, "lineLayerLabelSpec");
3776
- L(this, "lineLayerNodeSpec");
3777
- L(this, "polygonLayerSpec");
3778
- L(this, "computeElevation");
3807
+ k(this, "lineLayerLabelSpec");
3808
+ k(this, "lineLayerNodeSpec");
3809
+ k(this, "polygonLayerSpec");
3810
+ k(this, "computeElevation");
3779
3811
  /**
3780
3812
  * Calculate area / distance and update a feature properties
3781
3813
  * @param feature GeoJSON feature
3782
3814
  * @returns updated GeoJSON feature
3783
3815
  */
3784
- L(this, "updateFeatureProperties", (t) => {
3816
+ k(this, "updateFeatureProperties", (t) => {
3785
3817
  if (!this.map || !this.map.loaded()) return t;
3786
3818
  const i = t.geometry.type;
3787
3819
  return i === "LineString" ? t = this.calcDistance(t) : i === "Polygon" && (t = this.calcArea(t)), t;
@@ -3794,7 +3826,7 @@ class Ki extends Di {
3794
3826
  * @returns HTML Element
3795
3827
  */
3796
3828
  onAdd(t) {
3797
- return this.controlContainer = super.onAdd(t), t.once("load", this.registerMesureControl.bind(this)), this.controlContainer;
3829
+ return this.controlContainer = super.onAdd(t), this.controlContainer;
3798
3830
  }
3799
3831
  /**
3800
3832
  * Remove the plugin control from maplibre
@@ -3803,6 +3835,36 @@ class Ki extends Di {
3803
3835
  onRemove() {
3804
3836
  this.unregisterMesureControl(), super.onRemove();
3805
3837
  }
3838
+ /**
3839
+ * Activate Terra Draw to start drawing
3840
+ */
3841
+ activate() {
3842
+ super.activate(), this.registerMesureControl();
3843
+ }
3844
+ /**
3845
+ * Recalculate area and distance in TerraDraw snapshot
3846
+ *
3847
+ * if you use `addFeatures` to restore GeoJSON features to TerraDraw, this recalc method needs to be called to re-measure again.
3848
+ *
3849
+ * For example, the below code is an example usage.
3850
+ * ```
3851
+ * drawInstance?.addFeatures(initData);
3852
+ * map?.once('idle', ()=>{
3853
+ * drawControl.recalc()
3854
+ * })
3855
+ * ```
3856
+ */
3857
+ recalc() {
3858
+ const t = this.getTerraDrawInstance();
3859
+ if (t) {
3860
+ this.registerMesureControl();
3861
+ const i = t.getSnapshot();
3862
+ for (const n of i) {
3863
+ const o = n.id, r = n.geometry.type, a = n.properties.mode;
3864
+ a === "linestring" && r === "LineString" ? this.measureLine(o) : !["point", "linestring", "select", "render"].includes(a) && r === "Polygon" && this.measurePolygon(o);
3865
+ }
3866
+ }
3867
+ }
3806
3868
  /**
3807
3869
  * Register measure control related maplibre sources and layers
3808
3870
  */
@@ -3830,20 +3892,25 @@ class Ki extends Di {
3830
3892
  data: { type: "FeatureCollection", features: [] }
3831
3893
  }), this.map.getLayer(this.polygonLayerSpec.id) || this.map.addLayer(this.polygonLayerSpec)), t && t.length > 0 || i && i.length > 0) {
3832
3894
  const r = this.getTerraDrawInstance();
3833
- r && (r.on("change", (a) => {
3834
- if (!this.map) return;
3835
- const l = this.getTerraDrawInstance();
3836
- if (!l) return;
3837
- const d = l.getSnapshot();
3838
- for (const c of a) {
3839
- const h = d == null ? void 0 : d.find((u) => u.id === c);
3840
- if (h) {
3841
- const u = h.geometry.type, g = h.properties.mode;
3842
- g === "linestring" && u === "LineString" ? this.measureLine(c) : !["point", "linestring", "select", "render"].includes(g) && u === "Polygon" && this.measurePolygon(c);
3843
- } else
3844
- this.clearMeasureFeatures(c, this.lineLayerNodeSpec.source), this.clearMeasureFeatures(c, this.lineLayerLabelSpec.source), this.clearMeasureFeatures(c, this.polygonLayerSpec.source);
3845
- }
3846
- }), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
3895
+ r && (r.on("change", this.handleTerradrawFeatureChanged.bind(this)), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
3896
+ }
3897
+ }
3898
+ /**
3899
+ * Handle change event of TerraDraw
3900
+ * @param ids Feature IDs
3901
+ */
3902
+ handleTerradrawFeatureChanged(t) {
3903
+ if (!this.map) return;
3904
+ const i = this.getTerraDrawInstance();
3905
+ if (!i) return;
3906
+ const n = i.getSnapshot();
3907
+ for (const o of t) {
3908
+ const r = n.find((a) => a.id === o);
3909
+ if (r) {
3910
+ const a = r.geometry.type, l = r.properties.mode;
3911
+ l === "linestring" && a === "LineString" ? this.measureLine(o) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(o);
3912
+ } else
3913
+ this.clearMeasureFeatures(o, this.lineLayerNodeSpec.source), this.clearMeasureFeatures(o, this.lineLayerLabelSpec.source), this.clearMeasureFeatures(o, this.polygonLayerSpec.source);
3847
3914
  }
3848
3915
  }
3849
3916
  /**
@@ -3876,7 +3943,7 @@ class Ki extends Di {
3876
3943
  */
3877
3944
  calcArea(t) {
3878
3945
  if (t.geometry.type !== "Polygon") return t;
3879
- const i = Gi(t.geometry);
3946
+ const i = Ai(t.geometry);
3880
3947
  let n = i, o = "m2";
3881
3948
  return i > 1e4 ? (n = i / 1e4, o = "ha") : i > 1e3 && (n = i / 1e3, o = "km2"), n = parseFloat(n.toFixed(2)), t.properties.area = n, t.properties.unit = o, t;
3882
3949
  }
@@ -3926,9 +3993,9 @@ class Ki extends Di {
3926
3993
  }
3927
3994
  ));
3928
3995
  const l = JSON.parse(JSON.stringify(o));
3929
- l.id = l.id + "-area-label", l.geometry = Ui(o.geometry).geometry, l.properties.originalId = o.id, o = this.calcArea(o), l.properties.area = o.properties.area, l.properties.unit = o.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (r = this.map.getSource(this.polygonLayerSpec.source)) == null || r.setData(
3996
+ l.id = l.id + "-area-label", l.geometry = Ti(o.geometry).geometry, l.properties.originalId = o.id, o = this.calcArea(o), l.properties.area = o.properties.area, l.properties.unit = o.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (r = this.map.getSource(this.polygonLayerSpec.source)) == null || r.setData(
3930
3997
  a.data
3931
- ), this.map.moveLayer(this.polygonLayerSpec.id);
3998
+ ), this.map.moveLayer(this.polygonLayerSpec.id), this.map.getLayer(this.lineLayerLabelSpec.id) && this.map.moveLayer(this.lineLayerLabelSpec.id), this.map.getLayer(this.lineLayerNodeSpec.id) && this.map.moveLayer(this.lineLayerNodeSpec.id);
3932
3999
  }
3933
4000
  }
3934
4001
  }
@@ -3958,11 +4025,11 @@ class Ki extends Di {
3958
4025
  typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
3959
4026
  const h = c.geometry.coordinates, u = h[0], g = h[1];
3960
4027
  if (d === 0) {
3961
- const f = JSON.parse(JSON.stringify(c));
3962
- f.id = `${c.id}-node-${d}`, f.geometry = {
4028
+ const y = JSON.parse(JSON.stringify(c));
4029
+ y.id = `${c.id}-node-${d}`, y.geometry = {
3963
4030
  type: "Point",
3964
4031
  coordinates: u
3965
- }, f.properties.distance = 0, f.properties.total = 0, c.properties.elevation_start && (f.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(f);
4032
+ }, y.properties.distance = 0, y.properties.total = 0, c.properties.elevation_start && (y.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
3966
4033
  }
3967
4034
  const p = JSON.parse(JSON.stringify(c));
3968
4035
  p.id = `${c.id}-node-${d + 1}`, p.geometry = {
@@ -3972,7 +4039,7 @@ class Ki extends Di {
3972
4039
  }
3973
4040
  (r = this.map.getSource(this.lineLayerLabelSpec.source)) == null || r.setData(
3974
4041
  a.data
3975
- ), this.map.moveLayer(this.lineLayerLabelSpec.id), this.map.moveLayer(this.lineLayerNodeSpec.id);
4042
+ ), this.map.getLayer(this.polygonLayerSpec.id) && this.map.moveLayer(this.polygonLayerSpec.id), this.map.moveLayer(this.lineLayerLabelSpec.id), this.map.moveLayer(this.lineLayerNodeSpec.id);
3976
4043
  }
3977
4044
  }
3978
4045
  }
@@ -4021,10 +4088,10 @@ class Ki extends Di {
4021
4088
  export {
4022
4089
  Xi as AvailableMeasureModes,
4023
4090
  Ri as AvailableModes,
4024
- Ki as MaplibreMeasureControl,
4025
- Di as MaplibreTerradrawControl,
4026
- Fi as defaultControlOptions,
4027
- Ei as defaultMeasureControlOptions,
4028
- _i as getDefaultModeOptions
4091
+ zi as MaplibreMeasureControl,
4092
+ _i as MaplibreTerradrawControl,
4093
+ Ei as defaultControlOptions,
4094
+ Fi as defaultMeasureControlOptions,
4095
+ Di as getDefaultModeOptions
4029
4096
  };
4030
4097
  //# sourceMappingURL=maplibre-gl-terradraw.es.js.map