vue-virtual-flow 0.0.7 → 0.0.9

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.
@@ -1,51 +1,96 @@
1
- import { watch as le, defineComponent as $e, ref as P, computed as i, nextTick as O, onMounted as ke, onUpdated as Ae, onBeforeUnmount as Le, openBlock as x, createElementBlock as T, normalizeStyle as C, createElementVNode as De, renderSlot as ie, createTextVNode as Ie, createCommentVNode as xe, Fragment as ze, renderList as Ee, unref as c, normalizeClass as Be, toDisplayString as Oe } from "vue";
2
- function Ye(a) {
3
- return typeof a == "string" || typeof a == "number" || typeof a == "symbol";
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";
4
4
  }
5
- function Pe(a, _) {
6
- const E = a[_];
7
- return Ye(E) ? E : void 0;
5
+ function Ze(l, P) {
6
+ const x = l[P];
7
+ return tt(x) ? x : void 0;
8
8
  }
9
- function _e(a) {
10
- return Pe(a, "id") ?? Pe(a, "key");
9
+ function lt(l) {
10
+ return Ze(l, "id") ?? Ze(l, "key");
11
11
  }
12
- function He(a) {
13
- function _(e, y) {
14
- const f = a.itemKey();
12
+ function Pe(l) {
13
+ function P(e, p) {
14
+ const f = l.itemKey();
15
15
  if (typeof f == "function")
16
- return f(e, y);
16
+ return f(e, p);
17
17
  if (e !== null && typeof e == "object") {
18
18
  if (f !== void 0) {
19
- const r = Pe(e, f);
20
- if (r !== void 0) return r;
19
+ const o = Ze(e, f);
20
+ if (o !== void 0) return o;
21
21
  }
22
- const S = _e(e);
23
- if (S !== void 0) return S;
22
+ const r = lt(e);
23
+ if (r !== void 0) return r;
24
24
  }
25
- return y;
25
+ return p;
26
26
  }
27
- function E() {
27
+ function x() {
28
28
  }
29
- return le(
30
- () => [a.itemKey(), a.items()],
31
- E,
29
+ return ie(
30
+ () => [l.itemKey(), l.items()],
31
+ x,
32
32
  { immediate: !0 }
33
- ), { getItemKey: _ };
33
+ ), { getItemKey: P };
34
34
  }
35
- function Ve(a) {
36
- return a === "fill" ? "100%" : typeof a == "number" ? `${a}px` : a;
35
+ function Fe(l) {
36
+ return l === "fill" ? "100%" : typeof l == "number" ? `${l}px` : l;
37
37
  }
38
- function Ce(a) {
39
- return (_, E) => {
40
- typeof E == "string" && (E === "fill" || E.trim().endsWith("%"));
38
+ function Ue(l) {
39
+ return (P, x) => {
40
+ typeof x == "string" && (x === "fill" || x.trim().endsWith("%"));
41
41
  };
42
42
  }
43
- const Ge = ["aria-label"], je = {
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]);
51
+ }
52
+ let f = 1;
53
+ for (; f * 2 <= x; ) f *= 2;
54
+ return {
55
+ length: x,
56
+ get total() {
57
+ return p;
58
+ },
59
+ getSize(r) {
60
+ return P[r];
61
+ },
62
+ getOffset(r) {
63
+ let o = 0;
64
+ for (let m = r; m > 0; m -= m & -m)
65
+ o += e[m];
66
+ return o;
67
+ },
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;
74
+ }
75
+ },
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]);
83
+ }
84
+ return Math.min(o, x - 1);
85
+ }
86
+ };
87
+ }
88
+ const ot = ["aria-label"], nt = {
44
89
  key: 0,
45
90
  class: "vue-chat-virtual-scroll__loading-older",
46
91
  role: "status",
47
92
  "aria-live": "polite"
48
- }, Ue = ["aria-posinset", "aria-setsize"], Ze = /* @__PURE__ */ $e({
93
+ }, it = ["aria-posinset", "aria-setsize"], st = /* @__PURE__ */ Oe({
49
94
  name: "ChatVirtualScroll",
50
95
  __name: "ChatVirtualScroll",
51
96
  props: {
@@ -64,343 +109,376 @@ const Ge = ["aria-label"], je = {
64
109
  loadOlderThreshold: { default: 120 }
65
110
  },
66
111
  emits: ["scroll", "loadOlder", "bottomChange"],
67
- setup(a, { expose: _, emit: E }) {
68
- const e = a, y = E, f = P(), S = P(0), r = P(0), H = P(0), U = P(0), F = P(!0), W = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map();
69
- let L, p, I = -1, w = !1, A = !1, V = !1, N, K = 0, ee = !1, $ = 0;
70
- const X = Ce(), { getItemKey: B } = He({
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({
71
116
  componentName: "ChatVirtualScroll",
72
117
  items: () => e.items,
73
118
  itemKey: () => e.itemKey
74
- }), q = i(
75
- () => Math.max(1, e.estimatedItemSize)
76
- ), ae = i(() => Math.max(0, Math.floor(e.overscan))), he = i(
119
+ }), de = n(
120
+ () => Number.isFinite(e.estimatedItemSize) ? Math.max(1, e.estimatedItemSize) : 48
121
+ ), ue = n(() => Math.max(0, Math.floor(e.overscan))), we = n(
77
122
  () => e.size !== void 0 && Number.isFinite(e.size) && e.size > 0 ? Math.max(1, Math.floor(e.size)) : void 0
78
- ), oe = i(() => H.value > 0 ? H.value : typeof e.height == "number" ? Math.max(0, e.height) : q.value), v = i(() => {
79
- U.value;
80
- const t = new Array(e.items.length + 1), n = new Array(e.items.length);
81
- t[0] = 0;
82
- for (let u = 0; u < e.items.length; u += 1) {
83
- const g = B(e.items[u], u), R = W.get(g) ?? q.value;
84
- n[u] = R, t[u + 1] = t[u] + R;
85
- }
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));
86
125
  return {
87
- offsets: t,
88
- sizes: n,
89
- total: t[e.items.length] ?? 0
126
+ keys: i,
127
+ indexes: new Map(i.map((h, M) => [h, M])),
128
+ sizes: at(i.map((h) => U.get(h) ?? de.value))
90
129
  };
91
- }), M = i(() => {
92
- const t = /* @__PURE__ */ new Map();
93
- return e.items.forEach((n, u) => {
94
- t.set(B(n, u), u);
95
- }), t;
96
- });
97
- function D(t) {
98
- if (e.items.length === 0) return 0;
99
- const n = v.value.offsets;
100
- let u = 0, g = e.items.length;
101
- for (; u < g; ) {
102
- const R = Math.floor((u + g) / 2);
103
- n[R + 1] <= t ? u = R + 1 : g = R;
104
- }
105
- return Math.min(u, e.items.length - 1);
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);
106
133
  }
107
- const ve = i(() => {
134
+ function Q(i) {
135
+ return d.value.sizes.findIndex(i);
136
+ }
137
+ r.value = e.initialScroll === "bottom" ? z() : 0;
138
+ const he = n(() => {
108
139
  if (e.items.length === 0) return { start: 0, end: 0 };
109
- const t = D(S.value), n = D(S.value + oe.value) + 1, u = Math.max(0, t - ae.value), g = Math.min(
140
+ const i = Q(r.value), h = Q(r.value + G.value) + 1, M = Math.max(0, i - ue.value), K = Math.min(
110
141
  e.items.length,
111
- n + ae.value
112
- ), R = he.value;
113
- if (R === void 0 || g - u <= R) return { start: u, end: g };
114
- const Q = Math.max(0, R - (n - t)), re = t - u, ce = g - n;
115
- let de = Math.min(re, Math.ceil(Q / 2));
116
- const Se = Math.min(ce, Q - de);
117
- return de = Math.min(re, Q - Se), { start: t - de, end: n + Se };
118
- }), te = i(() => ve.value.start), ye = i(() => ve.value.end), ne = i(
119
- () => e.items.slice(te.value, ye.value).map((t, n) => {
120
- const u = te.value + n;
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;
121
152
  return {
122
- item: t,
123
- index: u,
124
- key: B(t, u),
125
- top: v.value.offsets[u] - r.value
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
126
157
  };
127
158
  })
128
- ), fe = i(() => ({
129
- height: Ve(e.height)
159
+ ), te = n(() => ({
160
+ height: Fe(e.height)
130
161
  }));
131
- function J() {
132
- var t;
133
- return (((t = f.value) == null ? void 0 : t.scrollTop) ?? 0) + K;
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());
176
+ });
134
177
  }
135
- function me() {
136
- ee || (ee = !0, O(() => {
137
- ee = !1;
138
- const t = f.value;
139
- !t || V || K === 0 || (K = 0, t.scrollTop = S.value, S.value = t.scrollTop, ue(), s());
140
- }));
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;
183
+ return;
184
+ }
185
+ (W || Y) && !H ? (o.value = Z, h.scrollTop >= -1 && re(!0)) : re();
186
+ }
141
187
  }
142
- function m(t) {
143
- !f.value || t === 0 || (K += t, S.value = J(), V ? r.value = K : me());
188
+ function _() {
189
+ clearTimeout(ne), ne = void 0;
144
190
  }
145
- function b() {
146
- clearTimeout(N), N = void 0;
191
+ function ee() {
192
+ if (F) return;
193
+ _(), W = !1;
194
+ const i = Y;
195
+ if (Y = void 0, i) {
196
+ i();
197
+ return;
198
+ }
199
+ r.value = oe(), re();
147
200
  }
148
- function z() {
149
- A || (b(), V = !1, S.value = J(), r.value = 0, me());
201
+ function s() {
202
+ _(), (W || Y) && !F && (ne = setTimeout(ee, 150));
150
203
  }
151
- function G() {
152
- b(), V && !A && (N = setTimeout(z, 150));
204
+ function t() {
205
+ R = void 0, Y = void 0;
153
206
  }
154
- function Me() {
155
- b(), A = !0, V = !0, r.value = K;
207
+ function a() {
208
+ t(), _(), F = !0, W = !0, o.value = Z;
156
209
  }
157
- function se(t) {
158
- A = t.touches.length > 0, G();
210
+ function g(i) {
211
+ F = i.touches.length > 0, s();
159
212
  }
160
- function ue() {
161
- const t = f.value;
162
- if (!t) return;
163
- const u = Math.max(
213
+ function b() {
214
+ const i = f.value;
215
+ if (!i) return;
216
+ const M = Math.max(
164
217
  0,
165
- v.value.total - J() - t.clientHeight
218
+ d.value.total - oe() - i.clientHeight
166
219
  ) <= Math.max(0, e.bottomThreshold);
167
- u !== F.value && (F.value = u, w && y("bottomChange", u));
220
+ M !== O.value && (O.value = M, E && p("bottomChange", M));
168
221
  }
169
- function Y() {
170
- var t;
171
- H.value = ((t = f.value) == null ? void 0 : t.clientHeight) ?? 0, X(f.value, e.height), O(() => {
172
- ue(), s();
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();
173
226
  });
174
227
  }
175
- function j() {
176
- var t;
177
- K < 0 && J() < 0 && (K = -Math.max(0, ((t = f.value) == null ? void 0 : t.scrollTop) ?? 0), V && (r.value = K)), S.value = J(), G(), ue(), y("scroll", {
178
- scrollTop: S.value,
179
- startIndex: te.value,
180
- endIndex: ye.value
181
- }), s();
182
- }
183
- function s() {
184
- const t = f.value;
185
- !w || !t || !e.hasOlder || e.loadingOlder || I === e.items.length || J() <= Math.max(0, e.loadOlderThreshold) && (I = e.items.length, y("loadOlder"));
186
- }
187
- function l(t) {
188
- const n = t.borderBoxSize;
189
- if (n) {
190
- const u = Array.isArray(n) ? n[0] : n;
191
- if (u != null && u.blockSize) return u.blockSize;
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;
192
245
  }
193
- return t.contentRect.height;
194
- }
195
- function o(t) {
196
- const n = v.value, u = J(), g = !V && F.value && e.stickToBottom;
197
- let R = 0, Q = !1;
198
- for (const ce of t) {
199
- const de = ce.target, Se = Z.get(de), Re = l(ce);
200
- if (Se === void 0 || Re <= 0) continue;
201
- const Fe = W.get(Se) ?? q.value;
202
- if (Math.abs(Fe - Re) < 0.5) continue;
203
- const We = M.value.get(Se);
204
- We !== void 0 && n.offsets[We + 1] <= u && (R += Re - Fe), W.set(Se, Re), Q = !0;
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);
205
257
  }
206
- if (!Q) return;
207
- U.value += 1;
208
- const re = f.value;
209
- re && (m(g ? Math.max(0, v.value.total - re.clientHeight) - u : R), O(ue));
210
- }
211
- function h(t, n) {
212
- t instanceof HTMLElement && Z.get(t) !== n && (Z.set(t, n), p == null || p.observe(t));
213
- }
214
- function k() {
215
- for (const [t] of Z)
216
- t.isConnected || (p == null || p.unobserve(t), Z.delete(t));
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) });
268
+ }
269
+ ke(h);
217
270
  }
218
- function ge(t, n, u = !1) {
219
- const g = f.value;
220
- if (!g) return;
221
- const R = J(), Q = r.value !== 0, re = ++$, ce = n.behavior ?? "auto";
222
- K = 0, r.value = 0, V = !1, b(), ce === "auto" && (S.value = t);
223
- const de = () => {
224
- f.value !== g || re !== $ || (Q && ce !== "auto" && (g.scrollTop = R), u && ce === "auto" ? g.scrollTop = t : g.scrollTo({ ...n, top: t, behavior: ce }), O(ue));
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 });
276
+ }
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));
225
295
  };
226
- Q ? O(de) : de();
227
- }
228
- function pe(t, n = {}) {
229
- const u = f.value;
230
- if (!u) return;
231
- const g = Math.max(0, v.value.total - u.clientHeight), R = Math.min(
232
- Math.max(0, Number.isFinite(t) ? t : 0),
233
- g
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
234
304
  );
235
- ge(R, n);
305
+ X(pe, h);
236
306
  }
237
- function we(t, n = {}) {
238
- const u = f.value;
239
- if (!u || e.items.length === 0) return;
240
- const g = Math.min(
241
- e.items.length - 1,
242
- Math.max(0, Math.floor(t))
243
- ), { align: R = "start", ...Q } = n, re = v.value.sizes[g];
244
- let ce = v.value.offsets[g];
245
- R === "center" ? ce -= (u.clientHeight - re) / 2 : R === "end" && (ce -= u.clientHeight - re);
246
- const de = Math.max(
247
- 0,
248
- Math.min(ce, v.value.total - u.clientHeight)
249
- );
250
- ge(de, Q);
251
- }
252
- function be(t = "auto") {
253
- ge(0, { behavior: t });
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()));
254
311
  }
