@watergis/maplibre-gl-terradraw 0.8.1 → 0.8.2

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,21 +1,21 @@
1
1
  var Lt = Object.defineProperty;
2
- var Wt = (o, e, t) => e in o ? Lt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var j = (o, e, t) => Wt(o, typeof e != "symbol" ? e + "" : e, t);
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);
4
4
  function M() {
5
- return M = Object.assign ? Object.assign.bind() : function(o) {
5
+ return M = Object.assign ? Object.assign.bind() : function(s) {
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) && (o[i] = t[i]);
8
+ for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (s[i] = t[i]);
9
9
  }
10
- return o;
10
+ return s;
11
11
  }, M.apply(this, arguments);
12
12
  }
13
- function F(o, e = 9) {
13
+ function F(s, e = 9) {
14
14
  const t = Math.pow(10, e);
15
- return Math.round(o * t) / t;
15
+ return Math.round(s * t) / t;
16
16
  }
17
- const E = (o, e) => {
18
- const { x: t, y: i } = o, { x: n, y: s } = e, r = n - t, a = s - i;
17
+ const E = (s, e) => {
18
+ const { x: t, y: i } = s, { x: n, y: o } = e, r = n - t, a = o - i;
19
19
  return Math.sqrt(a * a + r * r);
20
20
  };
21
21
  class J {
@@ -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: s, 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: s, containerY: r, button: a, heldKeys: l };
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 };
46
46
  }
47
47
  register(e) {
48
48
  this._currentModeCallbacks = e, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
@@ -68,9 +68,9 @@ class ct {
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 }, s = this._currentModeCallbacks.getState(), r = E(i, n);
71
+ const i = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, n = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), r = E(i, n);
72
72
  let a = !1;
73
- if (a = s === "drawing" ? r < this._minPixelDragDistanceDrawing : s === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, a) return;
73
+ if (a = o === "drawing" ? r < this._minPixelDragDistanceDrawing : o === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, a) return;
74
74
  this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (l) => {
75
75
  this.setDraggability.bind(this)(l);
76
76
  });
@@ -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 = [], s = [], r = [];
188
+ const i = [...e.created, ...e.updated, ...e.unchanged], n = [], o = [], 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, 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));
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));
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", s), d && this._setGeoJSONLayerData("Polygon", r), c && this._map.moveLayer(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);
197
197
  } else {
198
198
  const a = this._addGeoJSONLayer("Point", n);
199
- this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon", r), this._rendered = !0, a && this._map.moveLayer(a);
199
+ this._addGeoJSONLayer("LineString", o), 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(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;
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;
263
263
  }
264
264
  canWrapX() {
265
265
  return this.canWrapX_;
@@ -285,23 +285,23 @@ var ht = class {
285
285
  isGlobal() {
286
286
  return this.global_;
287
287
  }
288
- setGlobal(o) {
289
- this.global_ = o, this.canWrapX_ = !(!o || !this.extent_);
288
+ setGlobal(s) {
289
+ this.global_ = s, this.canWrapX_ = !(!s || !this.extent_);
290
290
  }
291
291
  getDefaultTileGrid() {
292
292
  return this.defaultTileGrid_;
293
293
  }
294
- setDefaultTileGrid(o) {
295
- this.defaultTileGrid_ = o;
294
+ setDefaultTileGrid(s) {
295
+ this.defaultTileGrid_ = s;
296
296
  }
297
- setExtent(o) {
298
- this.extent_ = o, this.canWrapX_ = !(!this.global_ || !o);
297
+ setExtent(s) {
298
+ this.extent_ = s, this.canWrapX_ = !(!this.global_ || !s);
299
299
  }
300
- setWorldExtent(o) {
301
- this.worldExtent_ = o;
300
+ setWorldExtent(s) {
301
+ this.worldExtent_ = s;
302
302
  }
303
- setGetPointResolution(o) {
304
- this.getPointResolutionFunc_ = o;
303
+ setGetPointResolution(s) {
304
+ this.getPointResolutionFunc_ = s;
305
305
  }
306
306
  getPointResolutionFunc() {
307
307
  return this.getPointResolutionFunc_;
@@ -323,63 +323,63 @@ 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(o, e, t) {
327
- const i = o.getCode(), n = e.getCode();
326
+ function ye(s, e, t) {
327
+ const i = s.getCode(), n = e.getCode();
328
328
  i in Me || (Me[i] = {}), Me[i][n] = t;
329
329
  }
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();
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();
333
333
  return e;
334
334
  }
335
- function Ut(o) {
336
- o.getCode(), ye(o, o, ut);
335
+ function Ut(s) {
336
+ s.getCode(), ye(s, s, ut);
337
337
  }
338
- function Xe(o) {
338
+ function Xe(s) {
339
339
  (function(e) {
340
340
  e.forEach(Ut);
341
- })(o), o.forEach(function(e) {
342
- o.forEach(function(t) {
341
+ })(s), s.forEach(function(e) {
342
+ s.forEach(function(t) {
343
343
  e !== t && ye(e, t, ut);
344
344
  });
345
345
  });
346
346
  }
347
347
  var Ke, ze, Ye, b;
348
- Xe(Ue), Xe(Re), Ke = Ue, ze = 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));
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));
351
351
  for (let n = 0; n < i; n += t) {
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;
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;
355
355
  }
356
356
  return e;
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;
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;
361
361
  return e;
362
- }, Re.forEach(function(o) {
362
+ }, Re.forEach(function(s) {
363
363
  Ke.forEach(function(e) {
364
- ye(o, e, ze), ye(e, o, Ye);
364
+ ye(s, e, ze), ye(e, s, Ye);
365
365
  });
366
366
  });
367
- (function(o) {
368
- o.Commit = "commit", o.Provisional = "provisional", o.Finish = "finish";
367
+ (function(s) {
368
+ s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
369
369
  })(b || (b = {}));
370
- const _e = "selected", oe = "midPoint", ae = "closingPoint", De = "snappingPoint";
371
- function we(o) {
372
- return !!(o && typeof o == "object" && o !== null && !Array.isArray(o));
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));
373
373
  }
374
- function He(o) {
374
+ function He(s) {
375
375
  return !!function(e) {
376
376
  return typeof e == "number" && !isNaN(new Date(e).valueOf());
377
- }(o);
377
+ }(s);
378
378
  }
379
379
  const Tt = "Feature mode property does not match the mode being added to";
380
380
  var z;
381
- (function(o) {
382
- o.Drawing = "drawing", o.Select = "select", o.Static = "static", o.Render = "render";
381
+ (function(s) {
382
+ s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
383
383
  })(z || (z = {}));
384
384
  class N {
385
385
  get state() {
@@ -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 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";
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";
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 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 };
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 };
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 });
@@ -480,78 +480,78 @@ class Rt extends N {
480
480
  super(...e), this.type = z.Select;
481
481
  }
482
482
  }
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);
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);
485
485
  return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
486
486
  }
487
487
  const Oe = 63710088e-1;
488
- function _(o) {
489
- return o % 360 * Math.PI / 180;
488
+ function _(s) {
489
+ return s % 360 * Math.PI / 180;
490
490
  }
491
- function gt(o) {
492
- return o / (Oe / 1e3);
491
+ function gt(s) {
492
+ return s / (Oe / 1e3);
493
493
  }
494
- function U(o) {
495
- return o % (2 * Math.PI) * 180 / Math.PI;
494
+ function U(s) {
495
+ return s % (2 * Math.PI) * 180 / Math.PI;
496
496
  }
497
- const Je = 57.29577951308232, $e = 0.017453292519943295, me = 6378137, S = (o, e) => ({ x: o === 0 ? 0 : o * $e * me, y: e === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + e * $e / 2)) * me }), L = (o, e) => ({ lng: o === 0 ? 0 : Je * (o / me), lat: e === 0 ? 0 : (2 * Math.atan(Math.exp(e / me)) - Math.PI / 2) * Je });
498
- function Xt(o, e, t) {
499
- const i = _(o[0]), n = _(o[1]), s = _(t), r = gt(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)];
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)];
501
501
  }
502
- function qe(o) {
503
- const { center: e, radiusKilometers: t, coordinatePrecision: i } = o, n = o.steps ? o.steps : 64, s = [];
502
+ function qe(s) {
503
+ const { center: e, radiusKilometers: t, coordinatePrecision: i } = s, n = s.steps ? s.steps : 64, o = [];
504
504
  for (let r = 0; r < n; r++) {
505
505
  const a = Xt(e, t, -360 * r / n);
506
- s.push([F(a[0], i), F(a[1], i)]);
506
+ o.push([F(a[0], i), F(a[1], i)]);
507
507
  }
508
- return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
508
+ return o.push(o[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [o] }, properties: {} };
509
509
  }
510
- function ke(o) {
510
+ function ke(s) {
511
511
  const e = { epsilon: 0 };
512
512
  let t;
513
- if (o.geometry.type === "Polygon") t = o.geometry.coordinates;
513
+ if (s.geometry.type === "Polygon") t = s.geometry.coordinates;
514
514
  else {
515
- if (o.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
516
- t = [o.geometry.coordinates];
515
+ if (s.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
516
+ t = [s.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++) s(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++) o(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 s(r, a, l, d) {
525
- const c = t[r][a], h = t[r][a + 1], u = t[l][d], g = t[l][d + 1], f = function(y, C, m, v) {
524
+ function o(r, a, l, d) {
525
+ const c = t[r][a], h = t[r][a + 1], u = t[l][d], g = t[l][d + 1], p = function(y, C, m, v) {
526
526
  if (he(y, m) || he(y, v) || he(C, m) || he(v, m)) return null;
527
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
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
529
  }(c, h, u, g);
530
- if (f === null) return;
531
- let p, P;
532
- p = h[0] !== c[0] ? (f[0] - c[0]) / (h[0] - c[0]) : (f[1] - c[1]) / (h[1] - c[1]), P = g[0] !== u[0] ? (f[0] - u[0]) / (g[0] - u[0]) : (f[1] - u[1]) / (g[1] - u[1]), n(p) || n(P) || (f.toString(), i.push(f));
530
+ if (p === null) return;
531
+ let f, P;
532
+ f = h[0] !== c[0] ? (p[0] - c[0]) / (h[0] - c[0]) : (p[1] - c[1]) / (h[1] - c[1]), P = g[0] !== u[0] ? (p[0] - u[0]) / (g[0] - u[0]) : (p[1] - u[1]) / (g[1] - u[1]), n(f) || n(P) || (p.toString(), i.push(p));
533
533
  }
534
534
  }
535
- function he(o, e) {
536
- return o[0] === e[0] && o[1] === e[1];
535
+ function he(s, e) {
536
+ return s[0] === e[0] && s[1] === e[1];
537
537
  }
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;
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;
540
540
  var t, i;
541
541
  }
542
- function Ze(o) {
542
+ function Ze(s) {
543
543
  let e = 1, t = 0;
544
- for (; Math.round(o * e) / e !== o; ) e *= 10, t++;
544
+ for (; Math.round(s * e) / e !== s; ) e *= 10, t++;
545
545
  return t;
546
546
  }
547
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(o, e) {
549
- return o.geometry.type !== "Polygon" ? { valid: !1, reason: Kt } : o.geometry.coordinates.length !== 1 ? { valid: !1, reason: zt } : 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: Jt } : { valid: !0 } : { valid: !1, reason: Ht };
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 };
550
550
  var t, i;
551
551
  }
552
- function de(o, e) {
553
- const t = Se(o, e);
554
- return t.valid ? ke(o) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : t;
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;
555
555
  }
556
556
  class pt extends N {
557
557
  constructor(e) {
@@ -621,19 +621,19 @@ 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(s, r) {
625
- const a = 1e3 * V(s, r);
624
+ const n = function(o, r) {
625
+ const a = 1e3 * V(o, r);
626
626
  if (a === 0) return 1;
627
- const { x: l, y: d } = S(s[0], s[1]), { x: c, y: h } = S(r[0], r[1]);
627
+ const { x: l, y: d } = S(o[0], o[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(s) {
631
- const { center: r, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = r, { x: g, y: f } = S(h, u), p = [];
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 = [];
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, f + m], { lng: w, lat: I } = L(v, x);
634
- p.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] = [g + C, p + m], { lng: w, lat: I } = W(v, x);
634
+ f.push([F(w, l), F(I, l)]);
635
635
  }
636
- return p.push(p[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [p] }, properties: {} };
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 });
638
638
  } else {
639
639
  if (this.projection !== "globe") throw new Error("Invalid projection");
@@ -673,7 +673,7 @@ 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, s] = t.coordinates[0][i], { x: r, y: a } = this.project(n, s), 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);
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
677
  if (E({ 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;
@@ -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 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;
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;
726
726
  }
727
727
  }
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])] } };
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])] } };
731
731
  }
732
- class Le extends W {
732
+ class Le extends j {
733
733
  constructor(e) {
734
734
  super(e);
735
735
  }
@@ -738,7 +738,7 @@ class Le extends W {
738
738
  return yt({ unproject: this.unproject, point: { x: t, y: i }, pointerDistance: this.pointerDistance });
739
739
  }
740
740
  }
741
- class We extends W {
741
+ class We extends j {
742
742
  constructor(e) {
743
743
  super(e);
744
744
  }
@@ -747,12 +747,12 @@ class We extends W {
747
747
  return E({ x: i, y: n }, { x: e.containerX, y: e.containerY });
748
748
  }
749
749
  }
750
- class mt extends W {
750
+ class mt extends j {
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, (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;
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;
753
753
  }
754
754
  getSnappable(e, t) {
755
- const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), s = { coord: void 0, minDist: 1 / 0 };
755
+ const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), o = { 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,62 +762,62 @@ class mt extends W {
762
762
  }
763
763
  a.forEach((l) => {
764
764
  const d = this.pixelDistance.measure(e, l);
765
- d < s.minDist && d < this.pointerDistance && (s.coord = l, s.minDist = d);
765
+ d < o.minDist && d < this.pointerDistance && (o.coord = l, o.minDist = d);
766
766
  });
767
- }), s.coord;
767
+ }), o.coord;
768
768
  }
