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