255
- function Te(t = "auto") {
256
- const n = f.value;
257
- if (!n) return;
258
- const u = Math.max(0, v.value.total - n.clientHeight);
259
- ge(u, { behavior: t }, !0);
260
- }
261
- let d = e.items.map((t, n) => B(t, n));
262
- return le(
263
- () => e.items.map((t, n) => B(t, n)),
264
- async (t) => {
265
- const n = d;
266
- d = t;
267
- const u = f.value, g = !V && F.value && e.stickToBottom, R = n[0], Q = R === void 0 ? 0 : t.indexOf(R), re = Q > 0 ? t.slice(0, Q).reduce(
268
- (de, Se) => de + (W.get(Se) ?? q.value),
269
- 0
270
- ) : 0, ce = new Set(t);
271
- for (const de of W.keys())
272
- ce.has(de) || W.delete(de);
273
- U.value += 1, re > 0 ? m(re) : u && t.length > n.length && g ? m(
274
- Math.max(0, v.value.total - u.clientHeight) - J()
275
- ) : (t.length === 0 || Q < 0) && (K = 0, r.value = 0), await O(), f.value && (S.value = J(), ue(), s());
312
+ function Be(i, h = {}) {
313
+ if (!f.value || e.items.length === 0) return;
314
+ const M = Math.min(
315
+ 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);
344
+ } 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();
347
+ }
348
+ f.value && (r.value = oe(), b(), ve());
276
349
  }
277
- ), le(
350
+ ), ie(
278
351
  () => [e.hasOlder, e.loadingOlder],
279
- async ([t]) => {
280
- t || (I = -1), await O(), s();
352
+ async ([i]) => {
353
+ i || (k = -1), await C(), ve();
281
354
  }
282
- ), ke(() => {
283
- if (Y(), typeof ResizeObserver < "u") {
284
- L = new ResizeObserver(Y), p = new ResizeObserver(o), f.value && L.observe(f.value);
285
- for (const [t] of Z)
286
- p.observe(t);
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);
287
360
  }
288
- O(() => {
289
- e.initialScroll === "bottom" && Te("auto"), w = !0, ue(), s();
361
+ C(() => {
362
+ E = !0, b(), ve();
290
363
  });
291
- }), Ae(k), Le(() => {
292
- w = !1, b(), K = 0, $ += 1, L && (L.disconnect(), L = void 0), p && (p.disconnect(), p = void 0), Z.clear();
293
- }), _({
294
- isAtBottom: F,
295
- scrollTo: pe,
296
- scrollToIndex: we,
297
- scrollToTop: be,
298
- scrollToBottom: Te
299
- }), (t, n) => (x(), T("div", {
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", {
300
375
  ref_key: "viewport",
301
376
  ref: f,
302
377
  class: "vue-chat-virtual-scroll",
303
- style: C(fe.value),
378
+ style: N(te.value),
304
379
  role: "log",
305
- "aria-label": a.ariaLabel,
380
+ "aria-label": l.ariaLabel,
306
381
  "aria-live": "polite",
307
382
  tabindex: "0",
308
- onScrollPassive: j,
309
- onScrollendPassive: z,
310
- onTouchstartPassive: Me,
311
- onTouchendPassive: se,
312
- onTouchcancelPassive: se
383
+ onScrollPassive: ge,
384
+ onScrollendPassive: ee,
385
+ onPointerdownPassive: t,
386
+ onWheelPassive: t,
387
+ onKeydown: t,
388
+ onTouchstartPassive: a,
389
+ onTouchendPassive: g,
390
+ onTouchcancelPassive: g
313
391
  }, [
314
- a.loadingOlder ? (x(), T("div", je, [
315
- De("div", null, [
316
- ie(t.$slots, "loadingOlder", {}, () => [
317
- n[0] || (n[0] = Ie("Loading older messages…", -1))
318
- ])
319
- ])
320
- ])) : xe("", !0),
321
- a.items.length ? (x(), T("div", {
322
- key: 1,
392
+ Ge("div", {
323
393
  class: "vue-chat-virtual-scroll__spacer",
324
- style: C({ height: `${Math.max(0, v.value.total - r.value)}px` })
394
+ style: N({ height: `${Math.max(G.value, d.value.total + o.value)}px` })
325
395
  }, [
326
- (x(!0), T(ze, null, Ee(ne.value, ({ item: u, index: g, key: R, top: Q }) => (x(), T("div", {
327
- key: R,
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,
328
405
  ref_for: !0,
329
- ref: (re) => h(re, R),
406
+ ref: (Te) => T(Te, pe),
330
407
  class: "vue-chat-virtual-scroll__item",
331
- style: C({ transform: `translateY(${Q}px)` }),
408
+ style: N({ transform: `translateY(${-xe}px)` }),
332
409
  role: "article",
333
- "aria-posinset": g + 1,
334
- "aria-setsize": a.items.length
410
+ "aria-posinset": K + 1,
411
+ "aria-setsize": l.items.length
335
412
  }, [
336
- ie(t.$slots, "default", {
337
- item: u,
338
- index: g
413
+ ce(i.$slots, "default", {
414
+ item: M,
415
+ index: K
339
416
  })
340
- ], 12, Ue))), 128))
341
- ], 4)) : ie(t.$slots, "empty", {}, void 0, void 0, 2)
342
- ], 44, Ge));
417
+ ], 12, it))), 128)),
418
+ l.items.length ? ze("", !0) : ce(i.$slots, "empty", {}, void 0, void 0, 1)
419
+ ], 4)
420
+ ], 44, ot));
343
421
  }
344
422
  });
345
- function Ke(a) {
346
- const _ = P(), E = P(0), e = P(!1), y = P(!1), f = i(() => Math.max(1, a.threshold())), S = i(
347
- () => a.refreshing() || y.value ? f.value : E.value
348
- ), r = i(
349
- () => Math.min(1, E.value / f.value)
350
- ), H = i(() => a.refreshing() || y.value ? "Refreshing…" : r.value >= 1 ? "Release to refresh" : "Pull to refresh");
351
- function U() {
352
- _.value = void 0, e.value = !1, E.value = 0;
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;
353
431
  }
354
- function F(L) {
355
- var w;
356
- const p = L.currentTarget, I = ((w = a.scrollTop) == null ? void 0 : w.call(a)) ?? p.scrollTop;
357
- !a.enabled() || a.refreshing() || I > 0 || L.touches.length !== 1 || (_.value = L.touches[0].clientY, e.value = !0);
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);
358
436
  }