769
769
  }
770
- function Qe(o, e, t) {
771
- const i = _(o[0]), n = _(o[1]), s = _(t), r = gt(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)];
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)];
773
773
  }
774
- function le({ x: o, y: e }, t, i) {
774
+ function le({ x: s, y: e }, t, i) {
775
775
  const n = _(i);
776
- return { x: o + t * Math.cos(n), y: e + t * Math.sin(n) };
776
+ return { x: s + t * Math.cos(n), y: e + t * Math.sin(n) };
777
777
  }
778
- function et(o, e) {
779
- const t = _(o[0]), i = _(e[0]), n = _(o[1]), s = _(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);
778
+ function et(s, e) {
779
+ const t = _(s[0]), i = _(e[0]), n = _(s[1]), o = _(e[1]), r = Math.sin(i - t) * Math.cos(o), a = Math.cos(n) * Math.sin(o) - Math.sin(n) * Math.cos(o) * Math.cos(i - t);
780
780
  return U(Math.atan2(r, a));
781
781
  }
782
- function A({ x: o, y: e }, { x: t, y: i }) {
783
- let n = Math.atan2(i - e, t - o);
782
+ function A({ x: s, y: e }, { x: t, y: i }) {
783
+ let n = Math.atan2(i - e, t - s);
784
784
  return n *= 180 / Math.PI, n > 180 ? n -= 360 : n < -180 && (n += 360), n;
785
785
  }
786
- function K(o) {
787
- return (o + 360) % 360;
786
+ function K(s) {
787
+ return (s + 360) % 360;
788
788
  }
789
- function $t(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++) {
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++) {
793
793
  if (l > e && i.length === 0) {
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);
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);
796
796
  }
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]);
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]);
800
800
  }
801
- if (l < e && o.length === n) throw new Error("Start position is beyond line");
802
- const d = o[o.length - 1];
801
+ if (l < e && s.length === n) throw new Error("Start position is beyond line");
802
+ const d = s[s.length - 1];
803
803
  return [d, d];
804
804
  }
805
- function ue(o) {
806
- return o * (Math.PI / 180);
805
+ function ue(s) {
806
+ return s * (Math.PI / 180);
807
807
  }
808
- function tt(o) {
809
- return o * (180 / Math.PI);
808
+ function tt(s) {
809
+ return s * (180 / Math.PI);
810
810
  }
811
- class qt extends W {
811
+ class qt extends j {
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 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;
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;
821
821
  Number.isInteger(r) || (r = Math.floor(r) + 1);
822
822
  const a = [];
823
823
  for (let d = 0; d < r; d++) {
@@ -829,30 +829,30 @@ class qt extends W {
829
829
  return this.limitCoordinates(l);
830
830
  }
831
831
  generateInsertionGeodesicCoordinates(e, t, i) {
832
- const n = V(e, t), s = function(r, a, l) {
832
+ const n = V(e, t), o = function(r, a, l) {
833
833
  const d = [], c = ue(r[1]), h = ue(r[0]), u = ue(a[1]), g = ue(a[0]);
834
834
  l += 1;
835
- const f = 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 (f === 0 || isNaN(f)) return d;
837
- for (let p = 0; p <= l; p++) {
838
- const P = p / l, y = Math.sin((1 - P) * f) / Math.sin(f), C = Math.sin(P * f) / Math.sin(f), 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);
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;
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);
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(s);
845
+ return this.limitCoordinates(o);
846
846
  }
847
847
  limitCoordinates(e) {
848
848
  return e.map((t) => [F(t[0], this.config.coordinatePrecision), F(t[1], this.config.coordinatePrecision)]);
849
849
  }
850
850
  }
851
- function ee(o, e) {
852
- return o[0] === e[0] && o[1] === e[1];
851
+ function ee(s, e) {
852
+ return s[0] === e[0] && s[1] === e[1];
853
853
  }
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" };
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" };
856
856
  }
857
857
  class Pt extends N {
858
858
  constructor(e) {
@@ -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 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);
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);
881
881
  }
882
882
  generateInsertCoordinates(e, t) {
883
883
  if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
@@ -899,7 +899,7 @@ 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, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: r, y: a } = this.project(n, s);
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
903
  if (E({ 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];
@@ -932,15 +932,15 @@ class Pt extends N {
932
932
  const [r, a] = n[n.length - 1], { x: l, y: d } = this.project(r, a);
933
933
  E({ x: l, y: d }, { x: e.containerX, y: e.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
934
934
  }
935
- let s = [...n, i];
935
+ let o = [...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
- s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
940
+ o = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
941
941
  }
942
942
  }
943
- this.updateGeometries(s, void 0, b.Provisional);
943
+ this.updateGeometries(o, 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,8 +985,8 @@ 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(o, e) {
989
- return o.geometry.type !== "Point" ? { valid: !1, reason: Zt } : xe(o.geometry.coordinates, e) ? { valid: !0 } : { valid: !1, reason: Qt };
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 };
990
990
  }
991
991
  class ei extends N {
992
992
  constructor(e) {
@@ -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 W {
1032
+ class ti extends j {
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 W {
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), s = this.pixelDistance.measure(e, i.coordinates);
1055
- return { isClosing: n < this.pointerDistance, isPreviousClosing: s < 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), o = this.pixelDistance.measure(e, i.coordinates);
1055
+ return { isClosing: n < this.pointerDistance, isPreviousClosing: o < this.pointerDistance };
1056
1056
  }
1057
1057
  }
1058
- function it(o) {
1059
- return Math.sqrt(Math.pow(o[0], 2) + Math.pow(o[1], 2) + Math.pow(o[2], 2));
1058
+ function it(s) {
1059
+ return Math.sqrt(Math.pow(s[0], 2) + Math.pow(s[1], 2) + Math.pow(s[2], 2));
1060
1060
  }
1061
- function R(o, e) {
1061
+ function R(s, e) {
1062
1062
  const t = function(i, n) {
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));
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));
1066
1066
  return Math.acos(Math.min(Math.max(t, -1), 1));
1067
1067
  }
1068
- function be(o) {
1069
- const e = _(o[1]), t = _(o[0]);
1068
+ function be(s) {
1069
+ const e = _(s[1]), t = _(s[0]);
1070
1070
  return [Math.cos(e) * Math.cos(t), Math.cos(e) * Math.sin(t), Math.sin(e)];
1071
1071
  }
1072
- function X(o) {
1073
- const [e, t, i] = o, n = U(Math.asin(i));
1072
+ function X(s) {
1073
+ const [e, t, i] = s, n = U(Math.asin(i));
1074
1074
  return [U(Math.atan2(t, e)), n];
1075
1075
  }
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(B, Y) {
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
1078
  const [H, Be, Ne] = B, [Ge, Ae, Ve] = Y;
1079
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, f = d * a - c * r, p = f * c - g * h, P = u * h - f * d, y = g * d - u * c, C = 1 / Math.sqrt(Math.pow(p, 2) + Math.pow(P, 2) + Math.pow(y, 2)), m = [p * C, P * C, y * C], v = [-1 * p * 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);
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
1081
  let O;
1082
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];
1083
1083
  }
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 };
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 };
1087
1087
  }
1088
- class si extends W {
1088
+ class oi extends j {
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, (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;
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;
1091
1091
  }
1092
1092
  getSnappable(e, t) {
1093
- const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), s = { coord: void 0, minDistance: 1 / 0 };
1093
+ const i = this.clickBoundingBox.create(e), n = this.store.search(i, t), o = { 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];
@@ -1103,7 +1103,7 @@ class si extends W {
1103
1103
  let d;
1104
1104
  const c = [e.lng, e.lat];
1105
1105
  if (this.config.projection === "web-mercator" ? d = function(u, g) {
1106
- let f = [1 / 0, 1 / 0], p = 1 / 0;
1106
+ let p = [1 / 0, 1 / 0], f = 1 / 0;
1107
1107
  for (let P of g) {
1108
1108
  const y = P[0], C = P[1];
1109
1109
  let m, v = 1 / 0;
@@ -1111,24 +1111,24 @@ class si extends W {
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 } = L(D, G);
1114
+ const { x: D, y: G } = ni(x, w, I), { lng: O, lat: B } = W(D, G);
1115
1115
  m = [O, B];
1116
1116
  }
1117
- m && (v = E(I, S(m[0], m[1])), v < p && (f = m, p = v));
1117
+ m && (v = E(I, S(m[0], m[1])), v < f && (p = m, f = v));
1118
1118
  }
1119
- return p === 1 / 0 ? void 0 : { coordinate: f, distance: p };
1119
+ return f === 1 / 0 ? void 0 : { coordinate: p, distance: f };
1120
1120
  }(c, l) : this.config.projection === "globe" && (d = function(u, g) {
1121
- let f = [1 / 0, 1 / 0], p = 1 / 0;
1121
+ let p = [1 / 0, 1 / 0], f = 1 / 0;
1122
1122
  for (let P of g) {
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 < p && (f = m, p = 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 && (p = m, f = v));
1126
1126
  }
1127
- return p === 1 / 0 ? void 0 : { coordinate: f, distance: p };
1127
+ return f === 1 / 0 ? void 0 : { coordinate: p, distance: f };
1128
1128
  }(c, l)), !d) return;
1129
1129
  const h = this.pixelDistance.measure(e, d.coordinate);
1130
- h < s.minDistance && h < this.pointerDistance && (s.coord = d.coordinate, s.minDistance = h);
1131
- }), s.coord;
1130
+ h < o.minDistance && h < this.pointerDistance && (o.coord = d.coordinate, o.minDistance = h);
1131
+ }), o.coord;
1132
1132
  }
1133
1133
  }
1134
1134
  class xt extends N {
@@ -1150,7 +1150,7 @@ class xt extends N {
1150
1150
  }
1151
1151
  registerBehaviors(e) {
1152
1152
  const t = new Le(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);
1153
+ this.pixelDistance = new We(e), this.lineSnapping = new oi(e, this.pixelDistance, t), this.coordinateSnapping = new mt(e, this.pixelDistance, t), this.closingPoints = new ti(e, this.pixelDistance);
1154
1154
  }
1155
1155
  start() {
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 [s] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [De]: !0 } }]);
1168
- this.snappedPointId = s;
1167
+ const [o] = this.store.create([{ geometry: { type: "Point", coordinates: t }, properties: { mode: this.mode, [De]: !0 } }]);
1168
+ this.snappedPointId = o;
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 s = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, s);
1176
+ const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
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: 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]];
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]];
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 s;
1192
+ let o;
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 && (s = r);
1195
+ r = this.currentId ? this.lineSnapping.getSnappableCoordinate(e, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(e), r && (o = 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 && (s = r);
1199
+ r = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(e, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(e), r && (o = r);
1200
1200
  }
1201
- return (n = this.snapping) != null && n.toCustom && (s = this.snapping.toCustom(e)), s;
1201
+ return (n = this.snapping) != null && n.toCustom && (o = this.snapping.toCustom(e)), o;
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 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;
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;
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]]]);
@@ -1369,44 +1369,44 @@ class ie extends N {
1369
1369
  return t;
1370
1370
  }
