open-plant 1.2.6 → 1.2.7
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/README.md +7 -0
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1222 -1195
- package/dist/index.js.map +1 -1
- package/dist/types/react/draw-layer.d.ts +12 -1
- package/dist/types/react/draw-layer.d.ts.map +1 -1
- package/dist/types/react/wsi-viewer-canvas.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var b = (e, t, n) =>
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useRef as
|
|
6
|
-
function
|
|
1
|
+
var rr = Object.defineProperty;
|
|
2
|
+
var ir = (e, t, n) => t in e ? rr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var b = (e, t, n) => ir(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { jsx as Ut, jsxs as mn, Fragment as or } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as j, useMemo as tt, useCallback as B, useEffect as X, useState as Jt } from "react";
|
|
6
|
+
function gn(e, t, n) {
|
|
7
7
|
const r = e.createShader(t);
|
|
8
8
|
if (!r)
|
|
9
9
|
throw new Error("Failed to create shader.");
|
|
@@ -13,8 +13,8 @@ function mn(e, t, n) {
|
|
|
13
13
|
}
|
|
14
14
|
return r;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const r =
|
|
16
|
+
function sr(e, t, n) {
|
|
17
|
+
const r = gn(e, e.VERTEX_SHADER, t), i = gn(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)) {
|
|
@@ -29,7 +29,7 @@ function _e(e, t, n) {
|
|
|
29
29
|
throw new Error(`Failed to get uniform location: ${n}`);
|
|
30
30
|
return r;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function ar(e) {
|
|
33
33
|
const t = e.getContext("webgl2", {
|
|
34
34
|
alpha: !1,
|
|
35
35
|
antialias: !1,
|
|
@@ -42,7 +42,7 @@ function sr(e) {
|
|
|
42
42
|
throw new Error("WebGL2 is not available.");
|
|
43
43
|
return t;
|
|
44
44
|
}
|
|
45
|
-
let
|
|
45
|
+
let ur = class {
|
|
46
46
|
constructor() {
|
|
47
47
|
b(this, "viewportWidth", 1);
|
|
48
48
|
b(this, "viewportHeight", 1);
|
|
@@ -82,7 +82,7 @@ let ar = class {
|
|
|
82
82
|
]);
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
const
|
|
85
|
+
const cr = `#version 300 es
|
|
86
86
|
precision highp float;
|
|
87
87
|
|
|
88
88
|
in vec2 aUnit;
|
|
@@ -102,7 +102,7 @@ void main() {
|
|
|
102
102
|
gl_Position = vec4(clip.xy, 0.0, 1.0);
|
|
103
103
|
vUv = aUv;
|
|
104
104
|
}
|
|
105
|
-
`,
|
|
105
|
+
`, lr = `#version 300 es
|
|
106
106
|
precision highp float;
|
|
107
107
|
|
|
108
108
|
in vec2 vUv;
|
|
@@ -114,11 +114,11 @@ void main() {
|
|
|
114
114
|
outColor = texture(uTexture, vUv);
|
|
115
115
|
}
|
|
116
116
|
`;
|
|
117
|
-
class
|
|
117
|
+
class hr {
|
|
118
118
|
constructor(t) {
|
|
119
119
|
b(this, "canvas");
|
|
120
120
|
b(this, "gl");
|
|
121
|
-
b(this, "camera", new
|
|
121
|
+
b(this, "camera", new ur());
|
|
122
122
|
b(this, "imageWidth");
|
|
123
123
|
b(this, "imageHeight");
|
|
124
124
|
b(this, "clearColor");
|
|
@@ -135,7 +135,7 @@ class lr {
|
|
|
135
135
|
b(this, "destroyed", !1);
|
|
136
136
|
b(this, "fitted", !1);
|
|
137
137
|
b(this, "controlledViewState", !1);
|
|
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 =
|
|
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 = ar(this.canvas), this.program = sr(this.gl, cr, lr);
|
|
139
139
|
const n = this.gl.createVertexArray(), r = this.gl.createBuffer();
|
|
140
140
|
if (!n || !r)
|
|
141
141
|
throw new Error("Failed to create WebGL buffers.");
|
|
@@ -310,16 +310,16 @@ class lr {
|
|
|
310
310
|
this.gl.deleteTexture(n.texture);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
const
|
|
313
|
+
const fr = 0.1, dr = 4e6, mr = 4096, gr = 64, Fn = 1e-6, pr = 24;
|
|
314
314
|
function Ne(e, t, n) {
|
|
315
315
|
return Math.max(t, Math.min(n, e));
|
|
316
316
|
}
|
|
317
|
-
function
|
|
317
|
+
function Wt(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);
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function br(e) {
|
|
323
323
|
if (!Array.isArray(e) || e.length === 0) return [];
|
|
324
324
|
const t = [];
|
|
325
325
|
for (const n of e) {
|
|
@@ -331,8 +331,8 @@ function pr(e) {
|
|
|
331
331
|
}
|
|
332
332
|
return t;
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
if (t <=
|
|
334
|
+
function wr(e, t, n) {
|
|
335
|
+
if (t <= Fn || n < 8) return [];
|
|
336
336
|
const r = [];
|
|
337
337
|
for (let i = 0; i <= n; i += 1) {
|
|
338
338
|
const o = i / n * Math.PI * 2;
|
|
@@ -341,39 +341,39 @@ function br(e, t, n) {
|
|
|
341
341
|
e[1] + Math.sin(o) * t
|
|
342
342
|
]);
|
|
343
343
|
}
|
|
344
|
-
return
|
|
344
|
+
return Wt(r);
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function Be(e, t) {
|
|
347
347
|
if (!e.length) return [];
|
|
348
348
|
let n = 1 / 0, r = 1 / 0, i = -1 / 0, o = -1 / 0;
|
|
349
349
|
for (const [a, u] of e)
|
|
350
350
|
a < n && (n = a), a > i && (i = a), u < r && (r = u), u > o && (o = u);
|
|
351
351
|
if (!Number.isFinite(n) || !Number.isFinite(r)) return [];
|
|
352
352
|
const s = Math.max(t, 1);
|
|
353
|
-
return
|
|
353
|
+
return Wt([
|
|
354
354
|
[n - s, r - s],
|
|
355
355
|
[i + s, r - s],
|
|
356
356
|
[i + s, o + s],
|
|
357
357
|
[n - s, o + s]
|
|
358
358
|
]);
|
|
359
359
|
}
|
|
360
|
-
function
|
|
360
|
+
function yr(e, t) {
|
|
361
361
|
let n = 1 / 0, r = 1 / 0, i = -1 / 0, o = -1 / 0;
|
|
362
362
|
for (const [a, u] of e)
|
|
363
363
|
a < n && (n = a), a > i && (i = a), u < r && (r = u), u > o && (o = u);
|
|
364
364
|
const s = Math.max(t, 1);
|
|
365
365
|
return [n - s, r - s, i + s, o + s];
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function xr(e, t, n) {
|
|
368
368
|
const r = Math.max(
|
|
369
|
-
|
|
369
|
+
fr,
|
|
370
370
|
Number(n.minRasterStep) || 0
|
|
371
371
|
), i = Math.max(
|
|
372
372
|
32768,
|
|
373
|
-
Math.floor(n.maxRasterPixels ||
|
|
373
|
+
Math.floor(n.maxRasterPixels || dr)
|
|
374
374
|
), o = Math.max(
|
|
375
375
|
256,
|
|
376
|
-
Math.floor(n.maxRasterSize ||
|
|
376
|
+
Math.floor(n.maxRasterSize || mr)
|
|
377
377
|
), s = Math.max(1e-3, e[2] - e[0]), a = Math.max(1e-3, e[3] - e[1]);
|
|
378
378
|
let u = Math.max(r, Number.EPSILON), c = 3, h = Math.ceil(s / u) + c * 2 + 1, g = Math.ceil(a / u) + c * 2 + 1;
|
|
379
379
|
for (; (h > o || g > o || h * g > i) && (u *= 1.15, h = Math.ceil(s / u) + c * 2 + 1, g = Math.ceil(a / u) + c * 2 + 1, !(u > Math.max(s, a))); )
|
|
@@ -387,7 +387,7 @@ function yr(e, t, n) {
|
|
|
387
387
|
height: g
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function Sr(e, t) {
|
|
391
391
|
if (typeof OffscreenCanvas < "u") {
|
|
392
392
|
const r = new OffscreenCanvas(e, t).getContext("2d", { willReadFrequently: !0 });
|
|
393
393
|
if (r) return r;
|
|
@@ -398,17 +398,17 @@ function xr(e, t) {
|
|
|
398
398
|
}
|
|
399
399
|
return null;
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function Tr(e, t) {
|
|
402
402
|
return [
|
|
403
403
|
(e[0] - t.minX) / t.step + t.padding,
|
|
404
404
|
(e[1] - t.minY) / t.step + t.padding
|
|
405
405
|
];
|
|
406
406
|
}
|
|
407
|
-
function
|
|
408
|
-
const r =
|
|
407
|
+
function Mr(e, t, n) {
|
|
408
|
+
const r = Sr(n.width, n.height);
|
|
409
409
|
if (!r) return new Uint8Array(0);
|
|
410
410
|
r.clearRect(0, 0, n.width, n.height), r.fillStyle = "#ffffff", r.strokeStyle = "#ffffff", r.lineCap = "round", r.lineJoin = "round", r.lineWidth = t * 2 / n.step;
|
|
411
|
-
const i = e.map((a) =>
|
|
411
|
+
const i = e.map((a) => Tr(a, n));
|
|
412
412
|
if (i.length <= 1) {
|
|
413
413
|
const a = i[0];
|
|
414
414
|
if (!a) return new Uint8Array(0);
|
|
@@ -421,10 +421,10 @@ function Tr(e, t, n) {
|
|
|
421
421
|
}
|
|
422
422
|
const o = r.getImageData(0, 0, n.width, n.height), s = new Uint8Array(n.width * n.height);
|
|
423
423
|
for (let a = 0; a < s.length; a += 1)
|
|
424
|
-
s[a] = o.data[a * 4 + 3] >=
|
|
424
|
+
s[a] = o.data[a * 4 + 3] >= pr ? 1 : 0;
|
|
425
425
|
return s;
|
|
426
426
|
}
|
|
427
|
-
function
|
|
427
|
+
function Ar(e, t, n) {
|
|
428
428
|
const r = [], i = t + 1, o = (a, u) => u * i + a, s = (a, u) => a >= 0 && u >= 0 && a < t && u < n && e[u * t + a] > 0;
|
|
429
429
|
for (let a = 0; a < n; a += 1)
|
|
430
430
|
for (let u = 0; u < t; u += 1)
|
|
@@ -447,11 +447,11 @@ function Mr(e, t, n) {
|
|
|
447
447
|
}));
|
|
448
448
|
return r;
|
|
449
449
|
}
|
|
450
|
-
function
|
|
450
|
+
function Pr(e, t) {
|
|
451
451
|
const n = (t - e + 4) % 4;
|
|
452
452
|
return n === 1 ? 0 : n === 0 ? 1 : n === 3 ? 2 : 3;
|
|
453
453
|
}
|
|
454
|
-
function
|
|
454
|
+
function Er(e) {
|
|
455
455
|
if (!e.length) return [];
|
|
456
456
|
const t = /* @__PURE__ */ new Map();
|
|
457
457
|
for (let i = 0; i < e.length; i += 1) {
|
|
@@ -470,22 +470,22 @@ function Pr(e) {
|
|
|
470
470
|
for (; a !== s && h < g; ) {
|
|
471
471
|
const d = t.get(a);
|
|
472
472
|
if (!d || d.length === 0) break;
|
|
473
|
-
let
|
|
474
|
-
for (const
|
|
475
|
-
if (n[
|
|
476
|
-
const
|
|
477
|
-
|
|
473
|
+
let p = -1, x = 1 / 0;
|
|
474
|
+
for (const P of d) {
|
|
475
|
+
if (n[P]) continue;
|
|
476
|
+
const k = e[P], C = Pr(u, k.dir);
|
|
477
|
+
C < x && (x = C, p = P);
|
|
478
478
|
}
|
|
479
|
-
if (
|
|
480
|
-
n[
|
|
481
|
-
const
|
|
482
|
-
a =
|
|
479
|
+
if (p < 0) break;
|
|
480
|
+
n[p] = 1;
|
|
481
|
+
const S = e[p];
|
|
482
|
+
a = S.end, u = S.dir, c.push(a), h += 1;
|
|
483
483
|
}
|
|
484
484
|
c.length >= 4 && c[0] === c[c.length - 1] && r.push(c);
|
|
485
485
|
}
|
|
486
486
|
return r;
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function Rr(e, t, n) {
|
|
489
489
|
const r = t + 1, i = [];
|
|
490
490
|
for (const o of e) {
|
|
491
491
|
const s = o % r, a = Math.floor(o / r);
|
|
@@ -494,9 +494,9 @@ function vr(e, t, n) {
|
|
|
494
494
|
n.minY + (a - n.padding) * n.step
|
|
495
495
|
]);
|
|
496
496
|
}
|
|
497
|
-
return
|
|
497
|
+
return Wt(i);
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function vr(e) {
|
|
500
500
|
if (e.length < 4) return 0;
|
|
501
501
|
let t = 0;
|
|
502
502
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
@@ -505,17 +505,17 @@ function Rr(e) {
|
|
|
505
505
|
}
|
|
506
506
|
return t * 0.5;
|
|
507
507
|
}
|
|
508
|
-
function
|
|
509
|
-
const n =
|
|
508
|
+
function Cr(e, t = 1e-9) {
|
|
509
|
+
const n = Wt(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], u = (s[0] - o[0]) * (a[1] - s[1]) - (s[1] - o[1]) * (a[0] - s[0]);
|
|
514
514
|
Math.abs(u) <= t || r.push(s);
|
|
515
515
|
}
|
|
516
|
-
return r.push(r[0]),
|
|
516
|
+
return r.push(r[0]), Wt(r);
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function Ir(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
521
|
const g = e[0] - t[0], d = e[1] - t[1];
|
|
@@ -528,7 +528,7 @@ function Cr(e, t, n) {
|
|
|
528
528
|
), a = t[0] + r * s, u = t[1] + i * s, c = e[0] - a, h = e[1] - u;
|
|
529
529
|
return c * c + h * h;
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function _r(e, t) {
|
|
532
532
|
if (e.length <= 2 || t <= 0) return e.slice();
|
|
533
533
|
const n = new Uint8Array(e.length);
|
|
534
534
|
n[0] = 1, n[e.length - 1] = 1;
|
|
@@ -540,7 +540,7 @@ function Ir(e, t) {
|
|
|
540
540
|
if (u - a <= 1) continue;
|
|
541
541
|
let c = 0, h = -1;
|
|
542
542
|
for (let g = a + 1; g < u; g += 1) {
|
|
543
|
-
const d =
|
|
543
|
+
const d = Ir(e[g], e[a], e[u]);
|
|
544
544
|
d > c && (c = d, h = g);
|
|
545
545
|
}
|
|
546
546
|
h >= 0 && c > r && (n[h] = 1, i.push([a, h], [h, u]));
|
|
@@ -550,14 +550,14 @@ function Ir(e, t) {
|
|
|
550
550
|
n[s] && o.push(e[s]);
|
|
551
551
|
return o;
|
|
552
552
|
}
|
|
553
|
-
function
|
|
554
|
-
const n =
|
|
553
|
+
function Br(e, t) {
|
|
554
|
+
const n = Wt(e);
|
|
555
555
|
if (n.length < 5 || t <= 0) return n;
|
|
556
|
-
const r = n.slice(0, -1), i =
|
|
557
|
-
return i.length < 3 ? n :
|
|
556
|
+
const r = n.slice(0, -1), i = _r(r, t);
|
|
557
|
+
return i.length < 3 ? n : Wt(i);
|
|
558
558
|
}
|
|
559
559
|
function ie(e, t) {
|
|
560
|
-
return t ?
|
|
560
|
+
return t ? Wt(
|
|
561
561
|
e.map(([n, r]) => [
|
|
562
562
|
Ne(n, t[0], t[2]),
|
|
563
563
|
Ne(r, t[1], t[3])
|
|
@@ -565,47 +565,47 @@ function ie(e, t) {
|
|
|
565
565
|
) : e;
|
|
566
566
|
}
|
|
567
567
|
function Fr(e, t) {
|
|
568
|
-
const n =
|
|
568
|
+
const n = br(e), r = Math.max(Fn, Number(t.radius) || 0);
|
|
569
569
|
if (n.length === 0 || !Number.isFinite(r)) return [];
|
|
570
|
-
const i = Math.max(12, Math.floor(t.circleSides ||
|
|
570
|
+
const i = Math.max(12, Math.floor(t.circleSides || gr));
|
|
571
571
|
if (n.length === 1)
|
|
572
572
|
return ie(
|
|
573
|
-
|
|
573
|
+
wr(n[0], r, i),
|
|
574
574
|
t.clipBounds
|
|
575
575
|
);
|
|
576
|
-
const o =
|
|
576
|
+
const o = yr(n, r), s = xr(o, r, t), a = Mr(n, r, s);
|
|
577
577
|
if (!a.length)
|
|
578
|
-
return ie(
|
|
579
|
-
const u =
|
|
578
|
+
return ie(Be(n, r), t.clipBounds);
|
|
579
|
+
const u = Ar(a, s.width, s.height), c = Er(u);
|
|
580
580
|
if (!c.length)
|
|
581
|
-
return ie(
|
|
581
|
+
return ie(Be(n, r), t.clipBounds);
|
|
582
582
|
let h = [], g = 0;
|
|
583
|
-
for (const
|
|
584
|
-
const
|
|
585
|
-
|
|
583
|
+
for (const x of c) {
|
|
584
|
+
const S = Rr(x, s.width, s), P = Math.abs(vr(S));
|
|
585
|
+
P <= g || (g = P, h = S);
|
|
586
586
|
}
|
|
587
587
|
if (!h.length)
|
|
588
|
-
return ie(
|
|
589
|
-
const d = typeof t.simplifyTolerance == "number" && Number.isFinite(t.simplifyTolerance) ? Math.max(0, t.simplifyTolerance) : s.step * 0.2,
|
|
590
|
-
|
|
588
|
+
return ie(Be(n, r), t.clipBounds);
|
|
589
|
+
const d = typeof t.simplifyTolerance == "number" && Number.isFinite(t.simplifyTolerance) ? Math.max(0, t.simplifyTolerance) : s.step * 0.2, p = Br(
|
|
590
|
+
Cr(h, s.step * 1e-3),
|
|
591
591
|
d
|
|
592
592
|
);
|
|
593
|
-
return ie(
|
|
593
|
+
return ie(p, t.clipBounds);
|
|
594
594
|
}
|
|
595
|
-
const
|
|
595
|
+
const Un = [
|
|
596
596
|
160,
|
|
597
597
|
160,
|
|
598
598
|
160,
|
|
599
599
|
255
|
|
600
600
|
];
|
|
601
|
-
function
|
|
601
|
+
function it(e, t, n) {
|
|
602
602
|
return Math.max(t, Math.min(n, e));
|
|
603
603
|
}
|
|
604
604
|
function zn(e, t, n) {
|
|
605
605
|
const r = Number(e), i = Number(t), o = Number(n);
|
|
606
606
|
return !Number.isFinite(r) || r <= 0 ? 1 : !Number.isFinite(i) || !Number.isFinite(o) ? r : Math.pow(2, i - o) * r;
|
|
607
607
|
}
|
|
608
|
-
function
|
|
608
|
+
function co(e, t, n) {
|
|
609
609
|
let i = 100 * zn(e, t, n);
|
|
610
610
|
if (Number(e)) {
|
|
611
611
|
let o = "μm";
|
|
@@ -613,10 +613,10 @@ function io(e, t, n) {
|
|
|
613
613
|
}
|
|
614
614
|
return `${Math.round(i * 1e3) / 1e3} pixels`;
|
|
615
615
|
}
|
|
616
|
-
function
|
|
616
|
+
function lo(e, t) {
|
|
617
617
|
return !e && !t ? !0 : !e || !t ? !1 : Math.abs((e.zoom ?? 0) - (t.zoom ?? 0)) < 1e-6 && Math.abs((e.offsetX ?? 0) - (t.offsetX ?? 0)) < 1e-6 && Math.abs((e.offsetY ?? 0) - (t.offsetY ?? 0)) < 1e-6 && Math.abs((e.rotationDeg ?? 0) - (t.rotationDeg ?? 0)) < 1e-6;
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function ho(e) {
|
|
620
620
|
const t = String(e ?? "").trim();
|
|
621
621
|
if (!t) return "";
|
|
622
622
|
if (/^bearer\s+/i.test(t)) {
|
|
@@ -627,13 +627,13 @@ function so(e) {
|
|
|
627
627
|
}
|
|
628
628
|
function Ur(e) {
|
|
629
629
|
const n = String(e ?? "").trim().match(/^#?([0-9a-fA-F]{6})$/);
|
|
630
|
-
if (!n) return [...
|
|
630
|
+
if (!n) return [...Un];
|
|
631
631
|
const r = Number.parseInt(n[1], 16);
|
|
632
632
|
return [r >> 16 & 255, r >> 8 & 255, r & 255, 255];
|
|
633
633
|
}
|
|
634
|
-
function
|
|
634
|
+
function fo(e) {
|
|
635
635
|
const t = [
|
|
636
|
-
[...
|
|
636
|
+
[...Un]
|
|
637
637
|
], n = /* @__PURE__ */ new Map();
|
|
638
638
|
for (const i of e ?? []) {
|
|
639
639
|
const o = String(i?.termId ?? "");
|
|
@@ -644,7 +644,7 @@ function ao(e) {
|
|
|
644
644
|
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];
|
|
645
645
|
return { colors: r, termToPaletteIndex: n };
|
|
646
646
|
}
|
|
647
|
-
function
|
|
647
|
+
function pn(e, t, n) {
|
|
648
648
|
const r = e.createShader(e.VERTEX_SHADER), i = e.createShader(e.FRAGMENT_SHADER);
|
|
649
649
|
if (!r || !i)
|
|
650
650
|
throw new Error("Shader allocation failed");
|
|
@@ -659,7 +659,7 @@ function gn(e, t, n) {
|
|
|
659
659
|
throw new Error(e.getProgramInfoLog(o) || "program link failed");
|
|
660
660
|
return o;
|
|
661
661
|
}
|
|
662
|
-
const
|
|
662
|
+
const zr = "rgba(255, 77, 79, 0.16)", Lr = 3, Dr = 2, Ln = 96, Nr = 1, bn = [], Pe = [], wn = 1e3, Dn = 2, Nn = 2, kr = 4096, Xr = 0.2, Yr = 1.12, Wr = 0.89, Vr = 32, Or = "#000000", Gr = 0.1, qr = "#FFCF00", $r = "#FF0000", Hr = 1.5, yn = [2, 2], Zr = 1, Kr = 0.25, jr = 4, Jr = 1.5, Xt = {
|
|
663
663
|
color: "#ff4d4f",
|
|
664
664
|
width: 2,
|
|
665
665
|
lineJoin: "round",
|
|
@@ -668,7 +668,7 @@ const Br = "rgba(255, 77, 79, 0.16)", zr = 3, Lr = 2, Ln = 96, Nr = 1, pn = [],
|
|
|
668
668
|
shadowBlur: 0,
|
|
669
669
|
shadowOffsetX: 0,
|
|
670
670
|
shadowOffsetY: 0
|
|
671
|
-
},
|
|
671
|
+
}, Qr = {
|
|
672
672
|
color: "#4cc9f0",
|
|
673
673
|
width: 2,
|
|
674
674
|
lineDash: [10, 8],
|
|
@@ -691,76 +691,81 @@ const Br = "rgba(255, 77, 79, 0.16)", zr = 3, Lr = 2, Ln = 96, Nr = 1, pn = [],
|
|
|
691
691
|
offsetY: 10,
|
|
692
692
|
borderRadius: 3
|
|
693
693
|
};
|
|
694
|
-
function
|
|
694
|
+
function ne(e, t, n) {
|
|
695
695
|
return Math.max(t, Math.min(n, e));
|
|
696
696
|
}
|
|
697
|
-
function
|
|
697
|
+
function we(e) {
|
|
698
698
|
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";
|
|
699
699
|
}
|
|
700
700
|
function se(e, t) {
|
|
701
701
|
return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? t : e;
|
|
702
702
|
}
|
|
703
|
-
function
|
|
703
|
+
function ti(e) {
|
|
704
704
|
return {
|
|
705
|
-
rectangleAreaMm2: se(e?.rectangleAreaMm2,
|
|
706
|
-
circleAreaMm2: se(e?.circleAreaMm2,
|
|
707
|
-
rectanglePixelSize: se(e?.rectanglePixelSize,
|
|
705
|
+
rectangleAreaMm2: se(e?.rectangleAreaMm2, Dn),
|
|
706
|
+
circleAreaMm2: se(e?.circleAreaMm2, Nn),
|
|
707
|
+
rectanglePixelSize: se(e?.rectanglePixelSize, kr)
|
|
708
708
|
};
|
|
709
709
|
}
|
|
710
|
-
function
|
|
711
|
-
return typeof e != "number" || !Number.isFinite(e) ? t :
|
|
710
|
+
function ei(e, t) {
|
|
711
|
+
return typeof e != "number" || !Number.isFinite(e) ? t : ne(e, 0, 1);
|
|
712
712
|
}
|
|
713
|
-
function
|
|
714
|
-
if (!Array.isArray(e)) return
|
|
713
|
+
function ni(e) {
|
|
714
|
+
if (!Array.isArray(e)) return yn;
|
|
715
715
|
const t = e.filter((n) => Number.isFinite(n) && n >= 0);
|
|
716
|
-
return t.length > 0 ? t :
|
|
716
|
+
return t.length > 0 ? t : yn;
|
|
717
|
+
}
|
|
718
|
+
function ri(e) {
|
|
719
|
+
return typeof e != "number" || !Number.isFinite(e) ? Zr : ne(e, Kr, jr);
|
|
717
720
|
}
|
|
718
|
-
function
|
|
719
|
-
const t = se(e?.radius,
|
|
721
|
+
function ii(e) {
|
|
722
|
+
const t = se(e?.radius, Vr), n = se(e?.cursorLineWidth, Hr), r = ri(e?.edgeDetail);
|
|
720
723
|
return {
|
|
721
724
|
radius: t,
|
|
725
|
+
edgeDetail: r,
|
|
726
|
+
clickSelectRoi: e?.clickSelectRoi === !0,
|
|
722
727
|
fillColor: e?.fillColor || Or,
|
|
723
|
-
fillOpacity:
|
|
724
|
-
cursorColor: e?.cursorColor ||
|
|
725
|
-
cursorActiveColor: e?.cursorActiveColor ||
|
|
728
|
+
fillOpacity: ei(e?.fillOpacity, Gr),
|
|
729
|
+
cursorColor: e?.cursorColor || qr,
|
|
730
|
+
cursorActiveColor: e?.cursorActiveColor || $r,
|
|
726
731
|
cursorLineWidth: n,
|
|
727
|
-
cursorLineDash:
|
|
732
|
+
cursorLineDash: ni(e?.cursorLineDash)
|
|
728
733
|
};
|
|
729
734
|
}
|
|
730
|
-
function
|
|
731
|
-
return e *
|
|
735
|
+
function oi(e) {
|
|
736
|
+
return e * wn * wn;
|
|
732
737
|
}
|
|
733
|
-
function
|
|
734
|
-
return !e || !Number.isFinite(t) || t <= 0 ? [] :
|
|
738
|
+
function xn(e, t) {
|
|
739
|
+
return !e || !Number.isFinite(t) || t <= 0 ? [] : Rt([
|
|
735
740
|
[e[0] - t, e[1] - t],
|
|
736
741
|
[e[0] + t, e[1] - t],
|
|
737
742
|
[e[0] + t, e[1] + t],
|
|
738
743
|
[e[0] - t, e[1] + t]
|
|
739
744
|
]);
|
|
740
745
|
}
|
|
741
|
-
function
|
|
746
|
+
function si(e, t, n = Ln) {
|
|
742
747
|
if (!e || !Number.isFinite(t) || t <= 0) return [];
|
|
743
748
|
const r = [];
|
|
744
749
|
for (let i = 0; i <= n; i += 1) {
|
|
745
750
|
const o = i / n * Math.PI * 2;
|
|
746
751
|
r.push([e[0] + Math.cos(o) * t, e[1] + Math.sin(o) * t]);
|
|
747
752
|
}
|
|
748
|
-
return
|
|
753
|
+
return Rt(r);
|
|
749
754
|
}
|
|
750
|
-
function
|
|
755
|
+
function Rt(e) {
|
|
751
756
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
752
757
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
753
758
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
754
759
|
}
|
|
755
|
-
function
|
|
756
|
-
return !e || !t ? [] :
|
|
760
|
+
function Sn(e, t) {
|
|
761
|
+
return !e || !t ? [] : Rt([
|
|
757
762
|
[e[0], e[1]],
|
|
758
763
|
[t[0], e[1]],
|
|
759
764
|
[t[0], t[1]],
|
|
760
765
|
[e[0], t[1]]
|
|
761
766
|
]);
|
|
762
767
|
}
|
|
763
|
-
function
|
|
768
|
+
function Tn(e, t, n = Ln) {
|
|
764
769
|
if (!e || !t) return [];
|
|
765
770
|
const r = (e[0] + t[0]) * 0.5, i = (e[1] + t[1]) * 0.5, o = Math.hypot(t[0] - e[0], t[1] - e[1]) * 0.5;
|
|
766
771
|
if (o < 1) return [];
|
|
@@ -769,9 +774,9 @@ function Sn(e, t, n = Ln) {
|
|
|
769
774
|
const u = a / n * Math.PI * 2;
|
|
770
775
|
s.push([r + Math.cos(u) * o, i + Math.sin(u) * o]);
|
|
771
776
|
}
|
|
772
|
-
return
|
|
777
|
+
return Rt(s);
|
|
773
778
|
}
|
|
774
|
-
function
|
|
779
|
+
function ke(e) {
|
|
775
780
|
if (!Array.isArray(e) || e.length < 4) return 0;
|
|
776
781
|
let t = 0;
|
|
777
782
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
@@ -780,17 +785,17 @@ function De(e) {
|
|
|
780
785
|
}
|
|
781
786
|
return Math.abs(t * 0.5);
|
|
782
787
|
}
|
|
783
|
-
function
|
|
788
|
+
function Mn(e) {
|
|
784
789
|
if (!Array.isArray(e) || e.length === 0) return [0, 0, 0, 0];
|
|
785
790
|
let t = 1 / 0, n = 1 / 0, r = -1 / 0, i = -1 / 0;
|
|
786
791
|
for (const [o, s] of e)
|
|
787
792
|
o < t && (t = o), o > r && (r = o), s < n && (n = s), s > i && (i = s);
|
|
788
793
|
return [t, n, r, i];
|
|
789
794
|
}
|
|
790
|
-
function
|
|
791
|
-
return Array.isArray(e) && e.length >= 4 &&
|
|
795
|
+
function An(e) {
|
|
796
|
+
return Array.isArray(e) && e.length >= 4 && ke(e) > Nr;
|
|
792
797
|
}
|
|
793
|
-
function
|
|
798
|
+
function Xe(e, t, n = !1) {
|
|
794
799
|
if (t.length !== 0) {
|
|
795
800
|
e.moveTo(t[0][0], t[0][1]);
|
|
796
801
|
for (let r = 1; r < t.length; r += 1)
|
|
@@ -798,18 +803,18 @@ function ke(e, t, n = !1) {
|
|
|
798
803
|
n && e.closePath();
|
|
799
804
|
}
|
|
800
805
|
}
|
|
801
|
-
function
|
|
802
|
-
t.length !== 0 && (e.beginPath(),
|
|
806
|
+
function Qt(e, t, n, r = !1, i = !1) {
|
|
807
|
+
t.length !== 0 && (e.beginPath(), Xe(e, t, r), i && r && (e.fillStyle = zr, 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(Pe), e.shadowColor = "rgba(0, 0, 0, 0)", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0);
|
|
803
808
|
}
|
|
804
809
|
function kn(e) {
|
|
805
|
-
const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((s) => Number.isFinite(s) && s >= 0) :
|
|
810
|
+
const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((s) => Number.isFinite(s) && s >= 0) : Pe, n = typeof e?.width == "number" && Number.isFinite(e.width) ? Math.max(0, e.width) : Xt.width, r = typeof e?.shadowBlur == "number" && Number.isFinite(e.shadowBlur) ? Math.max(0, e.shadowBlur) : Xt.shadowBlur, i = typeof e?.shadowOffsetX == "number" && Number.isFinite(e.shadowOffsetX) ? e.shadowOffsetX : Xt.shadowOffsetX, o = typeof e?.shadowOffsetY == "number" && Number.isFinite(e.shadowOffsetY) ? e.shadowOffsetY : Xt.shadowOffsetY;
|
|
806
811
|
return {
|
|
807
|
-
color: e?.color ||
|
|
812
|
+
color: e?.color || Xt.color,
|
|
808
813
|
width: n,
|
|
809
|
-
lineDash: t.length ? t :
|
|
810
|
-
lineJoin: e?.lineJoin ||
|
|
811
|
-
lineCap: e?.lineCap ||
|
|
812
|
-
shadowColor: e?.shadowColor ||
|
|
814
|
+
lineDash: t.length ? t : Pe,
|
|
815
|
+
lineJoin: e?.lineJoin || Xt.lineJoin,
|
|
816
|
+
lineCap: e?.lineCap || Xt.lineCap,
|
|
817
|
+
shadowColor: e?.shadowColor || Xt.shadowColor,
|
|
813
818
|
shadowBlur: r,
|
|
814
819
|
shadowOffsetX: i,
|
|
815
820
|
shadowOffsetY: o
|
|
@@ -828,25 +833,25 @@ function oe(e, t) {
|
|
|
828
833
|
shadowOffsetY: t.shadowOffsetY ?? e.shadowOffsetY
|
|
829
834
|
}) : e;
|
|
830
835
|
}
|
|
831
|
-
function
|
|
836
|
+
function Pn(e, t) {
|
|
832
837
|
return e == null || t === null || t === void 0 ? !1 : String(e) === String(t);
|
|
833
838
|
}
|
|
834
|
-
function
|
|
839
|
+
function ai(e) {
|
|
835
840
|
const t = e[0];
|
|
836
841
|
return Array.isArray(t) && Array.isArray(t[0]);
|
|
837
842
|
}
|
|
838
|
-
function
|
|
843
|
+
function En(e) {
|
|
839
844
|
return typeof e == "number" && Number.isFinite(e);
|
|
840
845
|
}
|
|
841
|
-
function
|
|
842
|
-
return Array.isArray(e) && e.length >= 2 &&
|
|
846
|
+
function ui(e) {
|
|
847
|
+
return Array.isArray(e) && e.length >= 2 && En(e[0]) && En(e[1]);
|
|
843
848
|
}
|
|
844
|
-
function
|
|
845
|
-
return Array.isArray(e) && e.length >= 2 && e.every((t) =>
|
|
849
|
+
function ci(e) {
|
|
850
|
+
return Array.isArray(e) && e.length >= 2 && e.every((t) => ui(t));
|
|
846
851
|
}
|
|
847
852
|
function Xn(e, t) {
|
|
848
853
|
if (!(!Array.isArray(e) || e.length === 0)) {
|
|
849
|
-
if (
|
|
854
|
+
if (ci(e)) {
|
|
850
855
|
t.push(e.map(([n, r]) => [n, r]));
|
|
851
856
|
return;
|
|
852
857
|
}
|
|
@@ -854,26 +859,26 @@ function Xn(e, t) {
|
|
|
854
859
|
Xn(n, t);
|
|
855
860
|
}
|
|
856
861
|
}
|
|
857
|
-
function
|
|
862
|
+
function Rn(e, t) {
|
|
858
863
|
const n = [];
|
|
859
864
|
Xn(e, n);
|
|
860
865
|
const r = [];
|
|
861
866
|
for (const i of n) {
|
|
862
867
|
if (i.length < 2) continue;
|
|
863
|
-
const o = t ?
|
|
868
|
+
const o = t ? Rt(i) : i;
|
|
864
869
|
o.length >= (t ? 4 : 2) && r.push(o);
|
|
865
870
|
}
|
|
866
871
|
return r;
|
|
867
872
|
}
|
|
868
|
-
function
|
|
873
|
+
function li(e, t, n, r) {
|
|
869
874
|
if (!(t.length < 4 || n.length === 0)) {
|
|
870
|
-
e.save(), e.beginPath(),
|
|
875
|
+
e.save(), e.beginPath(), Xe(e, t, !0);
|
|
871
876
|
for (const i of n)
|
|
872
|
-
i.length < 4 ||
|
|
877
|
+
i.length < 4 || Xe(e, i, !0);
|
|
873
878
|
e.fillStyle = r, e.fill("evenodd"), e.restore();
|
|
874
879
|
}
|
|
875
880
|
}
|
|
876
|
-
function
|
|
881
|
+
function hi(e) {
|
|
877
882
|
const t = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) : Et.paddingX, n = typeof e?.paddingY == "number" && Number.isFinite(e.paddingY) ? Math.max(0, e.paddingY) : Et.paddingY, r = typeof e?.fontSize == "number" && Number.isFinite(e.fontSize) ? Math.max(8, e.fontSize) : Et.fontSize, i = typeof e?.borderWidth == "number" && Number.isFinite(e.borderWidth) ? Math.max(0, e.borderWidth) : Et.borderWidth, o = typeof e?.offsetY == "number" && Number.isFinite(e.offsetY) ? e.offsetY : Et.offsetY, s = typeof e?.borderRadius == "number" && Number.isFinite(e.borderRadius) ? Math.max(0, e.borderRadius) : Et.borderRadius;
|
|
878
883
|
return {
|
|
879
884
|
fontFamily: e?.fontFamily || Et.fontFamily,
|
|
@@ -889,11 +894,11 @@ function si(e) {
|
|
|
889
894
|
borderRadius: s
|
|
890
895
|
};
|
|
891
896
|
}
|
|
892
|
-
function
|
|
897
|
+
function fi(e, t, n, r, i, o) {
|
|
893
898
|
const s = Math.max(0, Math.min(o, r * 0.5, i * 0.5));
|
|
894
899
|
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();
|
|
895
900
|
}
|
|
896
|
-
function
|
|
901
|
+
function di(e) {
|
|
897
902
|
if (!e.length) return null;
|
|
898
903
|
let t = 1 / 0;
|
|
899
904
|
for (const i of e)
|
|
@@ -904,22 +909,22 @@ function ui(e) {
|
|
|
904
909
|
Math.abs(i[1] - t) > 0.5 || (i[0] < n && (n = i[0]), i[0] > r && (r = i[0]));
|
|
905
910
|
return !Number.isFinite(n) || !Number.isFinite(r) ? null : [(n + r) * 0.5, t];
|
|
906
911
|
}
|
|
907
|
-
function
|
|
912
|
+
function mi(e, t, n, r, i, o) {
|
|
908
913
|
const s = t.trim();
|
|
909
914
|
if (!s) return;
|
|
910
915
|
e.save(), e.font = `${o.fontWeight} ${o.fontSize}px ${o.fontFamily}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
911
|
-
const u = e.measureText(s).width + o.paddingX * 2, c = o.fontSize + o.paddingY * 2, h =
|
|
912
|
-
e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth,
|
|
916
|
+
const u = e.measureText(s).width + o.paddingX * 2, c = o.fontSize + o.paddingY * 2, h = ne(n[0], u * 0.5 + 1, r - u * 0.5 - 1), g = ne(n[1] - o.offsetY, c * 0.5 + 1, i - c * 0.5 - 1), d = h - u * 0.5, p = g - c * 0.5;
|
|
917
|
+
e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth, fi(e, d, p, u, c, o.borderRadius), e.fill(), o.borderWidth > 0 && e.stroke(), e.fillStyle = o.textColor, e.fillText(s, h, g + 0.5), e.restore();
|
|
913
918
|
}
|
|
914
|
-
function
|
|
915
|
-
return [
|
|
919
|
+
function Fe(e, t, n) {
|
|
920
|
+
return [ne(e[0], 0, t), ne(e[1], 0, n)];
|
|
916
921
|
}
|
|
917
|
-
function
|
|
922
|
+
function te(e) {
|
|
918
923
|
if (!Array.isArray(e) || e.length < 2) return null;
|
|
919
924
|
const t = Number(e[0]), n = Number(e[1]);
|
|
920
925
|
return !Number.isFinite(t) || !Number.isFinite(n) ? null : [t, n];
|
|
921
926
|
}
|
|
922
|
-
function
|
|
927
|
+
function gi({
|
|
923
928
|
tool: e,
|
|
924
929
|
imageWidth: t,
|
|
925
930
|
imageHeight: n,
|
|
@@ -928,27 +933,28 @@ function li({
|
|
|
928
933
|
stampOptions: o,
|
|
929
934
|
brushOptions: s,
|
|
930
935
|
projectorRef: a,
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
936
|
+
onBrushTap: u,
|
|
937
|
+
onDrawComplete: c,
|
|
938
|
+
onPatchComplete: h,
|
|
939
|
+
enabled: g,
|
|
940
|
+
viewStateSignal: d,
|
|
941
|
+
persistedRegions: p,
|
|
942
|
+
patchRegions: x,
|
|
943
|
+
persistedPolygons: S,
|
|
944
|
+
regionStrokeStyle: P,
|
|
945
|
+
regionStrokeHoverStyle: k,
|
|
946
|
+
regionStrokeActiveStyle: C,
|
|
947
|
+
patchStrokeStyle: E,
|
|
948
|
+
resolveRegionStrokeStyle: D,
|
|
949
|
+
overlayShapes: J,
|
|
950
|
+
hoveredRegionId: ft = null,
|
|
951
|
+
activeRegionId: at = null,
|
|
952
|
+
regionLabelStyle: $,
|
|
953
|
+
invalidateRef: ht,
|
|
954
|
+
className: vt,
|
|
955
|
+
style: Ot
|
|
950
956
|
}) {
|
|
951
|
-
const
|
|
957
|
+
const K = j(null), Ct = j(!1), zt = j(/* @__PURE__ */ new Map()), Kt = j(e), dt = j({
|
|
952
958
|
isDrawing: !1,
|
|
953
959
|
pointerId: null,
|
|
954
960
|
start: null,
|
|
@@ -956,10 +962,10 @@ function li({
|
|
|
956
962
|
cursor: null,
|
|
957
963
|
points: [],
|
|
958
964
|
stampCenter: null
|
|
959
|
-
}),
|
|
965
|
+
}), Q = g ?? e !== "cursor", M = tt(() => p && p.length > 0 ? p : !S || S.length === 0 ? bn : S.map((l, f) => ({
|
|
960
966
|
id: f,
|
|
961
967
|
coordinates: l
|
|
962
|
-
})), [
|
|
968
|
+
})), [p, S]), I = tt(() => x ?? bn, [x]), A = tt(() => kn(P), [P]), L = tt(() => oe(A, k), [A, k]), Z = tt(() => oe(A, C), [A, C]), et = tt(() => oe(Qr, E), [E]), mt = tt(() => hi($), [$]), yt = tt(() => ti(o), [o]), U = tt(() => ii(s), [s]), At = tt(
|
|
963
969
|
() => ({
|
|
964
970
|
position: "absolute",
|
|
965
971
|
inset: 0,
|
|
@@ -968,426 +974,432 @@ function li({
|
|
|
968
974
|
height: "100%",
|
|
969
975
|
display: "block",
|
|
970
976
|
touchAction: "none",
|
|
971
|
-
pointerEvents:
|
|
972
|
-
cursor:
|
|
973
|
-
...
|
|
977
|
+
pointerEvents: Q ? "auto" : "none",
|
|
978
|
+
cursor: Q ? e === "brush" ? "none" : "crosshair" : "default",
|
|
979
|
+
...Ot
|
|
974
980
|
}),
|
|
975
|
-
[
|
|
976
|
-
),
|
|
977
|
-
const l =
|
|
981
|
+
[Q, e, Ot]
|
|
982
|
+
), gt = B(() => {
|
|
983
|
+
const l = K.current;
|
|
978
984
|
if (!l) return;
|
|
979
|
-
const f = l.getBoundingClientRect(),
|
|
980
|
-
(l.width !==
|
|
981
|
-
}, []),
|
|
985
|
+
const f = l.getBoundingClientRect(), w = Math.max(1, window.devicePixelRatio || 1), y = Math.max(1, Math.round(f.width * w)), R = Math.max(1, Math.round(f.height * w));
|
|
986
|
+
(l.width !== y || l.height !== R) && (l.width = y, l.height = R);
|
|
987
|
+
}, []), N = B(
|
|
982
988
|
(l) => {
|
|
983
989
|
const f = a.current;
|
|
984
990
|
if (!f || l.length === 0) return [];
|
|
985
|
-
const
|
|
986
|
-
for (let
|
|
987
|
-
const
|
|
988
|
-
if (!
|
|
989
|
-
|
|
991
|
+
const w = new Array(l.length);
|
|
992
|
+
for (let y = 0; y < l.length; y += 1) {
|
|
993
|
+
const R = te(f.worldToScreen(l[y][0], l[y][1]));
|
|
994
|
+
if (!R) return [];
|
|
995
|
+
w[y] = R;
|
|
990
996
|
}
|
|
991
|
-
return
|
|
997
|
+
return w;
|
|
992
998
|
},
|
|
993
999
|
[a]
|
|
994
|
-
), G =
|
|
1000
|
+
), G = B(
|
|
995
1001
|
(l, f) => {
|
|
996
1002
|
if (!Number.isFinite(f) || f <= 0) return 0;
|
|
997
|
-
const
|
|
998
|
-
if (!
|
|
999
|
-
const
|
|
1000
|
-
return !
|
|
1003
|
+
const w = a.current;
|
|
1004
|
+
if (!w) return 0;
|
|
1005
|
+
const y = te(w.worldToScreen(l[0], l[1])), R = te(w.worldToScreen(l[0] + f, l[1]));
|
|
1006
|
+
return !y || !R ? 0 : Math.hypot(R[0] - y[0], R[1] - y[1]);
|
|
1001
1007
|
},
|
|
1002
1008
|
[a]
|
|
1003
|
-
),
|
|
1009
|
+
), ut = B(
|
|
1004
1010
|
(l) => {
|
|
1005
1011
|
if (!Number.isFinite(l) || l <= 0) return 0;
|
|
1006
|
-
const f = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1,
|
|
1007
|
-
return l /
|
|
1012
|
+
const f = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, w = typeof i == "number" && Number.isFinite(i) ? i : 0, y = a.current?.getViewState?.().zoom, R = typeof y == "number" && Number.isFinite(y) && y > 0 ? y : 1, v = w + Math.log2(R), Y = Math.max(1e-9, zn(f, w, v));
|
|
1013
|
+
return l / Y / R;
|
|
1008
1014
|
},
|
|
1009
1015
|
[r, i, a]
|
|
1010
|
-
),
|
|
1016
|
+
), nt = B(
|
|
1011
1017
|
(l, f) => {
|
|
1012
1018
|
if (!f) return [];
|
|
1013
|
-
let
|
|
1019
|
+
let w = 0;
|
|
1014
1020
|
if (l === "stamp-rectangle-4096px") {
|
|
1015
|
-
const
|
|
1016
|
-
return
|
|
1021
|
+
const v = yt.rectanglePixelSize * 0.5;
|
|
1022
|
+
return xn(f, v).map((V) => Fe(V, t, n));
|
|
1017
1023
|
}
|
|
1018
|
-
if (l === "stamp-rectangle" || l === "stamp-rectangle-2mm2" ?
|
|
1019
|
-
const
|
|
1020
|
-
let
|
|
1024
|
+
if (l === "stamp-rectangle" || l === "stamp-rectangle-2mm2" ? w = l === "stamp-rectangle-2mm2" ? Dn : yt.rectangleAreaMm2 : (l === "stamp-circle" || l === "stamp-circle-2mm2" || l === "stamp-circle-hpf-0.2mm2") && (w = l === "stamp-circle-hpf-0.2mm2" ? Xr : l === "stamp-circle-2mm2" ? Nn : yt.circleAreaMm2), !Number.isFinite(w) || w <= 0) return [];
|
|
1025
|
+
const y = oi(w);
|
|
1026
|
+
let R = [];
|
|
1021
1027
|
if (l === "stamp-rectangle" || l === "stamp-rectangle-2mm2") {
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1028
|
+
const v = ut(Math.sqrt(y) * 0.5);
|
|
1029
|
+
R = xn(f, v);
|
|
1024
1030
|
} else if (l === "stamp-circle" || l === "stamp-circle-2mm2" || l === "stamp-circle-hpf-0.2mm2") {
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1031
|
+
const v = ut(Math.sqrt(y / Math.PI));
|
|
1032
|
+
R = si(f, v);
|
|
1027
1033
|
}
|
|
1028
|
-
return
|
|
1034
|
+
return R.length ? R.map((v) => Fe(v, t, n)) : [];
|
|
1029
1035
|
},
|
|
1030
|
-
[
|
|
1031
|
-
),
|
|
1036
|
+
[ut, t, n, yt]
|
|
1037
|
+
), rt = B(() => {
|
|
1032
1038
|
const l = dt.current;
|
|
1033
|
-
return
|
|
1034
|
-
}, [e,
|
|
1039
|
+
return we(e) ? nt(e, l.stampCenter) : e === "brush" ? [] : l.isDrawing ? e === "freehand" ? l.points : e === "rectangle" ? Sn(l.start, l.current) : e === "circular" ? Tn(l.start, l.current) : [] : [];
|
|
1040
|
+
}, [e, nt]), q = B(
|
|
1035
1041
|
(l) => {
|
|
1036
1042
|
const f = dt.current;
|
|
1037
1043
|
if (!f.isDrawing || f.points.length === 0) return;
|
|
1038
|
-
const
|
|
1039
|
-
if (
|
|
1040
|
-
const
|
|
1041
|
-
if (!(!Number.isFinite(
|
|
1042
|
-
if (l.save(), l.globalAlpha =
|
|
1043
|
-
l.beginPath(), l.arc(
|
|
1044
|
+
const w = N(f.points);
|
|
1045
|
+
if (w.length === 0) return;
|
|
1046
|
+
const y = f.points[f.points.length - 1] ?? f.points[0], R = G(y, U.radius);
|
|
1047
|
+
if (!(!Number.isFinite(R) || R <= 0)) {
|
|
1048
|
+
if (l.save(), l.globalAlpha = U.fillOpacity, l.fillStyle = U.fillColor, l.strokeStyle = U.fillColor, l.lineCap = "round", l.lineJoin = "round", l.lineWidth = R * 2, w.length === 1)
|
|
1049
|
+
l.beginPath(), l.arc(w[0][0], w[0][1], R, 0, Math.PI * 2), l.fill();
|
|
1044
1050
|
else {
|
|
1045
|
-
l.beginPath(), l.moveTo(
|
|
1046
|
-
for (let
|
|
1047
|
-
l.lineTo(
|
|
1051
|
+
l.beginPath(), l.moveTo(w[0][0], w[0][1]);
|
|
1052
|
+
for (let v = 1; v < w.length; v += 1)
|
|
1053
|
+
l.lineTo(w[v][0], w[v][1]);
|
|
1048
1054
|
l.stroke();
|
|
1049
1055
|
}
|
|
1050
1056
|
l.restore();
|
|
1051
1057
|
}
|
|
1052
1058
|
},
|
|
1053
|
-
[
|
|
1054
|
-
),
|
|
1059
|
+
[N, G, U]
|
|
1060
|
+
), It = B(
|
|
1055
1061
|
(l) => {
|
|
1056
|
-
const f = dt.current,
|
|
1057
|
-
if (!
|
|
1058
|
-
const
|
|
1059
|
-
if (!
|
|
1060
|
-
const
|
|
1061
|
-
!Number.isFinite(
|
|
1062
|
+
const f = dt.current, w = f.cursor;
|
|
1063
|
+
if (!w) return;
|
|
1064
|
+
const y = te(a.current?.worldToScreen(w[0], w[1]) ?? []);
|
|
1065
|
+
if (!y) return;
|
|
1066
|
+
const R = G(w, U.radius);
|
|
1067
|
+
!Number.isFinite(R) || R <= 0 || (l.save(), l.beginPath(), l.arc(y[0], y[1], R, 0, Math.PI * 2), l.strokeStyle = f.isDrawing ? U.cursorActiveColor : U.cursorColor, l.lineWidth = U.cursorLineWidth, l.setLineDash(U.cursorLineDash), l.stroke(), l.setLineDash(Pe), l.restore());
|
|
1062
1068
|
},
|
|
1063
|
-
[a, G,
|
|
1064
|
-
),
|
|
1065
|
-
|
|
1066
|
-
const l =
|
|
1069
|
+
[a, G, U]
|
|
1070
|
+
), _t = B(() => {
|
|
1071
|
+
gt();
|
|
1072
|
+
const l = K.current;
|
|
1067
1073
|
if (!l) return;
|
|
1068
1074
|
const f = l.getContext("2d");
|
|
1069
1075
|
if (!f) return;
|
|
1070
|
-
const
|
|
1071
|
-
if (f.setTransform(1, 0, 0, 1, 0, 0), f.clearRect(0, 0, l.width, l.height), f.setTransform(
|
|
1072
|
-
for (let
|
|
1073
|
-
const
|
|
1076
|
+
const w = Math.max(1, window.devicePixelRatio || 1), y = l.width / w, R = l.height / w;
|
|
1077
|
+
if (f.setTransform(1, 0, 0, 1, 0, 0), f.clearRect(0, 0, l.width, l.height), f.setTransform(w, 0, 0, w, 0, 0), M.length > 0)
|
|
1078
|
+
for (let v = 0; v < M.length; v += 1) {
|
|
1079
|
+
const Y = M[v], V = Y?.coordinates;
|
|
1074
1080
|
if (!V || V.length < 3) continue;
|
|
1075
|
-
const
|
|
1076
|
-
if (
|
|
1077
|
-
const
|
|
1078
|
-
let
|
|
1079
|
-
if (
|
|
1080
|
-
const
|
|
1081
|
-
region:
|
|
1082
|
-
regionId:
|
|
1083
|
-
regionIndex:
|
|
1084
|
-
state:
|
|
1081
|
+
const W = Rt(V), lt = N(W);
|
|
1082
|
+
if (lt.length >= 4) {
|
|
1083
|
+
const Pt = Y.id ?? v, $t = Pn(at, Pt) ? "active" : Pn(ft, Pt) ? "hover" : "default";
|
|
1084
|
+
let xt = $t === "active" ? Z : $t === "hover" ? L : A;
|
|
1085
|
+
if (D) {
|
|
1086
|
+
const H = D({
|
|
1087
|
+
region: Y,
|
|
1088
|
+
regionId: Pt,
|
|
1089
|
+
regionIndex: v,
|
|
1090
|
+
state: $t
|
|
1085
1091
|
});
|
|
1086
|
-
|
|
1092
|
+
xt = oe(xt, H || void 0);
|
|
1087
1093
|
}
|
|
1088
|
-
|
|
1094
|
+
Qt(f, lt, xt, !0, !1);
|
|
1089
1095
|
}
|
|
1090
1096
|
}
|
|
1091
|
-
if (
|
|
1092
|
-
for (let
|
|
1093
|
-
const V =
|
|
1097
|
+
if (I.length > 0)
|
|
1098
|
+
for (let v = 0; v < I.length; v += 1) {
|
|
1099
|
+
const V = I[v]?.coordinates;
|
|
1094
1100
|
if (!V || V.length < 3) continue;
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1101
|
+
const W = Rt(V), lt = N(W);
|
|
1102
|
+
lt.length < 4 || Qt(f, lt, et, !0, !1);
|
|
1097
1103
|
}
|
|
1098
|
-
if (Array.isArray(
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1104
|
+
if (Array.isArray(J) && J.length > 0) {
|
|
1105
|
+
const v = !!globalThis.__OPEN_PLANT_DEBUG_OVERLAY__, Y = N(
|
|
1106
|
+
Rt([
|
|
1101
1107
|
[0, 0],
|
|
1102
1108
|
[t, 0],
|
|
1103
1109
|
[t, n],
|
|
1104
1110
|
[0, n]
|
|
1105
1111
|
])
|
|
1106
1112
|
);
|
|
1107
|
-
for (let V = 0; V <
|
|
1108
|
-
const
|
|
1109
|
-
if (!
|
|
1110
|
-
const
|
|
1111
|
-
if (
|
|
1112
|
-
const
|
|
1113
|
-
for (const
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1113
|
+
for (let V = 0; V < J.length; V += 1) {
|
|
1114
|
+
const W = J[V];
|
|
1115
|
+
if (!W?.coordinates?.length || W.visible === !1) continue;
|
|
1116
|
+
const lt = W.closed ?? ai(W.coordinates), Pt = Rn(W.coordinates, lt);
|
|
1117
|
+
if (W.invertedFill?.fillColor) {
|
|
1118
|
+
const xt = [], H = Rn(W.coordinates, !0);
|
|
1119
|
+
for (const St of H) {
|
|
1120
|
+
const Tt = N(St);
|
|
1121
|
+
Tt.length >= 4 && xt.push(Tt);
|
|
1116
1122
|
}
|
|
1117
|
-
if (
|
|
1118
|
-
const
|
|
1119
|
-
|
|
1120
|
-
id:
|
|
1121
|
-
outerRingPoints:
|
|
1122
|
-
sourceRingCount:
|
|
1123
|
-
holeRingCount:
|
|
1124
|
-
fillColor:
|
|
1123
|
+
if (v) {
|
|
1124
|
+
const St = String(W.id ?? V), Tt = `${Y.length}|${H.length}|${xt.length}|${W.invertedFill.fillColor}`;
|
|
1125
|
+
zt.current.get(St) !== Tt && (zt.current.set(St, Tt), console.debug("[open-plant] invertedFill", {
|
|
1126
|
+
id: W.id ?? V,
|
|
1127
|
+
outerRingPoints: Y.length,
|
|
1128
|
+
sourceRingCount: H.length,
|
|
1129
|
+
holeRingCount: xt.length,
|
|
1130
|
+
fillColor: W.invertedFill.fillColor
|
|
1125
1131
|
}));
|
|
1126
1132
|
}
|
|
1127
|
-
|
|
1133
|
+
li(f, Y, xt, W.invertedFill.fillColor);
|
|
1128
1134
|
}
|
|
1129
|
-
if (
|
|
1130
|
-
const
|
|
1131
|
-
for (const
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1135
|
+
if (Pt.length === 0) continue;
|
|
1136
|
+
const $t = oe(A, W.stroke ?? W.strokeStyle);
|
|
1137
|
+
for (const xt of Pt) {
|
|
1138
|
+
const H = N(xt);
|
|
1139
|
+
H.length < 2 || Qt(f, H, $t, lt, W.fill ?? !1);
|
|
1134
1140
|
}
|
|
1135
1141
|
}
|
|
1136
1142
|
}
|
|
1137
|
-
if (
|
|
1143
|
+
if (Q)
|
|
1138
1144
|
if (e === "brush")
|
|
1139
|
-
|
|
1145
|
+
q(f), It(f);
|
|
1140
1146
|
else {
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1147
|
+
const v = rt();
|
|
1148
|
+
if (v.length > 0)
|
|
1143
1149
|
if (e === "freehand") {
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1150
|
+
const Y = N(v);
|
|
1151
|
+
Y.length >= 2 && Qt(f, Y, A, !1, !1), Y.length >= 3 && Qt(f, N(Rt(v)), A, !0, !0);
|
|
1146
1152
|
} else {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1153
|
+
const Y = N(v);
|
|
1154
|
+
Y.length >= 4 && Qt(f, Y, A, !0, !0);
|
|
1149
1155
|
}
|
|
1150
1156
|
}
|
|
1151
|
-
if (
|
|
1152
|
-
for (const
|
|
1153
|
-
if (!
|
|
1154
|
-
const
|
|
1155
|
-
if (!
|
|
1156
|
-
const V =
|
|
1157
|
-
if (!
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1157
|
+
if (M.length > 0)
|
|
1158
|
+
for (const v of M) {
|
|
1159
|
+
if (!v.label) continue;
|
|
1160
|
+
const Y = v?.coordinates;
|
|
1161
|
+
if (!Y || Y.length < 3) continue;
|
|
1162
|
+
const V = Rt(Y), W = di(V);
|
|
1163
|
+
if (!W) continue;
|
|
1164
|
+
const lt = te(a.current?.worldToScreen(W[0], W[1]) ?? []);
|
|
1165
|
+
lt && mi(f, v.label, lt, y, R, mt);
|
|
1160
1166
|
}
|
|
1161
1167
|
}, [
|
|
1162
|
-
it,
|
|
1163
|
-
e,
|
|
1164
|
-
st,
|
|
1165
1168
|
Q,
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
+
e,
|
|
1170
|
+
rt,
|
|
1171
|
+
q,
|
|
1172
|
+
It,
|
|
1173
|
+
gt,
|
|
1174
|
+
N,
|
|
1169
1175
|
t,
|
|
1170
1176
|
n,
|
|
1171
1177
|
a,
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
nt,
|
|
1178
|
+
M,
|
|
1179
|
+
J,
|
|
1175
1180
|
ft,
|
|
1176
|
-
|
|
1177
|
-
|
|
1181
|
+
at,
|
|
1182
|
+
A,
|
|
1178
1183
|
L,
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1184
|
+
Z,
|
|
1185
|
+
I,
|
|
1186
|
+
et,
|
|
1187
|
+
D,
|
|
1188
|
+
mt
|
|
1189
|
+
]), F = B(() => {
|
|
1190
|
+
Ct.current || (Ct.current = !0, requestAnimationFrame(() => {
|
|
1191
|
+
Ct.current = !1, _t();
|
|
1186
1192
|
}));
|
|
1187
|
-
}, [
|
|
1188
|
-
const f = dt.current,
|
|
1189
|
-
if (
|
|
1193
|
+
}, [_t]), ct = B((l = !1) => {
|
|
1194
|
+
const f = dt.current, w = K.current;
|
|
1195
|
+
if (w && f.pointerId !== null && w.hasPointerCapture(f.pointerId))
|
|
1190
1196
|
try {
|
|
1191
|
-
|
|
1197
|
+
w.releasePointerCapture(f.pointerId);
|
|
1192
1198
|
} catch {
|
|
1193
1199
|
}
|
|
1194
1200
|
f.isDrawing = !1, f.pointerId = null, f.start = null, f.current = null, f.points = [], f.stampCenter = null, l || (f.cursor = null);
|
|
1195
|
-
}, []),
|
|
1201
|
+
}, []), ot = B(
|
|
1196
1202
|
(l) => {
|
|
1197
1203
|
const f = a.current;
|
|
1198
1204
|
if (!f || t <= 0 || n <= 0) return null;
|
|
1199
|
-
const
|
|
1200
|
-
return
|
|
1205
|
+
const w = te(f.screenToWorld(l.clientX, l.clientY));
|
|
1206
|
+
return w ? Fe(w, t, n) : null;
|
|
1201
1207
|
},
|
|
1202
1208
|
[a, t, n]
|
|
1203
|
-
),
|
|
1209
|
+
), Gt = B(() => {
|
|
1204
1210
|
const l = dt.current;
|
|
1205
1211
|
if (!l.isDrawing) {
|
|
1206
|
-
|
|
1212
|
+
ct(!0), F();
|
|
1207
1213
|
return;
|
|
1208
1214
|
}
|
|
1209
1215
|
let f = [];
|
|
1210
1216
|
if (e === "freehand")
|
|
1211
|
-
l.points.length >=
|
|
1217
|
+
l.points.length >= Lr && (f = Rt(l.points));
|
|
1212
1218
|
else if (e === "rectangle")
|
|
1213
|
-
f = xn(l.start, l.current);
|
|
1214
|
-
else if (e === "circular")
|
|
1215
1219
|
f = Sn(l.start, l.current);
|
|
1220
|
+
else if (e === "circular")
|
|
1221
|
+
f = Tn(l.start, l.current);
|
|
1216
1222
|
else if (e === "brush") {
|
|
1217
|
-
const
|
|
1223
|
+
const w = l.points[l.points.length - 1] ?? l.current ?? l.start;
|
|
1224
|
+
if (U.clickSelectRoi && w && l.points.length <= 1 && u?.(w)) {
|
|
1225
|
+
ct(!0), F();
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
const y = Math.max(1e-6, a.current?.getViewState?.().zoom ?? 1), R = U.edgeDetail, v = 0.75 / (y * R);
|
|
1218
1229
|
f = Fr(l.points, {
|
|
1219
|
-
radius:
|
|
1230
|
+
radius: U.radius,
|
|
1220
1231
|
clipBounds: [0, 0, t, n],
|
|
1221
|
-
minRasterStep:
|
|
1222
|
-
|
|
1232
|
+
minRasterStep: v,
|
|
1233
|
+
circleSides: Math.max(24, Math.round(64 * R)),
|
|
1234
|
+
simplifyTolerance: v * 0.4
|
|
1223
1235
|
});
|
|
1224
1236
|
}
|
|
1225
|
-
(e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") &&
|
|
1237
|
+
(e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") && An(f) && c && c({
|
|
1226
1238
|
tool: e,
|
|
1227
1239
|
intent: e === "brush" ? "brush" : "roi",
|
|
1228
1240
|
coordinates: f,
|
|
1229
|
-
bbox:
|
|
1230
|
-
areaPx:
|
|
1231
|
-
}),
|
|
1232
|
-
}, [e,
|
|
1241
|
+
bbox: Mn(f),
|
|
1242
|
+
areaPx: ke(f)
|
|
1243
|
+
}), ct(!0), F();
|
|
1244
|
+
}, [e, c, ct, F, U.radius, U.edgeDetail, U.clickSelectRoi, t, n, a, u]), Bt = B(
|
|
1233
1245
|
(l, f) => {
|
|
1234
|
-
const
|
|
1235
|
-
if (!
|
|
1236
|
-
const
|
|
1246
|
+
const w = nt(l, f);
|
|
1247
|
+
if (!An(w)) return;
|
|
1248
|
+
const y = l === "stamp-rectangle-4096px" ? "patch" : "roi", R = {
|
|
1237
1249
|
tool: l,
|
|
1238
|
-
intent:
|
|
1239
|
-
coordinates:
|
|
1240
|
-
bbox:
|
|
1241
|
-
areaPx:
|
|
1250
|
+
intent: y,
|
|
1251
|
+
coordinates: w,
|
|
1252
|
+
bbox: Mn(w),
|
|
1253
|
+
areaPx: ke(w)
|
|
1242
1254
|
};
|
|
1243
|
-
|
|
1255
|
+
c?.(R), y === "patch" && h && h(R);
|
|
1244
1256
|
},
|
|
1245
|
-
[
|
|
1246
|
-
),
|
|
1257
|
+
[nt, c, h]
|
|
1258
|
+
), Ft = B(
|
|
1247
1259
|
(l, f) => {
|
|
1248
|
-
const
|
|
1249
|
-
if (!
|
|
1260
|
+
const w = a.current, y = Math.max(1e-6, w?.getViewState?.().zoom ?? 1), R = Jr / y, v = R * R, Y = l.points[l.points.length - 1];
|
|
1261
|
+
if (!Y) {
|
|
1250
1262
|
l.points.push(f), l.current = f;
|
|
1251
1263
|
return;
|
|
1252
1264
|
}
|
|
1253
|
-
const V = f[0] -
|
|
1254
|
-
V * V +
|
|
1265
|
+
const V = f[0] - Y[0], W = f[1] - Y[1];
|
|
1266
|
+
V * V + W * W >= v ? l.points.push(f) : l.points[l.points.length - 1] = f, l.current = f;
|
|
1255
1267
|
},
|
|
1256
1268
|
[a]
|
|
1257
|
-
), qt =
|
|
1269
|
+
), qt = B(
|
|
1258
1270
|
(l) => {
|
|
1259
|
-
if (!
|
|
1260
|
-
const f =
|
|
1271
|
+
if (!Q || e === "cursor" || l.button !== 0) return;
|
|
1272
|
+
const f = ot(l);
|
|
1261
1273
|
if (!f) return;
|
|
1262
|
-
if (l.preventDefault(), l.stopPropagation(),
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1274
|
+
if (l.preventDefault(), l.stopPropagation(), we(e)) {
|
|
1275
|
+
const R = dt.current;
|
|
1276
|
+
R.stampCenter = f, Bt(e, f), F();
|
|
1265
1277
|
return;
|
|
1266
1278
|
}
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1279
|
+
const w = K.current;
|
|
1280
|
+
w && w.setPointerCapture(l.pointerId);
|
|
1281
|
+
const y = dt.current;
|
|
1282
|
+
y.isDrawing = !0, y.pointerId = l.pointerId, y.start = f, y.current = f, y.cursor = f, y.points = e === "freehand" || e === "brush" ? [f] : [], F();
|
|
1271
1283
|
},
|
|
1272
|
-
[
|
|
1273
|
-
),
|
|
1284
|
+
[Q, e, ot, Bt, F]
|
|
1285
|
+
), pt = B(
|
|
1274
1286
|
(l) => {
|
|
1275
|
-
if (!
|
|
1276
|
-
const f =
|
|
1287
|
+
if (!Q || e === "cursor") return;
|
|
1288
|
+
const f = ot(l);
|
|
1277
1289
|
if (!f) return;
|
|
1278
|
-
if (
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1290
|
+
if (we(e)) {
|
|
1291
|
+
const y = dt.current;
|
|
1292
|
+
y.stampCenter = f, l.preventDefault(), l.stopPropagation(), F();
|
|
1281
1293
|
return;
|
|
1282
1294
|
}
|
|
1283
|
-
const
|
|
1295
|
+
const w = dt.current;
|
|
1284
1296
|
if (e === "brush") {
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1297
|
+
if (w.cursor = f, !w.isDrawing || w.pointerId !== l.pointerId) {
|
|
1298
|
+
F();
|
|
1287
1299
|
return;
|
|
1288
1300
|
}
|
|
1289
|
-
l.preventDefault(), l.stopPropagation(),
|
|
1301
|
+
l.preventDefault(), l.stopPropagation(), Ft(w, f), F();
|
|
1290
1302
|
return;
|
|
1291
1303
|
}
|
|
1292
|
-
if (!(!
|
|
1304
|
+
if (!(!w.isDrawing || w.pointerId !== l.pointerId)) {
|
|
1293
1305
|
if (l.preventDefault(), l.stopPropagation(), e === "freehand") {
|
|
1294
|
-
const
|
|
1306
|
+
const y = a.current, R = Math.max(1e-6, y?.getViewState?.().zoom ?? 1), v = Dr / R, Y = v * v, V = w.points[w.points.length - 1];
|
|
1295
1307
|
if (!V)
|
|
1296
|
-
|
|
1308
|
+
w.points.push(f);
|
|
1297
1309
|
else {
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1310
|
+
const W = f[0] - V[0], lt = f[1] - V[1];
|
|
1311
|
+
W * W + lt * lt >= Y && w.points.push(f);
|
|
1300
1312
|
}
|
|
1301
1313
|
} else
|
|
1302
|
-
|
|
1303
|
-
|
|
1314
|
+
w.current = f;
|
|
1315
|
+
F();
|
|
1304
1316
|
}
|
|
1305
1317
|
},
|
|
1306
|
-
[
|
|
1307
|
-
),
|
|
1318
|
+
[Q, e, ot, F, a, Ft]
|
|
1319
|
+
), ue = B(
|
|
1308
1320
|
(l) => {
|
|
1309
1321
|
const f = dt.current;
|
|
1310
1322
|
if (!f.isDrawing || f.pointerId !== l.pointerId) return;
|
|
1311
1323
|
l.preventDefault(), l.stopPropagation();
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1314
|
-
const
|
|
1315
|
-
if (
|
|
1324
|
+
const w = ot(l);
|
|
1325
|
+
w && (f.cursor = w, e === "brush" ? Ft(f, w) : f.current = w);
|
|
1326
|
+
const y = K.current;
|
|
1327
|
+
if (y && y.hasPointerCapture(l.pointerId))
|
|
1316
1328
|
try {
|
|
1317
|
-
|
|
1329
|
+
y.releasePointerCapture(l.pointerId);
|
|
1318
1330
|
} catch {
|
|
1319
1331
|
}
|
|
1320
|
-
|
|
1332
|
+
Gt();
|
|
1321
1333
|
},
|
|
1322
|
-
[
|
|
1323
|
-
),
|
|
1334
|
+
[Gt, ot, e, Ft]
|
|
1335
|
+
), ce = B(() => {
|
|
1324
1336
|
const l = dt.current;
|
|
1325
1337
|
let f = !1;
|
|
1326
|
-
e === "brush" && !l.isDrawing && l.cursor && (l.cursor = null, f = !0),
|
|
1327
|
-
}, [e,
|
|
1338
|
+
e === "brush" && !l.isDrawing && l.cursor && (l.cursor = null, f = !0), we(e) && l.stampCenter && (l.stampCenter = null, f = !0), f && F();
|
|
1339
|
+
}, [e, F]);
|
|
1328
1340
|
return X(() => {
|
|
1329
|
-
|
|
1330
|
-
const l =
|
|
1341
|
+
gt(), F();
|
|
1342
|
+
const l = K.current;
|
|
1331
1343
|
if (!l) return;
|
|
1332
1344
|
const f = new ResizeObserver(() => {
|
|
1333
|
-
|
|
1345
|
+
gt(), F();
|
|
1334
1346
|
});
|
|
1335
1347
|
return f.observe(l), () => {
|
|
1336
1348
|
f.disconnect();
|
|
1337
1349
|
};
|
|
1338
|
-
}, [
|
|
1339
|
-
|
|
1340
|
-
}, [
|
|
1341
|
-
|
|
1342
|
-
}, [e,
|
|
1343
|
-
|
|
1344
|
-
}, [
|
|
1345
|
-
if (
|
|
1346
|
-
return
|
|
1347
|
-
|
|
1350
|
+
}, [gt, F]), X(() => {
|
|
1351
|
+
Q || ct(), F();
|
|
1352
|
+
}, [Q, F, ct]), X(() => {
|
|
1353
|
+
Kt.current !== e && (Kt.current = e, ct(), F());
|
|
1354
|
+
}, [e, ct, F]), X(() => {
|
|
1355
|
+
F();
|
|
1356
|
+
}, [d, M, J, F]), X(() => {
|
|
1357
|
+
if (ht)
|
|
1358
|
+
return ht.current = F, () => {
|
|
1359
|
+
ht.current === F && (ht.current = null);
|
|
1348
1360
|
};
|
|
1349
|
-
}, [
|
|
1350
|
-
if (!
|
|
1361
|
+
}, [ht, F]), X(() => {
|
|
1362
|
+
if (!Q) return;
|
|
1351
1363
|
const l = (f) => {
|
|
1352
|
-
f.key === "Escape" && (
|
|
1364
|
+
f.key === "Escape" && (ct(), F());
|
|
1353
1365
|
};
|
|
1354
1366
|
return window.addEventListener("keydown", l), () => {
|
|
1355
1367
|
window.removeEventListener("keydown", l);
|
|
1356
1368
|
};
|
|
1357
|
-
}, [
|
|
1369
|
+
}, [Q, ct, F]), /* @__PURE__ */ Ut(
|
|
1358
1370
|
"canvas",
|
|
1359
1371
|
{
|
|
1360
|
-
ref:
|
|
1361
|
-
className:
|
|
1362
|
-
style:
|
|
1372
|
+
ref: K,
|
|
1373
|
+
className: vt,
|
|
1374
|
+
style: At,
|
|
1363
1375
|
onPointerDown: qt,
|
|
1364
|
-
onPointerMove:
|
|
1365
|
-
onPointerUp:
|
|
1366
|
-
onPointerCancel:
|
|
1367
|
-
onPointerLeave:
|
|
1376
|
+
onPointerMove: pt,
|
|
1377
|
+
onPointerUp: ue,
|
|
1378
|
+
onPointerCancel: ue,
|
|
1379
|
+
onPointerLeave: ce,
|
|
1368
1380
|
onContextMenu: (l) => {
|
|
1369
|
-
|
|
1381
|
+
Q && l.preventDefault();
|
|
1370
1382
|
},
|
|
1371
1383
|
onWheel: (l) => {
|
|
1372
|
-
if (!
|
|
1373
|
-
const f =
|
|
1374
|
-
if (!f || typeof
|
|
1384
|
+
if (!Q) return;
|
|
1385
|
+
const f = K.current, w = a.current;
|
|
1386
|
+
if (!f || typeof w?.zoomBy != "function") return;
|
|
1375
1387
|
l.preventDefault(), l.stopPropagation();
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1388
|
+
const y = f.getBoundingClientRect(), R = l.clientX - y.left, v = l.clientY - y.top;
|
|
1389
|
+
w.zoomBy(l.deltaY < 0 ? Yr : Wr, R, v), F();
|
|
1378
1390
|
}
|
|
1379
1391
|
}
|
|
1380
1392
|
);
|
|
1381
1393
|
}
|
|
1382
|
-
function
|
|
1394
|
+
function vn(e) {
|
|
1383
1395
|
return String(e ?? "").replace(/\/+$/, "");
|
|
1384
1396
|
}
|
|
1385
1397
|
function Yn(e) {
|
|
1386
1398
|
const t = String(e ?? "");
|
|
1387
1399
|
return t.startsWith("/") ? t : `/${t}`;
|
|
1388
1400
|
}
|
|
1389
|
-
function
|
|
1390
|
-
const t =
|
|
1401
|
+
function pi(e) {
|
|
1402
|
+
const t = vn(e);
|
|
1391
1403
|
if (!t) return "";
|
|
1392
1404
|
if (/\/TileGroup\d+$/i.test(t)) return t;
|
|
1393
1405
|
let n = null;
|
|
@@ -1397,20 +1409,20 @@ function hi(e) {
|
|
|
1397
1409
|
n = null;
|
|
1398
1410
|
}
|
|
1399
1411
|
if (n) {
|
|
1400
|
-
const r = `${n.protocol}//${n.host}`, i =
|
|
1412
|
+
const r = `${n.protocol}//${n.host}`, i = vn(n.pathname || "");
|
|
1401
1413
|
return /\/ims$/i.test(i) ? `${r}${i}` : /\/tiles$/i.test(i) ? `${r}${i}` : `${r}${i}/tiles`;
|
|
1402
1414
|
}
|
|
1403
1415
|
return /\/ims$/i.test(t) ? "/ims" : /\/tiles$/i.test(t) ? `${t}` : `${t}/tiles`;
|
|
1404
1416
|
}
|
|
1405
|
-
function
|
|
1417
|
+
function mo(e, t) {
|
|
1406
1418
|
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), u = String(n.path ?? e?.path ?? ""), c = Number(n.mpp ?? e?.mpp ?? 0);
|
|
1407
1419
|
if (!i || !o || !s || !u)
|
|
1408
1420
|
throw new Error("이미지 메타데이터가 불완전합니다. width/height/tileSize/path 확인 필요");
|
|
1409
|
-
const h = Array.isArray(e?.terms) ? e.terms.map((
|
|
1410
|
-
termId: String(
|
|
1411
|
-
termName: String(
|
|
1412
|
-
termColor: String(
|
|
1413
|
-
})) : [], g = Yn(u), d =
|
|
1421
|
+
const h = Array.isArray(e?.terms) ? e.terms.map((x) => ({
|
|
1422
|
+
termId: String(x?.termId ?? ""),
|
|
1423
|
+
termName: String(x?.termName ?? ""),
|
|
1424
|
+
termColor: String(x?.termColor ?? "")
|
|
1425
|
+
})) : [], g = Yn(u), d = pi(t), p = r ? (x, S, P) => `${d}${g}/${x}/${P}_${S}.webp` : void 0;
|
|
1414
1426
|
return {
|
|
1415
1427
|
id: e?._id || "unknown",
|
|
1416
1428
|
name: e?.name || "unknown",
|
|
@@ -1422,7 +1434,7 @@ function uo(e, t) {
|
|
|
1422
1434
|
tilePath: u,
|
|
1423
1435
|
tileBaseUrl: t,
|
|
1424
1436
|
terms: h,
|
|
1425
|
-
tileUrlBuilder:
|
|
1437
|
+
tileUrlBuilder: p
|
|
1426
1438
|
};
|
|
1427
1439
|
}
|
|
1428
1440
|
function Wn(e, t, n, r) {
|
|
@@ -1431,7 +1443,7 @@ function Wn(e, t, n, r) {
|
|
|
1431
1443
|
const i = Yn(e.tilePath);
|
|
1432
1444
|
return `${e.tileBaseUrl}${i}/${t}/${r}_${n}.webp`;
|
|
1433
1445
|
}
|
|
1434
|
-
const
|
|
1446
|
+
const bt = {
|
|
1435
1447
|
width: 220,
|
|
1436
1448
|
height: 140,
|
|
1437
1449
|
margin: 16,
|
|
@@ -1446,13 +1458,13 @@ const St = {
|
|
|
1446
1458
|
showThumbnail: !0,
|
|
1447
1459
|
maxThumbnailTiles: 16
|
|
1448
1460
|
};
|
|
1449
|
-
function
|
|
1461
|
+
function ee(e, t, n = 1) {
|
|
1450
1462
|
return typeof e != "number" || !Number.isFinite(e) ? t : Math.max(n, e);
|
|
1451
1463
|
}
|
|
1452
|
-
function
|
|
1464
|
+
function ye(e) {
|
|
1453
1465
|
return Array.isArray(e) && e.length === 4 && Number.isFinite(e[0]) && Number.isFinite(e[1]) && Number.isFinite(e[2]) && Number.isFinite(e[3]);
|
|
1454
1466
|
}
|
|
1455
|
-
function
|
|
1467
|
+
function bi({
|
|
1456
1468
|
source: e,
|
|
1457
1469
|
projectorRef: t,
|
|
1458
1470
|
authToken: n = "",
|
|
@@ -1461,253 +1473,253 @@ function fi({
|
|
|
1461
1473
|
className: o,
|
|
1462
1474
|
style: s
|
|
1463
1475
|
}) {
|
|
1464
|
-
const a =
|
|
1476
|
+
const a = j(null), u = j(null), c = j(null), h = j({
|
|
1465
1477
|
active: !1,
|
|
1466
1478
|
pointerId: null
|
|
1467
|
-
}), g =
|
|
1479
|
+
}), g = j(null), d = j(!1), p = ee(
|
|
1468
1480
|
r?.width,
|
|
1469
|
-
|
|
1481
|
+
bt.width,
|
|
1470
1482
|
64
|
|
1471
|
-
),
|
|
1483
|
+
), x = ee(
|
|
1472
1484
|
r?.height,
|
|
1473
|
-
|
|
1485
|
+
bt.height,
|
|
1474
1486
|
48
|
|
1475
|
-
),
|
|
1487
|
+
), S = ee(
|
|
1476
1488
|
r?.margin,
|
|
1477
|
-
|
|
1489
|
+
bt.margin,
|
|
1478
1490
|
0
|
|
1479
|
-
),
|
|
1491
|
+
), P = ee(
|
|
1480
1492
|
r?.borderRadius,
|
|
1481
|
-
|
|
1493
|
+
bt.borderRadius,
|
|
1482
1494
|
0
|
|
1483
|
-
),
|
|
1495
|
+
), k = ee(
|
|
1484
1496
|
r?.borderWidth,
|
|
1485
|
-
|
|
1497
|
+
bt.borderWidth,
|
|
1486
1498
|
0
|
|
1487
|
-
),
|
|
1499
|
+
), C = Math.max(
|
|
1488
1500
|
1,
|
|
1489
1501
|
Math.round(
|
|
1490
|
-
|
|
1502
|
+
ee(
|
|
1491
1503
|
r?.maxThumbnailTiles,
|
|
1492
|
-
|
|
1504
|
+
bt.maxThumbnailTiles,
|
|
1493
1505
|
1
|
|
1494
1506
|
)
|
|
1495
1507
|
)
|
|
1496
|
-
),
|
|
1497
|
-
const
|
|
1498
|
-
return
|
|
1508
|
+
), E = r?.backgroundColor || bt.backgroundColor, D = r?.borderColor || bt.borderColor, J = r?.viewportStrokeColor || bt.viewportStrokeColor, ft = r?.viewportFillColor || bt.viewportFillColor, at = r?.interactive ?? bt.interactive, $ = r?.showThumbnail ?? bt.showThumbnail, ht = r?.position || bt.position, vt = tt(() => {
|
|
1509
|
+
const M = {};
|
|
1510
|
+
return ht === "top-left" || ht === "bottom-left" ? M.left = S : M.right = S, ht === "top-left" || ht === "top-right" ? M.top = S : M.bottom = S, {
|
|
1499
1511
|
position: "absolute",
|
|
1500
|
-
...
|
|
1501
|
-
width:
|
|
1502
|
-
height:
|
|
1503
|
-
borderRadius:
|
|
1512
|
+
...M,
|
|
1513
|
+
width: p,
|
|
1514
|
+
height: x,
|
|
1515
|
+
borderRadius: P,
|
|
1504
1516
|
overflow: "hidden",
|
|
1505
1517
|
zIndex: 4,
|
|
1506
|
-
pointerEvents:
|
|
1518
|
+
pointerEvents: at ? "auto" : "none",
|
|
1507
1519
|
touchAction: "none",
|
|
1508
1520
|
boxShadow: "0 10px 22px rgba(0, 0, 0, 0.3)",
|
|
1509
1521
|
...s
|
|
1510
1522
|
};
|
|
1511
|
-
}, [
|
|
1512
|
-
const
|
|
1513
|
-
if (!
|
|
1514
|
-
const
|
|
1515
|
-
if (!
|
|
1516
|
-
const
|
|
1517
|
-
(
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
L -
|
|
1523
|
+
}, [S, ht, p, x, P, at, s]), Ot = B(() => {
|
|
1524
|
+
const M = a.current;
|
|
1525
|
+
if (!M) return;
|
|
1526
|
+
const I = M.getContext("2d");
|
|
1527
|
+
if (!I) return;
|
|
1528
|
+
const A = p, L = x, Z = Math.max(1, window.devicePixelRatio || 1), et = Math.max(1, Math.round(A * Z)), mt = Math.max(1, Math.round(L * Z));
|
|
1529
|
+
(M.width !== et || M.height !== mt) && (M.width = et, M.height = mt), I.setTransform(1, 0, 0, 1, 0, 0), I.clearRect(0, 0, M.width, M.height), I.setTransform(Z, 0, 0, Z, 0, 0), I.fillStyle = E, I.fillRect(0, 0, A, L);
|
|
1530
|
+
const yt = u.current;
|
|
1531
|
+
yt && I.drawImage(yt, 0, 0, A, L), I.strokeStyle = D, I.lineWidth = k, I.strokeRect(
|
|
1532
|
+
k * 0.5,
|
|
1533
|
+
k * 0.5,
|
|
1534
|
+
A - k,
|
|
1535
|
+
L - k
|
|
1524
1536
|
);
|
|
1525
|
-
const
|
|
1526
|
-
if (!
|
|
1527
|
-
c.current =
|
|
1528
|
-
const
|
|
1529
|
-
(
|
|
1530
|
-
) ?
|
|
1531
|
-
if (
|
|
1532
|
-
|
|
1533
|
-
for (let
|
|
1534
|
-
const Gt =
|
|
1535
|
-
|
|
1537
|
+
const U = t.current, At = U?.getViewBounds?.(), gt = U?.getViewCorners?.(), N = ye(At) ? At : ye(c.current) ? c.current : null;
|
|
1538
|
+
if (!N) return;
|
|
1539
|
+
c.current = N;
|
|
1540
|
+
const G = A / Math.max(1, e.width), ut = L / Math.max(1, e.height), nt = Array.isArray(gt) && gt.length >= 4 && gt.every(
|
|
1541
|
+
(ot) => Array.isArray(ot) && ot.length >= 2 && Number.isFinite(ot[0]) && Number.isFinite(ot[1])
|
|
1542
|
+
) ? gt : null;
|
|
1543
|
+
if (nt) {
|
|
1544
|
+
I.beginPath();
|
|
1545
|
+
for (let ot = 0; ot < nt.length; ot += 1) {
|
|
1546
|
+
const Gt = nt[ot], Bt = it(Gt[0] * G, 0, A), Ft = it(Gt[1] * ut, 0, L);
|
|
1547
|
+
ot === 0 ? I.moveTo(Bt, Ft) : I.lineTo(Bt, Ft);
|
|
1536
1548
|
}
|
|
1537
|
-
|
|
1549
|
+
I.closePath(), I.fillStyle = ft, I.fill(), I.strokeStyle = J, I.lineWidth = 1.5, I.stroke();
|
|
1538
1550
|
return;
|
|
1539
1551
|
}
|
|
1540
|
-
const
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
Math.max(1,
|
|
1545
|
-
Math.max(1,
|
|
1552
|
+
const rt = it(N[0] * G, 0, A), q = it(N[1] * ut, 0, L), It = it(N[2] * G, 0, A), _t = it(N[3] * ut, 0, L), F = Math.max(1, It - rt), ct = Math.max(1, _t - q);
|
|
1553
|
+
I.fillStyle = ft, I.fillRect(rt, q, F, ct), I.strokeStyle = J, I.lineWidth = 1.5, I.strokeRect(
|
|
1554
|
+
rt + 0.5,
|
|
1555
|
+
q + 0.5,
|
|
1556
|
+
Math.max(1, F - 1),
|
|
1557
|
+
Math.max(1, ct - 1)
|
|
1546
1558
|
);
|
|
1547
1559
|
}, [
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1560
|
+
p,
|
|
1561
|
+
x,
|
|
1562
|
+
E,
|
|
1563
|
+
D,
|
|
1564
|
+
k,
|
|
1553
1565
|
t,
|
|
1554
1566
|
e.width,
|
|
1555
1567
|
e.height,
|
|
1556
1568
|
ft,
|
|
1557
|
-
|
|
1558
|
-
]),
|
|
1569
|
+
J
|
|
1570
|
+
]), K = B(() => {
|
|
1559
1571
|
d.current || (d.current = !0, g.current = requestAnimationFrame(() => {
|
|
1560
|
-
d.current = !1, g.current = null,
|
|
1572
|
+
d.current = !1, g.current = null, Ot();
|
|
1561
1573
|
}));
|
|
1562
|
-
}, [
|
|
1563
|
-
(
|
|
1564
|
-
const
|
|
1565
|
-
if (!
|
|
1566
|
-
const L =
|
|
1574
|
+
}, [Ot]), Ct = B(
|
|
1575
|
+
(M, I) => {
|
|
1576
|
+
const A = a.current;
|
|
1577
|
+
if (!A) return null;
|
|
1578
|
+
const L = A.getBoundingClientRect();
|
|
1567
1579
|
if (!L.width || !L.height) return null;
|
|
1568
|
-
const
|
|
1569
|
-
return [
|
|
1580
|
+
const Z = it((M - L.left) / L.width, 0, 1), et = it((I - L.top) / L.height, 0, 1);
|
|
1581
|
+
return [Z * e.width, et * e.height];
|
|
1570
1582
|
},
|
|
1571
1583
|
[e.width, e.height]
|
|
1572
|
-
),
|
|
1573
|
-
(
|
|
1574
|
-
const
|
|
1575
|
-
if (!
|
|
1576
|
-
if (
|
|
1577
|
-
|
|
1584
|
+
), zt = B(
|
|
1585
|
+
(M, I) => {
|
|
1586
|
+
const A = t.current;
|
|
1587
|
+
if (!A) return;
|
|
1588
|
+
if (A.setViewCenter) {
|
|
1589
|
+
A.setViewCenter(M, I), K();
|
|
1578
1590
|
return;
|
|
1579
1591
|
}
|
|
1580
|
-
const L =
|
|
1581
|
-
if (
|
|
1582
|
-
const
|
|
1583
|
-
|
|
1584
|
-
offsetX:
|
|
1585
|
-
offsetY:
|
|
1586
|
-
}),
|
|
1592
|
+
const L = A.getViewBounds?.(), Z = ye(L) ? L : ye(c.current) ? c.current : null;
|
|
1593
|
+
if (!Z) return;
|
|
1594
|
+
const et = Math.max(1e-6, Z[2] - Z[0]), mt = Math.max(1e-6, Z[3] - Z[1]);
|
|
1595
|
+
A.setViewState({
|
|
1596
|
+
offsetX: M - et * 0.5,
|
|
1597
|
+
offsetY: I - mt * 0.5
|
|
1598
|
+
}), K();
|
|
1587
1599
|
},
|
|
1588
|
-
[t,
|
|
1589
|
-
),
|
|
1590
|
-
(
|
|
1591
|
-
if (!
|
|
1592
|
-
const
|
|
1593
|
-
if (!
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1600
|
+
[t, K]
|
|
1601
|
+
), Kt = B(
|
|
1602
|
+
(M) => {
|
|
1603
|
+
if (!at || M.button !== 0) return;
|
|
1604
|
+
const I = a.current;
|
|
1605
|
+
if (!I) return;
|
|
1606
|
+
const A = Ct(M.clientX, M.clientY);
|
|
1607
|
+
A && (M.preventDefault(), M.stopPropagation(), I.setPointerCapture(M.pointerId), h.current = { active: !0, pointerId: M.pointerId }, zt(A[0], A[1]));
|
|
1596
1608
|
},
|
|
1597
|
-
[
|
|
1598
|
-
),
|
|
1599
|
-
(
|
|
1600
|
-
const
|
|
1601
|
-
if (!
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1609
|
+
[at, Ct, zt]
|
|
1610
|
+
), dt = B(
|
|
1611
|
+
(M) => {
|
|
1612
|
+
const I = h.current;
|
|
1613
|
+
if (!I.active || I.pointerId !== M.pointerId) return;
|
|
1614
|
+
const A = Ct(M.clientX, M.clientY);
|
|
1615
|
+
A && (M.preventDefault(), M.stopPropagation(), zt(A[0], A[1]));
|
|
1604
1616
|
},
|
|
1605
|
-
[
|
|
1606
|
-
),
|
|
1607
|
-
(
|
|
1608
|
-
const
|
|
1609
|
-
if (!
|
|
1610
|
-
const
|
|
1611
|
-
if (
|
|
1617
|
+
[Ct, zt]
|
|
1618
|
+
), Q = B(
|
|
1619
|
+
(M) => {
|
|
1620
|
+
const I = h.current;
|
|
1621
|
+
if (!I.active || I.pointerId !== M.pointerId) return;
|
|
1622
|
+
const A = a.current;
|
|
1623
|
+
if (A && A.hasPointerCapture(M.pointerId))
|
|
1612
1624
|
try {
|
|
1613
|
-
|
|
1625
|
+
A.releasePointerCapture(M.pointerId);
|
|
1614
1626
|
} catch {
|
|
1615
1627
|
}
|
|
1616
|
-
h.current = { active: !1, pointerId: null },
|
|
1628
|
+
h.current = { active: !1, pointerId: null }, K();
|
|
1617
1629
|
},
|
|
1618
|
-
[
|
|
1630
|
+
[K]
|
|
1619
1631
|
);
|
|
1620
1632
|
return X(() => {
|
|
1621
|
-
let
|
|
1622
|
-
u.current = null,
|
|
1623
|
-
const
|
|
1624
|
-
if (
|
|
1633
|
+
let M = !1;
|
|
1634
|
+
u.current = null, K();
|
|
1635
|
+
const I = 0, A = 2 ** (e.maxTierZoom - I), L = Math.ceil(e.width / A), Z = Math.ceil(e.height / A), et = Math.max(1, Math.ceil(L / e.tileSize)), mt = Math.max(1, Math.ceil(Z / e.tileSize)), yt = et * mt;
|
|
1636
|
+
if (!$ || yt > C)
|
|
1625
1637
|
return;
|
|
1626
|
-
const
|
|
1627
|
-
|
|
1628
|
-
const
|
|
1629
|
-
if (!
|
|
1638
|
+
const U = document.createElement("canvas");
|
|
1639
|
+
U.width = Math.max(1, Math.round(p)), U.height = Math.max(1, Math.round(x));
|
|
1640
|
+
const At = U.getContext("2d");
|
|
1641
|
+
if (!At)
|
|
1630
1642
|
return;
|
|
1631
|
-
|
|
1632
|
-
const
|
|
1633
|
-
for (let
|
|
1634
|
-
for (let
|
|
1635
|
-
const
|
|
1636
|
-
|
|
1637
|
-
url: Wn(e,
|
|
1638
|
-
bounds: [
|
|
1643
|
+
At.fillStyle = E, At.fillRect(0, 0, U.width, U.height);
|
|
1644
|
+
const gt = [];
|
|
1645
|
+
for (let N = 0; N < mt; N += 1)
|
|
1646
|
+
for (let G = 0; G < et; G += 1) {
|
|
1647
|
+
const ut = G * e.tileSize * A, nt = N * e.tileSize * A, rt = Math.min((G + 1) * e.tileSize, L) * A, q = Math.min((N + 1) * e.tileSize, Z) * A;
|
|
1648
|
+
gt.push({
|
|
1649
|
+
url: Wn(e, I, G, N),
|
|
1650
|
+
bounds: [ut, nt, rt, q]
|
|
1639
1651
|
});
|
|
1640
1652
|
}
|
|
1641
1653
|
return Promise.allSettled(
|
|
1642
|
-
|
|
1643
|
-
const
|
|
1644
|
-
headers:
|
|
1654
|
+
gt.map(async (N) => {
|
|
1655
|
+
const G = !!n, ut = await fetch(N.url, {
|
|
1656
|
+
headers: G ? { Authorization: n } : void 0
|
|
1645
1657
|
});
|
|
1646
|
-
if (!
|
|
1647
|
-
throw new Error(`HTTP ${
|
|
1648
|
-
const
|
|
1649
|
-
return { tile:
|
|
1658
|
+
if (!ut.ok)
|
|
1659
|
+
throw new Error(`HTTP ${ut.status}`);
|
|
1660
|
+
const nt = await createImageBitmap(await ut.blob());
|
|
1661
|
+
return { tile: N, bitmap: nt };
|
|
1650
1662
|
})
|
|
1651
|
-
).then((
|
|
1652
|
-
if (
|
|
1653
|
-
for (const
|
|
1654
|
-
|
|
1663
|
+
).then((N) => {
|
|
1664
|
+
if (M) {
|
|
1665
|
+
for (const nt of N)
|
|
1666
|
+
nt.status === "fulfilled" && nt.value.bitmap.close();
|
|
1655
1667
|
return;
|
|
1656
1668
|
}
|
|
1657
|
-
const
|
|
1658
|
-
for (const
|
|
1659
|
-
if (
|
|
1669
|
+
const G = U.width / Math.max(1, e.width), ut = U.height / Math.max(1, e.height);
|
|
1670
|
+
for (const nt of N) {
|
|
1671
|
+
if (nt.status !== "fulfilled") continue;
|
|
1660
1672
|
const {
|
|
1661
|
-
tile: { bounds:
|
|
1662
|
-
bitmap:
|
|
1663
|
-
} =
|
|
1664
|
-
|
|
1673
|
+
tile: { bounds: rt },
|
|
1674
|
+
bitmap: q
|
|
1675
|
+
} = nt.value, It = rt[0] * G, _t = rt[1] * ut, F = Math.max(1, (rt[2] - rt[0]) * G), ct = Math.max(1, (rt[3] - rt[1]) * ut);
|
|
1676
|
+
At.drawImage(q, It, _t, F, ct), q.close();
|
|
1665
1677
|
}
|
|
1666
|
-
u.current =
|
|
1678
|
+
u.current = U, K();
|
|
1667
1679
|
}), () => {
|
|
1668
|
-
|
|
1680
|
+
M = !0;
|
|
1669
1681
|
};
|
|
1670
1682
|
}, [
|
|
1671
1683
|
e,
|
|
1672
1684
|
n,
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1685
|
+
p,
|
|
1686
|
+
x,
|
|
1687
|
+
E,
|
|
1688
|
+
$,
|
|
1689
|
+
C,
|
|
1690
|
+
K
|
|
1679
1691
|
]), X(() => {
|
|
1680
|
-
|
|
1681
|
-
}, [
|
|
1692
|
+
K();
|
|
1693
|
+
}, [K]), X(() => {
|
|
1682
1694
|
if (i)
|
|
1683
|
-
return i.current =
|
|
1684
|
-
i.current ===
|
|
1695
|
+
return i.current = K, () => {
|
|
1696
|
+
i.current === K && (i.current = null);
|
|
1685
1697
|
};
|
|
1686
|
-
}, [i,
|
|
1698
|
+
}, [i, K]), X(
|
|
1687
1699
|
() => () => {
|
|
1688
1700
|
h.current = { active: !1, pointerId: null }, g.current !== null && (cancelAnimationFrame(g.current), g.current = null), d.current = !1;
|
|
1689
1701
|
},
|
|
1690
1702
|
[]
|
|
1691
|
-
), /* @__PURE__ */
|
|
1703
|
+
), /* @__PURE__ */ Ut(
|
|
1692
1704
|
"canvas",
|
|
1693
1705
|
{
|
|
1694
1706
|
ref: a,
|
|
1695
1707
|
className: o,
|
|
1696
|
-
style:
|
|
1697
|
-
onPointerDown:
|
|
1698
|
-
onPointerMove:
|
|
1699
|
-
onPointerUp:
|
|
1700
|
-
onPointerCancel:
|
|
1701
|
-
onContextMenu: (
|
|
1702
|
-
|
|
1708
|
+
style: vt,
|
|
1709
|
+
onPointerDown: Kt,
|
|
1710
|
+
onPointerMove: dt,
|
|
1711
|
+
onPointerUp: Q,
|
|
1712
|
+
onPointerCancel: Q,
|
|
1713
|
+
onContextMenu: (M) => {
|
|
1714
|
+
M.preventDefault();
|
|
1703
1715
|
},
|
|
1704
|
-
onWheel: (
|
|
1705
|
-
|
|
1716
|
+
onWheel: (M) => {
|
|
1717
|
+
M.preventDefault(), M.stopPropagation();
|
|
1706
1718
|
}
|
|
1707
1719
|
}
|
|
1708
1720
|
);
|
|
1709
1721
|
}
|
|
1710
|
-
function
|
|
1722
|
+
function go({
|
|
1711
1723
|
imageWidth: e,
|
|
1712
1724
|
imageHeight: t,
|
|
1713
1725
|
tiles: n,
|
|
@@ -1715,7 +1727,7 @@ function co({
|
|
|
1715
1727
|
className: i,
|
|
1716
1728
|
style: o
|
|
1717
1729
|
}) {
|
|
1718
|
-
const s =
|
|
1730
|
+
const s = j(null), a = j(null), u = tt(
|
|
1719
1731
|
() => ({ width: "100%", height: "100%", display: "block", ...o }),
|
|
1720
1732
|
[o]
|
|
1721
1733
|
);
|
|
@@ -1723,7 +1735,7 @@ function co({
|
|
|
1723
1735
|
const c = s.current;
|
|
1724
1736
|
if (!c)
|
|
1725
1737
|
return;
|
|
1726
|
-
const h = new
|
|
1738
|
+
const h = new hr({
|
|
1727
1739
|
canvas: c,
|
|
1728
1740
|
imageWidth: e,
|
|
1729
1741
|
imageHeight: t,
|
|
@@ -1738,9 +1750,9 @@ function co({
|
|
|
1738
1750
|
}, [n]), X(() => {
|
|
1739
1751
|
const c = a.current;
|
|
1740
1752
|
!c || !r || c.setViewState(r);
|
|
1741
|
-
}, [r]), /* @__PURE__ */
|
|
1753
|
+
}, [r]), /* @__PURE__ */ Ut("canvas", { ref: s, className: i, style: u });
|
|
1742
1754
|
}
|
|
1743
|
-
function
|
|
1755
|
+
function Vn(e) {
|
|
1744
1756
|
return Math.max(
|
|
1745
1757
|
0,
|
|
1746
1758
|
Math.min(
|
|
@@ -1750,15 +1762,15 @@ function On(e) {
|
|
|
1750
1762
|
)
|
|
1751
1763
|
);
|
|
1752
1764
|
}
|
|
1753
|
-
function
|
|
1765
|
+
function wi(e) {
|
|
1754
1766
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
1755
1767
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
1756
1768
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
1757
1769
|
}
|
|
1758
|
-
function
|
|
1770
|
+
function On(e) {
|
|
1759
1771
|
const t = [];
|
|
1760
1772
|
for (const n of e ?? []) {
|
|
1761
|
-
const r =
|
|
1773
|
+
const r = wi(n);
|
|
1762
1774
|
if (r.length < 4) continue;
|
|
1763
1775
|
let i = 1 / 0, o = 1 / 0, s = -1 / 0, a = -1 / 0;
|
|
1764
1776
|
for (const [u, c] of r)
|
|
@@ -1767,7 +1779,7 @@ function Vn(e) {
|
|
|
1767
1779
|
}
|
|
1768
1780
|
return t;
|
|
1769
1781
|
}
|
|
1770
|
-
function
|
|
1782
|
+
function yi(e, t, n) {
|
|
1771
1783
|
let r = !1;
|
|
1772
1784
|
for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
|
|
1773
1785
|
const s = n[i][0], a = n[i][1], u = n[o][0], c = n[o][1];
|
|
@@ -1777,25 +1789,25 @@ function mi(e, t, n) {
|
|
|
1777
1789
|
}
|
|
1778
1790
|
function Gn(e, t, n) {
|
|
1779
1791
|
for (const r of n)
|
|
1780
|
-
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) &&
|
|
1792
|
+
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && yi(e, t, r.ring))
|
|
1781
1793
|
return !0;
|
|
1782
1794
|
return !1;
|
|
1783
1795
|
}
|
|
1784
|
-
function
|
|
1796
|
+
function Ee(e, t) {
|
|
1785
1797
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
1786
1798
|
return null;
|
|
1787
|
-
const n =
|
|
1799
|
+
const n = On(t ?? []);
|
|
1788
1800
|
if (n.length === 0)
|
|
1789
1801
|
return {
|
|
1790
1802
|
count: 0,
|
|
1791
1803
|
positions: new Float32Array(0),
|
|
1792
1804
|
paletteIndices: new Uint16Array(0)
|
|
1793
1805
|
};
|
|
1794
|
-
const r =
|
|
1806
|
+
const r = Vn(e), i = e.positions, o = e.paletteIndices, s = e.ids instanceof Uint32Array && e.ids.length >= r ? e.ids : null, a = new Float32Array(r * 2), u = new Uint16Array(r), c = s ? new Uint32Array(r) : null;
|
|
1795
1807
|
let h = 0;
|
|
1796
1808
|
for (let d = 0; d < r; d += 1) {
|
|
1797
|
-
const
|
|
1798
|
-
Gn(
|
|
1809
|
+
const p = i[d * 2], x = i[d * 2 + 1];
|
|
1810
|
+
Gn(p, x, n) && (a[h * 2] = p, a[h * 2 + 1] = x, u[h] = o[d], c && (c[h] = s[d]), h += 1);
|
|
1799
1811
|
}
|
|
1800
1812
|
const g = {
|
|
1801
1813
|
count: h,
|
|
@@ -1804,13 +1816,13 @@ function Pe(e, t) {
|
|
|
1804
1816
|
};
|
|
1805
1817
|
return c && (g.ids = c.subarray(0, h)), g;
|
|
1806
1818
|
}
|
|
1807
|
-
function
|
|
1819
|
+
function xi(e, t) {
|
|
1808
1820
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
1809
1821
|
return new Uint32Array(0);
|
|
1810
|
-
const n =
|
|
1822
|
+
const n = On(t ?? []);
|
|
1811
1823
|
if (n.length === 0)
|
|
1812
1824
|
return new Uint32Array(0);
|
|
1813
|
-
const r =
|
|
1825
|
+
const r = Vn(e);
|
|
1814
1826
|
if (r === 0)
|
|
1815
1827
|
return new Uint32Array(0);
|
|
1816
1828
|
const i = e.positions, o = new Uint32Array(r);
|
|
@@ -1821,8 +1833,8 @@ function gi(e, t) {
|
|
|
1821
1833
|
}
|
|
1822
1834
|
return o.subarray(0, s);
|
|
1823
1835
|
}
|
|
1824
|
-
let
|
|
1825
|
-
const
|
|
1836
|
+
let xe = null;
|
|
1837
|
+
const Si = `
|
|
1826
1838
|
struct Params {
|
|
1827
1839
|
pointCount: u32,
|
|
1828
1840
|
boundsCount: u32,
|
|
@@ -1854,20 +1866,20 @@ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
|
1854
1866
|
outputMask[i] = inside;
|
|
1855
1867
|
}
|
|
1856
1868
|
`;
|
|
1857
|
-
function
|
|
1869
|
+
function Ti() {
|
|
1858
1870
|
if (typeof navigator > "u") return !1;
|
|
1859
1871
|
const e = navigator;
|
|
1860
1872
|
return typeof e.gpu == "object" && e.gpu !== null;
|
|
1861
1873
|
}
|
|
1862
1874
|
function qn() {
|
|
1863
|
-
if (!
|
|
1875
|
+
if (!Ti()) return null;
|
|
1864
1876
|
const t = navigator.gpu;
|
|
1865
1877
|
if (!t || typeof t != "object") return null;
|
|
1866
1878
|
const n = t;
|
|
1867
1879
|
return typeof n.requestAdapter != "function" ? null : n;
|
|
1868
1880
|
}
|
|
1869
|
-
const
|
|
1870
|
-
async function
|
|
1881
|
+
const Se = globalThis.GPUShaderStage?.COMPUTE ?? 4, Ue = globalThis.GPUBufferUsage?.STORAGE ?? 128, Te = globalThis.GPUBufferUsage?.COPY_DST ?? 8, Mi = globalThis.GPUBufferUsage?.COPY_SRC ?? 4, Ai = globalThis.GPUBufferUsage?.UNIFORM ?? 64, Pi = globalThis.GPUBufferUsage?.MAP_READ ?? 1, Ei = globalThis.GPUMapMode?.READ ?? 1;
|
|
1882
|
+
async function po() {
|
|
1871
1883
|
const e = qn();
|
|
1872
1884
|
if (!e)
|
|
1873
1885
|
return { supported: !1, features: [] };
|
|
@@ -1887,8 +1899,8 @@ async function lo() {
|
|
|
1887
1899
|
}
|
|
1888
1900
|
} : { supported: !1, features: [] };
|
|
1889
1901
|
}
|
|
1890
|
-
async function
|
|
1891
|
-
return
|
|
1902
|
+
async function Ri() {
|
|
1903
|
+
return xe || (xe = (async () => {
|
|
1892
1904
|
const e = qn();
|
|
1893
1905
|
if (!e) return null;
|
|
1894
1906
|
const t = await e.requestAdapter();
|
|
@@ -1897,40 +1909,40 @@ async function Ti() {
|
|
|
1897
1909
|
entries: [
|
|
1898
1910
|
{
|
|
1899
1911
|
binding: 0,
|
|
1900
|
-
visibility:
|
|
1912
|
+
visibility: Se,
|
|
1901
1913
|
buffer: { type: "read-only-storage" }
|
|
1902
1914
|
},
|
|
1903
1915
|
{
|
|
1904
1916
|
binding: 1,
|
|
1905
|
-
visibility:
|
|
1917
|
+
visibility: Se,
|
|
1906
1918
|
buffer: { type: "read-only-storage" }
|
|
1907
1919
|
},
|
|
1908
1920
|
{
|
|
1909
1921
|
binding: 2,
|
|
1910
|
-
visibility:
|
|
1922
|
+
visibility: Se,
|
|
1911
1923
|
buffer: { type: "storage" }
|
|
1912
1924
|
},
|
|
1913
1925
|
{
|
|
1914
1926
|
binding: 3,
|
|
1915
|
-
visibility:
|
|
1927
|
+
visibility: Se,
|
|
1916
1928
|
buffer: { type: "uniform" }
|
|
1917
1929
|
}
|
|
1918
1930
|
]
|
|
1919
1931
|
}), i = n.createComputePipeline({
|
|
1920
1932
|
layout: n.createPipelineLayout({ bindGroupLayouts: [r] }),
|
|
1921
1933
|
compute: {
|
|
1922
|
-
module: n.createShaderModule({ code:
|
|
1934
|
+
module: n.createShaderModule({ code: Si }),
|
|
1923
1935
|
entryPoint: "main"
|
|
1924
1936
|
}
|
|
1925
1937
|
});
|
|
1926
1938
|
return { device: n, pipeline: i, bindGroupLayout: r };
|
|
1927
|
-
})(),
|
|
1939
|
+
})(), xe);
|
|
1928
1940
|
}
|
|
1929
|
-
function
|
|
1941
|
+
function Me(e, t) {
|
|
1930
1942
|
return Math.ceil(e / t) * t;
|
|
1931
1943
|
}
|
|
1932
|
-
async function
|
|
1933
|
-
const r = await
|
|
1944
|
+
async function vi(e, t, n) {
|
|
1945
|
+
const r = await Ri();
|
|
1934
1946
|
if (!r) return null;
|
|
1935
1947
|
const i = Math.max(0, Math.floor(t)), o = Math.max(0, Math.floor(n.length / 4));
|
|
1936
1948
|
if (i === 0 || o === 0)
|
|
@@ -1942,20 +1954,20 @@ async function Mi(e, t, n) {
|
|
|
1942
1954
|
if (a > h || u > h || c > h)
|
|
1943
1955
|
return null;
|
|
1944
1956
|
const g = r.device.createBuffer({
|
|
1945
|
-
size:
|
|
1946
|
-
usage:
|
|
1957
|
+
size: Me(a, 4),
|
|
1958
|
+
usage: Ue | Te
|
|
1947
1959
|
}), d = r.device.createBuffer({
|
|
1948
|
-
size:
|
|
1949
|
-
usage:
|
|
1950
|
-
}),
|
|
1951
|
-
size:
|
|
1952
|
-
usage:
|
|
1953
|
-
}), y = r.device.createBuffer({
|
|
1954
|
-
size: 16,
|
|
1955
|
-
usage: yi | Se
|
|
1960
|
+
size: Me(u, 4),
|
|
1961
|
+
usage: Ue | Te
|
|
1962
|
+
}), p = r.device.createBuffer({
|
|
1963
|
+
size: Me(c, 4),
|
|
1964
|
+
usage: Ue | Mi
|
|
1956
1965
|
}), x = r.device.createBuffer({
|
|
1957
|
-
size:
|
|
1958
|
-
usage:
|
|
1966
|
+
size: 16,
|
|
1967
|
+
usage: Ai | Te
|
|
1968
|
+
}), S = r.device.createBuffer({
|
|
1969
|
+
size: Me(c, 4),
|
|
1970
|
+
usage: Te | Pi
|
|
1959
1971
|
});
|
|
1960
1972
|
r.device.queue.writeBuffer(
|
|
1961
1973
|
g,
|
|
@@ -1970,35 +1982,35 @@ async function Mi(e, t, n) {
|
|
|
1970
1982
|
n.byteOffset,
|
|
1971
1983
|
u
|
|
1972
1984
|
), r.device.queue.writeBuffer(
|
|
1973
|
-
|
|
1985
|
+
x,
|
|
1974
1986
|
0,
|
|
1975
1987
|
new Uint32Array([s, o, 0, 0])
|
|
1976
1988
|
);
|
|
1977
|
-
const
|
|
1989
|
+
const P = r.device.createBindGroup({
|
|
1978
1990
|
layout: r.bindGroupLayout,
|
|
1979
1991
|
entries: [
|
|
1980
1992
|
{ binding: 0, resource: { buffer: g } },
|
|
1981
1993
|
{ binding: 1, resource: { buffer: d } },
|
|
1982
|
-
{ binding: 2, resource: { buffer:
|
|
1983
|
-
{ binding: 3, resource: { buffer:
|
|
1994
|
+
{ binding: 2, resource: { buffer: p } },
|
|
1995
|
+
{ binding: 3, resource: { buffer: x } }
|
|
1984
1996
|
]
|
|
1985
|
-
}),
|
|
1986
|
-
|
|
1987
|
-
const
|
|
1988
|
-
return
|
|
1997
|
+
}), k = r.device.createCommandEncoder(), C = k.beginComputePass();
|
|
1998
|
+
C.setPipeline(r.pipeline), C.setBindGroup(0, P), C.dispatchWorkgroups(Math.ceil(s / 256)), C.end(), k.copyBufferToBuffer(p, 0, S, 0, c), r.device.queue.submit([k.finish()]), await S.mapAsync(Ei);
|
|
1999
|
+
const E = S.getMappedRange(), D = new Uint32Array(E.slice(0));
|
|
2000
|
+
return S.unmap(), g.destroy(), d.destroy(), p.destroy(), x.destroy(), S.destroy(), D;
|
|
1989
2001
|
}
|
|
1990
|
-
function
|
|
2002
|
+
function Lt() {
|
|
1991
2003
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
1992
2004
|
}
|
|
1993
|
-
function
|
|
2005
|
+
function Ci(e) {
|
|
1994
2006
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
1995
2007
|
const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
|
|
1996
2008
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
1997
2009
|
}
|
|
1998
|
-
function
|
|
2010
|
+
function Ii(e) {
|
|
1999
2011
|
const t = [];
|
|
2000
2012
|
for (const n of e ?? []) {
|
|
2001
|
-
const r =
|
|
2013
|
+
const r = Ci(n);
|
|
2002
2014
|
if (r.length < 4) continue;
|
|
2003
2015
|
let i = 1 / 0, o = 1 / 0, s = -1 / 0, a = -1 / 0;
|
|
2004
2016
|
for (const [u, c] of r)
|
|
@@ -2007,7 +2019,7 @@ function Pi(e) {
|
|
|
2007
2019
|
}
|
|
2008
2020
|
return t;
|
|
2009
2021
|
}
|
|
2010
|
-
function
|
|
2022
|
+
function _i(e, t, n) {
|
|
2011
2023
|
let r = !1;
|
|
2012
2024
|
for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
|
|
2013
2025
|
const s = n[i][0], a = n[i][1], u = n[o][0], c = n[o][1];
|
|
@@ -2015,26 +2027,26 @@ function vi(e, t, n) {
|
|
|
2015
2027
|
}
|
|
2016
2028
|
return r;
|
|
2017
2029
|
}
|
|
2018
|
-
function
|
|
2030
|
+
function Cn(e, t, n) {
|
|
2019
2031
|
for (const r of n)
|
|
2020
|
-
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) &&
|
|
2032
|
+
if (!(e < r.minX || e > r.maxX || t < r.minY || t > r.maxY) && _i(e, t, r.ring))
|
|
2021
2033
|
return !0;
|
|
2022
2034
|
return !1;
|
|
2023
2035
|
}
|
|
2024
|
-
async function
|
|
2025
|
-
const r =
|
|
2036
|
+
async function Bi(e, t, n = {}) {
|
|
2037
|
+
const r = Lt(), i = n.bridgeToDraw === !0;
|
|
2026
2038
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
2027
2039
|
return {
|
|
2028
2040
|
data: null,
|
|
2029
2041
|
meta: {
|
|
2030
2042
|
mode: "hybrid-webgpu",
|
|
2031
|
-
durationMs:
|
|
2043
|
+
durationMs: Lt() - r,
|
|
2032
2044
|
usedWebGpu: !1,
|
|
2033
2045
|
candidateCount: 0,
|
|
2034
2046
|
bridgedToDraw: !1
|
|
2035
2047
|
}
|
|
2036
2048
|
};
|
|
2037
|
-
const o =
|
|
2049
|
+
const o = Ii(t ?? []);
|
|
2038
2050
|
if (o.length === 0)
|
|
2039
2051
|
return {
|
|
2040
2052
|
data: {
|
|
@@ -2044,7 +2056,7 @@ async function Ri(e, t, n = {}) {
|
|
|
2044
2056
|
},
|
|
2045
2057
|
meta: {
|
|
2046
2058
|
mode: "hybrid-webgpu",
|
|
2047
|
-
durationMs:
|
|
2059
|
+
durationMs: Lt() - r,
|
|
2048
2060
|
usedWebGpu: !1,
|
|
2049
2061
|
candidateCount: 0,
|
|
2050
2062
|
bridgedToDraw: !1
|
|
@@ -2060,56 +2072,56 @@ async function Ri(e, t, n = {}) {
|
|
|
2060
2072
|
},
|
|
2061
2073
|
meta: {
|
|
2062
2074
|
mode: "hybrid-webgpu",
|
|
2063
|
-
durationMs:
|
|
2075
|
+
durationMs: Lt() - r,
|
|
2064
2076
|
usedWebGpu: !1,
|
|
2065
2077
|
candidateCount: 0,
|
|
2066
2078
|
bridgedToDraw: !1
|
|
2067
2079
|
}
|
|
2068
2080
|
};
|
|
2069
2081
|
const u = new Float32Array(o.length * 4);
|
|
2070
|
-
for (let
|
|
2071
|
-
const
|
|
2072
|
-
u[
|
|
2082
|
+
for (let C = 0; C < o.length; C += 1) {
|
|
2083
|
+
const E = C * 4, D = o[C];
|
|
2084
|
+
u[E] = D.minX, u[E + 1] = D.minY, u[E + 2] = D.maxX, u[E + 3] = D.maxY;
|
|
2073
2085
|
}
|
|
2074
2086
|
let c = null, h = !1;
|
|
2075
2087
|
try {
|
|
2076
|
-
c = await
|
|
2088
|
+
c = await vi(e.positions, s, u), h = !!c;
|
|
2077
2089
|
} catch {
|
|
2078
2090
|
c = null, h = !1;
|
|
2079
2091
|
}
|
|
2080
2092
|
if (!c)
|
|
2081
2093
|
return {
|
|
2082
|
-
data:
|
|
2094
|
+
data: Ee(e, t),
|
|
2083
2095
|
meta: {
|
|
2084
2096
|
mode: "hybrid-webgpu",
|
|
2085
|
-
durationMs:
|
|
2097
|
+
durationMs: Lt() - r,
|
|
2086
2098
|
usedWebGpu: !1,
|
|
2087
2099
|
candidateCount: s,
|
|
2088
2100
|
bridgedToDraw: !1
|
|
2089
2101
|
}
|
|
2090
2102
|
};
|
|
2091
2103
|
let g = 0;
|
|
2092
|
-
for (let
|
|
2093
|
-
c[
|
|
2104
|
+
for (let C = 0; C < s; C += 1)
|
|
2105
|
+
c[C] === 1 && (g += 1);
|
|
2094
2106
|
const d = new Uint32Array(g);
|
|
2095
2107
|
if (g > 0) {
|
|
2096
|
-
let
|
|
2097
|
-
for (let
|
|
2098
|
-
c[
|
|
2108
|
+
let C = 0;
|
|
2109
|
+
for (let E = 0; E < s; E += 1)
|
|
2110
|
+
c[E] === 1 && (d[C] = E, C += 1);
|
|
2099
2111
|
}
|
|
2100
2112
|
if (g === 0) {
|
|
2101
2113
|
if (i) {
|
|
2102
|
-
const
|
|
2114
|
+
const C = {
|
|
2103
2115
|
count: s,
|
|
2104
2116
|
positions: e.positions.subarray(0, s * 2),
|
|
2105
2117
|
paletteIndices: e.paletteIndices.subarray(0, s),
|
|
2106
2118
|
drawIndices: new Uint32Array(0)
|
|
2107
2119
|
};
|
|
2108
|
-
return a && (
|
|
2109
|
-
data:
|
|
2120
|
+
return a && (C.ids = a.subarray(0, s)), {
|
|
2121
|
+
data: C,
|
|
2110
2122
|
meta: {
|
|
2111
2123
|
mode: "hybrid-webgpu",
|
|
2112
|
-
durationMs:
|
|
2124
|
+
durationMs: Lt() - r,
|
|
2113
2125
|
usedWebGpu: !0,
|
|
2114
2126
|
candidateCount: 0,
|
|
2115
2127
|
bridgedToDraw: !0
|
|
@@ -2125,7 +2137,7 @@ async function Ri(e, t, n = {}) {
|
|
|
2125
2137
|
},
|
|
2126
2138
|
meta: {
|
|
2127
2139
|
mode: "hybrid-webgpu",
|
|
2128
|
-
durationMs:
|
|
2140
|
+
durationMs: Lt() - r,
|
|
2129
2141
|
usedWebGpu: !0,
|
|
2130
2142
|
candidateCount: 0,
|
|
2131
2143
|
bridgedToDraw: !1
|
|
@@ -2133,71 +2145,71 @@ async function Ri(e, t, n = {}) {
|
|
|
2133
2145
|
};
|
|
2134
2146
|
}
|
|
2135
2147
|
if (i) {
|
|
2136
|
-
const
|
|
2137
|
-
let
|
|
2138
|
-
for (let
|
|
2139
|
-
const ft = d[
|
|
2140
|
-
|
|
2148
|
+
const C = new Uint32Array(g);
|
|
2149
|
+
let E = 0;
|
|
2150
|
+
for (let J = 0; J < g; J += 1) {
|
|
2151
|
+
const ft = d[J] ?? 0, at = e.positions[ft * 2], $ = e.positions[ft * 2 + 1];
|
|
2152
|
+
Cn(at, $, o) && (C[E] = ft, E += 1);
|
|
2141
2153
|
}
|
|
2142
|
-
const
|
|
2154
|
+
const D = {
|
|
2143
2155
|
count: s,
|
|
2144
2156
|
positions: e.positions.subarray(0, s * 2),
|
|
2145
2157
|
paletteIndices: e.paletteIndices.subarray(0, s),
|
|
2146
|
-
drawIndices:
|
|
2158
|
+
drawIndices: C.subarray(0, E)
|
|
2147
2159
|
};
|
|
2148
|
-
return a && (
|
|
2149
|
-
data:
|
|
2160
|
+
return a && (D.ids = a.subarray(0, s)), {
|
|
2161
|
+
data: D,
|
|
2150
2162
|
meta: {
|
|
2151
2163
|
mode: "hybrid-webgpu",
|
|
2152
|
-
durationMs:
|
|
2164
|
+
durationMs: Lt() - r,
|
|
2153
2165
|
usedWebGpu: !0,
|
|
2154
2166
|
candidateCount: g,
|
|
2155
2167
|
bridgedToDraw: !0
|
|
2156
2168
|
}
|
|
2157
2169
|
};
|
|
2158
2170
|
}
|
|
2159
|
-
const
|
|
2160
|
-
let
|
|
2161
|
-
for (let
|
|
2162
|
-
const
|
|
2163
|
-
|
|
2171
|
+
const p = new Float32Array(g * 2), x = new Uint16Array(g), S = a ? new Uint32Array(g) : null;
|
|
2172
|
+
let P = 0;
|
|
2173
|
+
for (let C = 0; C < g; C += 1) {
|
|
2174
|
+
const E = d[C] ?? 0, D = e.positions[E * 2], J = e.positions[E * 2 + 1];
|
|
2175
|
+
Cn(D, J, o) && (p[P * 2] = D, p[P * 2 + 1] = J, x[P] = e.paletteIndices[E], S && (S[P] = a[E]), P += 1);
|
|
2164
2176
|
}
|
|
2165
|
-
const
|
|
2166
|
-
count:
|
|
2167
|
-
positions:
|
|
2168
|
-
paletteIndices:
|
|
2177
|
+
const k = {
|
|
2178
|
+
count: P,
|
|
2179
|
+
positions: p.subarray(0, P * 2),
|
|
2180
|
+
paletteIndices: x.subarray(0, P)
|
|
2169
2181
|
};
|
|
2170
|
-
return
|
|
2171
|
-
data:
|
|
2182
|
+
return S && (k.ids = S.subarray(0, P)), {
|
|
2183
|
+
data: k,
|
|
2172
2184
|
meta: {
|
|
2173
2185
|
mode: "hybrid-webgpu",
|
|
2174
|
-
durationMs:
|
|
2186
|
+
durationMs: Lt() - r,
|
|
2175
2187
|
usedWebGpu: !0,
|
|
2176
2188
|
candidateCount: g,
|
|
2177
2189
|
bridgedToDraw: !1
|
|
2178
2190
|
}
|
|
2179
2191
|
};
|
|
2180
2192
|
}
|
|
2181
|
-
let
|
|
2193
|
+
let wt = null, Ye = !0, $n = 1;
|
|
2182
2194
|
const Vt = /* @__PURE__ */ new Map();
|
|
2183
|
-
function
|
|
2195
|
+
function Yt() {
|
|
2184
2196
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
2185
2197
|
}
|
|
2186
2198
|
function Hn() {
|
|
2187
|
-
if (!
|
|
2188
|
-
if (
|
|
2199
|
+
if (!Ye) return null;
|
|
2200
|
+
if (wt) return wt;
|
|
2189
2201
|
try {
|
|
2190
2202
|
const e = new Worker(new URL(
|
|
2191
2203
|
/* @vite-ignore */
|
|
2192
2204
|
"" + new URL("assets/roi-clip-worker-D3hALtsJ.js", import.meta.url).href,
|
|
2193
2205
|
import.meta.url
|
|
2194
2206
|
), { type: "module" });
|
|
2195
|
-
return e.addEventListener("message",
|
|
2207
|
+
return e.addEventListener("message", qe), e.addEventListener("error", $e), wt = e, e;
|
|
2196
2208
|
} catch {
|
|
2197
|
-
return
|
|
2209
|
+
return Ye = !1, null;
|
|
2198
2210
|
}
|
|
2199
2211
|
}
|
|
2200
|
-
function
|
|
2212
|
+
function qe(e) {
|
|
2201
2213
|
const t = e.data;
|
|
2202
2214
|
if (!t) return;
|
|
2203
2215
|
const n = Vt.get(t.id);
|
|
@@ -2216,7 +2228,7 @@ function Ge(e) {
|
|
|
2216
2228
|
indices: c,
|
|
2217
2229
|
meta: {
|
|
2218
2230
|
mode: "worker",
|
|
2219
|
-
durationMs: Number.isFinite(t.durationMs) ? t.durationMs :
|
|
2231
|
+
durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Yt() - n.startMs
|
|
2220
2232
|
}
|
|
2221
2233
|
});
|
|
2222
2234
|
return;
|
|
@@ -2234,25 +2246,25 @@ function Ge(e) {
|
|
|
2234
2246
|
data: a,
|
|
2235
2247
|
meta: {
|
|
2236
2248
|
mode: "worker",
|
|
2237
|
-
durationMs: Number.isFinite(t.durationMs) ? t.durationMs :
|
|
2249
|
+
durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Yt() - n.startMs
|
|
2238
2250
|
}
|
|
2239
2251
|
});
|
|
2240
2252
|
}
|
|
2241
|
-
function
|
|
2242
|
-
|
|
2253
|
+
function $e() {
|
|
2254
|
+
Ye = !1, wt && (wt.removeEventListener("message", qe), wt.removeEventListener("error", $e), wt.terminate(), wt = null);
|
|
2243
2255
|
for (const [, e] of Vt)
|
|
2244
2256
|
e.reject(new Error("worker crashed"));
|
|
2245
2257
|
Vt.clear();
|
|
2246
2258
|
}
|
|
2247
|
-
function
|
|
2248
|
-
if (
|
|
2249
|
-
|
|
2259
|
+
function bo() {
|
|
2260
|
+
if (wt) {
|
|
2261
|
+
wt.removeEventListener("message", qe), wt.removeEventListener("error", $e), wt.terminate(), wt = null;
|
|
2250
2262
|
for (const [, e] of Vt)
|
|
2251
2263
|
e.reject(new Error("worker terminated"));
|
|
2252
2264
|
Vt.clear();
|
|
2253
2265
|
}
|
|
2254
2266
|
}
|
|
2255
|
-
async function
|
|
2267
|
+
async function Fi(e, t) {
|
|
2256
2268
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
2257
2269
|
return {
|
|
2258
2270
|
data: null,
|
|
@@ -2260,13 +2272,13 @@ async function Ei(e, t) {
|
|
|
2260
2272
|
};
|
|
2261
2273
|
const n = Hn();
|
|
2262
2274
|
if (!n) {
|
|
2263
|
-
const c =
|
|
2275
|
+
const c = Yt();
|
|
2264
2276
|
return {
|
|
2265
|
-
data:
|
|
2266
|
-
meta: { mode: "sync", durationMs:
|
|
2277
|
+
data: Ee(e, t),
|
|
2278
|
+
meta: { mode: "sync", durationMs: Yt() - c }
|
|
2267
2279
|
};
|
|
2268
2280
|
}
|
|
2269
|
-
const r = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length)), i = e.positions.slice(0, r * 2), o = e.paletteIndices.slice(0, r), s = e.ids instanceof Uint32Array && e.ids.length >= r ? e.ids.slice(0, r) : null, a = $n++, u =
|
|
2281
|
+
const r = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length)), i = e.positions.slice(0, r * 2), o = e.paletteIndices.slice(0, r), s = e.ids instanceof Uint32Array && e.ids.length >= r ? e.ids.slice(0, r) : null, a = $n++, u = Yt();
|
|
2270
2282
|
return new Promise((c, h) => {
|
|
2271
2283
|
Vt.set(a, { kind: "data", resolve: c, reject: h, startMs: u });
|
|
2272
2284
|
const g = {
|
|
@@ -2281,7 +2293,7 @@ async function Ei(e, t) {
|
|
|
2281
2293
|
s && d.push(s.buffer), n.postMessage(g, d);
|
|
2282
2294
|
});
|
|
2283
2295
|
}
|
|
2284
|
-
async function
|
|
2296
|
+
async function wo(e, t) {
|
|
2285
2297
|
if (!e || !e.count || !e.positions || !e.paletteIndices)
|
|
2286
2298
|
return {
|
|
2287
2299
|
indices: new Uint32Array(0),
|
|
@@ -2289,13 +2301,13 @@ async function fo(e, t) {
|
|
|
2289
2301
|
};
|
|
2290
2302
|
const n = Hn();
|
|
2291
2303
|
if (!n) {
|
|
2292
|
-
const a =
|
|
2304
|
+
const a = Yt();
|
|
2293
2305
|
return {
|
|
2294
|
-
indices:
|
|
2295
|
-
meta: { mode: "sync", durationMs:
|
|
2306
|
+
indices: xi(e, t),
|
|
2307
|
+
meta: { mode: "sync", durationMs: Yt() - a }
|
|
2296
2308
|
};
|
|
2297
2309
|
}
|
|
2298
|
-
const r = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length)), i = e.positions.slice(0, r * 2), o = $n++, s =
|
|
2310
|
+
const r = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length)), i = e.positions.slice(0, r * 2), o = $n++, s = Yt();
|
|
2299
2311
|
return new Promise((a, u) => {
|
|
2300
2312
|
Vt.set(o, { kind: "index", resolve: a, reject: u, startMs: s });
|
|
2301
2313
|
const c = {
|
|
@@ -2308,14 +2320,14 @@ async function fo(e, t) {
|
|
|
2308
2320
|
n.postMessage(c, [i.buffer]);
|
|
2309
2321
|
});
|
|
2310
2322
|
}
|
|
2311
|
-
function
|
|
2323
|
+
function Ui(e) {
|
|
2312
2324
|
if (!Array.isArray(e) || e.length < 3) return [];
|
|
2313
2325
|
const t = e.map(
|
|
2314
2326
|
(i) => [Number(i[0]), Number(i[1])]
|
|
2315
2327
|
), n = t[0], r = t[t.length - 1];
|
|
2316
2328
|
return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
|
|
2317
2329
|
}
|
|
2318
|
-
function
|
|
2330
|
+
function zi(e) {
|
|
2319
2331
|
let t = 0;
|
|
2320
2332
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
2321
2333
|
const [r, i] = e[n], [o, s] = e[n + 1];
|
|
@@ -2323,12 +2335,12 @@ function Ii(e) {
|
|
|
2323
2335
|
}
|
|
2324
2336
|
return Math.abs(t * 0.5);
|
|
2325
2337
|
}
|
|
2326
|
-
function
|
|
2338
|
+
function Li(e) {
|
|
2327
2339
|
const t = [];
|
|
2328
2340
|
for (let n = 0; n < e.length; n += 1) {
|
|
2329
2341
|
const r = e[n];
|
|
2330
2342
|
if (!r?.coordinates?.length) continue;
|
|
2331
|
-
const i =
|
|
2343
|
+
const i = Ui(r.coordinates);
|
|
2332
2344
|
if (i.length < 4) continue;
|
|
2333
2345
|
let o = 1 / 0, s = 1 / 0, a = -1 / 0, u = -1 / 0;
|
|
2334
2346
|
for (const [c, h] of i)
|
|
@@ -2341,12 +2353,12 @@ function _i(e) {
|
|
|
2341
2353
|
minY: s,
|
|
2342
2354
|
maxX: a,
|
|
2343
2355
|
maxY: u,
|
|
2344
|
-
area: Math.max(1e-6,
|
|
2356
|
+
area: Math.max(1e-6, zi(i))
|
|
2345
2357
|
});
|
|
2346
2358
|
}
|
|
2347
2359
|
return t;
|
|
2348
2360
|
}
|
|
2349
|
-
function
|
|
2361
|
+
function Di(e, t, n) {
|
|
2350
2362
|
let r = !1;
|
|
2351
2363
|
for (let i = 0, o = n.length - 1; i < n.length; o = i, i += 1) {
|
|
2352
2364
|
const s = n[i][0], a = n[i][1], u = n[o][0], c = n[o][1];
|
|
@@ -2354,7 +2366,7 @@ function Fi(e, t, n) {
|
|
|
2354
2366
|
}
|
|
2355
2367
|
return r;
|
|
2356
2368
|
}
|
|
2357
|
-
function
|
|
2369
|
+
function Ni(e, t) {
|
|
2358
2370
|
if (Array.isArray(t)) {
|
|
2359
2371
|
const n = t[e];
|
|
2360
2372
|
if (typeof n == "string" && n.length > 0) return n;
|
|
@@ -2365,7 +2377,7 @@ function Ui(e, t) {
|
|
|
2365
2377
|
}
|
|
2366
2378
|
return String(e);
|
|
2367
2379
|
}
|
|
2368
|
-
function
|
|
2380
|
+
function ki(e, t, n = {}) {
|
|
2369
2381
|
const r = Math.max(
|
|
2370
2382
|
0,
|
|
2371
2383
|
Math.min(
|
|
@@ -2377,23 +2389,23 @@ function Bi(e, t, n = {}) {
|
|
|
2377
2389
|
let i = null;
|
|
2378
2390
|
if (e?.drawIndices instanceof Uint32Array) {
|
|
2379
2391
|
const d = e.drawIndices;
|
|
2380
|
-
let
|
|
2381
|
-
for (let
|
|
2382
|
-
d[
|
|
2383
|
-
if (
|
|
2392
|
+
let p = d.length;
|
|
2393
|
+
for (let x = 0; x < d.length; x += 1)
|
|
2394
|
+
d[x] < r || (p -= 1);
|
|
2395
|
+
if (p === d.length)
|
|
2384
2396
|
i = d;
|
|
2385
|
-
else if (
|
|
2386
|
-
const
|
|
2387
|
-
let
|
|
2388
|
-
for (let
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2397
|
+
else if (p > 0) {
|
|
2398
|
+
const x = new Uint32Array(p);
|
|
2399
|
+
let S = 0;
|
|
2400
|
+
for (let P = 0; P < d.length; P += 1) {
|
|
2401
|
+
const k = d[P];
|
|
2402
|
+
k >= r || (x[S] = k, S += 1);
|
|
2391
2403
|
}
|
|
2392
|
-
i =
|
|
2404
|
+
i = x;
|
|
2393
2405
|
} else
|
|
2394
2406
|
i = new Uint32Array(0);
|
|
2395
2407
|
}
|
|
2396
|
-
const o = i ? i.length : r, s =
|
|
2408
|
+
const o = i ? i.length : r, s = Li(t ?? []);
|
|
2397
2409
|
if (!e || o === 0 || s.length === 0)
|
|
2398
2410
|
return {
|
|
2399
2411
|
groups: [],
|
|
@@ -2404,32 +2416,32 @@ function Bi(e, t, n = {}) {
|
|
|
2404
2416
|
const a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
2405
2417
|
let c = 0;
|
|
2406
2418
|
for (let d = 0; d < o; d += 1) {
|
|
2407
|
-
const
|
|
2408
|
-
let
|
|
2409
|
-
for (const
|
|
2410
|
-
|
|
2411
|
-
if (!
|
|
2419
|
+
const p = i ? i[d] : d, x = e.positions[p * 2], S = e.positions[p * 2 + 1];
|
|
2420
|
+
let P = null;
|
|
2421
|
+
for (const E of s)
|
|
2422
|
+
x < E.minX || x > E.maxX || S < E.minY || S > E.maxY || Di(x, S, E.ring) && (!P || E.area < P.area) && (P = E);
|
|
2423
|
+
if (!P) continue;
|
|
2412
2424
|
c += 1;
|
|
2413
|
-
const
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
(u.get(
|
|
2425
|
+
const k = e.paletteIndices[p] ?? 0, C = a.get(P.regionIndex) ?? /* @__PURE__ */ new Map();
|
|
2426
|
+
C.set(k, (C.get(k) ?? 0) + 1), a.set(P.regionIndex, C), u.set(
|
|
2427
|
+
P.regionIndex,
|
|
2428
|
+
(u.get(P.regionIndex) ?? 0) + 1
|
|
2417
2429
|
);
|
|
2418
2430
|
}
|
|
2419
2431
|
const h = n.includeEmptyRegions ?? !1, g = [];
|
|
2420
2432
|
for (const d of s) {
|
|
2421
|
-
const
|
|
2422
|
-
if (!h &&
|
|
2423
|
-
const
|
|
2424
|
-
termId:
|
|
2425
|
-
paletteIndex:
|
|
2426
|
-
count:
|
|
2427
|
-
})).sort((
|
|
2433
|
+
const p = u.get(d.regionIndex) ?? 0;
|
|
2434
|
+
if (!h && p <= 0) continue;
|
|
2435
|
+
const x = a.get(d.regionIndex) ?? /* @__PURE__ */ new Map(), S = Array.from(x.entries()).map(([P, k]) => ({
|
|
2436
|
+
termId: Ni(P, n.paletteIndexToTermId),
|
|
2437
|
+
paletteIndex: P,
|
|
2438
|
+
count: k
|
|
2439
|
+
})).sort((P, k) => k.count - P.count || P.paletteIndex - k.paletteIndex);
|
|
2428
2440
|
g.push({
|
|
2429
2441
|
regionId: d.regionId,
|
|
2430
2442
|
regionIndex: d.regionIndex,
|
|
2431
|
-
totalCount:
|
|
2432
|
-
termCounts:
|
|
2443
|
+
totalCount: p,
|
|
2444
|
+
termCounts: S
|
|
2433
2445
|
});
|
|
2434
2446
|
}
|
|
2435
2447
|
return {
|
|
@@ -2439,10 +2451,10 @@ function Bi(e, t, n = {}) {
|
|
|
2439
2451
|
unmatchedPointCount: Math.max(0, o - c)
|
|
2440
2452
|
};
|
|
2441
2453
|
}
|
|
2442
|
-
function
|
|
2454
|
+
function Ae() {
|
|
2443
2455
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
2444
2456
|
}
|
|
2445
|
-
function
|
|
2457
|
+
function Xi(e, t) {
|
|
2446
2458
|
if (!t) return !1;
|
|
2447
2459
|
try {
|
|
2448
2460
|
const r = new URL(e, typeof window < "u" ? window.location.href : void 0).hostname.toLowerCase();
|
|
@@ -2451,7 +2463,7 @@ function zi(e, t) {
|
|
|
2451
2463
|
}
|
|
2452
2464
|
return !0;
|
|
2453
2465
|
}
|
|
2454
|
-
class
|
|
2466
|
+
class Yi {
|
|
2455
2467
|
constructor(t) {
|
|
2456
2468
|
b(this, "maxConcurrency");
|
|
2457
2469
|
b(this, "maxRetries");
|
|
@@ -2501,7 +2513,7 @@ class Li {
|
|
|
2501
2513
|
const o = {
|
|
2502
2514
|
tile: r,
|
|
2503
2515
|
attempt: 0,
|
|
2504
|
-
readyAt:
|
|
2516
|
+
readyAt: Ae()
|
|
2505
2517
|
};
|
|
2506
2518
|
this.queue.push(o), this.queuedByKey.set(r.key, o);
|
|
2507
2519
|
}
|
|
@@ -2557,14 +2569,14 @@ class Li {
|
|
|
2557
2569
|
if (this.inflight.size >= this.maxConcurrency || this.queue.length === 0) return;
|
|
2558
2570
|
const t = this.queue[0]?.readyAt;
|
|
2559
2571
|
if (typeof t != "number") return;
|
|
2560
|
-
const n = Math.max(0, t -
|
|
2572
|
+
const n = Math.max(0, t - Ae());
|
|
2561
2573
|
this.timerId = window.setTimeout(() => {
|
|
2562
2574
|
this.timerId = null, this.pump();
|
|
2563
2575
|
}, n);
|
|
2564
2576
|
}
|
|
2565
2577
|
takeNextReadyQueueItem() {
|
|
2566
2578
|
if (this.queue.length === 0) return null;
|
|
2567
|
-
const t =
|
|
2579
|
+
const t = Ae(), n = this.queue[0];
|
|
2568
2580
|
return !n || n.readyAt > t ? null : (this.queue.shift(), this.queuedByKey.delete(n.tile.key), n);
|
|
2569
2581
|
}
|
|
2570
2582
|
startFetch(t) {
|
|
@@ -2574,7 +2586,7 @@ class Li {
|
|
|
2574
2586
|
controller: n
|
|
2575
2587
|
};
|
|
2576
2588
|
this.inflight.set(t.tile.key, r), this.emitStateChange();
|
|
2577
|
-
const i =
|
|
2589
|
+
const i = Xi(t.tile.url, this.authToken);
|
|
2578
2590
|
fetch(t.tile.url, {
|
|
2579
2591
|
signal: n.signal,
|
|
2580
2592
|
headers: i ? { Authorization: this.authToken } : void 0
|
|
@@ -2600,7 +2612,7 @@ class Li {
|
|
|
2600
2612
|
const a = t.attempt + 1, u = this.getRetryDelay(a), c = {
|
|
2601
2613
|
tile: t.tile,
|
|
2602
2614
|
attempt: a,
|
|
2603
|
-
readyAt:
|
|
2615
|
+
readyAt: Ae() + u
|
|
2604
2616
|
}, h = this.queuedByKey.get(t.tile.key);
|
|
2605
2617
|
h ? (h.tile = c.tile, h.readyAt = Math.min(h.readyAt, c.readyAt), h.attempt = Math.max(h.attempt, c.attempt)) : (this.queue.push(c), this.queuedByKey.set(c.tile.key, c)), this.sortQueue();
|
|
2606
2618
|
return;
|
|
@@ -2624,7 +2636,7 @@ class Li {
|
|
|
2624
2636
|
this.onStateChange?.(this.getSnapshot());
|
|
2625
2637
|
}
|
|
2626
2638
|
}
|
|
2627
|
-
const
|
|
2639
|
+
const In = 0.35, We = 0.5, Wi = 256, Ve = [
|
|
2628
2640
|
{ zoom: 1, size: 2.8 },
|
|
2629
2641
|
{ zoom: 2, size: 3.4 },
|
|
2630
2642
|
{ zoom: 3, size: 4.2 },
|
|
@@ -2638,7 +2650,7 @@ const Cn = 0.35, Ye = 0.5, Ni = 256, We = [
|
|
|
2638
2650
|
{ zoom: 11, size: 22 },
|
|
2639
2651
|
{ zoom: 12, size: 28 }
|
|
2640
2652
|
];
|
|
2641
|
-
class
|
|
2653
|
+
class Vi {
|
|
2642
2654
|
constructor() {
|
|
2643
2655
|
b(this, "viewportWidth", 1);
|
|
2644
2656
|
b(this, "viewportHeight", 1);
|
|
@@ -2677,10 +2689,10 @@ class Di {
|
|
|
2677
2689
|
return [o + a * h - u * g, s + a * g + u * h];
|
|
2678
2690
|
}
|
|
2679
2691
|
worldToScreen(t, n) {
|
|
2680
|
-
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = t - o, u = n - s, c = ae(r.rotationDeg), h = Math.cos(c), g = Math.sin(c), d = a * h + u * g,
|
|
2692
|
+
const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, s] = this.getCenter(), a = t - o, u = n - s, c = ae(r.rotationDeg), h = Math.cos(c), g = Math.sin(c), d = a * h + u * g, p = -a * g + u * h;
|
|
2681
2693
|
return [
|
|
2682
2694
|
this.viewportWidth * 0.5 + d * i,
|
|
2683
|
-
this.viewportHeight * 0.5 +
|
|
2695
|
+
this.viewportHeight * 0.5 + p * i
|
|
2684
2696
|
];
|
|
2685
2697
|
}
|
|
2686
2698
|
getViewCorners() {
|
|
@@ -2700,7 +2712,7 @@ class Di {
|
|
|
2700
2712
|
function ae(e) {
|
|
2701
2713
|
return e * Math.PI / 180;
|
|
2702
2714
|
}
|
|
2703
|
-
function
|
|
2715
|
+
function _n() {
|
|
2704
2716
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
2705
2717
|
}
|
|
2706
2718
|
function Zt(e, t, n) {
|
|
@@ -2715,16 +2727,16 @@ function ze(e, t) {
|
|
|
2715
2727
|
function Oe(e) {
|
|
2716
2728
|
return e.map((t) => ({ zoom: t.zoom, size: t.size }));
|
|
2717
2729
|
}
|
|
2718
|
-
function
|
|
2719
|
-
if (!e) return Oe(
|
|
2730
|
+
function Bn(e) {
|
|
2731
|
+
if (!e) return Oe(Ve);
|
|
2720
2732
|
const t = /* @__PURE__ */ new Map();
|
|
2721
2733
|
for (const [n, r] of Object.entries(e)) {
|
|
2722
2734
|
const i = Number(n), o = Number(r);
|
|
2723
2735
|
!Number.isFinite(i) || !Number.isFinite(o) || o <= 0 || t.set(i, o);
|
|
2724
2736
|
}
|
|
2725
|
-
return t.size === 0 ? Oe(
|
|
2737
|
+
return t.size === 0 ? Oe(Ve) : Array.from(t.entries()).sort((n, r) => n[0] - r[0]).map(([n, r]) => ({ zoom: n, size: r }));
|
|
2726
2738
|
}
|
|
2727
|
-
function
|
|
2739
|
+
function Oi(e, t) {
|
|
2728
2740
|
if (e === t) return !0;
|
|
2729
2741
|
if (e.length !== t.length) return !1;
|
|
2730
2742
|
for (let n = 0; n < e.length; n += 1)
|
|
@@ -2732,25 +2744,25 @@ function ki(e, t) {
|
|
|
2732
2744
|
return !1;
|
|
2733
2745
|
return !0;
|
|
2734
2746
|
}
|
|
2735
|
-
function
|
|
2736
|
-
if (!Number.isFinite(e)) return t[0]?.size ??
|
|
2737
|
-
if (t.length === 0) return
|
|
2747
|
+
function Gi(e, t) {
|
|
2748
|
+
if (!Number.isFinite(e)) return t[0]?.size ?? We;
|
|
2749
|
+
if (t.length === 0) return We;
|
|
2738
2750
|
if (t.length === 1 || e <= t[0].zoom) return t[0].size;
|
|
2739
2751
|
for (let s = 1; s < t.length; s += 1) {
|
|
2740
2752
|
const a = t[s - 1], u = t[s];
|
|
2741
2753
|
if (e > u.zoom) continue;
|
|
2742
|
-
const c = Math.max(1e-6, u.zoom - a.zoom), h =
|
|
2754
|
+
const c = Math.max(1e-6, u.zoom - a.zoom), h = it((e - a.zoom) / c, 0, 1);
|
|
2743
2755
|
return a.size + (u.size - a.size) * h;
|
|
2744
2756
|
}
|
|
2745
2757
|
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;
|
|
2746
2758
|
return n.size + (e - n.zoom) * o;
|
|
2747
2759
|
}
|
|
2748
|
-
class
|
|
2760
|
+
class qi {
|
|
2749
2761
|
constructor(t, n, r = {}) {
|
|
2750
2762
|
b(this, "canvas");
|
|
2751
2763
|
b(this, "source");
|
|
2752
2764
|
b(this, "gl");
|
|
2753
|
-
b(this, "camera", new
|
|
2765
|
+
b(this, "camera", new Vi());
|
|
2754
2766
|
b(this, "onViewStateChange");
|
|
2755
2767
|
b(this, "onStats");
|
|
2756
2768
|
b(this, "onTileError");
|
|
@@ -2783,7 +2795,7 @@ class Yi {
|
|
|
2783
2795
|
b(this, "usePointIndices", !1);
|
|
2784
2796
|
b(this, "pointBuffersDirty", !0);
|
|
2785
2797
|
b(this, "pointPaletteSize", 1);
|
|
2786
|
-
b(this, "pointSizeStops", Oe(
|
|
2798
|
+
b(this, "pointSizeStops", Oe(Ve));
|
|
2787
2799
|
b(this, "lastPointData", null);
|
|
2788
2800
|
b(this, "lastPointPalette", null);
|
|
2789
2801
|
b(this, "cache", /* @__PURE__ */ new Map());
|
|
@@ -2795,7 +2807,7 @@ class Yi {
|
|
|
2795
2807
|
b(this, "boundContextMenu");
|
|
2796
2808
|
b(this, "boundContextLost");
|
|
2797
2809
|
b(this, "boundContextRestored");
|
|
2798
|
-
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) :
|
|
2810
|
+
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) : In, this.pointSizeStops = Bn(r.pointSizeByZoom);
|
|
2799
2811
|
const i = t.getContext("webgl2", {
|
|
2800
2812
|
alpha: !1,
|
|
2801
2813
|
antialias: !1,
|
|
@@ -2805,7 +2817,7 @@ class Yi {
|
|
|
2805
2817
|
});
|
|
2806
2818
|
if (!i)
|
|
2807
2819
|
throw new Error("WebGL2 not supported");
|
|
2808
|
-
this.gl = i, this.tileProgram = this.initTileProgram(), this.pointProgram = this.initPointProgram(), this.tileScheduler = new
|
|
2820
|
+
this.gl = i, this.tileProgram = this.initTileProgram(), this.pointProgram = this.initPointProgram(), this.tileScheduler = new Yi({
|
|
2809
2821
|
authToken: this.authToken,
|
|
2810
2822
|
maxConcurrency: r.tileScheduler?.maxConcurrency ?? 12,
|
|
2811
2823
|
maxRetries: r.tileScheduler?.maxRetries ?? 2,
|
|
@@ -2822,7 +2834,7 @@ class Yi {
|
|
|
2822
2834
|
}
|
|
2823
2835
|
setViewState(t) {
|
|
2824
2836
|
const n = { ...t };
|
|
2825
|
-
typeof n.zoom == "number" && (n.zoom =
|
|
2837
|
+
typeof n.zoom == "number" && (n.zoom = it(n.zoom, this.minZoom, this.maxZoom)), this.camera.setViewState(n), this.clampViewState(), this.emitViewState(), this.requestRender();
|
|
2826
2838
|
}
|
|
2827
2839
|
getViewState() {
|
|
2828
2840
|
return this.camera.getViewState();
|
|
@@ -2900,8 +2912,8 @@ class Yi {
|
|
|
2900
2912
|
this.interactionLocked !== n && (this.interactionLocked = n, n && this.cancelDrag());
|
|
2901
2913
|
}
|
|
2902
2914
|
setPointSizeByZoom(t) {
|
|
2903
|
-
const n =
|
|
2904
|
-
|
|
2915
|
+
const n = Bn(t);
|
|
2916
|
+
Oi(this.pointSizeStops, n) || (this.pointSizeStops = n, this.requestRender());
|
|
2905
2917
|
}
|
|
2906
2918
|
cancelDrag() {
|
|
2907
2919
|
if (this.pointerId !== null && this.canvas.hasPointerCapture(this.pointerId))
|
|
@@ -2933,38 +2945,38 @@ class Yi {
|
|
|
2933
2945
|
Math.abs(t.rotationDeg) < 1e-6 || (this.camera.setViewState({ rotationDeg: 0 }), this.clampViewState(), this.emitViewState(), this.requestRender());
|
|
2934
2946
|
}
|
|
2935
2947
|
getPointSizeByZoom() {
|
|
2936
|
-
const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t), r =
|
|
2937
|
-
return
|
|
2948
|
+
const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t), r = Gi(n, this.pointSizeStops);
|
|
2949
|
+
return it(r, We, Wi);
|
|
2938
2950
|
}
|
|
2939
2951
|
fitToImage() {
|
|
2940
2952
|
const t = this.canvas.getBoundingClientRect(), n = Math.max(1, t.width || 1), r = Math.max(1, t.height || 1), i = Math.min(n / this.source.width, r / this.source.height), o = Number.isFinite(i) && i > 0 ? i : 1;
|
|
2941
2953
|
this.fitZoom = o, this.minZoom = Math.max(this.fitZoom * 0.5, 1e-6), this.maxZoom = Math.max(1, this.fitZoom * 8), this.minZoom > this.maxZoom && (this.minZoom = this.maxZoom);
|
|
2942
2954
|
const s = n / o, a = r / o;
|
|
2943
2955
|
this.camera.setViewState({
|
|
2944
|
-
zoom:
|
|
2956
|
+
zoom: it(o, this.minZoom, this.maxZoom),
|
|
2945
2957
|
offsetX: (this.source.width - s) * 0.5,
|
|
2946
2958
|
offsetY: (this.source.height - a) * 0.5,
|
|
2947
2959
|
rotationDeg: 0
|
|
2948
2960
|
}), this.clampViewState(), this.emitViewState(), this.requestRender();
|
|
2949
2961
|
}
|
|
2950
2962
|
zoomBy(t, n, r) {
|
|
2951
|
-
const i = this.camera.getViewState(), o =
|
|
2963
|
+
const i = this.camera.getViewState(), o = it(i.zoom * t, this.minZoom, this.maxZoom);
|
|
2952
2964
|
if (o === i.zoom) return;
|
|
2953
2965
|
const [s, a] = this.camera.screenToWorld(n, r);
|
|
2954
2966
|
this.camera.setViewState({ zoom: o });
|
|
2955
|
-
const u = this.camera.getViewport(), c = n - u.width * 0.5, h = r - u.height * 0.5, g = ae(this.camera.getViewState().rotationDeg), d = Math.cos(g),
|
|
2956
|
-
this.camera.setCenter(s -
|
|
2967
|
+
const u = this.camera.getViewport(), c = n - u.width * 0.5, h = r - u.height * 0.5, g = ae(this.camera.getViewState().rotationDeg), d = Math.cos(g), p = Math.sin(g), x = c / o * d - h / o * p, S = c / o * p + h / o * d;
|
|
2968
|
+
this.camera.setCenter(s - x, a - S), this.clampViewState(), this.emitViewState(), this.requestRender();
|
|
2957
2969
|
}
|
|
2958
2970
|
clampViewState() {
|
|
2959
|
-
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(), u = n * 0.5, c = r * 0.5, h = u - i, g = this.source.width - u + i, d = c - o,
|
|
2960
|
-
this.camera.setCenter(
|
|
2971
|
+
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(), u = n * 0.5, c = r * 0.5, h = u - i, g = this.source.width - u + i, d = c - o, p = this.source.height - c + o, x = h <= g ? it(s, h, g) : this.source.width * 0.5, S = d <= p ? it(a, d, p) : this.source.height * 0.5;
|
|
2972
|
+
this.camera.setCenter(x, S);
|
|
2961
2973
|
}
|
|
2962
2974
|
emitViewState() {
|
|
2963
2975
|
this.onViewStateChange?.(this.camera.getViewState());
|
|
2964
2976
|
}
|
|
2965
2977
|
selectTier() {
|
|
2966
2978
|
const t = Math.max(1e-6, this.camera.getViewState().zoom), n = this.source.maxTierZoom + Math.log2(t);
|
|
2967
|
-
return
|
|
2979
|
+
return it(Math.floor(n), 0, this.source.maxTierZoom);
|
|
2968
2980
|
}
|
|
2969
2981
|
getViewBounds() {
|
|
2970
2982
|
const t = this.camera.getViewCorners();
|
|
@@ -2979,40 +2991,40 @@ class Yi {
|
|
|
2979
2991
|
getVisibleTiles() {
|
|
2980
2992
|
const t = this.selectTier();
|
|
2981
2993
|
this.currentTier = t;
|
|
2982
|
-
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)), u = n[0], c = n[1], h = n[2], g = n[3], d =
|
|
2994
|
+
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)), u = n[0], c = n[1], h = n[2], g = n[3], d = it(
|
|
2983
2995
|
Math.floor(u / r / this.source.tileSize),
|
|
2984
2996
|
0,
|
|
2985
2997
|
s - 1
|
|
2986
|
-
),
|
|
2998
|
+
), p = it(
|
|
2987
2999
|
Math.floor((h - 1) / r / this.source.tileSize),
|
|
2988
3000
|
0,
|
|
2989
3001
|
s - 1
|
|
2990
|
-
),
|
|
3002
|
+
), x = it(
|
|
2991
3003
|
Math.floor(c / r / this.source.tileSize),
|
|
2992
3004
|
0,
|
|
2993
3005
|
a - 1
|
|
2994
|
-
),
|
|
3006
|
+
), S = it(
|
|
2995
3007
|
Math.floor((g - 1) / r / this.source.tileSize),
|
|
2996
3008
|
0,
|
|
2997
3009
|
a - 1
|
|
2998
3010
|
);
|
|
2999
|
-
if (d >
|
|
3011
|
+
if (d > p || x > S)
|
|
3000
3012
|
return [];
|
|
3001
|
-
const
|
|
3002
|
-
for (let
|
|
3003
|
-
for (let
|
|
3004
|
-
const
|
|
3005
|
-
|
|
3006
|
-
key: `${t}/${
|
|
3013
|
+
const P = (u + h) * 0.5 / r / this.source.tileSize, k = (c + g) * 0.5 / r / this.source.tileSize, C = [];
|
|
3014
|
+
for (let E = x; E <= S; E += 1)
|
|
3015
|
+
for (let D = d; D <= p; D += 1) {
|
|
3016
|
+
const J = D * this.source.tileSize * r, ft = E * this.source.tileSize * r, at = Math.min((D + 1) * this.source.tileSize, i) * r, $ = Math.min((E + 1) * this.source.tileSize, o) * r, ht = D - P, vt = E - k;
|
|
3017
|
+
C.push({
|
|
3018
|
+
key: `${t}/${D}/${E}`,
|
|
3007
3019
|
tier: t,
|
|
3008
|
-
x:
|
|
3009
|
-
y:
|
|
3010
|
-
bounds: [
|
|
3011
|
-
distance2:
|
|
3012
|
-
url: Wn(this.source, t,
|
|
3020
|
+
x: D,
|
|
3021
|
+
y: E,
|
|
3022
|
+
bounds: [J, ft, at, $],
|
|
3023
|
+
distance2: ht * ht + vt * vt,
|
|
3024
|
+
url: Wn(this.source, t, D, E)
|
|
3013
3025
|
});
|
|
3014
3026
|
}
|
|
3015
|
-
return
|
|
3027
|
+
return C.sort((E, D) => E.distance2 - D.distance2), C;
|
|
3016
3028
|
}
|
|
3017
3029
|
trimCache() {
|
|
3018
3030
|
if (this.cache.size <= this.maxCacheTiles) return;
|
|
@@ -3026,7 +3038,7 @@ class Yi {
|
|
|
3026
3038
|
}
|
|
3027
3039
|
render() {
|
|
3028
3040
|
if (this.destroyed || this.contextLost || this.gl.isContextLost()) return;
|
|
3029
|
-
const t =
|
|
3041
|
+
const t = _n();
|
|
3030
3042
|
this.frameSerial += 1;
|
|
3031
3043
|
const n = this.gl, r = this.tileProgram, i = this.pointProgram;
|
|
3032
3044
|
n.clearColor(0.03, 0.06, 0.1, 1), n.clear(n.COLOR_BUFFER_BIT);
|
|
@@ -3035,7 +3047,7 @@ class Yi {
|
|
|
3035
3047
|
const u = [];
|
|
3036
3048
|
for (const [, d] of this.cache)
|
|
3037
3049
|
a.has(d.key) || this.intersectsBounds(d.bounds, s) && u.push(d);
|
|
3038
|
-
u.sort((d,
|
|
3050
|
+
u.sort((d, p) => d.tier - p.tier);
|
|
3039
3051
|
for (const d of u)
|
|
3040
3052
|
d.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, d.texture), n.uniform4f(
|
|
3041
3053
|
r.uBounds,
|
|
@@ -3047,23 +3059,23 @@ class Yi {
|
|
|
3047
3059
|
let c = 0;
|
|
3048
3060
|
const h = [];
|
|
3049
3061
|
for (const d of o) {
|
|
3050
|
-
const
|
|
3051
|
-
if (!
|
|
3062
|
+
const p = this.cache.get(d.key);
|
|
3063
|
+
if (!p) {
|
|
3052
3064
|
h.push(d);
|
|
3053
3065
|
continue;
|
|
3054
3066
|
}
|
|
3055
|
-
|
|
3067
|
+
p.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, p.texture), n.uniform4f(
|
|
3056
3068
|
r.uBounds,
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3069
|
+
p.bounds[0],
|
|
3070
|
+
p.bounds[1],
|
|
3071
|
+
p.bounds[2],
|
|
3072
|
+
p.bounds[3]
|
|
3061
3073
|
), n.drawArrays(n.TRIANGLE_STRIP, 0, 4), c += 1;
|
|
3062
3074
|
}
|
|
3063
3075
|
this.tileScheduler.schedule(h), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null);
|
|
3064
3076
|
let g = 0;
|
|
3065
3077
|
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.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), g = this.pointCount), this.onStats) {
|
|
3066
|
-
const d = this.tileScheduler.getSnapshot(),
|
|
3078
|
+
const d = this.tileScheduler.getSnapshot(), p = c, x = h.length, S = u.length + c + (g > 0 ? 1 : 0);
|
|
3067
3079
|
this.onStats({
|
|
3068
3080
|
tier: this.currentTier,
|
|
3069
3081
|
visible: o.length,
|
|
@@ -3076,10 +3088,10 @@ class Yi {
|
|
|
3076
3088
|
retries: d.retries,
|
|
3077
3089
|
failed: d.failed,
|
|
3078
3090
|
aborted: d.aborted,
|
|
3079
|
-
cacheHits:
|
|
3080
|
-
cacheMisses:
|
|
3081
|
-
drawCalls:
|
|
3082
|
-
frameMs:
|
|
3091
|
+
cacheHits: p,
|
|
3092
|
+
cacheMisses: x,
|
|
3093
|
+
drawCalls: S,
|
|
3094
|
+
frameMs: _n() - t
|
|
3083
3095
|
});
|
|
3084
3096
|
}
|
|
3085
3097
|
}
|
|
@@ -3103,7 +3115,7 @@ class Yi {
|
|
|
3103
3115
|
if (this.lastPointerX = t.clientX, this.lastPointerY = t.clientY, this.interactionMode === "rotate") {
|
|
3104
3116
|
const i = this.getPointerAngleRad(t.clientX, t.clientY), o = this.rotateLastAngleRad;
|
|
3105
3117
|
if (this.rotateLastAngleRad = i, o !== null) {
|
|
3106
|
-
const s = i - o, a = Math.atan2(Math.sin(s), Math.cos(s)), u = this.rotationDragSensitivityDegPerPixel /
|
|
3118
|
+
const s = i - o, a = Math.atan2(Math.sin(s), Math.cos(s)), u = this.rotationDragSensitivityDegPerPixel / In, c = this.camera.getViewState();
|
|
3107
3119
|
this.camera.setViewState({
|
|
3108
3120
|
rotationDeg: c.rotationDeg - a * 180 / Math.PI * u
|
|
3109
3121
|
});
|
|
@@ -3157,7 +3169,7 @@ class Yi {
|
|
|
3157
3169
|
}
|
|
3158
3170
|
}
|
|
3159
3171
|
initTileProgram() {
|
|
3160
|
-
const t = this.gl, i =
|
|
3172
|
+
const t = this.gl, i = pn(t, `#version 300 es
|
|
3161
3173
|
precision highp float;
|
|
3162
3174
|
in vec2 aUnit;
|
|
3163
3175
|
in vec2 aUv;
|
|
@@ -3193,7 +3205,7 @@ class Yi {
|
|
|
3193
3205
|
return t.enableVertexAttribArray(h), t.enableVertexAttribArray(g), t.vertexAttribPointer(h, 2, t.FLOAT, !1, 16, 0), t.vertexAttribPointer(g, 2, t.FLOAT, !1, 16, 8), t.bindVertexArray(null), t.bindBuffer(t.ARRAY_BUFFER, null), { program: i, vao: u, vbo: c, uCamera: o, uBounds: s, uTexture: a };
|
|
3194
3206
|
}
|
|
3195
3207
|
initPointProgram() {
|
|
3196
|
-
const t = this.gl, i =
|
|
3208
|
+
const t = this.gl, i = pn(t, `#version 300 es
|
|
3197
3209
|
precision highp float;
|
|
3198
3210
|
in vec2 aPosition;
|
|
3199
3211
|
in uint aTerm;
|
|
@@ -3232,18 +3244,18 @@ class Yi {
|
|
|
3232
3244
|
if (alpha <= 0.001) discard;
|
|
3233
3245
|
|
|
3234
3246
|
outColor = vec4(color.rgb * alpha, alpha);
|
|
3235
|
-
}`), o = Zt(t, i, "uCamera"), s = Zt(t, i, "uPointSize"), a = Zt(t, i, "uPalette"), u = Zt(t, i, "uPaletteSize"), c = t.createVertexArray(), h = t.createBuffer(), g = t.createBuffer(), d = t.createBuffer(),
|
|
3236
|
-
if (!c || !h || !g || !d || !
|
|
3247
|
+
}`), o = Zt(t, i, "uCamera"), s = Zt(t, i, "uPointSize"), a = Zt(t, i, "uPalette"), u = Zt(t, i, "uPaletteSize"), c = t.createVertexArray(), h = t.createBuffer(), g = t.createBuffer(), d = t.createBuffer(), p = t.createTexture();
|
|
3248
|
+
if (!c || !h || !g || !d || !p)
|
|
3237
3249
|
throw new Error("point buffer allocation failed");
|
|
3238
3250
|
t.bindVertexArray(c), t.bindBuffer(t.ARRAY_BUFFER, h), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
3239
|
-
const
|
|
3240
|
-
if (y < 0)
|
|
3241
|
-
throw new Error("point position attribute not found");
|
|
3242
|
-
t.enableVertexAttribArray(y), t.vertexAttribPointer(y, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ARRAY_BUFFER, g), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
3243
|
-
const x = t.getAttribLocation(i, "aTerm");
|
|
3251
|
+
const x = t.getAttribLocation(i, "aPosition");
|
|
3244
3252
|
if (x < 0)
|
|
3253
|
+
throw new Error("point position attribute not found");
|
|
3254
|
+
t.enableVertexAttribArray(x), t.vertexAttribPointer(x, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ARRAY_BUFFER, g), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
|
|
3255
|
+
const S = t.getAttribLocation(i, "aTerm");
|
|
3256
|
+
if (S < 0)
|
|
3245
3257
|
throw new Error("point term attribute not found");
|
|
3246
|
-
return t.enableVertexAttribArray(
|
|
3258
|
+
return t.enableVertexAttribArray(S), t.vertexAttribIPointer(S, 1, t.UNSIGNED_SHORT, 0, 0), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, d), 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, p), 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(
|
|
3247
3259
|
t.TEXTURE_2D,
|
|
3248
3260
|
0,
|
|
3249
3261
|
t.RGBA,
|
|
@@ -3259,7 +3271,7 @@ class Yi {
|
|
|
3259
3271
|
posBuffer: h,
|
|
3260
3272
|
termBuffer: g,
|
|
3261
3273
|
indexBuffer: d,
|
|
3262
|
-
paletteTexture:
|
|
3274
|
+
paletteTexture: p,
|
|
3263
3275
|
uCamera: o,
|
|
3264
3276
|
uPointSize: s,
|
|
3265
3277
|
uPalette: a,
|
|
@@ -3290,15 +3302,15 @@ class Yi {
|
|
|
3290
3302
|
return r ? (n.bindTexture(n.TEXTURE_2D, r), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, 1), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, n.LINEAR), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, n.LINEAR), n.texImage2D(n.TEXTURE_2D, 0, n.RGBA, n.RGBA, n.UNSIGNED_BYTE, t), n.bindTexture(n.TEXTURE_2D, null), r) : null;
|
|
3291
3303
|
}
|
|
3292
3304
|
}
|
|
3293
|
-
const Le = [],
|
|
3305
|
+
const Le = [], $i = [], Hi = {
|
|
3294
3306
|
count: 0,
|
|
3295
3307
|
positions: new Float32Array(0),
|
|
3296
3308
|
paletteIndices: new Uint16Array(0)
|
|
3297
|
-
},
|
|
3298
|
-
function
|
|
3309
|
+
}, Zi = 0.65, Ki = 4, ji = 24, Ji = 1024, Qi = 4;
|
|
3310
|
+
function to(e) {
|
|
3299
3311
|
return Math.max(0, Math.min(Math.floor(e.count ?? 0), Math.floor((e.positions?.length ?? 0) / 2), e.paletteIndices?.length ?? 0));
|
|
3300
3312
|
}
|
|
3301
|
-
function
|
|
3313
|
+
function eo(e, t) {
|
|
3302
3314
|
if (!(e instanceof Uint32Array) || t <= 0 || e.length === 0)
|
|
3303
3315
|
return null;
|
|
3304
3316
|
let n = !1;
|
|
@@ -3317,28 +3329,28 @@ function Ki(e, t) {
|
|
|
3317
3329
|
}
|
|
3318
3330
|
return r.subarray(0, i);
|
|
3319
3331
|
}
|
|
3320
|
-
function
|
|
3332
|
+
function no(e, t) {
|
|
3321
3333
|
if (!e || t <= 0) return 256;
|
|
3322
|
-
const n = Math.max(1, e.width * e.height), i = Math.sqrt(n / Math.max(1, t)) *
|
|
3323
|
-
return Math.max(
|
|
3334
|
+
const n = Math.max(1, e.width * e.height), i = Math.sqrt(n / Math.max(1, t)) * Qi;
|
|
3335
|
+
return Math.max(ji, Math.min(Ji, i));
|
|
3324
3336
|
}
|
|
3325
|
-
function
|
|
3337
|
+
function ro(e, t) {
|
|
3326
3338
|
if (!e || !e.positions || !e.paletteIndices)
|
|
3327
3339
|
return null;
|
|
3328
|
-
const n =
|
|
3340
|
+
const n = to(e);
|
|
3329
3341
|
if (n <= 0)
|
|
3330
3342
|
return null;
|
|
3331
|
-
const r = e.positions.subarray(0, n * 2), i = e.ids instanceof Uint32Array && e.ids.length >= n ? e.ids.subarray(0, n) : null, o =
|
|
3343
|
+
const r = e.positions.subarray(0, n * 2), i = e.ids instanceof Uint32Array && e.ids.length >= n ? e.ids.subarray(0, n) : null, o = eo(e.drawIndices, n), s = o ? o.length : n;
|
|
3332
3344
|
if (s === 0)
|
|
3333
3345
|
return null;
|
|
3334
|
-
const a =
|
|
3346
|
+
const a = no(t, s), u = /* @__PURE__ */ new Map(), c = (h) => {
|
|
3335
3347
|
const g = r[h * 2], d = r[h * 2 + 1];
|
|
3336
3348
|
if (!Number.isFinite(g) || !Number.isFinite(d)) return;
|
|
3337
|
-
const
|
|
3338
|
-
let
|
|
3339
|
-
|
|
3340
|
-
const
|
|
3341
|
-
|
|
3349
|
+
const p = Math.floor(g / a), x = Math.floor(d / a);
|
|
3350
|
+
let S = u.get(p);
|
|
3351
|
+
S || (S = /* @__PURE__ */ new Map(), u.set(p, S));
|
|
3352
|
+
const P = S.get(x);
|
|
3353
|
+
P ? P.push(h) : S.set(x, [h]);
|
|
3342
3354
|
};
|
|
3343
3355
|
if (o)
|
|
3344
3356
|
for (let h = 0; h < o.length; h += 1)
|
|
@@ -3354,10 +3366,10 @@ function Ji(e, t) {
|
|
|
3354
3366
|
buckets: u
|
|
3355
3367
|
};
|
|
3356
3368
|
}
|
|
3357
|
-
function
|
|
3369
|
+
function Ge(e, t) {
|
|
3358
3370
|
return e.id ?? t;
|
|
3359
3371
|
}
|
|
3360
|
-
function
|
|
3372
|
+
function io(e, t) {
|
|
3361
3373
|
if (!Array.isArray(t) || t.length < 3) return !1;
|
|
3362
3374
|
const [n, r] = e;
|
|
3363
3375
|
let i = !1;
|
|
@@ -3367,19 +3379,19 @@ function Qi(e, t) {
|
|
|
3367
3379
|
}
|
|
3368
3380
|
return i;
|
|
3369
3381
|
}
|
|
3370
|
-
function
|
|
3382
|
+
function De(e, t) {
|
|
3371
3383
|
for (let n = t.length - 1; n >= 0; n -= 1) {
|
|
3372
3384
|
const r = t[n];
|
|
3373
|
-
if (r?.coordinates?.length &&
|
|
3385
|
+
if (r?.coordinates?.length && io(e, r.coordinates))
|
|
3374
3386
|
return {
|
|
3375
3387
|
region: r,
|
|
3376
3388
|
regionIndex: n,
|
|
3377
|
-
regionId:
|
|
3389
|
+
regionId: Ge(r, n)
|
|
3378
3390
|
};
|
|
3379
3391
|
}
|
|
3380
3392
|
return null;
|
|
3381
3393
|
}
|
|
3382
|
-
function
|
|
3394
|
+
function yo({
|
|
3383
3395
|
source: e,
|
|
3384
3396
|
viewState: t,
|
|
3385
3397
|
onViewStateChange: n,
|
|
@@ -3393,44 +3405,44 @@ function mo({
|
|
|
3393
3405
|
rotationResetNonce: h = 0,
|
|
3394
3406
|
authToken: g = "",
|
|
3395
3407
|
ctrlDragRotate: d = !0,
|
|
3396
|
-
pointData:
|
|
3397
|
-
pointPalette:
|
|
3398
|
-
pointSizeByZoom:
|
|
3399
|
-
roiRegions:
|
|
3400
|
-
roiPolygons:
|
|
3401
|
-
clipPointsToRois:
|
|
3402
|
-
clipMode:
|
|
3403
|
-
onClipStats:
|
|
3404
|
-
onRoiPointGroups:
|
|
3408
|
+
pointData: p = null,
|
|
3409
|
+
pointPalette: x = null,
|
|
3410
|
+
pointSizeByZoom: S,
|
|
3411
|
+
roiRegions: P,
|
|
3412
|
+
roiPolygons: k,
|
|
3413
|
+
clipPointsToRois: C = !1,
|
|
3414
|
+
clipMode: E = "worker",
|
|
3415
|
+
onClipStats: D,
|
|
3416
|
+
onRoiPointGroups: J,
|
|
3405
3417
|
roiPaletteIndexToTermId: ft,
|
|
3406
|
-
interactionLock:
|
|
3407
|
-
drawTool:
|
|
3408
|
-
stampOptions:
|
|
3409
|
-
brushOptions:
|
|
3410
|
-
regionStrokeStyle:
|
|
3411
|
-
regionStrokeHoverStyle:
|
|
3412
|
-
regionStrokeActiveStyle:
|
|
3413
|
-
patchStrokeStyle:
|
|
3414
|
-
resolveRegionStrokeStyle:
|
|
3415
|
-
overlayShapes:
|
|
3416
|
-
customLayers:
|
|
3417
|
-
patchRegions:
|
|
3418
|
-
regionLabelStyle:
|
|
3419
|
-
onPointerWorldMove:
|
|
3418
|
+
interactionLock: at = !1,
|
|
3419
|
+
drawTool: $ = "cursor",
|
|
3420
|
+
stampOptions: ht,
|
|
3421
|
+
brushOptions: vt,
|
|
3422
|
+
regionStrokeStyle: Ot,
|
|
3423
|
+
regionStrokeHoverStyle: K,
|
|
3424
|
+
regionStrokeActiveStyle: Ct,
|
|
3425
|
+
patchStrokeStyle: zt,
|
|
3426
|
+
resolveRegionStrokeStyle: Kt,
|
|
3427
|
+
overlayShapes: dt,
|
|
3428
|
+
customLayers: Q,
|
|
3429
|
+
patchRegions: M,
|
|
3430
|
+
regionLabelStyle: I,
|
|
3431
|
+
onPointerWorldMove: A,
|
|
3420
3432
|
onPointHover: L,
|
|
3421
|
-
onPointClick:
|
|
3422
|
-
onRegionHover:
|
|
3423
|
-
onRegionClick:
|
|
3424
|
-
onActiveRegionChange:
|
|
3425
|
-
getCellByCoordinatesRef:
|
|
3426
|
-
onDrawComplete:
|
|
3427
|
-
onPatchComplete:
|
|
3428
|
-
showOverviewMap:
|
|
3429
|
-
overviewMapOptions:
|
|
3430
|
-
className:
|
|
3431
|
-
style:
|
|
3433
|
+
onPointClick: Z,
|
|
3434
|
+
onRegionHover: et,
|
|
3435
|
+
onRegionClick: mt,
|
|
3436
|
+
onActiveRegionChange: yt,
|
|
3437
|
+
getCellByCoordinatesRef: U,
|
|
3438
|
+
onDrawComplete: At,
|
|
3439
|
+
onPatchComplete: gt,
|
|
3440
|
+
showOverviewMap: N = !1,
|
|
3441
|
+
overviewMapOptions: G,
|
|
3442
|
+
className: ut,
|
|
3443
|
+
style: nt
|
|
3432
3444
|
}) {
|
|
3433
|
-
const
|
|
3445
|
+
const rt = j(null), q = j(null), It = j(null), _t = j(null), F = j(n), ct = j(r), ot = j(a), [Gt, Bt] = Jt(!0), [Ft, qt] = Jt(null), [pt, ue] = Jt(null), [ce, l] = Jt(null), [f, w] = Jt(null), y = j(null), R = j(null), v = j(null), Y = j(0), V = P ?? Le, W = M ?? Le, lt = k ?? $i, Pt = (Q?.length ?? 0) > 0, $t = tt(() => ({ position: "relative", width: "100%", height: "100%", ...nt }), [nt]), xt = tt(
|
|
3434
3446
|
() => ({
|
|
3435
3447
|
position: "absolute",
|
|
3436
3448
|
top: 8,
|
|
@@ -3452,56 +3464,56 @@ function mo({
|
|
|
3452
3464
|
...u
|
|
3453
3465
|
}),
|
|
3454
3466
|
[u]
|
|
3455
|
-
),
|
|
3456
|
-
id:
|
|
3457
|
-
coordinates:
|
|
3458
|
-
})), [
|
|
3467
|
+
), H = tt(() => V.length > 0 ? V : lt.length === 0 ? Le : lt.map((m, T) => ({
|
|
3468
|
+
id: T,
|
|
3469
|
+
coordinates: m
|
|
3470
|
+
})), [V, lt]), St = tt(() => H.map((m) => m.coordinates), [H]), [Tt, le] = Jt(p);
|
|
3459
3471
|
X(() => {
|
|
3460
|
-
const
|
|
3461
|
-
let
|
|
3462
|
-
if (!
|
|
3463
|
-
return
|
|
3464
|
-
|
|
3472
|
+
const m = ++Y.current;
|
|
3473
|
+
let T = !1;
|
|
3474
|
+
if (!C)
|
|
3475
|
+
return le(p), () => {
|
|
3476
|
+
T = !0;
|
|
3465
3477
|
};
|
|
3466
|
-
if (!
|
|
3467
|
-
return
|
|
3468
|
-
|
|
3478
|
+
if (!p || !p.count || !p.positions || !p.paletteIndices)
|
|
3479
|
+
return le(null), () => {
|
|
3480
|
+
T = !0;
|
|
3469
3481
|
};
|
|
3470
|
-
if (
|
|
3471
|
-
return
|
|
3472
|
-
mode:
|
|
3482
|
+
if (St.length === 0)
|
|
3483
|
+
return le(Hi), D?.({
|
|
3484
|
+
mode: E,
|
|
3473
3485
|
durationMs: 0,
|
|
3474
|
-
inputCount:
|
|
3486
|
+
inputCount: p.count,
|
|
3475
3487
|
outputCount: 0,
|
|
3476
3488
|
polygonCount: 0
|
|
3477
3489
|
}), () => {
|
|
3478
|
-
|
|
3490
|
+
T = !0;
|
|
3479
3491
|
};
|
|
3480
|
-
const _ = (z,
|
|
3481
|
-
if (
|
|
3482
|
-
const
|
|
3483
|
-
|
|
3484
|
-
mode:
|
|
3485
|
-
durationMs:
|
|
3486
|
-
inputCount:
|
|
3487
|
-
outputCount:
|
|
3488
|
-
polygonCount:
|
|
3489
|
-
usedWebGpu:
|
|
3490
|
-
candidateCount:
|
|
3491
|
-
bridgedToDraw:
|
|
3492
|
+
const _ = (z, st) => {
|
|
3493
|
+
if (T || m !== Y.current) return;
|
|
3494
|
+
const de = z?.drawIndices ? z.drawIndices.length : z?.count ?? 0;
|
|
3495
|
+
le(z), D?.({
|
|
3496
|
+
mode: st.mode,
|
|
3497
|
+
durationMs: st.durationMs,
|
|
3498
|
+
inputCount: p.count,
|
|
3499
|
+
outputCount: de,
|
|
3500
|
+
polygonCount: St.length,
|
|
3501
|
+
usedWebGpu: st.usedWebGpu,
|
|
3502
|
+
candidateCount: st.candidateCount,
|
|
3503
|
+
bridgedToDraw: st.bridgedToDraw
|
|
3492
3504
|
});
|
|
3493
3505
|
};
|
|
3494
3506
|
return (async () => {
|
|
3495
|
-
if (
|
|
3496
|
-
const z = performance.now(),
|
|
3497
|
-
_(
|
|
3507
|
+
if (E === "sync") {
|
|
3508
|
+
const z = performance.now(), st = Ee(p, St);
|
|
3509
|
+
_(st, {
|
|
3498
3510
|
mode: "sync",
|
|
3499
3511
|
durationMs: performance.now() - z
|
|
3500
3512
|
});
|
|
3501
3513
|
return;
|
|
3502
3514
|
}
|
|
3503
|
-
if (
|
|
3504
|
-
const z = await
|
|
3515
|
+
if (E === "hybrid-webgpu") {
|
|
3516
|
+
const z = await Bi(p, St, { bridgeToDraw: !0 });
|
|
3505
3517
|
_(z.data, {
|
|
3506
3518
|
mode: z.meta.mode,
|
|
3507
3519
|
durationMs: z.meta.durationMs,
|
|
@@ -3512,209 +3524,209 @@ function mo({
|
|
|
3512
3524
|
return;
|
|
3513
3525
|
}
|
|
3514
3526
|
try {
|
|
3515
|
-
const z = await
|
|
3527
|
+
const z = await Fi(p, St);
|
|
3516
3528
|
_(z.data, {
|
|
3517
3529
|
mode: z.meta.mode,
|
|
3518
3530
|
durationMs: z.meta.durationMs
|
|
3519
3531
|
});
|
|
3520
3532
|
} catch {
|
|
3521
|
-
const z = performance.now(),
|
|
3522
|
-
_(
|
|
3533
|
+
const z = performance.now(), st = Ee(p, St);
|
|
3534
|
+
_(st, {
|
|
3523
3535
|
mode: "sync",
|
|
3524
3536
|
durationMs: performance.now() - z
|
|
3525
3537
|
});
|
|
3526
3538
|
}
|
|
3527
3539
|
})(), () => {
|
|
3528
|
-
|
|
3540
|
+
T = !0;
|
|
3529
3541
|
};
|
|
3530
|
-
}, [
|
|
3531
|
-
const
|
|
3532
|
-
(
|
|
3533
|
-
const
|
|
3534
|
-
if (!
|
|
3535
|
-
const _ = Number(
|
|
3536
|
-
if (!Number.isFinite(_) || !Number.isFinite(
|
|
3537
|
-
const z = Math.max(1e-6,
|
|
3542
|
+
}, [C, E, p, St, D]);
|
|
3543
|
+
const He = !!(L || Z || U), Mt = tt(() => He ? ro(Tt, e) : null, [He, Tt, e]), Ht = B(
|
|
3544
|
+
(m) => {
|
|
3545
|
+
const T = q.current;
|
|
3546
|
+
if (!T || !Mt) return null;
|
|
3547
|
+
const _ = Number(m[0]), O = Number(m[1]);
|
|
3548
|
+
if (!Number.isFinite(_) || !Number.isFinite(O)) return null;
|
|
3549
|
+
const z = Math.max(1e-6, T.getViewState().zoom), st = T.getPointSizeByZoom(), re = Math.max(Ki, st * Zi) / z;
|
|
3538
3550
|
if (!Number.isFinite(re) || re <= 0) return null;
|
|
3539
|
-
const Re =
|
|
3540
|
-
let
|
|
3541
|
-
for (let
|
|
3542
|
-
const
|
|
3543
|
-
if (
|
|
3544
|
-
for (let Ce =
|
|
3545
|
-
const
|
|
3546
|
-
if (!(!
|
|
3547
|
-
for (let Ie = 0; Ie <
|
|
3548
|
-
const
|
|
3549
|
-
if (
|
|
3550
|
-
const
|
|
3551
|
-
|
|
3551
|
+
const Re = Mt.cellSize, nn = Math.floor(_ / Re), rn = Math.floor(O / Re), me = Math.max(1, Math.ceil(re / Re)), er = re * re;
|
|
3552
|
+
let ge = -1, on = er, sn = 0, an = 0;
|
|
3553
|
+
for (let ve = nn - me; ve <= nn + me; ve += 1) {
|
|
3554
|
+
const un = Mt.buckets.get(ve);
|
|
3555
|
+
if (un)
|
|
3556
|
+
for (let Ce = rn - me; Ce <= rn + me; Ce += 1) {
|
|
3557
|
+
const pe = un.get(Ce);
|
|
3558
|
+
if (!(!pe || pe.length === 0))
|
|
3559
|
+
for (let Ie = 0; Ie < pe.length; Ie += 1) {
|
|
3560
|
+
const be = pe[Ie];
|
|
3561
|
+
if (be >= Mt.safeCount) continue;
|
|
3562
|
+
const cn = Mt.positions[be * 2], ln = Mt.positions[be * 2 + 1], hn = cn - _, fn = ln - O, dn = hn * hn + fn * fn;
|
|
3563
|
+
dn > on || (on = dn, ge = be, sn = cn, an = ln);
|
|
3552
3564
|
}
|
|
3553
3565
|
}
|
|
3554
3566
|
}
|
|
3555
|
-
if (
|
|
3556
|
-
const
|
|
3567
|
+
if (ge < 0) return null;
|
|
3568
|
+
const nr = Mt.ids ? Number(Mt.ids[ge]) : null;
|
|
3557
3569
|
return {
|
|
3558
|
-
index:
|
|
3559
|
-
id:
|
|
3560
|
-
coordinate: [_,
|
|
3561
|
-
pointCoordinate: [
|
|
3570
|
+
index: ge,
|
|
3571
|
+
id: nr,
|
|
3572
|
+
coordinate: [_, O],
|
|
3573
|
+
pointCoordinate: [sn, an]
|
|
3562
3574
|
};
|
|
3563
3575
|
},
|
|
3564
|
-
[
|
|
3565
|
-
), jt =
|
|
3566
|
-
(
|
|
3576
|
+
[Mt]
|
|
3577
|
+
), jt = B(
|
|
3578
|
+
(m, T) => {
|
|
3567
3579
|
if (!L) return;
|
|
3568
|
-
const _ =
|
|
3569
|
-
|
|
3580
|
+
const _ = m?.index ?? null, O = m?.id ?? null;
|
|
3581
|
+
R.current === _ && v.current === O || (R.current = _, v.current = O, L({
|
|
3570
3582
|
index: _,
|
|
3571
|
-
id:
|
|
3572
|
-
coordinate:
|
|
3573
|
-
pointCoordinate:
|
|
3583
|
+
id: O,
|
|
3584
|
+
coordinate: T,
|
|
3585
|
+
pointCoordinate: m?.pointCoordinate ?? null
|
|
3574
3586
|
}));
|
|
3575
3587
|
},
|
|
3576
3588
|
[L]
|
|
3577
|
-
),
|
|
3578
|
-
(
|
|
3579
|
-
if (
|
|
3580
|
-
const _ = Ht(
|
|
3581
|
-
_ &&
|
|
3589
|
+
), he = B(
|
|
3590
|
+
(m, T) => {
|
|
3591
|
+
if (!Z) return;
|
|
3592
|
+
const _ = Ht(m);
|
|
3593
|
+
_ && Z({
|
|
3582
3594
|
..._,
|
|
3583
|
-
button:
|
|
3595
|
+
button: T
|
|
3584
3596
|
});
|
|
3585
3597
|
},
|
|
3586
|
-
[
|
|
3598
|
+
[Z, Ht]
|
|
3587
3599
|
);
|
|
3588
|
-
|
|
3589
|
-
const
|
|
3590
|
-
return Number.isFinite(
|
|
3591
|
-
}, [
|
|
3592
|
-
const
|
|
3593
|
-
const
|
|
3594
|
-
return Number.isFinite(
|
|
3595
|
-
}, [
|
|
3596
|
-
const
|
|
3597
|
-
return Number.isFinite(
|
|
3598
|
-
}, [
|
|
3600
|
+
tt(() => {
|
|
3601
|
+
const m = Number(G?.width ?? 220);
|
|
3602
|
+
return Number.isFinite(m) ? Math.max(64, m) : 220;
|
|
3603
|
+
}, [G?.width]);
|
|
3604
|
+
const Ze = tt(() => {
|
|
3605
|
+
const m = Number(G?.height ?? 140);
|
|
3606
|
+
return Number.isFinite(m) ? Math.max(48, m) : 140;
|
|
3607
|
+
}, [G?.height]), Dt = tt(() => {
|
|
3608
|
+
const m = Number(G?.margin ?? 16);
|
|
3609
|
+
return Number.isFinite(m) ? Math.max(0, m) : 16;
|
|
3610
|
+
}, [G?.margin]), fe = G?.position || "bottom-right";
|
|
3599
3611
|
X(() => {
|
|
3600
|
-
if (
|
|
3601
|
-
return
|
|
3602
|
-
|
|
3612
|
+
if (U)
|
|
3613
|
+
return U.current = Ht, () => {
|
|
3614
|
+
U.current === Ht && (U.current = null);
|
|
3603
3615
|
};
|
|
3604
|
-
}, [
|
|
3605
|
-
const
|
|
3606
|
-
(
|
|
3607
|
-
|
|
3616
|
+
}, [U, Ht]);
|
|
3617
|
+
const Nt = B(
|
|
3618
|
+
(m) => {
|
|
3619
|
+
ue((T) => String(T) === String(m) ? T : (yt?.(m), m));
|
|
3608
3620
|
},
|
|
3609
|
-
[
|
|
3621
|
+
[yt]
|
|
3610
3622
|
);
|
|
3611
3623
|
X(() => {
|
|
3612
|
-
|
|
3624
|
+
F.current = n;
|
|
3613
3625
|
}, [n]), X(() => {
|
|
3614
|
-
|
|
3626
|
+
ct.current = r;
|
|
3615
3627
|
}, [r]), X(() => {
|
|
3616
|
-
|
|
3628
|
+
ot.current = a, a || w(null);
|
|
3617
3629
|
}, [a]);
|
|
3618
|
-
const
|
|
3619
|
-
|
|
3620
|
-
}, []), Zn =
|
|
3621
|
-
`tier ${
|
|
3622
|
-
`tiles visible ${
|
|
3623
|
-
`cache size ${
|
|
3624
|
-
`queue inflight ${
|
|
3625
|
-
`points ${
|
|
3630
|
+
const Ke = B((m) => {
|
|
3631
|
+
ct.current?.(m), ot.current && w(m);
|
|
3632
|
+
}, []), Zn = tt(() => f ? [
|
|
3633
|
+
`tier ${f.tier} | frame ${f.frameMs?.toFixed(2) ?? "-"} ms | drawCalls ${f.drawCalls ?? "-"}`,
|
|
3634
|
+
`tiles visible ${f.visible} | rendered ${f.rendered} | fallback ${f.fallback}`,
|
|
3635
|
+
`cache size ${f.cache} | hit ${f.cacheHits ?? "-"} | miss ${f.cacheMisses ?? "-"}`,
|
|
3636
|
+
`queue inflight ${f.inflight} | queued ${f.queued ?? "-"} | retries ${f.retries ?? "-"} | failed ${f.failed ?? "-"} | aborted ${f.aborted ?? "-"}`,
|
|
3637
|
+
`points ${f.points}`
|
|
3626
3638
|
].join(`
|
|
3627
|
-
`) : "stats: waiting for first frame...", [
|
|
3639
|
+
`) : "stats: waiting for first frame...", [f]);
|
|
3628
3640
|
X(() => {
|
|
3629
|
-
!(
|
|
3630
|
-
const
|
|
3631
|
-
!(
|
|
3641
|
+
!(pt === null ? !0 : H.some((O, z) => String(Ge(O, z)) === String(pt))) && pt !== null && Nt(null);
|
|
3642
|
+
const T = y.current;
|
|
3643
|
+
!(T === null ? !0 : H.some((O, z) => String(Ge(O, z)) === String(T))) && T !== null && (y.current = null, qt(null), et?.({
|
|
3632
3644
|
region: null,
|
|
3633
3645
|
regionId: null,
|
|
3634
3646
|
regionIndex: -1,
|
|
3635
3647
|
coordinate: null
|
|
3636
3648
|
}));
|
|
3637
|
-
}, [
|
|
3638
|
-
const
|
|
3639
|
-
|
|
3649
|
+
}, [H, pt, et, Nt]), X(() => {
|
|
3650
|
+
const m = R.current;
|
|
3651
|
+
m !== null && (Mt && m < Mt.safeCount || (R.current = null, v.current = null, L?.({
|
|
3640
3652
|
index: null,
|
|
3641
3653
|
id: null,
|
|
3642
3654
|
coordinate: null,
|
|
3643
3655
|
pointCoordinate: null
|
|
3644
3656
|
})));
|
|
3645
|
-
}, [
|
|
3646
|
-
const
|
|
3647
|
-
(
|
|
3648
|
-
|
|
3649
|
-
const
|
|
3650
|
-
|
|
3657
|
+
}, [Mt, L]);
|
|
3658
|
+
const je = B(
|
|
3659
|
+
(m) => {
|
|
3660
|
+
Pt && l(m);
|
|
3661
|
+
const T = F.current;
|
|
3662
|
+
T && T(m), It.current?.(), _t.current?.();
|
|
3651
3663
|
},
|
|
3652
|
-
[
|
|
3664
|
+
[Pt]
|
|
3653
3665
|
);
|
|
3654
3666
|
X(() => {
|
|
3655
|
-
if (!
|
|
3656
|
-
|
|
3667
|
+
if (!N) {
|
|
3668
|
+
Bt(!1);
|
|
3657
3669
|
return;
|
|
3658
3670
|
}
|
|
3659
|
-
|
|
3660
|
-
}, [
|
|
3661
|
-
|
|
3671
|
+
Bt(!0);
|
|
3672
|
+
}, [N, e?.id]), X(() => {
|
|
3673
|
+
$ !== "cursor" && y.current !== null && (y.current = null, qt(null), et?.({
|
|
3662
3674
|
region: null,
|
|
3663
3675
|
regionId: null,
|
|
3664
3676
|
regionIndex: -1,
|
|
3665
3677
|
coordinate: null
|
|
3666
3678
|
}));
|
|
3667
|
-
}, [
|
|
3668
|
-
|
|
3679
|
+
}, [$, et]), X(() => {
|
|
3680
|
+
$ !== "cursor" && R.current !== null && (R.current = null, v.current = null, L?.({
|
|
3669
3681
|
index: null,
|
|
3670
3682
|
id: null,
|
|
3671
3683
|
coordinate: null,
|
|
3672
3684
|
pointCoordinate: null
|
|
3673
3685
|
}));
|
|
3674
|
-
}, [
|
|
3675
|
-
const
|
|
3676
|
-
const _ =
|
|
3686
|
+
}, [$, L]);
|
|
3687
|
+
const kt = B((m, T) => {
|
|
3688
|
+
const _ = q.current;
|
|
3677
3689
|
if (!_) return null;
|
|
3678
|
-
const
|
|
3679
|
-
if (!Array.isArray(
|
|
3680
|
-
const z = Number(
|
|
3681
|
-
return !Number.isFinite(z) || !Number.isFinite(
|
|
3682
|
-
}, []),
|
|
3683
|
-
const _ =
|
|
3690
|
+
const O = _.screenToWorld(m, T);
|
|
3691
|
+
if (!Array.isArray(O) || O.length < 2) return null;
|
|
3692
|
+
const z = Number(O[0]), st = Number(O[1]);
|
|
3693
|
+
return !Number.isFinite(z) || !Number.isFinite(st) ? null : [z, st];
|
|
3694
|
+
}, []), Je = B((m, T) => {
|
|
3695
|
+
const _ = q.current;
|
|
3684
3696
|
if (!_) return null;
|
|
3685
|
-
const
|
|
3686
|
-
if (!Array.isArray(
|
|
3687
|
-
const z = Number(
|
|
3688
|
-
return !Number.isFinite(z) || !Number.isFinite(
|
|
3689
|
-
}, []),
|
|
3690
|
-
|
|
3691
|
-
}, []),
|
|
3697
|
+
const O = _.worldToScreen(m, T);
|
|
3698
|
+
if (!Array.isArray(O) || O.length < 2) return null;
|
|
3699
|
+
const z = Number(O[0]), st = Number(O[1]);
|
|
3700
|
+
return !Number.isFinite(z) || !Number.isFinite(st) ? null : [z, st];
|
|
3701
|
+
}, []), Qe = B(() => {
|
|
3702
|
+
q.current?.requestRender(), It.current?.(), _t.current?.();
|
|
3703
|
+
}, []), tn = tt(() => ce ?? q.current?.getViewState() ?? null, [ce]), en = tt(() => {
|
|
3692
3704
|
if (!e) return null;
|
|
3693
|
-
const
|
|
3694
|
-
return
|
|
3705
|
+
const m = tn;
|
|
3706
|
+
return m ? {
|
|
3695
3707
|
source: e,
|
|
3696
|
-
viewState:
|
|
3697
|
-
drawTool:
|
|
3698
|
-
interactionLock:
|
|
3699
|
-
worldToScreen:
|
|
3700
|
-
screenToWorld:
|
|
3701
|
-
requestRedraw:
|
|
3708
|
+
viewState: m,
|
|
3709
|
+
drawTool: $,
|
|
3710
|
+
interactionLock: at,
|
|
3711
|
+
worldToScreen: Je,
|
|
3712
|
+
screenToWorld: kt,
|
|
3713
|
+
requestRedraw: Qe
|
|
3702
3714
|
} : null;
|
|
3703
|
-
}, [e,
|
|
3704
|
-
(
|
|
3705
|
-
const
|
|
3706
|
-
if (
|
|
3707
|
-
const
|
|
3708
|
-
|
|
3715
|
+
}, [e, tn, $, at, Je, kt, Qe]), Kn = B(
|
|
3716
|
+
(m) => {
|
|
3717
|
+
const T = m.target === rt.current, _ = kt(m.clientX, m.clientY);
|
|
3718
|
+
if (A) {
|
|
3719
|
+
const de = !!_ && _[0] >= 0 && _[1] >= 0 && !!e && _[0] <= e.width && _[1] <= e.height;
|
|
3720
|
+
A({
|
|
3709
3721
|
coordinate: _,
|
|
3710
|
-
clientX:
|
|
3711
|
-
clientY:
|
|
3712
|
-
insideImage:
|
|
3722
|
+
clientX: m.clientX,
|
|
3723
|
+
clientY: m.clientY,
|
|
3724
|
+
insideImage: de
|
|
3713
3725
|
});
|
|
3714
3726
|
}
|
|
3715
|
-
if (
|
|
3716
|
-
if (!
|
|
3717
|
-
jt(null, null),
|
|
3727
|
+
if ($ !== "cursor") return;
|
|
3728
|
+
if (!T) {
|
|
3729
|
+
jt(null, null), y.current !== null && (y.current = null, qt(null), et?.({
|
|
3718
3730
|
region: null,
|
|
3719
3731
|
regionId: null,
|
|
3720
3732
|
regionIndex: -1,
|
|
@@ -3726,110 +3738,124 @@ function mo({
|
|
|
3726
3738
|
jt(null, null);
|
|
3727
3739
|
return;
|
|
3728
3740
|
}
|
|
3729
|
-
if (L && jt(Ht(_), _), !
|
|
3730
|
-
const
|
|
3731
|
-
String(
|
|
3732
|
-
region:
|
|
3741
|
+
if (L && jt(Ht(_), _), !H.length) return;
|
|
3742
|
+
const O = De(_, H), z = O?.regionId ?? null, st = y.current;
|
|
3743
|
+
String(st) !== String(z) && (y.current = z, qt(z), et?.({
|
|
3744
|
+
region: O?.region ?? null,
|
|
3733
3745
|
regionId: z,
|
|
3734
|
-
regionIndex:
|
|
3746
|
+
regionIndex: O?.regionIndex ?? -1,
|
|
3735
3747
|
coordinate: _
|
|
3736
3748
|
}));
|
|
3737
3749
|
},
|
|
3738
|
-
[
|
|
3739
|
-
), jn =
|
|
3740
|
-
|
|
3750
|
+
[$, H, kt, et, A, e, jt, Ht, L]
|
|
3751
|
+
), jn = B(() => {
|
|
3752
|
+
A?.({
|
|
3741
3753
|
coordinate: null,
|
|
3742
3754
|
clientX: -1,
|
|
3743
3755
|
clientY: -1,
|
|
3744
3756
|
insideImage: !1
|
|
3745
|
-
}), jt(null, null),
|
|
3757
|
+
}), jt(null, null), y.current !== null && (y.current = null, qt(null), et?.({
|
|
3746
3758
|
region: null,
|
|
3747
3759
|
regionId: null,
|
|
3748
3760
|
regionIndex: -1,
|
|
3749
3761
|
coordinate: null
|
|
3750
3762
|
}));
|
|
3751
|
-
}, [
|
|
3752
|
-
(
|
|
3753
|
-
if (
|
|
3754
|
-
const
|
|
3755
|
-
if (!
|
|
3756
|
-
if (
|
|
3757
|
-
|
|
3763
|
+
}, [et, A, jt]), Jn = B(
|
|
3764
|
+
(m) => {
|
|
3765
|
+
if ($ !== "cursor" || m.target !== rt.current) return;
|
|
3766
|
+
const T = kt(m.clientX, m.clientY);
|
|
3767
|
+
if (!T) return;
|
|
3768
|
+
if (he(T, m.button), !H.length) {
|
|
3769
|
+
Nt(null);
|
|
3758
3770
|
return;
|
|
3759
3771
|
}
|
|
3760
|
-
const _ =
|
|
3772
|
+
const _ = De(T, H);
|
|
3761
3773
|
if (!_) {
|
|
3762
|
-
|
|
3774
|
+
Nt(null);
|
|
3763
3775
|
return;
|
|
3764
3776
|
}
|
|
3765
|
-
const
|
|
3766
|
-
|
|
3777
|
+
const O = pt !== null && String(pt) === String(_.regionId) ? null : _.regionId;
|
|
3778
|
+
Nt(O), mt?.({
|
|
3767
3779
|
region: _.region,
|
|
3768
3780
|
regionId: _.regionId,
|
|
3769
3781
|
regionIndex: _.regionIndex,
|
|
3770
|
-
coordinate:
|
|
3782
|
+
coordinate: T
|
|
3771
3783
|
});
|
|
3772
3784
|
},
|
|
3773
|
-
[
|
|
3774
|
-
), Qn =
|
|
3775
|
-
(
|
|
3776
|
-
if (
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3785
|
+
[$, H, kt, mt, pt, Nt, he]
|
|
3786
|
+
), Qn = B(
|
|
3787
|
+
(m) => {
|
|
3788
|
+
if ($ !== "brush" || vt?.clickSelectRoi !== !0 || !H.length) return !1;
|
|
3789
|
+
const T = De(m, H);
|
|
3790
|
+
if (!T) return !1;
|
|
3791
|
+
const _ = pt !== null && String(pt) === String(T.regionId) ? null : T.regionId;
|
|
3792
|
+
return Nt(_), mt?.({
|
|
3793
|
+
region: T.region,
|
|
3794
|
+
regionId: T.regionId,
|
|
3795
|
+
regionIndex: T.regionIndex,
|
|
3796
|
+
coordinate: m
|
|
3797
|
+
}), !0;
|
|
3798
|
+
},
|
|
3799
|
+
[$, vt?.clickSelectRoi, H, pt, Nt, mt]
|
|
3800
|
+
), tr = B(
|
|
3801
|
+
(m) => {
|
|
3802
|
+
if (!Z || $ !== "cursor" || m.target !== rt.current) return;
|
|
3803
|
+
m.preventDefault();
|
|
3804
|
+
const T = kt(m.clientX, m.clientY);
|
|
3805
|
+
T && he(T, m.button);
|
|
3780
3806
|
},
|
|
3781
|
-
[
|
|
3807
|
+
[$, kt, he, Z]
|
|
3782
3808
|
);
|
|
3783
3809
|
return X(() => {
|
|
3784
|
-
const
|
|
3785
|
-
if (!
|
|
3810
|
+
const m = rt.current;
|
|
3811
|
+
if (!m || !e)
|
|
3786
3812
|
return;
|
|
3787
|
-
const
|
|
3788
|
-
onViewStateChange:
|
|
3789
|
-
onStats:
|
|
3813
|
+
const T = new qi(m, e, {
|
|
3814
|
+
onViewStateChange: je,
|
|
3815
|
+
onStats: Ke,
|
|
3790
3816
|
onTileError: i,
|
|
3791
3817
|
onContextLost: o,
|
|
3792
3818
|
onContextRestored: s,
|
|
3793
3819
|
authToken: g,
|
|
3794
3820
|
ctrlDragRotate: d,
|
|
3795
|
-
pointSizeByZoom:
|
|
3821
|
+
pointSizeByZoom: S
|
|
3796
3822
|
});
|
|
3797
|
-
return
|
|
3798
|
-
|
|
3823
|
+
return q.current = T, t && T.setViewState(t), T.setInteractionLock(at), Pt && l(T.getViewState()), () => {
|
|
3824
|
+
T.destroy(), q.current = null;
|
|
3799
3825
|
};
|
|
3800
|
-
}, [e,
|
|
3801
|
-
const
|
|
3802
|
-
!
|
|
3826
|
+
}, [e, Ke, i, o, s, g, d, S, je, Pt]), X(() => {
|
|
3827
|
+
const m = q.current;
|
|
3828
|
+
!m || !t || m.setViewState(t);
|
|
3803
3829
|
}, [t]), X(() => {
|
|
3804
|
-
const
|
|
3805
|
-
|
|
3830
|
+
const m = q.current;
|
|
3831
|
+
m && m.fitToImage();
|
|
3806
3832
|
}, [c]), X(() => {
|
|
3807
|
-
const
|
|
3808
|
-
|
|
3833
|
+
const m = q.current;
|
|
3834
|
+
m && m.resetRotation();
|
|
3809
3835
|
}, [h]), X(() => {
|
|
3810
|
-
const
|
|
3811
|
-
!
|
|
3812
|
-
}, [y]), X(() => {
|
|
3813
|
-
const p = O.current;
|
|
3814
|
-
p && p.setPointSizeByZoom(x);
|
|
3836
|
+
const m = q.current;
|
|
3837
|
+
!m || !x || m.setPointPalette(x);
|
|
3815
3838
|
}, [x]), X(() => {
|
|
3816
|
-
const
|
|
3817
|
-
|
|
3818
|
-
}, [
|
|
3819
|
-
|
|
3820
|
-
|
|
3839
|
+
const m = q.current;
|
|
3840
|
+
m && m.setPointSizeByZoom(S);
|
|
3841
|
+
}, [S]), X(() => {
|
|
3842
|
+
const m = q.current;
|
|
3843
|
+
m && m.setPointData(Tt);
|
|
3844
|
+
}, [Tt]), X(() => {
|
|
3845
|
+
if (!J) return;
|
|
3846
|
+
const T = ki(C ? Tt : p, H, {
|
|
3821
3847
|
paletteIndexToTermId: ft,
|
|
3822
3848
|
includeEmptyRegions: !0
|
|
3823
3849
|
});
|
|
3824
|
-
|
|
3825
|
-
}, [
|
|
3826
|
-
const
|
|
3827
|
-
|
|
3828
|
-
}, [
|
|
3829
|
-
/* @__PURE__ */
|
|
3850
|
+
J(T);
|
|
3851
|
+
}, [J, C, p, Tt, H, ft]), X(() => {
|
|
3852
|
+
const m = q.current;
|
|
3853
|
+
m && m.setInteractionLock(at);
|
|
3854
|
+
}, [at]), /* @__PURE__ */ mn("div", { className: ut, style: $t, onPointerMove: Kn, onPointerLeave: jn, onClick: Jn, onContextMenu: tr, children: [
|
|
3855
|
+
/* @__PURE__ */ Ut(
|
|
3830
3856
|
"canvas",
|
|
3831
3857
|
{
|
|
3832
|
-
ref:
|
|
3858
|
+
ref: rt,
|
|
3833
3859
|
className: "wsi-render-canvas",
|
|
3834
3860
|
style: {
|
|
3835
3861
|
position: "absolute",
|
|
@@ -3839,68 +3865,69 @@ function mo({
|
|
|
3839
3865
|
height: "100%",
|
|
3840
3866
|
display: "block",
|
|
3841
3867
|
touchAction: "none",
|
|
3842
|
-
cursor:
|
|
3868
|
+
cursor: $ === "cursor" && Ft !== null ? "pointer" : at ? "crosshair" : "grab"
|
|
3843
3869
|
}
|
|
3844
3870
|
}
|
|
3845
3871
|
),
|
|
3846
|
-
e &&
|
|
3872
|
+
e && en && Array.isArray(Q) && Q.length > 0 ? Q.map((m, T) => /* @__PURE__ */ Ut(
|
|
3847
3873
|
"div",
|
|
3848
3874
|
{
|
|
3849
|
-
className:
|
|
3875
|
+
className: m.className,
|
|
3850
3876
|
style: {
|
|
3851
3877
|
position: "absolute",
|
|
3852
3878
|
inset: 0,
|
|
3853
|
-
zIndex:
|
|
3854
|
-
pointerEvents:
|
|
3855
|
-
...
|
|
3879
|
+
zIndex: m.zIndex ?? 3,
|
|
3880
|
+
pointerEvents: m.pointerEvents ?? "none",
|
|
3881
|
+
...m.style
|
|
3856
3882
|
},
|
|
3857
|
-
children:
|
|
3883
|
+
children: m.render(en)
|
|
3858
3884
|
},
|
|
3859
|
-
|
|
3885
|
+
m.id ?? T
|
|
3860
3886
|
)) : null,
|
|
3861
|
-
e ? /* @__PURE__ */
|
|
3862
|
-
|
|
3887
|
+
e ? /* @__PURE__ */ Ut(
|
|
3888
|
+
gi,
|
|
3863
3889
|
{
|
|
3864
|
-
tool:
|
|
3865
|
-
enabled:
|
|
3890
|
+
tool: $,
|
|
3891
|
+
enabled: $ !== "cursor",
|
|
3866
3892
|
imageWidth: e.width,
|
|
3867
3893
|
imageHeight: e.height,
|
|
3868
3894
|
imageMpp: e.mpp,
|
|
3869
3895
|
imageZoom: e.maxTierZoom,
|
|
3870
|
-
stampOptions:
|
|
3871
|
-
brushOptions:
|
|
3872
|
-
projectorRef:
|
|
3896
|
+
stampOptions: ht,
|
|
3897
|
+
brushOptions: vt,
|
|
3898
|
+
projectorRef: q,
|
|
3899
|
+
onBrushTap: Qn,
|
|
3873
3900
|
viewStateSignal: t,
|
|
3874
|
-
persistedRegions:
|
|
3875
|
-
patchRegions:
|
|
3876
|
-
regionStrokeStyle:
|
|
3877
|
-
regionStrokeHoverStyle:
|
|
3878
|
-
regionStrokeActiveStyle:
|
|
3879
|
-
patchStrokeStyle:
|
|
3880
|
-
resolveRegionStrokeStyle:
|
|
3881
|
-
overlayShapes:
|
|
3882
|
-
hoveredRegionId:
|
|
3883
|
-
activeRegionId:
|
|
3884
|
-
regionLabelStyle:
|
|
3901
|
+
persistedRegions: H,
|
|
3902
|
+
patchRegions: W,
|
|
3903
|
+
regionStrokeStyle: Ot,
|
|
3904
|
+
regionStrokeHoverStyle: K,
|
|
3905
|
+
regionStrokeActiveStyle: Ct,
|
|
3906
|
+
patchStrokeStyle: zt,
|
|
3907
|
+
resolveRegionStrokeStyle: Kt,
|
|
3908
|
+
overlayShapes: dt,
|
|
3909
|
+
hoveredRegionId: Ft,
|
|
3910
|
+
activeRegionId: pt,
|
|
3911
|
+
regionLabelStyle: I,
|
|
3885
3912
|
invalidateRef: It,
|
|
3886
|
-
onDrawComplete:
|
|
3887
|
-
onPatchComplete:
|
|
3913
|
+
onDrawComplete: At,
|
|
3914
|
+
onPatchComplete: gt
|
|
3888
3915
|
}
|
|
3889
3916
|
) : null,
|
|
3890
|
-
a ? /* @__PURE__ */
|
|
3891
|
-
e &&
|
|
3892
|
-
/* @__PURE__ */
|
|
3893
|
-
/* @__PURE__ */
|
|
3917
|
+
a ? /* @__PURE__ */ Ut("pre", { "data-open-plant-debug-overlay": !0, style: xt, children: Zn }) : null,
|
|
3918
|
+
e && N ? Gt ? /* @__PURE__ */ mn(or, { children: [
|
|
3919
|
+
/* @__PURE__ */ Ut(bi, { source: e, projectorRef: q, authToken: g, options: G, invalidateRef: _t }),
|
|
3920
|
+
/* @__PURE__ */ Ut(
|
|
3894
3921
|
"button",
|
|
3895
3922
|
{
|
|
3896
3923
|
type: "button",
|
|
3897
3924
|
"aria-label": "Hide overview map",
|
|
3898
|
-
onClick: () =>
|
|
3925
|
+
onClick: () => Bt(!1),
|
|
3899
3926
|
style: {
|
|
3900
3927
|
position: "absolute",
|
|
3901
3928
|
zIndex: 6,
|
|
3902
|
-
...
|
|
3903
|
-
...
|
|
3929
|
+
...fe.includes("left") ? { left: Dt } : { right: Dt },
|
|
3930
|
+
...fe.includes("top") ? { top: Dt + Ze + 8 } : { bottom: Dt + Ze + 8 },
|
|
3904
3931
|
width: 20,
|
|
3905
3932
|
height: 20,
|
|
3906
3933
|
borderRadius: 999,
|
|
@@ -3915,17 +3942,17 @@ function mo({
|
|
|
3915
3942
|
children: "×"
|
|
3916
3943
|
}
|
|
3917
3944
|
)
|
|
3918
|
-
] }) : /* @__PURE__ */
|
|
3945
|
+
] }) : /* @__PURE__ */ Ut(
|
|
3919
3946
|
"button",
|
|
3920
3947
|
{
|
|
3921
3948
|
type: "button",
|
|
3922
3949
|
"aria-label": "Show overview map",
|
|
3923
|
-
onClick: () =>
|
|
3950
|
+
onClick: () => Bt(!0),
|
|
3924
3951
|
style: {
|
|
3925
3952
|
position: "absolute",
|
|
3926
3953
|
zIndex: 6,
|
|
3927
|
-
...
|
|
3928
|
-
...
|
|
3954
|
+
...fe.includes("left") ? { left: Dt } : { right: Dt },
|
|
3955
|
+
...fe.includes("top") ? { top: Dt } : { bottom: Dt },
|
|
3929
3956
|
height: 24,
|
|
3930
3957
|
minWidth: 40,
|
|
3931
3958
|
borderRadius: 999,
|
|
@@ -3943,34 +3970,34 @@ function mo({
|
|
|
3943
3970
|
] });
|
|
3944
3971
|
}
|
|
3945
3972
|
export {
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3973
|
+
Un as DEFAULT_POINT_COLOR,
|
|
3974
|
+
gi as DrawLayer,
|
|
3975
|
+
hr as M1TileRenderer,
|
|
3976
|
+
bi as OverviewMap,
|
|
3977
|
+
Yi as TileScheduler,
|
|
3978
|
+
go as TileViewerCanvas,
|
|
3979
|
+
qi as WsiTileRenderer,
|
|
3980
|
+
yo as WsiViewerCanvas,
|
|
3981
|
+
fo as buildTermPalette,
|
|
3982
|
+
co as calcScaleLength,
|
|
3956
3983
|
zn as calcScaleResolution,
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3984
|
+
it as clamp,
|
|
3985
|
+
Rt as closeRing,
|
|
3986
|
+
ki as computeRoiPointGroups,
|
|
3987
|
+
Tn as createCircle,
|
|
3988
|
+
Sn as createRectangle,
|
|
3989
|
+
Ee as filterPointDataByPolygons,
|
|
3990
|
+
Bi as filterPointDataByPolygonsHybrid,
|
|
3991
|
+
Fi as filterPointDataByPolygonsInWorker,
|
|
3992
|
+
xi as filterPointIndicesByPolygons,
|
|
3993
|
+
wo as filterPointIndicesByPolygonsInWorker,
|
|
3994
|
+
po as getWebGpuCapabilities,
|
|
3968
3995
|
Ur as hexToRgba,
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3996
|
+
lo as isSameViewState,
|
|
3997
|
+
mo as normalizeImageInfo,
|
|
3998
|
+
vi as prefilterPointsByBoundsWebGpu,
|
|
3999
|
+
bo as terminateRoiClipWorker,
|
|
4000
|
+
ho as toBearerToken,
|
|
3974
4001
|
Wn as toTileUrl
|
|
3975
4002
|
};
|
|
3976
4003
|
//# sourceMappingURL=index.js.map
|