@maplat/tin 0.11.4 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,118 +1,366 @@
1
- var Qe = Object.defineProperty;
2
- var Ze = (o, t, e) => t in o ? Qe(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var rt = (o, t, e) => Ze(o, typeof t != "symbol" ? t + "" : t, e);
4
- import ts from "@turf/boolean-point-in-polygon";
5
- import es from "@turf/centroid";
6
- import ke from "@turf/convex";
7
- import { featureCollection as Ot, polygon as me, point as Jt, lineString as xe } from "@turf/helpers";
8
- import ss from "@turf/line-intersect";
9
- import ns from "delaunator";
10
- var is = Object.defineProperty, rs = (o, t, e) => t in o ? is(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, nt = (o, t, e) => rs(o, typeof t != "symbol" ? t + "" : t, e);
11
- const Tt = 11102230246251565e-32, lt = 134217729, os = (3 + 8 * Tt) * Tt;
12
- function ae(o, t, e, s, i) {
13
- let n, r, a, f, c = t[0], u = s[0], h = 0, l = 0;
14
- u > c == u > -c ? (n = c, c = t[++h]) : (n = u, u = s[++l]);
15
- let p = 0;
16
- if (h < o && l < e)
17
- for (u > c == u > -c ? (r = c + n, a = n - (r - c), c = t[++h]) : (r = u + n, a = n - (r - u), u = s[++l]), n = r, a !== 0 && (i[p++] = a); h < o && l < e; )
18
- u > c == u > -c ? (r = n + c, f = r - n, a = n - (r - f) + (c - f), c = t[++h]) : (r = n + u, f = r - n, a = n - (r - f) + (u - f), u = s[++l]), n = r, a !== 0 && (i[p++] = a);
19
- for (; h < o; )
20
- r = n + c, f = r - n, a = n - (r - f) + (c - f), c = t[++h], n = r, a !== 0 && (i[p++] = a);
21
- for (; l < e; )
22
- r = n + u, f = r - n, a = n - (r - f) + (u - f), u = s[++l], n = r, a !== 0 && (i[p++] = a);
23
- return (n !== 0 || p === 0) && (i[p++] = n), p;
24
- }
25
- function as(o, t) {
1
+ const Ct = 11102230246251565e-32, rt = 134217729, Xn = (3 + 8 * Ct) * Ct;
2
+ function Yt(o, t, e, n, r) {
3
+ let i, s, a, c, h = t[0], u = n[0], f = 0, d = 0;
4
+ u > h == u > -h ? (i = h, h = t[++f]) : (i = u, u = n[++d]);
5
+ let y = 0;
6
+ if (f < o && d < e)
7
+ for (u > h == u > -h ? (s = h + i, a = i - (s - h), h = t[++f]) : (s = u + i, a = i - (s - u), u = n[++d]), i = s, a !== 0 && (r[y++] = a); f < o && d < e; )
8
+ u > h == u > -h ? (s = i + h, c = s - i, a = i - (s - c) + (h - c), h = t[++f]) : (s = i + u, c = s - i, a = i - (s - c) + (u - c), u = n[++d]), i = s, a !== 0 && (r[y++] = a);
9
+ for (; f < o; )
10
+ s = i + h, c = s - i, a = i - (s - c) + (h - c), h = t[++f], i = s, a !== 0 && (r[y++] = a);
11
+ for (; d < e; )
12
+ s = i + u, c = s - i, a = i - (s - c) + (u - c), u = n[++d], i = s, a !== 0 && (r[y++] = a);
13
+ return (i !== 0 || y === 0) && (r[y++] = i), y;
14
+ }
15
+ function Ut(o, t, e, n, r, i, s, a) {
16
+ return Yt(Yt(o, t, e, n, s), s, r, i, a);
17
+ }
18
+ function U(o, t, e, n) {
19
+ let r, i, s, a, c, h, u, f, d, y, E;
20
+ u = rt * e, y = u - (u - e), E = e - y;
21
+ let k = t[0];
22
+ r = k * e, u = rt * k, f = u - (u - k), d = k - f, s = d * E - (r - f * y - d * y - f * E);
23
+ let X = 0;
24
+ s !== 0 && (n[X++] = s);
25
+ for (let C = 1; C < o; C++)
26
+ k = t[C], a = k * e, u = rt * k, f = u - (u - k), d = k - f, c = d * E - (a - f * y - d * y - f * E), i = r + c, h = i - r, s = r - (i - h) + (c - h), s !== 0 && (n[X++] = s), r = a + i, s = i - (r - a), s !== 0 && (n[X++] = s);
27
+ return (r !== 0 || X === 0) && (n[X++] = r), X;
28
+ }
29
+ function Yn(o, t) {
26
30
  let e = t[0];
27
- for (let s = 1; s < o; s++) e += t[s];
31
+ for (let n = 1; n < o; n++) e += t[n];
28
32
  return e;
29
33
  }
30
- function Ht(o) {
34
+ function vt(o) {
31
35
  return new Float64Array(o);
32
36
  }
33
- const hs = (3 + 16 * Tt) * Tt, cs = (2 + 12 * Tt) * Tt, fs = (9 + 64 * Tt) * Tt * Tt, Vt = Ht(4), _e = Ht(8), Me = Ht(12), Se = Ht(16), gt = Ht(4);
34
- function us(o, t, e, s, i, n, r) {
35
- let a, f, c, u, h, l, p, y, g, b, w, S, _, v, T, I, N, V;
36
- const z = o - i, G = e - i, tt = t - n, X = s - n;
37
- v = z * X, l = lt * z, p = l - (l - z), y = z - p, l = lt * X, g = l - (l - X), b = X - g, T = y * b - (v - p * g - y * g - p * b), I = tt * G, l = lt * tt, p = l - (l - tt), y = tt - p, l = lt * G, g = l - (l - G), b = G - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, Vt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, Vt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, Vt[2] = S - (V - h) + (w - h), Vt[3] = V;
38
- let it = as(4, Vt), d = cs * r;
39
- if (it >= d || -it >= d || (h = o - z, a = o - (z + h) + (h - i), h = e - G, c = e - (G + h) + (h - i), h = t - tt, f = t - (tt + h) + (h - n), h = s - X, u = s - (X + h) + (h - n), a === 0 && f === 0 && c === 0 && u === 0) || (d = fs * r + os * Math.abs(it), it += z * u + X * a - (tt * c + G * f), it >= d || -it >= d)) return it;
40
- v = a * X, l = lt * a, p = l - (l - a), y = a - p, l = lt * X, g = l - (l - X), b = X - g, T = y * b - (v - p * g - y * g - p * b), I = f * G, l = lt * f, p = l - (l - f), y = f - p, l = lt * G, g = l - (l - G), b = G - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, gt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, gt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, gt[2] = S - (V - h) + (w - h), gt[3] = V;
41
- const m = ae(4, Vt, 4, gt, _e);
42
- v = z * u, l = lt * z, p = l - (l - z), y = z - p, l = lt * u, g = l - (l - u), b = u - g, T = y * b - (v - p * g - y * g - p * b), I = tt * c, l = lt * tt, p = l - (l - tt), y = tt - p, l = lt * c, g = l - (l - c), b = c - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, gt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, gt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, gt[2] = S - (V - h) + (w - h), gt[3] = V;
43
- const x = ae(m, _e, 4, gt, Me);
44
- v = a * u, l = lt * a, p = l - (l - a), y = a - p, l = lt * u, g = l - (l - u), b = u - g, T = y * b - (v - p * g - y * g - p * b), I = f * c, l = lt * f, p = l - (l - f), y = f - p, l = lt * c, g = l - (l - c), b = c - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, gt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, gt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, gt[2] = S - (V - h) + (w - h), gt[3] = V;
45
- const A = ae(x, Me, 4, gt, Se);
46
- return Se[A - 1];
47
- }
48
- function ls(o, t, e, s, i, n) {
49
- const r = (t - n) * (e - i), a = (o - i) * (s - n), f = r - a, c = Math.abs(r + a);
50
- return Math.abs(f) >= hs * c ? f : -us(o, t, e, s, i, n, c);
51
- }
52
- function ds(o, t) {
53
- var e, s, i = 0, n, r, a, f, c, u, h, l = o[0], p = o[1], y = t.length;
54
- for (e = 0; e < y; e++) {
55
- s = 0;
56
- var g = t[e], b = g.length - 1;
57
- if (u = g[0], u[0] !== g[b][0] && u[1] !== g[b][1])
37
+ const Jn = (3 + 16 * Ct) * Ct, Kn = (2 + 12 * Ct) * Ct, Gn = (9 + 64 * Ct) * Ct * Ct, me = vt(4), cn = vt(8), hn = vt(12), fn = vt(16), Ft = vt(4);
38
+ function Qn(o, t, e, n, r, i, s) {
39
+ let a, c, h, u, f, d, y, E, k, X, C, m, v, l, g, x, A, I;
40
+ const b = o - r, T = e - r, R = t - i, D = n - i;
41
+ l = b * D, d = rt * b, y = d - (d - b), E = b - y, d = rt * D, k = d - (d - D), X = D - k, g = E * X - (l - y * k - E * k - y * X), x = R * T, d = rt * R, y = d - (d - R), E = R - y, d = rt * T, k = d - (d - T), X = T - k, A = E * X - (x - y * k - E * k - y * X), C = g - A, f = g - C, me[0] = g - (C + f) + (f - A), m = l + C, f = m - l, v = l - (m - f) + (C - f), C = v - x, f = v - C, me[1] = v - (C + f) + (f - x), I = m + C, f = I - m, me[2] = m - (I - f) + (C - f), me[3] = I;
42
+ let Q = Yn(4, me), p = Kn * s;
43
+ if (Q >= p || -Q >= p || (f = o - b, a = o - (b + f) + (f - r), f = e - T, h = e - (T + f) + (f - r), f = t - R, c = t - (R + f) + (f - i), f = n - D, u = n - (D + f) + (f - i), a === 0 && c === 0 && h === 0 && u === 0) || (p = Gn * s + Xn * Math.abs(Q), Q += b * u + D * a - (R * h + T * c), Q >= p || -Q >= p)) return Q;
44
+ l = a * D, d = rt * a, y = d - (d - a), E = a - y, d = rt * D, k = d - (d - D), X = D - k, g = E * X - (l - y * k - E * k - y * X), x = c * T, d = rt * c, y = d - (d - c), E = c - y, d = rt * T, k = d - (d - T), X = T - k, A = E * X - (x - y * k - E * k - y * X), C = g - A, f = g - C, Ft[0] = g - (C + f) + (f - A), m = l + C, f = m - l, v = l - (m - f) + (C - f), C = v - x, f = v - C, Ft[1] = v - (C + f) + (f - x), I = m + C, f = I - m, Ft[2] = m - (I - f) + (C - f), Ft[3] = I;
45
+ const M = Yt(4, me, 4, Ft, cn);
46
+ l = b * u, d = rt * b, y = d - (d - b), E = b - y, d = rt * u, k = d - (d - u), X = u - k, g = E * X - (l - y * k - E * k - y * X), x = R * h, d = rt * R, y = d - (d - R), E = R - y, d = rt * h, k = d - (d - h), X = h - k, A = E * X - (x - y * k - E * k - y * X), C = g - A, f = g - C, Ft[0] = g - (C + f) + (f - A), m = l + C, f = m - l, v = l - (m - f) + (C - f), C = v - x, f = v - C, Ft[1] = v - (C + f) + (f - x), I = m + C, f = I - m, Ft[2] = m - (I - f) + (C - f), Ft[3] = I;
47
+ const _ = Yt(M, cn, 4, Ft, hn);
48
+ l = a * u, d = rt * a, y = d - (d - a), E = a - y, d = rt * u, k = d - (d - u), X = u - k, g = E * X - (l - y * k - E * k - y * X), x = c * h, d = rt * c, y = d - (d - c), E = c - y, d = rt * h, k = d - (d - h), X = h - k, A = E * X - (x - y * k - E * k - y * X), C = g - A, f = g - C, Ft[0] = g - (C + f) + (f - A), m = l + C, f = m - l, v = l - (m - f) + (C - f), C = v - x, f = v - C, Ft[1] = v - (C + f) + (f - x), I = m + C, f = I - m, Ft[2] = m - (I - f) + (C - f), Ft[3] = I;
49
+ const B = Yt(_, hn, 4, Ft, fn);
50
+ return fn[B - 1];
51
+ }
52
+ function te(o, t, e, n, r, i) {
53
+ const s = (t - i) * (e - r), a = (o - r) * (n - i), c = s - a, h = Math.abs(s + a);
54
+ return Math.abs(c) >= Jn * h ? c : -Qn(o, t, e, n, r, i, h);
55
+ }
56
+ const Hn = (10 + 96 * Ct) * Ct, Zn = (4 + 48 * Ct) * Ct, tr = (44 + 576 * Ct) * Ct * Ct, re = vt(4), ie = vt(4), se = vt(4), Qt = vt(4), Ht = vt(4), Zt = vt(4), Lt = vt(4), Dt = vt(4), Ve = vt(8), We = vt(8), Je = vt(8), Ke = vt(8), Ge = vt(8), Qe = vt(8), Ae = vt(8), Pe = vt(8), Be = vt(8), fe = vt(4), ue = vt(4), le = vt(4), ot = vt(8), pt = vt(16), kt = vt(16), St = vt(16), bt = vt(32), oe = vt(32), Ot = vt(48), $t = vt(64);
57
+ let ye = vt(1152), He = vt(1152);
58
+ function It(o, t, e) {
59
+ o = Yt(o, ye, t, e, He);
60
+ const n = ye;
61
+ return ye = He, He = n, o;
62
+ }
63
+ function er(o, t, e, n, r, i, s, a, c) {
64
+ let h, u, f, d, y, E, k, X, C, m, v, l, g, x, A, I, b, T, R, D, Q, p, M, _, B, N, Y, w, O, $, q, V, z, K, j;
65
+ const ct = o - s, ht = e - s, lt = r - s, dt = t - a, gt = n - a, mt = i - a;
66
+ q = ht * mt, M = rt * ht, _ = M - (M - ht), B = ht - _, M = rt * mt, N = M - (M - mt), Y = mt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = lt * gt, M = rt * lt, _ = M - (M - lt), B = lt - _, M = rt * gt, N = M - (M - gt), Y = gt - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, re[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, re[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, re[2] = O - (j - p) + (w - p), re[3] = j, q = lt * dt, M = rt * lt, _ = M - (M - lt), B = lt - _, M = rt * dt, N = M - (M - dt), Y = dt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ct * mt, M = rt * ct, _ = M - (M - ct), B = ct - _, M = rt * mt, N = M - (M - mt), Y = mt - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, ie[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, ie[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, ie[2] = O - (j - p) + (w - p), ie[3] = j, q = ct * gt, M = rt * ct, _ = M - (M - ct), B = ct - _, M = rt * gt, N = M - (M - gt), Y = gt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ht * dt, M = rt * ht, _ = M - (M - ht), B = ht - _, M = rt * dt, N = M - (M - dt), Y = dt - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, se[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, se[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, se[2] = O - (j - p) + (w - p), se[3] = j, h = Yt(
67
+ Yt(
68
+ Yt(
69
+ U(U(4, re, ct, ot), ot, ct, pt),
70
+ pt,
71
+ U(U(4, re, dt, ot), ot, dt, kt),
72
+ kt,
73
+ bt
74
+ ),
75
+ bt,
76
+ Yt(
77
+ U(U(4, ie, ht, ot), ot, ht, pt),
78
+ pt,
79
+ U(U(4, ie, gt, ot), ot, gt, kt),
80
+ kt,
81
+ oe
82
+ ),
83
+ oe,
84
+ $t
85
+ ),
86
+ $t,
87
+ Yt(
88
+ U(U(4, se, lt, ot), ot, lt, pt),
89
+ pt,
90
+ U(U(4, se, mt, ot), ot, mt, kt),
91
+ kt,
92
+ bt
93
+ ),
94
+ bt,
95
+ ye
96
+ );
97
+ let Pt = Yn(h, ye), Tt = Zn * c;
98
+ if (Pt >= Tt || -Pt >= Tt || (p = o - ct, u = o - (ct + p) + (p - s), p = t - dt, y = t - (dt + p) + (p - a), p = e - ht, f = e - (ht + p) + (p - s), p = n - gt, E = n - (gt + p) + (p - a), p = r - lt, d = r - (lt + p) + (p - s), p = i - mt, k = i - (mt + p) + (p - a), u === 0 && f === 0 && d === 0 && y === 0 && E === 0 && k === 0) || (Tt = tr * c + Xn * Math.abs(Pt), Pt += (ct * ct + dt * dt) * (ht * k + mt * f - (gt * d + lt * E)) + 2 * (ct * u + dt * y) * (ht * mt - gt * lt) + ((ht * ht + gt * gt) * (lt * y + dt * d - (mt * u + ct * k)) + 2 * (ht * f + gt * E) * (lt * dt - mt * ct)) + ((lt * lt + mt * mt) * (ct * E + gt * u - (dt * f + ht * y)) + 2 * (lt * d + mt * k) * (ct * gt - dt * ht)), Pt >= Tt || -Pt >= Tt))
99
+ return Pt;
100
+ if ((f !== 0 || E !== 0 || d !== 0 || k !== 0) && (q = ct * ct, M = rt * ct, _ = M - (M - ct), B = ct - _, V = B * B - (q - _ * _ - (_ + _) * B), z = dt * dt, M = rt * dt, _ = M - (M - dt), B = dt - _, K = B * B - (z - _ * _ - (_ + _) * B), w = V + K, p = w - V, Qt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Qt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Qt[2] = O - (j - p) + (w - p), Qt[3] = j), (d !== 0 || k !== 0 || u !== 0 || y !== 0) && (q = ht * ht, M = rt * ht, _ = M - (M - ht), B = ht - _, V = B * B - (q - _ * _ - (_ + _) * B), z = gt * gt, M = rt * gt, _ = M - (M - gt), B = gt - _, K = B * B - (z - _ * _ - (_ + _) * B), w = V + K, p = w - V, Ht[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Ht[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Ht[2] = O - (j - p) + (w - p), Ht[3] = j), (u !== 0 || y !== 0 || f !== 0 || E !== 0) && (q = lt * lt, M = rt * lt, _ = M - (M - lt), B = lt - _, V = B * B - (q - _ * _ - (_ + _) * B), z = mt * mt, M = rt * mt, _ = M - (M - mt), B = mt - _, K = B * B - (z - _ * _ - (_ + _) * B), w = V + K, p = w - V, Zt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Zt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Zt[2] = O - (j - p) + (w - p), Zt[3] = j), u !== 0 && (X = U(4, re, u, Ve), h = It(h, Ut(
101
+ U(X, Ve, 2 * ct, pt),
102
+ pt,
103
+ U(U(4, Zt, u, ot), ot, gt, kt),
104
+ kt,
105
+ U(U(4, Ht, u, ot), ot, -mt, St),
106
+ St,
107
+ bt,
108
+ Ot
109
+ ), Ot)), y !== 0 && (C = U(4, re, y, We), h = It(h, Ut(
110
+ U(C, We, 2 * dt, pt),
111
+ pt,
112
+ U(U(4, Ht, y, ot), ot, lt, kt),
113
+ kt,
114
+ U(U(4, Zt, y, ot), ot, -ht, St),
115
+ St,
116
+ bt,
117
+ Ot
118
+ ), Ot)), f !== 0 && (m = U(4, ie, f, Je), h = It(h, Ut(
119
+ U(m, Je, 2 * ht, pt),
120
+ pt,
121
+ U(U(4, Qt, f, ot), ot, mt, kt),
122
+ kt,
123
+ U(U(4, Zt, f, ot), ot, -dt, St),
124
+ St,
125
+ bt,
126
+ Ot
127
+ ), Ot)), E !== 0 && (v = U(4, ie, E, Ke), h = It(h, Ut(
128
+ U(v, Ke, 2 * gt, pt),
129
+ pt,
130
+ U(U(4, Zt, E, ot), ot, ct, kt),
131
+ kt,
132
+ U(U(4, Qt, E, ot), ot, -lt, St),
133
+ St,
134
+ bt,
135
+ Ot
136
+ ), Ot)), d !== 0 && (l = U(4, se, d, Ge), h = It(h, Ut(
137
+ U(l, Ge, 2 * lt, pt),
138
+ pt,
139
+ U(U(4, Ht, d, ot), ot, dt, kt),
140
+ kt,
141
+ U(U(4, Qt, d, ot), ot, -gt, St),
142
+ St,
143
+ bt,
144
+ Ot
145
+ ), Ot)), k !== 0 && (g = U(4, se, k, Qe), h = It(h, Ut(
146
+ U(g, Qe, 2 * mt, pt),
147
+ pt,
148
+ U(U(4, Qt, k, ot), ot, ht, kt),
149
+ kt,
150
+ U(U(4, Ht, k, ot), ot, -ct, St),
151
+ St,
152
+ bt,
153
+ Ot
154
+ ), Ot)), u !== 0 || y !== 0) {
155
+ if (f !== 0 || E !== 0 || d !== 0 || k !== 0 ? (q = f * mt, M = rt * f, _ = M - (M - f), B = f - _, M = rt * mt, N = M - (M - mt), Y = mt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ht * k, M = rt * ht, _ = M - (M - ht), B = ht - _, M = rt * k, N = M - (M - k), Y = k - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Lt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Lt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Lt[2] = O - (j - p) + (w - p), Lt[3] = j, q = d * -gt, M = rt * d, _ = M - (M - d), B = d - _, M = rt * -gt, N = M - (M - -gt), Y = -gt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = lt * -E, M = rt * lt, _ = M - (M - lt), B = lt - _, M = rt * -E, N = M - (M - -E), Y = -E - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Dt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Dt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Dt[2] = O - (j - p) + (w - p), Dt[3] = j, A = Yt(4, Lt, 4, Dt, Pe), q = f * k, M = rt * f, _ = M - (M - f), B = f - _, M = rt * k, N = M - (M - k), Y = k - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = d * E, M = rt * d, _ = M - (M - d), B = d - _, M = rt * E, N = M - (M - E), Y = E - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, ue[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, ue[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, ue[2] = O - (j - p) + (w - p), ue[3] = j, T = 4) : (Pe[0] = 0, A = 1, ue[0] = 0, T = 1), u !== 0) {
156
+ const xt = U(A, Pe, u, St);
157
+ h = It(h, Yt(
158
+ U(X, Ve, u, pt),
159
+ pt,
160
+ U(xt, St, 2 * ct, bt),
161
+ bt,
162
+ Ot
163
+ ), Ot);
164
+ const Mt = U(T, ue, u, ot);
165
+ h = It(h, Ut(
166
+ U(Mt, ot, 2 * ct, pt),
167
+ pt,
168
+ U(Mt, ot, u, kt),
169
+ kt,
170
+ U(xt, St, u, bt),
171
+ bt,
172
+ oe,
173
+ $t
174
+ ), $t), E !== 0 && (h = It(h, U(U(4, Zt, u, ot), ot, E, pt), pt)), k !== 0 && (h = It(h, U(U(4, Ht, -u, ot), ot, k, pt), pt));
175
+ }
176
+ if (y !== 0) {
177
+ const xt = U(A, Pe, y, St);
178
+ h = It(h, Yt(
179
+ U(C, We, y, pt),
180
+ pt,
181
+ U(xt, St, 2 * dt, bt),
182
+ bt,
183
+ Ot
184
+ ), Ot);
185
+ const Mt = U(T, ue, y, ot);
186
+ h = It(h, Ut(
187
+ U(Mt, ot, 2 * dt, pt),
188
+ pt,
189
+ U(Mt, ot, y, kt),
190
+ kt,
191
+ U(xt, St, y, bt),
192
+ bt,
193
+ oe,
194
+ $t
195
+ ), $t);
196
+ }
197
+ }
198
+ if (f !== 0 || E !== 0) {
199
+ if (d !== 0 || k !== 0 || u !== 0 || y !== 0 ? (q = d * dt, M = rt * d, _ = M - (M - d), B = d - _, M = rt * dt, N = M - (M - dt), Y = dt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = lt * y, M = rt * lt, _ = M - (M - lt), B = lt - _, M = rt * y, N = M - (M - y), Y = y - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Lt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Lt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Lt[2] = O - (j - p) + (w - p), Lt[3] = j, D = -mt, Q = -k, q = u * D, M = rt * u, _ = M - (M - u), B = u - _, M = rt * D, N = M - (M - D), Y = D - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ct * Q, M = rt * ct, _ = M - (M - ct), B = ct - _, M = rt * Q, N = M - (M - Q), Y = Q - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Dt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Dt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Dt[2] = O - (j - p) + (w - p), Dt[3] = j, I = Yt(4, Lt, 4, Dt, Be), q = d * y, M = rt * d, _ = M - (M - d), B = d - _, M = rt * y, N = M - (M - y), Y = y - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = u * k, M = rt * u, _ = M - (M - u), B = u - _, M = rt * k, N = M - (M - k), Y = k - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, le[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, le[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, le[2] = O - (j - p) + (w - p), le[3] = j, R = 4) : (Be[0] = 0, I = 1, le[0] = 0, R = 1), f !== 0) {
200
+ const xt = U(I, Be, f, St);
201
+ h = It(h, Yt(
202
+ U(m, Je, f, pt),
203
+ pt,
204
+ U(xt, St, 2 * ht, bt),
205
+ bt,
206
+ Ot
207
+ ), Ot);
208
+ const Mt = U(R, le, f, ot);
209
+ h = It(h, Ut(
210
+ U(Mt, ot, 2 * ht, pt),
211
+ pt,
212
+ U(Mt, ot, f, kt),
213
+ kt,
214
+ U(xt, St, f, bt),
215
+ bt,
216
+ oe,
217
+ $t
218
+ ), $t), k !== 0 && (h = It(h, U(U(4, Qt, f, ot), ot, k, pt), pt)), y !== 0 && (h = It(h, U(U(4, Zt, -f, ot), ot, y, pt), pt));
219
+ }
220
+ if (E !== 0) {
221
+ const xt = U(I, Be, E, St);
222
+ h = It(h, Yt(
223
+ U(v, Ke, E, pt),
224
+ pt,
225
+ U(xt, St, 2 * gt, bt),
226
+ bt,
227
+ Ot
228
+ ), Ot);
229
+ const Mt = U(R, le, E, ot);
230
+ h = It(h, Ut(
231
+ U(Mt, ot, 2 * gt, pt),
232
+ pt,
233
+ U(Mt, ot, E, kt),
234
+ kt,
235
+ U(xt, St, E, bt),
236
+ bt,
237
+ oe,
238
+ $t
239
+ ), $t);
240
+ }
241
+ }
242
+ if (d !== 0 || k !== 0) {
243
+ if (u !== 0 || y !== 0 || f !== 0 || E !== 0 ? (q = u * gt, M = rt * u, _ = M - (M - u), B = u - _, M = rt * gt, N = M - (M - gt), Y = gt - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ct * E, M = rt * ct, _ = M - (M - ct), B = ct - _, M = rt * E, N = M - (M - E), Y = E - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Lt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Lt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Lt[2] = O - (j - p) + (w - p), Lt[3] = j, D = -dt, Q = -y, q = f * D, M = rt * f, _ = M - (M - f), B = f - _, M = rt * D, N = M - (M - D), Y = D - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = ht * Q, M = rt * ht, _ = M - (M - ht), B = ht - _, M = rt * Q, N = M - (M - Q), Y = Q - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V + K, p = w - V, Dt[0] = V - (w - p) + (K - p), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ + z, p = w - $, Dt[1] = $ - (w - p) + (z - p), j = O + w, p = j - O, Dt[2] = O - (j - p) + (w - p), Dt[3] = j, x = Yt(4, Lt, 4, Dt, Ae), q = u * E, M = rt * u, _ = M - (M - u), B = u - _, M = rt * E, N = M - (M - E), Y = E - N, V = B * Y - (q - _ * N - B * N - _ * Y), z = f * y, M = rt * f, _ = M - (M - f), B = f - _, M = rt * y, N = M - (M - y), Y = y - N, K = B * Y - (z - _ * N - B * N - _ * Y), w = V - K, p = V - w, fe[0] = V - (w + p) + (p - K), O = q + w, p = O - q, $ = q - (O - p) + (w - p), w = $ - z, p = $ - w, fe[1] = $ - (w + p) + (p - z), j = O + w, p = j - O, fe[2] = O - (j - p) + (w - p), fe[3] = j, b = 4) : (Ae[0] = 0, x = 1, fe[0] = 0, b = 1), d !== 0) {
244
+ const xt = U(x, Ae, d, St);
245
+ h = It(h, Yt(
246
+ U(l, Ge, d, pt),
247
+ pt,
248
+ U(xt, St, 2 * lt, bt),
249
+ bt,
250
+ Ot
251
+ ), Ot);
252
+ const Mt = U(b, fe, d, ot);
253
+ h = It(h, Ut(
254
+ U(Mt, ot, 2 * lt, pt),
255
+ pt,
256
+ U(Mt, ot, d, kt),
257
+ kt,
258
+ U(xt, St, d, bt),
259
+ bt,
260
+ oe,
261
+ $t
262
+ ), $t), y !== 0 && (h = It(h, U(U(4, Ht, d, ot), ot, y, pt), pt)), E !== 0 && (h = It(h, U(U(4, Qt, -d, ot), ot, E, pt), pt));
263
+ }
264
+ if (k !== 0) {
265
+ const xt = U(x, Ae, k, St);
266
+ h = It(h, Yt(
267
+ U(g, Qe, k, pt),
268
+ pt,
269
+ U(xt, St, 2 * mt, bt),
270
+ bt,
271
+ Ot
272
+ ), Ot);
273
+ const Mt = U(b, fe, k, ot);
274
+ h = It(h, Ut(
275
+ U(Mt, ot, 2 * mt, pt),
276
+ pt,
277
+ U(Mt, ot, k, kt),
278
+ kt,
279
+ U(xt, St, k, bt),
280
+ bt,
281
+ oe,
282
+ $t
283
+ ), $t);
284
+ }
285
+ }
286
+ return ye[h - 1];
287
+ }
288
+ function nr(o, t, e, n, r, i, s, a) {
289
+ const c = o - s, h = e - s, u = r - s, f = t - a, d = n - a, y = i - a, E = h * y, k = u * d, X = c * c + f * f, C = u * f, m = c * y, v = h * h + d * d, l = c * d, g = h * f, x = u * u + y * y, A = X * (E - k) + v * (C - m) + x * (l - g), I = (Math.abs(E) + Math.abs(k)) * X + (Math.abs(C) + Math.abs(m)) * v + (Math.abs(l) + Math.abs(g)) * x, b = Hn * I;
290
+ return A > b || -A > b ? A : er(o, t, e, n, r, i, s, a, I);
291
+ }
292
+ function rr(o, t) {
293
+ var e, n, r = 0, i, s, a, c, h, u, f, d = o[0], y = o[1], E = t.length;
294
+ for (e = 0; e < E; e++) {
295
+ n = 0;
296
+ var k = t[e], X = k.length - 1;
297
+ if (u = k[0], u[0] !== k[X][0] && u[1] !== k[X][1])
58
298
  throw new Error("First and last coordinates in a ring must be the same");
59
- for (r = u[0] - l, a = u[1] - p, s; s < b; s++) {
60
- if (h = g[s + 1], f = h[0] - l, c = h[1] - p, a === 0 && c === 0) {
61
- if (f <= 0 && r >= 0 || r <= 0 && f >= 0)
299
+ for (s = u[0] - d, a = u[1] - y, n; n < X; n++) {
300
+ if (f = k[n + 1], c = f[0] - d, h = f[1] - y, a === 0 && h === 0) {
301
+ if (c <= 0 && s >= 0 || s <= 0 && c >= 0)
62
302
  return 0;
63
- } else if (c >= 0 && a <= 0 || c <= 0 && a >= 0) {
64
- if (n = ls(r, f, a, c, 0, 0), n === 0)
303
+ } else if (h >= 0 && a <= 0 || h <= 0 && a >= 0) {
304
+ if (i = te(s, c, a, h, 0, 0), i === 0)
65
305
  return 0;
66
- (n > 0 && c > 0 && a <= 0 || n < 0 && c <= 0 && a > 0) && i++;
306
+ (i > 0 && h > 0 && a <= 0 || i < 0 && h <= 0 && a > 0) && r++;
67
307
  }
68
- u = h, a = c, r = f;
308
+ u = f, a = h, s = c;
69
309
  }
70
310
  }
71
- return i % 2 !== 0;
311
+ return r % 2 !== 0;
72
312
  }
73
- function Le(o, t, e = {}) {
74
- const s = { type: "Feature" };
75
- return (e.id === 0 || e.id) && (s.id = e.id), e.bbox && (s.bbox = e.bbox), s.properties = t || {}, s.geometry = o, s;
313
+ function Se(o, t, e = {}) {
314
+ const n = { type: "Feature" };
315
+ return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = o, n;
76
316
  }
77
- function Yt(o, t, e = {}) {
317
+ function de(o, t, e = {}) {
78
318
  if (!o)
79
319
  throw new Error("coordinates is required");
80
320
  if (!Array.isArray(o))
81
321
  throw new Error("coordinates must be an Array");
82
322
  if (o.length < 2)
83
323
  throw new Error("coordinates must be at least 2 numbers long");
84
- if (!Ae(o[0]) || !Ae(o[1]))
324
+ if (!ln(o[0]) || !ln(o[1]))
85
325
  throw new Error("coordinates must contain numbers");
86
- return Le({
326
+ return Se({
87
327
  type: "Point",
88
328
  coordinates: o
89
329
  }, t, e);
90
330
  }
91
- function Ve(o, t, e = {}) {
92
- for (const s of o) {
93
- if (s.length < 4)
331
+ function Ee(o, t, e = {}) {
332
+ for (const r of o) {
333
+ if (r.length < 4)
94
334
  throw new Error(
95
335
  "Each LinearRing of a Polygon must have 4 or more Positions."
96
336
  );
97
- if (s[s.length - 1].length !== s[0].length)
337
+ if (r[r.length - 1].length !== r[0].length)
98
338
  throw new Error("First and last Position are not equivalent.");
99
- for (let i = 0; i < s[s.length - 1].length; i++)
100
- if (s[s.length - 1][i] !== s[0][i])
339
+ for (let i = 0; i < r[r.length - 1].length; i++)
340
+ if (r[r.length - 1][i] !== r[0][i])
101
341
  throw new Error("First and last Position are not equivalent.");
102
342
  }
103
- return Le({
343
+ return Se({
104
344
  type: "Polygon",
105
345
  coordinates: o
106
346
  }, t, e);
107
347
  }
108
- function Lt(o, t = {}) {
348
+ function un(o, t, e = {}) {
349
+ if (o.length < 2)
350
+ throw new Error("coordinates must be an array of two or more positions");
351
+ return Se({
352
+ type: "LineString",
353
+ coordinates: o
354
+ }, t, e);
355
+ }
356
+ function Kt(o, t = {}) {
109
357
  const e = { type: "FeatureCollection" };
110
358
  return t.id && (e.id = t.id), t.bbox && (e.bbox = t.bbox), e.features = o, e;
111
359
  }
112
- function Ae(o) {
360
+ function ln(o) {
113
361
  return !isNaN(o) && o !== null && !Array.isArray(o);
114
362
  }
115
- function gs(o) {
363
+ function ir(o) {
116
364
  if (!o)
117
365
  throw new Error("coord is required");
118
366
  if (!Array.isArray(o)) {
@@ -125,863 +373,1331 @@ function gs(o) {
125
373
  return [...o];
126
374
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
127
375
  }
128
- function Ee(o) {
129
- if (Array.isArray(o))
130
- return o;
131
- if (o.type === "Feature") {
132
- if (o.geometry !== null)
133
- return o.geometry.coordinates;
134
- } else if (o.coordinates)
135
- return o.coordinates;
136
- throw new Error(
137
- "coords must be GeoJSON Feature, Geometry Object or an Array"
138
- );
139
- }
140
- function ps(o) {
376
+ function sr(o) {
141
377
  return o.type === "Feature" ? o.geometry : o;
142
378
  }
143
- function ws(o, t, e = {}) {
379
+ function or(o, t, e = {}) {
144
380
  if (!o)
145
381
  throw new Error("point is required");
146
382
  if (!t)
147
383
  throw new Error("polygon is required");
148
- const s = gs(o), i = ps(t), n = i.type, r = t.bbox;
149
- let a = i.coordinates;
150
- if (r && ms(s, r) === !1)
384
+ const n = ir(o), r = sr(t), i = r.type, s = t.bbox;
385
+ let a = r.coordinates;
386
+ if (s && ar(n, s) === !1)
151
387
  return !1;
152
- n === "Polygon" && (a = [a]);
153
- let f = !1;
154
- for (var c = 0; c < a.length; ++c) {
155
- const u = ds(s, a[c]);
388
+ i === "Polygon" && (a = [a]);
389
+ let c = !1;
390
+ for (var h = 0; h < a.length; ++h) {
391
+ const u = rr(n, a[h]);
156
392
  if (u === 0) return !e.ignoreBoundary;
157
- u && (f = !0);
393
+ u && (c = !0);
158
394
  }
159
- return f;
395
+ return c;
160
396
  }
161
- function ms(o, t) {
397
+ function ar(o, t) {
162
398
  return t[0] <= o[0] && t[1] <= o[1] && t[2] >= o[0] && t[3] >= o[1];
163
399
  }
164
- var pe = ws;
165
- function ve(o) {
166
- const t = o.features;
167
- for (let e = 0; e < t.length; e++) {
168
- const s = t[e];
169
- `${s.properties.a.index}`.substring(0, 1) === "b" && `${s.properties.b.index}`.substring(0, 1) === "b" ? t[e] = {
170
- geometry: {
171
- type: "Polygon",
172
- coordinates: [
173
- [
174
- s.geometry.coordinates[0][2],
175
- s.geometry.coordinates[0][0],
176
- s.geometry.coordinates[0][1],
177
- s.geometry.coordinates[0][2]
178
- ]
179
- ]
180
- },
181
- properties: {
182
- a: {
183
- geom: s.properties.c.geom,
184
- index: s.properties.c.index
185
- },
186
- b: {
187
- geom: s.properties.a.geom,
188
- index: s.properties.a.index
189
- },
190
- c: {
191
- geom: s.properties.b.geom,
192
- index: s.properties.b.index
193
- }
194
- },
195
- type: "Feature"
196
- } : `${s.properties.c.index}`.substring(0, 1) === "b" && `${s.properties.a.index}`.substring(0, 1) === "b" && (t[e] = {
197
- geometry: {
198
- type: "Polygon",
199
- coordinates: [
200
- [
201
- s.geometry.coordinates[0][1],
202
- s.geometry.coordinates[0][2],
203
- s.geometry.coordinates[0][0],
204
- s.geometry.coordinates[0][1]
205
- ]
206
- ]
207
- },
208
- properties: {
209
- a: {
210
- geom: s.properties.b.geom,
211
- index: s.properties.b.index
212
- },
213
- b: {
214
- geom: s.properties.c.geom,
215
- index: s.properties.c.index
216
- },
217
- c: {
218
- geom: s.properties.a.geom,
219
- index: s.properties.a.index
400
+ var cr = or;
401
+ function rn(o, t, e) {
402
+ if (o !== null)
403
+ for (var n, r, i, s, a, c, h, u = 0, f = 0, d, y = o.type, E = y === "FeatureCollection", k = y === "Feature", X = E ? o.features.length : 1, C = 0; C < X; C++) {
404
+ h = E ? o.features[C].geometry : k ? o.geometry : o, d = h ? h.type === "GeometryCollection" : !1, a = d ? h.geometries.length : 1;
405
+ for (var m = 0; m < a; m++) {
406
+ var v = 0, l = 0;
407
+ if (s = d ? h.geometries[m] : h, s !== null) {
408
+ c = s.coordinates;
409
+ var g = s.type;
410
+ switch (u = e && (g === "Polygon" || g === "MultiPolygon") ? 1 : 0, g) {
411
+ case null:
412
+ break;
413
+ case "Point":
414
+ if (t(
415
+ c,
416
+ f,
417
+ C,
418
+ v,
419
+ l
420
+ ) === !1)
421
+ return !1;
422
+ f++, v++;
423
+ break;
424
+ case "LineString":
425
+ case "MultiPoint":
426
+ for (n = 0; n < c.length; n++) {
427
+ if (t(
428
+ c[n],
429
+ f,
430
+ C,
431
+ v,
432
+ l
433
+ ) === !1)
434
+ return !1;
435
+ f++, g === "MultiPoint" && v++;
436
+ }
437
+ g === "LineString" && v++;
438
+ break;
439
+ case "Polygon":
440
+ case "MultiLineString":
441
+ for (n = 0; n < c.length; n++) {
442
+ for (r = 0; r < c[n].length - u; r++) {
443
+ if (t(
444
+ c[n][r],
445
+ f,
446
+ C,
447
+ v,
448
+ l
449
+ ) === !1)
450
+ return !1;
451
+ f++;
452
+ }
453
+ g === "MultiLineString" && v++, g === "Polygon" && l++;
454
+ }
455
+ g === "Polygon" && v++;
456
+ break;
457
+ case "MultiPolygon":
458
+ for (n = 0; n < c.length; n++) {
459
+ for (l = 0, r = 0; r < c[n].length; r++) {
460
+ for (i = 0; i < c[n][r].length - u; i++) {
461
+ if (t(
462
+ c[n][r][i],
463
+ f,
464
+ C,
465
+ v,
466
+ l
467
+ ) === !1)
468
+ return !1;
469
+ f++;
470
+ }
471
+ l++;
472
+ }
473
+ v++;
474
+ }
475
+ break;
476
+ case "GeometryCollection":
477
+ for (n = 0; n < s.geometries.length; n++)
478
+ if (rn(s.geometries[n], t, e) === !1)
479
+ return !1;
480
+ break;
481
+ default:
482
+ throw new Error("Unknown Geometry Type");
483
+ }
220
484
  }
221
- },
222
- type: "Feature"
223
- });
224
- }
225
- return o;
485
+ }
486
+ }
226
487
  }
227
- function bs(o) {
228
- const t = ["a", "b", "c", "a"].map(
229
- (n) => o.properties[n].geom
230
- ), e = o.geometry.coordinates[0], s = o.properties, i = {
231
- a: { geom: e[0], index: s.a.index },
232
- b: { geom: e[1], index: s.b.index },
233
- c: { geom: e[2], index: s.c.index }
234
- };
235
- return Ve([t], i);
236
- }
237
- function ys(o) {
238
- const t = [0, 1, 2, 0].map((s) => o[s][0][0]), e = {
239
- a: { geom: o[0][0][1], index: o[0][1] },
240
- b: { geom: o[1][0][1], index: o[1][1] },
241
- c: { geom: o[2][0][1], index: o[2][1] }
242
- };
243
- return Ve([t], e);
244
- }
245
- function Gt(o, t, e, s, i, n = !1, r) {
246
- const a = o.map(
247
- (f) => {
248
- (!r || r < 2.00703) && (f = We(f));
249
- const c = isFinite(f) ? t[f] : f === "c" ? s : f === "b0" ? i[0] : f === "b1" ? i[1] : f === "b2" ? i[2] : f === "b3" ? i[3] : function() {
250
- const u = f.match(/e(\d+)/);
251
- if (u) {
252
- const h = parseInt(u[1]);
253
- return e[h];
488
+ function hr(o, t = {}) {
489
+ let e = 0, n = 0, r = 0;
490
+ return rn(
491
+ o,
492
+ function(i) {
493
+ e += i[0], n += i[1], r++;
494
+ },
495
+ !0
496
+ ), de([e / r, n / r], t.properties);
497
+ }
498
+ var fr = hr;
499
+ function ur(o) {
500
+ return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
501
+ }
502
+ function lr(o) {
503
+ if (Object.prototype.hasOwnProperty.call(o, "__esModule")) return o;
504
+ var t = o.default;
505
+ if (typeof t == "function") {
506
+ var e = function n() {
507
+ var r = !1;
508
+ try {
509
+ r = this instanceof n;
510
+ } catch {
511
+ }
512
+ return r ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
513
+ };
514
+ e.prototype = t.prototype;
515
+ } else e = {};
516
+ return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(o).forEach(function(n) {
517
+ var r = Object.getOwnPropertyDescriptor(o, n);
518
+ Object.defineProperty(e, n, r.get ? r : {
519
+ enumerable: !0,
520
+ get: function() {
521
+ return o[n];
522
+ }
523
+ });
524
+ }), e;
525
+ }
526
+ var Oe = { exports: {} }, $e = { exports: {} }, pr = $e.exports, pn;
527
+ function dr() {
528
+ return pn || (pn = 1, (function(o, t) {
529
+ (function(e, n) {
530
+ o.exports = n();
531
+ })(pr, function() {
532
+ function e(m, v, l, g, x) {
533
+ (function A(I, b, T, R, D) {
534
+ for (; R > T; ) {
535
+ if (R - T > 600) {
536
+ var Q = R - T + 1, p = b - T + 1, M = Math.log(Q), _ = 0.5 * Math.exp(2 * M / 3), B = 0.5 * Math.sqrt(M * _ * (Q - _) / Q) * (p - Q / 2 < 0 ? -1 : 1), N = Math.max(T, Math.floor(b - p * _ / Q + B)), Y = Math.min(R, Math.floor(b + (Q - p) * _ / Q + B));
537
+ A(I, b, N, Y, D);
538
+ }
539
+ var w = I[b], O = T, $ = R;
540
+ for (n(I, T, b), D(I[R], w) > 0 && n(I, T, R); O < $; ) {
541
+ for (n(I, O, $), O++, $--; D(I[O], w) < 0; ) O++;
542
+ for (; D(I[$], w) > 0; ) $--;
543
+ }
544
+ D(I[T], w) === 0 ? n(I, T, $) : n(I, ++$, R), $ <= b && (T = $ + 1), b <= $ && (R = $ - 1);
545
+ }
546
+ })(m, v, l || 0, g || m.length - 1, x || r);
547
+ }
548
+ function n(m, v, l) {
549
+ var g = m[v];
550
+ m[v] = m[l], m[l] = g;
551
+ }
552
+ function r(m, v) {
553
+ return m < v ? -1 : m > v ? 1 : 0;
554
+ }
555
+ var i = function(m) {
556
+ m === void 0 && (m = 9), this._maxEntries = Math.max(4, m), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
557
+ };
558
+ function s(m, v, l) {
559
+ if (!l) return v.indexOf(m);
560
+ for (var g = 0; g < v.length; g++) if (l(m, v[g])) return g;
561
+ return -1;
562
+ }
563
+ function a(m, v) {
564
+ c(m, 0, m.children.length, v, m);
565
+ }
566
+ function c(m, v, l, g, x) {
567
+ x || (x = X(null)), x.minX = 1 / 0, x.minY = 1 / 0, x.maxX = -1 / 0, x.maxY = -1 / 0;
568
+ for (var A = v; A < l; A++) {
569
+ var I = m.children[A];
570
+ h(x, m.leaf ? g(I) : I);
571
+ }
572
+ return x;
573
+ }
574
+ function h(m, v) {
575
+ 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;
576
+ }
577
+ function u(m, v) {
578
+ return m.minX - v.minX;
579
+ }
580
+ function f(m, v) {
581
+ return m.minY - v.minY;
582
+ }
583
+ function d(m) {
584
+ return (m.maxX - m.minX) * (m.maxY - m.minY);
585
+ }
586
+ function y(m) {
587
+ return m.maxX - m.minX + (m.maxY - m.minY);
588
+ }
589
+ function E(m, v) {
590
+ return m.minX <= v.minX && m.minY <= v.minY && v.maxX <= m.maxX && v.maxY <= m.maxY;
591
+ }
592
+ function k(m, v) {
593
+ return v.minX <= m.maxX && v.minY <= m.maxY && v.maxX >= m.minX && v.maxY >= m.minY;
594
+ }
595
+ function X(m) {
596
+ return { children: m, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
597
+ }
598
+ function C(m, v, l, g, x) {
599
+ for (var A = [v, l]; A.length; ) if (!((l = A.pop()) - (v = A.pop()) <= g)) {
600
+ var I = v + Math.ceil((l - v) / g / 2) * g;
601
+ e(m, I, v, l, x), A.push(v, I, I, l);
602
+ }
603
+ }
604
+ return i.prototype.all = function() {
605
+ return this._all(this.data, []);
606
+ }, i.prototype.search = function(m) {
607
+ var v = this.data, l = [];
608
+ if (!k(m, v)) return l;
609
+ for (var g = this.toBBox, x = []; v; ) {
610
+ for (var A = 0; A < v.children.length; A++) {
611
+ var I = v.children[A], b = v.leaf ? g(I) : I;
612
+ k(m, b) && (v.leaf ? l.push(I) : E(m, b) ? this._all(I, l) : x.push(I));
613
+ }
614
+ v = x.pop();
254
615
  }
255
- throw "Bad index value for indexesToTri";
256
- }();
257
- return n ? [[c[1], c[0]], f] : [[c[0], c[1]], f];
616
+ return l;
617
+ }, i.prototype.collides = function(m) {
618
+ var v = this.data;
619
+ if (!k(m, v)) return !1;
620
+ for (var l = []; v; ) {
621
+ for (var g = 0; g < v.children.length; g++) {
622
+ var x = v.children[g], A = v.leaf ? this.toBBox(x) : x;
623
+ if (k(m, A)) {
624
+ if (v.leaf || E(m, A)) return !0;
625
+ l.push(x);
626
+ }
627
+ }
628
+ v = l.pop();
629
+ }
630
+ return !1;
631
+ }, i.prototype.load = function(m) {
632
+ if (!m || !m.length) return this;
633
+ if (m.length < this._minEntries) {
634
+ for (var v = 0; v < m.length; v++) this.insert(m[v]);
635
+ return this;
636
+ }
637
+ var l = this._build(m.slice(), 0, m.length - 1, 0);
638
+ if (this.data.children.length) if (this.data.height === l.height) this._splitRoot(this.data, l);
639
+ else {
640
+ if (this.data.height < l.height) {
641
+ var g = this.data;
642
+ this.data = l, l = g;
643
+ }
644
+ this._insert(l, this.data.height - l.height - 1, !0);
645
+ }
646
+ else this.data = l;
647
+ return this;
648
+ }, i.prototype.insert = function(m) {
649
+ return m && this._insert(m, this.data.height - 1), this;
650
+ }, i.prototype.clear = function() {
651
+ return this.data = X([]), this;
652
+ }, i.prototype.remove = function(m, v) {
653
+ if (!m) return this;
654
+ for (var l, g, x, A = this.data, I = this.toBBox(m), b = [], T = []; A || b.length; ) {
655
+ if (A || (A = b.pop(), g = b[b.length - 1], l = T.pop(), x = !0), A.leaf) {
656
+ var R = s(m, A.children, v);
657
+ if (R !== -1) return A.children.splice(R, 1), b.push(A), this._condense(b), this;
658
+ }
659
+ x || A.leaf || !E(A, I) ? g ? (l++, A = g.children[l], x = !1) : A = null : (b.push(A), T.push(l), l = 0, g = A, A = A.children[0]);
660
+ }
661
+ return this;
662
+ }, i.prototype.toBBox = function(m) {
663
+ return m;
664
+ }, i.prototype.compareMinX = function(m, v) {
665
+ return m.minX - v.minX;
666
+ }, i.prototype.compareMinY = function(m, v) {
667
+ return m.minY - v.minY;
668
+ }, i.prototype.toJSON = function() {
669
+ return this.data;
670
+ }, i.prototype.fromJSON = function(m) {
671
+ return this.data = m, this;
672
+ }, i.prototype._all = function(m, v) {
673
+ for (var l = []; m; ) m.leaf ? v.push.apply(v, m.children) : l.push.apply(l, m.children), m = l.pop();
674
+ return v;
675
+ }, i.prototype._build = function(m, v, l, g) {
676
+ var x, A = l - v + 1, I = this._maxEntries;
677
+ if (A <= I) return a(x = X(m.slice(v, l + 1)), this.toBBox), x;
678
+ g || (g = Math.ceil(Math.log(A) / Math.log(I)), I = Math.ceil(A / Math.pow(I, g - 1))), (x = X([])).leaf = !1, x.height = g;
679
+ var b = Math.ceil(A / I), T = b * Math.ceil(Math.sqrt(I));
680
+ C(m, v, l, T, this.compareMinX);
681
+ for (var R = v; R <= l; R += T) {
682
+ var D = Math.min(R + T - 1, l);
683
+ C(m, R, D, b, this.compareMinY);
684
+ for (var Q = R; Q <= D; Q += b) {
685
+ var p = Math.min(Q + b - 1, D);
686
+ x.children.push(this._build(m, Q, p, g - 1));
687
+ }
688
+ }
689
+ return a(x, this.toBBox), x;
690
+ }, i.prototype._chooseSubtree = function(m, v, l, g) {
691
+ for (; g.push(v), !v.leaf && g.length - 1 !== l; ) {
692
+ for (var x = 1 / 0, A = 1 / 0, I = void 0, b = 0; b < v.children.length; b++) {
693
+ var T = v.children[b], R = d(T), D = (Q = m, p = T, (Math.max(p.maxX, Q.maxX) - Math.min(p.minX, Q.minX)) * (Math.max(p.maxY, Q.maxY) - Math.min(p.minY, Q.minY)) - R);
694
+ D < A ? (A = D, x = R < x ? R : x, I = T) : D === A && R < x && (x = R, I = T);
695
+ }
696
+ v = I || v.children[0];
697
+ }
698
+ var Q, p;
699
+ return v;
700
+ }, i.prototype._insert = function(m, v, l) {
701
+ var g = l ? m : this.toBBox(m), x = [], A = this._chooseSubtree(g, this.data, v, x);
702
+ for (A.children.push(m), h(A, g); v >= 0 && x[v].children.length > this._maxEntries; ) this._split(x, v), v--;
703
+ this._adjustParentBBoxes(g, x, v);
704
+ }, i.prototype._split = function(m, v) {
705
+ var l = m[v], g = l.children.length, x = this._minEntries;
706
+ this._chooseSplitAxis(l, x, g);
707
+ var A = this._chooseSplitIndex(l, x, g), I = X(l.children.splice(A, l.children.length - A));
708
+ I.height = l.height, I.leaf = l.leaf, a(l, this.toBBox), a(I, this.toBBox), v ? m[v - 1].children.push(I) : this._splitRoot(l, I);
709
+ }, i.prototype._splitRoot = function(m, v) {
710
+ this.data = X([m, v]), this.data.height = m.height + 1, this.data.leaf = !1, a(this.data, this.toBBox);
711
+ }, i.prototype._chooseSplitIndex = function(m, v, l) {
712
+ for (var g, x, A, I, b, T, R, D = 1 / 0, Q = 1 / 0, p = v; p <= l - v; p++) {
713
+ var M = c(m, 0, p, this.toBBox), _ = c(m, p, l, this.toBBox), B = (x = M, A = _, I = void 0, b = void 0, T = void 0, R = void 0, I = Math.max(x.minX, A.minX), b = Math.max(x.minY, A.minY), T = Math.min(x.maxX, A.maxX), R = Math.min(x.maxY, A.maxY), Math.max(0, T - I) * Math.max(0, R - b)), N = d(M) + d(_);
714
+ B < D ? (D = B, g = p, Q = N < Q ? N : Q) : B === D && N < Q && (Q = N, g = p);
715
+ }
716
+ return g || l - v;
717
+ }, i.prototype._chooseSplitAxis = function(m, v, l) {
718
+ var g = m.leaf ? this.compareMinX : u, x = m.leaf ? this.compareMinY : f;
719
+ this._allDistMargin(m, v, l, g) < this._allDistMargin(m, v, l, x) && m.children.sort(g);
720
+ }, i.prototype._allDistMargin = function(m, v, l, g) {
721
+ m.children.sort(g);
722
+ for (var x = this.toBBox, A = c(m, 0, v, x), I = c(m, l - v, l, x), b = y(A) + y(I), T = v; T < l - v; T++) {
723
+ var R = m.children[T];
724
+ h(A, m.leaf ? x(R) : R), b += y(A);
725
+ }
726
+ for (var D = l - v - 1; D >= v; D--) {
727
+ var Q = m.children[D];
728
+ h(I, m.leaf ? x(Q) : Q), b += y(I);
729
+ }
730
+ return b;
731
+ }, i.prototype._adjustParentBBoxes = function(m, v, l) {
732
+ for (var g = l; g >= 0; g--) h(v[g], m);
733
+ }, i.prototype._condense = function(m) {
734
+ for (var v = m.length - 1, l = void 0; v >= 0; v--) m[v].children.length === 0 ? v > 0 ? (l = m[v - 1].children).splice(l.indexOf(m[v]), 1) : this.clear() : a(m[v], this.toBBox);
735
+ }, i;
736
+ });
737
+ })($e)), $e.exports;
738
+ }
739
+ let mr = class {
740
+ constructor(t = [], e = gr) {
741
+ if (this.data = t, this.length = this.data.length, this.compare = e, this.length > 0)
742
+ for (let n = (this.length >> 1) - 1; n >= 0; n--) this._down(n);
743
+ }
744
+ push(t) {
745
+ this.data.push(t), this.length++, this._up(this.length - 1);
746
+ }
747
+ pop() {
748
+ if (this.length === 0) return;
749
+ const t = this.data[0], e = this.data.pop();
750
+ return this.length--, this.length > 0 && (this.data[0] = e, this._down(0)), t;
751
+ }
752
+ peek() {
753
+ return this.data[0];
754
+ }
755
+ _up(t) {
756
+ const { data: e, compare: n } = this, r = e[t];
757
+ for (; t > 0; ) {
758
+ const i = t - 1 >> 1, s = e[i];
759
+ if (n(r, s) >= 0) break;
760
+ e[t] = s, t = i;
258
761
  }
259
- );
260
- return ys(a);
261
- }
262
- function We(o) {
263
- return typeof o == "number" ? o : o.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
264
- }
265
- function ze(o, t) {
266
- return t && t >= 2.00703 || Array.isArray(o[0]) ? o : o.map((e) => [
267
- e.illstNodes,
268
- e.mercNodes,
269
- e.startEnd
270
- ]);
271
- }
272
- function Oe(o, t) {
273
- for (let e = 0; e < t.features.length; e++)
274
- if (pe(o, t.features[e]))
275
- return t.features[e];
276
- }
277
- function Xe(o, t, e) {
278
- const s = t.geometry.coordinates[0][0], i = t.geometry.coordinates[0][1], n = t.geometry.coordinates[0][2], r = o.geometry.coordinates, a = t.properties.a.geom, f = t.properties.b.geom, c = t.properties.c.geom, u = [i[0] - s[0], i[1] - s[1]], h = [n[0] - s[0], n[1] - s[1]], l = [r[0] - s[0], r[1] - s[1]], p = [f[0] - a[0], f[1] - a[1]], y = [c[0] - a[0], c[1] - a[1]];
279
- let g = (h[1] * l[0] - h[0] * l[1]) / (u[0] * h[1] - u[1] * h[0]), b = (u[0] * l[1] - u[1] * l[0]) / (u[0] * h[1] - u[1] * h[0]);
280
- if (e) {
281
- const w = e[t.properties.a.index], S = e[t.properties.b.index], _ = e[t.properties.c.index];
282
- let v;
283
- if (g < 0 || b < 0 || 1 - g - b < 0) {
284
- const T = g / (g + b), I = b / (g + b);
285
- v = g / S / (T / S + I / _), b = b / _ / (T / S + I / _);
286
- } else
287
- v = g / S / (g / S + b / _ + (1 - g - b) / w), b = b / _ / (g / S + b / _ + (1 - g - b) / w);
288
- g = v;
762
+ e[t] = r;
763
+ }
764
+ _down(t) {
765
+ const { data: e, compare: n } = this, r = this.length >> 1, i = e[t];
766
+ for (; t < r; ) {
767
+ let s = (t << 1) + 1, a = e[s];
768
+ const c = s + 1;
769
+ if (c < this.length && n(e[c], a) < 0 && (s = c, a = e[c]), n(a, i) >= 0) break;
770
+ e[t] = a, t = s;
771
+ }
772
+ e[t] = i;
289
773
  }
290
- return [
291
- g * p[0] + b * y[0] + a[0],
292
- g * p[1] + b * y[1] + a[1]
293
- ];
294
- }
295
- function ks(o, t, e, s) {
296
- const i = o.geometry.coordinates, n = e.geometry.coordinates, r = Math.atan2(i[0] - n[0], i[1] - n[1]), a = xs(r, t[0]);
297
- if (a === void 0)
298
- throw new Error("Unable to determine vertex index");
299
- const f = t[1][a];
300
- return Xe(o, f.features[0], s);
301
- }
302
- function re(o, t, e, s, i, n, r, a) {
303
- let f;
304
- if (r && (f = Oe(o, Lt([r]))), !f) {
305
- if (e) {
306
- const c = o.geometry.coordinates, u = e.gridNum, h = e.xOrigin, l = e.yOrigin, p = e.xUnit, y = e.yUnit, g = e.gridCache, b = At(c[0], h, p, u), w = At(c[1], l, y, u), S = g[b] ? g[b][w] ? g[b][w] : [] : [];
307
- t = Lt(S.map((_) => t.features[_]));
774
+ };
775
+ function gr(o, t) {
776
+ return o < t ? -1 : o > t ? 1 : 0;
777
+ }
778
+ const wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
779
+ __proto__: null,
780
+ default: mr
781
+ }, Symbol.toStringTag, { value: "Module" })), yr = /* @__PURE__ */ lr(wr);
782
+ var be = { exports: {} }, Ze, dn;
783
+ function vr() {
784
+ return dn || (dn = 1, Ze = function(t, e, n, r) {
785
+ var i = t[0], s = t[1], a = !1;
786
+ n === void 0 && (n = 0), r === void 0 && (r = e.length);
787
+ for (var c = (r - n) / 2, h = 0, u = c - 1; h < c; u = h++) {
788
+ var f = e[n + h * 2 + 0], d = e[n + h * 2 + 1], y = e[n + u * 2 + 0], E = e[n + u * 2 + 1], k = d > s != E > s && i < (y - f) * (s - d) / (E - d) + f;
789
+ k && (a = !a);
308
790
  }
309
- f = Oe(o, t);
310
- }
311
- return a && a(f), f ? Xe(o, f, n) : ks(o, s, i, n);
312
- }
313
- function At(o, t, e, s) {
314
- let i = Math.floor((o - t) / e);
315
- return i >= s && (i = s - 1), i;
316
- }
317
- function xs(o, t) {
318
- let e = Te(o - t[0]), s = Math.PI * 2, i;
319
- for (let n = 0; n < t.length; n++) {
320
- const r = (n + 1) % t.length, a = Te(o - t[r]), f = Math.min(Math.abs(e), Math.abs(a));
321
- e * a <= 0 && f < s && (s = f, i = n), e = a;
322
- }
323
- return i;
324
- }
325
- function Te(o, t = !1) {
326
- const e = t ? function(s) {
327
- return !(s >= 0 && s < Math.PI * 2);
328
- } : function(s) {
329
- return !(s > -1 * Math.PI && s <= Math.PI);
330
- };
331
- for (; e(o); )
332
- o = o + 2 * Math.PI * (o > 0 ? -1 : 1);
333
- return o;
334
- }
335
- const we = 2.00703, kt = class xt {
336
- constructor() {
337
- nt(this, "points", []), nt(this, "pointsWeightBuffer"), nt(this, "strict_status"), nt(this, "vertices_params"), nt(this, "centroid"), nt(this, "edgeNodes"), nt(this, "edges"), nt(this, "tins"), nt(this, "kinks"), nt(this, "yaxisMode", xt.YAXIS_INVERT), nt(this, "strictMode", xt.MODE_AUTO), nt(this, "vertexMode", xt.VERTEX_PLAIN), nt(this, "bounds"), nt(this, "boundsPolygon"), nt(this, "wh"), nt(this, "xy"), nt(this, "indexedTins"), nt(this, "stateFull", !1), nt(this, "stateTriangle"), nt(this, "stateBackward");
791
+ return a;
792
+ }), Ze;
793
+ }
794
+ var tn, mn;
795
+ function br() {
796
+ return mn || (mn = 1, tn = function(t, e, n, r) {
797
+ var i = t[0], s = t[1], a = !1;
798
+ n === void 0 && (n = 0), r === void 0 && (r = e.length);
799
+ for (var c = r - n, h = 0, u = c - 1; h < c; u = h++) {
800
+ var f = e[h + n][0], d = e[h + n][1], y = e[u + n][0], E = e[u + n][1], k = d > s != E > s && i < (y - f) * (s - d) / (E - d) + f;
801
+ k && (a = !a);
802
+ }
803
+ return a;
804
+ }), tn;
805
+ }
806
+ var gn;
807
+ function _r() {
808
+ if (gn) return be.exports;
809
+ gn = 1;
810
+ var o = vr(), t = br();
811
+ return be.exports = function(n, r, i, s) {
812
+ return r.length > 0 && Array.isArray(r[0]) ? t(n, r, i, s) : o(n, r, i, s);
813
+ }, be.exports.nested = t, be.exports.flat = o, be.exports;
814
+ }
815
+ var xe = { exports: {} }, xr = xe.exports, wn;
816
+ function Mr() {
817
+ return wn || (wn = 1, (function(o, t) {
818
+ (function(e, n) {
819
+ n(t);
820
+ })(xr, function(e) {
821
+ const r = 33306690738754706e-32;
822
+ function i(k, X, C, m, v) {
823
+ let l, g, x, A, I = X[0], b = m[0], T = 0, R = 0;
824
+ b > I == b > -I ? (l = I, I = X[++T]) : (l = b, b = m[++R]);
825
+ let D = 0;
826
+ if (T < k && R < C) for (b > I == b > -I ? (x = l - ((g = I + l) - I), I = X[++T]) : (x = l - ((g = b + l) - b), b = m[++R]), l = g, x !== 0 && (v[D++] = x); T < k && R < C; ) b > I == b > -I ? (x = l - ((g = l + I) - (A = g - l)) + (I - A), I = X[++T]) : (x = l - ((g = l + b) - (A = g - l)) + (b - A), b = m[++R]), l = g, x !== 0 && (v[D++] = x);
827
+ for (; T < k; ) x = l - ((g = l + I) - (A = g - l)) + (I - A), I = X[++T], l = g, x !== 0 && (v[D++] = x);
828
+ for (; R < C; ) x = l - ((g = l + b) - (A = g - l)) + (b - A), b = m[++R], l = g, x !== 0 && (v[D++] = x);
829
+ return l === 0 && D !== 0 || (v[D++] = l), D;
830
+ }
831
+ function s(k) {
832
+ return new Float64Array(k);
833
+ }
834
+ const a = 33306690738754716e-32, c = 22204460492503146e-32, h = 11093356479670487e-47, u = s(4), f = s(8), d = s(12), y = s(16), E = s(4);
835
+ e.orient2d = function(k, X, C, m, v, l) {
836
+ const g = (X - l) * (C - v), x = (k - v) * (m - l), A = g - x;
837
+ if (g === 0 || x === 0 || g > 0 != x > 0) return A;
838
+ const I = Math.abs(g + x);
839
+ return Math.abs(A) >= a * I ? A : -(function(b, T, R, D, Q, p, M) {
840
+ let _, B, N, Y, w, O, $, q, V, z, K, j, ct, ht, lt, dt, gt, mt;
841
+ const Pt = b - Q, Tt = R - Q, xt = T - p, Mt = D - p;
842
+ w = (lt = (q = Pt - ($ = (O = 134217729 * Pt) - (O - Pt))) * (z = Mt - (V = (O = 134217729 * Mt) - (O - Mt))) - ((ht = Pt * Mt) - $ * V - q * V - $ * z)) - (K = lt - (gt = (q = xt - ($ = (O = 134217729 * xt) - (O - xt))) * (z = Tt - (V = (O = 134217729 * Tt) - (O - Tt))) - ((dt = xt * Tt) - $ * V - q * V - $ * z))), u[0] = lt - (K + w) + (w - gt), w = (ct = ht - ((j = ht + K) - (w = j - ht)) + (K - w)) - (K = ct - dt), u[1] = ct - (K + w) + (w - dt), w = (mt = j + K) - j, u[2] = j - (mt - w) + (K - w), u[3] = mt;
843
+ let Gt = (function(S, P) {
844
+ let F = P[0];
845
+ for (let L = 1; L < S; L++) F += P[L];
846
+ return F;
847
+ })(4, u), ce = c * M;
848
+ if (Gt >= ce || -Gt >= ce || (_ = b - (Pt + (w = b - Pt)) + (w - Q), N = R - (Tt + (w = R - Tt)) + (w - Q), B = T - (xt + (w = T - xt)) + (w - p), Y = D - (Mt + (w = D - Mt)) + (w - p), _ === 0 && B === 0 && N === 0 && Y === 0) || (ce = h * M + r * Math.abs(Gt), (Gt += Pt * Y + Mt * _ - (xt * N + Tt * B)) >= ce || -Gt >= ce)) return Gt;
849
+ w = (lt = (q = _ - ($ = (O = 134217729 * _) - (O - _))) * (z = Mt - (V = (O = 134217729 * Mt) - (O - Mt))) - ((ht = _ * Mt) - $ * V - q * V - $ * z)) - (K = lt - (gt = (q = B - ($ = (O = 134217729 * B) - (O - B))) * (z = Tt - (V = (O = 134217729 * Tt) - (O - Tt))) - ((dt = B * Tt) - $ * V - q * V - $ * z))), E[0] = lt - (K + w) + (w - gt), w = (ct = ht - ((j = ht + K) - (w = j - ht)) + (K - w)) - (K = ct - dt), E[1] = ct - (K + w) + (w - dt), w = (mt = j + K) - j, E[2] = j - (mt - w) + (K - w), E[3] = mt;
850
+ const je = i(4, u, 4, E, f);
851
+ w = (lt = (q = Pt - ($ = (O = 134217729 * Pt) - (O - Pt))) * (z = Y - (V = (O = 134217729 * Y) - (O - Y))) - ((ht = Pt * Y) - $ * V - q * V - $ * z)) - (K = lt - (gt = (q = xt - ($ = (O = 134217729 * xt) - (O - xt))) * (z = N - (V = (O = 134217729 * N) - (O - N))) - ((dt = xt * N) - $ * V - q * V - $ * z))), E[0] = lt - (K + w) + (w - gt), w = (ct = ht - ((j = ht + K) - (w = j - ht)) + (K - w)) - (K = ct - dt), E[1] = ct - (K + w) + (w - dt), w = (mt = j + K) - j, E[2] = j - (mt - w) + (K - w), E[3] = mt;
852
+ const ze = i(je, f, 4, E, d);
853
+ w = (lt = (q = _ - ($ = (O = 134217729 * _) - (O - _))) * (z = Y - (V = (O = 134217729 * Y) - (O - Y))) - ((ht = _ * Y) - $ * V - q * V - $ * z)) - (K = lt - (gt = (q = B - ($ = (O = 134217729 * B) - (O - B))) * (z = N - (V = (O = 134217729 * N) - (O - N))) - ((dt = B * N) - $ * V - q * V - $ * z))), E[0] = lt - (K + w) + (w - gt), w = (ct = ht - ((j = ht + K) - (w = j - ht)) + (K - w)) - (K = ct - dt), E[1] = ct - (K + w) + (w - dt), w = (mt = j + K) - j, E[2] = j - (mt - w) + (K - w), E[3] = mt;
854
+ const qt = i(ze, d, 4, E, y);
855
+ return y[qt - 1];
856
+ })(k, X, C, m, v, l, I);
857
+ }, e.orient2dfast = function(k, X, C, m, v, l) {
858
+ return (X - l) * (C - v) - (k - v) * (m - l);
859
+ }, Object.defineProperty(e, "__esModule", { value: !0 });
860
+ });
861
+ })(xe, xe.exports)), xe.exports;
862
+ }
863
+ var yn;
864
+ function kr() {
865
+ if (yn) return Oe.exports;
866
+ yn = 1;
867
+ var o = dr(), t = yr, e = _r(), n = Mr().orient2d;
868
+ t.default && (t = t.default), Oe.exports = r, Oe.exports.default = r;
869
+ function r(l, g, x) {
870
+ g = Math.max(0, g === void 0 ? 2 : g), x = x || 0;
871
+ var A = y(l), I = new o(16);
872
+ I.toBBox = function($) {
873
+ return {
874
+ minX: $[0],
875
+ minY: $[1],
876
+ maxX: $[0],
877
+ maxY: $[1]
878
+ };
879
+ }, I.compareMinX = function($, q) {
880
+ return $[0] - q[0];
881
+ }, I.compareMinY = function($, q) {
882
+ return $[1] - q[1];
883
+ }, I.load(l);
884
+ for (var b = [], T = 0, R; T < A.length; T++) {
885
+ var D = A[T];
886
+ I.remove(D), R = E(D, R), b.push(R);
887
+ }
888
+ var Q = new o(16);
889
+ for (T = 0; T < b.length; T++) Q.insert(d(b[T]));
890
+ for (var p = g * g, M = x * x; b.length; ) {
891
+ var _ = b.shift(), B = _.p, N = _.next.p, Y = k(B, N);
892
+ if (!(Y < M)) {
893
+ var w = Y / p;
894
+ D = i(I, _.prev.p, B, N, _.next.next.p, w, Q), D && Math.min(k(D, B), k(D, N)) <= w && (b.push(_), b.push(E(D, _)), I.remove(D), Q.remove(_), Q.insert(d(_)), Q.insert(d(_.next)));
895
+ }
896
+ }
897
+ _ = R;
898
+ var O = [];
899
+ do
900
+ O.push(_.p), _ = _.next;
901
+ while (_ !== R);
902
+ return O.push(_.p), O;
903
+ }
904
+ function i(l, g, x, A, I, b, T) {
905
+ for (var R = new t([], s), D = l.data; D; ) {
906
+ for (var Q = 0; Q < D.children.length; Q++) {
907
+ var p = D.children[Q], M = D.leaf ? X(p, x, A) : a(x, A, p);
908
+ M > b || R.push({
909
+ node: p,
910
+ dist: M
911
+ });
912
+ }
913
+ for (; R.length && !R.peek().node.children; ) {
914
+ var _ = R.pop(), B = _.node, N = X(B, g, x), Y = X(B, A, I);
915
+ if (_.dist < N && _.dist < Y && h(x, B, T) && h(A, B, T)) return B;
916
+ }
917
+ D = R.pop(), D && (D = D.node);
918
+ }
919
+ return null;
920
+ }
921
+ function s(l, g) {
922
+ return l.dist - g.dist;
923
+ }
924
+ function a(l, g, x) {
925
+ if (c(l, x) || c(g, x)) return 0;
926
+ var A = C(l[0], l[1], g[0], g[1], x.minX, x.minY, x.maxX, x.minY);
927
+ if (A === 0) return 0;
928
+ var I = C(l[0], l[1], g[0], g[1], x.minX, x.minY, x.minX, x.maxY);
929
+ if (I === 0) return 0;
930
+ var b = C(l[0], l[1], g[0], g[1], x.maxX, x.minY, x.maxX, x.maxY);
931
+ if (b === 0) return 0;
932
+ var T = C(l[0], l[1], g[0], g[1], x.minX, x.maxY, x.maxX, x.maxY);
933
+ return T === 0 ? 0 : Math.min(A, I, b, T);
934
+ }
935
+ function c(l, g) {
936
+ return l[0] >= g.minX && l[0] <= g.maxX && l[1] >= g.minY && l[1] <= g.maxY;
937
+ }
938
+ function h(l, g, x) {
939
+ for (var A = Math.min(l[0], g[0]), I = Math.min(l[1], g[1]), b = Math.max(l[0], g[0]), T = Math.max(l[1], g[1]), R = x.search({ minX: A, minY: I, maxX: b, maxY: T }), D = 0; D < R.length; D++)
940
+ if (f(R[D].p, R[D].next.p, l, g)) return !1;
941
+ return !0;
942
+ }
943
+ function u(l, g, x) {
944
+ return n(l[0], l[1], g[0], g[1], x[0], x[1]);
945
+ }
946
+ function f(l, g, x, A) {
947
+ return l !== A && g !== x && u(l, g, x) > 0 != u(l, g, A) > 0 && u(x, A, l) > 0 != u(x, A, g) > 0;
948
+ }
949
+ function d(l) {
950
+ var g = l.p, x = l.next.p;
951
+ return l.minX = Math.min(g[0], x[0]), l.minY = Math.min(g[1], x[1]), l.maxX = Math.max(g[0], x[0]), l.maxY = Math.max(g[1], x[1]), l;
952
+ }
953
+ function y(l) {
954
+ for (var g = l[0], x = l[0], A = l[0], I = l[0], b = 0; b < l.length; b++) {
955
+ var T = l[b];
956
+ T[0] < g[0] && (g = T), T[0] > A[0] && (A = T), T[1] < x[1] && (x = T), T[1] > I[1] && (I = T);
957
+ }
958
+ var R = [g, x, A, I], D = R.slice();
959
+ for (b = 0; b < l.length; b++)
960
+ e(l[b], R) || D.push(l[b]);
961
+ return v(D);
962
+ }
963
+ function E(l, g) {
964
+ var x = {
965
+ p: l,
966
+ prev: null,
967
+ next: null,
968
+ minX: 0,
969
+ minY: 0,
970
+ maxX: 0,
971
+ maxY: 0
972
+ };
973
+ return g ? (x.next = g.next, x.prev = g, g.next.prev = x, g.next = x) : (x.prev = x, x.next = x), x;
338
974
  }
339
- /**
340
- * コンパイルされた設定を適用します
341
- *
342
- * @param compiled - コンパイルされた設定オブジェクト
343
- * @returns 変換に必要な主要なオブジェクトのセット
344
- *
345
- * 以下の処理を行います:
346
- * 1. バージョンに応じた設定の解釈
347
- * 2. 各種パラメータの復元
348
- * 3. TINネットワークの再構築
349
- * 4. インデックスの作成
350
- */
351
- setCompiled(t) {
352
- if (t.version || !t.tins && t.points && t.tins_points) {
353
- this.points = t.points, this.pointsWeightBuffer = !t.version || t.version < 2.00703 ? ["forw", "bakw"].reduce((s, i) => {
354
- const n = t.weight_buffer[i];
355
- return n && (s[i] = Object.keys(n).reduce((r, a) => {
356
- const f = We(a);
357
- return r[f] = n[a], r;
358
- }, {})), s;
359
- }, {}) : t.weight_buffer, t.strict_status ? this.strict_status = t.strict_status : t.kinks_points ? this.strict_status = xt.STATUS_ERROR : t.tins_points.length == 2 ? this.strict_status = xt.STATUS_LOOSE : this.strict_status = xt.STATUS_STRICT, this.vertices_params = {
360
- forw: [t.vertices_params[0]],
361
- bakw: [t.vertices_params[1]]
362
- }, this.vertices_params.forw[1] = [0, 1, 2, 3].map((s) => {
363
- const i = (s + 1) % 4, n = Gt(
364
- ["c", `b${s}`, `b${i}`],
365
- t.points,
366
- t.edgeNodes || [],
367
- t.centroid_point,
368
- t.vertices_points,
369
- !1,
370
- we
371
- );
372
- return Lt([n]);
373
- }), this.vertices_params.bakw[1] = [0, 1, 2, 3].map((s) => {
374
- const i = (s + 1) % 4, n = Gt(
375
- ["c", `b${s}`, `b${i}`],
376
- t.points,
377
- t.edgeNodes || [],
378
- t.centroid_point,
379
- t.vertices_points,
380
- !0,
381
- we
382
- );
383
- return Lt([n]);
384
- }), this.centroid = {
385
- forw: Yt(t.centroid_point[0], {
386
- target: {
387
- geom: t.centroid_point[1],
388
- index: "c"
975
+ function k(l, g) {
976
+ var x = l[0] - g[0], A = l[1] - g[1];
977
+ return x * x + A * A;
978
+ }
979
+ function X(l, g, x) {
980
+ var A = g[0], I = g[1], b = x[0] - A, T = x[1] - I;
981
+ if (b !== 0 || T !== 0) {
982
+ var R = ((l[0] - A) * b + (l[1] - I) * T) / (b * b + T * T);
983
+ R > 1 ? (A = x[0], I = x[1]) : R > 0 && (A += b * R, I += T * R);
984
+ }
985
+ return b = l[0] - A, T = l[1] - I, b * b + T * T;
986
+ }
987
+ function C(l, g, x, A, I, b, T, R) {
988
+ var D = x - l, Q = A - g, p = T - I, M = R - b, _ = l - I, B = g - b, N = D * D + Q * Q, Y = D * p + Q * M, w = p * p + M * M, O = D * _ + Q * B, $ = p * _ + M * B, q = N * w - Y * Y, V, z, K, j, ct = q, ht = q;
989
+ q === 0 ? (z = 0, ct = 1, j = $, ht = w) : (z = Y * $ - w * O, j = N * $ - Y * O, z < 0 ? (z = 0, j = $, ht = w) : z > ct && (z = ct, j = $ + Y, ht = w)), j < 0 ? (j = 0, -O < 0 ? z = 0 : -O > N ? z = ct : (z = -O, ct = N)) : j > ht && (j = ht, -O + Y < 0 ? z = 0 : -O + Y > N ? z = ct : (z = -O + Y, ct = N)), V = z === 0 ? 0 : z / ct, K = j === 0 ? 0 : j / ht;
990
+ var lt = (1 - V) * l + V * x, dt = (1 - V) * g + V * A, gt = (1 - K) * I + K * T, mt = (1 - K) * b + K * R, Pt = gt - lt, Tt = mt - dt;
991
+ return Pt * Pt + Tt * Tt;
992
+ }
993
+ function m(l, g) {
994
+ return l[0] === g[0] ? l[1] - g[1] : l[0] - g[0];
995
+ }
996
+ function v(l) {
997
+ l.sort(m);
998
+ for (var g = [], x = 0; x < l.length; x++) {
999
+ for (; g.length >= 2 && u(g[g.length - 2], g[g.length - 1], l[x]) <= 0; )
1000
+ g.pop();
1001
+ g.push(l[x]);
1002
+ }
1003
+ for (var A = [], I = l.length - 1; I >= 0; I--) {
1004
+ for (; A.length >= 2 && u(A[A.length - 2], A[A.length - 1], l[I]) <= 0; )
1005
+ A.pop();
1006
+ A.push(l[I]);
1007
+ }
1008
+ return A.pop(), g.pop(), g.concat(A);
1009
+ }
1010
+ return Oe.exports;
1011
+ }
1012
+ var Sr = kr();
1013
+ const Er = /* @__PURE__ */ ur(Sr);
1014
+ function Ar(o, t = {}) {
1015
+ t.concavity = t.concavity || 1 / 0;
1016
+ const e = [];
1017
+ if (rn(o, (r) => {
1018
+ e.push([r[0], r[1]]);
1019
+ }), !e.length)
1020
+ return null;
1021
+ const n = Er(e, t.concavity);
1022
+ return n.length > 3 ? Ee([n]) : null;
1023
+ }
1024
+ var vn = Ar, Me = { exports: {} }, Pr = Me.exports, bn;
1025
+ function Br() {
1026
+ return bn || (bn = 1, (function(o, t) {
1027
+ (function(e, n) {
1028
+ n(t);
1029
+ })(Pr, function(e) {
1030
+ const n = 11102230246251565e-32, r = 134217729, i = (3 + 8 * n) * n;
1031
+ function s(S, P, F, L, tt) {
1032
+ let G, et, st, it, at = P[0], ft = L[0], J = 0, Z = 0;
1033
+ ft > at == ft > -at ? (G = at, at = P[++J]) : (G = ft, ft = L[++Z]);
1034
+ let ut = 0;
1035
+ if (J < S && Z < F) for (ft > at == ft > -at ? (et = at + G, st = G - (et - at), at = P[++J]) : (et = ft + G, st = G - (et - ft), ft = L[++Z]), G = et, st !== 0 && (tt[ut++] = st); J < S && Z < F; ) ft > at == ft > -at ? (et = G + at, it = et - G, st = G - (et - it) + (at - it), at = P[++J]) : (et = G + ft, it = et - G, st = G - (et - it) + (ft - it), ft = L[++Z]), G = et, st !== 0 && (tt[ut++] = st);
1036
+ for (; J < S; ) et = G + at, it = et - G, st = G - (et - it) + (at - it), at = P[++J], G = et, st !== 0 && (tt[ut++] = st);
1037
+ for (; Z < F; ) et = G + ft, it = et - G, st = G - (et - it) + (ft - it), ft = L[++Z], G = et, st !== 0 && (tt[ut++] = st);
1038
+ return (G !== 0 || ut === 0) && (tt[ut++] = G), ut;
1039
+ }
1040
+ function a(S, P) {
1041
+ let F = P[0];
1042
+ for (let L = 1; L < S; L++) F += P[L];
1043
+ return F;
1044
+ }
1045
+ function c(S) {
1046
+ return new Float64Array(S);
1047
+ }
1048
+ const h = (3 + 16 * n) * n, u = (2 + 12 * n) * n, f = (9 + 64 * n) * n * n, d = c(4), y = c(8), E = c(12), k = c(16), X = c(4);
1049
+ function C(S, P, F, L, tt, G, et) {
1050
+ let st, it, at, ft, J, Z, ut, _t, nt, H, W, wt, Et, At, Nt, yt, Bt, Rt;
1051
+ const zt = S - tt, Vt = F - tt, Wt = P - G, Jt = L - G;
1052
+ At = zt * Jt, Z = r * zt, ut = Z - (Z - zt), _t = zt - ut, Z = r * Jt, nt = Z - (Z - Jt), H = Jt - nt, Nt = _t * H - (At - ut * nt - _t * nt - ut * H), yt = Wt * Vt, Z = r * Wt, ut = Z - (Z - Wt), _t = Wt - ut, Z = r * Vt, nt = Z - (Z - Vt), H = Vt - nt, Bt = _t * H - (yt - ut * nt - _t * nt - ut * H), W = Nt - Bt, J = Nt - W, d[0] = Nt - (W + J) + (J - Bt), wt = At + W, J = wt - At, Et = At - (wt - J) + (W - J), W = Et - yt, J = Et - W, d[1] = Et - (W + J) + (J - yt), Rt = wt + W, J = Rt - wt, d[2] = wt - (Rt - J) + (W - J), d[3] = Rt;
1053
+ let he = a(4, d), ve = u * et;
1054
+ if (he >= ve || -he >= ve || (J = S - zt, st = S - (zt + J) + (J - tt), J = F - Vt, at = F - (Vt + J) + (J - tt), J = P - Wt, it = P - (Wt + J) + (J - G), J = L - Jt, ft = L - (Jt + J) + (J - G), st === 0 && it === 0 && at === 0 && ft === 0) || (ve = f * et + i * Math.abs(he), he += zt * ft + Jt * st - (Wt * at + Vt * it), he >= ve || -he >= ve)) return he;
1055
+ At = st * Jt, Z = r * st, ut = Z - (Z - st), _t = st - ut, Z = r * Jt, nt = Z - (Z - Jt), H = Jt - nt, Nt = _t * H - (At - ut * nt - _t * nt - ut * H), yt = it * Vt, Z = r * it, ut = Z - (Z - it), _t = it - ut, Z = r * Vt, nt = Z - (Z - Vt), H = Vt - nt, Bt = _t * H - (yt - ut * nt - _t * nt - ut * H), W = Nt - Bt, J = Nt - W, X[0] = Nt - (W + J) + (J - Bt), wt = At + W, J = wt - At, Et = At - (wt - J) + (W - J), W = Et - yt, J = Et - W, X[1] = Et - (W + J) + (J - yt), Rt = wt + W, J = Rt - wt, X[2] = wt - (Rt - J) + (W - J), X[3] = Rt;
1056
+ const zn = s(4, d, 4, X, y);
1057
+ At = zt * ft, Z = r * zt, ut = Z - (Z - zt), _t = zt - ut, Z = r * ft, nt = Z - (Z - ft), H = ft - nt, Nt = _t * H - (At - ut * nt - _t * nt - ut * H), yt = Wt * at, Z = r * Wt, ut = Z - (Z - Wt), _t = Wt - ut, Z = r * at, nt = Z - (Z - at), H = at - nt, Bt = _t * H - (yt - ut * nt - _t * nt - ut * H), W = Nt - Bt, J = Nt - W, X[0] = Nt - (W + J) + (J - Bt), wt = At + W, J = wt - At, Et = At - (wt - J) + (W - J), W = Et - yt, J = Et - W, X[1] = Et - (W + J) + (J - yt), Rt = wt + W, J = Rt - wt, X[2] = wt - (Rt - J) + (W - J), X[3] = Rt;
1058
+ const Vn = s(zn, y, 4, X, E);
1059
+ At = st * ft, Z = r * st, ut = Z - (Z - st), _t = st - ut, Z = r * ft, nt = Z - (Z - ft), H = ft - nt, Nt = _t * H - (At - ut * nt - _t * nt - ut * H), yt = it * at, Z = r * it, ut = Z - (Z - it), _t = it - ut, Z = r * at, nt = Z - (Z - at), H = at - nt, Bt = _t * H - (yt - ut * nt - _t * nt - ut * H), W = Nt - Bt, J = Nt - W, X[0] = Nt - (W + J) + (J - Bt), wt = At + W, J = wt - At, Et = At - (wt - J) + (W - J), W = Et - yt, J = Et - W, X[1] = Et - (W + J) + (J - yt), Rt = wt + W, J = Rt - wt, X[2] = wt - (Rt - J) + (W - J), X[3] = Rt;
1060
+ const Wn = s(Vn, E, 4, X, k);
1061
+ return k[Wn - 1];
1062
+ }
1063
+ function m(S, P, F, L, tt, G) {
1064
+ const et = (P - G) * (F - tt), st = (S - tt) * (L - G), it = et - st, at = Math.abs(et + st);
1065
+ return Math.abs(it) >= h * at ? it : -C(S, P, F, L, tt, G, at);
1066
+ }
1067
+ function v(S, P) {
1068
+ var F, L, tt = 0, G, et, st, it, at, ft, J, Z = S[0], ut = S[1], _t = P.length;
1069
+ for (F = 0; F < _t; F++) {
1070
+ L = 0;
1071
+ var nt = P[F], H = nt.length - 1;
1072
+ if (ft = nt[0], ft[0] !== nt[H][0] && ft[1] !== nt[H][1]) throw new Error("First and last coordinates in a ring must be the same");
1073
+ for (et = ft[0] - Z, st = ft[1] - ut, L; L < H; L++) {
1074
+ if (J = nt[L + 1], it = J[0] - Z, at = J[1] - ut, st === 0 && at === 0) {
1075
+ if (it <= 0 && et >= 0 || et <= 0 && it >= 0) return 0;
1076
+ } else if (at >= 0 && st <= 0 || at <= 0 && st >= 0) {
1077
+ if (G = m(et, it, st, at, 0, 0), G === 0) return 0;
1078
+ (G > 0 && at > 0 && st <= 0 || G < 0 && at <= 0 && st > 0) && tt++;
1079
+ }
1080
+ ft = J, st = at, et = it;
389
1081
  }
390
- }),
391
- bakw: Yt(t.centroid_point[1], {
392
- target: {
393
- geom: t.centroid_point[0],
394
- index: "c"
1082
+ }
1083
+ return tt % 2 !== 0;
1084
+ }
1085
+ function l(S, P, F = {}) {
1086
+ const L = { type: "Feature" };
1087
+ return (F.id === 0 || F.id) && (L.id = F.id), F.bbox && (L.bbox = F.bbox), L.properties = P || {}, L.geometry = S, L;
1088
+ }
1089
+ function g(S, P, F = {}) {
1090
+ if (!S) throw new Error("coordinates is required");
1091
+ if (!Array.isArray(S)) throw new Error("coordinates must be an Array");
1092
+ if (S.length < 2) throw new Error("coordinates must be at least 2 numbers long");
1093
+ if (!I(S[0]) || !I(S[1])) throw new Error("coordinates must contain numbers");
1094
+ return l({ type: "Point", coordinates: S }, P, F);
1095
+ }
1096
+ function x(S, P, F = {}) {
1097
+ for (const L of S) {
1098
+ if (L.length < 4) throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
1099
+ if (L[L.length - 1].length !== L[0].length) throw new Error("First and last Position are not equivalent.");
1100
+ for (let tt = 0; tt < L[L.length - 1].length; tt++) if (L[L.length - 1][tt] !== L[0][tt]) throw new Error("First and last Position are not equivalent.");
1101
+ }
1102
+ return l({ type: "Polygon", coordinates: S }, P, F);
1103
+ }
1104
+ function A(S, P = {}) {
1105
+ const F = { type: "FeatureCollection" };
1106
+ return P.id && (F.id = P.id), P.bbox && (F.bbox = P.bbox), F.features = S, F;
1107
+ }
1108
+ function I(S) {
1109
+ return !isNaN(S) && S !== null && !Array.isArray(S);
1110
+ }
1111
+ function b(S) {
1112
+ if (!S) throw new Error("coord is required");
1113
+ if (!Array.isArray(S)) {
1114
+ if (S.type === "Feature" && S.geometry !== null && S.geometry.type === "Point") return [...S.geometry.coordinates];
1115
+ if (S.type === "Point") return [...S.coordinates];
1116
+ }
1117
+ if (Array.isArray(S) && S.length >= 2 && !Array.isArray(S[0]) && !Array.isArray(S[1])) return [...S];
1118
+ throw new Error("coord must be GeoJSON Point or an Array of numbers");
1119
+ }
1120
+ function T(S) {
1121
+ if (Array.isArray(S)) return S;
1122
+ if (S.type === "Feature") {
1123
+ if (S.geometry !== null) return S.geometry.coordinates;
1124
+ } else if (S.coordinates) return S.coordinates;
1125
+ throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array");
1126
+ }
1127
+ function R(S) {
1128
+ return S.type === "Feature" ? S.geometry : S;
1129
+ }
1130
+ function D(S, P, F = {}) {
1131
+ if (!S) throw new Error("point is required");
1132
+ if (!P) throw new Error("polygon is required");
1133
+ const L = b(S), tt = R(P), G = tt.type, et = P.bbox;
1134
+ let st = tt.coordinates;
1135
+ if (et && Q(L, et) === !1) return !1;
1136
+ G === "Polygon" && (st = [st]);
1137
+ let it = !1;
1138
+ for (var at = 0; at < st.length; ++at) {
1139
+ const ft = v(L, st[at]);
1140
+ if (ft === 0) return !F.ignoreBoundary;
1141
+ ft && (it = !0);
1142
+ }
1143
+ return it;
1144
+ }
1145
+ function Q(S, P) {
1146
+ return P[0] <= S[0] && P[1] <= S[1] && P[2] >= S[0] && P[3] >= S[1];
1147
+ }
1148
+ var p = D;
1149
+ function M(S, P) {
1150
+ for (let F = 0; F < P.features.length; F++) if (p(S, P.features[F])) return P.features[F];
1151
+ }
1152
+ function _(S, P, F) {
1153
+ const L = P.geometry.coordinates[0][0], tt = P.geometry.coordinates[0][1], G = P.geometry.coordinates[0][2], et = S.geometry.coordinates, st = P.properties.a.geom, it = P.properties.b.geom, at = P.properties.c.geom, ft = [tt[0] - L[0], tt[1] - L[1]], J = [G[0] - L[0], G[1] - L[1]], Z = [et[0] - L[0], et[1] - L[1]], ut = [it[0] - st[0], it[1] - st[1]], _t = [at[0] - st[0], at[1] - st[1]];
1154
+ let nt = (J[1] * Z[0] - J[0] * Z[1]) / (ft[0] * J[1] - ft[1] * J[0]), H = (ft[0] * Z[1] - ft[1] * Z[0]) / (ft[0] * J[1] - ft[1] * J[0]);
1155
+ if (F) {
1156
+ const W = F[P.properties.a.index], wt = F[P.properties.b.index], Et = F[P.properties.c.index];
1157
+ let At;
1158
+ if (nt < 0 || H < 0 || 1 - nt - H < 0) {
1159
+ const Nt = nt / (nt + H), yt = H / (nt + H);
1160
+ At = nt / wt / (Nt / wt + yt / Et), H = H / Et / (Nt / wt + yt / Et);
1161
+ } else At = nt / wt / (nt / wt + H / Et + (1 - nt - H) / W), H = H / Et / (nt / wt + H / Et + (1 - nt - H) / W);
1162
+ nt = At;
1163
+ }
1164
+ return [nt * ut[0] + H * _t[0] + st[0], nt * ut[1] + H * _t[1] + st[1]];
1165
+ }
1166
+ function B(S, P, F, L) {
1167
+ const tt = S.geometry.coordinates, G = F.geometry.coordinates, et = Math.atan2(tt[0] - G[0], tt[1] - G[1]), st = w(et, P[0]);
1168
+ if (st === void 0) throw new Error("Unable to determine vertex index");
1169
+ const it = P[1][st];
1170
+ return _(S, it.features[0], L);
1171
+ }
1172
+ function N(S, P, F, L, tt, G, et, st) {
1173
+ let it;
1174
+ if (et && (it = M(S, A([et]))), !it) {
1175
+ if (F) {
1176
+ const at = S.geometry.coordinates, ft = F.gridNum, J = F.xOrigin, Z = F.yOrigin, ut = F.xUnit, _t = F.yUnit, nt = F.gridCache, H = Y(at[0], J, ut, ft), W = Y(at[1], Z, _t, ft), wt = nt[H] ? nt[H][W] ? nt[H][W] : [] : [];
1177
+ P = A(wt.map((Et) => P.features[Et]));
395
1178
  }
396
- })
397
- }, this.edges = ze(t.edges || []), this.edgeNodes = t.edgeNodes || [];
398
- const e = t.tins_points.length == 1 ? 0 : 1;
399
- this.tins = {
400
- forw: Lt(
401
- t.tins_points[0].map(
402
- (s) => Gt(
403
- s,
404
- t.points,
405
- t.edgeNodes || [],
406
- t.centroid_point,
407
- t.vertices_points,
408
- !1,
409
- t.version
410
- )
411
- )
412
- ),
413
- bakw: Lt(
414
- t.tins_points[e].map(
415
- (s) => Gt(
416
- s,
417
- t.points,
418
- t.edgeNodes || [],
419
- t.centroid_point,
420
- t.vertices_points,
421
- !0,
422
- t.version
423
- )
424
- )
425
- )
426
- }, this.addIndexedTin(), t.kinks_points && (this.kinks = {
427
- bakw: Lt(
428
- t.kinks_points.map((s) => Yt(s))
429
- )
430
- }), t.yaxisMode ? this.yaxisMode = t.yaxisMode : this.yaxisMode = xt.YAXIS_INVERT, t.vertexMode && (this.vertexMode = t.vertexMode), t.strictMode && (this.strictMode = t.strictMode), t.bounds ? (this.bounds = t.bounds, this.boundsPolygon = t.boundsPolygon, this.xy = t.xy, this.wh = t.wh) : (this.xy = [0, 0], t.wh && (this.wh = t.wh), this.bounds = void 0, this.boundsPolygon = void 0);
431
- } else {
432
- t = JSON.parse(
433
- JSON.stringify(t).replace('"cent"', '"c"').replace(/"bbox(\d+)"/g, '"b$1"')
434
- ), this.tins = t.tins, this.addIndexedTin(), this.strict_status = t.strict_status, this.pointsWeightBuffer = t.weight_buffer, this.vertices_params = t.vertices_params, this.centroid = t.centroid, this.kinks = t.kinks;
435
- const e = [];
436
- for (let s = 0; s < this.tins.forw.features.length; s++) {
437
- const i = this.tins.forw.features[s];
438
- ["a", "b", "c"].map((n, r) => {
439
- const a = i.geometry.coordinates[0][r], f = i.properties[n].geom, c = i.properties[n].index;
440
- typeof c == "number" && (e[c] = [a, f]);
1179
+ it = M(S, P);
1180
+ }
1181
+ return st && st(it), it ? _(S, it, G) : B(S, L, tt, G);
1182
+ }
1183
+ function Y(S, P, F, L) {
1184
+ let tt = Math.floor((S - P) / F);
1185
+ return tt >= L && (tt = L - 1), tt;
1186
+ }
1187
+ function w(S, P) {
1188
+ let F = O(S - P[0]), L = Math.PI * 2, tt;
1189
+ for (let G = 0; G < P.length; G++) {
1190
+ const et = (G + 1) % P.length, st = O(S - P[et]), it = Math.min(Math.abs(F), Math.abs(st));
1191
+ F * st <= 0 && it < L && (L = it, tt = G), F = st;
1192
+ }
1193
+ return tt;
1194
+ }
1195
+ function O(S, P = !1) {
1196
+ const F = P ? function(L) {
1197
+ return !(L >= 0 && L < Math.PI * 2);
1198
+ } : function(L) {
1199
+ return !(L > -1 * Math.PI && L <= Math.PI);
1200
+ };
1201
+ for (; F(S); ) S = S + 2 * Math.PI * (S > 0 ? -1 : 1);
1202
+ return S;
1203
+ }
1204
+ function $(S, P) {
1205
+ return P && P >= 2.00703 || Array.isArray(S[0]) ? S : S.map((F) => [F.illstNodes, F.mercNodes, F.startEnd]);
1206
+ }
1207
+ function q(S) {
1208
+ const P = S.features;
1209
+ for (let F = 0; F < P.length; F++) {
1210
+ const L = P[F];
1211
+ `${L.properties.a.index}`.substring(0, 1) === "b" && `${L.properties.b.index}`.substring(0, 1) === "b" ? P[F] = { geometry: { type: "Polygon", coordinates: [[L.geometry.coordinates[0][2], L.geometry.coordinates[0][0], L.geometry.coordinates[0][1], L.geometry.coordinates[0][2]]] }, properties: { a: { geom: L.properties.c.geom, index: L.properties.c.index }, b: { geom: L.properties.a.geom, index: L.properties.a.index }, c: { geom: L.properties.b.geom, index: L.properties.b.index } }, type: "Feature" } : `${L.properties.c.index}`.substring(0, 1) === "b" && `${L.properties.a.index}`.substring(0, 1) === "b" && (P[F] = { geometry: { type: "Polygon", coordinates: [[L.geometry.coordinates[0][1], L.geometry.coordinates[0][2], L.geometry.coordinates[0][0], L.geometry.coordinates[0][1]]] }, properties: { a: { geom: L.properties.b.geom, index: L.properties.b.index }, b: { geom: L.properties.c.geom, index: L.properties.c.index }, c: { geom: L.properties.a.geom, index: L.properties.a.index } }, type: "Feature" });
1212
+ }
1213
+ return S;
1214
+ }
1215
+ function V(S) {
1216
+ const P = ["a", "b", "c", "a"].map((G) => S.properties[G].geom), F = S.geometry.coordinates[0], L = S.properties, tt = { a: { geom: F[0], index: L.a.index }, b: { geom: F[1], index: L.b.index }, c: { geom: F[2], index: L.c.index } };
1217
+ return x([P], tt);
1218
+ }
1219
+ function z(S) {
1220
+ const P = [0, 1, 2, 0].map((L) => S[L][0][0]), F = { a: { geom: S[0][0][1], index: S[0][1] }, b: { geom: S[1][0][1], index: S[1][1] }, c: { geom: S[2][0][1], index: S[2][1] } };
1221
+ return x([P], F);
1222
+ }
1223
+ function K(S, P, F, L, tt, G = !1, et) {
1224
+ const st = S.map((it) => {
1225
+ (!et || et < 2.00703) && (it = j(it));
1226
+ const at = isFinite(it) ? P[it] : it === "c" ? L : it === "b0" ? tt[0] : it === "b1" ? tt[1] : it === "b2" ? tt[2] : it === "b3" ? tt[3] : (function() {
1227
+ const ft = it.match(/e(\d+)/);
1228
+ if (ft) {
1229
+ const J = parseInt(ft[1]);
1230
+ return F[J];
1231
+ }
1232
+ throw "Bad index value for indexesToTri";
1233
+ })();
1234
+ return G ? [[at[1], at[0]], it] : [[at[0], at[1]], it];
441
1235
  });
1236
+ return z(st);
1237
+ }
1238
+ function j(S) {
1239
+ return typeof S == "number" ? S : S.replace(/^(c|e|b)(?:ent|dgeNode|box)(\d+)?$/, "$1$2");
1240
+ }
1241
+ const ct = 2.00703;
1242
+ function ht(S) {
1243
+ return !!(S.version || !S.tins && S.points && S.tins_points);
1244
+ }
1245
+ function lt(S) {
1246
+ return { points: S.points, pointsWeightBuffer: gt(S), strictStatus: mt(S), verticesParams: Pt(S), centroid: xt(S), edges: $(S.edges || []), edgeNodes: S.edgeNodes || [], tins: Mt(S), kinks: Gt(S.kinks_points), yaxisMode: S.yaxisMode ?? "invert", strictMode: S.strictMode ?? "auto", vertexMode: S.vertexMode, bounds: S.bounds, boundsPolygon: S.boundsPolygon, wh: S.wh, xy: S.bounds ? S.xy : [0, 0] };
1247
+ }
1248
+ function dt(S) {
1249
+ const P = ce(S), F = P.tins;
1250
+ return { compiled: P, tins: F, points: je(F), strictStatus: P.strict_status, pointsWeightBuffer: P.weight_buffer, verticesParams: P.vertices_params, centroid: P.centroid, kinks: P.kinks };
1251
+ }
1252
+ function gt(S) {
1253
+ return !S.version || S.version < ct ? ["forw", "bakw"].reduce((P, F) => {
1254
+ const L = S.weight_buffer[F];
1255
+ return L && (P[F] = Object.keys(L).reduce((tt, G) => {
1256
+ const et = j(G);
1257
+ return tt[et] = L[G], tt;
1258
+ }, {})), P;
1259
+ }, {}) : S.weight_buffer;
1260
+ }
1261
+ function mt(S) {
1262
+ return S.strict_status ? S.strict_status : S.kinks_points ? "strict_error" : S.tins_points.length === 2 ? "loose" : "strict";
1263
+ }
1264
+ function Pt(S) {
1265
+ const P = { forw: [S.vertices_params[0]], bakw: [S.vertices_params[1]] };
1266
+ return P.forw[1] = Tt(S, !1), P.bakw[1] = Tt(S, !0), P;
1267
+ }
1268
+ function Tt(S, P) {
1269
+ return [0, 1, 2, 3].map((F) => {
1270
+ const L = (F + 1) % 4, tt = K(["c", `b${F}`, `b${L}`], S.points, S.edgeNodes || [], S.centroid_point, S.vertices_points, P, ct);
1271
+ return A([tt]);
1272
+ });
1273
+ }
1274
+ function xt(S) {
1275
+ return { forw: g(S.centroid_point[0], { target: { geom: S.centroid_point[1], index: "c" } }), bakw: g(S.centroid_point[1], { target: { geom: S.centroid_point[0], index: "c" } }) };
442
1276
  }
443
- this.points = e;
1277
+ function Mt(S) {
1278
+ const P = S.tins_points.length === 1 ? 0 : 1;
1279
+ return { forw: A(S.tins_points[0].map((F) => K(F, S.points, S.edgeNodes || [], S.centroid_point, S.vertices_points, !1, S.version))), bakw: A(S.tins_points[P].map((F) => K(F, S.points, S.edgeNodes || [], S.centroid_point, S.vertices_points, !0, S.version))) };
1280
+ }
1281
+ function Gt(S) {
1282
+ if (S) return { bakw: A(S.map((P) => g(P))) };
1283
+ }
1284
+ function ce(S) {
1285
+ return JSON.parse(JSON.stringify(S).replace('"cent"', '"c"').replace(/"bbox(\d+)"/g, '"b$1"'));
1286
+ }
1287
+ function je(S) {
1288
+ const P = [], F = S.forw.features;
1289
+ for (let L = 0; L < F.length; L++) {
1290
+ const tt = F[L];
1291
+ ["a", "b", "c"].map((G, et) => {
1292
+ const st = tt.geometry.coordinates[0][et], it = tt.properties[G].geom, at = tt.properties[G].index;
1293
+ typeof at == "number" && (P[at] = [st, it]);
1294
+ });
1295
+ }
1296
+ return P;
1297
+ }
1298
+ const ze = ct;
1299
+ class qt {
1300
+ static VERTEX_PLAIN = "plain";
1301
+ static VERTEX_BIRDEYE = "birdeye";
1302
+ static MODE_STRICT = "strict";
1303
+ static MODE_AUTO = "auto";
1304
+ static MODE_LOOSE = "loose";
1305
+ static STATUS_STRICT = "strict";
1306
+ static STATUS_ERROR = "strict_error";
1307
+ static STATUS_LOOSE = "loose";
1308
+ static YAXIS_FOLLOW = "follow";
1309
+ static YAXIS_INVERT = "invert";
1310
+ points = [];
1311
+ pointsWeightBuffer;
1312
+ strict_status;
1313
+ vertices_params;
1314
+ centroid;
1315
+ edgeNodes;
1316
+ edges;
1317
+ tins;
1318
+ kinks;
1319
+ yaxisMode = qt.YAXIS_INVERT;
1320
+ strictMode = qt.MODE_AUTO;
1321
+ vertexMode = qt.VERTEX_PLAIN;
1322
+ bounds;
1323
+ boundsPolygon;
1324
+ wh;
1325
+ xy;
1326
+ indexedTins;
1327
+ stateFull = !1;
1328
+ stateTriangle;
1329
+ stateBackward;
1330
+ constructor() {
1331
+ }
1332
+ setCompiled(P) {
1333
+ if (ht(P)) {
1334
+ this.applyModernState(lt(P));
1335
+ return;
1336
+ }
1337
+ this.applyLegacyState(dt(P));
1338
+ }
1339
+ applyModernState(P) {
1340
+ this.points = P.points, this.pointsWeightBuffer = P.pointsWeightBuffer, this.strict_status = P.strictStatus, this.vertices_params = P.verticesParams, this.centroid = P.centroid, this.edges = P.edges, this.edgeNodes = P.edgeNodes || [], this.tins = P.tins, this.addIndexedTin(), this.kinks = P.kinks, this.yaxisMode = P.yaxisMode ?? qt.YAXIS_INVERT, this.vertexMode = P.vertexMode ?? qt.VERTEX_PLAIN, this.strictMode = P.strictMode ?? qt.MODE_AUTO, P.bounds ? (this.bounds = P.bounds, this.boundsPolygon = P.boundsPolygon, this.xy = P.xy, this.wh = P.wh) : (this.bounds = void 0, this.boundsPolygon = void 0, this.xy = P.xy ?? [0, 0], P.wh && (this.wh = P.wh));
1341
+ }
1342
+ applyLegacyState(P) {
1343
+ this.tins = P.tins, this.addIndexedTin(), this.strict_status = P.strictStatus, this.pointsWeightBuffer = P.pointsWeightBuffer, this.vertices_params = P.verticesParams, this.centroid = P.centroid, this.kinks = P.kinks, this.points = P.points;
1344
+ }
1345
+ addIndexedTin() {
1346
+ const P = this.tins, F = P.forw, L = P.bakw, tt = Math.ceil(Math.sqrt(F.features.length));
1347
+ if (tt < 3) {
1348
+ this.indexedTins = void 0;
1349
+ return;
1350
+ }
1351
+ let G = [], et = [];
1352
+ const st = F.features.map((nt) => {
1353
+ let H = [];
1354
+ return T(nt)[0].map((W) => {
1355
+ G.length === 0 ? G = [Array.from(W), Array.from(W)] : (W[0] < G[0][0] && (G[0][0] = W[0]), W[0] > G[1][0] && (G[1][0] = W[0]), W[1] < G[0][1] && (G[0][1] = W[1]), W[1] > G[1][1] && (G[1][1] = W[1])), H.length === 0 ? H = [Array.from(W), Array.from(W)] : (W[0] < H[0][0] && (H[0][0] = W[0]), W[0] > H[1][0] && (H[1][0] = W[0]), W[1] < H[0][1] && (H[0][1] = W[1]), W[1] > H[1][1] && (H[1][1] = W[1]));
1356
+ }), H;
1357
+ }), it = (G[1][0] - G[0][0]) / tt, at = (G[1][1] - G[0][1]) / tt, ft = st.reduce((nt, H, W) => {
1358
+ const wt = Y(H[0][0], G[0][0], it, tt), Et = Y(H[1][0], G[0][0], it, tt), At = Y(H[0][1], G[0][1], at, tt), Nt = Y(H[1][1], G[0][1], at, tt);
1359
+ for (let yt = wt; yt <= Et; yt++) {
1360
+ nt[yt] || (nt[yt] = []);
1361
+ for (let Bt = At; Bt <= Nt; Bt++) nt[yt][Bt] || (nt[yt][Bt] = []), nt[yt][Bt].push(W);
1362
+ }
1363
+ return nt;
1364
+ }, []), J = L.features.map((nt) => {
1365
+ let H = [];
1366
+ return T(nt)[0].map((W) => {
1367
+ et.length === 0 ? et = [Array.from(W), Array.from(W)] : (W[0] < et[0][0] && (et[0][0] = W[0]), W[0] > et[1][0] && (et[1][0] = W[0]), W[1] < et[0][1] && (et[0][1] = W[1]), W[1] > et[1][1] && (et[1][1] = W[1])), H.length === 0 ? H = [Array.from(W), Array.from(W)] : (W[0] < H[0][0] && (H[0][0] = W[0]), W[0] > H[1][0] && (H[1][0] = W[0]), W[1] < H[0][1] && (H[0][1] = W[1]), W[1] > H[1][1] && (H[1][1] = W[1]));
1368
+ }), H;
1369
+ }), Z = (et[1][0] - et[0][0]) / tt, ut = (et[1][1] - et[0][1]) / tt, _t = J.reduce((nt, H, W) => {
1370
+ const wt = Y(H[0][0], et[0][0], Z, tt), Et = Y(H[1][0], et[0][0], Z, tt), At = Y(H[0][1], et[0][1], ut, tt), Nt = Y(H[1][1], et[0][1], ut, tt);
1371
+ for (let yt = wt; yt <= Et; yt++) {
1372
+ nt[yt] || (nt[yt] = []);
1373
+ for (let Bt = At; Bt <= Nt; Bt++) nt[yt][Bt] || (nt[yt][Bt] = []), nt[yt][Bt].push(W);
1374
+ }
1375
+ return nt;
1376
+ }, []);
1377
+ this.indexedTins = { forw: { gridNum: tt, xOrigin: G[0][0], yOrigin: G[0][1], xUnit: it, yUnit: at, gridCache: ft }, bakw: { gridNum: tt, xOrigin: et[0][0], yOrigin: et[0][1], xUnit: Z, yUnit: ut, gridCache: _t } };
1378
+ }
1379
+ transform(P, F, L) {
1380
+ if (F && this.strict_status == qt.STATUS_ERROR) throw 'Backward transform is not allowed if strict_status == "strict_error"';
1381
+ this.yaxisMode == qt.YAXIS_FOLLOW && F && (P = [P[0], -1 * P[1]]);
1382
+ const tt = g(P);
1383
+ if (this.bounds && !F && !L && !p(tt, this.boundsPolygon)) return !1;
1384
+ const G = F ? this.tins.bakw : this.tins.forw, et = F ? this.indexedTins.bakw : this.indexedTins.forw, st = F ? this.vertices_params.bakw : this.vertices_params.forw, it = F ? this.centroid.bakw : this.centroid.forw, at = F ? this.pointsWeightBuffer.bakw : this.pointsWeightBuffer.forw;
1385
+ let ft, J;
1386
+ this.stateFull && (this.stateBackward == F ? ft = this.stateTriangle : (this.stateBackward = F, this.stateTriangle = void 0), J = (ut) => {
1387
+ this.stateTriangle = ut;
1388
+ });
1389
+ let Z = N(tt, G, et, st, it, at, ft, J);
1390
+ if (this.bounds && F && !L) {
1391
+ const ut = g(Z);
1392
+ if (!p(ut, this.boundsPolygon)) return !1;
1393
+ } else this.yaxisMode == qt.YAXIS_FOLLOW && !F && (Z = [Z[0], -1 * Z[1]]);
1394
+ return Z;
1395
+ }
1396
+ }
1397
+ e.Transform = qt, e.counterTri = V, e.format_version = ze, e.normalizeEdges = $, e.rotateVerticesTriangle = q, e.transformArr = N, Object.defineProperty(e, Symbol.toStringTag, { value: "Module" });
1398
+ });
1399
+ })(Me, Me.exports)), Me.exports;
1400
+ }
1401
+ var jt = Br();
1402
+ const _n = Math.pow(2, -52), Ie = new Uint32Array(512);
1403
+ class sn {
1404
+ static from(t, e = Xr, n = Yr) {
1405
+ const r = t.length, i = new Float64Array(r * 2);
1406
+ for (let s = 0; s < r; s++) {
1407
+ const a = t[s];
1408
+ i[2 * s] = e(a), i[2 * s + 1] = n(a);
444
1409
  }
1410
+ return new sn(i);
445
1411
  }
446
- /**
447
- * TINネットワークのインデックスを作成します
448
- *
449
- * インデックスは変換処理を高速化するために使用されます。
450
- * グリッド形式のインデックスを作成し、各グリッドに
451
- * 含まれる三角形を記録します。
452
- */
453
- addIndexedTin() {
454
- const t = this.tins, e = t.forw, s = t.bakw, i = Math.ceil(Math.sqrt(e.features.length));
455
- if (i < 3) {
456
- this.indexedTins = void 0;
1412
+ constructor(t) {
1413
+ const e = t.length >> 1;
1414
+ if (e > 0 && typeof t[0] != "number") throw new Error("Expected coords to contain numbers.");
1415
+ this.coords = t;
1416
+ const n = Math.max(2 * e - 5, 0);
1417
+ this._triangles = new Uint32Array(n * 3), this._halfedges = new Int32Array(n * 3), this._hashSize = Math.ceil(Math.sqrt(e)), this._hullPrev = new Uint32Array(e), this._hullNext = new Uint32Array(e), this._hullTri = new Uint32Array(e), this._hullHash = new Int32Array(this._hashSize), this._ids = new Uint32Array(e), this._dists = new Float64Array(e), this.update();
1418
+ }
1419
+ update() {
1420
+ const { coords: t, _hullPrev: e, _hullNext: n, _hullTri: r, _hullHash: i } = this, s = t.length >> 1;
1421
+ let a = 1 / 0, c = 1 / 0, h = -1 / 0, u = -1 / 0;
1422
+ for (let b = 0; b < s; b++) {
1423
+ const T = t[2 * b], R = t[2 * b + 1];
1424
+ T < a && (a = T), R < c && (c = R), T > h && (h = T), R > u && (u = R), this._ids[b] = b;
1425
+ }
1426
+ const f = (a + h) / 2, d = (c + u) / 2;
1427
+ let y, E, k;
1428
+ for (let b = 0, T = 1 / 0; b < s; b++) {
1429
+ const R = en(f, d, t[2 * b], t[2 * b + 1]);
1430
+ R < T && (y = b, T = R);
1431
+ }
1432
+ const X = t[2 * y], C = t[2 * y + 1];
1433
+ for (let b = 0, T = 1 / 0; b < s; b++) {
1434
+ if (b === y) continue;
1435
+ const R = en(X, C, t[2 * b], t[2 * b + 1]);
1436
+ R < T && R > 0 && (E = b, T = R);
1437
+ }
1438
+ let m = t[2 * E], v = t[2 * E + 1], l = 1 / 0;
1439
+ for (let b = 0; b < s; b++) {
1440
+ if (b === y || b === E) continue;
1441
+ const T = Tr(X, C, m, v, t[2 * b], t[2 * b + 1]);
1442
+ T < l && (k = b, l = T);
1443
+ }
1444
+ let g = t[2 * k], x = t[2 * k + 1];
1445
+ if (l === 1 / 0) {
1446
+ for (let R = 0; R < s; R++)
1447
+ this._dists[R] = t[2 * R] - t[0] || t[2 * R + 1] - t[1];
1448
+ we(this._ids, this._dists, 0, s - 1);
1449
+ const b = new Uint32Array(s);
1450
+ let T = 0;
1451
+ for (let R = 0, D = -1 / 0; R < s; R++) {
1452
+ const Q = this._ids[R], p = this._dists[Q];
1453
+ p > D && (b[T++] = Q, D = p);
1454
+ }
1455
+ this.hull = b.subarray(0, T), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
457
1456
  return;
458
1457
  }
459
- let n = [], r = [];
460
- const a = e.features.map((g) => {
461
- let b = [];
462
- return Ee(g)[0].map((w) => {
463
- n.length === 0 ? n = [Array.from(w), Array.from(w)] : (w[0] < n[0][0] && (n[0][0] = w[0]), w[0] > n[1][0] && (n[1][0] = w[0]), w[1] < n[0][1] && (n[0][1] = w[1]), w[1] > n[1][1] && (n[1][1] = w[1])), b.length === 0 ? b = [Array.from(w), Array.from(w)] : (w[0] < b[0][0] && (b[0][0] = w[0]), w[0] > b[1][0] && (b[1][0] = w[0]), w[1] < b[0][1] && (b[0][1] = w[1]), w[1] > b[1][1] && (b[1][1] = w[1]));
464
- }), b;
465
- }), f = (n[1][0] - n[0][0]) / i, c = (n[1][1] - n[0][1]) / i, u = a.reduce(
466
- (g, b, w) => {
467
- const S = At(
468
- b[0][0],
469
- n[0][0],
470
- f,
471
- i
472
- ), _ = At(
473
- b[1][0],
474
- n[0][0],
475
- f,
476
- i
477
- ), v = At(
478
- b[0][1],
479
- n[0][1],
480
- c,
481
- i
482
- ), T = At(
483
- b[1][1],
484
- n[0][1],
485
- c,
486
- i
487
- );
488
- for (let I = S; I <= _; I++) {
489
- g[I] || (g[I] = []);
490
- for (let N = v; N <= T; N++)
491
- g[I][N] || (g[I][N] = []), g[I][N].push(w);
1458
+ if (te(X, C, m, v, g, x) < 0) {
1459
+ const b = E, T = m, R = v;
1460
+ E = k, m = g, v = x, k = b, g = T, x = R;
1461
+ }
1462
+ const A = Nr(X, C, m, v, g, x);
1463
+ this._cx = A.x, this._cy = A.y;
1464
+ for (let b = 0; b < s; b++)
1465
+ this._dists[b] = en(t[2 * b], t[2 * b + 1], A.x, A.y);
1466
+ we(this._ids, this._dists, 0, s - 1), this._hullStart = y;
1467
+ let I = 3;
1468
+ n[y] = e[k] = E, n[E] = e[y] = k, n[k] = e[E] = y, r[y] = 0, r[E] = 1, r[k] = 2, i.fill(-1), i[this._hashKey(X, C)] = y, i[this._hashKey(m, v)] = E, i[this._hashKey(g, x)] = k, this.trianglesLen = 0, this._addTriangle(y, E, k, -1, -1, -1);
1469
+ for (let b = 0, T, R; b < this._ids.length; b++) {
1470
+ const D = this._ids[b], Q = t[2 * D], p = t[2 * D + 1];
1471
+ if (b > 0 && Math.abs(Q - T) <= _n && Math.abs(p - R) <= _n || (T = Q, R = p, D === y || D === E || D === k)) continue;
1472
+ let M = 0;
1473
+ for (let w = 0, O = this._hashKey(Q, p); w < this._hashSize && (M = i[(O + w) % this._hashSize], !(M !== -1 && M !== n[M])); w++)
1474
+ ;
1475
+ M = e[M];
1476
+ let _ = M, B;
1477
+ for (; B = n[_], te(Q, p, t[2 * _], t[2 * _ + 1], t[2 * B], t[2 * B + 1]) >= 0; )
1478
+ if (_ = B, _ === M) {
1479
+ _ = -1;
1480
+ break;
492
1481
  }
493
- return g;
494
- },
495
- []
496
- ), h = s.features.map((g) => {
497
- let b = [];
498
- return Ee(g)[0].map((w) => {
499
- r.length === 0 ? r = [Array.from(w), Array.from(w)] : (w[0] < r[0][0] && (r[0][0] = w[0]), w[0] > r[1][0] && (r[1][0] = w[0]), w[1] < r[0][1] && (r[0][1] = w[1]), w[1] > r[1][1] && (r[1][1] = w[1])), b.length === 0 ? b = [Array.from(w), Array.from(w)] : (w[0] < b[0][0] && (b[0][0] = w[0]), w[0] > b[1][0] && (b[1][0] = w[0]), w[1] < b[0][1] && (b[0][1] = w[1]), w[1] > b[1][1] && (b[1][1] = w[1]));
500
- }), b;
501
- }), l = (r[1][0] - r[0][0]) / i, p = (r[1][1] - r[0][1]) / i, y = h.reduce(
502
- (g, b, w) => {
503
- const S = At(
504
- b[0][0],
505
- r[0][0],
506
- l,
507
- i
508
- ), _ = At(
509
- b[1][0],
510
- r[0][0],
511
- l,
512
- i
513
- ), v = At(
514
- b[0][1],
515
- r[0][1],
516
- p,
517
- i
518
- ), T = At(
519
- b[1][1],
520
- r[0][1],
521
- p,
522
- i
523
- );
524
- for (let I = S; I <= _; I++) {
525
- g[I] || (g[I] = []);
526
- for (let N = v; N <= T; N++)
527
- g[I][N] || (g[I][N] = []), g[I][N].push(w);
1482
+ if (_ === -1) continue;
1483
+ let N = this._addTriangle(_, D, n[_], -1, -1, r[_]);
1484
+ r[D] = this._legalize(N + 2), r[_] = N, I++;
1485
+ let Y = n[_];
1486
+ for (; B = n[Y], te(Q, p, t[2 * Y], t[2 * Y + 1], t[2 * B], t[2 * B + 1]) < 0; )
1487
+ N = this._addTriangle(Y, D, B, r[D], -1, r[Y]), r[D] = this._legalize(N + 2), n[Y] = Y, I--, Y = B;
1488
+ if (_ === M)
1489
+ for (; B = e[_], te(Q, p, t[2 * B], t[2 * B + 1], t[2 * _], t[2 * _ + 1]) < 0; )
1490
+ N = this._addTriangle(B, D, _, -1, r[_], r[B]), this._legalize(N + 2), r[B] = N, n[_] = _, I--, _ = B;
1491
+ this._hullStart = e[D] = _, n[_] = e[Y] = D, n[D] = Y, i[this._hashKey(Q, p)] = D, i[this._hashKey(t[2 * _], t[2 * _ + 1])] = _;
1492
+ }
1493
+ this.hull = new Uint32Array(I);
1494
+ for (let b = 0, T = this._hullStart; b < I; b++)
1495
+ this.hull[b] = T, T = n[T];
1496
+ this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
1497
+ }
1498
+ _hashKey(t, e) {
1499
+ return Math.floor(Or(t - this._cx, e - this._cy) * this._hashSize) % this._hashSize;
1500
+ }
1501
+ _legalize(t) {
1502
+ const { _triangles: e, _halfedges: n, coords: r } = this;
1503
+ let i = 0, s = 0;
1504
+ for (; ; ) {
1505
+ const a = n[t], c = t - t % 3;
1506
+ if (s = c + (t + 2) % 3, a === -1) {
1507
+ if (i === 0) break;
1508
+ t = Ie[--i];
1509
+ continue;
1510
+ }
1511
+ const h = a - a % 3, u = c + (t + 1) % 3, f = h + (a + 2) % 3, d = e[s], y = e[t], E = e[u], k = e[f];
1512
+ if (Ir(
1513
+ r[2 * d],
1514
+ r[2 * d + 1],
1515
+ r[2 * y],
1516
+ r[2 * y + 1],
1517
+ r[2 * E],
1518
+ r[2 * E + 1],
1519
+ r[2 * k],
1520
+ r[2 * k + 1]
1521
+ )) {
1522
+ e[t] = k, e[a] = d;
1523
+ const C = n[f];
1524
+ if (C === -1) {
1525
+ let v = this._hullStart;
1526
+ do {
1527
+ if (this._hullTri[v] === f) {
1528
+ this._hullTri[v] = t;
1529
+ break;
1530
+ }
1531
+ v = this._hullPrev[v];
1532
+ } while (v !== this._hullStart);
528
1533
  }
529
- return g;
530
- },
531
- []
532
- );
533
- this.indexedTins = {
534
- forw: {
535
- gridNum: i,
536
- xOrigin: n[0][0],
537
- yOrigin: n[0][1],
538
- xUnit: f,
539
- yUnit: c,
540
- gridCache: u
541
- },
542
- bakw: {
543
- gridNum: i,
544
- xOrigin: r[0][0],
545
- yOrigin: r[0][1],
546
- xUnit: l,
547
- yUnit: p,
548
- gridCache: y
1534
+ this._link(t, C), this._link(a, n[s]), this._link(s, f);
1535
+ const m = h + (a + 1) % 3;
1536
+ i < Ie.length && (Ie[i++] = m);
1537
+ } else {
1538
+ if (i === 0) break;
1539
+ t = Ie[--i];
549
1540
  }
550
- };
1541
+ }
1542
+ return s;
551
1543
  }
552
- /**
553
- * 座標変換を実行します
554
- *
555
- * @param apoint - 変換する座標
556
- * @param backward - 逆方向の変換かどうか
557
- * @param ignoreBounds - 境界チェックを無視するかどうか
558
- * @returns 変換後の座標、または境界外の場合はfalse
559
- *
560
- * @throws {Error} 逆方向変換が許可されていない状態での逆変換時
561
- */
562
- transform(t, e, s) {
563
- if (e && this.strict_status == xt.STATUS_ERROR)
564
- throw 'Backward transform is not allowed if strict_status == "strict_error"';
565
- this.yaxisMode == xt.YAXIS_FOLLOW && e && (t = [t[0], -1 * t[1]]);
566
- const i = Yt(t);
567
- if (this.bounds && !e && !s && !pe(i, this.boundsPolygon))
568
- return !1;
569
- const n = e ? this.tins.bakw : this.tins.forw, r = e ? this.indexedTins.bakw : this.indexedTins.forw, a = e ? this.vertices_params.bakw : this.vertices_params.forw, f = e ? this.centroid.bakw : this.centroid.forw, c = e ? this.pointsWeightBuffer.bakw : this.pointsWeightBuffer.forw;
570
- let u, h;
571
- this.stateFull && (this.stateBackward == e ? u = this.stateTriangle : (this.stateBackward = e, this.stateTriangle = void 0), h = (p) => {
572
- this.stateTriangle = p;
573
- });
574
- let l = re(
575
- i,
576
- n,
577
- r,
578
- a,
579
- f,
580
- c,
581
- u,
582
- h
583
- );
584
- if (this.bounds && e && !s) {
585
- const p = Yt(l);
586
- if (!pe(p, this.boundsPolygon)) return !1;
587
- } else this.yaxisMode == xt.YAXIS_FOLLOW && !e && (l = [l[0], -1 * l[1]]);
588
- return l;
1544
+ _link(t, e) {
1545
+ this._halfedges[t] = e, e !== -1 && (this._halfedges[e] = t);
1546
+ }
1547
+ // add a new triangle given vertex indices and adjacent half-edge ids
1548
+ _addTriangle(t, e, n, r, i, s) {
1549
+ const a = this.trianglesLen;
1550
+ return this._triangles[a] = t, this._triangles[a + 1] = e, this._triangles[a + 2] = n, this._link(a, r), this._link(a + 1, i), this._link(a + 2, s), this.trianglesLen += 3, a;
589
1551
  }
590
- };
591
- nt(kt, "VERTEX_PLAIN", "plain"), nt(kt, "VERTEX_BIRDEYE", "birdeye"), nt(kt, "MODE_STRICT", "strict"), nt(kt, "MODE_AUTO", "auto"), nt(kt, "MODE_LOOSE", "loose"), nt(kt, "STATUS_STRICT", "strict"), nt(kt, "STATUS_ERROR", "strict_error"), nt(kt, "STATUS_LOOSE", "loose"), nt(kt, "YAXIS_FOLLOW", "follow"), nt(kt, "YAXIS_INVERT", "invert");
592
- let _s = kt;
593
- const dt = 11102230246251565e-32, $ = 134217729, Ye = (3 + 8 * dt) * dt;
594
- function ct(o, t, e, s, i) {
595
- let n, r, a, f, c = t[0], u = s[0], h = 0, l = 0;
596
- u > c == u > -c ? (n = c, c = t[++h]) : (n = u, u = s[++l]);
597
- let p = 0;
598
- if (h < o && l < e)
599
- for (u > c == u > -c ? (r = c + n, a = n - (r - c), c = t[++h]) : (r = u + n, a = n - (r - u), u = s[++l]), n = r, a !== 0 && (i[p++] = a); h < o && l < e; )
600
- u > c == u > -c ? (r = n + c, f = r - n, a = n - (r - f) + (c - f), c = t[++h]) : (r = n + u, f = r - n, a = n - (r - f) + (u - f), u = s[++l]), n = r, a !== 0 && (i[p++] = a);
601
- for (; h < o; )
602
- r = n + c, f = r - n, a = n - (r - f) + (c - f), c = t[++h], n = r, a !== 0 && (i[p++] = a);
603
- for (; l < e; )
604
- r = n + u, f = r - n, a = n - (r - f) + (u - f), u = s[++l], n = r, a !== 0 && (i[p++] = a);
605
- return (n !== 0 || p === 0) && (i[p++] = n), p;
606
- }
607
- function yt(o, t, e, s, i, n, r, a) {
608
- return ct(ct(o, t, e, s, r), r, i, n, a);
609
- }
610
- function M(o, t, e, s) {
611
- let i, n, r, a, f, c, u, h, l, p, y;
612
- u = $ * e, p = u - (u - e), y = e - p;
613
- let g = t[0];
614
- i = g * e, u = $ * g, h = u - (u - g), l = g - h, r = l * y - (i - h * p - l * p - h * y);
615
- let b = 0;
616
- r !== 0 && (s[b++] = r);
617
- for (let w = 1; w < o; w++)
618
- g = t[w], a = g * e, u = $ * g, h = u - (u - g), l = g - h, f = l * y - (a - h * p - l * p - h * y), n = i + f, c = n - i, r = i - (n - c) + (f - c), r !== 0 && (s[b++] = r), i = a + n, r = n - (i - a), r !== 0 && (s[b++] = r);
619
- return (i !== 0 || b === 0) && (s[b++] = i), b;
620
- }
621
- function Ce(o, t) {
622
- let e = t[0];
623
- for (let s = 1; s < o; s++) e += t[s];
624
- return e;
625
1552
  }
626
- function H(o) {
627
- return new Float64Array(o);
1553
+ function Or(o, t) {
1554
+ const e = o / (Math.abs(o) + Math.abs(t));
1555
+ return (t > 0 ? 3 - e : 1 + e) / 4;
628
1556
  }
629
- const Ms = (3 + 16 * dt) * dt, Ss = (2 + 12 * dt) * dt, As = (9 + 64 * dt) * dt * dt, Wt = H(4), Ie = H(8), Pe = H(12), $e = H(16), pt = H(4);
630
- function Es(o, t, e, s, i, n, r) {
631
- let a, f, c, u, h, l, p, y, g, b, w, S, _, v, T, I, N, V;
632
- const z = o - i, G = e - i, tt = t - n, X = s - n;
633
- v = z * X, l = $ * z, p = l - (l - z), y = z - p, l = $ * X, g = l - (l - X), b = X - g, T = y * b - (v - p * g - y * g - p * b), I = tt * G, l = $ * tt, p = l - (l - tt), y = tt - p, l = $ * G, g = l - (l - G), b = G - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, Wt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, Wt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, Wt[2] = S - (V - h) + (w - h), Wt[3] = V;
634
- let it = Ce(4, Wt), d = Ss * r;
635
- if (it >= d || -it >= d || (h = o - z, a = o - (z + h) + (h - i), h = e - G, c = e - (G + h) + (h - i), h = t - tt, f = t - (tt + h) + (h - n), h = s - X, u = s - (X + h) + (h - n), a === 0 && f === 0 && c === 0 && u === 0) || (d = As * r + Ye * Math.abs(it), it += z * u + X * a - (tt * c + G * f), it >= d || -it >= d)) return it;
636
- v = a * X, l = $ * a, p = l - (l - a), y = a - p, l = $ * X, g = l - (l - X), b = X - g, T = y * b - (v - p * g - y * g - p * b), I = f * G, l = $ * f, p = l - (l - f), y = f - p, l = $ * G, g = l - (l - G), b = G - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, pt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, pt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, pt[2] = S - (V - h) + (w - h), pt[3] = V;
637
- const m = ct(4, Wt, 4, pt, Ie);
638
- v = z * u, l = $ * z, p = l - (l - z), y = z - p, l = $ * u, g = l - (l - u), b = u - g, T = y * b - (v - p * g - y * g - p * b), I = tt * c, l = $ * tt, p = l - (l - tt), y = tt - p, l = $ * c, g = l - (l - c), b = c - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, pt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, pt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, pt[2] = S - (V - h) + (w - h), pt[3] = V;
639
- const x = ct(m, Ie, 4, pt, Pe);
640
- v = a * u, l = $ * a, p = l - (l - a), y = a - p, l = $ * u, g = l - (l - u), b = u - g, T = y * b - (v - p * g - y * g - p * b), I = f * c, l = $ * f, p = l - (l - f), y = f - p, l = $ * c, g = l - (l - c), b = c - g, N = y * b - (I - p * g - y * g - p * b), w = T - N, h = T - w, pt[0] = T - (w + h) + (h - N), S = v + w, h = S - v, _ = v - (S - h) + (w - h), w = _ - I, h = _ - w, pt[1] = _ - (w + h) + (h - I), V = S + w, h = V - S, pt[2] = S - (V - h) + (w - h), pt[3] = V;
641
- const A = ct(x, Pe, 4, pt, $e);
642
- return $e[A - 1];
643
- }
644
- function Ct(o, t, e, s, i, n) {
645
- const r = (t - n) * (e - i), a = (o - i) * (s - n), f = r - a, c = Math.abs(r + a);
646
- return Math.abs(f) >= Ms * c ? f : -Es(o, t, e, s, i, n, c);
647
- }
648
- const vs = (10 + 96 * dt) * dt, Os = (4 + 48 * dt) * dt, Ts = (44 + 576 * dt) * dt * dt, It = H(4), Pt = H(4), $t = H(4), _t = H(4), Mt = H(4), St = H(4), wt = H(4), mt = H(4), he = H(8), ce = H(8), fe = H(8), ue = H(8), le = H(8), de = H(8), Kt = H(8), Qt = H(8), Zt = H(8), Bt = H(4), Dt = H(4), Ft = H(4), U = H(8), L = H(16), et = H(16), st = H(16), Z = H(32), Rt = H(32), ot = H(48), bt = H(64);
649
- let zt = H(1152), ge = H(1152);
650
- function at(o, t, e) {
651
- o = ct(o, zt, t, e, ge);
652
- const s = zt;
653
- return zt = ge, ge = s, o;
654
- }
655
- function Is(o, t, e, s, i, n, r, a, f) {
656
- let c, u, h, l, p, y, g, b, w, S, _, v, T, I, N, V, z, G, tt, X, it, d, m, x, A, E, R, k, O, B, P, D, F, W, j;
657
- const Y = o - r, C = e - r, q = i - r, K = t - a, J = s - a, Q = n - a;
658
- P = C * Q, m = $ * C, x = m - (m - C), A = C - x, m = $ * Q, E = m - (m - Q), R = Q - E, D = A * R - (P - x * E - A * E - x * R), F = q * J, m = $ * q, x = m - (m - q), A = q - x, m = $ * J, E = m - (m - J), R = J - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, It[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, It[1] = B - (k + d) + (d - F), j = O + k, d = j - O, It[2] = O - (j - d) + (k - d), It[3] = j, P = q * K, m = $ * q, x = m - (m - q), A = q - x, m = $ * K, E = m - (m - K), R = K - E, D = A * R - (P - x * E - A * E - x * R), F = Y * Q, m = $ * Y, x = m - (m - Y), A = Y - x, m = $ * Q, E = m - (m - Q), R = Q - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, Pt[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, Pt[1] = B - (k + d) + (d - F), j = O + k, d = j - O, Pt[2] = O - (j - d) + (k - d), Pt[3] = j, P = Y * J, m = $ * Y, x = m - (m - Y), A = Y - x, m = $ * J, E = m - (m - J), R = J - E, D = A * R - (P - x * E - A * E - x * R), F = C * K, m = $ * C, x = m - (m - C), A = C - x, m = $ * K, E = m - (m - K), R = K - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, $t[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, $t[1] = B - (k + d) + (d - F), j = O + k, d = j - O, $t[2] = O - (j - d) + (k - d), $t[3] = j, c = ct(
659
- ct(
660
- ct(
661
- M(M(4, It, Y, U), U, Y, L),
662
- L,
663
- M(M(4, It, K, U), U, K, et),
664
- et,
665
- Z
666
- ),
667
- Z,
668
- ct(
669
- M(M(4, Pt, C, U), U, C, L),
670
- L,
671
- M(M(4, Pt, J, U), U, J, et),
672
- et,
673
- Rt
674
- ),
675
- Rt,
676
- bt
677
- ),
678
- bt,
679
- ct(
680
- M(M(4, $t, q, U), U, q, L),
681
- L,
682
- M(M(4, $t, Q, U), U, Q, et),
683
- et,
684
- Z
685
- ),
686
- Z,
687
- zt
688
- );
689
- let Ut = Ce(c, zt), Xt = Os * f;
690
- if (Ut >= Xt || -Ut >= Xt || (d = o - Y, u = o - (Y + d) + (d - r), d = t - K, p = t - (K + d) + (d - a), d = e - C, h = e - (C + d) + (d - r), d = s - J, y = s - (J + d) + (d - a), d = i - q, l = i - (q + d) + (d - r), d = n - Q, g = n - (Q + d) + (d - a), u === 0 && h === 0 && l === 0 && p === 0 && y === 0 && g === 0) || (Xt = Ts * f + Ye * Math.abs(Ut), Ut += (Y * Y + K * K) * (C * g + Q * h - (J * l + q * y)) + 2 * (Y * u + K * p) * (C * Q - J * q) + ((C * C + J * J) * (q * p + K * l - (Q * u + Y * g)) + 2 * (C * h + J * y) * (q * K - Q * Y)) + ((q * q + Q * Q) * (Y * y + J * u - (K * h + C * p)) + 2 * (q * l + Q * g) * (Y * J - K * C)), Ut >= Xt || -Ut >= Xt))
691
- return Ut;
692
- if ((h !== 0 || y !== 0 || l !== 0 || g !== 0) && (P = Y * Y, m = $ * Y, x = m - (m - Y), A = Y - x, D = A * A - (P - x * x - (x + x) * A), F = K * K, m = $ * K, x = m - (m - K), A = K - x, W = A * A - (F - x * x - (x + x) * A), k = D + W, d = k - D, _t[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, _t[1] = B - (k - d) + (F - d), j = O + k, d = j - O, _t[2] = O - (j - d) + (k - d), _t[3] = j), (l !== 0 || g !== 0 || u !== 0 || p !== 0) && (P = C * C, m = $ * C, x = m - (m - C), A = C - x, D = A * A - (P - x * x - (x + x) * A), F = J * J, m = $ * J, x = m - (m - J), A = J - x, W = A * A - (F - x * x - (x + x) * A), k = D + W, d = k - D, Mt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, Mt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, Mt[2] = O - (j - d) + (k - d), Mt[3] = j), (u !== 0 || p !== 0 || h !== 0 || y !== 0) && (P = q * q, m = $ * q, x = m - (m - q), A = q - x, D = A * A - (P - x * x - (x + x) * A), F = Q * Q, m = $ * Q, x = m - (m - Q), A = Q - x, W = A * A - (F - x * x - (x + x) * A), k = D + W, d = k - D, St[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, St[1] = B - (k - d) + (F - d), j = O + k, d = j - O, St[2] = O - (j - d) + (k - d), St[3] = j), u !== 0 && (b = M(4, It, u, he), c = at(c, yt(
693
- M(b, he, 2 * Y, L),
694
- L,
695
- M(M(4, St, u, U), U, J, et),
696
- et,
697
- M(M(4, Mt, u, U), U, -Q, st),
698
- st,
699
- Z,
700
- ot
701
- ), ot)), p !== 0 && (w = M(4, It, p, ce), c = at(c, yt(
702
- M(w, ce, 2 * K, L),
703
- L,
704
- M(M(4, Mt, p, U), U, q, et),
705
- et,
706
- M(M(4, St, p, U), U, -C, st),
707
- st,
708
- Z,
709
- ot
710
- ), ot)), h !== 0 && (S = M(4, Pt, h, fe), c = at(c, yt(
711
- M(S, fe, 2 * C, L),
712
- L,
713
- M(M(4, _t, h, U), U, Q, et),
714
- et,
715
- M(M(4, St, h, U), U, -K, st),
716
- st,
717
- Z,
718
- ot
719
- ), ot)), y !== 0 && (_ = M(4, Pt, y, ue), c = at(c, yt(
720
- M(_, ue, 2 * J, L),
721
- L,
722
- M(M(4, St, y, U), U, Y, et),
723
- et,
724
- M(M(4, _t, y, U), U, -q, st),
725
- st,
726
- Z,
727
- ot
728
- ), ot)), l !== 0 && (v = M(4, $t, l, le), c = at(c, yt(
729
- M(v, le, 2 * q, L),
730
- L,
731
- M(M(4, Mt, l, U), U, K, et),
732
- et,
733
- M(M(4, _t, l, U), U, -J, st),
734
- st,
735
- Z,
736
- ot
737
- ), ot)), g !== 0 && (T = M(4, $t, g, de), c = at(c, yt(
738
- M(T, de, 2 * Q, L),
739
- L,
740
- M(M(4, _t, g, U), U, C, et),
741
- et,
742
- M(M(4, Mt, g, U), U, -Y, st),
743
- st,
744
- Z,
745
- ot
746
- ), ot)), u !== 0 || p !== 0) {
747
- if (h !== 0 || y !== 0 || l !== 0 || g !== 0 ? (P = h * Q, m = $ * h, x = m - (m - h), A = h - x, m = $ * Q, E = m - (m - Q), R = Q - E, D = A * R - (P - x * E - A * E - x * R), F = C * g, m = $ * C, x = m - (m - C), A = C - x, m = $ * g, E = m - (m - g), R = g - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, wt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, wt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, wt[2] = O - (j - d) + (k - d), wt[3] = j, P = l * -J, m = $ * l, x = m - (m - l), A = l - x, m = $ * -J, E = m - (m - -J), R = -J - E, D = A * R - (P - x * E - A * E - x * R), F = q * -y, m = $ * q, x = m - (m - q), A = q - x, m = $ * -y, E = m - (m - -y), R = -y - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, mt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, mt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, mt[2] = O - (j - d) + (k - d), mt[3] = j, N = ct(4, wt, 4, mt, Qt), P = h * g, m = $ * h, x = m - (m - h), A = h - x, m = $ * g, E = m - (m - g), R = g - E, D = A * R - (P - x * E - A * E - x * R), F = l * y, m = $ * l, x = m - (m - l), A = l - x, m = $ * y, E = m - (m - y), R = y - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, Dt[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, Dt[1] = B - (k + d) + (d - F), j = O + k, d = j - O, Dt[2] = O - (j - d) + (k - d), Dt[3] = j, G = 4) : (Qt[0] = 0, N = 1, Dt[0] = 0, G = 1), u !== 0) {
748
- const ft = M(N, Qt, u, st);
749
- c = at(c, ct(
750
- M(b, he, u, L),
751
- L,
752
- M(ft, st, 2 * Y, Z),
753
- Z,
754
- ot
755
- ), ot);
756
- const ut = M(G, Dt, u, U);
757
- c = at(c, yt(
758
- M(ut, U, 2 * Y, L),
759
- L,
760
- M(ut, U, u, et),
761
- et,
762
- M(ft, st, u, Z),
763
- Z,
764
- Rt,
765
- bt
766
- ), bt), y !== 0 && (c = at(c, M(M(4, St, u, U), U, y, L), L)), g !== 0 && (c = at(c, M(M(4, Mt, -u, U), U, g, L), L));
767
- }
768
- if (p !== 0) {
769
- const ft = M(N, Qt, p, st);
770
- c = at(c, ct(
771
- M(w, ce, p, L),
772
- L,
773
- M(ft, st, 2 * K, Z),
774
- Z,
775
- ot
776
- ), ot);
777
- const ut = M(G, Dt, p, U);
778
- c = at(c, yt(
779
- M(ut, U, 2 * K, L),
780
- L,
781
- M(ut, U, p, et),
782
- et,
783
- M(ft, st, p, Z),
784
- Z,
785
- Rt,
786
- bt
787
- ), bt);
788
- }
789
- }
790
- if (h !== 0 || y !== 0) {
791
- if (l !== 0 || g !== 0 || u !== 0 || p !== 0 ? (P = l * K, m = $ * l, x = m - (m - l), A = l - x, m = $ * K, E = m - (m - K), R = K - E, D = A * R - (P - x * E - A * E - x * R), F = q * p, m = $ * q, x = m - (m - q), A = q - x, m = $ * p, E = m - (m - p), R = p - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, wt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, wt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, wt[2] = O - (j - d) + (k - d), wt[3] = j, X = -Q, it = -g, P = u * X, m = $ * u, x = m - (m - u), A = u - x, m = $ * X, E = m - (m - X), R = X - E, D = A * R - (P - x * E - A * E - x * R), F = Y * it, m = $ * Y, x = m - (m - Y), A = Y - x, m = $ * it, E = m - (m - it), R = it - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, mt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, mt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, mt[2] = O - (j - d) + (k - d), mt[3] = j, V = ct(4, wt, 4, mt, Zt), P = l * p, m = $ * l, x = m - (m - l), A = l - x, m = $ * p, E = m - (m - p), R = p - E, D = A * R - (P - x * E - A * E - x * R), F = u * g, m = $ * u, x = m - (m - u), A = u - x, m = $ * g, E = m - (m - g), R = g - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, Ft[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, Ft[1] = B - (k + d) + (d - F), j = O + k, d = j - O, Ft[2] = O - (j - d) + (k - d), Ft[3] = j, tt = 4) : (Zt[0] = 0, V = 1, Ft[0] = 0, tt = 1), h !== 0) {
792
- const ft = M(V, Zt, h, st);
793
- c = at(c, ct(
794
- M(S, fe, h, L),
795
- L,
796
- M(ft, st, 2 * C, Z),
797
- Z,
798
- ot
799
- ), ot);
800
- const ut = M(tt, Ft, h, U);
801
- c = at(c, yt(
802
- M(ut, U, 2 * C, L),
803
- L,
804
- M(ut, U, h, et),
805
- et,
806
- M(ft, st, h, Z),
807
- Z,
808
- Rt,
809
- bt
810
- ), bt), g !== 0 && (c = at(c, M(M(4, _t, h, U), U, g, L), L)), p !== 0 && (c = at(c, M(M(4, St, -h, U), U, p, L), L));
811
- }
812
- if (y !== 0) {
813
- const ft = M(V, Zt, y, st);
814
- c = at(c, ct(
815
- M(_, ue, y, L),
816
- L,
817
- M(ft, st, 2 * J, Z),
818
- Z,
819
- ot
820
- ), ot);
821
- const ut = M(tt, Ft, y, U);
822
- c = at(c, yt(
823
- M(ut, U, 2 * J, L),
824
- L,
825
- M(ut, U, y, et),
826
- et,
827
- M(ft, st, y, Z),
828
- Z,
829
- Rt,
830
- bt
831
- ), bt);
832
- }
833
- }
834
- if (l !== 0 || g !== 0) {
835
- if (u !== 0 || p !== 0 || h !== 0 || y !== 0 ? (P = u * J, m = $ * u, x = m - (m - u), A = u - x, m = $ * J, E = m - (m - J), R = J - E, D = A * R - (P - x * E - A * E - x * R), F = Y * y, m = $ * Y, x = m - (m - Y), A = Y - x, m = $ * y, E = m - (m - y), R = y - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, wt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, wt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, wt[2] = O - (j - d) + (k - d), wt[3] = j, X = -K, it = -p, P = h * X, m = $ * h, x = m - (m - h), A = h - x, m = $ * X, E = m - (m - X), R = X - E, D = A * R - (P - x * E - A * E - x * R), F = C * it, m = $ * C, x = m - (m - C), A = C - x, m = $ * it, E = m - (m - it), R = it - E, W = A * R - (F - x * E - A * E - x * R), k = D + W, d = k - D, mt[0] = D - (k - d) + (W - d), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B + F, d = k - B, mt[1] = B - (k - d) + (F - d), j = O + k, d = j - O, mt[2] = O - (j - d) + (k - d), mt[3] = j, I = ct(4, wt, 4, mt, Kt), P = u * y, m = $ * u, x = m - (m - u), A = u - x, m = $ * y, E = m - (m - y), R = y - E, D = A * R - (P - x * E - A * E - x * R), F = h * p, m = $ * h, x = m - (m - h), A = h - x, m = $ * p, E = m - (m - p), R = p - E, W = A * R - (F - x * E - A * E - x * R), k = D - W, d = D - k, Bt[0] = D - (k + d) + (d - W), O = P + k, d = O - P, B = P - (O - d) + (k - d), k = B - F, d = B - k, Bt[1] = B - (k + d) + (d - F), j = O + k, d = j - O, Bt[2] = O - (j - d) + (k - d), Bt[3] = j, z = 4) : (Kt[0] = 0, I = 1, Bt[0] = 0, z = 1), l !== 0) {
836
- const ft = M(I, Kt, l, st);
837
- c = at(c, ct(
838
- M(v, le, l, L),
839
- L,
840
- M(ft, st, 2 * q, Z),
841
- Z,
842
- ot
843
- ), ot);
844
- const ut = M(z, Bt, l, U);
845
- c = at(c, yt(
846
- M(ut, U, 2 * q, L),
847
- L,
848
- M(ut, U, l, et),
849
- et,
850
- M(ft, st, l, Z),
851
- Z,
852
- Rt,
853
- bt
854
- ), bt), p !== 0 && (c = at(c, M(M(4, Mt, l, U), U, p, L), L)), y !== 0 && (c = at(c, M(M(4, _t, -l, U), U, y, L), L));
1557
+ function en(o, t, e, n) {
1558
+ const r = o - e, i = t - n;
1559
+ return r * r + i * i;
1560
+ }
1561
+ function Ir(o, t, e, n, r, i, s, a) {
1562
+ const c = o - s, h = t - a, u = e - s, f = n - a, d = r - s, y = i - a, E = c * c + h * h, k = u * u + f * f, X = d * d + y * y;
1563
+ return c * (f * X - k * y) - h * (u * X - k * d) + E * (u * y - f * d) < 0;
1564
+ }
1565
+ function Tr(o, t, e, n, r, i) {
1566
+ const s = e - o, a = n - t, c = r - o, h = i - t, u = s * s + a * a, f = c * c + h * h, d = 0.5 / (s * h - a * c), y = (h * u - a * f) * d, E = (s * f - c * u) * d;
1567
+ return y * y + E * E;
1568
+ }
1569
+ function Nr(o, t, e, n, r, i) {
1570
+ const s = e - o, a = n - t, c = r - o, h = i - t, u = s * s + a * a, f = c * c + h * h, d = 0.5 / (s * h - a * c), y = o + (h * u - a * f) * d, E = t + (s * f - c * u) * d;
1571
+ return { x: y, y: E };
1572
+ }
1573
+ function we(o, t, e, n) {
1574
+ if (n - e <= 20)
1575
+ for (let r = e + 1; r <= n; r++) {
1576
+ const i = o[r], s = t[i];
1577
+ let a = r - 1;
1578
+ for (; a >= e && t[o[a]] > s; ) o[a + 1] = o[a--];
1579
+ o[a + 1] = i;
855
1580
  }
856
- if (g !== 0) {
857
- const ft = M(I, Kt, g, st);
858
- c = at(c, ct(
859
- M(T, de, g, L),
860
- L,
861
- M(ft, st, 2 * Q, Z),
862
- Z,
863
- ot
864
- ), ot);
865
- const ut = M(z, Bt, g, U);
866
- c = at(c, yt(
867
- M(ut, U, 2 * Q, L),
868
- L,
869
- M(ut, U, g, et),
870
- et,
871
- M(ft, st, g, Z),
872
- Z,
873
- Rt,
874
- bt
875
- ), bt);
1581
+ else {
1582
+ const r = e + n >> 1;
1583
+ let i = e + 1, s = n;
1584
+ _e(o, r, i), t[o[e]] > t[o[n]] && _e(o, e, n), t[o[i]] > t[o[n]] && _e(o, i, n), t[o[e]] > t[o[i]] && _e(o, e, i);
1585
+ const a = o[i], c = t[a];
1586
+ for (; ; ) {
1587
+ do
1588
+ i++;
1589
+ while (t[o[i]] < c);
1590
+ do
1591
+ s--;
1592
+ while (t[o[s]] > c);
1593
+ if (s < i) break;
1594
+ _e(o, i, s);
876
1595
  }
1596
+ o[e + 1] = o[s], o[s] = a, n - i + 1 >= s - e ? (we(o, t, i, n), we(o, t, e, s - 1)) : (we(o, t, e, s - 1), we(o, t, i, n));
877
1597
  }
878
- return zt[c - 1];
879
1598
  }
880
- function Ps(o, t, e, s, i, n, r, a) {
881
- const f = o - r, c = e - r, u = i - r, h = t - a, l = s - a, p = n - a, y = c * p, g = u * l, b = f * f + h * h, w = u * h, S = f * p, _ = c * c + l * l, v = f * l, T = c * h, I = u * u + p * p, N = b * (y - g) + _ * (w - S) + I * (v - T), V = (Math.abs(y) + Math.abs(g)) * b + (Math.abs(w) + Math.abs(S)) * _ + (Math.abs(v) + Math.abs(T)) * I, z = vs * V;
882
- return N > z || -N > z ? N : Is(o, t, e, s, i, n, r, a, V);
1599
+ function _e(o, t, e) {
1600
+ const n = o[t];
1601
+ o[t] = o[e], o[e] = n;
1602
+ }
1603
+ function Xr(o) {
1604
+ return o[0];
883
1605
  }
884
- class $s {
1606
+ function Yr(o) {
1607
+ return o[1];
1608
+ }
1609
+ class Rr {
1610
+ bs;
1611
+ width;
885
1612
  constructor(t, e) {
886
- this.W = t, this.bs = e;
1613
+ this.width = t, this.bs = e;
887
1614
  }
888
1615
  /**
889
1616
  * Add a number to the set.
890
- *
1617
+ *
891
1618
  * @param idx The number to add. Must be 0 <= idx < len.
892
- * @return this.
893
1619
  */
894
1620
  add(t) {
895
- const e = this.W, s = t / e | 0, i = t % e;
896
- return this.bs[s] |= 1 << i, this;
1621
+ const e = Math.floor(t / this.width), n = t % this.width;
1622
+ return this.bs[e] |= 1 << n, this;
897
1623
  }
898
1624
  /**
899
1625
  * Delete a number from the set.
900
- *
1626
+ *
901
1627
  * @param idx The number to delete. Must be 0 <= idx < len.
902
- * @return this.
903
1628
  */
904
1629
  delete(t) {
905
- const e = this.W, s = t / e | 0, i = t % e;
906
- return this.bs[s] &= ~(1 << i), this;
1630
+ const e = Math.floor(t / this.width), n = t % this.width;
1631
+ return this.bs[e] &= ~(1 << n), this;
907
1632
  }
908
1633
  /**
909
1634
  * Add or delete a number in the set, depending on the second argument.
910
- *
1635
+ *
911
1636
  * @param idx The number to add or delete. Must be 0 <= idx < len.
912
1637
  * @param val If true, add the number, otherwise delete.
913
- * @return val.
914
1638
  */
915
1639
  set(t, e) {
916
- const s = this.W, i = t / s | 0, n = t % s, r = 1 << n;
917
- return this.bs[i] ^= (-e ^ this.bs[i]) & r, e;
1640
+ const n = Math.floor(t / this.width), i = 1 << t % this.width;
1641
+ return this.bs[n] ^= (-Number(e) ^ this.bs[n]) & i, e;
918
1642
  }
919
1643
  /**
920
1644
  * Whether the number is in the set.
921
- *
1645
+ *
922
1646
  * @param idx The number to test. Must be 0 <= idx < len.
923
- * @return True if the number is in the set.
924
1647
  */
925
1648
  has(t) {
926
- const e = this.W, s = t / e | 0, i = t % e;
927
- return !!(this.bs[s] & 1 << i);
1649
+ const e = Math.floor(t / this.width), n = t % this.width;
1650
+ return (this.bs[e] & 1 << n) !== 0;
928
1651
  }
929
1652
  /**
930
- * Iterate over the numbers that are in the set. The callback is invoked
931
- * with each number that is set. It is allowed to change the BitSet during
932
- * iteration. If it deletes a number that has not been iterated over, that
933
- * number will not show up in a later call. If it adds a number during
934
- * iteration, that number may or may not show up in a later call.
935
- *
936
- * @param fn The function to call for each number.
937
- * @return this.
1653
+ * Iterate over the numbers that are in the set.
938
1654
  */
939
1655
  forEach(t) {
940
- const e = this.W, s = this.bs, i = s.length;
941
- for (let n = 0; n < i; n++) {
1656
+ const e = this.bs.length;
1657
+ for (let n = 0; n < e; n++) {
942
1658
  let r = 0;
943
- for (; s[n] && r < e; )
944
- s[n] & 1 << r && t(n * e + r), r++;
1659
+ for (; this.bs[n] && r < this.width; )
1660
+ this.bs[n] & 1 << r && t(n * this.width + r), r++;
945
1661
  }
946
1662
  return this;
947
1663
  }
948
1664
  }
949
- class Re extends $s {
950
- /**
951
- * Create a bit set.
952
- *
953
- * @param len The length of the bit set, limiting the maximum value that
954
- * can be stored in it to len - 1.
955
- */
1665
+ class xn extends Rr {
956
1666
  constructor(t) {
957
- const e = new Uint8Array(Math.ceil(t / 8)).fill(0);
958
- super(8, e);
1667
+ super(8, new Uint8Array(Math.ceil(t / 8)).fill(0));
959
1668
  }
960
1669
  }
961
- function jt(o) {
1670
+ function pe(o) {
962
1671
  return o % 3 === 2 ? o - 2 : o + 1;
963
1672
  }
964
- function Et(o) {
1673
+ function ee(o) {
965
1674
  return o % 3 === 0 ? o + 2 : o - 1;
966
1675
  }
967
- function qe(o, t, e, s, i, n, r, a) {
968
- const f = Ct(o, t, i, n, r, a), c = Ct(e, s, i, n, r, a);
969
- if (f > 0 && c > 0 || f < 0 && c < 0)
1676
+ function Mn(o, t, e, n, r, i, s, a) {
1677
+ const c = te(o, t, r, i, s, a), h = te(e, n, r, i, s, a);
1678
+ if (c > 0 && h > 0 || c < 0 && h < 0)
970
1679
  return !1;
971
- const u = Ct(i, n, o, t, e, s), h = Ct(r, a, o, t, e, s);
972
- return u > 0 && h > 0 || u < 0 && h < 0 ? !1 : f === 0 && c === 0 && u === 0 && h === 0 ? !(Math.max(i, r) < Math.min(o, e) || Math.max(o, e) < Math.min(i, r) || Math.max(n, a) < Math.min(t, s) || Math.max(t, s) < Math.min(n, a)) : !0;
1680
+ const u = te(r, i, o, t, e, n), f = te(s, a, o, t, e, n);
1681
+ return u > 0 && f > 0 || u < 0 && f < 0 ? !1 : c === 0 && h === 0 && u === 0 && f === 0 ? !(Math.max(r, s) < Math.min(o, e) || Math.max(o, e) < Math.min(r, s) || Math.max(i, a) < Math.min(t, n) || Math.max(t, n) < Math.min(i, a)) : !0;
973
1682
  }
974
- class Rs {
1683
+ class Cr {
1684
+ /**
1685
+ * The triangulation object from Delaunator.
1686
+ */
1687
+ del;
975
1688
  constructor(t) {
976
1689
  this.del = t;
977
1690
  }
978
1691
  }
979
- const Je = class extends Rs {
1692
+ class Fr extends Cr {
1693
+ vertMap;
1694
+ flips;
1695
+ consd;
980
1696
  /**
981
- * Make a Constrain.
1697
+ * Create a Constrain instance.
982
1698
  *
983
1699
  * @param del The triangulation output from Delaunator.
984
- * @param edges If provided, constrain these edges as by constrainAll.
1700
+ * @param edges If provided, constrain these edges via constrainAll.
985
1701
  */
986
1702
  constructor(t, e) {
987
1703
  if (!t || typeof t != "object" || !t.triangles || !t.halfedges || !t.coords)
@@ -991,11 +1707,11 @@ const Je = class extends Rs {
991
1707
  if (t.triangles.length < 3)
992
1708
  throw new Error("No edges in triangulation");
993
1709
  super(t);
994
- const s = 2 ** 32 - 1, i = t.coords.length >> 1, n = t.triangles.length;
995
- this.vertMap = new Uint32Array(i).fill(s), this.flips = new Re(n), this.consd = new Re(n);
996
- for (let r = 0; r < n; r++) {
997
- const a = t.triangles[r];
998
- this.vertMap[a] === s && this.updateVert(r);
1710
+ const n = 2 ** 32 - 1, r = t.coords.length >> 1, i = t.triangles.length;
1711
+ this.vertMap = new Uint32Array(r).fill(n), this.flips = new xn(i), this.consd = new xn(i);
1712
+ for (let s = 0; s < i; s++) {
1713
+ const a = t.triangles[s];
1714
+ this.vertMap[a] === n && this.updateVert(s);
999
1715
  }
1000
1716
  e && this.constrainAll(e);
1001
1717
  }
@@ -1003,53 +1719,73 @@ const Je = class extends Rs {
1003
1719
  * Constrain the triangulation such that there is an edge between p1 and p2.
1004
1720
  */
1005
1721
  constrainOne(t, e) {
1006
- const { triangles: s, halfedges: i } = this.del, n = this.vertMap[t];
1007
- let r = n;
1722
+ const { triangles: n, halfedges: r } = this.del, i = this.vertMap[t];
1723
+ let s = i;
1008
1724
  do {
1009
- const c = s[r], u = jt(r);
1010
- if (c === e)
1011
- return this.protect(r);
1012
- const h = Et(r), l = s[h];
1013
- if (l === e)
1725
+ const h = n[s], u = pe(s);
1726
+ if (h === e)
1727
+ return this.protect(s);
1728
+ const f = ee(s), d = n[f];
1729
+ if (d === e)
1014
1730
  return this.protect(u), u;
1015
- if (this.intersectSegments(t, e, l, c)) {
1016
- r = h;
1731
+ if (this.intersectSegments(t, e, d, h)) {
1732
+ s = f;
1017
1733
  break;
1018
1734
  }
1019
- r = i[u];
1020
- } while (r !== -1 && r !== n);
1021
- let a = r, f = -1;
1022
- for (; r !== -1; ) {
1023
- const c = i[r], u = Et(r), h = Et(c), l = jt(c);
1024
- if (c === -1)
1735
+ s = r[u];
1736
+ } while (s !== -1 && s !== i);
1737
+ let a = s, c = -1;
1738
+ for (; s !== -1; ) {
1739
+ const h = r[s], u = ee(s), f = ee(h), d = pe(h);
1740
+ if (h === -1)
1025
1741
  throw new Error("Constraining edge exited the hull");
1026
- if (this.consd.has(r))
1742
+ if (this.consd.has(s))
1027
1743
  throw new Error("Edge intersects already constrained edge");
1028
- if (this.isCollinear(t, e, s[r]) || this.isCollinear(t, e, s[c]))
1744
+ if (this.isCollinear(t, e, n[s]) || this.isCollinear(t, e, n[h]))
1029
1745
  throw new Error("Constraining edge intersects point");
1030
1746
  if (!this.intersectSegments(
1031
- s[r],
1032
- s[c],
1033
- s[u],
1034
- s[h]
1747
+ n[s],
1748
+ n[h],
1749
+ n[u],
1750
+ n[f]
1035
1751
  )) {
1036
- if (f === -1 && (f = r), s[h] === e) {
1037
- if (r === f)
1752
+ if (c === -1 && (c = s), n[f] === e) {
1753
+ if (s === c)
1038
1754
  throw new Error("Infinite loop: non-convex quadrilateral");
1039
- r = f, f = -1;
1755
+ s = c, c = -1;
1040
1756
  continue;
1041
1757
  }
1042
- if (this.intersectSegments(t, e, s[h], s[c]))
1043
- r = h;
1044
- else if (this.intersectSegments(t, e, s[l], s[h]))
1045
- r = l;
1046
- else if (f === r)
1758
+ if (this.intersectSegments(
1759
+ t,
1760
+ e,
1761
+ n[f],
1762
+ n[h]
1763
+ ))
1764
+ s = f;
1765
+ else if (this.intersectSegments(
1766
+ t,
1767
+ e,
1768
+ n[d],
1769
+ n[f]
1770
+ ))
1771
+ s = d;
1772
+ else if (c === s)
1047
1773
  throw new Error("Infinite loop: no further intersect after non-convex");
1048
1774
  continue;
1049
1775
  }
1050
- if (this.flipDiagonal(r), this.intersectSegments(t, e, s[u], s[h]) && (f === -1 && (f = u), f === u))
1776
+ if (this.flipDiagonal(s), this.intersectSegments(
1777
+ t,
1778
+ e,
1779
+ n[u],
1780
+ n[f]
1781
+ ) && (c === -1 && (c = u), c === u))
1051
1782
  throw new Error("Infinite loop: flipped diagonal still intersects");
1052
- s[h] === e ? (a = h, r = f, f = -1) : this.intersectSegments(t, e, s[l], s[h]) && (r = l);
1783
+ n[f] === e ? (a = f, s = c, c = -1) : this.intersectSegments(
1784
+ t,
1785
+ e,
1786
+ n[d],
1787
+ n[f]
1788
+ ) && (s = d);
1053
1789
  }
1054
1790
  return this.protect(a), this.delaunify(!0), this.findEdge(t, e);
1055
1791
  }
@@ -1057,32 +1793,33 @@ const Je = class extends Rs {
1057
1793
  * Fix the Delaunay condition.
1058
1794
  */
1059
1795
  delaunify(t = !1) {
1060
- const { halfedges: e } = this.del, s = this.flips, i = this.consd, n = e.length;
1796
+ const { halfedges: e } = this.del, n = this.flips, r = this.consd, i = e.length;
1797
+ let s;
1061
1798
  do {
1062
- var r = 0;
1063
- for (let a = 0; a < n; a++) {
1064
- if (i.has(a))
1799
+ s = 0;
1800
+ for (let a = 0; a < i; a++) {
1801
+ if (r.has(a))
1065
1802
  continue;
1066
- s.delete(a);
1067
- const f = e[a];
1068
- f !== -1 && (s.delete(f), this.isDelaunay(a) || (this.flipDiagonal(a), r++));
1803
+ n.delete(a);
1804
+ const c = e[a];
1805
+ c !== -1 && (n.delete(c), this.isDelaunay(a) || (this.flipDiagonal(a), s++));
1069
1806
  }
1070
- } while (t && r > 0);
1807
+ } while (t && s > 0);
1071
1808
  return this;
1072
1809
  }
1073
1810
  /**
1074
- * Call constrainOne on each edge
1811
+ * Call constrainOne on each edge.
1075
1812
  */
1076
1813
  constrainAll(t) {
1077
1814
  const e = t.length;
1078
- for (let s = 0; s < e; s++) {
1079
- const i = t[s];
1080
- this.constrainOne(i[0], i[1]);
1815
+ for (let n = 0; n < e; n++) {
1816
+ const r = t[n];
1817
+ this.constrainOne(r[0], r[1]);
1081
1818
  }
1082
1819
  return this;
1083
1820
  }
1084
1821
  /**
1085
- * Whether an edge is constrained
1822
+ * Whether an edge is constrained.
1086
1823
  */
1087
1824
  isConstrained(t) {
1088
1825
  return this.consd.has(t);
@@ -1092,186 +1829,445 @@ const Je = class extends Rs {
1092
1829
  * p2 -> p1 (i.e. it is on the hull), returns the negative id of it.
1093
1830
  */
1094
1831
  findEdge(t, e) {
1095
- const s = this.vertMap[e], { triangles: i, halfedges: n } = this.del;
1096
- let r = s, a = -1;
1832
+ const n = this.vertMap[e], { triangles: r, halfedges: i } = this.del;
1833
+ let s = n, a = -1;
1097
1834
  do {
1098
- if (i[r] === t)
1099
- return r;
1100
- a = jt(r), r = n[a];
1101
- } while (r !== -1 && r !== s);
1102
- return i[jt(a)] === t ? -a : 1 / 0;
1835
+ if (r[s] === t)
1836
+ return s;
1837
+ a = pe(s), s = i[a];
1838
+ } while (s !== -1 && s !== n);
1839
+ return r[pe(a)] === t ? -a : 1 / 0;
1103
1840
  }
1104
1841
  /**
1105
1842
  * Mark an edge as constrained, i.e. should not be touched by `delaunify`.
1106
1843
  */
1107
1844
  protect(t) {
1108
- const e = this.del.halfedges[t], s = this.flips, i = this.consd;
1109
- return s.delete(t), i.add(t), e !== -1 ? (s.delete(e), i.add(e), e) : -t;
1845
+ const e = this.del.halfedges[t], n = this.flips, r = this.consd;
1846
+ return n.delete(t), r.add(t), e !== -1 ? (n.delete(e), r.add(e), e) : -t;
1110
1847
  }
1111
1848
  /**
1112
1849
  * Mark an edge as flipped unless constrained.
1113
1850
  */
1114
1851
  markFlip(t) {
1115
- const e = this.del.halfedges, s = this.flips;
1852
+ const e = this.del.halfedges, n = this.flips;
1116
1853
  if (this.consd.has(t))
1117
1854
  return !1;
1118
1855
  const i = e[t];
1119
- return i !== -1 && (s.add(t), s.add(i)), !0;
1856
+ return i !== -1 && (n.add(t), n.add(i)), !0;
1120
1857
  }
1121
1858
  /**
1122
- * Flip the edge shared by two triangles.
1123
- */
1859
+ * Flip the edge shared by two triangles.
1860
+ */
1124
1861
  flipDiagonal(t) {
1125
- const { triangles: e, halfedges: s } = this.del, i = this.flips, n = this.consd, r = s[t], a = Et(t), f = jt(t), c = Et(r), u = jt(r), h = s[a], l = s[c];
1126
- if (n.has(t))
1862
+ const { triangles: e, halfedges: n } = this.del, r = this.flips, i = this.consd, s = n[t], a = ee(t), c = pe(t), h = ee(s), u = pe(s), f = n[a], d = n[h];
1863
+ if (i.has(t))
1127
1864
  throw new Error("Trying to flip a constrained edge");
1128
- return e[t] = e[c], s[t] = l, i.set(t, i.has(c)) || n.set(t, n.has(c)), l !== -1 && (s[l] = t), s[a] = c, e[r] = e[a], s[r] = h, i.set(r, i.has(a)) || n.set(r, n.has(a)), h !== -1 && (s[h] = r), s[c] = a, this.markFlip(t), this.markFlip(f), this.markFlip(r), this.markFlip(u), i.add(a), n.delete(a), i.add(c), n.delete(c), this.updateVert(t), this.updateVert(f), this.updateVert(r), this.updateVert(u), a;
1865
+ return e[t] = e[h], n[t] = d, r.set(t, r.has(h)) || i.set(t, i.has(h)), d !== -1 && (n[d] = t), n[a] = h, e[s] = e[a], n[s] = f, r.set(s, r.has(a)) || i.set(s, i.has(a)), f !== -1 && (n[f] = s), n[h] = a, this.markFlip(t), this.markFlip(c), this.markFlip(s), this.markFlip(u), r.add(a), i.delete(a), r.add(h), i.delete(h), this.updateVert(t), this.updateVert(c), this.updateVert(s), this.updateVert(u), a;
1129
1866
  }
1130
1867
  /**
1131
- * Whether point p1, p2, and p are collinear
1868
+ * Whether point p1, p2, and p are collinear.
1132
1869
  */
1133
- isCollinear(t, e, s) {
1870
+ isCollinear(t, e, n) {
1871
+ const r = this.del.coords;
1872
+ return te(
1873
+ r[t * 2],
1874
+ r[t * 2 + 1],
1875
+ r[e * 2],
1876
+ r[e * 2 + 1],
1877
+ r[n * 2],
1878
+ r[n * 2 + 1]
1879
+ ) === 0;
1880
+ }
1881
+ /**
1882
+ * Whether the triangle formed by p1, p2, p3 keeps px outside the circumcircle.
1883
+ */
1884
+ inCircle(t, e, n, r) {
1134
1885
  const i = this.del.coords;
1135
- return Ct(
1886
+ return nr(
1136
1887
  i[t * 2],
1137
1888
  i[t * 2 + 1],
1138
1889
  i[e * 2],
1139
1890
  i[e * 2 + 1],
1140
- i[s * 2],
1141
- i[s * 2 + 1]
1142
- ) === 0;
1143
- }
1144
- /**
1145
- * Whether px is in the circumcircle of the triangle formed by p1, p2, p3
1146
- */
1147
- inCircle(t, e, s, i) {
1148
- const n = this.del.coords;
1149
- return Ps(
1150
- n[t * 2],
1151
- n[t * 2 + 1],
1152
- n[e * 2],
1153
- n[e * 2 + 1],
1154
- n[s * 2],
1155
- n[s * 2 + 1],
1156
- n[i * 2],
1157
- n[i * 2 + 1]
1891
+ i[n * 2],
1892
+ i[n * 2 + 1],
1893
+ i[r * 2],
1894
+ i[r * 2 + 1]
1158
1895
  ) < 0;
1159
1896
  }
1160
1897
  /**
1161
- * Whether the triangles sharing edg conform to the Delaunay condition
1898
+ * Whether the triangles sharing edg conform to the Delaunay condition.
1162
1899
  */
1163
1900
  isDelaunay(t) {
1164
- const { triangles: e, halfedges: s } = this.del, i = s[t];
1165
- if (i === -1)
1901
+ const { triangles: e, halfedges: n } = this.del, r = n[t];
1902
+ if (r === -1)
1166
1903
  return !0;
1167
- const n = e[Et(t)], r = e[t], a = e[jt(t)], f = e[Et(i)];
1168
- return !this.inCircle(n, r, a, f);
1904
+ const i = e[ee(t)], s = e[t], a = e[pe(t)], c = e[ee(r)];
1905
+ return !this.inCircle(i, s, a, c);
1169
1906
  }
1170
1907
  /**
1171
- * Update the vertex -> incoming edge map
1908
+ * Update the vertex -> incoming edge map.
1172
1909
  */
1173
1910
  updateVert(t) {
1174
- const { triangles: e, halfedges: s } = this.del, i = this.vertMap, n = e[t];
1175
- let r = Et(t), a = s[r];
1911
+ const { triangles: e, halfedges: n } = this.del, r = this.vertMap, i = e[t];
1912
+ let s = ee(t), a = n[s];
1176
1913
  for (; a !== -1 && a !== t; )
1177
- r = Et(a), a = s[r];
1178
- return i[n] = r, r;
1914
+ s = ee(a), a = n[s];
1915
+ return r[i] = s, s;
1179
1916
  }
1180
1917
  /**
1181
- * Whether the segments between vertices intersect
1918
+ * Whether the segments between vertices intersect.
1182
1919
  */
1183
- intersectSegments(t, e, s, i) {
1184
- const n = this.del.coords;
1185
- return t === s || t === i || e === s || e === i ? !1 : qe(
1186
- n[t * 2],
1187
- n[t * 2 + 1],
1188
- n[e * 2],
1189
- n[e * 2 + 1],
1190
- n[s * 2],
1191
- n[s * 2 + 1],
1192
- n[i * 2],
1193
- n[i * 2 + 1]
1920
+ intersectSegments(t, e, n, r) {
1921
+ const i = this.del.coords;
1922
+ return t === n || t === r || e === n || e === r ? !1 : Mn(
1923
+ i[t * 2],
1924
+ i[t * 2 + 1],
1925
+ i[e * 2],
1926
+ i[e * 2 + 1],
1927
+ i[n * 2],
1928
+ i[n * 2 + 1],
1929
+ i[r * 2],
1930
+ i[r * 2 + 1]
1194
1931
  );
1195
1932
  }
1196
- };
1197
- Je.intersectSegments = qe;
1198
- let Ns = Je;
1199
- function te(o, t, e) {
1933
+ static intersectSegments = Mn;
1934
+ }
1935
+ function Te(o, t, e) {
1200
1936
  if (t || (t = []), typeof o != "object" || o.type !== "FeatureCollection")
1201
1937
  throw "Argument points must be FeatureCollection";
1202
1938
  if (!Array.isArray(t)) throw "Argument points must be Array of Array";
1203
- const s = o.features.map(
1204
- (f) => f.geometry.coordinates
1205
- ), i = ns.from(s);
1206
- let n;
1207
- const r = [];
1208
- i.triangles.length !== 0 && t.length !== 0 && (n = new Ns(i), n.constrainAll(t));
1209
- for (let f = 0; f < i.triangles.length; f += 3)
1210
- r.push([i.triangles[f], i.triangles[f + 1], i.triangles[f + 2]]);
1939
+ const n = o.features.map(
1940
+ (c) => c.geometry.coordinates
1941
+ ), r = sn.from(n);
1942
+ let i;
1943
+ const s = [];
1944
+ r.triangles.length !== 0 && t.length !== 0 && (i = new Fr(r), i.constrainAll(t));
1945
+ for (let c = 0; c < r.triangles.length; c += 3)
1946
+ s.push([r.triangles[c], r.triangles[c + 1], r.triangles[c + 2]]);
1211
1947
  const a = ["a", "b", "c"];
1212
- return Ot(
1213
- r.map((f) => {
1214
- const c = {}, u = f.map((h, l) => {
1215
- const p = o.features[h], y = p.geometry.coordinates, g = [y[0], y[1]];
1216
- return y.length === 3 ? g[2] = y[2] : c[a[l]] = p.properties[e], g;
1948
+ return Kt(
1949
+ s.map((c) => {
1950
+ const h = {}, u = c.map((f, d) => {
1951
+ const y = o.features[f], E = y.geometry.coordinates, k = [E[0], E[1]];
1952
+ return E.length === 3 ? k[2] = E[2] : h[a[d]] = y.properties[e], k;
1217
1953
  });
1218
- return u[3] = u[0], me([u], c);
1954
+ return u[3] = u[0], Ee([u], h);
1219
1955
  })
1220
1956
  );
1221
1957
  }
1222
- function Us(o) {
1223
- const e = new Bs(o).findSegmentIntersections();
1224
- return Ke(e).reduce(
1225
- (s, i, n, r) => Array.isArray(s) || (s || (s = {}), s[`${i.x}:${i.y}`] = i, n != r.length - 1) ? s : Object.keys(s).map((a) => Jt([s[a].x, s[a].y])),
1226
- {}
1958
+ class Rn {
1959
+ constructor(t = [], e = Lr) {
1960
+ if (this.data = t, this.length = this.data.length, this.compare = e, this.length > 0)
1961
+ for (let n = (this.length >> 1) - 1; n >= 0; n--) this._down(n);
1962
+ }
1963
+ push(t) {
1964
+ this.data.push(t), this.length++, this._up(this.length - 1);
1965
+ }
1966
+ pop() {
1967
+ if (this.length === 0) return;
1968
+ const t = this.data[0], e = this.data.pop();
1969
+ return this.length--, this.length > 0 && (this.data[0] = e, this._down(0)), t;
1970
+ }
1971
+ peek() {
1972
+ return this.data[0];
1973
+ }
1974
+ _up(t) {
1975
+ const { data: e, compare: n } = this, r = e[t];
1976
+ for (; t > 0; ) {
1977
+ const i = t - 1 >> 1, s = e[i];
1978
+ if (n(r, s) >= 0) break;
1979
+ e[t] = s, t = i;
1980
+ }
1981
+ e[t] = r;
1982
+ }
1983
+ _down(t) {
1984
+ const { data: e, compare: n } = this, r = this.length >> 1, i = e[t];
1985
+ for (; t < r; ) {
1986
+ let s = (t << 1) + 1, a = e[s];
1987
+ const c = s + 1;
1988
+ if (c < this.length && n(e[c], a) < 0 && (s = c, a = e[c]), n(a, i) >= 0) break;
1989
+ e[t] = a, t = s;
1990
+ }
1991
+ e[t] = i;
1992
+ }
1993
+ }
1994
+ function Lr(o, t) {
1995
+ return o < t ? -1 : o > t ? 1 : 0;
1996
+ }
1997
+ function Cn(o, t) {
1998
+ return o.p.x > t.p.x ? 1 : o.p.x < t.p.x ? -1 : o.p.y !== t.p.y ? o.p.y > t.p.y ? 1 : -1 : 1;
1999
+ }
2000
+ function Dr(o, t) {
2001
+ return o.rightSweepEvent.p.x > t.rightSweepEvent.p.x ? 1 : o.rightSweepEvent.p.x < t.rightSweepEvent.p.x ? -1 : o.rightSweepEvent.p.y !== t.rightSweepEvent.p.y ? o.rightSweepEvent.p.y < t.rightSweepEvent.p.y ? 1 : -1 : 1;
2002
+ }
2003
+ class kn {
2004
+ constructor(t, e, n, r) {
2005
+ this.p = {
2006
+ x: t[0],
2007
+ y: t[1]
2008
+ }, this.featureId = e, this.ringId = n, this.eventId = r, this.otherEvent = null, this.isLeftEndpoint = null;
2009
+ }
2010
+ isSamePoint(t) {
2011
+ return this.p.x === t.p.x && this.p.y === t.p.y;
2012
+ }
2013
+ }
2014
+ function $r(o, t) {
2015
+ if (o.type === "FeatureCollection") {
2016
+ const e = o.features;
2017
+ for (let n = 0; n < e.length; n++)
2018
+ Sn(e[n], t);
2019
+ } else
2020
+ Sn(o, t);
2021
+ }
2022
+ let Ne = 0, Xe = 0, Ye = 0;
2023
+ function Sn(o, t) {
2024
+ const e = o.type === "Feature" ? o.geometry : o;
2025
+ let n = e.coordinates;
2026
+ (e.type === "Polygon" || e.type === "MultiLineString") && (n = [n]), e.type === "LineString" && (n = [[n]]);
2027
+ for (let r = 0; r < n.length; r++)
2028
+ for (let i = 0; i < n[r].length; i++) {
2029
+ let s = n[r][i][0], a = null;
2030
+ Xe = Xe + 1;
2031
+ for (let c = 0; c < n[r][i].length - 1; c++) {
2032
+ a = n[r][i][c + 1];
2033
+ const h = new kn(s, Ne, Xe, Ye), u = new kn(a, Ne, Xe, Ye + 1);
2034
+ h.otherEvent = u, u.otherEvent = h, Cn(h, u) > 0 ? (u.isLeftEndpoint = !0, h.isLeftEndpoint = !1) : (h.isLeftEndpoint = !0, u.isLeftEndpoint = !1), t.push(h), t.push(u), s = a, Ye = Ye + 1;
2035
+ }
2036
+ }
2037
+ Ne = Ne + 1;
2038
+ }
2039
+ class qr {
2040
+ constructor(t) {
2041
+ this.leftSweepEvent = t, this.rightSweepEvent = t.otherEvent;
2042
+ }
2043
+ }
2044
+ function Ur(o, t) {
2045
+ if (o === null || t === null || o.leftSweepEvent.ringId === t.leftSweepEvent.ringId && (o.rightSweepEvent.isSamePoint(t.leftSweepEvent) || o.rightSweepEvent.isSamePoint(t.leftSweepEvent) || o.rightSweepEvent.isSamePoint(t.rightSweepEvent) || o.leftSweepEvent.isSamePoint(t.leftSweepEvent) || o.leftSweepEvent.isSamePoint(t.rightSweepEvent))) return !1;
2046
+ const e = o.leftSweepEvent.p.x, n = o.leftSweepEvent.p.y, r = o.rightSweepEvent.p.x, i = o.rightSweepEvent.p.y, s = t.leftSweepEvent.p.x, a = t.leftSweepEvent.p.y, c = t.rightSweepEvent.p.x, h = t.rightSweepEvent.p.y, u = (h - a) * (r - e) - (c - s) * (i - n), f = (c - s) * (n - a) - (h - a) * (e - s), d = (r - e) * (n - a) - (i - n) * (e - s);
2047
+ if (u === 0)
2048
+ return !1;
2049
+ const y = f / u, E = d / u;
2050
+ if (y >= 0 && y <= 1 && E >= 0 && E <= 1) {
2051
+ const k = e + y * (r - e), X = n + y * (i - n);
2052
+ return [k, X];
2053
+ }
2054
+ return !1;
2055
+ }
2056
+ function jr(o, t) {
2057
+ t = t || !1;
2058
+ const e = [], n = new Rn([], Dr);
2059
+ for (; o.length; ) {
2060
+ const r = o.pop();
2061
+ if (r.isLeftEndpoint) {
2062
+ const i = new qr(r);
2063
+ for (let s = 0; s < n.data.length; s++) {
2064
+ const a = n.data[s];
2065
+ if (t && a.leftSweepEvent.featureId === r.featureId)
2066
+ continue;
2067
+ const c = Ur(i, a);
2068
+ c !== !1 && e.push(c);
2069
+ }
2070
+ n.push(i);
2071
+ } else r.isLeftEndpoint === !1 && n.pop();
2072
+ }
2073
+ return e;
2074
+ }
2075
+ function zr(o, t) {
2076
+ const e = new Rn([], Cn);
2077
+ return $r(o, e), jr(e, t);
2078
+ }
2079
+ var Vr = zr;
2080
+ function Wr(o, t, e = {}) {
2081
+ const { removeDuplicates: n = !0, ignoreSelfIntersections: r = !0 } = e;
2082
+ let i = [];
2083
+ o.type === "FeatureCollection" ? i = i.concat(o.features) : o.type === "Feature" ? i.push(o) : (o.type === "LineString" || o.type === "Polygon" || o.type === "MultiLineString" || o.type === "MultiPolygon") && i.push(Se(o)), t.type === "FeatureCollection" ? i = i.concat(t.features) : t.type === "Feature" ? i.push(t) : (t.type === "LineString" || t.type === "Polygon" || t.type === "MultiLineString" || t.type === "MultiPolygon") && i.push(Se(t));
2084
+ const s = Vr(
2085
+ Kt(i),
2086
+ r
1227
2087
  );
2088
+ let a = [];
2089
+ if (n) {
2090
+ const c = {};
2091
+ s.forEach((h) => {
2092
+ const u = h.join(",");
2093
+ c[u] || (c[u] = !0, a.push(h));
2094
+ });
2095
+ } else
2096
+ a = s;
2097
+ return Kt(a.map((c) => de(c)));
2098
+ }
2099
+ var Jr = Wr;
2100
+ function Fn(o, t, e, n, r, i) {
2101
+ return Object.keys(o).reduce((s, a) => {
2102
+ const c = o[a], h = c.forw, u = c.bakw, f = {
2103
+ forw: [h[0] - t.forw[0], h[1] - t.forw[1]],
2104
+ bakw: [u[0] - t.bakw[0], u[1] - t.bakw[1]]
2105
+ }, d = f.forw[0] === 0 ? 1 / 0 : ((f.forw[0] < 0 ? e : n) - t.forw[0]) / f.forw[0], y = f.forw[1] === 0 ? 1 / 0 : ((f.forw[1] < 0 ? r : i) - t.forw[1]) / f.forw[1];
2106
+ if (Math.abs(d) / Math.abs(y) < 1.1) {
2107
+ const E = {
2108
+ forw: [
2109
+ f.forw[0] * d + t.forw[0],
2110
+ f.forw[1] * d + t.forw[1]
2111
+ ],
2112
+ bakw: [
2113
+ f.bakw[0] * d + t.bakw[0],
2114
+ f.bakw[1] * d + t.bakw[1]
2115
+ ]
2116
+ };
2117
+ f.forw[0] < 0 ? s[3].push(E) : s[1].push(E);
2118
+ }
2119
+ if (Math.abs(y) / Math.abs(d) < 1.1) {
2120
+ const E = {
2121
+ forw: [
2122
+ f.forw[0] * y + t.forw[0],
2123
+ f.forw[1] * y + t.forw[1]
2124
+ ],
2125
+ bakw: [
2126
+ f.bakw[0] * y + t.bakw[0],
2127
+ f.bakw[1] * y + t.bakw[1]
2128
+ ]
2129
+ };
2130
+ f.forw[1] < 0 ? s[0].push(E) : s[2].push(E);
2131
+ }
2132
+ return s;
2133
+ }, [[], [], [], []]);
2134
+ }
2135
+ function Kr(o, t) {
2136
+ const e = [[], [], [], []], n = [];
2137
+ return Object.keys(o).forEach((r) => {
2138
+ const i = o[r], s = i.forw, a = i.bakw, c = [
2139
+ s[0] - t.forw[0],
2140
+ s[1] - t.forw[1]
2141
+ ], h = [
2142
+ a[0] - t.bakw[0],
2143
+ t.bakw[1] - a[1]
2144
+ ], u = { forw: c, bakw: h };
2145
+ if (n.push(u), c[0] === 0 || c[1] === 0)
2146
+ return;
2147
+ let f = 0;
2148
+ c[0] > 0 && (f += 1), c[1] > 0 && (f += 2), e[f].push(u);
2149
+ }), { perQuad: e, aggregate: n };
2150
+ }
2151
+ function Gr(o) {
2152
+ let t = 1 / 0, e = 0, n = 0;
2153
+ return o.forEach((r) => {
2154
+ const { forw: i, bakw: s } = r, a = Math.hypot(i[0], i[1]), c = Math.hypot(s[0], s[1]);
2155
+ if (c === 0) return;
2156
+ const h = a / c, u = Math.atan2(i[0], i[1]) - Math.atan2(s[0], s[1]);
2157
+ t = Math.min(t, h), e += Math.cos(u), n += Math.sin(u);
2158
+ }), isFinite(t) ? [t, Math.atan2(n, e)] : [1, 0];
2159
+ }
2160
+ function Ln(o, t, e) {
2161
+ const { perQuad: n, aggregate: r } = Kr(o, t), i = n.every((c) => c.length > 0), a = (e === "birdeye" ? i ? n : [r] : [r]).map((c) => Gr(c));
2162
+ return a.length === 1 ? [a[0], a[0], a[0], a[0]] : a;
2163
+ }
2164
+ function Qr(o, t, e) {
2165
+ const n = [1, 1, 1, 1];
2166
+ for (let r = 0; r < 4; r++) {
2167
+ const i = (r + 1) % 4, s = un([o[r].bakw, o[i].bakw]);
2168
+ t[r].map((a) => {
2169
+ const c = un([e.bakw, a.bakw]), h = Jr(s, c);
2170
+ if (h.features.length > 0 && h.features[0].geometry) {
2171
+ const u = h.features[0], f = Math.sqrt(
2172
+ Math.pow(a.bakw[0] - e.bakw[0], 2) + Math.pow(a.bakw[1] - e.bakw[1], 2)
2173
+ ), d = Math.sqrt(
2174
+ Math.pow(
2175
+ u.geometry.coordinates[0] - e.bakw[0],
2176
+ 2
2177
+ ) + Math.pow(
2178
+ u.geometry.coordinates[1] - e.bakw[1],
2179
+ 2
2180
+ )
2181
+ ), y = f / d;
2182
+ y > n[r] && (n[r] = y), y > n[i] && (n[i] = y);
2183
+ }
2184
+ });
2185
+ }
2186
+ o.forEach((r, i) => {
2187
+ const s = n[i], a = [
2188
+ (r.bakw[0] - e.bakw[0]) * s + e.bakw[0],
2189
+ (r.bakw[1] - e.bakw[1]) * s + e.bakw[1]
2190
+ ];
2191
+ r.bakw = a;
2192
+ });
1228
2193
  }
1229
- class Bs {
2194
+ function Dn(o, t, e, n) {
2195
+ const r = o.map((s, a) => {
2196
+ const c = t[a], h = [
2197
+ c[0] - e.forw[0],
2198
+ c[1] - e.forw[1]
2199
+ ], f = Math.sqrt(
2200
+ Math.pow(h[0], 2) + Math.pow(h[1], 2)
2201
+ ) / s[0], d = Math.atan2(h[0], h[1]) - s[1], y = [
2202
+ e.bakw[0] + f * Math.sin(d),
2203
+ e.bakw[1] - f * Math.cos(d)
2204
+ ];
2205
+ return { forw: c, bakw: y };
2206
+ }), i = r[2];
2207
+ return r[2] = r[3], r[3] = i, Qr(r, n, e), r;
2208
+ }
2209
+ function Hr(o) {
2210
+ const { convexBuf: t, centroid: e, bbox: n, minx: r, maxx: i, miny: s, maxy: a } = o, c = Fn(t, e, r, i, s, a), h = Ln(t, e, "plain");
2211
+ return Dn(h, n, e, c);
2212
+ }
2213
+ function Zr(o) {
2214
+ const { convexBuf: t, centroid: e, bbox: n, minx: r, maxx: i, miny: s, maxy: a } = o, c = Fn(t, e, r, i, s, a), h = Ln(t, e, "birdeye");
2215
+ return Dn(h, n, e, c);
2216
+ }
2217
+ function ti(o) {
2218
+ const e = new ei(o).findSegmentIntersections(), n = Un(e), r = /* @__PURE__ */ new Map();
2219
+ return n.forEach((i) => {
2220
+ r.set(`${i.x}:${i.y}`, i);
2221
+ }), Array.from(r.values()).map(
2222
+ (i) => de([i.x, i.y])
2223
+ );
2224
+ }
2225
+ class ei {
2226
+ /**
2227
+ * 座標データの配列
2228
+ * _xx, _yy: Float64Array形式で座標を保持
2229
+ * _ii: 各線分の開始インデックス
2230
+ * _nn: 各線分の頂点数
2231
+ */
2232
+ _xx;
2233
+ _yy;
2234
+ // coordinates data
2235
+ _ii;
2236
+ _nn;
2237
+ // indexes, sizes
2238
+ _zz;
2239
+ _zlimit = 0;
2240
+ // simplification
2241
+ _bb;
2242
+ _allBounds;
2243
+ // bounding boxes
2244
+ _arcIter;
2245
+ _filteredArcIter;
2246
+ // path iterators
2247
+ buf;
1230
2248
  /**
1231
2249
  * 線分群からArcCollectionを初期化
1232
2250
  * @param coords - 線分群の座標配列
1233
2251
  */
1234
2252
  constructor(t) {
1235
- /**
1236
- * 座標データの配列
1237
- * _xx, _yy: Float64Array形式で座標を保持
1238
- * _ii: 各線分の開始インデックス
1239
- * _nn: 各線分の頂点数
1240
- */
1241
- rt(this, "_xx");
1242
- rt(this, "_yy");
1243
- // coordinates data
1244
- rt(this, "_ii");
1245
- rt(this, "_nn");
1246
- // indexes, sizes
1247
- rt(this, "_zz");
1248
- rt(this, "_zlimit", 0);
1249
- // simplification
1250
- rt(this, "_bb");
1251
- rt(this, "_allBounds");
1252
- // bounding boxes
1253
- rt(this, "_arcIter");
1254
- rt(this, "_filteredArcIter");
1255
- // path iterators
1256
- rt(this, "buf");
1257
2253
  this.initArcs(t);
1258
2254
  }
1259
2255
  initArcs(t) {
1260
- const e = [], s = [], i = t.map((n) => {
1261
- const r = n ? n.length : 0;
1262
- for (let a = 0; a < r; a++)
1263
- e.push(n[a][0]), s.push(n[a][1]);
1264
- return r;
2256
+ const e = [], n = [], r = t.map((i) => {
2257
+ const s = i ? i.length : 0;
2258
+ for (let a = 0; a < s; a++)
2259
+ e.push(i[a][0]), n.push(i[a][1]);
2260
+ return s;
1265
2261
  });
1266
- this.initXYData(i, e, s);
2262
+ this.initXYData(r, e, n);
1267
2263
  }
1268
- initXYData(t, e, s) {
1269
- const i = t.length;
1270
- this._xx = new Float64Array(e), this._yy = new Float64Array(s), this._nn = new Uint32Array(t), this._zz = null, this._zlimit = 0, this._filteredArcIter = null, this._ii = new Uint32Array(i);
1271
- let n = 0;
1272
- for (let r = 0; r < i; r++)
1273
- this._ii[r] = n, n += t[r];
1274
- (n != this._xx.length || this._xx.length != this._yy.length) && be("ArcCollection#initXYData() Counting error"), this.initBounds(), this._arcIter = new sn(this._xx, this._yy);
2264
+ initXYData(t, e, n) {
2265
+ const r = t.length;
2266
+ this._xx = new Float64Array(e), this._yy = new Float64Array(n), this._nn = new Uint32Array(t), this._zz = null, this._zlimit = 0, this._filteredArcIter = null, this._ii = new Uint32Array(r);
2267
+ let i = 0;
2268
+ for (let s = 0; s < r; s++)
2269
+ this._ii[s] = i, i += t[s];
2270
+ (i != this._xx.length || this._xx.length != this._yy.length) && on("ArcCollection#initXYData() Counting error"), this.initBounds(), this._arcIter = new _i(this._xx, this._yy);
1275
2271
  }
1276
2272
  initBounds() {
1277
2273
  const t = this.calcArcBounds_(this._xx, this._yy, this._nn);
@@ -1281,14 +2277,14 @@ class Bs {
1281
2277
  * データの境界を計算
1282
2278
  * @returns バウンディングボックス情報
1283
2279
  */
1284
- calcArcBounds_(t, e, s) {
1285
- const i = s.length, n = new Float64Array(i * 4), r = new oe();
1286
- let a = 0, f, c, u;
1287
- for (let h = 0; h < i; h++)
1288
- f = s[h], f > 0 && (c = h * 4, u = nn(t, e, a, f), n[c++] = u[0], n[c++] = u[1], n[c++] = u[2], n[c] = u[3], a += f, r.mergeBounds(u));
2280
+ calcArcBounds_(t, e, n) {
2281
+ const r = n.length, i = new Float64Array(r * 4), s = new qe();
2282
+ let a = 0, c, h, u;
2283
+ for (let f = 0; f < r; f++)
2284
+ c = n[f], c > 0 && (h = f * 4, u = xi(t, e, a, c), i[h++] = u[0], i[h++] = u[1], i[h++] = u[2], i[h] = u[3], a += c, s.mergeBounds(u));
1289
2285
  return {
1290
- bb: n,
1291
- bounds: r
2286
+ bb: i,
2287
+ bounds: s
1292
2288
  };
1293
2289
  }
1294
2290
  getBounds() {
@@ -1297,8 +2293,8 @@ class Bs {
1297
2293
  // @cb function(i, j, xx, yy)
1298
2294
  forEachSegment(t) {
1299
2295
  let e = 0;
1300
- for (let s = 0, i = this.size(); s < i; s++)
1301
- e += this.forEachArcSegment(s, t);
2296
+ for (let n = 0, r = this.size(); n < r; n++)
2297
+ e += this.forEachArcSegment(n, t);
1302
2298
  return e;
1303
2299
  }
1304
2300
  size() {
@@ -1306,10 +2302,10 @@ class Bs {
1306
2302
  }
1307
2303
  // @cb function(i, j, xx, yy)
1308
2304
  forEachArcSegment(t, e) {
1309
- const s = t >= 0, i = s ? t : ~t, n = this.getRetainedInterval(), r = this._nn[i], a = s ? 1 : -1;
1310
- let f = s ? this._ii[i] : this._ii[i] + r - 1, c = f, u = 0;
1311
- for (let h = 1; h < r; h++)
1312
- c += a, (n === 0 || this._zz[c] >= n) && (e(f, c, this._xx, this._yy), f = c, u++);
2305
+ const n = t >= 0, r = n ? t : ~t, i = this.getRetainedInterval(), s = this._nn[r], a = n ? 1 : -1;
2306
+ let c = n ? this._ii[r] : this._ii[r] + s - 1, h = c, u = 0;
2307
+ for (let f = 1; f < s; f++)
2308
+ h += a, (i === 0 || this._zz[h] >= i) && (e(c, h, this._xx, this._yy), c = h, u++);
1313
2309
  return u;
1314
2310
  }
1315
2311
  getRetainedInterval() {
@@ -1333,12 +2329,12 @@ class Bs {
1333
2329
  // Return average magnitudes of dx, dy (with simplification)
1334
2330
  getAvgSegment2() {
1335
2331
  let t = 0, e = 0;
1336
- const s = this.forEachSegment(
1337
- (i, n, r, a) => {
1338
- t += Math.abs(r[i] - r[n]), e += Math.abs(a[i] - a[n]);
2332
+ const n = this.forEachSegment(
2333
+ (r, i, s, a) => {
2334
+ t += Math.abs(s[r] - s[i]), e += Math.abs(a[r] - a[i]);
1339
2335
  }
1340
2336
  );
1341
- return [t / s || 0, e / s || 0];
2337
+ return [t / n || 0, e / n || 0];
1342
2338
  }
1343
2339
  /**
1344
2340
  * 交差判定のためのストライプ数を計算
@@ -1346,8 +2342,8 @@ class Bs {
1346
2342
  */
1347
2343
  calcSegmentIntersectionStripeCount() {
1348
2344
  const t = this.getBounds().height(), e = this.getAvgSegment2()[1];
1349
- let s = 1;
1350
- return e > 0 && t > 0 && (s = Math.ceil(t / e / 20)), s || 1;
2345
+ let n = 1;
2346
+ return e > 0 && t > 0 && (n = Math.ceil(t / e / 20)), n || 1;
1351
2347
  }
1352
2348
  /**
1353
2349
  * 線分の交差を検出
@@ -1356,243 +2352,243 @@ class Bs {
1356
2352
  * @returns 検出された交差点の配列
1357
2353
  */
1358
2354
  findSegmentIntersections() {
1359
- const t = this.getBounds(), e = t.ymin, s = t.ymax - e, i = this.calcSegmentIntersectionStripeCount(), n = new Uint32Array(i), r = i > 1 ? (g) => Math.floor((i - 1) * (g - e) / s) : () => 0;
1360
- let a, f;
2355
+ const t = this.getBounds(), e = t.ymin, n = t.ymax - e, r = this.calcSegmentIntersectionStripeCount(), i = new Uint32Array(r), s = r > 1 ? (k) => Math.floor((r - 1) * (k - e) / n) : () => 0;
2356
+ let a, c;
1361
2357
  this.forEachSegment(
1362
- (g, b, w, S) => {
1363
- let _ = r(S[g]);
1364
- const v = r(S[b]);
1365
- for (; n[_] = n[_] + 2, _ != v; )
1366
- _ += v > _ ? 1 : -1;
2358
+ (k, X, C, m) => {
2359
+ let v = s(m[k]);
2360
+ const l = s(m[X]);
2361
+ for (; i[v] = i[v] + 2, v != l; )
2362
+ v += l > v ? 1 : -1;
1367
2363
  }
1368
2364
  );
1369
- const c = this.getUint32Array(js(n));
2365
+ const h = this.getUint32Array(ii(i));
1370
2366
  let u = 0;
1371
- const h = [];
1372
- Ls(n, (g) => {
1373
- const b = u;
1374
- u += g, h.push(c.subarray(b, u));
1375
- }), Vs(n, 0), this.forEachSegment(
1376
- (g, b, w, S) => {
1377
- let _ = r(S[g]);
1378
- const v = r(S[b]);
1379
- let T, I;
1380
- for (; T = n[_], n[_] = T + 2, I = h[_], I[T] = g, I[T + 1] = b, _ != v; )
1381
- _ += v > _ ? 1 : -1;
2367
+ const f = [];
2368
+ si(i, (k) => {
2369
+ const X = u;
2370
+ u += k, f.push(h.subarray(X, u));
2371
+ }), oi(i, 0), this.forEachSegment(
2372
+ (k, X, C, m) => {
2373
+ let v = s(m[k]);
2374
+ const l = s(m[X]);
2375
+ let g, x;
2376
+ for (; g = i[v], i[v] = g + 2, x = f[v], x[g] = k, x[g + 1] = X, v != l; )
2377
+ v += l > v ? 1 : -1;
1382
2378
  }
1383
2379
  );
1384
- const l = this.getVertexData(), p = [];
1385
- let y;
1386
- for (a = 0; a < i; a++)
1387
- for (y = Ws(h[a], l.xx, l.yy), f = 0; f < y.length; f++)
1388
- p.push(y[f]);
1389
- return Ke(p);
2380
+ const d = this.getVertexData(), y = [];
2381
+ let E;
2382
+ for (a = 0; a < r; a++)
2383
+ for (E = ai(f[a], d.xx, d.yy), c = 0; c < E.length; c++)
2384
+ y.push(E[c]);
2385
+ return Un(y);
1390
2386
  }
1391
2387
  }
1392
- function be(...o) {
2388
+ function on(...o) {
1393
2389
  const t = o.join(" ");
1394
2390
  throw new Error(t);
1395
2391
  }
1396
- function ye(o) {
1397
- return o ? Fs(o) ? !0 : Ds(o) ? !1 : o.length === 0 ? !0 : o.length > 0 : !1;
2392
+ function an(o) {
2393
+ return o ? ri(o) ? !0 : ni(o) ? !1 : o.length === 0 ? !0 : o.length > 0 : !1;
1398
2394
  }
1399
- function Ds(o) {
2395
+ function ni(o) {
1400
2396
  return o != null && o.toString === String.prototype.toString;
1401
2397
  }
1402
- function Fs(o) {
2398
+ function ri(o) {
1403
2399
  return Array.isArray(o);
1404
2400
  }
1405
- function js(o, t) {
1406
- ye(o) || be("utils.sum() expects an array, received:", o);
1407
- let e = 0, s;
1408
- for (let i = 0, n = o.length; i < n; i++)
1409
- s = o[i], s && (e += s);
2401
+ function ii(o, t) {
2402
+ an(o) || on("utils.sum() expects an array, received:", o);
2403
+ let e = 0, n;
2404
+ for (let r = 0, i = o.length; r < i; r++)
2405
+ n = o[r], n && (e += n);
1410
2406
  return e;
1411
2407
  }
1412
- function Ls(o, t, e) {
1413
- if (!ye(o))
2408
+ function si(o, t, e) {
2409
+ if (!an(o))
1414
2410
  throw new Error(`#forEach() takes an array-like argument. ${o}`);
1415
- for (let s = 0, i = o.length; s < i; s++)
1416
- t.call(e, o[s], s);
2411
+ for (let n = 0, r = o.length; n < r; n++)
2412
+ t.call(e, o[n], n);
1417
2413
  }
1418
- function Vs(o, t) {
1419
- for (let e = 0, s = o.length; e < s; e++)
2414
+ function oi(o, t) {
2415
+ for (let e = 0, n = o.length; e < n; e++)
1420
2416
  o[e] = t;
1421
2417
  return o;
1422
2418
  }
1423
- function Ws(o, t, e) {
1424
- const s = o.length - 2, i = [];
1425
- let n, r, a, f, c, u, h, l, p, y, g, b, w, S, _, v, T;
1426
- for (Qs(t, o), v = 0; v < s; ) {
1427
- for (n = o[v], r = o[v + 1], c = t[n], u = t[r], p = e[n], y = e[r], T = v; T < s && (T += 2, a = o[T], h = t[a], !(u < h)); ) {
1428
- if (g = e[a], f = o[T + 1], l = t[f], b = e[f], p >= g) {
1429
- if (p > b && y > g && y > b) continue;
1430
- } else if (p < b && y < g && y < b) continue;
1431
- n == a || n == f || r == a || r == f || (w = zs(
1432
- c,
1433
- p,
1434
- u,
1435
- y,
2419
+ function ai(o, t, e) {
2420
+ const n = o.length - 2, r = [];
2421
+ let i, s, a, c, h, u, f, d, y, E, k, X, C, m, v, l, g;
2422
+ for (wi(t, o), l = 0; l < n; ) {
2423
+ for (i = o[l], s = o[l + 1], h = t[i], u = t[s], y = e[i], E = e[s], g = l; g < n && (g += 2, a = o[g], f = t[a], !(u < f)); ) {
2424
+ if (k = e[a], c = o[g + 1], d = t[c], X = e[c], y >= k) {
2425
+ if (y > X && E > k && E > X) continue;
2426
+ } else if (y < X && E < k && E < X) continue;
2427
+ i == a || i == c || s == a || s == c || (C = ci(
1436
2428
  h,
1437
- g,
1438
- l,
1439
- b
1440
- ), w && (S = [n, r], _ = [a, f], i.push(Ue(w, S, _, t, e)), w.length == 4 && i.push(
1441
- Ue(w.slice(2), S, _, t, e)
2429
+ y,
2430
+ u,
2431
+ E,
2432
+ f,
2433
+ k,
2434
+ d,
2435
+ X
2436
+ ), C && (m = [i, s], v = [a, c], r.push(An(C, m, v, t, e)), C.length == 4 && r.push(
2437
+ An(C.slice(2), m, v, t, e)
1442
2438
  )));
1443
2439
  }
1444
- v += 2;
2440
+ l += 2;
1445
2441
  }
1446
- return i;
2442
+ return r;
1447
2443
  }
1448
- function zs(o, t, e, s, i, n, r, a) {
1449
- const f = Xs(o, t, e, s, i, n, r, a);
1450
- let c = null;
1451
- return f && (c = Ys(o, t, e, s, i, n, r, a), c ? Ks(o, t, e, s, i, n, r, a) && (c = null) : c = Gs(o, t, e, s, i, n, r, a)), c;
2444
+ function ci(o, t, e, n, r, i, s, a) {
2445
+ const c = hi(o, t, e, n, r, i, s, a);
2446
+ let h = null;
2447
+ return c && (h = fi(o, t, e, n, r, i, s, a), h ? gi(o, t, e, n, r, i, s, a) && (h = null) : h = mi(o, t, e, n, r, i, s, a)), h;
1452
2448
  }
1453
- function Xs(o, t, e, s, i, n, r, a) {
1454
- return qt(o, t, e, s, i, n) * qt(o, t, e, s, r, a) <= 0 && qt(i, n, r, a, o, t) * qt(i, n, r, a, e, s) <= 0;
2449
+ function hi(o, t, e, n, r, i, s, a) {
2450
+ return ke(o, t, e, n, r, i) * ke(o, t, e, n, s, a) <= 0 && ke(r, i, s, a, o, t) * ke(r, i, s, a, e, n) <= 0;
1455
2451
  }
1456
- function qt(o, t, e, s, i, n) {
1457
- return He(o - i, t - n, e - i, s - n);
2452
+ function ke(o, t, e, n, r, i) {
2453
+ return $n(o - r, t - i, e - r, n - i);
1458
2454
  }
1459
- function He(o, t, e, s) {
1460
- return o * s - t * e;
2455
+ function $n(o, t, e, n) {
2456
+ return o * n - t * e;
1461
2457
  }
1462
- function Ys(o, t, e, s, i, n, r, a) {
1463
- let f = ee(o, t, e, s, i, n, r, a), c;
1464
- return f && (c = qs(f[0], f[1], o, t, e, s, i, n, r, a), c == 1 ? f = ee(e, s, o, t, i, n, r, a) : c == 2 ? f = ee(i, n, r, a, o, t, e, s) : c == 3 && (f = ee(r, a, i, n, o, t, e, s))), f && Hs(f, o, t, e, s, i, n, r, a), f;
2458
+ function fi(o, t, e, n, r, i, s, a) {
2459
+ let c = Re(o, t, e, n, r, i, s, a), h;
2460
+ return c && (h = li(c[0], c[1], o, t, e, n, r, i, s, a), h == 1 ? c = Re(e, n, o, t, r, i, s, a) : h == 2 ? c = Re(r, i, s, a, o, t, e, n) : h == 3 && (c = Re(s, a, r, i, o, t, e, n))), c && di(c, o, t, e, n, r, i, s, a), c;
1465
2461
  }
1466
- function ee(o, t, e, s, i, n, r, a) {
1467
- const f = He(e - o, s - t, r - i, a - n), c = 1e-18;
2462
+ function Re(o, t, e, n, r, i, s, a) {
2463
+ const c = $n(e - o, n - t, s - r, a - i), h = 1e-18;
1468
2464
  let u;
1469
- if (f === 0) return null;
1470
- const h = qt(i, n, r, a, o, t) / f;
1471
- return f <= c && f >= -c ? u = Cs(o, t, e, s, i, n, r, a) : u = [o + h * (e - o), t + h * (s - t)], u;
2465
+ if (c === 0) return null;
2466
+ const f = ke(r, i, s, a, o, t) / c;
2467
+ return c <= h && c >= -h ? u = ui(o, t, e, n, r, i, s, a) : u = [o + f * (e - o), t + f * (n - t)], u;
1472
2468
  }
1473
- function Cs(o, t, e, s, i, n, r, a) {
1474
- let f = null;
1475
- return !vt(o, i, r) && !vt(t, n, a) ? f = [o, t] : !vt(e, i, r) && !vt(s, n, a) ? f = [e, s] : !vt(i, o, e) && !vt(n, t, s) ? f = [i, n] : !vt(r, o, e) && !vt(a, t, s) && (f = [r, a]), f;
2469
+ function ui(o, t, e, n, r, i, s, a) {
2470
+ let c = null;
2471
+ return !ne(o, r, s) && !ne(t, i, a) ? c = [o, t] : !ne(e, r, s) && !ne(n, i, a) ? c = [e, n] : !ne(r, o, e) && !ne(i, t, n) ? c = [r, i] : !ne(s, o, e) && !ne(a, t, n) && (c = [s, a]), c;
1476
2472
  }
1477
- function vt(o, t, e) {
1478
- let s;
1479
- return t < e ? s = o < t || o > e : t > e ? s = o > t || o < e : s = o != t, s;
2473
+ function ne(o, t, e) {
2474
+ let n;
2475
+ return t < e ? n = o < t || o > e : t > e ? n = o > t || o < e : n = o != t, n;
1480
2476
  }
1481
- function qs(o, t, ...e) {
1482
- let s = -1, i = 1 / 0, n;
1483
- for (let r = 0, a = 0, f = e.length; a < f; r++, a += 2)
1484
- n = Js(o, t, e[a], e[a + 1]), n < i && (i = n, s = r);
1485
- return s;
2477
+ function li(o, t, ...e) {
2478
+ let n = -1, r = 1 / 0, i;
2479
+ for (let s = 0, a = 0, c = e.length; a < c; s++, a += 2)
2480
+ i = pi(o, t, e[a], e[a + 1]), i < r && (r = i, n = s);
2481
+ return n;
1486
2482
  }
1487
- function Js(o, t, e, s) {
1488
- const i = o - e, n = t - s;
1489
- return i * i + n * n;
2483
+ function pi(o, t, e, n) {
2484
+ const r = o - e, i = t - n;
2485
+ return r * r + i * i;
1490
2486
  }
1491
- function Hs(o, t, e, s, i, n, r, a, f) {
1492
- let c = o[0], u = o[1];
1493
- c = se(c, t, s), c = se(c, n, a), u = se(u, e, i), u = se(u, r, f), o[0] = c, o[1] = u;
2487
+ function di(o, t, e, n, r, i, s, a, c) {
2488
+ let h = o[0], u = o[1];
2489
+ h = Ce(h, t, n), h = Ce(h, i, a), u = Ce(u, e, r), u = Ce(u, s, c), o[0] = h, o[1] = u;
1494
2490
  }
1495
- function se(o, t, e) {
1496
- let s;
1497
- return vt(o, t, e) && (s = Math.abs(o - t) < Math.abs(o - e) ? t : e, o = s), o;
2491
+ function Ce(o, t, e) {
2492
+ let n;
2493
+ return ne(o, t, e) && (n = Math.abs(o - t) < Math.abs(o - e) ? t : e, o = n), o;
1498
2494
  }
1499
- function Gs(o, t, e, s, i, n, r, a) {
1500
- const f = Math.min(o, e, i, r), c = Math.max(o, e, i, r), u = Math.min(t, s, n, a), h = Math.max(t, s, n, a), l = h - u > c - f;
1501
- let p = [];
1502
- return (l ? Nt(t, u, h) : Nt(o, f, c)) && p.push(o, t), (l ? Nt(s, u, h) : Nt(e, f, c)) && p.push(e, s), (l ? Nt(n, u, h) : Nt(i, f, c)) && p.push(i, n), (l ? Nt(a, u, h) : Nt(r, f, c)) && p.push(r, a), (p.length != 2 && p.length != 4 || p.length == 4 && p[0] == p[2] && p[1] == p[3]) && (p = null), p;
2495
+ function mi(o, t, e, n, r, i, s, a) {
2496
+ const c = Math.min(o, e, r, s), h = Math.max(o, e, r, s), u = Math.min(t, n, i, a), f = Math.max(t, n, i, a), d = f - u > h - c;
2497
+ let y = [];
2498
+ return (d ? ae(t, u, f) : ae(o, c, h)) && y.push(o, t), (d ? ae(n, u, f) : ae(e, c, h)) && y.push(e, n), (d ? ae(i, u, f) : ae(r, c, h)) && y.push(r, i), (d ? ae(a, u, f) : ae(s, c, h)) && y.push(s, a), (y.length != 2 && y.length != 4 || y.length == 4 && y[0] == y[2] && y[1] == y[3]) && (y = null), y;
1503
2499
  }
1504
- function Ks(o, t, e, s, i, n, r, a) {
1505
- return o == i && t == n || o == r && t == a || e == i && s == n || e == r && s == a;
2500
+ function gi(o, t, e, n, r, i, s, a) {
2501
+ return o == r && t == i || o == s && t == a || e == r && n == i || e == s && n == a;
1506
2502
  }
1507
- function Nt(o, t, e) {
2503
+ function ae(o, t, e) {
1508
2504
  return o > t && o < e;
1509
2505
  }
1510
- function Qs(o, t) {
1511
- Zs(o, t), Ge(o, t, 0, t.length - 2);
2506
+ function wi(o, t) {
2507
+ yi(o, t), qn(o, t, 0, t.length - 2);
1512
2508
  }
1513
- function Zs(o, t) {
1514
- for (let e = 0, s = t.length; e < s; e += 2)
1515
- o[t[e]] > o[t[e + 1]] && tn(t, e, e + 1);
2509
+ function yi(o, t) {
2510
+ for (let e = 0, n = t.length; e < n; e += 2)
2511
+ o[t[e]] > o[t[e + 1]] && vi(t, e, e + 1);
1516
2512
  }
1517
- function tn(o, t, e) {
1518
- const s = o[t];
1519
- o[t] = o[e], o[e] = s;
2513
+ function vi(o, t, e) {
2514
+ const n = o[t];
2515
+ o[t] = o[e], o[e] = n;
1520
2516
  }
1521
- function Ge(o, t, e, s) {
1522
- let i = e, n = s, r, a;
1523
- for (; i < s; ) {
1524
- for (r = o[t[e + s >> 2 << 1]]; i <= n; ) {
1525
- for (; o[t[i]] < r; ) i += 2;
1526
- for (; o[t[n]] > r; ) n -= 2;
1527
- i <= n && (a = t[i], t[i] = t[n], t[n] = a, a = t[i + 1], t[i + 1] = t[n + 1], t[n + 1] = a, i += 2, n -= 2);
2517
+ function qn(o, t, e, n) {
2518
+ let r = e, i = n, s, a;
2519
+ for (; r < n; ) {
2520
+ for (s = o[t[e + n >> 2 << 1]]; r <= i; ) {
2521
+ for (; o[t[r]] < s; ) r += 2;
2522
+ for (; o[t[i]] > s; ) i -= 2;
2523
+ r <= i && (a = t[r], t[r] = t[i], t[i] = a, a = t[r + 1], t[r + 1] = t[i + 1], t[i + 1] = a, r += 2, i -= 2);
1528
2524
  }
1529
- if (n - e < 40 ? Ne(o, t, e, n) : Ge(o, t, e, n), s - i < 40) {
1530
- Ne(o, t, i, s);
2525
+ if (i - e < 40 ? En(o, t, e, i) : qn(o, t, e, i), n - r < 40) {
2526
+ En(o, t, r, n);
1531
2527
  return;
1532
2528
  }
1533
- e = i, n = s;
2529
+ e = r, i = n;
1534
2530
  }
1535
2531
  }
1536
- function Ne(o, t, e, s) {
1537
- let i, n;
1538
- for (let r = e + 2; r <= s; r += 2) {
1539
- i = t[r], n = t[r + 1];
2532
+ function En(o, t, e, n) {
2533
+ let r, i;
2534
+ for (let s = e + 2; s <= n; s += 2) {
2535
+ r = t[s], i = t[s + 1];
1540
2536
  let a;
1541
- for (a = r - 2; a >= e && o[i] < o[t[a]]; a -= 2)
2537
+ for (a = s - 2; a >= e && o[r] < o[t[a]]; a -= 2)
1542
2538
  t[a + 2] = t[a], t[a + 3] = t[a + 1];
1543
- t[a + 2] = i, t[a + 3] = n;
2539
+ t[a + 2] = r, t[a + 3] = i;
1544
2540
  }
1545
2541
  }
1546
- function Ue(o, t, e, s, i) {
1547
- const n = o[0], r = o[1];
1548
- t = Be(n, r, t[0], t[1], s, i), e = Be(n, r, e[0], e[1], s, i);
1549
- const a = t[0] < e[0] ? t : e, f = a == t ? e : t;
1550
- return { x: n, y: r, a, b: f };
2542
+ function An(o, t, e, n, r) {
2543
+ const i = o[0], s = o[1];
2544
+ t = Pn(i, s, t[0], t[1], n, r), e = Pn(i, s, e[0], e[1], n, r);
2545
+ const a = t[0] < e[0] ? t : e, c = a == t ? e : t;
2546
+ return { x: i, y: s, a, b: c };
1551
2547
  }
1552
- function Be(o, t, e, s, i, n) {
1553
- let r = e < s ? e : s, a = r === e ? s : e;
1554
- return i[r] == o && n[r] == t ? a = r : i[a] == o && n[a] == t && (r = a), [r, a];
2548
+ function Pn(o, t, e, n, r, i) {
2549
+ let s = e < n ? e : n, a = s === e ? n : e;
2550
+ return r[s] == o && i[s] == t ? a = s : r[a] == o && i[a] == t && (s = a), [s, a];
1555
2551
  }
1556
- function Ke(o) {
2552
+ function Un(o) {
1557
2553
  const t = {};
1558
2554
  return o.filter((e) => {
1559
- const s = en(e);
1560
- return s in t ? !1 : (t[s] = !0, !0);
2555
+ const n = bi(e);
2556
+ return n in t ? !1 : (t[n] = !0, !0);
1561
2557
  });
1562
2558
  }
1563
- function en(o) {
2559
+ function bi(o) {
1564
2560
  return `${o.a.join(",")};${o.b.join(",")}`;
1565
2561
  }
1566
- class sn {
2562
+ class _i {
2563
+ _i = 0;
2564
+ _n = 0;
2565
+ _inc = 1;
2566
+ _xx;
2567
+ _yy;
2568
+ i = 0;
2569
+ x = 0;
2570
+ y = 0;
1567
2571
  constructor(t, e) {
1568
- rt(this, "_i", 0);
1569
- rt(this, "_n", 0);
1570
- rt(this, "_inc", 1);
1571
- rt(this, "_xx");
1572
- rt(this, "_yy");
1573
- rt(this, "i", 0);
1574
- rt(this, "x", 0);
1575
- rt(this, "y", 0);
1576
2572
  this._xx = t, this._yy = e;
1577
2573
  }
1578
2574
  }
1579
- function nn(o, t, e, s) {
1580
- let i = e | 0;
1581
- const n = isNaN(s) ? o.length - i : s + i;
1582
- let r, a, f, c, u, h;
1583
- if (n > 0)
1584
- f = u = o[i], c = h = t[i];
2575
+ function xi(o, t, e, n) {
2576
+ let r = e | 0;
2577
+ const i = isNaN(n) ? o.length - r : n + r;
2578
+ let s, a, c, h, u, f;
2579
+ if (i > 0)
2580
+ c = u = o[r], h = f = t[r];
1585
2581
  else return [void 0, void 0, void 0, void 0];
1586
- for (i++; i < n; i++)
1587
- r = o[i], a = t[i], r < f && (f = r), r > u && (u = r), a < c && (c = a), a > h && (h = a);
1588
- return [f, c, u, h];
1589
- }
1590
- class oe {
2582
+ for (r++; r < i; r++)
2583
+ s = o[r], a = t[r], s < c && (c = s), s > u && (u = s), a < h && (h = a), a > f && (f = a);
2584
+ return [c, h, u, f];
2585
+ }
2586
+ class qe {
2587
+ xmin;
2588
+ ymin;
2589
+ xmax;
2590
+ ymax;
1591
2591
  constructor(...t) {
1592
- rt(this, "xmin");
1593
- rt(this, "ymin");
1594
- rt(this, "xmax");
1595
- rt(this, "ymax");
1596
2592
  t.length > 0 && this.setBounds(t);
1597
2593
  }
1598
2594
  // Return a bounding box with the same extent as this one.
@@ -1600,7 +2596,7 @@ class oe {
1600
2596
  return this.clone();
1601
2597
  }
1602
2598
  clone() {
1603
- return new oe(this.xmin, this.ymin, this.xmax, this.ymax);
2599
+ return new qe(this.xmin, this.ymin, this.xmax, this.ymax);
1604
2600
  }
1605
2601
  width() {
1606
2602
  return this.xmax - this.xmin || 0;
@@ -1608,19 +2604,19 @@ class oe {
1608
2604
  height() {
1609
2605
  return this.ymax - this.ymin || 0;
1610
2606
  }
1611
- setBounds(t, e, s, i) {
1612
- return arguments.length == 1 && (ye(t) ? (e = t[1], s = t[2], i = t[3], t = t[0]) : (e = t.ymin, s = t.xmax, i = t.ymax, t = t.xmin)), this.xmin = t, this.ymin = e, this.xmax = s, this.ymax = i, (t > s || e > i) && this.update(), this;
2607
+ setBounds(t, e, n, r) {
2608
+ return arguments.length == 1 && (an(t) ? (e = t[1], n = t[2], r = t[3], t = t[0]) : (e = t.ymin, n = t.xmax, r = t.ymax, t = t.xmin)), this.xmin = t, this.ymin = e, this.xmax = n, this.ymax = r, (t > n || e > r) && this.update(), this;
1613
2609
  }
1614
2610
  update() {
1615
2611
  let t;
1616
2612
  this.xmin > this.xmax && (t = this.xmin, this.xmin = this.xmax, this.xmax = t), this.ymin > this.ymax && (t = this.ymin, this.ymin = this.ymax, this.ymax = t);
1617
2613
  }
1618
2614
  mergeBounds(t, ...e) {
1619
- let s, i, n, r;
1620
- return t instanceof oe ? (s = t.xmin, i = t.ymin, n = t.xmax, r = t.ymax) : e.length == 3 ? (s = t, i = e[0], n = e[1], r = e[2]) : t.length == 4 ? (s = t[0], i = t[1], n = t[2], r = t[3]) : be("Bounds#mergeBounds() invalid argument:", t), this.xmin === void 0 ? this.setBounds(s, i, n, r) : (s < this.xmin && (this.xmin = s), i < this.ymin && (this.ymin = i), n > this.xmax && (this.xmax = n), r > this.ymax && (this.ymax = r)), this;
2615
+ let n, r, i, s;
2616
+ return t instanceof qe ? (n = t.xmin, r = t.ymin, i = t.xmax, s = t.ymax) : e.length == 3 ? (n = t, r = e[0], i = e[1], s = e[2]) : t.length == 4 ? (n = t[0], r = t[1], i = t[2], s = t[3]) : on("Bounds#mergeBounds() invalid argument:", t), this.xmin === void 0 ? this.setBounds(n, r, i, s) : (n < this.xmin && (this.xmin = n), r < this.ymin && (this.ymin = r), i > this.xmax && (this.xmax = i), s > this.ymax && (this.ymax = s)), this;
1621
2617
  }
1622
2618
  }
1623
- function De(o) {
2619
+ function Ue(o) {
1624
2620
  const t = ["a", "b", "c"].map(
1625
2621
  (e) => o.properties[e].index
1626
2622
  );
@@ -1630,565 +2626,618 @@ function De(o) {
1630
2626
  [1, 2],
1631
2627
  [0, 1, 2]
1632
2628
  ].map(
1633
- (e) => e.map((s) => t[s]).sort().join("-")
2629
+ (e) => e.map((n) => t[n]).sort().join("-")
1634
2630
  ).sort();
1635
2631
  }
1636
- function rn(o, t, e) {
1637
- const s = De(t.forw), i = De(t.bakw);
1638
- if (JSON.stringify(s) != JSON.stringify(i))
2632
+ function jn(o, t, e) {
2633
+ const n = Ue(t.forw), r = Ue(t.bakw);
2634
+ if (JSON.stringify(n) != JSON.stringify(r))
1639
2635
  throw `${JSON.stringify(t, null, 2)}
1640
2636
  ${JSON.stringify(
1641
- s
2637
+ n
1642
2638
  )}
1643
- ${JSON.stringify(i)}`;
1644
- for (let n = 0; n < s.length; n++) {
1645
- const r = s[n];
1646
- o[r] || (o[r] = []), o[r].push(t);
2639
+ ${JSON.stringify(r)}`;
2640
+ for (let i = 0; i < n.length; i++) {
2641
+ const s = n[i];
2642
+ o[s] || (o[s] = []), o[s].push(t);
1647
2643
  }
1648
2644
  e && (e.forw.features.push(t.forw), e.bakw.features.push(t.bakw));
1649
2645
  }
1650
- function ne(o, t, e) {
1651
- return Jt(o, { target: { geom: t, index: e } });
2646
+ function Bn(o, t, e) {
2647
+ const n = Ue(t.forw), r = Ue(t.bakw);
2648
+ if (JSON.stringify(n) != JSON.stringify(r))
2649
+ throw `${JSON.stringify(t, null, 2)}
2650
+ ${JSON.stringify(n)}
2651
+ ${JSON.stringify(r)}`;
2652
+ if (n.forEach((i) => {
2653
+ const s = o[i];
2654
+ if (!s) return;
2655
+ const a = s.filter((c) => c !== t);
2656
+ a.length === 0 ? delete o[i] : o[i] = a;
2657
+ }), e) {
2658
+ const i = (s, a) => {
2659
+ !s || !a || (s.features = s.features.filter((c) => c !== a));
2660
+ };
2661
+ i(e.forw, t.forw), i(e.bakw, t.bakw);
2662
+ }
2663
+ }
2664
+ function Fe(o, t, e) {
2665
+ return de(o, { target: { geom: t, index: e } });
1652
2666
  }
1653
- function ie(o) {
1654
- return Jt(o.properties.target.geom, {
2667
+ function Le(o) {
2668
+ return de(o.properties.target.geom, {
1655
2669
  target: {
1656
2670
  geom: o.geometry.coordinates,
1657
2671
  index: o.properties.target.index
1658
2672
  }
1659
2673
  });
1660
2674
  }
1661
- function Fe(o, t) {
2675
+ function On(o, t) {
1662
2676
  const e = t.geometry.coordinates;
1663
- return [0, 1, 2, 3].map((s) => {
1664
- const i = (s + 1) % 4, n = o[s], r = o[i], a = n.geometry.coordinates, f = Math.atan2(
2677
+ return [0, 1, 2, 3].map((n) => {
2678
+ const r = (n + 1) % 4, i = o[n], s = o[r], a = i.geometry.coordinates, c = Math.atan2(
1665
2679
  a[0] - e[0],
1666
2680
  a[1] - e[1]
1667
- ), c = [t, n, r, t].map(
1668
- (l) => l.geometry.coordinates
2681
+ ), h = [t, i, s, t].map(
2682
+ (d) => d.geometry.coordinates
1669
2683
  ), u = {
1670
2684
  a: {
1671
2685
  geom: t.properties.target.geom,
1672
2686
  index: t.properties.target.index
1673
2687
  },
1674
2688
  b: {
1675
- geom: n.properties.target.geom,
1676
- index: n.properties.target.index
2689
+ geom: i.properties.target.geom,
2690
+ index: i.properties.target.index
1677
2691
  },
1678
2692
  c: {
1679
- geom: r.properties.target.geom,
1680
- index: r.properties.target.index
2693
+ geom: s.properties.target.geom,
2694
+ index: s.properties.target.index
1681
2695
  }
1682
- }, h = Ot([
1683
- me([c], u)
2696
+ }, f = Kt([
2697
+ Ee([h], u)
1684
2698
  ]);
1685
- return [f, h];
2699
+ return [c, f];
1686
2700
  }).reduce(
1687
- (s, i) => (s[0].push(i[0]), s[1].push(i[1]), s),
2701
+ (n, r) => (n[0].push(r[0]), n[1].push(r[1]), n),
1688
2702
  [[], []]
1689
2703
  );
1690
2704
  }
1691
- const je = we;
1692
- class ht extends _s {
2705
+ function Mi(o) {
2706
+ const { tins: t, targets: e, includeReciprocals: n } = o, r = {};
2707
+ e.forEach((s) => {
2708
+ const a = t[s];
2709
+ if (!a || !a.features) return;
2710
+ r[s] = {};
2711
+ const c = {};
2712
+ a.features.forEach((h) => {
2713
+ const u = ["a", "b", "c"];
2714
+ for (let f = 0; f < 3; f++) {
2715
+ const d = (f + 1) % 3, y = u[f], E = u[d], k = h.properties[y].index, X = h.properties[E].index, C = [k, X].sort().join("-");
2716
+ if (c[C]) continue;
2717
+ c[C] = !0;
2718
+ const m = h.geometry.coordinates[0][f], v = h.geometry.coordinates[0][d], l = h.properties[y].geom, g = h.properties[E].geom, x = Math.sqrt(
2719
+ Math.pow(l[0] - g[0], 2) + Math.pow(l[1] - g[1], 2)
2720
+ ) / Math.sqrt(
2721
+ Math.pow(m[0] - v[0], 2) + Math.pow(m[1] - v[1], 2)
2722
+ ), A = r[s];
2723
+ A[`${k}:${C}`] = x, A[`${X}:${C}`] = x;
2724
+ }
2725
+ });
2726
+ });
2727
+ const i = {};
2728
+ return n && (i.bakw = {}), e.forEach((s) => {
2729
+ const a = r[s];
2730
+ if (i[s] = {}, !a)
2731
+ return;
2732
+ const c = {};
2733
+ Object.keys(a).forEach((u) => {
2734
+ const [f] = u.split(":");
2735
+ c[f] || (c[f] = []), c[f].push(a[u]);
2736
+ }), Object.keys(c).forEach((u) => {
2737
+ const f = c[u], d = f.reduce((y, E) => y + E, 0) / f.length;
2738
+ i[s][u] = d, n && i.bakw && (i.bakw[u] = 1 / d);
2739
+ });
2740
+ let h = 0;
2741
+ for (let u = 0; u < 4; u++) {
2742
+ const f = `b${u}`, d = i[s][f] || 0;
2743
+ h += d;
2744
+ }
2745
+ i[s].c = h / 4, n && i.bakw && (i.bakw.c = 1 / i[s].c);
2746
+ }), i;
2747
+ }
2748
+ function ki(o, t) {
2749
+ const e = o.split("-");
2750
+ if (e.length !== 2 || !e.every((i) => /^-?\d+$/.test(i))) return !1;
2751
+ const [n, r] = e.map((i) => parseInt(i, 10)).sort((i, s) => i - s);
2752
+ return t.some((i) => {
2753
+ if (i.length !== 2) return !1;
2754
+ const s = i.map((c) => parseInt(`${c}`, 10));
2755
+ if (s.some((c) => Number.isNaN(c))) return !1;
2756
+ const a = s.sort((c, h) => c - h);
2757
+ return a[0] === n && a[1] === r;
2758
+ });
2759
+ }
2760
+ function De(o) {
2761
+ return ["a", "b", "c"].map((t, e) => ({
2762
+ prop: o.properties[t],
2763
+ geom: o.geometry.coordinates[0][e]
2764
+ }));
2765
+ }
2766
+ function Si(o, t, e) {
2767
+ const n = /* @__PURE__ */ new Set();
2768
+ let r = !1;
2769
+ const i = Object.keys(t);
2770
+ for (const s of i) {
2771
+ if (n.has(s)) continue;
2772
+ n.add(s);
2773
+ const a = t[s];
2774
+ if (!a || a.length < 2) continue;
2775
+ const c = s.split("-");
2776
+ if (c.length !== 2 || ki(s, e)) continue;
2777
+ const h = De(a[0].bakw), u = De(a[1].bakw), f = De(a[0].forw), d = De(a[1].forw), y = c.map(
2778
+ (b) => h.find((T) => `${T.prop.index}` === b) || u.find((T) => `${T.prop.index}` === b)
2779
+ ), E = c.map(
2780
+ (b) => f.find((T) => `${T.prop.index}` === b) || d.find((T) => `${T.prop.index}` === b)
2781
+ );
2782
+ if (y.some((b) => !b) || E.some((b) => !b))
2783
+ continue;
2784
+ const k = [h, u].map(
2785
+ (b) => b.find((T) => !c.includes(`${T.prop.index}`))
2786
+ ), X = [f, d].map(
2787
+ (b) => b.find((T) => !c.includes(`${T.prop.index}`))
2788
+ );
2789
+ if (k.some((b) => !b) || X.some((b) => !b))
2790
+ continue;
2791
+ const C = a[0].bakw.geometry.coordinates[0].slice(0, 3).map((b) => ge(b)), m = a[1].bakw.geometry.coordinates[0].slice(0, 3).map((b) => ge(b));
2792
+ if (!(In(
2793
+ ge(k[0].geom),
2794
+ m
2795
+ ) || In(
2796
+ ge(k[1].geom),
2797
+ C
2798
+ )))
2799
+ continue;
2800
+ const l = E.map(
2801
+ (b) => ge(b.geom)
2802
+ ), g = X.map(
2803
+ (b) => ge(b.geom)
2804
+ ), x = Ei([
2805
+ ...l,
2806
+ ...g
2807
+ ]), A = Ai(x), I = Tn(
2808
+ l[0],
2809
+ l[1],
2810
+ g[0]
2811
+ ) + Tn(
2812
+ l[0],
2813
+ l[1],
2814
+ g[1]
2815
+ );
2816
+ nn(A, I) && (Bn(t, a[0], o), Bn(t, a[1], o), y.forEach((b) => {
2817
+ if (!b) return;
2818
+ const T = [
2819
+ b.geom,
2820
+ k[0].geom,
2821
+ k[1].geom,
2822
+ b.geom
2823
+ ], R = {
2824
+ a: b.prop,
2825
+ b: k[0].prop,
2826
+ c: k[1].prop
2827
+ }, D = Ee([T], R), Q = jt.counterTri(D);
2828
+ jn(t, {
2829
+ forw: Q,
2830
+ bakw: D
2831
+ }, o);
2832
+ }), r = !0);
2833
+ }
2834
+ return r;
2835
+ }
2836
+ function ge(o) {
2837
+ return [o[0], o[1]];
2838
+ }
2839
+ function In(o, t) {
2840
+ const [e, n] = t[0], [r, i] = t[1], [s, a] = t[2], c = s - e, h = a - n, u = r - e, f = i - n, d = o[0] - e, y = o[1] - n, E = c * c + h * h, k = c * u + h * f, X = c * d + h * y, C = u * u + f * f, m = u * d + f * y, v = E * C - k * k;
2841
+ if (v === 0) return !1;
2842
+ const l = 1 / v, g = (C * X - k * m) * l, x = (E * m - k * X) * l, A = 1e-9;
2843
+ return g >= -A && x >= -A && g + x <= 1 + A;
2844
+ }
2845
+ function Ei(o) {
2846
+ const t = o.map((s) => s.slice()).filter(
2847
+ (s, a, c) => c.findIndex(
2848
+ (h) => nn(h[0], s[0]) && nn(h[1], s[1])
2849
+ ) === a
2850
+ );
2851
+ if (t.length <= 1) return t;
2852
+ const e = t.sort(
2853
+ (s, a) => s[0] === a[0] ? s[1] - a[1] : s[0] - a[0]
2854
+ ), n = (s, a, c) => (a[0] - s[0]) * (c[1] - s[1]) - (a[1] - s[1]) * (c[0] - s[0]), r = [];
2855
+ for (const s of e) {
2856
+ for (; r.length >= 2 && n(
2857
+ r[r.length - 2],
2858
+ r[r.length - 1],
2859
+ s
2860
+ ) <= 0; )
2861
+ r.pop();
2862
+ r.push(s);
2863
+ }
2864
+ const i = [];
2865
+ for (let s = e.length - 1; s >= 0; s--) {
2866
+ const a = e[s];
2867
+ for (; i.length >= 2 && n(
2868
+ i[i.length - 2],
2869
+ i[i.length - 1],
2870
+ a
2871
+ ) <= 0; )
2872
+ i.pop();
2873
+ i.push(a);
2874
+ }
2875
+ return i.pop(), r.pop(), r.concat(i);
2876
+ }
2877
+ function Ai(o) {
2878
+ if (o.length < 3) return 0;
2879
+ let t = 0;
2880
+ for (let e = 0; e < o.length; e++) {
2881
+ const [n, r] = o[e], [i, s] = o[(e + 1) % o.length];
2882
+ t += n * s - i * r;
2883
+ }
2884
+ return Math.abs(t) / 2;
2885
+ }
2886
+ function Tn(o, t, e) {
2887
+ return Math.abs(
2888
+ (o[0] * (t[1] - e[1]) + t[0] * (e[1] - o[1]) + e[0] * (o[1] - t[1])) / 2
2889
+ );
2890
+ }
2891
+ function nn(o, t, e = 1e-9) {
2892
+ return Math.abs(o - t) <= e;
2893
+ }
2894
+ const Pi = 2.00703, Nn = typeof jt.format_version < "u" ? jt.format_version : Pi;
2895
+ class Xt extends jt.Transform {
2896
+ importance;
2897
+ priority;
2898
+ pointsSet;
1693
2899
  /**
1694
2900
  * Tinクラスのインスタンスを生成します
1695
2901
  * @param options - 初期化オプション
1696
2902
  */
1697
- constructor(e = {}) {
1698
- super();
1699
- rt(this, "importance");
1700
- rt(this, "priority");
1701
- rt(this, "pointsSet");
1702
- e.bounds ? this.setBounds(e.bounds) : (this.setWh(e.wh), this.vertexMode = e.vertexMode || ht.VERTEX_PLAIN), this.strictMode = e.strictMode || ht.MODE_AUTO, this.yaxisMode = e.yaxisMode || ht.YAXIS_INVERT, this.importance = e.importance || 0, this.priority = e.priority || 0, this.stateFull = e.stateFull || !1, e.points && this.setPoints(e.points), e.edges && this.setEdges(e.edges);
2903
+ constructor(t = {}) {
2904
+ super(), t.bounds ? this.setBounds(t.bounds) : (this.setWh(t.wh), this.vertexMode = t.vertexMode || Xt.VERTEX_PLAIN), this.strictMode = t.strictMode || Xt.MODE_AUTO, this.yaxisMode = t.yaxisMode || Xt.YAXIS_INVERT, this.importance = t.importance || 0, this.priority = t.priority || 0, this.stateFull = t.stateFull || !1, t.points && this.setPoints(t.points), t.edges && this.setEdges(t.edges);
1703
2905
  }
1704
2906
  /**
1705
2907
  * フォーマットバージョンを取得します
1706
2908
  */
1707
2909
  getFormatVersion() {
1708
- return je;
2910
+ return Nn;
1709
2911
  }
1710
2912
  /**
1711
- * 制御点(GCP: Ground Control Points)を設定します
2913
+ * 制御点(GCP: Ground Control Points)を設定します。
2914
+ * 指定した点群に合わせて内部のTINキャッシュをリセットします。
1712
2915
  */
1713
- setPoints(e) {
1714
- this.yaxisMode === ht.YAXIS_FOLLOW && (e = e.map((s) => [
1715
- s[0],
1716
- [s[1][0], -1 * s[1][1]]
1717
- ])), this.points = e, this.tins = void 0, this.indexedTins = void 0;
2916
+ setPoints(t) {
2917
+ this.yaxisMode === Xt.YAXIS_FOLLOW && (t = t.map((e) => [
2918
+ e[0],
2919
+ [e[1][0], -1 * e[1][1]]
2920
+ ])), this.points = t, this.tins = void 0, this.indexedTins = void 0;
1718
2921
  }
1719
2922
  /**
1720
- * エッジ(制約線)を設定します
2923
+ * エッジ(制約線)を設定します。
2924
+ * 制約線を正規化した上で、依存するキャッシュをリセットします。
1721
2925
  */
1722
- setEdges(e = []) {
1723
- this.edges = ze(e), this.edgeNodes = void 0, this.tins = void 0, this.indexedTins = void 0;
2926
+ setEdges(t = []) {
2927
+ this.edges = jt.normalizeEdges(t), this.edgeNodes = void 0, this.tins = void 0, this.indexedTins = void 0;
1724
2928
  }
1725
2929
  /**
1726
2930
  * 境界ポリゴンを設定します
1727
2931
  */
1728
- setBounds(e) {
1729
- this.bounds = e;
1730
- let s = e[0][0], i = s, n = e[0][1], r = n;
1731
- const a = [e[0]];
1732
- for (let f = 1; f < e.length; f++) {
1733
- const c = e[f];
1734
- c[0] < s && (s = c[0]), c[0] > i && (i = c[0]), c[1] < n && (n = c[1]), c[1] > r && (r = c[1]), a.push(c);
2932
+ setBounds(t) {
2933
+ this.bounds = t;
2934
+ let e = t[0][0], n = e, r = t[0][1], i = r;
2935
+ const s = [t[0]];
2936
+ for (let a = 1; a < t.length; a++) {
2937
+ const c = t[a];
2938
+ c[0] < e && (e = c[0]), c[0] > n && (n = c[0]), c[1] < r && (r = c[1]), c[1] > i && (i = c[1]), s.push(c);
1735
2939
  }
1736
- a.push(e[0]), this.boundsPolygon = me([a]), this.xy = [s, n], this.wh = [i - s, r - n], this.vertexMode = ht.VERTEX_PLAIN, this.tins = void 0, this.indexedTins = void 0;
2940
+ s.push(t[0]), this.boundsPolygon = Ee([s]), this.xy = [e, r], this.wh = [n - e, i - r], this.vertexMode = Xt.VERTEX_PLAIN, this.tins = void 0, this.indexedTins = void 0;
1737
2941
  }
1738
2942
  /**
1739
2943
  * 現在の設定を永続化可能な形式にコンパイルします
1740
2944
  */
1741
2945
  getCompiled() {
1742
- var i;
1743
- const e = {};
1744
- e.version = je, e.points = this.points, e.weight_buffer = this.pointsWeightBuffer, e.centroid_point = [
2946
+ const t = {};
2947
+ t.version = Nn, t.points = this.points, t.weight_buffer = this.pointsWeightBuffer, t.centroid_point = [
1745
2948
  this.centroid.forw.geometry.coordinates,
1746
2949
  this.centroid.forw.properties.target.geom
1747
- ], e.vertices_params = [
2950
+ ], t.vertices_params = [
1748
2951
  this.vertices_params.forw[0],
1749
2952
  this.vertices_params.bakw[0]
1750
- ], e.vertices_points = [];
1751
- const s = this.vertices_params.forw[1];
1752
- return s && [0, 1, 2, 3].map((n) => {
1753
- const r = s[n].features[0], a = r.geometry.coordinates[0][1], f = r.properties.b.geom;
1754
- e.vertices_points[n] = [a, f];
1755
- }), e.strict_status = this.strict_status, e.tins_points = [[]], this.tins.forw.features.map((n) => {
1756
- e.tins_points[0].push(
2953
+ ], t.vertices_points = [];
2954
+ const e = this.vertices_params.forw[1];
2955
+ return e && [0, 1, 2, 3].map((n) => {
2956
+ const r = e[n].features[0], i = r.geometry.coordinates[0][1], s = r.properties.b.geom;
2957
+ t.vertices_points[n] = [i, s];
2958
+ }), t.strict_status = this.strict_status, t.tins_points = [[]], this.tins.forw.features.map((n) => {
2959
+ t.tins_points[0].push(
1757
2960
  ["a", "b", "c"].map(
1758
2961
  (r) => n.properties[r].index
1759
2962
  )
1760
2963
  );
1761
- }), this.strict_status === ht.STATUS_LOOSE ? (e.tins_points[1] = [], this.tins.bakw.features.map((n) => {
1762
- e.tins_points[1].push(
2964
+ }), this.strict_status === Xt.STATUS_LOOSE ? (t.tins_points[1] = [], this.tins.bakw.features.map((n) => {
2965
+ t.tins_points[1].push(
1763
2966
  ["a", "b", "c"].map(
1764
2967
  (r) => n.properties[r].index
1765
2968
  )
1766
2969
  );
1767
- })) : this.strict_status === ht.STATUS_ERROR && ((i = this.kinks) != null && i.bakw) && (e.kinks_points = this.kinks.bakw.features.map(
2970
+ })) : this.strict_status === Xt.STATUS_ERROR && this.kinks?.bakw && (t.kinks_points = this.kinks.bakw.features.map(
1768
2971
  (n) => n.geometry.coordinates
1769
- )), e.yaxisMode = this.yaxisMode, e.vertexMode = this.vertexMode, e.strictMode = this.strictMode, this.bounds ? (e.bounds = this.bounds, e.boundsPolygon = this.boundsPolygon, e.xy = this.xy, e.wh = this.wh) : e.wh = this.wh, e.edges = this.edges, e.edgeNodes = this.edgeNodes, e;
2972
+ )), t.yaxisMode = this.yaxisMode, t.vertexMode = this.vertexMode, t.strictMode = this.strictMode, this.bounds ? (t.bounds = this.bounds, t.boundsPolygon = this.boundsPolygon, t.xy = this.xy, t.wh = this.wh) : t.wh = this.wh, t.edges = this.edges, t.edgeNodes = this.edgeNodes, t;
1770
2973
  }
1771
2974
  /**
1772
2975
  * 幅と高さを設定します
1773
2976
  */
1774
- setWh(e) {
1775
- this.wh = e || [100, 100], this.xy = [0, 0], this.bounds = void 0, this.boundsPolygon = void 0, this.tins = void 0, this.indexedTins = void 0;
2977
+ setWh(t) {
2978
+ this.wh = t || [100, 100], this.xy = [0, 0], this.bounds = void 0, this.boundsPolygon = void 0, this.tins = void 0, this.indexedTins = void 0;
1776
2979
  }
1777
2980
  /**
1778
2981
  * 頂点モードを設定します
1779
2982
  */
1780
- setVertexMode(e) {
1781
- this.vertexMode = e, this.tins = void 0, this.indexedTins = void 0;
2983
+ setVertexMode(t) {
2984
+ this.vertexMode = t, this.tins = void 0, this.indexedTins = void 0;
1782
2985
  }
1783
2986
  /**
1784
2987
  * 厳密性モードを設定します
1785
2988
  */
1786
- setStrictMode(e) {
1787
- this.strictMode = e, this.tins = void 0, this.indexedTins = void 0;
2989
+ setStrictMode(t) {
2990
+ this.strictMode = t, this.tins = void 0, this.indexedTins = void 0;
1788
2991
  }
1789
2992
  /**
1790
2993
  * 厳密なTINを計算します
1791
2994
  */
1792
2995
  calcurateStrictTin() {
1793
- const e = this.tins.forw.features.map(
1794
- (n) => bs(n)
2996
+ const t = this.tins.forw.features.map(
2997
+ (r) => jt.counterTri(r)
1795
2998
  );
1796
- this.tins.bakw = Ot(e);
1797
- const s = {};
1798
- this.tins.forw.features.forEach((n, r) => {
1799
- const a = this.tins.bakw.features[r];
1800
- rn(s, { forw: n, bakw: a });
1801
- });
1802
- const i = ["forw", "bakw"].map((n) => {
1803
- const r = this.tins[n].features.map(
1804
- (a) => a.geometry.coordinates[0]
2999
+ this.tins.bakw = Kt(t);
3000
+ const e = {};
3001
+ this.tins.forw.features.forEach((r, i) => {
3002
+ const s = this.tins.bakw.features[i];
3003
+ jn(e, { forw: r, bakw: s });
3004
+ }), Si(
3005
+ this.tins,
3006
+ e,
3007
+ this.pointsSet?.edges || []
3008
+ );
3009
+ const n = ["forw", "bakw"].map((r) => {
3010
+ const i = this.tins[r].features.map(
3011
+ (s) => s.geometry.coordinates[0]
1805
3012
  );
1806
- return Us(r);
3013
+ return ti(i);
3014
+ });
3015
+ n[0].length === 0 && n[1].length === 0 ? (this.strict_status = Xt.STATUS_STRICT, delete this.kinks) : (this.strict_status = Xt.STATUS_ERROR, this.kinks = {
3016
+ forw: Kt(n[0]),
3017
+ bakw: Kt(n[1])
1807
3018
  });
1808
- i[0].length === 0 && i[1].length === 0 ? (this.strict_status = ht.STATUS_STRICT, delete this.kinks) : (this.strict_status = ht.STATUS_ERROR, this.kinks = {}, i[0].length > 0 && (this.kinks.forw = Ot(i[0])), i[1].length > 0 && (this.kinks.bakw = Ot(i[1])));
1809
3019
  }
1810
3020
  /**
1811
- * 点群セットを生成します
3021
+ * 点群セットを生成します。
3022
+ * GCP と中間エッジノードを GeoJSON Point に変換し、後続の三角分割に備えます。
1812
3023
  */
1813
3024
  generatePointsSet() {
1814
- const e = {
3025
+ const t = {
1815
3026
  forw: [],
1816
3027
  bakw: []
1817
3028
  };
1818
- for (let n = 0; n < this.points.length; n++) {
1819
- const r = this.points[n][0], a = this.points[n][1], f = ne(r, a, n);
1820
- e.forw.push(f), e.bakw.push(ie(f));
3029
+ for (let r = 0; r < this.points.length; r++) {
3030
+ const i = this.points[r][0], s = this.points[r][1], a = Fe(i, s, r);
3031
+ t.forw.push(a), t.bakw.push(Le(a));
1821
3032
  }
1822
- const s = [];
1823
- let i = 0;
3033
+ const e = [];
3034
+ let n = 0;
1824
3035
  this.edgeNodes = [], this.edges || (this.edges = []);
1825
- for (let n = 0; n < this.edges.length; n++) {
1826
- const r = this.edges[n][2], a = Object.assign([], this.edges[n][0]), f = Object.assign([], this.edges[n][1]);
1827
- if (a.length === 0 && f.length === 0) {
1828
- s.push(r);
3036
+ for (let r = 0; r < this.edges.length; r++) {
3037
+ const i = this.edges[r][2], s = Object.assign([], this.edges[r][0]), a = Object.assign([], this.edges[r][1]);
3038
+ if (s.length === 0 && a.length === 0) {
3039
+ e.push(i);
1829
3040
  continue;
1830
3041
  }
1831
- a.unshift(this.points[r[0]][0]), a.push(this.points[r[1]][0]), f.unshift(this.points[r[0]][1]), f.push(this.points[r[1]][1]);
1832
- const c = [a, f].map((u) => {
1833
- const h = u.map((p, y, g) => {
3042
+ s.unshift(this.points[i[0]][0]), s.push(this.points[i[1]][0]), a.unshift(this.points[i[0]][1]), a.push(this.points[i[1]][1]);
3043
+ const c = [s, a].map((h) => {
3044
+ const u = h.map((d, y, E) => {
1834
3045
  if (y === 0) return 0;
1835
- const b = g[y - 1];
3046
+ const k = E[y - 1];
1836
3047
  return Math.sqrt(
1837
- Math.pow(p[0] - b[0], 2) + Math.pow(p[1] - b[1], 2)
3048
+ Math.pow(d[0] - k[0], 2) + Math.pow(d[1] - k[1], 2)
1838
3049
  );
1839
- }), l = h.reduce((p, y, g) => g === 0 ? [0] : (p.push(p[g - 1] + y), p), []);
1840
- return l.map((p, y, g) => {
1841
- const b = p / g[g.length - 1];
1842
- return [u[y], h[y], l[y], b];
3050
+ }), f = u.reduce((d, y, E) => E === 0 ? [0] : (d.push(d[E - 1] + y), d), []);
3051
+ return f.map((d, y, E) => {
3052
+ const k = d / E[E.length - 1];
3053
+ return [h[y], u[y], f[y], k];
1843
3054
  });
1844
3055
  });
1845
- c.map((u, h) => {
1846
- const l = c[h ? 0 : 1];
1847
- return u.filter((p, y) => !(y === 0 || y === u.length - 1 || p[4] === "handled")).map((p) => {
1848
- const y = p[0], g = p[3], b = l.reduce(
1849
- (w, S, _, v) => {
1850
- if (w) return w;
1851
- const T = v[_ + 1];
1852
- if (S[3] === g)
1853
- return S[4] = "handled", [S];
1854
- if (S[3] < g && T && T[3] > g)
1855
- return [S, T];
3056
+ c.map((h, u) => {
3057
+ const f = c[u ? 0 : 1];
3058
+ return h.filter((d, y) => !(y === 0 || y === h.length - 1 || d[4] === "handled")).map((d) => {
3059
+ const y = d[0], E = d[3], k = f.reduce(
3060
+ (X, C, m, v) => {
3061
+ if (X) return X;
3062
+ const l = v[m + 1];
3063
+ if (C[3] === E)
3064
+ return C[4] = "handled", [C];
3065
+ if (C[3] < E && l && l[3] > E)
3066
+ return [C, l];
1856
3067
  },
1857
3068
  void 0
1858
3069
  );
1859
- if (b && b.length === 1)
1860
- return h === 0 ? [y, b[0][0], g] : [b[0][0], y, g];
1861
- if (b && b.length === 2) {
1862
- const w = b[0], S = b[1], _ = (g - w[3]) / (S[3] - w[3]), v = [
1863
- (S[0][0] - w[0][0]) * _ + w[0][0],
1864
- (S[0][1] - w[0][1]) * _ + w[0][1]
3070
+ if (k && k.length === 1)
3071
+ return u === 0 ? [y, k[0][0], E] : [k[0][0], y, E];
3072
+ if (k && k.length === 2) {
3073
+ const X = k[0], C = k[1], m = (E - X[3]) / (C[3] - X[3]), v = [
3074
+ (C[0][0] - X[0][0]) * m + X[0][0],
3075
+ (C[0][1] - X[0][1]) * m + X[0][1]
1865
3076
  ];
1866
- return h === 0 ? [y, v, g] : [v, y, g];
3077
+ return u === 0 ? [y, v, E] : [v, y, E];
1867
3078
  }
1868
3079
  return [];
1869
3080
  });
1870
- }).reduce((u, h) => u.concat(h), []).sort((u, h) => u[2] < h[2] ? -1 : 1).map((u, h, l) => {
1871
- this.edgeNodes[i] = [
1872
- u[0],
1873
- u[1]
3081
+ }).reduce((h, u) => h.concat(u), []).sort((h, u) => h[2] < u[2] ? -1 : 1).map((h, u, f) => {
3082
+ this.edgeNodes[n] = [
3083
+ h[0],
3084
+ h[1]
1874
3085
  ];
1875
- const p = ne(
1876
- u[0],
1877
- u[1],
1878
- `e${i}`
3086
+ const d = Fe(
3087
+ h[0],
3088
+ h[1],
3089
+ `e${n}`
1879
3090
  );
1880
- i++, e.forw.push(p), e.bakw.push(ie(p)), h === 0 ? s.push([r[0], e.forw.length - 1]) : s.push([
1881
- e.forw.length - 2,
1882
- e.forw.length - 1
1883
- ]), h === l.length - 1 && s.push([e.forw.length - 1, r[1]]);
3091
+ n++, t.forw.push(d), t.bakw.push(Le(d)), u === 0 ? e.push([i[0], t.forw.length - 1]) : e.push([
3092
+ t.forw.length - 2,
3093
+ t.forw.length - 1
3094
+ ]), u === f.length - 1 && e.push([t.forw.length - 1, i[1]]);
1884
3095
  });
1885
3096
  }
1886
3097
  return {
1887
- forw: e.forw,
1888
- bakw: e.bakw,
1889
- edges: s
3098
+ forw: t.forw,
3099
+ bakw: t.bakw,
3100
+ edges: e
1890
3101
  };
1891
3102
  }
1892
3103
  /**
1893
3104
  * 入力データの検証と初期データの準備
1894
3105
  */
1895
3106
  validateAndPrepareInputs() {
1896
- const e = this.xy[0] - 0.05 * this.wh[0], s = this.xy[0] + 1.05 * this.wh[0], i = this.xy[1] - 0.05 * this.wh[1], n = this.xy[1] + 1.05 * this.wh[1];
1897
- if (!this.points.reduce((f, c) => f && (this.bounds ? ts(c[0], this.boundsPolygon) : c[0][0] >= e && c[0][0] <= s && c[0][1] >= i && c[0][1] <= n), !0))
3107
+ const t = this.xy[0] - 0.05 * this.wh[0], e = this.xy[0] + 1.05 * this.wh[0], n = this.xy[1] - 0.05 * this.wh[1], r = this.xy[1] + 1.05 * this.wh[1];
3108
+ if (!this.points.reduce((a, c) => a && (this.bounds ? cr(c[0], this.boundsPolygon) : c[0][0] >= t && c[0][0] <= e && c[0][1] >= n && c[0][1] <= r), !0))
1898
3109
  throw "SOME POINTS OUTSIDE";
1899
- let a = [];
1900
- return this.wh && (a = [[e, i], [s, i], [e, n], [s, n]]), {
3110
+ let s = [];
3111
+ return this.wh && (s = [[t, n], [e, n], [t, r], [e, r]]), {
1901
3112
  pointsSet: this.generatePointsSet(),
1902
- bbox: a,
1903
- minx: e,
1904
- maxx: s,
1905
- miny: i,
1906
- maxy: n
3113
+ bbox: s,
3114
+ minx: t,
3115
+ maxx: e,
3116
+ miny: n,
3117
+ maxy: r
1907
3118
  };
1908
3119
  }
1909
3120
  /**
1910
- * TINネットワークを更新し、座標変換の準備を行います
3121
+ * TINネットワークを同期的に更新し、座標変換の準備を行います。
3122
+ * 重めの計算を伴うため、呼び出し側が非同期制御を行いたい場合は
3123
+ * {@link updateTinAsync} を利用してください。
1911
3124
  */
1912
3125
  updateTin() {
1913
- let e = this.strictMode;
1914
- e !== ht.MODE_STRICT && e !== ht.MODE_LOOSE && (e = ht.MODE_AUTO);
1915
- const { pointsSet: s, bbox: i, minx: n, maxx: r, miny: a, maxy: f } = this.validateAndPrepareInputs(), c = {
1916
- forw: Ot(s.forw),
1917
- bakw: Ot(s.bakw)
1918
- }, u = te(
3126
+ let t = this.strictMode;
3127
+ t !== Xt.MODE_STRICT && t !== Xt.MODE_LOOSE && (t = Xt.MODE_AUTO);
3128
+ const { pointsSet: e, bbox: n, minx: r, maxx: i, miny: s, maxy: a } = this.validateAndPrepareInputs(), c = {
3129
+ forw: Kt(e.forw),
3130
+ bakw: Kt(e.bakw)
3131
+ }, h = Te(
1919
3132
  c.forw,
1920
- s.edges,
3133
+ e.edges,
1921
3134
  "target"
1922
- ), h = te(
3135
+ ), u = Te(
1923
3136
  c.bakw,
1924
- s.edges,
3137
+ e.edges,
1925
3138
  "target"
1926
3139
  );
1927
- if (u.features.length === 0 || h.features.length === 0)
3140
+ if (h.features.length === 0 || u.features.length === 0)
1928
3141
  throw "TOO LINEAR1";
1929
- const l = es(c.forw), p = ke(c.forw);
1930
- if (!p) throw "TOO LINEAR2";
1931
- const y = {}, g = p.geometry.coordinates[0];
1932
- let b;
3142
+ const f = fr(c.forw), d = vn(c.forw);
3143
+ if (!d) throw "TOO LINEAR2";
3144
+ const y = {}, E = d.geometry.coordinates[0];
3145
+ let k;
1933
3146
  try {
1934
- b = g.map((N) => ({
1935
- forw: N,
1936
- bakw: re(Jt(N), u)
1937
- })), b.forEach((N) => {
1938
- y[`${N.forw[0]}:${N.forw[1]}`] = N;
3147
+ k = E.map((b) => ({
3148
+ forw: b,
3149
+ bakw: jt.transformArr(de(b), h)
3150
+ })), k.forEach((b) => {
3151
+ y[`${b.forw[0]}:${b.forw[1]}`] = b;
1939
3152
  });
1940
3153
  } catch {
1941
3154
  throw "TOO LINEAR2";
1942
3155
  }
1943
- const w = ke(c.bakw);
1944
- if (!w) throw "TOO LINEAR2";
1945
- const S = w.geometry.coordinates[0];
3156
+ const X = vn(c.bakw);
3157
+ if (!X) throw "TOO LINEAR2";
3158
+ const C = X.geometry.coordinates[0];
1946
3159
  try {
1947
- b = S.map((N) => ({
1948
- bakw: N,
1949
- forw: re(Jt(N), h)
1950
- })), b.forEach((N) => {
1951
- y[`${N.forw[0]}:${N.forw[1]}`] = N;
3160
+ k = C.map((b) => ({
3161
+ bakw: b,
3162
+ forw: jt.transformArr(de(b), u)
3163
+ })), k.forEach((b) => {
3164
+ y[`${b.forw[0]}:${b.forw[1]}`] = b;
1952
3165
  });
1953
3166
  } catch {
1954
3167
  throw "TOO LINEAR2";
1955
3168
  }
1956
- const _ = {
1957
- forw: l.geometry.coordinates,
1958
- bakw: re(l, u)
1959
- }, v = ne(_.forw, _.bakw, "c");
3169
+ const m = {
3170
+ forw: f.geometry.coordinates,
3171
+ bakw: jt.transformArr(f, h)
3172
+ }, v = Fe(m.forw, m.bakw, "c");
1960
3173
  this.centroid = {
1961
3174
  forw: v,
1962
- bakw: ie(v)
3175
+ bakw: Le(v)
1963
3176
  };
1964
- const T = this.vertexMode === ht.VERTEX_BIRDEYE ? this.calculateBirdeyeVertices(
1965
- y,
1966
- _,
1967
- i,
1968
- n,
1969
- r,
1970
- a,
1971
- f
1972
- ) : this.calculatePlainVertices(
1973
- y,
1974
- _,
1975
- i,
1976
- n,
1977
- r,
1978
- a,
1979
- f
1980
- ), I = {
3177
+ const l = {
3178
+ convexBuf: y,
3179
+ centroid: m,
3180
+ bbox: n,
3181
+ minx: r,
3182
+ maxx: i,
3183
+ miny: s,
3184
+ maxy: a
3185
+ }, g = this.vertexMode === Xt.VERTEX_BIRDEYE ? Zr(l) : Hr(l), x = {
1981
3186
  forw: [],
1982
3187
  bakw: []
1983
3188
  };
1984
- for (let N = 0; N < T.length; N++) {
1985
- const V = T[N].forw, z = T[N].bakw, G = ne(V, z, `b${N}`), tt = ie(G);
1986
- s.forw.push(G), s.bakw.push(tt), I.forw.push(G), I.bakw.push(tt);
3189
+ for (let b = 0; b < g.length; b++) {
3190
+ const T = g[b].forw, R = g[b].bakw, D = Fe(T, R, `b${b}`), Q = Le(D);
3191
+ e.forw.push(D), e.bakw.push(Q), x.forw.push(D), x.bakw.push(Q);
1987
3192
  }
1988
3193
  this.pointsSet = {
1989
- forw: Ot(s.forw),
1990
- bakw: Ot(s.bakw),
1991
- edges: []
3194
+ forw: Kt(e.forw),
3195
+ bakw: Kt(e.bakw),
3196
+ edges: e.edges
1992
3197
  }, this.tins = {
1993
- forw: ve(
1994
- te(
3198
+ forw: jt.rotateVerticesTriangle(
3199
+ Te(
1995
3200
  this.pointsSet.forw,
1996
- s.edges,
3201
+ e.edges,
1997
3202
  "target"
1998
3203
  )
1999
3204
  )
2000
- }, (e === ht.MODE_STRICT || e === ht.MODE_AUTO) && this.calcurateStrictTin(), (e === ht.MODE_LOOSE || e === ht.MODE_AUTO && this.strict_status === ht.STATUS_ERROR) && (this.tins.bakw = ve(
2001
- te(
3205
+ }, (t === Xt.MODE_STRICT || t === Xt.MODE_AUTO) && this.calcurateStrictTin(), (t === Xt.MODE_LOOSE || t === Xt.MODE_AUTO && this.strict_status === Xt.STATUS_ERROR) && (this.tins.bakw = jt.rotateVerticesTriangle(
3206
+ Te(
2002
3207
  this.pointsSet.bakw,
2003
- s.edges,
3208
+ e.edges,
2004
3209
  "target"
2005
3210
  )
2006
- ), delete this.kinks, this.strict_status = ht.STATUS_LOOSE), this.vertices_params = {
2007
- forw: Fe(I.forw, this.centroid.forw),
2008
- bakw: Fe(I.bakw, this.centroid.bakw)
2009
- }, this.addIndexedTin(), this.calculatePointsWeight();
2010
- }
2011
- /**
2012
- * 通常の頂点を計算
2013
- */
2014
- calculatePlainVertices(e, s, i, n, r, a, f) {
2015
- const c = Object.keys(e).reduce((y, g) => {
2016
- const b = e[g], w = b.forw, S = b.bakw, _ = {
2017
- forw: [w[0] - s.forw[0], w[1] - s.forw[1]],
2018
- bakw: [S[0] - s.bakw[0], S[1] - s.bakw[1]]
2019
- }, v = _.forw[0] === 0 ? 1 / 0 : ((_.forw[0] < 0 ? n : r) - s.forw[0]) / _.forw[0], T = _.forw[1] === 0 ? 1 / 0 : ((_.forw[1] < 0 ? a : f) - s.forw[1]) / _.forw[1];
2020
- if (Math.abs(v) / Math.abs(T) < 1.1) {
2021
- const I = {
2022
- forw: [
2023
- _.forw[0] * v + s.forw[0],
2024
- _.forw[1] * v + s.forw[1]
2025
- ],
2026
- bakw: [
2027
- _.bakw[0] * v + s.bakw[0],
2028
- _.bakw[1] * v + s.bakw[1]
2029
- ]
2030
- };
2031
- _.forw[0] < 0 ? y[3].push(I) : y[1].push(I);
2032
- }
2033
- if (Math.abs(T) / Math.abs(v) < 1.1) {
2034
- const I = {
2035
- forw: [
2036
- _.forw[0] * T + s.forw[0],
2037
- _.forw[1] * T + s.forw[1]
2038
- ],
2039
- bakw: [
2040
- _.bakw[0] * T + s.bakw[0],
2041
- _.bakw[1] * T + s.bakw[1]
2042
- ]
2043
- };
2044
- _.forw[1] < 0 ? y[0].push(I) : y[2].push(I);
2045
- }
2046
- return y;
2047
- }, [[], [], [], []]);
2048
- let h = Object.keys(e).reduce(
2049
- (y, g, b, w) => {
2050
- const S = e[g], _ = S.forw, v = S.bakw, T = {
2051
- forw: [_[0] - s.forw[0], _[1] - s.forw[1]],
2052
- bakw: [v[0] - s.bakw[0], s.bakw[1] - v[1]]
2053
- };
2054
- if (T.forw[0] === 0 || T.forw[1] === 0) return y;
2055
- let I = 0;
2056
- return T.forw[0] > 0 && (I += 1), T.forw[1] > 0 && (I += 2), y[I].push([T.forw, T.bakw]), b === w.length - 1 ? y.map((N) => N.reduce(
2057
- (V, z, G, tt) => {
2058
- V || (V = [1 / 0, 0, 0]);
2059
- let X = Math.sqrt(Math.pow(z[0][0], 2) + Math.pow(z[0][1], 2)) / Math.sqrt(Math.pow(z[1][0], 2) + Math.pow(z[1][1], 2));
2060
- X = X < V[0] ? X : V[0];
2061
- const it = Math.atan2(z[0][0], z[0][1]) - Math.atan2(z[1][0], z[1][1]), d = V[1] + Math.cos(it), m = V[2] + Math.sin(it);
2062
- return G === tt.length - 1 ? [X, Math.atan2(m, d)] : [X, d, m];
2063
- },
2064
- null
2065
- )) : y;
2066
- },
2067
- [[], [], [], []]
2068
- );
2069
- h.length === 1 && (h = [
2070
- h[0],
2071
- h[0],
2072
- h[0],
2073
- h[0]
2074
- ]);
2075
- const l = h.map((y, g) => {
2076
- const b = i[g], w = [
2077
- b[0] - s.forw[0],
2078
- b[1] - s.forw[1]
2079
- ], _ = Math.sqrt(
2080
- Math.pow(w[0], 2) + Math.pow(w[1], 2)
2081
- ) / y[0], v = Math.atan2(w[0], w[1]) - y[1], T = [
2082
- s.bakw[0] + _ * Math.sin(v),
2083
- s.bakw[1] - _ * Math.cos(v)
2084
- ];
2085
- return { forw: b, bakw: T };
2086
- }), p = l[2];
2087
- return l[2] = l[3], l[3] = p, this.checkAndAdjustVertices(l, c, s), l;
2088
- }
2089
- /**
2090
- * 鳥瞰図モードの頂点を計算
2091
- */
2092
- calculateBirdeyeVertices(e, s, i, n, r, a, f) {
2093
- return this.calculatePlainVertices(
2094
- e,
2095
- s,
2096
- i,
2097
- n,
2098
- r,
2099
- a,
2100
- f
2101
- );
2102
- }
2103
- /**
2104
- * 頂点の位置を調整
2105
- */
2106
- checkAndAdjustVertices(e, s, i) {
2107
- const n = [1, 1, 1, 1];
2108
- for (let r = 0; r < 4; r++) {
2109
- const a = (r + 1) % 4, f = xe([e[r].bakw, e[a].bakw]);
2110
- s[r].map((c) => {
2111
- const u = xe([i.bakw, c.bakw]), h = ss(f, u);
2112
- if (h.features.length > 0 && h.features[0].geometry) {
2113
- const l = h.features[0], p = Math.sqrt(
2114
- Math.pow(c.bakw[0] - i.bakw[0], 2) + Math.pow(c.bakw[1] - i.bakw[1], 2)
2115
- ), y = Math.sqrt(
2116
- Math.pow(
2117
- l.geometry.coordinates[0] - i.bakw[0],
2118
- 2
2119
- ) + Math.pow(
2120
- l.geometry.coordinates[1] - i.bakw[1],
2121
- 2
2122
- )
2123
- ), g = p / y;
2124
- g > n[r] && (n[r] = g), g > n[a] && (n[a] = g);
2125
- }
2126
- });
2127
- }
2128
- e.forEach((r, a) => {
2129
- const f = n[a], c = [
2130
- (r.bakw[0] - i.bakw[0]) * f + i.bakw[0],
2131
- (r.bakw[1] - i.bakw[1]) * f + i.bakw[1]
2132
- ];
2133
- r.bakw = c;
3211
+ ), delete this.kinks, this.strict_status = Xt.STATUS_LOOSE), this.vertices_params = {
3212
+ forw: On(x.forw, this.centroid.forw),
3213
+ bakw: On(x.bakw, this.centroid.bakw)
3214
+ }, this.addIndexedTin();
3215
+ const A = ["forw"];
3216
+ this.strict_status === Xt.STATUS_LOOSE && A.push("bakw");
3217
+ const I = this.strict_status === Xt.STATUS_STRICT;
3218
+ this.pointsWeightBuffer = Mi({
3219
+ tins: this.tins,
3220
+ targets: A,
3221
+ includeReciprocals: I
2134
3222
  });
2135
3223
  }
2136
3224
  /**
2137
- * 点の重み付けを計算します
3225
+ * 非同期ラッパーを提供します。
3226
+ * 互換性のために Promise ベースの API を維持しますが、内部処理は同期的です。
2138
3227
  */
2139
- calculatePointsWeight() {
2140
- const e = ["forw"];
2141
- this.strict_status === ht.STATUS_LOOSE && e.push("bakw");
2142
- const s = {};
2143
- e.forEach((n) => {
2144
- s[n] = {};
2145
- const r = {};
2146
- this.tins[n].features.map((a) => {
2147
- const f = ["a", "b", "c"];
2148
- for (let c = 0; c < 3; c++) {
2149
- const u = (c + 1) % 3, h = f[c], l = f[u], p = a.properties[h].index, y = a.properties[l].index, g = [p, y].sort().join("-");
2150
- if (!r[g]) {
2151
- const b = a.geometry.coordinates[0][c], w = a.geometry.coordinates[0][u], S = a.properties[h].geom, _ = a.properties[l].geom;
2152
- r[g] = 1;
2153
- const v = Math.sqrt(
2154
- Math.pow(S[0] - _[0], 2) + Math.pow(S[1] - _[1], 2)
2155
- ) / Math.sqrt(
2156
- Math.pow(b[0] - w[0], 2) + Math.pow(b[1] - w[1], 2)
2157
- );
2158
- s[n] || (s[n] = {});
2159
- const T = s[n];
2160
- T[`${p}:${g}`] = v, T[`${y}:${g}`] = v;
2161
- }
2162
- }
2163
- });
2164
- });
2165
- const i = {};
2166
- e.map((n) => {
2167
- i[n] = {}, this.strict_status === ht.STATUS_STRICT && (i.bakw = {});
2168
- const r = s[n], a = {};
2169
- Object.keys(r).forEach((c) => {
2170
- const [u] = c.split(":");
2171
- a[u] || (a[u] = []), a[u].push(r[c]);
2172
- }), Object.keys(a).forEach((c) => {
2173
- const u = a[c], h = u.reduce((l, p) => l + p, 0) / u.length;
2174
- i[n] || (i[n] = {}), i[n][c] = h, this.strict_status === ht.STATUS_STRICT && (i.bakw || (i.bakw = {}), i.bakw[c] = 1 / h);
2175
- });
2176
- let f = 0;
2177
- for (let c = 0; c < 4; c++) {
2178
- const u = `b${c}`, h = i[n][u] || 0;
2179
- f += h;
2180
- }
2181
- i[n].c = f / 4, this.strict_status === ht.STATUS_STRICT && i.bakw && (i.bakw.c = 1 / i[n].c);
2182
- }), this.pointsWeightBuffer = i;
3228
+ async updateTinAsync() {
3229
+ this.updateTin();
2183
3230
  }
2184
3231
  }
3232
+ const Oi = jt.format_version;
2185
3233
  export {
2186
- ht as Tin,
2187
- te as constrainedTin,
2188
- ie as counterPoint,
2189
- ne as createPoint,
2190
- Us as findIntersections,
2191
- we as format_version,
2192
- rn as insertSearchIndex,
2193
- Fe as vertexCalc
3234
+ Xt as Tin,
3235
+ Te as constrainedTin,
3236
+ Le as counterPoint,
3237
+ Fe as createPoint,
3238
+ Xt as default,
3239
+ ti as findIntersections,
3240
+ Oi as format_version,
3241
+ jn as insertSearchIndex,
3242
+ On as vertexCalc
2194
3243
  };