@watergis/maplibre-gl-terradraw 0.8.2 → 0.8.4

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,24 +1,24 @@
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 = (o, e, t) => e in o ? kt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var A = (o, e, t) => Wt(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  function M() {
5
- return M = Object.assign ? Object.assign.bind() : function(s) {
5
+ return M = Object.assign ? Object.assign.bind() : function(o) {
6
6
  for (var e = 1; e < arguments.length; e++) {
7
7
  var t = arguments[e];
8
- for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (s[i] = t[i]);
8
+ for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (o[i] = t[i]);
9
9
  }
10
- return s;
10
+ return o;
11
11
  }, M.apply(this, arguments);
12
12
  }
13
- function F(s, e = 9) {
13
+ function E(o, e = 9) {
14
14
  const t = Math.pow(10, e);
15
- return Math.round(s * t) / t;
15
+ return Math.round(o * t) / t;
16
16
  }
17
- const E = (s, e) => {
18
- const { x: t, y: i } = s, { x: n, y: o } = e, r = n - t, a = o - i;
17
+ const F = (o, e) => {
18
+ const { x: t, y: i } = o, { x: n, y: s } = e, r = n - t, a = s - 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));
@@ -41,8 +41,8 @@ class ct {
41
41
  getDrawEventFromEvent(e) {
42
42
  const t = this.getLngLatFromEvent(e);
43
43
  if (!t) return null;
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 };
44
+ const { lng: i, lat: n } = t, { containerX: s, containerY: r } = this.getMapElementXYPosition(e), a = this.getButton(e), l = Array.from(this._heldKeys);
45
+ return { lng: E(i, this._coordinatePrecision), lat: E(n, this._coordinatePrecision), containerX: s, 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,16 +61,16 @@ 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 }, s = this._currentModeCallbacks.getState(), r = F(i, n);
72
72
  let a = !1;
73
- if (a = o === "drawing" ? r < this._minPixelDragDistanceDrawing : o === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, a) return;
73
+ if (a = s === "drawing" ? r < this._minPixelDragDistanceDrawing : s === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, a) return;
74
74
  this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (l) => {
75
75
  this.setDraggability.bind(this)(l);
76
76
  });
@@ -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);
@@ -185,18 +185,18 @@ class jt extends ct {
185
185
  }
186
186
  render(e, t) {
187
187
  this.updateChangedIds(e), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
188
- const i = [...e.created, ...e.updated, ...e.unchanged], n = [], o = [], r = [];
188
+ const i = [...e.created, ...e.updated, ...e.unchanged], n = [], s = [], r = [];
189
189
  for (let a = 0; a < i.length; a++) {
190
190
  const l = i[a], { properties: d } = l, c = t[d.mode](l);
191
- l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, n.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, o.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, r.push(l));
191
+ l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, n.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, s.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, r.push(l));
192
192
  }
193
193
  if (this._rendered) {
194
194
  const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
195
195
  let c;
196
- (a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", n)), l && this._setGeoJSONLayerData("LineString", o), d && this._setGeoJSONLayerData("Polygon", r), c && this._map.moveLayer(c);
196
+ (a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", n)), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", r), c && this._map.moveLayer(c);
197
197
  } else {
198
198
  const a = this._addGeoJSONLayer("Point", n);
199
- this._addGeoJSONLayer("LineString", o), this._addGeoJSONLayer("Polygon", r), this._rendered = !0, a && this._map.moveLayer(a);
199
+ this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon", r), this._rendered = !0, a && this._map.moveLayer(a);
200
200
  }
201
201
  this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
202
202
  });
@@ -258,8 +258,8 @@ class Bt extends ct {
258
258
  }
259
259
  const Nt = { radians: 6370997 / (2 * Math.PI), degrees: 2 * Math.PI * 6370997 / 360, ft: 0.3048, m: 1, "us-ft": 1200 / 3937 };
