@aiquants/virtualscroll 0.2.0 → 0.2.2

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,6 +1,6 @@
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 ge, { useState as X, useRef as Y, useEffect as B, forwardRef as de, useReducer as be, useMemo as ne, useCallback as L, useLayoutEffect as oe, useImperativeHandle as he, useId as ve } from "react";
2
2
  import { twMerge as ae } from "tailwind-merge";
3
- var re = { exports: {} }, K = {};
3
+ var re = { exports: {} }, ee = {};
4
4
  /**
5
5
  * @license React
6
6
  * react-jsx-runtime.production.js
@@ -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() {
15
- if (ie) return K;
14
+ function xe() {
15
+ if (ie) return ee;
16
16
  ie = 1;
17
- var u = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
18
- function n(r, s, a) {
17
+ var l = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
18
+ function r(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 = {};
@@ -23,16 +23,16 @@ function ve() {
23
23
  d !== "key" && (a[d] = s[d]);
24
24
  } else a = s;
25
25
  return s = a.ref, {
26
- $$typeof: u,
27
- type: r,
26
+ $$typeof: l,
27
+ type: t,
28
28
  key: o,
29
29
  ref: s !== void 0 ? s : null,
30
30
  props: a
31
31
  };
32
32
  }
33
- return K.Fragment = e, K.jsx = n, K.jsxs = n, K;
33
+ return ee.Fragment = e, ee.jsx = r, ee.jsxs = r, ee;
34
34
  }
35
- var ee = {};
35
+ var te = {};
36
36
  /**
37
37
  * @license React
38
38
  * react-jsx-runtime.development.js
@@ -45,293 +45,293 @@ var ee = {};
45
45
  var le;
46
46
  function pe() {
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 l(n) {
49
+ if (n == null) return null;
50
+ if (typeof n == "function")
51
+ return n.$$typeof === H ? null : n.displayName || n.name || null;
52
+ if (typeof n == "string") return n;
53
+ switch (n) {
54
+ case j:
55
55
  return "Fragment";
56
- case k:
56
+ case I:
57
57
  return "Profiler";
58
58
  case b:
59
59
  return "StrictMode";
60
- case y:
60
+ case V:
61
61
  return "Suspense";
62
- case N:
62
+ case C:
63
63
  return "SuspenseList";
64
64
  case J:
65
65
  return "Activity";
66
66
  }
67
- if (typeof t == "object")
68
- switch (typeof t.tag == "number" && console.error(
67
+ if (typeof n == "object")
68
+ switch (typeof n.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
+ ), n.$$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";
77
- case w:
78
- var i = t.render;
79
- return t = t.displayName, t || (t = i.displayName || i.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
74
+ return (n.displayName || "Context") + ".Provider";
75
+ case k:
76
+ return (n._context.displayName || "Context") + ".Consumer";
77
+ case P:
78
+ var u = n.render;
79
+ return n = n.displayName, n || (n = u.displayName || u.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
80
80
  case $:
81
- return i = t.displayName || null, i !== null ? i : u(t.type) || "Memo";
82
- case _:
83
- i = t._payload, t = t._init;
81
+ return u = n.displayName || null, u !== null ? u : l(n.type) || "Memo";
82
+ case w:
83
+ u = n._payload, n = n._init;
84
84
  try {
85
- return u(t(i));
85
+ return l(n(u));
86
86
  } catch {
87
87
  }
88
88
  }
89
89
  return null;
90
90
  }
91
- function e(t) {
92
- return "" + t;
91
+ function e(n) {
92
+ return "" + n;
93
93
  }
94
- function n(t) {
94
+ function r(n) {
95
95
  try {
96
- e(t);
97
- var i = !1;
96
+ e(n);
97
+ var u = !1;
98
98
  } catch {
99
- i = !0;
99
+ u = !0;
100
100
  }
101
- if (i) {
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(
105
- i,
101
+ if (u) {
102
+ u = console;
103
+ var h = u.error, x = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object";
104
+ return h.call(
105
+ u,
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
+ x
108
+ ), e(n);
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(n) {
112
+ if (n === j) return "<>";
113
+ if (typeof n == "object" && n !== null && n.$$typeof === w)
114
114
  return "<...>";
115
115
  try {
116
- var i = u(t);
117
- return i ? "<" + i + ">" : "<...>";
116
+ var u = l(n);
117
+ return u ? "<" + u + ">" : "<...>";
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 n = U.A;
124
+ return n === null ? null : n.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;
132
- if (i && i.isReactWarning) return !1;
129
+ function o(n) {
130
+ if (Z.call(n, "key")) {
131
+ var u = Object.getOwnPropertyDescriptor(n, "key").get;
132
+ if (u && u.isReactWarning) return !1;
133
133
  }
134
- return t.key !== void 0;
134
+ return n.key !== void 0;
135
135
  }
136
- function d(t, i) {
137
- function m() {
138
- G || (G = !0, console.error(
136
+ function d(n, u) {
137
+ function h() {
138
+ g || (g = !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
- i
140
+ u
141
141
  ));
142
142
  }
143
- m.isReactWarning = !0, Object.defineProperty(t, "key", {
144
- get: m,
143
+ h.isReactWarning = !0, Object.defineProperty(n, "key", {
144
+ get: h,
145
145
  configurable: !0
146
146
  });
147
147
  }
148
- function l() {
149
- var t = u(this.type);
150
- return B[t] || (B[t] = !0, console.error(
148
+ function i() {
149
+ var n = l(this.type);
150
+ return E[n] || (E[n] = !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
+ )), n = this.props.ref, n !== void 0 ? n : 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,
158
- key: i,
154
+ function c(n, u, h, x, z, T, q, G) {
155
+ return h = T.ref, n = {
156
+ $$typeof: p,
157
+ type: n,
158
+ key: u,
159
159
  props: T,
160
- _owner: P
161
- }, (m !== void 0 ? m : null) !== null ? Object.defineProperty(t, "ref", {
160
+ _owner: z
161
+ }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(n, "ref", {
162
162
  enumerable: !1,
163
- get: l
164
- }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
163
+ get: i
164
+ }) : Object.defineProperty(n, "ref", { enumerable: !1, value: null }), n._store = {}, Object.defineProperty(n._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(n, "_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(n, "_debugStack", {
175
175
  configurable: !1,
176
176
  enumerable: !1,
177
177
  writable: !0,
178
- value: C
179
- }), Object.defineProperty(t, "_debugTask", {
178
+ value: q
179
+ }), Object.defineProperty(n, "_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: G
184
+ }), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
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(n, u, h, x, z, T, q, G) {
187
+ var R = u.children;
188
+ if (R !== void 0)
189
+ if (x)
190
+ if (F(R)) {
191
+ for (x = 0; x < R.length; x++)
192
+ v(R[x]);
193
+ Object.freeze && Object.freeze(R);
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);
199
- if (Z.call(i, "key")) {
200
- V = u(t);
201
- var q = Object.keys(i).filter(function(se) {
198
+ else v(R);
199
+ if (Z.call(u, "key")) {
200
+ R = l(n);
201
+ var W = Object.keys(u).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
+ x = 0 < W.length ? "{key: someKey, " + W.join(": ..., ") + ": ...}" : "{key: someKey}", M[R + x] || (W = 0 < W.length ? "{" + W.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
+ x,
212
+ R,
213
+ W,
214
+ R
215
+ ), M[R + x] = !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 = {};
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
217
+ if (R = null, h !== void 0 && (r(h), R = "" + h), o(u) && (r(u.key), R = "" + u.key), "key" in u) {
218
+ h = {};
219
+ for (var K in u)
220
+ K !== "key" && (h[K] = u[K]);
221
+ } else h = u;
222
+ return R && d(
223
+ h,
224
+ typeof n == "function" ? n.displayName || n.name || "Unknown" : n
225
225
  ), c(
226
- t,
227
- V,
226
+ n,
227
+ R,
228
228
  T,
229
- P,
229
+ z,
230
230
  s(),
231
- m,
232
- C,
233
- D
231
+ h,
232
+ q,
233
+ G
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 v(n) {
237
+ typeof n == "object" && n !== null && n.$$typeof === p && n._store && (n._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 _ = ge, p = Symbol.for("react.transitional.element"), S = Symbol.for("react.portal"), j = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), I = Symbol.for("react.profiler"), k = Symbol.for("react.consumer"), f = Symbol.for("react.context"), P = Symbol.for("react.forward_ref"), V = Symbol.for("react.suspense"), C = Symbol.for("react.suspense_list"), $ = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), J = Symbol.for("react.activity"), H = Symbol.for("react.client.reference"), U = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, F = Array.isArray, Q = 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(n) {
244
+ return n();
245
245
  }
246
246
  };
247
- var G, B = {}, te = R.react_stack_bottom_frame.bind(
248
- R,
247
+ var g, E = {}, y = _.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) {
250
+ )(), O = Q(t(a)), M = {};
251
+ te.Fragment = j, te.jsx = function(n, u, h, x, z) {
252
252
  var T = 1e4 > U.recentlyCreatedOwnerStacks++;
253
- return g(
254
- t,
255
- i,
256
- m,
253
+ return m(
254
+ n,
255
+ u,
256
+ h,
257
257
  !1,
258
- p,
259
- P,
260
- T ? Error("react-stack-top-frame") : te,
261
- T ? M(r(t)) : h
258
+ x,
259
+ z,
260
+ T ? Error("react-stack-top-frame") : y,
261
+ T ? Q(t(n)) : O
262
262
  );
263
- }, ee.jsxs = function(t, i, m, p, P) {
263
+ }, te.jsxs = function(n, u, h, x, z) {
264
264
  var T = 1e4 > U.recentlyCreatedOwnerStacks++;
265
- return g(
266
- t,
267
- i,
268
- m,
265
+ return m(
266
+ n,
267
+ u,
268
+ h,
269
269
  !0,
270
- p,
271
- P,
272
- T ? Error("react-stack-top-frame") : te,
273
- T ? M(r(t)) : h
270
+ x,
271
+ z,
272
+ T ? Error("react-stack-top-frame") : y,
273
+ T ? Q(t(n)) : O
274
274
  );
275
275
  };
276
- })()), ee;
276
+ })()), te;
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 Te() {
280
+ return ue || (ue = 1, process.env.NODE_ENV === "production" ? re.exports = xe() : re.exports = pe()), re.exports;
281
281
  }
282
- var z = xe();
283
- const A = {
284
- debug(u, ...e) {
285
- typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${u}`, ...e);
282
+ var D = Te();
283
+ const N = {
284
+ debug(l, ...e) {
285
+ typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${l}`, ...e);
286
286
  },
287
- warn(u, ...e) {
288
- console.warn(`[VirtualScroll] ${u}`, ...e);
287
+ warn(l, ...e) {
288
+ console.warn(`[VirtualScroll] ${l}`, ...e);
289
289
  },
290
- error(u, ...e) {
291
- console.error(`[VirtualScroll] ${u}`, ...e);
290
+ error(l, ...e) {
291
+ console.error(`[VirtualScroll] ${l}`, ...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();
296
- const l = "touches" in d ? d.touches[0] : d;
293
+ }, A = (l, e, r) => Math.min(r, Math.max(e, l)), ce = (l, e, r) => {
294
+ const t = "touches" in l.nativeEvent, s = t ? l.nativeEvent.touches[0] : l.nativeEvent, a = (d) => {
295
+ t && d.cancelable && d.preventDefault();
296
+ const i = "touches" in d ? d.touches[0] : d;
297
297
  e({
298
- deltaX: l.clientX - s.clientX,
299
- deltaY: l.clientY - s.clientY
298
+ deltaX: i.clientX - s.clientX,
299
+ deltaY: i.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)), r?.();
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");
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)
304
+ t ? (document.addEventListener("touchmove", a, { passive: !1 }), document.addEventListener("touchend", o)) : (document.addEventListener("mousemove", a), document.addEventListener("mouseup", o));
305
+ }, Ee = 20, _e = ({ contentSize: l, viewportSize: e, scrollPosition: r, onScroll: t, horizontal: s = !1, scrollBarWidth: a = 12, className: o, ariaControls: d }) => {
306
+ const [i, c] = X(!1), m = Y(null), v = e / l, _ = Math.max(Ee, v * e), p = l - e, S = r / p * (e - _), j = l > e;
307
+ B(() => {
308
+ m.current && (i ? m.current.style.backgroundColor = "#4F4F4F" : m.current.style.backgroundColor = "#7F7F7F");
309
+ }, [i]);
310
+ const b = (f) => A(f / (e - _) * p, 0, p), I = (f) => {
311
+ if (!j || "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: V, deltaY: C }) => {
318
+ t?.(b(P + (s ? V : C)), 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 (!j || "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 V = "touches" in f.nativeEvent ? f.nativeEvent.touches[0] : f.nativeEvent, C = s ? V.clientX : V.clientY, $ = f.currentTarget.getBoundingClientRect(), J = (s ? C - $.left : C - $.top) - _ / 2;
328
+ t?.(b(J), S), ce(f, ({ deltaX: H, deltaY: U }) => {
329
+ t?.(b(J + (s ? H : U)), S);
330
330
  });
331
331
  };
332
332
  return (
333
333
  // スクロールバーのコンテナ
334
- /* @__PURE__ */ z.jsx(
334
+ /* @__PURE__ */ D.jsx(
335
335
  "div",
336
336
  {
337
337
  className: ae("group relative cursor-default select-none", o),
@@ -341,41 +341,41 @@ 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
- "aria-valuenow": n,
349
+ "aria-valuenow": r,
350
350
  "aria-valuemin": 0,
351
- "aria-valuemax": E,
351
+ "aria-valuemax": p,
352
352
  "aria-orientation": s ? "horizontal" : "vertical",
353
- children: u > e && // スクロールバーのつまみの当たり判定を広げるためのラッパー
354
- /* @__PURE__ */ z.jsx(
353
+ children: l > e && // スクロールバーのつまみの当たり判定を広げるためのラッパー
354
+ /* @__PURE__ */ D.jsx(
355
355
  "div",
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: I,
365
+ onTouchStart: I,
366
366
  role: "slider",
367
367
  "aria-orientation": s ? "horizontal" : "vertical",
368
- "aria-valuenow": n,
368
+ "aria-valuenow": r,
369
369
  "aria-valuemin": 0,
370
- "aria-valuemax": E,
370
+ "aria-valuemax": p,
371
371
  tabIndex: 0,
372
- children: /* @__PURE__ */ z.jsx(
372
+ children: /* @__PURE__ */ D.jsx(
373
373
  "div",
374
374
  {
375
- ref: g,
375
+ ref: m,
376
376
  className: ae(
377
377
  "absolute",
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]"}`
378
+ s ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${i ? "inset-y-[-2px]" : "group-active:inset-y-[-2px]"}` : `inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${i ? "inset-x-[-2px]" : "group-active:inset-x-[-2px]"}`
379
379
  ),
380
380
  style: {
381
381
  backgroundColor: "#7F7F7F",
@@ -384,20 +384,20 @@ const A = {
384
384
  ...s ? {
385
385
  left: 0,
386
386
  right: 0,
387
- top: l ? -2 : 1.5,
388
- bottom: l ? -2 : 1.5
387
+ top: i ? -2 : 1.5,
388
+ bottom: i ? -2 : 1.5
389
389
  } : {
390
390
  top: 0,
391
391
  bottom: 0,
392
- left: l ? -2 : 1.5,
393
- right: l ? -2 : 1.5
392
+ left: i ? -2 : 1.5,
393
+ right: i ? -2 : 1.5
394
394
  }
395
395
  },
396
396
  onMouseEnter: (f) => {
397
- s ? (f.currentTarget.style.top = "-0.5px", f.currentTarget.style.bottom = "-0.5px") : (f.currentTarget.style.left = "-0.5px", f.currentTarget.style.right = "-0.5px"), l || (f.currentTarget.style.backgroundColor = "#5F5F5F");
397
+ s ? (f.currentTarget.style.top = "-0.5px", f.currentTarget.style.bottom = "-0.5px") : (f.currentTarget.style.left = "-0.5px", f.currentTarget.style.right = "-0.5px"), i || (f.currentTarget.style.backgroundColor = "#5F5F5F");
398
398
  },
399
399
  onMouseLeave: (f) => {
400
- s ? (f.currentTarget.style.top = l ? "-2px" : "1.5px", f.currentTarget.style.bottom = l ? "-2px" : "1.5px") : (f.currentTarget.style.left = l ? "-2px" : "1.5px", f.currentTarget.style.right = l ? "-2px" : "1.5px"), l || (f.currentTarget.style.backgroundColor = "#7F7F7F");
400
+ s ? (f.currentTarget.style.top = i ? "-2px" : "1.5px", f.currentTarget.style.bottom = i ? "-2px" : "1.5px") : (f.currentTarget.style.left = i ? "-2px" : "1.5px", f.currentTarget.style.right = i ? "-2px" : "1.5px"), i || (f.currentTarget.style.backgroundColor = "#7F7F7F");
401
401
  }
402
402
  }
403
403
  )
@@ -406,57 +406,57 @@ 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: l, contentSize: e, viewportSize: r, scrollBarWidth: t = 12, onScroll: s, className: a, style: o, background: d }, i) => {
410
+ const c = Y(0), [m, v] = be((I) => I + 1, 0), _ = Y(null);
411
+ N.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: r, scrollBarWidth: t, className: a, style: o });
412
+ const p = ne(() => e > r, [e, r]), S = L(
413
+ (I) => {
414
+ const k = e > r, f = c.current;
415
+ if (N.debug("[ScrollPane] scrollTo called", { newPosition: I, contentSize: e, viewportSize: r, 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 I == "function" ? I(c.current) : I, V = A(P, 0, e - r);
420
+ c.current !== V && (c.current = V, s?.(V, f));
421
421
  },
422
- [s, e, n]
422
+ [s, e, r]
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 (p) {
426
+ N.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: r, scrollPosition: c.current });
427
+ const I = A(e - r, 0, e);
428
+ c.current > I && S(I);
429
429
  } else
430
- I(0);
431
- }, [E, I, e, n]), X(() => {
432
- const k = (f) => {
433
- if (!E)
430
+ S(0);
431
+ }, [p, S, e, r]), B(() => {
432
+ const I = (f) => {
433
+ if (!p)
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 *= r), N.debug("[ScrollPane] wheel event", { deltaY: P, scrollPosition: c.current }), S((V) => V + P);
438
+ }, k = _.current;
439
+ return k && k.addEventListener("wheel", I, { passive: !1 }), () => {
440
+ k && k.removeEventListener("wheel", I);
441
441
  };
442
- }, [E, I, n]), he(
443
- l,
442
+ }, [p, S, r]), he(
443
+ i,
444
444
  () => ({
445
- scrollTo: I,
445
+ scrollTo: S,
446
446
  getScrollPosition: () => c.current,
447
447
  getContentSize: () => e,
448
- getViewportSize: () => n
448
+ getViewportSize: () => r
449
449
  }),
450
- [I, e, n]
450
+ [S, e, r]
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 j = ve();
453
+ return ne(() => /* @__PURE__ */ D.jsxs("div", { ref: _, className: ae("flex", a), style: o, children: [
454
+ /* @__PURE__ */ D.jsxs("div", { className: "relative h-full flex-1 overflow-hidden", style: { height: r }, id: j, children: [
455
455
  d,
456
- u(c.current)
456
+ l(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
+ p && /* @__PURE__ */ D.jsx(_e, { contentSize: e, viewportSize: r, scrollPosition: c.current, onScroll: S, scrollBarWidth: t, ariaControls: j })
459
+ ] }), [l, e, r, t, a, o, p, S, j, d]);
460
460
  });
461
461
  class Re {
462
462
  /**
@@ -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, r, t) {
502
+ this.reset(e, r, t);
503
503
  }
504
504
  /**
505
505
  * @method reset
@@ -509,26 +509,26 @@ 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) {
513
- if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof n == "function") {
514
- if (this.valueFn = n, this.size > 0) {
515
- const a = r?.sampleRange ?? {
512
+ reset(e, r, t) {
513
+ if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof r == "function") {
514
+ if (this.valueFn = r, this.size > 0) {
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)
520
- for (let l = 0; l < d.length; l++) {
521
- const c = d[l], g = a.from + l;
522
- if (g >= this.size)
519
+ if (this.baseValue = o, t?.materialize)
520
+ for (let i = 0; i < d.length; i++) {
521
+ const c = d[i], m = a.from + i;
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 v = c - this.baseValue;
525
+ this.deltas.set(m, v), this._updateTree(m, v);
526
526
  }
527
527
  } else
528
528
  this.baseValue = 0;
529
529
  this.total = this.getTotal();
530
530
  } else
531
- this.valueFn = void 0, this.baseValue = n, this.total = this.baseValue * this.size;
531
+ this.valueFn = void 0, this.baseValue = r, this.total = this.baseValue * this.size;
532
532
  }
533
533
  /**
534
534
  * @method setValueFn
@@ -548,31 +548,31 @@ class Re {
548
548
  * @param {number} to - The ending index of the range (inclusive).
549
549
  * @returns {{ mode: number; materializedValues: number[] }} An object containing the calculated mode and the array of generated values.
550
550
  */
551
- _calculateMode(e, n) {
551
+ _calculateMode(e, r) {
552
552
  if (!this.valueFn)
553
553
  return { mode: 0, materializedValues: [] };
554
- const r = [];
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)
554
+ const t = [];
555
+ for (let c = e; c <= r && !(c >= this.size); c++)
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
- 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);
565
+ let i = 0;
566
+ for (const c of t) {
567
+ const m = (d.get(c) ?? 0) + 1;
568
+ d.set(c, m), m > i && (i = m);
569
569
  }
570
- if (l > 1) {
570
+ if (i > 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 [v, _] of d.entries())
573
+ _ === i && c.push(v);
574
+ const m = c.reduce((v, _) => v + _, 0);
575
+ o = Math.floor(m / c.length);
576
576
  }
577
577
  return { mode: o, materializedValues: s };
578
578
  }
@@ -583,8 +583,8 @@ class Re {
583
583
  * @param {number} index - The 0-based index to update.
584
584
  * @param {number} value - The new value.
585
585
  */
586
- update(e, n) {
587
- return this.updates([{ index: e, value: n }]);
586
+ update(e, r) {
587
+ return this.updates([{ index: e, value: r }]);
588
588
  }
589
589
  /**
590
590
  * @method updates
@@ -593,15 +593,15 @@ 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 r = 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);
604
- return n.length > 0 ? this.updateDeltas(n) : this.total;
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
+ return r.length > 0 ? this.updateDeltas(r) : this.total;
605
605
  }
606
606
  /**
607
607
  * @method updateDelta
@@ -610,8 +610,8 @@ class Re {
610
610
  * @param {number} index - The 0-based index to update.
611
611
  * @param {number} change - The value to add to the delta at the given index.
612
612
  */
613
- updateDelta(e, n) {
614
- return this.updateDeltas([{ index: e, change: n }]);
613
+ updateDelta(e, r) {
614
+ return this.updateDeltas([{ index: e, change: r }]);
615
615
  }
616
616
  /**
617
617
  * @method updateDeltas
@@ -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) {
624
- if (n < 0 || n >= this.size)
625
- throw new Error(`Index ${n} out of bounds`);
626
- const s = this.deltas.get(n) ?? 0;
627
- this.deltas.set(n, s + r), this._updateTree(n, r);
623
+ for (const { index: r, change: t } of e) {
624
+ if (r < 0 || r >= this.size)
625
+ throw new Error(`Index ${r} out of bounds`);
626
+ const s = this.deltas.get(r) ?? 0;
627
+ this.deltas.set(r, s + t), this._updateTree(r, t);
628
628
  }
629
629
  return this.total;
630
630
  }
@@ -636,13 +636,13 @@ class Re {
636
636
  * @param {number} index - The 0-based index that changed.
637
637
  * @param {number} change - The change in value.
638
638
  */
639
- _updateTree(e, n) {
640
- if (n === 0)
639
+ _updateTree(e, r) {
640
+ if (r === 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;
645
- this.total !== void 0 && (this.total += n);
642
+ let t = e + 1;
643
+ for (; t <= this.size; )
644
+ this.tree.set(t, (this.tree.get(t) ?? 0) + r), t += t & -t;
645
+ this.total !== void 0 && (this.total += r);
646
646
  }
647
647
  /**
648
648
  * @private
@@ -652,11 +652,11 @@ class Re {
652
652
  * @param {number} index - The 0-based index to materialize.
653
653
  * @param {boolean} [updateTree=true] - Whether to update the Fenwick tree after materialization.
654
654
  */
655
- _materialize(e, n = !0) {
655
+ _materialize(e, r = !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), r)) {
659
+ const o = a - t;
660
660
  this._updateTree(e, o);
661
661
  }
662
662
  }
@@ -674,26 +674,26 @@ class Re {
674
674
  * @param {number} options.materializeOption.ranges.to - The ending index of the range.
675
675
  * @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.
676
676
  */
677
- prefixSum(e, n) {
677
+ prefixSum(e, r) {
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 = A(e, 0, this.size - 1), s = r?.materializeOption;
681
681
  if (s?.materialize && this.valueFn) {
682
682
  if (s.ranges)
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);
683
+ for (const i of s.ranges) {
684
+ const c = i.from, m = Math.min(i.to, this.size - 1);
685
+ for (let v = c; v <= m; v++)
686
+ this._materialize(v);
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
- const l = this.tree.get(o) ?? 0;
693
- a += l, o -= o & -o;
692
+ const i = this.tree.get(o) ?? 0;
693
+ a += i, 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
@@ -708,18 +708,18 @@ class Re {
708
708
  * @param {number} options.materializeOption.ranges.to - The ending index of the range.
709
709
  * @returns {number} The value at the given index.
710
710
  */
711
- get(e, n) {
711
+ get(e, r) {
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 = r?.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;
@@ -737,10 +737,10 @@ class Re {
737
737
  * @returns {number} The total sum of all values.
738
738
  */
739
739
  getTotal(e) {
740
- const n = e?.materializeOption;
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);
740
+ const r = e?.materializeOption;
741
+ if (r?.materialize && this.valueFn && r.ranges)
742
+ for (const t of r.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
  }
@@ -768,16 +768,16 @@ class Re {
768
768
  this.reset(this.size, (a) => s(a), { materialize: !0 });
769
769
  return;
770
770
  }
771
- const n = /* @__PURE__ */ new Map();
772
- let r = this.baseValue * this.size;
771
+ const r = /* @__PURE__ */ new Map();
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
- n.set(o, (n.get(o) ?? 0) + a), o += o & -o;
778
+ r.set(o, (r.get(o) ?? 0) + a), o += o & -o;
779
779
  }
780
- this.tree = n, this.total = r;
780
+ this.tree = r, this.total = t;
781
781
  }
782
782
  /**
783
783
  * @method calculateAccumulatedError
@@ -789,8 +789,8 @@ class Re {
789
789
  if (this.total === void 0)
790
790
  return 0;
791
791
  let e = this.baseValue * this.size;
792
- for (const n of this.deltas.values())
793
- e += n;
792
+ for (const r of this.deltas.values())
793
+ e += r;
794
794
  return this.total - e;
795
795
  }
796
796
  /**
@@ -800,11 +800,11 @@ class Re {
800
800
  * @param {number} newSize - The new size of the tree.
801
801
  */
802
802
  changeSize(e) {
803
- const n = this.size;
804
- if (e !== n) {
805
- if (e < n)
806
- for (const r of this.deltas.keys())
807
- r >= e && this.deltas.delete(r);
803
+ const r = this.size;
804
+ if (e !== r) {
805
+ if (e < 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
  }
@@ -830,13 +830,13 @@ class Re {
830
830
  * @param {number} options.materializeOption.ranges.to - The ending index of the range.
831
831
  * @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.
832
832
  */
833
- findIndexAtOrAfter(e, n) {
833
+ findIndexAtOrAfter(e, r) {
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 i = Math.floor((t + s) / 2);
839
+ o = this.prefixSum(i, r), d = o.total, o.cumulative >= e ? (a = i, s = i - 1) : t = i + 1;
840
840
  }
841
841
  return { index: a, total: d, cumulative: o?.cumulative, currentValue: o?.currentValue, safeIndex: o?.safeIndex };
842
842
  }
@@ -853,162 +853,158 @@ class Re {
853
853
  * @param {number} options.materializeOption.ranges.to - The ending index of the range.
854
854
  * @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.
855
855
  */
856
- findIndexAtOrBefore(e, n) {
856
+ findIndexAtOrBefore(e, r) {
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 i = Math.floor((t + s) / 2);
862
+ o = this.prefixSum(i, r), d = o.total, o.cumulative <= e ? (a = i, t = i + 1) : s = i - 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 Se = (l, e, r) => {
868
+ const t = Math.max(0, l), s = Y(null), a = ne(() => new Re(t, e, r), [t, e, r]);
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 ke({ itemCount: l, getItem: e, getItemHeight: r, viewportSize: t, overscanCount: s = 5, className: a, onScroll: o, onRangeChange: d, children: i, background: c, initialScrollIndex: m, initialScrollOffset: v }, _) {
872
+ const p = Y(null), S = Y(!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 j = Y({ size: l, valueOrFn: r, options: { sampleRange: { from: 0, to: 100 } } }), b = Se(j.current.size, j.current.valueOrFn, j.current.options), [I] = X(() => {
877
+ let g = 0, E = 0;
878
+ if (typeof m == "number") {
879
+ const y = A(m, 0, l - 1), O = A(y - s * 2, 0, l - 1), M = A(y + s * 2, 0, l - 1), n = m > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: O, to: M }] } } : void 0, { cumulative: u, total: h, currentValue: x } = b.prefixSum(m, n);
880
+ g = u - x, E = h ?? b.getTotal();
881
+ } else typeof v == "number" && (g = v), E = b.getTotal();
882
+ return { position: g, total: E };
883
+ }), [k, f] = X(I.position), [P, V] = X(I.total), [C, $] = X(I.position), [w, J] = X(l);
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]);
885
+ b.setValueFn(r), w !== l && (b.changeSize(l), J(l));
886
+ const g = b.getTotal();
887
+ P !== g && V(g);
888
+ }, [b, w, l, P, r]), oe(() => {
889
+ C !== null && p.current && (N.debug("[VirtualScroll] Scrolling to position:", C), p.current.scrollTo(C), $(null));
890
+ }, [C]);
891
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);
892
+ (g) => {
893
+ if (p.current) {
894
+ N.debug("[VirtualScroll] Scrolling to index:", g);
895
+ const E = A(g, 0, w - 1), y = A(E - s * 2, 0, w - 1), O = A(E + s * 2, 0, w - 1), { cumulative: M, total: n, currentValue: u } = b.prefixSum(E, { materializeOption: { materialize: !0, ranges: [{ from: y, to: O }] } });
896
+ N.debug("[VirtualScroll] Scrolling to index:", g, "Offset:", M, "Total height:", n, "Current value:", u, "safeIndex:", E, "safeIndexFrom:", y, "safeIndexTo:", O), n && (V(n), $(M - u)), N.debug("[VirtualScroll] Setting scroll position to:", M - u);
897
897
  }
898
898
  },
899
- [b, s, _]
899
+ [b, s, w]
900
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);
901
+ (g) => {
902
+ if (p.current) {
903
+ const E = b.getTotal(), y = A(Math.floor(g), 0, E), O = b.findIndexAtOrAfter(y, { materializeOption: { materialize: !1 } }).index;
904
+ H(O);
905
905
  }
906
906
  },
907
907
  [b, H]
908
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);
909
+ (g, E) => {
910
+ N.debug("[VirtualScroll] Scroll position changed:", g), f(g);
911
+ const y = b.getTotal();
912
+ o?.(g, y);
913
913
  },
914
914
  [b, o]
915
- ), { renderingStartIndex: j, renderingEndIndex: M, visibleStartIndex: G, visibleEndIndex: B } = ne(() => {
916
- if (_ === 0)
915
+ ), F = 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 } });
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++;
918
+ const { index: g, cumulative: E, currentValue: y } = b.findIndexAtOrAfter(k, { materializeOption: { materialize: !1 } });
919
+ let O = 0;
920
+ g === -1 ? O = 0 : (E ?? 0) < k + (y ?? 0) ? O = 1 : O = 0;
921
+ const M = g === -1 ? 0 : g + O, n = A(M - s, 0, w - 1);
922
+ let u = 0, h = g === -1 ? 0 : g + O;
923
+ for (; h < w && u < t; ) {
924
+ const z = r(h);
925
+ u += z, h++;
926
926
  }
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,
933
- visibleEndIndex: T,
934
- scrollPosition: S,
927
+ h -= 1;
928
+ const x = A(h + s, 0, w - 1);
929
+ return N.debug("[VirtualScroll] Calculated rendering range:", {
930
+ renderingStartIndex: n,
931
+ renderingEndIndex: x,
932
+ visibleStartIndex: M,
933
+ visibleEndIndex: h,
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)
966
- 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;
973
- return /* @__PURE__ */ z.jsx(
937
+ viewportSize: t
938
+ }), { renderingStartIndex: n, renderingEndIndex: x, visibleStartIndex: M, visibleEndIndex: h };
939
+ }, [k, s, t, r, b, w]);
940
+ B(() => {
941
+ const g = p.current?.getScrollPosition() ?? 0;
942
+ N.debug("[VirtualScroll] Range change effect triggered", {
943
+ renderingStartIndex: F.renderingStartIndex,
944
+ renderingEndIndex: F.renderingEndIndex,
945
+ visibleStartIndex: F.visibleStartIndex,
946
+ visibleEndIndex: F.visibleEndIndex,
947
+ scrollPosition: k,
948
+ contentSize: P,
949
+ scrollPaneScrollPosition: g
950
+ }), d?.(F.renderingStartIndex, F.renderingEndIndex, F.visibleStartIndex, F.visibleEndIndex, k, P);
951
+ }, [F.renderingStartIndex, F.renderingEndIndex, F.visibleStartIndex, F.visibleEndIndex, d, k, P]);
952
+ const Q = L(
953
+ (g) => {
954
+ const { renderingStartIndex: E, renderingEndIndex: y } = F;
955
+ if (N.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: g, renderingStartIndex: E, renderingEndIndex: y, fenwickSize: w, viewportSize: t }), w === 0)
956
+ return /* @__PURE__ */ D.jsx("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ D.jsx("div", { className: "text-center text-gray-500", children: "No items" }) });
957
+ const O = A(E, 0, w - 1), { cumulative: M, currentValue: n } = b.prefixSum(O, { materializeOption: { materialize: !1 } }), u = M - n, h = [], x = [];
958
+ for (let T = E; T <= y; T++) {
959
+ const q = r(T);
960
+ h.push({ item: e(T), height: q }), b.get(T) !== q && x.push({ index: T, value: q });
961
+ }
962
+ x.length > 0 && Promise.resolve().then(() => {
963
+ const T = b.updates(x);
964
+ T && (V(T), N.debug("[VirtualScroll] Updated heights for items", x, "New total height:", T));
965
+ });
966
+ const z = P < t ? 0 : u - g;
967
+ return N.debug("[VirtualScroll] Rendering items", { visibleItems: h, containerTop: z }), /* @__PURE__ */ D.jsx("div", { className: "absolute w-full", style: { top: z }, children: h.map(({ item: T, height: q }, G) => {
968
+ const R = E + G, W = A(R, 0, w - 1), { cumulative: K, currentValue: se } = b.prefixSum(W, { materializeOption: { materialize: !1 } }), me = K - se;
969
+ return /* @__PURE__ */ D.jsx(
974
970
  "div",
975
971
  {
976
- "data-index": D,
972
+ "data-index": R,
977
973
  style: {
978
974
  position: "absolute",
979
- top: se - m,
975
+ top: me - u,
980
976
  width: "100%"
981
977
  },
982
- children: l(T, D)
978
+ children: i(T, R)
983
979
  },
984
- D
980
+ R
985
981
  );
986
982
  }) });
987
983
  },
988
- [e, l, w, r, j, M, b, _]
984
+ [e, i, P, t, F, b, w, r]
989
985
  );
990
986
  return he(
991
- R,
987
+ _,
992
988
  () => ({
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),
989
+ getScrollPosition: () => p.current?.getScrollPosition() ?? -1,
990
+ getContentSize: () => p.current?.getContentSize() ?? -1,
991
+ getViewportSize: () => p.current?.getViewportSize() ?? -1,
992
+ scrollTo: (g) => U(g),
993
+ scrollToIndex: (g) => H(g),
998
994
  getFenwickTreeTotalHeight: () => b.getTotal(),
999
995
  getFenwickSize: () => b.getSize()
1000
996
  }),
1001
997
  [H, b, U]
1002
- ), /* @__PURE__ */ z.jsx(_e, { ref: E, contentSize: w, viewportSize: r, className: a, onScroll: Z, background: c, children: te });
998
+ ), /* @__PURE__ */ D.jsx(Ie, { ref: p, contentSize: P, viewportSize: t, className: a, onScroll: Z, background: c, children: Q });
1003
999
  }
1004
- const Oe = de(ke);
1005
- class Se {
1000
+ const Fe = de(ke);
1001
+ class Pe {
1006
1002
  key;
1007
1003
  value;
1008
1004
  prev = null;
1009
1005
  next = null;
1010
- constructor(e, n) {
1011
- this.key = e, this.value = n;
1006
+ constructor(e, r) {
1007
+ this.key = e, this.value = r;
1012
1008
  }
1013
1009
  }
1014
1010
  class fe {
@@ -1052,54 +1048,54 @@ class fe {
1052
1048
  this.remove(e), this.addToTail(e);
1053
1049
  }
1054
1050
  }
1055
- function we(u) {
1056
- const e = Y(/* @__PURE__ */ new Map()), n = Y(new fe());
1057
- X(() => {
1058
- for (; e.current.size > u; ) {
1059
- const c = n.current.removeHead();
1051
+ function we(l) {
1052
+ const e = Y(/* @__PURE__ */ new Map()), r = Y(new fe());
1053
+ B(() => {
1054
+ for (; e.current.size > l; ) {
1055
+ const c = r.current.removeHead();
1060
1056
  if (c)
1061
1057
  e.current.delete(c.key);
1062
1058
  else
1063
1059
  break;
1064
1060
  }
1065
- }, [u]);
1066
- const r = L((c) => {
1067
- const g = e.current.get(c);
1068
- if (g)
1069
- return n.current.moveToTail(g), g.value;
1061
+ }, [l]);
1062
+ const t = L((c) => {
1063
+ const m = e.current.get(c);
1064
+ if (m)
1065
+ return r.current.moveToTail(m), m.value;
1070
1066
  }, []), s = L(
1071
- (c, g) => {
1072
- if (u <= 0)
1067
+ (c, m) => {
1068
+ if (l <= 0)
1073
1069
  return;
1074
- let x = e.current.get(c);
1075
- if (x)
1076
- x.value = g, n.current.moveToTail(x);
1070
+ let v = e.current.get(c);
1071
+ if (v)
1072
+ v.value = m, r.current.moveToTail(v);
1077
1073
  else {
1078
- if (e.current.size >= u) {
1079
- const R = n.current.removeHead();
1080
- R && e.current.delete(R.key);
1074
+ if (e.current.size >= l) {
1075
+ const _ = r.current.removeHead();
1076
+ _ && e.current.delete(_.key);
1081
1077
  }
1082
- x = new Se(c, g), e.current.set(c, x), n.current.addToTail(x);
1078
+ v = new Pe(c, m), e.current.set(c, v), r.current.addToTail(v);
1083
1079
  }
1084
1080
  },
1085
- [u]
1081
+ [l]
1086
1082
  ), a = L((c) => e.current.has(c), []), o = L(() => {
1087
- 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
+ e.current.clear(), r.current = new fe();
1084
+ }, []), [d, i] = X(() => ({ get: t, set: s, has: a, clear: o }));
1085
+ return B(() => i({ get: t, set: s, has: a, clear: o }), [t, s, a, o]), d;
1090
1086
  }
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 };
1087
+ const Ve = 1e4, Ae = () => {
1088
+ const { get: l, set: e, has: r, clear: t } = we(Ve);
1089
+ return { get: l, set: e, has: r, clear: t };
1094
1090
  };
1095
1091
  export {
1096
1092
  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,
1093
+ _e as ScrollBar,
1094
+ Ie as ScrollPane,
1095
+ Fe as VirtualScroll,
1096
+ A as minmax,
1097
+ Se as useFenwickMapTree,
1098
+ Ae as useHeightCache,
1103
1099
  we as useLruCache
1104
1100
  };
1105
1101
  //# sourceMappingURL=index.js.map