@aiquants/virtualscroll 0.2.1 → 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 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";
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
@@ -12,10 +12,10 @@ var re = { exports: {} }, K = {};
12
12
  */
13
13
  var ie;
14
14
  function xe() {
15
- if (ie) return K;
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(t, 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 xe() {
23
23
  d !== "key" && (a[d] = s[d]);
24
24
  } else a = s;
25
25
  return s = a.ref, {
26
- $$typeof: u,
26
+ $$typeof: l,
27
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
@@ -43,295 +43,295 @@ var ee = {};
43
43
  * LICENSE file in the root directory of this source tree.
44
44
  */
45
45
  var le;
46
- function Te() {
46
+ function pe() {
47
47
  return le || (le = 1, process.env.NODE_ENV !== "production" && (function() {
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:
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 R:
56
+ case I:
57
57
  return "Profiler";
58
58
  case b:
59
59
  return "StrictMode";
60
- case O:
60
+ case V:
61
61
  return "Suspense";
62
- case M:
62
+ case C:
63
63
  return "SuspenseList";
64
- case X:
64
+ case J:
65
65
  return "Activity";
66
66
  }
67
- if (typeof r == "object")
68
- switch (typeof r.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
- ), r.$$typeof) {
70
+ ), n.$$typeof) {
71
71
  case S:
72
72
  return "Portal";
73
73
  case f:
74
- return (r.displayName || "Context") + ".Provider";
74
+ return (n.displayName || "Context") + ".Provider";
75
75
  case k:
76
- return (r._context.displayName || "Context") + ".Consumer";
76
+ return (n._context.displayName || "Context") + ".Consumer";
77
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";
78
+ var u = n.render;
79
+ return n = n.displayName, n || (n = u.displayName || u.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
80
+ case $:
81
+ return u = n.displayName || null, u !== null ? u : l(n.type) || "Memo";
82
82
  case w:
83
- i = r._payload, r = r._init;
83
+ u = n._payload, n = n._init;
84
84
  try {
85
- return u(r(i));
85
+ return l(n(u));
86
86
  } catch {
87
87
  }
88
88
  }
89
89
  return null;
90
90
  }
91
- function e(r) {
92
- return "" + r;
91
+ function e(n) {
92
+ return "" + n;
93
93
  }
94
- function n(r) {
94
+ function r(n) {
95
95
  try {
96
- e(r);
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 h = i.error, v = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
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
104
  return h.call(
105
- i,
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
- v
108
- ), e(r);
107
+ x
108
+ ), e(n);
109
109
  }
110
110
  }
111
- function t(r) {
112
- if (r === A) return "<>";
113
- if (typeof r == "object" && r !== null && r.$$typeof === w)
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(r);
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 r = q.A;
124
- return r === null ? null : r.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(r) {
130
- if (Z.call(r, "key")) {
131
- var i = Object.getOwnPropertyDescriptor(r, "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 r.key !== void 0;
134
+ return n.key !== void 0;
135
135
  }
136
- function d(r, i) {
136
+ function d(n, u) {
137
137
  function h() {
138
- J || (J = !0, console.error(
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
- h.isReactWarning = !0, Object.defineProperty(r, "key", {
143
+ h.isReactWarning = !0, Object.defineProperty(n, "key", {
144
144
  get: h,
145
145
  configurable: !0
146
146
  });
147
147
  }
148
- function l() {
149
- var r = u(this.type);
150
- return G[r] || (G[r] = !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
- )), r = this.props.ref, r !== void 0 ? r : null;
152
+ )), n = this.props.ref, n !== void 0 ? n : null;
153
153
  }
154
- function c(r, i, h, v, E, T, I, L) {
155
- return h = T.ref, r = {
156
- $$typeof: x,
157
- type: r,
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: E
161
- }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(r, "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(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._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(r, "_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(r, "_debugStack", {
174
+ }), Object.defineProperty(n, "_debugStack", {
175
175
  configurable: !1,
176
176
  enumerable: !1,
177
177
  writable: !0,
178
- value: I
179
- }), Object.defineProperty(r, "_debugTask", {
178
+ value: q
179
+ }), Object.defineProperty(n, "_debugTask", {
180
180
  configurable: !1,
181
181
  enumerable: !1,
182
182
  writable: !0,
183
- value: L
184
- }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
183
+ value: G
184
+ }), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
185
185
  }
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);
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 p(y);
199
- if (Z.call(i, "key")) {
200
- y = u(r);
201
- var N = 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
- v = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", V[y + v] || (N = 0 < N.length ? "{" + N.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
- v,
212
- y,
213
- N,
214
- y
215
- ), V[y + v] = !0);
211
+ x,
212
+ R,
213
+ W,
214
+ R
215
+ ), M[R + x] = !0);
216
216
  }
217
- if (y = null, h !== void 0 && (n(h), y = "" + h), o(i) && (n(i.key), y = "" + i.key), "key" in i) {
217
+ if (R = null, h !== void 0 && (r(h), R = "" + h), o(u) && (r(u.key), R = "" + u.key), "key" in u) {
218
218
  h = {};
219
- for (var Q in i)
220
- Q !== "key" && (h[Q] = i[Q]);
221
- } else h = i;
222
- return y && d(
219
+ for (var K in u)
220
+ K !== "key" && (h[K] = u[K]);
221
+ } else h = u;
222
+ return R && d(
223
223
  h,
224
- typeof r == "function" ? r.displayName || r.name || "Unknown" : r
224
+ typeof n == "function" ? n.displayName || n.name || "Unknown" : n
225
225
  ), c(
226
- r,
227
- y,
226
+ n,
227
+ R,
228
228
  T,
229
- E,
229
+ z,
230
230
  s(),
231
231
  h,
232
- I,
233
- L
232
+ q,
233
+ G
234
234
  );
235
235
  }
236
- function p(r) {
237
- typeof r == "object" && r !== null && r.$$typeof === x && r._store && (r._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 _ = 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() {
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
242
  _ = {
243
- react_stack_bottom_frame: function(r) {
244
- return r();
243
+ react_stack_bottom_frame: function(n) {
244
+ return n();
245
245
  }
246
246
  };
247
- var J, G = {}, te = _.react_stack_bottom_frame.bind(
247
+ var g, E = {}, y = _.react_stack_bottom_frame.bind(
248
248
  _,
249
249
  a
250
- )(), g = D(t(a)), V = {};
251
- ee.Fragment = A, ee.jsx = function(r, i, h, v, E) {
252
- var T = 1e4 > q.recentlyCreatedOwnerStacks++;
250
+ )(), O = Q(t(a)), M = {};
251
+ te.Fragment = j, te.jsx = function(n, u, h, x, z) {
252
+ var T = 1e4 > U.recentlyCreatedOwnerStacks++;
253
253
  return m(
254
- r,
255
- i,
254
+ n,
255
+ u,
256
256
  h,
257
257
  !1,
258
- v,
259
- E,
260
- T ? Error("react-stack-top-frame") : te,
261
- T ? D(t(r)) : g
258
+ x,
259
+ z,
260
+ T ? Error("react-stack-top-frame") : y,
261
+ T ? Q(t(n)) : O
262
262
  );
263
- }, ee.jsxs = function(r, i, h, v, E) {
264
- var T = 1e4 > q.recentlyCreatedOwnerStacks++;
263
+ }, te.jsxs = function(n, u, h, x, z) {
264
+ var T = 1e4 > U.recentlyCreatedOwnerStacks++;
265
265
  return m(
266
- r,
267
- i,
266
+ n,
267
+ u,
268
268
  h,
269
269
  !0,
270
- v,
271
- E,
272
- T ? Error("react-stack-top-frame") : te,
273
- T ? D(t(r)) : g
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 Ee() {
280
- return ue || (ue = 1, process.env.NODE_ENV === "production" ? re.exports = xe() : re.exports = Te()), 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 = Ee();
283
- const j = {
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
- }, 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) => {
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
295
  t && d.cancelable && d.preventDefault();
296
- const l = "touches" in d ? d.touches[0] : d;
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
- t ? (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
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;
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
307
  B(() => {
308
- m.current && (l ? m.current.style.backgroundColor = "#4F4F4F" : m.current.style.backgroundColor = "#7F7F7F");
309
- }, [l]);
310
- const b = (f) => F(f / (e - _) * x, 0, x), R = (f) => {
311
- if (!A || "button" in f && f.button !== 0 || f.ctrlKey)
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
314
  const P = S;
315
315
  c(!0), ce(
316
316
  f,
317
- ({ deltaX: O, deltaY: M }) => {
318
- t?.(b(P + (s ? O : M)), S);
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
324
  }, k = (f) => {
325
- if (!A || "button" in f && f.button !== 0 || f.ctrlKey)
325
+ if (!j || "button" in f && f.button !== 0 || f.ctrlKey)
326
326
  return;
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);
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),
@@ -346,12 +346,12 @@ const j = {
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": x,
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",
@@ -361,21 +361,21 @@ const j = {
361
361
  // 当たり判定を上下または左右に広げる
362
362
  ...s ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
363
363
  },
364
- onMouseDown: R,
365
- onTouchStart: R,
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": x,
370
+ "aria-valuemax": p,
371
371
  tabIndex: 0,
372
- children: /* @__PURE__ */ z.jsx(
372
+ children: /* @__PURE__ */ D.jsx(
373
373
  "div",
374
374
  {
375
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 j = {
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,59 +406,59 @@ const j = {
406
406
  }
407
407
  )
408
408
  );
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) {
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 P = typeof R == "function" ? R(c.current) : R, O = F(P, 0, e - n);
420
- c.current !== O && (c.current = O, s?.(O, 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 (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);
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
430
  S(0);
431
- }, [x, S, e, n]), B(() => {
432
- const R = (f) => {
433
- if (!x)
431
+ }, [p, S, e, r]), B(() => {
432
+ const I = (f) => {
433
+ if (!p)
434
434
  return;
435
435
  f.preventDefault();
436
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);
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
438
  }, k = _.current;
439
- return k && k.addEventListener("wheel", R, { passive: !1 }), () => {
440
- k && k.removeEventListener("wheel", R);
439
+ return k && k.addEventListener("wheel", I, { passive: !1 }), () => {
440
+ k && k.removeEventListener("wheel", I);
441
441
  };
442
- }, [x, S, n]), he(
443
- l,
442
+ }, [p, S, r]), he(
443
+ i,
444
444
  () => ({
445
445
  scrollTo: S,
446
446
  getScrollPosition: () => c.current,
447
447
  getContentSize: () => e,
448
- getViewportSize: () => n
448
+ getViewportSize: () => r
449
449
  }),
450
- [S, e, n]
450
+ [S, e, r]
451
451
  );
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: [
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
- 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]);
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
- class Se {
461
+ class Re {
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 Se {
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, t) {
502
- this.reset(e, n, t);
501
+ constructor(e, r, t) {
502
+ this.reset(e, r, t);
503
503
  }
504
504
  /**
505
505
  * @method reset
@@ -509,26 +509,26 @@ class Se {
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, t) {
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) {
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
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
519
  if (this.baseValue = o, t?.materialize)
520
- for (let l = 0; l < d.length; l++) {
521
- const c = d[l], m = a.from + l;
520
+ for (let i = 0; i < d.length; i++) {
521
+ const c = d[i], m = a.from + i;
522
522
  if (m >= this.size)
523
523
  break;
524
- const p = c - this.baseValue;
525
- this.deltas.set(m, p), this._updateTree(m, p);
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,11 +548,11 @@ class Se {
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
554
  const t = [];
555
- for (let c = e; c <= n && !(c >= this.size); c++)
555
+ for (let c = e; c <= r && !(c >= this.size); c++)
556
556
  t.push(this.valueFn(c));
557
557
  const s = [...t];
558
558
  if (t.length === 0)
@@ -562,16 +562,16 @@ class Se {
562
562
  let o;
563
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;
565
+ let i = 0;
566
566
  for (const c of t) {
567
567
  const m = (d.get(c) ?? 0) + 1;
568
- d.set(c, m), m > l && (l = m);
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 [p, _] of d.entries())
573
- _ === l && c.push(p);
574
- const m = c.reduce((p, _) => p + _, 0);
572
+ for (const [v, _] of d.entries())
573
+ _ === i && c.push(v);
574
+ const m = c.reduce((v, _) => v + _, 0);
575
575
  o = Math.floor(m / c.length);
576
576
  }
577
577
  return { mode: o, materializedValues: s };
@@ -583,8 +583,8 @@ class Se {
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,7 +593,7 @@ class Se {
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: t, value: s }) => {
596
+ const r = e.map(({ index: t, value: s }) => {
597
597
  if (t < 0 || t >= this.size)
598
598
  throw new Error(`Index ${t} out of bounds`);
599
599
  if (s < 0)
@@ -601,7 +601,7 @@ class Se {
601
601
  const a = this.deltas.has(t) ? (this.deltas.get(t) ?? 0) + this.baseValue : this.baseValue, o = s - a;
602
602
  return { index: t, change: o };
603
603
  }).filter((t) => t.change !== 0);
604
- return n.length > 0 ? this.updateDeltas(n) : this.total;
604
+ return r.length > 0 ? this.updateDeltas(r) : this.total;
605
605
  }
606
606
  /**
607
607
  * @method updateDelta
@@ -610,8 +610,8 @@ class Se {
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 Se {
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: t } 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 + t), this._updateTree(n, t);
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 Se {
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
642
  let t = e + 1;
643
643
  for (; t <= this.size; )
644
- this.tree.set(t, (this.tree.get(t) ?? 0) + n), t += t & -t;
645
- this.total !== void 0 && (this.total += n);
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,10 +652,10 @@ class Se {
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
657
  const t = this.deltas.get(e) ?? 0, a = this.valueFn(e) - this.baseValue;
658
- if (a !== t && (this.deltas.set(e, a), n)) {
658
+ if (a !== t && (this.deltas.set(e, a), r)) {
659
659
  const o = a - t;
660
660
  this._updateTree(e, o);
661
661
  }
@@ -674,23 +674,23 @@ class Se {
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 t = F(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, m = Math.min(l.to, this.size - 1);
685
- for (let p = c; p <= m; p++)
686
- this._materialize(p);
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
688
  this._materialize(t);
689
689
  }
690
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
695
  const d = s?.materialize ? this.get(t) : (this.deltas.get(t) || 0) + this.baseValue;
696
696
  return { cumulative: a + this.baseValue * (t + 1), total: this.total, currentValue: d, safeIndex: t };
@@ -708,10 +708,10 @@ class Se {
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 t = n?.materializeOption;
714
+ const t = r?.materializeOption;
715
715
  if (t?.materialize && this.valueFn)
716
716
  if (t.ranges) {
717
717
  for (const s of t.ranges) {
@@ -737,9 +737,9 @@ class Se {
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 t of n.ranges) {
740
+ const r = e?.materializeOption;
741
+ if (r?.materialize && this.valueFn && r.ranges)
742
+ for (const t of r.ranges) {
743
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);
@@ -768,16 +768,16 @@ class Se {
768
768
  this.reset(this.size, (a) => s(a), { materialize: !0 });
769
769
  return;
770
770
  }
771
- const n = /* @__PURE__ */ new Map();
771
+ const r = /* @__PURE__ */ new Map();
772
772
  let t = this.baseValue * this.size;
773
773
  for (const [s, a] of this.deltas.entries()) {
774
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 = t;
780
+ this.tree = r, this.total = t;
781
781
  }
782
782
  /**
783
783
  * @method calculateAccumulatedError
@@ -789,8 +789,8 @@ class Se {
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,9 +800,9 @@ class Se {
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)
803
+ const r = this.size;
804
+ if (e !== r) {
805
+ if (e < r)
806
806
  for (const t of this.deltas.keys())
807
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");
@@ -830,13 +830,13 @@ class Se {
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
836
  let t = 0, s = this.size - 1, a = -1, o, d = this.total;
837
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;
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,157 +853,158 @@ class Se {
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
859
  let t = 0, s = this.size - 1, a = -1, o, d = this.total;
860
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;
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 ke = (u, e, n) => {
868
- const t = Math.max(0, u), s = $(null), a = ne(() => new Se(t, e, n), [t, 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 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);
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
873
  B(() => (S.current = !0, () => {
874
874
  S.current = !1;
875
875
  }), []);
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;
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
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);
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), w !== u && (b.changeSize(u), X(u));
885
+ b.setValueFn(r), w !== l && (b.changeSize(l), J(l));
886
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(
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
+ const H = L(
892
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);
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
899
  [b, s, w]
900
- ), q = Y(
900
+ ), U = L(
901
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);
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
- [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);
907
+ [b, H]
908
+ ), Z = L(
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: C, renderingEndIndex: D, visibleStartIndex: J, visibleEndIndex: G } = ne(() => {
915
+ ), F = ne(() => {
916
916
  if (w === 0)
917
917
  return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
918
- const { index: g, cumulative: V, currentValue: r } = b.findIndexAtOrAfter(k, { materializeOption: { materialize: !1 } });
919
- let i = 0;
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++;
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 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
- visibleEndIndex: T,
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
934
  scrollPosition: k,
935
935
  renderingContentSize: b.getTotal(),
936
936
  overscanCount: s,
937
937
  viewportSize: t
938
- }), { renderingStartIndex: v, renderingEndIndex: I, visibleStartIndex: h, visibleEndIndex: T };
939
- }, [k, s, t, n, b, w]);
938
+ }), { renderingStartIndex: n, renderingEndIndex: x, visibleStartIndex: M, visibleEndIndex: h };
939
+ }, [k, s, t, r, b, w]);
940
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,
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
947
  scrollPosition: k,
948
948
  contentSize: P,
949
949
  scrollPaneScrollPosition: g
950
- }), d?.(C, D, J, G, k, P);
951
- }, [C, D, J, G, d, k, P]);
952
- const te = Y(
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
953
  (g) => {
954
- if (j.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: g, renderingStartIndex: C, renderingEndIndex: D, fenwickSize: w, viewportSize: t }), w === 0)
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" }) });
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 });
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 });
960
961
  }
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));
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));
964
965
  });
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;
968
- return /* @__PURE__ */ z.jsx(
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(
969
970
  "div",
970
971
  {
971
- "data-index": N,
972
+ "data-index": R,
972
973
  style: {
973
974
  position: "absolute",
974
- top: ge - h,
975
+ top: me - u,
975
976
  width: "100%"
976
977
  },
977
- children: l(I, N)
978
+ children: i(T, R)
978
979
  },
979
- N
980
+ R
980
981
  );
981
982
  }) });
982
983
  },
983
- [e, l, P, t, C, D, b, w, n]
984
+ [e, i, P, t, F, b, w, r]
984
985
  );
985
986
  return he(
986
987
  _,
987
988
  () => ({
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),
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),
993
994
  getFenwickTreeTotalHeight: () => b.getTotal(),
994
995
  getFenwickSize: () => b.getSize()
995
996
  }),
996
- [U, b, q]
997
- ), /* @__PURE__ */ z.jsx(Ie, { ref: x, contentSize: P, viewportSize: t, className: a, onScroll: Z, background: c, children: te });
997
+ [H, b, U]
998
+ ), /* @__PURE__ */ D.jsx(Ie, { ref: p, contentSize: P, viewportSize: t, className: a, onScroll: Z, background: c, children: Q });
998
999
  }
999
- const Ae = de(Pe);
1000
- class we {
1000
+ const Fe = de(ke);
1001
+ class Pe {
1001
1002
  key;
1002
1003
  value;
1003
1004
  prev = null;
1004
1005
  next = null;
1005
- constructor(e, n) {
1006
- this.key = e, this.value = n;
1006
+ constructor(e, r) {
1007
+ this.key = e, this.value = r;
1007
1008
  }
1008
1009
  }
1009
1010
  class fe {
@@ -1047,54 +1048,54 @@ class fe {
1047
1048
  this.remove(e), this.addToTail(e);
1048
1049
  }
1049
1050
  }
1050
- function Ve(u) {
1051
- const e = $(/* @__PURE__ */ new Map()), n = $(new fe());
1051
+ function we(l) {
1052
+ const e = Y(/* @__PURE__ */ new Map()), r = Y(new fe());
1052
1053
  B(() => {
1053
- for (; e.current.size > u; ) {
1054
- const c = n.current.removeHead();
1054
+ for (; e.current.size > l; ) {
1055
+ const c = r.current.removeHead();
1055
1056
  if (c)
1056
1057
  e.current.delete(c.key);
1057
1058
  else
1058
1059
  break;
1059
1060
  }
1060
- }, [u]);
1061
- const t = Y((c) => {
1061
+ }, [l]);
1062
+ const t = L((c) => {
1062
1063
  const m = e.current.get(c);
1063
1064
  if (m)
1064
- return n.current.moveToTail(m), m.value;
1065
- }, []), s = Y(
1065
+ return r.current.moveToTail(m), m.value;
1066
+ }, []), s = L(
1066
1067
  (c, m) => {
1067
- if (u <= 0)
1068
+ if (l <= 0)
1068
1069
  return;
1069
- let p = e.current.get(c);
1070
- if (p)
1071
- p.value = m, n.current.moveToTail(p);
1070
+ let v = e.current.get(c);
1071
+ if (v)
1072
+ v.value = m, r.current.moveToTail(v);
1072
1073
  else {
1073
- if (e.current.size >= u) {
1074
- const _ = n.current.removeHead();
1074
+ if (e.current.size >= l) {
1075
+ const _ = r.current.removeHead();
1075
1076
  _ && e.current.delete(_.key);
1076
1077
  }
1077
- p = new we(c, m), e.current.set(c, p), n.current.addToTail(p);
1078
+ v = new Pe(c, m), e.current.set(c, v), r.current.addToTail(v);
1078
1079
  }
1079
1080
  },
1080
- [u]
1081
- ), a = Y((c) => e.current.has(c), []), o = Y(() => {
1082
- e.current.clear(), n.current = new fe();
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;
1081
+ [l]
1082
+ ), a = L((c) => e.current.has(c), []), o = L(() => {
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;
1085
1086
  }
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 };
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 };
1089
1090
  };
1090
1091
  export {
1091
- Se as FenwickMapTree,
1092
- Re as ScrollBar,
1092
+ Re as FenwickMapTree,
1093
+ _e as ScrollBar,
1093
1094
  Ie as ScrollPane,
1094
- Ae as VirtualScroll,
1095
- F as minmax,
1096
- ke as useFenwickMapTree,
1097
- je as useHeightCache,
1098
- Ve as useLruCache
1095
+ Fe as VirtualScroll,
1096
+ A as minmax,
1097
+ Se as useFenwickMapTree,
1098
+ Ae as useHeightCache,
1099
+ we as useLruCache
1099
1100
  };
1100
1101
  //# sourceMappingURL=index.js.map