@aiquants/virtualscroll 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,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";
2
- import { twMerge as ae } from "tailwind-merge";
3
- var re = { exports: {} }, K = {};
1
+ import He, { forwardRef as Re, useState as le, useRef as H, useCallback as $, useImperativeHandle as Ae, useMemo as U, useEffect as ae, useReducer as $e, useLayoutEffect as be, useId as Ue } from "react";
2
+ import { twMerge as pe } from "tailwind-merge";
3
+ var Te = { exports: {} }, fe = {};
4
4
  /**
5
5
  * @license React
6
6
  * react-jsx-runtime.production.js
@@ -10,29 +10,29 @@ var re = { exports: {} }, K = {};
10
10
  * This source code is licensed under the MIT license found in the
11
11
  * LICENSE file in the root directory of this source tree.
12
12
  */
13
- var ie;
14
- function xe() {
15
- if (ie) return K;
16
- ie = 1;
17
- var u = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
18
- function n(t, s, a) {
19
- var o = null;
20
- if (a !== void 0 && (o = "" + a), s.key !== void 0 && (o = "" + s.key), "key" in s) {
13
+ var Ve;
14
+ function qe() {
15
+ if (Ve) return fe;
16
+ Ve = 1;
17
+ var c = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
18
+ function n(r, s, a) {
19
+ var i = null;
20
+ if (a !== void 0 && (i = "" + a), s.key !== void 0 && (i = "" + s.key), "key" in s) {
21
21
  a = {};
22
- for (var d in s)
23
- d !== "key" && (a[d] = s[d]);
22
+ for (var f in s)
23
+ f !== "key" && (a[f] = s[f]);
24
24
  } else a = s;
25
25
  return s = a.ref, {
26
- $$typeof: u,
27
- type: t,
28
- key: o,
26
+ $$typeof: c,
27
+ type: r,
28
+ key: i,
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 fe.Fragment = e, fe.jsx = n, fe.jsxs = n, fe;
34
34
  }
35
- var ee = {};
35
+ var me = {};
36
36
  /**
37
37
  * @license React
38
38
  * react-jsx-runtime.development.js
@@ -42,423 +42,874 @@ var ee = {};
42
42
  * This source code is licensed under the MIT license found in the
43
43
  * LICENSE file in the root directory of this source tree.
44
44
  */
45
- var le;
46
- function Te() {
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:
45
+ var ke;
46
+ function Xe() {
47
+ return ke || (ke = 1, process.env.NODE_ENV !== "production" && (function() {
48
+ function c(t) {
49
+ if (t == null) return null;
50
+ if (typeof t == "function")
51
+ return t.$$typeof === l ? null : t.displayName || t.name || null;
52
+ if (typeof t == "string") return t;
53
+ switch (t) {
54
+ case N:
55
55
  return "Fragment";
56
- case R:
56
+ case F:
57
57
  return "Profiler";
58
- case b:
58
+ case K:
59
59
  return "StrictMode";
60
- case O:
60
+ case k:
61
61
  return "Suspense";
62
- case M:
62
+ case C:
63
63
  return "SuspenseList";
64
- case X:
64
+ case se:
65
65
  return "Activity";
66
66
  }
67
- if (typeof r == "object")
68
- switch (typeof r.tag == "number" && console.error(
67
+ if (typeof t == "object")
68
+ switch (typeof t.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) {
71
- case S:
70
+ ), t.$$typeof) {
71
+ case ie:
72
72
  return "Portal";
73
- case f:
74
- return (r.displayName || "Context") + ".Provider";
75
- case k:
76
- return (r._context.displayName || "Context") + ".Consumer";
77
- case P:
78
- var i = r.render;
79
- return r = r.displayName, r || (r = i.displayName || i.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
80
- case H:
81
- return i = r.displayName || null, i !== null ? i : u(r.type) || "Memo";
82
- case w:
83
- i = r._payload, r = r._init;
73
+ case Z:
74
+ return (t.displayName || "Context") + ".Provider";
75
+ case m:
76
+ return (t._context.displayName || "Context") + ".Consumer";
77
+ case A:
78
+ var o = t.render;
79
+ return t = t.displayName, t || (t = o.displayName || o.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
80
+ case B:
81
+ return o = t.displayName || null, o !== null ? o : c(t.type) || "Memo";
82
+ case X:
83
+ o = t._payload, t = t._init;
84
84
  try {
85
- return u(r(i));
85
+ return c(t(o));
86
86
  } catch {
87
87
  }
88
88
  }
89
89
  return null;
90
90
  }
91
- function e(r) {
92
- return "" + r;
91
+ function e(t) {
92
+ return "" + t;
93
93
  }
94
- function n(r) {
94
+ function n(t) {
95
95
  try {
96
- e(r);
97
- var i = !1;
96
+ e(t);
97
+ var o = !1;
98
98
  } catch {
99
- i = !0;
99
+ o = !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";
104
- return h.call(
105
- i,
101
+ if (o) {
102
+ o = console;
103
+ var T = o.error, y = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
104
+ return T.call(
105
+ o,
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
+ y
108
+ ), e(t);
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 r(t) {
112
+ if (t === N) return "<>";
113
+ if (typeof t == "object" && t !== null && t.$$typeof === X)
114
114
  return "<...>";
115
115
  try {
116
- var i = u(r);
117
- return i ? "<" + i + ">" : "<...>";
116
+ var o = c(t);
117
+ return o ? "<" + o + ">" : "<...>";
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 t = Y.A;
124
+ return t === null ? null : t.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 i(t) {
130
+ if (j.call(t, "key")) {
131
+ var o = Object.getOwnPropertyDescriptor(t, "key").get;
132
+ if (o && o.isReactWarning) return !1;
133
133
  }
134
- return r.key !== void 0;
134
+ return t.key !== void 0;
135
135
  }
136
- function d(r, i) {
137
- function h() {
138
- J || (J = !0, console.error(
136
+ function f(t, o) {
137
+ function T() {
138
+ E || (E = !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
+ o
141
141
  ));
142
142
  }
143
- h.isReactWarning = !0, Object.defineProperty(r, "key", {
144
- get: h,
143
+ T.isReactWarning = !0, Object.defineProperty(t, "key", {
144
+ get: T,
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 p() {
149
+ var t = c(this.type);
150
+ return M[t] || (M[t] = !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
+ )), t = this.props.ref, t !== void 0 ? t : 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,
159
- props: T,
160
- _owner: E
161
- }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(r, "ref", {
154
+ function g(t, o, T, y, w, V, D, _) {
155
+ return T = V.ref, t = {
156
+ $$typeof: ne,
157
+ type: t,
158
+ key: o,
159
+ props: V,
160
+ _owner: w
161
+ }, (T !== void 0 ? T : null) !== null ? Object.defineProperty(t, "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: p
164
+ }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._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(t, "_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(t, "_debugStack", {
175
175
  configurable: !1,
176
176
  enumerable: !1,
177
177
  writable: !0,
178
- value: I
179
- }), Object.defineProperty(r, "_debugTask", {
178
+ value: D
179
+ }), Object.defineProperty(t, "_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: _
184
+ }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
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 x(t, o, T, y, w, V, D, _) {
187
+ var R = o.children;
188
+ if (R !== void 0)
189
+ if (y)
190
+ if (L(R)) {
191
+ for (y = 0; y < R.length; y++)
192
+ P(R[y]);
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) {
202
- return se !== "key";
198
+ else P(R);
199
+ if (j.call(o, "key")) {
200
+ R = c(t);
201
+ var G = Object.keys(o).filter(function(u) {
202
+ return u !== "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
+ y = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", I[R + y] || (G = 0 < G.length ? "{" + G.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
211
  y,
213
- N,
214
- y
215
- ), V[y + v] = !0);
212
+ R,
213
+ G,
214
+ R
215
+ ), I[R + y] = !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) {
218
- h = {};
219
- for (var Q in i)
220
- Q !== "key" && (h[Q] = i[Q]);
221
- } else h = i;
222
- return y && d(
223
- h,
224
- typeof r == "function" ? r.displayName || r.name || "Unknown" : r
225
- ), c(
226
- r,
227
- y,
217
+ if (R = null, T !== void 0 && (n(T), R = "" + T), i(o) && (n(o.key), R = "" + o.key), "key" in o) {
218
+ T = {};
219
+ for (var J in o)
220
+ J !== "key" && (T[J] = o[J]);
221
+ } else T = o;
222
+ return R && f(
228
223
  T,
229
- E,
224
+ typeof t == "function" ? t.displayName || t.name || "Unknown" : t
225
+ ), g(
226
+ t,
227
+ R,
228
+ V,
229
+ w,
230
230
  s(),
231
- h,
232
- I,
233
- L
231
+ T,
232
+ D,
233
+ _
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 P(t) {
237
+ typeof t == "object" && t !== null && t.$$typeof === ne && t._store && (t._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 S = He, ne = Symbol.for("react.transitional.element"), ie = Symbol.for("react.portal"), N = Symbol.for("react.fragment"), K = Symbol.for("react.strict_mode"), F = Symbol.for("react.profiler"), m = Symbol.for("react.consumer"), Z = Symbol.for("react.context"), A = Symbol.for("react.forward_ref"), k = Symbol.for("react.suspense"), C = Symbol.for("react.suspense_list"), B = Symbol.for("react.memo"), X = Symbol.for("react.lazy"), se = Symbol.for("react.activity"), l = Symbol.for("react.client.reference"), Y = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, L = Array.isArray, b = console.createTask ? console.createTask : function() {
240
240
  return null;
241
241
  };
242
- _ = {
243
- react_stack_bottom_frame: function(r) {
244
- return r();
242
+ S = {
243
+ react_stack_bottom_frame: function(t) {
244
+ return t();
245
245
  }
246
246
  };
247
- var J, G = {}, te = _.react_stack_bottom_frame.bind(
248
- _,
247
+ var E, M = {}, h = S.react_stack_bottom_frame.bind(
248
+ S,
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++;
253
- return m(
254
- r,
255
- i,
256
- h,
250
+ )(), v = b(r(a)), I = {};
251
+ me.Fragment = N, me.jsx = function(t, o, T, y, w) {
252
+ var V = 1e4 > Y.recentlyCreatedOwnerStacks++;
253
+ return x(
254
+ t,
255
+ o,
256
+ T,
257
257
  !1,
258
- v,
259
- E,
260
- T ? Error("react-stack-top-frame") : te,
261
- T ? D(t(r)) : g
258
+ y,
259
+ w,
260
+ V ? Error("react-stack-top-frame") : h,
261
+ V ? b(r(t)) : v
262
262
  );
263
- }, ee.jsxs = function(r, i, h, v, E) {
264
- var T = 1e4 > q.recentlyCreatedOwnerStacks++;
265
- return m(
266
- r,
267
- i,
268
- h,
263
+ }, me.jsxs = function(t, o, T, y, w) {
264
+ var V = 1e4 > Y.recentlyCreatedOwnerStacks++;
265
+ return x(
266
+ t,
267
+ o,
268
+ T,
269
269
  !0,
270
- v,
271
- E,
272
- T ? Error("react-stack-top-frame") : te,
273
- T ? D(t(r)) : g
270
+ y,
271
+ w,
272
+ V ? Error("react-stack-top-frame") : h,
273
+ V ? b(r(t)) : v
274
274
  );
275
275
  };
276
- })()), ee;
276
+ })()), me;
277
277
  }
278
- var ue;
279
- function Ee() {
280
- return ue || (ue = 1, process.env.NODE_ENV === "production" ? re.exports = xe() : re.exports = Te()), re.exports;
278
+ var Le;
279
+ function We() {
280
+ return Le || (Le = 1, process.env.NODE_ENV === "production" ? Te.exports = qe() : Te.exports = Xe()), Te.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 q = We();
283
+ const re = {
284
+ debug(c, ...e) {
285
+ typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${c}`, ...e);
286
286
  },
287
- warn(u, ...e) {
288
- console.warn(`[VirtualScroll] ${u}`, ...e);
287
+ warn(c, ...e) {
288
+ console.warn(`[VirtualScroll] ${c}`, ...e);
289
289
  },
290
- error(u, ...e) {
291
- console.error(`[VirtualScroll] ${u}`, ...e);
290
+ error(c, ...e) {
291
+ console.error(`[VirtualScroll] ${c}`, ...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) => {
295
- t && d.cancelable && d.preventDefault();
296
- const l = "touches" in d ? d.touches[0] : d;
293
+ }, z = (c, e, n) => Math.min(n, Math.max(e, c)), Ie = {
294
+ active: !1,
295
+ offsetY: 0,
296
+ distance: 0,
297
+ direction: 0
298
+ }, Oe = 6, je = Re(({ onDragChange: c, className: e, maxVisualDistance: n = 160, size: r = 64, style: s, opacity: a = 1 }, i) => {
299
+ const [f, p] = le(Ie), g = H(null), x = H({ x: 0, y: 0 }), P = H(null), S = $(
300
+ (b, E = !1) => {
301
+ const { y: M } = x.current, h = b - M, v = Math.abs(h), I = v < Oe ? 0 : h < 0 ? -1 : 1, t = {
302
+ active: E || v >= Oe,
303
+ offsetY: h,
304
+ distance: v,
305
+ direction: I
306
+ };
307
+ p(t), c(t);
308
+ },
309
+ [c]
310
+ ), ne = $(
311
+ (b = !1) => {
312
+ if (b && g.current !== null) {
313
+ const E = P.current;
314
+ E?.hasPointerCapture(g.current) && E.releasePointerCapture(g.current);
315
+ }
316
+ g.current = null, p(Ie), c(Ie);
317
+ },
318
+ [c]
319
+ ), ie = $(
320
+ (b) => {
321
+ b.preventDefault(), b.stopPropagation();
322
+ const E = P.current ?? b.currentTarget, M = E.getBoundingClientRect();
323
+ x.current = {
324
+ x: M.left + M.width / 2,
325
+ y: M.top + M.height / 2
326
+ }, g.current = b.pointerId, E.setPointerCapture(b.pointerId), S(b.clientY, !0);
327
+ },
328
+ [S]
329
+ ), N = $(
330
+ (b) => {
331
+ g.current === b.pointerId && (b.preventDefault(), S(b.clientY));
332
+ },
333
+ [S]
334
+ ), K = $(
335
+ (b) => {
336
+ g.current === b.pointerId && (b.preventDefault(), b.stopPropagation(), ne(!0));
337
+ },
338
+ [ne]
339
+ );
340
+ Ae(
341
+ i,
342
+ () => ({
343
+ reset: () => {
344
+ ne(!0);
345
+ },
346
+ getElement: () => P.current
347
+ }),
348
+ [ne]
349
+ );
350
+ const F = U(() => Math.min(f.distance, n) / n, [f.distance, n]), m = U(() => r / 64, [r]), Z = U(() => 1 + F * 0.4, [F]), A = U(() => f.direction * F * 10 * m, [f.direction, F, m]), k = U(() => f.direction * F * 26 * m, [f.direction, F, m]), C = U(() => 22 * m, [m]), B = U(() => Math.max(2.5, 3 * m), [m]), X = U(() => 6 * m, [m]), se = U(() => 3 * m, [m]), l = U(() => Math.min(Math.max(a, 0), 1), [a]), Y = U(() => {
351
+ const b = {
352
+ ...s,
353
+ width: r,
354
+ height: r,
355
+ transform: `translateY(${A}px)`
356
+ };
357
+ return b.opacity = l, b;
358
+ }, [l, A, r, s]), j = U(() => Math.abs(k) + X, [X, k]), L = U(() => k > 0 ? se : -Math.abs(k) - se, [se, k]);
359
+ return /* @__PURE__ */ q.jsxs(
360
+ "div",
361
+ {
362
+ ref: P,
363
+ className: pe(
364
+ "relative flex items-center justify-center touch-none select-none",
365
+ "transition-transform duration-100 ease-out",
366
+ e
367
+ ),
368
+ style: Y,
369
+ onPointerDown: ie,
370
+ onPointerMove: N,
371
+ onPointerUp: K,
372
+ onPointerCancel: K,
373
+ role: "presentation",
374
+ children: [
375
+ /* @__PURE__ */ q.jsx(
376
+ "div",
377
+ {
378
+ className: "absolute inset-0 rounded-full border border-white/40 bg-gradient-to-br from-[#1d4ed8]/60 via-[#60a5fa]/55 to-[#bfdbfe]/40 shadow-md",
379
+ style: {
380
+ transform: `scaleY(${Z})`,
381
+ transition: f.active ? "transform 40ms ease-out" : "transform 200ms ease"
382
+ }
383
+ }
384
+ ),
385
+ /* @__PURE__ */ q.jsx(
386
+ "div",
387
+ {
388
+ className: "absolute left-1/2 top-1/2 h-6 w-6 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white/50 bg-white/85",
389
+ style: {
390
+ width: C,
391
+ height: C,
392
+ transform: `translate(-50%, calc(-50% + ${k * 0.3}px)) scale(${1 + F * 0.2})`,
393
+ transition: f.active ? "transform 40ms ease-out" : "transform 200ms ease"
394
+ }
395
+ }
396
+ ),
397
+ /* @__PURE__ */ q.jsx(
398
+ "div",
399
+ {
400
+ className: "absolute left-1/2 top-1/2 w-1 rounded-full bg-white/50",
401
+ style: {
402
+ width: B,
403
+ height: j,
404
+ transform: `translate(-50%, ${L}px)`,
405
+ opacity: F,
406
+ transition: f.active ? "height 40ms ease-out, opacity 60ms" : "height 200ms ease, opacity 120ms"
407
+ }
408
+ }
409
+ )
410
+ ]
411
+ }
412
+ );
413
+ });
414
+ je.displayName = "TapScrollCircle";
415
+ const De = (c, e, n) => {
416
+ const r = "touches" in c.nativeEvent, s = r ? c.nativeEvent.touches[0] : c.nativeEvent, a = (f) => {
417
+ r && f.cancelable && f.preventDefault();
418
+ const p = "touches" in f ? f.touches[0] : f;
297
419
  e({
298
- deltaX: l.clientX - s.clientX,
299
- deltaY: l.clientY - s.clientY
420
+ deltaX: p.clientX - s.clientX,
421
+ deltaY: p.clientY - s.clientY
300
422
  });
301
- }, o = () => {
302
- t ? (document.removeEventListener("touchmove", a), document.removeEventListener("touchend", o)) : (document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", o)), n?.();
423
+ }, i = () => {
424
+ r ? (document.removeEventListener("touchmove", a), document.removeEventListener("touchend", i)) : (document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", i)), n?.();
303
425
  };
304
- t ? (document.addEventListener("touchmove", a, { passive: !1 }), document.addEventListener("touchend", o)) : (document.addEventListener("mousemove", a), document.addEventListener("mouseup", o));
305
- }, _e = 20, Re = ({ contentSize: u, viewportSize: e, scrollPosition: n, onScroll: t, horizontal: s = !1, scrollBarWidth: a = 12, className: o, ariaControls: d }) => {
306
- const [l, c] = W(!1), m = $(null), p = e / u, _ = Math.max(_e, p * e), x = u - e, S = n / x * (e - _), A = u > e;
307
- B(() => {
308
- m.current && (l ? m.current.style.backgroundColor = "#4F4F4F" : m.current.style.backgroundColor = "#7F7F7F");
309
- }, [l]);
310
- const b = (f) => F(f / (e - _) * x, 0, x), R = (f) => {
311
- if (!A || "button" in f && f.button !== 0 || f.ctrlKey)
426
+ r ? (document.addEventListener("touchmove", a, { passive: !1 }), document.addEventListener("touchend", i)) : (document.addEventListener("mousemove", a), document.addEventListener("mouseup", i));
427
+ }, Pe = "virtualscroll:tap-scroll-cancel", Fe = 20, Ge = 250, Je = 60, Be = 20, Ke = 20, Ze = 220, Ne = { active: !1, offsetY: 0, distance: 0, direction: 0 }, _e = 2.2, Qe = 8, et = 120, ce = {
428
+ enabled: !0,
429
+ size: 64,
430
+ offsetX: -80,
431
+ offsetY: 0,
432
+ className: void 0,
433
+ maxVisualDistance: Ze,
434
+ opacity: 1
435
+ }, tt = (c) => {
436
+ if (!c || c <= 0)
437
+ return _e;
438
+ const e = Math.max(1, c), n = Math.log10(e), r = _e + n * Qe;
439
+ return z(r, _e, et);
440
+ }, rt = ({ contentSize: c, viewportSize: e, scrollPosition: n, onScroll: r, horizontal: s = !1, scrollBarWidth: a = 12, className: i, ariaControls: f, tapScrollCircleOptions: p, itemCount: g }) => {
441
+ const [x, P] = le(!1), [S, ne] = le(!1), ie = H(null), N = H(n), K = H(null), F = H(null), m = H(Ne), Z = H(null), A = H(null), k = H(null), C = U(() => {
442
+ const d = p?.maxSpeedMultiplier, O = typeof d == "number" ? d : tt(g);
443
+ return {
444
+ enabled: p?.enabled ?? ce.enabled,
445
+ size: p?.size ?? ce.size,
446
+ offsetX: p?.offsetX ?? ce.offsetX,
447
+ offsetY: p?.offsetY ?? ce.offsetY,
448
+ className: p?.className ?? ce.className,
449
+ maxVisualDistance: p?.maxVisualDistance ?? ce.maxVisualDistance,
450
+ maxSpeedMultiplier: O,
451
+ opacity: z(p?.opacity ?? ce.opacity, 0, 1)
452
+ };
453
+ }, [g, p]), {
454
+ enabled: B,
455
+ size: X,
456
+ offsetX: se,
457
+ offsetY: l,
458
+ className: Y,
459
+ maxVisualDistance: j,
460
+ maxSpeedMultiplier: L,
461
+ opacity: b
462
+ } = C, E = Math.max(j, 1), M = e / c, h = a, v = Math.max(e - h * 2, 0), I = M * v, t = Math.min(Math.max(Fe, I || 0), v || Fe), o = c - e, T = Math.max(v - t, 0), y = o <= 0 || T <= 0 ? 0 : n / o * T, w = c > e;
463
+ ae(() => {
464
+ N.current = n;
465
+ }, [n]), ae(() => {
466
+ ie.current && (x ? ie.current.style.backgroundColor = "#4F4F4F" : ie.current.style.backgroundColor = "#7F7F7F");
467
+ }, [x]);
468
+ const V = $(() => {
469
+ K.current !== null && (window.clearInterval(K.current), K.current = null), F.current !== null && (window.clearTimeout(F.current), F.current = null);
470
+ }, []), D = $(() => {
471
+ A.current !== null && (window.cancelAnimationFrame(A.current), A.current = null), k.current = null;
472
+ }, []), _ = $(() => {
473
+ m.current = { ...Ne }, ne(!1), Z.current?.reset(), D();
474
+ }, [D]), R = $(
475
+ (d) => {
476
+ const O = m.current;
477
+ if (!O.active || O.direction === 0) {
478
+ D();
479
+ return;
480
+ }
481
+ if (!w || o <= 0) {
482
+ D();
483
+ return;
484
+ }
485
+ const te = k.current ?? d, Q = Math.max((d - te) / 1e3, 0);
486
+ if (k.current = d, Q <= 0) {
487
+ A.current = window.requestAnimationFrame(R);
488
+ return;
489
+ }
490
+ const Ee = (Math.min(O.distance, E) / E) ** 1.1, de = Math.max(e * 0.2, 40), we = Math.max(e * L, 1200), Se = de + (we - de) * Ee, xe = N.current, ye = z(xe + O.direction * Se * Q, 0, o);
491
+ if (ye === xe) {
492
+ D();
493
+ return;
494
+ }
495
+ N.current = ye, r?.(ye, xe), A.current = window.requestAnimationFrame(R);
496
+ },
497
+ [E, o, r, w, D, L, e]
498
+ ), G = $(() => {
499
+ A.current === null && (k.current = null, A.current = window.requestAnimationFrame(R));
500
+ }, [R]);
501
+ ae(() => () => {
502
+ V(), D();
503
+ }, [V, D]);
504
+ const J = $(
505
+ (d) => {
506
+ m.current = d, ne(d.active), d.active && d.direction !== 0 ? G() : D();
507
+ },
508
+ [G, D]
509
+ );
510
+ ae(() => {
511
+ B || _();
512
+ }, [_, B]), ae(() => {
513
+ const d = (O) => {
514
+ const Q = O.detail?.paneId;
515
+ Q && f && Q !== f || _();
516
+ };
517
+ return window.addEventListener(Pe, d), () => {
518
+ window.removeEventListener(Pe, d);
519
+ };
520
+ }, [f, _]), ae(() => {
521
+ if (!B)
312
522
  return;
313
- f.stopPropagation();
314
- const P = S;
315
- c(!0), ce(
316
- f,
317
- ({ deltaX: O, deltaY: M }) => {
318
- t?.(b(P + (s ? O : M)), S);
523
+ const d = (O) => {
524
+ if (!m.current.active)
525
+ return;
526
+ const te = O.target;
527
+ if (!(te instanceof Node)) {
528
+ _();
529
+ return;
530
+ }
531
+ Z.current?.getElement()?.contains(te) || _();
532
+ };
533
+ return document.addEventListener("pointerdown", d, !0), () => {
534
+ document.removeEventListener("pointerdown", d, !0);
535
+ };
536
+ }, [_, B]);
537
+ const u = (d) => {
538
+ if (!w || T <= 0 || o <= 0)
539
+ return 0;
540
+ const O = z(d, 0, T);
541
+ return z(O / T * o, 0, o);
542
+ }, ee = (d) => {
543
+ if (!w || o <= 0)
544
+ return;
545
+ const O = Math.max(Math.round(e / Ke), Be), te = N.current, Q = z(te + d * O, 0, o);
546
+ Q !== te && (N.current = Q, r?.(Q, te));
547
+ }, W = () => {
548
+ V();
549
+ }, oe = (d) => (O) => {
550
+ w && (O.preventDefault(), O.stopPropagation(), _(), V(), ee(d), F.current = window.setTimeout(() => {
551
+ K.current = window.setInterval(() => {
552
+ ee(d);
553
+ }, Je);
554
+ }, Ge));
555
+ }, ue = (d) => (O) => {
556
+ (O.key === "Enter" || O.key === " " || O.key === "Spacebar") && (O.preventDefault(), ee(d));
557
+ }, ge = (d) => {
558
+ if (!w || "button" in d && d.button !== 0 || d.ctrlKey)
559
+ return;
560
+ d.stopPropagation(), _();
561
+ const O = y;
562
+ P(!0), De(
563
+ d,
564
+ ({ deltaX: te, deltaY: Q }) => {
565
+ r?.(u(O + (s ? te : Q)), y);
319
566
  },
320
567
  () => {
321
- c(!1);
568
+ P(!1);
322
569
  }
323
570
  );
324
- }, k = (f) => {
325
- if (!A || "button" in f && f.button !== 0 || f.ctrlKey)
571
+ }, Me = (d) => {
572
+ if (!w || "button" in d && d.button !== 0 || d.ctrlKey)
326
573
  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);
574
+ const te = "touches" in d.nativeEvent ? d.nativeEvent.touches[0] : d.nativeEvent, Q = s ? te.clientX : te.clientY, ve = d.currentTarget.getBoundingClientRect(), Ee = s ? Q - ve.left : Q - ve.top;
575
+ _();
576
+ const de = Ee - t / 2;
577
+ r?.(u(de), y), De(d, ({ deltaX: we, deltaY: Se }) => {
578
+ r?.(u(de + (s ? we : Se)), y);
330
579
  });
331
- };
332
- return (
333
- // スクロールバーのコンテナ
334
- /* @__PURE__ */ z.jsx(
335
- "div",
336
- {
337
- className: ae("group relative cursor-default select-none", o),
338
- style: {
339
- [s ? "width" : "height"]: e,
340
- [s ? "height" : "width"]: a,
341
- backgroundColor: "white",
342
- userSelect: "none"
343
- },
344
- onMouseDown: k,
345
- onTouchStart: k,
346
- role: "scrollbar",
347
- tabIndex: -1,
348
- "aria-controls": d,
349
- "aria-valuenow": n,
350
- "aria-valuemin": 0,
351
- "aria-valuemax": x,
352
- "aria-orientation": s ? "horizontal" : "vertical",
353
- children: u > e && // スクロールバーのつまみの当たり判定を広げるためのラッパー
354
- /* @__PURE__ */ z.jsx(
580
+ }, Ye = U(() => z((S ? 1 : 0.8) * b, 0, 1), [S, b]), ze = U(() => {
581
+ const O = `calc(50% - ${X / 2}px + ${l}px)`;
582
+ return {
583
+ left: se,
584
+ top: O
585
+ };
586
+ }, [se, l, X]);
587
+ return /* @__PURE__ */ q.jsxs(
588
+ "div",
589
+ {
590
+ className: pe(
591
+ "group relative cursor-default select-none",
592
+ s ? "flex flex-row items-stretch" : "flex flex-col items-stretch",
593
+ i
594
+ ),
595
+ style: {
596
+ [s ? "width" : "height"]: e,
597
+ [s ? "height" : "width"]: a,
598
+ backgroundColor: "white",
599
+ userSelect: "none",
600
+ position: "relative"
601
+ },
602
+ role: "scrollbar",
603
+ tabIndex: -1,
604
+ "aria-controls": f,
605
+ "aria-valuenow": n,
606
+ "aria-valuemin": 0,
607
+ "aria-valuemax": o,
608
+ "aria-orientation": s ? "horizontal" : "vertical",
609
+ children: [
610
+ !s && w && B && /* @__PURE__ */ q.jsx(
611
+ je,
612
+ {
613
+ ref: Z,
614
+ className: pe(
615
+ "pointer-events-auto absolute transition-opacity duration-150",
616
+ Y
617
+ ),
618
+ size: X,
619
+ maxVisualDistance: E,
620
+ style: ze,
621
+ opacity: Ye,
622
+ onDragChange: J
623
+ }
624
+ ),
625
+ /* @__PURE__ */ q.jsx(
626
+ "button",
627
+ {
628
+ type: "button",
629
+ className: "flex items-center justify-center text-xs text-[#313131] transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[#60a5fa] focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
630
+ style: {
631
+ [s ? "width" : "height"]: h,
632
+ [s ? "height" : "width"]: a,
633
+ backgroundColor: "#E0E0E0"
634
+ },
635
+ "aria-label": s ? "Scroll left" : "Scroll up",
636
+ onMouseDown: oe(-1),
637
+ onTouchStart: oe(-1),
638
+ onMouseUp: W,
639
+ onMouseLeave: W,
640
+ onTouchEnd: W,
641
+ onTouchCancel: W,
642
+ onKeyDown: ue(-1),
643
+ disabled: !w,
644
+ children: /* @__PURE__ */ q.jsx("span", { "aria-hidden": "true", children: s ? "◀" : "▲" })
645
+ }
646
+ ),
647
+ /* @__PURE__ */ q.jsx(
355
648
  "div",
356
649
  {
357
- className: "group absolute",
650
+ className: "relative flex-1",
358
651
  style: {
359
- [s ? "width" : "height"]: _,
360
- [s ? "left" : "top"]: S,
361
- // 当たり判定を上下または左右に広げる
362
- ...s ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
652
+ backgroundColor: "#F5F5F5",
653
+ borderRadius: a / 2
363
654
  },
364
- onMouseDown: R,
365
- onTouchStart: R,
366
- role: "slider",
367
- "aria-orientation": s ? "horizontal" : "vertical",
368
- "aria-valuenow": n,
369
- "aria-valuemin": 0,
370
- "aria-valuemax": x,
371
- tabIndex: 0,
372
- children: /* @__PURE__ */ z.jsx(
655
+ onMouseDown: Me,
656
+ onTouchStart: Me,
657
+ children: c > e && // スクロールバーのつまみの当たり判定を広げるためのラッパー
658
+ /* @__PURE__ */ q.jsx(
373
659
  "div",
374
660
  {
375
- ref: m,
376
- className: ae(
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]"}`
379
- ),
661
+ className: "group absolute",
380
662
  style: {
381
- backgroundColor: "#7F7F7F",
382
- borderRadius: a - 1,
383
- // Tailwind が適用されない場合のフォールバック
384
- ...s ? {
385
- left: 0,
386
- right: 0,
387
- top: l ? -2 : 1.5,
388
- bottom: l ? -2 : 1.5
389
- } : {
390
- top: 0,
391
- bottom: 0,
392
- left: l ? -2 : 1.5,
393
- right: l ? -2 : 1.5
394
- }
395
- },
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");
663
+ [s ? "width" : "height"]: t,
664
+ [s ? "left" : "top"]: y,
665
+ ...s ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
398
666
  },
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");
401
- }
667
+ onMouseDown: ge,
668
+ onTouchStart: ge,
669
+ role: "slider",
670
+ "aria-orientation": s ? "horizontal" : "vertical",
671
+ "aria-valuenow": n,
672
+ "aria-valuemin": 0,
673
+ "aria-valuemax": o,
674
+ tabIndex: 0,
675
+ children: /* @__PURE__ */ q.jsx(
676
+ "div",
677
+ {
678
+ ref: ie,
679
+ className: pe(
680
+ "absolute",
681
+ s ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${x ? "inset-y-[-2px]" : "group-active:inset-y-[-2px]"}` : `inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${x ? "inset-x-[-2px]" : "group-active:inset-x-[-2px]"}`
682
+ ),
683
+ style: {
684
+ backgroundColor: "#7F7F7F",
685
+ borderRadius: a - 1,
686
+ ...s ? {
687
+ left: 0,
688
+ right: 0,
689
+ top: x ? -2 : 1.5,
690
+ bottom: x ? -2 : 1.5
691
+ } : {
692
+ top: 0,
693
+ bottom: 0,
694
+ left: x ? -2 : 1.5,
695
+ right: x ? -2 : 1.5
696
+ }
697
+ },
698
+ onMouseEnter: (d) => {
699
+ s ? (d.currentTarget.style.top = "-0.5px", d.currentTarget.style.bottom = "-0.5px") : (d.currentTarget.style.left = "-0.5px", d.currentTarget.style.right = "-0.5px"), x || (d.currentTarget.style.backgroundColor = "#5F5F5F");
700
+ },
701
+ onMouseLeave: (d) => {
702
+ s ? (d.currentTarget.style.top = x ? "-2px" : "1.5px", d.currentTarget.style.bottom = x ? "-2px" : "1.5px") : (d.currentTarget.style.left = x ? "-2px" : "1.5px", d.currentTarget.style.right = x ? "-2px" : "1.5px"), x || (d.currentTarget.style.backgroundColor = "#7F7F7F");
703
+ }
704
+ }
705
+ )
402
706
  }
403
707
  )
404
708
  }
709
+ ),
710
+ /* @__PURE__ */ q.jsx(
711
+ "button",
712
+ {
713
+ type: "button",
714
+ className: "flex items-center justify-center text-xs text-[#313131] transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[#60a5fa] focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
715
+ style: {
716
+ [s ? "width" : "height"]: h,
717
+ [s ? "height" : "width"]: a,
718
+ backgroundColor: "#E0E0E0"
719
+ },
720
+ "aria-label": s ? "Scroll right" : "Scroll down",
721
+ onMouseDown: oe(1),
722
+ onTouchStart: oe(1),
723
+ onMouseUp: W,
724
+ onMouseLeave: W,
725
+ onTouchEnd: W,
726
+ onTouchCancel: W,
727
+ onKeyDown: ue(1),
728
+ disabled: !w,
729
+ children: /* @__PURE__ */ q.jsx("span", { "aria-hidden": "true", children: s ? "▶" : "▼" })
730
+ }
405
731
  )
406
- }
407
- )
732
+ ]
733
+ }
408
734
  );
409
- }, Ie = de(({ children: u, contentSize: e, viewportSize: n, scrollBarWidth: t = 12, onScroll: s, className: a, style: o, background: d }, l) => {
410
- const c = $(0), [m, p] = ve((R) => R + 1, 0), _ = $(null);
411
- j.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: n, scrollBarWidth: t, className: a, style: o });
412
- const x = ne(() => e > n, [e, n]), S = Y(
413
- (R) => {
414
- const k = e > n, f = c.current;
415
- if (j.debug("[ScrollPane] scrollTo called", { newPosition: R, contentSize: e, viewportSize: n, currentIsScrollable: k, prevPosition: f }), !k) {
416
- c.current !== 0 && (c.current = 0, s?.(0, f));
735
+ }, he = {
736
+ maxVelocity: 6,
737
+ minVelocity: 0.02,
738
+ deceleration: 25e-4,
739
+ velocitySampleWindow: 90,
740
+ startVelocityThreshold: 0.04
741
+ }, nt = Re(({ children: c, contentSize: e, viewportSize: n, scrollBarWidth: r = 12, onScroll: s, className: a, style: i, background: f, tapScrollCircleOptions: p, inertiaOptions: g, itemCount: x }, P) => {
742
+ const S = H(0), [ne, ie] = $e((l) => l + 1, 0), N = H(null), K = H(null), F = H({
743
+ frame: null,
744
+ velocity: 0,
745
+ lastTimestamp: null
746
+ }), m = U(
747
+ () => ({
748
+ maxVelocity: g?.maxVelocity ?? he.maxVelocity,
749
+ minVelocity: g?.minVelocity ?? he.minVelocity,
750
+ deceleration: g?.deceleration ?? he.deceleration,
751
+ velocitySampleWindow: g?.velocitySampleWindow ?? he.velocitySampleWindow,
752
+ startVelocityThreshold: g?.startVelocityThreshold ?? he.startVelocityThreshold
753
+ }),
754
+ [g]
755
+ );
756
+ re.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: n, scrollBarWidth: r, className: a, style: i, tapScrollCircleOptions: p, inertiaOptions: g });
757
+ const Z = H({ contentSize: e, viewportSize: n }), A = U(() => e > n, [e, n]), k = $(
758
+ (l) => {
759
+ const { contentSize: Y, viewportSize: j } = Z.current, L = Y > j, b = S.current;
760
+ if (re.debug("[ScrollPane] scrollTo called", { newPosition: l, contentSize: Y, viewportSize: j, currentIsScrollable: L, prevPosition: b }), !L) {
761
+ S.current !== 0 && (S.current = 0, s?.(0, b));
417
762
  return;
418
763
  }
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));
764
+ const E = typeof l == "function" ? l(S.current) : l, M = z(E, 0, Y - j);
765
+ S.current !== M && (S.current = M, s?.(M, b));
766
+ },
767
+ [s]
768
+ ), C = $(() => {
769
+ const l = F.current;
770
+ l.frame !== null && cancelAnimationFrame(l.frame), l.frame = null, l.velocity = 0, l.lastTimestamp = null;
771
+ }, []), B = $(
772
+ (l) => {
773
+ if (!A)
774
+ return;
775
+ const { maxVelocity: Y, minVelocity: j, deceleration: L, startVelocityThreshold: b } = m, E = z(l, -Y, Y);
776
+ if (Math.abs(E) < b)
777
+ return;
778
+ C(), F.current.velocity = E, F.current.lastTimestamp = null;
779
+ const M = (h) => {
780
+ const v = F.current;
781
+ if (v.lastTimestamp === null) {
782
+ v.lastTimestamp = h, v.frame = requestAnimationFrame(M);
783
+ return;
784
+ }
785
+ const I = h - v.lastTimestamp;
786
+ if (v.lastTimestamp = h, I <= 0) {
787
+ v.frame = requestAnimationFrame(M);
788
+ return;
789
+ }
790
+ const t = v.velocity;
791
+ let o = t;
792
+ const T = L * I;
793
+ t > 0 ? o = Math.max(0, t - T) : t < 0 && (o = Math.min(0, t + T));
794
+ const w = (t + o) / 2 * I, V = S.current;
795
+ w !== 0 && k((u) => u + w);
796
+ const D = S.current, { contentSize: _, viewportSize: R } = Z.current, G = Math.max(_ - R, 0);
797
+ v.velocity = o;
798
+ const J = D === V || D <= 0 && o <= 0 || D >= G && o >= 0;
799
+ if (Math.abs(o) < j || J) {
800
+ C();
801
+ return;
802
+ }
803
+ v.frame = requestAnimationFrame(M);
804
+ };
805
+ F.current.frame = requestAnimationFrame(M);
421
806
  },
422
- [s, e, n]
807
+ [A, m, k, C]
423
808
  );
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);
809
+ be(() => {
810
+ Z.current = { contentSize: e, viewportSize: n };
811
+ }, [e, n]), be(() => {
812
+ if (A) {
813
+ re.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: n, scrollPosition: S.current });
814
+ const l = z(e - n, 0, e);
815
+ S.current > l && k(l);
429
816
  } else
430
- S(0);
431
- }, [x, S, e, n]), B(() => {
432
- const R = (f) => {
433
- if (!x)
817
+ k(0);
818
+ }, [A, k, e, n]), ae(() => {
819
+ const l = (j) => {
820
+ if (!A)
434
821
  return;
435
- f.preventDefault();
436
- let P = f.deltaY;
437
- f.deltaMode === 1 ? P *= 16 : f.deltaMode === 2 && (P *= n), j.debug("[ScrollPane] wheel event", { deltaY: P, scrollPosition: c.current }), S((O) => O + P);
438
- }, k = _.current;
439
- return k && k.addEventListener("wheel", R, { passive: !1 }), () => {
440
- k && k.removeEventListener("wheel", R);
822
+ j.preventDefault(), C();
823
+ let L = j.deltaY;
824
+ j.deltaMode === 1 ? L *= 16 : j.deltaMode === 2 && (L *= n), re.debug("[ScrollPane] wheel event", { deltaY: L, scrollPosition: S.current }), k((b) => b + L);
825
+ }, Y = N.current;
826
+ return Y && Y.addEventListener("wheel", l, { passive: !1 }), () => {
827
+ Y && Y.removeEventListener("wheel", l);
441
828
  };
442
- }, [x, S, n]), he(
443
- l,
829
+ }, [A, k, C, n]), Ae(
830
+ P,
444
831
  () => ({
445
- scrollTo: S,
446
- getScrollPosition: () => c.current,
832
+ scrollTo: k,
833
+ getScrollPosition: () => S.current,
447
834
  getContentSize: () => e,
448
835
  getViewportSize: () => n
449
836
  }),
450
- [S, e, n]
837
+ [k, e, n]
451
838
  );
452
- const A = pe();
453
- return ne(() => /* @__PURE__ */ z.jsxs("div", { ref: _, className: ae("flex", a), style: o, children: [
454
- /* @__PURE__ */ z.jsxs("div", { className: "relative h-full flex-1 overflow-hidden", style: { height: n }, id: A, children: [
455
- d,
456
- u(c.current)
839
+ const X = Ue(), se = U(() => /* @__PURE__ */ q.jsxs("div", { ref: N, className: pe("flex", a), style: i, children: [
840
+ /* @__PURE__ */ q.jsxs("div", { ref: K, className: "relative h-full flex-1 overflow-hidden", style: { height: n, touchAction: "none" }, id: X, children: [
841
+ f,
842
+ c(S.current)
457
843
  ] }),
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]);
844
+ A && /* @__PURE__ */ q.jsx(
845
+ rt,
846
+ {
847
+ contentSize: e,
848
+ viewportSize: n,
849
+ scrollPosition: S.current,
850
+ onScroll: k,
851
+ scrollBarWidth: r,
852
+ ariaControls: X,
853
+ tapScrollCircleOptions: p,
854
+ itemCount: x
855
+ }
856
+ )
857
+ ] }), [c, e, n, r, a, i, A, k, X, f, p, x]);
858
+ return ae(() => {
859
+ const l = K.current;
860
+ if (!l)
861
+ return;
862
+ const Y = 6, j = "input, textarea, select, button, a[href], [role='button']";
863
+ let L = null, b = 0, E = 0, M = !1, h = !1, v = !1, I = null, t = [];
864
+ const o = () => {
865
+ L = null, b = 0, E = 0, M = !1, h = !1, t = [];
866
+ }, T = (u) => {
867
+ const ee = performance.now();
868
+ t.push({ clientY: u, time: ee }), t = t.filter((W) => ee - W.time <= m.velocitySampleWindow);
869
+ }, y = (u) => u instanceof HTMLElement ? u.closest("[data-scrollpane-ignore-drag='true']") !== null : !1, w = (u) => u instanceof HTMLElement ? u.closest(j) !== null : !1, V = (u) => {
870
+ v && (u.preventDefault(), u.stopPropagation(), v = !1);
871
+ }, D = (u) => {
872
+ M || (M = !0, h = !1, v = !0, l.hasPointerCapture(u.pointerId) || l.setPointerCapture(u.pointerId), T(u.clientY));
873
+ }, _ = (u) => {
874
+ if (L !== u.pointerId)
875
+ return;
876
+ if (!M) {
877
+ const oe = Math.abs(u.clientY - b);
878
+ if (h && oe < Y)
879
+ return;
880
+ D(u);
881
+ }
882
+ if (!M)
883
+ return;
884
+ T(u.clientY);
885
+ const ee = u.clientY - b, W = E - ee;
886
+ k(W), u.cancelable && u.preventDefault();
887
+ }, R = (u) => {
888
+ if (L !== u.pointerId)
889
+ return;
890
+ M && v && u.cancelable && (u.preventDefault(), u.stopPropagation()), l.hasPointerCapture(u.pointerId) && l.releasePointerCapture(u.pointerId);
891
+ let ee = 0;
892
+ if (M && t.length >= 2) {
893
+ const W = t[t.length - 1], oe = t.find((ue) => W.time - ue.time <= m.velocitySampleWindow) ?? t[0];
894
+ if (W && oe && W.time !== oe.time) {
895
+ const ue = W.clientY - oe.clientY, ge = W.time - oe.time;
896
+ ee = -(ue / ge);
897
+ }
898
+ }
899
+ o(), I !== null && window.clearTimeout(I), v && (I = window.setTimeout(() => {
900
+ v = !1, I = null;
901
+ }, 0)), Math.abs(ee) >= m.startVelocityThreshold && B(ee);
902
+ }, G = (u) => {
903
+ A && (u.button !== 0 && u.pointerType === "mouse" || u.ctrlKey || u.metaKey || u.altKey || y(u.target) || (window.dispatchEvent(new CustomEvent(Pe, { detail: { paneId: X } })), C(), L = u.pointerId, b = u.clientY, E = S.current, h = w(u.target), M = !1, v = !1, t = [], h || (v = !0, D(u), T(u.clientY), u.cancelable && u.preventDefault())));
904
+ }, J = (u) => {
905
+ L === u.pointerId && (v = !1, l.hasPointerCapture(u.pointerId) && l.releasePointerCapture(u.pointerId), I !== null && (window.clearTimeout(I), I = null), o());
906
+ };
907
+ return l.addEventListener("click", V, !0), l.addEventListener("pointerdown", G, { passive: !1 }), l.addEventListener("pointermove", _, { passive: !1 }), l.addEventListener("pointerup", R), l.addEventListener("pointercancel", J), window.addEventListener("pointermove", _, { passive: !1 }), window.addEventListener("pointerup", R), window.addEventListener("pointercancel", J), () => {
908
+ l.removeEventListener("click", V, !0), l.removeEventListener("pointerdown", G), l.removeEventListener("pointermove", _), l.removeEventListener("pointerup", R), l.removeEventListener("pointercancel", J), window.removeEventListener("pointermove", _), window.removeEventListener("pointerup", R), window.removeEventListener("pointercancel", J), L !== null && l.hasPointerCapture(L) && l.releasePointerCapture(L), I !== null && window.clearTimeout(I), C();
909
+ };
910
+ }, [X, A, m, k, B, C]), se;
460
911
  });
461
- class Se {
912
+ class st {
462
913
  /**
463
914
  * @private
464
915
  * @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
@@ -498,8 +949,8 @@ class Se {
498
949
  * @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
499
950
  * @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
500
951
  */
501
- constructor(e, n, t) {
502
- this.reset(e, n, t);
952
+ constructor(e, n, r) {
953
+ this.reset(e, n, r);
503
954
  }
504
955
  /**
505
956
  * @method reset
@@ -509,20 +960,20 @@ class Se {
509
960
  * @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
510
961
  * @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
511
962
  */
512
- reset(e, n, t) {
963
+ reset(e, n, r) {
513
964
  if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof n == "function") {
514
965
  if (this.valueFn = n, this.size > 0) {
515
- const a = t?.sampleRange ?? {
966
+ const a = r?.sampleRange ?? {
516
967
  from: 0,
517
968
  to: Math.min(99, this.size - 1)
518
- }, { mode: o, materializedValues: d } = this._calculateMode(a.from, a.to);
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;
522
- if (m >= this.size)
969
+ }, { mode: i, materializedValues: f } = this._calculateMode(a.from, a.to);
970
+ if (this.baseValue = i, r?.materialize)
971
+ for (let p = 0; p < f.length; p++) {
972
+ const g = f[p], x = a.from + p;
973
+ if (x >= this.size)
523
974
  break;
524
- const p = c - this.baseValue;
525
- this.deltas.set(m, p), this._updateTree(m, p);
975
+ const P = g - this.baseValue;
976
+ this.deltas.set(x, P), this._updateTree(x, P);
526
977
  }
527
978
  } else
528
979
  this.baseValue = 0;
@@ -551,30 +1002,30 @@ class Se {
551
1002
  _calculateMode(e, n) {
552
1003
  if (!this.valueFn)
553
1004
  return { mode: 0, materializedValues: [] };
554
- const t = [];
555
- for (let c = e; c <= n && !(c >= this.size); c++)
556
- t.push(this.valueFn(c));
557
- const s = [...t];
558
- if (t.length === 0)
1005
+ const r = [];
1006
+ for (let g = e; g <= n && !(g >= this.size); g++)
1007
+ r.push(this.valueFn(g));
1008
+ const s = [...r];
1009
+ if (r.length === 0)
559
1010
  return { mode: 0, materializedValues: [] };
560
- t.sort((c, m) => c - m);
561
- const a = Math.floor(t.length / 2);
562
- let o;
563
- t.length % 2 === 0 ? o = Math.floor((t[a - 1] + t[a]) / 2) : o = t[a];
564
- const d = /* @__PURE__ */ new Map();
565
- let l = 0;
566
- for (const c of t) {
567
- const m = (d.get(c) ?? 0) + 1;
568
- d.set(c, m), m > l && (l = m);
1011
+ r.sort((g, x) => g - x);
1012
+ const a = Math.floor(r.length / 2);
1013
+ let i;
1014
+ r.length % 2 === 0 ? i = Math.floor((r[a - 1] + r[a]) / 2) : i = r[a];
1015
+ const f = /* @__PURE__ */ new Map();
1016
+ let p = 0;
1017
+ for (const g of r) {
1018
+ const x = (f.get(g) ?? 0) + 1;
1019
+ f.set(g, x), x > p && (p = x);
569
1020
  }
570
- if (l > 1) {
571
- const c = [];
572
- for (const [p, _] of d.entries())
573
- _ === l && c.push(p);
574
- const m = c.reduce((p, _) => p + _, 0);
575
- o = Math.floor(m / c.length);
1021
+ if (p > 1) {
1022
+ const g = [];
1023
+ for (const [P, S] of f.entries())
1024
+ S === p && g.push(P);
1025
+ const x = g.reduce((P, S) => P + S, 0);
1026
+ i = Math.floor(x / g.length);
576
1027
  }
577
- return { mode: o, materializedValues: s };
1028
+ return { mode: i, materializedValues: s };
578
1029
  }
579
1030
  /**
580
1031
  * @method update
@@ -593,14 +1044,14 @@ class Se {
593
1044
  * @param {{ index: number; value: number }[]} updates - An array of updates, each with an index and the new value.
594
1045
  */
595
1046
  updates(e) {
596
- const n = e.map(({ index: t, value: s }) => {
597
- if (t < 0 || t >= this.size)
598
- throw new Error(`Index ${t} out of bounds`);
1047
+ const n = e.map(({ index: r, value: s }) => {
1048
+ if (r < 0 || r >= this.size)
1049
+ throw new Error(`Index ${r} out of bounds`);
599
1050
  if (s < 0)
600
1051
  throw new Error("Value cannot be negative.");
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);
1052
+ const a = this.deltas.has(r) ? (this.deltas.get(r) ?? 0) + this.baseValue : this.baseValue, i = s - a;
1053
+ return { index: r, change: i };
1054
+ }).filter((r) => r.change !== 0);
604
1055
  return n.length > 0 ? this.updateDeltas(n) : this.total;
605
1056
  }
606
1057
  /**
@@ -620,11 +1071,11 @@ class Se {
620
1071
  * @param {{ index: number; change: number }[]} updates - An array of updates, each with an index and the change to apply.
621
1072
  */
622
1073
  updateDeltas(e) {
623
- for (const { index: n, change: t } of e) {
1074
+ for (const { index: n, change: r } of e) {
624
1075
  if (n < 0 || n >= this.size)
625
1076
  throw new Error(`Index ${n} out of bounds`);
626
1077
  const s = this.deltas.get(n) ?? 0;
627
- this.deltas.set(n, s + t), this._updateTree(n, t);
1078
+ this.deltas.set(n, s + r), this._updateTree(n, r);
628
1079
  }
629
1080
  return this.total;
630
1081
  }
@@ -639,9 +1090,9 @@ class Se {
639
1090
  _updateTree(e, n) {
640
1091
  if (n === 0)
641
1092
  return;
642
- let t = e + 1;
643
- for (; t <= this.size; )
644
- this.tree.set(t, (this.tree.get(t) ?? 0) + n), t += t & -t;
1093
+ let r = e + 1;
1094
+ for (; r <= this.size; )
1095
+ this.tree.set(r, (this.tree.get(r) ?? 0) + n), r += r & -r;
645
1096
  this.total !== void 0 && (this.total += n);
646
1097
  }
647
1098
  /**
@@ -654,10 +1105,10 @@ class Se {
654
1105
  */
655
1106
  _materialize(e, n = !0) {
656
1107
  if (this.valueFn) {
657
- const t = this.deltas.get(e) ?? 0, a = this.valueFn(e) - this.baseValue;
658
- if (a !== t && (this.deltas.set(e, a), n)) {
659
- const o = a - t;
660
- this._updateTree(e, o);
1108
+ const r = this.deltas.get(e) ?? 0, a = this.valueFn(e) - this.baseValue;
1109
+ if (a !== r && (this.deltas.set(e, a), n)) {
1110
+ const i = a - r;
1111
+ this._updateTree(e, i);
661
1112
  }
662
1113
  }
663
1114
  }
@@ -677,23 +1128,23 @@ class Se {
677
1128
  prefixSum(e, n) {
678
1129
  if (e < 0)
679
1130
  return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
680
- const t = F(e, 0, this.size - 1), s = n?.materializeOption;
1131
+ const r = z(e, 0, this.size - 1), s = n?.materializeOption;
681
1132
  if (s?.materialize && this.valueFn) {
682
1133
  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);
1134
+ for (const p of s.ranges) {
1135
+ const g = p.from, x = Math.min(p.to, this.size - 1);
1136
+ for (let P = g; P <= x; P++)
1137
+ this._materialize(P);
687
1138
  }
688
- this._materialize(t);
1139
+ this._materialize(r);
689
1140
  }
690
- let a = 0, o = t + 1;
691
- for (; o > 0; ) {
692
- const l = this.tree.get(o) ?? 0;
693
- a += l, o -= o & -o;
1141
+ let a = 0, i = r + 1;
1142
+ for (; i > 0; ) {
1143
+ const p = this.tree.get(i) ?? 0;
1144
+ a += p, i -= i & -i;
694
1145
  }
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 };
1146
+ const f = s?.materialize ? this.get(r) : (this.deltas.get(r) || 0) + this.baseValue;
1147
+ return { cumulative: a + this.baseValue * (r + 1), total: this.total, currentValue: f, safeIndex: r };
697
1148
  }
698
1149
  /**
699
1150
  * @method get
@@ -711,15 +1162,15 @@ class Se {
711
1162
  get(e, n) {
712
1163
  if (e < 0 || e >= this.size)
713
1164
  throw new Error("Index out of bounds");
714
- const t = n?.materializeOption;
715
- if (t?.materialize && this.valueFn)
716
- if (t.ranges) {
717
- for (const s of t.ranges) {
718
- const a = s.from, o = Math.min(s.to, this.size - 1);
719
- for (let d = a; d <= o; d++)
720
- this._materialize(d);
1165
+ const r = n?.materializeOption;
1166
+ if (r?.materialize && this.valueFn)
1167
+ if (r.ranges) {
1168
+ for (const s of r.ranges) {
1169
+ const a = s.from, i = Math.min(s.to, this.size - 1);
1170
+ for (let f = a; f <= i; f++)
1171
+ this._materialize(f);
721
1172
  }
722
- e >= t.ranges[0].from && e <= t.ranges[t.ranges.length - 1].to && this._materialize(e);
1173
+ e >= r.ranges[0].from && e <= r.ranges[r.ranges.length - 1].to && this._materialize(e);
723
1174
  } else
724
1175
  this._materialize(e);
725
1176
  return (this.deltas.get(e) ?? 0) + this.baseValue;
@@ -739,19 +1190,19 @@ class Se {
739
1190
  getTotal(e) {
740
1191
  const n = e?.materializeOption;
741
1192
  if (n?.materialize && this.valueFn && n.ranges)
742
- for (const t of n.ranges) {
743
- const s = t.from, a = Math.min(t.to, this.size - 1);
744
- for (let o = s; o <= a; o++)
745
- this._materialize(o);
1193
+ for (const r of n.ranges) {
1194
+ const s = r.from, a = Math.min(r.to, this.size - 1);
1195
+ for (let i = s; i <= a; i++)
1196
+ this._materialize(i);
746
1197
  }
747
1198
  if (this.total === void 0)
748
1199
  if (this.size === 0)
749
1200
  this.total = 0;
750
1201
  else {
751
- let t = this.baseValue * this.size;
1202
+ let r = this.baseValue * this.size;
752
1203
  for (const s of this.deltas.values())
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");
1204
+ r += s;
1205
+ this.total = r, console.assert(this.prefixSum(this.getSize() - 1).cumulative === this.prefixSum(this.getSize() - 1).total, "Inconsistent Fenwick Tree state");
755
1206
  }
756
1207
  return this.total;
757
1208
  }
@@ -769,15 +1220,15 @@ class Se {
769
1220
  return;
770
1221
  }
771
1222
  const n = /* @__PURE__ */ new Map();
772
- let t = this.baseValue * this.size;
1223
+ let r = this.baseValue * this.size;
773
1224
  for (const [s, a] of this.deltas.entries()) {
774
- if (t += a, a === 0)
1225
+ if (r += a, a === 0)
775
1226
  continue;
776
- let o = s + 1;
777
- for (; o <= this.size; )
778
- n.set(o, (n.get(o) ?? 0) + a), o += o & -o;
1227
+ let i = s + 1;
1228
+ for (; i <= this.size; )
1229
+ n.set(i, (n.get(i) ?? 0) + a), i += i & -i;
779
1230
  }
780
- this.tree = n, this.total = t;
1231
+ this.tree = n, this.total = r;
781
1232
  }
782
1233
  /**
783
1234
  * @method calculateAccumulatedError
@@ -803,8 +1254,8 @@ class Se {
803
1254
  const n = this.size;
804
1255
  if (e !== n) {
805
1256
  if (e < n)
806
- for (const t of this.deltas.keys())
807
- t >= e && this.deltas.delete(t);
1257
+ for (const r of this.deltas.keys())
1258
+ r >= e && this.deltas.delete(r);
808
1259
  this.size = e, this.rebuildTree(), console.assert(this.prefixSum(this.getSize() - 1).cumulative === this.prefixSum(this.getSize() - 1).total, "Inconsistent Fenwick Tree state");
809
1260
  }
810
1261
  }
@@ -833,12 +1284,12 @@ class Se {
833
1284
  findIndexAtOrAfter(e, n) {
834
1285
  if (this.size === 0)
835
1286
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
836
- let t = 0, s = this.size - 1, a = -1, o, d = this.total;
837
- for (; t <= s; ) {
838
- const l = Math.floor((t + s) / 2);
839
- o = this.prefixSum(l, n), d = o.total, o.cumulative >= e ? (a = l, s = l - 1) : t = l + 1;
1287
+ let r = 0, s = this.size - 1, a = -1, i, f = this.total;
1288
+ for (; r <= s; ) {
1289
+ const p = Math.floor((r + s) / 2);
1290
+ i = this.prefixSum(p, n), f = i.total, i.cumulative >= e ? (a = p, s = p - 1) : r = p + 1;
840
1291
  }
841
- return { index: a, total: d, cumulative: o?.cumulative, currentValue: o?.currentValue, safeIndex: o?.safeIndex };
1292
+ return { index: a, total: f, cumulative: i?.cumulative, currentValue: i?.currentValue, safeIndex: i?.safeIndex };
842
1293
  }
843
1294
  /**
844
1295
  * @method findIndexAtOrBefore
@@ -856,148 +1307,163 @@ class Se {
856
1307
  findIndexAtOrBefore(e, n) {
857
1308
  if (this.size === 0)
858
1309
  return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
859
- let t = 0, s = this.size - 1, a = -1, o, d = this.total;
860
- for (; t <= s; ) {
861
- const l = Math.floor((t + s) / 2);
862
- o = this.prefixSum(l, n), d = o.total, o.cumulative <= e ? (a = l, t = l + 1) : s = l - 1;
1310
+ let r = 0, s = this.size - 1, a = -1, i, f = this.total;
1311
+ for (; r <= s; ) {
1312
+ const p = Math.floor((r + s) / 2);
1313
+ i = this.prefixSum(p, n), f = i.total, i.cumulative <= e ? (a = p, r = p + 1) : s = p - 1;
863
1314
  }
864
- return { index: a, total: d, cumulative: o?.cumulative, currentValue: o?.currentValue, safeIndex: o?.safeIndex };
1315
+ return { index: a, total: f, cumulative: i?.cumulative, currentValue: i?.currentValue, safeIndex: i?.safeIndex };
865
1316
  }
866
1317
  }
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]);
1318
+ const ot = (c, e, n) => {
1319
+ const r = Math.max(0, c), s = H(null), a = U(() => new st(r, e, n), [r, e, n]);
869
1320
  return Object.is(s.current, a) || console.warn("[useFenwickMapTree] instance changed"), s.current = a, a;
870
1321
  };
871
- function Pe({ itemCount: u, getItem: e, getItemHeight: n, viewportSize: t, overscanCount: s = 5, className: a, onScroll: o, onRangeChange: d, children: l, background: c, initialScrollIndex: m, initialScrollOffset: p }, _) {
872
- const x = $(null), S = $(!1);
873
- B(() => (S.current = !0, () => {
874
- S.current = !1;
1322
+ function at({ itemCount: c, getItem: e, getItemHeight: n, viewportSize: r, overscanCount: s = 5, className: a, onScroll: i, onRangeChange: f, children: p, background: g, initialScrollIndex: x, initialScrollOffset: P, tapScrollCircleOptions: S, inertiaOptions: ne }, ie) {
1323
+ const N = H(null), K = H(!1);
1324
+ ae(() => (K.current = !0, () => {
1325
+ K.current = !1;
875
1326
  }), []);
876
- const A = $({ size: u, valueOrFn: n, options: { sampleRange: { from: 0, to: 100 } } }), b = ke(A.current.size, A.current.valueOrFn, A.current.options), [R] = W(() => {
877
- let g = 0, V = 0;
878
- if (typeof m == "number") {
879
- const r = F(m, 0, u - 1), i = F(r - s * 2, 0, u - 1), h = F(r + s * 2, 0, u - 1), v = m > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: i, to: h }] } } : void 0, { cumulative: E, total: T, currentValue: I } = b.prefixSum(m, v);
880
- g = E - I, V = T ?? b.getTotal();
881
- } else typeof p == "number" && (g = p), V = b.getTotal();
882
- return { position: g, total: V };
883
- }), [k, f] = W(R.position), [P, O] = W(R.total), [M, H] = W(R.position), [w, X] = W(u);
884
- oe(() => {
885
- b.setValueFn(n), w !== u && (b.changeSize(u), X(u));
886
- const g = b.getTotal();
887
- P !== g && O(g);
888
- }, [b, w, u, P, n]), oe(() => {
889
- M !== null && x.current && (j.debug("[VirtualScroll] Scrolling to position:", M), x.current.scrollTo(M), H(null));
890
- }, [M]);
891
- const U = Y(
892
- (g) => {
893
- if (x.current) {
894
- j.debug("[VirtualScroll] Scrolling to index:", g);
895
- const V = F(g, 0, w - 1), r = F(V - s * 2, 0, w - 1), i = F(V + s * 2, 0, w - 1), { cumulative: h, total: v, currentValue: E } = b.prefixSum(V, { materializeOption: { materialize: !0, ranges: [{ from: r, to: i }] } });
896
- j.debug("[VirtualScroll] Scrolling to index:", g, "Offset:", h, "Total height:", v, "Current value:", E, "safeIndex:", V, "safeIndexFrom:", r, "safeIndexTo:", i), v && (O(v), H(h - E)), j.debug("[VirtualScroll] Setting scroll position to:", h - E);
1327
+ const F = H({ size: c, valueOrFn: n, options: { sampleRange: { from: 0, to: 100 } } }), m = ot(F.current.size, F.current.valueOrFn, F.current.options), [Z] = le(() => {
1328
+ let h = 0, v = 0;
1329
+ if (typeof x == "number") {
1330
+ const I = z(x, 0, c - 1), t = z(I - s * 2, 0, c - 1), o = z(I + s * 2, 0, c - 1), T = x > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: t, to: o }] } } : void 0, { cumulative: y, total: w, currentValue: V } = m.prefixSum(x, T);
1331
+ h = y - V, v = w ?? m.getTotal();
1332
+ } else typeof P == "number" && (h = P), v = m.getTotal();
1333
+ return { position: h, total: v };
1334
+ }), [A, k] = le(Z.position), [C, B] = le(Z.total), [X, se] = le(Z.position), [l, Y] = le(c);
1335
+ be(() => {
1336
+ m.setValueFn(n), l !== c && (m.changeSize(c), Y(c));
1337
+ const h = m.getTotal();
1338
+ C !== h && B(h);
1339
+ }, [m, l, c, C, n]), be(() => {
1340
+ X !== null && N.current && (re.debug("[VirtualScroll] Scrolling to position:", X), N.current.scrollTo(X), se(null));
1341
+ }, [X]);
1342
+ const j = $(
1343
+ (h) => {
1344
+ if (N.current) {
1345
+ re.debug("[VirtualScroll] Scrolling to index:", h);
1346
+ const v = z(h, 0, l - 1), I = z(v - s * 2, 0, l - 1), t = z(v + s * 2, 0, l - 1), { cumulative: o, total: T, currentValue: y } = m.prefixSum(v, { materializeOption: { materialize: !0, ranges: [{ from: I, to: t }] } });
1347
+ re.debug("[VirtualScroll] Scrolling to index:", h, "Offset:", o, "Total height:", T, "Current value:", y, "safeIndex:", v, "safeIndexFrom:", I, "safeIndexTo:", t), T && (B(T), se(o - y)), re.debug("[VirtualScroll] Setting scroll position to:", o - y);
897
1348
  }
898
1349
  },
899
- [b, s, w]
900
- ), q = Y(
901
- (g) => {
902
- if (x.current) {
903
- const V = b.getTotal(), r = F(Math.floor(g), 0, V), i = b.findIndexAtOrAfter(r, { materializeOption: { materialize: !1 } }).index;
904
- U(i);
1350
+ [m, s, l]
1351
+ ), L = $(
1352
+ (h) => {
1353
+ if (N.current) {
1354
+ const v = m.getTotal(), I = z(Math.floor(h), 0, v), t = m.findIndexAtOrAfter(I, { materializeOption: { materialize: !1 } }).index;
1355
+ j(t);
905
1356
  }
906
1357
  },
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);
1358
+ [m, j]
1359
+ ), b = $(
1360
+ (h, v) => {
1361
+ re.debug("[VirtualScroll] Scroll position changed:", h), k(h);
1362
+ const I = m.getTotal();
1363
+ i?.(h, I);
913
1364
  },
914
- [b, o]
915
- ), { renderingStartIndex: C, renderingEndIndex: D, visibleStartIndex: J, visibleEndIndex: G } = ne(() => {
916
- if (w === 0)
1365
+ [m, i]
1366
+ ), E = U(() => {
1367
+ if (l === 0)
917
1368
  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++;
1369
+ const { index: h, cumulative: v, currentValue: I } = m.findIndexAtOrAfter(A, { materializeOption: { materialize: !1 } });
1370
+ let t = 0;
1371
+ h === -1 ? t = 0 : (v ?? 0) < A + (I ?? 0) ? t = 1 : t = 0;
1372
+ const o = h === -1 ? 0 : h + t, T = z(o - s, 0, l - 1);
1373
+ let y = 0, w = h === -1 ? 0 : h + t;
1374
+ for (; w < l && y < r; ) {
1375
+ const D = n(w);
1376
+ y += D, w++;
926
1377
  }
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,
934
- scrollPosition: k,
935
- renderingContentSize: b.getTotal(),
1378
+ w -= 1;
1379
+ const V = z(w + s, 0, l - 1);
1380
+ return re.debug("[VirtualScroll] Calculated rendering range:", {
1381
+ renderingStartIndex: T,
1382
+ renderingEndIndex: V,
1383
+ visibleStartIndex: o,
1384
+ visibleEndIndex: w,
1385
+ scrollPosition: A,
1386
+ renderingContentSize: m.getTotal(),
936
1387
  overscanCount: s,
937
- viewportSize: t
938
- }), { renderingStartIndex: v, renderingEndIndex: I, visibleStartIndex: h, visibleEndIndex: T };
939
- }, [k, s, t, n, b, w]);
940
- B(() => {
941
- const g = x.current?.getScrollPosition() ?? 0;
942
- j.debug("[VirtualScroll] Range change effect triggered", {
943
- renderingStartIndex: C,
944
- renderingEndIndex: D,
945
- visibleStartIndex: J,
946
- visibleEndIndex: G,
947
- scrollPosition: k,
948
- contentSize: P,
949
- scrollPaneScrollPosition: g
950
- }), d?.(C, D, J, G, k, P);
951
- }, [C, D, J, G, d, k, P]);
952
- const te = Y(
953
- (g) => {
954
- if (j.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: g, renderingStartIndex: C, renderingEndIndex: D, fenwickSize: w, viewportSize: t }), w === 0)
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 });
1388
+ viewportSize: r
1389
+ }), { renderingStartIndex: T, renderingEndIndex: V, visibleStartIndex: o, visibleEndIndex: w };
1390
+ }, [A, s, r, n, m, l]);
1391
+ ae(() => {
1392
+ const h = N.current?.getScrollPosition() ?? 0;
1393
+ re.debug("[VirtualScroll] Range change effect triggered", {
1394
+ renderingStartIndex: E.renderingStartIndex,
1395
+ renderingEndIndex: E.renderingEndIndex,
1396
+ visibleStartIndex: E.visibleStartIndex,
1397
+ visibleEndIndex: E.visibleEndIndex,
1398
+ scrollPosition: A,
1399
+ contentSize: C,
1400
+ scrollPaneScrollPosition: h
1401
+ }), f?.(E.renderingStartIndex, E.renderingEndIndex, E.visibleStartIndex, E.visibleEndIndex, A, C);
1402
+ }, [E.renderingStartIndex, E.renderingEndIndex, E.visibleStartIndex, E.visibleEndIndex, f, A, C]);
1403
+ const M = $(
1404
+ (h) => {
1405
+ const { renderingStartIndex: v, renderingEndIndex: I } = E;
1406
+ if (re.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: h, renderingStartIndex: v, renderingEndIndex: I, fenwickSize: l, viewportSize: r }), l === 0)
1407
+ return /* @__PURE__ */ q.jsx("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ q.jsx("div", { className: "text-center text-gray-500", children: "No items" }) });
1408
+ const t = z(v, 0, l - 1), { cumulative: o, currentValue: T } = m.prefixSum(t, { materializeOption: { materialize: !1 } }), y = o - T, w = [], V = [];
1409
+ for (let _ = v; _ <= I; _++) {
1410
+ const R = n(_);
1411
+ w.push({ item: e(_), height: R }), m.get(_) !== R && V.push({ index: _, value: R });
960
1412
  }
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));
1413
+ V.length > 0 && Promise.resolve().then(() => {
1414
+ const _ = m.updates(V);
1415
+ _ && (B(_), re.debug("[VirtualScroll] Updated heights for items", V, "New total height:", _));
964
1416
  });
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(
1417
+ const D = C < r ? 0 : y - h;
1418
+ return re.debug("[VirtualScroll] Rendering items", { visibleItems: w, containerTop: D }), /* @__PURE__ */ q.jsx("div", { className: "absolute w-full", style: { top: D }, children: w.map(({ item: _, height: R }, G) => {
1419
+ const J = v + G, u = z(J, 0, l - 1), { cumulative: ee, currentValue: W } = m.prefixSum(u, { materializeOption: { materialize: !1 } }), oe = ee - W;
1420
+ return /* @__PURE__ */ q.jsx(
969
1421
  "div",
970
1422
  {
971
- "data-index": N,
1423
+ "data-index": J,
972
1424
  style: {
973
1425
  position: "absolute",
974
- top: ge - h,
1426
+ top: oe - y,
975
1427
  width: "100%"
976
1428
  },
977
- children: l(I, N)
1429
+ children: p(_, J)
978
1430
  },
979
- N
1431
+ J
980
1432
  );
981
1433
  }) });
982
1434
  },
983
- [e, l, P, t, C, D, b, w, n]
1435
+ [e, p, C, r, E, m, l, n]
984
1436
  );
985
- return he(
986
- _,
1437
+ return Ae(
1438
+ ie,
987
1439
  () => ({
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),
993
- getFenwickTreeTotalHeight: () => b.getTotal(),
994
- getFenwickSize: () => b.getSize()
1440
+ getScrollPosition: () => N.current?.getScrollPosition() ?? -1,
1441
+ getContentSize: () => N.current?.getContentSize() ?? -1,
1442
+ getViewportSize: () => N.current?.getViewportSize() ?? -1,
1443
+ scrollTo: (h) => L(h),
1444
+ scrollToIndex: (h) => j(h),
1445
+ getFenwickTreeTotalHeight: () => m.getTotal(),
1446
+ getFenwickSize: () => m.getSize()
995
1447
  }),
996
- [U, b, q]
997
- ), /* @__PURE__ */ z.jsx(Ie, { ref: x, contentSize: P, viewportSize: t, className: a, onScroll: Z, background: c, children: te });
1448
+ [j, m, L]
1449
+ ), /* @__PURE__ */ q.jsx(
1450
+ nt,
1451
+ {
1452
+ ref: N,
1453
+ contentSize: C,
1454
+ viewportSize: r,
1455
+ className: a,
1456
+ onScroll: b,
1457
+ background: g,
1458
+ tapScrollCircleOptions: S,
1459
+ inertiaOptions: ne,
1460
+ itemCount: c,
1461
+ children: M
1462
+ }
1463
+ );
998
1464
  }
999
- const Ae = de(Pe);
1000
- class we {
1465
+ const ft = Re(at);
1466
+ class it {
1001
1467
  key;
1002
1468
  value;
1003
1469
  prev = null;
@@ -1006,7 +1472,7 @@ class we {
1006
1472
  this.key = e, this.value = n;
1007
1473
  }
1008
1474
  }
1009
- class fe {
1475
+ class Ce {
1010
1476
  head = null;
1011
1477
  tail = null;
1012
1478
  /**
@@ -1047,54 +1513,54 @@ class fe {
1047
1513
  this.remove(e), this.addToTail(e);
1048
1514
  }
1049
1515
  }
1050
- function Ve(u) {
1051
- const e = $(/* @__PURE__ */ new Map()), n = $(new fe());
1052
- B(() => {
1053
- for (; e.current.size > u; ) {
1054
- const c = n.current.removeHead();
1055
- if (c)
1056
- e.current.delete(c.key);
1516
+ function lt(c) {
1517
+ const e = H(/* @__PURE__ */ new Map()), n = H(new Ce());
1518
+ ae(() => {
1519
+ for (; e.current.size > c; ) {
1520
+ const g = n.current.removeHead();
1521
+ if (g)
1522
+ e.current.delete(g.key);
1057
1523
  else
1058
1524
  break;
1059
1525
  }
1060
- }, [u]);
1061
- const t = Y((c) => {
1062
- const m = e.current.get(c);
1063
- if (m)
1064
- return n.current.moveToTail(m), m.value;
1065
- }, []), s = Y(
1066
- (c, m) => {
1067
- if (u <= 0)
1526
+ }, [c]);
1527
+ const r = $((g) => {
1528
+ const x = e.current.get(g);
1529
+ if (x)
1530
+ return n.current.moveToTail(x), x.value;
1531
+ }, []), s = $(
1532
+ (g, x) => {
1533
+ if (c <= 0)
1068
1534
  return;
1069
- let p = e.current.get(c);
1070
- if (p)
1071
- p.value = m, n.current.moveToTail(p);
1535
+ let P = e.current.get(g);
1536
+ if (P)
1537
+ P.value = x, n.current.moveToTail(P);
1072
1538
  else {
1073
- if (e.current.size >= u) {
1074
- const _ = n.current.removeHead();
1075
- _ && e.current.delete(_.key);
1539
+ if (e.current.size >= c) {
1540
+ const S = n.current.removeHead();
1541
+ S && e.current.delete(S.key);
1076
1542
  }
1077
- p = new we(c, m), e.current.set(c, p), n.current.addToTail(p);
1543
+ P = new it(g, x), e.current.set(g, P), n.current.addToTail(P);
1078
1544
  }
1079
1545
  },
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;
1546
+ [c]
1547
+ ), a = $((g) => e.current.has(g), []), i = $(() => {
1548
+ e.current.clear(), n.current = new Ce();
1549
+ }, []), [f, p] = le(() => ({ get: r, set: s, has: a, clear: i }));
1550
+ return ae(() => p({ get: r, set: s, has: a, clear: i }), [r, s, a, i]), f;
1085
1551
  }
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 };
1552
+ const ct = 1e4, mt = () => {
1553
+ const { get: c, set: e, has: n, clear: r } = lt(ct);
1554
+ return { get: c, set: e, has: n, clear: r };
1089
1555
  };
1090
1556
  export {
1091
- Se as FenwickMapTree,
1092
- Re as ScrollBar,
1093
- Ie as ScrollPane,
1094
- Ae as VirtualScroll,
1095
- F as minmax,
1096
- ke as useFenwickMapTree,
1097
- je as useHeightCache,
1098
- Ve as useLruCache
1557
+ st as FenwickMapTree,
1558
+ rt as ScrollBar,
1559
+ nt as ScrollPane,
1560
+ ft as VirtualScroll,
1561
+ z as minmax,
1562
+ ot as useFenwickMapTree,
1563
+ mt as useHeightCache,
1564
+ lt as useLruCache
1099
1565
  };
1100
1566
  //# sourceMappingURL=index.js.map