@watergis/maplibre-gl-terradraw 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- var be = Object.defineProperty;
2
- var Fe = (r, t, e) => t in r ? be(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var L = (r, t, e) => Fe(r, typeof t != "symbol" ? t + "" : t, e);
1
+ var Le = Object.defineProperty;
2
+ var ke = (r, t, e) => t in r ? Le(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var k = (r, t, e) => ke(r, typeof t != "symbol" ? t + "" : t, e);
4
4
  import "maplibre-gl";
5
5
  function M() {
6
6
  return M = Object.assign ? Object.assign.bind() : function(r) {
@@ -19,12 +19,12 @@ const V = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selec
19
19
  function xt(r) {
20
20
  return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
21
21
  }
22
- function Nt(r) {
22
+ function Tt(r) {
23
23
  return !!function(t) {
24
24
  return typeof t == "number" && !isNaN(new Date(t).valueOf());
25
25
  }(r);
26
26
  }
27
- const Ee = "Feature mode property does not match the mode being added to";
27
+ const We = "Feature mode property does not match the mode being added to";
28
28
  var Y;
29
29
  (function(r) {
30
30
  r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
@@ -91,7 +91,7 @@ class N {
91
91
  }
92
92
  validateModeFeature(t, e) {
93
93
  const i = this.performFeatureValidation(t);
94
- return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Ee } : e(t) : { valid: !1, reason: i.reason };
94
+ return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: We } : e(t) : { valid: !1, reason: i.reason };
95
95
  }
96
96
  onFinish(t, e) {
97
97
  }
@@ -123,43 +123,43 @@ class N {
123
123
  return t === void 0 ? e : typeof t == "function" ? t(i) : t;
124
124
  }
125
125
  }
126
- class De extends N {
126
+ class Be extends N {
127
127
  constructor(...t) {
128
128
  super(...t), this.type = Y.Select;
129
129
  }
130
130
  }
131
- function T(r, t) {
132
- const e = (l) => l * Math.PI / 180, i = e(r[1]), o = e(r[0]), s = e(t[1]), n = s - i, a = e(t[0]) - o, d = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(s) * Math.sin(a / 2) * Math.sin(a / 2);
133
- return 2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)) * 6371e3 / 1e3;
131
+ function G(r, t) {
132
+ const e = (d) => d * Math.PI / 180, i = e(r[1]), o = e(r[0]), s = e(t[1]), n = s - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(s) * Math.sin(a / 2) * Math.sin(a / 2);
133
+ return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
134
134
  }
135
- const ie = 63710088e-1;
136
- function E(r) {
135
+ const ae = 63710088e-1;
136
+ function F(r) {
137
137
  return r % 360 * Math.PI / 180;
138
138
  }
139
- function oe(r) {
139
+ function le(r) {
140
140
  return r / 6371.0088;
141
141
  }
142
142
  function U(r) {
143
143
  return r % (2 * Math.PI) * 180 / Math.PI;
144
144
  }
145
- function F(r, t = 9) {
145
+ function E(r, t = 9) {
146
146
  const e = Math.pow(10, t);
147
147
  return Math.round(r * e) / e;
148
148
  }
149
- const At = 57.29577951308232, Gt = 0.017453292519943295, ut = 6378137, S = (r, t) => ({ x: r === 0 ? 0 : r * Gt * ut, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Gt / 2)) * ut }), W = (r, t) => ({ lng: r === 0 ? 0 : At * (r / ut), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ut)) - Math.PI / 2) * At });
150
- function Oe(r, t, e) {
151
- const i = E(r[0]), o = E(r[1]), s = E(e), n = oe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
149
+ const Gt = 57.29577951308232, Vt = 0.017453292519943295, ut = 6378137, x = (r, t) => ({ x: r === 0 ? 0 : r * Vt * ut, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Vt / 2)) * ut }), W = (r, t) => ({ lng: r === 0 ? 0 : Gt * (r / ut), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ut)) - Math.PI / 2) * Gt });
150
+ function je(r, t, e) {
151
+ const i = F(r[0]), o = F(r[1]), s = F(e), n = le(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
152
152
  return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
153
153
  }
154
- function Tt(r) {
154
+ function Ut(r) {
155
155
  const { center: t, radiusKilometers: e, coordinatePrecision: i } = r, o = r.steps ? r.steps : 64, s = [];
156
156
  for (let n = 0; n < o; n++) {
157
- const a = Oe(t, e, -360 * n / o);
158
- s.push([F(a[0], i), F(a[1], i)]);
157
+ const a = je(t, e, -360 * n / o);
158
+ s.push([E(a[0], i), E(a[1], i)]);
159
159
  }
160
160
  return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
161
161
  }
162
- function Et(r) {
162
+ function Ot(r) {
163
163
  let t;
164
164
  if (r.geometry.type === "Polygon") t = r.geometry.coordinates;
165
165
  else {
@@ -167,44 +167,44 @@ function Et(r) {
167
167
  t = [r.geometry.coordinates];
168
168
  }
169
169
  const e = [];
170
- for (let s = 0; s < t.length; s++) for (let n = 0; n < t[s].length - 1; n++) for (let a = 0; a < t.length; a++) for (let d = 0; d < t[a].length - 1; d++) o(s, n, a, d);
170
+ for (let s = 0; s < t.length; s++) for (let n = 0; n < t[s].length - 1; n++) for (let a = 0; a < t.length; a++) for (let l = 0; l < t[a].length - 1; l++) o(s, n, a, l);
171
171
  return e.length > 0;
172
172
  function i(s) {
173
173
  return s < 0 || s > 1;
174
174
  }
175
- function o(s, n, a, d) {
176
- const l = t[s][n], c = t[s][n + 1], h = t[a][d], u = t[a][d + 1], p = function(v, f, m, C) {
175
+ function o(s, n, a, l) {
176
+ const d = t[s][n], c = t[s][n + 1], h = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
177
177
  if (at(v, m) || at(v, C) || at(f, m) || at(C, m)) return null;
178
- const P = v[0], x = v[1], I = f[0], b = f[1], O = m[0], A = m[1], _ = C[0], j = C[1], z = (P - I) * (A - j) - (x - b) * (O - _);
179
- return z === 0 ? null : [((P * b - x * I) * (O - _) - (P - I) * (O * j - A * _)) / z, ((P * b - x * I) * (A - j) - (x - b) * (O * j - A * _)) / z];
180
- }(l, c, h, u);
178
+ const P = v[0], S = v[1], I = f[0], b = f[1], O = m[0], A = m[1], _ = C[0], j = C[1], z = (P - I) * (A - j) - (S - b) * (O - _);
179
+ return z === 0 ? null : [((P * b - S * I) * (O - _) - (P - I) * (O * j - A * _)) / z, ((P * b - S * I) * (A - j) - (S - b) * (O * j - A * _)) / z];
180
+ }(d, c, h, u);
181
181
  if (p === null) return;
182
182
  let g, y;
183
- g = c[0] !== l[0] ? (p[0] - l[0]) / (c[0] - l[0]) : (p[1] - l[1]) / (c[1] - l[1]), y = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(g) || i(y) || (p.toString(), e.push(p));
183
+ g = c[0] !== d[0] ? (p[0] - d[0]) / (c[0] - d[0]) : (p[1] - d[1]) / (c[1] - d[1]), y = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(g) || i(y) || (p.toString(), e.push(p));
184
184
  }
185
185
  }
186
186
  function at(r, t) {
187
187
  return r[0] === t[0] && r[1] === t[1];
188
188
  }
189
189
  function mt(r, t) {
190
- return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (i = r[0]) >= -180 && i <= 180 && (e = r[1]) >= -90 && e <= 90 && Vt(r[0]) <= t && Vt(r[1]) <= t;
190
+ return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (i = r[0]) >= -180 && i <= 180 && (e = r[1]) >= -90 && e <= 90 && zt(r[0]) <= t && zt(r[1]) <= t;
191
191
  var e, i;
192
192
  }
193
- function Vt(r) {
193
+ function zt(r) {
194
194
  let t = 1, e = 0;
195
195
  for (; Math.round(r * t) / t !== r; ) t *= 10, e++;
196
196
  return e;
197
197
  }
198
- const _e = "Feature has holes", Le = "Feature has less than 4 coordinates", ke = "Feature has invalid coordinates", We = "Feature coordinates are not closed";
198
+ const Ne = "Feature has holes", Ae = "Feature has less than 4 coordinates", Te = "Feature has invalid coordinates", Ge = "Feature coordinates are not closed";
199
199
  function vt(r, t) {
200
- return r.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : r.geometry.coordinates.length !== 1 ? { valid: !1, reason: _e } : r.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Le } : r.geometry.coordinates[0].every((o) => mt(o, t)) ? (e = r.geometry.coordinates[0][0])[0] !== (i = r.geometry.coordinates[0][r.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: We } : { valid: !0 } : { valid: !1, reason: ke };
200
+ return r.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : r.geometry.coordinates.length !== 1 ? { valid: !1, reason: Ne } : r.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Ae } : r.geometry.coordinates[0].every((o) => mt(o, t)) ? (e = r.geometry.coordinates[0][0])[0] !== (i = r.geometry.coordinates[0][r.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: Ge } : { valid: !0 } : { valid: !1, reason: Te };
201
201
  var e, i;
202
202
  }
203
203
  function nt(r, t) {
204
204
  const e = vt(r, t);
205
- return e.valid ? Et(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
205
+ return e.valid ? Ot(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
206
206
  }
207
- class se extends N {
207
+ class de extends N {
208
208
  constructor(t) {
209
209
  var e;
210
210
  super(t), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1;
@@ -234,7 +234,7 @@ class se extends N {
234
234
  onClick(t) {
235
235
  if (this.clickCount === 0) {
236
236
  this.center = [t.lng, t.lat];
237
- const e = Tt({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
237
+ const e = Ut({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
238
238
  this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
239
239
  } else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
240
240
  }
@@ -269,26 +269,26 @@ class se extends N {
269
269
  }
270
270
  updateCircle(t) {
271
271
  if (this.clickCount === 1 && this.center && this.currentCircleId) {
272
- const e = T(this.center, [t.lng, t.lat]);
272
+ const e = G(this.center, [t.lng, t.lat]);
273
273
  let i;
274
274
  if (this.projection === "web-mercator") {
275
275
  const o = function(s, n) {
276
- const a = 1e3 * T(s, n);
276
+ const a = 1e3 * G(s, n);
277
277
  if (a === 0) return 1;
278
- const { x: d, y: l } = S(s[0], s[1]), { x: c, y: h } = S(n[0], n[1]);
279
- return Math.sqrt(Math.pow(c - d, 2) + Math.pow(h - l, 2)) / a;
278
+ const { x: l, y: d } = x(s[0], s[1]), { x: c, y: h } = x(n[0], n[1]);
279
+ return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
280
280
  }(this.center, [t.lng, t.lat]);
281
281
  i = function(s) {
282
- const { center: n, radiusKilometers: a, coordinatePrecision: d } = s, l = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = S(h, u), y = [];
283
- for (let v = 0; v < l; v++) {
284
- const f = 360 * v / l * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, x] = [p + m, g + C], { lng: I, lat: b } = W(P, x);
285
- y.push([F(I, d), F(b, d)]);
282
+ const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = x(h, u), y = [];
283
+ for (let v = 0; v < d; v++) {
284
+ const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, S] = [p + m, g + C], { lng: I, lat: b } = W(P, S);
285
+ y.push([E(I, l), E(b, l)]);
286
286
  }
287
287
  return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
288
288
  }({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
289
289
  } else {
290
290
  if (this.projection !== "globe") throw new Error("Invalid projection");
291
- i = Tt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
291
+ i = Ut({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
292
292
  }
293
293
  if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional }).valid) return;
294
294
  this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
@@ -299,7 +299,7 @@ const D = (r, t) => {
299
299
  const { x: e, y: i } = r, { x: o, y: s } = t, n = o - e, a = s - i;
300
300
  return Math.sqrt(a * a + n * n);
301
301
  };
302
- let re = class extends N {
302
+ let ce = class extends N {
303
303
  constructor(t) {
304
304
  super(t), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = void 0, this.keyEvents = void 0, this.cursors = void 0, this.preventPointsNearClose = void 0, this.autoClose = void 0, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1;
305
305
  const e = { start: "crosshair", close: "pointer" };
@@ -328,13 +328,13 @@ let re = class extends N {
328
328
  }
329
329
  onMouseMove(t) {
330
330
  if (this.currentId === void 0 || this.startingClick === !1) return;
331
- const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), d = D({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [l, c] = e.coordinates[0][0], { x: h, y: u } = this.project(l, c);
331
+ const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l = D({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
332
332
  if (D({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
333
333
  if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
334
334
  this.preventNewFeature = !1;
335
335
  }, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
336
336
  } else this.hasLeftStartingPoint = !0, this.setCursor(this.cursors.start);
337
- if (d < this.minDistance) return;
337
+ if (l < this.minDistance) return;
338
338
  e.coordinates[0].pop();
339
339
  const p = { type: "Polygon", coordinates: [[...e.coordinates[0], [t.lng, t.lat], e.coordinates[0][0]]] };
340
340
  this.validate && !this.validate({ type: "Feature", id: this.currentId, geometry: p, properties: {} }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Provisional }).valid || this.store.updateGeometry([{ id: this.currentId, geometry: p }]);
@@ -379,7 +379,7 @@ let re = class extends N {
379
379
  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 = t, this.mode = e, this.project = i, this.unproject = o, this.pointerDistance = s, this.coordinatePrecision = n, this.projection = a;
380
380
  }
381
381
  };
382
- function ne({ unproject: r, point: t, pointerDistance: e }) {
382
+ function he({ unproject: r, point: t, pointerDistance: e }) {
383
383
  const i = e / 2, { x: o, y: s } = t;
384
384
  return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[r(o - i, s - i), r(o + i, s - i), r(o + i, s + i), r(o - i, s + i), r(o - i, s - i)].map((n) => [n.lng, n.lat])] } };
385
385
  }
@@ -389,7 +389,7 @@ let Ct = class extends B {
389
389
  }
390
390
  create(t) {
391
391
  const { containerX: e, containerY: i } = t;
392
- return ne({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
392
+ return he({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
393
393
  }
394
394
  };
395
395
  class Pt extends B {
@@ -401,7 +401,7 @@ class Pt extends B {
401
401
  return D({ x: i, y: o }, { x: t.containerX, y: t.containerY });
402
402
  }
403
403
  }
404
- class ae extends B {
404
+ class ue extends B {
405
405
  constructor(t, e, i) {
406
406
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== s)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
407
407
  }
@@ -414,101 +414,101 @@ class ae extends B {
414
414
  if (n.geometry.type !== "LineString") return;
415
415
  a = n.geometry.coordinates;
416
416
  }
417
- a.forEach((d, l) => {
418
- const c = this.pixelDistance.measure(t, d);
419
- c < s.minDist && c < this.pointerDistance && (s.coordinate = d, s.minDist = c, s.featureId = n.id, s.featureCoordinateIndex = l);
417
+ a.forEach((l, d) => {
418
+ const c = this.pixelDistance.measure(t, l);
419
+ c < s.minDist && c < this.pointerDistance && (s.coordinate = l, s.minDist = c, s.featureId = n.id, s.featureCoordinateIndex = d);
420
420
  });
421
421
  }), s;
422
422
  }
423
423
  }
424
- function Ut(r, t, e) {
425
- const i = E(r[0]), o = E(r[1]), s = E(e), n = oe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
424
+ function Rt(r, t, e) {
425
+ const i = F(r[0]), o = F(r[1]), s = F(e), n = le(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
426
426
  return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
427
427
  }
428
428
  function rt({ x: r, y: t }, e, i) {
429
- const o = E(i);
429
+ const o = F(i);
430
430
  return { x: r + e * Math.cos(o), y: t + e * Math.sin(o) };
431
431
  }
432
- function zt(r, t) {
433
- const e = E(r[0]), i = E(t[0]), o = E(r[1]), s = E(t[1]), n = Math.sin(i - e) * Math.cos(s), a = Math.cos(o) * Math.sin(s) - Math.sin(o) * Math.cos(s) * Math.cos(i - e);
432
+ function Xt(r, t) {
433
+ const e = F(r[0]), i = F(t[0]), o = F(r[1]), s = F(t[1]), n = Math.sin(i - e) * Math.cos(s), a = Math.cos(o) * Math.sin(s) - Math.sin(o) * Math.cos(s) * Math.cos(i - e);
434
434
  return U(Math.atan2(n, a));
435
435
  }
436
- function G({ x: r, y: t }, { x: e, y: i }) {
436
+ function T({ x: r, y: t }, { x: e, y: i }) {
437
437
  let o = Math.atan2(i - t, e - r);
438
438
  return o *= 180 / Math.PI, o > 180 ? o -= 360 : o < -180 && (o += 360), o;
439
439
  }
440
440
  function K(r) {
441
441
  return (r + 360) % 360;
442
442
  }
443
- function Be(r, t, e) {
443
+ function Ve(r, t, e) {
444
444
  const i = [], o = r.length;
445
- let s, n, a, d = 0;
446
- for (let c = 0; c < r.length && !(t >= d && c === r.length - 1); c++) {
447
- if (d > t && i.length === 0) {
448
- if (s = t - d, !s) return i.push(r[c]), i;
449
- n = zt(r[c], r[c - 1]) - 180, a = Ut(r[c], s, n), i.push(a);
445
+ let s, n, a, l = 0;
446
+ for (let c = 0; c < r.length && !(t >= l && c === r.length - 1); c++) {
447
+ if (l > t && i.length === 0) {
448
+ if (s = t - l, !s) return i.push(r[c]), i;
449
+ n = Xt(r[c], r[c - 1]) - 180, a = Rt(r[c], s, n), i.push(a);
450
450
  }
451
- if (d >= e) return s = e - d, s ? (n = zt(r[c], r[c - 1]) - 180, a = Ut(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
452
- if (d >= t && i.push(r[c]), c === r.length - 1) return i;
453
- d += T(r[c], r[c + 1]);
451
+ if (l >= e) return s = e - l, s ? (n = Xt(r[c], r[c - 1]) - 180, a = Rt(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
452
+ if (l >= t && i.push(r[c]), c === r.length - 1) return i;
453
+ l += G(r[c], r[c + 1]);
454
454
  }
455
- if (d < t && r.length === o) throw new Error("Start position is beyond line");
456
- const l = r[r.length - 1];
457
- return [l, l];
455
+ if (l < t && r.length === o) throw new Error("Start position is beyond line");
456
+ const d = r[r.length - 1];
457
+ return [d, d];
458
458
  }
459
459
  function lt(r) {
460
460
  return r * (Math.PI / 180);
461
461
  }
462
- function Rt(r) {
462
+ function Kt(r) {
463
463
  return r * (180 / Math.PI);
464
464
  }
465
- class je extends B {
465
+ class Ue extends B {
466
466
  constructor(t) {
467
467
  super(t), this.config = void 0, this.config = t;
468
468
  }
469
469
  generateInsertionCoordinates(t, e, i) {
470
470
  const o = [t, e];
471
471
  let s = 0;
472
- for (let l = 0; l < o.length - 1; l++) s += T(o[0], o[1]);
472
+ for (let d = 0; d < o.length - 1; d++) s += G(o[0], o[1]);
473
473
  if (s <= i) return o;
474
474
  let n = s / i - 1;
475
475
  Number.isInteger(n) || (n = Math.floor(n) + 1);
476
476
  const a = [];
477
- for (let l = 0; l < n; l++) {
478
- const c = Be(o, i * l, i * (l + 1));
477
+ for (let d = 0; d < n; d++) {
478
+ const c = Ve(o, i * d, i * (d + 1));
479
479
  a.push(c);
480
480
  }
481
- const d = [];
482
- for (let l = 0; l < a.length; l++) d.push(a[l][1]);
483
- return this.limitCoordinates(d);
481
+ const l = [];
482
+ for (let d = 0; d < a.length; d++) l.push(a[d][1]);
483
+ return this.limitCoordinates(l);
484
484
  }
485
485
  generateInsertionGeodesicCoordinates(t, e, i) {
486
- const o = T(t, e), s = function(n, a, d) {
487
- const l = [], c = lt(n[1]), h = lt(n[0]), u = lt(a[1]), p = lt(a[0]);
488
- d += 1;
486
+ const o = G(t, e), s = function(n, a, l) {
487
+ const d = [], c = lt(n[1]), h = lt(n[0]), u = lt(a[1]), p = lt(a[0]);
488
+ l += 1;
489
489
  const g = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
490
- if (g === 0 || isNaN(g)) return l;
491
- for (let y = 0; y <= d; y++) {
492
- const v = y / d, f = Math.sin((1 - v) * g) / Math.sin(g), m = Math.sin(v * g) / Math.sin(g), C = f * Math.cos(c) * Math.cos(h) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(c) * Math.sin(h) + m * Math.cos(u) * Math.sin(p), x = f * Math.sin(c) + m * Math.sin(u);
493
- if (isNaN(C) || isNaN(P) || isNaN(x)) continue;
494
- const I = Math.atan2(x, Math.sqrt(C ** 2 + P ** 2)), b = Math.atan2(P, C);
495
- isNaN(I) || isNaN(b) || l.push([Rt(b), Rt(I)]);
490
+ if (g === 0 || isNaN(g)) return d;
491
+ for (let y = 0; y <= l; y++) {
492
+ const v = y / l, f = Math.sin((1 - v) * g) / Math.sin(g), m = Math.sin(v * g) / Math.sin(g), C = f * Math.cos(c) * Math.cos(h) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(c) * Math.sin(h) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(c) + m * Math.sin(u);
493
+ if (isNaN(C) || isNaN(P) || isNaN(S)) continue;
494
+ const I = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), b = Math.atan2(P, C);
495
+ isNaN(I) || isNaN(b) || d.push([Kt(b), Kt(I)]);
496
496
  }
497
- return l.slice(1, -1);
497
+ return d.slice(1, -1);
498
498
  }(t, e, Math.floor(o / i));
499
499
  return this.limitCoordinates(s);
500
500
  }
501
501
  limitCoordinates(t) {
502
- return t.map((e) => [F(e[0], this.config.coordinatePrecision), F(e[1], this.config.coordinatePrecision)]);
502
+ return t.map((e) => [E(e[0], this.config.coordinatePrecision), E(e[1], this.config.coordinatePrecision)]);
503
503
  }
504
504
  }
505
505
  function Z(r, t) {
506
506
  return r[0] === t[0] && r[1] === t[1];
507
507
  }
508
- function le(r, t) {
508
+ function pe(r, t) {
509
509
  return r.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : r.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : r.geometry.coordinates.every((e) => mt(e, t)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
510
510
  }
511
- class de extends N {
511
+ class ge extends N {
512
512
  constructor(t) {
513
513
  super(t), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0;
514
514
  const e = { start: "crosshair", close: "pointer" };
@@ -536,7 +536,7 @@ class de extends N {
536
536
  generateInsertCoordinates(t, e) {
537
537
  if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
538
538
  if (this.insertCoordinates.strategy !== "amount") throw new Error("Strategy does not exist");
539
- const i = T(t, e) / (this.insertCoordinates.value + 1);
539
+ const i = G(t, e) / (this.insertCoordinates.value + 1);
540
540
  let o = [];
541
541
  return this.projection === "globe" ? o = this.insertPoint.generateInsertionGeodesicCoordinates(t, e, i) : this.projection === "web-mercator" && (o = this.insertPoint.generateInsertionCoordinates(t, e, i)), o;
542
542
  }
@@ -556,11 +556,11 @@ class de extends N {
556
556
  const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, s);
557
557
  if (D({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
558
558
  this.setCursor(this.cursors.close);
559
- const d = [...i, t];
560
- this.updateGeometries(d, i[i.length - 1], w.Commit), this.currentCoordinate++;
559
+ const l = [...i, t];
560
+ this.updateGeometries(l, i[i.length - 1], w.Commit), this.currentCoordinate++;
561
561
  }
562
562
  registerBehaviors(t) {
563
- this.coordinateSnapping = new ae(t, new Pt(t), new Ct(t)), this.insertPoint = new je(t);
563
+ this.coordinateSnapping = new ue(t, new Pt(t), new Ct(t)), this.insertPoint = new Ue(t);
564
564
  }
565
565
  start() {
566
566
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -583,15 +583,15 @@ class de extends N {
583
583
  if (this.currentId === void 0 || this.currentCoordinate === 0) return;
584
584
  const o = this.store.getGeometryCopy(this.currentId).coordinates;
585
585
  if (o.pop(), this.closingPointId) {
586
- const [n, a] = o[o.length - 1], { x: d, y: l } = this.project(n, a);
587
- D({ x: d, y: l }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
586
+ const [n, a] = o[o.length - 1], { x: l, y: d } = this.project(n, a);
587
+ D({ x: l, y: d }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
588
588
  }
589
589
  let s = [...o, i];
590
590
  if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
591
591
  const n = this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1], a = i;
592
592
  if (!Z(n, a)) {
593
- const d = this.generateInsertCoordinates(n, a);
594
- s = [...this.lastCommitedCoordinates.slice(0, -1), ...d, i];
593
+ const l = this.generateInsertCoordinates(n, a);
594
+ s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
595
595
  }
596
596
  }
597
597
  this.updateGeometries(s, void 0, w.Provisional);
@@ -630,7 +630,7 @@ class de extends N {
630
630
  return e;
631
631
  }
632
632
  validateFeature(t) {
633
- return this.validateModeFeature(t, (e) => le(e, this.coordinatePrecision));
633
+ return this.validateModeFeature(t, (e) => pe(e, this.coordinatePrecision));
634
634
  }
635
635
  snapCoordinate(t) {
636
636
  var e, i;
@@ -638,11 +638,11 @@ class de extends N {
638
638
  return (e = this.snapping) != null && e.toCoordinate && (o = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t)), (i = this.snapping) != null && i.toCustom && (o = this.snapping.toCustom(t)), o;
639
639
  }
640
640
  }
641
- const Ne = "Feature is not a Point", Ae = "Feature has invalid coordinates";
642
- function ce(r, t) {
643
- return r.geometry.type !== "Point" ? { valid: !1, reason: Ne } : mt(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: Ae };
641
+ const ze = "Feature is not a Point", Re = "Feature has invalid coordinates";
642
+ function ye(r, t) {
643
+ return r.geometry.type !== "Point" ? { valid: !1, reason: ze } : mt(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: Re };
644
644
  }
645
- class Ge extends N {
645
+ class Xe extends N {
646
646
  constructor(t) {
647
647
  super(t), this.mode = "point", this.cursors = void 0, this.editable = void 0, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0;
648
648
  const e = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
@@ -675,10 +675,10 @@ class Ge extends N {
675
675
  const i = this.clickBoundingBox.create(t), o = this.store.search(i);
676
676
  let s, n = 1 / 0;
677
677
  for (let a = 0; a < o.length; a++) {
678
- const d = o[a];
679
- if (d.geometry.type !== "Point" || d.properties.mode !== this.mode) continue;
680
- const l = this.pixelDistance.measure(t, d.geometry.coordinates);
681
- l > n || l > this.pointerDistance || (n = l, s = d);
678
+ const l = o[a];
679
+ if (l.geometry.type !== "Point" || l.properties.mode !== this.mode) continue;
680
+ const d = this.pixelDistance.measure(t, l.geometry.coordinates);
681
+ d > n || d > this.pointerDistance || (n = d, s = l);
682
682
  }
683
683
  s && (this.editedFeatureId = s.id);
684
684
  }
@@ -702,10 +702,10 @@ class Ge extends N {
702
702
  return e;
703
703
  }
704
704
  validateFeature(t) {
705
- return this.validateModeFeature(t, (e) => ce(e, this.coordinatePrecision));
705
+ return this.validateModeFeature(t, (e) => ye(e, this.coordinatePrecision));
706
706
  }
707
707
  }
708
- class Te extends B {
708
+ class Ke extends B {
709
709
  constructor(t, e) {
710
710
  super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
711
711
  }
@@ -731,37 +731,37 @@ class Te extends B {
731
731
  return { isClosing: o < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
732
732
  }
733
733
  }
734
- function Xt(r) {
734
+ function Yt(r) {
735
735
  return Math.sqrt(Math.pow(r[0], 2) + Math.pow(r[1], 2) + Math.pow(r[2], 2));
736
736
  }
737
737
  function R(r, t) {
738
738
  const e = function(i, o) {
739
- const [s, n, a] = i, [d, l, c] = o;
740
- return s * d + n * l + a * c;
741
- }(r, t) / (Xt(r) * Xt(t));
739
+ const [s, n, a] = i, [l, d, c] = o;
740
+ return s * l + n * d + a * c;
741
+ }(r, t) / (Yt(r) * Yt(t));
742
742
  return Math.acos(Math.min(Math.max(e, -1), 1));
743
743
  }
744
- function St(r) {
745
- const t = E(r[1]), e = E(r[0]);
744
+ function Mt(r) {
745
+ const t = F(r[1]), e = F(r[0]);
746
746
  return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
747
747
  }
748
748
  function X(r) {
749
749
  const [t, e, i] = r, o = U(Math.asin(i));
750
750
  return [U(Math.atan2(e, t)), o];
751
751
  }
752
- function Ve(r, t, e) {
753
- const i = St(r), o = St(t), s = St(e), [n, a, d] = s, [l, c, h] = function(j, z) {
754
- const [_t, Lt, kt] = j, [Wt, Bt, jt] = z;
755
- return [Lt * jt - kt * Bt, kt * Wt - _t * jt, _t * Bt - Lt * Wt];
756
- }(i, o), u = c * d - h * a, p = h * n - l * d, g = l * a - c * n, y = g * c - p * h, v = u * h - g * l, f = p * l - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], x = R(i, o), I = R(i, C), b = R(o, C), O = R(i, P), A = R(o, P);
752
+ function Ye(r, t, e) {
753
+ const i = Mt(r), o = Mt(t), s = Mt(e), [n, a, l] = s, [d, c, h] = function(j, z) {
754
+ const [kt, Wt, Bt] = j, [jt, Nt, At] = z;
755
+ return [Wt * At - Bt * Nt, Bt * jt - kt * At, kt * Nt - Wt * jt];
756
+ }(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, v = u * h - g * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], S = R(i, o), I = R(i, C), b = R(o, C), O = R(i, P), A = R(o, P);
757
757
  let _;
758
- return _ = I < O && I < A || b < O && b < A ? C : P, R(i, _) > x || R(o, _) > x ? T(X(_), X(i)) <= T(X(_), X(o)) ? [X(i), !0, !1] : [X(o), !1, !0] : [X(_), !1, !1];
758
+ return _ = I < O && I < A || b < O && b < A ? C : P, R(i, _) > S || R(o, _) > S ? G(X(_), X(i)) <= G(X(_), X(o)) ? [X(i), !0, !1] : [X(o), !1, !0] : [X(_), !1, !1];
759
759
  }
760
- function Ue(r, t, e) {
760
+ function $e(r, t, e) {
761
761
  const i = t.x - r.x, o = t.y - r.y, s = Math.max(0, Math.min(1, ((e.x - r.x) * i + (e.y - r.y) * o) / (i * i + o * o)));
762
762
  return { x: r.x + s * i, y: r.y + s * o };
763
763
  }
764
- class ze extends B {
764
+ class He extends B {
765
765
  constructor(t, e, i) {
766
766
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== s)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
767
767
  }
@@ -774,40 +774,40 @@ class ze extends B {
774
774
  if (n.geometry.type !== "LineString") return;
775
775
  a = n.geometry.coordinates;
776
776
  }
777
- const d = [];
778
- for (let u = 0; u < a.length - 1; u++) d.push([a[u], a[u + 1]]);
779
- let l;
777
+ const l = [];
778
+ for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
779
+ let d;
780
780
  const c = [t.lng, t.lat];
781
- if (this.config.projection === "web-mercator" ? l = function(u, p) {
781
+ if (this.config.projection === "web-mercator" ? d = function(u, p) {
782
782
  let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
783
783
  for (let f of p) {
784
784
  const m = f[0], C = f[1];
785
- let P, x = 1 / 0;
786
- const I = S(m[0], m[1]), b = S(C[0], C[1]), O = S(u[0], u[1]);
785
+ let P, S = 1 / 0;
786
+ const I = x(m[0], m[1]), b = x(C[0], C[1]), O = x(u[0], u[1]);
787
787
  if (m[0] === u[0] && m[1] === u[1]) P = m;
788
788
  else if (C[0] === u[0] && C[1] === u[1]) P = C;
789
789
  else {
790
- const { x: A, y: _ } = Ue(I, b, O), { lng: j, lat: z } = W(A, _);
790
+ const { x: A, y: _ } = $e(I, b, O), { lng: j, lat: z } = W(A, _);
791
791
  P = [j, z];
792
792
  }
793
- P && (x = D(O, S(P[0], P[1])), x < y && (g = P, y = x, v = p.indexOf(f)));
793
+ P && (S = D(O, x(P[0], P[1])), S < y && (g = P, y = S, v = p.indexOf(f)));
794
794
  }
795
795
  return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: v, distance: y };
796
- }(c, d) : this.config.projection === "globe" && (l = function(u, p) {
796
+ }(c, l) : this.config.projection === "globe" && (d = function(u, p) {
797
797
  let g = [1 / 0, 1 / 0], y = 1 / 0, v = 0;
798
798
  for (let f of p) {
799
799
  const m = f[0], C = f[1];
800
- let P, x = 1 / 0;
801
- m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = Ve(m, C, u), P && (x = T(u, P), x < y && (g = P, y = x, v = p.indexOf(f)));
800
+ let P, S = 1 / 0;
801
+ m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = Ye(m, C, u), P && (S = G(u, P), S < y && (g = P, y = S, v = p.indexOf(f)));
802
802
  }
803
803
  return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: v };
804
- }(c, d)), !l) return;
805
- const h = this.pixelDistance.measure(t, l.coordinate);
806
- h < s.minDistance && h < this.pointerDistance && (s.featureId = n.id, s.coordinate = l.coordinate, s.featureCoordinateIndex = l.lineIndex, s.minDistance = h);
804
+ }(c, l)), !d) return;
805
+ const h = this.pixelDistance.measure(t, d.coordinate);
806
+ h < s.minDistance && h < this.pointerDistance && (s.featureId = n.id, s.coordinate = d.coordinate, s.featureCoordinateIndex = d.lineIndex, s.minDistance = h);
807
807
  }), s;
808
808
  }
809
809
  }
810
- class he extends N {
810
+ class fe extends N {
811
811
  constructor(t) {
812
812
  super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.editable = void 0, this.snappedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.clickBoundingBox = void 0, this.cursors = void 0, this.mouseMove = !1;
813
813
  const e = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
@@ -826,7 +826,7 @@ class he extends N {
826
826
  this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.snappedPointId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
827
827
  }
828
828
  registerBehaviors(t) {
829
- this.clickBoundingBox = new Ct(t), this.pixelDistance = new Pt(t), this.lineSnapping = new ze(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new ae(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new Te(t, this.pixelDistance);
829
+ this.clickBoundingBox = new Ct(t), this.pixelDistance = new Pt(t), this.lineSnapping = new He(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new ue(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new Ke(t, this.pixelDistance);
830
830
  }
831
831
  start() {
832
832
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -965,7 +965,7 @@ class he extends N {
965
965
  return this.validateModeFeature(t, (e) => vt(e, this.coordinatePrecision));
966
966
  }
967
967
  }
968
- class ue extends N {
968
+ class me extends N {
969
969
  constructor(t) {
970
970
  super(t), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
971
971
  const e = { start: "crosshair" };
@@ -1060,50 +1060,50 @@ class et extends N {
1060
1060
  validateFeature(t) {
1061
1061
  const e = super.validateFeature(t);
1062
1062
  if (e.valid) {
1063
- const i = t, o = ce(i, this.coordinatePrecision).valid || vt(i, this.coordinatePrecision).valid || le(i, this.coordinatePrecision).valid;
1063
+ const i = t, o = ye(i, this.coordinatePrecision).valid || vt(i, this.coordinatePrecision).valid || pe(i, this.coordinatePrecision).valid;
1064
1064
  return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
1065
1065
  }
1066
1066
  return e;
1067
1067
  }
1068
1068
  }
1069
1069
  function pt(r, t) {
1070
- const e = r, i = t, o = E(e[1]), s = E(i[1]);
1071
- let n = E(i[0] - e[0]);
1070
+ const e = r, i = t, o = F(e[1]), s = F(i[1]);
1071
+ let n = F(i[0] - e[0]);
1072
1072
  n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
1073
- const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), d = (U(Math.atan2(n, a)) + 360) % 360;
1074
- return d > 180 ? -(360 - d) : d;
1073
+ const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (U(Math.atan2(n, a)) + 360) % 360;
1074
+ return l > 180 ? -(360 - l) : l;
1075
1075
  }
1076
- function Dt(r, t, e) {
1076
+ function _t(r, t, e) {
1077
1077
  let i = t;
1078
1078
  t < 0 && (i = -Math.abs(i));
1079
- const o = i / ie, s = r[0] * Math.PI / 180, n = E(r[1]), a = E(e), d = o * Math.cos(a);
1080
- let l = n + d;
1081
- Math.abs(l) > Math.PI / 2 && (l = l > 0 ? Math.PI - l : -Math.PI - l);
1082
- const c = Math.log(Math.tan(l / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? d / c : Math.cos(n), u = [(180 * (s + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * l / Math.PI];
1079
+ const o = i / ae, s = r[0] * Math.PI / 180, n = F(r[1]), a = F(e), l = o * Math.cos(a);
1080
+ let d = n + l;
1081
+ Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
1082
+ const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (s + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1083
1083
  return u[0] += u[0] - r[0] > 180 ? -360 : r[0] - u[0] > 180 ? 360 : 0, u;
1084
1084
  }
1085
- function pe(r, t, e, i, o) {
1086
- const s = i(r[0], r[1]), n = i(t[0], t[1]), { lng: a, lat: d } = o((s.x + n.x) / 2, (s.y + n.y) / 2);
1087
- return [F(a, e), F(d, e)];
1085
+ function ve(r, t, e, i, o) {
1086
+ const s = i(r[0], r[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((s.x + n.x) / 2, (s.y + n.y) / 2);
1087
+ return [E(a, e), E(l, e)];
1088
1088
  }
1089
- function Re(r, t, e) {
1090
- const i = Dt(r, 1e3 * T(r, t) / 2, pt(r, t));
1091
- return [F(i[0], e), F(i[1], e)];
1089
+ function qe(r, t, e) {
1090
+ const i = _t(r, 1e3 * G(r, t) / 2, pt(r, t));
1091
+ return [E(i[0], e), E(i[1], e)];
1092
1092
  }
1093
- function Kt({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
1093
+ function $t({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
1094
1094
  const s = [];
1095
1095
  for (let n = 0; n < r.length - 1; n++) {
1096
1096
  let a;
1097
- if (o === "web-mercator") a = pe(r[n], r[n + 1], t, i, e);
1097
+ if (o === "web-mercator") a = ve(r[n], r[n + 1], t, i, e);
1098
1098
  else {
1099
1099
  if (o !== "globe") throw new Error("Invalid projection");
1100
- a = Re(r[n], r[n + 1], t);
1100
+ a = qe(r[n], r[n + 1], t);
1101
1101
  }
1102
1102
  s.push(a);
1103
1103
  }
1104
1104
  return s;
1105
1105
  }
1106
- class Xe extends B {
1106
+ class Je extends B {
1107
1107
  constructor(t, e) {
1108
1108
  super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
1109
1109
  }
@@ -1118,18 +1118,18 @@ class Xe extends B {
1118
1118
  }
1119
1119
  create(t, e, i) {
1120
1120
  if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
1121
- this._midPoints = this.store.create(function(o, s, n, a, d, l) {
1122
- return Kt({ featureCoords: o, precision: n, project: a, unproject: d, projection: l }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1121
+ this._midPoints = this.store.create(function(o, s, n, a, l, d) {
1122
+ return $t({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1123
1123
  }(t, (o) => ({ mode: this.mode, [V.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
1124
1124
  }
1125
1125
  delete() {
1126
1126
  this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
1127
1127
  }
1128
1128
  getUpdated(t) {
1129
- if (this._midPoints.length !== 0) return Kt({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
1129
+ if (this._midPoints.length !== 0) return $t({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
1130
1130
  }
1131
1131
  }
1132
- class Ke extends B {
1132
+ class Ze extends B {
1133
1133
  constructor(t) {
1134
1134
  super(t), this._selectionPoints = [];
1135
1135
  }
@@ -1140,8 +1140,8 @@ class Ke extends B {
1140
1140
  }
1141
1141
  create(t, e, i) {
1142
1142
  this._selectionPoints = this.store.create(function(o, s, n) {
1143
- const a = [], d = s === "Polygon" ? o.length - 1 : o.length;
1144
- for (let l = 0; l < d; l++) a.push({ geometry: { type: "Point", coordinates: o[l] }, properties: n(l) });
1143
+ const a = [], l = s === "Polygon" ? o.length - 1 : o.length;
1144
+ for (let d = 0; d < l; d++) a.push({ geometry: { type: "Point", coordinates: o[d] }, properties: n(d) });
1145
1145
  return a;
1146
1146
  }(t, e, (o) => ({ mode: this.mode, selectionPoint: !0, selectionPointFeatureId: i, index: o })));
1147
1147
  }
@@ -1155,52 +1155,52 @@ class Ke extends B {
1155
1155
  if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
1156
1156
  }
1157
1157
  }
1158
- function ge(r, t) {
1158
+ function Ce(r, t) {
1159
1159
  let e = !1;
1160
1160
  for (let n = 0, a = t.length; n < a; n++) {
1161
- const d = t[n];
1162
- for (let l = 0, c = d.length, h = c - 1; l < c; h = l++) (o = d[l])[1] > (i = r)[1] != (s = d[h])[1] > i[1] && i[0] < (s[0] - o[0]) * (i[1] - o[1]) / (s[1] - o[1]) + o[0] && (e = !e);
1161
+ const l = t[n];
1162
+ for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i = r)[1] != (s = l[h])[1] > i[1] && i[0] < (s[0] - o[0]) * (i[1] - o[1]) / (s[1] - o[1]) + o[0] && (e = !e);
1163
1163
  }
1164
1164
  var i, o, s;
1165
1165
  return e;
1166
1166
  }
1167
- const ye = (r, t, e) => {
1167
+ const Pe = (r, t, e) => {
1168
1168
  const i = (s) => s * s, o = (s, n) => i(s.x - n.x) + i(s.y - n.y);
1169
1169
  return Math.sqrt(((s, n, a) => {
1170
- const d = o(n, a);
1171
- if (d === 0) return o(s, n);
1172
- let l = ((s.x - n.x) * (a.x - n.x) + (s.y - n.y) * (a.y - n.y)) / d;
1173
- return l = Math.max(0, Math.min(1, l)), o(s, { x: n.x + l * (a.x - n.x), y: n.y + l * (a.y - n.y) });
1170
+ const l = o(n, a);
1171
+ if (l === 0) return o(s, n);
1172
+ let d = ((s.x - n.x) * (a.x - n.x) + (s.y - n.y) * (a.y - n.y)) / l;
1173
+ return d = Math.max(0, Math.min(1, d)), o(s, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
1174
1174
  })(r, t, e));
1175
1175
  };
1176
- class Ye extends B {
1176
+ class Qe extends B {
1177
1177
  constructor(t, e, i) {
1178
1178
  super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
1179
1179
  }
1180
1180
  find(t, e) {
1181
- let i, o, s, n, a = 1 / 0, d = 1 / 0, l = 1 / 0;
1181
+ let i, o, s, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
1182
1182
  const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
1183
1183
  for (let u = 0; u < h.length; u++) {
1184
1184
  const p = h[u], g = p.geometry;
1185
1185
  if (g.type === "Point") {
1186
1186
  if (p.properties.selectionPoint || !e && p.properties[V.MID_POINT]) continue;
1187
1187
  const y = this.pixelDistance.measure(t, g.coordinates);
1188
- p.properties[V.MID_POINT] && y < this.pointerDistance && y < l ? (l = y, s = p) : !p.properties[V.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
1188
+ p.properties[V.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, s = p) : !p.properties[V.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
1189
1189
  } else if (g.type === "LineString") {
1190
1190
  if (i) continue;
1191
1191
  for (let y = 0; y < g.coordinates.length - 1; y++) {
1192
- const v = g.coordinates[y], f = g.coordinates[y + 1], m = ye({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
1193
- m < this.pointerDistance && m < d && (d = m, o = p);
1192
+ const v = g.coordinates[y], f = g.coordinates[y + 1], m = Pe({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
1193
+ m < this.pointerDistance && m < l && (l = m, o = p);
1194
1194
  }
1195
1195
  } else if (g.type === "Polygon") {
1196
1196
  if (i || o) continue;
1197
- ge([t.lng, t.lat], g.coordinates) && (n = p);
1197
+ Ce([t.lng, t.lat], g.coordinates) && (n = p);
1198
1198
  }
1199
1199
  }
1200
1200
  return { clickedFeature: i || o || n, clickedMidPoint: s };
1201
1201
  }
1202
1202
  }
1203
- class $e extends B {
1203
+ class ti extends B {
1204
1204
  constructor(t, e, i, o) {
1205
1205
  super(t), 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 = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o;
1206
1206
  }
@@ -1223,27 +1223,27 @@ class $e extends B {
1223
1223
  if (i.type === "Polygon" || i.type === "LineString") {
1224
1224
  let s, n;
1225
1225
  if (i.type === "Polygon" ? (s = i.coordinates[0], n = s.length - 1) : (s = i.coordinates, n = s.length), !this.dragPosition) return !1;
1226
- for (let l = 0; l < n; l++) {
1227
- const c = s[l];
1226
+ for (let d = 0; d < n; d++) {
1227
+ const c = s[d];
1228
1228
  let h, u;
1229
1229
  if (this.config.projection === "web-mercator") {
1230
- const p = S(this.dragPosition[0], this.dragPosition[1]), g = S(o[0], o[1]), y = S(c[0], c[1]), v = { x: p.x - g.x, y: p.y - g.y }, f = y.x - v.x, m = y.y - v.y, { lng: C, lat: P } = W(f, m);
1230
+ const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(o[0], o[1]), y = x(c[0], c[1]), v = { x: p.x - g.x, y: p.y - g.y }, f = y.x - v.x, m = y.y - v.y, { lng: C, lat: P } = W(f, m);
1231
1231
  h = C, u = P;
1232
1232
  } else {
1233
1233
  const p = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
1234
1234
  h = c[0] - p[0], u = c[1] - p[1];
1235
1235
  }
1236
- if (h = F(h, this.config.coordinatePrecision), u = F(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
1237
- s[l] = [h, u];
1236
+ if (h = E(h, this.config.coordinatePrecision), u = E(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
1237
+ s[d] = [h, u];
1238
1238
  }
1239
1239
  i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
1240
- const a = this.selectionPoints.getUpdated(s) || [], d = this.midPoints.getUpdated(s) || [];
1240
+ const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [];
1241
1241
  if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional }).valid) return !1;
1242
- this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...d]), this.dragPosition = [t.lng, t.lat];
1242
+ this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [t.lng, t.lat];
1243
1243
  } else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
1244
1244
  }
1245
1245
  }
1246
- class He extends B {
1246
+ class ei extends B {
1247
1247
  constructor(t, e, i, o) {
1248
1248
  super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
1249
1249
  }
@@ -1277,8 +1277,8 @@ class He extends B {
1277
1277
  const h = n.length - 1;
1278
1278
  n[0] = a, n[h] = a;
1279
1279
  }
1280
- const d = this.selectionPoints.getOneUpdated(o, a), l = d ? [d] : [], c = this.midPoints.getUpdated(n) || [];
1281
- return !(s.type !== "Point" && !e && Et({ geometry: s }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...l, ...c]), 0));
1280
+ const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(n) || [];
1281
+ return !(s.type !== "Point" && !e && Ot({ geometry: s }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...c]), 0));
1282
1282
  }
1283
1283
  isDragging() {
1284
1284
  return this.draggedCoordinate.id !== null;
@@ -1296,38 +1296,38 @@ function gt(r) {
1296
1296
  t += o[0], e += o[1], i++;
1297
1297
  }, !0), [t / i, e / i];
1298
1298
  }
1299
- function fe(r, t) {
1299
+ function Se(r, t) {
1300
1300
  r[0] += r[0] - t[0] > 180 ? -360 : t[0] - r[0] > 180 ? 360 : 0;
1301
- const e = ie, i = t[1] * Math.PI / 180, o = r[1] * Math.PI / 180, s = o - i;
1301
+ const e = ae, i = t[1] * Math.PI / 180, o = r[1] * Math.PI / 180, s = o - i;
1302
1302
  let n = Math.abs(r[0] - t[0]) * Math.PI / 180;
1303
1303
  n > Math.PI && (n -= 2 * Math.PI);
1304
- const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), d = Math.abs(a) > 1e-11 ? s / a : Math.cos(i);
1305
- return Math.sqrt(s * s + d * d * n * n) * e;
1304
+ const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? s / a : Math.cos(i);
1305
+ return Math.sqrt(s * s + l * l * n * n) * e;
1306
1306
  }
1307
1307
  function yt(r) {
1308
1308
  const t = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map((e) => {
1309
- const { x: i, y: o } = S(e[0], e[1]);
1309
+ const { x: i, y: o } = x(e[0], e[1]);
1310
1310
  return [i, o];
1311
1311
  });
1312
1312
  return r.geometry.type === "Polygon" ? function(e) {
1313
1313
  let i = 0, o = 0, s = 0;
1314
1314
  const n = e.length;
1315
1315
  for (let a = 0; a < n - 1; a++) {
1316
- const [d, l] = e[a], [c, h] = e[a + 1], u = d * h - c * l;
1317
- i += u, o += (d + c) * u, s += (l + h) * u;
1316
+ const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
1317
+ i += u, o += (l + c) * u, s += (d + h) * u;
1318
1318
  }
1319
1319
  return i /= 2, o /= 6 * i, s /= 6 * i, { x: o, y: s };
1320
1320
  }(t) : function(e) {
1321
1321
  const i = e.length;
1322
1322
  let o = 0, s = 0;
1323
1323
  for (let n = 0; n < i; n++) {
1324
- const [a, d] = e[n];
1325
- o += a, s += d;
1324
+ const [a, l] = e[n];
1325
+ o += a, s += l;
1326
1326
  }
1327
1327
  return { x: o / i, y: s / i };
1328
1328
  }(t);
1329
1329
  }
1330
- class qe extends B {
1330
+ class ii extends B {
1331
1331
  constructor(t, e, i) {
1332
1332
  super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
1333
1333
  }
@@ -1341,10 +1341,10 @@ class qe extends B {
1341
1341
  let n;
1342
1342
  const a = { type: "Feature", geometry: o, properties: {} };
1343
1343
  if (this.config.projection === "web-mercator") {
1344
- if (n = G(yt(a), S(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
1344
+ if (n = T(yt(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
1345
1345
  ((h, u) => {
1346
1346
  if (u === 0 || u === 360 || u === -360) return h;
1347
- const p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, m]) => S(f, m)), y = g.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
1347
+ const p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, m]) => x(f, m)), y = g.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
1348
1348
  y.x /= g.length, y.y /= g.length;
1349
1349
  const v = g.map((f) => ({ x: y.x + (f.x - y.x) * Math.cos(p) - (f.y - y.y) * Math.sin(p), y: y.y + (f.x - y.x) * Math.sin(p) + (f.y - y.y) * Math.cos(p) })).map(({ x: f, y: m }) => [W(f, m).lng, W(f, m).lat]);
1350
1350
  h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = v : h.geometry.coordinates = v;
@@ -1356,21 +1356,21 @@ class qe extends B {
1356
1356
  if (u === 0 || u === 360 || u === -360) return h;
1357
1357
  const p = gt(h);
1358
1358
  (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((g) => {
1359
- const y = pt(p, g) + u, v = fe(p, g), f = Dt(p, v, y);
1359
+ const y = pt(p, g) + u, v = Se(p, g), f = _t(p, v, y);
1360
1360
  g[0] = f[0], g[1] = f[1];
1361
1361
  });
1362
1362
  })(a, -(this.lastBearing - (n + 180)));
1363
1363
  }
1364
- const d = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1365
- d.forEach((h) => {
1366
- h[0] = F(h[0], this.coordinatePrecision), h[1] = F(h[1], this.coordinatePrecision);
1364
+ const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1365
+ l.forEach((h) => {
1366
+ h[0] = E(h[0], this.coordinatePrecision), h[1] = E(h[1], this.coordinatePrecision);
1367
1367
  });
1368
- const l = this.midPoints.getUpdated(d) || [], c = this.selectionPoints.getUpdated(d) || [];
1368
+ const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [];
1369
1369
  if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional })) return !1;
1370
- this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...l]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
1370
+ this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
1371
1371
  }
1372
1372
  }
1373
- class Je extends B {
1373
+ class oi extends B {
1374
1374
  constructor(t, e, i) {
1375
1375
  super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
1376
1376
  }
@@ -1382,39 +1382,39 @@ class Je extends B {
1382
1382
  if (o.type !== "Polygon" && o.type !== "LineString") return;
1383
1383
  const s = [t.lng, t.lat], n = { type: "Feature", geometry: o, properties: {} };
1384
1384
  let a;
1385
- const d = yt(n);
1385
+ const l = yt(n);
1386
1386
  if (this.config.projection === "web-mercator") {
1387
- const p = S(t.lng, t.lat);
1388
- a = D(d, p);
1387
+ const p = x(t.lng, t.lat);
1388
+ a = D(l, p);
1389
1389
  } else {
1390
1390
  if (this.config.projection !== "globe") throw new Error("Invalid projection");
1391
- a = T(gt({ geometry: o }), s);
1391
+ a = G(gt({ geometry: o }), s);
1392
1392
  }
1393
1393
  if (!this.lastDistance) return void (this.lastDistance = a);
1394
- const l = 1 - (this.lastDistance - a) / a;
1394
+ const d = 1 - (this.lastDistance - a) / a;
1395
1395
  if (this.config.projection === "web-mercator") {
1396
- const { lng: p, lat: g } = W(d.x, d.y);
1396
+ const { lng: p, lat: g } = W(l.x, l.y);
1397
1397
  (function(y, v, f) {
1398
1398
  if (v === 1) return y;
1399
- const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([x, I]) => S(x, I)), C = S(f[0], f[1]), P = m.map((x) => ({ x: C.x + (x.x - C.x) * v, y: C.y + (x.y - C.y) * v })).map(({ x, y: I }) => [W(x, I).lng, W(x, I).lat]);
1399
+ const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, I]) => x(S, I)), C = x(f[0], f[1]), P = m.map((S) => ({ x: C.x + (S.x - C.x) * v, y: C.y + (S.y - C.y) * v })).map(({ x: S, y: I }) => [W(S, I).lng, W(S, I).lat]);
1400
1400
  y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = P : y.geometry.coordinates = P;
1401
- })(n, l, [p, g]);
1401
+ })(n, d, [p, g]);
1402
1402
  } else this.config.projection === "globe" && function(p, g, y, v = "xy") {
1403
1403
  g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
1404
- const m = fe(y, f), C = pt(y, f), P = Dt(y, m * g, C);
1404
+ const m = Se(y, f), C = pt(y, f), P = _t(y, m * g, C);
1405
1405
  v !== "x" && v !== "xy" || (f[0] = P[0]), v !== "y" && v !== "xy" || (f[1] = P[1]);
1406
1406
  });
1407
- }(n, l, gt(n));
1407
+ }(n, d, gt(n));
1408
1408
  const c = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1409
1409
  c.forEach((p) => {
1410
- p[0] = F(p[0], this.coordinatePrecision), p[1] = F(p[1], this.coordinatePrecision);
1410
+ p[0] = E(p[0], this.coordinatePrecision), p[1] = E(p[1], this.coordinatePrecision);
1411
1411
  });
1412
1412
  const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
1413
1413
  if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional })) return !1;
1414
1414
  this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...h]), this.lastDistance = a;
1415
1415
  }
1416
1416
  }
1417
- class Ze extends B {
1417
+ class si extends B {
1418
1418
  constructor(t, e, i, o) {
1419
1419
  super(t), 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 = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
1420
1420
  }
@@ -1475,16 +1475,16 @@ class Ze extends B {
1475
1475
  if (!e) return null;
1476
1476
  const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = yt(i);
1477
1477
  if (!a) return null;
1478
- const d = S(n[0], n[1]), { closestBBoxIndex: l } = this.getIndexesWebMercator(o, d), c = S(t.lng, t.lat);
1479
- return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: d, webMercatorOrigin: a }), s;
1478
+ const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
1479
+ return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1480
1480
  }
1481
1481
  centerFixedWebMercatorDrag(t) {
1482
1482
  const e = this.getSelectedFeatureDataWebMercator();
1483
1483
  if (!e) return null;
1484
1484
  const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = yt(i);
1485
1485
  if (!a) return null;
1486
- const d = S(n[0], n[1]), { closestBBoxIndex: l } = this.getIndexesWebMercator(o, d), c = S(t.lng, t.lat);
1487
- return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: d, webMercatorOrigin: a }), s;
1486
+ const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
1487
+ return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1488
1488
  }
1489
1489
  scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
1490
1490
  if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
@@ -1494,22 +1494,22 @@ class Ze extends B {
1494
1494
  oppositeFixedWebMercatorDrag(t) {
1495
1495
  const e = this.getSelectedFeatureDataWebMercator();
1496
1496
  if (!e) return null;
1497
- const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = S(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: d } = this.getIndexesWebMercator(i, n), l = { x: i[a][0], y: i[a][1] }, c = S(t.lng, t.lat);
1498
- return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: l }), o;
1497
+ const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
1498
+ return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
1499
1499
  }
1500
1500
  oppositeWebMercatorDrag(t) {
1501
1501
  const e = this.getSelectedFeatureDataWebMercator();
1502
1502
  if (!e) return null;
1503
- const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = S(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: d } = this.getIndexesWebMercator(i, n), l = { x: i[a][0], y: i[a][1] }, c = S(t.lng, t.lat);
1504
- return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: l }), o;
1503
+ const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
1504
+ return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
1505
1505
  }
1506
1506
  scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
1507
1507
  const n = e.x - o.x, a = e.y - o.y;
1508
1508
  if (!this.isValidDragWebMercator(t, n, a)) return null;
1509
- let d = 1;
1510
- n !== 0 && t !== 1 && t !== 5 && (d = 1 - (e.x - i.x - n) / n);
1511
1509
  let l = 1;
1512
- return a !== 0 && t !== 3 && t !== 7 && (l = 1 - (e.y - i.y - a) / a), this.validateScale(d, l) ? (d < 0 && (d = this.minimumScale), l < 0 && (l = this.minimumScale), this.performWebMercatorScale(s, e.x, e.y, d, l), s) : null;
1510
+ n !== 0 && t !== 1 && t !== 5 && (l = 1 - (e.x - i.x - n) / n);
1511
+ let d = 1;
1512
+ return a !== 0 && t !== 3 && t !== 7 && (d = 1 - (e.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(s, e.x, e.y, l, d), s) : null;
1513
1513
  }
1514
1514
  getFeature(t) {
1515
1515
  if (this.draggedCoordinate.id === null) return null;
@@ -1525,17 +1525,17 @@ class Ze extends B {
1525
1525
  }
1526
1526
  performWebMercatorScale(t, e, i, o, s) {
1527
1527
  t.forEach((n) => {
1528
- const { x: a, y: d } = S(n[0], n[1]), l = e + (a - e) * o, c = i + (d - i) * s, { lng: h, lat: u } = W(l, c);
1528
+ const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * s, { lng: h, lat: u } = W(d, c);
1529
1529
  n[0] = h, n[1] = u;
1530
1530
  });
1531
1531
  }
1532
1532
  getBBoxWebMercator(t) {
1533
1533
  const e = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
1534
1534
  (t = t.map((a) => {
1535
- const { x: d, y: l } = S(a[0], a[1]);
1536
- return [d, l];
1537
- })).forEach(([a, d]) => {
1538
- a < e[0] && (e[0] = a), d < e[1] && (e[1] = d), a > e[2] && (e[2] = a), d > e[3] && (e[3] = d);
1535
+ const { x: l, y: d } = x(a[0], a[1]);
1536
+ return [l, d];
1537
+ })).forEach(([a, l]) => {
1538
+ a < e[0] && (e[0] = a), l < e[1] && (e[1] = l), a > e[2] && (e[2] = a), l > e[3] && (e[3] = l);
1539
1539
  });
1540
1540
  const [i, o, s, n] = e;
1541
1541
  return [[i, n], [(i + s) / 2, n], [s, n], [s, n + (o - n) / 2], [s, o], [(i + s) / 2, o], [i, o], [i, n + (o - n) / 2]];
@@ -1568,15 +1568,15 @@ class Ze extends B {
1568
1568
  if (!o) return !1;
1569
1569
  let s = null;
1570
1570
  if (e === "center" ? s = this.centerWebMercatorDrag(t) : e === "opposite" ? s = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? s = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (s = this.oppositeFixedWebMercatorDrag(t)), !s) return !1;
1571
- for (let l = 0; l < s.length; l++) {
1572
- const c = s[l];
1573
- if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !mt(c, this.coordinatePrecision)) return !1;
1571
+ for (let d = 0; d < s.length; d++) {
1572
+ const c = s[d];
1573
+ if (c[0] = E(c[0], this.coordinatePrecision), c[1] = E(c[1], this.coordinatePrecision), !mt(c, this.coordinatePrecision)) return !1;
1574
1574
  }
1575
- const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], d = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
1576
- return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: d, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: w.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: d }, ...a, ...n]), 0));
1575
+ const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
1576
+ 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: w.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
1577
1577
  }
1578
1578
  }
1579
- class Qe extends De {
1579
+ class ri extends Be {
1580
1580
  constructor(t) {
1581
1581
  var e;
1582
1582
  super(t), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = void 0, this.keyEvents = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.cursors = void 0, this.validations = {}, this.flags = t && t.flags ? t.flags : {};
@@ -1599,7 +1599,7 @@ class Qe extends De {
1599
1599
  this._state = "selecting";
1600
1600
  }
1601
1601
  registerBehaviors(t) {
1602
- this.pixelDistance = new Pt(t), this.clickBoundingBox = new Ct(t), this.featuresAtMouseEvent = new Ye(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Ke(t), this.midPoints = new Xe(t, this.selectionPoints), this.rotateFeature = new qe(t, this.selectionPoints, this.midPoints), this.scaleFeature = new Je(t, this.selectionPoints, this.midPoints), this.dragFeature = new $e(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new He(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Ze(t, this.pixelDistance, this.selectionPoints, this.midPoints);
1602
+ this.pixelDistance = new Pt(t), this.clickBoundingBox = new Ct(t), this.featuresAtMouseEvent = new Qe(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Ze(t), this.midPoints = new Je(t, this.selectionPoints), this.rotateFeature = new ii(t, this.selectionPoints, this.midPoints), this.scaleFeature = new oi(t, this.selectionPoints, this.midPoints), this.dragFeature = new ti(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new ei(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new si(t, this.pixelDistance, this.selectionPoints, this.midPoints);
1603
1603
  }
1604
1604
  deselectFeature() {
1605
1605
  this.deselect();
@@ -1618,14 +1618,14 @@ class Qe extends De {
1618
1618
  const u = this.store.getGeometryCopy(h), p = this.pixelDistance.measure(t, u.coordinates);
1619
1619
  p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(h));
1620
1620
  }), !e) return;
1621
- const o = e.selectionPointFeatureId, s = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], d = this.validations[n.mode];
1621
+ const o = e.selectionPointFeatureId, s = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
1622
1622
  if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
1623
- const l = this.store.getGeometryCopy(o);
1623
+ const d = this.store.getGeometryCopy(o);
1624
1624
  let c;
1625
- if (l.type === "Polygon") {
1626
- if (c = l.coordinates[0], c.length <= 4) return;
1627
- } else if (l.type === "LineString" && (c = l.coordinates, c.length <= 2)) return;
1628
- c && (l.type !== "Polygon" || s !== 0 && s !== c.length - 1 ? c.splice(s, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), (!d || d({ id: o, type: "Feature", geometry: l, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: l }]), this.selectionPoints.create(c, l.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision)));
1625
+ if (d.type === "Polygon") {
1626
+ if (c = d.coordinates[0], c.length <= 4) return;
1627
+ } else if (d.type === "LineString" && (c = d.coordinates, c.length <= 2)) return;
1628
+ c && (d.type !== "Polygon" || s !== 0 && s !== c.length - 1 ? c.splice(s, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: w.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision)));
1629
1629
  }
1630
1630
  select(t, e = !0) {
1631
1631
  if (this.selected[0] === t) return;
@@ -1639,8 +1639,8 @@ class Qe extends De {
1639
1639
  e && this.setCursor(this.cursors.pointerOver), this.selected = [t], this.store.updateProperty([{ id: t, property: "selected", value: !0 }]), this.onSelect(t);
1640
1640
  const { type: n, coordinates: a } = this.store.getGeometryCopy(t);
1641
1641
  if (n !== "LineString" && n !== "Polygon") return;
1642
- const d = n === "LineString" ? a : a[0];
1643
- d && o && o.feature.coordinates && (this.selectionPoints.create(d, n, t), o.feature.coordinates.midpoints && this.midPoints.create(d, t, this.coordinatePrecision));
1642
+ const l = n === "LineString" ? a : a[0];
1643
+ l && o && o.feature.coordinates && (this.selectionPoints.create(l, n, t), o.feature.coordinates.midpoints && this.midPoints.create(l, t, this.coordinatePrecision));
1644
1644
  }
1645
1645
  onLeftClick(t) {
1646
1646
  const { clickedFeature: e, clickedMidPoint: i } = this.featuresAtMouseEvent.find(t, this.selected.length > 0);
@@ -1734,7 +1734,7 @@ class Qe extends De {
1734
1734
  return e;
1735
1735
  }
1736
1736
  }
1737
- class ti extends N {
1737
+ class ni extends N {
1738
1738
  constructor(...t) {
1739
1739
  super(...t), this.type = Y.Static, this.mode = "static";
1740
1740
  }
@@ -1762,11 +1762,11 @@ class ti extends N {
1762
1762
  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 });
1763
1763
  }
1764
1764
  }
1765
- function me(r, t, e, i, o) {
1765
+ function xe(r, t, e, i, o) {
1766
1766
  for (; i > e; ) {
1767
1767
  if (i - e > 600) {
1768
- const d = i - e + 1, l = t - e + 1, c = Math.log(d), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (d - h) / d) * (l - d / 2 < 0 ? -1 : 1);
1769
- me(r, t, Math.max(e, Math.floor(t - l * h / d + u)), Math.min(i, Math.floor(t + (d - l) * h / d + u)), o);
1768
+ const l = i - e + 1, d = t - e + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
1769
+ xe(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
1770
1770
  }
1771
1771
  const s = r[t];
1772
1772
  let n = e, a = i;
@@ -1795,23 +1795,23 @@ function it(r, t, e, i, o) {
1795
1795
  function ot(r, t) {
1796
1796
  return r.minX = Math.min(r.minX, t.minX), r.minY = Math.min(r.minY, t.minY), r.maxX = Math.max(r.maxX, t.maxX), r.maxY = Math.max(r.maxY, t.maxY), r;
1797
1797
  }
1798
- function ei(r, t) {
1798
+ function ai(r, t) {
1799
1799
  return r.minX - t.minX;
1800
1800
  }
1801
- function ii(r, t) {
1801
+ function li(r, t) {
1802
1802
  return r.minY - t.minY;
1803
1803
  }
1804
- function Mt(r) {
1804
+ function It(r) {
1805
1805
  return (r.maxX - r.minX) * (r.maxY - r.minY);
1806
1806
  }
1807
1807
  function dt(r) {
1808
1808
  return r.maxX - r.minX + (r.maxY - r.minY);
1809
1809
  }
1810
- function oi(r, t) {
1810
+ function di(r, t) {
1811
1811
  const e = Math.max(r.minX, t.minX), i = Math.max(r.minY, t.minY), o = Math.min(r.maxX, t.maxX), s = Math.min(r.maxY, t.maxY);
1812
1812
  return Math.max(0, o - e) * Math.max(0, s - i);
1813
1813
  }
1814
- function It(r, t) {
1814
+ function wt(r, t) {
1815
1815
  return r.minX <= t.minX && r.minY <= t.minY && t.maxX <= r.maxX && t.maxY <= r.maxY;
1816
1816
  }
1817
1817
  function ct(r, t) {
@@ -1820,15 +1820,15 @@ function ct(r, t) {
1820
1820
  function q(r) {
1821
1821
  return { children: r, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
1822
1822
  }
1823
- function Yt(r, t, e, i, o) {
1823
+ function Ht(r, t, e, i, o) {
1824
1824
  const s = [t, e];
1825
1825
  for (; s.length; ) {
1826
1826
  if ((e = s.pop()) - (t = s.pop()) <= i) continue;
1827
1827
  const n = t + Math.ceil((e - t) / i / 2) * i;
1828
- me(r, n, t, e, o), s.push(t, n, n, e);
1828
+ xe(r, n, t, e, o), s.push(t, n, n, e);
1829
1829
  }
1830
1830
  }
1831
- class si {
1831
+ class ci {
1832
1832
  constructor(t) {
1833
1833
  this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
1834
1834
  }
@@ -1839,8 +1839,8 @@ class si {
1839
1839
  const o = this.toBBox, s = [];
1840
1840
  for (; e; ) {
1841
1841
  for (let n = 0; n < e.children.length; n++) {
1842
- const a = e.children[n], d = e.leaf ? o(a) : a;
1843
- ct(t, d) && (e.leaf ? i.push(a) : It(t, d) ? this._all(a, i) : s.push(a));
1842
+ const a = e.children[n], l = e.leaf ? o(a) : a;
1843
+ ct(t, l) && (e.leaf ? i.push(a) : wt(t, l) ? this._all(a, i) : s.push(a));
1844
1844
  }
1845
1845
  e = s.pop();
1846
1846
  }
@@ -1854,7 +1854,7 @@ class si {
1854
1854
  for (let o = 0; o < e.children.length; o++) {
1855
1855
  const s = e.children[o], n = e.leaf ? this.toBBox(s) : s;
1856
1856
  if (ct(t, n)) {
1857
- if (e.leaf || It(t, n)) return !0;
1857
+ if (e.leaf || wt(t, n)) return !0;
1858
1858
  i.push(s);
1859
1859
  }
1860
1860
  }
@@ -1888,13 +1888,13 @@ class si {
1888
1888
  remove(t) {
1889
1889
  let e = this.data;
1890
1890
  const i = this.toBBox(t), o = [], s = [];
1891
- let n, a, d = !1;
1891
+ let n, a, l = !1;
1892
1892
  for (; e || o.length; ) {
1893
- if (e || (e = o.pop(), a = o[o.length - 1], n = s.pop(), d = !0), e.leaf) {
1894
- const l = e.children.indexOf(t);
1895
- l !== -1 && (e.children.splice(l, 1), o.push(e), this._condense(o));
1893
+ if (e || (e = o.pop(), a = o[o.length - 1], n = s.pop(), l = !0), e.leaf) {
1894
+ const d = e.children.indexOf(t);
1895
+ d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
1896
1896
  }
1897
- d || e.leaf || !It(e, i) ? a ? (n++, e = a.children[n], d = !1) : e = null : (o.push(e), s.push(n), n = 0, a = e, e = e.children[0]);
1897
+ l || e.leaf || !wt(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), s.push(n), n = 0, a = e, e = e.children[0]);
1898
1898
  }
1899
1899
  }
1900
1900
  toBBox(t) {
@@ -1916,13 +1916,13 @@ class si {
1916
1916
  let n, a = this._maxEntries;
1917
1917
  if (s <= a) return n = q(t.slice(e, i + 1)), $(n, this.toBBox), n;
1918
1918
  o || (o = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, o - 1))), n = q([]), n.leaf = !1, n.height = o;
1919
- const d = Math.ceil(s / a), l = d * Math.ceil(Math.sqrt(a));
1920
- Yt(t, e, i, l, this.compareMinX);
1921
- for (let c = e; c <= i; c += l) {
1922
- const h = Math.min(c + l - 1, i);
1923
- Yt(t, c, h, d, this.compareMinY);
1924
- for (let u = c; u <= h; u += d) {
1925
- const p = Math.min(u + d - 1, h);
1919
+ const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
1920
+ Ht(t, e, i, d, this.compareMinX);
1921
+ for (let c = e; c <= i; c += d) {
1922
+ const h = Math.min(c + d - 1, i);
1923
+ Ht(t, c, h, l, this.compareMinY);
1924
+ for (let u = c; u <= h; u += l) {
1925
+ const p = Math.min(u + l - 1, h);
1926
1926
  n.children.push(this._build(t, u, p, o - 1));
1927
1927
  }
1928
1928
  }
@@ -1930,10 +1930,10 @@ class si {
1930
1930
  }
1931
1931
  _chooseSubtree(t, e, i, o) {
1932
1932
  for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
1933
- let a, d = 1 / 0, l = 1 / 0;
1933
+ let a, l = 1 / 0, d = 1 / 0;
1934
1934
  for (let c = 0; c < e.children.length; c++) {
1935
- const h = e.children[c], u = Mt(h), p = (s = t, n = h, (Math.max(n.maxX, s.maxX) - Math.min(n.minX, s.minX)) * (Math.max(n.maxY, s.maxY) - Math.min(n.minY, s.minY)) - u);
1936
- p < l ? (l = p, d = u < d ? u : d, a = h) : p === l && u < d && (d = u, a = h);
1935
+ const h = e.children[c], u = It(h), p = (s = t, n = h, (Math.max(n.maxX, s.maxX) - Math.min(n.minX, s.minX)) * (Math.max(n.maxY, s.maxY) - Math.min(n.minY, s.minY)) - u);
1936
+ p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
1937
1937
  }
1938
1938
  e = a || e.children[0];
1939
1939
  }
@@ -1957,28 +1957,28 @@ class si {
1957
1957
  _chooseSplitIndex(t, e, i) {
1958
1958
  let o, s = 1 / 0, n = 1 / 0;
1959
1959
  for (let a = e; a <= i - e; a++) {
1960
- const d = it(t, 0, a, this.toBBox), l = it(t, a, i, this.toBBox), c = oi(d, l), h = Mt(d) + Mt(l);
1960
+ const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), c = di(l, d), h = It(l) + It(d);
1961
1961
  c < s ? (s = c, o = a, n = h < n ? h : n) : c === s && h < n && (n = h, o = a);
1962
1962
  }
1963
1963
  return o || i - e;
1964
1964
  }
1965
1965
  _chooseSplitAxis(t, e, i) {
1966
- const o = t.leaf ? this.compareMinX : ei, s = t.leaf ? this.compareMinY : ii;
1966
+ const o = t.leaf ? this.compareMinX : ai, s = t.leaf ? this.compareMinY : li;
1967
1967
  this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, s) && t.children.sort(o);
1968
1968
  }
1969
1969
  _allDistMargin(t, e, i, o) {
1970
1970
  t.children.sort(o);
1971
1971
  const s = this.toBBox, n = it(t, 0, e, s), a = it(t, i - e, i, s);
1972
- let d = dt(n) + dt(a);
1973
- for (let l = e; l < i - e; l++) {
1974
- const c = t.children[l];
1975
- ot(n, t.leaf ? s(c) : c), d += dt(n);
1972
+ let l = dt(n) + dt(a);
1973
+ for (let d = e; d < i - e; d++) {
1974
+ const c = t.children[d];
1975
+ ot(n, t.leaf ? s(c) : c), l += dt(n);
1976
1976
  }
1977
- for (let l = i - e - 1; l >= e; l--) {
1978
- const c = t.children[l];
1979
- ot(a, t.leaf ? s(c) : c), d += dt(a);
1977
+ for (let d = i - e - 1; d >= e; d--) {
1978
+ const c = t.children[d];
1979
+ ot(a, t.leaf ? s(c) : c), l += dt(a);
1980
1980
  }
1981
- return d;
1981
+ return l;
1982
1982
  }
1983
1983
  _adjustParentBBoxes(t, e, i) {
1984
1984
  for (let o = i; o >= 0; o--) ot(e[o], t);
@@ -1987,9 +1987,9 @@ class si {
1987
1987
  for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() : $(t[i], this.toBBox);
1988
1988
  }
1989
1989
  }
1990
- class ri {
1990
+ class hi {
1991
1991
  constructor(t) {
1992
- this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new si(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
1992
+ this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new ci(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
1993
1993
  }
1994
1994
  setMaps(t, e) {
1995
1995
  this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
@@ -2040,14 +2040,14 @@ class ri {
2040
2040
  return this.tree.collides(this.toBBox(t));
2041
2041
  }
2042
2042
  }
2043
- const ni = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
2043
+ const ui = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
2044
2044
  const t = 16 * Math.random() | 0;
2045
2045
  return (r == "x" ? t : 3 & t | 8).toString(16);
2046
2046
  }), isValidId: (r) => typeof r == "string" && r.length === 36 };
2047
- class ai {
2047
+ class pi {
2048
2048
  constructor(t) {
2049
2049
  this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
2050
- }, this.store = {}, this.spatialIndex = new ri(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : ni;
2050
+ }, this.store = {}, this.spatialIndex = new hi(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : ui;
2051
2051
  }
2052
2052
  clone(t) {
2053
2053
  return JSON.parse(JSON.stringify(t));
@@ -2066,15 +2066,15 @@ class ai {
2066
2066
  n.id == null && (n.id = this.idStrategy.getId());
2067
2067
  const a = n.id;
2068
2068
  if (e) {
2069
- const d = e(n);
2070
- if (!d.valid) return s.push({ id: a, valid: !1, reason: d.reason }), !1;
2069
+ const l = e(n);
2070
+ if (!l.valid) return s.push({ id: a, valid: !1, reason: l.reason }), !1;
2071
2071
  }
2072
2072
  if (this.tracked) {
2073
2073
  if (n.properties.createdAt) {
2074
- if (!Nt(n.properties.createdAt)) return s.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2074
+ if (!Tt(n.properties.createdAt)) return s.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2075
2075
  } else n.properties.createdAt = +/* @__PURE__ */ new Date();
2076
2076
  if (n.properties.updatedAt) {
2077
- if (!Nt(n.properties.updatedAt)) return s.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2077
+ if (!Tt(n.properties.updatedAt)) return s.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2078
2078
  } else n.properties.updatedAt = +/* @__PURE__ */ new Date();
2079
2079
  }
2080
2080
  return this.has(a) ? (s.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = n, o.push(a), s.push({ id: a, valid: !0 }), !0);
@@ -2121,8 +2121,8 @@ class ai {
2121
2121
  return t.forEach(({ geometry: i, properties: o }) => {
2122
2122
  let s, n = M({}, o);
2123
2123
  this.tracked && (s = +/* @__PURE__ */ new Date(), o ? (n.createdAt = typeof o.createdAt == "number" ? o.createdAt : s, n.updatedAt = typeof o.updatedAt == "number" ? o.updatedAt : s) : n = { createdAt: s, updatedAt: s });
2124
- const a = this.getId(), d = { id: a, type: "Feature", geometry: i, properties: n };
2125
- this.store[a] = d, this.spatialIndex.insert(d), e.push(a);
2124
+ const a = this.getId(), l = { id: a, type: "Feature", geometry: i, properties: n };
2125
+ this.store[a] = l, this.spatialIndex.insert(l), e.push(a);
2126
2126
  }), this._onChange && this._onChange([...e], "create"), e;
2127
2127
  }
2128
2128
  delete(t) {
@@ -2141,13 +2141,13 @@ class ai {
2141
2141
  return Object.keys(this.store).length;
2142
2142
  }
2143
2143
  }
2144
- const li = "Feature is not a Polygon or LineString", di = "Feature intersects itself", ci = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: li } : Et(r) ? { valid: !1, reason: di } : { valid: !0 };
2145
- function $t(r, t, e) {
2146
- const i = G(r, t);
2147
- let o = G(t, e) - i;
2144
+ const gi = "Feature is not a Polygon or LineString", yi = "Feature intersects itself", fi = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: gi } : Ot(r) ? { valid: !1, reason: yi } : { valid: !0 };
2145
+ function qt(r, t, e) {
2146
+ const i = T(r, t);
2147
+ let o = T(t, e) - i;
2148
2148
  return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
2149
2149
  }
2150
- class ve extends N {
2150
+ class Me extends N {
2151
2151
  constructor(t) {
2152
2152
  super(t), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
2153
2153
  const e = { start: "crosshair", close: "pointer" };
@@ -2176,10 +2176,10 @@ class ve extends N {
2176
2176
  const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
2177
2177
  i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
2178
2178
  } else if (this.currentCoordinate === 2) {
2179
- const o = e[0], s = e[1], n = pe(o, s, this.coordinatePrecision, this.project, this.unproject), a = S(o[0], o[1]), d = S(n[0], n[1]), l = S(s[0], s[1]), c = S(t.lng, t.lat), h = D(c, a) < D(c, l), u = $t(a, d, c), p = h ? 90 - u : $t(a, d, c) - 90, g = D(d, c), y = Math.cos(E(p)) * g, v = G(a, l) + (function(x, I, b) {
2180
- const O = (b.x - I.x) * (x.y - I.y) - (b.y - I.y) * (x.x - I.x);
2179
+ const o = e[0], s = e[1], n = ve(o, s, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(s[0], s[1]), c = x(t.lng, t.lat), h = D(c, a) < D(c, d), u = qt(a, l, c), p = h ? 90 - u : qt(a, l, c) - 90, g = D(l, c), y = Math.cos(F(p)) * g, v = T(a, d) + (function(S, I, b) {
2180
+ const O = (b.x - I.x) * (S.y - I.y) - (b.y - I.y) * (S.x - I.x);
2181
2181
  return O > 1e-10 ? "left" : O < -1e-10 ? "right" : "left";
2182
- }(a, l, c) === "right" ? -90 : 90), f = rt(a, y, v), m = rt(l, y, v), C = W(f.x, f.y), P = W(m.x, m.y);
2182
+ }(a, d, c) === "right" ? -90 : 90), f = rt(a, y, v), m = rt(d, y, v), C = W(f.x, f.y), P = W(m.x, m.y);
2183
2183
  i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
2184
2184
  }
2185
2185
  i && this.updatePolygonGeometry(this.currentId, i, w.Provisional);
@@ -2224,10 +2224,10 @@ class ve extends N {
2224
2224
  return this.validateModeFeature(t, (e) => nt(e, this.coordinatePrecision));
2225
2225
  }
2226
2226
  }
2227
- function Ce(r, t, e) {
2227
+ function Ie(r, t, e) {
2228
2228
  return (t.x - r.x) * (e.y - r.y) - (t.y - r.y) * (e.x - r.x) <= 0;
2229
2229
  }
2230
- class Pe extends N {
2230
+ class we extends N {
2231
2231
  constructor(t) {
2232
2232
  super(t), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
2233
2233
  const e = { start: "crosshair", close: "pointer" };
@@ -2257,18 +2257,18 @@ class Pe extends N {
2257
2257
  const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
2258
2258
  i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
2259
2259
  } else if (this.currentCoordinate === 2) {
2260
- const o = e[0], s = e[1], n = [t.lng, t.lat], a = S(o[0], o[1]), d = S(s[0], s[1]), l = S(n[0], n[1]);
2260
+ const o = e[0], s = e[1], n = [t.lng, t.lat], a = x(o[0], o[1]), l = x(s[0], s[1]), d = x(n[0], n[1]);
2261
2261
  if (this.direction === void 0) {
2262
- const C = Ce(a, d, l);
2262
+ const C = Ie(a, l, d);
2263
2263
  this.direction = C ? "clockwise" : "anticlockwise";
2264
2264
  }
2265
- const c = D(a, d), h = G(a, d), u = G(a, l), p = this.arcPoints, g = [o], y = K(h), v = K(u);
2265
+ const c = D(a, l), h = T(a, l), u = T(a, d), p = this.arcPoints, g = [o], y = K(h), v = K(u);
2266
2266
  let f;
2267
2267
  this.direction === "anticlockwise" ? (f = v - y, f < 0 && (f += 360)) : (f = y - v, f < 0 && (f += 360));
2268
2268
  const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
2269
2269
  g.push(s);
2270
2270
  for (let C = 0; C <= p; C++) {
2271
- const P = rt(a, c, y + C * m), { lng: x, lat: I } = W(P.x, P.y), b = [F(x, this.coordinatePrecision), F(I, this.coordinatePrecision)];
2271
+ const P = rt(a, c, y + C * m), { lng: S, lat: I } = W(P.x, P.y), b = [E(S, this.coordinatePrecision), E(I, this.coordinatePrecision)];
2272
2272
  b[0] !== g[g.length - 1][0] && b[1] !== g[g.length - 1][1] && g.push(b);
2273
2273
  }
2274
2274
  g.push(o), i = [...g];
@@ -2315,7 +2315,7 @@ class Pe extends N {
2315
2315
  return this.validateModeFeature(t, (e) => nt(e, this.coordinatePrecision));
2316
2316
  }
2317
2317
  }
2318
- class xe extends N {
2318
+ class be extends N {
2319
2319
  constructor(t) {
2320
2320
  super(t), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
2321
2321
  const e = { start: "crosshair", close: "pointer" };
@@ -2340,28 +2340,28 @@ class xe extends N {
2340
2340
  onMouseMove(t) {
2341
2341
  if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
2342
2342
  if (this.currentCoordinate === 2) {
2343
- const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n = S(o[0], o[1]), a = S(s[0], s[1]), d = S(i[0], i[1]), l = D(d, n);
2343
+ const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n = x(o[0], o[1]), a = x(s[0], s[1]), l = x(i[0], i[1]), d = D(l, n);
2344
2344
  if (this.direction === void 0) {
2345
- const m = Ce(d, n, a);
2345
+ const m = Ie(l, n, a);
2346
2346
  this.direction = m ? "clockwise" : "anticlockwise";
2347
2347
  }
2348
- const c = G(d, n), h = G(d, a), u = this.arcPoints, p = [o], g = K(c), y = K(h);
2348
+ const c = T(l, n), h = T(l, a), u = this.arcPoints, p = [o], g = K(c), y = K(h);
2349
2349
  let v;
2350
2350
  this.direction === "anticlockwise" ? (v = y - g, v < 0 && (v += 360)) : (v = g - y, v < 0 && (v += 360));
2351
2351
  const f = (this.direction === "anticlockwise" ? 1 : -1) * v / u;
2352
2352
  for (let m = 0; m <= u; m++) {
2353
- const C = rt(d, l, g + m * f), { lng: P, lat: x } = W(C.x, C.y), I = [F(P, this.coordinatePrecision), F(x, this.coordinatePrecision)];
2353
+ const C = rt(l, d, g + m * f), { lng: P, lat: S } = W(C.x, C.y), I = [E(P, this.coordinatePrecision), E(S, this.coordinatePrecision)];
2354
2354
  I[0] !== p[p.length - 1][0] && I[1] !== p[p.length - 1][1] && p.push(I);
2355
2355
  }
2356
2356
  this.updateLineStringGeometry(this.currentInitialArcId, p, w.Provisional);
2357
2357
  } else if (this.currentCoordinate === 3) {
2358
2358
  const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2359
2359
  if (e.length < 2 || !this.direction) return;
2360
- const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = S(t.lng, t.lat), a = S(o[0], o[1]), d = S(s[0], s[1]), l = S(i[0], i[1]), c = D(l, a), h = D(l, n) < c ? a : n, u = G(l, n), p = G(l, a), g = G(l, d), y = K(p), v = K(g), f = K(u);
2360
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(s[0], s[1]), d = x(i[0], i[1]), c = D(d, a), h = D(d, n) < c ? a : n, u = T(d, n), p = T(d, a), g = T(d, l), y = K(p), v = K(g), f = K(u);
2361
2361
  if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: v, direction: this.direction })) return;
2362
- const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, x = D(l, h), I = [];
2362
+ const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = D(d, h), I = [];
2363
2363
  for (let b = 0; b <= C; b++) {
2364
- const O = rt(l, x, y + b * P), { lng: A, lat: _ } = W(O.x, O.y), j = [F(A, this.coordinatePrecision), F(_, this.coordinatePrecision)];
2364
+ const O = rt(d, S, y + b * P), { lng: A, lat: _ } = W(O.x, O.y), j = [E(A, this.coordinatePrecision), E(_, this.coordinatePrecision)];
2365
2365
  j[0] !== e[e.length - 1][0] && j[1] !== e[e.length - 1][1] && I.unshift(j);
2366
2366
  }
2367
2367
  e.push(...I), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, w.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
@@ -2418,9 +2418,9 @@ class xe extends N {
2418
2418
  return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
2419
2419
  }
2420
2420
  }
2421
- class hi {
2421
+ class mi {
2422
2422
  constructor(t) {
2423
- this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new ti();
2423
+ this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new ni();
2424
2424
  const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
2425
2425
  if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
2426
2426
  return e.add(h.mode), c[h.mode] = h, c;
@@ -2431,7 +2431,7 @@ class hi {
2431
2431
  if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
2432
2432
  this._instanceSelectMode = c;
2433
2433
  }
2434
- }), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new ai({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2434
+ }), this._modes = M({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new pi({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2435
2435
  const s = (c) => {
2436
2436
  const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
2437
2437
  return { changed: h, unchanged: u };
@@ -2446,14 +2446,14 @@ class hi {
2446
2446
  });
2447
2447
  const { changed: u, unchanged: p } = s(c);
2448
2448
  h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: p, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
2449
- }, d = (c) => {
2449
+ }, l = (c) => {
2450
2450
  if (!this._enabled) return;
2451
2451
  this._eventListeners.select.forEach((p) => {
2452
2452
  p(c);
2453
2453
  });
2454
2454
  const { changed: h, unchanged: u } = s([c]);
2455
2455
  this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2456
- }, l = (c) => {
2456
+ }, d = (c) => {
2457
2457
  if (!this._enabled) return;
2458
2458
  this._eventListeners.deselect.forEach((p) => {
2459
2459
  p();
@@ -2462,7 +2462,7 @@ class hi {
2462
2462
  h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2463
2463
  };
2464
2464
  Object.keys(this._modes).forEach((c) => {
2465
- this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: d, onDeselect: l, onFinish: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
2465
+ this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
2466
2466
  });
2467
2467
  }
2468
2468
  checkEnabled() {
@@ -2475,22 +2475,22 @@ class hi {
2475
2475
  }), t;
2476
2476
  }
2477
2477
  featuresAtLocation({ lng: t, lat: e }, i) {
2478
- const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), d = a(t, e), l = ne({ unproject: n, point: d, pointerDistance: o });
2479
- return this._store.search(l).filter((c) => {
2478
+ const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = he({ unproject: n, point: l, pointerDistance: o });
2479
+ return this._store.search(d).filter((c) => {
2480
2480
  if (s && (c.properties[V.MID_POINT] || c.properties[V.SELECTION_POINT])) return !1;
2481
2481
  if (c.geometry.type === "Point") {
2482
2482
  const h = c.geometry.coordinates, u = a(h[0], h[1]);
2483
- return D(d, u) < o;
2483
+ return D(l, u) < o;
2484
2484
  }
2485
2485
  if (c.geometry.type === "LineString") {
2486
2486
  const h = c.geometry.coordinates;
2487
2487
  for (let u = 0; u < h.length - 1; u++) {
2488
2488
  const p = h[u], g = h[u + 1];
2489
- if (ye(d, a(p[0], p[1]), a(g[0], g[1])) < o) return !0;
2489
+ if (Pe(l, a(p[0], p[1]), a(g[0], g[1])) < o) return !0;
2490
2490
  }
2491
2491
  return !1;
2492
2492
  }
2493
- return !!ge([t, e], c.geometry.coordinates) || void 0;
2493
+ return !!Ce([t, e], c.geometry.coordinates) || void 0;
2494
2494
  });
2495
2495
  }
2496
2496
  getSelectMode() {
@@ -2591,14 +2591,14 @@ class hi {
2591
2591
  i.includes(e) && i.splice(i.indexOf(e), 1);
2592
2592
  }
2593
2593
  }
2594
- var Ht, wt, qt;
2595
- function Jt(r, t = 9) {
2594
+ var Jt, bt, Zt;
2595
+ function Qt(r, t = 9) {
2596
2596
  const e = Math.pow(10, t);
2597
2597
  return Math.round(r * e) / e;
2598
2598
  }
2599
- (wt = Ht || (Ht = {})).Commit = "commit", wt.Provisional = "provisional", wt.Finish = "finish", function(r) {
2599
+ (bt = Jt || (Jt = {})).Commit = "commit", bt.Provisional = "provisional", bt.Finish = "finish", function(r) {
2600
2600
  r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
2601
- }(qt || (qt = {}));
2601
+ }(Zt || (Zt = {}));
2602
2602
  class H {
2603
2603
  constructor({ name: t, callback: e, unregister: i, register: o }) {
2604
2604
  this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
@@ -2608,7 +2608,7 @@ class H {
2608
2608
  }, this.callback = e;
2609
2609
  }
2610
2610
  }
2611
- var ui = class {
2611
+ var vi = class {
2612
2612
  constructor(r) {
2613
2613
  this._minPixelDragDistance = void 0, this._minPixelDragDistanceDrawing = void 0, this._minPixelDragDistanceSelecting = void 0, this._lastDrawEvent = void 0, this._coordinatePrecision = void 0, this._heldKeys = /* @__PURE__ */ new Set(), this._listeners = [], this._dragState = "not-dragging", this._currentModeCallbacks = void 0, this._minPixelDragDistance = typeof r.minPixelDragDistance == "number" ? r.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof r.minPixelDragDistanceSelecting == "number" ? r.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof r.minPixelDragDistanceDrawing == "number" ? r.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof r.coordinatePrecision == "number" ? r.coordinatePrecision : 9;
2614
2614
  }
@@ -2623,7 +2623,7 @@ var ui = class {
2623
2623
  const t = this.getLngLatFromEvent(r);
2624
2624
  if (!t) return null;
2625
2625
  const { lng: e, lat: i } = t, { containerX: o, containerY: s } = this.getMapElementXYPosition(r), n = this.getButton(r), a = Array.from(this._heldKeys);
2626
- return { lng: Jt(e, this._coordinatePrecision), lat: Jt(i, this._coordinatePrecision), containerX: o, containerY: s, button: n, heldKeys: a };
2626
+ return { lng: Qt(e, this._coordinatePrecision), lat: Qt(i, this._coordinatePrecision), containerX: o, containerY: s, button: n, heldKeys: a };
2627
2627
  }
2628
2628
  register(r) {
2629
2629
  this._currentModeCallbacks = r, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
@@ -2649,8 +2649,8 @@ var ui = class {
2649
2649
  if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
2650
2650
  else if (this._dragState === "pre-dragging") {
2651
2651
  if (!this._lastDrawEvent) return;
2652
- const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), s = ((a, d) => {
2653
- const { x: l, y: c } = a, { x: h, y: u } = d, p = h - l, g = u - c;
2652
+ const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), s = ((a, l) => {
2653
+ const { x: d, y: c } = a, { x: h, y: u } = l, p = h - d, g = u - c;
2654
2654
  return Math.sqrt(g * g + p * p);
2655
2655
  })(e, i);
2656
2656
  let n = !1;
@@ -2701,7 +2701,7 @@ var ui = class {
2701
2701
  }), this.clear();
2702
2702
  }
2703
2703
  };
2704
- class pi extends ui {
2704
+ class Ci extends vi {
2705
2705
  constructor(t) {
2706
2706
  super(t), this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer();
2707
2707
  }
@@ -2771,13 +2771,13 @@ class pi extends ui {
2771
2771
  this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
2772
2772
  const i = [...t.created, ...t.updated, ...t.unchanged], o = [], s = [], n = [];
2773
2773
  for (let a = 0; a < i.length; a++) {
2774
- const d = i[a], { properties: l } = d, c = e[l.mode](d);
2775
- d.geometry.type === "Point" ? (l.pointColor = c.pointColor, l.pointOutlineColor = c.pointOutlineColor, l.pointOutlineWidth = c.pointOutlineWidth, l.pointWidth = c.pointWidth, o.push(d)) : d.geometry.type === "LineString" ? (l.lineStringColor = c.lineStringColor, l.lineStringWidth = c.lineStringWidth, s.push(d)) : d.geometry.type === "Polygon" && (l.polygonFillColor = c.polygonFillColor, l.polygonFillOpacity = c.polygonFillOpacity, l.polygonOutlineColor = c.polygonOutlineColor, l.polygonOutlineWidth = c.polygonOutlineWidth, n.push(d));
2774
+ const l = i[a], { properties: d } = l, c = e[d.mode](l);
2775
+ l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, o.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, n.push(l));
2776
2776
  }
2777
2777
  if (this._rendered) {
2778
- const a = this.changedIds.deletion || this.changedIds.styling, d = a || this.changedIds.linestrings, l = a || this.changedIds.polygons;
2778
+ const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
2779
2779
  let c;
2780
- (a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), d && this._setGeoJSONLayerData("LineString", s), l && this._setGeoJSONLayerData("Polygon", n), c && this._map.moveLayer(c);
2780
+ (a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", n), c && this._map.moveLayer(c);
2781
2781
  } else {
2782
2782
  const a = this._addGeoJSONLayer("Point", o);
2783
2783
  this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
@@ -2799,7 +2799,7 @@ class pi extends ui {
2799
2799
  super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
2800
2800
  }
2801
2801
  }
2802
- const Hi = [
2802
+ const eo = [
2803
2803
  "render",
2804
2804
  "point",
2805
2805
  "linestring",
@@ -2814,7 +2814,7 @@ const Hi = [
2814
2814
  "delete-selection",
2815
2815
  "delete",
2816
2816
  "download"
2817
- ], qi = [
2817
+ ], io = [
2818
2818
  "render",
2819
2819
  "linestring",
2820
2820
  "polygon",
@@ -2828,7 +2828,7 @@ const Hi = [
2828
2828
  "delete-selection",
2829
2829
  "delete",
2830
2830
  "download"
2831
- ], gi = {
2831
+ ], Pi = {
2832
2832
  modes: [
2833
2833
  "render",
2834
2834
  "point",
@@ -2846,7 +2846,7 @@ const Hi = [
2846
2846
  "download"
2847
2847
  ],
2848
2848
  open: !1
2849
- }, yi = {
2849
+ }, Dt = {
2850
2850
  modes: [
2851
2851
  "render",
2852
2852
  "linestring",
@@ -2865,7 +2865,7 @@ const Hi = [
2865
2865
  open: !1,
2866
2866
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
2867
2867
  modeOptions: {
2868
- linestring: new de({
2868
+ linestring: new ge({
2869
2869
  styles: {
2870
2870
  lineStringColor: "#232E3D",
2871
2871
  lineStringWidth: 2,
@@ -2875,7 +2875,7 @@ const Hi = [
2875
2875
  closingPointOutlineWidth: 1
2876
2876
  }
2877
2877
  }),
2878
- polygon: new he({
2878
+ polygon: new fe({
2879
2879
  styles: {
2880
2880
  fillColor: "#EDEFF0",
2881
2881
  fillOpacity: 0.7,
@@ -2887,7 +2887,7 @@ const Hi = [
2887
2887
  closingPointOutlineWidth: 1
2888
2888
  }
2889
2889
  }),
2890
- rectangle: new ue({
2890
+ rectangle: new me({
2891
2891
  styles: {
2892
2892
  fillColor: "#EDEFF0",
2893
2893
  fillOpacity: 0.7,
@@ -2895,7 +2895,7 @@ const Hi = [
2895
2895
  outlineWidth: 2
2896
2896
  }
2897
2897
  }),
2898
- "angled-rectangle": new ve({
2898
+ "angled-rectangle": new Me({
2899
2899
  styles: {
2900
2900
  fillColor: "#EDEFF0",
2901
2901
  fillOpacity: 0.7,
@@ -2903,7 +2903,7 @@ const Hi = [
2903
2903
  outlineWidth: 2
2904
2904
  }
2905
2905
  }),
2906
- circle: new se({
2906
+ circle: new de({
2907
2907
  styles: {
2908
2908
  fillColor: "#EDEFF0",
2909
2909
  fillOpacity: 0.7,
@@ -2911,7 +2911,7 @@ const Hi = [
2911
2911
  outlineWidth: 2
2912
2912
  }
2913
2913
  }),
2914
- freehand: new re({
2914
+ freehand: new ce({
2915
2915
  styles: {
2916
2916
  fillColor: "#EDEFF0",
2917
2917
  fillOpacity: 0.7,
@@ -2923,7 +2923,7 @@ const Hi = [
2923
2923
  closingPointOutlineWidth: 1
2924
2924
  }
2925
2925
  }),
2926
- sensor: new xe({
2926
+ sensor: new be({
2927
2927
  styles: {
2928
2928
  fillColor: "#EDEFF0",
2929
2929
  fillOpacity: 0.7,
@@ -2935,7 +2935,7 @@ const Hi = [
2935
2935
  centerPointOutlineWidth: 1
2936
2936
  }
2937
2937
  }),
2938
- sector: new Pe({
2938
+ sector: new we({
2939
2939
  styles: {
2940
2940
  fillColor: "#EDEFF0",
2941
2941
  fillOpacity: 0.7,
@@ -3056,28 +3056,28 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3056
3056
  distancePrecision: 2,
3057
3057
  areaUnit: "metric",
3058
3058
  areaPrecision: 2
3059
- }, fi = () => ({
3059
+ }, Si = () => ({
3060
3060
  render: new et({
3061
3061
  modeName: "render",
3062
3062
  styles: {}
3063
3063
  }),
3064
- point: new Ge(),
3065
- linestring: new de(),
3066
- polygon: new he({
3064
+ point: new Xe(),
3065
+ linestring: new ge(),
3066
+ polygon: new fe({
3067
3067
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3068
3068
  // @ts-ignore
3069
3069
  validation: (t, e) => {
3070
3070
  const i = e.updateType;
3071
- return i === "finish" || i === "commit" ? ci(t) : { valid: !0 };
3071
+ return i === "finish" || i === "commit" ? fi(t) : { valid: !0 };
3072
3072
  }
3073
3073
  }),
3074
- rectangle: new ue(),
3075
- "angled-rectangle": new ve(),
3076
- circle: new se(),
3077
- freehand: new re(),
3078
- sensor: new xe(),
3079
- sector: new Pe(),
3080
- select: new Qe({
3074
+ rectangle: new me(),
3075
+ "angled-rectangle": new Me(),
3076
+ circle: new de(),
3077
+ freehand: new ce(),
3078
+ sensor: new be(),
3079
+ sector: new we(),
3080
+ select: new ri({
3081
3081
  flags: {
3082
3082
  point: {
3083
3083
  feature: {
@@ -3190,32 +3190,39 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3190
3190
  modeName: "download",
3191
3191
  styles: {}
3192
3192
  })
3193
- });
3194
- class mi {
3193
+ }), te = (r) => r.charAt(0).toUpperCase() + r.slice(1), St = ["td-point", "td-linestring", "td-polygon"];
3194
+ var re, ne;
3195
+ const oo = [
3196
+ ...St,
3197
+ (re = Dt.polygonLayerSpec) == null ? void 0 : re.source,
3198
+ (ne = Dt.lineLayerLabelSpec) == null ? void 0 : ne.source
3199
+ ], Ee = (r, t, e = St) => {
3200
+ const i = JSON.parse(JSON.stringify(r));
3201
+ return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
3202
+ e.includes(o) || delete i.sources[o];
3203
+ })) : t.excludeTerraDrawLayers === !0 && (i.layers = i.layers.filter((o) => "source" in o && !e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
3204
+ e.includes(o) && delete i.sources[o];
3205
+ }))), i;
3206
+ }, xi = (r, t = 250) => {
3207
+ let e;
3208
+ return (...i) => {
3209
+ clearTimeout(e), e = setTimeout(() => r(...i), t);
3210
+ };
3211
+ };
3212
+ class Mi {
3195
3213
  /**
3196
3214
  * Constructor
3197
3215
  * @param options Plugin control options
3198
3216
  */
3199
3217
  constructor(t) {
3200
- L(this, "controlContainer");
3201
- L(this, "map");
3202
- L(this, "modeButtons", {});
3203
- L(this, "_isExpanded", !1);
3204
- L(this, "terradraw");
3205
- L(this, "options", gi);
3206
- L(this, "events", {});
3207
- L(this, "defaultMode", "render");
3208
- /**
3209
- * debounce
3210
- * @param callback callback function
3211
- * @param delay millisecond to delay
3212
- */
3213
- L(this, "debounce", (t, e = 250) => {
3214
- let i;
3215
- return (...o) => {
3216
- clearTimeout(i), i = setTimeout(() => t(...o), e);
3217
- };
3218
- });
3218
+ k(this, "controlContainer");
3219
+ k(this, "map");
3220
+ k(this, "modeButtons", {});
3221
+ k(this, "_isExpanded", !1);
3222
+ k(this, "terradraw");
3223
+ k(this, "options", Pi);
3224
+ k(this, "events", {});
3225
+ k(this, "defaultMode", "render");
3219
3226
  this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
3220
3227
  }
3221
3228
  /**
@@ -3253,16 +3260,16 @@ class mi {
3253
3260
  * @returns HTML Element
3254
3261
  */
3255
3262
  onAdd(t) {
3256
- var o, s, n, a, d;
3263
+ var o, s, n, a, l;
3257
3264
  if (this.options && this.options.modes && this.options.modes.length === 0)
3258
3265
  throw new Error("At least a mode must be enabled.");
3259
3266
  this.map = t;
3260
- const e = fi(), i = [];
3261
- return (s = (o = this.options) == null ? void 0 : o.modes) == null || s.forEach((l) => {
3262
- if (this.options.modeOptions && this.options.modeOptions[l]) {
3263
- const c = this.options.modeOptions[l];
3264
- if (l === "select") {
3265
- const h = e[l];
3267
+ const e = Si(), i = [];
3268
+ return (s = (o = this.options) == null ? void 0 : o.modes) == null || s.forEach((d) => {
3269
+ if (this.options.modeOptions && this.options.modeOptions[d]) {
3270
+ const c = this.options.modeOptions[d];
3271
+ if (d === "select") {
3272
+ const h = e[d];
3266
3273
  if (h) {
3267
3274
  const u = h.flags;
3268
3275
  Object.keys(u).forEach((p) => {
@@ -3271,23 +3278,23 @@ class mi {
3271
3278
  }
3272
3279
  }
3273
3280
  i.push(c);
3274
- } else e[l] && i.push(e[l]);
3275
- }), i.forEach((l) => {
3276
- l.state !== "unregistered" && (l._state = "unregistered");
3281
+ } else e[d] && i.push(e[d]);
3282
+ }), i.forEach((d) => {
3283
+ d.state !== "unregistered" && (d._state = "unregistered");
3277
3284
  }), (a = (n = this.options) == null ? void 0 : n.modes) != null && a.includes("render") || (i.push(
3278
3285
  new et({
3279
3286
  modeName: "default",
3280
3287
  styles: {}
3281
3288
  })
3282
- ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new hi({
3283
- adapter: new pi({ map: t, ...this.options.adapterOptions }),
3289
+ ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new mi({
3290
+ adapter: new Ci({ map: t, ...this.options.adapterOptions }),
3284
3291
  modes: i
3285
- }), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((l) => {
3286
- l.mode !== "default" && this.addTerradrawButton(l.mode);
3287
- }), Object.values(this.modeButtons).forEach((l) => {
3292
+ }), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
3293
+ d.mode !== "default" && this.addTerradrawButton(d.mode);
3294
+ }), Object.values(this.modeButtons).forEach((d) => {
3288
3295
  var c;
3289
- (c = this.controlContainer) == null || c.appendChild(l);
3290
- }), (d = this.terradraw) == null || d.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
3296
+ (c = this.controlContainer) == null || c.appendChild(d);
3297
+ }), (l = this.terradraw) == null || l.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
3291
3298
  }
3292
3299
  /**
3293
3300
  * Remove the plugin control from maplibre
@@ -3372,7 +3379,7 @@ class mi {
3372
3379
  */
3373
3380
  addTerradrawButton(t) {
3374
3381
  const e = document.createElement("button");
3375
- e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = this.capitalize("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = this.capitalize(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
3382
+ e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = te("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = te(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
3376
3383
  this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
3377
3384
  })) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
3378
3385
  var s;
@@ -3381,7 +3388,7 @@ class mi {
3381
3388
  if (o.length > 0) {
3382
3389
  const n = this.terradraw.getMode();
3383
3390
  this.terradraw.setMode(this.defaultMode);
3384
- const a = o.map((d) => d.id);
3391
+ const a = o.map((l) => l.id);
3385
3392
  this.terradraw.removeFeatures(a), this.terradraw.setMode(n), this.dispatchEvent("feature-deleted");
3386
3393
  }
3387
3394
  this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
@@ -3405,6 +3412,24 @@ class mi {
3405
3412
  };
3406
3413
  return t !== !0 || (o.features = o.features.filter((n) => n.properties.selected === !0)), o;
3407
3414
  }
3415
+ /**
3416
+ * clean maplibre style to filter only for terradraw related layers or without them.
3417
+ * If options are not set, returns original style given to the function.
3418
+ *
3419
+ * This can be useful incase users only want to get terradraw related layers or without it.
3420
+ *
3421
+ * Usage:
3422
+ * `cleanStyle(map.getStyle, { excludeTerraDrawLayers: true})`
3423
+ * `cleanStyle(map.getStyle, { onlyTerraDrawLayers: true})`
3424
+ *
3425
+ * @param style maplibre style spec
3426
+ * @param options.excludeTerraDrawLayers return maplibre style without terradraw layers and sources
3427
+ * @param options.onlyTerraDrawLayers return maplibre style with only terradraw layers and sources
3428
+ * @returns
3429
+ */
3430
+ cleanStyle(t, e) {
3431
+ return Ee(t, e, St);
3432
+ }
3408
3433
  /**
3409
3434
  * Download button click event handler
3410
3435
  */
@@ -3434,66 +3459,58 @@ class mi {
3434
3459
  * Toggle the state of delete-select button
3435
3460
  */
3436
3461
  toggleDeleteSelectionButton() {
3437
- var a, d;
3438
- const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (d = this.terradraw) == null ? void 0 : d.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, s = o && t && e === "select", n = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
3439
- for (let l = 0; l < n.length; l++) {
3440
- const c = n.item(l);
3462
+ var a, l;
3463
+ const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, s = o && t && e === "select", n = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
3464
+ for (let d = 0; d < n.length; d++) {
3465
+ const c = n.item(d);
3441
3466
  c && (s ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
3442
3467
  }
3443
3468
  if (!o) {
3444
- const l = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
3445
- for (let c = 0; c < l.length; c++) {
3446
- const h = l.item(c);
3469
+ const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
3470
+ for (let c = 0; c < d.length; c++) {
3471
+ const h = d.item(c);
3447
3472
  h && h.classList.remove("active");
3448
3473
  }
3449
3474
  }
3450
3475
  }
3451
- /**
3452
- * Capitalzie string value
3453
- * @param value string value
3454
- * @returns string
3455
- */
3456
- capitalize(t) {
3457
- return t.charAt(0).toUpperCase() + t.slice(1);
3458
- }
3459
3476
  }
3460
- var k = 63710088e-1, vi = {
3461
- centimeters: k * 100,
3462
- centimetres: k * 100,
3477
+ var L = 63710088e-1, Ii = {
3478
+ centimeters: L * 100,
3479
+ centimetres: L * 100,
3463
3480
  degrees: 360 / (2 * Math.PI),
3464
- feet: k * 3.28084,
3465
- inches: k * 39.37,
3466
- kilometers: k / 1e3,
3467
- kilometres: k / 1e3,
3468
- meters: k,
3469
- metres: k,
3470
- miles: k / 1609.344,
3471
- millimeters: k * 1e3,
3472
- millimetres: k * 1e3,
3473
- nauticalmiles: k / 1852,
3481
+ feet: L * 3.28084,
3482
+ inches: L * 39.37,
3483
+ kilometers: L / 1e3,
3484
+ kilometres: L / 1e3,
3485
+ meters: L,
3486
+ metres: L,
3487
+ miles: L / 1609.344,
3488
+ millimeters: L * 1e3,
3489
+ millimetres: L * 1e3,
3490
+ nauticalmiles: L / 1852,
3474
3491
  radians: 1,
3475
- yards: k * 1.0936
3492
+ yards: L * 1.0936
3476
3493
  };
3477
- function Ci(r, t, e = {}) {
3494
+ function wi(r, t, e = {}) {
3478
3495
  const i = { type: "Feature" };
3479
3496
  return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
3480
3497
  }
3481
- function Pi(r, t, e = {}) {
3498
+ function bi(r, t, e = {}) {
3482
3499
  if (!r)
3483
3500
  throw new Error("coordinates is required");
3484
3501
  if (!Array.isArray(r))
3485
3502
  throw new Error("coordinates must be an Array");
3486
3503
  if (r.length < 2)
3487
3504
  throw new Error("coordinates must be at least 2 numbers long");
3488
- if (!Zt(r[0]) || !Zt(r[1]))
3505
+ if (!ee(r[0]) || !ee(r[1]))
3489
3506
  throw new Error("coordinates must contain numbers");
3490
- return Ci({
3507
+ return wi({
3491
3508
  type: "Point",
3492
3509
  coordinates: r
3493
3510
  }, t, e);
3494
3511
  }
3495
- function xi(r, t = "kilometers") {
3496
- const e = vi[t];
3512
+ function Ei(r, t = "kilometers") {
3513
+ const e = Ii[t];
3497
3514
  if (!e)
3498
3515
  throw new Error(t + " units is invalid");
3499
3516
  return r * e;
@@ -3501,10 +3518,10 @@ function xi(r, t = "kilometers") {
3501
3518
  function ht(r) {
3502
3519
  return r % 360 * Math.PI / 180;
3503
3520
  }
3504
- function Zt(r) {
3521
+ function ee(r) {
3505
3522
  return !isNaN(r) && r !== null && !Array.isArray(r);
3506
3523
  }
3507
- function Qt(r) {
3524
+ function ie(r) {
3508
3525
  if (!r)
3509
3526
  throw new Error("coord is required");
3510
3527
  if (!Array.isArray(r)) {
@@ -3517,28 +3534,28 @@ function Qt(r) {
3517
3534
  return [...r];
3518
3535
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
3519
3536
  }
3520
- function Si(r, t, e = {}) {
3521
- var i = Qt(r), o = Qt(t), s = ht(o[1] - i[1]), n = ht(o[0] - i[0]), a = ht(i[1]), d = ht(o[1]), l = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(d);
3522
- return xi(
3523
- 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)),
3537
+ function Fi(r, t, e = {}) {
3538
+ var i = ie(r), o = ie(t), s = ht(o[1] - i[1]), n = ht(o[0] - i[0]), a = ht(i[1]), l = ht(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3539
+ return Ei(
3540
+ 2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3524
3541
  e.units
3525
3542
  );
3526
3543
  }
3527
- function Se(r, t, e) {
3544
+ function Fe(r, t, e) {
3528
3545
  if (r !== null)
3529
- for (var i, o, s, n, a, d, l, c = 0, h = 0, u, p = r.type, g = p === "FeatureCollection", y = p === "Feature", v = g ? r.features.length : 1, f = 0; f < v; f++) {
3530
- l = g ? r.features[f].geometry : y ? r.geometry : r, u = l ? l.type === "GeometryCollection" : !1, a = u ? l.geometries.length : 1;
3546
+ for (var i, o, s, n, a, l, d, c = 0, h = 0, u, p = r.type, g = p === "FeatureCollection", y = p === "Feature", v = g ? r.features.length : 1, f = 0; f < v; f++) {
3547
+ d = g ? r.features[f].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
3531
3548
  for (var m = 0; m < a; m++) {
3532
3549
  var C = 0, P = 0;
3533
- if (n = u ? l.geometries[m] : l, n !== null) {
3534
- d = n.coordinates;
3535
- var x = n.type;
3536
- switch (c = x === "Polygon" || x === "MultiPolygon" ? 1 : 0, x) {
3550
+ if (n = u ? d.geometries[m] : d, n !== null) {
3551
+ l = n.coordinates;
3552
+ var S = n.type;
3553
+ switch (c = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
3537
3554
  case null:
3538
3555
  break;
3539
3556
  case "Point":
3540
3557
  if (t(
3541
- d,
3558
+ l,
3542
3559
  h,
3543
3560
  f,
3544
3561
  C,
@@ -3549,25 +3566,25 @@ function Se(r, t, e) {
3549
3566
  break;
3550
3567
  case "LineString":
3551
3568
  case "MultiPoint":
3552
- for (i = 0; i < d.length; i++) {
3569
+ for (i = 0; i < l.length; i++) {
3553
3570
  if (t(
3554
- d[i],
3571
+ l[i],
3555
3572
  h,
3556
3573
  f,
3557
3574
  C,
3558
3575
  P
3559
3576
  ) === !1)
3560
3577
  return !1;
3561
- h++, x === "MultiPoint" && C++;
3578
+ h++, S === "MultiPoint" && C++;
3562
3579
  }
3563
- x === "LineString" && C++;
3580
+ S === "LineString" && C++;
3564
3581
  break;
3565
3582
  case "Polygon":
3566
3583
  case "MultiLineString":
3567
- for (i = 0; i < d.length; i++) {
3568
- for (o = 0; o < d[i].length - c; o++) {
3584
+ for (i = 0; i < l.length; i++) {
3585
+ for (o = 0; o < l[i].length - c; o++) {
3569
3586
  if (t(
3570
- d[i][o],
3587
+ l[i][o],
3571
3588
  h,
3572
3589
  f,
3573
3590
  C,
@@ -3576,16 +3593,16 @@ function Se(r, t, e) {
3576
3593
  return !1;
3577
3594
  h++;
3578
3595
  }
3579
- x === "MultiLineString" && C++, x === "Polygon" && P++;
3596
+ S === "MultiLineString" && C++, S === "Polygon" && P++;
3580
3597
  }
3581
- x === "Polygon" && C++;
3598
+ S === "Polygon" && C++;
3582
3599
  break;
3583
3600
  case "MultiPolygon":
3584
- for (i = 0; i < d.length; i++) {
3585
- for (P = 0, o = 0; o < d[i].length; o++) {
3586
- for (s = 0; s < d[i][o].length - c; s++) {
3601
+ for (i = 0; i < l.length; i++) {
3602
+ for (P = 0, o = 0; o < l[i].length; o++) {
3603
+ for (s = 0; s < l[i][o].length - c; s++) {
3587
3604
  if (t(
3588
- d[i][o][s],
3605
+ l[i][o][s],
3589
3606
  h,
3590
3607
  f,
3591
3608
  C,
@@ -3601,7 +3618,7 @@ function Se(r, t, e) {
3601
3618
  break;
3602
3619
  case "GeometryCollection":
3603
3620
  for (i = 0; i < n.geometries.length; i++)
3604
- if (Se(n.geometries[i], t) === !1)
3621
+ if (Fe(n.geometries[i], t) === !1)
3605
3622
  return !1;
3606
3623
  break;
3607
3624
  default:
@@ -3611,15 +3628,15 @@ function Se(r, t, e) {
3611
3628
  }
3612
3629
  }
3613
3630
  }
3614
- function Mi(r, t) {
3615
- var e, i, o, s, n, a, d, l, c, h, u = 0, p = r.type === "FeatureCollection", g = r.type === "Feature", y = p ? r.features.length : 1;
3631
+ function Di(r, t) {
3632
+ var e, i, o, s, n, a, l, d, c, h, u = 0, p = r.type === "FeatureCollection", g = r.type === "Feature", y = p ? r.features.length : 1;
3616
3633
  for (e = 0; e < y; e++) {
3617
- for (a = p ? r.features[e].geometry : g ? r.geometry : r, l = p ? r.features[e].properties : g ? r.properties : {}, c = p ? r.features[e].bbox : g ? r.bbox : void 0, h = p ? r.features[e].id : g ? r.id : void 0, d = a ? a.type === "GeometryCollection" : !1, n = d ? a.geometries.length : 1, o = 0; o < n; o++) {
3618
- if (s = d ? a.geometries[o] : a, s === null) {
3634
+ for (a = p ? r.features[e].geometry : g ? r.geometry : r, d = p ? r.features[e].properties : g ? r.properties : {}, c = p ? r.features[e].bbox : g ? r.bbox : void 0, h = p ? r.features[e].id : g ? r.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
3635
+ if (s = l ? a.geometries[o] : a, s === null) {
3619
3636
  if (t(
3620
3637
  null,
3621
3638
  u,
3622
- l,
3639
+ d,
3623
3640
  c,
3624
3641
  h
3625
3642
  ) === !1)
@@ -3636,7 +3653,7 @@ function Mi(r, t) {
3636
3653
  if (t(
3637
3654
  s,
3638
3655
  u,
3639
- l,
3656
+ d,
3640
3657
  c,
3641
3658
  h
3642
3659
  ) === !1)
@@ -3648,7 +3665,7 @@ function Mi(r, t) {
3648
3665
  if (t(
3649
3666
  s.geometries[i],
3650
3667
  u,
3651
- l,
3668
+ d,
3652
3669
  c,
3653
3670
  h
3654
3671
  ) === !1)
@@ -3662,37 +3679,37 @@ function Mi(r, t) {
3662
3679
  u++;
3663
3680
  }
3664
3681
  }
3665
- function Ii(r, t, e) {
3682
+ function Oi(r, t, e) {
3666
3683
  var i = e;
3667
- return Mi(
3684
+ return Di(
3668
3685
  r,
3669
- function(o, s, n, a, d) {
3686
+ function(o, s, n, a, l) {
3670
3687
  s === 0 && e === void 0 ? i = o : i = t(
3671
3688
  i,
3672
3689
  o,
3673
3690
  s,
3674
3691
  n,
3675
3692
  a,
3676
- d
3693
+ l
3677
3694
  );
3678
3695
  }
3679
3696
  ), i;
3680
3697
  }
3681
- function wi(r) {
3682
- return Ii(
3698
+ function _i(r) {
3699
+ return Oi(
3683
3700
  r,
3684
- (t, e) => t + bi(e),
3701
+ (t, e) => t + Li(e),
3685
3702
  0
3686
3703
  );
3687
3704
  }
3688
- function bi(r) {
3705
+ function Li(r) {
3689
3706
  let t = 0, e;
3690
3707
  switch (r.type) {
3691
3708
  case "Polygon":
3692
- return te(r.coordinates);
3709
+ return oe(r.coordinates);
3693
3710
  case "MultiPolygon":
3694
3711
  for (e = 0; e < r.coordinates.length; e++)
3695
- t += te(r.coordinates[e]);
3712
+ t += oe(r.coordinates[e]);
3696
3713
  return t;
3697
3714
  case "Point":
3698
3715
  case "MultiPoint":
@@ -3702,87 +3719,87 @@ function bi(r) {
3702
3719
  }
3703
3720
  return 0;
3704
3721
  }
3705
- function te(r) {
3722
+ function oe(r) {
3706
3723
  let t = 0;
3707
3724
  if (r && r.length > 0) {
3708
- t += Math.abs(ee(r[0]));
3725
+ t += Math.abs(se(r[0]));
3709
3726
  for (let e = 1; e < r.length; e++)
3710
- t -= Math.abs(ee(r[e]));
3727
+ t -= Math.abs(se(r[e]));
3711
3728
  }
3712
3729
  return t;
3713
3730
  }
3714
- var Fi = k * k / 2, bt = Math.PI / 180;
3715
- function ee(r) {
3731
+ var ki = L * L / 2, Et = Math.PI / 180;
3732
+ function se(r) {
3716
3733
  const t = r.length - 1;
3717
3734
  if (t <= 2) return 0;
3718
3735
  let e = 0, i = 0;
3719
3736
  for (; i < t; ) {
3720
- const o = r[i], s = r[i + 1 === t ? 0 : i + 1], n = r[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * bt, d = s[1] * bt, l = n[0] * bt;
3721
- e += (l - a) * Math.sin(d), i++;
3737
+ const o = r[i], s = r[i + 1 === t ? 0 : i + 1], n = r[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Et, l = s[1] * Et, d = n[0] * Et;
3738
+ e += (d - a) * Math.sin(l), i++;
3722
3739
  }
3723
- return e * Fi;
3740
+ return e * ki;
3724
3741
  }
3725
- function Ei(r, t = {}) {
3742
+ function Wi(r, t = {}) {
3726
3743
  let e = 0, i = 0, o = 0;
3727
- return Se(
3744
+ return Fe(
3728
3745
  r,
3729
3746
  function(s) {
3730
3747
  e += s[0], i += s[1], o++;
3731
3748
  }
3732
- ), Pi([e / o, i / o], t.properties);
3749
+ ), bi([e / o, i / o], t.properties);
3733
3750
  }
3734
- var Di = Object.defineProperty, Oi = (r, t, e) => t in r ? Di(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, tt = (r, t, e) => Oi(r, typeof t != "symbol" ? t + "" : t, e), ft = 2 * Math.PI * 6378137 / 2;
3735
- function _i(r) {
3751
+ var Bi = Object.defineProperty, ji = (r, t, e) => t in r ? Bi(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, tt = (r, t, e) => ji(r, typeof t != "symbol" ? t + "" : t, e), ft = 2 * Math.PI * 6378137 / 2;
3752
+ function Ni(r) {
3736
3753
  return r = r || 256, 2 * Math.PI * 6378137 / r;
3737
3754
  }
3738
- function Li(r, t, e = { enable: !0, decimal: 1 }) {
3739
- r = Ot(r);
3755
+ function Ai(r, t, e = { enable: !0, decimal: 1 }) {
3756
+ r = Lt(r);
3740
3757
  var i = r[0], o = r[1], s = i * ft / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
3741
3758
  return n = n * ft / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
3742
3759
  }
3743
- function ki(r, t, e) {
3744
- var i = r[0], o = r[1], s = Gi(t, e), n = (i + ft) / s, a = (o + ft) / s;
3760
+ function Ti(r, t, e) {
3761
+ var i = r[0], o = r[1], s = Xi(t, e), n = (i + ft) / s, a = (o + ft) / s;
3745
3762
  return [n, a, t];
3746
3763
  }
3747
- function Me(r, t, e) {
3748
- r = Ot(r);
3749
- var i = Li(r), o = ki(i, t);
3750
- return Bi(o);
3764
+ function De(r, t, e) {
3765
+ r = Lt(r);
3766
+ var i = Ai(r), o = Ti(i, t);
3767
+ return Vi(o);
3751
3768
  }
3752
- function Wi(r, t, e) {
3753
- if (r = Ot(r), t === 0)
3769
+ function Gi(r, t, e) {
3770
+ if (r = Lt(r), t === 0)
3754
3771
  return [0, 0, 0];
3755
- var i = Me(r, t);
3756
- return ji(i);
3772
+ var i = De(r, t);
3773
+ return Ui(i);
3757
3774
  }
3758
- function Bi(r, t, e) {
3775
+ function Vi(r, t, e) {
3759
3776
  t = t || 256;
3760
3777
  var i = r[0], o = r[1], s = r[2];
3761
3778
  if (s === 0) return [0, 0, 0];
3762
- Ie(s);
3779
+ Oe(s);
3763
3780
  var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
3764
3781
  return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, s];
3765
3782
  }
3766
- function ji(r, t) {
3767
- Ni(r);
3783
+ function Ui(r, t) {
3784
+ zi(r);
3768
3785
  var e = r[0], i = r[1], o = r[2];
3769
3786
  if (o === 0)
3770
3787
  return [0, 0, 0];
3771
3788
  var s = e, n = Math.pow(2, o) - 1 - i;
3772
3789
  return [s, n, o];
3773
3790
  }
3774
- function Ni(r, t) {
3791
+ function zi(r, t) {
3775
3792
  var e = r[0], i = r[1], o = r[2];
3776
3793
  if (o == null) throw new Error("<zoom> is required");
3777
3794
  if (e == null) throw new Error("<x> is required");
3778
3795
  if (i == null) throw new Error("<y> is required");
3779
- return o = Ie(o), r = Ai(r), r;
3796
+ return o = Oe(o), r = Ri(r), r;
3780
3797
  }
3781
- function Ai(r) {
3798
+ function Ri(r) {
3782
3799
  var t = r[0], e = r[1], i = r[2], o = Math.pow(2, i);
3783
3800
  return t = t % o, t < 0 && (t = t + o), [t, e, i];
3784
3801
  }
3785
- function Ie(r) {
3802
+ function Oe(r) {
3786
3803
  if (r === !1) return r;
3787
3804
  if (r == null)
3788
3805
  throw new Error("<zoom> is required");
@@ -3792,22 +3809,22 @@ function Ie(r) {
3792
3809
  throw new Error("<zoom> cannot be greater than 32");
3793
3810
  return r;
3794
3811
  }
3795
- function Ot(r, t) {
3796
- var e = Vi(r[0]), i = Ti(r[1]);
3812
+ function Lt(r, t) {
3813
+ var e = Yi(r[0]), i = Ki(r[1]);
3797
3814
  return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
3798
3815
  }
3799
- function Gi(r, t) {
3800
- return _i(t) / Math.pow(2, r);
3816
+ function Xi(r, t) {
3817
+ return Ni(t) / Math.pow(2, r);
3801
3818
  }
3802
- function Ti(r) {
3819
+ function Ki(r) {
3803
3820
  if (r == null) throw new Error("lat is required");
3804
3821
  return (r > 90 || r < -90) && (r = r % 180, r > 90 && (r = -180 + r), r < -90 && (r = 180 + r), r === 0 && (r = 0)), r;
3805
3822
  }
3806
- function Vi(r) {
3823
+ function Yi(r) {
3807
3824
  if (r == null) throw new Error("lng is required");
3808
3825
  return (r > 180 || r < -180) && (r = r % 360, r > 180 && (r = -360 + r), r < -180 && (r = 360 + r), r === 0 && (r = 0)), r;
3809
3826
  }
3810
- class we {
3827
+ class _e {
3811
3828
  /**
3812
3829
  * Constructor
3813
3830
  * @param url URL for terrain RGB raster tilesets
@@ -3832,12 +3849,12 @@ class we {
3832
3849
  const s = t[0], n = t[1];
3833
3850
  let a = e;
3834
3851
  e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
3835
- const d = this.tms ? Me([s, n], a) : Wi([s, n], a), l = this.url.replace(/{x}/g, d[0].toString()).replace(/{y}/g, d[1].toString()).replace(/{z}/g, d[2].toString());
3836
- let c = this.getUrlExtension(l);
3852
+ const l = this.tms ? De([s, n], a) : Gi([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
3853
+ let c = this.getUrlExtension(d);
3837
3854
  switch (c || (c = "png"), c) {
3838
3855
  case "png":
3839
3856
  case "webp":
3840
- this.getValueFromRaster(l, d, s, n).then((h) => {
3857
+ this.getValueFromRaster(d, l, s, n).then((h) => {
3841
3858
  i(h);
3842
3859
  });
3843
3860
  break;
@@ -3864,17 +3881,17 @@ class we {
3864
3881
  throw new Error(`Failed to fetch tile: ${s.statusText}`);
3865
3882
  }
3866
3883
  const n = await s.blob();
3867
- return new Promise((a, d) => {
3868
- const l = new Image();
3869
- l.onload = () => {
3884
+ return new Promise((a, l) => {
3885
+ const d = new Image();
3886
+ d.onload = () => {
3870
3887
  const c = document.createElement("canvas");
3871
- c.width = l.width, c.height = l.height;
3888
+ c.width = d.width, c.height = d.height;
3872
3889
  const h = c.getContext("2d");
3873
- if (!h) return d(new Error("Failed to create canvas context"));
3874
- h.drawImage(l, 0, 0);
3875
- const u = h.getImageData(0, 0, l.width, l.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), g = this.calc(p[0], p[1], p[2], p[3]);
3890
+ if (!h) return l(new Error("Failed to create canvas context"));
3891
+ h.drawImage(d, 0, 0);
3892
+ const u = h.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), g = this.calc(p[0], p[1], p[2], p[3]);
3876
3893
  a(g);
3877
- }, l.onerror = () => a(void 0), l.src = URL.createObjectURL(n);
3894
+ }, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
3878
3895
  });
3879
3896
  }
3880
3897
  /**
@@ -3887,12 +3904,12 @@ class we {
3887
3904
  */
3888
3905
  pixels2rgba(t, e, i, o) {
3889
3906
  const s = [];
3890
- for (let l = 0; l < t.length; l += 4) {
3891
- const c = t[l], h = t[l + 1], u = t[l + 2], p = t[l + 3], g = [c, h, u, p];
3907
+ for (let d = 0; d < t.length; d += 4) {
3908
+ const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], g = [c, h, u, p];
3892
3909
  s.push(g);
3893
3910
  }
3894
- const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), d = a[0] + a[1] * this.tileSize;
3895
- return s[d];
3911
+ const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
3912
+ return s[l];
3896
3913
  }
3897
3914
  /**
3898
3915
  * Get the position in pixel from the coordinates
@@ -3902,7 +3919,7 @@ class we {
3902
3919
  * @returns The position in pixel
3903
3920
  */
3904
3921
  getPixelPosition(t, e, i) {
3905
- const o = this.tileSize, s = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], d = (t - i[0]) / n, l = (e - i[1]) / a, c = Math.floor(o * d), h = Math.floor(s * (1 - l));
3922
+ const o = this.tileSize, s = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a, c = Math.floor(o * l), h = Math.floor(s * (1 - d));
3906
3923
  return [c, h];
3907
3924
  }
3908
3925
  /**
@@ -3934,7 +3951,7 @@ class we {
3934
3951
  return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
3935
3952
  }
3936
3953
  }
3937
- class Ui extends we {
3954
+ class $i extends _e {
3938
3955
  /**
3939
3956
  * Constructor
3940
3957
  * @param url URL for terrain RGB raster tilesets
@@ -3966,7 +3983,7 @@ class Ui extends we {
3966
3983
  return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
3967
3984
  }
3968
3985
  }
3969
- class zi extends we {
3986
+ class Hi extends _e {
3970
3987
  /**
3971
3988
  * Constructor
3972
3989
  * @param url URL for terrarium raster tilesets
@@ -4000,26 +4017,26 @@ class zi extends we {
4000
4017
  return parseInt(o.toFixed(0));
4001
4018
  }
4002
4019
  }
4003
- class Ji extends mi {
4020
+ class so extends Mi {
4004
4021
  /**
4005
4022
  * Constructor
4006
4023
  * @param options Plugin control options
4007
4024
  */
4008
4025
  constructor(e) {
4009
- let i = yi;
4026
+ let i = Dt;
4010
4027
  e && (i = Object.assign(i, e));
4011
4028
  super({
4012
4029
  modes: i.modes,
4013
4030
  open: i.open,
4014
4031
  modeOptions: i.modeOptions
4015
4032
  });
4016
- L(this, "measureOptions");
4033
+ k(this, "measureOptions");
4017
4034
  /**
4018
4035
  * Handle deselect event of terradraw
4019
4036
  * @param id Feature ID
4020
4037
  */
4021
- L(this, "handleTerradrawDeselect", () => {
4022
- if (this.map && this.measureOptions.computeElevation === !0 && this.measureOptions.terrainSource !== void 0) {
4038
+ k(this, "handleTerradrawDeselect", () => {
4039
+ if (this.map && this.computeElevation === !0 && this.measureOptions.terrainSource !== void 0) {
4023
4040
  const e = this.getTerraDrawInstance();
4024
4041
  if (!e) return;
4025
4042
  const o = e.getSnapshot().filter(
@@ -4034,16 +4051,16 @@ class Ji extends mi {
4034
4051
  * Handle finish event of terradraw. It will be called after finishing adding a feature
4035
4052
  * @param id Feature ID
4036
4053
  */
4037
- L(this, "handleTerradrawFeatureReady", this.debounce((e) => {
4054
+ k(this, "handleTerradrawFeatureReady", xi((e) => {
4038
4055
  this.map && this.computeElevationByFeatureID(e);
4039
4056
  }, 300));
4040
4057
  /**
4041
4058
  * Compute elevation by a LineString feature ID
4042
4059
  * @param id FeatureID
4043
4060
  */
4044
- L(this, "computeElevationByFeatureID", async (e) => {
4061
+ k(this, "computeElevationByFeatureID", async (e) => {
4045
4062
  var i;
4046
- if (this.map && this.measureOptions.computeElevation === !0) {
4063
+ if (this.map && this.computeElevation === !0) {
4047
4064
  const o = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
4048
4065
  if (o && typeof o.data != "string" && o.data.type === "FeatureCollection") {
4049
4066
  const s = o.data.features.filter(
@@ -4057,23 +4074,23 @@ class Ji extends mi {
4057
4074
  s
4058
4075
  ), a = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
4059
4076
  if (a && typeof a.data != "string" && a.data.type === "FeatureCollection") {
4060
- const d = n.map((l) => l.id);
4077
+ const l = n.map((d) => d.id);
4061
4078
  if (typeof a.data != "string" && a.data.type === "FeatureCollection") {
4062
4079
  a.data.features = [
4063
4080
  ...a.data.features = a.data.features.filter(
4064
4081
  (c) => {
4065
4082
  var h;
4066
- return !(d.includes((h = c.properties) == null ? void 0 : h.originalId) && c.geometry.type === "Point");
4083
+ return !(l.includes((h = c.properties) == null ? void 0 : h.originalId) && c.geometry.type === "Point");
4067
4084
  }
4068
4085
  ),
4069
4086
  ...n
4070
4087
  ];
4071
- const l = {};
4088
+ const d = {};
4072
4089
  a.data.features.forEach((c) => {
4073
4090
  var u;
4074
4091
  const h = c.id;
4075
- l[h] ? !l[h].properties.elevation && ((u = c.properties) != null && u.elevation) && (l[h] = c) : l[h] = c;
4076
- }), a.data.features = Array.from(Object.values(l)), (i = this.map.getSource(
4092
+ d[h] ? !d[h].properties.elevation && ((u = c.properties) != null && u.elevation) && (d[h] = c) : d[h] = c;
4093
+ }), a.data.features = Array.from(Object.values(d)), (i = this.map.getSource(
4077
4094
  this.measureOptions.lineLayerLabelSpec.source
4078
4095
  )) == null || i.setData(a.data);
4079
4096
  }
@@ -4087,7 +4104,7 @@ class Ji extends mi {
4087
4104
  * @param feature GeoJSON feature
4088
4105
  * @returns updated GeoJSON feature
4089
4106
  */
4090
- L(this, "updateFeatureProperties", (e) => {
4107
+ k(this, "updateFeatureProperties", (e) => {
4091
4108
  if (!this.map || !this.map.loaded()) return e;
4092
4109
  const i = e.geometry.type;
4093
4110
  return i === "LineString" ? e = this.calcDistance(e) : i === "Polygon" && (e = this.calcArea(e)), e;
@@ -4136,6 +4153,17 @@ class Ji extends mi {
4136
4153
  const i = this.measureOptions.areaPrecision === e;
4137
4154
  this.measureOptions.areaPrecision = e, i || this.recalc();
4138
4155
  }
4156
+ /**
4157
+ * The flag of whether computing elevation. Default is false.
4158
+ * Using setter to override the value if you want.
4159
+ */
4160
+ get computeElevation() {
4161
+ return this.measureOptions.computeElevation ?? !1;
4162
+ }
4163
+ set computeElevation(e) {
4164
+ const i = this.measureOptions.computeElevation === e;
4165
+ this.measureOptions.computeElevation = e, i || this.recalc();
4166
+ }
4139
4167
  /**
4140
4168
  * add the plugin control to maplibre
4141
4169
  * @param map Maplibre Map object
@@ -4181,6 +4209,28 @@ class Ji extends mi {
4181
4209
  }
4182
4210
  }
4183
4211
  }
4212
+ /**
4213
+ * clean maplibre style to filter only for terradraw related layers or without them.
4214
+ * If options are not set, returns original style given to the function.
4215
+ *
4216
+ * This can be useful incase users only want to get terradraw related layers or without it.
4217
+ *
4218
+ * Usage:
4219
+ * `cleanStyle(map.getStyle, { excludeTerraDrawLayers: true})`
4220
+ * `cleanStyle(map.getStyle, { onlyTerraDrawLayers: true})`
4221
+ *
4222
+ * @param style maplibre style spec
4223
+ * @param options.excludeTerraDrawLayers return maplibre style without terradraw layers and sources
4224
+ * @param options.onlyTerraDrawLayers return maplibre style with only terradraw layers and sources
4225
+ * @returns
4226
+ */
4227
+ cleanStyle(e, i) {
4228
+ var a, l;
4229
+ const o = St, s = (a = this.measureOptions.polygonLayerSpec) == null ? void 0 : a.source;
4230
+ s && o.push(s);
4231
+ const n = (l = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : l.source;
4232
+ return n && o.push(n), Ee(e, i, o);
4233
+ }
4184
4234
  /**
4185
4235
  * Register measure control related maplibre sources and layers
4186
4236
  */
@@ -4233,8 +4283,8 @@ class Ji extends mi {
4233
4283
  for (const s of e) {
4234
4284
  const n = o.find((a) => a.id === s);
4235
4285
  if (n) {
4236
- const a = n.geometry.type, d = n.properties.mode;
4237
- d === "linestring" && a === "LineString" ? this.measureLine(s) : !["point", "linestring", "select", "render"].includes(d) && a === "Polygon" && this.measurePolygon(s);
4286
+ const a = n.geometry.type, l = n.properties.mode;
4287
+ l === "linestring" && a === "LineString" ? this.measureLine(s) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(s);
4238
4288
  } else
4239
4289
  this.clearMeasureFeatures(
4240
4290
  s,
@@ -4284,7 +4334,7 @@ class Ji extends mi {
4284
4334
  */
4285
4335
  calcArea(e) {
4286
4336
  if (e.geometry.type !== "Polygon") return e;
4287
- const i = wi(e.geometry);
4337
+ const i = _i(e.geometry);
4288
4338
  let o = i, s = "m²";
4289
4339
  return this.areaUnit === "metric" ? i >= 1e6 ? (o = i / 1e6, s = "km²") : i >= 1e4 && (o = i / 1e4, s = "ha") : i >= 258998811e-2 ? (o = i / 258998811e-2, s = "mi²") : i >= 4046.856 ? (o = i / 4046.856, s = "acre") : i >= 0.83612736 && (o = i / 0.83612736, s = "yd²"), o = parseFloat(o.toFixed(this.areaPrecision)), e.properties.area = o, e.properties.unit = s, e;
4290
4340
  }
@@ -4310,8 +4360,8 @@ class Ji extends mi {
4310
4360
  o.geometry.type !== "Point" && s(o);
4311
4361
  const n = this.measureOptions.terrainSource;
4312
4362
  if (n) {
4313
- const a = n.url, d = n.encoding ?? "mapbox", l = n.tileSize ?? 512, c = n.minzoom ?? 5, h = n.maxzoom ?? 15, u = n.tms ?? !1;
4314
- (d === "mapbox" ? new Ui(a, l, c, h, u) : new zi(a, l, c, h, u)).getElevation(o.geometry.coordinates, h).then((p) => {
4363
+ const a = n.url, l = n.encoding ?? "mapbox", d = n.tileSize ?? 512, c = n.minzoom ?? 5, h = n.maxzoom ?? 15, u = n.tms ?? !1;
4364
+ (l === "mapbox" ? new $i(a, d, c, h, u) : new Hi(a, d, c, h, u)).getElevation(o.geometry.coordinates, h).then((p) => {
4315
4365
  p && (o.properties.elevation = p), s(o);
4316
4366
  }).catch(() => s(o));
4317
4367
  } else
@@ -4331,12 +4381,12 @@ class Ji extends mi {
4331
4381
  const i = e.geometry.coordinates;
4332
4382
  let o = 0;
4333
4383
  const s = [];
4334
- for (let d = 0; d < i.length - 1; d++) {
4335
- const l = i[d], c = i[d + 1], h = Si(l, c, { units: this.distanceUnit });
4384
+ for (let l = 0; l < i.length - 1; l++) {
4385
+ const d = i[l], c = i[l + 1], h = Fi(d, c, { units: this.distanceUnit });
4336
4386
  o += h;
4337
4387
  const u = JSON.parse(JSON.stringify(e));
4338
- if (u.id = `${u.id}-${d}`, u.geometry.coordinates = [l, c], u.properties.originalId = e.id, u.properties.distance = parseFloat(h.toFixed(this.distancePrecision)), u.properties.total = parseFloat(o.toFixed(this.distancePrecision)), u.properties.unit = this.getDistanceUnitName(this.distanceUnit), this.measureOptions.computeElevation === !0 && this.measureOptions.terrainSource === void 0) {
4339
- const p = (n = this.map) == null ? void 0 : n.queryTerrainElevation(l);
4388
+ if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, c], u.properties.originalId = e.id, u.properties.distance = parseFloat(h.toFixed(this.distancePrecision)), u.properties.total = parseFloat(o.toFixed(this.distancePrecision)), u.properties.unit = this.getDistanceUnitName(this.distanceUnit), this.computeElevation === !0 && this.measureOptions.terrainSource === void 0) {
4389
+ const p = (n = this.map) == null ? void 0 : n.queryTerrainElevation(d);
4340
4390
  p && (u.properties.elevation_start = p);
4341
4391
  const g = (a = this.map) == null ? void 0 : a.queryTerrainElevation(c);
4342
4392
  g && (u.properties.elevation_end = g);
@@ -4360,13 +4410,13 @@ class Ji extends mi {
4360
4410
  const a = this.map.getStyle().sources[this.measureOptions.polygonLayerSpec.source];
4361
4411
  if (a) {
4362
4412
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
4363
- (l) => {
4413
+ (d) => {
4364
4414
  var c;
4365
- return ((c = l.properties) == null ? void 0 : c.originalId) !== e;
4415
+ return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
4366
4416
  }
4367
4417
  ));
4368
- const d = JSON.parse(JSON.stringify(s));
4369
- d.id = d.id + "-area-label", d.geometry = Ei(s.geometry).geometry, d.properties.originalId = s.id, s = this.calcArea(s), d.properties.area = s.properties.area, d.properties.unit = s.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(d), (n = this.map.getSource(
4418
+ const l = JSON.parse(JSON.stringify(s));
4419
+ l.id = l.id + "-area-label", l.geometry = Wi(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), (n = this.map.getSource(
4370
4420
  this.measureOptions.polygonLayerSpec.source
4371
4421
  )) == null || n.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
4372
4422
  this.measureOptions.lineLayerLabelSpec.id
@@ -4391,25 +4441,25 @@ class Ji extends mi {
4391
4441
  const a = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
4392
4442
  if (a) {
4393
4443
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
4394
- (l) => {
4444
+ (d) => {
4395
4445
  var c;
4396
- return ((c = l.properties) == null ? void 0 : c.originalId) !== e;
4446
+ return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
4397
4447
  }
4398
4448
  )), s = this.calcDistance(s);
4399
- const d = s.properties.segments;
4400
- for (let l = 0; l < d.length; l++) {
4401
- const c = d[l];
4449
+ const l = s.properties.segments;
4450
+ for (let d = 0; d < l.length; d++) {
4451
+ const c = l[d];
4402
4452
  typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
4403
4453
  const h = c.geometry.coordinates, u = h[0], p = h[1];
4404
- if (l === 0) {
4454
+ if (d === 0) {
4405
4455
  const y = JSON.parse(JSON.stringify(c));
4406
- y.id = `${c.id}-node-${l}`, y.geometry = {
4456
+ y.id = `${c.id}-node-${d}`, y.geometry = {
4407
4457
  type: "Point",
4408
4458
  coordinates: u
4409
4459
  }, y.properties.distance = 0, y.properties.total = 0, c.properties.elevation_start && (y.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
4410
4460
  }
4411
4461
  const g = JSON.parse(JSON.stringify(c));
4412
- g.id = `${c.id}-node-${l + 1}`, g.geometry = {
4462
+ g.id = `${c.id}-node-${d + 1}`, g.geometry = {
4413
4463
  type: "Point",
4414
4464
  coordinates: p
4415
4465
  }, c.properties.elevation_end && (g.properties.elevation = c.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
@@ -4435,7 +4485,7 @@ class Ji extends mi {
4435
4485
  for (const n of s) {
4436
4486
  const a = this.map.getStyle().sources[n];
4437
4487
  if (a) {
4438
- const d = e.getSnapshot(), c = (d == null ? void 0 : d.filter(
4488
+ const l = e.getSnapshot(), c = (l == null ? void 0 : l.filter(
4439
4489
  (h) => ["LineString", "Polygon"].includes(h.geometry.type)
4440
4490
  )).map((h) => h.id);
4441
4491
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
@@ -4478,12 +4528,17 @@ class Ji extends mi {
4478
4528
  }
4479
4529
  }
4480
4530
  export {
4481
- qi as AvailableMeasureModes,
4482
- Hi as AvailableModes,
4483
- Ji as MaplibreMeasureControl,
4484
- mi as MaplibreTerradrawControl,
4485
- gi as defaultControlOptions,
4486
- yi as defaultMeasureControlOptions,
4487
- fi as getDefaultModeOptions
4531
+ io as AvailableMeasureModes,
4532
+ eo as AvailableModes,
4533
+ so as MaplibreMeasureControl,
4534
+ Mi as MaplibreTerradrawControl,
4535
+ oo as TERRADRAW_MEASURE_SOURCE_IDS,
4536
+ St as TERRADRAW_SOURCE_IDS,
4537
+ te as capitalize,
4538
+ Ee as cleanMaplibreStyle,
4539
+ xi as debounce,
4540
+ Pi as defaultControlOptions,
4541
+ Dt as defaultMeasureControlOptions,
4542
+ Si as getDefaultModeOptions
4488
4543
  };
4489
4544
  //# sourceMappingURL=maplibre-gl-terradraw.es.js.map