open-plant 1.2.11 → 1.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
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 w = (e, t, n) => gr(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { jsx as zt, jsxs as Sn, Fragment as pr } from "react/jsx-runtime";
5
- import { useRef as tt, useMemo as $, useCallback as B, useEffect as Y, useState as te } from "react";
6
- function An(e, t, n) {
1
+ var gr = Object.defineProperty;
2
+ var pr = (e, t, n) => t in e ? gr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var w = (e, t, n) => pr(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { jsx as zt, jsxs as Sn, Fragment as br } from "react/jsx-runtime";
5
+ import { useRef as tt, useMemo as K, useCallback as U, useEffect as X, useState as ee } from "react";
6
+ function xn(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 An(e, t, n) {
13
13
  }
14
14
  return r;
15
15
  }
16
- function br(e, t, n) {
17
- const r = An(e, e.VERTEX_SHADER, t), i = An(e, e.FRAGMENT_SHADER, n), o = e.createProgram();
16
+ function yr(e, t, n) {
17
+ const r = xn(e, e.VERTEX_SHADER, t), i = xn(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 br(e, t, n) {
23
23
  }
24
24
  return o;
25
25
  }
26
- function Ne(e, t, n) {
26
+ function De(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 yr(e) {
32
+ function wr(e) {
33
33
  const t = e.getContext("webgl2", {
34
34
  alpha: !1,
35
35
  antialias: !1,
@@ -42,7 +42,7 @@ function yr(e) {
42
42
  throw new Error("WebGL2 is not available.");
43
43
  return t;
44
44
  }
45
- let wr = class {
45
+ let Mr = class {
46
46
  constructor() {
47
47
  w(this, "viewportWidth", 1);
48
48
  w(this, "viewportHeight", 1);
@@ -82,7 +82,7 @@ let wr = class {
82
82
  ]);
83
83
  }
84
84
  };
85
- const Mr = `#version 300 es
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
- `, Sr = `#version 300 es
105
+ `, xr = `#version 300 es
106
106
  precision highp float;
107
107
 
108
108
  in vec2 vUv;
@@ -118,7 +118,7 @@ class Ar {
118
118
  constructor(t) {
119
119
  w(this, "canvas");
120
120
  w(this, "gl");
121
- w(this, "camera", new wr());
121
+ w(this, "camera", new Mr());
122
122
  w(this, "imageWidth");
123
123
  w(this, "imageHeight");
124
124
  w(this, "clearColor");
@@ -135,7 +135,7 @@ class Ar {
135
135
  w(this, "destroyed", !1);
136
136
  w(this, "fitted", !1);
137
137
  w(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 = yr(this.canvas), this.program = br(this.gl, Mr, Sr);
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 = yr(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 Ar {
177
177
  !1,
178
178
  s,
179
179
  2 * Float32Array.BYTES_PER_ELEMENT
180
- ), this.gl.bindVertexArray(null), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.uCameraLocation = Ne(
180
+ ), this.gl.bindVertexArray(null), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.uCameraLocation = De(
181
181
  this.gl,
182
182
  this.program,
183
183
  "uCamera"
184
- ), this.uBoundsLocation = Ne(
184
+ ), this.uBoundsLocation = De(
185
185
  this.gl,
186
186
  this.program,
187
187
  "uBounds"
188
- ), this.uTextureLocation = Ne(
188
+ ), this.uTextureLocation = De(
189
189
  this.gl,
190
190
  this.program,
191
191
  "uTexture"
@@ -310,16 +310,16 @@ class Ar {
310
310
  this.gl.deleteTexture(n.texture);
311
311
  }
312
312
  }
313
- const xr = 0.1, Tr = 4e6, Er = 4096, Rr = 64, Pr = 1, vr = 4, On = 1e-6, Ir = 24;
314
- function ve(e, t, n) {
313
+ const Tr = 0.1, Er = 4e6, Pr = 4096, Rr = 64, vr = 1, Ir = 4, Vn = 1e-6, Cr = 24;
314
+ function Ie(e, t, n) {
315
315
  return Math.max(t, Math.min(n, e));
316
316
  }
317
- function Lt(e) {
317
+ function Nt(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 Cr(e) {
322
+ function _r(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 Cr(e) {
331
331
  }
332
332
  return t;
333
333
  }
334
- function _r(e, t, n) {
335
- if (t <= On || n < 8) return [];
334
+ function Fr(e, t, n) {
335
+ if (t <= Vn || 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 _r(e, t, n) {
341
341
  e[1] + Math.sin(o) * t
342
342
  ]);
343
343
  }
344
- return Lt(r);
344
+ return Nt(r);
345
345
  }
346
- function De(e, t) {
346
+ function ke(e, t) {
347
347
  if (!e.length) return [];
348
348
  let n = 1 / 0, r = 1 / 0, i = -1 / 0, o = -1 / 0;
349
349
  for (const [s, l] of e)
350
350
  s < n && (n = s), s > i && (i = s), l < r && (r = l), l > o && (o = l);
351
351
  if (!Number.isFinite(n) || !Number.isFinite(r)) return [];
352
352
  const a = Math.max(t, 1);
353
- return Lt([
353
+ return Nt([
354
354
  [n - a, r - a],
355
355
  [i + a, r - a],
356
356
  [i + a, o + a],
357
357
  [n - a, o + a]
358
358
  ]);
359
359
  }
360
- function Fr(e, t) {
360
+ function Ur(e, t) {
361
361
  let n = 1 / 0, r = 1 / 0, i = -1 / 0, o = -1 / 0;
362
362
  for (const [s, l] of e)
363
363
  s < n && (n = s), s > i && (i = s), l < r && (r = l), l > o && (o = l);
364
364
  const a = Math.max(t, 1);
365
365
  return [n - a, r - a, i + a, o + a];
366
366
  }
367
- function Ur(e, t, n) {
367
+ function Br(e, t, n) {
368
368
  const r = Math.max(
369
- xr,
369
+ Tr,
370
370
  Number(n.minRasterStep) || 0
371
371
  ), i = Math.max(
372
372
  32768,
373
- Math.floor(n.maxRasterPixels || Tr)
373
+ Math.floor(n.maxRasterPixels || Er)
374
374
  ), o = Math.max(
375
375
  256,
376
- Math.floor(n.maxRasterSize || Er)
376
+ Math.floor(n.maxRasterSize || Pr)
377
377
  ), a = Math.max(1e-3, e[2] - e[0]), s = Math.max(1e-3, e[3] - e[1]);
378
- let l = Math.max(r, Number.EPSILON), c = 3, h = Math.ceil(a / l) + c * 2 + 1, g = Math.ceil(s / l) + c * 2 + 1;
379
- for (; (h > o || g > o || h * g > i) && (l *= 1.15, h = Math.ceil(a / l) + c * 2 + 1, g = Math.ceil(s / l) + c * 2 + 1, !(l > Math.max(a, s))); )
378
+ let l = Math.max(r, Number.EPSILON), c = 3, f = Math.ceil(a / l) + c * 2 + 1, p = Math.ceil(s / l) + c * 2 + 1;
379
+ for (; (f > o || p > o || f * p > i) && (l *= 1.15, f = Math.ceil(a / l) + c * 2 + 1, p = Math.ceil(s / l) + c * 2 + 1, !(l > Math.max(a, s))); )
380
380
  ;
381
- return h = Math.max(8, h), g = Math.max(8, g), {
381
+ return f = Math.max(8, f), p = Math.max(8, p), {
382
382
  minX: e[0],
383
383
  minY: e[1],
384
384
  step: l,
385
385
  padding: c,
386
- width: h,
387
- height: g
386
+ width: f,
387
+ height: p
388
388
  };
389
389
  }
390
- function Br(e, t) {
390
+ function Lr(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;
@@ -404,8 +404,8 @@ function zr(e, t) {
404
404
  (e[1] - t.minY) / t.step + t.padding
405
405
  ];
406
406
  }
407
- function Lr(e, t, n) {
408
- const r = Br(n.width, n.height);
407
+ function Nr(e, t, n) {
408
+ const r = Lr(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
411
  const i = e.map((s) => zr(s, n));
@@ -421,10 +421,10 @@ function Lr(e, t, n) {
421
421
  }
422
422
  const o = r.getImageData(0, 0, n.width, n.height), a = new Uint8Array(n.width * n.height);
423
423
  for (let s = 0; s < a.length; s += 1)
424
- a[s] = o.data[s * 4 + 3] >= Ir ? 1 : 0;
424
+ a[s] = o.data[s * 4 + 3] >= Cr ? 1 : 0;
425
425
  return a;
426
426
  }
427
- function Nr(e, t, n) {
427
+ function Dr(e, t, n) {
428
428
  const r = [], i = t + 1, o = (s, l) => l * i + s, a = (s, l) => s >= 0 && l >= 0 && s < t && l < n && e[l * t + s] > 0;
429
429
  for (let s = 0; s < n; s += 1)
430
430
  for (let l = 0; l < t; l += 1)
@@ -447,11 +447,11 @@ function Nr(e, t, n) {
447
447
  }));
448
448
  return r;
449
449
  }
450
- function Dr(e, t) {
450
+ function kr(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 kr(e) {
454
+ function Xr(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) {
@@ -465,27 +465,27 @@ function kr(e) {
465
465
  let s = o.end, l = o.dir;
466
466
  const c = [o.start, o.end];
467
467
  n[i] = 1;
468
- let h = 0;
469
- const g = e.length * 3;
470
- for (; s !== a && h < g; ) {
468
+ let f = 0;
469
+ const p = e.length * 3;
470
+ for (; s !== a && f < p; ) {
471
471
  const d = t.get(s);
472
472
  if (!d || d.length === 0) break;
473
- let m = -1, p = 1 / 0;
474
- for (const x of d) {
475
- if (n[x]) continue;
476
- const C = e[x], W = Dr(l, C.dir);
477
- W < p && (p = W, m = x);
473
+ let m = -1, b = 1 / 0;
474
+ for (const T of d) {
475
+ if (n[T]) continue;
476
+ const C = e[T], Y = kr(l, C.dir);
477
+ Y < b && (b = Y, m = T);
478
478
  }
479
479
  if (m < 0) break;
480
480
  n[m] = 1;
481
481
  const S = e[m];
482
- s = S.end, l = S.dir, c.push(s), h += 1;
482
+ s = S.end, l = S.dir, c.push(s), f += 1;
483
483
  }
484
484
  c.length >= 4 && c[0] === c[c.length - 1] && r.push(c);
485
485
  }
486
486
  return r;
487
487
  }
488
- function Xr(e, t, n) {
488
+ function Yr(e, t, n) {
489
489
  const r = t + 1, i = [];
490
490
  for (const o of e) {
491
491
  const a = o % r, s = Math.floor(o / r);
@@ -494,9 +494,9 @@ function Xr(e, t, n) {
494
494
  n.minY + (s - n.padding) * n.step
495
495
  ]);
496
496
  }
497
- return Lt(i);
497
+ return Nt(i);
498
498
  }
499
- function Yr(e) {
499
+ function Wr(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 Yr(e) {
505
505
  }
506
506
  return t * 0.5;
507
507
  }
508
- function Wr(e, t = 1e-9) {
509
- const n = Lt(e);
508
+ function Or(e, t = 1e-9) {
509
+ const n = Nt(e);
510
510
  if (n.length < 5) return n;
511
511
  const r = [n[0]];
512
512
  for (let i = 1; i < n.length - 1; i += 1) {
513
513
  const o = r[r.length - 1], a = n[i], s = n[i + 1], l = (a[0] - o[0]) * (s[1] - a[1]) - (a[1] - o[1]) * (s[0] - a[0]);
514
514
  Math.abs(l) <= t || r.push(a);
515
515
  }
516
- return r.push(r[0]), Lt(r);
516
+ return r.push(r[0]), Nt(r);
517
517
  }
518
- function Or(e, t, n) {
518
+ function Vr(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 g = e[0] - t[0], d = e[1] - t[1];
522
- return g * g + d * d;
521
+ const p = e[0] - t[0], d = e[1] - t[1];
522
+ return p * p + d * d;
523
523
  }
524
- const a = ve(
524
+ const a = Ie(
525
525
  ((e[0] - t[0]) * r + (e[1] - t[1]) * i) / o,
526
526
  0,
527
527
  1
528
- ), s = t[0] + r * a, l = t[1] + i * a, c = e[0] - s, h = e[1] - l;
529
- return c * c + h * h;
528
+ ), s = t[0] + r * a, l = t[1] + i * a, c = e[0] - s, f = e[1] - l;
529
+ return c * c + f * f;
530
530
  }
531
- function Vr(e, t) {
531
+ function Gr(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;
@@ -538,26 +538,26 @@ function Vr(e, t) {
538
538
  if (!a) break;
539
539
  const [s, l] = a;
540
540
  if (l - s <= 1) continue;
541
- let c = 0, h = -1;
542
- for (let g = s + 1; g < l; g += 1) {
543
- const d = Or(e[g], e[s], e[l]);
544
- d > c && (c = d, h = g);
541
+ let c = 0, f = -1;
542
+ for (let p = s + 1; p < l; p += 1) {
543
+ const d = Vr(e[p], e[s], e[l]);
544
+ d > c && (c = d, f = p);
545
545
  }
546
- h >= 0 && c > r && (n[h] = 1, i.push([s, h], [h, l]));
546
+ f >= 0 && c > r && (n[f] = 1, i.push([s, f], [f, l]));
547
547
  }
548
548
  const o = [];
549
549
  for (let a = 0; a < e.length; a += 1)
550
550
  n[a] && o.push(e[a]);
551
551
  return o;
552
552
  }
553
- function Gr(e, t) {
554
- const n = Lt(e);
553
+ function qr(e, t) {
554
+ const n = Nt(e);
555
555
  if (n.length < 5 || t <= 0) return n;
556
- const r = n.slice(0, -1), i = Vr(r, t);
557
- return i.length < 3 ? n : Lt(i);
556
+ const r = n.slice(0, -1), i = Gr(r, t);
557
+ return i.length < 3 ? n : Nt(i);
558
558
  }
559
- function qr(e, t) {
560
- let n = Lt(e);
559
+ function Hr(e, t) {
560
+ let n = Nt(e);
561
561
  if (t <= 0 || n.length < 5) return n;
562
562
  for (let r = 0; r < t; r += 1) {
563
563
  const i = n.slice(0, -1);
@@ -570,65 +570,65 @@ function qr(e, t) {
570
570
  [s[0] * 0.25 + l[0] * 0.75, s[1] * 0.25 + l[1] * 0.75]
571
571
  );
572
572
  }
573
- n = Lt(o);
573
+ n = Nt(o);
574
574
  }
575
575
  return n;
576
576
  }
577
577
  function se(e, t) {
578
- return t ? Lt(
578
+ return t ? Nt(
579
579
  e.map(([n, r]) => [
580
- ve(n, t[0], t[2]),
581
- ve(r, t[1], t[3])
580
+ Ie(n, t[0], t[2]),
581
+ Ie(r, t[1], t[3])
582
582
  ])
583
583
  ) : e;
584
584
  }
585
- function Hr(e, t) {
586
- const n = Cr(e), r = Math.max(On, Number(t.radius) || 0);
585
+ function $r(e, t) {
586
+ const n = _r(e), r = Math.max(Vn, Number(t.radius) || 0);
587
587
  if (n.length === 0 || !Number.isFinite(r)) return [];
588
588
  const i = Math.max(12, Math.floor(t.circleSides || Rr));
589
589
  if (n.length === 1)
590
590
  return se(
591
- _r(n[0], r, i),
591
+ Fr(n[0], r, i),
592
592
  t.clipBounds
593
593
  );
594
- const o = Fr(n, r), a = Ur(o, r, t), s = Lr(n, r, a);
594
+ const o = Ur(n, r), a = Br(o, r, t), s = Nr(n, r, a);
595
595
  if (!s.length)
596
- return se(De(n, r), t.clipBounds);
597
- const l = Nr(s, a.width, a.height), c = kr(l);
596
+ return se(ke(n, r), t.clipBounds);
597
+ const l = Dr(s, a.width, a.height), c = Xr(l);
598
598
  if (!c.length)
599
- return se(De(n, r), t.clipBounds);
600
- let h = [], g = 0;
599
+ return se(ke(n, r), t.clipBounds);
600
+ let f = [], p = 0;
601
601
  for (const S of c) {
602
- const x = Xr(S, a.width, a), C = Math.abs(Yr(x));
603
- C <= g || (g = C, h = x);
604
- }
605
- if (!h.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) : a.step * 0.2, m = typeof t.smoothingPasses == "number" && Number.isFinite(t.smoothingPasses) ? Math.round(ve(t.smoothingPasses, 0, vr)) : Pr, p = Gr(
608
- qr(
609
- Wr(h, a.step * 1e-3),
602
+ const T = Yr(S, a.width, a), C = Math.abs(Wr(T));
603
+ C <= p || (p = C, f = T);
604
+ }
605
+ if (!f.length)
606
+ return se(ke(n, r), t.clipBounds);
607
+ const d = typeof t.simplifyTolerance == "number" && Number.isFinite(t.simplifyTolerance) ? Math.max(0, t.simplifyTolerance) : a.step * 0.2, m = typeof t.smoothingPasses == "number" && Number.isFinite(t.smoothingPasses) ? Math.round(Ie(t.smoothingPasses, 0, Ir)) : vr, b = qr(
608
+ Hr(
609
+ Or(f, a.step * 1e-3),
610
610
  m
611
611
  ),
612
612
  d
613
613
  );
614
- return se(p, t.clipBounds);
614
+ return se(b, t.clipBounds);
615
615
  }
616
- function xn(e) {
616
+ function An(e) {
617
617
  return typeof e == "number" && Number.isFinite(e);
618
618
  }
619
- function $r(e) {
620
- return Array.isArray(e) && e.length >= 2 && xn(e[0]) && xn(e[1]);
621
- }
622
- function Vn(e) {
623
- return Array.isArray(e) && e.length > 0 && e.every((t) => $r(t));
619
+ function Zr(e) {
620
+ return Array.isArray(e) && e.length >= 2 && An(e[0]) && An(e[1]);
624
621
  }
625
622
  function Gn(e) {
626
- return Array.isArray(e) && e.length > 0 && e.every((t) => Vn(t));
623
+ return Array.isArray(e) && e.length > 0 && e.every((t) => Zr(t));
627
624
  }
628
- function Zr(e) {
625
+ function qn(e) {
629
626
  return Array.isArray(e) && e.length > 0 && e.every((t) => Gn(t));
630
627
  }
631
628
  function Kr(e) {
629
+ return Array.isArray(e) && e.length > 0 && e.every((t) => qn(t));
630
+ }
631
+ function Jr(e) {
632
632
  if (!Array.isArray(e) || e.length < 3) return [];
633
633
  const t = [];
634
634
  for (const i of e) {
@@ -651,11 +651,11 @@ function Ve(e) {
651
651
  }
652
652
  return t * 0.5;
653
653
  }
654
- function ke(e) {
654
+ function Xe(e) {
655
655
  if (!Array.isArray(e) || e.length === 0) return [];
656
656
  const t = [];
657
657
  for (const o of e) {
658
- const a = Kr(o);
658
+ const a = Jr(o);
659
659
  a.length >= 4 && t.push(a);
660
660
  }
661
661
  if (t.length === 0) return [];
@@ -670,20 +670,20 @@ function ke(e) {
670
670
  o !== n && i.push(t[o]);
671
671
  return i;
672
672
  }
673
- function qn(e) {
673
+ function Hn(e) {
674
674
  if (!e) return [];
675
- if (Vn(e)) {
676
- const t = ke([e]);
675
+ if (Gn(e)) {
676
+ const t = Xe([e]);
677
677
  return t.length > 0 ? [t] : [];
678
678
  }
679
- if (Gn(e)) {
680
- const t = ke(e);
679
+ if (qn(e)) {
680
+ const t = Xe(e);
681
681
  return t.length > 0 ? [t] : [];
682
682
  }
683
- if (Zr(e)) {
683
+ if (Kr(e)) {
684
684
  const t = [];
685
685
  for (const n of e) {
686
- const r = ke(n);
686
+ const r = Xe(n);
687
687
  r.length > 0 && t.push(r);
688
688
  }
689
689
  return t;
@@ -698,21 +698,21 @@ function Tn(e, t, n) {
698
698
  }
699
699
  return r;
700
700
  }
701
- function ce(e) {
701
+ function he(e) {
702
702
  const t = [];
703
703
  for (const n of e ?? []) {
704
- const r = qn(n);
704
+ const r = Hn(n);
705
705
  for (const i of r) {
706
706
  const o = i[0];
707
707
  if (!o || o.length < 4) continue;
708
708
  let a = 1 / 0, s = 1 / 0, l = -1 / 0, c = -1 / 0;
709
- for (const [g, d] of o)
710
- g < a && (a = g), g > l && (l = g), d < s && (s = d), d > c && (c = d);
709
+ for (const [p, d] of o)
710
+ p < a && (a = p), p > l && (l = p), d < s && (s = d), d > c && (c = d);
711
711
  if (!Number.isFinite(a) || !Number.isFinite(s) || !Number.isFinite(l) || !Number.isFinite(c))
712
712
  continue;
713
- let h = Math.abs(Ve(o));
714
- for (let g = 1; g < i.length; g += 1)
715
- h -= Math.abs(Ve(i[g]));
713
+ let f = Math.abs(Ve(o));
714
+ for (let p = 1; p < i.length; p += 1)
715
+ f -= Math.abs(Ve(i[p]));
716
716
  t.push({
717
717
  outer: o,
718
718
  holes: i.slice(1),
@@ -720,25 +720,25 @@ function ce(e) {
720
720
  minY: s,
721
721
  maxX: l,
722
722
  maxY: c,
723
- area: Math.max(1e-6, h)
723
+ area: Math.max(1e-6, f)
724
724
  });
725
725
  }
726
726
  }
727
727
  return t;
728
728
  }
729
- function Qe(e, t, n) {
729
+ function je(e, t, n) {
730
730
  if (e < n.minX || e > n.maxX || t < n.minY || t > n.maxY || !Tn(e, t, n.outer)) return !1;
731
731
  for (const r of n.holes)
732
732
  if (Tn(e, t, r)) return !1;
733
733
  return !0;
734
734
  }
735
- function Ie(e, t, n) {
735
+ function Ce(e, t, n) {
736
736
  for (const r of n)
737
- if (Qe(e, t, r))
737
+ if (je(e, t, r))
738
738
  return !0;
739
739
  return !1;
740
740
  }
741
- const Hn = [
741
+ const $n = [
742
742
  160,
743
743
  160,
744
744
  160,
@@ -747,12 +747,12 @@ const Hn = [
747
747
  function it(e, t, n) {
748
748
  return Math.max(t, Math.min(n, e));
749
749
  }
750
- function $n(e, t, n) {
750
+ function Zn(e, t, n) {
751
751
  const r = Number(e), i = Number(t), o = Number(n);
752
752
  return !Number.isFinite(r) || r <= 0 ? 1 : !Number.isFinite(i) || !Number.isFinite(o) ? r : Math.pow(2, i - o) * r;
753
753
  }
754
754
  function vo(e, t, n) {
755
- let i = 100 * $n(e, t, n);
755
+ let i = 100 * Zn(e, t, n);
756
756
  if (Number(e)) {
757
757
  let o = "μm";
758
758
  return i > 1e3 && (i /= 1e3, o = "mm"), `${i.toPrecision(3)} ${o}`;
@@ -771,19 +771,19 @@ function Co(e) {
771
771
  }
772
772
  return `Bearer ${t}`;
773
773
  }
774
- function Jr(e) {
774
+ function jr(e) {
775
775
  const n = String(e ?? "").trim().match(/^#?([0-9a-fA-F]{6})$/);
776
- if (!n) return [...Hn];
776
+ if (!n) return [...$n];
777
777
  const r = Number.parseInt(n[1], 16);
778
778
  return [r >> 16 & 255, r >> 8 & 255, r & 255, 255];
779
779
  }
780
780
  function _o(e) {
781
781
  const t = [
782
- [...Hn]
782
+ [...$n]
783
783
  ], n = /* @__PURE__ */ new Map();
784
784
  for (const i of e ?? []) {
785
785
  const o = String(i?.termId ?? "");
786
- !o || n.has(o) || (n.set(o, t.length), t.push(Jr(i?.termColor)));
786
+ !o || n.has(o) || (n.set(o, t.length), t.push(jr(i?.termColor)));
787
787
  }
788
788
  const r = new Uint8Array(t.length * 4);
789
789
  for (let i = 0; i < t.length; i += 1)
@@ -805,7 +805,7 @@ function En(e, t, n) {
805
805
  throw new Error(e.getProgramInfoLog(o) || "program link failed");
806
806
  return o;
807
807
  }
808
- const Qr = "rgba(255, 77, 79, 0.16)", jr = 3, ti = 2, Zn = 96, ei = 1, Rn = [], Ce = [], Pn = 1e3, Kn = 2, Jn = 2, ni = 4096, ri = 0.2, ii = 1.12, oi = 0.89, si = 32, ai = "#000000", li = 0.1, ui = "#FFCF00", ci = "#FF0000", hi = 1.5, vn = [2, 2], fi = 1, di = 0.25, mi = 4, gi = 1, pi = 0, bi = 4, yi = 0.05, wi = 256, Mi = 1.5, Vt = {
808
+ const Qr = "rgba(255, 77, 79, 0.16)", ti = 3, ei = 2, Kn = 96, ni = 1, Pn = [], _e = [], Rn = 1e3, Jn = 2, jn = 2, ri = 4096, ii = 0.2, oi = 1.12, si = 0.89, ai = 32, li = "#000000", ui = 0.1, ci = "#FFCF00", hi = "#FF0000", fi = 1.5, vn = [2, 2], di = 1, mi = 0.25, gi = 4, pi = 1, bi = 0, yi = 4, wi = 0.05, Mi = 256, In = 1.5, Ht = {
809
809
  color: "#ff4d4f",
810
810
  width: 2,
811
811
  lineJoin: "round",
@@ -824,7 +824,7 @@ const Qr = "rgba(255, 77, 79, 0.16)", jr = 3, ti = 2, Zn = 96, ei = 1, Rn = [],
824
824
  shadowBlur: 0,
825
825
  shadowOffsetX: 0,
826
826
  shadowOffsetY: 0
827
- }, vt = {
827
+ }, _t = {
828
828
  fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
829
829
  fontSize: 12,
830
830
  fontWeight: 500,
@@ -837,24 +837,24 @@ const Qr = "rgba(255, 77, 79, 0.16)", jr = 3, ti = 2, Zn = 96, ei = 1, Rn = [],
837
837
  offsetY: 10,
838
838
  borderRadius: 3
839
839
  };
840
- function Jt(e, t, n) {
840
+ function Yt(e, t, n) {
841
841
  return Math.max(t, Math.min(n, e));
842
842
  }
843
843
  function Me(e) {
844
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";
845
845
  }
846
- function le(e, t) {
846
+ function ue(e, t) {
847
847
  return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? t : e;
848
848
  }
849
- function Ai(e) {
849
+ function xi(e) {
850
850
  return {
851
- rectangleAreaMm2: le(e?.rectangleAreaMm2, Kn),
852
- circleAreaMm2: le(e?.circleAreaMm2, Jn),
853
- rectanglePixelSize: le(e?.rectanglePixelSize, ni)
851
+ rectangleAreaMm2: ue(e?.rectangleAreaMm2, Jn),
852
+ circleAreaMm2: ue(e?.circleAreaMm2, jn),
853
+ rectanglePixelSize: ue(e?.rectanglePixelSize, ri)
854
854
  };
855
855
  }
856
- function xi(e, t) {
857
- return typeof e != "number" || !Number.isFinite(e) ? t : Jt(e, 0, 1);
856
+ function Ai(e, t) {
857
+ return typeof e != "number" || !Number.isFinite(e) ? t : Yt(e, 0, 1);
858
858
  }
859
859
  function Ti(e) {
860
860
  if (!Array.isArray(e)) return vn;
@@ -862,60 +862,60 @@ function Ti(e) {
862
862
  return t.length > 0 ? t : vn;
863
863
  }
864
864
  function Ei(e) {
865
- return typeof e != "number" || !Number.isFinite(e) ? fi : Jt(e, di, mi);
866
- }
867
- function Ri(e) {
868
- return typeof e != "number" || !Number.isFinite(e) ? gi : Math.round(Jt(e, pi, bi));
865
+ return typeof e != "number" || !Number.isFinite(e) ? di : Yt(e, mi, gi);
869
866
  }
870
867
  function Pi(e) {
871
- const t = le(e?.radius, si), n = le(e?.cursorLineWidth, hi), r = Ei(e?.edgeDetail), i = Ri(e?.edgeSmoothing);
868
+ return typeof e != "number" || !Number.isFinite(e) ? pi : Math.round(Yt(e, bi, yi));
869
+ }
870
+ function Ri(e) {
871
+ const t = ue(e?.radius, ai), n = ue(e?.cursorLineWidth, fi), r = Ei(e?.edgeDetail), i = Pi(e?.edgeSmoothing);
872
872
  return {
873
873
  radius: t,
874
874
  edgeDetail: r,
875
875
  edgeSmoothing: i,
876
876
  clickSelectRoi: e?.clickSelectRoi === !0,
877
- fillColor: e?.fillColor || ai,
878
- fillOpacity: xi(e?.fillOpacity, li),
879
- cursorColor: e?.cursorColor || ui,
880
- cursorActiveColor: e?.cursorActiveColor || ci,
877
+ fillColor: e?.fillColor || li,
878
+ fillOpacity: Ai(e?.fillOpacity, ui),
879
+ cursorColor: e?.cursorColor || ci,
880
+ cursorActiveColor: e?.cursorActiveColor || hi,
881
881
  cursorLineWidth: n,
882
882
  cursorLineDash: Ti(e?.cursorLineDash)
883
883
  };
884
884
  }
885
885
  function vi(e) {
886
- return e * Pn * Pn;
886
+ return e * Rn * Rn;
887
887
  }
888
- function In(e, t) {
889
- return !e || !Number.isFinite(t) || t <= 0 ? [] : Ht([
888
+ function Cn(e, t) {
889
+ return !e || !Number.isFinite(t) || t <= 0 ? [] : Xt([
890
890
  [e[0] - t, e[1] - t],
891
891
  [e[0] + t, e[1] - t],
892
892
  [e[0] + t, e[1] + t],
893
893
  [e[0] - t, e[1] + t]
894
894
  ]);
895
895
  }
896
- function Ii(e, t, n = Zn) {
896
+ function Ii(e, t, n = Kn) {
897
897
  if (!e || !Number.isFinite(t) || t <= 0) return [];
898
898
  const r = [];
899
899
  for (let i = 0; i <= n; i += 1) {
900
900
  const o = i / n * Math.PI * 2;
901
901
  r.push([e[0] + Math.cos(o) * t, e[1] + Math.sin(o) * t]);
902
902
  }
903
- return Ht(r);
903
+ return Xt(r);
904
904
  }
905
- function Ht(e) {
905
+ function Xt(e) {
906
906
  if (!Array.isArray(e) || e.length < 3) return [];
907
907
  const t = e.map(([i, o]) => [i, o]), n = t[0], r = t[t.length - 1];
908
908
  return !n || !r ? [] : ((n[0] !== r[0] || n[1] !== r[1]) && t.push([n[0], n[1]]), t);
909
909
  }
910
- function Cn(e, t) {
911
- return !e || !t ? [] : Ht([
910
+ function _n(e, t) {
911
+ return !e || !t ? [] : Xt([
912
912
  [e[0], e[1]],
913
913
  [t[0], e[1]],
914
914
  [t[0], t[1]],
915
915
  [e[0], t[1]]
916
916
  ]);
917
917
  }
918
- function _n(e, t, n = Zn) {
918
+ function Fn(e, t, n = Kn) {
919
919
  if (!e || !t) return [];
920
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;
921
921
  if (o < 1) return [];
@@ -924,7 +924,7 @@ function _n(e, t, n = Zn) {
924
924
  const l = s / n * Math.PI * 2;
925
925
  a.push([r + Math.cos(l) * o, i + Math.sin(l) * o]);
926
926
  }
927
- return Ht(a);
927
+ return Xt(a);
928
928
  }
929
929
  function Ge(e) {
930
930
  if (!Array.isArray(e) || e.length < 4) return 0;
@@ -935,15 +935,15 @@ function Ge(e) {
935
935
  }
936
936
  return Math.abs(t * 0.5);
937
937
  }
938
- function Fn(e) {
938
+ function Un(e) {
939
939
  if (!Array.isArray(e) || e.length === 0) return [0, 0, 0, 0];
940
940
  let t = 1 / 0, n = 1 / 0, r = -1 / 0, i = -1 / 0;
941
941
  for (const [o, a] of e)
942
942
  o < t && (t = o), o > r && (r = o), a < n && (n = a), a > i && (i = a);
943
943
  return [t, n, r, i];
944
944
  }
945
- function Un(e) {
946
- return Array.isArray(e) && e.length >= 4 && Ge(e) > ei;
945
+ function Bn(e) {
946
+ return Array.isArray(e) && e.length >= 4 && Ge(e) > ni;
947
947
  }
948
948
  function qe(e, t, n = !1) {
949
949
  if (t.length !== 0) {
@@ -953,18 +953,18 @@ function qe(e, t, n = !1) {
953
953
  n && e.closePath();
954
954
  }
955
955
  }
956
- function Gt(e, t, n, r = !1, i = !1) {
957
- t.length !== 0 && (e.beginPath(), qe(e, t, r), i && r && (e.fillStyle = Qr, 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);
956
+ function $t(e, t, n, r = !1, i = !1) {
957
+ t.length !== 0 && (e.beginPath(), qe(e, t, r), i && r && (e.fillStyle = Qr, e.fill()), e.strokeStyle = n.color, e.lineWidth = n.width, e.lineJoin = n.lineJoin, e.lineCap = n.lineCap, e.shadowColor = n.shadowColor, e.shadowBlur = n.shadowBlur, e.shadowOffsetX = n.shadowOffsetX, e.shadowOffsetY = n.shadowOffsetY, e.setLineDash(n.lineDash), e.stroke(), e.setLineDash(_e), e.shadowColor = "rgba(0, 0, 0, 0)", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0);
958
958
  }
959
959
  function Qn(e) {
960
- const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((a) => Number.isFinite(a) && a >= 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;
960
+ const t = Array.isArray(e?.lineDash) ? e.lineDash.filter((a) => Number.isFinite(a) && a >= 0) : _e, n = typeof e?.width == "number" && Number.isFinite(e.width) ? Math.max(0, e.width) : Ht.width, r = typeof e?.shadowBlur == "number" && Number.isFinite(e.shadowBlur) ? Math.max(0, e.shadowBlur) : Ht.shadowBlur, i = typeof e?.shadowOffsetX == "number" && Number.isFinite(e.shadowOffsetX) ? e.shadowOffsetX : Ht.shadowOffsetX, o = typeof e?.shadowOffsetY == "number" && Number.isFinite(e.shadowOffsetY) ? e.shadowOffsetY : Ht.shadowOffsetY;
961
961
  return {
962
- color: e?.color || Vt.color,
962
+ color: e?.color || Ht.color,
963
963
  width: n,
964
- lineDash: t.length ? t : Ce,
965
- lineJoin: e?.lineJoin || Vt.lineJoin,
966
- lineCap: e?.lineCap || Vt.lineCap,
967
- shadowColor: e?.shadowColor || Vt.shadowColor,
964
+ lineDash: t.length ? t : _e,
965
+ lineJoin: e?.lineJoin || Ht.lineJoin,
966
+ lineCap: e?.lineCap || Ht.lineCap,
967
+ shadowColor: e?.shadowColor || Ht.shadowColor,
968
968
  shadowBlur: r,
969
969
  shadowOffsetX: i,
970
970
  shadowOffsetY: o
@@ -983,7 +983,7 @@ function ae(e, t) {
983
983
  shadowOffsetY: t.shadowOffsetY ?? e.shadowOffsetY
984
984
  }) : e;
985
985
  }
986
- function Bn(e, t) {
986
+ function Ln(e, t) {
987
987
  return e == null || t === null || t === void 0 ? !1 : String(e) === String(t);
988
988
  }
989
989
  function Ci(e) {
@@ -999,23 +999,23 @@ function _i(e) {
999
999
  function Fi(e) {
1000
1000
  return Array.isArray(e) && e.length >= 2 && e.every((t) => _i(t));
1001
1001
  }
1002
- function jn(e, t) {
1002
+ function tr(e, t) {
1003
1003
  if (!(!Array.isArray(e) || e.length === 0)) {
1004
1004
  if (Fi(e)) {
1005
1005
  t.push(e.map(([n, r]) => [n, r]));
1006
1006
  return;
1007
1007
  }
1008
1008
  for (const n of e)
1009
- jn(n, t);
1009
+ tr(n, t);
1010
1010
  }
1011
1011
  }
1012
- function Ln(e, t) {
1012
+ function Nn(e, t) {
1013
1013
  const n = [];
1014
- jn(e, n);
1014
+ tr(e, n);
1015
1015
  const r = [];
1016
1016
  for (const i of n) {
1017
1017
  if (i.length < 2) continue;
1018
- const o = t ? Ht(i) : i;
1018
+ const o = t ? Xt(i) : i;
1019
1019
  o.length >= (t ? 4 : 2) && r.push(o);
1020
1020
  }
1021
1021
  return r;
@@ -1029,14 +1029,14 @@ function Ui(e, t, n, r) {
1029
1029
  }
1030
1030
  }
1031
1031
  function Bi(e) {
1032
- const t = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) : vt.paddingX, n = typeof e?.paddingY == "number" && Number.isFinite(e.paddingY) ? Math.max(0, e.paddingY) : vt.paddingY, r = typeof e?.fontSize == "number" && Number.isFinite(e.fontSize) ? Math.max(8, e.fontSize) : vt.fontSize, i = typeof e?.borderWidth == "number" && Number.isFinite(e.borderWidth) ? Math.max(0, e.borderWidth) : vt.borderWidth, o = typeof e?.offsetY == "number" && Number.isFinite(e.offsetY) ? e.offsetY : vt.offsetY, a = typeof e?.borderRadius == "number" && Number.isFinite(e.borderRadius) ? Math.max(0, e.borderRadius) : vt.borderRadius;
1032
+ const t = typeof e?.paddingX == "number" && Number.isFinite(e.paddingX) ? Math.max(0, e.paddingX) : _t.paddingX, n = typeof e?.paddingY == "number" && Number.isFinite(e.paddingY) ? Math.max(0, e.paddingY) : _t.paddingY, r = typeof e?.fontSize == "number" && Number.isFinite(e.fontSize) ? Math.max(8, e.fontSize) : _t.fontSize, i = typeof e?.borderWidth == "number" && Number.isFinite(e.borderWidth) ? Math.max(0, e.borderWidth) : _t.borderWidth, o = typeof e?.offsetY == "number" && Number.isFinite(e.offsetY) ? e.offsetY : _t.offsetY, a = typeof e?.borderRadius == "number" && Number.isFinite(e.borderRadius) ? Math.max(0, e.borderRadius) : _t.borderRadius;
1033
1033
  return {
1034
- fontFamily: e?.fontFamily || vt.fontFamily,
1034
+ fontFamily: e?.fontFamily || _t.fontFamily,
1035
1035
  fontSize: r,
1036
- fontWeight: e?.fontWeight || vt.fontWeight,
1037
- textColor: e?.textColor || vt.textColor,
1038
- backgroundColor: e?.backgroundColor || vt.backgroundColor,
1039
- borderColor: e?.borderColor || vt.borderColor,
1036
+ fontWeight: e?.fontWeight || _t.fontWeight,
1037
+ textColor: e?.textColor || _t.textColor,
1038
+ backgroundColor: e?.backgroundColor || _t.backgroundColor,
1039
+ borderColor: e?.borderColor || _t.borderColor,
1040
1040
  borderWidth: i,
1041
1041
  paddingX: t,
1042
1042
  paddingY: n,
@@ -1044,11 +1044,11 @@ function Bi(e) {
1044
1044
  borderRadius: a
1045
1045
  };
1046
1046
  }
1047
- function zi(e, t, n, r, i, o) {
1047
+ function Li(e, t, n, r, i, o) {
1048
1048
  const a = Math.max(0, Math.min(o, r * 0.5, i * 0.5));
1049
1049
  e.beginPath(), e.moveTo(t + a, n), e.lineTo(t + r - a, n), e.quadraticCurveTo(t + r, n, t + r, n + a), e.lineTo(t + r, n + i - a), e.quadraticCurveTo(t + r, n + i, t + r - a, n + i), e.lineTo(t + a, n + i), e.quadraticCurveTo(t, n + i, t, n + i - a), e.lineTo(t, n + a), e.quadraticCurveTo(t, n, t + a, n), e.closePath();
1050
1050
  }
1051
- function Li(e) {
1051
+ function zi(e) {
1052
1052
  if (!e.length) return null;
1053
1053
  let t = 1 / 0;
1054
1054
  for (const i of e)
@@ -1062,13 +1062,13 @@ function Li(e) {
1062
1062
  function Ni(e) {
1063
1063
  let t = null;
1064
1064
  for (const n of e) {
1065
- const r = Li(n.outer);
1065
+ const r = zi(n.outer);
1066
1066
  r && (!t || r[1] < t[1] || r[1] === t[1] && r[0] < t[0]) && (t = r);
1067
1067
  }
1068
1068
  return t;
1069
1069
  }
1070
- function Nn(e) {
1071
- const t = qn(e);
1070
+ function Dn(e) {
1071
+ const t = Hn(e);
1072
1072
  if (t.length === 0) return [];
1073
1073
  const n = [];
1074
1074
  for (const r of t) {
@@ -1077,7 +1077,7 @@ function Nn(e) {
1077
1077
  const o = i.map(([s, l]) => [s, l]), a = [];
1078
1078
  for (let s = 1; s < r.length; s += 1) {
1079
1079
  const l = r[s];
1080
- !l || l.length < 4 || a.push(l.map(([c, h]) => [c, h]));
1080
+ !l || l.length < 4 || a.push(l.map(([c, f]) => [c, f]));
1081
1081
  }
1082
1082
  n.push({
1083
1083
  outer: o,
@@ -1090,13 +1090,13 @@ function Di(e, t, n, r, i, o) {
1090
1090
  const a = t.trim();
1091
1091
  if (!a) return;
1092
1092
  e.save(), e.font = `${o.fontWeight} ${o.fontSize}px ${o.fontFamily}`, e.textAlign = "center", e.textBaseline = "middle";
1093
- const l = e.measureText(a).width + o.paddingX * 2, c = o.fontSize + o.paddingY * 2, h = Jt(n[0], l * 0.5 + 1, r - l * 0.5 - 1), g = Jt(n[1] - o.offsetY, c * 0.5 + 1, i - c * 0.5 - 1), d = h - l * 0.5, m = g - c * 0.5;
1094
- e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth, zi(e, d, m, l, c, o.borderRadius), e.fill(), o.borderWidth > 0 && e.stroke(), e.fillStyle = o.textColor, e.fillText(a, h, g + 0.5), e.restore();
1093
+ const l = e.measureText(a).width + o.paddingX * 2, c = o.fontSize + o.paddingY * 2, f = Yt(n[0], l * 0.5 + 1, r - l * 0.5 - 1), p = Yt(n[1] - o.offsetY, c * 0.5 + 1, i - c * 0.5 - 1), d = f - l * 0.5, m = p - c * 0.5;
1094
+ e.fillStyle = o.backgroundColor, e.strokeStyle = o.borderColor, e.lineWidth = o.borderWidth, Li(e, d, m, l, c, o.borderRadius), e.fill(), o.borderWidth > 0 && e.stroke(), e.fillStyle = o.textColor, e.fillText(a, f, p + 0.5), e.restore();
1095
1095
  }
1096
- function Xe(e, t, n) {
1097
- return [Jt(e[0], 0, t), Jt(e[1], 0, n)];
1096
+ function Se(e, t, n) {
1097
+ return [Yt(e[0], 0, t), Yt(e[1], 0, n)];
1098
1098
  }
1099
- function ee(e) {
1099
+ function le(e) {
1100
1100
  if (!Array.isArray(e) || e.length < 2) return null;
1101
1101
  const t = Number(e[0]), n = Number(e[1]);
1102
1102
  return !Number.isFinite(t) || !Number.isFinite(n) ? null : [t, n];
@@ -1112,61 +1112,63 @@ function ki({
1112
1112
  projectorRef: s,
1113
1113
  onBrushTap: l,
1114
1114
  onDrawComplete: c,
1115
- onPatchComplete: h,
1116
- enabled: g,
1115
+ onPatchComplete: f,
1116
+ enabled: p,
1117
1117
  viewStateSignal: d,
1118
1118
  persistedRegions: m,
1119
- patchRegions: p,
1119
+ patchRegions: b,
1120
1120
  persistedPolygons: S,
1121
- regionStrokeStyle: x,
1121
+ regionStrokeStyle: T,
1122
1122
  regionStrokeHoverStyle: C,
1123
- regionStrokeActiveStyle: W,
1123
+ regionStrokeActiveStyle: Y,
1124
1124
  patchStrokeStyle: F,
1125
- resolveRegionStrokeStyle: O,
1126
- overlayShapes: E,
1127
- hoveredRegionId: N = null,
1128
- activeRegionId: K = null,
1129
- regionLabelStyle: rt,
1130
- invalidateRef: D,
1131
- className: It,
1132
- style: Et
1125
+ resolveRegionStrokeStyle: W,
1126
+ overlayShapes: P,
1127
+ hoveredRegionId: z = null,
1128
+ activeRegionId: J = null,
1129
+ regionLabelStyle: nt,
1130
+ invalidateRef: N,
1131
+ className: Ft,
1132
+ style: vt
1133
1133
  }) {
1134
- const J = tt(null), Ct = tt(!1), Nt = tt(/* @__PURE__ */ new Map()), Qt = tt(e), bt = tt({
1134
+ const Z = tt(null), Ut = tt(!1), Dt = tt(/* @__PURE__ */ new Map()), Qt = tt(e), Mt = tt({
1135
1135
  isDrawing: !1,
1136
1136
  pointerId: null,
1137
1137
  start: null,
1138
1138
  current: null,
1139
1139
  cursor: null,
1140
+ cursorScreen: null,
1140
1141
  points: [],
1142
+ screenPoints: [],
1141
1143
  stampCenter: null
1142
- }), ot = g ?? e !== "cursor", T = $(() => m && m.length > 0 ? m : !S || S.length === 0 ? Rn : S.map((u, f) => ({
1143
- id: f,
1144
+ }), ot = p ?? e !== "cursor", E = K(() => m && m.length > 0 ? m : !S || S.length === 0 ? Pn : S.map((u, h) => ({
1145
+ id: h,
1144
1146
  coordinates: u
1145
- })), [m, S]), R = $(() => p ?? Rn, [p]), v = $(() => {
1147
+ })), [m, S]), R = K(() => b ?? Pn, [b]), v = K(() => {
1146
1148
  const u = [];
1147
- for (let f = 0; f < T.length; f += 1) {
1148
- const y = T[f], M = Nn(y.coordinates);
1149
+ for (let h = 0; h < E.length; h += 1) {
1150
+ const g = E[h], M = Dn(g.coordinates);
1149
1151
  M.length !== 0 && u.push({
1150
- region: y,
1151
- regionIndex: f,
1152
- regionKey: y.id ?? f,
1152
+ region: g,
1153
+ regionIndex: h,
1154
+ regionKey: g.id ?? h,
1153
1155
  polygons: M
1154
1156
  });
1155
1157
  }
1156
1158
  return u;
1157
- }, [T]), V = $(() => {
1159
+ }, [E]), O = K(() => {
1158
1160
  const u = [];
1159
- for (let f = 0; f < R.length; f += 1) {
1160
- const y = R[f], M = Nn(y.coordinates);
1161
+ for (let h = 0; h < R.length; h += 1) {
1162
+ const g = R[h], M = Dn(g.coordinates);
1161
1163
  M.length !== 0 && u.push({
1162
- region: y,
1163
- regionIndex: f,
1164
- regionKey: y.id ?? f,
1164
+ region: g,
1165
+ regionIndex: h,
1166
+ regionKey: g.id ?? h,
1165
1167
  polygons: M
1166
1168
  });
1167
1169
  }
1168
1170
  return u;
1169
- }, [R]), L = $(() => Qn(x), [x]), at = $(() => ae(L, C), [L, C]), st = $(() => ae(L, W), [L, W]), Mt = $(() => ae(Si, F), [F]), mt = $(() => Bi(rt), [rt]), lt = $(() => Ai(o), [o]), G = $(() => Pi(a), [a]), et = $(
1171
+ }, [R]), L = K(() => Qn(T), [T]), at = K(() => ae(L, C), [L, C]), st = K(() => ae(L, Y), [L, Y]), xt = K(() => ae(Si, F), [F]), mt = K(() => Bi(nt), [nt]), lt = K(() => xi(o), [o]), G = K(() => Ri(a), [a]), et = K(
1170
1172
  () => ({
1171
1173
  position: "absolute",
1172
1174
  inset: 0,
@@ -1177,445 +1179,448 @@ function ki({
1177
1179
  touchAction: "none",
1178
1180
  pointerEvents: ot ? "auto" : "none",
1179
1181
  cursor: ot ? e === "brush" ? "none" : "crosshair" : "default",
1180
- ...Et
1182
+ ...vt
1181
1183
  }),
1182
- [ot, e, Et]
1183
- ), Q = B(() => {
1184
- const u = J.current;
1184
+ [ot, e, vt]
1185
+ ), j = U(() => {
1186
+ const u = Z.current;
1185
1187
  if (!u) return;
1186
- const f = u.getBoundingClientRect(), y = Math.max(1, window.devicePixelRatio || 1), M = Math.max(1, Math.round(f.width * y)), P = Math.max(1, Math.round(f.height * y));
1187
- (u.width !== M || u.height !== P) && (u.width = M, u.height = P);
1188
- }, []), X = B(
1188
+ const h = u.getBoundingClientRect(), g = Math.max(1, window.devicePixelRatio || 1), M = Math.max(1, Math.round(h.width * g)), x = Math.max(1, Math.round(h.height * g));
1189
+ (u.width !== M || u.height !== x) && (u.width = M, u.height = x);
1190
+ }, []), k = U(
1189
1191
  (u) => {
1190
- const f = s.current;
1191
- if (!f || u.length === 0) return [];
1192
- const y = new Array(u.length);
1192
+ const h = s.current;
1193
+ if (!h || u.length === 0) return [];
1194
+ const g = new Array(u.length);
1193
1195
  for (let M = 0; M < u.length; M += 1) {
1194
- const P = ee(f.worldToScreen(u[M][0], u[M][1]));
1195
- if (!P) return [];
1196
- y[M] = P;
1196
+ const x = le(h.worldToScreen(u[M][0], u[M][1]));
1197
+ if (!x) return [];
1198
+ g[M] = x;
1197
1199
  }
1198
- return y;
1200
+ return g;
1199
1201
  },
1200
1202
  [s]
1201
- ), dt = B(
1202
- (u, f) => {
1203
- if (!Number.isFinite(f) || f <= 0) return 0;
1204
- const y = s.current;
1205
- if (!y) return 0;
1206
- const M = ee(y.worldToScreen(u[0], u[1]));
1207
- if (M) {
1208
- const U = ee(y.screenToWorld(M[0] + f, M[1]));
1209
- if (U) {
1210
- const z = Math.hypot(U[0] - u[0], U[1] - u[1]);
1211
- if (Number.isFinite(z) && z > 0) return z;
1212
- }
1213
- }
1214
- const P = Math.max(1e-6, y.getViewState?.().zoom ?? 1);
1215
- return f / P;
1203
+ ), dt = U(
1204
+ (u) => {
1205
+ const h = s.current, g = Z.current;
1206
+ if (!h || !g) return null;
1207
+ const M = g.getBoundingClientRect(), x = le(h.screenToWorld(M.left + u[0], M.top + u[1]));
1208
+ return x ? Se(x, t, n) : null;
1216
1209
  },
1217
- [s]
1218
- ), ut = B(
1210
+ [s, t, n]
1211
+ ), ut = U(
1219
1212
  (u) => {
1220
1213
  if (!Number.isFinite(u) || u <= 0) return 0;
1221
- const f = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, y = typeof i == "number" && Number.isFinite(i) ? i : 0, M = s.current?.getViewState?.().zoom, P = typeof M == "number" && Number.isFinite(M) && M > 0 ? M : 1, U = y + Math.log2(P), z = Math.max(1e-9, $n(f, y, U));
1222
- return u / z / P;
1214
+ const h = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, g = typeof i == "number" && Number.isFinite(i) ? i : 0, M = s.current?.getViewState?.().zoom, x = typeof M == "number" && Number.isFinite(M) && M > 0 ? M : 1, B = g + Math.log2(x), V = Math.max(1e-9, Zn(h, g, B));
1215
+ return u / V / x;
1223
1216
  },
1224
1217
  [r, i, s]
1225
- ), ct = B(
1226
- (u, f) => {
1227
- if (!f) return [];
1228
- let y = 0;
1218
+ ), ct = U(
1219
+ (u, h) => {
1220
+ if (!h) return [];
1221
+ let g = 0;
1229
1222
  if (u === "stamp-rectangle-4096px") {
1230
- const U = lt.rectanglePixelSize * 0.5;
1231
- return In(f, U).map((Z) => Xe(Z, t, n));
1223
+ const B = lt.rectanglePixelSize * 0.5;
1224
+ return Cn(h, B).map(($) => Se($, t, n));
1232
1225
  }
1233
- if (u === "stamp-rectangle" || u === "stamp-rectangle-2mm2" ? y = u === "stamp-rectangle-2mm2" ? Kn : lt.rectangleAreaMm2 : (u === "stamp-circle" || u === "stamp-circle-2mm2" || u === "stamp-circle-hpf-0.2mm2") && (y = u === "stamp-circle-hpf-0.2mm2" ? ri : u === "stamp-circle-2mm2" ? Jn : lt.circleAreaMm2), !Number.isFinite(y) || y <= 0) return [];
1234
- const M = vi(y);
1235
- let P = [];
1226
+ if (u === "stamp-rectangle" || u === "stamp-rectangle-2mm2" ? g = u === "stamp-rectangle-2mm2" ? Jn : lt.rectangleAreaMm2 : (u === "stamp-circle" || u === "stamp-circle-2mm2" || u === "stamp-circle-hpf-0.2mm2") && (g = u === "stamp-circle-hpf-0.2mm2" ? ii : u === "stamp-circle-2mm2" ? jn : lt.circleAreaMm2), !Number.isFinite(g) || g <= 0) return [];
1227
+ const M = vi(g);
1228
+ let x = [];
1236
1229
  if (u === "stamp-rectangle" || u === "stamp-rectangle-2mm2") {
1237
- const U = ut(Math.sqrt(M) * 0.5);
1238
- P = In(f, U);
1230
+ const B = ut(Math.sqrt(M) * 0.5);
1231
+ x = Cn(h, B);
1239
1232
  } else if (u === "stamp-circle" || u === "stamp-circle-2mm2" || u === "stamp-circle-hpf-0.2mm2") {
1240
- const U = ut(Math.sqrt(M / Math.PI));
1241
- P = Ii(f, U);
1233
+ const B = ut(Math.sqrt(M / Math.PI));
1234
+ x = Ii(h, B);
1242
1235
  }
1243
- return P.length ? P.map((U) => Xe(U, t, n)) : [];
1236
+ return x.length ? x.map((B) => Se(B, t, n)) : [];
1244
1237
  },
1245
1238
  [ut, t, n, lt]
1246
- ), j = B(() => {
1247
- const u = bt.current;
1248
- return Me(e) ? ct(e, u.stampCenter) : e === "brush" ? [] : u.isDrawing ? e === "freehand" ? u.points : e === "rectangle" ? Cn(u.start, u.current) : e === "circular" ? _n(u.start, u.current) : [] : [];
1249
- }, [e, ct]), _t = B(
1239
+ ), Q = U(() => {
1240
+ const u = Mt.current;
1241
+ return Me(e) ? ct(e, u.stampCenter) : e === "brush" ? [] : u.isDrawing ? e === "freehand" ? u.points : e === "rectangle" ? _n(u.start, u.current) : e === "circular" ? Fn(u.start, u.current) : [] : [];
1242
+ }, [e, ct]), Bt = U(
1250
1243
  (u) => {
1251
- const f = bt.current;
1252
- if (!f.isDrawing || f.points.length === 0) return;
1253
- const y = X(f.points);
1254
- if (y.length === 0) return;
1244
+ const h = Mt.current;
1245
+ if (!h.isDrawing || h.screenPoints.length === 0) return;
1246
+ const g = h.screenPoints;
1247
+ if (g.length === 0) return;
1255
1248
  const M = G.radius;
1256
1249
  if (!(!Number.isFinite(M) || M <= 0)) {
1257
- if (u.save(), u.globalAlpha = G.fillOpacity, u.fillStyle = G.fillColor, u.strokeStyle = G.fillColor, u.lineCap = "round", u.lineJoin = "round", u.lineWidth = M * 2, y.length === 1)
1258
- u.beginPath(), u.arc(y[0][0], y[0][1], M, 0, Math.PI * 2), u.fill();
1250
+ if (u.save(), u.globalAlpha = G.fillOpacity, u.fillStyle = G.fillColor, u.strokeStyle = G.fillColor, u.lineCap = "round", u.lineJoin = "round", u.lineWidth = M * 2, g.length === 1)
1251
+ u.beginPath(), u.arc(g[0][0], g[0][1], M, 0, Math.PI * 2), u.fill();
1259
1252
  else {
1260
- u.beginPath(), u.moveTo(y[0][0], y[0][1]);
1261
- for (let P = 1; P < y.length; P += 1)
1262
- u.lineTo(y[P][0], y[P][1]);
1253
+ u.beginPath(), u.moveTo(g[0][0], g[0][1]);
1254
+ for (let x = 1; x < g.length; x += 1)
1255
+ u.lineTo(g[x][0], g[x][1]);
1263
1256
  u.stroke();
1264
1257
  }
1265
1258
  u.restore();
1266
1259
  }
1267
1260
  },
1268
- [X, G]
1269
- ), Rt = B(
1261
+ [G]
1262
+ ), It = U(
1270
1263
  (u) => {
1271
- const f = bt.current, y = f.cursor;
1272
- if (!y) return;
1273
- const M = ee(s.current?.worldToScreen(y[0], y[1]) ?? []);
1264
+ const h = Mt.current, g = h.cursor;
1265
+ if (!g) return;
1266
+ const M = h.cursorScreen ?? le(s.current?.worldToScreen(g[0], g[1]) ?? []);
1274
1267
  if (!M) return;
1275
- const P = G.radius;
1276
- !Number.isFinite(P) || P <= 0 || (u.save(), u.beginPath(), u.arc(M[0], M[1], P, 0, Math.PI * 2), u.strokeStyle = f.isDrawing ? G.cursorActiveColor : G.cursorColor, u.lineWidth = G.cursorLineWidth, u.setLineDash(G.cursorLineDash), u.stroke(), u.setLineDash(Ce), u.restore());
1268
+ const x = G.radius;
1269
+ !Number.isFinite(x) || x <= 0 || (u.save(), u.beginPath(), u.arc(M[0], M[1], x, 0, Math.PI * 2), u.strokeStyle = h.isDrawing ? G.cursorActiveColor : G.cursorColor, u.lineWidth = G.cursorLineWidth, u.setLineDash(G.cursorLineDash), u.stroke(), u.setLineDash(_e), u.restore());
1277
1270
  },
1278
1271
  [s, G]
1279
- ), Ft = B(() => {
1280
- Q();
1281
- const u = J.current;
1272
+ ), Lt = U(() => {
1273
+ j();
1274
+ const u = Z.current;
1282
1275
  if (!u) return;
1283
- const f = u.getContext("2d");
1284
- if (!f) return;
1285
- const y = Math.max(1, window.devicePixelRatio || 1), M = u.width / y, P = u.height / y;
1286
- if (f.setTransform(1, 0, 0, 1, 0, 0), f.clearRect(0, 0, u.width, u.height), f.setTransform(y, 0, 0, y, 0, 0), v.length > 0)
1287
- for (const U of v) {
1288
- const { region: z, polygons: Z, regionIndex: q, regionKey: gt } = U, kt = Bn(K, gt) ? "active" : Bn(N, gt) ? "hover" : "default";
1289
- let Xt = kt === "active" ? st : kt === "hover" ? at : L;
1290
- if (O) {
1291
- const nt = O({
1292
- region: z,
1276
+ const h = u.getContext("2d");
1277
+ if (!h) return;
1278
+ const g = Math.max(1, window.devicePixelRatio || 1), M = u.width / g, x = u.height / g;
1279
+ if (h.setTransform(1, 0, 0, 1, 0, 0), h.clearRect(0, 0, u.width, u.height), h.setTransform(g, 0, 0, g, 0, 0), v.length > 0)
1280
+ for (const B of v) {
1281
+ const { region: V, polygons: $, regionIndex: q, regionKey: gt } = B, Ot = Ln(J, gt) ? "active" : Ln(z, gt) ? "hover" : "default";
1282
+ let pt = Ot === "active" ? st : Ot === "hover" ? at : L;
1283
+ if (W) {
1284
+ const rt = W({
1285
+ region: V,
1293
1286
  regionId: gt,
1294
1287
  regionIndex: q,
1295
- state: kt
1288
+ state: Ot
1296
1289
  });
1297
- Xt = ae(Xt, nt || void 0);
1290
+ pt = ae(pt, rt || void 0);
1298
1291
  }
1299
- for (const nt of Z) {
1300
- const ht = X(nt.outer);
1301
- ht.length >= 4 && Gt(f, ht, Xt, !0, !1);
1302
- for (const wt of nt.holes) {
1303
- const yt = X(wt);
1304
- yt.length >= 4 && Gt(f, yt, Xt, !0, !1);
1292
+ for (const rt of $) {
1293
+ const bt = k(rt.outer);
1294
+ bt.length >= 4 && $t(h, bt, pt, !0, !1);
1295
+ for (const At of rt.holes) {
1296
+ const Tt = k(At);
1297
+ Tt.length >= 4 && $t(h, Tt, pt, !0, !1);
1305
1298
  }
1306
1299
  }
1307
1300
  }
1308
- if (V.length > 0)
1309
- for (const U of V)
1310
- for (const z of U.polygons) {
1311
- const Z = X(z.outer);
1312
- Z.length >= 4 && Gt(f, Z, Mt, !0, !1);
1313
- for (const q of z.holes) {
1314
- const gt = X(q);
1315
- gt.length >= 4 && Gt(f, gt, Mt, !0, !1);
1301
+ if (O.length > 0)
1302
+ for (const B of O)
1303
+ for (const V of B.polygons) {
1304
+ const $ = k(V.outer);
1305
+ $.length >= 4 && $t(h, $, xt, !0, !1);
1306
+ for (const q of V.holes) {
1307
+ const gt = k(q);
1308
+ gt.length >= 4 && $t(h, gt, xt, !0, !1);
1316
1309
  }
1317
1310
  }
1318
- if (Array.isArray(E) && E.length > 0) {
1319
- const U = !!globalThis.__OPEN_PLANT_DEBUG_OVERLAY__, z = X(
1320
- Ht([
1311
+ if (Array.isArray(P) && P.length > 0) {
1312
+ const B = !!globalThis.__OPEN_PLANT_DEBUG_OVERLAY__, V = k(
1313
+ Xt([
1321
1314
  [0, 0],
1322
1315
  [t, 0],
1323
1316
  [t, n],
1324
1317
  [0, n]
1325
1318
  ])
1326
1319
  );
1327
- for (let Z = 0; Z < E.length; Z += 1) {
1328
- const q = E[Z];
1320
+ for (let $ = 0; $ < P.length; $ += 1) {
1321
+ const q = P[$];
1329
1322
  if (!q?.coordinates?.length || q.visible === !1) continue;
1330
- const gt = q.closed ?? Ci(q.coordinates), kt = Ln(q.coordinates, gt);
1323
+ const gt = q.closed ?? Ci(q.coordinates), Ot = Nn(q.coordinates, gt);
1331
1324
  if (q.invertedFill?.fillColor) {
1332
- const nt = [], ht = Ln(q.coordinates, !0);
1333
- for (const wt of ht) {
1334
- const yt = X(wt);
1335
- yt.length >= 4 && nt.push(yt);
1325
+ const rt = [], bt = Nn(q.coordinates, !0);
1326
+ for (const At of bt) {
1327
+ const Tt = k(At);
1328
+ Tt.length >= 4 && rt.push(Tt);
1336
1329
  }
1337
- if (U) {
1338
- const wt = String(q.id ?? Z), yt = `${z.length}|${ht.length}|${nt.length}|${q.invertedFill.fillColor}`;
1339
- Nt.current.get(wt) !== yt && (Nt.current.set(wt, yt), console.debug("[open-plant] invertedFill", {
1340
- id: q.id ?? Z,
1341
- outerRingPoints: z.length,
1342
- sourceRingCount: ht.length,
1343
- holeRingCount: nt.length,
1330
+ if (B) {
1331
+ const At = String(q.id ?? $), Tt = `${V.length}|${bt.length}|${rt.length}|${q.invertedFill.fillColor}`;
1332
+ Dt.current.get(At) !== Tt && (Dt.current.set(At, Tt), console.debug("[open-plant] invertedFill", {
1333
+ id: q.id ?? $,
1334
+ outerRingPoints: V.length,
1335
+ sourceRingCount: bt.length,
1336
+ holeRingCount: rt.length,
1344
1337
  fillColor: q.invertedFill.fillColor
1345
1338
  }));
1346
1339
  }
1347
- Ui(f, z, nt, q.invertedFill.fillColor);
1340
+ Ui(h, V, rt, q.invertedFill.fillColor);
1348
1341
  }
1349
- if (kt.length === 0) continue;
1350
- const Xt = ae(L, q.stroke ?? q.strokeStyle);
1351
- for (const nt of kt) {
1352
- const ht = X(nt);
1353
- ht.length < 2 || Gt(f, ht, Xt, gt, q.fill ?? !1);
1342
+ if (Ot.length === 0) continue;
1343
+ const pt = ae(L, q.stroke ?? q.strokeStyle);
1344
+ for (const rt of Ot) {
1345
+ const bt = k(rt);
1346
+ bt.length < 2 || $t(h, bt, pt, gt, q.fill ?? !1);
1354
1347
  }
1355
1348
  }
1356
1349
  }
1357
1350
  if (ot)
1358
1351
  if (e === "brush")
1359
- _t(f), Rt(f);
1352
+ Bt(h), It(h);
1360
1353
  else {
1361
- const U = j();
1362
- if (U.length > 0)
1354
+ const B = Q();
1355
+ if (B.length > 0)
1363
1356
  if (e === "freehand") {
1364
- const z = X(U);
1365
- z.length >= 2 && Gt(f, z, L, !1, !1), z.length >= 3 && Gt(f, X(Ht(U)), L, !0, !0);
1357
+ const V = k(B);
1358
+ V.length >= 2 && $t(h, V, L, !1, !1), V.length >= 3 && $t(h, k(Xt(B)), L, !0, !0);
1366
1359
  } else {
1367
- const z = X(U);
1368
- z.length >= 4 && Gt(f, z, L, !0, !0);
1360
+ const V = k(B);
1361
+ V.length >= 4 && $t(h, V, L, !0, !0);
1369
1362
  }
1370
1363
  }
1371
1364
  if (v.length > 0)
1372
- for (const U of v) {
1373
- if (!U.region.label) continue;
1374
- const z = Ni(U.polygons);
1375
- if (!z) continue;
1376
- const Z = ee(s.current?.worldToScreen(z[0], z[1]) ?? []);
1377
- Z && Di(f, U.region.label, Z, M, P, mt);
1365
+ for (const B of v) {
1366
+ if (!B.region.label) continue;
1367
+ const V = Ni(B.polygons);
1368
+ if (!V) continue;
1369
+ const $ = le(s.current?.worldToScreen(V[0], V[1]) ?? []);
1370
+ $ && Di(h, B.region.label, $, M, x, mt);
1378
1371
  }
1379
1372
  }, [
1380
1373
  ot,
1381
1374
  e,
1382
- j,
1383
- _t,
1384
- Rt,
1385
1375
  Q,
1386
- X,
1376
+ Bt,
1377
+ It,
1378
+ j,
1379
+ k,
1387
1380
  t,
1388
1381
  n,
1389
1382
  s,
1390
1383
  v,
1391
- E,
1392
- N,
1393
- K,
1384
+ P,
1385
+ z,
1386
+ J,
1394
1387
  L,
1395
1388
  at,
1396
1389
  st,
1397
- V,
1398
- Mt,
1399
1390
  O,
1391
+ xt,
1392
+ W,
1400
1393
  mt
1401
- ]), _ = B(() => {
1402
- Ct.current || (Ct.current = !0, requestAnimationFrame(() => {
1403
- Ct.current = !1, Ft();
1394
+ ]), _ = U(() => {
1395
+ Ut.current || (Ut.current = !0, requestAnimationFrame(() => {
1396
+ Ut.current = !1, Lt();
1404
1397
  }));
1405
- }, [Ft]), pt = B((u = !1) => {
1406
- const f = bt.current, y = J.current;
1407
- if (y && f.pointerId !== null && y.hasPointerCapture(f.pointerId))
1398
+ }, [Lt]), yt = U((u = !1) => {
1399
+ const h = Mt.current, g = Z.current;
1400
+ if (g && h.pointerId !== null && g.hasPointerCapture(h.pointerId))
1408
1401
  try {
1409
- y.releasePointerCapture(f.pointerId);
1402
+ g.releasePointerCapture(h.pointerId);
1410
1403
  } catch {
1411
1404
  }
1412
- f.isDrawing = !1, f.pointerId = null, f.start = null, f.current = null, f.points = [], f.stampCenter = null, u || (f.cursor = null);
1413
- }, []), Pt = B(
1405
+ h.isDrawing = !1, h.pointerId = null, h.start = null, h.current = null, h.points = [], h.screenPoints = [], h.stampCenter = null, u || (h.cursor = null, h.cursorScreen = null);
1406
+ }, []), Ct = U(
1414
1407
  (u) => {
1415
- const f = s.current;
1416
- if (!f || t <= 0 || n <= 0) return null;
1417
- const y = ee(f.screenToWorld(u.clientX, u.clientY));
1418
- return y ? Xe(y, t, n) : null;
1408
+ const h = s.current;
1409
+ if (!h || t <= 0 || n <= 0) return null;
1410
+ const g = le(h.screenToWorld(u.clientX, u.clientY));
1411
+ return g ? Se(g, t, n) : null;
1419
1412
  },
1420
1413
  [s, t, n]
1421
- ), Ut = B(() => {
1422
- const u = bt.current;
1414
+ ), St = U((u) => {
1415
+ const h = Z.current;
1416
+ if (!h) return null;
1417
+ const g = h.getBoundingClientRect(), M = Yt(u.clientX - g.left, 0, g.width), x = Yt(u.clientY - g.top, 0, g.height);
1418
+ return !Number.isFinite(M) || !Number.isFinite(x) ? null : [M, x];
1419
+ }, []), re = U(() => {
1420
+ const u = Mt.current;
1423
1421
  if (!u.isDrawing) {
1424
- pt(!0), _();
1422
+ yt(!0), _();
1425
1423
  return;
1426
1424
  }
1427
- let f = [];
1425
+ let h = [];
1428
1426
  if (e === "freehand")
1429
- u.points.length >= jr && (f = Ht(u.points));
1427
+ u.points.length >= ti && (h = Xt(u.points));
1430
1428
  else if (e === "rectangle")
1431
- f = Cn(u.start, u.current);
1429
+ h = _n(u.start, u.current);
1432
1430
  else if (e === "circular")
1433
- f = _n(u.start, u.current);
1431
+ h = Fn(u.start, u.current);
1434
1432
  else if (e === "brush") {
1435
- const y = u.points[u.points.length - 1] ?? u.current ?? u.start;
1436
- if (G.clickSelectRoi && y && u.points.length <= 1 && l?.(y)) {
1437
- pt(!0), _();
1433
+ const g = u.points[u.points.length - 1] ?? u.current ?? u.start;
1434
+ if (G.clickSelectRoi && g && u.points.length <= 1 && l?.(g)) {
1435
+ yt(!0), _();
1438
1436
  return;
1439
1437
  }
1440
- const M = u.points[u.points.length - 1] ?? u.current ?? u.start, P = M ? dt(M, G.radius) : 0, U = G.edgeDetail, z = Math.max(
1441
- yi,
1442
- P * 2 / (wi * U)
1443
- );
1444
- f = Hr(u.points, {
1445
- radius: P,
1446
- clipBounds: [0, 0, t, n],
1447
- minRasterStep: z,
1448
- circleSides: Math.max(24, Math.round(64 * U)),
1449
- simplifyTolerance: z * 0.25,
1438
+ const M = G.edgeDetail, x = Math.max(
1439
+ wi,
1440
+ G.radius * 2 / (Mi * M)
1441
+ ), B = u.screenPoints.length > 0 ? u.screenPoints : k(u.points), V = $r(B, {
1442
+ radius: G.radius,
1443
+ minRasterStep: x,
1444
+ circleSides: Math.max(24, Math.round(64 * M)),
1445
+ simplifyTolerance: x * 0.25,
1450
1446
  smoothingPasses: G.edgeSmoothing
1451
- });
1447
+ }), $ = [];
1448
+ for (const q of V) {
1449
+ const gt = dt(q);
1450
+ gt && $.push(gt);
1451
+ }
1452
+ h = Xt($);
1452
1453
  }
1453
- (e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") && Un(f) && c && c({
1454
+ (e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") && Bn(h) && c && c({
1454
1455
  tool: e,
1455
1456
  intent: e === "brush" ? "brush" : "roi",
1456
- coordinates: f,
1457
- bbox: Fn(f),
1458
- areaPx: Ge(f)
1459
- }), pt(!0), _();
1460
- }, [e, c, pt, _, dt, G.radius, G.edgeDetail, G.edgeSmoothing, G.clickSelectRoi, t, n, l]), re = B(
1461
- (u, f) => {
1462
- const y = ct(u, f);
1463
- if (!Un(y)) return;
1464
- const M = u === "stamp-rectangle-4096px" ? "patch" : "roi", P = {
1457
+ coordinates: h,
1458
+ bbox: Un(h),
1459
+ areaPx: Ge(h)
1460
+ }), yt(!0), _();
1461
+ }, [e, c, yt, _, k, dt, G.radius, G.edgeDetail, G.edgeSmoothing, G.clickSelectRoi, l]), Wt = U(
1462
+ (u, h) => {
1463
+ const g = ct(u, h);
1464
+ if (!Bn(g)) return;
1465
+ const M = u === "stamp-rectangle-4096px" ? "patch" : "roi", x = {
1465
1466
  tool: u,
1466
1467
  intent: M,
1467
- coordinates: y,
1468
- bbox: Fn(y),
1469
- areaPx: Ge(y)
1468
+ coordinates: g,
1469
+ bbox: Un(g),
1470
+ areaPx: Ge(g)
1470
1471
  };
1471
- c?.(P), M === "patch" && h && h(P);
1472
+ c?.(x), M === "patch" && f && f(x);
1472
1473
  },
1473
- [ct, c, h]
1474
- ), Bt = B(
1475
- (u, f) => {
1476
- const y = s.current, M = Math.max(1e-6, y?.getViewState?.().zoom ?? 1), P = Mi / M, U = P * P, z = u.points[u.points.length - 1];
1477
- if (!z) {
1478
- u.points.push(f), u.current = f;
1474
+ [ct, c, f]
1475
+ ), wt = U(
1476
+ (u, h, g) => {
1477
+ const M = In * In, x = u.screenPoints[u.screenPoints.length - 1];
1478
+ if (!x) {
1479
+ u.points.push(h), u.screenPoints.push(g), u.current = h;
1479
1480
  return;
1480
1481
  }
1481
- const Z = f[0] - z[0], q = f[1] - z[1];
1482
- Z * Z + q * q >= U ? u.points.push(f) : u.points[u.points.length - 1] = f, u.current = f;
1482
+ const B = g[0] - x[0], V = g[1] - x[1];
1483
+ B * B + V * V >= M ? (u.points.push(h), u.screenPoints.push(g)) : (u.points[u.points.length - 1] = h, u.screenPoints[u.screenPoints.length - 1] = g), u.current = h;
1483
1484
  },
1484
- [s]
1485
- ), St = B(
1485
+ []
1486
+ ), Ue = U(
1486
1487
  (u) => {
1487
1488
  if (!ot || e === "cursor" || u.button !== 0) return;
1488
- const f = Pt(u);
1489
- if (!f) return;
1489
+ const h = Ct(u);
1490
+ if (!h) return;
1491
+ const g = e === "brush" ? St(u) : null;
1492
+ if (e === "brush" && !g) return;
1490
1493
  if (u.preventDefault(), u.stopPropagation(), Me(e)) {
1491
- const P = bt.current;
1492
- P.stampCenter = f, re(e, f), _();
1494
+ const B = Mt.current;
1495
+ B.stampCenter = h, Wt(e, h), _();
1493
1496
  return;
1494
1497
  }
1495
- const y = J.current;
1496
- y && y.setPointerCapture(u.pointerId);
1497
- const M = bt.current;
1498
- M.isDrawing = !0, M.pointerId = u.pointerId, M.start = f, M.current = f, M.cursor = f, M.points = e === "freehand" || e === "brush" ? [f] : [], _();
1498
+ const M = Z.current;
1499
+ M && M.setPointerCapture(u.pointerId);
1500
+ const x = Mt.current;
1501
+ x.isDrawing = !0, x.pointerId = u.pointerId, x.start = h, x.current = h, x.cursor = h, x.cursorScreen = g, x.points = e === "freehand" || e === "brush" ? [h] : [], x.screenPoints = e === "brush" && g ? [g] : [], _();
1499
1502
  },
1500
- [ot, e, Pt, re, _]
1501
- ), Fe = B(
1503
+ [ot, e, Ct, St, Wt, _]
1504
+ ), fe = U(
1502
1505
  (u) => {
1503
1506
  if (!ot || e === "cursor") return;
1504
- const f = Pt(u);
1505
- if (!f) return;
1507
+ const h = Ct(u);
1508
+ if (!h) return;
1506
1509
  if (Me(e)) {
1507
- const M = bt.current;
1508
- M.stampCenter = f, u.preventDefault(), u.stopPropagation(), _();
1510
+ const M = Mt.current;
1511
+ M.stampCenter = h, u.preventDefault(), u.stopPropagation(), _();
1509
1512
  return;
1510
1513
  }
1511
- const y = bt.current;
1514
+ const g = Mt.current;
1512
1515
  if (e === "brush") {
1513
- if (y.cursor = f, !y.isDrawing || y.pointerId !== u.pointerId) {
1516
+ const M = St(u);
1517
+ if (!M) return;
1518
+ if (g.cursor = h, g.cursorScreen = M, !g.isDrawing || g.pointerId !== u.pointerId) {
1514
1519
  _();
1515
1520
  return;
1516
1521
  }
1517
- u.preventDefault(), u.stopPropagation(), Bt(y, f), _();
1522
+ u.preventDefault(), u.stopPropagation(), wt(g, h, M), _();
1518
1523
  return;
1519
1524
  }
1520
- if (!(!y.isDrawing || y.pointerId !== u.pointerId)) {
1525
+ if (!(!g.isDrawing || g.pointerId !== u.pointerId)) {
1521
1526
  if (u.preventDefault(), u.stopPropagation(), e === "freehand") {
1522
- const M = s.current, P = Math.max(1e-6, M?.getViewState?.().zoom ?? 1), U = ti / P, z = U * U, Z = y.points[y.points.length - 1];
1523
- if (!Z)
1524
- y.points.push(f);
1527
+ const M = s.current, x = Math.max(1e-6, M?.getViewState?.().zoom ?? 1), B = ei / x, V = B * B, $ = g.points[g.points.length - 1];
1528
+ if (!$)
1529
+ g.points.push(h);
1525
1530
  else {
1526
- const q = f[0] - Z[0], gt = f[1] - Z[1];
1527
- q * q + gt * gt >= z && y.points.push(f);
1531
+ const q = h[0] - $[0], gt = h[1] - $[1];
1532
+ q * q + gt * gt >= V && g.points.push(h);
1528
1533
  }
1529
1534
  } else
1530
- y.current = f;
1535
+ g.current = h;
1531
1536
  _();
1532
1537
  }
1533
1538
  },
1534
- [ot, e, Pt, _, s, Bt]
1535
- ), ie = B(
1539
+ [ot, e, Ct, St, _, s, wt]
1540
+ ), ie = U(
1536
1541
  (u) => {
1537
- const f = bt.current;
1538
- if (!f.isDrawing || f.pointerId !== u.pointerId) return;
1542
+ const h = Mt.current;
1543
+ if (!h.isDrawing || h.pointerId !== u.pointerId) return;
1539
1544
  u.preventDefault(), u.stopPropagation();
1540
- const y = Pt(u);
1541
- y && (f.cursor = y, e === "brush" ? Bt(f, y) : f.current = y);
1542
- const M = J.current;
1543
- if (M && M.hasPointerCapture(u.pointerId))
1545
+ const g = Ct(u), M = e === "brush" ? St(u) : null;
1546
+ g && (h.cursor = g, e === "brush" ? M && (h.cursorScreen = M, wt(h, g, M)) : h.current = g);
1547
+ const x = Z.current;
1548
+ if (x && x.hasPointerCapture(u.pointerId))
1544
1549
  try {
1545
- M.releasePointerCapture(u.pointerId);
1550
+ x.releasePointerCapture(u.pointerId);
1546
1551
  } catch {
1547
1552
  }
1548
- Ut();
1553
+ re();
1549
1554
  },
1550
- [Ut, Pt, e, Bt]
1551
- ), he = B(() => {
1552
- const u = bt.current;
1553
- let f = !1;
1554
- e === "brush" && !u.isDrawing && u.cursor && (u.cursor = null, f = !0), Me(e) && u.stampCenter && (u.stampCenter = null, f = !0), f && _();
1555
+ [re, Ct, St, e, wt]
1556
+ ), ht = U(() => {
1557
+ const u = Mt.current;
1558
+ let h = !1;
1559
+ e === "brush" && !u.isDrawing && u.cursor && (u.cursor = null, u.cursorScreen = null, h = !0), Me(e) && u.stampCenter && (u.stampCenter = null, h = !0), h && _();
1555
1560
  }, [e, _]);
1556
- return Y(() => {
1557
- Q(), _();
1558
- const u = J.current;
1561
+ return X(() => {
1562
+ j(), _();
1563
+ const u = Z.current;
1559
1564
  if (!u) return;
1560
- const f = new ResizeObserver(() => {
1561
- Q(), _();
1565
+ const h = new ResizeObserver(() => {
1566
+ j(), _();
1562
1567
  });
1563
- return f.observe(u), () => {
1564
- f.disconnect();
1568
+ return h.observe(u), () => {
1569
+ h.disconnect();
1565
1570
  };
1566
- }, [Q, _]), Y(() => {
1567
- ot || pt(), _();
1568
- }, [ot, _, pt]), Y(() => {
1569
- Qt.current !== e && (Qt.current = e, pt(), _());
1570
- }, [e, pt, _]), Y(() => {
1571
+ }, [j, _]), X(() => {
1572
+ ot || yt(), _();
1573
+ }, [ot, _, yt]), X(() => {
1574
+ Qt.current !== e && (Qt.current = e, yt(), _());
1575
+ }, [e, yt, _]), X(() => {
1571
1576
  _();
1572
- }, [d, T, E, _]), Y(() => {
1573
- if (D)
1574
- return D.current = _, () => {
1575
- D.current === _ && (D.current = null);
1577
+ }, [d, E, P, _]), X(() => {
1578
+ if (N)
1579
+ return N.current = _, () => {
1580
+ N.current === _ && (N.current = null);
1576
1581
  };
1577
- }, [D, _]), Y(() => {
1582
+ }, [N, _]), X(() => {
1578
1583
  if (!ot) return;
1579
- const u = (f) => {
1580
- f.key === "Escape" && (pt(), _());
1584
+ const u = (h) => {
1585
+ h.key === "Escape" && (yt(), _());
1581
1586
  };
1582
1587
  return window.addEventListener("keydown", u), () => {
1583
1588
  window.removeEventListener("keydown", u);
1584
1589
  };
1585
- }, [ot, pt, _]), /* @__PURE__ */ zt(
1590
+ }, [ot, yt, _]), /* @__PURE__ */ zt(
1586
1591
  "canvas",
1587
1592
  {
1588
- ref: J,
1589
- className: It,
1593
+ ref: Z,
1594
+ className: Ft,
1590
1595
  style: et,
1591
- onPointerDown: St,
1592
- onPointerMove: Fe,
1596
+ onPointerDown: Ue,
1597
+ onPointerMove: fe,
1593
1598
  onPointerUp: ie,
1594
1599
  onPointerCancel: ie,
1595
- onPointerLeave: he,
1600
+ onPointerLeave: ht,
1596
1601
  onContextMenu: (u) => {
1597
1602
  ot && u.preventDefault();
1598
1603
  },
1599
1604
  onWheel: (u) => {
1600
1605
  if (!ot) return;
1601
- const f = J.current, y = s.current;
1602
- if (!f || typeof y?.zoomBy != "function") return;
1606
+ const h = Z.current, g = s.current;
1607
+ if (!h || typeof g?.zoomBy != "function") return;
1603
1608
  u.preventDefault(), u.stopPropagation();
1604
- const M = f.getBoundingClientRect(), P = u.clientX - M.left, U = u.clientY - M.top;
1605
- y.zoomBy(u.deltaY < 0 ? ii : oi, P, U), _();
1609
+ const M = h.getBoundingClientRect(), x = u.clientX - M.left, B = u.clientY - M.top;
1610
+ g.zoomBy(u.deltaY < 0 ? oi : si, x, B), _();
1606
1611
  }
1607
1612
  }
1608
1613
  );
1609
1614
  }
1610
- function Dn(e) {
1615
+ function kn(e) {
1611
1616
  return String(e ?? "").replace(/\/+$/, "");
1612
1617
  }
1613
- function tr(e) {
1618
+ function er(e) {
1614
1619
  const t = String(e ?? "");
1615
1620
  return t.startsWith("/") ? t : `/${t}`;
1616
1621
  }
1617
1622
  function Xi(e) {
1618
- const t = Dn(e);
1623
+ const t = kn(e);
1619
1624
  if (!t) return "";
1620
1625
  if (/\/TileGroup\d+$/i.test(t)) return t;
1621
1626
  let n = null;
@@ -1625,7 +1630,7 @@ function Xi(e) {
1625
1630
  n = null;
1626
1631
  }
1627
1632
  if (n) {
1628
- const r = `${n.protocol}//${n.host}`, i = Dn(n.pathname || "");
1633
+ const r = `${n.protocol}//${n.host}`, i = kn(n.pathname || "");
1629
1634
  return /\/ims$/i.test(i) ? `${r}${i}` : /\/tiles$/i.test(i) ? `${r}${i}` : `${r}${i}/tiles`;
1630
1635
  }
1631
1636
  return /\/ims$/i.test(t) ? "/ims" : /\/tiles$/i.test(t) ? `${t}` : `${t}/tiles`;
@@ -1634,11 +1639,11 @@ function Fo(e, t) {
1634
1639
  const n = e?.imsInfo || {}, r = !!e?.imsInfo, i = Number(n.width ?? e?.width ?? 0), o = Number(n.height ?? e?.height ?? 0), a = Number(n.tileSize ?? e?.tileSize ?? 0), s = Number(n.zoom ?? e?.zoom ?? 0), l = String(n.path ?? e?.path ?? ""), c = Number(n.mpp ?? e?.mpp ?? 0);
1635
1640
  if (!i || !o || !a || !l)
1636
1641
  throw new Error("이미지 메타데이터가 불완전합니다. width/height/tileSize/path 확인 필요");
1637
- const h = Array.isArray(e?.terms) ? e.terms.map((p) => ({
1638
- termId: String(p?.termId ?? ""),
1639
- termName: String(p?.termName ?? ""),
1640
- termColor: String(p?.termColor ?? "")
1641
- })) : [], g = tr(l), d = Xi(t), m = r ? (p, S, x) => `${d}${g}/${p}/${x}_${S}.webp` : void 0;
1642
+ const f = Array.isArray(e?.terms) ? e.terms.map((b) => ({
1643
+ termId: String(b?.termId ?? ""),
1644
+ termName: String(b?.termName ?? ""),
1645
+ termColor: String(b?.termColor ?? "")
1646
+ })) : [], p = er(l), d = Xi(t), m = r ? (b, S, T) => `${d}${p}/${b}/${T}_${S}.webp` : void 0;
1642
1647
  return {
1643
1648
  id: e?._id || "unknown",
1644
1649
  name: e?.name || "unknown",
@@ -1649,17 +1654,17 @@ function Fo(e, t) {
1649
1654
  maxTierZoom: Number.isFinite(s) ? Math.max(0, Math.floor(s)) : 0,
1650
1655
  tilePath: l,
1651
1656
  tileBaseUrl: t,
1652
- terms: h,
1657
+ terms: f,
1653
1658
  tileUrlBuilder: m
1654
1659
  };
1655
1660
  }
1656
- function er(e, t, n, r) {
1661
+ function nr(e, t, n, r) {
1657
1662
  if (e.tileUrlBuilder)
1658
1663
  return e.tileUrlBuilder(t, n, r);
1659
- const i = tr(e.tilePath);
1664
+ const i = er(e.tilePath);
1660
1665
  return `${e.tileBaseUrl}${i}/${t}/${r}_${n}.webp`;
1661
1666
  }
1662
- const At = {
1667
+ const Et = {
1663
1668
  width: 220,
1664
1669
  height: 140,
1665
1670
  margin: 16,
@@ -1677,7 +1682,7 @@ const At = {
1677
1682
  function ne(e, t, n = 1) {
1678
1683
  return typeof e != "number" || !Number.isFinite(e) ? t : Math.max(n, e);
1679
1684
  }
1680
- function Se(e) {
1685
+ function xe(e) {
1681
1686
  return Array.isArray(e) && e.length === 4 && Number.isFinite(e[0]) && Number.isFinite(e[1]) && Number.isFinite(e[2]) && Number.isFinite(e[3]);
1682
1687
  }
1683
1688
  function Yi({
@@ -1689,231 +1694,231 @@ function Yi({
1689
1694
  className: o,
1690
1695
  style: a
1691
1696
  }) {
1692
- const s = tt(null), l = tt(null), c = tt(null), h = tt({
1697
+ const s = tt(null), l = tt(null), c = tt(null), f = tt({
1693
1698
  active: !1,
1694
1699
  pointerId: null
1695
- }), g = tt(null), d = tt(!1), m = ne(
1700
+ }), p = tt(null), d = tt(!1), m = ne(
1696
1701
  r?.width,
1697
- At.width,
1702
+ Et.width,
1698
1703
  64
1699
- ), p = ne(
1704
+ ), b = ne(
1700
1705
  r?.height,
1701
- At.height,
1706
+ Et.height,
1702
1707
  48
1703
1708
  ), S = ne(
1704
1709
  r?.margin,
1705
- At.margin,
1710
+ Et.margin,
1706
1711
  0
1707
- ), x = ne(
1712
+ ), T = ne(
1708
1713
  r?.borderRadius,
1709
- At.borderRadius,
1714
+ Et.borderRadius,
1710
1715
  0
1711
1716
  ), C = ne(
1712
1717
  r?.borderWidth,
1713
- At.borderWidth,
1718
+ Et.borderWidth,
1714
1719
  0
1715
- ), W = Math.max(
1720
+ ), Y = Math.max(
1716
1721
  1,
1717
1722
  Math.round(
1718
1723
  ne(
1719
1724
  r?.maxThumbnailTiles,
1720
- At.maxThumbnailTiles,
1725
+ Et.maxThumbnailTiles,
1721
1726
  1
1722
1727
  )
1723
1728
  )
1724
- ), F = r?.backgroundColor || At.backgroundColor, O = r?.borderColor || At.borderColor, E = r?.viewportStrokeColor || At.viewportStrokeColor, N = r?.viewportFillColor || At.viewportFillColor, K = r?.interactive ?? At.interactive, rt = r?.showThumbnail ?? At.showThumbnail, D = r?.position || At.position, It = $(() => {
1725
- const T = {};
1726
- return D === "top-left" || D === "bottom-left" ? T.left = S : T.right = S, D === "top-left" || D === "top-right" ? T.top = S : T.bottom = S, {
1729
+ ), F = r?.backgroundColor || Et.backgroundColor, W = r?.borderColor || Et.borderColor, P = r?.viewportStrokeColor || Et.viewportStrokeColor, z = r?.viewportFillColor || Et.viewportFillColor, J = r?.interactive ?? Et.interactive, nt = r?.showThumbnail ?? Et.showThumbnail, N = r?.position || Et.position, Ft = K(() => {
1730
+ const E = {};
1731
+ return N === "top-left" || N === "bottom-left" ? E.left = S : E.right = S, N === "top-left" || N === "top-right" ? E.top = S : E.bottom = S, {
1727
1732
  position: "absolute",
1728
- ...T,
1733
+ ...E,
1729
1734
  width: m,
1730
- height: p,
1731
- borderRadius: x,
1735
+ height: b,
1736
+ borderRadius: T,
1732
1737
  overflow: "hidden",
1733
1738
  zIndex: 4,
1734
- pointerEvents: K ? "auto" : "none",
1739
+ pointerEvents: J ? "auto" : "none",
1735
1740
  touchAction: "none",
1736
1741
  boxShadow: "0 10px 22px rgba(0, 0, 0, 0.3)",
1737
1742
  ...a
1738
1743
  };
1739
- }, [S, D, m, p, x, K, a]), Et = B(() => {
1740
- const T = s.current;
1741
- if (!T) return;
1742
- const R = T.getContext("2d");
1744
+ }, [S, N, m, b, T, J, a]), vt = U(() => {
1745
+ const E = s.current;
1746
+ if (!E) return;
1747
+ const R = E.getContext("2d");
1743
1748
  if (!R) return;
1744
- const v = m, V = p, L = Math.max(1, window.devicePixelRatio || 1), at = Math.max(1, Math.round(v * L)), st = Math.max(1, Math.round(V * L));
1745
- (T.width !== at || T.height !== st) && (T.width = at, T.height = st), R.setTransform(1, 0, 0, 1, 0, 0), R.clearRect(0, 0, T.width, T.height), R.setTransform(L, 0, 0, L, 0, 0), R.fillStyle = F, R.fillRect(0, 0, v, V);
1746
- const Mt = l.current;
1747
- Mt && R.drawImage(Mt, 0, 0, v, V), R.strokeStyle = O, R.lineWidth = C, R.strokeRect(
1749
+ const v = m, O = b, L = Math.max(1, window.devicePixelRatio || 1), at = Math.max(1, Math.round(v * L)), st = Math.max(1, Math.round(O * L));
1750
+ (E.width !== at || E.height !== st) && (E.width = at, E.height = st), R.setTransform(1, 0, 0, 1, 0, 0), R.clearRect(0, 0, E.width, E.height), R.setTransform(L, 0, 0, L, 0, 0), R.fillStyle = F, R.fillRect(0, 0, v, O);
1751
+ const xt = l.current;
1752
+ xt && R.drawImage(xt, 0, 0, v, O), R.strokeStyle = W, R.lineWidth = C, R.strokeRect(
1748
1753
  C * 0.5,
1749
1754
  C * 0.5,
1750
1755
  v - C,
1751
- V - C
1756
+ O - C
1752
1757
  );
1753
- const mt = t.current, lt = mt?.getViewBounds?.(), G = mt?.getViewCorners?.(), et = Se(lt) ? lt : Se(c.current) ? c.current : null;
1758
+ const mt = t.current, lt = mt?.getViewBounds?.(), G = mt?.getViewCorners?.(), et = xe(lt) ? lt : xe(c.current) ? c.current : null;
1754
1759
  if (!et) return;
1755
1760
  c.current = et;
1756
- const Q = v / Math.max(1, e.width), X = V / Math.max(1, e.height), dt = Array.isArray(G) && G.length >= 4 && G.every(
1761
+ const j = v / Math.max(1, e.width), k = O / Math.max(1, e.height), dt = Array.isArray(G) && G.length >= 4 && G.every(
1757
1762
  (_) => Array.isArray(_) && _.length >= 2 && Number.isFinite(_[0]) && Number.isFinite(_[1])
1758
1763
  ) ? G : null;
1759
1764
  if (dt) {
1760
1765
  R.beginPath();
1761
1766
  for (let _ = 0; _ < dt.length; _ += 1) {
1762
- const pt = dt[_], Pt = it(pt[0] * Q, 0, v), Ut = it(pt[1] * X, 0, V);
1763
- _ === 0 ? R.moveTo(Pt, Ut) : R.lineTo(Pt, Ut);
1767
+ const yt = dt[_], Ct = it(yt[0] * j, 0, v), St = it(yt[1] * k, 0, O);
1768
+ _ === 0 ? R.moveTo(Ct, St) : R.lineTo(Ct, St);
1764
1769
  }
1765
- R.closePath(), R.fillStyle = N, R.fill(), R.strokeStyle = E, R.lineWidth = 1.5, R.stroke();
1770
+ R.closePath(), R.fillStyle = z, R.fill(), R.strokeStyle = P, R.lineWidth = 1.5, R.stroke();
1766
1771
  return;
1767
1772
  }
1768
- const ut = it(et[0] * Q, 0, v), ct = it(et[1] * X, 0, V), j = it(et[2] * Q, 0, v), _t = it(et[3] * X, 0, V), Rt = Math.max(1, j - ut), Ft = Math.max(1, _t - ct);
1769
- R.fillStyle = N, R.fillRect(ut, ct, Rt, Ft), R.strokeStyle = E, R.lineWidth = 1.5, R.strokeRect(
1773
+ const ut = it(et[0] * j, 0, v), ct = it(et[1] * k, 0, O), Q = it(et[2] * j, 0, v), Bt = it(et[3] * k, 0, O), It = Math.max(1, Q - ut), Lt = Math.max(1, Bt - ct);
1774
+ R.fillStyle = z, R.fillRect(ut, ct, It, Lt), R.strokeStyle = P, R.lineWidth = 1.5, R.strokeRect(
1770
1775
  ut + 0.5,
1771
1776
  ct + 0.5,
1772
- Math.max(1, Rt - 1),
1773
- Math.max(1, Ft - 1)
1777
+ Math.max(1, It - 1),
1778
+ Math.max(1, Lt - 1)
1774
1779
  );
1775
1780
  }, [
1776
1781
  m,
1777
- p,
1782
+ b,
1778
1783
  F,
1779
- O,
1784
+ W,
1780
1785
  C,
1781
1786
  t,
1782
1787
  e.width,
1783
1788
  e.height,
1784
- N,
1785
- E
1786
- ]), J = B(() => {
1787
- d.current || (d.current = !0, g.current = requestAnimationFrame(() => {
1788
- d.current = !1, g.current = null, Et();
1789
+ z,
1790
+ P
1791
+ ]), Z = U(() => {
1792
+ d.current || (d.current = !0, p.current = requestAnimationFrame(() => {
1793
+ d.current = !1, p.current = null, vt();
1789
1794
  }));
1790
- }, [Et]), Ct = B(
1791
- (T, R) => {
1795
+ }, [vt]), Ut = U(
1796
+ (E, R) => {
1792
1797
  const v = s.current;
1793
1798
  if (!v) return null;
1794
- const V = v.getBoundingClientRect();
1795
- if (!V.width || !V.height) return null;
1796
- const L = it((T - V.left) / V.width, 0, 1), at = it((R - V.top) / V.height, 0, 1);
1799
+ const O = v.getBoundingClientRect();
1800
+ if (!O.width || !O.height) return null;
1801
+ const L = it((E - O.left) / O.width, 0, 1), at = it((R - O.top) / O.height, 0, 1);
1797
1802
  return [L * e.width, at * e.height];
1798
1803
  },
1799
1804
  [e.width, e.height]
1800
- ), Nt = B(
1801
- (T, R) => {
1805
+ ), Dt = U(
1806
+ (E, R) => {
1802
1807
  const v = t.current;
1803
1808
  if (!v) return;
1804
1809
  if (v.setViewCenter) {
1805
- v.setViewCenter(T, R), J();
1810
+ v.setViewCenter(E, R), Z();
1806
1811
  return;
1807
1812
  }
1808
- const V = v.getViewBounds?.(), L = Se(V) ? V : Se(c.current) ? c.current : null;
1813
+ const O = v.getViewBounds?.(), L = xe(O) ? O : xe(c.current) ? c.current : null;
1809
1814
  if (!L) return;
1810
1815
  const at = Math.max(1e-6, L[2] - L[0]), st = Math.max(1e-6, L[3] - L[1]);
1811
1816
  v.setViewState({
1812
- offsetX: T - at * 0.5,
1817
+ offsetX: E - at * 0.5,
1813
1818
  offsetY: R - st * 0.5
1814
- }), J();
1819
+ }), Z();
1815
1820
  },
1816
- [t, J]
1817
- ), Qt = B(
1818
- (T) => {
1819
- if (!K || T.button !== 0) return;
1821
+ [t, Z]
1822
+ ), Qt = U(
1823
+ (E) => {
1824
+ if (!J || E.button !== 0) return;
1820
1825
  const R = s.current;
1821
1826
  if (!R) return;
1822
- const v = Ct(T.clientX, T.clientY);
1823
- v && (T.preventDefault(), T.stopPropagation(), R.setPointerCapture(T.pointerId), h.current = { active: !0, pointerId: T.pointerId }, Nt(v[0], v[1]));
1827
+ const v = Ut(E.clientX, E.clientY);
1828
+ v && (E.preventDefault(), E.stopPropagation(), R.setPointerCapture(E.pointerId), f.current = { active: !0, pointerId: E.pointerId }, Dt(v[0], v[1]));
1824
1829
  },
1825
- [K, Ct, Nt]
1826
- ), bt = B(
1827
- (T) => {
1828
- const R = h.current;
1829
- if (!R.active || R.pointerId !== T.pointerId) return;
1830
- const v = Ct(T.clientX, T.clientY);
1831
- v && (T.preventDefault(), T.stopPropagation(), Nt(v[0], v[1]));
1830
+ [J, Ut, Dt]
1831
+ ), Mt = U(
1832
+ (E) => {
1833
+ const R = f.current;
1834
+ if (!R.active || R.pointerId !== E.pointerId) return;
1835
+ const v = Ut(E.clientX, E.clientY);
1836
+ v && (E.preventDefault(), E.stopPropagation(), Dt(v[0], v[1]));
1832
1837
  },
1833
- [Ct, Nt]
1834
- ), ot = B(
1835
- (T) => {
1836
- const R = h.current;
1837
- if (!R.active || R.pointerId !== T.pointerId) return;
1838
+ [Ut, Dt]
1839
+ ), ot = U(
1840
+ (E) => {
1841
+ const R = f.current;
1842
+ if (!R.active || R.pointerId !== E.pointerId) return;
1838
1843
  const v = s.current;
1839
- if (v && v.hasPointerCapture(T.pointerId))
1844
+ if (v && v.hasPointerCapture(E.pointerId))
1840
1845
  try {
1841
- v.releasePointerCapture(T.pointerId);
1846
+ v.releasePointerCapture(E.pointerId);
1842
1847
  } catch {
1843
1848
  }
1844
- h.current = { active: !1, pointerId: null }, J();
1849
+ f.current = { active: !1, pointerId: null }, Z();
1845
1850
  },
1846
- [J]
1851
+ [Z]
1847
1852
  );
1848
- return Y(() => {
1849
- let T = !1;
1850
- l.current = null, J();
1851
- const R = 0, v = 2 ** (e.maxTierZoom - R), V = Math.ceil(e.width / v), L = Math.ceil(e.height / v), at = Math.max(1, Math.ceil(V / e.tileSize)), st = Math.max(1, Math.ceil(L / e.tileSize)), Mt = at * st;
1852
- if (!rt || Mt > W)
1853
+ return X(() => {
1854
+ let E = !1;
1855
+ l.current = null, Z();
1856
+ const R = 0, v = 2 ** (e.maxTierZoom - R), O = Math.ceil(e.width / v), L = Math.ceil(e.height / v), at = Math.max(1, Math.ceil(O / e.tileSize)), st = Math.max(1, Math.ceil(L / e.tileSize)), xt = at * st;
1857
+ if (!nt || xt > Y)
1853
1858
  return;
1854
1859
  const mt = document.createElement("canvas");
1855
- mt.width = Math.max(1, Math.round(m)), mt.height = Math.max(1, Math.round(p));
1860
+ mt.width = Math.max(1, Math.round(m)), mt.height = Math.max(1, Math.round(b));
1856
1861
  const lt = mt.getContext("2d");
1857
1862
  if (!lt)
1858
1863
  return;
1859
1864
  lt.fillStyle = F, lt.fillRect(0, 0, mt.width, mt.height);
1860
1865
  const G = [];
1861
1866
  for (let et = 0; et < st; et += 1)
1862
- for (let Q = 0; Q < at; Q += 1) {
1863
- const X = Q * e.tileSize * v, dt = et * e.tileSize * v, ut = Math.min((Q + 1) * e.tileSize, V) * v, ct = Math.min((et + 1) * e.tileSize, L) * v;
1867
+ for (let j = 0; j < at; j += 1) {
1868
+ const k = j * e.tileSize * v, dt = et * e.tileSize * v, ut = Math.min((j + 1) * e.tileSize, O) * v, ct = Math.min((et + 1) * e.tileSize, L) * v;
1864
1869
  G.push({
1865
- url: er(e, R, Q, et),
1866
- bounds: [X, dt, ut, ct]
1870
+ url: nr(e, R, j, et),
1871
+ bounds: [k, dt, ut, ct]
1867
1872
  });
1868
1873
  }
1869
1874
  return Promise.allSettled(
1870
1875
  G.map(async (et) => {
1871
- const Q = !!n, X = await fetch(et.url, {
1872
- headers: Q ? { Authorization: n } : void 0
1876
+ const j = !!n, k = await fetch(et.url, {
1877
+ headers: j ? { Authorization: n } : void 0
1873
1878
  });
1874
- if (!X.ok)
1875
- throw new Error(`HTTP ${X.status}`);
1876
- const dt = await createImageBitmap(await X.blob());
1879
+ if (!k.ok)
1880
+ throw new Error(`HTTP ${k.status}`);
1881
+ const dt = await createImageBitmap(await k.blob());
1877
1882
  return { tile: et, bitmap: dt };
1878
1883
  })
1879
1884
  ).then((et) => {
1880
- if (T) {
1885
+ if (E) {
1881
1886
  for (const dt of et)
1882
1887
  dt.status === "fulfilled" && dt.value.bitmap.close();
1883
1888
  return;
1884
1889
  }
1885
- const Q = mt.width / Math.max(1, e.width), X = mt.height / Math.max(1, e.height);
1890
+ const j = mt.width / Math.max(1, e.width), k = mt.height / Math.max(1, e.height);
1886
1891
  for (const dt of et) {
1887
1892
  if (dt.status !== "fulfilled") continue;
1888
1893
  const {
1889
1894
  tile: { bounds: ut },
1890
1895
  bitmap: ct
1891
- } = dt.value, j = ut[0] * Q, _t = ut[1] * X, Rt = Math.max(1, (ut[2] - ut[0]) * Q), Ft = Math.max(1, (ut[3] - ut[1]) * X);
1892
- lt.drawImage(ct, j, _t, Rt, Ft), ct.close();
1896
+ } = dt.value, Q = ut[0] * j, Bt = ut[1] * k, It = Math.max(1, (ut[2] - ut[0]) * j), Lt = Math.max(1, (ut[3] - ut[1]) * k);
1897
+ lt.drawImage(ct, Q, Bt, It, Lt), ct.close();
1893
1898
  }
1894
- l.current = mt, J();
1899
+ l.current = mt, Z();
1895
1900
  }), () => {
1896
- T = !0;
1901
+ E = !0;
1897
1902
  };
1898
1903
  }, [
1899
1904
  e,
1900
1905
  n,
1901
1906
  m,
1902
- p,
1907
+ b,
1903
1908
  F,
1904
- rt,
1905
- W,
1906
- J
1907
- ]), Y(() => {
1908
- J();
1909
- }, [J]), Y(() => {
1909
+ nt,
1910
+ Y,
1911
+ Z
1912
+ ]), X(() => {
1913
+ Z();
1914
+ }, [Z]), X(() => {
1910
1915
  if (i)
1911
- return i.current = J, () => {
1912
- i.current === J && (i.current = null);
1916
+ return i.current = Z, () => {
1917
+ i.current === Z && (i.current = null);
1913
1918
  };
1914
- }, [i, J]), Y(
1919
+ }, [i, Z]), X(
1915
1920
  () => () => {
1916
- h.current = { active: !1, pointerId: null }, g.current !== null && (cancelAnimationFrame(g.current), g.current = null), d.current = !1;
1921
+ f.current = { active: !1, pointerId: null }, p.current !== null && (cancelAnimationFrame(p.current), p.current = null), d.current = !1;
1917
1922
  },
1918
1923
  []
1919
1924
  ), /* @__PURE__ */ zt(
@@ -1921,16 +1926,16 @@ function Yi({
1921
1926
  {
1922
1927
  ref: s,
1923
1928
  className: o,
1924
- style: It,
1929
+ style: Ft,
1925
1930
  onPointerDown: Qt,
1926
- onPointerMove: bt,
1931
+ onPointerMove: Mt,
1927
1932
  onPointerUp: ot,
1928
1933
  onPointerCancel: ot,
1929
- onContextMenu: (T) => {
1930
- T.preventDefault();
1934
+ onContextMenu: (E) => {
1935
+ E.preventDefault();
1931
1936
  },
1932
- onWheel: (T) => {
1933
- T.preventDefault(), T.stopPropagation();
1937
+ onWheel: (E) => {
1938
+ E.preventDefault(), E.stopPropagation();
1934
1939
  }
1935
1940
  }
1936
1941
  );
@@ -1943,32 +1948,32 @@ function Uo({
1943
1948
  className: i,
1944
1949
  style: o
1945
1950
  }) {
1946
- const a = tt(null), s = tt(null), l = $(
1951
+ const a = tt(null), s = tt(null), l = K(
1947
1952
  () => ({ width: "100%", height: "100%", display: "block", ...o }),
1948
1953
  [o]
1949
1954
  );
1950
- return Y(() => {
1955
+ return X(() => {
1951
1956
  const c = a.current;
1952
1957
  if (!c)
1953
1958
  return;
1954
- const h = new Ar({
1959
+ const f = new Ar({
1955
1960
  canvas: c,
1956
1961
  imageWidth: e,
1957
1962
  imageHeight: t,
1958
1963
  initialViewState: r
1959
1964
  });
1960
- return s.current = h, h.setTiles(n), () => {
1961
- h.destroy(), s.current = null;
1965
+ return s.current = f, f.setTiles(n), () => {
1966
+ f.destroy(), s.current = null;
1962
1967
  };
1963
- }, [e, t]), Y(() => {
1968
+ }, [e, t]), X(() => {
1964
1969
  const c = s.current;
1965
1970
  c && c.setTiles(n);
1966
- }, [n]), Y(() => {
1971
+ }, [n]), X(() => {
1967
1972
  const c = s.current;
1968
1973
  !c || !r || c.setViewState(r);
1969
1974
  }, [r]), /* @__PURE__ */ zt("canvas", { ref: a, className: i, style: l });
1970
1975
  }
1971
- function nr(e) {
1976
+ function rr(e) {
1972
1977
  const t = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER;
1973
1978
  return Math.max(
1974
1979
  0,
@@ -1980,45 +1985,45 @@ function nr(e) {
1980
1985
  )
1981
1986
  );
1982
1987
  }
1983
- function _e(e, t) {
1988
+ function Fe(e, t) {
1984
1989
  if (!e || !e.count || !e.positions || !e.paletteIndices)
1985
1990
  return null;
1986
- const n = ce(t ?? []);
1991
+ const n = he(t ?? []);
1987
1992
  if (n.length === 0) {
1988
- const p = {
1993
+ const b = {
1989
1994
  count: 0,
1990
1995
  positions: new Float32Array(0),
1991
1996
  paletteIndices: new Uint16Array(0)
1992
1997
  };
1993
- return e.fillModes instanceof Uint8Array && (p.fillModes = new Uint8Array(0)), e.ids instanceof Uint32Array && (p.ids = new Uint32Array(0)), p;
1998
+ return e.fillModes instanceof Uint8Array && (b.fillModes = new Uint8Array(0)), e.ids instanceof Uint32Array && (b.ids = new Uint32Array(0)), b;
1994
1999
  }
1995
- const r = nr(e), i = e.positions, o = e.paletteIndices, a = e.fillModes instanceof Uint8Array && e.fillModes.length >= r ? e.fillModes : null, s = e.ids instanceof Uint32Array && e.ids.length >= r ? e.ids : null, l = new Float32Array(r * 2), c = new Uint16Array(r), h = a ? new Uint8Array(r) : null, g = s ? new Uint32Array(r) : null;
2000
+ const r = rr(e), i = e.positions, o = e.paletteIndices, a = e.fillModes instanceof Uint8Array && e.fillModes.length >= r ? e.fillModes : null, s = e.ids instanceof Uint32Array && e.ids.length >= r ? e.ids : null, l = new Float32Array(r * 2), c = new Uint16Array(r), f = a ? new Uint8Array(r) : null, p = s ? new Uint32Array(r) : null;
1996
2001
  let d = 0;
1997
- for (let p = 0; p < r; p += 1) {
1998
- const S = i[p * 2], x = i[p * 2 + 1];
1999
- Ie(S, x, n) && (l[d * 2] = S, l[d * 2 + 1] = x, c[d] = o[p], h && (h[d] = a[p]), g && (g[d] = s[p]), d += 1);
2002
+ for (let b = 0; b < r; b += 1) {
2003
+ const S = i[b * 2], T = i[b * 2 + 1];
2004
+ Ce(S, T, n) && (l[d * 2] = S, l[d * 2 + 1] = T, c[d] = o[b], f && (f[d] = a[b]), p && (p[d] = s[b]), d += 1);
2000
2005
  }
2001
2006
  const m = {
2002
2007
  count: d,
2003
2008
  positions: l.subarray(0, d * 2),
2004
2009
  paletteIndices: c.subarray(0, d)
2005
2010
  };
2006
- return h && (m.fillModes = h.subarray(0, d)), g && (m.ids = g.subarray(0, d)), m;
2011
+ return f && (m.fillModes = f.subarray(0, d)), p && (m.ids = p.subarray(0, d)), m;
2007
2012
  }
2008
2013
  function Wi(e, t) {
2009
2014
  if (!e || !e.count || !e.positions || !e.paletteIndices)
2010
2015
  return new Uint32Array(0);
2011
- const n = ce(t ?? []);
2016
+ const n = he(t ?? []);
2012
2017
  if (n.length === 0)
2013
2018
  return new Uint32Array(0);
2014
- const r = nr(e);
2019
+ const r = rr(e);
2015
2020
  if (r === 0)
2016
2021
  return new Uint32Array(0);
2017
2022
  const i = e.positions, o = new Uint32Array(r);
2018
2023
  let a = 0;
2019
2024
  for (let s = 0; s < r; s += 1) {
2020
2025
  const l = i[s * 2], c = i[s * 2 + 1];
2021
- Ie(l, c, n) && (o[a] = s, a += 1);
2026
+ Ce(l, c, n) && (o[a] = s, a += 1);
2022
2027
  }
2023
2028
  return o.subarray(0, a);
2024
2029
  }
@@ -2060,16 +2065,16 @@ function Vi() {
2060
2065
  const e = navigator;
2061
2066
  return typeof e.gpu == "object" && e.gpu !== null;
2062
2067
  }
2063
- function rr() {
2068
+ function ir() {
2064
2069
  if (!Vi()) return null;
2065
2070
  const t = navigator.gpu;
2066
2071
  if (!t || typeof t != "object") return null;
2067
2072
  const n = t;
2068
2073
  return typeof n.requestAdapter != "function" ? null : n;
2069
2074
  }
2070
- const xe = globalThis.GPUShaderStage?.COMPUTE ?? 4, Ye = globalThis.GPUBufferUsage?.STORAGE ?? 128, Te = 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;
2075
+ const Te = globalThis.GPUShaderStage?.COMPUTE ?? 4, Ye = globalThis.GPUBufferUsage?.STORAGE ?? 128, Ee = 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;
2071
2076
  async function Bo() {
2072
- const e = rr();
2077
+ const e = ir();
2073
2078
  if (!e)
2074
2079
  return { supported: !1, features: [] };
2075
2080
  const t = await e.requestAdapter();
@@ -2090,7 +2095,7 @@ async function Bo() {
2090
2095
  }
2091
2096
  async function Zi() {
2092
2097
  return Ae || (Ae = (async () => {
2093
- const e = rr();
2098
+ const e = ir();
2094
2099
  if (!e) return null;
2095
2100
  const t = await e.requestAdapter();
2096
2101
  if (!t) return null;
@@ -2098,22 +2103,22 @@ async function Zi() {
2098
2103
  entries: [
2099
2104
  {
2100
2105
  binding: 0,
2101
- visibility: xe,
2106
+ visibility: Te,
2102
2107
  buffer: { type: "read-only-storage" }
2103
2108
  },
2104
2109
  {
2105
2110
  binding: 1,
2106
- visibility: xe,
2111
+ visibility: Te,
2107
2112
  buffer: { type: "read-only-storage" }
2108
2113
  },
2109
2114
  {
2110
2115
  binding: 2,
2111
- visibility: xe,
2116
+ visibility: Te,
2112
2117
  buffer: { type: "storage" }
2113
2118
  },
2114
2119
  {
2115
2120
  binding: 3,
2116
- visibility: xe,
2121
+ visibility: Te,
2117
2122
  buffer: { type: "uniform" }
2118
2123
  }
2119
2124
  ]
@@ -2127,7 +2132,7 @@ async function Zi() {
2127
2132
  return { device: n, pipeline: i, bindGroupLayout: r };
2128
2133
  })(), Ae);
2129
2134
  }
2130
- function Ee(e, t) {
2135
+ function Pe(e, t) {
2131
2136
  return Math.ceil(e / t) * t;
2132
2137
  }
2133
2138
  async function Ki(e, t, n) {
@@ -2139,27 +2144,27 @@ async function Ki(e, t, n) {
2139
2144
  const a = Math.min(i, Math.floor(e.length / 2));
2140
2145
  if (a === 0)
2141
2146
  return new Uint32Array(0);
2142
- const s = a * 2 * Float32Array.BYTES_PER_ELEMENT, l = o * 4 * Float32Array.BYTES_PER_ELEMENT, c = a * Uint32Array.BYTES_PER_ELEMENT, h = Number(r.device.limits.maxStorageBufferBindingSize);
2143
- if (s > h || l > h || c > h)
2147
+ const s = a * 2 * Float32Array.BYTES_PER_ELEMENT, l = o * 4 * Float32Array.BYTES_PER_ELEMENT, c = a * Uint32Array.BYTES_PER_ELEMENT, f = Number(r.device.limits.maxStorageBufferBindingSize);
2148
+ if (s > f || l > f || c > f)
2144
2149
  return null;
2145
- const g = r.device.createBuffer({
2146
- size: Ee(s, 4),
2147
- usage: Ye | Te
2150
+ const p = r.device.createBuffer({
2151
+ size: Pe(s, 4),
2152
+ usage: Ye | Ee
2148
2153
  }), d = r.device.createBuffer({
2149
- size: Ee(l, 4),
2150
- usage: Ye | Te
2154
+ size: Pe(l, 4),
2155
+ usage: Ye | Ee
2151
2156
  }), m = r.device.createBuffer({
2152
- size: Ee(c, 4),
2157
+ size: Pe(c, 4),
2153
2158
  usage: Ye | Gi
2154
- }), p = r.device.createBuffer({
2159
+ }), b = r.device.createBuffer({
2155
2160
  size: 16,
2156
- usage: qi | Te
2161
+ usage: qi | Ee
2157
2162
  }), S = r.device.createBuffer({
2158
- size: Ee(c, 4),
2159
- usage: Te | Hi
2163
+ size: Pe(c, 4),
2164
+ usage: Ee | Hi
2160
2165
  });
2161
2166
  r.device.queue.writeBuffer(
2162
- g,
2167
+ p,
2163
2168
  0,
2164
2169
  e.buffer,
2165
2170
  e.byteOffset,
@@ -2171,51 +2176,51 @@ async function Ki(e, t, n) {
2171
2176
  n.byteOffset,
2172
2177
  l
2173
2178
  ), r.device.queue.writeBuffer(
2174
- p,
2179
+ b,
2175
2180
  0,
2176
2181
  new Uint32Array([a, o, 0, 0])
2177
2182
  );
2178
- const x = r.device.createBindGroup({
2183
+ const T = r.device.createBindGroup({
2179
2184
  layout: r.bindGroupLayout,
2180
2185
  entries: [
2181
- { binding: 0, resource: { buffer: g } },
2186
+ { binding: 0, resource: { buffer: p } },
2182
2187
  { binding: 1, resource: { buffer: d } },
2183
2188
  { binding: 2, resource: { buffer: m } },
2184
- { binding: 3, resource: { buffer: p } }
2189
+ { binding: 3, resource: { buffer: b } }
2185
2190
  ]
2186
- }), C = r.device.createCommandEncoder(), W = C.beginComputePass();
2187
- W.setPipeline(r.pipeline), W.setBindGroup(0, x), W.dispatchWorkgroups(Math.ceil(a / 256)), W.end(), C.copyBufferToBuffer(m, 0, S, 0, c), r.device.queue.submit([C.finish()]), await S.mapAsync($i);
2188
- const F = S.getMappedRange(), O = new Uint32Array(F.slice(0));
2189
- return S.unmap(), g.destroy(), d.destroy(), m.destroy(), p.destroy(), S.destroy(), O;
2191
+ }), C = r.device.createCommandEncoder(), Y = C.beginComputePass();
2192
+ Y.setPipeline(r.pipeline), Y.setBindGroup(0, T), Y.dispatchWorkgroups(Math.ceil(a / 256)), Y.end(), C.copyBufferToBuffer(m, 0, S, 0, c), r.device.queue.submit([C.finish()]), await S.mapAsync($i);
2193
+ const F = S.getMappedRange(), W = new Uint32Array(F.slice(0));
2194
+ return S.unmap(), p.destroy(), d.destroy(), m.destroy(), b.destroy(), S.destroy(), W;
2190
2195
  }
2191
- function Dt() {
2196
+ function kt() {
2192
2197
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
2193
2198
  }
2194
2199
  async function Ji(e, t, n = {}) {
2195
- const r = Dt(), i = n.bridgeToDraw === !0;
2200
+ const r = kt(), i = n.bridgeToDraw === !0;
2196
2201
  if (!e || !e.count || !e.positions || !e.paletteIndices)
2197
2202
  return {
2198
2203
  data: null,
2199
2204
  meta: {
2200
2205
  mode: "hybrid-webgpu",
2201
- durationMs: Dt() - r,
2206
+ durationMs: kt() - r,
2202
2207
  usedWebGpu: !1,
2203
2208
  candidateCount: 0,
2204
2209
  bridgedToDraw: !1
2205
2210
  }
2206
2211
  };
2207
- const o = ce(t ?? []);
2212
+ const o = he(t ?? []);
2208
2213
  if (o.length === 0) {
2209
- const E = {
2214
+ const P = {
2210
2215
  count: 0,
2211
2216
  positions: new Float32Array(0),
2212
2217
  paletteIndices: new Uint16Array(0)
2213
2218
  };
2214
- return e.fillModes instanceof Uint8Array && (E.fillModes = new Uint8Array(0)), e.ids instanceof Uint32Array && (E.ids = new Uint32Array(0)), {
2215
- data: E,
2219
+ return e.fillModes instanceof Uint8Array && (P.fillModes = new Uint8Array(0)), e.ids instanceof Uint32Array && (P.ids = new Uint32Array(0)), {
2220
+ data: P,
2216
2221
  meta: {
2217
2222
  mode: "hybrid-webgpu",
2218
- durationMs: Dt() - r,
2223
+ durationMs: kt() - r,
2219
2224
  usedWebGpu: !1,
2220
2225
  candidateCount: 0,
2221
2226
  bridgedToDraw: !1
@@ -2224,82 +2229,82 @@ async function Ji(e, t, n = {}) {
2224
2229
  }
2225
2230
  const a = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER, s = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length, a)), l = e.fillModes instanceof Uint8Array && e.fillModes.length >= s ? e.fillModes : null, c = e.ids instanceof Uint32Array && e.ids.length >= s ? e.ids : null;
2226
2231
  if (s === 0) {
2227
- const E = {
2232
+ const P = {
2228
2233
  count: 0,
2229
2234
  positions: new Float32Array(0),
2230
2235
  paletteIndices: new Uint16Array(0)
2231
2236
  };
2232
- return l && (E.fillModes = new Uint8Array(0)), c && (E.ids = new Uint32Array(0)), {
2233
- data: E,
2237
+ return l && (P.fillModes = new Uint8Array(0)), c && (P.ids = new Uint32Array(0)), {
2238
+ data: P,
2234
2239
  meta: {
2235
2240
  mode: "hybrid-webgpu",
2236
- durationMs: Dt() - r,
2241
+ durationMs: kt() - r,
2237
2242
  usedWebGpu: !1,
2238
2243
  candidateCount: 0,
2239
2244
  bridgedToDraw: !1
2240
2245
  }
2241
2246
  };
2242
2247
  }
2243
- const h = new Float32Array(o.length * 4);
2244
- for (let E = 0; E < o.length; E += 1) {
2245
- const N = E * 4, K = o[E];
2246
- h[N] = K.minX, h[N + 1] = K.minY, h[N + 2] = K.maxX, h[N + 3] = K.maxY;
2248
+ const f = new Float32Array(o.length * 4);
2249
+ for (let P = 0; P < o.length; P += 1) {
2250
+ const z = P * 4, J = o[P];
2251
+ f[z] = J.minX, f[z + 1] = J.minY, f[z + 2] = J.maxX, f[z + 3] = J.maxY;
2247
2252
  }
2248
- let g = null, d = !1;
2253
+ let p = null, d = !1;
2249
2254
  try {
2250
- g = await Ki(e.positions, s, h), d = !!g;
2255
+ p = await Ki(e.positions, s, f), d = !!p;
2251
2256
  } catch {
2252
- g = null, d = !1;
2257
+ p = null, d = !1;
2253
2258
  }
2254
- if (!g)
2259
+ if (!p)
2255
2260
  return {
2256
- data: _e(e, t),
2261
+ data: Fe(e, t),
2257
2262
  meta: {
2258
2263
  mode: "hybrid-webgpu",
2259
- durationMs: Dt() - r,
2264
+ durationMs: kt() - r,
2260
2265
  usedWebGpu: !1,
2261
2266
  candidateCount: s,
2262
2267
  bridgedToDraw: !1
2263
2268
  }
2264
2269
  };
2265
2270
  let m = 0;
2266
- for (let E = 0; E < s; E += 1)
2267
- g[E] === 1 && (m += 1);
2268
- const p = new Uint32Array(m);
2271
+ for (let P = 0; P < s; P += 1)
2272
+ p[P] === 1 && (m += 1);
2273
+ const b = new Uint32Array(m);
2269
2274
  if (m > 0) {
2270
- let E = 0;
2271
- for (let N = 0; N < s; N += 1)
2272
- g[N] === 1 && (p[E] = N, E += 1);
2275
+ let P = 0;
2276
+ for (let z = 0; z < s; z += 1)
2277
+ p[z] === 1 && (b[P] = z, P += 1);
2273
2278
  }
2274
2279
  if (m === 0) {
2275
2280
  if (i) {
2276
- const N = {
2281
+ const z = {
2277
2282
  count: s,
2278
2283
  positions: e.positions.subarray(0, s * 2),
2279
2284
  paletteIndices: e.paletteIndices.subarray(0, s),
2280
2285
  drawIndices: new Uint32Array(0)
2281
2286
  };
2282
- return l && (N.fillModes = l.subarray(0, s)), c && (N.ids = c.subarray(0, s)), {
2283
- data: N,
2287
+ return l && (z.fillModes = l.subarray(0, s)), c && (z.ids = c.subarray(0, s)), {
2288
+ data: z,
2284
2289
  meta: {
2285
2290
  mode: "hybrid-webgpu",
2286
- durationMs: Dt() - r,
2291
+ durationMs: kt() - r,
2287
2292
  usedWebGpu: !0,
2288
2293
  candidateCount: 0,
2289
2294
  bridgedToDraw: !0
2290
2295
  }
2291
2296
  };
2292
2297
  }
2293
- const E = {
2298
+ const P = {
2294
2299
  count: 0,
2295
2300
  positions: new Float32Array(0),
2296
2301
  paletteIndices: new Uint16Array(0)
2297
2302
  };
2298
- return l && (E.fillModes = new Uint8Array(0)), c && (E.ids = new Uint32Array(0)), {
2299
- data: E,
2303
+ return l && (P.fillModes = new Uint8Array(0)), c && (P.ids = new Uint32Array(0)), {
2304
+ data: P,
2300
2305
  meta: {
2301
2306
  mode: "hybrid-webgpu",
2302
- durationMs: Dt() - r,
2307
+ durationMs: kt() - r,
2303
2308
  usedWebGpu: !0,
2304
2309
  candidateCount: 0,
2305
2310
  bridgedToDraw: !1
@@ -2307,76 +2312,76 @@ async function Ji(e, t, n = {}) {
2307
2312
  };
2308
2313
  }
2309
2314
  if (i) {
2310
- const E = new Uint32Array(m);
2311
- let N = 0;
2312
- for (let rt = 0; rt < m; rt += 1) {
2313
- const D = p[rt] ?? 0, It = e.positions[D * 2], Et = e.positions[D * 2 + 1];
2314
- Ie(It, Et, o) && (E[N] = D, N += 1);
2315
+ const P = new Uint32Array(m);
2316
+ let z = 0;
2317
+ for (let nt = 0; nt < m; nt += 1) {
2318
+ const N = b[nt] ?? 0, Ft = e.positions[N * 2], vt = e.positions[N * 2 + 1];
2319
+ Ce(Ft, vt, o) && (P[z] = N, z += 1);
2315
2320
  }
2316
- const K = {
2321
+ const J = {
2317
2322
  count: s,
2318
2323
  positions: e.positions.subarray(0, s * 2),
2319
2324
  paletteIndices: e.paletteIndices.subarray(0, s),
2320
- drawIndices: E.subarray(0, N)
2325
+ drawIndices: P.subarray(0, z)
2321
2326
  };
2322
- return l && (K.fillModes = l.subarray(0, s)), c && (K.ids = c.subarray(0, s)), {
2323
- data: K,
2327
+ return l && (J.fillModes = l.subarray(0, s)), c && (J.ids = c.subarray(0, s)), {
2328
+ data: J,
2324
2329
  meta: {
2325
2330
  mode: "hybrid-webgpu",
2326
- durationMs: Dt() - r,
2331
+ durationMs: kt() - r,
2327
2332
  usedWebGpu: !0,
2328
2333
  candidateCount: m,
2329
2334
  bridgedToDraw: !0
2330
2335
  }
2331
2336
  };
2332
2337
  }
2333
- const S = new Float32Array(m * 2), x = new Uint16Array(m), C = l ? new Uint8Array(m) : null, W = c ? new Uint32Array(m) : null;
2338
+ const S = new Float32Array(m * 2), T = new Uint16Array(m), C = l ? new Uint8Array(m) : null, Y = c ? new Uint32Array(m) : null;
2334
2339
  let F = 0;
2335
- for (let E = 0; E < m; E += 1) {
2336
- const N = p[E] ?? 0, K = e.positions[N * 2], rt = e.positions[N * 2 + 1];
2337
- Ie(K, rt, o) && (S[F * 2] = K, S[F * 2 + 1] = rt, x[F] = e.paletteIndices[N], C && (C[F] = l[N]), W && (W[F] = c[N]), F += 1);
2340
+ for (let P = 0; P < m; P += 1) {
2341
+ const z = b[P] ?? 0, J = e.positions[z * 2], nt = e.positions[z * 2 + 1];
2342
+ Ce(J, nt, o) && (S[F * 2] = J, S[F * 2 + 1] = nt, T[F] = e.paletteIndices[z], C && (C[F] = l[z]), Y && (Y[F] = c[z]), F += 1);
2338
2343
  }
2339
- const O = {
2344
+ const W = {
2340
2345
  count: F,
2341
2346
  positions: S.subarray(0, F * 2),
2342
- paletteIndices: x.subarray(0, F)
2347
+ paletteIndices: T.subarray(0, F)
2343
2348
  };
2344
- return C && (O.fillModes = C.subarray(0, F)), W && (O.ids = W.subarray(0, F)), {
2345
- data: O,
2349
+ return C && (W.fillModes = C.subarray(0, F)), Y && (W.ids = Y.subarray(0, F)), {
2350
+ data: W,
2346
2351
  meta: {
2347
2352
  mode: "hybrid-webgpu",
2348
- durationMs: Dt() - r,
2353
+ durationMs: kt() - r,
2349
2354
  usedWebGpu: !0,
2350
2355
  candidateCount: m,
2351
2356
  bridgedToDraw: !1
2352
2357
  }
2353
2358
  };
2354
2359
  }
2355
- let xt = null, He = !0, ir = 1;
2356
- const Zt = /* @__PURE__ */ new Map();
2357
- function $t() {
2360
+ let Pt = null, He = !0, or = 1;
2361
+ const Jt = /* @__PURE__ */ new Map();
2362
+ function Kt() {
2358
2363
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
2359
2364
  }
2360
- function or() {
2365
+ function sr() {
2361
2366
  if (!He) return null;
2362
- if (xt) return xt;
2367
+ if (Pt) return Pt;
2363
2368
  try {
2364
2369
  const e = new Worker(new URL(
2365
2370
  /* @vite-ignore */
2366
2371
  "" + new URL("assets/roi-clip-worker-BDVQwN2T.js", import.meta.url).href,
2367
2372
  import.meta.url
2368
2373
  ), { type: "module" });
2369
- return e.addEventListener("message", je), e.addEventListener("error", tn), xt = e, e;
2374
+ return e.addEventListener("message", Qe), e.addEventListener("error", tn), Pt = e, e;
2370
2375
  } catch {
2371
2376
  return He = !1, null;
2372
2377
  }
2373
2378
  }
2374
- function je(e) {
2379
+ function Qe(e) {
2375
2380
  const t = e.data;
2376
2381
  if (!t) return;
2377
- const n = Zt.get(t.id);
2382
+ const n = Jt.get(t.id);
2378
2383
  if (!n) return;
2379
- if (Zt.delete(t.id), t.type === "roi-clip-failure") {
2384
+ if (Jt.delete(t.id), t.type === "roi-clip-failure") {
2380
2385
  n.reject(new Error(t.error || "worker clip failed"));
2381
2386
  return;
2382
2387
  }
@@ -2385,12 +2390,12 @@ function je(e) {
2385
2390
  n.reject(new Error("worker response mismatch: expected point data result"));
2386
2391
  return;
2387
2392
  }
2388
- const c = Math.max(0, Math.floor(t.count)), h = new Uint32Array(t.indices).subarray(0, c);
2393
+ const c = Math.max(0, Math.floor(t.count)), f = new Uint32Array(t.indices).subarray(0, c);
2389
2394
  n.resolve({
2390
- indices: h,
2395
+ indices: f,
2391
2396
  meta: {
2392
2397
  mode: "worker",
2393
- durationMs: Number.isFinite(t.durationMs) ? t.durationMs : $t() - n.startMs
2398
+ durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Kt() - n.startMs
2394
2399
  }
2395
2400
  });
2396
2401
  return;
@@ -2408,41 +2413,41 @@ function je(e) {
2408
2413
  data: l,
2409
2414
  meta: {
2410
2415
  mode: "worker",
2411
- durationMs: Number.isFinite(t.durationMs) ? t.durationMs : $t() - n.startMs
2416
+ durationMs: Number.isFinite(t.durationMs) ? t.durationMs : Kt() - n.startMs
2412
2417
  }
2413
2418
  });
2414
2419
  }
2415
2420
  function tn() {
2416
- He = !1, xt && (xt.removeEventListener("message", je), xt.removeEventListener("error", tn), xt.terminate(), xt = null);
2417
- for (const [, e] of Zt)
2421
+ He = !1, Pt && (Pt.removeEventListener("message", Qe), Pt.removeEventListener("error", tn), Pt.terminate(), Pt = null);
2422
+ for (const [, e] of Jt)
2418
2423
  e.reject(new Error("worker crashed"));
2419
- Zt.clear();
2424
+ Jt.clear();
2420
2425
  }
2421
- function zo() {
2422
- if (xt) {
2423
- xt.removeEventListener("message", je), xt.removeEventListener("error", tn), xt.terminate(), xt = null;
2424
- for (const [, e] of Zt)
2426
+ function Lo() {
2427
+ if (Pt) {
2428
+ Pt.removeEventListener("message", Qe), Pt.removeEventListener("error", tn), Pt.terminate(), Pt = null;
2429
+ for (const [, e] of Jt)
2425
2430
  e.reject(new Error("worker terminated"));
2426
- Zt.clear();
2431
+ Jt.clear();
2427
2432
  }
2428
2433
  }
2429
- async function Qi(e, t) {
2434
+ async function ji(e, t) {
2430
2435
  if (!e || !e.count || !e.positions || !e.paletteIndices)
2431
2436
  return {
2432
2437
  data: null,
2433
2438
  meta: { mode: "worker", durationMs: 0 }
2434
2439
  };
2435
- const n = or();
2440
+ const n = sr();
2436
2441
  if (!n) {
2437
- const g = $t();
2442
+ const p = Kt();
2438
2443
  return {
2439
- data: _e(e, t),
2440
- meta: { mode: "sync", durationMs: $t() - g }
2444
+ data: Fe(e, t),
2445
+ meta: { mode: "sync", durationMs: Kt() - p }
2441
2446
  };
2442
2447
  }
2443
- const r = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER, i = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length, r)), o = e.positions.slice(0, i * 2), a = e.paletteIndices.slice(0, i), s = e.fillModes instanceof Uint8Array && e.fillModes.length >= i ? e.fillModes.slice(0, i) : null, l = e.ids instanceof Uint32Array && e.ids.length >= i ? e.ids.slice(0, i) : null, c = ir++, h = $t();
2444
- return new Promise((g, d) => {
2445
- Zt.set(c, { kind: "data", resolve: g, reject: d, startMs: h });
2448
+ const r = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER, i = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length, r)), o = e.positions.slice(0, i * 2), a = e.paletteIndices.slice(0, i), s = e.fillModes instanceof Uint8Array && e.fillModes.length >= i ? e.fillModes.slice(0, i) : null, l = e.ids instanceof Uint32Array && e.ids.length >= i ? e.ids.slice(0, i) : null, c = or++, f = Kt();
2449
+ return new Promise((p, d) => {
2450
+ Jt.set(c, { kind: "data", resolve: p, reject: d, startMs: f });
2446
2451
  const m = {
2447
2452
  type: "roi-clip-request",
2448
2453
  id: c,
@@ -2452,41 +2457,41 @@ async function Qi(e, t) {
2452
2457
  fillModes: s?.buffer,
2453
2458
  ids: l?.buffer,
2454
2459
  polygons: t ?? []
2455
- }, p = [o.buffer, a.buffer];
2456
- s && p.push(s.buffer), l && p.push(l.buffer), n.postMessage(m, p);
2460
+ }, b = [o.buffer, a.buffer];
2461
+ s && b.push(s.buffer), l && b.push(l.buffer), n.postMessage(m, b);
2457
2462
  });
2458
2463
  }
2459
- async function Lo(e, t) {
2464
+ async function zo(e, t) {
2460
2465
  if (!e || !e.count || !e.positions || !e.paletteIndices)
2461
2466
  return {
2462
2467
  indices: new Uint32Array(0),
2463
2468
  meta: { mode: "worker", durationMs: 0 }
2464
2469
  };
2465
- const n = or();
2470
+ const n = sr();
2466
2471
  if (!n) {
2467
- const l = $t();
2472
+ const l = Kt();
2468
2473
  return {
2469
2474
  indices: Wi(e, t),
2470
- meta: { mode: "sync", durationMs: $t() - l }
2475
+ meta: { mode: "sync", durationMs: Kt() - l }
2471
2476
  };
2472
2477
  }
2473
- const r = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER, i = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length, r)), o = e.positions.slice(0, i * 2), a = ir++, s = $t();
2478
+ const r = e.fillModes instanceof Uint8Array ? e.fillModes.length : Number.MAX_SAFE_INTEGER, i = Math.max(0, Math.min(e.count, Math.floor(e.positions.length / 2), e.paletteIndices.length, r)), o = e.positions.slice(0, i * 2), a = or++, s = Kt();
2474
2479
  return new Promise((l, c) => {
2475
- Zt.set(a, { kind: "index", resolve: l, reject: c, startMs: s });
2476
- const h = {
2480
+ Jt.set(a, { kind: "index", resolve: l, reject: c, startMs: s });
2481
+ const f = {
2477
2482
  type: "roi-clip-index-request",
2478
2483
  id: a,
2479
2484
  count: i,
2480
2485
  positions: o.buffer,
2481
2486
  polygons: t ?? []
2482
2487
  };
2483
- n.postMessage(h, [o.buffer]);
2488
+ n.postMessage(f, [o.buffer]);
2484
2489
  });
2485
2490
  }
2486
- function ji(e) {
2491
+ function Qi(e) {
2487
2492
  const t = [];
2488
2493
  for (let n = 0; n < e.length; n += 1) {
2489
- const r = e[n], i = ce([r?.coordinates]);
2494
+ const r = e[n], i = he([r?.coordinates]);
2490
2495
  if (i.length === 0) continue;
2491
2496
  let o = 0;
2492
2497
  for (const a of i)
@@ -2525,22 +2530,22 @@ function eo(e, t, n = {}) {
2525
2530
  if (e?.drawIndices instanceof Uint32Array) {
2526
2531
  const d = e.drawIndices;
2527
2532
  let m = d.length;
2528
- for (let p = 0; p < d.length; p += 1)
2529
- d[p] < r || (m -= 1);
2533
+ for (let b = 0; b < d.length; b += 1)
2534
+ d[b] < r || (m -= 1);
2530
2535
  if (m === d.length)
2531
2536
  i = d;
2532
2537
  else if (m > 0) {
2533
- const p = new Uint32Array(m);
2538
+ const b = new Uint32Array(m);
2534
2539
  let S = 0;
2535
- for (let x = 0; x < d.length; x += 1) {
2536
- const C = d[x];
2537
- C >= r || (p[S] = C, S += 1);
2540
+ for (let T = 0; T < d.length; T += 1) {
2541
+ const C = d[T];
2542
+ C >= r || (b[S] = C, S += 1);
2538
2543
  }
2539
- i = p;
2544
+ i = b;
2540
2545
  } else
2541
2546
  i = new Uint32Array(0);
2542
2547
  }
2543
- const o = i ? i.length : r, a = ji(t ?? []);
2548
+ const o = i ? i.length : r, a = Qi(t ?? []);
2544
2549
  if (!e || o === 0 || a.length === 0)
2545
2550
  return {
2546
2551
  groups: [],
@@ -2551,35 +2556,35 @@ function eo(e, t, n = {}) {
2551
2556
  const s = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
2552
2557
  let c = 0;
2553
2558
  for (let d = 0; d < o; d += 1) {
2554
- const m = i ? i[d] : d, p = e.positions[m * 2], S = e.positions[m * 2 + 1];
2555
- let x = null;
2559
+ const m = i ? i[d] : d, b = e.positions[m * 2], S = e.positions[m * 2 + 1];
2560
+ let T = null;
2556
2561
  for (const F of a) {
2557
- let O = !1;
2558
- for (const E of F.polygons)
2559
- if (Qe(p, S, E)) {
2560
- O = !0;
2562
+ let W = !1;
2563
+ for (const P of F.polygons)
2564
+ if (je(b, S, P)) {
2565
+ W = !0;
2561
2566
  break;
2562
2567
  }
2563
- O && (!x || F.area < x.area) && (x = F);
2568
+ W && (!T || F.area < T.area) && (T = F);
2564
2569
  }
2565
- if (!x) continue;
2570
+ if (!T) continue;
2566
2571
  c += 1;
2567
- const C = e.paletteIndices[m] ?? 0, W = s.get(x.regionIndex) ?? /* @__PURE__ */ new Map();
2568
- W.set(C, (W.get(C) ?? 0) + 1), s.set(x.regionIndex, W), l.set(
2569
- x.regionIndex,
2570
- (l.get(x.regionIndex) ?? 0) + 1
2572
+ const C = e.paletteIndices[m] ?? 0, Y = s.get(T.regionIndex) ?? /* @__PURE__ */ new Map();
2573
+ Y.set(C, (Y.get(C) ?? 0) + 1), s.set(T.regionIndex, Y), l.set(
2574
+ T.regionIndex,
2575
+ (l.get(T.regionIndex) ?? 0) + 1
2571
2576
  );
2572
2577
  }
2573
- const h = n.includeEmptyRegions ?? !1, g = [];
2578
+ const f = n.includeEmptyRegions ?? !1, p = [];
2574
2579
  for (const d of a) {
2575
2580
  const m = l.get(d.regionIndex) ?? 0;
2576
- if (!h && m <= 0) continue;
2577
- const p = s.get(d.regionIndex) ?? /* @__PURE__ */ new Map(), S = Array.from(p.entries()).map(([x, C]) => ({
2578
- termId: to(x, n.paletteIndexToTermId),
2579
- paletteIndex: x,
2581
+ if (!f && m <= 0) continue;
2582
+ const b = s.get(d.regionIndex) ?? /* @__PURE__ */ new Map(), S = Array.from(b.entries()).map(([T, C]) => ({
2583
+ termId: to(T, n.paletteIndexToTermId),
2584
+ paletteIndex: T,
2580
2585
  count: C
2581
- })).sort((x, C) => C.count - x.count || x.paletteIndex - C.paletteIndex);
2582
- g.push({
2586
+ })).sort((T, C) => C.count - T.count || T.paletteIndex - C.paletteIndex);
2587
+ p.push({
2583
2588
  regionId: d.regionId,
2584
2589
  regionIndex: d.regionIndex,
2585
2590
  totalCount: m,
@@ -2587,7 +2592,7 @@ function eo(e, t, n = {}) {
2587
2592
  });
2588
2593
  }
2589
2594
  return {
2590
- groups: g,
2595
+ groups: p,
2591
2596
  inputPointCount: o,
2592
2597
  pointsInsideAnyRegion: c,
2593
2598
  unmatchedPointCount: Math.max(0, o - c)
@@ -2755,8 +2760,8 @@ class ro {
2755
2760
  tile: t.tile,
2756
2761
  attempt: s,
2757
2762
  readyAt: Re() + l
2758
- }, h = this.queuedByKey.get(t.tile.key);
2759
- h ? (h.tile = c.tile, h.readyAt = Math.min(h.readyAt, c.readyAt), h.attempt = Math.max(h.attempt, c.attempt)) : (this.queue.push(c), this.queuedByKey.set(c.tile.key, c)), this.sortQueue();
2763
+ }, f = this.queuedByKey.get(t.tile.key);
2764
+ f ? (f.tile = c.tile, f.readyAt = Math.min(f.readyAt, c.readyAt), f.attempt = Math.max(f.attempt, c.attempt)) : (this.queue.push(c), this.queuedByKey.set(c.tile.key, c)), this.sortQueue();
2760
2765
  return;
2761
2766
  }
2762
2767
  this.failedCount += 1, this.onTileError?.(t.tile, o, t.attempt + 1);
@@ -2778,7 +2783,7 @@ class ro {
2778
2783
  this.onStateChange?.(this.getSnapshot());
2779
2784
  }
2780
2785
  }
2781
- const kn = 0.35, $e = 0.5, io = 256, Ze = [
2786
+ const Xn = 0.35, $e = 0.5, io = 256, Ze = [
2782
2787
  { zoom: 1, size: 2.8 },
2783
2788
  { zoom: 2, size: 3.4 },
2784
2789
  { zoom: 3, size: 4.2 },
@@ -2827,11 +2832,11 @@ class oo {
2827
2832
  this.viewState.offsetX = t - this.viewportWidth / (2 * r), this.viewState.offsetY = n - this.viewportHeight / (2 * r);
2828
2833
  }
2829
2834
  screenToWorld(t, n) {
2830
- const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, a] = this.getCenter(), s = (t - this.viewportWidth * 0.5) / i, l = (n - this.viewportHeight * 0.5) / i, c = ue(r.rotationDeg), h = Math.cos(c), g = Math.sin(c);
2831
- return [o + s * h - l * g, a + s * g + l * h];
2835
+ const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, a] = this.getCenter(), s = (t - this.viewportWidth * 0.5) / i, l = (n - this.viewportHeight * 0.5) / i, c = ce(r.rotationDeg), f = Math.cos(c), p = Math.sin(c);
2836
+ return [o + s * f - l * p, a + s * p + l * f];
2832
2837
  }
2833
2838
  worldToScreen(t, n) {
2834
- const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, a] = this.getCenter(), s = t - o, l = n - a, c = ue(r.rotationDeg), h = Math.cos(c), g = Math.sin(c), d = s * h + l * g, m = -s * g + l * h;
2839
+ const r = this.viewState, i = Math.max(1e-6, r.zoom), [o, a] = this.getCenter(), s = t - o, l = n - a, c = ce(r.rotationDeg), f = Math.cos(c), p = Math.sin(c), d = s * f + l * p, m = -s * p + l * f;
2835
2840
  return [
2836
2841
  this.viewportWidth * 0.5 + d * i,
2837
2842
  this.viewportHeight * 0.5 + m * i
@@ -2847,29 +2852,29 @@ class oo {
2847
2852
  ];
2848
2853
  }
2849
2854
  getMatrix() {
2850
- const t = Math.max(1e-6, this.viewState.zoom), [n, r] = this.getCenter(), i = ue(this.viewState.rotationDeg), o = Math.cos(i), a = Math.sin(i), s = 2 * t * o / this.viewportWidth, l = 2 * t * a / this.viewportWidth, c = 2 * t * a / this.viewportHeight, h = -2 * t * o / this.viewportHeight, g = -(s * n + l * r), d = -(c * n + h * r);
2851
- return new Float32Array([s, c, 0, l, h, 0, g, d, 1]);
2855
+ const t = Math.max(1e-6, this.viewState.zoom), [n, r] = this.getCenter(), i = ce(this.viewState.rotationDeg), o = Math.cos(i), a = Math.sin(i), s = 2 * t * o / this.viewportWidth, l = 2 * t * a / this.viewportWidth, c = 2 * t * a / this.viewportHeight, f = -2 * t * o / this.viewportHeight, p = -(s * n + l * r), d = -(c * n + f * r);
2856
+ return new Float32Array([s, c, 0, l, f, 0, p, d, 1]);
2852
2857
  }
2853
2858
  }
2854
- function ue(e) {
2859
+ function ce(e) {
2855
2860
  return e * Math.PI / 180;
2856
2861
  }
2857
- function Xn() {
2862
+ function Yn() {
2858
2863
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
2859
2864
  }
2860
- function qt(e, t, n) {
2865
+ function Zt(e, t, n) {
2861
2866
  const r = e.getUniformLocation(t, n);
2862
2867
  if (!r)
2863
2868
  throw new Error(`uniform location lookup failed: ${n}`);
2864
2869
  return r;
2865
2870
  }
2866
- function Pe(e, t) {
2871
+ function ve(e, t) {
2867
2872
  return !e || !t ? e === t : e.buffer === t.buffer && e.byteOffset === t.byteOffset && e.byteLength === t.byteLength;
2868
2873
  }
2869
2874
  function Ke(e) {
2870
2875
  return e.map((t) => ({ zoom: t.zoom, size: t.size }));
2871
2876
  }
2872
- function Yn(e) {
2877
+ function Wn(e) {
2873
2878
  if (!e) return Ke(Ze);
2874
2879
  const t = /* @__PURE__ */ new Map();
2875
2880
  for (const [n, r] of Object.entries(e)) {
@@ -2893,14 +2898,14 @@ function ao(e, t) {
2893
2898
  for (let a = 1; a < t.length; a += 1) {
2894
2899
  const s = t[a - 1], l = t[a];
2895
2900
  if (e > l.zoom) continue;
2896
- const c = Math.max(1e-6, l.zoom - s.zoom), h = it((e - s.zoom) / c, 0, 1);
2897
- return s.size + (l.size - s.size) * h;
2901
+ const c = Math.max(1e-6, l.zoom - s.zoom), f = it((e - s.zoom) / c, 0, 1);
2902
+ return s.size + (l.size - s.size) * f;
2898
2903
  }
2899
2904
  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;
2900
2905
  return n.size + (e - n.zoom) * o;
2901
2906
  }
2902
2907
  const lo = 0.1, uo = 5;
2903
- function Wn(e) {
2908
+ function On(e) {
2904
2909
  return typeof e != "number" || !Number.isFinite(e) ? 1 : it(e, lo, uo);
2905
2910
  }
2906
2911
  class co {
@@ -2955,7 +2960,7 @@ class co {
2955
2960
  w(this, "boundContextMenu");
2956
2961
  w(this, "boundContextLost");
2957
2962
  w(this, "boundContextRestored");
2958
- 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);
2963
+ 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) : Xn, this.pointSizeStops = Wn(r.pointSizeByZoom), this.pointStrokeScale = On(r.pointStrokeScale);
2959
2964
  const i = t.getContext("webgl2", {
2960
2965
  alpha: !1,
2961
2966
  antialias: !1,
@@ -3019,8 +3024,8 @@ class co {
3019
3024
  t.paletteIndices.length,
3020
3025
  r ? n.length : Number.MAX_SAFE_INTEGER
3021
3026
  )
3022
- ), o = t.positions.subarray(0, i * 2), a = t.paletteIndices.subarray(0, i), s = r ? n.subarray(0, i) : void 0, l = t.drawIndices instanceof Uint32Array, c = l ? this.sanitizeDrawIndices(t.drawIndices, i) : null, h = this.lastPointData, g = h?.fillModes instanceof Uint8Array;
3023
- let d = this.pointBuffersDirty || !h || h.count !== i || !Pe(h.positions, o) || !Pe(h.paletteIndices, a) || g !== r || r && (!h?.fillModes || !Pe(h.fillModes, s)), m = this.pointBuffersDirty || l && (!h?.drawIndices || !Pe(h.drawIndices, c)) || !l && !!h?.drawIndices;
3027
+ ), o = t.positions.subarray(0, i * 2), a = t.paletteIndices.subarray(0, i), s = r ? n.subarray(0, i) : void 0, l = t.drawIndices instanceof Uint32Array, c = l ? this.sanitizeDrawIndices(t.drawIndices, i) : null, f = this.lastPointData, p = f?.fillModes instanceof Uint8Array;
3028
+ let d = this.pointBuffersDirty || !f || f.count !== i || !ve(f.positions, o) || !ve(f.paletteIndices, a) || p !== r || r && (!f?.fillModes || !ve(f.fillModes, s)), m = this.pointBuffersDirty || l && (!f?.drawIndices || !ve(f.drawIndices, c)) || !l && !!f?.drawIndices;
3024
3029
  if (this.lastPointData = {
3025
3030
  count: i,
3026
3031
  positions: o,
@@ -3028,20 +3033,20 @@ class co {
3028
3033
  fillModes: s,
3029
3034
  drawIndices: l ? c ?? void 0 : void 0
3030
3035
  }, this.contextLost || this.gl.isContextLost()) return;
3031
- const p = this.gl;
3032
- d && (p.bindBuffer(p.ARRAY_BUFFER, this.pointProgram.posBuffer), p.bufferData(p.ARRAY_BUFFER, this.lastPointData.positions, p.STATIC_DRAW), p.bindBuffer(p.ARRAY_BUFFER, this.pointProgram.termBuffer), p.bufferData(
3033
- p.ARRAY_BUFFER,
3036
+ const b = this.gl;
3037
+ d && (b.bindBuffer(b.ARRAY_BUFFER, this.pointProgram.posBuffer), b.bufferData(b.ARRAY_BUFFER, this.lastPointData.positions, b.STATIC_DRAW), b.bindBuffer(b.ARRAY_BUFFER, this.pointProgram.termBuffer), b.bufferData(
3038
+ b.ARRAY_BUFFER,
3034
3039
  this.lastPointData.paletteIndices,
3035
- p.STATIC_DRAW
3036
- ), p.bindBuffer(p.ARRAY_BUFFER, this.pointProgram.fillModeBuffer), p.bufferData(
3037
- p.ARRAY_BUFFER,
3040
+ b.STATIC_DRAW
3041
+ ), b.bindBuffer(b.ARRAY_BUFFER, this.pointProgram.fillModeBuffer), b.bufferData(
3042
+ b.ARRAY_BUFFER,
3038
3043
  this.lastPointData.fillModes ?? this.getZeroFillModes(i),
3039
- p.STATIC_DRAW
3040
- ), p.bindBuffer(p.ARRAY_BUFFER, null)), l && m && (p.bindBuffer(p.ELEMENT_ARRAY_BUFFER, this.pointProgram.indexBuffer), p.bufferData(
3041
- p.ELEMENT_ARRAY_BUFFER,
3044
+ b.STATIC_DRAW
3045
+ ), b.bindBuffer(b.ARRAY_BUFFER, null)), l && m && (b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, this.pointProgram.indexBuffer), b.bufferData(
3046
+ b.ELEMENT_ARRAY_BUFFER,
3042
3047
  c ?? new Uint32Array(0),
3043
- p.DYNAMIC_DRAW
3044
- ), p.bindBuffer(p.ELEMENT_ARRAY_BUFFER, null)), this.usePointIndices = l, this.pointCount = l ? c?.length ?? 0 : this.lastPointData.count, (d || m) && (this.pointBuffersDirty = !1), this.requestRender();
3048
+ b.DYNAMIC_DRAW
3049
+ ), b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, null)), this.usePointIndices = l, this.pointCount = l ? c?.length ?? 0 : this.lastPointData.count, (d || m) && (this.pointBuffersDirty = !1), this.requestRender();
3045
3050
  }
3046
3051
  sanitizeDrawIndices(t, n) {
3047
3052
  if (n <= 0 || t.length === 0)
@@ -3069,11 +3074,11 @@ class co {
3069
3074
  this.interactionLocked !== n && (this.interactionLocked = n, n && this.cancelDrag());
3070
3075
  }
3071
3076
  setPointSizeByZoom(t) {
3072
- const n = Yn(t);
3077
+ const n = Wn(t);
3073
3078
  so(this.pointSizeStops, n) || (this.pointSizeStops = n, this.requestRender());
3074
3079
  }
3075
3080
  setPointStrokeScale(t) {
3076
- const n = Wn(t);
3081
+ const n = On(t);
3077
3082
  this.pointStrokeScale !== n && (this.pointStrokeScale = n, this.requestRender());
3078
3083
  }
3079
3084
  cancelDrag() {
@@ -3125,12 +3130,12 @@ class co {
3125
3130
  if (o === i.zoom) return;
3126
3131
  const [a, s] = this.camera.screenToWorld(n, r);
3127
3132
  this.camera.setViewState({ zoom: o });
3128
- const l = this.camera.getViewport(), c = n - l.width * 0.5, h = r - l.height * 0.5, g = ue(this.camera.getViewState().rotationDeg), d = Math.cos(g), m = Math.sin(g), p = c / o * d - h / o * m, S = c / o * m + h / o * d;
3129
- this.camera.setCenter(a - p, s - S), this.clampViewState(), this.emitViewState(), this.requestRender();
3133
+ const l = this.camera.getViewport(), c = n - l.width * 0.5, f = r - l.height * 0.5, p = ce(this.camera.getViewState().rotationDeg), d = Math.cos(p), m = Math.sin(p), b = c / o * d - f / o * m, S = c / o * m + f / o * d;
3134
+ this.camera.setCenter(a - b, s - S), this.clampViewState(), this.emitViewState(), this.requestRender();
3130
3135
  }
3131
3136
  clampViewState() {
3132
- 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, [a, s] = this.camera.getCenter(), l = n * 0.5, c = r * 0.5, h = l - i, g = this.source.width - l + i, d = c - o, m = this.source.height - c + o, p = h <= g ? it(a, h, g) : this.source.width * 0.5, S = d <= m ? it(s, d, m) : this.source.height * 0.5;
3133
- this.camera.setCenter(p, S);
3137
+ 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, [a, s] = this.camera.getCenter(), l = n * 0.5, c = r * 0.5, f = l - i, p = this.source.width - l + i, d = c - o, m = this.source.height - c + o, b = f <= p ? it(a, f, p) : this.source.width * 0.5, S = d <= m ? it(s, d, m) : this.source.height * 0.5;
3138
+ this.camera.setCenter(b, S);
3134
3139
  }
3135
3140
  emitViewState() {
3136
3141
  this.onViewStateChange?.(this.camera.getViewState());
@@ -3152,40 +3157,40 @@ class co {
3152
3157
  getVisibleTiles() {
3153
3158
  const t = this.selectTier();
3154
3159
  this.currentTier = t;
3155
- 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), a = Math.max(1, Math.ceil(i / this.source.tileSize)), s = Math.max(1, Math.ceil(o / this.source.tileSize)), l = n[0], c = n[1], h = n[2], g = n[3], d = it(
3160
+ 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), a = Math.max(1, Math.ceil(i / this.source.tileSize)), s = Math.max(1, Math.ceil(o / this.source.tileSize)), l = n[0], c = n[1], f = n[2], p = n[3], d = it(
3156
3161
  Math.floor(l / r / this.source.tileSize),
3157
3162
  0,
3158
3163
  a - 1
3159
3164
  ), m = it(
3160
- Math.floor((h - 1) / r / this.source.tileSize),
3165
+ Math.floor((f - 1) / r / this.source.tileSize),
3161
3166
  0,
3162
3167
  a - 1
3163
- ), p = it(
3168
+ ), b = it(
3164
3169
  Math.floor(c / r / this.source.tileSize),
3165
3170
  0,
3166
3171
  s - 1
3167
3172
  ), S = it(
3168
- Math.floor((g - 1) / r / this.source.tileSize),
3173
+ Math.floor((p - 1) / r / this.source.tileSize),
3169
3174
  0,
3170
3175
  s - 1
3171
3176
  );
3172
- if (d > m || p > S)
3177
+ if (d > m || b > S)
3173
3178
  return [];
3174
- const x = (l + h) * 0.5 / r / this.source.tileSize, C = (c + g) * 0.5 / r / this.source.tileSize, W = [];
3175
- for (let F = p; F <= S; F += 1)
3176
- for (let O = d; O <= m; O += 1) {
3177
- const E = O * this.source.tileSize * r, N = F * this.source.tileSize * r, K = Math.min((O + 1) * this.source.tileSize, i) * r, rt = Math.min((F + 1) * this.source.tileSize, o) * r, D = O - x, It = F - C;
3178
- W.push({
3179
- key: `${t}/${O}/${F}`,
3179
+ const T = (l + f) * 0.5 / r / this.source.tileSize, C = (c + p) * 0.5 / r / this.source.tileSize, Y = [];
3180
+ for (let F = b; F <= S; F += 1)
3181
+ for (let W = d; W <= m; W += 1) {
3182
+ const P = W * this.source.tileSize * r, z = F * this.source.tileSize * r, J = Math.min((W + 1) * this.source.tileSize, i) * r, nt = Math.min((F + 1) * this.source.tileSize, o) * r, N = W - T, Ft = F - C;
3183
+ Y.push({
3184
+ key: `${t}/${W}/${F}`,
3180
3185
  tier: t,
3181
- x: O,
3186
+ x: W,
3182
3187
  y: F,
3183
- bounds: [E, N, K, rt],
3184
- distance2: D * D + It * It,
3185
- url: er(this.source, t, O, F)
3188
+ bounds: [P, z, J, nt],
3189
+ distance2: N * N + Ft * Ft,
3190
+ url: nr(this.source, t, W, F)
3186
3191
  });
3187
3192
  }
3188
- return W.sort((F, O) => F.distance2 - O.distance2), W;
3193
+ return Y.sort((F, W) => F.distance2 - W.distance2), Y;
3189
3194
  }
3190
3195
  trimCache() {
3191
3196
  if (this.cache.size <= this.maxCacheTiles) return;
@@ -3199,7 +3204,7 @@ class co {
3199
3204
  }
3200
3205
  render() {
3201
3206
  if (this.destroyed || this.contextLost || this.gl.isContextLost()) return;
3202
- const t = Xn();
3207
+ const t = Yn();
3203
3208
  this.frameSerial += 1;
3204
3209
  const n = this.gl, r = this.tileProgram, i = this.pointProgram;
3205
3210
  n.clearColor(0.03, 0.06, 0.1, 1), n.clear(n.COLOR_BUFFER_BIT);
@@ -3218,11 +3223,11 @@ class co {
3218
3223
  d.bounds[3]
3219
3224
  ), n.drawArrays(n.TRIANGLE_STRIP, 0, 4);
3220
3225
  let c = 0;
3221
- const h = [];
3226
+ const f = [];
3222
3227
  for (const d of o) {
3223
3228
  const m = this.cache.get(d.key);
3224
3229
  if (!m) {
3225
- h.push(d);
3230
+ f.push(d);
3226
3231
  continue;
3227
3232
  }
3228
3233
  m.lastUsed = this.frameSerial, n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, m.texture), n.uniform4f(
@@ -3233,15 +3238,15 @@ class co {
3233
3238
  m.bounds[3]
3234
3239
  ), n.drawArrays(n.TRIANGLE_STRIP, 0, 4), c += 1;
3235
3240
  }
3236
- this.tileScheduler.schedule(h), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null);
3237
- let g = 0;
3238
- 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), g = this.pointCount), this.onStats) {
3239
- const d = this.tileScheduler.getSnapshot(), m = c, p = h.length, S = l.length + c + (g > 0 ? 1 : 0);
3241
+ this.tileScheduler.schedule(f), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null);
3242
+ let p = 0;
3243
+ if (this.pointCount > 0 && (n.enable(n.BLEND), n.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), n.useProgram(i.program), n.bindVertexArray(i.vao), n.uniformMatrix3fv(i.uCamera, !1, this.camera.getMatrix()), n.uniform1f(i.uPointSize, this.getPointSizeByZoom()), n.uniform1f(i.uPointStrokeScale, this.pointStrokeScale), n.uniform1f(i.uPaletteSize, this.pointPaletteSize), n.uniform1i(i.uPalette, 1), n.activeTexture(n.TEXTURE1), n.bindTexture(n.TEXTURE_2D, i.paletteTexture), this.usePointIndices ? n.drawElements(n.POINTS, this.pointCount, n.UNSIGNED_INT, 0) : n.drawArrays(n.POINTS, 0, this.pointCount), n.bindTexture(n.TEXTURE_2D, null), n.bindVertexArray(null), p = this.pointCount), this.onStats) {
3244
+ const d = this.tileScheduler.getSnapshot(), m = c, b = f.length, S = l.length + c + (p > 0 ? 1 : 0);
3240
3245
  this.onStats({
3241
3246
  tier: this.currentTier,
3242
3247
  visible: o.length,
3243
3248
  rendered: c,
3244
- points: g,
3249
+ points: p,
3245
3250
  fallback: l.length,
3246
3251
  cache: this.cache.size,
3247
3252
  inflight: d.inflight,
@@ -3250,9 +3255,9 @@ class co {
3250
3255
  failed: d.failed,
3251
3256
  aborted: d.aborted,
3252
3257
  cacheHits: m,
3253
- cacheMisses: p,
3258
+ cacheMisses: b,
3254
3259
  drawCalls: S,
3255
- frameMs: Xn() - t
3260
+ frameMs: Yn() - t
3256
3261
  });
3257
3262
  }
3258
3263
  }
@@ -3276,16 +3281,16 @@ class co {
3276
3281
  if (this.lastPointerX = t.clientX, this.lastPointerY = t.clientY, this.interactionMode === "rotate") {
3277
3282
  const i = this.getPointerAngleRad(t.clientX, t.clientY), o = this.rotateLastAngleRad;
3278
3283
  if (this.rotateLastAngleRad = i, o !== null) {
3279
- const a = i - o, s = Math.atan2(Math.sin(a), Math.cos(a)), l = this.rotationDragSensitivityDegPerPixel / kn, c = this.camera.getViewState();
3284
+ const a = i - o, s = Math.atan2(Math.sin(a), Math.cos(a)), l = this.rotationDragSensitivityDegPerPixel / Xn, c = this.camera.getViewState();
3280
3285
  this.camera.setViewState({
3281
3286
  rotationDeg: c.rotationDeg - s * 180 / Math.PI * l
3282
3287
  });
3283
3288
  }
3284
3289
  } else {
3285
- const i = this.camera.getViewState(), o = Math.max(1e-6, i.zoom), a = ue(i.rotationDeg), s = Math.cos(a), l = Math.sin(a), c = (n * s - r * l) / o, h = (n * l + r * s) / o;
3290
+ const i = this.camera.getViewState(), o = Math.max(1e-6, i.zoom), a = ce(i.rotationDeg), s = Math.cos(a), l = Math.sin(a), c = (n * s - r * l) / o, f = (n * l + r * s) / o;
3286
3291
  this.camera.setViewState({
3287
3292
  offsetX: i.offsetX - c,
3288
- offsetY: i.offsetY - h
3293
+ offsetY: i.offsetY - f
3289
3294
  });
3290
3295
  }
3291
3296
  this.clampViewState(), this.emitViewState(), this.requestRender();
@@ -3352,7 +3357,7 @@ class co {
3352
3357
  out vec4 outColor;
3353
3358
  void main() {
3354
3359
  outColor = texture(uTexture, vUv);
3355
- }`), o = qt(t, i, "uCamera"), a = qt(t, i, "uBounds"), s = qt(t, i, "uTexture"), l = t.createVertexArray(), c = t.createBuffer();
3360
+ }`), o = Zt(t, i, "uCamera"), a = Zt(t, i, "uBounds"), s = Zt(t, i, "uTexture"), l = t.createVertexArray(), c = t.createBuffer();
3356
3361
  if (!l || !c)
3357
3362
  throw new Error("buffer allocation failed");
3358
3363
  t.bindVertexArray(l), t.bindBuffer(t.ARRAY_BUFFER, c), t.bufferData(
@@ -3360,10 +3365,10 @@ class co {
3360
3365
  new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1]),
3361
3366
  t.STATIC_DRAW
3362
3367
  );
3363
- const h = t.getAttribLocation(i, "aUnit"), g = t.getAttribLocation(i, "aUv");
3364
- if (h < 0 || g < 0)
3368
+ const f = t.getAttribLocation(i, "aUnit"), p = t.getAttribLocation(i, "aUv");
3369
+ if (f < 0 || p < 0)
3365
3370
  throw new Error("tile attribute lookup failed");
3366
- return t.enableVertexAttribArray(h), t.enableVertexAttribArray(g), t.vertexAttribPointer(h, 2, t.FLOAT, !1, 16, 0), t.vertexAttribPointer(g, 2, t.FLOAT, !1, 16, 8), t.bindVertexArray(null), t.bindBuffer(t.ARRAY_BUFFER, null), { program: i, vao: l, vbo: c, uCamera: o, uBounds: a, uTexture: s };
3371
+ return t.enableVertexAttribArray(f), t.enableVertexAttribArray(p), t.vertexAttribPointer(f, 2, t.FLOAT, !1, 16, 0), t.vertexAttribPointer(p, 2, t.FLOAT, !1, 16, 8), t.bindVertexArray(null), t.bindBuffer(t.ARRAY_BUFFER, null), { program: i, vao: l, vbo: c, uCamera: o, uBounds: a, uTexture: s };
3367
3372
  }
3368
3373
  initPointProgram() {
3369
3374
  const t = this.gl, i = En(t, `#version 300 es
@@ -3415,22 +3420,22 @@ class co {
3415
3420
  if (alpha <= 0.001) discard;
3416
3421
 
3417
3422
  outColor = vec4(color.rgb * alpha, alpha);
3418
- }`), o = qt(t, i, "uCamera"), a = qt(t, i, "uPointSize"), s = qt(t, i, "uPointStrokeScale"), l = qt(t, i, "uPalette"), c = qt(t, i, "uPaletteSize"), h = t.createVertexArray(), g = t.createBuffer(), d = t.createBuffer(), m = t.createBuffer(), p = t.createBuffer(), S = t.createTexture();
3419
- if (!h || !g || !d || !m || !p || !S)
3423
+ }`), o = Zt(t, i, "uCamera"), a = Zt(t, i, "uPointSize"), s = Zt(t, i, "uPointStrokeScale"), l = Zt(t, i, "uPalette"), c = Zt(t, i, "uPaletteSize"), f = t.createVertexArray(), p = t.createBuffer(), d = t.createBuffer(), m = t.createBuffer(), b = t.createBuffer(), S = t.createTexture();
3424
+ if (!f || !p || !d || !m || !b || !S)
3420
3425
  throw new Error("point buffer allocation failed");
3421
- t.bindVertexArray(h), t.bindBuffer(t.ARRAY_BUFFER, g), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
3422
- const x = t.getAttribLocation(i, "aPosition");
3423
- if (x < 0)
3426
+ t.bindVertexArray(f), t.bindBuffer(t.ARRAY_BUFFER, p), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
3427
+ const T = t.getAttribLocation(i, "aPosition");
3428
+ if (T < 0)
3424
3429
  throw new Error("point position attribute not found");
3425
- 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);
3430
+ t.enableVertexAttribArray(T), t.vertexAttribPointer(T, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ARRAY_BUFFER, d), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
3426
3431
  const C = t.getAttribLocation(i, "aTerm");
3427
3432
  if (C < 0)
3428
3433
  throw new Error("point term attribute not found");
3429
3434
  t.enableVertexAttribArray(C), t.vertexAttribIPointer(C, 1, t.UNSIGNED_SHORT, 0, 0), t.bindBuffer(t.ARRAY_BUFFER, m), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
3430
- const W = t.getAttribLocation(i, "aFillMode");
3431
- if (W < 0)
3435
+ const Y = t.getAttribLocation(i, "aFillMode");
3436
+ if (Y < 0)
3432
3437
  throw new Error("point fill mode attribute not found");
3433
- return t.enableVertexAttribArray(W), t.vertexAttribIPointer(W, 1, t.UNSIGNED_BYTE, 0, 0), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, p), 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(
3438
+ return t.enableVertexAttribArray(Y), t.vertexAttribIPointer(Y, 1, t.UNSIGNED_BYTE, 0, 0), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, b), 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(
3434
3439
  t.TEXTURE_2D,
3435
3440
  0,
3436
3441
  t.RGBA,
@@ -3442,11 +3447,11 @@ class co {
3442
3447
  new Uint8Array([160, 160, 160, 255])
3443
3448
  ), t.bindTexture(t.TEXTURE_2D, null), {
3444
3449
  program: i,
3445
- vao: h,
3446
- posBuffer: g,
3450
+ vao: f,
3451
+ posBuffer: p,
3447
3452
  termBuffer: d,
3448
3453
  fillModeBuffer: m,
3449
- indexBuffer: p,
3454
+ indexBuffer: b,
3450
3455
  paletteTexture: S,
3451
3456
  uCamera: o,
3452
3457
  uPointSize: a,
@@ -3512,7 +3517,7 @@ function So(e, t) {
3512
3517
  const n = Math.max(1, e.width * e.height), i = Math.sqrt(n / Math.max(1, t)) * yo;
3513
3518
  return Math.max(po, Math.min(bo, i));
3514
3519
  }
3515
- function Ao(e, t) {
3520
+ function xo(e, t) {
3516
3521
  if (!e || !e.positions || !e.paletteIndices)
3517
3522
  return null;
3518
3523
  const n = wo(e);
@@ -3521,21 +3526,21 @@ function Ao(e, t) {
3521
3526
  const r = e.positions.subarray(0, n * 2), i = e.ids instanceof Uint32Array && e.ids.length >= n ? e.ids.subarray(0, n) : null, o = Mo(e.drawIndices, n), a = o ? o.length : n;
3522
3527
  if (a === 0)
3523
3528
  return null;
3524
- const s = So(t, a), l = /* @__PURE__ */ new Map(), c = (h) => {
3525
- const g = r[h * 2], d = r[h * 2 + 1];
3526
- if (!Number.isFinite(g) || !Number.isFinite(d)) return;
3527
- const m = Math.floor(g / s), p = Math.floor(d / s);
3529
+ const s = So(t, a), l = /* @__PURE__ */ new Map(), c = (f) => {
3530
+ const p = r[f * 2], d = r[f * 2 + 1];
3531
+ if (!Number.isFinite(p) || !Number.isFinite(d)) return;
3532
+ const m = Math.floor(p / s), b = Math.floor(d / s);
3528
3533
  let S = l.get(m);
3529
3534
  S || (S = /* @__PURE__ */ new Map(), l.set(m, S));
3530
- const x = S.get(p);
3531
- x ? x.push(h) : S.set(p, [h]);
3535
+ const T = S.get(b);
3536
+ T ? T.push(f) : S.set(b, [f]);
3532
3537
  };
3533
3538
  if (o)
3534
- for (let h = 0; h < o.length; h += 1)
3535
- c(o[h] ?? 0);
3539
+ for (let f = 0; f < o.length; f += 1)
3540
+ c(o[f] ?? 0);
3536
3541
  else
3537
- for (let h = 0; h < n; h += 1)
3538
- c(h);
3542
+ for (let f = 0; f < n; f += 1)
3543
+ c(f);
3539
3544
  return l.size === 0 ? null : {
3540
3545
  cellSize: s,
3541
3546
  safeCount: n,
@@ -3547,10 +3552,10 @@ function Ao(e, t) {
3547
3552
  function Je(e, t) {
3548
3553
  return e.id ?? t;
3549
3554
  }
3550
- function xo(e) {
3555
+ function Ao(e) {
3551
3556
  const t = [];
3552
3557
  for (let n = 0; n < e.length; n += 1) {
3553
- const r = e[n], i = ce([r?.coordinates]);
3558
+ const r = e[n], i = he([r?.coordinates]);
3554
3559
  i.length !== 0 && t.push({
3555
3560
  region: r,
3556
3561
  regionIndex: n,
@@ -3565,7 +3570,7 @@ function Oe(e, t) {
3565
3570
  for (let i = t.length - 1; i >= 0; i -= 1) {
3566
3571
  const o = t[i];
3567
3572
  for (const a of o.polygons)
3568
- if (Qe(n, r, a))
3573
+ if (je(n, r, a))
3569
3574
  return {
3570
3575
  region: o.region,
3571
3576
  regionIndex: o.regionIndex,
@@ -3585,48 +3590,48 @@ function No({
3585
3590
  debugOverlay: s = !1,
3586
3591
  debugOverlayStyle: l,
3587
3592
  fitNonce: c = 0,
3588
- rotationResetNonce: h = 0,
3589
- authToken: g = "",
3593
+ rotationResetNonce: f = 0,
3594
+ authToken: p = "",
3590
3595
  ctrlDragRotate: d = !0,
3591
3596
  pointData: m = null,
3592
- pointPalette: p = null,
3597
+ pointPalette: b = null,
3593
3598
  pointSizeByZoom: S,
3594
- pointStrokeScale: x,
3599
+ pointStrokeScale: T,
3595
3600
  roiRegions: C,
3596
- roiPolygons: W,
3601
+ roiPolygons: Y,
3597
3602
  clipPointsToRois: F = !1,
3598
- clipMode: O = "worker",
3599
- onClipStats: E,
3600
- onRoiPointGroups: N,
3601
- roiPaletteIndexToTermId: K,
3602
- interactionLock: rt = !1,
3603
- drawTool: D = "cursor",
3604
- stampOptions: It,
3605
- brushOptions: Et,
3606
- regionStrokeStyle: J,
3607
- regionStrokeHoverStyle: Ct,
3608
- regionStrokeActiveStyle: Nt,
3603
+ clipMode: W = "worker",
3604
+ onClipStats: P,
3605
+ onRoiPointGroups: z,
3606
+ roiPaletteIndexToTermId: J,
3607
+ interactionLock: nt = !1,
3608
+ drawTool: N = "cursor",
3609
+ stampOptions: Ft,
3610
+ brushOptions: vt,
3611
+ regionStrokeStyle: Z,
3612
+ regionStrokeHoverStyle: Ut,
3613
+ regionStrokeActiveStyle: Dt,
3609
3614
  patchStrokeStyle: Qt,
3610
- resolveRegionStrokeStyle: bt,
3615
+ resolveRegionStrokeStyle: Mt,
3611
3616
  overlayShapes: ot,
3612
- customLayers: T,
3617
+ customLayers: E,
3613
3618
  patchRegions: R,
3614
3619
  regionLabelStyle: v,
3615
- onPointerWorldMove: V,
3620
+ onPointerWorldMove: O,
3616
3621
  onPointHover: L,
3617
3622
  onPointClick: at,
3618
3623
  onRegionHover: st,
3619
- onRegionClick: Mt,
3624
+ onRegionClick: xt,
3620
3625
  onActiveRegionChange: mt,
3621
3626
  getCellByCoordinatesRef: lt,
3622
3627
  onDrawComplete: G,
3623
3628
  onPatchComplete: et,
3624
- showOverviewMap: Q = !1,
3625
- overviewMapOptions: X,
3629
+ showOverviewMap: j = !1,
3630
+ overviewMapOptions: k,
3626
3631
  className: dt,
3627
3632
  style: ut
3628
3633
  }) {
3629
- const ct = tt(null), j = tt(null), _t = tt(null), Rt = tt(null), Ft = tt(n), _ = tt(r), pt = tt(s), [Pt, Ut] = te(!0), [re, Bt] = te(null), [St, Fe] = te(null), [ie, he] = te(null), [u, f] = te(null), y = tt(null), M = tt(null), P = tt(null), U = tt(0), z = C ?? We, Z = R ?? We, q = W ?? ho, gt = (T?.length ?? 0) > 0, kt = $(() => ({ position: "relative", width: "100%", height: "100%", ...ut }), [ut]), Xt = $(
3634
+ const ct = tt(null), Q = tt(null), Bt = tt(null), It = tt(null), Lt = tt(n), _ = tt(r), yt = tt(s), [Ct, St] = ee(!0), [re, Wt] = ee(null), [wt, Ue] = ee(null), [fe, ie] = ee(null), [ht, u] = ee(null), h = tt(null), g = tt(null), M = tt(null), x = tt(0), B = C ?? We, V = R ?? We, $ = Y ?? ho, q = (E?.length ?? 0) > 0, gt = K(() => ({ position: "relative", width: "100%", height: "100%", ...ut }), [ut]), Ot = K(
3630
3635
  () => ({
3631
3636
  position: "absolute",
3632
3637
  top: 8,
@@ -3648,27 +3653,24 @@ function No({
3648
3653
  ...l
3649
3654
  }),
3650
3655
  [l]
3651
- ), nt = $(() => z.length > 0 ? z : q.length === 0 ? We : q.map((b, A) => ({
3656
+ ), pt = K(() => B.length > 0 ? B : $.length === 0 ? We : $.map((y, A) => ({
3652
3657
  id: A,
3653
- coordinates: b
3654
- })), [z, q]), ht = $(() => xo(nt), [nt]), wt = $(
3655
- () => nt.map((b) => b.coordinates),
3656
- [nt]
3657
- ), [yt, fe] = te(m);
3658
- Y(() => {
3659
- const b = ++U.current;
3658
+ coordinates: y
3659
+ })), [B, $]), rt = K(() => Ao(pt), [pt]), bt = K(() => pt.map((y) => y.coordinates), [pt]), [At, Tt] = ee(m);
3660
+ X(() => {
3661
+ const y = ++x.current;
3660
3662
  let A = !1;
3661
3663
  if (!F)
3662
- return fe(m), () => {
3664
+ return Tt(m), () => {
3663
3665
  A = !0;
3664
3666
  };
3665
3667
  if (!m || !m.count || !m.positions || !m.paletteIndices)
3666
- return fe(null), () => {
3668
+ return Tt(null), () => {
3667
3669
  A = !0;
3668
3670
  };
3669
- if (wt.length === 0)
3670
- return fe(fo), E?.({
3671
- mode: O,
3671
+ if (bt.length === 0)
3672
+ return Tt(fo), P?.({
3673
+ mode: W,
3672
3674
  durationMs: 0,
3673
3675
  inputCount: m.count,
3674
3676
  outputCount: 0,
@@ -3676,244 +3678,244 @@ function No({
3676
3678
  }), () => {
3677
3679
  A = !0;
3678
3680
  };
3679
- const I = (k, ft) => {
3680
- if (A || b !== U.current) return;
3681
- const ge = k?.drawIndices ? k.drawIndices.length : k?.count ?? 0;
3682
- fe(k), E?.({
3681
+ const I = (D, ft) => {
3682
+ if (A || y !== x.current) return;
3683
+ const ge = D?.drawIndices ? D.drawIndices.length : D?.count ?? 0;
3684
+ Tt(D), P?.({
3683
3685
  mode: ft.mode,
3684
3686
  durationMs: ft.durationMs,
3685
3687
  inputCount: m.count,
3686
3688
  outputCount: ge,
3687
- polygonCount: wt.length,
3689
+ polygonCount: bt.length,
3688
3690
  usedWebGpu: ft.usedWebGpu,
3689
3691
  candidateCount: ft.candidateCount,
3690
3692
  bridgedToDraw: ft.bridgedToDraw
3691
3693
  });
3692
3694
  };
3693
3695
  return (async () => {
3694
- if (O === "sync") {
3695
- const k = performance.now(), ft = _e(m, wt);
3696
+ if (W === "sync") {
3697
+ const D = performance.now(), ft = Fe(m, bt);
3696
3698
  I(ft, {
3697
3699
  mode: "sync",
3698
- durationMs: performance.now() - k
3700
+ durationMs: performance.now() - D
3699
3701
  });
3700
3702
  return;
3701
3703
  }
3702
- if (O === "hybrid-webgpu") {
3703
- const k = await Ji(m, wt, { bridgeToDraw: !0 });
3704
- I(k.data, {
3705
- mode: k.meta.mode,
3706
- durationMs: k.meta.durationMs,
3707
- usedWebGpu: k.meta.usedWebGpu,
3708
- candidateCount: k.meta.candidateCount,
3709
- bridgedToDraw: k.meta.bridgedToDraw
3704
+ if (W === "hybrid-webgpu") {
3705
+ const D = await Ji(m, bt, { bridgeToDraw: !0 });
3706
+ I(D.data, {
3707
+ mode: D.meta.mode,
3708
+ durationMs: D.meta.durationMs,
3709
+ usedWebGpu: D.meta.usedWebGpu,
3710
+ candidateCount: D.meta.candidateCount,
3711
+ bridgedToDraw: D.meta.bridgedToDraw
3710
3712
  });
3711
3713
  return;
3712
3714
  }
3713
3715
  try {
3714
- const k = await Qi(m, wt);
3715
- I(k.data, {
3716
- mode: k.meta.mode,
3717
- durationMs: k.meta.durationMs
3716
+ const D = await ji(m, bt);
3717
+ I(D.data, {
3718
+ mode: D.meta.mode,
3719
+ durationMs: D.meta.durationMs
3718
3720
  });
3719
3721
  } catch {
3720
- const k = performance.now(), ft = _e(m, wt);
3722
+ const D = performance.now(), ft = Fe(m, bt);
3721
3723
  I(ft, {
3722
3724
  mode: "sync",
3723
- durationMs: performance.now() - k
3725
+ durationMs: performance.now() - D
3724
3726
  });
3725
3727
  }
3726
3728
  })(), () => {
3727
3729
  A = !0;
3728
3730
  };
3729
- }, [F, O, m, wt, E]);
3730
- const en = !!(L || at || lt), Tt = $(() => en ? Ao(yt, e) : null, [en, yt, e]), Kt = B(
3731
- (b) => {
3732
- const A = j.current;
3733
- if (!A || !Tt) return null;
3734
- const I = Number(b[0]), H = Number(b[1]);
3731
+ }, [F, W, m, bt, P]);
3732
+ const en = !!(L || at || lt), Rt = K(() => en ? xo(At, e) : null, [en, At, e]), jt = U(
3733
+ (y) => {
3734
+ const A = Q.current;
3735
+ if (!A || !Rt) return null;
3736
+ const I = Number(y[0]), H = Number(y[1]);
3735
3737
  if (!Number.isFinite(I) || !Number.isFinite(H)) return null;
3736
- const k = Math.max(1e-6, A.getViewState().zoom), ft = A.getPointSizeByZoom(), oe = Math.max(go, ft * mo) / k;
3738
+ const D = Math.max(1e-6, A.getViewState().zoom), ft = A.getPointSizeByZoom(), oe = Math.max(go, ft * mo) / D;
3737
3739
  if (!Number.isFinite(oe) || oe <= 0) return null;
3738
- const Ue = Tt.cellSize, cn = Math.floor(I / Ue), hn = Math.floor(H / Ue), pe = Math.max(1, Math.ceil(oe / Ue)), fr = oe * oe;
3739
- let be = -1, fn = fr, dn = 0, mn = 0;
3740
- for (let Be = cn - pe; Be <= cn + pe; Be += 1) {
3741
- const gn = Tt.buckets.get(Be);
3740
+ const Be = Rt.cellSize, cn = Math.floor(I / Be), hn = Math.floor(H / Be), pe = Math.max(1, Math.ceil(oe / Be)), dr = oe * oe;
3741
+ let be = -1, fn = dr, dn = 0, mn = 0;
3742
+ for (let Le = cn - pe; Le <= cn + pe; Le += 1) {
3743
+ const gn = Rt.buckets.get(Le);
3742
3744
  if (gn)
3743
3745
  for (let ze = hn - pe; ze <= hn + pe; ze += 1) {
3744
3746
  const ye = gn.get(ze);
3745
3747
  if (!(!ye || ye.length === 0))
3746
- for (let Le = 0; Le < ye.length; Le += 1) {
3747
- const we = ye[Le];
3748
- if (we >= Tt.safeCount) continue;
3749
- const pn = Tt.positions[we * 2], bn = Tt.positions[we * 2 + 1], yn = pn - I, wn = bn - H, Mn = yn * yn + wn * wn;
3748
+ for (let Ne = 0; Ne < ye.length; Ne += 1) {
3749
+ const we = ye[Ne];
3750
+ if (we >= Rt.safeCount) continue;
3751
+ const pn = Rt.positions[we * 2], bn = Rt.positions[we * 2 + 1], yn = pn - I, wn = bn - H, Mn = yn * yn + wn * wn;
3750
3752
  Mn > fn || (fn = Mn, be = we, dn = pn, mn = bn);
3751
3753
  }
3752
3754
  }
3753
3755
  }
3754
3756
  if (be < 0) return null;
3755
- const dr = Tt.ids ? Number(Tt.ids[be]) : null;
3757
+ const mr = Rt.ids ? Number(Rt.ids[be]) : null;
3756
3758
  return {
3757
3759
  index: be,
3758
- id: dr,
3760
+ id: mr,
3759
3761
  coordinate: [I, H],
3760
3762
  pointCoordinate: [dn, mn]
3761
3763
  };
3762
3764
  },
3763
- [Tt]
3764
- ), jt = B(
3765
- (b, A) => {
3765
+ [Rt]
3766
+ ), te = U(
3767
+ (y, A) => {
3766
3768
  if (!L) return;
3767
- const I = b?.index ?? null, H = b?.id ?? null;
3768
- M.current === I && P.current === H || (M.current = I, P.current = H, L({
3769
+ const I = y?.index ?? null, H = y?.id ?? null;
3770
+ g.current === I && M.current === H || (g.current = I, M.current = H, L({
3769
3771
  index: I,
3770
3772
  id: H,
3771
3773
  coordinate: A,
3772
- pointCoordinate: b?.pointCoordinate ?? null
3774
+ pointCoordinate: y?.pointCoordinate ?? null
3773
3775
  }));
3774
3776
  },
3775
3777
  [L]
3776
- ), de = B(
3777
- (b, A) => {
3778
+ ), de = U(
3779
+ (y, A) => {
3778
3780
  if (!at) return;
3779
- const I = Kt(b);
3781
+ const I = jt(y);
3780
3782
  I && at({
3781
3783
  ...I,
3782
3784
  button: A
3783
3785
  });
3784
3786
  },
3785
- [at, Kt]
3787
+ [at, jt]
3786
3788
  );
3787
- $(() => {
3788
- const b = Number(X?.width ?? 220);
3789
- return Number.isFinite(b) ? Math.max(64, b) : 220;
3790
- }, [X?.width]);
3791
- const nn = $(() => {
3792
- const b = Number(X?.height ?? 140);
3793
- return Number.isFinite(b) ? Math.max(48, b) : 140;
3794
- }, [X?.height]), Yt = $(() => {
3795
- const b = Number(X?.margin ?? 16);
3796
- return Number.isFinite(b) ? Math.max(0, b) : 16;
3797
- }, [X?.margin]), me = X?.position || "bottom-right";
3798
- Y(() => {
3789
+ K(() => {
3790
+ const y = Number(k?.width ?? 220);
3791
+ return Number.isFinite(y) ? Math.max(64, y) : 220;
3792
+ }, [k?.width]);
3793
+ const nn = K(() => {
3794
+ const y = Number(k?.height ?? 140);
3795
+ return Number.isFinite(y) ? Math.max(48, y) : 140;
3796
+ }, [k?.height]), Vt = K(() => {
3797
+ const y = Number(k?.margin ?? 16);
3798
+ return Number.isFinite(y) ? Math.max(0, y) : 16;
3799
+ }, [k?.margin]), me = k?.position || "bottom-right";
3800
+ X(() => {
3799
3801
  if (lt)
3800
- return lt.current = Kt, () => {
3801
- lt.current === Kt && (lt.current = null);
3802
+ return lt.current = jt, () => {
3803
+ lt.current === jt && (lt.current = null);
3802
3804
  };
3803
- }, [lt, Kt]);
3804
- const Wt = B(
3805
- (b) => {
3806
- Fe((A) => String(A) === String(b) ? A : (mt?.(b), b));
3805
+ }, [lt, jt]);
3806
+ const Gt = U(
3807
+ (y) => {
3808
+ Ue((A) => String(A) === String(y) ? A : (mt?.(y), y));
3807
3809
  },
3808
3810
  [mt]
3809
3811
  );
3810
- Y(() => {
3811
- Ft.current = n;
3812
- }, [n]), Y(() => {
3812
+ X(() => {
3813
+ Lt.current = n;
3814
+ }, [n]), X(() => {
3813
3815
  _.current = r;
3814
- }, [r]), Y(() => {
3815
- pt.current = s, s || f(null);
3816
+ }, [r]), X(() => {
3817
+ yt.current = s, s || u(null);
3816
3818
  }, [s]);
3817
- const rn = B((b) => {
3818
- _.current?.(b), pt.current && f(b);
3819
- }, []), sr = $(() => u ? [
3820
- `tier ${u.tier} | frame ${u.frameMs?.toFixed(2) ?? "-"} ms | drawCalls ${u.drawCalls ?? "-"}`,
3821
- `tiles visible ${u.visible} | rendered ${u.rendered} | fallback ${u.fallback}`,
3822
- `cache size ${u.cache} | hit ${u.cacheHits ?? "-"} | miss ${u.cacheMisses ?? "-"}`,
3823
- `queue inflight ${u.inflight} | queued ${u.queued ?? "-"} | retries ${u.retries ?? "-"} | failed ${u.failed ?? "-"} | aborted ${u.aborted ?? "-"}`,
3824
- `points ${u.points}`
3819
+ const rn = U((y) => {
3820
+ _.current?.(y), yt.current && u(y);
3821
+ }, []), ar = K(() => ht ? [
3822
+ `tier ${ht.tier} | frame ${ht.frameMs?.toFixed(2) ?? "-"} ms | drawCalls ${ht.drawCalls ?? "-"}`,
3823
+ `tiles visible ${ht.visible} | rendered ${ht.rendered} | fallback ${ht.fallback}`,
3824
+ `cache size ${ht.cache} | hit ${ht.cacheHits ?? "-"} | miss ${ht.cacheMisses ?? "-"}`,
3825
+ `queue inflight ${ht.inflight} | queued ${ht.queued ?? "-"} | retries ${ht.retries ?? "-"} | failed ${ht.failed ?? "-"} | aborted ${ht.aborted ?? "-"}`,
3826
+ `points ${ht.points}`
3825
3827
  ].join(`
3826
- `) : "stats: waiting for first frame...", [u]);
3827
- Y(() => {
3828
- !(St === null ? !0 : nt.some((H, k) => String(Je(H, k)) === String(St))) && St !== null && Wt(null);
3829
- const A = y.current;
3830
- !(A === null ? !0 : nt.some((H, k) => String(Je(H, k)) === String(A))) && A !== null && (y.current = null, Bt(null), st?.({
3828
+ `) : "stats: waiting for first frame...", [ht]);
3829
+ X(() => {
3830
+ !(wt === null ? !0 : pt.some((H, D) => String(Je(H, D)) === String(wt))) && wt !== null && Gt(null);
3831
+ const A = h.current;
3832
+ !(A === null ? !0 : pt.some((H, D) => String(Je(H, D)) === String(A))) && A !== null && (h.current = null, Wt(null), st?.({
3831
3833
  region: null,
3832
3834
  regionId: null,
3833
3835
  regionIndex: -1,
3834
3836
  coordinate: null
3835
3837
  }));
3836
- }, [nt, St, st, Wt]), Y(() => {
3837
- const b = M.current;
3838
- b !== null && (Tt && b < Tt.safeCount || (M.current = null, P.current = null, L?.({
3838
+ }, [pt, wt, st, Gt]), X(() => {
3839
+ const y = g.current;
3840
+ y !== null && (Rt && y < Rt.safeCount || (g.current = null, M.current = null, L?.({
3839
3841
  index: null,
3840
3842
  id: null,
3841
3843
  coordinate: null,
3842
3844
  pointCoordinate: null
3843
3845
  })));
3844
- }, [Tt, L]);
3845
- const on = B(
3846
- (b) => {
3847
- gt && he(b);
3848
- const A = Ft.current;
3849
- A && A(b), _t.current?.(), Rt.current?.();
3846
+ }, [Rt, L]);
3847
+ const on = U(
3848
+ (y) => {
3849
+ q && ie(y);
3850
+ const A = Lt.current;
3851
+ A && A(y), Bt.current?.(), It.current?.();
3850
3852
  },
3851
- [gt]
3853
+ [q]
3852
3854
  );
3853
- Y(() => {
3854
- if (!Q) {
3855
- Ut(!1);
3855
+ X(() => {
3856
+ if (!j) {
3857
+ St(!1);
3856
3858
  return;
3857
3859
  }
3858
- Ut(!0);
3859
- }, [Q, e?.id]), Y(() => {
3860
- D !== "cursor" && y.current !== null && (y.current = null, Bt(null), st?.({
3860
+ St(!0);
3861
+ }, [j, e?.id]), X(() => {
3862
+ N !== "cursor" && h.current !== null && (h.current = null, Wt(null), st?.({
3861
3863
  region: null,
3862
3864
  regionId: null,
3863
3865
  regionIndex: -1,
3864
3866
  coordinate: null
3865
3867
  }));
3866
- }, [D, st]), Y(() => {
3867
- D !== "cursor" && M.current !== null && (M.current = null, P.current = null, L?.({
3868
+ }, [N, st]), X(() => {
3869
+ N !== "cursor" && g.current !== null && (g.current = null, M.current = null, L?.({
3868
3870
  index: null,
3869
3871
  id: null,
3870
3872
  coordinate: null,
3871
3873
  pointCoordinate: null
3872
3874
  }));
3873
- }, [D, L]);
3874
- const Ot = B((b, A) => {
3875
- const I = j.current;
3875
+ }, [N, L]);
3876
+ const qt = U((y, A) => {
3877
+ const I = Q.current;
3876
3878
  if (!I) return null;
3877
- const H = I.screenToWorld(b, A);
3879
+ const H = I.screenToWorld(y, A);
3878
3880
  if (!Array.isArray(H) || H.length < 2) return null;
3879
- const k = Number(H[0]), ft = Number(H[1]);
3880
- return !Number.isFinite(k) || !Number.isFinite(ft) ? null : [k, ft];
3881
- }, []), sn = B((b, A) => {
3882
- const I = j.current;
3881
+ const D = Number(H[0]), ft = Number(H[1]);
3882
+ return !Number.isFinite(D) || !Number.isFinite(ft) ? null : [D, ft];
3883
+ }, []), sn = U((y, A) => {
3884
+ const I = Q.current;
3883
3885
  if (!I) return null;
3884
- const H = I.worldToScreen(b, A);
3886
+ const H = I.worldToScreen(y, A);
3885
3887
  if (!Array.isArray(H) || H.length < 2) return null;
3886
- const k = Number(H[0]), ft = Number(H[1]);
3887
- return !Number.isFinite(k) || !Number.isFinite(ft) ? null : [k, ft];
3888
- }, []), an = B(() => {
3889
- j.current?.requestRender(), _t.current?.(), Rt.current?.();
3890
- }, []), ln = $(() => ie ?? j.current?.getViewState() ?? null, [ie]), un = $(() => {
3888
+ const D = Number(H[0]), ft = Number(H[1]);
3889
+ return !Number.isFinite(D) || !Number.isFinite(ft) ? null : [D, ft];
3890
+ }, []), an = U(() => {
3891
+ Q.current?.requestRender(), Bt.current?.(), It.current?.();
3892
+ }, []), ln = K(() => fe ?? Q.current?.getViewState() ?? null, [fe]), un = K(() => {
3891
3893
  if (!e) return null;
3892
- const b = ln;
3893
- return b ? {
3894
+ const y = ln;
3895
+ return y ? {
3894
3896
  source: e,
3895
- viewState: b,
3896
- drawTool: D,
3897
- interactionLock: rt,
3897
+ viewState: y,
3898
+ drawTool: N,
3899
+ interactionLock: nt,
3898
3900
  worldToScreen: sn,
3899
- screenToWorld: Ot,
3901
+ screenToWorld: qt,
3900
3902
  requestRedraw: an
3901
3903
  } : null;
3902
- }, [e, ln, D, rt, sn, Ot, an]), ar = B(
3903
- (b) => {
3904
- const A = b.target === ct.current, I = Ot(b.clientX, b.clientY);
3905
- if (V) {
3904
+ }, [e, ln, N, nt, sn, qt, an]), lr = U(
3905
+ (y) => {
3906
+ const A = y.target === ct.current, I = qt(y.clientX, y.clientY);
3907
+ if (O) {
3906
3908
  const ge = !!I && I[0] >= 0 && I[1] >= 0 && !!e && I[0] <= e.width && I[1] <= e.height;
3907
- V({
3909
+ O({
3908
3910
  coordinate: I,
3909
- clientX: b.clientX,
3910
- clientY: b.clientY,
3911
+ clientX: y.clientX,
3912
+ clientY: y.clientY,
3911
3913
  insideImage: ge
3912
3914
  });
3913
3915
  }
3914
- if (D !== "cursor") return;
3916
+ if (N !== "cursor") return;
3915
3917
  if (!A) {
3916
- jt(null, null), y.current !== null && (y.current = null, Bt(null), st?.({
3918
+ te(null, null), h.current !== null && (h.current = null, Wt(null), st?.({
3917
3919
  region: null,
3918
3920
  regionId: null,
3919
3921
  regionIndex: -1,
@@ -3922,246 +3924,257 @@ function No({
3922
3924
  return;
3923
3925
  }
3924
3926
  if (!I) {
3925
- jt(null, null);
3927
+ te(null, null);
3926
3928
  return;
3927
3929
  }
3928
- if (L && jt(Kt(I), I), !ht.length) return;
3929
- const H = Oe(I, ht), k = H?.regionId ?? null, ft = y.current;
3930
- String(ft) !== String(k) && (y.current = k, Bt(k), st?.({
3930
+ if (L && te(jt(I), I), !rt.length) return;
3931
+ const H = Oe(I, rt), D = H?.regionId ?? null, ft = h.current;
3932
+ String(ft) !== String(D) && (h.current = D, Wt(D), st?.({
3931
3933
  region: H?.region ?? null,
3932
- regionId: k,
3934
+ regionId: D,
3933
3935
  regionIndex: H?.regionIndex ?? -1,
3934
3936
  coordinate: I
3935
3937
  }));
3936
3938
  },
3937
- [D, ht, Ot, st, V, e, jt, Kt, L]
3938
- ), lr = B(() => {
3939
- V?.({
3939
+ [N, rt, qt, st, O, e, te, jt, L]
3940
+ ), ur = U(() => {
3941
+ O?.({
3940
3942
  coordinate: null,
3941
3943
  clientX: -1,
3942
3944
  clientY: -1,
3943
3945
  insideImage: !1
3944
- }), jt(null, null), y.current !== null && (y.current = null, Bt(null), st?.({
3946
+ }), te(null, null), h.current !== null && (h.current = null, Wt(null), st?.({
3945
3947
  region: null,
3946
3948
  regionId: null,
3947
3949
  regionIndex: -1,
3948
3950
  coordinate: null
3949
3951
  }));
3950
- }, [st, V, jt]), ur = B(
3951
- (b) => {
3952
- if (D !== "cursor" || b.target !== ct.current) return;
3953
- const A = Ot(b.clientX, b.clientY);
3952
+ }, [st, O, te]), cr = U(
3953
+ (y) => {
3954
+ if (N !== "cursor" || y.target !== ct.current) return;
3955
+ const A = qt(y.clientX, y.clientY);
3954
3956
  if (!A) return;
3955
- if (de(A, b.button), !ht.length) {
3956
- Wt(null);
3957
+ if (de(A, y.button), !rt.length) {
3958
+ Gt(null);
3957
3959
  return;
3958
3960
  }
3959
- const I = Oe(A, ht);
3961
+ const I = Oe(A, rt);
3960
3962
  if (!I) {
3961
- Wt(null);
3963
+ Gt(null);
3962
3964
  return;
3963
3965
  }
3964
- const H = St !== null && String(St) === String(I.regionId) ? null : I.regionId;
3965
- Wt(H), Mt?.({
3966
+ const H = wt !== null && String(wt) === String(I.regionId) ? null : I.regionId;
3967
+ Gt(H), xt?.({
3966
3968
  region: I.region,
3967
3969
  regionId: I.regionId,
3968
3970
  regionIndex: I.regionIndex,
3969
3971
  coordinate: A
3970
3972
  });
3971
3973
  },
3972
- [D, ht, Ot, Mt, St, Wt, de]
3973
- ), cr = B(
3974
- (b) => {
3975
- if (D !== "brush" || Et?.clickSelectRoi !== !0 || !ht.length) return !1;
3976
- const A = Oe(b, ht);
3974
+ [N, rt, qt, xt, wt, Gt, de]
3975
+ ), hr = U(
3976
+ (y) => {
3977
+ if (N !== "brush" || vt?.clickSelectRoi !== !0 || !rt.length) return !1;
3978
+ const A = Oe(y, rt);
3977
3979
  if (!A) return !1;
3978
- const I = St !== null && String(St) === String(A.regionId) ? null : A.regionId;
3979
- return Wt(I), Mt?.({
3980
+ const I = wt !== null && String(wt) === String(A.regionId) ? null : A.regionId;
3981
+ return Gt(I), xt?.({
3980
3982
  region: A.region,
3981
3983
  regionId: A.regionId,
3982
3984
  regionIndex: A.regionIndex,
3983
- coordinate: b
3985
+ coordinate: y
3984
3986
  }), !0;
3985
3987
  },
3986
- [D, Et?.clickSelectRoi, ht, St, Wt, Mt]
3987
- ), hr = B(
3988
- (b) => {
3989
- if (!at || D !== "cursor" || b.target !== ct.current) return;
3990
- b.preventDefault();
3991
- const A = Ot(b.clientX, b.clientY);
3992
- A && de(A, b.button);
3988
+ [N, vt?.clickSelectRoi, rt, wt, Gt, xt]
3989
+ ), fr = U(
3990
+ (y) => {
3991
+ if (!at || N !== "cursor" || y.target !== ct.current) return;
3992
+ y.preventDefault();
3993
+ const A = qt(y.clientX, y.clientY);
3994
+ A && de(A, y.button);
3993
3995
  },
3994
- [D, Ot, de, at]
3996
+ [N, qt, de, at]
3995
3997
  );
3996
- return Y(() => {
3997
- const b = ct.current;
3998
- if (!b || !e)
3998
+ return X(() => {
3999
+ const y = ct.current;
4000
+ if (!y || !e)
3999
4001
  return;
4000
- const A = new co(b, e, {
4002
+ const A = new co(y, e, {
4001
4003
  onViewStateChange: on,
4002
4004
  onStats: rn,
4003
4005
  onTileError: i,
4004
4006
  onContextLost: o,
4005
4007
  onContextRestored: a,
4006
- authToken: g,
4008
+ authToken: p,
4007
4009
  ctrlDragRotate: d,
4008
4010
  pointSizeByZoom: S,
4009
- pointStrokeScale: x
4011
+ pointStrokeScale: T
4010
4012
  });
4011
- return j.current = A, t && A.setViewState(t), A.setInteractionLock(rt), gt && he(A.getViewState()), () => {
4012
- A.destroy(), j.current = null;
4013
+ return Q.current = A, t && A.setViewState(t), A.setInteractionLock(nt), q && ie(A.getViewState()), () => {
4014
+ A.destroy(), Q.current = null;
4013
4015
  };
4014
- }, [e, rn, i, o, a, g, d, S, x, on, gt]), Y(() => {
4015
- const b = j.current;
4016
- !b || !t || b.setViewState(t);
4017
- }, [t]), Y(() => {
4018
- const b = j.current;
4019
- b && b.fitToImage();
4020
- }, [c]), Y(() => {
4021
- const b = j.current;
4022
- b && b.resetRotation();
4023
- }, [h]), Y(() => {
4024
- const b = j.current;
4025
- !b || !p || b.setPointPalette(p);
4026
- }, [p]), Y(() => {
4027
- const b = j.current;
4028
- b && b.setPointSizeByZoom(S);
4029
- }, [S]), Y(() => {
4030
- const b = j.current;
4031
- b && b.setPointStrokeScale(x);
4032
- }, [x]), Y(() => {
4033
- const b = j.current;
4034
- b && b.setPointData(yt);
4035
- }, [yt]), Y(() => {
4036
- if (!N) return;
4037
- const A = eo(F ? yt : m, nt, {
4038
- paletteIndexToTermId: K,
4016
+ }, [e, rn, i, o, a, p, d, S, T, on, q]), X(() => {
4017
+ const y = Q.current;
4018
+ !y || !t || y.setViewState(t);
4019
+ }, [t]), X(() => {
4020
+ const y = Q.current;
4021
+ y && y.fitToImage();
4022
+ }, [c]), X(() => {
4023
+ const y = Q.current;
4024
+ y && y.resetRotation();
4025
+ }, [f]), X(() => {
4026
+ const y = Q.current;
4027
+ !y || !b || y.setPointPalette(b);
4028
+ }, [b]), X(() => {
4029
+ const y = Q.current;
4030
+ y && y.setPointSizeByZoom(S);
4031
+ }, [S]), X(() => {
4032
+ const y = Q.current;
4033
+ y && y.setPointStrokeScale(T);
4034
+ }, [T]), X(() => {
4035
+ const y = Q.current;
4036
+ y && y.setPointData(At);
4037
+ }, [At]), X(() => {
4038
+ if (!z) return;
4039
+ const A = eo(F ? At : m, pt, {
4040
+ paletteIndexToTermId: J,
4039
4041
  includeEmptyRegions: !0
4040
4042
  });
4041
- N(A);
4042
- }, [N, F, m, yt, nt, K]), Y(() => {
4043
- const b = j.current;
4044
- b && b.setInteractionLock(rt);
4045
- }, [rt]), /* @__PURE__ */ Sn("div", { className: dt, style: kt, onPointerMove: ar, onPointerLeave: lr, onClick: ur, onContextMenu: hr, children: [
4046
- /* @__PURE__ */ zt(
4047
- "canvas",
4048
- {
4049
- ref: ct,
4050
- className: "wsi-render-canvas",
4051
- style: {
4052
- position: "absolute",
4053
- inset: 0,
4054
- zIndex: 1,
4055
- width: "100%",
4056
- height: "100%",
4057
- display: "block",
4058
- touchAction: "none",
4059
- cursor: D === "cursor" && re !== null ? "pointer" : rt ? "crosshair" : "grab"
4060
- }
4061
- }
4062
- ),
4063
- e && un && Array.isArray(T) && T.length > 0 ? T.map((b, A) => /* @__PURE__ */ zt(
4064
- "div",
4065
- {
4066
- className: b.className,
4067
- style: {
4068
- position: "absolute",
4069
- inset: 0,
4070
- zIndex: b.zIndex ?? 3,
4071
- pointerEvents: b.pointerEvents ?? "none",
4072
- ...b.style
4073
- },
4074
- children: b.render(un)
4075
- },
4076
- b.id ?? A
4077
- )) : null,
4078
- e ? /* @__PURE__ */ zt(
4079
- ki,
4080
- {
4081
- tool: D,
4082
- enabled: D !== "cursor",
4083
- imageWidth: e.width,
4084
- imageHeight: e.height,
4085
- imageMpp: e.mpp,
4086
- imageZoom: e.maxTierZoom,
4087
- stampOptions: It,
4088
- brushOptions: Et,
4089
- projectorRef: j,
4090
- onBrushTap: cr,
4091
- viewStateSignal: t,
4092
- persistedRegions: nt,
4093
- patchRegions: Z,
4094
- regionStrokeStyle: J,
4095
- regionStrokeHoverStyle: Ct,
4096
- regionStrokeActiveStyle: Nt,
4097
- patchStrokeStyle: Qt,
4098
- resolveRegionStrokeStyle: bt,
4099
- overlayShapes: ot,
4100
- hoveredRegionId: re,
4101
- activeRegionId: St,
4102
- regionLabelStyle: v,
4103
- invalidateRef: _t,
4104
- onDrawComplete: G,
4105
- onPatchComplete: et
4106
- }
4107
- ) : null,
4108
- s ? /* @__PURE__ */ zt("pre", { "data-open-plant-debug-overlay": !0, style: Xt, children: sr }) : null,
4109
- e && Q ? Pt ? /* @__PURE__ */ Sn(pr, { children: [
4110
- /* @__PURE__ */ zt(Yi, { source: e, projectorRef: j, authToken: g, options: X, invalidateRef: Rt }),
4111
- /* @__PURE__ */ zt(
4112
- "button",
4113
- {
4114
- type: "button",
4115
- "aria-label": "Hide overview map",
4116
- onClick: () => Ut(!1),
4117
- style: {
4118
- position: "absolute",
4119
- zIndex: 6,
4120
- ...me.includes("left") ? { left: Yt } : { right: Yt },
4121
- ...me.includes("top") ? { top: Yt + nn + 8 } : { bottom: Yt + nn + 8 },
4122
- width: 20,
4123
- height: 20,
4124
- borderRadius: 999,
4125
- border: "1px solid rgba(255,255,255,0.4)",
4126
- background: "rgba(8, 14, 22, 0.9)",
4127
- color: "#fff",
4128
- fontSize: 13,
4129
- lineHeight: 1,
4130
- cursor: "pointer",
4131
- padding: 0
4043
+ z(A);
4044
+ }, [z, F, m, At, pt, J]), X(() => {
4045
+ const y = Q.current;
4046
+ y && y.setInteractionLock(nt);
4047
+ }, [nt]), /* @__PURE__ */ Sn(
4048
+ "div",
4049
+ {
4050
+ className: dt,
4051
+ style: gt,
4052
+ onPointerMove: lr,
4053
+ onPointerLeave: ur,
4054
+ onClick: cr,
4055
+ onContextMenu: fr,
4056
+ children: [
4057
+ /* @__PURE__ */ zt(
4058
+ "canvas",
4059
+ {
4060
+ ref: ct,
4061
+ className: "wsi-render-canvas",
4062
+ style: {
4063
+ position: "absolute",
4064
+ inset: 0,
4065
+ zIndex: 1,
4066
+ width: "100%",
4067
+ height: "100%",
4068
+ display: "block",
4069
+ touchAction: "none",
4070
+ cursor: N === "cursor" && re !== null ? "pointer" : nt ? "crosshair" : "grab"
4071
+ }
4072
+ }
4073
+ ),
4074
+ e && un && Array.isArray(E) && E.length > 0 ? E.map((y, A) => /* @__PURE__ */ zt(
4075
+ "div",
4076
+ {
4077
+ className: y.className,
4078
+ style: {
4079
+ position: "absolute",
4080
+ inset: 0,
4081
+ zIndex: y.zIndex ?? 3,
4082
+ pointerEvents: y.pointerEvents ?? "none",
4083
+ ...y.style
4084
+ },
4085
+ children: y.render(un)
4132
4086
  },
4133
- children: "×"
4134
- }
4135
- )
4136
- ] }) : /* @__PURE__ */ zt(
4137
- "button",
4138
- {
4139
- type: "button",
4140
- "aria-label": "Show overview map",
4141
- onClick: () => Ut(!0),
4142
- style: {
4143
- position: "absolute",
4144
- zIndex: 6,
4145
- ...me.includes("left") ? { left: Yt } : { right: Yt },
4146
- ...me.includes("top") ? { top: Yt } : { bottom: Yt },
4147
- height: 24,
4148
- minWidth: 40,
4149
- borderRadius: 999,
4150
- border: "1px solid rgba(255,255,255,0.45)",
4151
- background: "rgba(8, 14, 22, 0.9)",
4152
- color: "#dff8ff",
4153
- fontSize: 11,
4154
- fontWeight: 700,
4155
- cursor: "pointer",
4156
- padding: "0 8px"
4157
- },
4158
- children: "Map"
4159
- }
4160
- ) : null
4161
- ] });
4087
+ y.id ?? A
4088
+ )) : null,
4089
+ e ? /* @__PURE__ */ zt(
4090
+ ki,
4091
+ {
4092
+ tool: N,
4093
+ enabled: N !== "cursor",
4094
+ imageWidth: e.width,
4095
+ imageHeight: e.height,
4096
+ imageMpp: e.mpp,
4097
+ imageZoom: e.maxTierZoom,
4098
+ stampOptions: Ft,
4099
+ brushOptions: vt,
4100
+ projectorRef: Q,
4101
+ onBrushTap: hr,
4102
+ viewStateSignal: t,
4103
+ persistedRegions: pt,
4104
+ patchRegions: V,
4105
+ regionStrokeStyle: Z,
4106
+ regionStrokeHoverStyle: Ut,
4107
+ regionStrokeActiveStyle: Dt,
4108
+ patchStrokeStyle: Qt,
4109
+ resolveRegionStrokeStyle: Mt,
4110
+ overlayShapes: ot,
4111
+ hoveredRegionId: re,
4112
+ activeRegionId: wt,
4113
+ regionLabelStyle: v,
4114
+ invalidateRef: Bt,
4115
+ onDrawComplete: G,
4116
+ onPatchComplete: et
4117
+ }
4118
+ ) : null,
4119
+ s ? /* @__PURE__ */ zt("pre", { "data-open-plant-debug-overlay": !0, style: Ot, children: ar }) : null,
4120
+ e && j ? Ct ? /* @__PURE__ */ Sn(br, { children: [
4121
+ /* @__PURE__ */ zt(Yi, { source: e, projectorRef: Q, authToken: p, options: k, invalidateRef: It }),
4122
+ /* @__PURE__ */ zt(
4123
+ "button",
4124
+ {
4125
+ type: "button",
4126
+ "aria-label": "Hide overview map",
4127
+ onClick: () => St(!1),
4128
+ style: {
4129
+ position: "absolute",
4130
+ zIndex: 6,
4131
+ ...me.includes("left") ? { left: Vt } : { right: Vt },
4132
+ ...me.includes("top") ? { top: Vt + nn + 8 } : { bottom: Vt + nn + 8 },
4133
+ width: 20,
4134
+ height: 20,
4135
+ borderRadius: 999,
4136
+ border: "1px solid rgba(255,255,255,0.4)",
4137
+ background: "rgba(8, 14, 22, 0.9)",
4138
+ color: "#fff",
4139
+ fontSize: 13,
4140
+ lineHeight: 1,
4141
+ cursor: "pointer",
4142
+ padding: 0
4143
+ },
4144
+ children: "×"
4145
+ }
4146
+ )
4147
+ ] }) : /* @__PURE__ */ zt(
4148
+ "button",
4149
+ {
4150
+ type: "button",
4151
+ "aria-label": "Show overview map",
4152
+ onClick: () => St(!0),
4153
+ style: {
4154
+ position: "absolute",
4155
+ zIndex: 6,
4156
+ ...me.includes("left") ? { left: Vt } : { right: Vt },
4157
+ ...me.includes("top") ? { top: Vt } : { bottom: Vt },
4158
+ height: 24,
4159
+ minWidth: 40,
4160
+ borderRadius: 999,
4161
+ border: "1px solid rgba(255,255,255,0.45)",
4162
+ background: "rgba(8, 14, 22, 0.9)",
4163
+ color: "#dff8ff",
4164
+ fontSize: 11,
4165
+ fontWeight: 700,
4166
+ cursor: "pointer",
4167
+ padding: "0 8px"
4168
+ },
4169
+ children: "Map"
4170
+ }
4171
+ ) : null
4172
+ ]
4173
+ }
4174
+ );
4162
4175
  }
4163
4176
  export {
4164
- Hn as DEFAULT_POINT_COLOR,
4177
+ $n as DEFAULT_POINT_COLOR,
4165
4178
  ki as DrawLayer,
4166
4179
  Ar as M1TileRenderer,
4167
4180
  Yi as OverviewMap,
@@ -4171,24 +4184,24 @@ export {
4171
4184
  No as WsiViewerCanvas,
4172
4185
  _o as buildTermPalette,
4173
4186
  vo as calcScaleLength,
4174
- $n as calcScaleResolution,
4187
+ Zn as calcScaleResolution,
4175
4188
  it as clamp,
4176
- Ht as closeRing,
4189
+ Xt as closeRing,
4177
4190
  eo as computeRoiPointGroups,
4178
- _n as createCircle,
4179
- Cn as createRectangle,
4180
- _e as filterPointDataByPolygons,
4191
+ Fn as createCircle,
4192
+ _n as createRectangle,
4193
+ Fe as filterPointDataByPolygons,
4181
4194
  Ji as filterPointDataByPolygonsHybrid,
4182
- Qi as filterPointDataByPolygonsInWorker,
4195
+ ji as filterPointDataByPolygonsInWorker,
4183
4196
  Wi as filterPointIndicesByPolygons,
4184
- Lo as filterPointIndicesByPolygonsInWorker,
4197
+ zo as filterPointIndicesByPolygonsInWorker,
4185
4198
  Bo as getWebGpuCapabilities,
4186
- Jr as hexToRgba,
4199
+ jr as hexToRgba,
4187
4200
  Io as isSameViewState,
4188
4201
  Fo as normalizeImageInfo,
4189
4202
  Ki as prefilterPointsByBoundsWebGpu,
4190
- zo as terminateRoiClipWorker,
4203
+ Lo as terminateRoiClipWorker,
4191
4204
  Co as toBearerToken,
4192
- er as toTileUrl
4205
+ nr as toTileUrl
4193
4206
  };
4194
4207
  //# sourceMappingURL=index.js.map