359
- function W(L) {
360
- var A;
361
- if (_.value === void 0 || !e.value) return;
362
- const p = L.currentTarget;
363
- if ((((A = a.scrollTop) == null ? void 0 : A.call(a)) ?? p.scrollTop) > 0 || L.touches.length !== 1) {
364
- U();
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();
365
443
  return;
366
444
  }
367
- const w = L.touches[0].clientY - _.value;
368
- if (w <= 0) {
369
- E.value = 0;
445
+ const k = V.touches[0].clientY - P.value;
446
+ if (k <= 0) {
447
+ x.value = 0;
370
448
  return;
371
449
  }
372
- L.preventDefault(), E.value = Math.min(w * 0.5, f.value * 2);
450
+ V.preventDefault(), x.value = Math.min(k * 0.5, f.value * 2);
373
451
  }
374
- function Z() {
375
- if (_.value === void 0) return;
376
- const L = E.value >= f.value && a.enabled() && !a.refreshing();
377
- if (_.value = void 0, e.value = !1, !L) {
378
- E.value = 0;
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;
379
457
  return;
380
458
  }
381
- E.value = f.value, y.value = !0, a.onRefresh(), O(() => {
382
- a.refreshing() || (y.value = !1, E.value = 0);
459
+ x.value = f.value, p.value = !0, l.onRefresh(), C(() => {
460
+ l.refreshing() || (p.value = !1, x.value = 0);
383
461
  });
384
462
  }
385
- return le(
386
- () => a.refreshing(),
387
- (L, p) => {
388
- L ? (y.value = !1, E.value = f.value) : p && (y.value = !1, E.value = 0);
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);
389
467
  }
390
468
  ), {
391
469
  pulling: e,
392
- pullDistance: E,
393
- pullOffset: S,
394
- pullProgress: r,
395
- refreshMessage: H,
470
+ pullDistance: x,
471
+ pullOffset: r,
472
+ pullProgress: o,
473
+ refreshMessage: m,
396
474
  refreshThreshold: f,
397
- handleTouchStart: F,
398
- handleTouchMove: W,
399
- handleTouchEnd: Z,
400
- handleTouchCancel: U
475
+ handleTouchStart: O,
476
+ handleTouchMove: U,
477
+ handleTouchEnd: q,
478
+ handleTouchCancel: A
401
479
  };
402
480
  }
403
- const qe = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Ne = /* @__PURE__ */ $e({
481
+ const rt = ["aria-label"], ut = ["aria-posinset", "aria-setsize"], et = /* @__PURE__ */ Oe({
404
482
  name: "DynamicVirtualScroll",
405
483
  __name: "DynamicVirtualScroll",
406
484
  props: {
@@ -419,294 +497,294 @@ const qe = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Ne = /* @__PU
419
497
  pullRefreshThreshold: { default: 64 }
420
498
  },
421
499
  emits: ["scroll", "loadMore", "refresh"],
422
- setup(a, { expose: _, emit: E }) {
423
- const e = a, y = E, {
500
+ setup(l, { expose: P, emit: x }) {
501
+ const e = l, p = x, {
424
502
  pulling: f,
425
- pullDistance: S,
426
- pullOffset: r,
427
- pullProgress: H,
428
- refreshMessage: U,
429
- refreshThreshold: F,
430
- handleTouchStart: W,
431
- handleTouchMove: Z,
432
- handleTouchEnd: L,
433
- handleTouchCancel: p
434
- } = Ke({
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({
435
513
  enabled: () => e.pullToRefresh,
436
514
  refreshing: () => e.refreshing,
437
515
  threshold: () => e.pullRefreshThreshold,
438
- onRefresh: () => y("refresh")
439
- }), I = P(), w = P(0), A = P(0), V = P(0), N = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map();
440
- let ee, $, X = -1;
441
- const B = Ce(), { getItemKey: q } = He({
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({
442
520
  componentName: "DynamicVirtualScroll",
443
521
  items: () => e.items,
444
522
  itemKey: () => e.itemKey
445
- }), ae = i(
523
+ }), Y = n(
446
524
  () => Math.max(1, e.estimatedItemSize)
447
- ), he = i(
448
- () => Math.max(1, e.loadingItemSize ?? ae.value)
449
- ), oe = i(() => Math.max(0, Math.floor(e.overscan))), v = i(() => A.value > 0 ? A.value : typeof e.height == "number" ? Math.max(0, e.height) : ae.value), M = i(() => {
450
- V.value;
451
- const s = new Array(e.items.length + 1), l = new Array(e.items.length);
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);
452
530
  s[0] = 0;
453
- for (let o = 0; o < e.items.length; o += 1) {
454
- const h = q(e.items[o], o), k = N.get(h) ?? ae.value;
455
- l[o] = k, s[o + 1] = s[o] + k;
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;
456
534
  }
457
535
  return {
458
536
  offsets: s,
459
- sizes: l,
537
+ sizes: t,
460
538
  total: s[e.items.length] ?? 0
461
539
  };
462
- }), D = i(
463
- () => M.value.total + (e.loading ? he.value : 0)
464
- ), ve = i(() => {
540
+ }), ue = n(
541
+ () => de.value.total + (e.loading ? le.value : 0)
542
+ ), we = n(() => {
465
543
  const s = /* @__PURE__ */ new Map();
466
- return e.items.forEach((l, o) => {
467
- s.set(q(l, o), o);
544
+ return e.items.forEach((t, a) => {
545
+ s.set(J(t, a), a);
468
546
  }), s;
469
547
  });
470
- function te(s) {
548
+ function G(s) {
471
549
  if (e.items.length === 0) return 0;
472
- const l = M.value.offsets;
473
- let o = 0, h = e.items.length;
474
- for (; o < h; ) {
475
- const k = Math.floor((o + h) / 2);
476
- l[k + 1] <= s ? o = k + 1 : h = k;
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;
477
555
  }
478
- return Math.min(o, e.items.length - 1);
556
+ return Math.min(a, e.items.length - 1);
479
557
  }
480
- const ye = i(
558
+ const u = n(
481
559
  () => Math.max(
482
560
  0,
483
- te(w.value) - oe.value
561
+ G(k.value) - se.value
484
562
  )
485
- ), ne = i(() => {
563
+ ), d = n(() => {
486
564
  if (e.items.length === 0) return 0;
487
- const s = te(w.value + v.value) + 1;
565
+ const s = G(k.value + me.value) + 1;
488
566
  return Math.min(
489
567
  e.items.length,
490
- s + oe.value
568
+ s + se.value
491
569
  );
492
- }), fe = i(
493
- () => e.items.slice(ye.value, ne.value).map((s, l) => {
494
- const o = ye.value + l;
570
+ }), z = n(
571
+ () => e.items.slice(u.value, d.value).map((s, t) => {
572
+ const a = u.value + t;
495
573
  return {
496
574
  item: s,
497
- index: o,
498
- key: q(s, o),
499
- top: M.value.offsets[o]
575
+ index: a,
576
+ key: J(s, a),
577
+ top: de.value.offsets[a]
500
578
  };
501
579
  })
502
- ), J = i(() => ({
503
- height: Ve(e.height)
580
+ ), Q = n(() => ({
581
+ height: Fe(e.height)
504
582
  }));
505
- function me() {
583
+ function he() {
506
584
  var s;
507
- A.value = ((s = I.value) == null ? void 0 : s.clientHeight) ?? 0, B(I.value, e.height), O(b);
508
- }
509
- function m(s) {
510
- w.value = s.currentTarget.scrollTop, y("scroll", {
511
- scrollTop: w.value,
512
- startIndex: ye.value,
513
- endIndex: ne.value
514
- }), b();
515
- }
516
- function b() {
517
- const s = I.value;
518
- if (!s || !e.hasMore || e.loading || X === e.items.length)
585
+ E.value = ((s = w.value) == null ? void 0 : s.clientHeight) ?? 0, R(w.value, e.height), C(L);
586
+ }
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)
519
597
  return;
520
- const l = Math.max(0, e.loadMoreThreshold);
521
- D.value - s.scrollTop - s.clientHeight <= l && (X = e.items.length, y("loadMore"));
522
- }
523
- function z(s) {
524
- const l = s.borderBoxSize;
525
- if (l) {
526
- const o = Array.isArray(l) ? l[0] : l;
527
- if (o != null && o.blockSize) return o.blockSize;
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;
528
606
  }
529
607
  return s.contentRect.height;
530
608
  }
531
- function G(s) {
532
- const l = M.value;
533
- let o = 0, h = !1;
534
- for (const k of s) {
535
- const ge = k.target, pe = K.get(ge), we = z(k);
536
- if (pe === void 0 || we <= 0) continue;
537
- const be = N.get(pe) ?? ae.value;
538
- if (Math.abs(be - we) < 0.5) continue;
539
- const Te = ve.value.get(pe);
540
- Te !== void 0 && l.offsets[Te + 1] <= w.value && (o += we - be), N.set(pe, we), h = !0;
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;
541
619
  }
542
- h && (V.value += 1, O(b), o !== 0 && O(() => {
543
- const k = I.value;
544
- k && (k.scrollTop += o, w.value = k.scrollTop);
620
+ g && (F.value += 1, C(L), a !== 0 && C(() => {
621
+ const b = w.value;
622
+ b && (b.scrollTop += a, k.value = b.scrollTop);
545
623
  }));
546
624
  }
547
- function Me(s, l) {
548
- s instanceof HTMLElement && (K.set(s, l), $ == null || $.observe(s));
625
+ function oe(s, t) {
626
+ s instanceof HTMLElement && (ne.set(s, t), H == null || H.observe(s));
549
627
  }
550
- function se() {
551
- for (const [s] of K)
552
- s.isConnected || ($ == null || $.unobserve(s), K.delete(s));
628
+ function re() {
629
+ for (const [s] of ne)
630
+ s.isConnected || (H == null || H.unobserve(s), ne.delete(s));
553
631
  }
554
- function ue(s, l = {}) {
555
- const o = I.value;
556
- if (!o) return;
557
- const h = Math.max(0, D.value - o.clientHeight), k = Math.min(
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(
558
636
  Math.max(0, Number.isFinite(s) ? s : 0),
559
- h
560
- ), ge = l.behavior ?? "auto";
561
- ge === "auto" && (w.value = k), o.scrollTo({ ...l, top: k, behavior: ge });
562
- }
563
- function Y(s, l = {}) {
564
- const o = I.value;
565
- if (!o || e.items.length === 0) return;
566
- const h = Math.min(
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(
567
645
  e.items.length - 1,
568
646
  Math.max(0, Math.floor(s))
569
- ), { align: k = "start", ...ge } = l;
570
- let pe = M.value.offsets[h];
571
- const we = M.value.sizes[h];
572
- k === "center" ? pe -= (o.clientHeight - we) / 2 : k === "end" && (pe -= o.clientHeight - we);
573
- const be = Math.max(
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(
574
652
  0,
575
- Math.min(pe, D.value - o.clientHeight)
576
- ), Te = ge.behavior ?? "auto";
577
- Te === "auto" && (w.value = be), o.scrollTo({
578
- ...ge,
579
- top: be,
580
- behavior: Te
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
581
659
  });
582
660
  }
583
- function j(s = "auto") {
584
- var l;
585
- (l = I.value) == null || l.scrollTo({ top: 0, behavior: s });
661
+ function ee(s = "auto") {
662
+ var t;
663
+ (t = w.value) == null || t.scrollTo({ top: 0, behavior: s });
586
664
  }
587
- return le(
665
+ return ie(
588
666
  () => e.itemKey,
589
667
  () => {
590
- N.clear(), V.value += 1;
668
+ W.clear(), F.value += 1;
591
669
  }
592
- ), le(
670
+ ), ie(
593
671
  () => e.items.length,
594
672
  async () => {
595
673
  const s = new Set(
596
- e.items.map((h, k) => q(h, k))
674
+ e.items.map((g, b) => J(g, b))
597
675
  );
598
- for (const h of N.keys())
599
- s.has(h) || N.delete(h);
600
- V.value += 1, await O();
601
- const l = I.value;
602
- if (!l) return;
603
- const o = Math.max(0, D.value - l.clientHeight);
604
- l.scrollTop > o && (l.scrollTop = o, w.value = o), b();
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();
605
683
  }
606
- ), le(
684
+ ), ie(
607
685
  () => [e.hasMore, e.loading],
608
686
  async ([s]) => {
609
- s || (X = -1), await O(), b();
687
+ s || (ae = -1), await C(), L();
610
688
  }
611
- ), ke(() => {
612
- if (me(), typeof ResizeObserver < "u") {
613
- ee = new ResizeObserver(me), $ = new ResizeObserver(G), I.value && ee.observe(I.value);
614
- for (const [s] of K)
615
- $.observe(s);
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);
616
694
  }
617
- O(b);
618
- }), Ae(se), Le(() => {
619
- ee && (ee.disconnect(), ee = void 0), $ && ($.disconnect(), $ = void 0), K.clear();
620
- }), _({
621
- scrollTo: ue,
622
- scrollToIndex: Y,
623
- scrollToTop: j
624
- }), (s, l) => (x(), T("div", {
695
+ C(L);
696
+ }), Xe(re), Ce(() => {
697
+ Z && (Z.disconnect(), Z = void 0), H && (H.disconnect(), H = void 0), ne.clear();
698
+ }), P({
699
+ scrollTo: ye,
700
+ scrollToIndex: _,
701
+ scrollToTop: ee
702
+ }), (s, t) => (I(), $("div", {
625
703
  ref_key: "viewport",
626
- ref: I,
627
- class: Be(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": c(f) }]),
628
- style: C(J.value),
704
+ ref: w,
705
+ class: Ye(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": c(f) }]),
706
+ style: N(Q.value),
629
707
  role: "list",
630
- "aria-label": a.ariaLabel,
708
+ "aria-label": l.ariaLabel,
631
709
  tabindex: "0",
632
- onScrollPassive: m,
633
- onTouchstartPassive: l[0] || (l[0] = //@ts-ignore
634
- (...o) => c(W) && c(W)(...o)),
635
- onTouchmove: l[1] || (l[1] = //@ts-ignore
636
- (...o) => c(Z) && c(Z)(...o)),
637
- onTouchend: l[2] || (l[2] = //@ts-ignore
638
- (...o) => c(L) && c(L)(...o)),
639
- onTouchcancel: l[3] || (l[3] = //@ts-ignore
640
- (...o) => c(p) && c(p)(...o))
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))
641
719
  }, [
642
- a.pullToRefresh || a.refreshing ? (x(), T("div", {
720
+ l.pullToRefresh || l.refreshing ? (I(), $("div", {
643
721
  key: 0,
644
722
  class: "vue-dynamic-virtual-scroll__refresh",
645
- style: C({
646
- height: `${c(F)}px`,
647
- transform: `translateY(${c(r) - c(F)}px)`
723
+ style: N({
724
+ height: `${c(O)}px`,
725
+ transform: `translateY(${c(o) - c(O)}px)`
648
726
  }),
649
727
  role: "status",
650
728
  "aria-live": "polite"
651
729
  }, [
652
- ie(s.$slots, "refresh", {
653
- pullDistance: c(S),
654
- progress: c(H),
655
- refreshing: a.refreshing
730
+ ce(s.$slots, "refresh", {
731
+ pullDistance: c(r),
732
+ progress: c(m),
733
+ refreshing: l.refreshing
656
734
  }, () => [
657
- Ie(Oe(c(U)), 1)
735
+ Ve(je(c(A)), 1)
658
736
  ])
659
- ], 4)) : xe("", !0),
660
- a.items.length || a.loading ? (x(), T("div", {
737
+ ], 4)) : ze("", !0),
738
+ l.items.length || l.loading ? (I(), $("div", {
661
739
  key: 1,
662
740
  class: "vue-dynamic-virtual-scroll__spacer",
663
- style: C({
664
- height: `${D.value}px`,
665
- transform: `translateY(${c(r)}px)`
741
+ style: N({
742
+ height: `${ue.value}px`,
743
+ transform: `translateY(${c(o)}px)`
666
744
  })
667
745
  }, [
668
- (x(!0), T(ze, null, Ee(fe.value, ({ item: o, index: h, key: k, top: ge }) => (x(), T("div", {
669
- key: k,
746
+ (I(!0), $(Re, null, De(z.value, ({ item: a, index: g, key: b, top: Me }) => (I(), $("div", {
747
+ key: b,
670
748
  ref_for: !0,
671
- ref: (pe) => Me(pe, k),
749
+ ref: (ge) => oe(ge, b),
672
750
  class: "vue-dynamic-virtual-scroll__item",
673
- style: C({ transform: `translateY(${ge}px)` }),
751
+ style: N({ transform: `translateY(${Me}px)` }),
674
752
  role: "listitem",
675
- "aria-posinset": h + 1,
676
- "aria-setsize": a.items.length
753
+ "aria-posinset": g + 1,
754
+ "aria-setsize": l.items.length
677
755
  }, [
678
- ie(s.$slots, "default", {
679
- item: o,
680
- index: h
756
+ ce(s.$slots, "default", {
757
+ item: a,
758
+ index: g
681
759
  })
682
- ], 12, Je))), 128)),
683
- a.loading ? (x(), T("div", {
760
+ ], 12, ut))), 128)),
761
+ l.loading ? (I(), $("div", {
684
762
  key: 0,
685
763
  class: "vue-dynamic-virtual-scroll__loading",
686
- style: C({
687
- height: `${he.value}px`,
688
- transform: `translateY(${M.value.total}px)`
764
+ style: N({
765
+ height: `${le.value}px`,
766
+ transform: `translateY(${de.value.total}px)`
689
767
  }),
690
768
  role: "status",
691
769
  "aria-live": "polite"
692
770
  }, [
693
- ie(s.$slots, "loading", {}, () => [
694
- l[4] || (l[4] = Ie("Loading more…", -1))
771
+ ce(s.$slots, "loading", {}, () => [
772
+ t[4] || (t[4] = Ve("Loading more…", -1))
695
773
  ])
696
- ], 4)) : xe("", !0)
697
- ], 4)) : (x(), T("div", {
774
+ ], 4)) : ze("", !0)
775
+ ], 4)) : (I(), $("div", {
698
776
  key: 2,
699
777
  class: "vue-dynamic-virtual-scroll__empty",
700
- style: C({ transform: `translateY(${c(r)}px)` })
778
+ style: N({ transform: `translateY(${c(o)}px)` })
701
779
  }, [
702
- ie(s.$slots, "empty")
780
+ ce(s.$slots, "empty")
703
781
  ], 4))
704
- ], 46, qe));
782
+ ], 46, rt));
705
783
  }
706
- }), Qe = ["aria-label"], Xe = ["aria-current", "aria-posinset", "aria-setsize"], et = {
784
+ }), ct = ["aria-label"], dt = ["aria-current", "aria-posinset", "aria-setsize"], ft = {
707
785
  key: 1,
708
786
  class: "vue-short-media-feed__empty"
709
- }, tt = /* @__PURE__ */ $e({
787
+ }, vt = 36, ht = 700, mt = /* @__PURE__ */ Oe({
710
788
  name: "ShortMediaFeed",
711
789
  __name: "ShortMediaFeed",
712
790
  props: {
@@ -721,155 +799,170 @@ const qe = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Ne = /* @__PU
721
799
  loadMoreThreshold: { default: 2 }
722
800
  },
723
801
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
724
- setup(a, { expose: _, emit: E }) {
725
- const e = a, y = E, f = P(), S = P(0), r = P(ee(e.activeIndex));
726
- let H, U = -1;
727
- const F = Ce(), { getItemKey: W } = He({
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({
728
806
  componentName: "ShortMediaFeed",
729
807
  items: () => e.items,
730
808
  itemKey: () => e.itemKey
731
- }), Z = i(
809
+ }), w = n(
732
810
  () => Math.max(0, Math.floor(e.buffer))
733
- ), L = i(
811
+ ), k = n(
734
812
  () => Math.max(
735
813
  0,
736
814
  Math.floor(
737
815
  Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
738
816
  )
739
817
  )
740
- ), p = i(() => S.value > 0 ? S.value : typeof e.height == "number" ? Math.max(1, e.height) : 0), I = i(
741
- () => Math.max(0, r.value - Z.value)
742
- ), w = i(
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(
743
821
  () => Math.min(
744
822
  e.items.length,
745
- r.value + Z.value + 1
823
+ o.value + w.value + 1
746
824
  )
747
- ), A = i(
748
- () => e.items.slice(I.value, w.value).map((v, M) => ({
749
- item: v,
750
- index: I.value + M
825
+ ), ne = n(
826
+ () => e.items.slice(F.value, W.value).map((u, d) => ({
827
+ item: u,
828
+ index: F.value + d
751
829
  }))
752
- ), V = i(() => I.value * p.value), N = i(
753
- () => (e.items.length - w.value) * p.value
754
- ), K = i(() => ({
755
- height: Ve(e.height)
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)
756
834
  }));
757
- function ee(v) {
835
+ function R(u) {
758
836
  return e.items.length === 0 ? 0 : Math.min(
759
837
  e.items.length - 1,
760
- Math.max(0, Math.floor(Number.isFinite(v) ? v : 0))
838
+ Math.max(0, Math.floor(Number.isFinite(u) ? u : 0))
761
839
  );
762
840
  }
763
- function $() {
764
- if (!e.hasMore || e.loading || U === e.items.length)
841
+ function J() {
842
+ if (!e.hasMore || e.loading || A === e.items.length)
765
843
  return;
766
- (e.items.length === 0 ? 0 : e.items.length - 1 - r.value) <= L.value && (U = e.items.length, y("loadMore"));
844
+ (e.items.length === 0 ? 0 : e.items.length - 1 - o.value) <= k.value && (A = e.items.length, p("loadMore"));
767
845
  }
768
- function X(v) {
769
- const M = ee(v);
770
- M === r.value || e.items.length === 0 || (r.value = M, y("update:activeIndex", M), y("change", {
771
- index: M,
772
- item: e.items[M]
773
- }), M === 0 && y("reachStart"), M === e.items.length - 1 && y("reachEnd"), $());
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());
774
852
  }
775
- function B(v, M = {}) {
776
- const D = f.value;
777
- D && (typeof D.scrollTo == "function" ? D.scrollTo({ ...M, top: v }) : D.scrollTop = v);
853
+ function le(u, d = {}) {
854
+ const z = f.value;
855
+ z && (typeof z.scrollTo == "function" ? z.scrollTo({ ...d, top: u }) : z.scrollTop = u);
778
856
  }
779
- function q(v, M = {}) {
857
+ function se(u, d = {}) {
780
858
  if (e.items.length === 0) return;
781
- const D = ee(v);
782
- X(D), B(D * p.value, M);
783
- }
784
- function ae(v) {
785
- if (p.value <= 0) return;
786
- const M = v.currentTarget.scrollTop;
787
- X(Math.round(M / p.value));
788
- }
789
- function he(v) {
790
- let M;
791
- v.key === "ArrowDown" || v.key === "PageDown" ? M = r.value + 1 : v.key === "ArrowUp" || v.key === "PageUp" ? M = r.value - 1 : v.key === "Home" ? M = 0 : v.key === "End" && (M = e.items.length - 1), M !== void 0 && (v.preventDefault(), q(M, { behavior: "smooth" }));
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));
792
884
  }
793
- function oe() {
794
- var M;
795
- const v = ((M = f.value) == null ? void 0 : M.clientHeight) ?? 0;
796
- F(f.value, e.height), !(v <= 0 || v === S.value) && (S.value = v, O(() => {
797
- B(r.value * v);
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);
798
890
  }));
799
891
  }
800
- return le(
892
+ return ie(
801
893
  () => e.activeIndex,
802
- async (v) => {
803
- const M = ee(v);
804
- M !== r.value && (r.value = M, await O(), B(M * p.value), $());
894
+ async (u) => {
895
+ const d = R(u);
896
+ d !== o.value && (o.value = d, await C(), le(d * E.value), J());
805
897
  }
806
- ), le(
898
+ ), ie(
807
899
  () => [
808
900
  e.hasMore,
809
901
  e.loading,
810
902
  e.loadMoreThreshold
811
903
  ],
812
- async ([v]) => {
813
- v || (U = -1), await O(), $();
904
+ async ([u]) => {
905
+ u || (A = -1), await C(), J();
814
906
  }
815
- ), le(
907
+ ), ie(
816
908
  () => e.items.length,
817
909
  async () => {
818
- const v = ee(r.value);
819
- e.items.length === 0 ? r.value !== 0 && (r.value = 0, y("update:activeIndex", 0)) : X(v), await O(), B(v * p.value), $();
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();
820
912
  }
821
- ), ke(async () => {
822
- oe(), typeof ResizeObserver < "u" && f.value && (H = new ResizeObserver(oe), H.observe(f.value)), await O(), B(r.value * p.value), $();
823
- }), Le(() => {
824
- H && (H.disconnect(), H = void 0);
825
- }), _({
826
- scrollToIndex: q
827
- }), (v, M) => (x(), T("div", {
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", {
828
920
  ref_key: "viewport",
829
921
  ref: f,
830
922
  class: "vue-short-media-feed",
831
- style: C(K.value),
923
+ style: N(ae.value),
832
924
  role: "list",
833
925
  "aria-orientation": "vertical",
834
- "aria-label": a.ariaLabel,
926
+ "aria-label": l.ariaLabel,
835
927
  tabindex: "0",
836
- onScrollPassive: ae,
837
- onKeydown: he
928
+ onScrollPassive: me,
929
+ onWheel: we,
930
+ onKeydown: de
838
931
  }, [
839
- a.items.length ? (x(), T(ze, { key: 0 }, [
840
- V.value > 0 ? (x(), T("div", {
932
+ l.items.length ? (I(), $(Re, { key: 0 }, [
933
+ Z.value > 0 ? (I(), $("div", {
841
934
  key: 0,
842
935
  class: "vue-short-media-feed__spacer",
843
- style: C({ height: `${V.value}px` }),
936
+ style: N({ height: `${Z.value}px` }),
844
937
  "aria-hidden": "true"
845
- }, null, 4)) : xe("", !0),
846
- (x(!0), T(ze, null, Ee(A.value, ({ item: D, index: ve }) => (x(), T("div", {
847
- key: c(W)(D, ve),
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),
848
941
  class: "vue-short-media-feed__item",
849
- style: C({ height: `${p.value}px` }),
942
+ style: N({ height: `${E.value}px` }),
850
943
  role: "listitem",
851
- "aria-current": ve === r.value ? "true" : void 0,
852
- "aria-posinset": ve + 1,
853
- "aria-setsize": a.items.length
944
+ "aria-current": Q === o.value ? "true" : void 0,
945
+ "aria-posinset": Q + 1,
946
+ "aria-setsize": l.items.length
854
947
  }, [
855
- ie(v.$slots, "default", {
856
- item: D,
857
- index: ve,
858
- active: ve === r.value
948
+ ce(u.$slots, "default", {
949
+ item: z,
950
+ index: Q,
951
+ active: Q === o.value
859
952
  })
860
- ], 12, Xe))), 128)),
861
- N.value > 0 ? (x(), T("div", {
953
+ ], 12, dt))), 128)),
954
+ H.value > 0 ? (I(), $("div", {
862
955
  key: 1,
863
956
  class: "vue-short-media-feed__spacer",
864
- style: C({ height: `${N.value}px` }),
957
+ style: N({ height: `${H.value}px` }),
865
958
  "aria-hidden": "true"
866
- }, null, 4)) : xe("", !0)
867
- ], 64)) : (x(), T("div", et, [
868
- ie(v.$slots, "empty")
959
+ }, null, 4)) : ze("", !0)
960
+ ], 64)) : (I(), $("div", ft, [
961
+ ce(u.$slots, "empty")
869
962
  ]))
870
- ], 44, Qe));
963
+ ], 44, ct));
871
964
  }
872
- }), lt = ["aria-label"], at = /* @__PURE__ */ $e({
965
+ }), gt = ["aria-label"], pt = /* @__PURE__ */ Oe({
873
966
  __name: "SkeletonLoader",
874
967
  props: {
875
968
  width: { default: "100%" },
@@ -878,38 +971,38 @@ const qe = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Ne = /* @__PU
878
971
  animated: { type: Boolean, default: !0 },
879
972
  ariaLabel: { default: "Loading…" }
880
973
  },
881
- setup(a) {
882
- const _ = a;
883
- function E(y) {
884
- return typeof y == "number" ? `${Math.max(0, y)}px` : y;
885
- }
886
- const e = i(() => ({
887
- width: E(_.width),
888
- height: E(_.height)
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)
889
982
  }));
890
- return (y, f) => (x(), T("div", {
891
- class: Be(["vue-skeleton-loader", [
892
- `vue-skeleton-loader--${a.variant}`,
893
- { "vue-skeleton-loader--animated": a.animated }
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 }
894
987
  ]]),
895
- style: C(e.value),
988
+ style: N(e.value),
896
989
  role: "status",
897
- "aria-label": a.ariaLabel
898
- }, null, 14, lt));
990
+ "aria-label": l.ariaLabel
991
+ }, null, 14, gt));
899
992
  }
900
- }), ot = (a, _) => {
901
- const E = a.__vccOpts || a;
902
- for (const [e, y] of _)
903
- E[e] = y;
904
- return E;
905
- }, nt = /* @__PURE__ */ ot(at, [["__scopeId", "data-v-fc92f61f"]]), it = ["aria-label"], st = {
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 = {
906
999
  key: 0,
907
1000
  class: "vue-virtual-carousel__track",
908
1001
  role: "list"
909
- }, rt = ["aria-label", "aria-current"], ut = {
1002
+ }, Tt = ["aria-label", "aria-current"], bt = {
910
1003
  key: 1,
911
1004
  class: "vue-virtual-carousel__empty"
912
- }, ct = /* @__PURE__ */ $e({
1005
+ }, St = /* @__PURE__ */ Oe({
913
1006
  name: "VirtualCarousel",
914
1007
  __name: "VirtualCarousel",
915
1008
  props: {
@@ -932,307 +1025,307 @@ const qe = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Ne = /* @__PU
932
1025
  responsive: { default: void 0 }
933
1026
  },
934
1027
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
935
- setup(a, { expose: _, emit: E }) {
936
- const e = a, y = E, f = P(), S = P(0), r = P(0);
937
- let H, U = -1, F, W, Z = !1;
938
- const L = P(!1), { getItemKey: p } = He({
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({
939
1032
  componentName: "VirtualCarousel",
940
1033
  items: () => e.items,
941
1034
  itemKey: () => e.itemKey
942
- }), I = i(() => Math.max(0, S.value)), w = i(() => {
1035
+ }), w = n(() => Math.max(0, r.value)), k = n(() => {
943
1036
  if (!e.responsive || e.responsive.length === 0)
944
1037
  return {
945
1038
  slidesPerView: e.slidesPerView,
946
1039
  slidesToScroll: e.slidesToScroll,
947
1040
  gap: e.gap
948
1041
  };
949
- const l = I.value, o = [...e.responsive].sort(
950
- (h, k) => k.breakpoint - h.breakpoint
1042
+ const t = w.value, a = [...e.responsive].sort(
1043
+ (g, b) => b.breakpoint - g.breakpoint
951
1044
  );
952
- for (const h of o)
953
- if (l >= h.breakpoint)
1045
+ for (const g of a)
1046
+ if (t >= g.breakpoint)
954
1047
  return {
955
- slidesPerView: h.slidesPerView ?? e.slidesPerView,
956
- slidesToScroll: h.slidesToScroll ?? e.slidesToScroll,
957
- gap: h.gap ?? e.gap
1048
+ slidesPerView: g.slidesPerView ?? e.slidesPerView,
1049
+ slidesToScroll: g.slidesToScroll ?? e.slidesToScroll,
1050
+ gap: g.gap ?? e.gap
958
1051
  };
959
1052
  return {
960
1053
  slidesPerView: e.slidesPerView,
961
1054
  slidesToScroll: e.slidesToScroll,
962
1055
  gap: e.gap
963
1056
  };
964
- }), A = i(
1057
+ }), E = n(
965
1058
  () => Math.max(
966
1059
  1,
967
1060
  Math.floor(
968
- Number.isFinite(w.value.slidesPerView) ? w.value.slidesPerView : 1
1061
+ Number.isFinite(k.value.slidesPerView) ? k.value.slidesPerView : 1
969
1062
  )
970
1063
  )
971
- ), V = i(
1064
+ ), F = n(
972
1065
  () => Math.max(
973
1066
  1,
974
1067
  Math.floor(
975
- Number.isFinite(w.value.slidesToScroll) ? w.value.slidesToScroll : 1
1068
+ Number.isFinite(k.value.slidesToScroll) ? k.value.slidesToScroll : 1
976
1069
  )
977
1070
  )
978
- ), N = i(
979
- () => Math.max(0, Number.isFinite(w.value.gap) ? w.value.gap : 0)
980
- ), K = i(
1071
+ ), W = n(
1072
+ () => Math.max(0, Number.isFinite(k.value.gap) ? k.value.gap : 0)
1073
+ ), ne = n(
981
1074
  () => Math.max(
982
1075
  0,
983
1076
  Math.floor(Number.isFinite(e.buffer) ? e.buffer : 0)
984
1077
  )
985
- ), ee = i(
1078
+ ), Z = n(
986
1079
  () => Math.max(
987
1080
  0,
988
1081
  Math.floor(
989
1082
  Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
990
1083
  )
991
1084
  )
992
- ), $ = i(() => Number.isFinite(e.autoplayDelay) ? Math.max(1, e.autoplayDelay) : 3e3), X = i(() => {
993
- if (I.value <= 0) return 0;
994
- const l = (A.value - 1) * N.value;
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;
995
1088
  return Math.max(
996
1089
  1,
997
- (I.value - l) / A.value
1090
+ (w.value - t) / E.value
998
1091
  );
999
- }), B = i(() => X.value + N.value), q = i(
1092
+ }), R = n(() => ae.value + W.value), J = n(
1000
1093
  () => Math.max(
1001
1094
  0,
1002
- e.items.length - A.value
1095
+ e.items.length - E.value
1003
1096
  )
1004
- ), ae = i(
1005
- () => Math.max(0, r.value - K.value)
1006
- ), he = i(
1097
+ ), Y = n(
1098
+ () => Math.max(0, o.value - ne.value)
1099
+ ), le = n(
1007
1100
  () => Math.min(
1008
1101
  e.items.length,
1009
- r.value + A.value + K.value
1102
+ o.value + E.value + ne.value
1010
1103
  )
1011
- ), oe = i(
1012
- () => e.items.slice(ae.value, he.value).map((l, o) => ({
1013
- item: l,
1014
- index: ae.value + o
1104
+ ), se = n(
1105
+ () => e.items.slice(Y.value, le.value).map((t, a) => ({
1106
+ item: t,
1107
+ index: Y.value + a
1015
1108
  }))
1016
- ), v = i(() => e.items.length === 0 ? 0 : e.items.length * X.value + (e.items.length - 1) * N.value), M = i(
1017
- () => ae.value * B.value
1018
- ), D = i(
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(
1019
1112
  () => Math.max(
1020
1113
  0,
1021
- v.value - he.value * B.value
1114
+ me.value - le.value * R.value
1022
1115
  )
1023
- ), ve = i(() => ({
1024
- height: Ve(e.height)
1116
+ ), we = n(() => ({
1117
+ height: Fe(e.height)
1025
1118
  }));
1026
- function te(l) {
1119
+ function G(t) {
1027
1120
  return Math.min(
1028
- q.value,
1029
- Math.max(0, Math.floor(Number.isFinite(l) ? l : 0))
1121
+ J.value,
1122
+ Math.max(0, Math.floor(Number.isFinite(t) ? t : 0))
1030
1123
  );
1031
1124
  }
1032
- r.value = te(e.activeIndex);
1033
- function ye(l) {
1034
- return l >= r.value && l < Math.min(
1125
+ o.value = G(e.activeIndex);
1126
+ function u(t) {
1127
+ return t >= o.value && t < Math.min(
1035
1128
  e.items.length,
1036
- r.value + A.value
1129
+ o.value + E.value
1037
1130
  );
1038
1131
  }
1039
- function ne() {
1040
- if (!e.hasMore || e.loading || U === e.items.length)
1132
+ function d() {
1133
+ if (!e.hasMore || e.loading || A === e.items.length)
1041
1134
  return;
1042
- const l = e.items.length === 0 ? -1 : Math.min(
1135
+ const t = e.items.length === 0 ? -1 : Math.min(
1043
1136
  e.items.length - 1,
1044
- r.value + A.value - 1
1137
+ o.value + E.value - 1
1045
1138
  );
1046
- e.items.length - 1 - l <= ee.value && (U = e.items.length, y("loadMore"));
1139
+ e.items.length - 1 - t <= Z.value && (A = e.items.length, p("loadMore"));
1047
1140
  }
1048
- function fe(l) {
1049
- const o = te(l);
1050
- o === r.value || e.items.length === 0 || (r.value = o, y("update:activeIndex", o), y("change", {
1051
- index: o,
1052
- item: e.items[o]
1053
- }), o === 0 && y("reachStart"), o === q.value && y("reachEnd"), ne(), e.autoplay && !L.value && z());
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());
1054
1147
  }
1055
- function J(l, o = {}) {
1056
- const h = f.value;
1057
- h && (typeof h.scrollTo == "function" ? h.scrollTo({ ...o, left: l }) : h.scrollLeft = l);
1058
- }
1059
- function me(l, o = {}) {
1060
- if (e.items.length === 0 || B.value <= 0) return;
1061
- const h = te(l);
1062
- W = o.behavior === "smooth" ? h : void 0, fe(h), J(h * B.value, {
1063
- ...o,
1064
- behavior: o.behavior
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
1065
1158
  });
1066
1159
  }
1067
- function m(l = "smooth") {
1068
- me(
1069
- r.value + V.value,
1070
- { behavior: l }
1160
+ function y(t = "smooth") {
1161
+ he(
1162
+ o.value + F.value,
1163
+ { behavior: t }
1071
1164
  );
1072
1165
  }
1073
- function b(l = "smooth") {
1074
- me(
1075
- r.value - V.value,
1076
- { behavior: l }
1166
+ function L(t = "smooth") {
1167
+ he(
1168
+ o.value - F.value,
1169
+ { behavior: t }
1077
1170
  );
1078
1171
  }
1079
- function z() {
1080
- G(), !(!e.autoplay || e.items.length === 0) && (F = setTimeout(() => {
1081
- r.value >= q.value ? e.autoplayLoop ? me(0, { behavior: "smooth" }) : G() : m("smooth");
1082
- }, $.value));
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));
1083
1176
  }
1084
- function G() {
1085
- F !== void 0 && (clearTimeout(F), F = void 0);
1177
+ function te() {
1178
+ O !== void 0 && (clearTimeout(O), O = void 0);
1086
1179
  }
1087
- function Me() {
1088
- L.value = !0, e.pauseOnHover && G();
1180
+ function oe() {
1181
+ V.value = !0, e.pauseOnHover && te();
1089
1182
  }
1090
- function se() {
1091
- L.value = !1, e.autoplay && z();
1183
+ function re() {
1184
+ V.value = !1, e.autoplay && B();
1092
1185
  }
1093
- function ue() {
1094
- W = void 0;
1186
+ function ye() {
1187
+ U = void 0;
1095
1188
  }
1096
- function Y(l) {
1097
- if (B.value <= 0 || Z) return;
1098
- const o = l.currentTarget.scrollLeft;
1099
- if (W !== void 0) {
1100
- const h = W * B.value;
1101
- if (Math.abs(o - h) > 1) return;
1102
- W = void 0;
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;
1103
1196
  }
1104
- fe(Math.round(o / B.value));
1197
+ z(Math.round(a / R.value));
1105
1198
  }
1106
- function j(l) {
1107
- l.key === "ArrowRight" || l.key === "PageDown" ? (l.preventDefault(), m()) : l.key === "ArrowLeft" || l.key === "PageUp" ? (l.preventDefault(), b()) : l.key === "Home" ? (l.preventDefault(), me(0, { behavior: "smooth" })) : l.key === "End" && (l.preventDefault(), me(q.value, { behavior: "auto" }));
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" }));
1108
1201
  }
1109
1202
  function s() {
1110
- var o;
1111
- const l = ((o = f.value) == null ? void 0 : o.clientWidth) ?? 0;
1112
- l <= 0 || l === S.value || (Z = !0, S.value = l, O(() => {
1113
- const h = te(r.value);
1114
- J(h * B.value), Z = !1;
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;
1115
1208
  }));
1116
1209
  }
1117
- return le(
1210
+ return ie(
1118
1211
  () => e.activeIndex,
1119
- async (l) => {
1120
- const o = te(l);
1121
- o !== r.value && (ue(), r.value = o, await O(), J(o * B.value), ne());
1212
+ async (t) => {
1213
+ const a = G(t);
1214
+ a !== o.value && (ye(), o.value = a, await C(), Q(a * R.value), d());
1122
1215
  }
1123
- ), le(
1216
+ ), ie(
1124
1217
  () => [
1125
1218
  e.items.length,
1126
- w.value.slidesPerView,
1127
- w.value.gap,
1128
- w.value.slidesToScroll
1219
+ k.value.slidesPerView,
1220
+ k.value.gap,
1221
+ k.value.slidesToScroll
1129
1222
  ],
1130
1223
  async () => {
1131
- const l = te(r.value);
1132
- e.items.length === 0 ? r.value !== 0 && (r.value = 0, y("update:activeIndex", 0)) : fe(l), await O(), J(l * B.value), ne(), e.autoplay && e.items.length > 0 && !L.value && z();
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();
1133
1226
  }
1134
- ), le(
1227
+ ), ie(
1135
1228
  () => e.responsive,
1136
1229
  () => {
1137
- O(() => {
1138
- const l = te(r.value);
1139
- J(l * B.value);
1230
+ C(() => {
1231
+ const t = G(o.value);
1232
+ Q(t * R.value);
1140
1233
  });
1141
1234
  },
1142
1235
  { deep: !0 }
1143
- ), le(
1236
+ ), ie(
1144
1237
  () => [
1145
1238
  e.hasMore,
1146
1239
  e.loading,
1147
1240
  e.loadMoreThreshold
1148
1241
  ],
1149
- async ([l]) => {
1150
- l || (U = -1), await O(), ne();
1242
+ async ([t]) => {
1243
+ t || (A = -1), await C(), d();
1151
1244
  }
1152
- ), le(
1245
+ ), ie(
1153
1246
  () => e.autoplay,
1154
- (l) => {
1155
- l && !L.value ? z() : G();
1247
+ (t) => {
1248
+ t && !V.value ? B() : te();
1156
1249
  }
1157
- ), le(
1250
+ ), ie(
1158
1251
  () => e.autoplayDelay,
1159
1252
  () => {
1160
- e.autoplay && !L.value && z();
1253
+ e.autoplay && !V.value && B();
1161
1254
  }
1162
- ), le(
1255
+ ), ie(
1163
1256
  () => e.autoplayLoop,
1164
- (l) => {
1165
- !e.autoplay || L.value || (!l && r.value >= q.value ? G() : z());
1257
+ (t) => {
1258
+ !e.autoplay || V.value || (!t && o.value >= J.value ? te() : B());
1166
1259
  }
1167
- ), le(
1260
+ ), ie(
1168
1261
  () => e.pauseOnHover,
1169
- (l) => {
1170
- l && L.value ? G() : !l && e.autoplay && z();
1262
+ (t) => {
1263
+ t && V.value ? te() : !t && e.autoplay && B();
1171
1264
  }
1172
- ), ke(async () => {
1173
- s(), typeof ResizeObserver < "u" && f.value && (H = new ResizeObserver(s), H.observe(f.value)), await O(), J(r.value * B.value), ne(), e.autoplay && z();
1174
- }), Le(() => {
1175
- H && (H.disconnect(), H = void 0), G();
1176
- }), _({
1177
- next: m,
1178
- previous: b,
1179
- scrollToIndex: me,
1180
- startAutoplay: z,
1181
- stopAutoplay: G
1182
- }), (l, o) => (x(), T("div", {
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", {
1183
1276
  ref_key: "viewport",
1184
1277
  ref: f,
1185
1278
  class: "vue-virtual-carousel",
1186
- style: C(ve.value),
1279
+ style: N(we.value),
1187
1280
  role: "region",
1188
1281
  "aria-roledescription": "carousel",
1189
- "aria-label": a.ariaLabel,
1282
+ "aria-label": l.ariaLabel,
1190
1283
  tabindex: "0",
1191
- onScrollPassive: Y,
1192
- onPointerdown: ue,
1193
- onWheelPassive: ue,
1194
- onKeydown: j,
1195
- onMouseenter: Me,
1196
- onMouseleave: se
1284
+ onScrollPassive: _,
1285
+ onPointerdown: ye,
1286
+ onWheelPassive: ye,
1287
+ onKeydown: ee,
1288
+ onMouseenter: oe,
1289
+ onMouseleave: re
1197
1290
  }, [
1198
- a.items.length ? (x(), T("div", st, [
1199
- M.value > 0 ? (x(), T("div", {
1291
+ l.items.length ? (I(), $("div", wt, [
1292
+ de.value > 0 ? (I(), $("div", {
1200
1293
  key: 0,
1201
1294
  class: "vue-virtual-carousel__spacer",
1202
- style: C({ flexBasis: `${M.value}px` }),
1295
+ style: N({ flexBasis: `${de.value}px` }),
1203
1296
  "aria-hidden": "true"
1204
- }, null, 4)) : xe("", !0),
1205
- (x(!0), T(ze, null, Ee(oe.value, ({ item: h, index: k }) => (x(), T("div", {
1206
- key: c(p)(h, k),
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),
1207
1300
  class: "vue-virtual-carousel__item",
1208
- style: C({
1209
- flexBasis: `${X.value}px`,
1210
- marginRight: k < a.items.length - 1 ? `${N.value}px` : "0px"
1301
+ style: N({
1302
+ flexBasis: `${ae.value}px`,
1303
+ marginRight: b < l.items.length - 1 ? `${W.value}px` : "0px"
1211
1304
  }),
1212
1305
  role: "listitem",
1213
1306
  "aria-roledescription": "slide",
1214
- "aria-label": `${k + 1} of ${a.items.length}`,
1215
- "aria-current": k === r.value ? "true" : void 0
1307
+ "aria-label": `${b + 1} of ${l.items.length}`,
1308
+ "aria-current": b === o.value ? "true" : void 0
1216
1309
  }, [
1217
- ie(l.$slots, "default", {
1218
- item: h,
1219
- index: k,
1220
- active: k === r.value,
1221
- visible: ye(k)
1310
+ ce(t.$slots, "default", {
1311
+ item: g,
1312
+ index: b,
1313
+ active: b === o.value,
1314
+ visible: u(b)
1222
1315
  })
1223
- ], 12, rt))), 128)),
1224
- D.value > 0 ? (x(), T("div", {
1316
+ ], 12, Tt))), 128)),
1317
+ ue.value > 0 ? (I(), $("div", {
1225
1318
  key: 1,
1226
1319
  class: "vue-virtual-carousel__spacer",
1227
- style: C({ flexBasis: `${D.value}px` }),
1320
+ style: N({ flexBasis: `${ue.value}px` }),
1228
1321
  "aria-hidden": "true"
1229
- }, null, 4)) : xe("", !0)
1230
- ])) : (x(), T("div", ut, [
1231
- ie(l.$slots, "empty")
1322
+ }, null, 4)) : ze("", !0)
1323
+ ])) : (I(), $("div", bt, [
1324
+ ce(t.$slots, "empty")
1232
1325
  ]))
1233
- ], 44, it));
1326
+ ], 44, xt));
1234
1327
  }
1235
- }), dt = ["aria-label"], vt = ["aria-posinset", "aria-setsize"], ft = /* @__PURE__ */ $e({
1328
+ }), zt = ["aria-label"], It = ["aria-posinset", "aria-setsize"], $t = /* @__PURE__ */ Oe({
1236
1329
  name: "VirtualScroll",
1237
1330
  __name: "VirtualScroll",
1238
1331
  props: {
@@ -1251,210 +1344,210 @@ const qe = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Ne = /* @__PU
1251
1344
  pullRefreshThreshold: { default: 64 }
1252
1345
  },
1253
1346
  emits: ["scroll", "loadMore", "refresh"],
1254
- setup(a, { expose: _, emit: E }) {
1255
- const e = a, y = E, {
1347
+ setup(l, { expose: P, emit: x }) {
1348
+ const e = l, p = x, {
1256
1349
  pulling: f,
1257
- pullDistance: S,
1258
- pullOffset: r,
1259
- pullProgress: H,
1260
- refreshMessage: U,
1261
- refreshThreshold: F,
1262
- handleTouchStart: W,
1263
- handleTouchMove: Z,
1264
- handleTouchEnd: L,
1265
- handleTouchCancel: p
1266
- } = Ke({
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({
1267
1360
  enabled: () => e.pullToRefresh,
1268
1361
  refreshing: () => e.refreshing,
1269
1362
  threshold: () => e.pullRefreshThreshold,
1270
- onRefresh: () => y("refresh")
1271
- }), I = P(), w = P(0), A = P(0);
1272
- let V, N = -1;
1273
- const K = Ce(), { getItemKey: ee } = He({
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({
1274
1367
  componentName: "VirtualScroll",
1275
1368
  items: () => e.items,
1276
1369
  itemKey: () => e.itemKey
1277
- }), $ = i(() => Math.max(1, e.itemSize)), X = i(() => Math.max(0, Math.floor(e.overscan))), B = i(
1278
- () => e.items.length * $.value
1279
- ), q = i(
1280
- () => Math.max(1, e.loadingItemSize ?? $.value)
1281
- ), ae = i(
1282
- () => B.value + (e.loading ? q.value : 0)
1283
- ), he = i(() => A.value > 0 ? A.value : typeof e.height == "number" ? e.height : 0), oe = i(
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(
1284
1377
  () => Math.max(
1285
1378
  0,
1286
- Math.floor(w.value / $.value) - X.value
1379
+ Math.floor(k.value / H.value) - ae.value
1287
1380
  )
1288
- ), v = i(() => {
1289
- const m = Math.ceil(
1290
- (w.value + he.value) / $.value
1381
+ ), me = n(() => {
1382
+ const y = Math.ceil(
1383
+ (k.value + le.value) / H.value
1291
1384
  );
1292
1385
  return Math.min(
1293
1386
  e.items.length,
1294
- m + X.value
1387
+ y + ae.value
1295
1388
  );
1296
- }), M = i(
1297
- () => e.items.slice(oe.value, v.value).map((m, b) => ({
1298
- item: m,
1299
- index: oe.value + b
1389
+ }), de = n(
1390
+ () => e.items.slice(se.value, me.value).map((y, L) => ({
1391
+ item: y,
1392
+ index: se.value + L
1300
1393
  }))
1301
- ), D = i(() => ({
1302
- height: Ve(e.height)
1303
- })), ve = i(() => ({
1304
- transform: `translateY(${oe.value * $.value}px)`
1394
+ ), ue = n(() => ({
1395
+ height: Fe(e.height)
1396
+ })), we = n(() => ({
1397
+ transform: `translateY(${se.value * H.value}px)`
1305
1398
  }));
1306
- function te() {
1307
- var m;
1308
- A.value = ((m = I.value) == null ? void 0 : m.clientHeight) ?? 0, K(I.value, e.height), O(ne);
1309
- }
1310
- function ye(m) {
1311
- w.value = m.currentTarget.scrollTop, y("scroll", {
1312
- scrollTop: w.value,
1313
- startIndex: oe.value,
1314
- endIndex: v.value
1315
- }), ne();
1316
- }
1317
- function ne() {
1318
- const m = I.value;
1319
- if (!m || !e.hasMore || e.loading || N === e.items.length)
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)
1320
1413
  return;
1321
- const b = Math.max(0, e.loadMoreThreshold);
1322
- ae.value - m.scrollTop - m.clientHeight <= b && (N = e.items.length, y("loadMore"));
1323
- }
1324
- function fe(m, b = {}) {
1325
- const z = I.value;
1326
- if (!z) return;
1327
- const G = Math.max(0, ae.value - z.clientHeight), Me = Math.min(
1328
- Math.max(0, Number.isFinite(m) ? m : 0),
1329
- G
1330
- ), se = b.behavior ?? "auto";
1331
- se === "auto" && (w.value = Me), z.scrollTo({ ...b, top: Me, behavior: se });
1332
- }
1333
- function J(m, b = {}) {
1334
- const z = I.value;
1335
- if (!z || e.items.length === 0) return;
1336
- const G = Math.min(
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(
1337
1430
  e.items.length - 1,
1338
- Math.max(0, Math.floor(m))
1339
- ), { align: Me = "start", ...se } = b;
1340
- let ue = G * $.value;
1341
- Me === "center" ? ue -= (z.clientHeight - $.value) / 2 : Me === "end" && (ue -= z.clientHeight - $.value), z.scrollTo({
1342
- ...se,
1343
- top: Math.max(0, Math.min(ue, ae.value - z.clientHeight))
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))
1344
1437
  });
1345
1438
  }
1346
- function me(m = "auto") {
1347
- var b;
1348
- (b = I.value) == null || b.scrollTo({ top: 0, behavior: m });
1439
+ function he(y = "auto") {
1440
+ var L;
1441
+ (L = w.value) == null || L.scrollTo({ top: 0, behavior: y });
1349
1442
  }
1350
- return le(
1443
+ return ie(
1351
1444
  () => [e.items.length, e.itemSize],
1352
1445
  async () => {
1353
- await O();
1354
- const m = I.value;
1355
- if (!m) return;
1356
- const b = Math.max(0, ae.value - m.clientHeight);
1357
- m.scrollTop > b && (m.scrollTop = b, w.value = b), ne();
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();
1358
1451
  }
1359
- ), le(
1452
+ ), ie(
1360
1453
  () => [e.hasMore, e.loading],
1361
- async ([m]) => {
1362
- m || (N = -1), await O(), ne();
1454
+ async ([y]) => {
1455
+ y || (W = -1), await C(), d();
1363
1456
  }
1364
- ), ke(() => {
1365
- te(), typeof ResizeObserver < "u" && I.value && (V = new ResizeObserver(te), V.observe(I.value)), O(ne);
1366
- }), Le(() => {
1367
- V && (V.disconnect(), V = void 0);
1368
- }), _({
1369
- scrollTo: fe,
1370
- scrollToIndex: J,
1371
- scrollToTop: me
1372
- }), (m, b) => (x(), T("div", {
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", {
1373
1466
  ref_key: "viewport",
1374
- ref: I,
1375
- class: Be(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": c(f) }]),
1376
- style: C(D.value),
1467
+ ref: w,
1468
+ class: Ye(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": c(f) }]),
1469
+ style: N(ue.value),
1377
1470
  role: "list",
1378
- "aria-label": a.ariaLabel,
1471
+ "aria-label": l.ariaLabel,
1379
1472
  tabindex: "0",
1380
- onScrollPassive: ye,
1381
- onTouchstartPassive: b[0] || (b[0] = //@ts-ignore
1382
- (...z) => c(W) && c(W)(...z)),
1383
- onTouchmove: b[1] || (b[1] = //@ts-ignore
1384
- (...z) => c(Z) && c(Z)(...z)),
1385
- onTouchend: b[2] || (b[2] = //@ts-ignore
1386
- (...z) => c(L) && c(L)(...z)),
1387
- onTouchcancel: b[3] || (b[3] = //@ts-ignore
1388
- (...z) => c(p) && c(p)(...z))
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))
1389
1482
  }, [
1390
- a.pullToRefresh || a.refreshing ? (x(), T("div", {
1483
+ l.pullToRefresh || l.refreshing ? (I(), $("div", {
1391
1484
  key: 0,
1392
1485
  class: "vue-virtual-scroll__refresh",
1393
- style: C({
1394
- height: `${c(F)}px`,
1395
- transform: `translateY(${c(r) - c(F)}px)`
1486
+ style: N({
1487
+ height: `${c(O)}px`,
1488
+ transform: `translateY(${c(o) - c(O)}px)`
1396
1489
  }),
1397
1490
  role: "status",
1398
1491
  "aria-live": "polite"
1399
1492
  }, [
1400
- ie(m.$slots, "refresh", {
1401
- pullDistance: c(S),
1402
- progress: c(H),
1403
- refreshing: a.refreshing
1493
+ ce(y.$slots, "refresh", {
1494
+ pullDistance: c(r),
1495
+ progress: c(m),
1496
+ refreshing: l.refreshing
1404
1497
  }, () => [
1405
- Ie(Oe(c(U)), 1)
1498
+ Ve(je(c(A)), 1)
1406
1499
  ])
1407
- ], 4)) : xe("", !0),
1408
- a.items.length || a.loading ? (x(), T("div", {
1500
+ ], 4)) : ze("", !0),
1501
+ l.items.length || l.loading ? (I(), $("div", {
1409
1502
  key: 1,
1410
1503
  class: "vue-virtual-scroll__spacer",
1411
- style: C({
1412
- height: `${ae.value}px`,
1413
- transform: `translateY(${c(r)}px)`
1504
+ style: N({
1505
+ height: `${Y.value}px`,
1506
+ transform: `translateY(${c(o)}px)`
1414
1507
  })
1415
1508
  }, [
1416
- De("div", {
1509
+ Ge("div", {
1417
1510
  class: "vue-virtual-scroll__content",
1418
- style: C(ve.value)
1511
+ style: N(we.value)
1419
1512
  }, [
1420
- (x(!0), T(ze, null, Ee(M.value, ({ item: z, index: G }) => (x(), T("div", {
1421
- key: c(ee)(z, G),
1513
+ (I(!0), $(Re, null, De(de.value, ({ item: B, index: te }) => (I(), $("div", {
1514
+ key: c(Z)(B, te),
1422
1515
  class: "vue-virtual-scroll__item",
1423
- style: C({ height: `${$.value}px` }),
1516
+ style: N({ height: `${H.value}px` }),
1424
1517
  role: "listitem",
1425
- "aria-posinset": G + 1,
1426
- "aria-setsize": a.items.length
1518
+ "aria-posinset": te + 1,
1519
+ "aria-setsize": l.items.length
1427
1520
  }, [
1428
- ie(m.$slots, "default", {
1429
- item: z,
1430
- index: G
1521
+ ce(y.$slots, "default", {
1522
+ item: B,
1523
+ index: te
1431
1524
  })
1432
- ], 12, vt))), 128))
1525
+ ], 12, It))), 128))
1433
1526
  ], 4),
1434
- a.loading ? (x(), T("div", {
1527
+ l.loading ? (I(), $("div", {
1435
1528
  key: 0,
1436
1529
  class: "vue-virtual-scroll__loading",
1437
- style: C({
1438
- height: `${q.value}px`,
1439
- transform: `translateY(${B.value}px)`
1530
+ style: N({
1531
+ height: `${J.value}px`,
1532
+ transform: `translateY(${R.value}px)`
1440
1533
  }),
1441
1534
  role: "status",
1442
1535
  "aria-live": "polite"
1443
1536
  }, [
1444
- ie(m.$slots, "loading", {}, () => [
1445
- b[4] || (b[4] = Ie("Loading more…", -1))
1537
+ ce(y.$slots, "loading", {}, () => [
1538
+ L[4] || (L[4] = Ve("Loading more…", -1))
1446
1539
  ])
1447
- ], 4)) : xe("", !0)
1448
- ], 4)) : (x(), T("div", {
1540
+ ], 4)) : ze("", !0)
1541
+ ], 4)) : (I(), $("div", {
1449
1542
  key: 2,
1450
1543
  class: "vue-virtual-scroll__empty",
1451
- style: C({ transform: `translateY(${c(r)}px)` })
1544
+ style: N({ transform: `translateY(${c(o)}px)` })
1452
1545
  }, [
1453
- ie(m.$slots, "empty")
1546
+ ce(y.$slots, "empty")
1454
1547
  ], 4))
1455
- ], 46, dt));
1548
+ ], 46, zt));
1456
1549
  }
1457
- }), ht = ["aria-label"], mt = ["aria-posinset", "aria-setsize"], gt = /* @__PURE__ */ $e({
1550
+ }), kt = ["aria-label"], Et = ["aria-posinset", "aria-setsize"], Lt = /* @__PURE__ */ Oe({
1458
1551
  name: "WindowDynamicVirtualScroll",
1459
1552
  __name: "WindowDynamicVirtualScroll",
1460
1553
  props: {
@@ -1472,329 +1565,329 @@ const qe = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Ne = /* @__PU
1472
1565
  pullRefreshThreshold: { default: 64 }
1473
1566
  },
1474
1567
  emits: ["scroll", "loadMore", "refresh"],
1475
- setup(a, { expose: _, emit: E }) {
1476
- const e = a, y = E, f = P(), S = P(0), r = P(0), H = P(0), U = P(0), F = /* @__PURE__ */ new Map(), W = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map();
1477
- let L, p, I, w, A = !1, V = !1, N = -1;
1478
- const { getItemKey: K } = He({
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({
1479
1572
  componentName: "WindowDynamicVirtualScroll",
1480
1573
  items: () => e.items,
1481
1574
  itemKey: () => e.itemKey
1482
1575
  });
1483
- function ee(d) {
1576
+ function Z(v) {
1484
1577
  return typeof window.requestAnimationFrame == "function" ? {
1485
- id: window.requestAnimationFrame(d),
1578
+ id: window.requestAnimationFrame(v),
1486
1579
  type: "animation"
1487
1580
  } : {
1488
- id: window.setTimeout(d, 0),
1581
+ id: window.setTimeout(v, 0),
1489
1582
  type: "timeout"
1490
1583
  };
1491
1584
  }
1492
- function $(d) {
1493
- d && (d.type === "animation" ? window.cancelAnimationFrame(d.id) : window.clearTimeout(d.id));
1585
+ function H(v) {
1586
+ v && (v.type === "animation" ? window.cancelAnimationFrame(v.id) : window.clearTimeout(v.id));
1494
1587
  }
1495
1588
  const {
1496
- pulling: X,
1497
- pullDistance: B,
1498
- pullOffset: q,
1499
- pullProgress: ae,
1500
- refreshMessage: he,
1501
- refreshThreshold: oe,
1502
- handleTouchStart: v,
1503
- handleTouchMove: M,
1504
- handleTouchEnd: D,
1505
- handleTouchCancel: ve
1506
- } = Ke({
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({
1507
1600
  enabled: () => e.pullToRefresh,
1508
1601
  refreshing: () => e.refreshing,
1509
1602
  threshold: () => e.pullRefreshThreshold,
1510
- onRefresh: () => y("refresh"),
1603
+ onRefresh: () => p("refresh"),
1511
1604
  scrollTop: () => typeof window > "u" ? 0 : Math.max(0, window.scrollY)
1512
- }), te = i(
1605
+ }), G = n(
1513
1606
  () => Math.max(1, e.estimatedItemSize)
1514
- ), ye = i(
1515
- () => Math.max(1, e.loadingItemSize ?? te.value)
1516
- ), ne = i(() => Math.max(0, Math.floor(e.overscan))), fe = i(() => {
1517
- U.value;
1518
- const d = new Array(e.items.length + 1), t = new Array(e.items.length);
1519
- d[0] = 0;
1520
- for (let n = 0; n < e.items.length; n += 1) {
1521
- const u = K(e.items[n], n), g = F.get(u) ?? te.value;
1522
- t[n] = g, d[n + 1] = d[n] + g;
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;
1523
1616
  }
1524
1617
  return {
1525
- offsets: d,
1526
- sizes: t,
1527
- total: d[e.items.length] ?? 0
1618
+ offsets: v,
1619
+ sizes: S,
1620
+ total: v[e.items.length] ?? 0
1528
1621
  };
1529
- }), J = i(
1530
- () => fe.value.total + (e.loading ? ye.value : 0)
1531
- ), me = i(() => {
1532
- const d = /* @__PURE__ */ new Map();
1533
- return e.items.forEach((t, n) => {
1534
- d.set(K(t, n), n);
1535
- }), d;
1536
- }), m = i(
1537
- () => Math.max(0, S.value - H.value)
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)
1538
1631
  );
1539
- function b(d) {
1632
+ function L(v) {
1540
1633
  if (e.items.length === 0) return 0;
1541
- const t = fe.value.offsets;
1542
- let n = 0, u = e.items.length;
1543
- for (; n < u; ) {
1544
- const g = Math.floor((n + u) / 2);
1545
- t[g + 1] <= d ? n = g + 1 : u = g;
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;
1546
1639
  }
1547
- return Math.min(n, e.items.length - 1);
1640
+ return Math.min(T, e.items.length - 1);
1548
1641
  }
1549
- const z = i(
1642
+ const B = n(
1550
1643
  () => Math.max(
1551
1644
  0,
1552
- b(m.value) - ne.value
1645
+ L(y.value) - d.value
1553
1646
  )
1554
- ), G = i(() => {
1647
+ ), te = n(() => {
1555
1648
  if (e.items.length === 0) return 0;
1556
- const d = S.value + r.value - H.value, t = Math.max(
1557
- te.value,
1558
- d
1559
- ), n = b(t) + 1;
1649
+ const v = r.value + o.value - m.value, S = Math.max(
1650
+ G.value,
1651
+ v
1652
+ ), T = L(S) + 1;
1560
1653
  return Math.min(
1561
1654
  e.items.length,
1562
- n + ne.value
1655
+ T + d.value
1563
1656
  );
1564
- }), Me = i(
1565
- () => e.items.slice(z.value, G.value).map((d, t) => {
1566
- const n = z.value + t;
1657
+ }), oe = n(
1658
+ () => e.items.slice(B.value, te.value).map((v, S) => {
1659
+ const T = B.value + S;
1567
1660
  return {
1568
- item: d,
1569
- index: n,
1570
- key: K(d, n),
1571
- top: fe.value.offsets[n]
1661
+ item: v,
1662
+ index: T,
1663
+ key: ne(v, T),
1664
+ top: z.value.offsets[T]
1572
1665
  };
1573
1666
  })
1574
1667
  );
1575
- function se() {
1576
- typeof window > "u" || (S.value = Math.max(0, window.scrollY), r.value = window.innerHeight, f.value && (H.value = f.value.getBoundingClientRect().top + S.value));
1577
- }
1578
- function ue() {
1579
- y("scroll", {
1580
- scrollTop: m.value,
1581
- startIndex: z.value,
1582
- endIndex: G.value
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));
1670
+ }
1671
+ function ye() {
1672
+ p("scroll", {
1673
+ scrollTop: y.value,
1674
+ startIndex: B.value,
1675
+ endIndex: te.value
1583
1676
  });
1584
1677
  }
1585
- function Y(d = !1) {
1586
- V && (A || (A = d), !I && (I = ee(() => {
1587
- I = void 0, se(), A && (A = !1, ue()), l();
1678
+ function _(v = !1) {
1679
+ F && (E || (E = v), !w && (w = Z(() => {
1680
+ w = void 0, re(), E && (E = !1, ye()), t();
1588
1681
  })));
1589
1682
  }
1590
- function j() {
1591
- Y(!0);
1683
+ function ee() {
1684
+ _(!0);
1592
1685
  }
1593
1686
  function s() {
1594
- Y();
1687
+ _();
1595
1688
  }
1596
- function l() {
1597
- if (typeof window > "u" || !e.hasMore || e.loading || N === e.items.length)
1689
+ function t() {
1690
+ if (typeof window > "u" || !e.hasMore || e.loading || W === e.items.length)
1598
1691
  return;
1599
- const d = Math.max(0, e.loadMoreThreshold), t = H.value + J.value, n = S.value + r.value;
1600
- t - n <= d && (N = e.items.length, y("loadMore"));
1601
- }
1602
- function o(d) {
1603
- const t = d.borderBoxSize;
1604
- if (t) {
1605
- const n = Array.isArray(t) ? t[0] : t;
1606
- if (n != null && n.blockSize) return n.blockSize;
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;
1607
1700
  }
1608
- return d.contentRect.height;
1609
- }
1610
- function h(d) {
1611
- const t = fe.value;
1612
- let n = 0, u = !1;
1613
- for (const g of d) {
1614
- const R = g.target, Q = W.get(R), re = o(g);
1615
- if (Q === void 0 || re <= 0) continue;
1616
- const ce = F.get(Q) ?? te.value;
1617
- if (Math.abs(ce - re) < 0.5) continue;
1618
- const de = me.value.get(Q);
1619
- de !== void 0 && t.offsets[de + 1] <= m.value && (n += re - ce), F.set(Q, re), u = !0;
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;
1620
1713
  }
1621
- u && (U.value += 1, O(() => {
1622
- if (V) {
1623
- if (n !== 0 && typeof window < "u") {
1624
- const g = Math.max(
1714
+ fe && (A.value += 1, C(() => {
1715
+ if (F) {
1716
+ if (T !== 0 && typeof window < "u") {
1717
+ const X = Math.max(
1625
1718
  0,
1626
- S.value + n
1719
+ r.value + T
1627
1720
  );
1628
- S.value = g, window.scrollTo({ top: g, behavior: "auto" });
1721
+ r.value = X, window.scrollTo({ top: X, behavior: "auto" });
1629
1722
  }
1630
- se(), l();
1723
+ re(), t();
1631
1724
  }
1632
1725
  }));
1633
1726
  }
1634
- function k(d) {
1635
- if (V) {
1636
- for (const t of d)
1637
- Z.set(t.target, t);
1638
- w || (w = ee(() => {
1639
- w = void 0;
1640
- const t = Array.from(Z.values());
1641
- Z.clear(), h(t);
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);
1642
1735
  }));
1643
1736
  }
1644
1737
  }
1645
- function ge(d, t) {
1646
- d instanceof HTMLElement && (W.set(d, t), p == null || p.observe(d));
1738
+ function Me(v, S) {
1739
+ v instanceof HTMLElement && (U.set(v, S), D == null || D.observe(v));
1647
1740
  }
1648
- function pe() {
1649
- for (const [d] of W)
1650
- d.isConnected || (p == null || p.unobserve(d), W.delete(d));
1741
+ function ge() {
1742
+ for (const [v] of U)
1743
+ v.isConnected || (D == null || D.unobserve(v), U.delete(v));
1651
1744
  }
1652
- function we(d, t = {}) {
1745
+ function ve(v, S = {}) {
1653
1746
  if (typeof window > "u") return;
1654
- se();
1655
- const n = Math.max(0, J.value - r.value), u = Math.min(
1656
- Math.max(0, Number.isFinite(d) ? d : 0),
1657
- n
1658
- ), g = Math.max(0, H.value + u), R = t.behavior ?? "auto";
1659
- R === "auto" && (S.value = g), window.scrollTo({ ...t, top: g, behavior: R });
1660
- }
1661
- function be(d, t = {}) {
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 = {}) {
1662
1755
  if (typeof window > "u" || e.items.length === 0) return;
1663
- se();
1664
- const n = Math.min(
1756
+ re();
1757
+ const T = Math.min(
1665
1758
  e.items.length - 1,
1666
- Math.max(0, Math.floor(d))
1667
- ), { align: u = "start", ...g } = t, R = fe.value.sizes[n];
1668
- let Q = H.value + fe.value.offsets[n];
1669
- u === "center" ? Q -= (r.value - R) / 2 : u === "end" && (Q -= r.value - R);
1670
- const re = Math.max(
1671
- H.value,
1672
- H.value + J.value - r.value
1673
- ), ce = Math.max(0, Math.min(Q, re)), de = g.behavior ?? "auto";
1674
- de === "auto" && (S.value = ce), window.scrollTo({
1675
- ...g,
1676
- top: ce,
1677
- behavior: de
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
1678
1771
  });
1679
1772
  }
1680
- function Te(d = "auto") {
1681
- typeof window > "u" || (se(), window.scrollTo({ top: Math.max(0, H.value), behavior: d }));
1773
+ function ke(v = "auto") {
1774
+ typeof window > "u" || (re(), window.scrollTo({ top: Math.max(0, m.value), behavior: v }));
1682
1775
  }
1683
- return le(
1776
+ return ie(
1684
1777
  () => e.itemKey,
1685
1778
  () => {
1686
- F.clear(), U.value += 1, N = -1;
1779
+ O.clear(), A.value += 1, W = -1;
1687
1780
  }
1688
- ), le(
1689
- () => e.items.map((d, t) => K(d, t)),
1690
- async (d, t) => {
1691
- const n = d.length !== t.length || d.some((g, R) => g !== t[R]), u = new Set(d);
1692
- for (const g of F.keys())
1693
- u.has(g) || F.delete(g);
1694
- n && (N = -1), U.value += 1, await O(), V && (se(), l());
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());
1695
1788
  }
1696
- ), le(
1789
+ ), ie(
1697
1790
  () => [e.hasMore, e.loading],
1698
- async ([d]) => {
1699
- d || (N = -1), await O(), V && (se(), l());
1791
+ async ([v]) => {
1792
+ v || (W = -1), await C(), F && (re(), t());
1700
1793
  }
1701
- ), ke(() => {
1702
- if (V = !0, se(), window.addEventListener("scroll", j, { passive: !0 }), window.addEventListener("resize", s, { passive: !0 }), typeof ResizeObserver < "u") {
1703
- L = new ResizeObserver(() => {
1704
- Y();
1705
- }), p = new ResizeObserver(k), f.value && L.observe(f.value);
1706
- for (const [d] of W)
1707
- p.observe(d);
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);
1708
1801
  }
1709
- O(() => {
1710
- V && l();
1802
+ C(() => {
1803
+ F && t();
1711
1804
  });
1712
- }), Ae(pe), Le(() => {
1713
- V = !1, window.removeEventListener("scroll", j), window.removeEventListener("resize", s), $(I), $(w), I = void 0, w = void 0, A = !1, Z.clear(), L && (L.disconnect(), L = void 0), p && (p.disconnect(), p = void 0), W.clear();
1714
- }), _({
1715
- scrollTo: we,
1716
- scrollToIndex: be,
1717
- scrollToTop: Te
1718
- }), (d, t) => (x(), T("div", {
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", {
1719
1812
  ref_key: "root",
1720
1813
  ref: f,
1721
- class: Be(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": c(X) }]),
1814
+ class: Ye(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": c(ae) }]),
1722
1815
  role: "list",
1723
- "aria-label": a.ariaLabel,
1724
- onTouchstartPassive: t[0] || (t[0] = //@ts-ignore
1725
- (...n) => c(v) && c(v)(...n)),
1726
- onTouchmove: t[1] || (t[1] = //@ts-ignore
1727
- (...n) => c(M) && c(M)(...n)),
1728
- onTouchend: t[2] || (t[2] = //@ts-ignore
1729
- (...n) => c(D) && c(D)(...n)),
1730
- onTouchcancel: t[3] || (t[3] = //@ts-ignore
1731
- (...n) => c(ve) && c(ve)(...n))
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))
1732
1825
  }, [
1733
- a.pullToRefresh || a.refreshing ? (x(), T("div", {
1826
+ l.pullToRefresh || l.refreshing ? (I(), $("div", {
1734
1827
  key: 0,
1735
1828
  class: "vue-window-dynamic-virtual-scroll__refresh",
1736
- style: C({
1737
- height: `${c(oe)}px`,
1738
- transform: `translateY(${c(q) - c(oe)}px)`
1829
+ style: N({
1830
+ height: `${c(se)}px`,
1831
+ transform: `translateY(${c(J) - c(se)}px)`
1739
1832
  }),
1740
1833
  role: "status",
1741
1834
  "aria-live": "polite"
1742
1835
  }, [
1743
- ie(d.$slots, "refresh", {
1744
- pullDistance: c(B),
1745
- progress: c(ae),
1746
- refreshing: a.refreshing
1836
+ ce(v.$slots, "refresh", {
1837
+ pullDistance: c(R),
1838
+ progress: c(Y),
1839
+ refreshing: l.refreshing
1747
1840
  }, () => [
1748
- Ie(Oe(c(he)), 1)
1841
+ Ve(je(c(le)), 1)
1749
1842
  ])
1750
- ], 4)) : xe("", !0),
1751
- a.items.length || a.loading ? (x(), T("div", {
1843
+ ], 4)) : ze("", !0),
1844
+ l.items.length || l.loading ? (I(), $("div", {
1752
1845
  key: 1,
1753
1846
  class: "vue-window-dynamic-virtual-scroll__spacer",
1754
- style: C({
1755
- height: `${J.value}px`,
1756
- transform: `translateY(${c(q)}px)`
1847
+ style: N({
1848
+ height: `${Q.value}px`,
1849
+ transform: `translateY(${c(J)}px)`
1757
1850
  })
1758
1851
  }, [
1759
- (x(!0), T(ze, null, Ee(Me.value, ({ item: n, index: u, key: g, top: R }) => (x(), T("div", {
1760
- key: g,
1852
+ (I(!0), $(Re, null, De(oe.value, ({ item: T, index: fe, key: X, top: be }) => (I(), $("div", {
1853
+ key: X,
1761
1854
  ref_for: !0,
1762
- ref: (Q) => ge(Q, g),
1855
+ ref: (Ie) => Me(Ie, X),
1763
1856
  class: "vue-window-dynamic-virtual-scroll__item",
1764
- style: C({ transform: `translateY(${R}px)` }),
1857
+ style: N({ transform: `translateY(${be}px)` }),
1765
1858
  role: "listitem",
1766
- "aria-posinset": u + 1,
1767
- "aria-setsize": a.items.length
1859
+ "aria-posinset": fe + 1,
1860
+ "aria-setsize": l.items.length
1768
1861
  }, [
1769
- ie(d.$slots, "default", {
1770
- item: n,
1771
- index: u
1862
+ ce(v.$slots, "default", {
1863
+ item: T,
1864
+ index: fe
1772
1865
  })
1773
- ], 12, mt))), 128)),
1774
- a.loading ? (x(), T("div", {
1866
+ ], 12, Et))), 128)),
1867
+ l.loading ? (I(), $("div", {
1775
1868
  key: 0,
1776
1869
  class: "vue-window-dynamic-virtual-scroll__loading",
1777
- style: C({
1778
- height: `${ye.value}px`,
1779
- transform: `translateY(${fe.value.total}px)`
1870
+ style: N({
1871
+ height: `${u.value}px`,
1872
+ transform: `translateY(${z.value.total}px)`
1780
1873
  }),
1781
1874
  role: "status",
1782
1875
  "aria-live": "polite"
1783
1876
  }, [
1784
- ie(d.$slots, "loading", {}, () => [
1785
- t[4] || (t[4] = Ie("Loading more…", -1))
1877
+ ce(v.$slots, "loading", {}, () => [
1878
+ S[4] || (S[4] = Ve("Loading more…", -1))
1786
1879
  ])
1787
- ], 4)) : xe("", !0)
1788
- ], 4)) : (x(), T("div", {
1880
+ ], 4)) : ze("", !0)
1881
+ ], 4)) : (I(), $("div", {
1789
1882
  key: 2,
1790
1883
  class: "vue-window-dynamic-virtual-scroll__empty",
1791
- style: C({ transform: `translateY(${c(q)}px)` })
1884
+ style: N({ transform: `translateY(${c(J)}px)` })
1792
1885
  }, [
1793
- ie(d.$slots, "empty")
1886
+ ce(v.$slots, "empty")
1794
1887
  ], 4))
1795
- ], 42, ht));
1888
+ ], 42, kt));
1796
1889
  }
1797
- }), pt = ["aria-label"], yt = ["aria-posinset", "aria-setsize"], Mt = /* @__PURE__ */ $e({
1890
+ }), Bt = ["aria-label"], Vt = ["aria-posinset", "aria-setsize"], Ht = /* @__PURE__ */ Oe({
1798
1891
  name: "WindowGirdVirtualScroll",
1799
1892
  __name: "WindowGirdVirtualScroll",
1800
1893
  props: {
@@ -1814,133 +1907,133 @@ const qe = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Ne = /* @__PU
1814
1907
  pullRefreshThreshold: { default: 64 }
1815
1908
  },
1816
1909
  emits: ["scroll", "loadMore", "refresh"],
1817
- setup(a, { expose: _, emit: E }) {
1818
- const e = a, y = E, f = P(), S = P(0), r = P(0), H = P(0);
1819
- let U, F = -1;
1820
- const { getItemKey: W } = He({
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({
1821
1914
  componentName: "WindowGirdVirtualScroll",
1822
1915
  items: () => e.items,
1823
1916
  itemKey: () => e.itemKey
1824
1917
  }), {
1825
- pulling: Z,
1826
- pullDistance: L,
1827
- pullOffset: p,
1828
- pullProgress: I,
1829
- refreshMessage: w,
1830
- refreshThreshold: A,
1831
- handleTouchStart: V,
1832
- handleTouchMove: N,
1833
- handleTouchEnd: K,
1834
- handleTouchCancel: ee
1835
- } = Ke({
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({
1836
1929
  enabled: () => e.pullToRefresh,
1837
1930
  refreshing: () => e.refreshing,
1838
1931
  threshold: () => e.pullRefreshThreshold,
1839
- onRefresh: () => y("refresh"),
1932
+ onRefresh: () => p("refresh"),
1840
1933
  scrollTop: () => typeof window > "u" ? 0 : Math.max(0, window.scrollY)
1841
- }), $ = i(() => Math.max(1, e.itemSize)), X = i(
1934
+ }), H = n(() => Math.max(1, e.itemSize)), ae = n(
1842
1935
  () => Math.max(1, Math.floor(e.columns))
1843
- ), B = i(() => Math.max(0, e.gap)), q = i(() => Math.max(0, Math.floor(e.overscan))), ae = i(
1844
- () => Math.max(1, e.loadingItemSize ?? $.value)
1845
- ), he = i(
1846
- () => $.value + B.value
1847
- ), oe = i(
1848
- () => Math.ceil(e.items.length / X.value)
1849
- ), v = i(() => oe.value === 0 ? 0 : oe.value * $.value + (oe.value - 1) * B.value), M = i(
1850
- () => v.value + (e.items.length ? B.value : 0)
1851
- ), D = i(
1852
- () => v.value + (e.loading ? ae.value + (e.items.length ? B.value : 0) : 0)
1853
- ), ve = i(
1854
- () => Math.max(0, S.value - H.value)
1855
- ), te = i(
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(
1856
1949
  () => Math.max(
1857
1950
  0,
1858
- Math.floor(ve.value / he.value) - q.value
1951
+ Math.floor(we.value / le.value) - J.value
1859
1952
  )
1860
- ), ye = i(() => {
1861
- if (oe.value === 0) return 0;
1862
- const Y = Math.max(
1863
- $.value,
1864
- S.value + r.value - H.value
1865
- ), j = Math.ceil(
1866
- (Y + B.value) / he.value
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
1867
1960
  );
1868
1961
  return Math.min(
1869
- oe.value,
1870
- j + q.value
1962
+ se.value,
1963
+ ee + J.value
1871
1964
  );
1872
- }), ne = i(
1873
- () => Math.min(e.items.length, te.value * X.value)
1874
- ), fe = i(
1875
- () => Math.min(e.items.length, ye.value * X.value)
1876
- ), J = i(
1877
- () => e.items.slice(ne.value, fe.value).map((Y, j) => {
1878
- const s = ne.value + j;
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;
1879
1972
  return {
1880
- item: Y,
1973
+ item: _,
1881
1974
  index: s,
1882
- key: W(Y, s),
1883
- rowIndex: Math.floor(s / X.value),
1884
- columnIndex: s % X.value
1975
+ key: U(_, s),
1976
+ rowIndex: Math.floor(s / ae.value),
1977
+ columnIndex: s % ae.value
1885
1978
  };
1886
1979
  })
1887
- ), me = i(() => ({
1888
- gridTemplateColumns: `repeat(${X.value}, minmax(0, 1fr))`,
1889
- columnGap: `${B.value}px`,
1890
- rowGap: `${B.value}px`,
1891
- transform: `translateY(${te.value * he.value}px)`
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)`
1892
1985
  }));
1893
- function m() {
1894
- typeof window > "u" || (S.value = Math.max(0, window.scrollY), r.value = window.innerHeight, f.value && (H.value = f.value.getBoundingClientRect().top + S.value));
1895
- }
1896
- function b() {
1897
- y("scroll", {
1898
- scrollTop: ve.value,
1899
- startIndex: ne.value,
1900
- endIndex: fe.value
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
+ function L() {
1990
+ p("scroll", {
1991
+ scrollTop: we.value,
1992
+ startIndex: d.value,
1993
+ endIndex: z.value
1901
1994
  });
1902
1995
  }
1903
- function z() {
1904
- m(), b(), G();
1996
+ function B() {
1997
+ y(), L(), te();
1905
1998
  }
1906
- function G() {
1907
- if (typeof window > "u" || !e.hasMore || e.loading || F === e.items.length)
1999
+ function te() {
2000
+ if (typeof window > "u" || !e.hasMore || e.loading || O === e.items.length)
1908
2001
  return;
1909
- const Y = Math.max(0, e.loadMoreThreshold), j = H.value + D.value, s = S.value + r.value;
1910
- j - s <= Y && (F = e.items.length, y("loadMore"));
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"));
1911
2004
  }
1912
- function Me(Y, j = {}) {
2005
+ function oe(_, ee = {}) {
1913
2006
  if (typeof window > "u") return;
1914
- m();
1915
- const s = Math.max(0, D.value - r.value), l = Math.min(
1916
- Math.max(0, Number.isFinite(Y) ? Y : 0),
2007
+ y();
2008
+ const s = Math.max(0, ue.value - o.value), t = Math.min(
2009
+ Math.max(0, Number.isFinite(_) ? _ : 0),
1917
2010
  s
1918
- ), o = Math.max(0, H.value + l), h = j.behavior ?? "auto";
1919
- h === "auto" && (S.value = o), window.scrollTo({ ...j, top: o, behavior: h });
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 });
1920
2013
  }
1921
- function se(Y, j = {}) {
2014
+ function re(_, ee = {}) {
1922
2015
  if (typeof window > "u" || e.items.length === 0) return;
1923
- m();
2016
+ y();
1924
2017
  const s = Math.min(
1925
2018
  e.items.length - 1,
1926
- Math.max(0, Math.floor(Y))
1927
- ), l = Math.floor(s / X.value), { align: o = "start", ...h } = j;
1928
- let k = H.value + l * he.value;
1929
- o === "center" ? k -= (r.value - $.value) / 2 : o === "end" && (k -= r.value - $.value);
1930
- const ge = Math.max(
1931
- H.value,
1932
- H.value + D.value - r.value
1933
- ), pe = Math.max(0, Math.min(k, ge)), we = h.behavior ?? "auto";
1934
- we === "auto" && (S.value = pe), window.scrollTo({
1935
- ...h,
1936
- top: pe,
1937
- behavior: we
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
1938
2031
  });
1939
2032
  }
1940
- function ue(Y = "auto") {
1941
- typeof window > "u" || (m(), window.scrollTo({ top: Math.max(0, H.value), behavior: Y }));
2033
+ function ye(_ = "auto") {
2034
+ typeof window > "u" || (y(), window.scrollTo({ top: Math.max(0, m.value), behavior: _ }));
1942
2035
  }
1943
- return le(
2036
+ return ie(
1944
2037
  () => [
1945
2038
  e.items.length,
1946
2039
  e.itemSize,
@@ -1948,128 +2041,128 @@ const qe = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Ne = /* @__PU
1948
2041
  e.gap
1949
2042
  ],
1950
2043
  async () => {
1951
- await O(), m(), G();
2044
+ await C(), y(), te();
1952
2045
  }
1953
- ), le(
2046
+ ), ie(
1954
2047
  () => [e.hasMore, e.loading],
1955
- async ([Y]) => {
1956
- Y || (F = -1), await O(), m(), G();
2048
+ async ([_]) => {
2049
+ _ || (O = -1), await C(), y(), te();
1957
2050
  }
1958
- ), ke(() => {
1959
- m(), window.addEventListener("scroll", z, { passive: !0 }), window.addEventListener("resize", z, { passive: !0 }), typeof ResizeObserver < "u" && (U = new ResizeObserver(() => {
1960
- m(), G();
1961
- }), f.value && U.observe(f.value)), O(G);
1962
- }), Le(() => {
1963
- window.removeEventListener("scroll", z), window.removeEventListener("resize", z), U && (U.disconnect(), U = void 0);
1964
- }), _({
1965
- scrollTo: Me,
1966
- scrollToIndex: se,
1967
- scrollToTop: ue
1968
- }), (Y, j) => (x(), T("div", {
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,
2060
+ scrollToTop: ye
2061
+ }), (_, ee) => (I(), $("div", {
1969
2062
  ref_key: "root",
1970
2063
  ref: f,
1971
- class: Be(["vue-window-gird-virtual-scroll", { "vue-window-gird-virtual-scroll--pulling": c(Z) }]),
2064
+ class: Ye(["vue-window-gird-virtual-scroll", { "vue-window-gird-virtual-scroll--pulling": c(q) }]),
1972
2065
  role: "list",
1973
- "aria-label": a.ariaLabel,
1974
- onTouchstartPassive: j[0] || (j[0] = //@ts-ignore
1975
- (...s) => c(V) && c(V)(...s)),
1976
- onTouchmove: j[1] || (j[1] = //@ts-ignore
1977
- (...s) => c(N) && c(N)(...s)),
1978
- onTouchend: j[2] || (j[2] = //@ts-ignore
1979
- (...s) => c(K) && c(K)(...s)),
1980
- onTouchcancel: j[3] || (j[3] = //@ts-ignore
1981
- (...s) => c(ee) && c(ee)(...s))
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))
1982
2075
  }, [
1983
- a.pullToRefresh || a.refreshing ? (x(), T("div", {
2076
+ l.pullToRefresh || l.refreshing ? (I(), $("div", {
1984
2077
  key: 0,
1985
2078
  class: "vue-window-gird-virtual-scroll__refresh",
1986
- style: C({
1987
- height: `${c(A)}px`,
1988
- transform: `translateY(${c(p) - c(A)}px)`
2079
+ style: N({
2080
+ height: `${c(E)}px`,
2081
+ transform: `translateY(${c(D) - c(E)}px)`
1989
2082
  }),
1990
2083
  role: "status",
1991
2084
  "aria-live": "polite"
1992
2085
  }, [
1993
- ie(Y.$slots, "refresh", {
1994
- pullDistance: c(L),
1995
- progress: c(I),
1996
- refreshing: a.refreshing
2086
+ ce(_.$slots, "refresh", {
2087
+ pullDistance: c(V),
2088
+ progress: c(w),
2089
+ refreshing: l.refreshing
1997
2090
  }, () => [
1998
- Ie(Oe(c(w)), 1)
2091
+ Ve(je(c(k)), 1)
1999
2092
  ])
2000
- ], 4)) : xe("", !0),
2001
- a.items.length || a.loading ? (x(), T("div", {
2093
+ ], 4)) : ze("", !0),
2094
+ l.items.length || l.loading ? (I(), $("div", {
2002
2095
  key: 1,
2003
2096
  class: "vue-window-gird-virtual-scroll__spacer",
2004
- style: C({
2005
- height: `${D.value}px`,
2006
- transform: `translateY(${c(p)}px)`
2097
+ style: N({
2098
+ height: `${ue.value}px`,
2099
+ transform: `translateY(${c(D)}px)`
2007
2100
  })
2008
2101
  }, [
2009
- De("div", {
2102
+ Ge("div", {
2010
2103
  class: "vue-window-gird-virtual-scroll__content",
2011
- style: C(me.value)
2104
+ style: N(he.value)
2012
2105
  }, [
2013
- (x(!0), T(ze, null, Ee(J.value, ({ item: s, index: l, key: o, rowIndex: h, columnIndex: k }) => (x(), T("div", {
2014
- key: o,
2106
+ (I(!0), $(Re, null, De(Q.value, ({ item: s, index: t, key: a, rowIndex: g, columnIndex: b }) => (I(), $("div", {
2107
+ key: a,
2015
2108
  class: "vue-window-gird-virtual-scroll__item",
2016
- style: C({ height: `${$.value}px` }),
2109
+ style: N({ height: `${H.value}px` }),
2017
2110
  role: "listitem",
2018
- "aria-posinset": l + 1,
2019
- "aria-setsize": a.items.length
2111
+ "aria-posinset": t + 1,
2112
+ "aria-setsize": l.items.length
2020
2113
  }, [
2021
- ie(Y.$slots, "default", {
2114
+ ce(_.$slots, "default", {
2022
2115
  item: s,
2023
- index: l,
2024
- rowIndex: h,
2025
- columnIndex: k
2116
+ index: t,
2117
+ rowIndex: g,
2118
+ columnIndex: b
2026
2119
  })
2027
- ], 12, yt))), 128))
2120
+ ], 12, Vt))), 128))
2028
2121
  ], 4),
2029
- a.loading ? (x(), T("div", {
2122
+ l.loading ? (I(), $("div", {
2030
2123
  key: 0,
2031
2124
  class: "vue-window-gird-virtual-scroll__loading",
2032
- style: C({
2033
- height: `${ae.value}px`,
2034
- transform: `translateY(${M.value}px)`
2125
+ style: N({
2126
+ height: `${Y.value}px`,
2127
+ transform: `translateY(${de.value}px)`
2035
2128
  }),
2036
2129
  role: "status",
2037
2130
  "aria-live": "polite"
2038
2131
  }, [
2039
- ie(Y.$slots, "loading", {}, () => [
2040
- j[4] || (j[4] = Ie("Loading more…", -1))
2132
+ ce(_.$slots, "loading", {}, () => [
2133
+ ee[4] || (ee[4] = Ve("Loading more…", -1))
2041
2134
  ])
2042
- ], 4)) : xe("", !0)
2043
- ], 4)) : (x(), T("div", {
2135
+ ], 4)) : ze("", !0)
2136
+ ], 4)) : (I(), $("div", {
2044
2137
  key: 2,
2045
2138
  class: "vue-window-gird-virtual-scroll__empty",
2046
- style: C({ transform: `translateY(${c(p)}px)` })
2139
+ style: N({ transform: `translateY(${c(D)}px)` })
2047
2140
  }, [
2048
- ie(Y.$slots, "empty")
2141
+ ce(_.$slots, "empty")
2049
2142
  ], 4))
2050
- ], 42, pt));
2143
+ ], 42, Bt));
2051
2144
  }
2052
- }), wt = Ne, Tt = {
2053
- install(a) {
2054
- a.component("ChatVirtualScroll", Ze), a.component("DynamicVirtualScroll", Ne), a.component("ShortMediaFeed", tt), a.component("SkeletonLoader", nt), a.component("VirtualCarousel", ct), a.component("VirtualList", wt), a.component("VirtualScroll", ft), a.component(
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(
2055
2148
  "WindowDynamicVirtualScroll",
2056
- gt
2057
- ), a.component(
2149
+ Lt
2150
+ ), l.component(
2058
2151
  "WindowGirdVirtualScroll",
2059
- Mt
2152
+ Ht
2060
2153
  );
2061
2154
  }
2062
2155
  };
2063
2156
  export {
2064
- Ze as ChatVirtualScroll,
2065
- Ne as DynamicVirtualScroll,
2066
- tt as ShortMediaFeed,
2067
- nt as SkeletonLoader,
2068
- ct as VirtualCarousel,
2069
- wt as VirtualList,
2070
- ft as VirtualScroll,
2071
- Tt as VueVirtualScroll,
2072
- gt as WindowDynamicVirtualScroll,
2073
- Mt as WindowGirdVirtualScroll,
2074
- Tt as default
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
2075
2168
  };