@wyxos/vibe 1.6.20 → 1.6.22

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