vue-virtual-flow 0.0.9 → 0.1.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +94 -10
  3. package/README.vi.md +87 -10
  4. package/dist/components/ChatVirtualScroll.d.cts +29 -2
  5. package/dist/components/ChatVirtualScroll.d.ts +29 -2
  6. package/dist/components/DynamicVirtualScroll.d.cts +3 -3
  7. package/dist/components/DynamicVirtualScroll.d.ts +3 -3
  8. package/dist/components/ShortMediaFeed.d.cts +2 -2
  9. package/dist/components/ShortMediaFeed.d.ts +2 -2
  10. package/dist/components/VirtualCarousel.d.cts +15 -2
  11. package/dist/components/VirtualCarousel.d.ts +15 -2
  12. package/dist/components/VirtualScroll.d.cts +3 -3
  13. package/dist/components/VirtualScroll.d.ts +3 -3
  14. package/dist/components/WindowDynamicVirtualScroll.d.cts +3 -3
  15. package/dist/components/WindowDynamicVirtualScroll.d.ts +3 -3
  16. package/dist/components/WindowGirdVirtualScroll.d.cts +3 -3
  17. package/dist/components/WindowGirdVirtualScroll.d.ts +3 -3
  18. package/dist/composables/useCarouselAutoplay.d.cts +15 -0
  19. package/dist/composables/useCarouselAutoplay.d.ts +15 -0
  20. package/dist/composables/useCarouselInteraction.d.cts +40 -0
  21. package/dist/composables/useCarouselInteraction.d.ts +40 -0
  22. package/dist/composables/useScrollActivity.d.cts +28 -0
  23. package/dist/composables/useScrollActivity.d.ts +28 -0
  24. package/dist/index.d.cts +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/types.d.cts +46 -0
  27. package/dist/types.d.ts +46 -0
  28. package/dist/utils/carouselLayout.d.cts +8 -0
  29. package/dist/utils/carouselLayout.d.ts +8 -0
  30. package/dist/utils/carouselMotion.d.cts +5 -0
  31. package/dist/utils/carouselMotion.d.ts +5 -0
  32. package/dist/utils/keyedSizeIndex.d.cts +19 -0
  33. package/dist/utils/keyedSizeIndex.d.ts +19 -0
  34. package/dist/vue-virtual-flow.cjs +1 -1
  35. package/dist/vue-virtual-flow.css +1 -1
  36. package/dist/vue-virtual-flow.js +2191 -1523
  37. package/package.json +3 -2
