@maptiler/geocoding-control 2.1.0-with-autocomplete-timeout → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/MapLibreBasedGeocodingControl.d.ts +35 -69
  2. package/leaflet-controller.js +1942 -1523
  3. package/leaflet-controller.js.map +1 -1
  4. package/leaflet-controller.umd.js +1 -22
  5. package/leaflet-controller.umd.js.map +1 -1
  6. package/leaflet.js +2798 -2385
  7. package/leaflet.js.map +1 -1
  8. package/leaflet.umd.js +1 -22
  9. package/leaflet.umd.js.map +1 -1
  10. package/maplibregl-controller.js +1918 -1498
  11. package/maplibregl-controller.js.map +1 -1
  12. package/maplibregl-controller.umd.js +1 -22
  13. package/maplibregl-controller.umd.js.map +1 -1
  14. package/maplibregl.d.ts +34 -68
  15. package/maplibregl.js +2892 -2478
  16. package/maplibregl.js.map +1 -1
  17. package/maplibregl.umd.js +1 -22
  18. package/maplibregl.umd.js.map +1 -1
  19. package/maptilersdk.d.ts +34 -68
  20. package/maptilersdk.js +2896 -2481
  21. package/maptilersdk.js.map +1 -1
  22. package/maptilersdk.umd.js +1 -22
  23. package/maptilersdk.umd.js.map +1 -1
  24. package/openlayers-controller.js +1686 -1264
  25. package/openlayers-controller.js.map +1 -1
  26. package/openlayers-controller.umd.js +1 -22
  27. package/openlayers-controller.umd.js.map +1 -1
  28. package/openlayers.js +2778 -2365
  29. package/openlayers.js.map +1 -1
  30. package/openlayers.umd.js +1 -22
  31. package/openlayers.umd.js.map +1 -1
  32. package/package.json +23 -23
  33. package/react.js +753 -756
  34. package/react.js.map +1 -1
  35. package/react.umd.js +1 -1
  36. package/react.umd.js.map +1 -1
  37. package/svelte/GeocodingControl.svelte +71 -58
  38. package/svelte/GeocodingControl.svelte.d.ts +5 -3
  39. package/svelte/MapLibreBasedGeocodingControl.d.ts +35 -69
  40. package/svelte/info.json +1 -0
  41. package/svelte/maplibregl.d.ts +34 -68
  42. package/svelte/maptilersdk.d.ts +34 -68
  43. package/svelte/maptilersdk.js +2 -0
  44. package/svelte/react.js +3 -0
  45. package/svelte/types.d.ts +175 -128
  46. package/types.d.ts +175 -128
  47. package/vanilla.js +847 -853
  48. package/vanilla.js.map +1 -1
  49. package/vanilla.umd.js +1 -1
  50. package/vanilla.umd.js.map +1 -1
