@aiquants/virtualscroll 2.7.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,26 @@
1
- import { jsx as de, jsxs as Mt, Fragment as dr } from "react/jsx-runtime";
2
- import xr, { memo as Sr, forwardRef as Zt, useState as rt, useRef as g, useCallback as I, useImperativeHandle as Jt, useMemo as Fe, useLayoutEffect as nt, useEffect as q, useId as Ir } from "react";
3
- import { twMerge as Et } from "tailwind-merge";
4
- class T {
1
+ import { jsx as ie, jsxs as Tt, Fragment as rr } from "react/jsx-runtime";
2
+ import Er, { memo as Nr, forwardRef as nr, useState as Je, useRef as g, useCallback as S, useImperativeHandle as ir, useMemo as _e, useLayoutEffect as et, useEffect as X, useId as Vr } from "react";
3
+ import { twMerge as Vt } from "tailwind-merge";
4
+ const bn = (r) => {
5
+ const { quantum: e, resetOnDirectionChange: t = !0 } = r;
6
+ if (!(Number.isFinite(e) && e > 0))
7
+ throw new TypeError(`[createResidualQuantizer] quantum must be a finite positive number, received ${e}`);
8
+ let n = 0;
9
+ return {
10
+ push: (i) => {
11
+ if (!Number.isFinite(i) || Math.abs(i) > Number.MAX_SAFE_INTEGER)
12
+ return 0;
13
+ t && n !== 0 && i !== 0 && Math.sign(i) !== Math.sign(n) && (n = 0), n += i;
14
+ const s = Math.trunc(n / e) * e + 0;
15
+ return n -= s, s;
16
+ },
17
+ peekResidue: () => n,
18
+ reset: () => {
19
+ n = 0;
20
+ }
21
+ };
22
+ };
23
+ class P {
5
24
  level;
6
25
  prefix;
7
26
  impl;
@@ -14,7 +33,7 @@ class T {
14
33
  constructor(e = 2, t = "[virtualscroll]", n = console) {
15
34
  this.level = e, this.prefix = t, this.impl = n;
16
35
  }
17
- static instance = new T(2, "[virtualscroll]");
36
+ static instance = new P(2, "[virtualscroll]");
18
37
  /**
19
38
  * @method setLevel
20
39
  * @description Updates the current log level for the static instance.
@@ -22,7 +41,7 @@ class T {
22
41
  * @param {LogLevel} level - The new log level.
23
42
  */
24
43
  static setLevel(e) {
25
- T.instance.setLevel(e);
44
+ P.instance.setLevel(e);
26
45
  }
27
46
  /**
28
47
  * @method setLevel
@@ -40,7 +59,7 @@ class T {
40
59
  * @param {ILogger} impl - The new logger implementation.
41
60
  */
42
61
  static setImplementation(e) {
43
- T.instance.setImplementation(e);
62
+ P.instance.setImplementation(e);
44
63
  }
45
64
  /**
46
65
  * @method setImplementation
@@ -58,7 +77,7 @@ class T {
58
77
  * @param {string} prefix - The new prefix.
59
78
  */
60
79
  static setPrefix(e) {
61
- T.instance.setPrefix(e);
80
+ P.instance.setPrefix(e);
62
81
  }
63
82
  /**
64
83
  * @method setPrefix
@@ -77,7 +96,7 @@ class T {
77
96
  * @returns {boolean} True if a message at `level` would be emitted. / `level` のメッセージが出力されるなら true。
78
97
  */
79
98
  static isEnabled(e) {
80
- return T.instance.isEnabled(e);
99
+ return P.instance.isEnabled(e);
81
100
  }
82
101
  /**
83
102
  * @method isEnabled
@@ -122,41 +141,41 @@ class T {
122
141
  return typeof e == "string" ? [`${this.prefix} ${e}`] : [this.prefix, e];
123
142
  }
124
143
  static debug(e, ...t) {
125
- T.instance.debug(e, ...t);
144
+ P.instance.debug(e, ...t);
126
145
  }
127
146
  debug(e, ...t) {
128
- this.level <= 0 && this.impl.debug(...this.formatMessage(T.resolveLazy(e)), ...t.map(T.resolveLazy));
147
+ this.level <= 0 && this.impl.debug(...this.formatMessage(P.resolveLazy(e)), ...t.map(P.resolveLazy));
129
148
  }
130
149
  static info(e, ...t) {
131
- T.instance.info(e, ...t);
150
+ P.instance.info(e, ...t);
132
151
  }
133
152
  info(e, ...t) {
134
- this.level <= 1 && this.impl.info(...this.formatMessage(T.resolveLazy(e)), ...t.map(T.resolveLazy));
153
+ this.level <= 1 && this.impl.info(...this.formatMessage(P.resolveLazy(e)), ...t.map(P.resolveLazy));
135
154
  }
136
155
  static warn(e, ...t) {
137
- T.instance.warn(e, ...t);
156
+ P.instance.warn(e, ...t);
138
157
  }
139
158
  warn(e, ...t) {
140
- this.level <= 2 && this.impl.warn(...this.formatMessage(T.resolveLazy(e)), ...t.map(T.resolveLazy));
159
+ this.level <= 2 && this.impl.warn(...this.formatMessage(P.resolveLazy(e)), ...t.map(P.resolveLazy));
141
160
  }
142
161
  static error(e, ...t) {
143
- T.instance.error(e, ...t);
162
+ P.instance.error(e, ...t);
144
163
  }
145
164
  error(e, ...t) {
146
- this.level <= 3 && this.impl.error(...this.formatMessage(T.resolveLazy(e)), ...t.map(T.resolveLazy));
165
+ this.level <= 3 && this.impl.error(...this.formatMessage(P.resolveLazy(e)), ...t.map(P.resolveLazy));
147
166
  }
148
167
  }
149
- const rr = {
168
+ const fr = {
150
169
  active: !1,
151
170
  offsetX: 0,
152
171
  offsetY: 0,
153
172
  distance: 0,
154
173
  direction: 0,
155
174
  pointerId: null
156
- }, $t = 6, vr = 8, wr = ({ dragState: r, normalizedDistance: e }) => {
175
+ }, jt = 6, zr = 8, Cr = ({ dragState: r, normalizedDistance: e }) => {
157
176
  const t = 1 + e * 0.18, n = 0.16 + e * 0.24, i = 0.38 + e * 0.28, s = r.active ? "80ms ease-out" : "220ms ease";
158
- return /* @__PURE__ */ Mt(dr, { children: [
159
- /* @__PURE__ */ de(
177
+ return /* @__PURE__ */ Tt(rr, { children: [
178
+ /* @__PURE__ */ ie(
160
179
  "div",
161
180
  {
162
181
  className: "aqvs-tap-scroll-circle-visual-outer",
@@ -168,7 +187,7 @@ const rr = {
168
187
  }
169
188
  }
170
189
  ),
171
- /* @__PURE__ */ de(
190
+ /* @__PURE__ */ ie(
172
191
  "div",
173
192
  {
174
193
  className: "aqvs-tap-scroll-circle-inner",
@@ -181,154 +200,154 @@ const rr = {
181
200
  }
182
201
  )
183
202
  ] });
184
- }, fr = Sr(
185
- Zt(({ onDragChange: r, className: e, maxVisualDistance: t = 160, size: n = 40, style: i, opacity: s = 1, renderVisual: a }, c) => {
186
- const [f, b] = rt(rr), S = g(null), w = g(null), V = g({ x: 0, y: 0 }), h = g(null), C = g(0), G = I(
187
- (v) => {
188
- b(v), r(v);
203
+ }, Sr = Nr(
204
+ nr(({ onDragChange: r, className: e, maxVisualDistance: t = 160, size: n = 40, style: i, opacity: s = 1, renderVisual: l }, d) => {
205
+ const [m, b] = Je(fr), v = g(null), T = g(null), C = g({ x: 0, y: 0 }), h = g(null), O = g(0), W = S(
206
+ (I) => {
207
+ b(I), r(I);
189
208
  },
190
209
  [r]
191
- ), H = I(
192
- (v, U, ge = !1) => {
193
- const { x: qe, y: ee } = V.current, X = v - qe, Xe = U - ee, $e = Math.abs(Xe), Ce = $e < $t ? 0 : Xe < 0 ? -1 : 1, ze = C.current;
194
- let je = Ce;
195
- const Ge = $t + vr;
196
- Ce === 0 ? ze !== 0 && $e < Ge ? je = ze : (je = 0, ge || (C.current = 0)) : Ce !== ze && ze !== 0 && $e < Ge ? je = ze : C.current = Ce, G({
197
- active: ge || $e >= $t,
198
- offsetX: X,
199
- offsetY: Xe,
200
- distance: $e,
201
- direction: je,
202
- pointerId: S.current
210
+ ), D = S(
211
+ (I, G, fe = !1) => {
212
+ const { x: $e, y: Ue } = C.current, z = I - $e, ke = G - Ue, We = Math.abs(ke), Ve = We < jt ? 0 : ke < 0 ? -1 : 1, Fe = O.current;
213
+ let Ke = Ve;
214
+ const De = jt + zr;
215
+ Ve === 0 ? Fe !== 0 && We < De ? Ke = Fe : (Ke = 0, fe || (O.current = 0)) : Ve !== Fe && Fe !== 0 && We < De ? Ke = Fe : O.current = Ve, W({
216
+ active: fe || We >= jt,
217
+ offsetX: z,
218
+ offsetY: ke,
219
+ distance: We,
220
+ direction: Ke,
221
+ pointerId: v.current
203
222
  });
204
223
  },
205
- [G]
206
- ), pe = I((v) => {
207
- if (v === null)
224
+ [W]
225
+ ), ce = S((I) => {
226
+ if (I === null)
208
227
  return;
209
- const U = h.current;
210
- U?.hasPointerCapture(v) && U.releasePointerCapture(v);
211
- }, []), me = I(
212
- (v = !1) => {
213
- v && pe(S.current), S.current = null, w.current = null, C.current = 0, G(rr);
228
+ const G = h.current;
229
+ G?.hasPointerCapture(I) && G.releasePointerCapture(I);
230
+ }, []), ue = S(
231
+ (I = !1) => {
232
+ I && ce(v.current), v.current = null, T.current = null, O.current = 0, W(fr);
214
233
  },
215
- [G, pe]
216
- ), oe = I(
217
- (v) => {
218
- if (S.current !== null && S.current !== v.pointerId) {
219
- w.current = { pointerId: v.pointerId, clientX: v.clientX, clientY: v.clientY }, v.preventDefault(), v.stopPropagation();
234
+ [W, ce]
235
+ ), re = S(
236
+ (I) => {
237
+ if (v.current !== null && v.current !== I.pointerId) {
238
+ T.current = { pointerId: I.pointerId, clientX: I.clientX, clientY: I.clientY }, I.preventDefault(), I.stopPropagation();
220
239
  return;
221
240
  }
222
- v.preventDefault(), v.stopPropagation();
223
- const U = h.current ?? v.currentTarget, { left: ge, top: qe, width: ee, height: X } = U.getBoundingClientRect();
224
- V.current = { x: ge + ee / 2, y: qe + X / 2 }, S.current = v.pointerId;
241
+ I.preventDefault(), I.stopPropagation();
242
+ const G = h.current ?? I.currentTarget, { left: fe, top: $e, width: Ue, height: z } = G.getBoundingClientRect();
243
+ C.current = { x: fe + Ue / 2, y: $e + z / 2 }, v.current = I.pointerId;
225
244
  try {
226
- U.setPointerCapture(v.pointerId);
245
+ G.setPointerCapture(I.pointerId);
227
246
  } catch {
228
247
  }
229
- H(v.clientX, v.clientY, !0);
248
+ D(I.clientX, I.clientY, !0);
230
249
  },
231
- [H]
232
- ), ce = I(
233
- (v) => {
234
- if (S.current !== v.pointerId) {
235
- w.current !== null && w.current.pointerId === v.pointerId && (w.current = { pointerId: v.pointerId, clientX: v.clientX, clientY: v.clientY });
250
+ [D]
251
+ ), oe = S(
252
+ (I) => {
253
+ if (v.current !== I.pointerId) {
254
+ T.current !== null && T.current.pointerId === I.pointerId && (T.current = { pointerId: I.pointerId, clientX: I.clientX, clientY: I.clientY });
236
255
  return;
237
256
  }
238
- v.preventDefault(), H(v.clientX, v.clientY);
257
+ I.preventDefault(), D(I.clientX, I.clientY);
239
258
  },
240
- [H]
241
- ), he = I(
242
- (v) => {
243
- if (S.current !== v.pointerId) {
244
- w.current !== null && w.current.pointerId === v.pointerId && (w.current = null);
259
+ [D]
260
+ ), de = S(
261
+ (I) => {
262
+ if (v.current !== I.pointerId) {
263
+ T.current !== null && T.current.pointerId === I.pointerId && (T.current = null);
245
264
  return;
246
265
  }
247
- v.preventDefault(), v.stopPropagation();
248
- const U = w.current;
249
- if (w.current = null, U !== null) {
250
- pe(v.pointerId);
251
- const ge = h.current;
252
- let qe = !0;
253
- if (ge !== null && typeof ge.setPointerCapture == "function")
266
+ I.preventDefault(), I.stopPropagation();
267
+ const G = T.current;
268
+ if (T.current = null, G !== null) {
269
+ ce(I.pointerId);
270
+ const fe = h.current;
271
+ let $e = !0;
272
+ if (fe !== null && typeof fe.setPointerCapture == "function")
254
273
  try {
255
- ge.setPointerCapture(U.pointerId);
256
- } catch (ee) {
257
- (typeof ee == "object" && ee !== null && "name" in ee ? ee.name : void 0) === "NotFoundError" && (qe = !1);
274
+ fe.setPointerCapture(G.pointerId);
275
+ } catch (Ue) {
276
+ (typeof Ue == "object" && Ue !== null && "name" in Ue ? Ue.name : void 0) === "NotFoundError" && ($e = !1);
258
277
  }
259
- if (qe) {
260
- S.current = U.pointerId, H(U.clientX, U.clientY, !0);
278
+ if ($e) {
279
+ v.current = G.pointerId, D(G.clientX, G.clientY, !0);
261
280
  return;
262
281
  }
263
282
  }
264
- me(!0);
283
+ ue(!0);
265
284
  },
266
- [me, pe, H]
267
- ), P = I(
268
- (v) => {
269
- v.target === v.currentTarget && S.current === v.pointerId && me(!1);
285
+ [ue, ce, D]
286
+ ), y = S(
287
+ (I) => {
288
+ I.target === I.currentTarget && v.current === I.pointerId && ue(!1);
270
289
  },
271
- [me]
290
+ [ue]
272
291
  );
273
- Jt(
274
- c,
292
+ ir(
293
+ d,
275
294
  () => ({
276
295
  reset: () => {
277
- me(!0);
296
+ ue(!0);
278
297
  },
279
298
  getElement: () => h.current
280
299
  }),
281
- [me]
300
+ [ue]
282
301
  );
283
- const _ = Math.min(Math.max(s, 0), 1), M = n / 64, Z = Math.min(f.distance, t) / t, Q = f.direction * Z * 10 * M, W = a ?? wr, Ie = {
284
- dragState: f,
302
+ const Y = Math.min(Math.max(s, 0), 1), w = n / 64, Z = Math.min(m.distance, t) / t, Q = m.direction * Z * 10 * w, K = l ?? Cr, he = {
303
+ dragState: m,
285
304
  normalizedDistance: Z,
286
- sizeScale: M,
305
+ sizeScale: w,
287
306
  size: n,
288
- opacity: _
289
- }, z = {
307
+ opacity: Y
308
+ }, A = {
290
309
  ...i,
291
310
  width: n,
292
311
  height: n,
293
312
  transform: `translateY(${Q}px)`
294
313
  };
295
- return z.opacity = _, /* @__PURE__ */ de(
314
+ return A.opacity = Y, /* @__PURE__ */ ie(
296
315
  "div",
297
316
  {
298
317
  ref: h,
299
318
  "data-testid": "virtual-scroll-tap-circle",
300
- className: Et("aqvs-tap-scroll-circle", e),
301
- style: z,
319
+ className: Vt("aqvs-tap-scroll-circle", e),
320
+ style: A,
302
321
  tabIndex: -1,
303
- onPointerDown: oe,
304
- onPointerMove: ce,
305
- onPointerUp: he,
306
- onPointerCancel: he,
307
- onLostPointerCapture: P,
322
+ onPointerDown: re,
323
+ onPointerMove: oe,
324
+ onPointerUp: de,
325
+ onPointerCancel: de,
326
+ onLostPointerCapture: y,
308
327
  role: "presentation",
309
- children: W(Ie)
328
+ children: K(he)
310
329
  }
311
330
  );
312
331
  })
313
332
  );
314
- fr.displayName = "TapScrollCircle";
315
- const le = (r, e, t) => Math.max(e, Math.min(t, r)), Gt = "virtualscroll:tap-scroll-cancel", nr = 20, Tr = 250, Pr = 60, Mr = 20, yr = 20, pr = {
333
+ Sr.displayName = "TapScrollCircle";
334
+ const se = (r, e, t) => Math.max(e, Math.min(t, r)), tr = "virtualscroll:tap-scroll-cancel", mr = 20, Dr = 250, Ar = 60, Lr = 20, Or = 20, Tr = {
316
335
  /** 速度が最大に達する引き距離 (px)。`maxVisualDistance` の既定値。 */
317
336
  maxDistance: 240,
318
337
  /** 最小速度倍率 (ビューポート比)。 */
319
338
  minSpeedMultiplier: 0.2
320
- }, Rr = pr.maxDistance, ir = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0, pointerId: null }, Wt = 2.2, Er = 8, Nr = 120, Vr = 1 / 10, dt = {
339
+ }, _r = Tr.maxDistance, pr = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0, pointerId: null }, Zt = 2.2, kr = 8, Fr = 120, Yr = 1 / 10, dt = {
321
340
  enabled: !0,
322
341
  size: 40,
323
342
  offsetX: -80,
324
343
  offsetY: 0,
325
344
  className: void 0,
326
- maxVisualDistance: Rr,
327
- minSpeedMultiplier: pr.minSpeedMultiplier,
345
+ maxVisualDistance: _r,
346
+ minSpeedMultiplier: Tr.minSpeedMultiplier,
328
347
  opacity: 0.9,
329
348
  renderVisual: void 0,
330
349
  maxSpeedCurve: void 0
331
- }, Cr = (r) => r ? {
350
+ }, Br = (r) => r ? {
332
351
  mainSizeKey: "width",
333
352
  crossSizeKey: "height",
334
353
  positionKey: "left",
@@ -348,8 +367,8 @@ const le = (r, e, t) => Math.max(e, Math.min(t, r)), Gt = "virtualscroll:tap-scr
348
367
  arrowIcons: ["▲", "▼"],
349
368
  directionClass: "aqvs-scrollbar-vertical",
350
369
  orientation: "vertical"
351
- }, zr = (r, e) => {
352
- const t = r?.maxSpeedMultiplier, n = typeof t == "number" ? t : _r(e);
370
+ }, Hr = (r, e) => {
371
+ const t = r?.maxSpeedMultiplier, n = typeof t == "number" ? t : Wr(e);
353
372
  return {
354
373
  enabled: r?.enabled ?? dt.enabled,
355
374
  size: r?.size ?? dt.size,
@@ -359,503 +378,503 @@ const le = (r, e, t) => Math.max(e, Math.min(t, r)), Gt = "virtualscroll:tap-scr
359
378
  maxVisualDistance: r?.maxVisualDistance ?? dt.maxVisualDistance,
360
379
  maxSpeedMultiplier: n,
361
380
  minSpeedMultiplier: Math.max(r?.minSpeedMultiplier ?? dt.minSpeedMultiplier, 0),
362
- opacity: le(r?.opacity ?? dt.opacity, 0, 1),
381
+ opacity: se(r?.opacity ?? dt.opacity, 0, 1),
363
382
  renderVisual: r?.renderVisual ?? dt.renderVisual,
364
383
  maxSpeedCurve: r?.maxSpeedCurve ?? dt.maxSpeedCurve
365
384
  };
366
- }, Dr = ({ isDragging: r, isThumbHovered: e, enableThumbDrag: t }) => Fe(() => t ? r ? "dragging" : e ? "hover" : "idle" : "disabled", [t, r, e]), Ar = ({ canUseArrowButtons: r, enableArrowButtons: e, resetTapScroll: t, scrollByStep: n }) => {
367
- const i = g(null), s = g(null), a = g(null), c = I(() => {
368
- i.current !== null && (window.clearInterval(i.current), i.current = null), s.current !== null && (window.clearTimeout(s.current), s.current = null), a.current !== null && (window.removeEventListener("pointerup", a.current), window.removeEventListener("pointercancel", a.current), window.removeEventListener("blur", a.current), a.current = null);
369
- }, []), f = I(() => {
370
- c();
371
- }, [c]), b = I(
372
- (w) => (V) => {
385
+ }, qr = ({ isDragging: r, isThumbHovered: e, enableThumbDrag: t }) => _e(() => t ? r ? "dragging" : e ? "hover" : "idle" : "disabled", [t, r, e]), Xr = ({ canUseArrowButtons: r, enableArrowButtons: e, resetTapScroll: t, scrollByStep: n }) => {
386
+ const i = g(null), s = g(null), l = g(null), d = S(() => {
387
+ i.current !== null && (window.clearInterval(i.current), i.current = null), s.current !== null && (window.clearTimeout(s.current), s.current = null), l.current !== null && (window.removeEventListener("pointerup", l.current), window.removeEventListener("pointercancel", l.current), window.removeEventListener("blur", l.current), l.current = null);
388
+ }, []), m = S(() => {
389
+ d();
390
+ }, [d]), b = S(
391
+ (T) => (C) => {
373
392
  if (!r)
374
393
  return;
375
- V.cancelable && V.preventDefault(), V.stopPropagation(), t(), c(), n(w), s.current = window.setTimeout(() => {
394
+ C.cancelable && C.preventDefault(), C.stopPropagation(), t(), d(), n(T), s.current = window.setTimeout(() => {
376
395
  i.current = window.setInterval(() => {
377
- n(w);
378
- }, Pr);
379
- }, Tr);
380
- const h = () => c();
381
- a.current = h, window.addEventListener("pointerup", h), window.addEventListener("pointercancel", h), window.addEventListener("blur", h);
396
+ n(T);
397
+ }, Ar);
398
+ }, Dr);
399
+ const h = () => d();
400
+ l.current = h, window.addEventListener("pointerup", h), window.addEventListener("pointercancel", h), window.addEventListener("blur", h);
382
401
  },
383
- [r, c, t, n]
384
- ), S = I(
385
- (w) => (V) => {
386
- e && (V.key === "Enter" || V.key === " " || V.key === "Spacebar") && (V.preventDefault(), n(w));
402
+ [r, d, t, n]
403
+ ), v = S(
404
+ (T) => (C) => {
405
+ e && (C.key === "Enter" || C.key === " " || C.key === "Spacebar") && (C.preventDefault(), n(T));
387
406
  },
388
407
  [e, n]
389
408
  );
390
- return q(() => {
391
- r || c();
392
- }, [r, c]), q(() => () => {
393
- c();
394
- }, [c]), { handleArrowPointerDown: b, handleArrowPointerUp: f, handleArrowKeyDown: S };
395
- }, Lr = 700, St = (r, e) => typeof r == "number" && Number.isFinite(r) ? r : e, Or = ({ distance: r, maxDistance: e, viewportSize: t, minSpeedMultiplier: n, maxSpeedMultiplier: i, hasCustomMaxSpeedMultiplier: s, curve: a }) => {
396
- const c = Math.max(St(r, 0), 0), f = St(e, 0), b = f > 0 ? Math.min(c, f) / f : 1, S = Math.max(St(t, 0), 0), w = Math.max(St(n, 0), 0), V = Math.max(St(i, 0), 0), h = Math.max(S * w, 40), C = s ? h : 1200, G = Math.max(S * V, C), H = a ? Math.max(St(a.exponentialScale, V), 0) : 0, pe = a ? Math.min(G, Math.max(S * H, h)) : G, me = Math.max(pe, h);
397
- let oe = b ** 1.1;
398
- if (a) {
399
- const he = Math.min(Math.max(St(a.exponentialSteepness, 0), 0), Lr);
400
- if (he === 0)
401
- oe = b;
409
+ return X(() => {
410
+ r || d();
411
+ }, [r, d]), X(() => () => {
412
+ d();
413
+ }, [d]), { handleArrowPointerDown: b, handleArrowPointerUp: m, handleArrowKeyDown: v };
414
+ }, $r = 700, It = (r, e) => typeof r == "number" && Number.isFinite(r) ? r : e, Ur = ({ distance: r, maxDistance: e, viewportSize: t, minSpeedMultiplier: n, maxSpeedMultiplier: i, hasCustomMaxSpeedMultiplier: s, curve: l }) => {
415
+ const d = Math.max(It(r, 0), 0), m = It(e, 0), b = m > 0 ? Math.min(d, m) / m : 1, v = Math.max(It(t, 0), 0), T = Math.max(It(n, 0), 0), C = Math.max(It(i, 0), 0), h = Math.max(v * T, 40), O = s ? h : 1200, W = Math.max(v * C, O), D = l ? Math.max(It(l.exponentialScale, C), 0) : 0, ce = l ? Math.min(W, Math.max(v * D, h)) : W, ue = Math.max(ce, h);
416
+ let re = b ** 1.1;
417
+ if (l) {
418
+ const de = Math.min(Math.max(It(l.exponentialSteepness, 0), 0), $r);
419
+ if (de === 0)
420
+ re = b;
402
421
  else {
403
- const P = Math.expm1(he) || 1;
404
- oe = Math.min(Math.max(Math.expm1(he * b) / P, 0), 1);
422
+ const y = Math.expm1(de) || 1;
423
+ re = Math.min(Math.max(Math.expm1(de * b) / y, 0), 1);
405
424
  }
406
425
  }
407
- const ce = Math.min(Math.max(St(a?.easedOffset, 0), 0), 1);
408
- return h + (me - h) * (ce + (1 - ce) * oe);
409
- }, _r = (r) => {
426
+ const oe = Math.min(Math.max(It(l?.easedOffset, 0), 0), 1);
427
+ return h + (ue - h) * (oe + (1 - oe) * re);
428
+ }, Wr = (r) => {
410
429
  if (!r || r <= 0)
411
- return Wt;
412
- const e = Math.max(1, r), t = Math.log10(e), n = Wt + t * Er;
413
- return le(n, Wt, Nr);
414
- }, kr = ({
430
+ return Zt;
431
+ const e = Math.max(1, r), t = Math.log10(e), n = Zt + t * kr;
432
+ return se(n, Zt, Fr);
433
+ }, Kr = ({
415
434
  contentSize: r,
416
435
  viewportSize: e,
417
436
  scrollPosition: t,
418
437
  onScroll: n,
419
438
  enableThumbDrag: i = !0,
420
439
  enableTrackClick: s = !0,
421
- enableArrowButtons: a = !0,
422
- horizontal: c = !1,
423
- scrollBarWidth: f = 12,
440
+ enableArrowButtons: l = !0,
441
+ horizontal: d = !1,
442
+ scrollBarWidth: m = 12,
424
443
  className: b,
425
- ariaControls: S,
426
- tapScrollCircleOptions: w,
427
- itemCount: V,
444
+ ariaControls: v,
445
+ tapScrollCircleOptions: T,
446
+ itemCount: C,
428
447
  renderThumbOverlay: h,
429
- visibleStartIndex: C,
430
- visibleEndIndex: G
448
+ visibleStartIndex: O,
449
+ visibleEndIndex: W
431
450
  }) => {
432
- const [H, pe] = rt(!1), [me, oe] = rt(!1), [ce, he] = rt(!1), P = g(null), _ = g({
451
+ const [D, ce] = Je(!1), [ue, re] = Je(!1), [oe, de] = Je(!1), y = g(null), Y = g({
433
452
  pointerId: null,
434
453
  startThumbPosition: 0,
435
454
  startClientX: 0,
436
455
  startClientY: 0,
437
456
  scale: 1,
438
457
  captureTarget: null
439
- }), M = g({ pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0, scale: 1 }), Z = g(t), Q = g(n), W = g(ir), Ie = g(null), z = g(null), v = g(null), U = g(0), ge = g(0), qe = Fe(() => zr(w, V), [V, w]), ee = Fe(() => Cr(c), [c]), {
440
- enabled: X,
441
- size: Xe,
442
- offsetX: $e,
443
- offsetY: Ce,
444
- className: ze,
445
- maxVisualDistance: je,
446
- maxSpeedMultiplier: Ge,
447
- minSpeedMultiplier: K,
448
- opacity: Ae,
449
- renderVisual: ue,
450
- maxSpeedCurve: be
451
- } = qe, Te = g({
458
+ }), w = g({ pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0, scale: 1 }), Z = g(t), Q = g(n), K = g(pr), he = g(null), A = g(null), I = g(null), G = g(0), fe = g(0), $e = _e(() => Hr(T, C), [C, T]), Ue = _e(() => Br(d), [d]), {
459
+ enabled: z,
460
+ size: ke,
461
+ offsetX: We,
462
+ offsetY: Ve,
463
+ className: Fe,
464
+ maxVisualDistance: Ke,
465
+ maxSpeedMultiplier: De,
466
+ minSpeedMultiplier: Pe,
467
+ opacity: ze,
468
+ renderVisual: be,
469
+ maxSpeedCurve: Se
470
+ } = $e, j = g({
452
471
  viewportSize: e,
453
472
  maxScrollPosition: Math.max(r - e, 0),
454
473
  scrollBarVisible: r > e,
455
- effectiveTapMaxDistance: Math.max(je, 1),
456
- tapCircleMaxSpeedMultiplier: Ge,
457
- tapCircleMinSpeedMultiplier: K,
458
- tapCircleMaxSpeedCurve: be,
459
- tapScrollCircleOptions: w,
474
+ effectiveTapMaxDistance: Math.max(Ke, 1),
475
+ tapCircleMaxSpeedMultiplier: De,
476
+ tapCircleMinSpeedMultiplier: Pe,
477
+ tapCircleMaxSpeedCurve: Se,
478
+ tapScrollCircleOptions: T,
460
479
  effectiveTrackLength: 0,
461
480
  onScroll: n,
462
481
  scrollPosition: t
463
- }), { mainSizeKey: et, crossSizeKey: mt, positionKey: N, selectDelta: it, getPointerCoordinate: vt, arrowLabels: E, arrowIcons: J, directionClass: Ze, orientation: ht } = ee, Le = Math.max(je, 1), st = e / r, ie = Math.max(e - f * 2, 0), p = st * ie, F = Math.min(Math.max(nr, p || 0), ie || nr), B = r - e, Y = Math.max(ie - F, 0), te = B <= 0 || Y <= 0 ? 0 : le(t / B * Y, 0, Y), Me = te + F / 2, j = r > e || H, re = j && a;
464
- nt(() => {
465
- Te.current = {
482
+ }), { mainSizeKey: tt, crossSizeKey: Ge, positionKey: ft, selectDelta: st, getPointerCoordinate: N, arrowLabels: gt, arrowIcons: ne, directionClass: V, orientation: ot } = Ue, je = Math.max(Ke, 1), mt = e / r, Ae = Math.max(e - m * 2, 0), f = mt * Ae, M = Math.min(Math.max(mr, f || 0), Ae || mr), q = r - e, H = Math.max(Ae - M, 0), J = q <= 0 || H <= 0 ? 0 : se(t / q * H, 0, H), Te = J + M / 2, ee = r > e || D, xe = ee && l;
483
+ et(() => {
484
+ j.current = {
466
485
  viewportSize: e,
467
- maxScrollPosition: B,
468
- scrollBarVisible: j,
469
- effectiveTapMaxDistance: Le,
470
- tapCircleMaxSpeedMultiplier: Ge,
471
- tapCircleMinSpeedMultiplier: K,
472
- tapCircleMaxSpeedCurve: be,
473
- tapScrollCircleOptions: w,
474
- effectiveTrackLength: Y,
486
+ maxScrollPosition: q,
487
+ scrollBarVisible: ee,
488
+ effectiveTapMaxDistance: je,
489
+ tapCircleMaxSpeedMultiplier: De,
490
+ tapCircleMinSpeedMultiplier: Pe,
491
+ tapCircleMaxSpeedCurve: Se,
492
+ tapScrollCircleOptions: T,
493
+ effectiveTrackLength: H,
475
494
  onScroll: n,
476
495
  scrollPosition: t
477
496
  };
478
- }), nt(() => {
497
+ }), et(() => {
479
498
  Z.current = t;
480
- }, [t]), nt(() => {
499
+ }, [t]), et(() => {
481
500
  Q.current = n;
482
- }, [n]), q(() => {
483
- i || oe(!1);
501
+ }, [n]), X(() => {
502
+ i || re(!1);
484
503
  }, [i]);
485
- const De = Dr({ isDragging: H, isThumbHovered: me, enableThumbDrag: i }), ne = I((l, x) => {
486
- const R = Te.current, D = x ?? Z.current;
504
+ const ye = qr({ isDragging: D, isThumbHovered: ue, enableThumbDrag: i }), $ = S((a, x) => {
505
+ const E = j.current, L = x ?? Z.current;
487
506
  if (Q.current) {
488
- const Ee = Q.current(l, D);
489
- if (typeof Ee == "number" && Number.isFinite(Ee))
490
- return Z.current = Ee, Ee;
507
+ const He = Q.current(a, L);
508
+ if (typeof He == "number" && Number.isFinite(He))
509
+ return Z.current = He, He;
491
510
  }
492
- const $ = typeof l == "function" ? l(D) : l, ye = Math.max(R.maxScrollPosition, 0), Re = R.scrollBarVisible ? le($, 0, ye) : 0;
493
- return Z.current = Re, Re;
494
- }, []), Je = I(
495
- (l) => {
496
- const x = Te.current, R = Z.current;
511
+ const U = typeof a == "function" ? a(L) : a, ve = Math.max(E.maxScrollPosition, 0), Be = E.scrollBarVisible ? se(U, 0, ve) : 0;
512
+ return Z.current = Be, Be;
513
+ }, []), Re = S(
514
+ (a) => {
515
+ const x = j.current, E = Z.current;
497
516
  if (!x.scrollBarVisible || x.maxScrollPosition <= 0) {
498
- const Ye = ne(0, R), xt = Ye - R;
499
- return { nextPosition: Ye, actualDelta: xt, reachedBoundary: !0 };
517
+ const Ze = $(0, E), pt = Ze - E;
518
+ return { nextPosition: Ze, actualDelta: pt, reachedBoundary: !0 };
500
519
  }
501
- if (l === 0)
502
- return { nextPosition: R, actualDelta: 0, reachedBoundary: !1 };
503
- const $ = ne((Ye) => le(Ye + l, 0, x.maxScrollPosition), R), ye = $ - R, Re = l < 0 && R + l <= 0, Ee = l > 0 && R + l >= x.maxScrollPosition, lt = l < 0 && ($ <= 0 || Re && ye === 0) || l > 0 && ($ >= x.maxScrollPosition || Ee && ye === 0);
504
- return { nextPosition: $, actualDelta: ye, reachedBoundary: lt };
520
+ if (a === 0)
521
+ return { nextPosition: E, actualDelta: 0, reachedBoundary: !1 };
522
+ const U = $((Ze) => se(Ze + a, 0, x.maxScrollPosition), E), ve = U - E, Be = a < 0 && E + a <= 0, He = a > 0 && E + a >= x.maxScrollPosition, lt = a < 0 && (U <= 0 || Be && ve === 0) || a > 0 && (U >= x.maxScrollPosition || He && ve === 0);
523
+ return { nextPosition: U, actualDelta: ve, reachedBoundary: lt };
505
524
  },
506
- [ne]
507
- ), Oe = I(
508
- (l, x) => {
509
- l.current += x;
510
- const R = Math.max(Te.current.maxScrollPosition, 0);
511
- R > 0 && (l.current = le(l.current, -R, R));
512
- const D = Je(l.current);
513
- return l.current -= D.actualDelta, D.reachedBoundary && (l.current = 0), D;
525
+ [$]
526
+ ), Ce = S(
527
+ (a, x) => {
528
+ a.current += x;
529
+ const E = Math.max(j.current.maxScrollPosition, 0);
530
+ E > 0 && (a.current = se(a.current, -E, E));
531
+ const L = Re(a.current);
532
+ return a.current -= L.actualDelta, L.reachedBoundary && (a.current = 0), L;
514
533
  },
515
- [Je]
516
- ), ae = I(() => {
517
- z.current !== null && (window.cancelAnimationFrame(z.current), z.current = null), v.current = null, U.current = 0, ge.current = 0;
518
- }, []), ve = I(() => {
519
- W.current = { ...ir }, he(!1), Ie.current?.reset(), ae();
520
- }, [ae]), We = I(
521
- (l) => {
522
- const x = W.current, R = Te.current;
534
+ [Re]
535
+ ), me = S(() => {
536
+ A.current !== null && (window.cancelAnimationFrame(A.current), A.current = null), I.current = null, G.current = 0, fe.current = 0;
537
+ }, []), Ee = S(() => {
538
+ K.current = { ...pr }, de(!1), he.current?.reset(), me();
539
+ }, [me]), rt = S(
540
+ (a) => {
541
+ const x = K.current, E = j.current;
523
542
  if (!x.active || x.direction === 0) {
524
- ae();
543
+ me();
525
544
  return;
526
545
  }
527
- if (!R.scrollBarVisible || R.maxScrollPosition <= 0) {
528
- ae();
546
+ if (!E.scrollBarVisible || E.maxScrollPosition <= 0) {
547
+ me();
529
548
  return;
530
549
  }
531
- const D = v.current ?? l, $ = Math.max((l - D) / 1e3, 0), ye = Math.min($, Vr);
532
- if (v.current = l, ye <= 0) {
533
- z.current = window.requestAnimationFrame(We);
550
+ const L = I.current ?? a, U = Math.max((a - L) / 1e3, 0), ve = Math.min(U, Yr);
551
+ if (I.current = a, ve <= 0) {
552
+ A.current = window.requestAnimationFrame(rt);
534
553
  return;
535
554
  }
536
- const Re = Or({
555
+ const Be = Ur({
537
556
  distance: x.distance,
538
- maxDistance: R.effectiveTapMaxDistance,
539
- viewportSize: R.viewportSize,
540
- minSpeedMultiplier: R.tapCircleMinSpeedMultiplier,
541
- maxSpeedMultiplier: R.tapCircleMaxSpeedMultiplier,
542
- hasCustomMaxSpeedMultiplier: typeof R.tapScrollCircleOptions?.maxSpeedMultiplier == "number",
543
- curve: R.tapCircleMaxSpeedCurve
557
+ maxDistance: E.effectiveTapMaxDistance,
558
+ viewportSize: E.viewportSize,
559
+ minSpeedMultiplier: E.tapCircleMinSpeedMultiplier,
560
+ maxSpeedMultiplier: E.tapCircleMaxSpeedMultiplier,
561
+ hasCustomMaxSpeedMultiplier: typeof E.tapScrollCircleOptions?.maxSpeedMultiplier == "number",
562
+ curve: E.tapCircleMaxSpeedCurve
544
563
  });
545
- ge.current !== x.direction && (ge.current = x.direction, U.current = 0);
546
- const { reachedBoundary: Ee } = Oe(U, x.direction * Re * ye);
547
- if (Ee) {
548
- ae();
564
+ fe.current !== x.direction && (fe.current = x.direction, G.current = 0);
565
+ const { reachedBoundary: He } = Ce(G, x.direction * Be * ve);
566
+ if (He) {
567
+ me();
549
568
  return;
550
569
  }
551
- z.current = window.requestAnimationFrame(We);
570
+ A.current = window.requestAnimationFrame(rt);
552
571
  },
553
- [Oe, ae]
554
- ), Ve = I(() => {
555
- z.current === null && (v.current = null, U.current = 0, z.current = window.requestAnimationFrame(We));
556
- }, [We]);
557
- q(() => {
558
- const l = W.current;
559
- !l.active || l.direction === 0 || Ve();
560
- }, [r, e, Ve]), q(() => () => {
561
- ae();
562
- }, [ae]);
563
- const ft = I(
564
- (l) => {
565
- W.current = l, he(l.active), l.active && l.direction !== 0 ? Ve() : ae();
572
+ [Ce, me]
573
+ ), Le = S(() => {
574
+ A.current === null && (I.current = null, G.current = 0, A.current = window.requestAnimationFrame(rt));
575
+ }, [rt]);
576
+ X(() => {
577
+ const a = K.current;
578
+ !a.active || a.direction === 0 || Le();
579
+ }, [r, e, Le]), X(() => () => {
580
+ me();
581
+ }, [me]);
582
+ const at = S(
583
+ (a) => {
584
+ K.current = a, de(a.active), a.active && a.direction !== 0 ? Le() : me();
566
585
  },
567
- [Ve, ae]
586
+ [Le, me]
568
587
  );
569
- q(() => {
570
- X || ve();
571
- }, [ve, X]), q(() => {
572
- const l = (x) => {
573
- const D = x.detail?.paneId;
574
- D && S && D !== S || ve();
588
+ X(() => {
589
+ z || Ee();
590
+ }, [Ee, z]), X(() => {
591
+ const a = (x) => {
592
+ const L = x.detail?.paneId;
593
+ L && v && L !== v || Ee();
575
594
  };
576
- return window.addEventListener(Gt, l), () => {
577
- window.removeEventListener(Gt, l);
595
+ return window.addEventListener(tr, a), () => {
596
+ window.removeEventListener(tr, a);
578
597
  };
579
- }, [S, ve]), q(() => {
580
- if (!X)
598
+ }, [v, Ee]), X(() => {
599
+ if (!z)
581
600
  return;
582
- const l = (x) => {
583
- if (!W.current.active || W.current.pointerId === x.pointerId)
601
+ const a = (x) => {
602
+ if (!K.current.active || K.current.pointerId === x.pointerId)
584
603
  return;
585
- const R = x.target;
586
- if (!(R instanceof Node)) {
587
- ve();
604
+ const E = x.target;
605
+ if (!(E instanceof Node)) {
606
+ Ee();
588
607
  return;
589
608
  }
590
- Ie.current?.getElement()?.contains(R) || ve();
609
+ he.current?.getElement()?.contains(E) || Ee();
591
610
  };
592
- return document.addEventListener("pointerdown", l, !0), () => {
593
- document.removeEventListener("pointerdown", l, !0);
611
+ return document.addEventListener("pointerdown", a, !0), () => {
612
+ document.removeEventListener("pointerdown", a, !0);
594
613
  };
595
- }, [ve, X]);
596
- const Qe = (l) => {
597
- if (!j || Y <= 0 || B <= 0)
614
+ }, [Ee, z]);
615
+ const Me = (a) => {
616
+ if (!ee || H <= 0 || q <= 0)
598
617
  return 0;
599
- const x = le(l, 0, Y);
600
- return le(x / Y * B, 0, B);
601
- }, ot = I((l) => {
602
- const { scrollBarVisible: x, effectiveTrackLength: R, maxScrollPosition: D } = Te.current;
603
- if (T.debug("[ScrollBar] calculateScrollPositionFromThumb", () => ({ thumbPos: l, trackLen: R, maxScroll: D })), R <= 0 || D <= 0)
618
+ const x = se(a, 0, H);
619
+ return se(x / H * q, 0, q);
620
+ }, nt = S((a) => {
621
+ const { scrollBarVisible: x, effectiveTrackLength: E, maxScrollPosition: L } = j.current;
622
+ if (P.debug("[ScrollBar] calculateScrollPositionFromThumb", () => ({ thumbPos: a, trackLen: E, maxScroll: L })), E <= 0 || L <= 0)
604
623
  return null;
605
- const $ = le(l, 0, R);
606
- return le($ / R * D, 0, D);
607
- }, []), d = I(
608
- (l) => {
609
- const x = l.getBoundingClientRect(), R = c ? x.width : x.height, D = (lt) => {
610
- const Ye = Number.parseFloat(lt);
611
- return Number.isFinite(Ye) ? Ye : 0;
612
- }, $ = window.getComputedStyle(l), ye = D(c ? $.width : $.height), Re = ye > 0 ? ye + D(c ? $.paddingLeft : $.paddingTop) + D(c ? $.paddingRight : $.paddingBottom) + D(c ? $.borderLeftWidth : $.borderTopWidth) + D(c ? $.borderRightWidth : $.borderBottomWidth) : 0, Ee = Re > 0 ? Re : c ? l.offsetWidth : l.offsetHeight;
613
- return Ee <= 0 || R <= 0 ? 1 : R / Ee;
624
+ const U = se(a, 0, E);
625
+ return se(U / E * L, 0, L);
626
+ }, []), p = S(
627
+ (a) => {
628
+ const x = a.getBoundingClientRect(), E = d ? x.width : x.height, L = (lt) => {
629
+ const Ze = Number.parseFloat(lt);
630
+ return Number.isFinite(Ze) ? Ze : 0;
631
+ }, U = window.getComputedStyle(a), ve = L(d ? U.width : U.height), Be = ve > 0 ? ve + L(d ? U.paddingLeft : U.paddingTop) + L(d ? U.paddingRight : U.paddingBottom) + L(d ? U.borderLeftWidth : U.borderTopWidth) + L(d ? U.borderRightWidth : U.borderBottomWidth) : 0, He = Be > 0 ? Be : d ? a.offsetWidth : a.offsetHeight;
632
+ return He <= 0 || E <= 0 ? 1 : E / He;
614
633
  },
615
- [c]
616
- ), y = I(
617
- (l) => {
618
- const x = _.current;
619
- if (x.pointerId !== l.pointerId)
634
+ [d]
635
+ ), R = S(
636
+ (a) => {
637
+ const x = Y.current;
638
+ if (x.pointerId !== a.pointerId)
620
639
  return;
621
- const R = l.clientX - x.startClientX, D = l.clientY - x.startClientY, $ = it(R, D) / (x.scale || 1);
622
- T.debug("[ScrollBar] handleThumbPointerMove", () => ({
623
- delta: $,
640
+ const E = a.clientX - x.startClientX, L = a.clientY - x.startClientY, U = st(E, L) / (x.scale || 1);
641
+ P.debug("[ScrollBar] handleThumbPointerMove", () => ({
642
+ delta: U,
624
643
  startThumbPosition: x.startThumbPosition,
625
- clientY: l.clientY,
644
+ clientY: a.clientY,
626
645
  startClientY: x.startClientY,
627
- metrics: Te.current
646
+ metrics: j.current
628
647
  }));
629
- const ye = ot(x.startThumbPosition + $);
630
- ye !== null && ne(ye), l.cancelable && l.preventDefault();
648
+ const ve = nt(x.startThumbPosition + U);
649
+ ve !== null && $(ve), a.cancelable && a.preventDefault();
631
650
  },
632
- [it, ot, ne]
633
- ), xe = I(
634
- (l) => {
635
- const x = _.current;
636
- if (x.pointerId !== l.pointerId)
651
+ [st, nt, $]
652
+ ), ae = S(
653
+ (a) => {
654
+ const x = Y.current;
655
+ if (x.pointerId !== a.pointerId)
637
656
  return;
638
- document.removeEventListener("pointermove", y), document.removeEventListener("pointerup", xe), document.removeEventListener("pointercancel", xe);
639
- const R = x.captureTarget;
640
- if (R?.hasPointerCapture?.(l.pointerId) && R.releasePointerCapture(l.pointerId), _.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0, scale: 1, captureTarget: null }, pe(!1), P.current) {
641
- const D = P.current.getBoundingClientRect();
642
- l.clientX >= D.left && l.clientX <= D.right && l.clientY >= D.top && l.clientY <= D.bottom || oe(!1);
657
+ document.removeEventListener("pointermove", R), document.removeEventListener("pointerup", ae), document.removeEventListener("pointercancel", ae);
658
+ const E = x.captureTarget;
659
+ if (E?.hasPointerCapture?.(a.pointerId) && E.releasePointerCapture(a.pointerId), Y.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0, scale: 1, captureTarget: null }, ce(!1), y.current) {
660
+ const L = y.current.getBoundingClientRect();
661
+ a.clientX >= L.left && a.clientX <= L.right && a.clientY >= L.top && a.clientY <= L.bottom || re(!1);
643
662
  } else
644
- oe(!1);
663
+ re(!1);
645
664
  },
646
- [y]
665
+ [R]
647
666
  );
648
- q(() => () => {
649
- document.removeEventListener("pointermove", y), document.removeEventListener("pointerup", xe), document.removeEventListener("pointercancel", xe);
650
- }, [y, xe]);
651
- const tt = g(0), _e = g(0), ct = I(
652
- (l) => {
653
- const x = Math.max(Math.round(Te.current.viewportSize / yr), Mr);
654
- _e.current !== l && (_e.current = l, tt.current = 0), Oe(tt, l * x);
667
+ X(() => () => {
668
+ document.removeEventListener("pointermove", R), document.removeEventListener("pointerup", ae), document.removeEventListener("pointercancel", ae);
669
+ }, [R, ae]);
670
+ const it = g(0), Ne = g(0), zt = S(
671
+ (a) => {
672
+ const x = Math.max(Math.round(j.current.viewportSize / Or), Lr);
673
+ Ne.current !== a && (Ne.current = a, it.current = 0), Ce(it, a * x);
655
674
  },
656
- [Oe]
657
- ), { handleArrowPointerDown: ut, handleArrowPointerUp: at, handleArrowKeyDown: gt } = Ar({
658
- canUseArrowButtons: re,
659
- enableArrowButtons: a,
660
- resetTapScroll: ve,
661
- scrollByStep: ct
662
- }), pt = (l) => {
663
- if (!j)
675
+ [Ce]
676
+ ), { handleArrowPointerDown: ct, handleArrowPointerUp: Ye, handleArrowKeyDown: bt } = Xr({
677
+ canUseArrowButtons: xe,
678
+ enableArrowButtons: l,
679
+ resetTapScroll: Ee,
680
+ scrollByStep: zt
681
+ }), Pt = (a) => {
682
+ if (!ee)
664
683
  return;
665
684
  if (!i) {
666
- l.preventDefault(), l.stopPropagation();
685
+ a.preventDefault(), a.stopPropagation();
667
686
  return;
668
687
  }
669
- if (l.pointerType === "mouse" && l.button !== 0 || l.ctrlKey)
688
+ if (a.pointerType === "mouse" && a.button !== 0 || a.ctrlKey)
670
689
  return;
671
- ve();
672
- const x = l.currentTarget, R = d(x);
673
- let D = null;
690
+ Ee();
691
+ const x = a.currentTarget, E = p(x);
692
+ let L = null;
674
693
  if (x.setPointerCapture)
675
694
  try {
676
- x.setPointerCapture(l.pointerId), D = x;
695
+ x.setPointerCapture(a.pointerId), L = x;
677
696
  } catch {
678
- D = null;
697
+ L = null;
679
698
  }
680
- _.current = {
681
- pointerId: l.pointerId,
682
- startThumbPosition: te,
683
- startClientX: l.clientX,
684
- startClientY: l.clientY,
685
- scale: R,
686
- captureTarget: D
687
- }, document.addEventListener("pointermove", y), document.addEventListener("pointerup", xe), document.addEventListener("pointercancel", xe), pe(!0), oe(!0), l.preventDefault(), l.stopPropagation();
688
- }, yt = (l) => {
689
- if (!j)
699
+ Y.current = {
700
+ pointerId: a.pointerId,
701
+ startThumbPosition: J,
702
+ startClientX: a.clientX,
703
+ startClientY: a.clientY,
704
+ scale: E,
705
+ captureTarget: L
706
+ }, document.addEventListener("pointermove", R), document.addEventListener("pointerup", ae), document.addEventListener("pointercancel", ae), ce(!0), re(!0), a.preventDefault(), a.stopPropagation();
707
+ }, Ft = (a) => {
708
+ if (!ee)
690
709
  return;
691
710
  if (!s) {
692
- l.preventDefault(), l.stopPropagation();
711
+ a.preventDefault(), a.stopPropagation();
693
712
  return;
694
713
  }
695
- if (l.pointerType === "mouse" && l.button !== 0 || l.ctrlKey)
714
+ if (a.pointerType === "mouse" && a.button !== 0 || a.ctrlKey)
696
715
  return;
697
- const x = l.currentTarget, R = x.getBoundingClientRect(), D = vt(l), $ = d(x), ye = (D - (c ? R.left : R.top)) / $;
698
- ve();
699
- const Re = ye - F / 2, Ee = Qe(Re);
700
- if (ne(Ee), x.setPointerCapture)
716
+ const x = a.currentTarget, E = x.getBoundingClientRect(), L = N(a), U = p(x), ve = (L - (d ? E.left : E.top)) / U;
717
+ Ee();
718
+ const Be = ve - M / 2, He = Me(Be);
719
+ if ($(He), x.setPointerCapture)
701
720
  try {
702
- x.setPointerCapture(l.pointerId);
721
+ x.setPointerCapture(a.pointerId);
703
722
  } catch {
704
723
  }
705
- M.current = {
706
- pointerId: l.pointerId,
707
- startThumbPosition: Re,
708
- startClientX: l.clientX,
709
- startClientY: l.clientY,
710
- scale: $
711
- }, l.preventDefault(), l.stopPropagation();
712
- }, wt = () => {
713
- M.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0, scale: 1 };
714
- }, Nt = (l) => {
715
- const x = M.current;
716
- if (x.pointerId !== l.pointerId)
724
+ w.current = {
725
+ pointerId: a.pointerId,
726
+ startThumbPosition: Be,
727
+ startClientX: a.clientX,
728
+ startClientY: a.clientY,
729
+ scale: U
730
+ }, a.preventDefault(), a.stopPropagation();
731
+ }, ut = () => {
732
+ w.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0, scale: 1 };
733
+ }, yt = (a) => {
734
+ const x = w.current;
735
+ if (x.pointerId !== a.pointerId)
717
736
  return;
718
- if (l.pointerType === "mouse" && l.buttons === 0) {
719
- wt();
737
+ if (a.pointerType === "mouse" && a.buttons === 0) {
738
+ ut();
720
739
  return;
721
740
  }
722
- const R = l.clientX - x.startClientX, D = l.clientY - x.startClientY, $ = it(R, D) / (x.scale || 1), ye = Qe(x.startThumbPosition + $);
723
- ne(ye), l.cancelable && l.preventDefault();
724
- }, At = (l) => {
725
- if (M.current.pointerId !== l.pointerId)
741
+ const E = a.clientX - x.startClientX, L = a.clientY - x.startClientY, U = st(E, L) / (x.scale || 1), ve = Me(x.startThumbPosition + U);
742
+ $(ve), a.cancelable && a.preventDefault();
743
+ }, Yt = (a) => {
744
+ if (w.current.pointerId !== a.pointerId)
726
745
  return;
727
- const x = l.currentTarget;
728
- x.hasPointerCapture?.(l.pointerId) && x.releasePointerCapture(l.pointerId), wt(), l.preventDefault(), l.stopPropagation();
729
- }, we = (l) => {
730
- if (M.current.pointerId !== l.pointerId)
746
+ const x = a.currentTarget;
747
+ x.hasPointerCapture?.(a.pointerId) && x.releasePointerCapture(a.pointerId), ut(), a.preventDefault(), a.stopPropagation();
748
+ }, Ct = (a) => {
749
+ if (w.current.pointerId !== a.pointerId)
731
750
  return;
732
- const x = l.currentTarget;
733
- x.hasPointerCapture?.(l.pointerId) && x.releasePointerCapture(l.pointerId), wt();
734
- }, bt = (l) => {
735
- l.target === l.currentTarget && M.current.pointerId === l.pointerId && wt();
736
- }, Lt = Fe(() => le((ce ? 1 : 0.8) * Ae, 0, 1), [ce, Ae]), Ot = Fe(() => {
737
- const x = `calc(50% - ${Xe / 2}px + ${Ce}px)`;
751
+ const x = a.currentTarget;
752
+ x.hasPointerCapture?.(a.pointerId) && x.releasePointerCapture(a.pointerId), ut();
753
+ }, Bt = (a) => {
754
+ a.target === a.currentTarget && w.current.pointerId === a.pointerId && ut();
755
+ }, ge = _e(() => se((oe ? 1 : 0.8) * ze, 0, 1), [oe, ze]), xt = _e(() => {
756
+ const x = `calc(50% - ${ke / 2}px + ${Ve}px)`;
738
757
  return {
739
- left: $e,
758
+ left: We,
740
759
  top: x
741
760
  };
742
- }, [$e, Ce, Xe]), Ue = (l, x, R, D) => /* @__PURE__ */ de(
761
+ }, [We, Ve, ke]), Dt = (a, x, E, L) => /* @__PURE__ */ ie(
743
762
  "button",
744
763
  {
745
764
  type: "button",
746
765
  tabIndex: 0,
747
766
  className: "aqvs-scrollbar-arrow-button",
748
767
  style: {
749
- [et]: f,
750
- [mt]: f
768
+ [tt]: m,
769
+ [Ge]: m
751
770
  },
752
771
  "aria-label": x,
753
- onPointerDown: ut(l),
754
- onPointerUp: at,
755
- onPointerLeave: at,
756
- onPointerCancel: at,
757
- onKeyDown: gt(l),
758
- "aria-disabled": !a,
759
- disabled: !re,
760
- children: /* @__PURE__ */ de("span", { "aria-hidden": "true", children: R })
772
+ onPointerDown: ct(a),
773
+ onPointerUp: Ye,
774
+ onPointerLeave: Ye,
775
+ onPointerCancel: Ye,
776
+ onKeyDown: bt(a),
777
+ "aria-disabled": !l,
778
+ disabled: !xe,
779
+ children: /* @__PURE__ */ ie("span", { "aria-hidden": "true", children: E })
761
780
  },
762
- D
763
- ), Vt = h && j ? {
764
- orientation: ht,
781
+ L
782
+ ), At = h && ee ? {
783
+ orientation: ot,
765
784
  scrollPosition: t,
766
- maxScrollPosition: B,
785
+ maxScrollPosition: q,
767
786
  contentSize: r,
768
787
  viewportSize: e,
769
- thumbSize: F,
770
- thumbPosition: te,
771
- thumbCenter: Me,
772
- trackSize: ie,
773
- isDragging: H,
774
- isTapScrollActive: ce,
775
- visibleStartIndex: C,
776
- visibleEndIndex: G
788
+ thumbSize: M,
789
+ thumbPosition: J,
790
+ thumbCenter: Te,
791
+ trackSize: Ae,
792
+ isDragging: D,
793
+ isTapScrollActive: oe,
794
+ visibleStartIndex: O,
795
+ visibleEndIndex: W
777
796
  } : null;
778
- return /* @__PURE__ */ Mt(
797
+ return /* @__PURE__ */ Tt(
779
798
  "div",
780
799
  {
781
- className: Et("aqvs-scrollbar", Ze, b),
800
+ className: Vt("aqvs-scrollbar", V, b),
782
801
  style: {
783
- [et]: e,
784
- [mt]: f
802
+ [tt]: e,
803
+ [Ge]: m
785
804
  },
786
- "data-visible": j ? "true" : "false",
805
+ "data-visible": ee ? "true" : "false",
787
806
  role: "scrollbar",
788
807
  tabIndex: -1,
789
- "aria-controls": S,
808
+ "aria-controls": v,
790
809
  "aria-valuenow": t,
791
810
  "aria-valuemin": 0,
792
- "aria-valuemax": B,
793
- "aria-orientation": c ? "horizontal" : "vertical",
811
+ "aria-valuemax": q,
812
+ "aria-orientation": d ? "horizontal" : "vertical",
794
813
  children: [
795
- !c && j && X && /* @__PURE__ */ de(
796
- fr,
814
+ !d && ee && z && /* @__PURE__ */ ie(
815
+ Sr,
797
816
  {
798
- ref: Ie,
799
- className: Et("aqvs-scrollbar-tap-circle-wrapper", ze),
800
- size: Xe,
801
- maxVisualDistance: Le,
802
- style: Ot,
803
- opacity: Lt,
804
- renderVisual: ue,
805
- onDragChange: ft
817
+ ref: he,
818
+ className: Vt("aqvs-scrollbar-tap-circle-wrapper", Fe),
819
+ size: ke,
820
+ maxVisualDistance: je,
821
+ style: xt,
822
+ opacity: ge,
823
+ renderVisual: be,
824
+ onDragChange: at
806
825
  },
807
826
  "tap-circle"
808
827
  ),
809
- Ue(-1, E[0], J[0], "arrow-start"),
810
- /* @__PURE__ */ Mt(
828
+ Dt(-1, gt[0], ne[0], "arrow-start"),
829
+ /* @__PURE__ */ Tt(
811
830
  "div",
812
831
  {
813
832
  className: "aqvs-scrollbar-track",
814
833
  style: {
815
- borderRadius: f / 2
834
+ borderRadius: m / 2
816
835
  },
817
- onPointerDown: yt,
818
- onPointerMove: Nt,
819
- onPointerUp: At,
820
- onPointerCancel: we,
821
- onLostPointerCapture: bt,
836
+ onPointerDown: Ft,
837
+ onPointerMove: yt,
838
+ onPointerUp: Yt,
839
+ onPointerCancel: Ct,
840
+ onLostPointerCapture: Bt,
822
841
  "aria-disabled": !s,
823
842
  children: [
824
- Vt && /* @__PURE__ */ de("div", { className: "aqvs-scrollbar-overlay", "aria-hidden": !0, children: h?.(Vt) }, "overlay"),
825
- /* @__PURE__ */ de(
843
+ At && /* @__PURE__ */ ie("div", { className: "aqvs-scrollbar-overlay", "aria-hidden": !0, children: h?.(At) }, "overlay"),
844
+ /* @__PURE__ */ ie(
826
845
  "div",
827
846
  {
828
847
  className: "aqvs-scrollbar-thumb-wrapper",
829
848
  style: {
830
- [et]: F,
831
- [N]: te,
832
- ...c ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
849
+ [tt]: M,
850
+ [ft]: J,
851
+ ...d ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
833
852
  },
834
- "data-visible": j || H ? "true" : "false",
835
- onPointerDown: pt,
853
+ "data-visible": ee || D ? "true" : "false",
854
+ onPointerDown: Pt,
836
855
  role: "slider",
837
- "aria-orientation": c ? "horizontal" : "vertical",
856
+ "aria-orientation": d ? "horizontal" : "vertical",
838
857
  "aria-valuenow": t,
839
858
  "aria-valuemin": 0,
840
- "aria-valuemax": B,
859
+ "aria-valuemax": q,
841
860
  "aria-disabled": !i,
842
861
  tabIndex: -1,
843
- children: /* @__PURE__ */ de(
862
+ children: /* @__PURE__ */ ie(
844
863
  "div",
845
864
  {
846
- ref: P,
847
- className: Et("aqvs-scrollbar-thumb", c ? "aqvs-scrollbar-thumb-horizontal" : "aqvs-scrollbar-thumb-vertical"),
865
+ ref: y,
866
+ className: Vt("aqvs-scrollbar-thumb", d ? "aqvs-scrollbar-thumb-horizontal" : "aqvs-scrollbar-thumb-vertical"),
848
867
  "data-testid": "aqvs-scrollbar-thumb",
849
- "data-thumb-state": De,
868
+ "data-thumb-state": ye,
850
869
  style: {
851
- borderRadius: f - 1,
870
+ borderRadius: m - 1,
852
871
  cursor: i ? "pointer" : "default"
853
872
  },
854
873
  onMouseEnter: () => {
855
- i && oe(!0);
874
+ i && re(!0);
856
875
  },
857
876
  onMouseLeave: () => {
858
- i && oe(!1);
877
+ i && re(!1);
859
878
  }
860
879
  },
861
880
  "thumb"
@@ -867,11 +886,11 @@ const le = (r, e, t) => Math.max(e, Math.min(t, r)), Gt = "virtualscroll:tap-scr
867
886
  },
868
887
  "track"
869
888
  ),
870
- Ue(1, E[1], J[1], "arrow-end")
889
+ Dt(1, gt[1], ne[1], "arrow-end")
871
890
  ]
872
891
  }
873
892
  );
874
- }, Fr = 16, sr = (r, e, t) => e === 1 ? r * Fr : e === 2 ? r * t : r, Yr = (r, e) => {
893
+ }, Gr = 16, hr = (r, e, t) => e === 1 ? r * Gr : e === 2 ? r * t : r, jr = (r, e) => {
875
894
  const t = r.shiftKey && r.deltaX === 0, n = t ? r.deltaY : r.deltaX, i = t ? 0 : r.deltaY, s = n !== 0 && Math.abs(n) >= Math.abs(i);
876
895
  return {
877
896
  // ❗ ズームでもデルタは潰さない。ここは**事実だけ**を報告し、「横取りしない」という
@@ -880,21 +899,21 @@ const le = (r, e, t) => Math.max(e, Math.min(t, r)), Gt = "virtualscroll:tap-scr
880
899
  // どのテストも検出できなくなる (変異解析で実証済み)。
881
900
  isZoomGesture: r.ctrlKey,
882
901
  isHorizontalDominant: s,
883
- horizontalDelta: sr(n, r.deltaMode, e),
884
- verticalDelta: sr(i, r.deltaMode, e)
902
+ horizontalDelta: hr(n, r.deltaMode, e),
903
+ verticalDelta: hr(i, r.deltaMode, e)
885
904
  };
886
- }, mr = /* @__PURE__ */ new WeakSet(), or = (r) => {
887
- mr.add(r);
888
- }, Br = (r) => mr.has(r), Hr = ["mouse", "pen", "touch"], Ut = (r, e) => !(r === "mouse" || r === "pen" || r === "touch") || e.includes(r), qr = (r) => r === "mouse" || r === "pen", zt = {
905
+ }, wr = /* @__PURE__ */ new WeakSet(), gr = (r) => {
906
+ wr.add(r);
907
+ }, Zr = (r) => wr.has(r), Qr = ["mouse", "pen", "touch"], Qt = (r, e) => !(r === "mouse" || r === "pen" || r === "touch") || e.includes(r), Jr = (r) => r === "mouse" || r === "pen", _t = {
889
908
  maxVelocity: 6,
890
909
  minVelocity: 0.02,
891
910
  deceleration: 25e-4,
892
911
  velocitySampleWindow: 90,
893
912
  startVelocityThreshold: 0.04
894
- }, kt = (r, e, t) => {
913
+ }, qt = (r, e, t) => {
895
914
  for (const [n, i, s] of e)
896
915
  t === "add" ? r.addEventListener(n, i, s) : r.removeEventListener(n, i, s);
897
- }, Xr = Zt(
916
+ }, en = nr(
898
917
  ({
899
918
  children: r,
900
919
  contentSize: e,
@@ -902,240 +921,240 @@ const le = (r, e, t) => Math.max(e, Math.min(t, r)), Gt = "virtualscroll:tap-scr
902
921
  onViewportSizeChange: n,
903
922
  scrollBarWidth: i = 12,
904
923
  enableThumbDrag: s = !0,
905
- enableTrackClick: a = !0,
906
- enableArrowButtons: c = !0,
907
- enablePointerDrag: f = !0,
908
- pointerDragInputs: b = Hr,
909
- onScroll: S,
910
- className: w,
911
- testId: V,
924
+ enableTrackClick: l = !0,
925
+ enableArrowButtons: d = !0,
926
+ enablePointerDrag: m = !0,
927
+ pointerDragInputs: b = Qr,
928
+ onScroll: v,
929
+ className: T,
930
+ testId: C,
912
931
  style: h,
913
- background: C,
914
- tapScrollCircleOptions: G,
915
- inertiaOptions: H,
916
- itemCount: pe,
917
- renderThumbOverlay: me,
918
- wheelSpeedMultiplier: oe = 1,
919
- overscrollBehavior: ce = "auto",
920
- onWheelHorizontal: he,
921
- contentInsets: P,
922
- visibleStartIndex: _,
923
- visibleEndIndex: M,
932
+ background: O,
933
+ tapScrollCircleOptions: W,
934
+ inertiaOptions: D,
935
+ itemCount: ce,
936
+ renderThumbOverlay: ue,
937
+ wheelSpeedMultiplier: re = 1,
938
+ overscrollBehavior: oe = "auto",
939
+ onWheelHorizontal: de,
940
+ contentInsets: y,
941
+ visibleStartIndex: Y,
942
+ visibleEndIndex: w,
924
943
  renderOverlay: Z,
925
944
  initialScrollPosition: Q = 0,
926
- contentProps: W
927
- }, Ie) => {
928
- const z = g(Number.isFinite(Q) ? Math.max(0, Q) : 0), v = g(null), U = g(null), ge = t === void 0, [qe, ee] = rt(0), X = t ?? qe, Xe = g(null);
929
- nt(() => {
930
- if (!ge)
945
+ contentProps: K
946
+ }, he) => {
947
+ const A = g(Number.isFinite(Q) ? Math.max(0, Q) : 0), I = g(null), G = g(null), fe = t === void 0, [$e, Ue] = Je(0), z = t ?? $e, ke = g(null);
948
+ et(() => {
949
+ if (!fe)
931
950
  return;
932
- const p = U.current;
933
- if (!p)
951
+ const f = G.current;
952
+ if (!f)
934
953
  return;
935
- const F = () => {
936
- const Y = p.offsetHeight;
937
- if (Y > 0) {
938
- ee((te) => te === Y ? te : Y);
954
+ const M = () => {
955
+ const H = f.offsetHeight;
956
+ if (H > 0) {
957
+ Ue((J) => J === H ? J : H);
939
958
  return;
940
959
  }
941
- p.offsetParent !== null && e > 0 && Xe.current !== "zero" && (Xe.current = "zero", T.warn("[ScrollPane] The self-measured viewport is 0px. Give the scroll pane's host element a definite height (e.g. h-full, flex-1 + min-h-0, an explicit px height), or pass viewportSize explicitly."));
960
+ f.offsetParent !== null && e > 0 && ke.current !== "zero" && (ke.current = "zero", P.warn("[ScrollPane] The self-measured viewport is 0px. Give the scroll pane's host element a definite height (e.g. h-full, flex-1 + min-h-0, an explicit px height), or pass viewportSize explicitly."));
942
961
  };
943
- if (F(), typeof ResizeObserver != "function")
962
+ if (M(), typeof ResizeObserver != "function")
944
963
  return;
945
- const B = new ResizeObserver(F);
946
- return B.observe(p), () => {
947
- B.disconnect();
964
+ const q = new ResizeObserver(M);
965
+ return q.observe(f), () => {
966
+ q.disconnect();
948
967
  };
949
- }, [e, ge]), nt(() => {
950
- ge && n?.(qe);
951
- }, [ge, qe, n]), nt(() => {
952
- if (ge)
968
+ }, [e, fe]), et(() => {
969
+ fe && n?.($e);
970
+ }, [fe, $e, n]), et(() => {
971
+ if (fe)
953
972
  return;
954
- const p = v.current;
955
- if (!p)
973
+ const f = I.current;
974
+ if (!f)
956
975
  return;
957
- const F = () => {
958
- const Y = p.clientHeight;
959
- if (Y <= 0 || Math.abs(Y - X) <= 1)
976
+ const M = () => {
977
+ const H = f.clientHeight;
978
+ if (H <= 0 || Math.abs(H - z) <= 1)
960
979
  return;
961
- const te = `${X}/${Y}`;
962
- Xe.current !== te && (Xe.current = te, T.warn(
963
- `[ScrollPane] viewportSize=${X} but the host band is ${Y}px. The clip window, max scroll position, thumb mapping, rendered row count and scrollability all derive from viewportSize, so they are now wrong. Omit viewportSize to let the pane measure itself.`
980
+ const J = `${z}/${H}`;
981
+ ke.current !== J && (ke.current = J, P.warn(
982
+ `[ScrollPane] viewportSize=${z} but the host band is ${H}px. The clip window, max scroll position, thumb mapping, rendered row count and scrollability all derive from viewportSize, so they are now wrong. Omit viewportSize to let the pane measure itself.`
964
983
  ));
965
984
  };
966
- if (F(), typeof ResizeObserver != "function")
985
+ if (M(), typeof ResizeObserver != "function")
967
986
  return;
968
- const B = new ResizeObserver(F);
969
- return B.observe(p), () => {
970
- B.disconnect();
987
+ const q = new ResizeObserver(M);
988
+ return q.observe(f), () => {
989
+ q.disconnect();
971
990
  };
972
- }, [ge, X]);
973
- const $e = g(he);
974
- q(() => {
975
- $e.current = he;
976
- }, [he]);
977
- const Ce = g({
991
+ }, [fe, z]);
992
+ const We = g(de);
993
+ X(() => {
994
+ We.current = de;
995
+ }, [de]);
996
+ const Ve = g({
978
997
  frame: null,
979
998
  velocity: 0,
980
999
  lastTimestamp: null,
981
1000
  generation: 0
982
- }), ze = Fe(
1001
+ }), Fe = _e(
983
1002
  () => ({
984
- maxVelocity: H?.maxVelocity ?? zt.maxVelocity,
985
- minVelocity: H?.minVelocity ?? zt.minVelocity,
986
- deceleration: H?.deceleration ?? zt.deceleration,
987
- velocitySampleWindow: H?.velocitySampleWindow ?? zt.velocitySampleWindow,
988
- startVelocityThreshold: H?.startVelocityThreshold ?? zt.startVelocityThreshold
1003
+ maxVelocity: D?.maxVelocity ?? _t.maxVelocity,
1004
+ minVelocity: D?.minVelocity ?? _t.minVelocity,
1005
+ deceleration: D?.deceleration ?? _t.deceleration,
1006
+ velocitySampleWindow: D?.velocitySampleWindow ?? _t.velocitySampleWindow,
1007
+ startVelocityThreshold: D?.startVelocityThreshold ?? _t.startVelocityThreshold
989
1008
  }),
990
- [H]
991
- ), je = Fe(() => ({
992
- top: Math.max(0, P?.top ?? 0),
993
- bottom: Math.max(0, P?.bottom ?? 0)
994
- }), [P]);
995
- T.debug("[ScrollPane] ScrollPane rendered", () => ({
1009
+ [D]
1010
+ ), Ke = _e(() => ({
1011
+ top: Math.max(0, y?.top ?? 0),
1012
+ bottom: Math.max(0, y?.bottom ?? 0)
1013
+ }), [y]);
1014
+ P.debug("[ScrollPane] ScrollPane rendered", () => ({
996
1015
  contentSize: e,
997
- viewportSize: X,
1016
+ viewportSize: z,
998
1017
  scrollBarWidth: i,
999
- className: w,
1018
+ className: T,
1000
1019
  style: h,
1001
- tapScrollCircleOptions: G,
1002
- inertiaOptions: H,
1003
- enablePointerDrag: f,
1004
- contentInsets: je
1020
+ tapScrollCircleOptions: W,
1021
+ inertiaOptions: D,
1022
+ enablePointerDrag: m,
1023
+ contentInsets: Ke
1005
1024
  }));
1006
- const Ge = g({ contentSize: e, viewportSize: X }), K = Fe(() => e > X, [e, X]), Ae = I(
1007
- (p, F) => {
1008
- let B = F ?? Ge.current;
1009
- F && !(Number.isFinite(F.contentSize) && Number.isFinite(F.viewportSize)) && (T.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims", { dimsOverride: F }), B = Ge.current);
1010
- const { contentSize: Y, viewportSize: te } = B, Me = Y > te, j = z.current;
1011
- if (T.debug("[ScrollPane] scrollTo called", () => ({ newPosition: p, contentSize: Y, viewportSize: te, currentIsScrollable: Me, prevPosition: j })), !Me)
1012
- return z.current !== 0 && (z.current = 0, S?.(0, j)), z.current;
1013
- const re = typeof p == "function" ? p(z.current) : p;
1014
- if (!Number.isFinite(re))
1015
- return T.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position", { nextPosition: re }), z.current;
1016
- const De = Math.max(Y - te, 0), ne = le(re, 0, De);
1017
- return z.current !== ne && (z.current = ne, S?.(ne, j)), z.current;
1025
+ const De = g({ contentSize: e, viewportSize: z }), Pe = _e(() => e > z, [e, z]), ze = S(
1026
+ (f, M) => {
1027
+ let q = M ?? De.current;
1028
+ M && !(Number.isFinite(M.contentSize) && Number.isFinite(M.viewportSize)) && (P.warn("[ScrollPane] scrollTo received non-finite dimsOverride; falling back to the committed dims", { dimsOverride: M }), q = De.current);
1029
+ const { contentSize: H, viewportSize: J } = q, Te = H > J, ee = A.current;
1030
+ if (P.debug("[ScrollPane] scrollTo called", () => ({ newPosition: f, contentSize: H, viewportSize: J, currentIsScrollable: Te, prevPosition: ee })), !Te)
1031
+ return A.current !== 0 && (A.current = 0, v?.(0, ee)), A.current;
1032
+ const xe = typeof f == "function" ? f(A.current) : f;
1033
+ if (!Number.isFinite(xe))
1034
+ return P.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position", { nextPosition: xe }), A.current;
1035
+ const ye = Math.max(H - J, 0), $ = se(xe, 0, ye);
1036
+ return A.current !== $ && (A.current = $, v?.($, ee)), A.current;
1018
1037
  },
1019
- [S]
1020
- ), ue = g(Ae);
1021
- q(() => {
1022
- ue.current = Ae;
1023
- }, [Ae]);
1024
- const be = I(() => {
1025
- const p = Ce.current;
1026
- p.generation += 1, p.frame !== null && cancelAnimationFrame(p.frame), p.frame = null, p.velocity = 0, p.lastTimestamp = null;
1027
- }, []), Te = g(be);
1028
- q(() => {
1029
- Te.current = be;
1030
- }, [be]), q(() => () => {
1031
- Te.current();
1038
+ [v]
1039
+ ), be = g(ze);
1040
+ X(() => {
1041
+ be.current = ze;
1042
+ }, [ze]);
1043
+ const Se = S(() => {
1044
+ const f = Ve.current;
1045
+ f.generation += 1, f.frame !== null && cancelAnimationFrame(f.frame), f.frame = null, f.velocity = 0, f.lastTimestamp = null;
1046
+ }, []), j = g(Se);
1047
+ X(() => {
1048
+ j.current = Se;
1049
+ }, [Se]), X(() => () => {
1050
+ j.current();
1032
1051
  }, []);
1033
- const et = I(
1034
- (p) => {
1035
- if (!K)
1052
+ const tt = S(
1053
+ (f) => {
1054
+ if (!Pe)
1036
1055
  return;
1037
- const { maxVelocity: F, minVelocity: B, deceleration: Y, startVelocityThreshold: te } = ze, Me = le(p, -F, F);
1038
- if (Math.abs(Me) < te)
1056
+ const { maxVelocity: M, minVelocity: q, deceleration: H, startVelocityThreshold: J } = Fe, Te = se(f, -M, M);
1057
+ if (Math.abs(Te) < J)
1039
1058
  return;
1040
- be(), Ce.current.velocity = Me, Ce.current.lastTimestamp = null;
1041
- const j = Ce.current.generation, re = (De) => {
1042
- const ne = Ce.current;
1043
- if (ne.generation !== j)
1059
+ Se(), Ve.current.velocity = Te, Ve.current.lastTimestamp = null;
1060
+ const ee = Ve.current.generation, xe = (ye) => {
1061
+ const $ = Ve.current;
1062
+ if ($.generation !== ee)
1044
1063
  return;
1045
- if (ne.lastTimestamp === null) {
1046
- ne.lastTimestamp = De, ne.frame = requestAnimationFrame(re);
1064
+ if ($.lastTimestamp === null) {
1065
+ $.lastTimestamp = ye, $.frame = requestAnimationFrame(xe);
1047
1066
  return;
1048
1067
  }
1049
- const Je = De - ne.lastTimestamp;
1050
- if (ne.lastTimestamp = De, Je <= 0) {
1051
- ne.frame = requestAnimationFrame(re);
1068
+ const Re = ye - $.lastTimestamp;
1069
+ if ($.lastTimestamp = ye, Re <= 0) {
1070
+ $.frame = requestAnimationFrame(xe);
1052
1071
  return;
1053
1072
  }
1054
- const Oe = ne.velocity;
1055
- let ae = Oe;
1056
- const ve = Y * Je;
1057
- Oe > 0 ? ae = Math.max(0, Oe - ve) : Oe < 0 && (ae = Math.min(0, Oe + ve));
1058
- const Ve = (Oe + ae) / 2 * Je, ft = z.current;
1059
- if (Ve !== 0 && ue.current((tt) => tt + Ve), Ce.current.generation !== j)
1073
+ const Ce = $.velocity;
1074
+ let me = Ce;
1075
+ const Ee = H * Re;
1076
+ Ce > 0 ? me = Math.max(0, Ce - Ee) : Ce < 0 && (me = Math.min(0, Ce + Ee));
1077
+ const Le = (Ce + me) / 2 * Re, at = A.current;
1078
+ if (Le !== 0 && be.current((it) => it + Le), Ve.current.generation !== ee)
1060
1079
  return;
1061
- const Qe = z.current, { contentSize: ot, viewportSize: d } = Ge.current, y = Math.max(ot - d, 0);
1062
- ne.velocity = ae;
1063
- const xe = Qe === ft || Qe <= 0 && ae <= 0 || Qe >= y && ae >= 0;
1064
- if (Math.abs(ae) < B || xe) {
1065
- be();
1080
+ const Me = A.current, { contentSize: nt, viewportSize: p } = De.current, R = Math.max(nt - p, 0);
1081
+ $.velocity = me;
1082
+ const ae = Me === at || Me <= 0 && me <= 0 || Me >= R && me >= 0;
1083
+ if (Math.abs(me) < q || ae) {
1084
+ Se();
1066
1085
  return;
1067
1086
  }
1068
- ne.frame = requestAnimationFrame(re);
1087
+ $.frame = requestAnimationFrame(xe);
1069
1088
  };
1070
- Ce.current.frame = requestAnimationFrame(re);
1089
+ Ve.current.frame = requestAnimationFrame(xe);
1071
1090
  },
1072
- [K, ze, be]
1073
- ), mt = g(et);
1074
- q(() => {
1075
- mt.current = et;
1076
- }, [et]), nt(() => {
1077
- Ge.current = { contentSize: e, viewportSize: X };
1078
- }, [e, X]), nt(() => {
1079
- const p = U.current;
1080
- if (!p) return;
1081
- const F = () => {
1082
- p.scrollTop !== 0 && (T.debug("[ScrollPane] Native scroll detected, resetting to 0", () => ({ scrollTop: p.scrollTop })), p.scrollTop = 0), p.scrollLeft !== 0 && (p.scrollLeft = 0);
1091
+ [Pe, Fe, Se]
1092
+ ), Ge = g(tt);
1093
+ X(() => {
1094
+ Ge.current = tt;
1095
+ }, [tt]), et(() => {
1096
+ De.current = { contentSize: e, viewportSize: z };
1097
+ }, [e, z]), et(() => {
1098
+ const f = G.current;
1099
+ if (!f) return;
1100
+ const M = () => {
1101
+ f.scrollTop !== 0 && (P.debug("[ScrollPane] Native scroll detected, resetting to 0", () => ({ scrollTop: f.scrollTop })), f.scrollTop = 0), f.scrollLeft !== 0 && (f.scrollLeft = 0);
1083
1102
  };
1084
- return p.addEventListener("scroll", F), () => p.removeEventListener("scroll", F);
1085
- }, []), nt(() => {
1086
- if (K) {
1087
- T.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", () => ({ contentSize: e, viewportSize: X, scrollPosition: z.current }));
1088
- const p = le(e - X, 0, e);
1089
- z.current > p && Ae(p);
1103
+ return f.addEventListener("scroll", M), () => f.removeEventListener("scroll", M);
1104
+ }, []), et(() => {
1105
+ if (Pe) {
1106
+ P.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", () => ({ contentSize: e, viewportSize: z, scrollPosition: A.current }));
1107
+ const f = se(e - z, 0, e);
1108
+ A.current > f && ze(f);
1090
1109
  } else
1091
- Ae(0);
1092
- }, [K, Ae, e, X]);
1093
- const N = g({ isScrollable: K, viewportSize: X, wheelSpeedMultiplier: oe, overscrollBehavior: ce });
1094
- nt(() => {
1095
- N.current = { isScrollable: K, viewportSize: X, wheelSpeedMultiplier: oe, overscrollBehavior: ce };
1096
- }, [K, X, oe, ce]);
1097
- const it = I(
1098
- (p) => {
1099
- if (Br(p))
1110
+ ze(0);
1111
+ }, [Pe, ze, e, z]);
1112
+ const ft = g({ isScrollable: Pe, viewportSize: z, wheelSpeedMultiplier: re, overscrollBehavior: oe });
1113
+ et(() => {
1114
+ ft.current = { isScrollable: Pe, viewportSize: z, wheelSpeedMultiplier: re, overscrollBehavior: oe };
1115
+ }, [Pe, z, re, oe]);
1116
+ const st = S(
1117
+ (f) => {
1118
+ if (Zr(f))
1100
1119
  return !1;
1101
- const { isScrollable: F, viewportSize: B, wheelSpeedMultiplier: Y, overscrollBehavior: te } = N.current, Me = Yr(p, B);
1102
- if (Me.isZoomGesture)
1120
+ const { isScrollable: M, viewportSize: q, wheelSpeedMultiplier: H, overscrollBehavior: J } = ft.current, Te = jr(f, q);
1121
+ if (Te.isZoomGesture)
1103
1122
  return !1;
1104
- if (Me.isHorizontalDominant)
1105
- return $e.current ? (or(p), p.preventDefault(), be(), $e.current(Me.horizontalDelta), !0) : !1;
1106
- if (!F || Me.verticalDelta === 0)
1123
+ if (Te.isHorizontalDominant)
1124
+ return We.current ? (gr(f), f.preventDefault(), Se(), We.current(Te.horizontalDelta), !0) : !1;
1125
+ if (!M || Te.verticalDelta === 0)
1107
1126
  return !1;
1108
- let j = Me.verticalDelta;
1109
- if (Y !== 1 && (j *= Y), te !== "contain") {
1110
- const re = z.current, De = Math.max(Ge.current.contentSize - B, 0);
1111
- if (j > 0 && re >= De || j < 0 && re <= 0)
1127
+ let ee = Te.verticalDelta;
1128
+ if (H !== 1 && (ee *= H), J !== "contain") {
1129
+ const xe = A.current, ye = Math.max(De.current.contentSize - q, 0);
1130
+ if (ee > 0 && xe >= ye || ee < 0 && xe <= 0)
1112
1131
  return !1;
1113
1132
  }
1114
- return or(p), p.preventDefault(), be(), T.debug("[ScrollPane] wheel event", () => ({ deltaY: j, scrollPosition: z.current, wheelSpeedMultiplier: Y, deltaMode: p.deltaMode, scrollTop: U.current?.scrollTop })), Ae((re) => re + j), !0;
1133
+ return gr(f), f.preventDefault(), Se(), P.debug("[ScrollPane] wheel event", () => ({ deltaY: ee, scrollPosition: A.current, wheelSpeedMultiplier: H, deltaMode: f.deltaMode, scrollTop: G.current?.scrollTop })), ze((xe) => xe + ee), !0;
1115
1134
  },
1116
- [Ae, be]
1135
+ [ze, Se]
1117
1136
  );
1118
- q(() => {
1119
- const p = (Y) => {
1120
- it(Y);
1121
- }, F = () => {
1122
- be();
1123
- }, B = v.current;
1124
- return B && (B.addEventListener("wheel", p, { passive: !1 }), B.addEventListener("pointerdown", F, { capture: !0, passive: !0 })), () => {
1125
- B && (B.removeEventListener("wheel", p), B.removeEventListener("pointerdown", F, { capture: !0 }));
1137
+ X(() => {
1138
+ const f = (H) => {
1139
+ st(H);
1140
+ }, M = () => {
1141
+ Se();
1142
+ }, q = I.current;
1143
+ return q && (q.addEventListener("wheel", f, { passive: !1 }), q.addEventListener("pointerdown", M, { capture: !0, passive: !0 })), () => {
1144
+ q && (q.removeEventListener("wheel", f), q.removeEventListener("pointerdown", M, { capture: !0 }));
1126
1145
  };
1127
- }, [it, be]), Jt(
1128
- Ie,
1146
+ }, [st, Se]), ir(
1147
+ he,
1129
1148
  () => ({
1130
- scrollTo: (p, F) => (be(), Ae(p, F)),
1131
- getScrollPosition: () => z.current,
1149
+ scrollTo: (f, M) => (Se(), ze(f, M)),
1150
+ getScrollPosition: () => A.current,
1132
1151
  getContentSize: () => e,
1133
- getViewportSize: () => X,
1134
- applyWheel: it
1152
+ getViewportSize: () => z,
1153
+ applyWheel: st
1135
1154
  }),
1136
- [Ae, e, X, be, it]
1155
+ [ze, e, z, Se, st]
1137
1156
  );
1138
- const vt = Ir(), E = W?.id ?? vt, J = g({
1157
+ const N = Vr(), gt = K?.id ?? N, ne = g({
1139
1158
  pointerType: "",
1140
1159
  pointerId: null,
1141
1160
  startClientY: 0,
@@ -1144,151 +1163,151 @@ const le = (r, e, t) => Math.max(e, Math.min(t, r)), Gt = "virtualscroll:tap-scr
1144
1163
  shouldCancelNextClick: !1,
1145
1164
  clickResetTimer: null,
1146
1165
  velocitySamples: []
1147
- }), Ze = g(f), ht = g(b);
1148
- q(() => {
1149
- Ze.current = f;
1150
- }, [f]), q(() => {
1151
- ht.current = b;
1166
+ }), V = g(m), ot = g(b);
1167
+ X(() => {
1168
+ V.current = m;
1169
+ }, [m]), X(() => {
1170
+ ot.current = b;
1152
1171
  }, [b]);
1153
- const Le = g(K);
1154
- q(() => {
1155
- Le.current = K;
1156
- }, [K]);
1157
- const st = g(ze);
1158
- q(() => {
1159
- st.current = ze;
1160
- }, [ze]), q(() => {
1161
- const p = J.current;
1162
- if (f && K && (p.pointerId === null || Ut(p.pointerType, b)) || p.pointerId === null)
1172
+ const je = g(Pe);
1173
+ X(() => {
1174
+ je.current = Pe;
1175
+ }, [Pe]);
1176
+ const mt = g(Fe);
1177
+ X(() => {
1178
+ mt.current = Fe;
1179
+ }, [Fe]), X(() => {
1180
+ const f = ne.current;
1181
+ if (m && Pe && (f.pointerId === null || Qt(f.pointerType, b)) || f.pointerId === null)
1163
1182
  return;
1164
- const F = U.current;
1165
- p.clickResetTimer !== null && (window.clearTimeout(p.clickResetTimer), p.clickResetTimer = null);
1166
- const B = p.isDragging && p.shouldCancelNextClick, Y = p.pointerId;
1167
- p.pointerId = null, p.pointerType = "", p.startClientY = 0, p.startScroll = 0, p.isDragging = !1, p.shouldCancelNextClick = B, p.velocitySamples = [], F?.hasPointerCapture(Y) && F.releasePointerCapture(Y);
1168
- }, [f, b, K]), q(() => {
1169
- const p = U.current;
1170
- if (!p)
1183
+ const M = G.current;
1184
+ f.clickResetTimer !== null && (window.clearTimeout(f.clickResetTimer), f.clickResetTimer = null);
1185
+ const q = f.isDragging && f.shouldCancelNextClick, H = f.pointerId;
1186
+ f.pointerId = null, f.pointerType = "", f.startClientY = 0, f.startScroll = 0, f.isDragging = !1, f.shouldCancelNextClick = q, f.velocitySamples = [], M?.hasPointerCapture(H) && M.releasePointerCapture(H);
1187
+ }, [m, b, Pe]), X(() => {
1188
+ const f = G.current;
1189
+ if (!f)
1171
1190
  return;
1172
- const F = 6, B = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), Y = () => {
1173
- const d = J.current;
1174
- d.pointerId = null, d.pointerType = "", d.startClientY = 0, d.startScroll = 0, d.isDragging = !1, d.velocitySamples = [];
1175
- }, te = () => {
1176
- const d = J.current;
1177
- d.clickResetTimer !== null && (window.clearTimeout(d.clickResetTimer), d.clickResetTimer = null);
1178
- }, Me = (d) => {
1179
- const y = J.current, xe = B();
1180
- y.velocitySamples.push({ clientY: d, time: xe });
1181
- const tt = st.current.velocitySampleWindow;
1182
- y.velocitySamples = y.velocitySamples.filter((_e) => xe - _e.time <= tt);
1183
- }, j = (d) => d instanceof HTMLElement && d.closest("[data-scrollpane-ignore-drag='true']") !== null, re = (d) => {
1184
- const y = J.current;
1185
- y.shouldCancelNextClick && (d.preventDefault(), d.stopPropagation(), y.shouldCancelNextClick = !1);
1186
- }, De = (d) => {
1187
- const y = J.current;
1188
- if (!y.isDragging) {
1189
- if (y.isDragging = !0, y.shouldCancelNextClick = !0, !p.hasPointerCapture(d.pointerId))
1191
+ const M = 6, q = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), H = () => {
1192
+ const p = ne.current;
1193
+ p.pointerId = null, p.pointerType = "", p.startClientY = 0, p.startScroll = 0, p.isDragging = !1, p.velocitySamples = [];
1194
+ }, J = () => {
1195
+ const p = ne.current;
1196
+ p.clickResetTimer !== null && (window.clearTimeout(p.clickResetTimer), p.clickResetTimer = null);
1197
+ }, Te = (p) => {
1198
+ const R = ne.current, ae = q();
1199
+ R.velocitySamples.push({ clientY: p, time: ae });
1200
+ const it = mt.current.velocitySampleWindow;
1201
+ R.velocitySamples = R.velocitySamples.filter((Ne) => ae - Ne.time <= it);
1202
+ }, ee = (p) => p instanceof HTMLElement && p.closest("[data-scrollpane-ignore-drag='true']") !== null, xe = (p) => {
1203
+ const R = ne.current;
1204
+ R.shouldCancelNextClick && (p.preventDefault(), p.stopPropagation(), R.shouldCancelNextClick = !1);
1205
+ }, ye = (p) => {
1206
+ const R = ne.current;
1207
+ if (!R.isDragging) {
1208
+ if (R.isDragging = !0, R.shouldCancelNextClick = !0, !f.hasPointerCapture(p.pointerId))
1190
1209
  try {
1191
- p.setPointerCapture(d.pointerId);
1210
+ f.setPointerCapture(p.pointerId);
1192
1211
  } catch {
1193
1212
  }
1194
- Me(d.clientY);
1213
+ Te(p.clientY);
1195
1214
  }
1196
- }, ne = (d) => d.isTrusted || d.target === p, Je = (d) => {
1197
- const y = J.current;
1198
- p.hasPointerCapture(d) && p.releasePointerCapture(d), y.shouldCancelNextClick = !1, te(), Y();
1199
- }, Oe = (d) => {
1200
- const y = J.current;
1201
- if (y.pointerId !== d.pointerId)
1215
+ }, $ = (p) => p.isTrusted || p.target === f, Re = (p) => {
1216
+ const R = ne.current;
1217
+ f.hasPointerCapture(p) && f.releasePointerCapture(p), R.shouldCancelNextClick = !1, J(), H();
1218
+ }, Ce = (p) => {
1219
+ const R = ne.current;
1220
+ if (R.pointerId !== p.pointerId)
1202
1221
  return;
1203
- if (d.buttons === 0 && qr(d.pointerType)) {
1204
- Je(d.pointerId);
1222
+ if (p.buttons === 0 && Jr(p.pointerType)) {
1223
+ Re(p.pointerId);
1205
1224
  return;
1206
1225
  }
1207
- if (!(Ze.current && Le.current) || !Ut(d.pointerType, ht.current) || !y.isDragging && (Math.abs(d.clientY - y.startClientY) < F || (De(d), !y.isDragging)))
1226
+ if (!(V.current && je.current) || !Qt(p.pointerType, ot.current) || !R.isDragging && (Math.abs(p.clientY - R.startClientY) < M || (ye(p), !R.isDragging)))
1208
1227
  return;
1209
- Me(d.clientY);
1210
- const xe = d.clientY - y.startClientY, tt = y.startScroll - xe;
1211
- ue.current(tt), d.cancelable && d.preventDefault();
1212
- }, ae = () => {
1213
- const d = J.current;
1214
- return d.pointerId !== null || !d.shouldCancelNextClick ? !1 : (te(), d.clickResetTimer = window.setTimeout(() => {
1215
- const y = J.current;
1216
- y.shouldCancelNextClick = !1, y.clickResetTimer = null;
1228
+ Te(p.clientY);
1229
+ const ae = p.clientY - R.startClientY, it = R.startScroll - ae;
1230
+ be.current(it), p.cancelable && p.preventDefault();
1231
+ }, me = () => {
1232
+ const p = ne.current;
1233
+ return p.pointerId !== null || !p.shouldCancelNextClick ? !1 : (J(), p.clickResetTimer = window.setTimeout(() => {
1234
+ const R = ne.current;
1235
+ R.shouldCancelNextClick = !1, R.clickResetTimer = null;
1217
1236
  }, 0), !0);
1218
- }, ve = (d) => {
1219
- const y = J.current;
1220
- if (y.pointerId !== d.pointerId) {
1221
- ae();
1237
+ }, Ee = (p) => {
1238
+ const R = ne.current;
1239
+ if (R.pointerId !== p.pointerId) {
1240
+ me();
1222
1241
  return;
1223
1242
  }
1224
- y.isDragging && y.shouldCancelNextClick && d.cancelable && (d.preventDefault(), d.stopPropagation()), y.isDragging && Me(d.clientY);
1225
- let xe = 0;
1226
- if (y.isDragging && y.velocitySamples.length >= 2) {
1227
- const _e = y.velocitySamples, ct = st.current.velocitySampleWindow, ut = _e[_e.length - 1], at = _e.find((gt) => ut.time - gt.time <= ct) ?? _e[0];
1228
- if (ut && at && ut.time !== at.time) {
1229
- const gt = ut.clientY - at.clientY, pt = ut.time - at.time;
1230
- xe = -(gt / pt);
1243
+ R.isDragging && R.shouldCancelNextClick && p.cancelable && (p.preventDefault(), p.stopPropagation()), R.isDragging && Te(p.clientY);
1244
+ let ae = 0;
1245
+ if (R.isDragging && R.velocitySamples.length >= 2) {
1246
+ const Ne = R.velocitySamples, zt = mt.current.velocitySampleWindow, ct = Ne[Ne.length - 1], Ye = Ne.find((bt) => ct.time - bt.time <= zt) ?? Ne[0];
1247
+ if (ct && Ye && ct.time !== Ye.time) {
1248
+ const bt = ct.clientY - Ye.clientY, Pt = ct.time - Ye.time;
1249
+ ae = -(bt / Pt);
1231
1250
  }
1232
1251
  }
1233
- te(), y.shouldCancelNextClick && (y.clickResetTimer = window.setTimeout(() => {
1234
- const _e = J.current;
1235
- _e.shouldCancelNextClick = !1, _e.clickResetTimer = null;
1252
+ J(), R.shouldCancelNextClick && (R.clickResetTimer = window.setTimeout(() => {
1253
+ const Ne = ne.current;
1254
+ Ne.shouldCancelNextClick = !1, Ne.clickResetTimer = null;
1236
1255
  }, 0));
1237
- const tt = st.current.startVelocityThreshold;
1238
- Y(), p.hasPointerCapture(d.pointerId) && p.releasePointerCapture(d.pointerId), Math.abs(xe) >= tt && mt.current?.(xe);
1239
- }, We = (d) => {
1240
- if (J.current.pointerId !== null) {
1241
- if (!d.isPrimary || d.pointerType !== J.current.pointerType)
1256
+ const it = mt.current.startVelocityThreshold;
1257
+ H(), f.hasPointerCapture(p.pointerId) && f.releasePointerCapture(p.pointerId), Math.abs(ae) >= it && Ge.current?.(ae);
1258
+ }, rt = (p) => {
1259
+ if (ne.current.pointerId !== null) {
1260
+ if (!p.isPrimary || p.pointerType !== ne.current.pointerType)
1242
1261
  return;
1243
- Je(J.current.pointerId);
1262
+ Re(ne.current.pointerId);
1244
1263
  }
1245
- if (J.current.shouldCancelNextClick && (te(), J.current.shouldCancelNextClick = !1), !(Ze.current && Le.current) || !Ut(d.pointerType, ht.current) || d.button !== 0 && d.pointerType === "mouse" || d.ctrlKey || d.metaKey || d.altKey || j(d.target))
1264
+ if (ne.current.shouldCancelNextClick && (J(), ne.current.shouldCancelNextClick = !1), !(V.current && je.current) || !Qt(p.pointerType, ot.current) || p.button !== 0 && p.pointerType === "mouse" || p.ctrlKey || p.metaKey || p.altKey || ee(p.target))
1246
1265
  return;
1247
- window.dispatchEvent(new CustomEvent(Gt, { detail: { paneId: vt } })), Te.current?.();
1248
- const y = J.current;
1249
- te(), y.pointerId = d.pointerId, y.pointerType = d.pointerType, y.startClientY = d.clientY, y.startScroll = z.current, y.isDragging = !1, y.shouldCancelNextClick = !1, y.velocitySamples = [];
1250
- }, Ve = (d) => {
1251
- if (J.current.pointerId !== d.pointerId) {
1252
- ae();
1266
+ window.dispatchEvent(new CustomEvent(tr, { detail: { paneId: N } })), j.current?.();
1267
+ const R = ne.current;
1268
+ J(), R.pointerId = p.pointerId, R.pointerType = p.pointerType, R.startClientY = p.clientY, R.startScroll = A.current, R.isDragging = !1, R.shouldCancelNextClick = !1, R.velocitySamples = [];
1269
+ }, Le = (p) => {
1270
+ if (ne.current.pointerId !== p.pointerId) {
1271
+ me();
1253
1272
  return;
1254
1273
  }
1255
- ne(d) && Je(d.pointerId);
1256
- }, Qe = [
1257
- ["click", re, !0],
1258
- ["pointerdown", We, { passive: !1 }],
1259
- ["lostpointercapture", (d) => {
1260
- d.target !== p || J.current.pointerId !== d.pointerId || Je(d.pointerId);
1274
+ $(p) && Re(p.pointerId);
1275
+ }, Me = [
1276
+ ["click", xe, !0],
1277
+ ["pointerdown", rt, { passive: !1 }],
1278
+ ["lostpointercapture", (p) => {
1279
+ p.target !== f || ne.current.pointerId !== p.pointerId || Re(p.pointerId);
1261
1280
  }, void 0]
1262
- ], ot = [
1263
- ["pointermove", Oe, { passive: !1 }],
1264
- ["pointerup", ve, void 0],
1265
- ["pointercancel", Ve, void 0]
1281
+ ], nt = [
1282
+ ["pointermove", Ce, { passive: !1 }],
1283
+ ["pointerup", Ee, void 0],
1284
+ ["pointercancel", Le, void 0]
1266
1285
  ];
1267
- return kt(p, Qe, "add"), kt(window, ot, "add"), () => {
1268
- kt(p, Qe, "remove"), kt(window, ot, "remove");
1269
- const d = J.current;
1270
- d.pointerId !== null && p.hasPointerCapture(d.pointerId) && p.releasePointerCapture(d.pointerId), te(), Y();
1286
+ return qt(f, Me, "add"), qt(window, nt, "add"), () => {
1287
+ qt(f, Me, "remove"), qt(window, nt, "remove");
1288
+ const p = ne.current;
1289
+ p.pointerId !== null && f.hasPointerCapture(p.pointerId) && f.releasePointerCapture(p.pointerId), J(), H();
1271
1290
  };
1272
- }, [vt]);
1273
- const ie = I(
1274
- (p) => (be(), Ae(p)),
1275
- [Ae, be]
1291
+ }, [N]);
1292
+ const Ae = S(
1293
+ (f) => (Se(), ze(f)),
1294
+ [ze, Se]
1276
1295
  );
1277
- return /* @__PURE__ */ Mt("div", { ref: v, "data-testid": V, "data-self-measured": ge ? "true" : void 0, className: Et("aqvs-scroll-pane", w), style: h, children: [
1278
- /* @__PURE__ */ Mt(
1296
+ return /* @__PURE__ */ Tt("div", { ref: I, "data-testid": C, "data-self-measured": fe ? "true" : void 0, className: Vt("aqvs-scroll-pane", T), style: h, children: [
1297
+ /* @__PURE__ */ Tt(
1279
1298
  "div",
1280
1299
  {
1281
- ref: U,
1282
- className: Et("aqvs-scroll-pane-content"),
1300
+ ref: G,
1301
+ className: Vt("aqvs-scroll-pane-content"),
1283
1302
  "data-testid": "aqvs-scroll-pane-content",
1284
1303
  style: {
1285
1304
  // ❗ 自己計測モードでは高さを書かない。CSS の `height: 100%` (= ルートの確定高さ) が
1286
1305
  // レイアウトを所有することで、「計測した値を書き戻して自分のサイズを変える」
1287
1306
  // フィードバックループが構造的に起こらず、初回 paint の時点でも帯は実寸で正しい
1288
1307
  // (数値の反映だけが 1 コミット遅れる)。明示モードは従来どおり px を書く。
1289
- height: ge ? void 0 : X,
1290
- paddingTop: je.top,
1291
- paddingBottom: je.bottom,
1308
+ height: fe ? void 0 : z,
1309
+ paddingTop: Ke.top,
1310
+ paddingBottom: Ke.bottom,
1292
1311
  // スクロール不能時 (contentSize <= viewportSize) は touch-action を通常に戻し、
1293
1312
  // 短いリスト上のタッチがページ全体のパンを妨げるデッドゾーン化を防ぐ。
1294
1313
  // 直接操作 (指・ペン) のドラッグを許可していない場合も付けない。
@@ -1302,102 +1321,102 @@ const le = (r, e, t) => Math.max(e, Math.min(t, r)), Gt = "virtualscroll:tap-scr
1302
1321
  // 同一条件で揃えてあるため状態としても一貫している。
1303
1322
  // 非同期コンテンツを先読みして確保する挙動は意図的に入れていない
1304
1323
  // (空のペインがページのパンを殺すデッドゾーンになり、そちらの実害の方が大きいため)。
1305
- ...f && K && b.some((p) => p === "touch" || p === "pen") ? { touchAction: "none" } : {}
1324
+ ...m && Pe && b.some((f) => f === "touch" || f === "pen") ? { touchAction: "none" } : {}
1306
1325
  },
1307
- ...W,
1308
- id: E,
1326
+ ...K,
1327
+ id: gt,
1309
1328
  children: [
1310
- C,
1311
- r(z.current)
1329
+ O,
1330
+ r(A.current)
1312
1331
  ]
1313
1332
  }
1314
1333
  ),
1315
- /* @__PURE__ */ de(
1316
- kr,
1334
+ /* @__PURE__ */ ie(
1335
+ Kr,
1317
1336
  {
1318
1337
  contentSize: e,
1319
- viewportSize: X,
1320
- scrollPosition: z.current,
1321
- onScroll: ie,
1338
+ viewportSize: z,
1339
+ scrollPosition: A.current,
1340
+ onScroll: Ae,
1322
1341
  enableThumbDrag: s,
1323
- enableTrackClick: a,
1324
- enableArrowButtons: c,
1342
+ enableTrackClick: l,
1343
+ enableArrowButtons: d,
1325
1344
  scrollBarWidth: i,
1326
- ariaControls: E,
1327
- tapScrollCircleOptions: G,
1328
- itemCount: pe,
1329
- renderThumbOverlay: me,
1330
- visibleStartIndex: _,
1331
- visibleEndIndex: M
1345
+ ariaControls: gt,
1346
+ tapScrollCircleOptions: W,
1347
+ itemCount: ce,
1348
+ renderThumbOverlay: ue,
1349
+ visibleStartIndex: Y,
1350
+ visibleEndIndex: w
1332
1351
  },
1333
1352
  "scrollbar"
1334
1353
  ),
1335
1354
  Z?.()
1336
1355
  ] });
1337
1356
  }
1338
- ), ar = (r, e, t) => Math.min(Math.max(r, e), t), ln = ({ dragState: r, normalizedDistance: e, sizeScale: t, size: n }) => {
1339
- const i = Math.max(n / 2, 1), s = 1 + e * 0.65, a = Math.max(0.65, 1 - e * 0.25), c = r.direction * e * 26 * t, f = 0.8 + e * 0.18, b = 3 * t, S = 6 * t, w = 22 * t, V = Math.abs(c) + S, h = c > 0 ? b : -Math.abs(c) - b, C = Math.max(2.5, 3 * t), G = ar(r.offsetX, -i, i), H = ar(r.offsetY, -i, i), pe = i * 0.35, me = G / i * pe, oe = H / i * pe, ce = me * 0.45, he = oe * 0.45, P = Math.max(w * 0.38, 6), _ = 0.65 + e * 0.2, M = r.active;
1340
- return /* @__PURE__ */ Mt(dr, { children: [
1341
- /* @__PURE__ */ de(
1357
+ ), br = (r, e, t) => Math.min(Math.max(r, e), t), xn = ({ dragState: r, normalizedDistance: e, sizeScale: t, size: n }) => {
1358
+ const i = Math.max(n / 2, 1), s = 1 + e * 0.65, l = Math.max(0.65, 1 - e * 0.25), d = r.direction * e * 26 * t, m = 0.8 + e * 0.18, b = 3 * t, v = 6 * t, T = 22 * t, C = Math.abs(d) + v, h = d > 0 ? b : -Math.abs(d) - b, O = Math.max(2.5, 3 * t), W = br(r.offsetX, -i, i), D = br(r.offsetY, -i, i), ce = i * 0.35, ue = W / i * ce, re = D / i * ce, oe = ue * 0.45, de = re * 0.45, y = Math.max(T * 0.38, 6), Y = 0.65 + e * 0.2, w = r.active;
1359
+ return /* @__PURE__ */ Tt(rr, { children: [
1360
+ /* @__PURE__ */ ie(
1342
1361
  "div",
1343
1362
  {
1344
1363
  className: "aqvs-tap-scroll-circle-gradient",
1345
1364
  style: {
1346
- transform: `scale(${a}, ${s})`,
1347
- transition: M ? "40ms transform ease-out" : "200ms ease transform"
1365
+ transform: `scale(${l}, ${s})`,
1366
+ transition: w ? "40ms transform ease-out" : "200ms ease transform"
1348
1367
  }
1349
1368
  }
1350
1369
  ),
1351
- /* @__PURE__ */ de(
1370
+ /* @__PURE__ */ ie(
1352
1371
  "div",
1353
1372
  {
1354
1373
  className: "aqvs-sample-visual-pupil",
1355
1374
  style: {
1356
- width: w,
1357
- height: w,
1358
- transform: `translate(calc(-50% + ${me}px), calc(-50% + ${oe}px)) scale(${a}, ${f * s})`,
1359
- transition: M ? "70ms transform ease-out" : "200ms ease transform"
1375
+ width: T,
1376
+ height: T,
1377
+ transform: `translate(calc(-50% + ${ue}px), calc(-50% + ${re}px)) scale(${l}, ${m * s})`,
1378
+ transition: w ? "70ms transform ease-out" : "200ms ease transform"
1360
1379
  }
1361
1380
  }
1362
1381
  ),
1363
- /* @__PURE__ */ de(
1382
+ /* @__PURE__ */ ie(
1364
1383
  "div",
1365
1384
  {
1366
1385
  className: "aqvs-sample-visual-highlight",
1367
1386
  style: {
1368
- width: P,
1369
- height: P,
1370
- transform: `translate(calc(-50% + ${ce}px), calc(-50% + ${he}px)) scale(${a}, ${s})`,
1371
- opacity: _,
1387
+ width: y,
1388
+ height: y,
1389
+ transform: `translate(calc(-50% + ${oe}px), calc(-50% + ${de}px)) scale(${l}, ${s})`,
1390
+ opacity: Y,
1372
1391
  boxShadow: "0 0 8px rgba(255,255,255,0.45)",
1373
- transition: M ? "120ms opacity 150ms, 120ms transform ease-out ease-out" : "220ms ease transform, 240ms opacity ease"
1392
+ transition: w ? "120ms opacity 150ms, 120ms transform ease-out ease-out" : "220ms ease transform, 240ms opacity ease"
1374
1393
  }
1375
1394
  }
1376
1395
  ),
1377
- /* @__PURE__ */ de(
1396
+ /* @__PURE__ */ ie(
1378
1397
  "div",
1379
1398
  {
1380
1399
  className: "aqvs-sample-visual-rod",
1381
1400
  style: {
1382
- width: C,
1383
- height: V,
1401
+ width: O,
1402
+ height: C,
1384
1403
  transform: `translate(-50%, ${h}px)`,
1385
1404
  opacity: e,
1386
- transition: M ? "40ms height, 60ms opacity ease-out ease-out" : "200ms ease height, 120ms ease opacity"
1405
+ transition: w ? "40ms height, 60ms opacity ease-out ease-out" : "200ms ease height, 120ms ease opacity"
1387
1406
  }
1388
1407
  }
1389
1408
  )
1390
1409
  ] });
1391
- }, Ft = 100, $r = (r) => {
1410
+ }, Xt = 100, tn = (r) => {
1392
1411
  if (!Number.isFinite(r))
1393
1412
  return 0n;
1394
1413
  const e = Math.trunc(r);
1395
1414
  return e <= 0 ? 0n : BigInt(e);
1396
- }, Kt = (r, e) => {
1415
+ }, Jt = (r, e) => {
1397
1416
  if (!Number.isFinite(r))
1398
1417
  throw new Error(`valueFn returned a non-finite value at index ${e}: ${r}`);
1399
1418
  return r;
1400
- }, Rt = (r) => {
1419
+ }, Nt = (r) => {
1401
1420
  if (r <= 0 || !Number.isFinite(r))
1402
1421
  return 0;
1403
1422
  const e = Math.trunc(r);
@@ -1406,7 +1425,7 @@ const le = (r, e, t) => Math.max(e, Math.min(t, r)), Gt = "virtualscroll:tap-scr
1406
1425
  const t = BigInt(e) & -BigInt(e);
1407
1426
  return Number(t);
1408
1427
  };
1409
- class It {
1428
+ class St {
1410
1429
  /**
1411
1430
  * @private
1412
1431
  * @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
@@ -1470,27 +1489,27 @@ class It {
1470
1489
  this.size = i, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.valueFn = void 0, this.baseValue = t, this.total = this.baseValue * this.size;
1471
1490
  return;
1472
1491
  }
1473
- let s = 0, a;
1492
+ let s = 0, l;
1474
1493
  if (i > 0) {
1475
- const c = n?.sampleRange ?? {
1494
+ const d = n?.sampleRange ?? {
1476
1495
  from: 0,
1477
- to: Math.min(Ft - 1, i - 1)
1496
+ to: Math.min(Xt - 1, i - 1)
1478
1497
  };
1479
- let f = Math.max(0, Math.trunc(c.from)), b = Math.min(Math.trunc(c.to), i - 1);
1480
- if (f > b && (f = 0, b = Math.min(Ft - 1, i - 1)), i > Ft)
1481
- s = It._sampleBaseValueStrided(t, i, Ft), n?.materialize && (a = { from: f, values: It._collectValidatedValues(t, f, b) });
1498
+ let m = Math.max(0, Math.trunc(d.from)), b = Math.min(Math.trunc(d.to), i - 1);
1499
+ if (m > b && (m = 0, b = Math.min(Xt - 1, i - 1)), i > Xt)
1500
+ s = St._sampleBaseValueStrided(t, i, Xt), n?.materialize && (l = { from: m, values: St._collectValidatedValues(t, m, b) });
1482
1501
  else {
1483
- const S = It._collectValidatedValues(t, f, b);
1484
- s = It._modeOrMedian([...S]), n?.materialize && (a = { from: f, values: S });
1502
+ const v = St._collectValidatedValues(t, m, b);
1503
+ s = St._modeOrMedian([...v]), n?.materialize && (l = { from: m, values: v });
1485
1504
  }
1486
1505
  }
1487
- if (this.size = i, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, this.valueFn = t, this.baseValue = s, a)
1488
- for (let c = 0; c < a.values.length; c++) {
1489
- const f = a.from + c;
1490
- if (f >= this.size)
1506
+ if (this.size = i, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, this.valueFn = t, this.baseValue = s, l)
1507
+ for (let d = 0; d < l.values.length; d++) {
1508
+ const m = l.from + d;
1509
+ if (m >= this.size)
1491
1510
  break;
1492
- const b = a.values[c] - this.baseValue;
1493
- b !== 0 && (this.deltas.set(f, b), this._updateTree(f, b));
1511
+ const b = l.values[d] - this.baseValue;
1512
+ b !== 0 && (this.deltas.set(m, b), this._updateTree(m, b));
1494
1513
  }
1495
1514
  this.total = this.getTotal();
1496
1515
  }
@@ -1521,7 +1540,7 @@ class It {
1521
1540
  static _collectValidatedValues(e, t, n) {
1522
1541
  const i = [];
1523
1542
  for (let s = t; s <= n; s++)
1524
- i.push(Kt(e(s), s));
1543
+ i.push(Jt(e(s), s));
1525
1544
  return i;
1526
1545
  }
1527
1546
  /**
@@ -1535,22 +1554,22 @@ class It {
1535
1554
  static _modeOrMedian(e) {
1536
1555
  if (e.length === 0)
1537
1556
  return 0;
1538
- e.sort((a, c) => a - c);
1557
+ e.sort((l, d) => l - d);
1539
1558
  const t = Math.floor(e.length / 2);
1540
1559
  let n;
1541
1560
  e.length % 2 === 0 ? n = Math.floor((e[t - 1] + e[t]) / 2) : n = e[t];
1542
1561
  const i = /* @__PURE__ */ new Map();
1543
1562
  let s = 0;
1544
- for (const a of e) {
1545
- const c = (i.get(a) ?? 0) + 1;
1546
- i.set(a, c), c > s && (s = c);
1563
+ for (const l of e) {
1564
+ const d = (i.get(l) ?? 0) + 1;
1565
+ i.set(l, d), d > s && (s = d);
1547
1566
  }
1548
1567
  if (s > e.length * 0.2) {
1549
- const a = [];
1550
- for (const [f, b] of i.entries())
1551
- b === s && a.push(f);
1552
- const c = a.reduce((f, b) => f + b, 0);
1553
- n = Math.floor(c / a.length);
1568
+ const l = [];
1569
+ for (const [m, b] of i.entries())
1570
+ b === s && l.push(m);
1571
+ const d = l.reduce((m, b) => m + b, 0);
1572
+ n = Math.floor(d / l.length);
1554
1573
  }
1555
1574
  return n;
1556
1575
  }
@@ -1570,9 +1589,9 @@ class It {
1570
1589
  let i = Math.max(1, Math.ceil(t / n));
1571
1590
  i % 2 === 0 && (i += 1);
1572
1591
  const s = [];
1573
- for (let a = 0; a < t && s.length < n; a += i)
1574
- s.push(Kt(e(a), a));
1575
- return It._modeOrMedian(s);
1592
+ for (let l = 0; l < t && s.length < n; l += i)
1593
+ s.push(Jt(e(l), l));
1594
+ return St._modeOrMedian(s);
1576
1595
  }
1577
1596
  /**
1578
1597
  * @method update
@@ -1619,14 +1638,14 @@ class It {
1619
1638
  throw new Error(`Index must be an integer: ${n}`);
1620
1639
  if (!Number.isFinite(i))
1621
1640
  throw new Error(`Change must be a finite number: ${i}`);
1622
- const a = (t.get(n) ?? this.deltas.get(n) ?? 0) + i;
1623
- if (a + this.baseValue < -1e-9)
1624
- throw new Error(`Change would make the value at index ${n} negative: ${a + this.baseValue}`);
1625
- t.set(n, a);
1641
+ const l = (t.get(n) ?? this.deltas.get(n) ?? 0) + i;
1642
+ if (l + this.baseValue < -1e-9)
1643
+ throw new Error(`Change would make the value at index ${n} negative: ${l + this.baseValue}`);
1644
+ t.set(n, l);
1626
1645
  }
1627
1646
  for (const { index: n, change: i } of e) {
1628
- const a = (this.deltas.get(n) ?? 0) + i;
1629
- a === 0 ? this.deltas.delete(n) : this.deltas.set(n, a), this._updateTree(n, i);
1647
+ const l = (this.deltas.get(n) ?? 0) + i;
1648
+ l === 0 ? this.deltas.delete(n) : this.deltas.set(n, l), this._updateTree(n, i);
1630
1649
  }
1631
1650
  return this.total;
1632
1651
  }
@@ -1644,7 +1663,7 @@ class It {
1644
1663
  let n = e + 1;
1645
1664
  for (; n <= this.size; ) {
1646
1665
  this.tree.set(n, (this.tree.get(n) ?? 0) + t);
1647
- const i = Rt(n);
1666
+ const i = Nt(n);
1648
1667
  if (i === 0)
1649
1668
  break;
1650
1669
  n += i;
@@ -1670,8 +1689,8 @@ class It {
1670
1689
  throw new Error(`Value must be a finite number: ${s}`);
1671
1690
  if (s < 0)
1672
1691
  throw new Error("Value cannot be negative.");
1673
- const a = n.has(i) ? n.get(i) ?? 0 : this.deltas.get(i) ?? 0, c = a + this.baseValue, f = s - c;
1674
- f !== 0 && t.push({ index: i, change: f }), n.set(i, a + f);
1692
+ const l = n.has(i) ? n.get(i) ?? 0 : this.deltas.get(i) ?? 0, d = l + this.baseValue, m = s - d;
1693
+ m !== 0 && t.push({ index: i, change: m }), n.set(i, l + m);
1675
1694
  }
1676
1695
  return t;
1677
1696
  }
@@ -1688,7 +1707,7 @@ class It {
1688
1707
  let e = 0, t = this.size;
1689
1708
  for (; t > 0; ) {
1690
1709
  e += this.tree.get(t) ?? 0;
1691
- const n = Rt(t);
1710
+ const n = Nt(t);
1692
1711
  if (n === 0)
1693
1712
  break;
1694
1713
  t -= n;
@@ -1705,10 +1724,10 @@ class It {
1705
1724
  */
1706
1725
  _materialize(e, t = !0) {
1707
1726
  if (this.valueFn) {
1708
- const n = this.deltas.get(e) ?? 0, s = Kt(this.valueFn(e), e) - this.baseValue;
1727
+ const n = this.deltas.get(e) ?? 0, s = Jt(this.valueFn(e), e) - this.baseValue;
1709
1728
  if (s !== n && (s === 0 ? this.deltas.delete(e) : this.deltas.set(e, s), t)) {
1710
- const a = s - n;
1711
- this._updateTree(e, a);
1729
+ const l = s - n;
1730
+ this._updateTree(e, l);
1712
1731
  }
1713
1732
  }
1714
1733
  }
@@ -1726,10 +1745,10 @@ class It {
1726
1745
  return;
1727
1746
  const i = e.ranges;
1728
1747
  if (i && i.length > 0) {
1729
- for (const c of i) {
1730
- const f = Math.max(0, Math.trunc(c.from)), b = Math.min(Math.trunc(c.to), this.size - 1);
1731
- for (let S = f; S <= b; S++)
1732
- this._materialize(S);
1748
+ for (const d of i) {
1749
+ const m = Math.max(0, Math.trunc(d.from)), b = Math.min(Math.trunc(d.to), this.size - 1);
1750
+ for (let v = m; v <= b; v++)
1751
+ this._materialize(v);
1733
1752
  }
1734
1753
  if (t === void 0)
1735
1754
  return;
@@ -1737,8 +1756,8 @@ class It {
1737
1756
  this._materialize(t);
1738
1757
  return;
1739
1758
  }
1740
- const s = i[0].from, a = i[i.length - 1].to;
1741
- t >= s && t <= a && this._materialize(t);
1759
+ const s = i[0].from, l = i[i.length - 1].to;
1760
+ t >= s && t <= l && this._materialize(t);
1742
1761
  return;
1743
1762
  }
1744
1763
  t !== void 0 && this._materialize(t);
@@ -1766,17 +1785,17 @@ class It {
1766
1785
  return { index: -1, total: this.total ?? this.getTotal(), cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
1767
1786
  if (!i)
1768
1787
  break;
1769
- const c = this.deltas.get(s) ?? 0;
1770
- if (this._materialize(s), (this.deltas.get(s) ?? 0) === c)
1788
+ const d = this.deltas.get(s) ?? 0;
1789
+ if (this._materialize(s), (this.deltas.get(s) ?? 0) === d)
1771
1790
  break;
1772
1791
  }
1773
- const a = this.prefixSum(s);
1792
+ const l = this.prefixSum(s);
1774
1793
  return {
1775
1794
  index: s,
1776
- total: this.total ?? a.total,
1777
- cumulative: a.cumulative,
1778
- currentValue: a.currentValue,
1779
- safeIndex: a.safeIndex
1795
+ total: this.total ?? l.total,
1796
+ cumulative: l.cumulative,
1797
+ currentValue: l.currentValue,
1798
+ safeIndex: l.safeIndex
1780
1799
  };
1781
1800
  }
1782
1801
  /**
@@ -1793,10 +1812,10 @@ class It {
1793
1812
  for (; s << 1 <= this.size; )
1794
1813
  s <<= 1;
1795
1814
  for (; s > 0; s >>= 1) {
1796
- const a = n + s;
1797
- if (a <= this.size) {
1798
- const f = (this.tree.get(a) ?? 0) + this.baseValue * s;
1799
- (t ? i + f < e : i + f <= e) && (n = a, i += f);
1815
+ const l = n + s;
1816
+ if (l <= this.size) {
1817
+ const m = (this.tree.get(l) ?? 0) + this.baseValue * s;
1818
+ (t ? i + m < e : i + m <= e) && (n = l, i += m);
1800
1819
  }
1801
1820
  }
1802
1821
  return t ? n : n - 1;
@@ -1809,42 +1828,42 @@ class It {
1809
1828
  _findIndexLarge(e, t, n) {
1810
1829
  if (this.size === 0)
1811
1830
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
1812
- const i = $r(this.size);
1831
+ const i = tn(this.size);
1813
1832
  if (i === 0n)
1814
1833
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
1815
1834
  this._materializeRanges(t.materializeOption);
1816
1835
  const s = t.materializeOption?.materialize === !0;
1817
1836
  for (; ; ) {
1818
- let a = 0n, c = i - 1n, f, b, S = this.total;
1819
- for (; a <= c; ) {
1820
- const h = a + c >> 1n, C = Number(h), G = this.prefixSum(C);
1821
- if (S = G.total, n ? G.cumulative >= e : G.cumulative <= e)
1822
- if (f = h, b = G, n) {
1837
+ let l = 0n, d = i - 1n, m, b, v = this.total;
1838
+ for (; l <= d; ) {
1839
+ const h = l + d >> 1n, O = Number(h), W = this.prefixSum(O);
1840
+ if (v = W.total, n ? W.cumulative >= e : W.cumulative <= e)
1841
+ if (m = h, b = W, n) {
1823
1842
  if (h === 0n)
1824
1843
  break;
1825
- c = h - 1n;
1844
+ d = h - 1n;
1826
1845
  } else
1827
- a = h + 1n;
1846
+ l = h + 1n;
1828
1847
  else if (n)
1829
- a = h + 1n;
1848
+ l = h + 1n;
1830
1849
  else {
1831
1850
  if (h === 0n)
1832
1851
  break;
1833
- c = h - 1n;
1852
+ d = h - 1n;
1834
1853
  }
1835
1854
  }
1836
- const w = b, V = f !== void 0 ? Number(f) : -1;
1837
- if (s && V >= 0) {
1838
- const h = this.deltas.get(V) ?? 0;
1839
- if (this._materialize(V), (this.deltas.get(V) ?? 0) !== h)
1855
+ const T = b, C = m !== void 0 ? Number(m) : -1;
1856
+ if (s && C >= 0) {
1857
+ const h = this.deltas.get(C) ?? 0;
1858
+ if (this._materialize(C), (this.deltas.get(C) ?? 0) !== h)
1840
1859
  continue;
1841
1860
  }
1842
1861
  return {
1843
- index: V,
1844
- total: S,
1845
- cumulative: w?.cumulative,
1846
- currentValue: w?.currentValue,
1847
- safeIndex: w?.safeIndex
1862
+ index: C,
1863
+ total: v,
1864
+ cumulative: T?.cumulative,
1865
+ currentValue: T?.currentValue,
1866
+ safeIndex: T?.safeIndex
1848
1867
  };
1849
1868
  }
1850
1869
  }
@@ -1861,19 +1880,19 @@ class It {
1861
1880
  return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
1862
1881
  if (this.size === 0)
1863
1882
  return { cumulative: 0, total: this.total ?? 0, currentValue: 0, safeIndex: 0 };
1864
- const n = le(Math.trunc(e), 0, this.size - 1), i = t?.materializeOption;
1883
+ const n = se(Math.trunc(e), 0, this.size - 1), i = t?.materializeOption;
1865
1884
  this._materializeRanges(i, n, !0);
1866
- let s = 0, a = n + 1;
1867
- for (; a > 0; ) {
1868
- const f = this.tree.get(a) ?? 0;
1869
- s += f;
1870
- const b = Rt(a);
1885
+ let s = 0, l = n + 1;
1886
+ for (; l > 0; ) {
1887
+ const m = this.tree.get(l) ?? 0;
1888
+ s += m;
1889
+ const b = Nt(l);
1871
1890
  if (b === 0)
1872
1891
  break;
1873
- a -= b;
1892
+ l -= b;
1874
1893
  }
1875
- const c = i?.materialize ? this.get(n) : (this.deltas.get(n) || 0) + this.baseValue;
1876
- return { cumulative: s + this.baseValue * (n + 1), total: this.total, currentValue: c, safeIndex: n };
1894
+ const d = i?.materialize ? this.get(n) : (this.deltas.get(n) || 0) + this.baseValue;
1895
+ return { cumulative: s + this.baseValue * (n + 1), total: this.total, currentValue: d, safeIndex: n };
1877
1896
  }
1878
1897
  /**
1879
1898
  * @method get
@@ -1906,7 +1925,7 @@ class It {
1906
1925
  else {
1907
1926
  this.total = this._computeTreeTotal();
1908
1927
  const n = this.prefixSum(this.getSize() - 1);
1909
- n.cumulative !== n.total && T.error("Inconsistent Fenwick Tree state");
1928
+ n.cumulative !== n.total && P.error("Inconsistent Fenwick Tree state");
1910
1929
  }
1911
1930
  return this.total;
1912
1931
  }
@@ -1930,10 +1949,10 @@ class It {
1930
1949
  let s = n + 1;
1931
1950
  for (; s <= this.size; ) {
1932
1951
  t.set(s, (t.get(s) ?? 0) + i);
1933
- const a = Rt(s);
1934
- if (a === 0)
1952
+ const l = Nt(s);
1953
+ if (l === 0)
1935
1954
  break;
1936
- s += a;
1955
+ s += l;
1937
1956
  }
1938
1957
  }
1939
1958
  this.tree = t, this.total = this._computeTreeTotal();
@@ -2013,7 +2032,7 @@ class It {
2013
2032
  this.size = t, this.rebuildTree();
2014
2033
  }
2015
2034
  const i = this.prefixSum(this.getSize() - 1);
2016
- i.cumulative !== i.total && T.error("Inconsistent Fenwick Tree state");
2035
+ i.cumulative !== i.total && P.error("Inconsistent Fenwick Tree state");
2017
2036
  }
2018
2037
  /**
2019
2038
  * @private
@@ -2047,17 +2066,17 @@ class It {
2047
2066
  _propagateDeltaToGrownNodes(e, t, n, i) {
2048
2067
  let s = e + 1;
2049
2068
  for (; s <= n; ) {
2050
- const a = Rt(s);
2051
- if (a === 0)
2069
+ const l = Nt(s);
2070
+ if (l === 0)
2052
2071
  break;
2053
- s += a;
2072
+ s += l;
2054
2073
  }
2055
2074
  for (; s <= i; ) {
2056
2075
  this.tree.set(s, (this.tree.get(s) ?? 0) + t);
2057
- const a = Rt(s);
2058
- if (a === 0)
2076
+ const l = Nt(s);
2077
+ if (l === 0)
2059
2078
  break;
2060
- s += a;
2079
+ s += l;
2061
2080
  }
2062
2081
  }
2063
2082
  /**
@@ -2070,15 +2089,15 @@ class It {
2070
2089
  */
2071
2090
  _growSize(e, t) {
2072
2091
  if (this.size = t, this.deltas.size > 0) {
2073
- const n = It._minCoveredLowBound(e, t);
2092
+ const n = St._minCoveredLowBound(e, t);
2074
2093
  if (e - n < this.deltas.size)
2075
2094
  for (let s = n; s < e; s++) {
2076
- const a = this.deltas.get(s);
2077
- a === void 0 || a === 0 || this._propagateDeltaToGrownNodes(s, a, e, t);
2095
+ const l = this.deltas.get(s);
2096
+ l === void 0 || l === 0 || this._propagateDeltaToGrownNodes(s, l, e, t);
2078
2097
  }
2079
2098
  else
2080
- for (const [s, a] of this.deltas.entries())
2081
- a === 0 || s < n || this._propagateDeltaToGrownNodes(s, a, e, t);
2099
+ for (const [s, l] of this.deltas.entries())
2100
+ l === 0 || s < n || this._propagateDeltaToGrownNodes(s, l, e, t);
2082
2101
  }
2083
2102
  this.total = this._computeTreeTotal();
2084
2103
  }
@@ -2148,20 +2167,20 @@ class It {
2148
2167
  return this._findIndex(e, t ?? {}, !1);
2149
2168
  }
2150
2169
  }
2151
- const Wr = (r, e) => {
2170
+ const rn = (r, e) => {
2152
2171
  const t = r?.sampleRange, n = e?.sampleRange;
2153
2172
  return t === n ? !1 : t && n ? t.from !== n.from || t.to !== n.to : !0;
2154
- }, Ur = (r, e, t) => {
2173
+ }, nn = (r, e, t) => {
2155
2174
  const n = Number.isFinite(r) && r > 0 ? Math.trunc(r) : 0, i = g(null), s = g({ size: n, valueOrFn: e, options: t });
2156
- i.current === null && (i.current = new It(n, e, t));
2157
- const a = i.current, c = s.current, f = c.size !== n, b = c.valueOrFn !== e, S = Wr(c.options, t), w = c.size === 0 && n > 0 && (!i.current || i.current.base === 0);
2158
- if (b || S) {
2159
- const V = t?.resetOnValueFnChange ?? !0;
2160
- S || b && V || w ? (t?.debug && T.debug("[useFenwickMapTree] reset", { valueOrFnChanged: b, optionsChanged: S }), a.reset(n, e, t)) : (f && (t?.debug && T.debug("[useFenwickMapTree] resize (with valueFn change)", { from: c.size, to: n }), a.changeSize(n)), t?.debug && T.debug("[useFenwickMapTree] setValueFn (no reset)", { valueOrFnChanged: b }), a.setValueFn(e, { reset: !1 })), s.current = { size: n, valueOrFn: e, options: t };
2161
- } else f && (t?.debug && T.debug("[useFenwickMapTree] resize", { from: c.size, to: n }), w ? a.reset(n, e, t) : a.changeSize(n), s.current = { size: n, valueOrFn: e, options: t });
2162
- return a;
2175
+ i.current === null && (i.current = new St(n, e, t));
2176
+ const l = i.current, d = s.current, m = d.size !== n, b = d.valueOrFn !== e, v = rn(d.options, t), T = d.size === 0 && n > 0 && (!i.current || i.current.base === 0);
2177
+ if (b || v) {
2178
+ const C = t?.resetOnValueFnChange ?? !0;
2179
+ v || b && C || T ? (t?.debug && P.debug("[useFenwickMapTree] reset", { valueOrFnChanged: b, optionsChanged: v }), l.reset(n, e, t)) : (m && (t?.debug && P.debug("[useFenwickMapTree] resize (with valueFn change)", { from: d.size, to: n }), l.changeSize(n)), t?.debug && P.debug("[useFenwickMapTree] setValueFn (no reset)", { valueOrFnChanged: b }), l.setValueFn(e, { reset: !1 })), s.current = { size: n, valueOrFn: e, options: t };
2180
+ } else m && (t?.debug && P.debug("[useFenwickMapTree] resize", { from: d.size, to: n }), T ? l.reset(n, e, t) : l.changeSize(n), s.current = { size: n, valueOrFn: e, options: t });
2181
+ return l;
2163
2182
  };
2164
- class Kr {
2183
+ class sn {
2165
2184
  key;
2166
2185
  value;
2167
2186
  prev = null;
@@ -2170,7 +2189,7 @@ class Kr {
2170
2189
  this.key = e, this.value = t;
2171
2190
  }
2172
2191
  }
2173
- class jt {
2192
+ class er {
2174
2193
  head = null;
2175
2194
  tail = null;
2176
2195
  /**
@@ -2211,188 +2230,180 @@ class jt {
2211
2230
  this.remove(e), this.addToTail(e);
2212
2231
  }
2213
2232
  }
2214
- function jr(r) {
2215
- const e = g(/* @__PURE__ */ new Map()), t = g(new jt()), n = Math.floor(r), i = g(n);
2216
- q(() => {
2233
+ function on(r) {
2234
+ const e = g(/* @__PURE__ */ new Map()), t = g(new er()), n = Math.floor(r), i = g(n);
2235
+ X(() => {
2217
2236
  if (i.current = n, Number.isNaN(n) || n < 0) {
2218
- T.warn(`useLruCache: invalid capacity ${r}; the cache will not store any entries.`), e.current.clear(), t.current = new jt();
2237
+ P.warn(`useLruCache: invalid capacity ${r}; the cache will not store any entries.`), e.current.clear(), t.current = new er();
2219
2238
  return;
2220
2239
  }
2221
2240
  if (Number.isFinite(n))
2222
2241
  for (; e.current.size > n; ) {
2223
- const S = t.current.removeHead();
2224
- if (S)
2225
- e.current.delete(S.key);
2242
+ const v = t.current.removeHead();
2243
+ if (v)
2244
+ e.current.delete(v.key);
2226
2245
  else
2227
2246
  break;
2228
2247
  }
2229
2248
  }, [r, n]);
2230
- const s = I((S) => {
2231
- const w = e.current.get(S);
2232
- if (w)
2233
- return t.current.moveToTail(w), w.value;
2234
- }, []), a = I((S, w) => {
2235
- const V = i.current;
2236
- if (Number.isNaN(V) || V <= 0)
2249
+ const s = S((v) => {
2250
+ const T = e.current.get(v);
2251
+ if (T)
2252
+ return t.current.moveToTail(T), T.value;
2253
+ }, []), l = S((v, T) => {
2254
+ const C = i.current;
2255
+ if (Number.isNaN(C) || C <= 0)
2237
2256
  return;
2238
- let h = e.current.get(S);
2257
+ let h = e.current.get(v);
2239
2258
  if (h)
2240
- h.value = w, t.current.moveToTail(h);
2259
+ h.value = T, t.current.moveToTail(h);
2241
2260
  else {
2242
- if (e.current.size >= V) {
2243
- const C = t.current.removeHead();
2244
- C && e.current.delete(C.key);
2261
+ if (e.current.size >= C) {
2262
+ const O = t.current.removeHead();
2263
+ O && e.current.delete(O.key);
2245
2264
  }
2246
- h = new Kr(S, w), e.current.set(S, h), t.current.addToTail(h);
2265
+ h = new sn(v, T), e.current.set(v, h), t.current.addToTail(h);
2247
2266
  }
2248
- }, []), c = I((S) => e.current.has(S), []), f = I((S) => {
2249
- const w = e.current.get(S);
2250
- w && (t.current.remove(w), e.current.delete(S));
2251
- }, []), b = I(() => {
2252
- e.current.clear(), t.current = new jt();
2267
+ }, []), d = S((v) => e.current.has(v), []), m = S((v) => {
2268
+ const T = e.current.get(v);
2269
+ T && (t.current.remove(T), e.current.delete(v));
2270
+ }, []), b = S(() => {
2271
+ e.current.clear(), t.current = new er();
2253
2272
  }, []);
2254
- return Fe(() => ({ get: s, set: a, has: c, remove: f, clear: b }), [s, a, c, f, b]);
2273
+ return _e(() => ({ get: s, set: l, has: d, remove: m, clear: b }), [s, l, d, m, b]);
2255
2274
  }
2256
- const Gr = 1e4, cn = () => {
2257
- const { get: r, set: e, has: t, clear: n } = jr(Gr);
2258
- return Fe(() => ({ get: r, set: e, has: t, clear: n }), [r, e, t, n]);
2259
- }, un = (r, e) => {
2275
+ const an = 1e4, vn = () => {
2276
+ const { get: r, set: e, has: t, clear: n } = on(an);
2277
+ return _e(() => ({ get: r, set: e, has: t, clear: n }), [r, e, t, n]);
2278
+ }, In = (r, e) => {
2260
2279
  const t = g(e), n = g(r);
2261
- nt(() => {
2280
+ et(() => {
2262
2281
  t.current = e, n.current = r;
2263
2282
  }, [e, r]);
2264
2283
  const i = g(/* @__PURE__ */ new WeakMap());
2265
- return I((s) => {
2284
+ return S((s) => {
2266
2285
  if (!s || i.current.has(s))
2267
2286
  return;
2268
- const a = (c) => {
2269
- t.current?.enableBridge !== !1 && n.current.current?.applyWheel(c);
2287
+ const l = (d) => {
2288
+ t.current?.enableBridge !== !1 && n.current.current?.applyWheel(d);
2270
2289
  };
2271
- return s.addEventListener("wheel", a, { passive: !1 }), i.current.set(s, a), () => {
2272
- i.current.get(s) === a && (s.removeEventListener("wheel", a), i.current.delete(s));
2290
+ return s.addEventListener("wheel", l, { passive: !1 }), i.current.set(s, l), () => {
2291
+ i.current.get(s) === l && (s.removeEventListener("wheel", l), i.current.delete(s));
2273
2292
  };
2274
2293
  }, []);
2275
- }, Pe = (r, e) => e <= 0 ? 0 : le(r, 0, e - 1), lr = (r) => ({
2294
+ }, Ie = (r, e) => e <= 0 ? 0 : se(r, 0, e - 1), xr = (r) => ({
2276
2295
  top: Math.max(0, r?.top ?? 0),
2277
2296
  bottom: Math.max(0, r?.bottom ?? 0)
2278
- }), Ke = (r, e) => r <= e ? 0 : r - e, Pt = (r, e) => r <= 0 ? 0 : r + e, Yt = 1e3, cr = 2e3, Zr = 1048576, Jr = 40, Qr = (r) => {
2279
- const e = r.ownerDocument.defaultView?.getSelection();
2280
- if (!e || e.isCollapsed || e.rangeCount === 0)
2281
- return !1;
2282
- for (let t = 0; t < e.rangeCount; t += 1)
2283
- if (e.getRangeAt(t).intersectsNode(r))
2284
- return !0;
2285
- return !1;
2286
- }, Dt = (r) => {
2297
+ }), Qe = (r, e) => r <= e ? 0 : r - e, Mt = (r, e) => r <= 0 ? 0 : r + e, $t = 1e3, vr = 2e3, ln = 1048576, cn = 40, kt = (r) => {
2287
2298
  if (!Number.isFinite(r)) return 0n;
2288
2299
  const e = Math.trunc(r);
2289
2300
  return e <= 0 ? 0n : BigInt(e);
2290
- }, en = (r, e, t, n, i, s, a, c) => {
2291
- const f = Dt(n);
2292
- if (f === 0n)
2301
+ }, un = (r, e, t, n, i, s, l, d) => {
2302
+ const m = kt(n);
2303
+ if (m === 0n)
2293
2304
  return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
2294
- const b = (P) => P < 0n ? 0n : P >= f ? f - 1n : P, S = { materializeOption: { materialize: !1 } }, { index: w, cumulative: V } = s.findIndexAtOrAfter(r, S);
2305
+ const b = (y) => y < 0n ? 0n : y >= m ? m - 1n : y, v = { materializeOption: { materialize: !1 } }, { index: T, cumulative: C } = s.findIndexAtOrAfter(r, v);
2295
2306
  let h;
2296
- w === -1 ? h = f - 1n : (V === r ? h = Dt(w + 1) : h = Dt(w), h >= f && (h = f - 1n)), r <= 0 && (h = 0n), c && r >= a && (h = f - 1n);
2297
- const C = (P) => {
2298
- const _ = Number(P);
2299
- if (!Number.isSafeInteger(_))
2307
+ T === -1 ? h = m - 1n : (C === r ? h = kt(T + 1) : h = kt(T), h >= m && (h = m - 1n)), r <= 0 && (h = 0n), d && r >= l && (h = m - 1n);
2308
+ const O = (y) => {
2309
+ const Y = Number(y);
2310
+ if (!Number.isSafeInteger(Y))
2300
2311
  return null;
2301
- const { cumulative: M } = s.prefixSum(_, { materializeOption: { materialize: !1 } });
2302
- if (!Number.isFinite(M))
2312
+ const { cumulative: w } = s.prefixSum(Y, { materializeOption: { materialize: !1 } });
2313
+ if (!Number.isFinite(w))
2303
2314
  return null;
2304
- const { index: Z } = s.findIndexAtOrAfter(M + 0.5, { materializeOption: { materialize: !1 } });
2315
+ const { index: Z } = s.findIndexAtOrAfter(w + 0.5, { materializeOption: { materialize: !1 } });
2305
2316
  if (Z === -1)
2306
2317
  return null;
2307
- const Q = Dt(Z);
2308
- return Q > P ? Q : null;
2309
- }, G = (P) => {
2310
- let _ = 0, M = P, Z = P, Q = 0n, W = 0;
2311
- for (; M < f && _ < e; ) {
2312
- const Ie = Number(M), z = i(Ie);
2313
- if (_ += z, Z = M, M += 1n, Q += 1n, !Number.isFinite(z) || z < 0)
2318
+ const Q = kt(Z);
2319
+ return Q > y ? Q : null;
2320
+ }, W = (y) => {
2321
+ let Y = 0, w = y, Z = y, Q = 0n, K = 0;
2322
+ for (; w < m && Y < e; ) {
2323
+ const he = Number(w), A = i(he);
2324
+ if (Y += A, Z = w, w += 1n, Q += 1n, !Number.isFinite(A) || A < 0)
2314
2325
  break;
2315
- if (z === 0) {
2316
- if (W += 1, W > Yt) {
2317
- const v = C(Z);
2318
- if (v !== null && v > M)
2319
- M = v, W = 0;
2320
- else if (v !== null && v === M && i(Number(M)) > 0)
2321
- W = 0;
2326
+ if (A === 0) {
2327
+ if (K += 1, K > $t) {
2328
+ const I = O(Z);
2329
+ if (I !== null && I > w)
2330
+ w = I, K = 0;
2331
+ else if (I !== null && I === w && i(Number(w)) > 0)
2332
+ K = 0;
2322
2333
  else
2323
2334
  break;
2324
2335
  }
2325
2336
  } else
2326
- W = 0;
2337
+ K = 0;
2327
2338
  }
2328
- return Q === 0n && (Z = P), { height: _, end: Z };
2339
+ return Q === 0n && (Z = y), { height: Y, end: Z };
2329
2340
  };
2330
- let { height: H, end: pe } = G(h);
2331
- if (H < e && h > 0n) {
2332
- let P = h, _ = H, M = 0;
2333
- for (; P > 0n && _ < e; ) {
2334
- P -= 1n;
2335
- const Q = Number(P), W = i(Q);
2336
- if (_ += W, !Number.isFinite(W) || W < 0)
2341
+ let { height: D, end: ce } = W(h);
2342
+ if (D < e && h > 0n) {
2343
+ let y = h, Y = D, w = 0;
2344
+ for (; y > 0n && Y < e; ) {
2345
+ y -= 1n;
2346
+ const Q = Number(y), K = i(Q);
2347
+ if (Y += K, !Number.isFinite(K) || K < 0)
2337
2348
  break;
2338
- if (W === 0) {
2339
- if (M += 1, M > Yt) {
2340
- const Ie = Number(P);
2341
- if (!Number.isSafeInteger(Ie))
2349
+ if (K === 0) {
2350
+ if (w += 1, w > $t) {
2351
+ const he = Number(y);
2352
+ if (!Number.isSafeInteger(he))
2342
2353
  break;
2343
- const { cumulative: z } = s.prefixSum(Ie, { materializeOption: { materialize: !1 } });
2344
- if (!Number.isFinite(z))
2354
+ const { cumulative: A } = s.prefixSum(he, { materializeOption: { materialize: !1 } });
2355
+ if (!Number.isFinite(A))
2345
2356
  break;
2346
- const { index: v } = s.findIndexAtOrAfter(z - 0.5, { materializeOption: { materialize: !1 } }), U = v === -1 ? -1n : Dt(v);
2347
- if (U >= 0n && U < P)
2348
- P = U + 1n, M = 0;
2349
- else if (U === P && P >= 1n && i(Number(P - 1n)) > 0)
2350
- M = 0;
2357
+ const { index: I } = s.findIndexAtOrAfter(A - 0.5, { materializeOption: { materialize: !1 } }), G = I === -1 ? -1n : kt(I);
2358
+ if (G >= 0n && G < y)
2359
+ y = G + 1n, w = 0;
2360
+ else if (G === y && y >= 1n && i(Number(y - 1n)) > 0)
2361
+ w = 0;
2351
2362
  else
2352
2363
  break;
2353
2364
  }
2354
2365
  } else
2355
- M = 0;
2366
+ w = 0;
2356
2367
  }
2357
- h = b(P);
2358
- const Z = G(h);
2359
- H = Z.height, pe = Z.end;
2368
+ h = b(y);
2369
+ const Z = W(h);
2370
+ D = Z.height, ce = Z.end;
2360
2371
  }
2361
- const me = b(h), oe = b(pe), ce = b(me - BigInt(Math.max(0, t))), he = b(oe + BigInt(Math.max(0, t)));
2372
+ const ue = b(h), re = b(ce), oe = b(ue - BigInt(Math.max(0, t))), de = b(re + BigInt(Math.max(0, t)));
2362
2373
  return {
2363
- renderingStartIndex: Pe(Number(ce), n),
2364
- renderingEndIndex: Pe(Number(he), n),
2365
- visibleStartIndex: Pe(Number(me), n),
2366
- visibleEndIndex: Pe(Number(oe), n)
2374
+ renderingStartIndex: Ie(Number(oe), n),
2375
+ renderingEndIndex: Ie(Number(de), n),
2376
+ visibleStartIndex: Ie(Number(ue), n),
2377
+ visibleEndIndex: Ie(Number(re), n)
2367
2378
  };
2368
- }, tn = (r, e, t, n, i, s, a) => {
2379
+ }, dn = (r, e, t, n, i, s, l) => {
2369
2380
  if (n === 0)
2370
2381
  return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
2371
- const c = Number.isFinite(a), f = c ? Math.min(Math.max(0, r), a) : Math.max(0, r);
2382
+ const d = Number.isFinite(l), m = d ? Math.min(Math.max(0, r), l) : Math.max(0, r);
2372
2383
  if (n >= Number.MAX_SAFE_INTEGER)
2373
- return en(f, e, t, n, i, s, a, c);
2374
- const { index: b, cumulative: S, currentValue: w } = s.findIndexAtOrAfter(f, { materializeOption: { materialize: !1 } }), V = b === -1 ? e <= 0 || (S ?? 0) < f + (w ?? 0) ? n - 1 : 0 : b;
2375
- let h = Pe(V, n), C = 0;
2376
- if (b !== -1 && S === f)
2377
- h = Pe(b + 1, n), C = 0;
2378
- else if (h === b && S !== void 0 && w !== void 0)
2379
- C = S - w - f;
2384
+ return un(m, e, t, n, i, s, l, d);
2385
+ const { index: b, cumulative: v, currentValue: T } = s.findIndexAtOrAfter(m, { materializeOption: { materialize: !1 } }), C = b === -1 ? e <= 0 || (v ?? 0) < m + (T ?? 0) ? n - 1 : 0 : b;
2386
+ let h = Ie(C, n), O = 0;
2387
+ if (b !== -1 && v === m)
2388
+ h = Ie(b + 1, n), O = 0;
2389
+ else if (h === b && v !== void 0 && T !== void 0)
2390
+ O = v - T - m;
2380
2391
  else {
2381
- const { cumulative: P, currentValue: _ } = s.prefixSum(h, { materializeOption: { materialize: !1 } });
2382
- C = (P ?? 0) - (_ ?? 0) - f;
2392
+ const { cumulative: y, currentValue: Y } = s.prefixSum(h, { materializeOption: { materialize: !1 } });
2393
+ O = (y ?? 0) - (Y ?? 0) - m;
2383
2394
  }
2384
- const G = C, H = (P, _) => {
2385
- let M = P, Z = _, Q = 0;
2386
- for (; M < n && Z < e; ) {
2387
- const W = i(M);
2388
- if (Z += W, M++, !Number.isFinite(W) || W < 0)
2395
+ const W = O, D = (y, Y) => {
2396
+ let w = y, Z = Y, Q = 0;
2397
+ for (; w < n && Z < e; ) {
2398
+ const K = i(w);
2399
+ if (Z += K, w++, !Number.isFinite(K) || K < 0)
2389
2400
  break;
2390
- if (W === 0) {
2391
- if (Q++, Q > Yt) {
2392
- const { cumulative: Ie } = s.prefixSum(M - 1, { materializeOption: { materialize: !1 } }), { index: z } = Number.isFinite(Ie) ? s.findIndexAtOrAfter(Ie + 0.5, { materializeOption: { materialize: !1 } }) : { index: -1 };
2393
- if (z > M)
2394
- M = z, Q = 0;
2395
- else if (z === M && i(M) > 0)
2401
+ if (K === 0) {
2402
+ if (Q++, Q > $t) {
2403
+ const { cumulative: he } = s.prefixSum(w - 1, { materializeOption: { materialize: !1 } }), { index: A } = Number.isFinite(he) ? s.findIndexAtOrAfter(he + 0.5, { materializeOption: { materialize: !1 } }) : { index: -1 };
2404
+ if (A > w)
2405
+ w = A, Q = 0;
2406
+ else if (A === w && i(w) > 0)
2396
2407
  Q = 0;
2397
2408
  else
2398
2409
  break;
@@ -2400,44 +2411,44 @@ const Gr = 1e4, cn = () => {
2400
2411
  } else
2401
2412
  Q = 0;
2402
2413
  }
2403
- return { cursor: M, height: Z };
2404
- }, pe = H(h, C);
2405
- let me = pe.cursor;
2406
- if (C = pe.height, C < e && h > 0) {
2407
- let P = C + Math.abs(Math.min(0, G)), _ = h - 1, M = 0;
2408
- for (; _ >= 0 && P < e; ) {
2409
- const Q = i(_);
2410
- if (P += Q, !Number.isFinite(Q) || Q < 0) {
2411
- _--;
2414
+ return { cursor: w, height: Z };
2415
+ }, ce = D(h, O);
2416
+ let ue = ce.cursor;
2417
+ if (O = ce.height, O < e && h > 0) {
2418
+ let y = O + Math.abs(Math.min(0, W)), Y = h - 1, w = 0;
2419
+ for (; Y >= 0 && y < e; ) {
2420
+ const Q = i(Y);
2421
+ if (y += Q, !Number.isFinite(Q) || Q < 0) {
2422
+ Y--;
2412
2423
  break;
2413
2424
  }
2414
2425
  if (Q === 0) {
2415
- if (M++, M > Yt) {
2416
- const { cumulative: W } = s.prefixSum(_, { materializeOption: { materialize: !1 } }), { index: Ie } = Number.isFinite(W) ? s.findIndexAtOrAfter(W - 0.5, { materializeOption: { materialize: !1 } }) : { index: -1 };
2417
- if (Ie !== -1 && Ie < _) {
2418
- _ = Ie, M = 0;
2426
+ if (w++, w > $t) {
2427
+ const { cumulative: K } = s.prefixSum(Y, { materializeOption: { materialize: !1 } }), { index: he } = Number.isFinite(K) ? s.findIndexAtOrAfter(K - 0.5, { materializeOption: { materialize: !1 } }) : { index: -1 };
2428
+ if (he !== -1 && he < Y) {
2429
+ Y = he, w = 0;
2419
2430
  continue;
2420
2431
  }
2421
- if (Ie === _ && _ >= 1 && i(_ - 1) > 0)
2422
- M = 0;
2432
+ if (he === Y && Y >= 1 && i(Y - 1) > 0)
2433
+ w = 0;
2423
2434
  else {
2424
- _--;
2435
+ Y--;
2425
2436
  break;
2426
2437
  }
2427
2438
  }
2428
2439
  } else
2429
- M = 0;
2430
- _--;
2440
+ w = 0;
2441
+ Y--;
2431
2442
  }
2432
- h = Pe(_ + 1, n);
2433
- const Z = H(h, 0);
2434
- me = Z.cursor, C = Z.height;
2443
+ h = Ie(Y + 1, n);
2444
+ const Z = D(h, 0);
2445
+ ue = Z.cursor, O = Z.height;
2435
2446
  }
2436
- const oe = Pe(h - t, n), ce = Pe(Math.max(me - 1, h), n), he = Pe(ce + t, n);
2437
- return { renderingStartIndex: oe, renderingEndIndex: he, visibleStartIndex: h, visibleEndIndex: ce };
2438
- }, ur = (r, e, t) => {
2447
+ const re = Ie(h - t, n), oe = Ie(Math.max(ue - 1, h), n), de = Ie(oe + t, n);
2448
+ return { renderingStartIndex: re, renderingEndIndex: de, visibleStartIndex: h, visibleEndIndex: oe };
2449
+ }, Ir = (r, e, t) => {
2439
2450
  const n = Math.max(0, e ?? 0), i = g({ last: 0, id: null, arg: null }).current;
2440
- return q(
2451
+ return X(
2441
2452
  () => () => {
2442
2453
  if (i.id !== null && (cancelAnimationFrame(i.id), i.id = null), i.arg !== null && r.current) {
2443
2454
  try {
@@ -2449,679 +2460,727 @@ const Gr = 1e4, cn = () => {
2449
2460
  }
2450
2461
  },
2451
2462
  [i, r, t]
2452
- ), I(
2463
+ ), S(
2453
2464
  (s) => {
2454
2465
  if (i.arg = s, i.id !== null) return;
2455
- const a = (c) => {
2466
+ const l = (d) => {
2456
2467
  if (i.id = null, i.arg === null) return;
2457
- const f = c - i.last;
2458
- if (n === 0 || i.last === 0 || f >= n) {
2468
+ const m = d - i.last;
2469
+ if (n === 0 || i.last === 0 || m >= n) {
2459
2470
  if (r.current)
2460
2471
  try {
2461
2472
  t(r.current, i.arg);
2462
2473
  } catch (b) {
2463
2474
  console.error("[useThrottledInvoker] Error invoking callback", b);
2464
2475
  }
2465
- i.arg = null, i.last = c;
2476
+ i.arg = null, i.last = d;
2466
2477
  }
2467
- i.arg !== null && (i.id = requestAnimationFrame(a));
2478
+ i.arg !== null && (i.id = requestAnimationFrame(l));
2468
2479
  };
2469
- i.id = requestAnimationFrame(a);
2480
+ i.id = requestAnimationFrame(l);
2470
2481
  },
2471
2482
  [n, t, r, i]
2472
2483
  );
2473
- }, rn = xr.memo(({ index: r, top: e, height: t, item: n, children: i, clipItemHeight: s, enableKeyboardNavigation: a, onKeyDown: c, onFocus: f, registerItemRef: b }) => {
2474
- const S = I((C) => b(r, C), [r, b]), w = I((C) => c(C, r), [r, c]), V = I(() => f(r), [r, f]), h = I((C) => {
2475
- C.currentTarget.focus({ preventScroll: !0 });
2484
+ }, fn = Er.memo(({ index: r, top: e, height: t, item: n, children: i, clipItemHeight: s, enableKeyboardNavigation: l, onKeyDown: d, onEscapeKeyDown: m, onFocus: b, registerItemRef: v }) => {
2485
+ const T = S((D) => v(r, D), [r, v]), C = S((D) => d(D, r), [r, d]), h = S((D) => m?.(D, r), [r, m]), O = S(() => b(r), [r, b]), W = S((D) => {
2486
+ D.currentTarget.focus({ preventScroll: !0 });
2476
2487
  }, []);
2477
- return /* @__PURE__ */ de(
2478
- "div",
2479
- {
2480
- ref: S,
2481
- "data-index": r,
2482
- "data-virtualscroll-item": "true",
2483
- className: "aqvs-item-container",
2484
- style: {
2485
- top: e,
2486
- height: t,
2487
- overflow: s ? "hidden" : void 0
2488
- },
2489
- tabIndex: a ? -1 : void 0,
2490
- onPointerDown: a ? h : void 0,
2491
- onKeyDownCapture: a ? w : void 0,
2492
- onFocusCapture: a ? V : void 0,
2493
- children: i(n, r)
2494
- }
2488
+ return (
2489
+ // 行ラッパーの role は消費側の複合ウィジェット契約 (listbox / tree / grid — README「Composite widget
2490
+ // roles」) の所有物で、パッケージが既定 role を課すと衝突する。キー/フォーカス結線は
2491
+ // enableKeyboardNavigation の行ナビゲーション機構そのもの。
2492
+ // biome-ignore lint/a11y/noStaticElementInteractions: role は消費側の複合ウィジェット契約の所有物 (上記)
2493
+ /* @__PURE__ */ ie(
2494
+ "div",
2495
+ {
2496
+ ref: T,
2497
+ "data-index": r,
2498
+ "data-virtualscroll-item": "true",
2499
+ className: "aqvs-item-container",
2500
+ style: {
2501
+ top: e,
2502
+ height: t,
2503
+ overflow: s ? "hidden" : void 0
2504
+ },
2505
+ tabIndex: l ? -1 : void 0,
2506
+ onPointerDown: l ? W : void 0,
2507
+ onKeyDownCapture: l ? C : void 0,
2508
+ onKeyDown: l && m ? h : void 0,
2509
+ onFocusCapture: l ? O : void 0,
2510
+ children: i(n, r)
2511
+ }
2512
+ )
2495
2513
  );
2496
- }), nn = ({
2514
+ }), mn = ({
2497
2515
  itemCount: r,
2498
2516
  getItem: e,
2499
2517
  getItemKey: t,
2500
2518
  getItemHeight: n,
2501
2519
  viewportSize: i,
2502
2520
  overscanCount: s = 15,
2503
- className: a,
2504
- testId: c,
2505
- onScroll: f,
2521
+ className: l,
2522
+ testId: d,
2523
+ onScroll: m,
2506
2524
  onRangeChange: b,
2507
- children: S,
2508
- background: w,
2509
- initialScrollIndex: V,
2525
+ children: v,
2526
+ background: T,
2527
+ initialScrollIndex: C,
2510
2528
  initialScrollOffset: h,
2511
- initialScrollAnchor: C,
2512
- callbackThrottleMs: G = 5,
2513
- contentInsets: H,
2514
- onItemFocus: pe,
2515
- scrollBarOptions: me,
2516
- behaviorOptions: oe,
2517
- onWheelHorizontal: ce,
2518
- horizontalKeyInputs: he,
2519
- horizontalKeyStep: P = Jr,
2520
- contentProps: _
2521
- }, M) => {
2522
- const { width: Z, enableThumbDrag: Q, enableTrackClick: W, enableArrowButtons: Ie, enableScrollToTopBottomButtons: z, renderThumbOverlay: v, tapScrollCircleOptions: U } = me ?? {}, { enablePointerDrag: ge, pointerDragInputs: qe, enableKeyboardNavigation: ee = !0, wheelSpeedMultiplier: X, inertiaOptions: Xe, overscrollBehavior: $e, clipItemHeight: Ce = !1, resetOnGetItemHeightChange: ze = !1 } = oe ?? {}, [je, Ge] = rt(0), K = i ?? je, Ae = I((o) => {
2523
- Ge((u) => u === o ? u : o);
2524
- }, []), ue = g(null), be = g({
2529
+ initialScrollAnchor: O,
2530
+ callbackThrottleMs: W = 5,
2531
+ contentInsets: D,
2532
+ onItemFocus: ce,
2533
+ scrollBarOptions: ue,
2534
+ behaviorOptions: re,
2535
+ onWheelHorizontal: oe,
2536
+ horizontalKeyInputs: de,
2537
+ horizontalKeyStep: y = cn,
2538
+ contentProps: Y,
2539
+ liveRegion: w
2540
+ }, Z) => {
2541
+ const { width: Q, enableThumbDrag: K, enableTrackClick: he, enableArrowButtons: A, enableScrollToTopBottomButtons: I, renderThumbOverlay: G, tapScrollCircleOptions: fe } = ue ?? {}, { enablePointerDrag: $e, pointerDragInputs: Ue, enableKeyboardNavigation: z = !0, enableEscapeRowReturn: ke = !1, wheelSpeedMultiplier: We, inertiaOptions: Ve, overscrollBehavior: Fe, clipItemHeight: Ke = !1, resetOnGetItemHeightChange: De = !1 } = re ?? {}, [Pe, ze] = Je(0), be = i ?? Pe, Se = S((o) => {
2542
+ ze((c) => c === o ? c : o);
2543
+ }, []), j = g(null), tt = g({
2525
2544
  renderingStartIndex: 0,
2526
2545
  renderingEndIndex: 0,
2527
2546
  visibleStartIndex: 0,
2528
2547
  visibleEndIndex: 0,
2529
2548
  scrollPosition: 0,
2530
2549
  totalHeight: 0
2531
- }), Te = g(C && r > 0 ? { index: le(Math.trunc(C.index), 0, r - 1), align: "top", offset: -Math.max(0, C.offsetPx ?? 0) } : null), et = g(!1), mt = g(!0);
2532
- q(() => {
2533
- if (mt.current) {
2534
- mt.current = !1;
2550
+ }), Ge = g(O && r > 0 ? { index: se(Math.trunc(O.index), 0, r - 1), align: "top", offset: -Math.max(0, O.offsetPx ?? 0) } : null), ft = g(!1), st = g(!0);
2551
+ X(() => {
2552
+ if (st.current) {
2553
+ st.current = !1;
2535
2554
  return;
2536
2555
  }
2537
- ze && (Te.current = null);
2538
- }, [ze, n]);
2539
- const N = Fe(() => lr(H), [H]), [it] = rt(() => {
2540
- const u = C?.index ?? V, m = typeof u == "number" && Number.isFinite(u) ? Math.max(0, Math.trunc(u)) : 0;
2541
- return { from: Math.max(0, m - 50), to: m + 50 };
2542
- }), vt = Fe(
2556
+ De && (Ge.current = null);
2557
+ }, [De, n]);
2558
+ const N = _e(() => xr(D), [D]), [gt] = Je(() => {
2559
+ const c = O?.index ?? C, u = typeof c == "number" && Number.isFinite(c) ? Math.max(0, Math.trunc(c)) : 0;
2560
+ return { from: Math.max(0, u - 50), to: u + 50 };
2561
+ }), ne = _e(
2543
2562
  // 目的: Fenwick Tree のオプション設定
2544
2563
  // 依存関係: resetOnGetItemHeightChange, initialSampleRange (マウント時固定)
2545
2564
  // itemCount には依存させない (依存させると追記のたびに options 参照が変わり、計測済み高さが全消去される)。
2546
2565
  // この useMemo により sampleRange を毎レンダー新規生成しない = 参照同一性由来の破壊的 reset を防ぐ。
2547
2566
  () => ({
2548
- sampleRange: it,
2549
- resetOnValueFnChange: ze,
2567
+ sampleRange: gt,
2568
+ resetOnValueFnChange: De,
2550
2569
  materialize: !0
2551
2570
  }),
2552
- [ze, it]
2553
- ), E = Ur(r, n, vt), [J] = rt(() => {
2554
- let o = 0, u = 0;
2555
- if (C && r > 0) {
2556
- const m = le(Math.trunc(C.index), 0, r - 1), A = Math.max(0, C.offsetPx ?? 0), L = le(m - s * 2, 0, r - 1), O = le(m + s * 2, 0, r - 1), k = m > 0 || A > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: L, to: O }] } } : void 0, { cumulative: se, total: Ne, currentValue: Se } = E.prefixSum(m, k), fe = Math.max(se - Se + A, 0);
2557
- o = Pt(fe, N.top), u = Ne ?? E.getTotal();
2558
- } else if (typeof V == "number") {
2559
- const m = le(V, 0, r - 1), A = le(m - s * 2, 0, r - 1), L = le(m + s * 2, 0, r - 1), O = V > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: A, to: L }] } } : void 0, { cumulative: k, total: se, currentValue: Ne } = E.prefixSum(V, O), Se = Math.max(k - Ne, 0);
2560
- o = Pt(Se, N.top), u = se ?? E.getTotal();
2561
- } else typeof h == "number" && (o = Pt(Math.max(h, 0), N.top)), u = E.getTotal();
2562
- return { position: o, total: u };
2563
- }), [Ze, ht] = rt(J.position), [Le, st] = rt(J.total), ie = g(J.position), p = g(N.top), F = g(f ?? void 0), B = g(b ?? void 0), Y = g(ce), te = (he?.length ?? 0) > 0, Me = !!ce;
2564
- q(() => {
2565
- te && (ee || T.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."), Me || T.warn("[VirtualScroll] horizontalKeyInputs is set but onWheelHorizontal is missing; horizontal keyboard scrolling is disabled because the package does not own the horizontal axis."), Number.isFinite(P) && P > 0 || T.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${P}. Horizontal arrow keys are left untouched.`));
2566
- }, [te, Me, ee, P]);
2567
- const j = g(/* @__PURE__ */ new Map()), re = g(null), De = g(null), [ne, Je] = rt(null), [Oe, ae] = rt(!1), ve = g(null), We = g(!1), Ve = g(0), ft = g(!1), Qe = g(!1), ot = g(r);
2568
- ot.current !== r && (ot.current = r, Qe.current = !0), nt(() => {
2569
- F.current = f ?? void 0, B.current = b ?? void 0, Y.current = ce;
2570
- }, [b, f, ce]);
2571
- const d = I(
2571
+ [De, gt]
2572
+ ), V = nn(r, n, ne), [ot] = Je(() => {
2573
+ let o = 0, c = 0;
2574
+ if (O && r > 0) {
2575
+ const u = se(Math.trunc(O.index), 0, r - 1), _ = Math.max(0, O.offsetPx ?? 0), k = se(u - s * 2, 0, r - 1), F = se(u + s * 2, 0, r - 1), B = u > 0 || _ > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: k, to: F }] } } : void 0, { cumulative: te, total: we, currentValue: pe } = V.prefixSum(u, B), le = Math.max(te - pe + _, 0);
2576
+ o = Mt(le, N.top), c = we ?? V.getTotal();
2577
+ } else if (typeof C == "number") {
2578
+ const u = se(C, 0, r - 1), _ = se(u - s * 2, 0, r - 1), k = se(u + s * 2, 0, r - 1), F = C > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: _, to: k }] } } : void 0, { cumulative: B, total: te, currentValue: we } = V.prefixSum(C, F), pe = Math.max(B - we, 0);
2579
+ o = Mt(pe, N.top), c = te ?? V.getTotal();
2580
+ } else typeof h == "number" && (o = Mt(Math.max(h, 0), N.top)), c = V.getTotal();
2581
+ return { position: o, total: c };
2582
+ }), [je, mt] = Je(ot.position), [Ae, f] = Je(ot.total), M = g(ot.position), q = g(N.top), H = g(m ?? void 0), J = g(b ?? void 0), Te = g(oe), ee = (de?.length ?? 0) > 0, xe = !!oe;
2583
+ X(() => {
2584
+ ee && (z || P.warn("[VirtualScroll] horizontalKeyInputs is set but behaviorOptions.enableKeyboardNavigation is false; horizontal keyboard scrolling is disabled because the row key handler is not mounted."), xe || P.warn("[VirtualScroll] horizontalKeyInputs is set but onWheelHorizontal is missing; horizontal keyboard scrolling is disabled because the package does not own the horizontal axis."), Number.isFinite(y) && y > 0 || P.warn(`[VirtualScroll] horizontalKeyStep must be a finite positive number, received ${y}. Horizontal arrow keys are left untouched.`));
2585
+ }, [ee, xe, z, y]);
2586
+ const ye = g(/* @__PURE__ */ new Map()), $ = g(null), Re = g(null), [Ce, me] = Je(null), [Ee, rt] = Je(!1), Le = g(null), at = g(!1), Me = g(0), nt = g(!1), p = g(!1), R = g(r);
2587
+ R.current !== r && (R.current = r, p.current = !0), et(() => {
2588
+ H.current = m ?? void 0, J.current = b ?? void 0, Te.current = oe;
2589
+ }, [b, m, oe]);
2590
+ const ae = S(
2572
2591
  (o) => {
2573
- if (ee && o && typeof o.focus == "function")
2592
+ if (z && o && typeof o.focus == "function")
2574
2593
  try {
2575
2594
  o.focus({ preventScroll: !0 });
2576
2595
  } catch {
2577
2596
  o.focus();
2578
2597
  }
2579
2598
  },
2580
- [ee]
2581
- ), y = I((o, { position: u, totalHeight: m }) => {
2582
- o(u, m);
2583
- }, []), xe = ur(F, G, y), tt = I((o, u) => {
2584
- o(u);
2585
- }, []), _e = ur(B, G, tt), ct = g(N.top);
2586
- ct.current = N.top;
2587
- const ut = g(xe);
2588
- ut.current = xe, q(() => (et.current = !1, () => {
2589
- et.current = !0, ve.current && (clearTimeout(ve.current), ve.current = null);
2590
- }), []), q(() => {
2591
- ee || (j.current.clear(), re.current = null, De.current = null);
2592
- }, [ee]);
2593
- const at = I(
2594
- (o, u) => {
2595
- if (!u) {
2596
- j.current.delete(o);
2599
+ [z]
2600
+ ), it = S((o, { position: c, totalHeight: u }) => {
2601
+ o(c, u);
2602
+ }, []), Ne = Ir(H, W, it), zt = S((o, c) => {
2603
+ o(c);
2604
+ }, []), ct = Ir(J, W, zt), Ye = g(N.top);
2605
+ Ye.current = N.top;
2606
+ const bt = g(Ne);
2607
+ bt.current = Ne, X(() => (ft.current = !1, () => {
2608
+ ft.current = !0, Le.current && (clearTimeout(Le.current), Le.current = null);
2609
+ }), []), X(() => {
2610
+ z || (ye.current.clear(), $.current = null, Re.current = null);
2611
+ }, [z]);
2612
+ const Pt = S(
2613
+ (o, c) => {
2614
+ if (!c) {
2615
+ ye.current.delete(o);
2597
2616
  return;
2598
2617
  }
2599
- ee && (j.current.set(o, u), re.current === o && (re.current = null, De.current = o, d(u)));
2618
+ z && (ye.current.set(o, c), $.current === o && ($.current = null, Re.current = o, ae(c)));
2600
2619
  },
2601
- [ee, d]
2602
- ), gt = 0.01, pt = g({
2620
+ [z, ae]
2621
+ ), Ft = 0.01, ut = g({
2603
2622
  rafId: null,
2604
2623
  loopActive: !1,
2605
2624
  idleFrames: 0,
2606
- lastRenderedPosition: J.position
2607
- }), yt = I(() => {
2608
- const o = pt.current;
2625
+ lastRenderedPosition: ot.position
2626
+ }), yt = S(() => {
2627
+ const o = ut.current;
2609
2628
  o.rafId !== null && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(o.rafId), o.rafId = null, o.loopActive = !1, o.idleFrames = 0;
2610
2629
  }, []);
2611
- q(
2630
+ X(
2612
2631
  () => () => {
2613
2632
  yt();
2614
2633
  },
2615
2634
  [yt]
2616
2635
  );
2617
- const wt = g(() => {
2618
- }), Nt = I(() => {
2619
- const o = pt.current;
2636
+ const Yt = g(() => {
2637
+ }), Ct = S(() => {
2638
+ const o = ut.current;
2620
2639
  o.rafId = null;
2621
- const u = ie.current, m = Ke(u, ct.current), A = E.getTotal();
2622
- if (ht((O) => Math.abs(O - u) < gt ? O : u), Math.abs(o.lastRenderedPosition - u) >= gt ? (ut.current({ position: m, totalHeight: A }), o.lastRenderedPosition = u, o.idleFrames = 0) : o.idleFrames += 1, o.idleFrames >= 2) {
2640
+ const c = M.current, u = Qe(c, Ye.current), _ = V.getTotal();
2641
+ if (mt((F) => Math.abs(F - c) < Ft ? F : c), Math.abs(o.lastRenderedPosition - c) >= Ft ? (bt.current({ position: u, totalHeight: _ }), o.lastRenderedPosition = c, o.idleFrames = 0) : o.idleFrames += 1, o.idleFrames >= 2) {
2623
2642
  yt();
2624
2643
  return;
2625
2644
  }
2626
2645
  if (typeof requestAnimationFrame == "function") {
2627
- o.rafId = requestAnimationFrame((O) => wt.current(O));
2646
+ o.rafId = requestAnimationFrame((F) => Yt.current(F));
2628
2647
  return;
2629
2648
  }
2630
2649
  o.loopActive = !1;
2631
- }, [E, yt]);
2632
- wt.current = Nt;
2633
- const At = I(() => {
2634
- const o = pt.current;
2650
+ }, [V, yt]);
2651
+ Yt.current = Ct;
2652
+ const Bt = S(() => {
2653
+ const o = ut.current;
2635
2654
  if (o.idleFrames = 0, !o.loopActive) {
2636
2655
  if (o.loopActive = !0, typeof requestAnimationFrame == "function") {
2637
- o.rafId = requestAnimationFrame(Nt);
2656
+ o.rafId = requestAnimationFrame(Ct);
2638
2657
  return;
2639
2658
  }
2640
2659
  o.loopActive = !1;
2641
2660
  }
2642
- }, [Nt]), we = I(
2643
- (o, u) => {
2644
- const m = u?.immediate ?? !1, A = Ke(o, N.top);
2645
- if (ie.current = o, m) {
2646
- pt.current.lastRenderedPosition = o, pt.current.idleFrames = 0, ht(o), xe({ position: A, totalHeight: E.getTotal() });
2661
+ }, [Ct]), ge = S(
2662
+ (o, c) => {
2663
+ const u = c?.immediate ?? !1, _ = Qe(o, N.top);
2664
+ if (M.current = o, u) {
2665
+ ut.current.lastRenderedPosition = o, ut.current.idleFrames = 0, mt(o), Ne({ position: _, totalHeight: V.getTotal() });
2647
2666
  return;
2648
2667
  }
2649
- At();
2668
+ Bt();
2650
2669
  },
2651
- [At, E, N.top, xe]
2652
- ), bt = I((o, u = 0) => {
2653
- const m = ue.current;
2654
- if (!m)
2670
+ [Bt, V, N.top, Ne]
2671
+ ), xt = S((o, c = 0) => {
2672
+ const u = j.current;
2673
+ if (!u)
2655
2674
  return o;
2656
- const A = m.getScrollPosition();
2657
- Ve.current += 1;
2658
- const L = m.getContentSize() + u, O = m.getViewportSize(), k = m.scrollTo(o, { contentSize: L, viewportSize: O });
2659
- return k === A && (Ve.current = Math.max(0, Ve.current - 1)), Math.abs(k - o) > 0.5 && (ft.current = !0), k;
2660
- }, []), Lt = g(!1);
2661
- q(() => {
2662
- if (!Lt.current)
2663
- if (Lt.current = !0, C == null && typeof V != "number" && typeof h == "number") {
2664
- const o = Pt(Math.max(h, 0), N.top), u = Math.abs(o - ie.current) > 0.5;
2665
- we(o, { immediate: !0 }), u && ue.current?.scrollTo(o);
2675
+ const _ = u.getScrollPosition();
2676
+ Me.current += 1;
2677
+ const k = u.getContentSize() + c, F = u.getViewportSize(), B = u.scrollTo(o, { contentSize: k, viewportSize: F });
2678
+ return B === _ && (Me.current = Math.max(0, Me.current - 1)), Math.abs(B - o) > 0.5 && (nt.current = !0), B;
2679
+ }, []), Dt = g(!1);
2680
+ X(() => {
2681
+ if (!Dt.current)
2682
+ if (Dt.current = !0, O == null && typeof C != "number" && typeof h == "number") {
2683
+ const o = Mt(Math.max(h, 0), N.top), c = Math.abs(o - M.current) > 0.5;
2684
+ ge(o, { immediate: !0 }), c && j.current?.scrollTo(o);
2666
2685
  } else
2667
- we(ie.current, { immediate: !0 });
2668
- }, [C, V, h, N.top, we]), q(() => {
2669
- const o = E.getTotal();
2670
- if (Le !== o) {
2671
- st(o);
2686
+ ge(M.current, { immediate: !0 });
2687
+ }, [O, C, h, N.top, ge]), X(() => {
2688
+ const o = V.getTotal();
2689
+ if (Ae !== o) {
2690
+ f(o);
2672
2691
  return;
2673
2692
  }
2674
- if (ft.current) {
2675
- ft.current = !1;
2676
- const u = ue.current;
2677
- if (u && Math.abs(u.getScrollPosition() - ie.current) > 0.5) {
2678
- const m = bt(ie.current);
2679
- ft.current = !1, we(m, { immediate: !0 });
2693
+ if (nt.current) {
2694
+ nt.current = !1;
2695
+ const c = j.current;
2696
+ if (c && Math.abs(c.getScrollPosition() - M.current) > 0.5) {
2697
+ const u = xt(M.current);
2698
+ nt.current = !1, ge(u, { immediate: !0 });
2680
2699
  }
2681
2700
  }
2682
- }, [E, Le, r, bt, we]), q(() => {
2683
- if (Te.current !== null) {
2684
- const { index: o, align: u, offset: m } = Te.current, A = Pe(o, r), { cumulative: L, currentValue: O } = E.prefixSum(A, { materializeOption: { materialize: !1 } });
2685
- if (L !== void 0 && O !== void 0) {
2686
- const k = Math.max(L - O, 0);
2687
- let se = k;
2688
- u === "bottom" ? se = L - K : u === "center" && (se = k + O / 2 - K / 2), m && (se -= m), se = Math.max(0, se);
2689
- const Ne = Math.max(0, Le + N.top + N.bottom - K), Se = Math.min(Pt(se, N.top), Ne);
2690
- Math.abs(Se - ie.current) > 1 && (T.debug("[VirtualScroll] Drift correction", {
2691
- from: ie.current,
2692
- to: Se,
2693
- targetIndex: A
2694
- }), Ve.current === 0 && (Ve.current += 1), ue.current?.scrollTo(Se), we(Se, { immediate: !0 }));
2701
+ }, [V, Ae, r, xt, ge]), X(() => {
2702
+ if (Ge.current !== null) {
2703
+ const { index: o, align: c, offset: u } = Ge.current, _ = Ie(o, r), { cumulative: k, currentValue: F } = V.prefixSum(_, { materializeOption: { materialize: !1 } });
2704
+ if (k !== void 0 && F !== void 0) {
2705
+ const B = Math.max(k - F, 0);
2706
+ let te = B;
2707
+ c === "bottom" ? te = k - be : c === "center" && (te = B + F / 2 - be / 2), u && (te -= u), te = Math.max(0, te);
2708
+ const we = Math.max(0, Ae + N.top + N.bottom - be), pe = Math.min(Mt(te, N.top), we);
2709
+ Math.abs(pe - M.current) > 1 && (P.debug("[VirtualScroll] Drift correction", {
2710
+ from: M.current,
2711
+ to: pe,
2712
+ targetIndex: _
2713
+ }), Me.current === 0 && (Me.current += 1), j.current?.scrollTo(pe), ge(pe, { immediate: !0 }));
2695
2714
  }
2696
2715
  }
2697
- Qe.current = !1;
2698
- }, [Le, E, r, N.top, we, K, N.bottom]), q(() => {
2699
- const o = p.current;
2700
- if (o === N.top || (p.current = N.top, Te.current))
2716
+ p.current = !1;
2717
+ }, [Ae, V, r, N.top, ge, be, N.bottom]), X(() => {
2718
+ const o = q.current;
2719
+ if (o === N.top || (q.current = N.top, Ge.current))
2701
2720
  return;
2702
- const u = Ke(ie.current, o), m = Pt(u, N.top);
2703
- ie.current = m, ue.current?.scrollTo(m), we(m, { immediate: !0 });
2704
- }, [N.top, we]);
2705
- const Ot = I(
2706
- (o, u) => {
2721
+ const c = Qe(M.current, o), u = Mt(c, N.top);
2722
+ M.current = u, j.current?.scrollTo(u), ge(u, { immediate: !0 });
2723
+ }, [N.top, ge]);
2724
+ const At = S(
2725
+ (o, c) => {
2707
2726
  if (r === 0)
2708
2727
  return;
2709
- const m = Pe(o, r), A = E.get(m), L = u - A, O = E.update(m, u);
2710
- O !== void 0 && st(O), T.debug("[VirtualScroll] Updated item size manually", { index: m, size: u, total: O });
2711
- let k = Te.current ? Te.current.index : null;
2712
- if (k === null) {
2713
- const se = ie.current, Ne = lr(H).top, Se = Ke(se, Ne), { index: fe, cumulative: Be } = E.findIndexAtOrAfter(Se, { materializeOption: { materialize: !1 } });
2714
- k = Be !== void 0 && Be === Se ? fe + 1 : fe;
2728
+ const u = Ie(o, r), _ = V.get(u), k = c - _, F = V.update(u, c);
2729
+ F !== void 0 && f(F), P.debug("[VirtualScroll] Updated item size manually", { index: u, size: c, total: F });
2730
+ let B = Ge.current ? Ge.current.index : null;
2731
+ if (B === null) {
2732
+ const te = M.current, we = xr(D).top, pe = Qe(te, we), { index: le, cumulative: qe } = V.findIndexAtOrAfter(pe, { materializeOption: { materialize: !1 } });
2733
+ B = qe !== void 0 && qe === pe ? le + 1 : le;
2715
2734
  }
2716
- if (k !== -1 && m < k && L !== 0) {
2717
- const se = ie.current, Ne = se + L;
2718
- bt(Ne, L), we(Ne, { immediate: !0 }), T.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)", { from: se, to: Ne, causedByIndex: m, delta: L, activeVisibleStartIndex: k });
2735
+ if (B !== -1 && u < B && k !== 0) {
2736
+ const te = M.current, we = te + k;
2737
+ xt(we, k), ge(we, { immediate: !0 }), P.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)", { from: te, to: we, causedByIndex: u, delta: k, activeVisibleStartIndex: B });
2719
2738
  }
2720
2739
  },
2721
- [E, r, bt, we, H]
2722
- ), Ue = I(
2723
- (o, u) => {
2724
- if (!ue.current || r === 0)
2740
+ [V, r, xt, ge, D]
2741
+ ), a = S(
2742
+ (o, c) => {
2743
+ if (!j.current || r === 0)
2725
2744
  return;
2726
- const m = Pe(o, r), A = Pe(m - s * 2, r), L = Pe(m + s * 2, r), { cumulative: O, total: k, currentValue: se } = E.prefixSum(m, { materializeOption: { materialize: !0, ranges: [{ from: A, to: L }] } });
2727
- if (T.debug("[VirtualScroll] Scrolling to index:", m, "ItemBottom:", O, "Total height:", k, "ItemHeight:", se, "safeIndexFrom:", A, "safeIndexTo:", L), !k)
2745
+ const u = Ie(o, r), _ = Ie(u - s * 2, r), k = Ie(u + s * 2, r), { cumulative: F, total: B, currentValue: te } = V.prefixSum(u, { materializeOption: { materialize: !0, ranges: [{ from: _, to: k }] } });
2746
+ if (P.debug("[VirtualScroll] Scrolling to index:", u, "ItemBottom:", F, "Total height:", B, "ItemHeight:", te, "safeIndexFrom:", _, "safeIndexTo:", k), !B)
2728
2747
  return;
2729
- const Ne = Math.max(O - se, 0);
2730
- let Se = Ne;
2731
- u?.align === "bottom" ? Se = O - K : u?.align === "center" && (Se = Ne + se / 2 - K / 2), u?.offset && (Se -= u.offset), Se = Math.max(0, Se);
2732
- const fe = Pt(Se, N.top), Be = ue.current?.getContentSize() ?? k + N.top + N.bottom, ke = Math.max(0, Be - K), He = Math.min(fe, ke);
2733
- Te.current = {
2734
- index: m,
2735
- align: u?.align,
2736
- offset: u?.offset
2748
+ const we = Math.max(F - te, 0);
2749
+ let pe = we;
2750
+ c?.align === "bottom" ? pe = F - be : c?.align === "center" && (pe = we + te / 2 - be / 2), c?.offset && (pe -= c.offset), pe = Math.max(0, pe);
2751
+ const le = Mt(pe, N.top), qe = j.current?.getContentSize() ?? B + N.top + N.bottom, Oe = Math.max(0, qe - be), Xe = Math.min(le, Oe);
2752
+ Ge.current = {
2753
+ index: u,
2754
+ align: c?.align,
2755
+ offset: c?.offset
2737
2756
  };
2738
- const Ct = ue.current?.getScrollPosition() ?? -1, Xt = Math.abs(Ct - He) > 0.5;
2739
- We.current = !1, Ve.current = 0, Xt && (We.current = !0, Ve.current += 1, ue.current?.scrollTo(He)), st(k), we(He, { immediate: !0 }), T.debug("[VirtualScroll] Setting scroll position to:", He, { original: fe, max: ke });
2757
+ const Ot = j.current?.getScrollPosition() ?? -1, Gt = Math.abs(Ot - Xe) > 0.5;
2758
+ at.current = !1, Me.current = 0, Gt && (at.current = !0, Me.current += 1, j.current?.scrollTo(Xe)), f(B), ge(Xe, { immediate: !0 }), P.debug("[VirtualScroll] Setting scroll position to:", Xe, { original: le, max: Oe });
2740
2759
  },
2741
- [E, s, r, N.top, N.bottom, K, we]
2742
- ), Vt = g(C && r === 0 ? C : null);
2743
- q(() => {
2744
- const o = Vt.current;
2745
- !o || r === 0 || (Vt.current = null, Ue(le(Math.trunc(o.index), 0, r - 1), { align: "top", offset: -Math.max(0, o.offsetPx ?? 0) }));
2746
- }, [r, Ue]);
2747
- const l = I(
2760
+ [V, s, r, N.top, N.bottom, be, ge]
2761
+ ), x = g(O && r === 0 ? O : null);
2762
+ X(() => {
2763
+ const o = x.current;
2764
+ !o || r === 0 || (x.current = null, a(se(Math.trunc(o.index), 0, r - 1), { align: "top", offset: -Math.max(0, o.offsetPx ?? 0) }));
2765
+ }, [r, a]);
2766
+ const E = S(
2748
2767
  (o) => {
2749
- if (!ue.current || r === 0)
2768
+ if (!j.current || r === 0)
2750
2769
  return;
2751
- const u = E.getTotal(), m = le(Math.floor(o), 0, u), { index: A, cumulative: L, currentValue: O } = E.findIndexAtOrAfter(m, { materializeOption: { materialize: !1 } }), se = (L ?? 0) - (O ?? 0) - m;
2752
- Ue(A, { offset: se });
2770
+ const c = V.getTotal(), u = se(Math.floor(o), 0, c), { index: _, cumulative: k, currentValue: F } = V.findIndexAtOrAfter(u, { materializeOption: { materialize: !1 } }), te = (k ?? 0) - (F ?? 0) - u;
2771
+ a(_, { offset: te });
2753
2772
  },
2754
- [E, r, Ue]
2755
- ), x = I(() => {
2773
+ [V, r, a]
2774
+ ), L = S(() => {
2756
2775
  if (r === 0)
2757
2776
  return null;
2758
- const o = Ke(ie.current, N.top), { index: u, cumulative: m, currentValue: A } = E.findIndexAtOrAfter(o, { materializeOption: { materialize: !1 } });
2759
- if (u === -1)
2777
+ const o = Qe(M.current, N.top), { index: c, cumulative: u, currentValue: _ } = V.findIndexAtOrAfter(o, { materializeOption: { materialize: !1 } });
2778
+ if (c === -1)
2760
2779
  return { index: r - 1, offsetPx: 0 };
2761
- if (m === o)
2762
- return { index: le(u + 1, 0, r - 1), offsetPx: 0 };
2763
- const L = (m ?? 0) - (A ?? 0);
2764
- return { index: u, offsetPx: Math.max(0, o - L) };
2765
- }, [E, r, N.top]), R = I(
2780
+ if (u === o)
2781
+ return { index: se(c + 1, 0, r - 1), offsetPx: 0 };
2782
+ const k = (u ?? 0) - (_ ?? 0);
2783
+ return { index: c, offsetPx: Math.max(0, o - k) };
2784
+ }, [V, r, N.top]), U = S(
2766
2785
  (o) => {
2767
- const u = Ke(ie.current, N.top), m = typeof o == "function" ? o(u) : o;
2768
- l(m);
2769
- const A = ue.current?.getScrollPosition(), L = typeof A == "number" ? A : ie.current;
2770
- return we(L), Ke(L, ct.current);
2786
+ const c = Qe(M.current, N.top), u = typeof o == "function" ? o(c) : o;
2787
+ E(u);
2788
+ const _ = j.current?.getScrollPosition(), k = typeof _ == "number" ? _ : M.current;
2789
+ return ge(k), Qe(k, Ye.current);
2771
2790
  },
2772
- [N.top, l, we]
2773
- ), D = I((o) => {
2774
- const u = ue.current;
2775
- if (!u)
2776
- return Ke(ie.current, ct.current);
2777
- const m = u.scrollTo((A) => A + o);
2778
- return Ke(m, ct.current);
2779
- }, []), $ = I((o) => ue.current?.applyWheel(o) ?? !1, []), ye = I(
2780
- (o, u) => {
2781
- T.debug("[VirtualScroll] Scroll position changed:", o);
2782
- const m = We.current;
2783
- m && (We.current = !1);
2784
- const A = Ve.current > 0;
2785
- A && (Ve.current = 0);
2786
- const L = Qe.current && ot.current === r;
2787
- if (m || A || L || (Te.current = null), we(o), z) {
2788
- if (m || A)
2791
+ [N.top, E, ge]
2792
+ ), ve = S((o) => {
2793
+ const c = j.current;
2794
+ if (!c)
2795
+ return Qe(M.current, Ye.current);
2796
+ const u = c.scrollTo((_) => _ + o);
2797
+ return Qe(u, Ye.current);
2798
+ }, []), Be = S((o) => j.current?.applyWheel(o) ?? !1, []), He = S(
2799
+ (o, c) => {
2800
+ P.debug("[VirtualScroll] Scroll position changed:", o);
2801
+ const u = at.current;
2802
+ u && (at.current = !1);
2803
+ const _ = Me.current > 0;
2804
+ _ && (Me.current = 0);
2805
+ const k = p.current && R.current === r;
2806
+ if (u || _ || k || (Ge.current = null), ge(o), I) {
2807
+ if (u || _)
2789
2808
  return;
2790
- const O = o - u;
2791
- if (T.debug("[VirtualScroll] Scroll diff:", O, "New:", o, "Prev:", u), Math.abs(O) > 1) {
2792
- const k = O > 0 ? "down" : "up";
2793
- Je(k), ae(!0), T.debug("[VirtualScroll] Showing scroll buttons. Direction:", k), ve.current && clearTimeout(ve.current), ve.current = setTimeout(() => {
2794
- ae(!1), T.debug("[VirtualScroll] Hiding scroll buttons");
2809
+ const F = o - c;
2810
+ if (P.debug("[VirtualScroll] Scroll diff:", F, "New:", o, "Prev:", c), Math.abs(F) > 1) {
2811
+ const B = F > 0 ? "down" : "up";
2812
+ me(B), rt(!0), P.debug("[VirtualScroll] Showing scroll buttons. Direction:", B), Le.current && clearTimeout(Le.current), Le.current = setTimeout(() => {
2813
+ rt(!1), P.debug("[VirtualScroll] Hiding scroll buttons");
2795
2814
  }, 2e3);
2796
2815
  }
2797
2816
  }
2798
2817
  },
2799
- [we, z, r]
2800
- ), Re = Fe(() => Ke(Ze, N.top), [N.top, Ze]), Ee = Fe(() => {
2801
- const o = E.getTotal(), u = tn(Re, K, s, r, n, E, o);
2802
- return T.debug("[VirtualScroll] Calculated rendering range:", () => ({
2803
- ...u,
2804
- scrollPosition: Re,
2818
+ [ge, I, r]
2819
+ ), lt = _e(() => Qe(je, N.top), [N.top, je]), Ze = _e(() => {
2820
+ const o = V.getTotal(), c = dn(lt, be, s, r, n, V, o);
2821
+ return P.debug("[VirtualScroll] Calculated rendering range:", () => ({
2822
+ ...c,
2823
+ scrollPosition: lt,
2805
2824
  renderingContentSize: o,
2806
2825
  overscanCount: s,
2807
- viewportSize: K
2808
- })), u;
2809
- }, [Re, K, s, r, n, E]), { renderingStartIndex: lt, renderingEndIndex: Ye, visibleStartIndex: xt, visibleEndIndex: _t } = Ee, Tt = I(
2810
- (o, u) => {
2811
- if (!ee || r === 0)
2826
+ viewportSize: be
2827
+ })), c;
2828
+ }, [lt, be, s, r, n, V]), { renderingStartIndex: pt, renderingEndIndex: wt, visibleStartIndex: vt, visibleEndIndex: Rt } = Ze, ht = S(
2829
+ (o, c) => {
2830
+ if (!z || r === 0)
2812
2831
  return;
2813
- const m = Pe(o, r);
2814
- if (!(u?.ensureVisible ?? !0)) {
2815
- const ke = j.current.get(m);
2816
- ke && (re.current = null, De.current = m, d(ke));
2832
+ const u = Ie(o, r);
2833
+ if (!(c?.ensureVisible ?? !0)) {
2834
+ const Oe = ye.current.get(u);
2835
+ Oe && ($.current = null, Re.current = u, ae(Oe));
2817
2836
  return;
2818
2837
  }
2819
- const L = E.prefixSum(m, { materializeOption: { materialize: !1 } }), O = L.currentValue, k = Math.max(L.cumulative - O, 0), se = k + O, Ne = Ke(ie.current, N.top), Se = Ne + K;
2820
- if (k < Ne || se > Se) {
2821
- Ue(m);
2822
- const ke = j.current.get(m);
2823
- ke ? (re.current = null, De.current = m, d(ke)) : re.current = m;
2838
+ const k = V.prefixSum(u, { materializeOption: { materialize: !1 } }), F = k.currentValue, B = Math.max(k.cumulative - F, 0), te = B + F, we = Qe(M.current, N.top), pe = we + be;
2839
+ if (B < we || te > pe) {
2840
+ a(u);
2841
+ const Oe = ye.current.get(u);
2842
+ Oe ? ($.current = null, Re.current = u, ae(Oe)) : $.current = u;
2824
2843
  return;
2825
2844
  }
2826
- const Be = j.current.get(m);
2827
- if (Be) {
2828
- re.current = null, De.current = m, d(Be);
2845
+ const qe = ye.current.get(u);
2846
+ if (qe) {
2847
+ $.current = null, Re.current = u, ae(qe);
2829
2848
  return;
2830
2849
  }
2831
- re.current = m;
2850
+ $.current = u;
2832
2851
  },
2833
- [ee, r, E, N.top, Ue, d, K]
2834
- ), Qt = I(
2835
- (o, u) => {
2836
- if (!(!ee || o.defaultPrevented) && !(o.altKey || o.metaKey || o.ctrlKey) && o.target === o.currentTarget && !o.currentTarget.isContentEditable) {
2852
+ [z, r, V, N.top, a, ae, be]
2853
+ ), sr = S(
2854
+ (o, c) => {
2855
+ if (!(!z || o.defaultPrevented) && !(o.altKey || o.metaKey || o.ctrlKey) && o.target === o.currentTarget && !o.currentTarget.isContentEditable) {
2837
2856
  if (o.key === "ArrowLeft" || o.key === "ArrowRight") {
2838
- const m = Y.current;
2839
- if (!m)
2840
- return;
2841
- const A = o.shiftKey ? "shift-arrow" : "arrow";
2842
- if (!he?.includes(A) || o.shiftKey && Qr(o.currentTarget) || !(Number.isFinite(P) && P > 0))
2857
+ const u = Te.current;
2858
+ if (!u || o.shiftKey || !de?.includes("arrow") || !(Number.isFinite(y) && y > 0))
2843
2859
  return;
2844
- o.preventDefault(), m(o.key === "ArrowLeft" ? -P : P);
2860
+ o.preventDefault(), u(o.key === "ArrowLeft" ? -y : y);
2845
2861
  return;
2846
2862
  }
2847
2863
  if (o.key === "ArrowDown") {
2848
- u < r - 1 && (o.preventDefault(), Tt(u + 1));
2864
+ c < r - 1 && (o.preventDefault(), ht(c + 1));
2849
2865
  return;
2850
2866
  }
2851
2867
  if (o.key === "ArrowUp") {
2852
- u > 0 && (o.preventDefault(), Tt(u - 1));
2868
+ c > 0 && (o.preventDefault(), ht(c - 1));
2853
2869
  return;
2854
2870
  }
2855
2871
  if (o.key === "PageDown") {
2856
- if (u < r - 1) {
2872
+ if (c < r - 1) {
2857
2873
  o.preventDefault();
2858
- const { visibleStartIndex: m, visibleEndIndex: A } = be.current, L = Math.max(A - m + 1, 1), O = Math.max(L, 1), k = Pe(Math.min(u + O, r - 1), r);
2859
- Tt(k);
2874
+ const { visibleStartIndex: u, visibleEndIndex: _ } = tt.current, k = Math.max(_ - u + 1, 1), F = Math.max(k, 1), B = Ie(Math.min(c + F, r - 1), r);
2875
+ ht(B);
2860
2876
  }
2861
2877
  return;
2862
2878
  }
2863
- if (o.key === "PageUp" && u > 0) {
2879
+ if (o.key === "PageUp" && c > 0) {
2864
2880
  o.preventDefault();
2865
- const { visibleStartIndex: m, visibleEndIndex: A } = be.current, L = Math.max(A - m + 1, 1), O = Math.max(L, 1), k = Pe(u - O, r);
2866
- Tt(k);
2881
+ const { visibleStartIndex: u, visibleEndIndex: _ } = tt.current, k = Math.max(_ - u + 1, 1), F = Math.max(k, 1), B = Ie(c - F, r);
2882
+ ht(B);
2867
2883
  }
2868
2884
  }
2869
2885
  },
2870
- [ee, r, Tt, he, P]
2871
- ), er = I(
2886
+ [z, r, ht, de, y]
2887
+ ), or = S(
2888
+ /**
2889
+ * Returns focus from an element inside the row back to the row wrapper on Escape.
2890
+ * 行内要素の Escape で行ラッパーへフォーカスを戻す処理。
2891
+ *
2892
+ * @param event - Keyboard event (bubble phase on the row wrapper) / 行ラッパー bubble フェーズのキーイベント
2893
+ * @param index - Row index / 行インデックス
2894
+ */
2895
+ (o, c) => {
2896
+ if (o.key !== "Escape" || o.defaultPrevented || o.nativeEvent.isComposing || o.target === o.currentTarget)
2897
+ return;
2898
+ const u = o.target;
2899
+ u instanceof HTMLInputElement || u instanceof HTMLTextAreaElement || u instanceof HTMLSelectElement || u.isContentEditable || (o.preventDefault(), ht(c));
2900
+ },
2901
+ [ht]
2902
+ ), ar = S(
2872
2903
  (o) => {
2873
- if (!ee)
2904
+ if (!z)
2874
2905
  return;
2875
- const u = Pe(o, r);
2876
- re.current = null, De.current = u, pe?.(u);
2906
+ const c = Ie(o, r);
2907
+ $.current = null, Re.current = c, ce?.(c);
2877
2908
  },
2878
- [ee, r, pe]
2909
+ [z, r, ce]
2879
2910
  );
2880
- q(() => {
2881
- const o = ue.current?.getScrollPosition() ?? 0, u = ie.current, m = Ke(u, N.top);
2882
- T.debug("[VirtualScroll] Range change effect triggered", () => ({
2883
- renderingStartIndex: lt,
2884
- renderingEndIndex: Ye,
2885
- visibleStartIndex: xt,
2886
- visibleEndIndex: _t,
2887
- scrollPositionState: Ze,
2888
- paneScrollPosition: u,
2889
- logicalScrollPosition: m,
2890
- contentSize: Le,
2911
+ X(() => {
2912
+ const o = j.current?.getScrollPosition() ?? 0, c = M.current, u = Qe(c, N.top);
2913
+ P.debug("[VirtualScroll] Range change effect triggered", () => ({
2914
+ renderingStartIndex: pt,
2915
+ renderingEndIndex: wt,
2916
+ visibleStartIndex: vt,
2917
+ visibleEndIndex: Rt,
2918
+ scrollPositionState: je,
2919
+ paneScrollPosition: c,
2920
+ logicalScrollPosition: u,
2921
+ contentSize: Ae,
2891
2922
  scrollPaneScrollPosition: o
2892
- })), _e({
2893
- renderingStartIndex: lt,
2894
- renderingEndIndex: Ye,
2895
- visibleStartIndex: xt,
2896
- visibleEndIndex: _t,
2897
- scrollPosition: m,
2898
- totalHeight: Le
2923
+ })), ct({
2924
+ renderingStartIndex: pt,
2925
+ renderingEndIndex: wt,
2926
+ visibleStartIndex: vt,
2927
+ visibleEndIndex: Rt,
2928
+ scrollPosition: u,
2929
+ totalHeight: Ae
2899
2930
  });
2900
- }, [Le, Ye, lt, N.top, _e, Ze, _t, xt]);
2901
- const hr = I(() => {
2902
- if (!z)
2931
+ }, [Ae, wt, pt, N.top, ct, je, Rt, vt]);
2932
+ const Mr = S(() => {
2933
+ if (!I)
2903
2934
  return null;
2904
- const o = Oe && ne !== null;
2905
- return /* @__PURE__ */ de("div", { className: "aqvs-scroll-to-edge-overlay", "data-visible": o, inert: !o, children: ne === "up" ? /* @__PURE__ */ de("div", { className: "aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top", children: /* @__PURE__ */ de(
2935
+ const o = Ee && Ce !== null;
2936
+ return /* @__PURE__ */ ie("div", { className: "aqvs-scroll-to-edge-overlay", "data-visible": o, inert: !o, children: Ce === "up" ? /* @__PURE__ */ ie("div", { className: "aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top", children: /* @__PURE__ */ ie(
2906
2937
  "button",
2907
2938
  {
2908
2939
  type: "button",
2909
2940
  className: "aqvs-scroll-to-edge-button",
2910
2941
  tabIndex: o ? 0 : -1,
2911
- onClick: (m) => {
2912
- m.stopPropagation(), We.current = !0, Ue(0), ae(!1);
2942
+ onClick: (u) => {
2943
+ u.stopPropagation(), at.current = !0, a(0), rt(!1);
2913
2944
  },
2914
2945
  children: "Top"
2915
2946
  }
2916
- ) }) : /* @__PURE__ */ de("div", { className: "aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom", children: /* @__PURE__ */ de(
2947
+ ) }) : /* @__PURE__ */ ie("div", { className: "aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom", children: /* @__PURE__ */ ie(
2917
2948
  "button",
2918
2949
  {
2919
2950
  type: "button",
2920
2951
  className: "aqvs-scroll-to-edge-button",
2921
2952
  tabIndex: o ? 0 : -1,
2922
- onClick: (m) => {
2923
- m.stopPropagation(), We.current = !0, Ue(r - 1), ae(!1);
2953
+ onClick: (u) => {
2954
+ u.stopPropagation(), at.current = !0, a(r - 1), rt(!1);
2924
2955
  },
2925
2956
  children: "Bottom"
2926
2957
  }
2927
2958
  ) }) });
2928
- }, [z, Oe, ne, Ue, r]), Bt = g(0), { visibleItems: Ht, renderAnchor: qt } = Fe(() => {
2959
+ }, [I, Ee, Ce, a, r]), Ut = g(0), { visibleItems: Wt, renderAnchor: Kt } = _e(() => {
2929
2960
  if (r === 0)
2930
2961
  return {
2931
- visibleItems: /* @__PURE__ */ de("div", { className: "aqvs-no-items-container", children: /* @__PURE__ */ de("div", { className: "aqvs-no-items-text", children: "No items" }) }),
2962
+ visibleItems: /* @__PURE__ */ ie("div", { className: "aqvs-no-items-container", children: /* @__PURE__ */ ie("div", { className: "aqvs-no-items-text", children: "No items" }) }),
2932
2963
  renderAnchor: 0
2933
2964
  };
2934
- const o = Pe(lt, r), u = Pe(Ye, r), { cumulative: m, currentValue: A } = E.prefixSum(o, { materializeOption: { materialize: !1 } }), L = m - A;
2935
- Number.isFinite(L) && Math.abs(L - Bt.current) > Zr && (Bt.current = L);
2936
- const O = Bt.current, k = [], se = [];
2937
- let Ne = 0, Se = L;
2938
- for (let fe = o; fe <= u; fe++) {
2939
- if (se.length >= cr) {
2940
- T.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.", { cap: cr, safeRenderingStartIndex: o, safeRenderingEndIndex: u });
2965
+ const o = Ie(pt, r), c = Ie(wt, r), { cumulative: u, currentValue: _ } = V.prefixSum(o, { materializeOption: { materialize: !1 } }), k = u - _;
2966
+ Number.isFinite(k) && Math.abs(k - Ut.current) > ln && (Ut.current = k);
2967
+ const F = Ut.current, B = [], te = [];
2968
+ let we = 0, pe = k;
2969
+ for (let le = o; le <= c; le++) {
2970
+ if (te.length >= vr) {
2971
+ P.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.", { cap: vr, safeRenderingStartIndex: o, safeRenderingEndIndex: c });
2941
2972
  break;
2942
2973
  }
2943
- const Be = n(fe), ke = E.get(fe), He = Be - ke;
2944
- He !== 0 && k.push({ index: fe, value: Be });
2945
- const Ct = Se + Ne, Xt = t ? t(fe) : fe;
2946
- se.push(
2947
- /* @__PURE__ */ de(
2948
- rn,
2974
+ const qe = n(le), Oe = V.get(le), Xe = qe - Oe;
2975
+ Xe !== 0 && B.push({ index: le, value: qe });
2976
+ const Ot = pe + we, Gt = t ? t(le) : le;
2977
+ te.push(
2978
+ /* @__PURE__ */ ie(
2979
+ fn,
2949
2980
  {
2950
- index: fe,
2951
- top: Ct - O,
2952
- height: Be,
2953
- item: e(fe),
2954
- clipItemHeight: Ce,
2955
- enableKeyboardNavigation: ee,
2956
- onKeyDown: Qt,
2957
- onFocus: er,
2958
- registerItemRef: at,
2959
- children: S
2981
+ index: le,
2982
+ top: Ot - F,
2983
+ height: qe,
2984
+ item: e(le),
2985
+ clipItemHeight: Ke,
2986
+ enableKeyboardNavigation: z,
2987
+ onKeyDown: sr,
2988
+ onEscapeKeyDown: ke ? or : void 0,
2989
+ onFocus: ar,
2990
+ registerItemRef: Pt,
2991
+ children: v
2960
2992
  },
2961
- Xt
2993
+ Gt
2962
2994
  )
2963
- ), Ne += He, Se += ke;
2995
+ ), we += Xe, pe += Oe;
2964
2996
  }
2965
- return k.length > 0 && Promise.resolve().then(() => {
2966
- if (et.current)
2997
+ return B.length > 0 && Promise.resolve().then(() => {
2998
+ if (ft.current)
2967
2999
  return;
2968
- let fe = 0;
2969
- for (const He of k)
2970
- if (He.index < xt) {
2971
- const Ct = E.get(He.index);
2972
- fe += He.value - Ct;
3000
+ let le = 0;
3001
+ for (const Xe of B)
3002
+ if (Xe.index < vt) {
3003
+ const Ot = V.get(Xe.index);
3004
+ le += Xe.value - Ot;
2973
3005
  }
2974
- const Be = E.updates(k);
2975
- if (et.current || typeof Be != "number")
3006
+ const qe = V.updates(B);
3007
+ if (ft.current || typeof qe != "number")
2976
3008
  return;
2977
- st(Be), T.debug("[VirtualScroll] Updated heights for items", k, "New total height:", Be);
2978
- const ke = ue.current?.getScrollPosition() ?? ie.current;
2979
- if (fe !== 0) {
2980
- const He = ke + fe;
2981
- bt(He, fe), we(He, { immediate: !0 }), T.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)", { from: ke, to: He, shiftAmount: fe });
2982
- } else ke !== ie.current && we(ke);
2983
- }), { visibleItems: se, renderAnchor: O };
3009
+ f(qe), P.debug("[VirtualScroll] Updated heights for items", B, "New total height:", qe);
3010
+ const Oe = j.current?.getScrollPosition() ?? M.current;
3011
+ if (le !== 0) {
3012
+ const Xe = Oe + le;
3013
+ xt(Xe, le), ge(Xe, { immediate: !0 }), P.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)", { from: Oe, to: Xe, shiftAmount: le });
3014
+ } else Oe !== M.current && ge(Oe);
3015
+ }), { visibleItems: te, renderAnchor: F };
2984
3016
  }, [
2985
- S,
2986
- Ce,
2987
- Le,
2988
- ee,
3017
+ v,
3018
+ Ke,
3019
+ Ae,
3020
+ z,
2989
3021
  r,
2990
- E,
3022
+ V,
2991
3023
  e,
2992
3024
  t,
2993
3025
  n,
2994
- er,
2995
- Qt,
2996
- bt,
2997
- at,
2998
- Ye,
2999
- lt,
3000
- we,
3001
- xt
3002
- ]), gr = I(
3026
+ ar,
3027
+ sr,
3028
+ ke,
3029
+ or,
3030
+ xt,
3031
+ Pt,
3032
+ wt,
3033
+ pt,
3034
+ ge,
3035
+ vt
3036
+ ]), Pr = S(
3003
3037
  (o) => {
3004
- const u = (G ?? 0) > 0, m = Math.abs(o - Ze), A = u && m > 0.5 ? Ze : o, L = Ke(A, N.top);
3005
- if (T.debug("[VirtualScroll] Rendering visible items", () => ({
3038
+ const c = (W ?? 0) > 0, u = Math.abs(o - je), _ = c && u > 0.5 ? je : o, k = Qe(_, N.top);
3039
+ if (P.debug("[VirtualScroll] Rendering visible items", () => ({
3006
3040
  currentScrollPosition: o,
3007
- effectiveScrollPosition: L,
3008
- renderingStartIndex: lt,
3009
- renderingEndIndex: Ye,
3041
+ effectiveScrollPosition: k,
3042
+ renderingStartIndex: pt,
3043
+ renderingEndIndex: wt,
3010
3044
  itemCount: r,
3011
- viewportSize: K,
3012
- callbackThrottleMs: G,
3013
- diff: m,
3014
- rawEffectiveScrollPosition: A
3045
+ viewportSize: be,
3046
+ callbackThrottleMs: W,
3047
+ diff: u,
3048
+ rawEffectiveScrollPosition: _
3015
3049
  })), r === 0)
3016
- return Ht;
3017
- const O = N.top + qt - A, k = N.bottom > 0 ? /* @__PURE__ */ de(
3050
+ return Wt;
3051
+ const F = N.top + Kt - _, B = N.bottom > 0 ? /* @__PURE__ */ ie(
3018
3052
  "div",
3019
3053
  {
3020
3054
  className: "aqvs-bottom-inset",
3021
3055
  style: {
3022
3056
  // ラッパー座標での bottom インセット位置 = コンテンツ総高さ (最終行の下端) - アンカー。
3023
- top: E.getTotal() - qt,
3057
+ top: V.getTotal() - Kt,
3024
3058
  height: N.bottom
3025
3059
  }
3026
3060
  },
3027
3061
  "virtualscroll-bottom-inset"
3028
3062
  ) : null;
3029
- return T.debug("[VirtualScroll] Rendering items", () => ({
3030
- containerTop: O,
3031
- logicalScrollPosition: Re,
3063
+ return P.debug("[VirtualScroll] Rendering items", () => ({
3064
+ containerTop: F,
3065
+ logicalScrollPosition: lt,
3032
3066
  resolvedInsets: N,
3033
- effectiveScrollPosition: L
3034
- })), /* @__PURE__ */ Mt("div", { className: "aqvs-items-wrapper", style: { top: 0, transform: `translateY(${O}px)`, willChange: "transform" }, children: [
3035
- Ht,
3036
- k
3067
+ effectiveScrollPosition: k
3068
+ })), /* @__PURE__ */ Tt("div", { className: "aqvs-items-wrapper", style: { top: 0, transform: `translateY(${F}px)`, willChange: "transform" }, children: [
3069
+ Wt,
3070
+ B
3037
3071
  ] });
3038
3072
  },
3039
- [G, r, E, Re, qt, Ye, lt, N, Ze, K, Ht]
3040
- ), tr = Fe(
3073
+ [W, r, V, lt, Kt, wt, pt, N, je, be, Wt]
3074
+ ), lr = _e(
3041
3075
  () => ({
3042
- renderingStartIndex: Ee.renderingStartIndex,
3043
- renderingEndIndex: Ee.renderingEndIndex,
3044
- visibleStartIndex: Ee.visibleStartIndex,
3045
- visibleEndIndex: Ee.visibleEndIndex,
3046
- scrollPosition: Re,
3047
- totalHeight: E.getTotal()
3076
+ renderingStartIndex: Ze.renderingStartIndex,
3077
+ renderingEndIndex: Ze.renderingEndIndex,
3078
+ visibleStartIndex: Ze.visibleStartIndex,
3079
+ visibleEndIndex: Ze.visibleEndIndex,
3080
+ scrollPosition: lt,
3081
+ totalHeight: V.getTotal()
3048
3082
  // contentSize (State) ではなく最新値を反映
3049
3083
  }),
3050
3084
  // contentSize を依存に含めることで、updateItemSize/updates 等で木の総高さが変わった際に
3051
3085
  // (fenwickTree は安定参照のため getTotal() の変化だけでは再計算されない) 総高さを再取得する。
3052
- [Ee, Re, E, Le]
3086
+ [Ze, lt, V, Ae]
3053
3087
  );
3054
- q(() => {
3055
- be.current = tr;
3056
- }, [tr]), Jt(
3057
- M,
3088
+ X(() => {
3089
+ tt.current = lr;
3090
+ }, [lr]);
3091
+ const [yr, cr] = Je(""), ur = g(w);
3092
+ et(() => {
3093
+ ur.current = w;
3094
+ }, [w]);
3095
+ const Et = w?.debounceMs ?? 400, Ht = Number.isFinite(Et) && Et >= 0, Lt = w !== void 0;
3096
+ X(() => {
3097
+ Lt && !Ht && P.warn(`[VirtualScroll] liveRegion.debounceMs must be a finite number >= 0, received ${Et}. Announcements are disabled.`);
3098
+ }, [Lt, Ht, Et]), X(() => {
3099
+ if (!(Lt && Ht)) {
3100
+ cr("");
3101
+ return;
3102
+ }
3103
+ const o = setTimeout(() => {
3104
+ const c = ur.current?.format;
3105
+ if (!c)
3106
+ return;
3107
+ const u = c({ visibleStartIndex: vt, visibleEndIndex: Rt, itemCount: r });
3108
+ cr(u);
3109
+ }, Et);
3110
+ return () => clearTimeout(o);
3111
+ }, [Lt, Ht, Et, vt, Rt, r]), ir(
3112
+ Z,
3058
3113
  () => ({
3059
3114
  getScrollPosition: () => {
3060
- const o = ue.current?.getScrollPosition();
3061
- return typeof o == "number" ? Ke(o, ct.current) : -1;
3115
+ const o = j.current?.getScrollPosition();
3116
+ return typeof o == "number" ? Qe(o, Ye.current) : -1;
3062
3117
  },
3063
- getContentSize: () => ue.current?.getContentSize() ?? -1,
3064
- getViewportSize: () => ue.current?.getViewportSize() ?? -1,
3065
- scrollTo: R,
3066
- scrollBy: D,
3067
- applyWheel: $,
3068
- scrollToIndex: Ue,
3069
- getFenwickTreeTotalHeight: () => E.getTotal(),
3070
- getFenwickSize: () => E.getSize(),
3071
- focusItemAtIndex: Tt,
3072
- getRange: () => be.current,
3073
- getScrollAnchor: x,
3074
- updateItemSize: Ot
3118
+ getContentSize: () => j.current?.getContentSize() ?? -1,
3119
+ getViewportSize: () => j.current?.getViewportSize() ?? -1,
3120
+ scrollTo: U,
3121
+ scrollBy: ve,
3122
+ applyWheel: Be,
3123
+ scrollToIndex: a,
3124
+ getFenwickTreeTotalHeight: () => V.getTotal(),
3125
+ getFenwickSize: () => V.getSize(),
3126
+ focusItemAtIndex: ht,
3127
+ getRange: () => tt.current,
3128
+ getScrollAnchor: L,
3129
+ updateItemSize: At
3075
3130
  }),
3076
- [R, D, $, Ue, E, Tt, x, Ot]
3131
+ [U, ve, Be, a, V, ht, L, At]
3077
3132
  );
3078
- const br = E.getTotal() + N.top + N.bottom;
3079
- return /* @__PURE__ */ de(
3080
- Xr,
3133
+ const Rr = V.getTotal() + N.top + N.bottom, dr = /* @__PURE__ */ ie(
3134
+ en,
3081
3135
  {
3082
- ref: ue,
3083
- contentSize: br,
3136
+ ref: j,
3137
+ contentSize: Rr,
3084
3138
  viewportSize: i,
3085
- onViewportSizeChange: Ae,
3086
- className: a,
3087
- testId: c,
3088
- onScroll: ye,
3089
- background: w,
3090
- tapScrollCircleOptions: U,
3091
- inertiaOptions: Xe,
3092
- overscrollBehavior: $e,
3139
+ onViewportSizeChange: Se,
3140
+ className: l,
3141
+ testId: d,
3142
+ onScroll: He,
3143
+ background: T,
3144
+ tapScrollCircleOptions: fe,
3145
+ inertiaOptions: Ve,
3146
+ overscrollBehavior: Fe,
3093
3147
  itemCount: r,
3094
- scrollBarWidth: Z,
3095
- enableThumbDrag: Q,
3096
- enableTrackClick: W,
3097
- enableArrowButtons: Ie,
3098
- enablePointerDrag: ge,
3099
- pointerDragInputs: qe,
3100
- renderThumbOverlay: v,
3101
- wheelSpeedMultiplier: X,
3102
- onWheelHorizontal: ce,
3148
+ scrollBarWidth: Q,
3149
+ enableThumbDrag: K,
3150
+ enableTrackClick: he,
3151
+ enableArrowButtons: A,
3152
+ enablePointerDrag: $e,
3153
+ pointerDragInputs: Ue,
3154
+ renderThumbOverlay: G,
3155
+ wheelSpeedMultiplier: We,
3156
+ onWheelHorizontal: oe,
3103
3157
  contentInsets: N,
3104
- contentProps: _,
3105
- visibleStartIndex: xt,
3106
- visibleEndIndex: _t,
3107
- renderOverlay: hr,
3108
- initialScrollPosition: J.position,
3109
- children: gr
3158
+ contentProps: Y,
3159
+ visibleStartIndex: vt,
3160
+ visibleEndIndex: Rt,
3161
+ renderOverlay: Mr,
3162
+ initialScrollPosition: ot.position,
3163
+ children: Pr
3110
3164
  }
3111
3165
  );
3112
- }, dn = Zt(nn);
3166
+ return Lt ? /* @__PURE__ */ Tt(rr, { children: [
3167
+ dr,
3168
+ /* @__PURE__ */ ie("div", { className: "aqvs-live-region", role: "status", "aria-live": "polite", "aria-atomic": "true", "data-aqvs-live-region": "", children: yr })
3169
+ ] }) : dr;
3170
+ }, Sn = nr(mn);
3113
3171
  export {
3114
- It as FenwickMapTree,
3115
- kr as ScrollBar,
3116
- Xr as ScrollPane,
3117
- pr as TAP_SCROLL_SPEED_DEFAULTS,
3118
- dn as VirtualScroll,
3119
- _r as computeAutoTapScrollMaxSpeedMultiplier,
3120
- Or as computeTapScrollSpeed,
3121
- le as minmax,
3122
- ln as tapScrollCircleSampleVisual,
3123
- Ur as useFenwickMapTree,
3124
- cn as useHeightCache,
3125
- jr as useLruCache,
3126
- un as useWheelBridge
3172
+ St as FenwickMapTree,
3173
+ Kr as ScrollBar,
3174
+ en as ScrollPane,
3175
+ Tr as TAP_SCROLL_SPEED_DEFAULTS,
3176
+ Sn as VirtualScroll,
3177
+ Wr as computeAutoTapScrollMaxSpeedMultiplier,
3178
+ Ur as computeTapScrollSpeed,
3179
+ bn as createResidualQuantizer,
3180
+ se as minmax,
3181
+ xn as tapScrollCircleSampleVisual,
3182
+ nn as useFenwickMapTree,
3183
+ vn as useHeightCache,
3184
+ on as useLruCache,
3185
+ In as useWheelBridge
3127
3186
  };