@@ -1,101 +1,254 @@
1
- import { watch as ie, defineComponent as Oe, ref as j, computed as n, nextTick as C, onMounted as Ae, onUpdated as Xe, onBeforeUnmount as Ce, openBlock as I, createElementBlock as $, normalizeStyle as N, createElementVNode as Ge, renderSlot as ce, createTextVNode as Ve, createCommentVNode as ze, Fragment as Re, renderList as De, unref as c, normalizeClass as Ye, toDisplayString as je } from "vue";
2
- function tt(l) {
3
- return typeof l == "string" || typeof l == "number" || typeof l == "symbol";
1
+ import { watch as we, ref as ee, defineComponent as Qe, computed as m, shallowRef as ct, nextTick as Z, onMounted as _e, onUpdated as $t, onBeforeUnmount as qe, openBlock as j, createElementBlock as U, normalizeStyle as ue, createElementVNode as lt, mergeProps as Ot, unref as f, renderSlot as Se, createTextVNode as Ue, createCommentVNode as Ve, Fragment as Je, renderList as et, toDisplayString as vt, normalizeClass as ot } from "vue";
2
+ function At(t) {
3
+ return typeof t == "string" || typeof t == "number" || typeof t == "symbol";
4
4
  }
5
- function Ze(l, P) {
6
- const x = l[P];
7
- return tt(x) ? x : void 0;
5
+ function zt(t, s) {
6
+ const I = t[s];
7
+ return At(I) ? I : void 0;
8
8
  }
9
- function lt(l) {
10
- return Ze(l, "id") ?? Ze(l, "key");
9
+ function Ft(t) {
10
+ return zt(t, "id") ?? zt(t, "key");
11
11
  }
12
- function Pe(l) {
13
- function P(e, p) {
14
- const f = l.itemKey();
15
- if (typeof f == "function")
16
- return f(e, p);
17
- if (e !== null && typeof e == "object") {
18
- if (f !== void 0) {
19
- const o = Ze(e, f);
20
- if (o !== void 0) return o;
12
+ function tt(t) {
13
+ const s = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new Map();
14
+ function e(M) {
15
+ if (At(M)) return M;
16
+ if (M !== null && typeof M == "object") {
17
+ let c = s.get(M);
18
+ return c || (c = Symbol(`${t.componentName} item`), s.set(M, c)), c;
19
+ }
20
+ let d = I.get(M);
21
+ return d || (d = Symbol(`${t.componentName} primitive`), I.set(M, d)), d;
22
+ }
23
+ function x(M, d) {
24
+ const c = t.itemKey();
25
+ if (typeof c == "function")
26
+ return c(M, d);
27
+ if (M !== null && typeof M == "object") {
28
+ if (c !== void 0) {
29
+ const h = zt(M, c);
30
+ if (h !== void 0) return h;
21
31
  }
22
- const r = lt(e);
23
- if (r !== void 0) return r;
32
+ const n = Ft(M);
33
+ if (n !== void 0) return n;
24
34
  }
25
- return p;
35
+ return e(M);
26
36
  }
27
- function x() {
37
+ function y() {
28
38
  }
29
- return ie(
30
- () => [l.itemKey(), l.items()],
31
- x,
39
+ return we(
40
+ () => [t.itemKey(), t.items(), t.items().length],
41
+ y,
32
42
  { immediate: !0 }
33
- ), { getItemKey: P };
43
+ ), { getItemKey: x };
44
+ }
45
+ const Nt = /* @__PURE__ */ new Set([
46
+ "ArrowDown",
47
+ "ArrowUp",
48
+ "End",
49
+ "Home",
50
+ "PageDown",
51
+ "PageUp",
52
+ " "
53
+ ]);
54
+ function Yt(t) {
55
+ const s = ee(!1);
56
+ let I = !1, e = !1, x;
57
+ function y() {
58
+ clearTimeout(x), x = void 0;
59
+ }
60
+ function M(S) {
61
+ S !== s.value && (s.value = S, t.onChange(S));
62
+ }
63
+ function d() {
64
+ I || e || (y(), M(!1), t.onSettled());
65
+ }
66
+ function c() {
67
+ y(), (s.value || t.hasProgrammaticScroll()) && !I && !e && (x = setTimeout(d, t.delay()));
68
+ }
69
+ function n() {
70
+ t.onInterrupt(), y(), M(!0), t.onStart();
71
+ }
72
+ function h() {
73
+ I = !0, n();
74
+ }
75
+ function $(S) {
76
+ I = S.touches.length > 0, c();
77
+ }
78
+ function Y() {
79
+ n(), c();
80
+ }
81
+ function A(S) {
82
+ t.onInterrupt(), Nt.has(S.key) && (n(), c());
83
+ }
84
+ function P(S) {
85
+ t.onInterrupt(), S.pointerType === "mouse" && S.target === t.viewport() && (e = !0, n());
86
+ }
87
+ function E() {
88
+ e && (e = !1, c());
89
+ }
90
+ return {
91
+ isScrolling: s,
92
+ setScrolling: M,
93
+ scheduleScrollEnd: c,
94
+ handleScrollEnd: d,
95
+ handleTouchStart: h,
96
+ handleTouchEnd: $,
97
+ handleWheel: Y,
98
+ handleKeyDown: A,
99
+ handlePointerDown: P,
100
+ handlePointerUp: E,
101
+ dispose: y
102
+ };
34
103
  }
35
- function Fe(l) {
36
- return l === "fill" ? "100%" : typeof l == "number" ? `${l}px` : l;
104
+ function mt(t) {
105
+ return t === "fill" ? "100%" : typeof t == "number" ? `${t}px` : t;
37
106
  }
38
- function Ue(l) {
39
- return (P, x) => {
40
- typeof x == "string" && (x === "fill" || x.trim().endsWith("%"));
107
+ function wt(t) {
108
+ return (s, I) => {
109
+ typeof I == "string" && (I === "fill" || I.trim().endsWith("%"));
41
110
  };
42
111
  }
43
- function at(l) {
44
- const P = Float64Array.from(l), x = P.length, e = new Float64Array(x + 1);
45
- let p = 0;
46
- for (let r = 1; r <= x; r += 1) {
47
- const o = P[r - 1];
48
- p += o, e[r] += o;
49
- const m = r + (r & -r);
50
- m <= x && (e[m] += e[r]);
112
+ function Ne(t) {
113
+ return (t == null ? void 0 : t.count) ?? 0;
114
+ }
115
+ function dt(t) {
116
+ return (t == null ? void 0 : t.total) ?? 0;
117
+ }
118
+ function kt(t) {
119
+ t.count = 1 + Ne(t.left) + Ne(t.right), t.total = t.size + dt(t.left) + dt(t.right), t.left && (t.left.parent = t), t.right && (t.right.parent = t);
120
+ }
121
+ function ft(t, s) {
122
+ return t ? s ? t.priority < s.priority ? (t.right = ft(t.right, s), kt(t), t) : (s.left = ft(t, s.left), kt(s), s) : t : s;
123
+ }
124
+ function jt(t) {
125
+ let s, I = 0;
126
+ const e = /* @__PURE__ */ new Map();
127
+ function x(c) {
128
+ const n = /* @__PURE__ */ new Set();
129
+ for (const h of c) {
130
+ if (e.has(h.key) || n.has(h.key))
131
+ throw new Error(
132
+ `[vue-virtual-flow] Duplicate item key \`${String(h.key)}\`. ChatVirtualScroll requires a unique stable key for every message.`
133
+ );
134
+ n.add(h.key);
135
+ }
51
136
  }
52
- let f = 1;
53
- for (; f * 2 <= x; ) f *= 2;
54
- return {
55
- length: x,
56
- get total() {
57
- return p;
137
+ function y(c) {
138
+ I += 1;
139
+ let n = Math.imul(I ^ 2654435769, 2246822507);
140
+ n ^= n >>> 13, n = Math.imul(n, 3266489909) ^ n >>> 16;
141
+ const h = {
142
+ key: c.key,
143
+ size: c.size,
144
+ priority: n >>> 0,
145
+ count: 1,
146
+ total: c.size
147
+ };
148
+ return e.set(c.key, h), h;
149
+ }
150
+ function M(c) {
151
+ let n;
152
+ for (const h of c) n = ft(n, y(h));
153
+ return n && (n.parent = void 0), n;
154
+ }
155
+ function d(c) {
156
+ let n = s, h = c;
157
+ for (; n; ) {
158
+ const $ = Ne(n.left);
159
+ if (h < $) n = n.left;
160
+ else {
161
+ if (h === $) return n;
162
+ h -= $ + 1, n = n.right;
163
+ }
164
+ }
165
+ }
166
+ return x(t), s = M(t), {
167
+ get length() {
168
+ return Ne(s);
58
169
  },
59
- getSize(r) {
60
- return P[r];
170
+ get total() {
171
+ return dt(s);
61
172
  },
62
- getOffset(r) {
63
- let o = 0;
64
- for (let m = r; m > 0; m -= m & -m)
65
- o += e[m];
66
- return o;
173
+ getSize(c) {
174
+ var n;
175
+ return ((n = d(c)) == null ? void 0 : n.size) ?? 0;
67
176
  },
68
- setSize(r, o) {
69
- const m = o - P[r];
70
- if (m !== 0) {
71
- P[r] = o, p += m;
72
- for (let A = r + 1; A <= x; A += A & -A)
73
- e[A] += m;
177
+ getOffset(c) {
178
+ let n = s, h = Math.max(0, Math.min(c, Ne(s))), $ = 0;
179
+ for (; n && h > 0; ) {
180
+ const Y = Ne(n.left);
181
+ h <= Y ? n = n.left : ($ += dt(n.left) + n.size, h -= Y + 1, n = n.right);
74
182
  }
183
+ return $;
184
+ },
185
+ setSize(c, n) {
186
+ let h = d(c);
187
+ if (!(!h || h.size === n))
188
+ for (h.size = n; h; )
189
+ kt(h), h = h.parent;
75
190
  },
76
- findIndex(r) {
77
- if (x === 0 || r <= 0) return 0;
78
- if (r >= p) return x - 1;
79
- let o = 0, m = 0;
80
- for (let A = f; A > 0; A = Math.floor(A / 2)) {
81
- const O = o + A;
82
- O <= x && m + e[O] <= r && (o = O, m += e[O]);
191
+ findIndex(c) {
192
+ if (!s || c <= 0) return 0;
193
+ if (c >= s.total) return s.count - 1;
194
+ let n = s, h = 0, $ = c;
195
+ for (; n; ) {
196
+ const Y = dt(n.left), A = Ne(n.left);
197
+ if ($ < Y)
198
+ n = n.left;
199
+ else {
200
+ if ($ < Y + n.size)
201
+ return h + A;
202
+ $ -= Y + n.size, h += A + 1, n = n.right;
203
+ }
83
204
  }
84
- return Math.min(o, x - 1);
205
+ return Math.max(0, Ne(s) - 1);
206
+ },
207
+ getKey(c) {
208
+ var n;
209
+ return (n = d(c)) == null ? void 0 : n.key;
210
+ },
211
+ getIndex(c) {
212
+ let n = e.get(c);
213
+ if (!n) return;
214
+ let h = Ne(n.left);
215
+ for (; n.parent; )
216
+ n === n.parent.right && (h += Ne(n.parent.left) + 1), n = n.parent;
217
+ return n === s ? h : void 0;
218
+ },
219
+ getSizeByKey(c) {
220
+ var n;
221
+ return (n = e.get(c)) == null ? void 0 : n.size;
222
+ },
223
+ hasKey(c) {
224
+ return e.has(c);
225
+ },
226
+ append(c) {
227
+ c.length !== 0 && (x(c), s = ft(s, M(c)), s && (s.parent = void 0));
228
+ },
229
+ prepend(c) {
230
+ c.length !== 0 && (x(c), s = ft(M(c), s), s && (s.parent = void 0));
85
231
  }
86
232
  };
87
233
  }
88
- const ot = ["aria-label"], nt = {
234
+ const Ut = ["aria-label", "aria-live"], qt = {
89
235
  key: 0,
90
236
  class: "vue-chat-virtual-scroll__loading-older",
91
237
  role: "status",
92
238
  "aria-live": "polite"
93
- }, it = ["aria-posinset", "aria-setsize"], st = /* @__PURE__ */ Oe({
239
+ }, Gt = ["aria-posinset", "aria-setsize"], Xt = {
240
+ key: 0,
241
+ class: "vue-chat-virtual-scroll__new-items",
242
+ role: "status"
243
+ }, Zt = /* @__PURE__ */ Qe({
94
244
  name: "ChatVirtualScroll",
245
+ inheritAttrs: !1,
95
246
  __name: "ChatVirtualScroll",
96
247
  props: {
97
248
  items: {},
249
+ itemsVersion: {},
98
250
  estimatedItemSize: { default: 48 },
251
+ estimateItemSize: {},
99
252
  height: { default: 400 },
100
253
  overscan: { default: 5 },
101
254
  size: { default: void 0 },
@@ -106,379 +259,559 @@ const ot = ["aria-label"], nt = {
106
259
  initialScroll: { default: "bottom" },
107
260
  hasOlder: { type: Boolean, default: !1 },
108
261
  loadingOlder: { type: Boolean, default: !1 },
109
- loadOlderThreshold: { default: 120 }
262
+ loadOlderThreshold: { default: 120 },
263
+ scrollEndDelay: { default: 150 },
264
+ syncMeasurement: { type: Boolean, default: !0 },
265
+ pinnedKeys: { default: () => [] },
266
+ maxPinnedItems: { default: 20 },
267
+ keepFocusedItem: { type: Boolean, default: !0 },
268
+ showNewItemsIndicator: { type: Boolean, default: !0 },
269
+ newItemsLabel: { type: Function, default: void 0 },
270
+ forceStickToBottom: { type: Function, default: void 0 },
271
+ contain: { type: Boolean, default: !0 }
110
272
  },
111
- emits: ["scroll", "loadOlder", "bottomChange"],
112
- setup(l, { expose: P, emit: x }) {
113
- const e = l, p = x, f = j(), r = j(0), o = j(0), m = j(0), A = j(0), O = j(!0), U = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Set();
114
- let D, w, k = -1, E = !1, F = !1, W = !1, ne, Z = 0, H = !1, ae = 0, R, J, Y, le = 0;
115
- const se = Ue(), { getItemKey: me } = Pe({
273
+ emits: ["scroll", "loadOlder", "bottomChange", "scrollingChange", "newItemsChange", "visibleChange"],
274
+ setup(t, { expose: s, emit: I }) {
275
+ const e = t, x = I, y = ee(), M = ee(0), d = ee(0), c = ee(0), n = ee(0), h = ee(!0), $ = ee(0), Y = ee(), A = /* @__PURE__ */ new Set(), P = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set();
276
+ let S, B, K = -1, G = !1, te = 0, ce = !1, R = 0, fe, ne, oe, ie = 0;
277
+ const H = wt(), { getItemKey: le } = tt({
116
278
  componentName: "ChatVirtualScroll",
117
279
  items: () => e.items,
118
280
  itemKey: () => e.itemKey
119
- }), de = n(
281
+ }), pe = m(
120
282
  () => Number.isFinite(e.estimatedItemSize) ? Math.max(1, e.estimatedItemSize) : 48
121
- ), ue = n(() => Math.max(0, Math.floor(e.overscan))), we = n(
283
+ ), xe = m(() => Math.max(0, Math.floor(e.overscan))), he = m(
284
+ () => Number.isFinite(e.scrollEndDelay) ? Math.max(0, e.scrollEndDelay) : 150
285
+ ), {
286
+ isScrolling: ae,
287
+ setScrolling: F,
288
+ scheduleScrollEnd: b,
289
+ handleScrollEnd: C,
290
+ handleTouchStart: se,
291
+ handleTouchEnd: ve,
292
+ handleWheel: ke,
293
+ handleKeyDown: L,
294
+ handlePointerDown: N,
295
+ handlePointerUp: J,
296
+ dispose: Me
297
+ } = Yt({
298
+ delay: () => he.value,
299
+ viewport: () => y.value,
300
+ hasProgrammaticScroll: () => oe !== void 0,
301
+ onInterrupt: Le,
302
+ onStart: () => {
303
+ d.value = te;
304
+ },
305
+ onSettled: () => {
306
+ const o = oe;
307
+ if (oe = void 0, o) {
308
+ o();
309
+ return;
310
+ }
311
+ M.value = W(), Ie();
312
+ },
313
+ onChange: (o) => {
314
+ G && x("scrollingChange", o);
315
+ }
316
+ }), $e = m(
317
+ () => Number.isFinite(e.maxPinnedItems) ? Math.max(0, Math.floor(e.maxPinnedItems)) : 20
318
+ ), be = m(
122
319
  () => e.size !== void 0 && Number.isFinite(e.size) && e.size > 0 ? Math.max(1, Math.floor(e.size)) : void 0
123
- ), G = n(() => m.value > 0 ? m.value : typeof e.height == "number" ? Math.max(0, e.height) : de.value), u = n(() => {
124
- const i = e.items.map((h, M) => me(h, M));
125
- return {
126
- keys: i,
127
- indexes: new Map(i.map((h, M) => [h, M])),
128
- sizes: at(i.map((h) => U.get(h) ?? de.value))
129
- };
130
- }), d = n(() => (A.value, { sizes: u.value.sizes, total: u.value.sizes.total }));
131
- function z(i = d.value.total) {
132
- return Math.max(0, i - G.value);
320
+ ), ye = m(() => c.value > 0 ? c.value : typeof e.height == "number" ? Math.max(0, e.height) : pe.value);
321
+ function re(o, u) {
322
+ var O;
323
+ const w = (O = e.estimateItemSize) == null ? void 0 : O.call(e, o, u);
324
+ return Number.isFinite(w) && (w ?? 0) > 0 ? w : pe.value;
325
+ }
326
+ function de(o) {
327
+ return jt(e.items.map((u, w) => {
328
+ const O = le(u, w);
329
+ return {
330
+ key: O,
331
+ size: A.has(O) ? (o == null ? void 0 : o.getSizeByKey(O)) ?? re(u, w) : re(u, w)
332
+ };
333
+ }));
133
334
  }
134
- function Q(i) {
135
- return d.value.sizes.findIndex(i);
335
+ const v = ct({ sizes: de() }), T = m(() => (n.value, { sizes: v.value.sizes, total: v.value.sizes.total }));
336
+ function r(o = T.value.total) {
337
+ return Math.max(0, o - ye.value);
136
338
  }
137
- r.value = e.initialScroll === "bottom" ? z() : 0;
138
- const he = n(() => {
339
+ function q(o) {
340
+ return T.value.sizes.findIndex(o);
341
+ }
342
+ M.value = e.initialScroll === "bottom" ? r() : 0;
343
+ const Q = m(() => {
139
344
  if (e.items.length === 0) return { start: 0, end: 0 };
140
- const i = Q(r.value), h = Q(r.value + G.value) + 1, M = Math.max(0, i - ue.value), K = Math.min(
345
+ const o = q(M.value), u = q(M.value + ye.value) + 1;
346
+ return {
347
+ start: o,
348
+ end: Math.min(e.items.length, u)
349
+ };
350
+ }), ze = m(() => {
351
+ if (e.items.length === 0) return { start: 0, end: 0 };
352
+ const o = Q.value.start, u = Q.value.end, w = Math.max(0, o - xe.value), O = Math.min(
141
353
  e.items.length,
142
- h + ue.value
143
- ), pe = we.value;
144
- if (pe === void 0 || K - M <= pe) return { start: M, end: K };
145
- const xe = Math.max(0, pe - (h - i)), Te = i - M, Se = K - h;
146
- let Ee = Math.min(Te, Math.ceil(xe / 2));
147
- const $e = Math.min(Se, xe - Ee);
148
- return Ee = Math.min(Te, xe - $e), { start: i - Ee, end: h + $e };
149
- }), y = n(() => he.value.start), L = n(() => he.value.end), B = n(
150
- () => e.items.slice(y.value, L.value).map((i, h) => {
151
- const M = y.value + h;
152
- return {
153
- item: i,
154
- index: M,
155
- key: me(i, M),
156
- bottom: Math.max(d.value.total, G.value) - d.value.sizes.getOffset(M + 1) + o.value
157
- };
158
- })
159
- ), te = n(() => ({
160
- height: Fe(e.height)
161
- }));
162
- function oe(i = d.value.total) {
163
- var K;
164
- const h = z(i), M = Math.min(0, ((K = f.value) == null ? void 0 : K.scrollTop) ?? 0);
165
- return Math.max(0, Math.min(h, h + M + Z));
166
- }
167
- function re(i = !1) {
168
- if (H || (W || Y) && !i || Z === 0) return;
169
- H = !0;
170
- const h = le, M = ++ae;
171
- o.value = 0, C(() => {
172
- if (M !== ae) return;
173
- H = !1;
174
- const K = f.value;
175
- !K || h !== le || Z === 0 || (Z = 0, K.scrollTop = Math.min(0, r.value - z()), J = K.scrollTop, r.value = oe(), b(), ve());
354
+ u + xe.value
355
+ ), Pe = be.value;
356
+ if (Pe === void 0 || O - w <= Pe) return { start: w, end: O };
357
+ const Ee = Math.max(0, Pe - (u - o)), De = o - w, Re = O - u;
358
+ let Fe = Math.min(De, Math.ceil(Ee / 2));
359
+ const Ge = Math.min(Re, Ee - Fe);
360
+ return Fe = Math.min(De, Ee - Ge), { start: o - Fe, end: u + Ge };
361
+ }), i = m(() => ze.value.start), D = m(() => ze.value.end), _ = m(() => {
362
+ const o = /* @__PURE__ */ new Set();
363
+ for (let u = i.value; u < D.value; u += 1)
364
+ o.add(u);
365
+ for (const u of e.pinnedKeys.slice(0, $e.value)) {
366
+ const w = v.value.sizes.getIndex(u);
367
+ w !== void 0 && o.add(w);
368
+ }
369
+ if (e.keepFocusedItem && Y.value !== void 0) {
370
+ const u = v.value.sizes.getIndex(Y.value);
371
+ u !== void 0 && o.add(u);
372
+ }
373
+ return [...o].sort((u, w) => u - w);
374
+ }), X = m(() => _.value.map((o) => {
375
+ const u = e.items[o];
376
+ return {
377
+ item: u,
378
+ index: o,
379
+ key: le(u, o),
380
+ bottom: Math.max(T.value.total, ye.value) - T.value.sizes.getOffset(o + 1) + d.value
381
+ };
382
+ })), p = m(() => ({
383
+ height: mt(e.height)
384
+ })), z = m(() => ({
385
+ "vue-chat-virtual-scroll--contained": e.contain
386
+ })), k = m(() => h.value && !ae.value ? "polite" : "off");
387
+ function me(o) {
388
+ var u;
389
+ return ((u = e.newItemsLabel) == null ? void 0 : u.call(e, o)) ?? `${o} new ${o === 1 ? "message" : "messages"}`;
390
+ }
391
+ function W(o = T.value.total) {
392
+ var O;
393
+ const u = r(o), w = Math.min(0, ((O = y.value) == null ? void 0 : O.scrollTop) ?? 0);
394
+ return Math.max(0, Math.min(u, u + w + te));
395
+ }
396
+ function Ie(o = !1) {
397
+ if (ce || (ae.value || oe) && !o || te === 0) return;
398
+ ce = !0;
399
+ const u = ie, w = ++R;
400
+ d.value = 0, Z(() => {
401
+ if (w !== R) return;
402
+ ce = !1;
403
+ const O = y.value;
404
+ !O || u !== ie || te === 0 || (te = 0, O.scrollTop = Math.min(0, M.value - r()), ne = O.scrollTop, M.value = W(), a(), V());
176
405
  });
177
406
  }
178
- function ye(i) {
179
- const h = f.value;
180
- if (h) {
181
- if (Z += i, r.value = oe(), Z === 0 || z() === 0) {
182
- Z = 0, o.value = 0;
407
+ function ge(o) {
408
+ const u = y.value;
409
+ if (u) {
410
+ if (te += o, M.value = W(), te === 0 || r() === 0) {
411
+ te = 0, d.value = 0;
183
412
  return;
184
413
  }
185
- (W || Y) && !H ? (o.value = Z, h.scrollTop >= -1 && re(!0)) : re();
414
+ (ae.value || oe) && !ce ? (d.value = te, u.scrollTop >= -1 && Ie(!0)) : Ie();
186
415
  }
187
416
  }
188
- function _() {
189
- clearTimeout(ne), ne = void 0;
417
+ function Le() {
418
+ fe = void 0, oe = void 0;
190
419
  }
191
- function ee() {
192
- if (F) return;
193
- _(), W = !1;
194
- const i = Y;
195
- if (Y = void 0, i) {
196
- i();
420
+ function He() {
421
+ if (!e.keepFocusedItem) {
422
+ Y.value = void 0;
197
423
  return;
198
424
  }
199
- r.value = oe(), re();
425
+ const o = document.activeElement, u = o instanceof Element ? o.closest(".vue-chat-virtual-scroll__item") : null;
426
+ Y.value = u ? P.get(u) : void 0;
200
427
  }
201
- function s() {
202
- _(), (W || Y) && !F && (ne = setTimeout(ee, 150));
428
+ function Oe() {
429
+ He();
203
430
  }
204
- function t() {
205
- R = void 0, Y = void 0;
431
+ function Mt() {
432
+ Z(He);
206
433
  }
207
- function a() {
208
- t(), _(), F = !0, W = !0, o.value = Z;
434
+ function ht(o) {
435
+ const u = Math.max(0, Math.floor(o));
436
+ u !== $.value && ($.value = u, G && x("newItemsChange", u));
437
+ }
438
+ function it() {
439
+ ht(0);
209
440
  }
210
- function g(i) {
211
- F = i.touches.length > 0, s();
441
+ function rt() {
442
+ x("visibleChange", {
443
+ scrollTop: W(),
444
+ startIndex: Q.value.start,
445
+ endIndex: Q.value.end
446
+ });
212
447
  }
213
- function b() {
214
- const i = f.value;
215
- if (!i) return;
216
- const M = Math.max(
448
+ function a() {
449
+ const o = y.value;
450
+ if (!o) return;
451
+ const w = Math.max(
217
452
  0,
218
- d.value.total - oe() - i.clientHeight
453
+ T.value.total - W() - o.clientHeight
219
454
  ) <= Math.max(0, e.bottomThreshold);
220
- M !== O.value && (O.value = M, E && p("bottomChange", M));
455
+ w !== h.value && (h.value = w, G && x("bottomChange", w)), w && it();
221
456
  }
222
- function Me() {
223
- var i;
224
- m.value = ((i = f.value) == null ? void 0 : i.clientHeight) ?? 0, E && (r.value = oe()), se(f.value, e.height), C(() => {
225
- b(), ve();
457
+ function l() {
458
+ var o;
459
+ c.value = ((o = y.value) == null ? void 0 : o.clientHeight) ?? 0, G && (M.value = W()), H(y.value, e.height), Z(() => {
460
+ a(), V();
226
461
  });
227
462
  }
228
- function ge() {
229
- var i, h;
230
- R && J !== void 0 && Math.abs((((i = f.value) == null ? void 0 : i.scrollTop) ?? 0) - J) > 1 && t(), r.value = oe(), Z !== 0 && (((h = f.value) == null ? void 0 : h.scrollTop) ?? 0) >= -1 && re(!0), s(), b(), p("scroll", {
231
- scrollTop: r.value,
232
- startIndex: y.value,
233
- endIndex: L.value
234
- }), ve();
235
- }
236
- function ve() {
237
- const i = f.value;
238
- !E || !i || !e.hasOlder || e.loadingOlder || k === e.items.length || oe() <= Math.max(0, e.loadOlderThreshold) && (k = e.items.length, p("loadOlder"));
239
- }
240
- function Le(i) {
241
- const h = i.borderBoxSize;
242
- if (h) {
243
- const M = Array.isArray(h) ? h[0] : h;
244
- if (M != null && M.blockSize) return M.blockSize;
463
+ function g() {
464
+ var o, u;
465
+ fe && ne !== void 0 && Math.abs((((o = y.value) == null ? void 0 : o.scrollTop) ?? 0) - ne) > 1 && Le(), M.value = W(), te !== 0 && (((u = y.value) == null ? void 0 : u.scrollTop) ?? 0) >= -1 && Ie(!0), b(), a(), x("scroll", {
466
+ scrollTop: M.value,
467
+ startIndex: i.value,
468
+ endIndex: D.value
469
+ }), V();
470
+ }
471
+ function V() {
472
+ const o = y.value;
473
+ !G || !o || !e.hasOlder || e.loadingOlder || K === e.items.length || W() <= Math.max(0, e.loadOlderThreshold) && (K = e.items.length, x("loadOlder"));
474
+ }
475
+ function Te(o) {
476
+ const u = o.borderBoxSize;
477
+ if (u) {
478
+ const w = Array.isArray(u) ? u[0] : u;
479
+ if (w != null && w.blockSize) return w.blockSize;
245
480
  }
246
- return i.contentRect.height;
247
- }
248
- function ke(i) {
249
- const h = d.value.total, M = oe(), K = !W && !Y && O.value && e.stickToBottom && (E || e.initialScroll === "bottom"), pe = Q(M + G.value - 1), xe = !K && M <= 0;
250
- let Te = 0, Se = !1;
251
- for (const { key: Je, height: We } of i) {
252
- if (!Number.isFinite(We) || We <= 0) continue;
253
- const _e = u.value.indexes.get(Je);
254
- if (_e === void 0) continue;
255
- const Qe = d.value.sizes.getSize(_e);
256
- U.set(Je, We), !(Math.abs(Qe - We) < 0.5) && (_e <= pe && (Te += We - Qe), d.value.sizes.setSize(_e, We), Se = !0);
481
+ return o.contentRect.height;
482
+ }
483
+ function Be(o) {
484
+ const u = T.value.total, w = W(), O = !ae.value && !oe && h.value && e.stickToBottom && (G || e.initialScroll === "bottom"), Pe = q(w + ye.value - 1), Ee = !O && w <= 0;
485
+ let De = 0, Re = !1;
486
+ for (const { key: pt, height: Xe } of o) {
487
+ if (!Number.isFinite(Xe) || Xe <= 0) continue;
488
+ const Ye = v.value.sizes.getIndex(pt);
489
+ if (Ye === void 0) continue;
490
+ const Ze = T.value.sizes.getSize(Ye);
491
+ A.add(pt), !(Math.abs(Ze - Xe) < 0.5) && (Ye <= Pe && (De += Xe - Ze), T.value.sizes.setSize(Ye, Xe), Re = !0);
257
492
  }
258
- if (!Se) return;
259
- A.value += 1;
260
- const Ee = z() - z(h), $e = R && u.value.indexes.get(R.key), Ne = $e !== void 0 && R ? Ie($e, R.align) : K ? z() : xe ? 0 : M + Te;
261
- ye(Ne - M - Ee), C(b);
262
- }
263
- function v(i) {
264
- const h = [];
265
- for (const M of i) {
266
- const K = q.get(M.target);
267
- K !== void 0 && h.push({ key: K, height: Le(M) });
493
+ if (!Re) return;
494
+ n.value += 1;
495
+ const Fe = r() - r(u), Ge = fe && v.value.sizes.getIndex(fe.key), bt = Ge !== void 0 && fe ? Ct(Ge, fe.align) : O ? r() : Ee ? 0 : w + De;
496
+ ge(bt - w - Fe), Z(a);
497
+ }
498
+ function Ae(o) {
499
+ const u = [];
500
+ for (const w of o) {
501
+ const O = P.get(w.target);
502
+ O !== void 0 && u.push({ key: O, height: Te(w) });
268
503
  }
269
- ke(h);
504
+ Be(u);
270
505
  }
271
- function S() {
272
- const i = [];
273
- for (const h of V) {
274
- const M = q.get(h);
275
- M !== void 0 && h.isConnected && i.push({ key: M, height: h.getBoundingClientRect().height });
506
+ function We() {
507
+ const o = [];
508
+ for (const u of E) {
509
+ const w = P.get(u);
510
+ w !== void 0 && u.isConnected && o.push({ key: w, height: u.getBoundingClientRect().height });
276
511
  }
277
- V.clear(), ke(i);
278
- }
279
- function T(i, h) {
280
- i instanceof HTMLElement && q.get(i) !== h && (q.set(i, h), U.has(h) || V.add(i), w == null || w.observe(i));
281
- }
282
- function fe() {
283
- for (const [i] of q)
284
- i.isConnected || (w == null || w.unobserve(i), q.delete(i), V.delete(i));
285
- }
286
- function X(i, h, M = !1) {
287
- const K = f.value;
288
- if (!K) return;
289
- const pe = oe(), xe = o.value !== 0, Te = ++le;
290
- ae += 1, H = !1, R = void 0;
291
- const Se = h.behavior ?? "auto";
292
- Y = Se === "smooth" ? () => be(i) : void 0, Z = 0, o.value = 0, W = !1, _(), Se === "auto" && (r.value = i);
293
- const Ee = () => {
294
- f.value !== K || Te !== le || (xe && Se !== "auto" && (K.scrollTop = pe - z()), M && Se === "auto" ? K.scrollTop = i - z() : K.scrollTo({ ...h, top: i - z(), behavior: Se }), J = K.scrollTop, Se === "auto" ? r.value = oe() : s(), C(b));
512
+ E.clear(), Be(o);
513
+ }
514
+ function at(o, u) {
515
+ o instanceof HTMLElement && P.get(o) !== u && (P.set(o, u), e.syncMeasurement && !A.has(u) && E.add(o), B == null || B.observe(o));
516
+ }
517
+ function Dt() {
518
+ for (const [o] of P)
519
+ o.isConnected || (B == null || B.unobserve(o), P.delete(o), E.delete(o));
520
+ }
521
+ function st(o, u, w = !1) {
522
+ const O = y.value;
523
+ if (!O) return;
524
+ const Pe = W(), Ee = d.value !== 0, De = ++ie;
525
+ R += 1, ce = !1, fe = void 0;
526
+ const Re = u.behavior ?? "auto";
527
+ oe = Re === "smooth" ? () => Et(o) : void 0, te = 0, d.value = 0, F(!1), Me(), Re === "auto" && (M.value = o);
528
+ const Fe = () => {
529
+ y.value !== O || De !== ie || (Ee && Re !== "auto" && (O.scrollTop = Pe - r()), w && Re === "auto" ? O.scrollTop = o - r() : O.scrollTo({ ...u, top: o - r(), behavior: Re }), ne = O.scrollTop, Re === "auto" ? M.value = W() : b(), Z(a));
295
530
  };
296
- xe ? C(Ee) : Ee();
297
- }
298
- function be(i, h = {}) {
299
- const M = f.value;
300
- if (!M) return;
301
- const K = Math.max(0, d.value.total - M.clientHeight), pe = Math.min(
302
- Math.max(0, Number.isFinite(i) ? i : 0),
303
- K
531
+ Ee ? Z(Fe) : Fe();
532
+ }
533
+ function Et(o, u = {}) {
534
+ const w = y.value;
535
+ if (!w) return;
536
+ const O = Math.max(0, T.value.total - w.clientHeight), Pe = Math.min(
537
+ Math.max(0, Number.isFinite(o) ? o : 0),
538
+ O
304
539
  );
305
- X(pe, h);
540
+ st(Pe, u);
306
541
  }
307
- function Ie(i, h) {
308
- const M = d.value.sizes.getSize(i);
309
- let K = d.value.sizes.getOffset(i);
310
- return h === "center" ? K -= (G.value - M) / 2 : h === "end" && (K -= G.value - M), Math.max(0, Math.min(K, z()));
542
+ function Ct(o, u) {
543
+ const w = T.value.sizes.getSize(o);
544
+ let O = T.value.sizes.getOffset(o);
545
+ return u === "center" ? O -= (ye.value - w) / 2 : u === "end" && (O -= ye.value - w), Math.max(0, Math.min(O, r()));
311
546
  }
312
- function Be(i, h = {}) {
313
- if (!f.value || e.items.length === 0) return;
314
- const M = Math.min(
547
+ function Tt(o, u = {}) {
548
+ if (!y.value || e.items.length === 0) return;
549
+ const w = Math.min(
315
550
  e.items.length - 1,
316
- Math.max(0, Math.floor(Number.isFinite(i) ? i : 0))
317
- ), { align: K = "start", ...pe } = h;
318
- X(Ie(M, K), pe);
319
- const xe = u.value.keys[M];
320
- h.behavior === "smooth" ? Y = () => {
321
- const Te = u.value.indexes.get(xe);
322
- Te !== void 0 && Be(Te, { align: K });
323
- } : R = { key: xe, align: K };
324
- }
325
- function Ke(i = "auto") {
326
- X(0, { behavior: i });
327
- }
328
- function He(i = "auto") {
329
- const h = f.value;
330
- if (!h) return;
331
- const M = Math.max(0, d.value.total - h.clientHeight);
332
- X(M, { behavior: i }, !0), i === "smooth" && (Y = () => He());
333
- }
334
- return ie(
335
- u,
336
- async (i, h) => {
337
- const M = h.sizes.total, K = oe(M), pe = !W && !Y && O.value && e.stickToBottom, xe = h.sizes.findIndex(K + G.value - 1), Te = h.keys[xe], Se = Te === void 0 ? void 0 : i.indexes.get(Te), Ee = z() - z(M);
338
- for (const $e of U.keys())
339
- i.indexes.has($e) || U.delete($e);
340
- if (i.keys.length === 0 || Se === void 0) {
341
- Z = 0, o.value = 0, r.value = pe ? z() : Math.min(K, z());
342
- const $e = r.value, Ne = le;
343
- await C(), Ne === le && u.value === i && X($e, {}, !0);
551
+ Math.max(0, Math.floor(Number.isFinite(o) ? o : 0))
552
+ ), { align: O = "start", ...Pe } = u;
553
+ st(Ct(w, O), Pe);
554
+ const Ee = v.value.sizes.getKey(w);
555
+ u.behavior === "smooth" ? oe = () => {
556
+ const De = v.value.sizes.getIndex(Ee);
557
+ De !== void 0 && Tt(De, { align: O });
558
+ } : fe = { key: Ee, align: O };
559
+ }
560
+ function Kt(o, u = {}) {
561
+ const w = v.value.sizes.getIndex(o);
562
+ w !== void 0 && Tt(w, u);
563
+ }
564
+ function Vt() {
565
+ return W();
566
+ }
567
+ function Wt(o = "auto") {
568
+ st(0, { behavior: o });
569
+ }
570
+ function gt(o = "auto") {
571
+ const u = y.value;
572
+ if (!u) return;
573
+ const w = Math.max(0, T.value.total - u.clientHeight);
574
+ st(w, { behavior: o }, !0), o === "smooth" && (oe = () => gt());
575
+ }
576
+ const Lt = ee(0);
577
+ function Rt() {
578
+ Lt.value += 1;
579
+ }
580
+ return we(
581
+ () => {
582
+ const o = e.items.length;
583
+ return [
584
+ e.items,
585
+ o,
586
+ o > 0 ? le(e.items[0], 0) : void 0,
587
+ o > 0 ? le(e.items[Math.floor(o / 2)], Math.floor(o / 2)) : void 0,
588
+ o > 0 ? le(e.items[o - 1], o - 1) : void 0,
589
+ e.itemKey,
590
+ e.estimatedItemSize,
591
+ e.estimateItemSize,
592
+ e.itemsVersion,
593
+ Lt.value
594
+ ];
595
+ },
596
+ async (o, u) => {
597
+ const w = v.value.sizes, O = w.length, Pe = w.total, Ee = W(Pe), De = w.findIndex(Ee + ye.value - 1), Re = w.getKey(De), Fe = w.getOffset(De + 1), Ge = e.items.length, bt = o[5] !== u[5] || o[6] !== u[6] || o[7] !== u[7], pt = o[8] !== u[8] || o[9] !== u[9];
598
+ function Xe(Ce) {
599
+ if (O === 0) return !0;
600
+ const Ke = /* @__PURE__ */ new Set([0, Math.floor(O / 2), O - 1]);
601
+ for (const nt of Ke) {
602
+ const yt = Ce + nt;
603
+ if (yt >= Ge || w.getKey(nt) !== le(e.items[yt], yt))
604
+ return !1;
605
+ }
606
+ return !0;
607
+ }
608
+ const Ye = Ge - O;
609
+ let Ze = "rebuild";
610
+ !bt && !pt && Ye > 0 && (Xe(0) ? Ze = "append" : Xe(Ye) && (Ze = "prepend"));
611
+ let je = w;
612
+ Ze === "append" ? je.append(e.items.slice(O).map((Ce, Ke) => {
613
+ const nt = O + Ke;
614
+ return { key: le(Ce, nt), size: re(Ce, nt) };
615
+ })) : Ze === "prepend" ? je.prepend(e.items.slice(0, Ye).map((Ce, Ke) => ({ key: le(Ce, Ke), size: re(Ce, Ke) }))) : je = de(w), v.value = { sizes: je };
616
+ const St = Ze === "append" ? Array.from({ length: Ye }, (Ce, Ke) => O + Ke) : [], It = St.some(
617
+ (Ce) => {
618
+ var Ke;
619
+ return ((Ke = e.forceStickToBottom) == null ? void 0 : Ke.call(e, e.items[Ce], Ce)) === !0;
620
+ }
621
+ ) || !ae.value && !oe && h.value && e.stickToBottom;
622
+ St.length > 0 && !It && ht($.value + St.length);
623
+ const Pt = Re === void 0 ? void 0 : je.getIndex(Re), Ht = r() - r(Pe);
624
+ for (const Ce of A)
625
+ je.hasKey(Ce) || A.delete(Ce);
626
+ if (je.length === 0 || Pt === void 0) {
627
+ te = 0, d.value = 0, M.value = It ? r() : Math.min(Ee, r());
628
+ const Ce = M.value, Ke = ie;
629
+ await Z(), Ke === ie && v.value.sizes === je && st(Ce, {}, !0);
344
630
  } else {
345
- const $e = i.sizes.getOffset(Se + 1) - h.sizes.getOffset(xe + 1), Ne = pe ? z() : K + $e;
346
- ye(Ne - K - Ee), await C();
631
+ const Ce = je.getOffset(Pt + 1) - Fe, Ke = It ? r() : Ee + Ce;
632
+ ge(Ke - Ee - Ht), await Z();
347
633
  }
348
- f.value && (r.value = oe(), b(), ve());
634
+ y.value && (M.value = W(), a(), V());
349
635
  }
350
- ), ie(
636
+ ), we(
351
637
  () => [e.hasOlder, e.loadingOlder],
352
- async ([i]) => {
353
- i || (k = -1), await C(), ve();
638
+ async ([o]) => {
639
+ o || (K = -1), await Z(), V();
354
640
  }
355
- ), Ae(() => {
356
- if (Me(), f.value && (f.value.scrollTop = e.initialScroll === "bottom" ? 0 : -z(), r.value = oe()), S(), typeof ResizeObserver < "u") {
357
- D = new ResizeObserver(Me), w = new ResizeObserver(v), f.value && D.observe(f.value);
358
- for (const [i] of q)
359
- w.observe(i);
641
+ ), we(
642
+ () => e.syncMeasurement,
643
+ (o) => {
644
+ if (E.clear(), !!o) {
645
+ for (const [u, w] of P)
646
+ A.has(w) || E.add(u);
647
+ Z(We);
648
+ }
360
649
  }
361
- C(() => {
362
- E = !0, b(), ve();
650
+ ), we(
651
+ Q,
652
+ () => {
653
+ G && rt();
654
+ },
655
+ { flush: "post" }
656
+ ), _e(() => {
657
+ if (window.addEventListener("pointerup", J, { passive: !0 }), window.addEventListener("pointercancel", J, { passive: !0 }), l(), y.value && (y.value.scrollTop = e.initialScroll === "bottom" ? 0 : -r(), M.value = W()), We(), typeof ResizeObserver < "u") {
658
+ S = new ResizeObserver(l), B = new ResizeObserver(Ae), y.value && S.observe(y.value);
659
+ for (const [o] of P)
660
+ B.observe(o);
661
+ }
662
+ Z(() => {
663
+ G = !0, a(), V(), rt();
363
664
  });
364
- }), Xe(() => {
365
- fe(), S();
366
- }), Ce(() => {
367
- E = !1, _(), t(), Z = 0, le += 1, ae += 1, D && (D.disconnect(), D = void 0), w && (w.disconnect(), w = void 0), q.clear(), V.clear();
368
- }), P({
369
- isAtBottom: O,
370
- scrollTo: be,
371
- scrollToIndex: Be,
372
- scrollToTop: Ke,
373
- scrollToBottom: He
374
- }), (i, h) => (I(), $("div", {
375
- ref_key: "viewport",
376
- ref: f,
377
- class: "vue-chat-virtual-scroll",
378
- style: N(te.value),
379
- role: "log",
380
- "aria-label": l.ariaLabel,
381
- "aria-live": "polite",
382
- tabindex: "0",
383
- onScrollPassive: ge,
384
- onScrollendPassive: ee,
385
- onPointerdownPassive: t,
386
- onWheelPassive: t,
387
- onKeydown: t,
388
- onTouchstartPassive: a,
389
- onTouchendPassive: g,
390
- onTouchcancelPassive: g
665
+ }), $t(() => {
666
+ Dt(), We();
667
+ }), qe(() => {
668
+ G = !1, window.removeEventListener("pointerup", J), window.removeEventListener("pointercancel", J), Me(), Le(), te = 0, ie += 1, R += 1, S && (S.disconnect(), S = void 0), B && (B.disconnect(), B = void 0), P.clear(), E.clear();
669
+ }), s({
670
+ isAtBottom: h,
671
+ isScrolling: ae,
672
+ newItemsCount: $,
673
+ clearNewItems: it,
674
+ refresh: Rt,
675
+ getScrollPosition: Vt,
676
+ scrollTo: Et,
677
+ scrollToIndex: Tt,
678
+ scrollToKey: Kt,
679
+ scrollToTop: Wt,
680
+ scrollToBottom: gt
681
+ }), (o, u) => (j(), U("div", {
682
+ class: "vue-chat-virtual-scroll__root",
683
+ style: ue(p.value)
391
684
  }, [
392
- Ge("div", {
393
- class: "vue-chat-virtual-scroll__spacer",
394
- style: N({ height: `${Math.max(G.value, d.value.total + o.value)}px` })
395
- }, [
396
- l.loadingOlder ? (I(), $("div", nt, [
397
- Ge("div", null, [
398
- ce(i.$slots, "loadingOlder", {}, () => [
399
- h[0] || (h[0] = Ve("Loading older messages…", -1))
400
- ])
401
- ])
402
- ])) : ze("", !0),
403
- (I(!0), $(Re, null, De(B.value, ({ item: M, index: K, key: pe, bottom: xe }) => (I(), $("div", {
404
- key: pe,
405
- ref_for: !0,
406
- ref: (Te) => T(Te, pe),
407
- class: "vue-chat-virtual-scroll__item",
408
- style: N({ transform: `translateY(${-xe}px)` }),
409
- role: "article",
410
- "aria-posinset": K + 1,
411
- "aria-setsize": l.items.length
685
+ lt("div", Ot(o.$attrs, {
686
+ ref_key: "viewport",
687
+ ref: y,
688
+ class: ["vue-chat-virtual-scroll", z.value],
689
+ role: "log",
690
+ "aria-label": t.ariaLabel,
691
+ "aria-live": k.value,
692
+ "aria-relevant": "additions",
693
+ "aria-atomic": "false",
694
+ tabindex: "0",
695
+ onScrollPassive: g,
696
+ onScrollendPassive: u[0] || (u[0] = //@ts-ignore
697
+ (...w) => f(C) && f(C)(...w)),
698
+ onPointerdownPassive: u[1] || (u[1] = //@ts-ignore
699
+ (...w) => f(N) && f(N)(...w)),
700
+ onWheelPassive: u[2] || (u[2] = //@ts-ignore
701
+ (...w) => f(ke) && f(ke)(...w)),
702
+ onKeydown: u[3] || (u[3] = //@ts-ignore
703
+ (...w) => f(L) && f(L)(...w)),
704
+ onFocusin: Oe,
705
+ onFocusout: Mt,
706
+ onTouchstartPassive: u[4] || (u[4] = //@ts-ignore
707
+ (...w) => f(se) && f(se)(...w)),
708
+ onTouchendPassive: u[5] || (u[5] = //@ts-ignore
709
+ (...w) => f(ve) && f(ve)(...w)),
710
+ onTouchcancelPassive: u[6] || (u[6] = //@ts-ignore
711
+ (...w) => f(ve) && f(ve)(...w))
712
+ }), [
713
+ lt("div", {
714
+ class: "vue-chat-virtual-scroll__spacer",
715
+ style: ue({ height: `${Math.max(ye.value, T.value.total + d.value)}px` })
412
716
  }, [
413
- ce(i.$slots, "default", {
414
- item: M,
415
- index: K
416
- })
417
- ], 12, it))), 128)),
418
- l.items.length ? ze("", !0) : ce(i.$slots, "empty", {}, void 0, void 0, 1)
419
- ], 4)
420
- ], 44, ot));
717
+ t.loadingOlder ? (j(), U("div", qt, [
718
+ lt("div", null, [
719
+ Se(o.$slots, "loadingOlder", {}, () => [
720
+ u[8] || (u[8] = Ue("Loading older messages…", -1))
721
+ ])
722
+ ])
723
+ ])) : Ve("", !0),
724
+ (j(!0), U(Je, null, et(X.value, ({ item: w, index: O, key: Pe, bottom: Ee }) => (j(), U("div", {
725
+ key: Pe,
726
+ ref_for: !0,
727
+ ref: (De) => at(De, Pe),
728
+ class: "vue-chat-virtual-scroll__item",
729
+ style: ue({ transform: `translateY(${-Ee}px)` }),
730
+ role: "article",
731
+ "aria-posinset": O + 1,
732
+ "aria-setsize": t.items.length
733
+ }, [
734
+ Se(o.$slots, "default", {
735
+ item: w,
736
+ index: O
737
+ })
738
+ ], 12, Gt))), 128)),
739
+ t.items.length ? Ve("", !0) : Se(o.$slots, "empty", {}, void 0, void 0, 1)
740
+ ], 4)
741
+ ], 16, Ut),
742
+ t.showNewItemsIndicator && $.value > 0 ? (j(), U("div", Xt, [
743
+ Se(o.$slots, "newItems", {
744
+ count: $.value,
745
+ scrollToBottom: gt
746
+ }, () => [
747
+ lt("button", {
748
+ type: "button",
749
+ onClick: u[7] || (u[7] = (w) => gt("smooth"))
750
+ }, vt(me($.value)), 1)
751
+ ])
752
+ ])) : Ve("", !0)
753
+ ], 4));
421
754
  }
422
755
  });
423
- function qe(l) {
424
- const P = j(), x = j(0), e = j(!1), p = j(!1), f = n(() => Math.max(1, l.threshold())), r = n(
425
- () => l.refreshing() || p.value ? f.value : x.value
426
- ), o = n(
427
- () => Math.min(1, x.value / f.value)
428
- ), m = n(() => l.refreshing() || p.value ? "Refreshing…" : o.value >= 1 ? "Release to refresh" : "Pull to refresh");
429
- function A() {
430
- P.value = void 0, e.value = !1, x.value = 0;
756
+ function xt(t) {
757
+ const s = ee(), I = ee(0), e = ee(!1), x = ee(!1), y = m(() => Math.max(1, t.threshold())), M = m(
758
+ () => t.refreshing() || x.value ? y.value : I.value
759
+ ), d = m(
760
+ () => Math.min(1, I.value / y.value)
761
+ ), c = m(() => t.refreshing() || x.value ? "Refreshing…" : d.value >= 1 ? "Release to refresh" : "Pull to refresh");
762
+ function n() {
763
+ s.value = void 0, e.value = !1, I.value = 0;
431
764
  }
432
- function O(V) {
433
- var k;
434
- const D = V.currentTarget, w = ((k = l.scrollTop) == null ? void 0 : k.call(l)) ?? D.scrollTop;
435
- !l.enabled() || l.refreshing() || w > 0 || V.touches.length !== 1 || (P.value = V.touches[0].clientY, e.value = !0);
765
+ function h(A) {
766
+ var S;
767
+ const P = A.currentTarget, E = ((S = t.scrollTop) == null ? void 0 : S.call(t)) ?? P.scrollTop;
768
+ !t.enabled() || t.refreshing() || E > 0 || A.touches.length !== 1 || (s.value = A.touches[0].clientY, e.value = !0);
436
769
  }
437
- function U(V) {
438
- var E;
439
- if (P.value === void 0 || !e.value) return;
440
- const D = V.currentTarget;
441
- if ((((E = l.scrollTop) == null ? void 0 : E.call(l)) ?? D.scrollTop) > 0 || V.touches.length !== 1) {
442
- A();
770
+ function $(A) {
771
+ var B;
772
+ if (s.value === void 0 || !e.value) return;
773
+ const P = A.currentTarget;
774
+ if ((((B = t.scrollTop) == null ? void 0 : B.call(t)) ?? P.scrollTop) > 0 || A.touches.length !== 1) {
775
+ n();
443
776
  return;
444
777
  }
445
- const k = V.touches[0].clientY - P.value;
446
- if (k <= 0) {
447
- x.value = 0;
778
+ const S = A.touches[0].clientY - s.value;
779
+ if (S <= 0) {
780
+ I.value = 0;
448
781
  return;
449
782
  }
450
- V.preventDefault(), x.value = Math.min(k * 0.5, f.value * 2);
783
+ A.preventDefault(), I.value = Math.min(S * 0.5, y.value * 2);
451
784
  }
452
- function q() {
453
- if (P.value === void 0) return;
454
- const V = x.value >= f.value && l.enabled() && !l.refreshing();
455
- if (P.value = void 0, e.value = !1, !V) {
456
- x.value = 0;
785
+ function Y() {
786
+ if (s.value === void 0) return;
787
+ const A = I.value >= y.value && t.enabled() && !t.refreshing();
788
+ if (s.value = void 0, e.value = !1, !A) {
789
+ I.value = 0;
457
790
  return;
458
791
  }
459
- x.value = f.value, p.value = !0, l.onRefresh(), C(() => {
460
- l.refreshing() || (p.value = !1, x.value = 0);
792
+ I.value = y.value, x.value = !0, t.onRefresh(), Z(() => {
793
+ t.refreshing() || (x.value = !1, I.value = 0);
461
794
  });
462
795
  }
463
- return ie(
464
- () => l.refreshing(),
465
- (V, D) => {
466
- V ? (p.value = !1, x.value = f.value) : D && (p.value = !1, x.value = 0);
796
+ return we(
797
+ () => t.refreshing(),
798
+ (A, P) => {
799
+ A ? (x.value = !1, I.value = y.value) : P && (x.value = !1, I.value = 0);
467
800
  }
468
801
  ), {
469
802
  pulling: e,
470
- pullDistance: x,
471
- pullOffset: r,
472
- pullProgress: o,
473
- refreshMessage: m,
474
- refreshThreshold: f,
475
- handleTouchStart: O,
476
- handleTouchMove: U,
477
- handleTouchEnd: q,
478
- handleTouchCancel: A
803
+ pullDistance: I,
804
+ pullOffset: M,
805
+ pullProgress: d,
806
+ refreshMessage: c,
807
+ refreshThreshold: y,
808
+ handleTouchStart: h,
809
+ handleTouchMove: $,
810
+ handleTouchEnd: Y,
811
+ handleTouchCancel: n
479
812
  };
480
813
  }
481
- const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PURE__ */ Oe({
814
+ const Jt = ["aria-label"], Qt = ["aria-posinset", "aria-setsize"], Bt = /* @__PURE__ */ Qe({
482
815
  name: "DynamicVirtualScroll",
483
816
  __name: "DynamicVirtualScroll",
484
817
  props: {
@@ -497,294 +830,294 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
497
830
  pullRefreshThreshold: { default: 64 }
498
831
  },
499
832
  emits: ["scroll", "loadMore", "refresh"],
500
- setup(l, { expose: P, emit: x }) {
501
- const e = l, p = x, {
502
- pulling: f,
503
- pullDistance: r,
504
- pullOffset: o,
505
- pullProgress: m,
506
- refreshMessage: A,
507
- refreshThreshold: O,
508
- handleTouchStart: U,
509
- handleTouchMove: q,
510
- handleTouchEnd: V,
511
- handleTouchCancel: D
512
- } = qe({
833
+ setup(t, { expose: s, emit: I }) {
834
+ const e = t, x = I, {
835
+ pulling: y,
836
+ pullDistance: M,
837
+ pullOffset: d,
838
+ pullProgress: c,
839
+ refreshMessage: n,
840
+ refreshThreshold: h,
841
+ handleTouchStart: $,
842
+ handleTouchMove: Y,
843
+ handleTouchEnd: A,
844
+ handleTouchCancel: P
845
+ } = xt({
513
846
  enabled: () => e.pullToRefresh,
514
847
  refreshing: () => e.refreshing,
515
848
  threshold: () => e.pullRefreshThreshold,
516
- onRefresh: () => p("refresh")
517
- }), w = j(), k = j(0), E = j(0), F = j(0), W = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Map();
518
- let Z, H, ae = -1;
519
- const R = Ue(), { getItemKey: J } = Pe({
849
+ onRefresh: () => x("refresh")
850
+ }), E = ee(), S = ee(0), B = ee(0), K = ee(0), G = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Map();
851
+ let ce, R, fe = -1;
852
+ const ne = wt(), { getItemKey: oe } = tt({
520
853
  componentName: "DynamicVirtualScroll",
521
854
  items: () => e.items,
522
855
  itemKey: () => e.itemKey
523
- }), Y = n(
856
+ }), ie = m(
524
857
  () => Math.max(1, e.estimatedItemSize)
525
- ), le = n(
526
- () => Math.max(1, e.loadingItemSize ?? Y.value)
527
- ), se = n(() => Math.max(0, Math.floor(e.overscan))), me = n(() => E.value > 0 ? E.value : typeof e.height == "number" ? Math.max(0, e.height) : Y.value), de = n(() => {
528
- F.value;
529
- const s = new Array(e.items.length + 1), t = new Array(e.items.length);
530
- s[0] = 0;
531
- for (let a = 0; a < e.items.length; a += 1) {
532
- const g = J(e.items[a], a), b = W.get(g) ?? Y.value;
533
- t[a] = b, s[a + 1] = s[a] + b;
858
+ ), H = m(
859
+ () => Math.max(1, e.loadingItemSize ?? ie.value)
860
+ ), le = m(() => Math.max(0, Math.floor(e.overscan))), pe = m(() => B.value > 0 ? B.value : typeof e.height == "number" ? Math.max(0, e.height) : ie.value), xe = m(() => {
861
+ K.value;
862
+ const v = new Array(e.items.length + 1), T = new Array(e.items.length);
863
+ v[0] = 0;
864
+ for (let r = 0; r < e.items.length; r += 1) {
865
+ const q = oe(e.items[r], r), Q = G.get(q) ?? ie.value;
866
+ T[r] = Q, v[r + 1] = v[r] + Q;
534
867
  }
535
868
  return {
536
- offsets: s,
537
- sizes: t,
538
- total: s[e.items.length] ?? 0
869
+ offsets: v,
870
+ sizes: T,
871
+ total: v[e.items.length] ?? 0
539
872
  };
540
- }), ue = n(
541
- () => de.value.total + (e.loading ? le.value : 0)
542
- ), we = n(() => {
543
- const s = /* @__PURE__ */ new Map();
544
- return e.items.forEach((t, a) => {
545
- s.set(J(t, a), a);
546
- }), s;
873
+ }), he = m(
874
+ () => xe.value.total + (e.loading ? H.value : 0)
875
+ ), ae = m(() => {
876
+ const v = /* @__PURE__ */ new Map();
877
+ return e.items.forEach((T, r) => {
878
+ v.set(oe(T, r), r);
879
+ }), v;
547
880
  });
548
- function G(s) {
881
+ function F(v) {
549
882
  if (e.items.length === 0) return 0;
550
- const t = de.value.offsets;
551
- let a = 0, g = e.items.length;
552
- for (; a < g; ) {
553
- const b = Math.floor((a + g) / 2);
554
- t[b + 1] <= s ? a = b + 1 : g = b;
883
+ const T = xe.value.offsets;
884
+ let r = 0, q = e.items.length;
885
+ for (; r < q; ) {
886
+ const Q = Math.floor((r + q) / 2);
887
+ T[Q + 1] <= v ? r = Q + 1 : q = Q;
555
888
  }
556
- return Math.min(a, e.items.length - 1);
889
+ return Math.min(r, e.items.length - 1);
557
890
  }
558
- const u = n(
891
+ const b = m(
559
892
  () => Math.max(
560
893
  0,
561
- G(k.value) - se.value
894
+ F(S.value) - le.value
562
895
  )
563
- ), d = n(() => {
896
+ ), C = m(() => {
564
897
  if (e.items.length === 0) return 0;
565
- const s = G(k.value + me.value) + 1;
898
+ const v = F(S.value + pe.value) + 1;
566
899
  return Math.min(
567
900
  e.items.length,
568
- s + se.value
901
+ v + le.value
569
902
  );
570
- }), z = n(
571
- () => e.items.slice(u.value, d.value).map((s, t) => {
572
- const a = u.value + t;
903
+ }), se = m(
904
+ () => e.items.slice(b.value, C.value).map((v, T) => {
905
+ const r = b.value + T;
573
906
  return {
574
- item: s,
575
- index: a,
576
- key: J(s, a),
577
- top: de.value.offsets[a]
907
+ item: v,
908
+ index: r,
909
+ key: oe(v, r),
910
+ top: xe.value.offsets[r]
578
911
  };
579
912
  })
580
- ), Q = n(() => ({
581
- height: Fe(e.height)
913
+ ), ve = m(() => ({
914
+ height: mt(e.height)
582
915
  }));
583
- function he() {
584
- var s;
585
- E.value = ((s = w.value) == null ? void 0 : s.clientHeight) ?? 0, R(w.value, e.height), C(L);
916
+ function ke() {
917
+ var v;
918
+ B.value = ((v = E.value) == null ? void 0 : v.clientHeight) ?? 0, ne(E.value, e.height), Z(N);
586
919
  }
587
- function y(s) {
588
- k.value = s.currentTarget.scrollTop, p("scroll", {
589
- scrollTop: k.value,
590
- startIndex: u.value,
591
- endIndex: d.value
592
- }), L();
593
- }
594
- function L() {
595
- const s = w.value;
596
- if (!s || !e.hasMore || e.loading || ae === e.items.length)
920
+ function L(v) {
921
+ S.value = v.currentTarget.scrollTop, x("scroll", {
922
+ scrollTop: S.value,
923
+ startIndex: b.value,
924
+ endIndex: C.value
925
+ }), N();
926
+ }
927
+ function N() {
928
+ const v = E.value;
929
+ if (!v || !e.hasMore || e.loading || fe === e.items.length)
597
930
  return;
598
- const t = Math.max(0, e.loadMoreThreshold);
599
- ue.value - s.scrollTop - s.clientHeight <= t && (ae = e.items.length, p("loadMore"));
600
- }
601
- function B(s) {
602
- const t = s.borderBoxSize;
603
- if (t) {
604
- const a = Array.isArray(t) ? t[0] : t;
605
- if (a != null && a.blockSize) return a.blockSize;
931
+ const T = Math.max(0, e.loadMoreThreshold);
932
+ he.value - v.scrollTop - v.clientHeight <= T && (fe = e.items.length, x("loadMore"));
933
+ }
934
+ function J(v) {
935
+ const T = v.borderBoxSize;
936
+ if (T) {
937
+ const r = Array.isArray(T) ? T[0] : T;
938
+ if (r != null && r.blockSize) return r.blockSize;
606
939
  }
607
- return s.contentRect.height;
608
- }
609
- function te(s) {
610
- const t = de.value;
611
- let a = 0, g = !1;
612
- for (const b of s) {
613
- const Me = b.target, ge = ne.get(Me), ve = B(b);
614
- if (ge === void 0 || ve <= 0) continue;
615
- const Le = W.get(ge) ?? Y.value;
616
- if (Math.abs(Le - ve) < 0.5) continue;
617
- const ke = we.value.get(ge);
618
- ke !== void 0 && t.offsets[ke + 1] <= k.value && (a += ve - Le), W.set(ge, ve), g = !0;
940
+ return v.contentRect.height;
941
+ }
942
+ function Me(v) {
943
+ const T = xe.value;
944
+ let r = 0, q = !1;
945
+ for (const Q of v) {
946
+ const ze = Q.target, i = te.get(ze), D = J(Q);
947
+ if (i === void 0 || D <= 0) continue;
948
+ const _ = G.get(i) ?? ie.value;
949
+ if (Math.abs(_ - D) < 0.5) continue;
950
+ const X = ae.value.get(i);
951
+ X !== void 0 && T.offsets[X + 1] <= S.value && (r += D - _), G.set(i, D), q = !0;
619
952
  }
620
- g && (F.value += 1, C(L), a !== 0 && C(() => {
621
- const b = w.value;
622
- b && (b.scrollTop += a, k.value = b.scrollTop);
953
+ q && (K.value += 1, Z(N), r !== 0 && Z(() => {
954
+ const Q = E.value;
955
+ Q && (Q.scrollTop += r, S.value = Q.scrollTop);
623
956
  }));
624
957
  }
625
- function oe(s, t) {
626
- s instanceof HTMLElement && (ne.set(s, t), H == null || H.observe(s));
627
- }
628
- function re() {
629
- for (const [s] of ne)
630
- s.isConnected || (H == null || H.unobserve(s), ne.delete(s));
631
- }
632
- function ye(s, t = {}) {
633
- const a = w.value;
634
- if (!a) return;
635
- const g = Math.max(0, ue.value - a.clientHeight), b = Math.min(
636
- Math.max(0, Number.isFinite(s) ? s : 0),
637
- g
638
- ), Me = t.behavior ?? "auto";
639
- Me === "auto" && (k.value = b), a.scrollTo({ ...t, top: b, behavior: Me });
640
- }
641
- function _(s, t = {}) {
642
- const a = w.value;
643
- if (!a || e.items.length === 0) return;
644
- const g = Math.min(
958
+ function $e(v, T) {
959
+ v instanceof HTMLElement && (te.set(v, T), R == null || R.observe(v));
960
+ }
961
+ function be() {
962
+ for (const [v] of te)
963
+ v.isConnected || (R == null || R.unobserve(v), te.delete(v));
964
+ }
965
+ function ye(v, T = {}) {
966
+ const r = E.value;
967
+ if (!r) return;
968
+ const q = Math.max(0, he.value - r.clientHeight), Q = Math.min(
969
+ Math.max(0, Number.isFinite(v) ? v : 0),
970
+ q
971
+ ), ze = T.behavior ?? "auto";
972
+ ze === "auto" && (S.value = Q), r.scrollTo({ ...T, top: Q, behavior: ze });
973
+ }
974
+ function re(v, T = {}) {
975
+ const r = E.value;
976
+ if (!r || e.items.length === 0) return;
977
+ const q = Math.min(
645
978
  e.items.length - 1,
646
- Math.max(0, Math.floor(s))
647
- ), { align: b = "start", ...Me } = t;
648
- let ge = de.value.offsets[g];
649
- const ve = de.value.sizes[g];
650
- b === "center" ? ge -= (a.clientHeight - ve) / 2 : b === "end" && (ge -= a.clientHeight - ve);
651
- const Le = Math.max(
979
+ Math.max(0, Math.floor(v))
980
+ ), { align: Q = "start", ...ze } = T;
981
+ let i = xe.value.offsets[q];
982
+ const D = xe.value.sizes[q];
983
+ Q === "center" ? i -= (r.clientHeight - D) / 2 : Q === "end" && (i -= r.clientHeight - D);
984
+ const _ = Math.max(
652
985
  0,
653
- Math.min(ge, ue.value - a.clientHeight)
654
- ), ke = Me.behavior ?? "auto";
655
- ke === "auto" && (k.value = Le), a.scrollTo({
656
- ...Me,
657
- top: Le,
658
- behavior: ke
986
+ Math.min(i, he.value - r.clientHeight)
987
+ ), X = ze.behavior ?? "auto";
988
+ X === "auto" && (S.value = _), r.scrollTo({
989
+ ...ze,
990
+ top: _,
991
+ behavior: X
659
992
  });
660
993
  }
661
- function ee(s = "auto") {
662
- var t;
663
- (t = w.value) == null || t.scrollTo({ top: 0, behavior: s });
994
+ function de(v = "auto") {
995
+ var T;
996
+ (T = E.value) == null || T.scrollTo({ top: 0, behavior: v });
664
997
  }
665
- return ie(
998
+ return we(
666
999
  () => e.itemKey,
667
1000
  () => {
668
- W.clear(), F.value += 1;
1001
+ G.clear(), K.value += 1;
669
1002
  }
670
- ), ie(
1003
+ ), we(
671
1004
  () => e.items.length,
672
1005
  async () => {
673
- const s = new Set(
674
- e.items.map((g, b) => J(g, b))
1006
+ const v = new Set(
1007
+ e.items.map((q, Q) => oe(q, Q))
675
1008
  );
676
- for (const g of W.keys())
677
- s.has(g) || W.delete(g);
678
- F.value += 1, await C();
679
- const t = w.value;
680
- if (!t) return;
681
- const a = Math.max(0, ue.value - t.clientHeight);
682
- t.scrollTop > a && (t.scrollTop = a, k.value = a), L();
1009
+ for (const q of G.keys())
1010
+ v.has(q) || G.delete(q);
1011
+ K.value += 1, await Z();
1012
+ const T = E.value;
1013
+ if (!T) return;
1014
+ const r = Math.max(0, he.value - T.clientHeight);
1015
+ T.scrollTop > r && (T.scrollTop = r, S.value = r), N();
683
1016
  }
684
- ), ie(
1017
+ ), we(
685
1018
  () => [e.hasMore, e.loading],
686
- async ([s]) => {
687
- s || (ae = -1), await C(), L();
1019
+ async ([v]) => {
1020
+ v || (fe = -1), await Z(), N();
688
1021
  }
689
- ), Ae(() => {
690
- if (he(), typeof ResizeObserver < "u") {
691
- Z = new ResizeObserver(he), H = new ResizeObserver(te), w.value && Z.observe(w.value);
692
- for (const [s] of ne)
693
- H.observe(s);
1022
+ ), _e(() => {
1023
+ if (ke(), typeof ResizeObserver < "u") {
1024
+ ce = new ResizeObserver(ke), R = new ResizeObserver(Me), E.value && ce.observe(E.value);
1025
+ for (const [v] of te)
1026
+ R.observe(v);
694
1027
  }
695
- C(L);
696
- }), Xe(re), Ce(() => {
697
- Z && (Z.disconnect(), Z = void 0), H && (H.disconnect(), H = void 0), ne.clear();
698
- }), P({
1028
+ Z(N);
1029
+ }), $t(be), qe(() => {
1030
+ ce && (ce.disconnect(), ce = void 0), R && (R.disconnect(), R = void 0), te.clear();
1031
+ }), s({
699
1032
  scrollTo: ye,
700
- scrollToIndex: _,
701
- scrollToTop: ee
702
- }), (s, t) => (I(), $("div", {
1033
+ scrollToIndex: re,
1034
+ scrollToTop: de
1035
+ }), (v, T) => (j(), U("div", {
703
1036
  ref_key: "viewport",
704
- ref: w,
705
- class: Ye(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": c(f) }]),
706
- style: N(Q.value),
1037
+ ref: E,
1038
+ class: ot(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": f(y) }]),
1039
+ style: ue(ve.value),
707
1040
  role: "list",
708
- "aria-label": l.ariaLabel,
1041
+ "aria-label": t.ariaLabel,
709
1042
  tabindex: "0",
710
- onScrollPassive: y,
711
- onTouchstartPassive: t[0] || (t[0] = //@ts-ignore
712
- (...a) => c(U) && c(U)(...a)),
713
- onTouchmove: t[1] || (t[1] = //@ts-ignore
714
- (...a) => c(q) && c(q)(...a)),
715
- onTouchend: t[2] || (t[2] = //@ts-ignore
716
- (...a) => c(V) && c(V)(...a)),
717
- onTouchcancel: t[3] || (t[3] = //@ts-ignore
718
- (...a) => c(D) && c(D)(...a))
1043
+ onScrollPassive: L,
1044
+ onTouchstartPassive: T[0] || (T[0] = //@ts-ignore
1045
+ (...r) => f($) && f($)(...r)),
1046
+ onTouchmove: T[1] || (T[1] = //@ts-ignore
1047
+ (...r) => f(Y) && f(Y)(...r)),
1048
+ onTouchend: T[2] || (T[2] = //@ts-ignore
1049
+ (...r) => f(A) && f(A)(...r)),
1050
+ onTouchcancel: T[3] || (T[3] = //@ts-ignore
1051
+ (...r) => f(P) && f(P)(...r))
719
1052
  }, [
720
- l.pullToRefresh || l.refreshing ? (I(), $("div", {
1053
+ t.pullToRefresh || t.refreshing ? (j(), U("div", {
721
1054
  key: 0,
722
1055
  class: "vue-dynamic-virtual-scroll__refresh",
723
- style: N({
724
- height: `${c(O)}px`,
725
- transform: `translateY(${c(o) - c(O)}px)`
1056
+ style: ue({
1057
+ height: `${f(h)}px`,
1058
+ transform: `translateY(${f(d) - f(h)}px)`
726
1059
  }),
727
1060
  role: "status",
728
1061
  "aria-live": "polite"
729
1062
  }, [
730
- ce(s.$slots, "refresh", {
731
- pullDistance: c(r),
732
- progress: c(m),
733
- refreshing: l.refreshing
1063
+ Se(v.$slots, "refresh", {
1064
+ pullDistance: f(M),
1065
+ progress: f(c),
1066
+ refreshing: t.refreshing
734
1067
  }, () => [
735
- Ve(je(c(A)), 1)
1068
+ Ue(vt(f(n)), 1)
736
1069
  ])
737
- ], 4)) : ze("", !0),
738
- l.items.length || l.loading ? (I(), $("div", {
1070
+ ], 4)) : Ve("", !0),
1071
+ t.items.length || t.loading ? (j(), U("div", {
739
1072
  key: 1,
740
1073
  class: "vue-dynamic-virtual-scroll__spacer",
741
- style: N({
742
- height: `${ue.value}px`,
743
- transform: `translateY(${c(o)}px)`
1074
+ style: ue({
1075
+ height: `${he.value}px`,
1076
+ transform: `translateY(${f(d)}px)`
744
1077
  })
745
1078
  }, [
746
- (I(!0), $(Re, null, De(z.value, ({ item: a, index: g, key: b, top: Me }) => (I(), $("div", {
747
- key: b,
1079
+ (j(!0), U(Je, null, et(se.value, ({ item: r, index: q, key: Q, top: ze }) => (j(), U("div", {
1080
+ key: Q,
748
1081
  ref_for: !0,
749
- ref: (ge) => oe(ge, b),
1082
+ ref: (i) => $e(i, Q),
750
1083
  class: "vue-dynamic-virtual-scroll__item",
751
- style: N({ transform: `translateY(${Me}px)` }),
1084
+ style: ue({ transform: `translateY(${ze}px)` }),
752
1085
  role: "listitem",
753
- "aria-posinset": g + 1,
754
- "aria-setsize": l.items.length
1086
+ "aria-posinset": q + 1,
1087
+ "aria-setsize": t.items.length
755
1088
  }, [
756
- ce(s.$slots, "default", {
757
- item: a,
758
- index: g
1089
+ Se(v.$slots, "default", {
1090
+ item: r,
1091
+ index: q
759
1092
  })
760
- ], 12, ut))), 128)),
761
- l.loading ? (I(), $("div", {
1093
+ ], 12, Qt))), 128)),
1094
+ t.loading ? (j(), U("div", {
762
1095
  key: 0,
763
1096
  class: "vue-dynamic-virtual-scroll__loading",
764
- style: N({
765
- height: `${le.value}px`,
766
- transform: `translateY(${de.value.total}px)`
1097
+ style: ue({
1098
+ height: `${H.value}px`,
1099
+ transform: `translateY(${xe.value.total}px)`
767
1100
  }),
768
1101
  role: "status",
769
1102
  "aria-live": "polite"
770
1103
  }, [
771
- ce(s.$slots, "loading", {}, () => [
772
- t[4] || (t[4] = Ve("Loading more…", -1))
1104
+ Se(v.$slots, "loading", {}, () => [
1105
+ T[4] || (T[4] = Ue("Loading more…", -1))
773
1106
  ])
774
- ], 4)) : ze("", !0)
775
- ], 4)) : (I(), $("div", {
1107
+ ], 4)) : Ve("", !0)
1108
+ ], 4)) : (j(), U("div", {
776
1109
  key: 2,
777
1110
  class: "vue-dynamic-virtual-scroll__empty",
778
- style: N({ transform: `translateY(${c(o)}px)` })
1111
+ style: ue({ transform: `translateY(${f(d)}px)` })
779
1112
  }, [
780
- ce(s.$slots, "empty")
1113
+ Se(v.$slots, "empty")
781
1114
  ], 4))
782
- ], 46, rt));
1115
+ ], 46, Jt));
783
1116
  }
784
- }), ct = ["aria-label"], dt = ["aria-current", "aria-posinset", "aria-setsize"], ft = {
1117
+ }), _t = ["aria-label"], ea = ["aria-current", "aria-posinset", "aria-setsize"], ta = {
785
1118
  key: 1,
786
1119
  class: "vue-short-media-feed__empty"
787
- }, vt = 36, ht = 700, mt = /* @__PURE__ */ Oe({
1120
+ }, aa = 36, na = 700, la = /* @__PURE__ */ Qe({
788
1121
  name: "ShortMediaFeed",
789
1122
  __name: "ShortMediaFeed",
790
1123
  props: {
@@ -799,170 +1132,174 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
799
1132
  loadMoreThreshold: { default: 2 }
800
1133
  },
801
1134
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
802
- setup(l, { expose: P, emit: x }) {
803
- const e = l, p = x, f = j(), r = j(0), o = j(R(e.activeIndex));
804
- let m, A = -1, O = 0, U = !1, q;
805
- const V = Ue(), { getItemKey: D } = Pe({
1135
+ setup(t, { expose: s, emit: I }) {
1136
+ const e = t, x = I, y = ee(), M = ee(0), d = ee(ne(e.activeIndex));
1137
+ let c, n = -1, h = 0, $ = !1, Y;
1138
+ const A = wt(), { getItemKey: P } = tt({
806
1139
  componentName: "ShortMediaFeed",
807
1140
  items: () => e.items,
808
1141
  itemKey: () => e.itemKey
809
- }), w = n(
1142
+ }), E = m(
810
1143
  () => Math.max(0, Math.floor(e.buffer))
811
- ), k = n(
1144
+ ), S = m(
812
1145
  () => Math.max(
813
1146
  0,
814
1147
  Math.floor(
815
1148
  Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
816
1149
  )
817
1150
  )
818
- ), E = n(() => r.value > 0 ? r.value : typeof e.height == "number" ? Math.max(1, e.height) : 0), F = n(
819
- () => Math.max(0, o.value - w.value)
820
- ), W = n(
1151
+ ), B = m(() => M.value > 0 ? M.value : typeof e.height == "number" ? Math.max(1, e.height) : 0), K = m(
1152
+ () => Math.max(0, d.value - E.value)
1153
+ ), G = m(
821
1154
  () => Math.min(
822
1155
  e.items.length,
823
- o.value + w.value + 1
1156
+ d.value + E.value + 1
824
1157
  )
825
- ), ne = n(
826
- () => e.items.slice(F.value, W.value).map((u, d) => ({
827
- item: u,
828
- index: F.value + d
829
- }))
830
- ), Z = n(() => F.value * E.value), H = n(
831
- () => (e.items.length - W.value) * E.value
832
- ), ae = n(() => ({
833
- height: Fe(e.height)
1158
+ ), te = m(
1159
+ () => (
1160
+ // Do not register zero-sized snap targets before a CSS height is measured.
1161
+ // WebKit can retain the second target at scrollTop=0 and jump to it on resize.
1162
+ (B.value > 0 ? e.items : []).slice(K.value, G.value).map((b, C) => ({
1163
+ item: b,
1164
+ index: K.value + C
1165
+ }))
1166
+ )
1167
+ ), ce = m(() => K.value * B.value), R = m(
1168
+ () => (e.items.length - G.value) * B.value
1169
+ ), fe = m(() => ({
1170
+ height: mt(e.height)
834
1171
  }));
835
- function R(u) {
1172
+ function ne(b) {
836
1173
  return e.items.length === 0 ? 0 : Math.min(
837
1174
  e.items.length - 1,
838
- Math.max(0, Math.floor(Number.isFinite(u) ? u : 0))
1175
+ Math.max(0, Math.floor(Number.isFinite(b) ? b : 0))
839
1176
  );
840
1177
  }
841
- function J() {
842
- if (!e.hasMore || e.loading || A === e.items.length)
1178
+ function oe() {
1179
+ if (!e.hasMore || e.loading || n === e.items.length)
843
1180
  return;
844
- (e.items.length === 0 ? 0 : e.items.length - 1 - o.value) <= k.value && (A = e.items.length, p("loadMore"));
1181
+ (e.items.length === 0 ? 0 : e.items.length - 1 - d.value) <= S.value && (n = e.items.length, x("loadMore"));
845
1182
  }
846
- function Y(u) {
847
- const d = R(u);
848
- d === o.value || e.items.length === 0 || (o.value = d, p("update:activeIndex", d), p("change", {
849
- index: d,
850
- item: e.items[d]
851
- }), d === 0 && p("reachStart"), d === e.items.length - 1 && p("reachEnd"), J());
1183
+ function ie(b) {
1184
+ const C = ne(b);
1185
+ C === d.value || e.items.length === 0 || (d.value = C, x("update:activeIndex", C), x("change", {
1186
+ index: C,
1187
+ item: e.items[C]
1188
+ }), C === 0 && x("reachStart"), C === e.items.length - 1 && x("reachEnd"), oe());
852
1189
  }
853
- function le(u, d = {}) {
854
- const z = f.value;
855
- z && (typeof z.scrollTo == "function" ? z.scrollTo({ ...d, top: u }) : z.scrollTop = u);
1190
+ function H(b, C = {}) {
1191
+ const se = y.value;
1192
+ se && (typeof se.scrollTo == "function" ? se.scrollTo({ ...C, top: b }) : se.scrollTop = b);
856
1193
  }
857
- function se(u, d = {}) {
1194
+ function le(b, C = {}) {
858
1195
  if (e.items.length === 0) return;
859
- const z = R(u);
860
- Y(z), le(z * E.value, d);
861
- }
862
- function me(u) {
863
- if (E.value <= 0) return;
864
- const d = u.currentTarget.scrollTop;
865
- Y(Math.round(d / E.value));
866
- }
867
- function de(u) {
868
- let d;
869
- u.key === "ArrowDown" || u.key === "PageDown" ? d = o.value + 1 : u.key === "ArrowUp" || u.key === "PageUp" ? d = o.value - 1 : u.key === "Home" ? d = 0 : u.key === "End" && (d = e.items.length - 1), d !== void 0 && (u.preventDefault(), se(d, { behavior: "smooth" }));
870
- }
871
- function ue(u) {
872
- return u.deltaMode === WheelEvent.DOM_DELTA_LINE ? u.deltaY * 16 : u.deltaMode === WheelEvent.DOM_DELTA_PAGE ? u.deltaY * (E.value || 1) : u.deltaY;
873
- }
874
- function we(u) {
875
- if (u.ctrlKey || Math.abs(u.deltaX) > Math.abs(u.deltaY) || e.items.length === 0 || E.value <= 0 || (u.preventDefault(), U)) return;
876
- const d = ue(u);
877
- if (d * O < 0 && (O = 0), O += d, Math.abs(O) < vt) return;
878
- const z = O > 0 ? 1 : -1;
879
- O = 0;
880
- const Q = o.value + z;
881
- Q < 0 || Q >= e.items.length || (U = !0, se(Q, { behavior: "smooth" }), q = setTimeout(() => {
882
- U = !1;
883
- }, ht));
884
- }
885
- function G() {
886
- var d;
887
- const u = ((d = f.value) == null ? void 0 : d.clientHeight) ?? 0;
888
- V(f.value, e.height), !(u <= 0 || u === r.value) && (r.value = u, C(() => {
889
- le(o.value * u);
1196
+ const se = ne(b);
1197
+ ie(se), H(se * B.value, C);
1198
+ }
1199
+ function pe(b) {
1200
+ if (B.value <= 0) return;
1201
+ const C = b.currentTarget.scrollTop;
1202
+ ie(Math.round(C / B.value));
1203
+ }
1204
+ function xe(b) {
1205
+ let C;
1206
+ b.key === "ArrowDown" || b.key === "PageDown" ? C = d.value + 1 : b.key === "ArrowUp" || b.key === "PageUp" ? C = d.value - 1 : b.key === "Home" ? C = 0 : b.key === "End" && (C = e.items.length - 1), C !== void 0 && (b.preventDefault(), le(C, { behavior: "smooth" }));
1207
+ }
1208
+ function he(b) {
1209
+ return b.deltaMode === WheelEvent.DOM_DELTA_LINE ? b.deltaY * 16 : b.deltaMode === WheelEvent.DOM_DELTA_PAGE ? b.deltaY * (B.value || 1) : b.deltaY;
1210
+ }
1211
+ function ae(b) {
1212
+ if (b.ctrlKey || Math.abs(b.deltaX) > Math.abs(b.deltaY) || e.items.length === 0 || B.value <= 0 || (b.preventDefault(), $)) return;
1213
+ const C = he(b);
1214
+ if (C * h < 0 && (h = 0), h += C, Math.abs(h) < aa) return;
1215
+ const se = h > 0 ? 1 : -1;
1216
+ h = 0;
1217
+ const ve = d.value + se;
1218
+ ve < 0 || ve >= e.items.length || ($ = !0, le(ve, { behavior: "smooth" }), Y = setTimeout(() => {
1219
+ $ = !1;
1220
+ }, na));
1221
+ }
1222
+ function F() {
1223
+ var C;
1224
+ const b = ((C = y.value) == null ? void 0 : C.clientHeight) ?? 0;
1225
+ A(y.value, e.height), !(b <= 0 || b === M.value) && (M.value = b, Z(() => {
1226
+ H(d.value * b);
890
1227
  }));
891
1228
  }
892
- return ie(
1229
+ return we(
893
1230
  () => e.activeIndex,
894
- async (u) => {
895
- const d = R(u);
896
- d !== o.value && (o.value = d, await C(), le(d * E.value), J());
1231
+ async (b) => {
1232
+ const C = ne(b);
1233
+ C !== d.value && (d.value = C, await Z(), H(C * B.value), oe());
897
1234
  }
898
- ), ie(
1235
+ ), we(
899
1236
  () => [
900
1237
  e.hasMore,
901
1238
  e.loading,
902
1239
  e.loadMoreThreshold
903
1240
  ],
904
- async ([u]) => {
905
- u || (A = -1), await C(), J();
1241
+ async ([b]) => {
1242
+ b || (n = -1), await Z(), oe();
906
1243
  }
907
- ), ie(
1244
+ ), we(
908
1245
  () => e.items.length,
909
1246
  async () => {
910
- const u = R(o.value);
911
- e.items.length === 0 ? o.value !== 0 && (o.value = 0, p("update:activeIndex", 0)) : Y(u), await C(), le(u * E.value), J();
1247
+ const b = ne(d.value);
1248
+ e.items.length === 0 ? d.value !== 0 && (d.value = 0, x("update:activeIndex", 0)) : ie(b), await Z(), H(b * B.value), oe();
912
1249
  }
913
- ), Ae(async () => {
914
- G(), typeof ResizeObserver < "u" && f.value && (m = new ResizeObserver(G), m.observe(f.value)), await C(), le(o.value * E.value), J();
915
- }), Ce(() => {
916
- m && (m.disconnect(), m = void 0), q && (clearTimeout(q), q = void 0);
917
- }), P({
918
- scrollToIndex: se
919
- }), (u, d) => (I(), $("div", {
1250
+ ), _e(async () => {
1251
+ F(), typeof ResizeObserver < "u" && y.value && (c = new ResizeObserver(F), c.observe(y.value)), await Z(), H(d.value * B.value), oe();
1252
+ }), qe(() => {
1253
+ c && (c.disconnect(), c = void 0), Y && (clearTimeout(Y), Y = void 0);
1254
+ }), s({
1255
+ scrollToIndex: le
1256
+ }), (b, C) => (j(), U("div", {
920
1257
  ref_key: "viewport",
921
- ref: f,
1258
+ ref: y,
922
1259
  class: "vue-short-media-feed",
923
- style: N(ae.value),
1260
+ style: ue(fe.value),
924
1261
  role: "list",
925
1262
  "aria-orientation": "vertical",
926
- "aria-label": l.ariaLabel,
1263
+ "aria-label": t.ariaLabel,
927
1264
  tabindex: "0",
928
- onScrollPassive: me,
929
- onWheel: we,
930
- onKeydown: de
1265
+ onScrollPassive: pe,
1266
+ onWheel: ae,
1267
+ onKeydown: xe
931
1268
  }, [
932
- l.items.length ? (I(), $(Re, { key: 0 }, [
933
- Z.value > 0 ? (I(), $("div", {
1269
+ t.items.length ? (j(), U(Je, { key: 0 }, [
1270
+ ce.value > 0 ? (j(), U("div", {
934
1271
  key: 0,
935
1272
  class: "vue-short-media-feed__spacer",
936
- style: N({ height: `${Z.value}px` }),
1273
+ style: ue({ height: `${ce.value}px` }),
937
1274
  "aria-hidden": "true"
938
- }, null, 4)) : ze("", !0),
939
- (I(!0), $(Re, null, De(ne.value, ({ item: z, index: Q }) => (I(), $("div", {
940
- key: c(D)(z, Q),
1275
+ }, null, 4)) : Ve("", !0),
1276
+ (j(!0), U(Je, null, et(te.value, ({ item: se, index: ve }) => (j(), U("div", {
1277
+ key: f(P)(se, ve),
941
1278
  class: "vue-short-media-feed__item",
942
- style: N({ height: `${E.value}px` }),
1279
+ style: ue({ height: `${B.value}px` }),
943
1280
  role: "listitem",
944
- "aria-current": Q === o.value ? "true" : void 0,
945
- "aria-posinset": Q + 1,
946
- "aria-setsize": l.items.length
1281
+ "aria-current": ve === d.value ? "true" : void 0,
1282
+ "aria-posinset": ve + 1,
1283
+ "aria-setsize": t.items.length
947
1284
  }, [
948
- ce(u.$slots, "default", {
949
- item: z,
950
- index: Q,
951
- active: Q === o.value
1285
+ Se(b.$slots, "default", {
1286
+ item: se,
1287
+ index: ve,
1288
+ active: ve === d.value
952
1289
  })
953
- ], 12, dt))), 128)),
954
- H.value > 0 ? (I(), $("div", {
1290
+ ], 12, ea))), 128)),
1291
+ R.value > 0 ? (j(), U("div", {
955
1292
  key: 1,
956
1293
  class: "vue-short-media-feed__spacer",
957
- style: N({ height: `${H.value}px` }),
1294
+ style: ue({ height: `${R.value}px` }),
958
1295
  "aria-hidden": "true"
959
- }, null, 4)) : ze("", !0)
960
- ], 64)) : (I(), $("div", ft, [
961
- ce(u.$slots, "empty")
1296
+ }, null, 4)) : Ve("", !0)
1297
+ ], 64)) : (j(), U("div", ta, [
1298
+ Se(b.$slots, "empty")
962
1299
  ]))
963
- ], 44, ct));
1300
+ ], 44, _t));
964
1301
  }
965
- }), gt = ["aria-label"], pt = /* @__PURE__ */ Oe({
1302
+ }), oa = ["aria-label"], ia = /* @__PURE__ */ Qe({
966
1303
  __name: "SkeletonLoader",
967
1304
  props: {
968
1305
  width: { default: "100%" },
@@ -971,38 +1308,308 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
971
1308
  animated: { type: Boolean, default: !0 },
972
1309
  ariaLabel: { default: "Loading…" }
973
1310
  },
974
- setup(l) {
975
- const P = l;
976
- function x(p) {
977
- return typeof p == "number" ? `${Math.max(0, p)}px` : p;
978
- }
979
- const e = n(() => ({
980
- width: x(P.width),
981
- height: x(P.height)
1311
+ setup(t) {
1312
+ const s = t;
1313
+ function I(x) {
1314
+ return typeof x == "number" ? `${Math.max(0, x)}px` : x;
1315
+ }
1316
+ const e = m(() => ({
1317
+ width: I(s.width),
1318
+ height: I(s.height)
982
1319
  }));
983
- return (p, f) => (I(), $("div", {
984
- class: Ye(["vue-skeleton-loader", [
985
- `vue-skeleton-loader--${l.variant}`,
986
- { "vue-skeleton-loader--animated": l.animated }
1320
+ return (x, y) => (j(), U("div", {
1321
+ class: ot(["vue-skeleton-loader", [
1322
+ `vue-skeleton-loader--${t.variant}`,
1323
+ { "vue-skeleton-loader--animated": t.animated }
987
1324
  ]]),
988
- style: N(e.value),
1325
+ style: ue(e.value),
989
1326
  role: "status",
990
- "aria-label": l.ariaLabel
991
- }, null, 14, gt));
1327
+ "aria-label": t.ariaLabel
1328
+ }, null, 14, oa));
992
1329
  }
993
- }), yt = (l, P) => {
994
- const x = l.__vccOpts || l;
995
- for (const [e, p] of P)
996
- x[e] = p;
997
- return x;
998
- }, Mt = /* @__PURE__ */ yt(pt, [["__scopeId", "data-v-fc92f61f"]]), xt = ["aria-label"], wt = {
999
- key: 0,
1000
- class: "vue-virtual-carousel__track",
1001
- role: "list"
1002
- }, Tt = ["aria-label", "aria-current"], bt = {
1330
+ }), ra = (t, s) => {
1331
+ const I = t.__vccOpts || t;
1332
+ for (const [e, x] of s)
1333
+ I[e] = x;
1334
+ return I;
1335
+ }, sa = /* @__PURE__ */ ra(ia, [["__scopeId", "data-v-fc92f61f"]]), ua = 6e-3;
1336
+ function ca(t, s) {
1337
+ const I = t * Math.abs(t) / (2 * ua), e = s * 2;
1338
+ return Math.max(-e, Math.min(e, I));
1339
+ }
1340
+ function da(t, s, I, e = 250) {
1341
+ const x = s - t, y = Math.abs(I);
1342
+ if (!(y >= 0.1 && x * I > 0))
1343
+ return {
1344
+ keyframes: [
1345
+ { transform: `translate3d(${t}px, 0, 0)` },
1346
+ { transform: `translate3d(${s}px, 0, 0)` }
1347
+ ],
1348
+ options: {
1349
+ duration: Math.round(
1350
+ Math.max(120, Math.min(650, (190 + Math.abs(x) * 0.35) * e / 250))
1351
+ ),
1352
+ easing: "cubic-bezier(0.22, 1, 0.36, 1)",
1353
+ fill: "forwards"
1354
+ }
1355
+ };
1356
+ const d = Math.round(
1357
+ Math.max(180, Math.min(650, 2 * Math.abs(x) / y * e / 250))
1358
+ ), c = Math.min(3, y * d / Math.abs(x)), n = Math.ceil(d / 8);
1359
+ return {
1360
+ keyframes: Array.from({ length: n + 1 }, ($, Y) => {
1361
+ const A = Y / n, P = A * A, E = P * A, S = c * (E - 2 * P + A) + (-2 * E + 3 * P), B = t + x * S;
1362
+ return {
1363
+ offset: A,
1364
+ transform: `translate3d(${B}px, 0, 0)`
1365
+ };
1366
+ }),
1367
+ options: { duration: d, easing: "linear", fill: "forwards" }
1368
+ };
1369
+ }
1370
+ function fa(t) {
1371
+ const s = ee("idle"), I = m(() => s.value !== "idle"), e = m(() => s.value === "dragging"), x = ee(!1);
1372
+ let y, M = "", d = 0, c = 0, n = 0, h = 0, $ = 0, Y = 0, A = 0, P = 0, E = 0, S, B, K, G = 0, te = !1, ce, R, fe = "", ne = !1, oe, ie = !1;
1373
+ const H = () => t.rtl() ? -1 : 1, le = () => {
1374
+ var i;
1375
+ return (((i = t.viewport()) == null ? void 0 : i.scrollLeft) ?? 0) * H();
1376
+ };
1377
+ function pe(i, D) {
1378
+ const _ = t.viewport();
1379
+ if (!_) return;
1380
+ const X = i * H();
1381
+ _.scrollTo ? _.scrollTo(D === void 0 ? { left: X } : { left: X, behavior: D }) : _.scrollLeft = X;
1382
+ }
1383
+ function xe() {
1384
+ const i = t.viewport();
1385
+ i && (ne || (fe = i.style.scrollSnapType), ne = !0, i.style.scrollSnapType = "none");
1386
+ }
1387
+ function he() {
1388
+ const i = G;
1389
+ Z(() => {
1390
+ ie || i !== G || s.value !== "idle" || (t.viewport() && (t.viewport().style.scrollSnapType = fe), ne = !1);
1391
+ });
1392
+ }
1393
+ function ae() {
1394
+ const i = t.track();
1395
+ i && (i.style.transform = "", i.style.willChange = "");
1396
+ }
1397
+ function F() {
1398
+ const i = t.track();
1399
+ if (!i || !S) return $;
1400
+ const D = getComputedStyle(i).transform, _ = D.slice(D.indexOf("(") + 1, -1).split(",").map(Number), X = D.startsWith("matrix3d") ? _[12] : _[4];
1401
+ return Number.isFinite(X) ? X : $;
1402
+ }
1403
+ function b() {
1404
+ return S ? h - F() * H() : x.value ? h - $ * H() : le();
1405
+ }
1406
+ function C() {
1407
+ const i = S;
1408
+ S = void 0, i && (i.onfinish = null, i.oncancel = null, i.cancel()), K !== void 0 && cancelAnimationFrame(K), K = void 0;
1409
+ }
1410
+ function se() {
1411
+ var _;
1412
+ const i = y;
1413
+ y = void 0;
1414
+ const D = t.viewport();
1415
+ i !== void 0 && ((_ = D == null ? void 0 : D.hasPointerCapture) != null && _.call(D, i)) && D.releasePointerCapture(i), window.removeEventListener("pointermove", ye), window.removeEventListener("pointerup", de), window.removeEventListener("pointercancel", v), window.removeEventListener("blur", T);
1416
+ }
1417
+ function ve(i, D) {
1418
+ const _ = ++G;
1419
+ xe(), s.value = "committing", C(), ae(), x.value = !1, $ = 0;
1420
+ const X = t.canonical(i);
1421
+ pe(X, D), t.onPosition(X), t.onCommit(i), Z(() => {
1422
+ ie || _ !== G || (pe(X), s.value = "idle", he());
1423
+ });
1424
+ }
1425
+ function ke(i = !0) {
1426
+ R !== void 0 && clearTimeout(R), R = void 0;
1427
+ const D = S !== void 0 || $ !== 0, _ = i ? b() : le();
1428
+ return ++G, xe(), se(), C(), ae(), x.value = !1, B = void 0, $ = 0, s.value = "idle", i && (D && pe(_), t.onPosition(_)), he(), _;
1429
+ }
1430
+ function L() {
1431
+ S && (t.onPosition(b()), K = requestAnimationFrame(L));
1432
+ }
1433
+ function N() {
1434
+ return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1435
+ }
1436
+ function J(i, D, _) {
1437
+ const X = t.track(), p = (h - D) * H();
1438
+ if (!(X != null && X.animate) || N() || t.settleDuration() === 0 || Math.abs(p - $) < 1) {
1439
+ ae(), x.value = !1, $ = 0, s.value = "idle", !(X != null && X.animate) && !N() && t.settleDuration() !== 0 ? (t.onCommit(i), B = D, pe(D, "smooth"), he()) : ve(i);
1440
+ return;
1441
+ }
1442
+ ++G, xe(), s.value = "settling", x.value = !0;
1443
+ const z = da($, p, _, t.settleDuration()), k = X.animate(z.keyframes, z.options);
1444
+ S = k, k.onfinish = () => {
1445
+ S === k && ve(i);
1446
+ }, k.oncancel = () => {
1447
+ S === k && ke();
1448
+ }, K = requestAnimationFrame(L);
1449
+ }
1450
+ function Me(i, D = "smooth", _ = 0, X = !1) {
1451
+ const p = ke(), z = t.target(i, p, _);
1452
+ t.onCommit(i), Math.abs(z - p) < 0.5 || D !== "smooth" || N() ? ve(i, D) : X ? (h = le(), $ = (h - p) * H(), J(i, z, 0)) : (s.value = "settling", B = z, pe(z, D), t.viewport() && (t.viewport().style.scrollSnapType = fe), ne = !1);
1453
+ }
1454
+ function $e(i) {
1455
+ const D = i.currentTarget.scrollLeft * H();
1456
+ if (!(S || s.value === "dragging" || s.value === "committing")) {
1457
+ if (t.onPosition(D), B !== void 0) {
1458
+ if (Math.abs(D - B) > 1) return;
1459
+ B = void 0, s.value = "idle";
1460
+ }
1461
+ t.onCommit(t.indexAt(D));
1462
+ }
1463
+ }
1464
+ function be(i) {
1465
+ var X, p;
1466
+ if (y !== void 0 || i.isPrimary === !1 || i.pointerType === "mouse" && (!t.mouseDrag() || i.button !== 0) || !["mouse", "touch", "pen"].includes(i.pointerType) || (p = (X = i.target) == null ? void 0 : X.closest) != null && p.call(X, 'input, textarea, select, [contenteditable="true"], [data-carousel-no-drag]')) return;
1467
+ B !== void 0 && pe(le(), "auto");
1468
+ const D = b();
1469
+ S !== void 0 ? ($ = F(), C(), t.track().style.transform = `translate3d(${$}px, 0, 0)`, x.value = !0) : ($ = 0, h = le()), ++G, B = void 0, s.value = "pending", y = i.pointerId, M = i.pointerType, d = Y = i.clientX, c = i.clientY, n = D, A = i.timeStamp, P = 0, E = 0, te = !1, ce !== void 0 && clearTimeout(ce), window.addEventListener("pointermove", ye), window.addEventListener("pointerup", de), window.addEventListener("pointercancel", v), window.addEventListener("blur", T);
1470
+ }
1471
+ function ye(i) {
1472
+ var W, Ie;
1473
+ if (y !== i.pointerId || i === oe) return;
1474
+ oe = i;
1475
+ const D = i.clientX - d, _ = i.clientY - c, X = Number.isFinite(t.dragThreshold()) ? Math.max(1, t.dragThreshold()) : 8;
1476
+ if (s.value === "pending") {
1477
+ if (Math.max(Math.abs(D), Math.abs(_)) < X) return;
1478
+ if (M !== "mouse" && Math.abs(_) >= Math.abs(D)) {
1479
+ ke();
1480
+ return;
1481
+ }
1482
+ xe(), s.value = "dragging", (Ie = (W = t.viewport()) == null ? void 0 : W.setPointerCapture) == null || Ie.call(W, i.pointerId);
1483
+ }
1484
+ if (s.value !== "dragging") return;
1485
+ i.cancelable && i.preventDefault(), te = !0;
1486
+ const p = i.timeStamp - A;
1487
+ if (p > 0 && p <= 80) {
1488
+ const ge = Math.max(-2.5, Math.min(2.5, (i.clientX - Y) / p));
1489
+ P = E === 0 ? ge : P * 0.25 + ge * 0.75, E += 1;
1490
+ } else p > 80 && (P = 0, E = 0);
1491
+ Y = i.clientX, A = i.timeStamp;
1492
+ let z = n - D * H();
1493
+ const [k, me] = t.limits();
1494
+ z < k && (z = k + (z - k) * 0.35), z > me && (z = me + (z - me) * 0.35), $ = (h - z) * H(), K === void 0 && (K = requestAnimationFrame(() => {
1495
+ K = void 0;
1496
+ const ge = t.track();
1497
+ !ge || s.value !== "dragging" || (ge.style.willChange = "transform", ge.style.transform = `translate3d(${$}px, 0, 0)`, t.onPosition(h - $ * H()));
1498
+ }));
1499
+ }
1500
+ function re(i, D = !1) {
1501
+ if (y === void 0 || i && y !== i.pointerId) return;
1502
+ const _ = s.value === "dragging", X = $ !== 0;
1503
+ if (se(), K !== void 0 && cancelAnimationFrame(K), K = void 0, !_ && !X) {
1504
+ s.value = "idle", he();
1505
+ return;
1506
+ }
1507
+ const p = h - $ * H(), z = i ? Math.max(0, i.timeStamp - A) : 101, k = !D && t.momentum() && z <= 100 ? P * Math.exp(-z / 80) : 0, me = p - n, W = Math.min(80, Math.max(40, t.step() * 0.12)), Ie = E >= 2 && Math.abs(me) >= W ? ca(-k * H(), t.step()) : 0;
1508
+ let ge = t.indexAt(p + Ie);
1509
+ const Le = t.indexAt(n), He = Math.max(1, t.dragThreshold());
1510
+ !D && _ && ge === Le && Math.abs(me) >= He && (ge = Le + Math.sign(me));
1511
+ const Oe = t.target(ge, p);
1512
+ t.onPosition(p), J(t.indexAt(Oe), Oe, k), ce !== void 0 && clearTimeout(ce), ce = setTimeout(() => {
1513
+ te = !1;
1514
+ }, 0);
1515
+ }
1516
+ function de(i) {
1517
+ re(i);
1518
+ }
1519
+ function v(i) {
1520
+ re(i, !0);
1521
+ }
1522
+ function T() {
1523
+ re(void 0, !0);
1524
+ }
1525
+ function r(i) {
1526
+ i.target === t.viewport() && y === i.pointerId && s.value === "dragging" && re(i, !0);
1527
+ }
1528
+ function q(i) {
1529
+ !te || i.detail === 0 || (i.preventDefault(), i.stopPropagation(), te = !1);
1530
+ }
1531
+ function Q() {
1532
+ const i = S !== void 0 || s.value === "dragging", D = ke();
1533
+ i && t.onCommit(t.indexAt(D)), t.nativeSnap() || (R = setTimeout(() => {
1534
+ if (R = void 0, ie || s.value !== "idle") return;
1535
+ h = le(), $ = 0;
1536
+ const _ = t.indexAt(h);
1537
+ J(_, t.target(_, h), 0);
1538
+ }, 120));
1539
+ }
1540
+ function ze(i) {
1541
+ y !== void 0 && i.preventDefault();
1542
+ }
1543
+ return qe(() => {
1544
+ ke(!1), ie = !0, ce !== void 0 && clearTimeout(ce), t.viewport() && (t.viewport().style.scrollSnapType = fe);
1545
+ }), {
1546
+ phase: s,
1547
+ busy: I,
1548
+ dragging: e,
1549
+ transformed: x,
1550
+ read: le,
1551
+ write: pe,
1552
+ cancel: ke,
1553
+ commit: ve,
1554
+ navigate: Me,
1555
+ displayedPosition: b,
1556
+ handleScroll: $e,
1557
+ handlePointerDown: be,
1558
+ handlePointerMove: ye,
1559
+ handlePointerUp: de,
1560
+ handlePointerCancel: v,
1561
+ handleLostPointerCapture: r,
1562
+ handleClick: q,
1563
+ handleWheel: Q,
1564
+ handleDragStart: ze
1565
+ };
1566
+ }
1567
+ function va(t) {
1568
+ let s;
1569
+ function I() {
1570
+ s !== void 0 && clearTimeout(s), s = void 0;
1571
+ }
1572
+ function e() {
1573
+ if (I(), !t.enabled() || t.paused() || t.count() < 2 || t.atEnd() && !t.loop()) return;
1574
+ const x = Number.isFinite(t.delay()) ? Math.max(1, t.delay()) : 3e3;
1575
+ s = setTimeout(() => {
1576
+ s = void 0, !t.paused() && (t.atEnd() ? t.rewind() : t.advance(), e());
1577
+ }, x);
1578
+ }
1579
+ return we(
1580
+ () => [t.enabled(), t.paused(), t.delay(), t.count(), t.loop(), t.atEnd()],
1581
+ e,
1582
+ { immediate: !0 }
1583
+ ), qe(I), { start: e, stop: I };
1584
+ }
1585
+ function ut(t, s) {
1586
+ return s > 0 ? (t % s + s) % s : 0;
1587
+ }
1588
+ function ma(t, s) {
1589
+ const I = new Array(t.length + 1);
1590
+ I[0] = 0;
1591
+ for (let d = 0; d < t.length; d += 1)
1592
+ I[d + 1] = I[d] + t[d] + s;
1593
+ const e = I[t.length], x = Math.max(0, e - (t.length ? s : 0));
1594
+ function y(d) {
1595
+ if (!t.length) return 0;
1596
+ let c = 0, n = t.length - 1;
1597
+ for (; c < n; ) {
1598
+ const h = Math.ceil((c + n) / 2);
1599
+ I[h] <= d ? c = h : n = h - 1;
1600
+ }
1601
+ return c;
1602
+ }
1603
+ function M(d) {
1604
+ const c = y(d), n = Math.min(t.length - 1, c + 1);
1605
+ return d - I[c] <= I[n] - d ? c : n;
1606
+ }
1607
+ return { offsets: I, cycleWidth: e, totalWidth: x, indexAt: y, nearestIndex: M };
1608
+ }
1609
+ const ha = ["dir", "aria-label"], ga = ["data-carousel-index", "aria-label", "aria-current", "aria-hidden", "inert"], pa = {
1003
1610
  key: 1,
1004
1611
  class: "vue-virtual-carousel__empty"
1005
- }, St = /* @__PURE__ */ Oe({
1612
+ }, ya = /* @__PURE__ */ Qe({
1006
1613
  name: "VirtualCarousel",
1007
1614
  __name: "VirtualCarousel",
1008
1615
  props: {
@@ -1022,310 +1629,371 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
1022
1629
  autoplayDelay: { default: 3e3 },
1023
1630
  autoplayLoop: { type: Boolean, default: !0 },
1024
1631
  pauseOnHover: { type: Boolean, default: !0 },
1632
+ mouseDrag: { type: Boolean, default: !0 },
1633
+ dragThreshold: { default: 8 },
1634
+ momentum: { type: Boolean, default: !0 },
1635
+ settleDuration: { default: 250 },
1636
+ nativeSnap: { type: Boolean, default: !0 },
1637
+ autoWidth: { type: Boolean, default: !1 },
1638
+ estimatedItemWidth: { default: 240 },
1639
+ rtl: { type: Boolean, default: !1 },
1640
+ loop: { type: Boolean, default: !1 },
1641
+ keepAlive: { type: Boolean, default: !1 },
1642
+ maxCachedItems: { default: 20 },
1643
+ pinnedIndexes: { default: () => [] },
1025
1644
  responsive: { default: void 0 }
1026
1645
  },
1027
1646
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
1028
- setup(l, { expose: P, emit: x }) {
1029
- const e = l, p = x, f = j(), r = j(0), o = j(0);
1030
- let m, A = -1, O, U, q = !1;
1031
- const V = j(!1), { getItemKey: D } = Pe({
1647
+ setup(t, { expose: s, emit: I }) {
1648
+ const e = t, x = I, y = ee(), M = ee(), d = ee(0), c = ee(0), n = ee(0), h = ee(!1), $ = ee(!1), Y = ee(), A = ct([]), P = ct([0, 1]), E = ct(/* @__PURE__ */ new Map()), S = ct([]);
1649
+ let B, K, G = -1, te = !1;
1650
+ const ce = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map(), { getItemKey: fe } = tt({
1032
1651
  componentName: "VirtualCarousel",
1033
1652
  items: () => e.items,
1034
1653
  itemKey: () => e.itemKey
1035
- }), w = n(() => Math.max(0, r.value)), k = n(() => {
1036
- if (!e.responsive || e.responsive.length === 0)
1037
- return {
1038
- slidesPerView: e.slidesPerView,
1039
- slidesToScroll: e.slidesToScroll,
1040
- gap: e.gap
1041
- };
1042
- const t = w.value, a = [...e.responsive].sort(
1043
- (g, b) => b.breakpoint - g.breakpoint
1044
- );
1045
- for (const g of a)
1046
- if (t >= g.breakpoint)
1047
- return {
1048
- slidesPerView: g.slidesPerView ?? e.slidesPerView,
1049
- slidesToScroll: g.slidesToScroll ?? e.slidesToScroll,
1050
- gap: g.gap ?? e.gap
1051
- };
1654
+ }), ne = m(() => e.items.map((a, l) => fe(a, l))), oe = m(() => new Map(ne.value.map((a, l) => [a, l]))), ie = (a, l, g) => Math.max(l, Math.floor(Number.isFinite(a) ? a : g)), H = m(() => {
1655
+ const a = [...e.responsive ?? []].sort((l, g) => g.breakpoint - l.breakpoint).find((l) => d.value >= l.breakpoint);
1052
1656
  return {
1053
- slidesPerView: e.slidesPerView,
1054
- slidesToScroll: e.slidesToScroll,
1055
- gap: e.gap
1657
+ slidesPerView: ie((a == null ? void 0 : a.slidesPerView) ?? e.slidesPerView, 1, 1),
1658
+ slidesToScroll: ie((a == null ? void 0 : a.slidesToScroll) ?? e.slidesToScroll, 1, 1),
1659
+ gap: Math.max(0, Number.isFinite((a == null ? void 0 : a.gap) ?? e.gap) ? (a == null ? void 0 : a.gap) ?? e.gap : 0)
1056
1660
  };
1057
- }), E = n(
1058
- () => Math.max(
1059
- 1,
1060
- Math.floor(
1061
- Number.isFinite(k.value.slidesPerView) ? k.value.slidesPerView : 1
1062
- )
1063
- )
1064
- ), F = n(
1065
- () => Math.max(
1066
- 1,
1067
- Math.floor(
1068
- Number.isFinite(k.value.slidesToScroll) ? k.value.slidesToScroll : 1
1069
- )
1070
- )
1071
- ), W = n(
1072
- () => Math.max(0, Number.isFinite(k.value.gap) ? k.value.gap : 0)
1073
- ), ne = n(
1074
- () => Math.max(
1075
- 0,
1076
- Math.floor(Number.isFinite(e.buffer) ? e.buffer : 0)
1077
- )
1078
- ), Z = n(
1079
- () => Math.max(
1080
- 0,
1081
- Math.floor(
1082
- Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
1083
- )
1084
- )
1085
- ), H = n(() => Number.isFinite(e.autoplayDelay) ? Math.max(1, e.autoplayDelay) : 3e3), ae = n(() => {
1086
- if (w.value <= 0) return 0;
1087
- const t = (E.value - 1) * W.value;
1088
- return Math.max(
1089
- 1,
1090
- (w.value - t) / E.value
1091
- );
1092
- }), R = n(() => ae.value + W.value), J = n(
1093
- () => Math.max(
1094
- 0,
1095
- e.items.length - E.value
1096
- )
1097
- ), Y = n(
1098
- () => Math.max(0, o.value - ne.value)
1099
- ), le = n(
1100
- () => Math.min(
1101
- e.items.length,
1102
- o.value + E.value + ne.value
1103
- )
1104
- ), se = n(
1105
- () => e.items.slice(Y.value, le.value).map((t, a) => ({
1106
- item: t,
1107
- index: Y.value + a
1108
- }))
1109
- ), me = n(() => e.items.length === 0 ? 0 : e.items.length * ae.value + (e.items.length - 1) * W.value), de = n(
1110
- () => Y.value * R.value
1111
- ), ue = n(
1112
- () => Math.max(
1113
- 0,
1114
- me.value - le.value * R.value
1115
- )
1116
- ), we = n(() => ({
1117
- height: Fe(e.height)
1661
+ }), le = m(() => ie(e.buffer, 0, 1)), pe = m(() => ie(e.maxCachedItems, 0, 20)), xe = m(() => d.value > 0 ? Math.max(
1662
+ 1,
1663
+ (d.value - (H.value.slidesPerView - 1) * H.value.gap) / H.value.slidesPerView
1664
+ ) : 0), he = m(() => e.items.map((a, l) => e.autoWidth ? E.value.get(ne.value[l]) ?? Math.max(1, Number.isFinite(e.estimatedItemWidth) ? e.estimatedItemWidth : 240) : xe.value)), ae = m(() => ma(he.value, H.value.gap)), F = m(() => e.loop && e.items.length > 1 && ae.value.totalWidth > d.value), b = m(() => Math.max(0, ae.value.totalWidth - d.value)), C = m(() => {
1665
+ if (F.value) return e.items.length - 1;
1666
+ if (!e.autoWidth) return Math.max(0, e.items.length - H.value.slidesPerView);
1667
+ if (b.value <= 0) return 0;
1668
+ const a = ae.value.indexAt(b.value), l = ae.value.offsets[a] < b.value - 0.01 ? a + 1 : a;
1669
+ return Math.min(e.items.length - 1, l);
1670
+ }), se = m(() => F.value ? ae.value.cycleWidth * 3 : ae.value.totalWidth), ve = m(() => ({ height: mt(e.height) })), ke = m(() => ({
1671
+ width: `${se.value}px`,
1672
+ height: e.height === "auto" ? `${Math.max(1, c.value)}px` : "100%"
1118
1673
  }));
1119
- function G(t) {
1120
- return Math.min(
1121
- J.value,
1122
- Math.max(0, Math.floor(Number.isFinite(t) ? t : 0))
1123
- );
1124
- }
1125
- o.value = G(e.activeIndex);
1126
- function u(t) {
1127
- return t >= o.value && t < Math.min(
1128
- e.items.length,
1129
- o.value + E.value
1130
- );
1131
- }
1132
- function d() {
1133
- if (!e.hasMore || e.loading || A === e.items.length)
1674
+ function L(a) {
1675
+ const l = Math.floor(Number.isFinite(a) ? a : 0);
1676
+ return F.value ? ut(l, e.items.length) : Math.max(0, Math.min(C.value, l));
1677
+ }
1678
+ n.value = L(e.activeIndex);
1679
+ function N(a) {
1680
+ const l = ae.value.offsets[L(a)] ?? 0;
1681
+ return F.value ? ae.value.cycleWidth + l : Math.min(b.value, l);
1682
+ }
1683
+ function J(a) {
1684
+ const l = ae.value.cycleWidth;
1685
+ return F.value && l > 0 ? (a % l + l) % l : Math.max(0, a);
1686
+ }
1687
+ function Me(a) {
1688
+ if (!F.value && a >= b.value - 1 && b.value > 0) return C.value;
1689
+ const l = J(a);
1690
+ return F.value && l > (ae.value.offsets[e.items.length - 1] + ae.value.cycleWidth) / 2 ? 0 : L(ae.value.nearestIndex(l));
1691
+ }
1692
+ function $e(a, l, g = 0) {
1693
+ const V = N(a);
1694
+ if (!F.value) return V;
1695
+ const Te = ae.value.cycleWidth, Be = [V - Te, V, V + Te], Ae = Be.filter((We) => g > 0 ? We > l + 0.5 : g < 0 ? We < l - 0.5 : !0);
1696
+ return (Ae.length ? Ae : Be).sort((We, at) => Math.abs(We - l) - Math.abs(at - l))[0];
1697
+ }
1698
+ function be(a) {
1699
+ if (!F.value) return ae.value.indexAt(Math.max(0, a));
1700
+ const l = ae.value.cycleWidth, g = Math.floor(a / l);
1701
+ return g * e.items.length + ae.value.indexAt(a - g * l);
1702
+ }
1703
+ function ye(a) {
1704
+ return F.value ? Math.floor(a / e.items.length) * ae.value.cycleWidth + ae.value.offsets[ut(a, e.items.length)] : ae.value.offsets[a] ?? 0;
1705
+ }
1706
+ function re(a) {
1707
+ if (e.items.length === 0) {
1708
+ A.value = [], P.value = [0, 0];
1134
1709
  return;
1135
- const t = e.items.length === 0 ? -1 : Math.min(
1136
- e.items.length - 1,
1137
- o.value + E.value - 1
1138
- );
1139
- e.items.length - 1 - t <= Z.value && (A = e.items.length, p("loadMore"));
1140
- }
1141
- function z(t) {
1142
- const a = G(t);
1143
- a === o.value || e.items.length === 0 || (o.value = a, p("update:activeIndex", a), p("change", {
1144
- index: a,
1145
- item: e.items[a]
1146
- }), a === 0 && p("reachStart"), a === J.value && p("reachEnd"), d(), e.autoplay && !V.value && B());
1147
- }
1148
- function Q(t, a = {}) {
1149
- const g = f.value;
1150
- g && (typeof g.scrollTo == "function" ? g.scrollTo({ ...a, left: t }) : g.scrollLeft = t);
1151
- }
1152
- function he(t, a = {}) {
1153
- if (e.items.length === 0 || R.value <= 0) return;
1154
- const g = G(t);
1155
- U = a.behavior === "smooth" ? g : void 0, z(g), Q(g * R.value, {
1156
- ...a,
1157
- behavior: a.behavior
1158
- });
1159
- }
1160
- function y(t = "smooth") {
1161
- he(
1162
- o.value + F.value,
1163
- { behavior: t }
1164
- );
1710
+ }
1711
+ if (d.value <= 0) return;
1712
+ const l = be(a), g = be(a + d.value - 0.01);
1713
+ (P.value[0] !== l || P.value[1] !== g + 1) && (P.value = [l, g + 1]);
1714
+ const V = [];
1715
+ for (let Te = l; Te <= g; Te += 1) {
1716
+ const Be = F.value ? ut(Te, e.items.length) : Te;
1717
+ if (Be < 0 || Be >= e.items.length) continue;
1718
+ const Ae = ye(Te);
1719
+ Ae + he.value[Be] > a + 0.01 && Ae < a + d.value - 0.01 && !V.includes(Be) && V.push(Be);
1720
+ }
1721
+ V.join(",") !== A.value.join(",") && (A.value = V);
1165
1722
  }
1166
- function L(t = "smooth") {
1167
- he(
1168
- o.value - F.value,
1169
- { behavior: t }
1170
- );
1723
+ function de(a) {
1724
+ if (e.autoWidth) {
1725
+ const l = N(n.value), g = $e(a, l);
1726
+ return g + he.value[a] > l && g < l + d.value;
1727
+ }
1728
+ return F.value ? ut(a - n.value, e.items.length) < H.value.slidesPerView : a >= n.value && a < n.value + H.value.slidesPerView;
1729
+ }
1730
+ function v() {
1731
+ if (!e.hasMore || e.loading || G === e.items.length) return;
1732
+ const a = e.autoWidth ? A.value.length : H.value.slidesPerView;
1733
+ e.items.length - n.value - Math.max(1, a) <= ie(e.loadMoreThreshold, 0, 2) && (G = e.items.length, x("loadMore"));
1734
+ }
1735
+ function T(a) {
1736
+ const l = L(a);
1737
+ !e.items.length || l === n.value || (n.value = l, x("update:activeIndex", l), x("change", { index: l, item: e.items[l] }), l === 0 && x("reachStart"), l === C.value && x("reachEnd"), v());
1738
+ }
1739
+ const r = fa({
1740
+ viewport: () => y.value,
1741
+ track: () => M.value,
1742
+ rtl: () => e.rtl,
1743
+ mouseDrag: () => e.mouseDrag,
1744
+ nativeSnap: () => e.nativeSnap && !F.value,
1745
+ dragThreshold: () => Math.max(1, Number.isFinite(e.dragThreshold) ? e.dragThreshold : 8),
1746
+ momentum: () => e.momentum,
1747
+ settleDuration: () => Math.max(0, Number.isFinite(e.settleDuration) ? e.settleDuration : 250),
1748
+ limits: () => [0, F.value ? Math.max(0, se.value - d.value) : b.value],
1749
+ step: () => he.value[n.value] + H.value.gap || 1,
1750
+ indexAt: Me,
1751
+ target: $e,
1752
+ canonical: N,
1753
+ onPosition: re,
1754
+ onCommit: T
1755
+ }), { phase: q, dragging: Q } = r, ze = va({
1756
+ enabled: () => $.value && e.autoplay,
1757
+ paused: () => q.value === "pending" || q.value === "dragging" || q.value === "committing" || F.value && q.value === "settling" || h.value && e.pauseOnHover,
1758
+ delay: () => e.autoplayDelay,
1759
+ count: () => e.items.length,
1760
+ atEnd: () => !F.value && n.value >= C.value,
1761
+ loop: () => F.value || e.autoplayLoop,
1762
+ advance: () => Le(),
1763
+ rewind: () => ge(0, { behavior: "smooth" })
1764
+ }), i = m(() => {
1765
+ const a = Q.value || r.transformed.value, l = le.value + (a ? H.value.slidesPerView + 2 : 0);
1766
+ let g, V;
1767
+ !e.autoWidth && !F.value && !a ? (g = Math.max(0, n.value - l), V = Math.min(e.items.length, n.value + H.value.slidesPerView + l)) : (g = Math.max(0, P.value[0] - l), V = Math.min(F.value ? e.items.length * 3 : e.items.length, P.value[1] + l));
1768
+ const Te = (P.value[0] + P.value[1] - 1) / 2, Be = /* @__PURE__ */ new Map();
1769
+ for (let Ae = g; Ae < V; Ae += 1) {
1770
+ const We = F.value ? ut(Ae, e.items.length) : Ae, at = Be.get(We);
1771
+ (!at || Math.abs(Ae - Te) < Math.abs(at.virtual - Te)) && Be.set(We, { index: We, virtual: Ae, cached: !1 });
1772
+ }
1773
+ return [...Be.values()].sort((Ae, We) => Ae.virtual - We.virtual);
1774
+ });
1775
+ we([A, q, ne], () => {
1776
+ if (q.value !== "idle") return;
1777
+ const a = A.value.filter((g) => g < e.items.length).map((g) => ne.value[g]);
1778
+ if (!e.keepAlive) {
1779
+ S.value = [];
1780
+ return;
1781
+ }
1782
+ const l = S.value.filter((g) => oe.value.has(g) && !a.includes(g));
1783
+ S.value = [...l, ...a].slice(-(pe.value + a.length));
1784
+ }, { immediate: !0 });
1785
+ const D = m(() => {
1786
+ const a = [...i.value], l = new Set(a.map((V) => V.index)), g = /* @__PURE__ */ new Set();
1787
+ for (const V of e.pinnedIndexes.slice(0, pe.value))
1788
+ Number.isInteger(V) && V >= 0 && V < e.items.length && g.add(V);
1789
+ if (Y.value !== void 0 && Y.value < e.items.length && g.add(Y.value), e.keepAlive)
1790
+ for (const V of [...S.value].reverse()) {
1791
+ const Te = oe.value.get(V);
1792
+ Te !== void 0 && !l.has(Te) && g.size < pe.value && g.add(Te);
1793
+ }
1794
+ for (const V of g)
1795
+ l.has(V) || a.push({ index: V, virtual: F.value ? e.items.length + V : V, cached: V !== Y.value });
1796
+ return a.sort((V, Te) => V.virtual - Te.virtual).map((V) => ({
1797
+ ...V,
1798
+ item: e.items[V.index],
1799
+ key: ne.value[V.index]
1800
+ }));
1801
+ }), _ = m(() => i.value.length ? ye(i.value[0].virtual) : 0), X = m(() => !e.autoWidth && !F.value && !e.keepAlive && !e.pinnedIndexes.length && (Y.value === void 0 || i.value.some((a) => a.index === Y.value))), p = m(() => {
1802
+ const a = i.value[i.value.length - 1];
1803
+ return a ? Math.max(0, se.value - ye(a.virtual) - he.value[a.index] - H.value.gap) : 0;
1804
+ });
1805
+ function z(a) {
1806
+ const l = he.value[a.index];
1807
+ return {
1808
+ position: X.value ? "relative" : "absolute",
1809
+ [e.rtl ? "right" : "left"]: X.value ? void 0 : `${ye(a.virtual)}px`,
1810
+ width: e.autoWidth ? "max-content" : `${l}px`,
1811
+ flexBasis: e.autoWidth ? "auto" : `${l}px`,
1812
+ marginRight: !e.rtl && a.index < e.items.length - 1 ? `${H.value.gap}px` : "0px",
1813
+ marginLeft: e.rtl && a.index < e.items.length - 1 ? `${H.value.gap}px` : "0px",
1814
+ height: e.height === "auto" ? "auto" : "100%",
1815
+ visibility: a.cached ? "hidden" : void 0,
1816
+ scrollSnapAlign: e.nativeSnap && !F.value && d.value > 0 ? "start" : "none"
1817
+ };
1171
1818
  }
1172
- function B() {
1173
- te(), !(!e.autoplay || e.items.length === 0) && (O = setTimeout(() => {
1174
- o.value >= J.value ? e.autoplayLoop ? he(0, { behavior: "smooth" }) : te() : y("smooth");
1175
- }, H.value));
1819
+ function k() {
1820
+ if (!R.size || q.value !== "idle") return;
1821
+ const a = new Map(E.value);
1822
+ for (const [l, g] of R) a.set(l, g);
1823
+ R.clear(), E.value = a;
1824
+ }
1825
+ function me(a, l) {
1826
+ if (l < 0 || l >= e.items.length) return;
1827
+ const { width: g, height: V } = a.getBoundingClientRect();
1828
+ V > c.value && (c.value = V);
1829
+ const Te = ne.value[l];
1830
+ e.autoWidth && g > 0 && Math.abs((E.value.get(Te) ?? 0) - g) > 0.5 && R.set(Te, g);
1831
+ }
1832
+ function W() {
1833
+ var l;
1834
+ if (te || e.height !== "auto") return;
1835
+ let a = 0;
1836
+ for (const g of i.value)
1837
+ a = Math.max(a, ((l = ce.get(g.index)) == null ? void 0 : l.getBoundingClientRect().height) ?? 0);
1838
+ Math.abs(c.value - a) > 0.5 && (c.value = a);
1839
+ }
1840
+ function Ie(a, l) {
1841
+ const g = ce.get(l);
1842
+ if (g && (K == null || K.unobserve(g)), !(a instanceof HTMLElement)) {
1843
+ ce.delete(l);
1844
+ return;
1845
+ }
1846
+ ce.set(l, a), (e.autoWidth || e.height === "auto") && (K == null || K.observe(a), me(a, l), Z(k), Z(W));
1176
1847
  }
1177
- function te() {
1178
- O !== void 0 && (clearTimeout(O), O = void 0);
1848
+ function ge(a, l = {}) {
1849
+ !e.items.length || d.value <= 0 || r.navigate(L(a), l.behavior ?? "auto", 0, F.value || !e.nativeSnap);
1179
1850
  }
1180
- function oe() {
1181
- V.value = !0, e.pauseOnHover && te();
1851
+ function Le(a = "smooth") {
1852
+ !e.items.length || d.value <= 0 || r.navigate(L(n.value + H.value.slidesToScroll), a, 1, F.value || !e.nativeSnap);
1182
1853
  }
1183
- function re() {
1184
- V.value = !1, e.autoplay && B();
1854
+ function He(a = "smooth") {
1855
+ !e.items.length || d.value <= 0 || r.navigate(L(n.value - H.value.slidesToScroll), a, -1, F.value || !e.nativeSnap);
1185
1856
  }
1186
- function ye() {
1187
- U = void 0;
1188
- }
1189
- function _(t) {
1190
- if (R.value <= 0 || q) return;
1191
- const a = t.currentTarget.scrollLeft;
1192
- if (U !== void 0) {
1193
- const g = U * R.value;
1194
- if (Math.abs(a - g) > 1) return;
1195
- U = void 0;
1196
- }
1197
- z(Math.round(a / R.value));
1857
+ function Oe(a) {
1858
+ var V, Te;
1859
+ if ((Te = (V = a.target) == null ? void 0 : V.closest) != null && Te.call(V, 'input, textarea, select, [contenteditable="true"]')) return;
1860
+ const l = e.rtl ? "ArrowLeft" : "ArrowRight", g = e.rtl ? "ArrowRight" : "ArrowLeft";
1861
+ a.key === l || a.key === "PageDown" ? (a.preventDefault(), Le()) : a.key === g || a.key === "PageUp" ? (a.preventDefault(), He()) : a.key === "Home" ? (a.preventDefault(), ge(0, { behavior: "smooth" })) : a.key === "End" && (a.preventDefault(), ge(C.value));
1198
1862
  }
1199
- function ee(t) {
1200
- t.key === "ArrowRight" || t.key === "PageDown" ? (t.preventDefault(), y()) : t.key === "ArrowLeft" || t.key === "PageUp" ? (t.preventDefault(), L()) : t.key === "Home" ? (t.preventDefault(), he(0, { behavior: "smooth" })) : t.key === "End" && (t.preventDefault(), he(J.value, { behavior: "auto" }));
1863
+ function Mt(a) {
1864
+ var g, V;
1865
+ const l = (V = (g = a.target) == null ? void 0 : g.closest) == null ? void 0 : V.call(g, "[data-carousel-index]");
1866
+ Y.value = l ? Number(l.getAttribute("data-carousel-index")) : void 0;
1201
1867
  }
1202
- function s() {
1203
- var a;
1204
- const t = ((a = f.value) == null ? void 0 : a.clientWidth) ?? 0;
1205
- t <= 0 || t === r.value || (q = !0, r.value = t, C(() => {
1206
- const g = G(o.value);
1207
- Q(g * R.value), q = !1;
1208
- }));
1868
+ function ht() {
1869
+ Z(() => {
1870
+ var a;
1871
+ (a = y.value) != null && a.contains(document.activeElement) || (Y.value = void 0);
1872
+ });
1209
1873
  }
1210
- return ie(
1211
- () => e.activeIndex,
1212
- async (t) => {
1213
- const a = G(t);
1214
- a !== o.value && (ye(), o.value = a, await C(), Q(a * R.value), d());
1215
- }
1216
- ), ie(
1217
- () => [
1218
- e.items.length,
1219
- k.value.slidesPerView,
1220
- k.value.gap,
1221
- k.value.slidesToScroll
1222
- ],
1223
- async () => {
1224
- const t = G(o.value);
1225
- e.items.length === 0 ? o.value !== 0 && (o.value = 0, p("update:activeIndex", 0)) : z(t), await C(), Q(t * R.value), d(), e.autoplay && e.items.length > 0 && !V.value && B();
1226
- }
1227
- ), ie(
1228
- () => e.responsive,
1229
- () => {
1230
- C(() => {
1231
- const t = G(o.value);
1232
- Q(t * R.value);
1233
- });
1234
- },
1235
- { deep: !0 }
1236
- ), ie(
1237
- () => [
1238
- e.hasMore,
1239
- e.loading,
1240
- e.loadMoreThreshold
1241
- ],
1242
- async ([t]) => {
1243
- t || (A = -1), await C(), d();
1244
- }
1245
- ), ie(
1246
- () => e.autoplay,
1247
- (t) => {
1248
- t && !V.value ? B() : te();
1249
- }
1250
- ), ie(
1251
- () => e.autoplayDelay,
1252
- () => {
1253
- e.autoplay && !V.value && B();
1254
- }
1255
- ), ie(
1256
- () => e.autoplayLoop,
1257
- (t) => {
1258
- !e.autoplay || V.value || (!t && o.value >= J.value ? te() : B());
1259
- }
1260
- ), ie(
1261
- () => e.pauseOnHover,
1262
- (t) => {
1263
- t && V.value ? te() : !t && e.autoplay && B();
1264
- }
1265
- ), Ae(async () => {
1266
- s(), typeof ResizeObserver < "u" && f.value && (m = new ResizeObserver(s), m.observe(f.value)), await C(), Q(o.value * R.value), d(), e.autoplay && B();
1267
- }), Ce(() => {
1268
- m && (m.disconnect(), m = void 0), te();
1269
- }), P({
1270
- next: y,
1271
- previous: L,
1272
- scrollToIndex: he,
1273
- startAutoplay: B,
1274
- stopAutoplay: te
1275
- }), (t, a) => (I(), $("div", {
1874
+ function it() {
1875
+ r.cancel(!1), e.items.length ? T(L(n.value)) : n.value !== 0 && (n.value = 0, x("update:activeIndex", 0)), te || r.commit(n.value), Z(v);
1876
+ }
1877
+ function rt() {
1878
+ var l;
1879
+ const a = ((l = y.value) == null ? void 0 : l.clientWidth) ?? 0;
1880
+ a <= 0 || a === d.value || (d.value = a);
1881
+ }
1882
+ return we(() => [
1883
+ e.items.length,
1884
+ d.value,
1885
+ H.value.slidesPerView,
1886
+ H.value.gap,
1887
+ e.rtl,
1888
+ F.value,
1889
+ e.autoWidth,
1890
+ e.nativeSnap,
1891
+ E.value
1892
+ ], it), we(() => e.activeIndex, (a) => {
1893
+ const l = L(a);
1894
+ l !== n.value && (r.cancel(!1), n.value = l, r.commit(l), Z(v));
1895
+ }), we(() => [e.hasMore, e.loading, e.loadMoreThreshold], () => {
1896
+ e.hasMore || (G = -1), Z(v);
1897
+ }), we(() => ne.value, (a) => {
1898
+ const l = new Set(a);
1899
+ E.value = new Map([...E.value].filter(([g]) => l.has(g))), S.value = S.value.filter((g) => l.has(g));
1900
+ }), we(q, (a) => {
1901
+ a === "idle" && Z(k);
1902
+ }), we(() => [e.keepAlive, e.maxCachedItems], () => {
1903
+ const a = A.value.map((l) => ne.value[l]);
1904
+ S.value = e.keepAlive ? [...S.value.filter((l) => !a.includes(l)), ...a].slice(-(pe.value + a.length)) : [];
1905
+ }), _e(async () => {
1906
+ if (rt(), typeof ResizeObserver < "u" && (B = new ResizeObserver(rt), y.value && B.observe(y.value), K = new ResizeObserver((a) => {
1907
+ for (const l of a) me(l.target, Number(l.target.dataset.carouselIndex));
1908
+ k(), W();
1909
+ }), e.autoWidth || e.height === "auto"))
1910
+ for (const [a, l] of ce)
1911
+ K.observe(l), me(l, a);
1912
+ await Z(), it(), $.value = !0;
1913
+ }), qe(() => {
1914
+ te = !0, B == null || B.disconnect(), K == null || K.disconnect();
1915
+ }), s({ next: Le, previous: He, scrollToIndex: ge, startAutoplay: ze.start, stopAutoplay: ze.stop }), (a, l) => (j(), U("div", {
1276
1916
  ref_key: "viewport",
1277
- ref: f,
1278
- class: "vue-virtual-carousel",
1279
- style: N(we.value),
1917
+ ref: y,
1918
+ class: ot(["vue-virtual-carousel", { "vue-virtual-carousel--mouse-drag": t.mouseDrag, "vue-virtual-carousel--dragging": f(Q), "vue-virtual-carousel--controlled": F.value || !t.nativeSnap }]),
1919
+ style: ue(ve.value),
1920
+ dir: t.rtl ? "rtl" : "ltr",
1280
1921
  role: "region",
1281
1922
  "aria-roledescription": "carousel",
1282
- "aria-label": l.ariaLabel,
1923
+ "aria-label": t.ariaLabel,
1283
1924
  tabindex: "0",
1284
- onScrollPassive: _,
1285
- onPointerdown: ye,
1286
- onWheelPassive: ye,
1287
- onKeydown: ee,
1288
- onMouseenter: oe,
1289
- onMouseleave: re
1925
+ onScrollPassive: l[0] || (l[0] = //@ts-ignore
1926
+ (...g) => f(r).handleScroll && f(r).handleScroll(...g)),
1927
+ onPointerdown: l[1] || (l[1] = //@ts-ignore
1928
+ (...g) => f(r).handlePointerDown && f(r).handlePointerDown(...g)),
1929
+ onPointermove: l[2] || (l[2] = //@ts-ignore
1930
+ (...g) => f(r).handlePointerMove && f(r).handlePointerMove(...g)),
1931
+ onPointerup: l[3] || (l[3] = //@ts-ignore
1932
+ (...g) => f(r).handlePointerUp && f(r).handlePointerUp(...g)),
1933
+ onPointercancel: l[4] || (l[4] = //@ts-ignore
1934
+ (...g) => f(r).handlePointerCancel && f(r).handlePointerCancel(...g)),
1935
+ onLostpointercapture: l[5] || (l[5] = //@ts-ignore
1936
+ (...g) => f(r).handleLostPointerCapture && f(r).handleLostPointerCapture(...g)),
1937
+ onClickCapture: l[6] || (l[6] = //@ts-ignore
1938
+ (...g) => f(r).handleClick && f(r).handleClick(...g)),
1939
+ onDragstart: l[7] || (l[7] = //@ts-ignore
1940
+ (...g) => f(r).handleDragStart && f(r).handleDragStart(...g)),
1941
+ onWheelPassive: l[8] || (l[8] = //@ts-ignore
1942
+ (...g) => f(r).handleWheel && f(r).handleWheel(...g)),
1943
+ onKeydown: Oe,
1944
+ onMouseenter: l[9] || (l[9] = (g) => h.value = !0),
1945
+ onMouseleave: l[10] || (l[10] = (g) => h.value = !1),
1946
+ onFocusin: Mt,
1947
+ onFocusout: ht
1290
1948
  }, [
1291
- l.items.length ? (I(), $("div", wt, [
1292
- de.value > 0 ? (I(), $("div", {
1949
+ t.items.length ? (j(), U("div", {
1950
+ key: 0,
1951
+ ref_key: "track",
1952
+ ref: M,
1953
+ class: "vue-virtual-carousel__track",
1954
+ style: ue(ke.value),
1955
+ role: "list"
1956
+ }, [
1957
+ _.value > 0 ? (j(), U("div", {
1293
1958
  key: 0,
1294
1959
  class: "vue-virtual-carousel__spacer",
1295
- style: N({ flexBasis: `${de.value}px` }),
1960
+ style: ue({ flexBasis: `${_.value}px`, position: X.value ? "relative" : "absolute" }),
1296
1961
  "aria-hidden": "true"
1297
- }, null, 4)) : ze("", !0),
1298
- (I(!0), $(Re, null, De(se.value, ({ item: g, index: b }) => (I(), $("div", {
1299
- key: c(D)(g, b),
1962
+ }, null, 4)) : Ve("", !0),
1963
+ (j(!0), U(Je, null, et(D.value, (g) => (j(), U("div", {
1964
+ key: g.key,
1965
+ ref_for: !0,
1966
+ ref: (V) => Ie(V, g.index),
1300
1967
  class: "vue-virtual-carousel__item",
1301
- style: N({
1302
- flexBasis: `${ae.value}px`,
1303
- marginRight: b < l.items.length - 1 ? `${W.value}px` : "0px"
1304
- }),
1968
+ "data-carousel-index": g.index,
1969
+ style: ue(z(g)),
1305
1970
  role: "listitem",
1306
1971
  "aria-roledescription": "slide",
1307
- "aria-label": `${b + 1} of ${l.items.length}`,
1308
- "aria-current": b === o.value ? "true" : void 0
1972
+ "aria-label": `${g.index + 1} of ${t.items.length}`,
1973
+ "aria-current": g.index === n.value ? "true" : void 0,
1974
+ "aria-hidden": g.cached ? "true" : void 0,
1975
+ inert: g.cached ? !0 : void 0
1309
1976
  }, [
1310
- ce(t.$slots, "default", {
1311
- item: g,
1312
- index: b,
1313
- active: b === o.value,
1314
- visible: u(b)
1977
+ Se(a.$slots, "default", {
1978
+ item: g.item,
1979
+ index: g.index,
1980
+ active: g.index === n.value,
1981
+ visible: de(g.index),
1982
+ inViewport: A.value.includes(g.index)
1315
1983
  })
1316
- ], 12, Tt))), 128)),
1317
- ue.value > 0 ? (I(), $("div", {
1984
+ ], 12, ga))), 128)),
1985
+ p.value > 0 ? (j(), U("div", {
1318
1986
  key: 1,
1319
1987
  class: "vue-virtual-carousel__spacer",
1320
- style: N({ flexBasis: `${ue.value}px` }),
1988
+ style: ue({ flexBasis: `${p.value}px`, position: X.value ? "relative" : "absolute" }),
1321
1989
  "aria-hidden": "true"
1322
- }, null, 4)) : ze("", !0)
1323
- ])) : (I(), $("div", bt, [
1324
- ce(t.$slots, "empty")
1990
+ }, null, 4)) : Ve("", !0)
1991
+ ], 4)) : (j(), U("div", pa, [
1992
+ Se(a.$slots, "empty")
1325
1993
  ]))
1326
- ], 44, xt));
1994
+ ], 46, ha));
1327
1995
  }
1328
- }), zt = ["aria-label"], It = ["aria-posinset", "aria-setsize"], $t = /* @__PURE__ */ Oe({
1996
+ }), wa = ["aria-label"], xa = ["aria-posinset", "aria-setsize"], Ma = /* @__PURE__ */ Qe({
1329
1997
  name: "VirtualScroll",
1330
1998
  __name: "VirtualScroll",
1331
1999
  props: {
@@ -1344,210 +2012,210 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
1344
2012
  pullRefreshThreshold: { default: 64 }
1345
2013
  },
1346
2014
  emits: ["scroll", "loadMore", "refresh"],
1347
- setup(l, { expose: P, emit: x }) {
1348
- const e = l, p = x, {
1349
- pulling: f,
1350
- pullDistance: r,
1351
- pullOffset: o,
1352
- pullProgress: m,
1353
- refreshMessage: A,
1354
- refreshThreshold: O,
1355
- handleTouchStart: U,
1356
- handleTouchMove: q,
1357
- handleTouchEnd: V,
1358
- handleTouchCancel: D
1359
- } = qe({
2015
+ setup(t, { expose: s, emit: I }) {
2016
+ const e = t, x = I, {
2017
+ pulling: y,
2018
+ pullDistance: M,
2019
+ pullOffset: d,
2020
+ pullProgress: c,
2021
+ refreshMessage: n,
2022
+ refreshThreshold: h,
2023
+ handleTouchStart: $,
2024
+ handleTouchMove: Y,
2025
+ handleTouchEnd: A,
2026
+ handleTouchCancel: P
2027
+ } = xt({
1360
2028
  enabled: () => e.pullToRefresh,
1361
2029
  refreshing: () => e.refreshing,
1362
2030
  threshold: () => e.pullRefreshThreshold,
1363
- onRefresh: () => p("refresh")
1364
- }), w = j(), k = j(0), E = j(0);
1365
- let F, W = -1;
1366
- const ne = Ue(), { getItemKey: Z } = Pe({
2031
+ onRefresh: () => x("refresh")
2032
+ }), E = ee(), S = ee(0), B = ee(0);
2033
+ let K, G = -1;
2034
+ const te = wt(), { getItemKey: ce } = tt({
1367
2035
  componentName: "VirtualScroll",
1368
2036
  items: () => e.items,
1369
2037
  itemKey: () => e.itemKey
1370
- }), H = n(() => Math.max(1, e.itemSize)), ae = n(() => Math.max(0, Math.floor(e.overscan))), R = n(
1371
- () => e.items.length * H.value
1372
- ), J = n(
1373
- () => Math.max(1, e.loadingItemSize ?? H.value)
1374
- ), Y = n(
1375
- () => R.value + (e.loading ? J.value : 0)
1376
- ), le = n(() => E.value > 0 ? E.value : typeof e.height == "number" ? e.height : 0), se = n(
2038
+ }), R = m(() => Math.max(1, e.itemSize)), fe = m(() => Math.max(0, Math.floor(e.overscan))), ne = m(
2039
+ () => e.items.length * R.value
2040
+ ), oe = m(
2041
+ () => Math.max(1, e.loadingItemSize ?? R.value)
2042
+ ), ie = m(
2043
+ () => ne.value + (e.loading ? oe.value : 0)
2044
+ ), H = m(() => B.value > 0 ? B.value : typeof e.height == "number" ? e.height : 0), le = m(
1377
2045
  () => Math.max(
1378
2046
  0,
1379
- Math.floor(k.value / H.value) - ae.value
2047
+ Math.floor(S.value / R.value) - fe.value
1380
2048
  )
1381
- ), me = n(() => {
1382
- const y = Math.ceil(
1383
- (k.value + le.value) / H.value
2049
+ ), pe = m(() => {
2050
+ const L = Math.ceil(
2051
+ (S.value + H.value) / R.value
1384
2052
  );
1385
2053
  return Math.min(
1386
2054
  e.items.length,
1387
- y + ae.value
2055
+ L + fe.value
1388
2056
  );
1389
- }), de = n(
1390
- () => e.items.slice(se.value, me.value).map((y, L) => ({
1391
- item: y,
1392
- index: se.value + L
2057
+ }), xe = m(
2058
+ () => e.items.slice(le.value, pe.value).map((L, N) => ({
2059
+ item: L,
2060
+ index: le.value + N
1393
2061
  }))
1394
- ), ue = n(() => ({
1395
- height: Fe(e.height)
1396
- })), we = n(() => ({
1397
- transform: `translateY(${se.value * H.value}px)`
2062
+ ), he = m(() => ({
2063
+ height: mt(e.height)
2064
+ })), ae = m(() => ({
2065
+ transform: `translateY(${le.value * R.value}px)`
1398
2066
  }));
1399
- function G() {
1400
- var y;
1401
- E.value = ((y = w.value) == null ? void 0 : y.clientHeight) ?? 0, ne(w.value, e.height), C(d);
1402
- }
1403
- function u(y) {
1404
- k.value = y.currentTarget.scrollTop, p("scroll", {
1405
- scrollTop: k.value,
1406
- startIndex: se.value,
1407
- endIndex: me.value
1408
- }), d();
1409
- }
1410
- function d() {
1411
- const y = w.value;
1412
- if (!y || !e.hasMore || e.loading || W === e.items.length)
2067
+ function F() {
2068
+ var L;
2069
+ B.value = ((L = E.value) == null ? void 0 : L.clientHeight) ?? 0, te(E.value, e.height), Z(C);
2070
+ }
2071
+ function b(L) {
2072
+ S.value = L.currentTarget.scrollTop, x("scroll", {
2073
+ scrollTop: S.value,
2074
+ startIndex: le.value,
2075
+ endIndex: pe.value
2076
+ }), C();
2077
+ }
2078
+ function C() {
2079
+ const L = E.value;
2080
+ if (!L || !e.hasMore || e.loading || G === e.items.length)
1413
2081
  return;
1414
- const L = Math.max(0, e.loadMoreThreshold);
1415
- Y.value - y.scrollTop - y.clientHeight <= L && (W = e.items.length, p("loadMore"));
1416
- }
1417
- function z(y, L = {}) {
1418
- const B = w.value;
1419
- if (!B) return;
1420
- const te = Math.max(0, Y.value - B.clientHeight), oe = Math.min(
1421
- Math.max(0, Number.isFinite(y) ? y : 0),
1422
- te
1423
- ), re = L.behavior ?? "auto";
1424
- re === "auto" && (k.value = oe), B.scrollTo({ ...L, top: oe, behavior: re });
1425
- }
1426
- function Q(y, L = {}) {
1427
- const B = w.value;
1428
- if (!B || e.items.length === 0) return;
1429
- const te = Math.min(
2082
+ const N = Math.max(0, e.loadMoreThreshold);
2083
+ ie.value - L.scrollTop - L.clientHeight <= N && (G = e.items.length, x("loadMore"));
2084
+ }
2085
+ function se(L, N = {}) {
2086
+ const J = E.value;
2087
+ if (!J) return;
2088
+ const Me = Math.max(0, ie.value - J.clientHeight), $e = Math.min(
2089
+ Math.max(0, Number.isFinite(L) ? L : 0),
2090
+ Me
2091
+ ), be = N.behavior ?? "auto";
2092
+ be === "auto" && (S.value = $e), J.scrollTo({ ...N, top: $e, behavior: be });
2093
+ }
2094
+ function ve(L, N = {}) {
2095
+ const J = E.value;
2096
+ if (!J || e.items.length === 0) return;
2097
+ const Me = Math.min(
1430
2098
  e.items.length - 1,
1431
- Math.max(0, Math.floor(y))
1432
- ), { align: oe = "start", ...re } = L;
1433
- let ye = te * H.value;
1434
- oe === "center" ? ye -= (B.clientHeight - H.value) / 2 : oe === "end" && (ye -= B.clientHeight - H.value), B.scrollTo({
1435
- ...re,
1436
- top: Math.max(0, Math.min(ye, Y.value - B.clientHeight))
2099
+ Math.max(0, Math.floor(L))
2100
+ ), { align: $e = "start", ...be } = N;
2101
+ let ye = Me * R.value;
2102
+ $e === "center" ? ye -= (J.clientHeight - R.value) / 2 : $e === "end" && (ye -= J.clientHeight - R.value), J.scrollTo({
2103
+ ...be,
2104
+ top: Math.max(0, Math.min(ye, ie.value - J.clientHeight))
1437
2105
  });
1438
2106
  }
1439
- function he(y = "auto") {
1440
- var L;
1441
- (L = w.value) == null || L.scrollTo({ top: 0, behavior: y });
2107
+ function ke(L = "auto") {
2108
+ var N;
2109
+ (N = E.value) == null || N.scrollTo({ top: 0, behavior: L });
1442
2110
  }
1443
- return ie(
2111
+ return we(
1444
2112
  () => [e.items.length, e.itemSize],
1445
2113
  async () => {
1446
- await C();
1447
- const y = w.value;
1448
- if (!y) return;
1449
- const L = Math.max(0, Y.value - y.clientHeight);
1450
- y.scrollTop > L && (y.scrollTop = L, k.value = L), d();
2114
+ await Z();
2115
+ const L = E.value;
2116
+ if (!L) return;
2117
+ const N = Math.max(0, ie.value - L.clientHeight);
2118
+ L.scrollTop > N && (L.scrollTop = N, S.value = N), C();
1451
2119
  }
1452
- ), ie(
2120
+ ), we(
1453
2121
  () => [e.hasMore, e.loading],
1454
- async ([y]) => {
1455
- y || (W = -1), await C(), d();
2122
+ async ([L]) => {
2123
+ L || (G = -1), await Z(), C();
1456
2124
  }
1457
- ), Ae(() => {
1458
- G(), typeof ResizeObserver < "u" && w.value && (F = new ResizeObserver(G), F.observe(w.value)), C(d);
1459
- }), Ce(() => {
1460
- F && (F.disconnect(), F = void 0);
1461
- }), P({
1462
- scrollTo: z,
1463
- scrollToIndex: Q,
1464
- scrollToTop: he
1465
- }), (y, L) => (I(), $("div", {
2125
+ ), _e(() => {
2126
+ F(), typeof ResizeObserver < "u" && E.value && (K = new ResizeObserver(F), K.observe(E.value)), Z(C);
2127
+ }), qe(() => {
2128
+ K && (K.disconnect(), K = void 0);
2129
+ }), s({
2130
+ scrollTo: se,
2131
+ scrollToIndex: ve,
2132
+ scrollToTop: ke
2133
+ }), (L, N) => (j(), U("div", {
1466
2134
  ref_key: "viewport",
1467
- ref: w,
1468
- class: Ye(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": c(f) }]),
1469
- style: N(ue.value),
2135
+ ref: E,
2136
+ class: ot(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": f(y) }]),
2137
+ style: ue(he.value),
1470
2138
  role: "list",
1471
- "aria-label": l.ariaLabel,
2139
+ "aria-label": t.ariaLabel,
1472
2140
  tabindex: "0",
1473
- onScrollPassive: u,
1474
- onTouchstartPassive: L[0] || (L[0] = //@ts-ignore
1475
- (...B) => c(U) && c(U)(...B)),
1476
- onTouchmove: L[1] || (L[1] = //@ts-ignore
1477
- (...B) => c(q) && c(q)(...B)),
1478
- onTouchend: L[2] || (L[2] = //@ts-ignore
1479
- (...B) => c(V) && c(V)(...B)),
1480
- onTouchcancel: L[3] || (L[3] = //@ts-ignore
1481
- (...B) => c(D) && c(D)(...B))
2141
+ onScrollPassive: b,
2142
+ onTouchstartPassive: N[0] || (N[0] = //@ts-ignore
2143
+ (...J) => f($) && f($)(...J)),
2144
+ onTouchmove: N[1] || (N[1] = //@ts-ignore
2145
+ (...J) => f(Y) && f(Y)(...J)),
2146
+ onTouchend: N[2] || (N[2] = //@ts-ignore
2147
+ (...J) => f(A) && f(A)(...J)),
2148
+ onTouchcancel: N[3] || (N[3] = //@ts-ignore
2149
+ (...J) => f(P) && f(P)(...J))
1482
2150
  }, [
1483
- l.pullToRefresh || l.refreshing ? (I(), $("div", {
2151
+ t.pullToRefresh || t.refreshing ? (j(), U("div", {
1484
2152
  key: 0,
1485
2153
  class: "vue-virtual-scroll__refresh",
1486
- style: N({
1487
- height: `${c(O)}px`,
1488
- transform: `translateY(${c(o) - c(O)}px)`
2154
+ style: ue({
2155
+ height: `${f(h)}px`,
2156
+ transform: `translateY(${f(d) - f(h)}px)`
1489
2157
  }),
1490
2158
  role: "status",
1491
2159
  "aria-live": "polite"
1492
2160
  }, [
1493
- ce(y.$slots, "refresh", {
1494
- pullDistance: c(r),
1495
- progress: c(m),
1496
- refreshing: l.refreshing
2161
+ Se(L.$slots, "refresh", {
2162
+ pullDistance: f(M),
2163
+ progress: f(c),
2164
+ refreshing: t.refreshing
1497
2165
  }, () => [
1498
- Ve(je(c(A)), 1)
2166
+ Ue(vt(f(n)), 1)
1499
2167
  ])
1500
- ], 4)) : ze("", !0),
1501
- l.items.length || l.loading ? (I(), $("div", {
2168
+ ], 4)) : Ve("", !0),
2169
+ t.items.length || t.loading ? (j(), U("div", {
1502
2170
  key: 1,
1503
2171
  class: "vue-virtual-scroll__spacer",
1504
- style: N({
1505
- height: `${Y.value}px`,
1506
- transform: `translateY(${c(o)}px)`
2172
+ style: ue({
2173
+ height: `${ie.value}px`,
2174
+ transform: `translateY(${f(d)}px)`
1507
2175
  })
1508
2176
  }, [
1509
- Ge("div", {
2177
+ lt("div", {
1510
2178
  class: "vue-virtual-scroll__content",
1511
- style: N(we.value)
2179
+ style: ue(ae.value)
1512
2180
  }, [
1513
- (I(!0), $(Re, null, De(de.value, ({ item: B, index: te }) => (I(), $("div", {
1514
- key: c(Z)(B, te),
2181
+ (j(!0), U(Je, null, et(xe.value, ({ item: J, index: Me }) => (j(), U("div", {
2182
+ key: f(ce)(J, Me),
1515
2183
  class: "vue-virtual-scroll__item",
1516
- style: N({ height: `${H.value}px` }),
2184
+ style: ue({ height: `${R.value}px` }),
1517
2185
  role: "listitem",
1518
- "aria-posinset": te + 1,
1519
- "aria-setsize": l.items.length
2186
+ "aria-posinset": Me + 1,
2187
+ "aria-setsize": t.items.length
1520
2188
  }, [
1521
- ce(y.$slots, "default", {
1522
- item: B,
1523
- index: te
2189
+ Se(L.$slots, "default", {
2190
+ item: J,
2191
+ index: Me
1524
2192
  })
1525
- ], 12, It))), 128))
2193
+ ], 12, xa))), 128))
1526
2194
  ], 4),
1527
- l.loading ? (I(), $("div", {
2195
+ t.loading ? (j(), U("div", {
1528
2196
  key: 0,
1529
2197
  class: "vue-virtual-scroll__loading",
1530
- style: N({
1531
- height: `${J.value}px`,
1532
- transform: `translateY(${R.value}px)`
2198
+ style: ue({
2199
+ height: `${oe.value}px`,
2200
+ transform: `translateY(${ne.value}px)`
1533
2201
  }),
1534
2202
  role: "status",
1535
2203
  "aria-live": "polite"
1536
2204
  }, [
1537
- ce(y.$slots, "loading", {}, () => [
1538
- L[4] || (L[4] = Ve("Loading more…", -1))
2205
+ Se(L.$slots, "loading", {}, () => [
2206
+ N[4] || (N[4] = Ue("Loading more…", -1))
1539
2207
  ])
1540
- ], 4)) : ze("", !0)
1541
- ], 4)) : (I(), $("div", {
2208
+ ], 4)) : Ve("", !0)
2209
+ ], 4)) : (j(), U("div", {
1542
2210
  key: 2,
1543
2211
  class: "vue-virtual-scroll__empty",
1544
- style: N({ transform: `translateY(${c(o)}px)` })
2212
+ style: ue({ transform: `translateY(${f(d)}px)` })
1545
2213
  }, [
1546
- ce(y.$slots, "empty")
2214
+ Se(L.$slots, "empty")
1547
2215
  ], 4))
1548
- ], 46, zt));
2216
+ ], 46, wa));
1549
2217
  }
1550
- }), kt = ["aria-label"], Et = ["aria-posinset", "aria-setsize"], Lt = /* @__PURE__ */ Oe({
2218
+ }), Ta = ["aria-label"], ba = ["aria-posinset", "aria-setsize"], Sa = /* @__PURE__ */ Qe({
1551
2219
  name: "WindowDynamicVirtualScroll",
1552
2220
  __name: "WindowDynamicVirtualScroll",
1553
2221
  props: {
@@ -1565,329 +2233,329 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
1565
2233
  pullRefreshThreshold: { default: 64 }
1566
2234
  },
1567
2235
  emits: ["scroll", "loadMore", "refresh"],
1568
- setup(l, { expose: P, emit: x }) {
1569
- const e = l, p = x, f = j(), r = j(0), o = j(0), m = j(0), A = j(0), O = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map();
1570
- let V, D, w, k, E = !1, F = !1, W = -1;
1571
- const { getItemKey: ne } = Pe({
2236
+ setup(t, { expose: s, emit: I }) {
2237
+ const e = t, x = I, y = ee(), M = ee(0), d = ee(0), c = ee(0), n = ee(0), h = /* @__PURE__ */ new Map(), $ = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
2238
+ let A, P, E, S, B = !1, K = !1, G = -1;
2239
+ const { getItemKey: te } = tt({
1572
2240
  componentName: "WindowDynamicVirtualScroll",
1573
2241
  items: () => e.items,
1574
2242
  itemKey: () => e.itemKey
1575
2243
  });
1576
- function Z(v) {
2244
+ function ce(p) {
1577
2245
  return typeof window.requestAnimationFrame == "function" ? {
1578
- id: window.requestAnimationFrame(v),
2246
+ id: window.requestAnimationFrame(p),
1579
2247
  type: "animation"
1580
2248
  } : {
1581
- id: window.setTimeout(v, 0),
2249
+ id: window.setTimeout(p, 0),
1582
2250
  type: "timeout"
1583
2251
  };
1584
2252
  }
1585
- function H(v) {
1586
- v && (v.type === "animation" ? window.cancelAnimationFrame(v.id) : window.clearTimeout(v.id));
2253
+ function R(p) {
2254
+ p && (p.type === "animation" ? window.cancelAnimationFrame(p.id) : window.clearTimeout(p.id));
1587
2255
  }
1588
2256
  const {
1589
- pulling: ae,
1590
- pullDistance: R,
1591
- pullOffset: J,
1592
- pullProgress: Y,
1593
- refreshMessage: le,
1594
- refreshThreshold: se,
1595
- handleTouchStart: me,
1596
- handleTouchMove: de,
1597
- handleTouchEnd: ue,
1598
- handleTouchCancel: we
1599
- } = qe({
2257
+ pulling: fe,
2258
+ pullDistance: ne,
2259
+ pullOffset: oe,
2260
+ pullProgress: ie,
2261
+ refreshMessage: H,
2262
+ refreshThreshold: le,
2263
+ handleTouchStart: pe,
2264
+ handleTouchMove: xe,
2265
+ handleTouchEnd: he,
2266
+ handleTouchCancel: ae
2267
+ } = xt({
1600
2268
  enabled: () => e.pullToRefresh,
1601
2269
  refreshing: () => e.refreshing,
1602
2270
  threshold: () => e.pullRefreshThreshold,
1603
- onRefresh: () => p("refresh"),
2271
+ onRefresh: () => x("refresh"),
1604
2272
  scrollTop: () => typeof window > "u" ? 0 : Math.max(0, window.scrollY)
1605
- }), G = n(
2273
+ }), F = m(
1606
2274
  () => Math.max(1, e.estimatedItemSize)
1607
- ), u = n(
1608
- () => Math.max(1, e.loadingItemSize ?? G.value)
1609
- ), d = n(() => Math.max(0, Math.floor(e.overscan))), z = n(() => {
1610
- A.value;
1611
- const v = new Array(e.items.length + 1), S = new Array(e.items.length);
1612
- v[0] = 0;
1613
- for (let T = 0; T < e.items.length; T += 1) {
1614
- const fe = ne(e.items[T], T), X = O.get(fe) ?? G.value;
1615
- S[T] = X, v[T + 1] = v[T] + X;
2275
+ ), b = m(
2276
+ () => Math.max(1, e.loadingItemSize ?? F.value)
2277
+ ), C = m(() => Math.max(0, Math.floor(e.overscan))), se = m(() => {
2278
+ n.value;
2279
+ const p = new Array(e.items.length + 1), z = new Array(e.items.length);
2280
+ p[0] = 0;
2281
+ for (let k = 0; k < e.items.length; k += 1) {
2282
+ const me = te(e.items[k], k), W = h.get(me) ?? F.value;
2283
+ z[k] = W, p[k + 1] = p[k] + W;
1616
2284
  }
1617
2285
  return {
1618
- offsets: v,
1619
- sizes: S,
1620
- total: v[e.items.length] ?? 0
2286
+ offsets: p,
2287
+ sizes: z,
2288
+ total: p[e.items.length] ?? 0
1621
2289
  };
1622
- }), Q = n(
1623
- () => z.value.total + (e.loading ? u.value : 0)
1624
- ), he = n(() => {
1625
- const v = /* @__PURE__ */ new Map();
1626
- return e.items.forEach((S, T) => {
1627
- v.set(ne(S, T), T);
1628
- }), v;
1629
- }), y = n(
1630
- () => Math.max(0, r.value - m.value)
2290
+ }), ve = m(
2291
+ () => se.value.total + (e.loading ? b.value : 0)
2292
+ ), ke = m(() => {
2293
+ const p = /* @__PURE__ */ new Map();
2294
+ return e.items.forEach((z, k) => {
2295
+ p.set(te(z, k), k);
2296
+ }), p;
2297
+ }), L = m(
2298
+ () => Math.max(0, M.value - c.value)
1631
2299
  );
1632
- function L(v) {
2300
+ function N(p) {
1633
2301
  if (e.items.length === 0) return 0;
1634
- const S = z.value.offsets;
1635
- let T = 0, fe = e.items.length;
1636
- for (; T < fe; ) {
1637
- const X = Math.floor((T + fe) / 2);
1638
- S[X + 1] <= v ? T = X + 1 : fe = X;
2302
+ const z = se.value.offsets;
2303
+ let k = 0, me = e.items.length;
2304
+ for (; k < me; ) {
2305
+ const W = Math.floor((k + me) / 2);
2306
+ z[W + 1] <= p ? k = W + 1 : me = W;
1639
2307
  }
1640
- return Math.min(T, e.items.length - 1);
2308
+ return Math.min(k, e.items.length - 1);
1641
2309
  }
1642
- const B = n(
2310
+ const J = m(
1643
2311
  () => Math.max(
1644
2312
  0,
1645
- L(y.value) - d.value
2313
+ N(L.value) - C.value
1646
2314
  )
1647
- ), te = n(() => {
2315
+ ), Me = m(() => {
1648
2316
  if (e.items.length === 0) return 0;
1649
- const v = r.value + o.value - m.value, S = Math.max(
1650
- G.value,
1651
- v
1652
- ), T = L(S) + 1;
2317
+ const p = M.value + d.value - c.value, z = Math.max(
2318
+ F.value,
2319
+ p
2320
+ ), k = N(z) + 1;
1653
2321
  return Math.min(
1654
2322
  e.items.length,
1655
- T + d.value
2323
+ k + C.value
1656
2324
  );
1657
- }), oe = n(
1658
- () => e.items.slice(B.value, te.value).map((v, S) => {
1659
- const T = B.value + S;
2325
+ }), $e = m(
2326
+ () => e.items.slice(J.value, Me.value).map((p, z) => {
2327
+ const k = J.value + z;
1660
2328
  return {
1661
- item: v,
1662
- index: T,
1663
- key: ne(v, T),
1664
- top: z.value.offsets[T]
2329
+ item: p,
2330
+ index: k,
2331
+ key: te(p, k),
2332
+ top: se.value.offsets[k]
1665
2333
  };
1666
2334
  })
1667
2335
  );
1668
- function re() {
1669
- typeof window > "u" || (r.value = Math.max(0, window.scrollY), o.value = window.innerHeight, f.value && (m.value = f.value.getBoundingClientRect().top + r.value));
2336
+ function be() {
2337
+ typeof window > "u" || (M.value = Math.max(0, window.scrollY), d.value = window.innerHeight, y.value && (c.value = y.value.getBoundingClientRect().top + M.value));
1670
2338
  }
1671
2339
  function ye() {
1672
- p("scroll", {
1673
- scrollTop: y.value,
1674
- startIndex: B.value,
1675
- endIndex: te.value
2340
+ x("scroll", {
2341
+ scrollTop: L.value,
2342
+ startIndex: J.value,
2343
+ endIndex: Me.value
1676
2344
  });
1677
2345
  }
1678
- function _(v = !1) {
1679
- F && (E || (E = v), !w && (w = Z(() => {
1680
- w = void 0, re(), E && (E = !1, ye()), t();
2346
+ function re(p = !1) {
2347
+ K && (B || (B = p), !E && (E = ce(() => {
2348
+ E = void 0, be(), B && (B = !1, ye()), T();
1681
2349
  })));
1682
2350
  }
1683
- function ee() {
1684
- _(!0);
2351
+ function de() {
2352
+ re(!0);
1685
2353
  }
1686
- function s() {
1687
- _();
2354
+ function v() {
2355
+ re();
1688
2356
  }
1689
- function t() {
1690
- if (typeof window > "u" || !e.hasMore || e.loading || W === e.items.length)
2357
+ function T() {
2358
+ if (typeof window > "u" || !e.hasMore || e.loading || G === e.items.length)
1691
2359
  return;
1692
- const v = Math.max(0, e.loadMoreThreshold), S = m.value + Q.value, T = r.value + o.value;
1693
- S - T <= v && (W = e.items.length, p("loadMore"));
1694
- }
1695
- function a(v) {
1696
- const S = v.borderBoxSize;
1697
- if (S) {
1698
- const T = Array.isArray(S) ? S[0] : S;
1699
- if (T != null && T.blockSize) return T.blockSize;
2360
+ const p = Math.max(0, e.loadMoreThreshold), z = c.value + ve.value, k = M.value + d.value;
2361
+ z - k <= p && (G = e.items.length, x("loadMore"));
2362
+ }
2363
+ function r(p) {
2364
+ const z = p.borderBoxSize;
2365
+ if (z) {
2366
+ const k = Array.isArray(z) ? z[0] : z;
2367
+ if (k != null && k.blockSize) return k.blockSize;
1700
2368
  }
1701
- return v.contentRect.height;
1702
- }
1703
- function g(v) {
1704
- const S = z.value;
1705
- let T = 0, fe = !1;
1706
- for (const X of v) {
1707
- const be = X.target, Ie = U.get(be), Be = a(X);
1708
- if (Ie === void 0 || Be <= 0) continue;
1709
- const Ke = O.get(Ie) ?? G.value;
1710
- if (Math.abs(Ke - Be) < 0.5) continue;
1711
- const He = he.value.get(Ie);
1712
- He !== void 0 && S.offsets[He + 1] <= y.value && (T += Be - Ke), O.set(Ie, Be), fe = !0;
2369
+ return p.contentRect.height;
2370
+ }
2371
+ function q(p) {
2372
+ const z = se.value;
2373
+ let k = 0, me = !1;
2374
+ for (const W of p) {
2375
+ const Ie = W.target, ge = $.get(Ie), Le = r(W);
2376
+ if (ge === void 0 || Le <= 0) continue;
2377
+ const He = h.get(ge) ?? F.value;
2378
+ if (Math.abs(He - Le) < 0.5) continue;
2379
+ const Oe = ke.value.get(ge);
2380
+ Oe !== void 0 && z.offsets[Oe + 1] <= L.value && (k += Le - He), h.set(ge, Le), me = !0;
1713
2381
  }
1714
- fe && (A.value += 1, C(() => {
1715
- if (F) {
1716
- if (T !== 0 && typeof window < "u") {
1717
- const X = Math.max(
2382
+ me && (n.value += 1, Z(() => {
2383
+ if (K) {
2384
+ if (k !== 0 && typeof window < "u") {
2385
+ const W = Math.max(
1718
2386
  0,
1719
- r.value + T
2387
+ M.value + k
1720
2388
  );
1721
- r.value = X, window.scrollTo({ top: X, behavior: "auto" });
2389
+ M.value = W, window.scrollTo({ top: W, behavior: "auto" });
1722
2390
  }
1723
- re(), t();
2391
+ be(), T();
1724
2392
  }
1725
2393
  }));
1726
2394
  }
1727
- function b(v) {
1728
- if (F) {
1729
- for (const S of v)
1730
- q.set(S.target, S);
1731
- k || (k = Z(() => {
1732
- k = void 0;
1733
- const S = Array.from(q.values());
1734
- q.clear(), g(S);
2395
+ function Q(p) {
2396
+ if (K) {
2397
+ for (const z of p)
2398
+ Y.set(z.target, z);
2399
+ S || (S = ce(() => {
2400
+ S = void 0;
2401
+ const z = Array.from(Y.values());
2402
+ Y.clear(), q(z);
1735
2403
  }));
1736
2404
  }
1737
2405
  }
1738
- function Me(v, S) {
1739
- v instanceof HTMLElement && (U.set(v, S), D == null || D.observe(v));
2406
+ function ze(p, z) {
2407
+ p instanceof HTMLElement && ($.set(p, z), P == null || P.observe(p));
1740
2408
  }
1741
- function ge() {
1742
- for (const [v] of U)
1743
- v.isConnected || (D == null || D.unobserve(v), U.delete(v));
2409
+ function i() {
2410
+ for (const [p] of $)
2411
+ p.isConnected || (P == null || P.unobserve(p), $.delete(p));
1744
2412
  }
1745
- function ve(v, S = {}) {
2413
+ function D(p, z = {}) {
1746
2414
  if (typeof window > "u") return;
1747
- re();
1748
- const T = Math.max(0, Q.value - o.value), fe = Math.min(
1749
- Math.max(0, Number.isFinite(v) ? v : 0),
1750
- T
1751
- ), X = Math.max(0, m.value + fe), be = S.behavior ?? "auto";
1752
- be === "auto" && (r.value = X), window.scrollTo({ ...S, top: X, behavior: be });
1753
- }
1754
- function Le(v, S = {}) {
2415
+ be();
2416
+ const k = Math.max(0, ve.value - d.value), me = Math.min(
2417
+ Math.max(0, Number.isFinite(p) ? p : 0),
2418
+ k
2419
+ ), W = Math.max(0, c.value + me), Ie = z.behavior ?? "auto";
2420
+ Ie === "auto" && (M.value = W), window.scrollTo({ ...z, top: W, behavior: Ie });
2421
+ }
2422
+ function _(p, z = {}) {
1755
2423
  if (typeof window > "u" || e.items.length === 0) return;
1756
- re();
1757
- const T = Math.min(
2424
+ be();
2425
+ const k = Math.min(
1758
2426
  e.items.length - 1,
1759
- Math.max(0, Math.floor(v))
1760
- ), { align: fe = "start", ...X } = S, be = z.value.sizes[T];
1761
- let Ie = m.value + z.value.offsets[T];
1762
- fe === "center" ? Ie -= (o.value - be) / 2 : fe === "end" && (Ie -= o.value - be);
1763
- const Be = Math.max(
1764
- m.value,
1765
- m.value + Q.value - o.value
1766
- ), Ke = Math.max(0, Math.min(Ie, Be)), He = X.behavior ?? "auto";
1767
- He === "auto" && (r.value = Ke), window.scrollTo({
1768
- ...X,
1769
- top: Ke,
1770
- behavior: He
2427
+ Math.max(0, Math.floor(p))
2428
+ ), { align: me = "start", ...W } = z, Ie = se.value.sizes[k];
2429
+ let ge = c.value + se.value.offsets[k];
2430
+ me === "center" ? ge -= (d.value - Ie) / 2 : me === "end" && (ge -= d.value - Ie);
2431
+ const Le = Math.max(
2432
+ c.value,
2433
+ c.value + ve.value - d.value
2434
+ ), He = Math.max(0, Math.min(ge, Le)), Oe = W.behavior ?? "auto";
2435
+ Oe === "auto" && (M.value = He), window.scrollTo({
2436
+ ...W,
2437
+ top: He,
2438
+ behavior: Oe
1771
2439
  });
1772
2440
  }
1773
- function ke(v = "auto") {
1774
- typeof window > "u" || (re(), window.scrollTo({ top: Math.max(0, m.value), behavior: v }));
2441
+ function X(p = "auto") {
2442
+ typeof window > "u" || (be(), window.scrollTo({ top: Math.max(0, c.value), behavior: p }));
1775
2443
  }
1776
- return ie(
2444
+ return we(
1777
2445
  () => e.itemKey,
1778
2446
  () => {
1779
- O.clear(), A.value += 1, W = -1;
2447
+ h.clear(), n.value += 1, G = -1;
1780
2448
  }
1781
- ), ie(
1782
- () => e.items.map((v, S) => ne(v, S)),
1783
- async (v, S) => {
1784
- const T = v.length !== S.length || v.some((X, be) => X !== S[be]), fe = new Set(v);
1785
- for (const X of O.keys())
1786
- fe.has(X) || O.delete(X);
1787
- T && (W = -1), A.value += 1, await C(), F && (re(), t());
2449
+ ), we(
2450
+ () => e.items.map((p, z) => te(p, z)),
2451
+ async (p, z) => {
2452
+ const k = p.length !== z.length || p.some((W, Ie) => W !== z[Ie]), me = new Set(p);
2453
+ for (const W of h.keys())
2454
+ me.has(W) || h.delete(W);
2455
+ k && (G = -1), n.value += 1, await Z(), K && (be(), T());
1788
2456
  }
1789
- ), ie(
2457
+ ), we(
1790
2458
  () => [e.hasMore, e.loading],
1791
- async ([v]) => {
1792
- v || (W = -1), await C(), F && (re(), t());
2459
+ async ([p]) => {
2460
+ p || (G = -1), await Z(), K && (be(), T());
1793
2461
  }
1794
- ), Ae(() => {
1795
- if (F = !0, re(), window.addEventListener("scroll", ee, { passive: !0 }), window.addEventListener("resize", s, { passive: !0 }), typeof ResizeObserver < "u") {
1796
- V = new ResizeObserver(() => {
1797
- _();
1798
- }), D = new ResizeObserver(b), f.value && V.observe(f.value);
1799
- for (const [v] of U)
1800
- D.observe(v);
2462
+ ), _e(() => {
2463
+ if (K = !0, be(), window.addEventListener("scroll", de, { passive: !0 }), window.addEventListener("resize", v, { passive: !0 }), typeof ResizeObserver < "u") {
2464
+ A = new ResizeObserver(() => {
2465
+ re();
2466
+ }), P = new ResizeObserver(Q), y.value && A.observe(y.value);
2467
+ for (const [p] of $)
2468
+ P.observe(p);
1801
2469
  }
1802
- C(() => {
1803
- F && t();
2470
+ Z(() => {
2471
+ K && T();
1804
2472
  });
1805
- }), Xe(ge), Ce(() => {
1806
- F = !1, window.removeEventListener("scroll", ee), window.removeEventListener("resize", s), H(w), H(k), w = void 0, k = void 0, E = !1, q.clear(), V && (V.disconnect(), V = void 0), D && (D.disconnect(), D = void 0), U.clear();
1807
- }), P({
1808
- scrollTo: ve,
1809
- scrollToIndex: Le,
1810
- scrollToTop: ke
1811
- }), (v, S) => (I(), $("div", {
2473
+ }), $t(i), qe(() => {
2474
+ K = !1, window.removeEventListener("scroll", de), window.removeEventListener("resize", v), R(E), R(S), E = void 0, S = void 0, B = !1, Y.clear(), A && (A.disconnect(), A = void 0), P && (P.disconnect(), P = void 0), $.clear();
2475
+ }), s({
2476
+ scrollTo: D,
2477
+ scrollToIndex: _,
2478
+ scrollToTop: X
2479
+ }), (p, z) => (j(), U("div", {
1812
2480
  ref_key: "root",
1813
- ref: f,
1814
- class: Ye(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": c(ae) }]),
2481
+ ref: y,
2482
+ class: ot(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": f(fe) }]),
1815
2483
  role: "list",
1816
- "aria-label": l.ariaLabel,
1817
- onTouchstartPassive: S[0] || (S[0] = //@ts-ignore
1818
- (...T) => c(me) && c(me)(...T)),
1819
- onTouchmove: S[1] || (S[1] = //@ts-ignore
1820
- (...T) => c(de) && c(de)(...T)),
1821
- onTouchend: S[2] || (S[2] = //@ts-ignore
1822
- (...T) => c(ue) && c(ue)(...T)),
1823
- onTouchcancel: S[3] || (S[3] = //@ts-ignore
1824
- (...T) => c(we) && c(we)(...T))
2484
+ "aria-label": t.ariaLabel,
2485
+ onTouchstartPassive: z[0] || (z[0] = //@ts-ignore
2486
+ (...k) => f(pe) && f(pe)(...k)),
2487
+ onTouchmove: z[1] || (z[1] = //@ts-ignore
2488
+ (...k) => f(xe) && f(xe)(...k)),
2489
+ onTouchend: z[2] || (z[2] = //@ts-ignore
2490
+ (...k) => f(he) && f(he)(...k)),
2491
+ onTouchcancel: z[3] || (z[3] = //@ts-ignore
2492
+ (...k) => f(ae) && f(ae)(...k))
1825
2493
  }, [
1826
- l.pullToRefresh || l.refreshing ? (I(), $("div", {
2494
+ t.pullToRefresh || t.refreshing ? (j(), U("div", {
1827
2495
  key: 0,
1828
2496
  class: "vue-window-dynamic-virtual-scroll__refresh",
1829
- style: N({
1830
- height: `${c(se)}px`,
1831
- transform: `translateY(${c(J) - c(se)}px)`
2497
+ style: ue({
2498
+ height: `${f(le)}px`,
2499
+ transform: `translateY(${f(oe) - f(le)}px)`
1832
2500
  }),
1833
2501
  role: "status",
1834
2502
  "aria-live": "polite"
1835
2503
  }, [
1836
- ce(v.$slots, "refresh", {
1837
- pullDistance: c(R),
1838
- progress: c(Y),
1839
- refreshing: l.refreshing
2504
+ Se(p.$slots, "refresh", {
2505
+ pullDistance: f(ne),
2506
+ progress: f(ie),
2507
+ refreshing: t.refreshing
1840
2508
  }, () => [
1841
- Ve(je(c(le)), 1)
2509
+ Ue(vt(f(H)), 1)
1842
2510
  ])
1843
- ], 4)) : ze("", !0),
1844
- l.items.length || l.loading ? (I(), $("div", {
2511
+ ], 4)) : Ve("", !0),
2512
+ t.items.length || t.loading ? (j(), U("div", {
1845
2513
  key: 1,
1846
2514
  class: "vue-window-dynamic-virtual-scroll__spacer",
1847
- style: N({
1848
- height: `${Q.value}px`,
1849
- transform: `translateY(${c(J)}px)`
2515
+ style: ue({
2516
+ height: `${ve.value}px`,
2517
+ transform: `translateY(${f(oe)}px)`
1850
2518
  })
1851
2519
  }, [
1852
- (I(!0), $(Re, null, De(oe.value, ({ item: T, index: fe, key: X, top: be }) => (I(), $("div", {
1853
- key: X,
2520
+ (j(!0), U(Je, null, et($e.value, ({ item: k, index: me, key: W, top: Ie }) => (j(), U("div", {
2521
+ key: W,
1854
2522
  ref_for: !0,
1855
- ref: (Ie) => Me(Ie, X),
2523
+ ref: (ge) => ze(ge, W),
1856
2524
  class: "vue-window-dynamic-virtual-scroll__item",
1857
- style: N({ transform: `translateY(${be}px)` }),
2525
+ style: ue({ transform: `translateY(${Ie}px)` }),
1858
2526
  role: "listitem",
1859
- "aria-posinset": fe + 1,
1860
- "aria-setsize": l.items.length
2527
+ "aria-posinset": me + 1,
2528
+ "aria-setsize": t.items.length
1861
2529
  }, [
1862
- ce(v.$slots, "default", {
1863
- item: T,
1864
- index: fe
2530
+ Se(p.$slots, "default", {
2531
+ item: k,
2532
+ index: me
1865
2533
  })
1866
- ], 12, Et))), 128)),
1867
- l.loading ? (I(), $("div", {
2534
+ ], 12, ba))), 128)),
2535
+ t.loading ? (j(), U("div", {
1868
2536
  key: 0,
1869
2537
  class: "vue-window-dynamic-virtual-scroll__loading",
1870
- style: N({
1871
- height: `${u.value}px`,
1872
- transform: `translateY(${z.value.total}px)`
2538
+ style: ue({
2539
+ height: `${b.value}px`,
2540
+ transform: `translateY(${se.value.total}px)`
1873
2541
  }),
1874
2542
  role: "status",
1875
2543
  "aria-live": "polite"
1876
2544
  }, [
1877
- ce(v.$slots, "loading", {}, () => [
1878
- S[4] || (S[4] = Ve("Loading more…", -1))
2545
+ Se(p.$slots, "loading", {}, () => [
2546
+ z[4] || (z[4] = Ue("Loading more…", -1))
1879
2547
  ])
1880
- ], 4)) : ze("", !0)
1881
- ], 4)) : (I(), $("div", {
2548
+ ], 4)) : Ve("", !0)
2549
+ ], 4)) : (j(), U("div", {
1882
2550
  key: 2,
1883
2551
  class: "vue-window-dynamic-virtual-scroll__empty",
1884
- style: N({ transform: `translateY(${c(J)}px)` })
2552
+ style: ue({ transform: `translateY(${f(oe)}px)` })
1885
2553
  }, [
1886
- ce(v.$slots, "empty")
2554
+ Se(p.$slots, "empty")
1887
2555
  ], 4))
1888
- ], 42, kt));
2556
+ ], 42, Ta));
1889
2557
  }
1890
- }), Bt = ["aria-label"], Vt = ["aria-posinset", "aria-setsize"], Ht = /* @__PURE__ */ Oe({
2558
+ }), Ia = ["aria-label"], za = ["aria-posinset", "aria-setsize"], ka = /* @__PURE__ */ Qe({
1891
2559
  name: "WindowGirdVirtualScroll",
1892
2560
  __name: "WindowGirdVirtualScroll",
1893
2561
  props: {
@@ -1907,133 +2575,133 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
1907
2575
  pullRefreshThreshold: { default: 64 }
1908
2576
  },
1909
2577
  emits: ["scroll", "loadMore", "refresh"],
1910
- setup(l, { expose: P, emit: x }) {
1911
- const e = l, p = x, f = j(), r = j(0), o = j(0), m = j(0);
1912
- let A, O = -1;
1913
- const { getItemKey: U } = Pe({
2578
+ setup(t, { expose: s, emit: I }) {
2579
+ const e = t, x = I, y = ee(), M = ee(0), d = ee(0), c = ee(0);
2580
+ let n, h = -1;
2581
+ const { getItemKey: $ } = tt({
1914
2582
  componentName: "WindowGirdVirtualScroll",
1915
2583
  items: () => e.items,
1916
2584
  itemKey: () => e.itemKey
1917
2585
  }), {
1918
- pulling: q,
1919
- pullDistance: V,
1920
- pullOffset: D,
1921
- pullProgress: w,
1922
- refreshMessage: k,
1923
- refreshThreshold: E,
1924
- handleTouchStart: F,
1925
- handleTouchMove: W,
1926
- handleTouchEnd: ne,
1927
- handleTouchCancel: Z
1928
- } = qe({
2586
+ pulling: Y,
2587
+ pullDistance: A,
2588
+ pullOffset: P,
2589
+ pullProgress: E,
2590
+ refreshMessage: S,
2591
+ refreshThreshold: B,
2592
+ handleTouchStart: K,
2593
+ handleTouchMove: G,
2594
+ handleTouchEnd: te,
2595
+ handleTouchCancel: ce
2596
+ } = xt({
1929
2597
  enabled: () => e.pullToRefresh,
1930
2598
  refreshing: () => e.refreshing,
1931
2599
  threshold: () => e.pullRefreshThreshold,
1932
- onRefresh: () => p("refresh"),
2600
+ onRefresh: () => x("refresh"),
1933
2601
  scrollTop: () => typeof window > "u" ? 0 : Math.max(0, window.scrollY)
1934
- }), H = n(() => Math.max(1, e.itemSize)), ae = n(
2602
+ }), R = m(() => Math.max(1, e.itemSize)), fe = m(
1935
2603
  () => Math.max(1, Math.floor(e.columns))
1936
- ), R = n(() => Math.max(0, e.gap)), J = n(() => Math.max(0, Math.floor(e.overscan))), Y = n(
1937
- () => Math.max(1, e.loadingItemSize ?? H.value)
1938
- ), le = n(
1939
- () => H.value + R.value
1940
- ), se = n(
1941
- () => Math.ceil(e.items.length / ae.value)
1942
- ), me = n(() => se.value === 0 ? 0 : se.value * H.value + (se.value - 1) * R.value), de = n(
1943
- () => me.value + (e.items.length ? R.value : 0)
1944
- ), ue = n(
1945
- () => me.value + (e.loading ? Y.value + (e.items.length ? R.value : 0) : 0)
1946
- ), we = n(
1947
- () => Math.max(0, r.value - m.value)
1948
- ), G = n(
2604
+ ), ne = m(() => Math.max(0, e.gap)), oe = m(() => Math.max(0, Math.floor(e.overscan))), ie = m(
2605
+ () => Math.max(1, e.loadingItemSize ?? R.value)
2606
+ ), H = m(
2607
+ () => R.value + ne.value
2608
+ ), le = m(
2609
+ () => Math.ceil(e.items.length / fe.value)
2610
+ ), pe = m(() => le.value === 0 ? 0 : le.value * R.value + (le.value - 1) * ne.value), xe = m(
2611
+ () => pe.value + (e.items.length ? ne.value : 0)
2612
+ ), he = m(
2613
+ () => pe.value + (e.loading ? ie.value + (e.items.length ? ne.value : 0) : 0)
2614
+ ), ae = m(
2615
+ () => Math.max(0, M.value - c.value)
2616
+ ), F = m(
1949
2617
  () => Math.max(
1950
2618
  0,
1951
- Math.floor(we.value / le.value) - J.value
2619
+ Math.floor(ae.value / H.value) - oe.value
1952
2620
  )
1953
- ), u = n(() => {
1954
- if (se.value === 0) return 0;
1955
- const _ = Math.max(
1956
- H.value,
1957
- r.value + o.value - m.value
1958
- ), ee = Math.ceil(
1959
- (_ + R.value) / le.value
2621
+ ), b = m(() => {
2622
+ if (le.value === 0) return 0;
2623
+ const re = Math.max(
2624
+ R.value,
2625
+ M.value + d.value - c.value
2626
+ ), de = Math.ceil(
2627
+ (re + ne.value) / H.value
1960
2628
  );
1961
2629
  return Math.min(
1962
- se.value,
1963
- ee + J.value
2630
+ le.value,
2631
+ de + oe.value
1964
2632
  );
1965
- }), d = n(
1966
- () => Math.min(e.items.length, G.value * ae.value)
1967
- ), z = n(
1968
- () => Math.min(e.items.length, u.value * ae.value)
1969
- ), Q = n(
1970
- () => e.items.slice(d.value, z.value).map((_, ee) => {
1971
- const s = d.value + ee;
2633
+ }), C = m(
2634
+ () => Math.min(e.items.length, F.value * fe.value)
2635
+ ), se = m(
2636
+ () => Math.min(e.items.length, b.value * fe.value)
2637
+ ), ve = m(
2638
+ () => e.items.slice(C.value, se.value).map((re, de) => {
2639
+ const v = C.value + de;
1972
2640
  return {
1973
- item: _,
1974
- index: s,
1975
- key: U(_, s),
1976
- rowIndex: Math.floor(s / ae.value),
1977
- columnIndex: s % ae.value
2641
+ item: re,
2642
+ index: v,
2643
+ key: $(re, v),
2644
+ rowIndex: Math.floor(v / fe.value),
2645
+ columnIndex: v % fe.value
1978
2646
  };
1979
2647
  })
1980
- ), he = n(() => ({
1981
- gridTemplateColumns: `repeat(${ae.value}, minmax(0, 1fr))`,
1982
- columnGap: `${R.value}px`,
1983
- rowGap: `${R.value}px`,
1984
- transform: `translateY(${G.value * le.value}px)`
2648
+ ), ke = m(() => ({
2649
+ gridTemplateColumns: `repeat(${fe.value}, minmax(0, 1fr))`,
2650
+ columnGap: `${ne.value}px`,
2651
+ rowGap: `${ne.value}px`,
2652
+ transform: `translateY(${F.value * H.value}px)`
1985
2653
  }));
1986
- function y() {
1987
- typeof window > "u" || (r.value = Math.max(0, window.scrollY), o.value = window.innerHeight, f.value && (m.value = f.value.getBoundingClientRect().top + r.value));
1988
- }
1989
2654
  function L() {
1990
- p("scroll", {
1991
- scrollTop: we.value,
1992
- startIndex: d.value,
1993
- endIndex: z.value
2655
+ typeof window > "u" || (M.value = Math.max(0, window.scrollY), d.value = window.innerHeight, y.value && (c.value = y.value.getBoundingClientRect().top + M.value));
2656
+ }
2657
+ function N() {
2658
+ x("scroll", {
2659
+ scrollTop: ae.value,
2660
+ startIndex: C.value,
2661
+ endIndex: se.value
1994
2662
  });
1995
2663
  }
1996
- function B() {
1997
- y(), L(), te();
2664
+ function J() {
2665
+ L(), N(), Me();
1998
2666
  }
1999
- function te() {
2000
- if (typeof window > "u" || !e.hasMore || e.loading || O === e.items.length)
2667
+ function Me() {
2668
+ if (typeof window > "u" || !e.hasMore || e.loading || h === e.items.length)
2001
2669
  return;
2002
- const _ = Math.max(0, e.loadMoreThreshold), ee = m.value + ue.value, s = r.value + o.value;
2003
- ee - s <= _ && (O = e.items.length, p("loadMore"));
2670
+ const re = Math.max(0, e.loadMoreThreshold), de = c.value + he.value, v = M.value + d.value;
2671
+ de - v <= re && (h = e.items.length, x("loadMore"));
2004
2672
  }
2005
- function oe(_, ee = {}) {
2673
+ function $e(re, de = {}) {
2006
2674
  if (typeof window > "u") return;
2007
- y();
2008
- const s = Math.max(0, ue.value - o.value), t = Math.min(
2009
- Math.max(0, Number.isFinite(_) ? _ : 0),
2010
- s
2011
- ), a = Math.max(0, m.value + t), g = ee.behavior ?? "auto";
2012
- g === "auto" && (r.value = a), window.scrollTo({ ...ee, top: a, behavior: g });
2013
- }
2014
- function re(_, ee = {}) {
2675
+ L();
2676
+ const v = Math.max(0, he.value - d.value), T = Math.min(
2677
+ Math.max(0, Number.isFinite(re) ? re : 0),
2678
+ v
2679
+ ), r = Math.max(0, c.value + T), q = de.behavior ?? "auto";
2680
+ q === "auto" && (M.value = r), window.scrollTo({ ...de, top: r, behavior: q });
2681
+ }
2682
+ function be(re, de = {}) {
2015
2683
  if (typeof window > "u" || e.items.length === 0) return;
2016
- y();
2017
- const s = Math.min(
2684
+ L();
2685
+ const v = Math.min(
2018
2686
  e.items.length - 1,
2019
- Math.max(0, Math.floor(_))
2020
- ), t = Math.floor(s / ae.value), { align: a = "start", ...g } = ee;
2021
- let b = m.value + t * le.value;
2022
- a === "center" ? b -= (o.value - H.value) / 2 : a === "end" && (b -= o.value - H.value);
2023
- const Me = Math.max(
2024
- m.value,
2025
- m.value + ue.value - o.value
2026
- ), ge = Math.max(0, Math.min(b, Me)), ve = g.behavior ?? "auto";
2027
- ve === "auto" && (r.value = ge), window.scrollTo({
2028
- ...g,
2029
- top: ge,
2030
- behavior: ve
2687
+ Math.max(0, Math.floor(re))
2688
+ ), T = Math.floor(v / fe.value), { align: r = "start", ...q } = de;
2689
+ let Q = c.value + T * H.value;
2690
+ r === "center" ? Q -= (d.value - R.value) / 2 : r === "end" && (Q -= d.value - R.value);
2691
+ const ze = Math.max(
2692
+ c.value,
2693
+ c.value + he.value - d.value
2694
+ ), i = Math.max(0, Math.min(Q, ze)), D = q.behavior ?? "auto";
2695
+ D === "auto" && (M.value = i), window.scrollTo({
2696
+ ...q,
2697
+ top: i,
2698
+ behavior: D
2031
2699
  });
2032
2700
  }
2033
- function ye(_ = "auto") {
2034
- typeof window > "u" || (y(), window.scrollTo({ top: Math.max(0, m.value), behavior: _ }));
2701
+ function ye(re = "auto") {
2702
+ typeof window > "u" || (L(), window.scrollTo({ top: Math.max(0, c.value), behavior: re }));
2035
2703
  }
2036
- return ie(
2704
+ return we(
2037
2705
  () => [
2038
2706
  e.items.length,
2039
2707
  e.itemSize,
@@ -2041,128 +2709,128 @@ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PU
2041
2709
  e.gap
2042
2710
  ],
2043
2711
  async () => {
2044
- await C(), y(), te();
2712
+ await Z(), L(), Me();
2045
2713
  }
2046
- ), ie(
2714
+ ), we(
2047
2715
  () => [e.hasMore, e.loading],
2048
- async ([_]) => {
2049
- _ || (O = -1), await C(), y(), te();
2716
+ async ([re]) => {
2717
+ re || (h = -1), await Z(), L(), Me();
2050
2718
  }
2051
- ), Ae(() => {
2052
- y(), window.addEventListener("scroll", B, { passive: !0 }), window.addEventListener("resize", B, { passive: !0 }), typeof ResizeObserver < "u" && (A = new ResizeObserver(() => {
2053
- y(), te();
2054
- }), f.value && A.observe(f.value)), C(te);
2055
- }), Ce(() => {
2056
- window.removeEventListener("scroll", B), window.removeEventListener("resize", B), A && (A.disconnect(), A = void 0);
2057
- }), P({
2058
- scrollTo: oe,
2059
- scrollToIndex: re,
2719
+ ), _e(() => {
2720
+ L(), window.addEventListener("scroll", J, { passive: !0 }), window.addEventListener("resize", J, { passive: !0 }), typeof ResizeObserver < "u" && (n = new ResizeObserver(() => {
2721
+ L(), Me();
2722
+ }), y.value && n.observe(y.value)), Z(Me);
2723
+ }), qe(() => {
2724
+ window.removeEventListener("scroll", J), window.removeEventListener("resize", J), n && (n.disconnect(), n = void 0);
2725
+ }), s({
2726
+ scrollTo: $e,
2727
+ scrollToIndex: be,
2060
2728
  scrollToTop: ye
2061
- }), (_, ee) => (I(), $("div", {
2729
+ }), (re, de) => (j(), U("div", {
2062
2730
  ref_key: "root",
2063
- ref: f,
2064
- class: Ye(["vue-window-gird-virtual-scroll", { "vue-window-gird-virtual-scroll--pulling": c(q) }]),
2731
+ ref: y,
2732
+ class: ot(["vue-window-gird-virtual-scroll", { "vue-window-gird-virtual-scroll--pulling": f(Y) }]),
2065
2733
  role: "list",
2066
- "aria-label": l.ariaLabel,
2067
- onTouchstartPassive: ee[0] || (ee[0] = //@ts-ignore
2068
- (...s) => c(F) && c(F)(...s)),
2069
- onTouchmove: ee[1] || (ee[1] = //@ts-ignore
2070
- (...s) => c(W) && c(W)(...s)),
2071
- onTouchend: ee[2] || (ee[2] = //@ts-ignore
2072
- (...s) => c(ne) && c(ne)(...s)),
2073
- onTouchcancel: ee[3] || (ee[3] = //@ts-ignore
2074
- (...s) => c(Z) && c(Z)(...s))
2734
+ "aria-label": t.ariaLabel,
2735
+ onTouchstartPassive: de[0] || (de[0] = //@ts-ignore
2736
+ (...v) => f(K) && f(K)(...v)),
2737
+ onTouchmove: de[1] || (de[1] = //@ts-ignore
2738
+ (...v) => f(G) && f(G)(...v)),
2739
+ onTouchend: de[2] || (de[2] = //@ts-ignore
2740
+ (...v) => f(te) && f(te)(...v)),
2741
+ onTouchcancel: de[3] || (de[3] = //@ts-ignore
2742
+ (...v) => f(ce) && f(ce)(...v))
2075
2743
  }, [
2076
- l.pullToRefresh || l.refreshing ? (I(), $("div", {
2744
+ t.pullToRefresh || t.refreshing ? (j(), U("div", {
2077
2745
  key: 0,
2078
2746
  class: "vue-window-gird-virtual-scroll__refresh",
2079
- style: N({
2080
- height: `${c(E)}px`,
2081
- transform: `translateY(${c(D) - c(E)}px)`
2747
+ style: ue({
2748
+ height: `${f(B)}px`,
2749
+ transform: `translateY(${f(P) - f(B)}px)`
2082
2750
  }),
2083
2751
  role: "status",
2084
2752
  "aria-live": "polite"
2085
2753
  }, [
2086
- ce(_.$slots, "refresh", {
2087
- pullDistance: c(V),
2088
- progress: c(w),
2089
- refreshing: l.refreshing
2754
+ Se(re.$slots, "refresh", {
2755
+ pullDistance: f(A),
2756
+ progress: f(E),
2757
+ refreshing: t.refreshing
2090
2758
  }, () => [
2091
- Ve(je(c(k)), 1)
2759
+ Ue(vt(f(S)), 1)
2092
2760
  ])
2093
- ], 4)) : ze("", !0),
2094
- l.items.length || l.loading ? (I(), $("div", {
2761
+ ], 4)) : Ve("", !0),
2762
+ t.items.length || t.loading ? (j(), U("div", {
2095
2763
  key: 1,
2096
2764
  class: "vue-window-gird-virtual-scroll__spacer",
2097
- style: N({
2098
- height: `${ue.value}px`,
2099
- transform: `translateY(${c(D)}px)`
2765
+ style: ue({
2766
+ height: `${he.value}px`,
2767
+ transform: `translateY(${f(P)}px)`
2100
2768
  })
2101
2769
  }, [
2102
- Ge("div", {
2770
+ lt("div", {
2103
2771
  class: "vue-window-gird-virtual-scroll__content",
2104
- style: N(he.value)
2772
+ style: ue(ke.value)
2105
2773
  }, [
2106
- (I(!0), $(Re, null, De(Q.value, ({ item: s, index: t, key: a, rowIndex: g, columnIndex: b }) => (I(), $("div", {
2107
- key: a,
2774
+ (j(!0), U(Je, null, et(ve.value, ({ item: v, index: T, key: r, rowIndex: q, columnIndex: Q }) => (j(), U("div", {
2775
+ key: r,
2108
2776
  class: "vue-window-gird-virtual-scroll__item",
2109
- style: N({ height: `${H.value}px` }),
2777
+ style: ue({ height: `${R.value}px` }),
2110
2778
  role: "listitem",
2111
- "aria-posinset": t + 1,
2112
- "aria-setsize": l.items.length
2779
+ "aria-posinset": T + 1,
2780
+ "aria-setsize": t.items.length
2113
2781
  }, [
2114
- ce(_.$slots, "default", {
2115
- item: s,
2116
- index: t,
2117
- rowIndex: g,
2118
- columnIndex: b
2782
+ Se(re.$slots, "default", {
2783
+ item: v,
2784
+ index: T,
2785
+ rowIndex: q,
2786
+ columnIndex: Q
2119
2787
  })
2120
- ], 12, Vt))), 128))
2788
+ ], 12, za))), 128))
2121
2789
  ], 4),
2122
- l.loading ? (I(), $("div", {
2790
+ t.loading ? (j(), U("div", {
2123
2791
  key: 0,
2124
2792
  class: "vue-window-gird-virtual-scroll__loading",
2125
- style: N({
2126
- height: `${Y.value}px`,
2127
- transform: `translateY(${de.value}px)`
2793
+ style: ue({
2794
+ height: `${ie.value}px`,
2795
+ transform: `translateY(${xe.value}px)`
2128
2796
  }),
2129
2797
  role: "status",
2130
2798
  "aria-live": "polite"
2131
2799
  }, [
2132
- ce(_.$slots, "loading", {}, () => [
2133
- ee[4] || (ee[4] = Ve("Loading more…", -1))
2800
+ Se(re.$slots, "loading", {}, () => [
2801
+ de[4] || (de[4] = Ue("Loading more…", -1))
2134
2802
  ])
2135
- ], 4)) : ze("", !0)
2136
- ], 4)) : (I(), $("div", {
2803
+ ], 4)) : Ve("", !0)
2804
+ ], 4)) : (j(), U("div", {
2137
2805
  key: 2,
2138
2806
  class: "vue-window-gird-virtual-scroll__empty",
2139
- style: N({ transform: `translateY(${c(D)}px)` })
2807
+ style: ue({ transform: `translateY(${f(P)}px)` })
2140
2808
  }, [
2141
- ce(_.$slots, "empty")
2809
+ Se(re.$slots, "empty")
2142
2810
  ], 4))
2143
- ], 42, Bt));
2811
+ ], 42, Ia));
2144
2812
  }
2145
- }), Rt = et, Kt = {
2146
- install(l) {
2147
- l.component("ChatVirtualScroll", st), l.component("DynamicVirtualScroll", et), l.component("ShortMediaFeed", mt), l.component("SkeletonLoader", Mt), l.component("VirtualCarousel", St), l.component("VirtualList", Rt), l.component("VirtualScroll", $t), l.component(
2813
+ }), $a = Bt, La = {
2814
+ install(t) {
2815
+ t.component("ChatVirtualScroll", Zt), t.component("DynamicVirtualScroll", Bt), t.component("ShortMediaFeed", la), t.component("SkeletonLoader", sa), t.component("VirtualCarousel", ya), t.component("VirtualList", $a), t.component("VirtualScroll", Ma), t.component(
2148
2816
  "WindowDynamicVirtualScroll",
2149
- Lt
2150
- ), l.component(
2817
+ Sa
2818
+ ), t.component(
2151
2819
  "WindowGirdVirtualScroll",
2152
- Ht
2820
+ ka
2153
2821
  );
2154
2822
  }
2155
2823
  };
2156
2824
  export {
2157
- st as ChatVirtualScroll,
2158
- et as DynamicVirtualScroll,
2159
- mt as ShortMediaFeed,
2160
- Mt as SkeletonLoader,
2161
- St as VirtualCarousel,
2162
- Rt as VirtualList,
2163
- $t as VirtualScroll,
2164
- Kt as VueVirtualScroll,
2165
- Lt as WindowDynamicVirtualScroll,
2166
- Ht as WindowGirdVirtualScroll,
2167
- Kt as default
2825
+ Zt as ChatVirtualScroll,
2826
+ Bt as DynamicVirtualScroll,
2827
+ la as ShortMediaFeed,
2828
+ sa as SkeletonLoader,
2829
+ ya as VirtualCarousel,
2830
+ $a as VirtualList,
2831
+ Ma as VirtualScroll,
2832
+ La as VueVirtualScroll,
2833
+ Sa as WindowDynamicVirtualScroll,
2834
+ ka as WindowGirdVirtualScroll,
2835
+ La as default
2168
2836
  };