@@ -1,122 +1,125 @@
1
- import { Feature as N } from "ol";
2
- import { Point as Z, Polygon as ut, MultiPolygon as ft, GeometryCollection as $t, LineString as ct, MultiLineString as ht } from "ol/geom";
3
- import Tt from "ol/layer/Vector";
4
- import { fromLonLat as V, transformExtent as qt, toLonLat as at, getUserProjection as Qt } from "ol/proj";
5
- import Ut from "ol/source/Vector";
6
- import gt from "ol/style/Fill";
7
- import Yt from "ol/style/Icon";
8
- import pt from "ol/style/Stroke";
9
- import Vt from "ol/style/Style";
10
- import jt from "ol/style/Text";
11
- function D(o, t, e = {}) {
1
+ var ct = Object.defineProperty;
2
+ var at = (i, t, e) => t in i ? ct(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var M = (i, t, e) => at(i, typeof t != "symbol" ? t + "" : t, e);
4
+ import { Feature as se } from "ol";
5
+ import { Point as Re, Polygon as Fe, MultiPolygon as qe, GeometryCollection as pt, LineString as De, MultiLineString as ze } from "ol/geom";
6
+ import gt from "ol/layer/Vector";
7
+ import { fromLonLat as me, transformExtent as yt, toLonLat as Ue, getUserProjection as mt } from "ol/proj";
8
+ import dt from "ol/source/Vector";
9
+ import Ve from "ol/style/Fill";
10
+ import xt from "ol/style/Icon";
11
+ import $e from "ol/style/Stroke";
12
+ import wt from "ol/style/Style";
13
+ import Et from "ol/style/Text";
14
+ function Se(i, t, e = {}) {
12
15
  const n = { type: "Feature" };
13
- return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = o, n;
16
+ return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = i, n;
14
17
  }
15
- function ot(o, t, e = {}) {
16
- for (const r of o) {
18
+ function Be(i, t, e = {}) {
19
+ for (const r of i) {
17
20
  if (r.length < 4)
18
21
  throw new Error(
19
22
  "Each LinearRing of a Polygon must have 4 or more Positions."
20
23
  );
21
24
  if (r[r.length - 1].length !== r[0].length)
22
25
  throw new Error("First and last Position are not equivalent.");
23
- for (let i = 0; i < r[r.length - 1].length; i++)
24
- if (r[r.length - 1][i] !== r[0][i])
26
+ for (let f = 0; f < r[r.length - 1].length; f++)
27
+ if (r[r.length - 1][f] !== r[0][f])
25
28
  throw new Error("First and last Position are not equivalent.");
26
29
  }
27
- return D({
30
+ return Se({
28
31
  type: "Polygon",
29
- coordinates: o
32
+ coordinates: i
30
33
  }, t, e);
31
34
  }
32
- function H(o, t = {}) {
35
+ function Ce(i, t = {}) {
33
36
  const e = { type: "FeatureCollection" };
34
- return t.id && (e.id = t.id), t.bbox && (e.bbox = t.bbox), e.features = o, e;
37
+ return t.id && (e.id = t.id), t.bbox && (e.bbox = t.bbox), e.features = i, e;
35
38
  }
36
- function At(o, t, e = {}) {
37
- return D({
39
+ function rt(i, t, e = {}) {
40
+ return Se({
38
41
  type: "MultiPolygon",
39
- coordinates: o
42
+ coordinates: i
40
43
  }, t, e);
41
44
  }
42
- function Ot(o, t, e) {
43
- if (o !== null)
44
- for (var n, r, i, u, l, c, f, a = 0, s = 0, h, g = o.type, y = g === "FeatureCollection", p = g === "Feature", d = y ? o.features.length : 1, x = 0; x < d; x++) {
45
- f = y ? o.features[x].geometry : p ? o.geometry : o, h = f ? f.type === "GeometryCollection" : !1, l = h ? f.geometries.length : 1;
46
- for (var v = 0; v < l; v++) {
47
- var w = 0, m = 0;
48
- if (u = h ? f.geometries[v] : f, u !== null) {
49
- c = u.coordinates;
50
- var E = u.type;
51
- switch (a = 0, E) {
45
+ function st(i, t, e) {
46
+ if (i !== null)
47
+ for (var n, r, f, a, c, E, d, T = 0, b = 0, P, N = i.type, _ = N === "FeatureCollection", L = N === "Feature", A = _ ? i.features.length : 1, V = 0; V < A; V++) {
48
+ d = _ ? i.features[V].geometry : L ? i.geometry : i, P = d ? d.type === "GeometryCollection" : !1, c = P ? d.geometries.length : 1;
49
+ for (var S = 0; S < c; S++) {
50
+ var F = 0, B = 0;
51
+ if (a = P ? d.geometries[S] : d, a !== null) {
52
+ E = a.coordinates;
53
+ var Y = a.type;
54
+ switch (T = 0, Y) {
52
55
  case null:
53
56
  break;
54
57
  case "Point":
55
58
  if (t(
56
- c,
57
- s,
58
- x,
59
- w,
60
- m
59
+ E,
60
+ b,
61
+ V,
62
+ F,
63
+ B
61
64
  ) === !1)
62
65
  return !1;
63
- s++, w++;
66
+ b++, F++;
64
67
  break;
65
68
  case "LineString":
66
69
  case "MultiPoint":
67
- for (n = 0; n < c.length; n++) {
70
+ for (n = 0; n < E.length; n++) {
68
71
  if (t(
69
- c[n],
70
- s,
71
- x,
72
- w,
73
- m
72
+ E[n],
73
+ b,
74
+ V,
75
+ F,
76
+ B
74
77
  ) === !1)
75
78
  return !1;
76
- s++, E === "MultiPoint" && w++;
79
+ b++, Y === "MultiPoint" && F++;
77
80
  }
78
- E === "LineString" && w++;
81
+ Y === "LineString" && F++;
79
82
  break;
80
83
  case "Polygon":
81
84
  case "MultiLineString":
82
- for (n = 0; n < c.length; n++) {
83
- for (r = 0; r < c[n].length - a; r++) {
85
+ for (n = 0; n < E.length; n++) {
86
+ for (r = 0; r < E[n].length - T; r++) {
84
87
  if (t(
85
- c[n][r],
86
- s,
87
- x,
88
- w,
89
- m
88
+ E[n][r],
89
+ b,
90
+ V,
91
+ F,
92
+ B
90
93
  ) === !1)
91
94
  return !1;
92
- s++;
95
+ b++;
93
96
  }
94
- E === "MultiLineString" && w++, E === "Polygon" && m++;
97
+ Y === "MultiLineString" && F++, Y === "Polygon" && B++;
95
98
  }
96
- E === "Polygon" && w++;
99
+ Y === "Polygon" && F++;
97
100
  break;
98
101
  case "MultiPolygon":
99
- for (n = 0; n < c.length; n++) {
100
- for (m = 0, r = 0; r < c[n].length; r++) {
101
- for (i = 0; i < c[n][r].length - a; i++) {
102
+ for (n = 0; n < E.length; n++) {
103
+ for (B = 0, r = 0; r < E[n].length; r++) {
104
+ for (f = 0; f < E[n][r].length - T; f++) {
102
105
  if (t(
103
- c[n][r][i],
104
- s,
105
- x,
106
- w,
107
- m
106
+ E[n][r][f],
107
+ b,
108
+ V,
109
+ F,
110
+ B
108
111
  ) === !1)
109
112
  return !1;
110
- s++;
113
+ b++;
111
114
  }
112
- m++;
115
+ B++;
113
116
  }
114
- w++;
117
+ F++;
115
118
  }
116
119
  break;
117
120
  case "GeometryCollection":
118
- for (n = 0; n < u.geometries.length; n++)
119
- if (Ot(u.geometries[n], t) === !1)
121
+ for (n = 0; n < a.geometries.length; n++)
122
+ if (st(a.geometries[n], t) === !1)
120
123
  return !1;
121
124
  break;
122
125
  default:
@@ -126,22 +129,22 @@ function Ot(o, t, e) {
126
129
  }
127
130
  }
128
131
  }
129
- function st(o, t) {
130
- var e, n, r, i, u, l, c, f, a, s, h = 0, g = o.type === "FeatureCollection", y = o.type === "Feature", p = g ? o.features.length : 1;
131
- for (e = 0; e < p; e++) {
132
- for (l = g ? o.features[e].geometry : y ? o.geometry : o, f = g ? o.features[e].properties : y ? o.properties : {}, a = g ? o.features[e].bbox : y ? o.bbox : void 0, s = g ? o.features[e].id : y ? o.id : void 0, c = l ? l.type === "GeometryCollection" : !1, u = c ? l.geometries.length : 1, r = 0; r < u; r++) {
133
- if (i = c ? l.geometries[r] : l, i === null) {
132
+ function Ge(i, t) {
133
+ var e, n, r, f, a, c, E, d, T, b, P = 0, N = i.type === "FeatureCollection", _ = i.type === "Feature", L = N ? i.features.length : 1;
134
+ for (e = 0; e < L; e++) {
135
+ for (c = N ? i.features[e].geometry : _ ? i.geometry : i, d = N ? i.features[e].properties : _ ? i.properties : {}, T = N ? i.features[e].bbox : _ ? i.bbox : void 0, b = N ? i.features[e].id : _ ? i.id : void 0, E = c ? c.type === "GeometryCollection" : !1, a = E ? c.geometries.length : 1, r = 0; r < a; r++) {
136
+ if (f = E ? c.geometries[r] : c, f === null) {
134
137
  if (t(
135
138
  null,
136
- h,
137
- f,
138
- a,
139
- s
139
+ P,
140
+ d,
141
+ T,
142
+ b
140
143
  ) === !1)
141
144
  return !1;
142
145
  continue;
143
146
  }
144
- switch (i.type) {
147
+ switch (f.type) {
145
148
  case "Point":
146
149
  case "LineString":
147
150
  case "MultiPoint":
@@ -149,23 +152,23 @@ function st(o, t) {
149
152
  case "MultiLineString":
150
153
  case "MultiPolygon": {
151
154
  if (t(
152
- i,
153
- h,
154
155
  f,
155
- a,
156
- s
156
+ P,
157
+ d,
158
+ T,
159
+ b
157
160
  ) === !1)
158
161
  return !1;
159
162
  break;
160
163
  }
161
164
  case "GeometryCollection": {
162
- for (n = 0; n < i.geometries.length; n++)
165
+ for (n = 0; n < f.geometries.length; n++)
163
166
  if (t(
164
- i.geometries[n],
165
- h,
166
- f,
167
- a,
168
- s
167
+ f.geometries[n],
168
+ P,
169
+ d,
170
+ T,
171
+ b
169
172
  ) === !1)
170
173
  return !1;
171
174
  break;
@@ -174,606 +177,1052 @@ function st(o, t) {
174
177
  throw new Error("Unknown Geometry Type");
175
178
  }
176
179
  }
177
- h++;
180
+ P++;
178
181
  }
179
182
  }
180
- function Dt(o, t) {
181
- st(o, function(e, n, r, i, u) {
182
- var l = e === null ? null : e.type;
183
- switch (l) {
183
+ function St(i, t) {
184
+ Ge(i, function(e, n, r, f, a) {
185
+ var c = e === null ? null : e.type;
186
+ switch (c) {
184
187
  case null:
185
188
  case "Point":
186
189
  case "LineString":
187
190
  case "Polygon":
188
191
  return t(
189
- D(e, r, { bbox: i, id: u }),
192
+ Se(e, r, { bbox: f, id: a }),
190
193
  n,
191
194
  0
192
195
  ) === !1 ? !1 : void 0;
193
196
  }
194
- var c;
195
- switch (l) {
197
+ var E;
198
+ switch (c) {
196
199
  case "MultiPoint":
197
- c = "Point";
200
+ E = "Point";
198
201
  break;
199
202
  case "MultiLineString":
200
- c = "LineString";
203
+ E = "LineString";
201
204
  break;
202
205
  case "MultiPolygon":
203
- c = "Polygon";
206
+ E = "Polygon";
204
207
  break;
205
208
  }
206
- for (var f = 0; f < e.coordinates.length; f++) {
207
- var a = e.coordinates[f], s = {
208
- type: c,
209
- coordinates: a
209
+ for (var d = 0; d < e.coordinates.length; d++) {
210
+ var T = e.coordinates[d], b = {
211
+ type: E,
212
+ coordinates: T
210
213
  };
211
- if (t(D(s, r), n, f) === !1)
214
+ if (t(Se(b, r), n, d) === !1)
212
215
  return !1;
213
216
  }
214
217
  });
215
218
  }
216
- function Xt(o, t = {}) {
217
- if (o.bbox != null && t.recompute !== !0)
218
- return o.bbox;
219
+ function vt(i, t = {}) {
220
+ if (i.bbox != null && t.recompute !== !0)
221
+ return i.bbox;
219
222
  const e = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
220
- return Ot(o, (n) => {
223
+ return st(i, (n) => {
221
224
  e[0] > n[0] && (e[0] = n[0]), e[1] > n[1] && (e[1] = n[1]), e[2] < n[0] && (e[2] = n[0]), e[3] < n[1] && (e[3] = n[1]);
222
225
  }), e;
223
226
  }
224
- var yt = Xt;
225
- /**
226
- * splaytree v3.1.2
227
- * Fast Splay tree for Node and browser
228
- *
229
- * @author Alexander Milevski <info@w8r.name>
230
- * @license MIT
231
- * @preserve
232
- */
233
- /*! *****************************************************************************
234
- Copyright (c) Microsoft Corporation. All rights reserved.
235
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
236
- this file except in compliance with the License. You may obtain a copy of the
237
- License at http://www.apache.org/licenses/LICENSE-2.0
238
-
239
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
240
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
241
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
242
- MERCHANTABLITY OR NON-INFRINGEMENT.
243
-
244
- See the Apache Version 2.0 License for specific language governing permissions
245
- and limitations under the License.
246
- ***************************************************************************** */
247
- function Wt(o, t) {
248
- var e = { label: 0, sent: function() {
249
- if (i[0] & 1) throw i[1];
250
- return i[1];
251
- }, trys: [], ops: [] }, n, r, i, u;
252
- return u = { next: l(0), throw: l(1), return: l(2) }, typeof Symbol == "function" && (u[Symbol.iterator] = function() {
253
- return this;
254
- }), u;
255
- function l(f) {
256
- return function(a) {
257
- return c([f, a]);
258
- };
259
- }
260
- function c(f) {
261
- if (n) throw new TypeError("Generator is already executing.");
262
- for (; e; ) try {
263
- if (n = 1, r && (i = f[0] & 2 ? r.return : f[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, f[1])).done) return i;
264
- switch (r = 0, i && (f = [f[0] & 2, i.value]), f[0]) {
265
- case 0:
266
- case 1:
267
- i = f;
268
- break;
269
- case 4:
270
- return e.label++, { value: f[1], done: !1 };
271
- case 5:
272
- e.label++, r = f[1], f = [0];
273
- continue;
274
- case 7:
275
- f = e.ops.pop(), e.trys.pop();
276
- continue;
277
- default:
278
- if (i = e.trys, !(i = i.length > 0 && i[i.length - 1]) && (f[0] === 6 || f[0] === 2)) {
279
- e = 0;
227
+ var Ke = vt, bt = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, _e = Math.ceil, j = Math.floor, X = "[BigNumber Error] ", Xe = X + "Number primitive has more than 15 significant digits: ", ee = 1e14, C = 14, Ye = 9007199254740991, Oe = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], ue = 1e7, W = 1e9;
228
+ function ot(i) {
229
+ var t, e, n, r = S.prototype = { constructor: S, toString: null, valueOf: null }, f = new S(1), a = 20, c = 4, E = -7, d = 21, T = -1e7, b = 1e7, P = !1, N = 1, _ = 0, L = {
230
+ prefix: "",
231
+ groupSize: 3,
232
+ secondaryGroupSize: 0,
233
+ groupSeparator: ",",
234
+ decimalSeparator: ".",
235
+ fractionGroupSize: 0,
236
+ fractionGroupSeparator: " ",
237
+ // non-breaking space
238
+ suffix: ""
239
+ }, A = "0123456789abcdefghijklmnopqrstuvwxyz", V = !0;
240
+ function S(s, o) {
241
+ var l, m, h, g, w, u, p, x, y = this;
242
+ if (!(y instanceof S)) return new S(s, o);
243
+ if (o == null) {
244
+ if (s && s._isBigNumber === !0) {
245
+ y.s = s.s, !s.c || s.e > b ? y.c = y.e = null : s.e < T ? y.c = [y.e = 0] : (y.e = s.e, y.c = s.c.slice());
246
+ return;
247
+ }
248
+ if ((u = typeof s == "number") && s * 0 == 0) {
249
+ if (y.s = 1 / s < 0 ? (s = -s, -1) : 1, s === ~~s) {
250
+ for (g = 0, w = s; w >= 10; w /= 10, g++) ;
251
+ g > b ? y.c = y.e = null : (y.e = g, y.c = [s]);
252
+ return;
253
+ }
254
+ x = String(s);
255
+ } else {
256
+ if (!bt.test(x = String(s))) return n(y, x, u);
257
+ y.s = x.charCodeAt(0) == 45 ? (x = x.slice(1), -1) : 1;
258
+ }
259
+ (g = x.indexOf(".")) > -1 && (x = x.replace(".", "")), (w = x.search(/e/i)) > 0 ? (g < 0 && (g = w), g += +x.slice(w + 1), x = x.substring(0, w)) : g < 0 && (g = x.length);
260
+ } else {
261
+ if (q(o, 2, A.length, "Base"), o == 10 && V)
262
+ return y = new S(s), Z(y, a + y.e + 1, c);
263
+ if (x = String(s), u = typeof s == "number") {
264
+ if (s * 0 != 0) return n(y, x, u, o);
265
+ if (y.s = 1 / s < 0 ? (x = x.slice(1), -1) : 1, S.DEBUG && x.replace(/^0\.0*|\./, "").length > 15)
266
+ throw Error(Xe + s);
267
+ } else
268
+ y.s = x.charCodeAt(0) === 45 ? (x = x.slice(1), -1) : 1;
269
+ for (l = A.slice(0, o), g = w = 0, p = x.length; w < p; w++)
270
+ if (l.indexOf(m = x.charAt(w)) < 0) {
271
+ if (m == ".") {
272
+ if (w > g) {
273
+ g = p;
274
+ continue;
275
+ }
276
+ } else if (!h && (x == x.toUpperCase() && (x = x.toLowerCase()) || x == x.toLowerCase() && (x = x.toUpperCase()))) {
277
+ h = !0, w = -1, g = 0;
280
278
  continue;
281
279
  }
282
- if (f[0] === 3 && (!i || f[1] > i[0] && f[1] < i[3])) {
283
- e.label = f[1];
284
- break;
285
- }
286
- if (f[0] === 6 && e.label < i[1]) {
287
- e.label = i[1], i = f;
288
- break;
289
- }
290
- if (i && e.label < i[2]) {
291
- e.label = i[2], e.ops.push(f);
292
- break;
293
- }
294
- i[2] && e.ops.pop(), e.trys.pop();
295
- continue;
296
- }
297
- f = t.call(o, e);
298
- } catch (a) {
299
- f = [6, a], r = 0;
300
- } finally {
301
- n = i = 0;
280
+ return n(y, String(s), u, o);
281
+ }
282
+ u = !1, x = e(x, o, 10, y.s), (g = x.indexOf(".")) > -1 ? x = x.replace(".", "") : g = x.length;
302
283
  }
303
- if (f[0] & 5) throw f[1];
304
- return { value: f[0] ? f[1] : void 0, done: !0 };
305
- }
306
- }
307
- var $ = (
308
- /** @class */
309
- /* @__PURE__ */ function() {
310
- function o(t, e) {
311
- this.next = null, this.key = t, this.data = e, this.left = null, this.right = null;
312
- }
313
- return o;
314
- }()
315
- );
316
- function Zt(o, t) {
317
- return o > t ? 1 : o < t ? -1 : 0;
318
- }
319
- function G(o, t, e) {
320
- for (var n = new $(null, null), r = n, i = n; ; ) {
321
- var u = e(o, t.key);
322
- if (u < 0) {
323
- if (t.left === null)
324
- break;
325
- if (e(o, t.left.key) < 0) {
326
- var l = t.left;
327
- if (t.left = l.right, l.right = t, t = l, t.left === null)
328
- break;
329
- }
330
- i.left = t, i = t, t = t.left;
331
- } else if (u > 0) {
332
- if (t.right === null)
333
- break;
334
- if (e(o, t.right.key) > 0) {
335
- var l = t.right;
336
- if (t.right = l.left, l.left = t, t = l, t.right === null)
337
- break;
284
+ for (w = 0; x.charCodeAt(w) === 48; w++) ;
285
+ for (p = x.length; x.charCodeAt(--p) === 48; ) ;
286
+ if (x = x.slice(w, ++p)) {
287
+ if (p -= w, u && S.DEBUG && p > 15 && (s > Ye || s !== j(s)))
288
+ throw Error(Xe + y.s * s);
289
+ if ((g = g - w - 1) > b)
290
+ y.c = y.e = null;
291
+ else if (g < T)
292
+ y.c = [y.e = 0];
293
+ else {
294
+ if (y.e = g, y.c = [], w = (g + 1) % C, g < 0 && (w += C), w < p) {
295
+ for (w && y.c.push(+x.slice(0, w)), p -= C; w < p; )
296
+ y.c.push(+x.slice(w, w += C));
297
+ w = C - (x = x.slice(w)).length;
298
+ } else
299
+ w -= p;
300
+ for (; w--; x += "0") ;
301
+ y.c.push(+x);
338
302
  }
339
- r.right = t, r = t, t = t.right;
340
303
  } else
341
- break;
304
+ y.c = [y.e = 0];
342
305
  }
343
- return r.right = t.left, i.left = t.right, t.left = n.right, t.right = n.left, t;
344
- }
345
- function J(o, t, e, n) {
346
- var r = new $(o, t);
347
- if (e === null)
348
- return r.left = r.right = null, r;
349
- e = G(o, e, n);
350
- var i = n(o, e.key);
351
- return i < 0 ? (r.left = e.left, r.right = e, e.left = null) : i >= 0 && (r.right = e.right, r.left = e, e.right = null), r;
352
- }
353
- function xt(o, t, e) {
354
- var n = null, r = null;
355
- if (t) {
356
- t = G(o, t, e);
357
- var i = e(t.key, o);
358
- i === 0 ? (n = t.left, r = t.right) : i < 0 ? (r = t.right, t.right = null, n = t) : (n = t.left, t.left = null, r = t);
359
- }
360
- return { left: n, right: r };
361
- }
362
- function Jt(o, t, e) {
363
- return t === null ? o : (o === null || (t = G(o.key, t, e), t.left = o), t);
364
- }
365
- function tt(o, t, e, n, r) {
366
- if (o) {
367
- n("" + t + (e ? "└── " : "├── ") + r(o) + `
368
- `);
369
- var i = t + (e ? " " : "│ ");
370
- o.left && tt(o.left, i, !1, n, r), o.right && tt(o.right, i, !0, n, r);
371
- }
372
- }
373
- var lt = (
374
- /** @class */
375
- function() {
376
- function o(t) {
377
- t === void 0 && (t = Zt), this._root = null, this._size = 0, this._comparator = t;
378
- }
379
- return o.prototype.insert = function(t, e) {
380
- return this._size++, this._root = J(t, e, this._root, this._comparator);
381
- }, o.prototype.add = function(t, e) {
382
- var n = new $(t, e);
383
- this._root === null && (n.left = n.right = null, this._size++, this._root = n);
384
- var r = this._comparator, i = G(t, this._root, r), u = r(t, i.key);
385
- return u === 0 ? this._root = i : (u < 0 ? (n.left = i.left, n.right = i, i.left = null) : u > 0 && (n.right = i.right, n.left = i, i.right = null), this._size++, this._root = n), this._root;
386
- }, o.prototype.remove = function(t) {
387
- this._root = this._remove(t, this._root, this._comparator);
388
- }, o.prototype._remove = function(t, e, n) {
389
- var r;
390
- if (e === null)
391
- return null;
392
- e = G(t, e, n);
393
- var i = n(t, e.key);
394
- return i === 0 ? (e.left === null ? r = e.right : (r = G(t, e.left, n), r.right = e.right), this._size--, r) : e;
395
- }, o.prototype.pop = function() {
396
- var t = this._root;
397
- if (t) {
398
- for (; t.left; )
399
- t = t.left;
400
- return this._root = G(t.key, this._root, this._comparator), this._root = this._remove(t.key, this._root, this._comparator), { key: t.key, data: t.data };
306
+ S.clone = ot, S.ROUND_UP = 0, S.ROUND_DOWN = 1, S.ROUND_CEIL = 2, S.ROUND_FLOOR = 3, S.ROUND_HALF_UP = 4, S.ROUND_HALF_DOWN = 5, S.ROUND_HALF_EVEN = 6, S.ROUND_HALF_CEIL = 7, S.ROUND_HALF_FLOOR = 8, S.EUCLID = 9, S.config = S.set = function(s) {
307
+ var o, l;
308
+ if (s != null)
309
+ if (typeof s == "object") {
310
+ if (s.hasOwnProperty(o = "DECIMAL_PLACES") && (l = s[o], q(l, 0, W, o), a = l), s.hasOwnProperty(o = "ROUNDING_MODE") && (l = s[o], q(l, 0, 8, o), c = l), s.hasOwnProperty(o = "EXPONENTIAL_AT") && (l = s[o], l && l.pop ? (q(l[0], -1e9, 0, o), q(l[1], 0, W, o), E = l[0], d = l[1]) : (q(l, -1e9, W, o), E = -(d = l < 0 ? -l : l))), s.hasOwnProperty(o = "RANGE"))
311
+ if (l = s[o], l && l.pop)
312
+ q(l[0], -1e9, -1, o), q(l[1], 1, W, o), T = l[0], b = l[1];
313
+ else if (q(l, -1e9, W, o), l)
314
+ T = -(b = l < 0 ? -l : l);
315
+ else
316
+ throw Error(X + o + " cannot be zero: " + l);
317
+ if (s.hasOwnProperty(o = "CRYPTO"))
318
+ if (l = s[o], l === !!l)
319
+ if (l)
320
+ if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
321
+ P = l;
322
+ else
323
+ throw P = !l, Error(X + "crypto unavailable");
324
+ else
325
+ P = l;
326
+ else
327
+ throw Error(X + o + " not true or false: " + l);
328
+ if (s.hasOwnProperty(o = "MODULO_MODE") && (l = s[o], q(l, 0, 9, o), N = l), s.hasOwnProperty(o = "POW_PRECISION") && (l = s[o], q(l, 0, W, o), _ = l), s.hasOwnProperty(o = "FORMAT"))
329
+ if (l = s[o], typeof l == "object") L = l;
330
+ else throw Error(X + o + " not an object: " + l);
331
+ if (s.hasOwnProperty(o = "ALPHABET"))
332
+ if (l = s[o], typeof l == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(l))
333
+ V = l.slice(0, 10) == "0123456789", A = l;
334
+ else
335
+ throw Error(X + o + " invalid: " + l);
336
+ } else
337
+ throw Error(X + "Object expected: " + s);
338
+ return {
339
+ DECIMAL_PLACES: a,
340
+ ROUNDING_MODE: c,
341
+ EXPONENTIAL_AT: [E, d],
342
+ RANGE: [T, b],
343
+ CRYPTO: P,
344
+ MODULO_MODE: N,
345
+ POW_PRECISION: _,
346
+ FORMAT: L,
347
+ ALPHABET: A
348
+ };
349
+ }, S.isBigNumber = function(s) {
350
+ if (!s || s._isBigNumber !== !0) return !1;
351
+ if (!S.DEBUG) return !0;
352
+ var o, l, m = s.c, h = s.e, g = s.s;
353
+ e: if ({}.toString.call(m) == "[object Array]") {
354
+ if ((g === 1 || g === -1) && h >= -1e9 && h <= W && h === j(h)) {
355
+ if (m[0] === 0) {
356
+ if (h === 0 && m.length === 1) return !0;
357
+ break e;
358
+ }
359
+ if (o = (h + 1) % C, o < 1 && (o += C), String(m[0]).length == o) {
360
+ for (o = 0; o < m.length; o++)
361
+ if (l = m[o], l < 0 || l >= ee || l !== j(l)) break e;
362
+ if (l !== 0) return !0;
363
+ }
401
364
  }
402
- return null;
403
- }, o.prototype.findStatic = function(t) {
404
- for (var e = this._root, n = this._comparator; e; ) {
405
- var r = n(t, e.key);
406
- if (r === 0)
407
- return e;
408
- r < 0 ? e = e.left : e = e.right;
365
+ } else if (m === null && h === null && (g === null || g === 1 || g === -1))
366
+ return !0;
367
+ throw Error(X + "Invalid BigNumber: " + s);
368
+ }, S.maximum = S.max = function() {
369
+ return B(arguments, -1);
370
+ }, S.minimum = S.min = function() {
371
+ return B(arguments, 1);
372
+ }, S.random = function() {
373
+ var s = 9007199254740992, o = Math.random() * s & 2097151 ? function() {
374
+ return j(Math.random() * s);
375
+ } : function() {
376
+ return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
377
+ };
378
+ return function(l) {
379
+ var m, h, g, w, u, p = 0, x = [], y = new S(f);
380
+ if (l == null ? l = a : q(l, 0, W), w = _e(l / C), P)
381
+ if (crypto.getRandomValues) {
382
+ for (m = crypto.getRandomValues(new Uint32Array(w *= 2)); p < w; )
383
+ u = m[p] * 131072 + (m[p + 1] >>> 11), u >= 9e15 ? (h = crypto.getRandomValues(new Uint32Array(2)), m[p] = h[0], m[p + 1] = h[1]) : (x.push(u % 1e14), p += 2);
384
+ p = w / 2;
385
+ } else if (crypto.randomBytes) {
386
+ for (m = crypto.randomBytes(w *= 7); p < w; )
387
+ u = (m[p] & 31) * 281474976710656 + m[p + 1] * 1099511627776 + m[p + 2] * 4294967296 + m[p + 3] * 16777216 + (m[p + 4] << 16) + (m[p + 5] << 8) + m[p + 6], u >= 9e15 ? crypto.randomBytes(7).copy(m, p) : (x.push(u % 1e14), p += 7);
388
+ p = w / 7;
389
+ } else
390
+ throw P = !1, Error(X + "crypto unavailable");
391
+ if (!P)
392
+ for (; p < w; )
393
+ u = o(), u < 9e15 && (x[p++] = u % 1e14);
394
+ for (w = x[--p], l %= C, w && l && (u = Oe[C - l], x[p] = j(w / u) * u); x[p] === 0; x.pop(), p--) ;
395
+ if (p < 0)
396
+ x = [g = 0];
397
+ else {
398
+ for (g = -1; x[0] === 0; x.splice(0, 1), g -= C) ;
399
+ for (p = 1, u = x[0]; u >= 10; u /= 10, p++) ;
400
+ p < C && (g -= C - p);
409
401
  }
410
- return null;
411
- }, o.prototype.find = function(t) {
412
- return this._root && (this._root = G(t, this._root, this._comparator), this._comparator(t, this._root.key) !== 0) ? null : this._root;
413
- }, o.prototype.contains = function(t) {
414
- for (var e = this._root, n = this._comparator; e; ) {
415
- var r = n(t, e.key);
416
- if (r === 0)
417
- return !0;
418
- r < 0 ? e = e.left : e = e.right;
402
+ return y.e = g, y.c = x, y;
403
+ };
404
+ }(), S.sum = function() {
405
+ for (var s = 1, o = arguments, l = new S(o[0]); s < o.length; ) l = l.plus(o[s++]);
406
+ return l;
407
+ }, e = /* @__PURE__ */ function() {
408
+ var s = "0123456789";
409
+ function o(l, m, h, g) {
410
+ for (var w, u = [0], p, x = 0, y = l.length; x < y; ) {
411
+ for (p = u.length; p--; u[p] *= m) ;
412
+ for (u[0] += g.indexOf(l.charAt(x++)), w = 0; w < u.length; w++)
413
+ u[w] > h - 1 && (u[w + 1] == null && (u[w + 1] = 0), u[w + 1] += u[w] / h | 0, u[w] %= h);
419
414
  }
420
- return !1;
421
- }, o.prototype.forEach = function(t, e) {
422
- for (var n = this._root, r = [], i = !1; !i; )
423
- n !== null ? (r.push(n), n = n.left) : r.length !== 0 ? (n = r.pop(), t.call(e, n), n = n.right) : i = !0;
424
- return this;
425
- }, o.prototype.range = function(t, e, n, r) {
426
- for (var i = [], u = this._comparator, l = this._root, c; i.length !== 0 || l; )
427
- if (l)
428
- i.push(l), l = l.left;
429
- else {
430
- if (l = i.pop(), c = u(l.key, e), c > 0)
415
+ return u.reverse();
416
+ }
417
+ return function(l, m, h, g, w) {
418
+ var u, p, x, y, v, R, O, k, D = l.indexOf("."), U = a, I = c;
419
+ for (D >= 0 && (y = _, _ = 0, l = l.replace(".", ""), k = new S(m), R = k.pow(l.length - D), _ = y, k.c = o(
420
+ oe(J(R.c), R.e, "0"),
421
+ 10,
422
+ h,
423
+ s
424
+ ), k.e = k.c.length), O = o(l, m, h, w ? (u = A, s) : (u = s, A)), x = y = O.length; O[--y] == 0; O.pop()) ;
425
+ if (!O[0]) return u.charAt(0);
426
+ if (D < 0 ? --x : (R.c = O, R.e = x, R.s = g, R = t(R, k, U, I, h), O = R.c, v = R.r, x = R.e), p = x + U + 1, D = O[p], y = h / 2, v = v || p < 0 || O[p + 1] != null, v = I < 4 ? (D != null || v) && (I == 0 || I == (R.s < 0 ? 3 : 2)) : D > y || D == y && (I == 4 || v || I == 6 && O[p - 1] & 1 || I == (R.s < 0 ? 8 : 7)), p < 1 || !O[0])
427
+ l = v ? oe(u.charAt(1), -U, u.charAt(0)) : u.charAt(0);
428
+ else {
429
+ if (O.length = p, v)
430
+ for (--h; ++O[--p] > h; )
431
+ O[p] = 0, p || (++x, O = [1].concat(O));
432
+ for (y = O.length; !O[--y]; ) ;
433
+ for (D = 0, l = ""; D <= y; l += u.charAt(O[D++])) ;
434
+ l = oe(l, x, u.charAt(0));
435
+ }
436
+ return l;
437
+ };
438
+ }(), t = /* @__PURE__ */ function() {
439
+ function s(m, h, g) {
440
+ var w, u, p, x, y = 0, v = m.length, R = h % ue, O = h / ue | 0;
441
+ for (m = m.slice(); v--; )
442
+ p = m[v] % ue, x = m[v] / ue | 0, w = O * p + x * R, u = R * p + w % ue * ue + y, y = (u / g | 0) + (w / ue | 0) + O * x, m[v] = u % g;
443
+ return y && (m = [y].concat(m)), m;
444
+ }
445
+ function o(m, h, g, w) {
446
+ var u, p;
447
+ if (g != w)
448
+ p = g > w ? 1 : -1;
449
+ else
450
+ for (u = p = 0; u < g; u++)
451
+ if (m[u] != h[u]) {
452
+ p = m[u] > h[u] ? 1 : -1;
431
453
  break;
432
- if (u(l.key, t) >= 0 && n.call(r, l))
433
- return this;
434
- l = l.right;
435
- }
436
- return this;
437
- }, o.prototype.keys = function() {
438
- var t = [];
439
- return this.forEach(function(e) {
440
- var n = e.key;
441
- return t.push(n);
442
- }), t;
443
- }, o.prototype.values = function() {
444
- var t = [];
445
- return this.forEach(function(e) {
446
- var n = e.data;
447
- return t.push(n);
448
- }), t;
449
- }, o.prototype.min = function() {
450
- return this._root ? this.minNode(this._root).key : null;
451
- }, o.prototype.max = function() {
452
- return this._root ? this.maxNode(this._root).key : null;
453
- }, o.prototype.minNode = function(t) {
454
- if (t === void 0 && (t = this._root), t)
455
- for (; t.left; )
456
- t = t.left;
457
- return t;
458
- }, o.prototype.maxNode = function(t) {
459
- if (t === void 0 && (t = this._root), t)
460
- for (; t.right; )
461
- t = t.right;
462
- return t;
463
- }, o.prototype.at = function(t) {
464
- for (var e = this._root, n = !1, r = 0, i = []; !n; )
465
- if (e)
466
- i.push(e), e = e.left;
467
- else if (i.length > 0) {
468
- if (e = i.pop(), r === t)
469
- return e;
470
- r++, e = e.right;
471
- } else
472
- n = !0;
473
- return null;
474
- }, o.prototype.next = function(t) {
475
- var e = this._root, n = null;
476
- if (t.right) {
477
- for (n = t.right; n.left; )
478
- n = n.left;
479
- return n;
454
+ }
455
+ return p;
456
+ }
457
+ function l(m, h, g, w) {
458
+ for (var u = 0; g--; )
459
+ m[g] -= u, u = m[g] < h[g] ? 1 : 0, m[g] = u * w + m[g] - h[g];
460
+ for (; !m[0] && m.length > 1; m.splice(0, 1)) ;
461
+ }
462
+ return function(m, h, g, w, u) {
463
+ var p, x, y, v, R, O, k, D, U, I, G, $, ye, Le, Me, te, he, H = m.s == h.s ? 1 : -1, K = m.c, z = h.c;
464
+ if (!K || !K[0] || !z || !z[0])
465
+ return new S(
466
+ // Return NaN if either NaN, or both Infinity or 0.
467
+ !m.s || !h.s || (K ? z && K[0] == z[0] : !z) ? NaN : (
468
+ // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
469
+ K && K[0] == 0 || !z ? H * 0 : H / 0
470
+ )
471
+ );
472
+ for (D = new S(H), U = D.c = [], x = m.e - h.e, H = g + x + 1, u || (u = ee, x = Q(m.e / C) - Q(h.e / C), H = H / C | 0), y = 0; z[y] == (K[y] || 0); y++) ;
473
+ if (z[y] > (K[y] || 0) && x--, H < 0)
474
+ U.push(1), v = !0;
475
+ else {
476
+ for (Le = K.length, te = z.length, y = 0, H += 2, R = j(u / (z[0] + 1)), R > 1 && (z = s(z, R, u), K = s(K, R, u), te = z.length, Le = K.length), ye = te, I = K.slice(0, te), G = I.length; G < te; I[G++] = 0) ;
477
+ he = z.slice(), he = [0].concat(he), Me = z[0], z[1] >= u / 2 && Me++;
478
+ do {
479
+ if (R = 0, p = o(z, I, te, G), p < 0) {
480
+ if ($ = I[0], te != G && ($ = $ * u + (I[1] || 0)), R = j($ / Me), R > 1)
481
+ for (R >= u && (R = u - 1), O = s(z, R, u), k = O.length, G = I.length; o(O, I, k, G) == 1; )
482
+ R--, l(O, te < k ? he : z, k, u), k = O.length, p = 1;
483
+ else
484
+ R == 0 && (p = R = 1), O = z.slice(), k = O.length;
485
+ if (k < G && (O = [0].concat(O)), l(I, O, G, u), G = I.length, p == -1)
486
+ for (; o(z, I, te, G) < 1; )
487
+ R++, l(I, te < G ? he : z, G, u), G = I.length;
488
+ } else p === 0 && (R++, I = [0]);
489
+ U[y++] = R, I[0] ? I[G++] = K[ye] || 0 : (I = [K[ye]], G = 1);
490
+ } while ((ye++ < Le || I[0] != null) && H--);
491
+ v = I[0] != null, U[0] || U.splice(0, 1);
480
492
  }
481
- for (var r = this._comparator; e; ) {
482
- var i = r(t.key, e.key);
483
- if (i === 0)
484
- break;
485
- i < 0 ? (n = e, e = e.left) : e = e.right;
493
+ if (u == ee) {
494
+ for (y = 1, H = U[0]; H >= 10; H /= 10, y++) ;
495
+ Z(D, g + (D.e = y + x * C - 1) + 1, w, v);
496
+ } else
497
+ D.e = x, D.r = +v;
498
+ return D;
499
+ };
500
+ }();
501
+ function F(s, o, l, m) {
502
+ var h, g, w, u, p;
503
+ if (l == null ? l = c : q(l, 0, 8), !s.c) return s.toString();
504
+ if (h = s.c[0], w = s.e, o == null)
505
+ p = J(s.c), p = m == 1 || m == 2 && (w <= E || w >= d) ? xe(p, w) : oe(p, w, "0");
506
+ else if (s = Z(new S(s), o, l), g = s.e, p = J(s.c), u = p.length, m == 1 || m == 2 && (o <= g || g <= E)) {
507
+ for (; u < o; p += "0", u++) ;
508
+ p = xe(p, g);
509
+ } else if (o -= w, p = oe(p, g, "0"), g + 1 > u) {
510
+ if (--o > 0) for (p += "."; o--; p += "0") ;
511
+ } else if (o += g - u, o > 0)
512
+ for (g + 1 == u && (p += "."); o--; p += "0") ;
513
+ return s.s < 0 && h ? "-" + p : p;
514
+ }
515
+ function B(s, o) {
516
+ for (var l, m, h = 1, g = new S(s[0]); h < s.length; h++)
517
+ m = new S(s[h]), (!m.s || (l = fe(g, m)) === o || l === 0 && g.s === o) && (g = m);
518
+ return g;
519
+ }
520
+ function Y(s, o, l) {
521
+ for (var m = 1, h = o.length; !o[--h]; o.pop()) ;
522
+ for (h = o[0]; h >= 10; h /= 10, m++) ;
523
+ return (l = m + l * C - 1) > b ? s.c = s.e = null : l < T ? s.c = [s.e = 0] : (s.e = l, s.c = o), s;
524
+ }
525
+ n = /* @__PURE__ */ function() {
526
+ var s = /^(-?)0([xbo])(?=\w[\w.]*$)/i, o = /^([^.]+)\.$/, l = /^\.([^.]+)$/, m = /^-?(Infinity|NaN)$/, h = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
527
+ return function(g, w, u, p) {
528
+ var x, y = u ? w : w.replace(h, "");
529
+ if (m.test(y))
530
+ g.s = isNaN(y) ? null : y < 0 ? -1 : 1;
531
+ else {
532
+ if (!u && (y = y.replace(s, function(v, R, O) {
533
+ return x = (O = O.toLowerCase()) == "x" ? 16 : O == "b" ? 2 : 8, !p || p == x ? R : v;
534
+ }), p && (x = p, y = y.replace(o, "$1").replace(l, "0.$1")), w != y))
535
+ return new S(y, x);
536
+ if (S.DEBUG)
537
+ throw Error(X + "Not a" + (p ? " base " + p : "") + " number: " + w);
538
+ g.s = null;
486
539
  }
487
- return n;
488
- }, o.prototype.prev = function(t) {
489
- var e = this._root, n = null;
490
- if (t.left !== null) {
491
- for (n = t.left; n.right; )
492
- n = n.right;
493
- return n;
540
+ g.c = g.e = null;
541
+ };
542
+ }();
543
+ function Z(s, o, l, m) {
544
+ var h, g, w, u, p, x, y, v = s.c, R = Oe;
545
+ if (v) {
546
+ e: {
547
+ for (h = 1, u = v[0]; u >= 10; u /= 10, h++) ;
548
+ if (g = o - h, g < 0)
549
+ g += C, w = o, p = v[x = 0], y = j(p / R[h - w - 1] % 10);
550
+ else if (x = _e((g + 1) / C), x >= v.length)
551
+ if (m) {
552
+ for (; v.length <= x; v.push(0)) ;
553
+ p = y = 0, h = 1, g %= C, w = g - C + 1;
554
+ } else
555
+ break e;
556
+ else {
557
+ for (p = u = v[x], h = 1; u >= 10; u /= 10, h++) ;
558
+ g %= C, w = g - C + h, y = w < 0 ? 0 : j(p / R[h - w - 1] % 10);
559
+ }
560
+ if (m = m || o < 0 || // Are there any non-zero digits after the rounding digit?
561
+ // The expression n % pows10[d - j - 1] returns all digits of n to the right
562
+ // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
563
+ v[x + 1] != null || (w < 0 ? p : p % R[h - w - 1]), m = l < 4 ? (y || m) && (l == 0 || l == (s.s < 0 ? 3 : 2)) : y > 5 || y == 5 && (l == 4 || m || l == 6 && // Check whether the digit to the left of the rounding digit is odd.
564
+ (g > 0 ? w > 0 ? p / R[h - w] : 0 : v[x - 1]) % 10 & 1 || l == (s.s < 0 ? 8 : 7)), o < 1 || !v[0])
565
+ return v.length = 0, m ? (o -= s.e + 1, v[0] = R[(C - o % C) % C], s.e = -o || 0) : v[0] = s.e = 0, s;
566
+ if (g == 0 ? (v.length = x, u = 1, x--) : (v.length = x + 1, u = R[C - g], v[x] = w > 0 ? j(p / R[h - w] % R[w]) * u : 0), m)
567
+ for (; ; )
568
+ if (x == 0) {
569
+ for (g = 1, w = v[0]; w >= 10; w /= 10, g++) ;
570
+ for (w = v[0] += u, u = 1; w >= 10; w /= 10, u++) ;
571
+ g != u && (s.e++, v[0] == ee && (v[0] = 1));
572
+ break;
573
+ } else {
574
+ if (v[x] += u, v[x] != ee) break;
575
+ v[x--] = 0, u = 1;
576
+ }
577
+ for (g = v.length; v[--g] === 0; v.pop()) ;
494
578
  }
495
- for (var r = this._comparator; e; ) {
496
- var i = r(t.key, e.key);
497
- if (i === 0)
498
- break;
499
- i < 0 ? e = e.left : (n = e, e = e.right);
579
+ s.e > b ? s.c = s.e = null : s.e < T && (s.c = [s.e = 0]);
580
+ }
581
+ return s;
582
+ }
583
+ function re(s) {
584
+ var o, l = s.e;
585
+ return l === null ? s.toString() : (o = J(s.c), o = l <= E || l >= d ? xe(o, l) : oe(o, l, "0"), s.s < 0 ? "-" + o : o);
586
+ }
587
+ return r.absoluteValue = r.abs = function() {
588
+ var s = new S(this);
589
+ return s.s < 0 && (s.s = 1), s;
590
+ }, r.comparedTo = function(s, o) {
591
+ return fe(this, new S(s, o));
592
+ }, r.decimalPlaces = r.dp = function(s, o) {
593
+ var l, m, h, g = this;
594
+ if (s != null)
595
+ return q(s, 0, W), o == null ? o = c : q(o, 0, 8), Z(new S(g), s + g.e + 1, o);
596
+ if (!(l = g.c)) return null;
597
+ if (m = ((h = l.length - 1) - Q(this.e / C)) * C, h = l[h]) for (; h % 10 == 0; h /= 10, m--) ;
598
+ return m < 0 && (m = 0), m;
599
+ }, r.dividedBy = r.div = function(s, o) {
600
+ return t(this, new S(s, o), a, c);
601
+ }, r.dividedToIntegerBy = r.idiv = function(s, o) {
602
+ return t(this, new S(s, o), 0, 1);
603
+ }, r.exponentiatedBy = r.pow = function(s, o) {
604
+ var l, m, h, g, w, u, p, x, y, v = this;
605
+ if (s = new S(s), s.c && !s.isInteger())
606
+ throw Error(X + "Exponent not an integer: " + re(s));
607
+ if (o != null && (o = new S(o)), u = s.e > 14, !v.c || !v.c[0] || v.c[0] == 1 && !v.e && v.c.length == 1 || !s.c || !s.c[0])
608
+ return y = new S(Math.pow(+re(v), u ? s.s * (2 - de(s)) : +re(s))), o ? y.mod(o) : y;
609
+ if (p = s.s < 0, o) {
610
+ if (o.c ? !o.c[0] : !o.s) return new S(NaN);
611
+ m = !p && v.isInteger() && o.isInteger(), m && (v = v.mod(o));
612
+ } else {
613
+ if (s.e > 9 && (v.e > 0 || v.e < -1 || (v.e == 0 ? v.c[0] > 1 || u && v.c[1] >= 24e7 : v.c[0] < 8e13 || u && v.c[0] <= 9999975e7)))
614
+ return g = v.s < 0 && de(s) ? -0 : 0, v.e > -1 && (g = 1 / g), new S(p ? 1 / g : g);
615
+ _ && (g = _e(_ / C + 2));
616
+ }
617
+ for (u ? (l = new S(0.5), p && (s.s = 1), x = de(s)) : (h = Math.abs(+re(s)), x = h % 2), y = new S(f); ; ) {
618
+ if (x) {
619
+ if (y = y.times(v), !y.c) break;
620
+ g ? y.c.length > g && (y.c.length = g) : m && (y = y.mod(o));
500
621
  }
501
- return n;
502
- }, o.prototype.clear = function() {
503
- return this._root = null, this._size = 0, this;
504
- }, o.prototype.toList = function() {
505
- return Ht(this._root);
506
- }, o.prototype.load = function(t, e, n) {
507
- e === void 0 && (e = []), n === void 0 && (n = !1);
508
- var r = t.length, i = this._comparator;
509
- if (n && rt(t, e, 0, r - 1, i), this._root === null)
510
- this._root = et(t, e, 0, r), this._size = r;
622
+ if (h) {
623
+ if (h = j(h / 2), h === 0) break;
624
+ x = h % 2;
625
+ } else if (s = s.times(l), Z(s, s.e + 1, 1), s.e > 14)
626
+ x = de(s);
511
627
  else {
512
- var u = te(this.toList(), Kt(t, e), i);
513
- r = this._size + r, this._root = nt({ head: u }, 0, r);
628
+ if (h = +re(s), h === 0) break;
629
+ x = h % 2;
514
630
  }
515
- return this;
516
- }, o.prototype.isEmpty = function() {
517
- return this._root === null;
518
- }, Object.defineProperty(o.prototype, "size", {
519
- get: function() {
520
- return this._size;
521
- },
522
- enumerable: !0,
523
- configurable: !0
524
- }), Object.defineProperty(o.prototype, "root", {
525
- get: function() {
526
- return this._root;
527
- },
528
- enumerable: !0,
529
- configurable: !0
530
- }), o.prototype.toString = function(t) {
531
- t === void 0 && (t = function(n) {
532
- return String(n.key);
533
- });
534
- var e = [];
535
- return tt(this._root, "", !0, function(n) {
536
- return e.push(n);
537
- }, t), e.join("");
538
- }, o.prototype.update = function(t, e, n) {
539
- var r = this._comparator, i = xt(t, this._root, r), u = i.left, l = i.right;
540
- r(t, e) < 0 ? l = J(e, n, l, r) : u = J(e, n, u, r), this._root = Jt(u, l, r);
541
- }, o.prototype.split = function(t) {
542
- return xt(t, this._root, this._comparator);
543
- }, o.prototype[Symbol.iterator] = function() {
544
- var t, e, n;
545
- return Wt(this, function(r) {
546
- switch (r.label) {
547
- case 0:
548
- t = this._root, e = [], n = !1, r.label = 1;
549
- case 1:
550
- return n ? [3, 6] : t === null ? [3, 2] : (e.push(t), t = t.left, [3, 5]);
551
- case 2:
552
- return e.length === 0 ? [3, 4] : (t = e.pop(), [4, t]);
553
- case 3:
554
- return r.sent(), t = t.right, [3, 5];
555
- case 4:
556
- n = !0, r.label = 5;
557
- case 5:
558
- return [3, 1];
559
- case 6:
560
- return [
561
- 2
562
- /*return*/
563
- ];
631
+ v = v.times(v), g ? v.c && v.c.length > g && (v.c.length = g) : m && (v = v.mod(o));
632
+ }
633
+ return m ? y : (p && (y = f.div(y)), o ? y.mod(o) : g ? Z(y, _, c, w) : y);
634
+ }, r.integerValue = function(s) {
635
+ var o = new S(this);
636
+ return s == null ? s = c : q(s, 0, 8), Z(o, o.e + 1, s);
637
+ }, r.isEqualTo = r.eq = function(s, o) {
638
+ return fe(this, new S(s, o)) === 0;
639
+ }, r.isFinite = function() {
640
+ return !!this.c;
641
+ }, r.isGreaterThan = r.gt = function(s, o) {
642
+ return fe(this, new S(s, o)) > 0;
643
+ }, r.isGreaterThanOrEqualTo = r.gte = function(s, o) {
644
+ return (o = fe(this, new S(s, o))) === 1 || o === 0;
645
+ }, r.isInteger = function() {
646
+ return !!this.c && Q(this.e / C) > this.c.length - 2;
647
+ }, r.isLessThan = r.lt = function(s, o) {
648
+ return fe(this, new S(s, o)) < 0;
649
+ }, r.isLessThanOrEqualTo = r.lte = function(s, o) {
650
+ return (o = fe(this, new S(s, o))) === -1 || o === 0;
651
+ }, r.isNaN = function() {
652
+ return !this.s;
653
+ }, r.isNegative = function() {
654
+ return this.s < 0;
655
+ }, r.isPositive = function() {
656
+ return this.s > 0;
657
+ }, r.isZero = function() {
658
+ return !!this.c && this.c[0] == 0;
659
+ }, r.minus = function(s, o) {
660
+ var l, m, h, g, w = this, u = w.s;
661
+ if (s = new S(s, o), o = s.s, !u || !o) return new S(NaN);
662
+ if (u != o)
663
+ return s.s = -o, w.plus(s);
664
+ var p = w.e / C, x = s.e / C, y = w.c, v = s.c;
665
+ if (!p || !x) {
666
+ if (!y || !v) return y ? (s.s = -o, s) : new S(v ? w : NaN);
667
+ if (!y[0] || !v[0])
668
+ return v[0] ? (s.s = -o, s) : new S(y[0] ? w : (
669
+ // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
670
+ c == 3 ? -0 : 0
671
+ ));
672
+ }
673
+ if (p = Q(p), x = Q(x), y = y.slice(), u = p - x) {
674
+ for ((g = u < 0) ? (u = -u, h = y) : (x = p, h = v), h.reverse(), o = u; o--; h.push(0)) ;
675
+ h.reverse();
676
+ } else
677
+ for (m = (g = (u = y.length) < (o = v.length)) ? u : o, u = o = 0; o < m; o++)
678
+ if (y[o] != v[o]) {
679
+ g = y[o] < v[o];
680
+ break;
564
681
  }
565
- });
566
- }, o;
567
- }()
568
- );
569
- function et(o, t, e, n) {
570
- var r = n - e;
571
- if (r > 0) {
572
- var i = e + Math.floor(r / 2), u = o[i], l = t[i], c = new $(u, l);
573
- return c.left = et(o, t, e, i), c.right = et(o, t, i + 1, n), c;
574
- }
575
- return null;
576
- }
577
- function Kt(o, t) {
578
- for (var e = new $(null, null), n = e, r = 0; r < o.length; r++)
579
- n = n.next = new $(o[r], t[r]);
580
- return n.next = null, e.next;
581
- }
582
- function Ht(o) {
583
- for (var t = o, e = [], n = !1, r = new $(null, null), i = r; !n; )
584
- t ? (e.push(t), t = t.left) : e.length > 0 ? (t = i = i.next = e.pop(), t = t.right) : n = !0;
585
- return i.next = null, r.next;
586
- }
587
- function nt(o, t, e) {
588
- var n = e - t;
589
- if (n > 0) {
590
- var r = t + Math.floor(n / 2), i = nt(o, t, r), u = o.head;
591
- return u.left = i, o.head = o.head.next, u.right = nt(o, r + 1, e), u;
592
- }
593
- return null;
682
+ if (g && (h = y, y = v, v = h, s.s = -s.s), o = (m = v.length) - (l = y.length), o > 0) for (; o--; y[l++] = 0) ;
683
+ for (o = ee - 1; m > u; ) {
684
+ if (y[--m] < v[m]) {
685
+ for (l = m; l && !y[--l]; y[l] = o) ;
686
+ --y[l], y[m] += ee;
687
+ }
688
+ y[m] -= v[m];
689
+ }
690
+ for (; y[0] == 0; y.splice(0, 1), --x) ;
691
+ return y[0] ? Y(s, y, x) : (s.s = c == 3 ? -1 : 1, s.c = [s.e = 0], s);
692
+ }, r.modulo = r.mod = function(s, o) {
693
+ var l, m, h = this;
694
+ return s = new S(s, o), !h.c || !s.s || s.c && !s.c[0] ? new S(NaN) : !s.c || h.c && !h.c[0] ? new S(h) : (N == 9 ? (m = s.s, s.s = 1, l = t(h, s, 0, 3), s.s = m, l.s *= m) : l = t(h, s, 0, N), s = h.minus(l.times(s)), !s.c[0] && N == 1 && (s.s = h.s), s);
695
+ }, r.multipliedBy = r.times = function(s, o) {
696
+ var l, m, h, g, w, u, p, x, y, v, R, O, k, D, U, I = this, G = I.c, $ = (s = new S(s, o)).c;
697
+ if (!G || !$ || !G[0] || !$[0])
698
+ return !I.s || !s.s || G && !G[0] && !$ || $ && !$[0] && !G ? s.c = s.e = s.s = null : (s.s *= I.s, !G || !$ ? s.c = s.e = null : (s.c = [0], s.e = 0)), s;
699
+ for (m = Q(I.e / C) + Q(s.e / C), s.s *= I.s, p = G.length, v = $.length, p < v && (k = G, G = $, $ = k, h = p, p = v, v = h), h = p + v, k = []; h--; k.push(0)) ;
700
+ for (D = ee, U = ue, h = v; --h >= 0; ) {
701
+ for (l = 0, R = $[h] % U, O = $[h] / U | 0, w = p, g = h + w; g > h; )
702
+ x = G[--w] % U, y = G[w] / U | 0, u = O * x + y * R, x = R * x + u % U * U + k[g] + l, l = (x / D | 0) + (u / U | 0) + O * y, k[g--] = x % D;
703
+ k[g] = l;
704
+ }
705
+ return l ? ++m : k.splice(0, 1), Y(s, k, m);
706
+ }, r.negated = function() {
707
+ var s = new S(this);
708
+ return s.s = -s.s || null, s;
709
+ }, r.plus = function(s, o) {
710
+ var l, m = this, h = m.s;
711
+ if (s = new S(s, o), o = s.s, !h || !o) return new S(NaN);
712
+ if (h != o)
713
+ return s.s = -o, m.minus(s);
714
+ var g = m.e / C, w = s.e / C, u = m.c, p = s.c;
715
+ if (!g || !w) {
716
+ if (!u || !p) return new S(h / 0);
717
+ if (!u[0] || !p[0]) return p[0] ? s : new S(u[0] ? m : h * 0);
718
+ }
719
+ if (g = Q(g), w = Q(w), u = u.slice(), h = g - w) {
720
+ for (h > 0 ? (w = g, l = p) : (h = -h, l = u), l.reverse(); h--; l.push(0)) ;
721
+ l.reverse();
722
+ }
723
+ for (h = u.length, o = p.length, h - o < 0 && (l = p, p = u, u = l, o = h), h = 0; o; )
724
+ h = (u[--o] = u[o] + p[o] + h) / ee | 0, u[o] = ee === u[o] ? 0 : u[o] % ee;
725
+ return h && (u = [h].concat(u), ++w), Y(s, u, w);
726
+ }, r.precision = r.sd = function(s, o) {
727
+ var l, m, h, g = this;
728
+ if (s != null && s !== !!s)
729
+ return q(s, 1, W), o == null ? o = c : q(o, 0, 8), Z(new S(g), s, o);
730
+ if (!(l = g.c)) return null;
731
+ if (h = l.length - 1, m = h * C + 1, h = l[h]) {
732
+ for (; h % 10 == 0; h /= 10, m--) ;
733
+ for (h = l[0]; h >= 10; h /= 10, m++) ;
734
+ }
735
+ return s && g.e + 1 > m && (m = g.e + 1), m;
736
+ }, r.shiftedBy = function(s) {
737
+ return q(s, -9007199254740991, Ye), this.times("1e" + s);
738
+ }, r.squareRoot = r.sqrt = function() {
739
+ var s, o, l, m, h, g = this, w = g.c, u = g.s, p = g.e, x = a + 4, y = new S("0.5");
740
+ if (u !== 1 || !w || !w[0])
741
+ return new S(!u || u < 0 && (!w || w[0]) ? NaN : w ? g : 1 / 0);
742
+ if (u = Math.sqrt(+re(g)), u == 0 || u == 1 / 0 ? (o = J(w), (o.length + p) % 2 == 0 && (o += "0"), u = Math.sqrt(+o), p = Q((p + 1) / 2) - (p < 0 || p % 2), u == 1 / 0 ? o = "5e" + p : (o = u.toExponential(), o = o.slice(0, o.indexOf("e") + 1) + p), l = new S(o)) : l = new S(u + ""), l.c[0]) {
743
+ for (p = l.e, u = p + x, u < 3 && (u = 0); ; )
744
+ if (h = l, l = y.times(h.plus(t(g, h, x, 1))), J(h.c).slice(0, u) === (o = J(l.c)).slice(0, u))
745
+ if (l.e < p && --u, o = o.slice(u - 3, u + 1), o == "9999" || !m && o == "4999") {
746
+ if (!m && (Z(h, h.e + a + 2, 0), h.times(h).eq(g))) {
747
+ l = h;
748
+ break;
749
+ }
750
+ x += 4, u += 4, m = 1;
751
+ } else {
752
+ (!+o || !+o.slice(1) && o.charAt(0) == "5") && (Z(l, l.e + a + 2, 1), s = !l.times(l).eq(g));
753
+ break;
754
+ }
755
+ }
756
+ return Z(l, l.e + a + 1, c, s);
757
+ }, r.toExponential = function(s, o) {
758
+ return s != null && (q(s, 0, W), s++), F(this, s, o, 1);
759
+ }, r.toFixed = function(s, o) {
760
+ return s != null && (q(s, 0, W), s = s + this.e + 1), F(this, s, o);
761
+ }, r.toFormat = function(s, o, l) {
762
+ var m, h = this;
763
+ if (l == null)
764
+ s != null && o && typeof o == "object" ? (l = o, o = null) : s && typeof s == "object" ? (l = s, s = o = null) : l = L;
765
+ else if (typeof l != "object")
766
+ throw Error(X + "Argument not an object: " + l);
767
+ if (m = h.toFixed(s, o), h.c) {
768
+ var g, w = m.split("."), u = +l.groupSize, p = +l.secondaryGroupSize, x = l.groupSeparator || "", y = w[0], v = w[1], R = h.s < 0, O = R ? y.slice(1) : y, k = O.length;
769
+ if (p && (g = u, u = p, p = g, k -= g), u > 0 && k > 0) {
770
+ for (g = k % u || u, y = O.substr(0, g); g < k; g += u) y += x + O.substr(g, u);
771
+ p > 0 && (y += x + O.slice(g)), R && (y = "-" + y);
772
+ }
773
+ m = v ? y + (l.decimalSeparator || "") + ((p = +l.fractionGroupSize) ? v.replace(
774
+ new RegExp("\\d{" + p + "}\\B", "g"),
775
+ "$&" + (l.fractionGroupSeparator || "")
776
+ ) : v) : y;
777
+ }
778
+ return (l.prefix || "") + m + (l.suffix || "");
779
+ }, r.toFraction = function(s) {
780
+ var o, l, m, h, g, w, u, p, x, y, v, R, O = this, k = O.c;
781
+ if (s != null && (u = new S(s), !u.isInteger() && (u.c || u.s !== 1) || u.lt(f)))
782
+ throw Error(X + "Argument " + (u.isInteger() ? "out of range: " : "not an integer: ") + re(u));
783
+ if (!k) return new S(O);
784
+ for (o = new S(f), x = l = new S(f), m = p = new S(f), R = J(k), g = o.e = R.length - O.e - 1, o.c[0] = Oe[(w = g % C) < 0 ? C + w : w], s = !s || u.comparedTo(o) > 0 ? g > 0 ? o : x : u, w = b, b = 1 / 0, u = new S(R), p.c[0] = 0; y = t(u, o, 0, 1), h = l.plus(y.times(m)), h.comparedTo(s) != 1; )
785
+ l = m, m = h, x = p.plus(y.times(h = x)), p = h, o = u.minus(y.times(h = o)), u = h;
786
+ return h = t(s.minus(l), m, 0, 1), p = p.plus(h.times(x)), l = l.plus(h.times(m)), p.s = x.s = O.s, g = g * 2, v = t(x, m, g, c).minus(O).abs().comparedTo(
787
+ t(p, l, g, c).minus(O).abs()
788
+ ) < 1 ? [x, m] : [p, l], b = w, v;
789
+ }, r.toNumber = function() {
790
+ return +re(this);
791
+ }, r.toPrecision = function(s, o) {
792
+ return s != null && q(s, 1, W), F(this, s, o, 2);
793
+ }, r.toString = function(s) {
794
+ var o, l = this, m = l.s, h = l.e;
795
+ return h === null ? m ? (o = "Infinity", m < 0 && (o = "-" + o)) : o = "NaN" : (s == null ? o = h <= E || h >= d ? xe(J(l.c), h) : oe(J(l.c), h, "0") : s === 10 && V ? (l = Z(new S(l), a + h + 1, c), o = oe(J(l.c), l.e, "0")) : (q(s, 2, A.length, "Base"), o = e(oe(J(l.c), h, "0"), 10, s, m, !0)), m < 0 && l.c[0] && (o = "-" + o)), o;
796
+ }, r.valueOf = r.toJSON = function() {
797
+ return re(this);
798
+ }, r._isBigNumber = !0, r[Symbol.toStringTag] = "BigNumber", r[Symbol.for("nodejs.util.inspect.custom")] = r.valueOf, i != null && S.set(i), S;
594
799
  }
595
- function te(o, t, e) {
596
- for (var n = new $(null, null), r = n, i = o, u = t; i !== null && u !== null; )
597
- e(i.key, u.key) < 0 ? (r.next = i, i = i.next) : (r.next = u, u = u.next), r = r.next;
598
- return i !== null ? r.next = i : u !== null && (r.next = u), n.next;
800
+ function Q(i) {
801
+ var t = i | 0;
802
+ return i > 0 || i === t ? t : t - 1;
599
803
  }
600
- function rt(o, t, e, n, r) {
601
- if (!(e >= n)) {
602
- for (var i = o[e + n >> 1], u = e - 1, l = n + 1; ; ) {
603
- do
604
- u++;
605
- while (r(o[u], i) < 0);
606
- do
607
- l--;
608
- while (r(o[l], i) > 0);
609
- if (u >= l)
610
- break;
611
- var c = o[u];
612
- o[u] = o[l], o[l] = c, c = t[u], t[u] = t[l], t[l] = c;
613
- }
614
- rt(o, t, e, l, r), rt(o, t, l + 1, n, r);
804
+ function J(i) {
805
+ for (var t, e, n = 1, r = i.length, f = i[0] + ""; n < r; ) {
806
+ for (t = i[n++] + "", e = C - t.length; e--; t = "0" + t) ;
807
+ f += t;
615
808
  }
809
+ for (r = f.length; f.charCodeAt(--r) === 48; ) ;
810
+ return f.slice(0, r + 1 || 1);
616
811
  }
617
- const F = 11102230246251565e-32, _ = 134217729, ee = (3 + 8 * F) * F;
618
- function K(o, t, e, n, r) {
619
- let i, u, l, c, f = t[0], a = n[0], s = 0, h = 0;
620
- a > f == a > -f ? (i = f, f = t[++s]) : (i = a, a = n[++h]);
621
- let g = 0;
622
- if (s < o && h < e)
623
- for (a > f == a > -f ? (u = f + i, l = i - (u - f), f = t[++s]) : (u = a + i, l = i - (u - a), a = n[++h]), i = u, l !== 0 && (r[g++] = l); s < o && h < e; )
624
- a > f == a > -f ? (u = i + f, c = u - i, l = i - (u - c) + (f - c), f = t[++s]) : (u = i + a, c = u - i, l = i - (u - c) + (a - c), a = n[++h]), i = u, l !== 0 && (r[g++] = l);
625
- for (; s < o; )
626
- u = i + f, c = u - i, l = i - (u - c) + (f - c), f = t[++s], i = u, l !== 0 && (r[g++] = l);
627
- for (; h < e; )
628
- u = i + a, c = u - i, l = i - (u - c) + (a - c), a = n[++h], i = u, l !== 0 && (r[g++] = l);
629
- return (i !== 0 || g === 0) && (r[g++] = i), g;
812
+ function fe(i, t) {
813
+ var e, n, r = i.c, f = t.c, a = i.s, c = t.s, E = i.e, d = t.e;
814
+ if (!a || !c) return null;
815
+ if (e = r && !r[0], n = f && !f[0], e || n) return e ? n ? 0 : -c : a;
816
+ if (a != c) return a;
817
+ if (e = a < 0, n = E == d, !r || !f) return n ? 0 : !r ^ e ? 1 : -1;
818
+ if (!n) return E > d ^ e ? 1 : -1;
819
+ for (c = (E = r.length) < (d = f.length) ? E : d, a = 0; a < c; a++) if (r[a] != f[a]) return r[a] > f[a] ^ e ? 1 : -1;
820
+ return E == d ? 0 : E > d ^ e ? 1 : -1;
630
821
  }
631
- function ne(o, t) {
632
- let e = t[0];
633
- for (let n = 1; n < o; n++) e += t[n];
634
- return e;
822
+ function q(i, t, e, n) {
823
+ if (i < t || i > e || i !== j(i))
824
+ throw Error(X + (n || "Argument") + (typeof i == "number" ? i < t || i > e ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(i));
635
825
  }
636
- function Y(o) {
637
- return new Float64Array(o);
826
+ function de(i) {
827
+ var t = i.c.length - 1;
828
+ return Q(i.e / C) == t && i.c[t] % 2 != 0;
638
829
  }
639
- const re = (3 + 16 * F) * F, ie = (2 + 12 * F) * F, oe = (9 + 64 * F) * F * F, T = Y(4), dt = Y(8), vt = Y(12), mt = Y(16), P = Y(4);
640
- function se(o, t, e, n, r, i, u) {
641
- let l, c, f, a, s, h, g, y, p, d, x, v, w, m, E, b, M, S;
642
- const L = o - r, I = e - r, k = t - i, C = n - i;
643
- m = L * C, h = _ * L, g = h - (h - L), y = L - g, h = _ * C, p = h - (h - C), d = C - p, E = y * d - (m - g * p - y * p - g * d), b = k * I, h = _ * k, g = h - (h - k), y = k - g, h = _ * I, p = h - (h - I), d = I - p, M = y * d - (b - g * p - y * p - g * d), x = E - M, s = E - x, T[0] = E - (x + s) + (s - M), v = m + x, s = v - m, w = m - (v - s) + (x - s), x = w - b, s = w - x, T[1] = w - (x + s) + (s - b), S = v + x, s = S - v, T[2] = v - (S - s) + (x - s), T[3] = S;
644
- let O = ne(4, T), q = ie * u;
645
- if (O >= q || -O >= q || (s = o - L, l = o - (L + s) + (s - r), s = e - I, f = e - (I + s) + (s - r), s = t - k, c = t - (k + s) + (s - i), s = n - C, a = n - (C + s) + (s - i), l === 0 && c === 0 && f === 0 && a === 0) || (q = oe * u + ee * Math.abs(O), O += L * a + C * l - (k * f + I * c), O >= q || -O >= q)) return O;
646
- m = l * C, h = _ * l, g = h - (h - l), y = l - g, h = _ * C, p = h - (h - C), d = C - p, E = y * d - (m - g * p - y * p - g * d), b = c * I, h = _ * c, g = h - (h - c), y = c - g, h = _ * I, p = h - (h - I), d = I - p, M = y * d - (b - g * p - y * p - g * d), x = E - M, s = E - x, P[0] = E - (x + s) + (s - M), v = m + x, s = v - m, w = m - (v - s) + (x - s), x = w - b, s = w - x, P[1] = w - (x + s) + (s - b), S = v + x, s = S - v, P[2] = v - (S - s) + (x - s), P[3] = S;
647
- const Gt = K(4, T, 4, P, dt);
648
- m = L * a, h = _ * L, g = h - (h - L), y = L - g, h = _ * a, p = h - (h - a), d = a - p, E = y * d - (m - g * p - y * p - g * d), b = k * f, h = _ * k, g = h - (h - k), y = k - g, h = _ * f, p = h - (h - f), d = f - p, M = y * d - (b - g * p - y * p - g * d), x = E - M, s = E - x, P[0] = E - (x + s) + (s - M), v = m + x, s = v - m, w = m - (v - s) + (x - s), x = w - b, s = w - x, P[1] = w - (x + s) + (s - b), S = v + x, s = S - v, P[2] = v - (S - s) + (x - s), P[3] = S;
649
- const Bt = K(Gt, dt, 4, P, vt);
650
- m = l * a, h = _ * l, g = h - (h - l), y = l - g, h = _ * a, p = h - (h - a), d = a - p, E = y * d - (m - g * p - y * p - g * d), b = c * f, h = _ * c, g = h - (h - c), y = c - g, h = _ * f, p = h - (h - f), d = f - p, M = y * d - (b - g * p - y * p - g * d), x = E - M, s = E - x, P[0] = E - (x + s) + (s - M), v = m + x, s = v - m, w = m - (v - s) + (x - s), x = w - b, s = w - x, P[1] = w - (x + s) + (s - b), S = v + x, s = S - v, P[2] = v - (S - s) + (x - s), P[3] = S;
651
- const zt = K(Bt, vt, 4, P, mt);
652
- return mt[zt - 1];
830
+ function xe(i, t) {
831
+ return (i.length > 1 ? i.charAt(0) + "." + i.slice(1) : i) + (t < 0 ? "e" : "e+") + t;
653
832
  }
654
- function le(o, t, e, n, r, i) {
655
- const u = (t - i) * (e - r), l = (o - r) * (n - i), c = u - l, f = Math.abs(u + l);
656
- return Math.abs(c) >= re * f ? c : -se(o, t, e, n, r, i, f);
833
+ function oe(i, t, e) {
834
+ var n, r;
835
+ if (t < 0) {
836
+ for (r = e + "."; ++t; r += e) ;
837
+ i = r + i;
838
+ } else if (n = i.length, ++t > n) {
839
+ for (r = e, t -= n; --t; r += e) ;
840
+ i += r;
841
+ } else t < n && (i = i.slice(0, t) + "." + i.slice(t));
842
+ return i;
657
843
  }
658
- const Q = (o, t) => o.ll.x <= t.x && t.x <= o.ur.x && o.ll.y <= t.y && t.y <= o.ur.y, it = (o, t) => {
659
- if (t.ur.x < o.ll.x || o.ur.x < t.ll.x || t.ur.y < o.ll.y || o.ur.y < t.ll.y) return null;
660
- const e = o.ll.x < t.ll.x ? t.ll.x : o.ll.x, n = o.ur.x < t.ur.x ? o.ur.x : t.ur.x, r = o.ll.y < t.ll.y ? t.ll.y : o.ll.y, i = o.ur.y < t.ur.y ? o.ur.y : t.ur.y;
661
- return {
662
- ll: {
663
- x: e,
664
- y: r
665
- },
666
- ur: {
667
- x: n,
668
- y: i
669
- }
670
- };
671
- };
672
- let B = Number.EPSILON;
673
- B === void 0 && (B = Math.pow(2, -52));
674
- const ue = B * B, wt = (o, t) => {
675
- if (-B < o && o < B && -B < t && t < B)
676
- return 0;
677
- const e = o - t;
678
- return e * e < ue * o * t ? 0 : o < t ? -1 : 1;
679
- };
680
- class fe {
844
+ var ne = ot(), Tt = class {
845
+ constructor(i) {
846
+ M(this, "key");
847
+ M(this, "left", null);
848
+ M(this, "right", null);
849
+ this.key = i;
850
+ }
851
+ }, ce = class extends Tt {
852
+ constructor(i) {
853
+ super(i);
854
+ }
855
+ }, Pt = class {
681
856
  constructor() {
682
- this.reset();
857
+ M(this, "size", 0);
858
+ M(this, "modificationCount", 0);
859
+ M(this, "splayCount", 0);
683
860
  }
684
- reset() {
685
- this.xRounder = new Et(), this.yRounder = new Et();
861
+ splay(i) {
862
+ const t = this.root;
863
+ if (t == null)
864
+ return this.compare(i, i), -1;
865
+ let e = null, n = null, r = null, f = null, a = t;
866
+ const c = this.compare;
867
+ let E;
868
+ for (; ; )
869
+ if (E = c(a.key, i), E > 0) {
870
+ let d = a.left;
871
+ if (d == null || (E = c(d.key, i), E > 0 && (a.left = d.right, d.right = a, a = d, d = a.left, d == null)))
872
+ break;
873
+ e == null ? n = a : e.left = a, e = a, a = d;
874
+ } else if (E < 0) {
875
+ let d = a.right;
876
+ if (d == null || (E = c(d.key, i), E < 0 && (a.right = d.left, d.left = a, a = d, d = a.right, d == null)))
877
+ break;
878
+ r == null ? f = a : r.right = a, r = a, a = d;
879
+ } else
880
+ break;
881
+ return r != null && (r.right = a.left, a.left = f), e != null && (e.left = a.right, a.right = n), this.root !== a && (this.root = a, this.splayCount++), E;
882
+ }
883
+ splayMin(i) {
884
+ let t = i, e = t.left;
885
+ for (; e != null; ) {
886
+ const n = e;
887
+ t.left = n.right, n.right = t, t = n, e = t.left;
888
+ }
889
+ return t;
890
+ }
891
+ splayMax(i) {
892
+ let t = i, e = t.right;
893
+ for (; e != null; ) {
894
+ const n = e;
895
+ t.right = n.left, n.left = t, t = n, e = t.right;
896
+ }
897
+ return t;
898
+ }
899
+ _delete(i) {
900
+ if (this.root == null || this.splay(i) != 0) return null;
901
+ let e = this.root;
902
+ const n = e, r = e.left;
903
+ if (this.size--, r == null)
904
+ this.root = e.right;
905
+ else {
906
+ const f = e.right;
907
+ e = this.splayMax(r), e.right = f, this.root = e;
908
+ }
909
+ return this.modificationCount++, n;
910
+ }
911
+ addNewRoot(i, t) {
912
+ this.size++, this.modificationCount++;
913
+ const e = this.root;
914
+ if (e == null) {
915
+ this.root = i;
916
+ return;
917
+ }
918
+ t < 0 ? (i.left = e, i.right = e.right, e.right = null) : (i.right = e, i.left = e.left, e.left = null), this.root = i;
919
+ }
920
+ _first() {
921
+ const i = this.root;
922
+ return i == null ? null : (this.root = this.splayMin(i), this.root);
686
923
  }
687
- round(t, e) {
924
+ _last() {
925
+ const i = this.root;
926
+ return i == null ? null : (this.root = this.splayMax(i), this.root);
927
+ }
928
+ clear() {
929
+ this.root = null, this.size = 0, this.modificationCount++;
930
+ }
931
+ has(i) {
932
+ return this.validKey(i) && this.splay(i) == 0;
933
+ }
934
+ defaultCompare() {
935
+ return (i, t) => i < t ? -1 : i > t ? 1 : 0;
936
+ }
937
+ wrap() {
688
938
  return {
689
- x: this.xRounder.round(t),
690
- y: this.yRounder.round(e)
939
+ getRoot: () => this.root,
940
+ setRoot: (i) => {
941
+ this.root = i;
942
+ },
943
+ getSize: () => this.size,
944
+ getModificationCount: () => this.modificationCount,
945
+ getSplayCount: () => this.splayCount,
946
+ setSplayCount: (i) => {
947
+ this.splayCount = i;
948
+ },
949
+ splay: (i) => this.splay(i),
950
+ has: (i) => this.has(i)
691
951
  };
692
952
  }
693
- }
694
- class Et {
695
- constructor() {
696
- this.tree = new lt(), this.round(0);
697
- }
698
- // Note: this can rounds input values backwards or forwards.
699
- // You might ask, why not restrict this to just rounding
700
- // forwards? Wouldn't that allow left endpoints to always
701
- // remain left endpoints during splitting (never change to
702
- // right). No - it wouldn't, because we snap intersections
703
- // to endpoints (to establish independence from the segment
704
- // angle for t-intersections).
705
- round(t) {
706
- const e = this.tree.add(t), n = this.tree.prev(e);
707
- if (n !== null && wt(e.key, n.key) === 0)
708
- return this.tree.remove(t), n.key;
709
- const r = this.tree.next(e);
710
- return r !== null && wt(e.key, r.key) === 0 ? (this.tree.remove(t), r.key) : t;
953
+ }, it, nt, ve = class pe extends Pt {
954
+ constructor(e, n) {
955
+ super();
956
+ M(this, "root", null);
957
+ M(this, "compare");
958
+ M(this, "validKey");
959
+ M(this, it, "[object Set]");
960
+ this.compare = e ?? this.defaultCompare(), this.validKey = n ?? ((r) => r != null && r != null);
711
961
  }
712
- }
713
- const U = new fe(), j = (o, t) => o.x * t.y - o.y * t.x, Nt = (o, t) => o.x * t.x + o.y * t.y, bt = (o, t, e) => {
714
- const n = le(o.x, o.y, t.x, t.y, e.x, e.y);
715
- return n > 0 ? -1 : n < 0 ? 1 : 0;
716
- }, X = (o) => Math.sqrt(Nt(o, o)), ce = (o, t, e) => {
717
- const n = {
718
- x: t.x - o.x,
719
- y: t.y - o.y
720
- }, r = {
721
- x: e.x - o.x,
722
- y: e.y - o.y
723
- };
724
- return j(r, n) / X(r) / X(n);
725
- }, he = (o, t, e) => {
726
- const n = {
727
- x: t.x - o.x,
728
- y: t.y - o.y
729
- }, r = {
730
- x: e.x - o.x,
731
- y: e.y - o.y
732
- };
733
- return Nt(r, n) / X(r) / X(n);
734
- }, St = (o, t, e) => t.y === 0 ? null : {
735
- x: o.x + t.x / t.y * (e - o.y),
736
- y: e
737
- }, _t = (o, t, e) => t.x === 0 ? null : {
738
- x: e,
739
- y: o.y + t.y / t.x * (e - o.x)
740
- }, ae = (o, t, e, n) => {
741
- if (t.x === 0) return _t(e, n, o.x);
742
- if (n.x === 0) return _t(o, t, e.x);
743
- if (t.y === 0) return St(e, n, o.y);
744
- if (n.y === 0) return St(o, t, e.y);
745
- const r = j(t, n);
746
- if (r == 0) return null;
747
- const i = {
748
- x: e.x - o.x,
749
- y: e.y - o.y
750
- }, u = j(i, t) / r, l = j(i, n) / r, c = o.x + l * t.x, f = e.x + u * n.x, a = o.y + l * t.y, s = e.y + u * n.y, h = (c + f) / 2, g = (a + s) / 2;
751
- return {
752
- x: h,
753
- y: g
754
- };
962
+ delete(e) {
963
+ return this.validKey(e) ? this._delete(e) != null : !1;
964
+ }
965
+ deleteAll(e) {
966
+ for (const n of e)
967
+ this.delete(n);
968
+ }
969
+ forEach(e) {
970
+ const n = this[Symbol.iterator]();
971
+ let r;
972
+ for (; r = n.next(), !r.done; )
973
+ e(r.value, r.value, this);
974
+ }
975
+ add(e) {
976
+ const n = this.splay(e);
977
+ return n != 0 && this.addNewRoot(new ce(e), n), this;
978
+ }
979
+ addAndReturn(e) {
980
+ const n = this.splay(e);
981
+ return n != 0 && this.addNewRoot(new ce(e), n), this.root.key;
982
+ }
983
+ addAll(e) {
984
+ for (const n of e)
985
+ this.add(n);
986
+ }
987
+ isEmpty() {
988
+ return this.root == null;
989
+ }
990
+ isNotEmpty() {
991
+ return this.root != null;
992
+ }
993
+ single() {
994
+ if (this.size == 0) throw "Bad state: No element";
995
+ if (this.size > 1) throw "Bad state: Too many element";
996
+ return this.root.key;
997
+ }
998
+ first() {
999
+ if (this.size == 0) throw "Bad state: No element";
1000
+ return this._first().key;
1001
+ }
1002
+ last() {
1003
+ if (this.size == 0) throw "Bad state: No element";
1004
+ return this._last().key;
1005
+ }
1006
+ lastBefore(e) {
1007
+ if (e == null) throw "Invalid arguments(s)";
1008
+ if (this.root == null) return null;
1009
+ if (this.splay(e) < 0) return this.root.key;
1010
+ let r = this.root.left;
1011
+ if (r == null) return null;
1012
+ let f = r.right;
1013
+ for (; f != null; )
1014
+ r = f, f = r.right;
1015
+ return r.key;
1016
+ }
1017
+ firstAfter(e) {
1018
+ if (e == null) throw "Invalid arguments(s)";
1019
+ if (this.root == null) return null;
1020
+ if (this.splay(e) > 0) return this.root.key;
1021
+ let r = this.root.right;
1022
+ if (r == null) return null;
1023
+ let f = r.left;
1024
+ for (; f != null; )
1025
+ r = f, f = r.left;
1026
+ return r.key;
1027
+ }
1028
+ retainAll(e) {
1029
+ const n = new pe(this.compare, this.validKey), r = this.modificationCount;
1030
+ for (const f of e) {
1031
+ if (r != this.modificationCount)
1032
+ throw "Concurrent modification during iteration.";
1033
+ this.validKey(f) && this.splay(f) == 0 && n.add(this.root.key);
1034
+ }
1035
+ n.size != this.size && (this.root = n.root, this.size = n.size, this.modificationCount++);
1036
+ }
1037
+ lookup(e) {
1038
+ return !this.validKey(e) || this.splay(e) != 0 ? null : this.root.key;
1039
+ }
1040
+ intersection(e) {
1041
+ const n = new pe(this.compare, this.validKey);
1042
+ for (const r of this)
1043
+ e.has(r) && n.add(r);
1044
+ return n;
1045
+ }
1046
+ difference(e) {
1047
+ const n = new pe(this.compare, this.validKey);
1048
+ for (const r of this)
1049
+ e.has(r) || n.add(r);
1050
+ return n;
1051
+ }
1052
+ union(e) {
1053
+ const n = this.clone();
1054
+ return n.addAll(e), n;
1055
+ }
1056
+ clone() {
1057
+ const e = new pe(this.compare, this.validKey);
1058
+ return e.size = this.size, e.root = this.copyNode(this.root), e;
1059
+ }
1060
+ copyNode(e) {
1061
+ if (e == null) return null;
1062
+ function n(f, a) {
1063
+ let c, E;
1064
+ do {
1065
+ if (c = f.left, E = f.right, c != null) {
1066
+ const d = new ce(c.key);
1067
+ a.left = d, n(c, d);
1068
+ }
1069
+ if (E != null) {
1070
+ const d = new ce(E.key);
1071
+ a.right = d, f = E, a = d;
1072
+ }
1073
+ } while (E != null);
1074
+ }
1075
+ const r = new ce(e.key);
1076
+ return n(e, r), r;
1077
+ }
1078
+ toSet() {
1079
+ return this.clone();
1080
+ }
1081
+ entries() {
1082
+ return new Mt(this.wrap());
1083
+ }
1084
+ keys() {
1085
+ return this[Symbol.iterator]();
1086
+ }
1087
+ values() {
1088
+ return this[Symbol.iterator]();
1089
+ }
1090
+ [(nt = Symbol.iterator, it = Symbol.toStringTag, nt)]() {
1091
+ return new Lt(this.wrap());
1092
+ }
1093
+ }, lt = class {
1094
+ constructor(i) {
1095
+ M(this, "tree");
1096
+ M(this, "path", new Array());
1097
+ M(this, "modificationCount", null);
1098
+ M(this, "splayCount");
1099
+ this.tree = i, this.splayCount = i.getSplayCount();
1100
+ }
1101
+ [Symbol.iterator]() {
1102
+ return this;
1103
+ }
1104
+ next() {
1105
+ return this.moveNext() ? { done: !1, value: this.current() } : { done: !0, value: null };
1106
+ }
1107
+ current() {
1108
+ if (!this.path.length) return null;
1109
+ const i = this.path[this.path.length - 1];
1110
+ return this.getValue(i);
1111
+ }
1112
+ rebuildPath(i) {
1113
+ this.path.splice(0, this.path.length), this.tree.splay(i), this.path.push(this.tree.getRoot()), this.splayCount = this.tree.getSplayCount();
1114
+ }
1115
+ findLeftMostDescendent(i) {
1116
+ for (; i != null; )
1117
+ this.path.push(i), i = i.left;
1118
+ }
1119
+ moveNext() {
1120
+ if (this.modificationCount != this.tree.getModificationCount()) {
1121
+ if (this.modificationCount == null) {
1122
+ this.modificationCount = this.tree.getModificationCount();
1123
+ let e = this.tree.getRoot();
1124
+ for (; e != null; )
1125
+ this.path.push(e), e = e.left;
1126
+ return this.path.length > 0;
1127
+ }
1128
+ throw "Concurrent modification during iteration.";
1129
+ }
1130
+ if (!this.path.length) return !1;
1131
+ this.splayCount != this.tree.getSplayCount() && this.rebuildPath(this.path[this.path.length - 1].key);
1132
+ let i = this.path[this.path.length - 1], t = i.right;
1133
+ if (t != null) {
1134
+ for (; t != null; )
1135
+ this.path.push(t), t = t.left;
1136
+ return !0;
1137
+ }
1138
+ for (this.path.pop(); this.path.length && this.path[this.path.length - 1].right === i; )
1139
+ i = this.path.pop();
1140
+ return this.path.length > 0;
1141
+ }
1142
+ }, Lt = class extends lt {
1143
+ getValue(i) {
1144
+ return i.key;
1145
+ }
1146
+ }, Mt = class extends lt {
1147
+ getValue(i) {
1148
+ return [i.key, i.key];
1149
+ }
1150
+ }, ut = (i) => () => i, Ne = (i) => {
1151
+ const t = i ? (e, n) => n.minus(e).abs().isLessThanOrEqualTo(i) : ut(!1);
1152
+ return (e, n) => t(e, n) ? 0 : e.comparedTo(n);
755
1153
  };
756
- class R {
1154
+ function Rt(i) {
1155
+ const t = i ? (e, n, r, f, a) => e.exponentiatedBy(2).isLessThanOrEqualTo(
1156
+ f.minus(n).exponentiatedBy(2).plus(a.minus(r).exponentiatedBy(2)).times(i)
1157
+ ) : ut(!1);
1158
+ return (e, n, r) => {
1159
+ const f = e.x, a = e.y, c = r.x, E = r.y, d = a.minus(E).times(n.x.minus(c)).minus(f.minus(c).times(n.y.minus(E)));
1160
+ return t(d, f, a, c, E) ? 0 : d.comparedTo(0);
1161
+ };
1162
+ }
1163
+ var _t = (i) => i, Ot = (i) => {
1164
+ if (i) {
1165
+ const t = new ve(Ne(i)), e = new ve(Ne(i)), n = (f, a) => a.addAndReturn(f), r = (f) => ({
1166
+ x: n(f.x, t),
1167
+ y: n(f.y, e)
1168
+ });
1169
+ return r({ x: new ne(0), y: new ne(0) }), r;
1170
+ }
1171
+ return _t;
1172
+ }, Ae = (i) => ({
1173
+ set: (t) => {
1174
+ le = Ae(t);
1175
+ },
1176
+ reset: () => Ae(i),
1177
+ compare: Ne(i),
1178
+ snap: Ot(i),
1179
+ orient: Rt(i)
1180
+ }), le = Ae(), ae = (i, t) => i.ll.x.isLessThanOrEqualTo(t.x) && t.x.isLessThanOrEqualTo(i.ur.x) && i.ll.y.isLessThanOrEqualTo(t.y) && t.y.isLessThanOrEqualTo(i.ur.y), Ie = (i, t) => {
1181
+ if (t.ur.x.isLessThan(i.ll.x) || i.ur.x.isLessThan(t.ll.x) || t.ur.y.isLessThan(i.ll.y) || i.ur.y.isLessThan(t.ll.y))
1182
+ return null;
1183
+ const e = i.ll.x.isLessThan(t.ll.x) ? t.ll.x : i.ll.x, n = i.ur.x.isLessThan(t.ur.x) ? i.ur.x : t.ur.x, r = i.ll.y.isLessThan(t.ll.y) ? t.ll.y : i.ll.y, f = i.ur.y.isLessThan(t.ur.y) ? i.ur.y : t.ur.y;
1184
+ return { ll: { x: e, y: r }, ur: { x: n, y: f } };
1185
+ }, we = (i, t) => i.x.times(t.y).minus(i.y.times(t.x)), ft = (i, t) => i.x.times(t.x).plus(i.y.times(t.y)), be = (i) => ft(i, i).sqrt(), Ct = (i, t, e) => {
1186
+ const n = { x: t.x.minus(i.x), y: t.y.minus(i.y) }, r = { x: e.x.minus(i.x), y: e.y.minus(i.y) };
1187
+ return we(r, n).div(be(r)).div(be(n));
1188
+ }, Nt = (i, t, e) => {
1189
+ const n = { x: t.x.minus(i.x), y: t.y.minus(i.y) }, r = { x: e.x.minus(i.x), y: e.y.minus(i.y) };
1190
+ return ft(r, n).div(be(r)).div(be(n));
1191
+ }, We = (i, t, e) => t.y.isZero() ? null : { x: i.x.plus(t.x.div(t.y).times(e.minus(i.y))), y: e }, Ze = (i, t, e) => t.x.isZero() ? null : { x: e, y: i.y.plus(t.y.div(t.x).times(e.minus(i.x))) }, At = (i, t, e, n) => {
1192
+ if (t.x.isZero()) return Ze(e, n, i.x);
1193
+ if (n.x.isZero()) return Ze(i, t, e.x);
1194
+ if (t.y.isZero()) return We(e, n, i.y);
1195
+ if (n.y.isZero()) return We(i, t, e.y);
1196
+ const r = we(t, n);
1197
+ if (r.isZero()) return null;
1198
+ const f = { x: e.x.minus(i.x), y: e.y.minus(i.y) }, a = we(f, t).div(r), c = we(f, n).div(r), E = i.x.plus(c.times(t.x)), d = e.x.plus(a.times(n.x)), T = i.y.plus(c.times(t.y)), b = e.y.plus(a.times(n.y)), P = E.plus(d).div(2), N = T.plus(b).div(2);
1199
+ return { x: P, y: N };
1200
+ }, ie = class ht {
1201
+ // Warning: 'point' input will be modified and re-used (for performance)
1202
+ constructor(t, e) {
1203
+ M(this, "point");
1204
+ M(this, "isLeft");
1205
+ M(this, "segment");
1206
+ M(this, "otherSE");
1207
+ M(this, "consumedBy");
1208
+ t.events === void 0 ? t.events = [this] : t.events.push(this), this.point = t, this.isLeft = e;
1209
+ }
757
1210
  // for ordering sweep events in the sweep event queue
758
1211
  static compare(t, e) {
759
- const n = R.comparePoints(t.point, e.point);
760
- return n !== 0 ? n : (t.point !== e.point && t.link(e), t.isLeft !== e.isLeft ? t.isLeft ? 1 : -1 : z.compare(t.segment, e.segment));
1212
+ const n = ht.comparePoints(t.point, e.point);
1213
+ return n !== 0 ? n : (t.point !== e.point && t.link(e), t.isLeft !== e.isLeft ? t.isLeft ? 1 : -1 : Pe.compare(t.segment, e.segment));
761
1214
  }
762
1215
  // for ordering points in sweep line order
763
1216
  static comparePoints(t, e) {
764
- return t.x < e.x ? -1 : t.x > e.x ? 1 : t.y < e.y ? -1 : t.y > e.y ? 1 : 0;
765
- }
766
- // Warning: 'point' input will be modified and re-used (for performance)
767
- constructor(t, e) {
768
- t.events === void 0 ? t.events = [this] : t.events.push(this), this.point = t, this.isLeft = e;
1217
+ return t.x.isLessThan(e.x) ? -1 : t.x.isGreaterThan(e.x) ? 1 : t.y.isLessThan(e.y) ? -1 : t.y.isGreaterThan(e.y) ? 1 : 0;
769
1218
  }
770
1219
  link(t) {
771
1220
  if (t.point === this.point)
772
1221
  throw new Error("Tried to link already linked events");
773
1222
  const e = t.point.events;
774
1223
  for (let n = 0, r = e.length; n < r; n++) {
775
- const i = e[n];
776
- this.point.events.push(i), i.point = this.point;
1224
+ const f = e[n];
1225
+ this.point.events.push(f), f.point = this.point;
777
1226
  }
778
1227
  this.checkForConsuming();
779
1228
  }
@@ -785,8 +1234,8 @@ class R {
785
1234
  const n = this.point.events[e];
786
1235
  if (n.segment.consumedBy === void 0)
787
1236
  for (let r = e + 1; r < t; r++) {
788
- const i = this.point.events[r];
789
- i.consumedBy === void 0 && n.otherSE.point.events === i.otherSE.point.events && n.segment.consume(i.segment);
1237
+ const f = this.point.events[r];
1238
+ f.consumedBy === void 0 && n.otherSE.point.events === f.otherSE.point.events && n.segment.consume(f.segment);
790
1239
  }
791
1240
  }
792
1241
  }
@@ -810,27 +1259,301 @@ class R {
810
1259
  */
811
1260
  getLeftmostComparator(t) {
812
1261
  const e = /* @__PURE__ */ new Map(), n = (r) => {
813
- const i = r.otherSE;
1262
+ const f = r.otherSE;
814
1263
  e.set(r, {
815
- sine: ce(this.point, t.point, i.point),
816
- cosine: he(this.point, t.point, i.point)
1264
+ sine: Ct(this.point, t.point, f.point),
1265
+ cosine: Nt(this.point, t.point, f.point)
817
1266
  });
818
1267
  };
819
- return (r, i) => {
820
- e.has(r) || n(r), e.has(i) || n(i);
821
- const {
822
- sine: u,
823
- cosine: l
824
- } = e.get(r), {
825
- sine: c,
826
- cosine: f
827
- } = e.get(i);
828
- return u >= 0 && c >= 0 ? l < f ? 1 : l > f ? -1 : 0 : u < 0 && c < 0 ? l < f ? -1 : l > f ? 1 : 0 : c < u ? -1 : c > u ? 1 : 0;
1268
+ return (r, f) => {
1269
+ e.has(r) || n(r), e.has(f) || n(f);
1270
+ const { sine: a, cosine: c } = e.get(r), { sine: E, cosine: d } = e.get(f);
1271
+ return a.isGreaterThanOrEqualTo(0) && E.isGreaterThanOrEqualTo(0) ? c.isLessThan(d) ? 1 : c.isGreaterThan(d) ? -1 : 0 : a.isLessThan(0) && E.isLessThan(0) ? c.isLessThan(d) ? -1 : c.isGreaterThan(d) ? 1 : 0 : E.isLessThan(a) ? -1 : E.isGreaterThan(a) ? 1 : 0;
829
1272
  };
830
1273
  }
831
- }
832
- let ge = 0;
833
- class z {
1274
+ }, It = class ke {
1275
+ constructor(t) {
1276
+ M(this, "events");
1277
+ M(this, "poly");
1278
+ M(this, "_isExteriorRing");
1279
+ M(this, "_enclosingRing");
1280
+ this.events = t;
1281
+ for (let e = 0, n = t.length; e < n; e++)
1282
+ t[e].segment.ringOut = this;
1283
+ this.poly = null;
1284
+ }
1285
+ /* Given the segments from the sweep line pass, compute & return a series
1286
+ * of closed rings from all the segments marked to be part of the result */
1287
+ static factory(t) {
1288
+ const e = [];
1289
+ for (let n = 0, r = t.length; n < r; n++) {
1290
+ const f = t[n];
1291
+ if (!f.isInResult() || f.ringOut) continue;
1292
+ let a = null, c = f.leftSE, E = f.rightSE;
1293
+ const d = [c], T = c.point, b = [];
1294
+ for (; a = c, c = E, d.push(c), c.point !== T; )
1295
+ for (; ; ) {
1296
+ const P = c.getAvailableLinkedEvents();
1297
+ if (P.length === 0) {
1298
+ const L = d[0].point, A = d[d.length - 1].point;
1299
+ throw new Error(
1300
+ `Unable to complete output ring starting at [${L.x}, ${L.y}]. Last matching segment found ends at [${A.x}, ${A.y}].`
1301
+ );
1302
+ }
1303
+ if (P.length === 1) {
1304
+ E = P[0].otherSE;
1305
+ break;
1306
+ }
1307
+ let N = null;
1308
+ for (let L = 0, A = b.length; L < A; L++)
1309
+ if (b[L].point === c.point) {
1310
+ N = L;
1311
+ break;
1312
+ }
1313
+ if (N !== null) {
1314
+ const L = b.splice(N)[0], A = d.splice(L.index);
1315
+ A.unshift(A[0].otherSE), e.push(new ke(A.reverse()));
1316
+ continue;
1317
+ }
1318
+ b.push({
1319
+ index: d.length,
1320
+ point: c.point
1321
+ });
1322
+ const _ = c.getLeftmostComparator(a);
1323
+ E = P.sort(_)[0].otherSE;
1324
+ break;
1325
+ }
1326
+ e.push(new ke(d));
1327
+ }
1328
+ return e;
1329
+ }
1330
+ getGeom() {
1331
+ let t = this.events[0].point;
1332
+ const e = [t];
1333
+ for (let d = 1, T = this.events.length - 1; d < T; d++) {
1334
+ const b = this.events[d].point, P = this.events[d + 1].point;
1335
+ le.orient(b, t, P) !== 0 && (e.push(b), t = b);
1336
+ }
1337
+ if (e.length === 1) return null;
1338
+ const n = e[0], r = e[1];
1339
+ le.orient(n, t, r) === 0 && e.shift(), e.push(e[0]);
1340
+ const f = this.isExteriorRing() ? 1 : -1, a = this.isExteriorRing() ? 0 : e.length - 1, c = this.isExteriorRing() ? e.length : -1, E = [];
1341
+ for (let d = a; d != c; d += f)
1342
+ E.push([e[d].x.toNumber(), e[d].y.toNumber()]);
1343
+ return E;
1344
+ }
1345
+ isExteriorRing() {
1346
+ if (this._isExteriorRing === void 0) {
1347
+ const t = this.enclosingRing();
1348
+ this._isExteriorRing = t ? !t.isExteriorRing() : !0;
1349
+ }
1350
+ return this._isExteriorRing;
1351
+ }
1352
+ enclosingRing() {
1353
+ return this._enclosingRing === void 0 && (this._enclosingRing = this._calcEnclosingRing()), this._enclosingRing;
1354
+ }
1355
+ /* Returns the ring that encloses this one, if any */
1356
+ _calcEnclosingRing() {
1357
+ var r, f;
1358
+ let t = this.events[0];
1359
+ for (let a = 1, c = this.events.length; a < c; a++) {
1360
+ const E = this.events[a];
1361
+ ie.compare(t, E) > 0 && (t = E);
1362
+ }
1363
+ let e = t.segment.prevInResult(), n = e ? e.prevInResult() : null;
1364
+ for (; ; ) {
1365
+ if (!e) return null;
1366
+ if (!n) return e.ringOut;
1367
+ if (n.ringOut !== e.ringOut)
1368
+ return ((r = n.ringOut) == null ? void 0 : r.enclosingRing()) !== e.ringOut ? e.ringOut : (f = e.ringOut) == null ? void 0 : f.enclosingRing();
1369
+ e = n.prevInResult(), n = e ? e.prevInResult() : null;
1370
+ }
1371
+ }
1372
+ }, He = class {
1373
+ constructor(i) {
1374
+ M(this, "exteriorRing");
1375
+ M(this, "interiorRings");
1376
+ this.exteriorRing = i, i.poly = this, this.interiorRings = [];
1377
+ }
1378
+ addInterior(i) {
1379
+ this.interiorRings.push(i), i.poly = this;
1380
+ }
1381
+ getGeom() {
1382
+ const i = this.exteriorRing.getGeom();
1383
+ if (i === null) return null;
1384
+ const t = [i];
1385
+ for (let e = 0, n = this.interiorRings.length; e < n; e++) {
1386
+ const r = this.interiorRings[e].getGeom();
1387
+ r !== null && t.push(r);
1388
+ }
1389
+ return t;
1390
+ }
1391
+ }, kt = class {
1392
+ constructor(i) {
1393
+ M(this, "rings");
1394
+ M(this, "polys");
1395
+ this.rings = i, this.polys = this._composePolys(i);
1396
+ }
1397
+ getGeom() {
1398
+ const i = [];
1399
+ for (let t = 0, e = this.polys.length; t < e; t++) {
1400
+ const n = this.polys[t].getGeom();
1401
+ n !== null && i.push(n);
1402
+ }
1403
+ return i;
1404
+ }
1405
+ _composePolys(i) {
1406
+ var e;
1407
+ const t = [];
1408
+ for (let n = 0, r = i.length; n < r; n++) {
1409
+ const f = i[n];
1410
+ if (!f.poly)
1411
+ if (f.isExteriorRing()) t.push(new He(f));
1412
+ else {
1413
+ const a = f.enclosingRing();
1414
+ a != null && a.poly || t.push(new He(a)), (e = a == null ? void 0 : a.poly) == null || e.addInterior(f);
1415
+ }
1416
+ }
1417
+ return t;
1418
+ }
1419
+ }, Bt = class {
1420
+ constructor(i, t = Pe.compare) {
1421
+ M(this, "queue");
1422
+ M(this, "tree");
1423
+ M(this, "segments");
1424
+ this.queue = i, this.tree = new ve(t), this.segments = [];
1425
+ }
1426
+ process(i) {
1427
+ const t = i.segment, e = [];
1428
+ if (i.consumedBy)
1429
+ return i.isLeft ? this.queue.delete(i.otherSE) : this.tree.delete(t), e;
1430
+ i.isLeft && this.tree.add(t);
1431
+ let n = t, r = t;
1432
+ do
1433
+ n = this.tree.lastBefore(n);
1434
+ while (n != null && n.consumedBy != null);
1435
+ do
1436
+ r = this.tree.firstAfter(r);
1437
+ while (r != null && r.consumedBy != null);
1438
+ if (i.isLeft) {
1439
+ let f = null;
1440
+ if (n) {
1441
+ const c = n.getIntersection(t);
1442
+ if (c !== null && (t.isAnEndpoint(c) || (f = c), !n.isAnEndpoint(c))) {
1443
+ const E = this._splitSafely(n, c);
1444
+ for (let d = 0, T = E.length; d < T; d++)
1445
+ e.push(E[d]);
1446
+ }
1447
+ }
1448
+ let a = null;
1449
+ if (r) {
1450
+ const c = r.getIntersection(t);
1451
+ if (c !== null && (t.isAnEndpoint(c) || (a = c), !r.isAnEndpoint(c))) {
1452
+ const E = this._splitSafely(r, c);
1453
+ for (let d = 0, T = E.length; d < T; d++)
1454
+ e.push(E[d]);
1455
+ }
1456
+ }
1457
+ if (f !== null || a !== null) {
1458
+ let c = null;
1459
+ f === null ? c = a : a === null ? c = f : c = ie.comparePoints(
1460
+ f,
1461
+ a
1462
+ ) <= 0 ? f : a, this.queue.delete(t.rightSE), e.push(t.rightSE);
1463
+ const E = t.split(c);
1464
+ for (let d = 0, T = E.length; d < T; d++)
1465
+ e.push(E[d]);
1466
+ }
1467
+ e.length > 0 ? (this.tree.delete(t), e.push(i)) : (this.segments.push(t), t.prev = n);
1468
+ } else {
1469
+ if (n && r) {
1470
+ const f = n.getIntersection(r);
1471
+ if (f !== null) {
1472
+ if (!n.isAnEndpoint(f)) {
1473
+ const a = this._splitSafely(n, f);
1474
+ for (let c = 0, E = a.length; c < E; c++)
1475
+ e.push(a[c]);
1476
+ }
1477
+ if (!r.isAnEndpoint(f)) {
1478
+ const a = this._splitSafely(r, f);
1479
+ for (let c = 0, E = a.length; c < E; c++)
1480
+ e.push(a[c]);
1481
+ }
1482
+ }
1483
+ }
1484
+ this.tree.delete(t);
1485
+ }
1486
+ return e;
1487
+ }
1488
+ /* Safely split a segment that is currently in the datastructures
1489
+ * IE - a segment other than the one that is currently being processed. */
1490
+ _splitSafely(i, t) {
1491
+ this.tree.delete(i);
1492
+ const e = i.rightSE;
1493
+ this.queue.delete(e);
1494
+ const n = i.split(t);
1495
+ return n.push(e), i.consumedBy === void 0 && this.tree.add(i), n;
1496
+ }
1497
+ }, Gt = class {
1498
+ constructor() {
1499
+ M(this, "type");
1500
+ M(this, "numMultiPolys");
1501
+ }
1502
+ run(i, t, e) {
1503
+ ge.type = i;
1504
+ const n = [new je(t, !0)];
1505
+ for (let d = 0, T = e.length; d < T; d++)
1506
+ n.push(new je(e[d], !1));
1507
+ if (ge.numMultiPolys = n.length, ge.type === "difference") {
1508
+ const d = n[0];
1509
+ let T = 1;
1510
+ for (; T < n.length; )
1511
+ Ie(n[T].bbox, d.bbox) !== null ? T++ : n.splice(T, 1);
1512
+ }
1513
+ if (ge.type === "intersection")
1514
+ for (let d = 0, T = n.length; d < T; d++) {
1515
+ const b = n[d];
1516
+ for (let P = d + 1, N = n.length; P < N; P++)
1517
+ if (Ie(b.bbox, n[P].bbox) === null) return [];
1518
+ }
1519
+ const r = new ve(ie.compare);
1520
+ for (let d = 0, T = n.length; d < T; d++) {
1521
+ const b = n[d].getSweepEvents();
1522
+ for (let P = 0, N = b.length; P < N; P++)
1523
+ r.add(b[P]);
1524
+ }
1525
+ const f = new Bt(r);
1526
+ let a = null;
1527
+ for (r.size != 0 && (a = r.first(), r.delete(a)); a; ) {
1528
+ const d = f.process(a);
1529
+ for (let T = 0, b = d.length; T < b; T++) {
1530
+ const P = d[T];
1531
+ P.consumedBy === void 0 && r.add(P);
1532
+ }
1533
+ r.size != 0 ? (a = r.first(), r.delete(a)) : a = null;
1534
+ }
1535
+ le.reset();
1536
+ const c = It.factory(f.segments);
1537
+ return new kt(c).getGeom();
1538
+ }
1539
+ }, ge = new Gt(), Te = ge, Ft = 0, Pe = class Ee {
1540
+ /* Warning: a reference to ringWindings input will be stored,
1541
+ * and possibly will be later modified */
1542
+ constructor(t, e, n, r) {
1543
+ M(this, "id");
1544
+ M(this, "leftSE");
1545
+ M(this, "rightSE");
1546
+ M(this, "rings");
1547
+ M(this, "windings");
1548
+ M(this, "ringOut");
1549
+ M(this, "consumedBy");
1550
+ M(this, "prev");
1551
+ M(this, "_prevInResult");
1552
+ M(this, "_beforeState");
1553
+ M(this, "_afterState");
1554
+ M(this, "_isInResult");
1555
+ this.id = ++Ft, this.leftSE = t, t.segment = this, t.otherSE = e, this.rightSE = e, e.segment = this, e.otherSE = t, this.rings = n, this.windings = r;
1556
+ }
834
1557
  /* This compare() function is for ordering segments in the sweep
835
1558
  * line tree, and does so according to the following criteria:
836
1559
  *
@@ -845,60 +1568,58 @@ class z {
845
1568
  * is directly on the right-more of the two left inputs.
846
1569
  */
847
1570
  static compare(t, e) {
848
- const n = t.leftSE.point.x, r = e.leftSE.point.x, i = t.rightSE.point.x, u = e.rightSE.point.x;
849
- if (u < n) return 1;
850
- if (i < r) return -1;
851
- const l = t.leftSE.point.y, c = e.leftSE.point.y, f = t.rightSE.point.y, a = e.rightSE.point.y;
852
- if (n < r) {
853
- if (c < l && c < f) return 1;
854
- if (c > l && c > f) return -1;
855
- const s = t.comparePoint(e.leftSE.point);
856
- if (s < 0) return 1;
857
- if (s > 0) return -1;
858
- const h = e.comparePoint(t.rightSE.point);
859
- return h !== 0 ? h : -1;
860
- }
861
- if (n > r) {
862
- if (l < c && l < a) return -1;
863
- if (l > c && l > a) return 1;
864
- const s = e.comparePoint(t.leftSE.point);
865
- if (s !== 0) return s;
866
- const h = t.comparePoint(e.rightSE.point);
867
- return h < 0 ? 1 : h > 0 ? -1 : 1;
868
- }
869
- if (l < c) return -1;
870
- if (l > c) return 1;
871
- if (i < u) {
872
- const s = e.comparePoint(t.rightSE.point);
873
- if (s !== 0) return s;
874
- }
875
- if (i > u) {
876
- const s = t.comparePoint(e.rightSE.point);
877
- if (s < 0) return 1;
878
- if (s > 0) return -1;
879
- }
880
- if (i !== u) {
881
- const s = f - l, h = i - n, g = a - c, y = u - r;
882
- if (s > h && g < y) return 1;
883
- if (s < h && g > y) return -1;
884
- }
885
- return i > u ? 1 : i < u || f < a ? -1 : f > a ? 1 : t.id < e.id ? -1 : t.id > e.id ? 1 : 0;
886
- }
887
- /* Warning: a reference to ringWindings input will be stored,
888
- * and possibly will be later modified */
889
- constructor(t, e, n, r) {
890
- this.id = ++ge, this.leftSE = t, t.segment = this, t.otherSE = e, this.rightSE = e, e.segment = this, e.otherSE = t, this.rings = n, this.windings = r;
1571
+ const n = t.leftSE.point.x, r = e.leftSE.point.x, f = t.rightSE.point.x, a = e.rightSE.point.x;
1572
+ if (a.isLessThan(n)) return 1;
1573
+ if (f.isLessThan(r)) return -1;
1574
+ const c = t.leftSE.point.y, E = e.leftSE.point.y, d = t.rightSE.point.y, T = e.rightSE.point.y;
1575
+ if (n.isLessThan(r)) {
1576
+ if (E.isLessThan(c) && E.isLessThan(d)) return 1;
1577
+ if (E.isGreaterThan(c) && E.isGreaterThan(d)) return -1;
1578
+ const b = t.comparePoint(e.leftSE.point);
1579
+ if (b < 0) return 1;
1580
+ if (b > 0) return -1;
1581
+ const P = e.comparePoint(t.rightSE.point);
1582
+ return P !== 0 ? P : -1;
1583
+ }
1584
+ if (n.isGreaterThan(r)) {
1585
+ if (c.isLessThan(E) && c.isLessThan(T)) return -1;
1586
+ if (c.isGreaterThan(E) && c.isGreaterThan(T)) return 1;
1587
+ const b = e.comparePoint(t.leftSE.point);
1588
+ if (b !== 0) return b;
1589
+ const P = t.comparePoint(e.rightSE.point);
1590
+ return P < 0 ? 1 : P > 0 ? -1 : 1;
1591
+ }
1592
+ if (c.isLessThan(E)) return -1;
1593
+ if (c.isGreaterThan(E)) return 1;
1594
+ if (f.isLessThan(a)) {
1595
+ const b = e.comparePoint(t.rightSE.point);
1596
+ if (b !== 0) return b;
1597
+ }
1598
+ if (f.isGreaterThan(a)) {
1599
+ const b = t.comparePoint(e.rightSE.point);
1600
+ if (b < 0) return 1;
1601
+ if (b > 0) return -1;
1602
+ }
1603
+ if (!f.eq(a)) {
1604
+ const b = d.minus(c), P = f.minus(n), N = T.minus(E), _ = a.minus(r);
1605
+ if (b.isGreaterThan(P) && N.isLessThan(_)) return 1;
1606
+ if (b.isLessThan(P) && N.isGreaterThan(_)) return -1;
1607
+ }
1608
+ return f.isGreaterThan(a) ? 1 : f.isLessThan(a) || d.isLessThan(T) ? -1 : d.isGreaterThan(T) ? 1 : t.id < e.id ? -1 : t.id > e.id ? 1 : 0;
891
1609
  }
892
1610
  static fromRing(t, e, n) {
893
- let r, i, u;
894
- const l = R.comparePoints(t, e);
895
- if (l < 0)
896
- r = t, i = e, u = 1;
897
- else if (l > 0)
898
- r = e, i = t, u = -1;
899
- else throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);
900
- const c = new R(r, !0), f = new R(i, !1);
901
- return new z(c, f, [n], [u]);
1611
+ let r, f, a;
1612
+ const c = ie.comparePoints(t, e);
1613
+ if (c < 0)
1614
+ r = t, f = e, a = 1;
1615
+ else if (c > 0)
1616
+ r = e, f = t, a = -1;
1617
+ else
1618
+ throw new Error(
1619
+ `Tried to create degenerate segment at [${t.x}, ${t.y}]`
1620
+ );
1621
+ const E = new ie(r, !0), d = new ie(f, !1);
1622
+ return new Ee(E, d, [n], [a]);
902
1623
  }
903
1624
  /* When a segment is split, the rightSE is replaced with a new sweep event */
904
1625
  replaceRightSE(t) {
@@ -907,25 +1628,19 @@ class z {
907
1628
  bbox() {
908
1629
  const t = this.leftSE.point.y, e = this.rightSE.point.y;
909
1630
  return {
910
- ll: {
911
- x: this.leftSE.point.x,
912
- y: t < e ? t : e
913
- },
914
- ur: {
915
- x: this.rightSE.point.x,
916
- y: t > e ? t : e
917
- }
1631
+ ll: { x: this.leftSE.point.x, y: t.isLessThan(e) ? t : e },
1632
+ ur: { x: this.rightSE.point.x, y: t.isGreaterThan(e) ? t : e }
918
1633
  };
919
1634
  }
920
1635
  /* A vector from the left point to the right */
921
1636
  vector() {
922
1637
  return {
923
- x: this.rightSE.point.x - this.leftSE.point.x,
924
- y: this.rightSE.point.y - this.leftSE.point.y
1638
+ x: this.rightSE.point.x.minus(this.leftSE.point.x),
1639
+ y: this.rightSE.point.y.minus(this.leftSE.point.y)
925
1640
  };
926
1641
  }
927
1642
  isAnEndpoint(t) {
928
- return t.x === this.leftSE.point.x && t.y === this.leftSE.point.y || t.x === this.rightSE.point.x && t.y === this.rightSE.point.y;
1643
+ return t.x.eq(this.leftSE.point.x) && t.y.eq(this.leftSE.point.y) || t.x.eq(this.rightSE.point.x) && t.y.eq(this.rightSE.point.y);
929
1644
  }
930
1645
  /* Compare this segment with a point.
931
1646
  *
@@ -941,14 +1656,7 @@ class z {
941
1656
  * -1: point lies below the segment (to the right of vertical)
942
1657
  */
943
1658
  comparePoint(t) {
944
- if (this.isAnEndpoint(t)) return 0;
945
- const e = this.leftSE.point, n = this.rightSE.point, r = this.vector();
946
- if (e.x === n.x)
947
- return t.x === e.x ? 0 : t.x < e.x ? 1 : -1;
948
- const i = (t.y - e.y) / r.y, u = e.x + i * r.x;
949
- if (t.x === u) return 0;
950
- const l = (t.x - e.x) / r.x, c = e.y + l * r.y;
951
- return t.y === c ? 0 : t.y < c ? -1 : 1;
1659
+ return le.orient(this.leftSE.point, t, this.rightSE.point);
952
1660
  }
953
1661
  /**
954
1662
  * Given another segment, returns the first non-trivial intersection
@@ -966,20 +1674,20 @@ class z {
966
1674
  * Else, return null.
967
1675
  */
968
1676
  getIntersection(t) {
969
- const e = this.bbox(), n = t.bbox(), r = it(e, n);
1677
+ const e = this.bbox(), n = t.bbox(), r = Ie(e, n);
970
1678
  if (r === null) return null;
971
- const i = this.leftSE.point, u = this.rightSE.point, l = t.leftSE.point, c = t.rightSE.point, f = Q(e, l) && this.comparePoint(l) === 0, a = Q(n, i) && t.comparePoint(i) === 0, s = Q(e, c) && this.comparePoint(c) === 0, h = Q(n, u) && t.comparePoint(u) === 0;
972
- if (a && f)
973
- return h && !s ? u : !h && s ? c : null;
974
- if (a)
975
- return s && i.x === c.x && i.y === c.y ? null : i;
976
- if (f)
977
- return h && u.x === l.x && u.y === l.y ? null : l;
978
- if (h && s) return null;
979
- if (h) return u;
980
- if (s) return c;
981
- const g = ae(i, this.vector(), l, t.vector());
982
- return g === null || !Q(r, g) ? null : U.round(g.x, g.y);
1679
+ const f = this.leftSE.point, a = this.rightSE.point, c = t.leftSE.point, E = t.rightSE.point, d = ae(e, c) && this.comparePoint(c) === 0, T = ae(n, f) && t.comparePoint(f) === 0, b = ae(e, E) && this.comparePoint(E) === 0, P = ae(n, a) && t.comparePoint(a) === 0;
1680
+ if (T && d)
1681
+ return P && !b ? a : !P && b ? E : null;
1682
+ if (T)
1683
+ return b && f.x.eq(E.x) && f.y.eq(E.y) ? null : f;
1684
+ if (d)
1685
+ return P && a.x.eq(c.x) && a.y.eq(c.y) ? null : c;
1686
+ if (P && b) return null;
1687
+ if (P) return a;
1688
+ if (b) return E;
1689
+ const N = At(f, this.vector(), c, t.vector());
1690
+ return N === null || !ae(r, N) ? null : le.snap(N);
983
1691
  }
984
1692
  /**
985
1693
  * Split the given segment into multiple segments on the given points.
@@ -994,10 +1702,15 @@ class z {
994
1702
  * Warning: input array of points is modified
995
1703
  */
996
1704
  split(t) {
997
- const e = [], n = t.events !== void 0, r = new R(t, !0), i = new R(t, !1), u = this.rightSE;
998
- this.replaceRightSE(i), e.push(i), e.push(r);
999
- const l = new z(r, u, this.rings.slice(), this.windings.slice());
1000
- return R.comparePoints(l.leftSE.point, l.rightSE.point) > 0 && l.swapEvents(), R.comparePoints(this.leftSE.point, this.rightSE.point) > 0 && this.swapEvents(), n && (r.checkForConsuming(), i.checkForConsuming()), e;
1705
+ const e = [], n = t.events !== void 0, r = new ie(t, !0), f = new ie(t, !1), a = this.rightSE;
1706
+ this.replaceRightSE(f), e.push(f), e.push(r);
1707
+ const c = new Ee(
1708
+ r,
1709
+ a,
1710
+ this.rings.slice(),
1711
+ this.windings.slice()
1712
+ );
1713
+ return ie.comparePoints(c.leftSE.point, c.rightSE.point) > 0 && c.swapEvents(), ie.comparePoints(this.leftSE.point, this.rightSE.point) > 0 && this.swapEvents(), n && (r.checkForConsuming(), f.checkForConsuming()), e;
1001
1714
  }
1002
1715
  /* Swap which event is left and right */
1003
1716
  swapEvents() {
@@ -1012,19 +1725,19 @@ class z {
1012
1725
  let e = this, n = t;
1013
1726
  for (; e.consumedBy; ) e = e.consumedBy;
1014
1727
  for (; n.consumedBy; ) n = n.consumedBy;
1015
- const r = z.compare(e, n);
1728
+ const r = Ee.compare(e, n);
1016
1729
  if (r !== 0) {
1017
1730
  if (r > 0) {
1018
- const i = e;
1019
- e = n, n = i;
1731
+ const f = e;
1732
+ e = n, n = f;
1020
1733
  }
1021
1734
  if (e.prev === n) {
1022
- const i = e;
1023
- e = n, n = i;
1735
+ const f = e;
1736
+ e = n, n = f;
1024
1737
  }
1025
- for (let i = 0, u = n.rings.length; i < u; i++) {
1026
- const l = n.rings[i], c = n.windings[i], f = e.rings.indexOf(l);
1027
- f === -1 ? (e.rings.push(l), e.windings.push(c)) : e.windings[f] += c;
1738
+ for (let f = 0, a = n.rings.length; f < a; f++) {
1739
+ const c = n.rings[f], E = n.windings[f], d = e.rings.indexOf(c);
1740
+ d === -1 ? (e.rings.push(c), e.windings.push(E)) : e.windings[d] += E;
1028
1741
  }
1029
1742
  n.rings = null, n.windings = null, n.consumedBy = e, n.leftSE.consumedBy = e.leftSE, n.rightSE.consumedBy = e.rightSE;
1030
1743
  }
@@ -1035,11 +1748,12 @@ class z {
1035
1748
  }
1036
1749
  beforeState() {
1037
1750
  if (this._beforeState !== void 0) return this._beforeState;
1038
- if (!this.prev) this._beforeState = {
1039
- rings: [],
1040
- windings: [],
1041
- multiPolys: []
1042
- };
1751
+ if (!this.prev)
1752
+ this._beforeState = {
1753
+ rings: [],
1754
+ windings: [],
1755
+ multiPolys: []
1756
+ };
1043
1757
  else {
1044
1758
  const t = this.prev.consumedBy || this.prev;
1045
1759
  this._beforeState = t.afterState();
@@ -1055,25 +1769,25 @@ class z {
1055
1769
  multiPolys: []
1056
1770
  };
1057
1771
  const e = this._afterState.rings, n = this._afterState.windings, r = this._afterState.multiPolys;
1058
- for (let l = 0, c = this.rings.length; l < c; l++) {
1059
- const f = this.rings[l], a = this.windings[l], s = e.indexOf(f);
1060
- s === -1 ? (e.push(f), n.push(a)) : n[s] += a;
1061
- }
1062
- const i = [], u = [];
1063
- for (let l = 0, c = e.length; l < c; l++) {
1064
- if (n[l] === 0) continue;
1065
- const f = e[l], a = f.poly;
1066
- if (u.indexOf(a) === -1)
1067
- if (f.isExterior) i.push(a);
1772
+ for (let c = 0, E = this.rings.length; c < E; c++) {
1773
+ const d = this.rings[c], T = this.windings[c], b = e.indexOf(d);
1774
+ b === -1 ? (e.push(d), n.push(T)) : n[b] += T;
1775
+ }
1776
+ const f = [], a = [];
1777
+ for (let c = 0, E = e.length; c < E; c++) {
1778
+ if (n[c] === 0) continue;
1779
+ const d = e[c], T = d.poly;
1780
+ if (a.indexOf(T) === -1)
1781
+ if (d.isExterior) f.push(T);
1068
1782
  else {
1069
- u.indexOf(a) === -1 && u.push(a);
1070
- const s = i.indexOf(f.poly);
1071
- s !== -1 && i.splice(s, 1);
1783
+ a.indexOf(T) === -1 && a.push(T);
1784
+ const b = f.indexOf(d.poly);
1785
+ b !== -1 && f.splice(b, 1);
1072
1786
  }
1073
1787
  }
1074
- for (let l = 0, c = i.length; l < c; l++) {
1075
- const f = i[l].multiPoly;
1076
- r.indexOf(f) === -1 && r.push(f);
1788
+ for (let c = 0, E = f.length; c < E; c++) {
1789
+ const d = f[c].multiPoly;
1790
+ r.indexOf(d) === -1 && r.push(d);
1077
1791
  }
1078
1792
  return this._afterState;
1079
1793
  }
@@ -1082,7 +1796,7 @@ class z {
1082
1796
  if (this.consumedBy) return !1;
1083
1797
  if (this._isInResult !== void 0) return this._isInResult;
1084
1798
  const t = this.beforeState().multiPolys, e = this.afterState().multiPolys;
1085
- switch (A.type) {
1799
+ switch (Te.type) {
1086
1800
  case "union": {
1087
1801
  const n = t.length === 0, r = e.length === 0;
1088
1802
  this._isInResult = n !== r;
@@ -1090,7 +1804,7 @@ class z {
1090
1804
  }
1091
1805
  case "intersection": {
1092
1806
  let n, r;
1093
- t.length < e.length ? (n = t.length, r = e.length) : (n = e.length, r = t.length), this._isInResult = r === A.numMultiPolys && n < r;
1807
+ t.length < e.length ? (n = t.length, r = e.length) : (n = e.length, r = t.length), this._isInResult = r === Te.numMultiPolys && n < r;
1094
1808
  break;
1095
1809
  }
1096
1810
  case "xor": {
@@ -1103,428 +1817,136 @@ class z {
1103
1817
  this._isInResult = n(t) !== n(e);
1104
1818
  break;
1105
1819
  }
1106
- default:
1107
- throw new Error(`Unrecognized operation type found ${A.type}`);
1108
1820
  }
1109
1821
  return this._isInResult;
1110
1822
  }
1111
- }
1112
- class Pt {
1113
- constructor(t, e, n) {
1114
- if (!Array.isArray(t) || t.length === 0)
1823
+ }, Je = class {
1824
+ constructor(i, t, e) {
1825
+ M(this, "poly");
1826
+ M(this, "isExterior");
1827
+ M(this, "segments");
1828
+ M(this, "bbox");
1829
+ if (!Array.isArray(i) || i.length === 0)
1115
1830
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1116
- if (this.poly = e, this.isExterior = n, this.segments = [], typeof t[0][0] != "number" || typeof t[0][1] != "number")
1831
+ if (this.poly = t, this.isExterior = e, this.segments = [], typeof i[0][0] != "number" || typeof i[0][1] != "number")
1117
1832
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1118
- const r = U.round(t[0][0], t[0][1]);
1833
+ const n = le.snap({ x: new ne(i[0][0]), y: new ne(i[0][1]) });
1119
1834
  this.bbox = {
1120
- ll: {
1121
- x: r.x,
1122
- y: r.y
1123
- },
1124
- ur: {
1125
- x: r.x,
1126
- y: r.y
1127
- }
1835
+ ll: { x: n.x, y: n.y },
1836
+ ur: { x: n.x, y: n.y }
1128
1837
  };
1129
- let i = r;
1130
- for (let u = 1, l = t.length; u < l; u++) {
1131
- if (typeof t[u][0] != "number" || typeof t[u][1] != "number")
1838
+ let r = n;
1839
+ for (let f = 1, a = i.length; f < a; f++) {
1840
+ if (typeof i[f][0] != "number" || typeof i[f][1] != "number")
1132
1841
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1133
- let c = U.round(t[u][0], t[u][1]);
1134
- c.x === i.x && c.y === i.y || (this.segments.push(z.fromRing(i, c, this)), c.x < this.bbox.ll.x && (this.bbox.ll.x = c.x), c.y < this.bbox.ll.y && (this.bbox.ll.y = c.y), c.x > this.bbox.ur.x && (this.bbox.ur.x = c.x), c.y > this.bbox.ur.y && (this.bbox.ur.y = c.y), i = c);
1842
+ const c = le.snap({ x: new ne(i[f][0]), y: new ne(i[f][1]) });
1843
+ c.x.eq(r.x) && c.y.eq(r.y) || (this.segments.push(Pe.fromRing(r, c, this)), c.x.isLessThan(this.bbox.ll.x) && (this.bbox.ll.x = c.x), c.y.isLessThan(this.bbox.ll.y) && (this.bbox.ll.y = c.y), c.x.isGreaterThan(this.bbox.ur.x) && (this.bbox.ur.x = c.x), c.y.isGreaterThan(this.bbox.ur.y) && (this.bbox.ur.y = c.y), r = c);
1135
1844
  }
1136
- (r.x !== i.x || r.y !== i.y) && this.segments.push(z.fromRing(i, r, this));
1845
+ (!n.x.eq(r.x) || !n.y.eq(r.y)) && this.segments.push(Pe.fromRing(r, n, this));
1137
1846
  }
1138
1847
  getSweepEvents() {
1139
- const t = [];
1140
- for (let e = 0, n = this.segments.length; e < n; e++) {
1141
- const r = this.segments[e];
1142
- t.push(r.leftSE), t.push(r.rightSE);
1848
+ const i = [];
1849
+ for (let t = 0, e = this.segments.length; t < e; t++) {
1850
+ const n = this.segments[t];
1851
+ i.push(n.leftSE), i.push(n.rightSE);
1143
1852
  }
1144
- return t;
1853
+ return i;
1145
1854
  }
1146
- }
1147
- class pe {
1148
- constructor(t, e) {
1149
- if (!Array.isArray(t))
1855
+ }, qt = class {
1856
+ constructor(i, t) {
1857
+ M(this, "multiPoly");
1858
+ M(this, "exteriorRing");
1859
+ M(this, "interiorRings");
1860
+ M(this, "bbox");
1861
+ if (!Array.isArray(i))
1150
1862
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1151
- this.exteriorRing = new Pt(t[0], this, !0), this.bbox = {
1152
- ll: {
1153
- x: this.exteriorRing.bbox.ll.x,
1154
- y: this.exteriorRing.bbox.ll.y
1155
- },
1156
- ur: {
1157
- x: this.exteriorRing.bbox.ur.x,
1158
- y: this.exteriorRing.bbox.ur.y
1159
- }
1863
+ this.exteriorRing = new Je(i[0], this, !0), this.bbox = {
1864
+ ll: { x: this.exteriorRing.bbox.ll.x, y: this.exteriorRing.bbox.ll.y },
1865
+ ur: { x: this.exteriorRing.bbox.ur.x, y: this.exteriorRing.bbox.ur.y }
1160
1866
  }, this.interiorRings = [];
1161
- for (let n = 1, r = t.length; n < r; n++) {
1162
- const i = new Pt(t[n], this, !1);
1163
- i.bbox.ll.x < this.bbox.ll.x && (this.bbox.ll.x = i.bbox.ll.x), i.bbox.ll.y < this.bbox.ll.y && (this.bbox.ll.y = i.bbox.ll.y), i.bbox.ur.x > this.bbox.ur.x && (this.bbox.ur.x = i.bbox.ur.x), i.bbox.ur.y > this.bbox.ur.y && (this.bbox.ur.y = i.bbox.ur.y), this.interiorRings.push(i);
1867
+ for (let e = 1, n = i.length; e < n; e++) {
1868
+ const r = new Je(i[e], this, !1);
1869
+ r.bbox.ll.x.isLessThan(this.bbox.ll.x) && (this.bbox.ll.x = r.bbox.ll.x), r.bbox.ll.y.isLessThan(this.bbox.ll.y) && (this.bbox.ll.y = r.bbox.ll.y), r.bbox.ur.x.isGreaterThan(this.bbox.ur.x) && (this.bbox.ur.x = r.bbox.ur.x), r.bbox.ur.y.isGreaterThan(this.bbox.ur.y) && (this.bbox.ur.y = r.bbox.ur.y), this.interiorRings.push(r);
1164
1870
  }
1165
- this.multiPoly = e;
1871
+ this.multiPoly = t;
1166
1872
  }
1167
1873
  getSweepEvents() {
1168
- const t = this.exteriorRing.getSweepEvents();
1169
- for (let e = 0, n = this.interiorRings.length; e < n; e++) {
1170
- const r = this.interiorRings[e].getSweepEvents();
1171
- for (let i = 0, u = r.length; i < u; i++)
1172
- t.push(r[i]);
1874
+ const i = this.exteriorRing.getSweepEvents();
1875
+ for (let t = 0, e = this.interiorRings.length; t < e; t++) {
1876
+ const n = this.interiorRings[t].getSweepEvents();
1877
+ for (let r = 0, f = n.length; r < f; r++)
1878
+ i.push(n[r]);
1173
1879
  }
1174
- return t;
1880
+ return i;
1175
1881
  }
1176
- }
1177
- class Mt {
1178
- constructor(t, e) {
1179
- if (!Array.isArray(t))
1882
+ }, je = class {
1883
+ constructor(i, t) {
1884
+ M(this, "isSubject");
1885
+ M(this, "polys");
1886
+ M(this, "bbox");
1887
+ if (!Array.isArray(i))
1180
1888
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1181
1889
  try {
1182
- typeof t[0][0][0] == "number" && (t = [t]);
1890
+ typeof i[0][0][0] == "number" && (i = [i]);
1183
1891
  } catch {
1184
1892
  }
1185
1893
  this.polys = [], this.bbox = {
1186
- ll: {
1187
- x: Number.POSITIVE_INFINITY,
1188
- y: Number.POSITIVE_INFINITY
1189
- },
1190
- ur: {
1191
- x: Number.NEGATIVE_INFINITY,
1192
- y: Number.NEGATIVE_INFINITY
1193
- }
1894
+ ll: { x: new ne(Number.POSITIVE_INFINITY), y: new ne(Number.POSITIVE_INFINITY) },
1895
+ ur: { x: new ne(Number.NEGATIVE_INFINITY), y: new ne(Number.NEGATIVE_INFINITY) }
1194
1896
  };
1195
- for (let n = 0, r = t.length; n < r; n++) {
1196
- const i = new pe(t[n], this);
1197
- i.bbox.ll.x < this.bbox.ll.x && (this.bbox.ll.x = i.bbox.ll.x), i.bbox.ll.y < this.bbox.ll.y && (this.bbox.ll.y = i.bbox.ll.y), i.bbox.ur.x > this.bbox.ur.x && (this.bbox.ur.x = i.bbox.ur.x), i.bbox.ur.y > this.bbox.ur.y && (this.bbox.ur.y = i.bbox.ur.y), this.polys.push(i);
1897
+ for (let e = 0, n = i.length; e < n; e++) {
1898
+ const r = new qt(i[e], this);
1899
+ r.bbox.ll.x.isLessThan(this.bbox.ll.x) && (this.bbox.ll.x = r.bbox.ll.x), r.bbox.ll.y.isLessThan(this.bbox.ll.y) && (this.bbox.ll.y = r.bbox.ll.y), r.bbox.ur.x.isGreaterThan(this.bbox.ur.x) && (this.bbox.ur.x = r.bbox.ur.x), r.bbox.ur.y.isGreaterThan(this.bbox.ur.y) && (this.bbox.ur.y = r.bbox.ur.y), this.polys.push(r);
1198
1900
  }
1199
- this.isSubject = e;
1901
+ this.isSubject = t;
1200
1902
  }
1201
1903
  getSweepEvents() {
1202
- const t = [];
1203
- for (let e = 0, n = this.polys.length; e < n; e++) {
1204
- const r = this.polys[e].getSweepEvents();
1205
- for (let i = 0, u = r.length; i < u; i++)
1206
- t.push(r[i]);
1207
- }
1208
- return t;
1209
- }
1210
- }
1211
- class W {
1212
- /* Given the segments from the sweep line pass, compute & return a series
1213
- * of closed rings from all the segments marked to be part of the result */
1214
- static factory(t) {
1215
- const e = [];
1216
- for (let n = 0, r = t.length; n < r; n++) {
1217
- const i = t[n];
1218
- if (!i.isInResult() || i.ringOut) continue;
1219
- let u = null, l = i.leftSE, c = i.rightSE;
1220
- const f = [l], a = l.point, s = [];
1221
- for (; u = l, l = c, f.push(l), l.point !== a; )
1222
- for (; ; ) {
1223
- const h = l.getAvailableLinkedEvents();
1224
- if (h.length === 0) {
1225
- const p = f[0].point, d = f[f.length - 1].point;
1226
- throw new Error(`Unable to complete output ring starting at [${p.x}, ${p.y}]. Last matching segment found ends at [${d.x}, ${d.y}].`);
1227
- }
1228
- if (h.length === 1) {
1229
- c = h[0].otherSE;
1230
- break;
1231
- }
1232
- let g = null;
1233
- for (let p = 0, d = s.length; p < d; p++)
1234
- if (s[p].point === l.point) {
1235
- g = p;
1236
- break;
1237
- }
1238
- if (g !== null) {
1239
- const p = s.splice(g)[0], d = f.splice(p.index);
1240
- d.unshift(d[0].otherSE), e.push(new W(d.reverse()));
1241
- continue;
1242
- }
1243
- s.push({
1244
- index: f.length,
1245
- point: l.point
1246
- });
1247
- const y = l.getLeftmostComparator(u);
1248
- c = h.sort(y)[0].otherSE;
1249
- break;
1250
- }
1251
- e.push(new W(f));
1252
- }
1253
- return e;
1254
- }
1255
- constructor(t) {
1256
- this.events = t;
1257
- for (let e = 0, n = t.length; e < n; e++)
1258
- t[e].segment.ringOut = this;
1259
- this.poly = null;
1260
- }
1261
- getGeom() {
1262
- let t = this.events[0].point;
1263
- const e = [t];
1264
- for (let f = 1, a = this.events.length - 1; f < a; f++) {
1265
- const s = this.events[f].point, h = this.events[f + 1].point;
1266
- bt(s, t, h) !== 0 && (e.push(s), t = s);
1267
- }
1268
- if (e.length === 1) return null;
1269
- const n = e[0], r = e[1];
1270
- bt(n, t, r) === 0 && e.shift(), e.push(e[0]);
1271
- const i = this.isExteriorRing() ? 1 : -1, u = this.isExteriorRing() ? 0 : e.length - 1, l = this.isExteriorRing() ? e.length : -1, c = [];
1272
- for (let f = u; f != l; f += i) c.push([e[f].x, e[f].y]);
1273
- return c;
1274
- }
1275
- isExteriorRing() {
1276
- if (this._isExteriorRing === void 0) {
1277
- const t = this.enclosingRing();
1278
- this._isExteriorRing = t ? !t.isExteriorRing() : !0;
1279
- }
1280
- return this._isExteriorRing;
1281
- }
1282
- enclosingRing() {
1283
- return this._enclosingRing === void 0 && (this._enclosingRing = this._calcEnclosingRing()), this._enclosingRing;
1284
- }
1285
- /* Returns the ring that encloses this one, if any */
1286
- _calcEnclosingRing() {
1287
- let t = this.events[0];
1288
- for (let r = 1, i = this.events.length; r < i; r++) {
1289
- const u = this.events[r];
1290
- R.compare(t, u) > 0 && (t = u);
1291
- }
1292
- let e = t.segment.prevInResult(), n = e ? e.prevInResult() : null;
1293
- for (; ; ) {
1294
- if (!e) return null;
1295
- if (!n) return e.ringOut;
1296
- if (n.ringOut !== e.ringOut)
1297
- return n.ringOut.enclosingRing() !== e.ringOut ? e.ringOut : e.ringOut.enclosingRing();
1298
- e = n.prevInResult(), n = e ? e.prevInResult() : null;
1299
- }
1300
- }
1301
- }
1302
- class Rt {
1303
- constructor(t) {
1304
- this.exteriorRing = t, t.poly = this, this.interiorRings = [];
1305
- }
1306
- addInterior(t) {
1307
- this.interiorRings.push(t), t.poly = this;
1308
- }
1309
- getGeom() {
1310
- const t = [this.exteriorRing.getGeom()];
1311
- if (t[0] === null) return null;
1312
- for (let e = 0, n = this.interiorRings.length; e < n; e++) {
1313
- const r = this.interiorRings[e].getGeom();
1314
- r !== null && t.push(r);
1904
+ const i = [];
1905
+ for (let t = 0, e = this.polys.length; t < e; t++) {
1906
+ const n = this.polys[t].getSweepEvents();
1907
+ for (let r = 0, f = n.length; r < f; r++)
1908
+ i.push(n[r]);
1315
1909
  }
1316
- return t;
1910
+ return i;
1317
1911
  }
1318
- }
1319
- class ye {
1320
- constructor(t) {
1321
- this.rings = t, this.polys = this._composePolys(t);
1322
- }
1323
- getGeom() {
1324
- const t = [];
1325
- for (let e = 0, n = this.polys.length; e < n; e++) {
1326
- const r = this.polys[e].getGeom();
1327
- r !== null && t.push(r);
1328
- }
1329
- return t;
1330
- }
1331
- _composePolys(t) {
1332
- const e = [];
1333
- for (let n = 0, r = t.length; n < r; n++) {
1334
- const i = t[n];
1335
- if (!i.poly)
1336
- if (i.isExteriorRing()) e.push(new Rt(i));
1337
- else {
1338
- const u = i.enclosingRing();
1339
- u.poly || e.push(new Rt(u)), u.poly.addInterior(i);
1340
- }
1341
- }
1342
- return e;
1343
- }
1344
- }
1345
- class xe {
1346
- constructor(t) {
1347
- let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : z.compare;
1348
- this.queue = t, this.tree = new lt(e), this.segments = [];
1349
- }
1350
- process(t) {
1351
- const e = t.segment, n = [];
1352
- if (t.consumedBy)
1353
- return t.isLeft ? this.queue.remove(t.otherSE) : this.tree.remove(e), n;
1354
- const r = t.isLeft ? this.tree.add(e) : this.tree.find(e);
1355
- if (!r) throw new Error(`Unable to find segment #${e.id} [${e.leftSE.point.x}, ${e.leftSE.point.y}] -> [${e.rightSE.point.x}, ${e.rightSE.point.y}] in SweepLine tree.`);
1356
- let i = r, u = r, l, c;
1357
- for (; l === void 0; )
1358
- i = this.tree.prev(i), i === null ? l = null : i.key.consumedBy === void 0 && (l = i.key);
1359
- for (; c === void 0; )
1360
- u = this.tree.next(u), u === null ? c = null : u.key.consumedBy === void 0 && (c = u.key);
1361
- if (t.isLeft) {
1362
- let f = null;
1363
- if (l) {
1364
- const s = l.getIntersection(e);
1365
- if (s !== null && (e.isAnEndpoint(s) || (f = s), !l.isAnEndpoint(s))) {
1366
- const h = this._splitSafely(l, s);
1367
- for (let g = 0, y = h.length; g < y; g++)
1368
- n.push(h[g]);
1369
- }
1370
- }
1371
- let a = null;
1372
- if (c) {
1373
- const s = c.getIntersection(e);
1374
- if (s !== null && (e.isAnEndpoint(s) || (a = s), !c.isAnEndpoint(s))) {
1375
- const h = this._splitSafely(c, s);
1376
- for (let g = 0, y = h.length; g < y; g++)
1377
- n.push(h[g]);
1378
- }
1379
- }
1380
- if (f !== null || a !== null) {
1381
- let s = null;
1382
- f === null ? s = a : a === null ? s = f : s = R.comparePoints(f, a) <= 0 ? f : a, this.queue.remove(e.rightSE), n.push(e.rightSE);
1383
- const h = e.split(s);
1384
- for (let g = 0, y = h.length; g < y; g++)
1385
- n.push(h[g]);
1386
- }
1387
- n.length > 0 ? (this.tree.remove(e), n.push(t)) : (this.segments.push(e), e.prev = l);
1388
- } else {
1389
- if (l && c) {
1390
- const f = l.getIntersection(c);
1391
- if (f !== null) {
1392
- if (!l.isAnEndpoint(f)) {
1393
- const a = this._splitSafely(l, f);
1394
- for (let s = 0, h = a.length; s < h; s++)
1395
- n.push(a[s]);
1396
- }
1397
- if (!c.isAnEndpoint(f)) {
1398
- const a = this._splitSafely(c, f);
1399
- for (let s = 0, h = a.length; s < h; s++)
1400
- n.push(a[s]);
1401
- }
1402
- }
1403
- }
1404
- this.tree.remove(e);
1405
- }
1406
- return n;
1407
- }
1408
- /* Safely split a segment that is currently in the datastructures
1409
- * IE - a segment other than the one that is currently being processed. */
1410
- _splitSafely(t, e) {
1411
- this.tree.remove(t);
1412
- const n = t.rightSE;
1413
- this.queue.remove(n);
1414
- const r = t.split(e);
1415
- return r.push(n), t.consumedBy === void 0 && this.tree.add(t), r;
1416
- }
1417
- }
1418
- const Lt = typeof process < "u" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6, de = typeof process < "u" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6;
1419
- class ve {
1420
- run(t, e, n) {
1421
- A.type = t, U.reset();
1422
- const r = [new Mt(e, !0)];
1423
- for (let s = 0, h = n.length; s < h; s++)
1424
- r.push(new Mt(n[s], !1));
1425
- if (A.numMultiPolys = r.length, A.type === "difference") {
1426
- const s = r[0];
1427
- let h = 1;
1428
- for (; h < r.length; )
1429
- it(r[h].bbox, s.bbox) !== null ? h++ : r.splice(h, 1);
1430
- }
1431
- if (A.type === "intersection")
1432
- for (let s = 0, h = r.length; s < h; s++) {
1433
- const g = r[s];
1434
- for (let y = s + 1, p = r.length; y < p; y++)
1435
- if (it(g.bbox, r[y].bbox) === null) return [];
1436
- }
1437
- const i = new lt(R.compare);
1438
- for (let s = 0, h = r.length; s < h; s++) {
1439
- const g = r[s].getSweepEvents();
1440
- for (let y = 0, p = g.length; y < p; y++)
1441
- if (i.insert(g[y]), i.size > Lt)
1442
- throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).");
1443
- }
1444
- const u = new xe(i);
1445
- let l = i.size, c = i.pop();
1446
- for (; c; ) {
1447
- const s = c.key;
1448
- if (i.size === l) {
1449
- const g = s.segment;
1450
- throw new Error(`Unable to pop() ${s.isLeft ? "left" : "right"} SweepEvent [${s.point.x}, ${s.point.y}] from segment #${g.id} [${g.leftSE.point.x}, ${g.leftSE.point.y}] -> [${g.rightSE.point.x}, ${g.rightSE.point.y}] from queue.`);
1451
- }
1452
- if (i.size > Lt)
1453
- throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");
1454
- if (u.segments.length > de)
1455
- throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");
1456
- const h = u.process(s);
1457
- for (let g = 0, y = h.length; g < y; g++) {
1458
- const p = h[g];
1459
- p.consumedBy === void 0 && i.insert(p);
1460
- }
1461
- l = i.size, c = i.pop();
1462
- }
1463
- U.reset();
1464
- const f = W.factory(u.segments);
1465
- return new ye(f).getGeom();
1466
- }
1467
- }
1468
- const A = new ve(), me = function(o) {
1469
- for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++)
1470
- e[n - 1] = arguments[n];
1471
- return A.run("union", o, e);
1472
- }, we = function(o) {
1473
- for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++)
1474
- e[n - 1] = arguments[n];
1475
- return A.run("intersection", o, e);
1476
- }, Ee = function(o) {
1477
- for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++)
1478
- e[n - 1] = arguments[n];
1479
- return A.run("xor", o, e);
1480
- }, be = function(o) {
1481
- for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++)
1482
- e[n - 1] = arguments[n];
1483
- return A.run("difference", o, e);
1484
- };
1485
- var Ft = {
1486
- union: me,
1487
- intersection: we,
1488
- xor: Ee,
1489
- difference: be
1490
- };
1491
- function Se(o) {
1912
+ }, Dt = (i, ...t) => Te.run("union", i, t), zt = (i, ...t) => Te.run("difference", i, t);
1913
+ le.set;
1914
+ function Ut(i) {
1492
1915
  const t = [];
1493
- if (st(o, (r) => {
1916
+ if (Ge(i, (r) => {
1494
1917
  t.push(r.coordinates);
1495
1918
  }), t.length < 2)
1496
1919
  throw new Error("Must have at least two features");
1497
- const e = o.features[0].properties || {}, n = Ft.difference(t[0], ...t.slice(1));
1498
- return n.length === 0 ? null : n.length === 1 ? ot(n[0], e) : At(n, e);
1920
+ const e = i.features[0].properties || {}, n = zt(t[0], ...t.slice(1));
1921
+ return n.length === 0 ? null : n.length === 1 ? Be(n[0], e) : rt(n, e);
1499
1922
  }
1500
- var _e = Se;
1501
- function Pe(o) {
1502
- if (!o)
1503
- throw new Error("geojson is required");
1923
+ var Vt = Ut;
1924
+ function $t(i) {
1925
+ if (!i) throw new Error("geojson is required");
1504
1926
  var t = [];
1505
- return Dt(o, function(e) {
1927
+ return St(i, function(e) {
1506
1928
  t.push(e);
1507
- }), H(t);
1929
+ }), Ce(t);
1508
1930
  }
1509
- var Me = Pe;
1510
- function Re(o, t = {}) {
1931
+ var Kt = $t;
1932
+ function Xt(i, t = {}) {
1511
1933
  const e = [];
1512
- if (st(o, (r) => {
1934
+ if (Ge(i, (r) => {
1513
1935
  e.push(r.coordinates);
1514
1936
  }), e.length < 2)
1515
1937
  throw new Error("Must have at least 2 geometries");
1516
- const n = Ft.union(e[0], ...e.slice(1));
1517
- return n.length === 0 ? null : n.length === 1 ? ot(n[0], t.properties) : At(n, t.properties);
1938
+ const n = Dt(e[0], ...e.slice(1));
1939
+ return n.length === 0 ? null : n.length === 1 ? Be(n[0], t.properties) : rt(n, t.properties);
1518
1940
  }
1519
- var Le = Re;
1520
- function It(o) {
1521
- const t = [...o];
1941
+ var Yt = Xt;
1942
+ function Qe(i) {
1943
+ const t = [...i];
1522
1944
  return t[2] < t[0] && (Math.abs((t[0] + t[2] + 360) / 2) > Math.abs((t[0] - 360 + t[2]) / 2) ? t[0] -= 360 : t[2] += 360), t;
1523
1945
  }
1524
- function kt(o, t) {
1525
- const e = _e(
1526
- H([
1527
- ot([
1946
+ function et(i, t) {
1947
+ const e = Vt(
1948
+ Ce([
1949
+ Be([
1528
1950
  [
1529
1951
  [180, 90],
1530
1952
  [-180, 90],
@@ -1533,56 +1955,56 @@ function kt(o, t) {
1533
1955
  [180, 90]
1534
1956
  ]
1535
1957
  ]),
1536
- o
1958
+ i
1537
1959
  ])
1538
1960
  );
1539
1961
  if (!e)
1540
1962
  return;
1541
1963
  e.properties = { isMask: !0 };
1542
- const n = It(yt(o)), r = (n[2] - n[0]) / 360 / 1e3, i = n[0] < -180, u = n[2] > 180, l = Me(o);
1543
- if (l.features.length > 1 && (i || u))
1544
- for (const c of l.features) {
1545
- const f = It(yt(c));
1546
- if (u && f[0] < -180 + r)
1547
- for (const a of c.geometry.coordinates)
1548
- for (const s of a)
1549
- s[0] += 360 - r;
1550
- if (i && f[2] > 180 - r)
1551
- for (const a of c.geometry.coordinates)
1552
- for (const s of a)
1553
- s[0] -= 360 - r;
1964
+ const n = Qe(Ke(i)), r = (n[2] - n[0]) / 360 / 1e3, f = n[0] < -180, a = n[2] > 180, c = Kt(i);
1965
+ if (c.features.length > 1 && (f || a))
1966
+ for (const E of c.features) {
1967
+ const d = Qe(Ke(E));
1968
+ if (a && d[0] < -180 + r)
1969
+ for (const T of E.geometry.coordinates)
1970
+ for (const b of T)
1971
+ b[0] += 360 - r;
1972
+ if (f && d[2] > 180 - r)
1973
+ for (const T of E.geometry.coordinates)
1974
+ for (const b of T)
1975
+ b[0] -= 360 - r;
1554
1976
  }
1555
1977
  t(
1556
- H([
1557
- l.features.length < 2 ? o : Le(l) ?? o,
1978
+ Ce([
1979
+ c.features.length < 2 ? i : Yt(c) ?? i,
1558
1980
  e
1559
1981
  ])
1560
1982
  );
1561
1983
  }
1562
- const Ct = "EPSG:4326";
1563
- function Ie(o) {
1564
- var i;
1565
- const t = o.getProperties(), { isMask: e } = t, n = (i = o.getGeometry()) == null ? void 0 : i.getType(), r = e ? 0 : n === "LineString" || n === "MultiLineString" ? 3 : 2;
1566
- return new Vt({
1567
- stroke: e ? void 0 : new pt({
1984
+ const tt = "EPSG:4326";
1985
+ function Wt(i) {
1986
+ var f;
1987
+ const t = i.getProperties(), { isMask: e } = t, n = (f = i.getGeometry()) == null ? void 0 : f.getType(), r = e ? 0 : n === "LineString" || n === "MultiLineString" ? 3 : 2;
1988
+ return new wt({
1989
+ stroke: e ? void 0 : new $e({
1568
1990
  color: "#3170fe",
1569
1991
  lineDash: [r, r],
1570
1992
  width: r,
1571
1993
  lineCap: "butt"
1572
1994
  }),
1573
- fill: e ? new gt({
1995
+ fill: e ? new Ve({
1574
1996
  color: "#00000020"
1575
1997
  }) : void 0,
1576
- image: new Yt({
1998
+ image: new xt({
1577
1999
  src: `/icons/marker_${t.isReverse ? "reverse" : t.isSelected ? "selected" : "unselected"}.svg`,
1578
2000
  anchor: [0.5, 1]
1579
2001
  }),
1580
2002
  zIndex: t.isSelected ? 2 : t.isReverse ? 0 : 1,
1581
- text: t.isSelected && t.tooltip ? new jt({
1582
- backgroundFill: new gt({ color: "white" }),
2003
+ text: t.isSelected && t.tooltip ? new Et({
2004
+ backgroundFill: new Ve({ color: "white" }),
1583
2005
  text: t.tooltip,
1584
2006
  offsetY: -40,
1585
- backgroundStroke: new pt({
2007
+ backgroundStroke: new $e({
1586
2008
  color: "white",
1587
2009
  lineJoin: "round",
1588
2010
  width: 3
@@ -1591,162 +2013,162 @@ function Ie(o) {
1591
2013
  }) : void 0
1592
2014
  });
1593
2015
  }
1594
- function Te(o, t = {}, e = {}, n = Ie) {
1595
- let r = -1, i, u, l, c = !1;
1596
- const f = new Tt({
2016
+ function oi(i, t = {}, e = {}, n = Wt) {
2017
+ let r = -1, f, a, c, E = !1;
2018
+ const d = new gt({
1597
2019
  updateWhileAnimating: !0
1598
2020
  });
1599
- o.addLayer(f);
1600
- const a = new Ut({});
1601
- f.setSource(a), f.setStyle(n), o.on("click", (y) => {
1602
- o.forEachFeatureAtPixel(y.pixel, (p) => {
1603
- const d = p.getId();
1604
- if (d)
1605
- return y.stopPropagation(), u == null || u({ type: "markerClick", id: d }), p;
2021
+ i.addLayer(d);
2022
+ const T = new dt({});
2023
+ d.setSource(T), d.setStyle(n), i.on("click", (_) => {
2024
+ i.forEachFeatureAtPixel(_.pixel, (L) => {
2025
+ const A = L.getId();
2026
+ if (A)
2027
+ return _.stopPropagation(), a == null || a({ type: "markerClick", id: A }), L;
1606
2028
  });
1607
- }), o.on("pointermove", (y) => {
1608
- const p = o.forEachFeatureAtPixel(y.pixel, (d) => d.getId());
1609
- i !== p && (i && (u == null || u({
2029
+ }), i.on("pointermove", (_) => {
2030
+ const L = i.forEachFeatureAtPixel(_.pixel, (A) => A.getId());
2031
+ f !== L && (f && (a == null || a({
1610
2032
  type: "markerMouseLeave",
1611
- id: i
1612
- })), p && (u == null || u({
2033
+ id: f
2034
+ })), L && (a == null || a({
1613
2035
  type: "markerMouseEnter",
1614
- id: p
1615
- })), o.getTargetElement().style.cursor = p ? "pointer" : c ? "crosshair" : "", i = p);
2036
+ id: L
2037
+ })), i.getTargetElement().style.cursor = L ? "pointer" : E ? "crosshair" : "", f = L);
1616
2038
  });
1617
- function s() {
1618
- return Qt() ?? o.getView().getProjection();
2039
+ function b() {
2040
+ return mt() ?? i.getView().getProjection();
1619
2041
  }
1620
- function h(y) {
1621
- return y.transform(Ct, s());
2042
+ function P(_) {
2043
+ return _.transform(tt, b());
1622
2044
  }
1623
- const g = (y) => {
1624
- u == null || u({
2045
+ const N = (_) => {
2046
+ a == null || a({
1625
2047
  type: "mapClick",
1626
- coordinates: at(y.coordinate, s())
2048
+ coordinates: Ue(_.coordinate, b())
1627
2049
  });
1628
2050
  };
1629
2051
  return {
1630
- setEventHandler(y) {
1631
- y ? (u = y, o.on("click", g)) : (u = void 0, o.un("click", g));
2052
+ setEventHandler(_) {
2053
+ _ ? (a = _, i.on("click", N)) : (a = void 0, i.un("click", N));
1632
2054
  },
1633
- flyTo(y, p) {
1634
- o.getView().animate({
1635
- center: V(y, s()),
1636
- ...p ? { zoom: p } : {},
2055
+ flyTo(_, L) {
2056
+ i.getView().animate({
2057
+ center: me(_, b()),
2058
+ ...L ? { zoom: L } : {},
1637
2059
  duration: 2e3,
1638
2060
  ...t
1639
2061
  });
1640
2062
  },
1641
- fitBounds(y, p, d) {
1642
- o.getView().fit(qt(y, Ct, s()), {
1643
- padding: [p, p, p, p],
1644
- ...d ? { maxZoom: d } : {},
2063
+ fitBounds(_, L, A) {
2064
+ i.getView().fit(yt(_, tt, b()), {
2065
+ padding: [L, L, L, L],
2066
+ ...A ? { maxZoom: A } : {},
1645
2067
  duration: 2e3,
1646
2068
  ...e
1647
2069
  });
1648
2070
  },
1649
- indicateReverse(y) {
1650
- c = y, o.getTargetElement().style.cursor = y ? "crosshair" : "";
2071
+ indicateReverse(_) {
2072
+ E = _, i.getTargetElement().style.cursor = _ ? "crosshair" : "";
1651
2073
  },
1652
- setReverseMarker(y) {
1653
- l ? y ? l.getGeometry().setCoordinates(
1654
- V(y, s())
1655
- ) : (a.removeFeature(l), l.dispose(), l = void 0) : y && (l = new N(
1656
- new Z(V(y, s()))
1657
- ), l.setProperties({ isReverse: !0 }), a.addFeature(l));
2074
+ setReverseMarker(_) {
2075
+ c ? _ ? c.getGeometry().setCoordinates(
2076
+ me(_, b())
2077
+ ) : (T.removeFeature(c), c.dispose(), c = void 0) : _ && (c = new se(
2078
+ new Re(me(_, b()))
2079
+ ), c.setProperties({ isReverse: !0 }), T.addFeature(c));
1658
2080
  },
1659
- setFeatures(y, p, d) {
1660
- function x(v) {
1661
- var w;
1662
- if (v)
1663
- for (const m of v.features) {
1664
- const E = m.geometry.type === "Polygon" ? new ut(m.geometry.coordinates) : m.geometry.type === "MultiPolygon" ? new ft(m.geometry.coordinates) : null;
1665
- E && a.addFeature(
1666
- new N({
1667
- isMask: !!((w = m.properties) != null && w.isMask),
1668
- geometry: h(E)
2081
+ setFeatures(_, L, A) {
2082
+ function V(S) {
2083
+ var F;
2084
+ if (S)
2085
+ for (const B of S.features) {
2086
+ const Y = B.geometry.type === "Polygon" ? new Fe(B.geometry.coordinates) : B.geometry.type === "MultiPolygon" ? new qe(B.geometry.coordinates) : null;
2087
+ Y && T.addFeature(
2088
+ new se({
2089
+ isMask: !!((F = B.properties) != null && F.isMask),
2090
+ geometry: P(Y)
1669
2091
  })
1670
2092
  );
1671
2093
  }
1672
2094
  }
1673
- a.clear(), l && a.addFeature(l);
1674
- t: if (p) {
1675
- let v = !1;
1676
- if (p.geometry.type === "GeometryCollection") {
1677
- const w = p.geometry.geometries.map(
1678
- (m) => m.type === "Polygon" ? new ut(m.coordinates) : m.type === "MultiPolygon" ? new ft(m.coordinates) : null
1679
- ).filter((m) => !!m);
1680
- if (w.length > 0)
1681
- a.addFeature(
1682
- new N(h(new $t(w)))
1683
- ), v = !0;
2095
+ T.clear(), c && T.addFeature(c);
2096
+ e: if (L) {
2097
+ let S = !1;
2098
+ if (L.geometry.type === "GeometryCollection") {
2099
+ const F = L.geometry.geometries.map(
2100
+ (B) => B.type === "Polygon" ? new Fe(B.coordinates) : B.type === "MultiPolygon" ? new qe(B.coordinates) : null
2101
+ ).filter((B) => !!B);
2102
+ if (F.length > 0)
2103
+ T.addFeature(
2104
+ new se(P(new pt(F)))
2105
+ ), S = !0;
1684
2106
  else
1685
- for (const m of p.geometry.geometries)
1686
- m.type === "LineString" ? (a.addFeature(
1687
- new N(
1688
- h(new ct(m.coordinates))
2107
+ for (const B of L.geometry.geometries)
2108
+ B.type === "LineString" ? (T.addFeature(
2109
+ new se(
2110
+ P(new De(B.coordinates))
1689
2111
  )
1690
- ), v = !0) : m.type === "MultiLineString" && a.addFeature(
1691
- new N(
1692
- h(new ht(m.coordinates))
2112
+ ), S = !0) : B.type === "MultiLineString" && T.addFeature(
2113
+ new se(
2114
+ P(new ze(B.coordinates))
1693
2115
  )
1694
- ), v = !0;
2116
+ ), S = !0;
1695
2117
  }
1696
- if (!v) {
1697
- if (p.geometry.type === "Polygon")
1698
- kt(p, x);
1699
- else if (p.geometry.type === "MultiPolygon")
1700
- kt(p, x);
1701
- else if (p.geometry.type === "LineString") {
1702
- a.addFeature(
1703
- new N(
1704
- h(new ct(p.geometry.coordinates))
2118
+ if (!S) {
2119
+ if (L.geometry.type === "Polygon")
2120
+ et(L, V);
2121
+ else if (L.geometry.type === "MultiPolygon")
2122
+ et(L, V);
2123
+ else if (L.geometry.type === "LineString") {
2124
+ T.addFeature(
2125
+ new se(
2126
+ P(new De(L.geometry.coordinates))
1705
2127
  )
1706
2128
  );
1707
- break t;
1708
- } else if (p.geometry.type === "MultiLineString") {
1709
- a.addFeature(
1710
- new N(
1711
- h(new ht(p.geometry.coordinates))
2129
+ break e;
2130
+ } else if (L.geometry.type === "MultiLineString") {
2131
+ T.addFeature(
2132
+ new se(
2133
+ P(new ze(L.geometry.coordinates))
1712
2134
  )
1713
2135
  );
1714
- break t;
2136
+ break e;
1715
2137
  }
1716
2138
  }
1717
- if (!d && p.geometry.type !== "Point")
1718
- break t;
1719
- a.addFeature(new N(h(new Z(p.center))));
2139
+ if (!A && L.geometry.type !== "Point")
2140
+ break e;
2141
+ T.addFeature(new se(P(new Re(L.center))));
1720
2142
  }
1721
- for (const v of y ?? []) {
1722
- if (v === p)
2143
+ for (const S of _ ?? []) {
2144
+ if (S === L)
1723
2145
  continue;
1724
- const w = new N(
1725
- new Z(V(v.center, s()))
2146
+ const F = new se(
2147
+ new Re(me(S.center, b()))
1726
2148
  );
1727
- w.setId(v.id), w.setProperties({
1728
- fuzzy: !!v.matching_text,
1729
- tooltip: v.place_type[0] === "reverse" ? v.place_name : v.place_name.replace(/,.*/, "")
1730
- }), a.addFeature(w);
2149
+ F.setId(S.id), F.setProperties({
2150
+ fuzzy: !!S.matching_text,
2151
+ tooltip: S.place_type[0] === "reverse" ? S.place_name : S.place_name.replace(/,.*/, "")
2152
+ }), T.addFeature(F);
1731
2153
  }
1732
2154
  },
1733
- setSelectedMarker(y) {
1734
- var x, v, w;
1735
- const p = a.getFeatures(), d = (x = p[0]) != null && x.getProperties().isReverse ? 1 : 0;
1736
- r > -1 && ((v = p[r + d]) == null || v.setProperties({
2155
+ setSelectedMarker(_) {
2156
+ var V, S, F;
2157
+ const L = T.getFeatures(), A = (V = L[0]) != null && V.getProperties().isReverse ? 1 : 0;
2158
+ r > -1 && ((S = L[r + A]) == null || S.setProperties({
1737
2159
  isSelected: !1
1738
- })), y > -1 && ((w = p[y + d]) == null || w.setProperties({
2160
+ })), _ > -1 && ((F = L[_ + A]) == null || F.setProperties({
1739
2161
  isSelected: !0
1740
- })), r = y;
2162
+ })), r = _;
1741
2163
  },
1742
2164
  getCenterAndZoom() {
1743
- const y = o.getView(), p = y.getCenter(), d = y.getZoom();
1744
- if (!(!p || d === void 0))
1745
- return [d, ...at(p, s())];
2165
+ const _ = i.getView(), L = _.getCenter(), A = _.getZoom();
2166
+ if (!(!L || A === void 0))
2167
+ return [A, ...Ue(L, b())];
1746
2168
  }
1747
2169
  };
1748
2170
  }
1749
2171
  export {
1750
- Te as createOpenLayersMapController
2172
+ oi as createOpenLayersMapController
1751
2173
  };
1752
2174
  //# sourceMappingURL=openlayers-controller.js.map