1371
1371
  }
1372
- function Ce(o, e) {
1373
- const t = o, i = e, n = _(t[1]), s = _(i[1]);
1372
+ function Ce(s, e) {
1373
+ const t = s, i = e, n = _(t[1]), o = _(i[1]);
1374
1374
  let r = _(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(s / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), l = (U(Math.atan2(r, a)) + 360) % 360;
1376
+ const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), l = (U(Math.atan2(r, a)) + 360) % 360;
1377
1377
  return l > 180 ? -(360 - l) : l;
1378
1378
  }
1379
- function je(o, e, t) {
1379
+ function je(s, e, t) {
1380
1380
  let i = e;
1381
1381
  e < 0 && (i = -Math.abs(i));
1382
- const n = i / Oe, s = o[0] * Math.PI / 180, r = _(o[1]), a = _(t), l = n * Math.cos(a);
1382
+ const n = i / Oe, o = s[0] * Math.PI / 180, r = _(s[1]), a = _(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 * (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;
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;
1387
1387
  }
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);
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
1390
  return [F(a, t), F(l, t)];
1391
1391
  }
1392
- function oi(o, e, t) {
1393
- const i = je(o, 1e3 * V(o, e) / 2, Ce(o, e));
1392
+ function si(s, e, t) {
1393
+ const i = je(s, 1e3 * V(s, e) / 2, Ce(s, e));
1394
1394
  return [F(i[0], t), F(i[1], t)];
1395
1395
  }
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++) {
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++) {
1399
1399
  let a;
1400
- if (n === "web-mercator") a = Mt(o[r], o[r + 1], e, i, t);
1400
+ if (n === "web-mercator") a = Mt(s[r], s[r + 1], e, i, t);
1401
1401
  else {
1402
1402
  if (n !== "globe") throw new Error("Invalid projection");
1403
- a = oi(o[r], o[r + 1], e);
1403
+ a = si(s[r], s[r + 1], e);
1404
1404
  }
1405
- s.push(a);
1405
+ o.push(a);
1406
1406
  }
1407
- return s;
1407
+ return o;
1408
1408
  }
1409
- class ri extends W {
1409
+ class ri extends j {
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 W {
1416
1416
  set ids(e) {
1417
1417
  }
1418
1418
  insert(e, t) {
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);
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);
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, 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));
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));
1427
1427
  }
