vue-virtual-flow 0.0.1 → 0.0.3

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,51 @@
1
- import { watch as ae, defineComponent as ge, ref as A, computed as i, nextTick as $, onMounted as pe, onUpdated as ze, onBeforeUnmount as ye, openBlock as w, createElementBlock as b, normalizeStyle as C, createElementVNode as Be, renderSlot as X, createTextVNode as me, createCommentVNode as he, Fragment as ve, renderList as Me, unref as m, normalizeClass as $e, toDisplayString as ke } from "vue";
1
+ import { watch as Z, defineComponent as ge, ref as D, computed as s, nextTick as I, onMounted as pe, onUpdated as Se, onBeforeUnmount as ye, openBlock as x, createElementBlock as T, normalizeStyle as R, createElementVNode as $e, renderSlot as te, createTextVNode as he, createCommentVNode as ve, Fragment as me, renderList as Me, unref as v, normalizeClass as Ie, toDisplayString as ze } from "vue";
2
2
  function Ve(n) {
3
3
  return typeof n == "string" || typeof n == "number" || typeof n == "symbol";
4
4
  }
5
- function Ie(n, W) {
5
+ function be(n, W) {
6
6
  const k = n[W];
7
7
  return Ve(k) ? k : void 0;
8
8
  }
9
- function Ee(n) {
10
- return Ie(n, "id") ?? Ie(n, "key");
9
+ function Be(n) {
10
+ return be(n, "id") ?? be(n, "key");
11
11
  }
12
12
  function xe(n) {
13
- function W(e, S) {
13
+ function W(e, w) {
14
14
  const g = n.itemKey();
15
15
  if (typeof g == "function")
16
- return g(e, S);
16
+ return g(e, w);
17
17
  if (e !== null && typeof e == "object") {
18
18
  if (g !== void 0) {
19
- const u = Ie(e, g);
20
- if (u !== void 0) return u;
19
+ const r = be(e, g);
20
+ if (r !== void 0) return r;
21
21
  }
22
- const x = Ee(e);
23
- if (x !== void 0) return x;
22
+ const b = Be(e);
23
+ if (b !== void 0) return b;
24
24
  }
25
- return S;
25
+ return w;
26
26
  }
27
27
  function k() {
28
28
  }
29
- return ae(
29
+ return Z(
30
30
  () => [n.itemKey(), n.items()],
31
31
  k,
32
32
  { immediate: !0 }
33
33
  ), { getItemKey: W };
34
34
  }
35
- function we(n) {
35
+ function Te(n) {
36
36
  return n === "fill" ? "100%" : typeof n == "number" ? `${n}px` : n;
37
37
  }
38
- function be(n) {
38
+ function we(n) {
39
39
  return (W, k) => {
40
40
  typeof k == "string" && (k === "fill" || k.trim().endsWith("%"));
41
41
  };
42
42
  }
43
- const Ke = ["aria-label"], Ce = {
43
+ const Ee = ["aria-label"], Le = {
44
44
  key: 0,
45
45
  class: "vue-chat-virtual-scroll__loading-older",
46
46
  role: "status",
47
47
  "aria-live": "polite"
48
- }, De = ["aria-posinset", "aria-setsize"], Re = /* @__PURE__ */ ge({
48
+ }, Ke = ["aria-posinset", "aria-setsize"], Oe = /* @__PURE__ */ ge({
49
49
  name: "ChatVirtualScroll",
50
50
  __name: "ChatVirtualScroll",
51
51
  props: {
@@ -64,303 +64,300 @@ const Ke = ["aria-label"], Ce = {
64
64
  },
65
65
  emits: ["scroll", "loadOlder", "bottomChange"],
66
66
  setup(n, { expose: W, emit: k }) {
67
- const e = n, S = k, g = A(), x = A(0), u = A(0), V = A(0), P = A(!0), O = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
68
- let N, p, H = -1, T = !1;
69
- const B = be(), { getItemKey: F } = xe({
67
+ const e = n, w = k, g = D(), b = D(0), r = D(0), H = D(0), N = D(!0), C = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map();
68
+ let A, h, V = -1, M = !1;
69
+ const S = we(), { getItemKey: P } = xe({
70
70
  componentName: "ChatVirtualScroll",
71
71
  items: () => e.items,
72
72
  itemKey: () => e.itemKey
73
- }), I = i(
73
+ }), Y = s(
74
74
  () => Math.max(1, e.estimatedItemSize)
75
- ), U = i(() => Math.max(0, Math.floor(e.overscan))), ee = i(() => u.value > 0 ? u.value : typeof e.height == "number" ? Math.max(0, e.height) : I.value), K = i(() => {
76
- V.value;
77
- const a = new Array(e.items.length + 1), f = new Array(e.items.length);
78
- a[0] = 0;
79
- for (let r = 0; r < e.items.length; r += 1) {
80
- const D = F(e.items[r], r), R = O.get(D) ?? I.value;
81
- f[r] = R, a[r + 1] = a[r] + R;
75
+ ), _ = s(() => Math.max(0, Math.floor(e.overscan))), ae = s(() => r.value > 0 ? r.value : typeof e.height == "number" ? Math.max(0, e.height) : Y.value), K = s(() => {
76
+ H.value;
77
+ const o = new Array(e.items.length + 1), c = new Array(e.items.length);
78
+ o[0] = 0;
79
+ for (let u = 0; u < e.items.length; u += 1) {
80
+ const E = P(e.items[u], u), $ = C.get(E) ?? Y.value;
81
+ c[u] = $, o[u + 1] = o[u] + $;
82
82
  }
83
83
  return {
84
- offsets: a,
85
- sizes: f,
86
- total: a[e.items.length] ?? 0
84
+ offsets: o,
85
+ sizes: c,
86
+ total: o[e.items.length] ?? 0
87
87
  };
88
- }), z = i(() => {
89
- const a = /* @__PURE__ */ new Map();
90
- return e.items.forEach((f, r) => {
91
- a.set(F(f, r), r);
92
- }), a;
88
+ }), z = s(() => {
89
+ const o = /* @__PURE__ */ new Map();
90
+ return e.items.forEach((c, u) => {
91
+ o.set(P(c, u), u);
92
+ }), o;
93
93
  });
94
- function te(a) {
94
+ function Q(o) {
95
95
  if (e.items.length === 0) return 0;
96
- const f = K.value.offsets;
97
- let r = 0, D = e.items.length;
98
- for (; r < D; ) {
99
- const R = Math.floor((r + D) / 2);
100
- f[R + 1] <= a ? r = R + 1 : D = R;
96
+ const c = K.value.offsets;
97
+ let u = 0, E = e.items.length;
98
+ for (; u < E; ) {
99
+ const $ = Math.floor((u + E) / 2);
100
+ c[$ + 1] <= o ? u = $ + 1 : E = $;
101
101
  }
102
- return Math.min(r, e.items.length - 1);
102
+ return Math.min(u, e.items.length - 1);
103
103
  }
104
- const G = i(
104
+ const B = s(
105
105
  () => Math.max(
106
106
  0,
107
- te(x.value) - U.value
107
+ Q(b.value) - _.value
108
108
  )
109
- ), J = i(() => {
109
+ ), q = s(() => {
110
110
  if (e.items.length === 0) return 0;
111
- const a = te(x.value + ee.value) + 1;
111
+ const o = Q(b.value + ae.value) + 1;
112
112
  return Math.min(
113
113
  e.items.length,
114
- a + U.value
114
+ o + _.value
115
115
  );
116
- }), _ = i(
117
- () => e.items.slice(G.value, J.value).map((a, f) => {
118
- const r = G.value + f;
116
+ }), U = s(
117
+ () => e.items.slice(B.value, q.value).map((o, c) => {
118
+ const u = B.value + c;
119
119
  return {
120
- item: a,
121
- index: r,
122
- key: F(a, r),
123
- top: K.value.offsets[r]
120
+ item: o,
121
+ index: u,
122
+ key: P(o, u),
123
+ top: K.value.offsets[u]
124
124
  };
125
125
  })
126
- ), oe = i(() => ({
127
- height: we(e.height)
126
+ ), ie = s(() => ({
127
+ height: Te(e.height)
128
128
  }));
129
- function Y() {
130
- const a = g.value;
131
- if (!a) return;
132
- const r = Math.max(
129
+ function F() {
130
+ const o = g.value;
131
+ if (!o) return;
132
+ const u = Math.max(
133
133
  0,
134
- K.value.total - a.scrollTop - a.clientHeight
134
+ K.value.total - o.scrollTop - o.clientHeight
135
135
  ) <= Math.max(0, e.bottomThreshold);
136
- r !== P.value && (P.value = r, T && S("bottomChange", r));
136
+ u !== N.value && (N.value = u, M && w("bottomChange", u));
137
137
  }
138
- function c() {
139
- var a;
140
- u.value = ((a = g.value) == null ? void 0 : a.clientHeight) ?? 0, B(g.value, e.height), $(() => {
141
- Y(), L();
138
+ function f() {
139
+ var o;
140
+ r.value = ((o = g.value) == null ? void 0 : o.clientHeight) ?? 0, S(g.value, e.height), I(() => {
141
+ F(), O();
142
142
  });
143
143
  }
144
- function v(a) {
145
- x.value = a.currentTarget.scrollTop, Y(), S("scroll", {
146
- scrollTop: x.value,
147
- startIndex: G.value,
148
- endIndex: J.value
149
- }), L();
150
- }
151
- function L() {
152
- const a = g.value;
153
- !T || !a || !e.hasOlder || e.loadingOlder || H === e.items.length || a.scrollTop <= Math.max(0, e.loadOlderThreshold) && (H = e.items.length, S("loadOlder"));
154
- }
155
- function j(a) {
156
- const f = a.borderBoxSize;
157
- if (f) {
158
- const r = Array.isArray(f) ? f[0] : f;
159
- if (r != null && r.blockSize) return r.blockSize;
144
+ function m(o) {
145
+ b.value = o.currentTarget.scrollTop, F(), w("scroll", {
146
+ scrollTop: b.value,
147
+ startIndex: B.value,
148
+ endIndex: q.value
149
+ }), O();
150
+ }
151
+ function O() {
152
+ const o = g.value;
153
+ !M || !o || !e.hasOlder || e.loadingOlder || V === e.items.length || o.scrollTop <= Math.max(0, e.loadOlderThreshold) && (V = e.items.length, w("loadOlder"));
154
+ }
155
+ function oe(o) {
156
+ const c = o.borderBoxSize;
157
+ if (c) {
158
+ const u = Array.isArray(c) ? c[0] : c;
159
+ if (u != null && u.blockSize) return u.blockSize;
160
160
  }
161
- return a.contentRect.height;
162
- }
163
- function re(a) {
164
- const f = K.value, r = P.value && e.stickToBottom;
165
- let D = 0, R = !1;
166
- for (const Z of a) {
167
- const ue = Z.target, t = E.get(ue), o = j(Z);
168
- if (t === void 0 || o <= 0) continue;
169
- const l = O.get(t) ?? I.value;
170
- if (Math.abs(l - o) < 0.5) continue;
171
- const M = z.value.get(t);
172
- M !== void 0 && f.offsets[M + 1] <= x.value && (D += o - l), O.set(t, o), R = !0;
161
+ return o.contentRect.height;
162
+ }
163
+ function le(o) {
164
+ const c = K.value, u = N.value && e.stickToBottom;
165
+ let E = 0, $ = !1;
166
+ for (const j of o) {
167
+ const se = j.target, a = L.get(se), t = oe(j);
168
+ if (a === void 0 || t <= 0) continue;
169
+ const l = C.get(a) ?? Y.value;
170
+ if (Math.abs(l - t) < 0.5) continue;
171
+ const i = z.value.get(a);
172
+ i !== void 0 && c.offsets[i + 1] <= b.value && (E += t - l), C.set(a, t), $ = !0;
173
173
  }
174
- R && (V.value += 1, $(() => {
175
- const Z = g.value;
176
- Z && (r ? s("auto") : D !== 0 && (Z.scrollTop += D, x.value = Z.scrollTop, Y()));
174
+ $ && (H.value += 1, I(() => {
175
+ const j = g.value;
176
+ j && (u ? p("auto") : E !== 0 && (j.scrollTop += E, b.value = j.scrollTop, F()));
177
177
  }));
178
178
  }
179
- function se(a, f) {
180
- a instanceof HTMLElement && (E.set(a, f), p == null || p.observe(a));
181
- }
182
- function ne() {
183
- for (const [a] of E)
184
- a.isConnected || (p == null || p.unobserve(a), E.delete(a));
185
- }
186
- function fe(a, f = {}) {
187
- const r = g.value;
188
- if (!r) return;
189
- const D = Math.max(0, K.value.total - r.clientHeight), R = Math.min(
190
- Math.max(0, Number.isFinite(a) ? a : 0),
191
- D
192
- ), Z = f.behavior ?? "auto";
193
- Z === "auto" && (x.value = R), r.scrollTo({ ...f, top: R, behavior: Z }), $(Y);
194
- }
195
- function le(a, f = {}) {
196
- const r = g.value;
197
- if (!r || e.items.length === 0) return;
198
- const D = Math.min(
179
+ function ue(o, c) {
180
+ o instanceof HTMLElement && (L.set(o, c), h == null || h.observe(o));
181
+ }
182
+ function X() {
183
+ for (const [o] of L)
184
+ o.isConnected || (h == null || h.unobserve(o), L.delete(o));
185
+ }
186
+ function ce(o, c = {}) {
187
+ const u = g.value;
188
+ if (!u) return;
189
+ const E = Math.max(0, K.value.total - u.clientHeight), $ = Math.min(
190
+ Math.max(0, Number.isFinite(o) ? o : 0),
191
+ E
192
+ ), j = c.behavior ?? "auto";
193
+ j === "auto" && (b.value = $), u.scrollTo({ ...c, top: $, behavior: j }), I(F);
194
+ }
195
+ function G(o, c = {}) {
196
+ const u = g.value;
197
+ if (!u || e.items.length === 0) return;
198
+ const E = Math.min(
199
199
  e.items.length - 1,
200
- Math.max(0, Math.floor(a))
201
- ), { align: R = "start", ...Z } = f, ue = K.value.sizes[D];
202
- let t = K.value.offsets[D];
203
- R === "center" ? t -= (r.clientHeight - ue) / 2 : R === "end" && (t -= r.clientHeight - ue);
204
- const o = Math.max(
200
+ Math.max(0, Math.floor(o))
201
+ ), { align: $ = "start", ...j } = c, se = K.value.sizes[E];
202
+ let a = K.value.offsets[E];
203
+ $ === "center" ? a -= (u.clientHeight - se) / 2 : $ === "end" && (a -= u.clientHeight - se);
204
+ const t = Math.max(
205
205
  0,
206
- Math.min(t, K.value.total - r.clientHeight)
207
- ), l = Z.behavior ?? "auto", M = Math.max(
208
- r.clientHeight * 3,
209
- I.value * 10
210
- ), y = l === "smooth" && Math.abs(o - r.scrollTop) > M ? "auto" : l;
211
- y === "auto" && (x.value = o), r.scrollTo({
212
- ...Z,
213
- top: o,
214
- behavior: y
215
- }), $(Y);
216
- }
217
- function d(a = "auto") {
218
- const f = g.value;
219
- f && (a === "auto" && (x.value = 0), f.scrollTo({ top: 0, behavior: a }), $(Y));
220
- }
221
- function s(a = "auto") {
222
- const f = g.value;
223
- if (!f) return;
224
- const r = Math.max(0, K.value.total - f.clientHeight);
225
- a === "auto" ? (f.scrollTop = r, x.value = r) : f.scrollTo({ top: r, behavior: a }), $(Y);
226
- }
227
- let h = e.items.map((a, f) => F(a, f));
228
- return ae(
229
- () => e.items.map((a, f) => F(a, f)),
230
- async (a) => {
231
- const f = h;
232
- h = a;
233
- const r = g.value, D = (r == null ? void 0 : r.scrollTop) ?? 0, R = P.value && e.stickToBottom, Z = f[0], ue = Z === void 0 ? 0 : a.indexOf(Z), t = ue > 0 ? a.slice(0, ue).reduce(
234
- (l, M) => l + (O.get(M) ?? I.value),
206
+ Math.min(a, K.value.total - u.clientHeight)
207
+ ), l = j.behavior ?? "auto";
208
+ l === "auto" && (b.value = t), u.scrollTo({
209
+ ...j,
210
+ top: t,
211
+ behavior: l
212
+ }), I(F);
213
+ }
214
+ function ne(o = "auto") {
215
+ const c = g.value;
216
+ c && (o === "auto" && (b.value = 0), c.scrollTo({ top: 0, behavior: o }), I(F));
217
+ }
218
+ function p(o = "auto") {
219
+ const c = g.value;
220
+ if (!c) return;
221
+ const u = Math.max(0, K.value.total - c.clientHeight);
222
+ o === "auto" ? (c.scrollTop = u, b.value = u) : c.scrollTo({ top: u, behavior: o }), I(F);
223
+ }
224
+ let y = e.items.map((o, c) => P(o, c));
225
+ return Z(
226
+ () => e.items.map((o, c) => P(o, c)),
227
+ async (o) => {
228
+ const c = y;
229
+ y = o;
230
+ const u = g.value, E = (u == null ? void 0 : u.scrollTop) ?? 0, $ = N.value && e.stickToBottom, j = c[0], se = j === void 0 ? 0 : o.indexOf(j), a = se > 0 ? o.slice(0, se).reduce(
231
+ (l, i) => l + (C.get(i) ?? Y.value),
235
232
  0
236
- ) : 0, o = new Set(a);
237
- for (const l of O.keys())
238
- o.has(l) || O.delete(l);
239
- V.value += 1, await $(), r && (t > 0 ? (r.scrollTop = D + t, x.value = r.scrollTop) : a.length > f.length && R && s("auto"), Y(), L());
233
+ ) : 0, t = new Set(o);
234
+ for (const l of C.keys())
235
+ t.has(l) || C.delete(l);
236
+ H.value += 1, await I(), u && (a > 0 ? (u.scrollTop = E + a, b.value = u.scrollTop) : o.length > c.length && $ && p("auto"), F(), O());
240
237
  }
241
- ), ae(
238
+ ), Z(
242
239
  () => [e.hasOlder, e.loadingOlder],
243
- async ([a]) => {
244
- a || (H = -1), await $(), L();
240
+ async ([o]) => {
241
+ o || (V = -1), await I(), O();
245
242
  }
246
243
  ), pe(() => {
247
- if (c(), typeof ResizeObserver < "u") {
248
- N = new ResizeObserver(c), p = new ResizeObserver(re), g.value && N.observe(g.value);
249
- for (const [a] of E)
250
- p.observe(a);
244
+ if (f(), typeof ResizeObserver < "u") {
245
+ A = new ResizeObserver(f), h = new ResizeObserver(le), g.value && A.observe(g.value);
246
+ for (const [o] of L)
247
+ h.observe(o);
251
248
  }
252
- $(() => {
253
- e.initialScroll === "bottom" && s("auto"), T = !0, Y(), L();
249
+ I(() => {
250
+ e.initialScroll === "bottom" && p("auto"), M = !0, F(), O();
254
251
  });
255
- }), ze(ne), ye(() => {
256
- N == null || N.disconnect(), p == null || p.disconnect(), E.clear();
252
+ }), Se(X), ye(() => {
253
+ A && (A.disconnect(), A = void 0), h && (h.disconnect(), h = void 0), L.clear();
257
254
  }), W({
258
- isAtBottom: P,
259
- scrollTo: fe,
260
- scrollToIndex: le,
261
- scrollToTop: d,
262
- scrollToBottom: s
263
- }), (a, f) => (w(), b("div", {
255
+ isAtBottom: N,
256
+ scrollTo: ce,
257
+ scrollToIndex: G,
258
+ scrollToTop: ne,
259
+ scrollToBottom: p
260
+ }), (o, c) => (x(), T("div", {
264
261
  ref_key: "viewport",
265
262
  ref: g,
266
263
  class: "vue-chat-virtual-scroll",
267
- style: C(oe.value),
264
+ style: R(ie.value),
268
265
  role: "log",
269
266
  "aria-label": n.ariaLabel,
270
267
  "aria-live": "polite",
271
268
  tabindex: "0",
272
- onScrollPassive: v
269
+ onScrollPassive: m
273
270
  }, [
274
- n.loadingOlder ? (w(), b("div", Ce, [
275
- Be("div", null, [
276
- X(a.$slots, "loadingOlder", {}, () => [
277
- f[0] || (f[0] = me("Loading older messages…", -1))
271
+ n.loadingOlder ? (x(), T("div", Le, [
272
+ $e("div", null, [
273
+ te(o.$slots, "loadingOlder", {}, () => [
274
+ c[0] || (c[0] = he("Loading older messages…", -1))
278
275
  ])
279
276
  ])
280
- ])) : he("", !0),
281
- n.items.length ? (w(), b("div", {
277
+ ])) : ve("", !0),
278
+ n.items.length ? (x(), T("div", {
282
279
  key: 1,
283
280
  class: "vue-chat-virtual-scroll__spacer",
284
- style: C({ height: `${K.value.total}px` })
281
+ style: R({ height: `${K.value.total}px` })
285
282
  }, [
286
- (w(!0), b(ve, null, Me(_.value, ({ item: r, index: D, key: R, top: Z }) => (w(), b("div", {
287
- key: R,
283
+ (x(!0), T(me, null, Me(U.value, ({ item: u, index: E, key: $, top: j }) => (x(), T("div", {
284
+ key: $,
288
285
  ref_for: !0,
289
- ref: (ue) => se(ue, R),
286
+ ref: (se) => ue(se, $),
290
287
  class: "vue-chat-virtual-scroll__item",
291
- style: C({ transform: `translateY(${Z}px)` }),
288
+ style: R({ transform: `translateY(${j}px)` }),
292
289
  role: "article",
293
- "aria-posinset": D + 1,
290
+ "aria-posinset": E + 1,
294
291
  "aria-setsize": n.items.length
295
292
  }, [
296
- X(a.$slots, "default", {
297
- item: r,
298
- index: D
293
+ te(o.$slots, "default", {
294
+ item: u,
295
+ index: E
299
296
  })
300
- ], 12, De))), 128))
301
- ], 4)) : X(a.$slots, "empty", {}, void 0, void 0, 2)
302
- ], 44, Ke));
297
+ ], 12, Ke))), 128))
298
+ ], 4)) : te(o.$slots, "empty", {}, void 0, void 0, 2)
299
+ ], 44, Ee));
303
300
  }
304
301
  });
305
- function He(n) {
306
- const W = A(), k = A(0), e = A(!1), S = A(!1), g = i(() => Math.max(1, n.threshold())), x = i(
307
- () => n.refreshing() || S.value ? g.value : k.value
308
- ), u = i(
302
+ function ke(n) {
303
+ const W = D(), k = D(0), e = D(!1), w = D(!1), g = s(() => Math.max(1, n.threshold())), b = s(
304
+ () => n.refreshing() || w.value ? g.value : k.value
305
+ ), r = s(
309
306
  () => Math.min(1, k.value / g.value)
310
- ), V = i(() => n.refreshing() || S.value ? "Refreshing…" : u.value >= 1 ? "Release to refresh" : "Pull to refresh");
311
- function P() {
307
+ ), H = s(() => n.refreshing() || w.value ? "Refreshing…" : r.value >= 1 ? "Release to refresh" : "Pull to refresh");
308
+ function N() {
312
309
  W.value = void 0, e.value = !1, k.value = 0;
313
310
  }
314
- function O(p) {
315
- var B;
316
- const H = p.currentTarget, T = ((B = n.scrollTop) == null ? void 0 : B.call(n)) ?? H.scrollTop;
317
- !n.enabled() || n.refreshing() || T > 0 || p.touches.length !== 1 || (W.value = p.touches[0].clientY, e.value = !0);
311
+ function C(h) {
312
+ var S;
313
+ const V = h.currentTarget, M = ((S = n.scrollTop) == null ? void 0 : S.call(n)) ?? V.scrollTop;
314
+ !n.enabled() || n.refreshing() || M > 0 || h.touches.length !== 1 || (W.value = h.touches[0].clientY, e.value = !0);
318
315
  }
319
- function E(p) {
320
- var F;
316
+ function L(h) {
317
+ var P;
321
318
  if (W.value === void 0 || !e.value) return;
322
- const H = p.currentTarget;
323
- if ((((F = n.scrollTop) == null ? void 0 : F.call(n)) ?? H.scrollTop) > 0 || p.touches.length !== 1) {
324
- P();
319
+ const V = h.currentTarget;
320
+ if ((((P = n.scrollTop) == null ? void 0 : P.call(n)) ?? V.scrollTop) > 0 || h.touches.length !== 1) {
321
+ N();
325
322
  return;
326
323
  }
327
- const B = p.touches[0].clientY - W.value;
328
- if (B <= 0) {
324
+ const S = h.touches[0].clientY - W.value;
325
+ if (S <= 0) {
329
326
  k.value = 0;
330
327
  return;
331
328
  }
332
- p.preventDefault(), k.value = Math.min(B * 0.5, g.value * 2);
329
+ h.preventDefault(), k.value = Math.min(S * 0.5, g.value * 2);
333
330
  }
334
- function N() {
331
+ function A() {
335
332
  if (W.value === void 0) return;
336
- const p = k.value >= g.value && n.enabled() && !n.refreshing();
337
- if (W.value = void 0, e.value = !1, !p) {
333
+ const h = k.value >= g.value && n.enabled() && !n.refreshing();
334
+ if (W.value = void 0, e.value = !1, !h) {
338
335
  k.value = 0;
339
336
  return;
340
337
  }
341
- k.value = g.value, S.value = !0, n.onRefresh(), $(() => {
342
- n.refreshing() || (S.value = !1, k.value = 0);
338
+ k.value = g.value, w.value = !0, n.onRefresh(), I(() => {
339
+ n.refreshing() || (w.value = !1, k.value = 0);
343
340
  });
344
341
  }
345
- return ae(
342
+ return Z(
346
343
  () => n.refreshing(),
347
- (p, H) => {
348
- p ? (S.value = !1, k.value = g.value) : H && (S.value = !1, k.value = 0);
344
+ (h, V) => {
345
+ h ? (w.value = !1, k.value = g.value) : V && (w.value = !1, k.value = 0);
349
346
  }
350
347
  ), {
351
348
  pulling: e,
352
349
  pullDistance: k,
353
- pullOffset: x,
354
- pullProgress: u,
355
- refreshMessage: V,
350
+ pullOffset: b,
351
+ pullProgress: r,
352
+ refreshMessage: H,
356
353
  refreshThreshold: g,
357
- handleTouchStart: O,
358
- handleTouchMove: E,
359
- handleTouchEnd: N,
360
- handleTouchCancel: P
354
+ handleTouchStart: C,
355
+ handleTouchMove: L,
356
+ handleTouchEnd: A,
357
+ handleTouchCancel: N
361
358
  };
362
359
  }
363
- const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PURE__ */ ge({
360
+ const Re = ["aria-label"], Ce = ["aria-posinset", "aria-setsize"], He = /* @__PURE__ */ ge({
364
361
  name: "DynamicVirtualScroll",
365
362
  __name: "DynamicVirtualScroll",
366
363
  props: {
@@ -380,296 +377,293 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
380
377
  },
381
378
  emits: ["scroll", "loadMore", "refresh"],
382
379
  setup(n, { expose: W, emit: k }) {
383
- const e = n, S = k, {
380
+ const e = n, w = k, {
384
381
  pulling: g,
385
- pullDistance: x,
386
- pullOffset: u,
387
- pullProgress: V,
388
- refreshMessage: P,
389
- refreshThreshold: O,
390
- handleTouchStart: E,
391
- handleTouchMove: N,
392
- handleTouchEnd: p,
393
- handleTouchCancel: H
394
- } = He({
382
+ pullDistance: b,
383
+ pullOffset: r,
384
+ pullProgress: H,
385
+ refreshMessage: N,
386
+ refreshThreshold: C,
387
+ handleTouchStart: L,
388
+ handleTouchMove: A,
389
+ handleTouchEnd: h,
390
+ handleTouchCancel: V
391
+ } = ke({
395
392
  enabled: () => e.pullToRefresh,
396
393
  refreshing: () => e.refreshing,
397
394
  threshold: () => e.pullRefreshThreshold,
398
- onRefresh: () => S("refresh")
399
- }), T = A(), B = A(0), F = A(0), I = A(0), U = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Map();
400
- let K, z, te = -1;
401
- const G = be(), { getItemKey: J } = xe({
395
+ onRefresh: () => w("refresh")
396
+ }), M = D(), S = D(0), P = D(0), Y = D(0), _ = /* @__PURE__ */ new Map(), ae = /* @__PURE__ */ new Map();
397
+ let K, z, Q = -1;
398
+ const B = we(), { getItemKey: q } = xe({
402
399
  componentName: "DynamicVirtualScroll",
403
400
  items: () => e.items,
404
401
  itemKey: () => e.itemKey
405
- }), _ = i(
402
+ }), U = s(
406
403
  () => Math.max(1, e.estimatedItemSize)
407
- ), oe = i(
408
- () => Math.max(1, e.loadingItemSize ?? _.value)
409
- ), Y = i(() => Math.max(0, Math.floor(e.overscan))), c = i(() => F.value > 0 ? F.value : typeof e.height == "number" ? Math.max(0, e.height) : _.value), v = i(() => {
410
- I.value;
411
- const t = new Array(e.items.length + 1), o = new Array(e.items.length);
412
- t[0] = 0;
404
+ ), ie = s(
405
+ () => Math.max(1, e.loadingItemSize ?? U.value)
406
+ ), F = s(() => Math.max(0, Math.floor(e.overscan))), f = s(() => P.value > 0 ? P.value : typeof e.height == "number" ? Math.max(0, e.height) : U.value), m = s(() => {
407
+ Y.value;
408
+ const a = new Array(e.items.length + 1), t = new Array(e.items.length);
409
+ a[0] = 0;
413
410
  for (let l = 0; l < e.items.length; l += 1) {
414
- const M = J(e.items[l], l), y = U.get(M) ?? _.value;
415
- o[l] = y, t[l + 1] = t[l] + y;
411
+ const i = q(e.items[l], l), d = _.get(i) ?? U.value;
412
+ t[l] = d, a[l + 1] = a[l] + d;
416
413
  }
417
414
  return {
418
- offsets: t,
419
- sizes: o,
420
- total: t[e.items.length] ?? 0
415
+ offsets: a,
416
+ sizes: t,
417
+ total: a[e.items.length] ?? 0
421
418
  };
422
- }), L = i(
423
- () => v.value.total + (e.loading ? oe.value : 0)
424
- ), j = i(() => {
425
- const t = /* @__PURE__ */ new Map();
426
- return e.items.forEach((o, l) => {
427
- t.set(J(o, l), l);
428
- }), t;
419
+ }), O = s(
420
+ () => m.value.total + (e.loading ? ie.value : 0)
421
+ ), oe = s(() => {
422
+ const a = /* @__PURE__ */ new Map();
423
+ return e.items.forEach((t, l) => {
424
+ a.set(q(t, l), l);
425
+ }), a;
429
426
  });
430
- function re(t) {
427
+ function le(a) {
431
428
  if (e.items.length === 0) return 0;
432
- const o = v.value.offsets;
433
- let l = 0, M = e.items.length;
434
- for (; l < M; ) {
435
- const y = Math.floor((l + M) / 2);
436
- o[y + 1] <= t ? l = y + 1 : M = y;
429
+ const t = m.value.offsets;
430
+ let l = 0, i = e.items.length;
431
+ for (; l < i; ) {
432
+ const d = Math.floor((l + i) / 2);
433
+ t[d + 1] <= a ? l = d + 1 : i = d;
437
434
  }
438
435
  return Math.min(l, e.items.length - 1);
439
436
  }
440
- const se = i(
437
+ const ue = s(
441
438
  () => Math.max(
442
439
  0,
443
- re(B.value) - Y.value
440
+ le(S.value) - F.value
444
441
  )
445
- ), ne = i(() => {
442
+ ), X = s(() => {
446
443
  if (e.items.length === 0) return 0;
447
- const t = re(B.value + c.value) + 1;
444
+ const a = le(S.value + f.value) + 1;
448
445
  return Math.min(
449
446
  e.items.length,
450
- t + Y.value
447
+ a + F.value
451
448
  );
452
- }), fe = i(
453
- () => e.items.slice(se.value, ne.value).map((t, o) => {
454
- const l = se.value + o;
449
+ }), ce = s(
450
+ () => e.items.slice(ue.value, X.value).map((a, t) => {
451
+ const l = ue.value + t;
455
452
  return {
456
- item: t,
453
+ item: a,
457
454
  index: l,
458
- key: J(t, l),
459
- top: v.value.offsets[l]
455
+ key: q(a, l),
456
+ top: m.value.offsets[l]
460
457
  };
461
458
  })
462
- ), le = i(() => ({
463
- height: we(e.height)
459
+ ), G = s(() => ({
460
+ height: Te(e.height)
464
461
  }));
465
- function d() {
466
- var t;
467
- F.value = ((t = T.value) == null ? void 0 : t.clientHeight) ?? 0, G(T.value, e.height), $(h);
468
- }
469
- function s(t) {
470
- B.value = t.currentTarget.scrollTop, S("scroll", {
471
- scrollTop: B.value,
472
- startIndex: se.value,
473
- endIndex: ne.value
474
- }), h();
475
- }
476
- function h() {
477
- const t = T.value;
478
- if (!t || !e.hasMore || e.loading || te === e.items.length)
462
+ function ne() {
463
+ var a;
464
+ P.value = ((a = M.value) == null ? void 0 : a.clientHeight) ?? 0, B(M.value, e.height), I(y);
465
+ }
466
+ function p(a) {
467
+ S.value = a.currentTarget.scrollTop, w("scroll", {
468
+ scrollTop: S.value,
469
+ startIndex: ue.value,
470
+ endIndex: X.value
471
+ }), y();
472
+ }
473
+ function y() {
474
+ const a = M.value;
475
+ if (!a || !e.hasMore || e.loading || Q === e.items.length)
479
476
  return;
480
- const o = Math.max(0, e.loadMoreThreshold);
481
- L.value - t.scrollTop - t.clientHeight <= o && (te = e.items.length, S("loadMore"));
477
+ const t = Math.max(0, e.loadMoreThreshold);
478
+ O.value - a.scrollTop - a.clientHeight <= t && (Q = e.items.length, w("loadMore"));
482
479
  }
483
- function a(t) {
484
- const o = t.borderBoxSize;
485
- if (o) {
486
- const l = Array.isArray(o) ? o[0] : o;
480
+ function o(a) {
481
+ const t = a.borderBoxSize;
482
+ if (t) {
483
+ const l = Array.isArray(t) ? t[0] : t;
487
484
  if (l != null && l.blockSize) return l.blockSize;
488
485
  }
489
- return t.contentRect.height;
490
- }
491
- function f(t) {
492
- const o = v.value;
493
- let l = 0, M = !1;
494
- for (const y of t) {
495
- const Q = y.target, q = ee.get(Q), ie = a(y);
496
- if (q === void 0 || ie <= 0) continue;
497
- const ce = U.get(q) ?? _.value;
498
- if (Math.abs(ce - ie) < 0.5) continue;
499
- const de = j.value.get(q);
500
- de !== void 0 && o.offsets[de + 1] <= B.value && (l += ie - ce), U.set(q, ie), M = !0;
486
+ return a.contentRect.height;
487
+ }
488
+ function c(a) {
489
+ const t = m.value;
490
+ let l = 0, i = !1;
491
+ for (const d of a) {
492
+ const ee = d.target, J = ae.get(ee), re = o(d);
493
+ if (J === void 0 || re <= 0) continue;
494
+ const de = _.get(J) ?? U.value;
495
+ if (Math.abs(de - re) < 0.5) continue;
496
+ const fe = oe.value.get(J);
497
+ fe !== void 0 && t.offsets[fe + 1] <= S.value && (l += re - de), _.set(J, re), i = !0;
501
498
  }
502
- M && (I.value += 1, $(h), l !== 0 && $(() => {
503
- const y = T.value;
504
- y && (y.scrollTop += l, B.value = y.scrollTop);
499
+ i && (Y.value += 1, I(y), l !== 0 && I(() => {
500
+ const d = M.value;
501
+ d && (d.scrollTop += l, S.value = d.scrollTop);
505
502
  }));
506
503
  }
507
- function r(t, o) {
508
- t instanceof HTMLElement && (ee.set(t, o), z == null || z.observe(t));
504
+ function u(a, t) {
505
+ a instanceof HTMLElement && (ae.set(a, t), z == null || z.observe(a));
509
506
  }
510
- function D() {
511
- for (const [t] of ee)
512
- t.isConnected || (z == null || z.unobserve(t), ee.delete(t));
507
+ function E() {
508
+ for (const [a] of ae)
509
+ a.isConnected || (z == null || z.unobserve(a), ae.delete(a));
513
510
  }
514
- function R(t, o = {}) {
515
- const l = T.value;
511
+ function $(a, t = {}) {
512
+ const l = M.value;
516
513
  if (!l) return;
517
- const M = Math.max(0, L.value - l.clientHeight), y = Math.min(
518
- Math.max(0, Number.isFinite(t) ? t : 0),
519
- M
520
- ), Q = o.behavior ?? "auto";
521
- Q === "auto" && (B.value = y), l.scrollTo({ ...o, top: y, behavior: Q });
522
- }
523
- function Z(t, o = {}) {
524
- const l = T.value;
514
+ const i = Math.max(0, O.value - l.clientHeight), d = Math.min(
515
+ Math.max(0, Number.isFinite(a) ? a : 0),
516
+ i
517
+ ), ee = t.behavior ?? "auto";
518
+ ee === "auto" && (S.value = d), l.scrollTo({ ...t, top: d, behavior: ee });
519
+ }
520
+ function j(a, t = {}) {
521
+ const l = M.value;
525
522
  if (!l || e.items.length === 0) return;
526
- const M = Math.min(
523
+ const i = Math.min(
527
524
  e.items.length - 1,
528
- Math.max(0, Math.floor(t))
529
- ), { align: y = "start", ...Q } = o;
530
- let q = v.value.offsets[M];
531
- const ie = v.value.sizes[M];
532
- y === "center" ? q -= (l.clientHeight - ie) / 2 : y === "end" && (q -= l.clientHeight - ie);
533
- const ce = Math.max(
525
+ Math.max(0, Math.floor(a))
526
+ ), { align: d = "start", ...ee } = t;
527
+ let J = m.value.offsets[i];
528
+ const re = m.value.sizes[i];
529
+ d === "center" ? J -= (l.clientHeight - re) / 2 : d === "end" && (J -= l.clientHeight - re);
530
+ const de = Math.max(
534
531
  0,
535
- Math.min(q, L.value - l.clientHeight)
536
- ), de = Q.behavior ?? "auto", Se = Math.max(
537
- l.clientHeight * 3,
538
- _.value * 10
539
- ), Te = de === "smooth" && Math.abs(ce - l.scrollTop) > Se ? "auto" : de;
540
- Te === "auto" && (B.value = ce), l.scrollTo({
541
- ...Q,
542
- top: ce,
543
- behavior: Te
532
+ Math.min(J, O.value - l.clientHeight)
533
+ ), fe = ee.behavior ?? "auto";
534
+ fe === "auto" && (S.value = de), l.scrollTo({
535
+ ...ee,
536
+ top: de,
537
+ behavior: fe
544
538
  });
545
539
  }
546
- function ue(t = "auto") {
547
- var o;
548
- (o = T.value) == null || o.scrollTo({ top: 0, behavior: t });
540
+ function se(a = "auto") {
541
+ var t;
542
+ (t = M.value) == null || t.scrollTo({ top: 0, behavior: a });
549
543
  }
550
- return ae(
544
+ return Z(
551
545
  () => e.itemKey,
552
546
  () => {
553
- U.clear(), I.value += 1;
547
+ _.clear(), Y.value += 1;
554
548
  }
555
- ), ae(
549
+ ), Z(
556
550
  () => e.items.length,
557
551
  async () => {
558
- const t = new Set(
559
- e.items.map((M, y) => J(M, y))
552
+ const a = new Set(
553
+ e.items.map((i, d) => q(i, d))
560
554
  );
561
- for (const M of U.keys())
562
- t.has(M) || U.delete(M);
563
- I.value += 1, await $();
564
- const o = T.value;
565
- if (!o) return;
566
- const l = Math.max(0, L.value - o.clientHeight);
567
- o.scrollTop > l && (o.scrollTop = l, B.value = l), h();
555
+ for (const i of _.keys())
556
+ a.has(i) || _.delete(i);
557
+ Y.value += 1, await I();
558
+ const t = M.value;
559
+ if (!t) return;
560
+ const l = Math.max(0, O.value - t.clientHeight);
561
+ t.scrollTop > l && (t.scrollTop = l, S.value = l), y();
568
562
  }
569
- ), ae(
563
+ ), Z(
570
564
  () => [e.hasMore, e.loading],
571
- async ([t]) => {
572
- t || (te = -1), await $(), h();
565
+ async ([a]) => {
566
+ a || (Q = -1), await I(), y();
573
567
  }
574
568
  ), pe(() => {
575
- if (d(), typeof ResizeObserver < "u") {
576
- K = new ResizeObserver(d), z = new ResizeObserver(f), T.value && K.observe(T.value);
577
- for (const [t] of ee)
578
- z.observe(t);
569
+ if (ne(), typeof ResizeObserver < "u") {
570
+ K = new ResizeObserver(ne), z = new ResizeObserver(c), M.value && K.observe(M.value);
571
+ for (const [a] of ae)
572
+ z.observe(a);
579
573
  }
580
- $(h);
581
- }), ze(D), ye(() => {
582
- K == null || K.disconnect(), z == null || z.disconnect(), ee.clear();
574
+ I(y);
575
+ }), Se(E), ye(() => {
576
+ K && (K.disconnect(), K = void 0), z && (z.disconnect(), z = void 0), ae.clear();
583
577
  }), W({
584
- scrollTo: R,
585
- scrollToIndex: Z,
586
- scrollToTop: ue
587
- }), (t, o) => (w(), b("div", {
578
+ scrollTo: $,
579
+ scrollToIndex: j,
580
+ scrollToTop: se
581
+ }), (a, t) => (x(), T("div", {
588
582
  ref_key: "viewport",
589
- ref: T,
590
- class: $e(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": m(g) }]),
591
- style: C(le.value),
583
+ ref: M,
584
+ class: Ie(["vue-dynamic-virtual-scroll", { "vue-dynamic-virtual-scroll--pulling": v(g) }]),
585
+ style: R(G.value),
592
586
  role: "list",
593
587
  "aria-label": n.ariaLabel,
594
588
  tabindex: "0",
595
- onScrollPassive: s,
596
- onTouchstartPassive: o[0] || (o[0] = //@ts-ignore
597
- (...l) => m(E) && m(E)(...l)),
598
- onTouchmove: o[1] || (o[1] = //@ts-ignore
599
- (...l) => m(N) && m(N)(...l)),
600
- onTouchend: o[2] || (o[2] = //@ts-ignore
601
- (...l) => m(p) && m(p)(...l)),
602
- onTouchcancel: o[3] || (o[3] = //@ts-ignore
603
- (...l) => m(H) && m(H)(...l))
589
+ onScrollPassive: p,
590
+ onTouchstartPassive: t[0] || (t[0] = //@ts-ignore
591
+ (...l) => v(L) && v(L)(...l)),
592
+ onTouchmove: t[1] || (t[1] = //@ts-ignore
593
+ (...l) => v(A) && v(A)(...l)),
594
+ onTouchend: t[2] || (t[2] = //@ts-ignore
595
+ (...l) => v(h) && v(h)(...l)),
596
+ onTouchcancel: t[3] || (t[3] = //@ts-ignore
597
+ (...l) => v(V) && v(V)(...l))
604
598
  }, [
605
- n.pullToRefresh || n.refreshing ? (w(), b("div", {
599
+ n.pullToRefresh || n.refreshing ? (x(), T("div", {
606
600
  key: 0,
607
601
  class: "vue-dynamic-virtual-scroll__refresh",
608
- style: C({
609
- height: `${m(O)}px`,
610
- transform: `translateY(${m(u) - m(O)}px)`
602
+ style: R({
603
+ height: `${v(C)}px`,
604
+ transform: `translateY(${v(r) - v(C)}px)`
611
605
  }),
612
606
  role: "status",
613
607
  "aria-live": "polite"
614
608
  }, [
615
- X(t.$slots, "refresh", {
616
- pullDistance: m(x),
617
- progress: m(V),
609
+ te(a.$slots, "refresh", {
610
+ pullDistance: v(b),
611
+ progress: v(H),
618
612
  refreshing: n.refreshing
619
613
  }, () => [
620
- me(ke(m(P)), 1)
614
+ he(ze(v(N)), 1)
621
615
  ])
622
- ], 4)) : he("", !0),
623
- n.items.length || n.loading ? (w(), b("div", {
616
+ ], 4)) : ve("", !0),
617
+ n.items.length || n.loading ? (x(), T("div", {
624
618
  key: 1,
625
619
  class: "vue-dynamic-virtual-scroll__spacer",
626
- style: C({
627
- height: `${L.value}px`,
628
- transform: `translateY(${m(u)}px)`
620
+ style: R({
621
+ height: `${O.value}px`,
622
+ transform: `translateY(${v(r)}px)`
629
623
  })
630
624
  }, [
631
- (w(!0), b(ve, null, Me(fe.value, ({ item: l, index: M, key: y, top: Q }) => (w(), b("div", {
632
- key: y,
625
+ (x(!0), T(me, null, Me(ce.value, ({ item: l, index: i, key: d, top: ee }) => (x(), T("div", {
626
+ key: d,
633
627
  ref_for: !0,
634
- ref: (q) => r(q, y),
628
+ ref: (J) => u(J, d),
635
629
  class: "vue-dynamic-virtual-scroll__item",
636
- style: C({ transform: `translateY(${Q}px)` }),
630
+ style: R({ transform: `translateY(${ee}px)` }),
637
631
  role: "listitem",
638
- "aria-posinset": M + 1,
632
+ "aria-posinset": i + 1,
639
633
  "aria-setsize": n.items.length
640
634
  }, [
641
- X(t.$slots, "default", {
635
+ te(a.$slots, "default", {
642
636
  item: l,
643
- index: M
637
+ index: i
644
638
  })
645
- ], 12, Pe))), 128)),
646
- n.loading ? (w(), b("div", {
639
+ ], 12, Ce))), 128)),
640
+ n.loading ? (x(), T("div", {
647
641
  key: 0,
648
642
  class: "vue-dynamic-virtual-scroll__loading",
649
- style: C({
650
- height: `${oe.value}px`,
651
- transform: `translateY(${v.value.total}px)`
643
+ style: R({
644
+ height: `${ie.value}px`,
645
+ transform: `translateY(${m.value.total}px)`
652
646
  }),
653
647
  role: "status",
654
648
  "aria-live": "polite"
655
649
  }, [
656
- X(t.$slots, "loading", {}, () => [
657
- o[4] || (o[4] = me("Loading more…", -1))
650
+ te(a.$slots, "loading", {}, () => [
651
+ t[4] || (t[4] = he("Loading more…", -1))
658
652
  ])
659
- ], 4)) : he("", !0)
660
- ], 4)) : (w(), b("div", {
653
+ ], 4)) : ve("", !0)
654
+ ], 4)) : (x(), T("div", {
661
655
  key: 2,
662
656
  class: "vue-dynamic-virtual-scroll__empty",
663
- style: C({ transform: `translateY(${m(u)}px)` })
657
+ style: R({ transform: `translateY(${v(r)}px)` })
664
658
  }, [
665
- X(t.$slots, "empty")
659
+ te(a.$slots, "empty")
666
660
  ], 4))
667
- ], 46, Ae));
661
+ ], 46, Re));
668
662
  }
669
- }), Oe = ["aria-label"], Ne = ["aria-current", "aria-posinset", "aria-setsize"], Ye = {
663
+ }), De = ["aria-label"], Pe = ["aria-current", "aria-posinset", "aria-setsize"], Ae = {
670
664
  key: 1,
671
665
  class: "vue-short-media-feed__empty"
672
- }, Fe = /* @__PURE__ */ ge({
666
+ }, Ne = /* @__PURE__ */ ge({
673
667
  name: "ShortMediaFeed",
674
668
  __name: "ShortMediaFeed",
675
669
  props: {
@@ -685,161 +679,161 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
685
679
  },
686
680
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
687
681
  setup(n, { expose: W, emit: k }) {
688
- const e = n, S = k, g = A(), x = A(0), u = A(K(e.activeIndex));
689
- let V, P = -1;
690
- const O = be(), { getItemKey: E } = xe({
682
+ const e = n, w = k, g = D(), b = D(0), r = D(K(e.activeIndex));
683
+ let H, N = -1;
684
+ const C = we(), { getItemKey: L } = xe({
691
685
  componentName: "ShortMediaFeed",
692
686
  items: () => e.items,
693
687
  itemKey: () => e.itemKey
694
- }), N = i(
688
+ }), A = s(
695
689
  () => Math.max(0, Math.floor(e.buffer))
696
- ), p = i(
690
+ ), h = s(
697
691
  () => Math.max(
698
692
  0,
699
693
  Math.floor(
700
694
  Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
701
695
  )
702
696
  )
703
- ), H = i(() => x.value > 0 ? x.value : typeof e.height == "number" ? Math.max(1, e.height) : 0), T = i(
704
- () => Math.max(0, u.value - N.value)
705
- ), B = i(
697
+ ), V = s(() => b.value > 0 ? b.value : typeof e.height == "number" ? Math.max(1, e.height) : 0), M = s(
698
+ () => Math.max(0, r.value - A.value)
699
+ ), S = s(
706
700
  () => Math.min(
707
701
  e.items.length,
708
- u.value + N.value + 1
702
+ r.value + A.value + 1
709
703
  )
710
- ), F = i(
711
- () => e.items.slice(T.value, B.value).map((c, v) => ({
712
- item: c,
713
- index: T.value + v
704
+ ), P = s(
705
+ () => e.items.slice(M.value, S.value).map((f, m) => ({
706
+ item: f,
707
+ index: M.value + m
714
708
  }))
715
- ), I = i(() => T.value * H.value), U = i(
716
- () => (e.items.length - B.value) * H.value
717
- ), ee = i(() => ({
718
- height: we(e.height)
709
+ ), Y = s(() => M.value * V.value), _ = s(
710
+ () => (e.items.length - S.value) * V.value
711
+ ), ae = s(() => ({
712
+ height: Te(e.height)
719
713
  }));
720
- function K(c) {
714
+ function K(f) {
721
715
  return e.items.length === 0 ? 0 : Math.min(
722
716
  e.items.length - 1,
723
- Math.max(0, Math.floor(Number.isFinite(c) ? c : 0))
717
+ Math.max(0, Math.floor(Number.isFinite(f) ? f : 0))
724
718
  );
725
719
  }
726
720
  function z() {
727
- if (!e.hasMore || e.loading || P === e.items.length)
721
+ if (!e.hasMore || e.loading || N === e.items.length)
728
722
  return;
729
- (e.items.length === 0 ? 0 : e.items.length - 1 - u.value) <= p.value && (P = e.items.length, S("loadMore"));
723
+ (e.items.length === 0 ? 0 : e.items.length - 1 - r.value) <= h.value && (N = e.items.length, w("loadMore"));
730
724
  }
731
- function te(c) {
732
- const v = K(c);
733
- v === u.value || e.items.length === 0 || (u.value = v, S("update:activeIndex", v), S("change", {
734
- index: v,
735
- item: e.items[v]
736
- }), v === 0 && S("reachStart"), v === e.items.length - 1 && S("reachEnd"), z());
725
+ function Q(f) {
726
+ const m = K(f);
727
+ m === r.value || e.items.length === 0 || (r.value = m, w("update:activeIndex", m), w("change", {
728
+ index: m,
729
+ item: e.items[m]
730
+ }), m === 0 && w("reachStart"), m === e.items.length - 1 && w("reachEnd"), z());
737
731
  }
738
- function G(c, v = {}) {
739
- const L = g.value;
740
- L && (typeof L.scrollTo == "function" ? L.scrollTo({ ...v, top: c }) : L.scrollTop = c);
732
+ function B(f, m = {}) {
733
+ const O = g.value;
734
+ O && (typeof O.scrollTo == "function" ? O.scrollTo({ ...m, top: f }) : O.scrollTop = f);
741
735
  }
742
- function J(c, v = {}) {
736
+ function q(f, m = {}) {
743
737
  if (e.items.length === 0) return;
744
- const L = K(c);
745
- te(L), G(L * H.value, v);
746
- }
747
- function _(c) {
748
- if (H.value <= 0) return;
749
- const v = c.currentTarget.scrollTop;
750
- te(Math.round(v / H.value));
751
- }
752
- function oe(c) {
753
- let v;
754
- c.key === "ArrowDown" || c.key === "PageDown" ? v = u.value + 1 : c.key === "ArrowUp" || c.key === "PageUp" ? v = u.value - 1 : c.key === "Home" ? v = 0 : c.key === "End" && (v = e.items.length - 1), v !== void 0 && (c.preventDefault(), J(v, { behavior: "smooth" }));
755
- }
756
- function Y() {
757
- var v;
758
- const c = ((v = g.value) == null ? void 0 : v.clientHeight) ?? 0;
759
- O(g.value, e.height), !(c <= 0 || c === x.value) && (x.value = c, $(() => {
760
- G(u.value * c);
738
+ const O = K(f);
739
+ Q(O), B(O * V.value, m);
740
+ }
741
+ function U(f) {
742
+ if (V.value <= 0) return;
743
+ const m = f.currentTarget.scrollTop;
744
+ Q(Math.round(m / V.value));
745
+ }
746
+ function ie(f) {
747
+ let m;
748
+ f.key === "ArrowDown" || f.key === "PageDown" ? m = r.value + 1 : f.key === "ArrowUp" || f.key === "PageUp" ? m = r.value - 1 : f.key === "Home" ? m = 0 : f.key === "End" && (m = e.items.length - 1), m !== void 0 && (f.preventDefault(), q(m, { behavior: "smooth" }));
749
+ }
750
+ function F() {
751
+ var m;
752
+ const f = ((m = g.value) == null ? void 0 : m.clientHeight) ?? 0;
753
+ C(g.value, e.height), !(f <= 0 || f === b.value) && (b.value = f, I(() => {
754
+ B(r.value * f);
761
755
  }));
762
756
  }
763
- return ae(
757
+ return Z(
764
758
  () => e.activeIndex,
765
- async (c) => {
766
- const v = K(c);
767
- v !== u.value && (u.value = v, await $(), G(v * H.value), z());
759
+ async (f) => {
760
+ const m = K(f);
761
+ m !== r.value && (r.value = m, await I(), B(m * V.value), z());
768
762
  }
769
- ), ae(
763
+ ), Z(
770
764
  () => [
771
765
  e.hasMore,
772
766
  e.loading,
773
767
  e.loadMoreThreshold
774
768
  ],
775
- async ([c]) => {
776
- c || (P = -1), await $(), z();
769
+ async ([f]) => {
770
+ f || (N = -1), await I(), z();
777
771
  }
778
- ), ae(
772
+ ), Z(
779
773
  () => e.items.length,
780
774
  async () => {
781
- const c = K(u.value);
782
- e.items.length === 0 ? u.value !== 0 && (u.value = 0, S("update:activeIndex", 0)) : te(c), await $(), G(c * H.value), z();
775
+ const f = K(r.value);
776
+ e.items.length === 0 ? r.value !== 0 && (r.value = 0, w("update:activeIndex", 0)) : Q(f), await I(), B(f * V.value), z();
783
777
  }
784
778
  ), pe(async () => {
785
- Y(), typeof ResizeObserver < "u" && g.value && (V = new ResizeObserver(Y), V.observe(g.value)), await $(), G(u.value * H.value), z();
779
+ F(), typeof ResizeObserver < "u" && g.value && (H = new ResizeObserver(F), H.observe(g.value)), await I(), B(r.value * V.value), z();
786
780
  }), ye(() => {
787
- V == null || V.disconnect();
781
+ H && (H.disconnect(), H = void 0);
788
782
  }), W({
789
- scrollToIndex: J
790
- }), (c, v) => (w(), b("div", {
783
+ scrollToIndex: q
784
+ }), (f, m) => (x(), T("div", {
791
785
  ref_key: "viewport",
792
786
  ref: g,
793
787
  class: "vue-short-media-feed",
794
- style: C(ee.value),
788
+ style: R(ae.value),
795
789
  role: "list",
796
790
  "aria-orientation": "vertical",
797
791
  "aria-label": n.ariaLabel,
798
792
  tabindex: "0",
799
- onScrollPassive: _,
800
- onKeydown: oe
793
+ onScrollPassive: U,
794
+ onKeydown: ie
801
795
  }, [
802
- n.items.length ? (w(), b(ve, { key: 0 }, [
803
- I.value > 0 ? (w(), b("div", {
796
+ n.items.length ? (x(), T(me, { key: 0 }, [
797
+ Y.value > 0 ? (x(), T("div", {
804
798
  key: 0,
805
799
  class: "vue-short-media-feed__spacer",
806
- style: C({ height: `${I.value}px` }),
800
+ style: R({ height: `${Y.value}px` }),
807
801
  "aria-hidden": "true"
808
- }, null, 4)) : he("", !0),
809
- (w(!0), b(ve, null, Me(F.value, ({ item: L, index: j }) => (w(), b("div", {
810
- key: m(E)(L, j),
802
+ }, null, 4)) : ve("", !0),
803
+ (x(!0), T(me, null, Me(P.value, ({ item: O, index: oe }) => (x(), T("div", {
804
+ key: v(L)(O, oe),
811
805
  class: "vue-short-media-feed__item",
812
- style: C({ height: `${H.value}px` }),
806
+ style: R({ height: `${V.value}px` }),
813
807
  role: "listitem",
814
- "aria-current": j === u.value ? "true" : void 0,
815
- "aria-posinset": j + 1,
808
+ "aria-current": oe === r.value ? "true" : void 0,
809
+ "aria-posinset": oe + 1,
816
810
  "aria-setsize": n.items.length
817
811
  }, [
818
- X(c.$slots, "default", {
819
- item: L,
820
- index: j,
821
- active: j === u.value
812
+ te(f.$slots, "default", {
813
+ item: O,
814
+ index: oe,
815
+ active: oe === r.value
822
816
  })
823
- ], 12, Ne))), 128)),
824
- U.value > 0 ? (w(), b("div", {
817
+ ], 12, Pe))), 128)),
818
+ _.value > 0 ? (x(), T("div", {
825
819
  key: 1,
826
820
  class: "vue-short-media-feed__spacer",
827
- style: C({ height: `${U.value}px` }),
821
+ style: R({ height: `${_.value}px` }),
828
822
  "aria-hidden": "true"
829
- }, null, 4)) : he("", !0)
830
- ], 64)) : (w(), b("div", Ye, [
831
- X(c.$slots, "empty")
823
+ }, null, 4)) : ve("", !0)
824
+ ], 64)) : (x(), T("div", Ae, [
825
+ te(f.$slots, "empty")
832
826
  ]))
833
- ], 44, Oe));
827
+ ], 44, De));
834
828
  }
835
- }), We = ["aria-label"], _e = {
829
+ }), Ye = ["aria-label"], Fe = {
836
830
  key: 0,
837
831
  class: "vue-virtual-carousel__track",
838
832
  role: "list"
839
- }, Ue = ["aria-label", "aria-current"], je = {
833
+ }, We = ["aria-label", "aria-current"], _e = {
840
834
  key: 1,
841
835
  class: "vue-virtual-carousel__empty"
842
- }, Ze = /* @__PURE__ */ ge({
836
+ }, Ue = /* @__PURE__ */ ge({
843
837
  name: "VirtualCarousel",
844
838
  __name: "VirtualCarousel",
845
839
  props: {
@@ -854,229 +848,315 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
854
848
  ariaLabel: { default: "Carousel" },
855
849
  hasMore: { type: Boolean, default: !1 },
856
850
  loading: { type: Boolean, default: !1 },
857
- loadMoreThreshold: { default: 2 }
851
+ loadMoreThreshold: { default: 2 },
852
+ autoplay: { type: Boolean, default: !1 },
853
+ autoplayDelay: { default: 3e3 },
854
+ autoplayLoop: { type: Boolean, default: !0 },
855
+ pauseOnHover: { type: Boolean, default: !0 },
856
+ responsive: { default: void 0 }
858
857
  },
859
858
  emits: ["update:activeIndex", "change", "reachStart", "reachEnd", "loadMore"],
860
859
  setup(n, { expose: W, emit: k }) {
861
- const e = n, S = k, g = A(), x = A(0), u = A(0);
862
- let V, P = -1;
863
- const { getItemKey: O } = xe({
860
+ const e = n, w = k, g = D(), b = D(0), r = D(0);
861
+ let H, N = -1, C, L, A = !1;
862
+ const h = D(!1), { getItemKey: V } = xe({
864
863
  componentName: "VirtualCarousel",
865
864
  items: () => e.items,
866
865
  itemKey: () => e.itemKey
867
- }), E = i(
866
+ }), M = s(() => Math.max(0, b.value)), S = s(() => {
867
+ if (!e.responsive || e.responsive.length === 0)
868
+ return {
869
+ slidesPerView: e.slidesPerView,
870
+ slidesToScroll: e.slidesToScroll,
871
+ gap: e.gap
872
+ };
873
+ const t = M.value, l = [...e.responsive].sort(
874
+ (i, d) => d.breakpoint - i.breakpoint
875
+ );
876
+ for (const i of l)
877
+ if (t >= i.breakpoint)
878
+ return {
879
+ slidesPerView: i.slidesPerView ?? e.slidesPerView,
880
+ slidesToScroll: i.slidesToScroll ?? e.slidesToScroll,
881
+ gap: i.gap ?? e.gap
882
+ };
883
+ return {
884
+ slidesPerView: e.slidesPerView,
885
+ slidesToScroll: e.slidesToScroll,
886
+ gap: e.gap
887
+ };
888
+ }), P = s(
868
889
  () => Math.max(
869
890
  1,
870
891
  Math.floor(
871
- Number.isFinite(e.slidesPerView) ? e.slidesPerView : 1
892
+ Number.isFinite(S.value.slidesPerView) ? S.value.slidesPerView : 1
872
893
  )
873
894
  )
874
- ), N = i(
895
+ ), Y = s(
875
896
  () => Math.max(
876
897
  1,
877
898
  Math.floor(
878
- Number.isFinite(e.slidesToScroll) ? e.slidesToScroll : 1
899
+ Number.isFinite(S.value.slidesToScroll) ? S.value.slidesToScroll : 1
879
900
  )
880
901
  )
881
- ), p = i(
882
- () => Math.max(0, Number.isFinite(e.gap) ? e.gap : 0)
883
- ), H = i(
902
+ ), _ = s(
903
+ () => Math.max(0, Number.isFinite(S.value.gap) ? S.value.gap : 0)
904
+ ), ae = s(
884
905
  () => Math.max(
885
906
  0,
886
907
  Math.floor(Number.isFinite(e.buffer) ? e.buffer : 0)
887
908
  )
888
- ), T = i(
909
+ ), K = s(
889
910
  () => Math.max(
890
911
  0,
891
912
  Math.floor(
892
913
  Number.isFinite(e.loadMoreThreshold) ? e.loadMoreThreshold : 0
893
914
  )
894
915
  )
895
- ), B = i(() => Math.max(0, x.value)), F = i(() => {
896
- if (B.value <= 0) return 0;
897
- const d = (E.value - 1) * p.value;
916
+ ), z = s(() => Number.isFinite(e.autoplayDelay) ? Math.max(1, e.autoplayDelay) : 3e3), Q = s(() => {
917
+ if (M.value <= 0) return 0;
918
+ const t = (P.value - 1) * _.value;
898
919
  return Math.max(
899
920
  1,
900
- (B.value - d) / E.value
921
+ (M.value - t) / P.value
901
922
  );
902
- }), I = i(() => F.value + p.value), U = i(
923
+ }), B = s(() => Q.value + _.value), q = s(
903
924
  () => Math.max(
904
925
  0,
905
- e.items.length - E.value
926
+ e.items.length - P.value
906
927
  )
907
- ), ee = i(
908
- () => Math.max(0, u.value - H.value)
909
- ), K = i(
928
+ ), U = s(
929
+ () => Math.max(0, r.value - ae.value)
930
+ ), ie = s(
910
931
  () => Math.min(
911
932
  e.items.length,
912
- u.value + E.value + H.value
933
+ r.value + P.value + ae.value
913
934
  )
914
- ), z = i(
915
- () => e.items.slice(ee.value, K.value).map((d, s) => ({
916
- item: d,
917
- index: ee.value + s
935
+ ), F = s(
936
+ () => e.items.slice(U.value, ie.value).map((t, l) => ({
937
+ item: t,
938
+ index: U.value + l
918
939
  }))
919
- ), te = i(() => e.items.length === 0 ? 0 : e.items.length * F.value + (e.items.length - 1) * p.value), G = i(
920
- () => ee.value * I.value
921
- ), J = i(
940
+ ), f = s(() => e.items.length === 0 ? 0 : e.items.length * Q.value + (e.items.length - 1) * _.value), m = s(
941
+ () => U.value * B.value
942
+ ), O = s(
922
943
  () => Math.max(
923
944
  0,
924
- te.value - K.value * I.value
945
+ f.value - ie.value * B.value
925
946
  )
926
- ), _ = i(() => ({
927
- height: we(e.height)
947
+ ), oe = s(() => ({
948
+ height: Te(e.height)
928
949
  }));
929
- function oe(d) {
950
+ function le(t) {
930
951
  return Math.min(
931
- U.value,
932
- Math.max(0, Math.floor(Number.isFinite(d) ? d : 0))
952
+ q.value,
953
+ Math.max(0, Math.floor(Number.isFinite(t) ? t : 0))
933
954
  );
934
955
  }
935
- u.value = oe(e.activeIndex);
936
- function Y(d) {
937
- return d >= u.value && d < Math.min(
956
+ r.value = le(e.activeIndex);
957
+ function ue(t) {
958
+ return t >= r.value && t < Math.min(
938
959
  e.items.length,
939
- u.value + E.value
960
+ r.value + P.value
940
961
  );
941
962
  }
942
- function c() {
943
- if (!e.hasMore || e.loading || P === e.items.length)
963
+ function X() {
964
+ if (!e.hasMore || e.loading || N === e.items.length)
944
965
  return;
945
- const d = e.items.length === 0 ? -1 : Math.min(
966
+ const t = e.items.length === 0 ? -1 : Math.min(
946
967
  e.items.length - 1,
947
- u.value + E.value - 1
968
+ r.value + P.value - 1
948
969
  );
949
- e.items.length - 1 - d <= T.value && (P = e.items.length, S("loadMore"));
950
- }
951
- function v(d) {
952
- const s = oe(d);
953
- s === u.value || e.items.length === 0 || (u.value = s, S("update:activeIndex", s), S("change", {
954
- index: s,
955
- item: e.items[s]
956
- }), s === 0 && S("reachStart"), s === U.value && S("reachEnd"), c());
957
- }
958
- function L(d, s = {}) {
959
- const h = g.value;
960
- h && (typeof h.scrollTo == "function" ? h.scrollTo({ ...s, left: d }) : h.scrollLeft = d);
961
- }
962
- function j(d, s = {}) {
963
- if (e.items.length === 0 || I.value <= 0) return;
964
- const h = oe(d), a = Math.abs(h - u.value), f = s.behavior === "smooth" && a > H.value ? "auto" : s.behavior;
965
- v(h), L(h * I.value, {
966
- ...s,
967
- behavior: f
970
+ e.items.length - 1 - t <= K.value && (N = e.items.length, w("loadMore"));
971
+ }
972
+ function ce(t) {
973
+ const l = le(t);
974
+ l === r.value || e.items.length === 0 || (r.value = l, w("update:activeIndex", l), w("change", {
975
+ index: l,
976
+ item: e.items[l]
977
+ }), l === 0 && w("reachStart"), l === q.value && w("reachEnd"), X(), e.autoplay && !h.value && o());
978
+ }
979
+ function G(t, l = {}) {
980
+ const i = g.value;
981
+ i && (typeof i.scrollTo == "function" ? i.scrollTo({ ...l, left: t }) : i.scrollLeft = t);
982
+ }
983
+ function ne(t, l = {}) {
984
+ if (e.items.length === 0 || B.value <= 0) return;
985
+ const i = le(t);
986
+ L = l.behavior === "smooth" ? i : void 0, ce(i), G(i * B.value, {
987
+ ...l,
988
+ behavior: l.behavior
968
989
  });
969
990
  }
970
- function re(d = "smooth") {
971
- j(
972
- u.value + N.value,
973
- { behavior: d }
991
+ function p(t = "smooth") {
992
+ ne(
993
+ r.value + Y.value,
994
+ { behavior: t }
974
995
  );
975
996
  }
976
- function se(d = "smooth") {
977
- j(
978
- u.value - N.value,
979
- { behavior: d }
997
+ function y(t = "smooth") {
998
+ ne(
999
+ r.value - Y.value,
1000
+ { behavior: t }
980
1001
  );
981
1002
  }
982
- function ne(d) {
983
- if (I.value <= 0) return;
984
- const s = d.currentTarget.scrollLeft;
985
- v(Math.round(s / I.value));
1003
+ function o() {
1004
+ c(), !(!e.autoplay || e.items.length === 0) && (C = setTimeout(() => {
1005
+ r.value >= q.value ? e.autoplayLoop ? ne(0, { behavior: "smooth" }) : c() : p("smooth");
1006
+ }, z.value));
986
1007
  }
987
- function fe(d) {
988
- d.key === "ArrowRight" || d.key === "PageDown" ? (d.preventDefault(), re()) : d.key === "ArrowLeft" || d.key === "PageUp" ? (d.preventDefault(), se()) : d.key === "Home" ? (d.preventDefault(), j(0, { behavior: "smooth" })) : d.key === "End" && (d.preventDefault(), j(U.value, { behavior: "auto" }));
1008
+ function c() {
1009
+ C !== void 0 && (clearTimeout(C), C = void 0);
989
1010
  }
990
- function le() {
991
- var s;
992
- const d = ((s = g.value) == null ? void 0 : s.clientWidth) ?? 0;
993
- d <= 0 || d === x.value || (x.value = d, $(() => {
994
- L(u.value * I.value);
1011
+ function u() {
1012
+ h.value = !0, e.pauseOnHover && c();
1013
+ }
1014
+ function E() {
1015
+ h.value = !1, e.autoplay && o();
1016
+ }
1017
+ function $() {
1018
+ L = void 0;
1019
+ }
1020
+ function j(t) {
1021
+ if (B.value <= 0 || A) return;
1022
+ const l = t.currentTarget.scrollLeft;
1023
+ if (L !== void 0) {
1024
+ const i = L * B.value;
1025
+ if (Math.abs(l - i) > 1) return;
1026
+ L = void 0;
1027
+ }
1028
+ ce(Math.round(l / B.value));
1029
+ }
1030
+ function se(t) {
1031
+ t.key === "ArrowRight" || t.key === "PageDown" ? (t.preventDefault(), p()) : t.key === "ArrowLeft" || t.key === "PageUp" ? (t.preventDefault(), y()) : t.key === "Home" ? (t.preventDefault(), ne(0, { behavior: "smooth" })) : t.key === "End" && (t.preventDefault(), ne(q.value, { behavior: "auto" }));
1032
+ }
1033
+ function a() {
1034
+ var l;
1035
+ const t = ((l = g.value) == null ? void 0 : l.clientWidth) ?? 0;
1036
+ t <= 0 || t === b.value || (A = !0, b.value = t, I(() => {
1037
+ const i = le(r.value);
1038
+ G(i * B.value), A = !1;
995
1039
  }));
996
1040
  }
997
- return ae(
1041
+ return Z(
998
1042
  () => e.activeIndex,
999
- async (d) => {
1000
- const s = oe(d);
1001
- s !== u.value && (u.value = s, await $(), L(s * I.value), c());
1043
+ async (t) => {
1044
+ const l = le(t);
1045
+ l !== r.value && ($(), r.value = l, await I(), G(l * B.value), X());
1002
1046
  }
1003
- ), ae(
1047
+ ), Z(
1004
1048
  () => [
1005
1049
  e.items.length,
1006
- e.slidesPerView,
1007
- e.gap
1050
+ S.value.slidesPerView,
1051
+ S.value.gap,
1052
+ S.value.slidesToScroll
1008
1053
  ],
1009
1054
  async () => {
1010
- const d = oe(u.value);
1011
- e.items.length === 0 ? u.value !== 0 && (u.value = 0, S("update:activeIndex", 0)) : v(d), await $(), L(d * I.value), c();
1055
+ const t = le(r.value);
1056
+ e.items.length === 0 ? r.value !== 0 && (r.value = 0, w("update:activeIndex", 0)) : ce(t), await I(), G(t * B.value), X(), e.autoplay && e.items.length > 0 && !h.value && o();
1012
1057
  }
1013
- ), ae(
1058
+ ), Z(
1059
+ () => e.responsive,
1060
+ () => {
1061
+ I(() => {
1062
+ const t = le(r.value);
1063
+ G(t * B.value);
1064
+ });
1065
+ },
1066
+ { deep: !0 }
1067
+ ), Z(
1014
1068
  () => [
1015
1069
  e.hasMore,
1016
1070
  e.loading,
1017
1071
  e.loadMoreThreshold
1018
1072
  ],
1019
- async ([d]) => {
1020
- d || (P = -1), await $(), c();
1073
+ async ([t]) => {
1074
+ t || (N = -1), await I(), X();
1075
+ }
1076
+ ), Z(
1077
+ () => e.autoplay,
1078
+ (t) => {
1079
+ t && !h.value ? o() : c();
1080
+ }
1081
+ ), Z(
1082
+ () => e.autoplayDelay,
1083
+ () => {
1084
+ e.autoplay && !h.value && o();
1085
+ }
1086
+ ), Z(
1087
+ () => e.autoplayLoop,
1088
+ (t) => {
1089
+ !e.autoplay || h.value || (!t && r.value >= q.value ? c() : o());
1090
+ }
1091
+ ), Z(
1092
+ () => e.pauseOnHover,
1093
+ (t) => {
1094
+ t && h.value ? c() : !t && e.autoplay && o();
1021
1095
  }
1022
1096
  ), pe(async () => {
1023
- le(), typeof ResizeObserver < "u" && g.value && (V = new ResizeObserver(le), V.observe(g.value)), await $(), L(u.value * I.value), c();
1097
+ a(), typeof ResizeObserver < "u" && g.value && (H = new ResizeObserver(a), H.observe(g.value)), await I(), G(r.value * B.value), X(), e.autoplay && o();
1024
1098
  }), ye(() => {
1025
- V == null || V.disconnect();
1099
+ H && (H.disconnect(), H = void 0), c();
1026
1100
  }), W({
1027
- next: re,
1028
- previous: se,
1029
- scrollToIndex: j
1030
- }), (d, s) => (w(), b("div", {
1101
+ next: p,
1102
+ previous: y,
1103
+ scrollToIndex: ne,
1104
+ startAutoplay: o,
1105
+ stopAutoplay: c
1106
+ }), (t, l) => (x(), T("div", {
1031
1107
  ref_key: "viewport",
1032
1108
  ref: g,
1033
1109
  class: "vue-virtual-carousel",
1034
- style: C(_.value),
1110
+ style: R(oe.value),
1035
1111
  role: "region",
1036
1112
  "aria-roledescription": "carousel",
1037
1113
  "aria-label": n.ariaLabel,
1038
1114
  tabindex: "0",
1039
- onScrollPassive: ne,
1040
- onKeydown: fe
1115
+ onScrollPassive: j,
1116
+ onPointerdown: $,
1117
+ onWheelPassive: $,
1118
+ onKeydown: se,
1119
+ onMouseenter: u,
1120
+ onMouseleave: E
1041
1121
  }, [
1042
- n.items.length ? (w(), b("div", _e, [
1043
- G.value > 0 ? (w(), b("div", {
1122
+ n.items.length ? (x(), T("div", Fe, [
1123
+ m.value > 0 ? (x(), T("div", {
1044
1124
  key: 0,
1045
1125
  class: "vue-virtual-carousel__spacer",
1046
- style: C({ flexBasis: `${G.value}px` }),
1126
+ style: R({ flexBasis: `${m.value}px` }),
1047
1127
  "aria-hidden": "true"
1048
- }, null, 4)) : he("", !0),
1049
- (w(!0), b(ve, null, Me(z.value, ({ item: h, index: a }) => (w(), b("div", {
1050
- key: m(O)(h, a),
1128
+ }, null, 4)) : ve("", !0),
1129
+ (x(!0), T(me, null, Me(F.value, ({ item: i, index: d }) => (x(), T("div", {
1130
+ key: v(V)(i, d),
1051
1131
  class: "vue-virtual-carousel__item",
1052
- style: C({
1053
- flexBasis: `${F.value}px`,
1054
- marginRight: a < n.items.length - 1 ? `${p.value}px` : "0px"
1132
+ style: R({
1133
+ flexBasis: `${Q.value}px`,
1134
+ marginRight: d < n.items.length - 1 ? `${_.value}px` : "0px"
1055
1135
  }),
1056
1136
  role: "listitem",
1057
1137
  "aria-roledescription": "slide",
1058
- "aria-label": `${a + 1} of ${n.items.length}`,
1059
- "aria-current": a === u.value ? "true" : void 0
1138
+ "aria-label": `${d + 1} of ${n.items.length}`,
1139
+ "aria-current": d === r.value ? "true" : void 0
1060
1140
  }, [
1061
- X(d.$slots, "default", {
1062
- item: h,
1063
- index: a,
1064
- active: a === u.value,
1065
- visible: Y(a)
1141
+ te(t.$slots, "default", {
1142
+ item: i,
1143
+ index: d,
1144
+ active: d === r.value,
1145
+ visible: ue(d)
1066
1146
  })
1067
- ], 12, Ue))), 128)),
1068
- J.value > 0 ? (w(), b("div", {
1147
+ ], 12, We))), 128)),
1148
+ O.value > 0 ? (x(), T("div", {
1069
1149
  key: 1,
1070
1150
  class: "vue-virtual-carousel__spacer",
1071
- style: C({ flexBasis: `${J.value}px` }),
1151
+ style: R({ flexBasis: `${O.value}px` }),
1072
1152
  "aria-hidden": "true"
1073
- }, null, 4)) : he("", !0)
1074
- ])) : (w(), b("div", je, [
1075
- X(d.$slots, "empty")
1153
+ }, null, 4)) : ve("", !0)
1154
+ ])) : (x(), T("div", _e, [
1155
+ te(t.$slots, "empty")
1076
1156
  ]))
1077
- ], 44, We));
1157
+ ], 44, Ye));
1078
1158
  }
1079
- }), qe = ["aria-label"], Ge = ["aria-posinset", "aria-setsize"], Je = /* @__PURE__ */ ge({
1159
+ }), je = ["aria-label"], Ze = ["aria-posinset", "aria-setsize"], qe = /* @__PURE__ */ ge({
1080
1160
  name: "VirtualScroll",
1081
1161
  __name: "VirtualScroll",
1082
1162
  props: {
@@ -1096,209 +1176,209 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
1096
1176
  },
1097
1177
  emits: ["scroll", "loadMore", "refresh"],
1098
1178
  setup(n, { expose: W, emit: k }) {
1099
- const e = n, S = k, {
1179
+ const e = n, w = k, {
1100
1180
  pulling: g,
1101
- pullDistance: x,
1102
- pullOffset: u,
1103
- pullProgress: V,
1104
- refreshMessage: P,
1105
- refreshThreshold: O,
1106
- handleTouchStart: E,
1107
- handleTouchMove: N,
1108
- handleTouchEnd: p,
1109
- handleTouchCancel: H
1110
- } = He({
1181
+ pullDistance: b,
1182
+ pullOffset: r,
1183
+ pullProgress: H,
1184
+ refreshMessage: N,
1185
+ refreshThreshold: C,
1186
+ handleTouchStart: L,
1187
+ handleTouchMove: A,
1188
+ handleTouchEnd: h,
1189
+ handleTouchCancel: V
1190
+ } = ke({
1111
1191
  enabled: () => e.pullToRefresh,
1112
1192
  refreshing: () => e.refreshing,
1113
1193
  threshold: () => e.pullRefreshThreshold,
1114
- onRefresh: () => S("refresh")
1115
- }), T = A(), B = A(0), F = A(0);
1116
- let I, U = -1;
1117
- const ee = be(), { getItemKey: K } = xe({
1194
+ onRefresh: () => w("refresh")
1195
+ }), M = D(), S = D(0), P = D(0);
1196
+ let Y, _ = -1;
1197
+ const ae = we(), { getItemKey: K } = xe({
1118
1198
  componentName: "VirtualScroll",
1119
1199
  items: () => e.items,
1120
1200
  itemKey: () => e.itemKey
1121
- }), z = i(() => Math.max(1, e.itemSize)), te = i(() => Math.max(0, Math.floor(e.overscan))), G = i(
1201
+ }), z = s(() => Math.max(1, e.itemSize)), Q = s(() => Math.max(0, Math.floor(e.overscan))), B = s(
1122
1202
  () => e.items.length * z.value
1123
- ), J = i(
1203
+ ), q = s(
1124
1204
  () => Math.max(1, e.loadingItemSize ?? z.value)
1125
- ), _ = i(
1126
- () => G.value + (e.loading ? J.value : 0)
1127
- ), oe = i(() => F.value > 0 ? F.value : typeof e.height == "number" ? e.height : 0), Y = i(
1205
+ ), U = s(
1206
+ () => B.value + (e.loading ? q.value : 0)
1207
+ ), ie = s(() => P.value > 0 ? P.value : typeof e.height == "number" ? e.height : 0), F = s(
1128
1208
  () => Math.max(
1129
1209
  0,
1130
- Math.floor(B.value / z.value) - te.value
1210
+ Math.floor(S.value / z.value) - Q.value
1131
1211
  )
1132
- ), c = i(() => {
1133
- const s = Math.ceil(
1134
- (B.value + oe.value) / z.value
1212
+ ), f = s(() => {
1213
+ const p = Math.ceil(
1214
+ (S.value + ie.value) / z.value
1135
1215
  );
1136
1216
  return Math.min(
1137
1217
  e.items.length,
1138
- s + te.value
1218
+ p + Q.value
1139
1219
  );
1140
- }), v = i(
1141
- () => e.items.slice(Y.value, c.value).map((s, h) => ({
1142
- item: s,
1143
- index: Y.value + h
1220
+ }), m = s(
1221
+ () => e.items.slice(F.value, f.value).map((p, y) => ({
1222
+ item: p,
1223
+ index: F.value + y
1144
1224
  }))
1145
- ), L = i(() => ({
1146
- height: we(e.height)
1147
- })), j = i(() => ({
1148
- transform: `translateY(${Y.value * z.value}px)`
1225
+ ), O = s(() => ({
1226
+ height: Te(e.height)
1227
+ })), oe = s(() => ({
1228
+ transform: `translateY(${F.value * z.value}px)`
1149
1229
  }));
1150
- function re() {
1151
- var s;
1152
- F.value = ((s = T.value) == null ? void 0 : s.clientHeight) ?? 0, ee(T.value, e.height), $(ne);
1153
- }
1154
- function se(s) {
1155
- B.value = s.currentTarget.scrollTop, S("scroll", {
1156
- scrollTop: B.value,
1157
- startIndex: Y.value,
1158
- endIndex: c.value
1159
- }), ne();
1160
- }
1161
- function ne() {
1162
- const s = T.value;
1163
- if (!s || !e.hasMore || e.loading || U === e.items.length)
1230
+ function le() {
1231
+ var p;
1232
+ P.value = ((p = M.value) == null ? void 0 : p.clientHeight) ?? 0, ae(M.value, e.height), I(X);
1233
+ }
1234
+ function ue(p) {
1235
+ S.value = p.currentTarget.scrollTop, w("scroll", {
1236
+ scrollTop: S.value,
1237
+ startIndex: F.value,
1238
+ endIndex: f.value
1239
+ }), X();
1240
+ }
1241
+ function X() {
1242
+ const p = M.value;
1243
+ if (!p || !e.hasMore || e.loading || _ === e.items.length)
1164
1244
  return;
1165
- const h = Math.max(0, e.loadMoreThreshold);
1166
- _.value - s.scrollTop - s.clientHeight <= h && (U = e.items.length, S("loadMore"));
1167
- }
1168
- function fe(s, h = {}) {
1169
- const a = T.value;
1170
- if (!a) return;
1171
- const f = Math.max(0, _.value - a.clientHeight), r = Math.min(
1172
- Math.max(0, Number.isFinite(s) ? s : 0),
1173
- f
1174
- ), D = h.behavior ?? "auto";
1175
- D === "auto" && (B.value = r), a.scrollTo({ ...h, top: r, behavior: D });
1176
- }
1177
- function le(s, h = {}) {
1178
- const a = T.value;
1179
- if (!a || e.items.length === 0) return;
1180
- const f = Math.min(
1245
+ const y = Math.max(0, e.loadMoreThreshold);
1246
+ U.value - p.scrollTop - p.clientHeight <= y && (_ = e.items.length, w("loadMore"));
1247
+ }
1248
+ function ce(p, y = {}) {
1249
+ const o = M.value;
1250
+ if (!o) return;
1251
+ const c = Math.max(0, U.value - o.clientHeight), u = Math.min(
1252
+ Math.max(0, Number.isFinite(p) ? p : 0),
1253
+ c
1254
+ ), E = y.behavior ?? "auto";
1255
+ E === "auto" && (S.value = u), o.scrollTo({ ...y, top: u, behavior: E });
1256
+ }
1257
+ function G(p, y = {}) {
1258
+ const o = M.value;
1259
+ if (!o || e.items.length === 0) return;
1260
+ const c = Math.min(
1181
1261
  e.items.length - 1,
1182
- Math.max(0, Math.floor(s))
1183
- ), { align: r = "start", ...D } = h;
1184
- let R = f * z.value;
1185
- r === "center" ? R -= (a.clientHeight - z.value) / 2 : r === "end" && (R -= a.clientHeight - z.value), a.scrollTo({
1186
- ...D,
1187
- top: Math.max(0, Math.min(R, _.value - a.clientHeight))
1262
+ Math.max(0, Math.floor(p))
1263
+ ), { align: u = "start", ...E } = y;
1264
+ let $ = c * z.value;
1265
+ u === "center" ? $ -= (o.clientHeight - z.value) / 2 : u === "end" && ($ -= o.clientHeight - z.value), o.scrollTo({
1266
+ ...E,
1267
+ top: Math.max(0, Math.min($, U.value - o.clientHeight))
1188
1268
  });
1189
1269
  }
1190
- function d(s = "auto") {
1191
- var h;
1192
- (h = T.value) == null || h.scrollTo({ top: 0, behavior: s });
1270
+ function ne(p = "auto") {
1271
+ var y;
1272
+ (y = M.value) == null || y.scrollTo({ top: 0, behavior: p });
1193
1273
  }
1194
- return ae(
1274
+ return Z(
1195
1275
  () => [e.items.length, e.itemSize],
1196
1276
  async () => {
1197
- await $();
1198
- const s = T.value;
1199
- if (!s) return;
1200
- const h = Math.max(0, _.value - s.clientHeight);
1201
- s.scrollTop > h && (s.scrollTop = h, B.value = h), ne();
1277
+ await I();
1278
+ const p = M.value;
1279
+ if (!p) return;
1280
+ const y = Math.max(0, U.value - p.clientHeight);
1281
+ p.scrollTop > y && (p.scrollTop = y, S.value = y), X();
1202
1282
  }
1203
- ), ae(
1283
+ ), Z(
1204
1284
  () => [e.hasMore, e.loading],
1205
- async ([s]) => {
1206
- s || (U = -1), await $(), ne();
1285
+ async ([p]) => {
1286
+ p || (_ = -1), await I(), X();
1207
1287
  }
1208
1288
  ), pe(() => {
1209
- re(), typeof ResizeObserver < "u" && T.value && (I = new ResizeObserver(re), I.observe(T.value)), $(ne);
1289
+ le(), typeof ResizeObserver < "u" && M.value && (Y = new ResizeObserver(le), Y.observe(M.value)), I(X);
1210
1290
  }), ye(() => {
1211
- I == null || I.disconnect();
1291
+ Y && (Y.disconnect(), Y = void 0);
1212
1292
  }), W({
1213
- scrollTo: fe,
1214
- scrollToIndex: le,
1215
- scrollToTop: d
1216
- }), (s, h) => (w(), b("div", {
1293
+ scrollTo: ce,
1294
+ scrollToIndex: G,
1295
+ scrollToTop: ne
1296
+ }), (p, y) => (x(), T("div", {
1217
1297
  ref_key: "viewport",
1218
- ref: T,
1219
- class: $e(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": m(g) }]),
1220
- style: C(L.value),
1298
+ ref: M,
1299
+ class: Ie(["vue-virtual-scroll", { "vue-virtual-scroll--pulling": v(g) }]),
1300
+ style: R(O.value),
1221
1301
  role: "list",
1222
1302
  "aria-label": n.ariaLabel,
1223
1303
  tabindex: "0",
1224
- onScrollPassive: se,
1225
- onTouchstartPassive: h[0] || (h[0] = //@ts-ignore
1226
- (...a) => m(E) && m(E)(...a)),
1227
- onTouchmove: h[1] || (h[1] = //@ts-ignore
1228
- (...a) => m(N) && m(N)(...a)),
1229
- onTouchend: h[2] || (h[2] = //@ts-ignore
1230
- (...a) => m(p) && m(p)(...a)),
1231
- onTouchcancel: h[3] || (h[3] = //@ts-ignore
1232
- (...a) => m(H) && m(H)(...a))
1304
+ onScrollPassive: ue,
1305
+ onTouchstartPassive: y[0] || (y[0] = //@ts-ignore
1306
+ (...o) => v(L) && v(L)(...o)),
1307
+ onTouchmove: y[1] || (y[1] = //@ts-ignore
1308
+ (...o) => v(A) && v(A)(...o)),
1309
+ onTouchend: y[2] || (y[2] = //@ts-ignore
1310
+ (...o) => v(h) && v(h)(...o)),
1311
+ onTouchcancel: y[3] || (y[3] = //@ts-ignore
1312
+ (...o) => v(V) && v(V)(...o))
1233
1313
  }, [
1234
- n.pullToRefresh || n.refreshing ? (w(), b("div", {
1314
+ n.pullToRefresh || n.refreshing ? (x(), T("div", {
1235
1315
  key: 0,
1236
1316
  class: "vue-virtual-scroll__refresh",
1237
- style: C({
1238
- height: `${m(O)}px`,
1239
- transform: `translateY(${m(u) - m(O)}px)`
1317
+ style: R({
1318
+ height: `${v(C)}px`,
1319
+ transform: `translateY(${v(r) - v(C)}px)`
1240
1320
  }),
1241
1321
  role: "status",
1242
1322
  "aria-live": "polite"
1243
1323
  }, [
1244
- X(s.$slots, "refresh", {
1245
- pullDistance: m(x),
1246
- progress: m(V),
1324
+ te(p.$slots, "refresh", {
1325
+ pullDistance: v(b),
1326
+ progress: v(H),
1247
1327
  refreshing: n.refreshing
1248
1328
  }, () => [
1249
- me(ke(m(P)), 1)
1329
+ he(ze(v(N)), 1)
1250
1330
  ])
1251
- ], 4)) : he("", !0),
1252
- n.items.length || n.loading ? (w(), b("div", {
1331
+ ], 4)) : ve("", !0),
1332
+ n.items.length || n.loading ? (x(), T("div", {
1253
1333
  key: 1,
1254
1334
  class: "vue-virtual-scroll__spacer",
1255
- style: C({
1256
- height: `${_.value}px`,
1257
- transform: `translateY(${m(u)}px)`
1335
+ style: R({
1336
+ height: `${U.value}px`,
1337
+ transform: `translateY(${v(r)}px)`
1258
1338
  })
1259
1339
  }, [
1260
- Be("div", {
1340
+ $e("div", {
1261
1341
  class: "vue-virtual-scroll__content",
1262
- style: C(j.value)
1342
+ style: R(oe.value)
1263
1343
  }, [
1264
- (w(!0), b(ve, null, Me(v.value, ({ item: a, index: f }) => (w(), b("div", {
1265
- key: m(K)(a, f),
1344
+ (x(!0), T(me, null, Me(m.value, ({ item: o, index: c }) => (x(), T("div", {
1345
+ key: v(K)(o, c),
1266
1346
  class: "vue-virtual-scroll__item",
1267
- style: C({ height: `${z.value}px` }),
1347
+ style: R({ height: `${z.value}px` }),
1268
1348
  role: "listitem",
1269
- "aria-posinset": f + 1,
1349
+ "aria-posinset": c + 1,
1270
1350
  "aria-setsize": n.items.length
1271
1351
  }, [
1272
- X(s.$slots, "default", {
1273
- item: a,
1274
- index: f
1352
+ te(p.$slots, "default", {
1353
+ item: o,
1354
+ index: c
1275
1355
  })
1276
- ], 12, Ge))), 128))
1356
+ ], 12, Ze))), 128))
1277
1357
  ], 4),
1278
- n.loading ? (w(), b("div", {
1358
+ n.loading ? (x(), T("div", {
1279
1359
  key: 0,
1280
1360
  class: "vue-virtual-scroll__loading",
1281
- style: C({
1282
- height: `${J.value}px`,
1283
- transform: `translateY(${G.value}px)`
1361
+ style: R({
1362
+ height: `${q.value}px`,
1363
+ transform: `translateY(${B.value}px)`
1284
1364
  }),
1285
1365
  role: "status",
1286
1366
  "aria-live": "polite"
1287
1367
  }, [
1288
- X(s.$slots, "loading", {}, () => [
1289
- h[4] || (h[4] = me("Loading more…", -1))
1368
+ te(p.$slots, "loading", {}, () => [
1369
+ y[4] || (y[4] = he("Loading more…", -1))
1290
1370
  ])
1291
- ], 4)) : he("", !0)
1292
- ], 4)) : (w(), b("div", {
1371
+ ], 4)) : ve("", !0)
1372
+ ], 4)) : (x(), T("div", {
1293
1373
  key: 2,
1294
1374
  class: "vue-virtual-scroll__empty",
1295
- style: C({ transform: `translateY(${m(u)}px)` })
1375
+ style: R({ transform: `translateY(${v(r)}px)` })
1296
1376
  }, [
1297
- X(s.$slots, "empty")
1377
+ te(p.$slots, "empty")
1298
1378
  ], 4))
1299
- ], 46, qe));
1379
+ ], 46, je));
1300
1380
  }
1301
- }), Qe = ["aria-label"], Xe = ["aria-posinset", "aria-setsize"], et = /* @__PURE__ */ ge({
1381
+ }), Ge = ["aria-label"], Je = ["aria-posinset", "aria-setsize"], Qe = /* @__PURE__ */ ge({
1302
1382
  name: "WindowDynamicVirtualScroll",
1303
1383
  __name: "WindowDynamicVirtualScroll",
1304
1384
  props: {
@@ -1317,312 +1397,309 @@ const Ae = ["aria-label"], Pe = ["aria-posinset", "aria-setsize"], Le = /* @__PU
1317
1397
  },
1318
1398
  emits: ["scroll", "loadMore", "refresh"],
1319
1399
  setup(n, { expose: W, emit: k }) {
1320
- const e = n, S = k, g = A(), x = A(0), u = A(0), V = A(0), P = A(0), O = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
1321
- let N, p, H = -1;
1322
- const { getItemKey: T } = xe({
1400
+ const e = n, w = k, g = D(), b = D(0), r = D(0), H = D(0), N = D(0), C = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map();
1401
+ let A, h, V = -1;
1402
+ const { getItemKey: M } = xe({
1323
1403
  componentName: "WindowDynamicVirtualScroll",
1324
1404
  items: () => e.items,
1325
1405
  itemKey: () => e.itemKey
1326
1406
  }), {
1327
- pulling: B,
1328
- pullDistance: F,
1329
- pullOffset: I,
1330
- pullProgress: U,
1331
- refreshMessage: ee,
1407
+ pulling: S,
1408
+ pullDistance: P,
1409
+ pullOffset: Y,
1410
+ pullProgress: _,
1411
+ refreshMessage: ae,
1332
1412
  refreshThreshold: K,
1333
1413
  handleTouchStart: z,
1334
- handleTouchMove: te,
1335
- handleTouchEnd: G,
1336
- handleTouchCancel: J
1337
- } = He({
1414
+ handleTouchMove: Q,
1415
+ handleTouchEnd: B,
1416
+ handleTouchCancel: q
1417
+ } = ke({
1338
1418
  enabled: () => e.pullToRefresh,
1339
1419
  refreshing: () => e.refreshing,
1340
1420
  threshold: () => e.pullRefreshThreshold,
1341
- onRefresh: () => S("refresh"),
1421
+ onRefresh: () => w("refresh"),
1342
1422
  scrollTop: () => typeof window > "u" ? 0 : Math.max(0, window.scrollY)
1343
- }), _ = i(
1423
+ }), U = s(
1344
1424
  () => Math.max(1, e.estimatedItemSize)
1345
- ), oe = i(
1346
- () => Math.max(1, e.loadingItemSize ?? _.value)
1347
- ), Y = i(() => Math.max(0, Math.floor(e.overscan))), c = i(() => {
1348
- P.value;
1349
- const t = new Array(e.items.length + 1), o = new Array(e.items.length);
1350
- t[0] = 0;
1425
+ ), ie = s(
1426
+ () => Math.max(1, e.loadingItemSize ?? U.value)
1427
+ ), F = s(() => Math.max(0, Math.floor(e.overscan))), f = s(() => {
1428
+ N.value;
1429
+ const a = new Array(e.items.length + 1), t = new Array(e.items.length);
1430
+ a[0] = 0;
1351
1431
  for (let l = 0; l < e.items.length; l += 1) {
1352
- const M = T(e.items[l], l), y = O.get(M) ?? _.value;
1353
- o[l] = y, t[l + 1] = t[l] + y;
1432
+ const i = M(e.items[l], l), d = C.get(i) ?? U.value;
1433
+ t[l] = d, a[l + 1] = a[l] + d;
1354
1434
  }
1355
1435
  return {
1356
- offsets: t,
1357
- sizes: o,
1358
- total: t[e.items.length] ?? 0
1436
+ offsets: a,
1437
+ sizes: t,
1438
+ total: a[e.items.length] ?? 0
1359
1439
  };
1360
- }), v = i(
1361
- () => c.value.total + (e.loading ? oe.value : 0)
1362
- ), L = i(() => {
1363
- const t = /* @__PURE__ */ new Map();
1364
- return e.items.forEach((o, l) => {
1365
- t.set(T(o, l), l);
1366
- }), t;
1367
- }), j = i(
1368
- () => Math.max(0, x.value - V.value)
1440
+ }), m = s(
1441
+ () => f.value.total + (e.loading ? ie.value : 0)
1442
+ ), O = s(() => {
1443
+ const a = /* @__PURE__ */ new Map();
1444
+ return e.items.forEach((t, l) => {
1445
+ a.set(M(t, l), l);
1446
+ }), a;
1447
+ }), oe = s(
1448
+ () => Math.max(0, b.value - H.value)
1369
1449
  );
1370
- function re(t) {
1450
+ function le(a) {
1371
1451
  if (e.items.length === 0) return 0;
1372
- const o = c.value.offsets;
1373
- let l = 0, M = e.items.length;
1374
- for (; l < M; ) {
1375
- const y = Math.floor((l + M) / 2);
1376
- o[y + 1] <= t ? l = y + 1 : M = y;
1452
+ const t = f.value.offsets;
1453
+ let l = 0, i = e.items.length;
1454
+ for (; l < i; ) {
1455
+ const d = Math.floor((l + i) / 2);
1456
+ t[d + 1] <= a ? l = d + 1 : i = d;
1377
1457
  }
1378
1458
  return Math.min(l, e.items.length - 1);
1379
1459
  }
1380
- const se = i(
1460
+ const ue = s(
1381
1461
  () => Math.max(
1382
1462
  0,
1383
- re(j.value) - Y.value
1463
+ le(oe.value) - F.value
1384
1464
  )
1385
- ), ne = i(() => {
1465
+ ), X = s(() => {
1386
1466
  if (e.items.length === 0) return 0;
1387
- const t = x.value + u.value - V.value, o = Math.max(
1388
- _.value,
1389
- t
1390
- ), l = re(o) + 1;
1467
+ const a = b.value + r.value - H.value, t = Math.max(
1468
+ U.value,
1469
+ a
1470
+ ), l = le(t) + 1;
1391
1471
  return Math.min(
1392
1472
  e.items.length,
1393
- l + Y.value
1473
+ l + F.value
1394
1474
  );
1395
- }), fe = i(
1396
- () => e.items.slice(se.value, ne.value).map((t, o) => {
1397
- const l = se.value + o;
1475
+ }), ce = s(
1476
+ () => e.items.slice(ue.value, X.value).map((a, t) => {
1477
+ const l = ue.value + t;
1398
1478
  return {
1399
- item: t,
1479
+ item: a,
1400
1480
  index: l,
1401
- key: T(t, l),
1402
- top: c.value.offsets[l]
1481
+ key: M(a, l),
1482
+ top: f.value.offsets[l]
1403
1483
  };
1404
1484
  })
1405
1485
  );
1406
- function le() {
1407
- typeof window > "u" || (x.value = Math.max(0, window.scrollY), u.value = window.innerHeight, g.value && (V.value = g.value.getBoundingClientRect().top + x.value));
1486
+ function G() {
1487
+ typeof window > "u" || (b.value = Math.max(0, window.scrollY), r.value = window.innerHeight, g.value && (H.value = g.value.getBoundingClientRect().top + b.value));
1408
1488
  }
1409
- function d() {
1410
- S("scroll", {
1411
- scrollTop: j.value,
1412
- startIndex: se.value,
1413
- endIndex: ne.value
1489
+ function ne() {
1490
+ w("scroll", {
1491
+ scrollTop: oe.value,
1492
+ startIndex: ue.value,
1493
+ endIndex: X.value
1414
1494
  });
1415
1495
  }
1416
- function s() {
1417
- le(), d(), h();
1496
+ function p() {
1497
+ G(), ne(), y();
1418
1498
  }
1419
- function h() {
1420
- if (typeof window > "u" || !e.hasMore || e.loading || H === e.items.length)
1499
+ function y() {
1500
+ if (typeof window > "u" || !e.hasMore || e.loading || V === e.items.length)
1421
1501
  return;
1422
- const t = Math.max(0, e.loadMoreThreshold), o = V.value + v.value, l = x.value + u.value;
1423
- o - l <= t && (H = e.items.length, S("loadMore"));
1502
+ const a = Math.max(0, e.loadMoreThreshold), t = H.value + m.value, l = b.value + r.value;
1503
+ t - l <= a && (V = e.items.length, w("loadMore"));
1424
1504
  }
1425
- function a(t) {
1426
- const o = t.borderBoxSize;
1427
- if (o) {
1428
- const l = Array.isArray(o) ? o[0] : o;
1505
+ function o(a) {
1506
+ const t = a.borderBoxSize;
1507
+ if (t) {
1508
+ const l = Array.isArray(t) ? t[0] : t;
1429
1509
  if (l != null && l.blockSize) return l.blockSize;
1430
1510
  }
1431
- return t.contentRect.height;
1432
- }
1433
- function f(t) {
1434
- const o = c.value;
1435
- let l = 0, M = !1;
1436
- for (const y of t) {
1437
- const Q = y.target, q = E.get(Q), ie = a(y);
1438
- if (q === void 0 || ie <= 0) continue;
1439
- const ce = O.get(q) ?? _.value;
1440
- if (Math.abs(ce - ie) < 0.5) continue;
1441
- const de = L.value.get(q);
1442
- de !== void 0 && o.offsets[de + 1] <= j.value && (l += ie - ce), O.set(q, ie), M = !0;
1511
+ return a.contentRect.height;
1512
+ }
1513
+ function c(a) {
1514
+ const t = f.value;
1515
+ let l = 0, i = !1;
1516
+ for (const d of a) {
1517
+ const ee = d.target, J = L.get(ee), re = o(d);
1518
+ if (J === void 0 || re <= 0) continue;
1519
+ const de = C.get(J) ?? U.value;
1520
+ if (Math.abs(de - re) < 0.5) continue;
1521
+ const fe = O.value.get(J);
1522
+ fe !== void 0 && t.offsets[fe + 1] <= oe.value && (l += re - de), C.set(J, re), i = !0;
1443
1523
  }
1444
- M && (P.value += 1, $(() => {
1524
+ i && (N.value += 1, I(() => {
1445
1525
  if (l !== 0 && typeof window < "u") {
1446
- const y = Math.max(
1526
+ const d = Math.max(
1447
1527
  0,
1448
- x.value + l
1528
+ b.value + l
1449
1529
  );
1450
- x.value = y, window.scrollTo({ top: y, behavior: "auto" });
1530
+ b.value = d, window.scrollTo({ top: d, behavior: "auto" });
1451
1531
  }
1452
- le(), h();
1532
+ G(), y();
1453
1533
  }));
1454
1534
  }
1455
- function r(t, o) {
1456
- t instanceof HTMLElement && (E.set(t, o), p == null || p.observe(t));
1535
+ function u(a, t) {
1536
+ a instanceof HTMLElement && (L.set(a, t), h == null || h.observe(a));
1457
1537
  }
1458
- function D() {
1459
- for (const [t] of E)
1460
- t.isConnected || (p == null || p.unobserve(t), E.delete(t));
1538
+ function E() {
1539
+ for (const [a] of L)
1540
+ a.isConnected || (h == null || h.unobserve(a), L.delete(a));
1461
1541
  }
1462
- function R(t, o = {}) {
1542
+ function $(a, t = {}) {
1463
1543
  if (typeof window > "u") return;
1464
- le();
1465
- const l = Math.max(0, v.value - u.value), M = Math.min(
1466
- Math.max(0, Number.isFinite(t) ? t : 0),
1544
+ G();
1545
+ const l = Math.max(0, m.value - r.value), i = Math.min(
1546
+ Math.max(0, Number.isFinite(a) ? a : 0),
1467
1547
  l
1468
- ), y = Math.max(0, V.value + M), Q = o.behavior ?? "auto";
1469
- Q === "auto" && (x.value = y), window.scrollTo({ ...o, top: y, behavior: Q });
1548
+ ), d = Math.max(0, H.value + i), ee = t.behavior ?? "auto";
1549
+ ee === "auto" && (b.value = d), window.scrollTo({ ...t, top: d, behavior: ee });
1470
1550
  }
1471
- function Z(t, o = {}) {
1551
+ function j(a, t = {}) {
1472
1552
  if (typeof window > "u" || e.items.length === 0) return;
1473
- le();
1553
+ G();
1474
1554
  const l = Math.min(
1475
1555
  e.items.length - 1,
1476
- Math.max(0, Math.floor(t))
1477
- ), { align: M = "start", ...y } = o, Q = c.value.sizes[l];
1478
- let q = V.value + c.value.offsets[l];
1479
- M === "center" ? q -= (u.value - Q) / 2 : M === "end" && (q -= u.value - Q);
1480
- const ie = Math.max(
1481
- V.value,
1482
- V.value + v.value - u.value
1483
- ), ce = Math.max(0, Math.min(q, ie)), de = y.behavior ?? "auto", Se = Math.max(
1484
- u.value * 3,
1485
- _.value * 10
1486
- ), Te = de === "smooth" && Math.abs(ce - x.value) > Se ? "auto" : de;
1487
- Te === "auto" && (x.value = ce), window.scrollTo({
1488
- ...y,
1489
- top: ce,
1490
- behavior: Te
1556
+ Math.max(0, Math.floor(a))
1557
+ ), { align: i = "start", ...d } = t, ee = f.value.sizes[l];
1558
+ let J = H.value + f.value.offsets[l];
1559
+ i === "center" ? J -= (r.value - ee) / 2 : i === "end" && (J -= r.value - ee);
1560
+ const re = Math.max(
1561
+ H.value,
1562
+ H.value + m.value - r.value
1563
+ ), de = Math.max(0, Math.min(J, re)), fe = d.behavior ?? "auto";
1564
+ fe === "auto" && (b.value = de), window.scrollTo({
1565
+ ...d,
1566
+ top: de,
1567
+ behavior: fe
1491
1568
  });
1492
1569
  }
1493
- function ue(t = "auto") {
1494
- typeof window > "u" || (le(), window.scrollTo({ top: Math.max(0, V.value), behavior: t }));
1570
+ function se(a = "auto") {
1571
+ typeof window > "u" || (G(), window.scrollTo({ top: Math.max(0, H.value), behavior: a }));
1495
1572
  }
1496
- return ae(
1573
+ return Z(
1497
1574
  () => e.itemKey,
1498
1575
  () => {
1499
- O.clear(), P.value += 1;
1576
+ C.clear(), N.value += 1;
1500
1577
  }
1501
- ), ae(
1578
+ ), Z(
1502
1579
  () => e.items.length,
1503
1580
  async () => {
1504
- const t = new Set(
1505
- e.items.map((o, l) => T(o, l))
1581
+ const a = new Set(
1582
+ e.items.map((t, l) => M(t, l))
1506
1583
  );
1507
- for (const o of O.keys())
1508
- t.has(o) || O.delete(o);
1509
- P.value += 1, await $(), le(), h();
1584
+ for (const t of C.keys())
1585
+ a.has(t) || C.delete(t);
1586
+ N.value += 1, await I(), G(), y();
1510
1587
  }
1511
- ), ae(
1588
+ ), Z(
1512
1589
  () => [e.hasMore, e.loading],
1513
- async ([t]) => {
1514
- t || (H = -1), await $(), le(), h();
1590
+ async ([a]) => {
1591
+ a || (V = -1), await I(), G(), y();
1515
1592
  }
1516
1593
  ), pe(() => {
1517
- if (le(), window.addEventListener("scroll", s, { passive: !0 }), window.addEventListener("resize", s, { passive: !0 }), typeof ResizeObserver < "u") {
1518
- N = new ResizeObserver(() => {
1519
- le(), h();
1520
- }), p = new ResizeObserver(f), g.value && N.observe(g.value);
1521
- for (const [t] of E)
1522
- p.observe(t);
1594
+ if (G(), window.addEventListener("scroll", p, { passive: !0 }), window.addEventListener("resize", p, { passive: !0 }), typeof ResizeObserver < "u") {
1595
+ A = new ResizeObserver(() => {
1596
+ G(), y();
1597
+ }), h = new ResizeObserver(c), g.value && A.observe(g.value);
1598
+ for (const [a] of L)
1599
+ h.observe(a);
1523
1600
  }
1524
- $(h);
1525
- }), ze(D), ye(() => {
1526
- window.removeEventListener("scroll", s), window.removeEventListener("resize", s), N == null || N.disconnect(), p == null || p.disconnect(), E.clear();
1601
+ I(y);
1602
+ }), Se(E), ye(() => {
1603
+ window.removeEventListener("scroll", p), window.removeEventListener("resize", p), A && (A.disconnect(), A = void 0), h && (h.disconnect(), h = void 0), L.clear();
1527
1604
  }), W({
1528
- scrollTo: R,
1529
- scrollToIndex: Z,
1530
- scrollToTop: ue
1531
- }), (t, o) => (w(), b("div", {
1605
+ scrollTo: $,
1606
+ scrollToIndex: j,
1607
+ scrollToTop: se
1608
+ }), (a, t) => (x(), T("div", {
1532
1609
  ref_key: "root",
1533
1610
  ref: g,
1534
- class: $e(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": m(B) }]),
1611
+ class: Ie(["vue-window-dynamic-virtual-scroll", { "vue-window-dynamic-virtual-scroll--pulling": v(S) }]),
1535
1612
  role: "list",
1536
1613
  "aria-label": n.ariaLabel,
1537
- onTouchstartPassive: o[0] || (o[0] = //@ts-ignore
1538
- (...l) => m(z) && m(z)(...l)),
1539
- onTouchmove: o[1] || (o[1] = //@ts-ignore
1540
- (...l) => m(te) && m(te)(...l)),
1541
- onTouchend: o[2] || (o[2] = //@ts-ignore
1542
- (...l) => m(G) && m(G)(...l)),
1543
- onTouchcancel: o[3] || (o[3] = //@ts-ignore
1544
- (...l) => m(J) && m(J)(...l))
1614
+ onTouchstartPassive: t[0] || (t[0] = //@ts-ignore
1615
+ (...l) => v(z) && v(z)(...l)),
1616
+ onTouchmove: t[1] || (t[1] = //@ts-ignore
1617
+ (...l) => v(Q) && v(Q)(...l)),
1618
+ onTouchend: t[2] || (t[2] = //@ts-ignore
1619
+ (...l) => v(B) && v(B)(...l)),
1620
+ onTouchcancel: t[3] || (t[3] = //@ts-ignore
1621
+ (...l) => v(q) && v(q)(...l))
1545
1622
  }, [
1546
- n.pullToRefresh || n.refreshing ? (w(), b("div", {
1623
+ n.pullToRefresh || n.refreshing ? (x(), T("div", {
1547
1624
  key: 0,
1548
1625
  class: "vue-window-dynamic-virtual-scroll__refresh",
1549
- style: C({
1550
- height: `${m(K)}px`,
1551
- transform: `translateY(${m(I) - m(K)}px)`
1626
+ style: R({
1627
+ height: `${v(K)}px`,
1628
+ transform: `translateY(${v(Y) - v(K)}px)`
1552
1629
  }),
1553
1630
  role: "status",
1554
1631
  "aria-live": "polite"
1555
1632
  }, [
1556
- X(t.$slots, "refresh", {
1557
- pullDistance: m(F),
1558
- progress: m(U),
1633
+ te(a.$slots, "refresh", {
1634
+ pullDistance: v(P),
1635
+ progress: v(_),
1559
1636
  refreshing: n.refreshing
1560
1637
  }, () => [
1561
- me(ke(m(ee)), 1)
1638
+ he(ze(v(ae)), 1)
1562
1639
  ])
1563
- ], 4)) : he("", !0),
1564
- n.items.length || n.loading ? (w(), b("div", {
1640
+ ], 4)) : ve("", !0),
1641
+ n.items.length || n.loading ? (x(), T("div", {
1565
1642
  key: 1,
1566
1643
  class: "vue-window-dynamic-virtual-scroll__spacer",
1567
- style: C({
1568
- height: `${v.value}px`,
1569
- transform: `translateY(${m(I)}px)`
1644
+ style: R({
1645
+ height: `${m.value}px`,
1646
+ transform: `translateY(${v(Y)}px)`
1570
1647
  })
1571
1648
  }, [
1572
- (w(!0), b(ve, null, Me(fe.value, ({ item: l, index: M, key: y, top: Q }) => (w(), b("div", {
1573
- key: y,
1649
+ (x(!0), T(me, null, Me(ce.value, ({ item: l, index: i, key: d, top: ee }) => (x(), T("div", {
1650
+ key: d,
1574
1651
  ref_for: !0,
1575
- ref: (q) => r(q, y),
1652
+ ref: (J) => u(J, d),
1576
1653
  class: "vue-window-dynamic-virtual-scroll__item",
1577
- style: C({ transform: `translateY(${Q}px)` }),
1654
+ style: R({ transform: `translateY(${ee}px)` }),
1578
1655
  role: "listitem",
1579
- "aria-posinset": M + 1,
1656
+ "aria-posinset": i + 1,
1580
1657
  "aria-setsize": n.items.length
1581
1658
  }, [
1582
- X(t.$slots, "default", {
1659
+ te(a.$slots, "default", {
1583
1660
  item: l,
1584
- index: M
1661
+ index: i
1585
1662
  })
1586
- ], 12, Xe))), 128)),
1587
- n.loading ? (w(), b("div", {
1663
+ ], 12, Je))), 128)),
1664
+ n.loading ? (x(), T("div", {
1588
1665
  key: 0,
1589
1666
  class: "vue-window-dynamic-virtual-scroll__loading",
1590
- style: C({
1591
- height: `${oe.value}px`,
1592
- transform: `translateY(${c.value.total}px)`
1667
+ style: R({
1668
+ height: `${ie.value}px`,
1669
+ transform: `translateY(${f.value.total}px)`
1593
1670
  }),
1594
1671
  role: "status",
1595
1672
  "aria-live": "polite"
1596
1673
  }, [
1597
- X(t.$slots, "loading", {}, () => [
1598
- o[4] || (o[4] = me("Loading more…", -1))
1674
+ te(a.$slots, "loading", {}, () => [
1675
+ t[4] || (t[4] = he("Loading more…", -1))
1599
1676
  ])
1600
- ], 4)) : he("", !0)
1601
- ], 4)) : (w(), b("div", {
1677
+ ], 4)) : ve("", !0)
1678
+ ], 4)) : (x(), T("div", {
1602
1679
  key: 2,
1603
1680
  class: "vue-window-dynamic-virtual-scroll__empty",
1604
- style: C({ transform: `translateY(${m(I)}px)` })
1681
+ style: R({ transform: `translateY(${v(Y)}px)` })
1605
1682
  }, [
1606
- X(t.$slots, "empty")
1683
+ te(a.$slots, "empty")
1607
1684
  ], 4))
1608
- ], 42, Qe));
1685
+ ], 42, Ge));
1609
1686
  }
1610
- }), tt = Le, at = {
1687
+ }), Xe = He, tt = {
1611
1688
  install(n) {
1612
- n.component("ChatVirtualScroll", Re), n.component("DynamicVirtualScroll", Le), n.component("ShortMediaFeed", Fe), n.component("VirtualCarousel", Ze), n.component("VirtualList", tt), n.component("VirtualScroll", Je), n.component(
1689
+ n.component("ChatVirtualScroll", Oe), n.component("DynamicVirtualScroll", He), n.component("ShortMediaFeed", Ne), n.component("VirtualCarousel", Ue), n.component("VirtualList", Xe), n.component("VirtualScroll", qe), n.component(
1613
1690
  "WindowDynamicVirtualScroll",
1614
- et
1691
+ Qe
1615
1692
  );
1616
1693
  }
1617
1694
  };
1618
1695
  export {
1619
- Re as ChatVirtualScroll,
1620
- Le as DynamicVirtualScroll,
1621
- Fe as ShortMediaFeed,
1622
- Ze as VirtualCarousel,
1623
- tt as VirtualList,
1624
- Je as VirtualScroll,
1625
- at as VueVirtualScroll,
1626
- et as WindowDynamicVirtualScroll,
1627
- at as default
1696
+ Oe as ChatVirtualScroll,
1697
+ He as DynamicVirtualScroll,
1698
+ Ne as ShortMediaFeed,
1699
+ Ue as VirtualCarousel,
1700
+ Xe as VirtualList,
1701
+ qe as VirtualScroll,
1702
+ tt as VueVirtualScroll,
1703
+ Qe as WindowDynamicVirtualScroll,
1704
+ tt as default
1628
1705
  };