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