open-plant 1.4.19 → 1.4.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
@@ -2,7 +2,7 @@ var eo = Object.defineProperty;
2
2
  var no = (e, t, n) => t in e ? eo(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var S = (e, t, n) => no(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as Qt, jsxs as ci } from "react/jsx-runtime";
5
- import { useRef as q, useMemo as at, useCallback as V, useEffect as U, useContext as ro, createContext as io, useState as ae, forwardRef as oo, useImperativeHandle as so } from "react";
5
+ import { useRef as q, useMemo as at, useCallback as V, useEffect as z, useContext as ro, createContext as io, useState as ae, forwardRef as oo, useImperativeHandle as so } from "react";
6
6
  function Zn(e, t, n) {
7
7
  const r = e.createShader(t);
8
8
  if (!r)
@@ -23,24 +23,24 @@ function Se(e, t, n) {
23
23
  }
24
24
  return o;
25
25
  }
26
- function Dt(e, t, n) {
26
+ function Lt(e, t, n) {
27
27
  const r = e.getUniformLocation(t, n);
28
28
  if (!r)
29
29
  throw new Error(`Failed to get uniform location: ${n}`);
30
30
  return r;
31
31
  }
32
- function ao(e) {
33
- const t = e.getContext("webgl2", {
32
+ function ao(e, t) {
33
+ const n = e.getContext("webgl2", {
34
34
  alpha: !1,
35
35
  antialias: !1,
36
36
  depth: !1,
37
37
  stencil: !1,
38
- preserveDrawingBuffer: !1,
38
+ preserveDrawingBuffer: t?.preserveDrawingBuffer ?? !1,
39
39
  powerPreference: "high-performance"
40
40
  });
41
- if (!t)
41
+ if (!n)
42
42
  throw new Error("WebGL2 is not available.");
43
- return t;
43
+ return n;
44
44
  }
45
45
  function un(e) {
46
46
  return e * Math.PI / 180;
@@ -165,61 +165,18 @@ class uo {
165
165
  S(this, "destroyed", !1);
166
166
  S(this, "fitted", !1);
167
167
  S(this, "controlledViewState", !1);
168
- 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 = ao(this.canvas), this.program = Se(this.gl, lo, co);
168
+ 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 = ao(this.canvas, { preserveDrawingBuffer: t.preserveDrawingBuffer }), this.program = Se(this.gl, lo, co);
169
169
  const n = this.gl.createVertexArray(), r = this.gl.createBuffer();
170
170
  if (!n || !r)
171
171
  throw new Error("Failed to create WebGL buffers.");
172
172
  this.vao = n, this.quadBuffer = r, this.gl.bindVertexArray(this.vao), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.quadBuffer);
173
- const i = new Float32Array([
174
- 0,
175
- 0,
176
- 0,
177
- 0,
178
- 1,
179
- 0,
180
- 1,
181
- 0,
182
- 0,
183
- 1,
184
- 0,
185
- 1,
186
- 1,
187
- 1,
188
- 1,
189
- 1
190
- ]);
173
+ const i = new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1]);
191
174
  this.gl.bufferData(this.gl.ARRAY_BUFFER, i, this.gl.STATIC_DRAW);
192
175
  const o = this.gl.getAttribLocation(this.program, "aUnit"), s = this.gl.getAttribLocation(this.program, "aUv");
193
176
  if (o < 0 || s < 0)
194
177
  throw new Error("Failed to get attribute locations.");
195
178
  const a = 4 * Float32Array.BYTES_PER_ELEMENT;
196
- this.gl.enableVertexAttribArray(o), this.gl.vertexAttribPointer(
197
- o,
198
- 2,
199
- this.gl.FLOAT,
200
- !1,
201
- a,
202
- 0
203
- ), this.gl.enableVertexAttribArray(s), this.gl.vertexAttribPointer(
204
- s,
205
- 2,
206
- this.gl.FLOAT,
207
- !1,
208
- a,
209
- 2 * Float32Array.BYTES_PER_ELEMENT
210
- ), this.gl.bindVertexArray(null), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.uCameraLocation = Dt(
211
- this.gl,
212
- this.program,
213
- "uCamera"
214
- ), this.uBoundsLocation = Dt(
215
- this.gl,
216
- this.program,
217
- "uBounds"
218
- ), this.uTextureLocation = Dt(
219
- this.gl,
220
- this.program,
221
- "uTexture"
222
- ), t.initialViewState && (this.controlledViewState = !0, this.camera.setViewState(t.initialViewState)), this.resizeObserver = new ResizeObserver(() => {
179
+ this.gl.enableVertexAttribArray(o), this.gl.vertexAttribPointer(o, 2, this.gl.FLOAT, !1, a, 0), this.gl.enableVertexAttribArray(s), this.gl.vertexAttribPointer(s, 2, this.gl.FLOAT, !1, a, 2 * Float32Array.BYTES_PER_ELEMENT), this.gl.bindVertexArray(null), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.uCameraLocation = Lt(this.gl, this.program, "uCamera"), this.uBoundsLocation = Lt(this.gl, this.program, "uBounds"), this.uTextureLocation = Lt(this.gl, this.program, "uTexture"), t.initialViewState && (this.controlledViewState = !0, this.camera.setViewState(t.initialViewState)), this.resizeObserver = new ResizeObserver(() => {
223
180
  this.resize();
224
181
  }), this.resizeObserver.observe(this.canvas), this.resize();
225
182
  }
@@ -249,39 +206,14 @@ class uo {
249
206
  try {
250
207
  const r = await fetch(t.url);
251
208
  if (!r.ok)
252
- throw new Error(
253
- `Tile fetch failed: ${r.status} ${r.statusText}`
254
- );
209
+ throw new Error(`Tile fetch failed: ${r.status} ${r.statusText}`);
255
210
  const i = await r.blob(), o = await createImageBitmap(i);
256
211
  if (this.destroyed || n !== this.loadVersion)
257
212
  return o.close(), null;
258
213
  const s = this.gl.createTexture();
259
214
  if (!s)
260
215
  throw o.close(), new Error("Failed to create tile texture.");
261
- return this.gl.bindTexture(this.gl.TEXTURE_2D, s), this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, 1), this.gl.texParameteri(
262
- this.gl.TEXTURE_2D,
263
- this.gl.TEXTURE_WRAP_S,
264
- this.gl.CLAMP_TO_EDGE
265
- ), this.gl.texParameteri(
266
- this.gl.TEXTURE_2D,
267
- this.gl.TEXTURE_WRAP_T,
268
- this.gl.CLAMP_TO_EDGE
269
- ), this.gl.texParameteri(
270
- this.gl.TEXTURE_2D,
271
- this.gl.TEXTURE_MIN_FILTER,
272
- this.gl.LINEAR
273
- ), this.gl.texParameteri(
274
- this.gl.TEXTURE_2D,
275
- this.gl.TEXTURE_MAG_FILTER,
276
- this.gl.LINEAR
277
- ), this.gl.texImage2D(
278
- this.gl.TEXTURE_2D,
279
- 0,
280
- this.gl.RGBA,
281
- this.gl.RGBA,
282
- this.gl.UNSIGNED_BYTE,
283
- o
284
- ), this.gl.bindTexture(this.gl.TEXTURE_2D, null), o.close(), {
216
+ return this.gl.bindTexture(this.gl.TEXTURE_2D, s), this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, 1), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR), this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, o), this.gl.bindTexture(this.gl.TEXTURE_2D, null), o.close(), {
285
217
  id: t.id,
286
218
  bounds: t.bounds,
287
219
  texture: s
@@ -297,10 +229,7 @@ class uo {
297
229
  (this.canvas.width !== o || this.canvas.height !== s) && (this.canvas.width = o, this.canvas.height = s), this.camera.setViewport(n, r), this.gl.viewport(0, 0, this.canvas.width, this.canvas.height), !this.fitted && !this.controlledViewState && (this.fitToImage(), this.fitted = !0), this.requestRender();
298
230
  }
299
231
  fitToImage() {
300
- const t = this.camera.getViewportSize(), n = Math.min(
301
- t.width / this.imageWidth,
302
- t.height / this.imageHeight
303
- ), r = Number.isFinite(n) && n > 0 ? n : 1, i = t.width / r, o = t.height / r, s = (this.imageWidth - i) * 0.5, a = (this.imageHeight - o) * 0.5;
232
+ const t = this.camera.getViewportSize(), n = Math.min(t.width / this.imageWidth, t.height / this.imageHeight), r = Number.isFinite(n) && n > 0 ? n : 1, i = t.width / r, o = t.height / r, s = (this.imageWidth - i) * 0.5, a = (this.imageHeight - o) * 0.5;
304
233
  this.camera.setViewState({
305
234
  zoom: r,
306
235
  offsetX: s,
@@ -314,24 +243,9 @@ class uo {
314
243
  }
315
244
  render() {
316
245
  if (!this.destroyed) {
317
- this.gl.clearColor(
318
- this.clearColor[0],
319
- this.clearColor[1],
320
- this.clearColor[2],
321
- this.clearColor[3]
322
- ), this.gl.clear(this.gl.COLOR_BUFFER_BIT), this.gl.useProgram(this.program), this.gl.bindVertexArray(this.vao), this.gl.uniformMatrix3fv(
323
- this.uCameraLocation,
324
- !1,
325
- this.camera.getMatrix()
326
- ), this.gl.uniform1i(this.uTextureLocation, 0);
246
+ this.gl.clearColor(this.clearColor[0], this.clearColor[1], this.clearColor[2], this.clearColor[3]), this.gl.clear(this.gl.COLOR_BUFFER_BIT), this.gl.useProgram(this.program), this.gl.bindVertexArray(this.vao), this.gl.uniformMatrix3fv(this.uCameraLocation, !1, this.camera.getMatrix()), this.gl.uniform1i(this.uTextureLocation, 0);
327
247
  for (const t of this.tiles)
328
- this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, t.texture), this.gl.uniform4f(
329
- this.uBoundsLocation,
330
- t.bounds[0],
331
- t.bounds[1],
332
- t.bounds[2],
333
- t.bounds[3]
334
- ), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4);
248
+ this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, t.texture), this.gl.uniform4f(this.uBoundsLocation, t.bounds[0], t.bounds[1], t.bounds[2], t.bounds[3]), this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4);
335
249
  this.gl.bindTexture(this.gl.TEXTURE_2D, null), this.gl.bindVertexArray(null);
336
250
  }
337
251
  }
@@ -704,18 +618,18 @@ function ve(e) {
704
618
  }
705
619
  const bo = (3 + 16 * te) * te, wo = (2 + 12 * te) * te, So = (9 + 64 * te) * te * te, fe = ve(4), Hn = ve(8), $n = ve(12), Kn = ve(16), Yt = ve(4);
706
620
  function Ao(e, t, n, r, i, o, s) {
707
- let a, l, c, f, u, h, d, m, g, y, p, x, E, w, P, R, B, k;
708
- const Y = e - i, M = n - i, C = t - o, F = r - o;
709
- w = Y * F, h = Ot * Y, d = h - (h - Y), m = Y - d, h = Ot * F, g = h - (h - F), y = F - g, P = m * y - (w - d * g - m * g - d * y), R = C * M, h = Ot * C, d = h - (h - C), m = C - d, h = Ot * M, g = h - (h - M), y = M - g, B = m * y - (R - d * g - m * g - d * y), p = P - B, u = P - p, fe[0] = P - (p + u) + (u - B), x = w + p, u = x - w, E = w - (x - u) + (p - u), p = E - R, u = E - p, fe[1] = E - (p + u) + (u - R), k = x + p, u = k - x, fe[2] = x - (k - u) + (p - u), fe[3] = k;
710
- let I = xo(4, fe), W = wo * s;
711
- if (I >= W || -I >= W || (u = e - Y, a = e - (Y + u) + (u - i), u = n - M, c = n - (M + u) + (u - i), u = t - C, l = t - (C + u) + (u - o), u = r - F, f = r - (F + u) + (u - o), a === 0 && l === 0 && c === 0 && f === 0) || (W = So * s + yo * Math.abs(I), I += Y * f + F * a - (C * c + M * l), I >= W || -I >= W)) return I;
712
- w = a * F, h = Ot * a, d = h - (h - a), m = a - d, h = Ot * F, g = h - (h - F), y = F - g, P = m * y - (w - d * g - m * g - d * y), R = l * M, h = Ot * l, d = h - (h - l), m = l - d, h = Ot * M, g = h - (h - M), y = M - g, B = m * y - (R - d * g - m * g - d * y), p = P - B, u = P - p, Yt[0] = P - (p + u) + (u - B), x = w + p, u = x - w, E = w - (x - u) + (p - u), p = E - R, u = E - p, Yt[1] = E - (p + u) + (u - R), k = x + p, u = k - x, Yt[2] = x - (k - u) + (p - u), Yt[3] = k;
713
- const j = hn(4, fe, 4, Yt, Hn);
714
- w = Y * f, h = Ot * Y, d = h - (h - Y), m = Y - d, h = Ot * f, g = h - (h - f), y = f - g, P = m * y - (w - d * g - m * g - d * y), R = C * c, h = Ot * C, d = h - (h - C), m = C - d, h = Ot * c, g = h - (h - c), y = c - g, B = m * y - (R - d * g - m * g - d * y), p = P - B, u = P - p, Yt[0] = P - (p + u) + (u - B), x = w + p, u = x - w, E = w - (x - u) + (p - u), p = E - R, u = E - p, Yt[1] = E - (p + u) + (u - R), k = x + p, u = k - x, Yt[2] = x - (k - u) + (p - u), Yt[3] = k;
715
- const N = hn(j, Hn, 4, Yt, $n);
716
- w = a * f, h = Ot * a, d = h - (h - a), m = a - d, h = Ot * f, g = h - (h - f), y = f - g, P = m * y - (w - d * g - m * g - d * y), R = l * c, h = Ot * l, d = h - (h - l), m = l - d, h = Ot * c, g = h - (h - c), y = c - g, B = m * y - (R - d * g - m * g - d * y), p = P - B, u = P - p, Yt[0] = P - (p + u) + (u - B), x = w + p, u = x - w, E = w - (x - u) + (p - u), p = E - R, u = E - p, Yt[1] = E - (p + u) + (u - R), k = x + p, u = k - x, Yt[2] = x - (k - u) + (p - u), Yt[3] = k;
717
- const ut = hn(N, $n, 4, Yt, Kn);
718
- return Kn[ut - 1];
621
+ let a, l, c, f, u, h, d, m, g, y, p, x, E, w, P, R, B, N;
622
+ const Y = e - i, M = n - i, T = t - o, O = r - o;
623
+ w = Y * O, h = Ot * Y, d = h - (h - Y), m = Y - d, h = Ot * O, g = h - (h - O), y = O - g, P = m * y - (w - d * g - m * g - d * y), R = T * M, h = Ot * T, d = h - (h - T), m = T - d, h = Ot * M, g = h - (h - M), y = M - g, B = m * y - (R - d * g - m * g - d * y), p = P - B, u = P - p, fe[0] = P - (p + u) + (u - B), x = w + p, u = x - w, E = w - (x - u) + (p - u), p = E - R, u = E - p, fe[1] = E - (p + u) + (u - R), N = x + p, u = N - x, fe[2] = x - (N - u) + (p - u), fe[3] = N;
624
+ let v = xo(4, fe), W = wo * s;
625
+ if (v >= W || -v >= W || (u = e - Y, a = e - (Y + u) + (u - i), u = n - M, c = n - (M + u) + (u - i), u = t - T, l = t - (T + u) + (u - o), u = r - O, f = r - (O + u) + (u - o), a === 0 && l === 0 && c === 0 && f === 0) || (W = So * s + yo * Math.abs(v), v += Y * f + O * a - (T * c + M * l), v >= W || -v >= W)) return v;
626
+ w = a * O, h = Ot * a, d = h - (h - a), m = a - d, h = Ot * O, g = h - (h - O), y = O - g, P = m * y - (w - d * g - m * g - d * y), R = l * M, h = Ot * l, d = h - (h - l), m = l - d, h = Ot * M, g = h - (h - M), y = M - g, B = m * y - (R - d * g - m * g - d * y), p = P - B, u = P - p, Yt[0] = P - (p + u) + (u - B), x = w + p, u = x - w, E = w - (x - u) + (p - u), p = E - R, u = E - p, Yt[1] = E - (p + u) + (u - R), N = x + p, u = N - x, Yt[2] = x - (N - u) + (p - u), Yt[3] = N;
627
+ const J = hn(4, fe, 4, Yt, Hn);
628
+ w = Y * f, h = Ot * Y, d = h - (h - Y), m = Y - d, h = Ot * f, g = h - (h - f), y = f - g, P = m * y - (w - d * g - m * g - d * y), R = T * c, h = Ot * T, d = h - (h - T), m = T - d, h = Ot * c, g = h - (h - c), y = c - g, B = m * y - (R - d * g - m * g - d * y), p = P - B, u = P - p, Yt[0] = P - (p + u) + (u - B), x = w + p, u = x - w, E = w - (x - u) + (p - u), p = E - R, u = E - p, Yt[1] = E - (p + u) + (u - R), N = x + p, u = N - x, Yt[2] = x - (N - u) + (p - u), Yt[3] = N;
629
+ const F = hn(J, Hn, 4, Yt, $n);
630
+ w = a * f, h = Ot * a, d = h - (h - a), m = a - d, h = Ot * f, g = h - (h - f), y = f - g, P = m * y - (w - d * g - m * g - d * y), R = l * c, h = Ot * l, d = h - (h - l), m = l - d, h = Ot * c, g = h - (h - c), y = c - g, B = m * y - (R - d * g - m * g - d * y), p = P - B, u = P - p, Yt[0] = P - (p + u) + (u - B), x = w + p, u = x - w, E = w - (x - u) + (p - u), p = E - R, u = E - p, Yt[1] = E - (p + u) + (u - R), N = x + p, u = N - x, Yt[2] = x - (N - u) + (p - u), Yt[3] = N;
631
+ const xt = hn(F, $n, 4, Yt, Kn);
632
+ return Kn[xt - 1];
719
633
  }
720
634
  function Eo(e, t, n, r, i, o) {
721
635
  const s = (t - o) * (n - i), a = (e - i) * (r - o), l = s - a, c = Math.abs(s + a);
@@ -1710,7 +1624,7 @@ function eu(e, t, n) {
1710
1624
  }
1711
1625
  return `${Math.round(i * 1e3) / 1e3} pixels`;
1712
1626
  }
1713
- function Et() {
1627
+ function Pt() {
1714
1628
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
1715
1629
  }
1716
1630
  function ce(e) {
@@ -2555,19 +2469,19 @@ function ia({
2555
2469
  resolveRegionStrokeStyle: P,
2556
2470
  resolveRegionLabelStyle: R,
2557
2471
  overlayShapes: B,
2558
- hoveredRegionId: k = null,
2472
+ hoveredRegionId: N = null,
2559
2473
  activeRegionId: Y = null,
2560
2474
  regionLabelStyle: M,
2561
- drawAreaTooltip: C,
2562
- autoLiftRegionLabelAtMaxZoom: F = !1,
2563
- regionLabelAnchor: I = "top-center",
2475
+ drawAreaTooltip: T,
2476
+ autoLiftRegionLabelAtMaxZoom: O = !1,
2477
+ regionLabelAnchor: v = "top-center",
2564
2478
  clampRegionLabelToViewport: W = !0,
2565
- regionLabelAutoLiftOffsetPx: j,
2566
- invalidateRef: N,
2567
- className: ut,
2568
- style: pt
2479
+ regionLabelAutoLiftOffsetPx: J,
2480
+ invalidateRef: F,
2481
+ className: xt,
2482
+ style: ft
2569
2483
  }) {
2570
- const et = q(null), _t = q(!1), Ct = q(/* @__PURE__ */ new Map()), L = q(e), v = q({
2484
+ const tt = q(null), _t = q(!1), Ct = q(/* @__PURE__ */ new Map()), L = q(e), C = q({
2571
2485
  isDrawing: !1,
2572
2486
  pointerId: null,
2573
2487
  start: null,
@@ -2577,34 +2491,34 @@ function ia({
2577
2491
  points: [],
2578
2492
  screenPoints: [],
2579
2493
  stampCenter: null
2580
- }), O = u ?? e !== "cursor", lt = at(() => d && d.length > 0 ? d : !g || g.length === 0 ? mr : g.map((b, A) => ({
2494
+ }), U = u ?? e !== "cursor", lt = at(() => d && d.length > 0 ? d : !g || g.length === 0 ? mr : g.map((b, A) => ({
2581
2495
  id: A,
2582
2496
  coordinates: b
2583
- })), [d, g]), $ = at(() => m ?? mr, [m]), bt = at(() => {
2497
+ })), [d, g]), dt = at(() => m ?? mr, [m]), j = at(() => {
2584
2498
  const b = [];
2585
2499
  for (let A = 0; A < lt.length; A += 1) {
2586
- const T = lt[A], D = tn(T.coordinates);
2500
+ const I = lt[A], D = tn(I.coordinates);
2587
2501
  D.length !== 0 && b.push({
2588
- region: T,
2502
+ region: I,
2589
2503
  regionIndex: A,
2590
- regionKey: T.id ?? A,
2504
+ regionKey: I.id ?? A,
2591
2505
  polygons: D
2592
2506
  });
2593
2507
  }
2594
2508
  return b;
2595
- }, [lt]), ft = at(() => {
2509
+ }, [lt]), ht = at(() => {
2596
2510
  const b = [];
2597
- for (let A = 0; A < $.length; A += 1) {
2598
- const T = $[A], D = tn(T.coordinates);
2511
+ for (let A = 0; A < dt.length; A += 1) {
2512
+ const I = dt[A], D = tn(I.coordinates);
2599
2513
  D.length !== 0 && b.push({
2600
- region: T,
2514
+ region: I,
2601
2515
  regionIndex: A,
2602
- regionKey: T.id ?? A,
2516
+ regionKey: I.id ?? A,
2603
2517
  polygons: D
2604
2518
  });
2605
2519
  }
2606
2520
  return b;
2607
- }, [$]), it = at(() => zn(p), [p]), Nt = at(() => Jt(it, x), [it, x]), dt = at(() => Jt(it, E), [it, E]), wt = at(() => Jt(xi, w), [w]), yt = at(() => ra(y), [y]), ot = at(() => kn(M), [M]), ct = at(() => $s(C), [C]), ht = at(() => Qs(o), [o]), H = at(() => Us(s), [s]), It = at(
2521
+ }, [dt]), rt = at(() => zn(p), [p]), Dt = at(() => Jt(rt, x), [rt, x]), Rt = at(() => Jt(rt, E), [rt, E]), mt = at(() => Jt(xi, w), [w]), At = at(() => ra(y), [y]), nt = at(() => kn(M), [M]), ct = at(() => $s(T), [T]), gt = at(() => Qs(o), [o]), ut = at(() => Us(s), [s]), it = at(
2608
2522
  () => ({
2609
2523
  position: "absolute",
2610
2524
  inset: 0,
@@ -2613,107 +2527,107 @@ function ia({
2613
2527
  height: "100%",
2614
2528
  display: "block",
2615
2529
  touchAction: "none",
2616
- pointerEvents: O ? "auto" : "none",
2617
- cursor: O ? e === "brush" ? "none" : "crosshair" : "default",
2618
- ...pt
2530
+ pointerEvents: U ? "auto" : "none",
2531
+ cursor: U ? e === "brush" ? "none" : "crosshair" : "default",
2532
+ ...ft
2619
2533
  }),
2620
- [O, e, pt]
2621
- ), Pt = V(() => {
2622
- const b = et.current;
2534
+ [U, e, ft]
2535
+ ), vt = V(() => {
2536
+ const b = tt.current;
2623
2537
  if (!b) return;
2624
- const A = b.getBoundingClientRect(), T = Math.max(1, window.devicePixelRatio || 1), D = Math.max(1, Math.round(A.width * T)), Z = Math.max(1, Math.round(A.height * T));
2538
+ const A = b.getBoundingClientRect(), I = Math.max(1, window.devicePixelRatio || 1), D = Math.max(1, Math.round(A.width * I)), Z = Math.max(1, Math.round(A.height * I));
2625
2539
  (b.width !== D || b.height !== Z) && (b.width = D, b.height = Z);
2626
- }, [O, e]), St = V(
2540
+ }, [U, e]), Et = V(
2627
2541
  (b) => {
2628
2542
  const A = a.current;
2629
2543
  if (!A || b.length === 0) return [];
2630
- const T = new Array(b.length);
2544
+ const I = new Array(b.length);
2631
2545
  for (let D = 0; D < b.length; D += 1) {
2632
2546
  const Z = $t(A.worldToScreen(b[D][0], b[D][1]));
2633
2547
  if (!Z) return [];
2634
- T[D] = Z;
2548
+ I[D] = Z;
2635
2549
  }
2636
- return T;
2550
+ return I;
2637
2551
  },
2638
2552
  [a]
2639
2553
  ), G = V(
2640
2554
  (b) => {
2641
- const A = a.current, T = et.current;
2642
- if (!A || !T) return null;
2643
- const D = T.getBoundingClientRect(), Z = $t(A.screenToWorld(D.left + b[0], D.top + b[1]));
2555
+ const A = a.current, I = tt.current;
2556
+ if (!A || !I) return null;
2557
+ const D = I.getBoundingClientRect(), Z = $t(A.screenToWorld(D.left + b[0], D.top + b[1]));
2644
2558
  return Z ? Qe(Z, t, n) : null;
2645
2559
  },
2646
2560
  [a, t, n]
2647
- ), Q = V(() => {
2561
+ ), K = V(() => {
2648
2562
  const b = a.current, A = b?.getViewState?.().rotationDeg ?? 0;
2649
2563
  if (!(Math.abs(A % 360) < 0.01 || !b))
2650
2564
  return {
2651
- worldToScreen: (T, D) => $t(b.worldToScreen(T, D)),
2565
+ worldToScreen: (I, D) => $t(b.worldToScreen(I, D)),
2652
2566
  screenToWorld: G
2653
2567
  };
2654
- }, [a, G]), mt = V(
2568
+ }, [a, G]), St = V(
2655
2569
  (b) => {
2656
2570
  if (!Number.isFinite(b) || b <= 0) return 0;
2657
- const A = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, T = typeof i == "number" && Number.isFinite(i) ? i : 0, D = a.current?.getViewState?.().zoom, Z = typeof D == "number" && Number.isFinite(D) && D > 0 ? D : 1, xt = T + Math.log2(Z), st = Math.max(1e-9, yi(A, T, xt));
2571
+ const A = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 1, I = typeof i == "number" && Number.isFinite(i) ? i : 0, D = a.current?.getViewState?.().zoom, Z = typeof D == "number" && Number.isFinite(D) && D > 0 ? D : 1, wt = I + Math.log2(Z), st = Math.max(1e-9, yi(A, I, wt));
2658
2572
  return b / st / Z;
2659
2573
  },
2660
2574
  [r, i, a]
2661
- ), rt = V(
2575
+ ), et = V(
2662
2576
  (b, A) => ea({
2663
2577
  stampTool: b,
2664
2578
  center: A,
2665
- resolvedStampOptions: ht,
2579
+ resolvedStampOptions: gt,
2666
2580
  imageWidth: t,
2667
2581
  imageHeight: n,
2668
- micronsToWorldPixels: mt,
2669
- getRectangleProjection: Q
2582
+ micronsToWorldPixels: St,
2583
+ getRectangleProjection: K
2670
2584
  }),
2671
- [mt, t, n, ht, Q]
2672
- ), J = V(() => {
2673
- const b = v.current;
2674
- return Ne(e) ? rt(e, b.stampCenter) : e === "brush" ? [] : b.isDrawing ? e === "freehand" ? b.points : e === "rectangle" ? Rn(b.start, b.current, Q()) : e === "circular" ? Er(b.start, b.current) : [] : [];
2675
- }, [e, rt, Q]), Mt = V(() => {
2676
- Pt();
2677
- const b = et.current;
2585
+ [St, t, n, gt, K]
2586
+ ), Q = V(() => {
2587
+ const b = C.current;
2588
+ return Ne(e) ? et(e, b.stampCenter) : e === "brush" ? [] : b.isDrawing ? e === "freehand" ? b.points : e === "rectangle" ? Rn(b.start, b.current, K()) : e === "circular" ? Er(b.start, b.current) : [] : [];
2589
+ }, [e, et, K]), Mt = V(() => {
2590
+ vt();
2591
+ const b = tt.current;
2678
2592
  if (!b) return;
2679
2593
  const A = b.getContext("2d");
2680
2594
  if (!A) return;
2681
- const T = Math.max(1, window.devicePixelRatio || 1), D = b.width / T, Z = b.height / T;
2682
- if (A.setTransform(1, 0, 0, 1, 0, 0), A.clearRect(0, 0, b.width, b.height), A.setTransform(T, 0, 0, T, 0, 0), bt.length > 0)
2683
- for (const st of bt) {
2684
- const { region: gt, polygons: Tt, regionIndex: Lt, regionKey: kt } = st, ue = Je(Y, kt) ? "active" : Je(k, kt) ? "hover" : "default";
2685
- let ee = ue === "active" ? dt : ue === "hover" ? Nt : it;
2595
+ const I = Math.max(1, window.devicePixelRatio || 1), D = b.width / I, Z = b.height / I;
2596
+ if (A.setTransform(1, 0, 0, 1, 0, 0), A.clearRect(0, 0, b.width, b.height), A.setTransform(I, 0, 0, I, 0, 0), j.length > 0)
2597
+ for (const st of j) {
2598
+ const { region: yt, polygons: It, regionIndex: Ft, regionKey: kt } = st, ue = Je(Y, kt) ? "active" : Je(N, kt) ? "hover" : "default";
2599
+ let ee = ue === "active" ? Rt : ue === "hover" ? Dt : rt;
2686
2600
  if (P) {
2687
2601
  const _e = P({
2688
- region: gt,
2602
+ region: yt,
2689
2603
  regionId: kt,
2690
- regionIndex: Lt,
2604
+ regionIndex: Ft,
2691
2605
  state: ue
2692
2606
  });
2693
2607
  ee = Jt(ee, _e || void 0);
2694
2608
  }
2695
2609
  const Ie = ue === "default" ? null : na(ee);
2696
- for (const _e of Tt) {
2697
- const ln = St(_e.outer);
2610
+ for (const _e of It) {
2611
+ const ln = Et(_e.outer);
2698
2612
  ln.length >= 4 && (Ie && Wt(A, ln, Ie, !0, !1), Wt(A, ln, ee, !0, !1));
2699
2613
  for (const to of _e.holes) {
2700
- const cn = St(to);
2614
+ const cn = Et(to);
2701
2615
  cn.length >= 4 && (Ie && Wt(A, cn, Ie, !0, !1), Wt(A, cn, ee, !0, !1));
2702
2616
  }
2703
2617
  }
2704
2618
  }
2705
- if (ft.length > 0)
2706
- for (const st of ft)
2707
- for (const gt of st.polygons) {
2708
- const Tt = St(gt.outer);
2709
- Tt.length >= 4 && Wt(A, Tt, wt, !0, !1);
2710
- for (const Lt of gt.holes) {
2711
- const kt = St(Lt);
2712
- kt.length >= 4 && Wt(A, kt, wt, !0, !1);
2619
+ if (ht.length > 0)
2620
+ for (const st of ht)
2621
+ for (const yt of st.polygons) {
2622
+ const It = Et(yt.outer);
2623
+ It.length >= 4 && Wt(A, It, mt, !0, !1);
2624
+ for (const Ft of yt.holes) {
2625
+ const kt = Et(Ft);
2626
+ kt.length >= 4 && Wt(A, kt, mt, !0, !1);
2713
2627
  }
2714
2628
  }
2715
2629
  if (Array.isArray(B) && B.length > 0) {
2716
- const st = St(
2630
+ const st = Et(
2717
2631
  Vt([
2718
2632
  [0, 0],
2719
2633
  [t, 0],
@@ -2725,59 +2639,59 @@ function ia({
2725
2639
  ctx: A,
2726
2640
  overlayShapes: B,
2727
2641
  imageOuterRing: st,
2728
- worldToScreenPoints: St,
2729
- baseStrokeStyle: it,
2730
- onInvertedFillDebug: globalThis.__OPEN_PLANT_DEBUG_OVERLAY__ ? (gt) => {
2731
- const Tt = String(gt.id), Lt = `${gt.outerRingPoints}|${gt.sourceRingCount}|${gt.holeRingCount}|${gt.fillColor}`;
2732
- Ct.current.get(Tt) !== Lt && (Ct.current.set(Tt, Lt), console.debug("[open-plant] invertedFill", gt));
2642
+ worldToScreenPoints: Et,
2643
+ baseStrokeStyle: rt,
2644
+ onInvertedFillDebug: globalThis.__OPEN_PLANT_DEBUG_OVERLAY__ ? (yt) => {
2645
+ const It = String(yt.id), Ft = `${yt.outerRingPoints}|${yt.sourceRingCount}|${yt.holeRingCount}|${yt.fillColor}`;
2646
+ Ct.current.get(It) !== Ft && (Ct.current.set(It, Ft), console.debug("[open-plant] invertedFill", yt));
2733
2647
  } : void 0
2734
2648
  });
2735
2649
  }
2736
- const xt = J();
2737
- if (O) {
2650
+ const wt = Q();
2651
+ if (U) {
2738
2652
  if (e === "brush")
2739
- ks(A, v.current, H), Os(A, v.current, a.current, H);
2740
- else if (xt.length > 0)
2653
+ ks(A, C.current, ut), Os(A, C.current, a.current, ut);
2654
+ else if (wt.length > 0)
2741
2655
  if (e === "freehand") {
2742
- const st = St(xt);
2743
- st.length >= 2 && Wt(A, st, it, !1, !1), st.length >= 3 && Wt(A, St(Vt(xt)), it, !0, !0, yt);
2656
+ const st = Et(wt);
2657
+ st.length >= 2 && Wt(A, st, rt, !1, !1), st.length >= 3 && Wt(A, Et(Vt(wt)), rt, !0, !0, At);
2744
2658
  } else {
2745
- const st = St(xt);
2746
- st.length >= 4 && Wt(A, st, it, !0, !0, yt);
2659
+ const st = Et(wt);
2660
+ st.length >= 4 && Wt(A, st, rt, !0, !0, At);
2747
2661
  }
2748
2662
  }
2749
- if (bt.length > 0) {
2750
- const st = Math.max(1e-6, a.current?.getViewState?.().zoom ?? 1), gt = typeof j == "number" && Number.isFinite(j) ? Math.max(0, j) : Wn(
2751
- F,
2663
+ if (j.length > 0) {
2664
+ const st = Math.max(1e-6, a.current?.getViewState?.().zoom ?? 1), yt = typeof J == "number" && Number.isFinite(J) ? Math.max(0, J) : Wn(
2665
+ O,
2752
2666
  st,
2753
2667
  a.current?.getZoomRange?.(),
2754
2668
  a.current?.getRegionLabelAutoLiftCapZoom?.()
2755
2669
  );
2756
- for (const Tt of bt) {
2757
- if (!Tt.region.label) continue;
2758
- const Lt = Un(Tt.polygons, St, I);
2759
- if (!Lt) continue;
2670
+ for (const It of j) {
2671
+ if (!It.region.label) continue;
2672
+ const Ft = Un(It.polygons, Et, v);
2673
+ if (!Ft) continue;
2760
2674
  let kt = On(
2761
- ot,
2675
+ nt,
2762
2676
  R?.({
2763
- region: Tt.region,
2764
- regionId: Tt.regionKey,
2765
- regionIndex: Tt.regionIndex,
2677
+ region: It.region,
2678
+ regionId: It.regionKey,
2679
+ regionIndex: It.regionIndex,
2766
2680
  zoom: st
2767
2681
  })
2768
2682
  );
2769
- gt > 0 && (kt = {
2683
+ yt > 0 && (kt = {
2770
2684
  ...kt,
2771
- offsetY: kt.offsetY + gt
2772
- }), Mi(A, Tt.region.label, Lt, D, Z, kt, W);
2685
+ offsetY: kt.offsetY + yt
2686
+ }), Mi(A, It.region.label, Ft, D, Z, kt, W);
2773
2687
  }
2774
2688
  }
2775
- if (ct.enabled && O && (e === "freehand" || e === "rectangle" || e === "circular")) {
2776
- const st = v.current;
2689
+ if (ct.enabled && U && (e === "freehand" || e === "rectangle" || e === "circular")) {
2690
+ const st = C.current;
2777
2691
  if (st.isDrawing) {
2778
- const gt = e === "freehand" ? Vt(xt) : xt;
2779
- if (gt.length >= 4) {
2780
- const Tt = Ge(gt), Lt = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 0, kt = Lt > 0 ? Tt * Lt * Lt / (xr * xr) : 0, ue = ct.format(kt), ee = st.cursorScreen ?? (st.current ? $t(a.current?.worldToScreen(st.current[0], st.current[1]) ?? []) : null);
2692
+ const yt = e === "freehand" ? Vt(wt) : wt;
2693
+ if (yt.length >= 4) {
2694
+ const It = Ge(yt), Ft = typeof r == "number" && Number.isFinite(r) && r > 0 ? r : 0, kt = Ft > 0 ? It * Ft * Ft / (xr * xr) : 0, ue = ct.format(kt), ee = st.cursorScreen ?? (st.current ? $t(a.current?.worldToScreen(st.current[0], st.current[1]) ?? []) : null);
2781
2695
  ee && Ks(
2782
2696
  A,
2783
2697
  ue,
@@ -2792,84 +2706,84 @@ function ia({
2792
2706
  }
2793
2707
  }
2794
2708
  }, [
2795
- O,
2709
+ U,
2796
2710
  e,
2797
- J,
2798
- Pt,
2799
- St,
2711
+ Q,
2712
+ vt,
2713
+ Et,
2800
2714
  t,
2801
2715
  n,
2802
2716
  a,
2803
- bt,
2717
+ j,
2804
2718
  B,
2805
- k,
2719
+ N,
2806
2720
  Y,
2807
- it,
2808
- Nt,
2809
- dt,
2810
- yt,
2811
- ft,
2812
- wt,
2721
+ rt,
2722
+ Dt,
2723
+ Rt,
2724
+ At,
2725
+ ht,
2726
+ mt,
2813
2727
  P,
2814
2728
  R,
2815
- ot,
2729
+ nt,
2816
2730
  ct,
2817
- F,
2818
- I,
2731
+ O,
2732
+ v,
2819
2733
  W,
2820
- j,
2734
+ J,
2821
2735
  r,
2822
- H
2736
+ ut
2823
2737
  ]), X = V(() => {
2824
2738
  _t.current || (_t.current = !0, requestAnimationFrame(() => {
2825
2739
  _t.current = !1, Mt();
2826
2740
  }));
2827
- }, [Mt]), Ft = V((b = !1) => {
2828
- const A = v.current, T = et.current;
2829
- T && A.pointerId !== null && T.hasPointerCapture(A.pointerId) && T.releasePointerCapture(A.pointerId), A.isDrawing = !1, A.pointerId = null, A.start = null, A.current = null, A.points = [], A.screenPoints = [], A.stampCenter = null, b || (A.cursor = null, A.cursorScreen = null);
2741
+ }, [Mt]), Tt = V((b = !1) => {
2742
+ const A = C.current, I = tt.current;
2743
+ I && A.pointerId !== null && I.hasPointerCapture(A.pointerId) && I.releasePointerCapture(A.pointerId), A.isDrawing = !1, A.pointerId = null, A.start = null, A.current = null, A.points = [], A.screenPoints = [], A.stampCenter = null, b || (A.cursor = null, A.cursorScreen = null);
2830
2744
  }, []), Bt = V(
2831
2745
  (b) => {
2832
2746
  const A = a.current;
2833
2747
  if (!A || t <= 0 || n <= 0) return null;
2834
- const T = $t(A.screenToWorld(b.clientX, b.clientY));
2835
- return T ? Qe(T, t, n) : null;
2748
+ const I = $t(A.screenToWorld(b.clientX, b.clientY));
2749
+ return I ? Qe(I, t, n) : null;
2836
2750
  },
2837
2751
  [a, t, n]
2838
- ), z = V((b) => {
2839
- const A = et.current;
2752
+ ), zt = V((b) => {
2753
+ const A = tt.current;
2840
2754
  if (!A) return null;
2841
- const T = A.getBoundingClientRect(), D = _(b.clientX - T.left, 0, T.width), Z = _(b.clientY - T.top, 0, T.height);
2755
+ const I = A.getBoundingClientRect(), D = _(b.clientX - I.left, 0, I.width), Z = _(b.clientY - I.top, 0, I.height);
2842
2756
  return !Number.isFinite(D) || !Number.isFinite(Z) ? null : [D, Z];
2843
- }, []), K = V(() => {
2844
- const b = v.current;
2757
+ }, []), k = V(() => {
2758
+ const b = C.current;
2845
2759
  if (!b.isDrawing) {
2846
- Ft(!0), X();
2760
+ Tt(!0), X();
2847
2761
  return;
2848
2762
  }
2849
2763
  let A = [];
2850
2764
  if (e === "freehand")
2851
2765
  b.points.length >= fs && (A = Vt(b.points));
2852
2766
  else if (e === "rectangle")
2853
- A = Rn(b.start, b.current, Q());
2767
+ A = Rn(b.start, b.current, K());
2854
2768
  else if (e === "circular")
2855
2769
  A = Er(b.start, b.current);
2856
2770
  else if (e === "brush") {
2857
- const T = b.points[b.points.length - 1] ?? b.current ?? b.start;
2858
- if (H.clickSelectRoi && T && b.points.length <= 1 && l?.(T)) {
2859
- Ft(!0), X();
2771
+ const I = b.points[b.points.length - 1] ?? b.current ?? b.start;
2772
+ if (ut.clickSelectRoi && I && b.points.length <= 1 && l?.(I)) {
2773
+ Tt(!0), X();
2860
2774
  return;
2861
2775
  }
2862
- const D = Math.max(0.25, H.edgeDetail), Z = b.screenPoints.length > 0 ? b.screenPoints : St(b.points), xt = Math.max(0.5, H.radius * 0.04 / D), st = cs(Z, {
2863
- radius: H.radius,
2776
+ const D = Math.max(0.25, ut.edgeDetail), Z = b.screenPoints.length > 0 ? b.screenPoints : Et(b.points), wt = Math.max(0.5, ut.radius * 0.04 / D), st = cs(Z, {
2777
+ radius: ut.radius,
2864
2778
  circleSides: Math.max(16, Math.round(32 * D)),
2865
- simplifyTolerance: xt,
2866
- smoothingPasses: H.edgeSmoothing
2867
- }), gt = [];
2868
- for (const Tt of st) {
2869
- const Lt = G(Tt);
2870
- Lt && gt.push(Lt);
2779
+ simplifyTolerance: wt,
2780
+ smoothingPasses: ut.edgeSmoothing
2781
+ }), yt = [];
2782
+ for (const It of st) {
2783
+ const Ft = G(It);
2784
+ Ft && yt.push(Ft);
2871
2785
  }
2872
- A = Vt(gt);
2786
+ A = Vt(yt);
2873
2787
  }
2874
2788
  (e === "freehand" || e === "rectangle" || e === "circular" || e === "brush") && Mr(A) && c && c({
2875
2789
  tool: e,
@@ -2877,72 +2791,72 @@ function ia({
2877
2791
  coordinates: A,
2878
2792
  bbox: wr(A),
2879
2793
  areaPx: Ge(A)
2880
- }), Ft(!0), X();
2794
+ }), Tt(!0), X();
2881
2795
  }, [
2882
2796
  e,
2883
2797
  c,
2884
- Ft,
2798
+ Tt,
2885
2799
  X,
2886
- St,
2800
+ Et,
2887
2801
  G,
2888
- Q,
2889
- H.radius,
2890
- H.edgeDetail,
2891
- H.edgeSmoothing,
2892
- H.clickSelectRoi,
2802
+ K,
2803
+ ut.radius,
2804
+ ut.edgeDetail,
2805
+ ut.edgeSmoothing,
2806
+ ut.clickSelectRoi,
2893
2807
  l
2894
- ]), tt = V(
2808
+ ]), H = V(
2895
2809
  (b, A) => {
2896
- const T = rt(b, A);
2897
- if (!Mr(T)) return;
2810
+ const I = et(b, A);
2811
+ if (!Mr(I)) return;
2898
2812
  const D = b === "stamp-rectangle-4096px" ? "patch" : "roi", Z = {
2899
2813
  tool: b,
2900
2814
  intent: D,
2901
- coordinates: T,
2902
- bbox: wr(T),
2903
- areaPx: Ge(T)
2815
+ coordinates: I,
2816
+ bbox: wr(I),
2817
+ areaPx: Ge(I)
2904
2818
  };
2905
2819
  c?.(Z), D === "patch" && f && f(Z);
2906
2820
  },
2907
- [rt, c, f]
2908
- ), nt = V(
2909
- (b, A, T) => {
2910
- const D = Math.max(Is, H.radius * 0.1), Z = D * D, xt = b.screenPoints[b.screenPoints.length - 1];
2911
- if (!xt) {
2912
- b.points.push(A), b.screenPoints.push(T), b.current = A;
2821
+ [et, c, f]
2822
+ ), $ = V(
2823
+ (b, A, I) => {
2824
+ const D = Math.max(Is, ut.radius * 0.1), Z = D * D, wt = b.screenPoints[b.screenPoints.length - 1];
2825
+ if (!wt) {
2826
+ b.points.push(A), b.screenPoints.push(I), b.current = A;
2913
2827
  return;
2914
2828
  }
2915
- const st = T[0] - xt[0], gt = T[1] - xt[1];
2916
- st * st + gt * gt >= Z ? (b.points.push(A), b.screenPoints.push(T)) : (b.points[b.points.length - 1] = A, b.screenPoints[b.screenPoints.length - 1] = T), b.current = A;
2829
+ const st = I[0] - wt[0], yt = I[1] - wt[1];
2830
+ st * st + yt * yt >= Z ? (b.points.push(A), b.screenPoints.push(I)) : (b.points[b.points.length - 1] = A, b.screenPoints[b.screenPoints.length - 1] = I), b.current = A;
2917
2831
  },
2918
- [H.radius]
2919
- ), Rt = V(
2832
+ [ut.radius]
2833
+ ), ot = V(
2920
2834
  (b) => {
2921
- if (!O || e === "cursor" || b.button !== 0) return;
2835
+ if (!U || e === "cursor" || b.button !== 0) return;
2922
2836
  const A = Bt(b);
2923
2837
  if (!A) return;
2924
- const T = z(b);
2925
- if (!T) return;
2838
+ const I = zt(b);
2839
+ if (!I) return;
2926
2840
  if (b.preventDefault(), b.stopPropagation(), Ne(e)) {
2927
- const xt = v.current;
2928
- xt.stampCenter = A, tt(e, A), X();
2841
+ const wt = C.current;
2842
+ wt.stampCenter = A, H(e, A), X();
2929
2843
  return;
2930
2844
  }
2931
- const D = et.current;
2845
+ const D = tt.current;
2932
2846
  D && D.setPointerCapture(b.pointerId);
2933
- const Z = v.current;
2934
- Z.isDrawing = !0, Z.pointerId = b.pointerId, Z.start = A, Z.current = A, Z.cursor = A, Z.cursorScreen = T, Z.points = e === "freehand" || e === "brush" ? [A] : [], Z.screenPoints = e === "brush" ? [T] : [], X();
2847
+ const Z = C.current;
2848
+ Z.isDrawing = !0, Z.pointerId = b.pointerId, Z.start = A, Z.current = A, Z.cursor = A, Z.cursorScreen = I, Z.points = e === "freehand" || e === "brush" ? [A] : [], Z.screenPoints = e === "brush" ? [I] : [], X();
2935
2849
  },
2936
- [O, e, Bt, z, tt, X]
2937
- ), At = V(
2850
+ [U, e, Bt, zt, H, X]
2851
+ ), bt = V(
2938
2852
  (b) => {
2939
- if (!O || e === "cursor") return;
2853
+ if (!U || e === "cursor") return;
2940
2854
  const A = Bt(b);
2941
2855
  if (!A) return;
2942
- const T = z(b);
2943
- if (!T) return;
2944
- const D = v.current;
2945
- if (D.cursor = A, D.cursorScreen = T, Ne(e)) {
2856
+ const I = zt(b);
2857
+ if (!I) return;
2858
+ const D = C.current;
2859
+ if (D.cursor = A, D.cursorScreen = I, Ne(e)) {
2946
2860
  D.stampCenter = A, b.preventDefault(), b.stopPropagation(), X();
2947
2861
  return;
2948
2862
  }
@@ -2951,92 +2865,92 @@ function ia({
2951
2865
  X();
2952
2866
  return;
2953
2867
  }
2954
- b.preventDefault(), b.stopPropagation(), nt(D, A, T), X();
2868
+ b.preventDefault(), b.stopPropagation(), $(D, A, I), X();
2955
2869
  return;
2956
2870
  }
2957
2871
  if (!(!D.isDrawing || D.pointerId !== b.pointerId)) {
2958
2872
  if (b.preventDefault(), b.stopPropagation(), e === "freehand") {
2959
- const Z = a.current, xt = Math.max(1e-6, Z?.getViewState?.().zoom ?? 1), st = hs / xt, gt = st * st, Tt = D.points[D.points.length - 1];
2960
- if (!Tt)
2873
+ const Z = a.current, wt = Math.max(1e-6, Z?.getViewState?.().zoom ?? 1), st = hs / wt, yt = st * st, It = D.points[D.points.length - 1];
2874
+ if (!It)
2961
2875
  D.points.push(A);
2962
2876
  else {
2963
- const Lt = A[0] - Tt[0], kt = A[1] - Tt[1];
2964
- Lt * Lt + kt * kt >= gt && D.points.push(A);
2877
+ const Ft = A[0] - It[0], kt = A[1] - It[1];
2878
+ Ft * Ft + kt * kt >= yt && D.points.push(A);
2965
2879
  }
2966
2880
  } else
2967
2881
  D.current = A;
2968
2882
  X();
2969
2883
  }
2970
2884
  },
2971
- [O, e, Bt, z, X, a, nt]
2972
- ), vt = V(
2885
+ [U, e, Bt, zt, X, a, $]
2886
+ ), pt = V(
2973
2887
  (b) => {
2974
- const A = v.current;
2888
+ const A = C.current;
2975
2889
  if (!A.isDrawing || A.pointerId !== b.pointerId) return;
2976
2890
  b.preventDefault(), b.stopPropagation();
2977
- const T = Bt(b), D = z(b);
2978
- T && (A.cursor = T, D && (A.cursorScreen = D), e === "brush" ? D && nt(A, T, D) : A.current = T);
2979
- const Z = et.current;
2980
- Z && Z.hasPointerCapture(b.pointerId) && Z.releasePointerCapture(b.pointerId), K();
2891
+ const I = Bt(b), D = zt(b);
2892
+ I && (A.cursor = I, D && (A.cursorScreen = D), e === "brush" ? D && $(A, I, D) : A.current = I);
2893
+ const Z = tt.current;
2894
+ Z && Z.hasPointerCapture(b.pointerId) && Z.releasePointerCapture(b.pointerId), k();
2981
2895
  },
2982
- [K, Bt, z, e, nt]
2896
+ [k, Bt, zt, e, $]
2983
2897
  ), Ut = V(() => {
2984
- const b = v.current;
2898
+ const b = C.current;
2985
2899
  let A = !1;
2986
2900
  e === "brush" && !b.isDrawing && b.cursor && (b.cursor = null, b.cursorScreen = null, A = !0), Ne(e) && b.stampCenter && (b.stampCenter = null, A = !0), A && X();
2987
2901
  }, [e, X]);
2988
- return U(() => {
2989
- Pt(), X();
2990
- const b = et.current;
2902
+ return z(() => {
2903
+ vt(), X();
2904
+ const b = tt.current;
2991
2905
  if (!b) return;
2992
2906
  const A = new ResizeObserver(() => {
2993
- Pt(), X();
2907
+ vt(), X();
2994
2908
  });
2995
2909
  return A.observe(b), () => {
2996
2910
  A.disconnect();
2997
2911
  };
2998
- }, [Pt, X]), U(() => sn(() => {
2999
- Pt(), X();
3000
- }), [Pt, X]), U(() => {
3001
- O || Ft(), X();
3002
- }, [O, X, Ft]), U(() => {
3003
- L.current !== e && (L.current = e, Ft(), X());
3004
- }, [e, Ft, X]), U(() => {
2912
+ }, [vt, X]), z(() => sn(() => {
2913
+ vt(), X();
2914
+ }), [vt, X]), z(() => {
2915
+ U || Tt(), X();
2916
+ }, [U, X, Tt]), z(() => {
2917
+ L.current !== e && (L.current = e, Tt(), X());
2918
+ }, [e, Tt, X]), z(() => {
3005
2919
  X();
3006
- }, [h, lt, B, X]), U(() => {
3007
- if (N)
3008
- return N.current = X, () => {
3009
- N.current === X && (N.current = null);
2920
+ }, [h, lt, B, X]), z(() => {
2921
+ if (F)
2922
+ return F.current = X, () => {
2923
+ F.current === X && (F.current = null);
3010
2924
  };
3011
- }, [N, X]), U(() => {
3012
- if (!O) return;
2925
+ }, [F, X]), z(() => {
2926
+ if (!U) return;
3013
2927
  const b = (A) => {
3014
- A.key === "Escape" && (Ft(), X());
2928
+ A.key === "Escape" && (Tt(), X());
3015
2929
  };
3016
2930
  return window.addEventListener("keydown", b), () => {
3017
2931
  window.removeEventListener("keydown", b);
3018
2932
  };
3019
- }, [O, Ft, X]), /* @__PURE__ */ Qt(
2933
+ }, [U, Tt, X]), /* @__PURE__ */ Qt(
3020
2934
  "canvas",
3021
2935
  {
3022
- ref: et,
3023
- className: ut,
3024
- style: It,
3025
- onPointerDown: Rt,
3026
- onPointerMove: At,
3027
- onPointerUp: vt,
3028
- onPointerCancel: vt,
2936
+ ref: tt,
2937
+ className: xt,
2938
+ style: it,
2939
+ onPointerDown: ot,
2940
+ onPointerMove: bt,
2941
+ onPointerUp: pt,
2942
+ onPointerCancel: pt,
3029
2943
  onPointerLeave: Ut,
3030
2944
  onContextMenu: (b) => {
3031
- O && b.preventDefault();
2945
+ U && b.preventDefault();
3032
2946
  },
3033
2947
  onWheel: (b) => {
3034
- if (!O) return;
3035
- const A = et.current, T = a.current, D = typeof T?.handleWheelZoom == "function", Z = typeof T?.zoomBy == "function";
2948
+ if (!U) return;
2949
+ const A = tt.current, I = a.current, D = typeof I?.handleWheelZoom == "function", Z = typeof I?.zoomBy == "function";
3036
2950
  if (!A || !D && !Z) return;
3037
2951
  b.preventDefault(), b.stopPropagation();
3038
- const xt = A.getBoundingClientRect(), st = b.clientX - xt.left, gt = b.clientY - xt.top;
3039
- D ? T.handleWheelZoom?.(b.deltaY, st, gt) : T.zoomBy?.(b.deltaY < 0 ? ps : ys, st, gt), X();
2952
+ const wt = A.getBoundingClientRect(), st = b.clientX - wt.left, yt = b.clientY - wt.top;
2953
+ D ? I.handleWheelZoom?.(b.deltaY, st, yt) : I.zoomBy?.(b.deltaY < 0 ? ps : ys, st, yt), X();
3040
2954
  }
3041
2955
  }
3042
2956
  );
@@ -3050,7 +2964,7 @@ function pe() {
3050
2964
  }
3051
2965
  function iu({ tool: e = "cursor", stampOptions: t, brushOptions: n, fillColor: r, areaTooltip: i, onComplete: o, onPatchComplete: s, onBrushTap: a }) {
3052
2966
  const { source: l, rendererRef: c, rendererSerial: f, setInteractionLock: u } = pe(), h = e !== "cursor";
3053
- U(() => (u("drawing-layer", h), () => u("drawing-layer", !1)), [h, u]);
2967
+ z(() => (u("drawing-layer", h), () => u("drawing-layer", !1)), [h, u]);
3054
2968
  const d = at(() => c.current?.getViewState(), [f]);
3055
2969
  return l ? /* @__PURE__ */ Qt(
3056
2970
  ia,
@@ -3293,10 +3207,10 @@ class ha {
3293
3207
  if (!u || !h || !d || !m || !g || !y || !p || !x || !E || !w || !P || !R || !B)
3294
3208
  throw new Error("Failed to resolve heatmap WebGL uniforms.");
3295
3209
  this.uAccumResolution = u, this.uAccumPointSize = h, this.uAccumCoreRatio = d, this.uAccumPointAlpha = m, this.uColorAccumTexture = g, this.uColorGradientTexture = y, this.uColorOpacity = p, this.uColorCutoff = x, this.uColorGain = E, this.uColorGamma = w, this.uColorBias = P, this.uColorStretch = R, this.uColorResolution = B, t.bindVertexArray(this.accumVao), t.bindBuffer(t.ARRAY_BUFFER, this.pointBuffer), t.bufferData(t.ARRAY_BUFFER, 0, t.DYNAMIC_DRAW);
3296
- const k = t.getAttribLocation(this.accumProgram, "aCenter"), Y = t.getAttribLocation(this.accumProgram, "aWeight");
3297
- if (k < 0 || Y < 0)
3210
+ const N = t.getAttribLocation(this.accumProgram, "aCenter"), Y = t.getAttribLocation(this.accumProgram, "aWeight");
3211
+ if (N < 0 || Y < 0)
3298
3212
  throw new Error("Failed to resolve heatmap WebGL attributes.");
3299
- t.enableVertexAttribArray(k), t.vertexAttribPointer(k, 2, t.FLOAT, !1, 12, 0), t.enableVertexAttribArray(Y), t.vertexAttribPointer(Y, 1, t.FLOAT, !1, 12, 8), t.bindVertexArray(null), t.bindVertexArray(this.colorVao), t.bindBuffer(t.ARRAY_BUFFER, this.quadBuffer), t.bufferData(t.ARRAY_BUFFER, new Float32Array([
3213
+ t.enableVertexAttribArray(N), t.vertexAttribPointer(N, 2, t.FLOAT, !1, 12, 0), t.enableVertexAttribArray(Y), t.vertexAttribPointer(Y, 1, t.FLOAT, !1, 12, 8), t.bindVertexArray(null), t.bindVertexArray(this.colorVao), t.bindBuffer(t.ARRAY_BUFFER, this.quadBuffer), t.bufferData(t.ARRAY_BUFFER, new Float32Array([
3300
3214
  -1,
3301
3215
  -1,
3302
3216
  1,
@@ -3707,28 +3621,28 @@ function Fr(e) {
3707
3621
  if (!w || !P)
3708
3622
  return 0;
3709
3623
  const R = a.kernelRadiusPx + a.blurRadiusPx, B = Ia(f);
3710
- let k = 0;
3624
+ let N = 0;
3711
3625
  for (let M = 0; M < c.length; M += 1) {
3712
- const C = c[M];
3713
- if (!Na(C, f)) continue;
3714
- const F = l.xs[C], I = l.ys[C];
3715
- if (!Number.isFinite(F) || !Number.isFinite(I)) continue;
3716
- const W = r.worldToScreen(F, I);
3626
+ const T = c[M];
3627
+ if (!Na(T, f)) continue;
3628
+ const O = l.xs[T], v = l.ys[T];
3629
+ if (!Number.isFinite(O) || !Number.isFinite(v)) continue;
3630
+ const W = r.worldToScreen(O, v);
3717
3631
  if (!Array.isArray(W) || W.length < 2) continue;
3718
- const j = Number(W[0]), N = Number(W[1]);
3719
- if (!Number.isFinite(j) || !Number.isFinite(N)) continue;
3720
- const ut = j * a.rasterScaleX, pt = N * a.rasterScaleY;
3721
- if (ut < -R || pt < -R || ut > a.rasterWidth + R || pt > a.rasterHeight + R)
3632
+ const J = Number(W[0]), F = Number(W[1]);
3633
+ if (!Number.isFinite(J) || !Number.isFinite(F)) continue;
3634
+ const xt = J * a.rasterScaleX, ft = F * a.rasterScaleY;
3635
+ if (xt < -R || ft < -R || xt > a.rasterWidth + R || ft > a.rasterHeight + R)
3722
3636
  continue;
3723
- const et = k * 2;
3724
- w[et] = ut, w[et + 1] = pt, P[k] = Math.max(0, (l.ws[C] ?? 0) * B), k += 1;
3637
+ const tt = N * 2;
3638
+ w[tt] = xt, w[tt + 1] = ft, P[N] = Math.max(0, (l.ws[T] ?? 0) * B), N += 1;
3725
3639
  }
3726
- return k <= 0 || !x.render({
3640
+ return N <= 0 || !x.render({
3727
3641
  width: a.rasterWidth,
3728
3642
  height: a.rasterHeight,
3729
3643
  positions: w,
3730
3644
  weights: P,
3731
- count: k,
3645
+ count: N,
3732
3646
  kernelRadiusPx: a.kernelRadiusPx,
3733
3647
  blurRadiusPx: a.blurRadiusPx,
3734
3648
  pointAlpha: h,
@@ -3739,7 +3653,7 @@ function Fr(e) {
3739
3653
  gamma: Li(g),
3740
3654
  bias: Di(g),
3741
3655
  stretch: Ni(g, a.rawZoom, i)
3742
- }) ? 0 : (t.save(), p.length > 0 && Ba(t, r, p), y && (t.fillStyle = y, t.fillRect(0, 0, o, s)), t.globalAlpha = 1, t.imageSmoothingEnabled = !0, t.drawImage(x.canvas, 0, 0, a.rasterWidth, a.rasterHeight, 0, 0, o, s), t.restore(), k);
3656
+ }) ? 0 : (t.save(), p.length > 0 && Ba(t, r, p), y && (t.fillStyle = y, t.fillRect(0, 0, o, s)), t.globalAlpha = 1, t.imageSmoothingEnabled = !0, t.drawImage(x.canvas, 0, 0, a.rasterWidth, a.rasterHeight, 0, 0, o, s), t.restore(), N);
3743
3657
  }
3744
3658
  function ka(e) {
3745
3659
  const { ctx: t, runtime: n, renderer: r, source: i, logicalWidth: o, logicalHeight: s, state: a } = e, l = Wi(n, a.data, a.clipPolygons, a.clipKey, i);
@@ -3877,8 +3791,8 @@ function ou({
3877
3791
  onStats: m
3878
3792
  }) {
3879
3793
  const { rendererRef: g, source: y, registerDrawCallback: p, unregisterDrawCallback: x, requestOverlayRedraw: E } = pe(), w = at(() => {
3880
- const k = (u ?? []).map((Y) => Ce(Y?.coordinates)).filter((Y) => Y != null);
3881
- return ge(k);
3794
+ const N = (u ?? []).map((Y) => Ce(Y?.coordinates)).filter((Y) => Y != null);
3795
+ return ge(N);
3882
3796
  }, [u]), P = at(() => Bi(w), [w]), R = q({
3883
3797
  sourceData: null,
3884
3798
  fixedState: null,
@@ -3926,44 +3840,44 @@ function ou({
3926
3840
  clipKey: P,
3927
3841
  maxRenderedPoints: Math.max(Mn, Math.floor(d)),
3928
3842
  onStats: m
3929
- }, U(() => (p(Tr, h, (Y, M, C) => {
3930
- const F = B.current, I = R.current, W = g.current;
3931
- if (!F.visible || !F.data || !W || !y) return;
3932
- const j = Wi(I, F.data, F.clipPolygons, F.clipKey, y);
3933
- if (!j) return;
3934
- F.scaleMode === "fixed-zoom" && (!I.fixedState || !Vn(I.fixedState, F.data, F.clipKey) || F.fixedZoom !== void 0 && Math.abs(I.fixedState.referenceZoom - F.fixedZoom) > 1e-6) ? I.fixedState = Ua({
3935
- sourceData: j,
3843
+ }, z(() => (p(Tr, h, (Y, M, T) => {
3844
+ const O = B.current, v = R.current, W = g.current;
3845
+ if (!O.visible || !O.data || !W || !y) return;
3846
+ const J = Wi(v, O.data, O.clipPolygons, O.clipKey, y);
3847
+ if (!J) return;
3848
+ O.scaleMode === "fixed-zoom" && (!v.fixedState || !Vn(v.fixedState, O.data, O.clipKey) || O.fixedZoom !== void 0 && Math.abs(v.fixedState.referenceZoom - O.fixedZoom) > 1e-6) ? v.fixedState = Ua({
3849
+ sourceData: J,
3936
3850
  renderer: W,
3937
3851
  source: y,
3938
3852
  logicalWidth: M,
3939
- logicalHeight: C,
3940
- radius: F.radius,
3941
- blur: F.blur,
3942
- fixedZoom: F.fixedZoom,
3943
- zoomThreshold: F.zoomThreshold,
3944
- densityContrast: F.densityContrast,
3945
- maxRenderedPoints: F.maxRenderedPoints
3946
- }) : F.scaleMode !== "fixed-zoom" && (I.fixedState = null);
3947
- const ut = performance.now(), pt = ka({
3853
+ logicalHeight: T,
3854
+ radius: O.radius,
3855
+ blur: O.blur,
3856
+ fixedZoom: O.fixedZoom,
3857
+ zoomThreshold: O.zoomThreshold,
3858
+ densityContrast: O.densityContrast,
3859
+ maxRenderedPoints: O.maxRenderedPoints
3860
+ }) : O.scaleMode !== "fixed-zoom" && (v.fixedState = null);
3861
+ const xt = performance.now(), ft = ka({
3948
3862
  ctx: Y,
3949
- runtime: I,
3863
+ runtime: v,
3950
3864
  renderer: W,
3951
3865
  source: y,
3952
3866
  logicalWidth: M,
3953
- logicalHeight: C,
3954
- state: F
3867
+ logicalHeight: T,
3868
+ state: O
3955
3869
  });
3956
- !pt || !F.onStats || F.onStats({
3957
- ...pt,
3958
- renderTimeMs: performance.now() - ut
3870
+ !ft || !O.onStats || O.onStats({
3871
+ ...ft,
3872
+ renderTimeMs: performance.now() - xt
3959
3873
  });
3960
3874
  }), () => {
3961
3875
  x(Tr), R.current.sourceData = null, R.current.fixedState = null, R.current.screenLevelIndex = -1, R.current.screenSecondaryLevelIndex = -1, R.current.screenSecondaryLevelWeight = 0, R.current.screenPointAlpha = 0, R.current.screenNormalizationMaxWeight = 1, R.current.screenVisibilityStrength = 1, R.current.webgl?.destroy(), R.current.webgl = void 0, R.current.webglPositions = null, R.current.webglWeights = null, R.current.webglCapacity = 0;
3962
- }), [p, x, g, y, h]), U(() => {
3876
+ }), [p, x, g, y, h]), z(() => {
3963
3877
  R.current.sourceData = null, R.current.fixedState = null, R.current.screenLevelIndex = -1, R.current.screenSecondaryLevelIndex = -1, R.current.screenSecondaryLevelWeight = 0, R.current.screenPointAlpha = 0, R.current.screenNormalizationMaxWeight = 1, R.current.screenVisibilityStrength = 1, E();
3964
- }, [e?.positions, e?.weights, e?.count, P, E]), U(() => {
3878
+ }, [e?.positions, e?.weights, e?.count, P, E]), z(() => {
3965
3879
  R.current.fixedState = null, R.current.screenSecondaryLevelIndex = -1, R.current.screenSecondaryLevelWeight = 0, R.current.screenPointAlpha = 0, R.current.screenNormalizationMaxWeight = 1, R.current.screenVisibilityStrength = 1, E();
3966
- }, [r, i, a, l, c, f, d, E]), U(() => {
3880
+ }, [r, i, a, l, c, f, d, E]), z(() => {
3967
3881
  E();
3968
3882
  }, [t, n, o, s, E]), null;
3969
3883
  }
@@ -4001,7 +3915,7 @@ function au({ shapes: e }) {
4001
3915
  },
4002
3916
  []
4003
3917
  ), l = q({ shapes: e, worldToScreenPoints: a, source: r });
4004
- return l.current = { shapes: e, worldToScreenPoints: a, source: r }, U(() => (i(Lr, 30, (f) => {
3918
+ return l.current = { shapes: e, worldToScreenPoints: a, source: r }, z(() => (i(Lr, 30, (f) => {
4005
3919
  const { shapes: u, worldToScreenPoints: h, source: d } = l.current;
4006
3920
  if (!Array.isArray(u) || u.length === 0 || !d) return;
4007
3921
  const m = h(
@@ -4019,7 +3933,7 @@ function au({ shapes: e }) {
4019
3933
  worldToScreenPoints: h,
4020
3934
  baseStrokeStyle: jt
4021
3935
  });
4022
- }), () => o(Lr)), [i, o]), U(() => {
3936
+ }), () => o(Lr)), [i, o]), z(() => {
4023
3937
  s();
4024
3938
  }, [n, e, r, s]), null;
4025
3939
  }
@@ -4250,7 +4164,7 @@ function uu({ source: e, projectorRef: t, authToken: n = "", options: r, invalid
4250
4164
  const a = q(null), l = q(null), c = q(null), f = q({
4251
4165
  active: !1,
4252
4166
  pointerId: null
4253
- }), u = q(null), h = q(!1), d = he(r?.width, Xt.width, 64), m = he(r?.height, Xt.height, 48), g = he(r?.margin, Xt.margin, 0), y = he(r?.borderRadius, Xt.borderRadius, 0), p = he(r?.borderWidth, Xt.borderWidth, 0), x = Math.max(1, Math.round(he(r?.maxThumbnailTiles, Xt.maxThumbnailTiles, 1))), E = r?.backgroundColor || Xt.backgroundColor, w = r?.borderColor || Xt.borderColor, P = r?.viewportBorderColor || Xt.viewportBorderColor, R = r?.viewportBorderStyle === "stroke" || r?.viewportBorderStyle === "dash" ? r.viewportBorderStyle : Xt.viewportBorderStyle, B = r?.viewportFillColor ?? Xt.viewportFillColor, k = r?.interactive ?? Xt.interactive, Y = r?.showThumbnail ?? Xt.showThumbnail, M = r?.position || Xt.position, C = r?.onClose, F = r?.closeIcon, I = r?.closeButtonStyle, W = at(() => {
4167
+ }), u = q(null), h = q(!1), d = he(r?.width, Xt.width, 64), m = he(r?.height, Xt.height, 48), g = he(r?.margin, Xt.margin, 0), y = he(r?.borderRadius, Xt.borderRadius, 0), p = he(r?.borderWidth, Xt.borderWidth, 0), x = Math.max(1, Math.round(he(r?.maxThumbnailTiles, Xt.maxThumbnailTiles, 1))), E = r?.backgroundColor || Xt.backgroundColor, w = r?.borderColor || Xt.borderColor, P = r?.viewportBorderColor || Xt.viewportBorderColor, R = r?.viewportBorderStyle === "stroke" || r?.viewportBorderStyle === "dash" ? r.viewportBorderStyle : Xt.viewportBorderStyle, B = r?.viewportFillColor ?? Xt.viewportFillColor, N = r?.interactive ?? Xt.interactive, Y = r?.showThumbnail ?? Xt.showThumbnail, M = r?.position || Xt.position, T = r?.onClose, O = r?.closeIcon, v = r?.closeButtonStyle, W = at(() => {
4254
4168
  const L = {};
4255
4169
  return M === "top-left" || M === "bottom-left" ? L.left = g : L.right = g, M === "top-left" || M === "top-right" ? L.top = g : L.bottom = g, {
4256
4170
  position: "absolute",
@@ -4260,173 +4174,173 @@ function uu({ source: e, projectorRef: t, authToken: n = "", options: r, invalid
4260
4174
  borderRadius: y,
4261
4175
  overflow: "hidden",
4262
4176
  zIndex: 4,
4263
- pointerEvents: k ? "auto" : "none",
4177
+ pointerEvents: N ? "auto" : "none",
4264
4178
  touchAction: "none",
4265
4179
  boxShadow: "0 10px 22px rgba(0, 0, 0, 0.3)",
4266
4180
  ...s
4267
4181
  };
4268
- }, [g, M, d, m, y, k, s]), j = V(() => {
4182
+ }, [g, M, d, m, y, N, s]), J = V(() => {
4269
4183
  const L = a.current;
4270
4184
  if (!L) return;
4271
- const v = L.getContext("2d");
4272
- if (!v) return;
4273
- const O = d, lt = m, $ = Math.max(1, window.devicePixelRatio || 1), bt = Math.max(1, Math.round(O * $)), ft = Math.max(1, Math.round(lt * $));
4274
- (L.width !== bt || L.height !== ft) && (L.width = bt, L.height = ft), v.setTransform(1, 0, 0, 1, 0, 0), v.clearRect(0, 0, L.width, L.height), v.setTransform($, 0, 0, $, 0, 0), v.fillStyle = E, v.fillRect(0, 0, O, lt);
4275
- const it = t.current, Nt = Tn(it?.getInitialRotationDeg?.()), dt = Wr(e.width, e.height, O, lt, Nt), { contentX: wt, contentY: yt, contentWidth: ot, contentHeight: ct, metrics: ht } = dt, H = l.current;
4276
- H && (v.save(), v.beginPath(), v.rect(wt, yt, ot, ct), v.clip(), v.translate(wt, yt), v.scale(ot / ht.width, ct / ht.height), v.transform(ht.cos, -ht.sin, ht.sin, ht.cos, ht.translateX - ht.minX, ht.translateY - ht.minY), v.drawImage(H, 0, 0, e.width, e.height), v.restore()), v.strokeStyle = w, v.lineWidth = p, v.strokeRect(p * 0.5, p * 0.5, O - p, lt - p);
4277
- const It = it?.getViewBounds?.(), Pt = it?.getViewCorners?.(), St = Array.isArray(Pt) && Pt.length >= 4 && Pt.every((J) => Array.isArray(J) && J.length >= 2 && Number.isFinite(J[0]) && Number.isFinite(J[1])) ? Pt : null, G = xe(It) ? It : xe(c.current) ? c.current : null;
4278
- xe(It) && (c.current = It);
4279
- const Q = R === "dash";
4280
- if (St) {
4281
- const J = St.map((X) => Yr(X[0], X[1], dt)), Mt = Or(J, wt, yt, wt + ot, yt + ct);
4185
+ const C = L.getContext("2d");
4186
+ if (!C) return;
4187
+ const U = d, lt = m, dt = Math.max(1, window.devicePixelRatio || 1), j = Math.max(1, Math.round(U * dt)), ht = Math.max(1, Math.round(lt * dt));
4188
+ (L.width !== j || L.height !== ht) && (L.width = j, L.height = ht), C.setTransform(1, 0, 0, 1, 0, 0), C.clearRect(0, 0, L.width, L.height), C.setTransform(dt, 0, 0, dt, 0, 0), C.fillStyle = E, C.fillRect(0, 0, U, lt);
4189
+ const rt = t.current, Dt = Tn(rt?.getInitialRotationDeg?.()), Rt = Wr(e.width, e.height, U, lt, Dt), { contentX: mt, contentY: At, contentWidth: nt, contentHeight: ct, metrics: gt } = Rt, ut = l.current;
4190
+ ut && (C.save(), C.beginPath(), C.rect(mt, At, nt, ct), C.clip(), C.translate(mt, At), C.scale(nt / gt.width, ct / gt.height), C.transform(gt.cos, -gt.sin, gt.sin, gt.cos, gt.translateX - gt.minX, gt.translateY - gt.minY), C.drawImage(ut, 0, 0, e.width, e.height), C.restore()), C.strokeStyle = w, C.lineWidth = p, C.strokeRect(p * 0.5, p * 0.5, U - p, lt - p);
4191
+ const it = rt?.getViewBounds?.(), vt = rt?.getViewCorners?.(), Et = Array.isArray(vt) && vt.length >= 4 && vt.every((Q) => Array.isArray(Q) && Q.length >= 2 && Number.isFinite(Q[0]) && Number.isFinite(Q[1])) ? vt : null, G = xe(it) ? it : xe(c.current) ? c.current : null;
4192
+ xe(it) && (c.current = it);
4193
+ const K = R === "dash";
4194
+ if (Et) {
4195
+ const Q = Et.map((X) => Yr(X[0], X[1], Rt)), Mt = Or(Q, mt, At, mt + nt, At + ct);
4282
4196
  if (Mt.length >= 3) {
4283
- v.beginPath();
4197
+ C.beginPath();
4284
4198
  for (let X = 0; X < Mt.length; X += 1)
4285
- X === 0 ? v.moveTo(Mt[X][0], Mt[X][1]) : v.lineTo(Mt[X][0], Mt[X][1]);
4286
- v.closePath(), v.fillStyle = B, v.fill(), v.strokeStyle = P, v.lineWidth = 2.25, Q ? Nr(v, Mt, 4, 3) : v.stroke();
4199
+ X === 0 ? C.moveTo(Mt[X][0], Mt[X][1]) : C.lineTo(Mt[X][0], Mt[X][1]);
4200
+ C.closePath(), C.fillStyle = B, C.fill(), C.strokeStyle = P, C.lineWidth = 2.25, K ? Nr(C, Mt, 4, 3) : C.stroke();
4287
4201
  return;
4288
4202
  }
4289
4203
  }
4290
4204
  if (!G)
4291
4205
  return;
4292
- const mt = Ga(G).map((J) => Yr(J[0], J[1], dt)), rt = Or(mt, wt, yt, wt + ot, yt + ct);
4293
- if (!(rt.length < 3)) {
4294
- v.beginPath();
4295
- for (let J = 0; J < rt.length; J += 1)
4296
- J === 0 ? v.moveTo(rt[J][0], rt[J][1]) : v.lineTo(rt[J][0], rt[J][1]);
4297
- v.closePath(), v.fillStyle = B, v.fill(), v.strokeStyle = P, v.lineWidth = 2.25, Q ? Nr(v, rt, 4, 3) : v.stroke();
4298
- }
4299
- }, [d, m, E, w, p, t, e.width, e.height, B, P, R]), N = V(() => {
4206
+ const St = Ga(G).map((Q) => Yr(Q[0], Q[1], Rt)), et = Or(St, mt, At, mt + nt, At + ct);
4207
+ if (!(et.length < 3)) {
4208
+ C.beginPath();
4209
+ for (let Q = 0; Q < et.length; Q += 1)
4210
+ Q === 0 ? C.moveTo(et[Q][0], et[Q][1]) : C.lineTo(et[Q][0], et[Q][1]);
4211
+ C.closePath(), C.fillStyle = B, C.fill(), C.strokeStyle = P, C.lineWidth = 2.25, K ? Nr(C, et, 4, 3) : C.stroke();
4212
+ }
4213
+ }, [d, m, E, w, p, t, e.width, e.height, B, P, R]), F = V(() => {
4300
4214
  h.current || (h.current = !0, u.current = requestAnimationFrame(() => {
4301
- h.current = !1, u.current = null, j();
4215
+ h.current = !1, u.current = null, J();
4302
4216
  }));
4303
- }, [j]), ut = V(
4304
- (L, v) => {
4305
- const O = a.current;
4306
- if (!O) return null;
4307
- const lt = O.getBoundingClientRect();
4217
+ }, [J]), xt = V(
4218
+ (L, C) => {
4219
+ const U = a.current;
4220
+ if (!U) return null;
4221
+ const lt = U.getBoundingClientRect();
4308
4222
  if (!lt.width || !lt.height) return null;
4309
- const $ = t.current, bt = Tn($?.getInitialRotationDeg?.()), ft = Wr(e.width, e.height, d, m, bt), it = lt.width / d, Nt = lt.height / m, dt = ft.contentX * it, wt = ft.contentY * Nt, yt = ft.contentWidth * it, ot = ft.contentHeight * Nt, ct = _((L - lt.left - dt) / yt, 0, 1), ht = _((v - lt.top - wt) / ot, 0, 1);
4310
- return Va(ct * ft.metrics.width, ht * ft.metrics.height, ft, e.width, e.height);
4223
+ const dt = t.current, j = Tn(dt?.getInitialRotationDeg?.()), ht = Wr(e.width, e.height, d, m, j), rt = lt.width / d, Dt = lt.height / m, Rt = ht.contentX * rt, mt = ht.contentY * Dt, At = ht.contentWidth * rt, nt = ht.contentHeight * Dt, ct = _((L - lt.left - Rt) / At, 0, 1), gt = _((C - lt.top - mt) / nt, 0, 1);
4224
+ return Va(ct * ht.metrics.width, gt * ht.metrics.height, ht, e.width, e.height);
4311
4225
  },
4312
4226
  [t, e.width, e.height, d, m]
4313
- ), pt = V(
4314
- (L, v) => {
4315
- const O = t.current;
4316
- if (!O) return;
4317
- if (O.setViewCenter) {
4318
- O.setViewCenter(L, v), N();
4227
+ ), ft = V(
4228
+ (L, C) => {
4229
+ const U = t.current;
4230
+ if (!U) return;
4231
+ if (U.setViewCenter) {
4232
+ U.setViewCenter(L, C), F();
4319
4233
  return;
4320
4234
  }
4321
- const lt = O.getViewBounds?.(), $ = xe(lt) ? lt : xe(c.current) ? c.current : null;
4322
- if (!$) return;
4323
- const bt = Math.max(1e-6, $[2] - $[0]), ft = Math.max(1e-6, $[3] - $[1]);
4324
- O.setViewState({
4325
- offsetX: L - bt * 0.5,
4326
- offsetY: v - ft * 0.5
4327
- }), N();
4235
+ const lt = U.getViewBounds?.(), dt = xe(lt) ? lt : xe(c.current) ? c.current : null;
4236
+ if (!dt) return;
4237
+ const j = Math.max(1e-6, dt[2] - dt[0]), ht = Math.max(1e-6, dt[3] - dt[1]);
4238
+ U.setViewState({
4239
+ offsetX: L - j * 0.5,
4240
+ offsetY: C - ht * 0.5
4241
+ }), F();
4328
4242
  },
4329
- [t, N]
4330
- ), et = V(
4243
+ [t, F]
4244
+ ), tt = V(
4331
4245
  (L) => {
4332
- if (!k || L.button !== 0) return;
4333
- const v = a.current;
4334
- if (!v) return;
4335
- const O = ut(L.clientX, L.clientY);
4336
- O && (L.preventDefault(), L.stopPropagation(), v.setPointerCapture(L.pointerId), f.current = { active: !0, pointerId: L.pointerId }, pt(O[0], O[1]));
4246
+ if (!N || L.button !== 0) return;
4247
+ const C = a.current;
4248
+ if (!C) return;
4249
+ const U = xt(L.clientX, L.clientY);
4250
+ U && (L.preventDefault(), L.stopPropagation(), C.setPointerCapture(L.pointerId), f.current = { active: !0, pointerId: L.pointerId }, ft(U[0], U[1]));
4337
4251
  },
4338
- [k, ut, pt]
4252
+ [N, xt, ft]
4339
4253
  ), _t = V(
4340
4254
  (L) => {
4341
- const v = f.current;
4342
- if (!v.active || v.pointerId !== L.pointerId) return;
4343
- const O = ut(L.clientX, L.clientY);
4344
- O && (L.preventDefault(), L.stopPropagation(), pt(O[0], O[1]));
4255
+ const C = f.current;
4256
+ if (!C.active || C.pointerId !== L.pointerId) return;
4257
+ const U = xt(L.clientX, L.clientY);
4258
+ U && (L.preventDefault(), L.stopPropagation(), ft(U[0], U[1]));
4345
4259
  },
4346
- [ut, pt]
4260
+ [xt, ft]
4347
4261
  ), Ct = V(
4348
4262
  (L) => {
4349
- const v = f.current;
4350
- if (!v.active || v.pointerId !== L.pointerId) return;
4351
- const O = a.current;
4352
- if (O && O.hasPointerCapture(L.pointerId))
4263
+ const C = f.current;
4264
+ if (!C.active || C.pointerId !== L.pointerId) return;
4265
+ const U = a.current;
4266
+ if (U && U.hasPointerCapture(L.pointerId))
4353
4267
  try {
4354
- O.releasePointerCapture(L.pointerId);
4268
+ U.releasePointerCapture(L.pointerId);
4355
4269
  } catch {
4356
4270
  }
4357
- f.current = { active: !1, pointerId: null }, N();
4271
+ f.current = { active: !1, pointerId: null }, F();
4358
4272
  },
4359
- [N]
4273
+ [F]
4360
4274
  );
4361
- return U(() => {
4275
+ return z(() => {
4362
4276
  let L = !1;
4363
- l.current = null, N();
4364
- const v = 0, O = 2 ** (e.maxTierZoom - v), lt = Math.ceil(e.width / O), $ = Math.ceil(e.height / O), bt = Math.max(1, Math.ceil(lt / e.tileSize)), ft = Math.max(1, Math.ceil($ / e.tileSize)), it = bt * ft;
4365
- if (!Y || it > x)
4277
+ l.current = null, F();
4278
+ const C = 0, U = 2 ** (e.maxTierZoom - C), lt = Math.ceil(e.width / U), dt = Math.ceil(e.height / U), j = Math.max(1, Math.ceil(lt / e.tileSize)), ht = Math.max(1, Math.ceil(dt / e.tileSize)), rt = j * ht;
4279
+ if (!Y || rt > x)
4366
4280
  return;
4367
- const Nt = Math.min(d / Math.max(1, e.width), m / Math.max(1, e.height)), dt = document.createElement("canvas");
4368
- dt.width = Math.max(1, Math.round(e.width * Nt)), dt.height = Math.max(1, Math.round(e.height * Nt));
4369
- const wt = dt.getContext("2d");
4370
- if (!wt)
4281
+ const Dt = Math.min(d / Math.max(1, e.width), m / Math.max(1, e.height)), Rt = document.createElement("canvas");
4282
+ Rt.width = Math.max(1, Math.round(e.width * Dt)), Rt.height = Math.max(1, Math.round(e.height * Dt));
4283
+ const mt = Rt.getContext("2d");
4284
+ if (!mt)
4371
4285
  return;
4372
- wt.fillStyle = E, wt.fillRect(0, 0, dt.width, dt.height);
4373
- const yt = [];
4374
- for (let ot = 0; ot < ft; ot += 1)
4375
- for (let ct = 0; ct < bt; ct += 1) {
4376
- const ht = ct * e.tileSize * O, H = ot * e.tileSize * O, It = Math.min((ct + 1) * e.tileSize, lt) * O, Pt = Math.min((ot + 1) * e.tileSize, $) * O;
4377
- yt.push({
4378
- url: Xi(e, v, ct, ot),
4379
- bounds: [ht, H, It, Pt]
4286
+ mt.fillStyle = E, mt.fillRect(0, 0, Rt.width, Rt.height);
4287
+ const At = [];
4288
+ for (let nt = 0; nt < ht; nt += 1)
4289
+ for (let ct = 0; ct < j; ct += 1) {
4290
+ const gt = ct * e.tileSize * U, ut = nt * e.tileSize * U, it = Math.min((ct + 1) * e.tileSize, lt) * U, vt = Math.min((nt + 1) * e.tileSize, dt) * U;
4291
+ At.push({
4292
+ url: Xi(e, C, ct, nt),
4293
+ bounds: [gt, ut, it, vt]
4380
4294
  });
4381
4295
  }
4382
4296
  return Promise.allSettled(
4383
- yt.map(async (ot) => {
4384
- const ct = Wa(ot.url, n), ht = await fetch(ot.url, {
4297
+ At.map(async (nt) => {
4298
+ const ct = Wa(nt.url, n), gt = await fetch(nt.url, {
4385
4299
  headers: ct ? { Authorization: n } : void 0
4386
4300
  });
4387
- if (!ht.ok)
4388
- throw new Error(`HTTP ${ht.status}`);
4389
- const H = await createImageBitmap(await ht.blob());
4390
- return { tile: ot, bitmap: H };
4301
+ if (!gt.ok)
4302
+ throw new Error(`HTTP ${gt.status}`);
4303
+ const ut = await createImageBitmap(await gt.blob());
4304
+ return { tile: nt, bitmap: ut };
4391
4305
  })
4392
- ).then((ot) => {
4306
+ ).then((nt) => {
4393
4307
  if (L) {
4394
- for (const H of ot)
4395
- H.status === "fulfilled" && H.value.bitmap.close();
4308
+ for (const ut of nt)
4309
+ ut.status === "fulfilled" && ut.value.bitmap.close();
4396
4310
  return;
4397
4311
  }
4398
- const ct = dt.width / Math.max(1, e.width), ht = dt.height / Math.max(1, e.height);
4399
- for (const H of ot) {
4400
- if (H.status !== "fulfilled") continue;
4312
+ const ct = Rt.width / Math.max(1, e.width), gt = Rt.height / Math.max(1, e.height);
4313
+ for (const ut of nt) {
4314
+ if (ut.status !== "fulfilled") continue;
4401
4315
  const {
4402
- tile: { bounds: It },
4403
- bitmap: Pt
4404
- } = H.value, St = It[0] * ct, G = It[1] * ht, Q = Math.max(1, (It[2] - It[0]) * ct), mt = Math.max(1, (It[3] - It[1]) * ht);
4405
- wt.drawImage(Pt, St, G, Q, mt), Pt.close();
4316
+ tile: { bounds: it },
4317
+ bitmap: vt
4318
+ } = ut.value, Et = it[0] * ct, G = it[1] * gt, K = Math.max(1, (it[2] - it[0]) * ct), St = Math.max(1, (it[3] - it[1]) * gt);
4319
+ mt.drawImage(vt, Et, G, K, St), vt.close();
4406
4320
  }
4407
- l.current = dt, N();
4321
+ l.current = Rt, F();
4408
4322
  }), () => {
4409
4323
  L = !0;
4410
4324
  };
4411
- }, [e, n, E, d, m, Y, x, N]), U(() => {
4412
- N();
4413
- }, [N]), U(() => {
4325
+ }, [e, n, E, d, m, Y, x, F]), z(() => {
4326
+ F();
4327
+ }, [F]), z(() => {
4414
4328
  if (t.current) return;
4415
4329
  let L = 0;
4416
- const v = () => {
4330
+ const C = () => {
4417
4331
  if (t.current) {
4418
- N();
4332
+ F();
4419
4333
  return;
4420
4334
  }
4421
- L = requestAnimationFrame(v);
4335
+ L = requestAnimationFrame(C);
4422
4336
  };
4423
- return L = requestAnimationFrame(v), () => cancelAnimationFrame(L);
4424
- }, [t, N]), U(() => sn(() => N()), [N]), U(() => {
4337
+ return L = requestAnimationFrame(C), () => cancelAnimationFrame(L);
4338
+ }, [t, F]), z(() => sn(() => F()), [F]), z(() => {
4425
4339
  if (i)
4426
- return i.current = N, () => {
4427
- i.current === N && (i.current = null);
4340
+ return i.current = F, () => {
4341
+ i.current === F && (i.current = null);
4428
4342
  };
4429
- }, [i, N]), U(
4343
+ }, [i, F]), z(
4430
4344
  () => () => {
4431
4345
  f.current = { active: !1, pointerId: null }, u.current !== null && (cancelAnimationFrame(u.current), u.current = null), h.current = !1;
4432
4346
  },
@@ -4442,7 +4356,7 @@ function uu({ source: e, projectorRef: t, authToken: n = "", options: r, invalid
4442
4356
  display: "block",
4443
4357
  borderRadius: "inherit"
4444
4358
  },
4445
- onPointerDown: et,
4359
+ onPointerDown: tt,
4446
4360
  onPointerMove: _t,
4447
4361
  onPointerUp: Ct,
4448
4362
  onPointerCancel: Ct,
@@ -4454,16 +4368,16 @@ function uu({ source: e, projectorRef: t, authToken: n = "", options: r, invalid
4454
4368
  }
4455
4369
  }
4456
4370
  ),
4457
- C && /* @__PURE__ */ Qt(
4371
+ T && /* @__PURE__ */ Qt(
4458
4372
  "button",
4459
4373
  {
4460
4374
  type: "button",
4461
4375
  "aria-label": "Hide overview map",
4462
4376
  onClick: (L) => {
4463
- L.stopPropagation(), C();
4377
+ L.stopPropagation(), T();
4464
4378
  },
4465
- style: I ? { ...I } : { ...Za },
4466
- children: F ?? "×"
4379
+ style: v ? { ...v } : { ...Za },
4380
+ children: O ?? "×"
4467
4381
  }
4468
4382
  )
4469
4383
  ] });
@@ -4491,7 +4405,7 @@ function fu({ regions: e, strokeStyle: t }) {
4491
4405
  },
4492
4406
  []
4493
4407
  ), f = q({ prepared: l, resolvedStrokeStyle: a, worldToScreenPoints: c });
4494
- return f.current = { prepared: l, resolvedStrokeStyle: a, worldToScreenPoints: c }, U(() => (r(Xr, 20, (h) => {
4408
+ return f.current = { prepared: l, resolvedStrokeStyle: a, worldToScreenPoints: c }, z(() => (r(Xr, 20, (h) => {
4495
4409
  const { prepared: d, resolvedStrokeStyle: m, worldToScreenPoints: g } = f.current;
4496
4410
  for (const y of d)
4497
4411
  for (const p of y.polygons) {
@@ -4502,7 +4416,7 @@ function fu({ regions: e, strokeStyle: t }) {
4502
4416
  w.length >= 4 && Wt(h, w, m, !0, !1);
4503
4417
  }
4504
4418
  }
4505
- }), () => i(Xr)), [r, i]), U(() => {
4419
+ }), () => i(Xr)), [r, i]), z(() => {
4506
4420
  o();
4507
4421
  }, [l, a, o]), null;
4508
4422
  }
@@ -4725,13 +4639,13 @@ async function nl(e, t, n) {
4725
4639
  }
4726
4640
  }
4727
4641
  async function rl(e, t, n = {}) {
4728
- const r = Et(), i = n.bridgeToDraw === !0;
4642
+ const r = Pt(), i = n.bridgeToDraw === !0;
4729
4643
  if (!e || !e.count || !e.positions || !e.paletteIndices)
4730
4644
  return {
4731
4645
  data: null,
4732
4646
  meta: {
4733
4647
  mode: "hybrid-webgpu",
4734
- durationMs: Et() - r,
4648
+ durationMs: Pt() - r,
4735
4649
  usedWebGpu: !1,
4736
4650
  candidateCount: 0,
4737
4651
  bridgedToDraw: !1
@@ -4748,7 +4662,7 @@ async function rl(e, t, n = {}) {
4748
4662
  data: w,
4749
4663
  meta: {
4750
4664
  mode: "hybrid-webgpu",
4751
- durationMs: Et() - r,
4665
+ durationMs: Pt() - r,
4752
4666
  usedWebGpu: !1,
4753
4667
  candidateCount: 0,
4754
4668
  bridgedToDraw: !1
@@ -4766,7 +4680,7 @@ async function rl(e, t, n = {}) {
4766
4680
  data: w,
4767
4681
  meta: {
4768
4682
  mode: "hybrid-webgpu",
4769
- durationMs: Et() - r,
4683
+ durationMs: Pt() - r,
4770
4684
  usedWebGpu: !1,
4771
4685
  candidateCount: 0,
4772
4686
  bridgedToDraw: !1
@@ -4789,7 +4703,7 @@ async function rl(e, t, n = {}) {
4789
4703
  data: nn(e, t),
4790
4704
  meta: {
4791
4705
  mode: "hybrid-webgpu",
4792
- durationMs: Et() - r,
4706
+ durationMs: Pt() - r,
4793
4707
  usedWebGpu: !1,
4794
4708
  candidateCount: s,
4795
4709
  bridgedToDraw: !1
@@ -4816,7 +4730,7 @@ async function rl(e, t, n = {}) {
4816
4730
  data: P,
4817
4731
  meta: {
4818
4732
  mode: "hybrid-webgpu",
4819
- durationMs: Et() - r,
4733
+ durationMs: Pt() - r,
4820
4734
  usedWebGpu: !0,
4821
4735
  candidateCount: 0,
4822
4736
  bridgedToDraw: !0
@@ -4832,7 +4746,7 @@ async function rl(e, t, n = {}) {
4832
4746
  data: w,
4833
4747
  meta: {
4834
4748
  mode: "hybrid-webgpu",
4835
- durationMs: Et() - r,
4749
+ durationMs: Pt() - r,
4836
4750
  usedWebGpu: !0,
4837
4751
  candidateCount: 0,
4838
4752
  bridgedToDraw: !1
@@ -4843,8 +4757,8 @@ async function rl(e, t, n = {}) {
4843
4757
  const w = new Uint32Array(h);
4844
4758
  let P = 0;
4845
4759
  for (let B = 0; B < h; B += 1) {
4846
- const k = d[B] ?? 0, Y = e.positions[k * 2], M = e.positions[k * 2 + 1];
4847
- Re(Y, M, o) && (w[P] = k, P += 1);
4760
+ const N = d[B] ?? 0, Y = e.positions[N * 2], M = e.positions[N * 2 + 1];
4761
+ Re(Y, M, o) && (w[P] = N, P += 1);
4848
4762
  }
4849
4763
  const R = {
4850
4764
  count: s,
@@ -4856,7 +4770,7 @@ async function rl(e, t, n = {}) {
4856
4770
  data: R,
4857
4771
  meta: {
4858
4772
  mode: "hybrid-webgpu",
4859
- durationMs: Et() - r,
4773
+ durationMs: Pt() - r,
4860
4774
  usedWebGpu: !0,
4861
4775
  candidateCount: h,
4862
4776
  bridgedToDraw: !0
@@ -4878,7 +4792,7 @@ async function rl(e, t, n = {}) {
4878
4792
  data: E,
4879
4793
  meta: {
4880
4794
  mode: "hybrid-webgpu",
4881
- durationMs: Et() - r,
4795
+ durationMs: Pt() - r,
4882
4796
  usedWebGpu: !0,
4883
4797
  candidateCount: h,
4884
4798
  bridgedToDraw: !1
@@ -4956,7 +4870,7 @@ const Me = new Gi(
4956
4870
  indices: c,
4957
4871
  meta: {
4958
4872
  mode: "worker",
4959
- durationMs: Number.isFinite(e.durationMs) ? e.durationMs : Et() - t.startMs
4873
+ durationMs: Number.isFinite(e.durationMs) ? e.durationMs : Pt() - t.startMs
4960
4874
  }
4961
4875
  });
4962
4876
  return;
@@ -4974,7 +4888,7 @@ const Me = new Gi(
4974
4888
  data: a,
4975
4889
  meta: {
4976
4890
  mode: "worker",
4977
- durationMs: Number.isFinite(e.durationMs) ? e.durationMs : Et() - t.startMs
4891
+ durationMs: Number.isFinite(e.durationMs) ? e.durationMs : Pt() - t.startMs
4978
4892
  }
4979
4893
  });
4980
4894
  },
@@ -4994,7 +4908,7 @@ async function il(e, t) {
4994
4908
  };
4995
4909
  const n = ce(e), r = e.positions.slice(0, n * 2), i = e.paletteIndices.slice(0, n), o = e.fillModes instanceof Uint8Array && e.fillModes.length >= n ? e.fillModes.slice(0, n) : null, s = e.ids instanceof Uint32Array && e.ids.length >= n ? e.ids.slice(0, n) : null;
4996
4910
  return new Promise((a, l) => {
4997
- const c = Et(), f = Me.beginRequest({
4911
+ const c = Pt(), f = Me.beginRequest({
4998
4912
  kind: "data",
4999
4913
  resolve: a,
5000
4914
  reject: l,
@@ -5003,7 +4917,7 @@ async function il(e, t) {
5003
4917
  if (!f) {
5004
4918
  a({
5005
4919
  data: nn(e, t),
5006
- meta: { mode: "sync", durationMs: Et() - c }
4920
+ meta: { mode: "sync", durationMs: Pt() - c }
5007
4921
  });
5008
4922
  return;
5009
4923
  }
@@ -5034,7 +4948,7 @@ async function mu(e, t) {
5034
4948
  };
5035
4949
  const n = ce(e), r = e.positions.slice(0, n * 2);
5036
4950
  return new Promise((i, o) => {
5037
- const s = Et(), a = Me.beginRequest({
4951
+ const s = Pt(), a = Me.beginRequest({
5038
4952
  kind: "index",
5039
4953
  resolve: i,
5040
4954
  reject: o,
@@ -5043,7 +4957,7 @@ async function mu(e, t) {
5043
4957
  if (!a) {
5044
4958
  i({
5045
4959
  indices: Ha(e, t),
5046
- meta: { mode: "sync", durationMs: Et() - s }
4960
+ meta: { mode: "sync", durationMs: Pt() - s }
5047
4961
  });
5048
4962
  return;
5049
4963
  }
@@ -5072,7 +4986,7 @@ function sl(e, t, n, r, i) {
5072
4986
  () => r.map((c) => Ce(c.coordinates)).filter((c) => c != null),
5073
4987
  [r]
5074
4988
  );
5075
- return U(() => {
4989
+ return z(() => {
5076
4990
  const c = ++o.current;
5077
4991
  let f = !1;
5078
4992
  if (!e)
@@ -5181,14 +5095,14 @@ function hl(e) {
5181
5095
  const s = ul(e.sourceWidth, e.sourceHeight, o), a = 1 / s, l = new Int32Array(o), c = new Int32Array(o);
5182
5096
  let f = 0;
5183
5097
  if (i)
5184
- for (let I = 0; I < o; I += 1) {
5185
- const W = i[I], j = e.positions[W * 2], N = e.positions[W * 2 + 1];
5186
- !Number.isFinite(j) || !Number.isFinite(N) || (l[f] = Math.floor(j * a), c[f] = Math.floor(N * a), f += 1);
5098
+ for (let v = 0; v < o; v += 1) {
5099
+ const W = i[v], J = e.positions[W * 2], F = e.positions[W * 2 + 1];
5100
+ !Number.isFinite(J) || !Number.isFinite(F) || (l[f] = Math.floor(J * a), c[f] = Math.floor(F * a), f += 1);
5187
5101
  }
5188
5102
  else
5189
- for (let I = 0; I < r; I += 1) {
5190
- const W = e.positions[I * 2], j = e.positions[I * 2 + 1];
5191
- !Number.isFinite(W) || !Number.isFinite(j) || (l[f] = Math.floor(W * a), c[f] = Math.floor(j * a), f += 1);
5103
+ for (let v = 0; v < r; v += 1) {
5104
+ const W = e.positions[v * 2], J = e.positions[v * 2 + 1];
5105
+ !Number.isFinite(W) || !Number.isFinite(J) || (l[f] = Math.floor(W * a), c[f] = Math.floor(J * a), f += 1);
5192
5106
  }
5193
5107
  if (f === 0)
5194
5108
  return null;
@@ -5200,77 +5114,77 @@ function hl(e) {
5200
5114
  m.fill(2147483647);
5201
5115
  let y = 0;
5202
5116
  const p = new Int32Array(f);
5203
- for (let I = 0; I < f; I += 1) {
5204
- const W = l[I], j = c[I];
5205
- let N = be(W, j, d);
5117
+ for (let v = 0; v < f; v += 1) {
5118
+ const W = l[v], J = c[v];
5119
+ let F = be(W, J, d);
5206
5120
  for (; ; ) {
5207
- const ut = m[N * 2];
5208
- if (ut === 2147483647) {
5209
- if (m[N * 2] = W, m[N * 2 + 1] = j, g[N] = 1, p[I] = N, y += 1, y * 4 > h * 3) {
5210
- const pt = h;
5121
+ const xt = m[F * 2];
5122
+ if (xt === 2147483647) {
5123
+ if (m[F * 2] = W, m[F * 2 + 1] = J, g[F] = 1, p[v] = F, y += 1, y * 4 > h * 3) {
5124
+ const ft = h;
5211
5125
  h <<= 1, d = h - 1;
5212
- const et = new Int32Array(h * 2), _t = new Int32Array(h);
5213
- et.fill(2147483647);
5214
- for (let Ct = 0; Ct < pt; Ct += 1) {
5126
+ const tt = new Int32Array(h * 2), _t = new Int32Array(h);
5127
+ tt.fill(2147483647);
5128
+ for (let Ct = 0; Ct < ft; Ct += 1) {
5215
5129
  if (m[Ct * 2] === 2147483647) continue;
5216
- const L = m[Ct * 2], v = m[Ct * 2 + 1];
5217
- let O = be(L, v, d);
5218
- for (; et[O * 2] !== 2147483647; ) O = O + 1 & d;
5219
- et[O * 2] = L, et[O * 2 + 1] = v, _t[O] = g[Ct];
5130
+ const L = m[Ct * 2], C = m[Ct * 2 + 1];
5131
+ let U = be(L, C, d);
5132
+ for (; tt[U * 2] !== 2147483647; ) U = U + 1 & d;
5133
+ tt[U * 2] = L, tt[U * 2 + 1] = C, _t[U] = g[Ct];
5220
5134
  }
5221
- for (m = et, g = _t, N = be(W, j, d); m[N * 2] !== W || m[N * 2 + 1] !== j; )
5222
- N = N + 1 & d;
5223
- p[I] = N;
5135
+ for (m = tt, g = _t, F = be(W, J, d); m[F * 2] !== W || m[F * 2 + 1] !== J; )
5136
+ F = F + 1 & d;
5137
+ p[v] = F;
5224
5138
  }
5225
5139
  break;
5226
5140
  }
5227
- if (ut === W && m[N * 2 + 1] === j) {
5228
- g[N] += 1, p[I] = N;
5141
+ if (xt === W && m[F * 2 + 1] === J) {
5142
+ g[F] += 1, p[v] = F;
5229
5143
  break;
5230
5144
  }
5231
- N = N + 1 & d;
5145
+ F = F + 1 & d;
5232
5146
  }
5233
5147
  }
5234
5148
  const x = new Int32Array(y * 2), E = new Uint32Array(y), w = new Uint32Array(y), P = new Int32Array(h);
5235
5149
  P.fill(Ze);
5236
5150
  let R = 0, B = 0;
5237
- for (let I = 0; I < h; I += 1)
5238
- m[I * 2] !== 2147483647 && (x[R * 2] = m[I * 2], x[R * 2 + 1] = m[I * 2 + 1], E[R] = B, w[R] = g[I], P[I] = R, B += g[I], R += 1);
5239
- const k = new Uint32Array(f), Y = new Uint32Array(y);
5151
+ for (let v = 0; v < h; v += 1)
5152
+ m[v * 2] !== 2147483647 && (x[R * 2] = m[v * 2], x[R * 2 + 1] = m[v * 2 + 1], E[R] = B, w[R] = g[v], P[v] = R, B += g[v], R += 1);
5153
+ const N = new Uint32Array(f), Y = new Uint32Array(y);
5240
5154
  if (Y.set(E), i)
5241
- for (let I = 0; I < f; I += 1) {
5242
- const W = P[p[I]];
5243
- k[Y[W]] = i[I], Y[W] += 1;
5155
+ for (let v = 0; v < f; v += 1) {
5156
+ const W = P[p[v]];
5157
+ N[Y[W]] = i[v], Y[W] += 1;
5244
5158
  }
5245
5159
  else {
5246
- let I = 0;
5160
+ let v = 0;
5247
5161
  for (let W = 0; W < r; W += 1) {
5248
- const j = e.positions[W * 2], N = e.positions[W * 2 + 1];
5249
- if (!Number.isFinite(j) || !Number.isFinite(N)) continue;
5250
- const ut = P[p[I]];
5251
- k[Y[ut]] = W, Y[ut] += 1, I += 1;
5162
+ const J = e.positions[W * 2], F = e.positions[W * 2 + 1];
5163
+ if (!Number.isFinite(J) || !Number.isFinite(F)) continue;
5164
+ const xt = P[p[v]];
5165
+ N[Y[xt]] = W, Y[xt] += 1, v += 1;
5252
5166
  }
5253
5167
  }
5254
5168
  let M = 1;
5255
5169
  for (; M < y * 2; ) M <<= 1;
5256
- const C = M - 1, F = new Int32Array(M);
5257
- F.fill(Ze);
5258
- for (let I = 0; I < y; I += 1) {
5259
- const W = x[I * 2], j = x[I * 2 + 1];
5260
- let N = be(W, j, C);
5261
- for (; F[N] !== Ze; ) N = N + 1 & C;
5262
- F[N] = I;
5170
+ const T = M - 1, O = new Int32Array(M);
5171
+ O.fill(Ze);
5172
+ for (let v = 0; v < y; v += 1) {
5173
+ const W = x[v * 2], J = x[v * 2 + 1];
5174
+ let F = be(W, J, T);
5175
+ for (; O[F] !== Ze; ) F = F + 1 & T;
5176
+ O[F] = v;
5263
5177
  }
5264
5178
  return {
5265
5179
  cellSize: s,
5266
5180
  safeCount: r,
5267
5181
  cellCount: y,
5268
5182
  hashCapacity: M,
5269
- hashTable: F,
5183
+ hashTable: O,
5270
5184
  cellKeys: x,
5271
5185
  cellOffsets: E,
5272
5186
  cellLengths: w,
5273
- pointIndices: k
5187
+ pointIndices: N
5274
5188
  };
5275
5189
  }
5276
5190
  function dl(e, t, n) {
@@ -5383,7 +5297,7 @@ async function pl(e, t) {
5383
5297
  const yl = 0.65, xl = 4;
5384
5298
  function bl(e, t, n, r, i, o, s, a) {
5385
5299
  const l = !!(n || r || i), [c, f] = ae(null), u = q(null), h = q(null);
5386
- U(() => {
5300
+ z(() => {
5387
5301
  if (!l || !e) {
5388
5302
  f(null);
5389
5303
  return;
@@ -5403,24 +5317,24 @@ function bl(e, t, n, r, i, o, s, a) {
5403
5317
  if (!Number.isFinite(x) || !Number.isFinite(E)) return null;
5404
5318
  const w = Math.max(1e-6, p.getViewState().zoom), P = p.getPointSize(a), B = Math.max(xl, P * yl) / w;
5405
5319
  if (!Number.isFinite(B) || B <= 0) return null;
5406
- const { cellSize: k, cellOffsets: Y, cellLengths: M, pointIndices: C, positions: F, safeCount: I } = c, W = Math.floor(x / k), j = Math.floor(E / k), N = Math.max(1, Math.ceil(B / k)), ut = B * B;
5407
- let pt = -1, et = ut, _t = 0, Ct = 0;
5408
- for (let v = W - N; v <= W + N; v += 1)
5409
- for (let O = j - N; O <= j + N; O += 1) {
5410
- const lt = dl(c, v, O);
5320
+ const { cellSize: N, cellOffsets: Y, cellLengths: M, pointIndices: T, positions: O, safeCount: v } = c, W = Math.floor(x / N), J = Math.floor(E / N), F = Math.max(1, Math.ceil(B / N)), xt = B * B;
5321
+ let ft = -1, tt = xt, _t = 0, Ct = 0;
5322
+ for (let C = W - F; C <= W + F; C += 1)
5323
+ for (let U = J - F; U <= J + F; U += 1) {
5324
+ const lt = dl(c, C, U);
5411
5325
  if (lt < 0) continue;
5412
- const $ = Y[lt], bt = $ + M[lt];
5413
- for (let ft = $; ft < bt; ft += 1) {
5414
- const it = C[ft];
5415
- if (it >= I) continue;
5416
- const Nt = F[it * 2], dt = F[it * 2 + 1], wt = Nt - x, yt = dt - E, ot = wt * wt + yt * yt;
5417
- ot > et || (et = ot, pt = it, _t = Nt, Ct = dt);
5326
+ const dt = Y[lt], j = dt + M[lt];
5327
+ for (let ht = dt; ht < j; ht += 1) {
5328
+ const rt = T[ht];
5329
+ if (rt >= v) continue;
5330
+ const Dt = O[rt * 2], Rt = O[rt * 2 + 1], mt = Dt - x, At = Rt - E, nt = mt * mt + At * At;
5331
+ nt > tt || (tt = nt, ft = rt, _t = Dt, Ct = Rt);
5418
5332
  }
5419
5333
  }
5420
- if (pt < 0) return null;
5421
- const L = c.ids ? Number(c.ids[pt]) : null;
5334
+ if (ft < 0) return null;
5335
+ const L = c.ids ? Number(c.ids[ft]) : null;
5422
5336
  return {
5423
- index: pt,
5337
+ index: ft,
5424
5338
  id: L,
5425
5339
  coordinate: [x, E],
5426
5340
  pointCoordinate: [_t, Ct]
@@ -5450,12 +5364,12 @@ function bl(e, t, n, r, i, o, s, a) {
5450
5364
  },
5451
5365
  [r, d]
5452
5366
  );
5453
- return U(() => {
5367
+ return z(() => {
5454
5368
  if (i)
5455
5369
  return i.current = d, () => {
5456
5370
  i.current === d && (i.current = null);
5457
5371
  };
5458
- }, [i, d]), U(() => {
5372
+ }, [i, d]), z(() => {
5459
5373
  const y = u.current;
5460
5374
  y !== null && (c && y < c.safeCount || (u.current = null, h.current = null, n?.({
5461
5375
  index: null,
@@ -5463,7 +5377,7 @@ function bl(e, t, n, r, i, o, s, a) {
5463
5377
  coordinate: null,
5464
5378
  pointCoordinate: null
5465
5379
  })));
5466
- }, [c, n]), U(() => {
5380
+ }, [c, n]), z(() => {
5467
5381
  }, [o, n]), { getCellByCoordinates: d, emitPointHover: m, emitPointClick: g };
5468
5382
  }
5469
5383
  let wl = 0;
@@ -5485,45 +5399,45 @@ const pu = oo(function({
5485
5399
  onClick: g,
5486
5400
  dashed: y
5487
5401
  }, p) {
5488
- const { rendererRef: x, rendererSerial: E, source: w } = pe(), P = q(null), R = q(`__point_layer__${wl++}`), k = sl(f, h, t, u ?? Sl, d), { getCellByCoordinates: Y } = bl(k, w, m, g, P, "cursor", x, R.current);
5489
- return so(p, () => ({ queryAt: Y }), [Y]), U(() => {
5402
+ const { rendererRef: x, rendererSerial: E, source: w } = pe(), P = q(null), R = q(`__point_layer__${wl++}`), N = sl(f, h, t, u ?? Sl, d), { getCellByCoordinates: Y } = bl(N, w, m, g, P, "cursor", x, R.current);
5403
+ return so(p, () => ({ queryAt: Y }), [Y]), z(() => {
5490
5404
  const M = x.current;
5491
5405
  if (!M) return;
5492
- const C = R.current;
5493
- return M.registerPointLayer(C), () => {
5494
- M.unregisterPointLayer(C);
5406
+ const T = R.current;
5407
+ return M.registerPointLayer(T), () => {
5408
+ M.unregisterPointLayer(T);
5495
5409
  };
5496
- }, [x, E]), U(() => {
5410
+ }, [x, E]), z(() => {
5497
5411
  const M = x.current;
5498
5412
  M && M.setPointPalette(n, R.current);
5499
- }, [E, n, x]), U(() => {
5413
+ }, [E, n, x]), z(() => {
5500
5414
  const M = x.current;
5501
5415
  M && M.setPointLineDash(y, R.current);
5502
- }, [E, y, x]), U(() => {
5416
+ }, [E, y, x]), z(() => {
5503
5417
  const M = x.current;
5504
5418
  M && M.setPointSizeByZoom(r, R.current);
5505
- }, [E, r, x]), U(() => {
5419
+ }, [E, r, x]), z(() => {
5506
5420
  const M = x.current;
5507
5421
  M && M.setPointSizeByMagnification(i, R.current);
5508
- }, [E, i, x]), U(() => {
5422
+ }, [E, i, x]), z(() => {
5509
5423
  const M = x.current;
5510
5424
  M && M.setPointWeightByMagnification(o, R.current);
5511
- }, [E, o, x]), U(() => {
5425
+ }, [E, o, x]), z(() => {
5512
5426
  const M = x.current;
5513
5427
  !M || s === void 0 || M.setPointOpacity(s, R.current);
5514
- }, [E, s, x]), U(() => {
5428
+ }, [E, s, x]), z(() => {
5515
5429
  const M = x.current;
5516
5430
  !M || a === void 0 || M.setPointStrokeScale(a, R.current);
5517
- }, [E, a, x]), U(() => {
5431
+ }, [E, a, x]), z(() => {
5518
5432
  const M = x.current;
5519
5433
  !M || l === void 0 || M.setPointInnerFillOpacity(l, R.current);
5520
- }, [E, l, x]), U(() => {
5434
+ }, [E, l, x]), z(() => {
5521
5435
  const M = x.current;
5522
5436
  M && M.setPointInnerFillColor(c, R.current);
5523
- }, [E, c, x]), U(() => {
5437
+ }, [E, c, x]), z(() => {
5524
5438
  const M = x.current;
5525
- M && M.setPointData(k, R.current);
5526
- }, [E, k, x]), null;
5439
+ M && M.setPointData(N, R.current);
5440
+ }, [E, N, x]), null;
5527
5441
  }), Sl = [], Al = 180, Vr = 20;
5528
5442
  function El(e) {
5529
5443
  const t = _(e, 0, 1);
@@ -5572,7 +5486,7 @@ function Rl(e, t, n) {
5572
5486
  },
5573
5487
  [e, c]
5574
5488
  );
5575
- return U(() => () => {
5489
+ return z(() => () => {
5576
5490
  l();
5577
5491
  }, [l]), {
5578
5492
  regionLabelAutoLiftOffsetPx: r,
@@ -5711,278 +5625,278 @@ function yu({
5711
5625
  onHover: m,
5712
5626
  onClick: g
5713
5627
  }) {
5714
- const { rendererRef: y, rendererSerial: p, canvasRef: x, containerRef: E, registerDrawCallback: w, unregisterDrawCallback: P, requestOverlayRedraw: R, drawInvalidateRef: B, registerViewStateListener: k, screenToWorld: Y, worldToScreen: M, isInteractionLocked: C } = pe(), F = e ?? qr, I = t ?? Il, W = at(() => F.length > 0 ? F : I.length === 0 ? qr : I.map((G, Q) => ({ id: Q, coordinates: G })), [F, I]), [j, N] = ae(() => f ?? null), [ut, pt] = ae(() => u ?? null), et = f !== void 0, _t = u !== void 0, Ct = et ? f ?? null : j, L = _t ? u ?? null : ut, v = q(f ?? null), O = q(null), lt = q(null);
5715
- if (O.current === null || lt.current === null) {
5628
+ const { rendererRef: y, rendererSerial: p, canvasRef: x, containerRef: E, registerDrawCallback: w, unregisterDrawCallback: P, requestOverlayRedraw: R, drawInvalidateRef: B, registerViewStateListener: N, screenToWorld: Y, worldToScreen: M, isInteractionLocked: T } = pe(), O = e ?? qr, v = t ?? Il, W = at(() => O.length > 0 ? O : v.length === 0 ? qr : v.map((G, K) => ({ id: K, coordinates: G })), [O, v]), [J, F] = ae(() => f ?? null), [xt, ft] = ae(() => u ?? null), tt = f !== void 0, _t = u !== void 0, Ct = tt ? f ?? null : J, L = _t ? u ?? null : xt, C = q(f ?? null), U = q(null), lt = q(null);
5629
+ if (U.current === null || lt.current === null) {
5716
5630
  const G = _l++;
5717
- O.current = `__region_layer__${G}`, lt.current = `__region_label__${G}`;
5631
+ U.current = `__region_layer__${G}`, lt.current = `__region_label__${G}`;
5718
5632
  }
5719
- U(() => {
5720
- _t && pt(u ?? null);
5721
- }, [_t, u]), U(() => {
5722
- if (!et) return;
5633
+ z(() => {
5634
+ _t && ft(u ?? null);
5635
+ }, [_t, u]), z(() => {
5636
+ if (!tt) return;
5723
5637
  const G = f ?? null;
5724
- v.current = G, N(G);
5725
- }, [et, f]);
5726
- const $ = V(
5638
+ C.current = G, F(G);
5639
+ }, [tt, f]);
5640
+ const dt = V(
5727
5641
  (G) => {
5728
- String(L) !== String(G) && (_t || pt(G), d?.(G));
5642
+ String(L) !== String(G) && (_t || ft(G), d?.(G));
5729
5643
  },
5730
5644
  [L, _t, d]
5731
- ), { regionLabelAutoLiftOffsetPx: bt, syncRegionLabelAutoLiftTarget: ft } = Rl(l, y, B), it = at(() => zn(n), [n]), Nt = at(() => Jt(it, r), [it, r]), dt = at(() => Jt(it, i), [it, i]), { staticLabelStyle: wt, labelStyleResolver: yt } = at(() => typeof s == "function" ? { staticLabelStyle: void 0, labelStyleResolver: s } : { staticLabelStyle: s, labelStyleResolver: void 0 }, [s]), ot = at(() => kn(wt), [wt]), ct = at(() => {
5645
+ ), { regionLabelAutoLiftOffsetPx: j, syncRegionLabelAutoLiftTarget: ht } = Rl(l, y, B), rt = at(() => zn(n), [n]), Dt = at(() => Jt(rt, r), [rt, r]), Rt = at(() => Jt(rt, i), [rt, i]), { staticLabelStyle: mt, labelStyleResolver: At } = at(() => typeof s == "function" ? { staticLabelStyle: void 0, labelStyleResolver: s } : { staticLabelStyle: s, labelStyleResolver: void 0 }, [s]), nt = at(() => kn(mt), [mt]), ct = at(() => {
5732
5646
  const G = [];
5733
- for (let Q = 0; Q < W.length; Q += 1) {
5734
- const mt = W[Q], rt = tn(mt.coordinates);
5735
- rt.length !== 0 && G.push({ region: mt, regionIndex: Q, regionKey: mt.id ?? Q, polygons: rt });
5647
+ for (let K = 0; K < W.length; K += 1) {
5648
+ const St = W[K], et = tn(St.coordinates);
5649
+ et.length !== 0 && G.push({ region: St, regionIndex: K, regionKey: St.id ?? K, polygons: et });
5736
5650
  }
5737
5651
  return G;
5738
- }, [W]), ht = at(() => Tl(W), [W]);
5739
- U(() => {
5652
+ }, [W]), gt = at(() => Tl(W), [W]);
5653
+ z(() => {
5740
5654
  const G = y.current;
5741
5655
  if (G)
5742
- return ft(G.getViewState().zoom), k((Q) => {
5743
- ft(Q.zoom);
5656
+ return ht(G.getViewState().zoom), N((K) => {
5657
+ ht(K.zoom);
5744
5658
  });
5745
- }, [p, k, ft]), U(() => {
5746
- !(L === null ? !0 : W.some((rt, J) => String(_n(rt, J)) === String(L))) && L !== null && $(null);
5747
- const Q = v.current;
5748
- !(Q === null ? !0 : W.some((rt, J) => String(_n(rt, J)) === String(Q))) && Q !== null && (v.current = null, et || N(null), m?.({ region: null, regionId: null, regionIndex: -1, coordinate: null }));
5749
- }, [W, L, et, m, $]);
5750
- const H = V(
5659
+ }, [p, N, ht]), z(() => {
5660
+ !(L === null ? !0 : W.some((et, Q) => String(_n(et, Q)) === String(L))) && L !== null && dt(null);
5661
+ const K = C.current;
5662
+ !(K === null ? !0 : W.some((et, Q) => String(_n(et, Q)) === String(K))) && K !== null && (C.current = null, tt || F(null), m?.({ region: null, regionId: null, regionIndex: -1, coordinate: null }));
5663
+ }, [W, L, tt, m, dt]);
5664
+ const ut = V(
5751
5665
  (G) => {
5752
- const Q = y.current;
5753
- if (!Q || G.length === 0) return [];
5754
- const mt = new Array(G.length);
5755
- for (let rt = 0; rt < G.length; rt += 1) {
5756
- const J = $t(Q.worldToScreen(G[rt][0], G[rt][1]));
5757
- if (!J) return [];
5758
- mt[rt] = J;
5666
+ const K = y.current;
5667
+ if (!K || G.length === 0) return [];
5668
+ const St = new Array(G.length);
5669
+ for (let et = 0; et < G.length; et += 1) {
5670
+ const Q = $t(K.worldToScreen(G[et][0], G[et][1]));
5671
+ if (!Q) return [];
5672
+ St[et] = Q;
5759
5673
  }
5760
- return mt;
5674
+ return St;
5761
5675
  },
5762
5676
  []
5763
- ), It = q({
5677
+ ), it = q({
5764
5678
  preparedRegions: ct,
5765
5679
  hoveredRegionId: Ct,
5766
5680
  activeRegionId: L,
5767
- resolvedStrokeStyle: it,
5768
- resolvedHoverStrokeStyle: Nt,
5769
- resolvedActiveStrokeStyle: dt,
5681
+ resolvedStrokeStyle: rt,
5682
+ resolvedHoverStrokeStyle: Dt,
5683
+ resolvedActiveStrokeStyle: Rt,
5770
5684
  resolveStrokeStyleProp: o,
5771
- worldToScreenPoints: H
5685
+ worldToScreenPoints: ut
5772
5686
  });
5773
- It.current = {
5687
+ it.current = {
5774
5688
  preparedRegions: ct,
5775
5689
  hoveredRegionId: Ct,
5776
5690
  activeRegionId: L,
5777
- resolvedStrokeStyle: it,
5778
- resolvedHoverStrokeStyle: Nt,
5779
- resolvedActiveStrokeStyle: dt,
5691
+ resolvedStrokeStyle: rt,
5692
+ resolvedHoverStrokeStyle: Dt,
5693
+ resolvedActiveStrokeStyle: Rt,
5780
5694
  resolveStrokeStyleProp: o,
5781
- worldToScreenPoints: H
5782
- }, U(() => {
5783
- const G = (mt) => {
5695
+ worldToScreenPoints: ut
5696
+ }, z(() => {
5697
+ const G = (St) => {
5784
5698
  const {
5785
- preparedRegions: rt,
5786
- hoveredRegionId: J,
5699
+ preparedRegions: et,
5700
+ hoveredRegionId: Q,
5787
5701
  activeRegionId: Mt,
5788
5702
  resolvedStrokeStyle: X,
5789
- resolvedHoverStrokeStyle: Ft,
5703
+ resolvedHoverStrokeStyle: Tt,
5790
5704
  resolvedActiveStrokeStyle: Bt,
5791
- resolveStrokeStyleProp: z,
5792
- worldToScreenPoints: K
5793
- } = It.current;
5794
- for (const tt of rt) {
5795
- const { region: nt, polygons: Rt, regionIndex: At, regionKey: vt } = tt, Ut = Je(Mt, vt) ? "active" : Je(J, vt) ? "hover" : "default";
5796
- let b = Ut === "active" ? Bt : Ut === "hover" ? Ft : X;
5797
- if (z) {
5798
- const T = z({ region: nt, regionId: vt, regionIndex: At, state: Ut });
5799
- b = Jt(b, T || void 0);
5705
+ resolveStrokeStyleProp: zt,
5706
+ worldToScreenPoints: k
5707
+ } = it.current;
5708
+ for (const H of et) {
5709
+ const { region: $, polygons: ot, regionIndex: bt, regionKey: pt } = H, Ut = Je(Mt, pt) ? "active" : Je(Q, pt) ? "hover" : "default";
5710
+ let b = Ut === "active" ? Bt : Ut === "hover" ? Tt : X;
5711
+ if (zt) {
5712
+ const I = zt({ region: $, regionId: pt, regionIndex: bt, state: Ut });
5713
+ b = Jt(b, I || void 0);
5800
5714
  }
5801
5715
  const A = Ut === "default" ? null : Fl(b);
5802
- for (const T of Rt) {
5803
- const D = K(T.outer);
5804
- D.length >= 4 && (A && Wt(mt, D, A, !0, !1), Wt(mt, D, b, !0, !1));
5805
- for (const Z of T.holes) {
5806
- const xt = K(Z);
5807
- xt.length >= 4 && (A && Wt(mt, xt, A, !0, !1), Wt(mt, xt, b, !0, !1));
5716
+ for (const I of ot) {
5717
+ const D = k(I.outer);
5718
+ D.length >= 4 && (A && Wt(St, D, A, !0, !1), Wt(St, D, b, !0, !1));
5719
+ for (const Z of I.holes) {
5720
+ const wt = k(Z);
5721
+ wt.length >= 4 && (A && Wt(St, wt, A, !0, !1), Wt(St, wt, b, !0, !1));
5808
5722
  }
5809
5723
  }
5810
5724
  }
5811
- }, Q = O.current;
5812
- if (Q)
5813
- return w(Q, 10, G), () => P(Q);
5725
+ }, K = U.current;
5726
+ if (K)
5727
+ return w(K, 10, G), () => P(K);
5814
5728
  }, [w, P]);
5815
- const Pt = q({
5729
+ const vt = q({
5816
5730
  preparedRegions: ct,
5817
- resolvedLabelStyle: ot,
5818
- labelStyleResolver: yt,
5731
+ resolvedLabelStyle: nt,
5732
+ labelStyleResolver: At,
5819
5733
  labelAnchor: a,
5820
5734
  autoLiftLabelAtMaxZoom: l,
5821
5735
  clampLabelToViewport: c,
5822
- regionLabelAutoLiftOffsetPx: bt,
5736
+ regionLabelAutoLiftOffsetPx: j,
5823
5737
  rendererRef: y
5824
5738
  });
5825
- Pt.current = {
5739
+ vt.current = {
5826
5740
  preparedRegions: ct,
5827
- resolvedLabelStyle: ot,
5828
- labelStyleResolver: yt,
5741
+ resolvedLabelStyle: nt,
5742
+ labelStyleResolver: At,
5829
5743
  labelAnchor: a,
5830
5744
  autoLiftLabelAtMaxZoom: l,
5831
5745
  clampLabelToViewport: c,
5832
- regionLabelAutoLiftOffsetPx: bt,
5746
+ regionLabelAutoLiftOffsetPx: j,
5833
5747
  rendererRef: y
5834
- }, U(() => {
5835
- const G = (mt, rt, J) => {
5748
+ }, z(() => {
5749
+ const G = (St, et, Q) => {
5836
5750
  const {
5837
5751
  preparedRegions: Mt,
5838
5752
  resolvedLabelStyle: X,
5839
- labelStyleResolver: Ft,
5753
+ labelStyleResolver: Tt,
5840
5754
  labelAnchor: Bt,
5841
- autoLiftLabelAtMaxZoom: z,
5842
- clampLabelToViewport: K,
5843
- regionLabelAutoLiftOffsetPx: tt,
5844
- rendererRef: nt
5845
- } = Pt.current;
5755
+ autoLiftLabelAtMaxZoom: zt,
5756
+ clampLabelToViewport: k,
5757
+ regionLabelAutoLiftOffsetPx: H,
5758
+ rendererRef: $
5759
+ } = vt.current;
5846
5760
  if (Mt.length === 0) return;
5847
- const Rt = Math.max(1e-6, nt.current?.getViewState?.().zoom ?? 1), At = typeof tt == "number" && Number.isFinite(tt) ? Math.max(0, tt) : Wn(z, Rt, nt.current?.getZoomRange?.(), nt.current?.getRegionLabelAutoLiftCapZoom?.());
5848
- for (const vt of Mt) {
5849
- if (!vt.region.label) continue;
5761
+ const ot = Math.max(1e-6, $.current?.getViewState?.().zoom ?? 1), bt = typeof H == "number" && Number.isFinite(H) ? Math.max(0, H) : Wn(zt, ot, $.current?.getZoomRange?.(), $.current?.getRegionLabelAutoLiftCapZoom?.());
5762
+ for (const pt of Mt) {
5763
+ if (!pt.region.label) continue;
5850
5764
  const Ut = Un(
5851
- vt.polygons,
5765
+ pt.polygons,
5852
5766
  (A) => {
5853
- const T = nt.current;
5854
- if (!T) return [];
5767
+ const I = $.current;
5768
+ if (!I) return [];
5855
5769
  const D = [];
5856
5770
  for (let Z = 0; Z < A.length; Z += 1) {
5857
- const xt = $t(T.worldToScreen(A[Z][0], A[Z][1]));
5858
- if (!xt) return [];
5859
- D.push(xt);
5771
+ const wt = $t(I.worldToScreen(A[Z][0], A[Z][1]));
5772
+ if (!wt) return [];
5773
+ D.push(wt);
5860
5774
  }
5861
5775
  return D;
5862
5776
  },
5863
5777
  Bt
5864
5778
  );
5865
5779
  if (!Ut) continue;
5866
- let b = On(X, Ft?.({ region: vt.region, regionId: vt.regionKey, regionIndex: vt.regionIndex, zoom: Rt }));
5867
- At > 0 && (b = { ...b, offsetY: b.offsetY + At }), Mi(mt, vt.region.label, Ut, rt, J, b, K);
5780
+ let b = On(X, Tt?.({ region: pt.region, regionId: pt.regionKey, regionIndex: pt.regionIndex, zoom: ot }));
5781
+ bt > 0 && (b = { ...b, offsetY: b.offsetY + bt }), Mi(St, pt.region.label, Ut, et, Q, b, k);
5868
5782
  }
5869
- }, Q = lt.current;
5870
- if (Q)
5871
- return w(Q, 50, G), () => P(Q);
5872
- }, [w, P]), U(() => {
5783
+ }, K = lt.current;
5784
+ if (K)
5785
+ return w(K, 50, G), () => P(K);
5786
+ }, [w, P]), z(() => {
5873
5787
  R();
5874
- }, [ct, Ct, L, it, ot, bt, R]);
5875
- const St = q({
5876
- preparedRegionHits: ht,
5788
+ }, [ct, Ct, L, rt, nt, j, R]);
5789
+ const Et = q({
5790
+ preparedRegionHits: gt,
5877
5791
  labelAnchor: a,
5878
- resolvedLabelStyle: ot,
5879
- labelStyleResolver: yt,
5880
- regionLabelAutoLiftOffsetPx: bt,
5792
+ resolvedLabelStyle: nt,
5793
+ labelStyleResolver: At,
5794
+ regionLabelAutoLiftOffsetPx: j,
5881
5795
  clampLabelToViewport: c,
5882
5796
  onHover: m,
5883
5797
  onClick: g,
5884
- commitActive: $
5798
+ commitActive: dt
5885
5799
  });
5886
- return St.current = {
5887
- preparedRegionHits: ht,
5800
+ return Et.current = {
5801
+ preparedRegionHits: gt,
5888
5802
  labelAnchor: a,
5889
- resolvedLabelStyle: ot,
5890
- labelStyleResolver: yt,
5891
- regionLabelAutoLiftOffsetPx: bt,
5803
+ resolvedLabelStyle: nt,
5804
+ labelStyleResolver: At,
5805
+ regionLabelAutoLiftOffsetPx: j,
5892
5806
  clampLabelToViewport: c,
5893
5807
  onHover: m,
5894
5808
  onClick: g,
5895
- commitActive: $
5896
- }, U(() => {
5809
+ commitActive: dt
5810
+ }, z(() => {
5897
5811
  if (!h) return;
5898
5812
  const G = E.current;
5899
5813
  if (!G) return;
5900
- const Q = (J) => {
5901
- if (C()) return;
5814
+ const K = (Q) => {
5815
+ if (T()) return;
5902
5816
  const Mt = y.current;
5903
5817
  if (!Mt) return;
5904
5818
  const {
5905
5819
  preparedRegionHits: X,
5906
- labelAnchor: Ft,
5820
+ labelAnchor: Tt,
5907
5821
  resolvedLabelStyle: Bt,
5908
- labelStyleResolver: z,
5909
- regionLabelAutoLiftOffsetPx: K,
5910
- clampLabelToViewport: tt,
5911
- onHover: nt
5912
- } = St.current, Rt = Y(J.clientX, J.clientY);
5913
- if (!Rt) return;
5914
- let At = null, vt = null;
5822
+ labelStyleResolver: zt,
5823
+ regionLabelAutoLiftOffsetPx: k,
5824
+ clampLabelToViewport: H,
5825
+ onHover: $
5826
+ } = Et.current, ot = Y(Q.clientX, Q.clientY);
5827
+ if (!ot) return;
5828
+ let bt = null, pt = null;
5915
5829
  if (X.length > 0) {
5916
- const b = M(Rt[0], Rt[1]);
5830
+ const b = M(ot[0], ot[1]);
5917
5831
  if (b) {
5918
5832
  const A = x.current?.getBoundingClientRect();
5919
- vt = Zr(
5920
- Rt,
5833
+ pt = Zr(
5834
+ ot,
5921
5835
  b,
5922
5836
  X,
5923
5837
  Mt,
5924
- Ft,
5838
+ Tt,
5925
5839
  Bt,
5926
- z,
5927
- typeof K == "number" ? K : 0,
5840
+ zt,
5841
+ typeof k == "number" ? k : 0,
5928
5842
  A?.width ?? 0,
5929
5843
  A?.height ?? 0,
5930
- tt
5931
- ), At = vt?.regionId ?? null;
5844
+ H
5845
+ ), bt = pt?.regionId ?? null;
5932
5846
  }
5933
5847
  }
5934
- const Ut = v.current;
5935
- String(Ut) !== String(At) && (v.current = At, et || N(At), nt?.({
5936
- region: vt?.region ?? null,
5937
- regionId: At,
5938
- regionIndex: vt?.regionIndex ?? -1,
5939
- coordinate: Rt
5848
+ const Ut = C.current;
5849
+ String(Ut) !== String(bt) && (C.current = bt, tt || F(bt), $?.({
5850
+ region: pt?.region ?? null,
5851
+ regionId: bt,
5852
+ regionIndex: pt?.regionIndex ?? -1,
5853
+ coordinate: ot
5940
5854
  }), R());
5941
- }, mt = (J) => {
5942
- if (C()) return;
5855
+ }, St = (Q) => {
5856
+ if (T()) return;
5943
5857
  const Mt = y.current;
5944
5858
  if (!Mt) return;
5945
5859
  const {
5946
5860
  preparedRegionHits: X,
5947
- labelAnchor: Ft,
5861
+ labelAnchor: Tt,
5948
5862
  resolvedLabelStyle: Bt,
5949
- labelStyleResolver: z,
5950
- regionLabelAutoLiftOffsetPx: K,
5951
- clampLabelToViewport: tt,
5952
- onClick: nt,
5953
- commitActive: Rt
5954
- } = St.current;
5863
+ labelStyleResolver: zt,
5864
+ regionLabelAutoLiftOffsetPx: k,
5865
+ clampLabelToViewport: H,
5866
+ onClick: $,
5867
+ commitActive: ot
5868
+ } = Et.current;
5955
5869
  if (X.length === 0) return;
5956
- const At = Y(J.clientX, J.clientY);
5957
- if (!At) return;
5958
- const vt = M(At[0], At[1]);
5959
- if (!vt) return;
5870
+ const bt = Y(Q.clientX, Q.clientY);
5871
+ if (!bt) return;
5872
+ const pt = M(bt[0], bt[1]);
5873
+ if (!pt) return;
5960
5874
  const Ut = x.current?.getBoundingClientRect(), b = Zr(
5961
- At,
5962
- vt,
5875
+ bt,
5876
+ pt,
5963
5877
  X,
5964
5878
  Mt,
5965
- Ft,
5879
+ Tt,
5966
5880
  Bt,
5967
- z,
5968
- typeof K == "number" ? K : 0,
5881
+ zt,
5882
+ typeof k == "number" ? k : 0,
5969
5883
  Ut?.width ?? 0,
5970
5884
  Ut?.height ?? 0,
5971
- tt
5885
+ H
5972
5886
  ), A = b?.regionId ?? null;
5973
- Rt(A), b && nt && nt({
5887
+ ot(A), b && $ && $({
5974
5888
  region: b.region,
5975
5889
  regionId: b.regionId,
5976
5890
  regionIndex: b.regionIndex,
5977
- coordinate: At
5891
+ coordinate: bt
5978
5892
  });
5979
- }, rt = () => {
5980
- v.current !== null && (v.current = null, et || N(null), St.current.onHover?.({ region: null, regionId: null, regionIndex: -1, coordinate: null }), R());
5893
+ }, et = () => {
5894
+ C.current !== null && (C.current = null, tt || F(null), Et.current.onHover?.({ region: null, regionId: null, regionIndex: -1, coordinate: null }), R());
5981
5895
  };
5982
- return G.addEventListener("pointermove", Q), G.addEventListener("click", mt), G.addEventListener("pointerleave", rt), () => {
5983
- G.removeEventListener("pointermove", Q), G.removeEventListener("click", mt), G.removeEventListener("pointerleave", rt);
5896
+ return G.addEventListener("pointermove", K), G.addEventListener("click", St), G.addEventListener("pointerleave", et), () => {
5897
+ G.removeEventListener("pointermove", K), G.removeEventListener("click", St), G.removeEventListener("pointerleave", et);
5984
5898
  };
5985
- }, [E, y, x, h, et, Y, M, C, R]), null;
5899
+ }, [E, y, x, h, tt, Y, M, T, R]), null;
5986
5900
  }
5987
5901
  function xu({
5988
5902
  imageWidth: e,
@@ -5996,7 +5910,7 @@ function xu({
5996
5910
  () => ({ width: "100%", height: "100%", display: "block", ...o }),
5997
5911
  [o]
5998
5912
  );
5999
- return U(() => {
5913
+ return z(() => {
6000
5914
  const c = s.current;
6001
5915
  if (!c)
6002
5916
  return;
@@ -6009,10 +5923,10 @@ function xu({
6009
5923
  return a.current = f, f.setTiles(n), () => {
6010
5924
  f.destroy(), a.current = null;
6011
5925
  };
6012
- }, [e, t]), U(() => {
5926
+ }, [e, t]), z(() => {
6013
5927
  const c = a.current;
6014
5928
  c && c.setTiles(n);
6015
- }, [n]), U(() => {
5929
+ }, [n]), z(() => {
6016
5930
  const c = a.current;
6017
5931
  !c || !r || c.setViewState(r);
6018
5932
  }, [r]), /* @__PURE__ */ Qt("canvas", { ref: s, className: i, style: l });
@@ -6076,7 +5990,7 @@ class Dl {
6076
5990
  const o = {
6077
5991
  tile: r,
6078
5992
  attempt: 0,
6079
- readyAt: Et()
5993
+ readyAt: Pt()
6080
5994
  };
6081
5995
  this.queue.push(o), this.queuedByKey.set(r.key, o);
6082
5996
  }
@@ -6132,14 +6046,14 @@ class Dl {
6132
6046
  if (this.inflight.size >= this.maxConcurrency || this.queue.length === 0) return;
6133
6047
  const t = this.queue[0]?.readyAt;
6134
6048
  if (typeof t != "number") return;
6135
- const n = Math.max(0, t - Et());
6049
+ const n = Math.max(0, t - Pt());
6136
6050
  this.timerId = globalThis.setTimeout(() => {
6137
6051
  this.timerId = null, this.pump();
6138
6052
  }, n);
6139
6053
  }
6140
6054
  takeNextReadyQueueItem() {
6141
6055
  if (this.queue.length === 0) return null;
6142
- const t = Et(), n = this.queue[0];
6056
+ const t = Pt(), n = this.queue[0];
6143
6057
  return !n || n.readyAt > t ? null : (this.queue.shift(), this.queuedByKey.delete(n.tile.key), n);
6144
6058
  }
6145
6059
  startFetch(t) {
@@ -6175,7 +6089,7 @@ class Dl {
6175
6089
  const a = t.attempt + 1, l = this.getRetryDelay(a), c = {
6176
6090
  tile: t.tile,
6177
6091
  attempt: a,
6178
- readyAt: Et() + l
6092
+ readyAt: Pt() + l
6179
6093
  }, f = this.queuedByKey.get(t.tile.key);
6180
6094
  f ? (f.tile = c.tile, f.readyAt = Math.min(f.readyAt, c.readyAt), f.attempt = Math.max(f.attempt, c.attempt)) : (this.queue.push(c), this.queuedByKey.set(c.tile.key, c)), this.sortQueue();
6181
6095
  return;
@@ -6473,14 +6387,14 @@ function ji(e, t, n) {
6473
6387
  const p = (c + u) * 0.5 / i / t.tileSize, x = (f + h) * 0.5 / i / t.tileSize, E = [];
6474
6388
  for (let w = g; w <= y; w += 1)
6475
6389
  for (let P = d; P <= m; P += 1) {
6476
- const R = P * t.tileSize * i, B = w * t.tileSize * i, k = Math.min((P + 1) * t.tileSize, o) * i, Y = Math.min((w + 1) * t.tileSize, s) * i, M = P - p, C = w - x;
6390
+ const R = P * t.tileSize * i, B = w * t.tileSize * i, N = Math.min((P + 1) * t.tileSize, o) * i, Y = Math.min((w + 1) * t.tileSize, s) * i, M = P - p, T = w - x;
6477
6391
  E.push({
6478
6392
  key: `${n}/${P}/${w}`,
6479
6393
  tier: n,
6480
6394
  x: P,
6481
6395
  y: w,
6482
- bounds: [R, B, k, Y],
6483
- distance2: M * M + C * C,
6396
+ bounds: [R, B, N, Y],
6397
+ distance2: M * M + T * T,
6484
6398
  url: Xi(t, n, P, w)
6485
6399
  });
6486
6400
  }
@@ -6764,33 +6678,33 @@ function Cc(e) {
6764
6678
  const x = [];
6765
6679
  for (const [, M] of i)
6766
6680
  p.has(M.key) || d(M.bounds, y) && x.push(M);
6767
- x.sort((M, C) => M.tier - C.tier);
6681
+ x.sort((M, T) => M.tier - T.tier);
6768
6682
  for (const M of x)
6769
6683
  M.lastUsed = o, t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, M.texture), t.uniform4f(s.uBounds, M.bounds[0], M.bounds[1], M.bounds[2], M.bounds[3]), t.drawArrays(t.TRIANGLE_STRIP, 0, 4);
6770
6684
  let E = 0;
6771
6685
  const w = [];
6772
6686
  for (const M of g) {
6773
- const C = i.get(M.key);
6774
- if (!C) {
6687
+ const T = i.get(M.key);
6688
+ if (!T) {
6775
6689
  w.push(M);
6776
6690
  continue;
6777
6691
  }
6778
- C.lastUsed = o, t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, C.texture), t.uniform4f(s.uBounds, C.bounds[0], C.bounds[1], C.bounds[2], C.bounds[3]), t.drawArrays(t.TRIANGLE_STRIP, 0, 4), E += 1;
6692
+ T.lastUsed = o, t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, T.texture), t.uniform4f(s.uBounds, T.bounds[0], T.bounds[1], T.bounds[2], T.bounds[3]), t.drawArrays(t.TRIANGLE_STRIP, 0, 4), E += 1;
6779
6693
  }
6780
6694
  const P = w.slice(), R = 1e6, B = [];
6781
6695
  m > 0 && B.push(m - 1), m < r.maxTierZoom && B.push(m + 1);
6782
6696
  for (const M of B) {
6783
- const C = u(M);
6784
- for (const F of C)
6785
- i.has(F.key) || (F.distance2 += R, P.push(F));
6697
+ const T = u(M);
6698
+ for (const O of T)
6699
+ i.has(O.key) || (O.distance2 += R, P.push(O));
6786
6700
  }
6787
6701
  c.schedule(P), t.bindTexture(t.TEXTURE_2D, null), t.bindVertexArray(null);
6788
- let k = 0, Y = 0;
6702
+ let N = 0, Y = 0;
6789
6703
  if (l.length > 0) {
6790
6704
  t.enable(t.BLEND), t.blendFunc(t.ONE, t.ONE_MINUS_SRC_ALPHA);
6791
6705
  for (let M = 0; M < l.length; M += 1) {
6792
- const C = l[M];
6793
- C.pointCount <= 0 || (t.useProgram(C.pointProgram.program), t.bindVertexArray(C.pointProgram.vao), t.uniformMatrix3fv(C.pointProgram.uCamera, !1, n.getMatrix()), t.uniform1f(C.pointProgram.uPointSize, C.pointSizePx), t.uniform1f(C.pointProgram.uPointCssSize, C.pointCssSizePx), t.uniform2f(C.pointProgram.uPointLineDash, C.pointLineDash[0], C.pointLineDash[1]), t.uniform1f(C.pointProgram.uPointOpacity, C.pointOpacity), t.uniform1f(C.pointProgram.uPointStrokeScale, C.pointStrokeScale), t.uniform1f(C.pointProgram.uPointInnerFillAlpha, C.pointInnerFillOpacity), t.uniform3f(C.pointProgram.uPointInnerFillColor, C.pointInnerFillColor[0], C.pointInnerFillColor[1], C.pointInnerFillColor[2]), t.uniform1f(C.pointProgram.uPaletteSize, C.pointPaletteSize), t.uniform1i(C.pointProgram.uPalette, 1), t.activeTexture(t.TEXTURE1), t.bindTexture(t.TEXTURE_2D, C.pointProgram.paletteTexture), C.usePointIndices ? t.drawElements(t.POINTS, C.pointCount, t.UNSIGNED_INT, 0) : t.drawArrays(t.POINTS, 0, C.pointCount), k += C.pointCount, Y += 1);
6706
+ const T = l[M];
6707
+ T.pointCount <= 0 || (t.useProgram(T.pointProgram.program), t.bindVertexArray(T.pointProgram.vao), t.uniformMatrix3fv(T.pointProgram.uCamera, !1, n.getMatrix()), t.uniform1f(T.pointProgram.uPointSize, T.pointSizePx), t.uniform1f(T.pointProgram.uPointCssSize, T.pointCssSizePx), t.uniform2f(T.pointProgram.uPointLineDash, T.pointLineDash[0], T.pointLineDash[1]), t.uniform1f(T.pointProgram.uPointOpacity, T.pointOpacity), t.uniform1f(T.pointProgram.uPointStrokeScale, T.pointStrokeScale), t.uniform1f(T.pointProgram.uPointInnerFillAlpha, T.pointInnerFillOpacity), t.uniform3f(T.pointProgram.uPointInnerFillColor, T.pointInnerFillColor[0], T.pointInnerFillColor[1], T.pointInnerFillColor[2]), t.uniform1f(T.pointProgram.uPaletteSize, T.pointPaletteSize), t.uniform1i(T.pointProgram.uPalette, 1), t.activeTexture(t.TEXTURE1), t.bindTexture(t.TEXTURE_2D, T.pointProgram.paletteTexture), T.usePointIndices ? t.drawElements(t.POINTS, T.pointCount, t.UNSIGNED_INT, 0) : t.drawArrays(t.POINTS, 0, T.pointCount), N += T.pointCount, Y += 1);
6794
6708
  }
6795
6709
  t.bindTexture(t.TEXTURE_2D, null), t.bindVertexArray(null);
6796
6710
  }
@@ -6798,7 +6712,7 @@ function Cc(e) {
6798
6712
  tier: m,
6799
6713
  visible: g.length,
6800
6714
  rendered: E,
6801
- points: k,
6715
+ points: N,
6802
6716
  fallback: x.length,
6803
6717
  cacheHits: E,
6804
6718
  cacheMisses: w.length,
@@ -6851,7 +6765,7 @@ function ii(e) {
6851
6765
 
6852
6766
  color.rgb = clamp(color.rgb + uBrightness, vec3(0.0), vec3(1.0));
6853
6767
  outColor = color;
6854
- }`), i = Dt(e, r, "uCamera"), o = Dt(e, r, "uBounds"), s = Dt(e, r, "uTexture"), a = Dt(e, r, "uBrightness"), l = Dt(e, r, "uContrast"), c = Dt(e, r, "uSaturation"), f = e.createVertexArray(), u = e.createBuffer();
6768
+ }`), i = Lt(e, r, "uCamera"), o = Lt(e, r, "uBounds"), s = Lt(e, r, "uTexture"), a = Lt(e, r, "uBrightness"), l = Lt(e, r, "uContrast"), c = Lt(e, r, "uSaturation"), f = e.createVertexArray(), u = e.createBuffer();
6855
6769
  if (!f || !u)
6856
6770
  throw new Error("buffer allocation failed");
6857
6771
  e.bindVertexArray(f), e.bindBuffer(e.ARRAY_BUFFER, u), e.bufferData(e.ARRAY_BUFFER, new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1]), e.STATIC_DRAW);
@@ -6938,7 +6852,7 @@ function oi(e) {
6938
6852
  vec3 fillRgb = (uPointInnerFillColor / 255.0) * fillAlpha * pointOpacity;
6939
6853
  outColor = vec4(color.rgb * ringAlpha * pointOpacity + fillRgb, alpha);
6940
6854
  }
6941
- }`), i = Dt(e, r, "uCamera"), o = Dt(e, r, "uPointSize"), s = Dt(e, r, "uPointCssSize"), a = Dt(e, r, "uPointOpacity"), l = Dt(e, r, "uPointStrokeScale"), c = Dt(e, r, "uPointInnerFillAlpha"), f = Dt(e, r, "uPointInnerFillColor"), u = Dt(e, r, "uPalette"), h = Dt(e, r, "uPaletteSize"), d = Dt(e, r, "uPointLineDash"), m = e.createVertexArray(), g = e.createBuffer(), y = e.createBuffer(), p = e.createBuffer(), x = e.createBuffer(), E = e.createTexture();
6855
+ }`), i = Lt(e, r, "uCamera"), o = Lt(e, r, "uPointSize"), s = Lt(e, r, "uPointCssSize"), a = Lt(e, r, "uPointOpacity"), l = Lt(e, r, "uPointStrokeScale"), c = Lt(e, r, "uPointInnerFillAlpha"), f = Lt(e, r, "uPointInnerFillColor"), u = Lt(e, r, "uPalette"), h = Lt(e, r, "uPaletteSize"), d = Lt(e, r, "uPointLineDash"), m = e.createVertexArray(), g = e.createBuffer(), y = e.createBuffer(), p = e.createBuffer(), x = e.createBuffer(), E = e.createTexture();
6942
6856
  if (!m || !g || !y || !p || !x || !E)
6943
6857
  throw new Error("point buffer allocation failed");
6944
6858
  e.bindVertexArray(m), e.bindBuffer(e.ARRAY_BUFFER, g), e.bufferData(e.ARRAY_BUFFER, 0, e.DYNAMIC_DRAW);
@@ -6979,7 +6893,7 @@ function Qi(e) {
6979
6893
  function Tc(e) {
6980
6894
  const { state: t, camera: n, target: r, durationMs: i, easing: o, onUpdate: s } = e, a = n.getViewState();
6981
6895
  Qi(t), t.animation = {
6982
- startMs: Et(),
6896
+ startMs: Pt(),
6983
6897
  durationMs: Math.max(0, i),
6984
6898
  from: a,
6985
6899
  to: r,
@@ -6988,7 +6902,7 @@ function Tc(e) {
6988
6902
  const l = () => {
6989
6903
  const c = t.animation;
6990
6904
  if (!c) return;
6991
- const f = Math.max(0, Et() - c.startMs), u = c.durationMs <= 0 ? 1 : _(f / c.durationMs, 0, 1);
6905
+ const f = Math.max(0, Pt() - c.startMs), u = c.durationMs <= 0 ? 1 : _(f / c.durationMs, 0, 1);
6992
6906
  let h = u;
6993
6907
  try {
6994
6908
  h = c.easing(u);
@@ -7097,7 +7011,7 @@ function Bc(e, t, n, r, i) {
7097
7011
  };
7098
7012
  }, y = g(c);
7099
7013
  e.viewAnimationState.animation = {
7100
- startMs: Et(),
7014
+ startMs: Pt(),
7101
7015
  durationMs: Math.max(0, i),
7102
7016
  from: o,
7103
7017
  to: { zoom: c, offsetX: y.offsetX, offsetY: y.offsetY, rotationDeg: o.rotationDeg },
@@ -7106,14 +7020,14 @@ function Bc(e, t, n, r, i) {
7106
7020
  const p = () => {
7107
7021
  const x = e.viewAnimationState.animation;
7108
7022
  if (!x) return;
7109
- const E = Math.max(0, Et() - x.startMs), w = _(E / i, 0, 1), P = _(w * w * (3 - 2 * w), 0, 1), R = o.zoom + (c - o.zoom) * P, { offsetX: B, offsetY: k } = g(R);
7110
- e.camera.setViewState({ zoom: R, offsetX: B, offsetY: k, rotationDeg: o.rotationDeg });
7023
+ const E = Math.max(0, Pt() - x.startMs), w = _(E / i, 0, 1), P = _(w * w * (3 - 2 * w), 0, 1), R = o.zoom + (c - o.zoom) * P, { offsetX: B, offsetY: N } = g(R);
7024
+ e.camera.setViewState({ zoom: R, offsetX: B, offsetY: N, rotationDeg: o.rotationDeg });
7111
7025
  const Y = w >= 1;
7112
7026
  Y && (e.clampViewState(), e.viewAnimationState.animation = null, e.viewAnimationState.frame = null), e.onViewStateChange(e.camera.getViewState()), e.requestRender(), Y || (e.viewAnimationState.frame = requestAnimationFrame(p));
7113
7027
  };
7114
7028
  e.viewAnimationState.frame = requestAnimationFrame(p);
7115
7029
  }
7116
- const zt = "__default_point_layer__";
7030
+ const Nt = "__default_point_layer__";
7117
7031
  class Uc {
7118
7032
  constructor(t, n, r = {}) {
7119
7033
  S(this, "canvas");
@@ -7192,7 +7106,8 @@ class Uc {
7192
7106
  antialias: !1,
7193
7107
  depth: !1,
7194
7108
  stencil: !1,
7195
- powerPreference: "high-performance"
7109
+ powerPreference: "high-performance",
7110
+ preserveDrawingBuffer: r.preserveDrawingBuffer ?? !1
7196
7111
  });
7197
7112
  if (!i)
7198
7113
  throw new Error("WebGL2 not supported");
@@ -7260,7 +7175,7 @@ class Uc {
7260
7175
  Qi(this.viewAnimationState);
7261
7176
  }
7262
7177
  startViewAnimation(t, n, r) {
7263
- Tc({
7178
+ this.resetZoomSnapStateForZoomChange(this.camera.getViewState().zoom, t.zoom), Tc({
7264
7179
  state: this.viewAnimationState,
7265
7180
  camera: this.camera,
7266
7181
  target: t,
@@ -7297,8 +7212,8 @@ class Uc {
7297
7212
  pointInnerFillColor: [...this.defaultPointInnerFillColor]
7298
7213
  };
7299
7214
  }
7300
- ensurePointLayer(t = zt) {
7301
- const n = String(t || zt), r = this.pointLayers.get(n);
7215
+ ensurePointLayer(t = Nt) {
7216
+ const n = String(t || Nt), r = this.pointLayers.get(n);
7302
7217
  if (r) return r;
7303
7218
  const i = this.createPointLayerState(n);
7304
7219
  return this.pointLayers.set(n, i), i;
@@ -7326,8 +7241,15 @@ class Uc {
7326
7241
  }
7327
7242
  return n;
7328
7243
  }
7244
+ resetZoomSnapState() {
7245
+ this.zoomSnapState.accumulatedDelta = 0, this.zoomSnapState.lastSnapTimeMs = 0, this.zoomSnapState.blockedDirection = null;
7246
+ }
7247
+ resetZoomSnapStateForZoomChange(t, n) {
7248
+ Math.abs(t - n) < 1e-6 || this.resetZoomSnapState();
7249
+ }
7329
7250
  applyViewStateAndRender(t, n = !0) {
7330
- n && this.cancelViewAnimation(), this.camera.setViewState(t), this.onViewStateChange?.(this.camera.getViewState()), this.requestRender();
7251
+ const r = this.camera.getViewState();
7252
+ n && this.cancelViewAnimation(), this.resetZoomSnapStateForZoomChange(r.zoom, t.zoom), this.camera.setViewState(t), this.onViewStateChange?.(this.camera.getViewState()), this.requestRender();
7331
7253
  }
7332
7254
  setAuthToken(t) {
7333
7255
  this.authToken = String(t ?? ""), this.tileScheduler.setAuthToken(this.authToken);
@@ -7336,7 +7258,7 @@ class Uc {
7336
7258
  const r = Ye(t), i = Ye(n);
7337
7259
  if (this.minZoomOverride === r && this.maxZoomOverride === i)
7338
7260
  return;
7339
- this.minZoomOverride = r, this.maxZoomOverride = i, this.applyZoomBounds();
7261
+ this.minZoomOverride = r, this.maxZoomOverride = i, this.applyZoomBounds(), this.resetZoomSnapState();
7340
7262
  const o = this.resolveTargetViewState({}), s = this.camera.getViewState();
7341
7263
  cr(s, o) || this.applyViewStateAndRender(o);
7342
7264
  }
@@ -7370,18 +7292,18 @@ class Uc {
7370
7292
  this.ensurePointLayer(t);
7371
7293
  }
7372
7294
  unregisterPointLayer(t) {
7373
- const n = String(t || zt), r = this.pointLayers.get(n);
7295
+ const n = String(t || Nt), r = this.pointLayers.get(n);
7374
7296
  r && (this.pointLayers.delete(n), this.deletePointProgram(r.program), this.requestRender());
7375
7297
  }
7376
- setPointPalette(t, n = zt) {
7298
+ setPointPalette(t, n = Nt) {
7377
7299
  const r = this.ensurePointLayer(n);
7378
7300
  r.runtime = ni(r.runtime, this.gl, r.program, this.contextLost, t), !(!t || t.length === 0) && this.requestRender();
7379
7301
  }
7380
- setPointLineDash(t, n = zt) {
7302
+ setPointLineDash(t, n = Nt) {
7381
7303
  const r = this.ensurePointLayer(n), i = ec(t);
7382
7304
  r.pointLineDash[0] === i[0] && r.pointLineDash[1] === i[1] || (r.pointLineDash = i, this.requestRender());
7383
7305
  }
7384
- setPointData(t, n = zt) {
7306
+ setPointData(t, n = Nt) {
7385
7307
  const r = this.ensurePointLayer(n);
7386
7308
  r.runtime = ri(r.runtime, this.gl, r.program, this.contextLost, t), this.requestRender();
7387
7309
  }
@@ -7389,31 +7311,31 @@ class Uc {
7389
7311
  const n = !!t;
7390
7312
  this.interactionLocked !== n && (this.interactionLocked = n, n && this.cancelDrag());
7391
7313
  }
7392
- setPointSizeByZoom(t, n = zt) {
7314
+ setPointSizeByZoom(t, n = Nt) {
7393
7315
  const r = this.ensurePointLayer(n), i = $r(t);
7394
7316
  $l(r.pointSizeZoomStops, i) || (r.pointSizeZoomStops = i, this.requestRender());
7395
7317
  }
7396
- setPointSizeByMagnification(t, n = zt) {
7318
+ setPointSizeByMagnification(t, n = Nt) {
7397
7319
  const r = this.ensurePointLayer(n), i = Kr(t);
7398
7320
  Kl(r.pointSizeMagnificationStops, i) || (r.pointSizeMagnificationStops = i, this.requestRender());
7399
7321
  }
7400
- setPointWeightByMagnification(t, n = zt) {
7322
+ setPointWeightByMagnification(t, n = Nt) {
7401
7323
  const r = this.ensurePointLayer(n), i = jr(t);
7402
7324
  jl(r.pointWeightMagnificationStops, i) || (r.pointWeightMagnificationStops = i, this.requestRender());
7403
7325
  }
7404
- setPointOpacity(t, n = zt) {
7326
+ setPointOpacity(t, n = Nt) {
7405
7327
  const r = this.ensurePointLayer(n), i = Qr(t);
7406
7328
  r.pointOpacity !== i && (r.pointOpacity = i, this.requestRender());
7407
7329
  }
7408
- setPointStrokeScale(t, n = zt) {
7330
+ setPointStrokeScale(t, n = Nt) {
7409
7331
  const r = this.ensurePointLayer(n), i = qe(t);
7410
7332
  r.pointStrokeScale !== i && (r.pointStrokeScale = i, this.requestRender());
7411
7333
  }
7412
- setPointInnerFillOpacity(t, n = zt) {
7334
+ setPointInnerFillOpacity(t, n = Nt) {
7413
7335
  const r = this.ensurePointLayer(n), i = Jr(t);
7414
7336
  r.pointInnerFillOpacity !== i && (r.pointInnerFillOpacity = i, this.requestRender());
7415
7337
  }
7416
- setPointInnerFillColor(t, n = zt) {
7338
+ setPointInnerFillColor(t, n = Nt) {
7417
7339
  const r = this.ensurePointLayer(n), i = ti(t);
7418
7340
  r.pointInnerFillColor[0] === i[0] && r.pointInnerFillColor[1] === i[1] && r.pointInnerFillColor[2] === i[2] || (r.pointInnerFillColor = i, this.requestRender());
7419
7341
  }
@@ -7455,8 +7377,8 @@ class Uc {
7455
7377
  const n = this.camera.getViewState();
7456
7378
  Math.abs(n.rotationDeg - this.initialRotationDeg) < 1e-6 || this.setViewState({ rotationDeg: this.initialRotationDeg }, t);
7457
7379
  }
7458
- getPointSize(t = zt) {
7459
- const n = this.pointLayers.get(String(t || zt)), r = n?.pointSizeMagnificationStops ?? this.defaultPointSizeMagnificationStops;
7380
+ getPointSize(t = Nt) {
7381
+ const n = this.pointLayers.get(String(t || Nt)), r = n?.pointSizeMagnificationStops ?? this.defaultPointSizeMagnificationStops;
7460
7382
  if (r && r.length > 0) {
7461
7383
  const l = Math.max(1e-6, this.camera.getViewState().zoom), c = lr(this.source.mpp ?? 0, l);
7462
7384
  if (c > 0) {
@@ -7467,11 +7389,11 @@ class Uc {
7467
7389
  const i = Math.max(1e-6, this.camera.getViewState().zoom), o = this.source.maxTierZoom + Math.log2(i), s = n?.pointSizeZoomStops ?? this.defaultPointSizeZoomStops, a = Ql(o, s);
7468
7390
  return _(a, me, Hr);
7469
7391
  }
7470
- getPointSizeByZoom(t = zt) {
7392
+ getPointSizeByZoom(t = Nt) {
7471
7393
  return this.getPointSize(t);
7472
7394
  }
7473
- getPointStrokeScale(t = zt) {
7474
- const n = this.pointLayers.get(String(t || zt)), r = n?.pointWeightMagnificationStops ?? this.defaultPointWeightMagnificationStops;
7395
+ getPointStrokeScale(t = Nt) {
7396
+ const n = this.pointLayers.get(String(t || Nt)), r = n?.pointWeightMagnificationStops ?? this.defaultPointWeightMagnificationStops;
7475
7397
  if (r && r.length > 0) {
7476
7398
  const i = Math.max(1e-6, this.camera.getViewState().zoom), o = lr(this.source.mpp ?? 0, i);
7477
7399
  if (o > 0)
@@ -7499,7 +7421,7 @@ class Uc {
7499
7421
  o && this.setViewState(o, i);
7500
7422
  }
7501
7423
  setZoomSnaps(t, n) {
7502
- this.zoomSnaps = ai(t, this.source.mpp), this.zoomSnapFitAsMin = !!n;
7424
+ this.zoomSnaps = ai(t, this.source.mpp), this.zoomSnapFitAsMin = !!n, this.resetZoomSnapState();
7503
7425
  }
7504
7426
  setPanExtent(t) {
7505
7427
  this.applyPanExtent(t);
@@ -7538,7 +7460,7 @@ class Uc {
7538
7460
  }
7539
7461
  render() {
7540
7462
  if (this.destroyed || this.contextLost || this.gl.isContextLost()) return;
7541
- const t = this.onStats ? Et() : 0;
7463
+ const t = this.onStats ? Pt() : 0;
7542
7464
  this.frameSerial += 1;
7543
7465
  const n = Cc({
7544
7466
  gl: this.gl,
@@ -7572,7 +7494,7 @@ class Uc {
7572
7494
  cacheHits: n.cacheHits,
7573
7495
  cacheMisses: n.cacheMisses,
7574
7496
  drawCalls: n.drawCalls,
7575
- frameMs: Et() - t
7497
+ frameMs: Pt() - t
7576
7498
  });
7577
7499
  }
7578
7500
  }
@@ -7659,28 +7581,29 @@ function bu({
7659
7581
  zoomSnaps: y,
7660
7582
  zoomSnapFitAsMin: p,
7661
7583
  panExtent: x,
7662
- onPointerWorldMove: E,
7663
- debugOverlay: w = !1,
7664
- debugOverlayStyle: P,
7665
- className: R,
7666
- style: B,
7667
- children: k
7584
+ preserveDrawingBuffer: E,
7585
+ onPointerWorldMove: w,
7586
+ debugOverlay: P = !1,
7587
+ debugOverlayStyle: R,
7588
+ className: B,
7589
+ style: N,
7590
+ children: Y
7668
7591
  }) {
7669
- const Y = q(null), M = q(null), C = q(null), F = q(null), I = q(null), W = q(null), j = q(kc), N = q(!1), ut = q(/* @__PURE__ */ new Set()), pt = q(/* @__PURE__ */ new Set()), et = q(n), _t = q(r), Ct = q(i), L = q(o), v = q(s), [O, lt] = ae(0), [$, bt] = ae(null), ft = q(w);
7670
- U(() => {
7671
- et.current = n;
7672
- }, [n]), U(() => {
7673
- _t.current = r;
7674
- }, [r]), U(() => {
7675
- Ct.current = i;
7676
- }, [i]), U(() => {
7677
- L.current = o;
7678
- }, [o]), U(() => {
7679
- v.current = s;
7680
- }, [s]), U(() => {
7681
- ft.current = w, w || bt(null);
7682
- }, [w]);
7683
- const it = at(() => ({ position: "relative", width: "100%", height: "100%", ...B }), [B]), Nt = at(
7592
+ const M = q(null), T = q(null), O = q(null), v = q(null), W = q(null), J = q(null), F = q(kc), xt = q(!1), ft = q(/* @__PURE__ */ new Set()), tt = q(/* @__PURE__ */ new Set()), _t = q(n), Ct = q(r), L = q(i), C = q(o), U = q(s), [lt, dt] = ae(0), [j, ht] = ae(null), rt = q(P);
7593
+ z(() => {
7594
+ _t.current = n;
7595
+ }, [n]), z(() => {
7596
+ Ct.current = r;
7597
+ }, [r]), z(() => {
7598
+ L.current = i;
7599
+ }, [i]), z(() => {
7600
+ C.current = o;
7601
+ }, [o]), z(() => {
7602
+ U.current = s;
7603
+ }, [s]), z(() => {
7604
+ rt.current = P, P || ht(null);
7605
+ }, [P]);
7606
+ const Dt = at(() => ({ position: "relative", width: "100%", height: "100%", ...N }), [N]), Rt = at(
7684
7607
  () => ({
7685
7608
  position: "absolute",
7686
7609
  top: 8,
@@ -7699,98 +7622,98 @@ function bu({
7699
7622
  border: "1px solid rgba(173, 216, 255, 0.28)",
7700
7623
  borderRadius: 8,
7701
7624
  boxShadow: "0 8px 22px rgba(0,0,0,0.35)",
7702
- ...P
7625
+ ...R
7703
7626
  }),
7704
- [P]
7705
- ), dt = Oc(l), wt = V(
7706
- (z) => ({
7707
- ...z,
7708
- rotationDeg: z.rotationDeg - dt
7627
+ [R]
7628
+ ), mt = Oc(l), At = V(
7629
+ (k) => ({
7630
+ ...k,
7631
+ rotationDeg: k.rotationDeg - mt
7709
7632
  }),
7710
- [dt]
7711
- ), yt = V(
7712
- (z) => typeof z.rotationDeg != "number" || !Number.isFinite(z.rotationDeg) ? z : {
7713
- ...z,
7714
- rotationDeg: z.rotationDeg + dt
7633
+ [mt]
7634
+ ), nt = V(
7635
+ (k) => typeof k.rotationDeg != "number" || !Number.isFinite(k.rotationDeg) ? k : {
7636
+ ...k,
7637
+ rotationDeg: k.rotationDeg + mt
7715
7638
  },
7716
- [dt]
7717
- ), ot = V((z) => {
7718
- _t.current?.(z), ft.current && bt(z);
7719
- }, []), ct = at(() => $ ? [
7720
- `tier ${$.tier} | frame ${$.frameMs?.toFixed(2) ?? "-"} ms | drawCalls ${$.drawCalls ?? "-"}`,
7721
- `tiles visible ${$.visible} | rendered ${$.rendered} | fallback ${$.fallback}`,
7722
- `cache size ${$.cache} | hit ${$.cacheHits ?? "-"} | miss ${$.cacheMisses ?? "-"}`,
7723
- `queue inflight ${$.inflight} | queued ${$.queued ?? "-"} | retries ${$.retries ?? "-"} | failed ${$.failed ?? "-"} | aborted ${$.aborted ?? "-"}`,
7724
- `points ${$.points}`
7639
+ [mt]
7640
+ ), ct = V((k) => {
7641
+ Ct.current?.(k), rt.current && ht(k);
7642
+ }, []), gt = at(() => j ? [
7643
+ `tier ${j.tier} | frame ${j.frameMs?.toFixed(2) ?? "-"} ms | drawCalls ${j.drawCalls ?? "-"}`,
7644
+ `tiles visible ${j.visible} | rendered ${j.rendered} | fallback ${j.fallback}`,
7645
+ `cache size ${j.cache} | hit ${j.cacheHits ?? "-"} | miss ${j.cacheMisses ?? "-"}`,
7646
+ `queue inflight ${j.inflight} | queued ${j.queued ?? "-"} | retries ${j.retries ?? "-"} | failed ${j.failed ?? "-"} | aborted ${j.aborted ?? "-"}`,
7647
+ `points ${j.points}`
7725
7648
  ].join(`
7726
- `) : "stats: waiting for first frame...", [$]), ht = V(() => {
7727
- const z = C.current;
7728
- if (!z) return;
7729
- const K = z.getContext("2d");
7730
- if (!K) return;
7731
- const tt = Math.max(1, window.devicePixelRatio || 1), nt = z.getBoundingClientRect(), Rt = Math.max(1, Math.round(nt.width * tt)), At = Math.max(1, Math.round(nt.height * tt));
7732
- (z.width !== Rt || z.height !== At) && (z.width = Rt, z.height = At);
7733
- const vt = nt.width, Ut = nt.height;
7734
- K.setTransform(1, 0, 0, 1, 0, 0), K.clearRect(0, 0, z.width, z.height), K.setTransform(tt, 0, 0, tt, 0, 0);
7735
- const b = j.current;
7736
- for (let A = 0; A < b.length; A += 1)
7737
- K.save(), b[A].draw(K, vt, Ut), K.restore();
7738
- }, []), H = V(() => {
7739
- N.current || (N.current = !0, requestAnimationFrame(() => {
7740
- N.current = !1, ht();
7649
+ `) : "stats: waiting for first frame...", [j]), ut = V(() => {
7650
+ const k = O.current;
7651
+ if (!k) return;
7652
+ const H = k.getContext("2d");
7653
+ if (!H) return;
7654
+ const $ = Math.max(1, window.devicePixelRatio || 1), ot = k.getBoundingClientRect(), bt = Math.max(1, Math.round(ot.width * $)), pt = Math.max(1, Math.round(ot.height * $));
7655
+ (k.width !== bt || k.height !== pt) && (k.width = bt, k.height = pt);
7656
+ const Ut = ot.width, b = ot.height;
7657
+ H.setTransform(1, 0, 0, 1, 0, 0), H.clearRect(0, 0, k.width, k.height), H.setTransform($, 0, 0, $, 0, 0);
7658
+ const A = F.current;
7659
+ for (let I = 0; I < A.length; I += 1)
7660
+ H.save(), A[I].draw(H, Ut, b), H.restore();
7661
+ }, []), it = V(() => {
7662
+ xt.current || (xt.current = !0, requestAnimationFrame(() => {
7663
+ xt.current = !1, ut();
7741
7664
  }));
7742
- }, [ht]), It = V(
7743
- (z, K, tt) => {
7744
- const nt = j.current.filter((Rt) => Rt.id !== z);
7745
- nt.push({ id: z, priority: K, draw: tt }), nt.sort((Rt, At) => Rt.priority - At.priority), j.current = nt, H();
7665
+ }, [ut]), vt = V(
7666
+ (k, H, $) => {
7667
+ const ot = F.current.filter((bt) => bt.id !== k);
7668
+ ot.push({ id: k, priority: H, draw: $ }), ot.sort((bt, pt) => bt.priority - pt.priority), F.current = ot, it();
7746
7669
  },
7747
- [H]
7748
- ), Pt = V(
7749
- (z) => {
7750
- j.current = j.current.filter((K) => K.id !== z), H();
7670
+ [it]
7671
+ ), Et = V(
7672
+ (k) => {
7673
+ F.current = F.current.filter((H) => H.id !== k), it();
7751
7674
  },
7752
- [H]
7753
- ), St = V((z, K) => {
7754
- K ? ut.current.add(z) : ut.current.delete(z), F.current?.setInteractionLock(ut.current.size > 0);
7755
- }, []), G = V(() => ut.current.size > 0, []), Q = V((z, K) => {
7756
- const tt = F.current;
7757
- return tt ? Nn(tt.worldToScreen(z, K)) : null;
7758
- }, []), mt = V((z, K) => {
7759
- const tt = F.current;
7760
- if (!tt) return null;
7761
- const nt = tt.screenToWorld(z, K);
7762
- if (!Array.isArray(nt) || nt.length < 2) return null;
7763
- const Rt = Number(nt[0]), At = Number(nt[1]);
7764
- return !Number.isFinite(Rt) || !Number.isFinite(At) ? null : [Rt, At];
7765
- }, []), rt = V((z) => (pt.current.add(z), () => {
7766
- pt.current.delete(z);
7767
- }), []), J = V(
7768
- (z) => {
7769
- et.current?.(wt(z));
7770
- const K = pt.current;
7771
- if (K.size > 0) {
7772
- const tt = Array.from(K);
7773
- for (let nt = 0; nt < tt.length; nt += 1)
7774
- tt[nt](z);
7675
+ [it]
7676
+ ), G = V((k, H) => {
7677
+ H ? ft.current.add(k) : ft.current.delete(k), v.current?.setInteractionLock(ft.current.size > 0);
7678
+ }, []), K = V(() => ft.current.size > 0, []), St = V((k, H) => {
7679
+ const $ = v.current;
7680
+ return $ ? Nn($.worldToScreen(k, H)) : null;
7681
+ }, []), et = V((k, H) => {
7682
+ const $ = v.current;
7683
+ if (!$) return null;
7684
+ const ot = $.screenToWorld(k, H);
7685
+ if (!Array.isArray(ot) || ot.length < 2) return null;
7686
+ const bt = Number(ot[0]), pt = Number(ot[1]);
7687
+ return !Number.isFinite(bt) || !Number.isFinite(pt) ? null : [bt, pt];
7688
+ }, []), Q = V((k) => (tt.current.add(k), () => {
7689
+ tt.current.delete(k);
7690
+ }), []), Mt = V(
7691
+ (k) => {
7692
+ _t.current?.(At(k));
7693
+ const H = tt.current;
7694
+ if (H.size > 0) {
7695
+ const $ = Array.from(H);
7696
+ for (let ot = 0; ot < $.length; ot += 1)
7697
+ $[ot](k);
7775
7698
  }
7776
- I.current?.(), W.current?.(), H();
7699
+ W.current?.(), J.current?.(), it();
7777
7700
  },
7778
- [H, wt]
7701
+ [it, At]
7779
7702
  );
7780
- U(() => {
7781
- const z = M.current;
7782
- if (!z || !e) return;
7783
- const K = new Uc(z, e, {
7784
- onViewStateChange: J,
7785
- onStats: ot,
7786
- onTileError: (tt) => {
7787
- Ct.current?.(tt);
7703
+ z(() => {
7704
+ const k = T.current;
7705
+ if (!k || !e) return;
7706
+ const H = new Uc(k, e, {
7707
+ onViewStateChange: Mt,
7708
+ onStats: ct,
7709
+ onTileError: ($) => {
7710
+ L.current?.($);
7788
7711
  },
7789
7712
  onContextLost: () => {
7790
- L.current?.();
7713
+ C.current?.();
7791
7714
  },
7792
7715
  onContextRestored: () => {
7793
- v.current?.();
7716
+ U.current?.();
7794
7717
  },
7795
7718
  authToken: u,
7796
7719
  imageColorSettings: a,
@@ -7801,86 +7724,87 @@ function bu({
7801
7724
  viewTransition: g,
7802
7725
  zoomSnaps: y,
7803
7726
  zoomSnapFitAsMin: p,
7804
- panExtent: x
7727
+ panExtent: x,
7728
+ preserveDrawingBuffer: E
7805
7729
  });
7806
- return F.current = K, lt((tt) => tt + 1), t && K.setViewState(yt(t)), K.setInteractionLock(ut.current.size > 0), () => {
7807
- K.destroy(), F.current = null;
7730
+ return v.current = H, dt(($) => $ + 1), t && H.setViewState(nt(t)), H.setInteractionLock(ft.current.size > 0), () => {
7731
+ H.destroy(), v.current = null;
7808
7732
  };
7809
- }, [e, ot, h, J, dt, yt]), U(() => {
7810
- F.current?.setAuthToken(u);
7811
- }, [u]), U(() => {
7812
- const z = F.current;
7813
- !z || !t || z.isViewAnimating() || z.setViewState(yt(t));
7814
- }, [t, yt]), U(() => {
7815
- F.current?.fitToImage();
7816
- }, [c]), U(() => {
7817
- F.current?.resetRotation();
7818
- }, [f]), U(() => {
7819
- F.current?.setZoomRange(d, m);
7820
- }, [d, m]), U(() => {
7821
- F.current?.setViewTransition(g);
7822
- }, [g]), U(() => {
7823
- F.current?.setZoomSnaps(y, p);
7824
- }, [y, p]), U(() => {
7825
- F.current?.setPanExtent(x);
7826
- }, [x]), U(() => {
7827
- F.current?.setImageColorSettings(a);
7828
- }, [a]), U(() => {
7829
- const z = C.current;
7830
- if (!z) return;
7831
- I.current = H, H();
7832
- const K = new ResizeObserver(() => H());
7833
- return K.observe(z), () => {
7834
- K.disconnect(), I.current === H && (I.current = null);
7733
+ }, [e, ct, h, Mt, mt, nt]), z(() => {
7734
+ v.current?.setAuthToken(u);
7735
+ }, [u]), z(() => {
7736
+ const k = v.current;
7737
+ !k || !t || k.isViewAnimating() || k.setViewState(nt(t));
7738
+ }, [t, nt]), z(() => {
7739
+ v.current?.fitToImage();
7740
+ }, [c]), z(() => {
7741
+ v.current?.resetRotation();
7742
+ }, [f]), z(() => {
7743
+ v.current?.setZoomRange(d, m);
7744
+ }, [d, m]), z(() => {
7745
+ v.current?.setViewTransition(g);
7746
+ }, [g]), z(() => {
7747
+ v.current?.setZoomSnaps(y, p);
7748
+ }, [y, p]), z(() => {
7749
+ v.current?.setPanExtent(x);
7750
+ }, [x]), z(() => {
7751
+ v.current?.setImageColorSettings(a);
7752
+ }, [a]), z(() => {
7753
+ const k = O.current;
7754
+ if (!k) return;
7755
+ W.current = it, it();
7756
+ const H = new ResizeObserver(() => it());
7757
+ return H.observe(k), () => {
7758
+ H.disconnect(), W.current === it && (W.current = null);
7835
7759
  };
7836
- }, [H]), U(() => sn(() => H()), [H]);
7837
- const Mt = at(
7760
+ }, [it]), z(() => sn(() => it()), [it]);
7761
+ const X = at(
7838
7762
  () => ({
7839
7763
  source: e,
7840
- rendererRef: F,
7841
- rendererSerial: O,
7842
- canvasRef: M,
7843
- containerRef: Y,
7844
- drawInvalidateRef: I,
7845
- overviewInvalidateRef: W,
7846
- worldToScreen: Q,
7847
- screenToWorld: mt,
7848
- registerDrawCallback: It,
7849
- unregisterDrawCallback: Pt,
7850
- requestOverlayRedraw: H,
7851
- registerViewStateListener: rt,
7852
- setInteractionLock: St,
7853
- isInteractionLocked: G
7764
+ rendererRef: v,
7765
+ rendererSerial: lt,
7766
+ canvasRef: T,
7767
+ containerRef: M,
7768
+ drawInvalidateRef: W,
7769
+ overviewInvalidateRef: J,
7770
+ worldToScreen: St,
7771
+ screenToWorld: et,
7772
+ registerDrawCallback: vt,
7773
+ unregisterDrawCallback: Et,
7774
+ requestOverlayRedraw: it,
7775
+ registerViewStateListener: Q,
7776
+ setInteractionLock: G,
7777
+ isInteractionLocked: K
7854
7778
  }),
7855
- [e, O, Q, mt, It, Pt, H, rt, St, G]
7856
- ), X = q(E);
7857
- U(() => {
7858
- X.current = E;
7859
- }, [E]);
7860
- const Ft = V(
7861
- (z) => {
7862
- const K = X.current;
7863
- if (!K) return;
7864
- const tt = mt(z.clientX, z.clientY), nt = !!tt && tt[0] >= 0 && tt[1] >= 0 && !!e && tt[0] <= e.width && tt[1] <= e.height;
7865
- K({ coordinate: tt, clientX: z.clientX, clientY: z.clientY, insideImage: nt });
7779
+ [e, lt, St, et, vt, Et, it, Q, G, K]
7780
+ ), Tt = q(w);
7781
+ z(() => {
7782
+ Tt.current = w;
7783
+ }, [w]);
7784
+ const Bt = V(
7785
+ (k) => {
7786
+ const H = Tt.current;
7787
+ if (!H) return;
7788
+ const $ = et(k.clientX, k.clientY), ot = !!$ && $[0] >= 0 && $[1] >= 0 && !!e && $[0] <= e.width && $[1] <= e.height;
7789
+ H({ coordinate: $, clientX: k.clientX, clientY: k.clientY, insideImage: ot });
7866
7790
  },
7867
- [mt, e]
7868
- ), Bt = V(() => {
7869
- X.current?.({ coordinate: null, clientX: -1, clientY: -1, insideImage: !1 });
7791
+ [et, e]
7792
+ ), zt = V(() => {
7793
+ Tt.current?.({ coordinate: null, clientX: -1, clientY: -1, insideImage: !1 });
7870
7794
  }, []);
7871
- return /* @__PURE__ */ Qt(oa, { value: Mt, children: /* @__PURE__ */ ci(
7795
+ return /* @__PURE__ */ Qt(oa, { value: X, children: /* @__PURE__ */ ci(
7872
7796
  "div",
7873
7797
  {
7874
- ref: Y,
7875
- className: R,
7876
- style: it,
7877
- onPointerMove: E ? Ft : void 0,
7878
- onPointerLeave: E ? Bt : void 0,
7798
+ ref: M,
7799
+ className: B,
7800
+ style: Dt,
7801
+ onPointerMove: w ? Bt : void 0,
7802
+ onPointerLeave: w ? zt : void 0,
7879
7803
  children: [
7880
7804
  /* @__PURE__ */ Qt(
7881
7805
  "canvas",
7882
7806
  {
7883
- ref: M,
7807
+ ref: T,
7884
7808
  className: "wsi-render-canvas",
7885
7809
  style: {
7886
7810
  position: "absolute",
@@ -7896,7 +7820,7 @@ function bu({
7896
7820
  /* @__PURE__ */ Qt(
7897
7821
  "canvas",
7898
7822
  {
7899
- ref: C,
7823
+ ref: O,
7900
7824
  className: "wsi-overlay-canvas",
7901
7825
  style: {
7902
7826
  position: "absolute",
@@ -7910,8 +7834,8 @@ function bu({
7910
7834
  }
7911
7835
  }
7912
7836
  ),
7913
- k,
7914
- w && /* @__PURE__ */ Qt("pre", { "data-open-plant-debug-overlay": !0, style: Nt, children: ct })
7837
+ Y,
7838
+ P && /* @__PURE__ */ Qt("pre", { "data-open-plant-debug-overlay": !0, style: Rt, children: gt })
7915
7839
  ]
7916
7840
  }
7917
7841
  ) });
@@ -8033,8 +7957,8 @@ function wu(e, t, n = {}) {
8033
7957
  for (const P of x) {
8034
7958
  const R = s[P];
8035
7959
  let B = !1;
8036
- for (const k of R.polygons)
8037
- if (gi(g, y, k)) {
7960
+ for (const N of R.polygons)
7961
+ if (gi(g, y, N)) {
8038
7962
  B = !0;
8039
7963
  break;
8040
7964
  }