@wyxos/vibe 1.6.25 → 1.6.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,23 +1,23 @@
1
- import { nextTick as q, ref as B, computed as Z, defineComponent as et, onMounted as tt, onUnmounted as at, watch as te, createElementBlock as R, openBlock as O, createCommentVNode as ae, createElementVNode as V, normalizeStyle as ge, renderSlot as X, normalizeClass as re, withModifiers as Ye, toDisplayString as Be, unref as U, Fragment as Ue, renderList as _e, createVNode as He, withCtx as fe, mergeProps as de, TransitionGroup as Tt } from "vue";
2
- let $e = null;
3
- function It() {
4
- if ($e != null) return $e;
1
+ import { nextTick as X, ref as W, computed as K, defineComponent as _e, onMounted as Xe, onUnmounted as Ge, watch as ee, createElementBlock as q, openBlock as Y, createCommentVNode as te, createElementVNode as U, normalizeStyle as he, renderSlot as J, normalizeClass as re, withModifiers as Ae, toDisplayString as Pe, unref as G, Fragment as Re, renderList as Oe, createVNode as Se, withCtx as ve, mergeProps as fe, TransitionGroup as It } from "vue";
2
+ let ke = null;
3
+ function Lt() {
4
+ if (ke != null) return ke;
5
5
  const e = document.createElement("div");
6
6
  e.style.visibility = "hidden", e.style.overflow = "scroll", e.style.msOverflowStyle = "scrollbar", e.style.width = "100px", e.style.height = "100px", document.body.appendChild(e);
7
- const l = document.createElement("div");
8
- l.style.width = "100%", e.appendChild(l);
9
- const r = e.offsetWidth - l.offsetWidth;
10
- return document.body.removeChild(e), $e = r, r;
7
+ const n = document.createElement("div");
8
+ n.style.width = "100%", e.appendChild(n);
9
+ const i = e.offsetWidth - n.offsetWidth;
10
+ return document.body.removeChild(e), ke = i, i;
11
11
  }
12
- function Xe(e, l, r, t = {}) {
12
+ function Ce(e, n, i, a = {}) {
13
13
  const {
14
- gutterX: y = 0,
15
- gutterY: g = 0,
16
- header: h = 0,
17
- footer: i = 0,
18
- paddingLeft: w = 0,
19
- paddingRight: b = 0,
20
- sizes: n = {
14
+ gutterX: m = 0,
15
+ gutterY: d = 0,
16
+ header: f = 0,
17
+ footer: o = 0,
18
+ paddingLeft: c = 0,
19
+ paddingRight: y = 0,
20
+ sizes: t = {
21
21
  base: 1,
22
22
  sm: 2,
23
23
  md: 3,
@@ -25,195 +25,195 @@ function Xe(e, l, r, t = {}) {
25
25
  xl: 5,
26
26
  "2xl": 6
27
27
  },
28
- placement: p = "masonry"
29
- } = t;
30
- let x = 0, T = 0;
28
+ placement: w = "masonry"
29
+ } = a;
30
+ let T = 0, p = 0;
31
31
  try {
32
- if (l && l.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
33
- const L = window.getComputedStyle(l);
34
- x = parseFloat(L.paddingLeft) || 0, T = parseFloat(L.paddingRight) || 0;
32
+ if (n && n.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
33
+ const k = window.getComputedStyle(n);
34
+ T = parseFloat(k.paddingLeft) || 0, p = parseFloat(k.paddingRight) || 0;
35
35
  }
36
36
  } catch {
37
37
  }
38
- const s = (w || 0) + x, m = (b || 0) + T, a = l.offsetWidth - l.clientWidth, d = a > 0 ? a + 2 : It() + 2, v = l.offsetWidth - d - s - m, M = y * (r - 1), P = Math.floor((v - M) / r), I = e.map((L) => {
39
- const k = L.width, W = L.height;
40
- return Math.round(P * W / k) + i + h;
38
+ const h = (c || 0) + T, I = (y || 0) + p, S = n.offsetWidth - n.clientWidth, v = S > 0 ? S + 2 : Lt() + 2, r = n.offsetWidth - v - h - I, s = m * (i - 1), L = Math.floor((r - s) / i), M = e.map((k) => {
39
+ const N = k.width, A = k.height;
40
+ return Math.round(L * A / N) + o + f;
41
41
  });
42
- if (p === "sequential-balanced") {
43
- const L = I.length;
44
- if (L === 0) return [];
45
- const k = (D, Y, J) => D + (Y > 0 ? g : 0) + J;
46
- let W = Math.max(...I), o = I.reduce((D, Y) => D + Y, 0) + g * Math.max(0, L - 1);
47
- const u = (D) => {
48
- let Y = 1, J = 0, ne = 0;
49
- for (let K = 0; K < L; K++) {
50
- const ie = I[K], ee = k(J, ne, ie);
51
- if (ee <= D)
52
- J = ee, ne++;
53
- else if (Y++, J = ie, ne = 1, ie > D || Y > r) return !1;
42
+ if (w === "sequential-balanced") {
43
+ const k = M.length;
44
+ if (k === 0) return [];
45
+ const N = (b, H, R) => b + (H > 0 ? d : 0) + R;
46
+ let A = Math.max(...M), P = M.reduce((b, H) => b + H, 0) + d * Math.max(0, k - 1);
47
+ const z = (b) => {
48
+ let H = 1, R = 0, ne = 0;
49
+ for (let _ = 0; _ < k; _++) {
50
+ const ie = M[_], Q = N(R, ne, ie);
51
+ if (Q <= b)
52
+ R = Q, ne++;
53
+ else if (H++, R = ie, ne = 1, ie > b || H > i) return !1;
54
54
  }
55
- return Y <= r;
55
+ return H <= i;
56
56
  };
57
- for (; W < o; ) {
58
- const D = Math.floor((W + o) / 2);
59
- u(D) ? o = D : W = D + 1;
57
+ for (; A < P; ) {
58
+ const b = Math.floor((A + P) / 2);
59
+ z(b) ? P = b : A = b + 1;
60
60
  }
61
- const E = o, $ = new Array(r).fill(0);
62
- let C = r - 1, A = 0, N = 0;
63
- for (let D = L - 1; D >= 0; D--) {
64
- const Y = I[D], J = D < C;
65
- !(k(A, N, Y) <= E) || J ? ($[C] = D + 1, C--, A = Y, N = 1) : (A = k(A, N, Y), N++);
61
+ const F = P, l = new Array(i).fill(0);
62
+ let x = i - 1, E = 0, D = 0;
63
+ for (let b = k - 1; b >= 0; b--) {
64
+ const H = M[b], R = b < x;
65
+ !(N(E, D, H) <= F) || R ? (l[x] = b + 1, x--, E = H, D = 1) : (E = N(E, D, H), D++);
66
66
  }
67
- $[0] = 0;
68
- const j = [], G = new Array(r).fill(0);
69
- for (let D = 0; D < r; D++) {
70
- const Y = $[D], J = D + 1 < r ? $[D + 1] : L, ne = D * (P + y);
71
- for (let K = Y; K < J; K++) {
72
- const ee = {
73
- ...e[K],
74
- columnWidth: P,
67
+ l[0] = 0;
68
+ const V = [], C = new Array(i).fill(0);
69
+ for (let b = 0; b < i; b++) {
70
+ const H = l[b], R = b + 1 < i ? l[b + 1] : k, ne = b * (L + m);
71
+ for (let _ = H; _ < R; _++) {
72
+ const Q = {
73
+ ...e[_],
74
+ columnWidth: L,
75
75
  imageHeight: 0,
76
76
  columnHeight: 0,
77
77
  left: 0,
78
78
  top: 0
79
79
  };
80
- ee.imageHeight = I[K] - (i + h), ee.columnHeight = I[K], ee.left = ne, ee.top = G[D], G[D] += ee.columnHeight + (K + 1 < J ? g : 0), j.push(ee);
80
+ Q.imageHeight = M[_] - (o + f), Q.columnHeight = M[_], Q.left = ne, Q.top = C[b], C[b] += Q.columnHeight + (_ + 1 < R ? d : 0), V.push(Q);
81
81
  }
82
82
  }
83
- return j;
83
+ return V;
84
84
  }
85
- const f = new Array(r).fill(0), H = [];
86
- for (let L = 0; L < e.length; L++) {
87
- const k = e[L], W = {
88
- ...k,
85
+ const g = new Array(i).fill(0), $ = [];
86
+ for (let k = 0; k < e.length; k++) {
87
+ const N = e[k], A = {
88
+ ...N,
89
89
  columnWidth: 0,
90
90
  imageHeight: 0,
91
91
  columnHeight: 0,
92
92
  left: 0,
93
93
  top: 0
94
- }, o = f.indexOf(Math.min(...f)), u = k.width, E = k.height;
95
- W.columnWidth = P, W.left = o * (P + y), W.imageHeight = Math.round(P * E / u), W.columnHeight = W.imageHeight + i + h, W.top = f[o], f[o] += W.columnHeight + g, H.push(W);
94
+ }, P = g.indexOf(Math.min(...g)), z = N.width, F = N.height;
95
+ A.columnWidth = L, A.left = P * (L + m), A.imageHeight = Math.round(L * F / z), A.columnHeight = A.imageHeight + o + f, A.top = g[P], g[P] += A.columnHeight + d, $.push(A);
96
96
  }
97
- return H;
97
+ return $;
98
98
  }
99
- var Et = typeof global == "object" && global && global.Object === Object && global, kt = typeof self == "object" && self && self.Object === Object && self, nt = Et || kt || Function("return this")(), xe = nt.Symbol, lt = Object.prototype, Pt = lt.hasOwnProperty, Lt = lt.toString, he = xe ? xe.toStringTag : void 0;
100
- function St(e) {
101
- var l = Pt.call(e, he), r = e[he];
99
+ var St = typeof global == "object" && global && global.Object === Object && global, kt = typeof self == "object" && self && self.Object === Object && self, Je = St || kt || Function("return this")(), we = Je.Symbol, Ke = Object.prototype, Et = Ke.hasOwnProperty, Pt = Ke.toString, de = we ? we.toStringTag : void 0;
100
+ function Ht(e) {
101
+ var n = Et.call(e, de), i = e[de];
102
102
  try {
103
- e[he] = void 0;
104
- var t = !0;
103
+ e[de] = void 0;
104
+ var a = !0;
105
105
  } catch {
106
106
  }
107
- var y = Lt.call(e);
108
- return t && (l ? e[he] = r : delete e[he]), y;
107
+ var m = Pt.call(e);
108
+ return a && (n ? e[de] = i : delete e[de]), m;
109
109
  }
110
- var Ht = Object.prototype, $t = Ht.toString;
111
- function Nt(e) {
112
- return $t.call(e);
113
- }
114
- var Bt = "[object Null]", Dt = "[object Undefined]", Ge = xe ? xe.toStringTag : void 0;
110
+ var $t = Object.prototype, Ft = $t.toString;
115
111
  function zt(e) {
116
- return e == null ? e === void 0 ? Dt : Bt : Ge && Ge in Object(e) ? St(e) : Nt(e);
112
+ return Ft.call(e);
113
+ }
114
+ var Dt = "[object Null]", Bt = "[object Undefined]", Ve = we ? we.toStringTag : void 0;
115
+ function Nt(e) {
116
+ return e == null ? e === void 0 ? Bt : Dt : Ve && Ve in Object(e) ? Ht(e) : zt(e);
117
117
  }
118
- function Ft(e) {
118
+ function Wt(e) {
119
119
  return e != null && typeof e == "object";
120
120
  }
121
121
  var At = "[object Symbol]";
122
- function Wt(e) {
123
- return typeof e == "symbol" || Ft(e) && zt(e) == At;
122
+ function Rt(e) {
123
+ return typeof e == "symbol" || Wt(e) && Nt(e) == At;
124
124
  }
125
- var Rt = /\s/;
126
- function Ot(e) {
127
- for (var l = e.length; l-- && Rt.test(e.charAt(l)); )
125
+ var Ot = /\s/;
126
+ function Ct(e) {
127
+ for (var n = e.length; n-- && Ot.test(e.charAt(n)); )
128
128
  ;
129
- return l;
129
+ return n;
130
130
  }
131
- var Ct = /^\s+/;
131
+ var Vt = /^\s+/;
132
132
  function jt(e) {
133
- return e && e.slice(0, Ot(e) + 1).replace(Ct, "");
133
+ return e && e.slice(0, Ct(e) + 1).replace(Vt, "");
134
134
  }
135
- function De(e) {
136
- var l = typeof e;
137
- return e != null && (l == "object" || l == "function");
135
+ function He(e) {
136
+ var n = typeof e;
137
+ return e != null && (n == "object" || n == "function");
138
138
  }
139
- var Je = NaN, Vt = /^[-+]0x[0-9a-f]+$/i, qt = /^0b[01]+$/i, Yt = /^0o[0-7]+$/i, Ut = parseInt;
140
- function Ke(e) {
139
+ var je = NaN, qt = /^[-+]0x[0-9a-f]+$/i, Yt = /^0b[01]+$/i, Ut = /^0o[0-7]+$/i, _t = parseInt;
140
+ function qe(e) {
141
141
  if (typeof e == "number")
142
142
  return e;
143
- if (Wt(e))
144
- return Je;
145
- if (De(e)) {
146
- var l = typeof e.valueOf == "function" ? e.valueOf() : e;
147
- e = De(l) ? l + "" : l;
143
+ if (Rt(e))
144
+ return je;
145
+ if (He(e)) {
146
+ var n = typeof e.valueOf == "function" ? e.valueOf() : e;
147
+ e = He(n) ? n + "" : n;
148
148
  }
149
149
  if (typeof e != "string")
150
150
  return e === 0 ? e : +e;
151
151
  e = jt(e);
152
- var r = qt.test(e);
153
- return r || Yt.test(e) ? Ut(e.slice(2), r ? 2 : 8) : Vt.test(e) ? Je : +e;
152
+ var i = Yt.test(e);
153
+ return i || Ut.test(e) ? _t(e.slice(2), i ? 2 : 8) : qt.test(e) ? je : +e;
154
154
  }
155
- var Ne = function() {
156
- return nt.Date.now();
157
- }, _t = "Expected a function", Xt = Math.max, Gt = Math.min;
158
- function Qe(e, l, r) {
159
- var t, y, g, h, i, w, b = 0, n = !1, p = !1, x = !0;
155
+ var Ee = function() {
156
+ return Je.Date.now();
157
+ }, Xt = "Expected a function", Gt = Math.max, Jt = Math.min;
158
+ function Ye(e, n, i) {
159
+ var a, m, d, f, o, c, y = 0, t = !1, w = !1, T = !0;
160
160
  if (typeof e != "function")
161
- throw new TypeError(_t);
162
- l = Ke(l) || 0, De(r) && (n = !!r.leading, p = "maxWait" in r, g = p ? Xt(Ke(r.maxWait) || 0, l) : g, x = "trailing" in r ? !!r.trailing : x);
163
- function T(f) {
164
- var H = t, L = y;
165
- return t = y = void 0, b = f, h = e.apply(L, H), h;
161
+ throw new TypeError(Xt);
162
+ n = qe(n) || 0, He(i) && (t = !!i.leading, w = "maxWait" in i, d = w ? Gt(qe(i.maxWait) || 0, n) : d, T = "trailing" in i ? !!i.trailing : T);
163
+ function p(g) {
164
+ var $ = a, k = m;
165
+ return a = m = void 0, y = g, f = e.apply(k, $), f;
166
166
  }
167
- function s(f) {
168
- return b = f, i = setTimeout(d, l), n ? T(f) : h;
167
+ function h(g) {
168
+ return y = g, o = setTimeout(v, n), t ? p(g) : f;
169
169
  }
170
- function m(f) {
171
- var H = f - w, L = f - b, k = l - H;
172
- return p ? Gt(k, g - L) : k;
170
+ function I(g) {
171
+ var $ = g - c, k = g - y, N = n - $;
172
+ return w ? Jt(N, d - k) : N;
173
173
  }
174
- function a(f) {
175
- var H = f - w, L = f - b;
176
- return w === void 0 || H >= l || H < 0 || p && L >= g;
174
+ function S(g) {
175
+ var $ = g - c, k = g - y;
176
+ return c === void 0 || $ >= n || $ < 0 || w && k >= d;
177
177
  }
178
- function d() {
179
- var f = Ne();
180
- if (a(f))
181
- return v(f);
182
- i = setTimeout(d, m(f));
178
+ function v() {
179
+ var g = Ee();
180
+ if (S(g))
181
+ return r(g);
182
+ o = setTimeout(v, I(g));
183
183
  }
184
- function v(f) {
185
- return i = void 0, x && t ? T(f) : (t = y = void 0, h);
184
+ function r(g) {
185
+ return o = void 0, T && a ? p(g) : (a = m = void 0, f);
186
186
  }
187
- function M() {
188
- i !== void 0 && clearTimeout(i), b = 0, t = w = y = i = void 0;
187
+ function s() {
188
+ o !== void 0 && clearTimeout(o), y = 0, a = c = m = o = void 0;
189
189
  }
190
- function P() {
191
- return i === void 0 ? h : v(Ne());
190
+ function L() {
191
+ return o === void 0 ? f : r(Ee());
192
192
  }
193
- function I() {
194
- var f = Ne(), H = a(f);
195
- if (t = arguments, y = this, w = f, H) {
196
- if (i === void 0)
197
- return s(w);
198
- if (p)
199
- return clearTimeout(i), i = setTimeout(d, l), T(w);
193
+ function M() {
194
+ var g = Ee(), $ = S(g);
195
+ if (a = arguments, m = this, c = g, $) {
196
+ if (o === void 0)
197
+ return h(c);
198
+ if (w)
199
+ return clearTimeout(o), o = setTimeout(v, n), p(c);
200
200
  }
201
- return i === void 0 && (i = setTimeout(d, l)), h;
201
+ return o === void 0 && (o = setTimeout(v, n)), f;
202
202
  }
203
- return I.cancel = M, I.flush = P, I;
204
- }
205
- function ue(e, l) {
206
- const r = l ?? (typeof window < "u" ? window.innerWidth : 1024), t = e.sizes;
207
- return r >= 1536 && t["2xl"] ? t["2xl"] : r >= 1280 && t.xl ? t.xl : r >= 1024 && t.lg ? t.lg : r >= 768 && t.md ? t.md : r >= 640 && t.sm ? t.sm : t.base;
203
+ return M.cancel = s, M.flush = L, M;
208
204
  }
209
- function Jt(e) {
210
- const l = e ?? (typeof window < "u" ? window.innerWidth : 1024);
211
- return l >= 1536 ? "2xl" : l >= 1280 ? "xl" : l >= 1024 ? "lg" : l >= 768 ? "md" : l >= 640 ? "sm" : "base";
205
+ function se(e, n) {
206
+ const i = n ?? (typeof window < "u" ? window.innerWidth : 1024), a = e.sizes;
207
+ return i >= 1536 && a["2xl"] ? a["2xl"] : i >= 1280 && a.xl ? a.xl : i >= 1024 && a.lg ? a.lg : i >= 768 && a.md ? a.md : i >= 640 && a.sm ? a.sm : a.base;
212
208
  }
213
209
  function Kt(e) {
214
- return e.reduce((r, t) => Math.max(r, t.top + t.columnHeight), 0) + 500;
210
+ const n = e ?? (typeof window < "u" ? window.innerWidth : 1024);
211
+ return n >= 1536 ? "2xl" : n >= 1280 ? "xl" : n >= 1024 ? "lg" : n >= 768 ? "md" : n >= 640 ? "sm" : "base";
215
212
  }
216
213
  function Qt(e) {
214
+ return e.reduce((i, a) => Math.max(i, a.top + a.columnHeight), 0) + 500;
215
+ }
216
+ function Zt(e) {
217
217
  return {
218
218
  transform: `translate3d(${e.left}px, ${e.top}px, 0)`,
219
219
  top: "0px",
@@ -222,647 +222,674 @@ function Qt(e) {
222
222
  height: `${e.columnHeight}px`
223
223
  };
224
224
  }
225
- function Zt(e, l = 0) {
225
+ function ea(e, n = 0) {
226
226
  return {
227
- style: Qt(e),
227
+ style: Zt(e),
228
228
  "data-top": e.top,
229
229
  "data-left": e.left,
230
230
  "data-id": `${e.page}-${e.id}`,
231
- "data-index": l
231
+ "data-index": n
232
232
  };
233
233
  }
234
- function be(e, l) {
235
- if (!e.length || l <= 0)
236
- return new Array(Math.max(1, l)).fill(0);
237
- const t = Array.from(new Set(e.map((h) => h.left))).sort((h, i) => h - i).slice(0, l), y = /* @__PURE__ */ new Map();
238
- for (let h = 0; h < t.length; h++) y.set(t[h], h);
239
- const g = new Array(t.length).fill(0);
240
- for (const h of e) {
241
- const i = y.get(h.left);
242
- i != null && (g[i] = Math.max(g[i], h.top + h.columnHeight));
234
+ function $e(e, n) {
235
+ if (!e.length || n <= 0)
236
+ return new Array(Math.max(1, n)).fill(0);
237
+ const a = Array.from(new Set(e.map((f) => f.left))).sort((f, o) => f - o).slice(0, n), m = /* @__PURE__ */ new Map();
238
+ for (let f = 0; f < a.length; f++) m.set(a[f], f);
239
+ const d = new Array(a.length).fill(0);
240
+ for (const f of e) {
241
+ const o = m.get(f.left);
242
+ o != null && (d[o] = Math.max(d[o], f.top + f.columnHeight));
243
243
  }
244
- for (; g.length < l; ) g.push(0);
245
- return g;
244
+ for (; d.length < n; ) d.push(0);
245
+ return d;
246
246
  }
247
- function ea(e, l) {
248
- let r = 0, t = 0;
249
- const y = 1e3;
250
- function g(n, p) {
251
- var s;
252
- const x = (s = e.container) == null ? void 0 : s.value;
253
- if (x) {
254
- const m = x.scrollTop, a = x.clientHeight;
255
- r = m - y, t = m + a + y;
247
+ function ta(e, n) {
248
+ let i = 0, a = 0;
249
+ const m = 1e3;
250
+ function d(t, w) {
251
+ var h;
252
+ const T = (h = e.container) == null ? void 0 : h.value;
253
+ if (T) {
254
+ const I = T.scrollTop, S = T.clientHeight;
255
+ i = I - m, a = I + S + m;
256
256
  }
257
- return n + p >= r && n <= t;
257
+ return t + w >= i && t <= a;
258
258
  }
259
- function h(n, p) {
260
- var v;
261
- const x = parseInt(n.dataset.left || "0", 10), T = parseInt(n.dataset.top || "0", 10), s = parseInt(n.dataset.index || "0", 10), m = n.offsetHeight || parseInt(getComputedStyle(n).height || "200", 10) || 200;
262
- if ((v = l == null ? void 0 : l.virtualizing) != null && v.value) {
263
- n.style.transition = "none", n.style.opacity = "1", n.style.transform = `translate3d(${x}px, ${T}px, 0) scale(1)`, n.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
264
- n.style.transition = "", p();
259
+ function f(t, w) {
260
+ var r;
261
+ const T = parseInt(t.dataset.left || "0", 10), p = parseInt(t.dataset.top || "0", 10), h = parseInt(t.dataset.index || "0", 10), I = t.offsetHeight || parseInt(getComputedStyle(t).height || "200", 10) || 200;
262
+ if ((r = n == null ? void 0 : n.virtualizing) != null && r.value) {
263
+ t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${T}px, ${p}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
264
+ t.style.transition = "", w();
265
265
  });
266
266
  return;
267
267
  }
268
- if (!g(T, m)) {
269
- n.style.opacity = "1", n.style.transform = `translate3d(${x}px, ${T}px, 0) scale(1)`, n.style.transition = "none", p();
268
+ if (!d(p, I)) {
269
+ t.style.opacity = "1", t.style.transform = `translate3d(${T}px, ${p}px, 0) scale(1)`, t.style.transition = "none", w();
270
270
  return;
271
271
  }
272
- const a = Math.min(s * 20, 160), d = n.style.getPropertyValue("--masonry-opacity-delay");
273
- n.style.setProperty("--masonry-opacity-delay", `${a}ms`), requestAnimationFrame(() => {
274
- n.style.opacity = "1", n.style.transform = `translate3d(${x}px, ${T}px, 0) scale(1)`;
275
- const M = () => {
276
- d ? n.style.setProperty("--masonry-opacity-delay", d) : n.style.removeProperty("--masonry-opacity-delay"), n.removeEventListener("transitionend", M), p();
272
+ const S = Math.min(h * 20, 160), v = t.style.getPropertyValue("--masonry-opacity-delay");
273
+ t.style.setProperty("--masonry-opacity-delay", `${S}ms`), requestAnimationFrame(() => {
274
+ t.style.opacity = "1", t.style.transform = `translate3d(${T}px, ${p}px, 0) scale(1)`;
275
+ const s = () => {
276
+ v ? t.style.setProperty("--masonry-opacity-delay", v) : t.style.removeProperty("--masonry-opacity-delay"), t.removeEventListener("transitionend", s), w();
277
277
  };
278
- n.addEventListener("transitionend", M);
278
+ t.addEventListener("transitionend", s);
279
279
  });
280
280
  }
281
- function i(n) {
282
- var T;
283
- const p = parseInt(n.dataset.left || "0", 10), x = parseInt(n.dataset.top || "0", 10);
284
- if ((T = l == null ? void 0 : l.virtualizing) != null && T.value) {
285
- n.style.transition = "none", n.style.opacity = "1", n.style.transform = `translate3d(${p}px, ${x}px, 0) scale(1)`, n.style.removeProperty("--masonry-opacity-delay");
281
+ function o(t) {
282
+ var p;
283
+ const w = parseInt(t.dataset.left || "0", 10), T = parseInt(t.dataset.top || "0", 10);
284
+ if ((p = n == null ? void 0 : n.virtualizing) != null && p.value) {
285
+ t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${w}px, ${T}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay");
286
286
  return;
287
287
  }
288
- n.style.opacity = "0", n.style.transform = `translate3d(${p}px, ${x + 10}px, 0) scale(0.985)`;
288
+ t.style.opacity = "0", t.style.transform = `translate3d(${w}px, ${T + 10}px, 0) scale(0.985)`;
289
289
  }
290
- function w(n) {
291
- var s;
292
- const p = parseInt(n.dataset.left || "0", 10), x = parseInt(n.dataset.top || "0", 10), T = n.offsetHeight || parseInt(getComputedStyle(n).height || "200", 10) || 200;
293
- if (!((s = l == null ? void 0 : l.virtualizing) != null && s.value)) {
294
- if (!g(x, T)) {
295
- n.style.transition = "none";
290
+ function c(t) {
291
+ var h;
292
+ const w = parseInt(t.dataset.left || "0", 10), T = parseInt(t.dataset.top || "0", 10), p = t.offsetHeight || parseInt(getComputedStyle(t).height || "200", 10) || 200;
293
+ if (!((h = n == null ? void 0 : n.virtualizing) != null && h.value)) {
294
+ if (!d(T, p)) {
295
+ t.style.transition = "none";
296
296
  return;
297
297
  }
298
- n.style.transition = "none", n.style.opacity = "1", n.style.transform = `translate3d(${p}px, ${x}px, 0) scale(1)`, n.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
299
- n.style.transition = "";
298
+ t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${w}px, ${T}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
299
+ t.style.transition = "";
300
300
  });
301
301
  }
302
302
  }
303
- function b(n, p) {
304
- var I;
305
- const x = parseInt(n.dataset.left || "0", 10), T = parseInt(n.dataset.top || "0", 10), s = n.offsetHeight || parseInt(getComputedStyle(n).height || "200", 10) || 200;
306
- if ((I = l == null ? void 0 : l.virtualizing) != null && I.value) {
307
- p();
303
+ function y(t, w) {
304
+ var M;
305
+ const T = parseInt(t.dataset.left || "0", 10), p = parseInt(t.dataset.top || "0", 10), h = t.offsetHeight || parseInt(getComputedStyle(t).height || "200", 10) || 200;
306
+ if ((M = n == null ? void 0 : n.virtualizing) != null && M.value) {
307
+ w();
308
308
  return;
309
309
  }
310
- if (!g(T, s)) {
311
- n.style.transition = "none", n.style.opacity = "0", p();
310
+ if (!d(p, h)) {
311
+ t.style.transition = "none", t.style.opacity = "0", w();
312
312
  return;
313
313
  }
314
- const m = typeof (l == null ? void 0 : l.leaveDurationMs) == "number" ? l.leaveDurationMs : NaN;
315
- let a = Number.isFinite(m) && m > 0 ? m : NaN;
316
- if (!Number.isFinite(a)) {
317
- const H = getComputedStyle(n).getPropertyValue("--masonry-leave-duration") || "", L = parseFloat(H);
318
- a = Number.isFinite(L) && L > 0 ? L : 200;
314
+ const I = typeof (n == null ? void 0 : n.leaveDurationMs) == "number" ? n.leaveDurationMs : Number.NaN;
315
+ let S = Number.isFinite(I) && I > 0 ? I : Number.NaN;
316
+ if (!Number.isFinite(S)) {
317
+ const $ = getComputedStyle(t).getPropertyValue("--masonry-leave-duration") || "", k = parseFloat($);
318
+ S = Number.isFinite(k) && k > 0 ? k : 200;
319
319
  }
320
- const d = n.style.transitionDuration, v = () => {
321
- n.removeEventListener("transitionend", M), clearTimeout(P), n.style.transitionDuration = d || "";
322
- }, M = (f) => {
323
- (!f || f.target === n) && (v(), p());
324
- }, P = setTimeout(() => {
325
- v(), p();
326
- }, a + 100);
320
+ const v = t.style.transitionDuration, r = () => {
321
+ t.removeEventListener("transitionend", s), clearTimeout(L), t.style.transitionDuration = v || "";
322
+ }, s = (g) => {
323
+ (!g || g.target === t) && (r(), w());
324
+ }, L = setTimeout(() => {
325
+ r(), w();
326
+ }, S + 100);
327
327
  requestAnimationFrame(() => {
328
- n.style.transitionDuration = `${a}ms`, n.style.opacity = "0", n.style.transform = `translate3d(${x}px, ${T + 10}px, 0) scale(0.985)`, n.addEventListener("transitionend", M);
328
+ t.style.transitionDuration = `${S}ms`, t.style.opacity = "0", t.style.transform = `translate3d(${T}px, ${p + 10}px, 0) scale(0.985)`, t.addEventListener("transitionend", s);
329
329
  });
330
330
  }
331
331
  return {
332
- onEnter: h,
333
- onBeforeEnter: i,
334
- onBeforeLeave: w,
335
- onLeave: b
332
+ onEnter: f,
333
+ onBeforeEnter: o,
334
+ onBeforeLeave: c,
335
+ onLeave: y
336
336
  };
337
337
  }
338
- function ta({
338
+ function aa({
339
339
  container: e,
340
- masonry: l,
341
- columns: r,
342
- containerHeight: t,
343
- isLoading: y,
344
- pageSize: g,
345
- refreshLayout: h,
346
- setItemsRaw: i,
347
- loadNext: w,
348
- loadThresholdPx: b
340
+ masonry: n,
341
+ columns: i,
342
+ containerHeight: a,
343
+ isLoading: m,
344
+ pageSize: d,
345
+ refreshLayout: f,
346
+ setItemsRaw: o,
347
+ loadNext: c,
348
+ loadThresholdPx: y
349
349
  }) {
350
- let n = 0;
351
- async function p(x, T = !1) {
350
+ let t = 0;
351
+ async function w(T, p = !1) {
352
352
  if (!e.value) return;
353
- const s = x ?? be(l.value, r.value), m = s.length ? Math.max(...s) : 0, a = e.value.scrollTop + e.value.clientHeight, d = e.value.scrollTop > n + 1;
354
- n = e.value.scrollTop;
355
- const v = typeof b == "number" ? b : 200, M = v >= 0 ? Math.max(0, m - v) : Math.max(0, m + v);
356
- if (a >= M && (d || T) && !y.value) {
357
- await w(), await q();
353
+ const h = T ?? $e(n.value, i.value), I = h.length ? Math.max(...h) : 0, S = e.value.scrollTop + e.value.clientHeight, v = e.value.scrollTop > t + 1;
354
+ t = e.value.scrollTop;
355
+ const r = typeof y == "number" ? y : 200, s = r >= 0 ? Math.max(0, I - r) : Math.max(0, I + r);
356
+ if (S >= s && (v || p) && !m.value) {
357
+ await c(), await X();
358
358
  return;
359
359
  }
360
360
  }
361
361
  return {
362
- handleScroll: p
362
+ handleScroll: w
363
363
  };
364
364
  }
365
- function aa(e) {
366
- const { useSwipeMode: l, masonry: r, isLoading: t, loadNext: y, loadPage: g, paginationHistory: h } = e, i = B(0), w = B(0), b = B(!1), n = B(0), p = B(0), x = B(null), T = Z(() => {
367
- if (!l.value || r.value.length === 0) return null;
368
- const o = Math.max(0, Math.min(i.value, r.value.length - 1));
369
- return r.value[o] || null;
370
- }), s = Z(() => {
371
- if (!l.value || !T.value) return null;
372
- const o = i.value + 1;
373
- return o >= r.value.length ? null : r.value[o] || null;
374
- }), m = Z(() => {
375
- if (!l.value || !T.value) return null;
376
- const o = i.value - 1;
377
- return o < 0 ? null : r.value[o] || null;
365
+ function na(e) {
366
+ const { useSwipeMode: n, masonry: i, isLoading: a, loadNext: m, loadPage: d, paginationHistory: f } = e, o = W(0), c = W(0), y = W(!1), t = W(0), w = W(0), T = W(null), p = K(() => {
367
+ if (!n.value || i.value.length === 0) return null;
368
+ const P = Math.max(0, Math.min(o.value, i.value.length - 1));
369
+ return i.value[P] || null;
370
+ }), h = K(() => {
371
+ if (!n.value || !p.value) return null;
372
+ const P = o.value + 1;
373
+ return P >= i.value.length ? null : i.value[P] || null;
374
+ }), I = K(() => {
375
+ if (!n.value || !p.value) return null;
376
+ const P = o.value - 1;
377
+ return P < 0 ? null : i.value[P] || null;
378
378
  });
379
- function a() {
380
- if (!x.value) return;
381
- const o = x.value.clientHeight;
382
- w.value = -i.value * o;
379
+ function S() {
380
+ if (!T.value) return;
381
+ const P = T.value.clientHeight;
382
+ c.value = -o.value * P;
383
383
  }
384
- function d() {
385
- if (!s.value) {
386
- y();
384
+ function v() {
385
+ if (!h.value) {
386
+ m();
387
387
  return;
388
388
  }
389
- i.value++, a(), i.value >= r.value.length - 5 && y();
389
+ o.value++, S(), o.value >= i.value.length - 5 && m();
390
390
  }
391
- function v() {
392
- m.value && (i.value--, a());
391
+ function r() {
392
+ I.value && (o.value--, S());
393
393
  }
394
- function M(o) {
395
- l.value && (b.value = !0, n.value = o.touches[0].clientY, p.value = w.value, o.preventDefault());
394
+ function s(P) {
395
+ n.value && (y.value = !0, t.value = P.touches[0].clientY, w.value = c.value, P.preventDefault());
396
396
  }
397
- function P(o) {
398
- if (!l.value || !b.value) return;
399
- const u = o.touches[0].clientY - n.value;
400
- w.value = p.value + u, o.preventDefault();
397
+ function L(P) {
398
+ if (!n.value || !y.value) return;
399
+ const z = P.touches[0].clientY - t.value;
400
+ c.value = w.value + z, P.preventDefault();
401
401
  }
402
- function I(o) {
403
- if (!l.value || !b.value) return;
404
- b.value = !1;
405
- const u = w.value - p.value;
406
- Math.abs(u) > 100 ? u > 0 && m.value ? v() : u < 0 && s.value ? d() : a() : a(), o.preventDefault();
402
+ function M(P) {
403
+ if (!n.value || !y.value) return;
404
+ y.value = !1;
405
+ const z = c.value - w.value;
406
+ Math.abs(z) > 100 ? z > 0 && I.value ? r() : z < 0 && h.value ? v() : S() : S(), P.preventDefault();
407
407
  }
408
- function f(o) {
409
- l.value && (b.value = !0, n.value = o.clientY, p.value = w.value, o.preventDefault());
408
+ function g(P) {
409
+ n.value && (y.value = !0, t.value = P.clientY, w.value = c.value, P.preventDefault());
410
410
  }
411
- function H(o) {
412
- if (!l.value || !b.value) return;
413
- const u = o.clientY - n.value;
414
- w.value = p.value + u, o.preventDefault();
411
+ function $(P) {
412
+ if (!n.value || !y.value) return;
413
+ const z = P.clientY - t.value;
414
+ c.value = w.value + z, P.preventDefault();
415
415
  }
416
- function L(o) {
417
- if (!l.value || !b.value) return;
418
- b.value = !1;
419
- const u = w.value - p.value;
420
- Math.abs(u) > 100 ? u > 0 && m.value ? v() : u < 0 && s.value ? d() : a() : a(), o.preventDefault();
416
+ function k(P) {
417
+ if (!n.value || !y.value) return;
418
+ y.value = !1;
419
+ const z = c.value - w.value;
420
+ Math.abs(z) > 100 ? z > 0 && I.value ? r() : z < 0 && h.value ? v() : S() : S(), P.preventDefault();
421
421
  }
422
- function k() {
423
- !l.value && i.value > 0 && (i.value = 0, w.value = 0), l.value && r.value.length === 0 && !t.value && g(h.value[0]), l.value && a();
422
+ function N() {
423
+ !n.value && o.value > 0 && (o.value = 0, c.value = 0), n.value && i.value.length === 0 && !a.value && d(f.value[0]), n.value && S();
424
424
  }
425
- function W() {
426
- i.value = 0, w.value = 0, b.value = !1;
425
+ function A() {
426
+ o.value = 0, c.value = 0, y.value = !1;
427
427
  }
428
428
  return {
429
429
  // State
430
- currentSwipeIndex: i,
431
- swipeOffset: w,
432
- isDragging: b,
433
- swipeContainer: x,
430
+ currentSwipeIndex: o,
431
+ swipeOffset: c,
432
+ isDragging: y,
433
+ swipeContainer: T,
434
434
  // Computed
435
- currentItem: T,
436
- nextItem: s,
437
- previousItem: m,
435
+ currentItem: p,
436
+ nextItem: h,
437
+ previousItem: I,
438
438
  // Functions
439
- handleTouchStart: M,
440
- handleTouchMove: P,
441
- handleTouchEnd: I,
442
- handleMouseDown: f,
443
- handleMouseMove: H,
444
- handleMouseUp: L,
445
- goToNextItem: d,
446
- goToPreviousItem: v,
447
- snapToCurrentItem: a,
448
- handleWindowResize: k,
449
- reset: W
439
+ handleTouchStart: s,
440
+ handleTouchMove: L,
441
+ handleTouchEnd: M,
442
+ handleMouseDown: g,
443
+ handleMouseMove: $,
444
+ handleMouseUp: k,
445
+ goToNextItem: v,
446
+ goToPreviousItem: r,
447
+ snapToCurrentItem: S,
448
+ handleWindowResize: N,
449
+ reset: A
450
450
  };
451
451
  }
452
452
  function me(e) {
453
453
  return e instanceof Error ? e : new Error(String(e));
454
454
  }
455
- function na(e) {
455
+ function la(e) {
456
456
  const {
457
- getNextPage: l,
458
- masonry: r,
459
- isLoading: t,
460
- hasReachedEnd: y,
461
- loadError: g,
462
- currentPage: h,
463
- paginationHistory: i,
464
- refreshLayout: w,
465
- retryMaxAttempts: b,
466
- retryInitialDelayMs: n,
467
- retryBackoffStepMs: p,
468
- backfillEnabled: x,
469
- backfillDelayMs: T,
470
- backfillMaxCalls: s,
471
- pageSize: m,
472
- autoRefreshOnEmpty: a,
473
- emits: d
474
- } = e, v = B(!1);
475
- let M = !1;
476
- function P(u, E) {
477
- return new Promise(($) => {
478
- const C = Math.max(0, u | 0), A = Date.now();
479
- E(C, C);
480
- const N = setInterval(() => {
481
- if (v.value) {
482
- clearInterval(N), $();
457
+ getPage: n,
458
+ context: i,
459
+ masonry: a,
460
+ isLoading: m,
461
+ hasReachedEnd: d,
462
+ loadError: f,
463
+ currentPage: o,
464
+ paginationHistory: c,
465
+ refreshLayout: y,
466
+ retryMaxAttempts: t,
467
+ retryInitialDelayMs: w,
468
+ retryBackoffStepMs: T,
469
+ mode: p,
470
+ backfillDelayMs: h,
471
+ backfillMaxCalls: I,
472
+ pageSize: S,
473
+ emits: v
474
+ } = e, r = W(!1);
475
+ let s = !1;
476
+ function L(F) {
477
+ return a.value.filter((l) => l.page === F).length;
478
+ }
479
+ function M(F, l) {
480
+ return new Promise((x) => {
481
+ const E = Math.max(0, F | 0), D = Date.now();
482
+ l(E, E);
483
+ const V = setInterval(() => {
484
+ if (r.value) {
485
+ clearInterval(V), x();
483
486
  return;
484
487
  }
485
- const j = Date.now() - A, G = Math.max(0, C - j);
486
- E(G, C), G <= 0 && (clearInterval(N), $());
488
+ const C = Date.now() - D, b = Math.max(0, E - C);
489
+ l(b, E), b <= 0 && (clearInterval(V), x());
487
490
  }, 100);
488
491
  });
489
492
  }
490
- async function I(u) {
491
- let E = 0;
492
- const $ = b;
493
- let C = n;
493
+ async function g(F) {
494
+ let l = 0;
495
+ const x = t;
496
+ let E = w;
494
497
  for (; ; )
495
498
  try {
496
- const A = await u();
497
- return E > 0 && d("retry:stop", { attempt: E, success: !0 }), A;
498
- } catch (A) {
499
- if (E++, E > $)
500
- throw d("retry:stop", { attempt: E - 1, success: !1 }), A;
501
- d("retry:start", { attempt: E, max: $, totalMs: C }), await P(C, (N, j) => {
502
- d("retry:tick", { attempt: E, remainingMs: N, totalMs: j });
503
- }), C += p;
499
+ const D = await F();
500
+ return l > 0 && v("retry:stop", { attempt: l, success: !0 }), D;
501
+ } catch (D) {
502
+ if (l++, l > x)
503
+ throw v("retry:stop", { attempt: l - 1, success: !1 }), D;
504
+ v("retry:start", { attempt: l, max: x, totalMs: E }), await M(E, (V, C) => {
505
+ v("retry:tick", { attempt: l, remainingMs: V, totalMs: C });
506
+ }), E += T;
504
507
  }
505
508
  }
506
- async function f(u) {
509
+ async function $(F) {
507
510
  try {
508
- const E = await I(() => l(u));
509
- return w([...r.value, ...E.items]), E;
510
- } catch (E) {
511
- throw E;
511
+ const l = await g(() => n(F, i == null ? void 0 : i.value));
512
+ return y([...a.value, ...l.items]), l;
513
+ } catch (l) {
514
+ throw l;
512
515
  }
513
516
  }
514
- async function H(u, E = !1) {
515
- if (!E && !x || M || v.value || y.value) return;
516
- const $ = (u || 0) + (m || 0);
517
- if (!m || m <= 0) return;
518
- if (i.value[i.value.length - 1] == null) {
519
- y.value = !0;
517
+ async function k(F, l = !1) {
518
+ if (!l && p !== "backfill" || s || r.value || d.value) return;
519
+ const x = (F || 0) + (S || 0);
520
+ if (!S || S <= 0) return;
521
+ if (c.value[c.value.length - 1] == null) {
522
+ d.value = !0;
520
523
  return;
521
524
  }
522
- if (!(r.value.length >= $)) {
523
- M = !0, t.value = !0;
525
+ if (!(a.value.length >= x)) {
526
+ s = !0, m.value || (m.value = !0, v("loading:start"));
524
527
  try {
525
- let A = 0;
526
- for (d("backfill:start", { target: $, fetched: r.value.length, calls: A }); r.value.length < $ && A < s && i.value[i.value.length - 1] != null && !v.value && !y.value && M && (await P(T, (j, G) => {
527
- d("backfill:tick", {
528
- fetched: r.value.length,
529
- target: $,
530
- calls: A,
531
- remainingMs: j,
532
- totalMs: G
528
+ let D = 0;
529
+ for (v("backfill:start", { target: x, fetched: a.value.length, calls: D }); a.value.length < x && D < I && c.value[c.value.length - 1] != null && !r.value && !d.value && s && (await M(h, (C, b) => {
530
+ v("backfill:tick", {
531
+ fetched: a.value.length,
532
+ target: x,
533
+ calls: D,
534
+ remainingMs: C,
535
+ totalMs: b
533
536
  });
534
- }), !(v.value || !M)); ) {
535
- const N = i.value[i.value.length - 1];
536
- if (N == null) {
537
- y.value = !0;
537
+ }), !(r.value || !s)); ) {
538
+ const V = c.value[c.value.length - 1];
539
+ if (V == null) {
540
+ d.value = !0;
538
541
  break;
539
542
  }
540
543
  try {
541
- if (v.value || !M) break;
542
- const j = await f(N);
543
- if (v.value || !M) break;
544
- g.value = null, i.value.push(j.nextPage), j.nextPage == null && (y.value = !0);
545
- } catch (j) {
546
- if (v.value || !M) break;
547
- g.value = me(j);
544
+ if (r.value || !s) break;
545
+ const C = await $(V);
546
+ if (r.value || !s) break;
547
+ f.value = null, c.value.push(C.nextPage), C.nextPage == null && (d.value = !0);
548
+ } catch (C) {
549
+ if (r.value || !s) break;
550
+ f.value = me(C);
548
551
  }
549
- A++;
552
+ D++;
550
553
  }
551
- d("backfill:stop", { fetched: r.value.length, calls: A });
554
+ v("backfill:stop", { fetched: a.value.length, calls: D });
552
555
  } finally {
553
- M = !1, t.value = !1;
556
+ s = !1, m.value = !1, v("loading:stop", { fetched: a.value.length });
554
557
  }
555
558
  }
556
559
  }
557
- async function L(u) {
558
- if (!t.value) {
559
- v.value = !1, t.value = !0, y.value = !1, g.value = null;
560
+ async function N(F) {
561
+ if (!m.value) {
562
+ r.value = !1, m.value || (m.value = !0, v("loading:start")), d.value = !1, f.value = null;
560
563
  try {
561
- const E = r.value.length;
562
- if (v.value) return;
563
- const $ = await f(u);
564
- return v.value ? void 0 : (g.value = null, h.value = u, i.value.push($.nextPage), $.nextPage == null && (y.value = !0), await H(E), $);
565
- } catch (E) {
566
- throw g.value = me(E), E;
564
+ const l = a.value.length;
565
+ if (r.value) return;
566
+ const x = await $(F);
567
+ return r.value ? void 0 : (f.value = null, o.value = F, c.value.push(x.nextPage), x.nextPage == null && (d.value = !0), await k(l), x);
568
+ } catch (l) {
569
+ throw f.value = me(l), l;
567
570
  } finally {
568
- t.value = !1;
571
+ m.value = !1;
569
572
  }
570
573
  }
571
574
  }
572
- async function k() {
573
- if (!t.value && !y.value) {
574
- v.value = !1, t.value = !0, g.value = null;
575
+ async function A() {
576
+ if (!m.value && !d.value) {
577
+ r.value = !1, m.value || (m.value = !0, v("loading:start")), f.value = null;
575
578
  try {
576
- const u = r.value.length;
577
- if (v.value) return;
578
- const E = i.value[i.value.length - 1];
579
- if (E == null) {
580
- y.value = !0, t.value = !1;
579
+ const F = a.value.length;
580
+ if (r.value) return;
581
+ if (p === "refresh" && o.value != null && L(o.value) < S) {
582
+ const D = await g(() => n(o.value, i == null ? void 0 : i.value));
583
+ if (r.value) return;
584
+ const V = [...a.value], C = D.items.filter((H) => !H || H.id == null || H.page == null ? !1 : !V.some((R) => R && R.id === H.id && R.page === H.page));
585
+ if (C.length > 0) {
586
+ const H = [...a.value, ...C];
587
+ y(H), await new Promise((R) => setTimeout(R, 0));
588
+ }
589
+ if (f.value = null, C.length === 0) {
590
+ const H = c.value[c.value.length - 1];
591
+ if (H == null) {
592
+ d.value = !0;
593
+ return;
594
+ }
595
+ const R = await $(H);
596
+ return r.value ? void 0 : (f.value = null, o.value = H, c.value.push(R.nextPage), R.nextPage == null && (d.value = !0), await k(F), R);
597
+ }
598
+ if (L(o.value) >= S) {
599
+ const H = c.value[c.value.length - 1];
600
+ if (H == null) {
601
+ d.value = !0;
602
+ return;
603
+ }
604
+ const R = await $(H);
605
+ return r.value ? void 0 : (f.value = null, o.value = H, c.value.push(R.nextPage), R.nextPage == null && (d.value = !0), await k(F), R);
606
+ } else
607
+ return D;
608
+ }
609
+ const l = c.value[c.value.length - 1];
610
+ if (l == null) {
611
+ d.value = !0;
581
612
  return;
582
613
  }
583
- const $ = await f(E);
584
- return v.value ? void 0 : (g.value = null, h.value = E, i.value.push($.nextPage), $.nextPage == null && (y.value = !0), await H(u), $);
585
- } catch (u) {
586
- throw g.value = me(u), u;
614
+ const x = await $(l);
615
+ return r.value ? void 0 : (f.value = null, o.value = l, c.value.push(x.nextPage), x.nextPage == null && (d.value = !0), await k(F), x);
616
+ } catch (F) {
617
+ throw f.value = me(F), F;
587
618
  } finally {
588
- t.value = !1;
619
+ m.value = !1, v("loading:stop", { fetched: a.value.length });
589
620
  }
590
621
  }
591
622
  }
592
- async function W() {
593
- if (!t.value) {
594
- v.value = !1, t.value = !0;
623
+ async function P() {
624
+ if (!m.value) {
625
+ r.value = !1, m.value = !0, v("loading:start");
595
626
  try {
596
- const u = h.value;
597
- if (u == null) {
598
- console.warn("[Masonry] No current page to refresh - currentPage:", h.value, "paginationHistory:", i.value);
627
+ const F = o.value;
628
+ if (F == null) {
629
+ console.warn("[Masonry] No current page to refresh - currentPage:", o.value, "paginationHistory:", c.value);
599
630
  return;
600
631
  }
601
- r.value = [], y.value = !1, g.value = null, i.value = [u];
602
- const E = await f(u);
603
- if (v.value) return;
604
- g.value = null, h.value = u, i.value.push(E.nextPage), E.nextPage == null && (y.value = !0);
605
- const $ = r.value.length;
606
- return await H($), E;
607
- } catch (u) {
608
- throw g.value = me(u), u;
632
+ a.value = [], d.value = !1, f.value = null, c.value = [F];
633
+ const l = await $(F);
634
+ if (r.value) return;
635
+ f.value = null, o.value = F, c.value.push(l.nextPage), l.nextPage == null && (d.value = !0);
636
+ const x = a.value.length;
637
+ return await k(x), l;
638
+ } catch (F) {
639
+ throw f.value = me(F), F;
609
640
  } finally {
610
- t.value = !1;
641
+ m.value = !1, v("loading:stop", { fetched: a.value.length });
611
642
  }
612
643
  }
613
644
  }
614
- function o() {
615
- const u = M;
616
- v.value = !0, t.value = !1, M = !1, u && d("backfill:stop", { fetched: r.value.length, calls: 0, cancelled: !0 });
645
+ function z() {
646
+ const F = s;
647
+ r.value = !0, m.value = !1, s = !1, F && v("backfill:stop", { fetched: a.value.length, calls: 0, cancelled: !0 }), v("loading:stop", { fetched: a.value.length });
617
648
  }
618
649
  return {
619
- loadPage: L,
620
- loadNext: k,
621
- refreshCurrentPage: W,
622
- cancelLoad: o,
623
- maybeBackfillToTarget: H,
624
- getContent: f
650
+ loadPage: N,
651
+ loadNext: A,
652
+ refreshCurrentPage: P,
653
+ cancelLoad: z,
654
+ maybeBackfillToTarget: k,
655
+ getContent: $
625
656
  };
626
657
  }
627
- function la(e) {
658
+ function oa(e) {
628
659
  const {
629
- masonry: l,
630
- useSwipeMode: r,
631
- refreshLayout: t,
632
- refreshCurrentPage: y,
633
- loadNext: g,
634
- maybeBackfillToTarget: h,
635
- autoRefreshOnEmpty: i,
636
- paginationHistory: w
660
+ masonry: n,
661
+ useSwipeMode: i,
662
+ refreshLayout: a,
663
+ loadNext: m,
664
+ maybeBackfillToTarget: d,
665
+ paginationHistory: f
637
666
  } = e;
638
- async function b(s) {
639
- const m = l.value.filter((a) => a.id !== s.id);
640
- if (l.value = m, await q(), m.length === 0 && w.value.length > 0) {
641
- if (i)
642
- await y();
643
- else
644
- try {
645
- await g(), await h(0, !0);
646
- } catch {
647
- }
648
- return;
649
- }
650
- await new Promise((a) => requestAnimationFrame(() => a())), requestAnimationFrame(() => {
651
- t(m);
652
- });
667
+ let o = /* @__PURE__ */ new Set(), c = null, y = !1;
668
+ async function t() {
669
+ if (o.size === 0 || y) return;
670
+ y = !0;
671
+ const v = Array.from(o);
672
+ o.clear(), c = null, await T(v), y = !1;
653
673
  }
654
- async function n(s) {
655
- if (!s || s.length === 0) return;
656
- const m = new Set(s.map((d) => d.id)), a = l.value.filter((d) => !m.has(d.id));
657
- if (l.value = a, await q(), a.length === 0 && w.value.length > 0) {
658
- if (i)
659
- await y();
660
- else
661
- try {
662
- await g(), await h(0, !0);
663
- } catch {
664
- }
674
+ async function w(v) {
675
+ o.add(v), c && clearTimeout(c), c = setTimeout(() => {
676
+ t();
677
+ }, 16);
678
+ }
679
+ async function T(v) {
680
+ if (!v || v.length === 0) return;
681
+ const r = new Set(v.map((L) => L.id)), s = n.value.filter((L) => !r.has(L.id));
682
+ if (n.value = s, await X(), s.length === 0 && f.value.length > 0) {
683
+ try {
684
+ await m(), await d(0, !0);
685
+ } catch {
686
+ }
665
687
  return;
666
688
  }
667
- await new Promise((d) => requestAnimationFrame(() => d())), requestAnimationFrame(() => {
668
- t(a);
689
+ await new Promise((L) => requestAnimationFrame(() => L())), requestAnimationFrame(() => {
690
+ a(s);
669
691
  });
670
692
  }
671
- async function p(s, m) {
672
- if (!s) return;
673
- const a = l.value;
674
- if (a.findIndex((P) => P.id === s.id) !== -1) return;
675
- const v = [...a], M = Math.min(m, v.length);
676
- v.splice(M, 0, s), l.value = v, await q(), r.value || (await new Promise((P) => requestAnimationFrame(() => P())), requestAnimationFrame(() => {
677
- t(v);
693
+ async function p(v) {
694
+ !v || v.length === 0 || (v.forEach((r) => o.add(r)), c && clearTimeout(c), c = setTimeout(() => {
695
+ t();
696
+ }, 16));
697
+ }
698
+ async function h(v, r) {
699
+ if (!v) return;
700
+ const s = n.value;
701
+ if (s.findIndex(($) => $.id === v.id) !== -1) return;
702
+ const M = [...s], g = Math.min(r, M.length);
703
+ M.splice(g, 0, v), n.value = M, await X(), i.value || (await new Promise(($) => requestAnimationFrame(() => $())), requestAnimationFrame(() => {
704
+ a(M);
678
705
  }));
679
706
  }
680
- async function x(s, m) {
681
- var L;
682
- if (!s || s.length === 0) return;
683
- if (!m || m.length !== s.length) {
707
+ async function I(v, r) {
708
+ var P;
709
+ if (!v || v.length === 0) return;
710
+ if (!r || r.length !== v.length) {
684
711
  console.warn("[Masonry] restoreMany: items and indices arrays must have the same length");
685
712
  return;
686
713
  }
687
- const a = l.value, d = new Set(a.map((k) => k.id)), v = [];
688
- for (let k = 0; k < s.length; k++)
689
- d.has((L = s[k]) == null ? void 0 : L.id) || v.push({ item: s[k], index: m[k] });
690
- if (v.length === 0) return;
691
- const M = /* @__PURE__ */ new Map();
692
- for (const { item: k, index: W } of v)
693
- M.set(W, k);
694
- const P = v.length > 0 ? Math.max(...v.map(({ index: k }) => k)) : -1, I = Math.max(a.length - 1, P), f = [];
695
- let H = 0;
696
- for (let k = 0; k <= I; k++)
697
- M.has(k) ? f.push(M.get(k)) : H < a.length && (f.push(a[H]), H++);
698
- for (; H < a.length; )
699
- f.push(a[H]), H++;
700
- l.value = f, await q(), r.value || (await new Promise((k) => requestAnimationFrame(() => k())), requestAnimationFrame(() => {
701
- t(f);
714
+ const s = n.value, L = new Set(s.map((z) => z.id)), M = [];
715
+ for (let z = 0; z < v.length; z++)
716
+ L.has((P = v[z]) == null ? void 0 : P.id) || M.push({ item: v[z], index: r[z] });
717
+ if (M.length === 0) return;
718
+ const g = /* @__PURE__ */ new Map();
719
+ for (const { item: z, index: F } of M)
720
+ g.set(F, z);
721
+ const $ = M.length > 0 ? Math.max(...M.map(({ index: z }) => z)) : -1, k = Math.max(s.length - 1, $), N = [];
722
+ let A = 0;
723
+ for (let z = 0; z <= k; z++)
724
+ g.has(z) ? N.push(g.get(z)) : A < s.length && (N.push(s[A]), A++);
725
+ for (; A < s.length; )
726
+ N.push(s[A]), A++;
727
+ n.value = N, await X(), i.value || (await new Promise((z) => requestAnimationFrame(() => z())), requestAnimationFrame(() => {
728
+ a(N);
702
729
  }));
703
730
  }
704
- async function T() {
705
- l.value = [];
731
+ async function S() {
732
+ n.value = [];
706
733
  }
707
734
  return {
708
- remove: b,
709
- removeMany: n,
710
- restore: p,
711
- restoreMany: x,
712
- removeAll: T
735
+ remove: w,
736
+ removeMany: p,
737
+ restore: h,
738
+ restoreMany: I,
739
+ removeAll: S
713
740
  };
714
741
  }
715
- function oa(e) {
742
+ function ra(e) {
716
743
  const {
717
- masonry: l,
718
- useSwipeMode: r,
719
- container: t,
720
- columns: y,
721
- containerWidth: g,
722
- masonryContentHeight: h,
723
- layout: i,
724
- fixedDimensions: w,
725
- checkItemDimensions: b
744
+ masonry: n,
745
+ useSwipeMode: i,
746
+ container: a,
747
+ columns: m,
748
+ containerWidth: d,
749
+ masonryContentHeight: f,
750
+ layout: o,
751
+ fixedDimensions: c,
752
+ checkItemDimensions: y
726
753
  } = e;
727
- let n = [];
728
- function p(m) {
729
- const a = Kt(m);
730
- let d = 0;
731
- if (t.value) {
732
- const { scrollTop: v, clientHeight: M } = t.value;
733
- d = v + M + 100;
754
+ let t = [];
755
+ function w(I) {
756
+ const S = Qt(I);
757
+ let v = 0;
758
+ if (a.value) {
759
+ const { scrollTop: r, clientHeight: s } = a.value;
760
+ v = r + s + 100;
734
761
  }
735
- h.value = Math.max(a, d);
762
+ f.value = Math.max(S, v);
736
763
  }
737
- function x(m) {
738
- var M, P;
739
- if (r.value) {
740
- l.value = m;
764
+ function T(I) {
765
+ var s, L;
766
+ if (i.value) {
767
+ n.value = I;
741
768
  return;
742
769
  }
743
- if (!t.value) return;
744
- if (b(m, "refreshLayout"), m.length > 1e3 && n.length > m.length && n.length - m.length < 100) {
745
- let I = !0;
746
- for (let f = 0; f < m.length; f++)
747
- if (((M = m[f]) == null ? void 0 : M.id) !== ((P = n[f]) == null ? void 0 : P.id)) {
748
- I = !1;
770
+ if (n.value = I, !a.value) return;
771
+ if (y(I, "refreshLayout"), I.length > 1e3 && t.length > I.length && t.length - I.length < 100) {
772
+ let M = !0;
773
+ for (let g = 0; g < I.length; g++)
774
+ if (((s = I[g]) == null ? void 0 : s.id) !== ((L = t[g]) == null ? void 0 : L.id)) {
775
+ M = !1;
749
776
  break;
750
777
  }
751
- if (I) {
752
- const f = m.map((H, L) => ({
753
- ...n[L],
754
- originalIndex: L
778
+ if (M) {
779
+ const g = I.map(($, k) => ({
780
+ ...t[k],
781
+ originalIndex: k
755
782
  }));
756
- p(f), l.value = f, n = f;
783
+ w(g), n.value = g, t = g;
757
784
  return;
758
785
  }
759
786
  }
760
- const d = m.map((I, f) => ({
761
- ...I,
762
- originalIndex: f
763
- })), v = t.value;
764
- if (w.value && w.value.width !== void 0) {
765
- const I = v.style.width, f = v.style.boxSizing;
766
- v.style.boxSizing = "border-box", v.style.width = `${w.value.width}px`, v.offsetWidth;
767
- const H = Xe(d, v, y.value, i.value);
768
- v.style.width = I, v.style.boxSizing = f, p(H), l.value = H, n = H;
787
+ const v = I.map((M, g) => ({
788
+ ...M,
789
+ originalIndex: g
790
+ })), r = a.value;
791
+ if (c.value && c.value.width !== void 0) {
792
+ const M = r.style.width, g = r.style.boxSizing;
793
+ r.style.boxSizing = "border-box", r.style.width = `${c.value.width}px`, r.offsetWidth;
794
+ const $ = Ce(v, r, m.value, o.value);
795
+ r.style.width = M, r.style.boxSizing = g, w($), n.value = $, t = $;
769
796
  } else {
770
- const I = Xe(d, v, y.value, i.value);
771
- p(I), l.value = I, n = I;
797
+ const M = Ce(v, r, m.value, o.value);
798
+ w(M), n.value = M, t = M;
772
799
  }
773
800
  }
774
- function T(m, a) {
775
- w.value = m, m && (m.width !== void 0 && (g.value = m.width), !r.value && t.value && l.value.length > 0 && q(() => {
776
- y.value = ue(i.value, g.value), x(l.value), a && a();
801
+ function p(I, S) {
802
+ c.value = I, I && (I.width !== void 0 && (d.value = I.width), !i.value && a.value && n.value.length > 0 && X(() => {
803
+ m.value = se(o.value, d.value), T(n.value), S && S();
777
804
  }));
778
805
  }
779
- function s() {
780
- y.value = ue(i.value, g.value), x(l.value);
806
+ function h() {
807
+ m.value = se(o.value, d.value), T(n.value);
781
808
  }
782
809
  return {
783
- refreshLayout: x,
784
- setFixedDimensions: T,
785
- onResize: s,
786
- calculateHeight: p
810
+ refreshLayout: T,
811
+ setFixedDimensions: p,
812
+ onResize: h,
813
+ calculateHeight: w
787
814
  };
788
815
  }
789
- function ra(e) {
816
+ function ia(e) {
790
817
  const {
791
- masonry: l,
792
- container: r,
793
- columns: t,
794
- virtualBufferPx: y,
795
- loadThresholdPx: g
796
- } = e, h = B(e.handleScroll), i = B(0), w = B(0), b = y, n = B(!1), p = B({
818
+ masonry: n,
819
+ container: i,
820
+ columns: a,
821
+ virtualBufferPx: m,
822
+ loadThresholdPx: d
823
+ } = e, f = W(e.handleScroll), o = W(0), c = W(0), y = m, t = W(!1), w = W({
797
824
  distanceToTrigger: 0,
798
825
  isNearTrigger: !1
799
- }), x = Z(() => {
800
- const a = i.value - b, d = i.value + w.value + b, v = l.value;
801
- return !v || v.length === 0 ? [] : v.filter((P) => {
802
- if (typeof P.top != "number" || typeof P.columnHeight != "number")
826
+ }), T = K(() => {
827
+ const S = o.value - y, v = o.value + c.value + y, r = n.value;
828
+ return !r || r.length === 0 ? [] : r.filter((L) => {
829
+ if (typeof L.top != "number" || typeof L.columnHeight != "number")
803
830
  return !0;
804
- const I = P.top;
805
- return P.top + P.columnHeight >= a && I <= d;
831
+ const M = L.top;
832
+ return L.top + L.columnHeight >= S && M <= v;
806
833
  });
807
834
  });
808
- function T(a) {
809
- if (!r.value) return;
810
- const { scrollTop: d, clientHeight: v } = r.value, M = d + v, P = a ?? be(l.value, t.value), I = P.length ? Math.max(...P) : 0, f = typeof g == "number" ? g : 200, H = f >= 0 ? Math.max(0, I - f) : Math.max(0, I + f), L = Math.max(0, H - M), k = L <= 100;
811
- p.value = {
812
- distanceToTrigger: Math.round(L),
813
- isNearTrigger: k
835
+ function p(S) {
836
+ if (!i.value) return;
837
+ const { scrollTop: v, clientHeight: r } = i.value, s = v + r, L = S ?? $e(n.value, a.value), M = L.length ? Math.max(...L) : 0, g = typeof d == "number" ? d : 200, $ = g >= 0 ? Math.max(0, M - g) : Math.max(0, M + g), k = Math.max(0, $ - s), N = k <= 100;
838
+ w.value = {
839
+ distanceToTrigger: Math.round(k),
840
+ isNearTrigger: N
814
841
  };
815
842
  }
816
- async function s() {
817
- if (r.value) {
818
- const d = r.value.scrollTop, v = r.value.clientHeight || window.innerHeight, M = v > 0 ? v : window.innerHeight;
819
- i.value = d, w.value = M;
843
+ async function h() {
844
+ if (i.value) {
845
+ const v = i.value.scrollTop, r = i.value.clientHeight || window.innerHeight, s = r > 0 ? r : window.innerHeight;
846
+ o.value = v, c.value = s;
820
847
  }
821
- n.value = !0, await q(), await new Promise((d) => requestAnimationFrame(() => d())), n.value = !1;
822
- const a = be(l.value, t.value);
823
- h.value(a), T(a);
848
+ t.value = !0, await X(), await new Promise((v) => requestAnimationFrame(() => v())), t.value = !1;
849
+ const S = $e(n.value, a.value);
850
+ f.value(S), p(S);
824
851
  }
825
- function m() {
826
- i.value = 0, w.value = 0, n.value = !1, p.value = {
852
+ function I() {
853
+ o.value = 0, c.value = 0, t.value = !1, w.value = {
827
854
  distanceToTrigger: 0,
828
855
  isNearTrigger: !1
829
856
  };
830
857
  }
831
858
  return {
832
- viewportTop: i,
833
- viewportHeight: w,
834
- virtualizing: n,
835
- scrollProgress: p,
836
- visibleMasonry: x,
837
- updateScrollProgress: T,
838
- updateViewport: s,
839
- reset: m,
840
- handleScroll: h
859
+ viewportTop: o,
860
+ viewportHeight: c,
861
+ virtualizing: t,
862
+ scrollProgress: w,
863
+ visibleMasonry: T,
864
+ updateScrollProgress: p,
865
+ updateViewport: h,
866
+ reset: I,
867
+ handleScroll: f
841
868
  };
842
869
  }
843
- function ia(e) {
844
- const { masonry: l } = e, r = B(/* @__PURE__ */ new Set());
845
- function t(h) {
846
- return typeof h == "number" && h > 0 && Number.isFinite(h);
870
+ function sa(e) {
871
+ const { masonry: n } = e, i = W(/* @__PURE__ */ new Set());
872
+ function a(f) {
873
+ return typeof f == "number" && f > 0 && Number.isFinite(f);
847
874
  }
848
- function y(h, i) {
875
+ function m(f, o) {
849
876
  try {
850
- if (!Array.isArray(h) || h.length === 0) return;
851
- const w = h.filter((n) => !t(n == null ? void 0 : n.width) || !t(n == null ? void 0 : n.height));
852
- if (w.length === 0) return;
853
- const b = [];
854
- for (const n of w) {
855
- const p = (n == null ? void 0 : n.id) ?? `idx:${l.value.indexOf(n)}`;
856
- r.value.has(p) || (r.value.add(p), b.push(p));
877
+ if (!Array.isArray(f) || f.length === 0) return;
878
+ const c = f.filter((t) => !a(t == null ? void 0 : t.width) || !a(t == null ? void 0 : t.height));
879
+ if (c.length === 0) return;
880
+ const y = [];
881
+ for (const t of c) {
882
+ const w = (t == null ? void 0 : t.id) ?? `idx:${n.value.indexOf(t)}`;
883
+ i.value.has(w) || (i.value.add(w), y.push(w));
857
884
  }
858
- if (b.length > 0) {
859
- const n = b.slice(0, 10);
885
+ if (y.length > 0) {
886
+ const t = y.slice(0, 10);
860
887
  console.warn(
861
888
  "[Masonry] Items missing width/height detected:",
862
889
  {
863
- context: i,
864
- count: b.length,
865
- sampleIds: n,
890
+ context: o,
891
+ count: y.length,
892
+ sampleIds: t,
866
893
  hint: "Ensure each item has positive width and height. Consider providing fallbacks (e.g., 512x512) at the data layer."
867
894
  }
868
895
  );
@@ -870,28 +897,28 @@ function ia(e) {
870
897
  } catch {
871
898
  }
872
899
  }
873
- function g() {
874
- r.value.clear();
900
+ function d() {
901
+ i.value.clear();
875
902
  }
876
903
  return {
877
- checkItemDimensions: y,
878
- invalidDimensionIds: r,
879
- reset: g
904
+ checkItemDimensions: m,
905
+ invalidDimensionIds: i,
906
+ reset: d
880
907
  };
881
908
  }
882
- const sa = { class: "flex-1 relative min-h-0" }, ua = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm transition-all duration-300 bg-white relative" }, ca = {
909
+ const ua = { class: "flex-1 relative min-h-0" }, ca = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm transition-all duration-300 bg-white relative" }, va = {
883
910
  key: 0,
884
911
  class: "absolute inset-0 flex flex-col items-center justify-center bg-slate-100 text-slate-400 text-sm p-4 text-center"
885
- }, va = {
912
+ }, fa = {
886
913
  key: 1,
887
914
  class: "relative w-full h-full"
888
- }, fa = ["src"], da = ["src", "autoplay", "controls"], ha = { class: "w-12 h-12 rounded-full bg-white/80 backdrop-blur-sm flex items-center justify-center shadow-sm" }, ma = {
915
+ }, da = ["src"], ma = ["src", "autoplay", "controls"], ha = { class: "w-12 h-12 rounded-full bg-white/80 backdrop-blur-sm flex items-center justify-center shadow-sm" }, ga = {
889
916
  key: 3,
890
917
  class: "absolute bottom-2 left-1/2 transform -translate-x-1/2 flex items-center justify-center z-10"
891
- }, ga = {
918
+ }, pa = {
892
919
  key: 4,
893
920
  class: "absolute inset-0 flex flex-col items-center justify-center bg-slate-50 text-slate-400 text-sm p-4 text-center"
894
- }, Me = /* @__PURE__ */ et({
921
+ }, xe = /* @__PURE__ */ _e({
895
922
  __name: "MasonryItem",
896
923
  props: {
897
924
  item: {},
@@ -901,284 +928,318 @@ const sa = { class: "flex-1 relative min-h-0" }, ua = { class: "w-full h-full ro
901
928
  headerHeight: { default: 0 },
902
929
  footerHeight: { default: 0 },
903
930
  isActive: { type: Boolean, default: !1 },
904
- inSwipeMode: { type: Boolean, default: !1 }
931
+ inSwipeMode: { type: Boolean, default: !1 },
932
+ preloadThreshold: { default: 1 }
905
933
  },
906
- emits: ["preload:success", "preload:error", "mouse-enter", "mouse-leave"],
907
- setup(e, { emit: l }) {
908
- const r = e, t = l, y = B(!1), g = B(!1), h = B(null), i = B(!1), w = B(!1), b = B(null), n = B(!1), p = B(!1), x = B(!1), T = B(null), s = B(null);
909
- let m = null;
910
- const a = Z(() => {
911
- var o;
912
- return r.type ?? ((o = r.item) == null ? void 0 : o.type) ?? "image";
913
- }), d = Z(() => {
914
- var o;
915
- return r.notFound ?? ((o = r.item) == null ? void 0 : o.notFound) ?? !1;
916
- }), v = Z(() => !!r.inSwipeMode);
917
- function M(o) {
918
- t("mouse-enter", { item: r.item, type: o });
934
+ emits: ["preload:success", "preload:error", "mouse-enter", "mouse-leave", "in-view", "in-view-and-loaded"],
935
+ setup(e, { emit: n }) {
936
+ const i = e, a = n, m = W(!1), d = W(!1), f = W(null), o = W(!1), c = W(!1), y = W(null), t = W(!1), w = W(!1), T = W(!1), p = W(!1), h = W(!1), I = W(null), S = W(null);
937
+ let v = null;
938
+ const r = K(() => {
939
+ var l;
940
+ return i.type ?? ((l = i.item) == null ? void 0 : l.type) ?? "image";
941
+ }), s = K(() => {
942
+ var l;
943
+ return i.notFound ?? ((l = i.item) == null ? void 0 : l.notFound) ?? !1;
944
+ }), L = K(() => !!i.inSwipeMode);
945
+ function M(l, x) {
946
+ const E = l === "image" ? m.value : o.value;
947
+ w.value && E && !T.value && (T.value = !0, a("in-view-and-loaded", { item: i.item, type: l, src: x }));
948
+ }
949
+ function g(l) {
950
+ a("mouse-enter", { item: i.item, type: l });
919
951
  }
920
- function P(o) {
921
- t("mouse-leave", { item: r.item, type: o });
952
+ function $(l) {
953
+ a("mouse-leave", { item: i.item, type: l });
922
954
  }
923
- function I(o) {
924
- if (v.value) return;
925
- const u = o.target;
926
- u && (u.paused ? u.play() : u.pause());
955
+ function k(l) {
956
+ if (L.value) return;
957
+ const x = l.target;
958
+ x && (x.paused ? x.play() : x.pause());
927
959
  }
928
- function f(o) {
929
- const u = o.target;
930
- u && (v.value || u.play(), M("video"));
960
+ function N(l) {
961
+ const x = l.target;
962
+ x && (L.value || x.play(), g("video"));
931
963
  }
932
- function H(o) {
933
- const u = o.target;
934
- u && (v.value || u.pause(), P("video"));
964
+ function A(l) {
965
+ const x = l.target;
966
+ x && (L.value || x.pause(), $("video"));
935
967
  }
936
- function L(o) {
937
- return new Promise((u, E) => {
938
- if (!o) {
939
- const N = new Error("No image source provided");
940
- t("preload:error", { item: r.item, type: "image", src: o, error: N }), E(N);
968
+ function P(l) {
969
+ return new Promise((x, E) => {
970
+ if (!l) {
971
+ const b = new Error("No image source provided");
972
+ a("preload:error", { item: i.item, type: "image", src: l, error: b }), E(b);
941
973
  return;
942
974
  }
943
- const $ = new Image(), C = Date.now(), A = 300;
944
- $.onload = () => {
945
- const N = Date.now() - C, j = Math.max(0, A - N);
975
+ const D = new Image(), V = Date.now(), C = 300;
976
+ D.onload = () => {
977
+ const b = Date.now() - V, H = Math.max(0, C - b);
946
978
  setTimeout(async () => {
947
- y.value = !0, g.value = !1, p.value = !1, await q(), await new Promise((G) => setTimeout(G, 100)), x.value = !0, t("preload:success", { item: r.item, type: "image", src: o }), u();
948
- }, j);
949
- }, $.onerror = () => {
950
- g.value = !0, y.value = !1, p.value = !1;
951
- const N = new Error("Failed to load image");
952
- t("preload:error", { item: r.item, type: "image", src: o, error: N }), E(N);
953
- }, $.src = o;
979
+ m.value = !0, d.value = !1, p.value = !1, await X(), await new Promise((R) => setTimeout(R, 100)), h.value = !0, a("preload:success", { item: i.item, type: "image", src: l }), M("image", l), x();
980
+ }, H);
981
+ }, D.onerror = () => {
982
+ d.value = !0, m.value = !1, p.value = !1;
983
+ const b = new Error("Failed to load image");
984
+ a("preload:error", { item: i.item, type: "image", src: l, error: b }), E(b);
985
+ }, D.src = l;
954
986
  });
955
987
  }
956
- function k(o) {
957
- return new Promise((u, E) => {
958
- if (!o) {
959
- const N = new Error("No video source provided");
960
- t("preload:error", { item: r.item, type: "video", src: o, error: N }), E(N);
988
+ function z(l) {
989
+ return new Promise((x, E) => {
990
+ if (!l) {
991
+ const b = new Error("No video source provided");
992
+ a("preload:error", { item: i.item, type: "video", src: l, error: b }), E(b);
961
993
  return;
962
994
  }
963
- const $ = document.createElement("video"), C = Date.now(), A = 300;
964
- $.preload = "metadata", $.muted = !0, $.onloadedmetadata = () => {
965
- const N = Date.now() - C, j = Math.max(0, A - N);
995
+ const D = document.createElement("video"), V = Date.now(), C = 300;
996
+ D.preload = "metadata", D.muted = !0, D.onloadedmetadata = () => {
997
+ const b = Date.now() - V, H = Math.max(0, C - b);
966
998
  setTimeout(async () => {
967
- i.value = !0, w.value = !1, p.value = !1, await q(), await new Promise((G) => setTimeout(G, 100)), x.value = !0, t("preload:success", { item: r.item, type: "video", src: o }), u();
968
- }, j);
969
- }, $.onerror = () => {
970
- w.value = !0, i.value = !1, p.value = !1;
971
- const N = new Error("Failed to load video");
972
- t("preload:error", { item: r.item, type: "video", src: o, error: N }), E(N);
973
- }, $.src = o;
999
+ o.value = !0, c.value = !1, p.value = !1, await X(), await new Promise((R) => setTimeout(R, 100)), h.value = !0, a("preload:success", { item: i.item, type: "video", src: l }), M("video", l), x();
1000
+ }, H);
1001
+ }, D.onerror = () => {
1002
+ c.value = !0, o.value = !1, p.value = !1;
1003
+ const b = new Error("Failed to load video");
1004
+ a("preload:error", { item: i.item, type: "video", src: l, error: b }), E(b);
1005
+ }, D.src = l;
974
1006
  });
975
1007
  }
976
- async function W() {
977
- var u;
978
- if (!n.value || p.value || d.value || a.value === "video" && i.value || a.value === "image" && y.value)
1008
+ async function F() {
1009
+ var x;
1010
+ if (!t.value || p.value || s.value || r.value === "video" && o.value || r.value === "image" && m.value)
979
1011
  return;
980
- const o = (u = r.item) == null ? void 0 : u.src;
981
- if (o)
982
- if (p.value = !0, x.value = !1, a.value === "video") {
983
- b.value = o, i.value = !1, w.value = !1;
1012
+ const l = (x = i.item) == null ? void 0 : x.src;
1013
+ if (l)
1014
+ if (p.value = !0, h.value = !1, r.value === "video") {
1015
+ y.value = l, o.value = !1, c.value = !1;
984
1016
  try {
985
- await k(o);
1017
+ await z(l);
986
1018
  } catch {
987
1019
  }
988
1020
  } else {
989
- h.value = o, y.value = !1, g.value = !1;
1021
+ f.value = l, m.value = !1, d.value = !1;
990
1022
  try {
991
- await L(o);
1023
+ await P(l);
992
1024
  } catch {
993
1025
  }
994
1026
  }
995
1027
  }
996
- return tt(() => {
997
- T.value && (m = new IntersectionObserver(
998
- (o) => {
999
- o.forEach((u) => {
1000
- u.isIntersecting && u.intersectionRatio >= 1 ? n.value || (n.value = !0, W()) : u.isIntersecting;
1028
+ return Xe(async () => {
1029
+ if (!I.value) return;
1030
+ const l = [i.preloadThreshold, 1].filter((E, D, V) => V.indexOf(E) === D).sort((E, D) => E - D);
1031
+ v = new IntersectionObserver(
1032
+ (E) => {
1033
+ E.forEach((D) => {
1034
+ const V = D.intersectionRatio, C = V >= 1, b = V >= i.preloadThreshold;
1035
+ if (C && !w.value) {
1036
+ w.value = !0, a("in-view", { item: i.item, type: r.value });
1037
+ const H = r.value === "image" ? f.value : y.value, R = r.value === "image" ? m.value : o.value;
1038
+ H && R && M(r.value, H);
1039
+ }
1040
+ b && !t.value ? (t.value = !0, F()) : D.isIntersecting;
1001
1041
  });
1002
1042
  },
1003
1043
  {
1004
- // Only trigger when item is 100% visible (full height in view)
1005
- threshold: [1]
1044
+ // Trigger at both preloadThreshold and 1.0 (fully in view)
1045
+ threshold: l
1046
+ }
1047
+ ), v.observe(I.value), await X(), requestAnimationFrame(() => {
1048
+ requestAnimationFrame(() => {
1049
+ x();
1050
+ });
1051
+ }), setTimeout(() => {
1052
+ x();
1053
+ }, 100);
1054
+ function x() {
1055
+ if (!I.value || w.value) return;
1056
+ const E = I.value.getBoundingClientRect(), D = window.innerHeight, V = window.innerWidth;
1057
+ if (E.top >= 0 && E.bottom <= D && E.left >= 0 && E.right <= V && E.height > 0 && E.width > 0) {
1058
+ w.value = !0, a("in-view", { item: i.item, type: r.value });
1059
+ const b = r.value === "image" ? f.value : y.value, H = r.value === "image" ? m.value : o.value;
1060
+ b && H && M(r.value, b);
1006
1061
  }
1007
- ), m.observe(T.value));
1008
- }), at(() => {
1009
- m && (m.disconnect(), m = null);
1010
- }), te(
1062
+ }
1063
+ }), Ge(() => {
1064
+ v && (v.disconnect(), v = null);
1065
+ }), ee(
1011
1066
  () => {
1012
- var o;
1013
- return (o = r.item) == null ? void 0 : o.src;
1067
+ var l;
1068
+ return (l = i.item) == null ? void 0 : l.src;
1014
1069
  },
1015
- async (o) => {
1016
- if (!(!o || d.value)) {
1017
- if (a.value === "video") {
1018
- if (o !== b.value && (i.value = !1, w.value = !1, b.value = o, n.value)) {
1070
+ async (l) => {
1071
+ if (!(!l || s.value)) {
1072
+ if (r.value === "video") {
1073
+ if (l !== y.value && (o.value = !1, c.value = !1, y.value = l, t.value)) {
1019
1074
  p.value = !0;
1020
1075
  try {
1021
- await k(o);
1076
+ await z(l);
1022
1077
  } catch {
1023
1078
  }
1024
1079
  }
1025
- } else if (o !== h.value && (y.value = !1, g.value = !1, h.value = o, n.value)) {
1080
+ } else if (l !== f.value && (m.value = !1, d.value = !1, f.value = l, t.value)) {
1026
1081
  p.value = !0;
1027
1082
  try {
1028
- await L(o);
1083
+ await P(l);
1029
1084
  } catch {
1030
1085
  }
1031
1086
  }
1032
1087
  }
1033
1088
  }
1034
- ), te(
1035
- () => r.isActive,
1036
- (o) => {
1037
- !v.value || !s.value || (o ? s.value.play() : s.value.pause());
1089
+ ), ee(
1090
+ () => i.isActive,
1091
+ (l) => {
1092
+ !L.value || !S.value || (l ? S.value.play() : S.value.pause());
1038
1093
  }
1039
- ), (o, u) => (O(), R("div", {
1094
+ ), (l, x) => (Y(), q("div", {
1040
1095
  ref_key: "containerRef",
1041
- ref: T,
1096
+ ref: I,
1042
1097
  class: "relative w-full h-full flex flex-col"
1043
1098
  }, [
1044
- o.headerHeight > 0 ? (O(), R("div", {
1099
+ l.headerHeight > 0 ? (Y(), q("div", {
1045
1100
  key: 0,
1046
1101
  class: "relative z-10",
1047
- style: ge({ height: `${o.headerHeight}px` })
1102
+ style: he({ height: `${l.headerHeight}px` })
1048
1103
  }, [
1049
- X(o.$slots, "header", {
1050
- item: o.item,
1051
- remove: o.remove,
1052
- imageLoaded: y.value,
1053
- imageError: g.value,
1054
- videoLoaded: i.value,
1055
- videoError: w.value,
1056
- showNotFound: d.value,
1104
+ J(l.$slots, "header", {
1105
+ item: l.item,
1106
+ remove: l.remove,
1107
+ imageLoaded: m.value,
1108
+ imageError: d.value,
1109
+ videoLoaded: o.value,
1110
+ videoError: c.value,
1111
+ showNotFound: s.value,
1057
1112
  isLoading: p.value,
1058
- mediaType: a.value
1113
+ mediaType: r.value,
1114
+ isFullyInView: w.value
1059
1115
  })
1060
- ], 4)) : ae("", !0),
1061
- V("div", sa, [
1062
- X(o.$slots, "default", {
1063
- item: o.item,
1064
- remove: o.remove,
1065
- imageLoaded: y.value,
1066
- imageError: g.value,
1067
- videoLoaded: i.value,
1068
- videoError: w.value,
1069
- showNotFound: d.value,
1116
+ ], 4)) : te("", !0),
1117
+ U("div", ua, [
1118
+ J(l.$slots, "default", {
1119
+ item: l.item,
1120
+ remove: l.remove,
1121
+ imageLoaded: m.value,
1122
+ imageError: d.value,
1123
+ videoLoaded: o.value,
1124
+ videoError: c.value,
1125
+ showNotFound: s.value,
1070
1126
  isLoading: p.value,
1071
- mediaType: a.value,
1072
- imageSrc: h.value,
1073
- videoSrc: b.value,
1074
- showMedia: x.value
1127
+ mediaType: r.value,
1128
+ imageSrc: f.value,
1129
+ videoSrc: y.value,
1130
+ showMedia: h.value,
1131
+ isFullyInView: w.value
1075
1132
  }, () => [
1076
- V("div", ua, [
1077
- d.value ? (O(), R("div", ca, u[3] || (u[3] = [
1078
- V("i", { class: "fas fa-search text-3xl mb-3 opacity-50" }, null, -1),
1079
- V("span", { class: "font-medium" }, "Not Found", -1),
1080
- V("span", { class: "text-xs mt-1 opacity-75" }, "This item could not be located", -1)
1081
- ]))) : (O(), R("div", va, [
1082
- a.value === "image" && h.value ? (O(), R("img", {
1133
+ U("div", ca, [
1134
+ s.value ? (Y(), q("div", va, x[3] || (x[3] = [
1135
+ U("i", { class: "fas fa-search text-3xl mb-3 opacity-50" }, null, -1),
1136
+ U("span", { class: "font-medium" }, "Not Found", -1),
1137
+ U("span", { class: "text-xs mt-1 opacity-75" }, "This item could not be located", -1)
1138
+ ]))) : (Y(), q("div", fa, [
1139
+ r.value === "image" && f.value ? (Y(), q("img", {
1083
1140
  key: 0,
1084
- src: h.value,
1141
+ src: f.value,
1085
1142
  class: re([
1086
1143
  "w-full h-full object-cover transition-opacity duration-700 ease-in-out",
1087
- y.value && x.value ? "opacity-100" : "opacity-0"
1144
+ m.value && h.value ? "opacity-100" : "opacity-0"
1088
1145
  ]),
1089
1146
  style: { position: "absolute", top: "0", left: "0" },
1090
1147
  loading: "lazy",
1091
1148
  decoding: "async",
1092
1149
  alt: "",
1093
- onMouseenter: u[0] || (u[0] = (E) => M("image")),
1094
- onMouseleave: u[1] || (u[1] = (E) => P("image"))
1095
- }, null, 42, fa)) : ae("", !0),
1096
- a.value === "video" && b.value ? (O(), R("video", {
1150
+ onMouseenter: x[0] || (x[0] = (E) => g("image")),
1151
+ onMouseleave: x[1] || (x[1] = (E) => $("image"))
1152
+ }, null, 42, da)) : te("", !0),
1153
+ r.value === "video" && y.value ? (Y(), q("video", {
1097
1154
  key: 1,
1098
1155
  ref_key: "videoEl",
1099
- ref: s,
1100
- src: b.value,
1156
+ ref: S,
1157
+ src: y.value,
1101
1158
  class: re([
1102
1159
  "w-full h-full object-cover transition-opacity duration-700 ease-in-out",
1103
- i.value && x.value ? "opacity-100" : "opacity-0"
1160
+ o.value && h.value ? "opacity-100" : "opacity-0"
1104
1161
  ]),
1105
1162
  style: { position: "absolute", top: "0", left: "0" },
1106
1163
  muted: "",
1107
1164
  loop: "",
1108
1165
  playsinline: "",
1109
- autoplay: v.value && r.isActive,
1110
- controls: v.value,
1111
- onClick: Ye(I, ["stop"]),
1112
- onTouchend: Ye(I, ["stop", "prevent"]),
1113
- onMouseenter: f,
1114
- onMouseleave: H,
1115
- onError: u[2] || (u[2] = (E) => w.value = !0)
1116
- }, null, 42, da)) : ae("", !0),
1117
- !y.value && !i.value && !g.value && !w.value ? (O(), R("div", {
1166
+ autoplay: L.value && i.isActive,
1167
+ controls: L.value,
1168
+ onClick: Ae(k, ["stop"]),
1169
+ onTouchend: Ae(k, ["stop", "prevent"]),
1170
+ onMouseenter: N,
1171
+ onMouseleave: A,
1172
+ onError: x[2] || (x[2] = (E) => c.value = !0)
1173
+ }, null, 42, ma)) : te("", !0),
1174
+ !m.value && !o.value && !d.value && !c.value ? (Y(), q("div", {
1118
1175
  key: 2,
1119
1176
  class: re([
1120
1177
  "absolute inset-0 bg-slate-100 flex items-center justify-center transition-opacity duration-500",
1121
- x.value ? "opacity-0 pointer-events-none" : "opacity-100"
1178
+ h.value ? "opacity-0 pointer-events-none" : "opacity-100"
1122
1179
  ])
1123
1180
  }, [
1124
- V("div", ha, [
1125
- X(o.$slots, "placeholder-icon", { mediaType: a.value }, () => [
1126
- V("i", {
1127
- class: re(a.value === "video" ? "fas fa-video text-xl text-slate-400" : "fas fa-image text-xl text-slate-400")
1181
+ U("div", ha, [
1182
+ J(l.$slots, "placeholder-icon", { mediaType: r.value }, () => [
1183
+ U("i", {
1184
+ class: re(r.value === "video" ? "fas fa-video text-xl text-slate-400" : "fas fa-image text-xl text-slate-400")
1128
1185
  }, null, 2)
1129
1186
  ])
1130
1187
  ])
1131
- ], 2)) : ae("", !0),
1132
- p.value ? (O(), R("div", ma, u[4] || (u[4] = [
1133
- V("div", { class: "bg-white/90 backdrop-blur-sm rounded-full px-3 py-1.5 shadow-sm" }, [
1134
- V("div", { class: "animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500" })
1188
+ ], 2)) : te("", !0),
1189
+ p.value ? (Y(), q("div", ga, x[4] || (x[4] = [
1190
+ U("div", { class: "bg-white/90 backdrop-blur-sm rounded-full px-3 py-1.5 shadow-sm" }, [
1191
+ U("div", { class: "animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500" })
1135
1192
  ], -1)
1136
- ]))) : ae("", !0),
1137
- a.value === "image" && g.value || a.value === "video" && w.value ? (O(), R("div", ga, [
1138
- V("i", {
1139
- class: re(a.value === "video" ? "fas fa-video text-2xl mb-2 opacity-50" : "fas fa-image text-2xl mb-2 opacity-50")
1193
+ ]))) : te("", !0),
1194
+ r.value === "image" && d.value || r.value === "video" && c.value ? (Y(), q("div", pa, [
1195
+ U("i", {
1196
+ class: re(r.value === "video" ? "fas fa-video text-2xl mb-2 opacity-50" : "fas fa-image text-2xl mb-2 opacity-50")
1140
1197
  }, null, 2),
1141
- V("span", null, "Failed to load " + Be(a.value), 1)
1142
- ])) : ae("", !0)
1198
+ U("span", null, "Failed to load " + Pe(r.value), 1)
1199
+ ])) : te("", !0)
1143
1200
  ]))
1144
1201
  ])
1145
1202
  ])
1146
1203
  ]),
1147
- o.footerHeight > 0 ? (O(), R("div", {
1204
+ l.footerHeight > 0 ? (Y(), q("div", {
1148
1205
  key: 1,
1149
1206
  class: "relative z-10",
1150
- style: ge({ height: `${o.footerHeight}px` })
1207
+ style: he({ height: `${l.footerHeight}px` })
1151
1208
  }, [
1152
- X(o.$slots, "footer", {
1153
- item: o.item,
1154
- remove: o.remove,
1155
- imageLoaded: y.value,
1156
- imageError: g.value,
1157
- videoLoaded: i.value,
1158
- videoError: w.value,
1159
- showNotFound: d.value,
1209
+ J(l.$slots, "footer", {
1210
+ item: l.item,
1211
+ remove: l.remove,
1212
+ imageLoaded: m.value,
1213
+ imageError: d.value,
1214
+ videoLoaded: o.value,
1215
+ videoError: c.value,
1216
+ showNotFound: s.value,
1160
1217
  isLoading: p.value,
1161
- mediaType: a.value
1218
+ mediaType: r.value,
1219
+ isFullyInView: w.value
1162
1220
  })
1163
- ], 4)) : ae("", !0)
1221
+ ], 4)) : te("", !0)
1164
1222
  ], 512));
1165
1223
  }
1166
- }), pa = { class: "w-full h-full flex items-center justify-center p-4" }, ya = { class: "w-full h-full max-w-full max-h-full relative" }, wa = {
1224
+ }), ya = {
1225
+ key: 0,
1226
+ class: "w-full h-full flex items-center justify-center"
1227
+ }, wa = { class: "w-full h-full flex items-center justify-center p-4" }, xa = { class: "w-full h-full max-w-full max-h-full relative" }, ba = {
1167
1228
  key: 0,
1168
1229
  class: "w-full py-8 text-center"
1169
- }, xa = {
1230
+ }, Ma = {
1170
1231
  key: 1,
1171
1232
  class: "w-full py-8 text-center"
1172
- }, ba = { class: "text-red-500 dark:text-red-400" }, Ma = {
1233
+ }, Ta = { class: "text-red-500 dark:text-red-400" }, Ia = {
1173
1234
  key: 0,
1174
1235
  class: "w-full py-8 text-center"
1175
- }, Ta = {
1236
+ }, La = {
1176
1237
  key: 1,
1177
1238
  class: "w-full py-8 text-center"
1178
- }, Ia = { class: "text-red-500 dark:text-red-400" }, Ea = /* @__PURE__ */ et({
1239
+ }, Sa = { class: "text-red-500 dark:text-red-400" }, ka = /* @__PURE__ */ _e({
1179
1240
  __name: "Masonry",
1180
1241
  props: {
1181
- getNextPage: {
1242
+ getPage: {
1182
1243
  type: Function,
1183
1244
  default: () => {
1184
1245
  }
@@ -1191,6 +1252,12 @@ const sa = { class: "flex-1 relative min-h-0" }, ua = { class: "w-full h-full ro
1191
1252
  type: Array,
1192
1253
  default: () => []
1193
1254
  },
1255
+ // Opaque caller-owned context passed through to getPage(page, context).
1256
+ // Useful for including filters, service selection, tabId, etc.
1257
+ context: {
1258
+ type: Object,
1259
+ default: null
1260
+ },
1194
1261
  layout: {
1195
1262
  type: Object
1196
1263
  },
@@ -1200,27 +1267,20 @@ const sa = { class: "flex-1 relative min-h-0" }, ua = { class: "w-full h-full ro
1200
1267
  // or 'cursor'
1201
1268
  validator: (e) => ["page", "cursor"].includes(e)
1202
1269
  },
1203
- skipInitialLoad: {
1204
- type: Boolean,
1205
- default: !1
1206
- },
1207
- // Initial pagination state when skipInitialLoad is true and items are provided
1208
- initialPage: {
1209
- type: [Number, String],
1210
- default: null
1211
- },
1212
- initialNextPage: {
1213
- type: [Number, String],
1214
- default: null
1270
+ init: {
1271
+ type: String,
1272
+ default: "manual",
1273
+ validator: (e) => ["auto", "manual"].includes(e)
1215
1274
  },
1216
1275
  pageSize: {
1217
1276
  type: Number,
1218
1277
  default: 40
1219
1278
  },
1220
1279
  // Backfill configuration
1221
- backfillEnabled: {
1222
- type: Boolean,
1223
- default: !0
1280
+ mode: {
1281
+ type: String,
1282
+ default: "backfill",
1283
+ validator: (e) => ["backfill", "none", "refresh"].includes(e)
1224
1284
  },
1225
1285
  backfillDelayMs: {
1226
1286
  type: Number,
@@ -1269,10 +1329,6 @@ const sa = { class: "flex-1 relative min-h-0" }, ua = { class: "w-full h-full ro
1269
1329
  type: Number,
1270
1330
  default: 200
1271
1331
  },
1272
- autoRefreshOnEmpty: {
1273
- type: Boolean,
1274
- default: !1
1275
- },
1276
1332
  // Layout mode: 'auto' (detect from screen size), 'masonry', or 'swipe'
1277
1333
  layoutMode: {
1278
1334
  type: String,
@@ -1288,22 +1344,25 @@ const sa = { class: "flex-1 relative min-h-0" }, ua = { class: "w-full h-full ro
1288
1344
  },
1289
1345
  emits: [
1290
1346
  "update:items",
1347
+ "loading:start",
1291
1348
  "backfill:start",
1292
1349
  "backfill:tick",
1293
1350
  "backfill:stop",
1294
1351
  "retry:start",
1295
1352
  "retry:tick",
1296
1353
  "retry:stop",
1354
+ "loading:stop",
1297
1355
  "remove-all:complete",
1298
1356
  // Re-emit item-level preload events from the default MasonryItem
1299
1357
  "item:preload:success",
1300
1358
  "item:preload:error",
1301
1359
  // Mouse events from MasonryItem content
1302
1360
  "item:mouse-enter",
1303
- "item:mouse-leave"
1361
+ "item:mouse-leave",
1362
+ "update:context"
1304
1363
  ],
1305
- setup(e, { expose: l, emit: r }) {
1306
- const t = e, y = {
1364
+ setup(e, { expose: n, emit: i }) {
1365
+ const a = e, m = {
1307
1366
  sizes: { base: 1, sm: 2, md: 3, lg: 4, xl: 5, "2xl": 6 },
1308
1367
  gutterX: 10,
1309
1368
  gutterY: 10,
@@ -1312,314 +1371,337 @@ const sa = { class: "flex-1 relative min-h-0" }, ua = { class: "w-full h-full ro
1312
1371
  paddingLeft: 0,
1313
1372
  paddingRight: 0,
1314
1373
  placement: "masonry"
1315
- }, g = Z(() => {
1316
- var c;
1374
+ }, d = K(() => {
1375
+ var u;
1317
1376
  return {
1318
- ...y,
1319
- ...t.layout,
1377
+ ...m,
1378
+ ...a.layout,
1320
1379
  sizes: {
1321
- ...y.sizes,
1322
- ...((c = t.layout) == null ? void 0 : c.sizes) || {}
1380
+ ...m.sizes,
1381
+ ...((u = a.layout) == null ? void 0 : u.sizes) || {}
1323
1382
  }
1324
1383
  };
1325
- }), h = B(null), i = B(typeof window < "u" ? window.innerWidth : 1024), w = B(typeof window < "u" ? window.innerHeight : 768), b = B(null);
1326
- let n = null;
1327
- function p(c) {
1384
+ }), f = W(null), o = W(typeof window < "u" ? window.innerWidth : 1024), c = W(typeof window < "u" ? window.innerHeight : 768), y = W(null);
1385
+ let t = null;
1386
+ function w(u) {
1328
1387
  return {
1329
1388
  sm: 640,
1330
1389
  md: 768,
1331
1390
  lg: 1024,
1332
1391
  xl: 1280,
1333
1392
  "2xl": 1536
1334
- }[c] || 768;
1393
+ }[u] || 768;
1394
+ }
1395
+ const T = K(() => {
1396
+ if (a.layoutMode === "masonry") return !1;
1397
+ if (a.layoutMode === "swipe") return !0;
1398
+ const u = typeof a.mobileBreakpoint == "string" ? w(a.mobileBreakpoint) : a.mobileBreakpoint;
1399
+ return o.value < u;
1400
+ }), p = i, h = K({
1401
+ get: () => a.items,
1402
+ set: (u) => p("update:items", u)
1403
+ }), I = K({
1404
+ get: () => a.context,
1405
+ set: (u) => p("update:context", u)
1406
+ });
1407
+ function S(u) {
1408
+ I.value = u;
1335
1409
  }
1336
- const x = Z(() => {
1337
- if (t.layoutMode === "masonry") return !1;
1338
- if (t.layoutMode === "swipe") return !0;
1339
- const c = typeof t.mobileBreakpoint == "string" ? p(t.mobileBreakpoint) : t.mobileBreakpoint;
1340
- return i.value < c;
1341
- }), T = r, s = Z({
1342
- get: () => t.items,
1343
- set: (c) => T("update:items", c)
1344
- }), m = B(7), a = B(null), d = B([]), v = B(null), M = B(!1), P = B(0), I = B(!1), f = B(null), H = Z(() => Jt(i.value)), L = ia({
1345
- masonry: s
1346
- }), { checkItemDimensions: k, reset: W } = L, o = oa({
1347
- masonry: s,
1348
- useSwipeMode: x,
1349
- container: a,
1350
- columns: m,
1351
- containerWidth: i,
1352
- masonryContentHeight: P,
1353
- layout: g,
1354
- fixedDimensions: b,
1355
- checkItemDimensions: k
1356
- }), { refreshLayout: u, setFixedDimensions: E, onResize: $ } = o, C = ra({
1357
- masonry: s,
1358
- container: a,
1359
- columns: m,
1360
- virtualBufferPx: t.virtualBufferPx,
1361
- loadThresholdPx: t.loadThresholdPx,
1410
+ const v = K(() => {
1411
+ const u = h.value;
1412
+ return (u == null ? void 0 : u.length) ?? 0;
1413
+ }), r = W(7), s = W(null), L = W([]), M = W(null), g = W(!1), $ = W(0), k = W(!1), N = W(null), A = W(!1), P = K(() => Kt(o.value)), z = sa({
1414
+ masonry: h
1415
+ }), { checkItemDimensions: F, reset: l } = z, x = ra({
1416
+ masonry: h,
1417
+ useSwipeMode: T,
1418
+ container: s,
1419
+ columns: r,
1420
+ containerWidth: o,
1421
+ masonryContentHeight: $,
1422
+ layout: d,
1423
+ fixedDimensions: y,
1424
+ checkItemDimensions: F
1425
+ }), { refreshLayout: E, setFixedDimensions: D, onResize: V } = x, C = ia({
1426
+ masonry: h,
1427
+ container: s,
1428
+ columns: r,
1429
+ virtualBufferPx: a.virtualBufferPx,
1430
+ loadThresholdPx: a.loadThresholdPx,
1362
1431
  handleScroll: () => {
1363
1432
  }
1364
1433
  // Will be set after pagination is initialized
1365
- }), { viewportTop: A, viewportHeight: N, virtualizing: j, visibleMasonry: G, updateScrollProgress: D, updateViewport: Y, reset: J } = C, { onEnter: ne, onBeforeEnter: K, onBeforeLeave: ie, onLeave: ee } = ea(
1366
- { container: a },
1367
- { leaveDurationMs: t.leaveDurationMs, virtualizing: j }
1368
- ), ot = ne, rt = K, it = ie, st = ee, ut = na({
1369
- getNextPage: t.getNextPage,
1370
- masonry: s,
1371
- isLoading: M,
1372
- hasReachedEnd: I,
1373
- loadError: f,
1374
- currentPage: v,
1375
- paginationHistory: d,
1376
- refreshLayout: u,
1377
- retryMaxAttempts: t.retryMaxAttempts,
1378
- retryInitialDelayMs: t.retryInitialDelayMs,
1379
- retryBackoffStepMs: t.retryBackoffStepMs,
1380
- backfillEnabled: t.backfillEnabled,
1381
- backfillDelayMs: t.backfillDelayMs,
1382
- backfillMaxCalls: t.backfillMaxCalls,
1383
- pageSize: t.pageSize,
1384
- autoRefreshOnEmpty: t.autoRefreshOnEmpty,
1385
- emits: T
1386
- }), { loadPage: Te, loadNext: pe, refreshCurrentPage: ze, cancelLoad: Ie, maybeBackfillToTarget: ct } = ut, Q = aa({
1387
- useSwipeMode: x,
1388
- masonry: s,
1389
- isLoading: M,
1390
- loadNext: pe,
1391
- loadPage: Te,
1392
- paginationHistory: d
1393
- }), { handleScroll: Fe } = ta({
1394
- container: a,
1395
- masonry: s,
1396
- columns: m,
1397
- containerHeight: P,
1398
- isLoading: M,
1399
- pageSize: t.pageSize,
1400
- refreshLayout: u,
1401
- setItemsRaw: (c) => {
1402
- s.value = c;
1434
+ }), { viewportTop: b, viewportHeight: H, virtualizing: R, visibleMasonry: ne, updateScrollProgress: _, updateViewport: ie, reset: Q } = C, { onEnter: Qe, onBeforeEnter: Ze, onBeforeLeave: et, onLeave: tt } = ta(
1435
+ { container: s },
1436
+ { leaveDurationMs: a.leaveDurationMs, virtualizing: R }
1437
+ ), at = Qe, nt = Ze, lt = et, ot = tt, rt = la({
1438
+ getPage: a.getPage,
1439
+ context: I,
1440
+ masonry: h,
1441
+ isLoading: g,
1442
+ hasReachedEnd: k,
1443
+ loadError: N,
1444
+ currentPage: M,
1445
+ paginationHistory: L,
1446
+ refreshLayout: E,
1447
+ retryMaxAttempts: a.retryMaxAttempts,
1448
+ retryInitialDelayMs: a.retryInitialDelayMs,
1449
+ retryBackoffStepMs: a.retryBackoffStepMs,
1450
+ mode: a.mode,
1451
+ backfillDelayMs: a.backfillDelayMs,
1452
+ backfillMaxCalls: a.backfillMaxCalls,
1453
+ pageSize: a.pageSize,
1454
+ emits: p
1455
+ }), { loadPage: be, loadNext: ge, refreshCurrentPage: it, cancelLoad: Me, maybeBackfillToTarget: st } = rt, Z = na({
1456
+ useSwipeMode: T,
1457
+ masonry: h,
1458
+ isLoading: g,
1459
+ loadNext: ge,
1460
+ loadPage: be,
1461
+ paginationHistory: L
1462
+ }), { handleScroll: ut } = aa({
1463
+ container: s,
1464
+ masonry: h,
1465
+ columns: r,
1466
+ containerHeight: $,
1467
+ isLoading: g,
1468
+ pageSize: a.pageSize,
1469
+ refreshLayout: E,
1470
+ setItemsRaw: (u) => {
1471
+ h.value = u;
1403
1472
  },
1404
- loadNext: pe,
1405
- loadThresholdPx: t.loadThresholdPx
1473
+ loadNext: ge,
1474
+ loadThresholdPx: a.loadThresholdPx
1406
1475
  });
1407
- C.handleScroll.value = Fe;
1408
- const vt = la({
1409
- masonry: s,
1410
- useSwipeMode: x,
1411
- refreshLayout: u,
1412
- refreshCurrentPage: ze,
1413
- loadNext: pe,
1414
- maybeBackfillToTarget: ct,
1415
- autoRefreshOnEmpty: t.autoRefreshOnEmpty,
1416
- paginationHistory: d
1417
- }), { remove: ce, removeMany: ft, restore: dt, restoreMany: ht, removeAll: mt } = vt;
1418
- function gt(c) {
1419
- E(c, D), !c && h.value && (i.value = h.value.clientWidth, w.value = h.value.clientHeight);
1476
+ C.handleScroll.value = ut;
1477
+ const ct = oa({
1478
+ masonry: h,
1479
+ useSwipeMode: T,
1480
+ refreshLayout: E,
1481
+ loadNext: ge,
1482
+ maybeBackfillToTarget: st,
1483
+ paginationHistory: L
1484
+ }), { remove: ue, removeMany: vt, restore: ft, restoreMany: dt, removeAll: mt } = ct;
1485
+ function ht(u) {
1486
+ D(u, _), !u && f.value && (o.value = f.value.clientWidth, c.value = f.value.clientHeight);
1420
1487
  }
1421
- l({
1422
- isLoading: M,
1423
- refreshLayout: u,
1424
- // Container dimensions (wrapper element)
1425
- containerWidth: i,
1426
- containerHeight: w,
1427
- // Masonry content height (for backward compatibility, old containerHeight)
1428
- contentHeight: P,
1429
- // Current page
1430
- currentPage: v,
1431
- // End of list tracking
1432
- hasReachedEnd: I,
1433
- // Load error tracking
1434
- loadError: f,
1435
- // Set fixed dimensions (overrides ResizeObserver)
1436
- setFixedDimensions: gt,
1437
- remove: ce,
1438
- removeMany: ft,
1488
+ n({
1489
+ // Cancels any ongoing load operations (page loads, backfills, etc.)
1490
+ cancelLoad: Me,
1491
+ // Opaque caller context passed through to getPage(page, context). Useful for including filters, service selection, tabId, etc.
1492
+ context: I,
1493
+ // Container height (wrapper element) in pixels
1494
+ containerHeight: c,
1495
+ // Container width (wrapper element) in pixels
1496
+ containerWidth: o,
1497
+ // Current Tailwind breakpoint name (base, sm, md, lg, xl, 2xl) based on containerWidth
1498
+ currentBreakpoint: P,
1499
+ // Current page number or cursor being displayed
1500
+ currentPage: M,
1501
+ // Completely destroys the component, clearing all state and resetting to initial state
1502
+ destroy: Mt,
1503
+ // Boolean indicating if the end of the list has been reached (no more pages to load)
1504
+ hasReachedEnd: k,
1505
+ // Initializes the component with items, page, and next page cursor. Use this for manual init mode.
1506
+ initialize: Tt,
1507
+ // Boolean indicating if the component has been initialized (first content has loaded)
1508
+ isInitialized: A,
1509
+ // Boolean indicating if a page load or backfill operation is currently in progress
1510
+ isLoading: g,
1511
+ // Error object if the last load operation failed, null otherwise
1512
+ loadError: N,
1513
+ // Loads the next page of items asynchronously
1514
+ loadNext: ge,
1515
+ // Loads a specific page number or cursor asynchronously
1516
+ loadPage: be,
1517
+ // Array tracking pagination history (pages/cursors that have been loaded)
1518
+ paginationHistory: L,
1519
+ // Refreshes the current page by clearing items and reloading from the current page
1520
+ refreshCurrentPage: it,
1521
+ // Recalculates the layout positions for all items. Call this after manually modifying items.
1522
+ refreshLayout: E,
1523
+ // Removes a single item from the masonry
1524
+ remove: ue,
1525
+ // Removes all items from the masonry
1439
1526
  removeAll: mt,
1440
- restore: dt,
1441
- restoreMany: ht,
1442
- loadNext: pe,
1443
- loadPage: Te,
1444
- refreshCurrentPage: ze,
1445
- reset: xt,
1446
- destroy: bt,
1447
- init: Ve,
1448
- restoreItems: Le,
1449
- paginationHistory: d,
1450
- cancelLoad: Ie,
1451
- scrollToTop: pt,
1452
- scrollTo: yt,
1453
- totalItems: Z(() => s.value.length),
1454
- currentBreakpoint: H
1527
+ // Removes multiple items from the masonry in a single operation
1528
+ removeMany: vt,
1529
+ // Resets the component to initial state (clears items, resets pagination, scrolls to top)
1530
+ reset: bt,
1531
+ // Restores a single item at its original index (useful for undo operations)
1532
+ restore: ft,
1533
+ // Restores multiple items at their original indices (useful for undo operations)
1534
+ restoreMany: dt,
1535
+ // Scrolls the container to a specific position
1536
+ scrollTo: wt,
1537
+ // Scrolls the container to the top
1538
+ scrollToTop: yt,
1539
+ // Sets the opaque caller context (alternative to v-model:context)
1540
+ setContext: S,
1541
+ // Sets fixed dimensions for the container, overriding ResizeObserver. Pass null to restore automatic sizing.
1542
+ setFixedDimensions: ht,
1543
+ // Computed property returning the total number of items currently in the masonry
1544
+ totalItems: K(() => h.value.length)
1455
1545
  });
1456
- const se = Q.currentSwipeIndex, ve = Q.swipeOffset, ye = Q.isDragging, le = Q.swipeContainer, Ae = Q.handleTouchStart, We = Q.handleTouchMove, Re = Q.handleTouchEnd, Oe = Q.handleMouseDown, Ee = Q.handleMouseMove, ke = Q.handleMouseUp, Pe = Q.snapToCurrentItem;
1457
- function pt(c) {
1458
- a.value && a.value.scrollTo({
1546
+ const ce = Z.currentSwipeIndex, pe = Z.swipeOffset, ye = Z.isDragging, le = Z.swipeContainer, Fe = Z.handleTouchStart, ze = Z.handleTouchMove, De = Z.handleTouchEnd, Be = Z.handleMouseDown, Te = Z.handleMouseMove, Ie = Z.handleMouseUp, Le = Z.snapToCurrentItem;
1547
+ function gt(u) {
1548
+ const B = v.value, j = typeof u == "string" ? parseInt(u, 10) : u;
1549
+ return B > 0 ? `${j * (100 / B)}%` : "0%";
1550
+ }
1551
+ function pt() {
1552
+ const u = v.value;
1553
+ return u > 0 ? `${100 / u}%` : "0%";
1554
+ }
1555
+ function yt(u) {
1556
+ s.value && s.value.scrollTo({
1459
1557
  top: 0,
1460
- behavior: (c == null ? void 0 : c.behavior) ?? "smooth",
1461
- ...c
1558
+ behavior: (u == null ? void 0 : u.behavior) ?? "smooth",
1559
+ ...u
1462
1560
  });
1463
1561
  }
1464
- function yt(c) {
1465
- a.value && (a.value.scrollTo({
1466
- top: c.top ?? a.value.scrollTop,
1467
- left: c.left ?? a.value.scrollLeft,
1468
- behavior: c.behavior ?? "auto"
1469
- }), a.value && (A.value = a.value.scrollTop, N.value = a.value.clientHeight || window.innerHeight));
1470
- }
1471
- function wt() {
1472
- $(), a.value && (A.value = a.value.scrollTop, N.value = a.value.clientHeight);
1562
+ function wt(u) {
1563
+ s.value && (s.value.scrollTo({
1564
+ top: u.top ?? s.value.scrollTop,
1565
+ left: u.left ?? s.value.scrollLeft,
1566
+ behavior: u.behavior ?? "auto"
1567
+ }), s.value && (b.value = s.value.scrollTop, H.value = s.value.clientHeight || window.innerHeight));
1473
1568
  }
1474
1569
  function xt() {
1475
- Ie(), a.value && a.value.scrollTo({
1570
+ V(), s.value && (b.value = s.value.scrollTop, H.value = s.value.clientHeight);
1571
+ }
1572
+ function bt() {
1573
+ Me(), s.value && s.value.scrollTo({
1476
1574
  top: 0,
1477
1575
  behavior: "smooth"
1478
- }), s.value = [], w.value = 0, v.value = t.loadAtPage, d.value = [t.loadAtPage], I.value = !1, f.value = null, J(), we = !1;
1576
+ }), h.value = [], c.value = 0, M.value = a.loadAtPage, L.value = [a.loadAtPage], k.value = !1, N.value = null, A.value = !1, Q();
1479
1577
  }
1480
- function bt() {
1481
- Ie(), s.value = [], P.value = 0, v.value = null, d.value = [], I.value = !1, f.value = null, M.value = !1, se.value = 0, ve.value = 0, ye.value = !1, J(), W(), a.value && a.value.scrollTo({
1578
+ function Mt() {
1579
+ Me(), h.value = [], $.value = 0, M.value = null, L.value = [], k.value = !1, N.value = null, g.value = !1, A.value = !1, ce.value = 0, pe.value = 0, ye.value = !1, Q(), l(), s.value && s.value.scrollTo({
1482
1580
  top: 0,
1483
1581
  behavior: "auto"
1484
1582
  // Instant scroll for destroy
1485
1583
  });
1486
1584
  }
1487
- const oe = Qe(async () => {
1488
- x.value || await Y();
1489
- }, 200), Ce = Qe(wt, 200);
1490
- function je() {
1491
- Q.handleWindowResize();
1585
+ const oe = Ye(async () => {
1586
+ T.value || await ie();
1587
+ }, 200), Ne = Ye(xt, 200);
1588
+ function We() {
1589
+ Z.handleWindowResize();
1492
1590
  }
1493
- function Ve(c, S, z) {
1494
- v.value = S, d.value = [S], d.value.push(z), I.value = z == null, k(c, "init"), x.value ? (s.value = [...s.value, ...c], se.value === 0 && s.value.length > 0 && (ve.value = 0)) : (u([...s.value, ...c]), a.value && (A.value = a.value.scrollTop, N.value = a.value.clientHeight || window.innerHeight), q(() => {
1495
- a.value && (A.value = a.value.scrollTop, N.value = a.value.clientHeight || window.innerHeight, D());
1496
- }));
1591
+ function Tt(u, B, j) {
1592
+ M.value = B, L.value = [B], j != null && L.value.push(j), k.value = j === null, F(u, "initialize");
1593
+ const ae = h.value, O = ae.length === 0 ? u : [...ae, ...u];
1594
+ h.value = O, T.value ? ce.value === 0 && h.value.length > 0 && (pe.value = 0) : (E(O), s.value && (b.value = s.value.scrollTop, H.value = s.value.clientHeight || window.innerHeight), X(() => {
1595
+ s.value && (b.value = s.value.scrollTop, H.value = s.value.clientHeight || window.innerHeight, _());
1596
+ })), u && u.length > 0 && (A.value = !0);
1497
1597
  }
1498
- async function Le(c, S, z) {
1499
- if (!t.skipInitialLoad) {
1500
- Ve(c, S, z);
1501
- return;
1502
- }
1503
- if (v.value = S, d.value = [S], z != null && d.value.push(z), I.value = z === null, f.value = null, k(c, "restoreItems"), x.value)
1504
- s.value = c, se.value === 0 && s.value.length > 0 && (ve.value = 0);
1505
- else if (u(c), a.value && (A.value = a.value.scrollTop, N.value = a.value.clientHeight || window.innerHeight), await q(), a.value) {
1506
- A.value = a.value.scrollTop, N.value = a.value.clientHeight || window.innerHeight, D(), await q();
1507
- const _ = be(s.value, m.value), F = _.length ? Math.max(..._) : 0, qe = a.value.scrollTop + a.value.clientHeight, Se = typeof t.loadThresholdPx == "number" ? t.loadThresholdPx : 200, Mt = Se >= 0 ? Math.max(0, F - Se) : Math.max(0, F + Se);
1508
- qe >= Mt && !I.value && !M.value && d.value.length > 0 && d.value[d.value.length - 1] != null && await Fe(_, !0);
1509
- }
1510
- }
1511
- te(
1512
- g,
1598
+ return ee(
1599
+ d,
1513
1600
  () => {
1514
- x.value || a.value && (m.value = ue(g.value, i.value), u(s.value));
1601
+ T.value || s.value && (r.value = se(d.value, o.value), E(h.value));
1515
1602
  },
1516
1603
  { deep: !0 }
1517
- ), te(() => t.layoutMode, () => {
1518
- b.value && b.value.width !== void 0 ? i.value = b.value.width : h.value && (i.value = h.value.clientWidth);
1519
- }), te(a, (c) => {
1520
- c && !x.value ? (c.removeEventListener("scroll", oe), c.addEventListener("scroll", oe, { passive: !0 })) : c && c.removeEventListener("scroll", oe);
1521
- }, { immediate: !0 });
1522
- let we = !1;
1523
- return te(
1524
- () => [t.items, t.skipInitialLoad, t.initialPage, t.initialNextPage],
1525
- ([c, S, z, _]) => {
1526
- if (S && c && c.length > 0 && !we) {
1527
- we = !0;
1528
- const F = z ?? t.loadAtPage;
1529
- Le(c, F, _ !== void 0 ? _ : void 0);
1530
- }
1604
+ ), ee(() => a.layoutMode, () => {
1605
+ y.value && y.value.width !== void 0 ? o.value = y.value.width : f.value && (o.value = f.value.clientWidth);
1606
+ }), ee(s, (u) => {
1607
+ u && !T.value ? (u.removeEventListener("scroll", oe), u.addEventListener("scroll", oe, { passive: !0 })) : u && u.removeEventListener("scroll", oe);
1608
+ }, { immediate: !0 }), ee(
1609
+ () => h.value.length,
1610
+ (u, B) => {
1611
+ a.init === "manual" && !A.value && u > 0 && B === 0 && (A.value = !0);
1531
1612
  },
1532
1613
  { immediate: !1 }
1533
- ), te(x, (c, S) => {
1534
- S === void 0 && c === !1 || q(() => {
1535
- c ? (document.addEventListener("mousemove", Ee), document.addEventListener("mouseup", ke), a.value && a.value.removeEventListener("scroll", oe), se.value = 0, ve.value = 0, s.value.length > 0 && Pe()) : (document.removeEventListener("mousemove", Ee), document.removeEventListener("mouseup", ke), a.value && h.value && (b.value && b.value.width !== void 0 ? i.value = b.value.width : i.value = h.value.clientWidth, a.value.removeEventListener("scroll", oe), a.value.addEventListener("scroll", oe, { passive: !0 }), s.value.length > 0 && (m.value = ue(g.value, i.value), u(s.value), A.value = a.value.scrollTop, N.value = a.value.clientHeight, D())));
1614
+ ), ee(T, (u, B) => {
1615
+ B === void 0 && u === !1 || X(() => {
1616
+ u ? (document.addEventListener("mousemove", Te), document.addEventListener("mouseup", Ie), s.value && s.value.removeEventListener("scroll", oe), ce.value = 0, pe.value = 0, h.value.length > 0 && Le()) : (document.removeEventListener("mousemove", Te), document.removeEventListener("mouseup", Ie), s.value && f.value && (y.value && y.value.width !== void 0 ? o.value = y.value.width : o.value = f.value.clientWidth, s.value.removeEventListener("scroll", oe), s.value.addEventListener("scroll", oe, { passive: !0 }), h.value.length > 0 && (r.value = se(d.value, o.value), E(h.value), b.value = s.value.scrollTop, H.value = s.value.clientHeight, _())));
1536
1617
  });
1537
- }, { immediate: !0 }), te(le, (c) => {
1538
- c && (c.addEventListener("touchstart", Ae, { passive: !1 }), c.addEventListener("touchmove", We, { passive: !1 }), c.addEventListener("touchend", Re), c.addEventListener("mousedown", Oe));
1539
- }), te(() => s.value.length, (c, S) => {
1540
- x.value && c > 0 && S === 0 && (se.value = 0, q(() => Pe()));
1541
- }), te(h, (c) => {
1542
- n && (n.disconnect(), n = null), c && typeof ResizeObserver < "u" ? (n = new ResizeObserver((S) => {
1543
- if (!b.value)
1544
- for (const z of S) {
1545
- const _ = z.contentRect.width, F = z.contentRect.height;
1546
- i.value !== _ && (i.value = _), w.value !== F && (w.value = F);
1618
+ }, { immediate: !0 }), ee(le, (u) => {
1619
+ u && (u.addEventListener("touchstart", Fe, { passive: !1 }), u.addEventListener("touchmove", ze, { passive: !1 }), u.addEventListener("touchend", De), u.addEventListener("mousedown", Be));
1620
+ }), ee(() => h.value.length, (u, B) => {
1621
+ T.value && u > 0 && B === 0 && (ce.value = 0, X(() => Le()));
1622
+ }), ee(f, (u) => {
1623
+ t && (t.disconnect(), t = null), u && typeof ResizeObserver < "u" ? (t = new ResizeObserver((B) => {
1624
+ if (!y.value)
1625
+ for (const j of B) {
1626
+ const ae = j.contentRect.width, O = j.contentRect.height;
1627
+ o.value !== ae && (o.value = ae), c.value !== O && (c.value = O);
1547
1628
  }
1548
- }), n.observe(c), b.value || (i.value = c.clientWidth, w.value = c.clientHeight)) : c && (b.value || (i.value = c.clientWidth, w.value = c.clientHeight));
1549
- }, { immediate: !0 }), te(i, (c, S) => {
1550
- c !== S && c > 0 && !x.value && a.value && s.value.length > 0 && q(() => {
1551
- m.value = ue(g.value, c), u(s.value), D();
1629
+ }), t.observe(u), y.value || (o.value = u.clientWidth, c.value = u.clientHeight)) : u && (y.value || (o.value = u.clientWidth, c.value = u.clientHeight));
1630
+ }, { immediate: !0 }), ee(o, (u, B) => {
1631
+ u !== B && u > 0 && !T.value && s.value && h.value.length > 0 && X(() => {
1632
+ r.value = se(d.value, u), E(h.value), _();
1552
1633
  });
1553
- }), tt(async () => {
1634
+ }), Xe(async () => {
1554
1635
  try {
1555
- await q(), h.value && !n && (i.value = h.value.clientWidth, w.value = h.value.clientHeight), x.value || (m.value = ue(g.value, i.value), a.value && (A.value = a.value.scrollTop, N.value = a.value.clientHeight));
1556
- const c = t.loadAtPage;
1557
- if (d.value = [c], !t.skipInitialLoad)
1558
- await Te(d.value[0]);
1559
- else if (t.items && t.items.length > 0) {
1560
- const S = t.initialPage !== null && t.initialPage !== void 0 ? t.initialPage : t.loadAtPage, z = t.initialNextPage !== void 0 ? t.initialNextPage : void 0;
1561
- await Le(t.items, S, z), we = !0;
1636
+ await X(), f.value && !t && (o.value = f.value.clientWidth, c.value = f.value.clientHeight), T.value || (r.value = se(d.value, o.value), s.value && (b.value = s.value.scrollTop, H.value = s.value.clientHeight));
1637
+ const u = a.loadAtPage;
1638
+ if (L.value = [u], a.init === "auto") {
1639
+ A.value = !0, await X();
1640
+ try {
1641
+ await be(u);
1642
+ } catch {
1643
+ }
1562
1644
  }
1563
- x.value ? q(() => Pe()) : D();
1564
- } catch (c) {
1565
- f.value || (console.error("Error during component initialization:", c), f.value = me(c)), M.value = !1;
1645
+ T.value ? X(() => Le()) : _();
1646
+ } catch (u) {
1647
+ N.value || (console.error("Error during component initialization:", u), N.value = me(u)), g.value = !1;
1566
1648
  }
1567
- window.addEventListener("resize", Ce), window.addEventListener("resize", je);
1568
- }), at(() => {
1569
- var c;
1570
- n && (n.disconnect(), n = null), (c = a.value) == null || c.removeEventListener("scroll", oe), window.removeEventListener("resize", Ce), window.removeEventListener("resize", je), le.value && (le.value.removeEventListener("touchstart", Ae), le.value.removeEventListener("touchmove", We), le.value.removeEventListener("touchend", Re), le.value.removeEventListener("mousedown", Oe)), document.removeEventListener("mousemove", Ee), document.removeEventListener("mouseup", ke);
1571
- }), (c, S) => (O(), R("div", {
1649
+ window.addEventListener("resize", Ne), window.addEventListener("resize", We);
1650
+ }), Ge(() => {
1651
+ var u;
1652
+ t && (t.disconnect(), t = null), (u = s.value) == null || u.removeEventListener("scroll", oe), window.removeEventListener("resize", Ne), window.removeEventListener("resize", We), le.value && (le.value.removeEventListener("touchstart", Fe), le.value.removeEventListener("touchmove", ze), le.value.removeEventListener("touchend", De), le.value.removeEventListener("mousedown", Be)), document.removeEventListener("mousemove", Te), document.removeEventListener("mouseup", Ie);
1653
+ }), (u, B) => (Y(), q("div", {
1572
1654
  ref_key: "wrapper",
1573
- ref: h,
1655
+ ref: f,
1574
1656
  class: "w-full h-full flex flex-col relative"
1575
1657
  }, [
1576
- x.value ? (O(), R("div", {
1577
- key: 0,
1578
- class: re(["overflow-hidden w-full flex-1 swipe-container touch-none select-none", { "force-motion": t.forceMotion, "cursor-grab": !U(ye), "cursor-grabbing": U(ye) }]),
1658
+ A.value ? T.value ? (Y(), q("div", {
1659
+ key: 1,
1660
+ class: re(["overflow-hidden w-full flex-1 swipe-container touch-none select-none", { "force-motion": a.forceMotion, "cursor-grab": !G(ye), "cursor-grabbing": G(ye) }]),
1579
1661
  ref_key: "swipeContainer",
1580
1662
  ref: le,
1581
1663
  style: { height: "100%", "max-height": "100%", position: "relative" }
1582
1664
  }, [
1583
- V("div", {
1665
+ U("div", {
1584
1666
  class: "relative w-full",
1585
- style: ge({
1586
- transform: `translateY(${U(ve)}px)`,
1587
- transition: U(ye) ? "none" : `transform ${e.transitionDurationMs}ms ${e.transitionEasing}`,
1588
- height: `${s.value.length * 100}%`
1667
+ style: he({
1668
+ transform: `translateY(${G(pe)}px)`,
1669
+ transition: G(ye) ? "none" : `transform ${e.transitionDurationMs}ms ${e.transitionEasing}`,
1670
+ height: `${v.value * 100}%`
1589
1671
  })
1590
1672
  }, [
1591
- (O(!0), R(Ue, null, _e(s.value, (z, _) => (O(), R("div", {
1592
- key: `${z.page}-${z.id}`,
1673
+ (Y(!0), q(Re, null, Oe(h.value, (j, ae) => (Y(), q("div", {
1674
+ key: `${j.page}-${j.id}`,
1593
1675
  class: "absolute top-0 left-0 w-full",
1594
- style: ge({
1595
- top: `${_ * (100 / s.value.length)}%`,
1596
- height: `${100 / s.value.length}%`
1676
+ style: he({
1677
+ top: gt(ae),
1678
+ height: pt()
1597
1679
  })
1598
1680
  }, [
1599
- V("div", pa, [
1600
- V("div", ya, [
1601
- X(c.$slots, "default", {
1602
- item: z,
1603
- remove: U(ce),
1604
- index: z.originalIndex ?? s.value.indexOf(z)
1681
+ U("div", wa, [
1682
+ U("div", xa, [
1683
+ J(u.$slots, "default", {
1684
+ item: j,
1685
+ remove: G(ue),
1686
+ index: j.originalIndex ?? h.value.indexOf(j)
1605
1687
  }, () => [
1606
- He(Me, {
1607
- item: z,
1608
- remove: U(ce),
1609
- "header-height": g.value.header,
1610
- "footer-height": g.value.footer,
1688
+ Se(xe, {
1689
+ item: j,
1690
+ remove: G(ue),
1691
+ "header-height": d.value.header,
1692
+ "footer-height": d.value.footer,
1611
1693
  "in-swipe-mode": !0,
1612
- "is-active": _ === U(se),
1613
- "onPreload:success": S[0] || (S[0] = (F) => T("item:preload:success", F)),
1614
- "onPreload:error": S[1] || (S[1] = (F) => T("item:preload:error", F)),
1615
- onMouseEnter: S[2] || (S[2] = (F) => T("item:mouse-enter", F)),
1616
- onMouseLeave: S[3] || (S[3] = (F) => T("item:mouse-leave", F))
1694
+ "is-active": ae === G(ce),
1695
+ "onPreload:success": B[0] || (B[0] = (O) => p("item:preload:success", O)),
1696
+ "onPreload:error": B[1] || (B[1] = (O) => p("item:preload:error", O)),
1697
+ onMouseEnter: B[2] || (B[2] = (O) => p("item:mouse-enter", O)),
1698
+ onMouseLeave: B[3] || (B[3] = (O) => p("item:mouse-leave", O))
1617
1699
  }, {
1618
- header: fe((F) => [
1619
- X(c.$slots, "item-header", de({ ref_for: !0 }, F), void 0, !0)
1700
+ header: ve((O) => [
1701
+ J(u.$slots, "item-header", fe({ ref_for: !0 }, O), void 0, !0)
1620
1702
  ]),
1621
- footer: fe((F) => [
1622
- X(c.$slots, "item-footer", de({ ref_for: !0 }, F), void 0, !0)
1703
+ footer: ve((O) => [
1704
+ J(u.$slots, "item-footer", fe({ ref_for: !0 }, O), void 0, !0)
1623
1705
  ]),
1624
1706
  _: 2
1625
1707
  }, 1032, ["item", "remove", "header-height", "footer-height", "is-active"])
@@ -1628,62 +1710,62 @@ const sa = { class: "flex-1 relative min-h-0" }, ua = { class: "w-full h-full ro
1628
1710
  ])
1629
1711
  ], 4))), 128))
1630
1712
  ], 4),
1631
- I.value && s.value.length > 0 ? (O(), R("div", wa, [
1632
- X(c.$slots, "end-message", {}, () => [
1633
- S[8] || (S[8] = V("p", { class: "text-gray-500 dark:text-gray-400" }, "You've reached the end", -1))
1713
+ k.value && h.value.length > 0 ? (Y(), q("div", ba, [
1714
+ J(u.$slots, "end-message", {}, () => [
1715
+ B[9] || (B[9] = U("p", { class: "text-gray-500 dark:text-gray-400" }, "You've reached the end", -1))
1634
1716
  ], !0)
1635
- ])) : ae("", !0),
1636
- f.value && s.value.length > 0 ? (O(), R("div", xa, [
1637
- X(c.$slots, "error-message", { error: f.value }, () => [
1638
- V("p", ba, "Failed to load content: " + Be(f.value.message), 1)
1717
+ ])) : te("", !0),
1718
+ N.value && h.value.length > 0 ? (Y(), q("div", Ma, [
1719
+ J(u.$slots, "error-message", { error: N.value }, () => [
1720
+ U("p", Ta, "Failed to load content: " + Pe(N.value.message), 1)
1639
1721
  ], !0)
1640
- ])) : ae("", !0)
1641
- ], 2)) : (O(), R("div", {
1642
- key: 1,
1643
- class: re(["overflow-auto w-full flex-1 masonry-container", { "force-motion": t.forceMotion }]),
1722
+ ])) : te("", !0)
1723
+ ], 2)) : (Y(), q("div", {
1724
+ key: 2,
1725
+ class: re(["overflow-auto w-full flex-1 masonry-container", { "force-motion": a.forceMotion }]),
1644
1726
  ref_key: "container",
1645
- ref: a
1727
+ ref: s
1646
1728
  }, [
1647
- V("div", {
1729
+ U("div", {
1648
1730
  class: "relative",
1649
- style: ge({ height: `${P.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
1731
+ style: he({ height: `${$.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
1650
1732
  }, [
1651
- He(Tt, {
1733
+ Se(It, {
1652
1734
  name: "masonry",
1653
1735
  css: !1,
1654
- onEnter: U(ot),
1655
- onBeforeEnter: U(rt),
1656
- onLeave: U(st),
1657
- onBeforeLeave: U(it)
1736
+ onEnter: G(at),
1737
+ onBeforeEnter: G(nt),
1738
+ onLeave: G(ot),
1739
+ onBeforeLeave: G(lt)
1658
1740
  }, {
1659
- default: fe(() => [
1660
- (O(!0), R(Ue, null, _e(U(G), (z, _) => (O(), R("div", de({
1661
- key: `${z.page}-${z.id}`,
1741
+ default: ve(() => [
1742
+ (Y(!0), q(Re, null, Oe(G(ne), (j, ae) => (Y(), q("div", fe({
1743
+ key: `${j.page}-${j.id}`,
1662
1744
  class: "absolute masonry-item",
1663
1745
  ref_for: !0
1664
- }, U(Zt)(z, _)), [
1665
- X(c.$slots, "default", {
1666
- item: z,
1667
- remove: U(ce),
1668
- index: z.originalIndex ?? s.value.indexOf(z)
1746
+ }, G(ea)(j, ae)), [
1747
+ J(u.$slots, "default", {
1748
+ item: j,
1749
+ remove: G(ue),
1750
+ index: j.originalIndex ?? h.value.indexOf(j)
1669
1751
  }, () => [
1670
- He(Me, {
1671
- item: z,
1672
- remove: U(ce),
1673
- "header-height": g.value.header,
1674
- "footer-height": g.value.footer,
1752
+ Se(xe, {
1753
+ item: j,
1754
+ remove: G(ue),
1755
+ "header-height": d.value.header,
1756
+ "footer-height": d.value.footer,
1675
1757
  "in-swipe-mode": !1,
1676
1758
  "is-active": !1,
1677
- "onPreload:success": S[4] || (S[4] = (F) => T("item:preload:success", F)),
1678
- "onPreload:error": S[5] || (S[5] = (F) => T("item:preload:error", F)),
1679
- onMouseEnter: S[6] || (S[6] = (F) => T("item:mouse-enter", F)),
1680
- onMouseLeave: S[7] || (S[7] = (F) => T("item:mouse-leave", F))
1759
+ "onPreload:success": B[4] || (B[4] = (O) => p("item:preload:success", O)),
1760
+ "onPreload:error": B[5] || (B[5] = (O) => p("item:preload:error", O)),
1761
+ onMouseEnter: B[6] || (B[6] = (O) => p("item:mouse-enter", O)),
1762
+ onMouseLeave: B[7] || (B[7] = (O) => p("item:mouse-leave", O))
1681
1763
  }, {
1682
- header: fe((F) => [
1683
- X(c.$slots, "item-header", de({ ref_for: !0 }, F), void 0, !0)
1764
+ header: ve((O) => [
1765
+ J(u.$slots, "item-header", fe({ ref_for: !0 }, O), void 0, !0)
1684
1766
  ]),
1685
- footer: fe((F) => [
1686
- X(c.$slots, "item-footer", de({ ref_for: !0 }, F), void 0, !0)
1767
+ footer: ve((O) => [
1768
+ J(u.$slots, "item-footer", fe({ ref_for: !0 }, O), void 0, !0)
1687
1769
  ]),
1688
1770
  _: 2
1689
1771
  }, 1032, ["item", "remove", "header-height", "footer-height"])
@@ -1693,31 +1775,35 @@ const sa = { class: "flex-1 relative min-h-0" }, ua = { class: "w-full h-full ro
1693
1775
  _: 3
1694
1776
  }, 8, ["onEnter", "onBeforeEnter", "onLeave", "onBeforeLeave"])
1695
1777
  ], 4),
1696
- I.value && s.value.length > 0 ? (O(), R("div", Ma, [
1697
- X(c.$slots, "end-message", {}, () => [
1698
- S[9] || (S[9] = V("p", { class: "text-gray-500 dark:text-gray-400" }, "You've reached the end", -1))
1778
+ k.value && h.value.length > 0 ? (Y(), q("div", Ia, [
1779
+ J(u.$slots, "end-message", {}, () => [
1780
+ B[10] || (B[10] = U("p", { class: "text-gray-500 dark:text-gray-400" }, "You've reached the end", -1))
1699
1781
  ], !0)
1700
- ])) : ae("", !0),
1701
- f.value && s.value.length > 0 ? (O(), R("div", Ta, [
1702
- X(c.$slots, "error-message", { error: f.value }, () => [
1703
- V("p", Ia, "Failed to load content: " + Be(f.value.message), 1)
1782
+ ])) : te("", !0),
1783
+ N.value && h.value.length > 0 ? (Y(), q("div", La, [
1784
+ J(u.$slots, "error-message", { error: N.value }, () => [
1785
+ U("p", Sa, "Failed to load content: " + Pe(N.value.message), 1)
1704
1786
  ], !0)
1705
- ])) : ae("", !0)
1706
- ], 2))
1787
+ ])) : te("", !0)
1788
+ ], 2)) : (Y(), q("div", ya, [
1789
+ J(u.$slots, "loading-message", {}, () => [
1790
+ B[8] || (B[8] = U("p", { class: "text-gray-500 dark:text-gray-400" }, "Waiting for content to load...", -1))
1791
+ ], !0)
1792
+ ]))
1707
1793
  ], 512));
1708
1794
  }
1709
- }), ka = (e, l) => {
1710
- const r = e.__vccOpts || e;
1711
- for (const [t, y] of l)
1712
- r[t] = y;
1713
- return r;
1714
- }, Ze = /* @__PURE__ */ ka(Ea, [["__scopeId", "data-v-2c2a4c76"]]), Ha = {
1795
+ }), Ea = (e, n) => {
1796
+ const i = e.__vccOpts || e;
1797
+ for (const [a, m] of n)
1798
+ i[a] = m;
1799
+ return i;
1800
+ }, Ue = /* @__PURE__ */ Ea(ka, [["__scopeId", "data-v-ce75570c"]]), Ha = {
1715
1801
  install(e) {
1716
- e.component("WyxosMasonry", Ze), e.component("WMasonry", Ze), e.component("WyxosMasonryItem", Me), e.component("WMasonryItem", Me);
1802
+ e.component("WyxosMasonry", Ue), e.component("WMasonry", Ue), e.component("WyxosMasonryItem", xe), e.component("WMasonryItem", xe);
1717
1803
  }
1718
1804
  };
1719
1805
  export {
1720
- Ze as Masonry,
1721
- Me as MasonryItem,
1806
+ Ue as Masonry,
1807
+ xe as MasonryItem,
1722
1808
  Ha as default
1723
1809
  };