@pdanpdan/virtual-scroll 0.5.0 → 0.6.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.mjs CHANGED
@@ -1,2225 +1,1718 @@
1
- import { computed as u, toValue as st, ref as ee, reactive as jt, watch as Me, nextTick as kt, getCurrentInstance as fl, onMounted as hl, onUnmounted as ll, defineComponent as gl, openBlock as Ee, createElementBlock as It, normalizeProps as St, guardReactiveProps as il, unref as tt, createElementVNode as el, useSlots as yl, useId as Sl, toRefs as bl, createBlock as Je, resolveDynamicComponent as ht, normalizeStyle as gt, normalizeClass as Bt, withCtx as mt, renderSlot as pt, mergeProps as Vt, createCommentVNode as et, Fragment as wl, renderList as xl, toDisplayString as Qt } from "vue";
2
- class Kt {
3
- tree;
4
- values;
5
- /**
6
- * Creates a new Fenwick Tree with the specified size.
7
- *
8
- * @param size - The number of elements in the tree.
9
- */
10
- constructor(e) {
11
- this.tree = new Float64Array(e + 1), this.values = new Float64Array(e);
12
- }
13
- /**
14
- * Update the value at a specific index and propagate changes throughout the tree.
15
- *
16
- * @param index - The 0-based index to update.
17
- * @param delta - The change in value (new value - old value).
18
- */
19
- update(e, i) {
20
- if (!(e < 0 || e >= this.values.length))
21
- for (this.values[e] = this.values[e] + i, e++; e < this.tree.length; )
22
- this.tree[e] = this.tree[e] + i, e += e & -e;
23
- }
24
- /**
25
- * Get the prefix sum up to a specific index (exclusive).
26
- *
27
- * @param index - 0-based index. `query(n)` returns sum of values from index 0 to n-1.
28
- * @returns Sum of values in range [0, index).
29
- */
30
- query(e) {
31
- let i = 0;
32
- for (; e > 0; )
33
- i += this.tree[e] || 0, e -= e & -e;
34
- return i;
35
- }
36
- /**
37
- * Set the individual value at an index without updating the prefix sum tree.
38
- * Call `rebuild()` after multiple sets to update the tree efficiently in O(n).
39
- *
40
- * @param index - The 0-based index.
41
- * @param value - The new value.
42
- */
43
- set(e, i) {
44
- e < 0 || e >= this.values.length || (this.values[e] = i);
45
- }
46
- /**
47
- * Get the number of items in the tree.
48
- */
49
- get length() {
50
- return this.values.length;
51
- }
52
- /**
53
- * Get the individual value at a specific index.
54
- *
55
- * @param index - The 0-based index.
56
- * @returns The value at the specified index.
57
- */
58
- get(e) {
59
- return this.values[e] || 0;
60
- }
61
- /**
62
- * Get the underlying values array as a read-only Float64Array.
63
- *
64
- * @returns The read-only values array.
65
- */
66
- getValues() {
67
- return this.values;
68
- }
69
- /**
70
- * Find the largest index such that the prefix sum is less than or equal to the given value.
71
- * Highly efficient search used to find which item is at a specific scroll offset.
72
- *
73
- * @param value - The prefix sum value to search for.
74
- * @returns The 0-based index.
75
- */
76
- findLowerBound(e) {
77
- let i = 0;
78
- const t = this.tree.length;
79
- let s = 1 << Math.floor(Math.log2(t - 1));
80
- for (; s > 0; ) {
81
- const d = i + s;
82
- if (d < t) {
83
- const S = this.tree[d] || 0;
84
- S <= e && (i = d, e -= S);
85
- }
86
- s >>= 1;
87
- }
88
- return i;
89
- }
90
- /**
91
- * Rebuild the entire prefix sum tree from the current values array.
92
- * Time complexity: O(n).
93
- */
94
- rebuild() {
95
- this.tree.fill(0);
96
- for (let e = 0; e < this.values.length; e++)
97
- this.tree[e + 1] = this.values[e] || 0;
98
- for (let e = 1; e < this.tree.length; e++) {
99
- const i = e + (e & -e);
100
- i < this.tree.length && (this.tree[i] = this.tree[i] + this.tree[e]);
101
- }
102
- }
103
- /**
104
- * Resize the tree while preserving existing values and rebuilding the prefix sums.
105
- *
106
- * @param size - The new size of the tree.
107
- */
108
- resize(e) {
109
- if (e === this.values.length)
110
- return;
111
- const i = new Float64Array(e);
112
- i.set(this.values.subarray(0, Math.min(e, this.values.length))), this.values = i, this.tree = new Float64Array(e + 1), this.rebuild();
113
- }
114
- /**
115
- * Shift values by a given offset and rebuild the tree.
116
- * Useful when items are prepended to the list to maintain existing measurements.
117
- *
118
- * @param offset - Number of positions to shift. Positive for prepending (shifts right).
119
- */
120
- shift(e) {
121
- if (e === 0)
122
- return;
123
- const i = this.values.length, t = new Float64Array(i);
124
- e > 0 ? t.set(this.values.subarray(0, Math.min(i - e, this.values.length)), e) : t.set(this.values.subarray(-e)), this.values = t, this.rebuild();
125
- }
1
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, getCurrentInstance, guardReactiveProps, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onMounted, onUnmounted, openBlock, reactive, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, toRefs, toValue, unref, useId, useSlots, watch, withCtx } from "vue";
2
+ const DEFAULT_ITEM_SIZE = 40, DEFAULT_COLUMN_WIDTH = 100, DEFAULT_BUFFER = 5, EMPTY_SCROLL_DETAILS = {
3
+ items: [],
4
+ currentIndex: 0,
5
+ currentColIndex: 0,
6
+ currentEndIndex: 0,
7
+ currentEndColIndex: 0,
8
+ scrollOffset: {
9
+ x: 0,
10
+ y: 0
11
+ },
12
+ displayScrollOffset: {
13
+ x: 0,
14
+ y: 0
15
+ },
16
+ viewportSize: {
17
+ width: 0,
18
+ height: 0
19
+ },
20
+ displayViewportSize: {
21
+ width: 0,
22
+ height: 0
23
+ },
24
+ totalSize: {
25
+ width: 0,
26
+ height: 0
27
+ },
28
+ isScrolling: !1,
29
+ isProgrammaticScroll: !1,
30
+ range: {
31
+ start: 0,
32
+ end: 0
33
+ },
34
+ columnRange: {
35
+ start: 0,
36
+ end: 0,
37
+ padStart: 0,
38
+ padEnd: 0
39
+ }
40
+ };
41
+ var FenwickTree = class {
42
+ tree;
43
+ values;
44
+ constructor(e) {
45
+ this.tree = new Float64Array(e + 1), this.values = new Float64Array(e);
46
+ }
47
+ update(e, t) {
48
+ if (!(e < 0 || e >= this.values.length)) for (this.values[e] = this.values[e] + t, e++; e < this.tree.length;) this.tree[e] = this.tree[e] + t, e += e & -e;
49
+ }
50
+ query(e) {
51
+ let t = 0;
52
+ for (; e > 0;) t += this.tree[e] || 0, e -= e & -e;
53
+ return t;
54
+ }
55
+ set(e, t) {
56
+ e < 0 || e >= this.values.length || (this.values[e] = t);
57
+ }
58
+ get length() {
59
+ return this.values.length;
60
+ }
61
+ get(e) {
62
+ return this.values[e] || 0;
63
+ }
64
+ getValues() {
65
+ return this.values;
66
+ }
67
+ findLowerBound(e) {
68
+ let t = 0, n = this.tree.length, r = 1 << Math.floor(Math.log2(n - 1));
69
+ for (; r > 0;) {
70
+ let i = t + r;
71
+ if (i < n) {
72
+ let n = this.tree[i] || 0;
73
+ n <= e && (t = i, e -= n);
74
+ }
75
+ r >>= 1;
76
+ }
77
+ return t;
78
+ }
79
+ rebuild() {
80
+ this.tree.fill(0);
81
+ for (let e = 0; e < this.values.length; e++) this.tree[e + 1] = this.values[e] || 0;
82
+ for (let e = 1; e < this.tree.length; e++) {
83
+ let t = e + (e & -e);
84
+ t < this.tree.length && (this.tree[t] = this.tree[t] + this.tree[e]);
85
+ }
86
+ }
87
+ resize(e) {
88
+ if (e === this.values.length) return;
89
+ let t = new Float64Array(e);
90
+ t.set(this.values.subarray(0, Math.min(e, this.values.length))), this.values = t, this.tree = new Float64Array(e + 1), this.rebuild();
91
+ }
92
+ shift(e) {
93
+ if (e === 0) return;
94
+ let t = this.values.length, n = new Float64Array(t);
95
+ e > 0 ? n.set(this.values.subarray(0, Math.min(t - e, this.values.length)), e) : n.set(this.values.subarray(-e)), this.values = n, this.rebuild();
96
+ }
97
+ };
98
+ const BROWSER_MAX_SIZE = 1e7;
99
+ function isWindow(e) {
100
+ return e === null || e === document.documentElement || typeof window < "u" && e === window;
126
101
  }
