@aiquants/virtualscroll 0.2.0 → 0.2.1

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,4 +1,4 @@
1
- import me, { useState as W, useRef as Y, useEffect as X, forwardRef as de, useReducer as ge, useMemo as ne, useCallback as L, useLayoutEffect as oe, useImperativeHandle as he, useId as be } from "react";
1
+ import be, { useState as W, useRef as $, useEffect as B, forwardRef as de, useReducer as ve, useMemo as ne, useCallback as Y, useLayoutEffect as oe, useImperativeHandle as he, useId as pe } from "react";
2
2
  import { twMerge as ae } from "tailwind-merge";
3
3
  var re = { exports: {} }, K = {};
4
4
  /**
@@ -11,11 +11,11 @@ var re = { exports: {} }, K = {};
11
11
  * LICENSE file in the root directory of this source tree.
12
12
  */
13
13
  var ie;
14
- function ve() {
14
+ function xe() {
15
15
  if (ie) return K;
16
16
  ie = 1;
17
17
  var u = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
18
- function n(r, s, a) {
18
+ function n(t, s, a) {
19
19
  var o = null;
20
20
  if (a !== void 0 && (o = "" + a), s.key !== void 0 && (o = "" + s.key), "key" in s) {
21
21
  a = {};
@@ -24,7 +24,7 @@ function ve() {
24
24
  } else a = s;
25
25
  return s = a.ref, {
26
26
  $$typeof: u,
27
- type: r,
27
+ type: t,
28
28
  key: o,
29
29
  ref: s !== void 0 ? s : null,
30
30
  props: a
@@ -43,244 +43,244 @@ var ee = {};
43
43
  * LICENSE file in the root directory of this source tree.
44
44
  */
45
45
  var le;
46
- function pe() {
46
+ function Te() {
47
47
  return le || (le = 1, process.env.NODE_ENV !== "production" && (function() {
48
- function u(t) {
49
- if (t == null) return null;
50
- if (typeof t == "function")
51
- return t.$$typeof === H ? null : t.displayName || t.name || null;
52
- if (typeof t == "string") return t;
53
- switch (t) {
54
- case F:
48
+ function u(r) {
49
+ if (r == null) return null;
50
+ if (typeof r == "function")
51
+ return r.$$typeof === U ? null : r.displayName || r.name || null;
52
+ if (typeof r == "string") return r;
53
+ switch (r) {
54
+ case A:
55
55
  return "Fragment";
56
- case k:
56
+ case R:
57
57
  return "Profiler";
58
58
  case b:
59
59
  return "StrictMode";
60
- case y:
60
+ case O:
61
61
  return "Suspense";
62
- case N:
62
+ case M:
63
63
  return "SuspenseList";
64
- case J:
64
+ case X:
65
65
  return "Activity";
66
66
  }
67
- if (typeof t == "object")
68
- switch (typeof t.tag == "number" && console.error(
67
+ if (typeof r == "object")
68
+ switch (typeof r.tag == "number" && console.error(
69
69
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
70
- ), t.$$typeof) {
71
- case I:
70
+ ), r.$$typeof) {
71
+ case S:
72
72
  return "Portal";
73
73
  case f:
74
- return (t.displayName || "Context") + ".Provider";
75
- case S:
76
- return (t._context.displayName || "Context") + ".Consumer";
74
+ return (r.displayName || "Context") + ".Provider";
75
+ case k:
76
+ return (r._context.displayName || "Context") + ".Consumer";
77
+ case P:
78
+ var i = r.render;
79
+ return r = r.displayName, r || (r = i.displayName || i.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
80
+ case H:
81
+ return i = r.displayName || null, i !== null ? i : u(r.type) || "Memo";
77
82
  case w:
78
- var i = t.render;
79
- return t = t.displayName, t || (t = i.displayName || i.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
80
- case $:
81
- return i = t.displayName || null, i !== null ? i : u(t.type) || "Memo";
82
- case _:
83
- i = t._payload, t = t._init;
83
+ i = r._payload, r = r._init;
84
84
  try {
85
- return u(t(i));
85
+ return u(r(i));
86
86
  } catch {
87
87
  }
88
88
  }
89
89
  return null;
90
90
  }
91
- function e(t) {
92
- return "" + t;
91
+ function e(r) {
92
+ return "" + r;
93
93
  }
94
- function n(t) {
94
+ function n(r) {
95
95
  try {
96
- e(t);
96
+ e(r);
97
97
  var i = !1;
98
98
  } catch {
99
99
  i = !0;
100
100
  }
101
101
  if (i) {
102
102
  i = console;
103
- var m = i.error, p = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
104
- return m.call(
103
+ var h = i.error, v = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
104
+ return h.call(
105
105
  i,
106
106
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
107
- p
108
- ), e(t);
107
+ v
108
+ ), e(r);
109
109
  }
110
110
  }
111
- function r(t) {
112
- if (t === F) return "<>";
113
- if (typeof t == "object" && t !== null && t.$$typeof === _)
111
+ function t(r) {
112
+ if (r === A) return "<>";
113
+ if (typeof r == "object" && r !== null && r.$$typeof === w)
114
114
  return "<...>";
115
115
  try {
116
- var i = u(t);
116
+ var i = u(r);
117
117
  return i ? "<" + i + ">" : "<...>";
118
118
  } catch {
119
119
  return "<...>";
120
120
  }
121
121
  }
122
122
  function s() {
123
- var t = U.A;
124
- return t === null ? null : t.getOwner();
123
+ var r = q.A;
124
+ return r === null ? null : r.getOwner();
125
125
  }
126
126
  function a() {
127
127
  return Error("react-stack-top-frame");
128
128
  }
129
- function o(t) {
130
- if (Z.call(t, "key")) {
131
- var i = Object.getOwnPropertyDescriptor(t, "key").get;
129
+ function o(r) {
130
+ if (Z.call(r, "key")) {
131
+ var i = Object.getOwnPropertyDescriptor(r, "key").get;
132
132
  if (i && i.isReactWarning) return !1;
133
133
  }
134
- return t.key !== void 0;
134
+ return r.key !== void 0;
135
135
  }
136
- function d(t, i) {
137
- function m() {
138
- G || (G = !0, console.error(
136
+ function d(r, i) {
137
+ function h() {
138
+ J || (J = !0, console.error(
139
139
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
140
140
  i
141
141
  ));
142
142
  }
143
- m.isReactWarning = !0, Object.defineProperty(t, "key", {
144
- get: m,
143
+ h.isReactWarning = !0, Object.defineProperty(r, "key", {
144
+ get: h,
145
145
  configurable: !0
146
146
  });
147
147
  }
148
148
  function l() {
149
- var t = u(this.type);
150
- return B[t] || (B[t] = !0, console.error(
149
+ var r = u(this.type);
150
+ return G[r] || (G[r] = !0, console.error(
151
151
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
152
- )), t = this.props.ref, t !== void 0 ? t : null;
152
+ )), r = this.props.ref, r !== void 0 ? r : null;
153
153
  }
154
- function c(t, i, m, p, P, T, C, D) {
155
- return m = T.ref, t = {
156
- $$typeof: E,
157
- type: t,
154
+ function c(r, i, h, v, E, T, I, L) {
155
+ return h = T.ref, r = {
156
+ $$typeof: x,
157
+ type: r,
158
158
  key: i,
159
159
  props: T,
160
- _owner: P
161
- }, (m !== void 0 ? m : null) !== null ? Object.defineProperty(t, "ref", {
160
+ _owner: E
161
+ }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(r, "ref", {
162
162
  enumerable: !1,
163
163
  get: l
164
- }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
164
+ }) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
165
165
  configurable: !1,
166
166
  enumerable: !1,
167
167
  writable: !0,
168
168
  value: 0
169
- }), Object.defineProperty(t, "_debugInfo", {
169
+ }), Object.defineProperty(r, "_debugInfo", {
170
170
  configurable: !1,
171
171
  enumerable: !1,
172
172
  writable: !0,
173
173
  value: null
174
- }), Object.defineProperty(t, "_debugStack", {
174
+ }), Object.defineProperty(r, "_debugStack", {
175
175
  configurable: !1,
176
176
  enumerable: !1,
177
177
  writable: !0,
178
- value: C
179
- }), Object.defineProperty(t, "_debugTask", {
178
+ value: I
179
+ }), Object.defineProperty(r, "_debugTask", {
180
180
  configurable: !1,
181
181
  enumerable: !1,
182
182
  writable: !0,
183
- value: D
184
- }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
183
+ value: L
184
+ }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
185
185
  }
186
- function g(t, i, m, p, P, T, C, D) {
187
- var V = i.children;
188
- if (V !== void 0)
189
- if (p)
190
- if (j(V)) {
191
- for (p = 0; p < V.length; p++)
192
- x(V[p]);
193
- Object.freeze && Object.freeze(V);
186
+ function m(r, i, h, v, E, T, I, L) {
187
+ var y = i.children;
188
+ if (y !== void 0)
189
+ if (v)
190
+ if (C(y)) {
191
+ for (v = 0; v < y.length; v++)
192
+ p(y[v]);
193
+ Object.freeze && Object.freeze(y);
194
194
  } else
195
195
  console.error(
196
196
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
197
197
  );
198
- else x(V);
198
+ else p(y);
199
199
  if (Z.call(i, "key")) {
200
- V = u(t);
201
- var q = Object.keys(i).filter(function(se) {
200
+ y = u(r);
201
+ var N = Object.keys(i).filter(function(se) {
202
202
  return se !== "key";
203
203
  });
204
- p = 0 < q.length ? "{key: someKey, " + q.join(": ..., ") + ": ...}" : "{key: someKey}", v[V + p] || (q = 0 < q.length ? "{" + q.join(": ..., ") + ": ...}" : "{}", console.error(
204
+ v = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", V[y + v] || (N = 0 < N.length ? "{" + N.join(": ..., ") + ": ...}" : "{}", console.error(
205
205
  `A props object containing a "key" prop is being spread into JSX:
206
206
  let props = %s;
207
207
  <%s {...props} />
208
208
  React keys must be passed directly to JSX without using spread:
209
209
  let props = %s;
210
210
  <%s key={someKey} {...props} />`,
211
- p,
212
- V,
213
- q,
214
- V
215
- ), v[V + p] = !0);
211
+ v,
212
+ y,
213
+ N,
214
+ y
215
+ ), V[y + v] = !0);
216
216
  }
217
- if (V = null, m !== void 0 && (n(m), V = "" + m), o(i) && (n(i.key), V = "" + i.key), "key" in i) {
218
- m = {};
217
+ if (y = null, h !== void 0 && (n(h), y = "" + h), o(i) && (n(i.key), y = "" + i.key), "key" in i) {
218
+ h = {};
219
219
  for (var Q in i)
220
- Q !== "key" && (m[Q] = i[Q]);
221
- } else m = i;
222
- return V && d(
223
- m,
224
- typeof t == "function" ? t.displayName || t.name || "Unknown" : t
220
+ Q !== "key" && (h[Q] = i[Q]);
221
+ } else h = i;
222
+ return y && d(
223
+ h,
224
+ typeof r == "function" ? r.displayName || r.name || "Unknown" : r
225
225
  ), c(
226
- t,
227
- V,
226
+ r,
227
+ y,
228
228
  T,
229
- P,
229
+ E,
230
230
  s(),
231
- m,
232
- C,
233
- D
231
+ h,
232
+ I,
233
+ L
234
234
  );
235
235
  }
236
- function x(t) {
237
- typeof t == "object" && t !== null && t.$$typeof === E && t._store && (t._store.validated = 1);
236
+ function p(r) {
237
+ typeof r == "object" && r !== null && r.$$typeof === x && r._store && (r._store.validated = 1);
238
238
  }
239
- var R = me, E = Symbol.for("react.transitional.element"), I = Symbol.for("react.portal"), F = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), k = Symbol.for("react.profiler"), S = Symbol.for("react.consumer"), f = Symbol.for("react.context"), w = Symbol.for("react.forward_ref"), y = Symbol.for("react.suspense"), N = Symbol.for("react.suspense_list"), $ = Symbol.for("react.memo"), _ = Symbol.for("react.lazy"), J = Symbol.for("react.activity"), H = Symbol.for("react.client.reference"), U = R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, j = Array.isArray, M = console.createTask ? console.createTask : function() {
239
+ var _ = be, x = Symbol.for("react.transitional.element"), S = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), R = Symbol.for("react.profiler"), k = Symbol.for("react.consumer"), f = Symbol.for("react.context"), P = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), M = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), X = Symbol.for("react.activity"), U = Symbol.for("react.client.reference"), q = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, C = Array.isArray, D = console.createTask ? console.createTask : function() {
240
240
  return null;
241
241
  };
242
- R = {
243
- react_stack_bottom_frame: function(t) {
244
- return t();
242
+ _ = {
243
+ react_stack_bottom_frame: function(r) {
244
+ return r();
245
245
  }
246
246
  };
247
- var G, B = {}, te = R.react_stack_bottom_frame.bind(
248
- R,
247
+ var J, G = {}, te = _.react_stack_bottom_frame.bind(
248
+ _,
249
249
  a
250
- )(), h = M(r(a)), v = {};
251
- ee.Fragment = F, ee.jsx = function(t, i, m, p, P) {
252
- var T = 1e4 > U.recentlyCreatedOwnerStacks++;
253
- return g(
254
- t,
250
+ )(), g = D(t(a)), V = {};
251
+ ee.Fragment = A, ee.jsx = function(r, i, h, v, E) {
252
+ var T = 1e4 > q.recentlyCreatedOwnerStacks++;
253
+ return m(
254
+ r,
255
255
  i,
256
- m,
256
+ h,
257
257
  !1,
258
- p,
259
- P,
258
+ v,
259
+ E,
260
260
  T ? Error("react-stack-top-frame") : te,
261
- T ? M(r(t)) : h
261
+ T ? D(t(r)) : g
262
262
  );
263
- }, ee.jsxs = function(t, i, m, p, P) {
264
- var T = 1e4 > U.recentlyCreatedOwnerStacks++;
265
- return g(
266
- t,
263
+ }, ee.jsxs = function(r, i, h, v, E) {
264
+ var T = 1e4 > q.recentlyCreatedOwnerStacks++;
265
+ return m(
266
+ r,
267
267
  i,
268
- m,
268
+ h,
269
269
  !0,
270
- p,
271
- P,
270
+ v,
271
+ E,
272
272
  T ? Error("react-stack-top-frame") : te,
273
- T ? M(r(t)) : h
273
+ T ? D(t(r)) : g
274
274
  );
275
275
  };
276
276
  })()), ee;
277
277
  }
278
278
  var ue;
279
- function xe() {
280
- return ue || (ue = 1, process.env.NODE_ENV === "production" ? re.exports = ve() : re.exports = pe()), re.exports;
279
+ function Ee() {
280
+ return ue || (ue = 1, process.env.NODE_ENV === "production" ? re.exports = xe() : re.exports = Te()), re.exports;
281
281
  }
282
- var z = xe();
283
- const A = {
282
+ var z = Ee();
283
+ const j = {
284
284
  debug(u, ...e) {
285
285
  typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${u}`, ...e);
286
286
  },
@@ -290,43 +290,43 @@ const A = {
290
290
  error(u, ...e) {
291
291
  console.error(`[VirtualScroll] ${u}`, ...e);
292
292
  }
293
- }, O = (u, e, n) => Math.min(n, Math.max(e, u)), ce = (u, e, n) => {
294
- const r = "touches" in u.nativeEvent, s = r ? u.nativeEvent.touches[0] : u.nativeEvent, a = (d) => {
295
- r && d.cancelable && d.preventDefault();
293
+ }, F = (u, e, n) => Math.min(n, Math.max(e, u)), ce = (u, e, n) => {
294
+ const t = "touches" in u.nativeEvent, s = t ? u.nativeEvent.touches[0] : u.nativeEvent, a = (d) => {
295
+ t && d.cancelable && d.preventDefault();
296
296
  const l = "touches" in d ? d.touches[0] : d;
297
297
  e({
298
298
  deltaX: l.clientX - s.clientX,
299
299
  deltaY: l.clientY - s.clientY
300
300
  });
301
301
  }, o = () => {
302
- r ? (document.removeEventListener("touchmove", a), document.removeEventListener("touchend", o)) : (document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", o)), n?.();
302
+ t ? (document.removeEventListener("touchmove", a), document.removeEventListener("touchend", o)) : (document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", o)), n?.();
303
303
  };
304
- r ? (document.addEventListener("touchmove", a, { passive: !1 }), document.addEventListener("touchend", o)) : (document.addEventListener("mousemove", a), document.addEventListener("mouseup", o));
305
- }, Te = 20, Ee = ({ contentSize: u, viewportSize: e, scrollPosition: n, onScroll: r, horizontal: s = !1, scrollBarWidth: a = 12, className: o, ariaControls: d }) => {
306
- const [l, c] = W(!1), g = Y(null), x = e / u, R = Math.max(Te, x * e), E = u - e, I = n / E * (e - R), F = u > e;
307
- X(() => {
308
- g.current && (l ? g.current.style.backgroundColor = "#4F4F4F" : g.current.style.backgroundColor = "#7F7F7F");
304
+ t ? (document.addEventListener("touchmove", a, { passive: !1 }), document.addEventListener("touchend", o)) : (document.addEventListener("mousemove", a), document.addEventListener("mouseup", o));
305
+ }, _e = 20, Re = ({ contentSize: u, viewportSize: e, scrollPosition: n, onScroll: t, horizontal: s = !1, scrollBarWidth: a = 12, className: o, ariaControls: d }) => {
306
+ const [l, c] = W(!1), m = $(null), p = e / u, _ = Math.max(_e, p * e), x = u - e, S = n / x * (e - _), A = u > e;
307
+ B(() => {
308
+ m.current && (l ? m.current.style.backgroundColor = "#4F4F4F" : m.current.style.backgroundColor = "#7F7F7F");
309
309
  }, [l]);
310
- const b = (f) => O(f / (e - R) * E, 0, E), k = (f) => {
311
- if (!F || "button" in f && f.button !== 0 || f.ctrlKey)
310
+ const b = (f) => F(f / (e - _) * x, 0, x), R = (f) => {
311
+ if (!A || "button" in f && f.button !== 0 || f.ctrlKey)
312
312
  return;
313
313
  f.stopPropagation();
314
- const w = I;
314
+ const P = S;
315
315
  c(!0), ce(
316
316
  f,
317
- ({ deltaX: y, deltaY: N }) => {
318
- r?.(b(w + (s ? y : N)), I);
317
+ ({ deltaX: O, deltaY: M }) => {
318
+ t?.(b(P + (s ? O : M)), S);
319
319
  },
320
320
  () => {
321
321
  c(!1);
322
322
  }
323
323
  );
324
- }, S = (f) => {
325
- if (!F || "button" in f && f.button !== 0 || f.ctrlKey)
324
+ }, k = (f) => {
325
+ if (!A || "button" in f && f.button !== 0 || f.ctrlKey)
326
326
  return;
327
- const y = "touches" in f.nativeEvent ? f.nativeEvent.touches[0] : f.nativeEvent, N = s ? y.clientX : y.clientY, $ = f.currentTarget.getBoundingClientRect(), J = (s ? N - $.left : N - $.top) - R / 2;
328
- r?.(b(J), I), ce(f, ({ deltaX: H, deltaY: U }) => {
329
- r?.(b(J + (s ? H : U)), I);
327
+ const O = "touches" in f.nativeEvent ? f.nativeEvent.touches[0] : f.nativeEvent, M = s ? O.clientX : O.clientY, H = f.currentTarget.getBoundingClientRect(), X = (s ? M - H.left : M - H.top) - _ / 2;
328
+ t?.(b(X), S), ce(f, ({ deltaX: U, deltaY: q }) => {
329
+ t?.(b(X + (s ? U : q)), S);
330
330
  });
331
331
  };
332
332
  return (
@@ -341,14 +341,14 @@ const A = {
341
341
  backgroundColor: "white",
342
342
  userSelect: "none"
343
343
  },
344
- onMouseDown: S,
345
- onTouchStart: S,
344
+ onMouseDown: k,
345
+ onTouchStart: k,
346
346
  role: "scrollbar",
347
347
  tabIndex: -1,
348
348
  "aria-controls": d,
349
349
  "aria-valuenow": n,
350
350
  "aria-valuemin": 0,
351
- "aria-valuemax": E,
351
+ "aria-valuemax": x,
352
352
  "aria-orientation": s ? "horizontal" : "vertical",
353
353
  children: u > e && // スクロールバーのつまみの当たり判定を広げるためのラッパー
354
354
  /* @__PURE__ */ z.jsx(
@@ -356,23 +356,23 @@ const A = {
356
356
  {
357
357
  className: "group absolute",
358
358
  style: {
359
- [s ? "width" : "height"]: R,
360
- [s ? "left" : "top"]: I,
359
+ [s ? "width" : "height"]: _,
360
+ [s ? "left" : "top"]: S,
361
361
  // 当たり判定を上下または左右に広げる
362
362
  ...s ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
363
363
  },
364
- onMouseDown: k,
365
- onTouchStart: k,
364
+ onMouseDown: R,
365
+ onTouchStart: R,
366
366
  role: "slider",
367
367
  "aria-orientation": s ? "horizontal" : "vertical",
368
368
  "aria-valuenow": n,
369
369
  "aria-valuemin": 0,
370
- "aria-valuemax": E,
370
+ "aria-valuemax": x,
371
371
  tabIndex: 0,
372
372
  children: /* @__PURE__ */ z.jsx(
373
373
  "div",
374
374
  {
375
- ref: g,
375
+ ref: m,
376
376
  className: ae(
377
377
  "absolute",
378
378
  s ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${l ? "inset-y-[-2px]" : "group-active:inset-y-[-2px]"}` : `inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${l ? "inset-x-[-2px]" : "group-active:inset-x-[-2px]"}`
@@ -406,59 +406,59 @@ const A = {
406
406
  }
407
407
  )
408
408
  );
409
- }, _e = de(({ children: u, contentSize: e, viewportSize: n, scrollBarWidth: r = 12, onScroll: s, className: a, style: o, background: d }, l) => {
410
- const c = Y(0), [g, x] = ge((k) => k + 1, 0), R = Y(null);
411
- A.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: n, scrollBarWidth: r, className: a, style: o });
412
- const E = ne(() => e > n, [e, n]), I = L(
413
- (k) => {
414
- const S = e > n, f = c.current;
415
- if (A.debug("[ScrollPane] scrollTo called", { newPosition: k, contentSize: e, viewportSize: n, currentIsScrollable: S, prevPosition: f }), !S) {
409
+ }, Ie = de(({ children: u, contentSize: e, viewportSize: n, scrollBarWidth: t = 12, onScroll: s, className: a, style: o, background: d }, l) => {
410
+ const c = $(0), [m, p] = ve((R) => R + 1, 0), _ = $(null);
411
+ j.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: n, scrollBarWidth: t, className: a, style: o });
412
+ const x = ne(() => e > n, [e, n]), S = Y(
413
+ (R) => {
414
+ const k = e > n, f = c.current;
415
+ if (j.debug("[ScrollPane] scrollTo called", { newPosition: R, contentSize: e, viewportSize: n, currentIsScrollable: k, prevPosition: f }), !k) {
416
416
  c.current !== 0 && (c.current = 0, s?.(0, f));
417
417
  return;
418
418
  }
419
- const w = typeof k == "function" ? k(c.current) : k, y = O(w, 0, e - n);
420
- c.current !== y && (c.current = y, s?.(y, f));
419
+ const P = typeof R == "function" ? R(c.current) : R, O = F(P, 0, e - n);
420
+ c.current !== O && (c.current = O, s?.(O, f));
421
421
  },
422
422
  [s, e, n]
423
423
  );
424
424
  oe(() => {
425
- if (E) {
426
- A.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: n, scrollPosition: c.current });
427
- const k = O(e - n, 0, e);
428
- c.current > k && I(k);
425
+ if (x) {
426
+ j.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: n, scrollPosition: c.current });
427
+ const R = F(e - n, 0, e);
428
+ c.current > R && S(R);
429
429
  } else
430
- I(0);
431
- }, [E, I, e, n]), X(() => {
432
- const k = (f) => {
433
- if (!E)
430
+ S(0);
431
+ }, [x, S, e, n]), B(() => {
432
+ const R = (f) => {
433
+ if (!x)
434
434
  return;
435
435
  f.preventDefault();
436
- let w = f.deltaY;
437
- f.deltaMode === 1 ? w *= 16 : f.deltaMode === 2 && (w *= n), A.debug("[ScrollPane] wheel event", { deltaY: w, scrollPosition: c.current }), I((y) => y + w);
438
- }, S = R.current;
439
- return S && S.addEventListener("wheel", k, { passive: !1 }), () => {
440
- S && S.removeEventListener("wheel", k);
436
+ let P = f.deltaY;
437
+ f.deltaMode === 1 ? P *= 16 : f.deltaMode === 2 && (P *= n), j.debug("[ScrollPane] wheel event", { deltaY: P, scrollPosition: c.current }), S((O) => O + P);
438
+ }, k = _.current;
439
+ return k && k.addEventListener("wheel", R, { passive: !1 }), () => {
440
+ k && k.removeEventListener("wheel", R);
441
441
  };
442
- }, [E, I, n]), he(
442
+ }, [x, S, n]), he(
443
443
  l,
444
444
  () => ({
445
- scrollTo: I,
445
+ scrollTo: S,
446
446
  getScrollPosition: () => c.current,
447
447
  getContentSize: () => e,
448
448
  getViewportSize: () => n
449
449
  }),
450
- [I, e, n]
450
+ [S, e, n]
451
451
  );
452
- const F = be();
453
- return ne(() => /* @__PURE__ */ z.jsxs("div", { ref: R, className: ae("flex", a), style: o, children: [
454
- /* @__PURE__ */ z.jsxs("div", { className: "relative h-full flex-1 overflow-hidden", style: { height: n }, id: F, children: [
452
+ const A = pe();
453
+ return ne(() => /* @__PURE__ */ z.jsxs("div", { ref: _, className: ae("flex", a), style: o, children: [
454
+ /* @__PURE__ */ z.jsxs("div", { className: "relative h-full flex-1 overflow-hidden", style: { height: n }, id: A, children: [
455
455
  d,
456
456
  u(c.current)
457
457
  ] }),
458
- E && /* @__PURE__ */ z.jsx(Ee, { contentSize: e, viewportSize: n, scrollPosition: c.current, onScroll: I, scrollBarWidth: r, ariaControls: F })
459
- ] }), [u, e, n, r, a, o, E, I, F, d]);
458
+ x && /* @__PURE__ */ z.jsx(Re, { contentSize: e, viewportSize: n, scrollPosition: c.current, onScroll: S, scrollBarWidth: t, ariaControls: A })
459
+ ] }), [u, e, n, t, a, o, x, S, A, d]);
460
460
  });
461
- class Re {
461
+ class Se {
462
462
  /**
463
463
  * @private
464
464
  * @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
@@ -498,8 +498,8 @@ class Re {
498
498
  * @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
499
499
  * @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
500
500
  */
501
- constructor(e, n, r) {
502
- this.reset(e, n, r);
501
+ constructor(e, n, t) {
502
+ this.reset(e, n, t);
503
503
  }
504
504
  /**
505
505
  * @method reset
@@ -509,20 +509,20 @@ class Re {
509
509
  * @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
510
510
  * @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
511
511
  */
512
- reset(e, n, r) {
512
+ reset(e, n, t) {
513
513
  if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof n == "function") {
514
514
  if (this.valueFn = n, this.size > 0) {
515
- const a = r?.sampleRange ?? {
515
+ const a = t?.sampleRange ?? {
516
516
  from: 0,
517
517
  to: Math.min(99, this.size - 1)
518
518
  }, { mode: o, materializedValues: d } = this._calculateMode(a.from, a.to);
519
- if (this.baseValue = o, r?.materialize)
519
+ if (this.baseValue = o, t?.materialize)
520
520
  for (let l = 0; l < d.length; l++) {
521
- const c = d[l], g = a.from + l;
522
- if (g >= this.size)
521
+ const c = d[l], m = a.from + l;
522
+ if (m >= this.size)
523
523
  break;
524
- const x = c - this.baseValue;
525
- this.deltas.set(g, x), this._updateTree(g, x);
524
+ const p = c - this.baseValue;
525
+ this.deltas.set(m, p), this._updateTree(m, p);
526
526
  }
527
527
  } else
528
528
  this.baseValue = 0;
@@ -551,28 +551,28 @@ class Re {
551
551
  _calculateMode(e, n) {
552
552
  if (!this.valueFn)
553
553
  return { mode: 0, materializedValues: [] };
554
- const r = [];
554
+ const t = [];
555
555
  for (let c = e; c <= n && !(c >= this.size); c++)
556
- r.push(this.valueFn(c));
557
- const s = [...r];
558
- if (r.length === 0)
556
+ t.push(this.valueFn(c));
557
+ const s = [...t];
558
+ if (t.length === 0)
559
559
  return { mode: 0, materializedValues: [] };
560
- r.sort((c, g) => c - g);
561
- const a = Math.floor(r.length / 2);
560
+ t.sort((c, m) => c - m);
561
+ const a = Math.floor(t.length / 2);
562
562
  let o;
563
- r.length % 2 === 0 ? o = Math.floor((r[a - 1] + r[a]) / 2) : o = r[a];
563
+ t.length % 2 === 0 ? o = Math.floor((t[a - 1] + t[a]) / 2) : o = t[a];
564
564
  const d = /* @__PURE__ */ new Map();
565
565
  let l = 0;
566
- for (const c of r) {
567
- const g = (d.get(c) ?? 0) + 1;
568
- d.set(c, g), g > l && (l = g);
566
+ for (const c of t) {
567
+ const m = (d.get(c) ?? 0) + 1;
568
+ d.set(c, m), m > l && (l = m);
569
569
  }
570
570
  if (l > 1) {
571
571
  const c = [];
572
- for (const [x, R] of d.entries())
573
- R === l && c.push(x);
574
- const g = c.reduce((x, R) => x + R, 0);
575
- o = Math.floor(g / c.length);
572
+ for (const [p, _] of d.entries())
573
+ _ === l && c.push(p);
574
+ const m = c.reduce((p, _) => p + _, 0);
575
+ o = Math.floor(m / c.length);
576
576
  }
577
577
  return { mode: o, materializedValues: s };
578
578
  }
@@ -593,14 +593,14 @@ class Re {
593
593
  * @param {{ index: number; value: number }[]} updates - An array of updates, each with an index and the new value.
594
594
  */
595
595
  updates(e) {
596
- const n = e.map(({ index: r, value: s }) => {
597
- if (r < 0 || r >= this.size)
598
- throw new Error(`Index ${r} out of bounds`);
596
+ const n = e.map(({ index: t, value: s }) => {
597
+ if (t < 0 || t >= this.size)
598
+ throw new Error(`Index ${t} out of bounds`);
599
599
  if (s < 0)
600
600
  throw new Error("Value cannot be negative.");
601
- const a = this.deltas.has(r) ? (this.deltas.get(r) ?? 0) + this.baseValue : this.baseValue, o = s - a;
602
- return { index: r, change: o };
603
- }).filter((r) => r.change !== 0);
601
+ const a = this.deltas.has(t) ? (this.deltas.get(t) ?? 0) + this.baseValue : this.baseValue, o = s - a;
602
+ return { index: t, change: o };
603
+ }).filter((t) => t.change !== 0);
604
604
  return n.length > 0 ? this.updateDeltas(n) : this.total;
605
605
  }
606
606
  /**
@@ -620,11 +620,11 @@ class Re {
620
620
  * @param {{ index: number; change: number }[]} updates - An array of updates, each with an index and the change to apply.
621
621
  */
622
622
  updateDeltas(e) {
623
- for (const { index: n, change: r } of e) {
623
+ for (const { index: n, change: t } of e) {
624
624
  if (n < 0 || n >= this.size)
625
625
  throw new Error(`Index ${n} out of bounds`);
626
626
  const s = this.deltas.get(n) ?? 0;
627
- this.deltas.set(n, s + r), this._updateTree(n, r);
627
+ this.deltas.set(n, s + t), this._updateTree(n, t);
628
628
  }
629
629
  return this.total;
630
630
  }
@@ -639,9 +639,9 @@ class Re {
639
639
  _updateTree(e, n) {
640
640
  if (n === 0)
641
641
  return;
642
- let r = e + 1;
643
- for (; r <= this.size; )
644
- this.tree.set(r, (this.tree.get(r) ?? 0) + n), r += r & -r;
642
+ let t = e + 1;
643
+ for (; t <= this.size; )
644
+ this.tree.set(t, (this.tree.get(t) ?? 0) + n), t += t & -t;
645
645
  this.total !== void 0 && (this.total += n);
646
646
  }
647
647
  /**
@@ -654,9 +654,9 @@ class Re {
654
654
  */
655
655
  _materialize(e, n = !0) {
656
656
  if (this.valueFn) {
657
- const r = this.deltas.get(e) ?? 0, a = this.valueFn(e) - this.baseValue;
658
- if (a !== r && (this.deltas.set(e, a), n)) {
659
- const o = a - r;
657
+ const t = this.deltas.get(e) ?? 0, a = this.valueFn(e) - this.baseValue;
658
+ if (a !== t && (this.deltas.set(e, a), n)) {
659
+ const o = a - t;
660
660
  this._updateTree(e, o);
661
661
  }
662
662
  }
@@ -677,23 +677,23 @@ class Re {
677
677
  prefixSum(e, n) {
678
678
  if (e < 0)
679
679
  return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
680
- const r = O(e, 0, this.size - 1), s = n?.materializeOption;
680
+ const t = F(e, 0, this.size - 1), s = n?.materializeOption;
681
681
  if (s?.materialize && this.valueFn) {
682
682
  if (s.ranges)
683
683
  for (const l of s.ranges) {
684
- const c = l.from, g = Math.min(l.to, this.size - 1);
685
- for (let x = c; x <= g; x++)
686
- this._materialize(x);
684
+ const c = l.from, m = Math.min(l.to, this.size - 1);
685
+ for (let p = c; p <= m; p++)
686
+ this._materialize(p);
687
687
  }
688
- this._materialize(r);
688
+ this._materialize(t);
689
689
  }
690
- let a = 0, o = r + 1;
690
+ let a = 0, o = t + 1;
691
691
  for (; o > 0; ) {
692
692
  const l = this.tree.get(o) ?? 0;
693
693
  a += l, o -= o & -o;
694
694
  }
695
- const d = s?.materialize ? this.get(r) : (this.deltas.get(r) || 0) + this.baseValue;
696
- return { cumulative: a + this.baseValue * (r + 1), total: this.total, currentValue: d, safeIndex: r };
695
+ const d = s?.materialize ? this.get(t) : (this.deltas.get(t) || 0) + this.baseValue;
696
+ return { cumulative: a + this.baseValue * (t + 1), total: this.total, currentValue: d, safeIndex: t };
697
697
  }
698
698
  /**
699
699
  * @method get
@@ -711,15 +711,15 @@ class Re {
711
711
  get(e, n) {
712
712
  if (e < 0 || e >= this.size)
713
713
  throw new Error("Index out of bounds");
714
- const r = n?.materializeOption;
715
- if (r?.materialize && this.valueFn)
716
- if (r.ranges) {
717
- for (const s of r.ranges) {
714
+ const t = n?.materializeOption;
715
+ if (t?.materialize && this.valueFn)
716
+ if (t.ranges) {
717
+ for (const s of t.ranges) {
718
718
  const a = s.from, o = Math.min(s.to, this.size - 1);
719
719
  for (let d = a; d <= o; d++)
720
720
  this._materialize(d);
721
721
  }
722
- e >= r.ranges[0].from && e <= r.ranges[r.ranges.length - 1].to && this._materialize(e);
722
+ e >= t.ranges[0].from && e <= t.ranges[t.ranges.length - 1].to && this._materialize(e);
723
723
  } else
724
724
  this._materialize(e);
725
725
  return (this.deltas.get(e) ?? 0) + this.baseValue;
@@ -739,8 +739,8 @@ class Re {
739
739
  getTotal(e) {
740
740
  const n = e?.materializeOption;
741
741
  if (n?.materialize && this.valueFn && n.ranges)
742
- for (const r of n.ranges) {
743
- const s = r.from, a = Math.min(r.to, this.size - 1);
742
+ for (const t of n.ranges) {
743
+ const s = t.from, a = Math.min(t.to, this.size - 1);
744
744
  for (let o = s; o <= a; o++)
745
745
  this._materialize(o);
746
746
  }
@@ -748,10 +748,10 @@ class Re {
748
748
  if (this.size === 0)
749
749
  this.total = 0;
750
750
  else {
751
- let r = this.baseValue * this.size;
751
+ let t = this.baseValue * this.size;
752
752
  for (const s of this.deltas.values())
753
- r += s;
754
- this.total = r, console.assert(this.prefixSum(this.getSize() - 1).cumulative === this.prefixSum(this.getSize() - 1).total, "Inconsistent Fenwick Tree state");
753
+ t += s;
754
+ this.total = t, console.assert(this.prefixSum(this.getSize() - 1).cumulative === this.prefixSum(this.getSize() - 1).total, "Inconsistent Fenwick Tree state");
755
755
  }
756
756
  return this.total;
757
757
  }
@@ -769,15 +769,15 @@ class Re {
769
769
  return;
770
770
  }
771
771
  const n = /* @__PURE__ */ new Map();
772
- let r = this.baseValue * this.size;
772
+ let t = this.baseValue * this.size;
773
773
  for (const [s, a] of this.deltas.entries()) {
774
- if (r += a, a === 0)
774
+ if (t += a, a === 0)
775
775
  continue;
776
776
  let o = s + 1;
777
777
  for (; o <= this.size; )
778
778
  n.set(o, (n.get(o) ?? 0) + a), o += o & -o;
779
779
  }
780
- this.tree = n, this.total = r;
780
+ this.tree = n, this.total = t;
781
781
  }
782
782
  /**
783
783
  * @method calculateAccumulatedError
@@ -803,8 +803,8 @@ class Re {
803
803
  const n = this.size;
804
804
  if (e !== n) {
805
805
  if (e < n)
806
- for (const r of this.deltas.keys())
807
- r >= e && this.deltas.delete(r);
806
+ for (const t of this.deltas.keys())
807
+ t >= e && this.deltas.delete(t);
808
808
  this.size = e, this.rebuildTree(), console.assert(this.prefixSum(this.getSize() - 1).cumulative === this.prefixSum(this.getSize() - 1).total, "Inconsistent Fenwick Tree state");
809
809
  }
810
810
  }
@@ -833,10 +833,10 @@ class Re {
833
833
  findIndexAtOrAfter(e, n) {
834
834
  if (this.size === 0)
835
835
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
836
- let r = 0, s = this.size - 1, a = -1, o, d = this.total;
837
- for (; r <= s; ) {
838
- const l = Math.floor((r + s) / 2);
839
- o = this.prefixSum(l, n), d = o.total, o.cumulative >= e ? (a = l, s = l - 1) : r = l + 1;
836
+ let t = 0, s = this.size - 1, a = -1, o, d = this.total;
837
+ for (; t <= s; ) {
838
+ const l = Math.floor((t + s) / 2);
839
+ o = this.prefixSum(l, n), d = o.total, o.cumulative >= e ? (a = l, s = l - 1) : t = l + 1;
840
840
  }
841
841
  return { index: a, total: d, cumulative: o?.cumulative, currentValue: o?.currentValue, safeIndex: o?.safeIndex };
842
842
  }
@@ -856,153 +856,148 @@ class Re {
856
856
  findIndexAtOrBefore(e, n) {
857
857
  if (this.size === 0)
858
858
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
859
- let r = 0, s = this.size - 1, a = -1, o, d = this.total;
860
- for (; r <= s; ) {
861
- const l = Math.floor((r + s) / 2);
862
- o = this.prefixSum(l, n), d = o.total, o.cumulative <= e ? (a = l, r = l + 1) : s = l - 1;
859
+ let t = 0, s = this.size - 1, a = -1, o, d = this.total;
860
+ for (; t <= s; ) {
861
+ const l = Math.floor((t + s) / 2);
862
+ o = this.prefixSum(l, n), d = o.total, o.cumulative <= e ? (a = l, t = l + 1) : s = l - 1;
863
863
  }
864
864
  return { index: a, total: d, cumulative: o?.cumulative, currentValue: o?.currentValue, safeIndex: o?.safeIndex };
865
865
  }
866
866
  }
867
- const Ie = (u, e, n) => {
868
- const r = Math.max(0, u), s = Y(null), a = ne(() => new Re(r, e, n), [r, e, n]);
867
+ const ke = (u, e, n) => {
868
+ const t = Math.max(0, u), s = $(null), a = ne(() => new Se(t, e, n), [t, e, n]);
869
869
  return Object.is(s.current, a) || console.warn("[useFenwickMapTree] instance changed"), s.current = a, a;
870
870
  };
871
- function ke({ itemCount: u, getItem: e, getItemHeight: n, viewportSize: r, overscanCount: s = 5, className: a, onScroll: o, onRangeChange: d, children: l, background: c, initialScrollIndex: g, initialScrollOffset: x }, R) {
872
- const E = Y(null), I = Y(!1);
873
- X(() => (I.current = !0, () => {
874
- I.current = !1;
871
+ function Pe({ itemCount: u, getItem: e, getItemHeight: n, viewportSize: t, overscanCount: s = 5, className: a, onScroll: o, onRangeChange: d, children: l, background: c, initialScrollIndex: m, initialScrollOffset: p }, _) {
872
+ const x = $(null), S = $(!1);
873
+ B(() => (S.current = !0, () => {
874
+ S.current = !1;
875
875
  }), []);
876
- const F = Y({ size: u, valueOrFn: n, options: { sampleRange: { from: 0, to: 100 } } }), b = Ie(F.current.size, F.current.valueOrFn, F.current.options), [k] = W(() => {
877
- let h = 0, v = 0;
878
- if (typeof g == "number") {
879
- const t = O(g, 0, u - 1), i = O(t - s * 2, 0, u - 1), m = O(t + s * 2, 0, u - 1), p = g > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: i, to: m }] } } : void 0, { cumulative: P, total: T, currentValue: C } = b.prefixSum(g, p);
880
- h = P - C, v = T ?? b.getTotal();
881
- } else typeof x == "number" && (h = x), v = b.getTotal();
882
- return { position: h, total: v };
883
- }), [S, f] = W(k.position), [w, y] = W(k.total), [N, $] = W(k.position), [_, J] = W(u);
876
+ const A = $({ size: u, valueOrFn: n, options: { sampleRange: { from: 0, to: 100 } } }), b = ke(A.current.size, A.current.valueOrFn, A.current.options), [R] = W(() => {
877
+ let g = 0, V = 0;
878
+ if (typeof m == "number") {
879
+ const r = F(m, 0, u - 1), i = F(r - s * 2, 0, u - 1), h = F(r + s * 2, 0, u - 1), v = m > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: i, to: h }] } } : void 0, { cumulative: E, total: T, currentValue: I } = b.prefixSum(m, v);
880
+ g = E - I, V = T ?? b.getTotal();
881
+ } else typeof p == "number" && (g = p), V = b.getTotal();
882
+ return { position: g, total: V };
883
+ }), [k, f] = W(R.position), [P, O] = W(R.total), [M, H] = W(R.position), [w, X] = W(u);
884
884
  oe(() => {
885
- b.setValueFn(n), _ !== u && (b.changeSize(u), J(u));
886
- const h = b.getTotal();
887
- w !== h && y(h);
888
- }, [b, _, u, w, n]), oe(() => {
889
- N !== null && E.current && (A.debug("[VirtualScroll] Scrolling to position:", N), E.current.scrollTo(N), $(null));
890
- }, [N]);
891
- const H = L(
892
- (h) => {
893
- if (E.current) {
894
- A.debug("[VirtualScroll] Scrolling to index:", h);
895
- const v = O(h, 0, _ - 1), t = O(v - s * 2, 0, _ - 1), i = O(v + s * 2, 0, _ - 1), { cumulative: m, total: p, currentValue: P } = b.prefixSum(v, { materializeOption: { materialize: !0, ranges: [{ from: t, to: i }] } });
896
- A.debug("[VirtualScroll] Scrolling to index:", h, "Offset:", m, "Total height:", p, "Current value:", P, "safeIndex:", v, "safeIndexFrom:", t, "safeIndexTo:", i), p && (y(p), $(m - P)), A.debug("[VirtualScroll] Setting scroll position to:", m - P);
885
+ b.setValueFn(n), w !== u && (b.changeSize(u), X(u));
886
+ const g = b.getTotal();
887
+ P !== g && O(g);
888
+ }, [b, w, u, P, n]), oe(() => {
889
+ M !== null && x.current && (j.debug("[VirtualScroll] Scrolling to position:", M), x.current.scrollTo(M), H(null));
890
+ }, [M]);
891
+ const U = Y(
892
+ (g) => {
893
+ if (x.current) {
894
+ j.debug("[VirtualScroll] Scrolling to index:", g);
895
+ const V = F(g, 0, w - 1), r = F(V - s * 2, 0, w - 1), i = F(V + s * 2, 0, w - 1), { cumulative: h, total: v, currentValue: E } = b.prefixSum(V, { materializeOption: { materialize: !0, ranges: [{ from: r, to: i }] } });
896
+ j.debug("[VirtualScroll] Scrolling to index:", g, "Offset:", h, "Total height:", v, "Current value:", E, "safeIndex:", V, "safeIndexFrom:", r, "safeIndexTo:", i), v && (O(v), H(h - E)), j.debug("[VirtualScroll] Setting scroll position to:", h - E);
897
897
  }
898
898
  },
899
- [b, s, _]
900
- ), U = L(
901
- (h) => {
902
- if (E.current) {
903
- const v = b.getTotal(), t = O(Math.floor(h), 0, v), i = b.findIndexAtOrAfter(t, { materializeOption: { materialize: !1 } }).index;
904
- H(i);
899
+ [b, s, w]
900
+ ), q = Y(
901
+ (g) => {
902
+ if (x.current) {
903
+ const V = b.getTotal(), r = F(Math.floor(g), 0, V), i = b.findIndexAtOrAfter(r, { materializeOption: { materialize: !1 } }).index;
904
+ U(i);
905
905
  }
906
906
  },
907
- [b, H]
908
- ), Z = L(
909
- (h, v) => {
910
- A.debug("[VirtualScroll] Scroll position changed:", h), f(h);
911
- const t = b.getTotal();
912
- o?.(h, t);
907
+ [b, U]
908
+ ), Z = Y(
909
+ (g, V) => {
910
+ j.debug("[VirtualScroll] Scroll position changed:", g), f(g);
911
+ const r = b.getTotal();
912
+ o?.(g, r);
913
913
  },
914
914
  [b, o]
915
- ), { renderingStartIndex: j, renderingEndIndex: M, visibleStartIndex: G, visibleEndIndex: B } = ne(() => {
916
- if (_ === 0)
915
+ ), { renderingStartIndex: C, renderingEndIndex: D, visibleStartIndex: J, visibleEndIndex: G } = ne(() => {
916
+ if (w === 0)
917
917
  return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
918
- const { index: h, cumulative: v, currentValue: t } = b.findIndexAtOrAfter(S, { materializeOption: { materialize: !1 } });
918
+ const { index: g, cumulative: V, currentValue: r } = b.findIndexAtOrAfter(k, { materializeOption: { materialize: !1 } });
919
919
  let i = 0;
920
- h === -1 ? i = 0 : (v ?? 0) < S + (t ?? 0) ? i = 1 : i = 0;
921
- const m = h === -1 ? 0 : h + i, p = O(m - s, 0, _ - 1);
922
- let P = 0, T = h === -1 ? 0 : h + i;
923
- for (; T < _ && P < r; ) {
924
- const D = n(T);
925
- P += D, T++;
920
+ g === -1 ? i = 0 : (V ?? 0) < k + (r ?? 0) ? i = 1 : i = 0;
921
+ const h = g === -1 ? 0 : g + i, v = F(h - s, 0, w - 1);
922
+ let E = 0, T = g === -1 ? 0 : g + i;
923
+ for (; T < w && E < t; ) {
924
+ const L = n(T);
925
+ E += L, T++;
926
926
  }
927
927
  T -= 1;
928
- const C = O(T + s, 0, _ - 1);
929
- return A.debug("[VirtualScroll] Calculated rendering range:", {
930
- renderingStartIndex: p,
931
- renderingEndIndex: C,
932
- visibleStartIndex: m,
928
+ const I = F(T + s, 0, w - 1);
929
+ return j.debug("[VirtualScroll] Calculated rendering range:", {
930
+ renderingStartIndex: v,
931
+ renderingEndIndex: I,
932
+ visibleStartIndex: h,
933
933
  visibleEndIndex: T,
934
- scrollPosition: S,
934
+ scrollPosition: k,
935
935
  renderingContentSize: b.getTotal(),
936
936
  overscanCount: s,
937
- viewportSize: r
938
- }), { renderingStartIndex: p, renderingEndIndex: C, visibleStartIndex: m, visibleEndIndex: T };
939
- }, [S, s, r, n, b, _]);
940
- X(() => {
941
- const h = E.current?.getScrollPosition() ?? 0;
942
- A.debug("[VirtualScroll] Range change effect triggered", {
943
- renderingStartIndex: j,
944
- renderingEndIndex: M,
945
- visibleStartIndex: G,
946
- visibleEndIndex: B,
947
- scrollPosition: S,
948
- contentSize: w,
949
- scrollPaneScrollPosition: h
950
- }), d?.(j, M, G, B, S, w);
951
- }, [j, M, G, B, d, S, w]), X(() => {
952
- if (_ === 0) return;
953
- const h = [];
954
- for (let v = j; v <= M; v++) {
955
- const t = n(v);
956
- b.get(v) !== t && h.push({ index: v, value: t });
957
- }
958
- if (h.length > 0) {
959
- const v = b.updates(h);
960
- v && y((t) => v !== t && I.current ? (A.debug("[VirtualScroll] Updated heights for items", h, "New total height:", v), v) : t);
961
- }
962
- }, [j, M, n, b, _]);
963
- const te = L(
964
- (h) => {
965
- if (A.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: h, renderingStartIndex: j, renderingEndIndex: M, fenwickSize: _, viewportSize: r }), _ === 0)
937
+ viewportSize: t
938
+ }), { renderingStartIndex: v, renderingEndIndex: I, visibleStartIndex: h, visibleEndIndex: T };
939
+ }, [k, s, t, n, b, w]);
940
+ B(() => {
941
+ const g = x.current?.getScrollPosition() ?? 0;
942
+ j.debug("[VirtualScroll] Range change effect triggered", {
943
+ renderingStartIndex: C,
944
+ renderingEndIndex: D,
945
+ visibleStartIndex: J,
946
+ visibleEndIndex: G,
947
+ scrollPosition: k,
948
+ contentSize: P,
949
+ scrollPaneScrollPosition: g
950
+ }), d?.(C, D, J, G, k, P);
951
+ }, [C, D, J, G, d, k, P]);
952
+ const te = Y(
953
+ (g) => {
954
+ if (j.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: g, renderingStartIndex: C, renderingEndIndex: D, fenwickSize: w, viewportSize: t }), w === 0)
966
955
  return /* @__PURE__ */ z.jsx("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ z.jsx("div", { className: "text-center text-gray-500", children: "No items" }) });
967
- const v = O(j, 0, _ - 1), { cumulative: t, currentValue: i } = b.prefixSum(v, { materializeOption: { materialize: !1 } }), m = t - i, p = [];
968
- for (let T = j; T <= M; T++)
969
- p.push(e(T));
970
- const P = w < r ? 0 : m - h;
971
- return A.debug("[VirtualScroll] Rendering items", { visibleItems: p, containerTop: P }), /* @__PURE__ */ z.jsx("div", { className: "absolute w-full", style: { top: P }, children: p.map((T, C) => {
972
- const D = j + C, V = O(D, 0, _ - 1), { cumulative: q, currentValue: Q } = b.prefixSum(V, { materializeOption: { materialize: !1 } }), se = q - Q;
956
+ const V = F(C, 0, w - 1), { cumulative: r, currentValue: i } = b.prefixSum(V, { materializeOption: { materialize: !1 } }), h = r - i, v = [], E = [];
957
+ for (let I = C; I <= D; I++) {
958
+ const L = n(I);
959
+ v.push({ item: e(I), height: L }), b.get(I) !== L && E.push({ index: I, value: L });
960
+ }
961
+ E.length > 0 && Promise.resolve().then(() => {
962
+ const I = b.updates(E);
963
+ I && (O(I), j.debug("[VirtualScroll] Updated heights for items", E, "New total height:", I));
964
+ });
965
+ const T = P < t ? 0 : h - g;
966
+ return j.debug("[VirtualScroll] Rendering items", { visibleItems: v, containerTop: T }), /* @__PURE__ */ z.jsx("div", { className: "absolute w-full", style: { top: T }, children: v.map(({ item: I, height: L }, y) => {
967
+ const N = C + y, Q = F(N, 0, w - 1), { cumulative: se, currentValue: me } = b.prefixSum(Q, { materializeOption: { materialize: !1 } }), ge = se - me;
973
968
  return /* @__PURE__ */ z.jsx(
974
969
  "div",
975
970
  {
976
- "data-index": D,
971
+ "data-index": N,
977
972
  style: {
978
973
  position: "absolute",
979
- top: se - m,
974
+ top: ge - h,
980
975
  width: "100%"
981
976
  },
982
- children: l(T, D)
977
+ children: l(I, N)
983
978
  },
984
- D
979
+ N
985
980
  );
986
981
  }) });
987
982
  },
988
- [e, l, w, r, j, M, b, _]
983
+ [e, l, P, t, C, D, b, w, n]
989
984
  );
990
985
  return he(
991
- R,
986
+ _,
992
987
  () => ({
993
- getScrollPosition: () => E.current?.getScrollPosition() ?? -1,
994
- getContentSize: () => E.current?.getContentSize() ?? -1,
995
- getViewportSize: () => E.current?.getViewportSize() ?? -1,
996
- scrollTo: (h) => U(h),
997
- scrollToIndex: (h) => H(h),
988
+ getScrollPosition: () => x.current?.getScrollPosition() ?? -1,
989
+ getContentSize: () => x.current?.getContentSize() ?? -1,
990
+ getViewportSize: () => x.current?.getViewportSize() ?? -1,
991
+ scrollTo: (g) => q(g),
992
+ scrollToIndex: (g) => U(g),
998
993
  getFenwickTreeTotalHeight: () => b.getTotal(),
999
994
  getFenwickSize: () => b.getSize()
1000
995
  }),
1001
- [H, b, U]
1002
- ), /* @__PURE__ */ z.jsx(_e, { ref: E, contentSize: w, viewportSize: r, className: a, onScroll: Z, background: c, children: te });
996
+ [U, b, q]
997
+ ), /* @__PURE__ */ z.jsx(Ie, { ref: x, contentSize: P, viewportSize: t, className: a, onScroll: Z, background: c, children: te });
1003
998
  }
1004
- const Oe = de(ke);
1005
- class Se {
999
+ const Ae = de(Pe);
1000
+ class we {
1006
1001
  key;
1007
1002
  value;
1008
1003
  prev = null;
@@ -1052,9 +1047,9 @@ class fe {
1052
1047
  this.remove(e), this.addToTail(e);
1053
1048
  }
1054
1049
  }
1055
- function we(u) {
1056
- const e = Y(/* @__PURE__ */ new Map()), n = Y(new fe());
1057
- X(() => {
1050
+ function Ve(u) {
1051
+ const e = $(/* @__PURE__ */ new Map()), n = $(new fe());
1052
+ B(() => {
1058
1053
  for (; e.current.size > u; ) {
1059
1054
  const c = n.current.removeHead();
1060
1055
  if (c)
@@ -1063,43 +1058,43 @@ function we(u) {
1063
1058
  break;
1064
1059
  }
1065
1060
  }, [u]);
1066
- const r = L((c) => {
1067
- const g = e.current.get(c);
1068
- if (g)
1069
- return n.current.moveToTail(g), g.value;
1070
- }, []), s = L(
1071
- (c, g) => {
1061
+ const t = Y((c) => {
1062
+ const m = e.current.get(c);
1063
+ if (m)
1064
+ return n.current.moveToTail(m), m.value;
1065
+ }, []), s = Y(
1066
+ (c, m) => {
1072
1067
  if (u <= 0)
1073
1068
  return;
1074
- let x = e.current.get(c);
1075
- if (x)
1076
- x.value = g, n.current.moveToTail(x);
1069
+ let p = e.current.get(c);
1070
+ if (p)
1071
+ p.value = m, n.current.moveToTail(p);
1077
1072
  else {
1078
1073
  if (e.current.size >= u) {
1079
- const R = n.current.removeHead();
1080
- R && e.current.delete(R.key);
1074
+ const _ = n.current.removeHead();
1075
+ _ && e.current.delete(_.key);
1081
1076
  }
1082
- x = new Se(c, g), e.current.set(c, x), n.current.addToTail(x);
1077
+ p = new we(c, m), e.current.set(c, p), n.current.addToTail(p);
1083
1078
  }
1084
1079
  },
1085
1080
  [u]
1086
- ), a = L((c) => e.current.has(c), []), o = L(() => {
1081
+ ), a = Y((c) => e.current.has(c), []), o = Y(() => {
1087
1082
  e.current.clear(), n.current = new fe();
1088
- }, []), [d, l] = W(() => ({ get: r, set: s, has: a, clear: o }));
1089
- return X(() => l({ get: r, set: s, has: a, clear: o }), [r, s, a, o]), d;
1083
+ }, []), [d, l] = W(() => ({ get: t, set: s, has: a, clear: o }));
1084
+ return B(() => l({ get: t, set: s, has: a, clear: o }), [t, s, a, o]), d;
1090
1085
  }
1091
- const Pe = 1e4, Fe = () => {
1092
- const { get: u, set: e, has: n, clear: r } = we(Pe);
1093
- return { get: u, set: e, has: n, clear: r };
1086
+ const ye = 1e4, je = () => {
1087
+ const { get: u, set: e, has: n, clear: t } = Ve(ye);
1088
+ return { get: u, set: e, has: n, clear: t };
1094
1089
  };
1095
1090
  export {
1096
- Re as FenwickMapTree,
1097
- Ee as ScrollBar,
1098
- _e as ScrollPane,
1099
- Oe as VirtualScroll,
1100
- O as minmax,
1101
- Ie as useFenwickMapTree,
1102
- Fe as useHeightCache,
1103
- we as useLruCache
1091
+ Se as FenwickMapTree,
1092
+ Re as ScrollBar,
1093
+ Ie as ScrollPane,
1094
+ Ae as VirtualScroll,
1095
+ F as minmax,
1096
+ ke as useFenwickMapTree,
1097
+ je as useHeightCache,
1098
+ Ve as useLruCache
1104
1099
  };
1105
1100
  //# sourceMappingURL=index.js.map