open-plant 1.2.19 → 1.2.21

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