127
- const bt = 1e7;
128
- function zl(a) {
129
- return a === null || a === document.documentElement || typeof window < "u" && a === window;
102
+ function isBody(e) {
103
+ return typeof e == "object" && !!e && "tagName" in e && e.tagName === "BODY";
130
104
  }
131
- function Ml(a) {
132
- return a != null && typeof a == "object" && "tagName" in a && a.tagName === "BODY";
105
+ function isWindowLike(e) {
106
+ return isWindow(e) || isBody(e);
133
107
  }
134
- function Pl(a) {
135
- return zl(a) || Ml(a);
108
+ function isElement(e) {
109
+ return e != null && "getBoundingClientRect" in e;
136
110
  }
137
- function Zt(a) {
138
- return a != null && "getBoundingClientRect" in a;
111
+ function isScrollableElement(e) {
112
+ return e != null && "scrollLeft" in e;
139
113
  }
140
- function Jt(a) {
141
- return a != null && "scrollLeft" in a;
114
+ function scrollTo(e, t) {
115
+ isWindow(e) ? window.scrollTo(t) : e != null && isScrollableElement(e) && (typeof e.scrollTo == "function" ? e.scrollTo(t) : (t.left !== void 0 && (e.scrollLeft = t.left), t.top !== void 0 && (e.scrollTop = t.top)));
142
116
  }
143
- function yt(a) {
144
- return typeof a == "object" && a != null && ("align" in a || "behavior" in a || "isCorrection" in a);
117
+ function isScrollToIndexOptions(e) {
118
+ return typeof e == "object" && !!e && ("align" in e || "behavior" in e || "isCorrection" in e);
145
119
  }
146
- function lt(a, e) {
147
- return typeof a == "object" && a !== null ? a.x || 0 : (e === "horizontal" || e === "both") && a || 0;
120
+ function getPaddingX(e, t) {
121
+ return typeof e == "object" && e ? e.x || 0 : (t === "horizontal" || t === "both") && e || 0;
148
122
  }
149
- function at(a, e) {
150
- return typeof a == "object" && a !== null ? a.y || 0 : (e === "vertical" || e === "both") && a || 0;
123
+ function getPaddingY(e, t) {
124
+ return typeof e == "object" && e ? e.y || 0 : (t === "vertical" || t === "both") && e || 0;
151
125
  }
152
- function ml({
153
- scrollPos: a,
154
- containerSize: e,
155
- count: i,
156
- bufferBefore: t,
157
- bufferAfter: s,
158
- gap: d,
159
- fixedSize: S,
160
- findLowerBound: w,
161
- query: m
162
- }) {
163
- let z = 0, h = i;
164
- const E = a + e;
165
- if (S !== null) {
166
- const b = S + d;
167
- z = Math.floor(a / b), h = Math.ceil(E / b);
168
- } else
169
- z = w(a), h = w(E), h < i && m(h) < E && h++;
170
- return {
171
- start: Math.max(0, z - t),
172
- end: Math.min(i, h + s)
173
- };
126
+ function calculateGenericRange({ scrollPos: e, containerSize: t, count: n, bufferBefore: r, bufferAfter: i, gap: a, fixedSize: o, findLowerBound: s, query: c }) {
127
+ let l = 0, u = n, d = e + t;
128
+ if (o !== null) {
129
+ let t = o + a;
130
+ l = Math.floor(e / t), u = Math.ceil(d / t);
131
+ } else l = s(e), u = s(d), u < n && c(u) < d && u++;
132
+ return {
133
+ start: Math.max(0, l - r),
134
+ end: Math.min(n, u + i)
135
+ };
174
136
  }
175
- function rl(a, e) {
176
- let i = 0, t = a.length - 1, s;
177
- for (; i <= t; ) {
178
- const d = i + t >>> 1;
179
- a[d] > e ? (s = a[d], t = d - 1) : i = d + 1;
180
- }
181
- return s;
137
+ function findNextStickyIndex(e, t) {
138
+ let n = 0, r = e.length - 1, i;
139
+ for (; n <= r;) {
140
+ let a = n + r >>> 1;
141
+ e[a] > t ? (i = e[a], r = a - 1) : n = a + 1;
142
+ }
143
+ return i;
182
144
  }
183
- function pl(a, e) {
184
- let i = 0, t = a.length - 1, s;
185
- for (; i <= t; ) {
186
- const d = i + t >>> 1;
187
- a[d] < e ? (s = a[d], i = d + 1) : t = d - 1;
188
- }
189
- return s;
145
+ function findPrevStickyIndex(e, t) {
146
+ let n = 0, r = e.length - 1, i;
147
+ for (; n <= r;) {
148
+ let a = n + r >>> 1;
149
+ e[a] < t ? (i = e[a], n = a + 1) : r = a - 1;
150
+ }
151
+ return i;
190
152
  }
191
- function kl({
192
- align: a,
193
- targetPos: e,
194
- itemSize: i,
195
- scrollPos: t,
196
- viewSize: s,
197
- stickyOffsetStart: d,
198
- stickyOffsetEnd: S
199
- }) {
200
- const w = e - d, m = e - (s - S - i);
201
- if (a === "start")
202
- return { target: w, effectiveAlign: "start" };
203
- if (a === "center")
204
- return {
205
- target: e - d - (s - d - S - i) / 2,
206
- effectiveAlign: "center"
207
- };
208
- if (a === "end")
209
- return { target: m, effectiveAlign: "end" };
210
- if (Il(e, i, t, s, d, S))
211
- return { target: t, effectiveAlign: "auto" };
212
- const z = s - d - S;
213
- return i <= z ? e < t + d ? {
214
- target: w,
215
- effectiveAlign: "start"
216
- } : {
217
- target: m,
218
- effectiveAlign: "end"
219
- } : Math.abs(w - t) < Math.abs(m - t) ? {
220
- target: w,
221
- effectiveAlign: "start"
222
- } : {
223
- target: m,
224
- effectiveAlign: "end"
225
- };
153
+ function calculateAxisAlignment({ align: e, targetPos: t, itemSize: n, scrollPos: r, viewSize: i, stickyOffsetStart: a, stickyOffsetEnd: o }) {
154
+ let s = t - a, c = t - (i - o - n);
155
+ return e === "start" ? {
156
+ target: s,
157
+ effectiveAlign: "start"
158
+ } : e === "center" ? {
159
+ target: t - a - (i - a - o - n) / 2,
160
+ effectiveAlign: "center"
161
+ } : e === "end" ? {
162
+ target: c,
163
+ effectiveAlign: "end"
164
+ } : isItemVisible(t, n, r, i, a, o) ? {
165
+ target: r,
166
+ effectiveAlign: "auto"
167
+ } : n <= i - a - o ? t < r + a ? {
168
+ target: s,
169
+ effectiveAlign: "start"
170
+ } : {
171
+ target: c,
172
+ effectiveAlign: "end"
173
+ } : Math.abs(s - r) < Math.abs(c - r) ? {
174
+ target: s,
175
+ effectiveAlign: "start"
176
+ } : {
177
+ target: c,
178
+ effectiveAlign: "end"
179
+ };
226
180
  }
227
- function Rt(a, e, i, t) {
228
- return a <= 0 ? 0 : e !== null ? Math.max(0, a * (e + i) - i) : Math.max(0, t(a) - i);
181
+ function calculateAxisSize(e, t, n, r) {
182
+ return e <= 0 ? 0 : t === null ? Math.max(0, r(e) - n) : Math.max(0, e * (t + n) - n);
229
183
  }
230
- function ul({
231
- index: a,
232
- align: e,
233
- viewSize: i,
234
- scrollPos: t,
235
- fixedSize: s,
236
- gap: d,
237
- query: S,
238
- getSize: w,
239
- stickyIndices: m,
240
- stickyStart: z,
241
- stickyEnd: h = 0
242
- }) {
243
- let E = z;
244
- if (m && m.length > 0) {
245
- const T = pl(m, a);
246
- T !== void 0 && (E += Rt(1, s, 0, () => w(T)));
247
- }
248
- const b = s !== null ? a * (s + d) : S(a), V = s !== null ? s : w(a) - d, { target: X, effectiveAlign: R } = kl({
249
- align: e,
250
- targetPos: b,
251
- itemSize: V,
252
- scrollPos: t,
253
- viewSize: i,
254
- stickyOffsetStart: E,
255
- stickyOffsetEnd: h
256
- });
257
- return { target: X, itemSize: V, effectiveAlign: R };
184
+ function calculateAxisTarget({ index: e, align: t, viewSize: n, scrollPos: r, fixedSize: i, gap: a, query: o, getSize: s, stickyIndices: c, stickyStart: l, stickyEnd: u = 0 }) {
185
+ let d = l;
186
+ if (c && c.length > 0) {
187
+ let t = findPrevStickyIndex(c, e);
188
+ t !== void 0 && (d += calculateAxisSize(1, i, 0, () => s(t)));
189
+ }
190
+ let f = i === null ? o(e) : e * (i + a), p = i === null ? s(e) - a : i, { target: m, effectiveAlign: h } = calculateAxisAlignment({
191
+ align: t,
192
+ targetPos: f,
193
+ itemSize: p,
194
+ scrollPos: r,
195
+ viewSize: n,
196
+ stickyOffsetStart: d,
197
+ stickyOffsetEnd: u
198
+ });
199
+ return {
200
+ target: m,
201
+ itemSize: p,
202
+ effectiveAlign: h
203
+ };
258
204
  }
259
- function Il(a, e, i, t, s = 0, d = 0) {
260
- const S = i + s, w = i + t - d, m = t - s - d;
261
- return e <= m ? a >= S - 0.5 && a + e <= w + 0.5 : a <= S + 0.5 && a + e >= w - 0.5;
205
+ function calculateAxisSticky(e, t, n, r, i, a) {
206
+ if (e <= t) return {
207
+ isActive: !1,
208
+ offset: 0
209
+ };
210
+ let o = findNextStickyIndex(i, r);
211
+ if (o === void 0) return {
212
+ isActive: !0,
213
+ offset: 0
214
+ };
215
+ let s = a(o);
216
+ return e >= s ? {
217
+ isActive: !1,
218
+ offset: 0
219
+ } : {
220
+ isActive: !0,
221
+ offset: Math.max(0, Math.min(n, s - e)) - n
222
+ };
262
223
  }
263
- function ct(a, e, i) {
264
- return (a - e) * i;
224
+ function isItemVisible(e, t, n, r, i = 0, a = 0) {
225
+ let o = n + i, s = n + r - a;
226
+ return t <= r - i - a ? e >= o - .5 && e + t <= s + .5 : e <= o + .5 && e + t >= s - .5;
265
227
  }
266
- function Ht(a, e, i) {
267
- return a / i + e;
228
+ function displayToVirtual(e, t, n) {
229
+ return (e - t) * n;
268
230
  }
269
- function sl({
270
- rowIndex: a,
271
- colIndex: e,
272
- options: i,
273
- direction: t,
274
- viewportWidth: s,
275
- viewportHeight: d,
276
- totalWidth: S,
277
- totalHeight: w,
278
- gap: m,
279
- columnGap: z,
280
- fixedSize: h,
281
- fixedWidth: E,
282
- relativeScrollX: b,
283
- relativeScrollY: V,
284
- getItemSizeY: X,
285
- getItemSizeX: R,
286
- getItemQueryY: T,
287
- getItemQueryX: $,
288
- getColumnSize: L,
289
- getColumnQuery: k,
290
- scaleX: C,
291
- scaleY: W,
292
- hostOffsetX: P,
293
- hostOffsetY: x,
294
- stickyIndices: q,
295
- stickyStartX: H = 0,
296
- stickyStartY: K = 0,
297
- stickyEndX: Q = 0,
298
- stickyEndY: Z = 0,
299
- flowPaddingStartX: Y = 0,
300
- flowPaddingStartY: re = 0,
301
- paddingStartX: de = 0,
302
- paddingStartY: G = 0,
303
- paddingEndX: le = 0,
304
- paddingEndY: Be = 0
305
- }) {
306
- let ue;
307
- yt(i) ? ue = i.align : ue = i;
308
- const wt = (ue && typeof ue == "object" ? ue.x : ue) || "auto", te = (ue && typeof ue == "object" ? ue.y : ue) || "auto";
309
- let Pe = b, ce = V, Le = 0, ae = 0, Te = "auto", ie = "auto";
310
- const ke = C === 1 ? S : bt, fe = W === 1 ? w : bt, _e = Math.max(0, P + ke - s), pe = Math.max(0, x + fe - d), be = (_e - P) * C, ye = (pe - x) * W, Ge = Y + H + de, nt = re + K + G;
311
- if (a != null) {
312
- const ne = ul({
313
- index: a,
314
- align: te,
315
- viewSize: d,
316
- scrollPos: V,
317
- fixedSize: h,
318
- gap: m,
319
- query: T,
320
- getSize: X,
321
- stickyIndices: q,
322
- stickyStart: K + G,
323
- stickyEnd: Z + Be
324
- });
325
- ce = ne.target + nt, ae = ne.itemSize, ie = ne.effectiveAlign;
326
- }
327
- if (e != null) {
328
- const ne = t === "both", Ie = ul({
329
- index: e,
330
- align: wt,
331
- viewSize: s,
332
- scrollPos: b,
333
- fixedSize: ne ? E : h,
334
- gap: ne || t === "horizontal" ? z : m,
335
- query: ne ? k : $,
336
- getSize: ne ? L : R,
337
- stickyIndices: q,
338
- stickyStart: H + de,
339
- stickyEnd: Q + le
340
- });
341
- Pe = Ie.target + Ge, Le = Ie.itemSize, Te = Ie.effectiveAlign;
342
- }
343
- return Pe = Math.max(0, Math.min(Pe, be)), ce = Math.max(0, Math.min(ce, ye)), { targetX: Pe, targetY: ce, itemWidth: Le, itemHeight: ae, effectiveAlignX: Te, effectiveAlignY: ie };
231
+ function virtualToDisplay(e, t, n) {
232
+ return e / n + t;
344
233
  }
345
- function Rl({
346
- direction: a,
347
- relativeScrollX: e,
348
- relativeScrollY: i,
349
- usableWidth: t,
350
- usableHeight: s,
351
- itemsLength: d,
352
- bufferBefore: S,
353
- bufferAfter: w,
354
- gap: m,
355
- columnGap: z,
356
- fixedSize: h,
357
- findLowerBoundY: E,
358
- findLowerBoundX: b,
359
- queryY: V,
360
- queryX: X
361
- }) {
362
- const R = a === "vertical" || a === "both";
363
- return ml({
364
- scrollPos: R ? i : e,
365
- containerSize: R ? s : t,
366
- count: d,
367
- bufferBefore: S,
368
- bufferAfter: w,
369
- gap: R ? m : z,
370
- fixedSize: h,
371
- findLowerBound: R ? E : b,
372
- query: R ? V : X
373
- });
234
+ function calculateScrollTarget({ rowIndex: e, colIndex: t, options: n, direction: r, viewportWidth: i, viewportHeight: a, totalWidth: o, totalHeight: s, gap: c, columnGap: l, fixedSize: u, fixedWidth: d, relativeScrollX: f, relativeScrollY: p, getItemSizeY: m, getItemSizeX: h, getItemQueryY: g, getItemQueryX: _, getColumnSize: v, getColumnQuery: y, scaleX: b, scaleY: x, hostOffsetX: S, hostOffsetY: C, stickyIndices: w, stickyStartX: T = 0, stickyStartY: E = 0, stickyEndX: D = 0, stickyEndY: ee = 0, flowPaddingStartX: O = 0, flowPaddingStartY: k = 0, paddingStartX: A = 0, paddingStartY: j = 0, paddingEndX: M = 0, paddingEndY: N = 0 }) {
235
+ let P;
236
+ P = isScrollToIndexOptions(n) ? n.align : n;
237
+ let F = (P && typeof P == "object" ? P.x : P) || "auto", ne = (P && typeof P == "object" ? P.y : P) || "auto", re = f, ie = p, ae = 0, oe = 0, se = "auto", ce = "auto", L = b === 1 ? o : BROWSER_MAX_SIZE, le = x === 1 ? s : BROWSER_MAX_SIZE, R = Math.max(0, S + L - i), z = Math.max(0, C + le - a), B = (R - S) * b, V = (z - C) * x, de = O + T + A, fe = k + E + j;
238
+ if (e != null) {
239
+ let t = calculateAxisTarget({
240
+ index: e,
241
+ align: ne,
242
+ viewSize: a,
243
+ scrollPos: p,
244
+ fixedSize: u,
245
+ gap: c,
246
+ query: g,
247
+ getSize: m,
248
+ stickyIndices: w,
249
+ stickyStart: E + j,
250
+ stickyEnd: ee + N
251
+ });
252
+ ie = t.target + fe, oe = t.itemSize, ce = t.effectiveAlign;
253
+ }
254
+ if (t != null) {
255
+ let e = r === "both", n = calculateAxisTarget({
256
+ index: t,
257
+ align: F,
258
+ viewSize: i,
259
+ scrollPos: f,
260
+ fixedSize: e ? d : u,
261
+ gap: e || r === "horizontal" ? l : c,
262
+ query: e ? y : _,
263
+ getSize: e ? v : h,
264
+ stickyIndices: w,
265
+ stickyStart: T + A,
266
+ stickyEnd: D + M
267
+ });
268
+ re = n.target + de, ae = n.itemSize, se = n.effectiveAlign;
269
+ }
270
+ return re = Math.max(0, Math.min(re, B)), ie = Math.max(0, Math.min(ie, V)), {
271
+ targetX: re,
272
+ targetY: ie,
273
+ itemWidth: ae,
274
+ itemHeight: oe,
275
+ effectiveAlignX: se,
276
+ effectiveAlignY: ce
277
+ };
374
278
  }
375
- function Xl({
376
- columnCount: a,
377
- relativeScrollX: e,
378
- usableWidth: i,
379
- colBuffer: t,
380
- fixedWidth: s,
381
- columnGap: d,
382
- findLowerBound: S,
383
- query: w,
384
- totalColsQuery: m
385
- }) {
386
- if (!a)
387
- return { start: 0, end: 0, padStart: 0, padEnd: 0 };
388
- const { start: z, end: h } = ml({
389
- scrollPos: e,
390
- containerSize: i,
391
- count: a,
392
- bufferBefore: t,
393
- bufferAfter: t,
394
- gap: d,
395
- fixedSize: s,
396
- findLowerBound: S,
397
- query: w
398
- }), E = z, b = h, V = s !== null ? E * (s + d) : w(E), X = s !== null ? a * (s + d) - d : Math.max(0, m() - d), R = s !== null ? b * (s + d) - (b > 0 ? d : 0) : w(b) - (b > 0 ? d : 0);
399
- return {
400
- start: E,
401
- end: b,
402
- padStart: V,
403
- padEnd: Math.max(0, X - R)
404
- };
279
+ function calculateRange({ direction: e, relativeScrollX: t, relativeScrollY: n, usableWidth: r, usableHeight: i, itemsLength: a, bufferBefore: o, bufferAfter: s, gap: c, columnGap: l, fixedSize: u, findLowerBoundY: d, findLowerBoundX: f, queryY: p, queryX: m }) {
280
+ let h = e === "vertical" || e === "both";
281
+ return calculateGenericRange({
282
+ scrollPos: h ? n : t,
283
+ containerSize: h ? i : r,
284
+ count: a,
285
+ bufferBefore: o,
286
+ bufferAfter: s,
287
+ gap: h ? c : l,
288
+ fixedSize: u,
289
+ findLowerBound: h ? d : f,
290
+ query: h ? p : m
291
+ });
405
292
  }
406
- function Cl({
407
- index: a,
408
- isSticky: e,
409
- direction: i,
410
- relativeScrollX: t,
411
- relativeScrollY: s,
412
- originalX: d,
413
- originalY: S,
414
- width: w,
415
- height: m,
416
- stickyIndices: z,
417
- fixedSize: h,
418
- fixedWidth: E,
419
- gap: b,
420
- columnGap: V,
421
- getItemQueryY: X,
422
- getItemQueryX: R
423
- }) {
424
- let T = !1;
425
- const $ = { x: 0, y: 0 };
426
- if (!e)
427
- return { isStickyActive: T, stickyOffset: $ };
428
- if ((i === "vertical" || i === "both") && s > S) {
429
- const L = rl(z, a);
430
- if (L !== void 0) {
431
- const k = h !== null ? L * (h + b) : X(L);
432
- s >= k ? T = !1 : (T = !0, $.y = Math.max(0, Math.min(m, k - s)) - m);
433
- } else
434
- T = !0;
435
- }
436
- if ((i === "horizontal" || i === "both" && !T) && t > d) {
437
- const L = rl(z, a);
438
- if (L !== void 0) {
439
- const k = i === "horizontal" ? h !== null ? L * (h + V) : R(L) : E !== null ? L * (E + V) : R(L);
440
- t >= k ? T = !1 : (T = !0, $.x = Math.max(0, Math.min(w, k - t)) - w);
441
- } else
442
- T = !0;
443
- }
444
- return { isStickyActive: T, stickyOffset: $ };
293
+ function calculateColumnRange({ columnCount: e, relativeScrollX: t, usableWidth: n, colBuffer: r, fixedWidth: i, columnGap: a, findLowerBound: o, query: s, totalColsQuery: c }) {
294
+ if (!e) return {
295
+ start: 0,
296
+ end: 0,
297
+ padStart: 0,
298
+ padEnd: 0
299
+ };
300
+ let { start: l, end: u } = calculateGenericRange({
301
+ scrollPos: t,
302
+ containerSize: n,
303
+ count: e,
304
+ bufferBefore: r,
305
+ bufferAfter: r,
306
+ gap: a,
307
+ fixedSize: i,
308
+ findLowerBound: o,
309
+ query: s
310
+ }), d = l, f = u, p = i === null ? s(d) : d * (i + a), m = i === null ? Math.max(0, c() - a) : e * (i + a) - a, h = i === null ? s(f) - (f > 0 ? a : 0) : f * (i + a) - (f > 0 ? a : 0);
311
+ return {
312
+ start: d,
313
+ end: f,
314
+ padStart: p,
315
+ padEnd: Math.max(0, m - h)
316
+ };
445
317
  }
446
- function Yl({
447
- index: a,
448
- direction: e,
449
- fixedSize: i,
450
- gap: t,
451
- columnGap: s,
452
- usableWidth: d,
453
- usableHeight: S,
454
- totalWidth: w,
455
- queryY: m,
456
- queryX: z,
457
- getSizeY: h,
458
- getSizeX: E,
459
- columnRange: b
460
- }) {
461
- let V = 0, X = 0, R = 0, T = 0;
462
- return e === "horizontal" ? (V = i !== null ? a * (i + s) : z(a), R = i !== null ? i : E(a) - s, T = S) : e === "both" && b ? (X = i !== null ? a * (i + t) : m(a), T = i !== null ? i : h(a) - t, V = b.padStart, R = Math.max(0, w - b.padStart - b.padEnd)) : (X = i !== null ? a * (i + t) : m(a), T = i !== null ? i : h(a) - t, R = e === "both" ? w : d), { height: T, width: R, x: V, y: X };
318
+ function calculateStickyItem({ index: e, isSticky: t, direction: n, relativeScrollX: r, relativeScrollY: i, originalX: a, originalY: o, width: s, height: c, stickyIndices: l, fixedSize: u, gap: d, columnGap: f, getItemQueryY: p, getItemQueryX: m }) {
319
+ let h = !1, g = !1, _ = {
320
+ x: 0,
321
+ y: 0
322
+ };
323
+ if (!t) return {
324
+ isStickyActiveX: h,
325
+ isStickyActiveY: g,
326
+ isStickyActive: !1,
327
+ stickyOffset: _
328
+ };
329
+ if (n === "vertical" || n === "both") {
330
+ let t = calculateAxisSticky(i, o, c, e, l, (e) => u === null ? p(e) : e * (u + d));
331
+ g = t.isActive, _.y = t.offset;
332
+ }
333
+ if (n === "horizontal") {
334
+ let t = calculateAxisSticky(r, a, s, e, l, (e) => u === null ? m(e) : e * (u + f));
335
+ t.isActive && (h = !0, _.x = t.offset);
336
+ }
337
+ return {
338
+ isStickyActiveX: h,
339
+ isStickyActiveY: g,
340
+ isStickyActive: h || g,
341
+ stickyOffset: _
342
+ };
463
343
  }
464
- function El({
465
- item: a,
466
- direction: e,
467
- itemSize: i,
468
- containerTag: t,
469
- paddingStartX: s,
470
- paddingStartY: d,
471
- isHydrated: S,
472
- isRtl: w
473
- }) {
474
- const m = e === "vertical", z = e === "horizontal", h = e === "both", E = i == null || i === 0, b = {
475
- blockSize: z ? "100%" : E ? "auto" : `${a.size.height}px`
476
- };
477
- if (m && t === "table" ? b.minInlineSize = "100%" : b.inlineSize = m ? "100%" : E ? "auto" : `${a.size.width}px`, E && (m || (b.minInlineSize = "1px"), z || (b.minBlockSize = "1px")), S) {
478
- const V = w ? -(a.isStickyActive ? a.stickyOffset.x : a.offset.x) : a.isStickyActive ? a.stickyOffset.x : a.offset.x;
479
- a.isStickyActive ? ((m || h) && (b.insetBlockStart = `${d}px`), (z || h) && (b.insetInlineStart = `${s}px`), b.transform = `translate(${V}px, ${a.stickyOffset.y}px)`) : b.transform = `translate(${V}px, ${a.offset.y}px)`;
480
- }
481
- return b;
344
+ function calculateItemPosition({ index: e, direction: t, fixedSize: n, gap: r, columnGap: i, usableWidth: a, usableHeight: o, totalWidth: s, queryY: c, queryX: l, getSizeY: u, getSizeX: d, columnRange: f }) {
345
+ let p = 0, m = 0, h = 0, g = 0;
346
+ return t === "horizontal" ? (p = n === null ? l(e) : e * (n + i), h = n === null ? d(e) - i : n, g = o) : t === "both" && f ? (m = n === null ? c(e) : e * (n + r), g = n === null ? u(e) - r : n, p = f.padStart, h = Math.max(0, s - f.padStart - f.padEnd)) : (m = n === null ? c(e) : e * (n + r), g = n === null ? u(e) - r : n, h = t === "both" ? s : a), {
347
+ height: g,
348
+ width: h,
349
+ x: p,
350
+ y: m
351
+ };
482
352
  }
483
- function Tl({
484
- direction: a,
485
- itemsLength: e,
486
- columnCount: i,
487
- fixedSize: t,
488
- fixedWidth: s,
489
- gap: d,
490
- columnGap: S,
491
- usableWidth: w,
492
- usableHeight: m,
493
- queryY: z,
494
- queryX: h,
495
- queryColumn: E
496
- }) {
497
- const b = a === "both", V = a === "horizontal";
498
- let X = 0, R = 0;
499
- return b ? (X = Rt(i, s, S, E), R = Rt(e, t, d, z)) : V ? (X = Rt(e, t, S, h), R = m) : (X = w, R = Rt(e, t, d, z)), {
500
- width: b ? Math.max(X, w) : X,
501
- height: b ? Math.max(R, m) : R
502
- };
353
+ function calculateItemStyle({ item: e, direction: t, itemSize: n, containerTag: r, paddingStartX: i, paddingStartY: a, isHydrated: o, isRtl: s }) {
354
+ let c = t === "vertical", l = t === "horizontal", u = t === "both", d = n == null || n === 0, f = { blockSize: l ? "100%" : d ? "auto" : `${e.size.height}px` };
355
+ if (c && r === "table" ? f.minInlineSize = "100%" : f.inlineSize = c ? "100%" : d ? "auto" : `${e.size.width}px`, d && (c || (f.minInlineSize = "1px"), l || (f.minBlockSize = "1px")), o) {
356
+ let t = e.isStickyActiveY ?? (e.isStickyActive && (c || u)), n = e.isStickyActiveX ?? (e.isStickyActive && l), r = s ? -(n ? e.stickyOffset.x : e.offset.x) : n ? e.stickyOffset.x : e.offset.x, o = t ? e.stickyOffset.y : e.offset.y;
357
+ e.isStickyActive || e.isStickyActiveX || e.isStickyActiveY ? (f.insetBlockStart = t ? `${a}px` : "auto", f.insetInlineStart = n ? `${i}px` : "auto", f.transform = `translate(${r}px, ${o}px)`) : f.transform = `translate(${r}px, ${e.offset.y}px)`;
358
+ }
359
+ return f;
503
360
  }
504
- const Dt = 40, Lt = 100, cl = 5;
505
- function Ol(a) {
506
- const e = u(() => st(a)), i = ee(0), t = ee(0), s = ee(!1), d = ee(!1), S = ee(!1), w = ee(!1), m = ee(!1), z = ee(0), h = ee(0), E = jt({ x: 0, y: 0 }), b = jt({ x: 0, y: 0 });
507
- let V;
508
- const X = ee(!1), R = ee(0), T = ee(0);
509
- let $ = null;
510
- const L = () => {
511
- if (typeof window > "u")
512
- return;
513
- const l = e.value.container || e.value.hostRef || window, r = Zt(l) ? l : document.documentElement;
514
- (!$ || !("direction" in $)) && ($ = window.getComputedStyle(r));
515
- const o = $.direction === "rtl";
516
- m.value !== o && (m.value = o);
517
- }, k = new Kt(e.value.items?.length || 0), C = new Kt(e.value.items?.length || 0), W = new Kt(e.value.columnCount || 0), P = ee(0);
518
- let x = new Uint8Array(0), q = new Uint8Array(0), H = new Uint8Array(0);
519
- const K = ee(null), Q = ee(!1);
520
- let Z = [];
521
- const Y = u(() => ["vertical", "horizontal", "both"].includes(e.value.direction) ? e.value.direction : "vertical"), re = u(
522
- () => e.value.itemSize === void 0 || e.value.itemSize === null || e.value.itemSize === 0
523
- ), de = u(
524
- () => e.value.columnWidth === void 0 || e.value.columnWidth === null || e.value.columnWidth === 0
525
- ), G = u(
526
- () => typeof e.value.itemSize == "number" && e.value.itemSize > 0 ? e.value.itemSize : null
527
- ), le = u(
528
- () => typeof e.value.columnWidth == "number" && e.value.columnWidth > 0 ? e.value.columnWidth : null
529
- ), Be = u(() => e.value.defaultItemSize || G.value || Dt), ue = u(
530
- () => [...e.value.stickyIndices || []].sort((l, r) => l - r)
531
- ), wt = u(() => new Set(ue.value)), te = u(() => lt(e.value.scrollPaddingStart, e.value.direction)), Pe = u(() => lt(e.value.scrollPaddingEnd, e.value.direction)), ce = u(() => at(e.value.scrollPaddingStart, e.value.direction)), Le = u(() => at(e.value.scrollPaddingEnd, e.value.direction)), ae = u(() => lt(e.value.stickyStart, e.value.direction)), Te = u(() => lt(e.value.stickyEnd, e.value.direction)), ie = u(() => at(e.value.stickyStart, e.value.direction)), ke = u(() => at(e.value.stickyEnd, e.value.direction)), fe = u(() => lt(e.value.flowPaddingStart, e.value.direction)), _e = u(() => lt(e.value.flowPaddingEnd, e.value.direction)), pe = u(() => at(e.value.flowPaddingStart, e.value.direction)), be = u(() => at(e.value.flowPaddingEnd, e.value.direction)), ye = u(() => z.value - (Y.value !== "vertical" ? ae.value + Te.value : 0)), Ge = u(() => h.value - (Y.value !== "horizontal" ? ie.value + ke.value : 0)), nt = u(() => {
532
- if (P.value, !d.value && e.value.ssrRange && !w.value) {
533
- const { start: l = 0, end: r = 0, colStart: o = 0, colEnd: f = 0 } = e.value.ssrRange, p = e.value.columnCount || 0, y = e.value.gap || 0, B = e.value.columnGap || 0;
534
- let F = 0, g = 0;
535
- if (Y.value === "both") {
536
- if (p > 0) {
537
- const I = f || p, U = W.query(I) - W.query(o);
538
- F = Math.max(0, U - (I > o ? B : 0));
539
- }
540
- if (G.value !== null) {
541
- const I = r - l;
542
- g = Math.max(0, I * (G.value + y) - (I > 0 ? y : 0));
543
- } else {
544
- const I = C.query(r) - C.query(l);
545
- g = Math.max(0, I - (r > l ? y : 0));
546
- }
547
- } else if (Y.value === "horizontal") {
548
- if (G.value !== null) {
549
- const I = r - l;
550
- F = Math.max(0, I * (G.value + B) - (I > 0 ? B : 0));
551
- } else {
552
- const I = k.query(r) - k.query(l);
553
- F = Math.max(0, I - (r > l ? B : 0));
554
- }
555
- g = Ge.value;
556
- } else if (F = ye.value, G.value !== null) {
557
- const I = r - l;
558
- g = Math.max(0, I * (G.value + y) - (I > 0 ? y : 0));
559
- } else {
560
- const I = C.query(r) - C.query(l);
561
- g = Math.max(0, I - (r > l ? y : 0));
562
- }
563
- return {
564
- width: Math.max(F, ye.value),
565
- height: Math.max(g, Ge.value)
566
- };
567
- }
568
- return Tl({
569
- direction: Y.value,
570
- itemsLength: e.value.items.length,
571
- columnCount: e.value.columnCount || 0,
572
- fixedSize: G.value,
573
- fixedWidth: le.value,
574
- gap: e.value.gap || 0,
575
- columnGap: e.value.columnGap || 0,
576
- usableWidth: ye.value,
577
- usableHeight: Ge.value,
578
- queryY: (l) => C.query(l),
579
- queryX: (l) => k.query(l),
580
- queryColumn: (l) => W.query(l)
581
- });
582
- }), ne = u(() => Pl(e.value.container)), Oe = u(() => nt.value.width + te.value + Pe.value), Ie = u(() => nt.value.height + ce.value + Le.value), Ve = u(() => fe.value + ae.value + Te.value + _e.value + Oe.value), we = u(() => pe.value + ie.value + ke.value + be.value + Ie.value), Se = jt({
583
- x: u(() => Math.max(0, E.x - (fe.value + ae.value))),
584
- y: u(() => Math.max(0, E.y - (pe.value + ie.value)))
585
- }), ot = u(() => ne.value ? Ve.value : Math.min(Ve.value, bt)), Qe = u(() => ne.value ? we.value : Math.min(we.value, bt)), xt = u(() => ne.value ? Oe.value : Math.max(0, ot.value - (fe.value + ae.value + Te.value + _e.value))), oe = u(() => ne.value ? Ie.value : Math.max(0, Qe.value - (pe.value + ie.value + ke.value + be.value))), he = u(() => {
586
- if (ne.value || Ve.value <= bt)
587
- return 1;
588
- const l = Ve.value - z.value, r = ot.value - z.value;
589
- return r > 0 ? l / r : 1;
590
- }), Ae = u(() => {
591
- if (ne.value || we.value <= bt)
592
- return 1;
593
- const l = we.value - h.value, r = Qe.value - h.value;
594
- return r > 0 ? l / r : 1;
595
- }), Re = u(() => {
596
- if (Y.value === "vertical")
597
- return 0;
598
- const l = fe.value + ae.value + te.value;
599
- return R.value - l;
600
- }), $e = u(() => {
601
- if (Y.value === "horizontal")
602
- return 0;
603
- const l = pe.value + ie.value + ce.value;
604
- return T.value - l;
605
- }), $t = (l) => {
606
- P.value;
607
- const r = e.value.columnGap || 0, o = e.value.columnWidth;
608
- if (typeof o == "number" && o > 0)
609
- return o;
610
- if (Array.isArray(o) && o.length > 0) {
611
- const p = o[l % o.length];
612
- return p != null && p > 0 ? p : e.value.defaultColumnWidth || Lt;
613
- }
614
- if (typeof o == "function")
615
- return o(l);
616
- const f = W.get(l);
617
- return f > 0 ? f - r : e.value.defaultColumnWidth || Lt;
618
- }, Xt = (l) => {
619
- if (P.value, Y.value === "horizontal")
620
- return Ge.value;
621
- const r = e.value.gap || 0, o = e.value.itemSize;
622
- if (typeof o == "number" && o > 0)
623
- return o;
624
- if (typeof o == "function") {
625
- const p = e.value.items[l];
626
- return p !== void 0 ? o(p, l) : e.value.defaultItemSize || Dt;
627
- }
628
- const f = C.get(l);
629
- return f > 0 ? f - r : e.value.defaultItemSize || Dt;
630
- };
631
- function vt(l, r, o) {
632
- const f = typeof o == "object" && o !== null && "isCorrection" in o ? o.isCorrection : !1, p = e.value.container || window, { targetX: y, targetY: B, effectiveAlignX: F, effectiveAlignY: g } = sl({
633
- rowIndex: l,
634
- colIndex: r,
635
- options: o,
636
- direction: Y.value,
637
- viewportWidth: z.value,
638
- viewportHeight: h.value,
639
- totalWidth: Ve.value,
640
- totalHeight: we.value,
641
- gap: e.value.gap || 0,
642
- columnGap: e.value.columnGap || 0,
643
- fixedSize: G.value,
644
- fixedWidth: le.value,
645
- relativeScrollX: Re.value,
646
- relativeScrollY: $e.value,
647
- getItemSizeY: (M) => C.get(M),
648
- getItemSizeX: (M) => k.get(M),
649
- getItemQueryY: (M) => C.query(M),
650
- getItemQueryX: (M) => k.query(M),
651
- getColumnSize: (M) => W.get(M),
652
- getColumnQuery: (M) => W.query(M),
653
- scaleX: he.value,
654
- scaleY: Ae.value,
655
- hostOffsetX: Se.x,
656
- hostOffsetY: Se.y,
657
- stickyIndices: ue.value,
658
- stickyStartX: ae.value,
659
- stickyStartY: ie.value,
660
- stickyEndX: Te.value,
661
- stickyEndY: ke.value,
662
- flowPaddingStartX: fe.value,
663
- flowPaddingStartY: pe.value,
664
- flowPaddingEndX: _e.value,
665
- flowPaddingEndY: be.value,
666
- paddingStartX: te.value,
667
- paddingStartY: ce.value,
668
- paddingEndX: Pe.value,
669
- paddingEndY: Le.value
670
- });
671
- if (!f) {
672
- const M = yt(o) ? o.behavior : void 0;
673
- K.value = {
674
- rowIndex: l,
675
- colIndex: r,
676
- options: {
677
- align: { x: F, y: g },
678
- ...M != null ? { behavior: M } : {}
679
- }
680
- };
681
- }
682
- const I = Ht(y, Se.x, he.value), U = Ht(B, Se.y, Ae.value), D = m.value ? -I : I, J = U;
683
- let Xe;
684
- yt(o) && (Xe = o.behavior);
685
- const N = f ? "auto" : Xe || "smooth";
686
- if (X.value = !0, typeof window < "u" && p === window)
687
- window.scrollTo({
688
- left: r == null ? void 0 : m.value ? D : Math.max(0, D),
689
- top: l == null ? void 0 : Math.max(0, J),
690
- behavior: N
691
- });
692
- else if (Jt(p)) {
693
- const M = {
694
- behavior: N
695
- };
696
- r != null && (M.left = m.value ? D : Math.max(0, D)), l != null && (M.top = Math.max(0, J)), typeof p.scrollTo == "function" ? p.scrollTo(M) : (M.left !== void 0 && (p.scrollLeft = M.left), M.top !== void 0 && (p.scrollTop = M.top));
697
- }
698
- if ((N === "auto" || N === void 0) && (r != null && (i.value = m.value ? D : Math.max(0, D), R.value = y), l != null && (t.value = Math.max(0, J), T.value = B), K.value)) {
699
- const M = K.value.options;
700
- yt(M) ? M.behavior = "auto" : K.value.options = {
701
- align: M,
702
- behavior: "auto"
703
- };
704
- }
705
- }
706
- const je = (l, r, o) => {
707
- const f = e.value.container || window;
708
- X.value = !0, K.value = null;
709
- const p = l != null ? Math.max(0, Math.min(l, Ve.value - z.value)) : null, y = r != null ? Math.max(0, Math.min(r, we.value - h.value)) : null;
710
- p !== null && (R.value = p), y !== null && (T.value = y);
711
- const B = typeof window < "u" && f === window ? window.scrollX : f.scrollLeft, F = typeof window < "u" && f === window ? window.scrollY : f.scrollTop, g = p !== null ? Ht(p, Se.x, he.value) : null, I = y !== null ? Ht(y, Se.y, Ae.value) : null, U = g !== null ? m.value ? -g : g : B, D = I !== null ? I : F;
712
- if (typeof window < "u" && f === window)
713
- window.scrollTo({
714
- left: l != null ? U : void 0,
715
- top: r != null ? D : void 0,
716
- behavior: o?.behavior || "auto"
717
- });
718
- else if (Jt(f)) {
719
- const J = {
720
- behavior: o?.behavior || "auto"
721
- };
722
- l != null && (J.left = U), r != null && (J.top = D), typeof f.scrollTo == "function" ? f.scrollTo(J) : (J.left !== void 0 && (f.scrollLeft = J.left), J.top !== void 0 && (f.scrollTop = J.top));
723
- }
724
- (o?.behavior === "auto" || o?.behavior === void 0) && (l != null && (i.value = U), r != null && (t.value = D));
725
- }, Ft = (l, r) => {
726
- if (k.resize(l), C.resize(l), W.resize(r), q.length !== l) {
727
- const o = new Uint8Array(l);
728
- o.set(q.subarray(0, Math.min(l, q.length))), q = o;
729
- }
730
- if (H.length !== l) {
731
- const o = new Uint8Array(l);
732
- o.set(H.subarray(0, Math.min(l, H.length))), H = o;
733
- }
734
- if (x.length !== r) {
735
- const o = new Uint8Array(r);
736
- o.set(x.subarray(0, Math.min(r, x.length))), x = o;
737
- }
738
- }, it = () => {
739
- const r = e.value.items.length, o = e.value.columnCount || 0, f = e.value.gap || 0, p = e.value.columnGap || 0, y = e.value.columnWidth;
740
- let B = !1, F = !1;
741
- if (o > 0)
742
- for (let g = 0; g < o; g++) {
743
- const I = W.get(g), U = x[g] === 1;
744
- if (!de.value || !U && I === 0) {
745
- let D = 0;
746
- typeof y == "number" && y > 0 ? D = y : Array.isArray(y) && y.length > 0 ? D = y[g % y.length] || e.value.defaultColumnWidth || Lt : typeof y == "function" ? D = y(g) : D = e.value.defaultColumnWidth || Lt;
747
- const J = D + p;
748
- Math.abs(I - J) > 0.5 ? (W.set(g, J), x[g] = de.value ? 0 : 1, B = !0) : de.value || (x[g] = 1);
749
- }
750
- }
751
- for (let g = 0; g < r; g++) {
752
- const I = e.value.items[g], U = k.get(g), D = C.get(g), J = q[g] === 1, Xe = H[g] === 1;
753
- if (Y.value === "horizontal") {
754
- if (!re.value || !J && U === 0) {
755
- const M = (typeof e.value.itemSize == "function" ? e.value.itemSize(I, g) : Be.value) + p;
756
- Math.abs(U - M) > 0.5 ? (k.set(g, M), q[g] = re.value ? 0 : 1, F = !0) : re.value || (q[g] = 1);
757
- }
758
- } else U !== 0 && (k.set(g, 0), q[g] = 0, F = !0);
759
- if (Y.value !== "horizontal") {
760
- if (!re.value || !Xe && D === 0) {
761
- const M = (typeof e.value.itemSize == "function" ? e.value.itemSize(I, g) : Be.value) + f;
762
- Math.abs(D - M) > 0.5 ? (C.set(g, M), H[g] = re.value ? 0 : 1, F = !0) : re.value || (H[g] = 1);
763
- }
764
- } else D !== 0 && (C.set(g, 0), H[g] = 0, F = !0);
765
- }
766
- B && W.rebuild(), F && (k.rebuild(), C.rebuild());
767
- }, Ke = () => {
768
- const l = e.value.items, r = l.length, o = e.value.columnCount || 0;
769
- Ft(r, o);
770
- let f = 0;
771
- if (e.value.restoreScrollOnPrepend && Z.length > 0 && r > Z.length) {
772
- const p = Z[0];
773
- if (p !== void 0) {
774
- for (let y = 1; y <= r - Z.length; y++)
775
- if (l[y] === p) {
776
- f = y;
777
- break;
778
- }
779
- }
780
- }
781
- if (f > 0) {
782
- k.shift(f), C.shift(f), K.value && K.value.rowIndex !== null && K.value.rowIndex !== void 0 && (K.value.rowIndex += f);
783
- const p = new Uint8Array(r), y = new Uint8Array(r);
784
- p.set(q.subarray(0, Math.min(r - f, q.length)), f), y.set(H.subarray(0, Math.min(r - f, H.length)), f), q = p, H = y;
785
- const B = e.value.gap || 0, F = e.value.columnGap || 0;
786
- let g = 0, I = 0;
787
- for (let U = 0; U < f; U++) {
788
- const D = typeof e.value.itemSize == "function" ? e.value.itemSize(l[U], U) : Be.value;
789
- Y.value === "horizontal" ? g += D + F : I += D + B;
790
- }
791
- (g > 0 || I > 0) && kt(() => {
792
- je(
793
- g > 0 ? Re.value + g : null,
794
- I > 0 ? $e.value + I : null,
795
- { behavior: "auto" }
796
- );
797
- });
798
- }
799
- it(), Z = [...l], Q.value = !0, P.value++;
800
- }, He = () => {
801
- if (typeof window > "u")
802
- return;
803
- const l = e.value.container || window, r = (o) => {
804
- const f = o.getBoundingClientRect();
805
- if (l === window)
806
- return {
807
- x: m.value ? document.documentElement.clientWidth - f.right - window.scrollX : f.left + window.scrollX,
808
- y: f.top + window.scrollY
809
- };
810
- if (l === o)
811
- return { x: 0, y: 0 };
812
- if (Zt(l)) {
813
- const p = l.getBoundingClientRect();
814
- return {
815
- x: m.value ? p.right - f.right - l.scrollLeft : f.left - p.left + l.scrollLeft,
816
- y: f.top - p.top + l.scrollTop
817
- };
818
- }
819
- return { x: 0, y: 0 };
820
- };
821
- if (e.value.hostElement) {
822
- const o = r(e.value.hostElement);
823
- (Math.abs(E.x - o.x) > 0.1 || Math.abs(E.y - o.y) > 0.1) && (E.x = o.x, E.y = o.y);
824
- }
825
- if (e.value.hostRef) {
826
- const o = r(e.value.hostRef);
827
- (Math.abs(b.x - o.x) > 0.1 || Math.abs(b.y - o.y) > 0.1) && (b.x = o.x, b.y = o.y);
828
- }
829
- };
830
- Me([
831
- () => e.value.items,
832
- () => e.value.items.length,
833
- () => e.value.direction,
834
- () => e.value.columnCount,
835
- () => e.value.columnWidth,
836
- () => e.value.itemSize,
837
- () => e.value.gap,
838
- () => e.value.columnGap,
839
- () => e.value.defaultItemSize,
840
- () => e.value.defaultColumnWidth
841
- ], Ke, { immediate: !0 }), Me(() => [e.value.container, e.value.hostElement], () => {
842
- He();
843
- }), Me(m, (l, r) => {
844
- if (r === void 0 || l === r || !w.value)
845
- return;
846
- if (Y.value === "vertical") {
847
- He();
848
- return;
849
- }
850
- const o = r ? Math.abs(i.value) : i.value, f = ct(o, E.x, he.value);
851
- He(), je(f, null, { behavior: "auto" });
852
- }, { flush: "sync" }), Me([he, Ae], () => {
853
- !w.value || s.value || X.value || je(R.value, T.value, { behavior: "auto" });
854
- }), Me([() => e.value.items.length, () => e.value.columnCount], ([l, r], [o, f]) => {
855
- kt(() => {
856
- const p = Math.max(0, Ve.value - z.value), y = Math.max(0, we.value - h.value);
857
- R.value > p || T.value > y ? je(
858
- Math.min(R.value, p),
859
- Math.min(T.value, y),
860
- { behavior: "auto" }
861
- ) : (l !== o && Ae.value !== 1 || r !== f && he.value !== 1) && je(R.value, T.value, { behavior: "auto" }), He();
862
- });
863
- });
864
- const rt = (l) => {
865
- const r = e.value.gap || 0, o = e.value.columnGap || 0, f = G.value;
866
- if (Y.value === "horizontal") {
867
- const y = (f || 0) + o;
868
- return f !== null && y > 0 ? Math.floor(l / y) : k.findLowerBound(l);
869
- }
870
- const p = (f || 0) + r;
871
- return f !== null && p > 0 ? Math.floor(l / p) : C.findLowerBound(l);
872
- }, zt = (l) => Y.value === "both" ? W.findLowerBound(l) : Y.value === "horizontal" ? rt(l) : 0, Ct = u(() => {
873
- if (P.value, (!d.value || S.value) && e.value.ssrRange)
874
- return {
875
- start: e.value.ssrRange.start,
876
- end: e.value.ssrRange.end
877
- };
878
- const l = e.value.ssrRange && !s.value ? 0 : e.value.bufferBefore ?? cl, r = e.value.bufferAfter ?? cl;
879
- return Rl({
880
- direction: Y.value,
881
- relativeScrollX: Re.value,
882
- relativeScrollY: $e.value,
883
- usableWidth: ye.value,
884
- usableHeight: Ge.value,
885
- itemsLength: e.value.items.length,
886
- bufferBefore: l,
887
- bufferAfter: r,
888
- gap: e.value.gap || 0,
889
- columnGap: e.value.columnGap || 0,
890
- fixedSize: G.value,
891
- findLowerBoundY: (o) => C.findLowerBound(o),
892
- findLowerBoundX: (o) => k.findLowerBound(o),
893
- queryY: (o) => C.query(o),
894
- queryX: (o) => k.query(o)
895
- });
896
- }), Yt = u(() => {
897
- P.value;
898
- const l = Re.value + ae.value, r = $e.value + ie.value, o = Y.value === "horizontal" ? l : r;
899
- return rt(o);
900
- }), Ze = u(() => {
901
- P.value;
902
- const l = e.value.columnCount || 0;
903
- if (!l)
904
- return { start: 0, end: 0, padStart: 0, padEnd: 0 };
905
- if ((!d.value || S.value) && e.value.ssrRange) {
906
- const { colStart: o = 0, colEnd: f = 0 } = e.value.ssrRange, p = Math.max(0, o), y = Math.min(l, f || l), B = e.value.columnGap || 0, F = le.value !== null ? p * (le.value + B) : W.query(p), g = le.value !== null ? l * (le.value + B) - B : Math.max(0, W.query(l) - B), I = le.value !== null ? y * (le.value + B) - (y > 0 ? B : 0) : W.query(y) - (y > 0 ? B : 0);
907
- return {
908
- start: p,
909
- end: y,
910
- padStart: F,
911
- padEnd: Math.max(0, g - I)
912
- };
913
- }
914
- const r = e.value.ssrRange && !s.value ? 0 : 2;
915
- return Xl({
916
- columnCount: l,
917
- relativeScrollX: Re.value,
918
- usableWidth: ye.value,
919
- colBuffer: r,
920
- fixedWidth: le.value,
921
- columnGap: e.value.columnGap || 0,
922
- findLowerBound: (o) => W.findLowerBound(o),
923
- query: (o) => W.query(o),
924
- totalColsQuery: () => W.query(l)
925
- });
926
- });
927
- let Et = [];
928
- const Tt = u(() => {
929
- P.value;
930
- const { start: l, end: r } = Ct.value, o = [], f = G.value, p = e.value.gap || 0, y = e.value.columnGap || 0, B = ue.value, F = wt.value, g = [];
931
- if (d.value || !e.value.ssrRange) {
932
- const j = Yt.value, Ne = pl(B, j);
933
- Ne !== void 0 && Ne < l && g.push(Ne);
934
- }
935
- for (let j = l; j < r; j++)
936
- g.push(j);
937
- const I = e.value.ssrRange?.start || 0, U = e.value.ssrRange?.colStart || 0;
938
- let D = 0, J = 0;
939
- !d.value && e.value.ssrRange && (J = Y.value !== "horizontal" ? f !== null ? I * (f + p) : C.query(I) : 0, Y.value === "horizontal" ? D = f !== null ? U * (f + y) : k.query(U) : Y.value === "both" && (D = W.query(U)));
940
- const Xe = new Map(Et.map((j) => [j.index, j]));
941
- let N = -1, M = 0, qe = -1, Ce = 0;
942
- const Mt = (j) => j === N + 1 ? (M += k.get(N), N = j, M) : (M = k.query(j), N = j, M), me = (j) => j === qe + 1 ? (Ce += C.get(qe), qe = j, Ce) : (Ce = C.query(j), qe = j, Ce), Ue = fe.value + ae.value + te.value, se = pe.value + ie.value + ce.value, Ye = fe.value + ae.value, ze = pe.value + ie.value, ft = Ze.value;
943
- for (const j of g) {
944
- const Ne = e.value.items[j];
945
- if (Ne === void 0)
946
- continue;
947
- const { x: Ot, y: Pt, width: Ut, height: Nt } = Yl({
948
- index: j,
949
- direction: Y.value,
950
- fixedSize: G.value,
951
- gap: e.value.gap || 0,
952
- columnGap: e.value.columnGap || 0,
953
- usableWidth: ye.value,
954
- usableHeight: Ge.value,
955
- totalWidth: nt.value.width,
956
- queryY: me,
957
- queryX: Mt,
958
- getSizeY: (ut) => C.get(ut),
959
- getSizeX: (ut) => k.get(ut),
960
- columnRange: ft
961
- }), _t = F.has(j), At = Ot, Wt = Pt, { isStickyActive: al, stickyOffset: qt } = Cl({
962
- index: j,
963
- isSticky: _t,
964
- direction: Y.value,
965
- relativeScrollX: Re.value,
966
- relativeScrollY: $e.value,
967
- originalX: At,
968
- originalY: Wt,
969
- width: Ut,
970
- height: Nt,
971
- stickyIndices: B,
972
- fixedSize: G.value,
973
- fixedWidth: le.value,
974
- gap: e.value.gap || 0,
975
- columnGap: e.value.columnGap || 0,
976
- getItemQueryY: (ut) => C.query(ut),
977
- getItemQueryX: (ut) => k.query(ut)
978
- }), nl = d.value ? R.value / he.value + (At + Ue - R.value) - Ye : At - D, ol = d.value ? T.value / Ae.value + (Wt + se - T.value) - ze : Wt - J, De = Xe.get(j);
979
- De && De.item === Ne && De.offset.x === nl && De.offset.y === ol && De.size.width === Ut && De.size.height === Nt && De.isSticky === _t && De.isStickyActive === al && De.stickyOffset.x === qt.x && De.stickyOffset.y === qt.y ? o.push(De) : o.push({
980
- item: Ne,
981
- index: j,
982
- offset: { x: nl, y: ol },
983
- size: { width: Ut, height: Nt },
984
- originalX: At,
985
- originalY: Wt,
986
- isSticky: _t,
987
- isStickyActive: al,
988
- stickyOffset: {
989
- x: qt.x,
990
- y: qt.y
991
- }
992
- });
993
- }
994
- return Et = o, o;
995
- }), n = u(() => {
996
- P.value;
997
- const l = Re.value + ae.value, r = $e.value + ie.value, o = Re.value + (z.value - Te.value) - 1, f = $e.value + (h.value - ke.value) - 1, p = zt(l), y = rt(r), B = rt(Y.value === "horizontal" ? o : f), F = zt(o);
998
- return {
999
- items: Tt.value,
1000
- currentIndex: y,
1001
- currentColIndex: p,
1002
- currentEndIndex: B,
1003
- currentEndColIndex: F,
1004
- scrollOffset: {
1005
- x: R.value,
1006
- y: T.value
1007
- },
1008
- displayScrollOffset: {
1009
- x: m.value ? Math.abs(i.value + b.x) : Math.max(0, i.value - b.x),
1010
- y: Math.max(0, t.value - b.y)
1011
- },
1012
- viewportSize: {
1013
- width: z.value,
1014
- height: h.value
1015
- },
1016
- displayViewportSize: {
1017
- width: z.value,
1018
- height: h.value
1019
- },
1020
- totalSize: {
1021
- width: Ve.value,
1022
- height: we.value
1023
- },
1024
- isScrolling: s.value,
1025
- isProgrammaticScroll: X.value,
1026
- range: Ct.value,
1027
- columnRange: Ze.value
1028
- };
1029
- }), v = () => {
1030
- X.value = !1, K.value = null;
1031
- }, c = (l) => {
1032
- const r = l.target;
1033
- if (typeof window > "u")
1034
- return;
1035
- L(), r === window || r === document ? (i.value = window.scrollX, t.value = window.scrollY, z.value = document.documentElement.clientWidth, h.value = document.documentElement.clientHeight) : Jt(r) && (i.value = r.scrollLeft, t.value = r.scrollTop, z.value = r.clientWidth, h.value = r.clientHeight);
1036
- const o = m.value ? Math.abs(i.value) : i.value;
1037
- R.value = ct(o, Se.x, he.value), T.value = ct(t.value, Se.y, Ae.value), s.value || (X.value || (K.value = null), s.value = !0), clearTimeout(V), V = setTimeout(() => {
1038
- s.value = !1, X.value = !1;
1039
- }, 250);
1040
- }, A = (l) => {
1041
- let r = !1, o = 0, f = 0;
1042
- const p = e.value.gap || 0, y = e.value.columnGap || 0, B = Re.value, F = $e.value, g = rt(Y.value === "horizontal" ? B : F), I = zt(B), U = Y.value === "horizontal", D = Y.value === "both", J = /* @__PURE__ */ new Set(), Xe = /* @__PURE__ */ new Set();
1043
- for (const { index: N, inlineSize: M, blockSize: qe, element: Ce } of l) {
1044
- if (M <= 0 && qe <= 0)
1045
- continue;
1046
- const Mt = re.value || typeof e.value.itemSize == "function";
1047
- if (N >= 0 && !J.has(N) && Mt && qe > 0) {
1048
- if (J.add(N), U && M > 0) {
1049
- const Ue = k.get(N), se = M + y;
1050
- if (!q[N] || Math.abs(se - Ue) > 0.1) {
1051
- const Ye = se - Ue;
1052
- k.update(N, Ye), q[N] = 1, r = !0, N < g && (o += Ye);
1053
- }
1054
- }
1055
- if (!U) {
1056
- const Ue = C.get(N), se = qe + p;
1057
- if (!H[N] || Math.abs(se - Ue) > 0.1) {
1058
- const Ye = se - Ue;
1059
- C.update(N, Ye), H[N] = 1, r = !0, N < g && (f += Ye);
1060
- }
1061
- }
1062
- }
1063
- const me = de.value || typeof e.value.columnWidth == "function";
1064
- if (D && Ce && e.value.columnCount && me && (M > 0 || Ce.dataset.colIndex === void 0)) {
1065
- const Ue = Ce.dataset.colIndex;
1066
- if (Ue != null) {
1067
- const se = Number.parseInt(Ue, 10);
1068
- if (se >= 0 && se < (e.value.columnCount || 0) && !Xe.has(se)) {
1069
- Xe.add(se);
1070
- const Ye = W.get(se), ze = M + y;
1071
- if (!x[se] || Math.abs(Ye - ze) > 0.1) {
1072
- const ft = ze - Ye;
1073
- Math.abs(ft) > 0.1 && (W.update(se, ft), r = !0, se < I && (o += ft)), x[se] = 1;
1074
- }
1075
- }
1076
- } else {
1077
- const se = Ce.dataset.colIndex !== void 0 ? [Ce] : Array.from(Ce.querySelectorAll("[data-col-index]"));
1078
- for (const Ye of se) {
1079
- const ze = Number.parseInt(Ye.dataset.colIndex, 10);
1080
- if (ze >= 0 && ze < (e.value.columnCount || 0) && !Xe.has(ze)) {
1081
- Xe.add(ze);
1082
- const j = Ye.getBoundingClientRect().width, Ne = W.get(ze), Ot = j + y;
1083
- if (!x[ze] || Math.abs(Ne - Ot) > 0.1) {
1084
- const Pt = Ot - Ne;
1085
- Math.abs(Pt) > 0.1 && (W.update(ze, Pt), r = !0, ze < I && (o += Pt)), x[ze] = 1;
1086
- }
1087
- }
1088
- }
1089
- }
1090
- }
1091
- }
1092
- if (r && (P.value++, !(K.value !== null || X.value) && (o !== 0 || f !== 0))) {
1093
- const M = fe.value + ae.value + te.value, qe = pe.value + ie.value + ce.value;
1094
- je(
1095
- o !== 0 ? B + o + M : null,
1096
- f !== 0 ? F + f + qe : null,
1097
- { behavior: "auto" }
1098
- );
1099
- }
1100
- }, ve = (l, r, o, f) => {
1101
- A([{ index: l, inlineSize: r, blockSize: o, element: f }]);
1102
- };
1103
- function We() {
1104
- if (K.value && !S.value) {
1105
- const { rowIndex: l, colIndex: r, options: o } = K.value;
1106
- if (yt(o) && o.behavior === "smooth" && s.value)
1107
- return;
1108
- const p = e.value.container || window, y = typeof window < "u" && p === window ? window.scrollX : p.scrollLeft, B = typeof window < "u" && p === window ? window.scrollY : p.scrollTop, F = m.value ? Math.abs(y) : y, g = B, I = ct(F, 0, he.value), U = ct(g, 0, Ae.value), { targetX: D, targetY: J } = sl({
1109
- rowIndex: l,
1110
- colIndex: r,
1111
- options: o,
1112
- direction: Y.value,
1113
- viewportWidth: z.value,
1114
- viewportHeight: h.value,
1115
- totalWidth: Oe.value,
1116
- totalHeight: Ie.value,
1117
- gap: e.value.gap || 0,
1118
- columnGap: e.value.columnGap || 0,
1119
- fixedSize: G.value,
1120
- fixedWidth: le.value,
1121
- relativeScrollX: I,
1122
- relativeScrollY: U,
1123
- getItemSizeY: (me) => C.get(me),
1124
- getItemSizeX: (me) => k.get(me),
1125
- getItemQueryY: (me) => C.query(me),
1126
- getItemQueryX: (me) => k.query(me),
1127
- getColumnSize: (me) => W.get(me),
1128
- getColumnQuery: (me) => W.query(me),
1129
- scaleX: he.value,
1130
- scaleY: Ae.value,
1131
- hostOffsetX: Se.x,
1132
- hostOffsetY: Se.y,
1133
- stickyIndices: ue.value,
1134
- stickyStartX: ae.value,
1135
- stickyStartY: ie.value,
1136
- stickyEndX: Te.value,
1137
- stickyEndY: ke.value,
1138
- flowPaddingStartX: fe.value,
1139
- flowPaddingStartY: pe.value,
1140
- flowPaddingEndX: _e.value,
1141
- flowPaddingEndY: be.value,
1142
- paddingStartX: te.value,
1143
- paddingStartY: ce.value,
1144
- paddingEndX: Pe.value,
1145
- paddingEndY: Le.value
1146
- }), Xe = 2, N = 2, M = r == null || Math.abs(I - D) < Xe, qe = l == null || Math.abs(U - J) < N, Ce = r == null || r === void 0 || x[r] === 1, Mt = l == null || l === void 0 || H[l] === 1;
1147
- if (M && qe)
1148
- Ce && Mt && !s.value && !X.value && (K.value = null);
1149
- else {
1150
- const me = yt(o) ? { ...o, isCorrection: !0 } : { align: o, isCorrection: !0 };
1151
- vt(l, r, me);
1152
- }
1153
- }
1154
- }
1155
- Me([P, z, h], We), Me(s, (l) => {
1156
- l || We();
1157
- });
1158
- let xe = null, O = null, _;
1159
- const ge = (l) => {
1160
- if (!l || typeof window > "u")
1161
- return;
1162
- const r = l === window ? document : l;
1163
- if (r.addEventListener("scroll", c, { passive: !0 }), $ = null, L(), Zt(l) && (O = new MutationObserver(() => L()), O.observe(l, { attributes: !0, attributeFilter: ["dir", "style"] })), _ = setInterval(L, 1e3), l === window) {
1164
- z.value = document.documentElement.clientWidth, h.value = document.documentElement.clientHeight, i.value = window.scrollX, t.value = window.scrollY;
1165
- const o = () => {
1166
- L(), z.value = document.documentElement.clientWidth, h.value = document.documentElement.clientHeight, He();
1167
- };
1168
- return window.addEventListener("resize", o), () => {
1169
- r.removeEventListener("scroll", c), window.removeEventListener("resize", o), clearInterval(_), $ = null;
1170
- };
1171
- } else
1172
- return z.value = l.clientWidth, h.value = l.clientHeight, i.value = l.scrollLeft, t.value = l.scrollTop, xe = new ResizeObserver((o) => {
1173
- L();
1174
- for (const f of o)
1175
- f.target === l && (z.value = l.clientWidth, h.value = l.clientHeight, He());
1176
- }), xe.observe(l), () => {
1177
- r.removeEventListener("scroll", c), xe?.disconnect(), O?.disconnect(), clearInterval(_), $ = null;
1178
- };
1179
- };
1180
- let Fe;
1181
- return fl() && (hl(() => {
1182
- w.value = !0, L(), Me(() => e.value.container, (l) => {
1183
- Fe?.(), Fe = ge(l || null);
1184
- }, { immediate: !0 }), He(), kt(() => {
1185
- if (He(), e.value.ssrRange || e.value.initialScrollIndex !== void 0) {
1186
- const l = e.value.initialScrollIndex !== void 0 ? e.value.initialScrollIndex : e.value.ssrRange?.start, r = e.value.initialScrollAlign || "start";
1187
- l != null && vt(l, e.value.ssrRange?.colStart, { align: r, behavior: "auto" }), d.value = !0, S.value = !0, kt(() => {
1188
- S.value = !1;
1189
- });
1190
- } else
1191
- d.value = !0;
1192
- });
1193
- }), ll(() => {
1194
- Fe?.();
1195
- })), {
1196
- /**
1197
- * Array of items currently rendered in the DOM with their calculated offsets and sizes.
1198
- * Offsets are in Display Units (DU), sizes are in Virtual Units (VU).
1199
- * @see RenderedItem
1200
- */
1201
- renderedItems: Tt,
1202
- /**
1203
- * Total calculated width of all items including gaps (in VU).
1204
- */
1205
- totalWidth: Ve,
1206
- /**
1207
- * Total calculated height of all items including gaps (in VU).
1208
- */
1209
- totalHeight: we,
1210
- /**
1211
- * Total width to be rendered in the DOM (clamped to browser limits, in DU).
1212
- */
1213
- renderedWidth: ot,
1214
- /**
1215
- * Total height to be rendered in the DOM (clamped to browser limits, in DU).
1216
- */
1217
- renderedHeight: Qe,
1218
- /**
1219
- * Detailed information about the current scroll state.
1220
- * Includes currentIndex, scrollOffset (VU), displayScrollOffset (DU), viewportSize (DU), totalSize (VU), and scrolling status.
1221
- * @see ScrollDetails
1222
- */
1223
- scrollDetails: n,
1224
- /**
1225
- * Helper to get the height of a specific row based on current configuration and measurements.
1226
- *
1227
- * @param index - The row index.
1228
- * @returns The height in VU (excluding gap).
1229
- */
1230
- getRowHeight: Xt,
1231
- /**
1232
- * Helper to get the width of a specific column based on current configuration and measurements.
1233
- *
1234
- * @param index - The column index.
1235
- * @returns The width in VU (excluding gap).
1236
- */
1237
- getColumnWidth: $t,
1238
- /**
1239
- * Helper to get the virtual offset of a specific row.
1240
- *
1241
- * @param index - The row index.
1242
- * @returns The virtual offset in VU.
1243
- */
1244
- getRowOffset: (l) => pe.value + ie.value + ce.value + C.query(l),
1245
- /**
1246
- * Helper to get the virtual offset of a specific column.
1247
- *
1248
- * @param index - The column index.
1249
- * @returns The virtual offset in VU.
1250
- */
1251
- getColumnOffset: (l) => fe.value + ae.value + te.value + W.query(l),
1252
- /**
1253
- * Helper to get the virtual offset of a specific item along the scroll axis.
1254
- *
1255
- * @param index - The item index.
1256
- * @returns The virtual offset in VU.
1257
- */
1258
- getItemOffset: (l) => Y.value === "horizontal" ? fe.value + ae.value + te.value + k.query(l) : pe.value + ie.value + ce.value + C.query(l),
1259
- /**
1260
- * Helper to get the size of a specific item along the scroll axis.
1261
- *
1262
- * @param index - The item index.
1263
- * @returns The size in VU (excluding gap).
1264
- */
1265
- getItemSize: (l) => {
1266
- if (Y.value === "horizontal")
1267
- return Math.max(0, k.get(l) - (e.value.columnGap || 0));
1268
- const r = e.value.itemSize;
1269
- if (typeof r == "number" && r > 0)
1270
- return r;
1271
- if (typeof r == "function") {
1272
- const o = e.value.items[l];
1273
- return o !== void 0 ? r(o, l) : e.value.defaultItemSize || Dt;
1274
- }
1275
- return Math.max(0, C.get(l) - (e.value.gap || 0));
1276
- },
1277
- /**
1278
- * Programmatically scroll to a specific row and/or column.
1279
- *
1280
- * @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.
1281
- * @param colIndex - The column index to scroll to. Pass null to only scroll vertically.
1282
- * @param options - Alignment and behavior options.
1283
- * @see ScrollAlignment
1284
- * @see ScrollToIndexOptions
1285
- */
1286
- scrollToIndex: vt,
1287
- /**
1288
- * Programmatically scroll to a specific pixel offset relative to the content start.
1289
- *
1290
- * @param x - The pixel offset to scroll to on the X axis (VU). Pass null to keep current position.
1291
- * @param y - The pixel offset to scroll to on the Y axis (VU). Pass null to keep current position.
1292
- * @param options - Scroll options (behavior).
1293
- */
1294
- scrollToOffset: je,
1295
- /**
1296
- * Stops any currently active smooth scroll animation and clears pending corrections.
1297
- */
1298
- stopProgrammaticScroll: v,
1299
- /**
1300
- * Updates the stored size of an item. Should be called when an item is measured (e.g., via ResizeObserver).
1301
- *
1302
- * @param index - The item index.
1303
- * @param width - The measured inlineSize (width in DU).
1304
- * @param height - The measured blockSize (height in DU).
1305
- * @param element - The measured element (optional, used for robust grid column detection).
1306
- */
1307
- updateItemSize: ve,
1308
- /**
1309
- * Updates the stored size of multiple items simultaneously.
1310
- *
1311
- * @param updates - Array of measurement updates (sizes in DU).
1312
- */
1313
- updateItemSizes: A,
1314
- /**
1315
- * Recalculates the host element's offset relative to the scroll container.
1316
- * Useful if the container or host moves without a resize event.
1317
- */
1318
- updateHostOffset: He,
1319
- /**
1320
- * Detects the current direction (LTR/RTL) of the scroll container.
1321
- */
1322
- updateDirection: L,
1323
- /**
1324
- * Information about the current visible range of columns and their paddings.
1325
- * @see ColumnRange
1326
- */
1327
- columnRange: Ze,
1328
- /**
1329
- * Resets all dynamic measurements and re-initializes from props.
1330
- * Useful if item sizes have changed externally.
1331
- */
1332
- refresh: () => {
1333
- k.resize(0), C.resize(0), W.resize(0), x.fill(0), q.fill(0), H.fill(0), Ke();
1334
- },
1335
- /**
1336
- * Whether the component has finished its first client-side mount and hydration.
1337
- */
1338
- isHydrated: d,
1339
- /**
1340
- * Whether the container is the window or body.
1341
- */
1342
- isWindowContainer: ne,
1343
- /**
1344
- * Whether the scroll container is in Right-to-Left (RTL) mode.
1345
- */
1346
- isRtl: m,
1347
- /**
1348
- * Coordinate scaling factor for X axis (VU/DU).
1349
- */
1350
- scaleX: he,
1351
- /**
1352
- * Coordinate scaling factor for Y axis (VU/DU).
1353
- */
1354
- scaleY: Ae,
1355
- /**
1356
- * Absolute offset of the component within its container (DU).
1357
- */
1358
- componentOffset: Se,
1359
- /**
1360
- * Physical width of the items wrapper in the DOM (clamped to browser limits, in DU).
1361
- */
1362
- renderedVirtualWidth: xt,
1363
- /**
1364
- * Physical height of the items wrapper in the DOM (clamped to browser limits, in DU).
1365
- */
1366
- renderedVirtualHeight: oe
1367
- };
361
+ function calculateTotalSize({ direction: e, itemsLength: t, columnCount: n, fixedSize: r, fixedWidth: i, gap: a, columnGap: o, usableWidth: s, usableHeight: c, queryY: l, queryX: u, queryColumn: d }) {
362
+ let f = e === "both", p = e === "horizontal", m = 0, h = 0;
363
+ return f ? (m = calculateAxisSize(n, i, o, d), h = calculateAxisSize(t, r, a, l)) : p ? (m = calculateAxisSize(t, r, o, u), h = c) : (m = s, h = calculateAxisSize(t, r, a, l)), {
364
+ width: f ? Math.max(m, s) : m,
365
+ height: f ? Math.max(h, c) : h
366
+ };
1368
367
  }
1369
- function tl(a) {
1370
- const e = u(() => st(a.axis)), i = u(() => st(a.totalSize)), t = u(() => st(a.position)), s = u(() => st(a.viewportSize)), d = u(() => st(a.containerId)), S = u(() => !!st(a.isRtl)), w = u(() => e.value === "horizontal"), m = u(() => i.value <= 0 ? 0 : Math.min(1, s.value / i.value)), z = u(() => {
1371
- const x = i.value - s.value;
1372
- return x <= 0 ? 0 : Math.max(0, Math.min(1, t.value / x));
1373
- }), h = u(() => {
1374
- const q = s.value > 0 ? 32 / s.value : 0.1;
1375
- return Math.max(Math.min(q, 0.1), m.value) * 100;
1376
- }), E = u(() => z.value * (100 - h.value)), b = u(() => w.value ? {
1377
- inlineSize: `${h.value}%`,
1378
- insetInlineStart: `${E.value}%`
1379
- } : {
1380
- blockSize: `${h.value}%`,
1381
- insetBlockStart: `${E.value}%`
1382
- }), V = u(() => {
1383
- const x = s.value, q = "var(--vs-scrollbar-has-cross-gap, var(--vsi-scrollbar-has-cross-gap, 0)) * var(--vs-scrollbar-cross-gap, var(--vsi-scrollbar-size, 8px))";
1384
- return w.value ? {
1385
- inlineSize: `calc(${Math.max(0, x - 4)}px - ${q})`
1386
- } : {
1387
- blockSize: `calc(${Math.max(0, x - 4)}px - ${q})`
1388
- };
1389
- }), X = ee(!1);
1390
- let R = 0, T = 0;
1391
- function $(x) {
1392
- const q = x.currentTarget;
1393
- if (x.target !== q)
1394
- return;
1395
- const H = q.getBoundingClientRect(), K = w.value ? H.width : H.height;
1396
- let Q = 0;
1397
- w.value ? Q = S.value ? H.right - x.clientX : x.clientX - H.left : Q = x.clientY - H.top;
1398
- const Z = h.value / 100 * K, Y = (Q - Z / 2) / (K - Z), re = i.value - s.value;
1399
- let de = Y * re;
1400
- de > re - 1 && (de = re), a.scrollToOffset(Math.max(0, Math.min(re, de)));
1401
- }
1402
- function L(x) {
1403
- X.value = !0, R = w.value ? S.value ? -x.clientX : x.clientX : x.clientY, T = t.value, x.currentTarget.setPointerCapture(x.pointerId), x.preventDefault(), x.stopPropagation();
1404
- }
1405
- function k(x) {
1406
- if (!X.value)
1407
- return;
1408
- const H = x.currentTarget.parentElement;
1409
- if (!H)
1410
- return;
1411
- const Q = (w.value ? S.value ? -x.clientX : x.clientX : x.clientY) - R, Z = H.getBoundingClientRect(), Y = w.value ? Z.width : Z.height, re = h.value / 100 * Y, de = Y - re;
1412
- if (de <= 0)
1413
- return;
1414
- const G = i.value - s.value;
1415
- let le = T + Q / de * G;
1416
- le > G - 1 && (le = G), a.scrollToOffset(Math.max(0, Math.min(G, le)));
1417
- }
1418
- function C(x) {
1419
- X.value && (X.value = !1, x.currentTarget.releasePointerCapture(x.pointerId));
1420
- }
1421
- fl() && ll(() => {
1422
- X.value = !1;
1423
- });
1424
- const W = u(() => ({
1425
- class: [
1426
- "virtual-scrollbar-track",
1427
- `virtual-scrollbar-track--${w.value ? "horizontal" : "vertical"}`
1428
- ],
1429
- style: V.value,
1430
- role: "scrollbar",
1431
- "aria-orientation": e.value,
1432
- "aria-valuenow": Math.round(t.value),
1433
- "aria-valuemin": 0,
1434
- "aria-valuemax": Math.round(i.value - s.value),
1435
- "aria-controls": d.value,
1436
- tabindex: -1,
1437
- onMousedown: $
1438
- })), P = u(() => ({
1439
- class: [
1440
- "virtual-scrollbar-thumb",
1441
- `virtual-scrollbar-thumb--${w.value ? "horizontal" : "vertical"}`,
1442
- {
1443
- "virtual-scrollbar-thumb--active": X.value
1444
- }
1445
- ],
1446
- style: b.value,
1447
- onPointerdown: L,
1448
- onPointermove: k,
1449
- onPointerup: C,
1450
- onPointercancel: C
1451
- }));
1452
- return {
1453
- /** Viewport size as a percentage of total size (0 to 1). */
1454
- viewportPercent: m,
1455
- /** Current scroll position as a percentage of the scrollable range (0 to 1). */
1456
- positionPercent: z,
1457
- /** Calculated thumb size as a percentage of the track size (0 to 100). */
1458
- thumbSizePercent: h,
1459
- /** Calculated thumb position as a percentage of the track size (0 to 100). */
1460
- thumbPositionPercent: E,
1461
- /** Reactive style object for the scrollbar track. */
1462
- trackStyle: V,
1463
- /** Reactive style object for the scrollbar thumb. */
1464
- thumbStyle: b,
1465
- /** Attributes and event listeners to be bound to the track element. */
1466
- trackProps: W,
1467
- /** Attributes and event listeners to be bound to the thumb element. */
1468
- thumbProps: P,
1469
- /** Whether the thumb is currently being dragged. */
1470
- isDragging: X
1471
- };
368
+ function useVirtualScroll(e) {
369
+ let n = computed(() => toValue(e)), r = ref(0), i = ref(0), a = ref(!1), o = ref(!1), c = ref(!1), l = ref(!1), d = ref(!1), f = ref(0), p = ref(0), g = reactive({
370
+ x: 0,
371
+ y: 0
372
+ }), y = reactive({
373
+ x: 0,
374
+ y: 0
375
+ }), b, x = ref(!1), S = ref(0), C = ref(0), T = null, E = () => {
376
+ if (typeof window > "u") return;
377
+ let e = n.value.container || n.value.hostRef || window, t = isElement(e) ? e : document.documentElement;
378
+ (!T || !("direction" in T)) && (T = window.getComputedStyle(t));
379
+ let r = T.direction === "rtl";
380
+ d.value !== r && (d.value = r);
381
+ }, D = new FenwickTree(n.value.items?.length || 0), O = new FenwickTree(n.value.items?.length || 0), k = new FenwickTree(n.value.columnCount || 0), A = ref(0), j = new Uint8Array(), M = new Uint8Array(), P = new Uint8Array(), F = ref(null), ce = ref(!1), L = [], R = computed(() => [
382
+ "vertical",
383
+ "horizontal",
384
+ "both"
385
+ ].includes(n.value.direction) ? n.value.direction : "vertical"), z = computed(() => n.value.itemSize === void 0 || n.value.itemSize === null || n.value.itemSize === 0), ue = computed(() => n.value.columnWidth === void 0 || n.value.columnWidth === null || n.value.columnWidth === 0), B = computed(() => typeof n.value.itemSize == "number" && n.value.itemSize > 0 ? n.value.itemSize : null), V = computed(() => typeof n.value.columnWidth == "number" && n.value.columnWidth > 0 ? n.value.columnWidth : null), _e = computed(() => n.value.defaultItemSize || B.value || 40), ye = computed(() => [...n.value.stickyIndices || []].sort((e, t) => e - t)), be = computed(() => new Set(ye.value)), xe = computed(() => getPaddingX(n.value.scrollPaddingStart, n.value.direction)), Se = computed(() => getPaddingX(n.value.scrollPaddingEnd, n.value.direction)), Ce = computed(() => getPaddingY(n.value.scrollPaddingStart, n.value.direction)), we = computed(() => getPaddingY(n.value.scrollPaddingEnd, n.value.direction)), U = computed(() => getPaddingX(n.value.stickyStart, n.value.direction)), Te = computed(() => getPaddingX(n.value.stickyEnd, n.value.direction)), W = computed(() => getPaddingY(n.value.stickyStart, n.value.direction)), Ee = computed(() => getPaddingY(n.value.stickyEnd, n.value.direction)), G = computed(() => getPaddingX(n.value.flowPaddingStart, n.value.direction)), K = computed(() => getPaddingX(n.value.flowPaddingEnd, n.value.direction)), q = computed(() => getPaddingY(n.value.flowPaddingStart, n.value.direction)), De = computed(() => getPaddingY(n.value.flowPaddingEnd, n.value.direction)), Oe = computed(() => f.value - (R.value === "vertical" ? 0 : U.value + Te.value)), ke = computed(() => p.value - (R.value === "horizontal" ? 0 : W.value + Ee.value)), Ae = computed(() => {
386
+ if (A.value, !o.value && n.value.ssrRange && !l.value) {
387
+ let { start: e = 0, end: t = 0, colStart: r = 0, colEnd: i = 0 } = n.value.ssrRange, a = n.value.columnCount || 0, o = n.value.gap || 0, s = n.value.columnGap || 0, c = 0, l = 0;
388
+ if (R.value === "both") {
389
+ if (a > 0) {
390
+ let e = i || a, t = k.query(e) - k.query(r);
391
+ c = Math.max(0, t - (e > r ? s : 0));
392
+ }
393
+ if (B.value !== null) {
394
+ let n = t - e;
395
+ l = Math.max(0, n * (B.value + o) - (n > 0 ? o : 0));
396
+ } else {
397
+ let n = O.query(t) - O.query(e);
398
+ l = Math.max(0, n - (t > e ? o : 0));
399
+ }
400
+ } else if (R.value === "horizontal") {
401
+ if (B.value !== null) {
402
+ let n = t - e;
403
+ c = Math.max(0, n * (B.value + s) - (n > 0 ? s : 0));
404
+ } else {
405
+ let n = D.query(t) - D.query(e);
406
+ c = Math.max(0, n - (t > e ? s : 0));
407
+ }
408
+ l = ke.value;
409
+ } else if (c = Oe.value, B.value !== null) {
410
+ let n = t - e;
411
+ l = Math.max(0, n * (B.value + o) - (n > 0 ? o : 0));
412
+ } else {
413
+ let n = O.query(t) - O.query(e);
414
+ l = Math.max(0, n - (t > e ? o : 0));
415
+ }
416
+ return {
417
+ width: Math.max(c, Oe.value),
418
+ height: Math.max(l, ke.value)
419
+ };
420
+ }
421
+ return calculateTotalSize({
422
+ direction: R.value,
423
+ itemsLength: n.value.items.length,
424
+ columnCount: n.value.columnCount || 0,
425
+ fixedSize: B.value,
426
+ fixedWidth: V.value,
427
+ gap: n.value.gap || 0,
428
+ columnGap: n.value.columnGap || 0,
429
+ usableWidth: Oe.value,
430
+ usableHeight: ke.value,
431
+ queryY: (e) => O.query(e),
432
+ queryX: (e) => D.query(e),
433
+ queryColumn: (e) => k.query(e)
434
+ });
435
+ }), je = computed(() => isWindowLike(n.value.container)), Me = computed(() => Ae.value.width + xe.value + Se.value), Ne = computed(() => Ae.value.height + Ce.value + we.value), J = computed(() => G.value + U.value + Te.value + K.value + Me.value), Y = computed(() => q.value + W.value + Ee.value + De.value + Ne.value), X = reactive({
436
+ x: computed(() => Math.max(0, g.x - (G.value + U.value))),
437
+ y: computed(() => Math.max(0, g.y - (q.value + W.value)))
438
+ }), Pe = computed(() => je.value ? J.value : Math.min(J.value, BROWSER_MAX_SIZE)), Fe = computed(() => je.value ? Y.value : Math.min(Y.value, BROWSER_MAX_SIZE)), Ie = computed(() => je.value ? Me.value : Math.max(0, Pe.value - (G.value + U.value + Te.value + K.value))), Le = computed(() => je.value ? Ne.value : Math.max(0, Fe.value - (q.value + W.value + Ee.value + De.value))), Z = computed(() => {
439
+ if (je.value || J.value <= 1e7) return 1;
440
+ let e = J.value - f.value, t = Pe.value - f.value;
441
+ return t > 0 ? e / t : 1;
442
+ }), Q = computed(() => {
443
+ if (je.value || Y.value <= 1e7) return 1;
444
+ let e = Y.value - p.value, t = Fe.value - p.value;
445
+ return t > 0 ? e / t : 1;
446
+ }), Re = computed(() => {
447
+ if (R.value === "vertical") return 0;
448
+ let e = G.value + U.value + xe.value;
449
+ return S.value - e;
450
+ }), ze = computed(() => {
451
+ if (R.value === "horizontal") return 0;
452
+ let e = q.value + W.value + Ce.value;
453
+ return C.value - e;
454
+ }), Be = (e) => {
455
+ A.value;
456
+ let t = n.value.columnGap || 0, r = n.value.columnWidth;
457
+ if (typeof r == "number" && r > 0) return r;
458
+ if (Array.isArray(r) && r.length > 0) {
459
+ let t = r[e % r.length];
460
+ return t != null && t > 0 ? t : n.value.defaultColumnWidth || 100;
461
+ }
462
+ if (typeof r == "function") return r(e);
463
+ let i = k.get(e);
464
+ return i > 0 ? i - t : n.value.defaultColumnWidth || 100;
465
+ }, Ve = (e) => {
466
+ if (A.value, R.value === "horizontal") return ke.value;
467
+ let t = n.value.gap || 0, r = n.value.itemSize;
468
+ if (typeof r == "number" && r > 0) return r;
469
+ if (typeof r == "function") {
470
+ let t = n.value.items[e];
471
+ return t === void 0 ? n.value.defaultItemSize || 40 : r(t, e);
472
+ }
473
+ let i = O.get(e);
474
+ return i > 0 ? i - t : n.value.defaultItemSize || 40;
475
+ };
476
+ function He(e, t, a) {
477
+ let o = typeof a == "object" && a && "isCorrection" in a ? a.isCorrection : !1, s = n.value.container || window, { targetX: c, targetY: l, effectiveAlignX: u, effectiveAlignY: m } = calculateScrollTarget({
478
+ rowIndex: e,
479
+ colIndex: t,
480
+ options: a,
481
+ direction: R.value,
482
+ viewportWidth: f.value,
483
+ viewportHeight: p.value,
484
+ totalWidth: J.value,
485
+ totalHeight: Y.value,
486
+ gap: n.value.gap || 0,
487
+ columnGap: n.value.columnGap || 0,
488
+ fixedSize: B.value,
489
+ fixedWidth: V.value,
490
+ relativeScrollX: Re.value,
491
+ relativeScrollY: ze.value,
492
+ getItemSizeY: (e) => O.get(e),
493
+ getItemSizeX: (e) => D.get(e),
494
+ getItemQueryY: (e) => O.query(e),
495
+ getItemQueryX: (e) => D.query(e),
496
+ getColumnSize: (e) => k.get(e),
497
+ getColumnQuery: (e) => k.query(e),
498
+ scaleX: Z.value,
499
+ scaleY: Q.value,
500
+ hostOffsetX: X.x,
501
+ hostOffsetY: X.y,
502
+ stickyIndices: ye.value,
503
+ stickyStartX: U.value,
504
+ stickyStartY: W.value,
505
+ stickyEndX: Te.value,
506
+ stickyEndY: Ee.value,
507
+ flowPaddingStartX: G.value,
508
+ flowPaddingStartY: q.value,
509
+ paddingStartX: xe.value,
510
+ paddingStartY: Ce.value,
511
+ paddingEndX: Se.value,
512
+ paddingEndY: we.value
513
+ });
514
+ if (!o) {
515
+ let n = isScrollToIndexOptions(a) ? a.behavior : void 0;
516
+ F.value = {
517
+ rowIndex: e,
518
+ colIndex: t,
519
+ options: {
520
+ align: {
521
+ x: u,
522
+ y: m
523
+ },
524
+ ...n == null ? {} : { behavior: n }
525
+ }
526
+ };
527
+ }
528
+ let h = virtualToDisplay(c, X.x, Z.value), g = virtualToDisplay(l, X.y, Q.value), _ = d.value ? -h : h, v = g, y;
529
+ isScrollToIndexOptions(a) && (y = a.behavior);
530
+ let b = o ? "auto" : y || "smooth";
531
+ x.value = !0;
532
+ let w = { behavior: b };
533
+ if (t != null && (w.left = d.value ? _ : Math.max(0, _)), e != null && (w.top = Math.max(0, v)), scrollTo(s, w), (b === "auto" || b === void 0) && (t != null && (r.value = d.value ? _ : Math.max(0, _), S.value = c), e != null && (i.value = Math.max(0, v), C.value = l), F.value)) {
534
+ let e = F.value.options;
535
+ isScrollToIndexOptions(e) ? e.behavior = "auto" : F.value.options = {
536
+ align: e,
537
+ behavior: "auto"
538
+ };
539
+ }
540
+ }
541
+ let Ue = (e, t, a) => {
542
+ let o = n.value.container || window;
543
+ x.value = !0, F.value = null;
544
+ let s = e == null ? null : Math.max(0, Math.min(e, J.value - f.value)), c = t == null ? null : Math.max(0, Math.min(t, Y.value - p.value));
545
+ s !== null && (S.value = s), c !== null && (C.value = c);
546
+ let l = typeof window < "u" && o === window ? window.scrollX : o.scrollLeft, u = typeof window < "u" && o === window ? window.scrollY : o.scrollTop, m = s === null ? null : virtualToDisplay(s, X.x, Z.value), h = c === null ? null : virtualToDisplay(c, X.y, Q.value), g = m === null ? l : d.value ? -m : m, _ = h === null ? u : h, v = { behavior: a?.behavior || "auto" };
547
+ e != null && (v.left = g), t != null && (v.top = _), scrollTo(o, v), (a?.behavior === "auto" || a?.behavior === void 0) && (e != null && (r.value = g), t != null && (i.value = _));
548
+ }, We = (e, t) => {
549
+ if (D.resize(e), O.resize(e), k.resize(t), M.length !== e) {
550
+ let t = new Uint8Array(e);
551
+ t.set(M.subarray(0, Math.min(e, M.length))), M = t;
552
+ }
553
+ if (P.length !== e) {
554
+ let t = new Uint8Array(e);
555
+ t.set(P.subarray(0, Math.min(e, P.length))), P = t;
556
+ }
557
+ if (j.length !== t) {
558
+ let e = new Uint8Array(t);
559
+ e.set(j.subarray(0, Math.min(t, j.length))), j = e;
560
+ }
561
+ }, $ = () => {
562
+ let e = n.value.items.length, t = n.value.columnCount || 0, r = n.value.gap || 0, i = n.value.columnGap || 0, a = n.value.columnWidth, o = !1, s = !1;
563
+ if (t > 0) for (let e = 0; e < t; e++) {
564
+ let t = k.get(e), r = j[e] === 1;
565
+ if (!ue.value || !r && t === 0) {
566
+ let r = 0;
567
+ r = typeof a == "number" && a > 0 ? a : Array.isArray(a) && a.length > 0 ? a[e % a.length] || n.value.defaultColumnWidth || 100 : typeof a == "function" ? a(e) : n.value.defaultColumnWidth || 100;
568
+ let s = r + i;
569
+ Math.abs(t - s) > .5 ? (k.set(e, s), j[e] = ue.value ? 0 : 1, o = !0) : ue.value || (j[e] = 1);
570
+ }
571
+ }
572
+ for (let t = 0; t < e; t++) {
573
+ let e = n.value.items[t], a = D.get(t), o = O.get(t), c = M[t] === 1, l = P[t] === 1;
574
+ if (R.value === "horizontal") {
575
+ if (!z.value || !c && a === 0) {
576
+ let r = (typeof n.value.itemSize == "function" ? n.value.itemSize(e, t) : _e.value) + i;
577
+ Math.abs(a - r) > .5 ? (D.set(t, r), M[t] = z.value ? 0 : 1, s = !0) : z.value || (M[t] = 1);
578
+ }
579
+ } else a !== 0 && (D.set(t, 0), M[t] = 0, s = !0);
580
+ if (R.value !== "horizontal") {
581
+ if (!z.value || !l && o === 0) {
582
+ let i = (typeof n.value.itemSize == "function" ? n.value.itemSize(e, t) : _e.value) + r;
583
+ Math.abs(o - i) > .5 ? (O.set(t, i), P[t] = z.value ? 0 : 1, s = !0) : z.value || (P[t] = 1);
584
+ }
585
+ } else o !== 0 && (O.set(t, 0), P[t] = 0, s = !0);
586
+ }
587
+ o && k.rebuild(), s && (D.rebuild(), O.rebuild());
588
+ }, Ge = () => {
589
+ let e = n.value.items, t = e.length;
590
+ We(t, n.value.columnCount || 0);
591
+ let r = 0;
592
+ if (n.value.restoreScrollOnPrepend && L.length > 0 && t > L.length) {
593
+ let n = L[0];
594
+ if (n !== void 0) {
595
+ for (let i = 1; i <= t - L.length; i++) if (e[i] === n) {
596
+ r = i;
597
+ break;
598
+ }
599
+ }
600
+ }
601
+ if (r > 0) {
602
+ D.shift(r), O.shift(r), F.value && F.value.rowIndex !== null && F.value.rowIndex !== void 0 && (F.value.rowIndex += r);
603
+ let i = new Uint8Array(t), a = new Uint8Array(t);
604
+ i.set(M.subarray(0, Math.min(t - r, M.length)), r), a.set(P.subarray(0, Math.min(t - r, P.length)), r), M = i, P = a;
605
+ let o = n.value.gap || 0, s = n.value.columnGap || 0, c = 0, l = 0;
606
+ for (let t = 0; t < r; t++) {
607
+ let r = typeof n.value.itemSize == "function" ? n.value.itemSize(e[t], t) : _e.value;
608
+ R.value === "horizontal" ? c += r + s : l += r + o;
609
+ }
610
+ (c > 0 || l > 0) && nextTick(() => {
611
+ Ue(c > 0 ? Re.value + c : null, l > 0 ? ze.value + l : null, {
612
+ behavior: "auto",
613
+ isCorrection: !0
614
+ });
615
+ });
616
+ }
617
+ $(), L = [...e], ce.value = !0, A.value++;
618
+ }, Ke = () => {
619
+ if (typeof window > "u") return;
620
+ let e = n.value.container || window, t = (t) => {
621
+ let n = t.getBoundingClientRect();
622
+ if (e === window) return {
623
+ x: d.value ? document.documentElement.clientWidth - n.right - window.scrollX : n.left + window.scrollX,
624
+ y: n.top + window.scrollY
625
+ };
626
+ if (e === t) return {
627
+ x: 0,
628
+ y: 0
629
+ };
630
+ if (isElement(e)) {
631
+ let t = e.getBoundingClientRect();
632
+ return {
633
+ x: d.value ? t.right - n.right - e.scrollLeft : n.left - t.left + e.scrollLeft,
634
+ y: n.top - t.top + e.scrollTop
635
+ };
636
+ }
637
+ return {
638
+ x: 0,
639
+ y: 0
640
+ };
641
+ };
642
+ if (n.value.hostElement) {
643
+ let e = t(n.value.hostElement);
644
+ (Math.abs(g.x - e.x) > .1 || Math.abs(g.y - e.y) > .1) && (g.x = e.x, g.y = e.y);
645
+ }
646
+ if (n.value.hostRef) {
647
+ let e = t(n.value.hostRef);
648
+ (Math.abs(y.x - e.x) > .1 || Math.abs(y.y - e.y) > .1) && (y.x = e.x, y.y = e.y);
649
+ }
650
+ };
651
+ watch([
652
+ () => n.value.items,
653
+ () => n.value.items.length,
654
+ () => n.value.direction,
655
+ () => n.value.columnCount,
656
+ () => n.value.columnWidth,
657
+ () => n.value.itemSize,
658
+ () => n.value.gap,
659
+ () => n.value.columnGap,
660
+ () => n.value.defaultItemSize,
661
+ () => n.value.defaultColumnWidth
662
+ ], Ge, { immediate: !0 }), watch(() => [n.value.container, n.value.hostElement], () => {
663
+ Ke();
664
+ }), watch(d, (e, t) => {
665
+ if (t === void 0 || e === t || !l.value) return;
666
+ if (R.value === "vertical") {
667
+ Ke();
668
+ return;
669
+ }
670
+ let n = displayToVirtual(t ? Math.abs(r.value) : r.value, g.x, Z.value);
671
+ Ke(), Ue(n, null, { behavior: "auto" });
672
+ }, { flush: "sync" }), watch([Z, Q], () => {
673
+ !l.value || a.value || x.value || Ue(S.value, C.value, { behavior: "auto" });
674
+ }), watch([() => n.value.items.length, () => n.value.columnCount], ([e, t], [n, r]) => {
675
+ nextTick(() => {
676
+ let i = Math.max(0, J.value - f.value), a = Math.max(0, Y.value - p.value);
677
+ S.value > i || C.value > a ? Ue(Math.min(S.value, i), Math.min(C.value, a), { behavior: "auto" }) : (e !== n && Q.value !== 1 || t !== r && Z.value !== 1) && Ue(S.value, C.value, { behavior: "auto" }), Ke();
678
+ });
679
+ });
680
+ let qe = (e) => {
681
+ let t = n.value.gap || 0, r = n.value.columnGap || 0, i = B.value;
682
+ if (R.value === "horizontal") {
683
+ let t = (i || 0) + r;
684
+ return i !== null && t > 0 ? Math.floor(e / t) : D.findLowerBound(e);
685
+ }
686
+ let a = (i || 0) + t;
687
+ return i !== null && a > 0 ? Math.floor(e / a) : O.findLowerBound(e);
688
+ }, Je = (e) => R.value === "both" ? k.findLowerBound(e) : R.value === "horizontal" ? qe(e) : 0, Ye = computed(() => {
689
+ if (A.value, (!o.value || c.value) && n.value.ssrRange) return {
690
+ start: n.value.ssrRange.start,
691
+ end: n.value.ssrRange.end
692
+ };
693
+ let e = n.value.ssrRange && !a.value ? 0 : n.value.bufferBefore ?? 5, t = n.value.bufferAfter ?? 5;
694
+ return calculateRange({
695
+ direction: R.value,
696
+ relativeScrollX: Re.value,
697
+ relativeScrollY: ze.value,
698
+ usableWidth: Oe.value,
699
+ usableHeight: ke.value,
700
+ itemsLength: n.value.items.length,
701
+ bufferBefore: e,
702
+ bufferAfter: t,
703
+ gap: n.value.gap || 0,
704
+ columnGap: n.value.columnGap || 0,
705
+ fixedSize: B.value,
706
+ findLowerBoundY: (e) => O.findLowerBound(e),
707
+ findLowerBoundX: (e) => D.findLowerBound(e),
708
+ queryY: (e) => O.query(e),
709
+ queryX: (e) => D.query(e)
710
+ });
711
+ }), Xe = computed(() => {
712
+ A.value;
713
+ let e = Re.value + U.value, t = ze.value + W.value;
714
+ return qe(R.value === "horizontal" ? e : t);
715
+ }), Ze = computed(() => {
716
+ A.value;
717
+ let e = n.value.columnCount || 0;
718
+ if (!e) return {
719
+ start: 0,
720
+ end: 0,
721
+ padStart: 0,
722
+ padEnd: 0
723
+ };
724
+ if ((!o.value || c.value) && n.value.ssrRange) {
725
+ let { colStart: t = 0, colEnd: r = 0 } = n.value.ssrRange, i = Math.max(0, t), a = Math.min(e, r || e), o = n.value.columnGap || 0, s = V.value === null ? k.query(i) : i * (V.value + o), c = V.value === null ? Math.max(0, k.query(e) - o) : e * (V.value + o) - o, l = V.value === null ? k.query(a) - (a > 0 ? o : 0) : a * (V.value + o) - (a > 0 ? o : 0);
726
+ return {
727
+ start: i,
728
+ end: a,
729
+ padStart: s,
730
+ padEnd: Math.max(0, c - l)
731
+ };
732
+ }
733
+ let t = n.value.ssrRange && !a.value ? 0 : 2;
734
+ return calculateColumnRange({
735
+ columnCount: e,
736
+ relativeScrollX: Re.value,
737
+ usableWidth: Oe.value,
738
+ colBuffer: t,
739
+ fixedWidth: V.value,
740
+ columnGap: n.value.columnGap || 0,
741
+ findLowerBound: (e) => k.findLowerBound(e),
742
+ query: (e) => k.query(e),
743
+ totalColsQuery: () => k.query(e)
744
+ });
745
+ }), Qe = [], $e = computed(() => {
746
+ A.value;
747
+ let { start: e, end: t } = Ye.value, r = [], i = B.value, a = n.value.gap || 0, s = n.value.columnGap || 0, c = ye.value, l = be.value, u = [];
748
+ if (o.value || !n.value.ssrRange) {
749
+ let t = Xe.value, n = findPrevStickyIndex(c, t);
750
+ n !== void 0 && n < e && u.push(n);
751
+ }
752
+ for (let n = e; n < t; n++) u.push(n);
753
+ let d = n.value.ssrRange?.start || 0, f = n.value.ssrRange?.colStart || 0, p = 0, m = 0;
754
+ !o.value && n.value.ssrRange && (m = R.value === "horizontal" ? 0 : i === null ? O.query(d) : d * (i + a), R.value === "horizontal" ? p = i === null ? D.query(f) : f * (i + s) : R.value === "both" && (p = k.query(f)));
755
+ let h = new Map(Qe.map((e) => [e.index, e])), g = -1, _ = 0, v = -1, y = 0, b = (e) => e === g + 1 ? (_ += D.get(g), g = e, _) : (_ = D.query(e), g = e, _), x = (e) => e === v + 1 ? (y += O.get(v), v = e, y) : (y = O.query(e), v = e, y), w = G.value + U.value + xe.value, T = q.value + W.value + Ce.value, E = G.value + U.value, ee = q.value + W.value, j = Ze.value;
756
+ for (let e of u) {
757
+ let t = n.value.items[e];
758
+ if (t === void 0) continue;
759
+ let { x: i, y: a, width: s, height: u } = calculateItemPosition({
760
+ index: e,
761
+ direction: R.value,
762
+ fixedSize: B.value,
763
+ gap: n.value.gap || 0,
764
+ columnGap: n.value.columnGap || 0,
765
+ usableWidth: Oe.value,
766
+ usableHeight: ke.value,
767
+ totalWidth: Ae.value.width,
768
+ queryY: x,
769
+ queryX: b,
770
+ getSizeY: (e) => O.get(e),
771
+ getSizeX: (e) => D.get(e),
772
+ columnRange: j
773
+ }), d = l.has(e), f = i, g = a, { isStickyActive: _, isStickyActiveX: v, isStickyActiveY: y, stickyOffset: k } = calculateStickyItem({
774
+ index: e,
775
+ isSticky: d,
776
+ direction: R.value,
777
+ relativeScrollX: Re.value,
778
+ relativeScrollY: ze.value,
779
+ originalX: f,
780
+ originalY: g,
781
+ width: s,
782
+ height: u,
783
+ stickyIndices: c,
784
+ fixedSize: B.value,
785
+ fixedWidth: V.value,
786
+ gap: n.value.gap || 0,
787
+ columnGap: n.value.columnGap || 0,
788
+ getItemQueryY: x,
789
+ getItemQueryX: b
790
+ }), A = o.value ? S.value / Z.value + (i + w - S.value) - E : i - p, M = o.value ? C.value / Q.value + (a + T - C.value) - ee : a - m, N = h.get(e);
791
+ N && N.item === t && N.offset.x === A && N.offset.y === M && N.size.width === s && N.size.height === u && N.isSticky === d && N.isStickyActive === _ && N.isStickyActiveX === v && N.isStickyActiveY === y && N.stickyOffset.x === k.x && N.stickyOffset.y === k.y ? r.push(N) : r.push({
792
+ item: t,
793
+ index: e,
794
+ offset: {
795
+ x: A,
796
+ y: M
797
+ },
798
+ size: {
799
+ width: s,
800
+ height: u
801
+ },
802
+ originalX: f,
803
+ originalY: g,
804
+ isSticky: d,
805
+ isStickyActive: _,
806
+ isStickyActiveX: v,
807
+ isStickyActiveY: y,
808
+ stickyOffset: k
809
+ });
810
+ }
811
+ return Qe = r, r;
812
+ }), et = computed(() => {
813
+ A.value;
814
+ let e = Re.value + U.value, t = ze.value + W.value, n = Re.value + (f.value - Te.value) - 1, o = ze.value + (p.value - Ee.value) - 1, s = Je(e), c = qe(t), l = qe(R.value === "horizontal" ? n : o), u = Je(n);
815
+ return {
816
+ items: $e.value,
817
+ currentIndex: c,
818
+ currentColIndex: s,
819
+ currentEndIndex: l,
820
+ currentEndColIndex: u,
821
+ scrollOffset: {
822
+ x: S.value,
823
+ y: C.value
824
+ },
825
+ displayScrollOffset: {
826
+ x: d.value ? Math.abs(r.value + y.x) : Math.max(0, r.value - y.x),
827
+ y: Math.max(0, i.value - y.y)
828
+ },
829
+ viewportSize: {
830
+ width: f.value,
831
+ height: p.value
832
+ },
833
+ displayViewportSize: {
834
+ width: f.value,
835
+ height: p.value
836
+ },
837
+ totalSize: {
838
+ width: J.value,
839
+ height: Y.value
840
+ },
841
+ isScrolling: a.value,
842
+ isProgrammaticScroll: x.value,
843
+ range: Ye.value,
844
+ columnRange: Ze.value
845
+ };
846
+ }), tt = () => {
847
+ x.value = !1, F.value = null;
848
+ }, nt = (e) => {
849
+ let t = e.target;
850
+ typeof window > "u" || (E(), t === window || t === document ? (r.value = window.scrollX, i.value = window.scrollY, f.value = document.documentElement.clientWidth, p.value = document.documentElement.clientHeight) : isScrollableElement(t) && (r.value = t.scrollLeft, i.value = t.scrollTop, f.value = t.clientWidth, p.value = t.clientHeight), S.value = displayToVirtual(d.value ? Math.abs(r.value) : r.value, X.x, Z.value), C.value = displayToVirtual(i.value, X.y, Q.value), a.value ||= (x.value || (F.value = null), !0), clearTimeout(b), b = setTimeout(() => {
851
+ a.value = !1, x.value = !1;
852
+ }, 250));
853
+ }, rt = (e) => {
854
+ let t = !1, r = 0, i = 0, a = n.value.gap || 0, o = n.value.columnGap || 0, s = Re.value, c = ze.value, l = qe(R.value === "horizontal" ? s : c), u = Je(s), d = R.value === "horizontal", f = R.value === "both", p = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), h = (e, i) => {
855
+ if (e >= 0 && e < (n.value.columnCount || 0) && !m.has(e)) {
856
+ m.add(e);
857
+ let n = k.get(e), a = i + o;
858
+ if (!j[e] || Math.abs(n - a) > .1) {
859
+ let i = a - n;
860
+ Math.abs(i) > .1 && (k.update(e, i), t = !0, e < u && (r += i)), j[e] = 1;
861
+ }
862
+ }
863
+ };
864
+ for (let { index: s, inlineSize: c, blockSize: u, element: m } of e) {
865
+ if (c <= 0 && u <= 0) continue;
866
+ let e = z.value || typeof n.value.itemSize == "function";
867
+ if (s >= 0 && !p.has(s) && e && u > 0) {
868
+ if (p.add(s), d && c > 0) {
869
+ let e = D.get(s), n = c + o;
870
+ if (!M[s] || Math.abs(n - e) > .1) {
871
+ let i = n - e;
872
+ D.update(s, i), M[s] = 1, t = !0, s < l && (r += i);
873
+ }
874
+ }
875
+ if (!d) {
876
+ let e = O.get(s), n = u + a;
877
+ if (!P[s] || Math.abs(n - e) > .1) {
878
+ let r = n - e;
879
+ O.update(s, r), P[s] = 1, t = !0, s < l && (i += r);
880
+ }
881
+ }
882
+ }
883
+ let g = ue.value || typeof n.value.columnWidth == "function";
884
+ if (f && m && n.value.columnCount && g && (c > 0 || m.dataset.colIndex === void 0)) {
885
+ let e = m.dataset.colIndex;
886
+ if (e != null) h(Number.parseInt(e, 10), c);
887
+ else {
888
+ let e = Array.from(m.querySelectorAll("[data-col-index]"));
889
+ for (let t of e) h(Number.parseInt(t.dataset.colIndex, 10), t.getBoundingClientRect().width);
890
+ }
891
+ }
892
+ }
893
+ if (t && (A.value++, !(F.value !== null || x.value) && (r !== 0 || i !== 0))) {
894
+ let e = G.value + U.value + xe.value, t = q.value + W.value + Ce.value;
895
+ Ue(r === 0 ? null : s + r + e, i === 0 ? null : c + i + t, { behavior: "auto" });
896
+ }
897
+ }, it = (e, t, n, r) => {
898
+ rt([{
899
+ index: e,
900
+ inlineSize: t,
901
+ blockSize: n,
902
+ element: r
903
+ }]);
904
+ };
905
+ function at() {
906
+ if (F.value && !c.value) {
907
+ let { rowIndex: e, colIndex: t, options: r } = F.value;
908
+ if (isScrollToIndexOptions(r) && r.behavior === "smooth" && a.value) return;
909
+ let i = n.value.container || window, o = typeof window < "u" && i === window ? window.scrollX : i.scrollLeft, s = typeof window < "u" && i === window ? window.scrollY : i.scrollTop, c = d.value ? Math.abs(o) : o, l = s, u = displayToVirtual(c, 0, Z.value), m = displayToVirtual(l, 0, Q.value), { targetX: h, targetY: g } = calculateScrollTarget({
910
+ rowIndex: e,
911
+ colIndex: t,
912
+ options: r,
913
+ direction: R.value,
914
+ viewportWidth: f.value,
915
+ viewportHeight: p.value,
916
+ totalWidth: Me.value,
917
+ totalHeight: Ne.value,
918
+ gap: n.value.gap || 0,
919
+ columnGap: n.value.columnGap || 0,
920
+ fixedSize: B.value,
921
+ fixedWidth: V.value,
922
+ relativeScrollX: u,
923
+ relativeScrollY: m,
924
+ getItemSizeY: (e) => O.get(e),
925
+ getItemSizeX: (e) => D.get(e),
926
+ getItemQueryY: (e) => O.query(e),
927
+ getItemQueryX: (e) => D.query(e),
928
+ getColumnSize: (e) => k.get(e),
929
+ getColumnQuery: (e) => k.query(e),
930
+ scaleX: Z.value,
931
+ scaleY: Q.value,
932
+ hostOffsetX: X.x,
933
+ hostOffsetY: X.y,
934
+ stickyIndices: ye.value,
935
+ stickyStartX: U.value,
936
+ stickyStartY: W.value,
937
+ stickyEndX: Te.value,
938
+ stickyEndY: Ee.value,
939
+ flowPaddingStartX: G.value,
940
+ flowPaddingStartY: q.value,
941
+ paddingStartX: xe.value,
942
+ paddingStartY: Ce.value,
943
+ paddingEndX: Se.value,
944
+ paddingEndY: we.value
945
+ }), _ = t == null || Math.abs(u - h) < 2, v = e == null || Math.abs(m - g) < 2, y = t == null || t === void 0 || j[t] === 1, b = e == null || e === void 0 || P[e] === 1;
946
+ _ && v ? y && b && !a.value && !x.value && (F.value = null) : He(e, t, isScrollToIndexOptions(r) ? {
947
+ ...r,
948
+ isCorrection: !0
949
+ } : {
950
+ align: r,
951
+ isCorrection: !0
952
+ });
953
+ }
954
+ }
955
+ watch([
956
+ A,
957
+ f,
958
+ p
959
+ ], at), watch(a, (e) => {
960
+ e || at();
961
+ });
962
+ let ot = null, st = null, ct, lt = (e) => {
963
+ if (typeof window > "u") return;
964
+ let t = e || window, n = t === window || isElement(t) && t === document.documentElement ? document : t;
965
+ if (n.addEventListener("scroll", nt, { passive: !0 }), T = null, E(), isElement(t) && (st = new MutationObserver(() => E()), st.observe(t, {
966
+ attributes: !0,
967
+ attributeFilter: ["dir", "style"]
968
+ })), ct = setInterval(E, 1e3), t === window) {
969
+ f.value = document.documentElement.clientWidth, p.value = document.documentElement.clientHeight, r.value = window.scrollX, i.value = window.scrollY;
970
+ let e = () => {
971
+ E(), f.value = document.documentElement.clientWidth, p.value = document.documentElement.clientHeight, Ke();
972
+ };
973
+ return window.addEventListener("resize", e), () => {
974
+ n.removeEventListener("scroll", nt), window.removeEventListener("resize", e), st?.disconnect(), clearInterval(ct), T = null;
975
+ };
976
+ } else return f.value = t.clientWidth, p.value = t.clientHeight, r.value = t.scrollLeft, i.value = t.scrollTop, ot = new ResizeObserver(() => {
977
+ E(), f.value = t.clientWidth, p.value = t.clientHeight, Ke();
978
+ }), ot.observe(t), () => {
979
+ n.removeEventListener("scroll", nt), ot?.disconnect(), st?.disconnect(), clearInterval(ct), T = null;
980
+ };
981
+ }, ut;
982
+ return getCurrentInstance() && (onMounted(() => {
983
+ l.value = !0, E(), watch(() => n.value.container, (e) => {
984
+ ut?.(), ut = lt(e || null);
985
+ }, { immediate: !0 }), Ke(), nextTick(() => {
986
+ if (Ke(), n.value.ssrRange || n.value.initialScrollIndex !== void 0) {
987
+ let e = n.value.initialScrollIndex === void 0 ? n.value.ssrRange?.start : n.value.initialScrollIndex, t = n.value.initialScrollAlign || "start";
988
+ e != null && He(e, n.value.ssrRange?.colStart, {
989
+ align: t,
990
+ behavior: "auto"
991
+ }), o.value = !0, c.value = !0, nextTick(() => {
992
+ c.value = !1;
993
+ });
994
+ } else o.value = !0;
995
+ });
996
+ }), onUnmounted(() => {
997
+ ut?.();
998
+ })), {
999
+ renderedItems: $e,
1000
+ totalWidth: J,
1001
+ totalHeight: Y,
1002
+ renderedWidth: Pe,
1003
+ renderedHeight: Fe,
1004
+ scrollDetails: et,
1005
+ getRowHeight: Ve,
1006
+ getColumnWidth: Be,
1007
+ getRowOffset: (e) => q.value + W.value + Ce.value + O.query(e),
1008
+ getColumnOffset: (e) => G.value + U.value + xe.value + k.query(e),
1009
+ getItemOffset: (e) => R.value === "horizontal" ? G.value + U.value + xe.value + D.query(e) : q.value + W.value + Ce.value + O.query(e),
1010
+ getItemSize: (e) => {
1011
+ if (R.value === "horizontal") return Math.max(0, D.get(e) - (n.value.columnGap || 0));
1012
+ let t = n.value.itemSize;
1013
+ if (typeof t == "number" && t > 0) return t;
1014
+ if (typeof t == "function") {
1015
+ let r = n.value.items[e];
1016
+ return r === void 0 ? n.value.defaultItemSize || 40 : t(r, e);
1017
+ }
1018
+ return Math.max(0, O.get(e) - (n.value.gap || 0));
1019
+ },
1020
+ scrollToIndex: He,
1021
+ scrollToOffset: Ue,
1022
+ stopProgrammaticScroll: tt,
1023
+ updateItemSize: it,
1024
+ updateItemSizes: rt,
1025
+ updateHostOffset: Ke,
1026
+ updateDirection: E,
1027
+ columnRange: Ze,
1028
+ refresh: () => {
1029
+ D.resize(0), O.resize(0), k.resize(0), j.fill(0), M.fill(0), P.fill(0), Ge();
1030
+ },
1031
+ isHydrated: o,
1032
+ isWindowContainer: je,
1033
+ isRtl: d,
1034
+ scaleX: Z,
1035
+ scaleY: Q,
1036
+ componentOffset: X,
1037
+ renderedVirtualWidth: Ie,
1038
+ renderedVirtualHeight: Le
1039
+ };
1472
1040
  }
1473
- const vl = /* @__PURE__ */ gl({
1474
- __name: "VirtualScrollbar",
1475
- props: {
1476
- axis: { default: "vertical" },
1477
- totalSize: {},
1478
- position: {},
1479
- viewportSize: {},
1480
- scrollToOffset: {},
1481
- containerId: {},
1482
- isRtl: { type: Boolean, default: !1 }
1483
- },
1484
- emits: ["scrollToOffset"],
1485
- setup(a, { emit: e }) {
1486
- const i = a, t = e, { trackProps: s, thumbProps: d } = tl({
1487
- axis: () => i.axis,
1488
- totalSize: () => i.totalSize,
1489
- position: () => i.position,
1490
- viewportSize: () => i.viewportSize,
1491
- containerId: () => i.containerId,
1492
- isRtl: () => i.isRtl,
1493
- scrollToOffset: (S) => {
1494
- i.scrollToOffset?.(S), t("scrollToOffset", S);
1495
- }
1496
- });
1497
- return (S, w) => (Ee(), It("div", St(il(tt(s))), [
1498
- el("div", St(il(tt(d))), null, 16)
1499
- ], 16));
1500
- }
1501
- }), Al = {
1502
- key: 0,
1503
- class: "virtual-scroll-scrollbar-container"
1504
- }, Wl = {
1505
- key: 0,
1506
- class: "virtual-scroll-debug-info"
1507
- }, dl = 0.95, Gt = 0.1, ql = /* @__PURE__ */ gl({
1508
- __name: "VirtualScroll",
1509
- props: {
1510
- items: {},
1511
- itemSize: {},
1512
- direction: { default: "vertical" },
1513
- bufferBefore: { default: 5 },
1514
- bufferAfter: { default: 5 },
1515
- container: {},
1516
- ssrRange: {},
1517
- columnCount: { default: 0 },
1518
- columnWidth: {},
1519
- containerTag: { default: "div" },
1520
- wrapperTag: { default: "div" },
1521
- itemTag: { default: "div" },
1522
- scrollPaddingStart: { default: 0 },
1523
- scrollPaddingEnd: { default: 0 },
1524
- stickyHeader: { type: Boolean, default: !1 },
1525
- stickyFooter: { type: Boolean, default: !1 },
1526
- gap: { default: 0 },
1527
- columnGap: { default: 0 },
1528
- stickyIndices: { default: () => [] },
1529
- loadDistance: { default: 200 },
1530
- loading: { type: Boolean, default: !1 },
1531
- restoreScrollOnPrepend: { type: Boolean, default: !1 },
1532
- initialScrollIndex: {},
1533
- initialScrollAlign: {},
1534
- defaultItemSize: {},
1535
- defaultColumnWidth: {},
1536
- debug: { type: Boolean, default: !1 },
1537
- virtualScrollbar: { type: Boolean, default: !1 }
1538
- },
1539
- emits: ["scroll", "load", "visibleRangeChange"],
1540
- setup(a, { expose: e, emit: i }) {
1541
- const t = a, s = i, d = yl(), S = ee(null), w = ee(null), m = ee(null), z = ee(null), h = /* @__PURE__ */ new Map(), E = Sl(), b = u(() => `vs-container-${E}`), V = ee(0), X = ee(0), R = u(() => t.container === void 0 ? S.value : t.container), T = u(() => {
1542
- const n = R.value;
1543
- return n === S.value || typeof window < "u" && (n === window || n === null);
1544
- }), $ = u(() => (t.items.length, {
1545
- items: t.items,
1546
- itemSize: t.itemSize,
1547
- direction: t.direction,
1548
- bufferBefore: t.bufferBefore,
1549
- bufferAfter: t.bufferAfter,
1550
- container: R.value,
1551
- hostElement: w.value,
1552
- hostRef: S.value,
1553
- ssrRange: t.ssrRange,
1554
- columnCount: t.columnCount,
1555
- columnWidth: t.columnWidth,
1556
- scrollPaddingStart: {
1557
- x: lt(t.scrollPaddingStart, t.direction),
1558
- y: at(t.scrollPaddingStart, t.direction)
1559
- },
1560
- scrollPaddingEnd: {
1561
- x: lt(t.scrollPaddingEnd, t.direction),
1562
- y: at(t.scrollPaddingEnd, t.direction)
1563
- },
1564
- flowPaddingStart: {
1565
- x: 0,
1566
- y: t.stickyHeader ? 0 : V.value
1567
- },
1568
- flowPaddingEnd: {
1569
- x: 0,
1570
- y: t.stickyFooter ? 0 : X.value
1571
- },
1572
- stickyStart: {
1573
- x: 0,
1574
- y: t.stickyHeader && T.value ? V.value : 0
1575
- },
1576
- stickyEnd: {
1577
- x: 0,
1578
- y: t.stickyFooter && T.value ? X.value : 0
1579
- },
1580
- gap: t.gap,
1581
- columnGap: t.columnGap,
1582
- stickyIndices: t.stickyIndices,
1583
- loadDistance: t.loadDistance,
1584
- loading: t.loading,
1585
- restoreScrollOnPrepend: t.restoreScrollOnPrepend,
1586
- initialScrollIndex: t.initialScrollIndex,
1587
- initialScrollAlign: t.initialScrollAlign,
1588
- defaultItemSize: t.defaultItemSize,
1589
- defaultColumnWidth: t.defaultColumnWidth,
1590
- debug: t.debug
1591
- })), {
1592
- isHydrated: L,
1593
- isRtl: k,
1594
- columnRange: C,
1595
- renderedItems: W,
1596
- scrollDetails: P,
1597
- renderedHeight: x,
1598
- renderedWidth: q,
1599
- getColumnWidth: H,
1600
- getRowHeight: K,
1601
- scrollToIndex: Q,
1602
- scrollToOffset: Z,
1603
- updateHostOffset: Y,
1604
- updateItemSizes: re,
1605
- updateDirection: de,
1606
- getItemOffset: G,
1607
- getRowOffset: le,
1608
- getColumnOffset: Be,
1609
- getItemSize: ue,
1610
- refresh: wt,
1611
- stopProgrammaticScroll: te,
1612
- scaleX: Pe,
1613
- scaleY: ce,
1614
- isWindowContainer: Le,
1615
- componentOffset: ae,
1616
- renderedVirtualWidth: Te,
1617
- renderedVirtualHeight: ie
1618
- } = Ol($), ke = u(() => Pe.value !== 1 || ce.value !== 1), fe = u(() => Le.value ? !1 : t.virtualScrollbar === !0 || Pe.value !== 1 || ce.value !== 1);
1619
- function _e(n) {
1620
- const { displayViewportSize: v } = P.value, c = x.value - v.height;
1621
- if (n >= c - 0.5)
1622
- Z(null, Number.POSITIVE_INFINITY);
1623
- else {
1624
- const A = ct(n, ae.y, ce.value);
1625
- Z(null, A);
1626
- }
1627
- }
1628
- function pe(n) {
1629
- const { displayViewportSize: v } = P.value, c = q.value - v.width;
1630
- if (n >= c - 0.5)
1631
- Z(Number.POSITIVE_INFINITY, null);
1632
- else {
1633
- const A = ct(n, ae.x, Pe.value);
1634
- Z(A, null);
1635
- }
1636
- }
1637
- const be = tl({
1638
- axis: "vertical",
1639
- totalSize: x,
1640
- position: u(() => P.value.displayScrollOffset.y),
1641
- viewportSize: u(() => P.value.displayViewportSize.height),
1642
- scrollToOffset: _e,
1643
- containerId: b,
1644
- isRtl: k
1645
- }), ye = tl({
1646
- axis: "horizontal",
1647
- totalSize: q,
1648
- position: u(() => P.value.displayScrollOffset.x),
1649
- viewportSize: u(() => P.value.displayViewportSize.width),
1650
- scrollToOffset: pe,
1651
- containerId: b,
1652
- isRtl: k
1653
- }), Ge = u(() => t.direction !== "both" ? C.value : {
1654
- ...C.value,
1655
- padStart: 0,
1656
- padEnd: 0
1657
- });
1658
- function nt() {
1659
- wt(), de(), kt(() => {
1660
- const n = [];
1661
- for (const [v, c] of h.entries())
1662
- c && n.push({
1663
- index: v,
1664
- inlineSize: c.offsetWidth,
1665
- blockSize: c.offsetHeight,
1666
- element: c
1667
- });
1668
- n.length > 0 && re(n);
1669
- });
1670
- }
1671
- Me(P, (n, v) => {
1672
- !L.value || !n || (s("scroll", n), (!v || !v.range || !v.columnRange || n.range.start !== v.range.start || n.range.end !== v.range.end || n.columnRange.start !== v.columnRange.start || n.columnRange.end !== v.columnRange.end) && s("visibleRangeChange", {
1673
- start: n.range.start,
1674
- end: n.range.end,
1675
- colStart: n.columnRange.start,
1676
- colEnd: n.columnRange.end
1677
- }), !t.loading && (t.direction !== "horizontal" && n.totalSize && n.totalSize.height - (n.scrollOffset.y + n.viewportSize.height) <= t.loadDistance && s("load", "vertical"), t.direction !== "vertical" && n.totalSize && n.totalSize.width - (n.scrollOffset.x + n.viewportSize.width) <= t.loadDistance && s("load", "horizontal")));
1678
- }), Me(L, (n) => {
1679
- n && P.value?.range && P.value?.columnRange && s("visibleRangeChange", {
1680
- start: P.value.range.start,
1681
- end: P.value.range.end,
1682
- colStart: P.value.columnRange.start,
1683
- colEnd: P.value.columnRange.end
1684
- });
1685
- }, { once: !0 });
1686
- const ne = typeof window > "u" ? null : new ResizeObserver(Y), Oe = typeof window > "u" ? null : new ResizeObserver((n) => {
1687
- const v = [];
1688
- for (const c of n) {
1689
- const A = c.target, ve = Number(A.dataset.index), We = A.dataset.colIndex;
1690
- let xe = c.contentRect.width, O = c.contentRect.height;
1691
- c.borderBoxSize && c.borderBoxSize.length > 0 ? (xe = c.borderBoxSize[0].inlineSize, O = c.borderBoxSize[0].blockSize) : (xe = A.offsetWidth, O = A.offsetHeight), We !== void 0 ? v.push({ index: -1, inlineSize: xe, blockSize: O, element: A }) : Number.isNaN(ve) || v.push({ index: ve, inlineSize: xe, blockSize: O, element: A });
1692
- }
1693
- v.length > 0 && re(v);
1694
- }), Ie = typeof window > "u" ? null : new ResizeObserver(() => {
1695
- V.value = m.value?.offsetHeight || 0, X.value = z.value?.offsetHeight || 0, Y();
1696
- });
1697
- Me(m, (n, v) => {
1698
- v && Ie?.unobserve(v), n ? Ie?.observe(n) : V.value = 0;
1699
- }, { immediate: !0 }), Me(z, (n, v) => {
1700
- v && Ie?.unobserve(v), n ? Ie?.observe(n) : X.value = 0;
1701
- }, { immediate: !0 }), hl(() => {
1702
- S.value && ne?.observe(S.value);
1703
- for (const n of h.values())
1704
- Oe?.observe(n), t.direction === "both" && n.querySelectorAll("[data-col-index]").forEach((v) => Oe?.observe(v));
1705
- }), Me([S, w], ([n], [v]) => {
1706
- v && ne?.unobserve(v), n && ne?.observe(n);
1707
- }), Me([S, ke], ([n, v], [c, A]) => {
1708
- const ve = n !== c || v !== A;
1709
- c && ve && c.removeEventListener("wheel", vt), n && ve && n.addEventListener("wheel", vt, { passive: !v });
1710
- }, { immediate: !0 });
1711
- function Ve(n, v) {
1712
- if (n)
1713
- h.set(v, n), Oe?.observe(n), t.direction === "both" && n.querySelectorAll("[data-col-index]").forEach((c) => Oe?.observe(c));
1714
- else {
1715
- const c = h.get(v);
1716
- c && (Oe?.unobserve(c), t.direction === "both" && c.querySelectorAll("[data-col-index]").forEach((A) => Oe?.unobserve(A)), h.delete(v));
1717
- }
1718
- }
1719
- const we = ee(!1);
1720
- let Se = { x: 0, y: 0 }, ot = { x: 0, y: 0 }, Qe = { x: 0, y: 0 }, xt = 0, oe = { x: 0, y: 0 }, he = null;
1721
- function Ae() {
1722
- const n = () => {
1723
- oe.x *= dl, oe.y *= dl;
1724
- const v = P.value.scrollOffset.x, c = P.value.scrollOffset.y;
1725
- Z(
1726
- v + oe.x * 16,
1727
- // Assuming ~60fps (16ms per frame)
1728
- c + oe.y * 16,
1729
- { behavior: "auto" }
1730
- ), Math.abs(oe.x) > Gt || Math.abs(oe.y) > Gt ? he = requestAnimationFrame(n) : Re();
1731
- };
1732
- he = requestAnimationFrame(n);
1733
- }
1734
- function Re() {
1735
- he !== null && (cancelAnimationFrame(he), he = null), oe = { x: 0, y: 0 };
1736
- }
1737
- function $e(n) {
1738
- te(), Re(), ke.value && (n.pointerType === "mouse" && n.button !== 0 || (we.value = !0, Se = { x: n.clientX, y: n.clientY }, Qe = { x: n.clientX, y: n.clientY }, xt = performance.now(), ot = {
1739
- x: P.value.scrollOffset.x,
1740
- y: P.value.scrollOffset.y
1741
- }, n.currentTarget.setPointerCapture(n.pointerId)));
1742
- }
1743
- function $t(n) {
1744
- if (!we.value)
1745
- return;
1746
- const v = performance.now(), c = v - xt;
1747
- if (c > 0) {
1748
- const We = (Qe.x - n.clientX) / c, xe = (Qe.y - n.clientY) / c;
1749
- oe.x = oe.x * 0.2 + We * 0.8, oe.y = oe.y * 0.2 + xe * 0.8;
1750
- }
1751
- Qe = { x: n.clientX, y: n.clientY }, xt = v;
1752
- const A = Se.x - n.clientX, ve = Se.y - n.clientY;
1753
- requestAnimationFrame(() => {
1754
- Z(
1755
- ot.x + A,
1756
- ot.y + ve,
1757
- { behavior: "auto" }
1758
- );
1759
- });
1760
- }
1761
- function Xt(n) {
1762
- we.value && (we.value = !1, n.currentTarget.releasePointerCapture(n.pointerId), (Math.abs(oe.x) > Gt || Math.abs(oe.y) > Gt) && (Math.abs(oe.x) > 4 * Math.abs(oe.y) ? oe.y = 0 : Math.abs(oe.y) > 4 * Math.abs(oe.x) && (oe.x = 0), Ae()));
1763
- }
1764
- function vt(n) {
1765
- const { scrollOffset: v } = P.value;
1766
- if (te(), ke.value) {
1767
- n.preventDefault();
1768
- let c = n.deltaX, A = n.deltaY;
1769
- n.shiftKey && c === 0 && (c = A, A = 0);
1770
- const ve = v.x + c, We = v.y + A;
1771
- Z(ve, We, { behavior: "auto" });
1772
- }
1773
- }
1774
- function je(n) {
1775
- const { viewportSize: v, scrollOffset: c } = P.value, A = t.direction !== "vertical", ve = t.direction !== "horizontal", We = $.value.stickyStart, xe = $.value.stickyEnd;
1776
- switch (n.key) {
1777
- case "Home": {
1778
- n.preventDefault(), te();
1779
- const O = Math.max(c.x, c.y), _ = t.direction === "horizontal" ? v.width : v.height, ge = O > 10 * _ ? "auto" : "smooth";
1780
- Q(0, 0, { behavior: ge, align: "start" });
1781
- break;
1782
- }
1783
- case "End": {
1784
- n.preventDefault(), te();
1785
- const O = t.items.length - 1, _ = (t.columnCount || 0) > 0 ? t.columnCount - 1 : 0, { totalSize: ge } = P.value, Fe = Math.max(
1786
- ge.width - c.x - v.width,
1787
- ge.height - c.y - v.height
1788
- ), dt = t.direction === "horizontal" ? v.width : v.height, l = Fe > 10 * dt ? "auto" : "smooth";
1789
- t.direction === "both" ? Q(O, _, { behavior: l, align: "end" }) : Q(
1790
- t.direction === "vertical" ? O : 0,
1791
- t.direction === "horizontal" ? O : 0,
1792
- { behavior: l, align: "end" }
1793
- );
1794
- break;
1795
- }
1796
- case "ArrowUp": {
1797
- if (n.preventDefault(), te(), !ve)
1798
- return;
1799
- const { currentIndex: O, scrollOffset: _ } = P.value, ge = _.y + We.y + $.value.scrollPaddingStart.y;
1800
- le(O) < ge - 1 ? Q(O, null, { align: "start" }) : O > 0 && Q(O - 1, null, { align: "start" });
1801
- break;
1802
- }
1803
- case "ArrowDown": {
1804
- if (n.preventDefault(), te(), !ve)
1805
- return;
1806
- const { currentEndIndex: O } = P.value, _ = c.y + v.height - (xe.y + $.value.scrollPaddingEnd.y);
1807
- le(O) + K(O) > _ + 1 ? Q(O, null, { align: "end" }) : O < t.items.length - 1 && Q(O + 1, null, { align: "end" });
1808
- break;
1809
- }
1810
- case "ArrowLeft": {
1811
- if (n.preventDefault(), te(), !A)
1812
- return;
1813
- const { currentColIndex: O, currentEndColIndex: _ } = P.value;
1814
- if (k.value) {
1815
- const ge = c.x + v.width - (xe.x + $.value.scrollPaddingEnd.x);
1816
- if ((t.columnCount ? Be(_) + H(_) : G(_) + ue(_)) > ge + 1)
1817
- Q(null, _, { align: "end" });
1818
- else {
1819
- const dt = t.columnCount ? t.columnCount - 1 : t.items.length - 1;
1820
- _ < dt && Q(null, _ + 1, { align: "end" });
1821
- }
1822
- } else {
1823
- const ge = c.x + We.x + $.value.scrollPaddingStart.x;
1824
- (t.columnCount ? Be(O) : G(O)) < ge - 1 ? Q(null, O, { align: "start" }) : O > 0 && Q(null, O - 1, { align: "start" });
1825
- }
1826
- break;
1827
- }
1828
- case "ArrowRight": {
1829
- if (n.preventDefault(), te(), !A)
1830
- return;
1831
- const { currentColIndex: O, currentEndColIndex: _ } = P.value;
1832
- if (k.value) {
1833
- const ge = c.x + We.x + $.value.scrollPaddingStart.x;
1834
- (t.columnCount ? Be(O) : G(O)) < ge - 1 ? Q(null, O, { align: "start" }) : O > 0 && Q(null, O - 1, { align: "start" });
1835
- } else {
1836
- const ge = c.x + v.width - (xe.x + $.value.scrollPaddingEnd.x);
1837
- if ((t.columnCount ? Be(_) + H(_) : G(_) + ue(_)) > ge + 1)
1838
- Q(null, _, { align: "end" });
1839
- else {
1840
- const dt = t.columnCount ? t.columnCount - 1 : t.items.length - 1;
1841
- _ < dt && Q(null, _ + 1, { align: "end" });
1842
- }
1843
- }
1844
- break;
1845
- }
1846
- case "PageUp":
1847
- n.preventDefault(), te(), Z(
1848
- !ve && A ? c.x - v.width : null,
1849
- ve ? c.y - v.height : null
1850
- );
1851
- break;
1852
- case "PageDown":
1853
- n.preventDefault(), te(), Z(
1854
- !ve && A ? c.x + v.width : null,
1855
- ve ? c.y + v.height : null
1856
- );
1857
- break;
1858
- }
1859
- }
1860
- ll(() => {
1861
- ne?.disconnect(), Oe?.disconnect(), Ie?.disconnect();
1862
- });
1863
- const Ft = u(() => {
1864
- const n = {
1865
- ...t.direction !== "vertical" ? { whiteSpace: "nowrap" } : {}
1866
- };
1867
- return fe.value && (n.overflow = "auto"), ke.value && (n.touchAction = "none"), Le.value ? n : t.containerTag === "table" ? {
1868
- ...n,
1869
- minInlineSize: t.direction === "vertical" ? "100%" : "auto"
1870
- } : n;
1871
- }), it = u(() => {
1872
- if (t.direction === "horizontal")
1873
- return null;
1874
- const { displayViewportSize: n, displayScrollOffset: v } = P.value;
1875
- if (x.value <= n.height)
1876
- return null;
1877
- const c = {
1878
- axis: "vertical",
1879
- totalSize: x.value,
1880
- position: v.y,
1881
- viewportSize: n.height,
1882
- scrollToOffset: _e,
1883
- containerId: b.value,
1884
- isRtl: k.value
1885
- };
1886
- return {
1887
- positionPercent: be.positionPercent.value,
1888
- viewportPercent: be.viewportPercent.value,
1889
- thumbSizePercent: be.thumbSizePercent.value,
1890
- thumbPositionPercent: be.thumbPositionPercent.value,
1891
- trackProps: be.trackProps.value,
1892
- thumbProps: be.thumbProps.value,
1893
- scrollbarProps: c,
1894
- isDragging: be.isDragging.value
1895
- };
1896
- }), Ke = u(() => {
1897
- if (t.direction === "vertical")
1898
- return null;
1899
- const { displayViewportSize: n, displayScrollOffset: v } = P.value;
1900
- if (q.value <= n.width)
1901
- return null;
1902
- const c = {
1903
- axis: "horizontal",
1904
- totalSize: q.value,
1905
- position: v.x,
1906
- viewportSize: n.width,
1907
- scrollToOffset: pe,
1908
- containerId: b.value,
1909
- isRtl: k.value
1910
- };
1911
- return {
1912
- positionPercent: ye.positionPercent.value,
1913
- viewportPercent: ye.viewportPercent.value,
1914
- thumbSizePercent: ye.thumbSizePercent.value,
1915
- thumbPositionPercent: ye.thumbPositionPercent.value,
1916
- trackProps: ye.trackProps.value,
1917
- thumbProps: ye.thumbProps.value,
1918
- scrollbarProps: c,
1919
- isDragging: ye.isDragging.value
1920
- };
1921
- }), He = u(() => {
1922
- const n = t.direction === "horizontal", v = t.direction === "vertical", c = t.direction === "both", A = {
1923
- inlineSize: v ? "100%" : `${Te.value}px`,
1924
- blockSize: n ? "100%" : `${ie.value}px`
1925
- };
1926
- return L.value || (A.display = "flex", A.flexDirection = n ? "row" : "column", (n || c) && t.columnGap && (A.columnGap = `${t.columnGap}px`), (v || c) && t.gap && (A.rowGap = `${t.gap}px`)), A;
1927
- }), rt = u(() => {
1928
- const n = t.direction === "horizontal";
1929
- return {
1930
- display: n ? "inline-block" : "block",
1931
- ...n ? { blockSize: "100%", verticalAlign: "top" } : { inlineSize: "100%" }
1932
- };
1933
- }), zt = u(() => ({
1934
- inlineSize: t.direction === "vertical" ? "1px" : `${Te.value}px`,
1935
- blockSize: t.direction === "horizontal" ? "1px" : `${ie.value}px`
1936
- }));
1937
- function Ct(n) {
1938
- const v = El({
1939
- containerTag: t.containerTag,
1940
- direction: t.direction,
1941
- isHydrated: L.value,
1942
- item: n,
1943
- itemSize: t.itemSize,
1944
- paddingStartX: $.value.scrollPaddingStart.x,
1945
- paddingStartY: $.value.scrollPaddingStart.y,
1946
- isRtl: k.value
1947
- });
1948
- return !L.value && t.direction === "both" && (v.display = "flex", t.columnGap && (v.columnGap = `${t.columnGap}px`)), v;
1949
- }
1950
- const Yt = u(() => t.debug), Ze = u(() => t.containerTag === "table"), Et = u(() => Ze.value ? "thead" : "div"), Tt = u(() => Ze.value ? "tfoot" : "div");
1951
- return e({
1952
- ...bl(t),
1953
- /**
1954
- * Detailed information about the current scroll state.
1955
- * @see ScrollDetails
1956
- * @see useVirtualScroll
1957
- */
1958
- scrollDetails: P,
1959
- /**
1960
- * Information about the current visible range of columns.
1961
- * @see ColumnRange
1962
- * @see useVirtualScroll
1963
- */
1964
- columnRange: C,
1965
- /**
1966
- * Helper to get the width of a specific column.
1967
- * @param index - The column index.
1968
- * @see useVirtualScroll
1969
- */
1970
- getColumnWidth: H,
1971
- /**
1972
- * Helper to get the height of a specific row.
1973
- * @param index - The row index.
1974
- * @see useVirtualScroll
1975
- */
1976
- getRowHeight: K,
1977
- /**
1978
- * Helper to get the virtual offset of a specific row.
1979
- * @param index - The row index.
1980
- * @see useVirtualScroll
1981
- */
1982
- getRowOffset: le,
1983
- /**
1984
- * Helper to get the virtual offset of a specific column.
1985
- * @param index - The column index.
1986
- * @see useVirtualScroll
1987
- */
1988
- getColumnOffset: Be,
1989
- /**
1990
- * Helper to get the virtual offset of a specific item.
1991
- * @param index - The item index.
1992
- * @see useVirtualScroll
1993
- */
1994
- getItemOffset: G,
1995
- /**
1996
- * Helper to get the size of a specific item along the scroll axis.
1997
- * @param index - The item index.
1998
- * @see useVirtualScroll
1999
- */
2000
- getItemSize: ue,
2001
- /**
2002
- * Programmatically scroll to a specific row and/or column.
2003
- *
2004
- * @param rowIndex - The row index to scroll to. Pass null to only scroll horizontally.
2005
- * @param colIndex - The column index to scroll to. Pass null to only scroll vertically.
2006
- * @param options - Alignment and behavior options. Defaults to { align: 'auto', behavior: 'auto' }.
2007
- * @see ScrollAlignment
2008
- * @see ScrollToIndexOptions
2009
- * @see useVirtualScroll
2010
- */
2011
- scrollToIndex: Q,
2012
- /**
2013
- * Programmatically scroll to a specific pixel offset.
2014
- *
2015
- * @param x - The pixel offset to scroll to on the X axis. Pass null to keep current position.
2016
- * @param y - The pixel offset to scroll to on the Y axis. Pass null to keep current position.
2017
- * @param options - Scroll options (behavior). Defaults to { behavior: 'auto' }.
2018
- * @see useVirtualScroll
2019
- */
2020
- scrollToOffset: Z,
2021
- /**
2022
- * Resets all dynamic measurements and re-initializes from props.
2023
- * @see useVirtualScroll
2024
- */
2025
- refresh: nt,
2026
- /**
2027
- * Immediately stops any currently active smooth scroll animation and clears pending corrections.
2028
- * @see useVirtualScroll
2029
- */
2030
- stopProgrammaticScroll: () => {
2031
- te(), Re();
2032
- },
2033
- /**
2034
- * Detects the current direction (LTR/RTL) of the scroll container.
2035
- */
2036
- updateDirection: de,
2037
- /**
2038
- * Whether the scroll container is in Right-to-Left (RTL) mode.
2039
- */
2040
- isRtl: k,
2041
- /**
2042
- * Whether the component has finished its first client-side mount and hydration.
2043
- */
2044
- isHydrated: L,
2045
- /**
2046
- * Coordinate scaling factor for X axis.
2047
- */
2048
- scaleX: Pe,
2049
- /**
2050
- * Coordinate scaling factor for Y axis.
2051
- */
2052
- scaleY: ce,
2053
- /**
2054
- * Physical width of the content in the DOM (clamped to browser limits).
2055
- */
2056
- renderedWidth: q,
2057
- /**
2058
- * Physical height of the content in the DOM (clamped to browser limits).
2059
- */
2060
- renderedHeight: x,
2061
- /**
2062
- * Absolute offset of the component within its container.
2063
- */
2064
- componentOffset: ae,
2065
- /**
2066
- * Properties for the vertical scrollbar.
2067
- * Useful when building custom scrollbar interfaces.
2068
- */
2069
- scrollbarPropsVertical: it,
2070
- /**
2071
- * Properties for the horizontal scrollbar.
2072
- * Useful when building custom scrollbar interfaces.
2073
- */
2074
- scrollbarPropsHorizontal: Ke
2075
- }), (n, v) => (Ee(), Je(ht(a.containerTag), {
2076
- id: b.value,
2077
- ref_key: "hostRef",
2078
- ref: S,
2079
- class: Bt(["virtual-scroll-container", [
2080
- `virtual-scroll--${a.direction}`,
2081
- {
2082
- "virtual-scroll--hydrated": tt(L),
2083
- "virtual-scroll--window": tt(Le),
2084
- "virtual-scroll--table": Ze.value,
2085
- "virtual-scroll--hide-scrollbar": fe.value
2086
- }
2087
- ]]),
2088
- style: gt(Ft.value),
2089
- tabindex: "0",
2090
- onKeydown: je,
2091
- onPointerdown: $e,
2092
- onPointermove: $t,
2093
- onPointerup: Xt,
2094
- onPointercancel: Xt
2095
- }, {
2096
- default: mt(() => [
2097
- fe.value ? (Ee(), It("div", Al, [
2098
- el("div", {
2099
- class: "virtual-scroll-scrollbar-viewport",
2100
- style: gt({
2101
- inlineSize: `${tt(P).displayViewportSize.width}px`,
2102
- blockSize: `${tt(P).displayViewportSize.height}px`,
2103
- "--vsi-scrollbar-has-cross-gap": a.direction === "both" ? 1 : 0
2104
- })
2105
- }, [
2106
- d.scrollbar && it.value ? pt(n.$slots, "scrollbar", St(Vt({ key: 0 }, it.value)), void 0, !0) : it.value ? (Ee(), Je(vl, St(Vt({ key: 1 }, it.value.scrollbarProps)), null, 16)) : et("", !0),
2107
- d.scrollbar && Ke.value ? pt(n.$slots, "scrollbar", St(Vt({ key: 2 }, Ke.value)), void 0, !0) : Ke.value ? (Ee(), Je(vl, St(Vt({ key: 3 }, Ke.value.scrollbarProps)), null, 16)) : et("", !0)
2108
- ], 4)
2109
- ])) : et("", !0),
2110
- d.header ? (Ee(), Je(ht(Et.value), {
2111
- key: 1,
2112
- ref_key: "headerRef",
2113
- ref: m,
2114
- class: Bt(["virtual-scroll-header", { "virtual-scroll--sticky": a.stickyHeader }])
2115
- }, {
2116
- default: mt(() => [
2117
- pt(n.$slots, "header", {}, void 0, !0)
2118
- ]),
2119
- _: 3
2120
- }, 8, ["class"])) : et("", !0),
2121
- (Ee(), Je(ht(a.wrapperTag), {
2122
- ref_key: "wrapperRef",
2123
- ref: w,
2124
- class: "virtual-scroll-wrapper",
2125
- style: gt(He.value)
2126
- }, {
2127
- default: mt(() => [
2128
- Ze.value ? (Ee(), Je(ht(a.itemTag), {
2129
- key: 0,
2130
- class: "virtual-scroll-spacer",
2131
- style: gt(zt.value)
2132
- }, {
2133
- default: mt(() => [...v[0] || (v[0] = [
2134
- el("td", { style: { padding: "0", border: "none", "block-size": "inherit" } }, null, -1)
2135
- ])]),
2136
- _: 1
2137
- }, 8, ["style"])) : et("", !0),
2138
- (Ee(!0), It(wl, null, xl(tt(W), (c) => (Ee(), Je(ht(a.itemTag), {
2139
- key: c.index,
2140
- ref_for: !0,
2141
- ref: (A) => Ve(A, c.index),
2142
- "data-index": c.index,
2143
- class: Bt(["virtual-scroll-item", {
2144
- "virtual-scroll--sticky": c.isStickyActive,
2145
- "virtual-scroll--debug": Yt.value
2146
- }]),
2147
- style: gt(Ct(c))
2148
- }, {
2149
- default: mt(() => [
2150
- pt(n.$slots, "item", {
2151
- item: c.item,
2152
- index: c.index,
2153
- columnRange: Ge.value,
2154
- getColumnWidth: tt(H),
2155
- gap: t.gap,
2156
- columnGap: t.columnGap,
2157
- isSticky: c.isSticky,
2158
- isStickyActive: c.isStickyActive
2159
- }, void 0, !0),
2160
- Yt.value ? (Ee(), It("div", Wl, " #" + Qt(c.index) + " (" + Qt(Math.round(c.offset.x)) + ", " + Qt(Math.round(c.offset.y)) + ") ", 1)) : et("", !0)
2161
- ]),
2162
- _: 2
2163
- }, 1032, ["data-index", "class", "style"]))), 128))
2164
- ]),
2165
- _: 3
2166
- }, 8, ["style"])),
2167
- a.loading && d.loading ? (Ee(), It("div", {
2168
- key: 2,
2169
- class: "virtual-scroll-loading",
2170
- style: gt(rt.value)
2171
- }, [
2172
- pt(n.$slots, "loading", {}, void 0, !0)
2173
- ], 4)) : et("", !0),
2174
- d.footer ? (Ee(), Je(ht(Tt.value), {
2175
- key: 3,
2176
- ref_key: "footerRef",
2177
- ref: z,
2178
- class: Bt(["virtual-scroll-footer", { "virtual-scroll--sticky": a.stickyFooter }])
2179
- }, {
2180
- default: mt(() => [
2181
- pt(n.$slots, "footer", {}, void 0, !0)
2182
- ]),
2183
- _: 3
2184
- }, 8, ["class"])) : et("", !0)
2185
- ]),
2186
- _: 3
2187
- }, 40, ["id", "class", "style"]));
2188
- }
2189
- }), Bl = (a, e) => {
2190
- const i = a.__vccOpts || a;
2191
- for (const [t, s] of e)
2192
- i[t] = s;
2193
- return i;
2194
- }, Hl = /* @__PURE__ */ Bl(ql, [["__scopeId", "data-v-91b6ab6c"]]);
2195
- export {
2196
- bt as BROWSER_MAX_SIZE,
2197
- cl as DEFAULT_BUFFER,
2198
- Lt as DEFAULT_COLUMN_WIDTH,
2199
- Dt as DEFAULT_ITEM_SIZE,
2200
- Kt as FenwickTree,
2201
- Hl as VirtualScroll,
2202
- vl as VirtualScrollbar,
2203
- Xl as calculateColumnRange,
2204
- Yl as calculateItemPosition,
2205
- El as calculateItemStyle,
2206
- Rl as calculateRange,
2207
- sl as calculateScrollTarget,
2208
- Cl as calculateStickyItem,
2209
- Tl as calculateTotalSize,
2210
- ct as displayToVirtual,
2211
- pl as findPrevStickyIndex,
2212
- lt as getPaddingX,
2213
- at as getPaddingY,
2214
- Ml as isBody,
2215
- Zt as isElement,
2216
- Il as isItemVisible,
2217
- yt as isScrollToIndexOptions,
2218
- Jt as isScrollableElement,
2219
- zl as isWindow,
2220
- Pl as isWindowLike,
2221
- Ol as useVirtualScroll,
2222
- tl as useVirtualScrollbar,
2223
- Ht as virtualToDisplay
2224
- };
2225
- //# sourceMappingURL=index.mjs.map
1041
+ function useVirtualScrollbar(e) {
1042
+ let n = computed(() => toValue(e.axis)), r = computed(() => toValue(e.totalSize)), i = computed(() => toValue(e.position)), a = computed(() => toValue(e.viewportSize)), o = computed(() => toValue(e.containerId)), c = computed(() => !!toValue(e.isRtl)), l = computed(() => n.value === "horizontal"), u = computed(() => r.value <= 0 ? 0 : Math.min(1, a.value / r.value)), d = computed(() => {
1043
+ let e = r.value - a.value;
1044
+ return e <= 0 ? 0 : Math.max(0, Math.min(1, i.value / e));
1045
+ }), f = computed(() => {
1046
+ let e = a.value > 0 ? 32 / a.value : .1;
1047
+ return Math.max(Math.min(e, .1), u.value) * 100;
1048
+ }), p = computed(() => d.value * (100 - f.value)), m = computed(() => l.value ? {
1049
+ inlineSize: `${f.value}%`,
1050
+ insetInlineStart: `${p.value}%`
1051
+ } : {
1052
+ blockSize: `${f.value}%`,
1053
+ insetBlockStart: `${p.value}%`
1054
+ }), g = computed(() => {
1055
+ let e = a.value, t = "var(--vs-scrollbar-has-cross-gap, var(--vsi-scrollbar-has-cross-gap, 0)) * var(--vs-scrollbar-cross-gap, var(--vsi-scrollbar-size, 8px))";
1056
+ return l.value ? { inlineSize: `calc(${Math.max(0, e - 4)}px - ${t})` } : { blockSize: `calc(${Math.max(0, e - 4)}px - ${t})` };
1057
+ }), _ = ref(!1), y = 0, b = 0;
1058
+ function x(t) {
1059
+ let n = t.currentTarget;
1060
+ if (t.target !== n) return;
1061
+ let i = n.getBoundingClientRect(), o = l.value ? i.width : i.height, s = 0;
1062
+ s = l.value ? c.value ? i.right - t.clientX : t.clientX - i.left : t.clientY - i.top;
1063
+ let u = f.value / 100 * o, d = (s - u / 2) / (o - u), p = r.value - a.value, m = d * p;
1064
+ m > p - 1 && (m = p), e.scrollToOffset(Math.max(0, Math.min(p, m)));
1065
+ }
1066
+ function S(e) {
1067
+ _.value = !0, y = l.value ? c.value ? -e.clientX : e.clientX : e.clientY, b = i.value, e.currentTarget.setPointerCapture(e.pointerId), e.preventDefault(), e.stopPropagation();
1068
+ }
1069
+ function C(t) {
1070
+ if (!_.value) return;
1071
+ let n = t.currentTarget.parentElement;
1072
+ if (!n) return;
1073
+ let i = (l.value ? c.value ? -t.clientX : t.clientX : t.clientY) - y, o = n.getBoundingClientRect(), s = l.value ? o.width : o.height, u = s - f.value / 100 * s;
1074
+ if (u <= 0) return;
1075
+ let d = r.value - a.value, p = b + i / u * d;
1076
+ p > d - 1 && (p = d), e.scrollToOffset(Math.max(0, Math.min(d, p)));
1077
+ }
1078
+ function T(e) {
1079
+ _.value && (_.value = !1, e.currentTarget.releasePointerCapture(e.pointerId));
1080
+ }
1081
+ return getCurrentInstance() && onUnmounted(() => {
1082
+ _.value = !1;
1083
+ }), {
1084
+ viewportPercent: u,
1085
+ positionPercent: d,
1086
+ thumbSizePercent: f,
1087
+ thumbPositionPercent: p,
1088
+ trackStyle: g,
1089
+ thumbStyle: m,
1090
+ trackProps: computed(() => ({
1091
+ class: ["virtual-scrollbar-track", `virtual-scrollbar-track--${l.value ? "horizontal" : "vertical"}`],
1092
+ style: g.value,
1093
+ role: "scrollbar",
1094
+ "aria-orientation": n.value,
1095
+ "aria-valuenow": Math.round(i.value),
1096
+ "aria-valuemin": 0,
1097
+ "aria-valuemax": Math.round(r.value - a.value),
1098
+ "aria-controls": o.value,
1099
+ tabindex: -1,
1100
+ onMousedown: x
1101
+ })),
1102
+ thumbProps: computed(() => ({
1103
+ class: [
1104
+ "virtual-scrollbar-thumb",
1105
+ `virtual-scrollbar-thumb--${l.value ? "horizontal" : "vertical"}`,
1106
+ { "virtual-scrollbar-thumb--active": _.value }
1107
+ ],
1108
+ style: m.value,
1109
+ onPointerdown: S,
1110
+ onPointermove: C,
1111
+ onPointerup: T,
1112
+ onPointercancel: T
1113
+ })),
1114
+ isDragging: _
1115
+ };
1116
+ }
1117
+ var VirtualScrollbar_default = /* @__PURE__ */ defineComponent({
1118
+ __name: "VirtualScrollbar",
1119
+ props: {
1120
+ axis: { default: "vertical" },
1121
+ totalSize: {},
1122
+ position: {},
1123
+ viewportSize: {},
1124
+ scrollToOffset: {},
1125
+ containerId: {},
1126
+ isRtl: {
1127
+ type: Boolean,
1128
+ default: !1
1129
+ }
1130
+ },
1131
+ emits: ["scrollToOffset"],
1132
+ setup(e, { emit: t }) {
1133
+ let n = e, r = t, { trackProps: o, thumbProps: s } = useVirtualScrollbar({
1134
+ axis: () => n.axis,
1135
+ totalSize: () => n.totalSize,
1136
+ position: () => n.position,
1137
+ viewportSize: () => n.viewportSize,
1138
+ containerId: () => n.containerId,
1139
+ isRtl: () => n.isRtl,
1140
+ scrollToOffset: (e) => {
1141
+ n.scrollToOffset?.(e), r("scrollToOffset", e);
1142
+ }
1143
+ });
1144
+ return (e, t) => (openBlock(), createElementBlock("div", normalizeProps(guardReactiveProps(unref(o))), [createElementVNode("div", normalizeProps(guardReactiveProps(unref(s))), null, 16)], 16));
1145
+ }
1146
+ }), _hoisted_1 = {
1147
+ key: 0,
1148
+ class: "virtual-scroll-scrollbar-container"
1149
+ }, _hoisted_2 = {
1150
+ key: 0,
1151
+ class: "virtual-scroll-debug-info"
1152
+ }, FRICTION = .95, MIN_VELOCITY = .1, VirtualScroll_default = /* @__PURE__ */ ((e, t) => {
1153
+ let n = e.__vccOpts || e;
1154
+ for (let [e, r] of t) n[e] = r;
1155
+ return n;
1156
+ })(/* @__PURE__ */ defineComponent({
1157
+ __name: "VirtualScroll",
1158
+ props: {
1159
+ containerTag: { default: "div" },
1160
+ wrapperTag: { default: "div" },
1161
+ itemTag: { default: "div" },
1162
+ stickyHeader: {
1163
+ type: Boolean,
1164
+ default: !1
1165
+ },
1166
+ stickyFooter: {
1167
+ type: Boolean,
1168
+ default: !1
1169
+ },
1170
+ virtualScrollbar: {
1171
+ type: Boolean,
1172
+ default: !1
1173
+ },
1174
+ items: {},
1175
+ itemSize: {},
1176
+ direction: { default: "vertical" },
1177
+ bufferBefore: { default: 5 },
1178
+ bufferAfter: { default: 5 },
1179
+ container: {},
1180
+ ssrRange: {},
1181
+ columnCount: { default: 0 },
1182
+ columnWidth: {},
1183
+ scrollPaddingStart: { default: 0 },
1184
+ scrollPaddingEnd: { default: 0 },
1185
+ gap: { default: 0 },
1186
+ columnGap: { default: 0 },
1187
+ stickyIndices: { default: () => [] },
1188
+ loadDistance: { default: 200 },
1189
+ loading: {
1190
+ type: Boolean,
1191
+ default: !1
1192
+ },
1193
+ restoreScrollOnPrepend: {
1194
+ type: Boolean,
1195
+ default: !1
1196
+ },
1197
+ initialScrollIndex: {},
1198
+ initialScrollAlign: {},
1199
+ defaultItemSize: {},
1200
+ defaultColumnWidth: {},
1201
+ debug: {
1202
+ type: Boolean,
1203
+ default: !1
1204
+ }
1205
+ },
1206
+ emits: [
1207
+ "scroll",
1208
+ "load",
1209
+ "visibleRangeChange"
1210
+ ],
1211
+ setup(o, { expose: s, emit: c }) {
1212
+ let _ = o, w = c, k = useSlots(), A = ref(null), j = ref(null), M = ref(null), N = ref(null), te = /* @__PURE__ */ new Map(), P = useId(), F = computed(() => `vs-container-${P}`), ne = ref(0), re = ref(0), ie = computed(() => _.container === void 0 ? A.value : _.container), ae = computed(() => {
1213
+ let e = ie.value;
1214
+ return e === A.value || typeof window < "u" && (e === window || e === null);
1215
+ }), I = computed(() => (_.items.length, {
1216
+ items: _.items,
1217
+ itemSize: _.itemSize,
1218
+ direction: _.direction,
1219
+ bufferBefore: _.bufferBefore,
1220
+ bufferAfter: _.bufferAfter,
1221
+ container: ie.value,
1222
+ hostElement: j.value,
1223
+ hostRef: A.value,
1224
+ ssrRange: _.ssrRange,
1225
+ columnCount: _.columnCount,
1226
+ columnWidth: _.columnWidth,
1227
+ scrollPaddingStart: {
1228
+ x: getPaddingX(_.scrollPaddingStart, _.direction),
1229
+ y: getPaddingY(_.scrollPaddingStart, _.direction)
1230
+ },
1231
+ scrollPaddingEnd: {
1232
+ x: getPaddingX(_.scrollPaddingEnd, _.direction),
1233
+ y: getPaddingY(_.scrollPaddingEnd, _.direction)
1234
+ },
1235
+ flowPaddingStart: {
1236
+ x: 0,
1237
+ y: _.stickyHeader ? 0 : ne.value
1238
+ },
1239
+ flowPaddingEnd: {
1240
+ x: 0,
1241
+ y: _.stickyFooter ? 0 : re.value
1242
+ },
1243
+ stickyStart: {
1244
+ x: 0,
1245
+ y: _.stickyHeader && ae.value ? ne.value : 0
1246
+ },
1247
+ stickyEnd: {
1248
+ x: 0,
1249
+ y: _.stickyFooter && ae.value ? re.value : 0
1250
+ },
1251
+ gap: _.gap,
1252
+ columnGap: _.columnGap,
1253
+ stickyIndices: _.stickyIndices,
1254
+ loadDistance: _.loadDistance,
1255
+ loading: _.loading,
1256
+ restoreScrollOnPrepend: _.restoreScrollOnPrepend,
1257
+ initialScrollIndex: _.initialScrollIndex,
1258
+ initialScrollAlign: _.initialScrollAlign,
1259
+ defaultItemSize: _.defaultItemSize,
1260
+ defaultColumnWidth: _.defaultColumnWidth,
1261
+ debug: _.debug
1262
+ })), { isHydrated: ce, isRtl: L, columnRange: le, renderedItems: R, scrollDetails: z, renderedHeight: ue, renderedWidth: B, getColumnWidth: V, getRowHeight: fe, scrollToIndex: H, scrollToOffset: pe, updateHostOffset: me, updateItemSizes: he, updateDirection: ge, getItemOffset: ve, getRowOffset: Te, getColumnOffset: W, getItemSize: Ee, refresh: G, stopProgrammaticScroll: K, scaleX: q, scaleY: De, isWindowContainer: Oe, componentOffset: ke, renderedVirtualWidth: Ae, renderedVirtualHeight: je } = useVirtualScroll(I), Me = computed(() => q.value !== 1 || De.value !== 1), Ne = computed(() => Oe.value ? !1 : _.virtualScrollbar === !0 || q.value !== 1 || De.value !== 1);
1263
+ function J(e) {
1264
+ let { displayViewportSize: t } = z.value;
1265
+ e >= ue.value - t.height - .5 ? pe(null, Infinity) : pe(null, displayToVirtual(e, ke.y, De.value));
1266
+ }
1267
+ function Y(e) {
1268
+ let { displayViewportSize: t } = z.value;
1269
+ e >= B.value - t.width - .5 ? pe(Infinity, null) : pe(displayToVirtual(e, ke.x, q.value), null);
1270
+ }
1271
+ let X = useVirtualScrollbar({
1272
+ axis: "vertical",
1273
+ totalSize: ue,
1274
+ position: computed(() => z.value.displayScrollOffset.y),
1275
+ viewportSize: computed(() => z.value.displayViewportSize.height),
1276
+ scrollToOffset: J,
1277
+ containerId: F,
1278
+ isRtl: L
1279
+ }), Pe = useVirtualScrollbar({
1280
+ axis: "horizontal",
1281
+ totalSize: B,
1282
+ position: computed(() => z.value.displayScrollOffset.x),
1283
+ viewportSize: computed(() => z.value.displayViewportSize.width),
1284
+ scrollToOffset: Y,
1285
+ containerId: F,
1286
+ isRtl: L
1287
+ }), Fe = computed(() => _.direction === "both" ? {
1288
+ ...le.value,
1289
+ padStart: 0,
1290
+ padEnd: 0
1291
+ } : le.value);
1292
+ function Ie() {
1293
+ G(), ge(), nextTick(() => {
1294
+ let e = [];
1295
+ for (let [t, n] of te.entries()) n && e.push({
1296
+ index: t,
1297
+ inlineSize: n.offsetWidth,
1298
+ blockSize: n.offsetHeight,
1299
+ element: n
1300
+ });
1301
+ e.length > 0 && he(e);
1302
+ });
1303
+ }
1304
+ watch(z, (e, t) => {
1305
+ !ce.value || !e || (w("scroll", e), (!t || !t.range || !t.columnRange || e.range.start !== t.range.start || e.range.end !== t.range.end || e.columnRange.start !== t.columnRange.start || e.columnRange.end !== t.columnRange.end) && w("visibleRangeChange", {
1306
+ start: e.range.start,
1307
+ end: e.range.end,
1308
+ colStart: e.columnRange.start,
1309
+ colEnd: e.columnRange.end
1310
+ }), !_.loading && (_.direction !== "horizontal" && e.totalSize && e.totalSize.height - (e.scrollOffset.y + e.viewportSize.height) <= _.loadDistance && w("load", "vertical"), _.direction !== "vertical" && e.totalSize && e.totalSize.width - (e.scrollOffset.x + e.viewportSize.width) <= _.loadDistance && w("load", "horizontal")));
1311
+ }), watch(ce, (e) => {
1312
+ e && z.value?.range && z.value?.columnRange && w("visibleRangeChange", {
1313
+ start: z.value.range.start,
1314
+ end: z.value.range.end,
1315
+ colStart: z.value.columnRange.start,
1316
+ colEnd: z.value.columnRange.end
1317
+ });
1318
+ }, { once: !0 });
1319
+ let Le = typeof window > "u" ? null : new ResizeObserver(me), Z = typeof window > "u" ? null : new ResizeObserver((e) => {
1320
+ let t = [];
1321
+ for (let n of e) {
1322
+ let e = n.target, r = Number(e.dataset.index), i = e.dataset.colIndex, a = n.contentRect.width, o = n.contentRect.height;
1323
+ n.borderBoxSize && n.borderBoxSize.length > 0 ? (a = n.borderBoxSize[0].inlineSize, o = n.borderBoxSize[0].blockSize) : (a = e.offsetWidth, o = e.offsetHeight), i === void 0 ? Number.isNaN(r) || t.push({
1324
+ index: r,
1325
+ inlineSize: a,
1326
+ blockSize: o,
1327
+ element: e
1328
+ }) : t.push({
1329
+ index: -1,
1330
+ inlineSize: a,
1331
+ blockSize: o,
1332
+ element: e
1333
+ });
1334
+ }
1335
+ t.length > 0 && he(t);
1336
+ }), Q = typeof window > "u" ? null : new ResizeObserver(() => {
1337
+ ne.value = M.value?.offsetHeight || 0, re.value = N.value?.offsetHeight || 0, me();
1338
+ });
1339
+ function Re(e, t) {
1340
+ watch(e, (e, n) => {
1341
+ n && Q?.unobserve(n), e ? Q?.observe(e) : t.value = 0;
1342
+ }, { immediate: !0 });
1343
+ }
1344
+ Re(M, ne), Re(N, re), onMounted(() => {
1345
+ A.value && Le?.observe(A.value);
1346
+ for (let e of te.values()) Z?.observe(e), _.direction === "both" && e.querySelectorAll("[data-col-index]").forEach((e) => Z?.observe(e));
1347
+ }), watch([A, j], ([e], [t]) => {
1348
+ t && Le?.unobserve(t), e && Le?.observe(e);
1349
+ }), watch([A, Me], ([e, t], [n, r]) => {
1350
+ let i = e !== n || t !== r;
1351
+ n && i && n.removeEventListener("wheel", Ze), e && i && e.addEventListener("wheel", Ze, { passive: !t });
1352
+ }, { immediate: !0 });
1353
+ function ze(e, t) {
1354
+ if (e) te.set(t, e), Z?.observe(e), _.direction === "both" && e.querySelectorAll("[data-col-index]").forEach((e) => Z?.observe(e));
1355
+ else {
1356
+ let e = te.get(t);
1357
+ e && (Z?.unobserve(e), _.direction === "both" && e.querySelectorAll("[data-col-index]").forEach((e) => Z?.unobserve(e)), te.delete(t));
1358
+ }
1359
+ }
1360
+ let Be = ref(!1), Ve = {
1361
+ x: 0,
1362
+ y: 0
1363
+ }, He = {
1364
+ x: 0,
1365
+ y: 0
1366
+ }, Ue = {
1367
+ x: 0,
1368
+ y: 0
1369
+ }, We = 0, $ = {
1370
+ x: 0,
1371
+ y: 0
1372
+ }, Ge = null;
1373
+ function Ke() {
1374
+ let e = () => {
1375
+ $.x *= FRICTION, $.y *= FRICTION;
1376
+ let t = z.value.scrollOffset.x, n = z.value.scrollOffset.y;
1377
+ pe(t + $.x * 16, n + $.y * 16, { behavior: "auto" }), Math.abs($.x) > MIN_VELOCITY || Math.abs($.y) > MIN_VELOCITY ? Ge = requestAnimationFrame(e) : qe();
1378
+ };
1379
+ Ge = requestAnimationFrame(e);
1380
+ }
1381
+ function qe() {
1382
+ Ge !== null && (cancelAnimationFrame(Ge), Ge = null), $ = {
1383
+ x: 0,
1384
+ y: 0
1385
+ };
1386
+ }
1387
+ function Je(e) {
1388
+ K(), qe(), Me.value && (e.pointerType === "mouse" && e.button !== 0 || (Be.value = !0, Ve = {
1389
+ x: e.clientX,
1390
+ y: e.clientY
1391
+ }, Ue = {
1392
+ x: e.clientX,
1393
+ y: e.clientY
1394
+ }, We = performance.now(), He = {
1395
+ x: z.value.scrollOffset.x,
1396
+ y: z.value.scrollOffset.y
1397
+ }, e.currentTarget.setPointerCapture(e.pointerId)));
1398
+ }
1399
+ function Ye(e) {
1400
+ if (!Be.value) return;
1401
+ let t = performance.now(), n = t - We;
1402
+ if (n > 0) {
1403
+ let t = (Ue.x - e.clientX) / n, r = (Ue.y - e.clientY) / n;
1404
+ $.x = $.x * .2 + t * .8, $.y = $.y * .2 + r * .8;
1405
+ }
1406
+ Ue = {
1407
+ x: e.clientX,
1408
+ y: e.clientY
1409
+ }, We = t;
1410
+ let r = Ve.x - e.clientX, i = Ve.y - e.clientY;
1411
+ requestAnimationFrame(() => {
1412
+ pe(He.x + r, He.y + i, { behavior: "auto" });
1413
+ });
1414
+ }
1415
+ function Xe(e) {
1416
+ Be.value && (Be.value = !1, e.currentTarget.releasePointerCapture(e.pointerId), (Math.abs($.x) > MIN_VELOCITY || Math.abs($.y) > MIN_VELOCITY) && (Math.abs($.x) > 4 * Math.abs($.y) ? $.y = 0 : Math.abs($.y) > 4 * Math.abs($.x) && ($.x = 0), Ke()));
1417
+ }
1418
+ function Ze(e) {
1419
+ let { scrollOffset: t } = z.value;
1420
+ if (K(), Me.value) {
1421
+ e.preventDefault();
1422
+ let n = e.deltaX, r = e.deltaY;
1423
+ e.shiftKey && n === 0 && (n = r, r = 0), pe(t.x + n, t.y + r, { behavior: "auto" });
1424
+ }
1425
+ }
1426
+ function Qe(e) {
1427
+ let { viewportSize: t, scrollOffset: n } = z.value, r = _.direction !== "vertical", i = _.direction !== "horizontal", a = I.value.stickyStart, o = I.value.stickyEnd;
1428
+ switch (e.key) {
1429
+ case "Home":
1430
+ e.preventDefault(), K(), H(0, 0, {
1431
+ behavior: Math.max(n.x, n.y) > 10 * (_.direction === "horizontal" ? t.width : t.height) ? "auto" : "smooth",
1432
+ align: "start"
1433
+ });
1434
+ break;
1435
+ case "End": {
1436
+ e.preventDefault(), K();
1437
+ let r = _.items.length - 1, i = (_.columnCount || 0) > 0 ? _.columnCount - 1 : 0, { totalSize: a } = z.value, o = Math.max(a.width - n.x - t.width, a.height - n.y - t.height) > 10 * (_.direction === "horizontal" ? t.width : t.height) ? "auto" : "smooth";
1438
+ _.direction === "both" ? H(r, i, {
1439
+ behavior: o,
1440
+ align: "end"
1441
+ }) : H(_.direction === "vertical" ? r : 0, _.direction === "horizontal" ? r : 0, {
1442
+ behavior: o,
1443
+ align: "end"
1444
+ });
1445
+ break;
1446
+ }
1447
+ case "ArrowUp": {
1448
+ if (e.preventDefault(), K(), !i) return;
1449
+ let { currentIndex: t, scrollOffset: n } = z.value, r = n.y + a.y + I.value.scrollPaddingStart.y;
1450
+ Te(t) < r - 1 ? H(t, null, { align: "start" }) : t > 0 && H(t - 1, null, { align: "start" });
1451
+ break;
1452
+ }
1453
+ case "ArrowDown": {
1454
+ if (e.preventDefault(), K(), !i) return;
1455
+ let { currentEndIndex: r } = z.value, a = n.y + t.height - (o.y + I.value.scrollPaddingEnd.y);
1456
+ Te(r) + fe(r) > a + 1 ? H(r, null, { align: "end" }) : r < _.items.length - 1 && H(r + 1, null, { align: "end" });
1457
+ break;
1458
+ }
1459
+ case "ArrowLeft": {
1460
+ if (e.preventDefault(), K(), !r) return;
1461
+ let { currentColIndex: i, currentEndColIndex: s } = z.value;
1462
+ if (L.value) {
1463
+ let e = n.x + t.width - (o.x + I.value.scrollPaddingEnd.x);
1464
+ (_.columnCount ? W(s) + V(s) : ve(s) + Ee(s)) > e + 1 ? H(null, s, { align: "end" }) : s < (_.columnCount ? _.columnCount - 1 : _.items.length - 1) && H(null, s + 1, { align: "end" });
1465
+ } else {
1466
+ let e = n.x + a.x + I.value.scrollPaddingStart.x;
1467
+ (_.columnCount ? W(i) : ve(i)) < e - 1 ? H(null, i, { align: "start" }) : i > 0 && H(null, i - 1, { align: "start" });
1468
+ }
1469
+ break;
1470
+ }
1471
+ case "ArrowRight": {
1472
+ if (e.preventDefault(), K(), !r) return;
1473
+ let { currentColIndex: i, currentEndColIndex: s } = z.value;
1474
+ if (L.value) {
1475
+ let e = n.x + a.x + I.value.scrollPaddingStart.x;
1476
+ (_.columnCount ? W(i) : ve(i)) < e - 1 ? H(null, i, { align: "start" }) : i > 0 && H(null, i - 1, { align: "start" });
1477
+ } else {
1478
+ let e = n.x + t.width - (o.x + I.value.scrollPaddingEnd.x);
1479
+ (_.columnCount ? W(s) + V(s) : ve(s) + Ee(s)) > e + 1 ? H(null, s, { align: "end" }) : s < (_.columnCount ? _.columnCount - 1 : _.items.length - 1) && H(null, s + 1, { align: "end" });
1480
+ }
1481
+ break;
1482
+ }
1483
+ case "PageUp":
1484
+ e.preventDefault(), K(), pe(!i && r ? n.x - t.width : null, i ? n.y - t.height : null);
1485
+ break;
1486
+ case "PageDown":
1487
+ e.preventDefault(), K(), pe(!i && r ? n.x + t.width : null, i ? n.y + t.height : null);
1488
+ break;
1489
+ }
1490
+ }
1491
+ onUnmounted(() => {
1492
+ Le?.disconnect(), Z?.disconnect(), Q?.disconnect();
1493
+ });
1494
+ let $e = computed(() => {
1495
+ let e = { ..._.direction === "vertical" ? {} : { whiteSpace: "nowrap" } };
1496
+ return (Ne.value || !Oe.value) && (e.overflow = "auto"), Me.value && (e.touchAction = "none"), Oe.value ? e : _.containerTag === "table" ? {
1497
+ ...e,
1498
+ display: "block",
1499
+ minInlineSize: _.direction === "vertical" ? "100%" : "auto"
1500
+ } : e;
1501
+ }), et = computed(() => {
1502
+ if (_.direction === "horizontal") return null;
1503
+ let { displayViewportSize: e, displayScrollOffset: t } = z.value;
1504
+ if (ue.value <= e.height) return null;
1505
+ let n = {
1506
+ axis: "vertical",
1507
+ totalSize: ue.value,
1508
+ position: t.y,
1509
+ viewportSize: e.height,
1510
+ scrollToOffset: J,
1511
+ containerId: F.value,
1512
+ isRtl: L.value
1513
+ };
1514
+ return {
1515
+ axis: "vertical",
1516
+ positionPercent: X.positionPercent.value,
1517
+ viewportPercent: X.viewportPercent.value,
1518
+ thumbSizePercent: X.thumbSizePercent.value,
1519
+ thumbPositionPercent: X.thumbPositionPercent.value,
1520
+ trackProps: X.trackProps.value,
1521
+ thumbProps: X.thumbProps.value,
1522
+ scrollbarProps: n,
1523
+ isDragging: X.isDragging.value
1524
+ };
1525
+ }), tt = computed(() => {
1526
+ if (_.direction === "vertical") return null;
1527
+ let { displayViewportSize: e, displayScrollOffset: t } = z.value;
1528
+ if (B.value <= e.width) return null;
1529
+ let n = {
1530
+ axis: "horizontal",
1531
+ totalSize: B.value,
1532
+ position: t.x,
1533
+ viewportSize: e.width,
1534
+ scrollToOffset: Y,
1535
+ containerId: F.value,
1536
+ isRtl: L.value
1537
+ };
1538
+ return {
1539
+ axis: "horizontal",
1540
+ positionPercent: Pe.positionPercent.value,
1541
+ viewportPercent: Pe.viewportPercent.value,
1542
+ thumbSizePercent: Pe.thumbSizePercent.value,
1543
+ thumbPositionPercent: Pe.thumbPositionPercent.value,
1544
+ trackProps: Pe.trackProps.value,
1545
+ thumbProps: Pe.thumbProps.value,
1546
+ scrollbarProps: n,
1547
+ isDragging: Pe.isDragging.value
1548
+ };
1549
+ }), nt = computed(() => {
1550
+ let e = _.direction === "horizontal", t = _.direction === "vertical", n = _.direction === "both", r = {
1551
+ inlineSize: t ? "100%" : `${Ae.value}px`,
1552
+ blockSize: e ? "100%" : `${je.value}px`
1553
+ };
1554
+ return ce.value || (r.display = "flex", r.flexDirection = e ? "row" : "column", (e || n) && _.columnGap && (r.columnGap = `${_.columnGap}px`), (t || n) && _.gap && (r.rowGap = `${_.gap}px`)), r;
1555
+ }), rt = computed(() => {
1556
+ let e = _.direction === "horizontal";
1557
+ return {
1558
+ display: e ? "inline-block" : "block",
1559
+ ...e ? {
1560
+ blockSize: "100%",
1561
+ verticalAlign: "top"
1562
+ } : { inlineSize: "100%" }
1563
+ };
1564
+ }), it = computed(() => ({
1565
+ inlineSize: _.direction === "vertical" ? "1px" : `${Ae.value}px`,
1566
+ blockSize: _.direction === "horizontal" ? "1px" : `${je.value}px`
1567
+ }));
1568
+ function at(e) {
1569
+ let t = calculateItemStyle({
1570
+ containerTag: _.containerTag || "div",
1571
+ direction: _.direction,
1572
+ isHydrated: ce.value,
1573
+ item: e,
1574
+ itemSize: _.itemSize,
1575
+ paddingStartX: I.value.scrollPaddingStart.x,
1576
+ paddingStartY: I.value.scrollPaddingStart.y,
1577
+ isRtl: L.value
1578
+ });
1579
+ return !ce.value && _.direction === "both" && (t.display = "flex", _.columnGap && (t.columnGap = `${_.columnGap}px`)), t;
1580
+ }
1581
+ let ot = computed(() => _.debug), st = computed(() => _.containerTag === "table"), ct = computed(() => st.value ? "thead" : "div"), lt = computed(() => st.value ? "tfoot" : "div");
1582
+ return s({
1583
+ ...toRefs(_),
1584
+ scrollDetails: z,
1585
+ columnRange: le,
1586
+ getColumnWidth: V,
1587
+ getRowHeight: fe,
1588
+ getRowOffset: Te,
1589
+ getColumnOffset: W,
1590
+ getItemOffset: ve,
1591
+ getItemSize: Ee,
1592
+ scrollToIndex: H,
1593
+ scrollToOffset: pe,
1594
+ refresh: Ie,
1595
+ stopProgrammaticScroll: () => {
1596
+ K(), qe();
1597
+ },
1598
+ updateDirection: ge,
1599
+ isRtl: L,
1600
+ isHydrated: ce,
1601
+ scaleX: q,
1602
+ scaleY: De,
1603
+ renderedWidth: B,
1604
+ renderedHeight: ue,
1605
+ componentOffset: ke,
1606
+ scrollbarPropsVertical: et,
1607
+ scrollbarPropsHorizontal: tt
1608
+ }), (t, s) => (openBlock(), createBlock(resolveDynamicComponent(o.containerTag), {
1609
+ id: F.value,
1610
+ ref_key: "hostRef",
1611
+ ref: A,
1612
+ class: normalizeClass(["virtual-scroll-container", [`virtual-scroll--${o.direction}`, {
1613
+ "virtual-scroll--hydrated": unref(ce),
1614
+ "virtual-scroll--window": unref(Oe),
1615
+ "virtual-scroll--table": st.value,
1616
+ "virtual-scroll--hide-scrollbar": Ne.value
1617
+ }]]),
1618
+ style: normalizeStyle($e.value),
1619
+ tabindex: "0",
1620
+ onKeydown: Qe,
1621
+ onPointerdown: Je,
1622
+ onPointermove: Ye,
1623
+ onPointerup: Xe,
1624
+ onPointercancel: Xe
1625
+ }, {
1626
+ default: withCtx(() => [
1627
+ Ne.value ? (openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", {
1628
+ class: "virtual-scroll-scrollbar-viewport",
1629
+ style: normalizeStyle({
1630
+ inlineSize: `${unref(z).displayViewportSize.width}px`,
1631
+ blockSize: `${unref(z).displayViewportSize.height}px`,
1632
+ "--vsi-scrollbar-has-cross-gap": o.direction === "both" ? 1 : 0
1633
+ })
1634
+ }, [k.scrollbar && et.value ? renderSlot(t.$slots, "scrollbar", normalizeProps(mergeProps({ key: 0 }, et.value)), void 0, !0) : et.value ? (openBlock(), createBlock(VirtualScrollbar_default, normalizeProps(mergeProps({ key: 1 }, et.value.scrollbarProps)), null, 16)) : createCommentVNode("", !0), k.scrollbar && tt.value ? renderSlot(t.$slots, "scrollbar", normalizeProps(mergeProps({ key: 2 }, tt.value)), void 0, !0) : tt.value ? (openBlock(), createBlock(VirtualScrollbar_default, normalizeProps(mergeProps({ key: 3 }, tt.value.scrollbarProps)), null, 16)) : createCommentVNode("", !0)], 4)])) : createCommentVNode("", !0),
1635
+ k.header ? (openBlock(), createBlock(resolveDynamicComponent(ct.value), {
1636
+ key: 1,
1637
+ ref_key: "headerRef",
1638
+ ref: M,
1639
+ class: normalizeClass(["virtual-scroll-header", { "virtual-scroll--sticky": o.stickyHeader }])
1640
+ }, {
1641
+ default: withCtx(() => [renderSlot(t.$slots, "header", {}, void 0, !0)]),
1642
+ _: 3
1643
+ }, 8, ["class"])) : createCommentVNode("", !0),
1644
+ (openBlock(), createBlock(resolveDynamicComponent(o.wrapperTag), {
1645
+ ref_key: "wrapperRef",
1646
+ ref: j,
1647
+ class: "virtual-scroll-wrapper",
1648
+ style: normalizeStyle(nt.value)
1649
+ }, {
1650
+ default: withCtx(() => [st.value ? (openBlock(), createBlock(resolveDynamicComponent(o.itemTag), {
1651
+ key: 0,
1652
+ class: "virtual-scroll-spacer",
1653
+ style: normalizeStyle(it.value)
1654
+ }, {
1655
+ default: withCtx(() => [...s[0] ||= [createElementVNode("td", { style: {
1656
+ padding: "0",
1657
+ border: "none",
1658
+ "block-size": "inherit"
1659
+ } }, null, -1)]]),
1660
+ _: 1
1661
+ }, 8, ["style"])) : createCommentVNode("", !0), (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(R), (e) => (openBlock(), createBlock(resolveDynamicComponent(o.itemTag), {
1662
+ key: e.index,
1663
+ ref_for: !0,
1664
+ ref: (t) => ze(t, e.index),
1665
+ "data-index": e.index,
1666
+ class: normalizeClass(["virtual-scroll-item", {
1667
+ "virtual-scroll--sticky": e.isStickyActive,
1668
+ "virtual-scroll--debug": ot.value
1669
+ }]),
1670
+ style: normalizeStyle(at(e))
1671
+ }, {
1672
+ default: withCtx(() => [renderSlot(t.$slots, "item", {
1673
+ item: e.item,
1674
+ index: e.index,
1675
+ columnRange: Fe.value,
1676
+ getColumnWidth: unref(V),
1677
+ gap: _.gap,
1678
+ columnGap: _.columnGap,
1679
+ isSticky: e.isSticky,
1680
+ isStickyActive: e.isStickyActive,
1681
+ isStickyActiveX: e.isStickyActiveX,
1682
+ isStickyActiveY: e.isStickyActiveY,
1683
+ offset: e.offset
1684
+ }, void 0, !0), ot.value ? (openBlock(), createElementBlock("div", _hoisted_2, " #" + toDisplayString(e.index) + " (" + toDisplayString(Math.round(e.offset.x)) + ", " + toDisplayString(Math.round(e.offset.y)) + ") ", 1)) : createCommentVNode("", !0)]),
1685
+ _: 2
1686
+ }, 1032, [
1687
+ "data-index",
1688
+ "class",
1689
+ "style"
1690
+ ]))), 128))]),
1691
+ _: 3
1692
+ }, 8, ["style"])),
1693
+ o.loading && k.loading ? (openBlock(), createElementBlock("div", {
1694
+ key: 2,
1695
+ class: "virtual-scroll-loading",
1696
+ style: normalizeStyle(rt.value)
1697
+ }, [renderSlot(t.$slots, "loading", {}, void 0, !0)], 4)) : createCommentVNode("", !0),
1698
+ k.footer ? (openBlock(), createBlock(resolveDynamicComponent(lt.value), {
1699
+ key: 3,
1700
+ ref_key: "footerRef",
1701
+ ref: N,
1702
+ class: normalizeClass(["virtual-scroll-footer", { "virtual-scroll--sticky": o.stickyFooter }])
1703
+ }, {
1704
+ default: withCtx(() => [renderSlot(t.$slots, "footer", {}, void 0, !0)]),
1705
+ _: 3
1706
+ }, 8, ["class"])) : createCommentVNode("", !0)
1707
+ ]),
1708
+ _: 3
1709
+ }, 40, [
1710
+ "id",
1711
+ "class",
1712
+ "style"
1713
+ ]));
1714
+ }
1715
+ }), [["__scopeId", "data-v-408dd72c"]]);
1716
+ export { BROWSER_MAX_SIZE, DEFAULT_BUFFER, DEFAULT_COLUMN_WIDTH, DEFAULT_ITEM_SIZE, EMPTY_SCROLL_DETAILS, FenwickTree, VirtualScroll_default as VirtualScroll, VirtualScrollbar_default as VirtualScrollbar, calculateColumnRange, calculateItemPosition, calculateItemStyle, calculateRange, calculateScrollTarget, calculateStickyItem, calculateTotalSize, displayToVirtual, findPrevStickyIndex, getPaddingX, getPaddingY, isBody, isElement, isItemVisible, isScrollToIndexOptions, isScrollableElement, isWindow, isWindowLike, scrollTo, useVirtualScroll, useVirtualScrollbar, virtualToDisplay };
1717
+
1718
+ //# sourceMappingURL=index.mjs.map