vue-virtual-flow 0.0.3 → 0.0.5

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