1428
1428
  delete() {
1429
1429
  this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
@@ -1432,7 +1432,7 @@ class ri extends W {
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 W {
1435
+ class ai extends j {
1436
1436
  constructor(e) {
1437
1437
  super(e), this._selectionPoints = [];
1438
1438
  }
@@ -1442,8 +1442,8 @@ class ai extends W {
1442
1442
  set ids(e) {
1443
1443
  }
1444
1444
  create(e, t, i) {
1445
- this._selectionPoints = this.store.create(function(n, s, r) {
1446
- const a = [], l = s === "Polygon" ? n.length - 1 : n.length;
1445
+ this._selectionPoints = this.store.create(function(n, o, r) {
1446
+ const a = [], l = o === "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 W {
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(o, e) {
1461
+ function wt(s, 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 = 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);
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);
1466
1466
  }
1467
- var i, n, s;
1467
+ var i, n, o;
1468
1468
  return t;
1469
1469
  }
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) => {
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) => {
1473
1473
  const l = n(r, a);
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));
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));
1478
1478
  };
1479
- class li extends W {
1479
+ class li extends j {
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, s, r, a = 1 / 0, l = 1 / 0, d = 1 / 0;
1484
+ let i, n, o, 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], f = g.geometry;
1488
- if (f.type === "Point") {
1489
- if (g.properties.selectionPoint || !t && g.properties[oe]) continue;
1490
- const p = this.pixelDistance.measure(e, f.coordinates);
1491
- g.properties[oe] && p < this.pointerDistance && p < d ? (d = p, s = g) : !g.properties[oe] && p < this.pointerDistance && p < a && (a = p, i = g);
1492
- } else if (f.type === "LineString") {
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") {
1493
1493
  if (i) continue;
1494
- for (let p = 0; p < f.coordinates.length - 1; p++) {
1495
- const P = f.coordinates[p], y = f.coordinates[p + 1], C = bt({ x: e.containerX, y: e.containerY }, this.project(P[0], P[1]), this.project(y[0], y[1]));
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
1496
  C < this.pointerDistance && C < l && (l = C, n = g);
1497
1497
  }
1498
- } else if (f.type === "Polygon") {
1498
+ } else if (p.type === "Polygon") {
1499
1499
  if (i || n) continue;
1500
- wt([e.lng, e.lat], f.coordinates) && (r = g);
1500
+ wt([e.lng, e.lat], p.coordinates) && (r = g);
1501
1501
  }
1502
1502
  }
1503
- return { clickedFeature: i || n || r, clickedMidPoint: s };
1503
+ return { clickedFeature: i || n || r, clickedMidPoint: o };
1504
1504
  }
1505
1505
  }
1506
- class di extends W {
1506
+ class di extends j {
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 W {
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 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;
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;
1529
1529
  for (let d = 0; d < r; d++) {
1530
- const c = s[d];
1530
+ const c = o[d];
1531
1531
  let h, u;
1532
1532
  if (this.config.projection === "web-mercator") {
1533
- const g = S(this.dragPosition[0], this.dragPosition[1]), f = S(n[0], n[1]), p = S(c[0], c[1]), P = { x: g.x - f.x, y: g.y - f.y }, y = p.x - P.x, C = p.y - P.y, { lng: m, lat: v } = L(y, C);
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);
1534
1534
  h = m, u = v;
1535
1535
  } else {
1536
1536
  const g = [this.dragPosition[0] - n[0], this.dragPosition[1] - n[1]];
1537
1537
  h = c[0] - g[0], u = c[1] - g[1];
1538
1538
  }
1539
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
- s[d] = [h, u];
1540
+ o[d] = [h, u];
1541
1541
  }
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) || [];
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) || [];
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 W {
1549
+ class ci extends j {
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 W {
1558
1558
  if (t.type !== "Polygon") return i;
1559
1559
  n = t.coordinates[0];
1560
1560
  }
1561
- for (let s = 0; s < n.length; s++) {
1562
- const r = this.pixelDistance.measure(e, n[s]);
1561
+ for (let o = 0; o < n.length; o++) {
1562
+ const r = this.pixelDistance.measure(e, n[o]);
1563
1563
  if (r < this.pointerDistance && r < i.dist) {
1564
- const a = t.type === "Polygon" && (s === n.length - 1 || s === 0);
1565
- i.dist = r, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
1564
+ const a = t.type === "Polygon" && (o === n.length - 1 || o === 0);
1565
+ i.dist = r, i.index = a ? 0 : o, i.isFirstOrLastPolygonCoord = a;
1566
1566
  }
1567
1567
  }
1568
1568
  return i;
@@ -1573,15 +1573,15 @@ class ci extends W {
1573
1573
  }
1574
1574
  drag(e, t, i) {
1575
1575
  if (!this.draggedCoordinate.id) return !1;
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];
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];
1577
1577
  if (e.lng > 180 || e.lng < -180 || e.lat > 90 || e.lat < -90) return !1;
1578
- if (s.type !== "Polygon" || n !== r.length - 1 && n !== 0) r[n] = a;
1578
+ if (o.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 !(s.type !== "Point" && !t && ke({ 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));
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));
1585
1585
  }
1586
1586
  isDragging() {
1587
1587
  return this.draggedCoordinate.id !== null;
@@ -1593,44 +1593,44 @@ class ci extends W {
1593
1593
  this.draggedCoordinate = { id: null, index: -1 };
1594
1594
  }
1595
1595
  }
1596
- function Pe(o) {
1596
+ function Pe(s) {
1597
1597
  let e = 0, t = 0, i = 0;
1598
- return (o.geometry.type === "Polygon" ? o.geometry.coordinates[0].slice(0, -1) : o.geometry.coordinates).forEach((n) => {
1598
+ return (s.geometry.type === "Polygon" ? s.geometry.coordinates[0].slice(0, -1) : s.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(o, e) {
1603
- o[0] += o[0] - e[0] > 180 ? -360 : e[0] - o[0] > 180 ? 360 : 0;
1604
- const t = Oe, 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;
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;
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 ? s / a : Math.cos(i);
1608
- return Math.sqrt(s * s + 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 ? o / a : Math.cos(i);
1608
+ return Math.sqrt(o * o + l * l * r * r) * t;
1609
1609
  }
1610
- function ve(o) {
1611
- const e = (o.geometry.type === "Polygon" ? o.geometry.coordinates[0] : o.geometry.coordinates).map((t) => {
1610
+ function ve(s) {
1611
+ const e = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.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 o.geometry.type === "Polygon" ? function(t) {
1616
- let i = 0, n = 0, s = 0;
1615
+ return s.geometry.type === "Polygon" ? function(t) {
1616
+ let i = 0, n = 0, o = 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, s += (d + h) * u;
1620
+ i += u, n += (l + c) * u, o += (d + h) * u;
1621
1621
  }
1622
- return i /= 2, n /= 6 * i, s /= 6 * i, { x: n, y: s };
1622
+ return i /= 2, n /= 6 * i, o /= 6 * i, { x: n, y: o };
1623
1623
  }(e) : function(t) {
1624
1624
  const i = t.length;
1625
- let n = 0, s = 0;
1625
+ let n = 0, o = 0;
1626
1626
  for (let r = 0; r < i; r++) {
1627
1627
  const [a, l] = t[r];
1628
- n += a, s += l;
1628
+ n += a, o += l;
1629
1629
  }
1630
- return { x: n / i, y: s / i };
1630
+ return { x: n / i, y: o / i };
1631
1631
  }(e);
1632
1632
  }
1633
- class hi extends W {
1633
+ class hi extends j {
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,27 +1640,27 @@ class hi extends W {
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 s = [e.lng, e.lat];
1643
+ const o = [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
1647
  if (r = A(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, f = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([y, C]) => S(y, C)), p = f.reduce((y, C) => ({ x: y.x + C.x, y: y.y + C.y }), { x: 0, y: 0 });
1651
- p.x /= f.length, p.y /= f.length;
1652
- const P = f.map((y) => ({ x: p.x + (y.x - p.x) * Math.cos(g) - (y.y - p.y) * Math.sin(g), y: p.y + (y.x - p.x) * Math.sin(g) + (y.y - p.y) * Math.cos(g) })).map(({ x: y, y: C }) => [L(y, C).lng, L(y, C).lat]);
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]);
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: {} }), s), !this.lastBearing) return void (this.lastBearing = r + 180);
1657
+ if (r = Ce(Pe({ type: "Feature", geometry: n, properties: {} }), o), !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
1660
  const g = Pe(h);
1661
- (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((f) => {
1662
- const p = Ce(g, f) + u, P = It(g, f), y = je(g, P, p);
1663
- f[0] = y[0], f[1] = y[1];
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];
1664
1664
  });
1665
1665
  })(a, -(this.lastBearing - (r + 180)));
1666
1666
  }
@@ -1673,7 +1673,7 @@ class hi extends W {
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 W {
1676
+ class ui extends j {
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,7 +1683,7 @@ class ui extends W {
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 s = [e.lng, e.lat], r = { type: "Feature", geometry: n, properties: {} };
1686
+ const o = [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") {
@@ -1691,20 +1691,20 @@ class ui extends W {
1691
1691
  a = E(l, g);
1692
1692
  } else {
1693
1693
  if (this.config.projection !== "globe") throw new Error("Invalid projection");
1694
- a = V(Pe({ type: "Feature", geometry: n, properties: {} }), s);
1694
+ a = V(Pe({ type: "Feature", geometry: n, properties: {} }), o);
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: f } = L(l.x, l.y);
1700
- (function(p, P, y) {
1701
- if (P === 1) return p;
1702
- const C = (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.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 }) => [L(x, w).lng, L(x, w).lat]);
1703
- p.geometry.type === "Polygon" ? p.geometry.coordinates[0] = v : p.geometry.coordinates = v;
1704
- })(r, d, [g, f]);
1705
- } else this.config.projection === "globe" && function(g, f, p, P = "xy") {
1706
- f === 1 || (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.geometry.coordinates).forEach((y) => {
1707
- const C = It(p, y), m = Ce(p, y), v = je(p, C * f, m);
1699
+ const { lng: g, lat: p } = W(l.x, l.y);
1700
+ (function(f, P, y) {
1701
+ if (P === 1) return f;
1702
+ const C = (f.geometry.type === "Polygon" ? f.geometry.coordinates[0] : f.geometry.coordinates).map(([x, w]) => S(x, w)), m = S(y[0], y[1]), v = C.map((x) => ({ x: m.x + (x.x - m.x) * P, y: m.y + (x.y - m.y) * P })).map(({ x, y: w }) => [W(x, w).lng, W(x, w).lat]);
1703
+ f.geometry.type === "Polygon" ? f.geometry.coordinates[0] = v : f.geometry.coordinates = v;
1704
+ })(r, d, [g, p]);
1705
+ } else this.config.projection === "globe" && function(g, p, f, P = "xy") {
1706
+ p === 1 || (g.geometry.type === "Polygon" ? g.geometry.coordinates[0] : g.geometry.coordinates).forEach((y) => {
1707
+ const C = It(f, y), m = Ce(f, y), v = je(f, C * p, m);
1708
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));
@@ -1717,7 +1717,7 @@ class ui extends W {
1717
1717
  this.store.updateGeometry([{ id: t, geometry: n }, ...u, ...h]), this.lastDistance = a;
1718
1718
  }
1719
1719
  }
1720
- class gi extends W {
1720
+ class gi extends j {
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 W {
1729
1729
  if (t.type !== "Polygon") return i;
1730
1730
  n = t.coordinates[0];
1731
1731
  }
1732
- for (let s = 0; s < n.length; s++) {
1733
- const r = this.pixelDistance.measure(e, n[s]);
1732
+ for (let o = 0; o < n.length; o++) {
1733
+ const r = this.pixelDistance.measure(e, n[o]);
1734
1734
  if (r < this.pointerDistance && r < i.dist) {
1735
- const a = t.type === "Polygon" && (s === n.length - 1 || s === 0);
1736
- i.dist = r, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
1735
+ const a = t.type === "Polygon" && (o === n.length - 1 || o === 0);
1736
+ i.dist = r, i.index = a ? 0 : o, i.isFirstOrLastPolygonCoord = a;
1737
1737
  }
1738
1738
  }
1739
1739
  return i;
@@ -1776,43 +1776,43 @@ class gi extends W {
1776
1776
  centerWebMercatorDrag(e) {
1777
1777
  const t = this.getSelectedFeatureDataWebMercator();
1778
1778
  if (!t) return null;
1779
- const { feature: i, boundingBox: n, updatedCoords: s, selectedCoordinate: r } = t, a = ve(i);
1779
+ const { feature: i, boundingBox: n, updatedCoords: o, 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: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1782
+ return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), o;
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: s, selectedCoordinate: r } = t, a = ve(i);
1787
+ const { feature: i, boundingBox: n, updatedCoords: o, 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: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1790
+ return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), o;
1791
1791
  }
1792
- scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: s }) {
1792
+ scaleFixedWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: o }) {
1793
1793
  if (!this.isValidDragWebMercator(e, t.x - n.x, t.y - n.y)) return null;
1794
1794
  let r = E(t, n) / E(t, i);
1795
- return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(s, t.x, t.y, r, r), s;
1795
+ return r < 0 && (r = this.minimumScale), this.performWebMercatorScale(o, t.x, t.y, r, r), o;
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: 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);
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);
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: 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);
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);
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: s }) {
1809
+ scaleWebMercator({ closestBBoxIndex: e, webMercatorOrigin: t, webMercatorSelected: i, webMercatorCursor: n, updatedCoords: o }) {
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(s, t.x, t.y, l, d), s) : 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(o, t.x, t.y, l, d), o) : null;
1816
1816
  }
1817
1817
  getFeature(e) {
1818
1818
  if (this.draggedCoordinate.id === null) return null;
@@ -1826,9 +1826,9 @@ class gi extends W {
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, s) {
1829
+ performWebMercatorScale(e, t, i, n, o) {
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) * s, { lng: h, lat: u } = L(d, c);
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);
1832
1832
  r[0] = h, r[1] = u;
1833
1833
  });
1834
1834
  }
@@ -1840,14 +1840,14 @@ class gi extends W {
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, 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]];
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]];
1845
1845
  }
1846
1846
  getIndexesWebMercator(e, t) {
1847
1847
  let i, n = 1 / 0;
1848
- for (let s = 0; s < e.length; s++) {
1849
- const r = E({ x: t.x, y: t.y }, { x: e[s][0], y: e[s][1] });
1850
- r < n && (i = s, n = r);
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);
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,13 +1869,13 @@ class gi extends W {
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 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];
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
1876
  if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !xe(c, this.coordinatePrecision)) return !1;
1877
1877
  }
1878
- const r = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: n.geometry.type, coordinates: n.geometry.type === "Polygon" ? [s] : s };
1878
+ const r = this.midPoints.getUpdated(o) || [], a = this.selectionPoints.getUpdated(o) || [], l = { type: n.geometry.type, coordinates: n.geometry.type === "Polygon" ? [o] : o };
1879
1879
  return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: l, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: b.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...r]), 0));
1880
1880
  }
1881
1881
  }
@@ -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 s = e.flags[n].feature;
1894
- s && s.validation && (this.validations[n] = s.validation);
1893
+ const o = e.flags[n].feature;
1894
+ o && o.validation && (this.validations[n] = o.validation);
1895
1895
  }
1896
1896
  }
1897
1897
  selectFeature(e) {
@@ -1921,7 +1921,7 @@ class pi extends Rt {
1921
1921
  const u = this.store.getGeometryCopy(h), g = this.pixelDistance.measure(e, u.coordinates);
1922
1922
  g < this.pointerDistance && g < i && (i = g, t = this.store.getPropertiesCopy(h));
1923
1923
  }), !t) return;