260
260
  var ht = class {
261
- constructor(s) {
262
- this.code_ = s.code, this.units_ = s.units, this.extent_ = s.extent !== void 0 ? s.extent : null, this.worldExtent_ = s.worldExtent !== void 0 ? s.worldExtent : null, this.axisOrientation_ = s.axisOrientation !== void 0 ? s.axisOrientation : "enu", this.global_ = s.global !== void 0 && s.global, this.canWrapX_ = !(!this.global_ || !this.extent_), this.getPointResolutionFunc_ = s.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = s.metersPerUnit;
261
+ constructor(o) {
262
+ this.code_ = o.code, this.units_ = o.units, this.extent_ = o.extent !== void 0 ? o.extent : null, this.worldExtent_ = o.worldExtent !== void 0 ? o.worldExtent : null, this.axisOrientation_ = o.axisOrientation !== void 0 ? o.axisOrientation : "enu", this.global_ = o.global !== void 0 && o.global, this.canWrapX_ = !(!this.global_ || !this.extent_), this.getPointResolutionFunc_ = o.getPointResolution, this.defaultTileGrid_ = null, this.metersPerUnit_ = o.metersPerUnit;
263
263
  }
264
264
  canWrapX() {
265
265
  return this.canWrapX_;
@@ -285,37 +285,37 @@ var ht = class {
285
285
  isGlobal() {
286
286
  return this.global_;
287
287
  }
288
- setGlobal(s) {
289
- this.global_ = s, this.canWrapX_ = !(!s || !this.extent_);
288
+ setGlobal(o) {
289
+ this.global_ = o, this.canWrapX_ = !(!o || !this.extent_);
290
290
  }
291
291
  getDefaultTileGrid() {
292
292
  return this.defaultTileGrid_;
293
293
  }
294
- setDefaultTileGrid(s) {
295
- this.defaultTileGrid_ = s;
294
+ setDefaultTileGrid(o) {
295
+ this.defaultTileGrid_ = o;
296
296
  }
297
- setExtent(s) {
298
- this.extent_ = s, this.canWrapX_ = !(!this.global_ || !s);
297
+ setExtent(o) {
298
+ this.extent_ = o, this.canWrapX_ = !(!this.global_ || !o);
299
299
  }
300
- setWorldExtent(s) {
301
- this.worldExtent_ = s;
300
+ setWorldExtent(o) {
301
+ this.worldExtent_ = o;
302
302
  }
303
- setGetPointResolution(s) {
304
- this.getPointResolutionFunc_ = s;
303
+ setGetPointResolution(o) {
304
+ this.getPointResolutionFunc_ = o;
305
305
  }
306
306
  getPointResolutionFunc() {
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;
318
+ const Ue = [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")], Te = [-180, -90, 180, 90], Vt = 6378137 * Math.PI / 180;
319
319
  class T extends ht {
320
320
  constructor(e, t) {
321
321
  super({ code: e, units: "degrees", extent: Te, axisOrientation: t, global: !0, metersPerUnit: Vt, worldExtent: Te });
@@ -323,65 +323,65 @@ class T extends ht {
323
323
  }
324
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")];
325
325
  let Me = {};
326
- function ye(s, e, t) {
327
- const i = s.getCode(), n = e.getCode();
326
+ function ye(o, e, t) {
327
+ const i = o.getCode(), n = e.getCode();
328
328
  i in Me || (Me[i] = {}), Me[i][n] = t;
329
329
  }
330
- function ut(s, e) {
331
- if (e !== void 0) for (let t = 0, i = s.length; t < i; ++t) e[t] = s[t];
332
- else e = s.slice();
330
+ function ut(o, e) {
331
+ if (e !== void 0) for (let t = 0, i = o.length; t < i; ++t) e[t] = o[t];
332
+ else e = o.slice();
333
333
  return e;
334
334
  }
335
- function Ut(s) {
336
- s.getCode(), ye(s, s, ut);
335
+ function Ut(o) {
336
+ o.getCode(), ye(o, o, ut);
337
337
  }
338
- function Xe(s) {
338
+ function Xe(o) {
339
339
  (function(e) {
340
340
  e.forEach(Ut);
341
- })(s), s.forEach(function(e) {
342
- s.forEach(function(t) {
341
+ })(o), o.forEach(function(e) {
342
+ o.forEach(function(t) {
343
343
  e !== t && ye(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) {
349
- const i = s.length;
350
- t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? s.slice() : new Array(i));
347
+ var ze, Ke, Ye, b;
348
+ Xe(Ue), Xe(Re), ze = Ue, Ke = function(o, e, t) {
349
+ const i = o.length;
350
+ t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? o.slice() : new Array(i));
351
351
  for (let n = 0; n < i; n += t) {
352
- e[n] = Q * s[n] / 180;
353
- let o = re * Math.log(Math.tan(Math.PI * (+s[n + 1] + 90) / 360));
354
- o > ce ? o = ce : o < -ce && (o = -ce), e[n + 1] = o;
352
+ e[n] = Q * o[n] / 180;
353
+ let s = re * Math.log(Math.tan(Math.PI * (+o[n + 1] + 90) / 360));
354
+ s > ce ? s = ce : s < -ce && (s = -ce), e[n + 1] = s;
355
355
  }
356
356
  return e;
357
- }, Ye = function(s, e, t) {
358
- const i = s.length;
359
- t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? s.slice() : new Array(i));
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;
357
+ }, Ye = function(o, e, t) {
358
+ const i = o.length;
359
+ t = t > 1 ? t : 2, e === void 0 && (e = t > 2 ? o.slice() : new Array(i));
360
+ for (let n = 0; n < i; n += t) e[n] = 180 * o[n] / Q, e[n + 1] = 360 * Math.atan(Math.exp(o[n + 1] / re)) / Math.PI - 90;
361
361
  return e;
362
- }, Re.forEach(function(s) {
363
- Ke.forEach(function(e) {
364
- ye(s, e, ze), ye(e, s, Ye);
362
+ }, Re.forEach(function(o) {
363
+ ze.forEach(function(e) {
364
+ ye(o, e, Ke), ye(e, o, Ye);
365
365
  });
366
366
  });
367
- (function(s) {
368
- s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
367
+ (function(o) {
368
+ o.Commit = "commit", o.Provisional = "provisional", o.Finish = "finish";
369
369
  })(b || (b = {}));
370
- const _e = "selected", se = "midPoint", ae = "closingPoint", De = "snappingPoint";
371
- function we(s) {
372
- return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
370
+ const De = "selected", oe = "midPoint", ae = "closingPoint", Oe = "snappingPoint";
371
+ function we(o) {
372
+ return !!(o && typeof o == "object" && o !== null && !Array.isArray(o));
373
373
  }
374
- function He(s) {
374
+ function He(o) {
375
375
  return !!function(e) {
376
376
  return typeof e == "number" && !isNaN(new Date(e).valueOf());
377
- }(s);
377
+ }(o);
378
378
  }
379
379
  const Tt = "Feature mode property does not match the mode being added to";
380
- var z;
381
- (function(s) {
382
- s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
383
- })(z || (z = {}));
384
- class N {
380
+ var K;
381
+ (function(o) {
382
+ o.Drawing = "drawing", o.Select = "select", o.Static = "static", o.Render = "render";
383
+ })(K || (K = {}));
384
+ class B {
385
385
  get state() {
386
386
  return this._state;
387
387
  }
@@ -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");
@@ -422,18 +422,18 @@ class N {
422
422
  performFeatureValidation(e) {
423
423
  if (this._state === "unregistered") throw new Error("Mode must be registered");
424
424
  const t = function(i, n) {
425
- let o;
426
- if (we(i)) if (i.id == null) o = "Feature has no id";
427
- else if (typeof i.id != "string" && typeof i.id != "number") o = "Feature must be string or number as per GeoJSON spec";
425
+ let s;
426
+ if (we(i)) if (i.id == null) s = "Feature has no id";
427
+ else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
428
428
  else if (n(i.id)) if (we(i.geometry)) if (we(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
429
429
  if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
430
- } else o = "Feature coordinates is not an array";
431
- else o = "Feature is not Point, LineString or Polygon";
432
- else o = "Feature has no properties";
433
- else o = "Feature has no geometry";
434
- else o = "Feature must match the id strategy (default is UUID4)";
435
- else o = "Feature is not object";
436
- return o ? { valid: !1, reason: o } : { valid: !0 };
430
+ } else s = "Feature coordinates is not an array";
431
+ else s = "Feature is not Point, LineString or Polygon";
432
+ else s = "Feature has no properties";
433
+ else s = "Feature has no geometry";
434
+ else s = "Feature must match the id strategy (default is UUID4)";
435
+ else s = "Feature is not object";
436
+ return s ? { valid: !1, reason: s } : { valid: !0 };
437
437
  }(e, this.store.idStrategy.isValidId);
438
438
  if (this.validate) {
439
439
  const i = this.validate(e, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional });
@@ -475,85 +475,85 @@ class N {
475
475
  return e === void 0 ? t : typeof e == "function" ? e(i) : e;
476
476
  }
477
477
  }
478
- class Rt extends N {
478
+ class Rt extends B {
479
479
  constructor(...e) {
480
- super(...e), this.type = z.Select;
480
+ super(...e), this.type = K.Select;
481
481
  }
482
482
  }
483
- function V(s, e) {
484
- const t = (d) => d * Math.PI / 180, i = t(s[1]), n = t(s[0]), o = t(e[1]), r = o - i, a = t(e[0]) - n, l = Math.sin(r / 2) * Math.sin(r / 2) + Math.cos(i) * Math.cos(o) * Math.sin(a / 2) * Math.sin(a / 2);
483
+ function V(o, e) {
484
+ const t = (d) => d * Math.PI / 180, i = t(o[1]), n = t(o[0]), s = t(e[1]), r = s - i, a = t(e[0]) - n, l = Math.sin(r / 2) * Math.sin(r / 2) + Math.cos(i) * Math.cos(s) * Math.sin(a / 2) * Math.sin(a / 2);
485
485
  return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
486
486
  }
487
- const Oe = 63710088e-1;
488
- function _(s) {
489
- return s % 360 * Math.PI / 180;
487
+ const _e = 63710088e-1;
488
+ function D(o) {
489
+ return o % 360 * Math.PI / 180;
490
490
  }
491
- function gt(s) {
492
- return s / (Oe / 1e3);
491
+ function pt(o) {
492
+ return o / (_e / 1e3);
493
493
  }
494
- function U(s) {
495
- return s % (2 * Math.PI) * 180 / Math.PI;
494
+ function U(o) {
495
+ return o % (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 });
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)];
497
+ const $e = 57.29577951308232, Je = 0.017453292519943295, me = 6378137, S = (o, e) => ({ x: o === 0 ? 0 : o * Je * me, y: e === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + e * Je / 2)) * me }), k = (o, e) => ({ lng: o === 0 ? 0 : $e * (o / me), lat: e === 0 ? 0 : (2 * Math.atan(Math.exp(e / me)) - Math.PI / 2) * $e });
498
+ function Xt(o, e, t) {
499
+ const i = D(o[0]), n = D(o[1]), s = D(t), r = pt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
500
+ return [U(i + Math.atan2(Math.sin(s) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), U(a)];
501
501
  }
502
- function qe(s) {
503
- const { center: e, radiusKilometers: t, coordinatePrecision: i } = s, n = s.steps ? s.steps : 64, o = [];
502
+ function qe(o) {
503
+ const { center: e, radiusKilometers: t, coordinatePrecision: i } = o, n = o.steps ? o.steps : 64, s = [];
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
+ s.push([E(a[0], i), E(a[1], i)]);
507
507
  }
508
- return o.push(o[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [o] }, properties: {} };
508
+ return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
509
509
  }
510
- function ke(s) {
510
+ function Le(o) {
511
511
  const e = { epsilon: 0 };
512
512
  let t;
513
- if (s.geometry.type === "Polygon") t = s.geometry.coordinates;
513
+ if (o.geometry.type === "Polygon") t = o.geometry.coordinates;
514
514
  else {
515
- if (s.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
516
- t = [s.geometry.coordinates];
515
+ if (o.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
516
+ t = [o.geometry.coordinates];
517
517
  }
518
518
  const i = [];
519
- for (let r = 0; r < t.length; r++) for (let a = 0; a < t[r].length - 1; a++) for (let l = 0; l < t.length; l++) for (let d = 0; d < t[l].length - 1; d++) o(r, a, l, d);
519
+ for (let r = 0; r < t.length; r++) for (let a = 0; a < t[r].length - 1; a++) for (let l = 0; l < t.length; l++) for (let d = 0; d < t[l].length - 1; d++) s(r, a, l, d);
520
520
  return i.length > 0;
521
521
  function n(r) {
522
522
  return r < 0 - e.epsilon || r > 1 + e.epsilon;
523
523
  }
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) {
524
+ function s(r, a, l, d) {
525
+ const c = t[r][a], h = t[r][a + 1], u = t[l][d], p = t[l][d + 1], g = function(y, C, m, v) {
526
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];
529
- }(c, h, u, g);
530
- if (p === null) return;
527
+ const x = y[0], w = y[1], I = C[0], O = C[1], N = m[0], _ = m[1], j = v[0], Y = v[1], H = (x - I) * (_ - Y) - (w - O) * (N - j);
528
+ return H === 0 ? null : [((x * O - w * I) * (N - j) - (x - I) * (N * Y - _ * j)) / H, ((x * O - w * I) * (_ - Y) - (w - O) * (N * Y - _ * j)) / H];
529
+ }(c, h, u, p);
530
+ if (g === null) return;
531
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));
532
+ f = h[0] !== c[0] ? (g[0] - c[0]) / (h[0] - c[0]) : (g[1] - c[1]) / (h[1] - c[1]), P = p[0] !== u[0] ? (g[0] - u[0]) / (p[0] - u[0]) : (g[1] - u[1]) / (p[1] - u[1]), n(f) || n(P) || (g.toString(), i.push(g));
533
533
  }
534
534
  }
535
- function he(s, e) {
536
- return s[0] === e[0] && s[1] === e[1];
535
+ function he(o, e) {
536
+ return o[0] === e[0] && o[1] === e[1];
537
537
  }
538
- function xe(s, e) {
539
- return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (i = s[0]) >= -180 && i <= 180 && (t = s[1]) >= -90 && t <= 90 && Ze(s[0]) <= e && Ze(s[1]) <= e;
538
+ function xe(o, e) {
539
+ return o.length === 2 && typeof o[0] == "number" && typeof o[1] == "number" && o[0] !== 1 / 0 && o[1] !== 1 / 0 && (i = o[0]) >= -180 && i <= 180 && (t = o[1]) >= -90 && t <= 90 && Ze(o[0]) <= e && Ze(o[1]) <= e;
540
540
  var t, i;
541
541
  }
542
- function Ze(s) {
542
+ function Ze(o) {
543
543
  let e = 1, t = 0;
544
- for (; Math.round(s * e) / e !== s; ) e *= 10, t++;
544
+ for (; Math.round(o * e) / e !== o; ) 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";
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 };
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
+ function Se(o, e) {
549
+ return o.geometry.type !== "Polygon" ? { valid: !1, reason: zt } : o.geometry.coordinates.length !== 1 ? { valid: !1, reason: Kt } : o.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Yt } : o.geometry.coordinates[0].every((n) => xe(n, e)) ? (t = o.geometry.coordinates[0][0])[0] !== (i = o.geometry.coordinates[0][o.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
- function de(s, e) {
553
- const t = Se(s, e);
554
- return t.valid ? ke(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
552
+ function de(o, e) {
553
+ const t = Se(o, e);
554
+ return t.valid ? Le(o) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
555
555
  }
556
- class pt extends N {
556
+ class gt extends B {
557
557
  constructor(e) {
558
558
  var t;
559
559
  super(e), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1;
@@ -621,17 +621,17 @@ class pt extends N {
621
621
  const t = V(this.center, [e.lng, e.lat]);
622
622
  let i;
623
623
  if (this.projection === "web-mercator") {
624
- const n = function(o, r) {
625
- const a = 1e3 * V(o, r);
624
+ const n = function(s, r) {
625
+ const a = 1e3 * V(s, r);
626
626
  if (a === 0) return 1;
627
- const { x: l, y: d } = S(o[0], o[1]), { x: c, y: h } = S(r[0], r[1]);
627
+ const { x: l, y: d } = S(s[0], s[1]), { x: c, y: h } = S(r[0], r[1]);
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
- 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 = [];
630
+ i = function(s) {
631
+ const { center: r, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = r, { x: p, y: g } = S(h, u), f = [];
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 y = 360 * P / d * Math.PI / 180, C = c * Math.cos(y), m = c * Math.sin(y), [v, x] = [p + C, g + m], { lng: w, lat: I } = k(v, x);
634
+ f.push([E(w, l), E(I, l)]);
635
635
  }
636
636
  return f.push(f[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [f] }, properties: {} };
637
637
  }({ center: this.center, radiusKilometers: t * n, coordinatePrecision: this.coordinatePrecision });
@@ -644,7 +644,7 @@ class pt extends N {
644
644
  }
645
645
  }
646
646
  }
647
- class ft extends N {
647
+ class ft extends B {
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,16 +673,16 @@ 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, s] = t.coordinates[0][i], { x: r, y: a } = this.project(n, s), 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;
681
681
  } else this.hasLeftStartingPoint = !0, this.setCursor(this.cursors.start);
682
682
  if (l < this.minDistance) return;
683
683
  t.coordinates[0].pop();
684
- const g = { type: "Polygon", coordinates: [[...t.coordinates[0], [e.lng, e.lat], t.coordinates[0][0]]] };
685
- this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: g, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: g }]);
684
+ const p = { type: "Polygon", coordinates: [[...t.coordinates[0], [e.lng, e.lat], t.coordinates[0][0]]] };
685
+ this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
686
686
  }
687
687
  onClick(e) {
688
688
  if (!this.preventNewFeature) {
@@ -720,16 +720,16 @@ class ft extends N {
720
720
  return this.validateModeFeature(e, (t) => Se(t, this.coordinatePrecision));
721
721
  }
722
722
  }
723
- class j {
724
- constructor({ store: e, mode: t, project: i, unproject: n, pointerDistance: o, coordinatePrecision: r, projection: a }) {
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;
723
+ class W {
724
+ constructor({ store: e, mode: t, project: i, unproject: n, pointerDistance: s, coordinatePrecision: r, projection: a }) {
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 = s, this.coordinatePrecision = r, this.projection = a;
726
726
  }
727
727
  }
728
- function yt({ unproject: s, point: e, pointerDistance: t }) {
729
- const i = t / 2, { x: n, y: o } = e;
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])] } };
728
+ function yt({ unproject: o, point: e, pointerDistance: t }) {
729
+ const i = t / 2, { x: n, y: s } = e;
730
+ return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[o(n - i, s - i), o(n + i, s - i), o(n + i, s + i), o(n - i, s + i), o(n - i, s - i)].map((r) => [r.lng, r.lat])] } };
731
731
  }
732
- class Le extends j {
732
+ class ke extends W {
733
733
  constructor(e) {
734
734
  super(e);
735
735
  }
@@ -738,21 +738,21 @@ class Le extends j {
738
738
  return yt({ unproject: this.unproject, point: { x: t, y: i }, pointerDistance: this.pointerDistance });
739
739
  }
740
740
  }
741
- class We extends j {
741
+ class We extends W {
742
742
  constructor(e) {
743
743
  super(e);
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
- class mt extends j {
750
+ class mt extends W {
751
751
  constructor(e, t, i) {
752
- super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (o) => !!(o.properties && o.properties.mode === this.mode)), this.getSnappableCoordinate = (n, o) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== o)), this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
752
+ super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (n, s) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== s)), this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
753
753
  }
754
754
  getSnappable(e, t) {
755
- const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), o = { coord: void 0, minDist: 1 / 0 };
755
+ const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), s = { coord: void 0, minDist: 1 / 0 };
756
756
  return n.forEach((r) => {
757
757
  let a;
758
758
  if (r.geometry.type === "Polygon") a = r.geometry.coordinates[0];
@@ -762,66 +762,66 @@ class mt extends j {
762
762
  }
763
763
  a.forEach((l) => {
764
764
  const d = this.pixelDistance.measure(e, l);
765
- d < o.minDist && d < this.pointerDistance && (o.coord = l, o.minDist = d);
765
+ d < s.minDist && d < this.pointerDistance && (s.coord = l, s.minDist = d);
766
766
  });
767
- }), o.coord;
767
+ }), s.coord;
768
768
  }
769
769
  }
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)];
770
+ function Qe(o, e, t) {
771
+ const i = D(o[0]), n = D(o[1]), s = D(t), r = pt(e), a = Math.asin(Math.sin(n) * Math.cos(r) + Math.cos(n) * Math.sin(r) * Math.cos(s));
772
+ return [U(i + Math.atan2(Math.sin(s) * Math.sin(r) * Math.cos(n), Math.cos(r) - Math.sin(n) * Math.sin(a))), U(a)];
773
773
  }
774
- function le({ x: s, y: e }, t, i) {
775
- const n = _(i);
776
- return { x: s + t * Math.cos(n), y: e + t * Math.sin(n) };
774
+ function le({ x: o, y: e }, t, i) {
775
+ const n = D(i);
776
+ return { x: o + t * Math.cos(n), y: e + t * Math.sin(n) };
777
777
  }
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);
778
+ function et(o, e) {
779
+ const t = D(o[0]), i = D(e[0]), n = D(o[1]), s = D(e[1]), r = Math.sin(i - t) * Math.cos(s), a = Math.cos(n) * Math.sin(s) - Math.sin(n) * Math.cos(s) * Math.cos(i - t);
780
780
  return U(Math.atan2(r, a));
781
781
  }
782
- function A({ x: s, y: e }, { x: t, y: i }) {
783
- let n = Math.atan2(i - e, t - s);
782
+ function G({ x: o, y: e }, { x: t, y: i }) {
783
+ let n = Math.atan2(i - e, t - o);
784
784
  return n *= 180 / Math.PI, n > 180 ? n -= 360 : n < -180 && (n += 360), n;
785
785
  }
786
- function K(s) {
787
- return (s + 360) % 360;
786
+ function z(o) {
787
+ return (o + 360) % 360;
788
788
  }
789
- function $t(s, e, t) {
790
- const i = [], n = s.length;
791
- let o, r, a, l = 0;
792
- for (let c = 0; c < s.length && !(e >= l && c === s.length - 1); c++) {
789
+ function Jt(o, e, t) {
790
+ const i = [], n = o.length;
791
+ let s, r, a, l = 0;
792
+ for (let c = 0; c < o.length && !(e >= l && c === o.length - 1); c++) {
793
793
  if (l > e && i.length === 0) {
794
- if (o = e - l, !o) return i.push(s[c]), i;
795
- r = et(s[c], s[c - 1]) - 180, a = Qe(s[c], o, r), i.push(a);
794
+ if (s = e - l, !s) return i.push(o[c]), i;
795
+ r = et(o[c], o[c - 1]) - 180, a = Qe(o[c], s, r), i.push(a);
796
796
  }
797
- if (l >= t) return o = t - l, o ? (r = et(s[c], s[c - 1]) - 180, a = Qe(s[c], o, r), i.push(a), i) : (i.push(s[c]), i);
798
- if (l >= e && i.push(s[c]), c === s.length - 1) return i;
799
- l += V(s[c], s[c + 1]);
797
+ if (l >= t) return s = t - l, s ? (r = et(o[c], o[c - 1]) - 180, a = Qe(o[c], s, r), i.push(a), i) : (i.push(o[c]), i);
798
+ if (l >= e && i.push(o[c]), c === o.length - 1) return i;
799
+ l += V(o[c], o[c + 1]);
800
800
  }
801
- if (l < e && s.length === n) throw new Error("Start position is beyond line");
802
- const d = s[s.length - 1];
801
+ if (l < e && o.length === n) throw new Error("Start position is beyond line");
802
+ const d = o[o.length - 1];
803
803
  return [d, d];
804
804
  }
805
- function ue(s) {
806
- return s * (Math.PI / 180);
805
+ function ue(o) {
806
+ return o * (Math.PI / 180);
807
807
  }
808
- function tt(s) {
809
- return s * (180 / Math.PI);
808
+ function tt(o) {
809
+ return o * (180 / Math.PI);
810
810
  }
811
- class qt extends j {
811
+ class qt extends W {
812
812
  constructor(e) {
813
813
  super(e), this.config = void 0, this.config = e;
814
814
  }
815
815
  generateInsertionCoordinates(e, t, i) {
816
816
  const n = [e, t];
817
- let o = 0;
818
- for (let d = 0; d < n.length - 1; d++) o += V(n[0], n[1]);
819
- if (o <= i) return n;
820
- let r = o / i - 1;
817
+ let s = 0;
818
+ for (let d = 0; d < n.length - 1; d++) s += V(n[0], n[1]);
819
+ if (s <= i) return n;
820
+ let r = s / i - 1;
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 = [];
@@ -829,32 +829,32 @@ class qt extends j {
829
829
  return this.limitCoordinates(l);
830
830
  }
831
831
  generateInsertionGeodesicCoordinates(e, t, i) {
832
- const n = V(e, t), o = function(r, a, l) {
833
- const d = [], c = ue(r[1]), h = ue(r[0]), u = ue(a[1]), g = ue(a[0]);
832
+ const n = V(e, t), s = function(r, a, l) {
833
+ const d = [], c = ue(r[1]), h = ue(r[0]), u = ue(a[1]), p = ue(a[0]);
834
834
  l += 1;
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
- if (p === 0 || isNaN(p)) return d;
835
+ const g = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
836
+ if (g === 0 || isNaN(g)) return d;
837
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);
838
+ const P = f / l, y = Math.sin((1 - P) * g) / Math.sin(g), C = Math.sin(P * g) / Math.sin(g), m = y * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(p), v = y * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(p), x = y * 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)]);
842
842
  }
843
843
  return d.slice(1, -1);
844
844
  }(e, t, Math.floor(n / i));
845
- return this.limitCoordinates(o);
845
+ return this.limitCoordinates(s);
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
- function ee(s, e) {
852
- return s[0] === e[0] && s[1] === e[1];
851
+ function ee(o, e) {
852
+ return o[0] === e[0] && o[1] === e[1];
853
853
  }
854
- function Ct(s, e) {
855
- return s.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : s.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : s.geometry.coordinates.every((t) => xe(t, e)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
854
+ function Ct(o, e) {
855
+ return o.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : o.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : o.geometry.coordinates.every((t) => xe(t, e)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
856
856
  }
857
- class Pt extends N {
857
+ class Pt extends B {
858
858
  constructor(e) {
859
859
  super(e), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0;
860
860
  const t = { start: "crosshair", close: "pointer" };
@@ -876,8 +876,8 @@ class Pt extends N {
876
876
  if (!this.currentId) return;
877
877
  const n = { type: "LineString", coordinates: e };
878
878
  if (this.validate && !this.validate({ type: "Feature", geometry: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }).valid) return;
879
- const o = [{ id: this.currentId, geometry: n }];
880
- this.closingPointId && t && o.push({ id: this.closingPointId, geometry: { type: "Point", coordinates: t } }), i === "commit" && (this.lastCommitedCoordinates = n.coordinates), this.store.updateGeometry(o);
879
+ const s = [{ id: this.currentId, geometry: n }];
880
+ this.closingPointId && t && s.push({ id: this.closingPointId, geometry: { type: "Point", coordinates: t } }), i === "commit" && (this.lastCommitedCoordinates = n.coordinates), this.store.updateGeometry(s);
881
881
  }
882
882
  generateInsertCoordinates(e, t) {
883
883
  if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
@@ -899,14 +899,14 @@ class Pt extends N {
899
899
  }
900
900
  updateToLine(e, t) {
901
901
  if (!this.currentId) return;
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();
902
+ const i = this.store.getGeometryCopy(this.currentId).coordinates, [n, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: r, y: a } = this.project(n, s);
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, [Oe]: !0 } }]);
924
924
  this.snappedPointId = r;
925
925
  }
926
926
  e.lng = t[0], e.lat = t[1];
@@ -930,17 +930,17 @@ 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
- let o = [...n, i];
935
+ let s = [...n, i];
936
936
  if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
937
937
  const r = this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1], a = i;
938
938
  if (!ee(r, a)) {
939
939
  const l = this.generateInsertCoordinates(r, a);
940
- o = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
940
+ s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
941
941
  }
942
942
  }
943
- this.updateGeometries(o, void 0, b.Provisional);
943
+ this.updateGeometries(s, void 0, b.Provisional);
944
944
  }
945
945
  onClick(e) {
946
946
  this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(e), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
@@ -985,10 +985,10 @@ class Pt extends N {
985
985
  }
986
986
  }
987
987
  const Zt = "Feature is not a Point", Qt = "Feature has invalid coordinates";
988
- function vt(s, e) {
989
- return s.geometry.type !== "Point" ? { valid: !1, reason: Zt } : xe(s.geometry.coordinates, e) ? { valid: !0 } : { valid: !1, reason: Qt };
988
+ function vt(o, e) {
989
+ return o.geometry.type !== "Point" ? { valid: !1, reason: Zt } : xe(o.geometry.coordinates, e) ? { valid: !0 } : { valid: !1, reason: Qt };
990
990
  }
991
- class ei extends N {
991
+ class ei extends B {
992
992
  constructor(e) {
993
993
  super(e), this.mode = "point", this.cursors = void 0;
994
994
  const t = { create: "crosshair" };
@@ -1029,7 +1029,7 @@ class ei extends N {
1029
1029
  return this.validateModeFeature(e, (t) => vt(t, this.coordinatePrecision));
1030
1030
  }
1031
1031
  }
1032
- class ti extends j {
1032
+ class ti extends W {
1033
1033
  constructor(e, t) {
1034
1034
  super(e), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = e, this.pixelDistance = t;
1035
1035
  }
@@ -1051,46 +1051,46 @@ class ti extends j {
1051
1051
  this.store.updateGeometry([{ id: this.ids[0], geometry: { type: "Point", coordinates: e[0] } }, { id: this.ids[1], geometry: { type: "Point", coordinates: e[e.length - 3] } }]);
1052
1052
  }
1053
1053
  isClosingPoint(e) {
1054
- const t = this.store.getGeometryCopy(this.ids[0]), i = this.store.getGeometryCopy(this.ids[1]), n = this.pixelDistance.measure(e, t.coordinates), o = this.pixelDistance.measure(e, i.coordinates);
1055
- return { isClosing: n < this.pointerDistance, isPreviousClosing: o < this.pointerDistance };
1054
+ const t = this.store.getGeometryCopy(this.ids[0]), i = this.store.getGeometryCopy(this.ids[1]), n = this.pixelDistance.measure(e, t.coordinates), s = this.pixelDistance.measure(e, i.coordinates);
1055
+ return { isClosing: n < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
1056
1056
  }
1057
1057
  }
1058
- function it(s) {
1059
- return Math.sqrt(Math.pow(s[0], 2) + Math.pow(s[1], 2) + Math.pow(s[2], 2));
1058
+ function it(o) {
1059
+ return Math.sqrt(Math.pow(o[0], 2) + Math.pow(o[1], 2) + Math.pow(o[2], 2));
1060
1060
  }
1061
- function R(s, e) {
1061
+ function R(o, e) {
1062
1062
  const t = function(i, n) {
1063
- const [o, r, a] = i, [l, d, c] = n;
1064
- return o * l + r * d + a * c;
1065
- }(s, e) / (it(s) * it(e));
1063
+ const [s, r, a] = i, [l, d, c] = n;
1064
+ return s * l + r * d + a * c;
1065
+ }(o, e) / (it(o) * it(e));
1066
1066
  return Math.acos(Math.min(Math.max(t, -1), 1));
1067
1067
  }
1068
- function be(s) {
1069
- const e = _(s[1]), t = _(s[0]);
1068
+ function be(o) {
1069
+ const e = D(o[1]), t = D(o[0]);
1070
1070
  return [Math.cos(e) * Math.cos(t), Math.cos(e) * Math.sin(t), Math.sin(e)];
1071
1071
  }
1072
- function X(s) {
1073
- const [e, t, i] = s, n = U(Math.asin(i));
1072
+ function X(o) {
1073
+ const [e, t, i] = o, n = U(Math.asin(i));
1074
1074
  return [U(Math.atan2(t, e)), n];
1075
1075
  }
1076
- function ii(s, e, t) {
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);
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];
1076
+ function ii(o, e, t) {
1077
+ const i = be(o), n = be(e), s = be(t), [r, a, l] = s, [d, c, h] = function(j, Y) {
1078
+ const [H, Be, Ne] = j, [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, p = h * r - d * l, g = d * a - c * r, f = g * c - p * h, P = u * h - g * d, y = p * 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), O = R(i, v), N = R(n, v);
1081
+ let _;
1082
+ return _ = w < O && w < N || I < O && I < N ? m : v, R(i, _) > x || R(n, _) > x ? V(X(_), X(i)) <= V(X(_), X(n)) ? [X(i), !0, !1] : [X(n), !1, !0] : [X(_), !1, !1];
1083
1083
  }
1084
- function ni(s, e, t) {
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)));
1086
- return { x: s.x + o * i, y: s.y + o * n };
1084
+ function ni(o, e, t) {
1085
+ const i = e.x - o.x, n = e.y - o.y, s = Math.max(0, Math.min(1, ((t.x - o.x) * i + (t.y - o.y) * n) / (i * i + n * n)));
1086
+ return { x: o.x + s * i, y: o.y + s * n };
1087
1087
  }
1088
- class oi extends j {
1088
+ class si extends W {
1089
1089
  constructor(e, t, i) {
1090
- super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (o) => !!(o.properties && o.properties.mode === this.mode)), this.getSnappableCoordinate = (n, o) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== o)), this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
1090
+ super(e), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (n) => this.getSnappable(n, (s) => !!(s.properties && s.properties.mode === this.mode)), this.getSnappableCoordinate = (n, s) => this.getSnappable(n, (r) => !!(r.properties && r.properties.mode === this.mode && r.id !== s)), this.config = e, this.pixelDistance = t, this.clickBoundingBox = i;
1091
1091
  }
1092
1092
  getSnappable(e, t) {
1093
- const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), o = { coord: void 0, minDistance: 1 / 0 };
1093
+ const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), s = { coord: void 0, minDistance: 1 / 0 };
1094
1094
  return n.forEach((r) => {
1095
1095
  let a;
1096
1096
  if (r.geometry.type === "Polygon") a = r.geometry.coordinates[0];
@@ -1102,36 +1102,36 @@ class oi extends j {
1102
1102
  for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
1103
1103
  let d;
1104
1104
  const c = [e.lng, e.lat];
1105
- if (this.config.projection === "web-mercator" ? d = function(u, g) {
1106
- let p = [1 / 0, 1 / 0], f = 1 / 0;
1107
- for (let P of g) {
1105
+ if (this.config.projection === "web-mercator" ? d = function(u, p) {
1106
+ let g = [1 / 0, 1 / 0], f = 1 / 0;
1107
+ for (let P of p) {
1108
1108
  const y = P[0], C = P[1];
1109
1109
  let m, v = 1 / 0;
1110
1110
  const x = S(y[0], y[1]), w = S(C[0], C[1]), I = S(u[0], u[1]);
1111
1111
  if (y[0] === u[0] && y[1] === u[1]) m = y;
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);
1115
- m = [O, B];
1114
+ const { x: O, y: N } = ni(x, w, I), { lng: _, lat: j } = k(O, N);
1115
+ m = [_, j];
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 < f && (g = m, f = v));
1118
1118
  }
1119
- return f === 1 / 0 ? void 0 : { coordinate: p, distance: f };
1120
- }(c, l) : this.config.projection === "globe" && (d = function(u, g) {
1121
- let p = [1 / 0, 1 / 0], f = 1 / 0;
1122
- for (let P of g) {
1119
+ return f === 1 / 0 ? void 0 : { coordinate: g, distance: f };
1120
+ }(c, l) : this.config.projection === "globe" && (d = function(u, p) {
1121
+ let g = [1 / 0, 1 / 0], f = 1 / 0;
1122
+ for (let P of p) {
1123
1123
  const y = 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
+ 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 && (g = m, f = v));
1126
1126
  }
1127
- return f === 1 / 0 ? void 0 : { coordinate: p, distance: f };
1127
+ return f === 1 / 0 ? void 0 : { coordinate: g, distance: f };
1128
1128
  }(c, l)), !d) return;
1129
1129
  const h = this.pixelDistance.measure(e, d.coordinate);
1130
- h < o.minDistance && h < this.pointerDistance && (o.coord = d.coordinate, o.minDistance = h);
1131
- }), o.coord;
1130
+ h < s.minDistance && h < this.pointerDistance && (s.coord = d.coordinate, s.minDistance = h);
1131
+ }), s.coord;
1132
1132
  }
1133
1133
  }
1134
- class xt extends N {
1134
+ class xt extends B {
1135
1135
  constructor(e) {
1136
1136
  super(e), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.snappedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
1137
1137
  const t = { start: "crosshair", close: "pointer" };
@@ -1149,8 +1149,8 @@ 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);
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);
1152
+ const t = new ke(e);
1153
+ this.pixelDistance = new We(e), this.lineSnapping = new si(e, this.pixelDistance, t), this.coordinateSnapping = new mt(e, this.pixelDistance, t), this.closingPoints = new ti(e, this.pixelDistance);
1154
1154
  }
1155
1155
  start() {
1156
1156
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -1164,8 +1164,8 @@ 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 } }]);
1168
- this.snappedPointId = o;
1167
+ const [s] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [Oe]: !0 } }]);
1168
+ this.snappedPointId = s;
1169
1169
  }
1170
1170
  e.lng = t[0], e.lat = t[1];
1171
1171
  } else this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
@@ -1173,12 +1173,12 @@ class xt extends N {
1173
1173
  const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
1174
1174
  let n;
1175
1175
  if (this.currentCoordinate === 1) {
1176
- const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
1176
+ const s = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, s);
1177
1177
  n = [i[0], [e.lng, e.lat], [e.lng, e.lat - r], i[0]];
1178
1178
  } else if (this.currentCoordinate === 2) n = [i[0], i[1], [e.lng, e.lat], i[0]];
1179
1179
  else {
1180
- const { isClosing: o, isPreviousClosing: r } = this.closingPoints.isClosingPoint(e);
1181
- r || o ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), n = [...i.slice(0, -2), i[0], i[0]]) : n = [...i.slice(0, -2), [e.lng, e.lat], i[0]];
1180
+ const { isClosing: s, isPreviousClosing: r } = this.closingPoints.isClosingPoint(e);
1181
+ r || s ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), n = [...i.slice(0, -2), i[0], i[0]]) : n = [...i.slice(0, -2), [e.lng, e.lat], i[0]];
1182
1182
  }
1183
1183
  this.updatePolygonGeometry(n, b.Provisional);
1184
1184
  }
@@ -1189,16 +1189,16 @@ class xt extends N {
1189
1189
  }
1190
1190
  snapCoordinate(e) {
1191
1191
  var t, i, n;
1192
- let o;
1192
+ let s;
1193
1193
  if ((t = this.snapping) != null && t.toLine) {
1194
1194
  let r;
1195
- r = this.currentId ? this.lineSnapping.getSnappableCoordinate(e, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(e), r && (o = r);
1195
+ r = this.currentId ? this.lineSnapping.getSnappableCoordinate(e, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(e), r && (s = r);
1196
1196
  }
1197
1197
  if ((i = this.snapping) != null && i.toCoordinate) {
1198
1198
  let r;
1199
- r = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(e, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(e), r && (o = r);
1199
+ r = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(e, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(e), r && (s = r);
1200
1200
  }
1201
- return (n = this.snapping) != null && n.toCustom && (o = this.snapping.toCustom(e)), o;
1201
+ return (n = this.snapping) != null && n.toCustom && (s = this.snapping.toCustom(e)), s;
1202
1202
  }
1203
1203
  onClick(e) {
1204
1204
  if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(e), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
@@ -1222,8 +1222,8 @@ class xt extends N {
1222
1222
  const t = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: n } = this.closingPoints.isClosingPoint(e);
1223
1223
  if (n || i) this.close();
1224
1224
  else {
1225
- const o = this.snapCoordinate(e);
1226
- if (o && (e.lng = o[0], e.lat = o[1]), ee([e.lng, e.lat], t[this.currentCoordinate - 1])) return;
1225
+ const s = this.snapCoordinate(e);
1226
+ if (s && (e.lng = s[0], e.lat = s[1]), ee([e.lng, e.lat], t[this.currentCoordinate - 1])) return;
1227
1227
  const r = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
1228
1228
  return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
1229
1229
  }([[...t.slice(0, -1), [e.lng, e.lat], t[0]]]);
@@ -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[Oe];
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
  }
@@ -1268,7 +1268,7 @@ class xt extends N {
1268
1268
  return this.validateModeFeature(e, (t) => Se(t, this.coordinatePrecision));
1269
1269
  }
1270
1270
  }
1271
- class St extends N {
1271
+ class St extends B {
1272
1272
  constructor(e) {
1273
1273
  super(e), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
1274
1274
  const t = { start: "crosshair" };
@@ -1328,9 +1328,9 @@ class St extends N {
1328
1328
  return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
1329
1329
  }
1330
1330
  }
1331
- class ie extends N {
1331
+ class ie extends B {
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;
@@ -1369,44 +1369,44 @@ class ie extends N {
1369
1369
  return t;
1370
1370
  }
1371
1371
  }
1372
- function Ce(s, e) {
1373
- const t = s, i = e, n = _(t[1]), o = _(i[1]);
1374
- let r = _(i[0] - t[0]);
1372
+ function Ce(o, e) {
1373
+ const t = o, i = e, n = D(t[1]), s = 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(s / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), l = (U(Math.atan2(r, a)) + 360) % 360;
1377
1377
  return l > 180 ? -(360 - l) : l;
1378
1378
  }
1379
- function je(s, e, t) {
1379
+ function je(o, 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 / _e, s = o[0] * Math.PI / 180, r = D(o[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
- 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];
1386
- return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
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 * (s + n * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1386
+ return u[0] += u[0] - o[0] > 180 ? -360 : o[0] - u[0] > 180 ? 360 : 0, u;
1387
1387
  }
1388
- function Mt(s, e, t, i, n) {
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)];
1388
+ function Mt(o, e, t, i, n) {
1389
+ const s = i(o[0], o[1]), r = i(e[0], e[1]), { lng: a, lat: l } = n((s.x + r.x) / 2, (s.y + r.y) / 2);
1390
+ return [E(a, t), E(l, t)];
1391
1391
  }
1392
- function si(s, e, t) {
1393
- const i = je(s, 1e3 * V(s, e) / 2, Ce(s, e));
1394
- return [F(i[0], t), F(i[1], t)];
1392
+ function oi(o, e, t) {
1393
+ const i = je(o, 1e3 * V(o, e) / 2, Ce(o, e));
1394
+ return [E(i[0], t), E(i[1], t)];
1395
1395
  }
1396
- function nt({ featureCoords: s, precision: e, unproject: t, project: i, projection: n }) {
1397
- const o = [];
1398
- for (let r = 0; r < s.length - 1; r++) {
1396
+ function nt({ featureCoords: o, precision: e, unproject: t, project: i, projection: n }) {
1397
+ const s = [];
1398
+ for (let r = 0; r < o.length - 1; r++) {
1399
1399
  let a;
1400
- if (n === "web-mercator") a = Mt(s[r], s[r + 1], e, i, t);
1400
+ if (n === "web-mercator") a = Mt(o[r], o[r + 1], e, i, t);
1401
1401
  else {
1402
1402
  if (n !== "globe") throw new Error("Invalid projection");
1403
- a = si(s[r], s[r + 1], e);
1403
+ a = oi(o[r], o[r + 1], e);
1404
1404
  }
1405
- o.push(a);
1405
+ s.push(a);
1406
1406
  }
1407
- return o;
1407
+ return s;
1408
1408
  }
1409
- class ri extends j {
1409
+ class ri extends W {
1410
1410
  constructor(e, t) {
1411
1411
  super(e), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = e, this.selectionPointBehavior = t;
1412
1412
  }
@@ -1416,14 +1416,14 @@ class ri extends j {
1416
1416
  set ids(e) {
1417
1417
  }
1418
1418
  insert(e, t) {
1419
- const i = this.store.getGeometryCopy(e), { midPointFeatureId: n, midPointSegment: o } = this.store.getPropertiesCopy(e), r = this.store.getGeometryCopy(n), a = r.type === "Polygon" ? r.coordinates[0] : r.coordinates;
1420
- a.splice(o + 1, 0, i.coordinates), r.coordinates = r.type === "Polygon" ? [a] : a, this.store.updateGeometry([{ id: n, geometry: r }]), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(a, n, t), this.selectionPointBehavior.create(a, r.type, n);
1419
+ const i = this.store.getGeometryCopy(e), { midPointFeatureId: n, midPointSegment: s } = this.store.getPropertiesCopy(e), r = this.store.getGeometryCopy(n), a = r.type === "Polygon" ? r.coordinates[0] : r.coordinates;
1420
+ a.splice(s + 1, 0, i.coordinates), r.coordinates = r.type === "Polygon" ? [a] : a, this.store.updateGeometry([{ id: n, geometry: r }]), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(a, n, t), this.selectionPointBehavior.create(a, r.type, n);
1421
1421
  }
1422
1422
  create(e, t, i) {
1423
1423
  if (!this.store.has(t)) throw new Error("Store does not have feature with this id");
1424
- this._midPoints = this.store.create(function(n, o, r, a, l, d) {
1425
- return nt({ featureCoords: n, precision: r, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: o(h) }));
1426
- }(e, (n) => ({ mode: this.mode, [se]: !0, midPointSegment: n, midPointFeatureId: t }), i, this.config.project, this.config.unproject, this.projection));
1424
+ this._midPoints = this.store.create(function(n, s, r, a, l, d) {
1425
+ return nt({ featureCoords: n, precision: r, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1426
+ }(e, (n) => ({ mode: this.mode, [oe]: !0, midPointSegment: n, midPointFeatureId: t }), i, this.config.project, this.config.unproject, this.projection));
1427
1427
  }
1428
1428
  delete() {
1429
1429
  this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
@@ -1432,7 +1432,7 @@ class ri extends j {
1432
1432
  if (this._midPoints.length !== 0) return nt({ featureCoords: e, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((t, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: t } }));
1433
1433
  }
1434
1434
  }
1435
- class ai extends j {
1435
+ class ai extends W {
1436
1436
  constructor(e) {
1437
1437
  super(e), this._selectionPoints = [];
1438
1438
  }
@@ -1442,8 +1442,8 @@ class ai extends j {
1442
1442
  set ids(e) {
1443
1443
  }
1444
1444
  create(e, t, i) {
1445
- this._selectionPoints = this.store.create(function(n, o, r) {
1446
- const a = [], l = o === "Polygon" ? n.length - 1 : n.length;
1445
+ this._selectionPoints = this.store.create(function(n, s, r) {
1446
+ const a = [], l = s === "Polygon" ? n.length - 1 : n.length;
1447
1447
  for (let d = 0; d < l; d++) a.push({ geometry: { type: "Point", coordinates: n[d] }, properties: r(d) });
1448
1448
  return a;
1449
1449
  }(e, t, (n) => ({ mode: this.mode, selectionPoint: !0, selectionPointFeatureId: i, index: n })));
@@ -1458,52 +1458,52 @@ class ai extends j {
1458
1458
  if (this._selectionPoints[e] !== void 0) return { id: this._selectionPoints[e], geometry: { type: "Point", coordinates: t } };
1459
1459
  }
1460
1460
  }
1461
- function wt(s, e) {
1461
+ function wt(o, e) {
1462
1462
  let t = !1;
1463
1463
  for (let r = 0, a = e.length; r < a; r++) {
1464
1464
  const l = e[r];
1465
- for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (n = l[d])[1] > (i = s)[1] != (o = l[h])[1] > i[1] && i[0] < (o[0] - n[0]) * (i[1] - n[1]) / (o[1] - n[1]) + n[0] && (t = !t);
1465
+ for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (n = l[d])[1] > (i = o)[1] != (s = l[h])[1] > i[1] && i[0] < (s[0] - n[0]) * (i[1] - n[1]) / (s[1] - n[1]) + n[0] && (t = !t);
1466
1466
  }
1467
- var i, n, o;
1467
+ var i, n, s;
1468
1468
  return t;
1469
1469
  }
1470
- const bt = (s, e, t) => {
1471
- const i = (o) => o * o, n = (o, r) => i(o.x - r.x) + i(o.y - r.y);
1472
- return Math.sqrt(((o, r, a) => {
1470
+ const bt = (o, e, t) => {
1471
+ const i = (s) => s * s, n = (s, r) => i(s.x - r.x) + i(s.y - r.y);
1472
+ return Math.sqrt(((s, r, a) => {
1473
1473
  const l = n(r, a);
1474
- if (l === 0) return n(o, r);
1475
- let d = ((o.x - r.x) * (a.x - r.x) + (o.y - r.y) * (a.y - r.y)) / l;
1476
- return d = Math.max(0, Math.min(1, d)), n(o, { x: r.x + d * (a.x - r.x), y: r.y + d * (a.y - r.y) });
1477
- })(s, e, t));
1474
+ if (l === 0) return n(s, r);
1475
+ let d = ((s.x - r.x) * (a.x - r.x) + (s.y - r.y) * (a.y - r.y)) / l;
1476
+ return d = Math.max(0, Math.min(1, d)), n(s, { x: r.x + d * (a.x - r.x), y: r.y + d * (a.y - r.y) });
1477
+ })(o, e, t));
1478
1478
  };
1479
- class li extends j {
1479
+ class li extends W {
1480
1480
  constructor(e, t, i) {
1481
1481
  super(e), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = e, this.createClickBoundingBox = t, this.pixelDistance = i;
1482
1482
  }
1483
1483
  find(e, t) {
1484
- let i, n, o, r, a = 1 / 0, l = 1 / 0, d = 1 / 0;
1484
+ let i, n, s, r, a = 1 / 0, l = 1 / 0, d = 1 / 0;
1485
1485
  const c = this.createClickBoundingBox.create(e), h = this.store.search(c);
1486
1486
  for (let u = 0; u < h.length; u++) {
1487
- const g = h[u], p = g.geometry;
1488
- if (p.type === "Point") {
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);
1492
- } else if (p.type === "LineString") {
1487
+ const p = h[u], g = p.geometry;
1488
+ if (g.type === "Point") {
1489
+ if (p.properties.selectionPoint || !t && p.properties[oe]) continue;
1490
+ const f = this.pixelDistance.measure(e, g.coordinates);
1491
+ p.properties[oe] && f < this.pointerDistance && f < d ? (d = f, s = p) : !p.properties[oe] && f < this.pointerDistance && f < a && (a = f, i = p);
1492
+ } else if (g.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]));
1496
- C < this.pointerDistance && C < l && (l = C, n = g);
1494
+ for (let f = 0; f < g.coordinates.length - 1; f++) {
1495
+ const P = g.coordinates[f], y = g.coordinates[f + 1], C = bt({ x: e.containerX, y: e.containerY }, this.project(P[0], P[1]), this.project(y[0], y[1]));
1496
+ C < this.pointerDistance && C < l && (l = C, n = p);
1497
1497
  }
1498
- } else if (p.type === "Polygon") {
1498
+ } else if (g.type === "Polygon") {
1499
1499
  if (i || n) continue;
1500
- wt([e.lng, e.lat], p.coordinates) && (r = g);
1500
+ wt([e.lng, e.lat], g.coordinates) && (r = p);
1501
1501
  }
1502
1502
  }
1503
- return { clickedFeature: i || n || r, clickedMidPoint: o };
1503
+ return { clickedFeature: i || n || r, clickedMidPoint: s };
1504
1504
  }
1505
1505
  }
1506
- class di extends j {
1506
+ class di extends W {
1507
1507
  constructor(e, t, i, n) {
1508
1508
  super(e), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = e, this.featuresAtCursorEvent = t, this.selectionPoints = i, this.midPoints = n;
1509
1509
  }
@@ -1524,29 +1524,29 @@ class di extends j {
1524
1524
  if (!this.draggedFeatureId) return;
1525
1525
  const i = this.store.getGeometryCopy(this.draggedFeatureId), n = [e.lng, e.lat];
1526
1526
  if (i.type === "Polygon" || i.type === "LineString") {
1527
- let o, r;
1528
- if (i.type === "Polygon" ? (o = i.coordinates[0], r = o.length - 1) : (o = i.coordinates, r = o.length), !this.dragPosition) return !1;
1527
+ let s, r;
1528
+ if (i.type === "Polygon" ? (s = i.coordinates[0], r = s.length - 1) : (s = i.coordinates, r = s.length), !this.dragPosition) return !1;
1529
1529
  for (let d = 0; d < r; d++) {
1530
- const c = o[d];
1530
+ const c = s[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 p = S(this.dragPosition[0], this.dragPosition[1]), g = S(n[0], n[1]), f = S(c[0], c[1]), P = { x: p.x - g.x, y: p.y - g.y }, y = f.x - P.x, C = f.y - P.y, { lng: m, lat: v } = k(y, C);
1534
1534
  h = m, u = v;
1535
1535
  } else {
1536
- const g = [this.dragPosition[0] - n[0], this.dragPosition[1] - n[1]];
1537
- h = c[0] - g[0], u = c[1] - g[1];
1536
+ const p = [this.dragPosition[0] - n[0], this.dragPosition[1] - n[1]];
1537
+ h = c[0] - p[0], u = c[1] - p[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;
1540
- o[d] = [h, u];
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
+ s[d] = [h, u];
1541
1541
  }
1542
- i.type === "Polygon" && (o[o.length - 1] = [o[0][0], o[0][1]]);
1543
- const a = this.selectionPoints.getUpdated(o) || [], l = this.midPoints.getUpdated(o) || [];
1542
+ i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
1543
+ const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [];
1544
1544
  if (t && !t({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid) return !1;
1545
1545
  this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [e.lng, e.lat];
1546
1546
  } else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: n } }]), this.dragPosition = [e.lng, e.lat]);
1547
1547
  }
1548
1548
  }
1549
- class ci extends j {
1549
+ class ci extends W {
1550
1550
  constructor(e, t, i, n) {
1551
1551
  super(e), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = e, this.pixelDistance = t, this.selectionPoints = i, this.midPoints = n;
1552
1552
  }
@@ -1558,11 +1558,11 @@ class ci extends j {
1558
1558
  if (t.type !== "Polygon") return i;
1559
1559
  n = t.coordinates[0];
1560
1560
  }
1561
- for (let o = 0; o < n.length; o++) {
1562
- const r = this.pixelDistance.measure(e, n[o]);
1561
+ for (let s = 0; s < n.length; s++) {
1562
+ const r = this.pixelDistance.measure(e, n[s]);
1563
1563
  if (r < this.pointerDistance && r < i.dist) {
1564
- const a = t.type === "Polygon" && (o === n.length - 1 || o === 0);
1565
- i.dist = r, i.index = a ? 0 : o, i.isFirstOrLastPolygonCoord = a;
1564
+ const a = t.type === "Polygon" && (s === n.length - 1 || s === 0);
1565
+ i.dist = r, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
1566
1566
  }
1567
1567
  }
1568
1568
  return i;
@@ -1573,15 +1573,15 @@ class ci extends j {
1573
1573
  }
1574
1574
  drag(e, t, i) {
1575
1575
  if (!this.draggedCoordinate.id) return !1;
1576
- const n = this.draggedCoordinate.index, o = this.store.getGeometryCopy(this.draggedCoordinate.id), r = o.type === "LineString" ? o.coordinates : o.coordinates[0], a = [e.lng, e.lat];
1576
+ const n = this.draggedCoordinate.index, s = this.store.getGeometryCopy(this.draggedCoordinate.id), r = s.type === "LineString" ? s.coordinates : s.coordinates[0], a = [e.lng, e.lat];
1577
1577
  if (e.lng > 180 || e.lng < -180 || e.lat > 90 || e.lat < -90) return !1;
1578
- if (o.type !== "Polygon" || n !== r.length - 1 && n !== 0) r[n] = a;
1578
+ if (s.type !== "Polygon" || n !== r.length - 1 && n !== 0) r[n] = a;
1579
1579
  else {
1580
1580
  const h = r.length - 1;
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 !(s.type !== "Point" && !t && Le({ type: "Feature", geometry: s, properties: {} }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, 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: s }, ...d, ...c]), 0));
1585
1585
  }
1586
1586
  isDragging() {
1587
1587
  return this.draggedCoordinate.id !== null;
@@ -1593,44 +1593,44 @@ class ci extends j {
1593
1593
  this.draggedCoordinate = { id: null, index: -1 };
1594
1594
  }
1595
1595
  }
1596
- function Pe(s) {
1596
+ function Pe(o) {
1597
1597
  let e = 0, t = 0, i = 0;
1598
- return (s.geometry.type === "Polygon" ? s.geometry.coordinates[0].slice(0, -1) : s.geometry.coordinates).forEach((n) => {
1598
+ return (o.geometry.type === "Polygon" ? o.geometry.coordinates[0].slice(0, -1) : o.geometry.coordinates).forEach((n) => {
1599
1599
  e += n[0], t += n[1], i++;
1600
1600
  }, !0), [e / i, t / i];
1601
1601
  }
1602
- function It(s, e) {
1603
- s[0] += s[0] - e[0] > 180 ? -360 : e[0] - s[0] > 180 ? 360 : 0;
1604
- const t = Oe, i = e[1] * Math.PI / 180, n = s[1] * Math.PI / 180, o = n - i;
1605
- let r = Math.abs(s[0] - e[0]) * Math.PI / 180;
1602
+ function It(o, e) {
1603
+ o[0] += o[0] - e[0] > 180 ? -360 : e[0] - o[0] > 180 ? 360 : 0;
1604
+ const t = _e, i = e[1] * Math.PI / 180, n = o[1] * Math.PI / 180, s = n - i;
1605
+ let r = Math.abs(o[0] - e[0]) * Math.PI / 180;
1606
1606
  r > Math.PI && (r -= 2 * Math.PI);
1607
- const a = Math.log(Math.tan(n / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? o / a : Math.cos(i);
1608
- return Math.sqrt(o * o + l * l * r * r) * t;
1607
+ const a = Math.log(Math.tan(n / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? s / a : Math.cos(i);
1608
+ return Math.sqrt(s * s + l * l * r * r) * t;
1609
1609
  }
1610
- function ve(s) {
1611
- const e = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.geometry.coordinates).map((t) => {
1610
+ function ve(o) {
1611
+ const e = (o.geometry.type === "Polygon" ? o.geometry.coordinates[0] : o.geometry.coordinates).map((t) => {
1612
1612
  const { x: i, y: n } = S(t[0], t[1]);
1613
1613
  return [i, n];
1614
1614
  });
1615
- return s.geometry.type === "Polygon" ? function(t) {
1616
- let i = 0, n = 0, o = 0;
1615
+ return o.geometry.type === "Polygon" ? function(t) {
1616
+ let i = 0, n = 0, s = 0;
1617
1617
  const r = t.length;
1618
1618
  for (let a = 0; a < r - 1; a++) {
1619
1619
  const [l, d] = t[a], [c, h] = t[a + 1], u = l * h - c * d;
1620
- i += u, n += (l + c) * u, o += (d + h) * u;
1620
+ i += u, n += (l + c) * u, s += (d + h) * u;
1621
1621
  }
1622
- return i /= 2, n /= 6 * i, o /= 6 * i, { x: n, y: o };
1622
+ return i /= 2, n /= 6 * i, s /= 6 * i, { x: n, y: s };
1623
1623
  }(e) : function(t) {
1624
1624
  const i = t.length;
1625
- let n = 0, o = 0;
1625
+ let n = 0, s = 0;
1626
1626
  for (let r = 0; r < i; r++) {
1627
1627
  const [a, l] = t[r];
1628
- n += a, o += l;
1628
+ n += a, s += l;
1629
1629
  }
1630
- return { x: n / i, y: o / i };
1630
+ return { x: n / i, y: s / i };
1631
1631
  }(e);
1632
1632
  }
1633
- class hi extends j {
1633
+ class hi extends W {
1634
1634
  constructor(e, t, i) {
1635
1635
  super(e), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = e, this.selectionPoints = t, this.midPoints = i;
1636
1636
  }
@@ -1640,40 +1640,40 @@ class hi extends j {
1640
1640
  rotate(e, t, i) {
1641
1641
  const n = this.store.getGeometryCopy(t);
1642
1642
  if (n.type !== "Polygon" && n.type !== "LineString") return;
1643
- const o = [e.lng, e.lat];
1643
+ const s = [e.lng, e.lat];
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 p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([y, C]) => S(y, C)), f = g.reduce((y, C) => ({ x: y.x + C.x, y: y.y + C.y }), { x: 0, y: 0 });
1651
+ f.x /= g.length, f.y /= g.length;
1652
+ const P = g.map((y) => ({ x: f.x + (y.x - f.x) * Math.cos(p) - (y.y - f.y) * Math.sin(p), y: f.y + (y.x - f.x) * Math.sin(p) + (y.y - f.y) * Math.cos(p) })).map(({ x: y, y: C }) => [k(y, C).lng, k(y, 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 {
1656
1656
  if (this.config.projection !== "globe") throw new Error("Unsupported projection");
1657
- if (r = Ce(Pe({ type: "Feature", geometry: n, properties: {} }), o), !this.lastBearing) return void (this.lastBearing = r + 180);
1657
+ if (r = Ce(Pe({ type: "Feature", geometry: n, properties: {} }), s), !this.lastBearing) return void (this.lastBearing = r + 180);
1658
1658
  (function(h, u) {
1659
1659
  if (u === 0 || u === 360 || u === -360) return h;
1660
- const g = Pe(h);
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];
1660
+ const p = Pe(h);
1661
+ (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((g) => {
1662
+ const f = Ce(p, g) + u, P = It(p, g), y = je(p, P, f);
1663
+ g[0] = y[0], g[1] = y[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;
1673
1673
  this.store.updateGeometry([{ id: t, geometry: n }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = r : this.projection === "globe" && (this.lastBearing = r + 180);
1674
1674
  }
1675
1675
  }
1676
- class ui extends j {
1676
+ class ui extends W {
1677
1677
  constructor(e, t, i) {
1678
1678
  super(e), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = e, this.selectionPoints = t, this.midPoints = i;
1679
1679
  }
@@ -1683,41 +1683,41 @@ class ui extends j {
1683
1683
  scale(e, t, i) {
1684
1684
  const n = this.store.getGeometryCopy(t);
1685
1685
  if (n.type !== "Polygon" && n.type !== "LineString") return;
1686
- const o = [e.lng, e.lat], r = { type: "Feature", geometry: n, properties: {} };
1686
+ const s = [e.lng, e.lat], r = { type: "Feature", geometry: n, properties: {} };
1687
1687
  let a;
1688
1688
  const l = ve(r);
1689
1689
  if (this.config.projection === "web-mercator") {
1690
- const g = S(e.lng, e.lat);
1691
- a = E(l, g);
1690
+ const p = S(e.lng, e.lat);
1691
+ a = F(l, p);
1692
1692
  } else {
1693
1693
  if (this.config.projection !== "globe") throw new Error("Invalid projection");
1694
- a = V(Pe({ type: "Feature", geometry: n, properties: {} }), o);
1694
+ a = V(Pe({ type: "Feature", geometry: n, properties: {} }), s);
1695
1695
  }
1696
1696
  if (!this.lastDistance) return void (this.lastDistance = a);
1697
1697
  const d = 1 - (this.lastDistance - a) / a;
1698
1698
  if (this.config.projection === "web-mercator") {
1699
- const { lng: g, lat: p } = W(l.x, l.y);
1699
+ const { lng: p, lat: g } = k(l.x, l.y);
1700
1700
  (function(f, P, y) {
1701
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]);
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 }) => [k(x, w).lng, k(x, w).lat]);
1703
1703
  f.geometry.type === "Polygon" ? f.geometry.coordinates[0] = v : f.geometry.coordinates = v;
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);
1704
+ })(r, d, [p, g]);
1705
+ } else this.config.projection === "globe" && function(p, g, f, P = "xy") {
1706
+ g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((y) => {
1707
+ const C = It(f, y), m = Ce(f, y), v = je(f, C * g, m);
1708
1708
  P !== "x" && P !== "xy" || (y[0] = v[0]), P !== "y" && P !== "xy" || (y[1] = v[1]);
1709
1709
  });
1710
1710
  }(r, d, Pe(r));
1711
1711
  const c = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
1712
- c.forEach((g) => {
1713
- g[0] = F(g[0], this.coordinatePrecision), g[1] = F(g[1], this.coordinatePrecision);
1712
+ c.forEach((p) => {
1713
+ p[0] = E(p[0], this.coordinatePrecision), p[1] = E(p[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;
1717
1717
  this.store.updateGeometry([{ id: t, geometry: n }, ...u, ...h]), this.lastDistance = a;
1718
1718
  }
1719
1719
  }
1720
- class gi extends j {
1720
+ class pi extends W {
1721
1721
  constructor(e, t, i, n) {
1722
1722
  super(e), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.minimumScale = 1e-4, this.draggedCoordinate = { id: null, index: -1 }, this.boundingBoxMaps = { opposite: { 0: 4, 1: 5, 2: 6, 3: 7, 4: 0, 5: 1, 6: 2, 7: 3 } }, this.config = e, this.pixelDistance = t, this.selectionPoints = i, this.midPoints = n;
1723
1723
  }
@@ -1729,11 +1729,11 @@ class gi extends j {
1729
1729
  if (t.type !== "Polygon") return i;
1730
1730
  n = t.coordinates[0];
1731
1731
  }
1732
- for (let o = 0; o < n.length; o++) {
1733
- const r = this.pixelDistance.measure(e, n[o]);
1732
+ for (let s = 0; s < n.length; s++) {
1733
+ const r = this.pixelDistance.measure(e, n[s]);
1734
1734
  if (r < this.pointerDistance && r < i.dist) {
1735
- const a = t.type === "Polygon" && (o === n.length - 1 || o === 0);
1736
- i.dist = r, i.index = a ? 0 : o, i.isFirstOrLastPolygonCoord = a;
1735
+ const a = t.type === "Polygon" && (s === n.length - 1 || s === 0);
1736
+ i.dist = r, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
1737
1737
  }
1738
1738
  }
1739
1739
  return i;
@@ -1776,43 +1776,43 @@ class gi extends j {
1776
1776
  centerWebMercatorDrag(e) {
1777
1777
  const t = this.getSelectedFeatureDataWebMercator();
1778
1778
  if (!t) return null;
1779
- const { feature: i, boundingBox: n, updatedCoords: o, selectedCoordinate: r } = t, a = ve(i);
1779
+ const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a = ve(i);
1780
1780
  if (!a) return null;
1781
1781
  const l = S(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), c = S(e.lng, e.lat);
1782
- return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), o;
1782
+ return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1783
1783
  }
1784
1784
  centerFixedWebMercatorDrag(e) {
1785
1785
  const t = this.getSelectedFeatureDataWebMercator();
1786
1786
  if (!t) return null;
1787
- const { feature: i, boundingBox: n, updatedCoords: o, selectedCoordinate: r } = t, a = ve(i);
1787
+ const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a = ve(i);
1788
1788
  if (!a) return null;
1789
1789
  const l = S(r[0], r[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(n, l), c = S(e.lng, e.lat);
1790
- return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), o;
1790
+ return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1791
1791
  }
1792
- scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: o }) {
1792
+ scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: s }) {
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);
1795
- return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(o, t.x, t.y, r, r), o;
1794
+ let r = F(t, n) / F(t, i);
1795
+ return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(s, t.x, t.y, r, r), s;
1796
1796
  }
1797
1797
  oppositeFixedWebMercatorDrag(e) {
1798
1798
  const t = this.getSelectedFeatureDataWebMercator();
1799
1799
  if (!t) return null;
1800
- const { boundingBox: i, updatedCoords: n, selectedCoordinate: o } = t, r = S(o[0], o[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = S(e.lng, e.lat);
1800
+ const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = S(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = S(e.lng, e.lat);
1801
1801
  return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor: c, webMercatorSelected: r, webMercatorOrigin: d }), n;
1802
1802
  }
1803
1803
  oppositeWebMercatorDrag(e) {
1804
1804
  const t = this.getSelectedFeatureDataWebMercator();
1805
1805
  if (!t) return null;
1806
- const { boundingBox: i, updatedCoords: n, selectedCoordinate: o } = t, r = S(o[0], o[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = S(e.lng, e.lat);
1806
+ const { boundingBox: i, updatedCoords: n, selectedCoordinate: s } = t, r = S(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, r), d = { x: i[a][0], y: i[a][1] }, c = S(e.lng, e.lat);
1807
1807
  return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: n, webMercatorCursor: c, webMercatorSelected: r, webMercatorOrigin: d }), n;
1808
1808
  }
1809
- scaleWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: o }) {
1809
+ scaleWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: s }) {
1810
1810
  const r = t.x - n.x, a = t.y - n.y;
1811
1811
  if (!this.isValidDragWebMercator(e, r, a)) return null;
1812
1812
  let l = 1;
1813
1813
  r !== 0 && e !== 1 && e !== 5 && (l = 1 - (t.x - i.x - r) / r);
1814
1814
  let d = 1;
1815
- return a !== 0 && e !== 3 && e !== 7 && (d = 1 - (t.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(o, t.x, t.y, l, d), o) : null;
1815
+ return a !== 0 && e !== 3 && e !== 7 && (d = 1 - (t.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(s, t.x, t.y, l, d), s) : null;
1816
1816
  }
1817
1817
  getFeature(e) {
1818
1818
  if (this.draggedCoordinate.id === null) return null;
@@ -1826,9 +1826,9 @@ class gi extends j {
1826
1826
  const i = !isNaN(e) && t < Number.MAX_SAFE_INTEGER, n = !isNaN(t) && t < Number.MAX_SAFE_INTEGER;
1827
1827
  return i && n;
1828
1828
  }
1829
- performWebMercatorScale(e, t, i, n, o) {
1829
+ performWebMercatorScale(e, t, i, n, s) {
1830
1830
  e.forEach((r) => {
1831
- const { x: a, y: l } = S(r[0], r[1]), d = t + (a - t) * n, c = i + (l - i) * o, { lng: h, lat: u } = W(d, c);
1831
+ const { x: a, y: l } = S(r[0], r[1]), d = t + (a - t) * n, c = i + (l - i) * s, { lng: h, lat: u } = k(d, c);
1832
1832
  r[0] = h, r[1] = u;
1833
1833
  });
1834
1834
  }
@@ -1840,14 +1840,14 @@ class gi extends j {
1840
1840
  })).forEach(([a, l]) => {
1841
1841
  a < t[0] && (t[0] = a), l < t[1] && (t[1] = l), a > t[2] && (t[2] = a), l > t[3] && (t[3] = l);
1842
1842
  });
1843
- const [i, n, o, r] = t;
1844
- return [[i, r], [(i + o) / 2, r], [o, r], [o, r + (n - r) / 2], [o, n], [(i + o) / 2, n], [i, n], [i, r + (n - r) / 2]];
1843
+ const [i, n, s, r] = t;
1844
+ return [[i, r], [(i + s) / 2, r], [s, r], [s, r + (n - r) / 2], [s, n], [(i + s) / 2, n], [i, n], [i, r + (n - r) / 2]];
1845
1845
  }
1846
1846
  getIndexesWebMercator(e, t) {
1847
1847
  let i, n = 1 / 0;
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] });
1850
- r < n && (i = o, n = r);
1848
+ for (let s = 0; s < e.length; s++) {
1849
+ const r = F({ x: t.x, y: t.y }, { x: e[s][0], y: e[s][1] });
1850
+ r < n && (i = s, n = r);
1851
1851
  }
1852
1852
  if (i === void 0) throw new Error("No closest coordinate found");
1853
1853
  return { oppositeBboxIndex: this.boundingBoxMaps.opposite[i], closestBBoxIndex: i };
@@ -1869,17 +1869,17 @@ class gi extends j {
1869
1869
  if (!this.draggedCoordinate.id) return !1;
1870
1870
  const n = this.getFeature(this.draggedCoordinate.id);
1871
1871
  if (!n) return !1;
1872
- let o = null;
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
- for (let d = 0; d < o.length; d++) {
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;
1872
+ let s = null;
1873
+ if (t === "center" ? s = this.centerWebMercatorDrag(e) : t === "opposite" ? s = this.oppositeWebMercatorDrag(e) : t === "center-fixed" ? s = this.centerFixedWebMercatorDrag(e) : t === "opposite-fixed" && (s = this.oppositeFixedWebMercatorDrag(e)), !s) return !1;
1874
+ for (let d = 0; d < s.length; d++) {
1875
+ const c = s[d];
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
- const r = this.midPoints.getUpdated(o) || [], a = this.selectionPoints.getUpdated(o) || [], l = { type: n.geometry.type, coordinates: n.geometry.type === "Polygon" ? [o] : o };
1878
+ const r = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: n.geometry.type, coordinates: n.geometry.type === "Polygon" ? [s] : s };
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));
1880
1880
  }
1881
1881
  }
1882
- class pi extends Rt {
1882
+ class gi extends Rt {
1883
1883
  constructor(e) {
1884
1884
  var t;
1885
1885
  super(e), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = void 0, this.keyEvents = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.cursors = void 0, this.validations = {}, this.flags = e && e.flags ? e.flags : {};
@@ -1890,8 +1890,8 @@ class pi extends Rt {
1890
1890
  this.keyEvents = e && e.keyEvents ? M({}, n, e.keyEvents) : n;
1891
1891
  }
1892
1892
  if (this.dragEventThrottle = e && e.dragEventThrottle !== void 0 && e.dragEventThrottle || 5, this.allowManualDeselection = (t = e == null ? void 0 : e.allowManualDeselection) == null || t, e && e.flags && e.flags) for (const n in e.flags) {
1893
- const o = e.flags[n].feature;
1894
- o && o.validation && (this.validations[n] = o.validation);
1893
+ const s = e.flags[n].feature;
1894
+ s && s.validation && (this.validations[n] = s.validation);
1895
1895
  }
1896
1896
  }
1897
1897
  selectFeature(e) {
@@ -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 pi(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() {
@@ -1918,10 +1918,10 @@ class pi extends Rt {
1918
1918
  if (!this.selectionPoints.ids.length) return;
1919
1919
  let t, i = 1 / 0;
1920
1920
  if (this.selectionPoints.ids.forEach((h) => {
1921
- const u = this.store.getGeometryCopy(h), g = this.pixelDistance.measure(e, u.coordinates);
1922
- g < this.pointerDistance && g < i && (i = g, t = this.store.getPropertiesCopy(h));
1921
+ const u = this.store.getGeometryCopy(h), p = this.pixelDistance.measure(e, u.coordinates);
1922
+ p < this.pointerDistance && p < i && (i = p, t = this.store.getPropertiesCopy(h));
1923
1923
  }), !t) return;
1924
- const n = t.selectionPointFeatureId, o = t.index, r = this.store.getPropertiesCopy(n), a = this.flags[r.mode], l = this.validations[r.mode];
1924
+ const n = t.selectionPointFeatureId, s = t.index, r = this.store.getPropertiesCopy(n), a = this.flags[r.mode], l = this.validations[r.mode];
1925
1925
  if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
1926
1926
  const d = this.store.getGeometryCopy(n);
1927
1927
  let c;
@@ -1929,7 +1929,7 @@ class pi extends Rt {
1929
1929
  if (c = d.coordinates[0], c.length <= 4) return;
1930
1930
  } else if (d.type === "LineString" && (c = d.coordinates, c.length <= 3)) return;
1931
1931
  if (c) {
1932
- if (d.type === "Polygon" && o === 0 || o === c.length - 1 ? (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])) : c.splice(o, 1), l && !l({ id: n, type: "Feature", geometry: d, properties: r }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Commit }).valid) return;
1932
+ if (d.type === "Polygon" && s === 0 || s === c.length - 1 ? (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])) : c.splice(s, 1), l && !l({ id: n, type: "Feature", geometry: d, properties: r }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: b.Commit }).valid) return;
1933
1933
  this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: n, geometry: d }]), this.selectionPoints.create(c, d.type, n), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, n, this.coordinatePrecision);
1934
1934
  }
1935
1935
  }
@@ -1937,9 +1937,9 @@ class pi extends Rt {
1937
1937
  if (this.selected[0] === e) return;
1938
1938
  const { mode: i } = this.store.getPropertiesCopy(e), n = this.flags[i];
1939
1939
  if (!n || !n.feature) return;
1940
- const o = this.selected[0];
1941
- if (o) {
1942
- if (o === e) return;
1940
+ const s = this.selected[0];
1941
+ if (s) {
1942
+ if (s === e) return;
1943
1943
  this.deselect();
1944
1944
  }
1945
1945
  t && this.setCursor(this.cursors.pointerOver), this.selected = [e], this.store.updateProperty([{ id: e, property: "selected", value: !0 }]), this.onSelect(e);
@@ -1990,20 +1990,20 @@ class pi extends Rt {
1990
1990
  const i = this.store.getPropertiesCopy(this.selected[0]), n = this.flags[i.mode];
1991
1991
  if (!(n && n.feature && (n.feature.draggable || n.feature.coordinates && n.feature.coordinates.draggable || n.feature.coordinates && n.feature.coordinates.resizable))) return;
1992
1992
  this.dragEventCount = 0;
1993
- const o = this.selected[0], r = this.dragCoordinate.getDraggableIndex(e, o);
1994
- return n && n.feature && n.feature.coordinates && (n.feature.coordinates.draggable || n.feature.coordinates.resizable) && r !== -1 ? (this.setCursor(this.cursors.dragStart), n.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(o, r) : this.dragCoordinate.startDragging(o, r), void t(!1)) : n && n.feature && n.feature.draggable && this.dragFeature.canDrag(e, o) ? (this.setCursor(this.cursors.dragStart), this.dragFeature.startDragging(e, o), void t(!1)) : void 0;
1993
+ const s = this.selected[0], r = this.dragCoordinate.getDraggableIndex(e, s);
1994
+ return n && n.feature && n.feature.coordinates && (n.feature.coordinates.draggable || n.feature.coordinates.resizable) && r !== -1 ? (this.setCursor(this.cursors.dragStart), n.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(s, r) : this.dragCoordinate.startDragging(s, r), void t(!1)) : n && n.feature && n.feature.draggable && this.dragFeature.canDrag(e, s) ? (this.setCursor(this.cursors.dragStart), this.dragFeature.startDragging(e, s), void t(!1)) : void 0;
1995
1995
  }
1996
1996
  onDrag(e, t) {
1997
1997
  const i = this.selected[0];
1998
1998
  if (!i) return;
1999
- const n = this.store.getPropertiesCopy(i), o = this.flags[n.mode], r = (o && o.feature && o.feature.selfIntersectable) === !0;
1999
+ const n = this.store.getPropertiesCopy(i), s = this.flags[n.mode], r = (s && s.feature && s.feature.selfIntersectable) === !0;
2000
2000
  if (this.dragEventCount++, this.dragEventCount % this.dragEventThrottle == 0) return;
2001
2001
  const a = this.validations[n.mode];
2002
- if (o && o.feature && o.feature.rotateable && this.canRotate(e)) return t(!1), void this.rotateFeature.rotate(e, i, a);
2003
- if (o && o.feature && o.feature.scaleable && this.canScale(e)) return t(!1), void this.scaleFeature.scale(e, i, a);
2004
- if (this.dragCoordinateResizeFeature.isDragging() && o.feature && o.feature.coordinates && o.feature.coordinates.resizable) {
2002
+ if (s && s.feature && s.feature.rotateable && this.canRotate(e)) return t(!1), void this.rotateFeature.rotate(e, i, a);
2003
+ if (s && s.feature && s.feature.scaleable && this.canScale(e)) return t(!1), void this.scaleFeature.scale(e, i, a);
2004
+ if (this.dragCoordinateResizeFeature.isDragging() && s.feature && s.feature.coordinates && s.feature.coordinates.resizable) {
2005
2005
  if (this.projection === "globe") throw new Error("Globe is currently unsupported projection for resizable");
2006
- return t(!1), void this.dragCoordinateResizeFeature.drag(e, o.feature.coordinates.resizable, a);
2006
+ return t(!1), void this.dragCoordinateResizeFeature.drag(e, s.feature.coordinates.resizable, a);
2007
2007
  }
2008
2008
  this.dragCoordinate.isDragging() ? this.dragCoordinate.drag(e, r, a) : this.dragFeature.isDragging() ? this.dragFeature.drag(e, a) : t(!0);
2009
2009
  }
@@ -2014,14 +2014,14 @@ class pi extends Rt {
2014
2014
  if (!this.selected.length) return void this.setCursor("unset");
2015
2015
  if (this.dragFeature.isDragging()) return;
2016
2016
  let t = !1;
2017
- this.midPoints.ids.forEach((o) => {
2017
+ this.midPoints.ids.forEach((s) => {
2018
2018
  if (t) return;
2019
- const r = this.store.getGeometryCopy(o);
2019
+ const r = this.store.getGeometryCopy(s);
2020
2020
  this.pixelDistance.measure(e, r.coordinates) < this.pointerDistance && (t = !0);
2021
2021
  });
2022
2022
  let i = !1;
2023
- if (this.selectionPoints.ids.forEach((o) => {
2024
- const r = this.store.getGeometryCopy(o);
2023
+ if (this.selectionPoints.ids.forEach((s) => {
2024
+ const r = this.store.getGeometryCopy(s);
2025
2025
  this.pixelDistance.measure(e, r.coordinates) < this.pointerDistance && (t = !1, i = !0);
2026
2026
  }), t) return void this.setCursor(this.cursors.insertMidpoint);
2027
2027
  const { clickedFeature: n } = this.featuresAtMouseEvent.find(e, !0);
@@ -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 fi extends B {
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,70 +2068,70 @@ 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(o, 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(o, 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
- const o = s[e];
2077
+ const s = o[e];
2078
2078
  let r = t, a = i;
2079
- for (te(s, t, e), n(s[i], o) > 0 && te(s, t, i); r < a; ) {
2080
- for (te(s, r, a), r++, a--; n(s[r], o) < 0; ) r++;
2081
- for (; n(s[a], o) > 0; ) a--;
2079
+ for (te(o, t, e), n(o[i], s) > 0 && te(o, t, i); r < a; ) {
2080
+ for (te(o, r, a), r++, a--; n(o[r], s) < 0; ) r++;
2081
+ for (; n(o[a], s) > 0; ) a--;
2082
2082
  }
2083
- n(s[t], o) === 0 ? te(s, t, a) : (a++, te(s, a, i)), a <= e && (t = a + 1), e <= a && (i = a - 1);
2083
+ n(o[t], s) === 0 ? te(o, t, a) : (a++, te(o, a, i)), a <= e && (t = a + 1), e <= a && (i = a - 1);
2084
2084
  }
2085
2085
  }
2086
- function te(s, e, t) {
2087
- const i = s[e];
2088
- s[e] = s[t], s[t] = i;
2086
+ function te(o, e, t) {
2087
+ const i = o[e];
2088
+ o[e] = o[t], o[t] = i;
2089
2089
  }
2090
- function q(s, e) {
2091
- ne(s, 0, s.children.length, e, s);
2090
+ function q(o, e) {
2091
+ ne(o, 0, o.children.length, e, o);
2092
2092
  }
2093
- function ne(s, e, t, i, n) {
2093
+ function ne(o, e, t, i, n) {
2094
2094
  n || (n = Z([])), n.minX = 1 / 0, n.minY = 1 / 0, n.maxX = -1 / 0, n.maxY = -1 / 0;
2095
- for (let o = e; o < t; o++) {
2096
- const r = s.children[o];
2097
- oe(n, s.leaf ? i(r) : r);
2095
+ for (let s = e; s < t; s++) {
2096
+ const r = o.children[s];
2097
+ se(n, o.leaf ? i(r) : r);
2098
2098
  }
2099
2099
  return n;
2100
2100
  }
2101
- function oe(s, e) {
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;
2101
+ function se(o, e) {
2102
+ return o.minX = Math.min(o.minX, e.minX), o.minY = Math.min(o.minY, e.minY), o.maxX = Math.max(o.maxX, e.maxX), o.maxY = Math.max(o.maxY, e.maxY), o;
2103
2103
  }
2104
- function yi(s, e) {
2105
- return s.minX - e.minX;
2104
+ function yi(o, e) {
2105
+ return o.minX - e.minX;
2106
2106
  }
2107
- function mi(s, e) {
2108
- return s.minY - e.minY;
2107
+ function mi(o, e) {
2108
+ return o.minY - e.minY;
2109
2109
  }
2110
- function Ie(s) {
2111
- return (s.maxX - s.minX) * (s.maxY - s.minY);
2110
+ function Ie(o) {
2111
+ return (o.maxX - o.minX) * (o.maxY - o.minY);
2112
2112
  }
2113
- function ge(s) {
2114
- return s.maxX - s.minX + (s.maxY - s.minY);
2113
+ function pe(o) {
2114
+ return o.maxX - o.minX + (o.maxY - o.minY);
2115
2115
  }
2116
- function Ci(s, e) {
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
- return Math.max(0, n - t) * Math.max(0, o - i);
2116
+ function Ci(o, e) {
2117
+ const t = Math.max(o.minX, e.minX), i = Math.max(o.minY, e.minY), n = Math.min(o.maxX, e.maxX), s = Math.min(o.maxY, e.maxY);
2118
+ return Math.max(0, n - t) * Math.max(0, s - i);
2119
2119
  }
2120
- function Fe(s, e) {
2121
- return s.minX <= e.minX && s.minY <= e.minY && e.maxX <= s.maxX && e.maxY <= s.maxY;
2120
+ function Ee(o, e) {
2121
+ return o.minX <= e.minX && o.minY <= e.minY && e.maxX <= o.maxX && e.maxY <= o.maxY;
2122
2122
  }
2123
- function pe(s, e) {
2124
- return e.minX <= s.maxX && e.minY <= s.maxY && e.maxX >= s.minX && e.maxY >= s.minY;
2123
+ function ge(o, e) {
2124
+ return e.minX <= o.maxX && e.minY <= o.maxY && e.maxX >= o.minX && e.maxY >= o.minY;
2125
2125
  }
2126
- function Z(s) {
2127
- return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
2126
+ function Z(o) {
2127
+ return { children: o, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
2128
2128
  }
2129
- function ot(s, e, t, i, n) {
2130
- const o = [e, t];
2131
- for (; o.length; ) {
2132
- if ((t = o.pop()) - (e = o.pop()) <= i) continue;
2129
+ function st(o, e, t, i, n) {
2130
+ const s = [e, t];
2131
+ for (; s.length; ) {
2132
+ if ((t = s.pop()) - (e = s.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(o, r, e, t, n), s.push(e, r, r, t);
2135
2135
  }
2136
2136
  }
2137
2137
  class Pi {
@@ -2141,27 +2141,27 @@ class Pi {
2141
2141
  search(e) {
2142
2142
  let t = this.data;
2143
2143
  const i = [];
2144
- if (!pe(e, t)) return i;
2145
- const n = this.toBBox, o = [];
2144
+ if (!ge(e, t)) return i;
2145
+ const n = this.toBBox, s = [];
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
+ ge(e, l) && (t.leaf ? i.push(a) : Ee(e, l) ? this._all(a, i) : s.push(a));
2150
2150
  }
2151
- t = o.pop();
2151
+ t = s.pop();
2152
2152
  }
2153
2153
  return i;
2154
2154
  }
2155
2155
  collides(e) {
2156
2156
  let t = this.data;
2157
- if (pe(e, t)) {
2157
+ if (ge(e, t)) {
2158
2158
  const i = [];
2159
2159
  for (; t; ) {
2160
2160
  for (let n = 0; n < t.children.length; n++) {
2161
- const o = t.children[n], r = t.leaf ? this.toBBox(o) : o;
2162
- if (pe(e, r)) {
2163
- if (t.leaf || Fe(e, r)) return !0;
2164
- i.push(o);
2161
+ const s = t.children[n], r = t.leaf ? this.toBBox(s) : s;
2162
+ if (ge(e, r)) {
2163
+ if (t.leaf || Ee(e, r)) return !0;
2164
+ i.push(s);
2165
2165
  }
2166
2166
  }
2167
2167
  t = i.pop();
@@ -2193,14 +2193,14 @@ class Pi {
2193
2193
  }
2194
2194
  remove(e) {
2195
2195
  let t = this.data;
2196
- const i = this.toBBox(e), n = [], o = [];
2196
+ const i = this.toBBox(e), n = [], s = [];
2197
2197
  let r, a, l = !1;
2198
2198
  for (; t || n.length; ) {
2199
- if (t || (t = n.pop(), a = n[n.length - 1], r = o.pop(), l = !0), t.leaf) {
2199
+ if (t || (t = n.pop(), a = n[n.length - 1], r = s.pop(), l = !0), t.leaf) {
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), s.push(r), r = 0, a = t, t = t.children[0]);
2204
2204
  }
2205
2205
  }
2206
2206
  toBBox(e) {
@@ -2218,18 +2218,18 @@ class Pi {
2218
2218
  return t;
2219
2219
  }
2220
2220
  _build(e, t, i, n) {
2221
- const o = i - t + 1;
2221
+ const s = i - t + 1;
2222
2222
  let r, a = this._maxEntries;
2223
- if (o <= a) return r = Z(e.slice(t, i + 1)), q(r, this.toBBox), r;
2224
- n || (n = Math.ceil(Math.log(o) / Math.log(a)), a = Math.ceil(o / Math.pow(a, n - 1))), r = Z([]), r.leaf = !1, r.height = n;
2225
- const l = Math.ceil(o / a), d = l * Math.ceil(Math.sqrt(a));
2226
- ot(e, t, i, d, this.compareMinX);
2223
+ if (s <= a) return r = Z(e.slice(t, i + 1)), q(r, this.toBBox), r;
2224
+ n || (n = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, n - 1))), r = Z([]), r.leaf = !1, r.height = n;
2225
+ const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
2226
+ st(e, t, i, d, this.compareMinX);
2227
2227
  for (let c = t; c <= i; c += d) {
2228
2228
  const h = Math.min(c + d - 1, i);
2229
- ot(e, c, h, l, this.compareMinY);
2229
+ st(e, c, h, l, this.compareMinY);
2230
2230
  for (let u = c; u <= h; u += l) {
2231
- const g = Math.min(u + l - 1, h);
2232
- r.children.push(this._build(e, u, g, n - 1));
2231
+ const p = Math.min(u + l - 1, h);
2232
+ r.children.push(this._build(e, u, p, n - 1));
2233
2233
  }
2234
2234
  }
2235
2235
  return q(r, this.toBBox), r;
@@ -2238,56 +2238,56 @@ class Pi {
2238
2238
  for (; n.push(t), !t.leaf && n.length - 1 !== i; ) {
2239
2239
  let a, l = 1 / 0, d = 1 / 0;
2240
2240
  for (let c = 0; c < t.children.length; c++) {
2241
- const h = t.children[c], u = Ie(h), g = (o = e, r = h, (Math.max(r.maxX, o.maxX) - Math.min(r.minX, o.minX)) * (Math.max(r.maxY, o.maxY) - Math.min(r.minY, o.minY)) - u);
2242
- g < d ? (d = g, l = u < l ? u : l, a = h) : g === d && u < l && (l = u, a = h);
2241
+ const h = t.children[c], u = Ie(h), p = (s = e, r = h, (Math.max(r.maxX, s.maxX) - Math.min(r.minX, s.minX)) * (Math.max(r.maxY, s.maxY) - Math.min(r.minY, s.minY)) - u);
2242
+ p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
2243
2243
  }
2244
2244
  t = a || t.children[0];
2245
2245
  }
2246
- var o, r;
2246
+ var s, r;
2247
2247
  return t;
2248
2248
  }
2249
2249
  _insert(e, t, i) {
2250
- const n = i ? e : this.toBBox(e), o = [], r = this._chooseSubtree(n, this.data, t, o);
2251
- for (r.children.push(e), oe(r, n); t >= 0 && o[t].children.length > this._maxEntries; ) this._split(o, t), t--;
2252
- this._adjustParentBBoxes(n, o, t);
2250
+ const n = i ? e : this.toBBox(e), s = [], r = this._chooseSubtree(n, this.data, t, s);
2251
+ for (r.children.push(e), se(r, n); t >= 0 && s[t].children.length > this._maxEntries; ) this._split(s, t), t--;
2252
+ this._adjustParentBBoxes(n, s, t);
2253
2253
  }
2254
2254
  _split(e, t) {
2255
- const i = e[t], n = i.children.length, o = this._minEntries;
2256
- this._chooseSplitAxis(i, o, n);
2257
- const r = this._chooseSplitIndex(i, o, n), a = Z(i.children.splice(r, i.children.length - r));
2255
+ const i = e[t], n = i.children.length, s = this._minEntries;
2256
+ this._chooseSplitAxis(i, s, n);
2257
+ const r = this._chooseSplitIndex(i, s, n), a = Z(i.children.splice(r, i.children.length - r));
2258
2258
  a.height = i.height, a.leaf = i.leaf, q(i, this.toBBox), q(a, this.toBBox), t ? e[t - 1].children.push(a) : this._splitRoot(i, a);
2259
2259
  }
2260
2260
  _splitRoot(e, t) {
2261
2261
  this.data = Z([e, t]), this.data.height = e.height + 1, this.data.leaf = !1, q(this.data, this.toBBox);
2262
2262
  }
2263
2263
  _chooseSplitIndex(e, t, i) {
2264
- let n, o = 1 / 0, r = 1 / 0;
2264
+ let n, s = 1 / 0, r = 1 / 0;
2265
2265
  for (let a = t; a <= i - t; a++) {
2266
2266
  const l = ne(e, 0, a, this.toBBox), d = ne(e, a, i, this.toBBox), c = Ci(l, d), h = Ie(l) + Ie(d);
2267
- c < o ? (o = c, n = a, r = h < r ? h : r) : c === o && h < r && (r = h, n = a);
2267
+ c < s ? (s = c, n = a, r = h < r ? h : r) : c === s && h < r && (r = h, n = a);
2268
2268
  }
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;
2273
- this._allDistMargin(e, t, i, n) < this._allDistMargin(e, t, i, o) && e.children.sort(n);
2272
+ const n = e.leaf ? this.compareMinX : yi, s = e.leaf ? this.compareMinY : mi;
2273
+ this._allDistMargin(e, t, i, n) < this._allDistMargin(e, t, i, s) && e.children.sort(n);
2274
2274
  }
2275
2275
  _allDistMargin(e, t, i, n) {
2276
2276
  e.children.sort(n);
2277
- const o = this.toBBox, r = ne(e, 0, t, o), a = ne(e, i - t, i, o);
2278
- let l = ge(r) + ge(a);
2277
+ const s = this.toBBox, r = ne(e, 0, t, s), a = ne(e, i - t, i, s);
2278
+ let l = pe(r) + pe(a);
2279
2279
  for (let d = t; d < i - t; d++) {
2280
2280
  const c = e.children[d];
2281
- oe(r, e.leaf ? o(c) : c), l += ge(r);
2281
+ se(r, e.leaf ? s(c) : c), l += pe(r);
2282
2282
  }
2283
2283
  for (let d = i - t - 1; d >= t; d--) {
2284
2284
  const c = e.children[d];
2285
- oe(a, e.leaf ? o(c) : c), l += ge(a);
2285
+ se(a, e.leaf ? s(c) : c), l += pe(a);
2286
2286
  }
2287
2287
  return l;
2288
2288
  }
2289
2289
  _adjustParentBBoxes(e, t, i) {
2290
- for (let n = i; n >= 0; n--) oe(t[n], e);
2290
+ for (let n = i; n >= 0; n--) se(t[n], e);
2291
2291
  }
2292
2292
  _condense(e) {
2293
2293
  for (let t, i = e.length - 1; i >= 0; i--) e[i].children.length === 0 ? i > 0 ? (t = e[i - 1].children, t.splice(t.indexOf(e[i]), 1)) : this.clear() : q(e[i], this.toBBox);
@@ -2310,8 +2310,8 @@ class vi {
2310
2310
  n = [e.geometry.coordinates];
2311
2311
  }
2312
2312
  for (let a = 0; a < n.length; a++) i.push(n[a][1]), t.push(n[a][0]);
2313
- const o = Math.min(...i), r = Math.max(...i);
2314
- return { minX: Math.min(...t), minY: o, maxX: Math.max(...t), maxY: r };
2313
+ const s = Math.min(...i), r = Math.max(...i);
2314
+ return { minX: Math.min(...t), minY: s, maxX: Math.max(...t), maxY: r };
2315
2315
  }
2316
2316
  insert(e) {
2317
2317
  if (this.idToNode.get(String(e.id))) throw new Error("Feature already exists");
@@ -2321,9 +2321,9 @@ class vi {
2321
2321
  load(e) {
2322
2322
  const t = [], i = /* @__PURE__ */ new Set();
2323
2323
  e.forEach((n) => {
2324
- const o = this.toBBox(n);
2325
- if (this.setMaps(n, o), i.has(String(n.id))) throw new Error(`Duplicate feature ID found ${n.id}`);
2326
- i.add(String(n.id)), t.push(o);
2324
+ const s = this.toBBox(n);
2325
+ if (this.setMaps(n, s), i.has(String(n.id))) throw new Error(`Duplicate feature ID found ${n.id}`);
2326
+ i.add(String(n.id)), t.push(s);
2327
2327
  }), this.tree.load(t);
2328
2328
  }
2329
2329
  update(e) {
@@ -2346,10 +2346,10 @@ class vi {
2346
2346
  return this.tree.collides(this.toBBox(e));
2347
2347
  }
2348
2348
  }
2349
- const xi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
2349
+ const xi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(o) {
2350
2350
  const e = 16 * Math.random() | 0;
2351
- return (s == "x" ? e : 3 & e | 8).toString(16);
2352
- }), isValidId: (s) => typeof s == "string" && s.length === 36 };
2351
+ return (o == "x" ? e : 3 & e | 8).toString(16);
2352
+ }), isValidId: (o) => typeof o == "string" && o.length === 36 };
2353
2353
  class Si {
2354
2354
  constructor(e) {
2355
2355
  this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
@@ -2367,24 +2367,24 @@ class Si {
2367
2367
  load(e, t) {
2368
2368
  if (e.length === 0) return [];
2369
2369
  let i = this.clone(e);
2370
- const n = [], o = [];
2370
+ const n = [], s = [];
2371
2371
  return i = i.filter((r) => {
2372
2372
  r.id == null && (r.id = this.idStrategy.getId());
2373
2373
  const a = r.id;
2374
2374
  if (t) {
2375
2375
  const l = t(r);
2376
- if (!l.valid) return o.push({ id: a, valid: !1, reason: l.reason }), !1;
2376
+ if (!l.valid) return s.push({ id: a, valid: !1, reason: l.reason }), !1;
2377
2377
  }
2378
2378
  if (this.tracked) {
2379
2379
  if (r.properties.createdAt) {
2380
- if (!He(r.properties.createdAt)) return o.push({ id: r.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2380
+ if (!He(r.properties.createdAt)) return s.push({ id: r.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2381
2381
  } else r.properties.createdAt = +/* @__PURE__ */ new Date();
2382
2382
  if (r.properties.updatedAt) {
2383
- if (!He(r.properties.updatedAt)) return o.push({ id: r.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2383
+ if (!He(r.properties.updatedAt)) return s.push({ id: r.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2384
2384
  } else r.properties.updatedAt = +/* @__PURE__ */ new Date();
2385
2385
  }
2386
- return this.has(a) ? (o.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = r, n.push(a), o.push({ id: a, valid: !0 }), !0);
2387
- }), this.spatialIndex.load(i), this._onChange(n, "create"), o;
2386
+ return this.has(a) ? (s.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = r, n.push(a), s.push({ id: a, valid: !0 }), !0);
2387
+ }), this.spatialIndex.load(i), this._onChange(n, "create"), s;
2388
2388
  }
2389
2389
  search(e, t) {
2390
2390
  const i = this.spatialIndex.search(e).map((n) => this.store[n]);
@@ -2407,26 +2407,26 @@ class Si {
2407
2407
  }
2408
2408
  updateProperty(e) {
2409
2409
  const t = [];
2410
- e.forEach(({ id: i, property: n, value: o }) => {
2410
+ e.forEach(({ id: i, property: n, value: s }) => {
2411
2411
  const r = this.store[i];
2412
2412
  if (!r) throw new Error(`No feature with this (${i}), can not update geometry`);
2413
- t.push(i), r.properties[n] = o, this.tracked && (r.properties.updatedAt = +/* @__PURE__ */ new Date());
2413
+ t.push(i), r.properties[n] = s, this.tracked && (r.properties.updatedAt = +/* @__PURE__ */ new Date());
2414
2414
  }), this._onChange && this._onChange(t, "update");
2415
2415
  }
2416
2416
  updateGeometry(e) {
2417
2417
  const t = [];
2418
2418
  e.forEach(({ id: i, geometry: n }) => {
2419
2419
  t.push(i);
2420
- const o = this.store[i];
2421
- if (!o) throw new Error(`No feature with this (${i}), can not update geometry`);
2422
- o.geometry = this.clone(n), this.spatialIndex.update(o), this.tracked && (o.properties.updatedAt = +/* @__PURE__ */ new Date());
2420
+ const s = this.store[i];
2421
+ if (!s) throw new Error(`No feature with this (${i}), can not update geometry`);
2422
+ s.geometry = this.clone(n), this.spatialIndex.update(s), this.tracked && (s.properties.updatedAt = +/* @__PURE__ */ new Date());
2423
2423
  }), this._onChange && this._onChange(t, "update");
2424
2424
  }
2425
2425
  create(e) {
2426
2426
  const t = [];
2427
2427
  return e.forEach(({ geometry: i, properties: n }) => {
2428
- let o, r = M({}, n);
2429
- this.tracked && (o = +/* @__PURE__ */ new Date(), n ? (r.createdAt = typeof n.createdAt == "number" ? n.createdAt : o, r.updatedAt = typeof n.updatedAt == "number" ? n.updatedAt : o) : r = { createdAt: o, updatedAt: o });
2428
+ let s, r = M({}, n);
2429
+ this.tracked && (s = +/* @__PURE__ */ new Date(), n ? (r.createdAt = typeof n.createdAt == "number" ? n.createdAt : s, r.updatedAt = typeof n.updatedAt == "number" ? n.updatedAt : s) : r = { createdAt: s, updatedAt: s });
2430
2430
  const a = this.getId(), l = { id: a, type: "Feature", geometry: i, properties: r };
2431
2431
  this.store[a] = l, this.spatialIndex.insert(l), t.push(a);
2432
2432
  }), this._onChange && this._onChange([...t], "create"), t;
@@ -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 };
2451
- function st(s, e, t) {
2452
- const i = A(s, e);
2453
- let n = A(e, t) - i;
2450
+ const Mi = "Feature is not a Polygon or LineString", wi = "Feature intersects itself", bi = (o) => o.geometry.type !== "Polygon" && o.geometry.type !== "LineString" ? { valid: !1, reason: Mi } : Le(o) ? { valid: !1, reason: wi } : { valid: !0 };
2451
+ function ot(o, e, t) {
2452
+ const i = G(o, 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 B {
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" };
@@ -2479,13 +2479,13 @@ class Et extends N {
2479
2479
  const t = this.store.getGeometryCopy(this.currentId).coordinates[0];
2480
2480
  let i;
2481
2481
  if (this.currentCoordinate === 1) {
2482
- const n = 1 / Math.pow(10, this.coordinatePrecision - 1), o = Math.max(1e-6, n);
2483
- i = [t[0], [e.lng, e.lat], [e.lng, e.lat - o], t[0]];
2482
+ const n = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, n);
2483
+ i = [t[0], [e.lng, e.lat], [e.lng, e.lat - s], 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], s = t[1], r = Mt(n, s, this.coordinatePrecision, this.project, this.unproject), a = S(n[0], n[1]), l = S(r[0], r[1]), d = S(s[0], s[1]), c = S(e.lng, e.lat), h = F(c, a) < F(c, d), u = ot(a, l, c), p = h ? 90 - u : ot(a, l, c) - 90, g = F(l, c), f = Math.cos(D(p)) * g, P = G(a, d) + (function(x, w, I) {
2486
+ const O = (I.x - w.x) * (x.y - w.y) - (I.y - w.y) * (x.x - w.x);
2487
+ return O > 1e-10 ? "left" : O < -1e-10 ? "right" : "left";
2488
+ }(a, d, c) === "right" ? -90 : 90), y = le(a, f, P), C = le(d, f, P), m = k(y.x, y.y), v = k(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) {
2534
- return (e.x - s.x) * (t.y - s.y) - (e.y - s.y) * (t.x - s.x) <= 0;
2533
+ function Dt(o, e, t) {
2534
+ return (e.x - o.x) * (t.y - o.y) - (e.y - o.y) * (t.x - o.x) <= 0;
2535
2535
  }
2536
- class Dt extends N {
2536
+ class Ot extends B {
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" };
@@ -2560,24 +2560,24 @@ class Dt extends N {
2560
2560
  const t = this.store.getGeometryCopy(this.currentId).coordinates[0];
2561
2561
  let i;
2562
2562
  if (this.currentCoordinate === 1) {
2563
- const n = 1 / Math.pow(10, this.coordinatePrecision - 1), o = Math.max(1e-6, n);
2564
- i = [t[0], [e.lng, e.lat], [e.lng, e.lat - o], t[0]];
2563
+ const n = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, n);
2564
+ i = [t[0], [e.lng, e.lat], [e.lng, e.lat - s], t[0]];
2565
2565
  } else if (this.currentCoordinate === 2) {
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]);
2566
+ const n = t[0], s = t[1], r = [e.lng, e.lat], a = S(n[0], n[1]), l = S(s[0], s[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);
2571
+ const c = F(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [n], f = z(h), P = z(u);
2572
2572
  let y;
2573
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;
2575
- p.push(o);
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)];
2578
- I[0] !== p[p.length - 1][0] && I[1] !== p[p.length - 1][1] && p.push(I);
2574
+ const C = (this.direction === "anticlockwise" ? 1 : -1) * y / p;
2575
+ g.push(s);
2576
+ for (let m = 0; m <= p; m++) {
2577
+ const v = le(a, c, f + m * C), { lng: x, lat: w } = k(v.x, v.y), I = [E(x, this.coordinatePrecision), E(w, this.coordinatePrecision)];
2578
+ I[0] !== g[g.length - 1][0] && I[1] !== g[g.length - 1][1] && g.push(I);
2579
2579
  }
2580
- p.push(n), i = [...p];
2580
+ g.push(n), i = [...g];
2581
2581
  }
2582
2582
  i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
2583
2583
  }
@@ -2621,7 +2621,7 @@ class Dt extends N {
2621
2621
  return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
2622
2622
  }
2623
2623
  }
2624
- class Ot extends N {
2624
+ class _t extends B {
2625
2625
  constructor(e) {
2626
2626
  super(e), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
2627
2627
  const t = { start: "crosshair", close: "pointer" };
@@ -2646,29 +2646,29 @@ 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], s = [e.lng, e.lat], r = S(n[0], n[1]), a = S(s[0], s[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, p = [n], g = z(c), f = z(h);
2655
2655
  let P;
2656
- this.direction === "anticlockwise" ? (P = f - p, P < 0 && (P += 360)) : (P = p - f, P < 0 && (P += 360));
2656
+ this.direction === "anticlockwise" ? (P = f - g, P < 0 && (P += 360)) : (P = g - f, P < 0 && (P += 360));
2657
2657
  const y = (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)];
2660
- w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
2659
+ const m = le(l, d, g + C * y), { lng: v, lat: x } = k(m.x, m.y), w = [E(v, this.coordinatePrecision), E(x, this.coordinatePrecision)];
2660
+ w[0] !== p[p.length - 1][0] && w[1] !== p[p.length - 1][1] && p.push(w);
2661
2661
  }
2662
- this.updateLineStringGeometry(this.currentInitialArcId, g, b.Provisional);
2662
+ this.updateLineStringGeometry(this.currentInitialArcId, p, 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);
2666
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], s = t[t.length - 1], r = S(e.lng, e.lat), a = S(n[0], n[1]), l = S(s[0], s[1]), d = S(i[0], i[1]), c = F(d, a), h = F(d, r) < c ? a : r, u = G(d, r), p = G(d, a), g = G(d, l), f = z(p), P = z(g), y = z(u);
2667
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 = [];
2668
+ const C = this.getDeltaBearing(this.direction, f, 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)];
2671
- B[0] !== t[t.length - 1][0] && B[1] !== t[t.length - 1][1] && w.unshift(B);
2670
+ const O = le(d, x, f + I * v), { lng: N, lat: _ } = k(O.x, O.y), j = [E(N, this.coordinatePrecision), E(_, this.coordinatePrecision)];
2671
+ j[0] !== t[t.length - 1][0] && j[1] !== t[t.length - 1][1] && w.unshift(j);
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 } }]);
2674
2674
  }
@@ -2733,13 +2733,13 @@ class Ii {
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
  }
2740
2740
  }), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Si({ tracked: !!e.tracked, idStrategy: e.idStrategy ? e.idStrategy : void 0 });
2741
- const o = (c) => {
2742
- const h = [], u = this._store.copyAll().filter((g) => !c.includes(g.id) || (h.push(g), !1));
2741
+ const s = (c) => {
2742
+ const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
2743
2743
  return { changed: h, unchanged: u };
2744
2744
  }, r = (c, h) => {
2745
2745
  this._enabled && this._eventListeners.finish.forEach((u) => {
@@ -2747,24 +2747,24 @@ class Ii {
2747
2747
  });
2748
2748
  }, a = (c, h) => {
2749
2749
  if (!this._enabled) return;
2750
- this._eventListeners.change.forEach((p) => {
2751
- p(c, h);
2750
+ this._eventListeners.change.forEach((g) => {
2751
+ g(c, h);
2752
2752
  });
2753
- const { changed: u, unchanged: g } = o(c);
2754
- h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: g, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: g, updated: [] }, this.getModeStyles());
2753
+ const { changed: u, unchanged: p } = s(c);
2754
+ h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: p, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
2755
2755
  }, l = (c) => {
2756
2756
  if (!this._enabled) return;
2757
- this._eventListeners.select.forEach((g) => {
2758
- g(c);
2757
+ this._eventListeners.select.forEach((p) => {
2758
+ p(c);
2759
2759
  });
2760
- const { changed: h, unchanged: u } = o([c]);
2760
+ const { changed: h, unchanged: u } = s([c]);
2761
2761
  this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2762
2762
  }, d = (c) => {
2763
2763
  if (!this._enabled) return;
2764
- this._eventListeners.deselect.forEach((g) => {
2765
- g();
2764
+ this._eventListeners.deselect.forEach((p) => {
2765
+ p();
2766
2766
  });
2767
- const { changed: h, unchanged: u } = o([c]);
2767
+ const { changed: h, unchanged: u } = s([c]);
2768
2768
  h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2769
2769
  };
2770
2770
  Object.keys(this._modes).forEach((c) => {
@@ -2777,22 +2777,22 @@ 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, s = !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 });
2785
2785
  return this._store.search(d).filter((c) => {
2786
- if (o && (c.properties[se] || c.properties.selectionPoint)) return !1;
2786
+ if (s && (c.properties[oe] || 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;
2793
2793
  for (let u = 0; u < h.length - 1; u++) {
2794
- const g = h[u], p = h[u + 1];
2795
- if (bt(l, a(g[0], g[1]), a(p[0], p[1])) < n) return !0;
2794
+ const p = h[u], g = h[u + 1];
2795
+ if (bt(l, a(p[0], p[1]), a(g[0], g[1])) < n) return !0;
2796
2796
  }
2797
2797
  return !1;
2798
2798
  }
@@ -2848,8 +2848,8 @@ class Ii {
2848
2848
  }(t)) {
2849
2849
  const i = t.properties.mode, n = this._modes[i];
2850
2850
  if (!n) return { id: t.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
2851
- const o = n.validateFeature.bind(n)(t);
2852
- return { id: t.id, valid: o.valid, reason: o.reason ? o.reason : o.valid ? void 0 : "Feature is invalid" };
2851
+ const s = n.validateFeature.bind(n)(t);
2852
+ return { id: t.id, valid: s.valid, reason: s.reason ? s.reason : s.valid ? void 0 : "Feature is invalid" };
2853
2853
  }
2854
2854
  return { id: t.id, valid: !1, reason: "Mode property does not exist" };
2855
2855
  });
@@ -2897,7 +2897,7 @@ class Ii {
2897
2897
  i.includes(t) && i.splice(i.indexOf(t), 1);
2898
2898
  }
2899
2899
  }
2900
- const Ri = [
2900
+ const Xi = [
2901
2901
  "render",
2902
2902
  "point",
2903
2903
  "linestring",
@@ -2912,7 +2912,7 @@ const Ri = [
2912
2912
  "delete-selection",
2913
2913
  "delete",
2914
2914
  "download"
2915
- ], Xi = [
2915
+ ], zi = [
2916
2916
  "render",
2917
2917
  "linestring",
2918
2918
  "polygon",
@@ -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
- circle: new pt({
3004
+ circle: new gt({
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
3012
  freehand: new ft({
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
- sensor: new Ot({
3024
+ sensor: new _t({
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 Ot({
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,40 @@ 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
- }
3112
- }, _i = () => ({
3143
+ },
3144
+ computeElevation: !1,
3145
+ distanceUnit: "kilometers",
3146
+ distancePrecision: 2,
3147
+ areaUnit: "metric",
3148
+ areaPrecision: 2
3149
+ }, Di = () => ({
3113
3150
  render: new ie({
3114
3151
  modeName: "render",
3115
3152
  styles: {}
@@ -3125,12 +3162,12 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3125
3162
  }
3126
3163
  }),
3127
3164
  rectangle: new St(),
3128
- "angled-rectangle": new Et(),
3129
- circle: new pt(),
3165
+ "angled-rectangle": new Ft(),
3166
+ circle: new gt(),
3130
3167
  freehand: new ft(),
3131
- sensor: new Ot(),
3132
- sector: new Dt(),
3133
- select: new pi({
3168
+ sensor: new _t(),
3169
+ sector: new Ot(),
3170
+ select: new gi({
3134
3171
  flags: {
3135
3172
  point: {
3136
3173
  feature: {
@@ -3244,20 +3281,20 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3244
3281
  styles: {}
3245
3282
  })
3246
3283
  });
3247
- class Di {
3284
+ class Oi {
3248
3285
  /**
3249
3286
  * Constructor
3250
3287
  * @param options Plugin control options
3251
3288
  */
3252
3289
  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");
3290
+ A(this, "controlContainer");
3291
+ A(this, "map");
3292
+ A(this, "modeButtons", {});
3293
+ A(this, "isExpanded", !1);
3294
+ A(this, "terradraw");
3295
+ A(this, "options", Ei);
3296
+ A(this, "events", {});
3297
+ A(this, "defaultMode", "render");
3261
3298
  this.modeButtons = {}, e && (this.options = Object.assign(this.options, e));
3262
3299
  }
3263
3300
  /**
@@ -3273,20 +3310,20 @@ class Di {
3273
3310
  * @returns HTML Element
3274
3311
  */
3275
3312
  onAdd(e) {
3276
- var n, o, r, a, l;
3313
+ var n, s, r, a, l;
3277
3314
  if (this.options && this.options.modes && this.options.modes.length === 0)
3278
3315
  throw new Error("At least a mode must be enabled.");
3279
3316
  this.map = e;
3280
- const t = _i(), i = [];
3281
- return (o = (n = this.options) == null ? void 0 : n.modes) == null || o.forEach((d) => {
3317
+ const t = Di(), i = [];
3318
+ return (s = (n = this.options) == null ? void 0 : n.modes) == null || s.forEach((d) => {
3282
3319
  if (this.options.modeOptions && this.options.modeOptions[d]) {
3283
3320
  const c = this.options.modeOptions[d];
3284
3321
  if (d === "select") {
3285
3322
  const h = t[d];
3286
3323
  if (h) {
3287
3324
  const u = h.flags;
3288
- Object.keys(u).forEach((g) => {
3289
- c.flags[g] || (c.flags[g] = u[g]);
3325
+ Object.keys(u).forEach((p) => {
3326
+ c.flags[p] || (c.flags[p] = u[p]);
3290
3327
  });
3291
3328
  }
3292
3329
  }
@@ -3341,8 +3378,8 @@ class Di {
3341
3378
  */
3342
3379
  dispatchEvent(e) {
3343
3380
  this.events[e] && this.events[e].forEach((t) => {
3344
- var o, r;
3345
- const i = (o = this.terradraw) == null ? void 0 : o.getSnapshot(), n = i == null ? void 0 : i.filter((a) => a.properties.selected === !0);
3381
+ var s, r;
3382
+ const i = (s = this.terradraw) == null ? void 0 : s.getSnapshot(), n = i == null ? void 0 : i.filter((a) => a.properties.selected === !0);
3346
3383
  t({ feature: n, mode: (r = this.terradraw) == null ? void 0 : r.getMode() });
3347
3384
  });
3348
3385
  }
@@ -3373,8 +3410,8 @@ class Di {
3373
3410
  var i, n;
3374
3411
  if (!this.terradraw) return;
3375
3412
  const e = document.getElementsByClassName("maplibregl-terradraw-add-control");
3376
- for (let o = 0; o < e.length; o++) {
3377
- const r = e.item(o);
3413
+ for (let s = 0; s < e.length; s++) {
3414
+ const r = e.item(s);
3378
3415
  r && (this.isExpanded ? r.classList.add("hidden") : r.classList.remove("hidden"));
3379
3416
  }
3380
3417
  const t = document.getElementsByClassName("maplibregl-terradraw-render-button");
@@ -3403,9 +3440,9 @@ class Di {
3403
3440
  t.type = "button", this.modeButtons[e] = t, e === "render" ? (t.classList.add(`maplibregl-terradraw-${e}-button`), this.isExpanded && t.classList.add("enabled"), t.type = "button", t.title = this.capitalize("expand or collapse drawing tool"), t.addEventListener("click", this.toggleEditor.bind(this))) : (t.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || t.classList.add("hidden"), t.title = this.capitalize(e.replace(/-/g, " ")), e === "delete" ? (t.classList.add(`maplibregl-terradraw-${e}-button`), t.addEventListener("click", () => {
3404
3441
  this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
3405
3442
  })) : e === "delete-selection" ? (t.classList.add(`maplibregl-terradraw-${e}-button`), t.classList.add("hidden-delete-selection"), t.addEventListener("click", () => {
3406
- var o;
3443
+ var s;
3407
3444
  if (!this.terradraw || !this.terradraw.enabled) return;
3408
- const n = ((o = this.terradraw) == null ? void 0 : o.getSnapshot()).filter((r) => r.properties.selected === !0);
3445
+ const n = ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((r) => r.properties.selected === !0);
3409
3446
  if (n.length > 0) {
3410
3447
  const r = this.terradraw.getMode();
3411
3448
  this.terradraw.setMode(this.defaultMode);
@@ -3425,11 +3462,11 @@ class Di {
3425
3462
  * @returns FeatureCollection in GeoJSON format
3426
3463
  */
3427
3464
  getFeatures(e = !1) {
3428
- var o;
3465
+ var s;
3429
3466
  if (!this.terradraw) return;
3430
3467
  const n = {
3431
3468
  type: "FeatureCollection",
3432
- features: ((o = this.terradraw) == null ? void 0 : o.getSnapshot()).filter((r) => r.properties.mode !== "select")
3469
+ features: ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((r) => r.properties.mode !== "select")
3433
3470
  };
3434
3471
  return e !== !0 || (n.features = n.features.filter((r) => r.properties.selected === !0)), n;
3435
3472
  }
@@ -3451,9 +3488,9 @@ class Di {
3451
3488
  "maplibregl-terradraw-delete-button"
3452
3489
  ];
3453
3490
  for (const n of i) {
3454
- const o = this.controlContainer.getElementsByClassName(n);
3455
- for (let r = 0; r < o.length; r++) {
3456
- const a = o.item(r);
3491
+ const s = this.controlContainer.getElementsByClassName(n);
3492
+ for (let r = 0; r < s.length; r++) {
3493
+ const a = s.item(r);
3457
3494
  a && (a.disabled = !t);
3458
3495
  }
3459
3496
  }
@@ -3463,10 +3500,10 @@ class Di {
3463
3500
  */
3464
3501
  toggleDeleteSelectionButton() {
3465
3502
  var a, l;
3466
- const e = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, t = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), n = i && i.features.length > 0, o = n && e && t === "select", r = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
3503
+ const e = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, t = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), n = i && i.features.length > 0, s = n && e && t === "select", r = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
3467
3504
  for (let d = 0; d < r.length; d++) {
3468
3505
  const c = r.item(d);
3469
- c && (o ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
3506
+ c && (s ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
3470
3507
  }
3471
3508
  if (!n) {
3472
3509
  const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
@@ -3485,77 +3522,77 @@ class Di {
3485
3522
  return e.charAt(0).toUpperCase() + e.slice(1);
3486
3523
  }
3487
3524
  }
3488
- var k = 63710088e-1, Oi = {
3489
- centimeters: k * 100,
3490
- centimetres: k * 100,
3525
+ var L = 63710088e-1, _i = {
3526
+ centimeters: L * 100,
3527
+ centimetres: L * 100,
3491
3528
  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,
3529
+ feet: L * 3.28084,
3530
+ inches: L * 39.37,
3531
+ kilometers: L / 1e3,
3532
+ kilometres: L / 1e3,
3533
+ meters: L,
3534
+ metres: L,
3535
+ miles: L / 1609.344,
3536
+ millimeters: L * 1e3,
3537
+ millimetres: L * 1e3,
3538
+ nauticalmiles: L / 1852,
3502
3539
  radians: 1,
3503
- yards: k * 1.0936
3540
+ yards: L * 1.0936
3504
3541
  };
3505
- function ki(s, e, t = {}) {
3542
+ function Li(o, e, t = {}) {
3506
3543
  const i = { type: "Feature" };
3507
- return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = s, i;
3544
+ return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = o, i;
3508
3545
  }
3509
- function Li(s, e, t = {}) {
3510
- if (!s)
3546
+ function ki(o, e, t = {}) {
3547
+ if (!o)
3511
3548
  throw new Error("coordinates is required");
3512
- if (!Array.isArray(s))
3549
+ if (!Array.isArray(o))
3513
3550
  throw new Error("coordinates must be an Array");
3514
- if (s.length < 2)
3551
+ if (o.length < 2)
3515
3552
  throw new Error("coordinates must be at least 2 numbers long");
3516
- if (!rt(s[0]) || !rt(s[1]))
3553
+ if (!rt(o[0]) || !rt(o[1]))
3517
3554
  throw new Error("coordinates must contain numbers");
3518
- return ki({
3555
+ return Li({
3519
3556
  type: "Point",
3520
- coordinates: s
3557
+ coordinates: o
3521
3558
  }, e, t);
3522
3559
  }
3523
- function Wi(s, e = "kilometers") {
3524
- const t = Oi[e];
3560
+ function Wi(o, e = "kilometers") {
3561
+ const t = _i[e];
3525
3562
  if (!t)
3526
3563
  throw new Error(e + " units is invalid");
3527
- return s * t;
3564
+ return o * t;
3528
3565
  }
3529
- function fe(s) {
3530
- return s % 360 * Math.PI / 180;
3566
+ function fe(o) {
3567
+ return o % 360 * Math.PI / 180;
3531
3568
  }
3532
- function rt(s) {
3533
- return !isNaN(s) && s !== null && !Array.isArray(s);
3569
+ function rt(o) {
3570
+ return !isNaN(o) && o !== null && !Array.isArray(o);
3534
3571
  }
3535
- function at(s) {
3536
- if (!s)
3572
+ function at(o) {
3573
+ if (!o)
3537
3574
  throw new Error("coord is required");
3538
- if (!Array.isArray(s)) {
3539
- if (s.type === "Feature" && s.geometry !== null && s.geometry.type === "Point")
3540
- return [...s.geometry.coordinates];
3541
- if (s.type === "Point")
3542
- return [...s.coordinates];
3543
- }
3544
- if (Array.isArray(s) && s.length >= 2 && !Array.isArray(s[0]) && !Array.isArray(s[1]))
3545
- return [...s];
3575
+ if (!Array.isArray(o)) {
3576
+ if (o.type === "Feature" && o.geometry !== null && o.geometry.type === "Point")
3577
+ return [...o.geometry.coordinates];
3578
+ if (o.type === "Point")
3579
+ return [...o.coordinates];
3580
+ }
3581
+ if (Array.isArray(o) && o.length >= 2 && !Array.isArray(o[0]) && !Array.isArray(o[1]))
3582
+ return [...o];
3546
3583
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
3547
3584
  }
3548
- 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);
3585
+ function ji(o, e, t = {}) {
3586
+ var i = at(o), n = at(e), s = fe(n[1] - i[1]), r = fe(n[0] - i[0]), a = fe(i[1]), l = fe(n[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(r / 2), 2) * Math.cos(a) * Math.cos(l);
3550
3587
  return Wi(
3551
3588
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3552
3589
  t.units
3553
3590
  );
3554
3591
  }
3555
- function kt(s, e, t) {
3556
- 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;
3592
+ function Lt(o, e, t) {
3593
+ if (o !== null)
3594
+ for (var i, n, s, r, a, l, d, c = 0, h = 0, u, p = o.type, g = p === "FeatureCollection", f = p === "Feature", P = g ? o.features.length : 1, y = 0; y < P; y++) {
3595
+ d = g ? o.features[y].geometry : f ? o.geometry : o, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
3559
3596
  for (var C = 0; C < a; C++) {
3560
3597
  var m = 0, v = 0;
3561
3598
  if (r = u ? d.geometries[C] : d, r !== null) {
@@ -3611,9 +3648,9 @@ function kt(s, e, t) {
3611
3648
  case "MultiPolygon":
3612
3649
  for (i = 0; i < l.length; i++) {
3613
3650
  for (v = 0, n = 0; n < l[i].length; n++) {
3614
- for (o = 0; o < l[i][n].length - c; o++) {
3651
+ for (s = 0; s < l[i][n].length - c; s++) {
3615
3652
  if (e(
3616
- l[i][n][o],
3653
+ l[i][n][s],
3617
3654
  h,
3618
3655
  y,
3619
3656
  m,
@@ -3629,7 +3666,7 @@ function kt(s, e, t) {
3629
3666
  break;
3630
3667
  case "GeometryCollection":
3631
3668
  for (i = 0; i < r.geometries.length; i++)
3632
- if (kt(r.geometries[i], e) === !1)
3669
+ if (Lt(r.geometries[i], e) === !1)
3633
3670
  return !1;
3634
3671
  break;
3635
3672
  default:
@@ -3639,11 +3676,11 @@ function kt(s, e, t) {
3639
3676
  }
3640
3677
  }
3641
3678
  }
3642
- 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;
3679
+ function Bi(o, e) {
3680
+ var t, i, n, s, r, a, l, d, c, h, u = 0, p = o.type === "FeatureCollection", g = o.type === "Feature", f = p ? o.features.length : 1;
3644
3681
  for (t = 0; t < f; t++) {
3645
- 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
- if (o = l ? a.geometries[n] : a, o === null) {
3682
+ for (a = p ? o.features[t].geometry : g ? o.geometry : o, d = p ? o.features[t].properties : g ? o.properties : {}, c = p ? o.features[t].bbox : g ? o.bbox : void 0, h = p ? o.features[t].id : g ? o.id : void 0, l = a ? a.type === "GeometryCollection" : !1, r = l ? a.geometries.length : 1, n = 0; n < r; n++) {
3683
+ if (s = l ? a.geometries[n] : a, s === null) {
3647
3684
  if (e(
3648
3685
  null,
3649
3686
  u,
@@ -3654,7 +3691,7 @@ function Bi(s, e) {
3654
3691
  return !1;
3655
3692
  continue;
3656
3693
  }
3657
- switch (o.type) {
3694
+ switch (s.type) {
3658
3695
  case "Point":
3659
3696
  case "LineString":
3660
3697
  case "MultiPoint":
@@ -3662,7 +3699,7 @@ function Bi(s, e) {
3662
3699
  case "MultiLineString":
3663
3700
  case "MultiPolygon": {
3664
3701
  if (e(
3665
- o,
3702
+ s,
3666
3703
  u,
3667
3704
  d,
3668
3705
  c,
@@ -3672,9 +3709,9 @@ function Bi(s, e) {
3672
3709
  break;
3673
3710
  }
3674
3711
  case "GeometryCollection": {
3675
- for (i = 0; i < o.geometries.length; i++)
3712
+ for (i = 0; i < s.geometries.length; i++)
3676
3713
  if (e(
3677
- o.geometries[i],
3714
+ s.geometries[i],
3678
3715
  u,
3679
3716
  d,
3680
3717
  c,
@@ -3690,15 +3727,15 @@ function Bi(s, e) {
3690
3727
  u++;
3691
3728
  }
3692
3729
  }
3693
- function Ni(s, e, t) {
3730
+ function Ni(o, e, t) {
3694
3731
  var i = t;
3695
3732
  return Bi(
3696
- s,
3697
- function(n, o, r, a, l) {
3698
- o === 0 && t === void 0 ? i = n : i = e(
3733
+ o,
3734
+ function(n, s, r, a, l) {
3735
+ s === 0 && t === void 0 ? i = n : i = e(
3699
3736
  i,
3700
3737
  n,
3701
- o,
3738
+ s,
3702
3739
  r,
3703
3740
  a,
3704
3741
  l
@@ -3706,21 +3743,21 @@ function Ni(s, e, t) {
3706
3743
  }
3707
3744
  ), i;
3708
3745
  }
3709
- function Gi(s) {
3746
+ function Ai(o) {
3710
3747
  return Ni(
3711
- s,
3712
- (e, t) => e + Ai(t),
3748
+ o,
3749
+ (e, t) => e + Gi(t),
3713
3750
  0
3714
3751
  );
3715
3752
  }
3716
- function Ai(s) {
3753
+ function Gi(o) {
3717
3754
  let e = 0, t;
3718
- switch (s.type) {
3755
+ switch (o.type) {
3719
3756
  case "Polygon":
3720
- return lt(s.coordinates);
3757
+ return lt(o.coordinates);
3721
3758
  case "MultiPolygon":
3722
- for (t = 0; t < s.coordinates.length; t++)
3723
- e += lt(s.coordinates[t]);
3759
+ for (t = 0; t < o.coordinates.length; t++)
3760
+ e += lt(o.coordinates[t]);
3724
3761
  return e;
3725
3762
  case "Point":
3726
3763
  case "MultiPoint":
@@ -3730,63 +3767,103 @@ function Ai(s) {
3730
3767
  }
3731
3768
  return 0;
3732
3769
  }
3733
- function lt(s) {
3770
+ function lt(o) {
3734
3771
  let e = 0;
3735
- if (s && s.length > 0) {
3736
- e += Math.abs(dt(s[0]));
3737
- for (let t = 1; t < s.length; t++)
3738
- e -= Math.abs(dt(s[t]));
3772
+ if (o && o.length > 0) {
3773
+ e += Math.abs(dt(o[0]));
3774
+ for (let t = 1; t < o.length; t++)
3775
+ e -= Math.abs(dt(o[t]));
3739
3776
  }
3740
3777
  return e;
3741
3778
  }
3742
- var Vi = k * k / 2, Ee = Math.PI / 180;
3743
- function dt(s) {
3744
- const e = s.length - 1;
3779
+ var Vi = L * L / 2, Fe = Math.PI / 180;
3780
+ function dt(o) {
3781
+ const e = o.length - 1;
3745
3782
  if (e <= 2) return 0;
3746
3783
  let t = 0, i = 0;
3747
3784
  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;
3785
+ const n = o[i], s = o[i + 1 === e ? 0 : i + 1], r = o[i + 2 >= e ? (i + 2) % e : i + 2], a = n[0] * Fe, l = s[1] * Fe, d = r[0] * Fe;
3749
3786
  t += (d - a) * Math.sin(l), i++;
3750
3787
  }
3751
3788
  return t * Vi;
3752
3789
  }
3753
- function Ui(s, e = {}) {
3790
+ function Ui(o, e = {}) {
3754
3791
  let t = 0, i = 0, n = 0;
3755
- return kt(
3756
- s,
3757
- function(o) {
3758
- t += o[0], i += o[1], n++;
3792
+ return Lt(
3793
+ o,
3794
+ function(s) {
3795
+ t += s[0], i += s[1], n++;
3759
3796
  }
3760
- ), Li([t / n, i / n], e.properties);
3797
+ ), ki([t / n, i / n], e.properties);
3761
3798
  }
3762
- class Ki extends Di {
3799
+ const Ti = (o) => o === "degrees" ? "°" : o === "miles" ? "mi" : o === "radians" ? "rad" : "km";
3800
+ class Ki extends Oi {
3763
3801
  /**
3764
3802
  * Constructor
3765
3803
  * @param options Plugin control options
3766
3804
  */
3767
3805
  constructor(t) {
3768
- let i = Ei;
3806
+ let i = Fi;
3769
3807
  t && (i = Object.assign(i, t));
3770
3808
  super({
3771
3809
  modes: i.modes,
3772
3810
  open: i.open,
3773
3811
  modeOptions: i.modeOptions
3774
3812
  });
3775
- L(this, "lineLayerLabelSpec");
3776
- L(this, "lineLayerNodeSpec");
3777
- L(this, "polygonLayerSpec");
3778
- L(this, "computeElevation");
3813
+ A(this, "measureOptions");
3779
3814
  /**
3780
3815
  * Calculate area / distance and update a feature properties
3781
3816
  * @param feature GeoJSON feature
3782
3817
  * @returns updated GeoJSON feature
3783
3818
  */
3784
- L(this, "updateFeatureProperties", (t) => {
3819
+ A(this, "updateFeatureProperties", (t) => {
3785
3820
  if (!this.map || !this.map.loaded()) return t;
3786
3821
  const i = t.geometry.type;
3787
3822
  return i === "LineString" ? t = this.calcDistance(t) : i === "Polygon" && (t = this.calcArea(t)), t;
3788
3823
  });
3789
- this.lineLayerLabelSpec = i.lineLayerLabelSpec, this.lineLayerNodeSpec = i.lineLayerNodeSpec, this.polygonLayerSpec = i.polygonLayerSpec, this.computeElevation = i.computeElevation ?? !1;
3824
+ this.measureOptions = i;
3825
+ }
3826
+ /**
3827
+ * The unit of distance can be degrees, radians, miles, or kilometers (default 'kilometers')
3828
+ * The measuring result will be recalculated once new value is set
3829
+ */
3830
+ get distanceUnit() {
3831
+ return this.measureOptions.distanceUnit ?? "kilometers";
3832
+ }
3833
+ set distanceUnit(t) {
3834
+ const i = this.measureOptions.distanceUnit === t;
3835
+ this.measureOptions.distanceUnit = t, this.measureOptions.distanceUnit === "degrees" ? this.distancePrecision = 6 : this.distancePrecision = 2, i || this.recalc();
3836
+ }
3837
+ /**
3838
+ * The precision of distance value. It will be set different value dwhen distance unit is changed. Using setter to override the value if you want.
3839
+ */
3840
+ get distancePrecision() {
3841
+ return this.measureOptions.distancePrecision ?? 2;
3842
+ }
3843
+ set distancePrecision(t) {
3844
+ const i = this.measureOptions.distancePrecision === t;
3845
+ this.measureOptions.distancePrecision = t, i || this.recalc();
3846
+ }
3847
+ /**
3848
+ * The unit of area can be metric (m², ha, km²) or imperial (yd², acre, mi²). Default is metric.
3849
+ * The measuring result will be recalculated once new value is set
3850
+ */
3851
+ get areaUnit() {
3852
+ return this.measureOptions.areaUnit ?? "metric";
3853
+ }
3854
+ set areaUnit(t) {
3855
+ const i = this.measureOptions.areaUnit === t;
3856
+ this.measureOptions.areaUnit = t, i || this.recalc();
3857
+ }
3858
+ /**
3859
+ * The precision of area value. Using setter to override the value if you want.
3860
+ */
3861
+ get areaPrecision() {
3862
+ return this.measureOptions.areaPrecision ?? 2;
3863
+ }
3864
+ set areaPrecision(t) {
3865
+ const i = this.measureOptions.areaPrecision === t;
3866
+ this.measureOptions.areaPrecision = t, i || this.recalc();
3790
3867
  }
3791
3868
  /**
3792
3869
  * add the plugin control to maplibre
@@ -3794,7 +3871,7 @@ class Ki extends Di {
3794
3871
  * @returns HTML Element
3795
3872
  */
3796
3873
  onAdd(t) {
3797
- return this.controlContainer = super.onAdd(t), t.once("load", this.registerMesureControl.bind(this)), this.controlContainer;
3874
+ return this.controlContainer = super.onAdd(t), this.controlContainer;
3798
3875
  }
3799
3876
  /**
3800
3877
  * Remove the plugin control from maplibre
@@ -3803,18 +3880,53 @@ class Ki extends Di {
3803
3880
  onRemove() {
3804
3881
  this.unregisterMesureControl(), super.onRemove();
3805
3882
  }
3883
+ /**
3884
+ * Activate Terra Draw to start drawing
3885
+ */
3886
+ activate() {
3887
+ super.activate(), this.registerMesureControl();
3888
+ }
3889
+ /**
3890
+ * Recalculate area and distance in TerraDraw snapshot
3891
+ *
3892
+ * if you use `addFeatures` to restore GeoJSON features to TerraDraw, this recalc method needs to be called to re-measure again.
3893
+ *
3894
+ * For example, the below code is an example usage.
3895
+ * ```
3896
+ * drawInstance?.addFeatures(initData);
3897
+ * map?.once('idle', ()=>{
3898
+ * drawControl.recalc()
3899
+ * })
3900
+ * ```
3901
+ */
3902
+ recalc() {
3903
+ const t = this.getTerraDrawInstance();
3904
+ if (t) {
3905
+ this.registerMesureControl();
3906
+ const i = t.getSnapshot();
3907
+ for (const n of i) {
3908
+ const s = n.id, r = n.geometry.type, a = n.properties.mode;
3909
+ a === "linestring" && r === "LineString" ? this.measureLine(s) : !["point", "linestring", "select", "render"].includes(a) && r === "Polygon" && this.measurePolygon(s);
3910
+ }
3911
+ }
3912
+ }
3806
3913
  /**
3807
3914
  * Register measure control related maplibre sources and layers
3808
3915
  */
3809
3916
  registerMesureControl() {
3810
- var n, o;
3917
+ var n, s;
3811
3918
  if (!this.map) return;
3812
3919
  const t = (n = this.options.modes) == null ? void 0 : n.filter((r) => ["linestring"].includes(r));
3813
- t && t.length > 0 && (this.map.getSource(this.lineLayerLabelSpec.source) || this.map.addSource(this.lineLayerLabelSpec.source, {
3814
- type: "geojson",
3815
- data: { type: "FeatureCollection", features: [] }
3816
- }), this.map.getLayer(this.lineLayerNodeSpec.id) || this.map.addLayer(this.lineLayerNodeSpec), this.map.getLayer(this.lineLayerLabelSpec.id) || this.map.addLayer(this.lineLayerLabelSpec));
3817
- const i = (o = this.options.modes) == null ? void 0 : o.filter(
3920
+ t && t.length > 0 && (this.map.getSource(
3921
+ this.measureOptions.lineLayerLabelSpec.source
3922
+ ) || this.map.addSource(
3923
+ this.measureOptions.lineLayerLabelSpec.source,
3924
+ {
3925
+ type: "geojson",
3926
+ data: { type: "FeatureCollection", features: [] }
3927
+ }
3928
+ ), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) || this.map.addLayer(this.measureOptions.lineLayerNodeSpec), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) || this.map.addLayer(this.measureOptions.lineLayerLabelSpec));
3929
+ const i = (s = this.options.modes) == null ? void 0 : s.filter(
3818
3930
  (r) => [
3819
3931
  "polygon",
3820
3932
  "rectangle",
@@ -3825,32 +3937,57 @@ class Ki extends Di {
3825
3937
  "freehand"
3826
3938
  ].includes(r)
3827
3939
  );
3828
- if (i && i.length > 0 && (this.map.getSource(this.polygonLayerSpec.source) || this.map.addSource(this.polygonLayerSpec.source, {
3829
- type: "geojson",
3830
- data: { type: "FeatureCollection", features: [] }
3831
- }), this.map.getLayer(this.polygonLayerSpec.id) || this.map.addLayer(this.polygonLayerSpec)), t && t.length > 0 || i && i.length > 0) {
3940
+ if (i && i.length > 0 && (this.map.getSource(
3941
+ this.measureOptions.polygonLayerSpec.source
3942
+ ) || this.map.addSource(
3943
+ this.measureOptions.polygonLayerSpec.source,
3944
+ {
3945
+ type: "geojson",
3946
+ data: { type: "FeatureCollection", features: [] }
3947
+ }
3948
+ ), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) || this.map.addLayer(this.measureOptions.polygonLayerSpec)), t && t.length > 0 || i && i.length > 0) {
3832
3949
  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)));
3950
+ r && (r.on("change", this.handleTerradrawFeatureChanged.bind(this)), this.on("feature-deleted", this.onFeatureDeleted.bind(this)));
3951
+ }
3952
+ }
3953
+ /**
3954
+ * Handle change event of TerraDraw
3955
+ * @param ids Feature IDs
3956
+ */
3957
+ handleTerradrawFeatureChanged(t) {
3958
+ if (!this.map) return;
3959
+ const i = this.getTerraDrawInstance();
3960
+ if (!i) return;
3961
+ const n = i.getSnapshot();
3962
+ for (const s of t) {
3963
+ const r = n.find((a) => a.id === s);
3964
+ if (r) {
3965
+ const a = r.geometry.type, l = r.properties.mode;
3966
+ l === "linestring" && a === "LineString" ? this.measureLine(s) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(s);
3967
+ } else
3968
+ this.clearMeasureFeatures(
3969
+ s,
3970
+ this.measureOptions.lineLayerNodeSpec.source
3971
+ ), this.clearMeasureFeatures(
3972
+ s,
3973
+ this.measureOptions.lineLayerLabelSpec.source
3974
+ ), this.clearMeasureFeatures(
3975
+ s,
3976
+ this.measureOptions.polygonLayerSpec.source
3977
+ );
3847
3978
  }
3848
3979
  }
3849
3980
  /**
3850
3981
  * Unregister measure control related maplibre sources and layers
3851
3982
  */
3852
3983
  unregisterMesureControl() {
3853
- this.off("feature-deleted", this.onFeatureDeleted.bind(this)), this.map && (this.map.getLayer(this.lineLayerLabelSpec.id) && this.map.removeLayer(this.lineLayerLabelSpec.id), this.map.getLayer(this.lineLayerNodeSpec.id) && this.map.removeLayer(this.lineLayerNodeSpec.id), this.map.getLayer(this.polygonLayerSpec.id) && this.map.removeLayer(this.polygonLayerSpec.id), this.map.getSource(this.lineLayerLabelSpec.source) && this.map.removeSource(this.lineLayerLabelSpec.source), this.map.getSource(this.polygonLayerSpec.source) && this.map.removeSource(this.polygonLayerSpec.source));
3984
+ this.off("feature-deleted", this.onFeatureDeleted.bind(this)), this.map && (this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) && this.map.removeLayer(this.measureOptions.lineLayerNodeSpec.id), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.removeLayer(this.measureOptions.polygonLayerSpec.id), this.map.getSource(
3985
+ this.measureOptions.lineLayerLabelSpec.source
3986
+ ) && this.map.removeSource(
3987
+ this.measureOptions.lineLayerLabelSpec.source
3988
+ ), this.map.getSource(this.measureOptions.polygonLayerSpec.source) && this.map.removeSource(
3989
+ this.measureOptions.polygonLayerSpec.source
3990
+ ));
3854
3991
  }
3855
3992
  /**
3856
3993
  * Clear GeoJSON feature related to measure control by TerraDraw feature ID
@@ -3859,7 +3996,7 @@ class Ki extends Di {
3859
3996
  * @returns void
3860
3997
  */
3861
3998
  clearMeasureFeatures(t, i) {
3862
- var o;
3999
+ var s;
3863
4000
  if (!this.map) return;
3864
4001
  const n = this.map.getStyle().sources[i];
3865
4002
  n && typeof n.data != "string" && n.data.type === "FeatureCollection" && (n.data.features = n.data.features.filter(
@@ -3867,7 +4004,7 @@ class Ki extends Di {
3867
4004
  var a;
3868
4005
  return ((a = r.properties) == null ? void 0 : a.originalId) !== t;
3869
4006
  }
3870
- ), (o = this.map.getSource(i)) == null || o.setData(n.data));
4007
+ ), (s = this.map.getSource(i)) == null || s.setData(n.data));
3871
4008
  }
3872
4009
  /**
3873
4010
  * Calculate area from polygon feature
@@ -3876,9 +4013,9 @@ class Ki extends Di {
3876
4013
  */
3877
4014
  calcArea(t) {
3878
4015
  if (t.geometry.type !== "Polygon") return t;
3879
- const i = Gi(t.geometry);
3880
- let n = i, o = "m2";
3881
- 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;
4016
+ const i = Ai(t.geometry);
4017
+ let n = i, s = "";
4018
+ return this.areaUnit === "metric" ? i >= 1e6 ? (n = i / 1e6, s = "km²") : i >= 1e4 && (n = i / 1e4, s = "ha") : i >= 258998811e-2 ? (n = i / 258998811e-2, s = "mi²") : i >= 4046.856 ? (n = i / 4046.856, s = "acre") : i >= 0.83612736 && (n = i / 0.83612736, s = "yd²"), n = parseFloat(n.toFixed(this.areaPrecision)), t.properties.area = n, t.properties.unit = s, t;
3882
4019
  }
3883
4020
  /**
3884
4021
  * Caclulate distance for each segment on a given feature
@@ -3890,20 +4027,20 @@ class Ki extends Di {
3890
4027
  if (t.geometry.type !== "LineString") return t;
3891
4028
  const i = t.geometry.coordinates;
3892
4029
  let n = 0;
3893
- const o = [];
4030
+ const s = [];
3894
4031
  for (let l = 0; l < i.length - 1; l++) {
3895
- const d = i[l], c = i[l + 1], h = ji(d, c, { units: "kilometers" });
4032
+ const d = i[l], c = i[l + 1], h = ji(d, c, { units: this.distanceUnit });
3896
4033
  n += h;
3897
4034
  const u = JSON.parse(JSON.stringify(t));
3898
- if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, c], u.properties.originalId = t.id, u.properties.distance = parseFloat(h.toFixed(2)), u.properties.total = parseFloat(n.toFixed(2)), u.properties.unit = "km", this.computeElevation === !0) {
3899
- const g = (r = this.map) == null ? void 0 : r.queryTerrainElevation(d);
3900
- g && (u.properties.elevation_start = g);
3901
- const p = (a = this.map) == null ? void 0 : a.queryTerrainElevation(c);
3902
- p && (u.properties.elevation_end = p);
4035
+ if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, c], u.properties.originalId = t.id, u.properties.distance = parseFloat(h.toFixed(this.distancePrecision)), u.properties.total = parseFloat(n.toFixed(this.distancePrecision)), u.properties.unit = Ti(this.distanceUnit), this.measureOptions.computeElevation === !0) {
4036
+ const p = (r = this.map) == null ? void 0 : r.queryTerrainElevation(d);
4037
+ p && (u.properties.elevation_start = p);
4038
+ const g = (a = this.map) == null ? void 0 : a.queryTerrainElevation(c);
4039
+ g && (u.properties.elevation_end = g);
3903
4040
  }
3904
- o.push(u);
4041
+ s.push(u);
3905
4042
  }
3906
- return t.properties.distance = o[o.length - 1].properties.total, t.properties.unit = o[o.length - 1].properties.unit, t.properties.segments = JSON.parse(JSON.stringify(o)), t;
4043
+ return t.properties.distance = s[s.length - 1].properties.total, t.properties.unit = s[s.length - 1].properties.unit, t.properties.segments = JSON.parse(JSON.stringify(s)), t;
3907
4044
  }
3908
4045
  /**
3909
4046
  * measure polygon area for given feature ID
@@ -3915,9 +4052,9 @@ class Ki extends Di {
3915
4052
  const i = this.getTerraDrawInstance();
3916
4053
  if (!i) return;
3917
4054
  const n = i.getSnapshot();
3918
- let o = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "Polygon");
3919
- if (o) {
3920
- const a = this.map.getStyle().sources[this.polygonLayerSpec.source];
4055
+ let s = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "Polygon");
4056
+ if (s) {
4057
+ const a = this.map.getStyle().sources[this.measureOptions.polygonLayerSpec.source];
3921
4058
  if (a) {
3922
4059
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
3923
4060
  (d) => {
@@ -3925,10 +4062,14 @@ class Ki extends Di {
3925
4062
  return ((c = d.properties) == null ? void 0 : c.originalId) !== t;
3926
4063
  }
3927
4064
  ));
3928
- 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(
3930
- a.data
3931
- ), this.map.moveLayer(this.polygonLayerSpec.id);
4065
+ const l = JSON.parse(JSON.stringify(s));
4066
+ l.id = l.id + "-area-label", l.geometry = Ui(s.geometry).geometry, l.properties.originalId = s.id, s = this.calcArea(s), l.properties.area = s.properties.area, l.properties.unit = s.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (r = this.map.getSource(
4067
+ this.measureOptions.polygonLayerSpec.source
4068
+ )) == null || r.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
4069
+ this.measureOptions.lineLayerLabelSpec.id
4070
+ ), this.map.getLayer(this.measureOptions.lineLayerNodeSpec.id) && this.map.moveLayer(
4071
+ this.measureOptions.lineLayerNodeSpec.id
4072
+ );
3932
4073
  }
3933
4074
  }
3934
4075
  }
@@ -3942,21 +4083,21 @@ class Ki extends Di {
3942
4083
  const i = this.getTerraDrawInstance();
3943
4084
  if (!i) return;
3944
4085
  const n = i.getSnapshot();
3945
- let o = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "LineString");
3946
- if (o) {
3947
- const a = this.map.getStyle().sources[this.lineLayerLabelSpec.source];
4086
+ let s = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "LineString");
4087
+ if (s) {
4088
+ const a = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
3948
4089
  if (a) {
3949
4090
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
3950
4091
  (d) => {
3951
4092
  var c;
3952
4093
  return ((c = d.properties) == null ? void 0 : c.originalId) !== t;
3953
4094
  }
3954
- )), o = this.calcDistance(o);
3955
- const l = o.properties.segments;
4095
+ )), s = this.calcDistance(s);
4096
+ const l = s.properties.segments;
3956
4097
  for (let d = 0; d < l.length; d++) {
3957
4098
  const c = l[d];
3958
4099
  typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
3959
- const h = c.geometry.coordinates, u = h[0], g = h[1];
4100
+ const h = c.geometry.coordinates, u = h[0], p = h[1];
3960
4101
  if (d === 0) {
3961
4102
  const f = JSON.parse(JSON.stringify(c));
3962
4103
  f.id = `${c.id}-node-${d}`, f.geometry = {
@@ -3964,15 +4105,15 @@ class Ki extends Di {
3964
4105
  coordinates: u
3965
4106
  }, 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);
3966
4107
  }
3967
- const p = JSON.parse(JSON.stringify(c));
3968
- p.id = `${c.id}-node-${d + 1}`, p.geometry = {
4108
+ const g = JSON.parse(JSON.stringify(c));
4109
+ g.id = `${c.id}-node-${d + 1}`, g.geometry = {
3969
4110
  type: "Point",
3970
- coordinates: g
3971
- }, c.properties.elevation_end && (p.properties.elevation = c.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(p);
4111
+ coordinates: p
4112
+ }, c.properties.elevation_end && (g.properties.elevation = c.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
3972
4113
  }
3973
- (r = this.map.getSource(this.lineLayerLabelSpec.source)) == null || r.setData(
3974
- a.data
3975
- ), this.map.moveLayer(this.lineLayerLabelSpec.id), this.map.moveLayer(this.lineLayerNodeSpec.id);
4114
+ (r = this.map.getSource(
4115
+ this.measureOptions.lineLayerLabelSpec.source
4116
+ )) == null || r.setData(a.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.moveLayer(this.measureOptions.lineLayerLabelSpec.id), this.map.moveLayer(this.measureOptions.lineLayerNodeSpec.id);
3976
4117
  }
3977
4118
  }
3978
4119
  }
@@ -3984,8 +4125,11 @@ class Ki extends Di {
3984
4125
  if (!this.map) return;
3985
4126
  const t = this.getTerraDrawInstance();
3986
4127
  if (t) {
3987
- const o = [this.lineLayerLabelSpec.source, this.polygonLayerSpec.source];
3988
- for (const r of o) {
4128
+ const s = [
4129
+ this.measureOptions.lineLayerLabelSpec.source,
4130
+ this.measureOptions.polygonLayerSpec.source
4131
+ ];
4132
+ for (const r of s) {
3989
4133
  const a = this.map.getStyle().sources[r];
3990
4134
  if (a) {
3991
4135
  const l = t.getSnapshot(), c = (l == null ? void 0 : l.filter(
@@ -3996,11 +4140,23 @@ class Ki extends Di {
3996
4140
  var u;
3997
4141
  return c.includes((u = h.properties) == null ? void 0 : u.originalId);
3998
4142
  }
3999
- )), r === this.lineLayerLabelSpec.source ? ((i = this.map.getSource(this.lineLayerLabelSpec.source)) == null || i.setData(
4000
- a.data
4001
- ), this.map.getLayer(this.lineLayerNodeSpec.id) && this.map.moveLayer(this.lineLayerNodeSpec.id), this.map.getLayer(this.lineLayerLabelSpec.id) && this.map.moveLayer(this.lineLayerLabelSpec.id)) : r === this.polygonLayerSpec.source && ((n = this.map.getSource(this.polygonLayerSpec.source)) == null || n.setData(
4002
- a.data
4003
- ), this.map.getLayer(this.polygonLayerSpec.id) && this.map.moveLayer(this.polygonLayerSpec.id));
4143
+ )), r === this.measureOptions.lineLayerLabelSpec.source ? ((i = this.map.getSource(
4144
+ this.measureOptions.lineLayerLabelSpec.source
4145
+ )) == null || i.setData(a.data), this.map.getLayer(
4146
+ this.measureOptions.lineLayerNodeSpec.id
4147
+ ) && this.map.moveLayer(
4148
+ this.measureOptions.lineLayerNodeSpec.id
4149
+ ), this.map.getLayer(
4150
+ this.measureOptions.lineLayerLabelSpec.id
4151
+ ) && this.map.moveLayer(
4152
+ this.measureOptions.lineLayerLabelSpec.id
4153
+ )) : r === this.measureOptions.polygonLayerSpec.source && ((n = this.map.getSource(
4154
+ this.measureOptions.polygonLayerSpec.source
4155
+ )) == null || n.setData(a.data), this.map.getLayer(
4156
+ this.measureOptions.polygonLayerSpec.id
4157
+ ) && this.map.moveLayer(
4158
+ this.measureOptions.polygonLayerSpec.id
4159
+ ));
4004
4160
  }
4005
4161
  }
4006
4162
  }
@@ -4019,12 +4175,13 @@ class Ki extends Di {
4019
4175
  }
4020
4176
  }
4021
4177
  export {
4022
- Xi as AvailableMeasureModes,
4023
- Ri as AvailableModes,
4178
+ zi as AvailableMeasureModes,
4179
+ Xi as AvailableModes,
4024
4180
  Ki as MaplibreMeasureControl,
4025
- Di as MaplibreTerradrawControl,
4026
- Fi as defaultControlOptions,
4027
- Ei as defaultMeasureControlOptions,
4028
- _i as getDefaultModeOptions
4181
+ Oi as MaplibreTerradrawControl,
4182
+ Ei as defaultControlOptions,
4183
+ Fi as defaultMeasureControlOptions,
4184
+ Di as getDefaultModeOptions,
4185
+ Ti as getDistanceUnitName
4029
4186
  };
4030
4187
  //# sourceMappingURL=maplibre-gl-terradraw.es.js.map