@maplat/tin 1.1.1 → 1.1.2-rc.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.
@@ -2,7 +2,7 @@ function oe(e, t, n = {}) {
2
2
  const i = { type: "Feature" };
3
3
  return (n.id === 0 || n.id) && (i.id = n.id), n.bbox && (i.bbox = n.bbox), i.properties = t || {}, i.geometry = e, i;
4
4
  }
5
- function $t(e, t, n = {}) {
5
+ function Yt(e, t, n = {}) {
6
6
  if (!e)
7
7
  throw new Error("coordinates is required");
8
8
  if (!Array.isArray(e))
@@ -41,14 +41,14 @@ function He(e, t, n = {}) {
41
41
  coordinates: e
42
42
  }, t, n);
43
43
  }
44
- function St(e, t = {}) {
44
+ function Et(e, t = {}) {
45
45
  const n = { type: "FeatureCollection" };
46
46
  return t.id && (n.id = t.id), t.bbox && (n.bbox = t.bbox), n.features = e, n;
47
47
  }
48
48
  function We(e) {
49
49
  return !isNaN(e) && e !== null && !Array.isArray(e);
50
50
  }
51
- function ni(e) {
51
+ function oi(e) {
52
52
  if (!e)
53
53
  throw new Error("coord is required");
54
54
  if (!Array.isArray(e)) {
@@ -61,100 +61,100 @@ function ni(e) {
61
61
  return [...e];
62
62
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
63
63
  }
64
- function ii(e) {
64
+ function si(e) {
65
65
  return e.type === "Feature" ? e.geometry : e;
66
66
  }
67
67
  function ze(e, t, n) {
68
68
  if (e !== null)
69
- for (var i, o, r, s, a, h, l, u = 0, c = 0, f, p = e.type, M = p === "FeatureCollection", w = p === "Feature", I = M ? e.features.length : 1, x = 0; x < I; x++) {
70
- l = M ? (
69
+ for (var i, o, r, s, a, c, f, h = 0, l = 0, u, p = e.type, _ = p === "FeatureCollection", w = p === "Feature", O = _ ? e.features.length : 1, M = 0; M < O; M++) {
70
+ f = _ ? (
71
71
  // @ts-expect-error: Known type conflict
72
- e.features[x].geometry
72
+ e.features[M].geometry
73
73
  ) : w ? (
74
74
  // @ts-expect-error: Known type conflict
75
75
  e.geometry
76
- ) : e, f = l ? l.type === "GeometryCollection" : !1, a = f ? l.geometries.length : 1;
76
+ ) : e, u = f ? f.type === "GeometryCollection" : !1, a = u ? f.geometries.length : 1;
77
77
  for (var m = 0; m < a; m++) {
78
- var _ = 0, d = 0;
79
- if (s = f ? l.geometries[m] : l, s !== null) {
80
- h = s.coordinates;
81
- var v = s.type;
82
- switch (u = n && (v === "Polygon" || v === "MultiPolygon") ? 1 : 0, v) {
78
+ var v = 0, d = 0;
79
+ if (s = u ? f.geometries[m] : f, s !== null) {
80
+ c = s.coordinates;
81
+ var b = s.type;
82
+ switch (h = n && (b === "Polygon" || b === "MultiPolygon") ? 1 : 0, b) {
83
83
  case null:
84
84
  break;
85
85
  case "Point":
86
86
  if (
87
87
  // @ts-expect-error: Known type conflict
88
88
  t(
89
- h,
90
89
  c,
91
- x,
92
- _,
90
+ l,
91
+ M,
92
+ v,
93
93
  d
94
94
  ) === !1
95
95
  )
96
96
  return !1;
97
- c++, _++;
97
+ l++, v++;
98
98
  break;
99
99
  case "LineString":
100
100
  case "MultiPoint":
101
- for (i = 0; i < h.length; i++) {
101
+ for (i = 0; i < c.length; i++) {
102
102
  if (
103
103
  // @ts-expect-error: Known type conflict
104
104
  t(
105
- h[i],
106
- c,
107
- x,
108
- _,
105
+ c[i],
106
+ l,
107
+ M,
108
+ v,
109
109
  d
110
110
  ) === !1
111
111
  )
112
112
  return !1;
113
- c++, v === "MultiPoint" && _++;
113
+ l++, b === "MultiPoint" && v++;
114
114
  }
115
- v === "LineString" && _++;
115
+ b === "LineString" && v++;
116
116
  break;
117
117
  case "Polygon":
118
118
  case "MultiLineString":
119
- for (i = 0; i < h.length; i++) {
120
- for (o = 0; o < h[i].length - u; o++) {
119
+ for (i = 0; i < c.length; i++) {
120
+ for (o = 0; o < c[i].length - h; o++) {
121
121
  if (
122
122
  // @ts-expect-error: Known type conflict
123
123
  t(
124
- h[i][o],
125
- c,
126
- x,
127
- _,
124
+ c[i][o],
125
+ l,
126
+ M,
127
+ v,
128
128
  d
129
129
  ) === !1
130
130
  )
131
131
  return !1;
132
- c++;
132
+ l++;
133
133
  }
134
- v === "MultiLineString" && _++, v === "Polygon" && d++;
134
+ b === "MultiLineString" && v++, b === "Polygon" && d++;
135
135
  }
136
- v === "Polygon" && _++;
136
+ b === "Polygon" && v++;
137
137
  break;
138
138
  case "MultiPolygon":
139
- for (i = 0; i < h.length; i++) {
140
- for (d = 0, o = 0; o < h[i].length; o++) {
141
- for (r = 0; r < h[i][o].length - u; r++) {
139
+ for (i = 0; i < c.length; i++) {
140
+ for (d = 0, o = 0; o < c[i].length; o++) {
141
+ for (r = 0; r < c[i][o].length - h; r++) {
142
142
  if (
143
143
  // @ts-expect-error: Known type conflict
144
144
  t(
145
- h[i][o][r],
146
- c,
147
- x,
148
- _,
145
+ c[i][o][r],
146
+ l,
147
+ M,
148
+ v,
149
149
  d
150
150
  ) === !1
151
151
  )
152
152
  return !1;
153
- c++;
153
+ l++;
154
154
  }
155
155
  d++;
156
156
  }
157
- _++;
157
+ v++;
158
158
  }
159
159
  break;
160
160
  case "GeometryCollection":
@@ -172,35 +172,35 @@ function ze(e, t, n) {
172
172
  }
173
173
  }
174
174
  }
175
- const pt = 11102230246251565e-32, U = 134217729, Rn = (3 + 8 * pt) * pt;
176
- function ft(e, t, n, i, o) {
177
- let r, s, a, h, l = t[0], u = i[0], c = 0, f = 0;
178
- u > l == u > -l ? (r = l, l = t[++c]) : (r = u, u = i[++f]);
175
+ const pt = 11102230246251565e-32, q = 134217729, Ln = (3 + 8 * pt) * pt;
176
+ function ht(e, t, n, i, o) {
177
+ let r, s, a, c, f = t[0], h = i[0], l = 0, u = 0;
178
+ h > f == h > -f ? (r = f, f = t[++l]) : (r = h, h = i[++u]);
179
179
  let p = 0;
180
- if (c < e && f < n)
181
- for (u > l == u > -l ? (s = l + r, a = r - (s - l), l = t[++c]) : (s = u + r, a = r - (s - u), u = i[++f]), r = s, a !== 0 && (o[p++] = a); c < e && f < n; )
182
- u > l == u > -l ? (s = r + l, h = s - r, a = r - (s - h) + (l - h), l = t[++c]) : (s = r + u, h = s - r, a = r - (s - h) + (u - h), u = i[++f]), r = s, a !== 0 && (o[p++] = a);
183
- for (; c < e; )
184
- s = r + l, h = s - r, a = r - (s - h) + (l - h), l = t[++c], r = s, a !== 0 && (o[p++] = a);
185
- for (; f < n; )
186
- s = r + u, h = s - r, a = r - (s - h) + (u - h), u = i[++f], r = s, a !== 0 && (o[p++] = a);
180
+ if (l < e && u < n)
181
+ for (h > f == h > -f ? (s = f + r, a = r - (s - f), f = t[++l]) : (s = h + r, a = r - (s - h), h = i[++u]), r = s, a !== 0 && (o[p++] = a); l < e && u < n; )
182
+ h > f == h > -f ? (s = r + f, c = s - r, a = r - (s - c) + (f - c), f = t[++l]) : (s = r + h, c = s - r, a = r - (s - c) + (h - c), h = i[++u]), r = s, a !== 0 && (o[p++] = a);
183
+ for (; l < e; )
184
+ s = r + f, c = s - r, a = r - (s - c) + (f - c), f = t[++l], r = s, a !== 0 && (o[p++] = a);
185
+ for (; u < n; )
186
+ s = r + h, c = s - r, a = r - (s - c) + (h - c), h = i[++u], r = s, a !== 0 && (o[p++] = a);
187
187
  return (r !== 0 || p === 0) && (o[p++] = r), p;
188
188
  }
189
- function _t(e, t, n, i, o, r, s, a) {
190
- return ft(ft(e, t, n, i, s), s, o, r, a);
189
+ function Mt(e, t, n, i, o, r, s, a) {
190
+ return ht(ht(e, t, n, i, s), s, o, r, a);
191
191
  }
192
- function $(e, t, n, i) {
193
- let o, r, s, a, h, l, u, c, f, p, M;
194
- u = U * n, p = u - (u - n), M = n - p;
192
+ function Y(e, t, n, i) {
193
+ let o, r, s, a, c, f, h, l, u, p, _;
194
+ h = q * n, p = h - (h - n), _ = n - p;
195
195
  let w = t[0];
196
- o = w * n, u = U * w, c = u - (u - w), f = w - c, s = f * M - (o - c * p - f * p - c * M);
197
- let I = 0;
198
- s !== 0 && (i[I++] = s);
199
- for (let x = 1; x < e; x++)
200
- w = t[x], a = w * n, u = U * w, c = u - (u - w), f = w - c, h = f * M - (a - c * p - f * p - c * M), r = o + h, l = r - o, s = o - (r - l) + (h - l), s !== 0 && (i[I++] = s), o = a + r, s = r - (o - a), s !== 0 && (i[I++] = s);
201
- return (o !== 0 || I === 0) && (i[I++] = o), I;
202
- }
203
- function $n(e, t) {
196
+ o = w * n, h = q * w, l = h - (h - w), u = w - l, s = u * _ - (o - l * p - u * p - l * _);
197
+ let O = 0;
198
+ s !== 0 && (i[O++] = s);
199
+ for (let M = 1; M < e; M++)
200
+ w = t[M], a = w * n, h = q * w, l = h - (h - w), u = w - l, c = u * _ - (a - l * p - u * p - l * _), r = o + c, f = r - o, s = o - (r - f) + (c - f), s !== 0 && (i[O++] = s), o = a + r, s = r - (o - a), s !== 0 && (i[O++] = s);
201
+ return (o !== 0 || O === 0) && (i[O++] = o), O;
202
+ }
203
+ function Vn(e, t) {
204
204
  let n = t[0];
205
205
  for (let i = 1; i < e; i++) n += t[i];
206
206
  return n;
@@ -208,304 +208,304 @@ function $n(e, t) {
208
208
  function tt(e) {
209
209
  return new Float64Array(e);
210
210
  }
211
- const ri = (3 + 16 * pt) * pt, oi = (2 + 12 * pt) * pt, si = (9 + 64 * pt) * pt * pt, zt = tt(4), Ze = tt(8), tn = tt(12), en = tt(16), mt = tt(4);
212
- function ai(e, t, n, i, o, r, s) {
213
- let a, h, l, u, c, f, p, M, w, I, x, m, _, d, v, g, k, S;
214
- const A = e - o, O = n - o, B = t - r, X = i - r;
215
- d = A * X, f = U * A, p = f - (f - A), M = A - p, f = U * X, w = f - (f - X), I = X - w, v = M * I - (d - p * w - M * w - p * I), g = B * O, f = U * B, p = f - (f - B), M = B - p, f = U * O, w = f - (f - O), I = O - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, zt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, zt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, zt[2] = m - (S - c) + (x - c), zt[3] = S;
216
- let Y = $n(4, zt), y = oi * s;
217
- if (Y >= y || -Y >= y || (c = e - A, a = e - (A + c) + (c - o), c = n - O, l = n - (O + c) + (c - o), c = t - B, h = t - (B + c) + (c - r), c = i - X, u = i - (X + c) + (c - r), a === 0 && h === 0 && l === 0 && u === 0) || (y = si * s + Rn * Math.abs(Y), Y += A * u + X * a - (B * l + O * h), Y >= y || -Y >= y)) return Y;
218
- d = a * X, f = U * a, p = f - (f - a), M = a - p, f = U * X, w = f - (f - X), I = X - w, v = M * I - (d - p * w - M * w - p * I), g = h * O, f = U * h, p = f - (f - h), M = h - p, f = U * O, w = f - (f - O), I = O - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, mt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, mt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, mt[2] = m - (S - c) + (x - c), mt[3] = S;
219
- const P = ft(4, zt, 4, mt, Ze);
220
- d = A * u, f = U * A, p = f - (f - A), M = A - p, f = U * u, w = f - (f - u), I = u - w, v = M * I - (d - p * w - M * w - p * I), g = B * l, f = U * B, p = f - (f - B), M = B - p, f = U * l, w = f - (f - l), I = l - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, mt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, mt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, mt[2] = m - (S - c) + (x - c), mt[3] = S;
221
- const E = ft(P, Ze, 4, mt, tn);
222
- d = a * u, f = U * a, p = f - (f - a), M = a - p, f = U * u, w = f - (f - u), I = u - w, v = M * I - (d - p * w - M * w - p * I), g = h * l, f = U * h, p = f - (f - h), M = h - p, f = U * l, w = f - (f - l), I = l - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, mt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, mt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, mt[2] = m - (S - c) + (x - c), mt[3] = S;
223
- const T = ft(E, tn, 4, mt, en);
211
+ const ai = (3 + 16 * pt) * pt, ci = (2 + 12 * pt) * pt, li = (9 + 64 * pt) * pt * pt, zt = tt(4), Ze = tt(8), tn = tt(12), en = tt(16), mt = tt(4);
212
+ function fi(e, t, n, i, o, r, s) {
213
+ let a, c, f, h, l, u, p, _, w, O, M, m, v, d, b, g, E, S;
214
+ const k = e - o, P = n - o, N = t - r, C = i - r;
215
+ d = k * C, u = q * k, p = u - (u - k), _ = k - p, u = q * C, w = u - (u - C), O = C - w, b = _ * O - (d - p * w - _ * w - p * O), g = N * P, u = q * N, p = u - (u - N), _ = N - p, u = q * P, w = u - (u - P), O = P - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, zt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, zt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, zt[2] = m - (S - l) + (M - l), zt[3] = S;
216
+ let F = Vn(4, zt), y = ci * s;
217
+ if (F >= y || -F >= y || (l = e - k, a = e - (k + l) + (l - o), l = n - P, f = n - (P + l) + (l - o), l = t - N, c = t - (N + l) + (l - r), l = i - C, h = i - (C + l) + (l - r), a === 0 && c === 0 && f === 0 && h === 0) || (y = li * s + Ln * Math.abs(F), F += k * h + C * a - (N * f + P * c), F >= y || -F >= y)) return F;
218
+ d = a * C, u = q * a, p = u - (u - a), _ = a - p, u = q * C, w = u - (u - C), O = C - w, b = _ * O - (d - p * w - _ * w - p * O), g = c * P, u = q * c, p = u - (u - c), _ = c - p, u = q * P, w = u - (u - P), O = P - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, mt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, mt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, mt[2] = m - (S - l) + (M - l), mt[3] = S;
219
+ const I = ht(4, zt, 4, mt, Ze);
220
+ d = k * h, u = q * k, p = u - (u - k), _ = k - p, u = q * h, w = u - (u - h), O = h - w, b = _ * O - (d - p * w - _ * w - p * O), g = N * f, u = q * N, p = u - (u - N), _ = N - p, u = q * f, w = u - (u - f), O = f - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, mt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, mt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, mt[2] = m - (S - l) + (M - l), mt[3] = S;
221
+ const A = ht(I, Ze, 4, mt, tn);
222
+ d = a * h, u = q * a, p = u - (u - a), _ = a - p, u = q * h, w = u - (u - h), O = h - w, b = _ * O - (d - p * w - _ * w - p * O), g = c * f, u = q * c, p = u - (u - c), _ = c - p, u = q * f, w = u - (u - f), O = f - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, mt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, mt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, mt[2] = m - (S - l) + (M - l), mt[3] = S;
223
+ const T = ht(A, tn, 4, mt, en);
224
224
  return en[T - 1];
225
225
  }
226
- function Pt(e, t, n, i, o, r) {
227
- const s = (t - r) * (n - o), a = (e - o) * (i - r), h = s - a, l = Math.abs(s + a);
228
- return Math.abs(h) >= ri * l ? h : -ai(e, t, n, i, o, r, l);
226
+ function Ot(e, t, n, i, o, r) {
227
+ const s = (t - r) * (n - o), a = (e - o) * (i - r), c = s - a, f = Math.abs(s + a);
228
+ return Math.abs(c) >= ai * f ? c : -fi(e, t, n, i, o, r, f);
229
229
  }
230
- const ci = (10 + 96 * pt) * pt, li = (4 + 48 * pt) * pt, hi = (44 + 576 * pt) * pt * pt, Ct = tt(4), Dt = tt(4), Ft = tt(4), kt = tt(4), Et = tt(4), At = tt(4), gt = tt(4), wt = tt(4), Pe = tt(8), Oe = tt(8), Be = tt(8), Ne = tt(8), Te = tt(8), Xe = tt(8), ue = tt(8), de = tt(8), pe = tt(8), Lt = tt(4), Vt = tt(4), jt = tt(4), z = tt(8), K = tt(16), nt = tt(16), it = tt(16), et = tt(32), Yt = tt(32), at = tt(48), bt = tt(64);
231
- let Qt = tt(1152), Ce = tt(1152);
230
+ const hi = (10 + 96 * pt) * pt, ui = (4 + 48 * pt) * pt, di = (44 + 576 * pt) * pt * pt, Xt = tt(4), $t = tt(4), Dt = tt(4), kt = tt(4), At = tt(4), It = tt(4), gt = tt(4), wt = tt(4), Oe = tt(8), Pe = tt(8), Ne = tt(8), Be = tt(8), Te = tt(8), Ce = tt(8), ue = tt(8), de = tt(8), pe = tt(8), Lt = tt(4), Vt = tt(4), Ut = tt(4), z = tt(8), K = tt(16), nt = tt(16), it = tt(16), et = tt(32), Ft = tt(32), at = tt(48), bt = tt(64);
231
+ let Qt = tt(1152), Xe = tt(1152);
232
232
  function ct(e, t, n) {
233
- e = ft(e, Qt, t, n, Ce);
233
+ e = ht(e, Qt, t, n, Xe);
234
234
  const i = Qt;
235
- return Qt = Ce, Ce = i, e;
236
- }
237
- function fi(e, t, n, i, o, r, s, a, h) {
238
- let l, u, c, f, p, M, w, I, x, m, _, d, v, g, k, S, A, O, B, X, Y, y, P, E, T, C, F, b, N, D, R, L, V, q, j;
239
- const J = e - s, G = n - s, Q = o - s, H = t - a, Z = i - a, W = r - a;
240
- R = G * W, P = U * G, E = P - (P - G), T = G - E, P = U * W, C = P - (P - W), F = W - C, L = T * F - (R - E * C - T * C - E * F), V = Q * Z, P = U * Q, E = P - (P - Q), T = Q - E, P = U * Z, C = P - (P - Z), F = Z - C, q = T * F - (V - E * C - T * C - E * F), b = L - q, y = L - b, Ct[0] = L - (b + y) + (y - q), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D - V, y = D - b, Ct[1] = D - (b + y) + (y - V), j = N + b, y = j - N, Ct[2] = N - (j - y) + (b - y), Ct[3] = j, R = Q * H, P = U * Q, E = P - (P - Q), T = Q - E, P = U * H, C = P - (P - H), F = H - C, L = T * F - (R - E * C - T * C - E * F), V = J * W, P = U * J, E = P - (P - J), T = J - E, P = U * W, C = P - (P - W), F = W - C, q = T * F - (V - E * C - T * C - E * F), b = L - q, y = L - b, Dt[0] = L - (b + y) + (y - q), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D - V, y = D - b, Dt[1] = D - (b + y) + (y - V), j = N + b, y = j - N, Dt[2] = N - (j - y) + (b - y), Dt[3] = j, R = J * Z, P = U * J, E = P - (P - J), T = J - E, P = U * Z, C = P - (P - Z), F = Z - C, L = T * F - (R - E * C - T * C - E * F), V = G * H, P = U * G, E = P - (P - G), T = G - E, P = U * H, C = P - (P - H), F = H - C, q = T * F - (V - E * C - T * C - E * F), b = L - q, y = L - b, Ft[0] = L - (b + y) + (y - q), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D - V, y = D - b, Ft[1] = D - (b + y) + (y - V), j = N + b, y = j - N, Ft[2] = N - (j - y) + (b - y), Ft[3] = j, l = ft(
241
- ft(
242
- ft(
243
- $($(4, Ct, J, z), z, J, K),
235
+ return Qt = Xe, Xe = i, e;
236
+ }
237
+ function pi(e, t, n, i, o, r, s, a, c) {
238
+ let f, h, l, u, p, _, w, O, M, m, v, d, b, g, E, S, k, P, N, C, F, y, I, A, T, X, D, x, B, $, R, L, V, j, U;
239
+ const G = e - s, J = n - s, Q = o - s, H = t - a, Z = i - a, W = r - a;
240
+ R = J * W, I = q * J, A = I - (I - J), T = J - A, I = q * W, X = I - (I - W), D = W - X, L = T * D - (R - A * X - T * X - A * D), V = Q * Z, I = q * Q, A = I - (I - Q), T = Q - A, I = q * Z, X = I - (I - Z), D = Z - X, j = T * D - (V - A * X - T * X - A * D), x = L - j, y = L - x, Xt[0] = L - (x + y) + (y - j), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ - V, y = $ - x, Xt[1] = $ - (x + y) + (y - V), U = B + x, y = U - B, Xt[2] = B - (U - y) + (x - y), Xt[3] = U, R = Q * H, I = q * Q, A = I - (I - Q), T = Q - A, I = q * H, X = I - (I - H), D = H - X, L = T * D - (R - A * X - T * X - A * D), V = G * W, I = q * G, A = I - (I - G), T = G - A, I = q * W, X = I - (I - W), D = W - X, j = T * D - (V - A * X - T * X - A * D), x = L - j, y = L - x, $t[0] = L - (x + y) + (y - j), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ - V, y = $ - x, $t[1] = $ - (x + y) + (y - V), U = B + x, y = U - B, $t[2] = B - (U - y) + (x - y), $t[3] = U, R = G * Z, I = q * G, A = I - (I - G), T = G - A, I = q * Z, X = I - (I - Z), D = Z - X, L = T * D - (R - A * X - T * X - A * D), V = J * H, I = q * J, A = I - (I - J), T = J - A, I = q * H, X = I - (I - H), D = H - X, j = T * D - (V - A * X - T * X - A * D), x = L - j, y = L - x, Dt[0] = L - (x + y) + (y - j), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ - V, y = $ - x, Dt[1] = $ - (x + y) + (y - V), U = B + x, y = U - B, Dt[2] = B - (U - y) + (x - y), Dt[3] = U, f = ht(
241
+ ht(
242
+ ht(
243
+ Y(Y(4, Xt, G, z), z, G, K),
244
244
  K,
245
- $($(4, Ct, H, z), z, H, nt),
245
+ Y(Y(4, Xt, H, z), z, H, nt),
246
246
  nt,
247
247
  et
248
248
  ),
249
249
  et,
250
- ft(
251
- $($(4, Dt, G, z), z, G, K),
250
+ ht(
251
+ Y(Y(4, $t, J, z), z, J, K),
252
252
  K,
253
- $($(4, Dt, Z, z), z, Z, nt),
253
+ Y(Y(4, $t, Z, z), z, Z, nt),
254
254
  nt,
255
- Yt
255
+ Ft
256
256
  ),
257
- Yt,
257
+ Ft,
258
258
  bt
259
259
  ),
260
260
  bt,
261
- ft(
262
- $($(4, Ft, Q, z), z, Q, K),
261
+ ht(
262
+ Y(Y(4, Dt, Q, z), z, Q, K),
263
263
  K,
264
- $($(4, Ft, W, z), z, W, nt),
264
+ Y(Y(4, Dt, W, z), z, W, nt),
265
265
  nt,
266
266
  et
267
267
  ),
268
268
  et,
269
269
  Qt
270
270
  );
271
- let st = $n(l, Qt), lt = li * h;
272
- if (st >= lt || -st >= lt || (y = e - J, u = e - (J + y) + (y - s), y = t - H, p = t - (H + y) + (y - a), y = n - G, c = n - (G + y) + (y - s), y = i - Z, M = i - (Z + y) + (y - a), y = o - Q, f = o - (Q + y) + (y - s), y = r - W, w = r - (W + y) + (y - a), u === 0 && c === 0 && f === 0 && p === 0 && M === 0 && w === 0) || (lt = hi * h + Rn * Math.abs(st), st += (J * J + H * H) * (G * w + W * c - (Z * f + Q * M)) + 2 * (J * u + H * p) * (G * W - Z * Q) + ((G * G + Z * Z) * (Q * p + H * f - (W * u + J * w)) + 2 * (G * c + Z * M) * (Q * H - W * J)) + ((Q * Q + W * W) * (J * M + Z * u - (H * c + G * p)) + 2 * (Q * f + W * w) * (J * Z - H * G)), st >= lt || -st >= lt))
271
+ let st = Vn(f, Qt), ft = ui * c;
272
+ if (st >= ft || -st >= ft || (y = e - G, h = e - (G + y) + (y - s), y = t - H, p = t - (H + y) + (y - a), y = n - J, l = n - (J + y) + (y - s), y = i - Z, _ = i - (Z + y) + (y - a), y = o - Q, u = o - (Q + y) + (y - s), y = r - W, w = r - (W + y) + (y - a), h === 0 && l === 0 && u === 0 && p === 0 && _ === 0 && w === 0) || (ft = di * c + Ln * Math.abs(st), st += (G * G + H * H) * (J * w + W * l - (Z * u + Q * _)) + 2 * (G * h + H * p) * (J * W - Z * Q) + ((J * J + Z * Z) * (Q * p + H * u - (W * h + G * w)) + 2 * (J * l + Z * _) * (Q * H - W * G)) + ((Q * Q + W * W) * (G * _ + Z * h - (H * l + J * p)) + 2 * (Q * u + W * w) * (G * Z - H * J)), st >= ft || -st >= ft))
273
273
  return st;
274
- if ((c !== 0 || M !== 0 || f !== 0 || w !== 0) && (R = J * J, P = U * J, E = P - (P - J), T = J - E, L = T * T - (R - E * E - (E + E) * T), V = H * H, P = U * H, E = P - (P - H), T = H - E, q = T * T - (V - E * E - (E + E) * T), b = L + q, y = b - L, kt[0] = L - (b - y) + (q - y), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D + V, y = b - D, kt[1] = D - (b - y) + (V - y), j = N + b, y = j - N, kt[2] = N - (j - y) + (b - y), kt[3] = j), (f !== 0 || w !== 0 || u !== 0 || p !== 0) && (R = G * G, P = U * G, E = P - (P - G), T = G - E, L = T * T - (R - E * E - (E + E) * T), V = Z * Z, P = U * Z, E = P - (P - Z), T = Z - E, q = T * T - (V - E * E - (E + E) * T), b = L + q, y = b - L, Et[0] = L - (b - y) + (q - y), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D + V, y = b - D, Et[1] = D - (b - y) + (V - y), j = N + b, y = j - N, Et[2] = N - (j - y) + (b - y), Et[3] = j), (u !== 0 || p !== 0 || c !== 0 || M !== 0) && (R = Q * Q, P = U * Q, E = P - (P - Q), T = Q - E, L = T * T - (R - E * E - (E + E) * T), V = W * W, P = U * W, E = P - (P - W), T = W - E, q = T * T - (V - E * E - (E + E) * T), b = L + q, y = b - L, At[0] = L - (b - y) + (q - y), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D + V, y = b - D, At[1] = D - (b - y) + (V - y), j = N + b, y = j - N, At[2] = N - (j - y) + (b - y), At[3] = j), u !== 0 && (I = $(4, Ct, u, Pe), l = ct(l, _t(
275
- $(I, Pe, 2 * J, K),
274
+ if ((l !== 0 || _ !== 0 || u !== 0 || w !== 0) && (R = G * G, I = q * G, A = I - (I - G), T = G - A, L = T * T - (R - A * A - (A + A) * T), V = H * H, I = q * H, A = I - (I - H), T = H - A, j = T * T - (V - A * A - (A + A) * T), x = L + j, y = x - L, kt[0] = L - (x - y) + (j - y), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ + V, y = x - $, kt[1] = $ - (x - y) + (V - y), U = B + x, y = U - B, kt[2] = B - (U - y) + (x - y), kt[3] = U), (u !== 0 || w !== 0 || h !== 0 || p !== 0) && (R = J * J, I = q * J, A = I - (I - J), T = J - A, L = T * T - (R - A * A - (A + A) * T), V = Z * Z, I = q * Z, A = I - (I - Z), T = Z - A, j = T * T - (V - A * A - (A + A) * T), x = L + j, y = x - L, At[0] = L - (x - y) + (j - y), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ + V, y = x - $, At[1] = $ - (x - y) + (V - y), U = B + x, y = U - B, At[2] = B - (U - y) + (x - y), At[3] = U), (h !== 0 || p !== 0 || l !== 0 || _ !== 0) && (R = Q * Q, I = q * Q, A = I - (I - Q), T = Q - A, L = T * T - (R - A * A - (A + A) * T), V = W * W, I = q * W, A = I - (I - W), T = W - A, j = T * T - (V - A * A - (A + A) * T), x = L + j, y = x - L, It[0] = L - (x - y) + (j - y), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ + V, y = x - $, It[1] = $ - (x - y) + (V - y), U = B + x, y = U - B, It[2] = B - (U - y) + (x - y), It[3] = U), h !== 0 && (O = Y(4, Xt, h, Oe), f = ct(f, Mt(
275
+ Y(O, Oe, 2 * G, K),
276
276
  K,
277
- $($(4, At, u, z), z, Z, nt),
277
+ Y(Y(4, It, h, z), z, Z, nt),
278
278
  nt,
279
- $($(4, Et, u, z), z, -W, it),
279
+ Y(Y(4, At, h, z), z, -W, it),
280
280
  it,
281
281
  et,
282
282
  at
283
- ), at)), p !== 0 && (x = $(4, Ct, p, Oe), l = ct(l, _t(
284
- $(x, Oe, 2 * H, K),
283
+ ), at)), p !== 0 && (M = Y(4, Xt, p, Pe), f = ct(f, Mt(
284
+ Y(M, Pe, 2 * H, K),
285
285
  K,
286
- $($(4, Et, p, z), z, Q, nt),
286
+ Y(Y(4, At, p, z), z, Q, nt),
287
287
  nt,
288
- $($(4, At, p, z), z, -G, it),
288
+ Y(Y(4, It, p, z), z, -J, it),
289
289
  it,
290
290
  et,
291
291
  at
292
- ), at)), c !== 0 && (m = $(4, Dt, c, Be), l = ct(l, _t(
293
- $(m, Be, 2 * G, K),
292
+ ), at)), l !== 0 && (m = Y(4, $t, l, Ne), f = ct(f, Mt(
293
+ Y(m, Ne, 2 * J, K),
294
294
  K,
295
- $($(4, kt, c, z), z, W, nt),
295
+ Y(Y(4, kt, l, z), z, W, nt),
296
296
  nt,
297
- $($(4, At, c, z), z, -H, it),
297
+ Y(Y(4, It, l, z), z, -H, it),
298
298
  it,
299
299
  et,
300
300
  at
301
- ), at)), M !== 0 && (_ = $(4, Dt, M, Ne), l = ct(l, _t(
302
- $(_, Ne, 2 * Z, K),
301
+ ), at)), _ !== 0 && (v = Y(4, $t, _, Be), f = ct(f, Mt(
302
+ Y(v, Be, 2 * Z, K),
303
303
  K,
304
- $($(4, At, M, z), z, J, nt),
304
+ Y(Y(4, It, _, z), z, G, nt),
305
305
  nt,
306
- $($(4, kt, M, z), z, -Q, it),
306
+ Y(Y(4, kt, _, z), z, -Q, it),
307
307
  it,
308
308
  et,
309
309
  at
310
- ), at)), f !== 0 && (d = $(4, Ft, f, Te), l = ct(l, _t(
311
- $(d, Te, 2 * Q, K),
310
+ ), at)), u !== 0 && (d = Y(4, Dt, u, Te), f = ct(f, Mt(
311
+ Y(d, Te, 2 * Q, K),
312
312
  K,
313
- $($(4, Et, f, z), z, H, nt),
313
+ Y(Y(4, At, u, z), z, H, nt),
314
314
  nt,
315
- $($(4, kt, f, z), z, -Z, it),
315
+ Y(Y(4, kt, u, z), z, -Z, it),
316
316
  it,
317
317
  et,
318
318
  at
319
- ), at)), w !== 0 && (v = $(4, Ft, w, Xe), l = ct(l, _t(
320
- $(v, Xe, 2 * W, K),
319
+ ), at)), w !== 0 && (b = Y(4, Dt, w, Ce), f = ct(f, Mt(
320
+ Y(b, Ce, 2 * W, K),
321
321
  K,
322
- $($(4, kt, w, z), z, G, nt),
322
+ Y(Y(4, kt, w, z), z, J, nt),
323
323
  nt,
324
- $($(4, Et, w, z), z, -J, it),
324
+ Y(Y(4, At, w, z), z, -G, it),
325
325
  it,
326
326
  et,
327
327
  at
328
- ), at)), u !== 0 || p !== 0) {
329
- if (c !== 0 || M !== 0 || f !== 0 || w !== 0 ? (R = c * W, P = U * c, E = P - (P - c), T = c - E, P = U * W, C = P - (P - W), F = W - C, L = T * F - (R - E * C - T * C - E * F), V = G * w, P = U * G, E = P - (P - G), T = G - E, P = U * w, C = P - (P - w), F = w - C, q = T * F - (V - E * C - T * C - E * F), b = L + q, y = b - L, gt[0] = L - (b - y) + (q - y), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D + V, y = b - D, gt[1] = D - (b - y) + (V - y), j = N + b, y = j - N, gt[2] = N - (j - y) + (b - y), gt[3] = j, R = f * -Z, P = U * f, E = P - (P - f), T = f - E, P = U * -Z, C = P - (P - -Z), F = -Z - C, L = T * F - (R - E * C - T * C - E * F), V = Q * -M, P = U * Q, E = P - (P - Q), T = Q - E, P = U * -M, C = P - (P - -M), F = -M - C, q = T * F - (V - E * C - T * C - E * F), b = L + q, y = b - L, wt[0] = L - (b - y) + (q - y), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D + V, y = b - D, wt[1] = D - (b - y) + (V - y), j = N + b, y = j - N, wt[2] = N - (j - y) + (b - y), wt[3] = j, k = ft(4, gt, 4, wt, de), R = c * w, P = U * c, E = P - (P - c), T = c - E, P = U * w, C = P - (P - w), F = w - C, L = T * F - (R - E * C - T * C - E * F), V = f * M, P = U * f, E = P - (P - f), T = f - E, P = U * M, C = P - (P - M), F = M - C, q = T * F - (V - E * C - T * C - E * F), b = L - q, y = L - b, Vt[0] = L - (b + y) + (y - q), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D - V, y = D - b, Vt[1] = D - (b + y) + (y - V), j = N + b, y = j - N, Vt[2] = N - (j - y) + (b - y), Vt[3] = j, O = 4) : (de[0] = 0, k = 1, Vt[0] = 0, O = 1), u !== 0) {
330
- const rt = $(k, de, u, it);
331
- l = ct(l, ft(
332
- $(I, Pe, u, K),
328
+ ), at)), h !== 0 || p !== 0) {
329
+ if (l !== 0 || _ !== 0 || u !== 0 || w !== 0 ? (R = l * W, I = q * l, A = I - (I - l), T = l - A, I = q * W, X = I - (I - W), D = W - X, L = T * D - (R - A * X - T * X - A * D), V = J * w, I = q * J, A = I - (I - J), T = J - A, I = q * w, X = I - (I - w), D = w - X, j = T * D - (V - A * X - T * X - A * D), x = L + j, y = x - L, gt[0] = L - (x - y) + (j - y), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ + V, y = x - $, gt[1] = $ - (x - y) + (V - y), U = B + x, y = U - B, gt[2] = B - (U - y) + (x - y), gt[3] = U, R = u * -Z, I = q * u, A = I - (I - u), T = u - A, I = q * -Z, X = I - (I - -Z), D = -Z - X, L = T * D - (R - A * X - T * X - A * D), V = Q * -_, I = q * Q, A = I - (I - Q), T = Q - A, I = q * -_, X = I - (I - -_), D = -_ - X, j = T * D - (V - A * X - T * X - A * D), x = L + j, y = x - L, wt[0] = L - (x - y) + (j - y), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ + V, y = x - $, wt[1] = $ - (x - y) + (V - y), U = B + x, y = U - B, wt[2] = B - (U - y) + (x - y), wt[3] = U, E = ht(4, gt, 4, wt, de), R = l * w, I = q * l, A = I - (I - l), T = l - A, I = q * w, X = I - (I - w), D = w - X, L = T * D - (R - A * X - T * X - A * D), V = u * _, I = q * u, A = I - (I - u), T = u - A, I = q * _, X = I - (I - _), D = _ - X, j = T * D - (V - A * X - T * X - A * D), x = L - j, y = L - x, Vt[0] = L - (x + y) + (y - j), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ - V, y = $ - x, Vt[1] = $ - (x + y) + (y - V), U = B + x, y = U - B, Vt[2] = B - (U - y) + (x - y), Vt[3] = U, P = 4) : (de[0] = 0, E = 1, Vt[0] = 0, P = 1), h !== 0) {
330
+ const rt = Y(E, de, h, it);
331
+ f = ct(f, ht(
332
+ Y(O, Oe, h, K),
333
333
  K,
334
- $(rt, it, 2 * J, et),
334
+ Y(rt, it, 2 * G, et),
335
335
  et,
336
336
  at
337
337
  ), at);
338
- const ot = $(O, Vt, u, z);
339
- l = ct(l, _t(
340
- $(ot, z, 2 * J, K),
338
+ const ot = Y(P, Vt, h, z);
339
+ f = ct(f, Mt(
340
+ Y(ot, z, 2 * G, K),
341
341
  K,
342
- $(ot, z, u, nt),
342
+ Y(ot, z, h, nt),
343
343
  nt,
344
- $(rt, it, u, et),
344
+ Y(rt, it, h, et),
345
345
  et,
346
- Yt,
346
+ Ft,
347
347
  bt
348
- ), bt), M !== 0 && (l = ct(l, $($(4, At, u, z), z, M, K), K)), w !== 0 && (l = ct(l, $($(4, Et, -u, z), z, w, K), K));
348
+ ), bt), _ !== 0 && (f = ct(f, Y(Y(4, It, h, z), z, _, K), K)), w !== 0 && (f = ct(f, Y(Y(4, At, -h, z), z, w, K), K));
349
349
  }
350
350
  if (p !== 0) {
351
- const rt = $(k, de, p, it);
352
- l = ct(l, ft(
353
- $(x, Oe, p, K),
351
+ const rt = Y(E, de, p, it);
352
+ f = ct(f, ht(
353
+ Y(M, Pe, p, K),
354
354
  K,
355
- $(rt, it, 2 * H, et),
355
+ Y(rt, it, 2 * H, et),
356
356
  et,
357
357
  at
358
358
  ), at);
359
- const ot = $(O, Vt, p, z);
360
- l = ct(l, _t(
361
- $(ot, z, 2 * H, K),
359
+ const ot = Y(P, Vt, p, z);
360
+ f = ct(f, Mt(
361
+ Y(ot, z, 2 * H, K),
362
362
  K,
363
- $(ot, z, p, nt),
363
+ Y(ot, z, p, nt),
364
364
  nt,
365
- $(rt, it, p, et),
365
+ Y(rt, it, p, et),
366
366
  et,
367
- Yt,
367
+ Ft,
368
368
  bt
369
369
  ), bt);
370
370
  }
371
371
  }
372
- if (c !== 0 || M !== 0) {
373
- if (f !== 0 || w !== 0 || u !== 0 || p !== 0 ? (R = f * H, P = U * f, E = P - (P - f), T = f - E, P = U * H, C = P - (P - H), F = H - C, L = T * F - (R - E * C - T * C - E * F), V = Q * p, P = U * Q, E = P - (P - Q), T = Q - E, P = U * p, C = P - (P - p), F = p - C, q = T * F - (V - E * C - T * C - E * F), b = L + q, y = b - L, gt[0] = L - (b - y) + (q - y), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D + V, y = b - D, gt[1] = D - (b - y) + (V - y), j = N + b, y = j - N, gt[2] = N - (j - y) + (b - y), gt[3] = j, X = -W, Y = -w, R = u * X, P = U * u, E = P - (P - u), T = u - E, P = U * X, C = P - (P - X), F = X - C, L = T * F - (R - E * C - T * C - E * F), V = J * Y, P = U * J, E = P - (P - J), T = J - E, P = U * Y, C = P - (P - Y), F = Y - C, q = T * F - (V - E * C - T * C - E * F), b = L + q, y = b - L, wt[0] = L - (b - y) + (q - y), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D + V, y = b - D, wt[1] = D - (b - y) + (V - y), j = N + b, y = j - N, wt[2] = N - (j - y) + (b - y), wt[3] = j, S = ft(4, gt, 4, wt, pe), R = f * p, P = U * f, E = P - (P - f), T = f - E, P = U * p, C = P - (P - p), F = p - C, L = T * F - (R - E * C - T * C - E * F), V = u * w, P = U * u, E = P - (P - u), T = u - E, P = U * w, C = P - (P - w), F = w - C, q = T * F - (V - E * C - T * C - E * F), b = L - q, y = L - b, jt[0] = L - (b + y) + (y - q), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D - V, y = D - b, jt[1] = D - (b + y) + (y - V), j = N + b, y = j - N, jt[2] = N - (j - y) + (b - y), jt[3] = j, B = 4) : (pe[0] = 0, S = 1, jt[0] = 0, B = 1), c !== 0) {
374
- const rt = $(S, pe, c, it);
375
- l = ct(l, ft(
376
- $(m, Be, c, K),
372
+ if (l !== 0 || _ !== 0) {
373
+ if (u !== 0 || w !== 0 || h !== 0 || p !== 0 ? (R = u * H, I = q * u, A = I - (I - u), T = u - A, I = q * H, X = I - (I - H), D = H - X, L = T * D - (R - A * X - T * X - A * D), V = Q * p, I = q * Q, A = I - (I - Q), T = Q - A, I = q * p, X = I - (I - p), D = p - X, j = T * D - (V - A * X - T * X - A * D), x = L + j, y = x - L, gt[0] = L - (x - y) + (j - y), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ + V, y = x - $, gt[1] = $ - (x - y) + (V - y), U = B + x, y = U - B, gt[2] = B - (U - y) + (x - y), gt[3] = U, C = -W, F = -w, R = h * C, I = q * h, A = I - (I - h), T = h - A, I = q * C, X = I - (I - C), D = C - X, L = T * D - (R - A * X - T * X - A * D), V = G * F, I = q * G, A = I - (I - G), T = G - A, I = q * F, X = I - (I - F), D = F - X, j = T * D - (V - A * X - T * X - A * D), x = L + j, y = x - L, wt[0] = L - (x - y) + (j - y), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ + V, y = x - $, wt[1] = $ - (x - y) + (V - y), U = B + x, y = U - B, wt[2] = B - (U - y) + (x - y), wt[3] = U, S = ht(4, gt, 4, wt, pe), R = u * p, I = q * u, A = I - (I - u), T = u - A, I = q * p, X = I - (I - p), D = p - X, L = T * D - (R - A * X - T * X - A * D), V = h * w, I = q * h, A = I - (I - h), T = h - A, I = q * w, X = I - (I - w), D = w - X, j = T * D - (V - A * X - T * X - A * D), x = L - j, y = L - x, Ut[0] = L - (x + y) + (y - j), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ - V, y = $ - x, Ut[1] = $ - (x + y) + (y - V), U = B + x, y = U - B, Ut[2] = B - (U - y) + (x - y), Ut[3] = U, N = 4) : (pe[0] = 0, S = 1, Ut[0] = 0, N = 1), l !== 0) {
374
+ const rt = Y(S, pe, l, it);
375
+ f = ct(f, ht(
376
+ Y(m, Ne, l, K),
377
377
  K,
378
- $(rt, it, 2 * G, et),
378
+ Y(rt, it, 2 * J, et),
379
379
  et,
380
380
  at
381
381
  ), at);
382
- const ot = $(B, jt, c, z);
383
- l = ct(l, _t(
384
- $(ot, z, 2 * G, K),
382
+ const ot = Y(N, Ut, l, z);
383
+ f = ct(f, Mt(
384
+ Y(ot, z, 2 * J, K),
385
385
  K,
386
- $(ot, z, c, nt),
386
+ Y(ot, z, l, nt),
387
387
  nt,
388
- $(rt, it, c, et),
388
+ Y(rt, it, l, et),
389
389
  et,
390
- Yt,
390
+ Ft,
391
391
  bt
392
- ), bt), w !== 0 && (l = ct(l, $($(4, kt, c, z), z, w, K), K)), p !== 0 && (l = ct(l, $($(4, At, -c, z), z, p, K), K));
392
+ ), bt), w !== 0 && (f = ct(f, Y(Y(4, kt, l, z), z, w, K), K)), p !== 0 && (f = ct(f, Y(Y(4, It, -l, z), z, p, K), K));
393
393
  }
394
- if (M !== 0) {
395
- const rt = $(S, pe, M, it);
396
- l = ct(l, ft(
397
- $(_, Ne, M, K),
394
+ if (_ !== 0) {
395
+ const rt = Y(S, pe, _, it);
396
+ f = ct(f, ht(
397
+ Y(v, Be, _, K),
398
398
  K,
399
- $(rt, it, 2 * Z, et),
399
+ Y(rt, it, 2 * Z, et),
400
400
  et,
401
401
  at
402
402
  ), at);
403
- const ot = $(B, jt, M, z);
404
- l = ct(l, _t(
405
- $(ot, z, 2 * Z, K),
403
+ const ot = Y(N, Ut, _, z);
404
+ f = ct(f, Mt(
405
+ Y(ot, z, 2 * Z, K),
406
406
  K,
407
- $(ot, z, M, nt),
407
+ Y(ot, z, _, nt),
408
408
  nt,
409
- $(rt, it, M, et),
409
+ Y(rt, it, _, et),
410
410
  et,
411
- Yt,
411
+ Ft,
412
412
  bt
413
413
  ), bt);
414
414
  }
415
415
  }
416
- if (f !== 0 || w !== 0) {
417
- if (u !== 0 || p !== 0 || c !== 0 || M !== 0 ? (R = u * Z, P = U * u, E = P - (P - u), T = u - E, P = U * Z, C = P - (P - Z), F = Z - C, L = T * F - (R - E * C - T * C - E * F), V = J * M, P = U * J, E = P - (P - J), T = J - E, P = U * M, C = P - (P - M), F = M - C, q = T * F - (V - E * C - T * C - E * F), b = L + q, y = b - L, gt[0] = L - (b - y) + (q - y), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D + V, y = b - D, gt[1] = D - (b - y) + (V - y), j = N + b, y = j - N, gt[2] = N - (j - y) + (b - y), gt[3] = j, X = -H, Y = -p, R = c * X, P = U * c, E = P - (P - c), T = c - E, P = U * X, C = P - (P - X), F = X - C, L = T * F - (R - E * C - T * C - E * F), V = G * Y, P = U * G, E = P - (P - G), T = G - E, P = U * Y, C = P - (P - Y), F = Y - C, q = T * F - (V - E * C - T * C - E * F), b = L + q, y = b - L, wt[0] = L - (b - y) + (q - y), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D + V, y = b - D, wt[1] = D - (b - y) + (V - y), j = N + b, y = j - N, wt[2] = N - (j - y) + (b - y), wt[3] = j, g = ft(4, gt, 4, wt, ue), R = u * M, P = U * u, E = P - (P - u), T = u - E, P = U * M, C = P - (P - M), F = M - C, L = T * F - (R - E * C - T * C - E * F), V = c * p, P = U * c, E = P - (P - c), T = c - E, P = U * p, C = P - (P - p), F = p - C, q = T * F - (V - E * C - T * C - E * F), b = L - q, y = L - b, Lt[0] = L - (b + y) + (y - q), N = R + b, y = N - R, D = R - (N - y) + (b - y), b = D - V, y = D - b, Lt[1] = D - (b + y) + (y - V), j = N + b, y = j - N, Lt[2] = N - (j - y) + (b - y), Lt[3] = j, A = 4) : (ue[0] = 0, g = 1, Lt[0] = 0, A = 1), f !== 0) {
418
- const rt = $(g, ue, f, it);
419
- l = ct(l, ft(
420
- $(d, Te, f, K),
416
+ if (u !== 0 || w !== 0) {
417
+ if (h !== 0 || p !== 0 || l !== 0 || _ !== 0 ? (R = h * Z, I = q * h, A = I - (I - h), T = h - A, I = q * Z, X = I - (I - Z), D = Z - X, L = T * D - (R - A * X - T * X - A * D), V = G * _, I = q * G, A = I - (I - G), T = G - A, I = q * _, X = I - (I - _), D = _ - X, j = T * D - (V - A * X - T * X - A * D), x = L + j, y = x - L, gt[0] = L - (x - y) + (j - y), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ + V, y = x - $, gt[1] = $ - (x - y) + (V - y), U = B + x, y = U - B, gt[2] = B - (U - y) + (x - y), gt[3] = U, C = -H, F = -p, R = l * C, I = q * l, A = I - (I - l), T = l - A, I = q * C, X = I - (I - C), D = C - X, L = T * D - (R - A * X - T * X - A * D), V = J * F, I = q * J, A = I - (I - J), T = J - A, I = q * F, X = I - (I - F), D = F - X, j = T * D - (V - A * X - T * X - A * D), x = L + j, y = x - L, wt[0] = L - (x - y) + (j - y), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ + V, y = x - $, wt[1] = $ - (x - y) + (V - y), U = B + x, y = U - B, wt[2] = B - (U - y) + (x - y), wt[3] = U, g = ht(4, gt, 4, wt, ue), R = h * _, I = q * h, A = I - (I - h), T = h - A, I = q * _, X = I - (I - _), D = _ - X, L = T * D - (R - A * X - T * X - A * D), V = l * p, I = q * l, A = I - (I - l), T = l - A, I = q * p, X = I - (I - p), D = p - X, j = T * D - (V - A * X - T * X - A * D), x = L - j, y = L - x, Lt[0] = L - (x + y) + (y - j), B = R + x, y = B - R, $ = R - (B - y) + (x - y), x = $ - V, y = $ - x, Lt[1] = $ - (x + y) + (y - V), U = B + x, y = U - B, Lt[2] = B - (U - y) + (x - y), Lt[3] = U, k = 4) : (ue[0] = 0, g = 1, Lt[0] = 0, k = 1), u !== 0) {
418
+ const rt = Y(g, ue, u, it);
419
+ f = ct(f, ht(
420
+ Y(d, Te, u, K),
421
421
  K,
422
- $(rt, it, 2 * Q, et),
422
+ Y(rt, it, 2 * Q, et),
423
423
  et,
424
424
  at
425
425
  ), at);
426
- const ot = $(A, Lt, f, z);
427
- l = ct(l, _t(
428
- $(ot, z, 2 * Q, K),
426
+ const ot = Y(k, Lt, u, z);
427
+ f = ct(f, Mt(
428
+ Y(ot, z, 2 * Q, K),
429
429
  K,
430
- $(ot, z, f, nt),
430
+ Y(ot, z, u, nt),
431
431
  nt,
432
- $(rt, it, f, et),
432
+ Y(rt, it, u, et),
433
433
  et,
434
- Yt,
434
+ Ft,
435
435
  bt
436
- ), bt), p !== 0 && (l = ct(l, $($(4, Et, f, z), z, p, K), K)), M !== 0 && (l = ct(l, $($(4, kt, -f, z), z, M, K), K));
436
+ ), bt), p !== 0 && (f = ct(f, Y(Y(4, At, u, z), z, p, K), K)), _ !== 0 && (f = ct(f, Y(Y(4, kt, -u, z), z, _, K), K));
437
437
  }
438
438
  if (w !== 0) {
439
- const rt = $(g, ue, w, it);
440
- l = ct(l, ft(
441
- $(v, Xe, w, K),
439
+ const rt = Y(g, ue, w, it);
440
+ f = ct(f, ht(
441
+ Y(b, Ce, w, K),
442
442
  K,
443
- $(rt, it, 2 * W, et),
443
+ Y(rt, it, 2 * W, et),
444
444
  et,
445
445
  at
446
446
  ), at);
447
- const ot = $(A, Lt, w, z);
448
- l = ct(l, _t(
449
- $(ot, z, 2 * W, K),
447
+ const ot = Y(k, Lt, w, z);
448
+ f = ct(f, Mt(
449
+ Y(ot, z, 2 * W, K),
450
450
  K,
451
- $(ot, z, w, nt),
451
+ Y(ot, z, w, nt),
452
452
  nt,
453
- $(rt, it, w, et),
453
+ Y(rt, it, w, et),
454
454
  et,
455
- Yt,
455
+ Ft,
456
456
  bt
457
457
  ), bt);
458
458
  }
459
459
  }
460
- return Qt[l - 1];
460
+ return Qt[f - 1];
461
461
  }
462
- function ui(e, t, n, i, o, r, s, a) {
463
- const h = e - s, l = n - s, u = o - s, c = t - a, f = i - a, p = r - a, M = l * p, w = u * f, I = h * h + c * c, x = u * c, m = h * p, _ = l * l + f * f, d = h * f, v = l * c, g = u * u + p * p, k = I * (M - w) + _ * (x - m) + g * (d - v), S = (Math.abs(M) + Math.abs(w)) * I + (Math.abs(x) + Math.abs(m)) * _ + (Math.abs(d) + Math.abs(v)) * g, A = ci * S;
464
- return k > A || -k > A ? k : fi(e, t, n, i, o, r, s, a, S);
462
+ function mi(e, t, n, i, o, r, s, a) {
463
+ const c = e - s, f = n - s, h = o - s, l = t - a, u = i - a, p = r - a, _ = f * p, w = h * u, O = c * c + l * l, M = h * l, m = c * p, v = f * f + u * u, d = c * u, b = f * l, g = h * h + p * p, E = O * (_ - w) + v * (M - m) + g * (d - b), S = (Math.abs(_) + Math.abs(w)) * O + (Math.abs(M) + Math.abs(m)) * v + (Math.abs(d) + Math.abs(b)) * g, k = hi * S;
464
+ return E > k || -E > k ? E : pi(e, t, n, i, o, r, s, a, S);
465
465
  }
466
- function di(e, t) {
467
- var n, i, o = 0, r, s, a, h, l, u, c, f = e[0], p = e[1], M = t.length;
468
- for (n = 0; n < M; n++) {
466
+ function gi(e, t) {
467
+ var n, i, o = 0, r, s, a, c, f, h, l, u = e[0], p = e[1], _ = t.length;
468
+ for (n = 0; n < _; n++) {
469
469
  i = 0;
470
- var w = t[n], I = w.length - 1;
471
- if (u = w[0], u[0] !== w[I][0] && u[1] !== w[I][1])
470
+ var w = t[n], O = w.length - 1;
471
+ if (h = w[0], h[0] !== w[O][0] && h[1] !== w[O][1])
472
472
  throw new Error("First and last coordinates in a ring must be the same");
473
- for (s = u[0] - f, a = u[1] - p, i; i < I; i++) {
474
- if (c = w[i + 1], h = c[0] - f, l = c[1] - p, a === 0 && l === 0) {
475
- if (h <= 0 && s >= 0 || s <= 0 && h >= 0)
473
+ for (s = h[0] - u, a = h[1] - p, i; i < O; i++) {
474
+ if (l = w[i + 1], c = l[0] - u, f = l[1] - p, a === 0 && f === 0) {
475
+ if (c <= 0 && s >= 0 || s <= 0 && c >= 0)
476
476
  return 0;
477
- } else if (l >= 0 && a <= 0 || l <= 0 && a >= 0) {
478
- if (r = Pt(s, h, a, l, 0, 0), r === 0)
477
+ } else if (f >= 0 && a <= 0 || f <= 0 && a >= 0) {
478
+ if (r = Ot(s, c, a, f, 0, 0), r === 0)
479
479
  return 0;
480
- (r > 0 && l > 0 && a <= 0 || r < 0 && l <= 0 && a > 0) && o++;
480
+ (r > 0 && f > 0 && a <= 0 || r < 0 && f <= 0 && a > 0) && o++;
481
481
  }
482
- u = c, a = l, s = h;
482
+ h = l, a = f, s = c;
483
483
  }
484
484
  }
485
485
  return o % 2 !== 0;
486
486
  }
487
- function De(e, t, n = {}) {
487
+ function $e(e, t, n = {}) {
488
488
  if (!e)
489
489
  throw new Error("point is required");
490
490
  if (!t)
491
491
  throw new Error("polygon is required");
492
- const i = ni(e), o = ii(t), r = o.type, s = t.bbox;
492
+ const i = oi(e), o = si(t), r = o.type, s = t.bbox;
493
493
  let a = o.coordinates;
494
- if (s && pi(i, s) === !1)
494
+ if (s && wi(i, s) === !1)
495
495
  return !1;
496
496
  r === "Polygon" && (a = [a]);
497
- for (var h = 0; h < a.length; ++h) {
498
- const l = di(i, a[h]);
499
- if (l === 0 && !n.ignoreBoundary) return !0;
500
- if (l) return !0;
497
+ for (var c = 0; c < a.length; ++c) {
498
+ const f = gi(i, a[c]);
499
+ if (f === 0 && !n.ignoreBoundary) return !0;
500
+ if (f) return !0;
501
501
  }
502
502
  return !1;
503
503
  }
504
- function pi(e, t) {
504
+ function wi(e, t) {
505
505
  return t[0] <= e[0] && t[1] <= e[1] && t[2] >= e[0] && t[3] >= e[1];
506
506
  }
507
- class Ge {
508
- constructor(t = [], n = mi) {
507
+ class Je {
508
+ constructor(t = [], n = yi) {
509
509
  if (this.data = t, this.length = this.data.length, this.compare = n, this.length > 0)
510
510
  for (let i = (this.length >> 1) - 1; i >= 0; i--) this._down(i);
511
511
  }
@@ -533,73 +533,73 @@ class Ge {
533
533
  const { data: n, compare: i } = this, o = this.length >> 1, r = n[t];
534
534
  for (; t < o; ) {
535
535
  let s = (t << 1) + 1, a = n[s];
536
- const h = s + 1;
537
- if (h < this.length && i(n[h], a) < 0 && (s = h, a = n[h]), i(a, r) >= 0) break;
536
+ const c = s + 1;
537
+ if (c < this.length && i(n[c], a) < 0 && (s = c, a = n[c]), i(a, r) >= 0) break;
538
538
  n[t] = a, t = s;
539
539
  }
540
540
  n[t] = r;
541
541
  }
542
542
  }
543
- function mi(e, t) {
543
+ function yi(e, t) {
544
544
  return e < t ? -1 : e > t ? 1 : 0;
545
545
  }
546
- const gi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
546
+ const vi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
547
547
  __proto__: null,
548
- default: Ge
549
- }, Symbol.toStringTag, { value: "Module" })), Nt = 11102230246251565e-32, ut = 134217729, wi = (3 + 8 * Nt) * Nt;
550
- function Fe(e, t, n, i, o) {
551
- let r, s, a, h, l = t[0], u = i[0], c = 0, f = 0;
552
- u > l == u > -l ? (r = l, l = t[++c]) : (r = u, u = i[++f]);
548
+ default: Je
549
+ }, Symbol.toStringTag, { value: "Module" })), Bt = 11102230246251565e-32, ut = 134217729, bi = (3 + 8 * Bt) * Bt;
550
+ function De(e, t, n, i, o) {
551
+ let r, s, a, c, f = t[0], h = i[0], l = 0, u = 0;
552
+ h > f == h > -f ? (r = f, f = t[++l]) : (r = h, h = i[++u]);
553
553
  let p = 0;
554
- if (c < e && f < n)
555
- for (u > l == u > -l ? (s = l + r, a = r - (s - l), l = t[++c]) : (s = u + r, a = r - (s - u), u = i[++f]), r = s, a !== 0 && (o[p++] = a); c < e && f < n; )
556
- u > l == u > -l ? (s = r + l, h = s - r, a = r - (s - h) + (l - h), l = t[++c]) : (s = r + u, h = s - r, a = r - (s - h) + (u - h), u = i[++f]), r = s, a !== 0 && (o[p++] = a);
557
- for (; c < e; )
558
- s = r + l, h = s - r, a = r - (s - h) + (l - h), l = t[++c], r = s, a !== 0 && (o[p++] = a);
559
- for (; f < n; )
560
- s = r + u, h = s - r, a = r - (s - h) + (u - h), u = i[++f], r = s, a !== 0 && (o[p++] = a);
554
+ if (l < e && u < n)
555
+ for (h > f == h > -f ? (s = f + r, a = r - (s - f), f = t[++l]) : (s = h + r, a = r - (s - h), h = i[++u]), r = s, a !== 0 && (o[p++] = a); l < e && u < n; )
556
+ h > f == h > -f ? (s = r + f, c = s - r, a = r - (s - c) + (f - c), f = t[++l]) : (s = r + h, c = s - r, a = r - (s - c) + (h - c), h = i[++u]), r = s, a !== 0 && (o[p++] = a);
557
+ for (; l < e; )
558
+ s = r + f, c = s - r, a = r - (s - c) + (f - c), f = t[++l], r = s, a !== 0 && (o[p++] = a);
559
+ for (; u < n; )
560
+ s = r + h, c = s - r, a = r - (s - c) + (h - c), h = i[++u], r = s, a !== 0 && (o[p++] = a);
561
561
  return (r !== 0 || p === 0) && (o[p++] = r), p;
562
562
  }
563
- function yi(e, t) {
563
+ function xi(e, t) {
564
564
  let n = t[0];
565
565
  for (let i = 1; i < e; i++) n += t[i];
566
566
  return n;
567
567
  }
568
- function he(e) {
568
+ function fe(e) {
569
569
  return new Float64Array(e);
570
570
  }
571
- const vi = (3 + 16 * Nt) * Nt, bi = (2 + 12 * Nt) * Nt, xi = (9 + 64 * Nt) * Nt * Nt, Gt = he(4), nn = he(8), rn = he(12), on = he(16), yt = he(4);
572
- function _i(e, t, n, i, o, r, s) {
573
- let a, h, l, u, c, f, p, M, w, I, x, m, _, d, v, g, k, S;
574
- const A = e - o, O = n - o, B = t - r, X = i - r;
575
- d = A * X, f = ut * A, p = f - (f - A), M = A - p, f = ut * X, w = f - (f - X), I = X - w, v = M * I - (d - p * w - M * w - p * I), g = B * O, f = ut * B, p = f - (f - B), M = B - p, f = ut * O, w = f - (f - O), I = O - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, Gt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, Gt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, Gt[2] = m - (S - c) + (x - c), Gt[3] = S;
576
- let Y = yi(4, Gt), y = bi * s;
577
- if (Y >= y || -Y >= y || (c = e - A, a = e - (A + c) + (c - o), c = n - O, l = n - (O + c) + (c - o), c = t - B, h = t - (B + c) + (c - r), c = i - X, u = i - (X + c) + (c - r), a === 0 && h === 0 && l === 0 && u === 0) || (y = xi * s + wi * Math.abs(Y), Y += A * u + X * a - (B * l + O * h), Y >= y || -Y >= y)) return Y;
578
- d = a * X, f = ut * a, p = f - (f - a), M = a - p, f = ut * X, w = f - (f - X), I = X - w, v = M * I - (d - p * w - M * w - p * I), g = h * O, f = ut * h, p = f - (f - h), M = h - p, f = ut * O, w = f - (f - O), I = O - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, yt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, yt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, yt[2] = m - (S - c) + (x - c), yt[3] = S;
579
- const P = Fe(4, Gt, 4, yt, nn);
580
- d = A * u, f = ut * A, p = f - (f - A), M = A - p, f = ut * u, w = f - (f - u), I = u - w, v = M * I - (d - p * w - M * w - p * I), g = B * l, f = ut * B, p = f - (f - B), M = B - p, f = ut * l, w = f - (f - l), I = l - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, yt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, yt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, yt[2] = m - (S - c) + (x - c), yt[3] = S;
581
- const E = Fe(P, nn, 4, yt, rn);
582
- d = a * u, f = ut * a, p = f - (f - a), M = a - p, f = ut * u, w = f - (f - u), I = u - w, v = M * I - (d - p * w - M * w - p * I), g = h * l, f = ut * h, p = f - (f - h), M = h - p, f = ut * l, w = f - (f - l), I = l - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, yt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, yt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, yt[2] = m - (S - c) + (x - c), yt[3] = S;
583
- const T = Fe(E, rn, 4, yt, on);
571
+ const _i = (3 + 16 * Bt) * Bt, Mi = (2 + 12 * Bt) * Bt, Si = (9 + 64 * Bt) * Bt * Bt, Jt = fe(4), nn = fe(8), rn = fe(12), on = fe(16), yt = fe(4);
572
+ function Ei(e, t, n, i, o, r, s) {
573
+ let a, c, f, h, l, u, p, _, w, O, M, m, v, d, b, g, E, S;
574
+ const k = e - o, P = n - o, N = t - r, C = i - r;
575
+ d = k * C, u = ut * k, p = u - (u - k), _ = k - p, u = ut * C, w = u - (u - C), O = C - w, b = _ * O - (d - p * w - _ * w - p * O), g = N * P, u = ut * N, p = u - (u - N), _ = N - p, u = ut * P, w = u - (u - P), O = P - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, Jt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, Jt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, Jt[2] = m - (S - l) + (M - l), Jt[3] = S;
576
+ let F = xi(4, Jt), y = Mi * s;
577
+ if (F >= y || -F >= y || (l = e - k, a = e - (k + l) + (l - o), l = n - P, f = n - (P + l) + (l - o), l = t - N, c = t - (N + l) + (l - r), l = i - C, h = i - (C + l) + (l - r), a === 0 && c === 0 && f === 0 && h === 0) || (y = Si * s + bi * Math.abs(F), F += k * h + C * a - (N * f + P * c), F >= y || -F >= y)) return F;
578
+ d = a * C, u = ut * a, p = u - (u - a), _ = a - p, u = ut * C, w = u - (u - C), O = C - w, b = _ * O - (d - p * w - _ * w - p * O), g = c * P, u = ut * c, p = u - (u - c), _ = c - p, u = ut * P, w = u - (u - P), O = P - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, yt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, yt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, yt[2] = m - (S - l) + (M - l), yt[3] = S;
579
+ const I = De(4, Jt, 4, yt, nn);
580
+ d = k * h, u = ut * k, p = u - (u - k), _ = k - p, u = ut * h, w = u - (u - h), O = h - w, b = _ * O - (d - p * w - _ * w - p * O), g = N * f, u = ut * N, p = u - (u - N), _ = N - p, u = ut * f, w = u - (u - f), O = f - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, yt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, yt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, yt[2] = m - (S - l) + (M - l), yt[3] = S;
581
+ const A = De(I, nn, 4, yt, rn);
582
+ d = a * h, u = ut * a, p = u - (u - a), _ = a - p, u = ut * h, w = u - (u - h), O = h - w, b = _ * O - (d - p * w - _ * w - p * O), g = c * f, u = ut * c, p = u - (u - c), _ = c - p, u = ut * f, w = u - (u - f), O = f - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, yt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, yt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, yt[2] = m - (S - l) + (M - l), yt[3] = S;
583
+ const T = De(A, rn, 4, yt, on);
584
584
  return on[T - 1];
585
585
  }
586
586
  function sn(e, t, n, i, o, r) {
587
- const s = (t - r) * (n - o), a = (e - o) * (i - r), h = s - a;
588
- if (s === 0 || a === 0 || s > 0 != a > 0) return h;
589
- const l = Math.abs(s + a);
590
- return Math.abs(h) >= vi * l ? h : -_i(e, t, n, i, o, r, l);
587
+ const s = (t - r) * (n - o), a = (e - o) * (i - r), c = s - a;
588
+ if (s === 0 || a === 0 || s > 0 != a > 0) return c;
589
+ const f = Math.abs(s + a);
590
+ return Math.abs(c) >= _i * f ? c : -Ei(e, t, n, i, o, r, f);
591
591
  }
592
- function Mi(e, t) {
593
- const n = new Ge([], Ln);
594
- return ki(e, n), Ei(n, t);
592
+ function ki(e, t) {
593
+ const n = new Je([], Un);
594
+ return Ii(e, n), Oi(n, t);
595
595
  }
596
- function Ln(e, t) {
596
+ function Un(e, t) {
597
597
  return e.p.x > t.p.x ? 1 : e.p.x < t.p.x || e.p.x === t.p.x && (e.featureId !== t.featureId || e.ringId !== t.ringId) && e.isLeftEndpoint && !t.isLeftEndpoint ? -1 : e.p.y !== t.p.y ? e.p.y > t.p.y ? 1 : -1 : 1;
598
598
  }
599
- function Si(e, t) {
599
+ function Ai(e, t) {
600
600
  return e.rightSweepEvent.p.x > t.rightSweepEvent.p.x ? 1 : e.rightSweepEvent.p.x < t.rightSweepEvent.p.x ? -1 : e.rightSweepEvent.p.y !== t.rightSweepEvent.p.y ? e.rightSweepEvent.p.y < t.rightSweepEvent.p.y ? 1 : -1 : 1;
601
601
  }
602
- function ki(e, t) {
602
+ function Ii(e, t) {
603
603
  if (e.type === "FeatureCollection") {
604
604
  const n = e.features;
605
605
  for (let i = 0; i < n.length; i++)
@@ -616,10 +616,10 @@ function an(e, t) {
616
616
  for (let r = 0; r < i[o].length; r++) {
617
617
  let s = i[o][r][0], a = null;
618
618
  ge = ge + 1;
619
- for (let h = 0; h < i[o][r].length - 1; h++) {
620
- a = i[o][r][h + 1];
621
- const l = new cn(s, me, ge, we), u = new cn(a, me, ge, we + 1);
622
- l.otherEvent = u, u.otherEvent = l, Ln(l, u) > 0 ? (u.isLeftEndpoint = !0, l.isLeftEndpoint = !1) : (l.isLeftEndpoint = !0, u.isLeftEndpoint = !1), t.push(l), t.push(u), s = a, we = we + 1;
619
+ for (let c = 0; c < i[o][r].length - 1; c++) {
620
+ a = i[o][r][c + 1];
621
+ const f = new cn(s, me, ge, we), h = new cn(a, me, ge, we + 1);
622
+ f.otherEvent = h, h.otherEvent = f, Un(f, h) > 0 ? (h.isLeftEndpoint = !0, f.isLeftEndpoint = !1) : (f.isLeftEndpoint = !0, h.isLeftEndpoint = !1), t.push(f), t.push(h), s = a, we = we + 1;
623
623
  }
624
624
  }
625
625
  me = me + 1;
@@ -638,35 +638,35 @@ var cn = class {
638
638
  return [this.p.x, this.p.y];
639
639
  }
640
640
  };
641
- function Ei(e, t = !1) {
642
- const n = [], i = new Ge([], Si);
641
+ function Oi(e, t = !1) {
642
+ const n = [], i = new Je([], Ai);
643
643
  for (; e.length; ) {
644
644
  const o = e.pop();
645
645
  if (o.isLeftEndpoint) {
646
- const r = new Ai(o);
646
+ const r = new Pi(o);
647
647
  for (let s = 0; s < i.data.length; s++) {
648
648
  const a = i.data[s];
649
649
  if (t && a.leftSweepEvent.featureId === o.featureId)
650
650
  continue;
651
- const h = Ii(r, a);
652
- h !== !1 && n.push(h);
651
+ const c = Ni(r, a);
652
+ c !== !1 && n.push(c);
653
653
  }
654
654
  i.push(r);
655
655
  } else o.isLeftEndpoint === !1 && i.pop();
656
656
  }
657
657
  return n;
658
658
  }
659
- var Ai = class {
659
+ var Pi = class {
660
660
  /** @param event must have otherEvent non-null */
661
661
  constructor(e) {
662
662
  this.leftSweepEvent = e, this.rightSweepEvent = e.otherEvent;
663
663
  }
664
664
  };
665
- function Ii(e, t) {
665
+ function Ni(e, t) {
666
666
  if (e === null || t === null) return !1;
667
- const n = e.leftSweepEvent.p.x, i = e.leftSweepEvent.p.y, o = e.rightSweepEvent.p.x, r = e.rightSweepEvent.p.y, s = t.leftSweepEvent.p.x, a = t.leftSweepEvent.p.y, h = t.rightSweepEvent.p.x, l = t.rightSweepEvent.p.y, u = sn(n, i, o, r, s, a), c = sn(n, i, o, r, h, l);
668
- if (u > 0 && c > 0) return !1;
669
- if (u < 0 && c < 0) return !1;
667
+ const n = e.leftSweepEvent.p.x, i = e.leftSweepEvent.p.y, o = e.rightSweepEvent.p.x, r = e.rightSweepEvent.p.y, s = t.leftSweepEvent.p.x, a = t.leftSweepEvent.p.y, c = t.rightSweepEvent.p.x, f = t.rightSweepEvent.p.y, h = sn(n, i, o, r, s, a), l = sn(n, i, o, r, c, f);
668
+ if (h > 0 && l > 0) return !1;
669
+ if (h < 0 && l < 0) return !1;
670
670
  if (e.leftSweepEvent.ringId === t.leftSweepEvent.ringId) {
671
671
  if (e.rightSweepEvent.isSamePoint(t.leftSweepEvent) || e.rightSweepEvent.isSamePoint(t.rightSweepEvent) || e.leftSweepEvent.isSamePoint(t.leftSweepEvent) || e.leftSweepEvent.isSamePoint(t.rightSweepEvent))
672
672
  return !1;
@@ -680,39 +680,39 @@ function Ii(e, t) {
680
680
  if (e.leftSweepEvent.isSamePoint(t.rightSweepEvent))
681
681
  return t.rightSweepEvent.asNewXY();
682
682
  }
683
- const f = (l - a) * (o - n) - (h - s) * (r - i), p = (h - s) * (i - a) - (l - a) * (n - s), M = (o - n) * (i - a) - (r - i) * (n - s);
684
- if (f === 0)
683
+ const u = (f - a) * (o - n) - (c - s) * (r - i), p = (c - s) * (i - a) - (f - a) * (n - s), _ = (o - n) * (i - a) - (r - i) * (n - s);
684
+ if (u === 0)
685
685
  return !1;
686
- const w = p / f, I = M / f;
687
- if (w >= 0 && w <= 1 && I >= 0 && I <= 1) {
688
- const x = n + w * (o - n), m = i + w * (r - i);
689
- return [x, m];
686
+ const w = p / u, O = _ / u;
687
+ if (w >= 0 && w <= 1 && O >= 0 && O <= 1) {
688
+ const M = n + w * (o - n), m = i + w * (r - i);
689
+ return [M, m];
690
690
  }
691
691
  return !1;
692
692
  }
693
- function Pi(e, t, n = {}) {
693
+ function Bi(e, t, n = {}) {
694
694
  const { removeDuplicates: i = !0, ignoreSelfIntersections: o = !0 } = n;
695
695
  let r = [];
696
696
  e.type === "FeatureCollection" ? r = r.concat(e.features) : e.type === "Feature" ? r.push(e) : (e.type === "LineString" || e.type === "Polygon" || e.type === "MultiLineString" || e.type === "MultiPolygon") && r.push(oe(e)), t.type === "FeatureCollection" ? r = r.concat(t.features) : t.type === "Feature" ? r.push(t) : (t.type === "LineString" || t.type === "Polygon" || t.type === "MultiLineString" || t.type === "MultiPolygon") && r.push(oe(t));
697
- const s = Mi(
698
- St(r),
697
+ const s = ki(
698
+ Et(r),
699
699
  o
700
700
  );
701
701
  let a = [];
702
702
  if (i) {
703
- const h = {};
704
- s.forEach((l) => {
705
- const u = l.join(",");
706
- h[u] || (h[u] = !0, a.push(l));
703
+ const c = {};
704
+ s.forEach((f) => {
705
+ const h = f.join(",");
706
+ c[h] || (c[h] = !0, a.push(f));
707
707
  });
708
708
  } else
709
709
  a = s;
710
- return St(a.map((h) => $t(h)));
710
+ return Et(a.map((c) => Yt(c)));
711
711
  }
712
- function Oi(e) {
712
+ function Ti(e) {
713
713
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
714
714
  }
715
- function Bi(e) {
715
+ function Ci(e) {
716
716
  if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
717
717
  var t = e.default;
718
718
  if (typeof t == "function") {
@@ -736,7 +736,7 @@ function Bi(e) {
736
736
  });
737
737
  }), n;
738
738
  }
739
- function Ni(e, t = {}) {
739
+ function Xi(e, t = {}) {
740
740
  let n = 0, i = 0, o = 0;
741
741
  return ze(
742
742
  e,
@@ -744,125 +744,125 @@ function Ni(e, t = {}) {
744
744
  n += r[0], i += r[1], o++;
745
745
  },
746
746
  !0
747
- ), $t([n / o, i / o], t.properties);
747
+ ), Yt([n / o, i / o], t.properties);
748
748
  }
749
- var ye = { exports: {} }, Ee = { exports: {} }, Ti = Ee.exports, ln;
750
- function Xi() {
749
+ var ye = { exports: {} }, ke = { exports: {} }, $i = ke.exports, ln;
750
+ function Di() {
751
751
  return ln || (ln = 1, (function(e, t) {
752
752
  (function(n, i) {
753
753
  e.exports = i();
754
- })(Ti, function() {
755
- function n(m, _, d, v, g) {
756
- (function k(S, A, O, B, X) {
757
- for (; B > O; ) {
758
- if (B - O > 600) {
759
- var Y = B - O + 1, y = A - O + 1, P = Math.log(Y), E = 0.5 * Math.exp(2 * P / 3), T = 0.5 * Math.sqrt(P * E * (Y - E) / Y) * (y - Y / 2 < 0 ? -1 : 1), C = Math.max(O, Math.floor(A - y * E / Y + T)), F = Math.min(B, Math.floor(A + (Y - y) * E / Y + T));
760
- k(S, A, C, F, X);
754
+ })($i, function() {
755
+ function n(m, v, d, b, g) {
756
+ (function E(S, k, P, N, C) {
757
+ for (; N > P; ) {
758
+ if (N - P > 600) {
759
+ var F = N - P + 1, y = k - P + 1, I = Math.log(F), A = 0.5 * Math.exp(2 * I / 3), T = 0.5 * Math.sqrt(I * A * (F - A) / F) * (y - F / 2 < 0 ? -1 : 1), X = Math.max(P, Math.floor(k - y * A / F + T)), D = Math.min(N, Math.floor(k + (F - y) * A / F + T));
760
+ E(S, k, X, D, C);
761
761
  }
762
- var b = S[A], N = O, D = B;
763
- for (i(S, O, A), X(S[B], b) > 0 && i(S, O, B); N < D; ) {
764
- for (i(S, N, D), N++, D--; X(S[N], b) < 0; ) N++;
765
- for (; X(S[D], b) > 0; ) D--;
762
+ var x = S[k], B = P, $ = N;
763
+ for (i(S, P, k), C(S[N], x) > 0 && i(S, P, N); B < $; ) {
764
+ for (i(S, B, $), B++, $--; C(S[B], x) < 0; ) B++;
765
+ for (; C(S[$], x) > 0; ) $--;
766
766
  }
767
- X(S[O], b) === 0 ? i(S, O, D) : i(S, ++D, B), D <= A && (O = D + 1), A <= D && (B = D - 1);
767
+ C(S[P], x) === 0 ? i(S, P, $) : i(S, ++$, N), $ <= k && (P = $ + 1), k <= $ && (N = $ - 1);
768
768
  }
769
- })(m, _, d || 0, v || m.length - 1, g || o);
769
+ })(m, v, d || 0, b || m.length - 1, g || o);
770
770
  }
771
- function i(m, _, d) {
772
- var v = m[_];
773
- m[_] = m[d], m[d] = v;
771
+ function i(m, v, d) {
772
+ var b = m[v];
773
+ m[v] = m[d], m[d] = b;
774
774
  }
775
- function o(m, _) {
776
- return m < _ ? -1 : m > _ ? 1 : 0;
775
+ function o(m, v) {
776
+ return m < v ? -1 : m > v ? 1 : 0;
777
777
  }
778
778
  var r = function(m) {
779
779
  m === void 0 && (m = 9), this._maxEntries = Math.max(4, m), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
780
780
  };
781
- function s(m, _, d) {
782
- if (!d) return _.indexOf(m);
783
- for (var v = 0; v < _.length; v++) if (d(m, _[v])) return v;
781
+ function s(m, v, d) {
782
+ if (!d) return v.indexOf(m);
783
+ for (var b = 0; b < v.length; b++) if (d(m, v[b])) return b;
784
784
  return -1;
785
785
  }
786
- function a(m, _) {
787
- h(m, 0, m.children.length, _, m);
786
+ function a(m, v) {
787
+ c(m, 0, m.children.length, v, m);
788
788
  }
789
- function h(m, _, d, v, g) {
790
- g || (g = I(null)), g.minX = 1 / 0, g.minY = 1 / 0, g.maxX = -1 / 0, g.maxY = -1 / 0;
791
- for (var k = _; k < d; k++) {
792
- var S = m.children[k];
793
- l(g, m.leaf ? v(S) : S);
789
+ function c(m, v, d, b, g) {
790
+ g || (g = O(null)), g.minX = 1 / 0, g.minY = 1 / 0, g.maxX = -1 / 0, g.maxY = -1 / 0;
791
+ for (var E = v; E < d; E++) {
792
+ var S = m.children[E];
793
+ f(g, m.leaf ? b(S) : S);
794
794
  }
795
795
  return g;
796
796
  }
797
- function l(m, _) {
798
- return m.minX = Math.min(m.minX, _.minX), m.minY = Math.min(m.minY, _.minY), m.maxX = Math.max(m.maxX, _.maxX), m.maxY = Math.max(m.maxY, _.maxY), m;
797
+ function f(m, v) {
798
+ return m.minX = Math.min(m.minX, v.minX), m.minY = Math.min(m.minY, v.minY), m.maxX = Math.max(m.maxX, v.maxX), m.maxY = Math.max(m.maxY, v.maxY), m;
799
799
  }
800
- function u(m, _) {
801
- return m.minX - _.minX;
800
+ function h(m, v) {
801
+ return m.minX - v.minX;
802
802
  }
803
- function c(m, _) {
804
- return m.minY - _.minY;
803
+ function l(m, v) {
804
+ return m.minY - v.minY;
805
805
  }
806
- function f(m) {
806
+ function u(m) {
807
807
  return (m.maxX - m.minX) * (m.maxY - m.minY);
808
808
  }
809
809
  function p(m) {
810
810
  return m.maxX - m.minX + (m.maxY - m.minY);
811
811
  }
812
- function M(m, _) {
813
- return m.minX <= _.minX && m.minY <= _.minY && _.maxX <= m.maxX && _.maxY <= m.maxY;
812
+ function _(m, v) {
813
+ return m.minX <= v.minX && m.minY <= v.minY && v.maxX <= m.maxX && v.maxY <= m.maxY;
814
814
  }
815
- function w(m, _) {
816
- return _.minX <= m.maxX && _.minY <= m.maxY && _.maxX >= m.minX && _.maxY >= m.minY;
815
+ function w(m, v) {
816
+ return v.minX <= m.maxX && v.minY <= m.maxY && v.maxX >= m.minX && v.maxY >= m.minY;
817
817
  }
818
- function I(m) {
818
+ function O(m) {
819
819
  return { children: m, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
820
820
  }
821
- function x(m, _, d, v, g) {
822
- for (var k = [_, d]; k.length; ) if (!((d = k.pop()) - (_ = k.pop()) <= v)) {
823
- var S = _ + Math.ceil((d - _) / v / 2) * v;
824
- n(m, S, _, d, g), k.push(_, S, S, d);
821
+ function M(m, v, d, b, g) {
822
+ for (var E = [v, d]; E.length; ) if (!((d = E.pop()) - (v = E.pop()) <= b)) {
823
+ var S = v + Math.ceil((d - v) / b / 2) * b;
824
+ n(m, S, v, d, g), E.push(v, S, S, d);
825
825
  }
826
826
  }
827
827
  return r.prototype.all = function() {
828
828
  return this._all(this.data, []);
829
829
  }, r.prototype.search = function(m) {
830
- var _ = this.data, d = [];
831
- if (!w(m, _)) return d;
832
- for (var v = this.toBBox, g = []; _; ) {
833
- for (var k = 0; k < _.children.length; k++) {
834
- var S = _.children[k], A = _.leaf ? v(S) : S;
835
- w(m, A) && (_.leaf ? d.push(S) : M(m, A) ? this._all(S, d) : g.push(S));
830
+ var v = this.data, d = [];
831
+ if (!w(m, v)) return d;
832
+ for (var b = this.toBBox, g = []; v; ) {
833
+ for (var E = 0; E < v.children.length; E++) {
834
+ var S = v.children[E], k = v.leaf ? b(S) : S;
835
+ w(m, k) && (v.leaf ? d.push(S) : _(m, k) ? this._all(S, d) : g.push(S));
836
836
  }
837
- _ = g.pop();
837
+ v = g.pop();
838
838
  }
839
839
  return d;
840
840
  }, r.prototype.collides = function(m) {
841
- var _ = this.data;
842
- if (!w(m, _)) return !1;
843
- for (var d = []; _; ) {
844
- for (var v = 0; v < _.children.length; v++) {
845
- var g = _.children[v], k = _.leaf ? this.toBBox(g) : g;
846
- if (w(m, k)) {
847
- if (_.leaf || M(m, k)) return !0;
841
+ var v = this.data;
842
+ if (!w(m, v)) return !1;
843
+ for (var d = []; v; ) {
844
+ for (var b = 0; b < v.children.length; b++) {
845
+ var g = v.children[b], E = v.leaf ? this.toBBox(g) : g;
846
+ if (w(m, E)) {
847
+ if (v.leaf || _(m, E)) return !0;
848
848
  d.push(g);
849
849
  }
850
850
  }
851
- _ = d.pop();
851
+ v = d.pop();
852
852
  }
853
853
  return !1;
854
854
  }, r.prototype.load = function(m) {
855
855
  if (!m || !m.length) return this;
856
856
  if (m.length < this._minEntries) {
857
- for (var _ = 0; _ < m.length; _++) this.insert(m[_]);
857
+ for (var v = 0; v < m.length; v++) this.insert(m[v]);
858
858
  return this;
859
859
  }
860
860
  var d = this._build(m.slice(), 0, m.length - 1, 0);
861
861
  if (this.data.children.length) if (this.data.height === d.height) this._splitRoot(this.data, d);
862
862
  else {
863
863
  if (this.data.height < d.height) {
864
- var v = this.data;
865
- this.data = d, d = v;
864
+ var b = this.data;
865
+ this.data = d, d = b;
866
866
  }
867
867
  this._insert(d, this.data.height - d.height - 1, !0);
868
868
  }
@@ -871,277 +871,277 @@ function Xi() {
871
871
  }, r.prototype.insert = function(m) {
872
872
  return m && this._insert(m, this.data.height - 1), this;
873
873
  }, r.prototype.clear = function() {
874
- return this.data = I([]), this;
875
- }, r.prototype.remove = function(m, _) {
874
+ return this.data = O([]), this;
875
+ }, r.prototype.remove = function(m, v) {
876
876
  if (!m) return this;
877
- for (var d, v, g, k = this.data, S = this.toBBox(m), A = [], O = []; k || A.length; ) {
878
- if (k || (k = A.pop(), v = A[A.length - 1], d = O.pop(), g = !0), k.leaf) {
879
- var B = s(m, k.children, _);
880
- if (B !== -1) return k.children.splice(B, 1), A.push(k), this._condense(A), this;
877
+ for (var d, b, g, E = this.data, S = this.toBBox(m), k = [], P = []; E || k.length; ) {
878
+ if (E || (E = k.pop(), b = k[k.length - 1], d = P.pop(), g = !0), E.leaf) {
879
+ var N = s(m, E.children, v);
880
+ if (N !== -1) return E.children.splice(N, 1), k.push(E), this._condense(k), this;
881
881
  }
882
- g || k.leaf || !M(k, S) ? v ? (d++, k = v.children[d], g = !1) : k = null : (A.push(k), O.push(d), d = 0, v = k, k = k.children[0]);
882
+ g || E.leaf || !_(E, S) ? b ? (d++, E = b.children[d], g = !1) : E = null : (k.push(E), P.push(d), d = 0, b = E, E = E.children[0]);
883
883
  }
884
884
  return this;
885
885
  }, r.prototype.toBBox = function(m) {
886
886
  return m;
887
- }, r.prototype.compareMinX = function(m, _) {
888
- return m.minX - _.minX;
889
- }, r.prototype.compareMinY = function(m, _) {
890
- return m.minY - _.minY;
887
+ }, r.prototype.compareMinX = function(m, v) {
888
+ return m.minX - v.minX;
889
+ }, r.prototype.compareMinY = function(m, v) {
890
+ return m.minY - v.minY;
891
891
  }, r.prototype.toJSON = function() {
892
892
  return this.data;
893
893
  }, r.prototype.fromJSON = function(m) {
894
894
  return this.data = m, this;
895
- }, r.prototype._all = function(m, _) {
896
- for (var d = []; m; ) m.leaf ? _.push.apply(_, m.children) : d.push.apply(d, m.children), m = d.pop();
897
- return _;
898
- }, r.prototype._build = function(m, _, d, v) {
899
- var g, k = d - _ + 1, S = this._maxEntries;
900
- if (k <= S) return a(g = I(m.slice(_, d + 1)), this.toBBox), g;
901
- v || (v = Math.ceil(Math.log(k) / Math.log(S)), S = Math.ceil(k / Math.pow(S, v - 1))), (g = I([])).leaf = !1, g.height = v;
902
- var A = Math.ceil(k / S), O = A * Math.ceil(Math.sqrt(S));
903
- x(m, _, d, O, this.compareMinX);
904
- for (var B = _; B <= d; B += O) {
905
- var X = Math.min(B + O - 1, d);
906
- x(m, B, X, A, this.compareMinY);
907
- for (var Y = B; Y <= X; Y += A) {
908
- var y = Math.min(Y + A - 1, X);
909
- g.children.push(this._build(m, Y, y, v - 1));
895
+ }, r.prototype._all = function(m, v) {
896
+ for (var d = []; m; ) m.leaf ? v.push.apply(v, m.children) : d.push.apply(d, m.children), m = d.pop();
897
+ return v;
898
+ }, r.prototype._build = function(m, v, d, b) {
899
+ var g, E = d - v + 1, S = this._maxEntries;
900
+ if (E <= S) return a(g = O(m.slice(v, d + 1)), this.toBBox), g;
901
+ b || (b = Math.ceil(Math.log(E) / Math.log(S)), S = Math.ceil(E / Math.pow(S, b - 1))), (g = O([])).leaf = !1, g.height = b;
902
+ var k = Math.ceil(E / S), P = k * Math.ceil(Math.sqrt(S));
903
+ M(m, v, d, P, this.compareMinX);
904
+ for (var N = v; N <= d; N += P) {
905
+ var C = Math.min(N + P - 1, d);
906
+ M(m, N, C, k, this.compareMinY);
907
+ for (var F = N; F <= C; F += k) {
908
+ var y = Math.min(F + k - 1, C);
909
+ g.children.push(this._build(m, F, y, b - 1));
910
910
  }
911
911
  }
912
912
  return a(g, this.toBBox), g;
913
- }, r.prototype._chooseSubtree = function(m, _, d, v) {
914
- for (; v.push(_), !_.leaf && v.length - 1 !== d; ) {
915
- for (var g = 1 / 0, k = 1 / 0, S = void 0, A = 0; A < _.children.length; A++) {
916
- var O = _.children[A], B = f(O), X = (Y = m, y = O, (Math.max(y.maxX, Y.maxX) - Math.min(y.minX, Y.minX)) * (Math.max(y.maxY, Y.maxY) - Math.min(y.minY, Y.minY)) - B);
917
- X < k ? (k = X, g = B < g ? B : g, S = O) : X === k && B < g && (g = B, S = O);
913
+ }, r.prototype._chooseSubtree = function(m, v, d, b) {
914
+ for (; b.push(v), !v.leaf && b.length - 1 !== d; ) {
915
+ for (var g = 1 / 0, E = 1 / 0, S = void 0, k = 0; k < v.children.length; k++) {
916
+ var P = v.children[k], N = u(P), C = (F = m, y = P, (Math.max(y.maxX, F.maxX) - Math.min(y.minX, F.minX)) * (Math.max(y.maxY, F.maxY) - Math.min(y.minY, F.minY)) - N);
917
+ C < E ? (E = C, g = N < g ? N : g, S = P) : C === E && N < g && (g = N, S = P);
918
918
  }
919
- _ = S || _.children[0];
919
+ v = S || v.children[0];
920
920
  }
921
- var Y, y;
922
- return _;
923
- }, r.prototype._insert = function(m, _, d) {
924
- var v = d ? m : this.toBBox(m), g = [], k = this._chooseSubtree(v, this.data, _, g);
925
- for (k.children.push(m), l(k, v); _ >= 0 && g[_].children.length > this._maxEntries; ) this._split(g, _), _--;
926
- this._adjustParentBBoxes(v, g, _);
927
- }, r.prototype._split = function(m, _) {
928
- var d = m[_], v = d.children.length, g = this._minEntries;
929
- this._chooseSplitAxis(d, g, v);
930
- var k = this._chooseSplitIndex(d, g, v), S = I(d.children.splice(k, d.children.length - k));
931
- S.height = d.height, S.leaf = d.leaf, a(d, this.toBBox), a(S, this.toBBox), _ ? m[_ - 1].children.push(S) : this._splitRoot(d, S);
932
- }, r.prototype._splitRoot = function(m, _) {
933
- this.data = I([m, _]), this.data.height = m.height + 1, this.data.leaf = !1, a(this.data, this.toBBox);
934
- }, r.prototype._chooseSplitIndex = function(m, _, d) {
935
- for (var v, g, k, S, A, O, B, X = 1 / 0, Y = 1 / 0, y = _; y <= d - _; y++) {
936
- var P = h(m, 0, y, this.toBBox), E = h(m, y, d, this.toBBox), T = (g = P, k = E, S = void 0, A = void 0, O = void 0, B = void 0, S = Math.max(g.minX, k.minX), A = Math.max(g.minY, k.minY), O = Math.min(g.maxX, k.maxX), B = Math.min(g.maxY, k.maxY), Math.max(0, O - S) * Math.max(0, B - A)), C = f(P) + f(E);
937
- T < X ? (X = T, v = y, Y = C < Y ? C : Y) : T === X && C < Y && (Y = C, v = y);
921
+ var F, y;
922
+ return v;
923
+ }, r.prototype._insert = function(m, v, d) {
924
+ var b = d ? m : this.toBBox(m), g = [], E = this._chooseSubtree(b, this.data, v, g);
925
+ for (E.children.push(m), f(E, b); v >= 0 && g[v].children.length > this._maxEntries; ) this._split(g, v), v--;
926
+ this._adjustParentBBoxes(b, g, v);
927
+ }, r.prototype._split = function(m, v) {
928
+ var d = m[v], b = d.children.length, g = this._minEntries;
929
+ this._chooseSplitAxis(d, g, b);
930
+ var E = this._chooseSplitIndex(d, g, b), S = O(d.children.splice(E, d.children.length - E));
931
+ S.height = d.height, S.leaf = d.leaf, a(d, this.toBBox), a(S, this.toBBox), v ? m[v - 1].children.push(S) : this._splitRoot(d, S);
932
+ }, r.prototype._splitRoot = function(m, v) {
933
+ this.data = O([m, v]), this.data.height = m.height + 1, this.data.leaf = !1, a(this.data, this.toBBox);
934
+ }, r.prototype._chooseSplitIndex = function(m, v, d) {
935
+ for (var b, g, E, S, k, P, N, C = 1 / 0, F = 1 / 0, y = v; y <= d - v; y++) {
936
+ var I = c(m, 0, y, this.toBBox), A = c(m, y, d, this.toBBox), T = (g = I, E = A, S = void 0, k = void 0, P = void 0, N = void 0, S = Math.max(g.minX, E.minX), k = Math.max(g.minY, E.minY), P = Math.min(g.maxX, E.maxX), N = Math.min(g.maxY, E.maxY), Math.max(0, P - S) * Math.max(0, N - k)), X = u(I) + u(A);
937
+ T < C ? (C = T, b = y, F = X < F ? X : F) : T === C && X < F && (F = X, b = y);
938
938
  }
939
- return v || d - _;
940
- }, r.prototype._chooseSplitAxis = function(m, _, d) {
941
- var v = m.leaf ? this.compareMinX : u, g = m.leaf ? this.compareMinY : c;
942
- this._allDistMargin(m, _, d, v) < this._allDistMargin(m, _, d, g) && m.children.sort(v);
943
- }, r.prototype._allDistMargin = function(m, _, d, v) {
944
- m.children.sort(v);
945
- for (var g = this.toBBox, k = h(m, 0, _, g), S = h(m, d - _, d, g), A = p(k) + p(S), O = _; O < d - _; O++) {
946
- var B = m.children[O];
947
- l(k, m.leaf ? g(B) : B), A += p(k);
939
+ return b || d - v;
940
+ }, r.prototype._chooseSplitAxis = function(m, v, d) {
941
+ var b = m.leaf ? this.compareMinX : h, g = m.leaf ? this.compareMinY : l;
942
+ this._allDistMargin(m, v, d, b) < this._allDistMargin(m, v, d, g) && m.children.sort(b);
943
+ }, r.prototype._allDistMargin = function(m, v, d, b) {
944
+ m.children.sort(b);
945
+ for (var g = this.toBBox, E = c(m, 0, v, g), S = c(m, d - v, d, g), k = p(E) + p(S), P = v; P < d - v; P++) {
946
+ var N = m.children[P];
947
+ f(E, m.leaf ? g(N) : N), k += p(E);
948
948
  }
949
- for (var X = d - _ - 1; X >= _; X--) {
950
- var Y = m.children[X];
951
- l(S, m.leaf ? g(Y) : Y), A += p(S);
949
+ for (var C = d - v - 1; C >= v; C--) {
950
+ var F = m.children[C];
951
+ f(S, m.leaf ? g(F) : F), k += p(S);
952
952
  }
953
- return A;
954
- }, r.prototype._adjustParentBBoxes = function(m, _, d) {
955
- for (var v = d; v >= 0; v--) l(_[v], m);
953
+ return k;
954
+ }, r.prototype._adjustParentBBoxes = function(m, v, d) {
955
+ for (var b = d; b >= 0; b--) f(v[b], m);
956
956
  }, r.prototype._condense = function(m) {
957
- for (var _ = m.length - 1, d = void 0; _ >= 0; _--) m[_].children.length === 0 ? _ > 0 ? (d = m[_ - 1].children).splice(d.indexOf(m[_]), 1) : this.clear() : a(m[_], this.toBBox);
957
+ for (var v = m.length - 1, d = void 0; v >= 0; v--) m[v].children.length === 0 ? v > 0 ? (d = m[v - 1].children).splice(d.indexOf(m[v]), 1) : this.clear() : a(m[v], this.toBBox);
958
958
  }, r;
959
959
  });
960
- })(Ee)), Ee.exports;
960
+ })(ke)), ke.exports;
961
961
  }
962
- const Ci = /* @__PURE__ */ Bi(gi);
963
- var Zt = { exports: {} }, Ye, hn;
964
- function Di() {
965
- return hn || (hn = 1, Ye = function(t, n, i, o) {
962
+ const Fi = /* @__PURE__ */ Ci(vi);
963
+ var Zt = { exports: {} }, Fe, fn;
964
+ function Ri() {
965
+ return fn || (fn = 1, Fe = function(t, n, i, o) {
966
966
  var r = t[0], s = t[1], a = !1;
967
967
  i === void 0 && (i = 0), o === void 0 && (o = n.length);
968
- for (var h = (o - i) / 2, l = 0, u = h - 1; l < h; u = l++) {
969
- var c = n[i + l * 2 + 0], f = n[i + l * 2 + 1], p = n[i + u * 2 + 0], M = n[i + u * 2 + 1], w = f > s != M > s && r < (p - c) * (s - f) / (M - f) + c;
968
+ for (var c = (o - i) / 2, f = 0, h = c - 1; f < c; h = f++) {
969
+ var l = n[i + f * 2 + 0], u = n[i + f * 2 + 1], p = n[i + h * 2 + 0], _ = n[i + h * 2 + 1], w = u > s != _ > s && r < (p - l) * (s - u) / (_ - u) + l;
970
970
  w && (a = !a);
971
971
  }
972
972
  return a;
973
- }), Ye;
973
+ }), Fe;
974
974
  }
975
- var Re, fn;
976
- function Fi() {
977
- return fn || (fn = 1, Re = function(t, n, i, o) {
975
+ var Re, hn;
976
+ function Yi() {
977
+ return hn || (hn = 1, Re = function(t, n, i, o) {
978
978
  var r = t[0], s = t[1], a = !1;
979
979
  i === void 0 && (i = 0), o === void 0 && (o = n.length);
980
- for (var h = o - i, l = 0, u = h - 1; l < h; u = l++) {
981
- var c = n[l + i][0], f = n[l + i][1], p = n[u + i][0], M = n[u + i][1], w = f > s != M > s && r < (p - c) * (s - f) / (M - f) + c;
980
+ for (var c = o - i, f = 0, h = c - 1; f < c; h = f++) {
981
+ var l = n[f + i][0], u = n[f + i][1], p = n[h + i][0], _ = n[h + i][1], w = u > s != _ > s && r < (p - l) * (s - u) / (_ - u) + l;
982
982
  w && (a = !a);
983
983
  }
984
984
  return a;
985
985
  }), Re;
986
986
  }
987
987
  var un;
988
- function Yi() {
988
+ function Li() {
989
989
  if (un) return Zt.exports;
990
990
  un = 1;
991
- var e = Di(), t = Fi();
991
+ var e = Ri(), t = Yi();
992
992
  return Zt.exports = function(i, o, r, s) {
993
993
  return o.length > 0 && Array.isArray(o[0]) ? t(i, o, r, s) : e(i, o, r, s);
994
994
  }, Zt.exports.nested = t, Zt.exports.flat = e, Zt.exports;
995
995
  }
996
- var ee = { exports: {} }, Ri = ee.exports, dn;
997
- function $i() {
996
+ var ee = { exports: {} }, Vi = ee.exports, dn;
997
+ function Ui() {
998
998
  return dn || (dn = 1, (function(e, t) {
999
999
  (function(n, i) {
1000
1000
  i(t);
1001
- })(Ri, function(n) {
1001
+ })(Vi, function(n) {
1002
1002
  const o = 33306690738754706e-32;
1003
- function r(w, I, x, m, _) {
1004
- let d, v, g, k, S = I[0], A = m[0], O = 0, B = 0;
1005
- A > S == A > -S ? (d = S, S = I[++O]) : (d = A, A = m[++B]);
1006
- let X = 0;
1007
- if (O < w && B < x) for (A > S == A > -S ? (g = d - ((v = S + d) - S), S = I[++O]) : (g = d - ((v = A + d) - A), A = m[++B]), d = v, g !== 0 && (_[X++] = g); O < w && B < x; ) A > S == A > -S ? (g = d - ((v = d + S) - (k = v - d)) + (S - k), S = I[++O]) : (g = d - ((v = d + A) - (k = v - d)) + (A - k), A = m[++B]), d = v, g !== 0 && (_[X++] = g);
1008
- for (; O < w; ) g = d - ((v = d + S) - (k = v - d)) + (S - k), S = I[++O], d = v, g !== 0 && (_[X++] = g);
1009
- for (; B < x; ) g = d - ((v = d + A) - (k = v - d)) + (A - k), A = m[++B], d = v, g !== 0 && (_[X++] = g);
1010
- return d === 0 && X !== 0 || (_[X++] = d), X;
1003
+ function r(w, O, M, m, v) {
1004
+ let d, b, g, E, S = O[0], k = m[0], P = 0, N = 0;
1005
+ k > S == k > -S ? (d = S, S = O[++P]) : (d = k, k = m[++N]);
1006
+ let C = 0;
1007
+ if (P < w && N < M) for (k > S == k > -S ? (g = d - ((b = S + d) - S), S = O[++P]) : (g = d - ((b = k + d) - k), k = m[++N]), d = b, g !== 0 && (v[C++] = g); P < w && N < M; ) k > S == k > -S ? (g = d - ((b = d + S) - (E = b - d)) + (S - E), S = O[++P]) : (g = d - ((b = d + k) - (E = b - d)) + (k - E), k = m[++N]), d = b, g !== 0 && (v[C++] = g);
1008
+ for (; P < w; ) g = d - ((b = d + S) - (E = b - d)) + (S - E), S = O[++P], d = b, g !== 0 && (v[C++] = g);
1009
+ for (; N < M; ) g = d - ((b = d + k) - (E = b - d)) + (k - E), k = m[++N], d = b, g !== 0 && (v[C++] = g);
1010
+ return d === 0 && C !== 0 || (v[C++] = d), C;
1011
1011
  }
1012
1012
  function s(w) {
1013
1013
  return new Float64Array(w);
1014
1014
  }
1015
- const a = 33306690738754716e-32, h = 22204460492503146e-32, l = 11093356479670487e-47, u = s(4), c = s(8), f = s(12), p = s(16), M = s(4);
1016
- n.orient2d = function(w, I, x, m, _, d) {
1017
- const v = (I - d) * (x - _), g = (w - _) * (m - d), k = v - g;
1018
- if (v === 0 || g === 0 || v > 0 != g > 0) return k;
1019
- const S = Math.abs(v + g);
1020
- return Math.abs(k) >= a * S ? k : -(function(A, O, B, X, Y, y, P) {
1021
- let E, T, C, F, b, N, D, R, L, V, q, j, J, G, Q, H, Z, W;
1022
- const st = A - Y, lt = B - Y, rt = O - y, ot = X - y;
1023
- b = (Q = (R = st - (D = (N = 134217729 * st) - (N - st))) * (V = ot - (L = (N = 134217729 * ot) - (N - ot))) - ((G = st * ot) - D * L - R * L - D * V)) - (q = Q - (Z = (R = rt - (D = (N = 134217729 * rt) - (N - rt))) * (V = lt - (L = (N = 134217729 * lt) - (N - lt))) - ((H = rt * lt) - D * L - R * L - D * V))), u[0] = Q - (q + b) + (b - Z), b = (J = G - ((j = G + q) - (b = j - G)) + (q - b)) - (q = J - H), u[1] = J - (q + b) + (b - H), b = (W = j + q) - j, u[2] = j - (W - b) + (q - b), u[3] = W;
1024
- let Xt = (function(ei, Ke) {
1015
+ const a = 33306690738754716e-32, c = 22204460492503146e-32, f = 11093356479670487e-47, h = s(4), l = s(8), u = s(12), p = s(16), _ = s(4);
1016
+ n.orient2d = function(w, O, M, m, v, d) {
1017
+ const b = (O - d) * (M - v), g = (w - v) * (m - d), E = b - g;
1018
+ if (b === 0 || g === 0 || b > 0 != g > 0) return E;
1019
+ const S = Math.abs(b + g);
1020
+ return Math.abs(E) >= a * S ? E : -(function(k, P, N, C, F, y, I) {
1021
+ let A, T, X, D, x, B, $, R, L, V, j, U, G, J, Q, H, Z, W;
1022
+ const st = k - F, ft = N - F, rt = P - y, ot = C - y;
1023
+ x = (Q = (R = st - ($ = (B = 134217729 * st) - (B - st))) * (V = ot - (L = (B = 134217729 * ot) - (B - ot))) - ((J = st * ot) - $ * L - R * L - $ * V)) - (j = Q - (Z = (R = rt - ($ = (B = 134217729 * rt) - (B - rt))) * (V = ft - (L = (B = 134217729 * ft) - (B - ft))) - ((H = rt * ft) - $ * L - R * L - $ * V))), h[0] = Q - (j + x) + (x - Z), x = (G = J - ((U = J + j) - (x = U - J)) + (j - x)) - (j = G - H), h[1] = G - (j + x) + (x - H), x = (W = U + j) - U, h[2] = U - (W - x) + (j - x), h[3] = W;
1024
+ let Ct = (function(ri, Ke) {
1025
1025
  let Qe = Ke[0];
1026
- for (let Ie = 1; Ie < ei; Ie++) Qe += Ke[Ie];
1026
+ for (let Ie = 1; Ie < ri; Ie++) Qe += Ke[Ie];
1027
1027
  return Qe;
1028
- })(4, u), Wt = h * P;
1029
- if (Xt >= Wt || -Xt >= Wt || (E = A - (st + (b = A - st)) + (b - Y), C = B - (lt + (b = B - lt)) + (b - Y), T = O - (rt + (b = O - rt)) + (b - y), F = X - (ot + (b = X - ot)) + (b - y), E === 0 && T === 0 && C === 0 && F === 0) || (Wt = l * P + o * Math.abs(Xt), (Xt += st * F + ot * E - (rt * C + lt * T)) >= Wt || -Xt >= Wt)) return Xt;
1030
- b = (Q = (R = E - (D = (N = 134217729 * E) - (N - E))) * (V = ot - (L = (N = 134217729 * ot) - (N - ot))) - ((G = E * ot) - D * L - R * L - D * V)) - (q = Q - (Z = (R = T - (D = (N = 134217729 * T) - (N - T))) * (V = lt - (L = (N = 134217729 * lt) - (N - lt))) - ((H = T * lt) - D * L - R * L - D * V))), M[0] = Q - (q + b) + (b - Z), b = (J = G - ((j = G + q) - (b = j - G)) + (q - b)) - (q = J - H), M[1] = J - (q + b) + (b - H), b = (W = j + q) - j, M[2] = j - (W - b) + (q - b), M[3] = W;
1031
- const Wn = r(4, u, 4, M, c);
1032
- b = (Q = (R = st - (D = (N = 134217729 * st) - (N - st))) * (V = F - (L = (N = 134217729 * F) - (N - F))) - ((G = st * F) - D * L - R * L - D * V)) - (q = Q - (Z = (R = rt - (D = (N = 134217729 * rt) - (N - rt))) * (V = C - (L = (N = 134217729 * C) - (N - C))) - ((H = rt * C) - D * L - R * L - D * V))), M[0] = Q - (q + b) + (b - Z), b = (J = G - ((j = G + q) - (b = j - G)) + (q - b)) - (q = J - H), M[1] = J - (q + b) + (b - H), b = (W = j + q) - j, M[2] = j - (W - b) + (q - b), M[3] = W;
1033
- const Zn = r(Wn, c, 4, M, f);
1034
- b = (Q = (R = E - (D = (N = 134217729 * E) - (N - E))) * (V = F - (L = (N = 134217729 * F) - (N - F))) - ((G = E * F) - D * L - R * L - D * V)) - (q = Q - (Z = (R = T - (D = (N = 134217729 * T) - (N - T))) * (V = C - (L = (N = 134217729 * C) - (N - C))) - ((H = T * C) - D * L - R * L - D * V))), M[0] = Q - (q + b) + (b - Z), b = (J = G - ((j = G + q) - (b = j - G)) + (q - b)) - (q = J - H), M[1] = J - (q + b) + (b - H), b = (W = j + q) - j, M[2] = j - (W - b) + (q - b), M[3] = W;
1035
- const ti = r(Zn, f, 4, M, p);
1036
- return p[ti - 1];
1037
- })(w, I, x, m, _, d, S);
1038
- }, n.orient2dfast = function(w, I, x, m, _, d) {
1039
- return (I - d) * (x - _) - (w - _) * (m - d);
1028
+ })(4, h), Wt = c * I;
1029
+ if (Ct >= Wt || -Ct >= Wt || (A = k - (st + (x = k - st)) + (x - F), X = N - (ft + (x = N - ft)) + (x - F), T = P - (rt + (x = P - rt)) + (x - y), D = C - (ot + (x = C - ot)) + (x - y), A === 0 && T === 0 && X === 0 && D === 0) || (Wt = f * I + o * Math.abs(Ct), (Ct += st * D + ot * A - (rt * X + ft * T)) >= Wt || -Ct >= Wt)) return Ct;
1030
+ x = (Q = (R = A - ($ = (B = 134217729 * A) - (B - A))) * (V = ot - (L = (B = 134217729 * ot) - (B - ot))) - ((J = A * ot) - $ * L - R * L - $ * V)) - (j = Q - (Z = (R = T - ($ = (B = 134217729 * T) - (B - T))) * (V = ft - (L = (B = 134217729 * ft) - (B - ft))) - ((H = T * ft) - $ * L - R * L - $ * V))), _[0] = Q - (j + x) + (x - Z), x = (G = J - ((U = J + j) - (x = U - J)) + (j - x)) - (j = G - H), _[1] = G - (j + x) + (x - H), x = (W = U + j) - U, _[2] = U - (W - x) + (j - x), _[3] = W;
1031
+ const ei = r(4, h, 4, _, l);
1032
+ x = (Q = (R = st - ($ = (B = 134217729 * st) - (B - st))) * (V = D - (L = (B = 134217729 * D) - (B - D))) - ((J = st * D) - $ * L - R * L - $ * V)) - (j = Q - (Z = (R = rt - ($ = (B = 134217729 * rt) - (B - rt))) * (V = X - (L = (B = 134217729 * X) - (B - X))) - ((H = rt * X) - $ * L - R * L - $ * V))), _[0] = Q - (j + x) + (x - Z), x = (G = J - ((U = J + j) - (x = U - J)) + (j - x)) - (j = G - H), _[1] = G - (j + x) + (x - H), x = (W = U + j) - U, _[2] = U - (W - x) + (j - x), _[3] = W;
1033
+ const ni = r(ei, l, 4, _, u);
1034
+ x = (Q = (R = A - ($ = (B = 134217729 * A) - (B - A))) * (V = D - (L = (B = 134217729 * D) - (B - D))) - ((J = A * D) - $ * L - R * L - $ * V)) - (j = Q - (Z = (R = T - ($ = (B = 134217729 * T) - (B - T))) * (V = X - (L = (B = 134217729 * X) - (B - X))) - ((H = T * X) - $ * L - R * L - $ * V))), _[0] = Q - (j + x) + (x - Z), x = (G = J - ((U = J + j) - (x = U - J)) + (j - x)) - (j = G - H), _[1] = G - (j + x) + (x - H), x = (W = U + j) - U, _[2] = U - (W - x) + (j - x), _[3] = W;
1035
+ const ii = r(ni, u, 4, _, p);
1036
+ return p[ii - 1];
1037
+ })(w, O, M, m, v, d, S);
1038
+ }, n.orient2dfast = function(w, O, M, m, v, d) {
1039
+ return (O - d) * (M - v) - (w - v) * (m - d);
1040
1040
  }, Object.defineProperty(n, "__esModule", { value: !0 });
1041
1041
  });
1042
1042
  })(ee, ee.exports)), ee.exports;
1043
1043
  }
1044
1044
  var pn;
1045
- function Li() {
1045
+ function ji() {
1046
1046
  if (pn) return ye.exports;
1047
1047
  pn = 1;
1048
- var e = Xi(), t = Ci, n = Yi(), i = $i().orient2d;
1048
+ var e = Di(), t = Fi, n = Li(), i = Ui().orient2d;
1049
1049
  t.default && (t = t.default), ye.exports = o, ye.exports.default = o;
1050
- function o(d, v, g) {
1051
- v = Math.max(0, v === void 0 ? 2 : v), g = g || 0;
1052
- var k = p(d), S = new e(16);
1053
- S.toBBox = function(D) {
1050
+ function o(d, b, g) {
1051
+ b = Math.max(0, b === void 0 ? 2 : b), g = g || 0;
1052
+ var E = p(d), S = new e(16);
1053
+ S.toBBox = function($) {
1054
1054
  return {
1055
- minX: D[0],
1056
- minY: D[1],
1057
- maxX: D[0],
1058
- maxY: D[1]
1055
+ minX: $[0],
1056
+ minY: $[1],
1057
+ maxX: $[0],
1058
+ maxY: $[1]
1059
1059
  };
1060
- }, S.compareMinX = function(D, R) {
1061
- return D[0] - R[0];
1062
- }, S.compareMinY = function(D, R) {
1063
- return D[1] - R[1];
1060
+ }, S.compareMinX = function($, R) {
1061
+ return $[0] - R[0];
1062
+ }, S.compareMinY = function($, R) {
1063
+ return $[1] - R[1];
1064
1064
  }, S.load(d);
1065
- for (var A = [], O = 0, B; O < k.length; O++) {
1066
- var X = k[O];
1067
- S.remove(X), B = M(X, B), A.push(B);
1065
+ for (var k = [], P = 0, N; P < E.length; P++) {
1066
+ var C = E[P];
1067
+ S.remove(C), N = _(C, N), k.push(N);
1068
1068
  }
1069
- var Y = new e(16);
1070
- for (O = 0; O < A.length; O++) Y.insert(f(A[O]));
1071
- for (var y = v * v, P = g * g; A.length; ) {
1072
- var E = A.shift(), T = E.p, C = E.next.p, F = w(T, C);
1073
- if (!(F < P)) {
1074
- var b = F / y;
1075
- X = r(S, E.prev.p, T, C, E.next.next.p, b, Y), X && Math.min(w(X, T), w(X, C)) <= b && (A.push(E), A.push(M(X, E)), S.remove(X), Y.remove(E), Y.insert(f(E)), Y.insert(f(E.next)));
1069
+ var F = new e(16);
1070
+ for (P = 0; P < k.length; P++) F.insert(u(k[P]));
1071
+ for (var y = b * b, I = g * g; k.length; ) {
1072
+ var A = k.shift(), T = A.p, X = A.next.p, D = w(T, X);
1073
+ if (!(D < I)) {
1074
+ var x = D / y;
1075
+ C = r(S, A.prev.p, T, X, A.next.next.p, x, F), C && Math.min(w(C, T), w(C, X)) <= x && (k.push(A), k.push(_(C, A)), S.remove(C), F.remove(A), F.insert(u(A)), F.insert(u(A.next)));
1076
1076
  }
1077
1077
  }
1078
- E = B;
1079
- var N = [];
1078
+ A = N;
1079
+ var B = [];
1080
1080
  do
1081
- N.push(E.p), E = E.next;
1082
- while (E !== B);
1083
- return N.push(E.p), N;
1084
- }
1085
- function r(d, v, g, k, S, A, O) {
1086
- for (var B = new t([], s), X = d.data; X; ) {
1087
- for (var Y = 0; Y < X.children.length; Y++) {
1088
- var y = X.children[Y], P = X.leaf ? I(y, g, k) : a(g, k, y);
1089
- P > A || B.push({
1081
+ B.push(A.p), A = A.next;
1082
+ while (A !== N);
1083
+ return B.push(A.p), B;
1084
+ }
1085
+ function r(d, b, g, E, S, k, P) {
1086
+ for (var N = new t([], s), C = d.data; C; ) {
1087
+ for (var F = 0; F < C.children.length; F++) {
1088
+ var y = C.children[F], I = C.leaf ? O(y, g, E) : a(g, E, y);
1089
+ I > k || N.push({
1090
1090
  node: y,
1091
- dist: P
1091
+ dist: I
1092
1092
  });
1093
1093
  }
1094
- for (; B.length && !B.peek().node.children; ) {
1095
- var E = B.pop(), T = E.node, C = I(T, v, g), F = I(T, k, S);
1096
- if (E.dist < C && E.dist < F && l(g, T, O) && l(k, T, O)) return T;
1094
+ for (; N.length && !N.peek().node.children; ) {
1095
+ var A = N.pop(), T = A.node, X = O(T, b, g), D = O(T, E, S);
1096
+ if (A.dist < X && A.dist < D && f(g, T, P) && f(E, T, P)) return T;
1097
1097
  }
1098
- X = B.pop(), X && (X = X.node);
1098
+ C = N.pop(), C && (C = C.node);
1099
1099
  }
1100
1100
  return null;
1101
1101
  }
1102
- function s(d, v) {
1103
- return d.dist - v.dist;
1102
+ function s(d, b) {
1103
+ return d.dist - b.dist;
1104
1104
  }
1105
- function a(d, v, g) {
1106
- if (h(d, g) || h(v, g)) return 0;
1107
- var k = x(d[0], d[1], v[0], v[1], g.minX, g.minY, g.maxX, g.minY);
1108
- if (k === 0) return 0;
1109
- var S = x(d[0], d[1], v[0], v[1], g.minX, g.minY, g.minX, g.maxY);
1105
+ function a(d, b, g) {
1106
+ if (c(d, g) || c(b, g)) return 0;
1107
+ var E = M(d[0], d[1], b[0], b[1], g.minX, g.minY, g.maxX, g.minY);
1108
+ if (E === 0) return 0;
1109
+ var S = M(d[0], d[1], b[0], b[1], g.minX, g.minY, g.minX, g.maxY);
1110
1110
  if (S === 0) return 0;
1111
- var A = x(d[0], d[1], v[0], v[1], g.maxX, g.minY, g.maxX, g.maxY);
1112
- if (A === 0) return 0;
1113
- var O = x(d[0], d[1], v[0], v[1], g.minX, g.maxY, g.maxX, g.maxY);
1114
- return O === 0 ? 0 : Math.min(k, S, A, O);
1111
+ var k = M(d[0], d[1], b[0], b[1], g.maxX, g.minY, g.maxX, g.maxY);
1112
+ if (k === 0) return 0;
1113
+ var P = M(d[0], d[1], b[0], b[1], g.minX, g.maxY, g.maxX, g.maxY);
1114
+ return P === 0 ? 0 : Math.min(E, S, k, P);
1115
1115
  }
1116
- function h(d, v) {
1117
- return d[0] >= v.minX && d[0] <= v.maxX && d[1] >= v.minY && d[1] <= v.maxY;
1116
+ function c(d, b) {
1117
+ return d[0] >= b.minX && d[0] <= b.maxX && d[1] >= b.minY && d[1] <= b.maxY;
1118
1118
  }
1119
- function l(d, v, g) {
1120
- for (var k = Math.min(d[0], v[0]), S = Math.min(d[1], v[1]), A = Math.max(d[0], v[0]), O = Math.max(d[1], v[1]), B = g.search({ minX: k, minY: S, maxX: A, maxY: O }), X = 0; X < B.length; X++)
1121
- if (c(B[X].p, B[X].next.p, d, v)) return !1;
1119
+ function f(d, b, g) {
1120
+ for (var E = Math.min(d[0], b[0]), S = Math.min(d[1], b[1]), k = Math.max(d[0], b[0]), P = Math.max(d[1], b[1]), N = g.search({ minX: E, minY: S, maxX: k, maxY: P }), C = 0; C < N.length; C++)
1121
+ if (l(N[C].p, N[C].next.p, d, b)) return !1;
1122
1122
  return !0;
1123
1123
  }
1124
- function u(d, v, g) {
1125
- return i(d[0], d[1], v[0], v[1], g[0], g[1]);
1124
+ function h(d, b, g) {
1125
+ return i(d[0], d[1], b[0], b[1], g[0], g[1]);
1126
1126
  }
1127
- function c(d, v, g, k) {
1128
- return d !== k && v !== g && u(d, v, g) > 0 != u(d, v, k) > 0 && u(g, k, d) > 0 != u(g, k, v) > 0;
1127
+ function l(d, b, g, E) {
1128
+ return d !== E && b !== g && h(d, b, g) > 0 != h(d, b, E) > 0 && h(g, E, d) > 0 != h(g, E, b) > 0;
1129
1129
  }
1130
- function f(d) {
1131
- var v = d.p, g = d.next.p;
1132
- return d.minX = Math.min(v[0], g[0]), d.minY = Math.min(v[1], g[1]), d.maxX = Math.max(v[0], g[0]), d.maxY = Math.max(v[1], g[1]), d;
1130
+ function u(d) {
1131
+ var b = d.p, g = d.next.p;
1132
+ return d.minX = Math.min(b[0], g[0]), d.minY = Math.min(b[1], g[1]), d.maxX = Math.max(b[0], g[0]), d.maxY = Math.max(b[1], g[1]), d;
1133
1133
  }
1134
1134
  function p(d) {
1135
- for (var v = d[0], g = d[0], k = d[0], S = d[0], A = 0; A < d.length; A++) {
1136
- var O = d[A];
1137
- O[0] < v[0] && (v = O), O[0] > k[0] && (k = O), O[1] < g[1] && (g = O), O[1] > S[1] && (S = O);
1135
+ for (var b = d[0], g = d[0], E = d[0], S = d[0], k = 0; k < d.length; k++) {
1136
+ var P = d[k];
1137
+ P[0] < b[0] && (b = P), P[0] > E[0] && (E = P), P[1] < g[1] && (g = P), P[1] > S[1] && (S = P);
1138
1138
  }
1139
- var B = [v, g, k, S], X = B.slice();
1140
- for (A = 0; A < d.length; A++)
1141
- n(d[A], B) || X.push(d[A]);
1142
- return _(X);
1139
+ var N = [b, g, E, S], C = N.slice();
1140
+ for (k = 0; k < d.length; k++)
1141
+ n(d[k], N) || C.push(d[k]);
1142
+ return v(C);
1143
1143
  }
1144
- function M(d, v) {
1144
+ function _(d, b) {
1145
1145
  var g = {
1146
1146
  p: d,
1147
1147
  prev: null,
@@ -1151,47 +1151,47 @@ function Li() {
1151
1151
  maxX: 0,
1152
1152
  maxY: 0
1153
1153
  };
1154
- return v ? (g.next = v.next, g.prev = v, v.next.prev = g, v.next = g) : (g.prev = g, g.next = g), g;
1154
+ return b ? (g.next = b.next, g.prev = b, b.next.prev = g, b.next = g) : (g.prev = g, g.next = g), g;
1155
1155
  }
1156
- function w(d, v) {
1157
- var g = d[0] - v[0], k = d[1] - v[1];
1158
- return g * g + k * k;
1156
+ function w(d, b) {
1157
+ var g = d[0] - b[0], E = d[1] - b[1];
1158
+ return g * g + E * E;
1159
1159
  }
1160
- function I(d, v, g) {
1161
- var k = v[0], S = v[1], A = g[0] - k, O = g[1] - S;
1162
- if (A !== 0 || O !== 0) {
1163
- var B = ((d[0] - k) * A + (d[1] - S) * O) / (A * A + O * O);
1164
- B > 1 ? (k = g[0], S = g[1]) : B > 0 && (k += A * B, S += O * B);
1160
+ function O(d, b, g) {
1161
+ var E = b[0], S = b[1], k = g[0] - E, P = g[1] - S;
1162
+ if (k !== 0 || P !== 0) {
1163
+ var N = ((d[0] - E) * k + (d[1] - S) * P) / (k * k + P * P);
1164
+ N > 1 ? (E = g[0], S = g[1]) : N > 0 && (E += k * N, S += P * N);
1165
1165
  }
1166
- return A = d[0] - k, O = d[1] - S, A * A + O * O;
1166
+ return k = d[0] - E, P = d[1] - S, k * k + P * P;
1167
1167
  }
1168
- function x(d, v, g, k, S, A, O, B) {
1169
- var X = g - d, Y = k - v, y = O - S, P = B - A, E = d - S, T = v - A, C = X * X + Y * Y, F = X * y + Y * P, b = y * y + P * P, N = X * E + Y * T, D = y * E + P * T, R = C * b - F * F, L, V, q, j, J = R, G = R;
1170
- R === 0 ? (V = 0, J = 1, j = D, G = b) : (V = F * D - b * N, j = C * D - F * N, V < 0 ? (V = 0, j = D, G = b) : V > J && (V = J, j = D + F, G = b)), j < 0 ? (j = 0, -N < 0 ? V = 0 : -N > C ? V = J : (V = -N, J = C)) : j > G && (j = G, -N + F < 0 ? V = 0 : -N + F > C ? V = J : (V = -N + F, J = C)), L = V === 0 ? 0 : V / J, q = j === 0 ? 0 : j / G;
1171
- var Q = (1 - L) * d + L * g, H = (1 - L) * v + L * k, Z = (1 - q) * S + q * O, W = (1 - q) * A + q * B, st = Z - Q, lt = W - H;
1172
- return st * st + lt * lt;
1168
+ function M(d, b, g, E, S, k, P, N) {
1169
+ var C = g - d, F = E - b, y = P - S, I = N - k, A = d - S, T = b - k, X = C * C + F * F, D = C * y + F * I, x = y * y + I * I, B = C * A + F * T, $ = y * A + I * T, R = X * x - D * D, L, V, j, U, G = R, J = R;
1170
+ R === 0 ? (V = 0, G = 1, U = $, J = x) : (V = D * $ - x * B, U = X * $ - D * B, V < 0 ? (V = 0, U = $, J = x) : V > G && (V = G, U = $ + D, J = x)), U < 0 ? (U = 0, -B < 0 ? V = 0 : -B > X ? V = G : (V = -B, G = X)) : U > J && (U = J, -B + D < 0 ? V = 0 : -B + D > X ? V = G : (V = -B + D, G = X)), L = V === 0 ? 0 : V / G, j = U === 0 ? 0 : U / J;
1171
+ var Q = (1 - L) * d + L * g, H = (1 - L) * b + L * E, Z = (1 - j) * S + j * P, W = (1 - j) * k + j * N, st = Z - Q, ft = W - H;
1172
+ return st * st + ft * ft;
1173
1173
  }
1174
- function m(d, v) {
1175
- return d[0] === v[0] ? d[1] - v[1] : d[0] - v[0];
1174
+ function m(d, b) {
1175
+ return d[0] === b[0] ? d[1] - b[1] : d[0] - b[0];
1176
1176
  }
1177
- function _(d) {
1177
+ function v(d) {
1178
1178
  d.sort(m);
1179
- for (var v = [], g = 0; g < d.length; g++) {
1180
- for (; v.length >= 2 && u(v[v.length - 2], v[v.length - 1], d[g]) <= 0; )
1181
- v.pop();
1182
- v.push(d[g]);
1179
+ for (var b = [], g = 0; g < d.length; g++) {
1180
+ for (; b.length >= 2 && h(b[b.length - 2], b[b.length - 1], d[g]) <= 0; )
1181
+ b.pop();
1182
+ b.push(d[g]);
1183
1183
  }
1184
- for (var k = [], S = d.length - 1; S >= 0; S--) {
1185
- for (; k.length >= 2 && u(k[k.length - 2], k[k.length - 1], d[S]) <= 0; )
1186
- k.pop();
1187
- k.push(d[S]);
1184
+ for (var E = [], S = d.length - 1; S >= 0; S--) {
1185
+ for (; E.length >= 2 && h(E[E.length - 2], E[E.length - 1], d[S]) <= 0; )
1186
+ E.pop();
1187
+ E.push(d[S]);
1188
1188
  }
1189
- return k.pop(), v.pop(), v.concat(k);
1189
+ return E.pop(), b.pop(), b.concat(E);
1190
1190
  }
1191
1191
  return ye.exports;
1192
1192
  }
1193
- var Vi = Li();
1194
- const ji = /* @__PURE__ */ Oi(Vi);
1193
+ var qi = ji();
1194
+ const zi = /* @__PURE__ */ Ti(qi);
1195
1195
  function mn(e, t = {}) {
1196
1196
  t.concavity = t.concavity || 1 / 0;
1197
1197
  const n = [];
@@ -1199,10 +1199,10 @@ function mn(e, t = {}) {
1199
1199
  n.push([o[0], o[1]]);
1200
1200
  }), !n.length)
1201
1201
  return null;
1202
- const i = ji(n, t.concavity);
1202
+ const i = zi(n, t.concavity);
1203
1203
  return i.length > 3 ? le([i], t.properties) : null;
1204
1204
  }
1205
- function Vn(e, t, n = {}) {
1205
+ function jn(e, t, n = {}) {
1206
1206
  const i = { type: "Feature" };
1207
1207
  return (n.id === 0 || n.id) && (i.id = n.id), n.bbox && (i.bbox = n.bbox), i.properties = t || {}, i.geometry = e, i;
1208
1208
  }
@@ -1215,12 +1215,12 @@ function se(e, t, n = {}) {
1215
1215
  throw new Error("coordinates must be at least 2 numbers long");
1216
1216
  if (!gn(e[0]) || !gn(e[1]))
1217
1217
  throw new Error("coordinates must contain numbers");
1218
- return Vn({
1218
+ return jn({
1219
1219
  type: "Point",
1220
1220
  coordinates: e
1221
1221
  }, t, n);
1222
1222
  }
1223
- function jn(e, t, n = {}) {
1223
+ function qn(e, t, n = {}) {
1224
1224
  for (const i of e) {
1225
1225
  if (i.length < 4)
1226
1226
  throw new Error(
@@ -1232,7 +1232,7 @@ function jn(e, t, n = {}) {
1232
1232
  if (i[i.length - 1][o] !== i[0][o])
1233
1233
  throw new Error("First and last Position are not equivalent.");
1234
1234
  }
1235
- return Vn({
1235
+ return jn({
1236
1236
  type: "Polygon",
1237
1237
  coordinates: e
1238
1238
  }, t, n);
@@ -1244,7 +1244,7 @@ function Ht(e, t = {}) {
1244
1244
  function gn(e) {
1245
1245
  return !isNaN(e) && e !== null && !Array.isArray(e);
1246
1246
  }
1247
- function qi(e) {
1247
+ function Ji(e) {
1248
1248
  if (!e)
1249
1249
  throw new Error("coord is required");
1250
1250
  if (!Array.isArray(e)) {
@@ -1269,136 +1269,144 @@ function wn(e) {
1269
1269
  "coords must be GeoJSON Feature, Geometry Object or an Array"
1270
1270
  );
1271
1271
  }
1272
- function Ui(e) {
1272
+ function Gi(e) {
1273
1273
  return e.type === "Feature" ? e.geometry : e;
1274
1274
  }
1275
- const Tt = 11102230246251565e-32, dt = 134217729, zi = (3 + 8 * Tt) * Tt;
1276
- function $e(e, t, n, i, o) {
1277
- let r, s, a, h, l = t[0], u = i[0], c = 0, f = 0;
1278
- u > l == u > -l ? (r = l, l = t[++c]) : (r = u, u = i[++f]);
1275
+ const Tt = 11102230246251565e-32, dt = 134217729, Ki = (3 + 8 * Tt) * Tt;
1276
+ function Ye(e, t, n, i, o) {
1277
+ let r, s, a, c, f = t[0], h = i[0], l = 0, u = 0;
1278
+ h > f == h > -f ? (r = f, f = t[++l]) : (r = h, h = i[++u]);
1279
1279
  let p = 0;
1280
- if (c < e && f < n)
1281
- for (u > l == u > -l ? (s = l + r, a = r - (s - l), l = t[++c]) : (s = u + r, a = r - (s - u), u = i[++f]), r = s, a !== 0 && (o[p++] = a); c < e && f < n; )
1282
- u > l == u > -l ? (s = r + l, h = s - r, a = r - (s - h) + (l - h), l = t[++c]) : (s = r + u, h = s - r, a = r - (s - h) + (u - h), u = i[++f]), r = s, a !== 0 && (o[p++] = a);
1283
- for (; c < e; )
1284
- s = r + l, h = s - r, a = r - (s - h) + (l - h), l = t[++c], r = s, a !== 0 && (o[p++] = a);
1285
- for (; f < n; )
1286
- s = r + u, h = s - r, a = r - (s - h) + (u - h), u = i[++f], r = s, a !== 0 && (o[p++] = a);
1280
+ if (l < e && u < n)
1281
+ for (h > f == h > -f ? (s = f + r, a = r - (s - f), f = t[++l]) : (s = h + r, a = r - (s - h), h = i[++u]), r = s, a !== 0 && (o[p++] = a); l < e && u < n; )
1282
+ h > f == h > -f ? (s = r + f, c = s - r, a = r - (s - c) + (f - c), f = t[++l]) : (s = r + h, c = s - r, a = r - (s - c) + (h - c), h = i[++u]), r = s, a !== 0 && (o[p++] = a);
1283
+ for (; l < e; )
1284
+ s = r + f, c = s - r, a = r - (s - c) + (f - c), f = t[++l], r = s, a !== 0 && (o[p++] = a);
1285
+ for (; u < n; )
1286
+ s = r + h, c = s - r, a = r - (s - c) + (h - c), h = i[++u], r = s, a !== 0 && (o[p++] = a);
1287
1287
  return (r !== 0 || p === 0) && (o[p++] = r), p;
1288
1288
  }
1289
- function Gi(e, t) {
1289
+ function Qi(e, t) {
1290
1290
  let n = t[0];
1291
1291
  for (let i = 1; i < e; i++) n += t[i];
1292
1292
  return n;
1293
1293
  }
1294
- function fe(e) {
1294
+ function he(e) {
1295
1295
  return new Float64Array(e);
1296
1296
  }
1297
- const Ji = (3 + 16 * Tt) * Tt, Ki = (2 + 12 * Tt) * Tt, Qi = (9 + 64 * Tt) * Tt * Tt, Jt = fe(4), yn = fe(8), vn = fe(12), bn = fe(16), vt = fe(4);
1298
- function Hi(e, t, n, i, o, r, s) {
1299
- let a, h, l, u, c, f, p, M, w, I, x, m, _, d, v, g, k, S;
1300
- const A = e - o, O = n - o, B = t - r, X = i - r;
1301
- d = A * X, f = dt * A, p = f - (f - A), M = A - p, f = dt * X, w = f - (f - X), I = X - w, v = M * I - (d - p * w - M * w - p * I), g = B * O, f = dt * B, p = f - (f - B), M = B - p, f = dt * O, w = f - (f - O), I = O - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, Jt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, Jt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, Jt[2] = m - (S - c) + (x - c), Jt[3] = S;
1302
- let Y = Gi(4, Jt), y = Ki * s;
1303
- if (Y >= y || -Y >= y || (c = e - A, a = e - (A + c) + (c - o), c = n - O, l = n - (O + c) + (c - o), c = t - B, h = t - (B + c) + (c - r), c = i - X, u = i - (X + c) + (c - r), a === 0 && h === 0 && l === 0 && u === 0) || (y = Qi * s + zi * Math.abs(Y), Y += A * u + X * a - (B * l + O * h), Y >= y || -Y >= y)) return Y;
1304
- d = a * X, f = dt * a, p = f - (f - a), M = a - p, f = dt * X, w = f - (f - X), I = X - w, v = M * I - (d - p * w - M * w - p * I), g = h * O, f = dt * h, p = f - (f - h), M = h - p, f = dt * O, w = f - (f - O), I = O - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, vt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, vt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, vt[2] = m - (S - c) + (x - c), vt[3] = S;
1305
- const P = $e(4, Jt, 4, vt, yn);
1306
- d = A * u, f = dt * A, p = f - (f - A), M = A - p, f = dt * u, w = f - (f - u), I = u - w, v = M * I - (d - p * w - M * w - p * I), g = B * l, f = dt * B, p = f - (f - B), M = B - p, f = dt * l, w = f - (f - l), I = l - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, vt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, vt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, vt[2] = m - (S - c) + (x - c), vt[3] = S;
1307
- const E = $e(P, yn, 4, vt, vn);
1308
- d = a * u, f = dt * a, p = f - (f - a), M = a - p, f = dt * u, w = f - (f - u), I = u - w, v = M * I - (d - p * w - M * w - p * I), g = h * l, f = dt * h, p = f - (f - h), M = h - p, f = dt * l, w = f - (f - l), I = l - w, k = M * I - (g - p * w - M * w - p * I), x = v - k, c = v - x, vt[0] = v - (x + c) + (c - k), m = d + x, c = m - d, _ = d - (m - c) + (x - c), x = _ - g, c = _ - x, vt[1] = _ - (x + c) + (c - g), S = m + x, c = S - m, vt[2] = m - (S - c) + (x - c), vt[3] = S;
1309
- const T = $e(E, vn, 4, vt, bn);
1297
+ const Hi = (3 + 16 * Tt) * Tt, Wi = (2 + 12 * Tt) * Tt, Zi = (9 + 64 * Tt) * Tt * Tt, Gt = he(4), yn = he(8), vn = he(12), bn = he(16), vt = he(4);
1298
+ function tr(e, t, n, i, o, r, s) {
1299
+ let a, c, f, h, l, u, p, _, w, O, M, m, v, d, b, g, E, S;
1300
+ const k = e - o, P = n - o, N = t - r, C = i - r;
1301
+ d = k * C, u = dt * k, p = u - (u - k), _ = k - p, u = dt * C, w = u - (u - C), O = C - w, b = _ * O - (d - p * w - _ * w - p * O), g = N * P, u = dt * N, p = u - (u - N), _ = N - p, u = dt * P, w = u - (u - P), O = P - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, Gt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, Gt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, Gt[2] = m - (S - l) + (M - l), Gt[3] = S;
1302
+ let F = Qi(4, Gt), y = Wi * s;
1303
+ if (F >= y || -F >= y || (l = e - k, a = e - (k + l) + (l - o), l = n - P, f = n - (P + l) + (l - o), l = t - N, c = t - (N + l) + (l - r), l = i - C, h = i - (C + l) + (l - r), a === 0 && c === 0 && f === 0 && h === 0) || (y = Zi * s + Ki * Math.abs(F), F += k * h + C * a - (N * f + P * c), F >= y || -F >= y)) return F;
1304
+ d = a * C, u = dt * a, p = u - (u - a), _ = a - p, u = dt * C, w = u - (u - C), O = C - w, b = _ * O - (d - p * w - _ * w - p * O), g = c * P, u = dt * c, p = u - (u - c), _ = c - p, u = dt * P, w = u - (u - P), O = P - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, vt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, vt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, vt[2] = m - (S - l) + (M - l), vt[3] = S;
1305
+ const I = Ye(4, Gt, 4, vt, yn);
1306
+ d = k * h, u = dt * k, p = u - (u - k), _ = k - p, u = dt * h, w = u - (u - h), O = h - w, b = _ * O - (d - p * w - _ * w - p * O), g = N * f, u = dt * N, p = u - (u - N), _ = N - p, u = dt * f, w = u - (u - f), O = f - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, vt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, vt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, vt[2] = m - (S - l) + (M - l), vt[3] = S;
1307
+ const A = Ye(I, yn, 4, vt, vn);
1308
+ d = a * h, u = dt * a, p = u - (u - a), _ = a - p, u = dt * h, w = u - (u - h), O = h - w, b = _ * O - (d - p * w - _ * w - p * O), g = c * f, u = dt * c, p = u - (u - c), _ = c - p, u = dt * f, w = u - (u - f), O = f - w, E = _ * O - (g - p * w - _ * w - p * O), M = b - E, l = b - M, vt[0] = b - (M + l) + (l - E), m = d + M, l = m - d, v = d - (m - l) + (M - l), M = v - g, l = v - M, vt[1] = v - (M + l) + (l - g), S = m + M, l = S - m, vt[2] = m - (S - l) + (M - l), vt[3] = S;
1309
+ const T = Ye(A, vn, 4, vt, bn);
1310
1310
  return bn[T - 1];
1311
1311
  }
1312
- function Wi(e, t, n, i, o, r) {
1313
- const s = (t - r) * (n - o), a = (e - o) * (i - r), h = s - a, l = Math.abs(s + a);
1314
- return Math.abs(h) >= Ji * l ? h : -Hi(e, t, n, i, o, r, l);
1312
+ function er(e, t, n, i, o, r) {
1313
+ const s = (t - r) * (n - o), a = (e - o) * (i - r), c = s - a, f = Math.abs(s + a);
1314
+ return Math.abs(c) >= Hi * f ? c : -tr(e, t, n, i, o, r, f);
1315
1315
  }
1316
- function Zi(e, t) {
1317
- var n, i, o = 0, r, s, a, h, l, u, c, f = e[0], p = e[1], M = t.length;
1318
- for (n = 0; n < M; n++) {
1316
+ function nr(e, t) {
1317
+ var n, i, o = 0, r, s, a, c, f, h, l, u = e[0], p = e[1], _ = t.length;
1318
+ for (n = 0; n < _; n++) {
1319
1319
  i = 0;
1320
- var w = t[n], I = w.length - 1;
1321
- if (u = w[0], u[0] !== w[I][0] && u[1] !== w[I][1])
1320
+ var w = t[n], O = w.length - 1;
1321
+ if (h = w[0], h[0] !== w[O][0] && h[1] !== w[O][1])
1322
1322
  throw new Error("First and last coordinates in a ring must be the same");
1323
- for (s = u[0] - f, a = u[1] - p, i; i < I; i++) {
1324
- if (c = w[i + 1], h = c[0] - f, l = c[1] - p, a === 0 && l === 0) {
1325
- if (h <= 0 && s >= 0 || s <= 0 && h >= 0)
1323
+ for (s = h[0] - u, a = h[1] - p, i; i < O; i++) {
1324
+ if (l = w[i + 1], c = l[0] - u, f = l[1] - p, a === 0 && f === 0) {
1325
+ if (c <= 0 && s >= 0 || s <= 0 && c >= 0)
1326
1326
  return 0;
1327
- } else if (l >= 0 && a <= 0 || l <= 0 && a >= 0) {
1328
- if (r = Wi(s, h, a, l, 0, 0), r === 0)
1327
+ } else if (f >= 0 && a <= 0 || f <= 0 && a >= 0) {
1328
+ if (r = er(s, c, a, f, 0, 0), r === 0)
1329
1329
  return 0;
1330
- (r > 0 && l > 0 && a <= 0 || r < 0 && l <= 0 && a > 0) && o++;
1330
+ (r > 0 && f > 0 && a <= 0 || r < 0 && f <= 0 && a > 0) && o++;
1331
1331
  }
1332
- u = c, a = l, s = h;
1332
+ h = l, a = f, s = c;
1333
1333
  }
1334
1334
  }
1335
1335
  return o % 2 !== 0;
1336
1336
  }
1337
- function je(e, t, n = {}) {
1337
+ function Ue(e, t, n = {}) {
1338
1338
  if (!e)
1339
1339
  throw new Error("point is required");
1340
1340
  if (!t)
1341
1341
  throw new Error("polygon is required");
1342
- const i = qi(e), o = Ui(t), r = o.type, s = t.bbox;
1342
+ const i = Ji(e), o = Gi(t), r = o.type, s = t.bbox;
1343
1343
  let a = o.coordinates;
1344
- if (s && tr(i, s) === !1)
1344
+ if (s && ir(i, s) === !1)
1345
1345
  return !1;
1346
1346
  r === "Polygon" && (a = [a]);
1347
- for (var h = 0; h < a.length; ++h) {
1348
- const l = Zi(i, a[h]);
1349
- if (l === 0 && !n.ignoreBoundary || l) return !0;
1347
+ for (var c = 0; c < a.length; ++c) {
1348
+ const f = nr(i, a[c]);
1349
+ if (f === 0 && !n.ignoreBoundary || f) return !0;
1350
1350
  }
1351
1351
  return !1;
1352
1352
  }
1353
- function tr(e, t) {
1353
+ function ir(e, t) {
1354
1354
  return t[0] <= e[0] && t[1] <= e[1] && t[2] >= e[0] && t[3] >= e[1];
1355
1355
  }
1356
1356
  function Le(e, t) {
1357
1357
  for (let n = 0; n < t.features.length; n++)
1358
- if (je(e, t.features[n]))
1358
+ if (Ue(e, t.features[n]))
1359
1359
  return t.features[n];
1360
1360
  }
1361
- function qn(e, t) {
1362
- const n = t.geometry.coordinates[0][0], i = t.geometry.coordinates[0][1], o = t.geometry.coordinates[0][2], r = e.geometry.coordinates, s = t.properties.a.geom, a = t.properties.b.geom, h = t.properties.c.geom, l = [i[0] - n[0], i[1] - n[1]], u = [o[0] - n[0], o[1] - n[1]], c = [r[0] - n[0], r[1] - n[1]], f = [a[0] - s[0], a[1] - s[1]], p = [h[0] - s[0], h[1] - s[1]], M = (u[1] * c[0] - u[0] * c[1]) / (l[0] * u[1] - l[1] * u[0]), w = (l[0] * c[1] - l[1] * c[0]) / (l[0] * u[1] - l[1] * u[0]);
1361
+ function zn(e, t) {
1362
+ const n = t.geometry.coordinates[0][0], i = t.geometry.coordinates[0][1], o = t.geometry.coordinates[0][2], r = e.geometry.coordinates, s = t.properties.a.geom, a = t.properties.b.geom, c = t.properties.c.geom, f = [i[0] - n[0], i[1] - n[1]], h = [o[0] - n[0], o[1] - n[1]], l = [r[0] - n[0], r[1] - n[1]], u = [a[0] - s[0], a[1] - s[1]], p = [c[0] - s[0], c[1] - s[1]], _ = (h[1] * l[0] - h[0] * l[1]) / (f[0] * h[1] - f[1] * h[0]), w = (f[0] * l[1] - f[1] * l[0]) / (f[0] * h[1] - f[1] * h[0]);
1363
1363
  return [
1364
- M * f[0] + w * p[0] + s[0],
1365
- M * f[1] + w * p[1] + s[1]
1364
+ _ * u[0] + w * p[0] + s[0],
1365
+ _ * u[1] + w * p[1] + s[1]
1366
1366
  ];
1367
1367
  }
1368
- function er(e, t, n) {
1369
- const i = e.geometry.coordinates, o = n.geometry.coordinates, r = Math.atan2(i[0] - o[0], i[1] - o[1]), s = nr(r, t[0]);
1368
+ function rr(e, t, n) {
1369
+ const i = e.geometry.coordinates, o = n.geometry.coordinates, r = Math.atan2(i[0] - o[0], i[1] - o[1]), s = sr(r, t[0]);
1370
1370
  if (s === void 0)
1371
1371
  throw new Error("Unable to determine vertex index");
1372
1372
  const a = t[1][s];
1373
- return qn(e, a.features[0]);
1373
+ return zn(e, a.features[0]);
1374
1374
  }
1375
1375
  function ne(e, t, n, i, o, r, s, a) {
1376
- let h;
1377
- if (s && (h = Le(e, Ht([s]))), !h)
1376
+ let c;
1377
+ if (s && (c = Le(e, Ht([s]))), !c)
1378
1378
  if (n) {
1379
- const l = e.geometry.coordinates, u = n.gridNum, c = n.xOrigin, f = n.yOrigin, p = n.xUnit, M = n.yUnit, w = n.gridCache, I = It(l[0], c, p, u), x = It(l[1], f, M, u), m = w[I] ? w[I][x] ? w[I][x] : [] : [], _ = Ht(m.map((d) => t.features[d]));
1380
- h = Le(e, _);
1379
+ const f = e.geometry.coordinates, h = n.gridNum, l = n.xOrigin, u = n.yOrigin, p = n.xUnit, _ = n.yUnit, w = n.gridCache, O = xt(f[0], l, p, h), M = xt(f[1], u, _, h), m = w[O] ? w[O][M] ? w[O][M] : [] : [], v = Ht(m.map((d) => t.features[d]));
1380
+ c = Le(e, v);
1381
1381
  } else
1382
- h = Le(e, t);
1383
- return a && a(h), h ? qn(e, h) : er(e, i, o);
1382
+ c = Le(e, t);
1383
+ return a && a(c), c ? zn(e, c) : rr(e, i, o);
1384
1384
  }
1385
- function It(e, t, n, i) {
1385
+ function xt(e, t, n, i) {
1386
1386
  let o = Math.floor((e - t) / n);
1387
1387
  return o < 0 && (o = 0), o >= i && (o = i - 1), o;
1388
1388
  }
1389
- function nr(e, t) {
1390
- let n = xn(e - t[0]), i = Math.PI * 2, o;
1389
+ const or = 36;
1390
+ function xn(e, t, n) {
1391
+ const i = (t[1][0] - t[0][0]) / n, o = (t[1][1] - t[0][1]) / n;
1392
+ return e.reduce((r, s) => {
1393
+ const a = xt(s[0][0], t[0][0], i, n), c = xt(s[1][0], t[0][0], i, n), f = xt(s[0][1], t[0][1], o, n), h = xt(s[1][1], t[0][1], o, n), l = (c - a + 1) * (h - f + 1);
1394
+ return l > 0 ? r + l : r;
1395
+ }, 0);
1396
+ }
1397
+ function sr(e, t) {
1398
+ let n = _n(e - t[0]), i = Math.PI * 2, o;
1391
1399
  for (let r = 0; r < t.length; r++) {
1392
- const s = (r + 1) % t.length, a = xn(e - t[s]), h = Math.min(Math.abs(n), Math.abs(a));
1393
- n * a <= 0 && h < i && (i = h, o = r), n = a;
1400
+ const s = (r + 1) % t.length, a = _n(e - t[s]), c = Math.min(Math.abs(n), Math.abs(a));
1401
+ n * a <= 0 && c < i && (i = c, o = r), n = a;
1394
1402
  }
1395
1403
  return o;
1396
1404
  }
1397
- function xn(e, t = !1) {
1405
+ function _n(e, t = !1) {
1398
1406
  const n = 2 * Math.PI, i = e - Math.floor(e / n) * n;
1399
1407
  return t ? i : i > Math.PI ? i - n : i;
1400
1408
  }
1401
- function _n(e) {
1409
+ function Mn(e) {
1402
1410
  const t = e.features;
1403
1411
  for (let n = 0; n < t.length; n++) {
1404
1412
  const i = t[n];
@@ -1460,7 +1468,7 @@ function _n(e) {
1460
1468
  }
1461
1469
  return e;
1462
1470
  }
1463
- function Un(e) {
1471
+ function Jn(e) {
1464
1472
  const t = ["a", "b", "c", "a"].map(
1465
1473
  (r) => e.properties[r].geom
1466
1474
  ), n = e.geometry.coordinates[0], i = e.properties, o = {
@@ -1468,56 +1476,56 @@ function Un(e) {
1468
1476
  b: { geom: n[1], index: i.b.index },
1469
1477
  c: { geom: n[2], index: i.c.index }
1470
1478
  };
1471
- return jn([t], o);
1479
+ return qn([t], o);
1472
1480
  }
1473
- function ir(e) {
1481
+ function ar(e) {
1474
1482
  const t = [0, 1, 2, 0].map((i) => e[i][0][0]), n = {
1475
1483
  a: { geom: e[0][0][1], index: e[0][1] },
1476
1484
  b: { geom: e[1][0][1], index: e[1][1] },
1477
1485
  c: { geom: e[2][0][1], index: e[2][1] }
1478
1486
  };
1479
- return jn([t], n);
1487
+ return qn([t], n);
1480
1488
  }
1481
- function qe(e, t, n, i, o, r = !1, s) {
1489
+ function je(e, t, n, i, o, r = !1, s) {
1482
1490
  const a = e.map(
1483
- (h) => {
1484
- (!s || s < 2.00703) && (h = rr(h));
1485
- const l = isFinite(h) ? t[h] : h === "c" ? i : (function() {
1486
- const u = h.match(/^b(\d+)$/);
1487
- if (u) return o[parseInt(u[1])];
1488
- const c = h.match(/^e(\d+)$/);
1489
- if (c) return n[parseInt(c[1])];
1491
+ (c) => {
1492
+ (!s || s < 2.00703) && (c = cr(c));
1493
+ const f = isFinite(c) ? t[c] : c === "c" ? i : (function() {
1494
+ const h = c.match(/^b(\d+)$/);
1495
+ if (h) return o[parseInt(h[1])];
1496
+ const l = c.match(/^e(\d+)$/);
1497
+ if (l) return n[parseInt(l[1])];
1490
1498
  throw new Error("Bad index value for indexesToTri");
1491
1499
  })();
1492
- return r ? [[l[1], l[0]], h] : [[l[0], l[1]], h];
1500
+ return r ? [[f[1], f[0]], c] : [[f[0], f[1]], c];
1493
1501
  }
1494
1502
  );
1495
- return ir(a);
1503
+ return ar(a);
1496
1504
  }
1497
- function rr(e) {
1505
+ function cr(e) {
1498
1506
  return typeof e == "number" ? e : e.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
1499
1507
  }
1500
- function zn(e, t) {
1508
+ function Gn(e, t) {
1501
1509
  return t && t >= 2.00703 || Array.isArray(e[0]) ? e : e.map((n) => [
1502
1510
  n.illstNodes,
1503
1511
  n.mercNodes,
1504
1512
  n.startEnd
1505
1513
  ]);
1506
1514
  }
1507
- const or = 2.00704;
1508
- function sr(e) {
1515
+ const lr = 2.00704;
1516
+ function fr(e) {
1509
1517
  return !!(e.version !== void 0 || !e.tins && e.points && e.tins_points);
1510
1518
  }
1511
- function ar(e) {
1519
+ function hr(e) {
1512
1520
  return {
1513
1521
  points: e.points,
1514
- strictStatus: lr(e),
1515
- verticesParams: hr(e),
1516
- centroid: fr(e),
1517
- edges: zn(e.edges || []),
1522
+ strictStatus: dr(e),
1523
+ verticesParams: pr(e),
1524
+ centroid: mr(e),
1525
+ edges: Gn(e.edges || []),
1518
1526
  edgeNodes: e.edgeNodes || [],
1519
- tins: ur(e),
1520
- kinks: dr(e.kinks_points),
1527
+ tins: gr(e),
1528
+ kinks: wr(e.kinks_points),
1521
1529
  yaxisMode: e.yaxisMode ?? "invert",
1522
1530
  strictMode: e.strictMode ?? "auto",
1523
1531
  vertexMode: e.vertexMode,
@@ -1527,44 +1535,68 @@ function ar(e) {
1527
1535
  xy: e.xy ?? [0, 0]
1528
1536
  };
1529
1537
  }
1530
- function cr(e) {
1531
- const t = pr(e), n = t.tins;
1532
- return {
1538
+ function ur(e) {
1539
+ const t = yr(e), n = t.tins, i = t.vertices_params;
1540
+ return i != null && Kn(i), {
1533
1541
  compiled: t,
1534
1542
  tins: n,
1535
- points: mr(n),
1543
+ points: vr(n),
1536
1544
  strictStatus: t.strict_status,
1537
- verticesParams: t.vertices_params,
1545
+ verticesParams: i,
1538
1546
  centroid: t.centroid,
1539
1547
  kinks: t.kinks
1540
1548
  };
1541
1549
  }
1542
- function lr(e) {
1550
+ function dr(e) {
1543
1551
  return e.strict_status ? e.strict_status : e.kinks_points ? "strict_error" : e.tins_points.length === 2 ? "loose" : "strict";
1544
1552
  }
1545
- function hr(e) {
1553
+ function pr(e) {
1554
+ if (!Array.isArray(e.vertices_params) || !Array.isArray(e.vertices_points))
1555
+ throw new Error(
1556
+ "Invalid compiled data: vertices_params and vertices_points must be arrays"
1557
+ );
1546
1558
  const t = {
1547
1559
  forw: [e.vertices_params[0]],
1548
1560
  bakw: [e.vertices_params[1]]
1549
1561
  };
1550
- return t.forw[1] = Mn(e, !1), t.bakw[1] = Mn(e, !0), t;
1562
+ return t.forw[1] = Sn(e, !1), t.bakw[1] = Sn(e, !0), Kn(t), t;
1563
+ }
1564
+ function Kn(e) {
1565
+ if (typeof e != "object")
1566
+ throw new Error("Invalid compiled data: vertices_params has a wrong shape");
1567
+ ["forw", "bakw"].forEach((t) => {
1568
+ const n = e[t];
1569
+ if (n == null) return;
1570
+ const i = `vertices_params.${t}`, o = n[0], r = n[1];
1571
+ if (!Array.isArray(o) || !Array.isArray(r))
1572
+ throw new Error(`Invalid compiled data: ${i} must hold two arrays`);
1573
+ if (o.length !== r.length)
1574
+ throw new Error(
1575
+ `Invalid compiled data: ${i} must have one angle per vertex`
1576
+ );
1577
+ for (let s = 0; s < o.length; s++)
1578
+ if (typeof o[s] != "number" || !Number.isFinite(o[s]))
1579
+ throw new Error(
1580
+ `Invalid compiled data: ${i} must contain only finite numbers`
1581
+ );
1582
+ });
1551
1583
  }
1552
- function Mn(e, t) {
1584
+ function Sn(e, t) {
1553
1585
  const n = e.vertices_points.length;
1554
1586
  return Array.from({ length: n }, (i, o) => {
1555
- const r = (o + 1) % n, s = qe(
1587
+ const r = (o + 1) % n, s = je(
1556
1588
  ["c", `b${o}`, `b${r}`],
1557
1589
  e.points,
1558
1590
  e.edgeNodes || [],
1559
1591
  e.centroid_point,
1560
1592
  e.vertices_points,
1561
1593
  t,
1562
- or
1594
+ lr
1563
1595
  );
1564
1596
  return Ht([s]);
1565
1597
  });
1566
1598
  }
1567
- function fr(e) {
1599
+ function mr(e) {
1568
1600
  return {
1569
1601
  forw: se(e.centroid_point[0], {
1570
1602
  target: {
@@ -1580,12 +1612,12 @@ function fr(e) {
1580
1612
  })
1581
1613
  };
1582
1614
  }
1583
- function ur(e) {
1615
+ function gr(e) {
1584
1616
  const t = e.tins_points.length === 1 ? 0 : 1;
1585
1617
  return {
1586
1618
  forw: Ht(
1587
1619
  e.tins_points[0].map(
1588
- (n) => qe(
1620
+ (n) => je(
1589
1621
  n,
1590
1622
  e.points,
1591
1623
  e.edgeNodes || [],
@@ -1598,7 +1630,7 @@ function ur(e) {
1598
1630
  ),
1599
1631
  bakw: Ht(
1600
1632
  e.tins_points[t].map(
1601
- (n) => qe(
1633
+ (n) => je(
1602
1634
  n,
1603
1635
  e.points,
1604
1636
  e.edgeNodes || [],
@@ -1611,7 +1643,7 @@ function ur(e) {
1611
1643
  )
1612
1644
  };
1613
1645
  }
1614
- function dr(e) {
1646
+ function wr(e) {
1615
1647
  if (e)
1616
1648
  return {
1617
1649
  bakw: Ht(
@@ -1619,23 +1651,23 @@ function dr(e) {
1619
1651
  )
1620
1652
  };
1621
1653
  }
1622
- function pr(e) {
1654
+ function yr(e) {
1623
1655
  return JSON.parse(
1624
1656
  JSON.stringify(e).replace('"cent"', '"c"').replace(/"bbox(\d+)"/g, '"b$1"')
1625
1657
  );
1626
1658
  }
1627
- function mr(e) {
1659
+ function vr(e) {
1628
1660
  const t = [], n = e.forw.features;
1629
1661
  for (let i = 0; i < n.length; i++) {
1630
1662
  const o = n[i];
1631
1663
  ["a", "b", "c"].forEach((r, s) => {
1632
- const a = o.geometry.coordinates[0][s], h = o.properties[r].geom, l = o.properties[r].index;
1633
- typeof l == "number" && (t[l] = [a, h]);
1664
+ const a = o.geometry.coordinates[0][s], c = o.properties[r].geom, f = o.properties[r].index;
1665
+ typeof f == "number" && (t[f] = [a, c]);
1634
1666
  });
1635
1667
  }
1636
1668
  return t;
1637
1669
  }
1638
- class Mt {
1670
+ class St {
1639
1671
  /**
1640
1672
  * 各種モードの定数定義
1641
1673
  * すべてreadonlyで、型安全性を確保
@@ -1651,7 +1683,7 @@ class Mt {
1651
1683
  static YAXIS_FOLLOW = "follow";
1652
1684
  static YAXIS_INVERT = "invert";
1653
1685
  points = [];
1654
- /** @deprecated 2.00704 以降、Transform はこのプロパティを設定も参照もしない。サブクラス(MaplatTin)は、旧 @maplat/transform と組まれたときの互換のため {} を入れる(t2 設計 §2.1) */
1686
+ /** @deprecated 2.00704 以降、Transform はこのプロパティを設定も参照もしない。サブクラス(MaplatTin)は、旧 @maplat/transform と組まれたときの互換のため {} を入れる */
1655
1687
  pointsWeightBuffer;
1656
1688
  strict_status;
1657
1689
  vertices_params;
@@ -1660,9 +1692,9 @@ class Mt {
1660
1692
  edges;
1661
1693
  tins;
1662
1694
  kinks;
1663
- yaxisMode = Mt.YAXIS_INVERT;
1664
- strictMode = Mt.MODE_AUTO;
1665
- vertexMode = Mt.VERTEX_PLAIN;
1695
+ yaxisMode = St.YAXIS_INVERT;
1696
+ strictMode = St.MODE_AUTO;
1697
+ vertexMode = St.VERTEX_PLAIN;
1666
1698
  bounds;
1667
1699
  boundsPolygon;
1668
1700
  wh;
@@ -1699,14 +1731,14 @@ class Mt {
1699
1731
  * 4. インデックスの作成
1700
1732
  */
1701
1733
  setCompiled(t) {
1702
- if (sr(t)) {
1703
- this.applyModernState(ar(t));
1734
+ if (fr(t)) {
1735
+ this.applyModernState(hr(t));
1704
1736
  return;
1705
1737
  }
1706
- this.applyLegacyState(cr(t));
1738
+ this.applyLegacyState(ur(t));
1707
1739
  }
1708
1740
  applyModernState(t) {
1709
- this.points = t.points, this.strict_status = t.strictStatus, this.vertices_params = t.verticesParams, this.centroid = t.centroid, this.edges = t.edges, this.edgeNodes = t.edgeNodes || [], this.tins = t.tins, this.addIndexedTin(), this.kinks = t.kinks, this.yaxisMode = t.yaxisMode ?? Mt.YAXIS_INVERT, this.vertexMode = t.vertexMode ?? Mt.VERTEX_PLAIN, this.strictMode = t.strictMode ?? Mt.MODE_AUTO, t.bounds ? (this.bounds = t.bounds, this.boundsPolygon = t.boundsPolygon, this.xy = t.xy, this.wh = t.wh) : (this.bounds = void 0, this.boundsPolygon = void 0, this.xy = t.xy ?? [0, 0], t.wh && (this.wh = t.wh));
1741
+ this.points = t.points, this.strict_status = t.strictStatus, this.vertices_params = t.verticesParams, this.centroid = t.centroid, this.edges = t.edges, this.edgeNodes = t.edgeNodes || [], this.tins = t.tins, this.addIndexedTin(), this.kinks = t.kinks, this.yaxisMode = t.yaxisMode ?? St.YAXIS_INVERT, this.vertexMode = t.vertexMode ?? St.VERTEX_PLAIN, this.strictMode = t.strictMode ?? St.MODE_AUTO, t.bounds ? (this.bounds = t.bounds, this.boundsPolygon = t.boundsPolygon, this.xy = t.xy, this.wh = t.wh) : (this.bounds = void 0, this.boundsPolygon = void 0, this.xy = t.xy ?? [0, 0], t.wh && (this.wh = t.wh));
1710
1742
  }
1711
1743
  applyLegacyState(t) {
1712
1744
  this.tins = t.tins, this.addIndexedTin(), this.strict_status = t.strictStatus, this.vertices_params = t.verticesParams, this.centroid = t.centroid, this.kinks = t.kinks, this.points = t.points;
@@ -1717,6 +1749,8 @@ class Mt {
1717
1749
  * インデックスは変換処理を高速化するために使用されます。
1718
1750
  * グリッド形式のインデックスを作成し、各グリッドに
1719
1751
  * 含まれる三角形を記録します。
1752
+ * セル数が MAX_INDEX_CELLS_PER_TRIANGLE で決まる上限を超えるデータは
1753
+ * 索引を作らず、変換時に全三角形を線形に探します。
1720
1754
  */
1721
1755
  addIndexedTin() {
1722
1756
  const t = this.tins, n = t.forw, i = t.bakw, o = Math.ceil(Math.sqrt(n.features.length));
@@ -1726,33 +1760,41 @@ class Mt {
1726
1760
  }
1727
1761
  let r = [], s = [];
1728
1762
  const a = n.features.map((w) => {
1729
- let I = [];
1730
- return wn(w)[0].map((x) => {
1731
- r.length === 0 ? r = [Array.from(x), Array.from(x)] : (x[0] < r[0][0] && (r[0][0] = x[0]), x[0] > r[1][0] && (r[1][0] = x[0]), x[1] < r[0][1] && (r[0][1] = x[1]), x[1] > r[1][1] && (r[1][1] = x[1])), I.length === 0 ? I = [Array.from(x), Array.from(x)] : (x[0] < I[0][0] && (I[0][0] = x[0]), x[0] > I[1][0] && (I[1][0] = x[0]), x[1] < I[0][1] && (I[0][1] = x[1]), x[1] > I[1][1] && (I[1][1] = x[1]));
1732
- }), I;
1733
- }), h = (r[1][0] - r[0][0]) / o, l = (r[1][1] - r[0][1]) / o, u = a.reduce(
1734
- (w, I, x) => {
1735
- const m = It(I[0][0], r[0][0], h, o), _ = It(I[1][0], r[0][0], h, o), d = It(I[0][1], r[0][1], l, o), v = It(I[1][1], r[0][1], l, o);
1736
- for (let g = m; g <= _; g++) {
1763
+ let O = [];
1764
+ return wn(w)[0].map((M) => {
1765
+ r.length === 0 ? r = [Array.from(M), Array.from(M)] : (M[0] < r[0][0] && (r[0][0] = M[0]), M[0] > r[1][0] && (r[1][0] = M[0]), M[1] < r[0][1] && (r[0][1] = M[1]), M[1] > r[1][1] && (r[1][1] = M[1])), O.length === 0 ? O = [Array.from(M), Array.from(M)] : (M[0] < O[0][0] && (O[0][0] = M[0]), M[0] > O[1][0] && (O[1][0] = M[0]), M[1] < O[0][1] && (O[0][1] = M[1]), M[1] > O[1][1] && (O[1][1] = M[1]));
1766
+ }), O;
1767
+ }), c = i.features.map((w) => {
1768
+ let O = [];
1769
+ return wn(w)[0].map((M) => {
1770
+ s.length === 0 ? s = [Array.from(M), Array.from(M)] : (M[0] < s[0][0] && (s[0][0] = M[0]), M[0] > s[1][0] && (s[1][0] = M[0]), M[1] < s[0][1] && (s[0][1] = M[1]), M[1] > s[1][1] && (s[1][1] = M[1])), O.length === 0 ? O = [Array.from(M), Array.from(M)] : (M[0] < O[0][0] && (O[0][0] = M[0]), M[0] > O[1][0] && (O[1][0] = M[0]), M[1] < O[0][1] && (O[0][1] = M[1]), M[1] > O[1][1] && (O[1][1] = M[1]));
1771
+ }), O;
1772
+ });
1773
+ if (Math.max(
1774
+ xn(a, r, o),
1775
+ xn(c, s, o)
1776
+ ) > or * n.features.length) {
1777
+ this.indexedTins = void 0;
1778
+ return;
1779
+ }
1780
+ const f = (r[1][0] - r[0][0]) / o, h = (r[1][1] - r[0][1]) / o, l = a.reduce(
1781
+ (w, O, M) => {
1782
+ const m = xt(O[0][0], r[0][0], f, o), v = xt(O[1][0], r[0][0], f, o), d = xt(O[0][1], r[0][1], h, o), b = xt(O[1][1], r[0][1], h, o);
1783
+ for (let g = m; g <= v; g++) {
1737
1784
  w[g] || (w[g] = []);
1738
- for (let k = d; k <= v; k++)
1739
- w[g][k] || (w[g][k] = []), w[g][k].push(x);
1785
+ for (let E = d; E <= b; E++)
1786
+ w[g][E] || (w[g][E] = []), w[g][E].push(M);
1740
1787
  }
1741
1788
  return w;
1742
1789
  },
1743
1790
  []
1744
- ), c = i.features.map((w) => {
1745
- let I = [];
1746
- return wn(w)[0].map((x) => {
1747
- s.length === 0 ? s = [Array.from(x), Array.from(x)] : (x[0] < s[0][0] && (s[0][0] = x[0]), x[0] > s[1][0] && (s[1][0] = x[0]), x[1] < s[0][1] && (s[0][1] = x[1]), x[1] > s[1][1] && (s[1][1] = x[1])), I.length === 0 ? I = [Array.from(x), Array.from(x)] : (x[0] < I[0][0] && (I[0][0] = x[0]), x[0] > I[1][0] && (I[1][0] = x[0]), x[1] < I[0][1] && (I[0][1] = x[1]), x[1] > I[1][1] && (I[1][1] = x[1]));
1748
- }), I;
1749
- }), f = (s[1][0] - s[0][0]) / o, p = (s[1][1] - s[0][1]) / o, M = c.reduce(
1750
- (w, I, x) => {
1751
- const m = It(I[0][0], s[0][0], f, o), _ = It(I[1][0], s[0][0], f, o), d = It(I[0][1], s[0][1], p, o), v = It(I[1][1], s[0][1], p, o);
1752
- for (let g = m; g <= _; g++) {
1791
+ ), u = (s[1][0] - s[0][0]) / o, p = (s[1][1] - s[0][1]) / o, _ = c.reduce(
1792
+ (w, O, M) => {
1793
+ const m = xt(O[0][0], s[0][0], u, o), v = xt(O[1][0], s[0][0], u, o), d = xt(O[0][1], s[0][1], p, o), b = xt(O[1][1], s[0][1], p, o);
1794
+ for (let g = m; g <= v; g++) {
1753
1795
  w[g] || (w[g] = []);
1754
- for (let k = d; k <= v; k++)
1755
- w[g][k] || (w[g][k] = []), w[g][k].push(x);
1796
+ for (let E = d; E <= b; E++)
1797
+ w[g][E] || (w[g][E] = []), w[g][E].push(M);
1756
1798
  }
1757
1799
  return w;
1758
1800
  },
@@ -1763,17 +1805,17 @@ class Mt {
1763
1805
  gridNum: o,
1764
1806
  xOrigin: r[0][0],
1765
1807
  yOrigin: r[0][1],
1766
- xUnit: h,
1767
- yUnit: l,
1768
- gridCache: u
1808
+ xUnit: f,
1809
+ yUnit: h,
1810
+ gridCache: l
1769
1811
  },
1770
1812
  bakw: {
1771
1813
  gridNum: o,
1772
1814
  xOrigin: s[0][0],
1773
1815
  yOrigin: s[0][1],
1774
- xUnit: f,
1816
+ xUnit: u,
1775
1817
  yUnit: p,
1776
- gridCache: M
1818
+ gridCache: _
1777
1819
  }
1778
1820
  };
1779
1821
  }
@@ -1790,36 +1832,36 @@ class Mt {
1790
1832
  transform(t, n, i) {
1791
1833
  if (!this.tins)
1792
1834
  throw new Error("setCompiled() must be called before transform()");
1793
- if (n && this.strict_status == Mt.STATUS_ERROR)
1835
+ if (n && this.strict_status == St.STATUS_ERROR)
1794
1836
  throw new Error('Backward transform is not allowed if strict_status == "strict_error"');
1795
- this.yaxisMode == Mt.YAXIS_FOLLOW && n && (t = [t[0], -1 * t[1]]);
1837
+ this.yaxisMode == St.YAXIS_FOLLOW && n && (t = [t[0], -1 * t[1]]);
1796
1838
  const o = se(t);
1797
- if (this.bounds && !n && !i && !je(o, this.boundsPolygon))
1839
+ if (this.bounds && !n && !i && !Ue(o, this.boundsPolygon))
1798
1840
  return !1;
1799
- const r = n ? this.tins.bakw : this.tins.forw, s = n ? this.indexedTins.bakw : this.indexedTins.forw, a = n ? this.vertices_params.bakw : this.vertices_params.forw, h = n ? this.centroid.bakw : this.centroid.forw;
1800
- let l, u;
1801
- this.stateFull && (this.stateBackward == n ? l = this.stateTriangle : (this.stateBackward = n, this.stateTriangle = void 0), u = (f) => {
1802
- this.stateTriangle = f;
1841
+ const r = n ? this.tins.bakw : this.tins.forw, s = n ? this.indexedTins?.bakw : this.indexedTins?.forw, a = n ? this.vertices_params.bakw : this.vertices_params.forw, c = n ? this.centroid.bakw : this.centroid.forw;
1842
+ let f, h;
1843
+ this.stateFull && (this.stateBackward == n ? f = this.stateTriangle : (this.stateBackward = n, this.stateTriangle = void 0), h = (u) => {
1844
+ this.stateTriangle = u;
1803
1845
  });
1804
- let c = ne(
1846
+ let l = ne(
1805
1847
  o,
1806
1848
  r,
1807
1849
  s,
1808
1850
  a,
1809
- h,
1851
+ c,
1810
1852
  void 0,
1811
- l,
1812
- u
1853
+ f,
1854
+ h
1813
1855
  );
1814
1856
  if (this.bounds && n && !i) {
1815
- const f = se(c);
1816
- if (!je(f, this.boundsPolygon)) return !1;
1817
- } else this.yaxisMode == Mt.YAXIS_FOLLOW && !n && (c = [c[0], -1 * c[1]]);
1818
- return c;
1857
+ const u = se(l);
1858
+ if (!Ue(u, this.boundsPolygon)) return !1;
1859
+ } else this.yaxisMode == St.YAXIS_FOLLOW && !n && (l = [l[0], -1 * l[1]]);
1860
+ return l;
1819
1861
  }
1820
1862
  }
1821
- const Sn = Math.pow(2, -52), ve = new Uint32Array(512);
1822
- class Je {
1863
+ const En = Math.pow(2, -52), ve = new Uint32Array(512);
1864
+ class Ge {
1823
1865
  /**
1824
1866
  * Constructs a delaunay triangulation object given an array of points (`[x, y]` by default).
1825
1867
  * `getX` and `getY` are optional functions of the form `(point) => value` for custom point formats.
@@ -1830,13 +1872,13 @@ class Je {
1830
1872
  * @param {(p: P) => number} [getY]
1831
1873
  */
1832
1874
  // @ts-expect-error TS2322
1833
- static from(t, n = br, i = xr) {
1875
+ static from(t, n = Sr, i = Er) {
1834
1876
  const o = t.length, r = new Float64Array(o * 2);
1835
1877
  for (let s = 0; s < o; s++) {
1836
1878
  const a = t[s];
1837
1879
  r[2 * s] = n(a), r[2 * s + 1] = i(a);
1838
1880
  }
1839
- return new Je(r);
1881
+ return new Ge(r);
1840
1882
  }
1841
1883
  /**
1842
1884
  * Constructs a delaunay triangulation object given an array of point coordinates of the form:
@@ -1857,81 +1899,81 @@ class Je {
1857
1899
  */
1858
1900
  update() {
1859
1901
  const { coords: t, _hullPrev: n, _hullNext: i, _hullTri: o, _hullHash: r } = this, s = t.length >> 1;
1860
- let a = 1 / 0, h = 1 / 0, l = -1 / 0, u = -1 / 0;
1861
- for (let A = 0; A < s; A++) {
1862
- const O = t[2 * A], B = t[2 * A + 1];
1863
- O < a && (a = O), B < h && (h = B), O > l && (l = O), B > u && (u = B), this._ids[A] = A;
1902
+ let a = 1 / 0, c = 1 / 0, f = -1 / 0, h = -1 / 0;
1903
+ for (let k = 0; k < s; k++) {
1904
+ const P = t[2 * k], N = t[2 * k + 1];
1905
+ P < a && (a = P), N < c && (c = N), P > f && (f = P), N > h && (h = N), this._ids[k] = k;
1864
1906
  }
1865
- const c = (a + l) / 2, f = (h + u) / 2;
1866
- let p = 0, M = 0, w = 0;
1867
- for (let A = 0, O = 1 / 0; A < s; A++) {
1868
- const B = Ve(c, f, t[2 * A], t[2 * A + 1]);
1869
- B < O && (p = A, O = B);
1907
+ const l = (a + f) / 2, u = (c + h) / 2;
1908
+ let p = 0, _ = 0, w = 0;
1909
+ for (let k = 0, P = 1 / 0; k < s; k++) {
1910
+ const N = Ve(l, u, t[2 * k], t[2 * k + 1]);
1911
+ N < P && (p = k, P = N);
1870
1912
  }
1871
- const I = t[2 * p], x = t[2 * p + 1];
1872
- for (let A = 0, O = 1 / 0; A < s; A++) {
1873
- if (A === p) continue;
1874
- const B = Ve(I, x, t[2 * A], t[2 * A + 1]);
1875
- B < O && B > 0 && (M = A, O = B);
1913
+ const O = t[2 * p], M = t[2 * p + 1];
1914
+ for (let k = 0, P = 1 / 0; k < s; k++) {
1915
+ if (k === p) continue;
1916
+ const N = Ve(O, M, t[2 * k], t[2 * k + 1]);
1917
+ N < P && N > 0 && (_ = k, P = N);
1876
1918
  }
1877
- let m = t[2 * M], _ = t[2 * M + 1], d = 1 / 0;
1878
- for (let A = 0; A < s; A++) {
1879
- if (A === p || A === M) continue;
1880
- const O = yr(I, x, m, _, t[2 * A], t[2 * A + 1]);
1881
- O < d && (w = A, d = O);
1919
+ let m = t[2 * _], v = t[2 * _ + 1], d = 1 / 0;
1920
+ for (let k = 0; k < s; k++) {
1921
+ if (k === p || k === _) continue;
1922
+ const P = _r(O, M, m, v, t[2 * k], t[2 * k + 1]);
1923
+ P < d && (w = k, d = P);
1882
1924
  }
1883
- let v = t[2 * w], g = t[2 * w + 1];
1925
+ let b = t[2 * w], g = t[2 * w + 1];
1884
1926
  if (d === 1 / 0) {
1885
- for (let B = 0; B < s; B++)
1886
- this._dists[B] = t[2 * B] - t[0] || t[2 * B + 1] - t[1];
1927
+ for (let N = 0; N < s; N++)
1928
+ this._dists[N] = t[2 * N] - t[0] || t[2 * N + 1] - t[1];
1887
1929
  Kt(this._ids, this._dists, 0, s - 1);
1888
- const A = new Uint32Array(s);
1889
- let O = 0;
1890
- for (let B = 0, X = -1 / 0; B < s; B++) {
1891
- const Y = this._ids[B], y = this._dists[Y];
1892
- y > X && (A[O++] = Y, X = y);
1930
+ const k = new Uint32Array(s);
1931
+ let P = 0;
1932
+ for (let N = 0, C = -1 / 0; N < s; N++) {
1933
+ const F = this._ids[N], y = this._dists[F];
1934
+ y > C && (k[P++] = F, C = y);
1893
1935
  }
1894
- this.hull = A.subarray(0, O), this.triangles = new Uint32Array(0), this.halfedges = new Int32Array(0);
1936
+ this.hull = k.subarray(0, P), this.triangles = new Uint32Array(0), this.halfedges = new Int32Array(0);
1895
1937
  return;
1896
1938
  }
1897
- if (Pt(I, x, m, _, v, g) < 0) {
1898
- const A = M, O = m, B = _;
1899
- M = w, m = v, _ = g, w = A, v = O, g = B;
1939
+ if (Ot(O, M, m, v, b, g) < 0) {
1940
+ const k = _, P = m, N = v;
1941
+ _ = w, m = b, v = g, w = k, b = P, g = N;
1900
1942
  }
1901
- const k = vr(I, x, m, _, v, g);
1902
- this._cx = k.x, this._cy = k.y;
1903
- for (let A = 0; A < s; A++)
1904
- this._dists[A] = Ve(t[2 * A], t[2 * A + 1], k.x, k.y);
1943
+ const E = Mr(O, M, m, v, b, g);
1944
+ this._cx = E.x, this._cy = E.y;
1945
+ for (let k = 0; k < s; k++)
1946
+ this._dists[k] = Ve(t[2 * k], t[2 * k + 1], E.x, E.y);
1905
1947
  Kt(this._ids, this._dists, 0, s - 1), this._hullStart = p;
1906
1948
  let S = 3;
1907
- i[p] = n[w] = M, i[M] = n[p] = w, i[w] = n[M] = p, o[p] = 0, o[M] = 1, o[w] = 2, r.fill(-1), r[this._hashKey(I, x)] = p, r[this._hashKey(m, _)] = M, r[this._hashKey(v, g)] = w, this.trianglesLen = 0, this._addTriangle(p, M, w, -1, -1, -1);
1908
- for (let A = 0, O = 0, B = 0; A < this._ids.length; A++) {
1909
- const X = this._ids[A], Y = t[2 * X], y = t[2 * X + 1];
1910
- if (A > 0 && Math.abs(Y - O) <= Sn && Math.abs(y - B) <= Sn || (O = Y, B = y, X === p || X === M || X === w)) continue;
1911
- let P = 0;
1912
- for (let b = 0, N = this._hashKey(Y, y); b < this._hashSize && (P = r[(N + b) % this._hashSize], !(P !== -1 && P !== i[P])); b++)
1949
+ i[p] = n[w] = _, i[_] = n[p] = w, i[w] = n[_] = p, o[p] = 0, o[_] = 1, o[w] = 2, r.fill(-1), r[this._hashKey(O, M)] = p, r[this._hashKey(m, v)] = _, r[this._hashKey(b, g)] = w, this.trianglesLen = 0, this._addTriangle(p, _, w, -1, -1, -1);
1950
+ for (let k = 0, P = 0, N = 0; k < this._ids.length; k++) {
1951
+ const C = this._ids[k], F = t[2 * C], y = t[2 * C + 1];
1952
+ if (k > 0 && Math.abs(F - P) <= En && Math.abs(y - N) <= En || (P = F, N = y, C === p || C === _ || C === w)) continue;
1953
+ let I = 0;
1954
+ for (let x = 0, B = this._hashKey(F, y); x < this._hashSize && (I = r[(B + x) % this._hashSize], !(I !== -1 && I !== i[I])); x++)
1913
1955
  ;
1914
- P = n[P];
1915
- let E = P, T;
1916
- for (; T = i[E], Pt(Y, y, t[2 * E], t[2 * E + 1], t[2 * T], t[2 * T + 1]) >= 0; )
1917
- if (E = T, E === P) {
1918
- E = -1;
1956
+ I = n[I];
1957
+ let A = I, T;
1958
+ for (; T = i[A], Ot(F, y, t[2 * A], t[2 * A + 1], t[2 * T], t[2 * T + 1]) >= 0; )
1959
+ if (A = T, A === I) {
1960
+ A = -1;
1919
1961
  break;
1920
1962
  }
1921
- if (E === -1) continue;
1922
- let C = this._addTriangle(E, X, i[E], -1, -1, o[E]);
1923
- o[X] = this._legalize(C + 2), o[E] = C, S++;
1924
- let F = i[E];
1925
- for (; T = i[F], Pt(Y, y, t[2 * F], t[2 * F + 1], t[2 * T], t[2 * T + 1]) < 0; )
1926
- C = this._addTriangle(F, X, T, o[X], -1, o[F]), o[X] = this._legalize(C + 2), i[F] = F, S--, F = T;
1927
- if (E === P)
1928
- for (; T = n[E], Pt(Y, y, t[2 * T], t[2 * T + 1], t[2 * E], t[2 * E + 1]) < 0; )
1929
- C = this._addTriangle(T, X, E, -1, o[E], o[T]), this._legalize(C + 2), o[T] = C, i[E] = E, S--, E = T;
1930
- this._hullStart = n[X] = E, i[E] = n[F] = X, i[X] = F, r[this._hashKey(Y, y)] = X, r[this._hashKey(t[2 * E], t[2 * E + 1])] = E;
1963
+ if (A === -1) continue;
1964
+ let X = this._addTriangle(A, C, i[A], -1, -1, o[A]);
1965
+ o[C] = this._legalize(X + 2), o[A] = X, S++;
1966
+ let D = i[A];
1967
+ for (; T = i[D], Ot(F, y, t[2 * D], t[2 * D + 1], t[2 * T], t[2 * T + 1]) < 0; )
1968
+ X = this._addTriangle(D, C, T, o[C], -1, o[D]), o[C] = this._legalize(X + 2), i[D] = D, S--, D = T;
1969
+ if (A === I)
1970
+ for (; T = n[A], Ot(F, y, t[2 * T], t[2 * T + 1], t[2 * A], t[2 * A + 1]) < 0; )
1971
+ X = this._addTriangle(T, C, A, -1, o[A], o[T]), this._legalize(X + 2), o[T] = X, i[A] = A, S--, A = T;
1972
+ this._hullStart = n[C] = A, i[A] = n[D] = C, i[C] = D, r[this._hashKey(F, y)] = C, r[this._hashKey(t[2 * A], t[2 * A + 1])] = A;
1931
1973
  }
1932
1974
  this.hull = new Uint32Array(S);
1933
- for (let A = 0, O = this._hullStart; A < S; A++)
1934
- this.hull[A] = O, O = i[O];
1975
+ for (let k = 0, P = this._hullStart; k < S; k++)
1976
+ this.hull[k] = P, P = i[P];
1935
1977
  this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
1936
1978
  }
1937
1979
  /**
@@ -1942,7 +1984,7 @@ class Je {
1942
1984
  * @private
1943
1985
  */
1944
1986
  _hashKey(t, n) {
1945
- return Math.floor(gr(t - this._cx, n - this._cy) * this._hashSize) % this._hashSize;
1987
+ return Math.floor(br(t - this._cx, n - this._cy) * this._hashSize) % this._hashSize;
1946
1988
  }
1947
1989
  /**
1948
1990
  * Flip an edge in a pair of triangles if it doesn't satisfy the Delaunay condition.
@@ -1954,37 +1996,37 @@ class Je {
1954
1996
  const { _triangles: n, _halfedges: i, coords: o } = this;
1955
1997
  let r = 0, s = 0;
1956
1998
  for (; ; ) {
1957
- const a = i[t], h = t - t % 3;
1958
- if (s = h + (t + 2) % 3, a === -1) {
1999
+ const a = i[t], c = t - t % 3;
2000
+ if (s = c + (t + 2) % 3, a === -1) {
1959
2001
  if (r === 0) break;
1960
2002
  t = ve[--r];
1961
2003
  continue;
1962
2004
  }
1963
- const l = a - a % 3, u = h + (t + 1) % 3, c = l + (a + 2) % 3, f = n[s], p = n[t], M = n[u], w = n[c];
1964
- if (wr(
1965
- o[2 * f],
1966
- o[2 * f + 1],
2005
+ const f = a - a % 3, h = c + (t + 1) % 3, l = f + (a + 2) % 3, u = n[s], p = n[t], _ = n[h], w = n[l];
2006
+ if (xr(
2007
+ o[2 * u],
2008
+ o[2 * u + 1],
1967
2009
  o[2 * p],
1968
2010
  o[2 * p + 1],
1969
- o[2 * M],
1970
- o[2 * M + 1],
2011
+ o[2 * _],
2012
+ o[2 * _ + 1],
1971
2013
  o[2 * w],
1972
2014
  o[2 * w + 1]
1973
2015
  )) {
1974
- n[t] = w, n[a] = f;
1975
- const x = i[c];
1976
- if (x === -1) {
1977
- let _ = this._hullStart;
2016
+ n[t] = w, n[a] = u;
2017
+ const M = i[l];
2018
+ if (M === -1) {
2019
+ let v = this._hullStart;
1978
2020
  do {
1979
- if (this._hullTri[_] === c) {
1980
- this._hullTri[_] = t;
2021
+ if (this._hullTri[v] === l) {
2022
+ this._hullTri[v] = t;
1981
2023
  break;
1982
2024
  }
1983
- _ = this._hullPrev[_];
1984
- } while (_ !== this._hullStart);
2025
+ v = this._hullPrev[v];
2026
+ } while (v !== this._hullStart);
1985
2027
  }
1986
- this._link(t, x), this._link(a, i[s]), this._link(s, c);
1987
- const m = l + (a + 1) % 3;
2028
+ this._link(t, M), this._link(a, i[s]), this._link(s, l);
2029
+ const m = f + (a + 1) % 3;
1988
2030
  r < ve.length && (ve[r++] = m);
1989
2031
  } else {
1990
2032
  if (r === 0) break;
@@ -2018,7 +2060,7 @@ class Je {
2018
2060
  return this._triangles[a] = t, this._triangles[a + 1] = n, this._triangles[a + 2] = i, this._link(a, o), this._link(a + 1, r), this._link(a + 2, s), this.trianglesLen += 3, a;
2019
2061
  }
2020
2062
  }
2021
- function gr(e, t) {
2063
+ function br(e, t) {
2022
2064
  const n = e / (Math.abs(e) + Math.abs(t));
2023
2065
  return (t > 0 ? 3 - n : 1 + n) / 4;
2024
2066
  }
@@ -2026,17 +2068,17 @@ function Ve(e, t, n, i) {
2026
2068
  const o = e - n, r = t - i;
2027
2069
  return o * o + r * r;
2028
2070
  }
2029
- function wr(e, t, n, i, o, r, s, a) {
2030
- const h = e - s, l = t - a, u = n - s, c = i - a, f = o - s, p = r - a, M = h * h + l * l, w = u * u + c * c, I = f * f + p * p;
2031
- return h * (c * I - w * p) - l * (u * I - w * f) + M * (u * p - c * f) < 0;
2071
+ function xr(e, t, n, i, o, r, s, a) {
2072
+ const c = e - s, f = t - a, h = n - s, l = i - a, u = o - s, p = r - a, _ = c * c + f * f, w = h * h + l * l, O = u * u + p * p;
2073
+ return c * (l * O - w * p) - f * (h * O - w * u) + _ * (h * p - l * u) < 0;
2032
2074
  }
2033
- function yr(e, t, n, i, o, r) {
2034
- const s = n - e, a = i - t, h = o - e, l = r - t, u = s * s + a * a, c = h * h + l * l, f = 0.5 / (s * l - a * h), p = (l * u - a * c) * f, M = (s * c - h * u) * f;
2035
- return p * p + M * M;
2075
+ function _r(e, t, n, i, o, r) {
2076
+ const s = n - e, a = i - t, c = o - e, f = r - t, h = s * s + a * a, l = c * c + f * f, u = 0.5 / (s * f - a * c), p = (f * h - a * l) * u, _ = (s * l - c * h) * u;
2077
+ return p * p + _ * _;
2036
2078
  }
2037
- function vr(e, t, n, i, o, r) {
2038
- const s = n - e, a = i - t, h = o - e, l = r - t, u = s * s + a * a, c = h * h + l * l, f = 0.5 / (s * l - a * h), p = e + (l * u - a * c) * f, M = t + (s * c - h * u) * f;
2039
- return { x: p, y: M };
2079
+ function Mr(e, t, n, i, o, r) {
2080
+ const s = n - e, a = i - t, c = o - e, f = r - t, h = s * s + a * a, l = c * c + f * f, u = 0.5 / (s * f - a * c), p = e + (f * h - a * l) * u, _ = t + (s * l - c * h) * u;
2081
+ return { x: p, y: _ };
2040
2082
  }
2041
2083
  function Kt(e, t, n, i) {
2042
2084
  if (i - n <= 20)
@@ -2050,14 +2092,14 @@ function Kt(e, t, n, i) {
2050
2092
  const o = n + i >> 1;
2051
2093
  let r = n + 1, s = i;
2052
2094
  te(e, o, r), t[e[n]] > t[e[i]] && te(e, n, i), t[e[r]] > t[e[i]] && te(e, r, i), t[e[n]] > t[e[r]] && te(e, n, r);
2053
- const a = e[r], h = t[a];
2095
+ const a = e[r], c = t[a];
2054
2096
  for (; ; ) {
2055
2097
  do
2056
2098
  r++;
2057
- while (t[e[r]] < h);
2099
+ while (t[e[r]] < c);
2058
2100
  do
2059
2101
  s--;
2060
- while (t[e[s]] > h);
2102
+ while (t[e[s]] > c);
2061
2103
  if (s < r) break;
2062
2104
  te(e, r, s);
2063
2105
  }
@@ -2068,13 +2110,13 @@ function te(e, t, n) {
2068
2110
  const i = e[t];
2069
2111
  e[t] = e[n], e[n] = i;
2070
2112
  }
2071
- function br(e) {
2113
+ function Sr(e) {
2072
2114
  return e[0];
2073
2115
  }
2074
- function xr(e) {
2116
+ function Er(e) {
2075
2117
  return e[1];
2076
2118
  }
2077
- class _r {
2119
+ class kr {
2078
2120
  bs;
2079
2121
  width;
2080
2122
  constructor(t, n) {
@@ -2130,25 +2172,25 @@ class _r {
2130
2172
  return this;
2131
2173
  }
2132
2174
  }
2133
- class kn extends _r {
2175
+ class kn extends kr {
2134
2176
  constructor(t) {
2135
2177
  super(8, new Uint8Array(Math.ceil(t / 8)).fill(0));
2136
2178
  }
2137
2179
  }
2138
- function qt(e) {
2180
+ function jt(e) {
2139
2181
  return e % 3 === 2 ? e - 2 : e + 1;
2140
2182
  }
2141
- function Ot(e) {
2183
+ function Pt(e) {
2142
2184
  return e % 3 === 0 ? e + 2 : e - 1;
2143
2185
  }
2144
- function En(e, t, n, i, o, r, s, a) {
2145
- const h = Pt(e, t, o, r, s, a), l = Pt(n, i, o, r, s, a);
2146
- if (h > 0 && l > 0 || h < 0 && l < 0)
2186
+ function An(e, t, n, i, o, r, s, a) {
2187
+ const c = Ot(e, t, o, r, s, a), f = Ot(n, i, o, r, s, a);
2188
+ if (c > 0 && f > 0 || c < 0 && f < 0)
2147
2189
  return !1;
2148
- const u = Pt(o, r, e, t, n, i), c = Pt(s, a, e, t, n, i);
2149
- return u > 0 && c > 0 || u < 0 && c < 0 ? !1 : h === 0 && l === 0 && u === 0 && c === 0 ? !(Math.max(o, s) < Math.min(e, n) || Math.max(e, n) < Math.min(o, s) || Math.max(r, a) < Math.min(t, i) || Math.max(t, i) < Math.min(r, a)) : !0;
2190
+ const h = Ot(o, r, e, t, n, i), l = Ot(s, a, e, t, n, i);
2191
+ return h > 0 && l > 0 || h < 0 && l < 0 ? !1 : c === 0 && f === 0 && h === 0 && l === 0 ? !(Math.max(o, s) < Math.min(e, n) || Math.max(e, n) < Math.min(o, s) || Math.max(r, a) < Math.min(t, i) || Math.max(t, i) < Math.min(r, a)) : !0;
2150
2192
  }
2151
- class Mr {
2193
+ class Ar {
2152
2194
  /**
2153
2195
  * The triangulation object from Delaunator.
2154
2196
  */
@@ -2157,7 +2199,7 @@ class Mr {
2157
2199
  this.del = t;
2158
2200
  }
2159
2201
  }
2160
- class Sr extends Mr {
2202
+ class Ir extends Ar {
2161
2203
  vertMap;
2162
2204
  flips;
2163
2205
  consd;
@@ -2187,75 +2229,120 @@ class Sr extends Mr {
2187
2229
  * Constrain the triangulation such that there is an edge between p1 and p2.
2188
2230
  */
2189
2231
  constrainOne(t, n) {
2190
- const { triangles: i, halfedges: o } = this.del, r = this.vertMap[t];
2191
- let s = r;
2232
+ const { triangles: i, halfedges: o } = this.del;
2233
+ this.assertVertex(t, t, n), this.assertVertex(n, t, n), this.assertInTriangulation(t, t, n), this.assertInTriangulation(n, t, n);
2234
+ const r = this.vertMap[t], s = this.maxConstrainSteps();
2235
+ let a = 0, c = r;
2192
2236
  do {
2193
- const l = i[s], u = qt(s);
2237
+ if (++a > s)
2238
+ throw new Error(
2239
+ `Constraining edge [${t}, ${n}] exceeded the iteration limit`
2240
+ );
2241
+ const l = i[c], u = jt(c);
2194
2242
  if (l === n)
2195
- return this.protect(s);
2196
- const c = Ot(s), f = i[c];
2197
- if (f === n)
2243
+ return this.protect(c);
2244
+ const p = Pt(c), _ = i[p];
2245
+ if (_ === n)
2198
2246
  return this.protect(u), u;
2199
- if (this.intersectSegments(t, n, f, l)) {
2200
- s = c;
2247
+ if (this.intersectSegments(t, n, _, l)) {
2248
+ c = p;
2201
2249
  break;
2202
2250
  }
2203
- s = o[u];
2204
- } while (s !== -1 && s !== r);
2205
- let a = s, h = -1;
2206
- for (; s !== -1; ) {
2207
- const l = o[s], u = Ot(s), c = Ot(l), f = qt(l);
2251
+ c = o[u];
2252
+ } while (c !== -1 && c !== r);
2253
+ let f = c, h = -1;
2254
+ for (; c !== -1; ) {
2255
+ if (++a > s)
2256
+ throw new Error(
2257
+ `Constraining edge [${t}, ${n}] exceeded the iteration limit`
2258
+ );
2259
+ const l = o[c], u = Pt(c), p = Pt(l), _ = jt(l);
2208
2260
  if (l === -1)
2209
2261
  throw new Error("Constraining edge exited the hull");
2210
- if (this.consd.has(s))
2262
+ if (this.consd.has(c))
2211
2263
  throw new Error("Edge intersects already constrained edge");
2212
- if (this.isCollinear(t, n, i[s]) || this.isCollinear(t, n, i[l]))
2264
+ if (this.isCollinear(t, n, i[c]) || this.isCollinear(t, n, i[l]))
2213
2265
  throw new Error("Constraining edge intersects point");
2214
2266
  if (!this.intersectSegments(
2215
- i[s],
2267
+ i[c],
2216
2268
  i[l],
2217
2269
  i[u],
2218
- i[c]
2270
+ i[p]
2219
2271
  )) {
2220
- if (h === -1 && (h = s), i[c] === n) {
2221
- if (s === h)
2272
+ if (h === -1 && (h = c), i[p] === n) {
2273
+ if (c === h)
2222
2274
  throw new Error("Infinite loop: non-convex quadrilateral");
2223
- s = h, h = -1;
2275
+ c = h, h = -1;
2224
2276
  continue;
2225
2277
  }
2226
2278
  if (this.intersectSegments(
2227
2279
  t,
2228
2280
  n,
2229
- i[c],
2281
+ i[p],
2230
2282
  i[l]
2231
2283
  ))
2232
- s = c;
2284
+ c = p;
2233
2285
  else if (this.intersectSegments(
2234
2286
  t,
2235
2287
  n,
2236
- i[f],
2237
- i[c]
2288
+ i[_],
2289
+ i[p]
2238
2290
  ))
2239
- s = f;
2240
- else if (h === s)
2291
+ c = _;
2292
+ else if (h === c)
2241
2293
  throw new Error("Infinite loop: no further intersect after non-convex");
2242
2294
  continue;
2243
2295
  }
2244
- if (this.flipDiagonal(s), this.intersectSegments(
2296
+ if (this.flipDiagonal(c), this.intersectSegments(
2245
2297
  t,
2246
2298
  n,
2247
2299
  i[u],
2248
- i[c]
2300
+ i[p]
2249
2301
  ) && (h === -1 && (h = u), h === u))
2250
2302
  throw new Error("Infinite loop: flipped diagonal still intersects");
2251
- i[c] === n ? (a = c, s = h, h = -1) : this.intersectSegments(
2303
+ i[p] === n ? (f = p, c = h, h = -1) : this.intersectSegments(
2252
2304
  t,
2253
2305
  n,
2254
- i[f],
2255
- i[c]
2256
- ) && (s = f);
2306
+ i[_],
2307
+ i[p]
2308
+ ) && (c = _);
2257
2309
  }
2258
- return this.protect(a), this.delaunify(!0), this.findEdge(t, n);
2310
+ return this.protect(f), this.delaunify(!0), this.findEdge(t, n);
2311
+ }
2312
+ /**
2313
+ * Upper bound for the number of steps taken while constraining one edge.
2314
+ *
2315
+ * A constraint that crosses k edges is resolved in passes over the crossed
2316
+ * edges, so the number of steps can grow with k squared (for example when
2317
+ * the crossed edges fan out between two bowed rows of points). k is less
2318
+ * than the number of half-edges, so the square of that number is never
2319
+ * reached by a walk that terminates. The floor keeps tiny meshes away from
2320
+ * the limit.
2321
+ */
2322
+ maxConstrainSteps() {
2323
+ const t = this.del.triangles.length;
2324
+ return Math.max(t * t, 4096);
2325
+ }
2326
+ /**
2327
+ * Throw unless `vertex` is part of the triangulation. Delaunator leaves out
2328
+ * points that coincide with another point, so a valid point id may have no
2329
+ * triangle. An edge cannot start or end at such a point.
2330
+ */
2331
+ assertInTriangulation(t, n, i) {
2332
+ if (this.vertMap[t] >= this.del.triangles.length)
2333
+ throw new Error(
2334
+ `Invalid edge [${n}, ${i}]: vertex ${t} is not part of the triangulation`
2335
+ );
2336
+ }
2337
+ /**
2338
+ * Throw unless `vertex` is an id of a point given to Delaunator.
2339
+ */
2340
+ assertVertex(t, n, i) {
2341
+ const o = this.vertMap.length;
2342
+ if (!Number.isInteger(t) || t < 0 || t >= o)
2343
+ throw new Error(
2344
+ `Invalid edge [${String(n)}, ${String(i)}]: vertex ids must be integers from 0 to ${o - 1}`
2345
+ );
2259
2346
  }
2260
2347
  /**
2261
2348
  * Fix the Delaunay condition.
@@ -2269,8 +2356,8 @@ class Sr extends Mr {
2269
2356
  if (o.has(a))
2270
2357
  continue;
2271
2358
  i.delete(a);
2272
- const h = n[a];
2273
- h !== -1 && (i.delete(h), this.isDelaunay(a) || (this.flipDiagonal(a), s++));
2359
+ const c = n[a];
2360
+ c !== -1 && (i.delete(c), this.isDelaunay(a) || (this.flipDiagonal(a), s++));
2274
2361
  }
2275
2362
  } while (t && s > 0);
2276
2363
  return this;
@@ -2298,13 +2385,19 @@ class Sr extends Mr {
2298
2385
  */
2299
2386
  findEdge(t, n) {
2300
2387
  const i = this.vertMap[n], { triangles: o, halfedges: r } = this.del;
2301
- let s = i, a;
2388
+ if (!(i < o.length))
2389
+ return 1 / 0;
2390
+ let s = i, a, c = 0;
2302
2391
  do {
2392
+ if (++c > o.length)
2393
+ throw new Error(
2394
+ `Looking up edge [${t}, ${n}] exceeded the iteration limit`
2395
+ );
2303
2396
  if (o[s] === t)
2304
2397
  return s;
2305
- a = qt(s), s = r[a];
2398
+ a = jt(s), s = r[a];
2306
2399
  } while (s !== -1 && s !== i);
2307
- return o[qt(a)] === t ? -a : 1 / 0;
2400
+ return o[jt(a)] === t ? -a : 1 / 0;
2308
2401
  }
2309
2402
  /**
2310
2403
  * Mark an edge as constrained, i.e. should not be touched by `delaunify`.
@@ -2327,17 +2420,17 @@ class Sr extends Mr {
2327
2420
  * Flip the edge shared by two triangles.
2328
2421
  */
2329
2422
  flipDiagonal(t) {
2330
- const { triangles: n, halfedges: i } = this.del, o = this.flips, r = this.consd, s = i[t], a = Ot(t), h = qt(t), l = Ot(s), u = qt(s), c = i[a], f = i[l];
2423
+ const { triangles: n, halfedges: i } = this.del, o = this.flips, r = this.consd, s = i[t], a = Pt(t), c = jt(t), f = Pt(s), h = jt(s), l = i[a], u = i[f];
2331
2424
  if (r.has(t))
2332
2425
  throw new Error("Trying to flip a constrained edge");
2333
- return n[t] = n[l], i[t] = f, o.set(t, o.has(l)) || r.set(t, r.has(l)), f !== -1 && (i[f] = t), i[a] = l, n[s] = n[a], i[s] = c, o.set(s, o.has(a)) || r.set(s, r.has(a)), c !== -1 && (i[c] = s), i[l] = a, this.markFlip(t), this.markFlip(h), this.markFlip(s), this.markFlip(u), o.add(a), r.delete(a), o.add(l), r.delete(l), this.updateVert(t), this.updateVert(h), this.updateVert(s), this.updateVert(u), a;
2426
+ return n[t] = n[f], i[t] = u, o.set(t, o.has(f)) || r.set(t, r.has(f)), u !== -1 && (i[u] = t), i[a] = f, n[s] = n[a], i[s] = l, o.set(s, o.has(a)) || r.set(s, r.has(a)), l !== -1 && (i[l] = s), i[f] = a, this.markFlip(t), this.markFlip(c), this.markFlip(s), this.markFlip(h), o.add(a), r.delete(a), o.add(f), r.delete(f), this.updateVert(t), this.updateVert(c), this.updateVert(s), this.updateVert(h), a;
2334
2427
  }
2335
2428
  /**
2336
2429
  * Whether point p1, p2, and p are collinear.
2337
2430
  */
2338
2431
  isCollinear(t, n, i) {
2339
2432
  const o = this.del.coords;
2340
- return Pt(
2433
+ return Ot(
2341
2434
  o[t * 2],
2342
2435
  o[t * 2 + 1],
2343
2436
  o[n * 2],
@@ -2351,7 +2444,7 @@ class Sr extends Mr {
2351
2444
  */
2352
2445
  inCircle(t, n, i, o) {
2353
2446
  const r = this.del.coords;
2354
- return ui(
2447
+ return mi(
2355
2448
  r[t * 2],
2356
2449
  r[t * 2 + 1],
2357
2450
  r[n * 2],
@@ -2369,17 +2462,17 @@ class Sr extends Mr {
2369
2462
  const { triangles: n, halfedges: i } = this.del, o = i[t];
2370
2463
  if (o === -1)
2371
2464
  return !0;
2372
- const r = n[Ot(t)], s = n[t], a = n[qt(t)], h = n[Ot(o)];
2373
- return !this.inCircle(r, s, a, h);
2465
+ const r = n[Pt(t)], s = n[t], a = n[jt(t)], c = n[Pt(o)];
2466
+ return !this.inCircle(r, s, a, c);
2374
2467
  }
2375
2468
  /**
2376
2469
  * Update the vertex -> incoming edge map.
2377
2470
  */
2378
2471
  updateVert(t) {
2379
2472
  const { triangles: n, halfedges: i } = this.del, o = this.vertMap, r = n[t];
2380
- let s = Ot(t), a = i[s];
2473
+ let s = Pt(t), a = i[s];
2381
2474
  for (; a !== -1 && a !== t; )
2382
- s = Ot(a), a = i[s];
2475
+ s = Pt(a), a = i[s];
2383
2476
  return o[r] = s, s;
2384
2477
  }
2385
2478
  /**
@@ -2387,7 +2480,7 @@ class Sr extends Mr {
2387
2480
  */
2388
2481
  intersectSegments(t, n, i, o) {
2389
2482
  const r = this.del.coords;
2390
- return t === i || t === o || n === i || n === o ? !1 : En(
2483
+ return t === i || t === o || n === i || n === o ? !1 : An(
2391
2484
  r[t * 2],
2392
2485
  r[t * 2 + 1],
2393
2486
  r[n * 2],
@@ -2398,65 +2491,115 @@ class Sr extends Mr {
2398
2491
  r[o * 2 + 1]
2399
2492
  );
2400
2493
  }
2401
- static intersectSegments = En;
2494
+ static intersectSegments = An;
2402
2495
  }
2403
2496
  function be(e, t, n) {
2404
2497
  if (t || (t = []), typeof e != "object" || e.type !== "FeatureCollection")
2405
2498
  throw "Argument points must be FeatureCollection";
2406
2499
  if (!Array.isArray(t)) throw "Argument points must be Array of Array";
2407
2500
  const i = e.features.map(
2408
- (h) => h.geometry.coordinates
2409
- ), o = Je.from(i);
2501
+ (c) => c.geometry.coordinates
2502
+ ), o = Ge.from(i);
2410
2503
  let r;
2411
2504
  const s = [];
2412
- o.triangles.length !== 0 && t.length !== 0 && (r = new Sr(o), r.constrainAll(t));
2413
- for (let h = 0; h < o.triangles.length; h += 3)
2414
- s.push([o.triangles[h], o.triangles[h + 1], o.triangles[h + 2]]);
2505
+ o.triangles.length !== 0 && t.length !== 0 && (r = new Ir(o), r.constrainAll(t));
2506
+ for (let c = 0; c < o.triangles.length; c += 3)
2507
+ s.push([o.triangles[c], o.triangles[c + 1], o.triangles[c + 2]]);
2415
2508
  const a = ["a", "b", "c"];
2416
- return St(
2417
- s.map((h) => {
2418
- const l = {}, u = h.map((c, f) => {
2419
- const p = e.features[c], M = p.geometry.coordinates, w = [M[0], M[1]];
2420
- return M.length === 3 ? w[2] = M[2] : l[a[f]] = p.properties[n], w;
2509
+ return Et(
2510
+ s.map((c) => {
2511
+ const f = {}, h = c.map((l, u) => {
2512
+ const p = e.features[l], _ = p.geometry.coordinates, w = [_[0], _[1]];
2513
+ return _.length === 3 ? w[2] = _[2] : f[a[u]] = p.properties[n], w;
2421
2514
  });
2422
- return u[3] = u[0], le([u], l);
2515
+ return h[3] = h[0], le([h], f);
2423
2516
  })
2424
2517
  );
2425
2518
  }
2426
- function kr(e, t) {
2519
+ const Or = 256 * Number.EPSILON;
2520
+ function Pr(e, t) {
2521
+ const n = [e, t].map((o) => {
2522
+ const r = o.map((a, c, f) => {
2523
+ if (c === 0) return 0;
2524
+ const h = f[c - 1];
2525
+ return Math.sqrt(
2526
+ Math.pow(a[0] - h[0], 2) + Math.pow(a[1] - h[1], 2)
2527
+ );
2528
+ }), s = r.reduce((a, c, f) => f === 0 ? [0] : (a.push(a[f - 1] + c), a), []);
2529
+ return s.map((a, c, f) => {
2530
+ const h = a / f[f.length - 1];
2531
+ return [o[c], r[c], s[c], h];
2532
+ });
2533
+ }), i = [];
2534
+ return n.forEach((o, r) => {
2535
+ const s = n[r ? 0 : 1];
2536
+ o.forEach((a, c) => {
2537
+ if (c === 0 || c === o.length - 1 || a[4] === "handled")
2538
+ return;
2539
+ const f = a[0], h = a[3];
2540
+ let l, u = 1 / 0;
2541
+ for (let p = 1; p < s.length - 1; p++) {
2542
+ const _ = s[p];
2543
+ if (_[4] === "handled") continue;
2544
+ const w = Math.abs(_[3] - h);
2545
+ w <= Or && w < u && (l = _, u = w);
2546
+ }
2547
+ if (l) {
2548
+ l[4] = "handled", a[4] = "handled", i.push(
2549
+ r === 0 ? [f, l[0], h] : [l[0], f, h]
2550
+ );
2551
+ return;
2552
+ }
2553
+ for (let p = 0; p < s.length - 1; p++) {
2554
+ const _ = s[p], w = s[p + 1], O = _[3], M = w[3];
2555
+ if (O < h && M > h) {
2556
+ const m = (h - O) / (M - O), v = [
2557
+ (w[0][0] - _[0][0]) * m + _[0][0],
2558
+ (w[0][1] - _[0][1]) * m + _[0][1]
2559
+ ];
2560
+ i.push(
2561
+ r === 0 ? [f, v, h] : [v, f, h]
2562
+ );
2563
+ return;
2564
+ }
2565
+ }
2566
+ });
2567
+ }), i.sort((o, r) => o[2] - r[2]);
2568
+ }
2569
+ function Nr(e, t) {
2427
2570
  const n = [[], [], [], []], i = [];
2428
2571
  return Object.keys(e).forEach((o) => {
2429
- const r = e[o], s = r.forw, a = r.bakw, h = [
2572
+ const r = e[o], s = r.forw, a = r.bakw, c = [
2430
2573
  s[0] - t.forw[0],
2431
2574
  s[1] - t.forw[1]
2432
- ], l = [
2575
+ ], f = [
2433
2576
  a[0] - t.bakw[0],
2434
2577
  t.bakw[1] - a[1]
2435
- ], u = { forw: h, bakw: l };
2436
- if (i.push(u), h[0] === 0 || h[1] === 0)
2578
+ ], h = { forw: c, bakw: f };
2579
+ if (i.push(h), c[0] === 0 || c[1] === 0)
2437
2580
  return;
2438
- let c = 0;
2439
- h[0] > 0 && (c += 1), h[1] > 0 && (c += 2), n[c].push(u);
2581
+ let l = 0;
2582
+ c[0] > 0 && (l += 1), c[1] > 0 && (l += 2), n[l].push(h);
2440
2583
  }), { perQuad: n, aggregate: i };
2441
2584
  }
2442
- function Er(e) {
2585
+ function Br(e) {
2443
2586
  let t = 1 / 0, n = 0, i = 0;
2444
2587
  return e.forEach((o) => {
2445
- const { forw: r, bakw: s } = o, a = Math.hypot(r[0], r[1]), h = Math.hypot(s[0], s[1]);
2446
- if (h === 0) return;
2447
- const l = a / h, u = Math.atan2(r[0], r[1]) - Math.atan2(s[0], s[1]);
2448
- t = Math.min(t, l), n += Math.cos(u), i += Math.sin(u);
2588
+ const { forw: r, bakw: s } = o, a = Math.hypot(r[0], r[1]), c = Math.hypot(s[0], s[1]);
2589
+ if (c === 0) return;
2590
+ const f = a / c, h = Math.atan2(r[0], r[1]) - Math.atan2(s[0], s[1]);
2591
+ t = Math.min(t, f), n += Math.cos(h), i += Math.sin(h);
2449
2592
  }), isFinite(t) ? [t, Math.atan2(i, n)] : [1, 0];
2450
2593
  }
2451
- function Ar(e, t, n) {
2452
- const { perQuad: i, aggregate: o } = kr(e, t), r = i.every((h) => h.length > 0), a = (n === "birdeye" ? r ? i : [o] : [o]).map((h) => Er(h));
2594
+ function Tr(e, t, n) {
2595
+ const { perQuad: i, aggregate: o } = Nr(e, t), r = i.every((c) => c.length > 0), a = (n === "birdeye" ? r ? i : [o] : [o]).map((c) => Br(c));
2453
2596
  return a.length === 1 ? [a[0], a[0], a[0], a[0]] : a;
2454
2597
  }
2455
- function Ir(e, t) {
2598
+ function Cr(e, t) {
2456
2599
  let n = 0;
2457
2600
  return e[0] > t[0] && (n += 1), e[1] > t[1] && (n += 2), n;
2458
2601
  }
2459
- function Pr(e, t, n) {
2602
+ function Xr(e, t, n) {
2460
2603
  const i = [
2461
2604
  e[0] - t.forw[0],
2462
2605
  e[1] - t.forw[1]
@@ -2466,69 +2609,69 @@ function Pr(e, t, n) {
2466
2609
  t.bakw[1] - r * Math.cos(s)
2467
2610
  ];
2468
2611
  }
2469
- function Or(e, t, n, i) {
2612
+ function $r(e, t, n, i) {
2470
2613
  const o = t[0] - e[0], r = t[1] - e[1];
2471
2614
  if (Math.abs(o) < 1e-12 && Math.abs(r) < 1e-12) return null;
2472
- const s = i[0] - n[0], a = i[1] - n[1], h = n[0] - e[0], l = n[1] - e[1], u = o * a - r * s;
2473
- if (Math.abs(u) < 1e-12) return null;
2474
- const c = (h * a - l * s) / u, f = (h * r - l * o) / u;
2475
- return c <= 1e-10 || f < -1e-10 || f > 1 + 1e-10 ? null : { t: c, point: [e[0] + c * o, e[1] + c * r] };
2615
+ const s = i[0] - n[0], a = i[1] - n[1], c = n[0] - e[0], f = n[1] - e[1], h = o * a - r * s;
2616
+ if (Math.abs(h) < 1e-12) return null;
2617
+ const l = (c * a - f * s) / h, u = (c * r - f * o) / h;
2618
+ return l <= 1e-10 || u < -1e-10 || u > 1 + 1e-10 ? null : { t: l, point: [e[0] + l * o, e[1] + l * r] };
2476
2619
  }
2477
- function Br(e, t, n) {
2620
+ function Dr(e, t, n) {
2478
2621
  const i = n.length;
2479
2622
  let o = -1 / 0, r = null;
2480
2623
  for (let s = 0; s < i; s++) {
2481
- const a = (s + 1) % i, h = Or(
2624
+ const a = (s + 1) % i, c = $r(
2482
2625
  e,
2483
2626
  t,
2484
2627
  n[s].bakw,
2485
2628
  n[a].bakw
2486
2629
  );
2487
- h && h.t > o && (o = h.t, r = h.point);
2630
+ c && c.t > o && (o = c.t, r = c.point);
2488
2631
  }
2489
2632
  return r;
2490
2633
  }
2491
- function An(e, t) {
2634
+ function In(e, t) {
2492
2635
  const i = Math.atan2(e[0] - t[0], e[1] - t[1]) * (180 / Math.PI);
2493
2636
  return i < 0 ? i + 360 : i;
2494
2637
  }
2495
- function In(e, t, n, i, o, r) {
2638
+ function On(e, t, n, i, o, r) {
2496
2639
  const s = t[0] - e[0], a = t[1] - e[1];
2497
2640
  if (s === 0 && a === 0) return null;
2498
- const h = [];
2641
+ const c = [];
2499
2642
  if (s !== 0)
2500
- for (const u of [n, i]) {
2501
- const c = (u - e[0]) / s;
2502
- if (c > 0) {
2503
- const f = e[1] + c * a;
2504
- f >= o && f <= r && h.push({ t: c, x: u, y: f });
2643
+ for (const h of [n, i]) {
2644
+ const l = (h - e[0]) / s;
2645
+ if (l > 0) {
2646
+ const u = e[1] + l * a;
2647
+ u >= o && u <= r && c.push({ t: l, x: h, y: u });
2505
2648
  }
2506
2649
  }
2507
2650
  if (a !== 0)
2508
- for (const u of [o, r]) {
2509
- const c = (u - e[1]) / a;
2510
- if (c > 0) {
2511
- const f = e[0] + c * s;
2512
- f >= n && f <= i && h.push({ t: c, x: f, y: u });
2651
+ for (const h of [o, r]) {
2652
+ const l = (h - e[1]) / a;
2653
+ if (l > 0) {
2654
+ const u = e[0] + l * s;
2655
+ u >= n && u <= i && c.push({ t: l, x: u, y: h });
2513
2656
  }
2514
2657
  }
2515
- if (h.length === 0) return null;
2516
- h.sort((u, c) => u.t - c.t);
2517
- const l = h[0];
2518
- return [l.x, l.y];
2658
+ if (c.length === 0) return null;
2659
+ c.sort((h, l) => h.t - l.t);
2660
+ const f = c[0];
2661
+ return [f.x, f.y];
2519
2662
  }
2520
2663
  function Pn(e, t, n) {
2521
2664
  const i = e.length, o = new Array(i).fill(1);
2522
2665
  for (const r of t)
2523
2666
  for (let s = 0; s < i; s++) {
2524
- const a = (s + 1) % i, h = He([e[s].bakw, e[a].bakw]), l = He([n.bakw, r.bakw]), u = Pi(h, l);
2525
- if (u.features.length > 0 && u.features[0].geometry) {
2526
- const c = u.features[0], f = Math.sqrt(
2667
+ const a = (s + 1) % i, c = He([e[s].bakw, e[a].bakw]), f = He([n.bakw, r.bakw]), h = Bi(c, f);
2668
+ if (h.features.length > 0 && h.features[0].geometry) {
2669
+ const l = h.features[0], u = Math.sqrt(
2527
2670
  Math.pow(r.bakw[0] - n.bakw[0], 2) + Math.pow(r.bakw[1] - n.bakw[1], 2)
2528
2671
  ), p = Math.sqrt(
2529
- Math.pow(c.geometry.coordinates[0] - n.bakw[0], 2) + Math.pow(c.geometry.coordinates[1] - n.bakw[1], 2)
2530
- ), M = f / p;
2531
- M > o[s] && (o[s] = M), M > o[a] && (o[a] = M);
2672
+ Math.pow(l.geometry.coordinates[0] - n.bakw[0], 2) + Math.pow(l.geometry.coordinates[1] - n.bakw[1], 2)
2673
+ ), _ = u / p;
2674
+ _ > o[s] && (o[s] = _), _ > o[a] && (o[a] = _);
2532
2675
  }
2533
2676
  }
2534
2677
  e.forEach((r, s) => {
@@ -2539,114 +2682,114 @@ function Pn(e, t, n) {
2539
2682
  ];
2540
2683
  });
2541
2684
  }
2542
- function Gn(e, t, n) {
2543
- const { convexBuf: i, centroid: o, allGcps: r, minx: s, maxx: a, miny: h, maxy: l } = e, u = Ar(i, o, t), f = [
2544
- [s, h],
2545
- [a, h],
2546
- [a, l],
2547
- [s, l]
2685
+ function Qn(e, t, n) {
2686
+ const { convexBuf: i, centroid: o, allGcps: r, minx: s, maxx: a, miny: c, maxy: f } = e, h = Tr(i, o, t), u = [
2687
+ [s, c],
2688
+ [a, c],
2689
+ [a, f],
2690
+ [s, f]
2548
2691
  ].map((g) => ({
2549
2692
  forw: g,
2550
- bakw: Pr(
2693
+ bakw: Xr(
2551
2694
  g,
2552
2695
  o,
2553
- u[Ir(g, o.forw)]
2696
+ h[Cr(g, o.forw)]
2554
2697
  )
2555
2698
  }));
2556
- if (f.sort(
2557
- (g, k) => Math.atan2(g.forw[0] - o.forw[0], g.forw[1] - o.forw[1]) - Math.atan2(k.forw[0] - o.forw[0], k.forw[1] - o.forw[1])
2558
- ), Pn(f, r, o), !n) return f;
2559
- const p = 4, M = f.map(
2699
+ if (u.sort(
2700
+ (g, E) => Math.atan2(g.forw[0] - o.forw[0], g.forw[1] - o.forw[1]) - Math.atan2(E.forw[0] - o.forw[0], E.forw[1] - o.forw[1])
2701
+ ), Pn(u, r, o), !n) return u;
2702
+ const p = 4, _ = u.map(
2560
2703
  (g) => Math.atan2(g.forw[0] - o.forw[0], g.forw[1] - o.forw[1])
2561
- ), w = f.map(
2704
+ ), w = u.map(
2562
2705
  (g) => Math.atan2(
2563
2706
  g.bakw[0] - o.bakw[0],
2564
2707
  -(g.bakw[1] - o.bakw[1])
2565
2708
  )
2566
2709
  );
2567
- function I(g) {
2568
- for (let k = 0; k < p; k++) {
2569
- const S = (k + 1) % p, A = M[k], O = k < p - 1 ? M[S] : M[S] + 2 * Math.PI;
2570
- let B = g;
2571
- for (; B < A; ) B += 2 * Math.PI;
2572
- for (; B >= A + 2 * Math.PI; ) B -= 2 * Math.PI;
2573
- if (B >= A && B < O)
2574
- return { i: k, j: S, frac: (B - A) / (O - A) };
2710
+ function O(g) {
2711
+ for (let E = 0; E < p; E++) {
2712
+ const S = (E + 1) % p, k = _[E], P = E < p - 1 ? _[S] : _[S] + 2 * Math.PI;
2713
+ let N = g;
2714
+ for (; N < k; ) N += 2 * Math.PI;
2715
+ for (; N >= k + 2 * Math.PI; ) N -= 2 * Math.PI;
2716
+ if (N >= k && N < P)
2717
+ return { i: E, j: S, frac: (N - k) / (P - k) };
2575
2718
  }
2576
2719
  return { i: 0, j: 1, frac: 0 };
2577
2720
  }
2578
- function x(g) {
2579
- const { i: k, j: S, frac: A } = I(g), O = w[k];
2580
- let X = w[S] - O;
2581
- for (; X > Math.PI; ) X -= 2 * Math.PI;
2582
- for (; X < -Math.PI; ) X += 2 * Math.PI;
2583
- return O + A * X;
2721
+ function M(g) {
2722
+ const { i: E, j: S, frac: k } = O(g), P = w[E];
2723
+ let C = w[S] - P;
2724
+ for (; C > Math.PI; ) C -= 2 * Math.PI;
2725
+ for (; C < -Math.PI; ) C += 2 * Math.PI;
2726
+ return P + k * C;
2584
2727
  }
2585
2728
  const m = new Set(
2586
- f.map(
2587
- (g) => Math.floor(An(g.forw, o.forw) / 10) % 36
2729
+ u.map(
2730
+ (g) => Math.floor(In(g.forw, o.forw) / 10) % 36
2588
2731
  )
2589
- ), _ = r.map((g) => ({
2732
+ ), v = r.map((g) => ({
2590
2733
  forw: g.forw,
2591
2734
  bakw: g.bakw,
2592
- angleDeg: An(g.forw, o.forw),
2735
+ angleDeg: In(g.forw, o.forw),
2593
2736
  forwDist: Math.hypot(g.forw[0] - o.forw[0], g.forw[1] - o.forw[1])
2594
2737
  })), d = [];
2595
2738
  for (let g = 0; g < 36; g++) {
2596
2739
  if (m.has(g)) continue;
2597
- const k = g * 10, S = _.filter(
2598
- (P) => P.angleDeg >= k && P.angleDeg < k + 10
2740
+ const E = g * 10, S = v.filter(
2741
+ (I) => I.angleDeg >= E && I.angleDeg < E + 10
2599
2742
  );
2600
- let A = null;
2743
+ let k = null;
2601
2744
  if (S.length > 0) {
2602
- const P = S.reduce((E, T) => T.forwDist > E.forwDist ? T : E);
2603
- A = In(o.forw, P.forw, s, a, h, l);
2745
+ const I = S.reduce((A, T) => T.forwDist > A.forwDist ? T : A);
2746
+ k = On(o.forw, I.forw, s, a, c, f);
2604
2747
  }
2605
- if (!A) {
2606
- const P = (k + 5) % 360 * (Math.PI / 180), E = [
2607
- o.forw[0] + Math.sin(P),
2608
- o.forw[1] + Math.cos(P)
2748
+ if (!k) {
2749
+ const I = (E + 5) % 360 * (Math.PI / 180), A = [
2750
+ o.forw[0] + Math.sin(I),
2751
+ o.forw[1] + Math.cos(I)
2609
2752
  ];
2610
- A = In(o.forw, E, s, a, h, l);
2753
+ k = On(o.forw, A, s, a, c, f);
2611
2754
  }
2612
- if (!A) continue;
2613
- const O = [A[0] - o.forw[0], A[1] - o.forw[1]], B = Math.atan2(O[0], O[1]), X = x(B), Y = [
2614
- o.bakw[0] + Math.sin(X),
2615
- o.bakw[1] - Math.cos(X)
2616
- ], y = Br(o.bakw, Y, f);
2617
- y && d.push({ forw: A, bakw: y });
2618
- }
2619
- const v = [...f, ...d];
2620
- return v.sort(
2621
- (g, k) => Math.atan2(g.forw[0] - o.forw[0], g.forw[1] - o.forw[1]) - Math.atan2(k.forw[0] - o.forw[0], k.forw[1] - o.forw[1])
2622
- ), Pn(v, r, o), v;
2623
- }
2624
- function Nr(e, t = !1) {
2625
- return Gn(e, "plain", t);
2626
- }
2627
- function Tr(e, t = !1) {
2628
- return Gn(e, "birdeye", t);
2629
- }
2630
- function Xr(e) {
2631
- Cr(e);
2632
- const n = new Dr(e).findSegmentIntersections(), i = Qn(n), o = /* @__PURE__ */ new Map();
2633
- return i.forEach((r) => {
2634
- o.set(`${r.x}:${r.y}`, r);
2635
- }), Array.from(o.values()).map(
2636
- (r) => $t([r.x, r.y])
2755
+ if (!k) continue;
2756
+ const P = [k[0] - o.forw[0], k[1] - o.forw[1]], N = Math.atan2(P[0], P[1]), C = M(N), F = [
2757
+ o.bakw[0] + Math.sin(C),
2758
+ o.bakw[1] - Math.cos(C)
2759
+ ], y = Dr(o.bakw, F, u);
2760
+ y && d.push({ forw: k, bakw: y });
2761
+ }
2762
+ const b = [...u, ...d];
2763
+ return b.sort(
2764
+ (g, E) => Math.atan2(g.forw[0] - o.forw[0], g.forw[1] - o.forw[1]) - Math.atan2(E.forw[0] - o.forw[0], E.forw[1] - o.forw[1])
2765
+ ), Pn(b, r, o), b;
2766
+ }
2767
+ function Fr(e, t = !1) {
2768
+ return Qn(e, "plain", t);
2769
+ }
2770
+ function Rr(e, t = !1) {
2771
+ return Qn(e, "birdeye", t);
2772
+ }
2773
+ function vo(e) {
2774
+ return Hn(e, 1 / 0);
2775
+ }
2776
+ const Nn = 1e5, Yr = 16;
2777
+ function Hn(e, t) {
2778
+ return Lr(e), new Vr(e).findSegmentIntersections(t).map(
2779
+ (o) => Yt([o.x, o.y])
2637
2780
  );
2638
2781
  }
2639
- function Cr(e) {
2782
+ function Lr(e) {
2640
2783
  for (let t = 0, n = e.length; t < n; t++) {
2641
2784
  const i = e[t];
2642
- ae(i) || Ut(
2785
+ ae(i) || qt(
2643
2786
  "findIntersections() received invalid coordinates:",
2644
2787
  `line=${t}`,
2645
2788
  `points=${i}`
2646
2789
  );
2647
2790
  for (let o = 0, r = i.length; o < r; o++) {
2648
2791
  const s = i[o];
2649
- (!ae(s) || !Number.isFinite(s[0]) || !Number.isFinite(s[1])) && Ut(
2792
+ (!ae(s) || !Number.isFinite(s[0]) || !Number.isFinite(s[1])) && qt(
2650
2793
  "findIntersections() received non-finite coordinates:",
2651
2794
  `line=${t}`,
2652
2795
  `point=${o}`,
@@ -2655,7 +2798,7 @@ function Cr(e) {
2655
2798
  }
2656
2799
  }
2657
2800
  }
2658
- class Dr {
2801
+ class Vr {
2659
2802
  /**
2660
2803
  * 座標データの配列
2661
2804
  * _xx, _yy: Float64Array形式で座標を保持
@@ -2700,7 +2843,7 @@ class Dr {
2700
2843
  let r = 0;
2701
2844
  for (let s = 0; s < o; s++)
2702
2845
  this._ii[s] = r, r += t[s];
2703
- (r != this._xx.length || this._xx.length != this._yy.length) && Ut("ArcCollection#initXYData() Counting error"), this.initBounds(), this._arcIter = new no(this._xx, this._yy);
2846
+ (r != this._xx.length || this._xx.length != this._yy.length) && qt("ArcCollection#initXYData() Counting error"), this.initBounds(), this._arcIter = new co(this._xx, this._yy);
2704
2847
  }
2705
2848
  initBounds() {
2706
2849
  const t = this.calcArcBounds_(this._xx, this._yy, this._nn);
@@ -2712,9 +2855,9 @@ class Dr {
2712
2855
  */
2713
2856
  calcArcBounds_(t, n, i) {
2714
2857
  const o = i.length, r = new Float64Array(o * 4), s = new ce();
2715
- let a = 0, h, l, u;
2716
- for (let c = 0; c < o; c++)
2717
- h = i[c], h > 0 && (l = c * 4, u = io(t, n, a, h), r[l++] = u[0], r[l++] = u[1], r[l++] = u[2], r[l] = u[3], a += h, s.mergeBounds(u));
2858
+ let a = 0, c, f, h;
2859
+ for (let l = 0; l < o; l++)
2860
+ c = i[l], c > 0 && (f = l * 4, h = lo(t, n, a, c), r[f++] = h[0], r[f++] = h[1], r[f++] = h[2], r[f] = h[3], a += c, s.mergeBounds(h));
2718
2861
  return {
2719
2862
  bb: r,
2720
2863
  bounds: s
@@ -2736,10 +2879,10 @@ class Dr {
2736
2879
  // @cb function(i, j, xx, yy)
2737
2880
  forEachArcSegment(t, n) {
2738
2881
  const i = t >= 0, o = i ? t : ~t, r = this.getRetainedInterval(), s = this._nn[o], a = i ? 1 : -1;
2739
- let h = i ? this._ii[o] : this._ii[o] + s - 1, l = h, u = 0;
2740
- for (let c = 1; c < s; c++)
2741
- l += a, (r === 0 || this._zz[l] >= r) && (n(h, l, this._xx, this._yy), h = l, u++);
2742
- return u;
2882
+ let c = i ? this._ii[o] : this._ii[o] + s - 1, f = c, h = 0;
2883
+ for (let l = 1; l < s; l++)
2884
+ f += a, (r === 0 || this._zz[f] >= r) && (n(c, f, this._xx, this._yy), c = f, h++);
2885
+ return h;
2743
2886
  }
2744
2887
  getRetainedInterval() {
2745
2888
  return this._zlimit;
@@ -2782,184 +2925,188 @@ class Dr {
2782
2925
  * 線分の交差を検出
2783
2926
  * ストライプ分割による効率的な判定を実装
2784
2927
  *
2785
- * @returns 検出された交差点の配列
2928
+ * @param limit - 返す交差点の件数の上限(同じ位置の交差は 1 件に数える)
2929
+ * @returns 検出された交差点の配列(同じ位置の重複なし)
2786
2930
  */
2787
- findSegmentIntersections() {
2788
- const t = this.getBounds(), n = t.ymin || 0, i = (t.ymax || 0) - n, o = this.calcSegmentIntersectionStripeCount(), r = new Uint32Array(o), s = o > 1 ? (I) => Math.floor((o - 1) * (I - n) / i) : () => 0, a = o + 1;
2789
- let h, l;
2931
+ findSegmentIntersections(t = 1 / 0) {
2932
+ const n = this.getBounds(), i = n.ymin || 0, o = (n.ymax || 0) - i, r = this.calcSegmentIntersectionStripeCount(), s = new Uint32Array(r), a = r > 1 ? (v) => Math.floor((r - 1) * (v - i) / o) : () => 0, c = r + 1;
2933
+ let f;
2790
2934
  this.forEachSegment(
2791
- (I, x, m, _) => {
2792
- let d = s(_[I]);
2793
- const v = s(_[x]);
2794
- let g = 0;
2795
- for (; r[d] = r[d] + 2, d != v; )
2796
- g++, g > a && Ut(
2935
+ (v, d, b, g) => {
2936
+ let E = a(g[v]);
2937
+ const S = a(g[d]);
2938
+ let k = 0;
2939
+ for (; s[E] = s[E] + 2, E != S; )
2940
+ k++, k > c && qt(
2797
2941
  "findSegmentIntersections() exceeded the stripe iteration limit:",
2798
- `stripeCount=${o}`,
2799
- `s1=${d}`,
2800
- `s2=${v}`
2801
- ), d += v > d ? 1 : -1;
2942
+ `stripeCount=${r}`,
2943
+ `s1=${E}`,
2944
+ `s2=${S}`
2945
+ ), E += S > E ? 1 : -1;
2802
2946
  }
2803
2947
  );
2804
- const u = this.getUint32Array(Rr(r));
2805
- let c = 0;
2806
- const f = [];
2807
- $r(r, (I) => {
2808
- const x = c;
2809
- c += I, f.push(u.subarray(x, c));
2810
- }), Lr(r, 0), this.forEachSegment(
2811
- (I, x, m, _) => {
2812
- let d = s(_[I]);
2813
- const v = s(_[x]);
2814
- let g, k, S = 0;
2815
- for (; g = r[d], r[d] = g + 2, k = f[d], k[g] = I, k[g + 1] = x, d != v; )
2816
- S++, S > a && Ut(
2948
+ const h = this.getUint32Array(qr(s));
2949
+ let l = 0;
2950
+ const u = [];
2951
+ zr(s, (v) => {
2952
+ const d = l;
2953
+ l += v, u.push(h.subarray(d, l));
2954
+ }), Jr(s, 0), this.forEachSegment(
2955
+ (v, d, b, g) => {
2956
+ let E = a(g[v]);
2957
+ const S = a(g[d]);
2958
+ let k, P, N = 0;
2959
+ for (; k = s[E], s[E] = k + 2, P = u[E], P[k] = v, P[k + 1] = d, E != S; )
2960
+ N++, N > c && qt(
2817
2961
  "findSegmentIntersections() exceeded the stripe iteration limit:",
2818
- `stripeCount=${o}`,
2819
- `s1=${d}`,
2820
- `s2=${v}`
2821
- ), d += v > d ? 1 : -1;
2962
+ `stripeCount=${r}`,
2963
+ `s1=${E}`,
2964
+ `s2=${S}`
2965
+ ), E += S > E ? 1 : -1;
2822
2966
  }
2823
2967
  );
2824
- const p = this.getVertexData(), M = [];
2825
- let w;
2826
- for (h = 0; h < o; h++)
2827
- if (p.xx && p.yy)
2828
- for (w = Vr(f[h], p.xx, p.yy), l = 0; l < w.length; l++)
2829
- M.push(w[l]);
2830
- return Qn(M);
2968
+ const p = this.getVertexData(), _ = t * Yr;
2969
+ let w = 0;
2970
+ const O = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Map(), m = (v) => {
2971
+ w++;
2972
+ const d = ao(v);
2973
+ return O.has(d) || (O.add(d), M.set(`${v.x}:${v.y}`, v)), M.size >= t || w >= _;
2974
+ };
2975
+ if (p.xx && p.yy)
2976
+ for (f = 0; f < r && !Gr(u[f], p.xx, p.yy, m); f++)
2977
+ ;
2978
+ return Array.from(M.values());
2831
2979
  }
2832
2980
  }
2833
- function Ut(...e) {
2981
+ function qt(...e) {
2834
2982
  const t = e.join(" ");
2835
2983
  throw new Error(t);
2836
2984
  }
2837
2985
  function ae(e) {
2838
- return e ? Yr(e) ? !0 : Fr(e) ? !1 : e.length === 0 ? !0 : e.length > 0 : !1;
2986
+ return e ? jr(e) ? !0 : Ur(e) ? !1 : e.length === 0 ? !0 : e.length > 0 : !1;
2839
2987
  }
2840
- function Fr(e) {
2988
+ function Ur(e) {
2841
2989
  return e != null && e.toString === String.prototype.toString;
2842
2990
  }
2843
- function Yr(e) {
2991
+ function jr(e) {
2844
2992
  return Array.isArray(e);
2845
2993
  }
2846
- function Rr(e, t) {
2847
- ae(e) || Ut("utils.sum() expects an array, received:", e);
2994
+ function qr(e, t) {
2995
+ ae(e) || qt("utils.sum() expects an array, received:", e);
2848
2996
  let n = 0, i;
2849
2997
  for (let o = 0, r = e.length; o < r; o++)
2850
2998
  i = e[o], i && (n += i);
2851
2999
  return n;
2852
3000
  }
2853
- function $r(e, t, n) {
3001
+ function zr(e, t, n) {
2854
3002
  if (!ae(e))
2855
3003
  throw new Error(`#forEach() takes an array-like argument. ${e}`);
2856
3004
  for (let i = 0, o = e.length; i < o; i++)
2857
3005
  t.call(n, e[i], i);
2858
3006
  }
2859
- function Lr(e, t) {
3007
+ function Jr(e, t) {
2860
3008
  for (let n = 0, i = e.length; n < i; n++)
2861
3009
  e[n] = t;
2862
3010
  return e;
2863
3011
  }
2864
- function Vr(e, t, n) {
2865
- const i = e.length - 2, o = [];
2866
- let r, s, a, h, l, u, c, f, p, M, w, I, x, m, _, d, v;
2867
- for (Wr(t, e), d = 0; d < i; ) {
2868
- for (r = e[d], s = e[d + 1], l = t[r], u = t[s], p = n[r], M = n[s], v = d; v < i && (v += 2, a = e[v], c = t[a], !(u < c)); ) {
2869
- if (w = n[a], h = e[v + 1], f = t[h], I = n[h], p >= w) {
2870
- if (p > I && M > w && M > I) continue;
2871
- } else if (p < I && M < w && M < I) continue;
2872
- r == a || r == h || s == a || s == h || (x = jr(
2873
- l,
3012
+ function Gr(e, t, n, i) {
3013
+ const o = e.length - 2;
3014
+ let r, s, a, c, f, h, l, u, p, _, w, O, M, m, v, d, b;
3015
+ for (ro(t, e), d = 0; d < o; ) {
3016
+ for (r = e[d], s = e[d + 1], f = t[r], h = t[s], p = n[r], _ = n[s], b = d; b < o && (b += 2, a = e[b], l = t[a], !(h < l)); ) {
3017
+ if (w = n[a], c = e[b + 1], u = t[c], O = n[c], p >= w) {
3018
+ if (p > O && _ > w && _ > O) continue;
3019
+ } else if (p < O && _ < w && _ < O) continue;
3020
+ if (!(r == a || r == c || s == a || s == c) && (M = Kr(
3021
+ f,
2874
3022
  p,
2875
- u,
2876
- M,
2877
- c,
3023
+ h,
3024
+ _,
3025
+ l,
2878
3026
  w,
2879
- f,
2880
- I
2881
- ), x && (m = [r, s], _ = [a, h], o.push(Bn(x, m, _, t, n)), x.length == 4 && o.push(
2882
- Bn(x.slice(2), m, _, t, n)
2883
- )));
3027
+ u,
3028
+ O
3029
+ ), M && (m = [r, s], v = [a, c], i(Tn(M, m, v, t, n)) || M.length == 4 && i(Tn(M.slice(2), m, v, t, n)))))
3030
+ return !0;
2884
3031
  }
2885
3032
  d += 2;
2886
3033
  }
2887
- return o;
3034
+ return !1;
2888
3035
  }
2889
- function jr(e, t, n, i, o, r, s, a) {
2890
- const h = qr(e, t, n, i, o, r, s, a);
2891
- let l = null;
2892
- return h && (l = Ur(e, t, n, i, o, r, s, a), l ? Hr(e, t, n, i, o, r, s, a) && (l = null) : l = Qr(e, t, n, i, o, r, s, a)), l;
3036
+ function Kr(e, t, n, i, o, r, s, a) {
3037
+ const c = Qr(e, t, n, i, o, r, s, a);
3038
+ let f = null;
3039
+ return c && (f = Hr(e, t, n, i, o, r, s, a), f ? io(e, t, n, i, o, r, s, a) && (f = null) : f = no(e, t, n, i, o, r, s, a)), f;
2893
3040
  }
2894
- function qr(e, t, n, i, o, r, s, a) {
3041
+ function Qr(e, t, n, i, o, r, s, a) {
2895
3042
  return ie(e, t, n, i, o, r) * ie(e, t, n, i, s, a) <= 0 && ie(o, r, s, a, e, t) * ie(o, r, s, a, n, i) <= 0;
2896
3043
  }
2897
3044
  function ie(e, t, n, i, o, r) {
2898
- return Jn(e - o, t - r, n - o, i - r);
3045
+ return Wn(e - o, t - r, n - o, i - r);
2899
3046
  }
2900
- function Jn(e, t, n, i) {
3047
+ function Wn(e, t, n, i) {
2901
3048
  return e * i - t * n;
2902
3049
  }
2903
- function Ur(e, t, n, i, o, r, s, a) {
2904
- let h = xe(e, t, n, i, o, r, s, a), l;
2905
- return h && (l = Gr(h[0], h[1], e, t, n, i, o, r, s, a), l == 1 ? h = xe(n, i, e, t, o, r, s, a) : l == 2 ? h = xe(o, r, s, a, e, t, n, i) : l == 3 && (h = xe(s, a, o, r, e, t, n, i))), h && Kr(h, e, t, n, i, o, r, s, a), h;
3050
+ function Hr(e, t, n, i, o, r, s, a) {
3051
+ let c = xe(e, t, n, i, o, r, s, a), f;
3052
+ return c && (f = Zr(c[0], c[1], e, t, n, i, o, r, s, a), f == 1 ? c = xe(n, i, e, t, o, r, s, a) : f == 2 ? c = xe(o, r, s, a, e, t, n, i) : f == 3 && (c = xe(s, a, o, r, e, t, n, i))), c && eo(c, e, t, n, i, o, r, s, a), c;
2906
3053
  }
2907
3054
  function xe(e, t, n, i, o, r, s, a) {
2908
- const h = Jn(n - e, i - t, s - o, a - r), l = 1e-18;
2909
- let u;
2910
- if (h === 0) return null;
2911
- const c = ie(o, r, s, a, e, t) / h;
2912
- return h <= l && h >= -l ? u = zr(e, t, n, i, o, r, s, a) : u = [e + c * (n - e), t + c * (i - t)], u;
3055
+ const c = Wn(n - e, i - t, s - o, a - r), f = 1e-18;
3056
+ let h;
3057
+ if (c === 0) return null;
3058
+ const l = ie(o, r, s, a, e, t) / c;
3059
+ return c <= f && c >= -f ? h = Wr(e, t, n, i, o, r, s, a) : h = [e + l * (n - e), t + l * (i - t)], h;
2913
3060
  }
2914
- function zr(e, t, n, i, o, r, s, a) {
2915
- let h = null;
2916
- return !Bt(e, o, s) && !Bt(t, r, a) ? h = [e, t] : !Bt(n, o, s) && !Bt(i, r, a) ? h = [n, i] : !Bt(o, e, n) && !Bt(r, t, i) ? h = [o, r] : !Bt(s, e, n) && !Bt(a, t, i) && (h = [s, a]), h;
3061
+ function Wr(e, t, n, i, o, r, s, a) {
3062
+ let c = null;
3063
+ return !Nt(e, o, s) && !Nt(t, r, a) ? c = [e, t] : !Nt(n, o, s) && !Nt(i, r, a) ? c = [n, i] : !Nt(o, e, n) && !Nt(r, t, i) ? c = [o, r] : !Nt(s, e, n) && !Nt(a, t, i) && (c = [s, a]), c;
2917
3064
  }
2918
- function Bt(e, t, n) {
3065
+ function Nt(e, t, n) {
2919
3066
  let i;
2920
3067
  return t < n ? i = e < t || e > n : t > n ? i = e > t || e < n : i = e != t, i;
2921
3068
  }
2922
- function Gr(e, t, ...n) {
3069
+ function Zr(e, t, ...n) {
2923
3070
  let i = -1, o = 1 / 0, r;
2924
- for (let s = 0, a = 0, h = n.length; a < h; s++, a += 2)
2925
- r = Jr(e, t, n[a], n[a + 1]), r < o && (o = r, i = s);
3071
+ for (let s = 0, a = 0, c = n.length; a < c; s++, a += 2)
3072
+ r = to(e, t, n[a], n[a + 1]), r < o && (o = r, i = s);
2926
3073
  return i;
2927
3074
  }
2928
- function Jr(e, t, n, i) {
3075
+ function to(e, t, n, i) {
2929
3076
  const o = e - n, r = t - i;
2930
3077
  return o * o + r * r;
2931
3078
  }
2932
- function Kr(e, t, n, i, o, r, s, a, h) {
2933
- let l = e[0], u = e[1];
2934
- l = _e(l, t, i), l = _e(l, r, a), u = _e(u, n, o), u = _e(u, s, h), e[0] = l, e[1] = u;
3079
+ function eo(e, t, n, i, o, r, s, a, c) {
3080
+ let f = e[0], h = e[1];
3081
+ f = _e(f, t, i), f = _e(f, r, a), h = _e(h, n, o), h = _e(h, s, c), e[0] = f, e[1] = h;
2935
3082
  }
2936
3083
  function _e(e, t, n) {
2937
3084
  let i;
2938
- return Bt(e, t, n) && (i = Math.abs(e - t) < Math.abs(e - n) ? t : n, e = i), e;
3085
+ return Nt(e, t, n) && (i = Math.abs(e - t) < Math.abs(e - n) ? t : n, e = i), e;
2939
3086
  }
2940
- function Qr(e, t, n, i, o, r, s, a) {
2941
- const h = Math.min(e, n, o, s), l = Math.max(e, n, o, s), u = Math.min(t, i, r, a), c = Math.max(t, i, r, a), f = c - u > l - h;
3087
+ function no(e, t, n, i, o, r, s, a) {
3088
+ const c = Math.min(e, n, o, s), f = Math.max(e, n, o, s), h = Math.min(t, i, r, a), l = Math.max(t, i, r, a), u = l - h > f - c;
2942
3089
  let p = [];
2943
- return (f ? Rt(t, u, c) : Rt(e, h, l)) && p.push(e, t), (f ? Rt(i, u, c) : Rt(n, h, l)) && p.push(n, i), (f ? Rt(r, u, c) : Rt(o, h, l)) && p.push(o, r), (f ? Rt(a, u, c) : Rt(s, h, l)) && p.push(s, a), (p.length != 2 && p.length != 4 || p.length == 4 && p[0] == p[2] && p[1] == p[3]) && (p = null), p;
3090
+ return (u ? Rt(t, h, l) : Rt(e, c, f)) && p.push(e, t), (u ? Rt(i, h, l) : Rt(n, c, f)) && p.push(n, i), (u ? Rt(r, h, l) : Rt(o, c, f)) && p.push(o, r), (u ? Rt(a, h, l) : Rt(s, c, f)) && p.push(s, a), (p.length != 2 && p.length != 4 || p.length == 4 && p[0] == p[2] && p[1] == p[3]) && (p = null), p;
2944
3091
  }
2945
- function Hr(e, t, n, i, o, r, s, a) {
3092
+ function io(e, t, n, i, o, r, s, a) {
2946
3093
  return e == o && t == r || e == s && t == a || n == o && i == r || n == s && i == a;
2947
3094
  }
2948
3095
  function Rt(e, t, n) {
2949
3096
  return e > t && e < n;
2950
3097
  }
2951
- function Wr(e, t) {
2952
- Zr(e, t), Kn(e, t, 0, t.length - 2);
3098
+ function ro(e, t) {
3099
+ oo(e, t), Zn(e, t, 0, t.length - 2);
2953
3100
  }
2954
- function Zr(e, t) {
3101
+ function oo(e, t) {
2955
3102
  for (let n = 0, i = t.length; n < i; n += 2)
2956
- e[t[n]] > e[t[n + 1]] && to(t, n, n + 1);
3103
+ e[t[n]] > e[t[n + 1]] && so(t, n, n + 1);
2957
3104
  }
2958
- function to(e, t, n) {
3105
+ function so(e, t, n) {
2959
3106
  const i = e[t];
2960
3107
  e[t] = e[n], e[n] = i;
2961
3108
  }
2962
- function Kn(e, t, n, i) {
3109
+ function Zn(e, t, n, i) {
2963
3110
  let o = n, r = i, s, a;
2964
3111
  for (; o < i; ) {
2965
3112
  for (s = e[t[n + i >> 2 << 1]]; o <= r; ) {
@@ -2967,14 +3114,14 @@ function Kn(e, t, n, i) {
2967
3114
  for (; e[t[r]] > s; ) r -= 2;
2968
3115
  o <= r && (a = t[o], t[o] = t[r], t[r] = a, a = t[o + 1], t[o + 1] = t[r + 1], t[r + 1] = a, o += 2, r -= 2);
2969
3116
  }
2970
- if (r - n < 40 ? On(e, t, n, r) : Kn(e, t, n, r), i - o < 40) {
2971
- On(e, t, o, i);
3117
+ if (r - n < 40 ? Bn(e, t, n, r) : Zn(e, t, n, r), i - o < 40) {
3118
+ Bn(e, t, o, i);
2972
3119
  return;
2973
3120
  }
2974
3121
  n = o, r = i;
2975
3122
  }
2976
3123
  }
2977
- function On(e, t, n, i) {
3124
+ function Bn(e, t, n, i) {
2978
3125
  let o, r;
2979
3126
  for (let s = n + 2; s <= i; s += 2) {
2980
3127
  o = t[s], r = t[s + 1];
@@ -2984,27 +3131,20 @@ function On(e, t, n, i) {
2984
3131
  t[a + 2] = o, t[a + 3] = r;
2985
3132
  }
2986
3133
  }
2987
- function Bn(e, t, n, i, o) {
3134
+ function Tn(e, t, n, i, o) {
2988
3135
  const r = e[0], s = e[1];
2989
- t = Nn(r, s, t[0], t[1], i, o), n = Nn(r, s, n[0], n[1], i, o);
2990
- const a = t[0] < n[0] ? t : n, h = a == t ? n : t;
2991
- return { x: r, y: s, a, b: h };
3136
+ t = Cn(r, s, t[0], t[1], i, o), n = Cn(r, s, n[0], n[1], i, o);
3137
+ const a = t[0] < n[0] ? t : n, c = a == t ? n : t;
3138
+ return { x: r, y: s, a, b: c };
2992
3139
  }
2993
- function Nn(e, t, n, i, o, r) {
3140
+ function Cn(e, t, n, i, o, r) {
2994
3141
  let s = n < i ? n : i, a = s === n ? i : n;
2995
3142
  return o[s] == e && r[s] == t ? a = s : o[a] == e && r[a] == t && (s = a), [s, a];
2996
3143
  }
2997
- function Qn(e) {
2998
- const t = {};
2999
- return e.filter((n) => {
3000
- const i = eo(n);
3001
- return i in t ? !1 : (t[i] = !0, !0);
3002
- });
3003
- }
3004
- function eo(e) {
3144
+ function ao(e) {
3005
3145
  return `${e.a.join(",")};${e.b.join(",")}`;
3006
3146
  }
3007
- class no {
3147
+ class co {
3008
3148
  _i = 0;
3009
3149
  _n = 0;
3010
3150
  _inc = 1;
@@ -3017,16 +3157,16 @@ class no {
3017
3157
  this._xx = t, this._yy = n;
3018
3158
  }
3019
3159
  }
3020
- function io(e, t, n, i) {
3160
+ function lo(e, t, n, i) {
3021
3161
  let o = n | 0;
3022
3162
  const r = isNaN(i) ? e.length - o : i + o;
3023
- let s, a, h, l, u, c;
3163
+ let s, a, c, f, h, l;
3024
3164
  if (r > 0)
3025
- h = u = e[o], l = c = t[o];
3165
+ c = h = e[o], f = l = t[o];
3026
3166
  else return [void 0, void 0, void 0, void 0];
3027
3167
  for (o++; o < r; o++)
3028
- s = e[o], a = t[o], s < h && (h = s), s > u && (u = s), a < l && (l = a), a > c && (c = a);
3029
- return [h, l, u, c];
3168
+ s = e[o], a = t[o], s < c && (c = s), s > h && (h = s), a < f && (f = a), a > l && (l = a);
3169
+ return [c, f, h, l];
3030
3170
  }
3031
3171
  class ce {
3032
3172
  xmin;
@@ -3055,18 +3195,18 @@ class ce {
3055
3195
  return this.ymax - this.ymin || 0;
3056
3196
  }
3057
3197
  setBounds(t, n, i, o) {
3058
- let r, s, a, h;
3198
+ let r, s, a, c;
3059
3199
  if (arguments.length == 1)
3060
3200
  if (ae(t)) {
3061
- const l = t;
3062
- r = l[0], s = l[1], a = l[2], h = l[3];
3201
+ const f = t;
3202
+ r = f[0], s = f[1], a = f[2], c = f[3];
3063
3203
  } else {
3064
- const l = t;
3065
- r = l.xmin, s = l.ymin, a = l.xmax, h = l.ymax;
3204
+ const f = t;
3205
+ r = f.xmin, s = f.ymin, a = f.xmax, c = f.ymax;
3066
3206
  }
3067
3207
  else
3068
- r = t, s = n, a = i, h = o;
3069
- return this.xmin = r, this.ymin = s, this.xmax = a, this.ymax = h, (r > a || s > h) && this.update(), this;
3208
+ r = t, s = n, a = i, c = o;
3209
+ return this.xmin = r, this.ymin = s, this.xmax = a, this.ymax = c, (r > a || s > c) && this.update(), this;
3070
3210
  }
3071
3211
  update() {
3072
3212
  let t;
@@ -3074,7 +3214,7 @@ class ce {
3074
3214
  }
3075
3215
  mergeBounds(t, ...n) {
3076
3216
  let i, o, r, s;
3077
- return t instanceof ce ? (i = t.xmin, o = t.ymin, r = t.xmax, s = t.ymax) : n.length == 3 ? (i = t, o = n[0], r = n[1], s = n[2]) : t.length == 4 ? (i = t[0], o = t[1], r = t[2], s = t[3]) : Ut("Bounds#mergeBounds() invalid argument:", t), this.xmin === void 0 ? this.setBounds(i, o, r, s) : (i < this.xmin && (this.xmin = i), o < this.ymin && (this.ymin = o), r > this.xmax && (this.xmax = r), s > this.ymax && (this.ymax = s)), this;
3217
+ return t instanceof ce ? (i = t.xmin, o = t.ymin, r = t.xmax, s = t.ymax) : n.length == 3 ? (i = t, o = n[0], r = n[1], s = n[2]) : t.length == 4 ? (i = t[0], o = t[1], r = t[2], s = t[3]) : qt("Bounds#mergeBounds() invalid argument:", t), this.xmin === void 0 ? this.setBounds(i, o, r, s) : (i < this.xmin && (this.xmin = i), o < this.ymin && (this.ymin = o), r > this.xmax && (this.xmax = r), s > this.ymax && (this.ymax = s)), this;
3078
3218
  }
3079
3219
  }
3080
3220
  function Ae(e) {
@@ -3090,7 +3230,7 @@ function Ae(e) {
3090
3230
  (n) => n.map((i) => t[i]).sort().join("-")
3091
3231
  ).sort();
3092
3232
  }
3093
- function Hn(e, t, n) {
3233
+ function ti(e, t, n) {
3094
3234
  const i = Ae(t.forw), o = Ae(t.bakw);
3095
3235
  if (JSON.stringify(i) != JSON.stringify(o))
3096
3236
  throw `${JSON.stringify(t, null, 2)}
@@ -3104,7 +3244,7 @@ ${JSON.stringify(o)}`;
3104
3244
  }
3105
3245
  n && (n.forw.features.push(t.forw), n.bakw.features.push(t.bakw));
3106
3246
  }
3107
- function Tn(e, t, n) {
3247
+ function Xn(e, t, n) {
3108
3248
  const i = Ae(t.forw), o = Ae(t.bakw);
3109
3249
  if (JSON.stringify(i) != JSON.stringify(o))
3110
3250
  throw `${JSON.stringify(t, null, 2)}
@@ -3113,35 +3253,35 @@ ${JSON.stringify(o)}`;
3113
3253
  if (i.forEach((r) => {
3114
3254
  const s = e[r];
3115
3255
  if (!s) return;
3116
- const a = s.filter((h) => h !== t);
3256
+ const a = s.filter((c) => c !== t);
3117
3257
  a.length === 0 ? delete e[r] : e[r] = a;
3118
3258
  }), n) {
3119
3259
  const r = (s, a) => {
3120
- !s || !a || (s.features = s.features.filter((h) => h !== a));
3260
+ !s || !a || (s.features = s.features.filter((c) => c !== a));
3121
3261
  };
3122
3262
  r(n.forw, t.forw), r(n.bakw, t.bakw);
3123
3263
  }
3124
3264
  }
3125
3265
  function Me(e, t, n) {
3126
- return $t(e, { target: { geom: t, index: n } });
3266
+ return Yt(e, { target: { geom: t, index: n } });
3127
3267
  }
3128
3268
  function Se(e) {
3129
- return $t(e.properties.target.geom, {
3269
+ return Yt(e.properties.target.geom, {
3130
3270
  target: {
3131
3271
  geom: e.geometry.coordinates,
3132
3272
  index: e.properties.target.index
3133
3273
  }
3134
3274
  });
3135
3275
  }
3136
- function Xn(e, t) {
3276
+ function $n(e, t) {
3137
3277
  const n = e.length, i = t.geometry.coordinates;
3138
3278
  return Array.from({ length: n }, (o, r) => r).map((o) => {
3139
- const r = (o + 1) % n, s = e[o], a = e[r], h = s.geometry.coordinates, l = Math.atan2(
3140
- h[0] - i[0],
3141
- h[1] - i[1]
3142
- ), u = [t, s, a, t].map(
3279
+ const r = (o + 1) % n, s = e[o], a = e[r], c = s.geometry.coordinates, f = Math.atan2(
3280
+ c[0] - i[0],
3281
+ c[1] - i[1]
3282
+ ), h = [t, s, a, t].map(
3143
3283
  (p) => p.geometry.coordinates
3144
- ), c = {
3284
+ ), l = {
3145
3285
  a: {
3146
3286
  geom: t.properties.target.geom,
3147
3287
  index: t.properties.target.index
@@ -3154,20 +3294,20 @@ function Xn(e, t) {
3154
3294
  geom: a.properties.target.geom,
3155
3295
  index: a.properties.target.index
3156
3296
  }
3157
- }, f = St([
3158
- le([u], c)
3297
+ }, u = Et([
3298
+ le([h], l)
3159
3299
  ]);
3160
- return [l, f];
3300
+ return [f, u];
3161
3301
  }).reduce(
3162
3302
  (o, r) => (o[0].push(r[0]), o[1].push(r[1]), o),
3163
3303
  [[], []]
3164
3304
  );
3165
3305
  }
3166
- function ke(e, t = 1e-6) {
3306
+ function Ee(e, t = 1e-6) {
3167
3307
  const [n, i] = e[0], [o, r] = e[1], [s, a] = e[2];
3168
3308
  return Math.abs((o - n) * (a - i) - (s - n) * (r - i)) < t;
3169
3309
  }
3170
- function ro(e, t) {
3310
+ function fo(e, t) {
3171
3311
  const n = /* @__PURE__ */ new Set();
3172
3312
  return e.forEach((i) => {
3173
3313
  if (i.length !== 2) return;
@@ -3181,147 +3321,147 @@ function re(e) {
3181
3321
  geom: e.geometry.coordinates[0][n]
3182
3322
  }));
3183
3323
  }
3184
- const oo = 10;
3185
- function so(e, t, n, i, o, r) {
3324
+ const ho = 10;
3325
+ function uo(e, t, n, i, o, r) {
3186
3326
  if (!e && !t) return !1;
3187
- const s = e ? 0 : 1, a = 1 - s, h = n[s], l = n[a];
3188
- if (!h || !l) return !1;
3189
- const u = xt(l.geom);
3190
- let c = !1, f = !1;
3327
+ const s = e ? 0 : 1, a = 1 - s, c = n[s], f = n[a];
3328
+ if (!c || !f) return !1;
3329
+ const h = _t(f.geom);
3330
+ let l = !1, u = !1;
3191
3331
  for (let p = 0; p <= 1; p++) {
3192
- const M = i[p];
3193
- if (!M) continue;
3194
- const w = [String(M.prop.index), String(h.prop.index)].sort().join("-"), I = o[w];
3195
- if (!I || I.length < 2) continue;
3196
- const x = I.find(
3197
- (B) => B.bakw !== r[s].bakw
3332
+ const _ = i[p];
3333
+ if (!_) continue;
3334
+ const w = [String(_.prop.index), String(c.prop.index)].sort().join("-"), O = o[w];
3335
+ if (!O || O.length < 2) continue;
3336
+ const M = O.find(
3337
+ (N) => N.bakw !== r[s].bakw
3198
3338
  );
3199
- if (!x) continue;
3200
- const _ = re(x.bakw).find(
3201
- (B) => String(B.prop.index) !== String(M.prop.index) && String(B.prop.index) !== String(h.prop.index)
3339
+ if (!M) continue;
3340
+ const v = re(M.bakw).find(
3341
+ (N) => String(N.prop.index) !== String(_.prop.index) && String(N.prop.index) !== String(c.prop.index)
3202
3342
  );
3203
- if (!_) continue;
3204
- c = !0;
3205
- const d = xt(_.geom), v = xt(M.geom), g = xt(h.geom), k = g[0] - v[0], S = g[1] - v[1], A = k * (u[1] - v[1]) - S * (u[0] - v[0]), O = k * (d[1] - v[1]) - S * (d[0] - v[0]);
3206
- if (A * O > 0) {
3207
- f = !0;
3343
+ if (!v) continue;
3344
+ l = !0;
3345
+ const d = _t(v.geom), b = _t(_.geom), g = _t(c.geom), E = g[0] - b[0], S = g[1] - b[1], k = E * (h[1] - b[1]) - S * (h[0] - b[0]), P = E * (d[1] - b[1]) - S * (d[0] - b[0]);
3346
+ if (k * P > 0) {
3347
+ u = !0;
3208
3348
  break;
3209
3349
  }
3210
3350
  }
3211
- return c && !f;
3351
+ return l && !u;
3212
3352
  }
3213
- function ao(e, t, n, i) {
3353
+ function po(e, t, n, i) {
3214
3354
  if (!e && !t) return !1;
3215
3355
  if (n[0] && n[1] && i[0] && i[1]) {
3216
- const o = i.map((u) => xt(u.geom)), r = n.map((u) => xt(u.geom)), s = o[1][0] - o[0][0], a = o[1][1] - o[0][1], h = s * (r[0][1] - o[0][1]) - a * (r[0][0] - o[0][0]), l = s * (r[1][1] - o[0][1]) - a * (r[1][0] - o[0][0]);
3217
- return h * l < 0;
3356
+ const o = i.map((h) => _t(h.geom)), r = n.map((h) => _t(h.geom)), s = o[1][0] - o[0][0], a = o[1][1] - o[0][1], c = s * (r[0][1] - o[0][1]) - a * (r[0][0] - o[0][0]), f = s * (r[1][1] - o[0][1]) - a * (r[1][0] - o[0][0]);
3357
+ return c * f < 0;
3218
3358
  }
3219
3359
  return !1;
3220
3360
  }
3221
- function co(e, t, n, i) {
3222
- const o = ro(n, i), r = /* @__PURE__ */ new Set();
3361
+ function mo(e, t, n, i) {
3362
+ const o = fo(n, i), r = /* @__PURE__ */ new Set();
3223
3363
  let s = !1;
3224
- for (let a = 0; a < oo; a++) {
3225
- let h = !1;
3226
- for (const l of Object.keys(t)) {
3227
- if (r.has(l)) continue;
3228
- r.add(l);
3229
- const u = t[l];
3230
- if (!u || u.length < 2) continue;
3231
- const c = l.split("-");
3232
- if (c.length !== 2 || o.has(l)) continue;
3233
- const f = re(u[0].bakw), p = re(u[1].bakw), M = re(u[0].forw), w = re(u[1].forw), I = c.map(
3234
- (b) => f.find((N) => `${N.prop.index}` === b) || p.find((N) => `${N.prop.index}` === b)
3235
- ), x = c.map(
3236
- (b) => M.find((N) => `${N.prop.index}` === b) || w.find((N) => `${N.prop.index}` === b)
3364
+ for (let a = 0; a < ho; a++) {
3365
+ let c = !1;
3366
+ for (const f of Object.keys(t)) {
3367
+ if (r.has(f)) continue;
3368
+ r.add(f);
3369
+ const h = t[f];
3370
+ if (!h || h.length < 2) continue;
3371
+ const l = f.split("-");
3372
+ if (l.length !== 2 || o.has(f)) continue;
3373
+ const u = re(h[0].bakw), p = re(h[1].bakw), _ = re(h[0].forw), w = re(h[1].forw), O = l.map(
3374
+ (x) => u.find((B) => `${B.prop.index}` === x) || p.find((B) => `${B.prop.index}` === x)
3375
+ ), M = l.map(
3376
+ (x) => _.find((B) => `${B.prop.index}` === x) || w.find((B) => `${B.prop.index}` === x)
3237
3377
  );
3238
- if (I.some((b) => !b) || x.some((b) => !b))
3378
+ if (O.some((x) => !x) || M.some((x) => !x))
3239
3379
  continue;
3240
- const m = [f, p].map(
3241
- (b) => b.find((N) => !c.includes(`${N.prop.index}`))
3242
- ), _ = [M, w].map(
3243
- (b) => b.find((N) => !c.includes(`${N.prop.index}`))
3380
+ const m = [u, p].map(
3381
+ (x) => x.find((B) => !l.includes(`${B.prop.index}`))
3382
+ ), v = [_, w].map(
3383
+ (x) => x.find((B) => !l.includes(`${B.prop.index}`))
3244
3384
  );
3245
- if (m.some((b) => !b) || _.some((b) => !b))
3385
+ if (m.some((x) => !x) || v.some((x) => !x))
3246
3386
  continue;
3247
- const d = u[0].bakw.geometry.coordinates[0].slice(0, 3).map((b) => xt(b)), v = u[1].bakw.geometry.coordinates[0].slice(0, 3).map((b) => xt(b)), g = u[0].forw.geometry.coordinates[0].slice(0, 3).map((b) => xt(b)), k = u[1].forw.geometry.coordinates[0].slice(0, 3).map((b) => xt(b)), S = ke(d), A = ke(v), O = ke(g), B = ke(k), X = so(
3387
+ const d = h[0].bakw.geometry.coordinates[0].slice(0, 3).map((x) => _t(x)), b = h[1].bakw.geometry.coordinates[0].slice(0, 3).map((x) => _t(x)), g = h[0].forw.geometry.coordinates[0].slice(0, 3).map((x) => _t(x)), E = h[1].forw.geometry.coordinates[0].slice(0, 3).map((x) => _t(x)), S = Ee(d), k = Ee(b), P = Ee(g), N = Ee(E), C = uo(
3248
3388
  S,
3249
- A,
3389
+ k,
3250
3390
  m,
3251
- I,
3252
- t,
3253
- u
3254
- ), Y = ao(
3255
3391
  O,
3256
- B,
3392
+ t,
3393
+ h
3394
+ ), F = po(
3395
+ P,
3396
+ N,
3257
3397
  m,
3258
- I
3398
+ O
3259
3399
  );
3260
- if (!(X || Y || Cn(
3261
- xt(m[0].geom),
3262
- v
3263
- ) || Cn(
3264
- xt(m[1].geom),
3400
+ if (!(C || F || Dn(
3401
+ _t(m[0].geom),
3402
+ b
3403
+ ) || Dn(
3404
+ _t(m[1].geom),
3265
3405
  d
3266
3406
  )))
3267
3407
  continue;
3268
- const P = x.map(
3269
- (b) => xt(b.geom)
3270
- ), E = _.map(
3271
- (b) => xt(b.geom)
3272
- ), T = lo([
3273
- ...P,
3274
- ...E
3275
- ]), C = ho(T), F = Dn(
3276
- P[0],
3277
- P[1],
3278
- E[0]
3279
- ) + Dn(
3280
- P[0],
3281
- P[1],
3282
- E[1]
3408
+ const I = M.map(
3409
+ (x) => _t(x.geom)
3410
+ ), A = v.map(
3411
+ (x) => _t(x.geom)
3412
+ ), T = go([
3413
+ ...I,
3414
+ ...A
3415
+ ]), X = wo(T), D = Fn(
3416
+ I[0],
3417
+ I[1],
3418
+ A[0]
3419
+ ) + Fn(
3420
+ I[0],
3421
+ I[1],
3422
+ A[1]
3283
3423
  );
3284
- Ue(C, F) && (Tn(t, u[0], e), Tn(t, u[1], e), I.forEach((b) => {
3285
- if (!b) return;
3286
- const N = [
3287
- b.geom,
3424
+ qe(X, D) && (Xn(t, h[0], e), Xn(t, h[1], e), O.forEach((x) => {
3425
+ if (!x) return;
3426
+ const B = [
3427
+ x.geom,
3288
3428
  m[0].geom,
3289
3429
  m[1].geom,
3290
- b.geom
3291
- ], D = {
3292
- a: b.prop,
3430
+ x.geom
3431
+ ], $ = {
3432
+ a: x.prop,
3293
3433
  b: m[0].prop,
3294
3434
  c: m[1].prop
3295
- }, R = le([N], D), L = Un(R);
3296
- Hn(t, {
3435
+ }, R = le([B], $), L = Jn(R);
3436
+ ti(t, {
3297
3437
  forw: L,
3298
3438
  bakw: R
3299
3439
  }, e);
3300
- }), h = !0, s = !0);
3440
+ }), c = !0, s = !0);
3301
3441
  }
3302
- if (!h) break;
3442
+ if (!c) break;
3303
3443
  }
3304
3444
  return s;
3305
3445
  }
3306
- function xt(e) {
3446
+ function _t(e) {
3307
3447
  return [e[0], e[1]];
3308
3448
  }
3309
- function Cn(e, t) {
3310
- const [n, i] = t[0], [o, r] = t[1], [s, a] = t[2], h = s - n, l = a - i, u = o - n, c = r - i, f = e[0] - n, p = e[1] - i, M = h * h + l * l, w = h * u + l * c, I = h * f + l * p, x = u * u + c * c, m = u * f + c * p, _ = M * x - w * w;
3311
- if (_ === 0) return !1;
3312
- const d = 1 / _, v = (x * I - w * m) * d, g = (M * m - w * I) * d, k = 1e-9;
3313
- return v >= -k && g >= -k && v + g <= 1 + k;
3449
+ function Dn(e, t) {
3450
+ const [n, i] = t[0], [o, r] = t[1], [s, a] = t[2], c = s - n, f = a - i, h = o - n, l = r - i, u = e[0] - n, p = e[1] - i, _ = c * c + f * f, w = c * h + f * l, O = c * u + f * p, M = h * h + l * l, m = h * u + l * p, v = _ * M - w * w;
3451
+ if (v === 0) return !1;
3452
+ const d = 1 / v, b = (M * O - w * m) * d, g = (_ * m - w * O) * d, E = 1e-9;
3453
+ return b >= -E && g >= -E && b + g <= 1 + E;
3314
3454
  }
3315
- function lo(e) {
3455
+ function go(e) {
3316
3456
  const t = e.map((s) => s.slice()).filter(
3317
- (s, a, h) => h.findIndex(
3318
- (l) => Ue(l[0], s[0]) && Ue(l[1], s[1])
3457
+ (s, a, c) => c.findIndex(
3458
+ (f) => qe(f[0], s[0]) && qe(f[1], s[1])
3319
3459
  ) === a
3320
3460
  );
3321
3461
  if (t.length <= 1) return t;
3322
3462
  const n = t.sort(
3323
3463
  (s, a) => s[0] === a[0] ? s[1] - a[1] : s[0] - a[0]
3324
- ), i = (s, a, h) => (a[0] - s[0]) * (h[1] - s[1]) - (a[1] - s[1]) * (h[0] - s[0]), o = [];
3464
+ ), i = (s, a, c) => (a[0] - s[0]) * (c[1] - s[1]) - (a[1] - s[1]) * (c[0] - s[0]), o = [];
3325
3465
  for (const s of n) {
3326
3466
  for (; o.length >= 2 && i(
3327
3467
  o[o.length - 2],
@@ -3344,7 +3484,7 @@ function lo(e) {
3344
3484
  }
3345
3485
  return r.pop(), o.pop(), o.concat(r);
3346
3486
  }
3347
- function ho(e) {
3487
+ function wo(e) {
3348
3488
  if (e.length < 3) return 0;
3349
3489
  let t = 0;
3350
3490
  for (let n = 0; n < e.length; n++) {
@@ -3353,16 +3493,16 @@ function ho(e) {
3353
3493
  }
3354
3494
  return Math.abs(t) / 2;
3355
3495
  }
3356
- function Dn(e, t, n) {
3496
+ function Fn(e, t, n) {
3357
3497
  return Math.abs(
3358
3498
  (e[0] * (t[1] - n[1]) + t[0] * (n[1] - e[1]) + n[0] * (e[1] - t[1])) / 2
3359
3499
  );
3360
3500
  }
3361
- function Ue(e, t, n = 1e-9) {
3501
+ function qe(e, t, n = 1e-9) {
3362
3502
  return Math.abs(e - t) <= n;
3363
3503
  }
3364
- const Fn = 2.00704, Yn = 3.00001;
3365
- class ht extends Mt {
3504
+ const Rn = 2.00704, Yn = 3.00001;
3505
+ class lt extends St {
3366
3506
  importance;
3367
3507
  priority;
3368
3508
  pointsSet;
@@ -3372,20 +3512,20 @@ class ht extends Mt {
3372
3512
  * @param options - 初期化オプション
3373
3513
  */
3374
3514
  constructor(t = {}) {
3375
- super(), t.bounds ? this.setBounds(t.bounds) : (this.setWh(t.wh), this.vertexMode = t.vertexMode || ht.VERTEX_PLAIN), this.strictMode = t.strictMode || ht.MODE_AUTO, this.yaxisMode = t.yaxisMode || ht.YAXIS_INVERT, this.importance = t.importance || 0, this.priority = t.priority || 0, this.stateFull = t.stateFull || !1, this.useV2Algorithm = t.useV2Algorithm ?? !1, t.points && this.setPoints(t.points), t.edges && this.setEdges(t.edges);
3515
+ super(), t.bounds ? this.setBounds(t.bounds) : (this.setWh(t.wh), this.vertexMode = t.vertexMode || lt.VERTEX_PLAIN), this.strictMode = t.strictMode || lt.MODE_AUTO, this.yaxisMode = t.yaxisMode || lt.YAXIS_INVERT, this.importance = t.importance || 0, this.priority = t.priority || 0, this.stateFull = t.stateFull || !1, this.useV2Algorithm = t.useV2Algorithm ?? !1, t.points && this.setPoints(t.points), t.edges && this.setEdges(t.edges);
3376
3516
  }
3377
3517
  /**
3378
3518
  * フォーマットバージョンを取得します
3379
3519
  */
3380
3520
  getFormatVersion() {
3381
- return this.useV2Algorithm ? Fn : Yn;
3521
+ return this.useV2Algorithm ? Rn : Yn;
3382
3522
  }
3383
3523
  /**
3384
3524
  * 制御点(GCP: Ground Control Points)を設定します。
3385
3525
  * 指定した点群に合わせて内部のTINキャッシュをリセットします。
3386
3526
  */
3387
3527
  setPoints(t) {
3388
- this.yaxisMode === ht.YAXIS_FOLLOW && (t = t.map((n) => [
3528
+ this.yaxisMode === lt.YAXIS_FOLLOW && (t = t.map((n) => [
3389
3529
  n[0],
3390
3530
  [n[1][0], -1 * n[1][1]]
3391
3531
  ])), this.points = t, this.tins = void 0, this.indexedTins = void 0;
@@ -3395,7 +3535,7 @@ class ht extends Mt {
3395
3535
  * 制約線を正規化した上で、依存するキャッシュをリセットします。
3396
3536
  */
3397
3537
  setEdges(t = []) {
3398
- this.edges = zn(t), this.edgeNodes = void 0, this.tins = void 0, this.indexedTins = void 0;
3538
+ this.edges = Gn(t), this.edgeNodes = void 0, this.tins = void 0, this.indexedTins = void 0;
3399
3539
  }
3400
3540
  /**
3401
3541
  * 境界ポリゴンを設定します
@@ -3405,17 +3545,17 @@ class ht extends Mt {
3405
3545
  let n = t[0][0], i = n, o = t[0][1], r = o;
3406
3546
  const s = [t[0]];
3407
3547
  for (let a = 1; a < t.length; a++) {
3408
- const h = t[a];
3409
- h[0] < n && (n = h[0]), h[0] > i && (i = h[0]), h[1] < o && (o = h[1]), h[1] > r && (r = h[1]), s.push(h);
3548
+ const c = t[a];
3549
+ c[0] < n && (n = c[0]), c[0] > i && (i = c[0]), c[1] < o && (o = c[1]), c[1] > r && (r = c[1]), s.push(c);
3410
3550
  }
3411
- s.push(t[0]), this.boundsPolygon = le([s]), this.xy = [n, o], this.wh = [i - n, r - o], this.vertexMode = ht.VERTEX_PLAIN, this.tins = void 0, this.indexedTins = void 0;
3551
+ s.push(t[0]), this.boundsPolygon = le([s]), this.xy = [n, o], this.wh = [i - n, r - o], this.vertexMode = lt.VERTEX_PLAIN, this.tins = void 0, this.indexedTins = void 0;
3412
3552
  }
3413
3553
  /**
3414
3554
  * 現在の設定を永続化可能な形式にコンパイルします
3415
3555
  */
3416
3556
  getCompiled() {
3417
3557
  const t = {};
3418
- t.version = this.useV2Algorithm ? Fn : Yn, t.points = this.points, t.weight_buffer = {}, t.centroid_point = [
3558
+ t.version = this.useV2Algorithm ? Rn : Yn, t.points = this.points, t.weight_buffer = {}, t.centroid_point = [
3419
3559
  this.centroid.forw.geometry.coordinates,
3420
3560
  this.centroid.forw.properties.target.geom
3421
3561
  ], t.vertices_params = [
@@ -3434,13 +3574,13 @@ class ht extends Mt {
3434
3574
  (o) => i.properties[o].index
3435
3575
  )
3436
3576
  );
3437
- }), this.strict_status === ht.STATUS_LOOSE ? (t.tins_points[1] = [], this.tins.bakw.features.map((i) => {
3577
+ }), this.strict_status === lt.STATUS_LOOSE ? (t.tins_points[1] = [], this.tins.bakw.features.map((i) => {
3438
3578
  t.tins_points[1].push(
3439
3579
  ["a", "b", "c"].map(
3440
3580
  (o) => i.properties[o].index
3441
3581
  )
3442
3582
  );
3443
- })) : this.strict_status === ht.STATUS_ERROR && this.kinks?.bakw && (t.kinks_points = this.kinks.bakw.features.map(
3583
+ })) : this.strict_status === lt.STATUS_ERROR && this.kinks?.bakw && (t.kinks_points = this.kinks.bakw.features.map(
3444
3584
  (i) => i.geometry.coordinates
3445
3585
  )), t.yaxisMode = this.yaxisMode, t.vertexMode = this.vertexMode, t.strictMode = this.strictMode, this.bounds ? (t.bounds = this.bounds, t.boundsPolygon = this.boundsPolygon, this.useV2Algorithm && (t.xy = this.xy, t.wh = this.wh)) : t.wh = this.wh, t.edges = this.edges ?? [], t.edgeNodes = this.edgeNodes ?? [], t;
3446
3586
  }
@@ -3473,35 +3613,38 @@ class ht extends Mt {
3473
3613
  }
3474
3614
  /**
3475
3615
  * 厳密なTINを計算します
3616
+ *
3617
+ * @param kinkLimit - forw / bakw それぞれで残す交差(kinks)の件数の上限
3618
+ * (同じ位置の交差を 1 件に数えた件数)。届いた時点で数え上げをやめます
3476
3619
  */
3477
- calculateStrictTin() {
3478
- const t = this.tins.forw.features.map(
3479
- (r) => Un(r)
3620
+ calculateStrictTin(t = Nn) {
3621
+ const n = this.tins.forw.features.map(
3622
+ (s) => Jn(s)
3480
3623
  );
3481
- this.tins.bakw = St(t);
3482
- const n = {};
3483
- this.tins.forw.features.forEach((r, s) => {
3484
- const a = this.tins.bakw.features[s];
3485
- Hn(n, { forw: r, bakw: a });
3624
+ this.tins.bakw = Et(n);
3625
+ const i = {};
3626
+ this.tins.forw.features.forEach((s, a) => {
3627
+ const c = this.tins.bakw.features[a];
3628
+ ti(i, { forw: s, bakw: c });
3486
3629
  });
3487
- const i = (this.pointsSet?.forw.features ?? []).map(
3488
- (r) => r.properties.target.index
3630
+ const o = (this.pointsSet?.forw.features ?? []).map(
3631
+ (s) => s.properties.target.index
3489
3632
  );
3490
- co(
3633
+ mo(
3491
3634
  this.tins,
3492
- n,
3635
+ i,
3493
3636
  this.pointsSet?.edges || [],
3494
- i
3637
+ o
3495
3638
  );
3496
- const o = ["forw", "bakw"].map((r) => {
3497
- const s = this.tins[r].features.map(
3498
- (a) => a.geometry.coordinates[0]
3639
+ const r = ["forw", "bakw"].map((s) => {
3640
+ const a = this.tins[s].features.map(
3641
+ (c) => c.geometry.coordinates[0]
3499
3642
  );
3500
- return Xr(s);
3643
+ return Hn(a, t);
3501
3644
  });
3502
- o[0].length === 0 && o[1].length === 0 ? (this.strict_status = ht.STATUS_STRICT, delete this.kinks) : (this.strict_status = ht.STATUS_ERROR, this.kinks = {
3503
- forw: St(o[0]),
3504
- bakw: St(o[1])
3645
+ r[0].length === 0 && r[1].length === 0 ? (this.strict_status = lt.STATUS_STRICT, delete this.kinks) : (this.strict_status = lt.STATUS_ERROR, this.kinks = {
3646
+ forw: Et(r[0]),
3647
+ bakw: Et(r[1])
3505
3648
  });
3506
3649
  }
3507
3650
  /**
@@ -3522,63 +3665,24 @@ class ht extends Mt {
3522
3665
  this.edgeNodes = [], this.edges || (this.edges = []);
3523
3666
  for (let o = 0; o < this.edges.length; o++) {
3524
3667
  const r = this.edges[o][2], s = Object.assign([], this.edges[o][0]), a = Object.assign([], this.edges[o][1]);
3525
- if (s.length === 0 && a.length === 0) {
3668
+ if (yo(r, this.points.length, o), s.length === 0 && a.length === 0) {
3526
3669
  n.push(r);
3527
3670
  continue;
3528
3671
  }
3529
- s.unshift(this.points[r[0]][0]), s.push(this.points[r[1]][0]), a.unshift(this.points[r[0]][1]), a.push(this.points[r[1]][1]);
3530
- const h = [s, a].map((l) => {
3531
- const u = l.map((f, p, M) => {
3532
- if (p === 0) return 0;
3533
- const w = M[p - 1];
3534
- return Math.sqrt(
3535
- Math.pow(f[0] - w[0], 2) + Math.pow(f[1] - w[1], 2)
3536
- );
3537
- }), c = u.reduce((f, p, M) => M === 0 ? [0] : (f.push(f[M - 1] + p), f), []);
3538
- return c.map((f, p, M) => {
3539
- const w = f / M[M.length - 1];
3540
- return [l[p], u[p], c[p], w];
3541
- });
3542
- });
3543
- h.map((l, u) => {
3544
- const c = h[u ? 0 : 1];
3545
- return l.filter((f, p) => !(p === 0 || p === l.length - 1 || f[4] === "handled")).flatMap((f) => {
3546
- const p = f[0], M = f[3], w = c.reduce(
3547
- (I, x, m, _) => {
3548
- if (I) return I;
3549
- const d = _[m + 1];
3550
- if (x[3] === M)
3551
- return x[4] = "handled", [x];
3552
- if (x[3] < M && d && d[3] > M)
3553
- return [x, d];
3554
- },
3555
- void 0
3556
- );
3557
- if (w && w.length === 1)
3558
- return u === 0 ? [[p, w[0][0], M]] : [[w[0][0], p, M]];
3559
- if (w && w.length === 2) {
3560
- const I = w[0], x = w[1], m = (M - I[3]) / (x[3] - I[3]), _ = [
3561
- (x[0][0] - I[0][0]) * m + I[0][0],
3562
- (x[0][1] - I[0][1]) * m + I[0][1]
3563
- ];
3564
- return u === 0 ? [[p, _, M]] : [[_, p, M]];
3565
- }
3566
- return [];
3567
- });
3568
- }).reduce((l, u) => l.concat(u), []).sort((l, u) => l[2] < u[2] ? -1 : 1).map((l, u, c) => {
3672
+ s.unshift(this.points[r[0]][0]), s.push(this.points[r[1]][0]), a.unshift(this.points[r[0]][1]), a.push(this.points[r[1]][1]), Pr(s, a).map((c, f, h) => {
3569
3673
  this.edgeNodes[i] = [
3570
- l[0],
3571
- l[1]
3674
+ c[0],
3675
+ c[1]
3572
3676
  ];
3573
- const f = Me(
3574
- l[0],
3575
- l[1],
3677
+ const l = Me(
3678
+ c[0],
3679
+ c[1],
3576
3680
  `e${i}`
3577
3681
  );
3578
- i++, t.forw.push(f), t.bakw.push(Se(f)), u === 0 ? n.push([r[0], t.forw.length - 1]) : n.push([
3682
+ i++, t.forw.push(l), t.bakw.push(Se(l)), f === 0 ? n.push([r[0], t.forw.length - 1]) : n.push([
3579
3683
  t.forw.length - 2,
3580
3684
  t.forw.length - 1
3581
- ]), u === c.length - 1 && n.push([t.forw.length - 1, r[1]]);
3685
+ ]), f === h.length - 1 && n.push([t.forw.length - 1, r[1]]);
3582
3686
  });
3583
3687
  }
3584
3688
  return {
@@ -3594,7 +3698,7 @@ class ht extends Mt {
3594
3698
  const t = this.xy[0] - 0.05 * this.wh[0], n = this.xy[0] + 1.05 * this.wh[0], i = this.xy[1] - 0.05 * this.wh[1], o = this.xy[1] + 1.05 * this.wh[1];
3595
3699
  if (this.bounds && !this.boundsPolygon) throw new Error("Internal error: bounds is set but boundsPolygon is missing");
3596
3700
  const r = this.bounds ? this.boundsPolygon : void 0;
3597
- if (!this.points.reduce((h, l) => h && (r ? De(l[0], r) : l[0][0] >= t && l[0][0] <= n && l[0][1] >= i && l[0][1] <= o), !0))
3701
+ if (!this.points.reduce((c, f) => c && (r ? $e(f[0], r) : f[0][0] >= t && f[0][0] <= n && f[0][1] >= i && f[0][1] <= o), !0))
3598
3702
  throw "SOME POINTS OUTSIDE";
3599
3703
  let a = [];
3600
3704
  return this.wh && (a = [[t, i], [n, i], [t, o], [n, o]]), {
@@ -3613,8 +3717,8 @@ class ht extends Mt {
3613
3717
  computeGcpBbox() {
3614
3718
  let t = 1 / 0, n = -1 / 0, i = 1 / 0, o = -1 / 0;
3615
3719
  for (const a of this.points) {
3616
- const h = a[0][0], l = a[0][1];
3617
- h < t && (t = h), h > n && (n = h), l < i && (i = l), l > o && (o = l);
3720
+ const c = a[0][0], f = a[0][1];
3721
+ c < t && (t = c), c > n && (n = c), f < i && (i = f), f > o && (o = f);
3618
3722
  }
3619
3723
  const r = n - t, s = o - i;
3620
3724
  return {
@@ -3631,7 +3735,7 @@ class ht extends Mt {
3631
3735
  */
3632
3736
  updateTin() {
3633
3737
  let t = this.strictMode;
3634
- t !== ht.MODE_STRICT && t !== ht.MODE_LOOSE && (t = ht.MODE_AUTO);
3738
+ t !== lt.MODE_STRICT && t !== lt.MODE_LOOSE && (t = lt.MODE_AUTO);
3635
3739
  const n = !this.useV2Algorithm;
3636
3740
  let i, o, r, s, a;
3637
3741
  if (n) {
@@ -3639,7 +3743,7 @@ class ht extends Mt {
3639
3743
  const S = this.boundsPolygon;
3640
3744
  if (!S) throw new Error("Internal error: bounds is set but boundsPolygon is missing");
3641
3745
  if (!this.points.every(
3642
- (O) => De(O[0], S)
3746
+ (P) => $e(P[0], S)
3643
3747
  )) throw "SOME POINTS OUTSIDE";
3644
3748
  }
3645
3749
  i = this.generatePointsSet(), { minx: o, maxx: r, miny: s, maxy: a } = this.computeGcpBbox();
@@ -3647,41 +3751,41 @@ class ht extends Mt {
3647
3751
  const S = this.validateAndPrepareInputs();
3648
3752
  i = S.pointsSet, o = S.minx, r = S.maxx, s = S.miny, a = S.maxy;
3649
3753
  }
3650
- const h = {
3651
- forw: St(i.forw),
3652
- bakw: St(i.bakw)
3653
- }, l = be(
3654
- h.forw,
3754
+ const c = {
3755
+ forw: Et(i.forw),
3756
+ bakw: Et(i.bakw)
3757
+ }, f = be(
3758
+ c.forw,
3655
3759
  i.edges,
3656
3760
  "target"
3657
- ), u = be(
3658
- h.bakw,
3761
+ ), h = be(
3762
+ c.bakw,
3659
3763
  i.edges,
3660
3764
  "target"
3661
3765
  );
3662
- if (l.features.length === 0 || u.features.length === 0)
3766
+ if (f.features.length === 0 || h.features.length === 0)
3663
3767
  throw "TOO LINEAR1";
3664
- const c = Ni(h.forw), f = mn(h.forw);
3665
- if (!f) throw "TOO LINEAR2";
3666
- const p = {}, M = f.geometry.coordinates[0];
3768
+ const l = Xi(c.forw), u = mn(c.forw);
3769
+ if (!u) throw "TOO LINEAR2";
3770
+ const p = {}, _ = u.geometry.coordinates[0];
3667
3771
  let w;
3668
3772
  try {
3669
- w = M.map((S) => ({
3773
+ w = _.map((S) => ({
3670
3774
  forw: S,
3671
- bakw: ne($t(S), l)
3775
+ bakw: ne(Yt(S), f)
3672
3776
  })), w.forEach((S) => {
3673
3777
  p[`${S.forw[0]}:${S.forw[1]}`] = S;
3674
3778
  });
3675
3779
  } catch {
3676
3780
  throw "TOO LINEAR2";
3677
3781
  }
3678
- const I = mn(h.bakw);
3679
- if (!I) throw "TOO LINEAR2";
3680
- const x = I.geometry.coordinates[0];
3782
+ const O = mn(c.bakw);
3783
+ if (!O) throw "TOO LINEAR2";
3784
+ const M = O.geometry.coordinates[0];
3681
3785
  try {
3682
- w = x.map((S) => ({
3786
+ w = M.map((S) => ({
3683
3787
  bakw: S,
3684
- forw: ne($t(S), u)
3788
+ forw: ne(Yt(S), h)
3685
3789
  })), w.forEach((S) => {
3686
3790
  p[`${S.forw[0]}:${S.forw[1]}`] = S;
3687
3791
  });
@@ -3690,43 +3794,43 @@ class ht extends Mt {
3690
3794
  }
3691
3795
  let m;
3692
3796
  if (n) {
3693
- const S = c.geometry.coordinates, A = l.features.find(
3694
- (O) => De(
3695
- $t(S),
3696
- O
3797
+ const S = l.geometry.coordinates, k = f.features.find(
3798
+ (P) => $e(
3799
+ Yt(S),
3800
+ P
3697
3801
  )
3698
3802
  );
3699
- if (A) {
3700
- const O = A.geometry.coordinates[0], B = A.properties.a.geom, X = A.properties.b.geom, Y = A.properties.c.geom;
3803
+ if (k) {
3804
+ const P = k.geometry.coordinates[0], N = k.properties.a.geom, C = k.properties.b.geom, F = k.properties.c.geom;
3701
3805
  m = {
3702
3806
  forw: [
3703
- (O[0][0] + O[1][0] + O[2][0]) / 3,
3704
- (O[0][1] + O[1][1] + O[2][1]) / 3
3807
+ (P[0][0] + P[1][0] + P[2][0]) / 3,
3808
+ (P[0][1] + P[1][1] + P[2][1]) / 3
3705
3809
  ],
3706
3810
  bakw: [
3707
- (B[0] + X[0] + Y[0]) / 3,
3708
- (B[1] + X[1] + Y[1]) / 3
3811
+ (N[0] + C[0] + F[0]) / 3,
3812
+ (N[1] + C[1] + F[1]) / 3
3709
3813
  ]
3710
3814
  };
3711
3815
  } else
3712
3816
  m = {
3713
3817
  forw: S,
3714
- bakw: ne(c, l)
3818
+ bakw: ne(l, f)
3715
3819
  };
3716
3820
  } else
3717
3821
  m = {
3718
- forw: c.geometry.coordinates,
3719
- bakw: ne(c, l)
3822
+ forw: l.geometry.coordinates,
3823
+ bakw: ne(l, f)
3720
3824
  };
3721
- const _ = Me(m.forw, m.bakw, "c");
3825
+ const v = Me(m.forw, m.bakw, "c");
3722
3826
  this.centroid = {
3723
- forw: _,
3724
- bakw: Se(_)
3827
+ forw: v,
3828
+ bakw: Se(v)
3725
3829
  };
3726
3830
  const d = [
3727
3831
  ...this.points.map((S) => ({ forw: S[0], bakw: S[1] })),
3728
3832
  ...(this.edgeNodes ?? []).map((S) => ({ forw: S[0], bakw: S[1] }))
3729
- ], v = {
3833
+ ], b = {
3730
3834
  convexBuf: p,
3731
3835
  centroid: m,
3732
3836
  allGcps: d,
@@ -3734,35 +3838,37 @@ class ht extends Mt {
3734
3838
  maxx: r,
3735
3839
  miny: s,
3736
3840
  maxy: a
3737
- }, g = this.vertexMode === ht.VERTEX_BIRDEYE ? Tr(v, n) : Nr(v, n), k = {
3841
+ }, g = this.vertexMode === lt.VERTEX_BIRDEYE ? Rr(b, n) : Fr(b, n), E = {
3738
3842
  forw: [],
3739
3843
  bakw: []
3740
3844
  };
3741
3845
  for (let S = 0; S < g.length; S++) {
3742
- const A = g[S].forw, O = g[S].bakw, B = Me(A, O, `b${S}`), X = Se(B);
3743
- i.forw.push(B), i.bakw.push(X), k.forw.push(B), k.bakw.push(X);
3846
+ const k = g[S].forw, P = g[S].bakw, N = Me(k, P, `b${S}`), C = Se(N);
3847
+ i.forw.push(N), i.bakw.push(C), E.forw.push(N), E.bakw.push(C);
3744
3848
  }
3745
3849
  this.pointsSet = {
3746
- forw: St(i.forw),
3747
- bakw: St(i.bakw),
3850
+ forw: Et(i.forw),
3851
+ bakw: Et(i.bakw),
3748
3852
  edges: i.edges
3749
3853
  }, this.tins = {
3750
- forw: _n(
3854
+ forw: Mn(
3751
3855
  be(
3752
3856
  this.pointsSet.forw,
3753
3857
  i.edges,
3754
3858
  "target"
3755
3859
  )
3756
3860
  )
3757
- }, (t === ht.MODE_STRICT || t === ht.MODE_AUTO) && this.calculateStrictTin(), (t === ht.MODE_LOOSE || t === ht.MODE_AUTO && this.strict_status === ht.STATUS_ERROR) && (this.tins.bakw = _n(
3861
+ }, (t === lt.MODE_STRICT || t === lt.MODE_AUTO) && this.calculateStrictTin(
3862
+ t === lt.MODE_AUTO ? 1 : Nn
3863
+ ), (t === lt.MODE_LOOSE || t === lt.MODE_AUTO && this.strict_status === lt.STATUS_ERROR) && (this.tins.bakw = Mn(
3758
3864
  be(
3759
3865
  this.pointsSet.bakw,
3760
3866
  i.edges,
3761
3867
  "target"
3762
3868
  )
3763
- ), delete this.kinks, this.strict_status = ht.STATUS_LOOSE), this.vertices_params = {
3764
- forw: Xn(k.forw, this.centroid.forw),
3765
- bakw: Xn(k.bakw, this.centroid.bakw)
3869
+ ), delete this.kinks, this.strict_status = lt.STATUS_LOOSE), this.vertices_params = {
3870
+ forw: $n(E.forw, this.centroid.forw),
3871
+ bakw: $n(E.bakw, this.centroid.bakw)
3766
3872
  }, this.addIndexedTin(), this.pointsWeightBuffer = {};
3767
3873
  }
3768
3874
  /**
@@ -3773,14 +3879,21 @@ class ht extends Mt {
3773
3879
  this.updateTin();
3774
3880
  }
3775
3881
  }
3882
+ function yo(e, t, n) {
3883
+ const i = (o) => Number.isInteger(o) && o >= 0 && o < t;
3884
+ if (!Array.isArray(e) || !i(e[0]) || !i(e[1]))
3885
+ throw new Error(
3886
+ `Invalid edge at edges[${n}]: start/end ${JSON.stringify(e)} must be integer indices of points (0 to ${t - 1})`
3887
+ );
3888
+ }
3776
3889
  export {
3777
- ht as Tin,
3890
+ lt as Tin,
3778
3891
  be as constrainedTin,
3779
3892
  Se as counterPoint,
3780
3893
  Me as createPoint,
3781
- ht as default,
3782
- Xr as findIntersections,
3783
- Fn as format_version,
3784
- Hn as insertSearchIndex,
3785
- Xn as vertexCalc
3894
+ lt as default,
3895
+ vo as findIntersections,
3896
+ Rn as format_version,
3897
+ ti as insertSearchIndex,
3898
+ $n as vertexCalc
3786
3899
  };