1924
- const n = t.selectionPointFeatureId, s = t.index, r = this.store.getPropertiesCopy(n), a = this.flags[r.mode], l = this.validations[r.mode];
1924
+ const n = t.selectionPointFeatureId, o = 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" && 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;
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;
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 s = this.selected[0];
1941
- if (s) {
1942
- if (s === e) return;
1940
+ const o = this.selected[0];
1941
+ if (o) {
1942
+ if (o === 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 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;
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;
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), s = this.flags[n.mode], r = (s && s.feature && s.feature.selfIntersectable) === !0;
1999
+ const n = this.store.getPropertiesCopy(i), o = this.flags[n.mode], r = (o && o.feature && o.feature.selfIntersectable) === !0;
2000
2000
  if (this.dragEventCount++, this.dragEventCount % this.dragEventThrottle == 0) return;
2001
2001
  const a = this.validations[n.mode];
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) {
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) {
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, s.feature.coordinates.resizable, a);
2006
+ return t(!1), void this.dragCoordinateResizeFeature.drag(e, o.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((s) => {
2017
+ this.midPoints.ids.forEach((o) => {
2018
2018
  if (t) return;
2019
- const r = this.store.getGeometryCopy(s);
2019
+ const r = this.store.getGeometryCopy(o);
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((s) => {
2024
- const r = this.store.getGeometryCopy(s);
2023
+ if (this.selectionPoints.ids.forEach((o) => {
2024
+ const r = this.store.getGeometryCopy(o);
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);
@@ -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(o, e, t, i, n) {
2071
+ function Ft(s, e, t, i, n) {
2072
2072
  for (; i > t; ) {
2073
2073
  if (i - t > 600) {
2074
2074
  const l = i - t + 1, d = e - t + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
2075
- Ft(o, e, Math.max(t, Math.floor(e - d * h / l + u)), Math.min(i, Math.floor(e + (l - d) * h / l + u)), n);
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);
2076
2076
  }
2077
- const s = o[e];
2077
+ const o = s[e];
2078
2078
  let r = t, a = i;
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--;
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--;
2082
2082
  }
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);
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);
2084
2084
  }
2085
2085
  }
2086
- function te(o, e, t) {
2087
- const i = o[e];
2088
- o[e] = o[t], o[t] = i;
2086
+ function te(s, e, t) {
2087
+ const i = s[e];
2088
+ s[e] = s[t], s[t] = i;
2089
2089
  }
2090
- function q(o, e) {
2091
- ne(o, 0, o.children.length, e, o);
2090
+ function q(s, e) {
2091
+ ne(s, 0, s.children.length, e, s);
2092
2092
  }
2093
- function ne(o, e, t, i, n) {
2093
+ function ne(s, 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 s = e; s < t; s++) {
2096
- const r = o.children[s];
2097
- se(n, o.leaf ? i(r) : r);
2095
+ for (let o = e; o < t; o++) {
2096
+ const r = s.children[o];
2097
+ oe(n, s.leaf ? i(r) : r);
2098
2098
  }
2099
2099
  return n;
2100
2100
  }
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;
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;
2103
2103
  }
2104
- function yi(o, e) {
2105
- return o.minX - e.minX;
2104
+ function yi(s, e) {
2105
+ return s.minX - e.minX;
2106
2106
  }
2107
- function mi(o, e) {
2108
- return o.minY - e.minY;
2107
+ function mi(s, e) {
2108
+ return s.minY - e.minY;
2109
2109
  }
2110
- function Ie(o) {
2111
- return (o.maxX - o.minX) * (o.maxY - o.minY);
2110
+ function Ie(s) {
2111
+ return (s.maxX - s.minX) * (s.maxY - s.minY);
2112
2112
  }
2113
- function ge(o) {
2114
- return o.maxX - o.minX + (o.maxY - o.minY);
2113
+ function ge(s) {
2114
+ return s.maxX - s.minX + (s.maxY - s.minY);
2115
2115
  }
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);
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);
2119
2119
  }
2120
- function Fe(o, e) {
2121
- return o.minX <= e.minX && o.minY <= e.minY && e.maxX <= o.maxX && e.maxY <= o.maxY;
2120
+ function Fe(s, e) {
2121
+ return s.minX <= e.minX && s.minY <= e.minY && e.maxX <= s.maxX && e.maxY <= s.maxY;
2122
2122
  }
2123
- function pe(o, e) {
2124
- return e.minX <= o.maxX && e.minY <= o.maxY && e.maxX >= o.minX && e.maxY >= o.minY;
2123
+ function pe(s, e) {
2124
+ return e.minX <= s.maxX && e.minY <= s.maxY && e.maxX >= s.minX && e.maxY >= s.minY;
2125
2125
  }
2126
- function Z(o) {
2127
- return { children: o, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
2126
+ function Z(s) {
2127
+ return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
2128
2128
  }
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;
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;
2133
2133
  const r = e + Math.ceil((t - e) / i / 2) * i;
2134
- Ft(o, r, e, t, n), s.push(e, r, r, t);
2134
+ Ft(s, r, e, t, n), o.push(e, r, r, t);
2135
2135
  }
2136
2136
  }
2137
2137
  class Pi {
@@ -2142,13 +2142,13 @@ class Pi {
2142
2142
  let t = this.data;
2143
2143
  const i = [];
2144
2144
  if (!pe(e, t)) return i;
2145
- const n = this.toBBox, s = [];
2145
+ const n = this.toBBox, o = [];
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) : s.push(a));
2149
+ pe(e, l) && (t.leaf ? i.push(a) : Fe(e, l) ? this._all(a, i) : o.push(a));
2150
2150
  }
2151
- t = s.pop();
2151
+ t = o.pop();
2152
2152
  }
2153
2153
  return i;
2154
2154
  }
@@ -2158,10 +2158,10 @@ class Pi {
2158
2158
  const i = [];
2159
2159
  for (; t; ) {
2160
2160
  for (let n = 0; n < t.children.length; n++) {
2161
- const s = t.children[n], r = t.leaf ? this.toBBox(s) : s;
2161
+ const o = t.children[n], r = t.leaf ? this.toBBox(o) : o;
2162
2162
  if (pe(e, r)) {
2163
2163
  if (t.leaf || Fe(e, r)) return !0;
2164
- i.push(s);
2164
+ i.push(o);
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 = [], s = [];
2196
+ const i = this.toBBox(e), n = [], o = [];
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 = s.pop(), l = !0), t.leaf) {
2199
+ if (t || (t = n.pop(), a = n[n.length - 1], r = o.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), s.push(r), r = 0, a = t, t = t.children[0]);
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]);
2204
2204
  }
2205
2205
  }
2206
2206
  toBBox(e) {
@@ -2218,15 +2218,15 @@ class Pi {
2218
2218
  return t;
2219
2219
  }
2220
2220
  _build(e, t, i, n) {
2221
- const s = i - t + 1;
2221
+ const o = i - t + 1;
2222
2222
  let r, a = this._maxEntries;
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);
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);
2227
2227
  for (let c = t; c <= i; c += d) {
2228
2228
  const h = Math.min(c + d - 1, i);
2229
- st(e, c, h, l, this.compareMinY);
2229
+ ot(e, c, h, l, this.compareMinY);
2230
2230
  for (let u = c; u <= h; u += l) {
2231
2231
  const g = Math.min(u + l - 1, h);
2232
2232
  r.children.push(this._build(e, u, g, n - 1));
@@ -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 = (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);
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
2242
  g < d ? (d = g, l = u < l ? u : l, a = h) : g === d && u < l && (l = u, a = h);
2243
2243
  }
2244
2244
  t = a || t.children[0];
2245
2245
  }
2246
- var s, r;
2246
+ var o, r;
2247
2247
  return t;
2248
2248
  }
2249
2249
  _insert(e, t, i) {
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);
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);
2253
2253
  }
2254
2254
  _split(e, t) {
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));
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));
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, s = 1 / 0, r = 1 / 0;
2264
+ let n, o = 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 < s ? (s = c, n = a, r = h < r ? h : r) : c === s && h < r && (r = h, n = a);
2267
+ c < o ? (o = c, n = a, r = h < r ? h : r) : c === o && 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, s = e.leaf ? this.compareMinY : mi;
2273
- this._allDistMargin(e, t, i, n) < this._allDistMargin(e, t, i, s) && e.children.sort(n);
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);
2274
2274
  }
2275
2275
  _allDistMargin(e, t, i, n) {
2276
2276
  e.children.sort(n);
2277
- const s = this.toBBox, r = ne(e, 0, t, s), a = ne(e, i - t, i, s);
2277
+ const o = this.toBBox, r = ne(e, 0, t, o), a = ne(e, i - t, i, o);
2278
2278
  let l = ge(r) + ge(a);
2279
2279
  for (let d = t; d < i - t; d++) {
2280
2280
  const c = e.children[d];
2281
- se(r, e.leaf ? s(c) : c), l += ge(r);
2281
+ oe(r, e.leaf ? o(c) : c), l += ge(r);
2282
2282
  }
2283
2283
  for (let d = i - t - 1; d >= t; d--) {
2284
2284
  const c = e.children[d];
2285
- se(a, e.leaf ? s(c) : c), l += ge(a);
2285
+ oe(a, e.leaf ? o(c) : c), l += ge(a);
2286
2286
  }
2287
2287
  return l;
2288
2288
  }
2289
2289
  _adjustParentBBoxes(e, t, i) {
2290
- for (let n = i; n >= 0; n--) se(t[n], e);
2290
+ for (let n = i; n >= 0; n--) oe(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 s = Math.min(...i), r = Math.max(...i);
2314
- return { minX: Math.min(...t), minY: s, maxX: Math.max(...t), maxY: r };
2313
+ const o = Math.min(...i), r = Math.max(...i);
2314
+ return { minX: Math.min(...t), minY: o, 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 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);
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);
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(o) {
2349
+ const xi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
2350
2350
  const e = 16 * Math.random() | 0;
2351
- return (o == "x" ? e : 3 & e | 8).toString(16);
2352
- }), isValidId: (o) => typeof o == "string" && o.length === 36 };
2351
+ return (s == "x" ? e : 3 & e | 8).toString(16);
2352
+ }), isValidId: (s) => typeof s == "string" && s.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 = [], s = [];
2370
+ const n = [], o = [];
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 s.push({ id: a, valid: !1, reason: l.reason }), !1;
2376
+ if (!l.valid) return o.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 s.push({ id: r.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2380
+ if (!He(r.properties.createdAt)) return o.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 s.push({ id: r.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2383
+ if (!He(r.properties.updatedAt)) return o.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) ? (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;
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;
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: s }) => {
2410
+ e.forEach(({ id: i, property: n, value: o }) => {
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] = s, this.tracked && (r.properties.updatedAt = +/* @__PURE__ */ new Date());
2413
+ t.push(i), r.properties[n] = o, 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 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());
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());
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 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 });
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 });
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,9 +2447,9 @@ 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 = (o) => o.geometry.type !== "Polygon" && o.geometry.type !== "LineString" ? { valid: !1, reason: Mi } : ke(o) ? { valid: !1, reason: wi } : { valid: !0 };
2451
- function ot(o, e, t) {
2452
- const i = A(o, e);
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
2453
  let n = A(e, t) - i;
2454
2454
  return n < 0 && (n += 360), 180 - Math.abs(n - 90 - 90);
2455
2455
  }
@@ -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), s = Math.max(1e-6, n);
2483
- i = [t[0], [e.lng, e.lat], [e.lng, e.lat - s], t[0]];
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]];
2484
2484
  } else if (this.currentCoordinate === 2) {
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 = E(c, a) < E(c, d), u = ot(a, l, c), g = h ? 90 - u : ot(a, l, c) - 90, f = E(l, c), p = Math.cos(_(g)) * f, P = A(a, d) + (function(x, w, I) {
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
2486
  const D = (I.x - w.x) * (x.y - w.y) - (I.y - w.y) * (x.x - w.x);
2487
2487
  return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
2488
- }(a, d, c) === "right" ? -90 : 90), y = le(a, p, P), C = le(d, p, P), m = L(y.x, y.y), v = L(C.x, C.y);
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);
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,8 +2530,8 @@ class Et extends N {
2530
2530
  return this.validateModeFeature(e, (t) => de(t, this.coordinatePrecision));
2531
2531
  }
