open-plant 1.2.19 → 1.2.21
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.
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1371 -1333
- package/dist/index.js.map +1 -1
- package/dist/types/react/draw-layer.d.ts +4 -1
- package/dist/types/react/draw-layer.d.ts.map +1 -1
- package/dist/types/react/overview-map.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var ei = Object.defineProperty;
|
|
2
2
|
var ni = (e, t, n) => t in e ? ei(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
-
var
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useRef as
|
|
6
|
-
function
|
|
3
|
+
var w = (e, t, n) => ni(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { jsx as jt, jsxs as Tr } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as nt, useMemo as j, useCallback as I, useEffect as O, useState as Te } from "react";
|
|
6
|
+
function Jn(e, t, n) {
|
|
7
7
|
const r = e.createShader(t);
|
|
8
8
|
if (!r)
|
|
9
9
|
throw new Error("Failed to create shader.");
|
|
@@ -14,7 +14,7 @@ function Kn(e, t, n) {
|
|
|
14
14
|
return r;
|
|
15
15
|
}
|
|
16
16
|
function ri(e, t, n) {
|
|
17
|
-
const r =
|
|
17
|
+
const r = Jn(e, e.VERTEX_SHADER, t), i = Jn(e, e.FRAGMENT_SHADER, n), o = e.createProgram();
|
|
18
18
|
if (!o)
|
|
19
19
|
throw e.deleteShader(r), e.deleteShader(i), new Error("Failed to create program.");
|
|
20
20
|
if (e.attachShader(o, r), e.attachShader(o, i), e.linkProgram(o), e.deleteShader(r), e.deleteShader(i), !e.getProgramParameter(o, e.LINK_STATUS)) {
|
|
@@ -44,9 +44,9 @@ function ii(e) {
|
|
|
44
44
|
}
|
|
45
45
|
let oi = class {
|
|
46
46
|
constructor() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
w(this, "viewportWidth", 1);
|
|
48
|
+
w(this, "viewportHeight", 1);
|
|
49
|
+
w(this, "viewState", {
|
|
50
50
|
offsetX: 0,
|
|
51
51
|
offsetY: 0,
|
|
52
52
|
zoom: 1
|
|
@@ -116,25 +116,25 @@ void main() {
|
|
|
116
116
|
`;
|
|
117
117
|
class ci {
|
|
118
118
|
constructor(t) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
119
|
+
w(this, "canvas");
|
|
120
|
+
w(this, "gl");
|
|
121
|
+
w(this, "camera", new oi());
|
|
122
|
+
w(this, "imageWidth");
|
|
123
|
+
w(this, "imageHeight");
|
|
124
|
+
w(this, "clearColor");
|
|
125
|
+
w(this, "program");
|
|
126
|
+
w(this, "vao");
|
|
127
|
+
w(this, "quadBuffer");
|
|
128
|
+
w(this, "uCameraLocation");
|
|
129
|
+
w(this, "uBoundsLocation");
|
|
130
|
+
w(this, "uTextureLocation");
|
|
131
|
+
w(this, "resizeObserver");
|
|
132
|
+
w(this, "tiles", []);
|
|
133
|
+
w(this, "frameId", null);
|
|
134
|
+
w(this, "loadVersion", 0);
|
|
135
|
+
w(this, "destroyed", !1);
|
|
136
|
+
w(this, "fitted", !1);
|
|
137
|
+
w(this, "controlledViewState", !1);
|
|
138
138
|
this.canvas = t.canvas, this.imageWidth = Math.max(1, t.imageWidth), this.imageHeight = Math.max(1, t.imageHeight), this.clearColor = t.clearColor ?? [0.03, 0.05, 0.08, 1], this.gl = ii(this.canvas), this.program = ri(this.gl, si, ai);
|
|
139
139
|
const n = this.gl.createVertexArray(), r = this.gl.createBuffer();
|
|
140
140
|
if (!n || !r)
|
|
@@ -311,10 +311,10 @@ class ci {
|
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
const ui = 0.1, li = 4e6, fi = 4096, hi = 64, di = 1, mi = 4, Er = 1e-6, gi = 24;
|
|
314
|
-
function
|
|
314
|
+
function on(e, t, n) {
|
|
315
315
|
return Math.max(t, Math.min(n, e));
|
|
316
316
|
}
|
|
317
|
-
function
|
|
317
|
+
function qt(e) {
|
|
318
318
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
319
319
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
320
320
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
@@ -341,7 +341,7 @@ function bi(e, t, n) {
|
|
|
341
341
|
e[1] + Math.sin(o) * t
|
|
342
342
|
]);
|
|
343
343
|
}
|
|
344
|
-
return
|
|
344
|
+
return qt(r);
|
|
345
345
|
}
|
|
346
346
|
function mn(e, t) {
|
|
347
347
|
if (!e.length) return [];
|
|
@@ -350,7 +350,7 @@ function mn(e, t) {
|
|
|
350
350
|
a < n && (n = a), a > i && (i = a), c < r && (r = c), c > o && (o = c);
|
|
351
351
|
if (!Number.isFinite(n) || !Number.isFinite(r)) return [];
|
|
352
352
|
const s = Math.max(t, 1);
|
|
353
|
-
return
|
|
353
|
+
return qt([
|
|
354
354
|
[n - s, r - s],
|
|
355
355
|
[i + s, r - s],
|
|
356
356
|
[i + s, o + s],
|
|
@@ -468,13 +468,13 @@ function Ei(e) {
|
|
|
468
468
|
let f = 0;
|
|
469
469
|
const p = e.length * 3;
|
|
470
470
|
for (; a !== s && f < p; ) {
|
|
471
|
-
const
|
|
472
|
-
if (!
|
|
473
|
-
let b = -1,
|
|
474
|
-
for (const x of
|
|
471
|
+
const d = t.get(a);
|
|
472
|
+
if (!d || d.length === 0) break;
|
|
473
|
+
let b = -1, m = 1 / 0;
|
|
474
|
+
for (const x of d) {
|
|
475
475
|
if (n[x]) continue;
|
|
476
|
-
const _ = e[x],
|
|
477
|
-
|
|
476
|
+
const _ = e[x], B = Ti(c, _.dir);
|
|
477
|
+
B < m && (m = B, b = x);
|
|
478
478
|
}
|
|
479
479
|
if (b < 0) break;
|
|
480
480
|
n[b] = 1;
|
|
@@ -494,7 +494,7 @@ function Ri(e, t, n) {
|
|
|
494
494
|
n.minY + (a - n.padding) * n.step
|
|
495
495
|
]);
|
|
496
496
|
}
|
|
497
|
-
return
|
|
497
|
+
return qt(i);
|
|
498
498
|
}
|
|
499
499
|
function Pi(e) {
|
|
500
500
|
if (e.length < 4) return 0;
|
|
@@ -505,23 +505,23 @@ function Pi(e) {
|
|
|
505
505
|
}
|
|
506
506
|
return t * 0.5;
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
const n =
|
|
508
|
+
function Ci(e, t = 1e-9) {
|
|
509
|
+
const n = qt(e);
|
|
510
510
|
if (n.length < 5) return n;
|
|
511
511
|
const r = [n[0]];
|
|
512
512
|
for (let i = 1; i < n.length - 1; i += 1) {
|
|
513
513
|
const o = r[r.length - 1], s = n[i], a = n[i + 1], c = (s[0] - o[0]) * (a[1] - s[1]) - (s[1] - o[1]) * (a[0] - s[0]);
|
|
514
514
|
Math.abs(c) <= t || r.push(s);
|
|
515
515
|
}
|
|
516
|
-
return r.push(r[0]),
|
|
516
|
+
return r.push(r[0]), qt(r);
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function Ii(e, t, n) {
|
|
519
519
|
const r = n[0] - t[0], i = n[1] - t[1], o = r * r + i * i;
|
|
520
520
|
if (o <= 1e-12) {
|
|
521
|
-
const p = e[0] - t[0],
|
|
522
|
-
return p * p +
|
|
521
|
+
const p = e[0] - t[0], d = e[1] - t[1];
|
|
522
|
+
return p * p + d * d;
|
|
523
523
|
}
|
|
524
|
-
const s =
|
|
524
|
+
const s = on(
|
|
525
525
|
((e[0] - t[0]) * r + (e[1] - t[1]) * i) / o,
|
|
526
526
|
0,
|
|
527
527
|
1
|
|
@@ -540,8 +540,8 @@ function vi(e, t) {
|
|
|
540
540
|
if (c - a <= 1) continue;
|
|
541
541
|
let l = 0, f = -1;
|
|
542
542
|
for (let p = a + 1; p < c; p += 1) {
|
|
543
|
-
const
|
|
544
|
-
|
|
543
|
+
const d = Ii(e[p], e[a], e[c]);
|
|
544
|
+
d > l && (l = d, f = p);
|
|
545
545
|
}
|
|
546
546
|
f >= 0 && l > r && (n[f] = 1, i.push([a, f], [f, c]));
|
|
547
547
|
}
|
|
@@ -551,13 +551,13 @@ function vi(e, t) {
|
|
|
551
551
|
return o;
|
|
552
552
|
}
|
|
553
553
|
function _i(e, t) {
|
|
554
|
-
const n =
|
|
554
|
+
const n = qt(e);
|
|
555
555
|
if (n.length < 5 || t <= 0) return n;
|
|
556
556
|
const r = n.slice(0, -1), i = vi(r, t);
|
|
557
|
-
return i.length < 3 ? n :
|
|
557
|
+
return i.length < 3 ? n : qt(i);
|
|
558
558
|
}
|
|
559
559
|
function Fi(e, t) {
|
|
560
|
-
let n =
|
|
560
|
+
let n = qt(e);
|
|
561
561
|
if (t <= 0 || n.length < 5) return n;
|
|
562
562
|
for (let r = 0; r < t; r += 1) {
|
|
563
563
|
const i = n.slice(0, -1);
|
|
@@ -570,15 +570,15 @@ function Fi(e, t) {
|
|
|
570
570
|
[a[0] * 0.25 + c[0] * 0.75, a[1] * 0.25 + c[1] * 0.75]
|
|
571
571
|
);
|
|
572
572
|
}
|
|
573
|
-
n =
|
|
573
|
+
n = qt(o);
|
|
574
574
|
}
|
|
575
575
|
return n;
|
|
576
576
|
}
|
|
577
577
|
function Pe(e, t) {
|
|
578
|
-
return t ?
|
|
578
|
+
return t ? qt(
|
|
579
579
|
e.map(([n, r]) => [
|
|
580
|
-
|
|
581
|
-
|
|
580
|
+
on(n, t[0], t[2]),
|
|
581
|
+
on(r, t[1], t[3])
|
|
582
582
|
])
|
|
583
583
|
) : e;
|
|
584
584
|
}
|
|
@@ -604,20 +604,20 @@ function Ui(e, t) {
|
|
|
604
604
|
}
|
|
605
605
|
if (!f.length)
|
|
606
606
|
return Pe(mn(n, r), t.clipBounds);
|
|
607
|
-
const
|
|
607
|
+
const d = typeof t.simplifyTolerance == "number" && Number.isFinite(t.simplifyTolerance) ? Math.max(0, t.simplifyTolerance) : s.step * 0.2, b = typeof t.smoothingPasses == "number" && Number.isFinite(t.smoothingPasses) ? Math.round(on(t.smoothingPasses, 0, mi)) : di, m = _i(
|
|
608
608
|
Fi(
|
|
609
|
-
|
|
609
|
+
Ci(f, s.step * 1e-3),
|
|
610
610
|
b
|
|
611
611
|
),
|
|
612
|
-
|
|
612
|
+
d
|
|
613
613
|
);
|
|
614
|
-
return Pe(
|
|
614
|
+
return Pe(m, t.clipBounds);
|
|
615
615
|
}
|
|
616
|
-
function
|
|
616
|
+
function Qn(e) {
|
|
617
617
|
return typeof e == "number" && Number.isFinite(e);
|
|
618
618
|
}
|
|
619
619
|
function Bi(e) {
|
|
620
|
-
return Array.isArray(e) && e.length >= 2 &&
|
|
620
|
+
return Array.isArray(e) && e.length >= 2 && Qn(e[0]) && Qn(e[1]);
|
|
621
621
|
}
|
|
622
622
|
function Rr(e) {
|
|
623
623
|
return Array.isArray(e) && e.length > 0 && e.every((t) => Bi(t));
|
|
@@ -670,7 +670,7 @@ function gn(e) {
|
|
|
670
670
|
o !== n && i.push(t[o]);
|
|
671
671
|
return i;
|
|
672
672
|
}
|
|
673
|
-
function
|
|
673
|
+
function Cr(e) {
|
|
674
674
|
if (!e) return [];
|
|
675
675
|
if (Rr(e)) {
|
|
676
676
|
const t = gn([e]);
|
|
@@ -701,13 +701,13 @@ function jn(e, t, n) {
|
|
|
701
701
|
function Fe(e) {
|
|
702
702
|
const t = [];
|
|
703
703
|
for (const n of e ?? []) {
|
|
704
|
-
const r =
|
|
704
|
+
const r = Cr(n);
|
|
705
705
|
for (const i of r) {
|
|
706
706
|
const o = i[0];
|
|
707
707
|
if (!o || o.length < 4) continue;
|
|
708
708
|
let s = 1 / 0, a = 1 / 0, c = -1 / 0, l = -1 / 0;
|
|
709
|
-
for (const [p,
|
|
710
|
-
p < s && (s = p), p > c && (c = p),
|
|
709
|
+
for (const [p, d] of o)
|
|
710
|
+
p < s && (s = p), p > c && (c = p), d < a && (a = d), d > l && (l = d);
|
|
711
711
|
if (!Number.isFinite(s) || !Number.isFinite(a) || !Number.isFinite(c) || !Number.isFinite(l))
|
|
712
712
|
continue;
|
|
713
713
|
let f = Math.abs(Mn(o));
|
|
@@ -726,15 +726,15 @@ function Fe(e) {
|
|
|
726
726
|
}
|
|
727
727
|
return t;
|
|
728
728
|
}
|
|
729
|
-
function
|
|
729
|
+
function Ir(e, t, n) {
|
|
730
730
|
if (e < n.minX || e > n.maxX || t < n.minY || t > n.maxY || !jn(e, t, n.outer)) return !1;
|
|
731
731
|
for (const r of n.holes)
|
|
732
732
|
if (jn(e, t, r)) return !1;
|
|
733
733
|
return !0;
|
|
734
734
|
}
|
|
735
|
-
function
|
|
735
|
+
function sn(e, t, n) {
|
|
736
736
|
for (const r of n)
|
|
737
|
-
if (
|
|
737
|
+
if (Ir(e, t, r))
|
|
738
738
|
return !0;
|
|
739
739
|
return !1;
|
|
740
740
|
}
|
|
@@ -744,7 +744,7 @@ const vr = [
|
|
|
744
744
|
160,
|
|
745
745
|
255
|
|
746
746
|
];
|
|
747
|
-
function
|
|
747
|
+
function ct(e, t, n) {
|
|
748
748
|
return Math.max(t, Math.min(n, e));
|
|
749
749
|
}
|
|
750
750
|
function _r(e, t, n) {
|
|
@@ -790,7 +790,7 @@ function Ys(e) {
|
|
|
790
790
|
r[i * 4] = t[i][0], r[i * 4 + 1] = t[i][1], r[i * 4 + 2] = t[i][2], r[i * 4 + 3] = t[i][3];
|
|
791
791
|
return { colors: r, termToPaletteIndex: n };
|
|
792
792
|
}
|
|
793
|
-
function
|
|
793
|
+
function tr(e, t, n) {
|
|
794
794
|
const r = e.createShader(e.VERTEX_SHADER), i = e.createShader(e.FRAGMENT_SHADER);
|
|
795
795
|
if (!r || !i)
|
|
796
796
|
throw new Error("Shader allocation failed");
|
|
@@ -805,7 +805,7 @@ function Qn(e, t, n) {
|
|
|
805
805
|
throw new Error(e.getProgramInfoLog(o) || "program link failed");
|
|
806
806
|
return o;
|
|
807
807
|
}
|
|
808
|
-
const Di = "rgba(255, 77, 79, 0.16)",
|
|
808
|
+
const Di = "rgba(255, 77, 79, 0.16)", er = "transparent", Oi = 3, Xi = 2, Fr = 96, Yi = 1, nr = [], _e = [], an = 1e3, Ur = 2, Br = 2, ki = 4096, Wi = 0.2, Vi = 1.12, Gi = 0.89, Hi = 32, qi = "#000000", $i = 0.1, Zi = "#FFCF00", Ki = "#FF0000", Ji = 1.5, rr = [2, 2], Qi = 1, ji = 0.25, to = 4, eo = 1, no = 0, ro = 4, io = 0.05, oo = 256, ir = 1.5, oe = {
|
|
809
809
|
color: "#ff4d4f",
|
|
810
810
|
width: 2,
|
|
811
811
|
lineJoin: "round",
|
|
@@ -824,7 +824,7 @@ const Di = "rgba(255, 77, 79, 0.16)", tr = "transparent", Oi = 3, Xi = 2, Fr = 9
|
|
|
824
824
|
shadowBlur: 0,
|
|
825
825
|
shadowOffsetX: 0,
|
|
826
826
|
shadowOffsetY: 0
|
|
827
|
-
}, ao = "rgba(23, 23, 25, 0.1)", co = 6,
|
|
827
|
+
}, ao = "rgba(23, 23, 25, 0.1)", co = 6, Xt = {
|
|
828
828
|
fontFamily: "Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
829
829
|
fontSize: 11,
|
|
830
830
|
fontWeight: 600,
|
|
@@ -836,7 +836,7 @@ const Di = "rgba(255, 77, 79, 0.16)", tr = "transparent", Oi = 3, Xi = 2, Fr = 9
|
|
|
836
836
|
paddingY: 4,
|
|
837
837
|
offsetY: 10,
|
|
838
838
|
borderRadius: 4
|
|
839
|
-
},
|
|
839
|
+
}, se = {
|
|
840
840
|
fontFamily: "Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
841
841
|
fontSize: 13,
|
|
842
842
|
fontWeight: 500,
|
|
@@ -845,47 +845,47 @@ const Di = "rgba(255, 77, 79, 0.16)", tr = "transparent", Oi = 3, Xi = 2, Fr = 9
|
|
|
845
845
|
borderRadius: 4,
|
|
846
846
|
paddingX: 6,
|
|
847
847
|
paddingY: 3
|
|
848
|
-
},
|
|
848
|
+
}, or = {
|
|
849
849
|
x: 16,
|
|
850
850
|
y: -24
|
|
851
|
-
}, uo = 20,
|
|
852
|
-
function
|
|
851
|
+
}, uo = 20, sr = 1e-6;
|
|
852
|
+
function kt(e, t, n) {
|
|
853
853
|
return Math.max(t, Math.min(n, e));
|
|
854
854
|
}
|
|
855
855
|
function Lr(e, t, n) {
|
|
856
856
|
if (!e || !n) return 0;
|
|
857
857
|
const r = Number(n.minZoom), i = Number(n.maxZoom);
|
|
858
|
-
return !Number.isFinite(r) || !Number.isFinite(i) || i - r <=
|
|
858
|
+
return !Number.isFinite(r) || !Number.isFinite(i) || i - r <= sr || !Number.isFinite(t) ? 0 : t >= i - sr ? uo : 0;
|
|
859
859
|
}
|
|
860
|
-
function
|
|
860
|
+
function Ve(e) {
|
|
861
861
|
return e === "stamp-rectangle" || e === "stamp-circle" || e === "stamp-rectangle-4096px" || e === "stamp-rectangle-2mm2" || e === "stamp-circle-2mm2" || e === "stamp-circle-hpf-0.2mm2";
|
|
862
862
|
}
|
|
863
|
-
function
|
|
863
|
+
function Ie(e, t) {
|
|
864
864
|
return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? t : e;
|
|
865
865
|
}
|
|
866
866
|
function lo(e) {
|
|
867
867
|
return {
|
|
868
|
-
rectangleAreaMm2:
|
|
869
|
-
circleAreaMm2:
|
|
870
|
-
rectanglePixelSize:
|
|
868
|
+
rectangleAreaMm2: Ie(e?.rectangleAreaMm2, Ur),
|
|
869
|
+
circleAreaMm2: Ie(e?.circleAreaMm2, Br),
|
|
870
|
+
rectanglePixelSize: Ie(e?.rectanglePixelSize, ki)
|
|
871
871
|
};
|
|
872
872
|
}
|
|
873
873
|
function fo(e, t) {
|
|
874
|
-
return typeof e != "number" || !Number.isFinite(e) ? t :
|
|
874
|
+
return typeof e != "number" || !Number.isFinite(e) ? t : kt(e, 0, 1);
|
|
875
875
|
}
|
|
876
876
|
function ho(e) {
|
|
877
|
-
if (!Array.isArray(e)) return
|
|
877
|
+
if (!Array.isArray(e)) return rr;
|
|
878
878
|
const t = e.filter((n) => Number.isFinite(n) && n >= 0);
|
|
879
|
-
return t.length > 0 ? t :
|
|
879
|
+
return t.length > 0 ? t : rr;
|
|
880
880
|
}
|
|
881
881
|
function mo(e) {
|
|
882
|
-
return typeof e != "number" || !Number.isFinite(e) ?
|
|
882
|
+
return typeof e != "number" || !Number.isFinite(e) ? Qi : kt(e, ji, to);
|
|
883
883
|
}
|
|
884
884
|
function go(e) {
|
|
885
|
-
return typeof e != "number" || !Number.isFinite(e) ? eo : Math.round(
|
|
885
|
+
return typeof e != "number" || !Number.isFinite(e) ? eo : Math.round(kt(e, no, ro));
|
|
886
886
|
}
|
|
887
887
|
function po(e) {
|
|
888
|
-
const t =
|
|
888
|
+
const t = Ie(e?.radius, Hi), n = Ie(e?.cursorLineWidth, Ji), r = mo(e?.edgeDetail), i = go(e?.edgeSmoothing);
|
|
889
889
|
return {
|
|
890
890
|
radius: t,
|
|
891
891
|
edgeDetail: r,
|
|
@@ -900,10 +900,28 @@ function po(e) {
|
|
|
900
900
|
};
|
|
901
901
|
}
|
|
902
902
|
function bo(e) {
|
|
903
|
-
return e *
|
|
903
|
+
return e * an * an;
|
|
904
904
|
}
|
|
905
|
-
function
|
|
906
|
-
|
|
905
|
+
function ar(e, t, n) {
|
|
906
|
+
if (!e || !Number.isFinite(t) || t <= 0) return [];
|
|
907
|
+
if (n) {
|
|
908
|
+
const r = n.worldToScreen(e[0], e[1]), i = n.worldToScreen(e[0] + t, e[1]);
|
|
909
|
+
if (r && i) {
|
|
910
|
+
const o = Math.hypot(i[0] - r[0], i[1] - r[1]), s = [
|
|
911
|
+
[r[0] - o, r[1] - o],
|
|
912
|
+
[r[0] + o, r[1] - o],
|
|
913
|
+
[r[0] + o, r[1] + o],
|
|
914
|
+
[r[0] - o, r[1] + o]
|
|
915
|
+
], a = [];
|
|
916
|
+
for (const c of s) {
|
|
917
|
+
const l = n.screenToWorld(c);
|
|
918
|
+
if (!l) throw new Error("Failed to create rectangle");
|
|
919
|
+
a.push(l);
|
|
920
|
+
}
|
|
921
|
+
return zt(a);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return zt([
|
|
907
925
|
[e[0] - t, e[1] - t],
|
|
908
926
|
[e[0] + t, e[1] - t],
|
|
909
927
|
[e[0] + t, e[1] + t],
|
|
@@ -917,15 +935,33 @@ function wo(e, t, n = Fr) {
|
|
|
917
935
|
const o = i / n * Math.PI * 2;
|
|
918
936
|
r.push([e[0] + Math.cos(o) * t, e[1] + Math.sin(o) * t]);
|
|
919
937
|
}
|
|
920
|
-
return
|
|
938
|
+
return zt(r);
|
|
921
939
|
}
|
|
922
|
-
function
|
|
940
|
+
function zt(e) {
|
|
923
941
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
924
942
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
925
943
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
926
944
|
}
|
|
927
|
-
function
|
|
928
|
-
|
|
945
|
+
function An(e, t, n) {
|
|
946
|
+
if (!e || !t) return [];
|
|
947
|
+
if (n) {
|
|
948
|
+
const r = n.worldToScreen(e[0], e[1]), i = n.worldToScreen(t[0], t[1]);
|
|
949
|
+
if (r && i) {
|
|
950
|
+
const o = [
|
|
951
|
+
[r[0], r[1]],
|
|
952
|
+
[i[0], r[1]],
|
|
953
|
+
[i[0], i[1]],
|
|
954
|
+
[r[0], i[1]]
|
|
955
|
+
], s = [];
|
|
956
|
+
for (const a of o) {
|
|
957
|
+
const c = n.screenToWorld(a);
|
|
958
|
+
if (!c) return An(e, t);
|
|
959
|
+
s.push(c);
|
|
960
|
+
}
|
|
961
|
+
return zt(s);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
return zt([
|
|
929
965
|
[e[0], e[1]],
|
|
930
966
|
[t[0], e[1]],
|
|
931
967
|
[t[0], t[1]],
|
|
@@ -941,9 +977,9 @@ function cr(e, t, n = Fr) {
|
|
|
941
977
|
const c = a / n * Math.PI * 2;
|
|
942
978
|
s.push([r + Math.cos(c) * o, i + Math.sin(c) * o]);
|
|
943
979
|
}
|
|
944
|
-
return
|
|
980
|
+
return zt(s);
|
|
945
981
|
}
|
|
946
|
-
function
|
|
982
|
+
function rn(e) {
|
|
947
983
|
if (!Array.isArray(e) || e.length < 4) return 0;
|
|
948
984
|
let t = 0;
|
|
949
985
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
@@ -960,9 +996,9 @@ function ur(e) {
|
|
|
960
996
|
return [t, n, r, i];
|
|
961
997
|
}
|
|
962
998
|
function lr(e) {
|
|
963
|
-
return Array.isArray(e) && e.length >= 4 &&
|
|
999
|
+
return Array.isArray(e) && e.length >= 4 && rn(e) > Yi;
|
|
964
1000
|
}
|
|
965
|
-
function
|
|
1001
|
+
function xn(e, t, n = !1) {
|
|
966
1002
|
if (t.length !== 0) {
|
|
967
1003
|
e.moveTo(t[0][0], t[0][1]);
|
|
968
1004
|
for (let r = 1; r < t.length; r += 1)
|
|
@@ -971,28 +1007,28 @@ function An(e, t, n = !1) {
|
|
|
971
1007
|
}
|
|
972
1008
|
}
|
|
973
1009
|
function Ht(e, t, n, r = !1, i = !1, o = Di) {
|
|
974
|
-
t.length !== 0 && (e.beginPath(),
|
|
1010
|
+
t.length !== 0 && (e.beginPath(), xn(e, t, r), i && r && (e.fillStyle = o, e.fill()), e.strokeStyle = n.color, e.lineWidth = n.width, e.lineJoin = n.lineJoin, e.lineCap = n.lineCap, e.shadowColor = n.shadowColor, e.shadowBlur = n.shadowBlur, e.shadowOffsetX = n.shadowOffsetX, e.shadowOffsetY = n.shadowOffsetY, e.setLineDash(n.lineDash), e.stroke(), e.setLineDash(_e), e.shadowColor = "rgba(0, 0, 0, 0)", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0);
|
|
975
1011
|
}
|
|
976
1012
|
function yo(e) {
|
|
977
|
-
if (typeof e != "string") return
|
|
1013
|
+
if (typeof e != "string") return er;
|
|
978
1014
|
const t = e.trim();
|
|
979
|
-
return t.length > 0 ? t :
|
|
1015
|
+
return t.length > 0 ? t : er;
|
|
980
1016
|
}
|
|
981
1017
|
function Nr(e) {
|
|
982
|
-
const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((s) => Number.isFinite(s) && s >= 0) : _e, n = typeof e?.width == "number" && Number.isFinite(e.width) ? Math.max(0, e.width) :
|
|
1018
|
+
const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((s) => Number.isFinite(s) && s >= 0) : _e, n = typeof e?.width == "number" && Number.isFinite(e.width) ? Math.max(0, e.width) : oe.width, r = typeof e?.shadowBlur == "number" && Number.isFinite(e.shadowBlur) ? Math.max(0, e.shadowBlur) : oe.shadowBlur, i = typeof e?.shadowOffsetX == "number" && Number.isFinite(e.shadowOffsetX) ? e.shadowOffsetX : oe.shadowOffsetX, o = typeof e?.shadowOffsetY == "number" && Number.isFinite(e.shadowOffsetY) ? e.shadowOffsetY : oe.shadowOffsetY;
|
|
983
1019
|
return {
|
|
984
|
-
color: e?.color ||
|
|
1020
|
+
color: e?.color || oe.color,
|
|
985
1021
|
width: n,
|
|
986
1022
|
lineDash: t.length ? t : _e,
|
|
987
|
-
lineJoin: e?.lineJoin ||
|
|
988
|
-
lineCap: e?.lineCap ||
|
|
989
|
-
shadowColor: e?.shadowColor ||
|
|
1023
|
+
lineJoin: e?.lineJoin || oe.lineJoin,
|
|
1024
|
+
lineCap: e?.lineCap || oe.lineCap,
|
|
1025
|
+
shadowColor: e?.shadowColor || oe.shadowColor,
|
|
990
1026
|
shadowBlur: r,
|
|
991
1027
|
shadowOffsetX: i,
|
|
992
1028
|
shadowOffsetY: o
|
|
993
1029
|
};
|
|
994
1030
|
}
|
|
995
|
-
function
|
|
1031
|
+
function Ce(e, t) {
|
|
996
1032
|
return t ? Nr({
|
|
997
1033
|
color: t.color ?? e.color,
|
|
998
1034
|
width: t.width ?? e.width,
|
|
@@ -1037,28 +1073,28 @@ function dr(e, t) {
|
|
|
1037
1073
|
const r = [];
|
|
1038
1074
|
for (const i of n) {
|
|
1039
1075
|
if (i.length < 2) continue;
|
|
1040
|
-
const o = t ?
|
|
1076
|
+
const o = t ? zt(i) : i;
|
|
1041
1077
|
o.length >= (t ? 4 : 2) && r.push(o);
|
|
1042
1078
|
}
|
|
1043
1079
|
return r;
|
|
1044
1080
|
}
|
|
1045
1081
|
function xo(e, t, n, r) {
|
|
1046
1082
|
if (!(t.length < 4 || n.length === 0)) {
|
|
1047
|
-
e.save(), e.beginPath(),
|
|
1083
|
+
e.save(), e.beginPath(), xn(e, t, !0);
|
|
1048
1084
|
for (const i of n)
|
|
1049
|
-
i.length < 4 ||
|
|
1085
|
+
i.length < 4 || xn(e, i, !0);
|
|
1050
1086
|
e.fillStyle = r, e.fill("evenodd"), e.restore();
|
|
1051
1087
|
}
|
|
1052
1088
|
}
|
|
1053
|
-
function
|
|
1054
|
-
const t = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) :
|
|
1089
|
+
function _n(e) {
|
|
1090
|
+
const t = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) : Xt.paddingX, n = typeof e?.paddingY == "number" && Number.isFinite(e.paddingY) ? Math.max(0, e.paddingY) : Xt.paddingY, r = typeof e?.fontSize == "number" && Number.isFinite(e.fontSize) ? Math.max(8, e.fontSize) : Xt.fontSize, i = typeof e?.borderWidth == "number" && Number.isFinite(e.borderWidth) ? Math.max(0, e.borderWidth) : Xt.borderWidth, o = typeof e?.offsetY == "number" && Number.isFinite(e.offsetY) ? e.offsetY : Xt.offsetY, s = typeof e?.borderRadius == "number" && Number.isFinite(e.borderRadius) ? Math.max(0, e.borderRadius) : Xt.borderRadius;
|
|
1055
1091
|
return {
|
|
1056
|
-
fontFamily: e?.fontFamily ||
|
|
1092
|
+
fontFamily: e?.fontFamily || Xt.fontFamily,
|
|
1057
1093
|
fontSize: r,
|
|
1058
|
-
fontWeight: e?.fontWeight ||
|
|
1059
|
-
textColor: e?.textColor ||
|
|
1060
|
-
backgroundColor: e?.backgroundColor ||
|
|
1061
|
-
borderColor: e?.borderColor ||
|
|
1094
|
+
fontWeight: e?.fontWeight || Xt.fontWeight,
|
|
1095
|
+
textColor: e?.textColor || Xt.textColor,
|
|
1096
|
+
backgroundColor: e?.backgroundColor || Xt.backgroundColor,
|
|
1097
|
+
borderColor: e?.borderColor || Xt.borderColor,
|
|
1062
1098
|
borderWidth: i,
|
|
1063
1099
|
paddingX: t,
|
|
1064
1100
|
paddingY: n,
|
|
@@ -1067,7 +1103,7 @@ function vn(e) {
|
|
|
1067
1103
|
};
|
|
1068
1104
|
}
|
|
1069
1105
|
function Dr(e, t) {
|
|
1070
|
-
return t ?
|
|
1106
|
+
return t ? _n({
|
|
1071
1107
|
fontFamily: t.fontFamily ?? e.fontFamily,
|
|
1072
1108
|
fontSize: t.fontSize ?? e.fontSize,
|
|
1073
1109
|
fontWeight: t.fontWeight ?? e.fontWeight,
|
|
@@ -1082,27 +1118,27 @@ function Dr(e, t) {
|
|
|
1082
1118
|
}) : e;
|
|
1083
1119
|
}
|
|
1084
1120
|
function To(e) {
|
|
1085
|
-
const t = typeof e?.fontSize == "number" && Number.isFinite(e.fontSize) ? Math.max(8, e.fontSize) :
|
|
1121
|
+
const t = typeof e?.fontSize == "number" && Number.isFinite(e.fontSize) ? Math.max(8, e.fontSize) : se.fontSize, n = typeof e?.borderRadius == "number" && Number.isFinite(e.borderRadius) ? Math.max(0, e.borderRadius) : se.borderRadius, r = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) : se.paddingX, i = typeof e?.paddingY == "number" && Number.isFinite(e.paddingY) ? Math.max(0, e.paddingY) : se.paddingY;
|
|
1086
1122
|
return {
|
|
1087
|
-
fontFamily: e?.fontFamily ||
|
|
1123
|
+
fontFamily: e?.fontFamily || se.fontFamily,
|
|
1088
1124
|
fontSize: t,
|
|
1089
|
-
fontWeight: e?.fontWeight ||
|
|
1090
|
-
textColor: e?.textColor ||
|
|
1091
|
-
backgroundColor: e?.backgroundColor ||
|
|
1125
|
+
fontWeight: e?.fontWeight || se.fontWeight,
|
|
1126
|
+
textColor: e?.textColor || se.textColor,
|
|
1127
|
+
backgroundColor: e?.backgroundColor || se.backgroundColor,
|
|
1092
1128
|
borderRadius: n,
|
|
1093
1129
|
paddingX: r,
|
|
1094
1130
|
paddingY: i
|
|
1095
1131
|
};
|
|
1096
1132
|
}
|
|
1097
1133
|
function Eo(e) {
|
|
1098
|
-
const t = typeof e?.x == "number" && Number.isFinite(e.x) ? e.x :
|
|
1134
|
+
const t = typeof e?.x == "number" && Number.isFinite(e.x) ? e.x : or.x, n = typeof e?.y == "number" && Number.isFinite(e.y) ? e.y : or.y;
|
|
1099
1135
|
return { x: t, y: n };
|
|
1100
1136
|
}
|
|
1101
|
-
function
|
|
1137
|
+
function Tn(e) {
|
|
1102
1138
|
return Number.isFinite(e) ? `${Math.max(0, e).toFixed(3)} mm²` : "0.000 mm²";
|
|
1103
1139
|
}
|
|
1104
1140
|
function Ro(e) {
|
|
1105
|
-
const t = typeof e?.format == "function" ? e.format :
|
|
1141
|
+
const t = typeof e?.format == "function" ? e.format : Tn, n = Eo(e?.cursorOffset);
|
|
1106
1142
|
return {
|
|
1107
1143
|
enabled: e?.enabled === !0,
|
|
1108
1144
|
format: t,
|
|
@@ -1128,7 +1164,7 @@ function Or(e, t, n, r, i, o) {
|
|
|
1128
1164
|
const s = Math.max(0, Math.min(o, r * 0.5, i * 0.5));
|
|
1129
1165
|
e.beginPath(), e.moveTo(t + s, n), e.lineTo(t + r - s, n), e.quadraticCurveTo(t + r, n, t + r, n + s), e.lineTo(t + r, n + i - s), e.quadraticCurveTo(t + r, n + i, t + r - s, n + i), e.lineTo(t + s, n + i), e.quadraticCurveTo(t, n + i, t, n + i - s), e.lineTo(t, n + s), e.quadraticCurveTo(t, n, t + s, n), e.closePath();
|
|
1130
1166
|
}
|
|
1131
|
-
function
|
|
1167
|
+
function Co(e) {
|
|
1132
1168
|
if (!e.length) return null;
|
|
1133
1169
|
let t = 1 / 0;
|
|
1134
1170
|
for (const i of e)
|
|
@@ -1139,16 +1175,16 @@ function Io(e) {
|
|
|
1139
1175
|
Math.abs(i[1] - t) > 0.5 || (i[0] < n && (n = i[0]), i[0] > r && (r = i[0]));
|
|
1140
1176
|
return !Number.isFinite(n) || !Number.isFinite(r) ? null : [(n + r) * 0.5, t];
|
|
1141
1177
|
}
|
|
1142
|
-
function
|
|
1178
|
+
function Io(e) {
|
|
1143
1179
|
let t = null;
|
|
1144
1180
|
for (const n of e) {
|
|
1145
|
-
const r =
|
|
1181
|
+
const r = Co(n.outer);
|
|
1146
1182
|
r && (!t || r[1] < t[1] || r[1] === t[1] && r[0] < t[0]) && (t = r);
|
|
1147
1183
|
}
|
|
1148
1184
|
return t;
|
|
1149
1185
|
}
|
|
1150
1186
|
function mr(e) {
|
|
1151
|
-
const t =
|
|
1187
|
+
const t = Cr(e);
|
|
1152
1188
|
if (t.length === 0) return [];
|
|
1153
1189
|
const n = [];
|
|
1154
1190
|
for (const r of t) {
|
|
@@ -1170,20 +1206,20 @@ function vo(e, t, n, r, i, o) {
|
|
|
1170
1206
|
const s = t.trim();
|
|
1171
1207
|
if (!s) return;
|
|
1172
1208
|
e.save(), e.font = `${o.fontWeight} ${o.fontSize}px ${o.fontFamily}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
1173
|
-
const c = e.measureText(s).width + o.paddingX * 2, l = o.fontSize + o.paddingY * 2, f =
|
|
1174
|
-
e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth, Or(e,
|
|
1209
|
+
const c = e.measureText(s).width + o.paddingX * 2, l = o.fontSize + o.paddingY * 2, f = kt(n[0], c * 0.5 + 1, r - c * 0.5 - 1), p = kt(n[1] - o.offsetY, l * 0.5 + 1, i - l * 0.5 - 1), d = f - c * 0.5, b = p - l * 0.5;
|
|
1210
|
+
e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth, Or(e, d, b, c, l, o.borderRadius), e.fill(), o.borderWidth > 0 && e.stroke(), e.fillStyle = o.textColor, e.fillText(s, f, p + 0.5), e.restore();
|
|
1175
1211
|
}
|
|
1176
1212
|
function _o(e, t, n, r, i, o, s, a) {
|
|
1177
1213
|
const c = t.trim();
|
|
1178
1214
|
if (!c) return;
|
|
1179
1215
|
e.save(), e.font = `${o.fontWeight} ${o.fontSize}px ${o.fontFamily}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
1180
|
-
const f = e.measureText(c).width + o.paddingX * 2, p = o.fontSize + o.paddingY * 2,
|
|
1181
|
-
e.fillStyle = o.backgroundColor, Or(e,
|
|
1216
|
+
const f = e.measureText(c).width + o.paddingX * 2, p = o.fontSize + o.paddingY * 2, d = kt(n[0] + s, f * 0.5 + 1, r - f * 0.5 - 1), b = kt(n[1] + a, p * 0.5 + 1, i - p * 0.5 - 1), m = d - f * 0.5, S = b - p * 0.5;
|
|
1217
|
+
e.fillStyle = o.backgroundColor, Or(e, m, S, f, p, o.borderRadius), e.fill(), e.fillStyle = o.textColor, e.fillText(c, d, b + 0.5), e.restore();
|
|
1182
1218
|
}
|
|
1183
|
-
function
|
|
1184
|
-
return [
|
|
1219
|
+
function Ge(e, t, n) {
|
|
1220
|
+
return [kt(e[0], 0, t), kt(e[1], 0, n)];
|
|
1185
1221
|
}
|
|
1186
|
-
function
|
|
1222
|
+
function ge(e) {
|
|
1187
1223
|
if (!Array.isArray(e) || e.length < 2) return null;
|
|
1188
1224
|
const t = Number(e[0]), n = Number(e[1]);
|
|
1189
1225
|
return !Number.isFinite(t) || !Number.isFinite(n) ? null : [t, n];
|
|
@@ -1201,29 +1237,29 @@ function Fo({
|
|
|
1201
1237
|
onDrawComplete: l,
|
|
1202
1238
|
onPatchComplete: f,
|
|
1203
1239
|
enabled: p,
|
|
1204
|
-
viewStateSignal:
|
|
1240
|
+
viewStateSignal: d,
|
|
1205
1241
|
persistedRegions: b,
|
|
1206
|
-
patchRegions:
|
|
1242
|
+
patchRegions: m,
|
|
1207
1243
|
persistedPolygons: S,
|
|
1208
1244
|
drawFillColor: x,
|
|
1209
1245
|
regionStrokeStyle: _,
|
|
1210
|
-
regionStrokeHoverStyle:
|
|
1246
|
+
regionStrokeHoverStyle: B,
|
|
1211
1247
|
regionStrokeActiveStyle: N,
|
|
1212
1248
|
patchStrokeStyle: V,
|
|
1213
1249
|
resolveRegionStrokeStyle: F,
|
|
1214
|
-
resolveRegionLabelStyle:
|
|
1215
|
-
overlayShapes:
|
|
1250
|
+
resolveRegionLabelStyle: k,
|
|
1251
|
+
overlayShapes: K,
|
|
1216
1252
|
hoveredRegionId: dt = null,
|
|
1217
1253
|
activeRegionId: bt = null,
|
|
1218
|
-
regionLabelStyle:
|
|
1219
|
-
drawAreaTooltip:
|
|
1220
|
-
autoLiftRegionLabelAtMaxZoom:
|
|
1221
|
-
regionLabelAutoLiftOffsetPx:
|
|
1222
|
-
invalidateRef:
|
|
1223
|
-
className:
|
|
1224
|
-
style:
|
|
1254
|
+
regionLabelStyle: Pt,
|
|
1255
|
+
drawAreaTooltip: Ft,
|
|
1256
|
+
autoLiftRegionLabelAtMaxZoom: Bt = !1,
|
|
1257
|
+
regionLabelAutoLiftOffsetPx: ot,
|
|
1258
|
+
invalidateRef: Wt,
|
|
1259
|
+
className: ue,
|
|
1260
|
+
style: le
|
|
1225
1261
|
}) {
|
|
1226
|
-
const
|
|
1262
|
+
const tt = nt(null), Vt = nt(!1), $t = nt(/* @__PURE__ */ new Map()), be = nt(e), Tt = nt({
|
|
1227
1263
|
isDrawing: !1,
|
|
1228
1264
|
pointerId: null,
|
|
1229
1265
|
start: null,
|
|
@@ -1233,34 +1269,34 @@ function Fo({
|
|
|
1233
1269
|
points: [],
|
|
1234
1270
|
screenPoints: [],
|
|
1235
1271
|
stampCenter: null
|
|
1236
|
-
}),
|
|
1237
|
-
id:
|
|
1272
|
+
}), st = p ?? e !== "cursor", R = j(() => b && b.length > 0 ? b : !S || S.length === 0 ? nr : S.map((u, h) => ({
|
|
1273
|
+
id: h,
|
|
1238
1274
|
coordinates: u
|
|
1239
|
-
})), [b, S]),
|
|
1275
|
+
})), [b, S]), E = j(() => m ?? nr, [m]), U = j(() => {
|
|
1240
1276
|
const u = [];
|
|
1241
|
-
for (let
|
|
1242
|
-
const
|
|
1277
|
+
for (let h = 0; h < R.length; h += 1) {
|
|
1278
|
+
const y = R[h], M = mr(y.coordinates);
|
|
1243
1279
|
M.length !== 0 && u.push({
|
|
1244
|
-
region:
|
|
1245
|
-
regionIndex:
|
|
1246
|
-
regionKey:
|
|
1280
|
+
region: y,
|
|
1281
|
+
regionIndex: h,
|
|
1282
|
+
regionKey: y.id ?? h,
|
|
1247
1283
|
polygons: M
|
|
1248
1284
|
});
|
|
1249
1285
|
}
|
|
1250
1286
|
return u;
|
|
1251
|
-
}, [
|
|
1287
|
+
}, [R]), et = j(() => {
|
|
1252
1288
|
const u = [];
|
|
1253
|
-
for (let
|
|
1254
|
-
const
|
|
1289
|
+
for (let h = 0; h < E.length; h += 1) {
|
|
1290
|
+
const y = E[h], M = mr(y.coordinates);
|
|
1255
1291
|
M.length !== 0 && u.push({
|
|
1256
|
-
region:
|
|
1257
|
-
regionIndex:
|
|
1258
|
-
regionKey:
|
|
1292
|
+
region: y,
|
|
1293
|
+
regionIndex: h,
|
|
1294
|
+
regionKey: y.id ?? h,
|
|
1259
1295
|
polygons: M
|
|
1260
1296
|
});
|
|
1261
1297
|
}
|
|
1262
1298
|
return u;
|
|
1263
|
-
}, [
|
|
1299
|
+
}, [E]), W = j(() => Nr(_), [_]), ut = j(() => Ce(W, B), [W, B]), wt = j(() => Ce(W, N), [W, N]), J = j(() => Ce(so, V), [V]), G = j(() => yo(x), [x]), rt = j(() => _n(Pt), [Pt]), lt = j(() => Ro(Ft), [Ft]), Q = j(() => lo(o), [o]), X = j(() => po(s), [s]), mt = j(
|
|
1264
1300
|
() => ({
|
|
1265
1301
|
position: "absolute",
|
|
1266
1302
|
inset: 0,
|
|
@@ -1269,483 +1305,490 @@ function Fo({
|
|
|
1269
1305
|
height: "100%",
|
|
1270
1306
|
display: "block",
|
|
1271
1307
|
touchAction: "none",
|
|
1272
|
-
pointerEvents:
|
|
1273
|
-
cursor:
|
|
1274
|
-
...
|
|
1308
|
+
pointerEvents: st ? "auto" : "none",
|
|
1309
|
+
cursor: st ? e === "brush" ? "none" : "crosshair" : "default",
|
|
1310
|
+
...le
|
|
1275
1311
|
}),
|
|
1276
|
-
[
|
|
1277
|
-
),
|
|
1278
|
-
const u =
|
|
1312
|
+
[st, e, le]
|
|
1313
|
+
), ft = I(() => {
|
|
1314
|
+
const u = tt.current;
|
|
1279
1315
|
if (!u) return;
|
|
1280
|
-
const
|
|
1316
|
+
const h = u.getBoundingClientRect(), y = Math.max(1, window.devicePixelRatio || 1), M = Math.max(1, Math.round(h.width * y)), T = Math.max(1, Math.round(h.height * y));
|
|
1281
1317
|
(u.width !== M || u.height !== T) && (u.width = M, u.height = T);
|
|
1282
|
-
}, []),
|
|
1318
|
+
}, []), H = I(
|
|
1283
1319
|
(u) => {
|
|
1284
|
-
const
|
|
1285
|
-
if (!
|
|
1286
|
-
const
|
|
1320
|
+
const h = a.current;
|
|
1321
|
+
if (!h || u.length === 0) return [];
|
|
1322
|
+
const y = new Array(u.length);
|
|
1287
1323
|
for (let M = 0; M < u.length; M += 1) {
|
|
1288
|
-
const T =
|
|
1324
|
+
const T = ge(h.worldToScreen(u[M][0], u[M][1]));
|
|
1289
1325
|
if (!T) return [];
|
|
1290
|
-
|
|
1326
|
+
y[M] = T;
|
|
1291
1327
|
}
|
|
1292
|
-
return
|
|
1328
|
+
return y;
|
|
1293
1329
|
},
|
|
1294
1330
|
[a]
|
|
1295
|
-
),
|
|
1331
|
+
), yt = I(
|
|
1296
1332
|
(u) => {
|
|
1297
|
-
const
|
|
1298
|
-
if (!
|
|
1299
|
-
const M =
|
|
1300
|
-
return T ?
|
|
1333
|
+
const h = a.current, y = tt.current;
|
|
1334
|
+
if (!h || !y) return null;
|
|
1335
|
+
const M = y.getBoundingClientRect(), T = ge(h.screenToWorld(M.left + u[0], M.top + u[1]));
|
|
1336
|
+
return T ? Ge(T, t, n) : null;
|
|
1301
1337
|
},
|
|
1302
1338
|
[a, t, n]
|
|
1303
|
-
),
|
|
1339
|
+
), Et = I(() => {
|
|
1340
|
+
const u = a.current, h = u?.getViewState?.().rotationDeg ?? 0;
|
|
1341
|
+
if (!(Math.abs(h % 360) < 0.01 || !u))
|
|
1342
|
+
return {
|
|
1343
|
+
worldToScreen: (y, M) => ge(u.worldToScreen(y, M)),
|
|
1344
|
+
screenToWorld: yt
|
|
1345
|
+
};
|
|
1346
|
+
}, [a, yt]), Dt = I(
|
|
1304
1347
|
(u) => {
|
|
1305
1348
|
if (!Number.isFinite(u) || u <= 0) return 0;
|
|
1306
|
-
const
|
|
1307
|
-
return u /
|
|
1349
|
+
const h = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, y = typeof i == "number" && Number.isFinite(i) ? i : 0, M = a.current?.getViewState?.().zoom, T = typeof M == "number" && Number.isFinite(M) && M > 0 ? M : 1, D = y + Math.log2(T), L = Math.max(1e-9, _r(h, y, D));
|
|
1350
|
+
return u / L / T;
|
|
1308
1351
|
},
|
|
1309
1352
|
[r, i, a]
|
|
1310
|
-
),
|
|
1311
|
-
(u,
|
|
1312
|
-
if (!
|
|
1313
|
-
let
|
|
1353
|
+
), Ot = I(
|
|
1354
|
+
(u, h) => {
|
|
1355
|
+
if (!h) return [];
|
|
1356
|
+
let y = 0;
|
|
1314
1357
|
if (u === "stamp-rectangle-4096px") {
|
|
1315
|
-
const
|
|
1316
|
-
return
|
|
1358
|
+
const D = Q.rectanglePixelSize * 0.5;
|
|
1359
|
+
return ar(h, D, Et()).map((L) => Ge(L, t, n));
|
|
1317
1360
|
}
|
|
1318
|
-
if (u === "stamp-rectangle" || u === "stamp-rectangle-2mm2" ?
|
|
1319
|
-
const M = bo(
|
|
1361
|
+
if (u === "stamp-rectangle" || u === "stamp-rectangle-2mm2" ? y = u === "stamp-rectangle-2mm2" ? Ur : Q.rectangleAreaMm2 : (u === "stamp-circle" || u === "stamp-circle-2mm2" || u === "stamp-circle-hpf-0.2mm2") && (y = u === "stamp-circle-hpf-0.2mm2" ? Wi : u === "stamp-circle-2mm2" ? Br : Q.circleAreaMm2), !Number.isFinite(y) || y <= 0) return [];
|
|
1362
|
+
const M = bo(y);
|
|
1320
1363
|
let T = [];
|
|
1321
1364
|
if (u === "stamp-rectangle" || u === "stamp-rectangle-2mm2") {
|
|
1322
|
-
const
|
|
1323
|
-
T =
|
|
1365
|
+
const D = Dt(Math.sqrt(M) * 0.5);
|
|
1366
|
+
T = ar(h, D, Et());
|
|
1324
1367
|
} else if (u === "stamp-circle" || u === "stamp-circle-2mm2" || u === "stamp-circle-hpf-0.2mm2") {
|
|
1325
|
-
const
|
|
1326
|
-
T = wo(
|
|
1368
|
+
const D = Dt(Math.sqrt(M / Math.PI));
|
|
1369
|
+
T = wo(h, D);
|
|
1327
1370
|
}
|
|
1328
|
-
return T.length ? T.map((
|
|
1371
|
+
return T.length ? T.map((D) => Ge(D, t, n)) : [];
|
|
1329
1372
|
},
|
|
1330
|
-
[Dt, t, n, Q]
|
|
1331
|
-
),
|
|
1332
|
-
const u =
|
|
1333
|
-
return
|
|
1334
|
-
}, [e,
|
|
1373
|
+
[Dt, t, n, Q, Et]
|
|
1374
|
+
), Ct = I(() => {
|
|
1375
|
+
const u = Tt.current;
|
|
1376
|
+
return Ve(e) ? Ot(e, u.stampCenter) : e === "brush" ? [] : u.isDrawing ? e === "freehand" ? u.points : e === "rectangle" ? An(u.start, u.current, Et()) : e === "circular" ? cr(u.start, u.current) : [] : [];
|
|
1377
|
+
}, [e, Ot, Et]), St = I(
|
|
1335
1378
|
(u) => {
|
|
1336
|
-
const
|
|
1337
|
-
if (!
|
|
1338
|
-
const
|
|
1339
|
-
if (
|
|
1340
|
-
const M =
|
|
1379
|
+
const h = Tt.current;
|
|
1380
|
+
if (!h.isDrawing || h.screenPoints.length === 0) return;
|
|
1381
|
+
const y = h.screenPoints;
|
|
1382
|
+
if (y.length === 0) return;
|
|
1383
|
+
const M = X.radius;
|
|
1341
1384
|
if (!(!Number.isFinite(M) || M <= 0)) {
|
|
1342
|
-
if (u.save(), u.globalAlpha =
|
|
1343
|
-
u.beginPath(), u.arc(
|
|
1385
|
+
if (u.save(), u.globalAlpha = X.fillOpacity, u.fillStyle = X.fillColor, u.strokeStyle = X.fillColor, u.lineCap = "round", u.lineJoin = "round", u.lineWidth = M * 2, y.length === 1)
|
|
1386
|
+
u.beginPath(), u.arc(y[0][0], y[0][1], M, 0, Math.PI * 2), u.fill();
|
|
1344
1387
|
else {
|
|
1345
|
-
u.beginPath(), u.moveTo(
|
|
1346
|
-
for (let T = 1; T <
|
|
1347
|
-
u.lineTo(
|
|
1388
|
+
u.beginPath(), u.moveTo(y[0][0], y[0][1]);
|
|
1389
|
+
for (let T = 1; T < y.length; T += 1)
|
|
1390
|
+
u.lineTo(y[T][0], y[T][1]);
|
|
1348
1391
|
u.stroke();
|
|
1349
1392
|
}
|
|
1350
1393
|
u.restore();
|
|
1351
1394
|
}
|
|
1352
1395
|
},
|
|
1353
|
-
[
|
|
1354
|
-
),
|
|
1396
|
+
[X]
|
|
1397
|
+
), $ = I(
|
|
1355
1398
|
(u) => {
|
|
1356
|
-
const
|
|
1357
|
-
if (!
|
|
1358
|
-
const M =
|
|
1399
|
+
const h = Tt.current, y = h.cursor;
|
|
1400
|
+
if (!y) return;
|
|
1401
|
+
const M = h.cursorScreen ?? ge(a.current?.worldToScreen(y[0], y[1]) ?? []);
|
|
1359
1402
|
if (!M) return;
|
|
1360
|
-
const T =
|
|
1361
|
-
!Number.isFinite(T) || T <= 0 || (u.save(), u.beginPath(), u.arc(M[0], M[1], T, 0, Math.PI * 2), u.strokeStyle =
|
|
1403
|
+
const T = X.radius;
|
|
1404
|
+
!Number.isFinite(T) || T <= 0 || (u.save(), u.beginPath(), u.arc(M[0], M[1], T, 0, Math.PI * 2), u.strokeStyle = h.isDrawing ? X.cursorActiveColor : X.cursorColor, u.lineWidth = X.cursorLineWidth, u.setLineDash(X.cursorLineDash), u.stroke(), u.setLineDash(_e), u.restore());
|
|
1362
1405
|
},
|
|
1363
|
-
[a,
|
|
1364
|
-
),
|
|
1365
|
-
|
|
1366
|
-
const u =
|
|
1406
|
+
[a, X]
|
|
1407
|
+
), Zt = I(() => {
|
|
1408
|
+
ft();
|
|
1409
|
+
const u = tt.current;
|
|
1367
1410
|
if (!u) return;
|
|
1368
|
-
const
|
|
1369
|
-
if (!
|
|
1370
|
-
const
|
|
1371
|
-
if (
|
|
1372
|
-
for (const
|
|
1373
|
-
const { region:
|
|
1374
|
-
let
|
|
1411
|
+
const h = u.getContext("2d");
|
|
1412
|
+
if (!h) return;
|
|
1413
|
+
const y = Math.max(1, window.devicePixelRatio || 1), M = u.width / y, T = u.height / y;
|
|
1414
|
+
if (h.setTransform(1, 0, 0, 1, 0, 0), h.clearRect(0, 0, u.width, u.height), h.setTransform(y, 0, 0, y, 0, 0), U.length > 0)
|
|
1415
|
+
for (const L of U) {
|
|
1416
|
+
const { region: it, polygons: Z, regionIndex: Y, regionKey: ht } = L, pt = fr(bt, ht) ? "active" : fr(dt, ht) ? "hover" : "default";
|
|
1417
|
+
let Lt = pt === "active" ? wt : pt === "hover" ? ut : W;
|
|
1375
1418
|
if (F) {
|
|
1376
|
-
const
|
|
1377
|
-
region:
|
|
1378
|
-
regionId:
|
|
1379
|
-
regionIndex:
|
|
1419
|
+
const xt = F({
|
|
1420
|
+
region: it,
|
|
1421
|
+
regionId: ht,
|
|
1422
|
+
regionIndex: Y,
|
|
1380
1423
|
state: pt
|
|
1381
1424
|
});
|
|
1382
|
-
|
|
1425
|
+
Lt = Ce(Lt, xt || void 0);
|
|
1383
1426
|
}
|
|
1384
|
-
const
|
|
1385
|
-
for (const
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1388
|
-
for (const
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1427
|
+
const Rt = pt === "default" ? null : Po(Lt);
|
|
1428
|
+
for (const xt of Z) {
|
|
1429
|
+
const Gt = H(xt.outer);
|
|
1430
|
+
Gt.length >= 4 && (Rt && Ht(h, Gt, Rt, !0, !1), Ht(h, Gt, Lt, !0, !1));
|
|
1431
|
+
for (const Kt of xt.holes) {
|
|
1432
|
+
const It = H(Kt);
|
|
1433
|
+
It.length >= 4 && (Rt && Ht(h, It, Rt, !0, !1), Ht(h, It, Lt, !0, !1));
|
|
1391
1434
|
}
|
|
1392
1435
|
}
|
|
1393
1436
|
}
|
|
1394
|
-
if (
|
|
1395
|
-
for (const
|
|
1396
|
-
for (const
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1399
|
-
for (const
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1437
|
+
if (et.length > 0)
|
|
1438
|
+
for (const L of et)
|
|
1439
|
+
for (const it of L.polygons) {
|
|
1440
|
+
const Z = H(it.outer);
|
|
1441
|
+
Z.length >= 4 && Ht(h, Z, J, !0, !1);
|
|
1442
|
+
for (const Y of it.holes) {
|
|
1443
|
+
const ht = H(Y);
|
|
1444
|
+
ht.length >= 4 && Ht(h, ht, J, !0, !1);
|
|
1402
1445
|
}
|
|
1403
1446
|
}
|
|
1404
|
-
if (Array.isArray(
|
|
1405
|
-
const
|
|
1406
|
-
|
|
1447
|
+
if (Array.isArray(K) && K.length > 0) {
|
|
1448
|
+
const L = !!globalThis.__OPEN_PLANT_DEBUG_OVERLAY__, it = H(
|
|
1449
|
+
zt([
|
|
1407
1450
|
[0, 0],
|
|
1408
1451
|
[t, 0],
|
|
1409
1452
|
[t, n],
|
|
1410
1453
|
[0, n]
|
|
1411
1454
|
])
|
|
1412
1455
|
);
|
|
1413
|
-
for (let
|
|
1414
|
-
const
|
|
1415
|
-
if (!
|
|
1416
|
-
const
|
|
1417
|
-
if (
|
|
1418
|
-
const
|
|
1419
|
-
for (const
|
|
1420
|
-
const
|
|
1421
|
-
|
|
1456
|
+
for (let Z = 0; Z < K.length; Z += 1) {
|
|
1457
|
+
const Y = K[Z];
|
|
1458
|
+
if (!Y?.coordinates?.length || Y.visible === !1) continue;
|
|
1459
|
+
const ht = Y.closed ?? So(Y.coordinates), pt = dr(Y.coordinates, ht);
|
|
1460
|
+
if (Y.invertedFill?.fillColor) {
|
|
1461
|
+
const Rt = [], xt = dr(Y.coordinates, !0);
|
|
1462
|
+
for (const Gt of xt) {
|
|
1463
|
+
const Kt = H(Gt);
|
|
1464
|
+
Kt.length >= 4 && Rt.push(Kt);
|
|
1422
1465
|
}
|
|
1423
|
-
if (
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1426
|
-
id:
|
|
1427
|
-
outerRingPoints:
|
|
1428
|
-
sourceRingCount:
|
|
1429
|
-
holeRingCount:
|
|
1430
|
-
fillColor:
|
|
1466
|
+
if (L) {
|
|
1467
|
+
const Gt = String(Y.id ?? Z), Kt = `${it.length}|${xt.length}|${Rt.length}|${Y.invertedFill.fillColor}`;
|
|
1468
|
+
$t.current.get(Gt) !== Kt && ($t.current.set(Gt, Kt), console.debug("[open-plant] invertedFill", {
|
|
1469
|
+
id: Y.id ?? Z,
|
|
1470
|
+
outerRingPoints: it.length,
|
|
1471
|
+
sourceRingCount: xt.length,
|
|
1472
|
+
holeRingCount: Rt.length,
|
|
1473
|
+
fillColor: Y.invertedFill.fillColor
|
|
1431
1474
|
}));
|
|
1432
1475
|
}
|
|
1433
|
-
xo(
|
|
1476
|
+
xo(h, it, Rt, Y.invertedFill.fillColor);
|
|
1434
1477
|
}
|
|
1435
1478
|
if (pt.length === 0) continue;
|
|
1436
|
-
const
|
|
1437
|
-
for (const
|
|
1438
|
-
const
|
|
1439
|
-
|
|
1479
|
+
const Lt = Ce(W, Y.stroke ?? Y.strokeStyle);
|
|
1480
|
+
for (const Rt of pt) {
|
|
1481
|
+
const xt = H(Rt);
|
|
1482
|
+
xt.length < 2 || Ht(h, xt, Lt, ht, Y.fill ?? !1);
|
|
1440
1483
|
}
|
|
1441
1484
|
}
|
|
1442
1485
|
}
|
|
1443
|
-
const
|
|
1444
|
-
if (
|
|
1486
|
+
const D = Ct();
|
|
1487
|
+
if (st) {
|
|
1445
1488
|
if (e === "brush")
|
|
1446
|
-
|
|
1447
|
-
else if (
|
|
1489
|
+
St(h), $(h);
|
|
1490
|
+
else if (D.length > 0)
|
|
1448
1491
|
if (e === "freehand") {
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1492
|
+
const L = H(D);
|
|
1493
|
+
L.length >= 2 && Ht(h, L, W, !1, !1), L.length >= 3 && Ht(h, H(zt(D)), W, !0, !0, G);
|
|
1451
1494
|
} else {
|
|
1452
|
-
const
|
|
1453
|
-
|
|
1495
|
+
const L = H(D);
|
|
1496
|
+
L.length >= 4 && Ht(h, L, W, !0, !0, G);
|
|
1454
1497
|
}
|
|
1455
1498
|
}
|
|
1456
1499
|
if (U.length > 0) {
|
|
1457
|
-
const
|
|
1458
|
-
for (const
|
|
1459
|
-
if (!
|
|
1460
|
-
const
|
|
1461
|
-
if (!
|
|
1462
|
-
const
|
|
1463
|
-
if (!
|
|
1500
|
+
const L = Math.max(1e-6, a.current?.getViewState?.().zoom ?? 1), it = typeof ot == "number" && Number.isFinite(ot) ? Math.max(0, ot) : Lr(Bt, L, a.current?.getZoomRange?.());
|
|
1501
|
+
for (const Z of U) {
|
|
1502
|
+
if (!Z.region.label) continue;
|
|
1503
|
+
const Y = Io(Z.polygons);
|
|
1504
|
+
if (!Y) continue;
|
|
1505
|
+
const ht = ge(a.current?.worldToScreen(Y[0], Y[1]) ?? []);
|
|
1506
|
+
if (!ht) continue;
|
|
1464
1507
|
let pt = Dr(
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
region:
|
|
1468
|
-
regionId:
|
|
1469
|
-
regionIndex:
|
|
1470
|
-
zoom:
|
|
1508
|
+
rt,
|
|
1509
|
+
k?.({
|
|
1510
|
+
region: Z.region,
|
|
1511
|
+
regionId: Z.regionKey,
|
|
1512
|
+
regionIndex: Z.regionIndex,
|
|
1513
|
+
zoom: L
|
|
1471
1514
|
})
|
|
1472
1515
|
);
|
|
1473
|
-
|
|
1516
|
+
it > 0 && (pt = {
|
|
1474
1517
|
...pt,
|
|
1475
|
-
offsetY: pt.offsetY +
|
|
1476
|
-
}), vo(
|
|
1518
|
+
offsetY: pt.offsetY + it
|
|
1519
|
+
}), vo(h, Z.region.label, ht, M, T, pt);
|
|
1477
1520
|
}
|
|
1478
1521
|
}
|
|
1479
|
-
if (
|
|
1480
|
-
const
|
|
1481
|
-
if (
|
|
1482
|
-
const
|
|
1483
|
-
if (
|
|
1484
|
-
const
|
|
1485
|
-
let pt =
|
|
1522
|
+
if (lt.enabled && st && (e === "freehand" || e === "rectangle" || e === "circular")) {
|
|
1523
|
+
const L = Tt.current;
|
|
1524
|
+
if (L.isDrawing) {
|
|
1525
|
+
const it = e === "freehand" ? zt(D) : D;
|
|
1526
|
+
if (it.length >= 4) {
|
|
1527
|
+
const Z = rn(it), Y = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 0, ht = Y > 0 ? Z * Y * Y / (an * an) : 0;
|
|
1528
|
+
let pt = Tn(ht);
|
|
1486
1529
|
try {
|
|
1487
|
-
pt =
|
|
1530
|
+
pt = lt.format(ht);
|
|
1488
1531
|
} catch {
|
|
1489
|
-
pt =
|
|
1532
|
+
pt = Tn(ht);
|
|
1490
1533
|
}
|
|
1491
|
-
const
|
|
1492
|
-
|
|
1493
|
-
|
|
1534
|
+
const Lt = L.cursorScreen ?? (L.current ? ge(a.current?.worldToScreen(L.current[0], L.current[1]) ?? []) : null);
|
|
1535
|
+
Lt && _o(
|
|
1536
|
+
h,
|
|
1494
1537
|
pt,
|
|
1495
|
-
|
|
1538
|
+
Lt,
|
|
1496
1539
|
M,
|
|
1497
1540
|
T,
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1541
|
+
lt.style,
|
|
1542
|
+
lt.cursorOffsetX,
|
|
1543
|
+
lt.cursorOffsetY
|
|
1501
1544
|
);
|
|
1502
1545
|
}
|
|
1503
1546
|
}
|
|
1504
1547
|
}
|
|
1505
1548
|
}, [
|
|
1506
|
-
|
|
1549
|
+
st,
|
|
1507
1550
|
e,
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1551
|
+
Ct,
|
|
1552
|
+
St,
|
|
1553
|
+
$,
|
|
1554
|
+
ft,
|
|
1555
|
+
H,
|
|
1513
1556
|
t,
|
|
1514
1557
|
n,
|
|
1515
1558
|
a,
|
|
1516
1559
|
U,
|
|
1517
|
-
|
|
1560
|
+
K,
|
|
1518
1561
|
dt,
|
|
1519
1562
|
bt,
|
|
1520
|
-
k,
|
|
1521
|
-
lt,
|
|
1522
|
-
wt,
|
|
1523
1563
|
W,
|
|
1524
|
-
|
|
1525
|
-
|
|
1564
|
+
ut,
|
|
1565
|
+
wt,
|
|
1566
|
+
G,
|
|
1567
|
+
et,
|
|
1568
|
+
J,
|
|
1526
1569
|
F,
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1570
|
+
k,
|
|
1571
|
+
rt,
|
|
1572
|
+
lt,
|
|
1573
|
+
Bt,
|
|
1574
|
+
ot,
|
|
1532
1575
|
r
|
|
1533
|
-
]),
|
|
1534
|
-
|
|
1535
|
-
|
|
1576
|
+
]), z = I(() => {
|
|
1577
|
+
Vt.current || (Vt.current = !0, requestAnimationFrame(() => {
|
|
1578
|
+
Vt.current = !1, Zt();
|
|
1536
1579
|
}));
|
|
1537
|
-
}, [
|
|
1538
|
-
const
|
|
1539
|
-
if (
|
|
1580
|
+
}, [Zt]), Mt = I((u = !1) => {
|
|
1581
|
+
const h = Tt.current, y = tt.current;
|
|
1582
|
+
if (y && h.pointerId !== null && y.hasPointerCapture(h.pointerId))
|
|
1540
1583
|
try {
|
|
1541
|
-
|
|
1584
|
+
y.releasePointerCapture(h.pointerId);
|
|
1542
1585
|
} catch {
|
|
1543
1586
|
}
|
|
1544
|
-
|
|
1545
|
-
}, []),
|
|
1587
|
+
h.isDrawing = !1, h.pointerId = null, h.start = null, h.current = null, h.points = [], h.screenPoints = [], h.stampCenter = null, u || (h.cursor = null, h.cursorScreen = null);
|
|
1588
|
+
}, []), at = I(
|
|
1546
1589
|
(u) => {
|
|
1547
|
-
const
|
|
1548
|
-
if (!
|
|
1549
|
-
const
|
|
1550
|
-
return
|
|
1590
|
+
const h = a.current;
|
|
1591
|
+
if (!h || t <= 0 || n <= 0) return null;
|
|
1592
|
+
const y = ge(h.screenToWorld(u.clientX, u.clientY));
|
|
1593
|
+
return y ? Ge(y, t, n) : null;
|
|
1551
1594
|
},
|
|
1552
1595
|
[a, t, n]
|
|
1553
|
-
),
|
|
1554
|
-
const
|
|
1555
|
-
if (!
|
|
1556
|
-
const
|
|
1596
|
+
), gt = I((u) => {
|
|
1597
|
+
const h = tt.current;
|
|
1598
|
+
if (!h) return null;
|
|
1599
|
+
const y = h.getBoundingClientRect(), M = kt(u.clientX - y.left, 0, y.width), T = kt(u.clientY - y.top, 0, y.height);
|
|
1557
1600
|
return !Number.isFinite(M) || !Number.isFinite(T) ? null : [M, T];
|
|
1558
|
-
}, []),
|
|
1559
|
-
const u =
|
|
1601
|
+
}, []), Re = I(() => {
|
|
1602
|
+
const u = Tt.current;
|
|
1560
1603
|
if (!u.isDrawing) {
|
|
1561
|
-
|
|
1604
|
+
Mt(!0), z();
|
|
1562
1605
|
return;
|
|
1563
1606
|
}
|
|
1564
|
-
let
|
|
1607
|
+
let h = [];
|
|
1565
1608
|
if (e === "freehand")
|
|
1566
|
-
u.points.length >= Oi && (
|
|
1609
|
+
u.points.length >= Oi && (h = zt(u.points));
|
|
1567
1610
|
else if (e === "rectangle")
|
|
1568
|
-
|
|
1611
|
+
h = An(u.start, u.current, Et());
|
|
1569
1612
|
else if (e === "circular")
|
|
1570
|
-
|
|
1613
|
+
h = cr(u.start, u.current);
|
|
1571
1614
|
else if (e === "brush") {
|
|
1572
|
-
const
|
|
1573
|
-
if (
|
|
1574
|
-
|
|
1615
|
+
const y = u.points[u.points.length - 1] ?? u.current ?? u.start;
|
|
1616
|
+
if (X.clickSelectRoi && y && u.points.length <= 1 && c?.(y)) {
|
|
1617
|
+
Mt(!0), z();
|
|
1575
1618
|
return;
|
|
1576
1619
|
}
|
|
1577
|
-
const M =
|
|
1620
|
+
const M = X.edgeDetail, T = Math.max(
|
|
1578
1621
|
io,
|
|
1579
|
-
|
|
1580
|
-
),
|
|
1581
|
-
radius:
|
|
1622
|
+
X.radius * 2 / (oo * M)
|
|
1623
|
+
), D = u.screenPoints.length > 0 ? u.screenPoints : H(u.points), L = Ui(D, {
|
|
1624
|
+
radius: X.radius,
|
|
1582
1625
|
minRasterStep: T,
|
|
1583
1626
|
circleSides: Math.max(24, Math.round(64 * M)),
|
|
1584
1627
|
simplifyTolerance: T * 0.25,
|
|
1585
|
-
smoothingPasses:
|
|
1586
|
-
}),
|
|
1587
|
-
for (const
|
|
1588
|
-
const
|
|
1589
|
-
|
|
1628
|
+
smoothingPasses: X.edgeSmoothing
|
|
1629
|
+
}), it = [];
|
|
1630
|
+
for (const Z of L) {
|
|
1631
|
+
const Y = yt(Z);
|
|
1632
|
+
Y && it.push(Y);
|
|
1590
1633
|
}
|
|
1591
|
-
|
|
1634
|
+
h = zt(it);
|
|
1592
1635
|
}
|
|
1593
|
-
(e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") && lr(
|
|
1636
|
+
(e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") && lr(h) && l && l({
|
|
1594
1637
|
tool: e,
|
|
1595
1638
|
intent: e === "brush" ? "brush" : "roi",
|
|
1596
|
-
coordinates:
|
|
1597
|
-
bbox: ur(
|
|
1598
|
-
areaPx:
|
|
1599
|
-
}),
|
|
1600
|
-
}, [e, l,
|
|
1601
|
-
(u,
|
|
1602
|
-
const
|
|
1603
|
-
if (!lr(
|
|
1639
|
+
coordinates: h,
|
|
1640
|
+
bbox: ur(h),
|
|
1641
|
+
areaPx: rn(h)
|
|
1642
|
+
}), Mt(!0), z();
|
|
1643
|
+
}, [e, l, Mt, z, H, yt, Et, X.radius, X.edgeDetail, X.edgeSmoothing, X.clickSelectRoi, c]), te = I(
|
|
1644
|
+
(u, h) => {
|
|
1645
|
+
const y = Ot(u, h);
|
|
1646
|
+
if (!lr(y)) return;
|
|
1604
1647
|
const M = u === "stamp-rectangle-4096px" ? "patch" : "roi", T = {
|
|
1605
1648
|
tool: u,
|
|
1606
1649
|
intent: M,
|
|
1607
|
-
coordinates:
|
|
1608
|
-
bbox: ur(
|
|
1609
|
-
areaPx:
|
|
1650
|
+
coordinates: y,
|
|
1651
|
+
bbox: ur(y),
|
|
1652
|
+
areaPx: rn(y)
|
|
1610
1653
|
};
|
|
1611
1654
|
l?.(T), M === "patch" && f && f(T);
|
|
1612
1655
|
},
|
|
1613
|
-
[
|
|
1614
|
-
),
|
|
1615
|
-
(u,
|
|
1616
|
-
const M =
|
|
1656
|
+
[Ot, l, f]
|
|
1657
|
+
), we = I(
|
|
1658
|
+
(u, h, y) => {
|
|
1659
|
+
const M = ir * ir, T = u.screenPoints[u.screenPoints.length - 1];
|
|
1617
1660
|
if (!T) {
|
|
1618
|
-
u.points.push(
|
|
1661
|
+
u.points.push(h), u.screenPoints.push(y), u.current = h;
|
|
1619
1662
|
return;
|
|
1620
1663
|
}
|
|
1621
|
-
const
|
|
1622
|
-
|
|
1664
|
+
const D = y[0] - T[0], L = y[1] - T[1];
|
|
1665
|
+
D * D + L * L >= M ? (u.points.push(h), u.screenPoints.push(y)) : (u.points[u.points.length - 1] = h, u.screenPoints[u.screenPoints.length - 1] = y), u.current = h;
|
|
1623
1666
|
},
|
|
1624
1667
|
[]
|
|
1625
|
-
),
|
|
1668
|
+
), Ue = I(
|
|
1626
1669
|
(u) => {
|
|
1627
|
-
if (!
|
|
1628
|
-
const
|
|
1629
|
-
if (!
|
|
1630
|
-
const
|
|
1631
|
-
if (!
|
|
1632
|
-
if (u.preventDefault(), u.stopPropagation(),
|
|
1633
|
-
const
|
|
1634
|
-
|
|
1670
|
+
if (!st || e === "cursor" || u.button !== 0) return;
|
|
1671
|
+
const h = at(u);
|
|
1672
|
+
if (!h) return;
|
|
1673
|
+
const y = gt(u);
|
|
1674
|
+
if (!y) return;
|
|
1675
|
+
if (u.preventDefault(), u.stopPropagation(), Ve(e)) {
|
|
1676
|
+
const D = Tt.current;
|
|
1677
|
+
D.stampCenter = h, te(e, h), z();
|
|
1635
1678
|
return;
|
|
1636
1679
|
}
|
|
1637
|
-
const M =
|
|
1680
|
+
const M = tt.current;
|
|
1638
1681
|
M && M.setPointerCapture(u.pointerId);
|
|
1639
|
-
const T =
|
|
1640
|
-
T.isDrawing = !0, T.pointerId = u.pointerId, T.start =
|
|
1682
|
+
const T = Tt.current;
|
|
1683
|
+
T.isDrawing = !0, T.pointerId = u.pointerId, T.start = h, T.current = h, T.cursor = h, T.cursorScreen = y, T.points = e === "freehand" || e === "brush" ? [h] : [], T.screenPoints = e === "brush" ? [y] : [], z();
|
|
1641
1684
|
},
|
|
1642
|
-
[
|
|
1643
|
-
),
|
|
1685
|
+
[st, e, at, gt, te, z]
|
|
1686
|
+
), fe = I(
|
|
1644
1687
|
(u) => {
|
|
1645
|
-
if (!
|
|
1646
|
-
const
|
|
1647
|
-
if (!
|
|
1648
|
-
const
|
|
1649
|
-
if (!
|
|
1650
|
-
const M =
|
|
1651
|
-
if (M.cursor =
|
|
1652
|
-
M.stampCenter =
|
|
1688
|
+
if (!st || e === "cursor") return;
|
|
1689
|
+
const h = at(u);
|
|
1690
|
+
if (!h) return;
|
|
1691
|
+
const y = gt(u);
|
|
1692
|
+
if (!y) return;
|
|
1693
|
+
const M = Tt.current;
|
|
1694
|
+
if (M.cursor = h, M.cursorScreen = y, Ve(e)) {
|
|
1695
|
+
M.stampCenter = h, u.preventDefault(), u.stopPropagation(), z();
|
|
1653
1696
|
return;
|
|
1654
1697
|
}
|
|
1655
1698
|
if (e === "brush") {
|
|
1656
1699
|
if (!M.isDrawing || M.pointerId !== u.pointerId) {
|
|
1657
|
-
|
|
1700
|
+
z();
|
|
1658
1701
|
return;
|
|
1659
1702
|
}
|
|
1660
|
-
u.preventDefault(), u.stopPropagation(),
|
|
1703
|
+
u.preventDefault(), u.stopPropagation(), we(M, h, y), z();
|
|
1661
1704
|
return;
|
|
1662
1705
|
}
|
|
1663
1706
|
if (!(!M.isDrawing || M.pointerId !== u.pointerId)) {
|
|
1664
1707
|
if (u.preventDefault(), u.stopPropagation(), e === "freehand") {
|
|
1665
|
-
const T = a.current,
|
|
1666
|
-
if (!
|
|
1667
|
-
M.points.push(
|
|
1708
|
+
const T = a.current, D = Math.max(1e-6, T?.getViewState?.().zoom ?? 1), L = Xi / D, it = L * L, Z = M.points[M.points.length - 1];
|
|
1709
|
+
if (!Z)
|
|
1710
|
+
M.points.push(h);
|
|
1668
1711
|
else {
|
|
1669
|
-
const
|
|
1670
|
-
|
|
1712
|
+
const Y = h[0] - Z[0], ht = h[1] - Z[1];
|
|
1713
|
+
Y * Y + ht * ht >= it && M.points.push(h);
|
|
1671
1714
|
}
|
|
1672
1715
|
} else
|
|
1673
|
-
M.current =
|
|
1674
|
-
|
|
1716
|
+
M.current = h;
|
|
1717
|
+
z();
|
|
1675
1718
|
}
|
|
1676
1719
|
},
|
|
1677
|
-
[
|
|
1678
|
-
),
|
|
1720
|
+
[st, e, at, gt, z, a, we]
|
|
1721
|
+
), At = I(
|
|
1679
1722
|
(u) => {
|
|
1680
|
-
const
|
|
1681
|
-
if (!
|
|
1723
|
+
const h = Tt.current;
|
|
1724
|
+
if (!h.isDrawing || h.pointerId !== u.pointerId) return;
|
|
1682
1725
|
u.preventDefault(), u.stopPropagation();
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1685
|
-
const T =
|
|
1726
|
+
const y = at(u), M = gt(u);
|
|
1727
|
+
y && (h.cursor = y, M && (h.cursorScreen = M), e === "brush" ? M && we(h, y, M) : h.current = y);
|
|
1728
|
+
const T = tt.current;
|
|
1686
1729
|
if (T && T.hasPointerCapture(u.pointerId))
|
|
1687
1730
|
try {
|
|
1688
1731
|
T.releasePointerCapture(u.pointerId);
|
|
1689
1732
|
} catch {
|
|
1690
1733
|
}
|
|
1691
|
-
|
|
1734
|
+
Re();
|
|
1692
1735
|
},
|
|
1693
|
-
[
|
|
1694
|
-
),
|
|
1695
|
-
const u =
|
|
1696
|
-
let
|
|
1697
|
-
e === "brush" && !u.isDrawing && u.cursor && (u.cursor = null, u.cursorScreen = null,
|
|
1698
|
-
}, [e,
|
|
1699
|
-
return
|
|
1700
|
-
|
|
1701
|
-
const u =
|
|
1736
|
+
[Re, at, gt, e, we]
|
|
1737
|
+
), Be = I(() => {
|
|
1738
|
+
const u = Tt.current;
|
|
1739
|
+
let h = !1;
|
|
1740
|
+
e === "brush" && !u.isDrawing && u.cursor && (u.cursor = null, u.cursorScreen = null, h = !0), Ve(e) && u.stampCenter && (u.stampCenter = null, h = !0), h && z();
|
|
1741
|
+
}, [e, z]);
|
|
1742
|
+
return O(() => {
|
|
1743
|
+
ft(), z();
|
|
1744
|
+
const u = tt.current;
|
|
1702
1745
|
if (!u) return;
|
|
1703
|
-
const
|
|
1704
|
-
|
|
1746
|
+
const h = new ResizeObserver(() => {
|
|
1747
|
+
ft(), z();
|
|
1705
1748
|
});
|
|
1706
|
-
return
|
|
1707
|
-
|
|
1749
|
+
return h.observe(u), () => {
|
|
1750
|
+
h.disconnect();
|
|
1708
1751
|
};
|
|
1709
|
-
}, [
|
|
1710
|
-
|
|
1711
|
-
}, [
|
|
1712
|
-
be.current !== e && (be.current = e,
|
|
1713
|
-
}, [e,
|
|
1714
|
-
|
|
1715
|
-
}, [
|
|
1716
|
-
if (
|
|
1717
|
-
return
|
|
1718
|
-
|
|
1752
|
+
}, [ft, z]), O(() => {
|
|
1753
|
+
st || Mt(), z();
|
|
1754
|
+
}, [st, z, Mt]), O(() => {
|
|
1755
|
+
be.current !== e && (be.current = e, Mt(), z());
|
|
1756
|
+
}, [e, Mt, z]), O(() => {
|
|
1757
|
+
z();
|
|
1758
|
+
}, [d, R, K, z]), O(() => {
|
|
1759
|
+
if (Wt)
|
|
1760
|
+
return Wt.current = z, () => {
|
|
1761
|
+
Wt.current === z && (Wt.current = null);
|
|
1719
1762
|
};
|
|
1720
|
-
}, [
|
|
1721
|
-
if (!
|
|
1722
|
-
const u = (
|
|
1723
|
-
|
|
1763
|
+
}, [Wt, z]), O(() => {
|
|
1764
|
+
if (!st) return;
|
|
1765
|
+
const u = (h) => {
|
|
1766
|
+
h.key === "Escape" && (Mt(), z());
|
|
1724
1767
|
};
|
|
1725
1768
|
return window.addEventListener("keydown", u), () => {
|
|
1726
1769
|
window.removeEventListener("keydown", u);
|
|
1727
1770
|
};
|
|
1728
|
-
}, [
|
|
1771
|
+
}, [st, Mt, z]), /* @__PURE__ */ jt(
|
|
1729
1772
|
"canvas",
|
|
1730
1773
|
{
|
|
1731
|
-
ref:
|
|
1732
|
-
className:
|
|
1774
|
+
ref: tt,
|
|
1775
|
+
className: ue,
|
|
1733
1776
|
style: mt,
|
|
1734
|
-
onPointerDown:
|
|
1735
|
-
onPointerMove:
|
|
1736
|
-
onPointerUp:
|
|
1737
|
-
onPointerCancel:
|
|
1738
|
-
onPointerLeave:
|
|
1777
|
+
onPointerDown: Ue,
|
|
1778
|
+
onPointerMove: fe,
|
|
1779
|
+
onPointerUp: At,
|
|
1780
|
+
onPointerCancel: At,
|
|
1781
|
+
onPointerLeave: Be,
|
|
1739
1782
|
onContextMenu: (u) => {
|
|
1740
|
-
|
|
1783
|
+
st && u.preventDefault();
|
|
1741
1784
|
},
|
|
1742
1785
|
onWheel: (u) => {
|
|
1743
|
-
if (!
|
|
1744
|
-
const
|
|
1745
|
-
if (!
|
|
1786
|
+
if (!st) return;
|
|
1787
|
+
const h = tt.current, y = a.current;
|
|
1788
|
+
if (!h || typeof y?.zoomBy != "function") return;
|
|
1746
1789
|
u.preventDefault(), u.stopPropagation();
|
|
1747
|
-
const M =
|
|
1748
|
-
|
|
1790
|
+
const M = h.getBoundingClientRect(), T = u.clientX - M.left, D = u.clientY - M.top;
|
|
1791
|
+
y.zoomBy(u.deltaY < 0 ? Vi : Gi, T, D), z();
|
|
1749
1792
|
}
|
|
1750
1793
|
}
|
|
1751
1794
|
);
|
|
@@ -1777,11 +1820,11 @@ function ks(e, t) {
|
|
|
1777
1820
|
const n = e?.imsInfo || {}, r = !!e?.imsInfo, i = Number(n.width ?? e?.width ?? 0), o = Number(n.height ?? e?.height ?? 0), s = Number(n.tileSize ?? e?.tileSize ?? 0), a = Number(n.zoom ?? e?.zoom ?? 0), c = String(n.path ?? e?.path ?? ""), l = Number(n.mpp ?? e?.mpp ?? 0);
|
|
1778
1821
|
if (!i || !o || !s || !c)
|
|
1779
1822
|
throw new Error("이미지 메타데이터가 불완전합니다. width/height/tileSize/path 확인 필요");
|
|
1780
|
-
const f = Array.isArray(e?.terms) ? e.terms.map((
|
|
1781
|
-
termId: String(
|
|
1782
|
-
termName: String(
|
|
1783
|
-
termColor: String(
|
|
1784
|
-
})) : [], p = Xr(c),
|
|
1823
|
+
const f = Array.isArray(e?.terms) ? e.terms.map((m) => ({
|
|
1824
|
+
termId: String(m?.termId ?? ""),
|
|
1825
|
+
termName: String(m?.termName ?? ""),
|
|
1826
|
+
termColor: String(m?.termColor ?? "")
|
|
1827
|
+
})) : [], p = Xr(c), d = Uo(t), b = r ? (m, S, x) => `${d}${p}/${m}/${x}_${S}.webp` : void 0;
|
|
1785
1828
|
return {
|
|
1786
1829
|
id: e?._id || "unknown",
|
|
1787
1830
|
name: e?.name || "unknown",
|
|
@@ -1802,7 +1845,7 @@ function Yr(e, t, n, r) {
|
|
|
1802
1845
|
const i = Xr(e.tilePath);
|
|
1803
1846
|
return `${e.tileBaseUrl}${i}/${t}/${r}_${n}.webp`;
|
|
1804
1847
|
}
|
|
1805
|
-
const
|
|
1848
|
+
const _t = {
|
|
1806
1849
|
width: 200,
|
|
1807
1850
|
height: 125,
|
|
1808
1851
|
margin: 16,
|
|
@@ -1824,8 +1867,8 @@ function pr(e, t, n, r) {
|
|
|
1824
1867
|
for (let o = 0; o < i; o += 1) {
|
|
1825
1868
|
const s = t[o], a = t[(o + 1) % i], c = Math.hypot(a[0] - s[0], a[1] - s[1]);
|
|
1826
1869
|
if (c < 1e-6) continue;
|
|
1827
|
-
const l = Math.max(1, Math.round((c + r) / (n + r))), f = l * n + (l - 1) * r, p = c / Math.max(1e-6, f),
|
|
1828
|
-
e.beginPath(), e.moveTo(s[0], s[1]), e.lineTo(a[0], a[1]), e.setLineDash([
|
|
1870
|
+
const l = Math.max(1, Math.round((c + r) / (n + r))), f = l * n + (l - 1) * r, p = c / Math.max(1e-6, f), d = n * p, b = r * p;
|
|
1871
|
+
e.beginPath(), e.moveTo(s[0], s[1]), e.lineTo(a[0], a[1]), e.setLineDash([d, b]), e.lineDashOffset = 0, e.stroke();
|
|
1829
1872
|
}
|
|
1830
1873
|
e.setLineDash([]), e.lineDashOffset = 0;
|
|
1831
1874
|
}
|
|
@@ -1833,7 +1876,7 @@ function pr(e, t, n, r) {
|
|
|
1833
1876
|
function Ee(e, t, n = 1) {
|
|
1834
1877
|
return typeof e != "number" || !Number.isFinite(e) ? t : Math.max(n, e);
|
|
1835
1878
|
}
|
|
1836
|
-
function
|
|
1879
|
+
function He(e) {
|
|
1837
1880
|
return Array.isArray(e) && e.length === 4 && Number.isFinite(e[0]) && Number.isFinite(e[1]) && Number.isFinite(e[2]) && Number.isFinite(e[3]);
|
|
1838
1881
|
}
|
|
1839
1882
|
const Bo = {
|
|
@@ -1864,54 +1907,54 @@ function Lo({
|
|
|
1864
1907
|
className: o,
|
|
1865
1908
|
style: s
|
|
1866
1909
|
}) {
|
|
1867
|
-
const a =
|
|
1910
|
+
const a = nt(null), c = nt(null), l = nt(null), f = nt({
|
|
1868
1911
|
active: !1,
|
|
1869
1912
|
pointerId: null
|
|
1870
|
-
}), p =
|
|
1913
|
+
}), p = nt(null), d = nt(!1), b = Ee(
|
|
1871
1914
|
r?.width,
|
|
1872
|
-
|
|
1915
|
+
_t.width,
|
|
1873
1916
|
64
|
|
1874
|
-
),
|
|
1917
|
+
), m = Ee(
|
|
1875
1918
|
r?.height,
|
|
1876
|
-
|
|
1919
|
+
_t.height,
|
|
1877
1920
|
48
|
|
1878
|
-
), S =
|
|
1879
|
-
const
|
|
1880
|
-
let
|
|
1881
|
-
return U >
|
|
1882
|
-
x: (b -
|
|
1883
|
-
y: (
|
|
1884
|
-
w:
|
|
1885
|
-
h:
|
|
1921
|
+
), S = j(() => {
|
|
1922
|
+
const R = Math.max(1, e.width), E = Math.max(1, e.height), U = R / E, et = b / m;
|
|
1923
|
+
let W, ut;
|
|
1924
|
+
return U > et ? (W = b, ut = b / U) : (ut = m, W = m * U), {
|
|
1925
|
+
x: (b - W) / 2,
|
|
1926
|
+
y: (m - ut) / 2,
|
|
1927
|
+
w: W,
|
|
1928
|
+
h: ut
|
|
1886
1929
|
};
|
|
1887
|
-
}, [e.width, e.height, b,
|
|
1930
|
+
}, [e.width, e.height, b, m]), x = Ee(
|
|
1888
1931
|
r?.margin,
|
|
1889
|
-
|
|
1932
|
+
_t.margin,
|
|
1890
1933
|
0
|
|
1891
1934
|
), _ = Ee(
|
|
1892
1935
|
r?.borderRadius,
|
|
1893
|
-
|
|
1936
|
+
_t.borderRadius,
|
|
1894
1937
|
0
|
|
1895
|
-
),
|
|
1938
|
+
), B = Ee(
|
|
1896
1939
|
r?.borderWidth,
|
|
1897
|
-
|
|
1940
|
+
_t.borderWidth,
|
|
1898
1941
|
0
|
|
1899
1942
|
), N = Math.max(
|
|
1900
1943
|
1,
|
|
1901
1944
|
Math.round(
|
|
1902
1945
|
Ee(
|
|
1903
1946
|
r?.maxThumbnailTiles,
|
|
1904
|
-
|
|
1947
|
+
_t.maxThumbnailTiles,
|
|
1905
1948
|
1
|
|
1906
1949
|
)
|
|
1907
1950
|
)
|
|
1908
|
-
), V = r?.backgroundColor ||
|
|
1909
|
-
const
|
|
1910
|
-
return
|
|
1951
|
+
), V = r?.backgroundColor || _t.backgroundColor, F = r?.borderColor || _t.borderColor, k = r?.viewportBorderColor || _t.viewportBorderColor, K = r?.viewportBorderStyle === "stroke" || r?.viewportBorderStyle === "dash" ? r.viewportBorderStyle : _t.viewportBorderStyle, dt = r?.viewportFillColor ?? _t.viewportFillColor, bt = r?.interactive ?? _t.interactive, Pt = r?.showThumbnail ?? _t.showThumbnail, Ft = r?.position || _t.position, Bt = r?.onClose, ot = r?.closeIcon, Wt = r?.closeButtonStyle, ue = j(() => {
|
|
1952
|
+
const R = {};
|
|
1953
|
+
return Ft === "top-left" || Ft === "bottom-left" ? R.left = x : R.right = x, Ft === "top-left" || Ft === "top-right" ? R.top = x : R.bottom = x, {
|
|
1911
1954
|
position: "absolute",
|
|
1912
|
-
...
|
|
1955
|
+
...R,
|
|
1913
1956
|
width: b,
|
|
1914
|
-
height:
|
|
1957
|
+
height: m,
|
|
1915
1958
|
borderRadius: _,
|
|
1916
1959
|
overflow: "hidden",
|
|
1917
1960
|
zIndex: 4,
|
|
@@ -1920,204 +1963,199 @@ function Lo({
|
|
|
1920
1963
|
boxShadow: "0 10px 22px rgba(0, 0, 0, 0.3)",
|
|
1921
1964
|
...s
|
|
1922
1965
|
};
|
|
1923
|
-
}, [x,
|
|
1924
|
-
const
|
|
1966
|
+
}, [x, Ft, b, m, _, bt, s]), le = I(() => {
|
|
1967
|
+
const R = a.current;
|
|
1968
|
+
if (!R) return;
|
|
1969
|
+
const E = R.getContext("2d");
|
|
1925
1970
|
if (!E) return;
|
|
1926
|
-
const
|
|
1927
|
-
|
|
1928
|
-
const
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
U - L,
|
|
1935
|
-
nt - L
|
|
1971
|
+
const U = b, et = m, W = Math.max(1, window.devicePixelRatio || 1), ut = Math.max(1, Math.round(U * W)), wt = Math.max(1, Math.round(et * W));
|
|
1972
|
+
(R.width !== ut || R.height !== wt) && (R.width = ut, R.height = wt), E.setTransform(1, 0, 0, 1, 0, 0), E.clearRect(0, 0, R.width, R.height), E.setTransform(W, 0, 0, W, 0, 0), E.fillStyle = V, E.fillRect(0, 0, U, et);
|
|
1973
|
+
const { x: J, y: G, w: rt, h: lt } = S, Q = c.current;
|
|
1974
|
+
Q && E.drawImage(Q, J, G, rt, lt), E.strokeStyle = F, E.lineWidth = B, E.strokeRect(
|
|
1975
|
+
B * 0.5,
|
|
1976
|
+
B * 0.5,
|
|
1977
|
+
U - B,
|
|
1978
|
+
et - B
|
|
1936
1979
|
);
|
|
1937
|
-
const
|
|
1938
|
-
if (!
|
|
1939
|
-
l.current =
|
|
1940
|
-
const
|
|
1980
|
+
const X = t.current, mt = X?.getViewBounds?.(), ft = X?.getViewCorners?.(), H = He(mt) ? mt : He(l.current) ? l.current : null;
|
|
1981
|
+
if (!H) return;
|
|
1982
|
+
l.current = H;
|
|
1983
|
+
const yt = rt / Math.max(1, e.width), Et = lt / Math.max(1, e.height), Dt = Array.isArray(ft) && ft.length >= 4 && ft.every(
|
|
1941
1984
|
(at) => Array.isArray(at) && at.length >= 2 && Number.isFinite(at[0]) && Number.isFinite(at[1])
|
|
1942
|
-
) ?
|
|
1943
|
-
if (
|
|
1944
|
-
const at =
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
}
|
|
1952
|
-
P.beginPath();
|
|
1953
|
-
for (let St = 0; St < at.length; St += 1)
|
|
1954
|
-
St === 0 ? P.moveTo(at[St][0], at[St][1]) : P.lineTo(at[St][0], at[St][1]);
|
|
1955
|
-
P.closePath(), P.fillStyle = dt, P.fill(), P.strokeStyle = Y, P.lineWidth = 2.25, Kt ? pr(P, at, 4, 3) : P.stroke();
|
|
1985
|
+
) ? ft : null, Ot = K === "dash";
|
|
1986
|
+
if (Dt) {
|
|
1987
|
+
const at = Dt.map(
|
|
1988
|
+
(gt) => [J + gt[0] * yt, G + gt[1] * Et]
|
|
1989
|
+
);
|
|
1990
|
+
E.save(), E.beginPath(), E.rect(J, G, rt, lt), E.clip(), E.beginPath();
|
|
1991
|
+
for (let gt = 0; gt < at.length; gt += 1)
|
|
1992
|
+
gt === 0 ? E.moveTo(at[gt][0], at[gt][1]) : E.lineTo(at[gt][0], at[gt][1]);
|
|
1993
|
+
E.closePath(), E.fillStyle = dt, E.fill(), E.strokeStyle = k, E.lineWidth = 2.25, Ot ? pr(E, at, 4, 3) : E.stroke(), E.restore();
|
|
1956
1994
|
return;
|
|
1957
1995
|
}
|
|
1958
|
-
const
|
|
1959
|
-
if (
|
|
1996
|
+
const Ct = ct(J + H[0] * yt, J, J + rt), St = ct(G + H[1] * Et, G, G + lt), $ = ct(J + H[2] * yt, J, J + rt), Zt = ct(G + H[3] * Et, G, G + lt), z = Math.max(1, $ - Ct), Mt = Math.max(1, Zt - St);
|
|
1997
|
+
if (E.fillStyle = dt, E.fillRect(Ct, St, z, Mt), E.strokeStyle = k, E.lineWidth = 2.25, Ot) {
|
|
1960
1998
|
const at = [
|
|
1961
|
-
[
|
|
1962
|
-
[
|
|
1963
|
-
[
|
|
1964
|
-
[
|
|
1999
|
+
[Ct + 0.5, St + 0.5],
|
|
2000
|
+
[Ct + 0.5 + Math.max(1, z - 1), St + 0.5],
|
|
2001
|
+
[Ct + 0.5 + Math.max(1, z - 1), St + 0.5 + Math.max(1, Mt - 1)],
|
|
2002
|
+
[Ct + 0.5, St + 0.5 + Math.max(1, Mt - 1)]
|
|
1965
2003
|
];
|
|
1966
|
-
pr(
|
|
2004
|
+
pr(E, at, 4, 3);
|
|
1967
2005
|
} else
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
Math.max(1,
|
|
1972
|
-
Math.max(1,
|
|
2006
|
+
E.strokeRect(
|
|
2007
|
+
Ct + 0.5,
|
|
2008
|
+
St + 0.5,
|
|
2009
|
+
Math.max(1, z - 1),
|
|
2010
|
+
Math.max(1, Mt - 1)
|
|
1973
2011
|
);
|
|
1974
2012
|
}, [
|
|
1975
2013
|
b,
|
|
1976
|
-
|
|
2014
|
+
m,
|
|
1977
2015
|
S,
|
|
1978
2016
|
V,
|
|
1979
2017
|
F,
|
|
1980
|
-
|
|
2018
|
+
B,
|
|
1981
2019
|
t,
|
|
1982
2020
|
e.width,
|
|
1983
2021
|
e.height,
|
|
1984
2022
|
dt,
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
]),
|
|
1988
|
-
|
|
1989
|
-
|
|
2023
|
+
k,
|
|
2024
|
+
K
|
|
2025
|
+
]), tt = I(() => {
|
|
2026
|
+
d.current || (d.current = !0, p.current = requestAnimationFrame(() => {
|
|
2027
|
+
d.current = !1, p.current = null, le();
|
|
1990
2028
|
}));
|
|
1991
|
-
}, [
|
|
1992
|
-
(
|
|
2029
|
+
}, [le]), Vt = I(
|
|
2030
|
+
(R, E) => {
|
|
1993
2031
|
const U = a.current;
|
|
1994
2032
|
if (!U) return null;
|
|
1995
|
-
const
|
|
1996
|
-
if (!
|
|
1997
|
-
const
|
|
1998
|
-
return [
|
|
2033
|
+
const et = U.getBoundingClientRect();
|
|
2034
|
+
if (!et.width || !et.height) return null;
|
|
2035
|
+
const W = et.width / b, ut = et.height / m, wt = S.x * W, J = S.y * ut, G = S.w * W, rt = S.h * ut, lt = ct((R - et.left - wt) / G, 0, 1), Q = ct((E - et.top - J) / rt, 0, 1);
|
|
2036
|
+
return [lt * e.width, Q * e.height];
|
|
1999
2037
|
},
|
|
2000
|
-
[e.width, e.height, b,
|
|
2001
|
-
),
|
|
2002
|
-
(
|
|
2038
|
+
[e.width, e.height, b, m, S]
|
|
2039
|
+
), $t = I(
|
|
2040
|
+
(R, E) => {
|
|
2003
2041
|
const U = t.current;
|
|
2004
2042
|
if (!U) return;
|
|
2005
2043
|
if (U.setViewCenter) {
|
|
2006
|
-
U.setViewCenter(
|
|
2044
|
+
U.setViewCenter(R, E), tt();
|
|
2007
2045
|
return;
|
|
2008
2046
|
}
|
|
2009
|
-
const
|
|
2010
|
-
if (!
|
|
2011
|
-
const
|
|
2047
|
+
const et = U.getViewBounds?.(), W = He(et) ? et : He(l.current) ? l.current : null;
|
|
2048
|
+
if (!W) return;
|
|
2049
|
+
const ut = Math.max(1e-6, W[2] - W[0]), wt = Math.max(1e-6, W[3] - W[1]);
|
|
2012
2050
|
U.setViewState({
|
|
2013
|
-
offsetX:
|
|
2014
|
-
offsetY:
|
|
2015
|
-
}),
|
|
2051
|
+
offsetX: R - ut * 0.5,
|
|
2052
|
+
offsetY: E - wt * 0.5
|
|
2053
|
+
}), tt();
|
|
2016
2054
|
},
|
|
2017
|
-
[t,
|
|
2018
|
-
), be =
|
|
2019
|
-
(
|
|
2020
|
-
if (!bt ||
|
|
2021
|
-
const
|
|
2022
|
-
if (!
|
|
2023
|
-
const U =
|
|
2024
|
-
U && (
|
|
2055
|
+
[t, tt]
|
|
2056
|
+
), be = I(
|
|
2057
|
+
(R) => {
|
|
2058
|
+
if (!bt || R.button !== 0) return;
|
|
2059
|
+
const E = a.current;
|
|
2060
|
+
if (!E) return;
|
|
2061
|
+
const U = Vt(R.clientX, R.clientY);
|
|
2062
|
+
U && (R.preventDefault(), R.stopPropagation(), E.setPointerCapture(R.pointerId), f.current = { active: !0, pointerId: R.pointerId }, $t(U[0], U[1]));
|
|
2025
2063
|
},
|
|
2026
|
-
[bt,
|
|
2027
|
-
),
|
|
2028
|
-
(
|
|
2029
|
-
const
|
|
2030
|
-
if (!
|
|
2031
|
-
const U =
|
|
2032
|
-
U && (
|
|
2064
|
+
[bt, Vt, $t]
|
|
2065
|
+
), Tt = I(
|
|
2066
|
+
(R) => {
|
|
2067
|
+
const E = f.current;
|
|
2068
|
+
if (!E.active || E.pointerId !== R.pointerId) return;
|
|
2069
|
+
const U = Vt(R.clientX, R.clientY);
|
|
2070
|
+
U && (R.preventDefault(), R.stopPropagation(), $t(U[0], U[1]));
|
|
2033
2071
|
},
|
|
2034
|
-
[
|
|
2035
|
-
),
|
|
2036
|
-
(
|
|
2037
|
-
const
|
|
2038
|
-
if (!
|
|
2072
|
+
[Vt, $t]
|
|
2073
|
+
), st = I(
|
|
2074
|
+
(R) => {
|
|
2075
|
+
const E = f.current;
|
|
2076
|
+
if (!E.active || E.pointerId !== R.pointerId) return;
|
|
2039
2077
|
const U = a.current;
|
|
2040
|
-
if (U && U.hasPointerCapture(
|
|
2078
|
+
if (U && U.hasPointerCapture(R.pointerId))
|
|
2041
2079
|
try {
|
|
2042
|
-
U.releasePointerCapture(
|
|
2080
|
+
U.releasePointerCapture(R.pointerId);
|
|
2043
2081
|
} catch {
|
|
2044
2082
|
}
|
|
2045
|
-
f.current = { active: !1, pointerId: null },
|
|
2083
|
+
f.current = { active: !1, pointerId: null }, tt();
|
|
2046
2084
|
},
|
|
2047
|
-
[
|
|
2085
|
+
[tt]
|
|
2048
2086
|
);
|
|
2049
|
-
return
|
|
2050
|
-
let
|
|
2051
|
-
c.current = null,
|
|
2052
|
-
const
|
|
2053
|
-
if (!
|
|
2087
|
+
return O(() => {
|
|
2088
|
+
let R = !1;
|
|
2089
|
+
c.current = null, tt();
|
|
2090
|
+
const E = 0, U = 2 ** (e.maxTierZoom - E), et = Math.ceil(e.width / U), W = Math.ceil(e.height / U), ut = Math.max(1, Math.ceil(et / e.tileSize)), wt = Math.max(1, Math.ceil(W / e.tileSize)), J = ut * wt;
|
|
2091
|
+
if (!Pt || J > N)
|
|
2054
2092
|
return;
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2057
|
-
const
|
|
2058
|
-
if (!
|
|
2093
|
+
const G = document.createElement("canvas");
|
|
2094
|
+
G.width = Math.max(1, Math.round(S.w)), G.height = Math.max(1, Math.round(S.h));
|
|
2095
|
+
const rt = G.getContext("2d");
|
|
2096
|
+
if (!rt)
|
|
2059
2097
|
return;
|
|
2060
|
-
|
|
2061
|
-
const
|
|
2098
|
+
rt.fillStyle = V, rt.fillRect(0, 0, G.width, G.height);
|
|
2099
|
+
const lt = [];
|
|
2062
2100
|
for (let Q = 0; Q < wt; Q += 1)
|
|
2063
|
-
for (let
|
|
2064
|
-
const mt =
|
|
2065
|
-
|
|
2066
|
-
url: Yr(e,
|
|
2067
|
-
bounds: [mt,
|
|
2101
|
+
for (let X = 0; X < ut; X += 1) {
|
|
2102
|
+
const mt = X * e.tileSize * U, ft = Q * e.tileSize * U, H = Math.min((X + 1) * e.tileSize, et) * U, yt = Math.min((Q + 1) * e.tileSize, W) * U;
|
|
2103
|
+
lt.push({
|
|
2104
|
+
url: Yr(e, E, X, Q),
|
|
2105
|
+
bounds: [mt, ft, H, yt]
|
|
2068
2106
|
});
|
|
2069
2107
|
}
|
|
2070
2108
|
return Promise.allSettled(
|
|
2071
|
-
|
|
2072
|
-
const
|
|
2073
|
-
headers:
|
|
2109
|
+
lt.map(async (Q) => {
|
|
2110
|
+
const X = !!n, mt = await fetch(Q.url, {
|
|
2111
|
+
headers: X ? { Authorization: n } : void 0
|
|
2074
2112
|
});
|
|
2075
2113
|
if (!mt.ok)
|
|
2076
2114
|
throw new Error(`HTTP ${mt.status}`);
|
|
2077
|
-
const
|
|
2078
|
-
return { tile: Q, bitmap:
|
|
2115
|
+
const ft = await createImageBitmap(await mt.blob());
|
|
2116
|
+
return { tile: Q, bitmap: ft };
|
|
2079
2117
|
})
|
|
2080
2118
|
).then((Q) => {
|
|
2081
|
-
if (
|
|
2082
|
-
for (const
|
|
2083
|
-
|
|
2119
|
+
if (R) {
|
|
2120
|
+
for (const ft of Q)
|
|
2121
|
+
ft.status === "fulfilled" && ft.value.bitmap.close();
|
|
2084
2122
|
return;
|
|
2085
2123
|
}
|
|
2086
|
-
const
|
|
2087
|
-
for (const
|
|
2088
|
-
if (
|
|
2124
|
+
const X = G.width / Math.max(1, e.width), mt = G.height / Math.max(1, e.height);
|
|
2125
|
+
for (const ft of Q) {
|
|
2126
|
+
if (ft.status !== "fulfilled") continue;
|
|
2089
2127
|
const {
|
|
2090
|
-
tile: { bounds:
|
|
2091
|
-
bitmap:
|
|
2092
|
-
} =
|
|
2093
|
-
|
|
2128
|
+
tile: { bounds: H },
|
|
2129
|
+
bitmap: yt
|
|
2130
|
+
} = ft.value, Et = H[0] * X, Dt = H[1] * mt, Ot = Math.max(1, (H[2] - H[0]) * X), Ct = Math.max(1, (H[3] - H[1]) * mt);
|
|
2131
|
+
rt.drawImage(yt, Et, Dt, Ot, Ct), yt.close();
|
|
2094
2132
|
}
|
|
2095
|
-
c.current =
|
|
2133
|
+
c.current = G, tt();
|
|
2096
2134
|
}), () => {
|
|
2097
|
-
|
|
2135
|
+
R = !0;
|
|
2098
2136
|
};
|
|
2099
2137
|
}, [
|
|
2100
2138
|
e,
|
|
2101
2139
|
n,
|
|
2102
2140
|
S,
|
|
2103
2141
|
V,
|
|
2104
|
-
|
|
2142
|
+
Pt,
|
|
2105
2143
|
N,
|
|
2106
|
-
|
|
2107
|
-
]),
|
|
2108
|
-
|
|
2109
|
-
}, [
|
|
2144
|
+
tt
|
|
2145
|
+
]), O(() => {
|
|
2146
|
+
tt();
|
|
2147
|
+
}, [tt]), O(() => {
|
|
2110
2148
|
if (i)
|
|
2111
|
-
return i.current =
|
|
2112
|
-
i.current ===
|
|
2149
|
+
return i.current = tt, () => {
|
|
2150
|
+
i.current === tt && (i.current = null);
|
|
2113
2151
|
};
|
|
2114
|
-
}, [i,
|
|
2152
|
+
}, [i, tt]), O(
|
|
2115
2153
|
() => () => {
|
|
2116
|
-
f.current = { active: !1, pointerId: null }, p.current !== null && (cancelAnimationFrame(p.current), p.current = null),
|
|
2154
|
+
f.current = { active: !1, pointerId: null }, p.current !== null && (cancelAnimationFrame(p.current), p.current = null), d.current = !1;
|
|
2117
2155
|
},
|
|
2118
2156
|
[]
|
|
2119
|
-
), /* @__PURE__ */ Tr("div", { className: o, style:
|
|
2120
|
-
/* @__PURE__ */
|
|
2157
|
+
), /* @__PURE__ */ Tr("div", { className: o, style: ue, children: [
|
|
2158
|
+
/* @__PURE__ */ jt(
|
|
2121
2159
|
"canvas",
|
|
2122
2160
|
{
|
|
2123
2161
|
ref: a,
|
|
@@ -2128,27 +2166,27 @@ function Lo({
|
|
|
2128
2166
|
borderRadius: "inherit"
|
|
2129
2167
|
},
|
|
2130
2168
|
onPointerDown: be,
|
|
2131
|
-
onPointerMove:
|
|
2132
|
-
onPointerUp:
|
|
2133
|
-
onPointerCancel:
|
|
2134
|
-
onContextMenu: (
|
|
2135
|
-
|
|
2169
|
+
onPointerMove: Tt,
|
|
2170
|
+
onPointerUp: st,
|
|
2171
|
+
onPointerCancel: st,
|
|
2172
|
+
onContextMenu: (R) => {
|
|
2173
|
+
R.preventDefault();
|
|
2136
2174
|
},
|
|
2137
|
-
onWheel: (
|
|
2138
|
-
|
|
2175
|
+
onWheel: (R) => {
|
|
2176
|
+
R.preventDefault(), R.stopPropagation();
|
|
2139
2177
|
}
|
|
2140
2178
|
}
|
|
2141
2179
|
),
|
|
2142
|
-
|
|
2180
|
+
Bt && /* @__PURE__ */ jt(
|
|
2143
2181
|
"button",
|
|
2144
2182
|
{
|
|
2145
2183
|
type: "button",
|
|
2146
2184
|
"aria-label": "Hide overview map",
|
|
2147
|
-
onClick: (
|
|
2148
|
-
|
|
2185
|
+
onClick: (R) => {
|
|
2186
|
+
R.stopPropagation(), Bt();
|
|
2149
2187
|
},
|
|
2150
|
-
style:
|
|
2151
|
-
children:
|
|
2188
|
+
style: Wt ? { ...Wt } : { ...Bo },
|
|
2189
|
+
children: ot ?? "×"
|
|
2152
2190
|
}
|
|
2153
2191
|
)
|
|
2154
2192
|
] });
|
|
@@ -2161,11 +2199,11 @@ function Ws({
|
|
|
2161
2199
|
className: i,
|
|
2162
2200
|
style: o
|
|
2163
2201
|
}) {
|
|
2164
|
-
const s =
|
|
2202
|
+
const s = nt(null), a = nt(null), c = j(
|
|
2165
2203
|
() => ({ width: "100%", height: "100%", display: "block", ...o }),
|
|
2166
2204
|
[o]
|
|
2167
2205
|
);
|
|
2168
|
-
return
|
|
2206
|
+
return O(() => {
|
|
2169
2207
|
const l = s.current;
|
|
2170
2208
|
if (!l)
|
|
2171
2209
|
return;
|
|
@@ -2178,13 +2216,13 @@ function Ws({
|
|
|
2178
2216
|
return a.current = f, f.setTiles(n), () => {
|
|
2179
2217
|
f.destroy(), a.current = null;
|
|
2180
2218
|
};
|
|
2181
|
-
}, [e, t]),
|
|
2219
|
+
}, [e, t]), O(() => {
|
|
2182
2220
|
const l = a.current;
|
|
2183
2221
|
l && l.setTiles(n);
|
|
2184
|
-
}, [n]),
|
|
2222
|
+
}, [n]), O(() => {
|
|
2185
2223
|
const l = a.current;
|
|
2186
2224
|
!l || !r || l.setViewState(r);
|
|
2187
|
-
}, [r]), /* @__PURE__ */
|
|
2225
|
+
}, [r]), /* @__PURE__ */ jt("canvas", { ref: s, className: i, style: c });
|
|
2188
2226
|
}
|
|
2189
2227
|
function kr(e) {
|
|
2190
2228
|
const t = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER;
|
|
@@ -2198,30 +2236,30 @@ function kr(e) {
|
|
|
2198
2236
|
)
|
|
2199
2237
|
);
|
|
2200
2238
|
}
|
|
2201
|
-
function
|
|
2239
|
+
function cn(e, t) {
|
|
2202
2240
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
2203
2241
|
return null;
|
|
2204
2242
|
const n = Fe(t ?? []);
|
|
2205
2243
|
if (n.length === 0) {
|
|
2206
|
-
const
|
|
2244
|
+
const m = {
|
|
2207
2245
|
count: 0,
|
|
2208
2246
|
positions: new Float32Array(0),
|
|
2209
2247
|
paletteIndices: new Uint16Array(0)
|
|
2210
2248
|
};
|
|
2211
|
-
return e.fillModes instanceof Uint8Array && (
|
|
2249
|
+
return e.fillModes instanceof Uint8Array && (m.fillModes = new Uint8Array(0)), e.ids instanceof Uint32Array && (m.ids = new Uint32Array(0)), m;
|
|
2212
2250
|
}
|
|
2213
2251
|
const r = kr(e), i = e.positions, o = e.paletteIndices, s = e.fillModes instanceof Uint8Array && e.fillModes.length >= r ? e.fillModes : null, a = e.ids instanceof Uint32Array && e.ids.length >= r ? e.ids : null, c = new Float32Array(r * 2), l = new Uint16Array(r), f = s ? new Uint8Array(r) : null, p = a ? new Uint32Array(r) : null;
|
|
2214
|
-
let
|
|
2215
|
-
for (let
|
|
2216
|
-
const S = i[
|
|
2217
|
-
|
|
2252
|
+
let d = 0;
|
|
2253
|
+
for (let m = 0; m < r; m += 1) {
|
|
2254
|
+
const S = i[m * 2], x = i[m * 2 + 1];
|
|
2255
|
+
sn(S, x, n) && (c[d * 2] = S, c[d * 2 + 1] = x, l[d] = o[m], f && (f[d] = s[m]), p && (p[d] = a[m]), d += 1);
|
|
2218
2256
|
}
|
|
2219
2257
|
const b = {
|
|
2220
|
-
count:
|
|
2221
|
-
positions: c.subarray(0,
|
|
2222
|
-
paletteIndices: l.subarray(0,
|
|
2258
|
+
count: d,
|
|
2259
|
+
positions: c.subarray(0, d * 2),
|
|
2260
|
+
paletteIndices: l.subarray(0, d)
|
|
2223
2261
|
};
|
|
2224
|
-
return f && (b.fillModes = f.subarray(0,
|
|
2262
|
+
return f && (b.fillModes = f.subarray(0, d)), p && (b.ids = p.subarray(0, d)), b;
|
|
2225
2263
|
}
|
|
2226
2264
|
function No(e, t) {
|
|
2227
2265
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
@@ -2236,11 +2274,11 @@ function No(e, t) {
|
|
|
2236
2274
|
let s = 0;
|
|
2237
2275
|
for (let a = 0; a < r; a += 1) {
|
|
2238
2276
|
const c = i[a * 2], l = i[a * 2 + 1];
|
|
2239
|
-
|
|
2277
|
+
sn(c, l, n) && (o[s] = a, s += 1);
|
|
2240
2278
|
}
|
|
2241
2279
|
return o.subarray(0, s);
|
|
2242
2280
|
}
|
|
2243
|
-
let
|
|
2281
|
+
let qe = null;
|
|
2244
2282
|
const zo = `
|
|
2245
2283
|
struct Params {
|
|
2246
2284
|
pointCount: u32,
|
|
@@ -2285,7 +2323,7 @@ function Wr() {
|
|
|
2285
2323
|
const n = t;
|
|
2286
2324
|
return typeof n.requestAdapter != "function" ? null : n;
|
|
2287
2325
|
}
|
|
2288
|
-
const
|
|
2326
|
+
const $e = globalThis.GPUShaderStage?.COMPUTE ?? 4, pn = globalThis.GPUBufferUsage?.STORAGE ?? 128, Ze = globalThis.GPUBufferUsage?.COPY_DST ?? 8, Oo = globalThis.GPUBufferUsage?.COPY_SRC ?? 4, Xo = globalThis.GPUBufferUsage?.UNIFORM ?? 64, Yo = globalThis.GPUBufferUsage?.MAP_READ ?? 1, ko = globalThis.GPUMapMode?.READ ?? 1;
|
|
2289
2327
|
async function Vs() {
|
|
2290
2328
|
const e = Wr();
|
|
2291
2329
|
if (!e)
|
|
@@ -2307,7 +2345,7 @@ async function Vs() {
|
|
|
2307
2345
|
} : { supported: !1, features: [] };
|
|
2308
2346
|
}
|
|
2309
2347
|
async function Wo() {
|
|
2310
|
-
return
|
|
2348
|
+
return qe || (qe = (async () => {
|
|
2311
2349
|
const e = Wr();
|
|
2312
2350
|
if (!e) return null;
|
|
2313
2351
|
const t = await e.requestAdapter();
|
|
@@ -2316,22 +2354,22 @@ async function Wo() {
|
|
|
2316
2354
|
entries: [
|
|
2317
2355
|
{
|
|
2318
2356
|
binding: 0,
|
|
2319
|
-
visibility:
|
|
2357
|
+
visibility: $e,
|
|
2320
2358
|
buffer: { type: "read-only-storage" }
|
|
2321
2359
|
},
|
|
2322
2360
|
{
|
|
2323
2361
|
binding: 1,
|
|
2324
|
-
visibility:
|
|
2362
|
+
visibility: $e,
|
|
2325
2363
|
buffer: { type: "read-only-storage" }
|
|
2326
2364
|
},
|
|
2327
2365
|
{
|
|
2328
2366
|
binding: 2,
|
|
2329
|
-
visibility:
|
|
2367
|
+
visibility: $e,
|
|
2330
2368
|
buffer: { type: "storage" }
|
|
2331
2369
|
},
|
|
2332
2370
|
{
|
|
2333
2371
|
binding: 3,
|
|
2334
|
-
visibility:
|
|
2372
|
+
visibility: $e,
|
|
2335
2373
|
buffer: { type: "uniform" }
|
|
2336
2374
|
}
|
|
2337
2375
|
]
|
|
@@ -2343,9 +2381,9 @@ async function Wo() {
|
|
|
2343
2381
|
}
|
|
2344
2382
|
});
|
|
2345
2383
|
return { device: n, pipeline: i, bindGroupLayout: r };
|
|
2346
|
-
})(),
|
|
2384
|
+
})(), qe);
|
|
2347
2385
|
}
|
|
2348
|
-
function
|
|
2386
|
+
function Ke(e, t) {
|
|
2349
2387
|
return Math.ceil(e / t) * t;
|
|
2350
2388
|
}
|
|
2351
2389
|
async function Vo(e, t, n) {
|
|
@@ -2361,20 +2399,20 @@ async function Vo(e, t, n) {
|
|
|
2361
2399
|
if (a > f || c > f || l > f)
|
|
2362
2400
|
return null;
|
|
2363
2401
|
const p = r.device.createBuffer({
|
|
2364
|
-
size:
|
|
2365
|
-
usage: pn |
|
|
2366
|
-
}),
|
|
2367
|
-
size:
|
|
2368
|
-
usage: pn |
|
|
2402
|
+
size: Ke(a, 4),
|
|
2403
|
+
usage: pn | Ze
|
|
2404
|
+
}), d = r.device.createBuffer({
|
|
2405
|
+
size: Ke(c, 4),
|
|
2406
|
+
usage: pn | Ze
|
|
2369
2407
|
}), b = r.device.createBuffer({
|
|
2370
|
-
size:
|
|
2408
|
+
size: Ke(l, 4),
|
|
2371
2409
|
usage: pn | Oo
|
|
2372
|
-
}),
|
|
2410
|
+
}), m = r.device.createBuffer({
|
|
2373
2411
|
size: 16,
|
|
2374
|
-
usage: Xo |
|
|
2412
|
+
usage: Xo | Ze
|
|
2375
2413
|
}), S = r.device.createBuffer({
|
|
2376
|
-
size:
|
|
2377
|
-
usage:
|
|
2414
|
+
size: Ke(l, 4),
|
|
2415
|
+
usage: Ze | Yo
|
|
2378
2416
|
});
|
|
2379
2417
|
r.device.queue.writeBuffer(
|
|
2380
2418
|
p,
|
|
@@ -2383,13 +2421,13 @@ async function Vo(e, t, n) {
|
|
|
2383
2421
|
e.byteOffset,
|
|
2384
2422
|
a
|
|
2385
2423
|
), r.device.queue.writeBuffer(
|
|
2386
|
-
|
|
2424
|
+
d,
|
|
2387
2425
|
0,
|
|
2388
2426
|
n.buffer,
|
|
2389
2427
|
n.byteOffset,
|
|
2390
2428
|
c
|
|
2391
2429
|
), r.device.queue.writeBuffer(
|
|
2392
|
-
|
|
2430
|
+
m,
|
|
2393
2431
|
0,
|
|
2394
2432
|
new Uint32Array([s, o, 0, 0])
|
|
2395
2433
|
);
|
|
@@ -2397,14 +2435,14 @@ async function Vo(e, t, n) {
|
|
|
2397
2435
|
layout: r.bindGroupLayout,
|
|
2398
2436
|
entries: [
|
|
2399
2437
|
{ binding: 0, resource: { buffer: p } },
|
|
2400
|
-
{ binding: 1, resource: { buffer:
|
|
2438
|
+
{ binding: 1, resource: { buffer: d } },
|
|
2401
2439
|
{ binding: 2, resource: { buffer: b } },
|
|
2402
|
-
{ binding: 3, resource: { buffer:
|
|
2440
|
+
{ binding: 3, resource: { buffer: m } }
|
|
2403
2441
|
]
|
|
2404
|
-
}), _ = r.device.createCommandEncoder(),
|
|
2405
|
-
|
|
2442
|
+
}), _ = r.device.createCommandEncoder(), B = _.beginComputePass();
|
|
2443
|
+
B.setPipeline(r.pipeline), B.setBindGroup(0, x), B.dispatchWorkgroups(Math.ceil(s / 256)), B.end(), _.copyBufferToBuffer(b, 0, S, 0, l), r.device.queue.submit([_.finish()]), await S.mapAsync(ko);
|
|
2406
2444
|
const N = S.getMappedRange(), V = new Uint32Array(N.slice(0));
|
|
2407
|
-
return S.unmap(), p.destroy(),
|
|
2445
|
+
return S.unmap(), p.destroy(), d.destroy(), b.destroy(), m.destroy(), S.destroy(), V;
|
|
2408
2446
|
}
|
|
2409
2447
|
function Qt() {
|
|
2410
2448
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
@@ -2460,18 +2498,18 @@ async function Go(e, t, n = {}) {
|
|
|
2460
2498
|
}
|
|
2461
2499
|
const f = new Float32Array(o.length * 4);
|
|
2462
2500
|
for (let F = 0; F < o.length; F += 1) {
|
|
2463
|
-
const
|
|
2464
|
-
f[
|
|
2501
|
+
const k = F * 4, K = o[F];
|
|
2502
|
+
f[k] = K.minX, f[k + 1] = K.minY, f[k + 2] = K.maxX, f[k + 3] = K.maxY;
|
|
2465
2503
|
}
|
|
2466
|
-
let p = null,
|
|
2504
|
+
let p = null, d = !1;
|
|
2467
2505
|
try {
|
|
2468
|
-
p = await Vo(e.positions, a, f),
|
|
2506
|
+
p = await Vo(e.positions, a, f), d = !!p;
|
|
2469
2507
|
} catch {
|
|
2470
|
-
p = null,
|
|
2508
|
+
p = null, d = !1;
|
|
2471
2509
|
}
|
|
2472
2510
|
if (!p)
|
|
2473
2511
|
return {
|
|
2474
|
-
data:
|
|
2512
|
+
data: cn(e, t),
|
|
2475
2513
|
meta: {
|
|
2476
2514
|
mode: "hybrid-webgpu",
|
|
2477
2515
|
durationMs: Qt() - r,
|
|
@@ -2483,22 +2521,22 @@ async function Go(e, t, n = {}) {
|
|
|
2483
2521
|
let b = 0;
|
|
2484
2522
|
for (let F = 0; F < a; F += 1)
|
|
2485
2523
|
p[F] === 1 && (b += 1);
|
|
2486
|
-
const
|
|
2524
|
+
const m = new Uint32Array(b);
|
|
2487
2525
|
if (b > 0) {
|
|
2488
2526
|
let F = 0;
|
|
2489
|
-
for (let
|
|
2490
|
-
p[
|
|
2527
|
+
for (let k = 0; k < a; k += 1)
|
|
2528
|
+
p[k] === 1 && (m[F] = k, F += 1);
|
|
2491
2529
|
}
|
|
2492
2530
|
if (b === 0) {
|
|
2493
2531
|
if (i) {
|
|
2494
|
-
const
|
|
2532
|
+
const k = {
|
|
2495
2533
|
count: a,
|
|
2496
2534
|
positions: e.positions.subarray(0, a * 2),
|
|
2497
2535
|
paletteIndices: e.paletteIndices.subarray(0, a),
|
|
2498
2536
|
drawIndices: new Uint32Array(0)
|
|
2499
2537
|
};
|
|
2500
|
-
return c && (
|
|
2501
|
-
data:
|
|
2538
|
+
return c && (k.fillModes = c.subarray(0, a)), l && (k.ids = l.subarray(0, a)), {
|
|
2539
|
+
data: k,
|
|
2502
2540
|
meta: {
|
|
2503
2541
|
mode: "hybrid-webgpu",
|
|
2504
2542
|
durationMs: Qt() - r,
|
|
@@ -2526,19 +2564,19 @@ async function Go(e, t, n = {}) {
|
|
|
2526
2564
|
}
|
|
2527
2565
|
if (i) {
|
|
2528
2566
|
const F = new Uint32Array(b);
|
|
2529
|
-
let
|
|
2567
|
+
let k = 0;
|
|
2530
2568
|
for (let dt = 0; dt < b; dt += 1) {
|
|
2531
|
-
const bt =
|
|
2532
|
-
|
|
2569
|
+
const bt = m[dt] ?? 0, Pt = e.positions[bt * 2], Ft = e.positions[bt * 2 + 1];
|
|
2570
|
+
sn(Pt, Ft, o) && (F[k] = bt, k += 1);
|
|
2533
2571
|
}
|
|
2534
|
-
const
|
|
2572
|
+
const K = {
|
|
2535
2573
|
count: a,
|
|
2536
2574
|
positions: e.positions.subarray(0, a * 2),
|
|
2537
2575
|
paletteIndices: e.paletteIndices.subarray(0, a),
|
|
2538
|
-
drawIndices: F.subarray(0,
|
|
2576
|
+
drawIndices: F.subarray(0, k)
|
|
2539
2577
|
};
|
|
2540
|
-
return c && (
|
|
2541
|
-
data:
|
|
2578
|
+
return c && (K.fillModes = c.subarray(0, a)), l && (K.ids = l.subarray(0, a)), {
|
|
2579
|
+
data: K,
|
|
2542
2580
|
meta: {
|
|
2543
2581
|
mode: "hybrid-webgpu",
|
|
2544
2582
|
durationMs: Qt() - r,
|
|
@@ -2548,18 +2586,18 @@ async function Go(e, t, n = {}) {
|
|
|
2548
2586
|
}
|
|
2549
2587
|
};
|
|
2550
2588
|
}
|
|
2551
|
-
const S = new Float32Array(b * 2), x = new Uint16Array(b), _ = c ? new Uint8Array(b) : null,
|
|
2589
|
+
const S = new Float32Array(b * 2), x = new Uint16Array(b), _ = c ? new Uint8Array(b) : null, B = l ? new Uint32Array(b) : null;
|
|
2552
2590
|
let N = 0;
|
|
2553
2591
|
for (let F = 0; F < b; F += 1) {
|
|
2554
|
-
const
|
|
2555
|
-
|
|
2592
|
+
const k = m[F] ?? 0, K = e.positions[k * 2], dt = e.positions[k * 2 + 1];
|
|
2593
|
+
sn(K, dt, o) && (S[N * 2] = K, S[N * 2 + 1] = dt, x[N] = e.paletteIndices[k], _ && (_[N] = c[k]), B && (B[N] = l[k]), N += 1);
|
|
2556
2594
|
}
|
|
2557
2595
|
const V = {
|
|
2558
2596
|
count: N,
|
|
2559
2597
|
positions: S.subarray(0, N * 2),
|
|
2560
2598
|
paletteIndices: x.subarray(0, N)
|
|
2561
2599
|
};
|
|
2562
|
-
return _ && (V.fillModes = _.subarray(0, N)),
|
|
2600
|
+
return _ && (V.fillModes = _.subarray(0, N)), B && (V.ids = B.subarray(0, N)), {
|
|
2563
2601
|
data: V,
|
|
2564
2602
|
meta: {
|
|
2565
2603
|
mode: "hybrid-webgpu",
|
|
@@ -2570,31 +2608,31 @@ async function Go(e, t, n = {}) {
|
|
|
2570
2608
|
}
|
|
2571
2609
|
};
|
|
2572
2610
|
}
|
|
2573
|
-
let
|
|
2574
|
-
const
|
|
2575
|
-
function
|
|
2611
|
+
let Ut = null, En = !0, Vr = 1;
|
|
2612
|
+
const ce = /* @__PURE__ */ new Map();
|
|
2613
|
+
function ae() {
|
|
2576
2614
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
2577
2615
|
}
|
|
2578
2616
|
function Gr() {
|
|
2579
|
-
if (!
|
|
2580
|
-
if (
|
|
2617
|
+
if (!En) return null;
|
|
2618
|
+
if (Ut) return Ut;
|
|
2581
2619
|
try {
|
|
2582
2620
|
const e = new Worker(new URL(
|
|
2583
2621
|
/* @vite-ignore */
|
|
2584
2622
|
"" + new URL("assets/roi-clip-worker-BDVQwN2T.js", import.meta.url).href,
|
|
2585
2623
|
import.meta.url
|
|
2586
2624
|
), { type: "module" });
|
|
2587
|
-
return e.addEventListener("message",
|
|
2625
|
+
return e.addEventListener("message", Fn), e.addEventListener("error", Un), Ut = e, e;
|
|
2588
2626
|
} catch {
|
|
2589
|
-
return
|
|
2627
|
+
return En = !1, null;
|
|
2590
2628
|
}
|
|
2591
2629
|
}
|
|
2592
|
-
function
|
|
2630
|
+
function Fn(e) {
|
|
2593
2631
|
const t = e.data;
|
|
2594
2632
|
if (!t) return;
|
|
2595
|
-
const n =
|
|
2633
|
+
const n = ce.get(t.id);
|
|
2596
2634
|
if (!n) return;
|
|
2597
|
-
if (
|
|
2635
|
+
if (ce.delete(t.id), t.type === "roi-clip-failure") {
|
|
2598
2636
|
n.reject(new Error(t.error || "worker clip failed"));
|
|
2599
2637
|
return;
|
|
2600
2638
|
}
|
|
@@ -2608,7 +2646,7 @@ function _n(e) {
|
|
|
2608
2646
|
indices: f,
|
|
2609
2647
|
meta: {
|
|
2610
2648
|
mode: "worker",
|
|
2611
|
-
durationMs: Number.isFinite(t.durationMs) ? t.durationMs :
|
|
2649
|
+
durationMs: Number.isFinite(t.durationMs) ? t.durationMs : ae() - n.startMs
|
|
2612
2650
|
}
|
|
2613
2651
|
});
|
|
2614
2652
|
return;
|
|
@@ -2626,22 +2664,22 @@ function _n(e) {
|
|
|
2626
2664
|
data: c,
|
|
2627
2665
|
meta: {
|
|
2628
2666
|
mode: "worker",
|
|
2629
|
-
durationMs: Number.isFinite(t.durationMs) ? t.durationMs :
|
|
2667
|
+
durationMs: Number.isFinite(t.durationMs) ? t.durationMs : ae() - n.startMs
|
|
2630
2668
|
}
|
|
2631
2669
|
});
|
|
2632
2670
|
}
|
|
2633
|
-
function
|
|
2634
|
-
|
|
2635
|
-
for (const [, e] of
|
|
2671
|
+
function Un() {
|
|
2672
|
+
En = !1, Ut && (Ut.removeEventListener("message", Fn), Ut.removeEventListener("error", Un), Ut.terminate(), Ut = null);
|
|
2673
|
+
for (const [, e] of ce)
|
|
2636
2674
|
e.reject(new Error("worker crashed"));
|
|
2637
|
-
|
|
2675
|
+
ce.clear();
|
|
2638
2676
|
}
|
|
2639
2677
|
function Gs() {
|
|
2640
|
-
if (
|
|
2641
|
-
|
|
2642
|
-
for (const [, e] of
|
|
2678
|
+
if (Ut) {
|
|
2679
|
+
Ut.removeEventListener("message", Fn), Ut.removeEventListener("error", Un), Ut.terminate(), Ut = null;
|
|
2680
|
+
for (const [, e] of ce)
|
|
2643
2681
|
e.reject(new Error("worker terminated"));
|
|
2644
|
-
|
|
2682
|
+
ce.clear();
|
|
2645
2683
|
}
|
|
2646
2684
|
}
|
|
2647
2685
|
async function Ho(e, t) {
|
|
@@ -2652,15 +2690,15 @@ async function Ho(e, t) {
|
|
|
2652
2690
|
};
|
|
2653
2691
|
const n = Gr();
|
|
2654
2692
|
if (!n) {
|
|
2655
|
-
const p =
|
|
2693
|
+
const p = ae();
|
|
2656
2694
|
return {
|
|
2657
|
-
data:
|
|
2658
|
-
meta: { mode: "sync", durationMs:
|
|
2695
|
+
data: cn(e, t),
|
|
2696
|
+
meta: { mode: "sync", durationMs: ae() - p }
|
|
2659
2697
|
};
|
|
2660
2698
|
}
|
|
2661
|
-
const r = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER, i = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length, r)), o = e.positions.slice(0, i * 2), s = e.paletteIndices.slice(0, i), a = e.fillModes instanceof Uint8Array && e.fillModes.length >= i ? e.fillModes.slice(0, i) : null, c = e.ids instanceof Uint32Array && e.ids.length >= i ? e.ids.slice(0, i) : null, l = Vr++, f =
|
|
2662
|
-
return new Promise((p,
|
|
2663
|
-
|
|
2699
|
+
const r = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER, i = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length, r)), o = e.positions.slice(0, i * 2), s = e.paletteIndices.slice(0, i), a = e.fillModes instanceof Uint8Array && e.fillModes.length >= i ? e.fillModes.slice(0, i) : null, c = e.ids instanceof Uint32Array && e.ids.length >= i ? e.ids.slice(0, i) : null, l = Vr++, f = ae();
|
|
2700
|
+
return new Promise((p, d) => {
|
|
2701
|
+
ce.set(l, { kind: "data", resolve: p, reject: d, startMs: f });
|
|
2664
2702
|
const b = {
|
|
2665
2703
|
type: "roi-clip-request",
|
|
2666
2704
|
id: l,
|
|
@@ -2670,8 +2708,8 @@ async function Ho(e, t) {
|
|
|
2670
2708
|
fillModes: a?.buffer,
|
|
2671
2709
|
ids: c?.buffer,
|
|
2672
2710
|
polygons: t ?? []
|
|
2673
|
-
},
|
|
2674
|
-
a &&
|
|
2711
|
+
}, m = [o.buffer, s.buffer];
|
|
2712
|
+
a && m.push(a.buffer), c && m.push(c.buffer), n.postMessage(b, m);
|
|
2675
2713
|
});
|
|
2676
2714
|
}
|
|
2677
2715
|
async function Hs(e, t) {
|
|
@@ -2682,15 +2720,15 @@ async function Hs(e, t) {
|
|
|
2682
2720
|
};
|
|
2683
2721
|
const n = Gr();
|
|
2684
2722
|
if (!n) {
|
|
2685
|
-
const c =
|
|
2723
|
+
const c = ae();
|
|
2686
2724
|
return {
|
|
2687
2725
|
indices: No(e, t),
|
|
2688
|
-
meta: { mode: "sync", durationMs:
|
|
2726
|
+
meta: { mode: "sync", durationMs: ae() - c }
|
|
2689
2727
|
};
|
|
2690
2728
|
}
|
|
2691
|
-
const r = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER, i = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length, r)), o = e.positions.slice(0, i * 2), s = Vr++, a =
|
|
2729
|
+
const r = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER, i = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length, r)), o = e.positions.slice(0, i * 2), s = Vr++, a = ae();
|
|
2692
2730
|
return new Promise((c, l) => {
|
|
2693
|
-
|
|
2731
|
+
ce.set(s, { kind: "index", resolve: c, reject: l, startMs: a });
|
|
2694
2732
|
const f = {
|
|
2695
2733
|
type: "roi-clip-index-request",
|
|
2696
2734
|
id: s,
|
|
@@ -2741,20 +2779,20 @@ function Zo(e, t, n = {}) {
|
|
|
2741
2779
|
);
|
|
2742
2780
|
let i = null;
|
|
2743
2781
|
if (e?.drawIndices instanceof Uint32Array) {
|
|
2744
|
-
const
|
|
2745
|
-
let b =
|
|
2746
|
-
for (let
|
|
2747
|
-
|
|
2748
|
-
if (b ===
|
|
2749
|
-
i =
|
|
2782
|
+
const d = e.drawIndices;
|
|
2783
|
+
let b = d.length;
|
|
2784
|
+
for (let m = 0; m < d.length; m += 1)
|
|
2785
|
+
d[m] < r || (b -= 1);
|
|
2786
|
+
if (b === d.length)
|
|
2787
|
+
i = d;
|
|
2750
2788
|
else if (b > 0) {
|
|
2751
|
-
const
|
|
2789
|
+
const m = new Uint32Array(b);
|
|
2752
2790
|
let S = 0;
|
|
2753
|
-
for (let x = 0; x <
|
|
2754
|
-
const _ =
|
|
2755
|
-
_ >= r || (
|
|
2791
|
+
for (let x = 0; x < d.length; x += 1) {
|
|
2792
|
+
const _ = d[x];
|
|
2793
|
+
_ >= r || (m[S] = _, S += 1);
|
|
2756
2794
|
}
|
|
2757
|
-
i =
|
|
2795
|
+
i = m;
|
|
2758
2796
|
} else
|
|
2759
2797
|
i = new Uint32Array(0);
|
|
2760
2798
|
}
|
|
@@ -2768,13 +2806,13 @@ function Zo(e, t, n = {}) {
|
|
|
2768
2806
|
};
|
|
2769
2807
|
const a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
2770
2808
|
let l = 0;
|
|
2771
|
-
for (let
|
|
2772
|
-
const b = i ? i[
|
|
2809
|
+
for (let d = 0; d < o; d += 1) {
|
|
2810
|
+
const b = i ? i[d] : d, m = e.positions[b * 2], S = e.positions[b * 2 + 1];
|
|
2773
2811
|
let x = null;
|
|
2774
2812
|
for (const N of s) {
|
|
2775
2813
|
let V = !1;
|
|
2776
2814
|
for (const F of N.polygons)
|
|
2777
|
-
if (
|
|
2815
|
+
if (Ir(m, S, F)) {
|
|
2778
2816
|
V = !0;
|
|
2779
2817
|
break;
|
|
2780
2818
|
}
|
|
@@ -2782,24 +2820,24 @@ function Zo(e, t, n = {}) {
|
|
|
2782
2820
|
}
|
|
2783
2821
|
if (!x) continue;
|
|
2784
2822
|
l += 1;
|
|
2785
|
-
const _ = e.paletteIndices[b] ?? 0,
|
|
2786
|
-
|
|
2823
|
+
const _ = e.paletteIndices[b] ?? 0, B = a.get(x.regionIndex) ?? /* @__PURE__ */ new Map();
|
|
2824
|
+
B.set(_, (B.get(_) ?? 0) + 1), a.set(x.regionIndex, B), c.set(
|
|
2787
2825
|
x.regionIndex,
|
|
2788
2826
|
(c.get(x.regionIndex) ?? 0) + 1
|
|
2789
2827
|
);
|
|
2790
2828
|
}
|
|
2791
2829
|
const f = n.includeEmptyRegions ?? !1, p = [];
|
|
2792
|
-
for (const
|
|
2793
|
-
const b = c.get(
|
|
2830
|
+
for (const d of s) {
|
|
2831
|
+
const b = c.get(d.regionIndex) ?? 0;
|
|
2794
2832
|
if (!f && b <= 0) continue;
|
|
2795
|
-
const
|
|
2833
|
+
const m = a.get(d.regionIndex) ?? /* @__PURE__ */ new Map(), S = Array.from(m.entries()).map(([x, _]) => ({
|
|
2796
2834
|
termId: $o(x, n.paletteIndexToTermId),
|
|
2797
2835
|
paletteIndex: x,
|
|
2798
2836
|
count: _
|
|
2799
2837
|
})).sort((x, _) => _.count - x.count || x.paletteIndex - _.paletteIndex);
|
|
2800
2838
|
p.push({
|
|
2801
|
-
regionId:
|
|
2802
|
-
regionIndex:
|
|
2839
|
+
regionId: d.regionId,
|
|
2840
|
+
regionIndex: d.regionIndex,
|
|
2803
2841
|
totalCount: b,
|
|
2804
2842
|
termCounts: S
|
|
2805
2843
|
});
|
|
@@ -2811,7 +2849,7 @@ function Zo(e, t, n = {}) {
|
|
|
2811
2849
|
unmatchedPointCount: Math.max(0, o - l)
|
|
2812
2850
|
};
|
|
2813
2851
|
}
|
|
2814
|
-
function
|
|
2852
|
+
function Je() {
|
|
2815
2853
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
2816
2854
|
}
|
|
2817
2855
|
function Ko(e, t) {
|
|
@@ -2825,23 +2863,23 @@ function Ko(e, t) {
|
|
|
2825
2863
|
}
|
|
2826
2864
|
class Jo {
|
|
2827
2865
|
constructor(t) {
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2866
|
+
w(this, "maxConcurrency");
|
|
2867
|
+
w(this, "maxRetries");
|
|
2868
|
+
w(this, "retryBaseDelayMs");
|
|
2869
|
+
w(this, "retryMaxDelayMs");
|
|
2870
|
+
w(this, "onTileLoad");
|
|
2871
|
+
w(this, "onTileError");
|
|
2872
|
+
w(this, "onStateChange");
|
|
2873
|
+
w(this, "authToken");
|
|
2874
|
+
w(this, "destroyed", !1);
|
|
2875
|
+
w(this, "queue", []);
|
|
2876
|
+
w(this, "queuedByKey", /* @__PURE__ */ new Map());
|
|
2877
|
+
w(this, "inflight", /* @__PURE__ */ new Map());
|
|
2878
|
+
w(this, "visibleKeys", /* @__PURE__ */ new Set());
|
|
2879
|
+
w(this, "timerId", null);
|
|
2880
|
+
w(this, "abortedCount", 0);
|
|
2881
|
+
w(this, "retryCount", 0);
|
|
2882
|
+
w(this, "failedCount", 0);
|
|
2845
2883
|
this.maxConcurrency = Math.max(1, Math.floor(t.maxConcurrency ?? 12)), this.maxRetries = Math.max(0, Math.floor(t.maxRetries ?? 2)), this.retryBaseDelayMs = Math.max(
|
|
2846
2884
|
10,
|
|
2847
2885
|
Math.floor(t.retryBaseDelayMs ?? 120)
|
|
@@ -2873,7 +2911,7 @@ class Jo {
|
|
|
2873
2911
|
const o = {
|
|
2874
2912
|
tile: r,
|
|
2875
2913
|
attempt: 0,
|
|
2876
|
-
readyAt:
|
|
2914
|
+
readyAt: Je()
|
|
2877
2915
|
};
|
|
2878
2916
|
this.queue.push(o), this.queuedByKey.set(r.key, o);
|
|
2879
2917
|
}
|
|
@@ -2929,14 +2967,14 @@ class Jo {
|
|
|
2929
2967
|
if (this.inflight.size >= this.maxConcurrency || this.queue.length === 0) return;
|
|
2930
2968
|
const t = this.queue[0]?.readyAt;
|
|
2931
2969
|
if (typeof t != "number") return;
|
|
2932
|
-
const n = Math.max(0, t -
|
|
2970
|
+
const n = Math.max(0, t - Je());
|
|
2933
2971
|
this.timerId = window.setTimeout(() => {
|
|
2934
2972
|
this.timerId = null, this.pump();
|
|
2935
2973
|
}, n);
|
|
2936
2974
|
}
|
|
2937
2975
|
takeNextReadyQueueItem() {
|
|
2938
2976
|
if (this.queue.length === 0) return null;
|
|
2939
|
-
const t =
|
|
2977
|
+
const t = Je(), n = this.queue[0];
|
|
2940
2978
|
return !n || n.readyAt > t ? null : (this.queue.shift(), this.queuedByKey.delete(n.tile.key), n);
|
|
2941
2979
|
}
|
|
2942
2980
|
startFetch(t) {
|
|
@@ -2972,7 +3010,7 @@ class Jo {
|
|
|
2972
3010
|
const a = t.attempt + 1, c = this.getRetryDelay(a), l = {
|
|
2973
3011
|
tile: t.tile,
|
|
2974
3012
|
attempt: a,
|
|
2975
|
-
readyAt:
|
|
3013
|
+
readyAt: Je() + c
|
|
2976
3014
|
}, f = this.queuedByKey.get(t.tile.key);
|
|
2977
3015
|
f ? (f.tile = l.tile, f.readyAt = Math.min(f.readyAt, l.readyAt), f.attempt = Math.max(f.attempt, l.attempt)) : (this.queue.push(l), this.queuedByKey.set(l.tile.key, l)), this.sortQueue();
|
|
2978
3016
|
return;
|
|
@@ -2996,7 +3034,7 @@ class Jo {
|
|
|
2996
3034
|
this.onStateChange?.(this.getSnapshot());
|
|
2997
3035
|
}
|
|
2998
3036
|
}
|
|
2999
|
-
const br = 0.35,
|
|
3037
|
+
const br = 0.35, Rn = 0.5, Qo = 256, Pn = [
|
|
3000
3038
|
{ zoom: 1, size: 2.8 },
|
|
3001
3039
|
{ zoom: 2, size: 3.4 },
|
|
3002
3040
|
{ zoom: 3, size: 4.2 },
|
|
@@ -3010,11 +3048,11 @@ const br = 0.35, En = 0.5, jo = 256, Rn = [
|
|
|
3010
3048
|
{ zoom: 11, size: 22 },
|
|
3011
3049
|
{ zoom: 12, size: 28 }
|
|
3012
3050
|
];
|
|
3013
|
-
class
|
|
3051
|
+
class jo {
|
|
3014
3052
|
constructor() {
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3053
|
+
w(this, "viewportWidth", 1);
|
|
3054
|
+
w(this, "viewportHeight", 1);
|
|
3055
|
+
w(this, "viewState", {
|
|
3018
3056
|
zoom: 1,
|
|
3019
3057
|
offsetX: 0,
|
|
3020
3058
|
offsetY: 0,
|
|
@@ -3049,9 +3087,9 @@ class Qo {
|
|
|
3049
3087
|
return [o + a * f - c * p, s + a * p + c * f];
|
|
3050
3088
|
}
|
|
3051
3089
|
worldToScreen(t, n) {
|
|
3052
|
-
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = t - o, c = n - s, l = ve(r.rotationDeg), f = Math.cos(l), p = Math.sin(l),
|
|
3090
|
+
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = t - o, c = n - s, l = ve(r.rotationDeg), f = Math.cos(l), p = Math.sin(l), d = a * f + c * p, b = -a * p + c * f;
|
|
3053
3091
|
return [
|
|
3054
|
-
this.viewportWidth * 0.5 +
|
|
3092
|
+
this.viewportWidth * 0.5 + d * i,
|
|
3055
3093
|
this.viewportHeight * 0.5 + b * i
|
|
3056
3094
|
];
|
|
3057
3095
|
}
|
|
@@ -3065,17 +3103,17 @@ class Qo {
|
|
|
3065
3103
|
];
|
|
3066
3104
|
}
|
|
3067
3105
|
getMatrix() {
|
|
3068
|
-
const t = Math.max(1e-6, this.viewState.zoom), [n, r] = this.getCenter(), i = ve(this.viewState.rotationDeg), o = Math.cos(i), s = Math.sin(i), a = 2 * t * o / this.viewportWidth, c = 2 * t * s / this.viewportWidth, l = 2 * t * s / this.viewportHeight, f = -2 * t * o / this.viewportHeight, p = -(a * n + c * r),
|
|
3069
|
-
return new Float32Array([a, l, 0, c, f, 0, p,
|
|
3106
|
+
const t = Math.max(1e-6, this.viewState.zoom), [n, r] = this.getCenter(), i = ve(this.viewState.rotationDeg), o = Math.cos(i), s = Math.sin(i), a = 2 * t * o / this.viewportWidth, c = 2 * t * s / this.viewportWidth, l = 2 * t * s / this.viewportHeight, f = -2 * t * o / this.viewportHeight, p = -(a * n + c * r), d = -(l * n + f * r);
|
|
3107
|
+
return new Float32Array([a, l, 0, c, f, 0, p, d, 1]);
|
|
3070
3108
|
}
|
|
3071
3109
|
}
|
|
3072
3110
|
function ve(e) {
|
|
3073
3111
|
return e * Math.PI / 180;
|
|
3074
3112
|
}
|
|
3075
|
-
function
|
|
3113
|
+
function Qe() {
|
|
3076
3114
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
3077
3115
|
}
|
|
3078
|
-
function
|
|
3116
|
+
function Yt(e, t, n) {
|
|
3079
3117
|
const r = e.getUniformLocation(t, n);
|
|
3080
3118
|
if (!r)
|
|
3081
3119
|
throw new Error(`uniform location lookup failed: ${n}`);
|
|
@@ -3084,17 +3122,17 @@ function Xt(e, t, n) {
|
|
|
3084
3122
|
function je(e, t) {
|
|
3085
3123
|
return !e || !t ? e === t : e.buffer === t.buffer && e.byteOffset === t.byteOffset && e.byteLength === t.byteLength;
|
|
3086
3124
|
}
|
|
3087
|
-
function
|
|
3125
|
+
function Cn(e) {
|
|
3088
3126
|
return e.map((t) => ({ zoom: t.zoom, size: t.size }));
|
|
3089
3127
|
}
|
|
3090
3128
|
function wr(e) {
|
|
3091
|
-
if (!e) return Pn
|
|
3129
|
+
if (!e) return Cn(Pn);
|
|
3092
3130
|
const t = /* @__PURE__ */ new Map();
|
|
3093
3131
|
for (const [n, r] of Object.entries(e)) {
|
|
3094
3132
|
const i = Number(n), o = Number(r);
|
|
3095
3133
|
!Number.isFinite(i) || !Number.isFinite(o) || o <= 0 || t.set(i, o);
|
|
3096
3134
|
}
|
|
3097
|
-
return t.size === 0 ? Pn
|
|
3135
|
+
return t.size === 0 ? Cn(Pn) : Array.from(t.entries()).sort((n, r) => n[0] - r[0]).map(([n, r]) => ({ zoom: n, size: r }));
|
|
3098
3136
|
}
|
|
3099
3137
|
function ts(e, t) {
|
|
3100
3138
|
if (e === t) return !0;
|
|
@@ -3105,13 +3143,13 @@ function ts(e, t) {
|
|
|
3105
3143
|
return !0;
|
|
3106
3144
|
}
|
|
3107
3145
|
function es(e, t) {
|
|
3108
|
-
if (!Number.isFinite(e)) return t[0]?.size ??
|
|
3109
|
-
if (t.length === 0) return
|
|
3146
|
+
if (!Number.isFinite(e)) return t[0]?.size ?? Rn;
|
|
3147
|
+
if (t.length === 0) return Rn;
|
|
3110
3148
|
if (t.length === 1 || e <= t[0].zoom) return t[0].size;
|
|
3111
3149
|
for (let s = 1; s < t.length; s += 1) {
|
|
3112
3150
|
const a = t[s - 1], c = t[s];
|
|
3113
3151
|
if (e > c.zoom) continue;
|
|
3114
|
-
const l = Math.max(1e-6, c.zoom - a.zoom), f =
|
|
3152
|
+
const l = Math.max(1e-6, c.zoom - a.zoom), f = ct((e - a.zoom) / l, 0, 1);
|
|
3115
3153
|
return a.size + (c.size - a.size) * f;
|
|
3116
3154
|
}
|
|
3117
3155
|
const n = t[t.length - 1], r = t[t.length - 2], i = Math.max(1e-6, n.zoom - r.zoom), o = (n.size - r.size) / i;
|
|
@@ -3119,11 +3157,11 @@ function es(e, t) {
|
|
|
3119
3157
|
}
|
|
3120
3158
|
const ns = 0.1, rs = 5;
|
|
3121
3159
|
function yr(e) {
|
|
3122
|
-
return typeof e != "number" || !Number.isFinite(e) ? 1 :
|
|
3160
|
+
return typeof e != "number" || !Number.isFinite(e) ? 1 : ct(e, ns, rs);
|
|
3123
3161
|
}
|
|
3124
3162
|
const is = -100, os = 100;
|
|
3125
3163
|
function bn(e) {
|
|
3126
|
-
return typeof e != "number" || !Number.isFinite(e) ? 0 :
|
|
3164
|
+
return typeof e != "number" || !Number.isFinite(e) ? 0 : ct(e, is, os);
|
|
3127
3165
|
}
|
|
3128
3166
|
function Sr(e) {
|
|
3129
3167
|
const t = bn(e?.brightness), n = bn(e?.contrast), r = bn(e?.saturation);
|
|
@@ -3138,9 +3176,9 @@ function Hr(e) {
|
|
|
3138
3176
|
return e;
|
|
3139
3177
|
}
|
|
3140
3178
|
function wn(e) {
|
|
3141
|
-
return typeof e != "number" || !Number.isFinite(e) ? 0 :
|
|
3179
|
+
return typeof e != "number" || !Number.isFinite(e) ? 0 : ct(e, 0, ss);
|
|
3142
3180
|
}
|
|
3143
|
-
function
|
|
3181
|
+
function tn(e) {
|
|
3144
3182
|
return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? null : Math.max(1e-6, e);
|
|
3145
3183
|
}
|
|
3146
3184
|
function yn(e) {
|
|
@@ -3151,70 +3189,70 @@ function Mr(e, t) {
|
|
|
3151
3189
|
}
|
|
3152
3190
|
class as {
|
|
3153
3191
|
constructor(t, n, r = {}) {
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3192
|
+
w(this, "canvas");
|
|
3193
|
+
w(this, "source");
|
|
3194
|
+
w(this, "gl");
|
|
3195
|
+
w(this, "camera", new jo());
|
|
3196
|
+
w(this, "onViewStateChange");
|
|
3197
|
+
w(this, "onStats");
|
|
3198
|
+
w(this, "onTileError");
|
|
3199
|
+
w(this, "onContextLost");
|
|
3200
|
+
w(this, "onContextRestored");
|
|
3201
|
+
w(this, "resizeObserver");
|
|
3202
|
+
w(this, "tileProgram");
|
|
3203
|
+
w(this, "pointProgram");
|
|
3204
|
+
w(this, "tileScheduler");
|
|
3205
|
+
w(this, "authToken");
|
|
3206
|
+
w(this, "destroyed", !1);
|
|
3207
|
+
w(this, "contextLost", !1);
|
|
3208
|
+
w(this, "frame", null);
|
|
3209
|
+
w(this, "frameSerial", 0);
|
|
3210
|
+
w(this, "dragging", !1);
|
|
3211
|
+
w(this, "interactionMode", "none");
|
|
3212
|
+
w(this, "rotateLastAngleRad", null);
|
|
3213
|
+
w(this, "pointerId", null);
|
|
3214
|
+
w(this, "lastPointerX", 0);
|
|
3215
|
+
w(this, "lastPointerY", 0);
|
|
3216
|
+
w(this, "interactionLocked", !1);
|
|
3217
|
+
w(this, "ctrlDragRotate", !0);
|
|
3218
|
+
w(this, "rotationDragSensitivityDegPerPixel", 0.35);
|
|
3219
|
+
w(this, "maxCacheTiles");
|
|
3220
|
+
w(this, "fitZoom", 1);
|
|
3221
|
+
w(this, "minZoom", 1e-6);
|
|
3222
|
+
w(this, "maxZoom", 1);
|
|
3223
|
+
w(this, "minZoomOverride", null);
|
|
3224
|
+
w(this, "maxZoomOverride", null);
|
|
3225
|
+
w(this, "viewTransitionDurationMs", 0);
|
|
3226
|
+
w(this, "viewTransitionEasing", Hr);
|
|
3227
|
+
w(this, "viewAnimation", null);
|
|
3228
|
+
w(this, "viewAnimationFrame", null);
|
|
3229
|
+
w(this, "currentTier", 0);
|
|
3230
|
+
w(this, "pointCount", 0);
|
|
3231
|
+
w(this, "usePointIndices", !1);
|
|
3232
|
+
w(this, "pointBuffersDirty", !0);
|
|
3233
|
+
w(this, "pointPaletteSize", 1);
|
|
3234
|
+
w(this, "pointSizeStops", Cn(Pn));
|
|
3235
|
+
w(this, "pointStrokeScale", 1);
|
|
3236
|
+
w(this, "imageColorSettings", {
|
|
3199
3237
|
brightness: 0,
|
|
3200
3238
|
contrast: 0,
|
|
3201
3239
|
saturation: 0
|
|
3202
3240
|
});
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3241
|
+
w(this, "lastPointData", null);
|
|
3242
|
+
w(this, "lastPointPalette", null);
|
|
3243
|
+
w(this, "zeroFillModes", new Uint8Array(0));
|
|
3244
|
+
w(this, "cache", /* @__PURE__ */ new Map());
|
|
3245
|
+
w(this, "boundPointerDown");
|
|
3246
|
+
w(this, "boundPointerMove");
|
|
3247
|
+
w(this, "boundPointerUp");
|
|
3248
|
+
w(this, "boundWheel");
|
|
3249
|
+
w(this, "boundDoubleClick");
|
|
3250
|
+
w(this, "boundContextMenu");
|
|
3251
|
+
w(this, "boundContextLost");
|
|
3252
|
+
w(this, "boundContextRestored");
|
|
3215
3253
|
this.canvas = t, this.source = n, this.onViewStateChange = r.onViewStateChange, this.onStats = r.onStats, this.onTileError = r.onTileError, this.onContextLost = r.onContextLost, this.onContextRestored = r.onContextRestored, this.authToken = r.authToken ?? "", this.maxCacheTiles = Math.max(32, Math.floor(r.maxCacheTiles ?? 320)), this.ctrlDragRotate = r.ctrlDragRotate ?? !0, this.rotationDragSensitivityDegPerPixel = typeof r.rotationDragSensitivityDegPerPixel == "number" && Number.isFinite(r.rotationDragSensitivityDegPerPixel) ? Math.max(0, r.rotationDragSensitivityDegPerPixel) : br, this.pointSizeStops = wr(r.pointSizeByZoom), this.pointStrokeScale = yr(r.pointStrokeScale), this.imageColorSettings = Sr(
|
|
3216
3254
|
r.imageColorSettings
|
|
3217
|
-
), this.minZoomOverride =
|
|
3255
|
+
), this.minZoomOverride = tn(r.minZoom), this.maxZoomOverride = tn(r.maxZoom), this.viewTransitionDurationMs = wn(r.viewTransition?.duration), this.viewTransitionEasing = yn(r.viewTransition?.easing);
|
|
3218
3256
|
const i = t.getContext("webgl2", {
|
|
3219
3257
|
alpha: !1,
|
|
3220
3258
|
antialias: !1,
|
|
@@ -3250,7 +3288,7 @@ class as {
|
|
|
3250
3288
|
}
|
|
3251
3289
|
resolveTargetViewState(t) {
|
|
3252
3290
|
const n = this.camera.getViewState(), r = {
|
|
3253
|
-
zoom: typeof t.zoom == "number" && Number.isFinite(t.zoom) ?
|
|
3291
|
+
zoom: typeof t.zoom == "number" && Number.isFinite(t.zoom) ? ct(t.zoom, this.minZoom, this.maxZoom) : n.zoom,
|
|
3254
3292
|
offsetX: typeof t.offsetX == "number" && Number.isFinite(t.offsetX) ? t.offsetX : n.offsetX,
|
|
3255
3293
|
offsetY: typeof t.offsetY == "number" && Number.isFinite(t.offsetY) ? t.offsetY : n.offsetY,
|
|
3256
3294
|
rotationDeg: typeof t.rotationDeg == "number" && Number.isFinite(t.rotationDeg) ? t.rotationDeg : n.rotationDeg
|
|
@@ -3265,7 +3303,7 @@ class as {
|
|
|
3265
3303
|
startViewAnimation(t, n, r) {
|
|
3266
3304
|
const i = this.camera.getViewState();
|
|
3267
3305
|
this.cancelViewAnimation(), this.viewAnimation = {
|
|
3268
|
-
startMs:
|
|
3306
|
+
startMs: Qe(),
|
|
3269
3307
|
durationMs: Math.max(0, n),
|
|
3270
3308
|
from: i,
|
|
3271
3309
|
to: t,
|
|
@@ -3274,14 +3312,14 @@ class as {
|
|
|
3274
3312
|
const o = () => {
|
|
3275
3313
|
const s = this.viewAnimation;
|
|
3276
3314
|
if (!s) return;
|
|
3277
|
-
const a = Math.max(0,
|
|
3315
|
+
const a = Math.max(0, Qe() - s.startMs), c = s.durationMs <= 0 ? 1 : ct(a / s.durationMs, 0, 1);
|
|
3278
3316
|
let l = c;
|
|
3279
3317
|
try {
|
|
3280
3318
|
l = s.easing(c);
|
|
3281
3319
|
} catch {
|
|
3282
3320
|
l = c;
|
|
3283
3321
|
}
|
|
3284
|
-
Number.isFinite(l) || (l = c), l =
|
|
3322
|
+
Number.isFinite(l) || (l = c), l = ct(l, 0, 1);
|
|
3285
3323
|
const f = {
|
|
3286
3324
|
zoom: s.from.zoom + (s.to.zoom - s.from.zoom) * l,
|
|
3287
3325
|
offsetX: s.from.offsetX + (s.to.offsetX - s.from.offsetX) * l,
|
|
@@ -3300,7 +3338,7 @@ class as {
|
|
|
3300
3338
|
this.authToken = String(t ?? ""), this.tileScheduler.setAuthToken(this.authToken);
|
|
3301
3339
|
}
|
|
3302
3340
|
setZoomRange(t, n) {
|
|
3303
|
-
const r =
|
|
3341
|
+
const r = tn(t), i = tn(n);
|
|
3304
3342
|
if (this.minZoomOverride === r && this.maxZoomOverride === i)
|
|
3305
3343
|
return;
|
|
3306
3344
|
this.minZoomOverride = r, this.maxZoomOverride = i, this.applyZoomBounds();
|
|
@@ -3363,7 +3401,7 @@ class as {
|
|
|
3363
3401
|
r ? n.length : Number.MAX_SAFE_INTEGER
|
|
3364
3402
|
)
|
|
3365
3403
|
), o = t.positions.subarray(0, i * 2), s = t.paletteIndices.subarray(0, i), a = r ? n.subarray(0, i) : void 0, c = t.drawIndices instanceof Uint32Array, l = c ? this.sanitizeDrawIndices(t.drawIndices, i) : null, f = this.lastPointData, p = f?.fillModes instanceof Uint8Array;
|
|
3366
|
-
let
|
|
3404
|
+
let d = this.pointBuffersDirty || !f || f.count !== i || !je(f.positions, o) || !je(f.paletteIndices, s) || p !== r || r && (!f?.fillModes || !je(f.fillModes, a)), b = this.pointBuffersDirty || c && (!f?.drawIndices || !je(f.drawIndices, l)) || !c && !!f?.drawIndices;
|
|
3367
3405
|
if (this.lastPointData = {
|
|
3368
3406
|
count: i,
|
|
3369
3407
|
positions: o,
|
|
@@ -3371,20 +3409,20 @@ class as {
|
|
|
3371
3409
|
fillModes: a,
|
|
3372
3410
|
drawIndices: c ? l ?? void 0 : void 0
|
|
3373
3411
|
}, this.contextLost || this.gl.isContextLost()) return;
|
|
3374
|
-
const
|
|
3375
|
-
|
|
3376
|
-
|
|
3412
|
+
const m = this.gl;
|
|
3413
|
+
d && (m.bindBuffer(m.ARRAY_BUFFER, this.pointProgram.posBuffer), m.bufferData(m.ARRAY_BUFFER, this.lastPointData.positions, m.STATIC_DRAW), m.bindBuffer(m.ARRAY_BUFFER, this.pointProgram.termBuffer), m.bufferData(
|
|
3414
|
+
m.ARRAY_BUFFER,
|
|
3377
3415
|
this.lastPointData.paletteIndices,
|
|
3378
|
-
|
|
3379
|
-
),
|
|
3380
|
-
|
|
3416
|
+
m.STATIC_DRAW
|
|
3417
|
+
), m.bindBuffer(m.ARRAY_BUFFER, this.pointProgram.fillModeBuffer), m.bufferData(
|
|
3418
|
+
m.ARRAY_BUFFER,
|
|
3381
3419
|
this.lastPointData.fillModes ?? this.getZeroFillModes(i),
|
|
3382
|
-
|
|
3383
|
-
),
|
|
3384
|
-
|
|
3420
|
+
m.STATIC_DRAW
|
|
3421
|
+
), m.bindBuffer(m.ARRAY_BUFFER, null)), c && b && (m.bindBuffer(m.ELEMENT_ARRAY_BUFFER, this.pointProgram.indexBuffer), m.bufferData(
|
|
3422
|
+
m.ELEMENT_ARRAY_BUFFER,
|
|
3385
3423
|
l ?? new Uint32Array(0),
|
|
3386
|
-
|
|
3387
|
-
),
|
|
3424
|
+
m.DYNAMIC_DRAW
|
|
3425
|
+
), m.bindBuffer(m.ELEMENT_ARRAY_BUFFER, null)), this.usePointIndices = c, this.pointCount = c ? l?.length ?? 0 : this.lastPointData.count, (d || b) && (this.pointBuffersDirty = !1), this.requestRender();
|
|
3388
3426
|
}
|
|
3389
3427
|
sanitizeDrawIndices(t, n) {
|
|
3390
3428
|
if (n <= 0 || t.length === 0)
|
|
@@ -3462,12 +3500,12 @@ class as {
|
|
|
3462
3500
|
}
|
|
3463
3501
|
getPointSizeByZoom() {
|
|
3464
3502
|
const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t), r = es(n, this.pointSizeStops);
|
|
3465
|
-
return
|
|
3503
|
+
return ct(r, Rn, Qo);
|
|
3466
3504
|
}
|
|
3467
3505
|
fitToImage(t) {
|
|
3468
3506
|
const n = this.canvas.getBoundingClientRect(), r = Math.max(1, n.width || 1), i = Math.max(1, n.height || 1), o = Math.min(r / this.source.width, i / this.source.height), s = Number.isFinite(o) && o > 0 ? o : 1;
|
|
3469
3507
|
this.fitZoom = s, this.applyZoomBounds();
|
|
3470
|
-
const a =
|
|
3508
|
+
const a = ct(s, this.minZoom, this.maxZoom), c = r / a, l = i / a;
|
|
3471
3509
|
this.setViewState(
|
|
3472
3510
|
{
|
|
3473
3511
|
zoom: a,
|
|
@@ -3479,28 +3517,28 @@ class as {
|
|
|
3479
3517
|
);
|
|
3480
3518
|
}
|
|
3481
3519
|
zoomBy(t, n, r, i) {
|
|
3482
|
-
const o = this.camera.getViewState(), s =
|
|
3520
|
+
const o = this.camera.getViewState(), s = ct(o.zoom * t, this.minZoom, this.maxZoom);
|
|
3483
3521
|
if (s === o.zoom) return;
|
|
3484
|
-
const [a, c] = this.camera.screenToWorld(n, r), l = this.camera.getViewport(), f = n - l.width * 0.5, p = r - l.height * 0.5,
|
|
3522
|
+
const [a, c] = this.camera.screenToWorld(n, r), l = this.camera.getViewport(), f = n - l.width * 0.5, p = r - l.height * 0.5, d = ve(o.rotationDeg), b = Math.cos(d), m = Math.sin(d), S = f / s * b - p / s * m, x = f / s * m + p / s * b, _ = a - S, B = c - x;
|
|
3485
3523
|
this.setViewState(
|
|
3486
3524
|
{
|
|
3487
3525
|
zoom: s,
|
|
3488
3526
|
offsetX: _ - l.width / (2 * s),
|
|
3489
|
-
offsetY:
|
|
3527
|
+
offsetY: B - l.height / (2 * s)
|
|
3490
3528
|
},
|
|
3491
3529
|
i
|
|
3492
3530
|
);
|
|
3493
3531
|
}
|
|
3494
3532
|
clampViewState() {
|
|
3495
|
-
const t = this.getViewBounds(), n = Math.max(1e-6, t[2] - t[0]), r = Math.max(1e-6, t[3] - t[1]), i = n * 0.2, o = r * 0.2, [s, a] = this.camera.getCenter(), c = n * 0.5, l = r * 0.5, f = c - i, p = this.source.width - c + i,
|
|
3496
|
-
this.camera.setCenter(
|
|
3533
|
+
const t = this.getViewBounds(), n = Math.max(1e-6, t[2] - t[0]), r = Math.max(1e-6, t[3] - t[1]), i = n * 0.2, o = r * 0.2, [s, a] = this.camera.getCenter(), c = n * 0.5, l = r * 0.5, f = c - i, p = this.source.width - c + i, d = l - o, b = this.source.height - l + o, m = f <= p ? ct(s, f, p) : this.source.width * 0.5, S = d <= b ? ct(a, d, b) : this.source.height * 0.5;
|
|
3534
|
+
this.camera.setCenter(m, S);
|
|
3497
3535
|
}
|
|
3498
3536
|
emitViewState() {
|
|
3499
3537
|
this.onViewStateChange?.(this.camera.getViewState());
|
|
3500
3538
|
}
|
|
3501
3539
|
selectTier() {
|
|
3502
3540
|
const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t);
|
|
3503
|
-
return
|
|
3541
|
+
return ct(Math.floor(n), 0, this.source.maxTierZoom);
|
|
3504
3542
|
}
|
|
3505
3543
|
getViewBounds() {
|
|
3506
3544
|
const t = this.camera.getViewCorners();
|
|
@@ -3515,40 +3553,40 @@ class as {
|
|
|
3515
3553
|
getVisibleTiles() {
|
|
3516
3554
|
const t = this.selectTier();
|
|
3517
3555
|
this.currentTier = t;
|
|
3518
|
-
const n = this.getViewBounds(), r = Math.pow(2, this.source.maxTierZoom - t), i = Math.ceil(this.source.width / r), o = Math.ceil(this.source.height / r), s = Math.max(1, Math.ceil(i / this.source.tileSize)), a = Math.max(1, Math.ceil(o / this.source.tileSize)), c = n[0], l = n[1], f = n[2], p = n[3],
|
|
3556
|
+
const n = this.getViewBounds(), r = Math.pow(2, this.source.maxTierZoom - t), i = Math.ceil(this.source.width / r), o = Math.ceil(this.source.height / r), s = Math.max(1, Math.ceil(i / this.source.tileSize)), a = Math.max(1, Math.ceil(o / this.source.tileSize)), c = n[0], l = n[1], f = n[2], p = n[3], d = ct(
|
|
3519
3557
|
Math.floor(c / r / this.source.tileSize),
|
|
3520
3558
|
0,
|
|
3521
3559
|
s - 1
|
|
3522
|
-
), b =
|
|
3560
|
+
), b = ct(
|
|
3523
3561
|
Math.floor((f - 1) / r / this.source.tileSize),
|
|
3524
3562
|
0,
|
|
3525
3563
|
s - 1
|
|
3526
|
-
),
|
|
3564
|
+
), m = ct(
|
|
3527
3565
|
Math.floor(l / r / this.source.tileSize),
|
|
3528
3566
|
0,
|
|
3529
3567
|
a - 1
|
|
3530
|
-
), S =
|
|
3568
|
+
), S = ct(
|
|
3531
3569
|
Math.floor((p - 1) / r / this.source.tileSize),
|
|
3532
3570
|
0,
|
|
3533
3571
|
a - 1
|
|
3534
3572
|
);
|
|
3535
|
-
if (
|
|
3573
|
+
if (d > b || m > S)
|
|
3536
3574
|
return [];
|
|
3537
|
-
const x = (c + f) * 0.5 / r / this.source.tileSize, _ = (l + p) * 0.5 / r / this.source.tileSize,
|
|
3538
|
-
for (let N =
|
|
3539
|
-
for (let V =
|
|
3540
|
-
const F = V * this.source.tileSize * r,
|
|
3541
|
-
|
|
3575
|
+
const x = (c + f) * 0.5 / r / this.source.tileSize, _ = (l + p) * 0.5 / r / this.source.tileSize, B = [];
|
|
3576
|
+
for (let N = m; N <= S; N += 1)
|
|
3577
|
+
for (let V = d; V <= b; V += 1) {
|
|
3578
|
+
const F = V * this.source.tileSize * r, k = N * this.source.tileSize * r, K = Math.min((V + 1) * this.source.tileSize, i) * r, dt = Math.min((N + 1) * this.source.tileSize, o) * r, bt = V - x, Pt = N - _;
|
|
3579
|
+
B.push({
|
|
3542
3580
|
key: `${t}/${V}/${N}`,
|
|
3543
3581
|
tier: t,
|
|
3544
3582
|
x: V,
|
|
3545
3583
|
y: N,
|
|
3546
|
-
bounds: [F,
|
|
3547
|
-
distance2: bt * bt +
|
|
3584
|
+
bounds: [F, k, K, dt],
|
|
3585
|
+
distance2: bt * bt + Pt * Pt,
|
|
3548
3586
|
url: Yr(this.source, t, V, N)
|
|
3549
3587
|
});
|
|
3550
3588
|
}
|
|
3551
|
-
return
|
|
3589
|
+
return B.sort((N, V) => N.distance2 - V.distance2), B;
|
|
3552
3590
|
}
|
|
3553
3591
|
trimCache() {
|
|
3554
3592
|
if (this.cache.size <= this.maxCacheTiles) return;
|
|
@@ -3562,30 +3600,30 @@ class as {
|
|
|
3562
3600
|
}
|
|
3563
3601
|
render() {
|
|
3564
3602
|
if (this.destroyed || this.contextLost || this.gl.isContextLost()) return;
|
|
3565
|
-
const t =
|
|
3603
|
+
const t = Qe();
|
|
3566
3604
|
this.frameSerial += 1;
|
|
3567
3605
|
const n = this.gl, r = this.tileProgram, i = this.pointProgram;
|
|
3568
3606
|
n.clearColor(0.03, 0.06, 0.1, 1), n.clear(n.COLOR_BUFFER_BIT);
|
|
3569
|
-
const o = this.getVisibleTiles(), s = this.getViewBounds(), a = new Set(o.map((
|
|
3607
|
+
const o = this.getVisibleTiles(), s = this.getViewBounds(), a = new Set(o.map((d) => d.key));
|
|
3570
3608
|
n.useProgram(r.program), n.bindVertexArray(r.vao), n.uniformMatrix3fv(r.uCamera, !1, this.camera.getMatrix()), n.uniform1i(r.uTexture, 0), n.uniform1f(r.uBrightness, this.imageColorSettings.brightness), n.uniform1f(r.uContrast, this.imageColorSettings.contrast), n.uniform1f(r.uSaturation, this.imageColorSettings.saturation);
|
|
3571
3609
|
const c = [];
|
|
3572
|
-
for (const [,
|
|
3573
|
-
a.has(
|
|
3574
|
-
c.sort((
|
|
3575
|
-
for (const
|
|
3576
|
-
|
|
3610
|
+
for (const [, d] of this.cache)
|
|
3611
|
+
a.has(d.key) || this.intersectsBounds(d.bounds, s) && c.push(d);
|
|
3612
|
+
c.sort((d, b) => d.tier - b.tier);
|
|
3613
|
+
for (const d of c)
|
|
3614
|
+
d.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, d.texture), n.uniform4f(
|
|
3577
3615
|
r.uBounds,
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3616
|
+
d.bounds[0],
|
|
3617
|
+
d.bounds[1],
|
|
3618
|
+
d.bounds[2],
|
|
3619
|
+
d.bounds[3]
|
|
3582
3620
|
), n.drawArrays(n.TRIANGLE_STRIP, 0, 4);
|
|
3583
3621
|
let l = 0;
|
|
3584
3622
|
const f = [];
|
|
3585
|
-
for (const
|
|
3586
|
-
const b = this.cache.get(
|
|
3623
|
+
for (const d of o) {
|
|
3624
|
+
const b = this.cache.get(d.key);
|
|
3587
3625
|
if (!b) {
|
|
3588
|
-
f.push(
|
|
3626
|
+
f.push(d);
|
|
3589
3627
|
continue;
|
|
3590
3628
|
}
|
|
3591
3629
|
b.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, b.texture), n.uniform4f(
|
|
@@ -3599,7 +3637,7 @@ class as {
|
|
|
3599
3637
|
this.tileScheduler.schedule(f), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null);
|
|
3600
3638
|
let p = 0;
|
|
3601
3639
|
if (this.pointCount > 0 && (n.enable(n.BLEND), n.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), n.useProgram(i.program), n.bindVertexArray(i.vao), n.uniformMatrix3fv(i.uCamera, !1, this.camera.getMatrix()), n.uniform1f(i.uPointSize, this.getPointSizeByZoom()), n.uniform1f(i.uPointStrokeScale, this.pointStrokeScale), n.uniform1f(i.uPaletteSize, this.pointPaletteSize), n.uniform1i(i.uPalette, 1), n.activeTexture(n.TEXTURE1), n.bindTexture(n.TEXTURE_2D, i.paletteTexture), this.usePointIndices ? n.drawElements(n.POINTS, this.pointCount, n.UNSIGNED_INT, 0) : n.drawArrays(n.POINTS, 0, this.pointCount), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null), p = this.pointCount), this.onStats) {
|
|
3602
|
-
const
|
|
3640
|
+
const d = this.tileScheduler.getSnapshot(), b = l, m = f.length, S = c.length + l + (p > 0 ? 1 : 0);
|
|
3603
3641
|
this.onStats({
|
|
3604
3642
|
tier: this.currentTier,
|
|
3605
3643
|
visible: o.length,
|
|
@@ -3607,15 +3645,15 @@ class as {
|
|
|
3607
3645
|
points: p,
|
|
3608
3646
|
fallback: c.length,
|
|
3609
3647
|
cache: this.cache.size,
|
|
3610
|
-
inflight:
|
|
3611
|
-
queued:
|
|
3612
|
-
retries:
|
|
3613
|
-
failed:
|
|
3614
|
-
aborted:
|
|
3648
|
+
inflight: d.inflight,
|
|
3649
|
+
queued: d.queued,
|
|
3650
|
+
retries: d.retries,
|
|
3651
|
+
failed: d.failed,
|
|
3652
|
+
aborted: d.aborted,
|
|
3615
3653
|
cacheHits: b,
|
|
3616
|
-
cacheMisses:
|
|
3654
|
+
cacheMisses: m,
|
|
3617
3655
|
drawCalls: S,
|
|
3618
|
-
frameMs:
|
|
3656
|
+
frameMs: Qe() - t
|
|
3619
3657
|
});
|
|
3620
3658
|
}
|
|
3621
3659
|
}
|
|
@@ -3693,7 +3731,7 @@ class as {
|
|
|
3693
3731
|
}
|
|
3694
3732
|
}
|
|
3695
3733
|
initTileProgram() {
|
|
3696
|
-
const t = this.gl, i =
|
|
3734
|
+
const t = this.gl, i = tr(t, `#version 300 es
|
|
3697
3735
|
precision highp float;
|
|
3698
3736
|
in vec2 aUnit;
|
|
3699
3737
|
in vec2 aUv;
|
|
@@ -3738,21 +3776,21 @@ class as {
|
|
|
3738
3776
|
|
|
3739
3777
|
color.rgb = clamp(color.rgb + uBrightness, vec3(0.0), vec3(1.0));
|
|
3740
3778
|
outColor = color;
|
|
3741
|
-
}`), o =
|
|
3742
|
-
if (!p || !
|
|
3779
|
+
}`), o = Yt(t, i, "uCamera"), s = Yt(t, i, "uBounds"), a = Yt(t, i, "uTexture"), c = Yt(t, i, "uBrightness"), l = Yt(t, i, "uContrast"), f = Yt(t, i, "uSaturation"), p = t.createVertexArray(), d = t.createBuffer();
|
|
3780
|
+
if (!p || !d)
|
|
3743
3781
|
throw new Error("buffer allocation failed");
|
|
3744
|
-
t.bindVertexArray(p), t.bindBuffer(t.ARRAY_BUFFER,
|
|
3782
|
+
t.bindVertexArray(p), t.bindBuffer(t.ARRAY_BUFFER, d), t.bufferData(
|
|
3745
3783
|
t.ARRAY_BUFFER,
|
|
3746
3784
|
new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1]),
|
|
3747
3785
|
t.STATIC_DRAW
|
|
3748
3786
|
);
|
|
3749
|
-
const b = t.getAttribLocation(i, "aUnit"),
|
|
3750
|
-
if (b < 0 ||
|
|
3787
|
+
const b = t.getAttribLocation(i, "aUnit"), m = t.getAttribLocation(i, "aUv");
|
|
3788
|
+
if (b < 0 || m < 0)
|
|
3751
3789
|
throw new Error("tile attribute lookup failed");
|
|
3752
|
-
return t.enableVertexAttribArray(b), t.enableVertexAttribArray(
|
|
3790
|
+
return t.enableVertexAttribArray(b), t.enableVertexAttribArray(m), t.vertexAttribPointer(b, 2, t.FLOAT, !1, 16, 0), t.vertexAttribPointer(m, 2, t.FLOAT, !1, 16, 8), t.bindVertexArray(null), t.bindBuffer(t.ARRAY_BUFFER, null), {
|
|
3753
3791
|
program: i,
|
|
3754
3792
|
vao: p,
|
|
3755
|
-
vbo:
|
|
3793
|
+
vbo: d,
|
|
3756
3794
|
uCamera: o,
|
|
3757
3795
|
uBounds: s,
|
|
3758
3796
|
uTexture: a,
|
|
@@ -3762,7 +3800,7 @@ class as {
|
|
|
3762
3800
|
};
|
|
3763
3801
|
}
|
|
3764
3802
|
initPointProgram() {
|
|
3765
|
-
const t = this.gl, i =
|
|
3803
|
+
const t = this.gl, i = tr(t, `#version 300 es
|
|
3766
3804
|
precision highp float;
|
|
3767
3805
|
in vec2 aPosition;
|
|
3768
3806
|
in uint aTerm;
|
|
@@ -3811,22 +3849,22 @@ class as {
|
|
|
3811
3849
|
if (alpha <= 0.001) discard;
|
|
3812
3850
|
|
|
3813
3851
|
outColor = vec4(color.rgb * alpha, alpha);
|
|
3814
|
-
}`), o =
|
|
3815
|
-
if (!f || !p || !
|
|
3852
|
+
}`), o = Yt(t, i, "uCamera"), s = Yt(t, i, "uPointSize"), a = Yt(t, i, "uPointStrokeScale"), c = Yt(t, i, "uPalette"), l = Yt(t, i, "uPaletteSize"), f = t.createVertexArray(), p = t.createBuffer(), d = t.createBuffer(), b = t.createBuffer(), m = t.createBuffer(), S = t.createTexture();
|
|
3853
|
+
if (!f || !p || !d || !b || !m || !S)
|
|
3816
3854
|
throw new Error("point buffer allocation failed");
|
|
3817
3855
|
t.bindVertexArray(f), t.bindBuffer(t.ARRAY_BUFFER, p), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
3818
3856
|
const x = t.getAttribLocation(i, "aPosition");
|
|
3819
3857
|
if (x < 0)
|
|
3820
3858
|
throw new Error("point position attribute not found");
|
|
3821
|
-
t.enableVertexAttribArray(x), t.vertexAttribPointer(x, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ARRAY_BUFFER,
|
|
3859
|
+
t.enableVertexAttribArray(x), t.vertexAttribPointer(x, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ARRAY_BUFFER, d), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
3822
3860
|
const _ = t.getAttribLocation(i, "aTerm");
|
|
3823
3861
|
if (_ < 0)
|
|
3824
3862
|
throw new Error("point term attribute not found");
|
|
3825
3863
|
t.enableVertexAttribArray(_), t.vertexAttribIPointer(_, 1, t.UNSIGNED_SHORT, 0, 0), t.bindBuffer(t.ARRAY_BUFFER, b), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
3826
|
-
const
|
|
3827
|
-
if (
|
|
3864
|
+
const B = t.getAttribLocation(i, "aFillMode");
|
|
3865
|
+
if (B < 0)
|
|
3828
3866
|
throw new Error("point fill mode attribute not found");
|
|
3829
|
-
return t.enableVertexAttribArray(
|
|
3867
|
+
return t.enableVertexAttribArray(B), t.vertexAttribIPointer(B, 1, t.UNSIGNED_BYTE, 0, 0), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, m), t.bufferData(t.ELEMENT_ARRAY_BUFFER, 0, t.DYNAMIC_DRAW), t.bindVertexArray(null), t.bindBuffer(t.ARRAY_BUFFER, null), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, null), t.bindTexture(t.TEXTURE_2D, S), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST), t.texImage2D(
|
|
3830
3868
|
t.TEXTURE_2D,
|
|
3831
3869
|
0,
|
|
3832
3870
|
t.RGBA,
|
|
@@ -3840,9 +3878,9 @@ class as {
|
|
|
3840
3878
|
program: i,
|
|
3841
3879
|
vao: f,
|
|
3842
3880
|
posBuffer: p,
|
|
3843
|
-
termBuffer:
|
|
3881
|
+
termBuffer: d,
|
|
3844
3882
|
fillModeBuffer: b,
|
|
3845
|
-
indexBuffer:
|
|
3883
|
+
indexBuffer: m,
|
|
3846
3884
|
paletteTexture: S,
|
|
3847
3885
|
uCamera: o,
|
|
3848
3886
|
uPointSize: s,
|
|
@@ -3880,8 +3918,8 @@ const Sn = [], cs = [], us = {
|
|
|
3880
3918
|
positions: new Float32Array(0),
|
|
3881
3919
|
paletteIndices: new Uint16Array(0)
|
|
3882
3920
|
}, ls = 0.65, fs = 4, hs = 24, ds = 1024, ms = 4, gs = 6, ps = 0.5, bs = 0.58, ws = 4096, ys = 180, Ar = 20;
|
|
3883
|
-
let
|
|
3884
|
-
const
|
|
3921
|
+
let en = null;
|
|
3922
|
+
const nn = /* @__PURE__ */ new Map();
|
|
3885
3923
|
function Ss(e) {
|
|
3886
3924
|
const t = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER;
|
|
3887
3925
|
return Math.max(0, Math.min(Math.floor(e.count ?? 0), Math.floor((e.positions?.length ?? 0) / 2), e.paletteIndices?.length ?? 0, t));
|
|
@@ -3920,13 +3958,13 @@ function xs(e, t) {
|
|
|
3920
3958
|
if (s === 0)
|
|
3921
3959
|
return null;
|
|
3922
3960
|
const a = As(t, s), c = /* @__PURE__ */ new Map(), l = (f) => {
|
|
3923
|
-
const p = r[f * 2],
|
|
3924
|
-
if (!Number.isFinite(p) || !Number.isFinite(
|
|
3925
|
-
const b = Math.floor(p / a),
|
|
3961
|
+
const p = r[f * 2], d = r[f * 2 + 1];
|
|
3962
|
+
if (!Number.isFinite(p) || !Number.isFinite(d)) return;
|
|
3963
|
+
const b = Math.floor(p / a), m = Math.floor(d / a);
|
|
3926
3964
|
let S = c.get(b);
|
|
3927
3965
|
S || (S = /* @__PURE__ */ new Map(), c.set(b, S));
|
|
3928
|
-
const x = S.get(
|
|
3929
|
-
x ? x.push(f) : S.set(
|
|
3966
|
+
const x = S.get(m);
|
|
3967
|
+
x ? x.push(f) : S.set(m, [f]);
|
|
3930
3968
|
};
|
|
3931
3969
|
if (o)
|
|
3932
3970
|
for (let f = 0; f < o.length; f += 1)
|
|
@@ -3952,7 +3990,7 @@ function Ts(e) {
|
|
|
3952
3990
|
const t = pe(e, 0, 1);
|
|
3953
3991
|
return t * t * (3 - 2 * t);
|
|
3954
3992
|
}
|
|
3955
|
-
function
|
|
3993
|
+
function vn(e) {
|
|
3956
3994
|
if (!Array.isArray(e) || e.length < 2) return null;
|
|
3957
3995
|
const t = Number(e[0]), n = Number(e[1]);
|
|
3958
3996
|
return !Number.isFinite(t) || !Number.isFinite(n) ? null : [t, n];
|
|
@@ -3979,11 +4017,11 @@ function Rs(e) {
|
|
|
3979
4017
|
function Ps(e, t, n, r, i, o) {
|
|
3980
4018
|
const s = i - n, a = o - r, c = s * s + a * a;
|
|
3981
4019
|
if (c <= 1e-12) {
|
|
3982
|
-
const
|
|
3983
|
-
return
|
|
4020
|
+
const m = e - n, S = t - r;
|
|
4021
|
+
return m * m + S * S;
|
|
3984
4022
|
}
|
|
3985
|
-
const l = pe(((e - n) * s + (t - r) * a) / c, 0, 1), f = n + s * l, p = r + a * l,
|
|
3986
|
-
return
|
|
4023
|
+
const l = pe(((e - n) * s + (t - r) * a) / c, 0, 1), f = n + s * l, p = r + a * l, d = e - f, b = t - p;
|
|
4024
|
+
return d * d + b * b;
|
|
3987
4025
|
}
|
|
3988
4026
|
function xr(e, t, n, r) {
|
|
3989
4027
|
for (let i = 1; i < n.length; i += 1) {
|
|
@@ -3993,7 +4031,7 @@ function xr(e, t, n, r) {
|
|
|
3993
4031
|
}
|
|
3994
4032
|
return !1;
|
|
3995
4033
|
}
|
|
3996
|
-
function
|
|
4034
|
+
function Cs(e, t, n, r) {
|
|
3997
4035
|
if (e < n.minX - r || e > n.maxX + r || t < n.minY - r || t > n.maxY + r)
|
|
3998
4036
|
return !1;
|
|
3999
4037
|
const i = r * r;
|
|
@@ -4002,30 +4040,30 @@ function Is(e, t, n, r) {
|
|
|
4002
4040
|
if (xr(e, t, o, i)) return !0;
|
|
4003
4041
|
return !1;
|
|
4004
4042
|
}
|
|
4005
|
-
function
|
|
4006
|
-
if (
|
|
4043
|
+
function Is() {
|
|
4044
|
+
if (en) return en;
|
|
4007
4045
|
if (typeof document > "u") return null;
|
|
4008
4046
|
const t = document.createElement("canvas").getContext("2d");
|
|
4009
|
-
return t ? (
|
|
4047
|
+
return t ? (en = t, en) : null;
|
|
4010
4048
|
}
|
|
4011
4049
|
function vs(e, t) {
|
|
4012
|
-
const n = `${t.fontWeight}|${t.fontSize}|${t.fontFamily}|${e}`, r =
|
|
4050
|
+
const n = `${t.fontWeight}|${t.fontSize}|${t.fontFamily}|${e}`, r = nn.get(n);
|
|
4013
4051
|
if (r !== void 0) return r;
|
|
4014
|
-
const i = e.length * t.fontSize * bs, o =
|
|
4052
|
+
const i = e.length * t.fontSize * bs, o = Is();
|
|
4015
4053
|
let s = i;
|
|
4016
4054
|
if (o) {
|
|
4017
4055
|
o.font = `${t.fontWeight} ${t.fontSize}px ${t.fontFamily}`;
|
|
4018
4056
|
const a = o.measureText(e).width;
|
|
4019
4057
|
Number.isFinite(a) && a >= 0 && (s = a);
|
|
4020
4058
|
}
|
|
4021
|
-
return
|
|
4059
|
+
return nn.size > ws && nn.clear(), nn.set(n, s), s;
|
|
4022
4060
|
}
|
|
4023
4061
|
function _s(e, t, n, r, i, o) {
|
|
4024
4062
|
if (!e.label || !e.labelAnchor) return !1;
|
|
4025
|
-
const s =
|
|
4063
|
+
const s = vn(n.worldToScreen(e.labelAnchor[0], e.labelAnchor[1]));
|
|
4026
4064
|
if (!s) return !1;
|
|
4027
|
-
const c = vs(e.label, r) + r.paddingX * 2, l = r.fontSize + r.paddingY * 2, f = pe(s[0], c * 0.5 + 1, i - c * 0.5 - 1), p = pe(s[1] - r.offsetY, l * 0.5 + 1, o - l * 0.5 - 1),
|
|
4028
|
-
return t[0] >=
|
|
4065
|
+
const c = vs(e.label, r) + r.paddingX * 2, l = r.fontSize + r.paddingY * 2, f = pe(s[0], c * 0.5 + 1, i - c * 0.5 - 1), p = pe(s[1] - r.offsetY, l * 0.5 + 1, o - l * 0.5 - 1), d = f - c * 0.5, b = f + c * 0.5, m = p - l * 0.5, S = p + l * 0.5;
|
|
4066
|
+
return t[0] >= d && t[0] <= b && t[1] >= m && t[1] <= S;
|
|
4029
4067
|
}
|
|
4030
4068
|
function Fs(e) {
|
|
4031
4069
|
const t = [];
|
|
@@ -4045,11 +4083,11 @@ function Fs(e) {
|
|
|
4045
4083
|
return t;
|
|
4046
4084
|
}
|
|
4047
4085
|
function Us(e, t, n, r, i, o, s, a, c) {
|
|
4048
|
-
const l = e[0], f = e[1], p = Math.max(1e-6, r.getViewState().zoom),
|
|
4049
|
-
for (let
|
|
4050
|
-
const S = n[
|
|
4086
|
+
const l = e[0], f = e[1], p = Math.max(1e-6, r.getViewState().zoom), d = Math.max(0, s), b = gs / p;
|
|
4087
|
+
for (let m = n.length - 1; m >= 0; m -= 1) {
|
|
4088
|
+
const S = n[m];
|
|
4051
4089
|
for (const _ of S.polygons)
|
|
4052
|
-
if (
|
|
4090
|
+
if (Cs(l, f, _, b))
|
|
4053
4091
|
return {
|
|
4054
4092
|
region: S.region,
|
|
4055
4093
|
regionIndex: S.regionIndex,
|
|
@@ -4064,9 +4102,9 @@ function Us(e, t, n, r, i, o, s, a, c) {
|
|
|
4064
4102
|
zoom: p
|
|
4065
4103
|
})
|
|
4066
4104
|
);
|
|
4067
|
-
if (
|
|
4105
|
+
if (d > 0 && (x = {
|
|
4068
4106
|
...x,
|
|
4069
|
-
offsetY: x.offsetY +
|
|
4107
|
+
offsetY: x.offsetY + d
|
|
4070
4108
|
}), !!_s(S, t, r, x, a, c))
|
|
4071
4109
|
return {
|
|
4072
4110
|
region: S.region,
|
|
@@ -4089,59 +4127,59 @@ function qs({
|
|
|
4089
4127
|
debugOverlayStyle: l,
|
|
4090
4128
|
fitNonce: f = 0,
|
|
4091
4129
|
rotationResetNonce: p = 0,
|
|
4092
|
-
authToken:
|
|
4130
|
+
authToken: d = "",
|
|
4093
4131
|
ctrlDragRotate: b = !0,
|
|
4094
|
-
pointData:
|
|
4132
|
+
pointData: m = null,
|
|
4095
4133
|
pointPalette: S = null,
|
|
4096
4134
|
pointSizeByZoom: x,
|
|
4097
4135
|
pointStrokeScale: _,
|
|
4098
|
-
minZoom:
|
|
4136
|
+
minZoom: B,
|
|
4099
4137
|
maxZoom: N,
|
|
4100
4138
|
viewTransition: V,
|
|
4101
4139
|
roiRegions: F,
|
|
4102
|
-
roiPolygons:
|
|
4103
|
-
clipPointsToRois:
|
|
4140
|
+
roiPolygons: k,
|
|
4141
|
+
clipPointsToRois: K = !1,
|
|
4104
4142
|
clipMode: dt = "worker",
|
|
4105
4143
|
onClipStats: bt,
|
|
4106
|
-
onRoiPointGroups:
|
|
4107
|
-
roiPaletteIndexToTermId:
|
|
4108
|
-
interactionLock:
|
|
4109
|
-
drawTool:
|
|
4110
|
-
stampOptions:
|
|
4111
|
-
brushOptions:
|
|
4112
|
-
drawFillColor:
|
|
4113
|
-
regionStrokeStyle:
|
|
4114
|
-
regionStrokeHoverStyle:
|
|
4115
|
-
regionStrokeActiveStyle:
|
|
4144
|
+
onRoiPointGroups: Pt,
|
|
4145
|
+
roiPaletteIndexToTermId: Ft,
|
|
4146
|
+
interactionLock: Bt = !1,
|
|
4147
|
+
drawTool: ot = "cursor",
|
|
4148
|
+
stampOptions: Wt,
|
|
4149
|
+
brushOptions: ue,
|
|
4150
|
+
drawFillColor: le,
|
|
4151
|
+
regionStrokeStyle: tt,
|
|
4152
|
+
regionStrokeHoverStyle: Vt,
|
|
4153
|
+
regionStrokeActiveStyle: $t,
|
|
4116
4154
|
patchStrokeStyle: be,
|
|
4117
|
-
resolveRegionStrokeStyle:
|
|
4118
|
-
resolveRegionLabelStyle:
|
|
4119
|
-
overlayShapes:
|
|
4120
|
-
customLayers:
|
|
4155
|
+
resolveRegionStrokeStyle: Tt,
|
|
4156
|
+
resolveRegionLabelStyle: st,
|
|
4157
|
+
overlayShapes: R,
|
|
4158
|
+
customLayers: E,
|
|
4121
4159
|
patchRegions: U,
|
|
4122
|
-
regionLabelStyle:
|
|
4123
|
-
drawAreaTooltip:
|
|
4124
|
-
autoLiftRegionLabelAtMaxZoom:
|
|
4160
|
+
regionLabelStyle: et,
|
|
4161
|
+
drawAreaTooltip: W,
|
|
4162
|
+
autoLiftRegionLabelAtMaxZoom: ut = !1,
|
|
4125
4163
|
onPointerWorldMove: wt,
|
|
4126
|
-
onPointHover:
|
|
4127
|
-
onPointClick:
|
|
4128
|
-
onRegionHover:
|
|
4129
|
-
onRegionClick:
|
|
4164
|
+
onPointHover: J,
|
|
4165
|
+
onPointClick: G,
|
|
4166
|
+
onRegionHover: rt,
|
|
4167
|
+
onRegionClick: lt,
|
|
4130
4168
|
activeRegionId: Q,
|
|
4131
|
-
onActiveRegionChange:
|
|
4169
|
+
onActiveRegionChange: X,
|
|
4132
4170
|
getCellByCoordinatesRef: mt,
|
|
4133
|
-
onDrawComplete:
|
|
4134
|
-
onPatchComplete:
|
|
4135
|
-
overviewMapConfig:
|
|
4136
|
-
className:
|
|
4137
|
-
style:
|
|
4171
|
+
onDrawComplete: ft,
|
|
4172
|
+
onPatchComplete: H,
|
|
4173
|
+
overviewMapConfig: yt,
|
|
4174
|
+
className: Et,
|
|
4175
|
+
style: Dt
|
|
4138
4176
|
}) {
|
|
4139
|
-
const
|
|
4177
|
+
const Ot = yt?.show ?? !1, Ct = yt?.options, St = nt(null), $ = nt(null), Zt = nt(null), z = nt(null), Mt = nt(r), at = nt(i), gt = nt(c), [Re, te] = Te(null), [we, Ue] = Te(() => Q ?? null), fe = Q !== void 0, At = fe ? Q ?? null : we, [Be, u] = Te(null), [h, y] = Te(null), [M, T] = Te(0), D = nt(null), L = nt(null), it = nt(null), Z = nt(0), Y = nt({
|
|
4140
4178
|
rafId: null,
|
|
4141
4179
|
startMs: 0,
|
|
4142
4180
|
from: 0,
|
|
4143
4181
|
to: 0
|
|
4144
|
-
}),
|
|
4182
|
+
}), ht = nt(0), pt = F ?? Sn, Lt = U ?? Sn, Rt = k ?? cs, xt = (E?.length ?? 0) > 0, Gt = j(() => ({ position: "relative", width: "100%", height: "100%", ...Dt }), [Dt]), Kt = j(
|
|
4145
4183
|
() => ({
|
|
4146
4184
|
position: "absolute",
|
|
4147
4185
|
top: 8,
|
|
@@ -4163,93 +4201,93 @@ function qs({
|
|
|
4163
4201
|
...l
|
|
4164
4202
|
}),
|
|
4165
4203
|
[l]
|
|
4166
|
-
),
|
|
4204
|
+
), It = j(() => pt.length > 0 ? pt : Rt.length === 0 ? Sn : Rt.map((g, A) => ({
|
|
4167
4205
|
id: A,
|
|
4168
4206
|
coordinates: g
|
|
4169
|
-
})), [
|
|
4207
|
+
})), [pt, Rt]), ee = j(() => Fs(It), [It]), Bn = j(() => _n(et), [et]), ye = I((g) => {
|
|
4170
4208
|
const A = pe(g, 0, Ar);
|
|
4171
|
-
Math.abs(
|
|
4172
|
-
}, []),
|
|
4173
|
-
const g =
|
|
4209
|
+
Math.abs(Z.current - A) < 1e-4 || (Z.current = A, T(A));
|
|
4210
|
+
}, []), he = I(() => {
|
|
4211
|
+
const g = Y.current;
|
|
4174
4212
|
g.rafId !== null && (cancelAnimationFrame(g.rafId), g.rafId = null);
|
|
4175
|
-
}, []), un =
|
|
4213
|
+
}, []), un = I(
|
|
4176
4214
|
(g) => {
|
|
4177
|
-
const A = pe(g, 0, Ar),
|
|
4178
|
-
if (Math.abs(
|
|
4179
|
-
|
|
4215
|
+
const A = pe(g, 0, Ar), P = Y.current, C = Z.current;
|
|
4216
|
+
if (Math.abs(C - A) < 1e-4) {
|
|
4217
|
+
he(), P.to = A, ye(A);
|
|
4180
4218
|
return;
|
|
4181
4219
|
}
|
|
4182
|
-
|
|
4183
|
-
const v = (
|
|
4184
|
-
const
|
|
4185
|
-
if (
|
|
4186
|
-
|
|
4220
|
+
he(), P.startMs = performance.now(), P.from = C, P.to = A;
|
|
4221
|
+
const v = (q) => {
|
|
4222
|
+
const vt = Y.current, Jt = Math.max(0, q - vt.startMs), xe = pe(Jt / ys, 0, 1), De = Ts(xe), Oe = vt.from + (vt.to - vt.from) * De;
|
|
4223
|
+
if (ye(Oe), Zt.current?.(), xe >= 1) {
|
|
4224
|
+
vt.rafId = null, ye(vt.to);
|
|
4187
4225
|
return;
|
|
4188
4226
|
}
|
|
4189
|
-
|
|
4227
|
+
vt.rafId = requestAnimationFrame(v);
|
|
4190
4228
|
};
|
|
4191
|
-
|
|
4229
|
+
P.rafId = requestAnimationFrame(v);
|
|
4192
4230
|
},
|
|
4193
|
-
[
|
|
4194
|
-
),
|
|
4231
|
+
[ye, he]
|
|
4232
|
+
), ne = I(
|
|
4195
4233
|
(g) => {
|
|
4196
|
-
const A =
|
|
4234
|
+
const A = $.current;
|
|
4197
4235
|
if (!A || typeof g != "number" || !Number.isFinite(g)) {
|
|
4198
4236
|
un(0);
|
|
4199
4237
|
return;
|
|
4200
4238
|
}
|
|
4201
|
-
const
|
|
4202
|
-
un(
|
|
4239
|
+
const P = Lr(ut, g, A.getZoomRange());
|
|
4240
|
+
un(P);
|
|
4203
4241
|
},
|
|
4204
|
-
[
|
|
4205
|
-
),
|
|
4206
|
-
|
|
4207
|
-
const g = ++
|
|
4242
|
+
[ut, un]
|
|
4243
|
+
), de = j(() => It.map((g) => g.coordinates), [It]), [Se, Le] = Te(m);
|
|
4244
|
+
O(() => {
|
|
4245
|
+
const g = ++ht.current;
|
|
4208
4246
|
let A = !1;
|
|
4209
|
-
if (!
|
|
4210
|
-
return
|
|
4247
|
+
if (!K)
|
|
4248
|
+
return Le(m), () => {
|
|
4211
4249
|
A = !0;
|
|
4212
4250
|
};
|
|
4213
|
-
if (!
|
|
4214
|
-
return
|
|
4251
|
+
if (!m || !m.count || !m.positions || !m.paletteIndices)
|
|
4252
|
+
return Le(null), () => {
|
|
4215
4253
|
A = !0;
|
|
4216
4254
|
};
|
|
4217
|
-
if (
|
|
4218
|
-
return
|
|
4255
|
+
if (de.length === 0)
|
|
4256
|
+
return Le(us), bt?.({
|
|
4219
4257
|
mode: dt,
|
|
4220
4258
|
durationMs: 0,
|
|
4221
|
-
inputCount:
|
|
4259
|
+
inputCount: m.count,
|
|
4222
4260
|
outputCount: 0,
|
|
4223
4261
|
polygonCount: 0
|
|
4224
4262
|
}), () => {
|
|
4225
4263
|
A = !0;
|
|
4226
4264
|
};
|
|
4227
|
-
const
|
|
4228
|
-
if (A || g !==
|
|
4229
|
-
const
|
|
4230
|
-
|
|
4231
|
-
mode:
|
|
4232
|
-
durationMs:
|
|
4233
|
-
inputCount:
|
|
4234
|
-
outputCount:
|
|
4235
|
-
polygonCount:
|
|
4236
|
-
usedWebGpu:
|
|
4237
|
-
candidateCount:
|
|
4238
|
-
bridgedToDraw:
|
|
4265
|
+
const P = (v, q) => {
|
|
4266
|
+
if (A || g !== ht.current) return;
|
|
4267
|
+
const vt = v?.drawIndices ? v.drawIndices.length : v?.count ?? 0;
|
|
4268
|
+
Le(v), bt?.({
|
|
4269
|
+
mode: q.mode,
|
|
4270
|
+
durationMs: q.durationMs,
|
|
4271
|
+
inputCount: m.count,
|
|
4272
|
+
outputCount: vt,
|
|
4273
|
+
polygonCount: de.length,
|
|
4274
|
+
usedWebGpu: q.usedWebGpu,
|
|
4275
|
+
candidateCount: q.candidateCount,
|
|
4276
|
+
bridgedToDraw: q.bridgedToDraw
|
|
4239
4277
|
});
|
|
4240
4278
|
};
|
|
4241
4279
|
return (async () => {
|
|
4242
4280
|
if (dt === "sync") {
|
|
4243
|
-
const v = performance.now(),
|
|
4244
|
-
|
|
4281
|
+
const v = performance.now(), q = cn(m, de);
|
|
4282
|
+
P(q, {
|
|
4245
4283
|
mode: "sync",
|
|
4246
4284
|
durationMs: performance.now() - v
|
|
4247
4285
|
});
|
|
4248
4286
|
return;
|
|
4249
4287
|
}
|
|
4250
4288
|
if (dt === "hybrid-webgpu") {
|
|
4251
|
-
const v = await Go(
|
|
4252
|
-
|
|
4289
|
+
const v = await Go(m, de, { bridgeToDraw: !0 });
|
|
4290
|
+
P(v.data, {
|
|
4253
4291
|
mode: v.meta.mode,
|
|
4254
4292
|
durationMs: v.meta.durationMs,
|
|
4255
4293
|
usedWebGpu: v.meta.usedWebGpu,
|
|
@@ -4259,14 +4297,14 @@ function qs({
|
|
|
4259
4297
|
return;
|
|
4260
4298
|
}
|
|
4261
4299
|
try {
|
|
4262
|
-
const v = await Ho(
|
|
4263
|
-
|
|
4300
|
+
const v = await Ho(m, de);
|
|
4301
|
+
P(v.data, {
|
|
4264
4302
|
mode: v.meta.mode,
|
|
4265
4303
|
durationMs: v.meta.durationMs
|
|
4266
4304
|
});
|
|
4267
4305
|
} catch {
|
|
4268
|
-
const v = performance.now(),
|
|
4269
|
-
|
|
4306
|
+
const v = performance.now(), q = cn(m, de);
|
|
4307
|
+
P(q, {
|
|
4270
4308
|
mode: "sync",
|
|
4271
4309
|
durationMs: performance.now() - v
|
|
4272
4310
|
});
|
|
@@ -4274,210 +4312,210 @@ function qs({
|
|
|
4274
4312
|
})(), () => {
|
|
4275
4313
|
A = !0;
|
|
4276
4314
|
};
|
|
4277
|
-
}, [
|
|
4278
|
-
const
|
|
4315
|
+
}, [K, dt, m, de, bt]);
|
|
4316
|
+
const Ln = !!(J || G || mt), Nt = j(() => Ln ? xs(Se, e) : null, [Ln, Se, e]), me = I(
|
|
4279
4317
|
(g) => {
|
|
4280
|
-
const A =
|
|
4281
|
-
if (!A || !
|
|
4282
|
-
const
|
|
4283
|
-
if (!Number.isFinite(
|
|
4284
|
-
const v = Math.max(1e-6, A.getViewState().zoom),
|
|
4285
|
-
if (!Number.isFinite(
|
|
4286
|
-
const
|
|
4287
|
-
let
|
|
4288
|
-
for (let ln =
|
|
4289
|
-
const
|
|
4290
|
-
if (
|
|
4291
|
-
for (let fn =
|
|
4292
|
-
const
|
|
4293
|
-
if (!(!
|
|
4294
|
-
for (let hn = 0; hn <
|
|
4295
|
-
const
|
|
4296
|
-
if (
|
|
4297
|
-
const
|
|
4298
|
-
|
|
4318
|
+
const A = $.current;
|
|
4319
|
+
if (!A || !Nt) return null;
|
|
4320
|
+
const P = Number(g[0]), C = Number(g[1]);
|
|
4321
|
+
if (!Number.isFinite(P) || !Number.isFinite(C)) return null;
|
|
4322
|
+
const v = Math.max(1e-6, A.getViewState().zoom), q = A.getPointSizeByZoom(), Jt = Math.max(fs, q * ls) / v;
|
|
4323
|
+
if (!Number.isFinite(Jt) || Jt <= 0) return null;
|
|
4324
|
+
const xe = Nt.cellSize, De = Math.floor(P / xe), Oe = Math.floor(C / xe), Xe = Math.max(1, Math.ceil(Jt / xe)), jr = Jt * Jt;
|
|
4325
|
+
let Ye = -1, kn = jr, Wn = 0, Vn = 0;
|
|
4326
|
+
for (let ln = De - Xe; ln <= De + Xe; ln += 1) {
|
|
4327
|
+
const Gn = Nt.buckets.get(ln);
|
|
4328
|
+
if (Gn)
|
|
4329
|
+
for (let fn = Oe - Xe; fn <= Oe + Xe; fn += 1) {
|
|
4330
|
+
const ke = Gn.get(fn);
|
|
4331
|
+
if (!(!ke || ke.length === 0))
|
|
4332
|
+
for (let hn = 0; hn < ke.length; hn += 1) {
|
|
4333
|
+
const We = ke[hn];
|
|
4334
|
+
if (We >= Nt.safeCount) continue;
|
|
4335
|
+
const Hn = Nt.positions[We * 2], qn = Nt.positions[We * 2 + 1], $n = Hn - P, Zn = qn - C, Kn = $n * $n + Zn * Zn;
|
|
4336
|
+
Kn > kn || (kn = Kn, Ye = We, Wn = Hn, Vn = qn);
|
|
4299
4337
|
}
|
|
4300
4338
|
}
|
|
4301
4339
|
}
|
|
4302
|
-
if (
|
|
4303
|
-
const ti =
|
|
4340
|
+
if (Ye < 0) return null;
|
|
4341
|
+
const ti = Nt.ids ? Number(Nt.ids[Ye]) : null;
|
|
4304
4342
|
return {
|
|
4305
|
-
index:
|
|
4343
|
+
index: Ye,
|
|
4306
4344
|
id: ti,
|
|
4307
|
-
coordinate: [
|
|
4308
|
-
pointCoordinate: [
|
|
4345
|
+
coordinate: [P, C],
|
|
4346
|
+
pointCoordinate: [Wn, Vn]
|
|
4309
4347
|
};
|
|
4310
4348
|
},
|
|
4311
|
-
[
|
|
4312
|
-
),
|
|
4349
|
+
[Nt]
|
|
4350
|
+
), Me = I(
|
|
4313
4351
|
(g, A) => {
|
|
4314
|
-
if (
|
|
4315
|
-
const
|
|
4316
|
-
|
|
4317
|
-
index:
|
|
4318
|
-
id:
|
|
4352
|
+
if (!J) return;
|
|
4353
|
+
const P = g?.index ?? null, C = g?.id ?? null;
|
|
4354
|
+
L.current === P && it.current === C || (L.current = P, it.current = C, J({
|
|
4355
|
+
index: P,
|
|
4356
|
+
id: C,
|
|
4319
4357
|
coordinate: A,
|
|
4320
4358
|
pointCoordinate: g?.pointCoordinate ?? null
|
|
4321
4359
|
}));
|
|
4322
4360
|
},
|
|
4323
|
-
[
|
|
4324
|
-
),
|
|
4361
|
+
[J]
|
|
4362
|
+
), Ne = I(
|
|
4325
4363
|
(g, A) => {
|
|
4326
|
-
if (!
|
|
4327
|
-
const
|
|
4328
|
-
|
|
4329
|
-
...
|
|
4364
|
+
if (!G) return;
|
|
4365
|
+
const P = me(g);
|
|
4366
|
+
P && G({
|
|
4367
|
+
...P,
|
|
4330
4368
|
button: A
|
|
4331
4369
|
});
|
|
4332
4370
|
},
|
|
4333
|
-
[
|
|
4371
|
+
[G, me]
|
|
4334
4372
|
);
|
|
4335
|
-
|
|
4373
|
+
O(() => {
|
|
4336
4374
|
if (mt)
|
|
4337
|
-
return mt.current =
|
|
4338
|
-
mt.current ===
|
|
4375
|
+
return mt.current = me, () => {
|
|
4376
|
+
mt.current === me && (mt.current = null);
|
|
4339
4377
|
};
|
|
4340
|
-
}, [mt,
|
|
4341
|
-
|
|
4342
|
-
}, [
|
|
4343
|
-
const
|
|
4378
|
+
}, [mt, me]), O(() => {
|
|
4379
|
+
fe && Ue(Q ?? null);
|
|
4380
|
+
}, [fe, Q]);
|
|
4381
|
+
const re = I(
|
|
4344
4382
|
(g) => {
|
|
4345
|
-
String(
|
|
4383
|
+
String(At) !== String(g) && (fe || Ue(g), X?.(g));
|
|
4346
4384
|
},
|
|
4347
|
-
[
|
|
4385
|
+
[At, fe, X]
|
|
4348
4386
|
);
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
}, [r]),
|
|
4387
|
+
O(() => {
|
|
4388
|
+
Mt.current = r;
|
|
4389
|
+
}, [r]), O(() => {
|
|
4352
4390
|
at.current = i;
|
|
4353
|
-
}, [i]),
|
|
4354
|
-
|
|
4355
|
-
}, [c]),
|
|
4356
|
-
|
|
4357
|
-
}, [
|
|
4358
|
-
const
|
|
4359
|
-
at.current?.(g),
|
|
4360
|
-
}, []), qr =
|
|
4361
|
-
`tier ${
|
|
4362
|
-
`tiles visible ${
|
|
4363
|
-
`cache size ${
|
|
4364
|
-
`queue inflight ${
|
|
4365
|
-
`points ${
|
|
4391
|
+
}, [i]), O(() => {
|
|
4392
|
+
gt.current = c, c || y(null);
|
|
4393
|
+
}, [c]), O(() => () => {
|
|
4394
|
+
he();
|
|
4395
|
+
}, [he]);
|
|
4396
|
+
const Nn = I((g) => {
|
|
4397
|
+
at.current?.(g), gt.current && y(g);
|
|
4398
|
+
}, []), qr = j(() => h ? [
|
|
4399
|
+
`tier ${h.tier} | frame ${h.frameMs?.toFixed(2) ?? "-"} ms | drawCalls ${h.drawCalls ?? "-"}`,
|
|
4400
|
+
`tiles visible ${h.visible} | rendered ${h.rendered} | fallback ${h.fallback}`,
|
|
4401
|
+
`cache size ${h.cache} | hit ${h.cacheHits ?? "-"} | miss ${h.cacheMisses ?? "-"}`,
|
|
4402
|
+
`queue inflight ${h.inflight} | queued ${h.queued ?? "-"} | retries ${h.retries ?? "-"} | failed ${h.failed ?? "-"} | aborted ${h.aborted ?? "-"}`,
|
|
4403
|
+
`points ${h.points}`
|
|
4366
4404
|
].join(`
|
|
4367
|
-
`) : "stats: waiting for first frame...", [
|
|
4368
|
-
|
|
4369
|
-
!(
|
|
4370
|
-
const A =
|
|
4371
|
-
!(A === null ? !0 :
|
|
4405
|
+
`) : "stats: waiting for first frame...", [h]);
|
|
4406
|
+
O(() => {
|
|
4407
|
+
!(At === null ? !0 : It.some((C, v) => String(In(C, v)) === String(At))) && At !== null && re(null);
|
|
4408
|
+
const A = D.current;
|
|
4409
|
+
!(A === null ? !0 : It.some((C, v) => String(In(C, v)) === String(A))) && A !== null && (D.current = null, te(null), rt?.({
|
|
4372
4410
|
region: null,
|
|
4373
4411
|
regionId: null,
|
|
4374
4412
|
regionIndex: -1,
|
|
4375
4413
|
coordinate: null
|
|
4376
4414
|
}));
|
|
4377
|
-
}, [
|
|
4378
|
-
const g =
|
|
4379
|
-
g !== null && (
|
|
4415
|
+
}, [It, At, rt, re]), O(() => {
|
|
4416
|
+
const g = L.current;
|
|
4417
|
+
g !== null && (Nt && g < Nt.safeCount || (L.current = null, it.current = null, J?.({
|
|
4380
4418
|
index: null,
|
|
4381
4419
|
id: null,
|
|
4382
4420
|
coordinate: null,
|
|
4383
4421
|
pointCoordinate: null
|
|
4384
4422
|
})));
|
|
4385
|
-
}, [
|
|
4386
|
-
const
|
|
4423
|
+
}, [Nt, J]);
|
|
4424
|
+
const zn = I(
|
|
4387
4425
|
(g) => {
|
|
4388
|
-
|
|
4389
|
-
const A =
|
|
4390
|
-
A && A(g),
|
|
4426
|
+
ne(g.zoom), xt && u(g);
|
|
4427
|
+
const A = Mt.current;
|
|
4428
|
+
A && A(g), Zt.current?.(), z.current?.();
|
|
4391
4429
|
},
|
|
4392
|
-
[
|
|
4430
|
+
[xt, ne]
|
|
4393
4431
|
);
|
|
4394
|
-
|
|
4395
|
-
const g =
|
|
4396
|
-
g &&
|
|
4397
|
-
}, [
|
|
4398
|
-
|
|
4432
|
+
O(() => {
|
|
4433
|
+
const g = $.current;
|
|
4434
|
+
g && ne(g.getViewState().zoom);
|
|
4435
|
+
}, [ne, B, N]), O(() => {
|
|
4436
|
+
ot !== "cursor" && D.current !== null && (D.current = null, te(null), rt?.({
|
|
4399
4437
|
region: null,
|
|
4400
4438
|
regionId: null,
|
|
4401
4439
|
regionIndex: -1,
|
|
4402
4440
|
coordinate: null
|
|
4403
4441
|
}));
|
|
4404
|
-
}, [
|
|
4405
|
-
|
|
4442
|
+
}, [ot, rt]), O(() => {
|
|
4443
|
+
ot !== "cursor" && L.current !== null && (L.current = null, it.current = null, J?.({
|
|
4406
4444
|
index: null,
|
|
4407
4445
|
id: null,
|
|
4408
4446
|
coordinate: null,
|
|
4409
4447
|
pointCoordinate: null
|
|
4410
4448
|
}));
|
|
4411
|
-
}, [
|
|
4412
|
-
const
|
|
4413
|
-
const
|
|
4414
|
-
if (!
|
|
4415
|
-
const
|
|
4416
|
-
if (!Array.isArray(
|
|
4417
|
-
const v = Number(
|
|
4418
|
-
return !Number.isFinite(v) || !Number.isFinite(
|
|
4419
|
-
}, []),
|
|
4420
|
-
const
|
|
4421
|
-
if (!
|
|
4422
|
-
const
|
|
4423
|
-
return
|
|
4424
|
-
}, []),
|
|
4425
|
-
const
|
|
4426
|
-
if (!
|
|
4427
|
-
const
|
|
4428
|
-
if (!Number.isFinite(
|
|
4449
|
+
}, [ot, J]);
|
|
4450
|
+
const ie = I((g, A) => {
|
|
4451
|
+
const P = $.current;
|
|
4452
|
+
if (!P) return null;
|
|
4453
|
+
const C = P.screenToWorld(g, A);
|
|
4454
|
+
if (!Array.isArray(C) || C.length < 2) return null;
|
|
4455
|
+
const v = Number(C[0]), q = Number(C[1]);
|
|
4456
|
+
return !Number.isFinite(v) || !Number.isFinite(q) ? null : [v, q];
|
|
4457
|
+
}, []), Dn = I((g, A) => {
|
|
4458
|
+
const P = $.current;
|
|
4459
|
+
if (!P) return null;
|
|
4460
|
+
const C = P.worldToScreen(g, A);
|
|
4461
|
+
return vn(C);
|
|
4462
|
+
}, []), ze = I((g, A) => {
|
|
4463
|
+
const P = St.current;
|
|
4464
|
+
if (!P) return null;
|
|
4465
|
+
const C = P.getBoundingClientRect();
|
|
4466
|
+
if (!Number.isFinite(C.width) || !Number.isFinite(C.height) || C.width <= 0 || C.height <= 0)
|
|
4429
4467
|
return null;
|
|
4430
|
-
const v = g -
|
|
4431
|
-
return !Number.isFinite(v) || !Number.isFinite(
|
|
4432
|
-
screenCoord: [v,
|
|
4433
|
-
canvasWidth: Math.max(1,
|
|
4434
|
-
canvasHeight: Math.max(1,
|
|
4468
|
+
const v = g - C.left, q = A - C.top;
|
|
4469
|
+
return !Number.isFinite(v) || !Number.isFinite(q) ? null : {
|
|
4470
|
+
screenCoord: [v, q],
|
|
4471
|
+
canvasWidth: Math.max(1, C.width),
|
|
4472
|
+
canvasHeight: Math.max(1, C.height)
|
|
4435
4473
|
};
|
|
4436
|
-
}, []),
|
|
4437
|
-
(g, A,
|
|
4438
|
-
const v =
|
|
4474
|
+
}, []), Ae = I(
|
|
4475
|
+
(g, A, P, C) => {
|
|
4476
|
+
const v = $.current;
|
|
4439
4477
|
return v ? Us(
|
|
4440
4478
|
g,
|
|
4441
4479
|
A,
|
|
4442
|
-
|
|
4480
|
+
ee,
|
|
4443
4481
|
v,
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4482
|
+
Bn,
|
|
4483
|
+
st,
|
|
4484
|
+
M,
|
|
4485
|
+
P,
|
|
4486
|
+
C
|
|
4449
4487
|
) : null;
|
|
4450
4488
|
},
|
|
4451
|
-
[
|
|
4452
|
-
),
|
|
4453
|
-
|
|
4454
|
-
}, []),
|
|
4489
|
+
[ee, Bn, st, M]
|
|
4490
|
+
), On = I(() => {
|
|
4491
|
+
$.current?.requestRender(), Zt.current?.(), z.current?.();
|
|
4492
|
+
}, []), Xn = j(() => Be ?? $.current?.getViewState() ?? null, [Be]), Yn = j(() => {
|
|
4455
4493
|
if (!e) return null;
|
|
4456
|
-
const g =
|
|
4494
|
+
const g = Xn;
|
|
4457
4495
|
return g ? {
|
|
4458
4496
|
source: e,
|
|
4459
4497
|
viewState: g,
|
|
4460
|
-
drawTool:
|
|
4461
|
-
interactionLock:
|
|
4462
|
-
worldToScreen:
|
|
4463
|
-
screenToWorld:
|
|
4464
|
-
requestRedraw:
|
|
4498
|
+
drawTool: ot,
|
|
4499
|
+
interactionLock: Bt,
|
|
4500
|
+
worldToScreen: Dn,
|
|
4501
|
+
screenToWorld: ie,
|
|
4502
|
+
requestRedraw: On
|
|
4465
4503
|
} : null;
|
|
4466
|
-
}, [e,
|
|
4504
|
+
}, [e, Xn, ot, Bt, Dn, ie, On]), $r = I(
|
|
4467
4505
|
(g) => {
|
|
4468
|
-
const A = g.target ===
|
|
4506
|
+
const A = g.target === St.current, P = ie(g.clientX, g.clientY);
|
|
4469
4507
|
if (wt) {
|
|
4470
|
-
const
|
|
4508
|
+
const Jt = !!P && P[0] >= 0 && P[1] >= 0 && !!e && P[0] <= e.width && P[1] <= e.height;
|
|
4471
4509
|
wt({
|
|
4472
|
-
coordinate:
|
|
4510
|
+
coordinate: P,
|
|
4473
4511
|
clientX: g.clientX,
|
|
4474
4512
|
clientY: g.clientY,
|
|
4475
|
-
insideImage:
|
|
4513
|
+
insideImage: Jt
|
|
4476
4514
|
});
|
|
4477
4515
|
}
|
|
4478
|
-
if (
|
|
4516
|
+
if (ot !== "cursor") return;
|
|
4479
4517
|
if (!A) {
|
|
4480
|
-
|
|
4518
|
+
Me(null, null), D.current !== null && (D.current = null, te(null), rt?.({
|
|
4481
4519
|
region: null,
|
|
4482
4520
|
regionId: null,
|
|
4483
4521
|
regionIndex: -1,
|
|
@@ -4485,179 +4523,179 @@ function qs({
|
|
|
4485
4523
|
}));
|
|
4486
4524
|
return;
|
|
4487
4525
|
}
|
|
4488
|
-
if (!
|
|
4489
|
-
|
|
4526
|
+
if (!P) {
|
|
4527
|
+
Me(null, null);
|
|
4490
4528
|
return;
|
|
4491
4529
|
}
|
|
4492
|
-
if (
|
|
4493
|
-
const
|
|
4494
|
-
if (!
|
|
4495
|
-
const v =
|
|
4496
|
-
String(
|
|
4530
|
+
if (J && Me(me(P), P), !ee.length) return;
|
|
4531
|
+
const C = ze(g.clientX, g.clientY);
|
|
4532
|
+
if (!C) return;
|
|
4533
|
+
const v = Ae(P, C.screenCoord, C.canvasWidth, C.canvasHeight), q = v?.regionId ?? null, vt = D.current;
|
|
4534
|
+
String(vt) !== String(q) && (D.current = q, te(q), rt?.({
|
|
4497
4535
|
region: v?.region ?? null,
|
|
4498
|
-
regionId:
|
|
4536
|
+
regionId: q,
|
|
4499
4537
|
regionIndex: v?.regionIndex ?? -1,
|
|
4500
|
-
coordinate:
|
|
4538
|
+
coordinate: P
|
|
4501
4539
|
}));
|
|
4502
4540
|
},
|
|
4503
|
-
[
|
|
4504
|
-
), Zr =
|
|
4541
|
+
[ot, ee, ie, rt, wt, e, Me, me, J, ze, Ae]
|
|
4542
|
+
), Zr = I(() => {
|
|
4505
4543
|
wt?.({
|
|
4506
4544
|
coordinate: null,
|
|
4507
4545
|
clientX: -1,
|
|
4508
4546
|
clientY: -1,
|
|
4509
4547
|
insideImage: !1
|
|
4510
|
-
}),
|
|
4548
|
+
}), Me(null, null), D.current !== null && (D.current = null, te(null), rt?.({
|
|
4511
4549
|
region: null,
|
|
4512
4550
|
regionId: null,
|
|
4513
4551
|
regionIndex: -1,
|
|
4514
4552
|
coordinate: null
|
|
4515
4553
|
}));
|
|
4516
|
-
}, [
|
|
4554
|
+
}, [rt, wt, Me]), Kr = I(
|
|
4517
4555
|
(g) => {
|
|
4518
|
-
if (
|
|
4519
|
-
const A =
|
|
4556
|
+
if (ot !== "cursor" || g.target !== St.current) return;
|
|
4557
|
+
const A = ie(g.clientX, g.clientY);
|
|
4520
4558
|
if (!A) return;
|
|
4521
|
-
if (
|
|
4522
|
-
|
|
4559
|
+
if (Ne(A, g.button), !ee.length) {
|
|
4560
|
+
re(null);
|
|
4523
4561
|
return;
|
|
4524
4562
|
}
|
|
4525
|
-
const
|
|
4526
|
-
if (!
|
|
4527
|
-
const
|
|
4528
|
-
if (!
|
|
4529
|
-
|
|
4563
|
+
const P = ze(g.clientX, g.clientY);
|
|
4564
|
+
if (!P) return;
|
|
4565
|
+
const C = Ae(A, P.screenCoord, P.canvasWidth, P.canvasHeight);
|
|
4566
|
+
if (!C) {
|
|
4567
|
+
re(null);
|
|
4530
4568
|
return;
|
|
4531
4569
|
}
|
|
4532
|
-
const v =
|
|
4533
|
-
|
|
4534
|
-
region:
|
|
4535
|
-
regionId:
|
|
4536
|
-
regionIndex:
|
|
4570
|
+
const v = At !== null && String(At) === String(C.regionId) ? null : C.regionId;
|
|
4571
|
+
re(v), lt?.({
|
|
4572
|
+
region: C.region,
|
|
4573
|
+
regionId: C.regionId,
|
|
4574
|
+
regionIndex: C.regionIndex,
|
|
4537
4575
|
coordinate: A
|
|
4538
4576
|
});
|
|
4539
4577
|
},
|
|
4540
|
-
[
|
|
4541
|
-
), Jr =
|
|
4578
|
+
[ot, ee, ie, lt, At, re, Ne, ze, Ae]
|
|
4579
|
+
), Jr = I(
|
|
4542
4580
|
(g) => {
|
|
4543
|
-
if (
|
|
4544
|
-
const A =
|
|
4545
|
-
if (!A || !
|
|
4546
|
-
const
|
|
4547
|
-
if (
|
|
4548
|
-
const v =
|
|
4581
|
+
if (ot !== "brush" || ue?.clickSelectRoi !== !0 || !ee.length) return !1;
|
|
4582
|
+
const A = $.current, P = St.current;
|
|
4583
|
+
if (!A || !P) return !1;
|
|
4584
|
+
const C = P.getBoundingClientRect();
|
|
4585
|
+
if (C.width <= 0 || C.height <= 0) return !1;
|
|
4586
|
+
const v = vn(A.worldToScreen(g[0], g[1]));
|
|
4549
4587
|
if (!v) return !1;
|
|
4550
|
-
const
|
|
4551
|
-
if (!
|
|
4552
|
-
const
|
|
4553
|
-
return
|
|
4554
|
-
region:
|
|
4555
|
-
regionId:
|
|
4556
|
-
regionIndex:
|
|
4588
|
+
const q = Ae(g, v, C.width, C.height);
|
|
4589
|
+
if (!q) return !1;
|
|
4590
|
+
const vt = At !== null && String(At) === String(q.regionId) ? null : q.regionId;
|
|
4591
|
+
return re(vt), lt?.({
|
|
4592
|
+
region: q.region,
|
|
4593
|
+
regionId: q.regionId,
|
|
4594
|
+
regionIndex: q.regionIndex,
|
|
4557
4595
|
coordinate: g
|
|
4558
4596
|
}), !0;
|
|
4559
4597
|
},
|
|
4560
|
-
[
|
|
4561
|
-
),
|
|
4598
|
+
[ot, ue?.clickSelectRoi, ee, At, re, lt, Ae]
|
|
4599
|
+
), Qr = I(
|
|
4562
4600
|
(g) => {
|
|
4563
|
-
if (!
|
|
4601
|
+
if (!G || ot !== "cursor" || g.target !== St.current) return;
|
|
4564
4602
|
g.preventDefault();
|
|
4565
|
-
const A =
|
|
4566
|
-
A &&
|
|
4603
|
+
const A = ie(g.clientX, g.clientY);
|
|
4604
|
+
A && Ne(A, g.button);
|
|
4567
4605
|
},
|
|
4568
|
-
[
|
|
4606
|
+
[ot, ie, Ne, G]
|
|
4569
4607
|
);
|
|
4570
|
-
return
|
|
4571
|
-
const g =
|
|
4608
|
+
return O(() => {
|
|
4609
|
+
const g = St.current;
|
|
4572
4610
|
if (!g || !e)
|
|
4573
4611
|
return;
|
|
4574
4612
|
const A = new as(g, e, {
|
|
4575
|
-
onViewStateChange:
|
|
4576
|
-
onStats:
|
|
4613
|
+
onViewStateChange: zn,
|
|
4614
|
+
onStats: Nn,
|
|
4577
4615
|
onTileError: o,
|
|
4578
4616
|
onContextLost: s,
|
|
4579
4617
|
onContextRestored: a,
|
|
4580
|
-
authToken:
|
|
4618
|
+
authToken: d,
|
|
4581
4619
|
imageColorSettings: n,
|
|
4582
4620
|
ctrlDragRotate: b,
|
|
4583
4621
|
pointSizeByZoom: x,
|
|
4584
4622
|
pointStrokeScale: _,
|
|
4585
|
-
minZoom:
|
|
4623
|
+
minZoom: B,
|
|
4586
4624
|
maxZoom: N,
|
|
4587
4625
|
viewTransition: V
|
|
4588
4626
|
});
|
|
4589
|
-
return
|
|
4590
|
-
|
|
4627
|
+
return $.current = A, t && A.setViewState(t), ne(A.getViewState().zoom), A.setInteractionLock(Bt), xt && u(A.getViewState()), () => {
|
|
4628
|
+
he(), ye(0), A.destroy(), $.current = null;
|
|
4591
4629
|
};
|
|
4592
4630
|
}, [
|
|
4593
4631
|
e,
|
|
4594
|
-
|
|
4632
|
+
Nn,
|
|
4595
4633
|
o,
|
|
4596
4634
|
s,
|
|
4597
4635
|
a,
|
|
4598
|
-
|
|
4636
|
+
d,
|
|
4599
4637
|
b,
|
|
4600
4638
|
x,
|
|
4601
4639
|
_,
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
]),
|
|
4608
|
-
const g =
|
|
4640
|
+
zn,
|
|
4641
|
+
xt,
|
|
4642
|
+
ne,
|
|
4643
|
+
he,
|
|
4644
|
+
ye
|
|
4645
|
+
]), O(() => {
|
|
4646
|
+
const g = $.current;
|
|
4609
4647
|
!g || !t || g.setViewState(t);
|
|
4610
|
-
}, [t]),
|
|
4611
|
-
const g =
|
|
4648
|
+
}, [t]), O(() => {
|
|
4649
|
+
const g = $.current;
|
|
4612
4650
|
g && g.fitToImage();
|
|
4613
|
-
}, [f]),
|
|
4614
|
-
const g =
|
|
4651
|
+
}, [f]), O(() => {
|
|
4652
|
+
const g = $.current;
|
|
4615
4653
|
g && g.resetRotation();
|
|
4616
|
-
}, [p]),
|
|
4617
|
-
const g =
|
|
4654
|
+
}, [p]), O(() => {
|
|
4655
|
+
const g = $.current;
|
|
4618
4656
|
!g || !S || g.setPointPalette(S);
|
|
4619
|
-
}, [S]),
|
|
4620
|
-
const g =
|
|
4657
|
+
}, [S]), O(() => {
|
|
4658
|
+
const g = $.current;
|
|
4621
4659
|
g && g.setPointSizeByZoom(x);
|
|
4622
|
-
}, [x]),
|
|
4623
|
-
const g =
|
|
4660
|
+
}, [x]), O(() => {
|
|
4661
|
+
const g = $.current;
|
|
4624
4662
|
g && g.setPointStrokeScale(_);
|
|
4625
|
-
}, [_]),
|
|
4626
|
-
const g =
|
|
4627
|
-
g && (g.setZoomRange(
|
|
4628
|
-
}, [
|
|
4629
|
-
const g =
|
|
4663
|
+
}, [_]), O(() => {
|
|
4664
|
+
const g = $.current;
|
|
4665
|
+
g && (g.setZoomRange(B, N), ne(g.getViewState().zoom));
|
|
4666
|
+
}, [B, N, ne]), O(() => {
|
|
4667
|
+
const g = $.current;
|
|
4630
4668
|
g && g.setViewTransition(V);
|
|
4631
|
-
}, [V]),
|
|
4632
|
-
const g =
|
|
4669
|
+
}, [V]), O(() => {
|
|
4670
|
+
const g = $.current;
|
|
4633
4671
|
g && g.setImageColorSettings(n);
|
|
4634
|
-
}, [n]),
|
|
4635
|
-
const g =
|
|
4636
|
-
g && g.setPointData(
|
|
4637
|
-
}, [
|
|
4638
|
-
if (!
|
|
4639
|
-
const A = Zo(
|
|
4640
|
-
paletteIndexToTermId:
|
|
4672
|
+
}, [n]), O(() => {
|
|
4673
|
+
const g = $.current;
|
|
4674
|
+
g && g.setPointData(Se);
|
|
4675
|
+
}, [Se]), O(() => {
|
|
4676
|
+
if (!Pt) return;
|
|
4677
|
+
const A = Zo(K ? Se : m, It, {
|
|
4678
|
+
paletteIndexToTermId: Ft,
|
|
4641
4679
|
includeEmptyRegions: !0
|
|
4642
4680
|
});
|
|
4643
|
-
|
|
4644
|
-
}, [
|
|
4645
|
-
const g =
|
|
4646
|
-
g && g.setInteractionLock(
|
|
4647
|
-
}, [
|
|
4681
|
+
Pt(A);
|
|
4682
|
+
}, [Pt, K, m, Se, It, Ft]), O(() => {
|
|
4683
|
+
const g = $.current;
|
|
4684
|
+
g && g.setInteractionLock(Bt);
|
|
4685
|
+
}, [Bt]), /* @__PURE__ */ Tr(
|
|
4648
4686
|
"div",
|
|
4649
4687
|
{
|
|
4650
|
-
className:
|
|
4651
|
-
style:
|
|
4688
|
+
className: Et,
|
|
4689
|
+
style: Gt,
|
|
4652
4690
|
onPointerMove: $r,
|
|
4653
4691
|
onPointerLeave: Zr,
|
|
4654
4692
|
onClick: Kr,
|
|
4655
|
-
onContextMenu:
|
|
4693
|
+
onContextMenu: Qr,
|
|
4656
4694
|
children: [
|
|
4657
|
-
/* @__PURE__ */
|
|
4695
|
+
/* @__PURE__ */ jt(
|
|
4658
4696
|
"canvas",
|
|
4659
4697
|
{
|
|
4660
|
-
ref:
|
|
4698
|
+
ref: St,
|
|
4661
4699
|
className: "wsi-render-canvas",
|
|
4662
4700
|
style: {
|
|
4663
4701
|
position: "absolute",
|
|
@@ -4667,11 +4705,11 @@ function qs({
|
|
|
4667
4705
|
height: "100%",
|
|
4668
4706
|
display: "block",
|
|
4669
4707
|
touchAction: "none",
|
|
4670
|
-
cursor:
|
|
4708
|
+
cursor: ot === "cursor" && Re !== null ? "pointer" : Bt ? "crosshair" : "grab"
|
|
4671
4709
|
}
|
|
4672
4710
|
}
|
|
4673
4711
|
),
|
|
4674
|
-
e &&
|
|
4712
|
+
e && Yn && Array.isArray(E) && E.length > 0 ? E.map((g, A) => /* @__PURE__ */ jt(
|
|
4675
4713
|
"div",
|
|
4676
4714
|
{
|
|
4677
4715
|
className: g.className,
|
|
@@ -4682,56 +4720,56 @@ function qs({
|
|
|
4682
4720
|
pointerEvents: g.pointerEvents ?? "none",
|
|
4683
4721
|
...g.style
|
|
4684
4722
|
},
|
|
4685
|
-
children: g.render(
|
|
4723
|
+
children: g.render(Yn)
|
|
4686
4724
|
},
|
|
4687
4725
|
g.id ?? A
|
|
4688
4726
|
)) : null,
|
|
4689
|
-
e ? /* @__PURE__ */
|
|
4727
|
+
e ? /* @__PURE__ */ jt(
|
|
4690
4728
|
Fo,
|
|
4691
4729
|
{
|
|
4692
|
-
tool:
|
|
4693
|
-
enabled:
|
|
4730
|
+
tool: ot,
|
|
4731
|
+
enabled: ot !== "cursor",
|
|
4694
4732
|
imageWidth: e.width,
|
|
4695
4733
|
imageHeight: e.height,
|
|
4696
4734
|
imageMpp: e.mpp,
|
|
4697
4735
|
imageZoom: e.maxTierZoom,
|
|
4698
|
-
stampOptions:
|
|
4699
|
-
brushOptions:
|
|
4700
|
-
drawFillColor:
|
|
4701
|
-
projectorRef:
|
|
4736
|
+
stampOptions: Wt,
|
|
4737
|
+
brushOptions: ue,
|
|
4738
|
+
drawFillColor: le,
|
|
4739
|
+
projectorRef: $,
|
|
4702
4740
|
onBrushTap: Jr,
|
|
4703
4741
|
viewStateSignal: t,
|
|
4704
|
-
persistedRegions:
|
|
4705
|
-
patchRegions:
|
|
4706
|
-
regionStrokeStyle:
|
|
4707
|
-
regionStrokeHoverStyle:
|
|
4708
|
-
regionStrokeActiveStyle:
|
|
4742
|
+
persistedRegions: It,
|
|
4743
|
+
patchRegions: Lt,
|
|
4744
|
+
regionStrokeStyle: tt,
|
|
4745
|
+
regionStrokeHoverStyle: Vt,
|
|
4746
|
+
regionStrokeActiveStyle: $t,
|
|
4709
4747
|
patchStrokeStyle: be,
|
|
4710
|
-
resolveRegionStrokeStyle:
|
|
4711
|
-
resolveRegionLabelStyle:
|
|
4712
|
-
overlayShapes:
|
|
4713
|
-
hoveredRegionId:
|
|
4714
|
-
activeRegionId:
|
|
4715
|
-
regionLabelStyle:
|
|
4716
|
-
drawAreaTooltip:
|
|
4717
|
-
autoLiftRegionLabelAtMaxZoom:
|
|
4718
|
-
regionLabelAutoLiftOffsetPx:
|
|
4719
|
-
invalidateRef:
|
|
4720
|
-
onDrawComplete:
|
|
4721
|
-
onPatchComplete:
|
|
4748
|
+
resolveRegionStrokeStyle: Tt,
|
|
4749
|
+
resolveRegionLabelStyle: st,
|
|
4750
|
+
overlayShapes: R,
|
|
4751
|
+
hoveredRegionId: Re,
|
|
4752
|
+
activeRegionId: At,
|
|
4753
|
+
regionLabelStyle: et,
|
|
4754
|
+
drawAreaTooltip: W,
|
|
4755
|
+
autoLiftRegionLabelAtMaxZoom: ut,
|
|
4756
|
+
regionLabelAutoLiftOffsetPx: M,
|
|
4757
|
+
invalidateRef: Zt,
|
|
4758
|
+
onDrawComplete: ft,
|
|
4759
|
+
onPatchComplete: H
|
|
4722
4760
|
}
|
|
4723
4761
|
) : null,
|
|
4724
|
-
c ? /* @__PURE__ */
|
|
4725
|
-
e &&
|
|
4762
|
+
c ? /* @__PURE__ */ jt("pre", { "data-open-plant-debug-overlay": !0, style: Kt, children: qr }) : null,
|
|
4763
|
+
e && Ot && /* @__PURE__ */ jt(
|
|
4726
4764
|
Lo,
|
|
4727
4765
|
{
|
|
4728
4766
|
source: e,
|
|
4729
|
-
projectorRef:
|
|
4730
|
-
authToken:
|
|
4731
|
-
options:
|
|
4732
|
-
invalidateRef:
|
|
4733
|
-
className:
|
|
4734
|
-
style:
|
|
4767
|
+
projectorRef: $,
|
|
4768
|
+
authToken: d,
|
|
4769
|
+
options: Ct,
|
|
4770
|
+
invalidateRef: z,
|
|
4771
|
+
className: yt?.className,
|
|
4772
|
+
style: yt?.style
|
|
4735
4773
|
}
|
|
4736
4774
|
)
|
|
4737
4775
|
]
|
|
@@ -4750,12 +4788,12 @@ export {
|
|
|
4750
4788
|
Ys as buildTermPalette,
|
|
4751
4789
|
Ds as calcScaleLength,
|
|
4752
4790
|
_r as calcScaleResolution,
|
|
4753
|
-
|
|
4754
|
-
|
|
4791
|
+
ct as clamp,
|
|
4792
|
+
zt as closeRing,
|
|
4755
4793
|
Zo as computeRoiPointGroups,
|
|
4756
4794
|
cr as createCircle,
|
|
4757
|
-
|
|
4758
|
-
|
|
4795
|
+
An as createRectangle,
|
|
4796
|
+
cn as filterPointDataByPolygons,
|
|
4759
4797
|
Go as filterPointDataByPolygonsHybrid,
|
|
4760
4798
|
Ho as filterPointDataByPolygonsInWorker,
|
|
4761
4799
|
No as filterPointIndicesByPolygons,
|