2532
2532
  }
2533
- function _t(o, e, t) {
2534
- return (e.x - o.x) * (t.y - o.y) - (e.y - o.y) * (t.x - o.x) <= 0;
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;
2535
2535
  }
2536
2536
  class Dt extends N {
2537
2537
  constructor(e) {
@@ -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), s = Math.max(1e-6, n);
2564
- i = [t[0], [e.lng, e.lat], [e.lng, e.lat - s], t[0]];
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]];
2565
2565
  } else if (this.currentCoordinate === 2) {
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]);
2566
+ const n = t[0], o = t[1], r = [e.lng, e.lat], a = S(n[0], n[1]), l = S(o[0], o[1]), d = S(r[0], r[1]);
2567
2567
  if (this.direction === void 0) {
2568
2568
  const m = _t(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, f = [n], p = K(h), P = K(u);
2571
+ const c = E(a, l), h = A(a, l), u = A(a, d), g = this.arcPoints, p = [n], f = K(h), P = K(u);
2572
2572
  let y;
2573
- this.direction === "anticlockwise" ? (y = P - p, y < 0 && (y += 360)) : (y = p - P, y < 0 && (y += 360));
2573
+ this.direction === "anticlockwise" ? (y = P - f, y < 0 && (y += 360)) : (y = f - P, y < 0 && (y += 360));
2574
2574
  const C = (this.direction === "anticlockwise" ? 1 : -1) * y / g;
2575
- f.push(s);
2575
+ p.push(o);
2576
2576
  for (let m = 0; m <= g; m++) {
2577
- const v = le(a, c, p + m * C), { lng: x, lat: w } = L(v.x, v.y), I = [F(x, this.coordinatePrecision), F(w, this.coordinatePrecision)];
2578
- I[0] !== f[f.length - 1][0] && I[1] !== f[f.length - 1][1] && f.push(I);
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);
2579
2579
  }
2580
- f.push(n), i = [...f];
2580
+ p.push(n), i = [...p];
2581
2581
  }
2582
2582
  i && this.updatePolygonGeometry(this.currentId, i, b.Provisional);
2583
2583
  }
@@ -2646,28 +2646,28 @@ class Ot extends N {
2646
2646
  onMouseMove(e) {
2647
2647
  if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
2648
2648
  if (this.currentCoordinate === 2) {
2649
- const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], s = [e.lng, e.lat], r = S(n[0], n[1]), a = S(s[0], s[1]), l = S(i[0], i[1]), d = E(l, r);
2649
+ const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], o = [e.lng, e.lat], r = S(n[0], n[1]), a = S(o[0], o[1]), l = S(i[0], i[1]), d = E(l, r);
2650
2650
  if (this.direction === void 0) {
2651
2651
  const C = _t(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], f = K(c), p = K(h);
2654
+ const c = A(l, r), h = A(l, a), u = this.arcPoints, g = [n], p = K(c), f = K(h);
2655
2655
  let P;
2656
- this.direction === "anticlockwise" ? (P = p - f, P < 0 && (P += 360)) : (P = f - p, P < 0 && (P += 360));
2656
+ this.direction === "anticlockwise" ? (P = f - p, P < 0 && (P += 360)) : (P = p - 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, f + C * y), { lng: v, lat: x } = L(m.x, m.y), w = [F(v, this.coordinatePrecision), F(x, this.coordinatePrecision)];
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
2660
  w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
2661
2661
  }
2662
2662
  this.updateLineStringGeometry(this.currentInitialArcId, g, b.Provisional);
2663
2663
  } else if (this.currentCoordinate === 3) {
2664
2664
  const t = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2665
2665
  if (t.length < 2 || !this.direction) return;
2666
- const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], 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 = E(d, a), h = E(d, r) < c ? a : r, u = A(d, r), g = A(d, a), f = A(d, l), p = K(g), P = K(f), y = K(u);
2667
- if (this.notInSector({ normalizedCursor: y, normalizedStart: p, normalizedEnd: P, direction: this.direction })) return;
2668
- const C = this.getDeltaBearing(this.direction, p, P), m = this.arcPoints, v = (this.direction === "anticlockwise" ? 1 : -1) * C / m, x = E(d, h), w = [];
2666
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, n = t[0], o = t[t.length - 1], r = S(e.lng, e.lat), a = S(n[0], n[1]), l = S(o[0], o[1]), d = S(i[0], i[1]), c = E(d, a), h = E(d, r) < c ? a : r, u = A(d, r), g = A(d, a), p = A(d, l), f = K(g), P = K(p), y = K(u);
2667
+ if (this.notInSector({ normalizedCursor: y, normalizedStart: f, normalizedEnd: P, direction: this.direction })) return;
2668
+ const C = this.getDeltaBearing(this.direction, f, P), m = this.arcPoints, v = (this.direction === "anticlockwise" ? 1 : -1) * C / m, x = E(d, h), w = [];
2669
2669
  for (let I = 0; I <= m; I++) {
2670
- const D = le(d, x, p + I * v), { lng: G, lat: O } = L(D.x, D.y), B = [F(G, this.coordinatePrecision), F(O, this.coordinatePrecision)];
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
2671
  B[0] !== t[t.length - 1][0] && B[1] !== t[t.length - 1][1] && w.unshift(B);
2672
2672
  }
2673
2673
  t.push(...w), t.push(t[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, t, b.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [t] }, properties: { mode: this.mode } }]);
@@ -2738,7 +2738,7 @@ class Ii {
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 s = (c) => {
2741
+ const o = (c) => {
2742
2742
  const h = [], u = this._store.copyAll().filter((g) => !c.includes(g.id) || (h.push(g), !1));
2743
2743
  return { changed: h, unchanged: u };
2744
2744
  }, r = (c, h) => {
@@ -2747,24 +2747,24 @@ class Ii {
2747
2747
  });
2748
2748
  }, a = (c, h) => {
2749
2749
  if (!this._enabled) return;
2750
- this._eventListeners.change.forEach((f) => {
2751
- f(c, h);
2750
+ this._eventListeners.change.forEach((p) => {
2751
+ p(c, h);
2752
2752
  });
2753
- const { changed: u, unchanged: g } = s(c);
2753
+ const { changed: u, unchanged: g } = o(c);
2754
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());
2755
2755
  }, l = (c) => {
2756
2756
  if (!this._enabled) return;
2757
2757
  this._eventListeners.select.forEach((g) => {
2758
2758
  g(c);
2759
2759
  });
2760
- const { changed: h, unchanged: u } = s([c]);
2760
+ const { changed: h, unchanged: u } = o([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
2764
  this._eventListeners.deselect.forEach((g) => {
2765
2765
  g();
2766
2766
  });
2767
- const { changed: h, unchanged: u } = s([c]);
2767
+ const { changed: h, unchanged: u } = o([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) => {
@@ -2781,9 +2781,9 @@ class Ii {
2781
2781
  }), e;
2782
2782
  }
2783
2783
  featuresAtLocation({ lng: e, lat: t }, i) {
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 });
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 });
2785
2785
  return this._store.search(d).filter((c) => {
2786
- if (s && (c.properties[oe] || c.properties.selectionPoint)) return !1;
2786
+ if (o && (c.properties[se] || c.properties.selectionPoint)) return !1;
2787
2787
  if (c.geometry.type === "Point") {
2788
2788
  const h = c.geometry.coordinates, u = a(h[0], h[1]);
2789
2789
  return E(l, u) < n;
@@ -2791,8 +2791,8 @@ class Ii {
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], f = h[u + 1];
2795
- if (bt(l, a(g[0], g[1]), a(f[0], f[1])) < n) return !0;
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;
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 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" };
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" };
2853
2853
  }
2854
2854
  return { id: t.id, valid: !1, reason: "Mode property does not exist" };
2855
2855
  });
@@ -3055,6 +3055,13 @@ const Ri = [
3055
3055
  "",
3056
3056
  ["concat", `
3057
3057
  (`, ["to-string", ["get", "total"]], " ", ["get", "unit"], ")"]
3058
+ ],
3059
+ [
3060
+ "case",
3061
+ ["all", ["has", "elevation"], [">", ["get", "elevation"], 0]],
3062
+ ["concat", `
3063
+ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3064
+ ""
3058
3065
  ]
3059
3066
  ],
3060
3067
  "symbol-placement": "point",
@@ -3243,14 +3250,14 @@ class Di {
3243
3250
  * @param options Plugin control options
3244
3251
  */
3245
3252
  constructor(e) {
3246
- j(this, "controlContainer");
3247
- j(this, "map");
3248
- j(this, "modeButtons", {});
3249
- j(this, "isExpanded", !1);
3250
- j(this, "terradraw");
3251
- j(this, "options", Fi);
3252
- j(this, "events", {});
3253
- j(this, "defaultMode", "render");
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");
3254
3261
  this.modeButtons = {}, e && (this.options = Object.assign(this.options, e));
3255
3262
  }
3256
3263
  /**
@@ -3266,12 +3273,12 @@ class Di {
3266
3273
  * @returns HTML Element
3267
3274
  */
3268
3275
  onAdd(e) {
3269
- var n, s, r, a, l;
3276
+ var n, o, r, a, l;
3270
3277
  if (this.options && this.options.modes && this.options.modes.length === 0)
3271
3278
  throw new Error("At least a mode must be enabled.");
3272
3279
  this.map = e;
3273
3280
  const t = _i(), i = [];
3274
- return (s = (n = this.options) == null ? void 0 : n.modes) == null || s.forEach((d) => {
3281
+ return (o = (n = this.options) == null ? void 0 : n.modes) == null || o.forEach((d) => {
3275
3282
  if (this.options.modeOptions && this.options.modeOptions[d]) {
3276
3283
  const c = this.options.modeOptions[d];
3277
3284
  if (d === "select") {
@@ -3334,8 +3341,8 @@ class Di {
3334
3341
  */
3335
3342
  dispatchEvent(e) {
3336
3343
  this.events[e] && this.events[e].forEach((t) => {
3337
- var s, r;
3338
- const i = (s = this.terradraw) == null ? void 0 : s.getSnapshot(), n = i == null ? void 0 : i.filter((a) => a.properties.selected === !0);
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);
3339
3346
  t({ feature: n, mode: (r = this.terradraw) == null ? void 0 : r.getMode() });
3340
3347
  });
3341
3348
  }
@@ -3366,8 +3373,8 @@ class Di {
3366
3373
  var i, n;
3367
3374
  if (!this.terradraw) return;
3368
3375
  const e = document.getElementsByClassName("maplibregl-terradraw-add-control");
3369
- for (let s = 0; s < e.length; s++) {
3370
- const r = e.item(s);
3376
+ for (let o = 0; o < e.length; o++) {
3377
+ const r = e.item(o);
3371
3378
  r && (this.isExpanded ? r.classList.add("hidden") : r.classList.remove("hidden"));
3372
3379
  }
3373
3380
  const t = document.getElementsByClassName("maplibregl-terradraw-render-button");
@@ -3396,9 +3403,9 @@ class Di {
3396
3403
  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", () => {
3397
3404
  this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
3398
3405
  })) : e === "delete-selection" ? (t.classList.add(`maplibregl-terradraw-${e}-button`), t.classList.add("hidden-delete-selection"), t.addEventListener("click", () => {
3399
- var s;
3406
+ var o;
3400
3407
  if (!this.terradraw || !this.terradraw.enabled) return;
3401
- const n = ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((r) => r.properties.selected === !0);
3408
+ const n = ((o = this.terradraw) == null ? void 0 : o.getSnapshot()).filter((r) => r.properties.selected === !0);
3402
3409
  if (n.length > 0) {
3403
3410
  const r = this.terradraw.getMode();
3404
3411
  this.terradraw.setMode(this.defaultMode);
@@ -3418,11 +3425,11 @@ class Di {
3418
3425
  * @returns FeatureCollection in GeoJSON format
3419
3426
  */
3420
3427
  getFeatures(e = !1) {
3421
- var s;
3428
+ var o;
3422
3429
  if (!this.terradraw) return;
3423
3430
  const n = {
3424
3431
  type: "FeatureCollection",
3425
- features: ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((r) => r.properties.mode !== "select")
3432
+ features: ((o = this.terradraw) == null ? void 0 : o.getSnapshot()).filter((r) => r.properties.mode !== "select")
3426
3433
  };
3427
3434
  return e !== !0 || (n.features = n.features.filter((r) => r.properties.selected === !0)), n;
3428
3435
  }
@@ -3444,9 +3451,9 @@ class Di {
3444
3451
  "maplibregl-terradraw-delete-button"
3445
3452
  ];
3446
3453
  for (const n of i) {
3447
- const s = this.controlContainer.getElementsByClassName(n);
3448
- for (let r = 0; r < s.length; r++) {
3449
- const a = s.item(r);
3454
+ const o = this.controlContainer.getElementsByClassName(n);
3455
+ for (let r = 0; r < o.length; r++) {
3456
+ const a = o.item(r);
3450
3457
  a && (a.disabled = !t);
3451
3458
  }
3452
3459
  }
@@ -3456,10 +3463,10 @@ class Di {
3456
3463
  */
3457
3464
  toggleDeleteSelectionButton() {
3458
3465
  var a, l;
3459
- 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");
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");
3460
3467
  for (let d = 0; d < r.length; d++) {
3461
3468
  const c = r.item(d);
3462
- c && (s ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
3469
+ c && (o ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
3463
3470
  }
3464
3471
  if (!n) {
3465
3472
  const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
@@ -3495,60 +3502,60 @@ var k = 63710088e-1, Oi = {
3495
3502
  radians: 1,
3496
3503
  yards: k * 1.0936
3497
3504
  };
3498
- function ki(o, e, t = {}) {
3505
+ function ki(s, e, t = {}) {
3499
3506
  const i = { type: "Feature" };
3500
- return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = o, i;
3507
+ return (t.id === 0 || t.id) && (i.id = t.id), t.bbox && (i.bbox = t.bbox), i.properties = e || {}, i.geometry = s, i;
3501
3508
  }
3502
- function Li(o, e, t = {}) {
3503
- if (!o)
3509
+ function Li(s, e, t = {}) {
3510
+ if (!s)
3504
3511
  throw new Error("coordinates is required");
3505
- if (!Array.isArray(o))
3512
+ if (!Array.isArray(s))
3506
3513
  throw new Error("coordinates must be an Array");
3507
- if (o.length < 2)
3514
+ if (s.length < 2)
3508
3515
  throw new Error("coordinates must be at least 2 numbers long");
3509
- if (!rt(o[0]) || !rt(o[1]))
3516
+ if (!rt(s[0]) || !rt(s[1]))
3510
3517
  throw new Error("coordinates must contain numbers");
3511
3518
  return ki({
3512
3519
  type: "Point",
3513
- coordinates: o
3520
+ coordinates: s
3514
3521
  }, e, t);
3515
3522
  }
3516
- function Wi(o, e = "kilometers") {
3523
+ function Wi(s, e = "kilometers") {
3517
3524
  const t = Oi[e];
3518
3525
  if (!t)
3519
3526
  throw new Error(e + " units is invalid");
3520
- return o * t;
3527
+ return s * t;
3521
3528
  }
3522
- function fe(o) {
3523
- return o % 360 * Math.PI / 180;
3529
+ function fe(s) {
3530
+ return s % 360 * Math.PI / 180;
3524
3531
  }
3525
- function rt(o) {
3526
- return !isNaN(o) && o !== null && !Array.isArray(o);
3532
+ function rt(s) {
3533
+ return !isNaN(s) && s !== null && !Array.isArray(s);
3527
3534
  }
3528
- function at(o) {
3529
- if (!o)
3535
+ function at(s) {
3536
+ if (!s)
3530
3537
  throw new Error("coord is required");
3531
- if (!Array.isArray(o)) {
3532
- if (o.type === "Feature" && o.geometry !== null && o.geometry.type === "Point")
3533
- return [...o.geometry.coordinates];
3534
- if (o.type === "Point")
3535
- return [...o.coordinates];
3536
- }
3537
- if (Array.isArray(o) && o.length >= 2 && !Array.isArray(o[0]) && !Array.isArray(o[1]))
3538
- return [...o];
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];
3539
3546
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
3540
3547
  }
3541
- function ji(o, e, t = {}) {
3542
- 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);
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);
3543
3550
  return Wi(
3544
3551
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3545
3552
  t.units
3546
3553
  );
3547
3554
  }
3548
- function kt(o, e, t) {
3549
- if (o !== null)
3550
- for (var i, n, s, r, a, l, d, c = 0, h = 0, u, g = o.type, f = g === "FeatureCollection", p = g === "Feature", P = f ? o.features.length : 1, y = 0; y < P; y++) {
3551
- d = f ? o.features[y].geometry : p ? o.geometry : o, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
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;
3552
3559
  for (var C = 0; C < a; C++) {
3553
3560
  var m = 0, v = 0;
3554
3561
  if (r = u ? d.geometries[C] : d, r !== null) {
@@ -3604,9 +3611,9 @@ function kt(o, e, t) {
3604
3611
  case "MultiPolygon":
3605
3612
  for (i = 0; i < l.length; i++) {
3606
3613
  for (v = 0, n = 0; n < l[i].length; n++) {
3607
- for (s = 0; s < l[i][n].length - c; s++) {
3614
+ for (o = 0; o < l[i][n].length - c; o++) {
3608
3615
  if (e(
3609
- l[i][n][s],
3616
+ l[i][n][o],
3610
3617
  h,
3611
3618
  y,
3612
3619
  m,
@@ -3632,11 +3639,11 @@ function kt(o, e, t) {
3632
3639
  }
3633
3640
  }
3634
3641
  }
3635
- function Bi(o, e) {
3636
- var t, i, n, s, r, a, l, d, c, h, u = 0, g = o.type === "FeatureCollection", f = o.type === "Feature", p = g ? o.features.length : 1;
3637
- for (t = 0; t < p; t++) {
3638
- for (a = g ? o.features[t].geometry : f ? o.geometry : o, d = g ? o.features[t].properties : f ? o.properties : {}, c = g ? o.features[t].bbox : f ? o.bbox : void 0, h = g ? o.features[t].id : f ? o.id : void 0, l = a ? a.type === "GeometryCollection" : !1, r = l ? a.geometries.length : 1, n = 0; n < r; n++) {
3639
- if (s = l ? a.geometries[n] : a, s === null) {
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;
3644
+ 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) {
3640
3647
  if (e(
3641
3648
  null,
3642
3649
  u,
@@ -3647,7 +3654,7 @@ function Bi(o, e) {
3647
3654
  return !1;
3648
3655
  continue;
3649
3656
  }
3650
- switch (s.type) {
3657
+ switch (o.type) {
3651
3658
  case "Point":
3652
3659
  case "LineString":
3653
3660
  case "MultiPoint":
@@ -3655,7 +3662,7 @@ function Bi(o, e) {
3655
3662
  case "MultiLineString":
3656
3663
  case "MultiPolygon": {
3657
3664
  if (e(
3658
- s,
3665
+ o,
3659
3666
  u,
3660
3667
  d,
3661
3668
  c,
@@ -3665,9 +3672,9 @@ function Bi(o, e) {
3665
3672
  break;
3666
3673
  }
3667
3674
  case "GeometryCollection": {
3668
- for (i = 0; i < s.geometries.length; i++)
3675
+ for (i = 0; i < o.geometries.length; i++)
3669
3676
  if (e(
3670
- s.geometries[i],
3677
+ o.geometries[i],
3671
3678
  u,
3672
3679
  d,
3673
3680
  c,
@@ -3683,15 +3690,15 @@ function Bi(o, e) {
3683
3690
  u++;
3684
3691
  }
3685
3692
  }
3686
- function Ni(o, e, t) {
3693
+ function Ni(s, e, t) {
3687
3694
  var i = t;
3688
3695
  return Bi(
3689
- o,
3690
- function(n, s, r, a, l) {
3691
- s === 0 && t === void 0 ? i = n : i = e(
3696
+ s,
3697
+ function(n, o, r, a, l) {
3698
+ o === 0 && t === void 0 ? i = n : i = e(
3692
3699
  i,
3693
3700
  n,
3694
- s,
3701
+ o,
3695
3702
  r,
3696
3703
  a,
3697
3704
  l
@@ -3699,21 +3706,21 @@ function Ni(o, e, t) {
3699
3706
  }
3700
3707
  ), i;
3701
3708
  }
3702
- function Gi(o) {
3709
+ function Gi(s) {
3703
3710
  return Ni(
3704
- o,
3711
+ s,
3705
3712
  (e, t) => e + Ai(t),
3706
3713
  0
3707
3714
  );
3708
3715
  }
3709
- function Ai(o) {
3716
+ function Ai(s) {
3710
3717
  let e = 0, t;
3711
- switch (o.type) {
3718
+ switch (s.type) {
3712
3719
  case "Polygon":
3713
- return lt(o.coordinates);
3720
+ return lt(s.coordinates);
3714
3721
  case "MultiPolygon":
3715
- for (t = 0; t < o.coordinates.length; t++)
3716
- e += lt(o.coordinates[t]);
3722
+ for (t = 0; t < s.coordinates.length; t++)
3723
+ e += lt(s.coordinates[t]);
3717
3724
  return e;
3718
3725
  case "Point":
3719
3726
  case "MultiPoint":
@@ -3723,32 +3730,32 @@ function Ai(o) {
3723
3730
  }
3724
3731
  return 0;
3725
3732
  }
3726
- function lt(o) {
3733
+ function lt(s) {
3727
3734
  let e = 0;
3728
- if (o && o.length > 0) {
3729
- e += Math.abs(dt(o[0]));
3730
- for (let t = 1; t < o.length; t++)
3731
- e -= Math.abs(dt(o[t]));
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]));
3732
3739
  }
3733
3740
  return e;
3734
3741
  }
3735
3742
  var Vi = k * k / 2, Ee = Math.PI / 180;
3736
- function dt(o) {
3737
- const e = o.length - 1;
3743
+ function dt(s) {
3744
+ const e = s.length - 1;
3738
3745
  if (e <= 2) return 0;
3739
3746
  let t = 0, i = 0;
3740
3747
  for (; i < e; ) {
3741
- 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] * Ee, l = s[1] * Ee, d = r[0] * Ee;
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;
3742
3749
  t += (d - a) * Math.sin(l), i++;
3743
3750
  }
3744
3751
  return t * Vi;
3745
3752
  }
3746
- function Ui(o, e = {}) {
3753
+ function Ui(s, e = {}) {
3747
3754
  let t = 0, i = 0, n = 0;
3748
3755
  return kt(
3749
- o,
3750
- function(s) {
3751
- t += s[0], i += s[1], n++;
3756
+ s,
3757
+ function(o) {
3758
+ t += o[0], i += o[1], n++;
3752
3759
  }
3753
3760
  ), Li([t / n, i / n], e.properties);
3754
3761
  }
@@ -3765,20 +3772,21 @@ class Ki extends Di {
3765
3772
  open: i.open,
3766
3773
  modeOptions: i.modeOptions
3767
3774
  });
3768
- j(this, "lineLayerLabelSpec");
3769
- j(this, "lineLayerNodeSpec");
3770
- j(this, "polygonLayerSpec");
3775
+ L(this, "lineLayerLabelSpec");
3776
+ L(this, "lineLayerNodeSpec");
3777
+ L(this, "polygonLayerSpec");
3778
+ L(this, "computeElevation");
3771
3779
  /**
3772
3780
  * Calculate area / distance and update a feature properties
3773
3781
  * @param feature GeoJSON feature
3774
3782
  * @returns updated GeoJSON feature
3775
3783
  */
3776
- j(this, "updateFeatureProperties", (t) => {
3784
+ L(this, "updateFeatureProperties", (t) => {
3777
3785
  if (!this.map || !this.map.loaded()) return t;
3778
3786
  const i = t.geometry.type;
3779
3787
  return i === "LineString" ? t = this.calcDistance(t) : i === "Polygon" && (t = this.calcArea(t)), t;
3780
3788
  });
3781
- this.lineLayerLabelSpec = i.lineLayerLabelSpec, this.lineLayerNodeSpec = i.lineLayerNodeSpec, this.polygonLayerSpec = i.polygonLayerSpec;
3789
+ this.lineLayerLabelSpec = i.lineLayerLabelSpec, this.lineLayerNodeSpec = i.lineLayerNodeSpec, this.polygonLayerSpec = i.polygonLayerSpec, this.computeElevation = i.computeElevation ?? !1;
3782
3790
  }
3783
3791
  /**
3784
3792
  * add the plugin control to maplibre
@@ -3799,14 +3807,14 @@ class Ki extends Di {
3799
3807
  * Register measure control related maplibre sources and layers
3800
3808
  */
3801
3809
  registerMesureControl() {
3802
- var n, s;
3810
+ var n, o;
3803
3811
  if (!this.map) return;
3804
3812
  const t = (n = this.options.modes) == null ? void 0 : n.filter((r) => ["linestring"].includes(r));
3805
3813
  t && t.length > 0 && (this.map.getSource(this.lineLayerLabelSpec.source) || this.map.addSource(this.lineLayerLabelSpec.source, {
3806
3814
  type: "geojson",
3807
3815
  data: { type: "FeatureCollection", features: [] }
3808
3816
  }), this.map.getLayer(this.lineLayerNodeSpec.id) || this.map.addLayer(this.lineLayerNodeSpec), this.map.getLayer(this.lineLayerLabelSpec.id) || this.map.addLayer(this.lineLayerLabelSpec));
3809
- const i = (s = this.options.modes) == null ? void 0 : s.filter(
3817
+ const i = (o = this.options.modes) == null ? void 0 : o.filter(
3810
3818
  (r) => [
3811
3819
  "polygon",
3812
3820
  "rectangle",
@@ -3851,7 +3859,7 @@ class Ki extends Di {
3851
3859
  * @returns void
3852
3860
  */
3853
3861
  clearMeasureFeatures(t, i) {
3854
- var s;
3862
+ var o;
3855
3863
  if (!this.map) return;
3856
3864
  const n = this.map.getStyle().sources[i];
3857
3865
  n && typeof n.data != "string" && n.data.type === "FeatureCollection" && (n.data.features = n.data.features.filter(
@@ -3859,7 +3867,7 @@ class Ki extends Di {
3859
3867
  var a;
3860
3868
  return ((a = r.properties) == null ? void 0 : a.originalId) !== t;
3861
3869
  }
3862
- ), (s = this.map.getSource(i)) == null || s.setData(n.data));
3870
+ ), (o = this.map.getSource(i)) == null || o.setData(n.data));
3863
3871
  }
3864
3872
  /**
3865
3873
  * Calculate area from polygon feature
@@ -3869,8 +3877,8 @@ class Ki extends Di {
3869
3877
  calcArea(t) {
3870
3878
  if (t.geometry.type !== "Polygon") return t;
3871
3879
  const i = Gi(t.geometry);
3872
- let n = i, s = "m2";
3873
- return i > 1e4 ? (n = i / 1e4, s = "ha") : i > 1e3 && (n = i / 1e3, s = "km2"), n = parseFloat(n.toFixed(2)), t.properties.area = n, t.properties.unit = s, t;
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;
3874
3882
  }
3875
3883
  /**
3876
3884
  * Caclulate distance for each segment on a given feature
@@ -3878,17 +3886,24 @@ class Ki extends Di {
3878
3886
  * @returns The returning feature will contain `segments`, `distance`, `unit` properties. `segments` will have multiple point features.
3879
3887
  */
3880
3888
  calcDistance(t) {
3889
+ var r, a;
3881
3890
  if (t.geometry.type !== "LineString") return t;
3882
3891
  const i = t.geometry.coordinates;
3883
3892
  let n = 0;
3884
- const s = [];
3885
- for (let r = 0; r < i.length - 1; r++) {
3886
- const a = i[r], l = i[r + 1], d = ji(a, l, { units: "kilometers" });
3887
- n += d;
3888
- const c = JSON.parse(JSON.stringify(t));
3889
- c.id = `${c.id}-${r}`, c.geometry.coordinates = [a, l], c.properties.originalId = t.id, c.properties.distance = parseFloat(d.toFixed(2)), c.properties.total = parseFloat(n.toFixed(2)), c.properties.unit = "km", s.push(c);
3893
+ const o = [];
3894
+ for (let l = 0; l < i.length - 1; l++) {
3895
+ const d = i[l], c = i[l + 1], h = ji(d, c, { units: "kilometers" });
3896
+ n += h;
3897
+ 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);
3903
+ }
3904
+ o.push(u);
3890
3905
  }
3891
- 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;
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;
3892
3907
  }
3893
3908
  /**
3894
3909
  * measure polygon area for given feature ID
@@ -3900,8 +3915,8 @@ class Ki extends Di {
3900
3915
  const i = this.getTerraDrawInstance();
3901
3916
  if (!i) return;
3902
3917
  const n = i.getSnapshot();
3903
- let s = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "Polygon");
3904
- if (s) {
3918
+ let o = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "Polygon");
3919
+ if (o) {
3905
3920
  const a = this.map.getStyle().sources[this.polygonLayerSpec.source];
3906
3921
  if (a) {
3907
3922
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
@@ -3910,8 +3925,8 @@ class Ki extends Di {
3910
3925
  return ((c = d.properties) == null ? void 0 : c.originalId) !== t;
3911
3926
  }
3912
3927
  ));
3913
- const l = JSON.parse(JSON.stringify(s));
3914
- 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(this.polygonLayerSpec.source)) == null || r.setData(
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(
3915
3930
  a.data
3916
3931
  ), this.map.moveLayer(this.polygonLayerSpec.id);
3917
3932
  }
@@ -3927,8 +3942,8 @@ class Ki extends Di {
3927
3942
  const i = this.getTerraDrawInstance();
3928
3943
  if (!i) return;
3929
3944
  const n = i.getSnapshot();
3930
- let s = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "LineString");
3931
- if (s) {
3945
+ let o = n == null ? void 0 : n.find((a) => a.id === t && a.geometry.type === "LineString");
3946
+ if (o) {
3932
3947
  const a = this.map.getStyle().sources[this.lineLayerLabelSpec.source];
3933
3948
  if (a) {
3934
3949
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
@@ -3936,24 +3951,24 @@ class Ki extends Di {
3936
3951
  var c;
3937
3952
  return ((c = d.properties) == null ? void 0 : c.originalId) !== t;
3938
3953
  }
3939
- )), s = this.calcDistance(s);
3940
- const l = s.properties.segments;
3954
+ )), o = this.calcDistance(o);
3955
+ const l = o.properties.segments;
3941
3956
  for (let d = 0; d < l.length; d++) {
3942
3957
  const c = l[d];
3943
3958
  typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
3944
3959
  const h = c.geometry.coordinates, u = h[0], g = h[1];
3945
3960
  if (d === 0) {
3946
- const p = JSON.parse(JSON.stringify(c));
3947
- p.id = `${c.id}-node-${d}`, p.geometry = {
3961
+ const f = JSON.parse(JSON.stringify(c));
3962
+ f.id = `${c.id}-node-${d}`, f.geometry = {
3948
3963
  type: "Point",
3949
3964
  coordinates: u
3950
- }, p.properties.distance = 0, p.properties.total = 0, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(p);
3965
+ }, f.properties.distance = 0, f.properties.total = 0, c.properties.elevation_start && (f.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(f);
3951
3966
  }
3952
- const f = JSON.parse(JSON.stringify(c));
3953
- f.id = `${c.id}-node-${d + 1}`, f.geometry = {
3967
+ const p = JSON.parse(JSON.stringify(c));
3968
+ p.id = `${c.id}-node-${d + 1}`, p.geometry = {
3954
3969
  type: "Point",
3955
3970
  coordinates: g
3956
- }, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(f);
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);
3957
3972
  }
3958
3973
  (r = this.map.getSource(this.lineLayerLabelSpec.source)) == null || r.setData(
3959
3974
  a.data
@@ -3969,8 +3984,8 @@ class Ki extends Di {
3969
3984
  if (!this.map) return;
3970
3985
  const t = this.getTerraDrawInstance();
3971
3986
  if (t) {
3972
- const s = [this.lineLayerLabelSpec.source, this.polygonLayerSpec.source];
3973
- for (const r of s) {
3987
+ const o = [this.lineLayerLabelSpec.source, this.polygonLayerSpec.source];
3988
+ for (const r of o) {
3974
3989
  const a = this.map.getStyle().sources[r];
3975
3990
  if (a) {
3976
3991
  const l = t.getSnapshot(), c = (l == null ? void 0 : l.filter(